From 3b5354fd3bd55d5a4598f845e846e1c7f34c65d9 Mon Sep 17 00:00:00 2001 From: cvs2svn <> Date: Thu, 18 Feb 2010 10:56:28 +0000 Subject: This commit was manufactured by cvs2svn to create branch 'gdb_7_1-branch'. Sprout from master 2010-02-18 10:56:27 UTC Matthew Gretton-Dann ' * bfd/elf32-arm.c (elf32_arm_merge_eabi_attributes): Add support for' Cherrypick from cygnus 1999-05-03 07:29:06 UTC Richard Henderson '19990502 sourceware import': README config/mt-d30v config/mt-netware config/mt-ospace etc/add-log.el etc/add-log.vi etc/configbuild.ein etc/configbuild.fig etc/configbuild.jin etc/configbuild.tin etc/configdev.ein etc/configdev.fig etc/configdev.jin etc/configdev.tin include/aout/hppa.h include/coff/sym.h include/fopen-bin.h include/fopen-same.h include/opcode/tahoe.h makefile.vms Delete: libgloss/ChangeLog libgloss/Makefile.in libgloss/README libgloss/acinclude.m4 libgloss/aclocal.m4 libgloss/arm/Makefile.in libgloss/arm/_exit.c libgloss/arm/_kill.c libgloss/arm/aclocal.m4 libgloss/arm/coff-iq80310.specs libgloss/arm/coff-pid.specs libgloss/arm/coff-rdimon.specs libgloss/arm/coff-rdpmon.specs libgloss/arm/coff-redboot.ld libgloss/arm/coff-redboot.specs libgloss/arm/configure libgloss/arm/configure.in libgloss/arm/crt0.S libgloss/arm/elf-iq80310.specs libgloss/arm/elf-linux.specs libgloss/arm/elf-pid.specs libgloss/arm/elf-rdimon.specs libgloss/arm/elf-rdpmon.specs libgloss/arm/elf-redboot.ld libgloss/arm/elf-redboot.specs libgloss/arm/libcfunc.c libgloss/arm/linux-crt0.c libgloss/arm/linux-syscall.h libgloss/arm/linux-syscalls0.S libgloss/arm/linux-syscalls1.c libgloss/arm/redboot-crt0.S libgloss/arm/redboot-syscalls.c libgloss/arm/swi.h libgloss/arm/syscall.h libgloss/arm/syscalls.c libgloss/arm/trap.S libgloss/bfin/Makefile.in libgloss/bfin/aclocal.m4 libgloss/bfin/basiccrt.S libgloss/bfin/bf512.ld libgloss/bfin/bf514.ld libgloss/bfin/bf516.ld libgloss/bfin/bf518.ld libgloss/bfin/bf522.ld libgloss/bfin/bf523.ld libgloss/bfin/bf524.ld libgloss/bfin/bf525.ld libgloss/bfin/bf526.ld libgloss/bfin/bf527.ld libgloss/bfin/bf531.ld libgloss/bfin/bf532.ld libgloss/bfin/bf533.ld libgloss/bfin/bf534.ld libgloss/bfin/bf536.ld libgloss/bfin/bf537.ld libgloss/bfin/bf538.ld libgloss/bfin/bf539.ld libgloss/bfin/bf542.ld libgloss/bfin/bf544.ld libgloss/bfin/bf547.ld libgloss/bfin/bf548.ld libgloss/bfin/bf549.ld libgloss/bfin/bf561.ld libgloss/bfin/bf561a.ld libgloss/bfin/bf561b.ld libgloss/bfin/bf561m.ld libgloss/bfin/bfin-common-mc.ld libgloss/bfin/bfin-common-sc.ld libgloss/bfin/configure libgloss/bfin/configure.in libgloss/bfin/crt0.S libgloss/bfin/include/blackfin.h libgloss/bfin/include/ccblkfn.h libgloss/bfin/include/cdefBF512.h libgloss/bfin/include/cdefBF514.h libgloss/bfin/include/cdefBF516.h libgloss/bfin/include/cdefBF518.h libgloss/bfin/include/cdefBF51x_base.h libgloss/bfin/include/cdefBF522.h libgloss/bfin/include/cdefBF523.h libgloss/bfin/include/cdefBF524.h libgloss/bfin/include/cdefBF525.h libgloss/bfin/include/cdefBF526.h libgloss/bfin/include/cdefBF527.h libgloss/bfin/include/cdefBF52x_base.h libgloss/bfin/include/cdefBF531.h libgloss/bfin/include/cdefBF532.h libgloss/bfin/include/cdefBF533.h libgloss/bfin/include/cdefBF534.h libgloss/bfin/include/cdefBF535.h libgloss/bfin/include/cdefBF536.h libgloss/bfin/include/cdefBF537.h libgloss/bfin/include/cdefBF538.h libgloss/bfin/include/cdefBF539.h libgloss/bfin/include/cdefBF53x.h libgloss/bfin/include/cdefBF541.h libgloss/bfin/include/cdefBF542.h libgloss/bfin/include/cdefBF542M.h libgloss/bfin/include/cdefBF544.h libgloss/bfin/include/cdefBF544M.h libgloss/bfin/include/cdefBF547.h libgloss/bfin/include/cdefBF547M.h libgloss/bfin/include/cdefBF548.h libgloss/bfin/include/cdefBF548M.h libgloss/bfin/include/cdefBF549.h libgloss/bfin/include/cdefBF549M.h libgloss/bfin/include/cdefBF54x_base.h libgloss/bfin/include/cdefBF561.h libgloss/bfin/include/cdef_LPBlackfin.h libgloss/bfin/include/cdefblackfin.h libgloss/bfin/include/cplb.h libgloss/bfin/include/cplbtab.h libgloss/bfin/include/defBF512.h libgloss/bfin/include/defBF514.h libgloss/bfin/include/defBF516.h libgloss/bfin/include/defBF518.h libgloss/bfin/include/defBF51x_base.h libgloss/bfin/include/defBF522.h libgloss/bfin/include/defBF523.h libgloss/bfin/include/defBF524.h libgloss/bfin/include/defBF525.h libgloss/bfin/include/defBF526.h libgloss/bfin/include/defBF527.h libgloss/bfin/include/defBF52x_base.h libgloss/bfin/include/defBF531.h libgloss/bfin/include/defBF532.h libgloss/bfin/include/defBF533.h libgloss/bfin/include/defBF534.h libgloss/bfin/include/defBF535.h libgloss/bfin/include/defBF536.h libgloss/bfin/include/defBF537.h libgloss/bfin/include/defBF538.h libgloss/bfin/include/defBF539.h libgloss/bfin/include/defBF541.h libgloss/bfin/include/defBF542.h libgloss/bfin/include/defBF542M.h libgloss/bfin/include/defBF544.h libgloss/bfin/include/defBF544M.h libgloss/bfin/include/defBF547.h libgloss/bfin/include/defBF547M.h libgloss/bfin/include/defBF548.h libgloss/bfin/include/defBF548M.h libgloss/bfin/include/defBF549.h libgloss/bfin/include/defBF549M.h libgloss/bfin/include/defBF54x_base.h libgloss/bfin/include/defBF561.h libgloss/bfin/include/def_LPBlackfin.h libgloss/bfin/include/defblackfin.h libgloss/bfin/include/sys/_adi_platform.h libgloss/bfin/include/sys/anomaly_macros_rtl.h libgloss/bfin/include/sys/excause.h libgloss/bfin/include/sys/exception.h libgloss/bfin/include/sys/mc_typedef.h libgloss/bfin/include/sys/platform.h libgloss/bfin/include/sys/pll.h libgloss/bfin/include/sysreg.h libgloss/bfin/syscalls.c libgloss/close.c libgloss/config/default.mh libgloss/config/default.mt libgloss/config/dos.mh libgloss/config/mips.mt libgloss/config/mn10200.mt libgloss/config/mn10300.mt libgloss/config/ppc.mh libgloss/configure libgloss/configure.in libgloss/cris/Makefile.in libgloss/cris/aclocal.m4 libgloss/cris/configure libgloss/cris/configure.in libgloss/cris/crt0.S libgloss/cris/crti.c libgloss/cris/crtn.c libgloss/cris/gensyscalls libgloss/cris/irqtable.S libgloss/cris/lcrt0.c libgloss/cris/linunistd.h libgloss/cris/outbyte.c libgloss/cris/setup.S libgloss/crx/Makefile.in libgloss/crx/_exit.c libgloss/crx/_getenv.c libgloss/crx/_rename.c libgloss/crx/aclocal.m4 libgloss/crx/close.c libgloss/crx/configure libgloss/crx/configure.in libgloss/crx/crt0.S libgloss/crx/crti.S libgloss/crx/crtn.S libgloss/crx/dvz_hndl.c libgloss/crx/flg_hndl.c libgloss/crx/fstat.c libgloss/crx/getpid.c libgloss/crx/iad_hndl.c libgloss/crx/intable.c libgloss/crx/isatty.c libgloss/crx/kill.c libgloss/crx/lseek.c libgloss/crx/open.c libgloss/crx/putnum.c libgloss/crx/read.c libgloss/crx/sbrk.c libgloss/crx/sim.ld libgloss/crx/stat.c libgloss/crx/svc_hndl.c libgloss/crx/time.c libgloss/crx/und_hndl.c libgloss/crx/unlink.c libgloss/crx/write.c libgloss/d30v/Makefile.in libgloss/d30v/aclocal.m4 libgloss/d30v/configure libgloss/d30v/configure.in libgloss/d30v/crt0.S libgloss/d30v/inbyte.c libgloss/d30v/outbyte.c libgloss/d30v/syscalls.c libgloss/debug.c libgloss/debug.h libgloss/doc/Makefile.in libgloss/doc/configure libgloss/doc/configure.in libgloss/doc/porting.texi libgloss/fr30/Makefile.in libgloss/fr30/aclocal.m4 libgloss/fr30/configure libgloss/fr30/configure.in libgloss/fr30/crt0.s libgloss/fr30/syscalls.c libgloss/frv/Makefile.in libgloss/frv/aclocal.m4 libgloss/frv/configure libgloss/frv/configure.in libgloss/frv/crt0.S libgloss/frv/fstat.c libgloss/frv/getpid.c libgloss/frv/isatty.c libgloss/frv/kill.c libgloss/frv/print.c libgloss/frv/putnum.c libgloss/frv/sbrk.c libgloss/frv/sim-close.S libgloss/frv/sim-exit.S libgloss/frv/sim-inbyte.c libgloss/frv/sim-lseek.S libgloss/frv/sim-open.S libgloss/frv/sim-read.S libgloss/frv/sim-time.c libgloss/frv/sim-unlink.S libgloss/frv/sim-write.S libgloss/frv/stat.c libgloss/fstat.c libgloss/getpid.c libgloss/glue.h libgloss/hp74x/Makefile.in libgloss/hp74x/README libgloss/hp74x/aclocal.m4 libgloss/hp74x/checksum.c libgloss/hp74x/configure libgloss/hp74x/configure.in libgloss/hp74x/crt0.s libgloss/hp74x/debugger.h libgloss/hp74x/debugger.s libgloss/hp74x/diagnose.h libgloss/hp74x/hppa-defs.h libgloss/hp74x/hppa.ld libgloss/hp74x/io.c libgloss/hp74x/iva_table.h libgloss/hp74x/iva_table.s libgloss/hp74x/pa_stub.c libgloss/hp74x/test.c libgloss/i386/Makefile.in libgloss/i386/aclocal.m4 libgloss/i386/configure libgloss/i386/configure.in libgloss/i386/cygmon-crt0.S libgloss/i386/cygmon-gmon.c libgloss/i386/cygmon-gmon.h libgloss/i386/cygmon-salib.c libgloss/i386/cygmon-syscall.h libgloss/i386/cygmon.ld libgloss/i960/Makefile.in libgloss/i960/aclocal.m4 libgloss/i960/asm.h libgloss/i960/configure libgloss/i960/configure.in libgloss/i960/crt0.c libgloss/i960/mon-read.c libgloss/i960/mon-syscalls.S libgloss/i960/mon-write.c libgloss/i960/mon960.c libgloss/i960/mon960.ld libgloss/i960/syscall.h libgloss/iq2000/Makefile.in libgloss/iq2000/_exit.c libgloss/iq2000/access.c libgloss/iq2000/aclocal.m4 libgloss/iq2000/chmod.c libgloss/iq2000/chown.c libgloss/iq2000/close.c libgloss/iq2000/configure libgloss/iq2000/configure.in libgloss/iq2000/creat.c libgloss/iq2000/crt0.S libgloss/iq2000/crt1.c libgloss/iq2000/execv.c libgloss/iq2000/execve.c libgloss/iq2000/fork.c libgloss/iq2000/fstat.c libgloss/iq2000/getpid.c libgloss/iq2000/gettime.c libgloss/iq2000/isatty.c libgloss/iq2000/kill.c libgloss/iq2000/lseek.c libgloss/iq2000/open.c libgloss/iq2000/pipe.c libgloss/iq2000/read.c libgloss/iq2000/sbrk.c libgloss/iq2000/sim.ld libgloss/iq2000/stat.c libgloss/iq2000/test.c libgloss/iq2000/time.c libgloss/iq2000/times.c libgloss/iq2000/trap.c libgloss/iq2000/trap.h libgloss/iq2000/unlink.c libgloss/iq2000/utime.c libgloss/iq2000/wait.c libgloss/iq2000/write.c libgloss/isatty.c libgloss/kill.c libgloss/libnosys/Makefile.in libgloss/libnosys/_exit.c libgloss/libnosys/acconfig.h libgloss/libnosys/aclocal.m4 libgloss/libnosys/chown.c libgloss/libnosys/close.c libgloss/libnosys/config.h.in libgloss/libnosys/configure libgloss/libnosys/configure.in libgloss/libnosys/environ.c libgloss/libnosys/errno.c libgloss/libnosys/execve.c libgloss/libnosys/fork.c libgloss/libnosys/fstat.c libgloss/libnosys/getpid.c libgloss/libnosys/gettod.c libgloss/libnosys/isatty.c libgloss/libnosys/kill.c libgloss/libnosys/link.c libgloss/libnosys/lseek.c libgloss/libnosys/open.c libgloss/libnosys/read.c libgloss/libnosys/readlink.c libgloss/libnosys/sbrk.c libgloss/libnosys/stat.c libgloss/libnosys/symlink.c libgloss/libnosys/times.c libgloss/libnosys/unlink.c libgloss/libnosys/wait.c libgloss/libnosys/warning.h libgloss/libnosys/write.c libgloss/lm32/Makefile.in libgloss/lm32/aclocal.m4 libgloss/lm32/configure libgloss/lm32/configure.in libgloss/lm32/crt0.S libgloss/lm32/isatty.c libgloss/lm32/scall.S libgloss/lm32/sim.ld libgloss/lseek.c libgloss/m32c/Makefile.in libgloss/m32c/abort.S libgloss/m32c/aclocal.m4 libgloss/m32c/argv.S libgloss/m32c/argvlen.S libgloss/m32c/chdir.S libgloss/m32c/chmod.S libgloss/m32c/close.S libgloss/m32c/configure libgloss/m32c/configure.in libgloss/m32c/crt0.S libgloss/m32c/crtn.S libgloss/m32c/exit.S libgloss/m32c/fstat.S libgloss/m32c/genscript libgloss/m32c/getpid.S libgloss/m32c/gettimeofday.S libgloss/m32c/heaptop.S libgloss/m32c/isatty.S libgloss/m32c/kill.S libgloss/m32c/link.S libgloss/m32c/lseek.S libgloss/m32c/m32c.tmpl libgloss/m32c/m32csys.h libgloss/m32c/open.S libgloss/m32c/read.S libgloss/m32c/sample.c libgloss/m32c/sbrk.c libgloss/m32c/stat.S libgloss/m32c/time.S libgloss/m32c/times.S libgloss/m32c/unlink.S libgloss/m32c/utime.S libgloss/m32c/varvects.S libgloss/m32c/varvects.h libgloss/m32c/write.S libgloss/m32r/Makefile.in libgloss/m32r/aclocal.m4 libgloss/m32r/chmod.c libgloss/m32r/close.c libgloss/m32r/configure libgloss/m32r/configure.in libgloss/m32r/crt0.S libgloss/m32r/eit.h libgloss/m32r/eva-stub.ld libgloss/m32r/eva.ld libgloss/m32r/exit.c libgloss/m32r/fstat.c libgloss/m32r/getpid.c libgloss/m32r/isatty.c libgloss/m32r/kill.c libgloss/m32r/lseek.c libgloss/m32r/m32r-lib.c libgloss/m32r/m32r-stub.c libgloss/m32r/mon.specs libgloss/m32r/open.c libgloss/m32r/raise.c libgloss/m32r/read.c libgloss/m32r/sbrk.c libgloss/m32r/stat.c libgloss/m32r/trap0.S libgloss/m32r/trapmon0.c libgloss/m32r/unlink.c libgloss/m32r/utime.c libgloss/m32r/write.c libgloss/m68hc11/Makefile.in libgloss/m68hc11/aclocal.m4 libgloss/m68hc11/configure libgloss/m68hc11/configure.in libgloss/m68hc11/crt0.S libgloss/m68hc11/sci-inout.S libgloss/m68hc11/sim-valid-m68hc11.ld libgloss/m68hc11/sim-valid-m68hc12.ld libgloss/m68hc11/syscalls.c libgloss/m68k/Makefile.in libgloss/m68k/README libgloss/m68k/aclocal.m4 libgloss/m68k/asm.h libgloss/m68k/bcc.ld libgloss/m68k/cf-crt0.S libgloss/m68k/cf-crt1.c libgloss/m68k/cf-exit.c libgloss/m68k/cf-hosted.S libgloss/m68k/cf-isrs.c libgloss/m68k/cf-isv.S libgloss/m68k/cf-sbrk.c libgloss/m68k/cf.sc libgloss/m68k/configure libgloss/m68k/configure.in libgloss/m68k/cpu32bug.S libgloss/m68k/cpu32bug.h libgloss/m68k/crt0.S libgloss/m68k/dtor.C libgloss/m68k/fido-_exit.c libgloss/m68k/fido-crt0.S libgloss/m68k/fido-handler.c libgloss/m68k/fido-hosted.S libgloss/m68k/fido-sbrk.c libgloss/m68k/fido.h libgloss/m68k/fido.sc libgloss/m68k/fido_profiling.h libgloss/m68k/idp-inbyte.c libgloss/m68k/idp-outbyte.c libgloss/m68k/idp.ld libgloss/m68k/idpgdb.ld libgloss/m68k/io-close.c libgloss/m68k/io-exit.c libgloss/m68k/io-fstat.c libgloss/m68k/io-gdb.c libgloss/m68k/io-gettimeofday.c libgloss/m68k/io-isatty.c libgloss/m68k/io-lseek.c libgloss/m68k/io-open.c libgloss/m68k/io-read.c libgloss/m68k/io-rename.c libgloss/m68k/io-stat.c libgloss/m68k/io-system.c libgloss/m68k/io-time.c libgloss/m68k/io-unlink.c libgloss/m68k/io-write.c libgloss/m68k/io.h libgloss/m68k/leds.c libgloss/m68k/leds.h libgloss/m68k/mc68681reg.h libgloss/m68k/mc68ec.c libgloss/m68k/mvme-stub.c libgloss/m68k/mvme.S libgloss/m68k/mvme135-asm.S libgloss/m68k/mvme135.ld libgloss/m68k/mvme162.ld libgloss/m68k/mvme162lx-asm.S libgloss/m68k/sbc5204.ld libgloss/m68k/sbc5206.ld libgloss/m68k/sim-abort.c libgloss/m68k/sim-crt0.S libgloss/m68k/sim-errno.c libgloss/m68k/sim-funcs.c libgloss/m68k/sim-inbyte.c libgloss/m68k/sim-print.c libgloss/m68k/sim-sbrk.c libgloss/m68k/sim.ld libgloss/m68k/simulator.S libgloss/m68k/test.c libgloss/mcore/Makefile.in libgloss/mcore/aclocal.m4 libgloss/mcore/close.c libgloss/mcore/cmb-exit.c libgloss/mcore/cmb-inbyte.c libgloss/mcore/cmb-outbyte.c libgloss/mcore/configure libgloss/mcore/configure.in libgloss/mcore/crt0.S libgloss/mcore/elf-cmb.ld libgloss/mcore/elf-cmb.specs libgloss/mcore/fstat.c libgloss/mcore/getpid.c libgloss/mcore/kill.c libgloss/mcore/lseek.c libgloss/mcore/open.c libgloss/mcore/pe-cmb.ld libgloss/mcore/pe-cmb.specs libgloss/mcore/print.c libgloss/mcore/putnum.c libgloss/mcore/raise.c libgloss/mcore/read.c libgloss/mcore/sbrk.c libgloss/mcore/stat.c libgloss/mcore/syscalls.S libgloss/mcore/unlink.c libgloss/mcore/write.c libgloss/mep/Makefile.in libgloss/mep/aclocal.m4 libgloss/mep/configure libgloss/mep/configure.in libgloss/mep/crt0.S libgloss/mep/crtn.S libgloss/mep/default.ld libgloss/mep/fmax.ld libgloss/mep/gcov-io.h libgloss/mep/gmap_default.ld libgloss/mep/h_reset.c libgloss/mep/handlers.c libgloss/mep/isatty.c libgloss/mep/mep-bb.c libgloss/mep/mep-gmon.c libgloss/mep/min.ld libgloss/mep/read.c libgloss/mep/sbrk.c libgloss/mep/sdram-crt0.S libgloss/mep/sim-crt0.S libgloss/mep/sim-crtn.S libgloss/mep/simnovec-crt0.S libgloss/mep/simple.ld libgloss/mep/simsdram-crt0.S libgloss/mep/syscalls.S libgloss/mep/write.c libgloss/microblaze/Makefile.in libgloss/microblaze/_exception_handler.S libgloss/microblaze/_hw_exception_handler.S libgloss/microblaze/_interrupt_handler.S libgloss/microblaze/_program_clean.S libgloss/microblaze/_program_init.S libgloss/microblaze/configure libgloss/microblaze/configure.in libgloss/microblaze/crt0.S libgloss/microblaze/crt1.S libgloss/microblaze/crt2.S libgloss/microblaze/crt3.S libgloss/microblaze/crt4.S libgloss/microblaze/crtinit.S libgloss/microblaze/pgcrtinit.S libgloss/microblaze/sbrk.c libgloss/microblaze/sim-crtinit.S libgloss/microblaze/sim-pgcrtinit.S libgloss/microblaze/timer.c libgloss/microblaze/xil_malloc.c libgloss/microblaze/xil_sbrk.c libgloss/microblaze/xilinx.ld libgloss/mips/Makefile.in libgloss/mips/aclocal.m4 libgloss/mips/array-io.c libgloss/mips/array.ld libgloss/mips/cfe.c libgloss/mips/cfe.ld libgloss/mips/cfe_api.c libgloss/mips/cfe_api.h libgloss/mips/cfe_api_int.h libgloss/mips/cfe_error.h libgloss/mips/cfe_mem.c libgloss/mips/cma101.c libgloss/mips/configure libgloss/mips/configure.in libgloss/mips/crt0.S libgloss/mips/crt0_cfe.S libgloss/mips/crt0_cygmon.S libgloss/mips/cygmon.c libgloss/mips/ddb-kseg0.ld libgloss/mips/ddb.ld libgloss/mips/dtor.C libgloss/mips/dve.ld libgloss/mips/dvemon.c libgloss/mips/entry.S libgloss/mips/idt.ld libgloss/mips/idt32.ld libgloss/mips/idt64.ld libgloss/mips/idtecoff.ld libgloss/mips/idtmon.S libgloss/mips/jmr3904-io.c libgloss/mips/jmr3904app-java.ld libgloss/mips/jmr3904app.ld libgloss/mips/jmr3904dram-java.ld libgloss/mips/jmr3904dram.ld libgloss/mips/lsi.ld libgloss/mips/lsipmon.S libgloss/mips/nullmon.c libgloss/mips/nullmon.ld libgloss/mips/pmon.S libgloss/mips/pmon.ld libgloss/mips/regs.S libgloss/mips/syscalls.c libgloss/mips/test.c libgloss/mips/vr4300.S libgloss/mips/vr5xxx.S libgloss/mn10200/Makefile.in libgloss/mn10200/_exit.c libgloss/mn10200/access.c libgloss/mn10200/aclocal.m4 libgloss/mn10200/chmod.c libgloss/mn10200/chown.c libgloss/mn10200/close.c libgloss/mn10200/configure libgloss/mn10200/configure.in libgloss/mn10200/creat.c libgloss/mn10200/crt0.S libgloss/mn10200/crt1.c libgloss/mn10200/eval.ld libgloss/mn10200/execv.c libgloss/mn10200/execve.c libgloss/mn10200/fork.c libgloss/mn10200/fstat.c libgloss/mn10200/getpid.c libgloss/mn10200/gettime.c libgloss/mn10200/isatty.c libgloss/mn10200/kill.c libgloss/mn10200/lseek.c libgloss/mn10200/open.c libgloss/mn10200/pipe.c libgloss/mn10200/read.c libgloss/mn10200/sbrk.c libgloss/mn10200/sim.ld libgloss/mn10200/stat.c libgloss/mn10200/test.c libgloss/mn10200/time.c libgloss/mn10200/times.c libgloss/mn10200/trap.S libgloss/mn10200/trap.h libgloss/mn10200/unlink.c libgloss/mn10200/utime.c libgloss/mn10200/wait.c libgloss/mn10200/write.c libgloss/mn10300/Makefile.in libgloss/mn10300/_exit.c libgloss/mn10300/access.c libgloss/mn10300/aclocal.m4 libgloss/mn10300/asb2303.ld libgloss/mn10300/asb2305.ld libgloss/mn10300/chmod.c libgloss/mn10300/chown.c libgloss/mn10300/close.c libgloss/mn10300/configure libgloss/mn10300/configure.in libgloss/mn10300/creat.c libgloss/mn10300/crt0-eval.S libgloss/mn10300/crt0.S libgloss/mn10300/crt0_cygmon.S libgloss/mn10300/crt0_redboot.S libgloss/mn10300/crt1.c libgloss/mn10300/cygmon.c libgloss/mn10300/eval.ld libgloss/mn10300/execv.c libgloss/mn10300/execve.c libgloss/mn10300/fork.c libgloss/mn10300/fstat.c libgloss/mn10300/getpid.c libgloss/mn10300/gettime.c libgloss/mn10300/isatty.c libgloss/mn10300/kill.c libgloss/mn10300/lseek.c libgloss/mn10300/open.c libgloss/mn10300/pipe.c libgloss/mn10300/read.c libgloss/mn10300/sbrk.c libgloss/mn10300/sim.ld libgloss/mn10300/stat.c libgloss/mn10300/test.c libgloss/mn10300/time.c libgloss/mn10300/times.c libgloss/mn10300/trap.S libgloss/mn10300/trap.h libgloss/mn10300/unlink.c libgloss/mn10300/utime.c libgloss/mn10300/wait.c libgloss/mn10300/write.c libgloss/moxie/Makefile.in libgloss/moxie/aclocal.m4 libgloss/moxie/configure libgloss/moxie/configure.in libgloss/moxie/crt0.S libgloss/moxie/fstat.c libgloss/moxie/getpid.c libgloss/moxie/isatty.c libgloss/moxie/kill.c libgloss/moxie/moxie-elf-common.ld libgloss/moxie/print.c libgloss/moxie/putnum.c libgloss/moxie/qemu-time.c libgloss/moxie/qemu-write.c libgloss/moxie/qemu.ld libgloss/moxie/sbrk.c libgloss/moxie/sim-close.S libgloss/moxie/sim-exit.S libgloss/moxie/sim-inbyte.c libgloss/moxie/sim-lseek.S libgloss/moxie/sim-lseek.c libgloss/moxie/sim-open.S libgloss/moxie/sim-read.S libgloss/moxie/sim-time.c libgloss/moxie/sim-unlink.S libgloss/moxie/sim-write.S libgloss/moxie/sim.ld libgloss/moxie/stat.c libgloss/mt/16-002.ld libgloss/mt/16-003.ld libgloss/mt/64-001.ld libgloss/mt/Makefile.in libgloss/mt/access.c libgloss/mt/aclocal.m4 libgloss/mt/chmod.c libgloss/mt/close.c libgloss/mt/configure libgloss/mt/configure.in libgloss/mt/crt0-16-002.S libgloss/mt/crt0-16-003.S libgloss/mt/crt0-64-001.S libgloss/mt/crt0-ms2.S libgloss/mt/crt0.S libgloss/mt/exit-16-002.c libgloss/mt/exit-16-003.c libgloss/mt/exit-64-001.c libgloss/mt/exit-ms2.c libgloss/mt/exit.c libgloss/mt/fstat.c libgloss/mt/getpid.c libgloss/mt/gettime.c libgloss/mt/isatty.c libgloss/mt/kill.c libgloss/mt/lseek.c libgloss/mt/ms2.ld libgloss/mt/open.c libgloss/mt/read.c libgloss/mt/sbrk.c libgloss/mt/startup-16-002.S libgloss/mt/startup-16-003.S libgloss/mt/startup-64-001.S libgloss/mt/startup-ms2.S libgloss/mt/stat.c libgloss/mt/time.c libgloss/mt/times.c libgloss/mt/trap.S libgloss/mt/trap.h libgloss/mt/unlink.c libgloss/mt/utime.c libgloss/mt/write.c libgloss/open.c libgloss/pa/Makefile.in libgloss/pa/README libgloss/pa/aclocal.m4 libgloss/pa/configure libgloss/pa/configure.in libgloss/pa/crt0.S libgloss/pa/hp-milli.s libgloss/pa/op50n-io.S libgloss/pa/op50n.h libgloss/pa/op50n.ld libgloss/pa/op50nled.c libgloss/pa/setjmp.S libgloss/pa/test.c libgloss/pa/w89k-io.c libgloss/pa/w89k.h libgloss/pa/w89k.ld libgloss/print.c libgloss/putnum.c libgloss/read.c libgloss/rs6000/Makefile.in libgloss/rs6000/aclocal.m4 libgloss/rs6000/ads-exit.S libgloss/rs6000/ads-io.c libgloss/rs6000/ads.ld libgloss/rs6000/configure libgloss/rs6000/configure.in libgloss/rs6000/crt0.S libgloss/rs6000/mbx-exit.c libgloss/rs6000/mbx-inbyte.c libgloss/rs6000/mbx-outbyte.c libgloss/rs6000/mbx-print.c libgloss/rs6000/mbx.ld libgloss/rs6000/mbx.specs libgloss/rs6000/mcount.S libgloss/rs6000/mvme-errno.c libgloss/rs6000/mvme-exit.S libgloss/rs6000/mvme-inbyte.S libgloss/rs6000/mvme-outbyte.S libgloss/rs6000/mvme-print.c libgloss/rs6000/mvme-read.c libgloss/rs6000/sim-abort.c libgloss/rs6000/sim-crt0.S libgloss/rs6000/sim-errno.c libgloss/rs6000/sim-getrusage.S libgloss/rs6000/sim-inbyte.c libgloss/rs6000/sim-print.c libgloss/rs6000/sim-sbrk.c libgloss/rs6000/simulator.S libgloss/rs6000/sol-cfuncs.c libgloss/rs6000/sol-syscall.S libgloss/rs6000/test.c libgloss/rs6000/xil-crt0.S libgloss/rs6000/xilinx.ld libgloss/rs6000/xilinx440.ld libgloss/rs6000/yellowknife.ld libgloss/rx/Makefile.in libgloss/rx/abort.S libgloss/rx/argv.S libgloss/rx/argvlen.S libgloss/rx/chdir.S libgloss/rx/chmod.S libgloss/rx/close.S libgloss/rx/configure libgloss/rx/configure.in libgloss/rx/crt0.S libgloss/rx/crtn.S libgloss/rx/exit.S libgloss/rx/fstat.S libgloss/rx/gcrt0.S libgloss/rx/getpid.S libgloss/rx/gettimeofday.S libgloss/rx/heaptop.S libgloss/rx/isatty.S libgloss/rx/kill.S libgloss/rx/link.S libgloss/rx/lseek.S libgloss/rx/mcount.c libgloss/rx/open.S libgloss/rx/read.S libgloss/rx/rx-sim.ld libgloss/rx/rx.ld libgloss/rx/rxsys.h libgloss/rx/sbrk.c libgloss/rx/sigprocmask.S libgloss/rx/sleep.S libgloss/rx/stat.S libgloss/rx/time.S libgloss/rx/times.S libgloss/rx/unlink.S libgloss/rx/utime.S libgloss/rx/write.S libgloss/sbrk.c libgloss/sh/sh1lcevb.ld libgloss/sh/sh2lcevb.ld libgloss/sh/sh3bb.ld libgloss/sh/sh3lcevb.ld libgloss/sparc/Makefile.in libgloss/sparc/aclocal.m4 libgloss/sparc/asm.h libgloss/sparc/cache.c libgloss/sparc/configure libgloss/sparc/configure.in libgloss/sparc/crt0-701.S libgloss/sparc/crt0.S libgloss/sparc/cygmon-crt0.S libgloss/sparc/cygmon-salib.c libgloss/sparc/cygmon-sparc64-ld.src libgloss/sparc/cygmon.ld.src libgloss/sparc/dtor.C libgloss/sparc/elfsim.ld libgloss/sparc/erc32-crt0.S libgloss/sparc/erc32-io.c libgloss/sparc/erc32-stub.c libgloss/sparc/erc32.ld libgloss/sparc/ex930.ld libgloss/sparc/ex931.ld libgloss/sparc/ex934.ld libgloss/sparc/fixctors.c libgloss/sparc/libsys/Makefile.in libgloss/sparc/libsys/_exit.S libgloss/sparc/libsys/aclocal.m4 libgloss/sparc/libsys/cerror.S libgloss/sparc/libsys/configure libgloss/sparc/libsys/configure.in libgloss/sparc/libsys/isatty.c libgloss/sparc/libsys/libsys-crt0.S libgloss/sparc/libsys/sbrk.S libgloss/sparc/libsys/syscall.h libgloss/sparc/libsys/syscallasm.h libgloss/sparc/libsys/template.S libgloss/sparc/libsys/template_r.S libgloss/sparc/salib-701.c libgloss/sparc/salib.c libgloss/sparc/slite.h libgloss/sparc/sparc-stub.c libgloss/sparc/sparc86x.ld libgloss/sparc/sparcl-stub.c libgloss/sparc/sparclet-stub.c libgloss/sparc/sparclite.h libgloss/sparc/sysc-701.c libgloss/sparc/syscalls.c libgloss/sparc/test.c libgloss/sparc/traps.S libgloss/sparc/tsc701.ld libgloss/spu/Makefile.in libgloss/spu/access.c libgloss/spu/aclocal.m4 libgloss/spu/chdir.c libgloss/spu/chmod.c libgloss/spu/chown.c libgloss/spu/close.c libgloss/spu/configure libgloss/spu/configure.in libgloss/spu/conv_stat.c libgloss/spu/crt0.S libgloss/spu/crti.S libgloss/spu/crtn.S libgloss/spu/dirfuncs.c libgloss/spu/dup.c libgloss/spu/dup2.c libgloss/spu/exit.c libgloss/spu/fchdir.c libgloss/spu/fchmod.c libgloss/spu/fchown.c libgloss/spu/fdatasync.c libgloss/spu/fstat.c libgloss/spu/fsync.c libgloss/spu/ftruncate.c libgloss/spu/getcwd.c libgloss/spu/getitimer.c libgloss/spu/getpagesize.c libgloss/spu/getpid.c libgloss/spu/gettimeofday.c libgloss/spu/isatty.c libgloss/spu/jsre.h libgloss/spu/kill.c libgloss/spu/lchown.c libgloss/spu/link.c libgloss/spu/linux_getpid.c libgloss/spu/linux_gettid.c libgloss/spu/linux_syscalls.c libgloss/spu/lockf.c libgloss/spu/lseek.c libgloss/spu/lstat.c libgloss/spu/mkdir.c libgloss/spu/mknod.c libgloss/spu/mkstemp.c libgloss/spu/mktemp.c libgloss/spu/mmap_eaddr.c libgloss/spu/mremap_eaddr.c libgloss/spu/msync_eaddr.c libgloss/spu/munmap_eaddr.c libgloss/spu/nanosleep.c libgloss/spu/open.c libgloss/spu/pread.c libgloss/spu/pwrite.c libgloss/spu/read.c libgloss/spu/readlink.c libgloss/spu/readv.c libgloss/spu/rmdir.c libgloss/spu/sbrk.c libgloss/spu/sched_yield.c libgloss/spu/setitimer.c libgloss/spu/shm_open.c libgloss/spu/shm_unlink.c libgloss/spu/stat.c libgloss/spu/symlink.c libgloss/spu/sync.c libgloss/spu/syscalls.c libgloss/spu/times.c libgloss/spu/truncate.c libgloss/spu/umask.c libgloss/spu/unlink.c libgloss/spu/utime.c libgloss/spu/utimes.c libgloss/spu/write.c libgloss/spu/writev.c libgloss/stat.c libgloss/syscall.h libgloss/testsuite/Makefile.in libgloss/testsuite/config/hppa.mt libgloss/testsuite/config/m68k.mt libgloss/testsuite/config/mips.mt libgloss/testsuite/config/support.c libgloss/testsuite/configure.in libgloss/testsuite/lib/libgloss.exp libgloss/testsuite/libgloss.all/.gdbinit libgloss/testsuite/libgloss.all/Makefile.in libgloss/testsuite/libgloss.all/array.c libgloss/testsuite/libgloss.all/configure.in libgloss/testsuite/libgloss.all/div.c libgloss/testsuite/libgloss.all/double.c libgloss/testsuite/libgloss.all/float.c libgloss/testsuite/libgloss.all/func.c libgloss/testsuite/libgloss.all/io.c libgloss/testsuite/libgloss.all/math.c libgloss/testsuite/libgloss.all/memory.c libgloss/testsuite/libgloss.all/misc.c libgloss/testsuite/libgloss.all/printf.c libgloss/testsuite/libgloss.all/struct.c libgloss/testsuite/libgloss.all/varargs.c libgloss/testsuite/libgloss.all/varargs2.c libgloss/unlink.c libgloss/v850/sys/syscall.h libgloss/wince/Makefile.am libgloss/wince/Makefile.in libgloss/wince/aclocal.m4 libgloss/wince/configure libgloss/wince/configure.in libgloss/write.c libgloss/xc16x/Makefile.in libgloss/xc16x/aclocal.m4 libgloss/xc16x/close.S libgloss/xc16x/configure libgloss/xc16x/configure.in libgloss/xc16x/create.c libgloss/xc16x/crt0.S libgloss/xc16x/fstat.S libgloss/xc16x/getchar1.c libgloss/xc16x/isatty.c libgloss/xc16x/lseek.c libgloss/xc16x/mem-layout.c libgloss/xc16x/misc.c libgloss/xc16x/open.c libgloss/xc16x/read.c libgloss/xc16x/sbrk.c libgloss/xc16x/sys/syscall.h libgloss/xc16x/syscalls.c libgloss/xc16x/trap_handle.c libgloss/xc16x/write.c libgloss/xc16x/xc16x.mt libgloss/xstormy16/Makefile.in libgloss/xstormy16/aclocal.m4 libgloss/xstormy16/close.c libgloss/xstormy16/configure libgloss/xstormy16/configure.in libgloss/xstormy16/crt0.s libgloss/xstormy16/crt0_stub.s libgloss/xstormy16/crti.s libgloss/xstormy16/crtn.s libgloss/xstormy16/eva_app.c libgloss/xstormy16/eva_app.ld libgloss/xstormy16/eva_stub.ld libgloss/xstormy16/fstat.c libgloss/xstormy16/getpid.c libgloss/xstormy16/isatty.c libgloss/xstormy16/kill.c libgloss/xstormy16/lseek.c libgloss/xstormy16/open.c libgloss/xstormy16/sim_high.ld libgloss/xstormy16/sim_malloc_start.s libgloss/xstormy16/sim_rom.ld libgloss/xstormy16/stat.c libgloss/xstormy16/syscalls.S libgloss/xstormy16/syscalls.m4 libgloss/xstormy16/unlink.c libgloss/xstormy16/xstormy16_stub.c newlib/ChangeLog newlib/HOWTO newlib/MAINTAINERS newlib/Makefile.am newlib/Makefile.in newlib/Makefile.shared newlib/NEWS newlib/README newlib/acconfig.h newlib/acinclude.m4 newlib/aclocal.m4 newlib/configure newlib/configure.host newlib/configure.in newlib/confsubdir.m4 newlib/doc/Makefile.am newlib/doc/Makefile.in newlib/doc/aclocal.m4 newlib/doc/ansidecl.h newlib/doc/configure newlib/doc/configure.in newlib/doc/doc.str newlib/doc/makedoc.c newlib/iconvdata/EUC-JP.irreversible newlib/iconvdata/Makefile.am newlib/iconvdata/Makefile.in newlib/iconvdata/SJIS.irreversible newlib/iconvdata/aclocal.m4 newlib/iconvdata/configure newlib/iconvdata/configure.in newlib/iconvdata/dummy.c newlib/iconvdata/euc-jp.c newlib/iconvdata/gconv-modules newlib/iconvdata/jis0201.c newlib/iconvdata/jis0201.h newlib/iconvdata/jis0208.c newlib/iconvdata/jis0208.h newlib/iconvdata/jis0212.c newlib/iconvdata/jis0212.h newlib/iconvdata/sjis.c newlib/libc/Makefile.am newlib/libc/Makefile.in newlib/libc/aclocal.m4 newlib/libc/argz/Makefile.am newlib/libc/argz/Makefile.in newlib/libc/argz/argz_add.c newlib/libc/argz/argz_add_sep.c newlib/libc/argz/argz_append.c newlib/libc/argz/argz_count.c newlib/libc/argz/argz_create.c newlib/libc/argz/argz_create_sep.c newlib/libc/argz/argz_delete.c newlib/libc/argz/argz_extract.c newlib/libc/argz/argz_insert.c newlib/libc/argz/argz_next.c newlib/libc/argz/argz_replace.c newlib/libc/argz/argz_stringify.c newlib/libc/argz/buf_findstr.c newlib/libc/argz/buf_findstr.h newlib/libc/argz/dummy.c newlib/libc/argz/envz_add.c newlib/libc/argz/envz_entry.c newlib/libc/argz/envz_get.c newlib/libc/argz/envz_merge.c newlib/libc/argz/envz_remove.c newlib/libc/argz/envz_strip.c newlib/libc/configure newlib/libc/configure.in newlib/libc/ctype/Makefile.am newlib/libc/ctype/Makefile.in newlib/libc/ctype/ctype.tex newlib/libc/ctype/ctype_.c newlib/libc/ctype/ctype_cp.h newlib/libc/ctype/ctype_iso.h newlib/libc/ctype/isalnum.c newlib/libc/ctype/isalpha.c newlib/libc/ctype/isascii.c newlib/libc/ctype/isblank.c newlib/libc/ctype/iscntrl.c newlib/libc/ctype/isdigit.c newlib/libc/ctype/islower.c newlib/libc/ctype/isprint.c newlib/libc/ctype/ispunct.c newlib/libc/ctype/isspace.c newlib/libc/ctype/isupper.c newlib/libc/ctype/iswalnum.c newlib/libc/ctype/iswalpha.c newlib/libc/ctype/iswblank.c newlib/libc/ctype/iswcntrl.c newlib/libc/ctype/iswctype.c newlib/libc/ctype/iswdigit.c newlib/libc/ctype/iswgraph.c newlib/libc/ctype/iswlower.c newlib/libc/ctype/iswprint.c newlib/libc/ctype/iswpunct.c newlib/libc/ctype/iswspace.c newlib/libc/ctype/iswupper.c newlib/libc/ctype/iswxdigit.c newlib/libc/ctype/isxdigit.c newlib/libc/ctype/jp2uc.c newlib/libc/ctype/jp2uc.h newlib/libc/ctype/local.h newlib/libc/ctype/toascii.c newlib/libc/ctype/tolower.c newlib/libc/ctype/toupper.c newlib/libc/ctype/towctrans.c newlib/libc/ctype/towlower.c newlib/libc/ctype/towupper.c newlib/libc/ctype/utf8alpha.h newlib/libc/ctype/utf8print.h newlib/libc/ctype/utf8punct.h newlib/libc/ctype/wctrans.c newlib/libc/ctype/wctype.c newlib/libc/errno/Makefile.am newlib/libc/errno/Makefile.in newlib/libc/errno/errno.c newlib/libc/iconv/Makefile.am newlib/libc/iconv/Makefile.in newlib/libc/iconv/ccs/Makefile.am newlib/libc/iconv/ccs/Makefile.in newlib/libc/iconv/ccs/big5.c newlib/libc/iconv/ccs/binary/Makefile.am newlib/libc/iconv/ccs/binary/Makefile.in newlib/libc/iconv/ccs/binary/big5.cct newlib/libc/iconv/ccs/binary/cns11643_plane1.cct newlib/libc/iconv/ccs/binary/cns11643_plane14.cct newlib/libc/iconv/ccs/binary/cns11643_plane2.cct newlib/libc/iconv/ccs/binary/cp775.cct newlib/libc/iconv/ccs/binary/cp850.cct newlib/libc/iconv/ccs/binary/cp852.cct newlib/libc/iconv/ccs/binary/cp855.cct newlib/libc/iconv/ccs/binary/cp866.cct newlib/libc/iconv/ccs/binary/iso_8859_1.cct newlib/libc/iconv/ccs/binary/iso_8859_10.cct newlib/libc/iconv/ccs/binary/iso_8859_11.cct newlib/libc/iconv/ccs/binary/iso_8859_13.cct newlib/libc/iconv/ccs/binary/iso_8859_14.cct newlib/libc/iconv/ccs/binary/iso_8859_15.cct newlib/libc/iconv/ccs/binary/iso_8859_2.cct newlib/libc/iconv/ccs/binary/iso_8859_3.cct newlib/libc/iconv/ccs/binary/iso_8859_4.cct newlib/libc/iconv/ccs/binary/iso_8859_5.cct newlib/libc/iconv/ccs/binary/iso_8859_6.cct newlib/libc/iconv/ccs/binary/iso_8859_7.cct newlib/libc/iconv/ccs/binary/iso_8859_8.cct newlib/libc/iconv/ccs/binary/iso_8859_9.cct newlib/libc/iconv/ccs/binary/iso_ir_111.cct newlib/libc/iconv/ccs/binary/jis_x0201_1976.cct newlib/libc/iconv/ccs/binary/jis_x0208_1990.cct newlib/libc/iconv/ccs/binary/jis_x0212_1990.cct newlib/libc/iconv/ccs/binary/koi8_r.cct newlib/libc/iconv/ccs/binary/koi8_ru.cct newlib/libc/iconv/ccs/binary/koi8_u.cct newlib/libc/iconv/ccs/binary/koi8_uni.cct newlib/libc/iconv/ccs/binary/ksx1001.cct newlib/libc/iconv/ccs/binary/win_1250.cct newlib/libc/iconv/ccs/binary/win_1251.cct newlib/libc/iconv/ccs/binary/win_1252.cct newlib/libc/iconv/ccs/binary/win_1253.cct newlib/libc/iconv/ccs/binary/win_1254.cct newlib/libc/iconv/ccs/binary/win_1255.cct newlib/libc/iconv/ccs/binary/win_1256.cct newlib/libc/iconv/ccs/binary/win_1257.cct newlib/libc/iconv/ccs/binary/win_1258.cct newlib/libc/iconv/ccs/ccs.h newlib/libc/iconv/ccs/ccsbi.c newlib/libc/iconv/ccs/ccsbi.h newlib/libc/iconv/ccs/ccsnames.h newlib/libc/iconv/ccs/cns11643_plane1.c newlib/libc/iconv/ccs/cns11643_plane14.c newlib/libc/iconv/ccs/cns11643_plane2.c newlib/libc/iconv/ccs/cp775.c newlib/libc/iconv/ccs/cp850.c newlib/libc/iconv/ccs/cp852.c newlib/libc/iconv/ccs/cp855.c newlib/libc/iconv/ccs/cp866.c newlib/libc/iconv/ccs/iso_8859_1.c newlib/libc/iconv/ccs/iso_8859_10.c newlib/libc/iconv/ccs/iso_8859_11.c newlib/libc/iconv/ccs/iso_8859_13.c newlib/libc/iconv/ccs/iso_8859_14.c newlib/libc/iconv/ccs/iso_8859_15.c newlib/libc/iconv/ccs/iso_8859_2.c newlib/libc/iconv/ccs/iso_8859_3.c newlib/libc/iconv/ccs/iso_8859_4.c newlib/libc/iconv/ccs/iso_8859_5.c newlib/libc/iconv/ccs/iso_8859_6.c newlib/libc/iconv/ccs/iso_8859_7.c newlib/libc/iconv/ccs/iso_8859_8.c newlib/libc/iconv/ccs/iso_8859_9.c newlib/libc/iconv/ccs/iso_ir_111.c newlib/libc/iconv/ccs/jis_x0201_1976.c newlib/libc/iconv/ccs/jis_x0208_1990.c newlib/libc/iconv/ccs/jis_x0212_1990.c newlib/libc/iconv/ccs/koi8_r.c newlib/libc/iconv/ccs/koi8_ru.c newlib/libc/iconv/ccs/koi8_u.c newlib/libc/iconv/ccs/koi8_uni.c newlib/libc/iconv/ccs/ksx1001.c newlib/libc/iconv/ccs/mktbl.pl newlib/libc/iconv/ccs/win_1250.c newlib/libc/iconv/ccs/win_1251.c newlib/libc/iconv/ccs/win_1252.c newlib/libc/iconv/ccs/win_1253.c newlib/libc/iconv/ccs/win_1254.c newlib/libc/iconv/ccs/win_1255.c newlib/libc/iconv/ccs/win_1256.c newlib/libc/iconv/ccs/win_1257.c newlib/libc/iconv/ccs/win_1258.c newlib/libc/iconv/ces/Makefile.am newlib/libc/iconv/ces/Makefile.in newlib/libc/iconv/ces/cesbi.c newlib/libc/iconv/ces/cesbi.h newlib/libc/iconv/ces/cesdeps.h newlib/libc/iconv/ces/euc.c newlib/libc/iconv/ces/mkdeps.pl newlib/libc/iconv/ces/table-pcs.c newlib/libc/iconv/ces/table.c newlib/libc/iconv/ces/ucs-2-internal.c newlib/libc/iconv/ces/ucs-2.c newlib/libc/iconv/ces/ucs-4-internal.c newlib/libc/iconv/ces/ucs-4.c newlib/libc/iconv/ces/us-ascii.c newlib/libc/iconv/ces/utf-16.c newlib/libc/iconv/ces/utf-8.c newlib/libc/iconv/encoding.aliases newlib/libc/iconv/iconv.tex newlib/libc/iconv/lib/Makefile.am newlib/libc/iconv/lib/Makefile.in newlib/libc/iconv/lib/aliasesbi.c newlib/libc/iconv/lib/aliasesi.c newlib/libc/iconv/lib/conv.h newlib/libc/iconv/lib/encnames.h newlib/libc/iconv/lib/encoding.deps newlib/libc/iconv/lib/endian.h newlib/libc/iconv/lib/iconv.c newlib/libc/iconv/lib/iconvnls.c newlib/libc/iconv/lib/iconvnls.h newlib/libc/iconv/lib/local.h newlib/libc/iconv/lib/nullconv.c newlib/libc/iconv/lib/ucsconv.c newlib/libc/iconv/lib/ucsconv.h newlib/libc/include/_ansi.h newlib/libc/include/_syslist.h newlib/libc/include/alloca.h newlib/libc/include/ar.h newlib/libc/include/argz.h newlib/libc/include/assert.h newlib/libc/include/ctype.h newlib/libc/include/dirent.h newlib/libc/include/envlock.h newlib/libc/include/envz.h newlib/libc/include/errno.h newlib/libc/include/fastmath.h newlib/libc/include/fcntl.h newlib/libc/include/fnmatch.h newlib/libc/include/getopt.h newlib/libc/include/glob.h newlib/libc/include/grp.h newlib/libc/include/iconv.h newlib/libc/include/ieeefp.h newlib/libc/include/inttypes.h newlib/libc/include/langinfo.h newlib/libc/include/libgen.h newlib/libc/include/limits.h newlib/libc/include/locale.h newlib/libc/include/machine/_default_types.h newlib/libc/include/machine/_types.h newlib/libc/include/machine/ansi.h newlib/libc/include/machine/endian.h newlib/libc/include/machine/fastmath.h newlib/libc/include/machine/ieeefp.h newlib/libc/include/machine/malloc.h newlib/libc/include/machine/param.h newlib/libc/include/machine/setjmp-dj.h newlib/libc/include/machine/setjmp.h newlib/libc/include/machine/stdlib.h newlib/libc/include/machine/termios.h newlib/libc/include/machine/time.h newlib/libc/include/machine/types.h newlib/libc/include/malloc.h newlib/libc/include/math.h newlib/libc/include/newlib.h newlib/libc/include/paths.h newlib/libc/include/process.h newlib/libc/include/pthread.h newlib/libc/include/pwd.h newlib/libc/include/reent.h newlib/libc/include/regdef.h newlib/libc/include/regex.h newlib/libc/include/sched.h newlib/libc/include/search.h newlib/libc/include/setjmp.h newlib/libc/include/signal.h newlib/libc/include/stdint.h newlib/libc/include/stdio.h newlib/libc/include/stdlib.h newlib/libc/include/string.h newlib/libc/include/sys/_default_fcntl.h newlib/libc/include/sys/_types.h newlib/libc/include/sys/cdefs.h newlib/libc/include/sys/config.h newlib/libc/include/sys/custom_file.h newlib/libc/include/sys/dirent.h newlib/libc/include/sys/errno.h newlib/libc/include/sys/fcntl.h newlib/libc/include/sys/features.h newlib/libc/include/sys/file.h newlib/libc/include/sys/iconvnls.h newlib/libc/include/sys/lock.h newlib/libc/include/sys/param.h newlib/libc/include/sys/queue.h newlib/libc/include/sys/reent.h newlib/libc/include/sys/resource.h newlib/libc/include/sys/sched.h newlib/libc/include/sys/signal.h newlib/libc/include/sys/stat.h newlib/libc/include/sys/stdio.h newlib/libc/include/sys/string.h newlib/libc/include/sys/syslimits.h newlib/libc/include/sys/time.h newlib/libc/include/sys/timeb.h newlib/libc/include/sys/times.h newlib/libc/include/sys/types.h newlib/libc/include/sys/unistd.h newlib/libc/include/sys/utime.h newlib/libc/include/sys/wait.h newlib/libc/include/tar.h newlib/libc/include/termios.h newlib/libc/include/time.h newlib/libc/include/unctrl.h newlib/libc/include/unistd.h newlib/libc/include/utime.h newlib/libc/include/utmp.h newlib/libc/include/wchar.h newlib/libc/include/wctype.h newlib/libc/include/wordexp.h newlib/libc/libc.texinfo newlib/libc/locale/Makefile.am newlib/libc/locale/Makefile.in newlib/libc/locale/fix_grouping.c newlib/libc/locale/ldpart.c newlib/libc/locale/ldpart.h newlib/libc/locale/lmessages.c newlib/libc/locale/lmessages.h newlib/libc/locale/lmonetary.c newlib/libc/locale/lmonetary.h newlib/libc/locale/lnumeric.c newlib/libc/locale/lnumeric.h newlib/libc/locale/locale.c newlib/libc/locale/locale.tex newlib/libc/locale/nl_langinfo.3 newlib/libc/locale/nl_langinfo.c newlib/libc/locale/setlocale.h newlib/libc/locale/timelocal.c newlib/libc/locale/timelocal.h newlib/libc/machine/Makefile.am newlib/libc/machine/Makefile.in newlib/libc/machine/a29k/Makefile.am newlib/libc/machine/a29k/Makefile.in newlib/libc/machine/a29k/aclocal.m4 newlib/libc/machine/a29k/configure newlib/libc/machine/a29k/configure.in newlib/libc/machine/aclocal.m4 newlib/libc/machine/arm/Makefile.am newlib/libc/machine/arm/Makefile.in newlib/libc/machine/arm/access.c newlib/libc/machine/arm/aclocal.m4 newlib/libc/machine/arm/arm_asm.h newlib/libc/machine/arm/configure newlib/libc/machine/arm/configure.in newlib/libc/machine/arm/machine/param.h newlib/libc/machine/arm/setjmp.S newlib/libc/machine/arm/strcmp.c newlib/libc/machine/arm/strcpy.c newlib/libc/machine/arm/strlen.c newlib/libc/machine/bfin/Makefile.am newlib/libc/machine/bfin/Makefile.in newlib/libc/machine/bfin/aclocal.m4 newlib/libc/machine/bfin/configure newlib/libc/machine/bfin/configure.in newlib/libc/machine/bfin/longjmp.S newlib/libc/machine/bfin/setjmp.S newlib/libc/machine/configure newlib/libc/machine/configure.in newlib/libc/machine/cris/Makefile.am newlib/libc/machine/cris/Makefile.in newlib/libc/machine/cris/aclocal.m4 newlib/libc/machine/cris/configure newlib/libc/machine/cris/configure.in newlib/libc/machine/cris/include/pthread.h newlib/libc/machine/cris/libcdtor.c newlib/libc/machine/cris/memcpy.c newlib/libc/machine/cris/memmove.c newlib/libc/machine/cris/memset.c newlib/libc/machine/cris/setjmp.c newlib/libc/machine/cris/sys/errno.h newlib/libc/machine/cris/sys/fcntl.h newlib/libc/machine/cris/sys/signal.h newlib/libc/machine/crx/Makefile.am newlib/libc/machine/crx/Makefile.in newlib/libc/machine/crx/aclocal.m4 newlib/libc/machine/crx/configure newlib/libc/machine/crx/configure.in newlib/libc/machine/crx/getenv.c newlib/libc/machine/crx/setjmp.S newlib/libc/machine/crx/sys/asm.h newlib/libc/machine/crx/sys/libh.h newlib/libc/machine/crx/sys/syscall.h newlib/libc/machine/d10v/Makefile.am newlib/libc/machine/d10v/Makefile.in newlib/libc/machine/d10v/aclocal.m4 newlib/libc/machine/d10v/configure newlib/libc/machine/d10v/configure.in newlib/libc/machine/d10v/setjmp.S newlib/libc/machine/d30v/Makefile.am newlib/libc/machine/d30v/Makefile.in newlib/libc/machine/d30v/aclocal.m4 newlib/libc/machine/d30v/configure newlib/libc/machine/d30v/configure.in newlib/libc/machine/d30v/setjmp.S newlib/libc/machine/fr30/Makefile.am newlib/libc/machine/fr30/Makefile.in newlib/libc/machine/fr30/aclocal.m4 newlib/libc/machine/fr30/configure newlib/libc/machine/fr30/configure.in newlib/libc/machine/fr30/setjmp.S newlib/libc/machine/frv/Makefile.am newlib/libc/machine/frv/Makefile.in newlib/libc/machine/frv/aclocal.m4 newlib/libc/machine/frv/configure newlib/libc/machine/frv/configure.in newlib/libc/machine/frv/setjmp.S newlib/libc/machine/h8300/Makefile.am newlib/libc/machine/h8300/Makefile.in newlib/libc/machine/h8300/aclocal.m4 newlib/libc/machine/h8300/configure newlib/libc/machine/h8300/configure.in newlib/libc/machine/h8300/defines.h newlib/libc/machine/h8300/h8sx_strcpy.S newlib/libc/machine/h8300/memcpy.S newlib/libc/machine/h8300/memset.S newlib/libc/machine/h8300/reg_memcpy.S newlib/libc/machine/h8300/reg_memset.S newlib/libc/machine/h8300/setarch.h newlib/libc/machine/h8300/setjmp.S newlib/libc/machine/h8300/strcmp.S newlib/libc/machine/h8500/Makefile.am newlib/libc/machine/h8500/Makefile.in newlib/libc/machine/h8500/aclocal.m4 newlib/libc/machine/h8500/cmpsi.c newlib/libc/machine/h8500/configure newlib/libc/machine/h8500/configure.in newlib/libc/machine/h8500/divhi3.S newlib/libc/machine/h8500/divsi3.c newlib/libc/machine/h8500/mulhi3.c newlib/libc/machine/h8500/mulsi3.c newlib/libc/machine/h8500/negsi2.c newlib/libc/machine/h8500/psi.S newlib/libc/machine/h8500/setjmp.S newlib/libc/machine/h8500/shifts.c newlib/libc/machine/hppa/DEFS.h newlib/libc/machine/hppa/Makefile.am newlib/libc/machine/hppa/Makefile.in newlib/libc/machine/hppa/aclocal.m4 newlib/libc/machine/hppa/configure newlib/libc/machine/hppa/configure.in newlib/libc/machine/hppa/memchr.S newlib/libc/machine/hppa/memcmp.S newlib/libc/machine/hppa/memcpy.S newlib/libc/machine/hppa/memset.S newlib/libc/machine/hppa/pcc_prefix.s newlib/libc/machine/hppa/setjmp.S newlib/libc/machine/hppa/strcat.S newlib/libc/machine/hppa/strcmp.S newlib/libc/machine/hppa/strcpy.S newlib/libc/machine/hppa/strlen.S newlib/libc/machine/hppa/strncat.S newlib/libc/machine/hppa/strncmp.S newlib/libc/machine/hppa/strncpy.S newlib/libc/machine/i386/Makefile.am newlib/libc/machine/i386/Makefile.in newlib/libc/machine/i386/aclocal.m4 newlib/libc/machine/i386/configure newlib/libc/machine/i386/configure.in newlib/libc/machine/i386/f_atan2.S newlib/libc/machine/i386/f_atan2f.S newlib/libc/machine/i386/f_exp.c newlib/libc/machine/i386/f_expf.c newlib/libc/machine/i386/f_frexp.S newlib/libc/machine/i386/f_frexpf.S newlib/libc/machine/i386/f_ldexp.S newlib/libc/machine/i386/f_ldexpf.S newlib/libc/machine/i386/f_log.S newlib/libc/machine/i386/f_log10.S newlib/libc/machine/i386/f_log10f.S newlib/libc/machine/i386/f_logf.S newlib/libc/machine/i386/f_math.h newlib/libc/machine/i386/f_pow.c newlib/libc/machine/i386/f_powf.c newlib/libc/machine/i386/f_tan.S newlib/libc/machine/i386/f_tanf.S newlib/libc/machine/i386/i386mach.h newlib/libc/machine/i386/machine/fastmath.h newlib/libc/machine/i386/memchr.S newlib/libc/machine/i386/memcmp.S newlib/libc/machine/i386/memcpy.S newlib/libc/machine/i386/memmove.S newlib/libc/machine/i386/memset.S newlib/libc/machine/i386/setjmp.S newlib/libc/machine/i386/strchr.S newlib/libc/machine/i386/strlen.S newlib/libc/machine/i960/Makefile.am newlib/libc/machine/i960/Makefile.in newlib/libc/machine/i960/aclocal.m4 newlib/libc/machine/i960/configure newlib/libc/machine/i960/configure.in newlib/libc/machine/i960/memccpy.S newlib/libc/machine/i960/memccpy_ca.S newlib/libc/machine/i960/memchr.S newlib/libc/machine/i960/memchr_ca.S newlib/libc/machine/i960/memcmp.S newlib/libc/machine/i960/memcmp_ca.S newlib/libc/machine/i960/memcpy.S newlib/libc/machine/i960/memcpy_ca.S newlib/libc/machine/i960/memset.S newlib/libc/machine/i960/setjmp.S newlib/libc/machine/i960/strchr.S newlib/libc/machine/i960/strchr_ca.S newlib/libc/machine/i960/strcmp.S newlib/libc/machine/i960/strcmp_ca.S newlib/libc/machine/i960/strcpy.S newlib/libc/machine/i960/strcpy_ca.S newlib/libc/machine/i960/strcspn.S newlib/libc/machine/i960/strdup.S newlib/libc/machine/i960/strlen.S newlib/libc/machine/i960/strlen_ca.S newlib/libc/machine/i960/strncat.S newlib/libc/machine/i960/strncat_ca.S newlib/libc/machine/i960/strncmp.S newlib/libc/machine/i960/strncmp_ca.S newlib/libc/machine/i960/strncpy.S newlib/libc/machine/i960/strncpy_ca.S newlib/libc/machine/i960/strpbrk.S newlib/libc/machine/i960/strrchr.S newlib/libc/machine/iq2000/Makefile.am newlib/libc/machine/iq2000/Makefile.in newlib/libc/machine/iq2000/aclocal.m4 newlib/libc/machine/iq2000/configure newlib/libc/machine/iq2000/configure.in newlib/libc/machine/iq2000/setjmp.S newlib/libc/machine/lm32/Makefile.am newlib/libc/machine/lm32/Makefile.in newlib/libc/machine/lm32/aclocal.m4 newlib/libc/machine/lm32/configure newlib/libc/machine/lm32/configure.in newlib/libc/machine/lm32/setjmp.S newlib/libc/machine/m32c/Makefile.am newlib/libc/machine/m32c/Makefile.in newlib/libc/machine/m32c/aclocal.m4 newlib/libc/machine/m32c/configure newlib/libc/machine/m32c/configure.in newlib/libc/machine/m32c/setjmp.S newlib/libc/machine/m32r/Makefile.am newlib/libc/machine/m32r/Makefile.in newlib/libc/machine/m32r/aclocal.m4 newlib/libc/machine/m32r/configure newlib/libc/machine/m32r/configure.in newlib/libc/machine/m32r/setjmp.S newlib/libc/machine/m68hc11/Makefile.am newlib/libc/machine/m68hc11/Makefile.in newlib/libc/machine/m68hc11/aclocal.m4 newlib/libc/machine/m68hc11/configure newlib/libc/machine/m68hc11/configure.in newlib/libc/machine/m68hc11/setjmp.S newlib/libc/machine/m68k/Makefile.am newlib/libc/machine/m68k/Makefile.in newlib/libc/machine/m68k/aclocal.m4 newlib/libc/machine/m68k/configure newlib/libc/machine/m68k/configure.in newlib/libc/machine/m68k/m68kasm.h newlib/libc/machine/m68k/memcpy.S newlib/libc/machine/m68k/memset.S newlib/libc/machine/m68k/setjmp.S newlib/libc/machine/m68k/strcpy.c newlib/libc/machine/m68k/strlen.c newlib/libc/machine/m88k/Makefile.am newlib/libc/machine/m88k/Makefile.in newlib/libc/machine/m88k/aclocal.m4 newlib/libc/machine/m88k/configure newlib/libc/machine/m88k/configure.in newlib/libc/machine/m88k/setjmp.S newlib/libc/machine/mep/Makefile.am newlib/libc/machine/mep/Makefile.in newlib/libc/machine/mep/aclocal.m4 newlib/libc/machine/mep/configure newlib/libc/machine/mep/configure.in newlib/libc/machine/mep/setjmp.S newlib/libc/machine/microblaze/Makefile.am newlib/libc/machine/microblaze/Makefile.in newlib/libc/machine/microblaze/abort.c newlib/libc/machine/microblaze/aclocal.m4 newlib/libc/machine/microblaze/configure newlib/libc/machine/microblaze/configure.in newlib/libc/machine/microblaze/longjmp.S newlib/libc/machine/microblaze/setjmp.S newlib/libc/machine/microblaze/strcmp.c newlib/libc/machine/microblaze/strcpy.c newlib/libc/machine/microblaze/strlen.c newlib/libc/machine/mips/Makefile.am newlib/libc/machine/mips/Makefile.in newlib/libc/machine/mips/aclocal.m4 newlib/libc/machine/mips/configure newlib/libc/machine/mips/configure.in newlib/libc/machine/mips/machine/regdef.h newlib/libc/machine/mips/memcpy.c newlib/libc/machine/mips/memset.c newlib/libc/machine/mips/setjmp.S newlib/libc/machine/mips/strcmp.c newlib/libc/machine/mips/strlen.c newlib/libc/machine/mips/strncpy.c newlib/libc/machine/mn10200/Makefile.am newlib/libc/machine/mn10200/Makefile.in newlib/libc/machine/mn10200/aclocal.m4 newlib/libc/machine/mn10200/configure newlib/libc/machine/mn10200/configure.in newlib/libc/machine/mn10200/setjmp.S newlib/libc/machine/mn10300/Makefile.am newlib/libc/machine/mn10300/Makefile.in newlib/libc/machine/mn10300/aclocal.m4 newlib/libc/machine/mn10300/configure newlib/libc/machine/mn10300/configure.in newlib/libc/machine/mn10300/memchr.S newlib/libc/machine/mn10300/memcmp.S newlib/libc/machine/mn10300/memcpy.S newlib/libc/machine/mn10300/memset.S newlib/libc/machine/mn10300/setjmp.S newlib/libc/machine/mn10300/strchr.S newlib/libc/machine/mn10300/strcmp.S newlib/libc/machine/mn10300/strcpy.S newlib/libc/machine/mn10300/strlen.S newlib/libc/machine/moxie/Makefile.am newlib/libc/machine/moxie/Makefile.in newlib/libc/machine/moxie/aclocal.m4 newlib/libc/machine/moxie/configure newlib/libc/machine/moxie/configure.in newlib/libc/machine/moxie/setjmp.S newlib/libc/machine/mt/Makefile.am newlib/libc/machine/mt/Makefile.in newlib/libc/machine/mt/aclocal.m4 newlib/libc/machine/mt/configure newlib/libc/machine/mt/configure.in newlib/libc/machine/mt/setjmp.S newlib/libc/machine/necv70/Makefile.am newlib/libc/machine/necv70/Makefile.in newlib/libc/machine/necv70/aclocal.m4 newlib/libc/machine/necv70/configure newlib/libc/machine/necv70/configure.in newlib/libc/machine/necv70/fastmath.S newlib/libc/machine/necv70/machine/registers.h newlib/libc/machine/necv70/necv70.tex newlib/libc/machine/necv70/setjmp.S newlib/libc/machine/powerpc/Makefile.am newlib/libc/machine/powerpc/Makefile.in newlib/libc/machine/powerpc/aclocal.m4 newlib/libc/machine/powerpc/atosfix16.c newlib/libc/machine/powerpc/atosfix32.c newlib/libc/machine/powerpc/atosfix64.c newlib/libc/machine/powerpc/atoufix16.c newlib/libc/machine/powerpc/atoufix32.c newlib/libc/machine/powerpc/atoufix64.c newlib/libc/machine/powerpc/configure newlib/libc/machine/powerpc/configure.in newlib/libc/machine/powerpc/fix64.h newlib/libc/machine/powerpc/machine/malloc.h newlib/libc/machine/powerpc/machine/stdlib.h newlib/libc/machine/powerpc/setjmp.S newlib/libc/machine/powerpc/simdldtoa.c newlib/libc/machine/powerpc/strtosfix16.c newlib/libc/machine/powerpc/strtosfix32.c newlib/libc/machine/powerpc/strtosfix64.c newlib/libc/machine/powerpc/strtoufix16.c newlib/libc/machine/powerpc/strtoufix32.c newlib/libc/machine/powerpc/strtoufix64.c newlib/libc/machine/powerpc/times.c newlib/libc/machine/powerpc/ufix64toa.c newlib/libc/machine/powerpc/vec_calloc.c newlib/libc/machine/powerpc/vec_free.c newlib/libc/machine/powerpc/vec_malloc.c newlib/libc/machine/powerpc/vec_mallocr.c newlib/libc/machine/powerpc/vec_realloc.c newlib/libc/machine/powerpc/vfprintf.c newlib/libc/machine/powerpc/vfscanf.c newlib/libc/machine/rx/Makefile.am newlib/libc/machine/rx/Makefile.in newlib/libc/machine/rx/aclocal.m4 newlib/libc/machine/rx/configure newlib/libc/machine/rx/configure.in newlib/libc/machine/rx/memchr.S newlib/libc/machine/rx/memcpy.S newlib/libc/machine/rx/memmove.S newlib/libc/machine/rx/mempcpy.S newlib/libc/machine/rx/memset.S newlib/libc/machine/rx/setjmp.S newlib/libc/machine/rx/strcat.S newlib/libc/machine/rx/strcmp.S newlib/libc/machine/rx/strcpy.S newlib/libc/machine/rx/strlen.S newlib/libc/machine/rx/strncat.S newlib/libc/machine/rx/strncmp.S newlib/libc/machine/rx/strncpy.S newlib/libc/machine/sh/Makefile.am newlib/libc/machine/sh/Makefile.in newlib/libc/machine/sh/aclocal.m4 newlib/libc/machine/sh/asm.h newlib/libc/machine/sh/configure newlib/libc/machine/sh/configure.in newlib/libc/machine/sh/memcpy.S newlib/libc/machine/sh/memset.S newlib/libc/machine/sh/setjmp.S newlib/libc/machine/sh/strcmp.S newlib/libc/machine/sh/strcpy.S newlib/libc/machine/sh/strlen.S newlib/libc/machine/sh/strncpy.S newlib/libc/machine/sparc/Makefile.am newlib/libc/machine/sparc/Makefile.in newlib/libc/machine/sparc/aclocal.m4 newlib/libc/machine/sparc/configure newlib/libc/machine/sparc/configure.in newlib/libc/machine/sparc/machine/sparclet.h newlib/libc/machine/sparc/scan.c newlib/libc/machine/sparc/setjmp.S newlib/libc/machine/sparc/shuffle.c newlib/libc/machine/spu/Makefile.am newlib/libc/machine/spu/Makefile.in newlib/libc/machine/spu/aclocal.m4 newlib/libc/machine/spu/assert.c newlib/libc/machine/spu/c99ppe.h newlib/libc/machine/spu/calloc_ea.c newlib/libc/machine/spu/clearerr.c newlib/libc/machine/spu/configure newlib/libc/machine/spu/configure.in newlib/libc/machine/spu/creat.c newlib/libc/machine/spu/ea_internal.h newlib/libc/machine/spu/fclose.c newlib/libc/machine/spu/fdopen.c newlib/libc/machine/spu/feof.c newlib/libc/machine/spu/ferror.c newlib/libc/machine/spu/fflush.c newlib/libc/machine/spu/fgetc.c newlib/libc/machine/spu/fgetpos.c newlib/libc/machine/spu/fgets.c newlib/libc/machine/spu/fileno.c newlib/libc/machine/spu/fiprintf.S newlib/libc/machine/spu/fiscanf.S newlib/libc/machine/spu/fopen.c newlib/libc/machine/spu/fprintf.S newlib/libc/machine/spu/fputc.c newlib/libc/machine/spu/fputs.c newlib/libc/machine/spu/fread.c newlib/libc/machine/spu/free_ea.c newlib/libc/machine/spu/freopen.c newlib/libc/machine/spu/fscanf.S newlib/libc/machine/spu/fseek.c newlib/libc/machine/spu/fsetpos.c newlib/libc/machine/spu/ftell.c newlib/libc/machine/spu/fwrite.c newlib/libc/machine/spu/getc.c newlib/libc/machine/spu/getchar.c newlib/libc/machine/spu/gets.c newlib/libc/machine/spu/impure.c newlib/libc/machine/spu/include/ea.h newlib/libc/machine/spu/include/fenv.h newlib/libc/machine/spu/include/spu_timer.h newlib/libc/machine/spu/iprintf.S newlib/libc/machine/spu/iscanf.S newlib/libc/machine/spu/machine/_types.h newlib/libc/machine/spu/malloc_ea.c newlib/libc/machine/spu/memchr_ea.c newlib/libc/machine/spu/memcmp.c newlib/libc/machine/spu/memcmp_ea.c newlib/libc/machine/spu/memcpy.c newlib/libc/machine/spu/memcpy_ea.c newlib/libc/machine/spu/memmove.c newlib/libc/machine/spu/memmove_ea.c newlib/libc/machine/spu/memset.c newlib/libc/machine/spu/memset_ea.c newlib/libc/machine/spu/mk_syscalls newlib/libc/machine/spu/mmap_ea.c newlib/libc/machine/spu/mremap_ea.c newlib/libc/machine/spu/msync_ea.c newlib/libc/machine/spu/munmap_ea.c newlib/libc/machine/spu/perror.c newlib/libc/machine/spu/posix_memalign_ea.c newlib/libc/machine/spu/pread_ea.c newlib/libc/machine/spu/printf.S newlib/libc/machine/spu/putc.c newlib/libc/machine/spu/putchar.c newlib/libc/machine/spu/puts.c newlib/libc/machine/spu/pwrite_ea.c newlib/libc/machine/spu/read_ea.c newlib/libc/machine/spu/readv_ea.c newlib/libc/machine/spu/realloc_ea.c newlib/libc/machine/spu/remove.c newlib/libc/machine/spu/rename.c newlib/libc/machine/spu/rewind.c newlib/libc/machine/spu/scanf.S newlib/libc/machine/spu/setbuf.c newlib/libc/machine/spu/setjmp.S newlib/libc/machine/spu/setvbuf.c newlib/libc/machine/spu/siprintf.S newlib/libc/machine/spu/siscanf.S newlib/libc/machine/spu/sleep.c newlib/libc/machine/spu/sniprintf.S newlib/libc/machine/spu/snprintf.S newlib/libc/machine/spu/sprintf.S newlib/libc/machine/spu/spu-gmon.c newlib/libc/machine/spu/spu-mcount.S newlib/libc/machine/spu/spu_clock_stop.c newlib/libc/machine/spu/spu_clock_svcs.c newlib/libc/machine/spu/spu_timebase.c newlib/libc/machine/spu/spu_timer_flih.S newlib/libc/machine/spu/spu_timer_free.c newlib/libc/machine/spu/spu_timer_internal.h newlib/libc/machine/spu/spu_timer_slih.c newlib/libc/machine/spu/spu_timer_slih_reg.c newlib/libc/machine/spu/spu_timer_stop.c newlib/libc/machine/spu/spu_timer_svcs.c newlib/libc/machine/spu/sscanf.S newlib/libc/machine/spu/stack_reg_va.S newlib/libc/machine/spu/stdio.c newlib/libc/machine/spu/straddr.h newlib/libc/machine/spu/strcat.c newlib/libc/machine/spu/strcat_ea.c newlib/libc/machine/spu/strchr.c newlib/libc/machine/spu/strchr_ea.c newlib/libc/machine/spu/strcmp.c newlib/libc/machine/spu/strcmp_ea.c newlib/libc/machine/spu/strcpy.c newlib/libc/machine/spu/strcpy.h newlib/libc/machine/spu/strcpy_ea.c newlib/libc/machine/spu/strcspn.c newlib/libc/machine/spu/strcspn_ea.c newlib/libc/machine/spu/strlen.c newlib/libc/machine/spu/strlen_ea.c newlib/libc/machine/spu/strncat.c newlib/libc/machine/spu/strncat_ea.c newlib/libc/machine/spu/strncmp.c newlib/libc/machine/spu/strncmp.h newlib/libc/machine/spu/strncmp_ea.c newlib/libc/machine/spu/strncpy.c newlib/libc/machine/spu/strncpy_ea.c newlib/libc/machine/spu/strpbrk.c newlib/libc/machine/spu/strpbrk_ea.c newlib/libc/machine/spu/strrchr.c newlib/libc/machine/spu/strrchr_ea.c newlib/libc/machine/spu/strspn.c newlib/libc/machine/spu/strspn_ea.c newlib/libc/machine/spu/strstr_ea.c newlib/libc/machine/spu/strxfrm.c newlib/libc/machine/spu/sys/custom_file.h newlib/libc/machine/spu/sys/dirent.h newlib/libc/machine/spu/sys/errno.h newlib/libc/machine/spu/sys/fenv.h newlib/libc/machine/spu/sys/linux_syscalls.h newlib/libc/machine/spu/sys/mman.h newlib/libc/machine/spu/sys/sched.h newlib/libc/machine/spu/sys/syscall.h newlib/libc/machine/spu/sys/uio.h newlib/libc/machine/spu/sys/utime.h newlib/libc/machine/spu/syscall.def newlib/libc/machine/spu/tmpfile.c newlib/libc/machine/spu/tmpnam.c newlib/libc/machine/spu/ungetc.c newlib/libc/machine/spu/usleep.c newlib/libc/machine/spu/vec_literal.h newlib/libc/machine/spu/vfiprintf.c newlib/libc/machine/spu/vfiscanf.c newlib/libc/machine/spu/vfprintf.c newlib/libc/machine/spu/vfscanf.c newlib/libc/machine/spu/viprintf.c newlib/libc/machine/spu/viscanf.c newlib/libc/machine/spu/vprintf.c newlib/libc/machine/spu/vscanf.c newlib/libc/machine/spu/vsiprintf.c newlib/libc/machine/spu/vsiscanf.c newlib/libc/machine/spu/vsniprintf.c newlib/libc/machine/spu/vsnprintf.c newlib/libc/machine/spu/vsprintf.c newlib/libc/machine/spu/vsscanf.c newlib/libc/machine/spu/write_ea.c newlib/libc/machine/spu/writev_ea.c newlib/libc/machine/tic4x/Makefile.am newlib/libc/machine/tic4x/Makefile.in newlib/libc/machine/tic4x/aclocal.m4 newlib/libc/machine/tic4x/configure newlib/libc/machine/tic4x/configure.in newlib/libc/machine/tic4x/setjmp.S newlib/libc/machine/tic80/Makefile.am newlib/libc/machine/tic80/Makefile.in newlib/libc/machine/tic80/aclocal.m4 newlib/libc/machine/tic80/configure newlib/libc/machine/tic80/configure.in newlib/libc/machine/tic80/setjmp.S newlib/libc/machine/v850/Makefile.am newlib/libc/machine/v850/Makefile.in newlib/libc/machine/v850/aclocal.m4 newlib/libc/machine/v850/configure newlib/libc/machine/v850/configure.in newlib/libc/machine/v850/setjmp.S newlib/libc/machine/w65/Makefile.am newlib/libc/machine/w65/Makefile.in newlib/libc/machine/w65/aclocal.m4 newlib/libc/machine/w65/cmpsi.c newlib/libc/machine/w65/configure newlib/libc/machine/w65/configure.in newlib/libc/machine/w65/divsi3.c newlib/libc/machine/w65/lshrhi.S newlib/libc/machine/w65/mulsi3.c newlib/libc/machine/w65/sdivhi3.S newlib/libc/machine/w65/smulhi3.S newlib/libc/machine/w65/udivhi3.S newlib/libc/machine/w65/umodhi3.S newlib/libc/machine/x86_64/Makefile.am newlib/libc/machine/x86_64/Makefile.in newlib/libc/machine/x86_64/aclocal.m4 newlib/libc/machine/x86_64/configure newlib/libc/machine/x86_64/configure.in newlib/libc/machine/x86_64/memcpy.S newlib/libc/machine/x86_64/memset.S newlib/libc/machine/x86_64/setjmp.S newlib/libc/machine/x86_64/x86_64mach.h newlib/libc/machine/xc16x/Makefile.am newlib/libc/machine/xc16x/Makefile.in newlib/libc/machine/xc16x/aclocal.m4 newlib/libc/machine/xc16x/configure newlib/libc/machine/xc16x/configure.in newlib/libc/machine/xc16x/putchar.c newlib/libc/machine/xc16x/puts.c newlib/libc/machine/xc16x/setjmp.S newlib/libc/machine/xscale/Makefile.am newlib/libc/machine/xscale/Makefile.in newlib/libc/machine/xscale/aclocal.m4 newlib/libc/machine/xscale/configure newlib/libc/machine/xscale/configure.in newlib/libc/machine/xscale/machine/profile.h newlib/libc/machine/xscale/memchr.c newlib/libc/machine/xscale/memcmp.c newlib/libc/machine/xscale/memcpy.c newlib/libc/machine/xscale/memmove.c newlib/libc/machine/xscale/memset.c newlib/libc/machine/xscale/setjmp.S newlib/libc/machine/xscale/strchr.c newlib/libc/machine/xscale/strcmp.c newlib/libc/machine/xscale/strcpy.c newlib/libc/machine/xscale/strlen.c newlib/libc/machine/xscale/xscale.h newlib/libc/machine/xstormy16/Makefile.am newlib/libc/machine/xstormy16/Makefile.in newlib/libc/machine/xstormy16/aclocal.m4 newlib/libc/machine/xstormy16/configure newlib/libc/machine/xstormy16/configure.in newlib/libc/machine/xstormy16/mallocr.c newlib/libc/machine/xstormy16/setjmp.S newlib/libc/machine/xstormy16/tiny-malloc.c newlib/libc/machine/z8k/Makefile.am newlib/libc/machine/z8k/Makefile.in newlib/libc/machine/z8k/aclocal.m4 newlib/libc/machine/z8k/args.h newlib/libc/machine/z8k/configure newlib/libc/machine/z8k/configure.in newlib/libc/machine/z8k/memcmp.S newlib/libc/machine/z8k/memcpy.S newlib/libc/machine/z8k/memmove.S newlib/libc/machine/z8k/memset.S newlib/libc/machine/z8k/setjmp.S newlib/libc/misc/Makefile.am newlib/libc/misc/Makefile.in newlib/libc/misc/__dprintf.c newlib/libc/misc/ffs.c newlib/libc/misc/init.c newlib/libc/misc/misc.tex newlib/libc/misc/unctrl.c newlib/libc/posix/COPYRIGHT newlib/libc/posix/Makefile.am newlib/libc/posix/Makefile.in newlib/libc/posix/_isatty.c newlib/libc/posix/cclass.h newlib/libc/posix/closedir.c newlib/libc/posix/cname.h newlib/libc/posix/collate.c newlib/libc/posix/collate.h newlib/libc/posix/collcmp.c newlib/libc/posix/creat.c newlib/libc/posix/engine.c newlib/libc/posix/execl.c newlib/libc/posix/execle.c newlib/libc/posix/execlp.c newlib/libc/posix/execv.c newlib/libc/posix/execve.c newlib/libc/posix/execvp.c newlib/libc/posix/fnmatch.3 newlib/libc/posix/fnmatch.c newlib/libc/posix/glob.3 newlib/libc/posix/glob.c newlib/libc/posix/isatty.c newlib/libc/posix/namespace.h newlib/libc/posix/opendir.c newlib/libc/posix/popen.c newlib/libc/posix/posix.tex newlib/libc/posix/readdir.c newlib/libc/posix/readdir_r.c newlib/libc/posix/regcomp.c newlib/libc/posix/regerror.c newlib/libc/posix/regex.3 newlib/libc/posix/regex2.h newlib/libc/posix/regexec.c newlib/libc/posix/regfree.c newlib/libc/posix/rewinddir.c newlib/libc/posix/rune.h newlib/libc/posix/runetype.h newlib/libc/posix/scandir.c newlib/libc/posix/seekdir.c newlib/libc/posix/sleep.c newlib/libc/posix/sysexits.h newlib/libc/posix/telldir.c newlib/libc/posix/un-namespace.h newlib/libc/posix/usleep.c newlib/libc/posix/utils.h newlib/libc/posix/wordexp.c newlib/libc/posix/wordfree.c newlib/libc/reent/Makefile.am newlib/libc/reent/Makefile.in newlib/libc/reent/closer.c newlib/libc/reent/execr.c newlib/libc/reent/fcntlr.c newlib/libc/reent/fstat64r.c newlib/libc/reent/fstatr.c newlib/libc/reent/getreent.c newlib/libc/reent/gettimeofdayr.c newlib/libc/reent/impure.c newlib/libc/reent/isattyr.c newlib/libc/reent/linkr.c newlib/libc/reent/lseek64r.c newlib/libc/reent/lseekr.c newlib/libc/reent/mkdirr.c newlib/libc/reent/open64r.c newlib/libc/reent/openr.c newlib/libc/reent/readr.c newlib/libc/reent/reent.c newlib/libc/reent/reent.tex newlib/libc/reent/renamer.c newlib/libc/reent/sbrkr.c newlib/libc/reent/signalr.c newlib/libc/reent/signgam.c newlib/libc/reent/stat64r.c newlib/libc/reent/statr.c newlib/libc/reent/timesr.c newlib/libc/reent/unlinkr.c newlib/libc/reent/writer.c newlib/libc/saber newlib/libc/search/Makefile.am newlib/libc/search/Makefile.in newlib/libc/search/bsearch.c newlib/libc/search/db_local.h newlib/libc/search/extern.h newlib/libc/search/hash.c newlib/libc/search/hash.h newlib/libc/search/hash_bigkey.c newlib/libc/search/hash_buf.c newlib/libc/search/hash_func.c newlib/libc/search/hash_log2.c newlib/libc/search/hash_page.c newlib/libc/search/hcreate.3 newlib/libc/search/hcreate.c newlib/libc/search/hcreate_r.c newlib/libc/search/page.h newlib/libc/search/qsort.c newlib/libc/search/tdelete.c newlib/libc/search/tdestroy.c newlib/libc/search/tfind.c newlib/libc/search/tsearch.3 newlib/libc/search/tsearch.c newlib/libc/search/twalk.c newlib/libc/signal/Makefile.am newlib/libc/signal/Makefile.in newlib/libc/signal/raise.c newlib/libc/signal/signal.c newlib/libc/signal/signal.tex newlib/libc/stdio/Makefile.am newlib/libc/stdio/Makefile.in newlib/libc/stdio/asiprintf.c newlib/libc/stdio/asniprintf.c newlib/libc/stdio/asnprintf.c newlib/libc/stdio/asprintf.c newlib/libc/stdio/clearerr.c newlib/libc/stdio/diprintf.c newlib/libc/stdio/dprintf.c newlib/libc/stdio/fclose.c newlib/libc/stdio/fcloseall.c newlib/libc/stdio/fdopen.c newlib/libc/stdio/feof.c newlib/libc/stdio/ferror.c newlib/libc/stdio/fflush.c newlib/libc/stdio/fgetc.c newlib/libc/stdio/fgetpos.c newlib/libc/stdio/fgets.c newlib/libc/stdio/fgetwc.c newlib/libc/stdio/fgetws.c newlib/libc/stdio/fileno.c newlib/libc/stdio/findfp.c newlib/libc/stdio/fiprintf.c newlib/libc/stdio/fiscanf.c newlib/libc/stdio/flags.c newlib/libc/stdio/floatio.h newlib/libc/stdio/fmemopen.c newlib/libc/stdio/fopen.c newlib/libc/stdio/fopencookie.c newlib/libc/stdio/fprintf.c newlib/libc/stdio/fpurge.c newlib/libc/stdio/fputc.c newlib/libc/stdio/fputs.c newlib/libc/stdio/fputwc.c newlib/libc/stdio/fputws.c newlib/libc/stdio/fread.c newlib/libc/stdio/freopen.c newlib/libc/stdio/fscanf.c newlib/libc/stdio/fseek.c newlib/libc/stdio/fseeko.c newlib/libc/stdio/fsetpos.c newlib/libc/stdio/ftell.c newlib/libc/stdio/ftello.c newlib/libc/stdio/funopen.c newlib/libc/stdio/fvwrite.c newlib/libc/stdio/fvwrite.h newlib/libc/stdio/fwalk.c newlib/libc/stdio/fwide.c newlib/libc/stdio/fwprintf.c newlib/libc/stdio/fwrite.c newlib/libc/stdio/fwscanf.c newlib/libc/stdio/getc.c newlib/libc/stdio/getc_u.c newlib/libc/stdio/getchar.c newlib/libc/stdio/getchar_u.c newlib/libc/stdio/getdelim.c newlib/libc/stdio/getline.c newlib/libc/stdio/gets.c newlib/libc/stdio/getw.c newlib/libc/stdio/getwc.c newlib/libc/stdio/getwchar.c newlib/libc/stdio/iprintf.c newlib/libc/stdio/iscanf.c newlib/libc/stdio/local.h newlib/libc/stdio/makebuf.c newlib/libc/stdio/mktemp.c newlib/libc/stdio/open_memstream.c newlib/libc/stdio/perror.c newlib/libc/stdio/printf.c newlib/libc/stdio/putc.c newlib/libc/stdio/putc_u.c newlib/libc/stdio/putchar.c newlib/libc/stdio/putchar_u.c newlib/libc/stdio/puts.c newlib/libc/stdio/putw.c newlib/libc/stdio/putwc.c newlib/libc/stdio/putwchar.c newlib/libc/stdio/refill.c newlib/libc/stdio/remove.c newlib/libc/stdio/rename.c newlib/libc/stdio/rewind.c newlib/libc/stdio/rget.c newlib/libc/stdio/scanf.c newlib/libc/stdio/sccl.c newlib/libc/stdio/setbuf.c newlib/libc/stdio/setbuffer.c newlib/libc/stdio/setlinebuf.c newlib/libc/stdio/setvbuf.c newlib/libc/stdio/siprintf.c newlib/libc/stdio/siscanf.c newlib/libc/stdio/sniprintf.c newlib/libc/stdio/snprintf.c newlib/libc/stdio/sprintf.c newlib/libc/stdio/sscanf.c newlib/libc/stdio/stdio.c newlib/libc/stdio/stdio.tex newlib/libc/stdio/swprintf.c newlib/libc/stdio/swscanf.c newlib/libc/stdio/tmpfile.c newlib/libc/stdio/tmpnam.c newlib/libc/stdio/ungetc.c newlib/libc/stdio/ungetwc.c newlib/libc/stdio/vasiprintf.c newlib/libc/stdio/vasniprintf.c newlib/libc/stdio/vasnprintf.c newlib/libc/stdio/vasprintf.c newlib/libc/stdio/vdiprintf.c newlib/libc/stdio/vdprintf.c newlib/libc/stdio/vfieeefp.h newlib/libc/stdio/vfprintf.c newlib/libc/stdio/vfscanf.c newlib/libc/stdio/vfwprintf.c newlib/libc/stdio/vfwscanf.c newlib/libc/stdio/viprintf.c newlib/libc/stdio/viscanf.c newlib/libc/stdio/vprintf.c newlib/libc/stdio/vscanf.c newlib/libc/stdio/vsiprintf.c newlib/libc/stdio/vsiscanf.c newlib/libc/stdio/vsniprintf.c newlib/libc/stdio/vsnprintf.c newlib/libc/stdio/vsprintf.c newlib/libc/stdio/vsscanf.c newlib/libc/stdio/vswprintf.c newlib/libc/stdio/vswscanf.c newlib/libc/stdio/vwprintf.c newlib/libc/stdio/vwscanf.c newlib/libc/stdio/wbuf.c newlib/libc/stdio/wprintf.c newlib/libc/stdio/wscanf.c newlib/libc/stdio/wsetup.c newlib/libc/stdio64/Makefile.am newlib/libc/stdio64/Makefile.in newlib/libc/stdio64/dummy.c newlib/libc/stdio64/fdopen64.c newlib/libc/stdio64/fgetpos64.c newlib/libc/stdio64/fopen64.c newlib/libc/stdio64/freopen64.c newlib/libc/stdio64/fseeko64.c newlib/libc/stdio64/fsetpos64.c newlib/libc/stdio64/ftello64.c newlib/libc/stdio64/stdio64.c newlib/libc/stdio64/stdio64.tex newlib/libc/stdio64/tmpfile64.c newlib/libc/stdlib/Makefile.am newlib/libc/stdlib/Makefile.in newlib/libc/stdlib/_Exit.c newlib/libc/stdlib/__adjust.c newlib/libc/stdlib/__atexit.c newlib/libc/stdlib/__call_atexit.c newlib/libc/stdlib/__exp10.c newlib/libc/stdlib/__ten_mu.c newlib/libc/stdlib/a64l.c newlib/libc/stdlib/abort.c newlib/libc/stdlib/abs.c newlib/libc/stdlib/assert.c newlib/libc/stdlib/atexit.c newlib/libc/stdlib/atexit.h newlib/libc/stdlib/atof.c newlib/libc/stdlib/atoff.c newlib/libc/stdlib/atoi.c newlib/libc/stdlib/atol.c newlib/libc/stdlib/atoll.c newlib/libc/stdlib/btowc.c newlib/libc/stdlib/calloc.c newlib/libc/stdlib/cxa_atexit.c newlib/libc/stdlib/cxa_finalize.c newlib/libc/stdlib/div.c newlib/libc/stdlib/drand48.c newlib/libc/stdlib/dtoa.c newlib/libc/stdlib/dtoastub.c newlib/libc/stdlib/ecvtbuf.c newlib/libc/stdlib/efgcvt.c newlib/libc/stdlib/environ.c newlib/libc/stdlib/envlock.c newlib/libc/stdlib/eprintf.c newlib/libc/stdlib/erand48.c newlib/libc/stdlib/exit.c newlib/libc/stdlib/gd_qnan.h newlib/libc/stdlib/gdtoa-gethex.c newlib/libc/stdlib/gdtoa-hexnan.c newlib/libc/stdlib/gdtoa.h newlib/libc/stdlib/getenv.c newlib/libc/stdlib/getenv_r.c newlib/libc/stdlib/getopt.c newlib/libc/stdlib/getsubopt.3 newlib/libc/stdlib/getsubopt.c newlib/libc/stdlib/jrand48.c newlib/libc/stdlib/l64a.c newlib/libc/stdlib/labs.c newlib/libc/stdlib/lcong48.c newlib/libc/stdlib/ldiv.c newlib/libc/stdlib/ldtoa.c newlib/libc/stdlib/llabs.c newlib/libc/stdlib/lldiv.c newlib/libc/stdlib/local.h newlib/libc/stdlib/lrand48.c newlib/libc/stdlib/malign.c newlib/libc/stdlib/malloc.c newlib/libc/stdlib/mallocr.c newlib/libc/stdlib/mbctype.h newlib/libc/stdlib/mblen.c newlib/libc/stdlib/mblen_r.c newlib/libc/stdlib/mbrlen.c newlib/libc/stdlib/mbrtowc.c newlib/libc/stdlib/mbsinit.c newlib/libc/stdlib/mbsnrtowcs.c newlib/libc/stdlib/mbsrtowcs.c newlib/libc/stdlib/mbstowcs.c newlib/libc/stdlib/mbstowcs_r.c newlib/libc/stdlib/mbtowc.c newlib/libc/stdlib/mbtowc_r.c newlib/libc/stdlib/mlock.c newlib/libc/stdlib/mprec.c newlib/libc/stdlib/mprec.h newlib/libc/stdlib/mrand48.c newlib/libc/stdlib/msize.c newlib/libc/stdlib/mstats.c newlib/libc/stdlib/mtrim.c newlib/libc/stdlib/nrand48.c newlib/libc/stdlib/on_exit.c newlib/libc/stdlib/putenv.c newlib/libc/stdlib/putenv_r.c newlib/libc/stdlib/rand.c newlib/libc/stdlib/rand48.c newlib/libc/stdlib/rand48.h newlib/libc/stdlib/rand_r.c newlib/libc/stdlib/realloc.c newlib/libc/stdlib/reallocf.c newlib/libc/stdlib/sb_charsets.c newlib/libc/stdlib/seed48.c newlib/libc/stdlib/setenv.c newlib/libc/stdlib/setenv_r.c newlib/libc/stdlib/srand48.c newlib/libc/stdlib/std.h newlib/libc/stdlib/stdlib.tex newlib/libc/stdlib/strtod.c newlib/libc/stdlib/strtol.c newlib/libc/stdlib/strtold.c newlib/libc/stdlib/strtoll.c newlib/libc/stdlib/strtoll_r.c newlib/libc/stdlib/strtoul.c newlib/libc/stdlib/strtoull.c newlib/libc/stdlib/strtoull_r.c newlib/libc/stdlib/system.c newlib/libc/stdlib/valloc.c newlib/libc/stdlib/wcrtomb.c newlib/libc/stdlib/wcsnrtombs.c newlib/libc/stdlib/wcsrtombs.c newlib/libc/stdlib/wcstod.c newlib/libc/stdlib/wcstol.c newlib/libc/stdlib/wcstold.c newlib/libc/stdlib/wcstoll.c newlib/libc/stdlib/wcstoll_r.c newlib/libc/stdlib/wcstombs.c newlib/libc/stdlib/wcstombs_r.c newlib/libc/stdlib/wcstoul.c newlib/libc/stdlib/wcstoull.c newlib/libc/stdlib/wcstoull_r.c newlib/libc/stdlib/wctob.c newlib/libc/stdlib/wctomb.c newlib/libc/stdlib/wctomb_r.c newlib/libc/string/Makefile.am newlib/libc/string/Makefile.in newlib/libc/string/bcmp.c newlib/libc/string/bcopy.c newlib/libc/string/bzero.c newlib/libc/string/index.c newlib/libc/string/local.h newlib/libc/string/memccpy.c newlib/libc/string/memchr.c newlib/libc/string/memcmp.c newlib/libc/string/memcpy.c newlib/libc/string/memmem.c newlib/libc/string/memmove.c newlib/libc/string/mempcpy.c newlib/libc/string/memset.c newlib/libc/string/rindex.c newlib/libc/string/stpcpy.c newlib/libc/string/stpncpy.c newlib/libc/string/str-two-way.h newlib/libc/string/strcasecmp.c newlib/libc/string/strcasestr.c newlib/libc/string/strcat.c newlib/libc/string/strchr.c newlib/libc/string/strcmp.c newlib/libc/string/strcoll.c newlib/libc/string/strcpy.c newlib/libc/string/strcspn.c newlib/libc/string/strdup.c newlib/libc/string/strdup_r.c newlib/libc/string/strerror.c newlib/libc/string/strerror_r.c newlib/libc/string/strings.tex newlib/libc/string/strlcat.c newlib/libc/string/strlcpy.c newlib/libc/string/strlen.c newlib/libc/string/strlwr.c newlib/libc/string/strncasecmp.c newlib/libc/string/strncat.c newlib/libc/string/strncmp.c newlib/libc/string/strncpy.c newlib/libc/string/strndup.c newlib/libc/string/strndup_r.c newlib/libc/string/strnlen.c newlib/libc/string/strpbrk.c newlib/libc/string/strrchr.c newlib/libc/string/strsep.c newlib/libc/string/strspn.c newlib/libc/string/strstr.c newlib/libc/string/strtok.c newlib/libc/string/strtok_r.c newlib/libc/string/strupr.c newlib/libc/string/strxfrm.c newlib/libc/string/swab.c newlib/libc/string/u_strerr.c newlib/libc/string/wcpcpy.c newlib/libc/string/wcpncpy.c newlib/libc/string/wcscasecmp.c newlib/libc/string/wcscat.c newlib/libc/string/wcschr.c newlib/libc/string/wcscmp.c newlib/libc/string/wcscoll.c newlib/libc/string/wcscpy.c newlib/libc/string/wcscspn.c newlib/libc/string/wcsdup.c newlib/libc/string/wcslcat.c newlib/libc/string/wcslcpy.c newlib/libc/string/wcslen.c newlib/libc/string/wcsncasecmp.c newlib/libc/string/wcsncat.c newlib/libc/string/wcsncmp.c newlib/libc/string/wcsncpy.c newlib/libc/string/wcsnlen.c newlib/libc/string/wcspbrk.c newlib/libc/string/wcsrchr.c newlib/libc/string/wcsspn.c newlib/libc/string/wcsstr.c newlib/libc/string/wcstok.c newlib/libc/string/wcstrings.tex newlib/libc/string/wcswidth.c newlib/libc/string/wcsxfrm.c newlib/libc/string/wcwidth.c newlib/libc/string/wmemchr.c newlib/libc/string/wmemcmp.c newlib/libc/string/wmemcpy.c newlib/libc/string/wmemmove.c newlib/libc/string/wmemset.c newlib/libc/sys.tex newlib/libc/sys/Makefile.am newlib/libc/sys/Makefile.in newlib/libc/sys/a29khif/Makefile.am newlib/libc/sys/a29khif/Makefile.in newlib/libc/sys/a29khif/_alloc.S newlib/libc/sys/a29khif/_close.S newlib/libc/sys/a29khif/_cycles.S newlib/libc/sys/a29khif/_exit.S newlib/libc/sys/a29khif/_fstat.S newlib/libc/sys/a29khif/_getpsiz.S newlib/libc/sys/a29khif/_gettz.S newlib/libc/sys/a29khif/_ioctl.S newlib/libc/sys/a29khif/_iostat.S newlib/libc/sys/a29khif/_iowait.S newlib/libc/sys/a29khif/_isatty.S newlib/libc/sys/a29khif/_lseek.S newlib/libc/sys/a29khif/_open.S newlib/libc/sys/a29khif/_query.S newlib/libc/sys/a29khif/_read.S newlib/libc/sys/a29khif/_sbrk.S newlib/libc/sys/a29khif/_setim.S newlib/libc/sys/a29khif/_settrap.S newlib/libc/sys/a29khif/_setvec.S newlib/libc/sys/a29khif/_tmpnam.S newlib/libc/sys/a29khif/_write.S newlib/libc/sys/a29khif/aclocal.m4 newlib/libc/sys/a29khif/alloc.S newlib/libc/sys/a29khif/clock.S newlib/libc/sys/a29khif/configure newlib/libc/sys/a29khif/configure.in newlib/libc/sys/a29khif/crt0.S newlib/libc/sys/a29khif/getargs.S newlib/libc/sys/a29khif/getenv.S newlib/libc/sys/a29khif/getpid.c newlib/libc/sys/a29khif/kill.c newlib/libc/sys/a29khif/read.S newlib/libc/sys/a29khif/remove.S newlib/libc/sys/a29khif/rename.S newlib/libc/sys/a29khif/signal.S newlib/libc/sys/a29khif/stubs.S newlib/libc/sys/a29khif/sys/cpudef.h newlib/libc/sys/a29khif/sys/fpsymbol.h newlib/libc/sys/a29khif/sys/intrinsi.h newlib/libc/sys/a29khif/sys/macros.h newlib/libc/sys/a29khif/sys/proreg.h newlib/libc/sys/a29khif/sys/romdcl.h newlib/libc/sys/a29khif/sys/smartmac.h newlib/libc/sys/a29khif/sys/sysmac.h newlib/libc/sys/a29khif/systime.S newlib/libc/sys/a29khif/vec.S newlib/libc/sys/aclocal.m4 newlib/libc/sys/arc/Makefile.am newlib/libc/sys/arc/Makefile.in newlib/libc/sys/arc/aclocal.m4 newlib/libc/sys/arc/configure newlib/libc/sys/arc/configure.in newlib/libc/sys/arc/crt0.S newlib/libc/sys/arc/dummy.S newlib/libc/sys/arc/isatty.c newlib/libc/sys/arc/mem-layout.c newlib/libc/sys/arc/sbrk.c newlib/libc/sys/arc/sys/syscall.h newlib/libc/sys/arc/syscalls.c newlib/libc/sys/arm/Makefile.am newlib/libc/sys/arm/Makefile.in newlib/libc/sys/arm/aclocal.m4 newlib/libc/sys/arm/aeabi_atexit.c newlib/libc/sys/arm/configure newlib/libc/sys/arm/configure.in newlib/libc/sys/arm/crt0.S newlib/libc/sys/arm/libcfunc.c newlib/libc/sys/arm/swi.h newlib/libc/sys/arm/sys/fcntl.h newlib/libc/sys/arm/sys/param.h newlib/libc/sys/arm/syscalls.c newlib/libc/sys/arm/trap.S newlib/libc/sys/configure newlib/libc/sys/configure.in newlib/libc/sys/d10v/Makefile.am newlib/libc/sys/d10v/Makefile.in newlib/libc/sys/d10v/aclocal.m4 newlib/libc/sys/d10v/configure newlib/libc/sys/d10v/configure.in newlib/libc/sys/d10v/creat.c newlib/libc/sys/d10v/crt0.S newlib/libc/sys/d10v/sys/syscall.h newlib/libc/sys/d10v/syscalls.c newlib/libc/sys/d10v/trap.S newlib/libc/sys/decstation/Makefile.am newlib/libc/sys/decstation/Makefile.in newlib/libc/sys/decstation/_main.c newlib/libc/sys/decstation/aclocal.m4 newlib/libc/sys/decstation/configure newlib/libc/sys/decstation/configure.in newlib/libc/sys/decstation/sys/dirent.h newlib/libc/sys/h8300hms/Makefile.am newlib/libc/sys/h8300hms/Makefile.in newlib/libc/sys/h8300hms/_exit.S newlib/libc/sys/h8300hms/aclocal.m4 newlib/libc/sys/h8300hms/close.S newlib/libc/sys/h8300hms/configure newlib/libc/sys/h8300hms/configure.in newlib/libc/sys/h8300hms/crt0.S newlib/libc/sys/h8300hms/crt1.c newlib/libc/sys/h8300hms/fstat.S newlib/libc/sys/h8300hms/lseek.S newlib/libc/sys/h8300hms/misc.c newlib/libc/sys/h8300hms/open.S newlib/libc/sys/h8300hms/read.S newlib/libc/sys/h8300hms/sbrk.c newlib/libc/sys/h8300hms/setarch.h newlib/libc/sys/h8300hms/stat.S newlib/libc/sys/h8300hms/sys/file.h newlib/libc/sys/h8300hms/sys/syscall.h newlib/libc/sys/h8300hms/syscalls.c newlib/libc/sys/h8300hms/write.S newlib/libc/sys/h8500hms/Makefile.am newlib/libc/sys/h8500hms/Makefile.in newlib/libc/sys/h8500hms/aclocal.m4 newlib/libc/sys/h8500hms/configure newlib/libc/sys/h8500hms/configure.in newlib/libc/sys/h8500hms/crt0.c newlib/libc/sys/h8500hms/misc.c newlib/libc/sys/h8500hms/syscalls.c newlib/libc/sys/linux/Makefile.am newlib/libc/sys/linux/Makefile.in newlib/libc/sys/linux/aclocal.m4 newlib/libc/sys/linux/aio.c newlib/libc/sys/linux/aio64.c newlib/libc/sys/linux/argp/Makefile.am newlib/libc/sys/linux/argp/Makefile.in newlib/libc/sys/linux/argp/argp-ba.c newlib/libc/sys/linux/argp/argp-eexst.c newlib/libc/sys/linux/argp/argp-fmtstream.c newlib/libc/sys/linux/argp/argp-fmtstream.h newlib/libc/sys/linux/argp/argp-fs-xinl.c newlib/libc/sys/linux/argp/argp-help.c newlib/libc/sys/linux/argp/argp-namefrob.h newlib/libc/sys/linux/argp/argp-parse.c newlib/libc/sys/linux/argp/argp-pv.c newlib/libc/sys/linux/argp/argp-pvh.c newlib/libc/sys/linux/argp/argp-xinl.c newlib/libc/sys/linux/bits/dirent.h newlib/libc/sys/linux/bits/initspin.h newlib/libc/sys/linux/bits/libc-lock.h newlib/libc/sys/linux/bits/pthreadtypes.h newlib/libc/sys/linux/bits/typesizes.h newlib/libc/sys/linux/bp-checks.h newlib/libc/sys/linux/brk.c newlib/libc/sys/linux/calloc.c newlib/libc/sys/linux/callocr.c newlib/libc/sys/linux/cfreer.c newlib/libc/sys/linux/cfspeed.c newlib/libc/sys/linux/clock_getres.c newlib/libc/sys/linux/clock_gettime.c newlib/libc/sys/linux/clock_settime.c newlib/libc/sys/linux/cmath/Makefile.am newlib/libc/sys/linux/cmath/Makefile.in newlib/libc/sys/linux/cmath/math_private.h newlib/libc/sys/linux/cmath/s_cacos.c newlib/libc/sys/linux/cmath/s_cacosf.c newlib/libc/sys/linux/cmath/s_cacosh.c newlib/libc/sys/linux/cmath/s_cacoshf.c newlib/libc/sys/linux/cmath/s_cacoshl.c newlib/libc/sys/linux/cmath/s_cacosl.c newlib/libc/sys/linux/cmath/s_casin.c newlib/libc/sys/linux/cmath/s_casinf.c newlib/libc/sys/linux/cmath/s_casinh.c newlib/libc/sys/linux/cmath/s_casinhf.c newlib/libc/sys/linux/cmath/s_casinhl.c newlib/libc/sys/linux/cmath/s_casinl.c newlib/libc/sys/linux/cmath/s_catan.c newlib/libc/sys/linux/cmath/s_catanf.c newlib/libc/sys/linux/cmath/s_catanh.c newlib/libc/sys/linux/cmath/s_catanhf.c newlib/libc/sys/linux/cmath/s_catanhl.c newlib/libc/sys/linux/cmath/s_catanl.c newlib/libc/sys/linux/cmath/s_cbrtl.c newlib/libc/sys/linux/cmath/s_ccos.c newlib/libc/sys/linux/cmath/s_ccosf.c newlib/libc/sys/linux/cmath/s_ccosh.c newlib/libc/sys/linux/cmath/s_ccoshf.c newlib/libc/sys/linux/cmath/s_ccoshl.c newlib/libc/sys/linux/cmath/s_ccosl.c newlib/libc/sys/linux/cmath/s_cexp.c newlib/libc/sys/linux/cmath/s_cexpf.c newlib/libc/sys/linux/cmath/s_cexpl.c newlib/libc/sys/linux/cmath/s_clog.c newlib/libc/sys/linux/cmath/s_clog10.c newlib/libc/sys/linux/cmath/s_clog10f.c newlib/libc/sys/linux/cmath/s_clog10l.c newlib/libc/sys/linux/cmath/s_clogf.c newlib/libc/sys/linux/cmath/s_clogl.c newlib/libc/sys/linux/cmath/s_cpow.c newlib/libc/sys/linux/cmath/s_cpowf.c newlib/libc/sys/linux/cmath/s_cpowl.c newlib/libc/sys/linux/cmath/s_cproj.c newlib/libc/sys/linux/cmath/s_cprojf.c newlib/libc/sys/linux/cmath/s_cprojl.c newlib/libc/sys/linux/cmath/s_csin.c newlib/libc/sys/linux/cmath/s_csinf.c newlib/libc/sys/linux/cmath/s_csinh.c newlib/libc/sys/linux/cmath/s_csinhf.c newlib/libc/sys/linux/cmath/s_csinhl.c newlib/libc/sys/linux/cmath/s_csinl.c newlib/libc/sys/linux/cmath/s_csqrt.c newlib/libc/sys/linux/cmath/s_csqrtf.c newlib/libc/sys/linux/cmath/s_csqrtl.c newlib/libc/sys/linux/cmath/s_ctan.c newlib/libc/sys/linux/cmath/s_ctanf.c newlib/libc/sys/linux/cmath/s_ctanh.c newlib/libc/sys/linux/cmath/s_ctanhf.c newlib/libc/sys/linux/cmath/s_ctanhl.c newlib/libc/sys/linux/cmath/s_ctanl.c newlib/libc/sys/linux/config.h newlib/libc/sys/linux/configure newlib/libc/sys/linux/configure.in newlib/libc/sys/linux/confstr.c newlib/libc/sys/linux/confstr.h newlib/libc/sys/linux/crt1.c newlib/libc/sys/linux/ctermid.c newlib/libc/sys/linux/dl/Makefile.am newlib/libc/sys/linux/dl/Makefile.in newlib/libc/sys/linux/dl/abi-tag.h newlib/libc/sys/linux/dl/atomicity.h newlib/libc/sys/linux/dl/dl-addr.c newlib/libc/sys/linux/dl/dl-cache.c newlib/libc/sys/linux/dl/dl-cache.h newlib/libc/sys/linux/dl/dl-close.c newlib/libc/sys/linux/dl/dl-debug.c newlib/libc/sys/linux/dl/dl-deps.c newlib/libc/sys/linux/dl/dl-dst.h newlib/libc/sys/linux/dl/dl-error.c newlib/libc/sys/linux/dl/dl-fini.c newlib/libc/sys/linux/dl/dl-init.c newlib/libc/sys/linux/dl/dl-iteratephdr.c newlib/libc/sys/linux/dl/dl-libc.c newlib/libc/sys/linux/dl/dl-librecon.h newlib/libc/sys/linux/dl/dl-load.c newlib/libc/sys/linux/dl/dl-local.h newlib/libc/sys/linux/dl/dl-lookup.c newlib/libc/sys/linux/dl/dl-lookupcfg.h newlib/libc/sys/linux/dl/dl-minimal.c newlib/libc/sys/linux/dl/dl-misc.c newlib/libc/sys/linux/dl/dl-object.c newlib/libc/sys/linux/dl/dl-open.c newlib/libc/sys/linux/dl/dl-osinfo.h newlib/libc/sys/linux/dl/dl-profile.c newlib/libc/sys/linux/dl/dl-profstub.c newlib/libc/sys/linux/dl/dl-reloc.c newlib/libc/sys/linux/dl/dl-runtime.c newlib/libc/sys/linux/dl/dl-support.c newlib/libc/sys/linux/dl/dl-sym.c newlib/libc/sys/linux/dl/dl-version.c newlib/libc/sys/linux/dl/do-lookup.h newlib/libc/sys/linux/dl/do-rel.h newlib/libc/sys/linux/dl/dynamic-link.h newlib/libc/sys/linux/dl/kernel-features.h newlib/libc/sys/linux/dl/ldsodefs.h newlib/libc/sys/linux/dl/libintl.h newlib/libc/sys/linux/dl/trusted-dirs.h newlib/libc/sys/linux/dl/unsecvars.h newlib/libc/sys/linux/fclean.c newlib/libc/sys/linux/flockfile.c newlib/libc/sys/linux/fpathconf.c newlib/libc/sys/linux/free.c newlib/libc/sys/linux/freer.c newlib/libc/sys/linux/fstab.c newlib/libc/sys/linux/fstatvfs.c newlib/libc/sys/linux/fstatvfs64.c newlib/libc/sys/linux/ftok.c newlib/libc/sys/linux/ftw.c newlib/libc/sys/linux/ftw64.c newlib/libc/sys/linux/funlockfile.c newlib/libc/sys/linux/getdate.c newlib/libc/sys/linux/getdate_err.c newlib/libc/sys/linux/gethostid.c newlib/libc/sys/linux/gethostname.c newlib/libc/sys/linux/getlogin.c newlib/libc/sys/linux/getopt.c newlib/libc/sys/linux/getopt1.c newlib/libc/sys/linux/getpwent.c newlib/libc/sys/linux/getreent.c newlib/libc/sys/linux/getrlimit64.c newlib/libc/sys/linux/getwd.c newlib/libc/sys/linux/hp-timing.h newlib/libc/sys/linux/iconv/Makefile.am newlib/libc/sys/linux/iconv/Makefile.in newlib/libc/sys/linux/iconv/categories.def newlib/libc/sys/linux/iconv/dummy-repertoire.c newlib/libc/sys/linux/iconv/gconv.c newlib/libc/sys/linux/iconv/gconv_builtin.c newlib/libc/sys/linux/iconv/gconv_builtin.h newlib/libc/sys/linux/iconv/gconv_cache.c newlib/libc/sys/linux/iconv/gconv_charset.h newlib/libc/sys/linux/iconv/gconv_close.c newlib/libc/sys/linux/iconv/gconv_conf.c newlib/libc/sys/linux/iconv/gconv_db.c newlib/libc/sys/linux/iconv/gconv_dl.c newlib/libc/sys/linux/iconv/gconv_int.h newlib/libc/sys/linux/iconv/gconv_open.c newlib/libc/sys/linux/iconv/gconv_simple.c newlib/libc/sys/linux/iconv/gconv_trans.c newlib/libc/sys/linux/iconv/hash-string.h newlib/libc/sys/linux/iconv/iconv.c newlib/libc/sys/linux/iconv/iconv.h newlib/libc/sys/linux/iconv/iconv_charmap.c newlib/libc/sys/linux/iconv/iconv_close.c newlib/libc/sys/linux/iconv/iconv_open.c newlib/libc/sys/linux/iconv/iconvconfig.h newlib/libc/sys/linux/iconv/loadinfo.h newlib/libc/sys/linux/iconv/localeinfo.h newlib/libc/sys/linux/iconv/loop.c newlib/libc/sys/linux/iconv/skeleton.c newlib/libc/sys/linux/ids.c newlib/libc/sys/linux/include/argp.h newlib/libc/sys/linux/include/arpa/ftp.h newlib/libc/sys/linux/include/arpa/inet.h newlib/libc/sys/linux/include/arpa/nameser.h newlib/libc/sys/linux/include/arpa/nameser_compat.h newlib/libc/sys/linux/include/arpa/telnet.h newlib/libc/sys/linux/include/arpa/tftp.h newlib/libc/sys/linux/include/bp-sym.h newlib/libc/sys/linux/include/cmathcalls.h newlib/libc/sys/linux/include/complex.h newlib/libc/sys/linux/include/dl-hash.h newlib/libc/sys/linux/include/dlfcn.h newlib/libc/sys/linux/include/fnmatch.h newlib/libc/sys/linux/include/gconv.h newlib/libc/sys/linux/include/getopt.h newlib/libc/sys/linux/include/glob.h newlib/libc/sys/linux/include/hesiod.h newlib/libc/sys/linux/include/iconv.h newlib/libc/sys/linux/include/ifaddrs.h newlib/libc/sys/linux/include/limits.h newlib/libc/sys/linux/include/link.h newlib/libc/sys/linux/include/ltdl.h newlib/libc/sys/linux/include/malloc.h newlib/libc/sys/linux/include/mcheck.h newlib/libc/sys/linux/include/mqueue.h newlib/libc/sys/linux/include/namespace.h newlib/libc/sys/linux/include/net/bpf.h newlib/libc/sys/linux/include/net/bpf_compat.h newlib/libc/sys/linux/include/net/bpfdesc.h newlib/libc/sys/linux/include/net/bridge.h newlib/libc/sys/linux/include/net/ethernet.h newlib/libc/sys/linux/include/net/fddi.h newlib/libc/sys/linux/include/net/if.h newlib/libc/sys/linux/include/net/if_arc.h newlib/libc/sys/linux/include/net/if_arp.h newlib/libc/sys/linux/include/net/if_dl.h newlib/libc/sys/linux/include/net/if_gif.h newlib/libc/sys/linux/include/net/if_ieee80211.h newlib/libc/sys/linux/include/net/if_llc.h newlib/libc/sys/linux/include/net/if_mib.h newlib/libc/sys/linux/include/net/if_ppp.h newlib/libc/sys/linux/include/net/if_slvar.h newlib/libc/sys/linux/include/net/if_sppp.h newlib/libc/sys/linux/include/net/if_stf.h newlib/libc/sys/linux/include/net/if_tap.h newlib/libc/sys/linux/include/net/if_tapvar.h newlib/libc/sys/linux/include/net/if_tun.h newlib/libc/sys/linux/include/net/if_tunvar.h newlib/libc/sys/linux/include/net/if_types.h newlib/libc/sys/linux/include/net/if_var.h newlib/libc/sys/linux/include/net/if_vlan_var.h newlib/libc/sys/linux/include/net/intrq.h newlib/libc/sys/linux/include/net/iso88025.h newlib/libc/sys/linux/include/net/net_osdep.h newlib/libc/sys/linux/include/net/netisr.h newlib/libc/sys/linux/include/net/pfil.h newlib/libc/sys/linux/include/net/pfkeyv2.h newlib/libc/sys/linux/include/net/ppp_comp.h newlib/libc/sys/linux/include/net/ppp_defs.h newlib/libc/sys/linux/include/net/radix.h newlib/libc/sys/linux/include/net/raw_cb.h newlib/libc/sys/linux/include/net/route.h newlib/libc/sys/linux/include/net/slcompress.h newlib/libc/sys/linux/include/net/slip.h newlib/libc/sys/linux/include/net/zlib.h newlib/libc/sys/linux/include/netconfig.h newlib/libc/sys/linux/include/netdb.h newlib/libc/sys/linux/include/netinet/icmp6.h newlib/libc/sys/linux/include/netinet/icmp_var.h newlib/libc/sys/linux/include/netinet/if_ether.h newlib/libc/sys/linux/include/netinet/igmp.h newlib/libc/sys/linux/include/netinet/igmp_var.h newlib/libc/sys/linux/include/netinet/in.h newlib/libc/sys/linux/include/netinet/in_gif.h newlib/libc/sys/linux/include/netinet/in_pcb.h newlib/libc/sys/linux/include/netinet/in_systm.h newlib/libc/sys/linux/include/netinet/in_var.h newlib/libc/sys/linux/include/netinet/ip.h newlib/libc/sys/linux/include/netinet/ip6.h newlib/libc/sys/linux/include/netinet/ip_dummynet.h newlib/libc/sys/linux/include/netinet/ip_ecn.h newlib/libc/sys/linux/include/netinet/ip_encap.h newlib/libc/sys/linux/include/netinet/ip_fw.h newlib/libc/sys/linux/include/netinet/ip_icmp.h newlib/libc/sys/linux/include/netinet/ip_mroute.h newlib/libc/sys/linux/include/netinet/ip_var.h newlib/libc/sys/linux/include/netinet/ipprotosw.h newlib/libc/sys/linux/include/netinet/tcp.h newlib/libc/sys/linux/include/netinet/tcp_debug.h newlib/libc/sys/linux/include/netinet/tcp_fsm.h newlib/libc/sys/linux/include/netinet/tcp_seq.h newlib/libc/sys/linux/include/netinet/tcp_timer.h newlib/libc/sys/linux/include/netinet/tcp_var.h newlib/libc/sys/linux/include/netinet/tcpip.h newlib/libc/sys/linux/include/netinet/udp.h newlib/libc/sys/linux/include/netinet/udp_var.h newlib/libc/sys/linux/include/netinet6/ah.h newlib/libc/sys/linux/include/netinet6/ah6.h newlib/libc/sys/linux/include/netinet6/esp.h newlib/libc/sys/linux/include/netinet6/esp6.h newlib/libc/sys/linux/include/netinet6/esp_rijndael.h newlib/libc/sys/linux/include/netinet6/icmp6.h newlib/libc/sys/linux/include/netinet6/in6.h newlib/libc/sys/linux/include/netinet6/in6_gif.h newlib/libc/sys/linux/include/netinet6/in6_ifattach.h newlib/libc/sys/linux/include/netinet6/in6_pcb.h newlib/libc/sys/linux/include/netinet6/in6_prefix.h newlib/libc/sys/linux/include/netinet6/in6_var.h newlib/libc/sys/linux/include/netinet6/ip6.h newlib/libc/sys/linux/include/netinet6/ip6_ecn.h newlib/libc/sys/linux/include/netinet6/ip6_fw.h newlib/libc/sys/linux/include/netinet6/ip6_mroute.h newlib/libc/sys/linux/include/netinet6/ip6_var.h newlib/libc/sys/linux/include/netinet6/ip6protosw.h newlib/libc/sys/linux/include/netinet6/ipcomp.h newlib/libc/sys/linux/include/netinet6/ipcomp6.h newlib/libc/sys/linux/include/netinet6/ipsec.h newlib/libc/sys/linux/include/netinet6/ipsec6.h newlib/libc/sys/linux/include/netinet6/mld6_var.h newlib/libc/sys/linux/include/netinet6/nd6.h newlib/libc/sys/linux/include/netinet6/pim6.h newlib/libc/sys/linux/include/netinet6/pim6_var.h newlib/libc/sys/linux/include/netinet6/raw_ip6.h newlib/libc/sys/linux/include/netinet6/scope6_var.h newlib/libc/sys/linux/include/netinet6/tcp6_var.h newlib/libc/sys/linux/include/netinet6/udp6_var.h newlib/libc/sys/linux/include/netns/idp.h newlib/libc/sys/linux/include/netns/idp_var.h newlib/libc/sys/linux/include/netns/ns.h newlib/libc/sys/linux/include/netns/ns_error.h newlib/libc/sys/linux/include/netns/ns_if.h newlib/libc/sys/linux/include/netns/ns_pcb.h newlib/libc/sys/linux/include/netns/sp.h newlib/libc/sys/linux/include/netns/spidp.h newlib/libc/sys/linux/include/netns/spp_debug.h newlib/libc/sys/linux/include/netns/spp_timer.h newlib/libc/sys/linux/include/netns/spp_var.h newlib/libc/sys/linux/include/paths.h newlib/libc/sys/linux/include/pthread.h newlib/libc/sys/linux/include/regex.h newlib/libc/sys/linux/include/resolv.h newlib/libc/sys/linux/include/rpc/Makefile newlib/libc/sys/linux/include/rpc/auth.h newlib/libc/sys/linux/include/rpc/auth_des.h newlib/libc/sys/linux/include/rpc/auth_kerb.h newlib/libc/sys/linux/include/rpc/auth_unix.h newlib/libc/sys/linux/include/rpc/clnt.h newlib/libc/sys/linux/include/rpc/clnt_soc.h newlib/libc/sys/linux/include/rpc/clnt_stat.h newlib/libc/sys/linux/include/rpc/des.h newlib/libc/sys/linux/include/rpc/des_crypt.h newlib/libc/sys/linux/include/rpc/nettype.h newlib/libc/sys/linux/include/rpc/pmap_clnt.h newlib/libc/sys/linux/include/rpc/pmap_prot.h newlib/libc/sys/linux/include/rpc/pmap_rmt.h newlib/libc/sys/linux/include/rpc/raw.h newlib/libc/sys/linux/include/rpc/rpc.h newlib/libc/sys/linux/include/rpc/rpc_com.h newlib/libc/sys/linux/include/rpc/rpc_msg.h newlib/libc/sys/linux/include/rpc/rpcb_clnt.h newlib/libc/sys/linux/include/rpc/rpcb_prot.h newlib/libc/sys/linux/include/rpc/rpcb_prot.x newlib/libc/sys/linux/include/rpc/rpcent.h newlib/libc/sys/linux/include/rpc/svc.h newlib/libc/sys/linux/include/rpc/svc_auth.h newlib/libc/sys/linux/include/rpc/svc_dg.h newlib/libc/sys/linux/include/rpc/svc_soc.h newlib/libc/sys/linux/include/rpc/types.h newlib/libc/sys/linux/include/rpc/xdr.h newlib/libc/sys/linux/include/rune.h newlib/libc/sys/linux/include/runetype.h newlib/libc/sys/linux/include/sched.h newlib/libc/sys/linux/include/semaphore.h newlib/libc/sys/linux/include/setjmp.h newlib/libc/sys/linux/include/setlocale.h newlib/libc/sys/linux/include/stdint.h newlib/libc/sys/linux/include/time.h newlib/libc/sys/linux/include/un-namespace.h newlib/libc/sys/linux/include/unistd.h newlib/libc/sys/linux/include/wordexp.h newlib/libc/sys/linux/inode.c newlib/libc/sys/linux/internal_statvfs.c newlib/libc/sys/linux/intl/Makefile.am newlib/libc/sys/linux/intl/Makefile.in newlib/libc/sys/linux/intl/bindtextdom.c newlib/libc/sys/linux/intl/catgets.c newlib/libc/sys/linux/intl/catgetsinfo.h newlib/libc/sys/linux/intl/config.h newlib/libc/sys/linux/intl/dcgettext.c newlib/libc/sys/linux/intl/dcigettext.c newlib/libc/sys/linux/intl/dcngettext.c newlib/libc/sys/linux/intl/dgettext.c newlib/libc/sys/linux/intl/dngettext.c newlib/libc/sys/linux/intl/explodename.c newlib/libc/sys/linux/intl/finddomain.c newlib/libc/sys/linux/intl/gettext.c newlib/libc/sys/linux/intl/gettext.h newlib/libc/sys/linux/intl/gettextP.h newlib/libc/sys/linux/intl/hash-string.h newlib/libc/sys/linux/intl/l10nflist.c newlib/libc/sys/linux/intl/lcl_stpcpy.c newlib/libc/sys/linux/intl/loadinfo.h newlib/libc/sys/linux/intl/loadmsgcat.c newlib/libc/sys/linux/intl/localealias.c newlib/libc/sys/linux/intl/ngettext.c newlib/libc/sys/linux/intl/open_catalog.c newlib/libc/sys/linux/intl/plural.c newlib/libc/sys/linux/intl/plural.y newlib/libc/sys/linux/intl/textdomain.c newlib/libc/sys/linux/io.c newlib/libc/sys/linux/io64.c newlib/libc/sys/linux/ipc.c newlib/libc/sys/linux/isatty.c newlib/libc/sys/linux/kernel_sigaction.h newlib/libc/sys/linux/libc-internal.h newlib/libc/sys/linux/libc-symbols.h newlib/libc/sys/linux/libc-tsd.h newlib/libc/sys/linux/libintl.h newlib/libc/sys/linux/linux.c newlib/libc/sys/linux/linux_fsinfo.h newlib/libc/sys/linux/linuxthreads/LICENSE newlib/libc/sys/linux/linuxthreads/Makefile.am newlib/libc/sys/linux/linuxthreads/Makefile.in newlib/libc/sys/linux/linuxthreads/aclocal.m4 newlib/libc/sys/linux/linuxthreads/attr.c newlib/libc/sys/linux/linuxthreads/barrier.c newlib/libc/sys/linux/linuxthreads/bits/initspin.h newlib/libc/sys/linux/linuxthreads/bits/libc-lock.h newlib/libc/sys/linux/linuxthreads/bits/libc-tsd.h newlib/libc/sys/linux/linuxthreads/bits/local_lim.h newlib/libc/sys/linux/linuxthreads/bits/posix_opt.h newlib/libc/sys/linux/linuxthreads/bits/pthreadtypes.h newlib/libc/sys/linux/linuxthreads/bits/sigthread.h newlib/libc/sys/linux/linuxthreads/bp-sym.h newlib/libc/sys/linux/linuxthreads/cancel.c newlib/libc/sys/linux/linuxthreads/condvar.c newlib/libc/sys/linux/linuxthreads/config.h newlib/libc/sys/linux/linuxthreads/configure newlib/libc/sys/linux/linuxthreads/configure.in newlib/libc/sys/linux/linuxthreads/defs.awk newlib/libc/sys/linux/linuxthreads/ecmutex.c newlib/libc/sys/linux/linuxthreads/events.c newlib/libc/sys/linux/linuxthreads/getcpuclockid.c newlib/libc/sys/linux/linuxthreads/getreent.c newlib/libc/sys/linux/linuxthreads/internals.h newlib/libc/sys/linux/linuxthreads/join.c newlib/libc/sys/linux/linuxthreads/joinrace.c newlib/libc/sys/linux/linuxthreads/kernel-features.h newlib/libc/sys/linux/linuxthreads/libc-internal.h newlib/libc/sys/linux/linuxthreads/libc-symbols.h newlib/libc/sys/linux/linuxthreads/linuxthreads.texi newlib/libc/sys/linux/linuxthreads/lockfile.c newlib/libc/sys/linux/linuxthreads/machine/Makefile.am newlib/libc/sys/linux/linuxthreads/machine/Makefile.in newlib/libc/sys/linux/linuxthreads/machine/aclocal.m4 newlib/libc/sys/linux/linuxthreads/machine/configure newlib/libc/sys/linux/linuxthreads/machine/configure.in newlib/libc/sys/linux/linuxthreads/machine/generic/generic-sysdep.h newlib/libc/sys/linux/linuxthreads/machine/i386/Makefile.am newlib/libc/sys/linux/linuxthreads/machine/i386/Makefile.in newlib/libc/sys/linux/linuxthreads/machine/i386/aclocal.m4 newlib/libc/sys/linux/linuxthreads/machine/i386/bp-asm.h newlib/libc/sys/linux/linuxthreads/machine/i386/clone.S newlib/libc/sys/linux/linuxthreads/machine/i386/configure newlib/libc/sys/linux/linuxthreads/machine/i386/configure.in newlib/libc/sys/linux/linuxthreads/machine/i386/i386-sysdep.S newlib/libc/sys/linux/linuxthreads/machine/i386/i386-sysdep.h newlib/libc/sys/linux/linuxthreads/machine/i386/pspinlock.c newlib/libc/sys/linux/linuxthreads/machine/i386/pt-machine.h newlib/libc/sys/linux/linuxthreads/machine/i386/sigcontextinfo.h newlib/libc/sys/linux/linuxthreads/machine/i386/stackinfo.h newlib/libc/sys/linux/linuxthreads/machine/i386/sysdep.S newlib/libc/sys/linux/linuxthreads/machine/i386/sysdep.h newlib/libc/sys/linux/linuxthreads/machine/i386/useldt.h newlib/libc/sys/linux/linuxthreads/manager.c newlib/libc/sys/linux/linuxthreads/mq_notify.c newlib/libc/sys/linux/linuxthreads/mutex.c newlib/libc/sys/linux/linuxthreads/no-tsd.c newlib/libc/sys/linux/linuxthreads/oldsemaphore.c newlib/libc/sys/linux/linuxthreads/posix-timer.h newlib/libc/sys/linux/linuxthreads/prio.c newlib/libc/sys/linux/linuxthreads/proc_service.h newlib/libc/sys/linux/linuxthreads/pt-machine.c newlib/libc/sys/linux/linuxthreads/ptclock_gettime.c newlib/libc/sys/linux/linuxthreads/ptclock_settime.c newlib/libc/sys/linux/linuxthreads/ptfork.c newlib/libc/sys/linux/linuxthreads/pthread.c newlib/libc/sys/linux/linuxthreads/ptlongjmp.c newlib/libc/sys/linux/linuxthreads/queue.h newlib/libc/sys/linux/linuxthreads/reent.c newlib/libc/sys/linux/linuxthreads/reqsyscalls.c newlib/libc/sys/linux/linuxthreads/restart.h newlib/libc/sys/linux/linuxthreads/rwlock.c newlib/libc/sys/linux/linuxthreads/semaphore.c newlib/libc/sys/linux/linuxthreads/semaphore.h newlib/libc/sys/linux/linuxthreads/shlib-compat.h newlib/libc/sys/linux/linuxthreads/signals.c newlib/libc/sys/linux/linuxthreads/specific.c newlib/libc/sys/linux/linuxthreads/spinlock.c newlib/libc/sys/linux/linuxthreads/spinlock.h newlib/libc/sys/linux/linuxthreads/sysctl.c newlib/libc/sys/linux/linuxthreads/td_init.c newlib/libc/sys/linux/linuxthreads/td_log.c newlib/libc/sys/linux/linuxthreads/td_symbol_list.c newlib/libc/sys/linux/linuxthreads/td_ta_clear_event.c newlib/libc/sys/linux/linuxthreads/td_ta_delete.c newlib/libc/sys/linux/linuxthreads/td_ta_enable_stats.c newlib/libc/sys/linux/linuxthreads/td_ta_event_addr.c newlib/libc/sys/linux/linuxthreads/td_ta_event_getmsg.c newlib/libc/sys/linux/linuxthreads/td_ta_get_nthreads.c newlib/libc/sys/linux/linuxthreads/td_ta_get_ph.c newlib/libc/sys/linux/linuxthreads/td_ta_get_stats.c newlib/libc/sys/linux/linuxthreads/td_ta_map_id2thr.c newlib/libc/sys/linux/linuxthreads/td_ta_map_lwp2thr.c newlib/libc/sys/linux/linuxthreads/td_ta_new.c newlib/libc/sys/linux/linuxthreads/td_ta_reset_stats.c newlib/libc/sys/linux/linuxthreads/td_ta_set_event.c newlib/libc/sys/linux/linuxthreads/td_ta_setconcurrency.c newlib/libc/sys/linux/linuxthreads/td_ta_thr_iter.c newlib/libc/sys/linux/linuxthreads/td_ta_tsd_iter.c newlib/libc/sys/linux/linuxthreads/td_thr_clear_event.c newlib/libc/sys/linux/linuxthreads/td_thr_dbresume.c newlib/libc/sys/linux/linuxthreads/td_thr_dbsuspend.c newlib/libc/sys/linux/linuxthreads/td_thr_event_enable.c newlib/libc/sys/linux/linuxthreads/td_thr_event_getmsg.c newlib/libc/sys/linux/linuxthreads/td_thr_get_info.c newlib/libc/sys/linux/linuxthreads/td_thr_getfpregs.c newlib/libc/sys/linux/linuxthreads/td_thr_getgregs.c newlib/libc/sys/linux/linuxthreads/td_thr_getxregs.c newlib/libc/sys/linux/linuxthreads/td_thr_getxregsize.c newlib/libc/sys/linux/linuxthreads/td_thr_set_event.c newlib/libc/sys/linux/linuxthreads/td_thr_setfpregs.c newlib/libc/sys/linux/linuxthreads/td_thr_setgregs.c newlib/libc/sys/linux/linuxthreads/td_thr_setprio.c newlib/libc/sys/linux/linuxthreads/td_thr_setsigpending.c newlib/libc/sys/linux/linuxthreads/td_thr_setxregs.c newlib/libc/sys/linux/linuxthreads/td_thr_sigsetmask.c newlib/libc/sys/linux/linuxthreads/td_thr_tsd.c newlib/libc/sys/linux/linuxthreads/td_thr_validate.c newlib/libc/sys/linux/linuxthreads/testrtsig.h newlib/libc/sys/linux/linuxthreads/thread_db.h newlib/libc/sys/linux/linuxthreads/thread_dbP.h newlib/libc/sys/linux/linuxthreads/timer_create.c newlib/libc/sys/linux/linuxthreads/timer_delete.c newlib/libc/sys/linux/linuxthreads/timer_getoverr.c newlib/libc/sys/linux/linuxthreads/timer_gettime.c newlib/libc/sys/linux/linuxthreads/timer_routines.c newlib/libc/sys/linux/linuxthreads/timer_settime.c newlib/libc/sys/linux/linuxthreads/tst-cancel.c newlib/libc/sys/linux/linuxthreads/tst-context.c newlib/libc/sys/linux/linuxthreads/tststack.c newlib/libc/sys/linux/linuxthreads/unload.c newlib/libc/sys/linux/linuxthreads/weaks.c newlib/libc/sys/linux/linuxthreads/wrapsyscall.c newlib/libc/sys/linux/machine/Makefile.am newlib/libc/sys/linux/machine/Makefile.in newlib/libc/sys/linux/machine/aclocal.m4 newlib/libc/sys/linux/machine/configure newlib/libc/sys/linux/machine/configure.in newlib/libc/sys/linux/machine/hp-timing.h newlib/libc/sys/linux/machine/i386/Makefile.am newlib/libc/sys/linux/machine/i386/Makefile.in newlib/libc/sys/linux/machine/i386/aclocal.m4 newlib/libc/sys/linux/machine/i386/atomic.h newlib/libc/sys/linux/machine/i386/configure newlib/libc/sys/linux/machine/i386/configure.in newlib/libc/sys/linux/machine/i386/crt0.c newlib/libc/sys/linux/machine/i386/dl-machine.h newlib/libc/sys/linux/machine/i386/dl-procinfo.c newlib/libc/sys/linux/machine/i386/dl-procinfo.h newlib/libc/sys/linux/machine/i386/get_clockfreq.c newlib/libc/sys/linux/machine/i386/getpagesize.c newlib/libc/sys/linux/machine/i386/hp-timing.c newlib/libc/sys/linux/machine/i386/hp-timing.h newlib/libc/sys/linux/machine/i386/huge_val.h newlib/libc/sys/linux/machine/i386/i386mach.h newlib/libc/sys/linux/machine/i386/include/endian.h newlib/libc/sys/linux/machine/i386/include/param.h newlib/libc/sys/linux/machine/i386/include/setjmp.h newlib/libc/sys/linux/machine/i386/include/termios.h newlib/libc/sys/linux/machine/i386/setjmp.S newlib/libc/sys/linux/machine/i386/sigaction.c newlib/libc/sys/linux/machine/i386/sigstack.h newlib/libc/sys/linux/machine/i386/socketcall.h newlib/libc/sys/linux/machine/i386/syscall.h newlib/libc/sys/linux/machine/i386/sysdep.h newlib/libc/sys/linux/machine/i386/weakalias.h newlib/libc/sys/linux/malign.c newlib/libc/sys/linux/malignr.c newlib/libc/sys/linux/mallinfor.c newlib/libc/sys/linux/malloc.c newlib/libc/sys/linux/mallocr.c newlib/libc/sys/linux/malloptr.c newlib/libc/sys/linux/mallstatsr.c newlib/libc/sys/linux/mcheck.c newlib/libc/sys/linux/mhooks.h newlib/libc/sys/linux/mmap.c newlib/libc/sys/linux/mntent.c newlib/libc/sys/linux/mntent_r.c newlib/libc/sys/linux/mq_close.c newlib/libc/sys/linux/mq_getattr.c newlib/libc/sys/linux/mq_notify.c newlib/libc/sys/linux/mq_open.c newlib/libc/sys/linux/mq_receive.c newlib/libc/sys/linux/mq_send.c newlib/libc/sys/linux/mq_setattr.c newlib/libc/sys/linux/mq_unlink.c newlib/libc/sys/linux/mqlocal.h newlib/libc/sys/linux/msize.c newlib/libc/sys/linux/msizer.c newlib/libc/sys/linux/mstats.c newlib/libc/sys/linux/mtrim.c newlib/libc/sys/linux/mtrimr.c newlib/libc/sys/linux/net/Makefile.am newlib/libc/sys/linux/net/Makefile.in newlib/libc/sys/linux/net/XXX-lookup.c newlib/libc/sys/linux/net/addr2ascii.c newlib/libc/sys/linux/net/alias-lookup.c newlib/libc/sys/linux/net/aliases.h newlib/libc/sys/linux/net/ascii2addr.c newlib/libc/sys/linux/net/base64.c newlib/libc/sys/linux/net/check_pf.c newlib/libc/sys/linux/net/databases.def newlib/libc/sys/linux/net/digits_dots.c newlib/libc/sys/linux/net/ether_aton.c newlib/libc/sys/linux/net/ether_aton_r.c newlib/libc/sys/linux/net/ether_hton.c newlib/libc/sys/linux/net/ether_line.c newlib/libc/sys/linux/net/ether_ntoa.c newlib/libc/sys/linux/net/ether_ntoa_r.c newlib/libc/sys/linux/net/ether_ntoh.c newlib/libc/sys/linux/net/etherent.h newlib/libc/sys/linux/net/ethers-lookup.c newlib/libc/sys/linux/net/function.def newlib/libc/sys/linux/net/getXXbyYY.c newlib/libc/sys/linux/net/getXXbyYY_r.c newlib/libc/sys/linux/net/getXXent.c newlib/libc/sys/linux/net/getXXent_r.c newlib/libc/sys/linux/net/getaddrinfo.c newlib/libc/sys/linux/net/getaliasent.c newlib/libc/sys/linux/net/getaliasent_r.c newlib/libc/sys/linux/net/getaliasname.c newlib/libc/sys/linux/net/getaliasname_r.c newlib/libc/sys/linux/net/gethstbyad.c newlib/libc/sys/linux/net/gethstbyad_r.c newlib/libc/sys/linux/net/gethstbynm.c newlib/libc/sys/linux/net/gethstbynm2.c newlib/libc/sys/linux/net/gethstbynm2_r.c newlib/libc/sys/linux/net/gethstbynm_r.c newlib/libc/sys/linux/net/gethstent.c newlib/libc/sys/linux/net/gethstent_r.c newlib/libc/sys/linux/net/getnameinfo.c newlib/libc/sys/linux/net/getnetbyad.c newlib/libc/sys/linux/net/getnetbyad_r.c newlib/libc/sys/linux/net/getnetbynm.c newlib/libc/sys/linux/net/getnetbynm_r.c newlib/libc/sys/linux/net/getnetent.c newlib/libc/sys/linux/net/getnetent_r.c newlib/libc/sys/linux/net/getnetgrent.c newlib/libc/sys/linux/net/getnetgrent_r.c newlib/libc/sys/linux/net/getnssent.c newlib/libc/sys/linux/net/getnssent_r.c newlib/libc/sys/linux/net/getproto.c newlib/libc/sys/linux/net/getproto_r.c newlib/libc/sys/linux/net/getprtent.c newlib/libc/sys/linux/net/getprtent_r.c newlib/libc/sys/linux/net/getprtname.c newlib/libc/sys/linux/net/getprtname_r.c newlib/libc/sys/linux/net/getrpcbyname.c newlib/libc/sys/linux/net/getrpcbyname_r.c newlib/libc/sys/linux/net/getrpcbynumber.c newlib/libc/sys/linux/net/getrpcbynumber_r.c newlib/libc/sys/linux/net/getrpcent.c newlib/libc/sys/linux/net/getrpcent_r.c newlib/libc/sys/linux/net/getservent.c newlib/libc/sys/linux/net/getservent_r.c newlib/libc/sys/linux/net/getsrvbynm.c newlib/libc/sys/linux/net/getsrvbynm_r.c newlib/libc/sys/linux/net/getsrvbypt.c newlib/libc/sys/linux/net/getsrvbypt_r.c newlib/libc/sys/linux/net/grp-lookup.c newlib/libc/sys/linux/net/herrno.c newlib/libc/sys/linux/net/hosts-lookup.c newlib/libc/sys/linux/net/ifaddrs.h newlib/libc/sys/linux/net/ifname.c newlib/libc/sys/linux/net/ifreq.c newlib/libc/sys/linux/net/ifreq.h newlib/libc/sys/linux/net/in6_addr.c newlib/libc/sys/linux/net/inet6_option.c newlib/libc/sys/linux/net/inet_addr.c newlib/libc/sys/linux/net/inet_lnaof.c newlib/libc/sys/linux/net/inet_mkadr.c newlib/libc/sys/linux/net/inet_net.c newlib/libc/sys/linux/net/inet_net_ntop.c newlib/libc/sys/linux/net/inet_net_pton.c newlib/libc/sys/linux/net/inet_neta.c newlib/libc/sys/linux/net/inet_netof.c newlib/libc/sys/linux/net/inet_ntoa.c newlib/libc/sys/linux/net/inet_ntop.c newlib/libc/sys/linux/net/inet_pton.c newlib/libc/sys/linux/net/issetugid-stub.c newlib/libc/sys/linux/net/key-lookup.c newlib/libc/sys/linux/net/local.h newlib/libc/sys/linux/net/netgroup.h newlib/libc/sys/linux/net/netgrp-lookup.c newlib/libc/sys/linux/net/network-lookup.c newlib/libc/sys/linux/net/not-cancel.h newlib/libc/sys/linux/net/ns_name.c newlib/libc/sys/linux/net/ns_netint.c newlib/libc/sys/linux/net/ns_parse.c newlib/libc/sys/linux/net/ns_print.c newlib/libc/sys/linux/net/ns_samedomain.c newlib/libc/sys/linux/net/ns_ttl.c newlib/libc/sys/linux/net/nsap_addr.c newlib/libc/sys/linux/net/nscd-types.h newlib/libc/sys/linux/net/nscd/nscd-client.h newlib/libc/sys/linux/net/nscd/nscd_proto.h newlib/libc/sys/linux/net/nss.h newlib/libc/sys/linux/net/nsswitch.c newlib/libc/sys/linux/net/nsswitch.h newlib/libc/sys/linux/net/opensock.c newlib/libc/sys/linux/net/proto-lookup.c newlib/libc/sys/linux/net/pwd-lookup.c newlib/libc/sys/linux/net/rcmd.c newlib/libc/sys/linux/net/rcmdsh.c newlib/libc/sys/linux/net/recv.c newlib/libc/sys/linux/net/res_comp.c newlib/libc/sys/linux/net/res_data.c newlib/libc/sys/linux/net/res_debug.c newlib/libc/sys/linux/net/res_debug.h newlib/libc/sys/linux/net/res_hconf.c newlib/libc/sys/linux/net/res_hconf.h newlib/libc/sys/linux/net/res_init.c newlib/libc/sys/linux/net/res_libc.c newlib/libc/sys/linux/net/res_mkquery.c newlib/libc/sys/linux/net/res_query.c newlib/libc/sys/linux/net/res_send.c newlib/libc/sys/linux/net/rexec.c newlib/libc/sys/linux/net/rpc-lookup.c newlib/libc/sys/linux/net/ruserpass.c newlib/libc/sys/linux/net/send.c newlib/libc/sys/linux/net/service-lookup.c newlib/libc/sys/linux/net/spwd-lookup.c newlib/libc/sys/linux/net/un-namespace.h newlib/libc/sys/linux/ntp_gettime.c newlib/libc/sys/linux/pathconf.c newlib/libc/sys/linux/pread.c newlib/libc/sys/linux/pread64.c newlib/libc/sys/linux/process.c newlib/libc/sys/linux/prof-freq.c newlib/libc/sys/linux/profile.c newlib/libc/sys/linux/psignal.c newlib/libc/sys/linux/pvallocr.c newlib/libc/sys/linux/pwrite.c newlib/libc/sys/linux/pwrite64.c newlib/libc/sys/linux/raise.c newlib/libc/sys/linux/readdir64.c newlib/libc/sys/linux/realloc.c newlib/libc/sys/linux/reallocr.c newlib/libc/sys/linux/realpath.c newlib/libc/sys/linux/rename.c newlib/libc/sys/linux/resource.c newlib/libc/sys/linux/scandir64.c newlib/libc/sys/linux/sched.c newlib/libc/sys/linux/select.c newlib/libc/sys/linux/seteuid.c newlib/libc/sys/linux/sethostid.c newlib/libc/sys/linux/sethostname.c newlib/libc/sys/linux/setrlimit64.c newlib/libc/sys/linux/shared.ld newlib/libc/sys/linux/shlib-compat.h newlib/libc/sys/linux/shm_open.c newlib/libc/sys/linux/shm_unlink.c newlib/libc/sys/linux/sig.c newlib/libc/sys/linux/sigaction.c newlib/libc/sys/linux/siglongjmp.c newlib/libc/sys/linux/signal.c newlib/libc/sys/linux/sigqueue.c newlib/libc/sys/linux/sigset.c newlib/libc/sys/linux/sigwait.c newlib/libc/sys/linux/sleep.c newlib/libc/sys/linux/socket.c newlib/libc/sys/linux/sockops.h newlib/libc/sys/linux/stack.c newlib/libc/sys/linux/statvfs.c newlib/libc/sys/linux/statvfs64.c newlib/libc/sys/linux/strsignal.c newlib/libc/sys/linux/strverscmp.c newlib/libc/sys/linux/sys/_types.h newlib/libc/sys/linux/sys/cdefs.h newlib/libc/sys/linux/sys/dirent.h newlib/libc/sys/linux/sys/dlfcn.h newlib/libc/sys/linux/sys/elfclass.h newlib/libc/sys/linux/sys/errno.h newlib/libc/sys/linux/sys/event.h newlib/libc/sys/linux/sys/fcntl.h newlib/libc/sys/linux/sys/features.h newlib/libc/sys/linux/sys/file.h newlib/libc/sys/linux/sys/ioccom.h newlib/libc/sys/linux/sys/ioctl.h newlib/libc/sys/linux/sys/libc-lock.h newlib/libc/sys/linux/sys/libc-tsd.h newlib/libc/sys/linux/sys/link.h newlib/libc/sys/linux/sys/linux_time.h newlib/libc/sys/linux/sys/lock.h newlib/libc/sys/linux/sys/param.h newlib/libc/sys/linux/sys/resource.h newlib/libc/sys/linux/sys/select.h newlib/libc/sys/linux/sys/signal.h newlib/libc/sys/linux/sys/socket.h newlib/libc/sys/linux/sys/sockio.h newlib/libc/sys/linux/sys/stat.h newlib/libc/sys/linux/sys/stdint.h newlib/libc/sys/linux/sys/stdio.h newlib/libc/sys/linux/sys/string.h newlib/libc/sys/linux/sys/termios.h newlib/libc/sys/linux/sys/time.h newlib/libc/sys/linux/sys/types.h newlib/libc/sys/linux/sys/unistd.h newlib/libc/sys/linux/sys/utime.h newlib/libc/sys/linux/sys/utmp.h newlib/libc/sys/linux/sys/utsname.h newlib/libc/sys/linux/sys/wait.h newlib/libc/sys/linux/sysconf.c newlib/libc/sys/linux/sysctl.c newlib/libc/sys/linux/systat.c newlib/libc/sys/linux/system.c newlib/libc/sys/linux/tcdrain.c newlib/libc/sys/linux/tcsendbrk.c newlib/libc/sys/linux/termios.c newlib/libc/sys/linux/thread-m.h newlib/libc/sys/linux/time.c newlib/libc/sys/linux/ttyname_r.c newlib/libc/sys/linux/usleep.c newlib/libc/sys/linux/utimes.c newlib/libc/sys/linux/vallocr.c newlib/libc/sys/linux/versionsort.c newlib/libc/sys/linux/versionsort64.c newlib/libc/sys/linux/wait.c newlib/libc/sys/m88kbug/Makefile.am newlib/libc/sys/m88kbug/Makefile.in newlib/libc/sys/m88kbug/aclocal.m4 newlib/libc/sys/m88kbug/configure newlib/libc/sys/m88kbug/configure.in newlib/libc/sys/m88kbug/crt0.c newlib/libc/sys/m88kbug/sys/systraps.h newlib/libc/sys/m88kbug/syscalls.c newlib/libc/sys/mmixware/Makefile.am newlib/libc/sys/mmixware/Makefile.in newlib/libc/sys/mmixware/_exit.c newlib/libc/sys/mmixware/access.c newlib/libc/sys/mmixware/aclocal.m4 newlib/libc/sys/mmixware/chmod.c newlib/libc/sys/mmixware/chown.c newlib/libc/sys/mmixware/close.c newlib/libc/sys/mmixware/configure newlib/libc/sys/mmixware/configure.in newlib/libc/sys/mmixware/creat.c newlib/libc/sys/mmixware/crt0.c newlib/libc/sys/mmixware/execv.c newlib/libc/sys/mmixware/execve.c newlib/libc/sys/mmixware/fork.c newlib/libc/sys/mmixware/fstat.c newlib/libc/sys/mmixware/getpid.c newlib/libc/sys/mmixware/gettime.c newlib/libc/sys/mmixware/isatty.c newlib/libc/sys/mmixware/kill.c newlib/libc/sys/mmixware/link.c newlib/libc/sys/mmixware/lseek.c newlib/libc/sys/mmixware/open.c newlib/libc/sys/mmixware/pipe.c newlib/libc/sys/mmixware/read.c newlib/libc/sys/mmixware/sbrk.c newlib/libc/sys/mmixware/setjmp.S newlib/libc/sys/mmixware/stat.c newlib/libc/sys/mmixware/sys/syscall.h newlib/libc/sys/mmixware/time.c newlib/libc/sys/mmixware/times.c newlib/libc/sys/mmixware/unlink.c newlib/libc/sys/mmixware/utime.c newlib/libc/sys/mmixware/wait.c newlib/libc/sys/mmixware/write.c newlib/libc/sys/netware/Makefile.am newlib/libc/sys/netware/Makefile.in newlib/libc/sys/netware/aclocal.m4 newlib/libc/sys/netware/configure newlib/libc/sys/netware/configure.in newlib/libc/sys/netware/crt0.c newlib/libc/sys/netware/getpid.c newlib/libc/sys/netware/link.c newlib/libc/sys/rdos/Makefile.am newlib/libc/sys/rdos/Makefile.in newlib/libc/sys/rdos/aclocal.m4 newlib/libc/sys/rdos/chown.c newlib/libc/sys/rdos/close.c newlib/libc/sys/rdos/config.h newlib/libc/sys/rdos/configure newlib/libc/sys/rdos/configure.in newlib/libc/sys/rdos/crt0.S newlib/libc/sys/rdos/execve.c newlib/libc/sys/rdos/fork.c newlib/libc/sys/rdos/fstat.c newlib/libc/sys/rdos/getenv.c newlib/libc/sys/rdos/getpid.c newlib/libc/sys/rdos/gettod.c newlib/libc/sys/rdos/isatty.c newlib/libc/sys/rdos/kill.c newlib/libc/sys/rdos/link.c newlib/libc/sys/rdos/lseek.c newlib/libc/sys/rdos/open.c newlib/libc/sys/rdos/rdos.S newlib/libc/sys/rdos/rdos.h newlib/libc/sys/rdos/rdoshelp.c newlib/libc/sys/rdos/read.c newlib/libc/sys/rdos/readlink.c newlib/libc/sys/rdos/sbrk.c newlib/libc/sys/rdos/stat.c newlib/libc/sys/rdos/symlink.c newlib/libc/sys/rdos/times.c newlib/libc/sys/rdos/unlink.c newlib/libc/sys/rdos/user.def newlib/libc/sys/rdos/wait.c newlib/libc/sys/rdos/write.c newlib/libc/sys/rtems/Makefile.am newlib/libc/sys/rtems/Makefile.in newlib/libc/sys/rtems/aclocal.m4 newlib/libc/sys/rtems/configure newlib/libc/sys/rtems/configure.in newlib/libc/sys/rtems/crt0.c newlib/libc/sys/rtems/dummysys.c newlib/libc/sys/rtems/include/limits.h newlib/libc/sys/rtems/machine/_types.h newlib/libc/sys/rtems/machine/limits.h newlib/libc/sys/rtems/machine/param.h newlib/libc/sys/rtems/sys/dirent.h newlib/libc/sys/rtems/sys/param.h newlib/libc/sys/rtems/sys/queue.h newlib/libc/sys/rtems/sys/syslimits.h newlib/libc/sys/rtems/sys/utime.h newlib/libc/sys/sh/Makefile.am newlib/libc/sys/sh/Makefile.in newlib/libc/sys/sh/aclocal.m4 newlib/libc/sys/sh/configure newlib/libc/sys/sh/configure.in newlib/libc/sys/sh/creat.c newlib/libc/sys/sh/crt0.S newlib/libc/sys/sh/ftruncate.c newlib/libc/sys/sh/sys/syscall.h newlib/libc/sys/sh/syscalls.c newlib/libc/sys/sh/trap.S newlib/libc/sys/sh/truncate.c newlib/libc/sys/sparc64/Makefile.am newlib/libc/sys/sparc64/Makefile.in newlib/libc/sys/sparc64/_exit.S newlib/libc/sys/sparc64/_main.c newlib/libc/sys/sparc64/aclocal.m4 newlib/libc/sys/sparc64/cerror.S newlib/libc/sys/sparc64/closedir.c newlib/libc/sys/sparc64/configure newlib/libc/sys/sparc64/configure.in newlib/libc/sys/sparc64/creat.c newlib/libc/sys/sparc64/crt0.S newlib/libc/sys/sparc64/dup2.S newlib/libc/sys/sparc64/execve.S newlib/libc/sys/sparc64/ieee.c newlib/libc/sys/sparc64/isatty.c newlib/libc/sys/sparc64/lstat.S newlib/libc/sys/sparc64/opendir.c newlib/libc/sys/sparc64/readdir.c newlib/libc/sys/sparc64/rewinddir.c newlib/libc/sys/sparc64/sbrk.S newlib/libc/sys/sparc64/scandir.c newlib/libc/sys/sparc64/seekdir.c newlib/libc/sys/sparc64/sigsetjmp.S newlib/libc/sys/sparc64/stat.S newlib/libc/sys/sparc64/sys/dirent.h newlib/libc/sys/sparc64/sys/fcntl.h newlib/libc/sys/sparc64/sys/file.h newlib/libc/sys/sparc64/sys/stat.h newlib/libc/sys/sparc64/sys/syscall.h newlib/libc/sys/sparc64/sys/syscallasm.h newlib/libc/sys/sparc64/sys/termios.h newlib/libc/sys/sparc64/sys/time.h newlib/libc/sys/sparc64/sys/utime.h newlib/libc/sys/sparc64/sys/utmp.h newlib/libc/sys/sparc64/sys/wait.h newlib/libc/sys/sparc64/telldir.c newlib/libc/sys/sparc64/template.S newlib/libc/sys/sparc64/template_r.S newlib/libc/sys/sparc64/utime.S newlib/libc/sys/sparc64/utime2.c newlib/libc/sys/sparc64/wait.S newlib/libc/sys/sun4/Makefile.am newlib/libc/sys/sun4/Makefile.in newlib/libc/sys/sun4/_main.c newlib/libc/sys/sun4/aclocal.m4 newlib/libc/sys/sun4/configure newlib/libc/sys/sun4/configure.in newlib/libc/sys/sun4/ieee.c newlib/libc/sys/sun4/sys/dirent.h newlib/libc/sys/sun4/sys/file.h newlib/libc/sys/sun4/sys/termios.h newlib/libc/sys/sun4/sys/utime.h newlib/libc/sys/sun4/sys/utmp.h newlib/libc/sys/sun4/sys/wait.h newlib/libc/sys/sysmec/Makefile.am newlib/libc/sys/sysmec/Makefile.in newlib/libc/sys/sysmec/_exit.c newlib/libc/sys/sysmec/access.c newlib/libc/sys/sysmec/aclocal.m4 newlib/libc/sys/sysmec/chmod.c newlib/libc/sys/sysmec/chown.c newlib/libc/sys/sysmec/close.c newlib/libc/sys/sysmec/configure newlib/libc/sys/sysmec/configure.in newlib/libc/sys/sysmec/creat.c newlib/libc/sys/sysmec/crt0.S newlib/libc/sys/sysmec/crt1.c newlib/libc/sys/sysmec/execv.c newlib/libc/sys/sysmec/execve.c newlib/libc/sys/sysmec/fork.c newlib/libc/sys/sysmec/fstat.c newlib/libc/sys/sysmec/getpid.c newlib/libc/sys/sysmec/gettime.c newlib/libc/sys/sysmec/isatty.c newlib/libc/sys/sysmec/kill.c newlib/libc/sys/sysmec/lseek.c newlib/libc/sys/sysmec/open.c newlib/libc/sys/sysmec/pipe.c newlib/libc/sys/sysmec/read.c newlib/libc/sys/sysmec/sbrk.c newlib/libc/sys/sysmec/stat.c newlib/libc/sys/sysmec/sys/syscall.h newlib/libc/sys/sysmec/time.c newlib/libc/sys/sysmec/times.c newlib/libc/sys/sysmec/trap.S newlib/libc/sys/sysmec/unlink.c newlib/libc/sys/sysmec/utime.c newlib/libc/sys/sysmec/wait.c newlib/libc/sys/sysmec/write.c newlib/libc/sys/sysnec810/Makefile.am newlib/libc/sys/sysnec810/Makefile.in newlib/libc/sys/sysnec810/aclocal.m4 newlib/libc/sys/sysnec810/configure newlib/libc/sys/sysnec810/configure.in newlib/libc/sys/sysnec810/crt0.S newlib/libc/sys/sysnec810/io.S newlib/libc/sys/sysnec810/misc.c newlib/libc/sys/sysnec810/sbrk.c newlib/libc/sys/sysnec810/write.c newlib/libc/sys/sysnecv850/Makefile.am newlib/libc/sys/sysnecv850/Makefile.in newlib/libc/sys/sysnecv850/_exit.c newlib/libc/sys/sysnecv850/access.c newlib/libc/sys/sysnecv850/aclocal.m4 newlib/libc/sys/sysnecv850/chmod.c newlib/libc/sys/sysnecv850/chown.c newlib/libc/sys/sysnecv850/close.c newlib/libc/sys/sysnecv850/configure newlib/libc/sys/sysnecv850/configure.in newlib/libc/sys/sysnecv850/creat.c newlib/libc/sys/sysnecv850/crt0.S newlib/libc/sys/sysnecv850/crt1.c newlib/libc/sys/sysnecv850/execv.c newlib/libc/sys/sysnecv850/execve.c newlib/libc/sys/sysnecv850/fork.c newlib/libc/sys/sysnecv850/fstat.c newlib/libc/sys/sysnecv850/getpid.c newlib/libc/sys/sysnecv850/gettime.c newlib/libc/sys/sysnecv850/isatty.c newlib/libc/sys/sysnecv850/kill.c newlib/libc/sys/sysnecv850/link.c newlib/libc/sys/sysnecv850/lseek.c newlib/libc/sys/sysnecv850/open.c newlib/libc/sys/sysnecv850/pipe.c newlib/libc/sys/sysnecv850/read.c newlib/libc/sys/sysnecv850/sbrk.c newlib/libc/sys/sysnecv850/stat.c newlib/libc/sys/sysnecv850/sys/syscall.h newlib/libc/sys/sysnecv850/time.c newlib/libc/sys/sysnecv850/times.c newlib/libc/sys/sysnecv850/trap.S newlib/libc/sys/sysnecv850/unlink.c newlib/libc/sys/sysnecv850/utime.c newlib/libc/sys/sysnecv850/wait.c newlib/libc/sys/sysnecv850/write.c newlib/libc/sys/sysvi386/Makefile.am newlib/libc/sys/sysvi386/Makefile.in newlib/libc/sys/sysvi386/_exit.S newlib/libc/sys/sysvi386/_longjmp.S newlib/libc/sys/sysvi386/_setjmp.S newlib/libc/sys/sysvi386/access.S newlib/libc/sys/sysvi386/aclocal.m4 newlib/libc/sys/sysvi386/alarm.S newlib/libc/sys/sysvi386/brk.S newlib/libc/sys/sysvi386/cerror.S newlib/libc/sys/sysvi386/chdir.S newlib/libc/sys/sysvi386/chmod.S newlib/libc/sys/sysvi386/close.S newlib/libc/sys/sysvi386/closedir.c newlib/libc/sys/sysvi386/configure newlib/libc/sys/sysvi386/configure.in newlib/libc/sys/sysvi386/crt0.c newlib/libc/sys/sysvi386/dup.c newlib/libc/sys/sysvi386/dup2.c newlib/libc/sys/sysvi386/exec.c newlib/libc/sys/sysvi386/execve.S newlib/libc/sys/sysvi386/fcntl.S newlib/libc/sys/sysvi386/fork.S newlib/libc/sys/sysvi386/fpathconf.S newlib/libc/sys/sysvi386/fps.S newlib/libc/sys/sysvi386/fpx.c newlib/libc/sys/sysvi386/fstat.S newlib/libc/sys/sysvi386/getdents.S newlib/libc/sys/sysvi386/getegid.S newlib/libc/sys/sysvi386/geteuid.S newlib/libc/sys/sysvi386/getgid.S newlib/libc/sys/sysvi386/getgroups.S newlib/libc/sys/sysvi386/getpid.S newlib/libc/sys/sysvi386/getuid.S newlib/libc/sys/sysvi386/ioctl.S newlib/libc/sys/sysvi386/isatty.c newlib/libc/sys/sysvi386/kill.S newlib/libc/sys/sysvi386/link.S newlib/libc/sys/sysvi386/lseek.S newlib/libc/sys/sysvi386/mkdir.S newlib/libc/sys/sysvi386/open.S newlib/libc/sys/sysvi386/opendir.c newlib/libc/sys/sysvi386/pathconf.S newlib/libc/sys/sysvi386/pause.S newlib/libc/sys/sysvi386/pipe.S newlib/libc/sys/sysvi386/read.S newlib/libc/sys/sysvi386/readdir.c newlib/libc/sys/sysvi386/rename.S newlib/libc/sys/sysvi386/rewinddir.c newlib/libc/sys/sysvi386/rmdir.S newlib/libc/sys/sysvi386/sbrk.c newlib/libc/sys/sysvi386/scandir.c newlib/libc/sys/sysvi386/seekdir.c newlib/libc/sys/sysvi386/setgid.S newlib/libc/sys/sysvi386/setuid.S newlib/libc/sys/sysvi386/sigaction.S newlib/libc/sys/sysvi386/signal.S newlib/libc/sys/sysvi386/sigprocmask.S newlib/libc/sys/sysvi386/sleep.c newlib/libc/sys/sysvi386/speed.c newlib/libc/sys/sysvi386/stat.S newlib/libc/sys/sysvi386/sys/dirent.h newlib/libc/sys/sysvi386/sys/setjmp.h newlib/libc/sys/sysvi386/sys/termio.h newlib/libc/sys/sysvi386/sys/termios.h newlib/libc/sys/sysvi386/sys/utime.h newlib/libc/sys/sysvi386/sys/utmp.h newlib/libc/sys/sysvi386/sys/wait.h newlib/libc/sys/sysvi386/sysconf.S newlib/libc/sys/sysvi386/tcgetattr.c newlib/libc/sys/sysvi386/tcline.c newlib/libc/sys/sysvi386/tcsetattr.c newlib/libc/sys/sysvi386/telldir.c newlib/libc/sys/sysvi386/time.S newlib/libc/sys/sysvi386/times.S newlib/libc/sys/sysvi386/unlink.S newlib/libc/sys/sysvi386/utime.S newlib/libc/sys/sysvi386/wait.S newlib/libc/sys/sysvi386/waitpid.S newlib/libc/sys/sysvi386/write.S newlib/libc/sys/sysvnecv70/Makefile.am newlib/libc/sys/sysvnecv70/Makefile.in newlib/libc/sys/sysvnecv70/aclocal.m4 newlib/libc/sys/sysvnecv70/cerror.S newlib/libc/sys/sysvnecv70/close.S newlib/libc/sys/sysvnecv70/configure newlib/libc/sys/sysvnecv70/configure.in newlib/libc/sys/sysvnecv70/crt0.S newlib/libc/sys/sysvnecv70/exit.S newlib/libc/sys/sysvnecv70/fps.S newlib/libc/sys/sysvnecv70/fpx.c newlib/libc/sys/sysvnecv70/fstat.S newlib/libc/sys/sysvnecv70/ioctl.S newlib/libc/sys/sysvnecv70/isatty.S newlib/libc/sys/sysvnecv70/lseek.S newlib/libc/sys/sysvnecv70/open.S newlib/libc/sys/sysvnecv70/read.S newlib/libc/sys/sysvnecv70/sbrk.S newlib/libc/sys/sysvnecv70/sysv60.S newlib/libc/sys/sysvnecv70/sysvnecv70.tex newlib/libc/sys/sysvnecv70/write.S newlib/libc/sys/tic80/Makefile.am newlib/libc/sys/tic80/Makefile.in newlib/libc/sys/tic80/aclocal.m4 newlib/libc/sys/tic80/configure newlib/libc/sys/tic80/configure.in newlib/libc/sys/tic80/crt0.c newlib/libc/sys/w65/Makefile.am newlib/libc/sys/w65/Makefile.in newlib/libc/sys/w65/aclocal.m4 newlib/libc/sys/w65/configure newlib/libc/sys/w65/configure.in newlib/libc/sys/w65/crt0.c newlib/libc/sys/w65/sys/syscall.h newlib/libc/sys/w65/syscalls.c newlib/libc/sys/w65/trap.c newlib/libc/sys/z8ksim/Makefile.am newlib/libc/sys/z8ksim/Makefile.in newlib/libc/sys/z8ksim/aclocal.m4 newlib/libc/sys/z8ksim/configure newlib/libc/sys/z8ksim/configure.in newlib/libc/sys/z8ksim/crt0.c newlib/libc/sys/z8ksim/glue.c newlib/libc/sys/z8ksim/sys/syscall.h newlib/libc/syscalls/Makefile.am newlib/libc/syscalls/Makefile.in newlib/libc/syscalls/sysclose.c newlib/libc/syscalls/sysexecve.c newlib/libc/syscalls/sysfcntl.c newlib/libc/syscalls/sysfork.c newlib/libc/syscalls/sysfstat.c newlib/libc/syscalls/sysgetpid.c newlib/libc/syscalls/sysgettod.c newlib/libc/syscalls/sysisatty.c newlib/libc/syscalls/syskill.c newlib/libc/syscalls/syslink.c newlib/libc/syscalls/syslseek.c newlib/libc/syscalls/sysopen.c newlib/libc/syscalls/sysread.c newlib/libc/syscalls/syssbrk.c newlib/libc/syscalls/sysstat.c newlib/libc/syscalls/systimes.c newlib/libc/syscalls/sysunlink.c newlib/libc/syscalls/syswait.c newlib/libc/syscalls/syswrite.c newlib/libc/time/Makefile.am newlib/libc/time/Makefile.in newlib/libc/time/asctime.c newlib/libc/time/asctime_r.c newlib/libc/time/clock.c newlib/libc/time/ctime.c newlib/libc/time/ctime_r.c newlib/libc/time/difftime.c newlib/libc/time/gettzinfo.c newlib/libc/time/gmtime.c newlib/libc/time/gmtime_r.c newlib/libc/time/lcltime.c newlib/libc/time/lcltime_r.c newlib/libc/time/local.h newlib/libc/time/mktime.c newlib/libc/time/mktm_r.c newlib/libc/time/strftime.c newlib/libc/time/strptime.c newlib/libc/time/time.c newlib/libc/time/time.tex newlib/libc/time/tzlock.c newlib/libc/time/tzset.c newlib/libc/time/tzset_r.c newlib/libc/time/tzvars.c newlib/libc/time/wcsftime.c newlib/libc/unix/Makefile.am newlib/libc/unix/Makefile.in newlib/libc/unix/basename.c newlib/libc/unix/dirname.c newlib/libc/unix/getcwd.c newlib/libc/unix/getlogin.c newlib/libc/unix/getpass.c newlib/libc/unix/getpwent.c newlib/libc/unix/getut.c newlib/libc/unix/pread.c newlib/libc/unix/pwrite.c newlib/libc/unix/sigset.c newlib/libc/unix/ttyname.c newlib/libc/unix/ttyname.h newlib/libc/unix/ttyname_r.c newlib/libm/Makefile.am newlib/libm/Makefile.in newlib/libm/aclocal.m4 newlib/libm/common/Makefile.am newlib/libm/common/Makefile.in newlib/libm/common/acoshl.c newlib/libm/common/acosl.c newlib/libm/common/asinhl.c newlib/libm/common/asinl.c newlib/libm/common/atan2l.c newlib/libm/common/atanhl.c newlib/libm/common/atanl.c newlib/libm/common/cbrtl.c newlib/libm/common/ceill.c newlib/libm/common/copysignl.c newlib/libm/common/coshl.c newlib/libm/common/cosl.c newlib/libm/common/erfcl.c newlib/libm/common/erfl.c newlib/libm/common/exp2l.c newlib/libm/common/expl.c newlib/libm/common/expm1l.c newlib/libm/common/fabsl.c newlib/libm/common/fdiml.c newlib/libm/common/fdlibm.h newlib/libm/common/floorl.c newlib/libm/common/fmal.c newlib/libm/common/fmaxl.c newlib/libm/common/fminl.c newlib/libm/common/fmodl.c newlib/libm/common/frexpl.c newlib/libm/common/hypotl.c newlib/libm/common/ilogbl.c newlib/libm/common/isgreater.c newlib/libm/common/ldexpl.c newlib/libm/common/lgammal.c newlib/libm/common/llrintl.c newlib/libm/common/llroundl.c newlib/libm/common/local.h newlib/libm/common/log10l.c newlib/libm/common/log1pl.c newlib/libm/common/logl.c newlib/libm/common/lrintl.c newlib/libm/common/lroundl.c newlib/libm/common/modfl.c newlib/libm/common/nanl.c newlib/libm/common/nearbyintl.c newlib/libm/common/nextafterl.c newlib/libm/common/powl.c newlib/libm/common/remainderl.c newlib/libm/common/remquol.c newlib/libm/common/rintl.c newlib/libm/common/roundl.c newlib/libm/common/s_cbrt.c newlib/libm/common/s_copysign.c newlib/libm/common/s_exp10.c newlib/libm/common/s_expm1.c newlib/libm/common/s_fdim.c newlib/libm/common/s_finite.c newlib/libm/common/s_fma.c newlib/libm/common/s_fmax.c newlib/libm/common/s_fmin.c newlib/libm/common/s_fpclassify.c newlib/libm/common/s_ilogb.c newlib/libm/common/s_infconst.c newlib/libm/common/s_infinity.c newlib/libm/common/s_isinf.c newlib/libm/common/s_isinfd.c newlib/libm/common/s_isnan.c newlib/libm/common/s_isnand.c newlib/libm/common/s_lib_ver.c newlib/libm/common/s_llrint.c newlib/libm/common/s_llround.c newlib/libm/common/s_log1p.c newlib/libm/common/s_log2.c newlib/libm/common/s_logb.c newlib/libm/common/s_lrint.c newlib/libm/common/s_lround.c newlib/libm/common/s_matherr.c newlib/libm/common/s_modf.c newlib/libm/common/s_nan.c newlib/libm/common/s_nearbyint.c newlib/libm/common/s_nextafter.c newlib/libm/common/s_pow10.c newlib/libm/common/s_remquo.c newlib/libm/common/s_rint.c newlib/libm/common/s_round.c newlib/libm/common/s_scalbln.c newlib/libm/common/s_scalbn.c newlib/libm/common/s_signbit.c newlib/libm/common/s_trunc.c newlib/libm/common/scalblnl.c newlib/libm/common/scalbnl.c newlib/libm/common/sf_cbrt.c newlib/libm/common/sf_copysign.c newlib/libm/common/sf_exp10.c newlib/libm/common/sf_expm1.c newlib/libm/common/sf_fdim.c newlib/libm/common/sf_finite.c newlib/libm/common/sf_fma.c newlib/libm/common/sf_fmax.c newlib/libm/common/sf_fmin.c newlib/libm/common/sf_fpclassify.c newlib/libm/common/sf_ilogb.c newlib/libm/common/sf_infinity.c newlib/libm/common/sf_isinf.c newlib/libm/common/sf_isinff.c newlib/libm/common/sf_isnan.c newlib/libm/common/sf_isnanf.c newlib/libm/common/sf_llrint.c newlib/libm/common/sf_llround.c newlib/libm/common/sf_log1p.c newlib/libm/common/sf_log2.c newlib/libm/common/sf_logb.c newlib/libm/common/sf_lrint.c newlib/libm/common/sf_lround.c newlib/libm/common/sf_modf.c newlib/libm/common/sf_nan.c newlib/libm/common/sf_nearbyint.c newlib/libm/common/sf_nextafter.c newlib/libm/common/sf_pow10.c newlib/libm/common/sf_remquo.c newlib/libm/common/sf_rint.c newlib/libm/common/sf_round.c newlib/libm/common/sf_scalbln.c newlib/libm/common/sf_scalbn.c newlib/libm/common/sf_trunc.c newlib/libm/common/sinhl.c newlib/libm/common/sinl.c newlib/libm/common/sqrtl.c newlib/libm/common/tanhl.c newlib/libm/common/tanl.c newlib/libm/common/tgammal.c newlib/libm/common/truncl.c newlib/libm/config.h.in newlib/libm/configure newlib/libm/configure.in newlib/libm/libm.texinfo newlib/libm/machine/Makefile.am newlib/libm/machine/Makefile.in newlib/libm/machine/aclocal.m4 newlib/libm/machine/configure newlib/libm/machine/configure.in newlib/libm/machine/i386/Makefile.am newlib/libm/machine/i386/Makefile.in newlib/libm/machine/i386/aclocal.m4 newlib/libm/machine/i386/configure newlib/libm/machine/i386/configure.in newlib/libm/machine/i386/f_atan2.S newlib/libm/machine/i386/f_atan2f.S newlib/libm/machine/i386/f_exp.c newlib/libm/machine/i386/f_expf.c newlib/libm/machine/i386/f_frexp.S newlib/libm/machine/i386/f_frexpf.S newlib/libm/machine/i386/f_ldexp.S newlib/libm/machine/i386/f_ldexpf.S newlib/libm/machine/i386/f_llrint.c newlib/libm/machine/i386/f_llrintf.c newlib/libm/machine/i386/f_llrintl.c newlib/libm/machine/i386/f_log.S newlib/libm/machine/i386/f_log10.S newlib/libm/machine/i386/f_log10f.S newlib/libm/machine/i386/f_logf.S newlib/libm/machine/i386/f_lrint.c newlib/libm/machine/i386/f_lrintf.c newlib/libm/machine/i386/f_lrintl.c newlib/libm/machine/i386/f_math.h newlib/libm/machine/i386/f_pow.c newlib/libm/machine/i386/f_powf.c newlib/libm/machine/i386/f_rint.c newlib/libm/machine/i386/f_rintf.c newlib/libm/machine/i386/f_rintl.c newlib/libm/machine/i386/f_tan.S newlib/libm/machine/i386/f_tanf.S newlib/libm/machine/i386/i386mach.h newlib/libm/machine/spu/Makefile.am newlib/libm/machine/spu/Makefile.in newlib/libm/machine/spu/aclocal.m4 newlib/libm/machine/spu/configure newlib/libm/machine/spu/configure.in newlib/libm/machine/spu/fe_dfl_env.c newlib/libm/machine/spu/feclearexcept.c newlib/libm/machine/spu/fegetenv.c newlib/libm/machine/spu/fegetexceptflag.c newlib/libm/machine/spu/fegetround.c newlib/libm/machine/spu/feholdexcept.c newlib/libm/machine/spu/feraiseexcept.c newlib/libm/machine/spu/fesetenv.c newlib/libm/machine/spu/fesetexceptflag.c newlib/libm/machine/spu/fesetround.c newlib/libm/machine/spu/fetestexcept.c newlib/libm/machine/spu/feupdateenv.c newlib/libm/machine/spu/headers/acos.h newlib/libm/machine/spu/headers/acosd2.h newlib/libm/machine/spu/headers/acosf.h newlib/libm/machine/spu/headers/acosf4.h newlib/libm/machine/spu/headers/acosh.h newlib/libm/machine/spu/headers/acoshd2.h newlib/libm/machine/spu/headers/acoshf.h newlib/libm/machine/spu/headers/acoshf4.h newlib/libm/machine/spu/headers/asin.h newlib/libm/machine/spu/headers/asind2.h newlib/libm/machine/spu/headers/asinf.h newlib/libm/machine/spu/headers/asinf4.h newlib/libm/machine/spu/headers/asinh.h newlib/libm/machine/spu/headers/asinhd2.h newlib/libm/machine/spu/headers/asinhf.h newlib/libm/machine/spu/headers/asinhf4.h newlib/libm/machine/spu/headers/atan.h newlib/libm/machine/spu/headers/atan2.h newlib/libm/machine/spu/headers/atan2d2.h newlib/libm/machine/spu/headers/atan2f.h newlib/libm/machine/spu/headers/atan2f4.h newlib/libm/machine/spu/headers/atand2.h newlib/libm/machine/spu/headers/atanf.h newlib/libm/machine/spu/headers/atanf4.h newlib/libm/machine/spu/headers/atanh.h newlib/libm/machine/spu/headers/atanhd2.h newlib/libm/machine/spu/headers/atanhf.h newlib/libm/machine/spu/headers/atanhf4.h newlib/libm/machine/spu/headers/cbrt.h newlib/libm/machine/spu/headers/cbrtf.h newlib/libm/machine/spu/headers/ceil.h newlib/libm/machine/spu/headers/ceilf.h newlib/libm/machine/spu/headers/copysign.h newlib/libm/machine/spu/headers/copysignf.h newlib/libm/machine/spu/headers/cos.h newlib/libm/machine/spu/headers/cos_sin.h newlib/libm/machine/spu/headers/cosd2.h newlib/libm/machine/spu/headers/cosf.h newlib/libm/machine/spu/headers/cosf4.h newlib/libm/machine/spu/headers/cosh.h newlib/libm/machine/spu/headers/coshd2.h newlib/libm/machine/spu/headers/coshf.h newlib/libm/machine/spu/headers/coshf4.h newlib/libm/machine/spu/headers/divd2.h newlib/libm/machine/spu/headers/divf4.h newlib/libm/machine/spu/headers/dom_chkd_less_than.h newlib/libm/machine/spu/headers/dom_chkd_negone_one.h newlib/libm/machine/spu/headers/dom_chkf_less_than.h newlib/libm/machine/spu/headers/dom_chkf_negone_one.h newlib/libm/machine/spu/headers/erf.h newlib/libm/machine/spu/headers/erf_utils.h newlib/libm/machine/spu/headers/erfc.h newlib/libm/machine/spu/headers/erfcd2.h newlib/libm/machine/spu/headers/erfcf.h newlib/libm/machine/spu/headers/erfcf4.h newlib/libm/machine/spu/headers/erfd2.h newlib/libm/machine/spu/headers/erff.h newlib/libm/machine/spu/headers/erff4.h newlib/libm/machine/spu/headers/exp.h newlib/libm/machine/spu/headers/exp2.h newlib/libm/machine/spu/headers/exp2d2.h newlib/libm/machine/spu/headers/exp2f.h newlib/libm/machine/spu/headers/exp2f4.h newlib/libm/machine/spu/headers/expd2.h newlib/libm/machine/spu/headers/expf.h newlib/libm/machine/spu/headers/expf4.h newlib/libm/machine/spu/headers/expm1.h newlib/libm/machine/spu/headers/expm1d2.h newlib/libm/machine/spu/headers/expm1f.h newlib/libm/machine/spu/headers/expm1f4.h newlib/libm/machine/spu/headers/fabs.h newlib/libm/machine/spu/headers/fabsf.h newlib/libm/machine/spu/headers/fdim.h newlib/libm/machine/spu/headers/fdimf.h newlib/libm/machine/spu/headers/feclearexcept.h newlib/libm/machine/spu/headers/fefpscr.h newlib/libm/machine/spu/headers/fegetenv.h newlib/libm/machine/spu/headers/fegetexceptflag.h newlib/libm/machine/spu/headers/fegetround.h newlib/libm/machine/spu/headers/feholdexcept.h newlib/libm/machine/spu/headers/feraiseexcept.h newlib/libm/machine/spu/headers/fesetenv.h newlib/libm/machine/spu/headers/fesetexceptflag.h newlib/libm/machine/spu/headers/fesetround.h newlib/libm/machine/spu/headers/fetestexcept.h newlib/libm/machine/spu/headers/feupdateenv.h newlib/libm/machine/spu/headers/floor.h newlib/libm/machine/spu/headers/floord2.h newlib/libm/machine/spu/headers/floorf.h newlib/libm/machine/spu/headers/floorf4.h newlib/libm/machine/spu/headers/fma.h newlib/libm/machine/spu/headers/fmaf.h newlib/libm/machine/spu/headers/fmax.h newlib/libm/machine/spu/headers/fmaxf.h newlib/libm/machine/spu/headers/fmin.h newlib/libm/machine/spu/headers/fminf.h newlib/libm/machine/spu/headers/fmod.h newlib/libm/machine/spu/headers/fmodf.h newlib/libm/machine/spu/headers/frexp.h newlib/libm/machine/spu/headers/frexpf.h newlib/libm/machine/spu/headers/hypot.h newlib/libm/machine/spu/headers/hypotd2.h newlib/libm/machine/spu/headers/hypotf.h newlib/libm/machine/spu/headers/hypotf4.h newlib/libm/machine/spu/headers/ilogb.h newlib/libm/machine/spu/headers/ilogbf.h newlib/libm/machine/spu/headers/isnan.h newlib/libm/machine/spu/headers/isnand2.h newlib/libm/machine/spu/headers/isnanf.h newlib/libm/machine/spu/headers/isnanf4.h newlib/libm/machine/spu/headers/ldexp.h newlib/libm/machine/spu/headers/ldexpd2.h newlib/libm/machine/spu/headers/ldexpf.h newlib/libm/machine/spu/headers/ldexpf4.h newlib/libm/machine/spu/headers/lgamma.h newlib/libm/machine/spu/headers/lgammad2.h newlib/libm/machine/spu/headers/lgammaf.h newlib/libm/machine/spu/headers/lgammaf4.h newlib/libm/machine/spu/headers/llrint.h newlib/libm/machine/spu/headers/llrintf.h newlib/libm/machine/spu/headers/llround.h newlib/libm/machine/spu/headers/llroundf.h newlib/libm/machine/spu/headers/log.h newlib/libm/machine/spu/headers/log10.h newlib/libm/machine/spu/headers/log10d2.h newlib/libm/machine/spu/headers/log10f.h newlib/libm/machine/spu/headers/log1p.h newlib/libm/machine/spu/headers/log1pd2.h newlib/libm/machine/spu/headers/log1pf.h newlib/libm/machine/spu/headers/log1pf4.h newlib/libm/machine/spu/headers/log2.h newlib/libm/machine/spu/headers/log2d2.h newlib/libm/machine/spu/headers/log2f.h newlib/libm/machine/spu/headers/log2f4.h newlib/libm/machine/spu/headers/logbf.h newlib/libm/machine/spu/headers/logbf4.h newlib/libm/machine/spu/headers/logd2.h newlib/libm/machine/spu/headers/logf.h newlib/libm/machine/spu/headers/logf4.h newlib/libm/machine/spu/headers/lrint.h newlib/libm/machine/spu/headers/lrintf.h newlib/libm/machine/spu/headers/lround.h newlib/libm/machine/spu/headers/lroundf.h newlib/libm/machine/spu/headers/nearbyint.h newlib/libm/machine/spu/headers/nearbyintf.h newlib/libm/machine/spu/headers/nearbyintf4.h newlib/libm/machine/spu/headers/nextafter.h newlib/libm/machine/spu/headers/nextafterd2.h newlib/libm/machine/spu/headers/nextafterf.h newlib/libm/machine/spu/headers/nextafterf4.h newlib/libm/machine/spu/headers/pow.h newlib/libm/machine/spu/headers/powd2.h newlib/libm/machine/spu/headers/powf.h newlib/libm/machine/spu/headers/powf4.h newlib/libm/machine/spu/headers/recipd2.h newlib/libm/machine/spu/headers/recipf4.h newlib/libm/machine/spu/headers/remainder.h newlib/libm/machine/spu/headers/remainderf.h newlib/libm/machine/spu/headers/remquo.h newlib/libm/machine/spu/headers/remquof.h newlib/libm/machine/spu/headers/rint.h newlib/libm/machine/spu/headers/rintf.h newlib/libm/machine/spu/headers/rintf4.h newlib/libm/machine/spu/headers/round.h newlib/libm/machine/spu/headers/roundf.h newlib/libm/machine/spu/headers/scalbn.h newlib/libm/machine/spu/headers/scalbnf.h newlib/libm/machine/spu/headers/scalbnf4.h newlib/libm/machine/spu/headers/signbit.h newlib/libm/machine/spu/headers/signbitd2.h newlib/libm/machine/spu/headers/simdmath.h newlib/libm/machine/spu/headers/sin.h newlib/libm/machine/spu/headers/sincos.h newlib/libm/machine/spu/headers/sincosd2.h newlib/libm/machine/spu/headers/sincosf.h newlib/libm/machine/spu/headers/sincosf4.h newlib/libm/machine/spu/headers/sind2.h newlib/libm/machine/spu/headers/sinf.h newlib/libm/machine/spu/headers/sinf4.h newlib/libm/machine/spu/headers/sinh.h newlib/libm/machine/spu/headers/sinhd2.h newlib/libm/machine/spu/headers/sinhf.h newlib/libm/machine/spu/headers/sinhf4.h newlib/libm/machine/spu/headers/sqrt.h newlib/libm/machine/spu/headers/sqrtd2.h newlib/libm/machine/spu/headers/sqrtf.h newlib/libm/machine/spu/headers/sqrtf4.h newlib/libm/machine/spu/headers/tan.h newlib/libm/machine/spu/headers/tand2.h newlib/libm/machine/spu/headers/tanf.h newlib/libm/machine/spu/headers/tanf4.h newlib/libm/machine/spu/headers/tanh.h newlib/libm/machine/spu/headers/tanhd2.h newlib/libm/machine/spu/headers/tanhf.h newlib/libm/machine/spu/headers/tanhf4.h newlib/libm/machine/spu/headers/tgamma.h newlib/libm/machine/spu/headers/tgammad2.h newlib/libm/machine/spu/headers/tgammaf.h newlib/libm/machine/spu/headers/tgammaf4.h newlib/libm/machine/spu/headers/trunc.h newlib/libm/machine/spu/headers/truncd2.h newlib/libm/machine/spu/headers/truncf.h newlib/libm/machine/spu/headers/truncf4.h newlib/libm/machine/spu/headers/vec_literal.h newlib/libm/machine/spu/llrint.c newlib/libm/machine/spu/llrintf.c newlib/libm/machine/spu/llround.c newlib/libm/machine/spu/llroundf.c newlib/libm/machine/spu/log2.c newlib/libm/machine/spu/log2f.c newlib/libm/machine/spu/s_asinh.c newlib/libm/machine/spu/s_atan.c newlib/libm/machine/spu/s_cbrt.c newlib/libm/machine/spu/s_ceil.c newlib/libm/machine/spu/s_copysign.c newlib/libm/machine/spu/s_cos.c newlib/libm/machine/spu/s_erf.c newlib/libm/machine/spu/s_expm1.c newlib/libm/machine/spu/s_fabs.c newlib/libm/machine/spu/s_fdim.c newlib/libm/machine/spu/s_floor.c newlib/libm/machine/spu/s_fma.c newlib/libm/machine/spu/s_fmax.c newlib/libm/machine/spu/s_fmin.c newlib/libm/machine/spu/s_frexp.c newlib/libm/machine/spu/s_ilogb.c newlib/libm/machine/spu/s_isnan.c newlib/libm/machine/spu/s_ldexp.c newlib/libm/machine/spu/s_log1p.c newlib/libm/machine/spu/s_lrint.c newlib/libm/machine/spu/s_lround.c newlib/libm/machine/spu/s_nearbyint.c newlib/libm/machine/spu/s_nextafter.c newlib/libm/machine/spu/s_remquo.c newlib/libm/machine/spu/s_rint.c newlib/libm/machine/spu/s_round.c newlib/libm/machine/spu/s_scalbn.c newlib/libm/machine/spu/s_sin.c newlib/libm/machine/spu/s_tan.c newlib/libm/machine/spu/s_tanh.c newlib/libm/machine/spu/s_trunc.c newlib/libm/machine/spu/sf_asinh.c newlib/libm/machine/spu/sf_atan.c newlib/libm/machine/spu/sf_cbrt.c newlib/libm/machine/spu/sf_ceil.c newlib/libm/machine/spu/sf_copysign.c newlib/libm/machine/spu/sf_cos.c newlib/libm/machine/spu/sf_erf.c newlib/libm/machine/spu/sf_expm1.c newlib/libm/machine/spu/sf_fabs.c newlib/libm/machine/spu/sf_fdim.c newlib/libm/machine/spu/sf_finite.c newlib/libm/machine/spu/sf_floor.c newlib/libm/machine/spu/sf_fma.c newlib/libm/machine/spu/sf_fmax.c newlib/libm/machine/spu/sf_fmin.c newlib/libm/machine/spu/sf_fpclassify.c newlib/libm/machine/spu/sf_frexp.c newlib/libm/machine/spu/sf_ilogb.c newlib/libm/machine/spu/sf_isinf.c newlib/libm/machine/spu/sf_isinff.c newlib/libm/machine/spu/sf_isnan.c newlib/libm/machine/spu/sf_isnanf.c newlib/libm/machine/spu/sf_ldexp.c newlib/libm/machine/spu/sf_log1p.c newlib/libm/machine/spu/sf_logb.c newlib/libm/machine/spu/sf_lrint.c newlib/libm/machine/spu/sf_lround.c newlib/libm/machine/spu/sf_nan.c newlib/libm/machine/spu/sf_nearbyint.c newlib/libm/machine/spu/sf_nextafter.c newlib/libm/machine/spu/sf_remquo.c newlib/libm/machine/spu/sf_rint.c newlib/libm/machine/spu/sf_round.c newlib/libm/machine/spu/sf_scalbn.c newlib/libm/machine/spu/sf_sin.c newlib/libm/machine/spu/sf_tan.c newlib/libm/machine/spu/sf_tanh.c newlib/libm/machine/spu/sf_trunc.c newlib/libm/machine/spu/w_acos.c newlib/libm/machine/spu/w_acosh.c newlib/libm/machine/spu/w_asin.c newlib/libm/machine/spu/w_atan2.c newlib/libm/machine/spu/w_atanh.c newlib/libm/machine/spu/w_cosh.c newlib/libm/machine/spu/w_exp.c newlib/libm/machine/spu/w_exp2.c newlib/libm/machine/spu/w_fmod.c newlib/libm/machine/spu/w_hypot.c newlib/libm/machine/spu/w_lgamma.c newlib/libm/machine/spu/w_log.c newlib/libm/machine/spu/w_log10.c newlib/libm/machine/spu/w_pow.c newlib/libm/machine/spu/w_remainder.c newlib/libm/machine/spu/w_sincos.c newlib/libm/machine/spu/w_sinh.c newlib/libm/machine/spu/w_sqrt.c newlib/libm/machine/spu/w_tgamma.c newlib/libm/machine/spu/wf_acos.c newlib/libm/machine/spu/wf_acosh.c newlib/libm/machine/spu/wf_asin.c newlib/libm/machine/spu/wf_atan2.c newlib/libm/machine/spu/wf_atanh.c newlib/libm/machine/spu/wf_cosh.c newlib/libm/machine/spu/wf_exp.c newlib/libm/machine/spu/wf_exp2.c newlib/libm/machine/spu/wf_fmod.c newlib/libm/machine/spu/wf_hypot.c newlib/libm/machine/spu/wf_lgamma.c newlib/libm/machine/spu/wf_log.c newlib/libm/machine/spu/wf_log10.c newlib/libm/machine/spu/wf_pow.c newlib/libm/machine/spu/wf_remainder.c newlib/libm/machine/spu/wf_sincos.c newlib/libm/machine/spu/wf_sinh.c newlib/libm/machine/spu/wf_sqrt.c newlib/libm/machine/spu/wf_tgamma.c newlib/libm/math/Makefile.am newlib/libm/math/Makefile.in newlib/libm/math/e_acos.c newlib/libm/math/e_acosh.c newlib/libm/math/e_asin.c newlib/libm/math/e_atan2.c newlib/libm/math/e_atanh.c newlib/libm/math/e_cosh.c newlib/libm/math/e_exp.c newlib/libm/math/e_fmod.c newlib/libm/math/e_hypot.c newlib/libm/math/e_j0.c newlib/libm/math/e_j1.c newlib/libm/math/e_jn.c newlib/libm/math/e_log.c newlib/libm/math/e_log10.c newlib/libm/math/e_pow.c newlib/libm/math/e_rem_pio2.c newlib/libm/math/e_remainder.c newlib/libm/math/e_scalb.c newlib/libm/math/e_sinh.c newlib/libm/math/e_sqrt.c newlib/libm/math/ef_acos.c newlib/libm/math/ef_acosh.c newlib/libm/math/ef_asin.c newlib/libm/math/ef_atan2.c newlib/libm/math/ef_atanh.c newlib/libm/math/ef_cosh.c newlib/libm/math/ef_exp.c newlib/libm/math/ef_fmod.c newlib/libm/math/ef_hypot.c newlib/libm/math/ef_j0.c newlib/libm/math/ef_j1.c newlib/libm/math/ef_jn.c newlib/libm/math/ef_log.c newlib/libm/math/ef_log10.c newlib/libm/math/ef_pow.c newlib/libm/math/ef_rem_pio2.c newlib/libm/math/ef_remainder.c newlib/libm/math/ef_scalb.c newlib/libm/math/ef_sinh.c newlib/libm/math/ef_sqrt.c newlib/libm/math/er_gamma.c newlib/libm/math/er_lgamma.c newlib/libm/math/erf_gamma.c newlib/libm/math/erf_lgamma.c newlib/libm/math/k_cos.c newlib/libm/math/k_rem_pio2.c newlib/libm/math/k_sin.c newlib/libm/math/k_standard.c newlib/libm/math/k_tan.c newlib/libm/math/kf_cos.c newlib/libm/math/kf_rem_pio2.c newlib/libm/math/kf_sin.c newlib/libm/math/kf_tan.c newlib/libm/math/math.tex newlib/libm/math/s_asinh.c newlib/libm/math/s_atan.c newlib/libm/math/s_ceil.c newlib/libm/math/s_cos.c newlib/libm/math/s_erf.c newlib/libm/math/s_fabs.c newlib/libm/math/s_floor.c newlib/libm/math/s_frexp.c newlib/libm/math/s_ldexp.c newlib/libm/math/s_signif.c newlib/libm/math/s_sin.c newlib/libm/math/s_tan.c newlib/libm/math/s_tanh.c newlib/libm/math/sf_asinh.c newlib/libm/math/sf_atan.c newlib/libm/math/sf_ceil.c newlib/libm/math/sf_cos.c newlib/libm/math/sf_erf.c newlib/libm/math/sf_fabs.c newlib/libm/math/sf_floor.c newlib/libm/math/sf_frexp.c newlib/libm/math/sf_ldexp.c newlib/libm/math/sf_signif.c newlib/libm/math/sf_sin.c newlib/libm/math/sf_tan.c newlib/libm/math/sf_tanh.c newlib/libm/math/w_acos.c newlib/libm/math/w_acosh.c newlib/libm/math/w_asin.c newlib/libm/math/w_atan2.c newlib/libm/math/w_atanh.c newlib/libm/math/w_cabs.c newlib/libm/math/w_cosh.c newlib/libm/math/w_drem.c newlib/libm/math/w_exp.c newlib/libm/math/w_exp2.c newlib/libm/math/w_fmod.c newlib/libm/math/w_gamma.c newlib/libm/math/w_hypot.c newlib/libm/math/w_j0.c newlib/libm/math/w_j1.c newlib/libm/math/w_jn.c newlib/libm/math/w_lgamma.c newlib/libm/math/w_log.c newlib/libm/math/w_log10.c newlib/libm/math/w_pow.c newlib/libm/math/w_remainder.c newlib/libm/math/w_scalb.c newlib/libm/math/w_sincos.c newlib/libm/math/w_sinh.c newlib/libm/math/w_sqrt.c newlib/libm/math/w_tgamma.c newlib/libm/math/wf_acos.c newlib/libm/math/wf_acosh.c newlib/libm/math/wf_asin.c newlib/libm/math/wf_atan2.c newlib/libm/math/wf_atanh.c newlib/libm/math/wf_cabs.c newlib/libm/math/wf_cosh.c newlib/libm/math/wf_drem.c newlib/libm/math/wf_exp.c newlib/libm/math/wf_exp2.c newlib/libm/math/wf_fmod.c newlib/libm/math/wf_gamma.c newlib/libm/math/wf_hypot.c newlib/libm/math/wf_j0.c newlib/libm/math/wf_j1.c newlib/libm/math/wf_jn.c newlib/libm/math/wf_lgamma.c newlib/libm/math/wf_log.c newlib/libm/math/wf_log10.c newlib/libm/math/wf_pow.c newlib/libm/math/wf_remainder.c newlib/libm/math/wf_scalb.c newlib/libm/math/wf_sincos.c newlib/libm/math/wf_sinh.c newlib/libm/math/wf_sqrt.c newlib/libm/math/wf_tgamma.c newlib/libm/math/wr_gamma.c newlib/libm/math/wr_lgamma.c newlib/libm/math/wrf_gamma.c newlib/libm/math/wrf_lgamma.c newlib/libm/mathfp/Makefile.am newlib/libm/mathfp/Makefile.in newlib/libm/mathfp/e_acosh.c newlib/libm/mathfp/e_atanh.c newlib/libm/mathfp/e_hypot.c newlib/libm/mathfp/e_j0.c newlib/libm/mathfp/e_j1.c newlib/libm/mathfp/e_remainder.c newlib/libm/mathfp/e_scalb.c newlib/libm/mathfp/ef_acosh.c newlib/libm/mathfp/ef_atanh.c newlib/libm/mathfp/ef_hypot.c newlib/libm/mathfp/ef_j0.c newlib/libm/mathfp/ef_j1.c newlib/libm/mathfp/ef_remainder.c newlib/libm/mathfp/ef_scalb.c newlib/libm/mathfp/er_gamma.c newlib/libm/mathfp/er_lgamma.c newlib/libm/mathfp/erf_gamma.c newlib/libm/mathfp/erf_lgamma.c newlib/libm/mathfp/mathfp.tex newlib/libm/mathfp/s_acos.c newlib/libm/mathfp/s_asin.c newlib/libm/mathfp/s_asine.c newlib/libm/mathfp/s_asinh.c newlib/libm/mathfp/s_atan.c newlib/libm/mathfp/s_atan2.c newlib/libm/mathfp/s_atangent.c newlib/libm/mathfp/s_ceil.c newlib/libm/mathfp/s_cos.c newlib/libm/mathfp/s_cosh.c newlib/libm/mathfp/s_erf.c newlib/libm/mathfp/s_exp.c newlib/libm/mathfp/s_exp2.c newlib/libm/mathfp/s_fabs.c newlib/libm/mathfp/s_floor.c newlib/libm/mathfp/s_fmod.c newlib/libm/mathfp/s_frexp.c newlib/libm/mathfp/s_ispos.c newlib/libm/mathfp/s_ldexp.c newlib/libm/mathfp/s_log.c newlib/libm/mathfp/s_log10.c newlib/libm/mathfp/s_logarithm.c newlib/libm/mathfp/s_mathcnst.c newlib/libm/mathfp/s_numtest.c newlib/libm/mathfp/s_pow.c newlib/libm/mathfp/s_signif.c newlib/libm/mathfp/s_sin.c newlib/libm/mathfp/s_sincos.c newlib/libm/mathfp/s_sine.c newlib/libm/mathfp/s_sineh.c newlib/libm/mathfp/s_sinf.c newlib/libm/mathfp/s_sinh.c newlib/libm/mathfp/s_sqrt.c newlib/libm/mathfp/s_tan.c newlib/libm/mathfp/s_tanh.c newlib/libm/mathfp/s_tgamma.c newlib/libm/mathfp/sf_acos.c newlib/libm/mathfp/sf_asin.c newlib/libm/mathfp/sf_asine.c newlib/libm/mathfp/sf_asinh.c newlib/libm/mathfp/sf_atan.c newlib/libm/mathfp/sf_atan2.c newlib/libm/mathfp/sf_atangent.c newlib/libm/mathfp/sf_ceil.c newlib/libm/mathfp/sf_cos.c newlib/libm/mathfp/sf_cosh.c newlib/libm/mathfp/sf_erf.c newlib/libm/mathfp/sf_exp.c newlib/libm/mathfp/sf_exp2.c newlib/libm/mathfp/sf_fabs.c newlib/libm/mathfp/sf_floor.c newlib/libm/mathfp/sf_fmod.c newlib/libm/mathfp/sf_frexp.c newlib/libm/mathfp/sf_ispos.c newlib/libm/mathfp/sf_ldexp.c newlib/libm/mathfp/sf_log.c newlib/libm/mathfp/sf_log10.c newlib/libm/mathfp/sf_logarithm.c newlib/libm/mathfp/sf_numtest.c newlib/libm/mathfp/sf_pow.c newlib/libm/mathfp/sf_signif.c newlib/libm/mathfp/sf_sin.c newlib/libm/mathfp/sf_sincos.c newlib/libm/mathfp/sf_sine.c newlib/libm/mathfp/sf_sineh.c newlib/libm/mathfp/sf_sinh.c newlib/libm/mathfp/sf_sqrt.c newlib/libm/mathfp/sf_tan.c newlib/libm/mathfp/sf_tanh.c newlib/libm/mathfp/sf_tgamma.c newlib/libm/mathfp/w_cabs.c newlib/libm/mathfp/w_drem.c newlib/libm/mathfp/w_jn.c newlib/libm/mathfp/wf_cabs.c newlib/libm/mathfp/wf_drem.c newlib/libm/mathfp/wf_jn.c newlib/libm/mathfp/zmath.h newlib/libm/test/Makefile.in newlib/libm/test/acos_vec.c newlib/libm/test/acosf_vec.c newlib/libm/test/acosh_vec.c newlib/libm/test/acoshf_vec.c newlib/libm/test/asin_vec.c newlib/libm/test/asinf_vec.c newlib/libm/test/asinh_vec.c newlib/libm/test/asinhf_vec.c newlib/libm/test/atan2_vec.c newlib/libm/test/atan2f_vec.c newlib/libm/test/atan_vec.c newlib/libm/test/atanf_vec.c newlib/libm/test/atanh_vec.c newlib/libm/test/atanhf_vec.c newlib/libm/test/ceil_vec.c newlib/libm/test/ceilf_vec.c newlib/libm/test/conv_vec.c newlib/libm/test/convert.c newlib/libm/test/cos_vec.c newlib/libm/test/cosf_vec.c newlib/libm/test/cosh_vec.c newlib/libm/test/coshf_vec.c newlib/libm/test/dcvt.c newlib/libm/test/dvec.c newlib/libm/test/erf_vec.c newlib/libm/test/erfc_vec.c newlib/libm/test/erfcf_vec.c newlib/libm/test/erff_vec.c newlib/libm/test/exp_vec.c newlib/libm/test/expf_vec.c newlib/libm/test/fabs_vec.c newlib/libm/test/fabsf_vec.c newlib/libm/test/floor_vec.c newlib/libm/test/floorf_vec.c newlib/libm/test/fmod_vec.c newlib/libm/test/fmodf_vec.c newlib/libm/test/gamma_vec.c newlib/libm/test/gammaf_vec.c newlib/libm/test/hypot_vec.c newlib/libm/test/hypotf_vec.c newlib/libm/test/iconv_vec.c newlib/libm/test/j0_vec.c newlib/libm/test/j0f_vec.c newlib/libm/test/j1_vec.c newlib/libm/test/j1f_vec.c newlib/libm/test/jn_vec.c newlib/libm/test/jnf_vec.c newlib/libm/test/log10_vec.c newlib/libm/test/log10f_vec.c newlib/libm/test/log1p_vec.c newlib/libm/test/log1pf_vec.c newlib/libm/test/log2_vec.c newlib/libm/test/log2f_vec.c newlib/libm/test/log_vec.c newlib/libm/test/logf_vec.c newlib/libm/test/math.c newlib/libm/test/math2.c newlib/libm/test/sin_vec.c newlib/libm/test/sinf_vec.c newlib/libm/test/sinh_vec.c newlib/libm/test/sinhf_vec.c newlib/libm/test/sprint_ivec.c newlib/libm/test/sprint_vec.c newlib/libm/test/sqrt_vec.c newlib/libm/test/sqrtf_vec.c newlib/libm/test/string.c newlib/libm/test/tan_vec.c newlib/libm/test/tanf_vec.c newlib/libm/test/tanh_vec.c newlib/libm/test/tanhf_vec.c newlib/libm/test/test.c newlib/libm/test/test.h newlib/libm/test/test_ieee.c newlib/libm/test/test_is.c newlib/libm/test/y0_vec.c newlib/libm/test/y0f_vec.c newlib/libm/test/y1_vec.c newlib/libm/test/y1f_vec.c newlib/libm/test/yn_vec.c newlib/libm/test/ynf_vec.c newlib/newlib.hin newlib/stamp-h.in newlib/testsuite/config/default.exp newlib/testsuite/include/check.h newlib/testsuite/lib/checkoutput.exp newlib/testsuite/lib/flags.exp newlib/testsuite/lib/newlib.exp newlib/testsuite/lib/passfail.exp newlib/testsuite/newlib.elix/elix.exp newlib/testsuite/newlib.elix/tmmap.c newlib/testsuite/newlib.iconv/iconv.exp newlib/testsuite/newlib.iconv/iconvjp.c newlib/testsuite/newlib.iconv/iconvnm.c newlib/testsuite/newlib.iconv/iconvru.c newlib/testsuite/newlib.locale/UTF-8.c newlib/testsuite/newlib.locale/UTF-8.exp newlib/testsuite/newlib.locale/locale.exp newlib/testsuite/newlib.search/hsearchtest.c newlib/testsuite/newlib.search/hsearchtest.exp newlib/testsuite/newlib.stdlib/atexit.c newlib/testsuite/newlib.stdlib/atexit.exp newlib/testsuite/newlib.stdlib/size_max.c newlib/testsuite/newlib.stdlib/stdlib.exp newlib/testsuite/newlib.string/memmove1.c newlib/testsuite/newlib.string/string.exp newlib/testsuite/newlib.string/tstring.c newlib/testsuite/newlib.wctype/tiswctype.c newlib/testsuite/newlib.wctype/twctrans.c newlib/testsuite/newlib.wctype/twctype.c newlib/testsuite/newlib.wctype/wctype.exp winsup/COPYING winsup/CYGWIN_LICENSE winsup/ChangeLog winsup/Makefile.common winsup/Makefile.in winsup/README winsup/acinclude.m4 winsup/aclocal.m4 winsup/configure winsup/configure.in winsup/cygserver/ChangeLog winsup/cygserver/Makefile.in winsup/cygserver/README winsup/cygserver/aclocal.m4 winsup/cygserver/bsd_helper.cc winsup/cygserver/bsd_helper.h winsup/cygserver/bsd_log.cc winsup/cygserver/bsd_log.h winsup/cygserver/bsd_mutex.cc winsup/cygserver/bsd_mutex.h winsup/cygserver/client.cc winsup/cygserver/configure winsup/cygserver/configure.in winsup/cygserver/cygserver-config winsup/cygserver/cygserver.cc winsup/cygserver/cygserver.conf winsup/cygserver/msg.cc winsup/cygserver/process.cc winsup/cygserver/process.h winsup/cygserver/sem.cc winsup/cygserver/setpwd.cc winsup/cygserver/shm.cc winsup/cygserver/sysv_msg.cc winsup/cygserver/sysv_sem.cc winsup/cygserver/sysv_shm.cc winsup/cygserver/threaded_queue.cc winsup/cygserver/threaded_queue.h winsup/cygserver/transport.cc winsup/cygserver/transport.h winsup/cygserver/transport_pipes.cc winsup/cygserver/transport_pipes.h winsup/cygserver/woutsup.h winsup/cygwin/ChangeLog winsup/cygwin/ChangeLog-1995 winsup/cygwin/ChangeLog-1996 winsup/cygwin/ChangeLog-1997 winsup/cygwin/ChangeLog-1998 winsup/cygwin/ChangeLog-1999 winsup/cygwin/ChangeLog-2000 winsup/cygwin/ChangeLog-2001 winsup/cygwin/ChangeLog-2002 winsup/cygwin/ChangeLog-2003 winsup/cygwin/ChangeLog-2004 winsup/cygwin/ChangeLog-2005 winsup/cygwin/ChangeLog-2006 winsup/cygwin/ChangeLog-2007 winsup/cygwin/ChangeLog-2008 winsup/cygwin/ChangeLog-2009 winsup/cygwin/Makefile.in winsup/cygwin/ROADMAP winsup/cygwin/acconfig.h winsup/cygwin/aclocal.m4 winsup/cygwin/analyze_sigfe winsup/cygwin/assert.cc winsup/cygwin/autoload.cc winsup/cygwin/automode.c winsup/cygwin/binmode.c winsup/cygwin/child_info.h winsup/cygwin/config.h.in winsup/cygwin/config/i386/profile.h winsup/cygwin/configure winsup/cygwin/configure.in winsup/cygwin/cpuid.h winsup/cygwin/crt0.c winsup/cygwin/ctype.cc winsup/cygwin/cxx.cc winsup/cygwin/cygerrno.h winsup/cygwin/cygheap.cc winsup/cygwin/cygheap.h winsup/cygwin/cygheap_malloc.h winsup/cygwin/cyglsa.h winsup/cygwin/cygmagic winsup/cygwin/cygmalloc.h winsup/cygwin/cygprops.h winsup/cygwin/cygserver.h winsup/cygwin/cygserver_ipc.h winsup/cygwin/cygserver_msg.h winsup/cygwin/cygserver_sem.h winsup/cygwin/cygserver_setpwd.h winsup/cygwin/cygserver_shm.h winsup/cygwin/cygthread.cc winsup/cygwin/cygthread.h winsup/cygwin/cygtls.cc winsup/cygwin/cygtls.h winsup/cygwin/cygwin-cxx.h winsup/cygwin/cygwin-shilka winsup/cygwin/cygwin.din winsup/cygwin/cygwin.sc winsup/cygwin/cygwin_version.h winsup/cygwin/dcrt0.cc winsup/cygwin/debug.cc winsup/cygwin/debug.h winsup/cygwin/devices.cc winsup/cygwin/devices.h winsup/cygwin/devices.in winsup/cygwin/dir.cc winsup/cygwin/dlfcn.cc winsup/cygwin/dll_init.cc winsup/cygwin/dll_init.h winsup/cygwin/dll_init.sgml winsup/cygwin/dllfixdbg winsup/cygwin/dlmalloc.c winsup/cygwin/dlmalloc.h winsup/cygwin/dtable.cc winsup/cygwin/dtable.h winsup/cygwin/dtable.sgml winsup/cygwin/environ.cc winsup/cygwin/environ.h winsup/cygwin/errno.cc winsup/cygwin/exceptions.cc winsup/cygwin/exec.cc winsup/cygwin/external.cc winsup/cygwin/external.sgml winsup/cygwin/fcntl.cc winsup/cygwin/fhandler.cc winsup/cygwin/fhandler.h winsup/cygwin/fhandler_clipboard.cc winsup/cygwin/fhandler_console.cc winsup/cygwin/fhandler_disk_file.cc winsup/cygwin/fhandler_dsp.cc winsup/cygwin/fhandler_fifo.cc winsup/cygwin/fhandler_floppy.cc winsup/cygwin/fhandler_mailslot.cc winsup/cygwin/fhandler_mem.cc winsup/cygwin/fhandler_netdrive.cc winsup/cygwin/fhandler_nodevice.cc winsup/cygwin/fhandler_proc.cc winsup/cygwin/fhandler_process.cc winsup/cygwin/fhandler_procnet.cc winsup/cygwin/fhandler_random.cc winsup/cygwin/fhandler_raw.cc winsup/cygwin/fhandler_registry.cc winsup/cygwin/fhandler_serial.cc winsup/cygwin/fhandler_socket.cc winsup/cygwin/fhandler_tape.cc winsup/cygwin/fhandler_termios.cc winsup/cygwin/fhandler_tty.cc winsup/cygwin/fhandler_virtual.cc winsup/cygwin/fhandler_virtual.h winsup/cygwin/fhandler_windows.cc winsup/cygwin/fhandler_zero.cc winsup/cygwin/flock.cc winsup/cygwin/fork.cc winsup/cygwin/gcrt0.c winsup/cygwin/gendef winsup/cygwin/gendevices winsup/cygwin/gentls_offsets winsup/cygwin/glob.cc winsup/cygwin/glob_pattern_p.cc winsup/cygwin/globals.cc winsup/cygwin/gmon.c winsup/cygwin/gmon.h winsup/cygwin/grp.cc winsup/cygwin/heap.cc winsup/cygwin/heap.h winsup/cygwin/hires.h winsup/cygwin/hookapi.cc winsup/cygwin/how-autoload-works.txt winsup/cygwin/how-cygheap-works.txt winsup/cygwin/how-cygtls-works.txt winsup/cygwin/how-fhandlers-work.txt winsup/cygwin/how-signals-work.txt winsup/cygwin/how-spawn-works.txt winsup/cygwin/how-startup-shutdown-works.txt winsup/cygwin/how-to-debug-cygwin.txt winsup/cygwin/how-vfork-works.txt winsup/cygwin/include/a.out.h winsup/cygwin/include/arpa/ftp.h winsup/cygwin/include/arpa/inet.h winsup/cygwin/include/arpa/nameser.h winsup/cygwin/include/arpa/nameser_compat.h winsup/cygwin/include/arpa/telnet.h winsup/cygwin/include/asm/byteorder.h winsup/cygwin/include/asm/socket.h winsup/cygwin/include/asm/types.h winsup/cygwin/include/attr/xattr.h winsup/cygwin/include/bits/wordsize.h winsup/cygwin/include/byteswap.h winsup/cygwin/include/cygwin/_types.h winsup/cygwin/include/cygwin/acl.h winsup/cygwin/include/cygwin/config.h winsup/cygwin/include/cygwin/core_dump.h winsup/cygwin/include/cygwin/cygwin_dll.h winsup/cygwin/include/cygwin/fs.h winsup/cygwin/include/cygwin/grp.h winsup/cygwin/include/cygwin/hdreg.h winsup/cygwin/include/cygwin/icmp.h winsup/cygwin/include/cygwin/if.h winsup/cygwin/include/cygwin/in.h winsup/cygwin/include/cygwin/in6.h winsup/cygwin/include/cygwin/in_systm.h winsup/cygwin/include/cygwin/ipc.h winsup/cygwin/include/cygwin/kd.h winsup/cygwin/include/cygwin/msg.h winsup/cygwin/include/cygwin/mtio.h winsup/cygwin/include/cygwin/rdevio.h winsup/cygwin/include/cygwin/sem.h winsup/cygwin/include/cygwin/shm.h winsup/cygwin/include/cygwin/signal.h winsup/cygwin/include/cygwin/socket.h winsup/cygwin/include/cygwin/sockios.h winsup/cygwin/include/cygwin/stat.h winsup/cygwin/include/cygwin/stdlib.h winsup/cygwin/include/cygwin/sys_time.h winsup/cygwin/include/cygwin/sysproto.h winsup/cygwin/include/cygwin/time.h winsup/cygwin/include/cygwin/types.h winsup/cygwin/include/cygwin/utmp.h winsup/cygwin/include/cygwin/version.h winsup/cygwin/include/cygwin/wait.h winsup/cygwin/include/dlfcn.h winsup/cygwin/include/elf.h winsup/cygwin/include/endian.h winsup/cygwin/include/err.h winsup/cygwin/include/exceptions.h winsup/cygwin/include/fcntl.h winsup/cygwin/include/features.h winsup/cygwin/include/fnmatch.h winsup/cygwin/include/fts.h winsup/cygwin/include/ftw.h winsup/cygwin/include/getopt.h winsup/cygwin/include/glob.h winsup/cygwin/include/icmp.h winsup/cygwin/include/ifaddrs.h winsup/cygwin/include/inttypes.h winsup/cygwin/include/io.h winsup/cygwin/include/lastlog.h winsup/cygwin/include/libgen.h winsup/cygwin/include/limits.h winsup/cygwin/include/machine/stdlib.h winsup/cygwin/include/mapi.h winsup/cygwin/include/memory.h winsup/cygwin/include/mntent.h winsup/cygwin/include/monetary.h winsup/cygwin/include/mqueue.h winsup/cygwin/include/net/if.h winsup/cygwin/include/netdb.h winsup/cygwin/include/netinet/in.h winsup/cygwin/include/netinet/in_systm.h winsup/cygwin/include/netinet/ip.h winsup/cygwin/include/netinet/ip_icmp.h winsup/cygwin/include/netinet/tcp.h winsup/cygwin/include/netinet/udp.h winsup/cygwin/include/paths.h winsup/cygwin/include/poll.h winsup/cygwin/include/pthread.h winsup/cygwin/include/pty.h winsup/cygwin/include/regex.h winsup/cygwin/include/resolv.h winsup/cygwin/include/sched.h winsup/cygwin/include/search.h winsup/cygwin/include/semaphore.h winsup/cygwin/include/stdint.h winsup/cygwin/include/strings.h winsup/cygwin/include/sys/acl.h winsup/cygwin/include/sys/copying.dj winsup/cygwin/include/sys/cygwin.h winsup/cygwin/include/sys/dirent.h winsup/cygwin/include/sys/elf32.h winsup/cygwin/include/sys/elf64.h winsup/cygwin/include/sys/elf_common.h winsup/cygwin/include/sys/elf_generic.h winsup/cygwin/include/sys/file.h winsup/cygwin/include/sys/ioctl.h winsup/cygwin/include/sys/ipc.h winsup/cygwin/include/sys/kd.h winsup/cygwin/include/sys/lock.h winsup/cygwin/include/sys/mman.h winsup/cygwin/include/sys/mount.h winsup/cygwin/include/sys/msg.h winsup/cygwin/include/sys/mtio.h winsup/cygwin/include/sys/param.h winsup/cygwin/include/sys/poll.h winsup/cygwin/include/sys/procfs.h winsup/cygwin/include/sys/queue.h winsup/cygwin/include/sys/resource.h winsup/cygwin/include/sys/sched.h winsup/cygwin/include/sys/select.h winsup/cygwin/include/sys/sem.h winsup/cygwin/include/sys/shm.h winsup/cygwin/include/sys/smallprint.h winsup/cygwin/include/sys/socket.h winsup/cygwin/include/sys/soundcard.h winsup/cygwin/include/sys/statfs.h winsup/cygwin/include/sys/statvfs.h winsup/cygwin/include/sys/stdio.h winsup/cygwin/include/sys/strace.h winsup/cygwin/include/sys/sysinfo.h winsup/cygwin/include/sys/syslimits.h winsup/cygwin/include/sys/syslog.h winsup/cygwin/include/sys/sysmacros.h winsup/cygwin/include/sys/sysproto.h winsup/cygwin/include/sys/termio.h winsup/cygwin/include/sys/termios.h winsup/cygwin/include/sys/ttychars.h winsup/cygwin/include/sys/uio.h winsup/cygwin/include/sys/un.h winsup/cygwin/include/sys/utime.h winsup/cygwin/include/sys/utmp.h winsup/cygwin/include/sys/utsname.h winsup/cygwin/include/sys/vfs.h winsup/cygwin/include/sys/wait.h winsup/cygwin/include/sysexits.h winsup/cygwin/include/syslog.h winsup/cygwin/include/termio.h winsup/cygwin/include/tzfile.h winsup/cygwin/include/utmpx.h winsup/cygwin/include/wait.h winsup/cygwin/init.cc winsup/cygwin/ioctl.cc winsup/cygwin/ipc.cc winsup/cygwin/kernel32.cc winsup/cygwin/lc_msg.h winsup/cygwin/lib/_cygwin_crt0_common.cc winsup/cygwin/lib/crt0.h winsup/cygwin/lib/cygwin_attach_dll.c winsup/cygwin/lib/cygwin_crt0.c winsup/cygwin/lib/dll_entry.c winsup/cygwin/lib/dll_main.cc winsup/cygwin/lib/libcmain.c winsup/cygwin/lib/premain0.c winsup/cygwin/lib/premain1.c winsup/cygwin/lib/premain2.c winsup/cygwin/lib/premain3.c winsup/cygwin/lib/pseudo-reloc.c winsup/cygwin/libc/bsdlib.cc winsup/cygwin/libc/fnmatch.c winsup/cygwin/libc/fts.c winsup/cygwin/libc/ftw.c winsup/cygwin/libc/getopt.c winsup/cygwin/libc/inet_addr.c winsup/cygwin/libc/inet_network.c winsup/cygwin/libc/minires-os-if.c winsup/cygwin/libc/minires.c winsup/cygwin/libc/minires.h winsup/cygwin/libc/nftw.c winsup/cygwin/libc/rcmd.cc winsup/cygwin/libc/rexec.cc winsup/cygwin/libc/strfmon.c winsup/cygwin/libc/strptime.cc winsup/cygwin/libc/xsique.cc winsup/cygwin/libstdcxx_wrapper.cc winsup/cygwin/localtime.cc winsup/cygwin/lsearch.cc winsup/cygwin/malloc.cc winsup/cygwin/malloc_wrapper.cc winsup/cygwin/mcount.c winsup/cygwin/miscfuncs.cc winsup/cygwin/miscfuncs.h winsup/cygwin/mkglobals_h winsup/cygwin/mkimport winsup/cygwin/mkstatic winsup/cygwin/mktemp.cc winsup/cygwin/mkvers.sh winsup/cygwin/mmap.cc winsup/cygwin/mmap_helper.h winsup/cygwin/mount.cc winsup/cygwin/mount.h winsup/cygwin/msg.cc winsup/cygwin/mtinfo.h winsup/cygwin/net.cc winsup/cygwin/netdb.cc winsup/cygwin/nfs.cc winsup/cygwin/nfs.h winsup/cygwin/nlsfuncs.cc winsup/cygwin/ntdll.h winsup/cygwin/ntea.cc winsup/cygwin/passwd.cc winsup/cygwin/path.cc winsup/cygwin/path.h winsup/cygwin/path.sgml winsup/cygwin/perprocess.h winsup/cygwin/pinfo.cc winsup/cygwin/pinfo.h winsup/cygwin/pipe.cc winsup/cygwin/poll.cc winsup/cygwin/posix.sgml winsup/cygwin/posix_ipc.cc winsup/cygwin/profil.c winsup/cygwin/profil.h winsup/cygwin/pseudo-reloc.cc winsup/cygwin/pthread.cc winsup/cygwin/pwdgrp.h winsup/cygwin/random.cc winsup/cygwin/regex/COPYRIGHT winsup/cygwin/regex/cname.h winsup/cygwin/regex/engine.c winsup/cygwin/regex/regcomp.c winsup/cygwin/regex/regerror.c winsup/cygwin/regex/regex.3 winsup/cygwin/regex/regex.7 winsup/cygwin/regex/regex2.h winsup/cygwin/regex/regexec.c winsup/cygwin/regex/regfree.c winsup/cygwin/regex/utils.h winsup/cygwin/registry.cc winsup/cygwin/registry.h winsup/cygwin/resource.cc winsup/cygwin/scandir.cc winsup/cygwin/sched.cc winsup/cygwin/sec_acl.cc winsup/cygwin/sec_auth.cc winsup/cygwin/sec_helper.cc winsup/cygwin/security.cc winsup/cygwin/security.h winsup/cygwin/security.sgml winsup/cygwin/select.cc winsup/cygwin/select.h winsup/cygwin/sem.cc winsup/cygwin/setlsapwd.cc winsup/cygwin/shared.cc winsup/cygwin/shared_info.h winsup/cygwin/shm.cc winsup/cygwin/signal.cc winsup/cygwin/sigproc.cc winsup/cygwin/sigproc.h winsup/cygwin/smallprint.cc winsup/cygwin/sortdin winsup/cygwin/spawn.cc winsup/cygwin/speclib winsup/cygwin/stackdump.sgml winsup/cygwin/strace.cc winsup/cygwin/strfuncs.cc winsup/cygwin/string.h winsup/cygwin/strsep.cc winsup/cygwin/strsig.cc winsup/cygwin/sync.cc winsup/cygwin/sync.h winsup/cygwin/syscalls.cc winsup/cygwin/sysconf.cc winsup/cygwin/syslog.cc winsup/cygwin/termios.cc winsup/cygwin/textmode.c winsup/cygwin/textreadmode.c winsup/cygwin/thread.cc winsup/cygwin/thread.h winsup/cygwin/timer.cc winsup/cygwin/times.cc winsup/cygwin/tls_pbuf.cc winsup/cygwin/tls_pbuf.h winsup/cygwin/tlsoffsets.h winsup/cygwin/tty.cc winsup/cygwin/tty.h winsup/cygwin/tz_posixrules.h winsup/cygwin/uinfo.cc winsup/cygwin/uname.cc winsup/cygwin/wait.cc winsup/cygwin/wchar.h winsup/cygwin/winbase.h winsup/cygwin/wincap.cc winsup/cygwin/wincap.h winsup/cygwin/window.cc winsup/cygwin/winf.cc winsup/cygwin/winf.h winsup/cygwin/wininfo.h winsup/cygwin/winsup.h winsup/cygwin/winver.rc winsup/doc/ChangeLog winsup/doc/Makefile.in winsup/doc/README winsup/doc/aclocal.m4 winsup/doc/configure winsup/doc/configure.in winsup/doc/cygserver.sgml winsup/doc/cygwin-api.in.sgml winsup/doc/cygwin-ug-net.in.sgml winsup/doc/cygwin-ug.in.sgml winsup/doc/cygwin.dsl winsup/doc/cygwinenv.sgml winsup/doc/dll.sgml winsup/doc/doctool.c winsup/doc/doctool.txt winsup/doc/effectively.sgml winsup/doc/faq-api.xml winsup/doc/faq-programming.xml winsup/doc/faq-resources.xml winsup/doc/faq-sections.xml winsup/doc/faq-setup.xml winsup/doc/faq-using.xml winsup/doc/faq-what.xml winsup/doc/faq.xml winsup/doc/fhandler-tut.txt winsup/doc/filemodes.sgml winsup/doc/gcc.sgml winsup/doc/gdb.sgml winsup/doc/legal.sgml winsup/doc/new-features.sgml winsup/doc/ntsec.sgml winsup/doc/overview.sgml winsup/doc/overview2.sgml winsup/doc/pathnames.sgml winsup/doc/programming.sgml winsup/doc/setup-net.sgml winsup/doc/setup.sgml winsup/doc/setup2.sgml winsup/doc/textbinary.sgml winsup/doc/using.sgml winsup/doc/windres.sgml winsup/lsaauth/ChangeLog winsup/lsaauth/Makefile.in winsup/lsaauth/aclocal.m4 winsup/lsaauth/configure winsup/lsaauth/configure.in winsup/lsaauth/cyglsa-config winsup/lsaauth/cyglsa.c winsup/lsaauth/cyglsa.din winsup/lsaauth/cyglsa64.dll winsup/lsaauth/make-64bit-version-with-visual-c.bat winsup/lsaauth/mslsa.def winsup/mingw/CONTRIBUTORS winsup/mingw/CRT_fp10.c winsup/mingw/CRT_fp8.c winsup/mingw/CRT_noglob.c winsup/mingw/CRTfmode.c winsup/mingw/CRTglob.c winsup/mingw/CRTinit.c winsup/mingw/ChangeLog winsup/mingw/DISCLAIMER winsup/mingw/Makefile.in winsup/mingw/README winsup/mingw/TODO winsup/mingw/aclocal.m4 winsup/mingw/binmode.c winsup/mingw/config.guess winsup/mingw/config.sub winsup/mingw/configure winsup/mingw/configure.in winsup/mingw/cpu_features.c winsup/mingw/cpu_features.h winsup/mingw/crt1.c winsup/mingw/crtdll.def winsup/mingw/crtmt.c winsup/mingw/crtst.c winsup/mingw/dllcrt1.c winsup/mingw/dllmain.c winsup/mingw/gccmain.c winsup/mingw/include/_mingw.h winsup/mingw/include/assert.h winsup/mingw/include/complex.h winsup/mingw/include/conio.h winsup/mingw/include/ctype.h winsup/mingw/include/dir.h winsup/mingw/include/direct.h winsup/mingw/include/dirent.h winsup/mingw/include/dos.h winsup/mingw/include/errno.h winsup/mingw/include/excpt.h winsup/mingw/include/fcntl.h winsup/mingw/include/fenv.h winsup/mingw/include/float.h winsup/mingw/include/getopt.h winsup/mingw/include/inttypes.h winsup/mingw/include/io.h winsup/mingw/include/libgen.h winsup/mingw/include/limits.h winsup/mingw/include/locale.h winsup/mingw/include/malloc.h winsup/mingw/include/math.h winsup/mingw/include/mbctype.h winsup/mingw/include/mbstring.h winsup/mingw/include/mem.h winsup/mingw/include/memory.h winsup/mingw/include/process.h winsup/mingw/include/search.h winsup/mingw/include/setjmp.h winsup/mingw/include/share.h winsup/mingw/include/signal.h winsup/mingw/include/stdint.h winsup/mingw/include/stdio.h winsup/mingw/include/stdlib.h winsup/mingw/include/string.h winsup/mingw/include/strings.h winsup/mingw/include/sys/fcntl.h winsup/mingw/include/sys/file.h winsup/mingw/include/sys/locking.h winsup/mingw/include/sys/param.h winsup/mingw/include/sys/stat.h winsup/mingw/include/sys/time.h winsup/mingw/include/sys/timeb.h winsup/mingw/include/sys/types.h winsup/mingw/include/sys/unistd.h winsup/mingw/include/sys/utime.h winsup/mingw/include/tchar.h winsup/mingw/include/time.h winsup/mingw/include/unistd.h winsup/mingw/include/utime.h winsup/mingw/include/values.h winsup/mingw/include/varargs.h winsup/mingw/include/wchar.h winsup/mingw/include/wctype.h winsup/mingw/init.c winsup/mingw/install-sh winsup/mingw/isascii.c winsup/mingw/iscsym.c winsup/mingw/iscsymf.c winsup/mingw/jamfile winsup/mingw/main.c winsup/mingw/man/dirname.man winsup/mingw/mingwex/Makefile.in winsup/mingw/mingwex/_Exit.c winsup/mingw/mingwex/atoll.c winsup/mingw/mingwex/basename.c winsup/mingw/mingwex/btowc.c winsup/mingw/mingwex/complex/cabs.c winsup/mingw/mingwex/complex/cabsf.c winsup/mingw/mingwex/complex/cabsl.c winsup/mingw/mingwex/complex/cacos.c winsup/mingw/mingwex/complex/cacosf.c winsup/mingw/mingwex/complex/cacosh.c winsup/mingw/mingwex/complex/cacoshf.c winsup/mingw/mingwex/complex/cacoshl.c winsup/mingw/mingwex/complex/cacosl.c winsup/mingw/mingwex/complex/carg.c winsup/mingw/mingwex/complex/cargf.c winsup/mingw/mingwex/complex/cargl.c winsup/mingw/mingwex/complex/casin.c winsup/mingw/mingwex/complex/casinf.c winsup/mingw/mingwex/complex/casinh.c winsup/mingw/mingwex/complex/casinhf.c winsup/mingw/mingwex/complex/casinhl.c winsup/mingw/mingwex/complex/casinl.c winsup/mingw/mingwex/complex/catan.c winsup/mingw/mingwex/complex/catanf.c winsup/mingw/mingwex/complex/catanh.c winsup/mingw/mingwex/complex/catanhf.c winsup/mingw/mingwex/complex/catanhl.c winsup/mingw/mingwex/complex/catanl.c winsup/mingw/mingwex/complex/ccos.c winsup/mingw/mingwex/complex/ccosf.c winsup/mingw/mingwex/complex/ccosh.c winsup/mingw/mingwex/complex/ccoshf.c winsup/mingw/mingwex/complex/ccoshl.c winsup/mingw/mingwex/complex/ccosl.c winsup/mingw/mingwex/complex/cexp.c winsup/mingw/mingwex/complex/cexpf.c winsup/mingw/mingwex/complex/cexpl.c winsup/mingw/mingwex/complex/cimag.c winsup/mingw/mingwex/complex/cimagf.c winsup/mingw/mingwex/complex/cimagl.c winsup/mingw/mingwex/complex/clog.c winsup/mingw/mingwex/complex/clogf.c winsup/mingw/mingwex/complex/clogl.c winsup/mingw/mingwex/complex/cpow.c winsup/mingw/mingwex/complex/cpowf.c winsup/mingw/mingwex/complex/cpowl.c winsup/mingw/mingwex/complex/cproj.c winsup/mingw/mingwex/complex/cprojf.c winsup/mingw/mingwex/complex/cprojl.c winsup/mingw/mingwex/complex/creal.c winsup/mingw/mingwex/complex/crealf.c winsup/mingw/mingwex/complex/creall.c winsup/mingw/mingwex/complex/csin.c winsup/mingw/mingwex/complex/csinf.c winsup/mingw/mingwex/complex/csinh.c winsup/mingw/mingwex/complex/csinhf.c winsup/mingw/mingwex/complex/csinhl.c winsup/mingw/mingwex/complex/csinl.c winsup/mingw/mingwex/complex/csqrt.c winsup/mingw/mingwex/complex/csqrtf.c winsup/mingw/mingwex/complex/csqrtl.c winsup/mingw/mingwex/complex/ctan.c winsup/mingw/mingwex/complex/ctanf.c winsup/mingw/mingwex/complex/ctanh.c winsup/mingw/mingwex/complex/ctanhf.c winsup/mingw/mingwex/complex/ctanhl.c winsup/mingw/mingwex/complex/ctanl.c winsup/mingw/mingwex/dirent.c winsup/mingw/mingwex/dirname.c winsup/mingw/mingwex/feclearexcept.c winsup/mingw/mingwex/fegetenv.c winsup/mingw/mingwex/fegetexceptflag.c winsup/mingw/mingwex/fegetround.c winsup/mingw/mingwex/feholdexcept.c winsup/mingw/mingwex/feraiseexcept.c winsup/mingw/mingwex/fesetenv.c winsup/mingw/mingwex/fesetexceptflag.c winsup/mingw/mingwex/fesetround.c winsup/mingw/mingwex/fetestexcept.c winsup/mingw/mingwex/feupdateenv.c winsup/mingw/mingwex/ftruncate.c winsup/mingw/mingwex/fwide.c winsup/mingw/mingwex/gdtoa/README winsup/mingw/mingwex/gdtoa/README.mingw winsup/mingw/mingwex/gdtoa/arithchk.c winsup/mingw/mingwex/gdtoa/dmisc.c winsup/mingw/mingwex/gdtoa/dtoa.c winsup/mingw/mingwex/gdtoa/g__fmt.c winsup/mingw/mingwex/gdtoa/g_dfmt.c winsup/mingw/mingwex/gdtoa/g_ffmt.c winsup/mingw/mingwex/gdtoa/g_xfmt.c winsup/mingw/mingwex/gdtoa/gd_arith.h winsup/mingw/mingwex/gdtoa/gd_qnan.h winsup/mingw/mingwex/gdtoa/gdtoa.c winsup/mingw/mingwex/gdtoa/gdtoa.h winsup/mingw/mingwex/gdtoa/gdtoa_fltrnds.h winsup/mingw/mingwex/gdtoa/gdtoaimp.h winsup/mingw/mingwex/gdtoa/gethex.c winsup/mingw/mingwex/gdtoa/gmisc.c winsup/mingw/mingwex/gdtoa/hd_init.c winsup/mingw/mingwex/gdtoa/hexnan.c winsup/mingw/mingwex/gdtoa/misc.c winsup/mingw/mingwex/gdtoa/qnan.c winsup/mingw/mingwex/gdtoa/smisc.c winsup/mingw/mingwex/gdtoa/strtodg.c winsup/mingw/mingwex/gdtoa/strtodnrp.c winsup/mingw/mingwex/gdtoa/strtof.c winsup/mingw/mingwex/gdtoa/strtopx.c winsup/mingw/mingwex/gdtoa/sum.c winsup/mingw/mingwex/gdtoa/ulp.c winsup/mingw/mingwex/getopt.c winsup/mingw/mingwex/gettimeofday.c winsup/mingw/mingwex/imaxabs.c winsup/mingw/mingwex/imaxdiv.c winsup/mingw/mingwex/isblank.c winsup/mingw/mingwex/iswblank.c winsup/mingw/mingwex/lltoa.c winsup/mingw/mingwex/lltow.c winsup/mingw/mingwex/math/acosf.c winsup/mingw/mingwex/math/acosh.c winsup/mingw/mingwex/math/acoshf.c winsup/mingw/mingwex/math/acoshl.c winsup/mingw/mingwex/math/acosl.c winsup/mingw/mingwex/math/asinf.c winsup/mingw/mingwex/math/asinh.c winsup/mingw/mingwex/math/asinhf.c winsup/mingw/mingwex/math/asinhl.c winsup/mingw/mingwex/math/asinl.c winsup/mingw/mingwex/math/atan2f.c winsup/mingw/mingwex/math/atan2l.c winsup/mingw/mingwex/math/atanf.c winsup/mingw/mingwex/math/atanh.c winsup/mingw/mingwex/math/atanhf.c winsup/mingw/mingwex/math/atanhl.c winsup/mingw/mingwex/math/atanl.c winsup/mingw/mingwex/math/cbrt.c winsup/mingw/mingwex/math/cbrtf.c winsup/mingw/mingwex/math/cbrtl.c winsup/mingw/mingwex/math/ceilf.S winsup/mingw/mingwex/math/ceill.S winsup/mingw/mingwex/math/cephes_mconf.h winsup/mingw/mingwex/math/copysign.S winsup/mingw/mingwex/math/copysignf.S winsup/mingw/mingwex/math/copysignl.S winsup/mingw/mingwex/math/cosf.S winsup/mingw/mingwex/math/coshf.c winsup/mingw/mingwex/math/coshl.c winsup/mingw/mingwex/math/cosl.S winsup/mingw/mingwex/math/erfl.c winsup/mingw/mingwex/math/exp2.S winsup/mingw/mingwex/math/exp2f.S winsup/mingw/mingwex/math/exp2l.S winsup/mingw/mingwex/math/expf.c winsup/mingw/mingwex/math/expl.c winsup/mingw/mingwex/math/expm1.c winsup/mingw/mingwex/math/expm1f.c winsup/mingw/mingwex/math/expm1l.c winsup/mingw/mingwex/math/fabs.c winsup/mingw/mingwex/math/fabsf.c winsup/mingw/mingwex/math/fabsl.c winsup/mingw/mingwex/math/fastmath.h winsup/mingw/mingwex/math/fdim.c winsup/mingw/mingwex/math/fdimf.c winsup/mingw/mingwex/math/fdiml.c winsup/mingw/mingwex/math/floorf.S winsup/mingw/mingwex/math/floorl.S winsup/mingw/mingwex/math/fma.S winsup/mingw/mingwex/math/fmaf.S winsup/mingw/mingwex/math/fmal.c winsup/mingw/mingwex/math/fmax.c winsup/mingw/mingwex/math/fmaxf.c winsup/mingw/mingwex/math/fmaxl.c winsup/mingw/mingwex/math/fmin.c winsup/mingw/mingwex/math/fminf.c winsup/mingw/mingwex/math/fminl.c winsup/mingw/mingwex/math/fmodf.c winsup/mingw/mingwex/math/fmodl.c winsup/mingw/mingwex/math/fp_consts.c winsup/mingw/mingwex/math/fp_consts.h winsup/mingw/mingwex/math/fp_constsf.c winsup/mingw/mingwex/math/fp_constsl.c winsup/mingw/mingwex/math/fpclassify.c winsup/mingw/mingwex/math/fpclassifyf.c winsup/mingw/mingwex/math/fpclassifyl.c winsup/mingw/mingwex/math/frexpf.c winsup/mingw/mingwex/math/frexpl.S winsup/mingw/mingwex/math/fucom.c winsup/mingw/mingwex/math/hypotf.c winsup/mingw/mingwex/math/hypotl.c winsup/mingw/mingwex/math/ilogb.S winsup/mingw/mingwex/math/ilogbf.S winsup/mingw/mingwex/math/ilogbl.S winsup/mingw/mingwex/math/isnan.c winsup/mingw/mingwex/math/isnanf.c winsup/mingw/mingwex/math/isnanl.c winsup/mingw/mingwex/math/ldexpf.c winsup/mingw/mingwex/math/ldexpl.c winsup/mingw/mingwex/math/lgamma.c winsup/mingw/mingwex/math/lgammaf.c winsup/mingw/mingwex/math/lgammal.c winsup/mingw/mingwex/math/llrint.c winsup/mingw/mingwex/math/llrintf.c winsup/mingw/mingwex/math/llrintl.c winsup/mingw/mingwex/math/log10f.S winsup/mingw/mingwex/math/log10l.S winsup/mingw/mingwex/math/log1p.S winsup/mingw/mingwex/math/log1pf.S winsup/mingw/mingwex/math/log1pl.S winsup/mingw/mingwex/math/log2.S winsup/mingw/mingwex/math/log2f.S winsup/mingw/mingwex/math/log2l.S winsup/mingw/mingwex/math/logb.c winsup/mingw/mingwex/math/logbf.c winsup/mingw/mingwex/math/logbl.c winsup/mingw/mingwex/math/logf.S winsup/mingw/mingwex/math/logl.S winsup/mingw/mingwex/math/lrint.c winsup/mingw/mingwex/math/lrintf.c winsup/mingw/mingwex/math/lrintl.c winsup/mingw/mingwex/math/lround_generic.c winsup/mingw/mingwex/math/modff.c winsup/mingw/mingwex/math/modfl.c winsup/mingw/mingwex/math/nearbyint.S winsup/mingw/mingwex/math/nearbyintf.S winsup/mingw/mingwex/math/nearbyintl.S winsup/mingw/mingwex/math/nextafterf.c winsup/mingw/mingwex/math/nextafterl.c winsup/mingw/mingwex/math/nexttoward.c winsup/mingw/mingwex/math/nexttowardf.c winsup/mingw/mingwex/math/pow.c winsup/mingw/mingwex/math/powf.c winsup/mingw/mingwex/math/powi.c winsup/mingw/mingwex/math/powif.c winsup/mingw/mingwex/math/powil.c winsup/mingw/mingwex/math/powl.c winsup/mingw/mingwex/math/remainder.S winsup/mingw/mingwex/math/remainderf.S winsup/mingw/mingwex/math/remainderl.S winsup/mingw/mingwex/math/remquo.S winsup/mingw/mingwex/math/remquof.S winsup/mingw/mingwex/math/remquol.S winsup/mingw/mingwex/math/rint.c winsup/mingw/mingwex/math/rintf.c winsup/mingw/mingwex/math/rintl.c winsup/mingw/mingwex/math/round_generic.c winsup/mingw/mingwex/math/round_internal.h winsup/mingw/mingwex/math/s_erf.c winsup/mingw/mingwex/math/scalbn.S winsup/mingw/mingwex/math/scalbnf.S winsup/mingw/mingwex/math/scalbnl.S winsup/mingw/mingwex/math/sf_erf.c winsup/mingw/mingwex/math/signbit.c winsup/mingw/mingwex/math/signbitf.c winsup/mingw/mingwex/math/signbitl.c winsup/mingw/mingwex/math/sinf.S winsup/mingw/mingwex/math/sinhf.c winsup/mingw/mingwex/math/sinhl.c winsup/mingw/mingwex/math/sinl.S winsup/mingw/mingwex/math/sqrtf.c winsup/mingw/mingwex/math/sqrtl.c winsup/mingw/mingwex/math/tanf.S winsup/mingw/mingwex/math/tanhf.c winsup/mingw/mingwex/math/tanhl.c winsup/mingw/mingwex/math/tanl.S winsup/mingw/mingwex/math/tgamma.c winsup/mingw/mingwex/math/tgammaf.c winsup/mingw/mingwex/math/tgammal.c winsup/mingw/mingwex/math/trunc.c winsup/mingw/mingwex/math/truncf.c winsup/mingw/mingwex/math/truncl.c winsup/mingw/mingwex/mb_wc_common.h winsup/mingw/mingwex/mbrtowc.c winsup/mingw/mingwex/mbsinit.c winsup/mingw/mingwex/mingw-aligned-malloc.c winsup/mingw/mingwex/mingw-fseek.c winsup/mingw/mingwex/sitest.c winsup/mingw/mingwex/stdio/fopen64.c winsup/mingw/mingwex/stdio/fprintf.c winsup/mingw/mingwex/stdio/fseeko64.c winsup/mingw/mingwex/stdio/ftello64.c winsup/mingw/mingwex/stdio/lseek64.c winsup/mingw/mingwex/stdio/pformat.c winsup/mingw/mingwex/stdio/pformat.h winsup/mingw/mingwex/stdio/printf.c winsup/mingw/mingwex/stdio/snprintf.c winsup/mingw/mingwex/stdio/snwprintf.c winsup/mingw/mingwex/stdio/sprintf.c winsup/mingw/mingwex/stdio/vfprintf.c winsup/mingw/mingwex/stdio/vfscanf.c winsup/mingw/mingwex/stdio/vfwscanf.c winsup/mingw/mingwex/stdio/vprintf.c winsup/mingw/mingwex/stdio/vscanf.c winsup/mingw/mingwex/stdio/vsnprintf.c winsup/mingw/mingwex/stdio/vsnwprintf.c winsup/mingw/mingwex/stdio/vsprintf.c winsup/mingw/mingwex/stdio/vsscanf.c winsup/mingw/mingwex/stdio/vswscanf.c winsup/mingw/mingwex/stdio/vwscanf.c winsup/mingw/mingwex/strtoimax.c winsup/mingw/mingwex/strtoumax.c winsup/mingw/mingwex/tdelete.c winsup/mingw/mingwex/testwmem.c winsup/mingw/mingwex/tfind.c winsup/mingw/mingwex/tsearch.c winsup/mingw/mingwex/tst-aligned-malloc.c winsup/mingw/mingwex/twalk.c winsup/mingw/mingwex/ulltoa.c winsup/mingw/mingwex/ulltow.c winsup/mingw/mingwex/usleep.c winsup/mingw/mingwex/wcrtomb.c winsup/mingw/mingwex/wcstof.c winsup/mingw/mingwex/wcstoimax.c winsup/mingw/mingwex/wcstold.c winsup/mingw/mingwex/wcstoumax.c winsup/mingw/mingwex/wctob.c winsup/mingw/mingwex/wctrans.c winsup/mingw/mingwex/wctype.c winsup/mingw/mingwex/wdirent.c winsup/mingw/mingwex/wmemchr.c winsup/mingw/mingwex/wmemcmp.c winsup/mingw/mingwex/wmemcpy.c winsup/mingw/mingwex/wmemmove.c winsup/mingw/mingwex/wmemset.c winsup/mingw/mingwex/wtoll.c winsup/mingw/mkinstalldirs winsup/mingw/moldname.def.in winsup/mingw/msvcrt.def.in winsup/mingw/mthr.c winsup/mingw/mthr_init.c winsup/mingw/ofmt_stub.s winsup/mingw/profile/COPYING winsup/mingw/profile/CYGWIN_LICENSE winsup/mingw/profile/Makefile.in winsup/mingw/profile/gcrt0.c winsup/mingw/profile/gmon.c winsup/mingw/profile/gmon.h winsup/mingw/profile/mcount.c winsup/mingw/profile/profil.c winsup/mingw/profile/profil.h winsup/mingw/profile/profile.h winsup/mingw/pseudo-reloc-list.c winsup/mingw/pseudo-reloc.c winsup/mingw/readme.txt winsup/mingw/samples/dirent/jamfile winsup/mingw/samples/dirent/test.c winsup/mingw/samples/dirent/wtest.c winsup/mingw/samples/dlltest/dll.c winsup/mingw/samples/dlltest/dll.def winsup/mingw/samples/dlltest/dll.h winsup/mingw/samples/dlltest/exe.c winsup/mingw/samples/dlltest/exe.exp winsup/mingw/samples/dlltest/expexe.c winsup/mingw/samples/dlltest/expexe.def winsup/mingw/samples/dlltest/jamfile winsup/mingw/samples/dlltest/loaddll.c winsup/mingw/samples/dlltest/loadexe.c winsup/mingw/samples/dlltest/readme.txt winsup/mingw/samples/dlltest/silly.cpp winsup/mingw/samples/dlltest/silly.def winsup/mingw/samples/dlltest/silly.exp winsup/mingw/samples/dlltest/silly.h winsup/mingw/samples/dlltest/sillydll.cpp winsup/mingw/samples/filehand/filehand.c winsup/mingw/samples/filehand/jamfile winsup/mingw/samples/filehand/junk.txt winsup/mingw/samples/fixargv/fixargv.c winsup/mingw/samples/fixargv/fixargv.h winsup/mingw/samples/fixargv/readme.txt winsup/mingw/samples/fmode/all.c winsup/mingw/samples/fmode/jamfile winsup/mingw/samples/fmode/readme.txt winsup/mingw/samples/fmode/test.c winsup/mingw/samples/fmode/test2.c winsup/mingw/samples/globbing/glob.c winsup/mingw/samples/globbing/jamfile winsup/mingw/samples/globbing/noglob.c winsup/mingw/samples/globbing/readme.txt winsup/mingw/samples/print/jamfile winsup/mingw/samples/print/prntest.c winsup/mingw/samples/seh/eh3.c winsup/mingw/samples/seh/exutil.c winsup/mingw/samples/seh/exutil.def winsup/mingw/samples/seh/exutil.h winsup/mingw/samples/seh/jamfile winsup/mingw/samples/seh/sehfix.c winsup/mingw/samples/seh/sehsub.c winsup/mingw/samples/seh/sehtest.c winsup/mingw/samples/simpledll/dll.c winsup/mingw/samples/simpledll/dll.cpp winsup/mingw/samples/simpledll/dll.def winsup/mingw/samples/simpledll/exe.c winsup/mingw/samples/simpledll/jamfile winsup/mingw/samples/simpledll/makedll.bat winsup/mingw/samples/test/jamfile winsup/mingw/samples/test/test.c winsup/mingw/samples/wintest/jamfile winsup/mingw/samples/wintest/test.c winsup/mingw/strcasecmp.c winsup/mingw/strncasecmp.c winsup/mingw/test_headers.c winsup/mingw/tlsmcrt.c winsup/mingw/tlsmthread.c winsup/mingw/tlssup.c winsup/mingw/tlsthrd.c winsup/mingw/toascii.c winsup/mingw/txtmode.c winsup/mingw/wcscmpi.c winsup/testsuite/ChangeLog winsup/testsuite/Makefile.in winsup/testsuite/README winsup/testsuite/aclocal.m4 winsup/testsuite/config/default.exp winsup/testsuite/configure winsup/testsuite/configure.in winsup/testsuite/cygrun.c winsup/testsuite/libltp/include/dataascii.h winsup/testsuite/libltp/include/databin.h winsup/testsuite/libltp/include/file_lock.h winsup/testsuite/libltp/include/forker.h winsup/testsuite/libltp/include/open_flags.h winsup/testsuite/libltp/include/pattern.h winsup/testsuite/libltp/include/random_range.h winsup/testsuite/libltp/include/rmobj.h winsup/testsuite/libltp/include/search_path.h winsup/testsuite/libltp/include/str_to_bytes.h winsup/testsuite/libltp/include/string_to_tokens.h winsup/testsuite/libltp/include/test.h winsup/testsuite/libltp/include/tlibio.h winsup/testsuite/libltp/include/usctest.h winsup/testsuite/libltp/include/write_log.h winsup/testsuite/libltp/lib/dataascii.c winsup/testsuite/libltp/lib/databin.c winsup/testsuite/libltp/lib/datapid.c winsup/testsuite/libltp/lib/forker.c winsup/testsuite/libltp/lib/get_high_address.c winsup/testsuite/libltp/lib/libtestsuite.c winsup/testsuite/libltp/lib/open_flags.c winsup/testsuite/libltp/lib/parse_opts.c winsup/testsuite/libltp/lib/pattern.c winsup/testsuite/libltp/lib/rmobj.c winsup/testsuite/libltp/lib/search_path.c winsup/testsuite/libltp/lib/str_to_bytes.c winsup/testsuite/libltp/lib/string_to_tokens.c winsup/testsuite/libltp/lib/tst_res.c winsup/testsuite/libltp/lib/tst_sig.c winsup/testsuite/libltp/lib/tst_tmpdir.c winsup/testsuite/libltp/lib/write_log.c winsup/testsuite/winsup.api/checksignal.c winsup/testsuite/winsup.api/crlf.c winsup/testsuite/winsup.api/cygload.cc winsup/testsuite/winsup.api/cygload.exp winsup/testsuite/winsup.api/cygload.h winsup/testsuite/winsup.api/devdsp.c winsup/testsuite/winsup.api/devdsp_okay.h winsup/testsuite/winsup.api/devzero.c winsup/testsuite/winsup.api/iospeed.c winsup/testsuite/winsup.api/known_bugs.tcl winsup/testsuite/winsup.api/ltp/access01.c winsup/testsuite/winsup.api/ltp/access03.c winsup/testsuite/winsup.api/ltp/access04.c winsup/testsuite/winsup.api/ltp/access05.c winsup/testsuite/winsup.api/ltp/alarm01.c winsup/testsuite/winsup.api/ltp/alarm02.c winsup/testsuite/winsup.api/ltp/alarm03.c winsup/testsuite/winsup.api/ltp/alarm07.c winsup/testsuite/winsup.api/ltp/asyncio02.c winsup/testsuite/winsup.api/ltp/chdir02.c winsup/testsuite/winsup.api/ltp/chdir04.c winsup/testsuite/winsup.api/ltp/chmod01.c winsup/testsuite/winsup.api/ltp/chmod02.c winsup/testsuite/winsup.api/ltp/chown01.c winsup/testsuite/winsup.api/ltp/close01.c winsup/testsuite/winsup.api/ltp/close02.c winsup/testsuite/winsup.api/ltp/close08.c winsup/testsuite/winsup.api/ltp/creat01.c winsup/testsuite/winsup.api/ltp/creat03.c winsup/testsuite/winsup.api/ltp/creat09.c winsup/testsuite/winsup.api/ltp/dup01.c winsup/testsuite/winsup.api/ltp/dup02.c winsup/testsuite/winsup.api/ltp/dup03.c winsup/testsuite/winsup.api/ltp/dup04.c winsup/testsuite/winsup.api/ltp/dup05.c winsup/testsuite/winsup.api/ltp/execl01.c winsup/testsuite/winsup.api/ltp/execle01.c winsup/testsuite/winsup.api/ltp/execlp01.c winsup/testsuite/winsup.api/ltp/execv01.c winsup/testsuite/winsup.api/ltp/execve01.c winsup/testsuite/winsup.api/ltp/execvp01.c winsup/testsuite/winsup.api/ltp/exit01.c winsup/testsuite/winsup.api/ltp/exit02.c winsup/testsuite/winsup.api/ltp/fchdir01.c winsup/testsuite/winsup.api/ltp/fchdir02.c winsup/testsuite/winsup.api/ltp/fchmod01.c winsup/testsuite/winsup.api/ltp/fchown01.c winsup/testsuite/winsup.api/ltp/fcntl02.c winsup/testsuite/winsup.api/ltp/fcntl03.c winsup/testsuite/winsup.api/ltp/fcntl04.c winsup/testsuite/winsup.api/ltp/fcntl05.c winsup/testsuite/winsup.api/ltp/fcntl07.c winsup/testsuite/winsup.api/ltp/fcntl07B.c winsup/testsuite/winsup.api/ltp/fcntl08.c winsup/testsuite/winsup.api/ltp/fcntl09.c winsup/testsuite/winsup.api/ltp/fcntl10.c winsup/testsuite/winsup.api/ltp/fork01.c winsup/testsuite/winsup.api/ltp/fork02.c winsup/testsuite/winsup.api/ltp/fork03.c winsup/testsuite/winsup.api/ltp/fork04.c winsup/testsuite/winsup.api/ltp/fork06.c winsup/testsuite/winsup.api/ltp/fork07.c winsup/testsuite/winsup.api/ltp/fork09.c winsup/testsuite/winsup.api/ltp/fork10.c winsup/testsuite/winsup.api/ltp/fork11.c winsup/testsuite/winsup.api/ltp/fpathconf01.c winsup/testsuite/winsup.api/ltp/fstat01.c winsup/testsuite/winsup.api/ltp/fstat02.c winsup/testsuite/winsup.api/ltp/fstat03.c winsup/testsuite/winsup.api/ltp/fstat04.c winsup/testsuite/winsup.api/ltp/fsync01.c winsup/testsuite/winsup.api/ltp/ftruncate01.c winsup/testsuite/winsup.api/ltp/ftruncate02.c winsup/testsuite/winsup.api/ltp/ftruncate03.c winsup/testsuite/winsup.api/ltp/getegid01.c winsup/testsuite/winsup.api/ltp/geteuid01.c winsup/testsuite/winsup.api/ltp/getgid01.c winsup/testsuite/winsup.api/ltp/getgid02.c winsup/testsuite/winsup.api/ltp/getgid03.c winsup/testsuite/winsup.api/ltp/getgroups01.c winsup/testsuite/winsup.api/ltp/getgroups02.c winsup/testsuite/winsup.api/ltp/gethostid01.c winsup/testsuite/winsup.api/ltp/gethostname01.c winsup/testsuite/winsup.api/ltp/getpgid01.c winsup/testsuite/winsup.api/ltp/getpgid02.c winsup/testsuite/winsup.api/ltp/getpgrp01.c winsup/testsuite/winsup.api/ltp/getpid01.c winsup/testsuite/winsup.api/ltp/getpid02.c winsup/testsuite/winsup.api/ltp/getppid01.c winsup/testsuite/winsup.api/ltp/getppid02.c winsup/testsuite/winsup.api/ltp/getuid01.c winsup/testsuite/winsup.api/ltp/getuid02.c winsup/testsuite/winsup.api/ltp/getuid03.c winsup/testsuite/winsup.api/ltp/kill01.c winsup/testsuite/winsup.api/ltp/kill02.c winsup/testsuite/winsup.api/ltp/kill03.c winsup/testsuite/winsup.api/ltp/kill04.c winsup/testsuite/winsup.api/ltp/kill09.c winsup/testsuite/winsup.api/ltp/link02.c winsup/testsuite/winsup.api/ltp/link03.c winsup/testsuite/winsup.api/ltp/link04.c winsup/testsuite/winsup.api/ltp/link05.c winsup/testsuite/winsup.api/ltp/lseek01.c winsup/testsuite/winsup.api/ltp/lseek02.c winsup/testsuite/winsup.api/ltp/lseek03.c winsup/testsuite/winsup.api/ltp/lseek04.c winsup/testsuite/winsup.api/ltp/lseek05.c winsup/testsuite/winsup.api/ltp/lseek06.c winsup/testsuite/winsup.api/ltp/lseek07.c winsup/testsuite/winsup.api/ltp/lseek08.c winsup/testsuite/winsup.api/ltp/lseek09.c winsup/testsuite/winsup.api/ltp/lseek10.c winsup/testsuite/winsup.api/ltp/lstat02.c winsup/testsuite/winsup.api/ltp/mkdir01.c winsup/testsuite/winsup.api/ltp/mkdir08.c winsup/testsuite/winsup.api/ltp/mknod01.c winsup/testsuite/winsup.api/ltp/mmap001.c winsup/testsuite/winsup.api/ltp/mmap02.c winsup/testsuite/winsup.api/ltp/mmap03.c winsup/testsuite/winsup.api/ltp/mmap04.c winsup/testsuite/winsup.api/ltp/mmap05.c winsup/testsuite/winsup.api/ltp/mmap06.c winsup/testsuite/winsup.api/ltp/mmap07.c winsup/testsuite/winsup.api/ltp/mmap08.c winsup/testsuite/winsup.api/ltp/munmap01.c winsup/testsuite/winsup.api/ltp/munmap02.c winsup/testsuite/winsup.api/ltp/nice05.c winsup/testsuite/winsup.api/ltp/open02.c winsup/testsuite/winsup.api/ltp/open03.c winsup/testsuite/winsup.api/ltp/pathconf01.c winsup/testsuite/winsup.api/ltp/pause01.c winsup/testsuite/winsup.api/ltp/pipe01.c winsup/testsuite/winsup.api/ltp/pipe08.c winsup/testsuite/winsup.api/ltp/pipe09.c winsup/testsuite/winsup.api/ltp/pipe10.c winsup/testsuite/winsup.api/ltp/pipe11.c winsup/testsuite/winsup.api/ltp/poll01.c winsup/testsuite/winsup.api/ltp/read01.c winsup/testsuite/winsup.api/ltp/read04.c winsup/testsuite/winsup.api/ltp/readdir01.c winsup/testsuite/winsup.api/ltp/readlink01.c winsup/testsuite/winsup.api/ltp/readlink02.c winsup/testsuite/winsup.api/ltp/readlink03.c winsup/testsuite/winsup.api/ltp/rename01.c winsup/testsuite/winsup.api/ltp/rename02.c winsup/testsuite/winsup.api/ltp/rename08.c winsup/testsuite/winsup.api/ltp/rename10.c winsup/testsuite/winsup.api/ltp/rmdir01.c winsup/testsuite/winsup.api/ltp/rmdir04.c winsup/testsuite/winsup.api/ltp/rmdir05.c winsup/testsuite/winsup.api/ltp/sbrk01.c winsup/testsuite/winsup.api/ltp/select01.c winsup/testsuite/winsup.api/ltp/select02.c winsup/testsuite/winsup.api/ltp/select03.c winsup/testsuite/winsup.api/ltp/setgid01.c winsup/testsuite/winsup.api/ltp/setgroups01.c winsup/testsuite/winsup.api/ltp/setpgid01.c winsup/testsuite/winsup.api/ltp/setregid01.c winsup/testsuite/winsup.api/ltp/setreuid01.c winsup/testsuite/winsup.api/ltp/setuid01.c winsup/testsuite/winsup.api/ltp/setuid02.c winsup/testsuite/winsup.api/ltp/signal03.c winsup/testsuite/winsup.api/ltp/stat01.c winsup/testsuite/winsup.api/ltp/stat02.c winsup/testsuite/winsup.api/ltp/stat03.c winsup/testsuite/winsup.api/ltp/stat05.c winsup/testsuite/winsup.api/ltp/stat06.c winsup/testsuite/winsup.api/ltp/symlink01.c winsup/testsuite/winsup.api/ltp/symlink02.c winsup/testsuite/winsup.api/ltp/symlink03.c winsup/testsuite/winsup.api/ltp/symlink04.c winsup/testsuite/winsup.api/ltp/symlink05.c winsup/testsuite/winsup.api/ltp/sync01.c winsup/testsuite/winsup.api/ltp/sync02.c winsup/testsuite/winsup.api/ltp/time01.c winsup/testsuite/winsup.api/ltp/time02.c winsup/testsuite/winsup.api/ltp/times01.c winsup/testsuite/winsup.api/ltp/times02.c winsup/testsuite/winsup.api/ltp/times03.c winsup/testsuite/winsup.api/ltp/truncate01.c winsup/testsuite/winsup.api/ltp/truncate02.c winsup/testsuite/winsup.api/ltp/ulimit01.c winsup/testsuite/winsup.api/ltp/umask01.c winsup/testsuite/winsup.api/ltp/umask02.c winsup/testsuite/winsup.api/ltp/umask03.c winsup/testsuite/winsup.api/ltp/uname01.c winsup/testsuite/winsup.api/ltp/unlink05.c winsup/testsuite/winsup.api/ltp/unlink06.c winsup/testsuite/winsup.api/ltp/unlink07.c winsup/testsuite/winsup.api/ltp/unlink08.c winsup/testsuite/winsup.api/ltp/vfork01.c winsup/testsuite/winsup.api/ltp/wait02.c winsup/testsuite/winsup.api/ltp/wait401.c winsup/testsuite/winsup.api/ltp/wait402.c winsup/testsuite/winsup.api/ltp/write01.c winsup/testsuite/winsup.api/ltp/write02.c winsup/testsuite/winsup.api/ltp/write03.c winsup/testsuite/winsup.api/mmaptest01.c winsup/testsuite/winsup.api/mmaptest02.c winsup/testsuite/winsup.api/mmaptest03.c winsup/testsuite/winsup.api/mmaptest04.c winsup/testsuite/winsup.api/msgtest.c winsup/testsuite/winsup.api/nullgetcwd.c winsup/testsuite/winsup.api/pthread/cancel1.c winsup/testsuite/winsup.api/pthread/cancel10.c winsup/testsuite/winsup.api/pthread/cancel11.c winsup/testsuite/winsup.api/pthread/cancel12.c winsup/testsuite/winsup.api/pthread/cancel2.c winsup/testsuite/winsup.api/pthread/cancel3.c winsup/testsuite/winsup.api/pthread/cancel4.c winsup/testsuite/winsup.api/pthread/cancel5.c winsup/testsuite/winsup.api/pthread/cancel6.c winsup/testsuite/winsup.api/pthread/cancel7.c winsup/testsuite/winsup.api/pthread/cancel8.c winsup/testsuite/winsup.api/pthread/cancel9.c winsup/testsuite/winsup.api/pthread/cleanup2.c winsup/testsuite/winsup.api/pthread/cleanup3.c winsup/testsuite/winsup.api/pthread/condvar1.c winsup/testsuite/winsup.api/pthread/condvar2.c winsup/testsuite/winsup.api/pthread/condvar2_1.c winsup/testsuite/winsup.api/pthread/condvar3.c winsup/testsuite/winsup.api/pthread/condvar3_1.c winsup/testsuite/winsup.api/pthread/condvar3_2.c winsup/testsuite/winsup.api/pthread/condvar3_3.c winsup/testsuite/winsup.api/pthread/condvar4.c winsup/testsuite/winsup.api/pthread/condvar5.c winsup/testsuite/winsup.api/pthread/condvar6.c winsup/testsuite/winsup.api/pthread/condvar7.c winsup/testsuite/winsup.api/pthread/condvar8.c winsup/testsuite/winsup.api/pthread/condvar9.c winsup/testsuite/winsup.api/pthread/count1.c winsup/testsuite/winsup.api/pthread/create1.c winsup/testsuite/winsup.api/pthread/create2.c winsup/testsuite/winsup.api/pthread/equal1.c winsup/testsuite/winsup.api/pthread/exit1.c winsup/testsuite/winsup.api/pthread/exit2.c winsup/testsuite/winsup.api/pthread/exit3.c winsup/testsuite/winsup.api/pthread/inherit1.c winsup/testsuite/winsup.api/pthread/join0.c winsup/testsuite/winsup.api/pthread/join1.c winsup/testsuite/winsup.api/pthread/join2.c winsup/testsuite/winsup.api/pthread/mainthreadexits.c winsup/testsuite/winsup.api/pthread/mutex1.c winsup/testsuite/winsup.api/pthread/mutex1d.c winsup/testsuite/winsup.api/pthread/mutex1e.c winsup/testsuite/winsup.api/pthread/mutex1n.c winsup/testsuite/winsup.api/pthread/mutex1r.c winsup/testsuite/winsup.api/pthread/mutex2.c winsup/testsuite/winsup.api/pthread/mutex3.c winsup/testsuite/winsup.api/pthread/mutex4.c winsup/testsuite/winsup.api/pthread/mutex5.c winsup/testsuite/winsup.api/pthread/mutex6d.c winsup/testsuite/winsup.api/pthread/mutex6e.c winsup/testsuite/winsup.api/pthread/mutex6n.c winsup/testsuite/winsup.api/pthread/mutex6r.c winsup/testsuite/winsup.api/pthread/mutex7.c winsup/testsuite/winsup.api/pthread/mutex7d.c winsup/testsuite/winsup.api/pthread/mutex7e.c winsup/testsuite/winsup.api/pthread/mutex7n.c winsup/testsuite/winsup.api/pthread/mutex7r.c winsup/testsuite/winsup.api/pthread/mutex8e.c winsup/testsuite/winsup.api/pthread/mutex8n.c winsup/testsuite/winsup.api/pthread/mutex8r.c winsup/testsuite/winsup.api/pthread/once1.c winsup/testsuite/winsup.api/pthread/priority1.c winsup/testsuite/winsup.api/pthread/priority2.c winsup/testsuite/winsup.api/pthread/rwlock1.c winsup/testsuite/winsup.api/pthread/rwlock2.c winsup/testsuite/winsup.api/pthread/rwlock3.c winsup/testsuite/winsup.api/pthread/rwlock4.c winsup/testsuite/winsup.api/pthread/rwlock5.c winsup/testsuite/winsup.api/pthread/rwlock6.c winsup/testsuite/winsup.api/pthread/rwlock7.c winsup/testsuite/winsup.api/pthread/self1.c winsup/testsuite/winsup.api/pthread/self2.c winsup/testsuite/winsup.api/pthread/test.h winsup/testsuite/winsup.api/pthread/threadidafterfork.c winsup/testsuite/winsup.api/pthread/tsd1.c winsup/testsuite/winsup.api/resethand.c winsup/testsuite/winsup.api/samples/sample-fail.c winsup/testsuite/winsup.api/samples/sample-miscompile.c winsup/testsuite/winsup.api/samples/sample-pass.c winsup/testsuite/winsup.api/semtest.c winsup/testsuite/winsup.api/shmtest.c winsup/testsuite/winsup.api/sigchld.c winsup/testsuite/winsup.api/signal-into-win32-api.c winsup/testsuite/winsup.api/systemcall.c winsup/testsuite/winsup.api/user_malloc.c winsup/testsuite/winsup.api/waitpid.c winsup/testsuite/winsup.api/winsup.exp winsup/utils/COPYING.dumper winsup/utils/ChangeLog winsup/utils/ChangeLog-2000 winsup/utils/Makefile.in winsup/utils/aclocal.m4 winsup/utils/bloda.cc winsup/utils/configure winsup/utils/configure.in winsup/utils/cygcheck.cc winsup/utils/cygpath.cc winsup/utils/cygwin-console-helper.cc winsup/utils/dump_setup.cc winsup/utils/dumper.cc winsup/utils/dumper.h winsup/utils/getfacl.c winsup/utils/kill.cc winsup/utils/ldd.cc winsup/utils/ldh.cc winsup/utils/locale.cc winsup/utils/mingw winsup/utils/mkgroup.c winsup/utils/mkpasswd.c winsup/utils/module_info.cc winsup/utils/mount.cc winsup/utils/parse_pe.cc winsup/utils/passwd.c winsup/utils/path.cc winsup/utils/path.h winsup/utils/ps.cc winsup/utils/regtool.cc winsup/utils/setfacl.c winsup/utils/setmetamode.c winsup/utils/ssp.c winsup/utils/ssp.txt winsup/utils/strace.cc winsup/utils/testsuite.cc winsup/utils/testsuite.h winsup/utils/umount.cc winsup/utils/utils.sgml winsup/utils/wide_path.h winsup/w32api/CONTRIBUTIONS winsup/w32api/ChangeLog winsup/w32api/Makefile.in winsup/w32api/README.w32api winsup/w32api/TODO winsup/w32api/aclocal.m4 winsup/w32api/config.guess winsup/w32api/config.sub winsup/w32api/configure winsup/w32api/configure.in winsup/w32api/include/GL/gl.h winsup/w32api/include/GL/glext.h winsup/w32api/include/GL/glu.h winsup/w32api/include/accctrl.h winsup/w32api/include/aclapi.h winsup/w32api/include/aclui.h winsup/w32api/include/adsprop.h winsup/w32api/include/afxres.h winsup/w32api/include/amaudio.h winsup/w32api/include/amvideo.h winsup/w32api/include/audevcod.h winsup/w32api/include/aviriff.h winsup/w32api/include/aygshell.h winsup/w32api/include/basetsd.h winsup/w32api/include/basetyps.h winsup/w32api/include/bdatypes.h winsup/w32api/include/cderr.h winsup/w32api/include/cguid.h winsup/w32api/include/cmnquery.h winsup/w32api/include/comcat.h winsup/w32api/include/commctrl.h winsup/w32api/include/commdlg.h winsup/w32api/include/control.h winsup/w32api/include/cpl.h winsup/w32api/include/cplext.h winsup/w32api/include/custcntl.h winsup/w32api/include/dbt.h winsup/w32api/include/dde.h winsup/w32api/include/ddeml.h winsup/w32api/include/ddk/atm.h winsup/w32api/include/ddk/batclass.h winsup/w32api/include/ddk/cfg.h winsup/w32api/include/ddk/cfgmgr32.h winsup/w32api/include/ddk/d4drvif.h winsup/w32api/include/ddk/d4iface.h winsup/w32api/include/ddk/ddkmapi.h winsup/w32api/include/ddk/hidclass.h winsup/w32api/include/ddk/hidpi.h winsup/w32api/include/ddk/hidsdi.h winsup/w32api/include/ddk/hidusage.h winsup/w32api/include/ddk/kbdmou.h winsup/w32api/include/ddk/mcd.h winsup/w32api/include/ddk/miniport.h winsup/w32api/include/ddk/minitape.h winsup/w32api/include/ddk/mountdev.h winsup/w32api/include/ddk/mountmgr.h winsup/w32api/include/ddk/ndis.h winsup/w32api/include/ddk/ndisguid.h winsup/w32api/include/ddk/ndistapi.h winsup/w32api/include/ddk/ndiswan.h winsup/w32api/include/ddk/netevent.h winsup/w32api/include/ddk/netpnp.h winsup/w32api/include/ddk/newdev.h winsup/w32api/include/ddk/ntapi.h winsup/w32api/include/ddk/ntdd8042.h winsup/w32api/include/ddk/ntddbeep.h winsup/w32api/include/ddk/ntddcdrm.h winsup/w32api/include/ddk/ntddcdvd.h winsup/w32api/include/ddk/ntddchgr.h winsup/w32api/include/ddk/ntdddisk.h winsup/w32api/include/ddk/ntddk.h winsup/w32api/include/ddk/ntddkbd.h winsup/w32api/include/ddk/ntddmou.h winsup/w32api/include/ddk/ntddndis.h winsup/w32api/include/ddk/ntddpar.h winsup/w32api/include/ddk/ntddpcm.h winsup/w32api/include/ddk/ntddscsi.h winsup/w32api/include/ddk/ntddser.h winsup/w32api/include/ddk/ntddstor.h winsup/w32api/include/ddk/ntddtape.h winsup/w32api/include/ddk/ntddtdi.h winsup/w32api/include/ddk/ntddvdeo.h winsup/w32api/include/ddk/ntddvol.h winsup/w32api/include/ddk/ntifs.h winsup/w32api/include/ddk/ntpoapi.h winsup/w32api/include/ddk/ntstatus.h winsup/w32api/include/ddk/parallel.h winsup/w32api/include/ddk/pfhook.h winsup/w32api/include/ddk/poclass.h winsup/w32api/include/ddk/scsi.h winsup/w32api/include/ddk/scsiscan.h winsup/w32api/include/ddk/scsiwmi.h winsup/w32api/include/ddk/smbus.h winsup/w32api/include/ddk/srb.h winsup/w32api/include/ddk/storport.h winsup/w32api/include/ddk/tdi.h winsup/w32api/include/ddk/tdiinfo.h winsup/w32api/include/ddk/tdikrnl.h winsup/w32api/include/ddk/tdistat.h winsup/w32api/include/ddk/tvout.h winsup/w32api/include/ddk/upssvc.h winsup/w32api/include/ddk/usb.h winsup/w32api/include/ddk/usb100.h winsup/w32api/include/ddk/usbcamdi.h winsup/w32api/include/ddk/usbdi.h winsup/w32api/include/ddk/usbioctl.h winsup/w32api/include/ddk/usbiodef.h winsup/w32api/include/ddk/usbscan.h winsup/w32api/include/ddk/usbuser.h winsup/w32api/include/ddk/video.h winsup/w32api/include/ddk/videoagp.h winsup/w32api/include/ddk/win2k.h winsup/w32api/include/ddk/winddi.h winsup/w32api/include/ddk/winddk.h winsup/w32api/include/ddk/winnt4.h winsup/w32api/include/ddk/winxp.h winsup/w32api/include/ddk/ws2san.h winsup/w32api/include/ddk/xfilter.h winsup/w32api/include/devguid.h winsup/w32api/include/dhcpcsdk.h winsup/w32api/include/directx/d3d9.h winsup/w32api/include/directx/d3d9caps.h winsup/w32api/include/directx/d3d9types.h winsup/w32api/include/directx/dxerr8.h winsup/w32api/include/directx/dxerr9.h winsup/w32api/include/dlgs.h winsup/w32api/include/docobj.h winsup/w32api/include/dsadmin.h winsup/w32api/include/dsclient.h winsup/w32api/include/dsgetdc.h winsup/w32api/include/dshow.h winsup/w32api/include/dsquery.h winsup/w32api/include/dsrole.h winsup/w32api/include/dvdevcod.h winsup/w32api/include/dvdmedia.h winsup/w32api/include/edevdefs.h winsup/w32api/include/errorrep.h winsup/w32api/include/errors.h winsup/w32api/include/evcode.h winsup/w32api/include/exdisp.h winsup/w32api/include/exdispid.h winsup/w32api/include/fltdefs.h winsup/w32api/include/httpext.h winsup/w32api/include/icm.h winsup/w32api/include/idispids.h winsup/w32api/include/il21dec.h winsup/w32api/include/imagehlp.h winsup/w32api/include/imm.h winsup/w32api/include/initguid.h winsup/w32api/include/intshcut.h winsup/w32api/include/ipexport.h winsup/w32api/include/iphlpapi.h winsup/w32api/include/ipifcons.h winsup/w32api/include/ipinfoid.h winsup/w32api/include/iprtrmib.h winsup/w32api/include/iptypes.h winsup/w32api/include/ipxconst.h winsup/w32api/include/ipxrtdef.h winsup/w32api/include/ipxtfflt.h winsup/w32api/include/isguids.h winsup/w32api/include/ks.h winsup/w32api/include/ksmedia.h winsup/w32api/include/largeint.h winsup/w32api/include/lm.h winsup/w32api/include/lmaccess.h winsup/w32api/include/lmalert.h winsup/w32api/include/lmapibuf.h winsup/w32api/include/lmat.h winsup/w32api/include/lmaudit.h winsup/w32api/include/lmbrowsr.h winsup/w32api/include/lmchdev.h winsup/w32api/include/lmconfig.h winsup/w32api/include/lmcons.h winsup/w32api/include/lmerr.h winsup/w32api/include/lmerrlog.h winsup/w32api/include/lmmsg.h winsup/w32api/include/lmremutl.h winsup/w32api/include/lmrepl.h winsup/w32api/include/lmserver.h winsup/w32api/include/lmshare.h winsup/w32api/include/lmsname.h winsup/w32api/include/lmstats.h winsup/w32api/include/lmsvc.h winsup/w32api/include/lmuse.h winsup/w32api/include/lmuseflg.h winsup/w32api/include/lmwksta.h winsup/w32api/include/lzexpand.h winsup/w32api/include/mapi.h winsup/w32api/include/mciavi.h winsup/w32api/include/mcx.h winsup/w32api/include/mgm.h winsup/w32api/include/mgmtapi.h winsup/w32api/include/mlang.h winsup/w32api/include/mmreg.h winsup/w32api/include/mmsystem.h winsup/w32api/include/mpegtype.h winsup/w32api/include/mprapi.h winsup/w32api/include/mq.h winsup/w32api/include/msacm.h winsup/w32api/include/mshtml.h winsup/w32api/include/mswsock.h winsup/w32api/include/nb30.h winsup/w32api/include/nddeapi.h winsup/w32api/include/nspapi.h winsup/w32api/include/ntdef.h winsup/w32api/include/ntdll.h winsup/w32api/include/ntdsapi.h winsup/w32api/include/ntdsbcli.h winsup/w32api/include/ntldap.h winsup/w32api/include/ntsecapi.h winsup/w32api/include/ntsecpkg.h winsup/w32api/include/oaidl.h winsup/w32api/include/objbase.h winsup/w32api/include/objfwd.h winsup/w32api/include/objidl.h winsup/w32api/include/objsafe.h winsup/w32api/include/objsel.h winsup/w32api/include/ocidl.h winsup/w32api/include/odbcinst.h winsup/w32api/include/ole.h winsup/w32api/include/ole2.h winsup/w32api/include/ole2ver.h winsup/w32api/include/oleacc.h winsup/w32api/include/oleauto.h winsup/w32api/include/olectl.h winsup/w32api/include/olectlid.h winsup/w32api/include/oledlg.h winsup/w32api/include/oleidl.h winsup/w32api/include/pbt.h winsup/w32api/include/poppack.h winsup/w32api/include/powrprof.h winsup/w32api/include/prsht.h winsup/w32api/include/psapi.h winsup/w32api/include/pshpack1.h winsup/w32api/include/pshpack2.h winsup/w32api/include/pshpack4.h winsup/w32api/include/pshpack8.h winsup/w32api/include/qedit.h winsup/w32api/include/rapi.h winsup/w32api/include/ras.h winsup/w32api/include/rasdlg.h winsup/w32api/include/raserror.h winsup/w32api/include/rassapi.h winsup/w32api/include/reason.h winsup/w32api/include/regstr.h winsup/w32api/include/richedit.h winsup/w32api/include/richole.h winsup/w32api/include/routprot.h winsup/w32api/include/rpc.h winsup/w32api/include/rpcdce.h winsup/w32api/include/rpcdce2.h winsup/w32api/include/rpcdcep.h winsup/w32api/include/rpcndr.h winsup/w32api/include/rpcnsi.h winsup/w32api/include/rpcnsip.h winsup/w32api/include/rpcnterr.h winsup/w32api/include/rpcproxy.h winsup/w32api/include/rtutils.h winsup/w32api/include/schannel.h winsup/w32api/include/schnlsp.h winsup/w32api/include/scrnsave.h winsup/w32api/include/sddl.h winsup/w32api/include/secext.h winsup/w32api/include/security.h winsup/w32api/include/servprov.h winsup/w32api/include/setupapi.h winsup/w32api/include/shellapi.h winsup/w32api/include/shldisp.h winsup/w32api/include/shlguid.h winsup/w32api/include/shlobj.h winsup/w32api/include/shlwapi.h winsup/w32api/include/snmp.h winsup/w32api/include/specstrings.h winsup/w32api/include/sql.h winsup/w32api/include/sqlext.h winsup/w32api/include/sqltypes.h winsup/w32api/include/sqlucode.h winsup/w32api/include/sspi.h winsup/w32api/include/stm.h winsup/w32api/include/strmif.h winsup/w32api/include/subauth.h winsup/w32api/include/svcguid.h winsup/w32api/include/tlhelp32.h winsup/w32api/include/tmschema.h winsup/w32api/include/unknwn.h winsup/w32api/include/userenv.h winsup/w32api/include/usp10.h winsup/w32api/include/uxtheme.h winsup/w32api/include/vfw.h winsup/w32api/include/vidcap.h winsup/w32api/include/vmr9.h winsup/w32api/include/vptype.h winsup/w32api/include/w32api.h winsup/w32api/include/winable.h winsup/w32api/include/winbase.h winsup/w32api/include/winber.h winsup/w32api/include/wincon.h winsup/w32api/include/wincrypt.h winsup/w32api/include/windef.h winsup/w32api/include/windns.h winsup/w32api/include/windows.h winsup/w32api/include/windowsx.h winsup/w32api/include/winerror.h winsup/w32api/include/wingdi.h winsup/w32api/include/wininet.h winsup/w32api/include/winioctl.h winsup/w32api/include/winldap.h winsup/w32api/include/winnetwk.h winsup/w32api/include/winnls.h winsup/w32api/include/winnt.h winsup/w32api/include/winperf.h winsup/w32api/include/winreg.h winsup/w32api/include/winresrc.h winsup/w32api/include/winsnmp.h winsup/w32api/include/winsock.h winsup/w32api/include/winsock2.h winsup/w32api/include/winspool.h winsup/w32api/include/winsvc.h winsup/w32api/include/winuser.h winsup/w32api/include/winver.h winsup/w32api/include/ws2spi.h winsup/w32api/include/ws2tcpip.h winsup/w32api/include/wsahelp.h winsup/w32api/include/wsipx.h winsup/w32api/include/wsnetbs.h winsup/w32api/include/wtsapi32.h winsup/w32api/include/wtypes.h winsup/w32api/include/xprtdefs.h winsup/w32api/include/zmouse.h winsup/w32api/install-sh winsup/w32api/lib/Makefile.in winsup/w32api/lib/aclui.def winsup/w32api/lib/advapi32.def winsup/w32api/lib/ativscp-uuid.c winsup/w32api/lib/avicap32.def winsup/w32api/lib/avifil32.def winsup/w32api/lib/bthprops.def winsup/w32api/lib/cap.def winsup/w32api/lib/cguid-uuid.c winsup/w32api/lib/comcat-uuid.c winsup/w32api/lib/comctl32.def winsup/w32api/lib/comdlg32.def winsup/w32api/lib/crypt32.def winsup/w32api/lib/ctl3d32.def winsup/w32api/lib/ddk/Makefile.in winsup/w32api/lib/ddk/apcups.def winsup/w32api/lib/ddk/cfgmgr32.def winsup/w32api/lib/ddk/dxapi.def winsup/w32api/lib/ddk/hal.def winsup/w32api/lib/ddk/hid.def winsup/w32api/lib/ddk/hidparse.def winsup/w32api/lib/ddk/mcd.def winsup/w32api/lib/ddk/ndis.def winsup/w32api/lib/ddk/newdev.def winsup/w32api/lib/ddk/ntoskrnl.def winsup/w32api/lib/ddk/scsiport.def winsup/w32api/lib/ddk/tdi.def winsup/w32api/lib/ddk/usbcamd.def winsup/w32api/lib/ddk/usbcamd2.def winsup/w32api/lib/ddk/videoprt.def winsup/w32api/lib/ddk/win32k.def winsup/w32api/lib/devguid.c winsup/w32api/lib/dhcpcsvc.def winsup/w32api/lib/directx/Makefile.in winsup/w32api/lib/directx/d3d8.def winsup/w32api/lib/directx/d3d9.def winsup/w32api/lib/directx/d3dim.def winsup/w32api/lib/directx/d3drm.def winsup/w32api/lib/directx/d3dx8d.def winsup/w32api/lib/directx/d3dx9d.def winsup/w32api/lib/directx/d3dxof.def winsup/w32api/lib/directx/ddraw.def winsup/w32api/lib/directx/dinput.def winsup/w32api/lib/directx/dinput8.def winsup/w32api/lib/directx/dinput_joy.c winsup/w32api/lib/directx/dinput_joy2.c winsup/w32api/lib/directx/dinput_kbd.c winsup/w32api/lib/directx/dinput_mouse.c winsup/w32api/lib/directx/dinput_mouse2.c winsup/w32api/lib/directx/dinput_private.h winsup/w32api/lib/directx/dmoguids.c winsup/w32api/lib/directx/dplayx.def winsup/w32api/lib/directx/dpnaddr.def winsup/w32api/lib/directx/dpnet.def winsup/w32api/lib/directx/dpnlobby.def winsup/w32api/lib/directx/dpvoice.def winsup/w32api/lib/directx/dsetup.def winsup/w32api/lib/directx/dsound.def winsup/w32api/lib/directx/dxerr.c winsup/w32api/lib/directx/dxerr8.c winsup/w32api/lib/directx/dxerr8w.c winsup/w32api/lib/directx/dxerr9.c winsup/w32api/lib/directx/dxerr9w.c winsup/w32api/lib/directx/dxguid.c winsup/w32api/lib/directx/ksproxy.def winsup/w32api/lib/directx/ksuser.c winsup/w32api/lib/directx/ksuser.def winsup/w32api/lib/directx/msdmo.def winsup/w32api/lib/directx/strmiids.c winsup/w32api/lib/directx/test.c winsup/w32api/lib/dlcapi.def winsup/w32api/lib/dnsapi.def winsup/w32api/lib/docobj-uuid.c winsup/w32api/lib/exdisp-uuid.c winsup/w32api/lib/extras-uuid.c winsup/w32api/lib/faultrep.def winsup/w32api/lib/gdi32.def winsup/w32api/lib/glaux.def winsup/w32api/lib/glu32.def winsup/w32api/lib/hlguids-uuid.c winsup/w32api/lib/hlink-uuid.c winsup/w32api/lib/icmui.def winsup/w32api/lib/igmpagnt.def winsup/w32api/lib/imagehlp.def winsup/w32api/lib/imm32.def winsup/w32api/lib/iphlpapi.def winsup/w32api/lib/kernel32.def winsup/w32api/lib/largeint.c winsup/w32api/lib/lz32.def winsup/w32api/lib/mapi32.def winsup/w32api/lib/mfcuia32.def winsup/w32api/lib/mgmtapi.def winsup/w32api/lib/mlang-uuid.c winsup/w32api/lib/mpr.def winsup/w32api/lib/mprapi.def winsup/w32api/lib/mqrt.def winsup/w32api/lib/msacm32.def winsup/w32api/lib/mscms.def winsup/w32api/lib/mshtml-uuid.c winsup/w32api/lib/msimg32.def winsup/w32api/lib/msvcp60.def winsup/w32api/lib/msvfw32.def winsup/w32api/lib/mswsock.def winsup/w32api/lib/msxml-uuid.c winsup/w32api/lib/nddeapi.def winsup/w32api/lib/netapi32.def winsup/w32api/lib/ntdll.def winsup/w32api/lib/oaidl-uuid.c winsup/w32api/lib/objidl-uuid.c winsup/w32api/lib/objsafe-uuid.c winsup/w32api/lib/ocidl-uuid.c winsup/w32api/lib/odbc32.def winsup/w32api/lib/odbccp32.def winsup/w32api/lib/ole32.def winsup/w32api/lib/oleacc-uuid.c winsup/w32api/lib/oleacc.def winsup/w32api/lib/oleaut32.def winsup/w32api/lib/olecli32.def winsup/w32api/lib/olectlid-uuid.c winsup/w32api/lib/oledlg.def winsup/w32api/lib/oleidl-uuid.c winsup/w32api/lib/olepro32.def winsup/w32api/lib/olesvr32.def winsup/w32api/lib/opengl32.def winsup/w32api/lib/penwin32.def winsup/w32api/lib/pkpd32.def winsup/w32api/lib/power-uuid.c winsup/w32api/lib/powrprof.def winsup/w32api/lib/psapi.def winsup/w32api/lib/quartz.def winsup/w32api/lib/rapi.def winsup/w32api/lib/rasapi32.def winsup/w32api/lib/rasdlg.def winsup/w32api/lib/res.rc winsup/w32api/lib/rpcdce4.def winsup/w32api/lib/rpcns4.def winsup/w32api/lib/rpcrt4.def winsup/w32api/lib/rtm.def winsup/w32api/lib/rtutils.def winsup/w32api/lib/scrnsave.c winsup/w32api/lib/secur32.def winsup/w32api/lib/servprov-uuid.c winsup/w32api/lib/setupapi.def winsup/w32api/lib/shell32.c winsup/w32api/lib/shell32.def winsup/w32api/lib/shfolder.def winsup/w32api/lib/shlwapi.def winsup/w32api/lib/snmpapi.def winsup/w32api/lib/svrapi.def winsup/w32api/lib/tapi32.def winsup/w32api/lib/test.c winsup/w32api/lib/th32.def winsup/w32api/lib/thunk32.def winsup/w32api/lib/unknwn-uuid.c winsup/w32api/lib/url.def winsup/w32api/lib/urlmon-uuid.c winsup/w32api/lib/user32.def winsup/w32api/lib/userenv.def winsup/w32api/lib/usp10.def winsup/w32api/lib/uxtheme.def winsup/w32api/lib/vdmdbg.def winsup/w32api/lib/version.def winsup/w32api/lib/vfw32.mri winsup/w32api/lib/win32spl.def winsup/w32api/lib/wininet.def winsup/w32api/lib/winmm.def winsup/w32api/lib/winspool.def winsup/w32api/lib/winstrm.def winsup/w32api/lib/wldap32.def winsup/w32api/lib/wow32.def winsup/w32api/lib/ws2_32.c winsup/w32api/lib/ws2_32.def winsup/w32api/lib/wsnmp32.def winsup/w32api/lib/wsock32.def winsup/w32api/lib/wst.def winsup/w32api/lib/wtsapi32.def --- winsup/cygwin/ChangeLog | 663 - winsup/cygwin/ChangeLog-1995 | 177 - winsup/cygwin/ChangeLog-1996 | 2031 -- winsup/cygwin/ChangeLog-1997 | 2800 -- winsup/cygwin/ChangeLog-1998 | 4490 --- winsup/cygwin/ChangeLog-1999 | 3562 -- winsup/cygwin/ChangeLog-2000 | 4150 --- winsup/cygwin/ChangeLog-2001 | 5337 --- winsup/cygwin/ChangeLog-2002 | 6655 ---- winsup/cygwin/ChangeLog-2003 | 5678 ---- winsup/cygwin/ChangeLog-2004 | 3848 --- winsup/cygwin/ChangeLog-2005 | 5813 ---- winsup/cygwin/ChangeLog-2006 | 3571 -- winsup/cygwin/ChangeLog-2007 | 2769 -- winsup/cygwin/ChangeLog-2008 | 3341 -- winsup/cygwin/ChangeLog-2009 | 3483 -- winsup/cygwin/Makefile.in | 504 - winsup/cygwin/ROADMAP | 129 - winsup/cygwin/acconfig.h | 11 - winsup/cygwin/aclocal.m4 | 875 - winsup/cygwin/analyze_sigfe | 80 - winsup/cygwin/assert.cc | 62 - winsup/cygwin/autoload.cc | 465 - winsup/cygwin/automode.c | 26 - winsup/cygwin/binmode.c | 21 - winsup/cygwin/child_info.h | 146 - winsup/cygwin/config.h.in | 50 - winsup/cygwin/config/i386/profile.h | 58 - winsup/cygwin/configure | 6985 ---- winsup/cygwin/configure.in | 110 - winsup/cygwin/cpuid.h | 35 - winsup/cygwin/crt0.c | 55 - winsup/cygwin/ctype.cc | 90 - winsup/cygwin/cxx.cc | 108 - winsup/cygwin/cygerrno.h | 52 - winsup/cygwin/cygheap.cc | 461 - winsup/cygwin/cygheap.h | 420 - winsup/cygwin/cygheap_malloc.h | 54 - winsup/cygwin/cyglsa.h | 213 - winsup/cygwin/cygmagic | 34 - winsup/cygwin/cygmalloc.h | 36 - winsup/cygwin/cygprops.h | 20 - winsup/cygwin/cygserver.h | 191 - winsup/cygwin/cygserver_ipc.h | 84 - winsup/cygwin/cygserver_msg.h | 91 - winsup/cygwin/cygserver_sem.h | 87 - winsup/cygwin/cygserver_setpwd.h | 53 - winsup/cygwin/cygserver_shm.h | 98 - winsup/cygwin/cygthread.cc | 510 - winsup/cygwin/cygthread.h | 57 - winsup/cygwin/cygtls.cc | 264 - winsup/cygwin/cygtls.h | 315 - winsup/cygwin/cygwin-cxx.h | 37 - winsup/cygwin/cygwin-shilka | 8 - winsup/cygwin/cygwin.din | 1831 -- winsup/cygwin/cygwin.sc | 141 - winsup/cygwin/cygwin_version.h | 31 - winsup/cygwin/dcrt0.cc | 1187 - winsup/cygwin/debug.cc | 232 - winsup/cygwin/debug.h | 95 - winsup/cygwin/devices.cc | 43491 ------------------------- winsup/cygwin/devices.h | 298 - winsup/cygwin/devices.in | 196 - winsup/cygwin/dir.cc | 352 - winsup/cygwin/dlfcn.cc | 180 - winsup/cygwin/dll_init.cc | 431 - winsup/cygwin/dll_init.h | 108 - winsup/cygwin/dll_init.sgml | 11 - winsup/cygwin/dllfixdbg | 75 - winsup/cygwin/dlmalloc.c | 3815 --- winsup/cygwin/dlmalloc.h | 93 - winsup/cygwin/dtable.cc | 1038 - winsup/cygwin/dtable.h | 105 - winsup/cygwin/dtable.sgml | 20 - winsup/cygwin/environ.cc | 1113 - winsup/cygwin/environ.h | 49 - winsup/cygwin/errno.cc | 365 - winsup/cygwin/exceptions.cc | 1435 - winsup/cygwin/exec.cc | 109 - winsup/cygwin/external.cc | 483 - winsup/cygwin/external.sgml | 18 - winsup/cygwin/fcntl.cc | 107 - winsup/cygwin/fhandler.cc | 1783 - winsup/cygwin/fhandler.h | 1446 - winsup/cygwin/fhandler_clipboard.cc | 295 - winsup/cygwin/fhandler_console.cc | 2316 -- winsup/cygwin/fhandler_disk_file.cc | 2287 -- winsup/cygwin/fhandler_dsp.cc | 1374 - winsup/cygwin/fhandler_fifo.cc | 333 - winsup/cygwin/fhandler_floppy.cc | 555 - winsup/cygwin/fhandler_mailslot.cc | 190 - winsup/cygwin/fhandler_mem.cc | 280 - winsup/cygwin/fhandler_netdrive.cc | 330 - winsup/cygwin/fhandler_nodevice.cc | 27 - winsup/cygwin/fhandler_proc.cc | 1223 - winsup/cygwin/fhandler_process.cc | 1076 - winsup/cygwin/fhandler_procnet.cc | 297 - winsup/cygwin/fhandler_random.cc | 187 - winsup/cygwin/fhandler_raw.cc | 201 - winsup/cygwin/fhandler_registry.cc | 996 - winsup/cygwin/fhandler_serial.cc | 1127 - winsup/cygwin/fhandler_socket.cc | 2100 -- winsup/cygwin/fhandler_tape.cc | 1485 - winsup/cygwin/fhandler_termios.cc | 369 - winsup/cygwin/fhandler_tty.cc | 1484 - winsup/cygwin/fhandler_virtual.cc | 277 - winsup/cygwin/fhandler_virtual.h | 27 - winsup/cygwin/fhandler_windows.cc | 144 - winsup/cygwin/fhandler_zero.cc | 54 - winsup/cygwin/flock.cc | 1534 - winsup/cygwin/fork.cc | 784 - winsup/cygwin/gcrt0.c | 41 - winsup/cygwin/gendef | 464 - winsup/cygwin/gendevices | 159 - winsup/cygwin/gentls_offsets | 90 - winsup/cygwin/glob.cc | 978 - winsup/cygwin/glob_pattern_p.cc | 28 - winsup/cygwin/globals.cc | 162 - winsup/cygwin/gmon.c | 282 - winsup/cygwin/gmon.h | 166 - winsup/cygwin/grp.cc | 499 - winsup/cygwin/heap.cc | 175 - winsup/cygwin/heap.h | 20 - winsup/cygwin/hires.h | 54 - winsup/cygwin/hookapi.cc | 304 - winsup/cygwin/how-autoload-works.txt | 66 - winsup/cygwin/how-cygheap-works.txt | 120 - winsup/cygwin/how-cygtls-works.txt | 75 - winsup/cygwin/how-fhandlers-work.txt | 75 - winsup/cygwin/how-signals-work.txt | 158 - winsup/cygwin/how-spawn-works.txt | 33 - winsup/cygwin/how-startup-shutdown-works.txt | 165 - winsup/cygwin/how-to-debug-cygwin.txt | 128 - winsup/cygwin/how-vfork-works.txt | 36 - winsup/cygwin/include/a.out.h | 431 - winsup/cygwin/include/arpa/ftp.h | 109 - winsup/cygwin/include/arpa/inet.h | 37 - winsup/cygwin/include/arpa/nameser.h | 563 - winsup/cygwin/include/arpa/nameser_compat.h | 231 - winsup/cygwin/include/arpa/telnet.h | 322 - winsup/cygwin/include/asm/byteorder.h | 95 - winsup/cygwin/include/asm/socket.h | 76 - winsup/cygwin/include/asm/types.h | 23 - winsup/cygwin/include/attr/xattr.h | 46 - winsup/cygwin/include/bits/wordsize.h | 6 - winsup/cygwin/include/byteswap.h | 39 - winsup/cygwin/include/cygwin/_types.h | 16 - winsup/cygwin/include/cygwin/acl.h | 98 - winsup/cygwin/include/cygwin/config.h | 75 - winsup/cygwin/include/cygwin/core_dump.h | 73 - winsup/cygwin/include/cygwin/cygwin_dll.h | 96 - winsup/cygwin/include/cygwin/fs.h | 20 - winsup/cygwin/include/cygwin/grp.h | 48 - winsup/cygwin/include/cygwin/hdreg.h | 24 - winsup/cygwin/include/cygwin/icmp.h | 1 - winsup/cygwin/include/cygwin/if.h | 123 - winsup/cygwin/include/cygwin/in.h | 263 - winsup/cygwin/include/cygwin/in6.h | 119 - winsup/cygwin/include/cygwin/in_systm.h | 34 - winsup/cygwin/include/cygwin/ipc.h | 71 - winsup/cygwin/include/cygwin/kd.h | 20 - winsup/cygwin/include/cygwin/msg.h | 102 - winsup/cygwin/include/cygwin/mtio.h | 313 - winsup/cygwin/include/cygwin/rdevio.h | 42 - winsup/cygwin/include/cygwin/sem.h | 128 - winsup/cygwin/include/cygwin/shm.h | 106 - winsup/cygwin/include/cygwin/signal.h | 281 - winsup/cygwin/include/cygwin/socket.h | 306 - winsup/cygwin/include/cygwin/sockios.h | 1 - winsup/cygwin/include/cygwin/stat.h | 102 - winsup/cygwin/include/cygwin/stdlib.h | 78 - winsup/cygwin/include/cygwin/sys_time.h | 27 - winsup/cygwin/include/cygwin/sysproto.h | 94 - winsup/cygwin/include/cygwin/time.h | 40 - winsup/cygwin/include/cygwin/types.h | 252 - winsup/cygwin/include/cygwin/utmp.h | 40 - winsup/cygwin/include/cygwin/version.h | 453 - winsup/cygwin/include/cygwin/wait.h | 37 - winsup/cygwin/include/dlfcn.h | 42 - winsup/cygwin/include/elf.h | 25 - winsup/cygwin/include/endian.h | 40 - winsup/cygwin/include/err.h | 33 - winsup/cygwin/include/exceptions.h | 115 - winsup/cygwin/include/fcntl.h | 51 - winsup/cygwin/include/features.h | 35 - winsup/cygwin/include/fnmatch.h | 63 - winsup/cygwin/include/fts.h | 153 - winsup/cygwin/include/ftw.h | 71 - winsup/cygwin/include/getopt.h | 92 - winsup/cygwin/include/glob.h | 117 - winsup/cygwin/include/icmp.h | 1 - winsup/cygwin/include/ifaddrs.h | 57 - winsup/cygwin/include/inttypes.h | 246 - winsup/cygwin/include/io.h | 29 - winsup/cygwin/include/lastlog.h | 22 - winsup/cygwin/include/libgen.h | 23 - winsup/cygwin/include/limits.h | 491 - winsup/cygwin/include/machine/stdlib.h | 22 - winsup/cygwin/include/mapi.h | 102 - winsup/cygwin/include/memory.h | 17 - winsup/cygwin/include/mntent.h | 54 - winsup/cygwin/include/monetary.h | 39 - winsup/cygwin/include/mqueue.h | 45 - winsup/cygwin/include/net/if.h | 16 - winsup/cygwin/include/netdb.h | 236 - winsup/cygwin/include/netinet/in.h | 28 - winsup/cygwin/include/netinet/in_systm.h | 16 - winsup/cygwin/include/netinet/ip.h | 202 - winsup/cygwin/include/netinet/ip_icmp.h | 16 - winsup/cygwin/include/netinet/tcp.h | 144 - winsup/cygwin/include/netinet/udp.h | 51 - winsup/cygwin/include/paths.h | 32 - winsup/cygwin/include/poll.h | 11 - winsup/cygwin/include/pthread.h | 202 - winsup/cygwin/include/pty.h | 20 - winsup/cygwin/include/regex.h | 130 - winsup/cygwin/include/resolv.h | 461 - winsup/cygwin/include/sched.h | 64 - winsup/cygwin/include/search.h | 76 - winsup/cygwin/include/semaphore.h | 45 - winsup/cygwin/include/stdint.h | 182 - winsup/cygwin/include/strings.h | 37 - winsup/cygwin/include/sys/acl.h | 17 - winsup/cygwin/include/sys/copying.dj | 41 - winsup/cygwin/include/sys/cygwin.h | 341 - winsup/cygwin/include/sys/dirent.h | 111 - winsup/cygwin/include/sys/elf32.h | 156 - winsup/cygwin/include/sys/elf64.h | 172 - winsup/cygwin/include/sys/elf_common.h | 299 - winsup/cygwin/include/sys/elf_generic.h | 91 - winsup/cygwin/include/sys/file.h | 54 - winsup/cygwin/include/sys/ioctl.h | 69 - winsup/cygwin/include/sys/ipc.h | 18 - winsup/cygwin/include/sys/kd.h | 20 - winsup/cygwin/include/sys/lock.h | 54 - winsup/cygwin/include/sys/mman.h | 77 - winsup/cygwin/include/sys/mount.h | 50 - winsup/cygwin/include/sys/msg.h | 18 - winsup/cygwin/include/sys/mtio.h | 18 - winsup/cygwin/include/sys/param.h | 80 - winsup/cygwin/include/sys/poll.h | 45 - winsup/cygwin/include/sys/procfs.h | 18 - winsup/cygwin/include/sys/queue.h | 512 - winsup/cygwin/include/sys/resource.h | 84 - winsup/cygwin/include/sys/sched.h | 16 - winsup/cygwin/include/sys/select.h | 41 - winsup/cygwin/include/sys/sem.h | 18 - winsup/cygwin/include/sys/shm.h | 18 - winsup/cygwin/include/sys/smallprint.h | 27 - winsup/cygwin/include/sys/socket.h | 60 - winsup/cygwin/include/sys/soundcard.h | 1287 - winsup/cygwin/include/sys/statfs.h | 11 - winsup/cygwin/include/sys/statvfs.h | 44 - winsup/cygwin/include/sys/stdio.h | 44 - winsup/cygwin/include/sys/strace.h | 156 - winsup/cygwin/include/sys/sysinfo.h | 27 - winsup/cygwin/include/sys/syslimits.h | 20 - winsup/cygwin/include/sys/syslog.h | 143 - winsup/cygwin/include/sys/sysmacros.h | 24 - winsup/cygwin/include/sys/sysproto.h | 18 - winsup/cygwin/include/sys/termio.h | 12 - winsup/cygwin/include/sys/termios.h | 352 - winsup/cygwin/include/sys/ttychars.h | 1 - winsup/cygwin/include/sys/uio.h | 38 - winsup/cygwin/include/sys/un.h | 29 - winsup/cygwin/include/sys/utime.h | 30 - winsup/cygwin/include/sys/utmp.h | 54 - winsup/cygwin/include/sys/utsname.h | 33 - winsup/cygwin/include/sys/vfs.h | 38 - winsup/cygwin/include/sys/wait.h | 55 - winsup/cygwin/include/sysexits.h | 118 - winsup/cygwin/include/syslog.h | 16 - winsup/cygwin/include/termio.h | 16 - winsup/cygwin/include/tzfile.h | 51 - winsup/cygwin/include/utmpx.h | 55 - winsup/cygwin/include/wait.h | 16 - winsup/cygwin/init.cc | 158 - winsup/cygwin/ioctl.cc | 63 - winsup/cygwin/ipc.cc | 91 - winsup/cygwin/kernel32.cc | 439 - winsup/cygwin/lc_msg.h | 277 - winsup/cygwin/lib/_cygwin_crt0_common.cc | 156 - winsup/cygwin/lib/crt0.h | 23 - winsup/cygwin/lib/cygwin_attach_dll.c | 27 - winsup/cygwin/lib/cygwin_crt0.c | 23 - winsup/cygwin/lib/dll_entry.c | 17 - winsup/cygwin/lib/dll_main.cc | 38 - winsup/cygwin/lib/libcmain.c | 43 - winsup/cygwin/lib/premain0.c | 14 - winsup/cygwin/lib/premain1.c | 14 - winsup/cygwin/lib/premain2.c | 14 - winsup/cygwin/lib/premain3.c | 14 - winsup/cygwin/lib/pseudo-reloc.c | 367 - winsup/cygwin/libc/bsdlib.cc | 301 - winsup/cygwin/libc/fnmatch.c | 293 - winsup/cygwin/libc/fts.c | 1249 - winsup/cygwin/libc/ftw.c | 107 - winsup/cygwin/libc/getopt.c | 535 - winsup/cygwin/libc/inet_addr.c | 224 - winsup/cygwin/libc/inet_network.c | 120 - winsup/cygwin/libc/minires-os-if.c | 567 - winsup/cygwin/libc/minires.c | 995 - winsup/cygwin/libc/minires.h | 68 - winsup/cygwin/libc/nftw.c | 126 - winsup/cygwin/libc/rcmd.cc | 778 - winsup/cygwin/libc/rexec.cc | 412 - winsup/cygwin/libc/strfmon.c | 622 - winsup/cygwin/libc/strptime.cc | 388 - winsup/cygwin/libc/xsique.cc | 48 - winsup/cygwin/libstdcxx_wrapper.cc | 90 - winsup/cygwin/localtime.cc | 2198 -- winsup/cygwin/lsearch.cc | 51 - winsup/cygwin/malloc.cc | 5064 --- winsup/cygwin/malloc_wrapper.cc | 305 - winsup/cygwin/mcount.c | 172 - winsup/cygwin/miscfuncs.cc | 414 - winsup/cygwin/miscfuncs.h | 42 - winsup/cygwin/mkglobals_h | 28 - winsup/cygwin/mkimport | 83 - winsup/cygwin/mkstatic | 59 - winsup/cygwin/mktemp.cc | 183 - winsup/cygwin/mkvers.sh | 177 - winsup/cygwin/mmap.cc | 1835 -- winsup/cygwin/mmap_helper.h | 91 - winsup/cygwin/mount.cc | 1678 - winsup/cygwin/mount.h | 189 - winsup/cygwin/msg.cc | 183 - winsup/cygwin/mtinfo.h | 137 - winsup/cygwin/net.cc | 4713 --- winsup/cygwin/netdb.cc | 408 - winsup/cygwin/nfs.cc | 18 - winsup/cygwin/nfs.h | 55 - winsup/cygwin/nlsfuncs.cc | 1201 - winsup/cygwin/ntdll.h | 1096 - winsup/cygwin/ntea.cc | 514 - winsup/cygwin/passwd.cc | 294 - winsup/cygwin/path.cc | 3613 -- winsup/cygwin/path.h | 323 - winsup/cygwin/path.sgml | 178 - winsup/cygwin/perprocess.h | 28 - winsup/cygwin/pinfo.cc | 1281 - winsup/cygwin/pinfo.h | 240 - winsup/cygwin/pipe.cc | 414 - winsup/cygwin/poll.cc | 122 - winsup/cygwin/posix.sgml | 1424 - winsup/cygwin/posix_ipc.cc | 1074 - winsup/cygwin/profil.c | 173 - winsup/cygwin/profil.h | 44 - winsup/cygwin/pseudo-reloc.cc | 367 - winsup/cygwin/pthread.cc | 189 - winsup/cygwin/pwdgrp.h | 84 - winsup/cygwin/random.cc | 504 - winsup/cygwin/regex/COPYRIGHT | 52 - winsup/cygwin/regex/cname.h | 138 - winsup/cygwin/regex/engine.c | 1197 - winsup/cygwin/regex/regcomp.c | 1885 -- winsup/cygwin/regex/regerror.c | 190 - winsup/cygwin/regex/regex.3 | 727 - winsup/cygwin/regex/regex.7 | 480 - winsup/cygwin/regex/regex2.h | 196 - winsup/cygwin/regex/regexec.c | 256 - winsup/cygwin/regex/regfree.c | 89 - winsup/cygwin/regex/utils.h | 54 - winsup/cygwin/registry.cc | 313 - winsup/cygwin/registry.h | 51 - winsup/cygwin/resource.cc | 196 - winsup/cygwin/scandir.cc | 93 - winsup/cygwin/sched.cc | 489 - winsup/cygwin/sec_acl.cc | 985 - winsup/cygwin/sec_auth.cc | 1240 - winsup/cygwin/sec_helper.cc | 581 - winsup/cygwin/security.cc | 860 - winsup/cygwin/security.h | 467 - winsup/cygwin/security.sgml | 45 - winsup/cygwin/select.cc | 1719 - winsup/cygwin/select.h | 97 - winsup/cygwin/sem.cc | 138 - winsup/cygwin/setlsapwd.cc | 89 - winsup/cygwin/shared.cc | 495 - winsup/cygwin/shared_info.h | 108 - winsup/cygwin/shm.cc | 388 - winsup/cygwin/signal.cc | 598 - winsup/cygwin/sigproc.cc | 1298 - winsup/cygwin/sigproc.h | 98 - winsup/cygwin/smallprint.cc | 502 - winsup/cygwin/sortdin | 35 - winsup/cygwin/spawn.cc | 1144 - winsup/cygwin/speclib | 78 - winsup/cygwin/stackdump.sgml | 13 - winsup/cygwin/strace.cc | 469 - winsup/cygwin/strfuncs.cc | 646 - winsup/cygwin/string.h | 126 - winsup/cygwin/strsep.cc | 64 - winsup/cygwin/strsig.cc | 97 - winsup/cygwin/sync.cc | 151 - winsup/cygwin/sync.h | 73 - winsup/cygwin/syscalls.cc | 4292 --- winsup/cygwin/sysconf.cc | 319 - winsup/cygwin/syslog.cc | 458 - winsup/cygwin/termios.cc | 324 - winsup/cygwin/textmode.c | 21 - winsup/cygwin/textreadmode.c | 25 - winsup/cygwin/thread.cc | 3288 -- winsup/cygwin/thread.h | 683 - winsup/cygwin/timer.cc | 456 - winsup/cygwin/times.cc | 791 - winsup/cygwin/tls_pbuf.cc | 59 - winsup/cygwin/tls_pbuf.h | 27 - winsup/cygwin/tlsoffsets.h | 121 - winsup/cygwin/tty.cc | 407 - winsup/cygwin/tty.h | 143 - winsup/cygwin/tz_posixrules.h | 48 - winsup/cygwin/uinfo.cc | 581 - winsup/cygwin/uname.cc | 104 - winsup/cygwin/wait.cc | 117 - winsup/cygwin/wchar.h | 75 - winsup/cygwin/winbase.h | 76 - winsup/cygwin/wincap.cc | 576 - winsup/cygwin/wincap.h | 116 - winsup/cygwin/window.cc | 133 - winsup/cygwin/winf.cc | 154 - winsup/cygwin/winf.h | 89 - winsup/cygwin/wininfo.h | 25 - winsup/cygwin/winsup.h | 330 - winsup/cygwin/winver.rc | 50 - 425 files changed, 245004 deletions(-) delete mode 100644 winsup/cygwin/ChangeLog delete mode 100644 winsup/cygwin/ChangeLog-1995 delete mode 100644 winsup/cygwin/ChangeLog-1996 delete mode 100644 winsup/cygwin/ChangeLog-1997 delete mode 100644 winsup/cygwin/ChangeLog-1998 delete mode 100644 winsup/cygwin/ChangeLog-1999 delete mode 100644 winsup/cygwin/ChangeLog-2000 delete mode 100644 winsup/cygwin/ChangeLog-2001 delete mode 100644 winsup/cygwin/ChangeLog-2002 delete mode 100644 winsup/cygwin/ChangeLog-2003 delete mode 100644 winsup/cygwin/ChangeLog-2004 delete mode 100644 winsup/cygwin/ChangeLog-2005 delete mode 100644 winsup/cygwin/ChangeLog-2006 delete mode 100644 winsup/cygwin/ChangeLog-2007 delete mode 100644 winsup/cygwin/ChangeLog-2008 delete mode 100644 winsup/cygwin/ChangeLog-2009 delete mode 100644 winsup/cygwin/Makefile.in delete mode 100644 winsup/cygwin/ROADMAP delete mode 100644 winsup/cygwin/acconfig.h delete mode 100644 winsup/cygwin/aclocal.m4 delete mode 100755 winsup/cygwin/analyze_sigfe delete mode 100644 winsup/cygwin/assert.cc delete mode 100644 winsup/cygwin/autoload.cc delete mode 100644 winsup/cygwin/automode.c delete mode 100644 winsup/cygwin/binmode.c delete mode 100644 winsup/cygwin/child_info.h delete mode 100644 winsup/cygwin/config.h.in delete mode 100644 winsup/cygwin/config/i386/profile.h delete mode 100755 winsup/cygwin/configure delete mode 100644 winsup/cygwin/configure.in delete mode 100644 winsup/cygwin/cpuid.h delete mode 100644 winsup/cygwin/crt0.c delete mode 100644 winsup/cygwin/ctype.cc delete mode 100644 winsup/cygwin/cxx.cc delete mode 100644 winsup/cygwin/cygerrno.h delete mode 100644 winsup/cygwin/cygheap.cc delete mode 100644 winsup/cygwin/cygheap.h delete mode 100644 winsup/cygwin/cygheap_malloc.h delete mode 100644 winsup/cygwin/cyglsa.h delete mode 100755 winsup/cygwin/cygmagic delete mode 100644 winsup/cygwin/cygmalloc.h delete mode 100644 winsup/cygwin/cygprops.h delete mode 100644 winsup/cygwin/cygserver.h delete mode 100644 winsup/cygwin/cygserver_ipc.h delete mode 100644 winsup/cygwin/cygserver_msg.h delete mode 100644 winsup/cygwin/cygserver_sem.h delete mode 100644 winsup/cygwin/cygserver_setpwd.h delete mode 100644 winsup/cygwin/cygserver_shm.h delete mode 100644 winsup/cygwin/cygthread.cc delete mode 100644 winsup/cygwin/cygthread.h delete mode 100644 winsup/cygwin/cygtls.cc delete mode 100644 winsup/cygwin/cygtls.h delete mode 100755 winsup/cygwin/cygwin-cxx.h delete mode 100755 winsup/cygwin/cygwin-shilka delete mode 100644 winsup/cygwin/cygwin.din delete mode 100644 winsup/cygwin/cygwin.sc delete mode 100644 winsup/cygwin/cygwin_version.h delete mode 100644 winsup/cygwin/dcrt0.cc delete mode 100644 winsup/cygwin/debug.cc delete mode 100644 winsup/cygwin/debug.h delete mode 100644 winsup/cygwin/devices.cc delete mode 100644 winsup/cygwin/devices.h delete mode 100644 winsup/cygwin/devices.in delete mode 100644 winsup/cygwin/dir.cc delete mode 100644 winsup/cygwin/dlfcn.cc delete mode 100644 winsup/cygwin/dll_init.cc delete mode 100644 winsup/cygwin/dll_init.h delete mode 100644 winsup/cygwin/dll_init.sgml delete mode 100755 winsup/cygwin/dllfixdbg delete mode 100644 winsup/cygwin/dlmalloc.c delete mode 100644 winsup/cygwin/dlmalloc.h delete mode 100644 winsup/cygwin/dtable.cc delete mode 100644 winsup/cygwin/dtable.h delete mode 100644 winsup/cygwin/dtable.sgml delete mode 100644 winsup/cygwin/environ.cc delete mode 100644 winsup/cygwin/environ.h delete mode 100644 winsup/cygwin/errno.cc delete mode 100644 winsup/cygwin/exceptions.cc delete mode 100644 winsup/cygwin/exec.cc delete mode 100644 winsup/cygwin/external.cc delete mode 100644 winsup/cygwin/external.sgml delete mode 100644 winsup/cygwin/fcntl.cc delete mode 100644 winsup/cygwin/fhandler.cc delete mode 100644 winsup/cygwin/fhandler.h delete mode 100644 winsup/cygwin/fhandler_clipboard.cc delete mode 100644 winsup/cygwin/fhandler_console.cc delete mode 100644 winsup/cygwin/fhandler_disk_file.cc delete mode 100644 winsup/cygwin/fhandler_dsp.cc delete mode 100644 winsup/cygwin/fhandler_fifo.cc delete mode 100644 winsup/cygwin/fhandler_floppy.cc delete mode 100644 winsup/cygwin/fhandler_mailslot.cc delete mode 100644 winsup/cygwin/fhandler_mem.cc delete mode 100644 winsup/cygwin/fhandler_netdrive.cc delete mode 100644 winsup/cygwin/fhandler_nodevice.cc delete mode 100644 winsup/cygwin/fhandler_proc.cc delete mode 100644 winsup/cygwin/fhandler_process.cc delete mode 100644 winsup/cygwin/fhandler_procnet.cc delete mode 100644 winsup/cygwin/fhandler_random.cc delete mode 100644 winsup/cygwin/fhandler_raw.cc delete mode 100644 winsup/cygwin/fhandler_registry.cc delete mode 100644 winsup/cygwin/fhandler_serial.cc delete mode 100644 winsup/cygwin/fhandler_socket.cc delete mode 100644 winsup/cygwin/fhandler_tape.cc delete mode 100644 winsup/cygwin/fhandler_termios.cc delete mode 100644 winsup/cygwin/fhandler_tty.cc delete mode 100644 winsup/cygwin/fhandler_virtual.cc delete mode 100644 winsup/cygwin/fhandler_virtual.h delete mode 100644 winsup/cygwin/fhandler_windows.cc delete mode 100644 winsup/cygwin/fhandler_zero.cc delete mode 100644 winsup/cygwin/flock.cc delete mode 100644 winsup/cygwin/fork.cc delete mode 100644 winsup/cygwin/gcrt0.c delete mode 100755 winsup/cygwin/gendef delete mode 100755 winsup/cygwin/gendevices delete mode 100755 winsup/cygwin/gentls_offsets delete mode 100644 winsup/cygwin/glob.cc delete mode 100644 winsup/cygwin/glob_pattern_p.cc delete mode 100644 winsup/cygwin/globals.cc delete mode 100644 winsup/cygwin/gmon.c delete mode 100644 winsup/cygwin/gmon.h delete mode 100644 winsup/cygwin/grp.cc delete mode 100644 winsup/cygwin/heap.cc delete mode 100644 winsup/cygwin/heap.h delete mode 100644 winsup/cygwin/hires.h delete mode 100644 winsup/cygwin/hookapi.cc delete mode 100644 winsup/cygwin/how-autoload-works.txt delete mode 100644 winsup/cygwin/how-cygheap-works.txt delete mode 100644 winsup/cygwin/how-cygtls-works.txt delete mode 100644 winsup/cygwin/how-fhandlers-work.txt delete mode 100644 winsup/cygwin/how-signals-work.txt delete mode 100644 winsup/cygwin/how-spawn-works.txt delete mode 100755 winsup/cygwin/how-startup-shutdown-works.txt delete mode 100644 winsup/cygwin/how-to-debug-cygwin.txt delete mode 100644 winsup/cygwin/how-vfork-works.txt delete mode 100644 winsup/cygwin/include/a.out.h delete mode 100644 winsup/cygwin/include/arpa/ftp.h delete mode 100644 winsup/cygwin/include/arpa/inet.h delete mode 100755 winsup/cygwin/include/arpa/nameser.h delete mode 100755 winsup/cygwin/include/arpa/nameser_compat.h delete mode 100644 winsup/cygwin/include/arpa/telnet.h delete mode 100644 winsup/cygwin/include/asm/byteorder.h delete mode 100644 winsup/cygwin/include/asm/socket.h delete mode 100644 winsup/cygwin/include/asm/types.h delete mode 100644 winsup/cygwin/include/attr/xattr.h delete mode 100644 winsup/cygwin/include/bits/wordsize.h delete mode 100644 winsup/cygwin/include/byteswap.h delete mode 100644 winsup/cygwin/include/cygwin/_types.h delete mode 100644 winsup/cygwin/include/cygwin/acl.h delete mode 100644 winsup/cygwin/include/cygwin/config.h delete mode 100644 winsup/cygwin/include/cygwin/core_dump.h delete mode 100644 winsup/cygwin/include/cygwin/cygwin_dll.h delete mode 100644 winsup/cygwin/include/cygwin/fs.h delete mode 100644 winsup/cygwin/include/cygwin/grp.h delete mode 100644 winsup/cygwin/include/cygwin/hdreg.h delete mode 100644 winsup/cygwin/include/cygwin/icmp.h delete mode 100644 winsup/cygwin/include/cygwin/if.h delete mode 100644 winsup/cygwin/include/cygwin/in.h delete mode 100644 winsup/cygwin/include/cygwin/in6.h delete mode 100644 winsup/cygwin/include/cygwin/in_systm.h delete mode 100644 winsup/cygwin/include/cygwin/ipc.h delete mode 100644 winsup/cygwin/include/cygwin/kd.h delete mode 100644 winsup/cygwin/include/cygwin/msg.h delete mode 100644 winsup/cygwin/include/cygwin/mtio.h delete mode 100644 winsup/cygwin/include/cygwin/rdevio.h delete mode 100644 winsup/cygwin/include/cygwin/sem.h delete mode 100644 winsup/cygwin/include/cygwin/shm.h delete mode 100644 winsup/cygwin/include/cygwin/signal.h delete mode 100644 winsup/cygwin/include/cygwin/socket.h delete mode 100644 winsup/cygwin/include/cygwin/sockios.h delete mode 100644 winsup/cygwin/include/cygwin/stat.h delete mode 100644 winsup/cygwin/include/cygwin/stdlib.h delete mode 100644 winsup/cygwin/include/cygwin/sys_time.h delete mode 100644 winsup/cygwin/include/cygwin/sysproto.h delete mode 100644 winsup/cygwin/include/cygwin/time.h delete mode 100644 winsup/cygwin/include/cygwin/types.h delete mode 100644 winsup/cygwin/include/cygwin/utmp.h delete mode 100644 winsup/cygwin/include/cygwin/version.h delete mode 100644 winsup/cygwin/include/cygwin/wait.h delete mode 100644 winsup/cygwin/include/dlfcn.h delete mode 100644 winsup/cygwin/include/elf.h delete mode 100644 winsup/cygwin/include/endian.h delete mode 100644 winsup/cygwin/include/err.h delete mode 100644 winsup/cygwin/include/exceptions.h delete mode 100644 winsup/cygwin/include/fcntl.h delete mode 100644 winsup/cygwin/include/features.h delete mode 100644 winsup/cygwin/include/fnmatch.h delete mode 100644 winsup/cygwin/include/fts.h delete mode 100644 winsup/cygwin/include/ftw.h delete mode 100644 winsup/cygwin/include/getopt.h delete mode 100644 winsup/cygwin/include/glob.h delete mode 100644 winsup/cygwin/include/icmp.h delete mode 100644 winsup/cygwin/include/ifaddrs.h delete mode 100644 winsup/cygwin/include/inttypes.h delete mode 100644 winsup/cygwin/include/io.h delete mode 100644 winsup/cygwin/include/lastlog.h delete mode 100644 winsup/cygwin/include/libgen.h delete mode 100644 winsup/cygwin/include/limits.h delete mode 100644 winsup/cygwin/include/machine/stdlib.h delete mode 100644 winsup/cygwin/include/mapi.h delete mode 100644 winsup/cygwin/include/memory.h delete mode 100644 winsup/cygwin/include/mntent.h delete mode 100644 winsup/cygwin/include/monetary.h delete mode 100644 winsup/cygwin/include/mqueue.h delete mode 100644 winsup/cygwin/include/net/if.h delete mode 100644 winsup/cygwin/include/netdb.h delete mode 100644 winsup/cygwin/include/netinet/in.h delete mode 100644 winsup/cygwin/include/netinet/in_systm.h delete mode 100644 winsup/cygwin/include/netinet/ip.h delete mode 100644 winsup/cygwin/include/netinet/ip_icmp.h delete mode 100644 winsup/cygwin/include/netinet/tcp.h delete mode 100644 winsup/cygwin/include/netinet/udp.h delete mode 100644 winsup/cygwin/include/paths.h delete mode 100644 winsup/cygwin/include/poll.h delete mode 100644 winsup/cygwin/include/pthread.h delete mode 100644 winsup/cygwin/include/pty.h delete mode 100644 winsup/cygwin/include/regex.h delete mode 100755 winsup/cygwin/include/resolv.h delete mode 100644 winsup/cygwin/include/sched.h delete mode 100644 winsup/cygwin/include/search.h delete mode 100644 winsup/cygwin/include/semaphore.h delete mode 100644 winsup/cygwin/include/stdint.h delete mode 100644 winsup/cygwin/include/strings.h delete mode 100644 winsup/cygwin/include/sys/acl.h delete mode 100644 winsup/cygwin/include/sys/copying.dj delete mode 100644 winsup/cygwin/include/sys/cygwin.h delete mode 100644 winsup/cygwin/include/sys/dirent.h delete mode 100644 winsup/cygwin/include/sys/elf32.h delete mode 100644 winsup/cygwin/include/sys/elf64.h delete mode 100644 winsup/cygwin/include/sys/elf_common.h delete mode 100644 winsup/cygwin/include/sys/elf_generic.h delete mode 100644 winsup/cygwin/include/sys/file.h delete mode 100644 winsup/cygwin/include/sys/ioctl.h delete mode 100644 winsup/cygwin/include/sys/ipc.h delete mode 100644 winsup/cygwin/include/sys/kd.h delete mode 100644 winsup/cygwin/include/sys/lock.h delete mode 100644 winsup/cygwin/include/sys/mman.h delete mode 100644 winsup/cygwin/include/sys/mount.h delete mode 100644 winsup/cygwin/include/sys/msg.h delete mode 100644 winsup/cygwin/include/sys/mtio.h delete mode 100644 winsup/cygwin/include/sys/param.h delete mode 100644 winsup/cygwin/include/sys/poll.h delete mode 100644 winsup/cygwin/include/sys/procfs.h delete mode 100644 winsup/cygwin/include/sys/queue.h delete mode 100644 winsup/cygwin/include/sys/resource.h delete mode 100644 winsup/cygwin/include/sys/sched.h delete mode 100644 winsup/cygwin/include/sys/select.h delete mode 100644 winsup/cygwin/include/sys/sem.h delete mode 100644 winsup/cygwin/include/sys/shm.h delete mode 100644 winsup/cygwin/include/sys/smallprint.h delete mode 100644 winsup/cygwin/include/sys/socket.h delete mode 100644 winsup/cygwin/include/sys/soundcard.h delete mode 100644 winsup/cygwin/include/sys/statfs.h delete mode 100644 winsup/cygwin/include/sys/statvfs.h delete mode 100644 winsup/cygwin/include/sys/stdio.h delete mode 100644 winsup/cygwin/include/sys/strace.h delete mode 100644 winsup/cygwin/include/sys/sysinfo.h delete mode 100644 winsup/cygwin/include/sys/syslimits.h delete mode 100644 winsup/cygwin/include/sys/syslog.h delete mode 100644 winsup/cygwin/include/sys/sysmacros.h delete mode 100644 winsup/cygwin/include/sys/sysproto.h delete mode 100644 winsup/cygwin/include/sys/termio.h delete mode 100644 winsup/cygwin/include/sys/termios.h delete mode 100644 winsup/cygwin/include/sys/ttychars.h delete mode 100644 winsup/cygwin/include/sys/uio.h delete mode 100644 winsup/cygwin/include/sys/un.h delete mode 100644 winsup/cygwin/include/sys/utime.h delete mode 100644 winsup/cygwin/include/sys/utmp.h delete mode 100644 winsup/cygwin/include/sys/utsname.h delete mode 100644 winsup/cygwin/include/sys/vfs.h delete mode 100644 winsup/cygwin/include/sys/wait.h delete mode 100644 winsup/cygwin/include/sysexits.h delete mode 100644 winsup/cygwin/include/syslog.h delete mode 100644 winsup/cygwin/include/termio.h delete mode 100644 winsup/cygwin/include/tzfile.h delete mode 100644 winsup/cygwin/include/utmpx.h delete mode 100644 winsup/cygwin/include/wait.h delete mode 100644 winsup/cygwin/init.cc delete mode 100644 winsup/cygwin/ioctl.cc delete mode 100644 winsup/cygwin/ipc.cc delete mode 100644 winsup/cygwin/kernel32.cc delete mode 100644 winsup/cygwin/lc_msg.h delete mode 100644 winsup/cygwin/lib/_cygwin_crt0_common.cc delete mode 100644 winsup/cygwin/lib/crt0.h delete mode 100644 winsup/cygwin/lib/cygwin_attach_dll.c delete mode 100644 winsup/cygwin/lib/cygwin_crt0.c delete mode 100644 winsup/cygwin/lib/dll_entry.c delete mode 100644 winsup/cygwin/lib/dll_main.cc delete mode 100644 winsup/cygwin/lib/libcmain.c delete mode 100644 winsup/cygwin/lib/premain0.c delete mode 100644 winsup/cygwin/lib/premain1.c delete mode 100644 winsup/cygwin/lib/premain2.c delete mode 100644 winsup/cygwin/lib/premain3.c delete mode 100644 winsup/cygwin/lib/pseudo-reloc.c delete mode 100644 winsup/cygwin/libc/bsdlib.cc delete mode 100644 winsup/cygwin/libc/fnmatch.c delete mode 100644 winsup/cygwin/libc/fts.c delete mode 100644 winsup/cygwin/libc/ftw.c delete mode 100644 winsup/cygwin/libc/getopt.c delete mode 100644 winsup/cygwin/libc/inet_addr.c delete mode 100644 winsup/cygwin/libc/inet_network.c delete mode 100644 winsup/cygwin/libc/minires-os-if.c delete mode 100644 winsup/cygwin/libc/minires.c delete mode 100644 winsup/cygwin/libc/minires.h delete mode 100644 winsup/cygwin/libc/nftw.c delete mode 100644 winsup/cygwin/libc/rcmd.cc delete mode 100644 winsup/cygwin/libc/rexec.cc delete mode 100644 winsup/cygwin/libc/strfmon.c delete mode 100644 winsup/cygwin/libc/strptime.cc delete mode 100644 winsup/cygwin/libc/xsique.cc delete mode 100755 winsup/cygwin/libstdcxx_wrapper.cc delete mode 100644 winsup/cygwin/localtime.cc delete mode 100644 winsup/cygwin/lsearch.cc delete mode 100644 winsup/cygwin/malloc.cc delete mode 100644 winsup/cygwin/malloc_wrapper.cc delete mode 100644 winsup/cygwin/mcount.c delete mode 100644 winsup/cygwin/miscfuncs.cc delete mode 100644 winsup/cygwin/miscfuncs.h delete mode 100755 winsup/cygwin/mkglobals_h delete mode 100755 winsup/cygwin/mkimport delete mode 100755 winsup/cygwin/mkstatic delete mode 100644 winsup/cygwin/mktemp.cc delete mode 100755 winsup/cygwin/mkvers.sh delete mode 100644 winsup/cygwin/mmap.cc delete mode 100644 winsup/cygwin/mmap_helper.h delete mode 100644 winsup/cygwin/mount.cc delete mode 100644 winsup/cygwin/mount.h delete mode 100644 winsup/cygwin/msg.cc delete mode 100644 winsup/cygwin/mtinfo.h delete mode 100644 winsup/cygwin/net.cc delete mode 100644 winsup/cygwin/netdb.cc delete mode 100644 winsup/cygwin/nfs.cc delete mode 100644 winsup/cygwin/nfs.h delete mode 100644 winsup/cygwin/nlsfuncs.cc delete mode 100644 winsup/cygwin/ntdll.h delete mode 100644 winsup/cygwin/ntea.cc delete mode 100644 winsup/cygwin/passwd.cc delete mode 100644 winsup/cygwin/path.cc delete mode 100644 winsup/cygwin/path.h delete mode 100644 winsup/cygwin/path.sgml delete mode 100644 winsup/cygwin/perprocess.h delete mode 100644 winsup/cygwin/pinfo.cc delete mode 100644 winsup/cygwin/pinfo.h delete mode 100644 winsup/cygwin/pipe.cc delete mode 100644 winsup/cygwin/poll.cc delete mode 100644 winsup/cygwin/posix.sgml delete mode 100644 winsup/cygwin/posix_ipc.cc delete mode 100644 winsup/cygwin/profil.c delete mode 100644 winsup/cygwin/profil.h delete mode 100644 winsup/cygwin/pseudo-reloc.cc delete mode 100644 winsup/cygwin/pthread.cc delete mode 100644 winsup/cygwin/pwdgrp.h delete mode 100644 winsup/cygwin/random.cc delete mode 100644 winsup/cygwin/regex/COPYRIGHT delete mode 100644 winsup/cygwin/regex/cname.h delete mode 100644 winsup/cygwin/regex/engine.c delete mode 100644 winsup/cygwin/regex/regcomp.c delete mode 100644 winsup/cygwin/regex/regerror.c delete mode 100644 winsup/cygwin/regex/regex.3 delete mode 100644 winsup/cygwin/regex/regex.7 delete mode 100644 winsup/cygwin/regex/regex2.h delete mode 100644 winsup/cygwin/regex/regexec.c delete mode 100644 winsup/cygwin/regex/regfree.c delete mode 100644 winsup/cygwin/regex/utils.h delete mode 100644 winsup/cygwin/registry.cc delete mode 100644 winsup/cygwin/registry.h delete mode 100644 winsup/cygwin/resource.cc delete mode 100644 winsup/cygwin/scandir.cc delete mode 100644 winsup/cygwin/sched.cc delete mode 100644 winsup/cygwin/sec_acl.cc delete mode 100644 winsup/cygwin/sec_auth.cc delete mode 100644 winsup/cygwin/sec_helper.cc delete mode 100644 winsup/cygwin/security.cc delete mode 100644 winsup/cygwin/security.h delete mode 100644 winsup/cygwin/security.sgml delete mode 100644 winsup/cygwin/select.cc delete mode 100644 winsup/cygwin/select.h delete mode 100644 winsup/cygwin/sem.cc delete mode 100644 winsup/cygwin/setlsapwd.cc delete mode 100644 winsup/cygwin/shared.cc delete mode 100644 winsup/cygwin/shared_info.h delete mode 100644 winsup/cygwin/shm.cc delete mode 100644 winsup/cygwin/signal.cc delete mode 100644 winsup/cygwin/sigproc.cc delete mode 100644 winsup/cygwin/sigproc.h delete mode 100644 winsup/cygwin/smallprint.cc delete mode 100755 winsup/cygwin/sortdin delete mode 100644 winsup/cygwin/spawn.cc delete mode 100755 winsup/cygwin/speclib delete mode 100644 winsup/cygwin/stackdump.sgml delete mode 100644 winsup/cygwin/strace.cc delete mode 100644 winsup/cygwin/strfuncs.cc delete mode 100644 winsup/cygwin/string.h delete mode 100644 winsup/cygwin/strsep.cc delete mode 100644 winsup/cygwin/strsig.cc delete mode 100644 winsup/cygwin/sync.cc delete mode 100644 winsup/cygwin/sync.h delete mode 100644 winsup/cygwin/syscalls.cc delete mode 100644 winsup/cygwin/sysconf.cc delete mode 100644 winsup/cygwin/syslog.cc delete mode 100644 winsup/cygwin/termios.cc delete mode 100644 winsup/cygwin/textmode.c delete mode 100644 winsup/cygwin/textreadmode.c delete mode 100644 winsup/cygwin/thread.cc delete mode 100644 winsup/cygwin/thread.h delete mode 100644 winsup/cygwin/timer.cc delete mode 100644 winsup/cygwin/times.cc delete mode 100644 winsup/cygwin/tls_pbuf.cc delete mode 100644 winsup/cygwin/tls_pbuf.h delete mode 100644 winsup/cygwin/tlsoffsets.h delete mode 100644 winsup/cygwin/tty.cc delete mode 100644 winsup/cygwin/tty.h delete mode 100644 winsup/cygwin/tz_posixrules.h delete mode 100644 winsup/cygwin/uinfo.cc delete mode 100644 winsup/cygwin/uname.cc delete mode 100644 winsup/cygwin/wait.cc delete mode 100644 winsup/cygwin/wchar.h delete mode 100644 winsup/cygwin/winbase.h delete mode 100644 winsup/cygwin/wincap.cc delete mode 100644 winsup/cygwin/wincap.h delete mode 100644 winsup/cygwin/window.cc delete mode 100644 winsup/cygwin/winf.cc delete mode 100644 winsup/cygwin/winf.h delete mode 100644 winsup/cygwin/wininfo.h delete mode 100644 winsup/cygwin/winsup.h delete mode 100644 winsup/cygwin/winver.rc (limited to 'winsup/cygwin') diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog deleted file mode 100644 index e99507da9..000000000 --- a/winsup/cygwin/ChangeLog +++ /dev/null @@ -1,663 +0,0 @@ -2010-02-15 Corinna Vinschen - - * path.cc (path_conv::check): Treat native DOS paths as "noacl". - -2010-02-15 Corinna Vinschen - - * mount.cc (mount_info::conv_to_win32_path): Set UNC path flags to - cygdrive prefix path flags. - -2010-02-14 Christopher Faylor - - * fhandler.cc (fhandler_base::setup_overlapped): Don't set signalled - state to true initially. - (fhandler_base::has_ongoing_io): Delete ill-advised function. - (fhandler_base::read_overlapped): Rely on caller having checked - nonblocking state. Don't attempt to (incorrectly) check it here. - (fhandler_base::write_overlapped): Remove call to has_ongoing_io. - * select.cc (peek_pipe): Ditto. - * fhandler.h (fhandler_base::has_ongoing_io): Delete declaration. - -2010-02-14 Christopher Faylor - - * regex/regcomp.c (xwcrtomb): Fix one explicable and one inexcplicable - C warning. - -2010-02-13 Corinna Vinschen - - * regex/regcomp.c (xwcrtomb): Don't convert Unicode chars outside the - base plane always to UTF-8. Call wcsnrtombs instead to allow arbitrary - multibyte charsets. - -2010-02-12 Corinna Vinschen - - * regex/regcomp.c (wgetnext): Use size_t as type for n2 since that's - what's returned by mbrtowc. - * regex/regexec.c (xmbrtowc): Ditto. - -2010-02-12 Christopher Faylor - - * pthread.cc (pthread_mutex_init): Explicitly fill out third arg to - pthread_mutex::init. - * thread.cc: Remov some obsolete comments. - (verifyable_object_isvalid): Reflect change to use thread_magic_t for - magic numbers. - (pthread_mutex::pthread_mutex): Set magic number to invalid initially - until we've verified that everything is valid. - (pthread_mutex::unlock): Fix a comment. - (verifyable_object::verifyable_object): Delete here. - (~verifyable_object::~verifyable_object): Ditto. - (pthread_mutex::init): Don't run is_good_initializer for non-static - objects. - * thread.h (thread_magic_t): New typedef. - (verifyable_object::verifyable_object): Use thread_magic_t; - (verifyable_object::magic): Ditto. - (pthread_mutex::is_good_initializer_or_bad_object): Remove unneeded - variable names. - (pthread_mutex::can_be_unlocked): Ditto. - (pthread_mutex::init): Ditto. Remove default for third argument. - -2010-02-12 Corinna Vinschen - - * regex/regcomp.c (xwcrtomb): New function to convert wide chars - outside of the base plane to UTF-8. Call throughout instead of - wcrtomb. - (wgetnext): Handle surrogate pairs on UTF-16 systems. - * regex/regexec.c (xmbrtowc): Ditto. - -2010-02-12 Corinna Vinschen - - * sec_auth.cc (get_user_local_groups): Retrieve name of well known - builtin group from system. Explain why. - * sec_helper.cc (well_known_builtin_sid): New SID for BUILTIN group. - * security.h (well_known_builtin_sid): Declare. - -2010-02-11 Pierre Humblet - - * registry.cc (get_registry_hive_path): Add space in string. - -2010-02-11 Corinna Vinschen - - * regex/engine.c (step): Drop Cygwin-specific definition. - (NONCHAR): Better cast here to make the test work. Move comment - from step here. - (matcher): Disable skipping initial string in multibyte case. - * regex/regcomp.c (p_bracket): Don't simplify singleton in the invert - case. - (p_b_term): Handle early end of pattern after dash in bracket - expression. - (singleton): Don't ignore the wides just because there's already a - singleton in the single byte chars. Fix condition for a singleton - wide accordingly. - (findmust): Check for LC_CTYPE charset, rather than LC_COLLATE charset. - * regex2.h (CHIN): Fix condition in the icase & invert case. - (ISWORD): Fix wrong cast to unsigned char. - -2010-02-11 Andy Koppe - - * nlsfuncs.cc (initial_setlocale): Move check whether charset has - changed from here... - (internal_setlocale): ...to here, to avoid unnecessary work when invoked - via CW_INT_SETLOCALE. - -2010-02-10 Corinna Vinschen - - * nlsfuncs.cc (__set_charset_from_locale): Allow "@euro" modifier only - for locales which use EUR as currency. - -2010-02-10 Corinna Vinschen - - * nlsfuncs.cc (__get_lcid_from_locale): Convert iu_CA to iu-Latn-CA - rather than iu-Cans-CA on Vista and later. - (__set_charset_from_locale): Set default charset for iu_CA to UTF-8. - -2010-02-10 Christopher Faylor - - * dcrt0.cc (_dll_crt0): Set _main_tls as early as possible. - * thread.cc (pthread_mutex::can_be_unlocked): Remove check for - MUTEX_OWNER_ANONYMOUS since it is racy and unsafe. - (pthread::init_mainthread): Initialize thread directly from _my_tls. - (pthread::self): Ditto. - (pthread::get_tls_self_pointer): Delete. - (pthread_mutex::pthread_mutex): Use an event rather than a semaphore. - (pthread_mutex::lock): Rename from _. Derive self directly. - (pthread_mutex::tryunlock): Ditto. - (pthread_mutex::destroy): Ditto. - (pthread_mutex::unlock): Ditto. Accommodate change from semaphore to - event. - (pthread_mutex::_fixup_after_fork): Accommodate change from semaphore - to event. - (pthread_mutex::init): Don't attempt to initialize a semaphore unless - it is in an initialized state. Do this check under - mutex_initialization_lock.lock - * thread.h (fast_mutex::init): Use event rather than semaphore. - (fast_mutex::lock): Ditto. - (pthread_mutex::_lock): Delete. - (pthread_mutex::_unlock): Ditto. - (pthread_mutex::_trylock): Ditto. - (pthread_mutex::_destroy): Ditto. - (pthread_mutex::get_pthread_self): Ditto. - (pthread_mutex::get_tls_self_pointer): Ditto. - (pthread_mutex::lock): Un-inline. - (pthread_mutex::unlock): Ditto. - (pthread_mutex::trylock): Ditto. - (pthread_mutex::destroy): Ditto. - -2010-02-09 Christopher Faylor - - * cygtls.h (struct _cygtls): Remove unneeded elements. - * thread.cc (pthread::exit): Avoid potential double call to - _my_tls.remove. - * tlsoffsets.h: Regenerate. - -2010-02-09 Corinna Vinschen - - * nlsfuncs.cc (lc_wcstombs): Add `return_invalid' flag to specify - whether invalid chars should be ignored or not. Change comment. - (__set_lc_monetary_from_win): Call lc_wcstombs with return_invalid - flag set. - (__set_lc_messages_from_win): Simplify to accommodate the fact that - lc_wcstombs just ignores invalid chars. Explain why. - -2010-02-09 Corinna Vinschen - - * nlsfuncs.cc (__set_lc_messages_from_win): Fix typo. - -2010-02-09 Corinna Vinschen - - * lc_msg.h: New file, fix a problem in locales with modifiers. - -2010-02-09 Corinna Vinschen - - * lc_msg.h: New file, generated from running Linux system. - -2010-02-09 Corinna Vinschen - - * lc_msg.h: New file, autogenerated from CLDR data. - * nlsfuncs.cc: Include lc_msg.h. - (lc_time_buf): Remove. - (lc_numeric_buf): Remove. - (lc_monetary_buf): Remove. - (lc_mbstowcs): Fix previous fix. - (__set_lc_time_from_win): Take additional pointer to buffer pointer, - defined in newlib. - (__set_lc_numeric_from_win): Ditto. - (__set_lc_monetary_from_win): Ditto. - (locale_cmp): New static function. - (__set_lc_messages_from_win): New function to be called from newlib. - -2010-02-08 Corinna Vinschen - - * external.cc (cygwin_internal): Add CW_INT_SETLOCALE case to - allow to call internal_setlocale(). - * nlsfuncs.cc (internal_setlocale): Make externally available. - * include/cygwin/version.h: Bump API minor number. - * include/sys/cygwin.h (cygwin_getinfo_types): Add CW_INT_SETLOCALE. - - * nlsfuncs.cc (lc_mbstowcs): Fix call to f_mbtowc. - (__set_locale_from_locale_alias): Ignore "@cjknarrow" modifier. - -2010-02-07 Corinna Vinschen - - * nlsfuncs.cc (__get_lcid_from_locale): Handle "@cyrillic" modifier - for uz_UZ locale here. - (__set_charset_from_locale): Accommodate above change. - -2010-02-07 Corinna Vinschen - - * nlsfuncs.cc (__set_locale_from_locale_alias): New function to read - locale aliases from /usr/share/locale/locale.alias. - -2010-02-06 Corinna Vinschen - - * nlsfuncs.cc (__get_lcid_from_locale): Handle no_NO as nb_NO, rather - than nn_NO. - -2010-02-06 Corinna Vinschen - - * nlsfuncs.cc (has_modifier): MOve up in file to use in - __get_lcid_from_locale as well. - (__get_lcid_from_locale): Handle no_NO locale as alias for nn_NO. - Default all sr_XY locales to Cyrillic script. Change lcid to Latin - script if "@latin" modifier has been specified. - (__set_charset_from_locale): Handle Serbian in codepage 1251 case as - well. Also check for sr_BA lcid. Restrict "@euro" modifier to - locales otherwise defaulting to ISO-8859-1. - -2010-02-06 Corinna Vinschen - - * nlsfuncs.cc (__set_charset_from_locale): Set default charset for - "ka_GE" locale to GEORGIAN-PS, for "kk_KZ" to PT154. - -2010-02-06 Corinna Vinschen - - * path.cc (symlink_info::check_nfs_symlink): Reopen file with - FILE_READ_EA access since, surprisingly, you need it to read EAs even - on NFS. - -2010-02-06 Corinna Vinschen - - * sec_auth.cc (get_full_privileged_inheritable_token): New function - to fetch token with full privileges from logon token in Vista and - later, and to make token inheritable. Add lengthy comments to explain - the function's job. - (cygwin_logon_user): Drop calling SetHandleInformation. Enable TCB - privilege and call get_full_privileged_inheritable_token. - (lsaauth): Don't fetch linked token and don't make handle inheritable - here, just call get_full_privileged_inheritable_token instead. - (lsaprivkeyauth): Ditto. - -2010-02-05 Corinna Vinschen - - * nlsfuncs.cc (__set_charset_from_locale): Set default charset for - "uz_UZ" locale to ISO-8859-1, with the "@cyrillic" modifier to UTF-8. - -2010-02-05 Christopher Faylor - - * dll_init.cc (per_module::run_dtors): Use consistent method for - running destructors. - -2010-02-04 Christopher Faylor - - * regcomp.c (p_ere): Workaround incorrect compiler warning. - * regerror.c (regatoi): Return non-const string or compiler complains - in certain inexplicable situations. - -2010-02-04 Corinna Vinschen - - * regex/engine.c (step): Declare and define with `int ch' rather than - `wint_t ch' parameter. Explain why. - (NONCHAR): Remove related Cygwin patch here, including wrong comment. - -2010-02-04 Corinna Vinschen - - Replace regex files with multibyte-aware version from FreeBSD. - * Makefile.in (install-headers): Remove extra command to install - regex.h. - (uninstall-headers): Remove extra command to uninstall regex.h. - * nlsfuncs.cc (collate_lcid): Make externally available to allow - access to collation internals from regex functions. - (collate_charset): Ditto. - * wchar.h: Add __cplusplus guards to make C-clean. - * include/regex.h: New file, replacing regex/regex.h. Remove UCB - advertising clause. - * regex/COPYRIGHT: Accommodate BSD license. Remove UCB advertising - clause. - * regex/cclass.h: Remove. - * regex/cname.h: New file from FreeBSD. - * regex/engine.c: Ditto. - (NONCHAR): Tweak for Cygwin. - * regex/engine.ih: Remove. - * regex/mkh: Remove. - * regex/regcomp.c: New file from FreeBSD. Tweak slightly for Cygwin. - Import required collate internals from nlsfunc.cc. - (p_ere_exp): Add GNU-specific \< and \> handling for word boundaries. - (p_simp_re): Ditto. - (__collate_range_cmp): Define. - (p_b_term): Use Cygwin-specific collate internals. - (findmust): Ditto. - * regex/regcomp.ih: Remove. - * regex/regerror.c: New file from FreeBSD. Fix a few compiler warnings. - * regex/regerror.ih: Remove. - * regex/regex.7: New file from FreeBSD. Remove UCB advertising clause. - * regex/regex.h: Remove. Replaced by include/regex.h. - * regex/regexec.c: New file from FreeBSD. Fix a few compiler warnings. - * regex/regfree.c: New file from FreeBSD. - * regex/tests: Remove. - * regex/utils.h: New file from FreeBSD. - -2010-02-03 Christopher Faylor - - * sigproc.cc (get_proc_lock): Fix error message typo. - -2010-02-03 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::fstat_helper): Workaround - another bug in NWFS. Add comment to explain why. Improve debug output - in case the NT calls to test for binary fail. - * path.h (path_conv::fs_is_cifs): New method. - (path_conv::fs_is_nwfs): New method. - -2010-02-02 Corinna Vinschen - - * include/paths.h (_PATH_MNTTAB): Define. - (_PATH_MOUNTED): Define. - * include/mntent.h: Include paths.h. Define MNTTAB and MOUNTED as their - paths.h equivalents. Add comment. - -2010-02-01 Christopher Faylor - - * dcrt0.cc (atexit_lock): Delete. - (cygwin_exit): Remove atexit lock. - (cygwin_atexit): Ditto. Rename parameter to match newlib. Call - __cxa_atexit when invoked by a registered DLL. - * dll_init.cc (remove_dll_atexit): Delete. - (dll_list::find): New function. - (dll_list::detach): Use dll_list::find to find dll associated with - return address. Use __cxa_finalize to run atexit functions associated - with the dll. - (cygwin_detach_dll): Don't assume that HANDLE == void *. - * dll_init.h (dll_list::find): Declare. - (__cxa_atexit): Ditto. - (__cxa_finalize): Ditto. - - * init.cc (dll_entry): Clarify comment. - -2010-02-02 Dave Korn - - * how-startup-shutdown-works.txt: Add new document. - -2010-01-29 Corinna Vinschen - - * sec_auth.cc (lsaauth): Use CYG_LSA_MAGIC as checksum start value to - decouple from Cygwin release. - -2010-01-29 Corinna Vinschen - - * libc/strfmon.c (__setup_vars): Test for an empty string rather than - for a NULL pointer. - -2010-01-29 Christopher Faylor - - * dll_init.cc (remove_dll_atexit): New function. - (dll_list::detach): Run any atexit handlers registered in the DLL prior - to unloading. - -2010-01-29 Christopher Faylor - - * libc/strfmon.c (__setup_vars): Fix compiler warning about assigning - const strings. Compare a pointer to NULL rather than '\0'. - - * dll_init.cc (dll_dllcrt0_1): Minor comment fix. - - * pipe.cc (fhandler_pipe::create_selectable): Remove Win9x - accommodation. - -2010-01-29 Corinna Vinschen - - Throughout, use FileBothDirectoryInformation info class rather than - FileDirectoryInformation info class to avoid problems with incomplete - filesystem implementations. Fix comments accordingly. - * fhandler_disk_file.cc (fhandler_disk_file::readdir_helper): Set - fname->Length to 0 in error case to avoid potential crash in debug - output. - (fhandler_disk_file::readdir): Try to speed up the working default case. - Check for STATUS_INVALID_NETWORK_RESPONSE as potential status value - returned by filesystems not implementing FileIdBothDirectoryInformation. - * ntdll.h (STATUS_INVALID_NETWORK_RESPONSE): Define. - (FILE_BOTH_DIRECTORY_INFORMATION): Rename to official name. - * path.cc (symlink_info::check): Don't request FILE_READ_EA access, it's - not required for NFS. Try to speed up the working default case. Check - for STATUS_INVALID_NETWORK_RESPONSE as potential status value returned - by filesystems not supporting non-NULL EA parameters. Fix the way - fs.update is called. Improve debug output. - -2010-01-28 Corinna Vinschen - - * Makefile.in (tags, ctags, CTAGS)): Add rules to create tags file. - -2010-01-25 Corinna Vinschen - - * nlsfuncs.cc (__get_lcid_from_locale): Add comments. Fix typos in - comments. Make sure to set last_lcid every time. Return locale - without territory part as invalid. Handle modern serbian territory - names per ISO 3166 on older systems as well. Add appropriate comment. - (__set_charset_from_locale): Handle LCID for sr_CS as well to make older - systems happy. - -2010-01-25 Corinna Vinschen - - * nlsfuncs.cc (__set_charset_from_locale): Rearrange to set charset - more closely aligned to Glibc. - -2010-01-25 Corinna Vinschen - - * spawn.cc (spawn_guts): Only try to remove long path prefix from - runpath if runpath is not NULL. - -2010-01-25 Corinna Vinschen - - * nlsfuncs.cc (__get_lcid_from_locale): Fix a comment. Handle special - language/TERRITORY combinations explicitely. Explain why. - -2010-01-24 Corinna Vinschen - - * nlsfuncs.cc (__set_charset_from_locale): Fix comment. - -2010-01-24 Corinna Vinschen - - * nlsfuncs.cc (check_codepage): Move from syscalls.cc here. - (internal_setlocale): Ditto. - (initial_setlocale): Ditto. - (setlocale): Ditto. - * strfuncs.cc (__sjis_wctomb): Revert previous patch. - (__sjis_mbtowc): Ditto. - * syscalls.cc: Move setlocale-related functions to nlsfuncs.cc. - -2010-01-23 Corinna Vinschen - - * strfuncs.cc (__sjis_wctomb): Special handling for characters which - differ between SJIS and Windows codepage 932, if charset is "SJIS". - (__sjis_mbtowc): Ditto. - (_jis_wctomb): Remove. - (__jis_mbtowc): Remove. - -2010-01-23 Corinna Vinschen - - * nlsfuncs.cc (wcsxfrm): Call LCMapStringW with LCMAP_BYTEREV flag to - allow correct comparison using wcscmp. - -2010-01-22 Corinna Vinschen - - * posix.sgml (strfmon): Move to implemented SUSv4 API. - -2010-01-22 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Add nlsfunc.o and strfmon.o. - * autoload.cc (LocaleNameToLCID): Define. - * cygwin.din (strfmon): Export. - * nlsfuncs.cc: New file. Define a lot of internal functions called - from setlocale. - (wcscoll): Implement locale-aware here, using CompareStringW function. - (strcoll): Ditto. - (wcsxfrm): Implement locale-aware here, usingLCMapStringW function. - (strxfrm): Ditto. - (__set_charset_from_locale): Replace __set_charset_from_codepage. - Return Linux-compatible charset. - * strfuncs.cc (__set_charset_from_codepage): Remove. - * wchar.h (__set_charset_from_codepage): Drop definition. - * wincap.h (wincaps::has_localenames): New element. - * wincap.cc: Implement above element throughout. - * libc/strfmon.c: New file. - * libc/strptime.cc: Remove locale constant strings in favor of - access to locale-specifc data. - (strptime): Point _CurrentTimeLocale to locale-specific data. - Throughout use correct locale-specific format fields for all - locale-specific formats. - * include/monetary.h: New file. - * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. - -2010-01-18 Corinna Vinschen - - * strfuncs.cc: Remove needless includes. - -2010-01-17 Corinna Vinschen - - * syscalls.cc (internal_setlocale): Use UTF-8 internally if external - charset is ASCII. - -2010-01-15 Corinna Vinschen - - * libc/fnmatch.c: Replace with multibyte capable version from FreeBSD. - -2010-01-15 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::accept4): Reset async flag - on accepted socket. - -2010-01-15 Pierre A. Humblet - - * fhandler_socket.cc (fhandler_socket::accept4): Set nonblocking - flag exactly according to flags, as on Linux. - * net.cc (cygwin_accept): Maintain BSD semantics here. - -2010-01-15 Corinna Vinschen - - * cygwin.din (accept4): Export. - * fhandler.h (fhandler_socket::accept4): Rename from accept. Take - additional flag parameter. - * fhandler_socket.cc (fhandler_socket::accept4): Ditto. Handle - SOCK_NONBLOCK and SOCK_CLOEXEC flags. - * net.cc (cygwin_socket): Handle SOCK_NONBLOCK and SOCK_CLOEXEC flags - in type. Check for invalid flag values. - (socketpair): Ditto. - (cygwin_accept): Accommodate renaming of fhandler_socket::accept - function to accept4. - (accept4): New function. - * posix.sgml: Mention accept4 as GNU extensions. - * include/cygwin/socket.h (SOCK_NONBLOCK): Define. - (SOCK_CLOEXEC): Define. - (_SOCK_FLAG_MASK): Define when building Cygwin. - * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. - * include/sys/socket.h (accept4): Declare. - -2010-01-15 Corinna Vinschen - - * posix.sgml: Mention dup3 and pipe2 as GNU extensions. - -2010-01-14 Corinna Vinschen - - * dcrt0.cc (dll_crt0_1): Reset locale to "C" at the last moment before - calling the application's main. - * syscalls.cc (internal_setlocale): Don't reset locale to "C here. - Change comment accordingly. - -2010-01-14 Corinna Vinschen - - * cygwin.din (dup3): Export. - (pipe2): Export. - * dtable.cc (dtable::dup_worker): Take additional flags parameter. - Handle O_CLOEXEC flag. - (dtable::dup3): Rename from dup2. Take additional flags parameter. - Check for valid flags. Drop check for newfd == oldfd. - * dtable.h (dtable::dup_worker): Add flags parameter. - (dtable::dup3): Rename from dup2. - * fcntl.cc (fcntl64): Add F_DUPFD_CLOEXEC case. - * fhandler.h (fhandler_mailslot::get_object_attr): Add flags parameter. - * fhandler.cc (fhandler_base::open): Use security attribute with - inheritance according to setting of O_CLOEXEC flag. - * fhandler_console.cc (fhandler_console::open): Ditto. - * fhandler_fifo.cc (sec_user_cloexec): New inline function to - create security attribute with inheritance according to setting of - O_CLOEXEC flag. - (fhandler_fifo::open): Call sec_user_cloexec to fetch security - attribute. - (fhandler_fifo::wait): Ditto. - * fhandler_mem.cc (fhandler_dev_mem::open): Ditto. - * fhandler_mailslot.cc (fhandler_mailslot::get_object_attr): Take - additional flags parameter. Use security attribute with inheritance - according to setting of O_CLOEXEC flag. - (fhandler_mailslot::open): Call get_object_attr with flags parameter. - * fhandler_registry.cc (fhandler_registry::open): Call set_close_on_exec - on real handles to accommodate O_CLOEXEC flag. - * fhandler_tty.cc (fhandler_tty_slave::open): Ditto. - * fhandler_tape.cc: Create mutex with inheritance according to setting - of O_CLOEXEC flag. - * pipe.cc: Replace usage of O_NOINHERIT with O_CLOEXEC. - (fhandler_pipe::init): Simplify setting close_on_exec flag. - (fhandler_pipe::open): Remove setting close_on_exec flag. - (fhandler_pipe::create): Use security attribute with inheritance - according to setting of O_CLOEXEC flag. - (pipe2): New exported function. - * posix_ipc.cc: Throughout, open backing files with O_CLOEXEC - flag to follow POSIX semantics. - * security.h (sec_none_cloexec): New define. - * syscalls.cc (dup): Add missing extern "C" qualifier. Accommodate - renaming of dtable::dup2 to dtable::dup3. - (dup2): Ditto. Check newfd == oldfd here. - (dup3): New function. Check newfd == oldfd here. - (open): Set close_on_exec flag according to O_CLOEXEC flag before - calling fhandler->open. - * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. - -2010-01-13 Corinna Vinschen - - * include/fcntl.h (O_TTY_INIT): Define as 0. - -2010-01-13 Corinna Vinschen - - * fhandler_tty.cc (fhandler_tty_master::init): Don't erase all default - termios settings of slave console. - -2010-01-13 Corinna Vinschen - - * syscalls.cc (rename): Don't exit prematurely with EROFS when trying - to rename an AF_LOCAL socket or when trying to replace an AF_LOCAL - socket. - -2010-01-12 Corinna Vinschen - - * globals.cc (ro_u_nwfs): New R/O unicode string. - * mount.cc (fs_info::update): Check for NWFS filesystem. Set - has_buggy_basic_info, if so. Add comment to explain why. - (fillout_mntent): Add "nwfs" string to fs_names array. - * mount.h (enum fs_info_type): Add nwfs. - (class fs_info): Add has_buggy_basic_info status flag. Add accessors - for has_buggy_basic_info and is_nwfs. - * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Accommodate - filesystems with broken FileBasicInformation handling. - * path.cc (symlink_info::check): Ditto. - * path.h (path_conv::has_buggy_basic_info): Add method. - -2010-01-12 Corinna Vinschen - - * dtable.cc (build_fh_name_worker): Remove. Move all functionality - back into build_fh_name. - (build_fh_name): Drop unused HANDLE parameter. Drop call to pc.fillin. - Remove disabled build_fh_name with UNICODE_STRING name parameter. - * dtable.h (build_fh_name): Drop HANDLE parameter from declaration. - Remove declaration for build_fh_name with UNICODE_STRING name parameter. - * path.cc (path_conv::fillin): Remove. - (symlink_info::check): Fix comment. - * path.h (path_conv::fillin): Remove declaration. - * dir.cc: Accommodate change in build_fh_name parameters throughout. - * sec_acl.cc: Ditto. - * syscalls.cc: Ditto. - - * ntea.cc (getxattr_worker): Fix debug output. - (setxattr_worker): Ditto. - * times.cc (utimens_worker): Ditto. - -2010-01-11 Corinna Vinschen - - * fhandler_proc.cc (format_proc_stat): Use new in_buf. - (format_proc_cpuinfo): Replace szBuffer with a union in_buf. Use type - correct throughout. Add a couple of missing or newer cpu flags. Allow - certain AMD flags for intel as well. - -2010-01-10 Corinna Vinschen - - * fhandler.h (fhandler_base::fstat_helper): Declare timestamps as - PLARGE_INTEGER. - * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): - Accommodate fstat_helper change of timestamp arguments. - (fhandler_base::fstat_by_name): Ditto. - (fhandler_base::fstat_helper): Define with timestamps as PLARGE_INTEGER. - Accommodate in call to to_timestruc_t. - -2010-01-08 Corinna Vinschen - - * sec_auth.cc (get_token_group_sidlist): Add BUILTIN\Users account - to all created tokens. - * sec_helper.cc (well_known_users_sid): Define as BUILTIN\Users. - * security.h (well_known_users_sid): Declare. - -2010-01-01 Christopher Faylor - - * dcrt0.cc: Bump copyright. - -2010-01-01 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Move internal locale setting prior to - potential globify to prevent creation of unglobbed filenames in the - wrong character set. diff --git a/winsup/cygwin/ChangeLog-1995 b/winsup/cygwin/ChangeLog-1995 deleted file mode 100644 index 43d28a3a1..000000000 --- a/winsup/cygwin/ChangeLog-1995 +++ /dev/null @@ -1,177 +0,0 @@ -Mon Dec 18 16:44:38 1995 Jason Molenda (crash@phydeaux.cygnus.com) - - * configure.in (target_cpu): specify valid Intel x86 architectures - explicitly. - -Mon Dec 18 15:04:29 1995 Jason Molenda (crash@phydeaux.cygnus.com) - - * sysdef/*.def: moved to sysdef/i386/. - -Mon Dec 18 15:00:56 1995 Jason Molenda (crash@phydeaux.cygnus.com) - - * configure.in: Set DLL_ENTRY and SYSDEF_DIR for i386 and powerpc. - * configure: Regenerated with autoconf 2.7. - - * Makefile.in: Use DLL_ENTRY and SYSDEF_DIR. - -Sat Dec 16 18:36:44 1995 steve chamberlain - - Changed the way that file handles are inherited. Now - all files are opened with the inheriting turned on, and they're - closed when necessary. - - Changed the way that children are waited for. Now - you can exec a non-gnuwin32 program and wait for its - result. - - * Makefile.in: Turn off frame-pointer. - * dcrt0.cc (environ_init): Lint. - * dirsearch.cc (opendir): Use new path_conv mechanism. - * exceptions.cc (ctrl_c_handler): Exit with correct status - * exec.cc (file_exists): Moved to paths.cc - (_execve): Moved most of the work into spawn.cc. - * fhandler.cc (*): Much. - * libccrt0.c (foo): Deleted. - (cygwin_crt0): Lint. - * path.cc (readlink): Initialize the SECURITY_ATTRIBUTES struct. - * pipe.cc (pipe, dup*): Reorganized. - * registry.cc (read_in): Create the key in CURRENT_USER. - * wait.cc, spawn.cc (*): Much. - * sysconf.cc (sysconf): Understand SC_PAGESIZE. - * times.cc (utime): New function. - * uname.cc (uname): Dig out more info. - -Wed Dec 13 05:54:55 1995 Michael Meissner - - * dcrt0.cc (environ_init): Cast alloca return to appropriate type. - * spawn.cc (spawn_guts): Ditto. - - * strace.cc (__small_{v,}sprintf): Add appropriate prototypes. - - * exceptions.cc (_except_list): Only use segments for 386 systems. - (__stack_trace): Add PowerPC support, and do nothing for systems - that are not supported except print stack tracing is not yet - support. - - * sdata.cc (import_term): Only use __attribute__((section)) on 386 - systems. - - * shared.cc (shared_init): Use MARK macro instead of calling mark - directly with incorrect type arguments. - - * fhandler.cc (fhandler_dev_null::{read,write}): Use size_t in - prototype, not unsigned int. - - * fork.cc (find_exec): Fix type errors. - * path.cc (path_to_real_path_keep_rel): Ditto. - * syscalls.h (PATH_TO_REAL_PATH): Ditto. - - * {longjmp,setjmp}.c: #ifdef i386 code. - - * include/wintypes.h (ExitProcess): Add - __attribute__((__noreturn__)) so exit compiles without warnings. - -Tue Dec 12 18:25:05 1995 Jason Molenda (crash@phydeaux.cygnus.com) - - * include/wintypes.h (WINAPI): Only define WINAPI for x86 systems. - -Tue Dec 5 16:00:05 1995 Jason Molenda (crash@phydeaux.cygnus.com) - - * Makefile.in (all): Only build documentation for info target. - Expect texi2html to not be found most of the time. - -Tue Dec 5 08:08:08 1995 steve chamberlain - - Release-B10 - - * cygwin.dll (__assert, wait, spawnv, spawnvp): Deleted. - * dcrt0.c: Quoting rewritten. - * exec.cc (file_exists): Use new path_conv mechanism. - (_execve): Close open child process handles. - * fhandler.cc (fhandler_normal::open): Follow symlinks. - (fhandler_normal::read): Keep track of logical file posision. - (fhandler_normal::lseek): Seek in text files correctly. - (fhandler_normal::fstat): Set IFLNK bit if its a symlink. - (fhandler_normal::init): Maintain is_pipe. - (fhandler_dev_null::fstat): New. - (fhandler_dev_null::get_handle): Return INVALID_HANDLE. - * fork.cc: Use new event mechanism. - * libccrt0.cc: Keep track of _fmode variable. - * misc.c (readlink): Delete. - * path.cc (__path_to_real_path_1): Allow /d mechanism. - (path_to_real_path_keep_rel): New - (link_cookie:*): Support for symbolic links. - * spawn.cc (spawn_guts): Quoting rewritten. - * times.cc: New. - * syscalls.cc (_stat_worker): New. - (_stat, _lstat): Use _stat_worker. - * sysconf.cc (sysconf): Support _SC_CLK_TCK. - -Tue Nov 28 15:29:38 1995 steve chamberlain - - * loads of stuff. When I make < 100k of diffs in a day, - the ChangeLog will be usefull. - -Tue Nov 21 18:01:39 1995 steve chamberlain - - * Makefile.in: Build the doc. - * exceptions.cc: lint. - * fork.cc: lint. - * shared.cc (shared_init): If MapViewOfFileEx fails, then try - again, but get the OS to select the address (for win95) - * strace.cc (__sysprintf): Print pid and state in hex. - * syscalls.cc (_unlink): Translate path to realpath. - -Wed Nov 15 23:47:43 1995 Jason Molenda (crash@phydeaux.cygnus.com) - - * spawn.cc (_exit): set return value's lower byte to 0 by default. - - Tue Oct 3 10:23:14 1995 Anders Blomdell (anders.blomdell@control.lth.se) - - * spawn.cc (spawn_guts): quote doublequotes correctly - -Tue Nov 14 15:05:33 1995 Jason Molenda (crash@phydeaux.cygnus.com) - - * configure.in: comment out call to cfg-ml-com.in. - -Tue Oct 31 11:19:18 1995 steve chamberlain - - * libcerr.cc: New file. - * dcrt0.cc (environ_init): Initialize PATH and friends nicely. - * exceptions.cc (ctrl_c_handler): Default case is to exit. - * fork.cc (__suffixy, find_exec): translate between paths and - real_paths. - * shared.cc (shared_init): Hard wire shared memory at 0xa0000000. - * syscalls.c (__path_to_real_path, real_path_to_path): Always - translate '/' <> '\' - -Mon Oct 30 17:36:10 1995 steve chamberlain - - * syscalls.cc (_rename): Fix for win95. - -Fri Oct 27 20:53:47 1995 steve chamberlain - - * Everything changed. - -Thu Oct 19 10:47:52 1995 steve chamberlain - - * registry.cc, uinfo.cc: New files. - * crt0.c (*uinfo*, *_exe_suffix*): Delete. - (dll_crt0): Call shared_init. - * getlogin.c: deleted. - * shared.cc: Fill in. - * spawn.c (_spawn): Use __exe_suffix function. - * syscalls.c (getuid, getgid): Moved into uinfo.cc - * syscalls.h (*uinfo, __exe_suffix): Deleted - * Makefile.in: Cope with target configury. - * termios.c: Fix stub prototypes. - * win.h: Deleted. - * include/winadvapi.h: Fill in some REG prototypes. - -Thu Oct 19 10:47:52 1995 steve chamberlain - - * Makefile.in: Cope with target configury. - -Wed Oct 18 15:34:49 1995 steve chamberlain - - * Moved from newlib. diff --git a/winsup/cygwin/ChangeLog-1996 b/winsup/cygwin/ChangeLog-1996 deleted file mode 100644 index 9c786c408..000000000 --- a/winsup/cygwin/ChangeLog-1996 +++ /dev/null @@ -1,2031 +0,0 @@ -Mon Dec 23 13:35:27 1996 Jeremy Allison - - * Makefile.in: Added $(srcdir)/../libstdc++/stl -I$(srcdir)/../libio - to the include path. As mmap uses STL then this is needed - to build the cross compiler. Also added mmap.o file. - * cygwin.din: Added mmap, mprotect, msync, munmap. - * dcrt0.cc: Added code to get the module pathname from - a previously unused field in the u area so fork() calls - don't have to search the path. Forwards compatible with - earlier releases as they set this field to zero. - * fork.cc: Added call to recreate_mmaps_after_fork() in - child code. Ensures child has same view of mmap'ed areas - as parent. - * libccrt0.cc: (See dcrt0.cc change). Setup the module - handle so fork can get the path name. - * mmap.cc: New file. Implements mmap, mprotect, msync, munmap, - recreate_mmaps_after_fork. Uses STL. - * select.cc: Added code to set errno to EINVAL if select done - on handles and sockets. Must fix this soon. - * spawn.cc: Set new variable hmodule in u area to zero for child. - * syscalls.cc: Added fsync functionality. No longer a dummy call. - * winsup.h: Decremented internal_reserved array by one to add - hmodule in u area. Added prototype for recreate_mmaps_after_fork(). - * include/sys/mman.h: Fixed include file for mmap calls. - -Tue Dec 17 16:20:52 1996 Geoffrey Noer - - * syscalls.cc (_rename): fix code so we really do - return -1 if _rename fails. - -Tue Dec 17 12:12:29 1996 Jeremy Allison - - * fhandler.cc: Added Sergeys patch for FakeReadFile. - * cygwin.din: Re-ordered network calls. - -Mon Dec 16 16:47:26 1996 Geoffrey Noer - - * configure.in: remove AC_C_CROSS (now part of AC_PROG_CC) - * utils/configure.in: ditto - * configure: regenerate - * utils/configure: regenerate - -Mon Dec 16 14:50:46 1996 Geoffrey Noer - - * cygwin.din: export cygwin32_getsockopt - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * spawn.cc: don't assume all scripts should be run in - bash -- run the shell specified after the #! - -Fri Dec 13 16:18:22 1996 Jeremy Allison - - * path.cc: Added support for UNC paths. - -Fri Dec 13 10:56:21 1996 Jeremy Allison - - * cygwin.din: Added h_errno, seteuid, _seteuid. - * exceptions.cc: Made init_exceptions extern "C". - * exceptions.h: Added cplusplus wrappers to enable this to - be used from C. - * net.cc: Added error numbers, fixed gethostbyaddr, added h_errno - fixes. - * stubs.cc: Added seteuid. - * include/mywinsock.h: Added HOST error entries for DNS lookups. - -Tue Dec 10 15:38:46 1996 Geoffrey Noer - - * version.h: bump CYGWIN_DLL_VERSION_MINOR to 4 - - patch from Marcus Daniels : - * fhandler.cc: add fhandler_dev_null::dup (fhandler_base *child) - * fhandler.h: add matching header - - gnu-win32 beta 17.1 release made - -Thu Dec 5 14:03:08 1996 Geoffrey Noer - - * select.cc: add missing end comment at about line 933. - gnu-win32 beta 17 release made - -Wed Dec 4 15:53:11 1996 Geoffrey Noer - - * version.h: increment minor dll number in conjunction - with gnu-win32 beta 17 release - -Tue Dec 3 15:05:57 1996 Geoffrey Noer - - * strsep.cc: new file containing Berkeley-copyrighted strsep - code previously in misc.cc. - * misc.cc: strsep moved to strsep.cc, stop including - unistd.h, strings.h, sys/types.h, stddef.h, and stdarg.h - * Makefile.in: appropriate adjustments to add strsep.cc - -Tue Dec 3 13:50:59 1996 Geoffrey Noer - - * include/sys/copying.dj: new file whose presence is - required by include/sys/file.h - -Tue Dec 3 13:37:27 1996 Geoffrey Noer - - Throughout all Cygnus-developped source files: put all - code under GPL - -Tue Dec 3 10:54:01 1996 Jeremy Allison - - * fork.cc: Changed code to delete [] saved child_hinfo - after allocate_pid called. Needed as child changes this - value in the shared area when it de-linearizes fd array. - Needed to stop race condition with earlier fix. - * winsup.h: Changed definition of item in hinfo to be - a char array rather than fhandler_console. Stops - destructor being called when fork delete [] of - hinfo array called. - * hinfo.cc: Changes (casts) to support winsup.h changes. - -Mon Dec 2 17:22:13 1996 Geoffrey Noer - - * include/utime.h: add ifdef _UTIME_U wrapper around header - -Mon Dec 2 15:45:46 1996 Jeremy Allison - - * fork.cc: Fixed file descriptor resource leak in parent. - * registry.cc: Removed fatal error if registry key cannot - be opened. Causes errors in service code. - -Wed Nov 27 15:40:15 1996 Geoffrey Noer - - * cygwin.din: for MS compatibility, also export functions - as _funcname = funcname - * include/netdb: - * include/sys/socket.h: - Do the equivalent thing for functions exported as cygwin32_funcname - -Wed Nov 27 15:14:30 1996 Geoffrey Noer - - * cygwin.din: remove exported helper functions that shouldn't - need to be exported (_read et al) - * glob/Makefile.in: add SHELL definition - * utils/Makefile.in: add SHELL definition - -Mon Nov 25 14:24:52 1996 Geoffrey Noer - - * include/commdlg.h, ddeml.h, winadvapi.h, winbase.h, wincon.h, - windef.h, windowsx.h, winerror.h, wingdi.h, winkernel.h, winnt.h, - wintypes.h, winuser.h, winversion.h: - Add MS-style header files back, each of which now includes our - windows.h. This should allow compilation of Windows code - that expects normal MS-named headers as long as the information - is in our windows.h somewhere. The appropriate wrappers have - been added to each file so windows.h isn't included more than - once. - * include/windows.h: add paranoia wrapper so it can be included - more than once. - -Mon Nov 18 22:19:40 1996 Geoffrey Noer - - * Makefile.in: change rules around so new-cygwin.dll is - only rebuilt when necessary - * spawn.cc: include - -Mon Nov 18 21:08:15 1996 Geoffrey Noer - - * net.cc: remove extern "C"s that shouldn't be there - (get_win95_ifconf, get_winnt_ifconf, get_if_flags) - * syscalls.cc: remove extern "C"s from num_entries, _stat_worker - * winsup.h: add extern "C"s for syscalls protos - -Mon Nov 18 20:35:39 1996 Geoffrey Noer - - * winsup.h: include version.h - * Makefile.in: remove dependencies involving version.h, but add - version.h to winsup.h dependency line and also add others that - should also be there. - * dcrt0.cc: - * libccrt0.cc: - * registry.cc: - * shared.cc: delete includes of version.h - -Mon Nov 18 20:16:37 1996 Geoffrey Noer - - * stubs.c -> stubs.cc, add extern "C"s - * uname.c -> uname.cc, add extern "C"s - * console.cc: add extern "C"s, remove include windows.h - since its already included in winsup.h - * dirsearch.cc: add extern "C"s - * fcntl.cc: add extern "C"s - * winsup.h: remove LEAN_AND_MEAN define since that's no longer - relevant with new windows headers, include version.h - * malloc.cc: fix typos - -Mon Nov 18 18:02:31 1996 Geoffrey Noer - - * grp.c renamed to grp.cc, add extern "C"s - * misc.c renamed to misc.cc, add extern "C"s - -Mon Nov 18 16:08:26 1996 Geoffrey Noer - - * syscalls.cc: extern "C"'d function calls - * net.cc: extern "C"'d function calls, some respacing - * hinfo.cc: extern "C"'d function calls, some respacing - * syscalls.h: removed defines for MIN, errno, alloca(x), - DEFAULT_GID/UID, NOT_OPEN_FD(fd), STD_RBITS et al, - O_NOSYMLINK - * winsup.h: added what was just deleted from syscalls.h - -Mon Nov 18 15:56:22 1996 Jeremy Allison - - * cygwin.din: Added readv - * syscalls.cc: Added readv code. - * syscalls.h: Added readv prototype. - -Wed Nov 13 15:55:14 1996 Geoffrey Noer - - * cygwin.din: added C++-related exports for stuff in - libgcc.a (from new.o, tinfo.o, tinfo2.o, exception.o). - -Mon Nov 11 15:50:26 1996 Geoffrey Noer - - * dcrt0.cc - * dirsearch.cc - * malloc.cc - * passwd.cc - * path.cc, - * pinfo.cc - * syslog.cc - * utils/kill.cc - * utils/cygwin.cc: - need to #include which used to be included - automatically in windows.h included by winsup.h. - * shared.cc: UnmapViewOfFile takes a void *, not a - const void * - * malloc.cc: formatting fixes - -Fri Nov 8 17:31:55 1996 Jeremy Allison - - * select.cc: Added fix for HANDLE select sent by - Sergey Okhapkin. - * fhandler.h: Changed dup to return int. Can now - return error to dup2. - * fhandler.cc: Changed dup to return error code. - Corrected fhandler_console::close to return - error code. - * hinfo.cc (dup2): Check return code from - fhandler->dup. - * times.cc: Changed DST calculation as tm struct - month starts at zero, NT wMonth starts at 1. - * TODO: Added the things i'd like to do. - -Wed Nov 6 17:42:31 1996 Geoffrey Noer - - * Makefile.in: Changed name of base file for cygwin.dll from - base to cygwin.base. Changed name of exp file for cygwin.dll - from win.exp to cygwin.exp. Updated dependency list, removing - recently removed files like libcfork.cc, added missing files, - and added all missing header dependencies. Small formatting - fixes. - -Fri Nov 1 16:38:48 1996 Geoffrey Noer - - * TODO: deleted old stuff from a long time ago, added some - new stuff - - * added public domain disclaimers to all files missing them, - reformatting of non-imported code to conform to GNU standards. - Changes to: - delqueue.h, exceptions.h, fcntl.cc, fhandler.h, grp.c, - init.cc, ioctl.cc, key.cc, libcctype.c, libcerr.cc, libcmain.cc, - misc.c, path.h, pold.c, resource.cc, smallprint.c, strerror.cc, - syslog.cc, termios.cc, test.c, version.h, wait.cc - -Fri Nov 1 14:44:29 1996 Jeremy Allison - - * fhandler.h: Added is_console() method needed by - new select code. - * fhandler.cc (fhandler_console::init): Added c_oflag setting - dependent on bin parameter. - * select.cc: Added code to implement select from console - handles. Ignores keyup events and still blocks. - -Wed Oct 30 16:35:41 1996 Jeremy Allison - - * fhandler.h: Removed fhandler_console_in, fhandler_console_out - and integrated them both into fhandler_console. Added output_handle_ - so fhandler console has two handles. - * fhandler.cc: Updated to support changes in fhandler.h. It is now - possible to open("/dev/tty") and read/write to the same fd. - * hinfo.cc(build_fhandler): Removed references to obsolete classes. - * spawn.cc: Changed to get correct reference to output_handle_ for - fhandler_console class. - * console.cc: Changed to get output handle rather than input handle. - * winsup.h: Changed definition of prototypes for functions changed - in console.cc - -Wed Oct 30 13:05:33 1996 Geoffrey Noer - - * include/custcntl.h - * include/features.h - * include/icmp.h - * include/wchar.h - * include/cygwin32/icmp.h - * include/cygwin32/ip.h - * include/cygwin32/sockios.h - * include/cygwin32/types.h - * include/cygwin32/uio.h - * include/sys/ttychars.h - Added comment with name of header to each so that these are no - longer empty files (some unzip programs won't create - zero-length files which is a problem for headers) - -Sun Oct 27 17:30:03 1996 Geoffrey Noer - - * cygwin.din: also export "_execl = execl" and the same - for _execle and _execlp - -Thu Oct 24 01:43:29 1996 Geoffrey Noer - - * include/windows.h: rewritten to include headers from - the include/Windows32 subdirectory - * winsup.h: no longer define MAX_PATH here since it's defined - in header files dragged in by windows.h - * dirsearch.cc (readdir): change WIN32_FIND_DATAA to WIN32_FIND_DATA - * libccrt0.cc: #include - * syscalls.cc (_unlink): chmod file to be unlinked to be - writable and try to delete it again if first delete failed - with permission denied error (rm will now work on read-only files) - (num_entries): change WIN32_FIND_DATAA to WIN32_FIND_DATA - * include/commdlg.h: delete - * include/ddeml.h: delete - * include/winadvapi.h: delete - * include/winbase.h: delete - * include/wincon.h: delete - * include/windef.h: delete - * include/windowsx.h: delete - * include/winerror.h: delete - * include/wingdi.h: delete - * include/winkernel.h: delete - * include/winnt.h: delete - * include/wintypes.h: delete - * include/winuser.h: delete - * include/winversion.h: delete - -Wed Oct 23 10:43:05 1996 Jeremy Allison - - * dcrt0.cc (api_fatal): Changed locking clear of - process table to unlocking clear. Needed as lock code calls - api_fatal. - * exceptions.cc: Added debug_printfs to follow exceptions in - strace mode. - * pinfo.cc: Added code to ensure fd table is cleared when new - pid entry allocated. Fixed bug when process is terminated - violently by TerminateProcess and leaves fd table non-zero. - * termios.cc: Changed stubbed out syscalls to syscall_printf - rather than small_printf. Stops annoying tcdrain message. - * winsup.h: Made get_empty_pinfo call private to pinfo_list. - Should never be called external to this class. - -Tue Oct 22 16:14:23 1996 Jeremy Allison - - * hinfo.cc: Removed previous change. This is not the - correct place to flush input events. - -Tue Oct 22 09:25:32 1996 Jeremy Allison - - * dcrt0.cc: Fixed up exit code to clean up pinfo array. - * exceptions.cc: Fixed up exit code to clean up pinfo array. - * fork.cc: Tidied up access to inuse_p entry. Added flags - to allow different states to be represented. - * hinfo.cc: Added code to flush pending events if - stdin is a console. - * pinfo.cc (pinfo::record_death): Added code to clean - the pinfo array if we are an exiting parent. - * spawn.cc: Removed erroneous code to clean childs - pinfo entry. - * wait.cc: Changed WAIT_ERROR_RC to Win32 WAIT_FAILED. - Tidied up access to pinfo array. - * winsup.h: Added record_death_nolock to pinfo class. - Added PID_XXX types for inuse_p. - -Tue Oct 22 01:26:52 1996 Geoffrey Noer - - * include/Windows32/Base.h: - * include/Windows32/Functions.h: - * include/Windows32/Structures.h: - * include/Windows32/UnicodeFunctions.h: - Fixes to just commited changes - -Mon Oct 21 19:58:50 1996 Geoffrey Noer - - * include/Windows32/ASCIIFunctions.h: - * include/Windows32/Base.h: - * include/Windows32/Defines.h: - * include/Windows32/Functions.h: - * include/Windows32/Structures.h: - * include/Windows32/UnicodeFunctions.h: - - Add back items in old include files (commdlg.h, ddeml.h, - shellapi.h, winadvapi.h, winbase.h, wincon.h, windef.h, - windowsx.h, winerror.h, wingdi.h, winkernel.h, winnt.h, - wintypes.h, winuser.h, winversion.h) which should now be able - to be erased and windows.h modified to point to the new headers - without anything nasty happening. - - * include/WINREADME: deleted - * include/mywinsock.h: removed many blank lines - -Mon Oct 21 09:48:00 1996 Jeremy Allison - - * select.cc: Re-written from scratch. Take account of - the following cases. (1). All sockets [written&works] - (2). Handles, sockets and always readies [written,not tested] - (3). All handles [written,not tested]. (4). Handles & sockets - with timeout [not yet written,returns -1]. Correctly blocks - and doesn't spin cpu. - * pinfo.cc: Changed to add global lock around pinfo array. - * fork.cc: Changed to use global pinfo lock. - * shared.cc: Fixed bug with fork()->exec()->exec() code. - * net.cc: Removed select_init() call (no longer used). - * spawn.cc: Implemented suggestion that spawn creates - process suspended, then sets up it's dwProcessId entry - in the shared pinfo array. - * wait.cc: Changed to use global pinfo lock. - * winsup.h: Added missing windows_95() call. - * fhandler.h: Changed ifdefs to select new always_ready - methods. - * fhandler.cc (fhandler_console::write): Fixed bug - where return of write_normal was being ignored. - * dcrt0.cc: Added code to use global pinfo lock. - Ensure that process records it's own death. - * exceptions.cc: Added code to clear our entry in pinfo - array when we are exiting. Should reduce dead processes in - pinfo array. - * include/winbase.h: Added MAXIMUM_WAIT_OBJECTS define. - -Mon Oct 21 00:52:17 1996 Geoffrey Noer - - * Makefile.in: install headers from new Windows32 dir - -Sat Oct 19 00:47:58 1996 Geoffrey Noer - - * include/Windows32/Base.h: change DWORD to unsigned int from - unsigned long, change __WIN32__ checks to _WIN32, change - // comments to /* */ - -Fri Oct 18 17:33:07 1996 Geoffrey Noer - - * include/Windows32/Defines.h: change INFINITE to 0xFFFFFFFF, - add back definitions present in old winsup headers missing from - this file (STATUS_WAIT_0 et al, CONTEXT stuff, FAR, PACKED, - ASCIICHAR) - * include/Windows32/Functions.h: change // comments to /* */ - * include/Windows32/Messages.h: add definitions for WM_NULL, - WM_PENWINFIRST, WM_PENWINLAST - * include/Windows32/Sockets.h: change __WIN32__ checks to _WIN32 - * include/Windows32/Structures.h: add ppc case for CONTEXT - structure, change // comments to /* */ - -Fri Oct 18 17:25:09 1996 Geoffrey Noer - - * include/Windows32: new directory for Windows headers - * include/Windows32/ASCIIFunctions.h: - * include/Windows32/Base.h: - * include/Windows32/Defines.h: - * include/Windows32/Errors.h: - * include/Windows32/Functions.h: - * include/Windows32/Messages.h: - * include/Windows32/Sockets.h: - * include/Windows32/Structures.h: - * include/Windows32/UnicodeFunctions.h: - New Win32 headers from Scott Christley's windows32api-0.1.2 package - with no local modifications. - -Wed Oct 16 17:16:33 1996 Geoffrey Noer - - * key.cc: remove extra blank lines, change ASCIICHAR to AsciiChar - * registry.cc: remove #include since it's already - included in windows.h - -Tue Oct 15 09:51:48 1996 Jeremy Allison - - * fhandler.h: Many changes to support moving fhandler array out of - shared area into locally allocated memory. Removed fhandler class, - fhandler_base is now root of class tree. Re-arranged class definitions - to make it clear what functions are virtual and can be overridden. - Inlined may accessor functions. - * fhandler.cc: Many changes to support moving fhandler array out of - shared area into locally allocated memory. unix_path_name_ is now - always set (all fhandler_base classes have a name). - * hinfo.cc: Many changes to support moving fhandler array out of - shared area into locally allocated memory. Added linearization and - de-linearization functions. - * net.cc(socket): Added code to keep name for fhandler_socket. - * pinfo.cc : Changed allocation of fhandler_base array to be in local - memory rather than in shared area. (modified functions are pinfo_init, - pinfo_list::get_empty_pinfo, pinfo_list::allocate_pid, - pinfo::record_death). - * shared.cc: Added functions to copy fd area for spawned process. - Changed name of shared area to include master version number of - Cygwin32. - * spawn.cc (spawn_guts): Added code to initialize new shared area - for fds. - * syscalls.cc: Changed all code depending on NOFILE to use - getdtablesize(). Added internal setdtablesize() call for exec'ed - processes. - * syscalls.h: Added getdtablesize(). - * sysconf.cc (sysconf): Changed SC_OPEN_MAX to return getdtablesize(). - * winsup.h: Moved fhandler array out of shared area. Changed from - fhandler to fhandler_base (new root of class tree). - * include/mywinsock.h: Updated #endif to make end of - __INSIDE_CYGWIN32__ clear. - * include/winkernel.h: Added UnmapViewOfFile call. - -Mon Oct 14 14:59:16 1996 Geoffrey Noer - - * sysdef/i386: replace all files with ones from Scott - Christley's windows32api-0.1.2 package. Still need to - integrate new headers. - -Mon Oct 14 13:41:14 1996 Geoffrey Noer - - * syscalls.cc (_unlink): need to fchmod file to writable - before attempting to delete. This change still needs more - work (fchmod isn't written yet). - * (fchmod): change comment - -Fri Oct 11 22:27:17 1996 Geoffrey Noer - - * fhandler.cc, fhandler.h: minor fixes to console - support functions (remove missed reference to gotarg2, - definition in fhandler.h) - -Wed Oct 9 17:55:00 1996 Geoffrey Noer - - * delqueue.cc: added copyright notice, reformatted file - - from sos@prospect.com.ru (Sergey Okhapkin): - * fhandler.cc, fhandler.h: add/fix ansi/vt100 console support, - and fix a tab bug - (modified functions are fhandler_console_out::clear_screen, - fhandler_console_out::clear_to_eol, - fhandler_console_out::char_command, - fhandler_console_out::write, - FakeReadFile) - -Wed Oct 9 17:32:17 1996 Jeremy Allison - - * times.cc: Swapped gmtime and localtime (they were - incorrectly reversed). - Added is_dst determination to them both. - * misc.c: Added swab, ffs. - * fcntl.cc(fcntl): Added capability for lock calls. - * fhandler.h: Added lock method into fhandler class. - * fhandler.cc: Added NT/Win95 semantics locks into ::lock - made them pretend they are POSIX locks. - * syscalls.cc (writev): Fixed return value bug. - * net.cc: Added WSAEOPNOTSUPP error. - * cygwin.din: Added ffs and swab. - * include/strings.h: Added file (just include string.h). - * include/winbase.h: Added defines LOCKFILE_FAIL_IMMEDIATELY - and LOCKFILE_EXCLUSIVE_LOCK. - * include/winerror.h: Added define ERROR_LOCK_FAILED. - -Thu Oct 3 16:19:23 1996 Jeremy Allison - - * fhandler.h: Many changes - removed all public variables - from classes, replaced with accessor functions. Renamed all - class variables to add a trailing '_'. This makes reading - and understanding which variables are class variables much simpler. - Changed name member to unix_path_name_ and made dynamic rather - than a fixed 31 byte buffer per entry. - * fhandler.cc: Updated varable access for above. - * fcntl.cc: Updated varable access for above. - * hinfo.cc: Updated varable access for above. - * spawn.cc: Updated varable access for above. - * syscalls.cc: Added fsync (null call) and fchmod(null - call at present). - * net.cc: Added ioctls for SIOCGIFCONF and SIOCGIFFLAGS. - Added ntohs, ntohl, static functions get_winnt_ifconf, - get_win95_ifconf and get_if_flags. - * include/cygwin32/if.h: Added structs for new ioctls. - * include/cygwin32/socket.h: Added iovec include. - * include/asm/socket.h: Added defines for above ioctls. - * cygwin.din: Added ntohs, ntohl, fsync, fchmod. - -Wed Oct 2 17:34:21 1996 Geoffrey Noer - - * utils/configure.in: add call to AC_CANONICAL_SYSTEM - * utils/configure: regenerate - * Makefile.in: build cygwin.dll as new-cygwin.dll and install as - cygwin.dll to prevent confusion when building winsup natively - -Tue Oct 1 17:27:34 1996 Jeremy Allison (jra@cygnus.com) - - * include/regex.h: Added. - * net.cc: Added WSAECONNRESET, WSAEPFNOSUPPORT to - errmap array. - -Tue Oct 1 15:40:39 1996 Jeremy Allison (jra@cygnus.com) - - * fork.cc (cygwin_fork_helper1): Fixed resource leak of process - handles, added cleanup code. Also fixed timout problem when child - cannot be initialized. - * dirsearch.cc (readdir): Changed comparison to explicitly check for - INVALID_HANDLE_VALUE. Test < 0 fails with void *. - * syscalls.cc (num_entries): Changed comparison to explicitly check for - INVALID_HANDLE_VALUE. Test < 0 fails with void *. - * cygwin.din: Added regcomp, regexec, regerror, regfree. - * Makefile.in: Added EXTRA_OFILES containing ../librx/rx.o. Added - comment to explain makefrag. Added ../newlib/libc/include to include - path. - -Mon Sep 30 16:10:56 1996 Stu Grossman (grossman@critters.cygnus.com) - - * cygwin.din: Remove getopt and friends. - -Fri Sep 27 18:31:28 1996 Jeremy Allison - - * dcrt0.cc (dll_crt_1): Moved initialization of _reent to correct - position. - -Fri Sep 27 14:24:05 1996 Jeremy Allison - - * dcrt0.cc (dll_crt_1): Fixed fork bug with _impure_ptr not being - initialized correctly in a forked child. This should fix - the bash echo in a sub-shell bug. - * include/sys/uio.h: Created file. Contains definitions for writev - * include/limits.h: Added IOV_MAX and SSIZE_MAX. - * syscalls.cc: Added writev, changed read and write to return ssize_t. - * syscalls.h: Added writev, changed read and write to return ssize_t. - * cygwin.din: Added writev call. - -Wed Sep 20 13:09:00 1996 Jeremy Allison - - * include/mntent.h: Added MOUNTED definition, needed by - some code. - * dcrt0.cc : Added __progname for getopt code. - * misc.c: Added getw code. - * cygwin.din: Added getopt, optarg, opterr, optind - optopt, putw, getw calls. - -Fri Sep 20 03:03:17 1996 Geoffrey Noer - - * select.cc: change long millisec to unsigned int, - respaced file - - patch from Sergey Okhapkin : - * select.cc (polled): fix for select to get keyboard input - working properly (check EventType != KEY_EVENT instead - of checking for KeyEvent.AsciiChar == 0) - * select.cc (cygwin32_select): make int i unsigned int so NULL is - a valid timeout argument for loop - -Fri Sep 13 18:21:52 1996 Jeremy Allison - - * fhandler.cc (fhandler_base::read): rewrite text mode read - -Fri Sep 13 14:58:17 1996 Geoffrey Noer - - * exceptions.cc (call_handler): fix control-C not working - problem by setting rethere variable before the old value is - clobbered. - -Thu Sep 12 16:27:00 1996 Jeremy Allison - - * syslog.cc (pass_handler) : Removed duplicate code - in pass_handler::print(). Added get_win95_event_log_path() - to facilitate moving to registry configuration. - -Thu Sep 12 12:56:00 1996 Jeremy Allison - - * syslog.cc : Added real openlog, syslog, logmask, closelog - calls. syslog logs to event log on NT, file on Win95. - * include/winnt.h : added EVENTLOG_xx_TYPE definitions. - * include/winadvapi.h : added ReportEventA, RegisterEventSourceA - DeregisterEventSourceA declarations. - * include/winkernel.h : added LockFile, UnlockFile, LockFileEx, - UnlockFileEx declarations. - * include/wintypes.h : added PSID typedef. - * include/sys/syslog.h : added options flag definitions for openlog. - -Wed Sep 11 15:34:09 1996 Geoffrey Noer - - * fhandler.cc (popen): delete stub in favor of newlib's - (pclose): delete stub in favor of newlib's - -Tue Sep 10 17:20:56 1996 Geoffrey Noer - - * configure.in: don't transform names (the only time this might - be a good idea is for unix x cygwin32) - * configure: regenerated with autoconf - -Tue Sep 10 17:20:56 1996 Geoffrey Noer - - patch from Sergey Okhapkin : - * fhandler.cc (FakeReadFile): support arrow keys, stop treating - bringing window to front as a key down (resulting in random - characters being printed in bash). - -Mon Sep 9 19:09:36 1996 Geoffrey Noer - - * syscalls.cc (system): fix system call - -Fri Sep 6 09:33:13 1996 Doug Evans - - * fhandler.h (fhandler_base): Make execable_p public char, not - private signed char. Delete get_execable. - * fhandler.cc (fhandler_base::get_execable): Renamed to - check_execable_p. - (fhandler_base::open): Restore symlink support. - Set execable_p, symlink_p. - (fhandler_base::fstat): Replace call to get_execable with reference - to execable_p. - (fhandler_base::fhandler_base): Set execable_p to 0. - * path.h (symlink_check): Declare it. - * path.cc (symlink_check): New function. - (readlink): Call it. - (symlink_follow): Likewise. New arg EXEC, callers updated. - * syscalls.cc (_stat_worker): New arg CALLER, callers updated. - - * syscalls.cc: Delete all occurences of in/out and MARK. - -Thu Sep 5 18:51:01 1996 Doug Evans - - * fork.cc: Don't include . Delete find_exec and support. - * spawn.cc: Include . Move find_exec and support here. - (perhaps_suffix): New argument report_failure_p, callers updated. - (find_exec_1): Use perhaps_suffix when scanning PATH. - (spawn_guts): Replace code to translate posix to win32 path lists - with calls to utility fns that do the job. - -Wed Sep 4 13:30:57 1996 Doug Evans - - * path.cc (readlink): Make more bulletproof. - -Wed Aug 28 16:44:24 1996 Geoffrey Noer - - * syscalls.cc (system): use execlp - * public release beta 16 made - -Tue Aug 27 09:58:14 1996 Doug Evans - - * version.h (CYGWIN_DLL_VERSION_MINOR): Bump up to 2. - -Mon Aug 26 15:12:44 1996 Geoffrey Noer - - * syscalls.cc (system): added basic system() call. - -Mon Aug 26 13:46:30 1996 Doug Evans - - * cygwin.din (cygwin_fork_helper__FPvN30): Delete. - (vfork,select): Add. - * fork.cc (prepare_child): Delete, contents moved into - cygwin_fork_helper1. - (cygwin_fork_helper): Delete, contents moved into __fork. - * winsup.h (cygwin_fork_helper): Delete. - - * path.cc: #include . - (symlink,readlink): Reenable, rewrite. - (symlink_follow): New function. - * path.h (symlink): Delete. - (SYMLINK_COOKIE, MAX_LINK_DEPTH): Define. - (symlink_follow): Declare. - * spawn.cc (spawn_guts): Rewrite symlink support. - - * syscalls.cc (_unlink): Make arg a const char *. - * winsup.h (_unlink): Likewise. - - * spawn.cc (spawn_guts): Fix allocation of stack space for sh.exe path. - - * include/sys/errno.h: Deleted. Use newlib's. - -Fri Aug 23 16:00:00 1996 Jeremy Allison - - * net.cc (getdomainname): Changed win95 code to open - "System" key rather than "SYSTEM". I think the registry - is case-sensitive. - -Thu Aug 22 17:04:09 1996 Geoffrey Noer - - move fork into the dll: - * libcfork.cc: deleted - * fork.cc (vfork): used to be in libcfork.cc - * (__fork): used to be in libcfork.cc - * (fork): used to be in libcfork.cc - * Makefile.in: don't build libcfork.cc any more - * libccrt0.cc: set data_start, etc. from dll structure - * winsup.h: add data_start, etc. to public vars in dll - * cygwin.din: list fork - -Thu Aug 22 01:36:53 1996 Geoffrey Noer - - * registry.cc: fix new registry code - * syscalls.cc: make Windows95 check function extern "C" - -Wed Aug 21 16:15:47 1996 Geoffrey Noer - - * cygwin.din: list vfork - * dirsearch.cc: fix errno setting in readdir that caused - diff to not function on directories - * pipe.cc: reformatted - -Wed Aug 21 15:12:47 1996 Jeremy Allison - - * net.cc (domainname): Changed getdomainname to get the - information from the registry. - * registry.h: Modified interface to reg_key. - * registry.cc: Added open(),close() calls, made - get/set string values return error indication, added trailing - underscore to hkey member so it can be seen to - be a class member. - * include/winadvapi.h: Added KEY_READ and KEY write - defines for registry access. - -Mon Aug 19 09:22:35 1996 Doug Evans - - * path.cc (split_path): New function. - * path.h (split_path): Declare it. - * cygwin.din (cygwin32_split_path): Export it. - - * include/winkernel.h (FILE_SHARE_DELETE): Define. - - * syscalls.cc (__do_global_[cd]tors], __main): Move from here. - * dcrt0.cc: To here. - - * dcrt0.cc (recur): Restore (now that we know WHY it was needed). - (dll_crt0_1): Probe forked child's stack out. - - * fork.cc (FORK_WAIT_TIMEOUT): Bump up to two minutes. - - * fork.cc (dump_jmp_buf): New function. - (cygwin_fork_helper1): Call it. - * dcrt0.cc (dll_crt0:1): Call it. - * winsup.h (dump_jmp_buf): Declare it. - - * fork.cc (cygwin_fork_helper1): Reenable child suspend before - stack copy code. - -Sat Aug 17 04:06:36 1996 Geoffrey Noer - - * dirsearch.cc: reformatted, removed a couple of gotos - -Thu Aug 15 17:56:08 1996 Geoffrey Noer - - * cygwin.din: added __eprintf, a newlib function needed by assert. - * times.cc: swap gmtime and localtime (gmtime really was localtime - and vice versa). - -Tue Aug 13 03:46:22 1996 Geoffrey Noer - - * signal.cc: renamed all signal variables "sig", - fixed signal range error checking in all relevant functions, - (sigaddset): new - (sigismember): new - (sigfillset): new - (sigemptyset): new - * cygwin.din: added corresponding entries for new signal functions. - * cygwin.h: added protos for them - * fhandler.cc, fhandler.h: major reformat of code - * net.cc (cygwin32_socket): call checkinit() at start to - initialize WinSock in case it isn't already. - * syscalls.cc (access): set errno appropriately when no - write access - * fcntl.cc: reformatting - -Sat Aug 10 16:30:14 1996 Geoffrey Noer - - * signal.cc (_raise): rewrite to shorten code, corrected - return values. - * fcntl.cc, net.cc, signal.cc, stubs.c: reformatted, added - public domain notice at the tops if they were missing. - -Fri Aug 9 18:19:12 1996 Geoffrey Noer - - * syscalls.cc (_rename): return -1 if file to be renamed - doesn't exist. Reformatted whole file. - * fork.cc: increase timeout value to 60 sec from 30 sec - -Thu Aug 8 17:44:39 1996 Jim Wilson - - * config/i386/longjmp.c: Increment %eax if it is zero. - -Wed Aug 7 15:51:04 1996 Geoffrey Noer - - * include/sys/mman.h: fixed defines for PROT_READ et al to - match what's more normally there in unix - * sysdef/i386/*: removed the extra underscores present in most - of these files that shouldn't have been there - * net.cc: cleaned up whitespace, formatting - -Tue Jul 16 12:43:16 1996 Doug Evans - - * libccrt0.cc (__version): Deleted, unused. - - * uname.c (uname): Print CYGWIN_DLL_VERSION is version field. - -Mon Jul 15 16:48:29 1996 Doug Evans - - * version.h (CYGWIN_DLL_VERSION_MINOR): Bump up to 1. - - Path handling clean up, pass 2 (use //, not /..). - * path.cc (SLASH_DRIVE_PREFIX_LEN): Delete. - (slash_drive_to_win32_path): New function. - (mount_info::posix_path_p): Delete support for $CYGWIN, - always return 1. - (path_conv::path_conv): Call slash_drive_to_win32_path. - (mount_info::conv_to_win32_path): Renamed from - posix_path_to_win32_path. All callers updated. - (mount_info::conv_to_posix_path): Renamed from - win32_path_to_posix_path. All callers updated. - (normalize_posix_path): Keep two leading /'s (or \'s). - (normalize_win32_path): Likewise. - (conv_to_{win32,posix}_path): Renamed from - {posix,win32}_path_to_{win32,posix}_path_keep_rel. - (conv_to_full_{win32,posix}_path): Renamed from - {posix,win32}_path_to_full_{win32,posix}_path. - (posix_path_list_p): New function. - (cygwin32_{unix,dos}_path_to_{dos,unix}_path_keep_rel): Delete. - ({unix,dos}_path_to_{dos,unix}_path): Delete. - ({win32,posix}_to_{posix,win32}_path_list_buf_size): Renamed from - cygwin32_{win32,posix}_to_{posix,win32}_path_list_buf_size. - ({win32,posix}_to_{posix,win32}_path_list): Renamed from - cygwin32_{win32,posix}_to_{posix,win32}_path_list. - (slash_drive_prefix_p): Recognize //, not /.. - (build_slash_drive_prefix): Update. - * path.h: Update. - * cygwin.din ({dos,unix}_path_to_{unix,dos}_path): Delete. - (cygwin32_{dos,unix}_path_to_{unix,dos}_path_keep_rel): Delete. - (cygwin32_conv_to_{posix,win32}_path): Renamed from - (cygwin32_{win32,posix}_path_to_{posix,win32}_path_keep_rel. - (cygwin32_conv_to_full_{posix,win32}): New exports. - (cygwin32_posix_path_list_p): New export. - * dcrt0.cc (path_len): Delete. - (PATH_ENV_BUF_SIZE): Delete. - (conv_path_names): Delete all but PATH. - (dll_crt0_1): Rewrite environment variable conversion code. - * fork.cc (find_exec_1): Delete _SC_PATH_RULES support. Determine - path delimiter by calling posix_path_list_p. - * shared.cc (shared_info::initialize): Delete `path_rules'. - * sysconf.cc (sysconf): Delete _SC_PATH_RULES. - * winsup.h (shared_info): Delete `path_rules'. - - * fork.cc (cygwin_fork_helper1): Reset u->forkee after child has - started. - - * pinfo.cc (pinfo::init_from_fork): Delete. Empty function. - * fork.cc (cygwin_fork_helper1): Delete call to it. - - * utils/kill.cc (usage): New function. - (main): Allow multiple pids to be passed. Call usage. - -Mon Jul 15 13:07:23 1996 Michael Meissner - - * Makefile.in (install): If cross compiling, install the - cygwin.dll file as $target_alias-cygwin.dll in the bin directory, - instead of plain cygin.dll. - Install the cygwin.dll file in the library directory as well. - - * configure.in: Test for cross compiling, and if cross compiling, - transform name of cygwin.dll file in the binary directory. - - * configure: Regenerate. - - * utils/Makefile.in (Makefile): Rebuild Makefile if configure.in - changes. - (install): Use the toplevel install.sh to install the utilities, - and transform the name if cross compiling. - - * utils/configure.in: Test for cross compiling, and if cross - compiling, tranform mount, umount, ps, etc. Do not call - AC_PROG_INSTALL anymore. - - * utils/configure: Regenerate. - -Fri Jul 12 16:25:09 1996 Geoffrey Noer - - * Makefile.in: also make install in utils subdir so "mount" - et al gets installed. - -Thu Jul 11 17:53:31 1996 Geoffrey Noer - - * include/sys/param.h: fixed value of HZ (now 1000 instead of 100). - caused bug that showed up as "time sleep 5" returning 50. - -Thu Jul 11 14:08:09 1996 Geoffrey Noer - - * fhandler.cc: correct typo in comment - * exceptions.cc: remove definition of sig_func_ptr, replace - occurances with newlib-defined _sig_func_ptr. - -Wed Jul 10 19:12:18 1996 Doug Evans - - * version.h (CYGWIN_DLL_VERSION_{MAJOR,MINOR}): Bump up to 17.0. - * winsup.h (class per_process): New members {public,internal}_reserved. - (SIZEOF_PER_PROCESS): Define. - * dcrt0.cc (dll_crt0_1): Add sanity check of per_process size. - Don't call checkout for forkee. - * libccrt0.cc (cygwin_crt0): Set magic_biscuit to sizeof per_process - again. - - * utils/ps.cc (main): Print uid. - - * hinfo.h: Deleted. Contents moved to winsup.h. - * Makefile.in (WINSUP_H): Update. - - * dcrt0.cc (u, environ): Moved here. - * shared.cc: From here. - - * pinfo.cc (pinfo_init): Renamed from pinfo_init_per_process. - All callers updated. - * hinfo.cc (hmap_init): Renamed from hmap_init_per_process. - All callers updated. - * winsup.h (cygwin_parent_p): Renamed from invoked_by_cygwin_p. - All uses updated. - - * fork.cc (prepare_child): Add debug message. - - * uinfo.cc (uinfo_init): Renamed from uinfo::init. - All callers updated. Call getlogin instead of GetUserName. - (getlogin): Call GetUserName. - * winsup.h (class uinfo): Delete. Members uid,gid moved ... - (class pinfo): To here. All uses updated. - (class shared_info): Delete member `u'. - * fork.cc (cygwin_fork_helper1): Set child's uid,gid. - - * pinfo.cc (pinfo::clearout): Reset strace_mask_ptr. - - * shared.cc (open_shared_file_map): Add debugging message. - -Fri Jul 5 15:36:48 1996 Doug Evans - - * exceptions.cc (sig_func_ptr): New typedef. - (__stack_trace): Make i386 and ppc formats the same. - (sigfunc): Use sig_func_ptr. - (call_handler): Likewise. All callers updated. - (__cygwin_exception_handler): Handle exceptions before dll has - fully initialized. Only call dump_status once, like __stack_trace. - (really_exit): Call _exit, not exit. - - * hinfo.cc: Add copyright. - * uinfo.cc: Likewise. - - * passwd.c: Whitespace cleanup. - (search_for): Make static. - - * pinfo.cc (pinfo_list::init): Delete call to clearout vec[0]. - (pinfo::clearout): Reset more fields. - (pinfo_list::get_empty_pinfo): Delete printing of error messages - if table is full. - - * shared.cc (open_shared_file_map): Mark shared map as not inherited. - - * signal.cc (signal): Delete (void *) coersion of result. - (usleep): Convert microseconds to milliseconds. Delete second copy. - (_raise): Use _sig_func_ptr. - - * syscalls.h: Delete #include mntent.h, sys/types.h, string.h, - stdio.h, setjmp.h, stdlib.h, signal.h, sys/strace.h, unistd.h, - ctype.h, fcntl.h. - * winsup.h: #include sys/types.h, sys/strace.h, setjmp.h, signal.h, - string.h, windows.h. - * All necessary files updated. - - * winsup.h (class pinfo): Delete member localtime_buf. - * times.cc (corelocaltime): Use static local for localtime_buf. - - * winsup.h (class pinfo): Rename the_pid to pid. All uses updated. - Delete handle_valid_p, unused. Rename __sig_mask to sig_mask. - -Thu Jul 4 14:36:01 1996 Doug Evans - - * shared.h: Deleted. All files updated. - * winsup.h: shared.h contents moved here. - * Makefile.in (WINSUP_H): Update. - - * heap.cc: Renamed from pproc.cc. - (heap_init): Renamed from per_process::init. - In forkee initialization, ensure memory being reserved is at same - address as parent's. Commit forkee memory in one chunk. - (_sbrk): Moved here, - * syscalls.cc (_sbrk): From here. - * Makefile.in (DLL_OFILES): Update. - * dcrt0.cc (dll_crt0_1): Call heap_init instead of u->init. - * winsup.h (class per_process): Delete member `init'. - - * dcrt0.cc (recur): Delete. - (dos_argv_to_unix_argv): Delete. - - * delqueue.cc: Delete #include of delqueue.h, winerror.h - * winsup.h: #include delqueue.h. - - * exceptions.cc (ctrl_c_handler): Only require 13 ^c's to quit task. - - * fork.cc (fork_mutex,forkee_stopped,forker_stopped): New static - globals, were in class_shared info. - (fork_init,fork_terminate): New functions. - (prepare_child,cygwin_fork_helper1): Update. - (cygwin_fork_helper1): If fork disabled, return EAGAIN. - Delete unnecessary resetting of forkee_stopped event. - * winsup.h (fork_init,fork_terminate): Declare them. - * dcrt0.cc (dll_crt0_1): Call fork_init. - (_exit): Call fork_terminate. - * shared.c (shared_info::initialize): Delete init of fork stuff. - - * shared.c (h): New static global, was in class shared_info. - (shared_info::terminate): Delete, move contents into shared_terminate. - - * strace.cc (flush_p): New static global. - (strace_init): Don't clobber u->strace_mask if _STRACE_INHERIT set. - (__sys_printf): Only flush buffers if _STRACE_FLUSH. - * include/sys/strace.h (_STRACE_FLUSH,_STRACE_INHERIT): Define. - Reorganize bitmasks. - - * utils/ps.cc (main): Make output prettier. - -Wed Jul 3 12:30:24 1996 Doug Evans - - * utils/Makefile.in (mount,umount,ps,kill): Rewrite rules. - (PROGS): Add cygwin. - (cygwin): New target. - (install): Install all of $(PROGS). - * utils/cygwin.cc: New file. - - * pinfo.cc (pinfo_init_per_process): PID environment variable handling - moved here. Delete setting of u->parent. Set strace_mask_ptr. - Set invoked_by_cygwin_p appropriately. - (vfork_init): Delete, unused. - (pinfo::init_self): Delete setting of root_p. - (pinfo::terminate): root_p renamed to invoked_by_cygwin_p. - * winsup.h (class per_process): Delete initial_pid, no longer used. - (class pinfo): Add strace_mask_ptr. - * fork.cc (cygwin_fork_helper1): Update. - - * winsup.h (class per_process): Delete trace_file, trace_mutex. - Rename estrace to strace_mask. - (system_printf): Declare. - * strace.cc (strace_init): Renamed from per_process::strace_init. - Don't open trace file unless strace environment variable set. - Open trace file with FILE_SHARE_READ so others can read trace file - while tracing in progress. Print error if $strace too big. - (strace_file, strace_mutex): New static globals. - (__sys_printf): Don't do anything if strace file not opened. - (system_printf): New function. - * pproc.cc (per_process::init): Delete call to strace_init. - * dcrt0 (dll_crt0_1): Call strace_init as soon as possible. - - * dcrt0 (dll_crt0_1): Delete local can_glob, use - u->self->invoked_by_cygwin_p instead. - Move PID environment variable handling into pinfo_init_per_process. - Delete setting of u->self->in_bash. - Delete watching for bash. - * winsup.h (class pinfo): Delete in_bash. - - * exceptions.cc (*): Call system_printf, not __sys_printf. - - * shared.h (class shared_info): Delete pp, unused. - - * syscalls.cc (isatty): Replace ttyname with is_tty. - - * winsup.h (registry_init_once_only): Delete, unused. - (stdout_handle,file_handle_from_fd): Likewise. - (CHILD_P,child_p,ALL_FS,loadup_dll,cygwin_s): Likewise. - (unmixedcaseify): Prototype moved to path.h. - * path.h (unmixedcaseify): Declare. - - * fork.cc (FORK_WAIT_TIMEOUT, WAIT_ERROR_RC): Define. - (find_exec_1): Don't search PATH if directory present (not only if - absolute path). Search "." before searching PATH. - (copy): Return boolean indicating success. All callers updated. - (prepare_child): Simplify. Check return code of WaitForSingleObject. - Don't wait an infinite amount of time. - (cygwin_fork_helper1): Simplify. - Check return code of WaitForSingleObject. - Don't wait an infinite amount of time. - Check return code of copy. - Disable code to Suspend/Resume child thread a second time. - - * winsup.h (class per_process): Make initial_sp a char *. - * libccrt0.cc (cygwin_crt0): Update. - - * path.cc (path_conv): If name too long, set path to bogus value. - - * include/winkernel.h (WriteProcessMemory): Fix prototype. - - * include/sys/strace.h: Add extern "C" ifdef __cplusplus. - (_STRACE): Delete. - * dirsearch.cc (rewinddir): Use syscall_printf. - -Tue Jul 2 14:44:18 1996 Doug Evans - - * wait.cc (WAIT_ERROR_RC): Use it instead of ALL_FS. - (wait_found): New argument `options'. If GetExitCodeProcess fails, - ensure `result' contains something reasonable. - (wait_for_single): Check whether `c' is NULL before dereferencing it. - (wait_for_any): Add some comments. Delete unnecessary gotos. - (waitpid): Print message if called with intpid == 0. - -Sat Jun 29 10:49:28 1996 Doug Evans - - * dirsearch.cc (readdir): Clean up syscall tracing. - Mixed case handling temporarily disabled. - -Wed Jun 26 11:54:27 1996 Jason Molenda (crash@godzilla.cygnus.co.jp) - - * Makefile.in (bindir, libdir, datadir, infodir, includedir): - Use autoconf-set values. - (docdir): Removed. - (install-info): Add. - * configure.in (AC_PREREQ): autoconf 2.5 or higher. - * configure: Rebuilt. - * glob/configure.in (AC_PREREQ): autoconf 2.5 or higher. - * glob/configure: Rebuilt. - * utils/Makefile.in (bindir, exec_prefix): Use autoconf-set values. - * utils/configure.in (AC_PREREQ): autoconf 2.5 or higher. - * utils/configure: Rebuilt. - -Tue Jun 25 17:48:56 1996 Doug Evans - - * include/sys/param.h (PATH_MAX,MAXPATHLEN): Change from 1024 to 259. - (BIG_ENDIAN,LITTLE_ENDIAN,BYTE_ORDER): Define. - -Mon Jun 24 16:35:48 1996 Mark Eichin - - * fhandler.cc (read): Replace the old broken igncr code (which has - been disabled for a while anyway) with code that checks for - ENABLE_LINE_INPUT and replace only \r\n with \n. - -Mon Jun 24 00:12:22 1996 Doug Evans - - * dcrt0.cc (dll_crt0_1): Convert argv[0] to posix style if necessary. - -Sun Jun 23 17:21:41 1996 Doug Evans - - * version.h (CYGWIN_DLL_VERSION_MINOR): Bump up to 2. - - * fork.cc (perhaps_suffix): Simplify. - (find_exec_1): Likewise. Always try appending .exe first. - (cygwin_fork_helper1): Clean up (lots more needed still). - Test for split heap before calling CreateProcess. - No longer call find_exec, now done at start up. - * dcrt0.cc (dll_crt0_1): Call find_exec to expand argv[0]. - - * path.cc (conv_path_list_buf_size): New function. - (cygwin32_{win32,posix}_to_{posix,win32}_path_list_buf_size): Ditto. - (conv_path_list): Ditto. - (cygwin32_{win32,posix}_to_{posix,win32}_path_list): Ditto. - * cygwin.din: Export them. - - * misc.c (small_printf): Delete. - (vhangup): Set errno. - - * syscalls.cc (isatty): Print syscall trace message even if error. - - * console.cc (*): Check return codes of win32 api calls. - - * syscalls.cc (chmod): Set errno of SetFileAttributes fails. - Fix call to syscall_printf. - -Thu Jun 20 00:43:52 1996 Doug Evans - - * dcrt0.cc (dll_crt0_1): Save full program name. - * fork.cc (cygwin_fork_helper1): Always call find_exec. - - * path.cc (normalize_{posix,win32}_path): Fix edge case handling. - (path_conv::path_conv): Ensure path is \-ified if win32 path rules. - - * spawn.cc (spawn_guts): Set errno if CreateProcess fails. - -Wed Jun 19 00:18:03 1996 Doug Evans - - * path.h (PATH_RULES macros): Delete. Use ones in unistd.h. - (enum path_rules_enum): Deleted. All uses updated. - (path_conv): Rename member get_native to get_win32. All uses updated. - (*win32_path*): Renamed from *native_path*. - * path.cc (*win32_path*): Renamed from *native_path*. - (mount_info::posix_path_p): Prepend '_' to PATH_RULES. - Fix returning of cached value. - (slash_drive_prefix_p, build_slash_drive_prefix): New functions. - (mount_info::posix_path_to_win32_path): /.. is a drive spec. - (path_conv::path_conv): Likewise. - (mount_info::win32_path_to_posix_path): Convert unknown drives to - /.. Normalize win32_path. - (normalize_win32_path): New functions. - (getcwd_inner): New arg `posix_p'. All callers updated. - * shared.cc (shared_info::initialize): Prepend '_' to PATH_RULES. - _PATH_RULES_NATIVE -> _PATH_RULES_WIN32. - * spawn.cc (*win32_path*): Renamed from *native_path*. - * dcrt0.cc: Likewise. - * cygwin.din: Likewise. - - * Makefile.in (WINSUP_H): Add shared.h - - * smallprint.c (rn): Make static. - - * sysconf.cc: Renamed from sysconf.c. - (sysconf): Support _SC_PATH_RULES. - - * screen.c: Deleted. - * Makefile.in (DLL_OFILES): Delete screen.o. - - * fork.cc (cygwin_fork_helper): Don't pass 0 from longjmp to setjmp. - - * path.h (class mount_info): Update posix_path_to_native_path member. - * path.cc (path_prefix_p): Rewrite. - New arg `len'. All callers updated. - (mount_info::binary_native_path_p): Call path_prefix_p. - (path_conv::path_conv): Pass full_path to binary_native_path_p. - (mount_info::posix_path_to_native_path): Delete arg keep_rel_p. - New arg full_native_path. All callers updated. Don't call - getcwd_inner if unnecessary. Rewrite relative path handling. - (mount_info::native_path_to_posix_path): Call path_prefix_p. - Call slashify on `pathbuf', not original argument. - - * syscalls.cc (chdir): Fix lifetime of converted path. - -Tue Jun 18 11:48:51 1996 Doug Evans - - * configure.in (EXE_LDFLAGS): Explicitly link with newlib if necessary. - * configure: Regenerated. - * Makefile.in (EXE_LDFLAGS): Define. - (FLAGS_TO_PASS): Add EXE_LDFLAGS. - (config.status): New target. - (utils-all): Depend on $(LIBNAME). - * utils/Makefile.in (EXE_LDFLAGS): Define. - (mount,umount,ps,kill): Link with $(EXE_LDFLAGS). - - * version.h (CYGWIN_DLL_VERSION_MINOR): Bump up to 1. - -Mon Jun 17 18:29:54 1996 Doug Evans - - Improve pathname handling, first pass. - * path.h (symlink): Renamed from link_cookie. - (class path_conv): New member error. - (path_conv::get_native): Renamed from get_dos, all uses updated. - (path_conv::get_binary): Delete. - (mount_info::{mangle,reverse_mangle}): Delete. - (mount_item::posix_path_to_native_path): Renamed from mangle. - (mount_info::native_path_to_posix_path): Renamed from reverse_mangle. - (path_rules_enum): Define. - * path.cc: Temporarily disable mixed-case and symlink handling. - (mount_info::posix_path_p): New function. - (mount_info::binary_native_path_p): Renamed from binary_dos_path_p. - (path_conv::path_conv): Handle native path rules. - (mount_item::{mangle,reverse_mangle}): Delete. - (mount_info::posix_path_to_native_path): Renamed from mangle. - (mount_info::native_path_to_posix_path): Renamed from reverse_mangle. - (mount_info::from_registry): Set nmounts. Use MAX_PATH. - (mount_info::{add,del}_item): Rewrite. - (slashify): Renamed from flip_slash. - (getcwd_inner): Make static. Don't convert to posix path if using - native path rules. - (file_exists): Delete. - (addmntent,hasmntopt): Delete. - (mount): Only update registry if mount succeeded. - (umount): Only update registry if umount succeeded. - (normalize_posix_path): Renamed from normalize_path. Pass in cwd. - (cygwin32_{posix,native}_path_to_{native,posix}_path_keep_rel): Renamed - from ...{unix/dos}.... - * dcrt0.cc (dos_argv_to_unix_argv): #ifdef out. - (dll_crt0_1): Don't call it. - * fhandler.cc (fhandler_base::open): Temporarily disable symlinks. - * shared.cc (open_shared_file_map): New function. - (shared_init): Call it. - (shared_info::initialize): Fetch `path_rules' from registry. - * shared.h (inited): Make private. - (path_rules): New member. - * spawn.cc: #include "shared.h". - (spawn_guts, env var translation): Don't translate path names if - using native path rules. - * syscalls.cc (symlink): Delete (moved to path.cc). - * cygwin.din (dump__5pinfo): Delete. - (cygwin32_{posix,native}_path_to_{native,posix}_path_keep_rel): Renamed - from ...{unix/dos}.... - - * smallout.cc: Delete. - * sdata.cc: Delete. - * shared.cc (u,s,environ): Define here. - * Makefile.in (glob/libglob.a): Depend on glob/glob.c, glob/fnmatch.c. - (utils-all): New target. - (DLL_OFILES): Delete smallout.o, sdata.o. - (Makefile): Depend on cygwin.din. - (WINSUP_H): Depend on syscalls.h. - - * configure.in (AC_CONFIG_SUBDIRS): Add bin. - (AC_PROG_INSTALL): Call. - * configure: Regenerated. - * utils/{Makefile.in,configure.in,configure}: New files. - * utils/{kill.cc,mount.cc,ps.cc,umount.cc,termcap}: New files. - * Makefile.in (UTILS_ALL): Define. - (all): Depend on $(UTILS_ALL). - (utils-all): New target. - - * dcrt0.cc (recur): Make no-op to see what happens. - (globify): Don't call glob if unnecessary. - Check return code from glob. - (api_fatal): New function. - * fhandler.cc (fhandler_base::read): Dump first few chars read. - (fhandler_base::get_execable): New function. - (fhandler_base::fstat): Use it. - (fhandler_base::fhandler_base): Init execable_p. - (fhandler_disk_file::fhandler_disk_file): Delete execable_p. - (fhandler::{get,set}_execable_bit): Delete. - (fhandler_disk_file::{get,set}_execable_bit): Delete. - * fhandler.h (class fhandler): Delete {get,set}_execable_bit. - (class fhandler_base): New member execable_p. - New member fn get_execable. - * fork.cc: Simplify/cleanup. - (cygwin_fork_helper1): Use MAX_PATH, not MAXPATHLEN. - * pinfo.cc (pinfo::dump): Delete. - * pproc.cc (per_process::set_envname): Delete. - * strace.cc (smallout::do_pline): Delete. - * syscalls.h (readlink): Third arg is an int. - * winsup.h (class pinfo, member progname): Use MAX_PATH. - (class pinfo, member dump): Delete. - (class smallout): Delete. - (smallout): Delete. - (class per_process, member set_envname): Delete. - (file_exists): Delete. - (api_fatal): Declare. - * Makefile.in (LIB{C,CXX}FLAGS_FOR_TARGET): Delete, use {C,CXX}FLAGS. - (FLAGS_TO_PASS): Define. - (glob/libglob.a): Delete duplicate entry. - - * syscalls.cc (_sbrk): Update u->size when heap is grown. - - * hinfo.cc (hmap_init_per_process): Ensure stdout's handle != stderr's. - -Fri Jun 14 06:32:13 1996 Doug Evans - - * register.h, registry.cc: Whitespace cleanup. - -Thu Jun 13 20:57:28 1996 Doug Evans - - * Makefile.in (install): Install cygwin.dll in $(bindir). - -Tue Jun 11 13:46:17 1996 Geoffrey Noer - - * fhandler.cc: lseek is now only binary mode, interpret control - z characters as EOF when reading from a file. Reformatted some - of the code (cleaned up line spacing, etc.) - -Tue Jun 11 09:50:09 1996 Jason Molenda (crash@kyriath.cygnus.com) - - * path.cc (nofinalslash): move it so it is next to its friends - flip_slash and backslashify. - -Mon Jun 10 18:57:03 1996 Jason Molenda (crash@kyriath.cygnus.com) - - * path.cc (*): Pretty printing. - (unix_path_to_dos_path_with_rel): use "dosnamein" and "unixnameout" - instead of "path" & "real_path". - (dos_path_to_unix_path_keep_rel): delete obsolete code. - (mount_item::mangle): use "unixnamein" and "dosnameout" instead of - "unixname" and "dosname". - (mount_info::mangle): use "unixnamein" and "dosnameout". Remove - obsolete code. - * path.h (mount_item): Update prototypes, add comment. - (mount_info): Update prototypes. - -Mon Jun 10 17:05:23 1996 Jason Molenda (crash@kyriath.cygnus.com) - - * path.cc (mount_item::reverse_mangle): Pretty printing, - add a bit to the comment. - (getcwd_inner): use MAX_PATH not MAXPATHLEN. - (normalize_path): use MAX_PATH not MAXPATHLEN. - (link_cookie::follow): use MAX_PATH not MAXPATHLEN. - -Mon Jun 10 15:36:32 1996 Geoffrey Noer - - * Makefile.in: changed $(DOC) so it doesn't include html - files; made a new info-html target that does the html - versions of the docs. Since most customers don't have texi2html - installed, the make shouldn't fail because of this. - * configure: regenerated with autoconf 2.8 - -Sun Jun 9 17:10:37 1996 Doug Evans - - * version.c: Deleted. - * version.h: New file. - * winsup.h (VERSION): Deleted. - (class per_process): Add version_major, version_minor. Delete version. - * registry.cc: #include "version.h". - (reg_session::reg_session): Update. - * libccrt0.cc: #include "version.h" - (cygwin_crt0): Delete setting of version, set magic_biscuit to 0. - Set version_major, version_minor. - * dcrt0.cc: #include "version.h". - (cygwin_dll_version_{major,minor}): New static locals. - (dll_crt0_1): Rewrite app/dll compatibility test. - * Makefile.in (LIBCOS): Delete version.o. - (DLL_OFILES): Delete version.o. - (dcrt0.o,libccrt0.o,registry.o): Depend on version.h. - - * exceptions.h: New file. - * exceptions.cc: Massive cleanups (still lots more to go). - #include "exceptions.h". - (init_exceptions): Renamed from __init_exceptions. New argument of - pointer to exception handler list entry. - (init_exception_handler): Renamed from init_thread_exceptions. - Rewrite based on info from Onno Hovers . - (ppc descriptor_to_{function,gotattr}): Make static. - (i386 __stack_trace): Fix test for top of stack. - * dcrt0.cc: #include "exceptions.h". - (dll_crt0_1): Exception handler list entry must live on stack. - * winsup.h (class pinfo): Delete member myp. - * syscalls.h (struct exception_list): Delete. - (__really_exit, __init_exceptions): Delete. - * Makefile.in (dcrt0.o,exceptions.o): Depend on exceptions.h. - -Fri Jun 7 17:49:28 1996 Jason Molenda (crash@phydeaux.cygnus.com) - - * dcrt0.cc (conv_path_names): Add GCC_EXEC_PREFIX. - -Fri Jun 7 14:38:05 1996 Doug Evans - - * Makefile.in (CC_FOR_TARGET,LD,DLLTOOL): Define. - (AR,RANLIB): Set via configure. - * configure.in (AR,LD,DLLTOOL): Set. - (AC_PROG_RANLIB): Call. - * configure: Regenerated. - -Thu Jun 6 12:11:23 1996 Kim Knuttila - - * dcrt0.cc (dll_crt0_1): Removed reference to reent_data._next. - -Tue Jun 4 15:52:29 1996 Geoffrey Noer - - * include/winkernel.h: fixed typo - -Tue May 28 13:08:25 1996 Doug Evans - - * syscalls.cc (_sbrk): Fix test of return value from VirtualAlloc. - Delete lincr, make incr signed, and use only it. Misc. minor cleanup. - -Thu May 23 17:31:57 1996 Geoffrey Noer - - sac diffs applied: - * path.h: change MAXMOUNTS to 30 instead of 20 - * sysdef/i386/rpcndr.def: add "none" to end of file - * fhandler.cc: fix memset call to say sizeof (*buf) instead - of sizeof (buf). - * include/winuser.h: define MDIS_ALLCHILDSTYLES - * Makefile.in: entry to build glob/libglob.a: - -Thu May 23 10:38:43 1996 Doug Evans - - * fhandler.h (class fhandler_base): Make `name' private and shrink - to 32 bytes. - (set_name): Declare. - * fhandler.cc (fhandler::set_name): New function. - (fhander_base::open): Call it. - (fhander_base::init): Call it. - (fhandler_tty::ttyname): Call get_name instead of accessing `name' - directly. - - * dcrt0.cc (dll_crt0_1): Call ExitProcess instead of exit if - DLL and APP are out of sync. - -Thu May 16 03:07:18 1996 Mark Eichin - - * fhandler.cc (FakeReadFile): new function. Interface like - ReadFile, only called from fhandler_console_in::read, calls - ReadFile unless we're really reading from STD_INPUT_HANDLE and - with ENABLE_LINE_INPUT turned off, in which case we use - ReadConsoleInput instead. When using ReadConsoleInput, always read - all available events, but only block if we don't get at least one - actual character. This would be the place to implement FIONBIO on - the console tty, which doesn't actually exist yet. - (dbg_input_event): copied from select.cc, debugging code to show - detail of what events we're actually getting. - (ioctl): off-by-one on window size. - -Wed May 15 18:11:16 1996 Jim Wilson - - * fhandler.h (class fhandler_base): Use MAXPATHLEN not 100 for size - of array name. - -Wed May 15 11:14:46 1996 Doug Evans - - * fork.cc (cygwin_fork_helper1): More debugging printf's. - - * dcrt0.cc (num_ms_env_vars): Renamed from ms_env_arity. - (build_argv): Renamed from fill. - (compute_argc): Renamed from prepare. - * libccrt0.cc (cygwin_statu): Make static. - * pproc.cc (per_process::init): Move strace initialization from here, - * strace.cc (per_process::strace_init): To here. - Pass FILE_SHARE_WRITE to CreateFileA. Print error message if open - of log file fails. Create mutex for trace messages. - (__sys_printf): Always write to end of disk files. Use mutex. - (d): Delete. - * winsup.h (class per_process): Add strace_init. Reorganize. - `run_ctors' renamed to `run_ctors_p'. New member `trace_mutex'. - (d): Delete. - (PATH_MAX): Delete. - - * Makefile.in: Add header file dependencies. - - * dcrt0.cc (_exit): Add debugging printf. - * shared.h (class shared_info): Rename member mutex_a to fork_mutex. - * fork.cc (cygwin_fork_helper1): Update. - Return with error if process slot unavailable. - Set errno and release fork_mutex if failed because of split heap. - * shared.cc (shared_info::terminate): Update. - (shared_info::initialize): Update. - -Tue May 14 14:59:32 1996 Doug Evans - - * fork.cc (cygwin_fork_helper1): Avoid SIGSEGV if allocate_pid fails. - - * pproc.cc (per_process::init): Fix test. - - * winsup.h (): Rename member `parent' to `ppid'. - * fork.cc (prepare_child): Update. - (cygwin_fork_helper1): Likewise. - * hinfo.cc (hmap_init_per_process): Likewise. - (hinfo_vec::dup_for_fork): Fix message. - (hinfo_vec::dup2): Fix args to debug_printf. Delete extra printf's. - * pinfo.cc (pinfo_init_per_process): Update. - (pinfo::dump): Likewise. - (pinfo::init_self): Likewise. - * pproc.cc (per_process::init): Open strace file in append mode. - * smallprintf.c (__small_vsprintf): Support %p. - * syscalls.cc (getppid): Update. - * wait.cc (wait_for_any): Likewise. - -Mon May 13 13:45:36 1996 Mark Eichin - - * fhandler.cc (ioctl): fix TIOCGWINSZ handling: (1) check the - error return (2) if we're trying on STD_INPUT_HANDLE, substitute - STD_OUTPUT_HANDLE since GetConsoleScreenBufferInfo only works on - console output (3) check srWindow for the *screen* size, instead - of checking dwSize for the scroll buffer size. - - * include/sys/errno.h (ECONNABORTED): add another errno value. - * net.cc (errmap): add ECONNABORTED case. - - * fhandler.cc (fstat): clear the *entire* stat buf, not just the - first four bytes. - -Fri May 10 17:59:09 1996 Mark Eichin - - * select.cc: change most debugging statements to select_printf. - (dbg_input_event): new function, prints an INPUT_RECORD via select - printf. - (polled): Don't sleep around WaitForMultipleObjects; let it have a - 10ms timeout until we have time to test it with 0. If - WaitForMultipleObjects says that STD_INPUT_HANDLE has data, use - PeekConsoleInput to scan the available events. If the first one is - not a *bKeyDown* with a non-zero *AsciiChar* then use - ReadConsoleInput to rip it off the queue, and pretend it wasn't - there, so that later calls to read (and thus ReadFile) don't block - because they can't find any *real* input. (This could be optimized - later to check the whole queue, and if there are *no* real input - events, nuke them all.) - - * include/sys/strace.h (_STRACE_SELECT, select_printf): new printf - category, because select needs a *lot* of work. STRACE=256 to use it. - - * fhandler.cc (fhandler_console_in::init): IGNCR can't work - without major changes to deal with the interaction with select - (which shouldn't wake up if IGNCR causes the whole input to be - deleted...) so don't make it the default. - (fhandler_console_out::tcgetattr, fhandler_tty::tcgetattr): don't - set IGNCR based on get_r_binary either. - -Wed May 8 20:20:05 1996 Mark Eichin - - * times.cc (__to_clock_t): must cast dwLowDateTime to *unsigned* - before adding it -- otherwise we may subtract it! - (to_time_t): same. - -Wed May 8 18:21:28 1996 Mark Eichin - - * times.cc (corelocaltime): new function. Basic localtime from - newlib, with no conversions. - (gmtime): just calls corelocaltime. - (localtime): uses GetTimeZoneInformation, biases to standard time - first, then uses DaylightDate and StandardDate to figure out if - we're in DST -- and calls corelocaltime a second time with the - rebiased seconds, if we are. - (times): add debug_printf statements which work around apparent - compiler bug and 7+ minute error. - - * select.cc: revert to 's changes of 4/20 which were - accidentally backed out on 4/24. - -Tue May 7 05:29:42 1996 Mark Eichin - - * times.cc (__to_clock_t): subtract out FACTOR, the difference - between 1601 and 1970, just like to_time_t() does. - -Tue May 7 01:55:06 1996 Mark Eichin - - * times.cc (gmtime): new function. Use GetTimeZoneInformation to - compensate ahead before calling localtime (since the newlib - version doesn't know what timezone we're in.) - (localtime): use SECSPERMIN, not 60, to show that we know what - we're talking about. - - * net.cc (errmap): add WSAEADDRINUSE, WSAECONNREFUSED mappings. - -Sun May 5 00:45:59 1996 Mark Eichin - - * include/sys/socket.h: add recvfrom macro and cygwin32_recvfrom - declaration. Remove htons/htonl misdeclarations as they collide - with the macros in asm/byteorder.h. - - * include/asm/byteorder.h: enable the ntohl/ntohs declarations so - we at least get the macro versions when we optimize, even if the - library hooks aren't there. - -Wed Apr 24 23:42:49 1996 Steve Chamberlain - - * winsup.h (pinfo, pinfo_list): Remove dummy item. - * fork.cc (*): Revert changes of Apr 2. - -Sun Apr 21 17:00:14 1996 Steve Chamberlain - - * wait.cc (wait_for_any): Fix the wait heuristic. - -Sat Apr 20 13:22:03 1996 Steve Chamberlain - - * Makefile.in (.cc.o): Pass -fno-rtti. - * dcrt0.cc (globify): A single match is ok. - * exceptions.cc (i386 call_handler): optimize. - * fhandler.cc (fhandler_console_in::read): Handle ICRNL right. - (*:get_name *:always_ready): New. - * select.cc: Understand that console output doesn't signal when it's - ready. - -Fri Apr 12 14:49:34 1996 Doug Evans - - * Makefile.in (glob/libglob.a): Pass -I so glob.c finds right dirent.h. - -Wed Apr 10 16:13:30 1996 steve chamberlain - - * Makefile.in (glob/libglob.a): Call glob makefile correctly. - * winsup.h (pinfo, pinfo_list): Reorder elements to avoid - alignment bug in PPC gcc. - -Tue Apr 9 17:23:57 1996 steve chamberlain - - * dcrt0.cc (globify): Expand command line wildcards if - run from dos prompt. - - * exceptions.cc (386 call_handler): More fumblings. - * fhandler.cc (fhandler_base::stat): Initialize ino. - (fhandler_console::open): Fix test for RDONLY. - (fhandler_tty::stat): Set ino. - (fhandler_console_out::vt100 stuff): More. - * fork.cc: Lint. - * pinfo.cc (pinfo::init_self): Don't bother to DuplicateHandles - to get process info. - * signal.cc (usleep): Get correct order of magnitude. - * spawn.cc (spawn_guts): Turn of exception handling in - parent of thing which execs. - * syscalls.cc (stat): Look for and . - * wait.cc (wait_for_any): Keep waiting if WaitForMultipleObject - returns invalid result. - -Tue Apr 2 12:45:35 1996 steve chamberlain - - * dcrt0.cc (conv_path_names): Add HOME. - (dll_crt0_1): Use u->self->head_sp. - * exceptions.cc (i386 call_handler): Rewritten, now almost works - on win95. - * fhandler.cc (fhandler_base::open): Calculate namehash. - (fhandler_base::fstat): ^ name hash with file index low. - * fork.cc (*): forkee/forkerr events moved from sinfo - into pinfo. - -Fri Mar 29 16:35:02 1996 steve chamberlain - - * libcmain.cc: New. - * winsup.h: restore and myp moved from per_process to pinfo class. - * dcrt0.cc (dll_crt0_1): Cope with move. - * exceptions.cc (init_thread_exceptions): Ditto. - * signal.cc (sigprocmask): Ditto. - * fork.cc (cygwin_fork_helper1): Don't fork if split_heap_p. - * pinfo.cc (pinfo::clearout): Zero split_heap_p. - * syscalls.cc (_sbrk): Cope with not being able to - allocate contiguous chunks. - - -Tue Mar 26 09:14:32 1996 steve chamberlain - - * exceptions.cc (__cygwin_exception_handler): re-export. - -Fri Mar 22 16:49:29 1996 Michael Meissner - - * cygwin.din (__stack_trace): Export. - (__cygwin_exception_handler): Ditto. - - * exceptions.cc (i386 exception handling): Move under appropriate - x86 #ifdefs. Use the macro HAVE_INIT_THREAD_EXCEPTIONS to be - whatever a machine needs to do to initialize exceptions in this - thread. Nop for the PowerPC right now. - (__stack_trace): Make it a "C" function so there is no name - mangling, and export it. - (call_handler): Split by architecture before the function, rather - than inside it. First stab at PowerPC exception handling. - (__cygwin_exception_handler): Rename from ehandler3, and export - it. Add more status -> signal mappings. - (ctrl_c_handler, CTRL_LOGOFF_EVENT): Map to SIGHUP, not SIGQUIT. - (__stack_trace): Split into separate machine dependent functions, - rather than #ifdef'ing inside of a common function. Make the - PowerPC messages clearer. - -Mon Mar 18 13:27:05 1996 Michael Meissner - - * include/winkernel.h (CreateThread): Correctly declare function - pointer argument. - - * misc.c (wprintf): Convert to use vprintf and fix warnings. - (tgetent): Declare to return int to fix warnings. - (vhangup): Declare to return int to fix warnings. Return -1 also. - - * include/winbase.h (UnhandledExceptionFilter): Declare. - -Tue Mar 12 12:56:28 1996 Doug Evans - - * include/winkernel.h (FlushFileBuffers): Declare. - -Tue Mar 12 11:16:32 1996 Michael Meissner - - * exceptions.cc (dump_status): Make columns line up for PowerPC. - (call_handler): Right now, call exit(255) for the PowerPC. - - * strace.cc (__sys_printf): Call FlushFileBuffers after writing - out the file to make sure it really gets flushed. - - * include/winkernel.h (PowerPC CONTEXT): Add fields returned if - CONTEXT_DEBUG_REGISTERS is set. - -Sun Mar 10 15:31:17 1996 Steve Chamberlain - - * strerror.cc, syslog.cc, net.cc: New files. - * cygwin.din: Add new net functions. - * dcrt0.cc (dll_crt0_1): Fix call to build argv[0]. - * fhandler.cc (fhandler_base::open): Tidy. - * fhandler.h: Add net classes. - * hinfo.cc (hinfo_vec::build_fhandler): Add tape stuff. - * path.cc (*::mangle, *::reverse_mangle): Fix. - (mount_info::init): No trailing / now. - * select.cc (*): Rewrite. - * spawn.cc (spawn_guts): Fix leak. - * syscalls.cc (_sbrk): Keep working until memory really fills up. - -Tue Feb 20 16:53:24 1996 Steve Chamberlain - - * dcrt0.cc (dll_crt0_1): Get version from the header. - * fhandler.cc (CHUNK_SIZE): New. - (fhandler_base::read, fhandler_base::write): CRLF conversion - rewritten. - path.cc (path_conv::path_conv): Initialize mixed, binary and silent. - * smallprint.c (__small_vsprintf): Add 'c' option. - * wait.cc (wait_found): Close child handles. - -Mon Feb 19 09:11:57 1996 Michael Meissner - - * Makefile.in (real-headers): Eliminate real-headers dependency on - mspatches/*.patch, since you can't be guaranteed that it exists. - -Fri Feb 16 14:24:47 1996 Michael Meissner - - * exceptions.cc (dump_status): On the PowerPC, dump all of the - integer registers. - - * uname.c (uname): Don't assume that the only two NT systems are - i386 and PowerPC. - * exceptions.cc (call_handler): Ditto. - (dump_status): Ditto. - -Thu Feb 15 18:20:33 1996 Steve Chamberlain - - * cygwin.din (__empty): Add. - * dcrt0.cc (dos_argv_to_unix_argv): New. - (check, onetimecheck): New. - * exceptions.cc (ehandler3): Always show backtrace - if exception failed. - * fhandler.cc (*::open): Removed dos_path argument. - (fhandler_base::fstat): Use nFileIndexLow as the inode - value. - * hinfo.cc (init_std_file_from_handle): Don't default - to binary. - * paths.cc (*): Use new registry classes. - * registry.cc (*): Rewritten. - * syscalls.cc (open): Call fhandler->open without - the dos filename arg. - -Sat Feb 10 08:18:45 1996 Michael Meissner - - * configure.in (ALLOCA for powerpc): Add __allocate_stack. - -Wed Feb 7 16:41:18 1996 Steve Chamberlain - - Release-B13 - - * malloc.cc (export_*): New. Changed the way that malloc - stubs are used. - * cygwin.din: Export the export_* stuff as malloc, realloc and free. - * path.cc (link_cookie::create): Keep cookie filenames in unix - format. - (reverse_mangle): Clean up. - (readlink): Ditto. - (qfunc): Sort by name too. - * spawn.cc (spawn_guts): Handle zero length arg. - Only set errno when it's not 0. - * Makefile.in: Build new doc. - * fhandler.cc (fhandler_base::fstat): Round up block used. - * path.cc (escape_char): Now it's ^. - * syscalls.cc (errmap): ERROR_INVALID_NAME yields ENOENT. - (chown): Returns 0. - (sbrk): Clean up. - (_unlink): Only try and DeleteFile once. - -Mon Feb 5 19:15:44 1996 Steve Chamberlain - - * dcrt0.cc (dll_crt0_1): Build env string into static buffer. - * dirsearch.c (opendir): Stat on unix pathname. - * paths.cc (*): Support for mixed case filenames. - -Sun Feb 4 15:55:58 1996 Steve Chamberlain - - * *.cc: Lint. - (conv_path_names): New. - (dll_crt0_1): Use conv_path_names list. - * fctnl.cc (F_DUPFD): Look from the fd forward. - * fhandler.cc (fhandler_base::open): Understand binary modes. - (fhandler_console_in::init): Call tcsetattr with reasonable start - values. - * spawn.cc (spawn_guts): Use conv_path_names. - (queue_file_deletion): Deleted. - (unlink): Use new queue file stuff. - * delqueue.cc, delqueue.h: New files. - * shared.h: New file. - -Wed Jan 31 11:12:24 1996 Steve Chamberlain - - * crt0.cc: Hacks to probe out ppc stack. - * exceptions.cc (ehander3): Don't use 386 context info on the ppc. - * path.cc (mount_info::mangle): Turn /usi or /usp into /usr. - * uname.c (uname): Change sysname and get ppc name right. - -Fri Jan 26 15:47:31 1996 Steve Chamberlain - - * pproc.cc (per_process::init): Cope when no memory is needed. - * Makefile.in, configure.in: Cope with config directory. - * setjmp.c, longjmp.c: Moved into config/i386. - * config/ppc/setjmp.S, config/ppc/longjmp.S: New. - -Fri Jan 26 14:57:33 1996 Jason Molenda (crash@phydeaux.cygnus.com) - - * Makefile.in (DLL_OFILES): removed ppc-stub.o - ppc-stub.c: Removed. - configure: regenerated with autoconf 2.7. - -Fri Jan 26 11:18:07 1996 Kim Knuttila - - * Makefile.in (DLL_OFILES): added ppc-stub.o - -Thu Jan 25 09:33:24 1996 Steve Chamberlain - - * malloc.cc (malloc, free, realloc): Hack for ppc. - -Wed Jan 24 20:22:42 1996 Steve Chamberlain - - * cygwin.dll (loadup_dll): Remove. - * dcrt0.cc: lint. - * fhandler.* (*): Move to new class structure. - * hinfo.cc: Use new fhandler glue. - * libcfork.cc: Cope with ppc naming convention. - -Mon Jan 22 10:33:53 1996 Steve Chamberlain - - * fhandler.h, hinfo.h: New files. - * winsup.h: Split from here. - * configure.in: Set i386 entry point correctly. - * fhandler.cc (fhandler_normal:open): .com files - are executable too. - * hinfo.cc (init_std_file_from_handle): Inspect - master_fmode_binary. - * misc.cc (wcscmp, wcslen): New. - * dcrt0.cc (probe): Change way a forkee's stack is allocated. - * pproc.cc (per_process::init): Initialize using heap chunk. - * shared.cc (shared_info::initialize): Initialize heap chunk. - * syscalls.cc (_sbrk): If current chunk is used, allocate another. - * wait.cc (wait_found): Fix exit code. - -Thu Jan 18 10:09:45 1996 Steve Chamberlain - - * fhandler.cc (fhandler_normal::open) Don't test a - com port to see if it's executable. - * configure.in, cygwin.din: More powerpc configury. - -Wed Jan 17 16:25:36 1996 Steve Chamberlain - - * configure.in, Makefile.in: Build powerpc stuff. - * hinfo.cc (build_fhandler): Use new with placement. - (fhandler::operator new): New. - -Wed Jan 3 18:18:57 1996 steve chamberlain - - * select.cc: New file. - * Makefile.in: Cope with it. - -Tue Jan 2 08:58:58 1996 steve chamberlain - - * version.c: New file. - * Makefile.in: Cope with it. - * cygwin.def (setgrent, cuserid, setpgrp, mount, setmntent, endmntent, umount): New. - * dcrt0.cc: Remove obsolete vfork stuff. - (dll_crt0): Change way environ is built. Check that app is built - with correct version of dll. - * dirsearch.cc, exceptions.cc: Lint. - * fhandler.cc: Lint. Most of termios.c moved into here. - (fhandler_console:*): New. - * hinfo.cc (hinfo_vec::init_std_file_from_handle): Open stdfiles as consoles - if possible. - * libccrt0.cc: Lint. - * malloc.cc: More comments. - * path.cc (*): Cope with mount handling. - * registry.cc: Lint. - (reg_session): New. - * shared.cc: Lint. - * signal.cc (usleep): New. - * spawn.cc: Lint. Removed vfork stuff. - * stubs.c (getmntent, endgrent): Deleted. - * syscalls.c (__seterrno): Now takes arguments. - * termios.c: Much moved info fhandler.c - * times.cc (utime, utimes): New. - * uinfo.c (cuserid): New. diff --git a/winsup/cygwin/ChangeLog-1997 b/winsup/cygwin/ChangeLog-1997 deleted file mode 100644 index 33b001154..000000000 --- a/winsup/cygwin/ChangeLog-1997 +++ /dev/null @@ -1,2800 +0,0 @@ -Wed Dec 31 15:00:32 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * hinfo.cc (hinfo_vec::find_unused_handle): correct - previous patch -- need to fix up vec[i].h pointers - -Wed Dec 31 14:13:22 1997 Ian Lance Taylor - - * regexp/Makefile.in (tooldir): New variable. - (install): Install regexp.h. - -Tue Dec 30 19:52:46 1997 Ian Lance Taylor - - * net.cc (inet_netof): New function. - (inet_makeaddr): New function. - * cygwin.din: Export inet_netof and inet_makeaddr. - -Tue Dec 23 17:45:07 1997 Ian Lance Taylor - - * path.cc (current_directory_name): New static variable. - (current_directory_posix_name): New static variable. - (getcwd_inner): Cache the directory name. - (chdir): Move here from syscalls.cc. Clear directory cache - variables. - * syscalls.cc (chdir): Remove; now in path.cc. - - * environ.cc (setenv): Add cast to avoid warning. - - * security.cc (get_file_attribute): Make file parameter a pointer - to const char. - (set_file_attribute): Likewise. - * winsup.c (get_file_attribute): Update declaration. - (set_file_attribute): Likewise. - - * path.cc (path_conv): Don't pass the root directory to - symlink_check_one. - -Mon Dec 22 16:34:40 1997 Ian Lance Taylor - - * path.cc (realpath): Use path_conv to resolve symlinks. - - * path.cc (path_conv::path_conv): Rewrite completely to convert to - win32 path first and then check for symlinks element by element. - (symlink_check_one): New static function based on old - symlink_check_worker, but without path conversion. - (path_prefix_p): Move definition before all uses. - (skip_n_slashes, symlink_expand, symlink_follow): Remove. - (symlink_check_worker, symlink_check): Remove. - (readlink): Rewrite to use new symlink_check_one. - (unmixedcaseify, mixedcaseify): Comment out. - * path.h (symlink_check, symlink_follow): Don't declare. - * fhandler.cc (open): Don't pass O_NOSYMLINK to path_conv. Set - errno from path_conv if it fails. - * dirsearch.cc (opendir): Check errors from path_conv, and set - errno appropriately. - * times.cc (utimes): Likewise. - * syscalls.cc (_unlink, _link, mkdir, rmdir, chdir): Likewise. - (chmod, _rename): Likewise. - (_stat_worker): Don't just pass nofollow to _open, but base - whether to pass O_NOSYMLINK on whether nofollow is set. - (lstat): Pass 1, not O_NOSYMLINK, to _stat_worker. - * strerror.cc (strerror): Add ELOOP. - -Thu Dec 18 12:30:47 1997 Ian Lance Taylor - - * fhandler.h (class fhandler_base): Remove inline definitions of - tcflush, tcsendbreak, tcdrain, tcflow, tcsetattr, tcgetattr, - tcsetpgrp, and tcgetpgrp, so that we can set proper errno values. - (class fhandler_tty): Add pgrp_ field, and virtual tcgetpgrp and - tcsetpgrp functions. - * fhandler.cc (fhandler_base::tcflush): New function. - (fhandler_base::tcsendbreak): New function. - (fhandler_base::tcdrain): New function. - (fhandler_base::tcflow): New function. - (fhandler_base::tcsetattr): New function. - (fhandler_base::tcgetattr): New function. - (fhandler_base::tcsetpgrp): New function. - (fhandler_base::tcgetpgrp): New function. - (fhandler_tty::fhandler_tty): Initialize pgrp_. - - * tty.cc (tcsetpgrp): Set errno correctly on failure. - - * include/sys/termios.h (CBAUD): Change to 037. - (B57600, B115200): Change to values that can fit in a speed_t. - - * spawn.cc (spawn_guts): Set errno correctly if we can't find the - executable. - -Mon Dec 15 16:40:07 1997 Geoffrey Noer - - patch from msnyder@cygnus.com (Michael Snyder): - * heap.cc (_sbrk): handle situation where newalloc < incr - -Mon Dec 15 16:40:07 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - Allow Cygwin32 to terminate process even when in a blocking - winsock call. - * exceptions.cc (call_handler): call to WSACancelBlockingCall() - removed. - (sighandle): call WSACleanup() before exiting the process to - cancel blocking winsock calls. - * include/mywinsock.h: add proto for WSACleanup(). - -Mon Dec 15 16:40:07 1997 Geoffrey Noer - - * Makefile.in: compile .cc files with -fno-exceptions to - decrease dll size and increase execution speed a little. - -Mon Dec 15 16:40:07 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * tty.cc (do_input): Detect CTRL-T as a special case when - STRACE_CACHE is active. Dumps the strace cache to disk. - * console.cc (fhandler_console::read): Detect CTRL-T as a special - case when STRACE_CACHE is active. Dumps the strace cache to disk. - -Sat Dec 13 15:12:53 1997 Ian Lance Taylor - - * fork.cc: Include . - (cygwin_fork_helper1): Call __malloc_copy after copying the stack - and heap to the child. - -Thu Dec 11 15:14:40 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * sigproc.cc (proc_subproc): Remove over-enthusiastic test for - process handling readiness or proc_wait will loop attempting to - handle a dying subprocess when signal handlers are not ready. - * fork.cc (cygwin_fork_helper1): Reorganize to ensure that a - forked process is capable of receiving signals when fork() - returns. - -Wed Dec 10 15:43:37 1997 Ian Lance Taylor - - * include/sys/termios.h (IXANY): Correct value. - (PARMRK): Define again. - -Wed Dec 10 00:05:23 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * dcrt0.cc (dll_crt0_1): Move start time initialization to a more - logical place (pinfo_init). - (do_exit): Reorganize to attempt to solve races when a cygwin - process occupies two windows pids (i.e., an execed process). - * exceptions.cc (lock_cs): Fix erroneous WFSO logic. - (sighandle): Use new method for determining if process was - initiated via fork. - (events_terminate): Do not close pinfo_mutex. Allow automatic - close by ExitProcess to lengthen the time that the pinfo structure - is locked, minimizing races between an exiting child and a - potentially exiting parent. - * hinfo.cc (hmap_init): Use new method for determining if process - was initiated via fork. - (hinfo_vec::de_linearize_fd_array): Fix a typo in a comment. - * pinfo.cc (clearout): Remove this function. Handled in - allocate_pid. - (pinfo_init): Move start_time setting here from dll_crt0_1. - Remove call to init_self in favor of adding three additional lines - of code. - (pinfo_list::operator []): Implement a very simple hashing - scheme for pid lookup. - (lpfu): New routine controlled by DEBUGGING conditional. When - DEBUGGING is activated, lpfu returns more information about the - state of a timed out pinfo_mutex. - (pinfo_list::get_empty_pinfo): Remove function. Move - functionality to allocate_pid. - (allocate_pid): Implement a (very) simple hashing scheme for - finding an available pid. Take advantage of reorganized pinfo - structure to zero all pertinent fields with one memset. - (pinfo::record_death_nolock): Don't bothering zeroing - inconsequential stuff. - (pinfo::record_death): Leave pinfo_mutex locked with the - understanding that this function will be called just prior to - exiting the process. This minimizes a race between a child which - is exiting at nearly the same time as its parent. - * sigproc.cc: Reformat function calls. - (sigproc_init): Clear new PID_INITIALIZING flag to indicate that - a (possibly execed) process is now capable of receiving signals. - (sig_send): Be more defensive in determining if a signal can be - sent to myself or suffer problems with execed processes. - (sigproc_terminate): Wait for sig_proc to exit to ensure that - all pending signals have been handled. Use new 'proc_terminate' - function to terminate the subprocess handling thread. - (allow_sig_dispatch): Don't bother blocking signals if signal - handling isn't active in this process yet. - (block_sig_dispatch): Don't bother blocking signals if signal - handling isn't active in this process yet. - (sig_proc): Use sig_loop_wait variable to control wait time for - signal semaphores. Uncouples this wait from wait_subproc. - Perform signal cleanup here on thread termination. - (proc_exists): More accurate tests to determine if a process - really exists. - (proc_register): Remove this function in favor of a macro. - (proc_subproc): More stringent test for being "ready" to process - subprocesses. Add more common initialization to PROC_ADDCHILD. - Remove PROC_EXIT in favor of a separate function. - (proc_terminate): New function. Replaces PROC_EXIT functionality - in proc_subproc. Terminates subproc handler thread. - (stopped_or_terminated): use lock_pinfo_for_update when modifying - child stopsig status or suffer a race. - (wait_subproc): Save sig_proc thread handle away for - synchronization when exiting. Set up 'i_am_alive' mutex inherited - by childen. Child's inability to lock this mutex means that the - parent is still alive and processing children. Use proc_loop_wait - to control WFMO. Clean up events queue on thread exit. - (zap_subproc): Clear out pinfo structure for a child. - * sigproc.h: Remove PROC_EXIT constant. Remove obsolete - proc_register declaration. - (alive_parent): New macro to determine if a parent is still alive. - * spawn.cc (spawn_guts): Fix a comment typo. Use proc_terminate - to terminate all subprocess handling prior to an exec. Use new - method for determining if this process was started via a fork. - Attempt to clean up races between execed process, its parent, and - the execed child. - * winsup.h (pinfo): Add a new handle indicating that a parent is - alive. This should be a foolproof way of determining if a parent - has gone away so that a child will know whether to remove itself - from the pinfo table. - Reorganize the structure in such a way that items to be zeroed - are grouped together at the beginning for more efficient zeroing - in allocate_pid. - Add a new PID_* constant. - New lock_pinfo_for_update macro for use when debugging cygwin. - -Wed Dec 10 00:05:23 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - Change the way to inherit fd table on spawn/exec calls. - Use STARTUPINFO structure to pass an fd table to a child process - instead of shared memory area. This is undocumented, but is used - by MSVC runtime. The desktop inheritance code added again, - otherwise user32.dll will fail to initialize after sexec calls. - * pinfo.cc (pinfo_init): delinearize fd array from STARTUPINFO - structure instead of call to copy_shared_fd_table. - * shared.cc (create_shared_fd_mapping_name): remove - (create/copy_shared_fd_table): remove - * spawn.cc (spawn_guts): use lp(cb)Reserved2 fields of STARTUPINFO - to pass fd table to a child. Remove call to - create_shared_fd_table. Inherit window station/desktop on sexec - calls. - * winsup.h: remove prototypes for create/copy_shared_fd_table. - -Fri Dec 5 18:57:42 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * kill.cc (main): Report error if kill() fails. Minor reformat. - * ps.cc (main): Only use month/day in start time when starting - time is > 24 hours in the past, not when it occurs yesterday. - -Fri Dec 5 15:54:41 1997 Geoffrey Noer - - * fcntl.cc (_fcntl): reformat - * fhandler.cc (fhandler_tty::open): new, need special open for - ttys. In addition to calling fhandler_base::open, check - flags to handle blocking vs. non-blocking I/O. Should - initialize tty to standard state (9600 bits/sec - 8 - 1 with - no flow control) but this code needs more work still. Ifdef - out for now. - (fhandler_tty::tcsendbreak): new - (fhandler_tty::tcdrain): new - (fhandler_tty::tcflow): new - (fhandler_tty::tcsetattr): add support for action arg. Use - a DCB struct to hold the values we will set. First call - GetCommState to get the current state, then reassign values - based on the contents of the termios struct. Handle the - case where t->c_ospeed is set to B0, otherwise set state.BaudRate. - Set all the other DCB struct values appropriately, based on - the contents of the termios struct. - (fhandler_tty::tcgetattr): do the inverse of tcsetattr. - Call GetCommState to get the current state and use this to set - the appropriate termios struct values. - * termios.cc: reformat - (tcsendbreak): implement -- add duration arg, - call fhandler tcsendbreak as appropriate - (tcdrain): implement -- call fhandler tcdrain as appropriate - (tcflow): implement -- call fhandler tcflow as appropriate - * fhandler.h: add new tc* protos - * include/sys/termios.h: correct values of iflag bits, - define CRTSXOFF and CRTSCTS, CBAUD, B57600 and B115200. - Add protos for tc* functions. - -Wed Nov 26 17:06:17 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * spawn.cc (perhaps_suffix): resolve symlinks to .exes. - -Mon Nov 24 17:10:49 1997 Geoffrey Noer - - * cygwin.din: remove crypt - * syscalls.cc (crypt): remove crypt stub - -Sun Nov 23 17:34:42 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * spawn.cc (spawn_guts): save the path of the script itself, - use the saved path while building the command line to execute. - -Thu Nov 20 22:58:23 1997 Geoffrey Noer - - * stubs.cc: delete file, move unimplemented stubs to the - files in which they would normally belong. - * grp.cc (setgrent): implement (was in stubs.cc) - * syscalls.cc: move regfree, mknod, setgid, set(e)uid, sync, - crypt, and PPC __chkstk/_alloca/dll_entry stubs here from stubs.cc - (sync): just return zero for now instead of -1 - (crypt): return -1 instead of 0 - -Thu Nov 20 22:41:57 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * spawn.cc (spawn_guts): A premature close of the spawned filehandle - was possible when reparenting an exited process. Fix this. - * dcrt0.cc (do_exit): Only do minimal cleanup if "pid focus" - has moved to another windows process or the other process will - become confused. - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * sigproc.cc (getsem): set errno to EPERM if existing semaphore - cannot be opened. - (wait_subproc): allow access to signal semaphores to process's - owner only except for SIGCHLD (needed for SIGCHLD delivery after - sexecXX calls). - -Thu Nov 20 00:52:58 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * syscalls.cc (hash_path_name): Ignore trailing backslash when - calculating pathname hash. - * hinfo.cc (hinfo_vec::de_linearize_fd_array): Set use_tty - if /dev/ttyn is detected in the shared_fd_table. Before this - change, executing "set CYGWIN_TTY=1", "bash", "unset CYGWIN_TTY", - "/bin/pwd" would result in pwd printing nothing because - the de_linearize code would use the wrong fhandler_xxx when - reading from the buffer inherited from the parent process. - * cygwin.din: Add new ctermid function for export. - * syscalls.cc (ctermid): New function - * exceptions.cc (call_handler): If called during a P_OVERLAY - spawn, merely set appropriate flags and return. The spawn - code will then clean up and exit. - * sigproc.cc (proc_exists): Reorganize to better detect defunct - processes. Don't clean up pinfo if process has a parent since the - parent should clean up eventually. - * spawn.cc: New global exec_exit. Set by signal handler to - value which should be used on exit from aborted spawn. - (spawn_guts): Try harder to let the child terminate (if it is - going to) before exiting on a signal. Remove obsolete code. - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * exec.cc (file_exists): Removed - * spawn.cc (spawn_guts): call perhaps_suffix to convert filename - to win32 form and to check file existance; prog variable - removed, all references changed to real_path variable. - Do not inherit parent's window station/desktop on sexecXX calls. - They are no longer needed with the new signal handling. - (_spawnve): extra file existance check removed - * winsup.h: file_exists prototype removed - -Wed Nov 19 16:23:47 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * cygwin.din: add missing exports for random -- initstate - and setstate (accessed by gawk among others?) - -Tue Nov 18 22:27:10 1997 Geoffrey Noer - - * Makefile.in: Add spaces after colons in rules for make - -Mon Nov 17 22:35:25 1997 Geoffrey Noer - - patch from proven@cygnus.com (Chris Provenzano): - * Makefile.in: set SHELL = @SHELL@, set VPATH to only @srcdir@. - Remove mingw from directories to build for now, adapt rules - for building sysdef files without fancy VPATH - * configure: regenerate - * config/i386/makefrag: add rules to build setjmp/longjmp - * regexp/Makefile.in: set SHELL = @SHELL@ - * regexp/configure: regenerate - * utils/Makefile.in: set SHELL = @SHELL@ - * utils/configure: regenerate - -Mon Nov 17 18:36:50 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * fhandler.cc (fhandler_disk_file::open): calls to symlink_XXX - replaced with path_conv class calls. - * path.cc (path_conv::path_conv): comments added, O_NOSYMLINK case - added. - * path.h (class path_conv): symlink_p, exec_p - new class members. - * spawn.cc (spawn_guts): call path_conv instead of symlink_follow. - -Sun Nov 16 15:54:27 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * dcrt0.cc (do_exit): Use new pinfo element in debug statement. - * pinfo.cc (pinfo_init): Eliminate use of "PID" environment - variable in favor of scanning the process table for a - SpawnedProcessId field matching current windows process id. - Should speed up spawned process startup slightly. Delay setting - of dwProcessId until process is capable of processing signals - since this field is used to build signal semaphores. - * signal.cc (kill_worker): Perform a `proc_exists' on the pid - in question if signal == 0. This will verify that the process - actually exists and was not abnormally terminated. - * sigproc.cc (sigproc_init): Initialize dwProcessId field after - signal processing has been initialized. - (sigproc_terminate): Remove events[0] close. - (getsem): Use GetCurrentProcessId to find the windows pid since - this dwProcessId field is not yet set up. Use proc_exists to - determine if error should be printed on OpenSemaphore error. - (proc_exists): New function. Makes more exhaustive test of - process existence. Determines if process died without going - through normal shutdown. - (wait_subproc): Close wakeup event only on thread exit. - * spawn.cc: Remove pExeced. Use new field in pinfo. - (spawn_guts): Initialize dwSpawnedProcessId field. - * utils/ps.cc (main): Perform a kill(pid, 0) on any pids that - appear to be active. This will clear out pids that have died - abnormally. 'ps -f' bypasses this. - * winsup.h (class pinfo): Add dwSpawnedProcessId field. - -Sun Nov 16 15:54:27 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * pinfo.cc ((pinfo_init): use dwProcessId for execed/spawned - check, set subproc_ready event only if the process is exec'ed. - * spawn.cc (spawn_guts): initialize hProcess and dwProcessId - fields of pinfo on exec, keep progname field on spawn. - -Sun Nov 16 15:54:27 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * dcrt0.cc: remove commented out code - * spawn.cc: fix misapplied patch problem - -Sun Nov 16 15:54:27 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * fhandler.cc (fhandler_dev_null::open): Open Windows 'nul' - device rather than "faking" a real open. - (fhandler_dev_null::close): delete. - (fhandler_dev_null::fstat): delete. - (fhandler_dev_null::ioctl): delete. - (fhandler_dev_null::read): delete. - (fhandler_dev_null::write): delete. - (fhandler_dev_null::lseek): delete. - (fhandler_dev_null::dup): delete. - * fhandler.h (class fhandler_base): delete above methods from - class. - * hinfo.cc (hinfo_vec::build_fhandler): Use new fhandler_dev_null - class which opens 'nul' device. Treat /dev/null similarly to - other Windows devices. This allows redirection of /dev/null to - non-cygwin processes. - -Sun Nov 16 15:54:27 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * dcrt0.cc (do_exit): Use EXIT_* flags to determine how exit - should proceed. Honor new EXIT_NOCLOSEALL to avoid - close_all_files. - * exceptions.cc (__cygwin32_exception_handler): Use new - EXIT_SIGNAL define to indicate exiting due to signal. - * signal.cc (sigprocmask): Slightly more defensive check against - being called prior to complete cygwin setup. - (_raise): Defensive check to guard against being called prior to - complete cygwin setup. - * sigproc.cc (stopped_or_terminated): Use new EXIT_SIGNAL define - to detect exiting due to signal. - * sigproc.h: Define flags to be used during exit process as - EXIT_*. - * spawn.cc (spawn_guts): Use EXIT_* constants to control how - do_exit proceeds after _P_OVERLAY. - -Sun Nov 16 15:54:27 1997 Geoffrey Noer - - * sysconf.cc (sysconf): return 1048576 for ARG_MAX until - we figure out the right value (_POSIX_ARG_MAX is only 4K - which is too small). - -Sun Nov 16 15:54:27 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * dcrt0.cc (dll_crt0_1): call winsock_init if neccesary. - * fhandler.cc ((fhandler_socket::fhandler_socket): moved to net.cc - * fhandler.h (class fhandler_socket): destructor prototype added. - * fork.cc (cygwin_fork_helper1): set PID_SOCKETS_USED in the - child's pinfo if parent has open socket descriptors; call - winsock_init in child code if necessary. - * net.cc: static variable winsock_init_p removed; - number_of_sockets is new global variable containing number of - opened sockets. - (winsock_init): made global, save "winsock inited" flag in process - state field. - (cygwin32_winsock calls): condition for winsock initialisation - changed - (fhandler_socket::fhandler_socket): new, moved from fhandler.cc; - increment number_of_sockets on constructor call. - (fhandler_socket::~fhandler_socket): new. Decrement - number_of_sockets on destructor call, check for negative value. - (fhandler_socket::ioctl): check for winsock initialisation added. - * spawn.cc (spawn_guts): handle PID_SOCKETS_USED in child's pinfo. - * winsup.h: PID_SOCKETS_USED - new enum value; number_of_sockets - and winsock_init() prototypes added. - -Wed Nov 12 23:02:34 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * exceptions.cc: Substitute do_exit for _exit as appropriate. - do_exit allows full 32 bits of exit value. The upper 16 bits - are used for special cygwin operations. - * winsup.h: Change definition of do_exit to allow calling from - signal handler. - * dcrt0.cc (do_exit): Change to allow calling from signal handler - in place of _exit. This is necessary to ensure that only cygwin - internal applications can exit with the upper order 16 bits set - to non-zero. - -Wed Nov 12 23:02:34 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * dcrt0.cc (do_exit): New function. Subsumes functionality of - _exit but takes a DWORD argument. Changed to avoid some shutdown - activities when called with REPARENTING bit set in argument. Also - explicitly kills any executing non-cygwin subprocess from a - spawn(P_OVERLAY)... - (_exit): Use do_exit for exiting. Ensure that only low order 1 - bits of status are used or confusion will result if exiting with - some higher order bits set. - * exceptions.cc (set_process_mask): Reflect new method for - sig_send to send signals to self. - (handle_sigsuspend): Reflect new method for sig_send to send - signals to self. - * fork.cc: A handle name was changed in the pinfo structure to - be more reflective of its use. Change forkee_stopped to - subproc_ready everywhere. - * pinfo.cc (pinfo::clearout): Change forkee_stopped to - subproc_ready. - (pinfo_init): Use PID_EXECED flag to determine if this process has - been execed. If so, signal the remaining stub in the process - which invoked us so that the stub can terminate and let us take - over as this pid. - * sigproc.cc (sig_send): Change method for determining if sending - signals to myself. A NULL pointer means communicate with my - signal handler. This is necessary to allow communication with - our own signal processors after reparenting an execed process. - Also, add an additional test to detect if a process goes away in - the middle of attempting to send it a signal. - (allow_sig_dispatch): Reflect new method for sig_send to send - signals to self. - (getsem): Use dwProcessId in names for signal semaphores. Allows - communicating with both parts of a process that is temporarily - "split in two" while execing. - (sig_proc): Avoid printing an error if WAIT_FAILED and exiting - anyway. Process requests even if loop_wait == 0. - (proc_subproc): Defensive check for manipulating processes prior - to initialization or after terminating sigproc. - Use different check for subprocesses that have been reparented. - Hopefully this will eliminate WFSO, error 6 problems. - (wait_subproc): Only exit when loop_wait == 0 and not dealing with - a process. - * spawn.cc: Set up two global variables, used on exit when - execing a non-cygwin process: hExeced - handle of non-cygwin - process which is being waited for by a stub, pExeced - windows pid - of the process. - (spawn_guts): Reorganize to always (temporarily) wait for the new - process when P_OVERLAY. If a cygwin process is invoked, then the - wait will return when an event is signalled and the new process - will be "reparented" in the ppid. If a non-cygwin process is - invoked, wait until the process exits or a signal is received - which terminates the process. In this case, the do_exit function - will terminate the non-cygwin process. - * winsup.h: Rename forkee_stopped to subproc_ready since this - event now has a dual role which is better defined by this new - name. Add a new flag (PID_EXECED) for process_state. Define a - new function `do_exit' which operates similarly to _exit - but takes > 16 quantities with the high order bit signifying - different exit actions. - -Mon Nov 10 17:11:08 1997 Geoffrey Noer - - * include/utime.h: remove (moved to newlib/libc/sys/cygwin32/sys) - so as not to conflict with the one in newlib/libc/include. - -Mon Nov 10 15:11:42 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * exceptions.cc (__cygwin32_exception_handler): exit with - "core dumped" exit code after writing "core" file. - -Mon Nov 10 15:11:42 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * console.cc: Add convenience macros and structures for handling - scrolling. - (fhandler_console::fillin_info): New function to fill in the `info' - struct. - (fhandler_console::scroll_screen): Change to scroll only the visible - portion of the screen. Honor scroll regions more stringently. - (fhandler_console::open): Use new fillin_info function. - (fhandler_console::ioctl): Use new fillin_info function which - automatically calculates screen size. - (fhandler_console::clear_screen): Use new fillin_info function. - Only clear visible portion of screen. - (fhandler_console::cursor_set): Add a flag to indicate whether - cursor positioning is absolute within buffer or is screen relative. - Use new fillin_info function to get screen information. - (fhandler_console::cursor_rel): Use new fillin_info function. - Change for new cursor_set parameter. - (fhandler_console::cursor_get): Use new fillin_info function. - (fhandler_console::char_command): Use new fillin_info function - where appropriate. Change for new cursor set parameter where - appropriate. Scroll only visible portion of screen when required. - * fhandler.h (class fhandler_console): Add fillin_info, change - cursor_set to reflect additional argument. - -Mon Nov 10 15:11:42 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * dcrt0.cc (dll_crt0_1): Register process start time. - * fork.cc (cygwin_fork_helper1): Register process start time. - * utils/ps.cc (main): Report process start time. - (start_time): New function to format time similarly to UNIX ps. - A time from today shows as HH:MM, times from previous days just - show the month and day. - * winsup.h (class pinfo): Add start_time field. - -Mon Nov 10 11:54:27 1997 Ian Lance Taylor - - * include/Windows32/Defines.h (TIME_ZONE_ID_INVALID): Define. - * times.cc (gettimeofday): The error return from - GetTimeZoneInformation is TIME_ZONE_ID_INVALID, not - TIME_ZONE_ID_UNKNOWN. - -Sun Nov 9 17:08:30 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * Makefile.in: add ../libiberty/strsignal.o - * cygwin.din: add exports for strsignal, strtosigno - * utils/kill.cc: changes to allow accepting signal name - as argument - -Sun Nov 9 17:08:30 1997 Geoffrey Noer - - * include/limits.h: define PATH_MAX here instead of - include/sys/param.h, define _POSIX_NGROUPS_MAX as 0 not 1 - (system invariant value, not implementation-specific) - * include/sys/param.h: remove PATH_MAX, change NOFILE from 64 - to 8192, delete PATHSIZE, remove safety wrapper around - MAXHOSTNAMELEN, add comments - * sysconf.cc (sysconf): return NGROUPS_MAX not zero, - return _POSIX_SAVED_IDS not zero. Return _POSIX_CHILD_MAX - not 4096. Return _POSIX_CHILD_MAX, not 8. - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * winsup.h: add proto for setdtablesize, define NOFILE_INIT - and NOFILE_INCR - * hinfo.cc (hmap_init, hinfo_vec::find_unused_handle): change to - support virtually unlimited numbers of fds. Remove setdtablesize - proto - * syscalls.cc: initialize dtable_size to NOFILE_INIT instead of - NOFILE - -Thu Nov 6 13:14:09 1997 Geoffrey Noer - - * exceptions.cc (__cygwin32_exception_handler): don't - print "In cygwin32_except_handler" for exceptions Cygwin32 - isn't going to handle. Print "(progname PID) Exception: " - to console. Redirect all detailed information including the - stack trace to .core. This should reduce confusion - about what's causing the exception (a lot of people would see "In - cygwin32..." and think the problem was in Cygwin32 when most of - the time it was in some other program). - * syscalls.cc: add fixme - * times.cc: add fixme - -Wed Nov 5 19:23:10 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * Makefile.in: force .c.os and .cc.os to be built in same - directories as source - -Wed Nov 5 19:23:10 1997 Geoffrey Noer - - * drct0.cc (dll_crt0_1): stop initializing winsock on process - startup since that slows down startup time of all processes, even - ones that don't end up making Winsock calls. - * fork.cc (cygwin_fork_helper1): don't need to call uinfo_init - or socket_checkinit after fork -- the appropriate functions will - do the necessary initialization if they are ever called. - * net.cc: init winsock_init_p to zero and make it static - (all exported functions): call winsock_init before making - any WinSock calls since this no longer happens in dcrt0.cc - startup code. Only do this if !winsock_init_p. - (winsock_init): checkinit renamed. Now just inits winsock - without checking whether it has been already initialized. - Make it static. - * uinfo.cc (uinfo_init): after we call getpwnam, we know - the passwd file has been read in so don't check initialization - of it. However, we do need to read_etc_group() if group_in_memory - isn't set. - * passwd.cc: rename global i variable to pw_pos, rename - passwd_in_memory to passwd_in_memory_p to match net.cc scheme. - Add comments. - (read_etc_passwd): make static - (various): make sure to read_etc_passwd() if passwd_in_memory - isn't set - * grp.cc: add comments, rename idx global to grp_pos, - rename group_in_memory to group_in_memory_p to match net.cc - scheme, group_in_memory_p no longer static (needs to be accessed - by uinfo_init) - * winsup.h: remove proto for socket_checkinit since that's - renamed and static within net.cc - -Tue Nov 4 01:02:20 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * signal.cc (sigprocmask): Newer versions of gcc will call - sigprocmask when a builtin constructor is activated. If this - happens prior to the setup of u->self, then a NULL dereference - will occur. Guard against this. - -Mon Nov 3 17:00:45 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * hinfo.cc (hinfo_vec::build_fhandler): Open a console for - /dev/tty when !use_tty. - -Thu Oct 30 10:28:15 1997 Tom Tromey - - * include/mapi.h: New file. - * sysdef/i386/mapi32.def (MAPISendMail@20): New export. - -Thu Oct 30 15:08:13 1997 Geoffrey Noer - - * times.cc: add comments listing standards funcs are defined in - (dump_filetime): remove unused local func - * net.cc (fail): remove local func, replace one reference with - equivalent debug_printf, add standards comments, reformat a little - (fhandler_socket::close): simplify handling of res - (fhandler_socket::fstat): set ENOSYS (unimplemented) - * stubs.cc: set ENOSYS in unimplemented funcs - * uname.cc: add standards comment - * ntea.cc: reformat - -Wed Oct 29 22:43:57 1997 Geoffrey Noer - - * times.cc (settimeofday): set ENOSYS instead of EPERM - since ENOSYS maps to "Function not implemented" which is the - case here. - * syscalls.cc (seterrno): on failure, set EACCES instead of EPERM - which is better for the unknown error case - -Fri Oct 24 01:24:07 1997 Geoffrey Noer - - patch from green@cygnus.com (Anthony Green): - * dcrt0.cc: new host_dependent_constants object with a global - instance of it which allows constants that are different in Win 95 - and NT to be saved here instead of having forks in the code and - having to check the OS type each time. Add two constants for - fhandler, one for sharing attributes and one for upper word value - for locking files. - (dll_crt0_1): call host_dependent init function - * fhandler.cc (fhandler_base::open): use above object for - setting shared attributes - (fhandler_disk_file::lock): get upper word for locking from - host_dependent_constants - * winsup.h: define host_dependent_constants class and add extern - for global instance of it - -Wed Oct 22 02:27:53 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * cygwin.din: Export getenv, putenv, setenv and unsetenv instead - of cygwin32_ wrappers - * dcrt0.cc: External variable environ removed - (dll_crt0_1): strip executable's path on console title if - environment variable CYGWIN_TITLE set to "strip", references to - environ removed. - * environ.cc: New file. Code derived from newlib sources. - * exec.cc: include stdlib.h - (execl, execv): new (derived from newlib sources). - (sexecve): reference to environ removed. - (sexecvpe): call getenv instead of cygwin32_getenv. - * grp.cc: new static variable group_in_memory - (read_etc_group): skip blank lines - (getgrgid, getgrnam, getgrent): call read_etc_group when necessary. - * misc.cc (cygwin32_getenv/putenv/setenv/unsetenv): remove - wrappers. - * passwd.cc: new static variable passwd_in_memory - (read_etc_passwd): skip blank lines - (search_for, getpwent): call read_etc_passwd when necessary. - (setpwent): fixed incorrect initialization of i var. - * pinfo.cc (pinfo_init): initialize uid with illegal value to - force read of /etc/passwd and /etc/group. - * spawn.cc: call getenv instead cygwin32_getenv - (spawn_guts): force read of /etc/passwd and /etc/group on sexec - calls. - * uinfo.cc (uinfo_init): read /etc/passwd and /etc/group only if - uid is undefined. - * winsup.h: remove protos for environ, cygwin32_getenv, - cygwin32_putenv - -Wed Oct 22 02:08:54 1997 Geoffrey Noer - - * utils/aclocal.m4: new file. Define autoconf macros for - determining whether we're compiling for the cygwin32 environment - or not and determine the executable suffix - * utils/configure.in: call AM_CYGWIN32 and AM_EXEEXT - * utils/configure: regenerate - * utils/Makefile.in: add $(exeext) after executable names so - programs will be built with the .exe suffix - -Wed Oct 22 00:50:27 1997 Geoffrey Noer - - Now that it is possible to use gdb using a stable - cygwin.dll to debug a program using a newer, potentially buggy - cygwin.dll, the strace mechanism will probably end up being - used more and more for debugging timing/race-condition bugs that - aren't easily exposed in a gdb session. The following changes - make the strace facility better for debugging timing issues by - storing the last few commands in a buffer instead of writing - to disk each function call. - - patch from cgf@bbc.com (Chris Faylor): - * dcrt0.cc (dll_crt0_1): Change to strace_init call to take - an argument (for planned future registry changes). - (_exit): Call strace_dump when appropriate. Add a debugging - printf. - * include/sys/strace.h: Add _STRACE_CACHE, _STRACE_EXITDUMP, - strace_dump (). - * strace.c (strace_init): Allow hexadecimal, octal setting of - strace flags in environment variable. Handle new cache option. - (strace_printf): Display number of seconds from last message. - Handle _STRACE_CACHE. - (strace_dump): New function. Dump cached messages to disk. - -Wed Oct 22 00:08:40 1997 Geoffrey Noer - - * cygwin.din: export socket calls without cygwin32_ prefix - * net.cc: remove unused herror function in favor of - cygwin32_herror which is exported as herror - * include/netdb.h: we are now exporting the socket calls without - the cygwin32_ prefix so we don't need the nasty remapping in - header files - * include/arpa/inet.h: ditto - * include/sys/socket.h: ditto - * select.cc (select): make extern C - -Tue Oct 21 22:52:29 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * sigproc.cc (sigproc_terminate): Fix flawed attempt to signal - any processes waiting for signal notification success when the - process receiving the signal is terminating. - (wait_subproc): Report on errors when opening the - sync_proc_subproc mutex. Move initialization of events[0] - "wakeup" signal prior to wait_subproc_inited or risk a (miniscule) - chance for a reference to a NULL handle. - * strace.cc (ta[]): Change WM_ASYNCIO entry to reflect previous - changes to WM_ASYNCIO constant. - -Tue Oct 21 14:30:14 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * sigproc.cc (proc_subproc): fix minor error output problem - -Mon Oct 20 20:19:02 1997 Geoffrey Noer - - * Makefile.in: change DLL_NAME to cygwin97r2.dll - -Mon Oct 20 20:16:47 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * window.cc (alarm): When there is a previous alarm() request - with less than one second remaining, then the return from a call - to alarm() is supposed to return 1. - -Mon Oct 20 20:16:47 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * Makefile.in: Add sigproc.o target. Add sigproc.h dependency - where appropriate. Add -s to intermediate ld of cygwin.dll to - speed up the process of building the .dll. - * dcrt0.cc: Add new sigproc.h include. - (dll_crt0_1): Replace window_init with sigproc_init for - initialization of signal/sub process handling. Change to use new - process_state field in pinfo. - (_exit): Remove spurious debugging statement. Terminate sigproc - processing. Remove signal blocking obviated by previous signal - termination. Remove SIGCHLD notification of parent as it is now - handled automatically in the parent. - (api_fatal): Terminate sigproc processing. - * exceptions.cc: Add new sigproc.h include. Change name of - ourhThread. - (ctrl_c_handler): Change to static as this is no longer called - outside of this module. - (lock_cs): Change to a function which will optionally grab new - signal dispatch mutex. Don't wait forever for cs mutex. - (unlock_cs): Change to a function which will optionally release - new signal dispatch mutex. - (init_exceptions): Detect errors from SetConsoleCtrlHandler. - Initialize new sig_dispatch mutex. This mutex is used to - control dispatching to a function on signal receipt. - (sig_dispatch_pending): New function. Called from signal - processing thread to dispatch pending signals. - (set_process_mask): Block signal dispatch during setting of new - mask, if possible. Contact signal thread to dispatch pending - signals. - (handle_sigsuspend): New function. Attempts to implement a - sigsuspend which will not lose signal notification. Called from - sigsuspend. - (call_handler): Use sigproc_printf where appropriate. - (ctrl_c_handler): Use _raise to invoke the correct signal. - (sighandle): New function. Subsumes most of ctrl_c_handler. - Change to mark as suspended signals which would dispatch for which - the sig_dispatch mutex is unavailable. Use sigproc_printf where - appropriate. - (events_init): Remove application_stopped mutex made obsolete by - new sigproc handling. - (events_terminate): Remove application_stopped mutex made - obsolete by new sigproc handling. - * fork.cc: Add new sigproc.h include. - (cygwin_fork_helper1): Use process_state field in pinfo (replaces - inuse_p). Call proc_register to add a new subproc to sigproc - handling. Call sigproc_init for new subprocess. Remove obsolete - window_init. - * heap.cc (_sbrk): Use process_state field in pinfo (replaces - split_heap_p). - * hinfo.cc (hmap_init): Use process_state field in pinfo (replaces - cygwin_parent_p). - * include/sys/strace.h: Add tracing for signal/subprocesses. - * init.cc: Add new sigproc.h include. Add waitq_storage global - for new sigproc handling. - (dll_entry): Add initialization, destruction of structures needed - by new sigproc handling. - * net.cc (fhandler_socket::ioctl): Use gethwnd() function to find - hwnd of hidden window. - * pinfo.cc: Add new sigproc.h include. - (pinfo::clearout): Use process_state field in pinfo (replaces - split_heap_p). Explicitly initialize various handles to NULL. - (pinfo_init): Use process_state field in pinfo (replaces - cygwin_parent_p). - (pinfo_list::operator): Use process_state field in pinfo (replaces - inuse_p). - (pinfo_list::alocate_pid): Initialize process_state field. - (pinfo::init_self): Remove obsolete initialization of hProcess. - (pinfo::record_death_nolock): Changes for new sigproc handling. - (pinfo::record_death): Move bulk of this code to sigproc.cc. - (pinfo::terminate): Remove function made obsolete by sigproc - handling. - (pinfo::init_from_exec): Use process_state field (replaces - inuse_p). - * signal.cc: Add new sigproc.h include. - (kill_worker): Call new sig_send function to send signals to - cygwin processes. - (_kill): Use process_state field in pinfo (replaces inuse_p). - (sigsuspend): Call handle_sigsuspend in exceptions.cc to handle - sigsuspend in a non-raceable way. - * sigproc.cc: New signal/subprocess handling module. Replaces - SendMessage method for signals with a method using semaphores. - Also detects changes in the state of child processes. - * sigproc.h: New header file defining constants and functions for - signal/subprocess handling. - * spawn.cc: Add new sigproc.h include. Clean up trailing spaces. - (spawn_guts): Reorganize to use new sigproc handling. - Use new pinfo process_state field (replaces inuse_p). - * syscalls.cc (_read): Use new pinfo process_state field (replaces - inuse_p). - (_write): ditto. - * tty.cc (tty_init): Use new pinfo process_state field (replaces - cygwin_parent_p). - * utils/ps.cc (main): Use new pinfo process_state field (replaces - inuse_p). Detect "zombie" processes similarly to UNIX ps. - * wait.cc: Add required includes. - (wait_found): Function obsoleted by new sigproc handling. - (wait4): Reorganize to use new sigproc handling. - * window.cc: Changes for new sigproc handling. - (WndProc): Remove SIGNAL handling obsoleted by new sigproc - handling. Use static window handle since the field has been - removed from pinfo. Use _raise where appropriate to send signals. - (Winmain): Replace global window handle with static since the - field has been removed from pinfo. - (window_init): Remove obsolete function. - (gethwnd): New function to allocate hidden window on demand rather - than at startup. - (window_terminate): Kill hidden window only if allocated. - (setitimer): Use gethwnd function to retrieve hidden window - handle. - * winsup.h: Remove stuff made obsolete by sigproc handling. Move - some constants to new sigproc.h header file. Remove inuse_p, - cygin_parent_p, split_heap_p. Replace with a single process_state - field. Define bit fields for process_state in an enum for easier - debugging. - -Mon Oct 20 19:17:33 1997 Geoffrey Noer - - * sysdef/i386/winserve.def: remove ancient version of cygwin.din - * include/sgtty.h: remove since Cygwin32's tty handling doesn't - support bsd syntax/semantics - * include/sys/termios.h: change winsize struct to include - ws_xpixel and ws_ypixel members - * cygwin.din: remove export of ScreenCols, ScreenGetCursor, - ScreenRows, ScreenSetCursor, get_pid__5pinfo, getkey, _getkey, - kbhit, _kbhit, __small_printf = small_printf__FPCce - * key.cc: remove. Similar functionality exists in ncurses - which can be compiled for Cygwin32 - * console.cc (ScreenCols, ScreenGetCursor, ScreenSetCursor, - ScreenRows): delete and delete SCREEN_ROWS/COLS defines - * pold.c: remove old pipe-related code that's no longer used - * include/regex.h: remove, it's not a part of cygwin.dll - * syscalls.cc: started to add comments including standards - information - (truncate): new - (ftruncate): length is an off_t, not a size_t. Add missing - return value to debug printf - * syscalls.h: ftruncate length is an off_t, add proto for truncate - - patch from cgf@bbc.com (Chris Faylor): - * console.cc (fhandler_console::write): Recognize '@' as a valid - character to follow a '\e[' sequence or get 'Bad escape' errors. - -Wed Oct 15 18:44:25 1997 Geoffrey Noer - - * cygwin.din: restore __main as an export - -Mon Oct 13 18:41:09 1997 Geoffrey Noer - - * cygwin.din: revert renaming of __assert since that's - actually what it's supposed to be called - * assert.cc: ditto - -Fri Oct 10 19:25:49 1997 Tom Tromey - - * include/Windows32/Base.h: Moved typedefs of CHAR, SHORT, etc, - before all other uses in file. - -Fri Oct 10 17:50:12 1997 Ian Lance Taylor - - * include/Windows32/Base.h: Only typedef CHAR, SHORT, and LONG if - VOID is not defined - -Thu Oct 9 00:46:40 1997 Geoffrey Noer - - * cygwin.din: remove all libgcc.a exports. They don't - belong here since libgcc.a doesn't really relate to the - purpose of cygwin.dll, and (to make things worse) the contents - change over time. - * assert.cc: rename __assert to __cygwin32_assert - * exceptions.cc: rename __stack_trace to __cygwin32_stack_trace, - __cygwin_except_handler to __cygwin32_except_handler - * version.h: increment major and minor numbers - -Tue Oct 7 12:52:25 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * dcrt0.cc (_exit): under Win 95, don't send SIGCHLD - unless special env variable is set. This works around a - problem where exiting a process can hang under Win 95. - -Mon Oct 6 23:41:34 1997 Geoffrey Noer - - * regexp: new directory containing free regexp code by - Henry Spencer. Taken from the most recent release of NetBSD. - Write configure.in and Makefile.in, based on files from - winsup/utils. - * Makefile.in: build regexp directory and include objs in - cygwin.dll. - * stubs.cc: remove all reg* stubs except for regfree which - isn't provided by above code. - -Mon Oct 6 13:35:48 1997 Geoffrey Noer - - * dcrt0.cc: remove asm idata3 terminator, now that ld is fixed - such that this is no longer necessary. - * libccrt0.cc: ditto - -Mon Oct 6 13:14:00 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * spawn.cc (spawn_guts): return child's PID on - spawn (_P_NOWAIT,...) instead of child's handle. - (cwait): rewritten as a wrapper to waitpid. - -Mon Oct 6 13:02:01 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * net.cc (socketpair): new - * cygwin.din: add socketpair export - -Mon Oct 6 13:01:51 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * dcrt0.cc: Remove obsolete call to fork_terminate. - * exceptions.cc: Respace, remove extraneous trailing whitespace. - Change critical section to mutex since there are supposedly - multi-processor problems with critical sections under NT. - Use "lock_cs" and "unlock_cs" macros to lock/unlock critical - regions. - (init_exceptions): Change critical section initialization to mutex - initialization. - (set_process_mask): Use locking macros to control access to - sig_mask. - (ctrl_c_handler): Use lock_cs/unlock_cs to control access. - (events_init): Use standard cygname function to create names for - shareable objects. - (events_init): Close cs mutex. - * fork.cc: Use event flags which are specific to the child being - forked. This prevents one process from prematurely activating - another. It also makes fork slightly more thread-safe. - (fork_init): Remove event initialization. - (fork_terminate): Remove function. - (cygwin_fork_helper1): Initialize events on a per-fork basis. - Events are inherited in child's pinfo structure. - Remove child->hThread initialization as it not needed. Use - pi.hThread where child->hThread is used. - Work around Windows 95 bug where a WaitForSingleObjects will - sometimes return ERROR_INVALID_HANDLE when it is resumed after - a suspend. - * pinfo.cc: Remove references to hThread field whereever it occurs. - * strace.cc: Use standard cygname function to create name for - strace_mutex. Prevents confusion between different .dll versions. - * wait.cc (wait_found): Remove reference to hThread. - * winsup.h (class pinfo): Remove reference to hThread. Add - per-process fork control event handles. - * include/limits.h: Increase NGROUPS_MAX from 0 to 1 to reflect - recent change to getgroups. - -Mon Oct 6 11:06:22 1997 Geoffrey Noer - - Oops. ../libio refers to objdir and is not the same - as $(srcdir)/../libio. - -Thu Oct 2 23:12:19 1997 Geoffrey Noer - - Revert patches to sources applied after Sept 16. Removed - relevant portions of ChangeLog entries. Some of those changes - may reappear later (removing the entries makes this log easier - to understand). - -Thu Oct 2 15:34:03 1997 Geoffrey Noer - - * Makefile.in: remove hardcoding of SHELL to /bin/sh, remove - ../libio from INCLUDES since $(srcdir)/../libio is already - included. - * glob/Makefile.in: remove hardcoding of SHELL to /bin/sh - -Mon Sep 29 14:06:24 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * cygwin.din: add exports for rcmd, rresvport, rexec - * net.cc (cygwin32_rcmd): new - (cygwin32_rresvport): new - (cygwin32_rexec): new - * include/mywinsock.h: add protos for Winsock calls associated - with functions called by the above. - -Mon Sep 29 13:26:24 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * grp.cc (getgrent): Change overlooked comment to reflect new - behavior. - -Thu Sep 25 18:35:49 1997 Geoffrey Noer - - * Makefile.in: remove debugdll defs since the shared memory - overlap problem is solved by the timestamp addition of Sept 23 - * version.h: rework explanations of version numbers - -Thu Sep 25 16:21:49 1997 Geoffrey Noer - - * spawn.cc: add missing cast to debug printf - -Thu Sep 25 16:14:17 1997 Ian Lance Taylor - - * path.cc (conv_to_win32_path): Call backslashify on a win32 - path. - -Tue Sep 23 17:58:17 1997 Geoffrey Noer - - Fixes for things that were causing compile-time warnings: - * exec.cc (_execve): add missing const to args to match def - of execve in newlib which this calls. - (sexecve): add missing const to def - (sexeclpe): don't need to cast argv in sexecvpe call - (sexecvpe): add missing const to def - * winsup.h: correct _execve proto, add protos for login/logout - * syscalls.h: correct sexecve, sexecvpe protos - * include/Windows32/Base.h: NULL should be defined differently - for C++ - * init.cc: respacing - -Tue Sep 23 17:05:50 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * dcrt0.cc (dll_crt0_1): don't use alloca for allocating storage - for environment blocks because setenv() uses realloc! - -Tue Sep 23 17:05:50 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * Makefile.in (LD_STUFF): Add datestamp.o after DLL_OFILES. - (datestamp.o): New target. datestamp.c is generated whenever .o - files change. It creates a file containing a "date stamp" - which is used by the function "cygname" to create named - shared memory, events, mutexes, and semaphores used by - cygwin.dll. The unique datestamp allows multiple loading of - different cygwin.dll's even when they have incompatible use - of shared memory areas. - * init.cc (dll_entry): Create the name string used by cygname - from the name of the invoking .dll + the datestamp of the - .dll from the auto-generated datestamp.c - * misc.cc (cygname): New function. Creates a standard Cygnus - shared resource name given a prefix, a name (e.g., pinfo_mutex), - and a numeric suffix (e.g., a pid). Replaces custom code in - several files. Uses cygwin_dlldate from datestamp.c to construct - names that are unique for a given cygwin load. - * shared.cc (open_shared_file_map): Use standard cygname function - to create names for sharable objects. Use static handle 'h' - so that it can be closed later by shared_terminate. - (shared_terminate): Guard against calling CloseHandle with a - NULL handle. - (create_shared_fd_mapping_name): Use cygname function to generate - the name for the "fd_map". - -Tue Sep 16 23:34:36 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * fcntl.cc (_fcntl): correct errno value (EBADF instead of - EBADFD). - -Tue Sep 16 17:22:28 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * include/Windows32/Defines.h: add missing defines needed - for NTEA usage. - * ntea.cc: remove them from here - * syscalls.cc (_link): call CreateFile with FILE_WRITE_ATTRIBUTES - flag instead of GENERIC_WRITE - -Tue Sep 16 17:22:28 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * pinfo.cc (pinfo_init): Fix a NULL pointer dereference when PID - environment variable contains garbage. - -Thu Sep 11 16:51:40 1997 Geoffrey Noer - - * syscalls.cc (ftruncate): read file pointer location at - beginning of function and restore it at the end - -Thu Sep 11 15:35:10 1997 Ian Lance Taylor - - * path.cc (backslashify): Don't turn a single trailing slash into - a double trailing slash. - -Wed Sep 10 11:40:55 1997 Ian Lance Taylor - - * include/Windows32/Structures.h: Add PACKED to PRINTDLG. - * include/Windows32/Functions.h: Add STDCALL to a few function - declarations. - -Tue Sep 9 02:12:18 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * syscalls.cc (_link): Implement hard links under NT with NTFS - using the backup API. Default to copying the file (what we did - before). - -Mon Sep 8 20:19:09 1997 Geoffrey Noer - - Merge in the following changes: - - Thu Aug 21 13:30:12 1997 Ian Lance Taylor - * assert.cc: New file. - * Makefile.in (DLL_OFILES): Add assert.o. - (assert.o): New target. - * pinfo.cc (cygwin32_winpid_to_pid): New C function. - * cygwin.din: Add cygwin32_winpid_to_pid. - * include/sys/cygwin.h: Include . - (cygwin32_winpid_to_pid): Declare. - * pinfo.cc (pinfo_init): Add debug_printf showing pid and pgid. - - Wed Aug 20 13:24:30 1997 Ian Lance Taylor - * spawn.cc (env_sort): New static function. - (spawn_guts): Sort the environment before passing it to - CreateProcess. - * exceptions.cc (exit_already): New file static variable. - (__cygwin_exception_handler): If exit_already is set, just - return. If we get an exception we don't recognize, let the next - exception handler handle it. Just ignore the INVALID_HANDLE - exception. - (really_exit): Remove file static exit_already variable; use the - global one. - (events_terminate): Set exit_already. - * include/Windows32/Defines.h (EXCEPTION_INVALID_HANDLE): Define. - (STATUS_INVALID_HANDLE): Define. - * include/Windows32/Functions.h: Declare some shell functions. - -Mon Sep 8 17:40:46 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * dcrt0.cc (_exit): Kill the foreground process group on session - leader exit only if job control is in progress. - * exceptions.cc (ctrl_c_handler): protect the code with critical - section. This helps stability under Win 95. - * include/sys/strace.h: add new wm_printf macro - * signal.cc (kill_worker): window message number changed (window - messages WM_USER-WM_USER+0x100 reserved for common controls on - windows95). Debug print added. - * spawn.cc (spawn_guts): removed unneeded flag DETACHED_PROCESS. - * strace.cc: defines for SIGNAL and ASYNCIO messages added. - * tty.cc (create_tty_master): initialize speed fields of termios - structure. - (fhandler_pty_master::open): likewise. - * window.cc (WndProc): debug print added, window message number - changed. - * winsup.h: WM_ASYNCIO number changed. - -Mon Sep 8 16:40:46 1997 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * fhandler.h: set_w_binary/set_r_binary now defined to - return void - * grp.cc (getgroups): always return an array of length 1 where - the element is the user's gid. - * pinfo.cc (pinfo_init): verify that we haven't exceeded the - maximum number of processes - (pinfo_list::allocate_pid): ditto - * include/Windows32/Functions.h: add noreturn attrib to ExitProcess - * include/sys/strace.h: change strace defs so strace-related - printfs will automatically add __FUNCTION__: to the beginning, - rename __sys_printf to strace_printf. - * *.cc: remove function names from debug printfs in favor of the - new scheme where they are automatically added, change __sys_printf - references (now strace_printf). - * smallprint.c (__small_vsprintf): new function displayer code - to support the above changes - -Wed Sep 3 12:44:45 1997 Geoffrey Noer - - * Makefile.in: split subdir_do into subdir_dobefore and - subdir_doafter to reflect whether the subdir in question - should be built before or after the top level is built - (e.g. glob needs to be built before libcygwin.a but libcygwin.a - needs to be built before utils). - -Thu Aug 28 12:09:39 1997 Geoffrey Noer - - * configure.in: when setting up EXE_LDFLAGS, correct the - location of crt0.o to ../../newlib since EXE_LDFLAGS is used - by Cygwin32 subdirectories where newlib is two directories up - instead of one. - * configure: regenerate with autoconf - -Thu Aug 28 00:13:11 1997 Geoffrey Noer - - Replace all licensing-related headers in all Cygnus-owned - files. Instead of listing terms at the top of each file, now - we simply refer to: - * CYGWIN32_LICENSE: new file listing Cygwin32 licensing terms - -Wed Aug 27 17:40:16 1997 Geoffrey Noer - - * cygwin.din: export random, srandom - -Wed Aug 20 16:56:39 1997 Geoffrey Noer - - * Makefile.in: remove unused winsock-related build rules - that were commented out, minor comment changes, remove - test.exe build rule. - -Wed Aug 20 14:45:17 1997 Geoffrey Noer - - * Makefile.in: link cygwin.dll with -lm -lgcc -lc -lgcc instead - of -lc -lm -lm -lgcc so lgcc finds abort(). Add definitions that - will eventually be used to build a cygwindebug.dll used by gdb - so gdb can debug a buggy cygwin.dll. Change some variable names - to have underscores in them (DLL_NAME, LIB_NAME, DEF_FILE, etc.). - Comment out text.exe build rule. - -Tue Aug 19 20:41:51 1997 Geoffrey Noer - - * dcrt0.cc: respace, modify some comments slightly - -Tue Aug 19 16:17:57 1997 Geoffrey Noer - - * Makefile.in: include ../libiberty/random.o, stop including - librx since it is LGPL'd code. - * stubs.cc: add stubs for regcomp, regexec, regerror, regfree - * dcrt0.cc (dll_crt0_1): default to not support tty/pty devs, - default to not displaying the running process in the title bar. - -Fri Aug 15 18:23:43 1997 Rob Savoye - - Add mingw directory for the minimalist cygwin environment. - See mingw/ChangeLog for changes specific to that directory - - * configure.in: Add mingw to AC_CONFIG_SUBDIR. - * configure: Regenerated from autoconf 2.12 with Cygnus patches. - * Makefile.in: Use subdir_do which uses the value of $SUBDIRS - rather than having seperate target for each directory. - * glob/Makefile.in: Add a phony target for install. - * configure.in: Add mingw to AC_CONFIG_SUBDIR. - -Fri Aug 15 01:12:19 1997 Geoffrey Noer - - * times.cc: add missing extern "C"s around exported functions - -Thu Aug 14 17:00:32 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * console.cc (fhandler_console::input_tcsetattr): clear iflag_ and - lflag_ when tty support enabled. - (FakeReadFile): do not interrupt read when tty support enabled. - Do not reset signal_arrived event. - * cygwin.din: add exports - cf(g)set(i)ospeed, login, logout, ttyslot - * dcrt0.cc (_exit): kill orphaned childs with SIGHUP and SIGCONT - on group leader exit, kill foreground process group on session - leader exit. - * dirsearch.cc (closedir): check for FindFirst() was called - * exceptions.cc: include mywinsock.h. - (call_handler): call WSACancelBlockingCall to try to interrupt - blocking winsock call, do PulseEvent() instead of SetEvent(). - (ctrl_c_handler): clear pending SIGCONT on stop signals, clear all - pending stop signals on SIGCONT, suspend the thread before resuming - to avoid W95 bug, process pending signals on SIGCONT, add signals to - pending if the process is stopped. - * fcntl.cc (fcntl): some code rearrangement to always do debug printfs - on call exit. - * hinfo.cc: include stdio.h - (hinfo_vec::build_fhandler): always add ttynum to tty's filename - (hinfo_vec::dup2): fix return value initialization and errno setting. - * include/netdb.h: typedef for sig_t removed - * include/sys/termios.h: octal constants changed to hexadecimals - to simplify debugging. - * misc.cc: include unistd.h and utmp.h - (login): new - (logout): new - * pinfo.cc (lock_pinfo_for_update): debug printf added - (pinfo::record_death): mark processes as orphaned on group leader - exit. - * select.cc (cygwin32_select): ResetEvent() removed - * signal.cc: unneeded ResetEvents removed - (_kill): ignore stop signals from a member of orphaned process group, - kill self process the last on group kill. - (sigaction): reset pending SIGCHLD when the disposition is set to - default. - * spawn.cc (spawn_guts): ResetEvent removed - (cwait): do not interrupt the call - * strerror.cc: include stdio.h, reenable disabled cases, remove - duplicated cases, return decimal error value in the default case. - * syscalls.cc (setsid): set process group id to process id when setsid - called. - (setpgid): check for negative pgid - * syslog.cc (syslog): %m macro support added - * termios.cc (cfg(s)eti(o)speed): new fuctions needed to support - NIST PCTS requirements. - * tty.cc: include utmp.h. - (ttyslot): new - (tty_list::terminate): fill in utmp on tty master exit - (tty_list::allocate_tty): check for tty master pocess alive - (create_tty_master): fill in utmp - (do_input): restart tty output on interrupt - (fhandler_tty_slave::fhndler_tty_slave): ttynum logic moved to - build_fhandler. - (fhandler_tty_slave::open): set tty's session id to sid of the calling - process. - (fhandler_tty_slave::write): check for TOSTOP bit - (fhandler_tty_slave::fstat): allow access to tty to everyone - (fhandler_tty_slave::ioctl): check for TOSTOP bit - * tty.h: ttyslot prototype added - * wait.cc (wait4): check for valid value of option argument added - * winsup.h: define PID_ORPHANED, move tty_list array to the end - of shared area. - -Thu Aug 14 11:42:59 1997 Ian Lance Taylor - - * path.cc (slash_unc_prefix_p): Correct check of path[3]. Permit - numbers after the host name. - - * include/Windows32/Defines.h: Correct value for SM_CMETRICS, - SM_CXDRAG, SM_CYDRAG, SM_CXEDGE, SM_CYEDGE, SM_CXFIXEDFRAME, - SM_CYFIXEDFRAME, and add SM_MOUSEWHEELPRESENT. - -Wed Aug 13 20:11:52 1997 Ian Lance Taylor - - * fork.cc (cygwin_fork_helper1): If we don't have a console, pass - DETACHED_PROCESS to CreateProcess. - * spawn.cc (spawn_guts): Likewise. - -Tue Aug 12 19:51:32 1997 Ian Lance Taylor - - * include/Windows32/Structures.h (IMAGE_DOS_HEADER): Remove - dos_message and nt_signature fields; they aren't present in the - Windows header file. - -Wed Aug 6 16:27:13 1997 Ian Lance Taylor - - * include/Windows32/Structures.h: Define LPMEASUREITEMSTRUCT as a - pointer to MEASUREITEMSTRUCT. - - * syscalls.cc (_stat_worker): In directory case, only set - STD_WBITS in st_mode if FILE_ATTRIBUTE_READONLY is clear. - (access): Remove special case for directory. - - * include/Windows32/Defines.h (HKEY_DYN_DATA): Define. - (REG_FULL_RESOURCE_DESCRIPTOR): Define. - (REG_RESOURCE_REQUIREMENTS_LIST): Define. - -Mon Aug 4 21:15:05 1997 Andrew Cagney - - * glob/Makefile.in: Add include of newlib/libc/sys/cygwin32 to - explicit .c.o rule so that dirent.h is found. - -Thu Jul 24 02:14:24 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * cygwin.din: fpathconf, initgroups - new exports - * console.cc: new static variable CONSOLE_SCREEN_BUFFER_INFO info - (fhandler_console::scroll_screen): local variable info removed - (fhandler_console::open): likewise - (fhandler_console::ioctl): likewise - (fhandler_console::clear_screen): likewise - (fhandler_console::cursor_set): likewise - (fhandler_console::cursor_rel): likewise - (fhandler_console::cursor_get): likewise - (fhandler_console::write_normal): fixed scroll region bug, termcap - "cs" entry works now - * dcrt0.cc (dll_crt0_1): set file API to use OEM charset, convert - command line from ANSI to OEM charset. - (_exit): clear stopsig value on process exit - * exceptions.cc (call_handler): add one millisecond delay before - SetEvent() - (ctrl_c_handler): clear pending stop signals on SIGCONT, do not send - SIGCHLD to parent on process resuming; some debug printfs added; do - not call _exit() in a context of signal handling thread (would cause - more harm than good); fixed a bug with SA_NOCLDSTOP flag. - * fhandler.cc (fhandler_base::open): use full win32 path name to - generate inode number namehash instead of unix filename. - * fork.cc (cygwin_fork_helper1): block all signals while child and - parent are in fork() code - * grp.cc (initgroups): new stub added - * include/limits.h: new posix defines added - * include/sys/termios.h: typedef speed_t as unsigned char - * path.cc (mount_info::conv_to_posix_path) bugfix - * pinfo.cc (pinfo_list::operator []): PID_NOT_IN_USE check added - (pinfo::record_death): set child's ppid to 1 on parent exit - * signal.cc (sleep): correct return value if sleep call was - interrupted - (_kill): correct return value if killed pid was not found. - (sigaction): correct return value on handling non-handlable - signals, clear pending ignored signals - (sigsuspend): sigsuspend call should always return -1 and set errno - to EINTR. - * spawn.cc: respace - * syscalls.cc: map ERROR_NO_DATA to EPIPE instead of ENODATA - (isatty): fixed return value - (fpathconf): new - (pathconf): rewritten - (ttyname): fixed return value - * sysconf.cc (sysconf): misc fixes - * termios.cc (tcsendbreak): corrected errno set - (tcdrain): likewise - (tcflush): likewise - (tcflow): likewise - (tcsetattr): likewise - (tcgetattr): likewise - (tcgetpgrp): likewise - (tcsetpgrp): likewise - * tty.cc (fhandler_tty_slave::ioctl): TCGETA/TCSETA support added - * wait.cc (_wait): wait() syscall should do not terminate if - a child is stopped. - (wait4): wait calls should wait childs only; fixed a bug with - nprocinfo count; fixed signal handling. - -Thu Jul 24 02:10:25 1997 Geoffrey Noer - - * uname.cc: uname now outputs Cygwin32_NT or Cygwin32_95 - instead of Cygwin32/NT or Cygwin32/95. - -Thu Jul 24 02:10:25 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * cygwin.din: sexecve, sexecl, sexecle, sexeclp, sexeclpe, - sexecv, sexecp, sexecvpe - new exports - * exceptions.cc (ctrl_c_handler): do not raise SIGHUP on - CTRL_LOGOFF_EVENT to prevent termination of cygwin application - run as NT service on user logoff, raise SIGHUP instead of SIGQUIT - on system shutdown, clear stopped status in inuse_p on SIGCONT, - set stopped status on stop signals, call _exit() on process - termination in a context of signal thread to terminate while - in a blocking win32 syscall. - * exec.cc: include unistd.h and ctype.h. - (_execve): code moved to sexecve, call sexecve with a NULL hToken - handle. - (sexecve): new, check path, argv[0] and envp to null values, - pass nToken handle to spawn_guts(). - (sexecl): new (code derived from spawn family of functions in - spawn.cc) - (sexecle): new - (sexeclp): new - (sexeclpe): new - (sexecv): new - (sexecp): new - (strccopy): new - (sexecvpe): new - * fhandler.cc (fhandler_base::fstat): add STD_RBITS and STD_WBITS - to st_mode of non-file handles. - (fhandler_dev_floppy::open): clear O_TRUNC bit. - (fhandler_dev_tape::open): likewise - * fhandler.h (fhandler_pty_master): new member pktmode (flag to - indicate pty's packet mode) - * fork.cc (cygwin_fork_helper1): call uinfo_init () in a child code - to read /etc/passwd, /etc/group into memory. - * hinfo.cc (hinfo_vec::build_fhandler): check socket names for right - inheritance on exec(). - * include/Windows32/Defines.h: fixed a typo in LPSTR_TEXTCALLBACKA - definition - * include/Windows32/Functions.h: added prototype for - ImpersonateLoggedOnUser() API call. - * net.cc (cygwin32_socket): duplicate socket handle as inheritable - to avoid Windows95 socket inheritance bug, close the original socket. - (cygwin32_accept): likewise. - * path.cc (mount_info::conv_to_win32_path): do not add trailing - backslash to UNC device names like "\\.\a:", "\\.\tape0:" etc. - * pinfo.cc (pinfo::record_death_nolock) set PID_WAITING_FOR_PARENT - bit to inuse_p instead of assignment - inuse_p is a bit set now. - (pinfo::record_death): check PID_WAITING_FOR_PARENT bit instead of - comparison. - * select.cc (fd_pipe_map::convert_to_unix_fdset): deal with pipe - errors. - (pipethread): likewise - * shared.cc (create_shared_fd_table): allow any process to access - shared arg, needed for sexec() family implementation - * signal.cc (kill_worker): fixed a typo in debug printf - * spawn.cc (spawn_guts): new hToken argument (security token of - logged on user for sexec() calls implementation), added checks for - zero prog_arg and argv[0], if hToken is not NULL run - CreateProcessAsUser() on the current window station/desktop, or - just CreateProcess() otherwise, close hToken after the process is - created. - (_spawnve): pass NULL hToken to spawn_guts(). - * syscalls.cc (_read): set process's read status while in a read call - (_write): set process's write status while in a write call - (stat_worker): if GetFileAttributes() fails, try to call fstat to - support raw devices - * syscalls.h: include windows.h, added sexec() family functions - prototypes. - * sysdef/i386/kernel32.def: ImpersonateLoggedOnUser - new export - * tty.cc: tty attachment logic changed - tty_list::count field - counts now number of tty opens, but not a number of processes, - attached to a tty. - (tty_init): do not call attach_tty() in a exec'ed process - (attach_tty): correct return value if !use_tty. - (tty::init): initialize pgid and hwnd fields. - (tty_list::terminate): clearout tty on master exit. - (tty_list::allocate_tty): fixed a bug in a tty allocation. - (fhandler_tty_master::init): on NT allow any process to open - tty-master process for handle duplication, create synchronisation - events with a world-wide access, initialize winsize structure with - a default values. - (fhandler_tty_slave::open): if a tty doesn't have process group set, - set it to a process group of current process. - (fhandler_tty_slave::write): added missed \n to debug print, tty - write synchronization moved to a more correct place. - (fhandler_tty_slave::read): Sleep time changed for conformance with - other sleeps. - (fhandler_tty_slave::tcsetattr): synchronization added - (fhandler_tty_slave::ioctl): initialize arg.winsize with a tty-stored - value, copy the result of ioctl call to winsize. - (fhandler_pty_master::fstat): small fix - (fhandler_pty_master::open): on NT allow any process to open - pty-master process for handle duplication, initialize winsize - structure with a default values. - (fhandler_pty_master::read): check for pipe errors, changes to support - packet mode - (fhandler_pty_master::ioctl): rewritten, no longer a stub. - (fhandler_pty_master::linearize/de_linearize): save/restore pktmode - value. - * tty.h (class tty): winsize - new member - * utils/ps.cc: show process status just after tty number field - * winsup.h: defines for new bits in inuse_p added, spawn_guts() - prototype changed. - -Thu Jul 24 02:10:25 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * Makefile.in: Add tty.o to link and dependency lists, add - tty.h to headers list - * console.cc (fhandler_console::open): save open call flags - (fhandler_console::input_tcsetattr): clear all console modes if - tty support enabled - (FakeReadFile): restart read on signal delivering, changed CTRL - macro to CONTROL to avoid conflict with sys/termios.h, copy as - much as possible chars to output buffer instead of call to - undo_input after every char to prevent timeouts problem. - * cygwin.din: srandom, ptsname, grantpt, unlockpt - new exports. - * dcrt0.cc: include tty.h, new use_tty global variable. - (dll_crt0_1): call events_init() on application startup, set - use_tty to FALSE if CYGWIN_NOTTY environment variable is defined, - do not change console title if CYGWIN_NOTITLE environment - variable set, call tty_init(). - (_exit): call tty_terminate(), events_terminate() and others - in the right order. All modifications of console title are - mutexed to allow tty code to obtain console window handle right. - * exceptions.cc (exception_init): initialization of signal_arrived - event moved to events_init(). - (call_handler): raise signal arrived event after resuming main - thread. - (__cygwin_exception_handler): raise signal instead of calling - ctrl_c_handler, because exception handler is called in a context - of the thread, caused exception, and SuspendThread in call_handler - blocks itself :-) - (ctrl_c_handler): clear stopsig on SIGCONT delivery, call - ResumeThread until suspend count > 1, notify parent about child's - status changed. Care about handling SIGCONT signal. On stop - signals release vital mutexes used by stopped thread, save - signal number for wait(WUNTRACED) calls, notify parent about child's - status change. Do not stop processes running without job control - (when pgid == 0). Ensure that main thread is unblocked before - call _exit(). - (events_init): new - (events_terminate): new - * fcntl.cc (_fcntl): use saved open flags on F_GETFL/F_SETFL instead - of game with access_ variable. Is this variable longer needed? - * fhandler.cc (fhandler_base::linearize/de_linearize): save/restore - openflags_ variable. - (fhandler_base::open): save file open flags. - * fhandler.h (fhandler_base): new openflags_ member, new member - functions get_flags/set_flags, new virtual functions ptsname, - dup_for_fork, tcget(set)pgrp - (fhandler_pipe): remove always_write/except_ready because pipes - are always write ready (not true...) and selectable on read. - new classes fhandler_tty_slave, fhandler_pty_master, - fhandler_tty_master - * fork.cc (cygwin_fork_helper1): inherit control tty number on fork, - call tty_init on child startup. - * hinfo.cc: include stdlib.h and ctype.h. - (hmap_init): take care on exec'ed processes. - (init_std_file_from_handle): open /dev/tty for standard handles if - tty usage enabled. - (build_fhandler): check for tty slave and pty master devices. - * include/exceptions.h: exception handler returns "int" (exception - handling code), not "void". - * include/termios.h: new defines, struct winsize must contain - ws_xpixel and ws_ypixel members (commented now to avoid - incompabilities with existing binaries. Should be uncommented in - next release. - * net.cc (gethostbyaddr): corrected return value - * passwd.cc (parse): remove trailing newline from password - lines (user's shell was reported with trailing newline before). - * pinfo.cc (lock_pinfo_for_update): open mutex code moved to - events_init() in exceptions.cc. - (destroy_pinfo_lock): removed, pinfo_mutex is now closed in - events_terminate() in exceptions.cc. - (init_self): the initial value for pgid must be 0 (no job-controlled - process). - * select.cc: all debug_printf's changed to select_printf. - (fd_pipe_map): new class to implement (polling...) select on pipes. - (pipethread): new - (cygwin32_select): comment out socket only case since generic - code (select on different types of handles) works for sockets too - but is interruptable. The case for always_ready_used is used now - and for polling select (zero timevalue). Changes to support - select on pipes. - * shared.cc (shared_info::initialize): initialize tty table. - * signal.cc (sleep/usleep/sigsuspend/pause): signal_arrived moved - from u area to dll's address space, signal_arrived is manual reset - event now. - (_raise): implemented as kill (self, sig). - (kill_worker): new. Use SendMessage instead of PostMessage to avoid - some timing problems. - * spawn.cc: include tty.h. - (spawn_guts) call close_all_files() on exec, call tty_terminate() - before process exit. Some changes due to moving signal_arrived to - dll's address space. - (_spawnve): inherit control tty number on spawn. - * syscalls.cc (close_all_files): reenabled. The code is ok after - all! The troubles were due to incorrect usage on exec() calls. - (setsid): no longer a stub - (ptsname): new - * termios.cc: all syscall_printf's changed to termios_printf. - (tcget(set)pgrp): rewritten, no longer a stub. - * times.cc (utimes): It looks like Win32 does not allow changing - times of directories, so just return success in this case. - * tty.cc: new file - (tty_init): new - (tty_terminate): new - (attach_tty): new - (detach_tty): new - (tty::init): new - (tty_list::terminate): new - (tty_list::connect_tty): new - (tty_list::free_tty): new - (tty_list::init): new - (tty_list::allocate_tty): new - (fhandler_tty_master::fhandler_tty_master): new - (create_tty_master): new - (fhandler_tty_master::init): new - (doecho): new - (do_input): new - (process_input): new - (do_output): new - (process_output): new - (process_ioctl): new - (fhandler_tty_slave::fhandler_tty_slave): new - (fhandler_tty_slave::open): new - (fhandler_tty_slave::init): new - (fhandler_tty_slave::close): new - (fhandler_tty_slave::write): new - (fhandler_tty_slave::read): new - (fhandler_tty_slave::linearize): new - (fhandler_tty_slave::de_linearize): new - (fhandler_tty_slave::dup): new - (fhandler_tty_slave::dup_for_fork): new - (fhandler_tty_slave::fstat): new - (fhandler_tty_slave::tcgetattr): new - (fhandler_tty_slave::tcsetattr): new - (fhandler_tty_slave::tcflush): new - (fhandler_tty_slave::tcsetpgrp): new - (fhandler_tty_slave::tcgetpgrp): new - (fhandler_tty_slave::send_ioctl_request): new - (fhandler_tty_slave::ioctl): new - (fhandler_pty_master::fhandler_pty_master): new - (fhandler_pty_master::fstat): new - (fhandler_pty_master::open): new - (fhandler_pty_master::close): new - (fhandler_pty_master::write): new - (fhandler_pty_master::read): new - (fhandler_pty_master::tcgetattr): new - (fhandler_pty_master::tcsetattr): new - (fhandler_pty_master::tcflush): new - (fhandler_pty_master::ioctl): new - (fhandler_pty_master::ptsname): new - (fhandler_pty_master::linearize): new - (fhandler_pty_master::de_linearize): new - (fhandler_pty_master::dup_for_fork): new - (grantpt): new - (unlockpt): new - * tty.h: new - * utils/ps.cc: display process's control tty number. - * wait.cc (wait_for_single): removed. - (wait_for_any): all code moved to wait4(). - (wait4): rescan process table on child status changes, support for - WUNTRACED flag, avoid time races on child exit, correct return - value on timeout. - * window.cc: misc changes to wait creation of process's hidden - window to avoid race conditions on multiprocessor systems. - * winsup.h: misc changes to support all of the above. - -Thu Jul 24 02:10:25 1997 Geoffrey Noer - - * net.cc (cygwin32_shutdown): New implementation to replace - stub previously present - -Tue Jul 22 14:59:22 1997 Geoffrey Noer - - * cygwin.din: remove random, srandom - * Makefile.in: remove random/srandom-related lines - -Tue Jul 22 14:10:32 1997 Ian Lance Taylor - - * path.cc (realpath): New C function. - * cygwin.din: Export realpath. - - * cygwin.din: Export srandom. - -Wed Jul 9 12:26:03 1997 Geoffrey Noer - - * Makefile.in: libiberty random.o ends up in winsup, link - in that obj for now - -Tue Jul 8 14:02:41 1997 Ian Lance Taylor - - * libcmain.cc (main): Pass wShowWindow field from startup info to - WinMain. - -Mon Jul 7 17:47:48 1997 Geoffrey Noer - - * path.cc: respace, reword comments - * times.cc (utimes): add FIXME - -Tue Jun 24 18:31:27 1997 Geoffrey Noer - - * winsup.h: adjust protos to reflect the above, add enum os_type - which contains {winNT, win95, win32s, unknown} - * security.cc (is_nt): Delete - * syscalls.cc (windows_95): Delete - (get_os_type): New local function which returns os_type. Replaces - windows_95() and is_nt(). - - * fhandler.cc: Reformat. Call get_os_type() instead of - windows_95() and/or is_nt(), reorder so NT cases are first. - * mmap.cc: ditto - * net.cc: ditto - * syscalls.cc: ditto - * syslog.cc: ditto - - * uname.cc (uname): call get_os_type to fill new our_os local - variable, check that when filling out utsname struct, default - to i386 when we can't find out the specific Intel processor - variant. - * fhandler.cc (get_file_owner): remove doit variable - (get_file_group): ditto - * mmap.cc: extern "C" individual functions instead of wrapper - around most of file. - * misc.cc: minor reformat - * heap.cc (_sbrk): split a = b = c statement into two to - make code clearer and avoid invalid C++ casting warning during - compile. - * path.cc (symlink_follow): initialize syml_p and exec_p to zero - * select.cc: respace - (selectthread): cast first arg of WINSOCK_FD_SET - * ntea.cc (NTReadEARaw): add missing casts in front of malloc calls - * utils/mount.cc: remove mixed option since that hasn't been - supported for quite some time - -Sun Jun 22 17:27:03 1997 Ian Lance Taylor - - * include/windows.h: If RC_INVOKED is defined, don't include - limits.h, stdarg.h, Structures.h, Functions.h or Sockets.h, and - don't typedef BOOL. - * include/Windows32/Base.h: Don't do any typedefs if RC_INVOKED is - defined. - - * include/Windows32/Sockets.h (MAXHOSTNAMELEN): Don't define if - already defined. - * include/sys/param.h (MAXHOSTNAMELEN): Likewise. - -Fri Jun 20 11:06:09 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * include/sys/wait.h: correct operator precidence bug - in WIFSIGNALED - -Thu Jun 19 12:58:45 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - Handle unblocked pending signals on sig_mask changes - * exceptions.cc (return_handler): renamed to set_process_mask - (set_process_mask): new; use to set process mask instead of direct - u->self->sig_mask manipulations. - * winsup.h: rename return_handler proto to set_process_mask - * signal.cc: throughout file, call set_process_mask() instead of - direct manipulations of u->self->sig_mask. - (pause): new - * cygwin.din: add pause() export - * syscalls.cc (system): correct return value - -Wed Jun 18 22:01:56 1997 Geoffrey Noer - - * Makefile.in: add $(srcdir)/../newlib/libc/sys/cygwin32 to - the list of includes since that's where sys/dirent.h is - supposed to live - * include/sys/dirent.h: moved to newlib/libc/sys/cygwin32/sys - -Wed Jun 18 13:56:47 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * signal.cc (sigsuspend): deal with pending unblocked signals - * winsup.h: add proto for return_handler (sigset_t) - -Wed Jun 18 02:02:13 1997 Geoffrey Noer - - respaced console.cc, fhandler.cc, syscalls.cc, pinfo.cc, - fork.cc, spawn.cc - -Tue Jun 17 14:57:09 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * cygwin.din: add getpgid, killpg exports, delete duplicate - random export - * fork.cc (cygwin_fork_helper1): inherit pgid and sid on fork - * misc.cc (cygwin32_*env): save environ value in __cygwin_environ - too. Is __cygwin_environ variable really neccessary? Why not - export cygwin.dll's environ variable with "__cygwin_environ" name? - * pinfo.cc (pinfo::init_self): initialize pgid and sid - * signal.cc (kill_worker): new - (_kill): rewritten to support process groups - (killpg): new - * spawn.cc (_spawnwe): inherit pgid and sid on spawn family calls - * stubs.cc (setpgrp, getpgrp): remove stubs - * syscalls.cc (setpgid, getpgid, setpgrp, getpgrp): new - * termios.cc (setpgid): remove stub - * utils/ps.cc (main): add pgid to output, change output - format - * wait.cc (wait_for_any): add intpid argument, arrays ctable and - ptable have now fixed MAXIMUM_WAIT_OBJECTS size to avoid extra - scan of process table, changes for process groups support. - (wait4): misc changes to support process groups - * winsup.h (pinfo class): add new variables pgid, sid. - Define __cygwin_environ. - -Mon Jun 16 18:30:21 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * spawn.cc (spawn_guts): set child->hProcess and child->hThread, - CloseHandle on pi.hThread at end of spawn_guts instead of right - after starting the child process, - _P_WAIT needs to be handled separately from _P_OVERLAY - -Sun Jun 15 23:51:10 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * cygwin.din: remove setenv/getenv-related exports, - export cygwin32_ equivalents - * exec.cc: check ? - * misc.cc (cygwin32_getenv): new - (cygwin32_putenv): new - cygwin32_setenv): new - (cygwin32_unsetenv): new - * spawn.cc: call cygwin32_getenv instead of getenv, - call spawn with *u->envptr instead of environ - * winsup.h: define **environ as extern, define *cygwin32_getenv - -Sun Jun 15 20:51:09 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * Makefile.in: add ../libiberty/random.o to EXTRA_OFILES - * cygwin.din: remove exports of tgetent and _tgetent, added random - * exception.cc (exceptions_init): make OurThread handle - noniherittable, remove unused buf array. - (return_handler): add restmask argument (sig_mask value before - calling signal handler) - (call_handler): save sig_mask in user's stack before calling signal - handler, change PulseEvent() call to SetEvent() -- there were - losses of signal_arrived events if main thread was not in wait - state. - (ctrl_c_handler): add support for SIGIO signal. - * fhandler.cc (fhandler_base::linearize/delinearize): - save/restore async_ flag - (fhandler_base::fhandler_base): clear async_ flag - * fhandler.h: add async_ as new variable in fhandler_base, - add get_async/set_async functions - * misc.cc (tgetent): remove stub - * net.cc (fhandler_socket::write): raise SIGPIPE if write to - disconnected socket. - (cygwin32_accept): check the result of find_unused_handle() before - accept() call, set errno if no more file descriptors available. - (fhandler_socket::ioctl): add support for async I/O on sockets - * pinfo.cc (pinfo::clearout): clear sig_pending mask - * syscalls.cc (readv, writev): rewrite - * window.cc (WndProc): add support for async I/O - * winsup.h: define WM_ASYNCIO - -Mon Jun 9 18:51:09 1997 Geoffrey Noer - - * include/winsock.h: fix protection wrapper name - -Fri Jun 6 12:41:09 1997 Ian Lance Taylor - - * include/Windows32/Defines.h: Define CommonDlgExtendedError - return values (CDERR_*, PDERR_*, CFERR_*, FNERR_*). Define - TEXTMETRIC tmPitchAndFamily values (TMPF_*). - - * include/dlgs.h: New file; just includes windows.h. - * include/cderr.h: Likewise. - - * libcmain.cc (main): Don't pass the program name to WinMain. - - * cygwin.din: Export strlwr and strupr. - - * include/winreg.h: New file; just includes windows.h. - * include/winsock.h: New file; just includes windows.h and - Windows32/Sockets.h. - * include/Windows32/Sockets.h: Don't define u_char, et. al. if - _SYS_TYPES_H is defined. Undefine fd_set if it is defined. - - * include/Windows32/Functions.h: Define MoveMemory, FillMemory, - and ZeroMemory as macros. - - * times.cc (_timezone, _daylight, _tzname): New global variables. - (tzset): New function. - * cygwin.din: Don't set _timezone to timezone. Export tzset and - _tzset. Export _timezone, _daylight, and _tzname. - - * dcrt0.cc (__cygwin_environ): New global variable. - (dll_crt0_1): Set __cygwin_environ to environ. - * cygwin.din: Export __cygwin_environ. - -Thu Jun 5 17:52:02 1997 Ian Lance Taylor - - * times.cc (gettimeofday): Check return values and set tz_dsttime - correctly. - -Wed Jun 4 00:04:33 1997 Geoffrey Noer - - * fhandler.cc (fhandler_pipe::lseek): new virtual function - * fhandler.h: add lseek to fhandler_pipe class - -Tue Jun 3 19:20:47 1997 Ian Lance Taylor - - * include/Windows32/Defines.h (IMAGE_DOS_SIGNATURE): Define. - (IMAGE_NT_SIGNATURE): Define. - * include/Windows32/Structures.h (IMAGE_DOS_HEADER): Define. - -Tue Jun 3 13:05:26 1997 Geoffrey Noer - - * console.cc: respace - * fhandler.h: add virtual off_t lseek to fhandler_socket and - fhandler_tty defs, respacing - -Mon Jun 3 12:21:20 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * cygwin.din: export wait3, wait4 - * dcrt0.cc (_exit): call fill_rusage - * exceptions.cc (ctrl_c_handler): increment rusage_self.ru_nsignals++ - * fhandler.cc (fhandler_pipe::fhandler_pipe): new stub - * fhandler.h: add fhandler_pipe class - * hinfo.cc (hinfo_vec::build_fhandler): call - GetNumberOfConsoleInputEvents instead of GetConsoleScreenBufferInfo, - handle fhandler_pipe class - * pinfo.cc: include sys/resource.h, - (pinfo::clearout): erase memory associated with rusage_self - and rusage_children - * resource.cc (getrusage): rewrite - (add_timeval): new helper function - (add_rusage): new helper function - (fill_rusage): new helper function - * shared.cc (create_shared_fd_table): pass file mapping handle to - children letting them close it - * spawn.cc (spawn_guts): call fill_rusage and add_rusage as - appropriate - (cwait): ditto - * times.cc (__to_clock_t): add flag arg which says whether or not - to substract FACTOR from total - (times): also fill in tms_cstime and tms_cutime, add flag arg to - __to_clock_t calls - (totimeval): add extra flag passed on to __to_clock_t - (gettimeofday): add extra flag passed on to totimeval - * wait.cc (wait_for_single): add extra rusage arg, change - wait_found calls to account for extra arg - (wait_for_any): ditto - (_wait): call wait4 instead of waitpid - (wait_found): add rusage arg, deal with it calling add_rusage as - appropriate - (wait_pid): now just calls wait4 - (wait4): was wait_pid but adds extra rusage arg and deals with it - (wait3): new, calls wait4 - * winsup.h: include sys/resource.h, add rusage_self and - rusage_children to pinfo class, fix totimeval proto, add protos - for fill_rusage and add_rusage - * passwd.cc: include termios.h - (getpass): new - * stubs.cc (getpass): delete old stub - -Tue Jun 3 14:51:47 1997 Ian Lance Taylor - - * times.cc (ftime): New function. - * cygwin.din: Export ftime. - -Mon Jun 2 14:34:00 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * include/limits.h: NGROUPS_MAX should be 0 - * include/asm/socket.h: add missing additional options - including SO_SNDBUF, SO_RCVBUF, et al - * include/sys/wait.h: include sys/resource.h, add protos for - wait3() and wait4(). - -Mon Jun 2 15:26:35 1997 Ian Lance Taylor - - * utils/configure.in: Call AC_PROG_INSTALL. - * utils/configure: Rebuild. - -Mon Jun 2 11:44:14 1997 Geoffrey Noer - - * grp.cc (getgroups): new - * cygwin.din: export getgroups - -Fri May 30 16:47:38 1997 Geoffrey Noer - - * uname.cc (uname): completely rewrite, using more of the - SYSTEM_INFO struct to figure out information (now x86 type is - set correctly in Windows 95. - * version.h: increment CYGWIN_DLL_VERSION_MINOR - * include/Windows32/Structures.h: SYSTEM_INFO struct's first - member is dwOemId, not dwOemID according to MS docs - -Fri May 30 16:47:38 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * window.cc: new file - * Makefile.in: add window.cc to lists of source, object files, - and dependencies. - * console.cc: include , scroll_screen() added to - fhandler_console class, - add support for default screen attributes, - (open): set default_color on tty open - (linearize/delinearize): pass default_color to the child process - (clear_screen): fix Win95-specific bug, add support for - default_color. - (clear_to_eol): remove - (fhandler_console::fhandler_console): set default_color to - white on black - (char_command): add invisible screen attribute, misc changes - (FakeReadFile): do not convert AltGr-char to ESC-char sequence - to support international keyboards. - * cygwin.din: export setitimer, getitimer - * dcrt0.cc (dll_crt0_1): add call to window_init(), uppercase - environment vars only if started by a win32 process. - (_exit): add call to window_terminate() - * fhandler.cc: add mode argument to open() calls, - (fhandler_base::open): do not check for symlink in path_conv - calls, calls to set/get_file_attribute() instead of NTRead/WriteEA. - (fhandler_base::fstat): use get_file_attribute if possible - (fhandler_disk_file::open): remove unneeded unixattr checks - * fhandler.h: changes to support above. - * fork.cc (cygwin_fork_helper_1): pass umask value to the child, - call window_init() in child - * ntea.cc: enable EA calls, add FILE_FLAG_BACKUP_SEMANTICS - to CreateFile calls to support EA of directories. - * path.cc (symlink): add mode argument to _open call, remove - unneeded stuff - (symlink_check_worker): add checks for "system" attribute and EA. - * security.cc (get/set_file_attribute): new. Calls EA code now, - placeholders for NTFS security support. - * signal.cc (alarm): remove in favor of new implementation in - window.cc - (RemoteThread): remove - (_kill): use window messages to emulate signals on both NT and Win95 - * spawn.cc (spawn_guts): call window_terminate on exec() - (cwait): correct return result code - (_spawnve): add umask inheritance, some bug fixes - * syscalls.cc (_open): add mode argument, umask support - (umask): rewritten - (chmod): try to set file attributes, set system bit on symlinks - (stat_worker): fix nlinks of directories, add mode argument - to _open() call. - * syscalls.h: add mode argument to _open() prototype - * winsup.h: changes to support above - -Tue May 27 12:22:19 1997 Geoffrey Noer - - * times.cc (gettimeofday): return 0 on success instead of 1 - (utimes): init res to 0 - -Wed May 21 11:29:24 1997 Geoffrey Noer - - * include/limits.h: define NGROUPS_MAX - -Tue May 20 14:13:59 1997 Geoffrey Noer - - * passwd.cc: rename function setpwend to setpwent (typo) - * cygwin.din: ditto, also remove name__C9type_info from - exports list. - -Wed May 14 17:38:39 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * signal.cc (sleep): call WaitForSingleObject instead of Sleep - (usleep): ditto - -Wed May 7 15:34:07 1997 Geoffrey Noer - - Public gnu-win32 beta 18 release made - -Sun May 4 15:34:07 1997 Geoffrey Noer - - patch from Mikey : - * console.cc (FakeReadFile): FlushConsoleInputBuffer if - flags & ENABLE_LINE_INPUT and then return ReadFile - -Fri May 2 10:53:10 1997 Geoffrey Noer - - * signal.cc: make exported functions extern "C" - * include/cygwin32/socket.h: replace values assigned to - IP_ definitions with ones suitable for use with WinSock. - * cygwin.din: add exports for sigpending, sigsuspend, remove - exports for __9type_infoPCc and before__9type_infoRC9type_info - * winsup.h: remove signal-related protos from winsup.h in favor - of newlib/libc/include/sys/signal.h - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * signal.cc: (sigpending) new - (sigsuspend): new - * utils/termcap: replace with one from Linux - -Tue Apr 29 19:03:29 1997 Geoffrey Noer - - * utils/ps.cc: print Win32 pid as unsigned int so Windows 95 - pids don't show up as negative values - -Tue Apr 29 17:20:57 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * spawn.cc (spawn_guts): allocate new cygwin PID for a child - created with spawn(!_P_OVERLAY) - -Tue Apr 29 13:24:59 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * console.cc: assorted console fixes - * select.cc (fd_socket_map::convert_to_unix_fdset): only - do full debug_printf if used_ valid - * exceptions.cc: correct constants used for checking size of - stack (should be negated) - * fhandler.cc (fhandler_base::open): fix syscall_printf typo - - patch from marcus@cathcart.sysc.pdx.edu (Marcus Daniels): - * include/sys/mman.h: define MAP_ANON MAP_ANONYMOUS (typo fix) - -Mon Apr 28 15:19:44 1997 Geoffrey Noer - - * cygwin.din: remove libgcc2.a internal functions - -Mon Apr 28 14:57:04 1997 Michael Meissner - - * cygwin.din (before__9type_infoRC9type_info): Remove, the - type_info::before(type_info const &) function no longer seems to - exist. - -Mon Apr 28 14:19:44 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * console.cc (undo_input): new - (scroll_screen): new - (fhandler_console::output_tcsetattr): fix debug printf - (fhandler_console::input_tcsetattr): no longer call set_w_binary - (fhandler_console::cursor_get): fix base_chars - (fhandler_console::char_command): make savex, savey globals, - add char buf, add code to handle clears better, many other - additions - (fhandler_console::write_normal): assorted fixes - (fhandler_console::write): move screen scroll code to - scroll_screen(), support Reset Linux terminal, Restore cursor - position, Save cursor position, Skip orig_colors - (FakeReadFile): enlarge keytable to include shift/control/alt - values - Command set still missing set pelette, character sets, and - UTF codes. - -Mon Apr 28 12:19:44 1997 Geoffrey Noer - - * fhandler.cc (fhandler_base::open): only include - FILE_SHARE_DELETE in shared when running NT (Win 95 doesn't - support it). - -Thu Apr 24 18:57:21 1997 Geoffrey Noer - - patch from Jeremy Allison : - Correct problem caused by setting /dev/null fd to -1 which is - same as INVALID_HANDLE_VALUE. - * fhandler.h: set DEV_NULL_HANDLE_VALUE to -2 - * fhandler.cc (fhandler_dev_null::open): set handle to - DEV_NULL_HANDLE_VALUE instead of INVALID_HANDLE_VALUE - * hinfo.cc (hinfo_vec::build_fhandler): add case for - handle == (HANDLE) DEV_NULL_HANDLE_VALUE - -Thu Apr 24 15:12:13 1997 Geoffrey Noer - - * fhandler.cc (fhandler_base::write): catch return of raw_write - and return -1 if it failed - -Thu Apr 24 10:42:01 1997 Geoffrey Noer - - path.cc (symlink): restore chmod call for now since the NTEA code - isn't quite up to the task yet. - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * exceptions.cc (ctrl_c_handler): corrections to Apr 18 patch - * fhandler.cc: ditto - * dcrt0.cc (dll_crt0_1): move console title setting code, - set up default signal handlers - * fork.cc (cygwin_fork_helper1): also set child->sigs and - child->sig_mask - * spawn.cc (spawn_guts): if mode _P_OVERLAY, set up child - signal handlers. - -Mon Apr 21 22:29:49 1997 Geoffrey Noer - - * include/Windows32/ASCIIFunctions.h: remove old def of - GetEnvironmentStringsA, add new one based on def from Functions.h - * include/Windows32/Functions.h: define GetEnvironmentStrings as - GetEnvironmentStringsA when not unicode, remove definition of - GetEnvironmentStrings in favor of ones in ASCIIFunctions.h and - UnicodeFunctions.h - * include/Windows32/Defines.h: add missing XTYP_ definitions, - change value of XTYPF_NOBLOCK to 0x0002 from 0x2 - * include/Windows32/Sockets.h: comment out redefinitions of - errno.h-type constants since MS doesn't define them and we - have our own in errno.h - -Fri Apr 18 10:40:30 1997 Geoffrey Noer - - * include/Windows32/Structures.h: add typedefs for - LPDLGITEMTEMPLATE, PDLGITEMTEMPLATE. - * include/Windows32/Defines.h: define FW_REGULAR FW_NORMAL - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * exceptions.cc (ctrl_c_handler): do not reset signal - handler to SIG_DFL while processing the signal, instead - block the signal while handler executes. - * signal.cc (_raise): fixes related to the above - -Thu Apr 17 23:50:50 1997 Geoffrey Noer - - * path.h: increase path length in mount table to MAX_PATH - in size instad of 30. This will increase cygwin.dll memory - usage by 20K. We need to remove static allocations from - path code. - -Thu Apr 17 10:11:50 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * exceptions.cc (ctrl_c_handler): CTRL_CLOSE_EVENT should - generate SIGHUP instead of SIGQUIT - * signal.cc (_raise): rewrite - -Wed Apr 16 10:42:46 1997 Geoffrey Noer - - * version.h: increment CYGWIN_DLL_VERSION_MINOR - * syscalls.cc (system): use spawnvp instead of fork/exec - * ntea.cc: make all functions return false for now; they - were causing an obscene performance hit - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * console.cc (FakeReadFile): patch to support EINTR, EIO - * exceptions.cc: add support for return_handler, remove - control-C counter - (return_handler): new - (ctrl_c_handler): handle SIGCHLD, other assorted fixes - * fhandler.cc (fstat): reset errno to 0 - * passwd.cc (search_for): correct location of a debug printf - * select.cc: patches to handle signals better, respacing - * signal.cc (_raise): misc fixes - (_kill): call OpenProcess with PROCESS_ALL_ACCESS instead of - PROCESS_TERMINATE - * spawn.cc: more signal fixes - * syscalls.cc: add two new errors to errmap[] - (_stat_worker): fill out buf struct when stating directories - * wait.cc (wait_for_single): use INFINITE instead of large value - for timeouts - (wait_for_any): init nprocinfo to 1, not 0, other small fixes - * winsup.h: add signal_arrived to per_process class, reduce - amount of reserved space, add sig_pending to pinfo class - -Tue Apr 15 17:01:34 1997 Geoffrey Noer - - * utils/mkpasswd.c: change default shell to /bin/sh - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * utils/kill.cc: support sending numbered signals using - signal code instead of just calling TerminateProcess - -Tue Apr 15 15:24:55 1997 Ian Lance Taylor - - * utils/Makefile.in (INSTALL): Set to @INSTALL@. - (INSTALL_PROGRAM): Set to @INSTALL_PROGRAM@. - (INSTALL_DATA): Set to @INSTALL_DATA@. - (INSTALL_XFORM): Remove. - (install): Depend upon installdirs. Use $(program_transform_name) - directly, rather than using $(INSTALL_XFORM). - (installdirs): New target. - -Mon Apr 14 16:32:05 1997 Ian Lance Taylor - - * utils/Makefile.in (INSTALL): Change install.sh to install-sh. - -Mon Apr 14 12:33:22 1997 Geoffrey Noer - - * registry.cc: change key name to "Cygnus Solutions" instead - of "Cygnus Support" - * security.cc: don't include windows.h, already in winsup.h - * Makefile.in: add dependencies section entries for security.cc - and ntea.cc - -Fri Apr 11 00:03:49 1997 Geoffrey Noer - - * dcrt0.cc: add harmless cast to FreeEnvironmentStrings call - * registry.cc: added more presumed-harmless casts - * shared.cc: and another, and respacing - * utils/Makefile.in: don't need to link with -lkernel32 since it's - included automatically - * fhandler.cc: fhandler_console and FakeReadFile moved to - console.cc, stop including sys/stat.h, sys/param.h, sys/types.h, - stdio.h, ctype.h, pwd.h, grp.h, stdlib.h - reordered/respaced code so now we have all of fhandler_base, then - all of fhandler_disk_file, then all of fhandler_tty, etc... - (fhandler_base::ioctl): delete unused switch statement - * console.cc: added fhandler_console and FakeReadFile from - fhandler.cc, add includes necessary for this code - * grp.cc, Makefile.in: fix copyright dates - * ntea.cc: include string.h - -Thu Apr 10 22:00:43 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * path.cc (symlink): do NTWriteEA instead of chmod using same - flags - -Thu Apr 10 17:36:43 1997 Geoffrey Noer - - patch from gunther.ebert@ixos-leipzig.de (Gunther Ebert): - * Makefile.in: add libnetapi32.a to DLL_IMPORTS list, build security.o - * fhandler.cc (get_file_owner): new - (get_file_group): new - (fhandler_base::fstat): do another path_conv and check for error, - use get_file_owner and get_file_group to set buf->st_uid and - buf->st_gid - * fhandler.h: add protos for get_file_owner() and get_file_group() - * grp.cc (add_grp_line): new helper function - (read_etc_group): new helper function - (getgrgid): rewritten, no longer a stub - (getgrnam): rewritten, no longer a stub - (endgrent): rewritten, no longer a stub - (getgrent): rewritten, no longer a stub - * include/Windows32/ASCIIFunctions.h, include/Windows32/Base.h, - include/Windows32/Functions.h, include/Windows32/Defines.h, - include/Windows32/Structures.h, include/Windows32/UnicodeFunctions.h: - misc security/uid-related additions - * passwd.cc (add_pwd_line): new - (read_etc_passwd): new - (search_for): rewrite - (setpwend): rewritten, no longer a stub - (getpwent): rewritten, no longer a stub - (endpwent): rewritten, no longer a stub - * security.cc: new file - (get_world_sid): new - (world_full_access): new - (get_id_from_sid): new - (is_nt): new - * stubs.cc (endgrent): remove - (getgrent): remove - * syscalls.cc (rel2abssd): new - (set_process_privileges): new - (chown): now implemented for real for NT, still a stub in Win95 - (_stat_worker): use get_file_owner and get_file_group to set - buf->st_uid and buf->st_gid - * uinfo.cc: add protos for read_etc_passwd, read_etc_group - (uinfo_init): call read_etc_passwd(), read_etc_group() - * utils/Makefile.in: build mkpasswd, mkgroup - * utils/mkgroup.c: new, use to make an /etc/group file - * utils/mkpasswd.c: new, use to make an /etc/passwd file - * winsup.h: add protos for is_nt(), get_id_from_sid() - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * Makefile.in: build ntea.o - * dcrt0.cc (dll_crt0_1): move console title code here from spawn_guts - * exceptions.cc (ctrl_c_handler): small signal fixes, prepare - things so we can eventually reset the signal handler to SIG_DFL - * fhandler.cc (fhandler_disk_file::open): first check for EA info - about exec/symlink status before doing it the hard way - (fhandler_make_pipe): u->self->hmap.build_fhandler takes extra arg - (fhandler_base::open): make use of NTEA - * fhandler.h: remove init_std_file_from_handle, build_fhandler - protos - * hinfo.cc: include mywinsock.h and sys/socket.h, define - __INSIDE_CYGWIN_NET__, __INSIDE_CYGWIN32__ - (hinfo_vec::build_fhandler): takes an additional handle arg, - call GetConsoleScreenBufferInfo with it to see if are - fhandler_console, call GetCommState with it to see if we're - an fhandler_tty, call getpeername with it to see if we wamt - fhandler_socket. Old determining methods still work too. - * path.cc (symlink): chmod file to ((S_IFLNK) | (STD_RBITS) | - (STD_WBITS) | (STD_XBITS)) permissions - * select.cc: include stdio.h - (cygwin32_select): fix typo (missing an &), - assorted fixes for mixed socket/handles case - * shared.cc (create_shared_fd_table): set sa.bInheritHandle to 1 - to support reparenting - * signal.cc (_kill): add FIXME, cleanup return codes - * spawn.cc (spawn_guts): remove console title code, add code - to support reparenting of child processes - * syscalls.cc: add new third arg to hmap.build_fhandler calls - (chmod): make use of NTWriteEA - * ntea.cc: new file, NTEA handling routines - * times.cc: fix value of NSPERSEC - (utimes): fix return value - * wait.cc: changes to support reparenting, change INFINITE to - constant 500 to avoid "blocking win32 syscalls and signals" - problem - * winsup.h: add NTReadEA, NTWriteEA protos, define REPARENTING, - fix build_fhandler proto to add new arg, add handles hrProcess and - hrThread - -Tue Apr 9 00:25:33 1997 Geoffrey Noer - - * libcerr.cc: remove fixed size of sys_errlist array, figure out - sys_nerr from the sizeof the array rather than hard coding it. - * shared.cc (open_shared_file_map): add typecast - * signal.cc (_kill): SIGKILL should avoid exception handler - * fork.cc (cygwin_fork_helper1): don't call ExitProcess with a - negative arg on recreate_mmaps_after_fork failure - * include/Windows32/Defines.h: define VER_PLATFORM_WIN32_WINDOWS - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * dcrt0.cc: move reent_data from private address space to cygwin.dll - * fork.cc: copy parent's reent_data to the child - * cygwin.din: export reent_data - * winsup.h: add as public struct _reent reent_save to pinfo class - - another patch from sos@prospect.com.ru (Sergey Okhapkin): - * winsup.h: add ctrl_c_handler prototype - * exceptions.cc (init_exceptions): don't use u->self->hThread - since for a spawned process, this contains thread id of parent - Win32 process, not the child's. Instead use GetCurrent* funcs - to get thread handle. - (ctrl_c_handler): add more signal support, especially for kill - * signal.cc (_kill): more signal support, using CreateRemoteThread - under NT. Win95 only supports SIGKILL since it doesn't have this - call. - * syscalls.cc (windows_95): first version check should be an & - of 0x80000000 instead of 0x8000000 - (close_all_files): hmap[i] doesn't always exist, for now comment - out code - - patch from marcus@sysc.pdx.edu (Marcus Daniels): - * path.cc (skip_n_slashes): new local function - (symlink_check_worker): new local function, used to be symlink_check - (symlink_check): calls symlink_check_worker and returns - whether path is a symlink or not. - (symlink_expand): new local function, expand a symlink into - a file or directory path using symlink_check_worker - (path_conv::path_conv): takes extra follow_mode arg - (symlink_follow): call symlink_expand - * fhandler.cc, syscalls.cc: fix path_conv references - * path.h: fix path_conv prototype - -Mon Mar 24 19:44:28 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * select.cc: fix Feb 19 patch to select - * syscalls.cc: add statfs() and fstatfs() calls - * include/sys/vfs.h: new header file to support these - * cygwin.din: add them to dll export list - -Tue Mar 18 18:10:24 1997 Geoffrey Noer - - * dcrt0.cc: change idata3 asm section to have five null fields - instead of eight to conform to how MS does this section. - -Sun Mar 9 13:10:55 1997 Geoffrey Noer - - * include/sys/resource.h: add missing struct members to rusage struct - * resource.cc: added setting of missing fields, mostly to 0 until - we investigate how to set correct values. - -Wed Feb 19 17:44:06 1997 Jeremy Allison - - * select.cc: Added fixes from sos@prospect.com.ru (Sergey Okhapkin) - to implement blocking select on sockets/handles. This isn't - the way I finally want to do this, but I won't get chance - to do the re-write for a month or two so... - * include/Windows32/Defines.h: Added defines for NT ACL - stuff. - -Tue Feb 18 12:28:11 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * fhandler.cc: support reverse index escapes in console code - -Fri Feb 14 18:55:01 1997 Jeremy Allison - - * path.cc: Fixed normalize_posix_path() so that double slashes - are removed, except for those starting a UNC path. The command - ls .///////FILE_IN_DIRECTORY works now. - -Thu Feb 13 14:06:04 1997 Geoffrey Noer - - * path.cc: remove SLASH_P define and - * winsup.h: define it here instead - patch from scottk@utig.ig.utexas.edu (Scott Kempf): - dirsearch.cc (opendir): fix problem with accessing "/" - -Mon Feb 10 13:57:11 1997 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * misc.cc: replace nice () stub with Win32 implementation - * spawn.cc - * fork.cc: use priority returned by GetPriorityClass - -Wed Feb 5 16:56:23 1997 Geoffrey Noer - - * fhandler.cc, syscalls.cc: minor reformat - patch from sos@prospect.com.ru (Sergey Okhapkin): - * spawn.cc: set console title to reflect what's running - * winsup.h: TITLESIZE define added - -Mon Feb 3 16:53:10 1997 Geoffrey Noer - - * fhandler.h: fix typo - * fhandler.cc: check_execable_p should only take one arg now - -Mon Feb 3 16:16:39 1997 Jeremy Allison - - * fhandler.cc: Removed open_helper, turned it into - fhandler_base::open and added fhandler_disk_file::open. More - correct C++. - fhandler_disk_file: Moved check_execable_p into fhandler_disk_file. - tty ports are now closed correctly. - * fhandler.h: Changes to support the above. - -Fri Jan 31 19:14:34 1997 Geoffrey Noer - - * fhandler.cc (fhandler_base::open_helper): new function - containing the common open() code. symlink and executable - status defaults to 0. - (fhandler_tty::open): new function that calls - fhandler_base::open_helper - (fhandler_base::open): remove common code now in open_helper, - leaving symlink checking and executable checking - * fhandler.h: changes for the above, open_helper is protected - -Thu Jan 30 15:23:15 1997 Geoffrey Noer - - * hinfo.cc: also treat com3 and com4 as special files - * spawn.cc (spawn_guts): check return of WaitForSingleObject - in _P_WAIT case, some reformatting - -Tue Jan 28 10:46:16 1997 Jeremy Allison - - * net.cc: Added errors "WSAEINVAL", "WSAEFAULT" as these - can be returned for net calls. - * fhandler.cc: Added FILE_SHARE_DELETE to open share modes. - Much closer to POSIX on NT now (ignored on '95). - -Fri Jan 17 13:32:26 1997 Geoffrey Noer - - * configure.in: - * utils/configure.in: define LIB_AC_PROG_CC to get around - autoconf 1.12 problem. Invoke it instead of AC_PROG_CC. - * configure: - * utils/configure: regenerate - -Thu Jan 16 12:35:41 1997 Geoffrey Noer - - * mmap.cc: added missing copyright notice - -Tue Jan 14 12:51:12 1997 Jeremy Allison - - * cygwin.din: Added get_osfhandle, cwait and all the - spawn functions. - * exec.cc: Added include of process.h. Changed call to - spawn_guts to add extra parameter. - * libcerr.cc: Added extra error messages. Ensured - messages start at zero. - * spawn.cc: Changed spawn_guts to do wait and nowait - calls. Added all spawn functions. - * syscalls.cc: Added get_osfhandle. - * winsup.h: Removed incorrect spawn definitions, - corrected prototypes for spawn_guts and file_exists - calls. - * include/io.h: New file. Added for get_osfhandle. - -Thu Jan 9 14:20:01 1997 Jeremy Allison - - * exceptions.h: Moved from winsup to winsup/include. - * include/mywinsock.h: Added getprotobynumber and - getservbyport. - * Makefile.in: Moved exceptions.h dependency. - * cygwin.din: Added cygwin32_getprotobynumber and - cygwin32_getservbyport. - * net.cc: Added cygwin32_getprotobynumber and - cygwin32_getservbyport. - -Wed Jan 8 14:15:35 1997 Jeremy Allison - - * fhandler.cc: Fix from Scott Kempf (scottk@rimu.ig.utexas.edu) - to ensure creation_disposition is set correctly in open. - -Fri Jan 3 12:10:22 1997 Jeremy Allison - - * fork.cc: Added parameter to recreate_mmaps_after_fork - in child, and added set_child_mmap_ptr() call in parent. - Needed as cygwin.dll statics are not copied accros a fork. - * mmap.cc: Added parameter to recreate_mmaps_after_fork, - added set_child_mmap_ptr() call. - * winsup.h: Added mmap_ptr to pinfo struct. Removed obsolete - comments. - * Makefile.in: Added -I../libio, needed to rebuild source - using STL. Also added -nostdinc++ on recommendation of - Mike Stump (mrs@cygnus.com). - -Thu Jan 2 17:23:10 1997 Jeremy Allison - - * dcrt0.cc: Added a call to initialize winsock on app - init. - * fork.cc: Added call so child initializes winsock before - returning from the fork. This makes many network daemons - run correctly that did not before (apache soon...). - * net.cc: Removed calls to checkinit, this is now done on - app startup. Renamed checkinit to socket_checkinit and - removed static scope. - * winsup.h: Added prototype for socket_checkinit(). - -Thu Jan 2 12:25:06 1997 Jeremy Allison - - * dcrt0.cc (api_fatal): Check that u and u->self are - not zero before indirecting through them. - * fork.cc: Changed security descriptor for fork - mutexes to allow access by all. - * pinfo.cc: Changed security descriptor for shared - area to allow access by all. - * shared.cc: Added get_null_sd() call to return - security descriptor allowing access by all. Needed - when a cygwin32 service is running and also interactive - cygwin32 apps by the current logged in user. - * winsup.h: Added prototype for get_null_sd(). diff --git a/winsup/cygwin/ChangeLog-1998 b/winsup/cygwin/ChangeLog-1998 deleted file mode 100644 index aa657e01e..000000000 --- a/winsup/cygwin/ChangeLog-1998 +++ /dev/null @@ -1,4490 +0,0 @@ -Thu Dec 31 16:50:32 1998 DJ Delorie - - * mmap.cc: replaced all references to libstdc++ templates with - inline classes to remove build dependency on libstdc++ - -Thu Dec 31 00:02:40 1998 Geoffrey Noer - - * sysdef/uuid.def: remove useless stub. - * sysdef/oldnames.def: ditto. - * sysdef/largeint.def: ditto. - * sysdef/rpcndr.def: ditto. - -Wed Dec 30 20:33:09 1998 Geoffrey Noer - - * utils/cygcheck.cc: clean up misc. warnings relating to - signed vs. unsigned, char * vs. const char *, etc... - -Wed Dec 30 21:41:25 1998 Christopher Faylor - - * dcrt0.cc (do_exit): Remove previous dwProcessId - change as it presumes too much knowledge about signalling - in the wrong place in the code. - * sigproc.cc (sigproc_terminate): Move the dwProcessId - assignment here but only do it when it is necessary or - programs will die abnormally. - * fhandler.h: Add raw_write method to fhandler_serial. - * fhandler_serial.cc (raw_write): New method. Accommodates - overlapped I/O that now must be used with serial. - * utils/kill.cc (main): Allow `0' signal. Just checks - for existence of process. - -Wed Dec 30 00:01:18 1998 Geoffrey Noer - - * include/cygwin/version.h: bump API_MINOR to 8 to mark - recently exported _ctype_, _sys_errlist, _sys_nerr. Briefly - describe all API_MINOR changes to date. - -Wed Dec 30 01:31:34 1998 Christopher Faylor - - * dcrt0.cc (do_exit): Set myself->dwProcessId so that - some exit routines will not falsely believe that this - process has been execed. - * select.cc (peek_serial): Remove debugging statements. - * sigproc.cc (sigproc_terminate): Detect state where - myself->dwProcessId == 0 as indicative of not being - an exec stub. - -Tue Dec 29 21:13:33 1998 Christopher Faylor - - * dcrt0.cc (alloc_stack_hard_way): Fix a couple of thinkos - in calculating size of the new stack. Just use the size - passed from the parent. - (dll_crt0_1): Set up new frame pointers here, if appropriate. - * fork.cc (fork): Move frame pointer setup into dll_crt0_1. - -Tue Dec 29 12:57:38 1998 Geoffrey Noer - - * utils/mkpasswd.c: Include wchar.h. - * utils/mkgroup.c: Ditto. - -Tue Dec 29 12:53:23 1998 Geoffrey Noer - - * Makefile.in: remove dep for libcerr.o - -Mon Dec 28 22:02:15 1998 Christopher Faylor - - * fhandler.h: Make fhandler_serial io_status public since - select needs it. Add 'saw_error' field to select_record so - that select can detect error conditions. - * fhandler_serial.cc (fhandler_serial::raw_read): Detect - "operation aborted" error and retry. This seems to indicate - an attempt to retry an overlapped operation. - * select.cc (select_stuff::wait): Honor saw_error field when - appropriate. - (peek_serial): Rewrite to operate similarly to - fhandler_serial::raw_read. - * include/sys/termios.h: CBAUD mask was still not right. - -Mon Dec 28 09:09:27 1998 Christopher Faylor - - * libcerr.cc: Make obsolete. Move into errno.cc - * libctype.c: Make obsolete. Use newlib table. - * Makefile.in: Remove obsolete entries from LIBCOS. Define - __INSIDE_CYGWIN__ explicitly for .c -> .o compilation. - * cygwin.din: New exports: _ctype_, _sys_errlist, _sys_nerr. - * errno.cc: Move _sys_errlist and _sys_nerr here. - * dlfcn.cc: Reorganize includes to put ctype.h after winsup.h - so that __INSIDE_CYGWIN__ will be defined for use in ctype.h. - * fhandler_console.cc: Ditto. - * fhandler_tty.cc: Ditto. - * path.cc: Ditto. - * spawn.cc: Ditto. - -Sat Dec 26 00:20:48 1998 Christopher Faylor - - patch from Corinna Vinschen : - * include/Windows32/CommonFunction.h: Added proto for - NetUserChangePassword(). - -Thu Dec 24 16:15:40 1998 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Add more debugging output. - * ioctl.cc (ioctl): Can't use TC[GS]ET ioctls for pty master as - it conflicts with TIOCPKT. - * passwd.cc (passwd): Bypass tc[gs]etattr call in favor of appropriate - method or conversion confusion will result due to attempts to - appropriately convert to old-style termios structures in tc[gs]etattr. - * strace.cc (strace_vsprintf): Define t explicitly. - * termios.cc (tcsetattr): Reorganize to allow meaningful debugging - output. - (tcgetattr): Ditto. - -Wed Dec 23 15:02:11 1998 Christopher Faylor - - * winsup.h: Reorganize include order to allow thread-safe build. - -Wed Dec 23 11:45:33 1998 DJ Delorie - - * strace.cc (strace_microseconds): new function; returns elapsed - time in microseconds, using performance counters if available. - (strace_vsprintf): print timestamps and deltas as microseconds, - not seconds. - -Wed Dec 23 11:35:02 1998 DJ Delorie - - * times.cc (__to_clock_t): Change return value to unsigned long - long to prevent overflow. - -Tue Dec 22 19:37:55 1998 Christopher Faylor - - * fhandler.h: Reflect fhandler_*::init argument reordering. - Add dup and init methods to fhandler_serial. - * fhandler.cc (fhandler_base::init): Reorder arguments to mirror - open(). - * fhandler_console.cc (fhandler_console::init): Ditto. Initialize - using fhandler_base rather than fhandler_serial as console is - now being slowly uncouple from fhandler_serial. - * fhandler_serial.cc (fhandler_serial::fhandler_serial): Set size - of data structure or suffer strange behavior on exec(). - (raw_read): Add debugging output. - (fhandler_serial::init): New method. - (fhandler_serial::open): Detect call from init method and avoid - calling fhandler_base::open. Don't worry about non-blocking reads - since they are now handled correctly by _read(). - (fhandler_serial::tcsetattr): Honor ICANON in a kludgey sort of way. - (fhandler_serial::tcgetattr): Ditto. - (fhandler_serial::dup): New method. Ensures duplication of all - elements of fhandler_serial class. - * fhandler_tty.cc (fhandler_tty_master::init): Reflect init argument - reordering. - (fhandler_tty_slave::init): Ditto. - * hinfo.cc (hinfo::init_std_file_from_handle): Remove unnecessary - argument. - (hinfo_init): Reflect change to init_std_file_from_handle. - (cygwin_attach_handle_to_fd): Use more appropriate types for - arguments. - (hinfo::build_fhandler): Add some slop to allocated buffer just - for paranoia's sake. - (hinfo::dup2): Avoid dereferencing a NULL pointer when oldfd==newfd. - * pipe.cc (make_pipe): Reflect init argument change. - * shared.h: Another immigrant from winsup.h - * winsup.h: Reflect change to init_std_file_from_handle. Relocate - a declaration to shared.h so that it can be used in fhandler.h. - * include/sys/cygwin.h: Reflect change to cygwin_attach_handle_to_fd. - -Mon Dec 21 16:22:48 1998 Christopher Faylor - - * fhandler.cc (fhandler_base::open): Detect serial device as a special - case requiring an overlapped open. - * fhandler.h (fhandler_serial): Add several methods. Add new 'fixup after - fork required' field. - * fhandler_serial.cc (raw_read): Rewrite to come closer to handling VMIN - VTIME parameters and to allow EINTR. - (fhandler_serial::open): Initialize overlapped event here. Make error - messages more explicit. - (fhandler_serial::close): Close status event. - (fhandler_serial::tcsetattr): Store vtime_ as milliseconds. Attempt to - handle VMIN > 0, VTIME == 0 better. - (fhandler_serial::fixup_after_fork): Initialize a new event handle after - a fork. - (fhandler_serial::de_linearize): Ditto. - * hinfo.cc (hinfo::fixup_after_fork): Call fork fixer upper if close_on_exec - of need_fork_fixup set. - -Sun Dec 20 16:05:25 1998 Geoffrey Noer - - * include/shellapi.h: replace with stub that includes windows.h - like similar headers already do. - * scandir.cc (scandir): add parens around assignment used as truth - value. - -Sat Dec 19 00:42:44 1998 Christopher Faylor - - * thread.cc: Fix copyright info. - * thread.h: Ditto. - * libcmain.cc: gcc is now more picky about requiring a type - for main(), so add one. - * include/pthread.h: Add attribution for net contributor. - -Fri Dec 18 19:21:30 1998 Geoffrey Noer - - * pthread.cc: fix copyright header. - * shared.h: ditto. - -Fri Dec 18 19:21:30 1998 Geoffrey Noer - - patch from Corinna Vinschen : - * cygwin.din: export scandir and alphasort. - * Makefile.in: add scandir.o to deps - * scandir.cc: New file with scandir and alphasort implementations. - * include/cygwin/version.h: bump API_MINOR to 7. - -Fri Dec 18 16:44:07 1998 Geoffrey Noer - - * include/pthread.h: clean up, remove C++-style comments, - remove pthread_getsequence_np proto. - -Fri Dec 18 15:26:33 1998 Christopher Faylor - - Throughout, prepend cygwin_ to functions that are exported - as cygwin_* which previously needed to be aliased. - - * path.cc (cygwin_conv_to_win32_path): Resolve symbolic links. - Return success or failure value. - (cygwin_conv_to_full_win32_path): Ditto. - (cygwin_conv_to_posix_path): Return success or failure value. - (cygwin_win32_to_posix_path_list): Ditto. - (cygwin_posix_to_win32_path_list): Ditto. - * shared.h: New include file that incorporates parts of - winsup.h, fhandler_tty.h, path.h, and delqueue.h. - * Makefile.in: Remove old include files. - * cygwin.din: cygwin_* aliases are no longer required. - * libccrt0.cc: Store api_minor in per_process structure. - * select.cc: Change meaning of second argument to ready_for_read - to indicate whether read_ahead should be ignored. - * fhandler.h: Reflect change in second argument to ready_for_read. - * syscalls.cc (_read): Ditto. - * termios.cc: Throughout, detect attempt to use old style termios - structure and convert as appropriate. - * ioctl.cc (ioctl): Detect use of ioctl requiring termios field - and call appropriate tc[gs]et* function to handle it. - * fhandler_console.cc (fhandler_console::ioctl): Remove TC* calls - that are now handled in main ioctl. - * fhandler_tty.cc (fhandler_tty_slave::ioctl): Ditto. - * include/cygwin/version.h: Added TERMIOS defines. Bump API_MINOR - to 6. - * include/sys/cygwin.h: Reflect change in return value for some - cygwin_conv_* calls. - * include/sys/termios.h: Reformat slightly. Add conversion macros - for dealing with old style termios structure. - * include/pthread.h: add - -Fri Dec 18 15:03:33 1998 Christopher Faylor - - * Makefile.in: Cleanup pthread usage. - -Fri Dec 18 14:35:59 1998 Christopher Faylor - - * Makefile.in: Remove obsolete header dependency for - thread-safe build. - -Fri Dec 18 14:16:04 1998 Christopher Faylor - - * exceptions.cc (sig_handle): Avoid suspending top-level - processes. - * trace.cc: Remove unneeded include. - -Thu Dec 17 19:19:53 1998 Geoffrey Noer - - * cygwin.din: remove pthread_getsequence_np, _reent_clib - -Thu Dec 17 16:48:15 1998 Geoffrey Noer - - * include/cygwin/version.h: correct two typos in comments - -Thu Dec 17 19:11:31 1998 Christopher Faylor - - patch from Corinna Vinschen : - * include/Windows32/Defines.h: Add values for using Windows - function `DeviceIoControl()'. - -Thu Dec 17 18:00:34 1998 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): exception_list is not a struct. - * debug.cc (thread_stub): Ditto. - -Thu Dec 17 08:24:37 1998 Christopher Faylor - - * cygwin.din: Remove leading underscores from pthread functions. - * include/cygwin/version.h: Bump DLL major version to 21, DLL minor - version to 0, and API_MINOR to 5. - -Wed Dec 16 22:54:16 1998 Christopher Faylor - - Merge in thread-safe branch changes. - -Wed Dec 16 22:54:16 1998 Christopher Faylor - - * pthread.cc: Include winsup.h. - -Wed Dec 16 22:54:16 1998 Christopher Faylor - - * thread.cc: Reformat. - * pthread.cc: New file. - * cygwin.din: Add pthread interface functions - -Wed Dec 16 22:54:16 1998 Christopher Faylor - - * configure.in: Add some --enable options. - * configure: Regenerate. - * Makefile.in: Reorganize CFLAGS to recognize new --enable options. - -Wed Dec 16 22:54:16 1998 Christopher Faylor - - * fork.cc (stack_base): Store slightly different information - in child_info_fork structure for later use in alloc_stack_hard_way. - (fork): Set frame pointer information if stack has been reallocated. - * dcrt0.cc (alloc_stack_hard_way): Reflect change in - child_info_fork structure. - (dll_crt0_1): Make thread initializers "static" and NO_COPY or death - of the main thread causes death of other threads. - * winsup.h (child_info_fork): Change structure. - -Wed Dec 16 22:54:16 1998 Christopher Faylor - - * thread.h: Remove extraneous declaration. - * include/sys/strace.h: Make a new thread_printf function - for use by new thread-safe code. - * thread.cc: Use thread_printf throughout. - -Wed Dec 16 22:54:16 1998 Christopher Faylor - - patch from Marco Fuykschot (marco@ddi.nl) - * Throughout sources add locking control for preliminary - thread-safe cygwin operation. - -Wed Dec 16 22:54:16 1998 Christopher Faylor - - * dcrt0.cc (getprogname): Should be a static. - (alloc_stack): Extend to allow forking from another - thread. - (alloc_stack_hard_way): New function used by alloc_stack. - (dll_crt0_1); Don't pass parameters since stack may be - "funny". Use statics instead. Move fork/spawn checking - into dll_crt0. - (dll_crt0): Do fork spawn checking here. alloc_stack() - will call dll_crt0_1 if forked from a non-main thread. - * fork.cc (stack_base): New function determines base - (and other values) of this thread's stack. - (fork): Use new PROC_FORK1 method for forking. Provides - more data to forkee. Use stack_base to set stack - values. - * winsup.h (child_info_fork): Changes for PROC_FORK1. - -Wed Dec 16 16:15:29 1998 Geoffrey Noer - - * include/shellapi.h: fix typo in DragQueryPoint proto. - -Mon Dec 14 12:37:43 1998 Geoffrey Noer - - * net.cc: minor respacing - (get_ifconf): new local function, combines get_winnt_ifconf and - get_win95_ifconf. - (get_win95_ifconf): delete - (get_winnt_ifconf): delete - (fhandler_socket::ioctl): adjust ifconf calls in light of above, - check returned value for safety. - * include/cygwin/version.h: bump CYGWIN_VERSION_API_MINOR to 4 - in honor of newly supported socket ioctls. - - patch from Corinna Vinschen : - * include/asm/socket.h: Added defines for ioctl() calls - SIOCGIFADDR, SIOCGIFBRDADDR and SIOCGIFNETMASK. - * net.cc (get_winnt_ifconf): Check the registry entries - instead of just calling get_win95_ifconf(). Added what argument - to support the new ioctl() calls. - (get_win95_ifconf): Check the Windows 9x registry entries as - described by Tim Newsham. - (fhandler_socket::ioctl): Support the ioctl() commands - SIOCGIFADDR, SIOCGIFBRDADDR and SIOCGIFNETMASK. - (get_if_flags): Check for a down interface. - -Wed Dec 9 18:11:31 1998 Geoffrey Noer - - * fhandler.cc (fhandler_disk_file::open): check for shell scripts - regardless of Win32 OS type. - -Sun Dec 6 19:38:11 1998 Christopher Faylor - - patch from Corinna Vinschen : - * fhandler_console.cc (fhandler_console::tcgetattr): Fix typo. - ISIG should be ored with c_lflag. - -Tue Dec 1 16:28:56 1998 Geoffrey Noer - - * include/utmp.h: delete, moved to newlib/libc/sys/cygwin/sys. - -Thu Dec 3 15:41:51 1998 Geoffrey Noer - - Released 20.1 update. - -Thu Dec 3 22:24:18 1998 Christopher Faylor - - * exceptions.cc (set_process_mask): Add `sync' parameter - to control whether signals should be synched on exit. - (handle_sigsuspend): Provide second argument to set_process_mask - - don't sync. - (call_handler): Ditto for asm handler. - * signal.cc (sigprocmask): Ensure that signals are synchronized - by calling set_process_mask with sync == 1. - * sigproc.cc (__release_signal_mutex): Third argument is not - strictly a BOOL, so change it. - * sigproc.h: Reflect above parameter changes. - -Thu Dec 3 15:30:44 1998 Christopher Faylor - - * select.cc (peek_console): Work around NT bug that - caused strange behavior with ReadFile after this - function was invoked. - -Tue Dec 1 14:43:35 1998 Christopher Faylor - - * sigproc.cc (sigproc_init): Set maintid and signal_mutex early - to avoid races in wait_sig initialization. - (__get_signal_mutex): Improve debug output. - (__release_signal_mutex): Ditto. - * spawn.cc (spawn_guts): Allocate more space for string when building - up from #! and absolute path is not known. Otherwise weird stuff - like infinite recursion or unknown file errors occur. - -Tue Dec 1 08:34:18 1998 Christopher Faylor - - * mkvers.sh: Accommodate lack of timezone in date output so that - year shows up correctly. - -Mon Nov 30 14:30:51 1998 Jeff Johnston - - * times.cc (times): Altered function so that on non-Windows-NT systems - it does not use the GetProcessTimes() API which is not supported. - -Mon Nov 30 00:38:54 1998 Christopher Faylor - - * dcrt0.cc: Fix incorrect use of struct on exception_list - typedef. - * debug.cc (thread_stub): Ditto. - * dll_init.cc: Ditto. - * include/Windows32/Structures.h: Correct typo where - typedef SYSTEM_POWER_STATUS was being used as a struct. - -Sun Nov 29 22:03:17 1998 Christopher Faylor - - patch from Corinna Vinschen : - * fhandler_console.cc (fhandler_console::ioctl): - Added ioctl commands TCGETA, TCSETA, TCSETAW, TCSETAF. - -Fri Nov 27 22:30:58 1998 Christopher Faylor - - * fhandler.h: Set aside NOEINTR bit. When this is set - cygwin will not allow the read on this device to be - interrupted by a signal. - * pipe (_pipe): Set NOEINTR bit for read end of pipes - created using this method. The vague rationale for this - is that these pipes are supposed to be more like Windows - pipes than UNIX pipes. - * syscalls.cc (_pipe): Honor NOEINTR flag. - * getopt.c: Clean up some gcc warnings. - * libcerr.c: Ditto. - -Fri Nov 27 21:56:03 1998 Christopher Faylor - - * exceptions.cc (SIG_NONMASKABLE): Update for new signal - mask method. - (handle_sigsuspend): Release of signal mutex must be - synchronous -- the signal must be delivered before the - function returns. Otherwise, there will be races in - the caller code. - * sigproc.cc (sigproc_terminate): Minor cleanup. - -Thu Nov 26 20:26:17 1998 Christopher Faylor - - * exceptions.cc (call_handler): Attempt to work around - potential race when setting signal_arrived. This - particularly affects sigsuspend. - (handle_sigsuspend): Reset signal_arrived prior to - grabbing the mutex. This should reduce the probability - of a race. - * sigproc.cc (sig_send): Don't reset signal_arrived in - the SIGSUSPEND case since this could introduce a race. - -Thu Nov 26 12:19:16 1998 Christopher Faylor - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * select.cc (MAKEready): Don't wait for signal prior to - testing for read. That introduces an unnecessary delay. - -Wed Nov 25 23:03:47 1998 Christopher Faylor - - * winsup.h: Make `isdirsep' an alias for SLASH_P. - Implement isabspath convenience macro. - Change sigprotect to a macro since it appears to - be impossible to send __FILE__ type macros to a - constructor. Change use of sig_protect throughout. - * dcrt0.cc (dll_crt0_1): Use new path macro. - * dlfcn.cc (get_full_path_of_dll): Ditto. - * path.cc (path_conv::path_conv): Ditto. - (normalize_posix_path): Ditto. - (slashify): Ditto. - (backslashify): Ditto. - * syscalls.cc (num_entries): Ditto. - * lock.cc: Redefine lock methods to pass debug info to - {get,release}_signal_mutex. - * environ.cc (environ_init): Correct strncmp test for - TERM=, otherwise it's impossible to set TERM. - * exceptions.cc: Eliminate lock_cs and unlock_cs macros. - Use {get,release}_signal_mutex throughout. - (signal_init): Don't initialize signal_mutex here. - (set_process_mask): Remove vestiges of old mutex code. - (handle_sigsuspend): Ditto. - (call_handler): Move signal_arrived SetEvent back here. - It was being triggered too often before. - Detect when the signal thread is exiting. - (sig_handle): Remove inappropriate SetEvent(signal_arrived). - (events_terminate): Move close of signal_mutex elsewhere. - * glob.cc: Increase "MAXPATHLEN" size for arguments that - are not necessarily pathnames. - * pinfo.cc (lpfu): Lower timeout for reporting possible - problem with INFINITE wait. - * sigproc.cc (wake_wait_subproc): Make this a macro with - no arguments so that its use in the code is a little - clearer. - (proc_terminate): Eliminate signal blocking here since - this should already be handled by the caller. - (sigproc_init): It makes sense to initialize signal_mutex - here, so do so. - (__allow_sig_dispatch): Rename. Take debugging arguments. - Pass arguments on to release_signal_mutex. - (__block_sig_dispatch): Rename. Take debugging arguments. - Pass arguments on to get_signal_mutex. Detect signal - thread exiting confition. - (__get_signal_mutex): Take debugging arguments. Maintain - a stack of nested mutex calls for later display in - __release_signal_mutex. Detect signal thread exit - condition. Don't bother with locking if signal thread is - executing or if just an exec stub. - (__release_signal_mutex): Don't bother with locking if signal - thread is executing or if just an exec stub. - * sigproc.h: Reflect renamed functions above. Provide - wrappers to pass in diagnostic information. - * spawn.cc (spawn_guts): More fixes to deal with nested - #! and to properly report posix argv[0] when invoked as a - script. - -Wed Nov 25 12:41:12 1998 Christopher Faylor - - * Makefile.in: Reinstate libwinspool.a/winspool.drv creation. - -Tue Nov 24 18:48:56 1998 Geoffrey Noer - - * Makefile.in: add CFLAGS_COMMON and CFLAGS_CONFIG to CFLAGS - and CXXFLAGS in FLAGS_TO_PASS. - - * include/sys/select.h: new file with select proto. Avoid - potential conflict with Winsock inclusion by Cygwin internals. - * include/sys/socket.h: remove select proto. - * winsup.h: define __INSIDE_CYGWIN__. Include windows.h after - Unix include files. - * include/mywinsock.h: delete file - * include/Windows32/Sockets.h: add ndef __INSIDE_CYGWIN__s - around portions that conflict with Unix definitions. This - yields what used to be mywinsock.h which is a blend of Unix - sockets and Winsock needed by Cygwin internals. - * exceptions.cc: define Win32_Winsock to include - Windows32/Sockets.h. No longer define __INSIDE_CYGWIN__. - * hinfo.cc: ditto - * net.cc: ditto - * select.cc: ditto - - * include/exceptions.h: change wrapper define to _EXCEPTIONS_H. - * include/sys/resource.h: move includes outside __cplusplus check. - * include/sys/wait.h: ditto. - -Sun Nov 22 23:33:19 1998 Geoffrey Noer - - * sigproc.cc (__release_signal_mutex): revert Nov 3d change. - -Sun Nov 22 17:04:44 1998 Christopher Faylor - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * regexp/Makefile.in: Add additional bits necessary to - allow correct installation of include file. - -Fri Nov 20 17:04:48 1998 Christopher Faylor - - * Makefile.in: Set "Warn about writable strings" option in CFLAGS. - * fhandler_tty.h: Fix for writable strings detection. - * grp.cc (add_grp_line): Ditto. - * mkvers.sh: Ditto. - * path.h: Ditto. - * registry.cc: (reg_key::reg_key): Ditto. - * smallprint.c (__small_vsprintf): Ditto. - * tty.cc (tty::get_event): Ditto. - * winsup.h: Give up on read_ready_thread. Move sig_protect - here since it needs to use information set up after the sigproc.h - include. - * dcrt0.cc: Ditto. - * debug.cc (WFSO): New function. Used to ensure that - function shows up on stack trace. - (WFMO): Ditto. - * debug.h: Define the above. - * exceptions.cc (ctrl_c_handler): Record last signal - for signal handler. - * select.cc (MAKEready): New macro for constructing - fhandler_*::ready_for_read function. - (fhandler_*::ready_for_read): Use macro to construct this - method throughout. - * sigproc.cc (sig_send): Work around race on process termination - where the event being waited for may disappear. - (sigproc_terminate): #ifdef code here that attempted to deal with - the above condition in sig_send. - * sigproc.h: Move sig_protect to winsup.h. - * spawn.cc (perhaps_suffix): Don't return pointer into an - automatic variable. - (find_exec): Always point known_suffix to something. - * syscalls.cc (read_handler): Refine debug output. - (read_ready_thread): Delete. - (_read): Eliminate use of read_ready_thread. Call ready_for_read - directly as appropriate. - -Thu Nov 19 15:26:40 1998 Geoffrey Noer - - * Makefile.in: remove -Wunused since that's already in -Wall - * dlfcn.cc (check_path_access): rename winenv arg to mywinenv - * path.cc (symlink): change save_errno var to saved_errno - * spawn.cc (find_exec): rename winenv arg to mywinenv - (spawn_guts): rename sigprotect handle to starting_here - * winsup.h: remove trailing comma from process_state flags - enum - * utils/aclocal.m4: regenerate - * utils/configure: regenerate - -Thu Nov 19 11:16:38 1998 Christopher Faylor - - * Makefile.in: Use correct libpthread.a target when - thread-safe is enabled. - -Thu Nov 19 10:49:27 1998 Christopher Faylor - - * path.cc (path_conv): Correct error reporting. - -Wed Nov 18 20:07:50 1998 Geoffrey Noer - - * utils/Makefile.in: remove termcap file install rule - -Wed Nov 18 18:14:18 1998 Geoffrey Noer - - More minor cleanup: - * environ.cc (winenv): don't define len twice. - * fork.cc (sync_with_parent): should NOT use rc since - this is a macro and that could have interfered with rc in - the calling function. Renamed to psync_rc. - * fhandler_serial.cc (fhandler_serial::open): change - access to myaccess since it shadows global decl. - * hinfo.cc: ditto throughout - * path.cc: ditto throughout - (path_conv::path_conv): change error to err. - -Wed Nov 18 16:17:58 1998 Geoffrey Noer - - * profil.c: include stdio.h - (print_prof): comment out unused func - (profile_ctl): should return an int - -Wed Nov 18 16:17:58 1998 Geoffrey Noer - - * utils/ps.cc: include sys/cygwin.h, make pname buf - MAXPATH in size. - - patch from Corinna Vinschen : - * utils/ps.cc (main): converting windows paths to posix - paths in output. - -Wed Nov 18 15:34:46 1998 Geoffrey Noer - - * include/wchar.h: include stddef.h. - -Wed Nov 18 17:39:15 1998 Christopher Faylor - - * environ.cc (environ_init): Fix incorrect TERM= detection. - -Tue Nov 17 17:28:09 1998 Geoffrey Noer - - * gcrt0.c: include stdlib.h, add proto for monstartup. - -Tue Nov 17 16:47:42 1998 Geoffrey Noer - - * include/wchar.h: add protos for wcslen and wcscmp. - * syscalls.cc: minor reformat. - -Tue Nov 17 15:38:45 1998 Christopher Faylor - - * fhandler.cc (fhandler_base::fhandler_base): Default non-disk - devices to binary mode. - * fhandler.h: Reformat slightly. - -Tue Nov 17 11:19:23 1998 Christopher Faylor - - * external.cc (fillout_pinfo): Copy progname using strcpy to - save on time. - * path.h: Add new enums for more fine-grained control - of path_conv. - * dir.cc (opendir): Use enum argument to path_conv. - (mkdir): Ditto. - (rmdir): Ditto. - * dlfcn.cc (get_full_path_of_dll): Ditto. - * fhandler.h: Add new set_readahead_valid to set actual - readahead. - * fhandler.cc (raw_read): Remove extraneous variable. - (fhandler_base::read): Rework to allow readahead when - not text mode. - (fhandler_disk_file::fstat): get_symlink_p() only returns - true/false now. - (fhandler_disk_file::fhandler_disk_file): Use enum argument - to path_conv. - (fhandler_disk_file::open): Ditto. - * spawn.cc (perhaps_suffix): Ditto. - * syscalls.cc (_unlink): Ditto. - (_link): Ditto. - (stat_worker): Ditto. - (_rename): Ditto. - * fhandler_serial.cc (fhandler_serial::open): Always reset timeouts. - * path.cc (path_conv::path_conv): Honor new enum arguments. - Specifically, use SYMLINK_CONTENTS for readlink interface. - (readlink): Use SYMLINK_CONTENTS argument to path_conv. - * select.cc: Rework serial support which has apparently never - worked. - -Mon Nov 16 16:15:20 1998 Geoffrey Noer - - * Makefile.in: FLAGS_TO_PASS should pass CFLAGS and CXXFLAGS - not ALL_CFLAGS and ALL_CXXFLAGS. Rework handling of CFLAGS - variables to remove duplication and make it possible to - build mingw directory. - -Mon Nov 16 09:40:21 1998 Christopher Faylor - - * syscalls.cc (_open): Use new macro to check for - NULL or empty pathname and return appropriate error. - * path.cc (check_null_empty_path*): Move macro to - path.h. - * path.h: Move macros here. - -Sun Nov 15 20:23:10 1998 Geoffrey Noer - - * include/cygwin/version.h: bump API_MINOR to 3 to mark - addition of dll_noncygwin_dllcrt0 to exports list. - -Sun Nov 15 23:05:21 1998 Christopher Faylor - - * path.cc (check_null_empty_path): New macro. - (check_null_empty_path_errno): Ditto. - (path_conv::path_conv): Check for NULL and empty - path names here and set appropriate error. - (conv_to_win32_path): Ditto. - (conv_to_full_win32_path): Ditto. - (conv_to_posix_path): Ditto. - (conv_to_full_posix_path): Ditto. - (mount_info::conv_wo_win32_path): Back out previous - change. - (mount_info::conv_to_posix_path): Ditto. - -Sun Nov 15 19:29:19 1998 Geoffrey Noer - - * include/limits.h: define CHILD_MAX to be 63. - * sysconf.cc (sysconf): return CHILD_MAX when asked for - instead of _POSIX_CHILD_MAX. - -Sun Nov 15 18:25:22 1998 Geoffrey Noer - - patch from Mumit Khan : - * path.cc (mount_info::conv_to_posix_path): Handle NULL and - empty pathnames. - (mount_info::conv_to_win32_path): Likewise. - -Sun Nov 15 18:09:06 1998 Geoffrey Noer - - * cygwin.din: export dll_noncygwin_dllcrt0. - * {libccrt0.cc, winsup.h}: minor reformat. - -Sat Nov 14 22:14:51 1998 Christopher Faylor - - * environ.cc (environ_init): Use sizeof for string lengths - rather than hard-coded values. - - patch from Mumit Khan : - * dll_init.cc (dll_foreign_dllcrt0): Rename to - dll_noncygwin_dllcrt0. - * winsup.h: Ditto. - * include/cygwin/cygwin_dll.h: Ditto. - -Sat Nov 14 14:09:33 1998 Christopher Faylor - - * hinfo.cc (hinfo::de_linearize_fd_array): Reset first fd - for open to zero after an exec. - -Sat Nov 14 01:29:23 1998 Christopher Faylor - - * fork.cc (fork): No need for intermediate jmp_buf variable. - - patch from Mumit Khan : - * libccrt0.cc (cygwin_attach_foreign_dll): New function. - * dll_init.cc (dll_foreign_dllcrt0): New function to initialize - DLLs loaded by non-cygwin apps. - (dll_dllcrt0_1): Initialize process table entry. - (dll_dllcrt0): Revert last change to do partial initialization. - * winsup.h (dll_foreign_dllcrt0): Prototype. - * include/cygwin/cygwin_dll.h (_cygwin_foreign_dll_entry): New - entry point that does partial initialization for non-cygwin apps. - -Fri Nov 13 16:17:28 1998 Geoffrey Noer - - Assorted -Wall cleanup: - * utils/mount.cc (show_mounts): remove unused var i. - * utils/cygcheck.cc (dll_info): comment out unused var ofs. - (dump_sysinfo): return a void, not an int. Comment out unused - var len in two places. Add parens around assignment used as - truth value. - * utils/kill.cc (main): remove unused var i - * utils/mkpasswd: include and . - (enum_users): remove unused var rc. - (enum_local_groups): ditto. - * utils/ps.cc (main): Add parens around assignments used as - truth values. - * utils/mkgroup.c: include and . - (enum_groups): return void, not int. Remove unused var rc. - * gmon.c: include and . - (_mcleanup): remove unused vars buf and profdir. - -Fri Nov 13 16:17:28 1998 Geoffrey Noer - - patch from Corinna Vinschen : - * include/sys/sysmacros.h: new file, define major, minor, makedev - -Fri Nov 13 17:03:52 1998 Christopher Faylor - - * dcrt0.cc: Reflect a variable name change. - * fhandler.h: *::ready_for read takes an additional argument. - * fhandler_console.cc (get_non_ascii_key): New function derived - from fhandler_console::read1. - (fhandler_console::read1): Use new function. - * select.cc (*::ready_for_read): Add new "nonblocking" argument. - (peek_console): Be more diligent in detecting when a usable - character has been entered or false positives will be returned. - (fhandler_tty_common::ready_for_read): Detect attempt to perform - a "background" read. - * syscalls.cc (read_handler): Remove code for dealing with slow - devices. Just deal with non-blocking here. - (read_ready_thread): Renamed function. Rewritten to only detect - when an fd has data ready to be read. Actual reads happen in - the main thread. - (_read): Rely on read_handler to read data for everything. Use - the read_ready_thread to indicate when data is ready to be read. - Gut the read_thread_info class since it no longer needs to return - much information. - * winsup.h: Reflect above changes to read_thread_info. Rename - to read_ready_thread_info. - -Fri Nov 13 15:09:26 1998 Christopher Faylor - - patch from Corinna Vinschen and - Ron Parker : - * path.cc (mount_info::conv_to_win32_path): Refined recognition of - UNC devices. - -Fri Nov 13 12:37:00 1998 Christopher Faylor - - * Makefile.in: Fix a typo. - -Fri Nov 13 10:59:43 1998 DJ Delorie - - * Makefile.in: "make" uses new "ld -shared" by default internally. - -Fri Nov 13 00:58:38 1998 Christopher Faylor - - * spawn.cc (find_exec): Make sure that return value is correct - in all cases. Document. - * fhandler.h (fhandler_tty_common): Give unit number to constructor. - * fhandler_tty.cc (fhandler_tty_slave::fhandler_tty_slave): Give - unit number to descriptor. Create correct UNIX path name for - tty so that ttyname() will work correctly. - * select.cc (fhandler_tty_common::ready_for_read): Don't worry - about read_for_read since the tty read routines are already - interruptible. - * syscalls.cc (_read): Reset read thread events on signal. - - patch from Mumit Khan : - * dlfcn.cc (ctype.h): Include. - (check_access): Document. - (check_path_access): Document. - (get_full_path_to_dll): Rework to handle general filenames and - symlinks. - -Thu Nov 12 17:01:52 1998 DJ Delorie - - * Makefile.in (shared): "make shared" uses the new "ld -shared" - * cygwin.din: add LIBRARY and BASE tags for "ld -shared" - -Wed Nov 11 17:16:17 1998 Christopher Faylor - - * configure.in: Add --enable options for various cygwin defines - including preliminary thread-safe defines. - * configure: Regenerate - * Makefile.in: Honor new --enable options. - * glob.h: Move BSD defines to sys/cdefs.h. - * include/sys/cdefs.h: Move __P definition here. - -Wed Nov 11 14:00:45 1998 DJ Delorie - - * cygwin.din (getpwnam): remove duplicates - -Tue Nov 10 18:27:09 1998 Geoffrey Noer - - * utils/aclocal.m4: regenerate with aclocal - * utils/configure.in: don't call AM_CYGWIN32 - * utils/configure: regenerate - -Tue Nov 10 15:56:03 1998 Geoffrey Noer - - patch from Gary V. Vaughan : - * dlfcn.cc (dlopen): return an introspective handle to the - current module if name arg is NULL. The Single UNIX - Specification, Version 2 has this as a requirement. - -Mon Nov 9 16:29:27 1998 Geoffrey Noer - - * errno.cc (strerror): all errnos in - newlib/libc/include/sys/errno.h are now listed here. - -Mon Nov 9 16:29:27 1998 Geoffrey Noer - - * include/cygwin/version.h: up DLL version, bump API_MINOR to 2 - to mark following change. - - patch from Mumit Khan : - * cygwin.din: add exports for some of the newlib bessel - functions (j1, jn, y1, yn). - -Mon Nov 9 15:10:06 1998 Geoffrey Noer - - * syscalls.cc (_link): rewrite FIXME. - -Mon Nov 9 14:51:03 1998 Geoffrey Noer - - * errno.cc (strerror): add string for EDEADLOCK. - - patch from Corinna Vinschen : - * errno.cc (errmap[]): add END_OF_MEDIA and additional Win32 - error codes. - -Sun Nov 8 21:28:01 1998 Christopher Faylor - - * fhandler.h: fhandler_pipe cannot be is_slow under - Windows9[58]. There is no way to check for EOF on a pipe - without performing a read on that system. - * syscalls.cc (read_handler): Don't check for ready_for_read - unless this is a "slow" device. - * winsup.h: Reorganize to accomdate fhandler.h requirement - for os_type. - -Sat Nov 7 23:27:05 1998 Christopher Faylor - - * fhandler.h (fhandler_console): Add a new function declaration. - * fhandler_console.cc (fhandler_console::read1): New function - renamed from console_read to allow use of class fields. - Detect readahead situation when doing line buffering and - buffer does not contain \n. - (fhandler_console::read): Reflect function name change. - * select.cc (cygwin_select): Changes for better handling - of < 1000 usec timeouts. - (select_stuff::wait): Perform a poll on timeout to - set any fd's that may have become active. - (peek_pipe): More debugging. Honor write_ready if set. - (peek_console): Can't always use WaitForSingleObject. - Detect readahead conditions set in fhandler_console::read1. - Honor write_ready if set. - (peek_windows): Honor write_ready if set. - * times.cc (__to_clock_t): Return clock_t value. - (times): Add some debugging printfs. - -Fri Nov 6 20:15:20 1998 Christopher Faylor - - patch from Corinna Vinschen : - * spawn.cc (spawn_guts): find_exec() argument mismatch - resulted in inability to run !# scripts which did not - begin with '/'. - -Tue Nov 3 16:12:59 1998 Christopher Faylor - - * exceptions.cc (handle_exceptions): Don't wait for signal - completion. - (ctrl_c_handler): Ditto. - * fhandler.h (fhandler_*): Declare new ready_for_read functions. - * select.cc: Reorganize all methods into a peek_*, a poll_*, - and a fhandler_*::ready_for_read. This is to allow the _read - function to query the state of an fd without starting a thread. - * signal.cc (kill_worker): If sending a signal from a non-main thread - don't wait for completion. - * sigproc.h (myself_nowait_nonmain): New define for use by sig_send. - * sigproc.cc (sig_send): Honor myself_nowait_nonmain. Don't wait - if not in main thread. - (__release_signal_mutex): Revert to calling ReleaseMutex only - once or mutex is released prematurely. - * syscalls.cc (read_handler): Use new ready_for_read method to - determine if an fd has data for reading. This function optionally - blocks until there is data to read. - (read_helper): Add debugging statement. - (_read): Move signal_arrived reset to before sig_protect to avoid - a race. Force read_handler thread to longjmp back to read_handler - function on signal. - -Tue Nov 3 12:18:31 1998 DJ Delorie - - * utils/cygcheck.cc (dump_sysinfo): Note when not finding a - program (like cpp) on the path is a good thing. - -Tue Nov 3 01:26:08 1998 Geoffrey Noer - - patch from Kazuhiro Fujieda : - * environ.cc (environ_init): correct size arg to parse_options - -Mon Nov 2 21:40:32 1998 Christopher Faylor - - * regexp/regexp.c (regatom): Respond to compiler warning. - -Mon Nov 2 21:36:48 1998 Christopher Faylor - - * exceptions.cc (handle_exceptions): cygwin should not - print exception information if the exception is trapped - via signal(). - Also use consistent timings for lock_cs() throughout. - -Mon Nov 2 16:46:28 1998 Geoffrey Noer - - * Makefile.in: For now, also include newlib/libc/sys/cygwin. - Eventually will stop including newlib/libc/sys/cygwin32. - -Mon Nov 2 19:38:30 1998 Christopher Faylor - - patch from Corinna Vinschen : - * syscall.cc (gethostname): function deleted - * net.cc (gethostname): new function 'gethostname' which - first calls wsock32::gethostname and only if it fails, - calls GetComputerNameA. - -Wed Oct 28 17:57:53 1998 Geoffrey Noer - - * include/cygwin/version.h: up DLL version to 20.0 in honor - of new Net release. - -Wed Oct 28 17:57:53 1998 Geoffrey Noer - - patch from Mumit Khan : - * dll_init.cc (doGlobalCTORS): Fix invocation order. - (doGlobalDTORS): Likewise. - -Wed Oct 28 17:57:53 1998 Geoffrey Noer - - * Makefile.in: add include/exceptions.h to dll_init.cc deps. - - patch from Mumit Khan : - * dll_init.cc (exceptions.h): Include. - (dll_dllcrt0_1): New function to initialize Cygwin DLL guts - properly when a non-Cygwin app uses the Cygwin DLL. - (dll_dllcrt0): Call dll_dllcrt0_1 when user_data is NULL. - -Tue Oct 27 17:35:00 1998 Geoffrey Noer - - * syslog.cc: drop "32" from CYGWIN32_LOG_NAME - -Tue Oct 27 16:09:09 1998 DJ Delorie - - * utils/cygcheck.cc (usage): cygwhich->cygcheck - -Mon Oct 26 17:47:10 1998 Geoffrey Noer - - * Makefile.in: fix deps for dll_entry.o and dll_main.o, - add dep for glob.o. - - patch from Mumit Khan : - * dll_entry.cc: New file for user DLL entry point. - * dll_main.cc: New file for user DLL main. - * Makefile.in (LIBCOS): Add dll_entry.o and dll_main.o. - -Mon Oct 26 13:47:10 1998 Geoffrey Noer - - * Makefile.in: add back install of include/net which was - removed by accident. - -Mon Oct 26 15:25:22 1998 Christopher Faylor - - * strace.cc (get_strace_mutex): Don't reset last windows - error. - (strace_printf): Preserve last windows error. - -Mon Oct 26 11:01:46 1998 Christopher Faylor - - * uname.cc (uname): Remove slash from system name. - -Mon Oct 26 02:11:44 1998 Geoffrey Noer - - * include/asm/byteorder.h: add missing __cplusplus wrapper. - -Mon Oct 26 00:46:33 1998 Christopher Faylor - - * uname.cc (uname): Remove space from the system name. - -Sun Oct 25 23:47:56 1998 Christopher Faylor - - * fhandler_console.cc (console_read): Several typos caused flaky - behavior when \r or \n detected under ENABLE_LINE_INPUT. Also ignore - first \n detected under ENABLE_LINE_INPUT if it isn't preceded by a \r. - This avoids problems when switching from "raw" mode into "cooked mode. - -Sun Oct 25 12:28:21 1998 Geoffrey Noer - - * cygwin.din: remove unnecessary __cygwin32_stack_trace and - __cygwin_stack_trace exports. - -Sat Oct 24 21:18:46 1998 Christopher Faylor - - patch from Corinna Vinschen : - * path.cc (symlink): Standard protection for symlink should - be 0777. - * syscalls.cc (num_entries): Calculated links for directory - entry should only include directories. - -Sat Oct 24 20:51:08 1998 Christopher Faylor - - * mkvers.sh: Modify check for CVS/Tag to work around ash bug. - * sigproc.cc (wait_sig): Fix detection of non-blockable signals. - -Fri Oct 23 18:24:43 1998 Geoffrey Noer - - * environ.cc: CYGWIN32 environment variable is now called CYGWIN - * window.cc: lose "32" in Cygwin32WndClass - * syslog.cc: lose "32" in WIN95_EVENT_LOG_PATH and - CYGWIN32_LOG_NAME. - -Fri Oct 23 16:32:59 1998 Geoffrey Noer - - * utils/cygcheck.cc: reformat, add copyright notice - -Fri Oct 23 18:15:28 1998 DJ Delorie - - * utils/cygcheck.cc: new file - * utils/Makefile.in: build cygcheck.exe - -Fri Oct 23 16:48:41 1998 Christopher Faylor - - * exceptions.cc (signals_init): Add error to api_fatal. - (events_init): Ditto. Collapse printfs into one. - (winsock_init): Ditto. - * net.cc (winsock_init): Remove "Cygwin" from error message. - -Fri Oct 23 13:48:10 1998 Geoffrey Noer - - * Makefile.in: install include/cygwin headers, losing the "32". - * include/cygwin32: remove - -Fri Oct 23 14:36:31 1998 Christopher Faylor - - * environ.cc (environ_init): Avoid reallocating environ array. - * exec.cc: Increase number of arguments to 1024 throughout. - * fhandler.cc (fhandler_disk_file::open): Revert to checking - a file for '#!' to find out if it is executable but add - extra check for NTEA which, if set, eliminates the need for - the read. - * sigproc.cc (sigproc_terminate): Close hwait_sig and set it - to NULL prior to closing other handles since this flags some - routines that the process is going down. - -Fri Oct 23 00:31:27 1998 Geoffrey Noer - - * utils/*: remove "32"s from cygwin32_foo function calls - -Fri Oct 23 00:24:27 1998 Geoffrey Noer - - * include/cygwin/version.h: increment CYGWIN_VERSION_DLL_MINOR - and CYGWIN_VERSION_API_MINOR since I'm changing the API in a - meaningful but backwards-compatible fashion. - - * exceptions.cc: strip "32" from cygwin32_exception_handler - debug printfs - - * net.cc: strip "32" from all net functions - * select.cc, syscalls.cc, winsup.h: lose "32" from cygwin32_select - * cygwin.din: adjust for these changes (no backwards - compatability issues here). - - * cygwin.din: rename all cygwin32_foo functions, aliasing as - cygwin_foo for backwards compat. for now but intend to lose them - at a later date. - * include/sys/cygwin.h: copy all cygwin32_ protos and make them - usable without the "32". We will remove the cygwin32_ ones at a - later date. - * external.cc, external.h: lose "32" from cygwin32_internal - * shared.cc, winsup.h: lose "32" in cygwin32_getshared - * path.cc, path.h: lose "32" in cygwin32_foo comments - * dll_init.cc: lose "32" in cygwin32_detach_dll - * hinfo.cc: lose "32" in cygwin32_attach_handle_to_fd - * libccrt0.cc: lose "32" in refs to cygwin32_attach_dll - * pinfo.cc: lose "32" in cygwin32_winpid_to_pid - - * include/cygwin32: remove all files except cygwin32_dll.h which - some people may already be including. Aim to remove this - remaining file at a later date. - * include/cygwin: move all include/cygwin32 files here. - * cygwin/cygwin_dll.h: change protos to reflect loss of "32"s - * include/net/if.h, include/netinet/in.h, include/netinet/ip.h, - include/netinet/ip_icmp.h, include/asm/socket.h: - include/sys/socket.h: include the headers in include/cygwin - * Makefile.in, winsup.h: fix references to - include/cygwin32/version.h - - * libcctype.c, smallprint.c, test.c: lose "32" in Cygwin32 refs in - comments - * include/dlfcn.h, include/exceptions.h, include/mapi.h, - include/winsock.h, include/mywinsock.h: ditto - * config/*: ditto - * profil.c: ditto, and respace - -Thu Oct 22 22:52:40 1998 Geoffrey Noer - - * net.cc, exceptions.cc, hinfo.cc, select.cc, - include/mywinsock.h: rename __INSIDE_CYGWIN32__ to - __INSIDE_CYGWIN__ - -Thu Oct 22 17:39:06 1998 Geoffrey Noer - - First round of Cygwin32 -> Cygwin renaming. In all files, - rename Cygwin32 to Cygwin in comments. - * CYGWIN32_LICENSE: delete and - * CYGWIN_LICENSE: add it back under this name - -Thu Oct 22 20:10:24 1998 Christopher Faylor - - * exceptions.cc: Eliminate cs mutex. Just use signal_mutex - throughout. Rename sig_dispatch_mutex to signal_mutex throughout. - (lock_cs): Rewrite to be a front-end for get_signal_mutex. - (unlock_cs): Rewrite to be a front-end for release_signal_mutex. - (set_process_mask): Synchronize signals after resetting mask. - * sigproc.cc (release_signal_mutex): Report on success or - failure of signal_mutex release. - * include/Windows32/Defines.h (FILE_FLAG_WRITE_THROUGH): Make - unsigned to avoid a compiler warning. - -Thu Oct 22 14:23:49 1998 Geoffrey Noer - - * utils/Makefile.in: disable building cygwin.exe. - -Thu Oct 22 14:16:10 1998 Christopher Faylor - - * exceptions.cc (sig_handle): Minimize life of cs lock during - handling of signals to reduce the potential for a race. - -Thu Oct 22 10:23:19 1998 Christopher Faylor - - * include/sys/strace.h: Minor addition from threadsafe-branch. - -Thu Oct 22 09:03:18 1998 Christopher Faylor - - * debug.cc (close_handle): Error condition needs a return value. - * environ.cc (parse_thing): char pointers should all be constant. - (add): Ditto. - * heap.cc (heap_init): Provide a little more information in - fatal printf. Use api_fatal to print errors. - * sigproc.cc (sigproc_terminate): Move code executed on - thread termination here from wait_sig since this function - may actually be executing in the signal thread. - * strace.cc (strace_open): Argument should be const. - (strace_init): Ditto. - * winsup.h: Ditto. - * include/cygwin32/version.h: Note that original shared memory - version was 0 for 98r2. - -Wed Oct 21 08:41:39 1998 Christopher Faylor - - * dcrt0.cc (__api_fatal): Remove "cygwin" identifier. - * fhandler.cc (fhandler_disk_file::open): Set symlink flag - appropriately for previous change. - * shared.cc (shared_name): Initialize static buffer to - (hopefully) force it into NO_COPY segment. - * mkvers.sh: Reorganize, add cvs tag detection, and output - cygwin "info" defines. - -Tue Oct 20 18:42:50 1998 Geoffrey Noer - - * include/cygwin32/version.h: rewrite versioning comments, - updating for new scheme but keeping historical information. - -Mon Oct 19 23:45:24 1998 Geoffrey Noer - - * include/windows.h: remove Objective-C BOOL ifdef, now taken - care of within the include/Windows32 header files. - * fhandler_console.cc: fix KeyEvent references in light of - changes to the KeyEvent struct in the Windows32 headers. - - Update include/Windows32 header files. Changes from - Mumit Khan , Corinna Vinschen - , and me. - * include/Windows32/CommonFunctions.h: new file, contents from - Functions.h. - * include/Windows32/*.h: Misc updates. - -Mon Oct 19 20:26:15 1998 Christopher Faylor - - * debug.cc: Throughout, avoid calling *_printf while lock - is active. Previous lock count was not thread-safe. - * fhandler_console.cc (console_read): Avoid sending a - \r to caller if ENABLE_LINE_INPUT. - (fhandler_console::read): Rely on console_read to handle - \r\n conversion. - -Mon Oct 19 12:10:09 1998 Christopher Faylor - - * mkvers.sh: Use more portable constructs to allow running - this with /bin/sh, bash, and ksh. - -Mon Oct 19 11:19:58 1998 Christopher Faylor - - * path.cc (mount_info::from_registry): Missed "b15.0" part - for writing mount information back to registry. - (mount_info::init): Remove obsolete stuff. - -Mon Oct 19 10:42:17 1998 Christopher Faylor - - * Makefile.in: Avoid newer GNU make construction when building - version.cc. - -Mon Oct 19 00:09:06 1998 Geoffrey Noer - - * Makefile.in: invoke mkvers.sh with $(SHELL) - -Sun Oct 18 15:19:17 1998 Christopher Faylor - - * fhandler.cc (set_name): Accept unit argument for generating - win32_name. - (fhandler_base::fhandler_base): Ditto. - (fhandler_dev_floppy::fhandler_dev_floppy): Ditto. - (fhandler_dev_tape::fhandler_dev_tape): Ditto. - (fstat): Set symlink bit only if symlink_p is positive. - * fhandler.h: Reflect unit argument changes. - * fhandler_serial.cc (fhandler_serial::fhandler_serial): Accept - unit argument for generating win32_name. - * hinfo.cc (hinfo::build_fhandler): Pass unit argument to constructor - where apropriate. - * path.cc (path_conv::path_conv): Set symlink_p to a positive - value if !nofollow, negative otherwise. - (windows_device_names): Can't default to \dev\comx. \dev part - doesn't work. - (get_device_number): Accept just "comN" for backwards compatibility. - -Sat Oct 17 01:58:15 1998 Christopher Faylor - - * dcrt0.cc (globify): Fix problem with argument corruption - due to use of pointer freed by realloc. - -Sat Oct 17 00:10:53 1998 Christopher Faylor - - Change NOT_OPEN_FD to dtable.not_open throughout. - * Makefile.in: Change .dll name to cygwin1.dll. Increment - the '1' when there are API/shared memory changes. Make - version.cc file every time .dll is linked. Remove datestamp - stuff. - * mkvers.sh: New file. Creates version.cc. - * cygwin.din: Export setdtablesize. - * dcrt0.cc: Remove obsolete version variables. - (build_argv): Use issep() macro rather than isspace since - isspace includes whitespace that the shell does not consider - a command separator. - (check_sanity_and_sync): Use new cygwin version defines and - structures for compatibility checking. - (dll_crt0_1): Ditto. - (__api_fatal): Renamed from api_fatal. Now always called from - macro which tacks program name to beginning of fmt. Increase - size of buffer. - * environ.cc (regopt): Use new reg_key class constructor - functionality. - * net.cc (getdomainname): Ditto. - * path.cc (read_mounts): Ditto. - (mount_info::from_registry): Ditto. - (mount_info::to_registry): Ditto. - (hash_path_name): No need for this to be a "C" function. - * external.cc (cygwin32_internal): Export version info strings. - * external.h: Add CW_GETVERSIONINFO. - * fhandler.cc (fhandler_base::write): Eliminate use of MIN macro. - * init.cc (set_dllname): Obsolete function. Handled in version.cc. - (dll_entry): Remove reference to set_dllname. - * libccrt0.cc (this_proc): Renamed from cygwin_statu. - (cygwin_crt0_common): Record api version in this_proc. - * mmap.cc (recreate_mmaps_after_fork): No need for this to be - a "C" function. - * syscalls.cc (close_all_files): Ditto. - * pinfo.cc (lock_pinfo_for_update): Eliminate a compiler warning. - * registry.cc: Eliminate reg_session class. Augment reg_key to handle - functionality of reg_session. - * registry.h: Ditto. - * shared.cc (shared_name): No need for this to be a "C" function. - Use new cygwin version structure. - (shared_info::initialize): Use new reg_key class constructor - functionality. - * smallprint.c (__small_vsprintf): Accept %P as a format specifier. - Signifies the program name. - * spawn.cc (spawn_guts): Quote *all* of the stuff the dcrt0.c considers - special. - * tty.cc (tty::inuse_event_exists): Remove debugging printf. It results - in too much output to strace log. - * uinfo.cc: Add a needed include. - * uname.cc (uname): Use new cygwin version structure to fill in utsname - fields. - * winsup.h: Regroup into sections. Add new version structure. - * include/utmp.h: Move login/logout function declarations here. - * include/cygwin32/version.h: Define new CYGWIN version/info - stuff here. - -Fri Oct 16 00:13:35 1998 Geoffrey Noer - - * Makefile.in: enable building mingw subdir by default - -Thu Oct 15 12:01:08 1998 Christopher Faylor - - * spawn.cc (spawn_guts): Set all security attributes - for CreateProcess so that sexec will work properly. - -Thu Oct 15 08:49:12 1998 Christopher Faylor - - * hinfo.cc (hinfo::dup2): Avoid a null pointer dereference - in a debugging printf. - -Wed Oct 14 18:06:51 1998 Geoffrey Noer - - patch from Corinna Vinschen : - * fhandler_console.cc (fhandler_console::dup): reset - default_color since the console fhandler forgets its default - colorizing when it's `dup'ed. - (fhandler_console::fhandler_console): remove unnecessary - erasing in constructor of fhandler_console. - -Mon Oct 12 22:20:59 1998 Christopher Faylor - - * fcntl.cc (fcntl): According to the "Single UNIX Specification", - F_DUPFD should *not* close its argument. Revert to previous - behavior. - * hinfo.cc (dup2): Guard against closing target fd too early. - * pinfo.cc: Always initialize myself to a dummy value so that - myself != NULL checks are avoided. - * include/sys/strace.h (strace): Remove NULL check for myself. - * dcrt0.cc (api_fatal): Ditto. - * exceptions.cc (handle_exceptions): Ditto. - * signal.cc (sigprocmask): Ditto. - (_raise): Ditto. - * strace.cc (get_strace_mutex): Ditto. - -Mon Oct 12 15:19:47 1998 DJ Delorie - - * utils/ps.cc (main): use const char *pname - -Fri Oct 9 12:32:23 1998 Christopher Faylor - - * syscalls.cc (getw): Simplify. - -Thu Oct 8 23:09:34 1998 Geoffrey Noer - - * times.cc: add missing syscall_printfs to time functions, - slight reformatting. - -Thu Oct 8 21:56:37 1998 DJ Delorie - - * hinfo.cc (cygwin32_attach_handle_to_fd): allow to pass -1 - for dup() simulation; return allocated fd. - * pinfo.cc (lock_pinfo_for_update): if the mutex is broken, - fail instead of looping. If you do loop, don't use 100% CPU. - -Thu Oct 8 18:33:02 1998 Christopher Faylor - - * dcrt0.cc: Add another per-thread object for strace. - (quoted): Fix misconception of method used to quote - quotes. - (globify): Optionally output arguments. - (build_argv): Ditto. - (dll_crt0_1): Fix typo in line reassignment. - * debug.cc (class locker): Avoid calling lock multiple times. - * exceptions.cc (call_handler): Set strace recursion flag - to zero when invoking a signal handler. - * fcntl.cc (_fcntl): F_DUPFD should close its argument. - * fork.cc (fork): Move determination of parent process to - a safer place. - * sigproc.cc (get_sig_dispatch_mutex): Rename. Use macro - interface to provide the name of the caller for strace output. - (release_sig_dispatch_mutex): Ditto. - * sigproc.h: Define *_dispatch_mutex wrappers. - * strace.cc (strace_printf): Use new per-thread object to - guard against recursion. - * winsup.h: Define per_thread_strace_protect. Redo per_thread - base class for a little more clarity. - -Wed Oct 7 22:30:43 1998 Geoffrey Noer - - * fhandler_tty.h: up NTTYs from 16 to 128 - -Wed Oct 7 09:15:55 1998 Christopher Faylor - - * fhandler_console.cc (console_read): Distinguish between - 0 byte return from CTRL-C and EOF condition. - -Tue Oct 6 22:31:44 1998 Christopher Faylor - - * dcrt0.cc (build_argv): Rewrite. Now: 1) allocates argv on - the fly, 2) inserts '@' files as they are found, 3) uses - sh-style quoting using either " or ' which may be embedded - in an argument. - (insert_file): Don't scan command line. Accept already - parsed arguments from build_argv. - (quoted): New function for parsing quoted strings. - (globify): Don't scan argv list. Accept element from - build_argv which will be tacked to end of argv as it - is being built. Extend quoting options to allow - tilde, braces, and quotes. - (dcrt0_dll_1): Simplify argv processing. Just call - build_argv, which handles everything. - -Tue Oct 6 11:04:43 1998 Christopher Faylor - - Change Create[A-Z]* calls throughout to use sec_none_nih - to avoid subprocesses accidentally inheriting handles. - * grp.cc: Hold group structures in group_buf rather than - an image of the /etc/group file. - (parse_grp): New function to parse a group line into a - struct group. - (add_grp_line): Use parse_grp to add line from /etc/group - into internal cache. - (read_etc_group): Avoid redundant feof call. Set up - default group. - (getgrgid): Just return appropriate entry from group_buf - rather than reparsing internal representation. - (getgrnam): Ditto. - (getgrent): Ditto. - * hinfo.cc (hinfo::select_*): Set errno value when attempt - is made to use an unopened fd. - * passwd.cc: Hold passwd structures in passwd_buf rather than - an image of the /etc/passwd file. - (parse_pw): New function to parse a passwd line into a - struct passwd. - (add_pw_line): Use parse_pw to add line from /etc/passwd - into internal cache. - (read_etc_passwd): Avoid redundant feof call. - (search_for): Just scan passwd_buf for matching entries. - (getpwent): Just return appropriate entry from passwd_buf - rather than reparsing internal representation. - -Mon Oct 5 18:06:31 1998 Geoffrey Noer - - patch from Corinna Vinschen : - * sysdef/kernel32.def: add missing GetDiskFreeSpaceEx lines - -Sat Oct 3 23:52:23 1998 Christopher Faylor - - * dcrt0.cc (si): Initialize so that NO_COPY will work. - * debug.cc (class locker): Fix previous change. Critical - sections are still required, so protect them if operating - in main thread to avoid signal problems. - Make any previously static use of locker global since that - appears to be the only foolproof way of marking the variable - NO_COPY. Rename these variables to something that is not - likely to be collided with. - * exceptions.cc (call_handler): Signal arrival of a dispatched - signal here and wait a long time for the mutex before giving - up. Should increase performance slightly. - * sigproc.cc (maintid): New external symbol. - * sigproc.cc (maintid): Make this global since it is used - in other places now. - (sig_dispatch_pending): Don't wait for wait_sig to complete - if there are no pending signals. Avoids a race and should - be faster. - (wait_sig): Don't set signal_arrived event here. Do it in - call_handler. - * strace.cc (strace_printf): Remove previous recursion check - since it is not signal safe. - * syscalls.cc (_read): Remove duplicate CreateEvent typo. - -Fri Oct 2 09:54:42 1998 DJ Delorie - - * strace.cc (strace_printf): protect against recursion - -Thu Oct 1 17:08:47 1998 Geoffrey Noer - - * utils/ps.cc (main): add more detailed usage printfs - -Thu Oct 1 11:05:16 1998 Christopher Faylor - - * Makefile.in: Fix typo in debug.o dependency. - * debug.cc (class locker): Give up on using critical sections - since they are not safe to use in the main thread due to signals. - -Wed Sep 30 22:34:42 1998 Christopher Faylor - - * fork.cc (fork): Close parent's parent_alive handle - if there is one or suffer a handle leak. - * syscalls.cc (_read): Make all events no access and - non-inheritable or suffer potential handle leak. - * windows.cc (gethwnd): Ditto. - -Wed Sep 30 17:22:29 1998 Geoffrey Noer - - * include/io.h: add missing setmode proto - -Tue Sep 29 23:33:11 1998 Christopher Faylor - - * fhandler_tty.cc (fhandler_pty_master::close): Make sure - both sides of both pipes associated with a tty master are - closed or suffer handle leaks. - -Tue Sep 29 16:55:00 1998 Geoffrey Noer - - * path.cc (mount_info::init): remove default mounts for - raw devices. - * utils/mount.cc (reset_mounts): ditto - (main, usage): new -f flag disables warning messages about - missing mount point directories. Two new flags, disabled for - now: -c will create missing mount point directory, -g will - select adding the mount point to the global registry location. - * include/sys/mount.h: add MOUNT_GLOBAL define, for future use. - -Tue Sep 29 14:20:30 1998 Christopher Faylor - - * exceptions.cc (exception): Use %p to denote some hex - values. - * winsup.h (read_info): Add jmp_buf to structure. Required - for syscalls.cc change below. - -Mon Sep 28 19:36:41 1998 Syd Polk - - * include/{tchar.h, direct.h}: Added so that - tcl8.1a2 can be compiled with cygwin. - -Mon Sep 28 19:36:41 1998 Christopher Faylor - - * syscalls.cc (thread_reset): Yet another method for - handling interruptible reads. - (_read): Use thread_reset to reset reads after a signal. - -Sun Sep 27 21:11:46 1998 Christopher Faylor - - * cygwin.din: New alias for __cygwin32_stack_trace. - * debug.cc (find_handle): Avoid leaving function without - unlocking. - (newh): Ditto. - * exceptions.cc (__cygwin32_stack_trace): Rename to just - `stack'. Shortens stack trace output. - (exception): Use %p to distinguish register values. - * fhandler_console.cc (fhandler_console::init): Remove - debugging sig_protect. - * init.cc (dll_entry): Move definition to avoid a - compiler warning. - * path.cc (mount_info::conv_to_win32_path): Detect - case of root directory when setting win32 relative - path. - (mount): Remove obsolete label. - * syscalls.cc (thread_sync): New function for exiting - the read helper thread. - (_read): Use new method for exiting the read helper - thread. - -Sun Sep 27 11:25:06 1998 Christopher Faylor - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * delqueue.cc (delqueue_list::process_queue): Clear queue - entry if file cannot be deleted for a reason other than - sharing violation. - -Fri Sep 25 08:52:50 1998 Christopher Faylor - - * debug.cc: locker variables should all be static. - * syscalls.cc (_read): Call ForceCloseHandle on - thread handle since it is protected. - -Thu Sep 24 18:59:25 1998 Geoffrey Noer - - * path.cc (mount): don't verify that path is an existing - directory. Instead - * utils/mount.cc: verify that path is an existing directory - and print warning if it's not. Still do the mount. - -Thu Sep 24 11:45:04 1998 Christopher Faylor - - * debug.cc: locker class variables must be NO_COPY since - they contain data that should not be precisely duplicated - after a fork. This hopefully fixes a "SIGSEGV" problem. - * select.cc (peek_pipe): Pipes apparently should set both - "read" and "exception" flags on EOF. - -Wed Sep 23 18:26:31 1998 DJ Delorie - - * doc/doctool.c (main): typo checking for --help - -Wed Sep 23 17:46:06 1998 Christopher Faylor - - * path.cc (symlink_check_one): Try much harder to ensure that - CloseHandle is called on the file which was opened to check - for a symlink. Avoid obsolete check for NULL buf. - -Wed Sep 23 17:11:50 1998 Christopher Faylor - - * syscalls.cc (_read): Close thread handle or suffer a leak. - * dir.cc (opendir): Simplify logic. - (readdir): Ditto. Close handle explicitly when hit end - of files. - (rewinddir): Close directory handle or suffer leak. - (closedir): Simplify logic. - -Wed Sep 23 14:42:12 1998 Christopher Faylor - - patch from DJ Delorie : - * path.cc (symlink_check_one): Don't re-define res or symlinks - will be undetectable. - -Wed Sep 23 12:02:39 1998 Christopher Faylor - - * Change calls to api_fatal throughout to avoid need for \n - (see below). - Adapt some *_printf()/ExitProcess combinations to use api_fatal. - * winsup.h (SIGTOMASK): Generate signal mask correctly for - programs linked with newer cygwins. - * dcrt0.cc (check_sanity_and_check): Set subtract constant for - signal mask calculation based on whether binary was linked with - "older" or "newer" cygwin. - (do_global_ctors): Accept a second argument indicating whether - the ctors should always be run. Necessary in forked processes - for cygwin constructors which may do more than just allocate memory. - (checkout): Remove obsolete function. - (dll_crt0_1): Remove obsolete function call. Call do_global_ctors - with second argument TRUE. - (api_fatal): Change to a print-style function, allowing arguments. - Always emit a "\n" after a message. - (__main): Do not force running of constructors in forked processes. - * exceptions.cc (call_handler): Simplify arguments passed to this - function. Eliminate potential race by setting signal masks here. - (sig_handle): Just calculate current sigaction pointer once. - Change call_handler arguments. - * fhandler_console.cc (fhandler_console::write_normal): Output - unknown characters to screen. - (fhandler_console::write): Make signal protection synchronous. - * fork.cc (fork): Reorganize slightly to eliminate a compiler warning. - * init.cc (dll_entry): Temporarily remove freeing of waitq_storage - on thread detach until a more robust scheme is developed. - * signal.cc (signal): Make signal protection synchronous. - (sigaction): Ditto. - * sigproc.cc (get_sig_dispatch_mutex): More debug info. - (release_sig_dispatch_mutex): Work around potential bug in windows - with double allocation of a mutex when WaitForSingleObject is - interrupted. Save errno here only if about to call sig_send - where it may be changed. - (wait_sig): Remove unnecessary sig_sign stuff. Add some debugging - output. - * termios.cc (tcflow): Signal protection. - (tcgetattr): Ditto. - (tcsetattr): Make signal protection synchronous. - * winsup.h: Add new extern for SIGTOMASK macro. Use it in SIGTOMASK - macro. Move errno stuff to end so that it can benefit from previous - declarations. - * configure.in: Move AC_CANONICAL_SYSTEM up a little to avoid having - configure generate some code (like the check for host type) twice. - * configure: Regenerate. - -Wed Sep 23 11:49:55 1998 Christopher Faylor - - * path.cc (symlink_check_one): Fix handle leak resulting - from open of file to check for symlink magic. Suggested - by Corinna Vinschen . - -Wed Sep 23 08:33:26 1998 Christopher Faylor - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * fhandler_tty.cc (process_ioctl): Use console handle - for ioctl operations. - -Tue Sep 22 23:58:20 1998 Geoffrey Noer - - based on patch from sos@prospect.com.ru (Sergey Okhapkin): - * utils/ps.cc (main): rewrite ps to give it more options, - including a, e, f, l, and u. - -Tue Sep 22 15:18:41 1998 Geoffrey Noer - - * path.cc (umount): remove initial system_printf - (mount): stat path, verify that it's an existing directory, - otherwise fail. - (strncasematch, strcasematch): return 0 instead of FALSE - * utils/mount.cc (reset_mounts): reset / to System drive, - not C: as was done in the old days. - -Mon Sep 21 18:18:18 1998 Geoffrey Noer - - * path.cc (mount, umount, setmntent, getmntent, endmntent): - make extern "C" - -Mon Sep 21 20:37:16 1998 DJ Delorie - - * doc/configure.in: don't try to find cc until we can correctly - configure it for a native cc in a cross build. - -Mon Sep 21 17:17:14 1998 Geoffrey Noer - - * fhandler.cc (fhandler_disk_file::check_execable_p): - don't check for .shc since that's non-standard. Check for - .exe first. - -Mon Sep 21 14:57:50 1998 Geoffrey Noer - - * doc/Makefile.in: reference -db2html in case docbook - tools aren't installed. - -Mon Sep 21 14:43:40 1998 Geoffrey Noer - - patch from DJ Delorie : - * doc/doctool.c (scan_file): correct off by one error in - malloc - -Mon Sep 21 14:28:38 1998 Christopher Faylor - - * fhandler.h (select_record): Clear memory in constructor. - -Mon Sep 21 08:49:22 1998 Christopher Faylor - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * select.h: Use unsigned int to hold count in fd_set - structure or suffer alignment problems. - (WINSOCK_FD_ZERO): Back out previous change as it - is no longer needed due to the above. - -Sat Sep 19 22:58:18 1998 Christopher Faylor - - * fhandler_console.cc (console_read): Keep looping in - ENABLE_LINE_INPUT mode when no characters are read. - This apparently means that a CTRL-C has been hit. - * select.cc (select_record::operator new): Remove. - (setlect_stuff::~select_stuff): Use delete to remove - record. - (pipe_cleanup): Remove unneeded statement. - (poll_socket): Add debugging statement. - (start_thread_socket): Add debugging statements. - * fhandler.h: Remove new operator from select_record. - * select.h: Make WINSOCK_FD_ZERO more aggressive. - * sigproc.cc (allow_sig_dispatch): Use new errno - saving method. - * syscalls.cc (_read): Reorganize stack freeing - code to avoid overhead when it's not needed and - to actually decommit stack memory. - -Sat Sep 19 19:16:32 1998 Christopher Faylor - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * select.cc (socket_cleanup): Avoid using a pointer - after it has been deleted. - -Fri Sep 18 13:57:37 1998 Christopher Faylor - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * Makefile.in: Really remove extra slash in INCLUDES. - Previous change didn't work. - pipe.cc (make_pipe): set close-on-exec flag for non-inheritable - pipes. - -Thu Sep 17 15:26:14 1998 Christopher Faylor - - * doc/Makefile.in: Add dummy install target. - -Thu Sep 17 12:30:49 1998 Christopher Faylor - - * winsup.h (per_thread*): New classes for storing and - manipulating per_thread information. - (threadstuff): New array of per_thread objects which are - manipulated after a fork. - (read_helper_thread_info): read() thread local storage. - (waitq_storage): wait() thread local storage. - * debug.cc (class locker): New class for generic locking - of debug table manipulation. Use this throughout for - locking access to thread/debug tables. - (debug_init): Remove in favor of automatic constructor. - * debug.h: Ditto. - * fork.cc (fork): Iterate through threadstuff looking - for thread information to clear out. Should solve some - problems for Windows 95/98. - * init.cc (dll_entry): Remove thread storage initialization. - Use per_thread class for DLL_THREAD_DETEACH. - * sigproc.cc: Use system_printf rather than alert_printf - throughout since system_printf now has the same functionality. - (sigproc_init): Use method to initialize per-thread storage. - * sigproc.h: Remove waitq_storage declaration. - * syscalls.cc (_read): Use per_thread class to manipulate - per-thread information. - * wait.cc (wait4): Ditto. - -Wed Sep 16 12:58:49 1998 Christopher Faylor - - * syscalls.c (_read): Lower timeout for signal detection after - EOF on device. Should fix recent configure performance problems. - * Makefile.in: Extend clean target into regexp directory. - -Wed Sep 16 11:44:14 1998 Christopher Faylor - - * fhandler.cc (fhandler_base::set_name): Honor no_free_names(). - (fhandler_base::linearize): Remove unneeded check for NULL - get_win32_name(). - (fhandler_disk_file::fhandler_disk_file): Set path names - to a standard constant. They should eventually be filled - out by fhandler_disk_file::open. - (fhandler_disk_file::open): Detect if win32_path_name_ is - a dummy path. Fill it out from real_path, if so. - * hinfo.cc (hinfo::init_std_file_from_handle): Improve debugging - statement. - (hinfo::linearize_fd_array): Remove unneeded check for NULL - get*_name (). - * path.cc (path_conv::path_conv): Correct problem with - symlinks found at places like E:\. - -Wed Sep 16 02:25:33 1998 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * fhandler.cc (fhandler_disk_file::open): fix typo. - -Tue Sep 15 23:52:44 1998 Christopher Faylor - - * winsup.h: Remove side effects from SLASH_P. - -Tue Sep 15 18:36:08 1998 Ben Elliston - - * sysdef/kernel32.def: Add definition for the Win32 API function - `TryEnterCriticalSection'. - -Tue Sep 15 12:26:48 1998 Christopher Faylor - - * Makefile.in: Remove extra slash in INCLUDES. - * hinfo.cc (hinfo::dup2): Always clear close-on-exec - flag for duplicated handle (problem and fix determined - by Sergey Okhapkin, sos@prospect.com.ru). - * fhandler.cc (fhandler_base::set_name): Avoid use of empty - path names. - (fhandler_base::raw_read): Show error code on failure. - (fhandler_base::linearize): Avoid copying NULL names. - (fhandler_base::open): Use NULL detection in small_printf. - (fhandler_base::dup): Move set_close_on_exec_flag to dup2 - so it is caught in all cases. - (fhandler_disk_file::fhandler_disk_file): Set "no free names" - flag. - (fhandler_disk_file::open): Clear "no free names" flag since - names have been allocated to the fhandler structure at this point. - * fhandler.h (set_no_free_names): Newconditional "no free names" - function. - * hinfo.cc (hinfo::dup2): Clear close on exec here. - (hinfo::linearize_fd_array): Avoid copying NULL names. - * path.cc (normalize_posix_path): Avoid copying trailing slash - if root. - (nofinalslash): Rename variable. - * path.h: Add flag for future use. - * regexp/regerror.c: Avoid including RCS strings in product. - * regexp/regsub.c: Ditto. - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * select.cc (thread_pipe): Sleep for 10ms on every iteration. - (start_thread_pipe): Set the handle in the select structure - so that it will be properly identified in select_stuff::wait. - -Tue Sep 15 12:28:30 1998 DJ Delorie - - * added documentation and doctool.c - -Tue Sep 15 08:37:26 1998 Christopher Faylor - - * Makefile.in: Fix LIBGCC definition for native builds. - Remove CFCOMMON in favor of configure solution. - * configure.in: Default CXXFLAGS to be == CFLAGS. - * configure: regenerate. - -Sun Sep 13 19:52:04 1998 Geoffrey Noer - - * Makefile.in: include ../libio when building - -Sun Sep 13 19:30:58 1998 Geoffrey Noer - - * include/cygwin32/version.h: bump version minor now that - we've merged in all that new code... - -Sun Sep 13 21:34:33 1998 Christopher Faylor - - * dcrt0.cc (do_global_ctors): Reverse call order - of constructors thanks to insight from Mumit Khan - (hkan@xraylith.wisc.edu). - (do_global_dtors): Reflect above change: invoke destructors - in the proper order. - * smallprint.c (__small_vsprintf): Gracefully detect a - null pointer for '%s' format. - * syscalls.cc (_read): Set correct flags to retrieve stack - information or suffer sporadic failures due to uninitialized - flag. - * regexp/regexp.c: Comment out RCS string. This provides - no useful information in the .dll. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - Merge in experimental-980602 branch changes. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * path.cc (symlink_check_one): known_suffix needs to be - determined here in some cases, so deal with it here. - (path_conv::path_conv): More effort needed to propagate - the known_suffix back to caller in every case. - (has_suffix): Return suffix found. - (readlink): Avoid two passes through symlink_check_one. - * spawn.cc (find_exec): Propagate known_suffix from - perhaps_suffix back to caller, if appropriate. - (spawn_guts): Use suffix returned from find_exec to - determine if file should be scanned as a script when - a #! file is found. Avoids a duplicate call to - perhaps_suffix. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * path.h (suffix_info): New struct for dealing with standard - suffix (.exe, .bat, etc.) information. - (path_conv): Constructor now takes a suffix_info argument. - (std_suffixes) Standard array of suffixes to consider "special". - * path.cc (path_conv): Constructor now takes a suffix_info - argument. Record any known suffix in path_conv known_suffix - field. - (has_suffix): New function for determining if a path already - has a known suffix. - (next_suffix): New function for returning the next suffix from - a list of suffixes. - (symlink_check_one): Take an optional suffix_info argument - for suffixes to consider or tack on. - * spawn.cc (std_suffixes): Standard list of executable suffixes. - (perhaps_suffix): Pass std_suffixes to path_conv. Use - new known_suffix field in path_conv to determine if a - suffix has been detected. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - Substitute new str{,n}casematch for strcasecmp throughout. - This implementation is faster since it only tests equality. - - Change fhandler*::open throughout to return true/false - since the pointer returned was never used for anything. - - * Use strcasestr throughout for case insensitive matches for - filenames. - * Makefile.in: Use GNU make construct for determining gcc lib. - * dcrt0.cc (check_sanity_and_sync): Make error message more - explicit. - * debug.h: Better defines for dummy functions when !DEBUGGING. - * fhandler.cc (fhandler_base::fstat): Don't bother zeroing buf - here since it is always done in the caller. - (fhandler_base::~fhandler_base): Recognize cases where *_path_name_ - should not be freed. - (fhandler_disk_file::open): Split into two functions. First - function performs a path_conv and does testing on same. This - calls new fhandler_disk_file::open with path_conv data. New - function is called by stat_worker to avoid extra path tests and - mallocs. - Also, fix long standing off-by-one typo looking for #! magic. - Also, reapply test for != WinNT when checking files for magic. - Otherwise there is a tremendous slowdown in file opening, especially - for stat(). - * fhandler.h: Add support for setting/detecting when *_path_name - should not be freed. - Add new fhandler_disk_file::open declaration. - * hinfo.cc (digits): Remove obsolete function. - (hinfo::build_fhandler): Add default name for FH_DISK. - * path.cc (path_prefix_p_): Don't check beyond len1 for leading - slash. Responsible for reported performance problems? - (path_conv::path_conv): Ensure that fileattr is filled out - correctly in all cases. Return immediately when a file - is detected in !follow_mode. - (nofinalslash): Simplify. - (strncasematch): New function similar to strncasecmp except - that it only checks for =/!= and benchmarks faster than same. - (strcasematch): Ditto, re. strcasecmp. - (strcasestr): New function which does a case-insensitive strstr. - Needed for filename matching. - * smallprint.c (__small_vsprintf): Fix off-by-one in %.ns processing. - * spawn.cc (exe_exts): Make global for eventual use by other modules. - * syscalls.cc (_fstat): Zero buf prior to use. - (stat_worker): Rename from _stat_worker. Reorganize to minimize - mallocs and path name conversions. Should now perform only one - path conversion and 0 malloc/frees. - * winsup.h: Declare new functions. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - Clean up error messages throughout using new strace_printf - options. - * smallprint.c (__small_vsprintf): Add %E option for printing - error code. Understand %.n syntax. - * strace.cc (strace_vsprintf): Common routine for formatting - strace output. Default to always ending with \n unless - string ends with \b. - (strace_write): Common routine for writing to strace output. - (strace_printf): Use above two routines. - (system_printf): Ditto. - * path.cc (path_conv): Scan path to be converted from right - to left for efficiency. Implement extension searching - which is passed from spawn to symlink_check_one to minimize - overhead. - (symlink_check_one): Check extensions for existence for use - with spawn. - (readlink): Accommodate changes to symlink_check_one. - * spawn.cc (perhaps_suffix): Use new extension checking - capabilities of path_conv. - (find_exec_1): Delete. - (find_exec): Generalize to allow searching on any PATH like - environment variable. - * dllfcn.cc (check_path_access): Use find_exec to find a path. - This also ensures that paths are in Windows format which was - not the case before. - * environ.cc (conv_envvars): Add LD_LIBRARY_PATH. - * fork.cc (fork): Clean up dll loading slightly. - * Makefile.in: Turn on compiler warnings. - * winsup.h (save_errno): New class for saving errno from - being clobbered. - * include/sys/strace.h: Make system_printf a macro similar - to strace_printf_wrapper. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * sigproc.cc (sig_send): Attempt to work around Windows strangeness - when thread interrupted while waiting for completion event. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * dcrt0.cc: Remove debugging function DELETEME (). - * fhandler.cc (fhandler_base::fstat): Respond to compiler warning. - * signal.cc (sleep): Reset signal_arrived event before using it or - we could wake up immediately. - (usleep): Ditto. - (pause): Ditto. - * spawn.cc (spawn_guts): Ditto. Respond to compiler warning. - * sigproc.cc (sig_send): More debugging info. - (sig_dispatch_mutex): Only ping wait_sig when needed. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * select.cc (socket_cleanup): Close thread handle or suffer - handle leak. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * select.cc (verify_true): New function. - (fhandler_socket::select_*): Use verify_true for verification - function to avoid multiple calls to socket select. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * select.cc (select_stuff::wait): Scan entire list of fds - when WFMO wakes up. - (set_bits): Add some strace debugging output. - (thread_socket): Ditto. - (verify_ok): Return result of set_bits rather than always 1. - (start_thread_socket): Set the handle in the select structure - so that it will be properly identified in select_stuff::wait. - (fhandler_windows::select_read): Verification routine should - be `poll_windows'. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * sigproc.cc: Change some sigproc_printfs to only occur when - #ifdef DEBUGGING. - * spawn.cc (perhaps_suffix): Search for (PROG is the pathname to - the executable file) PROG.exe, PROG.com, PROG.bat, PROG.cmd, and - PROG and return extension found or NULL if no matching file. - (spawn_guts): If the file name of the executable ends in either - .exe, .com, .bat, or .cmd we assume that it is not a script file - and therefore do not open the file to determine if it is. - Fix "wait_failed" error when exec() called and non-cygwin parent. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * dir.cc (rmdir): Set correct errno when non-empty directory and - Windows9x. - * pipe.cc (pipe): Use binary mode by default for pipes. - * syscalls.cc (_read): Wait for terminated thread to exit before - clearing its stack memory. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * hinfo.cc (hinfo::fixup_after_fork): Start initial fd search - to zero forked processes so that a close(0)/dup(fd) will work. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * fhandler_windows::set_close_on_exec: Deal with possible - NULL handle. - (fhandler_windows::fixup_after_fork): Ditto. - * select.cc (select_stuff:wait): Handle return from - MsgWaitForMultipleObjects correctly for windows case. - * sigproc.cc (sig_send): Reset completion event for main thread. - * syscalls.cc (_read): Better handling of stack free condition. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * exceptions.cc (call_handler): Exit earlier if just running - in an exec'ed stub since the stub may own the sig_dispatch mutex, - but we still want to exit. - * select.cc (select_stuff::wait): Fix check for window activity - from MsgWaitForMultipleObjects. Handle infinite wait correctly. - (poll_windows): Add debugging output. - * spawn.cc (spawn_guts): Protect against signals interrupting - at an inopportune moment. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * select.cc (select_stuff:test_and_set): Take appropriate action - when a select record uses a window_handle. - (fhandler_windows::select_read): Set handle and windows_handle - appropriately. - (fhandler_windows::select_write): Ditto. - (fhandler_windows::select_except): Ditto. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * select.cc (cygwin32_select): Need to reset signal_arrived before - testing it or suffer loop. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * fork.cc (resume_child): Give up on SuspendThread synchronization - and use subproc_ready/forker_finished events. - (sync_with_parent): Ditto. - * sigproc.cc (wait_sig): Make sigcomplete_main manual reset to - allow handling of nested interrupts. - (wait_sig): Fix stupid typo on exit that would cause a - loop to run for a long time. Are exits faster now? - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * exceptions.cc (unlock_cs): Leave decision to release - sig_dispatch_mutex to the caller. - (set_process_mask): Call release_sig_dispatch_mutex explicitly - if needed. - (handle_sigsuspend): unlock_cs no longer takes an argument. - (call_handler): Try to acquire the strace mutex prior to - suspending the main thread to ensure that the mutex is always - released. - (sig_handle): Call release_sig_dispatch_mutex explicitly. - * fhandler_console.cc (fhandler_console::write): Protect against - signals while writing. - * signal.cc (signal): Protect against signal dispatch. - (sigaction): Ditto. - * sigproc.cc (sig_dispatch_pending): Return status no longer needed. - (sig_send): Assume pending_signals if sending signal to self. - (allow_sig_dispatch): Accept synchronize argument to control whether - to wait for wait_sig to do its thing. - (release_sig_dispatch_mutex): Just awaken wait_sig loop and wait - for acknowledgement if waitfor is TRUE. - (wait_sig): Don't ever zero pending_signals to avoid a possible race. - Set pending_signals for blocked signals, too. - * sigproc.h: Add __SIGFLUSH signal. - (class sig_protect): Allow destructor to wait for signal dispatch, - or not given constructor argument. - * strace.cc (get_strace_mutex): Renamed from waitfor_strace_mutex. - (release_strace_mutex): External function for use by call_handler. - This replaces raw calls to ReleaseMutex throughout. - * syscalls.cc (_read): Use sig_protect to protect against signals. - Other cosmetic cleanups. - (_close): Protect function with sig_protect. - * termios.cc (tcsetattr): Protect function with sig_protect. - -Thu Sep 10 21:09:51 1998 DJ Delorie - - * syscalls.cc (_read): typo in matching printf format to args. - - * fhandler.cc (write): Switch to the Microsoft/DJGPP way of - writing out text files: pass \r but prepend \r to \n. - (read): Don't collapse multiple \r's. - - * delqueue.cc: rewritten for speed. Don't check *every* entry in - the list if we know the list is empty, plus check for duplicates. - * delqueue.h: ditto. - * path.cc (path_conv): If a path component is missing, short- - circuit the symlink check. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * fhandler.h: Reorder fhandler status field so that device is - in lower bits. This allows gcc to optimize access to the device. - * hinfo.cc: Inline not_open(). - * winsup.h: Inline hinfo::not_open(). Make hinfo::[] operator a - simple array reference. - * strace.cc: Change strace() to a macro. - * include/sys/strace.h: Ditto. - * syscalls.cc (read_handler): New function. Called directly from - _read for "non-slow" devices or via read_handler for slow devices. - (_read): Use read_handler for reading. - (read_helper): Ditto. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * dcrt0.cc (do_exit): Don't ignore signals if reparenting. - Besides being a race, this screws up the process which is - actually executing. - * fork.cc (fork): Don't create a new process group when - forking or subprocesses won't respond to CTRL-C. - * syscalls.cc (_read): Ensure correct setting of EINTR errno. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * fork.cc (sync_with_child): Consider it a success if the child - has set the subproc_ready signal regardless of whether it has - exited or not. - * init.cc (dll_entry): Set read_helper_thread_info stuff to 0 - on dll initialization. Windows 95 seems to keep garbage here, - despite documentation to the contrary. - * syscalls.cc (_read): Report on errors to create read_helper - events. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * dcrt0.cc (compute_argc): Limit debug_printf string argument size - or suffer a buffer overrun. - (do_exit): Add debugging statement. - * exceptions.cc (call_handler): Remove extraneous sigproc_printf. - Consolidate signal_arrived event with sig_was_dispatched. - (events_terminate): Consolidate signal_arrived event with - sig_was_dispatched. - * fhandler.h: Rename a field to something more mnemonic. - * fhandler_tty.cc: Throughout: Only set up fhandler_tty_master when - actually using ttys. Change tty_master `f' field to `console'. - * tty.cc: Ditto. - * fork.cc (sync_with_child): Add more information to "child died" - error. - * hinfo.cc (hinfo::build_fhandler): Call tty master constructor - when appropriate. - * select.cc (select_stuff::wait): Consolidate signal_arrived event - with sig_was_dispatched. - * sigproc.h: Ditto. - * syscalls.cc (_read): Ditto. - * winsup.h: Ditto. - * sigproc.cc: Ditto, throughout. - (block_sig_dispatch): Don't reset signal_arrived. Causes races. - * spawn.cc (spawn_guts): Limit debug_printf string argument size - or suffer a buffer overrun. - * include/sys/strace.h: Implement strace_minimal for very minimal - output which, hopefully, will not affect the behavior of traced - programs as much. - -Thu Sep 10 21:09:51 1998 Geoffrey Noer - - * Makefile.in: build libwinspool.a with the dll name winspool.drv - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * dcrt0.cc (build_argv): Remove verbose debug_printf. - (dll_crt0_1): Use shared data handle passed in from parent process - when appropriate. Remove extraneous debug_printf. - * environ.cc (getwinenv): New function. Returns (possibly cached) - native version of an environment variable. - (win_env::add_cache): Add cached version of posix and win env - variables to local table. - (posify): Modify for use with native caching. - (setenv): Convert special environment variables to native here, - when they are set. - (struct parse_thing): Simplify struct. - (struct parse_things): Extend table to accommodate "envcache" - setting. - (parse_options): Add "envcache" option to control whether special - environment variables are cached. Simplify handling of remembered - parameters. - (winenv): Modify for use with getwinenv. - * exceptions.cc (unlock_cs): release_sig_dispatch takes an argument - now. - (set_process_mask): unlock_cs now wakens wait_sig when appropriate. - (handle_sigsuspend): Reorganize to take advantage of new behavior - of release_sig_dispatch_mutex and hopefully avoid a race. - (handle_sig): Avoid waking wait_sig if we couldn't get the dispatch - mutex. - * exec.cc (strccpy): Change to modify second argument to point - to position where "parse" stopped so that it doesn't have to be - recalculated by the caller. - (sexecvpe): Use find_exec () to find program to run. If you've - got a function for this, you might as well use it. - * fhandler_tty.cc (fhandler_pty_master::process_input_to_slave): - Report on signal being sent in termios_printf. Use kill_pgrp - interface. - * fork.cc (fork_copy): Just copy everything at once rather than - in individual pieces. - (fork): Potentially move up sbrk() when DEBUGGING so that parent - and child heaps are in sync. Pass cygwin_shared_h to child. - * path.cc (path_conv::path_conv): Make sure that a file is not - a symlink when returning immediately. - * sigproc.cc (sig_dispatch_pending): Return TRUE if signals were - pending. - (sigproc_init): Move sig_was_dispatched initialization here so - that it will always be available to other functions which rely - on it. Otherwise these functions would have to wait for wait_sig - to complete its initialization. - (sig_send): Rework SIGSUSPEND handling. - (release_sig_dispatch_mutex): Wait for signal to be dispatched - after releasing mutex if argument is TRUE. - (wait_sig): Remove sig_was_dispatched initialization from here. - * sigproc.h: release_sig_dispatch takes an argument. - * spawn.cc (perhaps_suffix): Take an optional argument indicating - whether the path has already been converted to win32. - (find_exec_1): Use getwinenv to get windows version of PATH. Use - windows version of individual directories to avoid posix lookups. - (spawn_guts): Call strace_dump here to cause strace output to - be slightly more synced when using strace caching. - (spawnvpe): Use find_exec () to find program to run. If you've - got a function for this, you might as well use it. - * syscalls.cc (_read): Only block signals for "slow" devices. - * winsup.h: Changes needed for previous checkin and getwinenv. - -Thu Sep 10 21:09:51 1998 DJ Delorie - - * path.cc (path_conv): bug fix when path ends in slash - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * fhandler.cc (fhandler_base::set_name): Use fhandler - method for determining native name. Avoid path_conv - when possible. - (fhandler_disk_file::get_native): New function, returns - windows name of disk file. - * fhandler.h: Add get_native() method to fhandler_* - classes. - * fhandler_serial.cc (fhandler_serial::get_native): Return - windows name of serial port. - * fhandler_tty.cc (fhandler_tty_master::init): Use consistent - name for tty master. - * fork.cc (fork_copy): Experimental change to avoid loop. - * grp.cc (add_grp_line): Use realloc to extend group buffer. - * hinfo.cc (hinfo::release): fd object should be deleted, - not freed or suffer a memory leak. - (init_std_file_from_handle): Reset first_fd_for_open to - signal that std* locations have been opened. Avoids use - of these locations prior to full dtable setup. - * passwd.cc (add_pwd_line): Use realloc to extend passwd buffer. - * path.cc (path_conv::path_conv): Avoid checking for symlinks on - network shares. Check for existence of file prior to taking - it apart for symlink checking (this needs more work). - (windows_device_names): Make global. - (get_device_number): Detect tty master. - * sigproc.cc (wait_sig): Maintain a flag which indicates when - signals are queued due to the wait_sig's inability to get a - sig_dispatch mutex. - (sig_dispatch_pending): Don't wake up the wait_sig thread if - unless there are signals queued (see above) or force argument. - (allow_sig_dispatch): Only wait for signal dispatch if something - is queued. - * sigproc.h: allow_sig_dispatch takes a (defaulted) argument now. - * syscalls.cc (_open): Use default hinfo::find_unused_handle call. - * net.cc: Ditto, throughout. - * pipe.cc: Ditto. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * dcrt0.cc (do_exit): Ignore user initiated signals here. - * fhandler.cc (fhandler_disk_file::open): Detect error condition - on fhandler_base::open. - * fhandler_console.cc (undo_input): Respond to compiler warnings. - * grp.cc (getgrgid): Ditto. - * times.cc (_tzname): Ditto. - * fhandler_tty.cc (fhandler_Tty_slave::open): Cosmetic changes. - * fork.cc: Clean up debugging output. - * pinfo.cc (pinfo_init): Set pgid and sid to different values - initially. Let user program set sid appropriately if it is - to be the owner of a tty. - * sigproc.cc (allow_sig_dispatch): Try harder to detect when we - should wait for a signal dispatch. - * strace.cc (strace_open): Revert to previous mutex behavior. - * include/sys/strace.h: Ditto. - * syscalls.cc (_open): Detect error from fhandler open. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - Global changes: - Store win32 name in fhandler structure to avoid multiple translations. - Support close_on_exec at the Win32 level for all but sockets. - Respond to gcc warnings. - Use single fstat() call for devices. - *::set_close_on_exec modified. - * dir.cc (opendir): Use win32 name in stat to speed things - up a little. - * debug.cc: New file. Provides routines for extra debugging - when -DDEBUGGING is specified. - * debug.h: New file. Definitions for debug.cc. - * exceptions.cc (signals_init): Break out signal initialization - from exceptions. - (dump_status): Add thread name to stack dump output. - (handle_exceptions): Renamed. - (set_process_mask): Don't ever mask non-maskable signals. - (ctrl_c_handler): Preliminary change to allow propagation of - cygwin signals back to gdb. - (sig_handle): Call do_exit directly from signal thread rather than - attempting to redirect the main thread. - * fhandler.cc (set_name): Store win32 name in fhandler structure. - (*::open) name field is extraneous now. Use get_win32_name () to - retrieve stored win32 name. - (fhandler_base::fstat): Default to performing fstat on a device. - (fhandler_disk_file::fstat): Renamed from fhandler_base::fstat. - Operate only on disk files. - (fhandler_base::set_close_on_exec_flag): New function sets flag - without touching the handle. - (fhandler_base::~fhandler_base): Free unix/win32 path names. - (fhandler_disk_file::close): Only call delqueue.process_queue from - this function since disk files are the only things that can - be unlinked, currently. - (fhandler_dev_null::open): Delete. - (set_inheritence): New function. Set handle inheritence. - (fhandler_*::fork_fixup): New functions. Inherit fhandler data - after a fork. - fhandler.h: *::set_output_handle - new method. - Setup methods for use by select(). - fork.cc (fork): Call fixup_after_fork in child to inherit - handles marked as non-inheritable on CreateProcess. - hinfo.cc (hinfo::build_fhandler): Use new function to detect - devices. - (dup_for_exec): Delete obsolete function. - (hinfo::dup2): Remove extraneous tests. - (hinfo::select_*): Interfaces into select(). - (hinfo::release): Free fd in dtable. - (hinfo::fixup_after_fork): New function. Inherit close-on-exec - handles from parent after fork. - path.cc (mount_info::posix_path_p): Make inline. - (path_conv::path_conv): Short circuit when path resolves to a device. - (digits): Move here from hinfo.cc. - (windows_device_names): Win32 names for Cygwin devices. - (get_device_number): New function. Return devie number given device - name. - (win32_device_name): New function. Decode a windows device name - and an optional "unit". - (mount_info::conv_to_win32_path): Short circuit when path resolves to - a device. - * path.h: add device and unit fields to path_conv class. - * select.cc: Rewrite for more structure, more OO. - * sigproc.cc: (get_sig_dispatch_mutex): New function. - (release_sig_dispatch_mutex): New function. - * sigproc.h: sig_protect class. Automatic protection from signals - when used. - * syscalls.cc (stat_dev): New function. - (stat_worker): Short-circuit when a cygwin device is detected. - * utils/ps.cc: Don't lock_pinfo when -f. Compress format to fit - more on a line. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Register name for main thread. - * exceptions.cc (dump_status): Add thread name to diagnostic output. - (__cygwin32_exception_handler): Rename to handle_exceptions. Avoid - creating a .core file. - * exec.cc (sexecve): Reflect spawn_guts argument change. - * fhandler_tty.cc (fhandler_tty_master::init): Use makethread to - create a new thread. - * select.cc: Create pipe/socket threads each time select is called. - Use thread termination as indication of fd readiness. - * sigproc.cc (sigproc_init): Use makethread to create a new thread. - (wait_sig): Simplify default signal call slightly. - * spawn.cc (spawn_guts): Accept child pinfo pointer rather than - pid. Reorganize so that common initialization is handled once. - * strace.cc: Set strace_mutex to NULL initially to catch CreateMutex - errors. - * window.cc (gethwnd): Use makethread to create a new thread. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * Makefile.in: Add debug.o target. - * cygwin.din: Separate pipe from _pipe. - * dcrt0.cc (alloc_stack): New, more precise method for allocating - stack space after a fork. - (dll_crt0_1): Use new child_proc_info class to retrieve information - from possible parent process. Remove #ifdef erroneously checked in. - Remove extraneous syscall_printf. - * exceptions.cc (signals_init): New function. - * fhandler.cc (fhandler_make_pipe): Move to pipe.cc. - * fhandler.h (fhandler_base): New = operator preserves unix_path_name_. - * fhandler_tty.cc: Strip some tty functions from here into tty.cc. - * fork.cc: Remove obsolete ifdefs. Reorganize, streamline with new - fork. - * hinfo.cc: Speed up build_fhandler. - * libccrt0.cc: Remove obsolete ifdefs. - * pinfo.cc (pinfo_init): Simplified by new fork/spawn info passing - method. - * pipe.cc (make_pipe): Moved from fhandler.cc. Handles MS-style - _pipe. - (pipe): Use new arguments to make_pipe. - (_pipe): New MS-compatible function. - * shared.cc: cygwin_shared_h make global so that it can be inherited - via new fork/spawn info passing method. - (open_shared_file_map): Detect if shared info is already set up from - fork/spawn. - * sigproc.cc (sigproc_init): Initialize signals with signals_init here. - Use new fork/spawn info passing method. - * spawn.cc (spawn_guts): Pass information in a structure to spawned - process. Identify structure type with a "magic number". - * strace.cc (strace_printf): Only print program full path spec once - to save space and clutter. Preserve any windows error. - * syscalls.cc (_open): Detect and avoid error return from - build_fhandler. - * tty.cc: Accept some non-fhandler functions formerly found in - fhandler_tty.cc - * winsup.h (pinfo): Remove some fields obsoleted by new fork/spawn - info passing method. - (child_info*): New classes for passing information to forked/spawned - process. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - * Makefile.in: Add debug.o target. - * console.cc (fhandler_console::char_command): Fix failed merge. - * dcrt0.cc (alloc_stack): New, more precise method for allocating - stack space after a fork. - (dll_crt0_1): Use new child_proc_info class to retrieve information - from possible parent process. Remove #ifdef erroneously checked in. - Remove extraneous syscall_printf. - -Thu Sep 10 21:09:51 1998 Christopher Faylor - - Global changes: - Replace pinfo hmap entry with "dtable" reference. - Replace cygwin_shared .t field with '.tty' and allow indexing via - tty into this array. - Make fhandler_ constructors set the size of the structure into any - created class. - Change fhandler settings into a bit mask. Use methods to access. - Record device type in fhandler class. - Remove old linearize/de_linearize code in favor of newer method - uses more bullet-proof method for determing device type of inherited - files. - Protect various important handles from closing when operating - under -DDEBUGGING. - * dcrt0.cc (do_global_ctors): Renamed, made static and reused - for calling from dll_crt0_1 to initialize cygwin.dll constructors. - (do_global_dtors): Renamed. - (dll_crt0_1): mark noreturn. Use new do_global_ctors function. - Call debug_init to initialize features turned on by -DDEBUGGING. - Call dtable_init to initialize dtable, hinfo_init to initialize - standard fds. - (dll_crt0): Mark noreturn. Move constructor calls to dll_crt0_1. - (__main): Use new do_global_ctors (). - Remove OLDWAY and _PPC_ conditionals. - * environ.cc (environ_init): Use appropriate strace printf. - * exceptions.cc (set_process_mask): Don't ever mask out unmaskable - signals. - * init.cc (dll_entry): Initialize storage for read_helper. - * pinfo.cc (init_from_exec): Delete obsolete function. - * sigproc.cc (sig_send): Implement myself_nowait to allow - sending a signal to myself without waiting for synchronization. - (wait_sig): Change method for determining whether signal should - be examined slightly. - * strace.cc (strace_printf): Add ability to report on thread from - which message originated. - (threadname): New function - * syscalls.cc (read_helper): New function. Invoked in separate thread - from _read. - (_read): Use a separate thread for reads that can be interrupted - with a TerminateThread(). Allows EINTR. - (setdtablesize): Use new method for extending the size. Callable - from anywhere. - (getdtablesize): Use new method for getting the current dtable size. - * tty.cc: Remove use count in favor of a method which checks tty - availability via an event. Some code cleanup. - (tty::inuse): New function for determining if a tty is - in use by any process. - (tty_list::terminate): Use new method for determining if a tty is in - use. Should avoid hangs waiting for non-existent processes to - free up a tty. - (tty::common_init): Common initialization for tty/pty master. - (fhandler_tty_master::init): New function. - (do_output): Use new method for determining if a tty is in use. - (fhandler_pty_master::open): Use comon initialization code. - (fhandler_pty_master::ptsname): static buffer is ok now. - * tty.h: Reflect inuse changes and tty.cc cleanup. - * winsup.h: Include debug.h for use when -DDEBUGGING. Remove - stuff previously here which was conditionally compiled with -DDEBUGGING. - (hinfo_vec): Rename to hinfo. Maintain argv style list of pointers - to open fds. Add methods to deal with above changes. - (pinfo): Removals due to above changes. - (shared_info): Rename t to tty. - Add common defines to extern "C" section. - -Wed Sep 9 22:24:50 1998 Christopher Faylor - - * path.cc (path_prefix_p_): Rewrite to avoid false match - against root when remote path or \\x style disk device. - * include/sys/strace.h: Implement new macro for use by - malloc_printf which does not default to "on" if STRACE=1. - This avoids massive strace logs. - -Tue Sep 8 11:31:42 1998 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Remove ill-advised ifdef NEEDOEM. - -Thu Sep 3 17:54:18 1998 Christopher Faylor - - * Makefile.in: Speed up dll links. - * path.cc (chdir): Fix previous change. - -Mon Aug 31 12:23:33 1998 Christopher Faylor - - * path.cc (chdir): Protect free from potential signal race. - -Fri Aug 28 15:59:27 1998 Geoffrey Noer - - * dlfcn.h: delete, move it - * include/dlfcn.h: here - -Thu Aug 27 14:20:38 1998 Christopher Faylor - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * path.cc (path_conv::path_conv): remove trailing backslash from - full win32 name, otherwise the last component of the path isn't - checked for symlink. - -Wed Aug 26 14:15:22 1998 Christopher Faylor - - * fhandler.h (fhandler_base): Make set_name() public and implement - clear_name() to accommodate dup2. - * hinfo.cc (dup2): Previous change exposed problem with dup2. - Same unix_path_name_ ptr was being used in two separate fds. - Fix this. - -Wed Aug 26 12:10:27 1998 Christopher Faylor - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * malloc.cc: Use malloc_printf throughout. - * path.cc (getcwd_inner): Allocate buffer with realloc to - avoid a memory leak. - * syscalls.cc (_close): delete unix_path_name_ explicitly since - destructor is never called. - * include/sys/strace.h: Add strace_malloc stuff. - -Mon Aug 24 15:45:59 1998 Geoffrey Noer - - * include/sys/ioctl.h: variable names in protos should start - with two leading underscores. - * include/sys/mman.h: ditto. - * include/sys/mount.h: ditto. - * include/sys/resource.h: ditto. - * include/sys/smallprint.h: ditto. - * include/sys/socket.h: ditto. - * include/sys/strace.h: ditto. - * include/sys/vfs.h: ditto. - * include/sys/wait.h: ditto. - * include/mntent.h: ditto. - -Tue Aug 18 17:00:20 1998 Geoffrey Noer - - patch from Trevor Yann (TYann@vet.com.au): - * uname.cc (uname): report processor type for win98 - -Tue Aug 18 16:09:13 1998 Christopher Faylor - - * fork.cc (cygwin_fork_helper1): Start initial fd search - to zero forked processes so that a close(0)/dup(fd) will work. - -Mon Aug 17 16:58:09 1998 Christopher Faylor - - * winsup.h (hinfo): Remember initial fd to start searching - for new fds. This avoid assigning std/in/out/err to - files opened early in initialization. - (hinfo_vec::find_unused_handle): New default way to search - for a new handle. Avoids using std/in/out/err until the - proper time in the initialization. - * fhandler.cc (fhandler_make_pipe): Use default method for - finding unused handle. - * net.cc: Ditto throughout. - * pipe.cc (dup): Ditto. - * syscalls.cc (_open): Ditto. - * hinfo.cc (hinfo_vec::init_std_file): Set initial fd for open - search to include std/in/out/err. - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * spawn.cc (perhaps_suffix): Use translated win32 path when - determining if a .exe extension should be added or suffer adding - a .exe extension twice. - -Mon Aug 10 15:08:49 1998 Geoffrey Noer - - * include/cygwin32/version.h: up minor version number - -Mon Aug 10 07:04:13 1998 DJ Delorie - - * delqueue.cc: rewritten for speed. Don't check *every* entry in - the list if we know the list is empty, plus check for duplicates. - * delqueue.h: ditto. - -Sat Aug 8 14:03:52 1998 Eric Bachalo - - * spawn.cc (perhaps_suffix): If report_failure_p is non-zero this - function will search for (PROG is the pathname to the executable - file) PROG.exe, PROG, PROG.com, PROG.bat, and PROG.cmd and return - either the full path name if found or NULL if not. - (spawn_guts): If the file name of the executable end in either - .exe, .com, .bat, or .cmd we assume that it is not a script file - and therefore do not open the file to determine if it is. - -Thu Aug 6 22:25:38 1998 Christopher Faylor - - * path.cc (path_conv): If a path component is missing, short- - circuit the symlink check. Bug fix for case where path ends - in a slash. - (path_conv::path_conv): Make sure that a file is not - a symlink when returning immediately. Avoid checking for - symlinks on network shares. Check for existence of file prior - to taking it apart for symlink checking (this needs more work). - -Sun Aug 2 19:17:59 1998 Christopher Faylor - - * select.cc (cleanup_pipe_thread): Cleanup thread handle or suffer - handle leak. - (cleanup_socket_thread): Ditto. - * sigproc.cc (proc_subproc): Make wait thread manual reset to - solve problem with nested waits not waiting correctly. - * fhandler_tty (fhandler_tty_slave::open): Don't create the output - mutex, just open it. If it can't be opened, its an error. - -Wed Jul 29 12:08:19 1998 Eric Bachalo - - * include/Windows32/Defines.h: Added Virtual-Key Code defines - for the Win95 keys - VK_LWIN, VK_RWIN, and VK_APPS. - -Tue Jul 21 14:47:59 1998 DJ Delorie - - * path.cc (path_prefix_p): optimize calls by comparing first - characters inline. - (path_conv): optimize by not checking both foo and foo/ for - symbolic links. - -Tue Jul 21 14:39:03 1998 Christopher Faylor - - * pinfo.cc (pinfo_init): Set myself->sid to 1 so that - a program started up outside of cygwin will not trump - other opens of ttys. Fixes problem with pgid change below. - -Tue Jul 21 12:59:21 1998 Christopher Faylor - - * path.cc (chdir): Force chdir to disk device to go to the root - directory. - -Tue Jul 21 09:32:23 1998 Christopher Faylor - - * pinfo.cc (pinfo_init): 0 is a very bad value for a default pgid. - -Fri Jul 16 15:09:50 1998 Stan Cox - - * (gcrt0.c, gmon.c, profil.c, mcount.c, gmon.h, profil.h, - config/i386/profile.h): New files for gprof cygwin support. - Some code contributed by Tim Newsham for Secure Networks, Inc. - * Makefile.in (LIBGMON_A, GMON_START, GMON_OFILES): New for gprof. - -Mon Jul 13 19:29:00 1998 Eric Bachalo - - * dcrt0.cc (insert_files): Now both -@file and @file work as - command line file insertion options. - * fhandler_serial.cc (fhandler_serial::open): Enabled RTS Control - Line by default to make full handshaking cables work for the - D10V board. (CDB.fRtsControl) - (fhandler_serial::tcsetattr): same as above - -Wed Jul 8 15:53:35 1998 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Avoid redundant strace_printf. - -Wed Jul 8 15:05:10 1998 DJ Delorie - - * fhandler.cc (fhandler_base::lseek): Note lseek so that next - write() can check for the Win95 "gap" bug. - (fhandler_base::write): If Win95 and lseek past eof - followed by write, use WriteFile to force the "gap" to be filled - with zeros rather than left to the "undefined" data Win32 specifies. - (fhandler_base::fhandler_base): initialize check_win95_lseek_bug_. - * fhandler.h (class fhandler_base): Add check_win95_lseek_bug_ - for bug: when seek past EOF and write, win95 fills with random - data (security hole). - -Thu Jul 2 10:45:15 1998 Christopher Faylor - - * environ.cc (winenv): Be more paranoid when restoring special - win32 environment variables beginning with '='. - -Thu Jul 2 09:19:32 1998 Christopher Faylor - - * environ.cc: Previous change was not rigorous enough. - Track environment variables to convert in a structure which - records the correct function for converting the environment - variable from/to POSIX format. - (isspecial): New function. - (parse_options): Use template to initialize parse array. - (posify): Use new conversion function. - (winenv): Ditto. Also restore special win32 environment variables - beginning with '='. - * path.cc (conv_path_list): Source argument should be const. - (win32_to_posix_path_list): Ditto. - (posix_to_win32_path_list): Ditto. - * path.h: Reflect changes to path.cc. - -Tue Jun 30 14:00:32 1998 Christopher Faylor - - * environ.cc (winenv): Avoid converting environment variables to - windows style if they begin with something like a 'C:'. - -Sun Jun 28 20:59:16 1998 Christopher Faylor - - * include/Windows32/Structures.h (MINMAXINFO): Add a missing - *LP... - -Thu Jun 25 10:45:38 1998 Christopher Faylor - - * signal.cc (sigpending): Stop from always reporting pending signals - when no signals are actually pending. - -Tue Jun 23 15:38:45 1998 Christopher Faylor - - * Makefile.in: Add a new target. - * cygwin.din: Add cygwin32_internal interface. - * dcrt0.cc (dll_crt0_1): Don't call main if no main set. Allows - initialization from a .dll. - * utils/ps.cc: Use new internal/external interface to cygwin to - provide an unchanging interface to some cygwin internals. - * external.h: Preliminary stab at an interface to cygwin32 for - getting at the "naughty bits". - * external.cc: External interfaces to some cygwin internal stuff. - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * exceptions.cc (sig_handle): When abnormally terminating, - close_all_files in signal thread context to prevent socket hangs. - -Thu Jun 18 15:17:06 1998 Christopher Faylor - - * pinfo.cc (pinfo_list::allocate_pid): Wrap pids at SHRT_MAX - or ash complains. - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * window.cc (WndProc): Always kill timer before starting up - a new one or eventually suffer a timer proliferation. - -Mon Jun 15 09:40:30 1998 Christopher Faylor - - * exceptions.cc: Cosmetic change. - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * syscalls.cc (system): Ignore SIGINT, SIGQUIT and SIGCHLD while - in a system() call. - -Thu Jun 11 18:37:02 1998 Geoffrey Noer - - * include/sys/syslog.h: add missing LOG_LOCALn bits - -Tue Jun 9 22:29:26 1998 Christopher Faylor - - * dll_init.cc (DllNameIterator::operator const char* ()): Add - a missing \n to a *_printf. - * fhandler_tty.cc (fhandler_tty_slave::dup): Ditto. - (fhandler_tty_slave::ioctl): Ditto. - * errno.cc (errmap): Add an unrepresented windows error. - Simplify table. - -Tue Jun 9 17:21:44 1998 Christopher Faylor - - * errno.cc (errmap): Make sure that errmap array is - terminated with a NULL or suffer a SIGSEGV. - -Tue Jun 9 10:30:02 1998 Christopher Faylor - - Change `sprintf' to `__small_sprintf' throughout cygwin. - * cygwin.din: Don't export exception handler. - * exceptions.cc (__cygwin32_exception_handler): Rename to - handle_exceptions. Make static. Redo core file generation - slightly so that __small_sprintf can be used. - (call_handler): Remove use of `rethere' in asm code. Don't - probe stack as this is potentially dangerous unless done - meticulously. - * select.cc (select): Redo to create thread whenever needed - for pipe/socket. Thread termination denotes fd readiness. - -Mon Jun 8 14:31:11 1998 Christopher Faylor - - * hinfo.cc (set_std_handle): New function to set windows - "standard" handles from cygwin handles. - (hinfo_vec::dup2): Set windows standard handle if appropriate. - * syscalls.cc (_open): Set windows standard handle if appropriate. - -Sun Jun 7 16:34:00 1998 Christopher Faylor - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * fhandler_console.cc (fhandler_console::scroll_screen): Add a - workaround for Win95 ScrollConsoleScreenBuffer bug which allowed - scrolling to work correctly in both directions. - (fhandler_console::char_command): Simulate underscore with cyan - instead of magenta like on a real linux console. - -Sat Jun 6 00:01:18 1998 Christopher Faylor - - * dcrt0.cc: Remove obsolete PPC and OLDWAY defines. - * exceptions.cc: Remove obsolete PPC defines. - -Fri Jun 5 22:18:01 1998 Christopher Faylor - - * utils/Makefile.in: install should build products if necessary. - -Fri Jun 5 17:47:11 1998 Geoffrey Noer - - * errno.cc (seterrno): shouldn't & against 0xff since there - are error codes above 255. - -Fri Jun 5 14:35:36 1998 Christopher Faylor - - * exceptions.cc (ctrl_c_handler): Ignore CTRL_LOGOFF_EVENT or - everybody gets signalled when a user logs off. Allow program - to clean up when receiving a CTRL_CLOSE_EVENT or CTRL_SHUTDOWN_EVENT. - * spawn.cc (_spawnve): Delete hmap.vec from created child since - it just gets overwritten in the child anyway. - * pinfo.cc (lpfu): u -> user_data. - -Thu Jun 4 22:45:12 1998 Geoffrey Noer - - * mmap.cc (mprotect): 3rd arg to VirtualProtect call should - be new_prot, not prot. Also, fix check for PROT_NONE (==, - not &). - -Wed Jun 3 16:37:43 1998 Geoffrey Noer - - * exceptions.cc: Fix typo in comment - (ctrl_c_handler): Add comments, return FALSE on CTRL_CLOSE_EVENT, - CTRL_LOGOFF_EVENT, and CTRL_SHUTDOWN_EVENT events. Otherwise, - we handle the console event ourselves, send a SIGINT, and return - TRUE. - -Wed Jun 3 14:36:08 1998 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * path.cc (conv_to_win32_path, conv_to_full_win32_path): resolve - symlinks before converting. - -Wed Jun 3 02:11:23 1998 Geoffrey Noer - - * exceptions.cc (ctrl_c_handler): return zero when a - CTRL_LOGOFF_EVENT occurs. - -Wed Jun 3 01:01:17 1998 Geoffrey Noer - - Reorganize fhandler-related file layout. - * Makefile.in: Remove console.o, add fhandler_console.o. Add - fhandler_serial.o. Remove tty.o, add fhandler_tty.o. - * fhandler_console.cc: Was console.cc. - * console.cc: Delete. - * fhandler_serial.cc: Was code in fhandler.cc. - * fhandler.cc: Delete fhandler_serial routines. - * fhandler.h: Fix comments describing fhandler file layout. - * fhandler_tty.cc: Was code in tty.cc. - * tty.h: Delete. - * fhandler_tty.h: Was tty.h. - * tty.cc: Delete code moved to fhandler_tty.cc. - * winsup.h: Include fhandler_tty.h instead of tty.h. - -Tue Jun 2 23:34:42 1998 Geoffrey Noer - - Don't need processor-specific sysdef directories: - * sysdef/powerpc: remove all files - * sysdef/i386: move all files to top of sysdef directory - * configure.in: stop setting processor-specific sysdef variable - * configure: regenerate - * Makefile.in: build .a files from top-level sysdef files. - -Tue Jun 2 16:52:18 1998 Geoffrey Noer - - patch from lhall@rfk.com (Larry Hall): - * console.cc (fhandler_console::fhandler_console): call - fillin_info() to check if console attributes have already been - set. If so, set the default foreground color to be the default - for the console, otherwise set it to white. - (fhandler_console::char_command): use the default color to set fg, - bg, and bold for all cases. - -Mon Jun 1 14:05:01 1998 Christopher Faylor - - * dir.cc (writable_directory): Avoid a malloc. - (opendir): Convert to fully qualified path spec. Use inode from - stat as hash instead of recalculating. - (readdir): Try hard to generate the same inode for filenames - as inodes returned from stat(). Handle '.' and '..' inodes - differently than normal files. Note that '..' will still fail - in certain pathological conditions. - * fhandler.cc (fstat): Preserve errno around path conversion. - * path.cc (path_conf::path_conv): Add an extra argument signifying - whether caller wants a fully qualified Windows spec. - (get_current_directory_name): New function. Retrieves current - directory name into internal buffer. - (getcwd_inner): Reorganize. Use get_current_directory_name() - to retrieve a (possibly cached) directory name. - (hash_path_name): Move function here from syscalls.cc. Rewrite to - deal (simplistically) with non-absolute path specs. Use - get_current_directory_name to absolutize path. - * path.h: Reflect additional argument for path_conv. - * select.cc (cygwin32_select): Remove newline from select_printf(). - * syscalls.cc (hash_path_name): Move to path.cc. - (stat_worker): Always use full path spec so that inodes are - calculated correctly. - * uinfo.cc (getlogin): Make extern "C". - * include/sys/resource.h: Put extern "C" around this file. - -Mon Jun 1 13:16:03 1998 Christopher Faylor - - * console.cc: Comment out small_printfs which issue errors - on things like invalid escape sequences. This is very much - unlike a normal terminal, or even like linux which console.cc - purports to emulate. - (console_read): Renamed from FakeReadConsole. Streamline - slightly. - (fhandler_console::read): Ditto. - -Fri May 29 22:41:18 1998 Geoffrey Noer - - * hinfo.cc: Include unistd.h, not fcntl.h. - -Fri May 29 21:38:10 1998 Christopher Faylor - - * path.cc (mount_info::binary_win32_path_p): Don't allow - the root mount to replace a //drive or //host specification. - -Fri May 29 08:20:28 1998 Geoffrey Noer - - * winsup.h: Remove exports section in favor of external - include files. Fix some comments. - * {console.cc, fcntl.cc, pipe.cc}: Include unistd.h. - * dcrt0.cc (__main): Make extern "C". - * strace.cc: Include time.h. - * wait.cc (_wait): Make extern "C". - * version.h: Bump minor version to 3 in honor of /dev/windows - support. - -Fri May 29 03:11:28 1998 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * Makefile.in: Add fhandler_windows.o target - * fhandler.h: Include . fhandler_windows: new - fhandler class that handles access to Windows message queue. - (fhandler_base::is_windows): new virtual member function - * fhandler_windows.cc: New file, fhandler_windows class - implementation. - * hinfo.cc (hinfo_vec::build_fhandler): build fhandler_windows - class for "/dev/windows". Include . - * select.cc: New fd_windows_map class - (fd_windows_map::convert_to_unix_fdset): New, check for Windows - messages in a queue. - (cygwin32_select): check for windows fd is passed to select call, - increase size of harray by one to support windows pseudo-handle, - do MsgWaitForMultipleObjects if windows fd passed to select call. - -Thu May 28 18:22:24 1998 Ian Lance Taylor - - * utils/cygpath.cc: New file. - * utils/Makefile.in (PROGS): Add cygpath$(EXEEXT). - (cygpath$(EXEEXT)): Ne target. - - * include/sys/cygwin.h: Declare more path conversion functions. - -Thu May 28 15:56:26 1998 Geoffrey Noer - - * include/sys/ioctl.h: need to include - * syscalls.h: remove ioctl proto - -Wed May 27 01:34:06 1998 Geoffrey Noer - - * cygwin.din: add sethostent/endhostent exports - * net.cc (sethostent, endhostent): new stubs - -Fri May 22 17:31:50 1998 Geoffrey Noer - - * include/cygwin32/in.h: correct typo in IPPORT_WHOIS define - -Fri May 22 17:00:48 1998 Geoffrey Noer - - * include/sys/ioctl.h: add ioctl proto - -Wed May 20 18:52:31 1998 Geoffrey Noer - - * include/sys/param.h: delete, file overlaps with newlib's. - Move it to newlib/libc/sys/cygwin32/sys where such files - are supposed to go. - -Wed May 20 18:20:35 1998 Geoffrey Noer - - * select.cc (auto_del_fd_set_map::auto_del_fd_set_map): correct - C++ problem -- can't use parens in call to new. - -Wed May 20 17:03:25 1998 Geoffrey Noer - - based on patch from newsham@lava.net (Tim Newsham): - * select.cc: FIXMEs added/adjusted - (select_sleep): new static select helper function - (cleanup_sockthread): ditto - (cleanup_pipethread): ditto - (cygwin32_select): remove degenerate goto in favor of calling - select_sleep, call cleanup_sockthread and cleanup_pipethread - instead of previously duplicated code. - -Wed May 20 02:21:37 1998 Geoffrey Noer - - patch from Christopher Faylor - * fhandler.cc (fhandler_serial::raw_read): When - vmin_ == 0, vtime_ > 0, don't force only one char at a time - to be read. - (fhandler_serial::tcsetattr): set to.ReadIntervalTimeout - and to.ReadTotalTimeoutMultiplier appropriately so reads - will time out properly when vmin_ == 0, vtime_ > 0. - -Tue May 19 09:05:46 1998 Christopher Faylor - - * init.cc (set_dllname): Use consistent "cygwin32" name for dll - if the name of the dll is actually cygwin. This will allow - better interoperability between dlls which have been renamed, - i.e., cygwindevo.dll -> cygwin98r1.dll. - -Mon May 18 22:39:35 1998 Christopher Faylor - - * winsup.h: Remove sig* undefs since this is now done in newlib. - Define SIGTOMASK define for use by signal mask operations. - * exceptions.cc (__cygwin32_exception_handler): Use SIGTOMASK. - (sig_handle): Ditto - * signal.cc (sigpending): Ditto. - (sigaddset): Use SIGTOMASK. Disallow signal 0. - (sigdelset): Ditto. - (sigismember): Ditto. - * strace.cc (strace_printf): It is possible for strace_mutex to - be an invalid handle. Open the mutex if so. Call ReleaseMutex - until exhausted since a signal may have interrupted an strace_printf. - (strace_dump): Call ReleaseMutex until exhausted. - * tty.cc (do_output): Remove strace printf to avoid filling up strace - output. - (fhandler_tty_slave::read): Use SIGTOMASK. - -Mon May 18 09:11:38 1998 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Clear errno before calling main. - -Thu May 14 00:37:01 1998 Geoffrey Noer - - * dcrt0.cc: add comments, reformatting - -Wed May 13 17:47:23 1998 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * times.cc (to_time_t): prevent stat from returning incorrect - file modification time (one second less) on fat partitions due - to round-up error. - -Wed May 13 16:03:07 1998 Geoffrey Noer - - * select.cc: add comments, FIXMEs, respace, delete old - sockets-only case that was previously commented out. - (cygwin32_select): in case where handles and sockets are - set, don't check that always_ready_used is zero (that case is - covered before). - * syscalls.cc: delete unused file_queue struct. - -Tue May 12 18:36:25 1998 Geoffrey Noer - - * syscalls.cc (get_os_type): add FIXME - -Tue May 5 14:02:12 1998 Christopher Faylor - - Throughout Cygwin replace use of "sa" SECURITY_ATTRIBUTE variables - with appropriate global variables. - * shared.cc (shared_init): Initialize global security attribute - variables for use in various places around cygwin. - * fork.cc (fork_init): Remove. Functionality replaced by above. - * dcrt0.cc (dll_crt0_1): Remove obsolete fork_init() call. - -Sat May 2 17:40:51 1998 Christopher Faylor - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * tty.cc (create_tty_master): Fill in ut_host utmp field with - local host name instead of "local" to avoid "who" command timeouts. - -Fri May 1 22:38:20 1998 Christopher Faylor - - * environ.cc: Add a global to control com port reset behavior. - (parse_options): Recognize "reset_com" as a CYGWIN32 option. - * fhandler.cc (fhandler_serial::raw_read): Handle vmin and vtime - more like UNIX. - (fhandler_serial::open): Revive code to reset com port on open. - Only reset the port if reset_com global is not set and if this - function is being called explicitly by open. - (fhandler_serial::tcsetattr): Make CRTSCTS flow control more - like UNIX -- it should turn on hardware handshaking in both - directions. Handle vmin and vtime in a manner more consistent - with UNIX. - (fhandler_serial::tcgetattr): Reflect CRTSCTS changes above when - reporting this state. - * include/sys/termios.h: Move CRTSCTS and CRTSXOFF (sic) into - 16 bits or they will never be capable of being set. - -Thu Apr 30 15:05:45 1998 Christopher Faylor - - * console.cc (fhandler_console::init): If resetting stdin, - make sure to reset the ConsoleCtrlHandler. - * exceptions.cc (set_console_handler): New function broken out - of init_exceptions(). Sets the function responsible for handling - CTRL-C. - (init_exceptions): Snipped out set_console_handler. - -Thu Apr 30 14:11:30 1998 Christopher Faylor - - * include/sys/cygwin.h: Remove cygnus-specific declaration. - * winsup.h: Move cygnus-specific cygwin32_attach_handle_to_fd - declaration here. This function may eventually be replaced by - an osf_* function. - -Tue Apr 28 17:07:46 1998 Geoffrey Noer - - * passwd.cc (parse, getpass): remove unneeded uses of NO_COPY - * grp.cc (getgrgid, getgrnam): ditto - -Tue Apr 28 16:18:03 1998 Geoffrey Noer - - * version.h: bump minor version to 2 - * errno.cc: add FIXME - -Wed Apr 22 15:43:56 1998 Geoffrey Noer - - * syscalls.cc (cygname): delete - * shared.cc (shared_name): new, was cygname - * strace.cc, exceptions.cc, sigproc.cc, shared.cc: fix - cygname references in light of above - -Wed Apr 22 14:12:09 1998 Christopher Faylor - - * select.cc (fd_set_map::remove_pair_by_handle): minor optimization - * strace.cc (strace_printf): change format for consistency - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * dcrt0.cc (dll_crt0): Call global constructors explicitly - * tty.cc (create_tty_master): Remove code which attempted to - invoke tty constructor - -Tue Apr 21 16:18:27 1998 Christopher Faylor - - * environ.cc (ucenv): inline - (posify): Ditto - (environ_init): remove obsolete function use - * path.cc (symlink_check_one): Set errno here where appropriate. - (readlink): Rely on errno set by symlink_check_one rather than - defaulting to EINVAL. Should fix problems with RCS. - -Tue Apr 21 15:36:41 1998 Christopher Faylor - - * Implement a NOSTRACE preprocessor define to allow building - Cygwin32 without any STRACE code. - * configure.in: Add entries for architecture specific programs - to allow easier cross-compile builds - * configure: Ditto - * Makefile.in: Ditto - * console.cc (fhandler_console::char_command): Fix two problems - with cursor position report: 1) it reported position relative - to beginning of buffer rather than beginning of screen, 2) it - reported y, x in reversed order - * dcrt0.cc: Remove NO_COPY from variables that don't need it. - Remove variables obsoleted by NO_COPY. - (dll_crt0_1): strace settings are now inherited. Don't try - to initialize strace early. Remove initialization of variables - which are now handled automatically by NO_COPY. Set error mode - for Cygwin32 to fail on critical errors rather than popping up - a dialog box. - * spawn.cc (spawn_guts): Always use default error mode when - spawning a new process. Move error message to more generally - useful location. Terminate signal handling in a cygwin parent - process or two processes will be handling signals. - (_spawnve): Inherit strace stuff - * exceptions.cc (events_init): Provide more information on - "Catastrophic failure". Change error message wording slightly. - * fork.cc: Remove obsolete structure - (cygwin_fork_helper1): Remove use of obsolete structure. Inherit - strace settings in child processes. - * sigproc.cc (sigproc_init): Set wait_sig priority immediately - after thread creation. - * smallprint.c: Remove unneeded include - * strace.cc: Reorganize to handle NOSTRACE - (strace_open): Use strace entries in pinfo structure which are - now inherited - (strace_dump): ditto - (strace_init): preprocessor define STRACE_HHMMSS causes strace - output to use alternate log file format. - (strace_printf): ditto - * syscalls.cc (access): Remove SetErrorMode in favor of global - cygwin32 setting in dll_crt0_1. - * fhandler.cc: Handle NOSTRACE - * tty.cc: Ditto - * window.cc: Ditto - * include/sys/strace.h: Ditto - * winsup.h: Move strace_file handle from per_process to pinfo so - that it can be inherited. Remove obsolete pinfo entry. - -Tue Apr 21 14:30:52 1998 Christopher Faylor - - * hinfo.cc (cygwin32_attach_handle_to_fd): New function - * include/sys/cygwin.h: Ditto. - * cygwin.din: Export new cygwin-specific function - -Tue Apr 21 02:32:08 1998 Geoffrey Noer - - * syscalls.cc: comment out file_queue struct that doesn't - seem to be used for anything anymore. Don't need to include - stdarg.h or sys/socket.h. Include utmp.h. Minor respacing. - Move all functions from misc.cc here. - (_read): change strace debug printf function name to _read - (logout): rename success to res - * misc.cc: delete file - * Makefile.in: adjust for above change - -Tue Apr 21 01:45:05 1998 Geoffrey Noer - - * dir.cc: new file for directory-related functions, was - dirsearch.cc. - (mkdir, rmdir, writable_directory): move here from syscalls.cc, - writable_directory no longer static - * dirsearch.cc: delete file - * winsup.h: add proto for writable_directory. - * errno.cc: new file for errno-related functions, move errmap - struct here from syscalls.cc - (seterrno): move from syscalls.cc - (strerror): move from strerror.cc - * strerror.cc: delete file - * syscalls.cc: delete everything moved to any of the above files - * Makefile.in: adjustments for above - -Thu Apr 17 16:43:23 1998 Geoffrey Noer - - * termios.cc: add comments, add extern "C" in front of exported - calls, move debugging local functions to end of file - * winsup.h: remove fork_terminate proto for function that is no - longer with us. Add strccpy proto. - * spawn.cc (_spawnve): make static - (strccpy): remove in favor of identical function in exec.cc - * exec.cc (strccpy): no longer static - - patch from newsham@lava.net (Tim Newsham): - * select.cc (cygwin32_select): fix off by one error, stop - using memcpy to copy memory over itself - -Thu Apr 16 16:23:00 1998 Geoffrey Noer - - * net.cc: respace, put all fhandler_socket functions together - (getsockopt): fix case statement bug resulting in faulty strace - output - (setsockopt): ditto - * shared.cc: throughout, rename global h to cygwin_shared_h - * strerror.cc: make error global a local variable - * fhandler.h: add comments, add virtual function always_read_ready - to fhandler_serial which should return zero to allow non-blocking - serial I/O. - * Makefile.in: select.cc should depend on select.h - -Wed Apr 15 16:14:01 1998 Geoffrey Noer - - * select.h: new file, containing macros used by select.cc. - * select.cc: remove them from here, include select.h - -Wed Apr 15 15:23:55 1998 Geoffrey Noer - - * ntea.cc (NTReadEARaw): mark as static, don't check allow_ntea - since this is only accessed by functions that have already checked - it. - -Tue Apr 14 14:07:54 1998 Geoffrey Noer - - * cygwin.din: export truncate call - -Mon Apr 13 23:15:13 1998 Geoffrey Noer - - Throughout Cygwin32, rename *u for per_process data *user_data. - Likewise, rename *s for shared memory data *cygwin_shared. - Respace where necessary. - * registry.cc: minor respace - * registry.h: ditto - * net.cc: ditto - * fhandler.cc (fhandler_base::read): don't redeclare int len - * syslog.cc: add FIXME, reformatting, remove extern "C" around - whole file, add before exported functions - (syslog): rename second cp char pointer cp2 - (setlogmask): comment out unused function - -Mon Apr 13 17:55:43 1998 Geoffrey Noer - - * environ.cc (parse_options): add "ntea" setting to CYGWIN32 - env variable. Setting determines whether NTEA is used or not. - * ntea.cc: Add allow_ntea global which is inited to FALSE. - Now instead of immediately returning FALSE, make all - functions check allow_ntea variable and use or not use NTEA - based on its value. - * ps.cc (main): widen Win32_pid field by one to better handle - Win 95 pids. - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * shared.cc (shared_info::initialize): increase default - heap_chunk_size to 128 mb to get around the problem that - Cygwin32 still can't cope with a split heap properly. - -Wed Apr 8 18:04:07 1998 Geoffrey Noer - - * net.cc (cygwin32_bind, cygwin32_getsockname, cygwin32_listen, - cygwin32_shutdown): if should check sock, not s. - -Wed Apr 8 15:00:46 1998 Geoffrey Noer - - Eliminate warnings revealed by -Wshadow -Wall: - * console.cc (FakeReadFile): fix aggregate with partly bracketed - initializer (add missing brackets). - * tty.cc (fhandler_tty_slave::close): remove unused variable tty - (fhandler_tty_slave::dup): ditto - (fhandler_tty_slave::send_ioctl_request): ditto - -Wed Apr 8 03:04:11 1998 Geoffrey Noer - - Eliminate warnings revealed by -Wshadow -Wall: - * console.cc (FakeReadFile): change variable name index to - modifier_index. - (fhandler_console::read): remove second definition of flags - * dcrt0.cc (build_argv): rename s to start, e to end - (insert_files): reformat, add parens around assign used as truth - value, make i a DWORD, remove dup def of i. - * dlfcn.cc (set_dl_error): rename s to str - (checkAccess): rename to check_access - (checkPathAccess): rename to check_path_access - (getFullPathOfDll): rename to get_full_path_of_dll, don't - redeclare len - * dll_init.cc (DllList::detachDll): rename index to dll_index - * fork.cc (cygwin_fork_helper1): rename index to dll_index, - reformat slightly, rename res in dll load section to loadres, - don't redeclare rc two additional times - (dump_jmp_buf): rename s to sbuf - * grp.cc (initgroups): rename group arg to grp - * hinfo.cc (digits): rename s to str - (hinfo_vec::build_fhandler): rename first buf variable to - buf_info, the second to buff. - (hinfo_vec::linearize_fd_array): cast sizeof return to int, - declare i in for loop - (hinfo_vec::de_linearize_fd_array): declare i in for loop - * misc.cc (nice): rename pri to priority, index to curr - (cygname): rename s to str - (login): rename tty to currtty - (logout) put missing parens around arg to sizeof calls - * net.cc (DuplicateSocket): rename function to duplicate_socket, - rename s arg to sock - (fhandler_socket::fhandler_socket): rename s arg to sock - (socketpair): rename sin to sock_in - (cygwin32_rexec): rename passwd arg to password - * passwd.cc (parse): rename stat array to tmpbuf - * resource.cc (fill_rusage): rename creation to creation_time, - exit to exit_time, kernel to kernel_time, user to user_time - (getrusage): rename rusage arg to rusage_in - * sigproc.cc (proc_terminate): move i declaration outside of - loop, get rid of extra declaration - (getsem): rename s to str - (proc_strace): declare i at top of function, remove extra two - declarations of it later - * smallprint.c: include ctype.h for isalnum proto - (__small_vsprintf): put parens around assign used as truth value - * spawn.cc (spawn_guts): rename both s variables to str, remove - redeclarations of i - * strace.cc (mark): rename s arg to str - * syscalls.cc (chown): remove unused vars group, passwd - (access): rename s to st - (ctermid): rename s to str - * termios.cc (cfsetospeed, cfsetispeed): rename s to speed - * times.cc (times): rename creation to creation_time, - exit to exit_time, kernel to kernel_time, user to user_time - (time_t_to_filetime, timeval_to_filetime): rename time to time_in - * tty.cc (create_tty_master): rename utmp variable our_utmp - (fhandler_tty_master::init): rename ttynum arg ttynum_in - -Tue Apr 7 17:18:05 1998 Geoffrey Noer - - * syscalls.cc (seterrno): add FIXME - * path.cc (symlink_check_one): change comment wording - - patch from Tom Tromey (tromey@cygnus.com) - * syscalls.cc (access): Call SetErrorMode to turn off critical - errors dialog. - - patch from Mikey (jeffdb@netzone.com): - * fhandler.cc (fhandler_disk_file::open): under Win95, set - S_IXOTH|S_IXGRP|S_IXGRP if the first two bytes of a file contain - a '#!'. - (fhandler_disk_file::check_execable_p): consider shell scripts - execable - -Mon Apr 6 20:55:06 1998 Geoffrey Noer - - * include/sys/cygwin.h: add protos for cygwin32 path conversion - functions. - -Wed Apr 1 16:12:58 1998 Geoffrey Noer - - * {fhandler.cc, fhandler.h, hinfo.cc, console.cc}: Rename - fhandler_tty class to fhandler_serial - -Tue Mar 31 16:27:36 1998 Geoffrey Noer - - * ntea.cc: temporarily disable reading/writing NTEA information - due to the large penalty incurred on NT fat partitions. - -Fri Mar 27 13:35:30 1998 Geoffrey Noer - - * environ.cc (parse_options): change struct to union to avoid - references to uninitialized fields. - -Thu Mar 26 19:03:00 1998 Eric Bachalo - - * dcrt0.cc (insert_files): added this function to replace - -@file in the command line with the contents of the file - (dll_crt0_1): calls insert_files before building argv - -Wed Mar 25 15:25:26 1998 Geoffrey Noer - - And more: - * {fhandler.cc, fhandler.h, tty.cc, net.cc, console.cc}: make - ioctl calls' cmd arg unsigned, ditto for access arg of init calls. - * console.cc (fhandler_console::fillin_info): add parens around - assignment used as truth value. - (FakeReadFile): make copied_chars a size_t - (fhandler_console::read): make i in loop unsigned - * environ.cc (setenv): make l_value unsigned, add parens around - assignments used as truth values. - * exceptions.cc (call_handler): supposed to return an int and - wasn't at the end of control flow. Now returns 1 there. - * fhandler.h (~fhandler_base): destructor should be marked virtual - * misc.cc (login): add parens around assignment used as truth - value. - * net.cc: cast INVALID_SOCKET to int in comparisons - (fhandler_socket::ioctl): remove int cast to FIONBIO since cmd - is now unsigned - (get_win95_ifconf): add cast to signed vs unsigned int comparison. - * ntea.cc (NTReadEA): add cast to signed vs unsigned int - comparison. - * path.cc (getcwd_inner): make len a size_t - * pinfo.cc (cygwin32_winpid_to_pid): add comment - * select.cc (cygwin32_select): make wait_ret an int - * signal.cc (kill_worker): add parens around assignments used as - truth values. - * sigproc.cc (wait_sig): make rc a DWORD - (sig_send): add parens around assignment used as truth value. - * strace.cc: make inqueue global a static DWORD - * tty.cc (do_output): add cast to signed vs unsigned int - comparison. - (fhandler_pty_master::open): remove unused handle nh - -Tue Mar 24 18:03:59 1998 Geoffrey Noer - - More spring cleaning: - * net.cc: move LOAD macro definition out of winsock_init, - correction to make it valid ANSI C++. - * grp.cc (read_etc_group): pass default line directly to - add_grp_line call - -Mon Mar 23 19:21:00 1998 Geoffrey Noer - - patch from cgf@bbc.com (Christopher Faylor): - * spawn.cc (spawn_guts): Don't call close_all_files if a cygwin - process has been spawned. Otherwise, we close tty handles twice. - -Fri Mar 20 23:01:24 1998 Geoffrey Noer - - * pinfo.cc (pinfo_list::init): Initialize next_pid to PBASE. - (pinfo_list::operator []): Now index is given by pid mod size(). - (pinfo_list::allocate_pid): Allow more pid numbers than spaces in - the process table. Pids now can range from PBASE (1000) to - INT_MAX. At that point they wrap to 1000 again. For speed, use - modular arithmetic to map pids into table. - * winsup.h: move PBASE to pinfo.cc, rename next_pid_index to - next_pid - * utils/ps.cc (main): reorg of what's printed where, listing pid - first. - -Thu Mar 19 15:05:07 1998 Geoffrey Noer - - * winsup.h: Change section name in NO_COPY definition. We were - using a .data$nocopy section to avoid copying certain data on - fork. The linker used to include this between __data_start__ and - __data_end__, but that broke building the cygwin32 dll. The fix - is to rename the section ".data_cygwin_nocopy" and explictly - include it after __data_end__. - -Wed Mar 18 15:03:51 1998 Geoffrey Noer - - * tty.h: fix ttyslot proto; it returns an int - * glob.h: fix glob proto; it returns an int - -Mon Mar 16 16:16:40 1998 Geoffrey Noer - - * Makefile.in: stop installing the dll in the lib directory as - well as the bindir. - * environ.cc (parse_options): don't need to call malloc - -Mon Mar 16 11:56:23 1998 Geoffrey Noer - - patch from cgf@bbc.com (Christopher Faylor): - * tty.cc (fhandler_tty_slave::dup): Don't set flags to 0. Flags - have already been set in wrapper. - * net.cc: Rename `s' variable which shadows global `s'. - * termios.cc: ditto - * time.cc: ditto - -Tue Mar 10 15:54:04 1998 Geoffrey Noer - - * version.h: up CYGWIN_DLL_VERSION_MINOR - -Tue Mar 10 15:41:29 1998 Geoffrey Noer - - patch from cgf@bbc.com (Christopher Faylor): - * spawn.cc (spawn_guts): Make argument handling after `#! pgm' - handle spaces similarly to UNIX. Close "linearized" file handles - when a non-cygwin32 binary is executed or suffer hangs on exit. - Reorganize lpReserved2 buffer to avoid conflicts with Microsoft - usage which resulted in incorrect stdin/stdout operation with - programs compiled using MSVC. - * pinfo.cc (pinfo_init): Accommodate change to lpReserved2 - organization. - -Mon Mar 9 19:27:17 1998 Geoffrey Noer - - * syscalls.cc (_open): modify to take a variable number of - arguments to match newlib's fcntl.h. - * environ.cc (parse_options): rewrite struct known to conform - to ANSI standards. Can't statically initialize, so do so - dynamically at the beginning of the function instead. - - patch from jeffdb@netzone.com (Mikey): - * dcrt0.cc (build_argv, compute_argc): need to escape quotes - -Sat Feb 28 16:41:54 1998 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * fhandler.cc (fhandler_base::init): call set_flags based on - access arg. - * net.cc: include fcntl.h - (fhandler_socket::fhandler_socket): made sockets O_RDWR - -Thu Feb 26 23:41:54 1998 Geoffrey Noer - - Beta 19 release made. - -Sun Feb 22 23:46:31 1998 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * Makefile.in: Do not link cygwinb19.dll with libwsock32.a - * exceptions.cc: add proto for i_WSACleanup. - (sig_handle): call *i_WSACleanup if winsock was inited. - * hinfo.cc: add proto for i_getpeername. - (hinfo_vec::build_fhandler): call *i_getpeername if winsock - was inited - * net.cc: wsock32, i_wsockimports - new globals. Throughout - file, call winsock functions via indirect pointers. - (winsock_init): dynamically load wsock32.dll and resolve addresses - of exports. - (cygwin32_rcmd, cygwin32_rexec, cygwin32_rresvport): resolve - addresses of exports. - * select.cc: add protos for i___WSAFDIsSet, i_WSAGetLastError, - i_select, i_socket, i_closesocket. WINSOCK_FD_ISSET changed to - use indirect pointer. Direct winsock calls changed to indirect. - (cygwin32_select): initialize winsock before calling select in - degenerate case. - * winsup.h: remove protos for ScreenRows, ScreenCols, - ScreenGetCursor, ScreenSetCursor. - -Sun Feb 22 17:44:55 1998 Geoffrey Noer - - * environ.cc (parse_options): comment out -- no longer - compiles with egcs. Will rewrite/enable later. - -Sun Feb 22 13:49:10 1998 Geoffrey Noer - - * syscalls.h: remove protos for _open, _read, _write since - they are in newlib headers that are already included - * syscalls.cc (_read): return int, not ssize_t - (_write): ditto - -Sat Feb 21 14:21:17 1998 Geoffrey Noer - - * Makefile.in: rename dll to cygwindevo.dll - -Sat Feb 21 01:33:56 1998 Geoffrey Noer - - * cygwin.din: remove dup definition of endpwent - -Thu Feb 19 14:20:21 1998 Geoffrey Noer - - * include/cygwin32/cygwin_dll.h: Correct protection wrapper - -Tue Feb 17 20:21:24 1998 Geoffrey Noer - - * include/Windows32/Structures.h: tagBITMAPFILEHEADER should - be packed. - -Tue Feb 17 19:34:41 1998 Geoffrey Noer - - patch from cgf@bbc.com (Christopher Faylor): - * cygwin.din: export sigpause - * signal.cc (sigpause): New "compatibility interface" to - sigsuspend function. Used currently by inetutils. - -Tue Feb 17 11:43:27 1998 Ian Lance Taylor - - * tty.h (class tty): Add slave_opened field. - * tty.cc (fhandler_tty_master::init): Initialize slave_opened. - (do_output): Only return with EOF if the slave has been opened. - (fhandler_tty_slave::open): Set slave_opened. - (fhandler_pty_master::open): Initialize slave_opened. - - * tty.cc (fhandler_pty_master::read): Change type of n to DWORD. - If there are no characters to read, and the descriptor is in - nonblocking mode, just return EGAIN. - -Mon Feb 16 15:11:25 1998 Ian Lance Taylor - - * tty.h (class tty): Remove handle_pid and slave_handles fields. - (class tty_list): Add getcount method. - * tty.cc (tty::init): Initialize input_handle and output_handle. - (tty_list::free_tty): If we just freed the last reference to this - tty, close input_handle and output_handle. - (fhandler_tty_master::init): Don't initialize handle_pid and - slave_handles. - (do_output): Instead of just calling ReadFile, loop using - PeekNamedPipe and check whether the tty has been closed. Return 0 - on EOF and -1 on error. - (process_output): Only print debugging error message if error - occurs in do_output. - (fhandler_tty_slave::open): Always duplicate handles from master. - Never close handles in source. Don't change slave_handles. - (fhandler_tty_slave::close): Don't change slave_handles, and don't - close tty handles. - (fhandler_tty_slave::linearize): Call attach_tty. - (fhandler_tty_slave::de_linearize): Don't call attach_tty. - (fhandler_tty_slave::dup): Don't increment slave handles. - (fhandler_pty_master::open): Don't initialize handle_pid and - slave_handles. - (fhandler_pty_master::close): Don't check slave_handles, and don't - close tty handles. - (fhandler_pty_master::read): Handle EOF return value from - do_output. - (fhandler_pty_master::linearize): Call attach_tty. - (fhandler_pty_master::de_linearize): Don't call attach_tty. - - * fork.cc (cygwin_fork_helper1): Copy strace_mask from parent to - child. - -Thu Feb 12 20:33:57 1998 Geoffrey Noer - - patch from cgf@bbc.com (Christopher Faylor): - * utils/cygwin.cc: Modify -s option to use new strace_mask entry - in pinfo. Prepare for future ability to specify an strace file. - -Thu Feb 12 11:57:26 1998 Geoffrey Noer - - * grp.cc (read_etc_group): add a default /etc/group in memory - if /etc/group isn't found - (getgrnam): return NULL if requested group isn't found instead - of returning a default group - -Wed Feb 11 15:59:10 1998 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * strace.cc (strace_open): do not close u->strace_file if it - points to stderr. - * malloc.cc (malloc_init): do not check for application's malloc - in a forkee, this breaks memory coherency in a forkee and forker. - use_internal_malloc flag now copies on fork. - -Tue Feb 10 18:11:30 1998 Geoffrey Noer - - patch from cgf@bbc.com (Christopher Faylor) - Throughout sources, mark statics and globals as NO_COPY where - appropriate. - * fork.cc (cygwin_fork_helper1): Remove #if 0 around fork_copy of - cygwin data/bss. Remove __malloc_copy since it is no longer - necessary. - -Tue Feb 10 15:30:19 1998 Geoffrey Noer - - patch from cgf@bbc.com (Christopher Faylor) - * console.cc (fhandler_console::write): Implement xterm style - escape sequences for setting title in the console title bar. - * fhandler.h: Define constants for console title escape sequence. - -Tue Feb 10 14:16:17 1998 Geoffrey Noer - - * include/a.out.h: remove junk chars introduced by mailer - when this header was sent to us - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * libccrt0.cc: rename cygwin_attach_dll to cygwin32_attach_dll - - patch from cgf@bbc.com (Christopher Faylor): - * environ.cc: fix off by one problem - -Mon Feb 9 14:56:00 1998 Geoffrey Noer - - * Makefile.in: add registry.h to environ.o deps - -Mon Feb 9 14:42:24 1998 Ian Lance Taylor - - * Makefile.in (DLL_OFILES): Rename dllinit.o to dll_init.o. - - * tty.cc (fhandler_tty_slave::close): Don't close the tty handles - if the slave and the master are the same process. - - * path.cc (read_mounts): Change key parameter to reference, to - avoiding running the destructor. - -Mon Feb 9 13:53:50 1998 Geoffrey Noer - - patch from cgf@bbc.com (Christopher Faylor): - Moves all environment manipulation into environ.cc. - Switches to CYGWIN32 for settings: - set CYGWIN32=[no]title [no]strip_title [no]binmode [no]glob - strace=mask:cache,file [no]tty - (set STRACE=whatever is still honored). - Propagates tty settings to all subprocesses regardless of - unsetting of environment variable. - Moves strace mask into pinfo structure for easier future - manipulation by external program. Moves strace_file into the - vacated position for automatic use in forked processes. - Propagates old title to execed processes so that they can - correctly restore the correct title when they exit. - * console.cc: Use PID_USETTY setting in process_state so that - tty state can be easily inherited. - (set_console_title): New function to set console title. - * syscalls.cc: Use PID_USETTY setting in process_state so that - tty state can be easily inherited. - * tty.cc: Ditto. - * hinfo.cc: Ditto. - (hinfo_vec::de_linearize_fd_array): Return last location in buffer - for further potential processing. - * dcrt0.cc: Add global variables for control of glob and title, - set by environ_init. Mark some variables as NO_COPY. - Remove routines and variables for dealing with environment. - (dll_crt0_1): Move environment initialization into separate - function. Honor 'noglob' CYGWIN32 setting. - * environ.cc (environ_init): New function to initialize the - environ table. Also scans for CYGWIN32 environment variable, - setting appropriate values. - (ucenv): New function. Upper cases an environment variable. - (parse_options): New function. Parse CYGWIN_* environment - variable. - (posify): New function. Convert a Windows env path spec to - cygwin. - (env_sort): New function. Sort an environ block. - (winenv): New function. Returns a windows style environment - block. - * fhandler.cc (fhandler_base::read): Reflect change to location of - strace_mask. - * fork.cc (cygwin_fork_helper1): Remove save/restore of some - settings since this is automatic now with new dll data copy. Save - PID_USETTY setting in child process_state. - * strace.h: Cosmetic change. - * pinfo.cc (pinfo_init): Call environ_init here since it may - affect further processing in this function. Use old console title - from "parent" process if execed process. Reflect change to - location of strace_mask. - * spawn.cc (spawn_guts): Remove environment manipulation code. - Use new winenv function call instead. Save old title in block of - memory copied to newly execed process if title is being displayed. - * strace.cc: Changes to reflect new location for strace_mask and - strace_file. These are now automatically inherited on fork. - * winsup.h: Move strace_mask into pinfo to allow possible - manipulation by other processes. Put u->strace_file in uptr - structure so that it will be automatically duplicated on fork, - removing the necessity of initializing strace in a forked - process. Add functions/variables associated with environment - manipulation and console title setting. - -Mon Feb 9 03:06:56 1998 Geoffrey Noer - - Extensive reformatting in new files from next patch. - Rename dllinit.h file to dll_init.h and likewise for dll_init.cc. - Rename cygwin_detach_dll to cygwin32_detach_dll throughout. - Similarly, rename cygwin_attach_dll and _cygwin_dll_entry. - And rename sanityAndSyncCheck to check_sanity_and_sync. - Also: - * dll_init.h: don't include winsup.h - * dll_init.cc: include winsup.h here instead - * dlfcn.cc: include winsup.h, don't include windows.h - * cygwin.din: rename cygwin_detach_dll to cygwin32_detach_dll. - - patch from giac@dalim.de (Philippe Giacinti): - Copy data areas of cygwin-compiled dlls on fork(), - implement dlopen/dlsym/dlclose/dlerror calls. - * Makefile.in: add dlfcn.o and dllinit.o to DLL_OFILES, add - dllinit.h dependencies - * cygwin.din: dll_dllcrt0, cygwin_detach_dll, dlopen, dlclose, - dlsym, dlerror, dlfork -- new exports. - * dcrt0.cc: include dllinit.h, mark u pointer as NO_COPY. - (sanityAndSyncCheck): new, code moved from dll_crt0_1. - Initialize all linked dlls before calling main(). - * dlfcn.cc: new file. - * dllinit.cc: new file. - * dllinit.h: new file. - * exceptions.cc: mark some variables with NO_COPY. - * fork.cc: include dllinit.h; declare cygwin.dll data/bss - start/end. - (cygwin_fork_helper1): copy data/bss of cygwin.dll itself to child - process (the code is disabled now); copy data areas of - linked/loaded dlls (if any); free loaded dll list on cleanup. - * include/cygwin32/cygwin_dll.h: new file. - * include/dlfcn.h: new file. - * libccrt0.cc (cygwin_crt0_common): new, code derived from - cygwin_crt0, MainFunc parameter added. - (cygwin_crt0): call cygwin_crt0_common. - (cygwin_attach_dll): new. - * shared.cc: mark some data as NO_COPY - * strace.cc: mark some data as NO_COPY - * winsup.h: add dll_dllcrt0 proto, NO_COPY macro. - -Sun Feb 8 17:51:26 1998 Geoffrey Noer - - * getopt.c: new. Import Berkeley getopt code modified for use - in Cygnus' kerberos implementation (including the writing of - getopt_long by Chris Provenzano (proven@cygnus.com)) then modified - a bit more to get it working in Cygwin32. Although we were - going to remove getopt, it appears that too many programs would - need fixing to remove it completely. Whether getopt should be - included in Cygwin32 should be decided at a later time. - * include/getopt.h: new. Import Berkeley getopt.h. - * Makefile.in: add getopt.o to LIBCOS - * utils/Makefile.in: remove include of ../../include since - getopt.h is now in winsup/include, also revert recent change - of addition of GETOPT_OBJS. - -Fri Feb 6 16:28:19 1998 Geoffrey Noer - - * cygwin.din: remove set_new_handler and cygwin_set_attributes - exports - * version.h: up major version number - * Makefile.in: rename dll to cygwinb19.dll - * syscalls.cc (cygwin_set_attributes): axe - -Thu Feb 5 18:28:37 1998 Geoffrey Noer - - * include/Windows32/Functions.h: add protos for - DdeCmpStringHandles and DdeCreateDataHandle - * Makefile.in: stop including ../libiberty/getopt* since - we aren't exporting or using them - * utils/Makefile.in: add new variable for libiberty getopt objs - which is linked in for cygwin.exe - -Thu Feb 5 17:59:12 1998 Geoffrey Noer - - syscalls.cc: move ppc dll_entry asm code to... - dcrt0.cc: ...here - - Import new globbing code from NetBSD 1.3 - * glob: delete subdirectory - * glob.c: new file - * glob.h: new file - * Makefile.in: remove glob from submakes, remove glob/libglob.a - from DLL_IMPORTS, fix dcrt0 glob.h dependency - * configure.in: don't configure glob subdirectory - * configure: regenerate - * dcrt0.cc: include glob.h, not glob/glob.h. - (globify): don't call glob with GLOB_NOESCAPE which isn't a valid - flag with this glob - -Wed Feb 4 16:14:13 1998 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - Allow system administrator to enter into the HKLM registry tree - a predefined mount table inherittable by all cygwin users. The - predefined mounts are non-mandatory so the user's mount table has - a higher priority than the default one. Cygwin reads HKLM tree - in read-only mode. - * path.cc (read_mounts): new, code derived from - mount_info::from_registry(). - (mount_info::from_registry): call read_mounts from user's table, - then from system-wide mount table. - * registry.cc (reg_session::reg_session): key and access arguments - added. - (reg_key::init): access argument added. - (reg_key::reg_key): access argument added. - * registry.h (class reg_key): init prototype changed, default - argument of reg_key added. - (class reg_session): default arguments of constructor added. - -Wed Feb 4 15:38:59 1998 Geoffrey Noer - - * include/a.out.h: new coff header file - -Wed Feb 4 01:55:18 1998 Geoffrey Noer - - * uinfo.cc: define DEFAULT_UID/GID here - * winsup.h: removed DEFAULT_UID/GID defs and unused - set_console_title proto. Did some major reorganizing, - and a little reformatting, commenting. - -Tue Feb 3 23:59:23 1998 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - Replace u->self and this_procinfo () with new `myself' pointer - wherever appropriate. Also replace get_pid() calls with a - simple ->pid reference. - -Mon Feb 2 12:34:49 1998 Geoffrey Noer - - patch from sos@prospect.com.ru (Sergey Okhapkin): - * console.cc (FakeReadFile): limit bytes to read to 30000 due to - Win NT 4.0 SP3 bug. Kill foreground process group with SIGWINCH - on console buffer size change if tty support enabled. - * include/sys/termios.h: define more constants. - * tty.cc (fhandler_pty_master::ioctl): kill foreground process - group with SIGWINCH on window resizing. - -Mon Feb 2 12:14:49 1998 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * dcrt0.cc (dll_crt0_1): Initialize u->self here, early in a - forked process so the correct pid is used in strace output and so - signals do not end up being erroneously sent to the parent. - * exceptions.cc: Make a global variable static. Some minor - optimizations. - (call_handler): Make sure that the signal mask is restored when - sig_dispatch mutex is unavailable. - Reorder asm statements to prevent clobbering of flags register by - preceding ors or risk random inexplicable behavior when returning - from a signal handler. - * fork.cc (cygwin_fork_helper1): Put setjmp restore in child's - pinfo. Have the child figure out its pid earlier in the - initialization process. Don't print a "child failed" error if the - child failed during initialization due to a CTRL-C. This is still - not quite right (see comment). - * sigproc.cc (sig_send): Remove unlock/lock_pinfo or suffer - consistent hangs in zsh. Make {allow,block}_sig_dispatch globally - available. - (wait_sig): Fix problem where blocked signals would still be - processed if queued. Add debugging SIGNOQUEUE conditional to turn - off signal queueing, making cygwin more like traditional UNIX. - * sigproc.h: Add {allow,block}_sig_dispatch functions. - -Mon Jan 26 17:33:57 1998 Geoffrey Noer - - * path.cc (mount_info::init): don't hardcode C: as the default - slash mount. Instead, use the drive letter that the OS is loaded - on. - -Mon Jan 26 13:33:57 1998 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * fork.cc (cygwin_fork_helper): Move setting PID_INITIALIZING - process_state here to avoid erroneously setting it permanently - via proc_register(). - * pinfo.cc (pinfo_init): Delay notifying "parent" when execing - until this process is ready to receive signals or risk a race - condition if exec parent calls sigproc_terminate prior to - the child exec. - * sigproc.cc (proc_subproc): Don't set PID_INITIALIZING here. - It is too late in the process creation. - (sig_send): Reset sigsuspend mutex prior to use to avoid a race. - (wait_sig): Create sigsuspend mutex as an auto reset to attempt - to avoid a race condition. Notify parent that this process is - ready if we were execed (code moved from pinfo_init). Change - PulseEvents to SetEvents to avoid races - * spawn.cc (spawn_guts): Move setting PID_INITIALIZING - process_state here to help avoid race. - -Fri Jan 23 12:31:37 1998 Ian Lance Taylor - - * malloc.cc (malloc_critical_section): New static variable. - (malloc_init): New function. - (__malloc_lock, __malloc_unlock): New functions. - * winsup.h (malloc_init): Declare. - * heap.cc (heap_init): Call malloc_init. - -Thu Jan 22 18:46:40 1998 Ian Lance Taylor - - * tty.h (class tty): Change slave_handles to int. - * tty.cc (fhandler_tty_slave::open): Check for invalid tty - handles. If this is the first slave, set slave_handles to 2; - otherwise, increment slave_handles. - (fhandler_tty_slave::close): Only close the tty handles if the - slave_handles field drops to 1. - (fhandler_tty_slave::write): Add a debugging message if WriteFile - fails. - (fhandler_tty_slave::dup): Set ttynum of new fhandler. Increment - slave_handles if appropriate. - (fhandler_pty_master::close): Only close the tty handles if the - tty is no longer allocated. - - * tty.h (class tty): Add handle_pid and slave_handles fields. - * tty.cc (attach_tty): Call connect_tty even if use_tty is not - set. - (detach_tty): Don't check use_tty. - (fhandler_tty_master::init): Initialize handle_pid and - slave_handles of tty. - (do_input): Treat \r as end of line character. - (do_output): Only set output_done_event if it is not NULL. - (fhandler_tty_slave::open): Don't worry if we can't open - output_done_event. Check slave_handles field of tty to decide - from where to duplicate the handles. Call detach_tty on error. - If we are now the owner of the slave handles, mark the tty - appropriately. - (fhandler_tty_slave::close): Only close output_done_event if it is - not NULL. Check for errors from CloseHandle. Close the tty - handles if we own them. - (fhandler_tty_slave::write): Only wait for output_done_event if it - is not NULL. - (fhandler_tty_slave::read): If nobody owns the tty, return EOF. - (fhandler_tty_slave::dup): Attach the tty. Don't duplicate - output_done_event if it is NULL. Detach the tty on error. - (fhandler_pty_master::open): Initialize handle_pid and - slave_handles of tty. Don't create output_done_event. - (fhandler_pty_master::close): Only close output_done_event if it - is not NULL. Check for errors from CloseHandle. Only close the - tty handles if we own them. - (fhandler_pty_master::read): Only set output_done_event if it is - not NULL. - * hinfo.cc (de_linearize_fd_array): Don't set use_tty just because - we find a tty to delinearize. - -Wed Jan 21 21:58:27 1998 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * sigproc.cc: Changes in wait_sig/sig_send semaphore/event - signaling to attempt to eliminate races. - -Tue Jan 20 16:11:05 1998 Geoffrey Noer - - Remove last remnants of the mixed case handling support. - * path.cc (path_conv::path_conv): remove mixed_p init - (mount_info::from_registry): don't check for fmixed - (mount_info::to_registry): ditto - (mount_item::getmntent): when setting ret.mnt_opts, only consider - text vs binary flag - (mount_item::init): remove init of mixed - * path.h: remove mixed_p, mixed from path_conv class. Remove - unmixedcaseify proto. - * include/sys/mount.h: comment out MOUNT_MIXED define, protect - header against multiple inclusion - - A little header file cleanup. Mostly to protect headers against - multiple inclusion. Some aren't strictly speaking necessary but... - * include/sys/cygwin.h: protect header against multiple inclusion - * include/sys/smallprint.h: ditto, also add cplusplus wrapper - * include/sys/strace.h: comment last endif - * include/cygwin32/in.h: change _LINUX_IN_H protect defines - to _CYGWIN32_IN_H - * include/arpa/inet.h: protect header against multiple inclusion - * include/asm/types.h: ditto - * include/net/if.h: ditto - * include/netinet/ip.h: ditto - * include/netinet/ip_icmp.h: ditto - * include/netinet/in.h: ditto, remove commented out real header - file - * include/fcntl.h: protect header against multiple inclusion - * include/memory.h: ditto - * include/mntent.h: ditto - * include/strings.h: ditto - * include/syslog.h: ditto - * include/termio.h: ditto - -Tue Jan 20 12:51:59 1998 Ian Lance Taylor - - * strace.cc (strace_stderr): New static variable. - (strace_init): Set strace_stderr. - (system_printf): If not strace_stderr, use debug_printf to put the - message in a trace file. - - * fhandler.h (fhandler_pty_master): Add neednl_ field. - * tty.h (RESTART_OUTPUT_EVENT): Change to be different from - IOCTL_DONE_EVENT. - * tty.cc (fhandler_tty_master::init): Initialize neednl_. - (do_output): Handle a length of one by using neednl_ to record an - expansion of \n to \r\n which doesn't fit. Never expand \r to - \r\n. Correct order of \r\n. - (fhandler_tty_slave::open): Improve error handling. Use - DUPLICATE_CLOSE_SOURCE to close the pipes in the master process. - (fhandler_tty_slave::dup): Duplicate the handles, rather than - calling fhandler_tty_slave::open. - (fhandler_pty_master::open): Initialize neednl_. - (fhandler_pty_master::read): Return EOF for ERROR_BROKEN_PIPE, - rather than error. Set errno correctly. - * hinfo.cc (digits): New static function. - (build_fhandler): Always accept /dev/ptmx and /dev/ttyDDD, even if - use_tty is not set. use_tty now only controls the interpretation - of /dev/tty. - -Mon Jan 19 14:49:45 1998 Geoffrey Noer - - * sigproc.cc (sig_send): lock_pinfo_for_update during this - function - -Fri Jan 16 18:09:59 1998 Geoffrey Noer - - * sigproc.cc (sigproc_init): if we can't create a signal - thread or can't create sync_proc_subproc mutex, fail with - an api_fatal call rather than just returning - -Fri Jan 16 18:08:49 1998 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - Changed signal handling to use one semaphore and one shared - memory array which is manipulated via Interlocked*() functions. - * exceptions.cc (lock_cs): Comment. Report on error. - (unlock_cs): Add debugging statement. - (sig_dispatch_pending): Remove obsolete function. - (set_process_mask): Adapt to new signal method. - (call_handler): Clear wait()ing threads here while main thread is - suspended to avoid timing screwups. Avoid calling the handler if - can't get dispatch mutex (code moved from sig_handle). Return - status of acquiring the sig_dispatch mutex. - (sighandle): Adapt to new signal method. Reorganize to *always* - honor sig_dispatch mutex or suffer deadlock on fatal signals when - someone else has the mutex and we're attempting to cleanup. - (events_init): Reflect change in cygname() arguments. - * fork.cc (stack_dummy): New function. Returns address of - argument to determine bounds for eventual stack copy. - (cygwin_fork_helper1): Call subproc_init to start up subproc - thread if it is not alreay started. Ensure that signals are - blocked while forked process is initializing. Change method of - calculation for lower stack bounds to slightly more foolproof - method. Preserve some global settings in forked process. - * misc.cc (cygname): Remove an unused argument. - * pinfo.cc (pinfo_list::allocate_pid): Add a useful debugging - statement. - * shared.cc (open_shared_file_map): Reflect change in cygname() - arguments. - * signal.cc (kill_pgrp): Avoid killing dead processes. Don't - kill processes in my pgrp if not also in my ctty. - (sigaction): Adapt to new signal method. - (sigpending): Adapt to new signal method. - * sigproc.cc: Many changes to adapt to new signal method. Also - delay waits for thread initialization until the thread needs to be - contacted. - * sigproc.h: Ditto. - * spawn.cc (spawn_guts): Fix potential off-by-one error(?) in - transcribing the argument list and add paranoid code to detect - future overruns. Change priority to highest so that waiting - process will clear out quickly. - (_spawnve): Call subproc_init() to start up subproc thread if is - not already started. - * strace.cc (strace_printf): Increase size of internal buffer so - that long argument lists printed from spawn_guts do not overrun it - so easily. - * wait.cc (wait4): Set status flag to -1 prior to exit. This will - cause previous wait that was interrupted by a signal which - dispatched to another wait to return the correct error value. - * winsup.h (pinfo): Add _sigtodo array for new signal method. - Remove obsolete field. Reflect change in cygname arguments. - -Thu Jan 15 13:07:07 1998 Ian Lance Taylor - - * syscalls.cc (mkdir): Don't permit the directory to be created if - the parent directory is not writable. - - * syscalls.cc (fchmod): Call chmod with the path name, rather than - just returning zero. - - * syscalls.cc (writable_directory): New static function. - (_unlink): Don't permit the file to be removed if the directory is - not writable. - (rename): Don't permit the rename if either the source or - destination directory is not writable. - - * syscalls.cc (chown): Set username and groupname lengths to UNLEN - + 1, rather than 100. If getpwuid fails, try to look up the real - user name to see if it is the same. Don't report an error if - there is no security mapping. - -Wed Jan 14 15:34:20 1998 Ian Lance Taylor - - * syscalls.cc (setegid): New function which just returns ENOSYS. - (chroot): Likewise. - * cygwin.din: Export setegid, _setegid, chroot, and _chroot. - - * syscalls.cc (setmode): Rename from _setmode. Change to return - the old mode. Remove old setmode function. - * cygwin.din: Make _setmode an alias for setmode. - -Wed Jan 14 14:46:00 1998 Geoffrey Noer - - * Makefile.in: don't strip cygwin.dll by default - * winsup.h: minor reformatting, removed/reworded some comments - -Mon Jan 12 13:53:03 1998 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - Speed up cygwin pid calculation by staying in the range - 1000 through (1000 + PSIZE - 1). - * pinfo.cc (pinfo_list::init): Change to reflect new pid - calculation method. - (pinfo_list::operator []): Ditto. - (pinfo_list::allocate_pid): Ditto. - * winsup.h (pinfo): Move pid and ppid into non-zeroed region since - they are always set by allocate_pid. - (pinfo_list): Change pid_base to next_pid_index to reflect new pid - calculation method. - (PBASE): New constant for new pid calcuation method. - -Sat Jan 10 12:06:38 1998 Geoffrey Noer - - * syscalls.cc (process_deletion_queue): remove wrapper function - (close_all_files): call s->delqueue.process_queue instead of - going through wrapper. - * fhandler.cc (fhandler_base::close): call - s->delqueue.process_queue instead of using above wrapper. - * winsup.h: remove process_deletion_queue proto - * delqueue.h: up MAX_DELQUEUES_PENDING to 100 for now. Rename - v to dqueue for clarity. - * delqueue.cc: v renamed to dqueue throughout. Add FIXME - describing why this whole delqueue system needs rewriting. - -Fri Jan 9 13:18:44 1998 Geoffrey Noer - - Remove some historical baggage: - * syscalls.cc (cygwin_set_attributes): remove commented-out code, - add FIXME since this function should go away next time an - incompatible change to cygwin.din is made. Stop including - include/sys/cygwin.h. - * include/sys/cygwin.h: remove cygwin_set_attributes proto. - Remove CYGWIN_FMODE_ALL_BINARY define. - * hinfo (hinfo_vec::init_std_file_from_handle): remove old - commented-out code - * path.cc (unmixedcaseify): delete commented-out function - (mixedcaseify): ditto - * strerror.cc (strerror): delete commented-out code section - -Tue Jan 6 18:51:40 1998 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - Conform to POSIX method for sending SIGHUP to stopped processes. - * dcrt0.cc (do_exit): Use new kill_pgrp function to kill orphaned - children on group leader exit iff the children are stopped (per - POSIX). - * signal.cc (kill_worker): Negative signal now means to send - a SIGCONT after the signal, to wake up the target process. - (_kill): Break out pgrp handling into separate function. - (kill_pgrp): New function pulled from _kill to send signals - to processes in a given pgrp. - -Tue Jan 6 14:37:43 1998 Geoffrey Noer - - patch from cgf@bbc.com (Chris Faylor): - * fhandler.cc (fhandler_base::open): include - FILE_FLAG_BACKUP_SEMANTICS in file_attributes when file is - a directory. Allows opening of directory as a file. Allows - use of handle to perform some operations on both directories and - files. - (fhandler_base::fstat): Loop when attempting to get volume serial - number. Works around an apparent Windows NT 3.51 bug. - * times.cc (utimes): use FILE_FLAG_BACKUP_SEMANTICS flag - to allow accessing directory times (may only work under NT; - until now it didn't work under either OS). - * winsup.h: Add O_DIROPEN constant. - -Mon Jan 5 19:18:01 1998 Geoffrey Noer - - * Makefile.in: make winsup.h depend on winsup.h in accordance - with below - - patch from cgf@bbc.com (Chris Faylor): - * {*.cc, *.h}: Remove include files already present in winsup.h. - Change empty function parameter lists to (void) where appropriate. - - * fork.cc: Clean up include files. Minor change to CreateProcess - parameter list. - * signal.cc: Remove ifdef'ed stuff. - * smallprint.c: Add a necessary include file. - * winsup.h: Add a common include file. Add a function declaration - for kill_pgrp. - -Mon Jan 5 18:30:37 1998 Geoffrey Noer - - Fix spoofing of directory inodes. - * syscalls.cc (hash_path_name): instead of initializing the - hash to zero, take the value of the initial hash as a new - argument. - (_stat_worker): fix up hash_path_name reference in light of above - * dirsearch.cc (opendir): initialize dir->__d_dirhash to the - hash of the full directory name so readdir can make use of it. - (readdir): compute d_ino by combining the directory hash - calculated by opendir with the hash of the filename. - * fhandler.cc: fix up hash_path_name reference in light of above - - * winsup.h: remove unnecessary protos for getkey, kbhit. Adjust - hash_path_name proto. diff --git a/winsup/cygwin/ChangeLog-1999 b/winsup/cygwin/ChangeLog-1999 deleted file mode 100644 index f2da41f51..000000000 --- a/winsup/cygwin/ChangeLog-1999 +++ /dev/null @@ -1,3562 +0,0 @@ -Sat Dec 25 12:46:25 1999 Christopher Faylor - - * dlfcn.cc (dlsym): Use correct HANDLE type for GetProcAddress. - (dlclose): Ditto for FreeLibrary. - * fhandler_windows.cc (fhandler_windows::set_close_on_exec): Properly - coerce arguments to set_inheritance. - (fhandler_windows::fixup_after_fork): Ditto for fork_fixup. - * libcmain.cc (main): Simplify. - * select.cc (peek_windows): Properly coerce argument to PeekMessage. - -Sat Dec 25 12:30:25 1999 Christopher Faylor - - * Makefile.in: Eliminate unneeded .y SUFFIX. - * dcrt0.cc (__api_fatal): Make "C". - (do_global_ctors): Make __stdcall. - (getprogname): Ditto. - (insert_file): Ditto. - (globify): Ditto. - (build_argv): Ditto. - (do_exit): Ditto. - * debug.cc (regthread): Ditto. - (makethread): Ditto. - (threadname): Ditto. - (find_handle): Ditto. - (handle_list): Ditto. - (add_handle): Ditto. - * debug.h: Reflect changes to __stdcall. - * shared.h: Ditto. - * winsup.h: Ditto. - -Sat Dec 25 12:09:10 1999 Kazuhiro Fujieda - - * path.cc (symlink): Don't return error if target is a symlink to a - nonexistent file. - -1999-12-23 DJ Delorie - - * dcrt0.cc (globify): Properly handle embedded tildes in variable - names. Treat a c:\foo style path spec as "special", i.e., don't - interpret the backslashes as quoting characters. - -Fri Dec 17 10:49:13 1999 Christopher Faylor - - * path.cc (symlink): Return error if the target exists. - -Thu Dec 16 22:36:45 1999 Christopher Faylor - - * path.cc: Change method for accessing com in windows_device_names to - allow > 2 com ports. - -Thu Dec 16 00:49:30 1999 Christopher Faylor - - * Makefile.in: Only build winver.o and version.o when required. - -Sat Dec 11 11:06:45 1999 Corinna Vinschen - - * path.cc (path_conv::path_conv): Ensure that a trailing slash is added - to "x:" specifications. - -Fri Dec 10 20:22:41 1999 Christopher Faylor - - * debug.cc (WFSO): Make __stdcall. - (WFMO): Ditto. - * debug.h: Reflect above changes. - * exceptions.cc (sig_set_errno): Set errno to be in effect after a - signal handler. - (handle_sigsuspend): Use set_sig_errno to ensure that the correct errno - is set after a signal handler. - (interrupt_now): Accommodate default errno field in stack. - (intterupt_on_return): Ditto. - (sigreturn): Pop, test, and possibly restore saved errno on return from - signal handler. - * fhandler_console.cc (fhandler_console::read): Set errno to be in - effect after a signal handler. - * fhandler_serial.cc (fhandler_serial::raw_read): Ditto. - * select.cc (cygwin_select): Ditto. - (select_stuff:wait): Ditto. - (peek_serial): Ditto. - * syscalls.cc (_read): Ditto. - * wait.cc (wait4): Ditto. - * winsup.h (signal_dispatch): Add "saved_errno" field. - -Thu Dec 9 23:35:45 1999 Christopher Faylor - - * debug.cc (threadname_init): Use new_muto macro to set up a static - buffer for a muto. - (debug_init): Ditto. - (WFSO): Reinstate wrapper for WaitForSingleObject. - (WFMO): Reinstate wrapper for WaitForMultipleObject. - * debug.h: Declare the above two wrappers. - * exceptions.cc (events_init): Use new_muto macro to set up a static - buffer for a muto. - * sigproc.cc (sigproc_init): Ditto. - * sync.cc (muto::acquire): Don't bump waiters if we already own the - muto. - * sync.h (new): New operator. - (delete): Ditto. - (new_muto): New macro. - -Dec 08 23:50:00 1999 Corinna Vinschen - - * security.cc (get_nt_attribute): Add debug output. Correct behaviour - in case of NULL ACL. - * syscalls.cc (stat_worker): Allow remote drives to get stat info from - fh.fstat(). - * include/winnt.h: Add defines for W2K ACL control flags. - * include/cygwin/socket.h: Add missing PF_NETBIOS. - -Wed Dec 8 23:06:07 1999 Christopher Faylor - - * Makefile.in: Ensure that winver.o is a dependency for building the - dll. - * mkvers.sh: Attempt to call windres in a fashion that accommodates - older and newer versions. - * winver.c: Reorganize slightly to accommodate older versions of - windres. - * fhandler.cc (fhandler_disk_file::fstat): Avoid using Windows "inodes" - on disks which do not support them. - -Tue Dec 7 21:15:11 1999 Christopher Faylor - - * dll_init.cc (DllList::forkeeLoadDlls): Reverse order of Free/Load - Library calls to ensure that references are resolved. - * path.cc (mount_info::conv_to_win32_path): Ensure that returned - windows paths are always normalized regardless of whether they were in - windows format to begin with. - -Tue Dec 7 08:48:22 1999 Christopher Faylor - - * environ.cc (parse_options): Properly detect end of known array. - -Mon Dec 6 22:32:04 1999 Christopher Faylor - - * mkvers.sh: Generate winver.o from winver.rc and various other things - from include/cygwin/version.h - * winver.rc: New file (adapted from donation by Mumit Khan - ). - * configure.in: Find windres. - * configure: Regenerate. - * Makefile.in: Link winver.o into cygwin1.dll. - -Mon Dec 6 13:04:47 1999 Mumit Khan - - * init.cc (dynamically_loaded): New global variable. - (dll_entry): Use. - * winsup.h (dynamically_loaded): Declare. - * dcrt0.cc (do_global_ctors): Likewise. - (set_os_type): Make static again. - (dll_crt0_1): Handle dynamically_loaded case. - * dll_init.cc (dll_dllcrt0_1): Delete. - (dll_dllcrt0): Handle dynamically_loaded case. - (dll_noncygwin_dllcrt0): Mark obsolescent. - * libccrt0.cc (cygwin_attach_noncygwin_dll): Delete. - * pinfo.cc (pinfo_init): Don't inherit parent fds if dynamically - loaded. - * include/cygwin/cygwin_dll.h (cygwin_attach_noncygwin_dll): Delete - prototype. - (_cygwin_noncygwin_dll_entry): Mark obsolescent. - -Mon Dec 6 11:09:41 1999 Christopher Faylor - - * configure.in: Make threadsafe the default. - * configure: regenerate. - * utils/strace.cc: Fix a compiler warning. - -Sun Dec 5 15:49:43 1999 Christopher Faylor - - * environ.cc (parse_options): Reinstate unions in parse_things, to - save space. - -Fri Dec 3 22:52:05 1999 Christopher Faylor - - Implement new signal-handling scheme which ensures that a program will - not be interrupted while in a system or cygwin DLL. - * Makefile.in: Add sync.o and dll_ofiles target. - * dcrt0.cc (alloc_stack_hard_way): Add more defensive code to ensure - that the stack is really grown. - (alloc_stack): Ditto. - (dll_crt0_1): Reorganize some initialization routines to ensure that - they occur after the heap has been initialized. - * debug.cc: Use muto for locks. Eliminate attempts to avoid being - interrupted by signals. - (threadname_init): New function. - (debug_init): Ditto. - * debug.h: Declare debug_init and threadname_init. - * exceptions.cc (stack_info::stack_info): Don't check for previous use - of get(). - (handle_sigsuspend): Simply using new signal-handling scheme. - (interruptible): New function. Determines if PC should be interrupted. - (interrupt_now): New function. Causes immediate signal dispatch. - (interrupt_on_return): New function. Causes signal dispatch on return - from cygwin or system routine. - (call_handler): Simplify to use new signal-handling scheme. - (set_process_mask): Use mask_sync muto to synchronize setting of - process signal mask. - (sig_handle_tty_stop): New function. Called when have to stop process - now. - (sig_handle): Simplify to use new signal-handling scheme. - (set_process_mask): Ditto. - (events_init): Allocate mask_sync muto. - (unused_sig_wrapper): New function. Encapsulates assembly language - signal handling support. - * fhandler.h (class select_stuff): Accommodate new signal-handling - scheme. - * fhandler_console.cc (fhandler_console): Simplify to use new - signal-handling scheme. - * fhandler_serial.cc (fhandler_serial::raw_read): Ditto. - * fhandler_termios.cc (bg_check): Ditto. - * fhandler_tty.cc (process_input): Ditto. - (fhandler_tty_slave::open): Ditto. - (fhandler_tty_slave::send_ioctl_request): Ditto. - * fork.cc: Ditto. - * path.cc (chdir): Ditto. - * select.cc: Ditto, throughout. - * shared.h: Eliminate unneeded signal enum. - * signal.cc (signal): Simplify to use new signal-handling scheme. - (sleep): Ditto. - (usleep): Ditto. - (sigprocmask): Ditto. - (sigaction): Ditto. - (pause): Use handle_sigsuspend to pause for signal. - * sigproc.cc: Change signal_arrived handle to global_signal_arrived - class. Change various mutex handles to mutos. - (proc_subproc): Simplify to use new signal-handling scheme. Use muto - for locking. - (get_proc_lock): Ditto. - (proc_terminate): Ditto. - (sig_dispatch_pending): Make a "C" function. Return status of pending - signals. - (sigproc_init): Initialize global_signal_arrived. Simplify to use new - signal-handling scheme. Initialize sync_proc_subproc muto. - (sig_send): Eliminate __SIGSUSPEND considerations. Simplify to use new - signal-handling scheme. - (__allow_sig_dispatch): Delete. - (__block_sig_dispatch): Delete. - (__get_signal_mutex): Delete. - (__release_signal_mutex): Delete. - (__have_signal_mutex): Delete. - (wait_sig): Simplify to use new signal-handling scheme. - * sigproc.h: Implement signal_arrived classes. - * smallprint.c (__small_vsprintf): Avoid printing a leading '*' in - function name with %F format. - * spawn.cc (spawn_guts): Simplify to use new signal-handling scheme. - (iscmd): Don't consider a filename to be a "command" unless it contains - a ':'. - * syscalls.cc (_read): Ditto. - (_open): Ditto. - (_close): Ditto. - * termios.cc (tcsendbreak): Ditto. - (tcdrain): Ditto. - (tcflush): Ditto. - (tcflow): Ditto. - (tcsetattr): Ditto. - (tcgetattr): Ditto. - * winsup.h: Reorganize include files. Add preliminary __sig_protect - implementation. - * cygwin/version.h: Bump current version to 1.1.0. - -Thu Dec 2 22:19:40 1999 Christopher Faylor - - * sync.cc (muto::muto): Use an event rather than a semaphore for wait - synchronization. - (muto::acquire): Rewrite to use an event and try to remove races. - (muto::release): Ditto. - -1999-12-02 DJ Delorie - - * environ.cc (parse_options): switch to a static initializer; - templates are sensitive to g++ bugs. - -Fri Nov 26 12:04:23 1999 Christopher Faylor - - * net.cc (cygwin_bind): Ensure that non-Unix domain socket operations - return success correctly. - -Wed Nov 24 21:37:58 1999 Christopher Faylor - - * net.cc (cygwin_bind): Guard against incorrectly setting res to zero - when there is an error condition. - -Tue Nov 23 17:49:55 1999 Christopher Faylor - - * fhandler.cc (fhandler_base::fhandler_base): Use better initialization - scheme. - * fork.cc (stack_base): Eliminate unneeded asm stuff. - * select.cc: Sprinkle in some comments. - * include/winnt.h: Add more CONTEXT. - -Nov 23 20:51:00 1999 Corinna Vinschen - - * net.cc (cygwin_bind): Use struct sockaddr_un in AF_UNIX code. Set - errno to ENAMETOOLONG if length of pathname exceeds limit in AF_UNIX - code. Sets errno to EADDRINUSE in AF_UNIX code if file system socket - object already exists. - * syscalls.cc (setsid): Set errno to EPERM if current process is - already process group leader. - * uinfo.cc (internal_getlogin): Rearrange for better debug output. Set - pi->psid to NULL if SID can't be determined. - * include/cygwin/socket.h: Add AF_LOCAL and PF_LOCAL - (same as AF_UNIX) for POSIX compatibility. - * include/sys/un.h: Add UNIX_PATH_LEN define. Added SUN_LEN macro for - POSIX compatibility. - -Sun Nov 21 22:55:04 1999 Christopher Faylor - - * environ.cc (parse_options): Return immediately after dealing with - NULL argument. Don't try to process it. - -Tue Nov 16 23:29:17 1999 Christopher Faylor - - * signal.cc (kill_worker): Guard against NULL dereference when thread - safe. - -Sat Oct 30 00:59:38 1999 Christopher Faylor - - * Makefile.in: Some general cleanup. - * smallprint.c (__small_vsprintf): Accommodate new format for - __PRETTY_FUNCTION__. - -Wed Oct 27 16:13:36 1999 Christopher Faylor - - * path.cc (mount_info::from_registry): Don't allow the same posix path - into the mount table more than once. - * utils/mount.cc (main): Add some orthogonality to the options. - -Tue Oct 26 21:55:49 1999 Christopher Faylor - - * environ.cc (environ_init): Turn off ntsec by default. - -Wed Oct 27 00:14:11 1999 J"orn Rennecke - - * fhandler.cc (fhandler_base::lseek): Take readahead into account. - -Tue Oct 26 16:46:54 1999 Christopher Faylor - - * syscalls.cc (_unlink): Return EISDIR when attempting to unlink a - directory. - -Mon Oct 25 18:05:23 1999 Christopher Faylor - - * fhandler.cc (fhandler_base::read): Fix previous fix. - -Mon Oct 25 13:46:44 1999 Christopher Faylor - - * dll_init.cc (add): Avoid allocating name for "LINK"ed DLLs. - (DllList::forkeeLoadDlls): Only reload DLLs if they have been - dlopen'ed. - * grp.cc (parse_grp): Assign gr_mem when it is determined. - -Sun Oct 24 21:55:48 1999 Christopher Faylor - - * dll_init.cc (struct dll): Add module name. - (add): Add additional 'name' parameter for recording in dll structure. - (reserve_upto): New function. - (release_upto): Ditto. - (DllList::forkeeLoadedDlls): Ditto. - (DllList::forkeeStartLoadDlls): Remove. - (DllList::forkeeEndLoadedDlls): Ditto. - (DllNameIterator::*): Eliminate class. - (LinkedDllNameIterator::*): Ditto. - * dll_init.h: Reflect above changes. - * fork.cc (fork): Don't generate a list of dlls to load in the parent. - Let the child do it. Use new DllList::forkeeLoadDlls to load DLLs. - * smallprint.c (__small_vsprintf): No need for a sign on a Win32 error. - (small_printf): Move function here from strace(). - * strace.cc (small_printf): Move to smallprint.c - * include/sys/strace.h: Always declare small_printf. - -Sun Oct 24 02:22:13 1999 Christopher Faylor - - * fhandler.cc (fhandler_base::read): Work around C bug. - -Tue Oct 19 22:10:21 1999 Christopher Faylor - - * dll_init.cc: Add some external symbols to allow thread-safe - compilation. - -Tue Oct 19 21:09:42 1999 Christopher Faylor - - Make minor changes throughout to accommodate new gcc merge. - * Makefile.in: Remvoe -fpermissive option when compiling using g++. - * dcrt0.cc (noload): Mark as "unused" to avoid a compiler warning. - * exceptions.cc (sigreturn): Make this "extern" since it essentially - *is* extern. - * fork.cc (sync_with_parent): Modify to cause the macro to be - considered void. - * heap.cc (sbrk): Remove debugging code. - * passwd.cc (getpass): Don't use fprintf to print the prompt. - * path.cc (mount_info::conv_to_win32_path): Accommodate compiler - warning. - * select.cc (cygwin_select): Experimental version of select which - handles fd_sets with non-standard FD_SETSIZE. - (select_stuff::wait): Ditto. - * termios.cc (tcgetattr): Avoid a compiler warning. - (cftospeed): Ditto. - (cftispeed): Ditto. - * uinfo.cc (netapi32_init): Ditto. - * winsup.h (api_fatal): Simplify and avoid a compiler warning. - * include/sys/strace.h (system_printf): Ditto. - (strace_printf_wrap): Modify to cause the macro to be considered void. - (strace_printf_wrap1): Ditto. - -1999-10-19 DJ Delorie - - * Makefile.in (.cc.o): add -fpermissive to avoid g++'s conformance - madness. - * environ.cc (_findenv): rename to my_findenv to avoid newlib - prototype. - * syscalls.cc (logout): remove braces around _PATH_UTMP - -Sat Oct 16 22:53:02 1999 Christopher Faylor - - * path.cc (mount_info::cygdrive_posix_path): Properly terminate string - after Oct 11 change below. - -Fri Oct 15 23:02:39 1999 Christopher Faylor - - * exceptions.cc (stack_info): Reimplement stack handling routines in - new stack_info class. - (stack_info::brute_force): Just fill out the same structure as - StackWalk. - (stack_info::walk): Just fill out stack info. - (stack): Use stack_info class stuff to iterate over and display the - stack. - -Fri Oct 15 00:32:13 1999 Christopher Faylor - - * include/cygwin/version.h: Bump some versions. - -Oct 5 11:45:00 1999 Corinna Vinschen - - * dcrt0.cc (dll_crt0_1): Delete calls to get_WHOEVER_sid. Move call to - uinfo_init() to the end of the function. - * fhandler.cc (get_file_owner): Substitute call to get_id_from_sid() - with call to get_uid_from_sid(). - (get_file_group): Substitute call to get_id_from_sid() with call to - get_gid_from_sid(). - * fork.cc (fork): Copy new pinfo members to child. - * grp.cc (parse_grp): Rewritten. Saves gr_passwd and all user names in - gr_mem. - (read_etc_group): Variable `group_sem' avoids endless loop. - * passwd.cc (read_etc_passwd): Variable `passwd_sem' avoids endless - loop. - * security.cc (get_sid): New function to generate SID from int values. - (get_ssid): New function to generate SID from string. - (get_pw_sid): New function to generate SID from pw_gecos entry. - (get_gr_sid): New function to generate SID from gr_passwd entry. - (get_admin_sid): Rewritten to avoid using heap space. - (get_system_sid): Ditto. - (get_creator_owner_sid): Ditto. - (get_world_sid): Ditto. - (get_id_from_sid): Try to read SIDs from /etc/passwd or /etc/group - files before using RID or Lookup... function. - (legal_sid_type): New function. - (lookup_name): Rewritten to use the logon server info, if any. - (alloc_sd): Try to use SID from /etc/passwd and /etc/group files before - call to lookup_name(). - (alloc_sd): New parameter for logon server. - (set_nt_attribute): Ditto. - (set_file_attribute): Ditto. - * shared.cc (sec_user): If SID is saved in myself, use it instead of - calling lookup_name(). - * shared.h: struct pinfo got extended user information. - * spawn.cc (spawn_guts): method for forcing reread /etc files changed. - (_spawnve): Copy new pinfo members to child. - * syscalls.cc (chown): Change call to set_file_attribute(). - (chmod): Ditto. - * uinfo.cc (internal_getlogin): New function. - (uinfo_init): Calls internal_getlogin() now. - (getlogin): Uses myself->username now. - * winsup.h: extern HANDLE netapi32_handle; Change prototypes for - set_file_attribute(), lookup_name(), get_id_from_sid(). New inline - functions get_uid_from_sid() and get_gid_from_sid(). - * utils/mkgroup.c: Adapt to the new ntsec features. - * utils/mkpasswd.c: Ditto. - -Thu Oct 14 23:46:03 1999 Christopher Faylor - - Replace calls to GetCurrentProcess() with hMainProc throughout. - * autoload.h: Implement LoadDLLinitnow() function to force the loading - of a DLL. - * cygwin.din: Export cygwin_stackdump. - * dcrt0.cc (dll_crt0): Set up hMainProc and hMainThread here. - * dll_init.cc (dll_dllcrt0_1): Ditto. - * environ.cc (parse_options): New "oldstack" option for forcing the use - of the old stack walking code. - * exceptions.cc (signals_init): Remove. - (err_printf): Remove. Use small_printf throughout. - (sfta): New helper function for StackWalk. - (sgmb): Ditto. - (stack_brute_force): Renamed from old stack walk function. Now uses - frame pointer from context handler. - (stack_walk): New function. Uses Windows API to walk the stack. - (stack): Reimplement to attempt to load imagehlp.dll. If this succeeds - use stack_walk() to display stack info, otherwise use - stack_brute_force. - (cygwin_stackdump): Temporary (?) function for displaying a stack dump - from the called location. - (stackdump): Accept new parameters for passing to stack(). - (handle_exceptions): Call stackdump with new parameters needed to walk - the stack. - * fhandler.cc (fhandler_base::read): Fix potential buffer overrun. Fix - end of buffer problems when \r is not followed by a \n. - (fhandler_base::lseek): Avoid flushing read ahead when not moving the - file pointer. - * fhandler_termios.cc (fhandler_termios::set_ctty): Add a debugging - statement. - * sigproc.cc (sigproc_init): Eliminate obsolete signals_init function. - * winsup.h: Add some declarations. - -Wed Oct 13 09:02:32 1999 Kazuhiro Fujieda - - * path.cc (readlink): Return errno correctly when it can't find the - target symlink. - -Tue Oct 12 13:02:08 1999 Christopher Faylor - - * syscalls.cc (setsid): Only reset sid/pgid when NOT process group - leader. - * tty.cc (tty_list::allocate_tty): Don't set sid to myself. The first - tty open should do that. - -Mon Oct 11 23:13:29 1999 Christopher Faylor - - * dcrt0.cc (noload): Issue appropriate Windows error. - * fhandler_termios.cc (fhandler_termios::ctty): Don't automatically set - sid, etc., unless the current pid associated with the tty's sid does - not exist. - * path.cc (mount_info::cygdrive_posix_path): Avoid copying beyond the - end of buffer or suffer garbage. - * pinfo.cc (pinfo_init): Restore sid behavior of a year ago. The sid - should be the same as the pid to be equivalent to UNIX. - (pinfo_list::operator []): Add more bounds checking. - -Sun Oct 10 14:08:30 1999 Christopher Faylor - - * select.cc (select): Return error if n > FD_SETSIZE. This is a - temporary fix. - -Sun Oct 10 13:56:14 1999 Christopher Faylor - - * path.cc (iscygdrive_device): Be more precise in detecting when a - "cygdrive" device. This should allow 'mkdir -p' to work correctly. - -Fri Oct 08 08:55:31 1999 Kazuhiro Fujieda - - * path.cc (symlink_check_one): set errno to EINVAL on socket files - same as normal files. - -1999-10-06 DJ Delorie - - * include/oaidl.h (IDispatch.GetIDsOfNames): Use DISPID* not DISPID - -1999-10-06 DJ Delorie - - * exceptions.cc (err_printf): new function; print to stderr - without strace's clutter. The stacktrace functions use this, so - the stacktrace files should be cleaner. - (exception): Print segment registers also - (stack): include a peek at the function's arguments - -Tue Oct 5 16:33:17 1999 Christopher Faylor - - * hinfo.cc (hinfo::extend): Eliminate inappropriate test for boundary - condition. - -1999-10-04 DJ Delorie - - * config/i386/longjmp.c: don't restore %fs (Paul Sokolovsky - ) - -1999-10-04 DJ Delorie - - * localtime.c (tzsetwall): Handle Asian Windows strings correctly - (from Kazuhiro Fujieda ). - -Sat Oct 2 23:00:00 1999 Corinna Vinschen - - * include/lm*.h: Correct multiple problems in lan manager - header files. - -Sun Oct 3 14:29:53 1999 Christopher Faylor - - * sysdef/imagehlp.def: New file. Definitions for imagehlp.dll. - * include/imagehlp.h: Ditto. - * include/winbase.h: YA missing structure. - -Fri Oct 1 11:16:00 Corinna Vinschen - - * security.cc (alloc_sd): Correct setting of FILE_DELETE_CHILD. - (get_file_attribute): Read ntea attributes only if ntsec is disabled. - * syscalls.cc (_unlink): Don't queue file into delqueue if DeleteFile - returns ERROR_ACCESS_DENIED. - -1999-09-30 Mumit Khan - - * init.cc (dll_entry): Remove static_load case. - * dcrt0.c (set_os_type): Make it externally visible. - * dll_init.cc (dll_dllcrt0_1): Update noncygwin initialization for - post-b20.1 code. - -1999-09-30 DJ Delorie - - * times.cc: declare _timezone and _daylight properly - -Wed Sep 29 23:57:40 1999 Christopher Faylor - - * dcrt0.cc (do_exit): Remove EXIT_SIGNAL mask when exiting. It is not - correct given changes to really_exit. - * select.cc (peek_serial): Work around apparent Windows bug. - -1999-09-29 Norbert Schulze - - * times.cc (timezone): revert 'return TZ if set' patch. - * times.cc (timezone): uses now tzset() and _timezone. - * times.cc (gettimeofday): ditto. - * localtime.c (tzsetwall): no negative minutes if offset is negativ. - * localtime.c (tzsetwall): minutes place holder was missing if - minutes == 0 and seconds !=0 (h:0:s). - * localtime.c (tzsetwall): if timezone has no daylight saving - (tz.StandardDate.wMonth==0) generate no daylight saving parameters. - -Sat Sep 25 15:11:04 1999 Christopher Faylor - - * fhandler_termios.cc (fhandler_termios::bg_check): Accept a new - argument to control whether we should worry about blocking signals. - * fhandler.h: Ditto. - * syscalls.cc (read_handler): Accept a new argument for passing to - bg_check. - (read): Inform read_handler if signals are blocked or not. - * termios.cc: Throughout, reorganize to always block signals before - calling bg_check. - -Sat Sep 25 13:36:06 1999 Christopher Faylor - - * fhandler.h (fhandler_termios::line_edit): Add an extra argument. - * fhandler_serial.cc (fhandler_serial::open): Maintain consisten - fAbortOnError state. - * fhandler_termios.cc (fhandler_termios::line_edit): Use new - "always_accept" argument to control whether input_done is set - regardless of canonical state. - * fork.cc (vfork): Duplicate "parent's" fd table. - * hinfo.cc (hinfo::dup_worker): New method. - (dup2): Use new dup_worker method. - (hinfo::fixup_after_fork): Lock dtable prior to operating on it. - (hinfo::vfork_child_dup): New method. Duplicates dtable for vfork. - (hinfo::vfork_parent_restore): New method. Restores dtable when vfork - exits. - * net.cc (set_winsock_errno): Make global. - * pipe.cc (pipe): Default mode to binary unless *explicitly* set to - text. - * select.cc (set_bits): Test that {read,write,except}_selected are - active before setting a bit. - (peek_pipe): Short circuit tests if we're not checking for readable - or "except"able handles. - (thread_socket): Use read check for exitsock as old method relied on - undocumented, unreliable behavior. - (start_thread_socket): Perform more setup on exitsock to improve thread - exit signalling. - (socket_cleanup): Connect to the exitsock to force thread_socket thread - exit. - * winsup.h (hinfo): Add preliminary vfork stuff. - * include/winsock.h: Add shutdown() how types. - * include/sys/socket.h: Add socketpair declaration. - -1999-09-22 DJ Delorie - - * syscalls.cc (chown): never return ENOSYS - just pretend it - works. - -Wed Sep 22 00:47:56 1999 Christopher Faylor - - * select.cc (MAKEready): Need to initialize 'fd' or open tests in - peek fail. - -Mon Sep 20 17:07:37 1999 Christopher Faylor - - * smallprint.c (__small_vsprintf): Fix '%+' handling. - -Thu Sep 16 21:48:13 1999 Christopher Faylor - - * utils/cygcheck.cc (dump_sysinfo): Deal with a new compiler error. - * utils/strace.cc (make_command_line): Change to a void * argument, as - is required for SetConsoleCtrlHandler. - -Thu Sep 16 20:47:12 1999 Christopher Faylor - - * dcrt0.cc (__api_fatal): Rearrange slightly. - * fhandler.h (set_ctty): Change to void. - * fhandler_termios.cc (fhandler_termios::set_ctty): Ditto. - * select.cc (thread_pipe): Change to a void * argument, as is required - for thread functions. - (thread_socket): Ditto. - (thread_serial): Ditto. - * include/winbase.h: Mark ExitProcess as noexit. - -Thu Sep 16 18:32:12 1999 Christopher Faylor - - * exceptions.cc (ctrl_c_handler): Make WINAPI, as required by - SetConsoleCtrlHandler. - -Thu Sep 16 17:48:05 1999 Christopher Faylor - - * debug.cc (thread_stub): Make WINAPI, as required by CreateThread. - * fhandler_tty.cc (process_input): Ditto. - (process_output): Ditto. - (process_ioctl): Ditto. - * select.cc (thread_pipe): Ditto. - (thread_serial): Ditto. - (thread_socket): Ditto. - * sigproc.cc (wait_proc): Ditto. - (wait_sig): Ditto. - * window.cc (winMain): Ditto. - -Wed Sep 15 20:58:37 1999 Christopher Faylor - - * exceptions.cc (call_handler): Let fatal signals through regardless of - signal_mutex. - * fhandler.h (fhandler_base): Make bg_check virtual. - (fhandler_termios::bg_check): Eliminate the second argument. - * fhandler_console.cc (fhandler_console::ioctl): Check for background - operation. - * fhandler_termios.cc (fhandler_termios::bg_check): Eliminate the - second argument. A negative arg 1 means the same thing. - * ioctl.cc (ioctl): Add debugging output. - * syscalls.cc (_write): Eliminate second argument to bg_check. - * termios.cc (tcsendbreak): Check for background operation. - (tcdrain): Ditto. - (tcflush): Ditto. - (tcflow): Ditto. - (tcsetattr): Reorganize on similar lines to above routine. - -Wed Sep 15 15:25:04 1999 Christopher Faylor - - * select.cc (peek_pipe): Only set read_ready if bg_check returns <= 0. - (peek_console): Ditto. Correct PeekConsole conditional so that the for - loop breaks eventually. - -Wed Sep 15 00:21:40 1999 Christopher Faylor - - * exceptions.cc (set_console_handler): Allocate security stuff here - since it is needed earlier in the process now. Allocate a shared event - for use in synchronizing CTRL-C events that happen while the process is - still initializing. - (ctrl_c_handler): Use the above event to synchronize with the cygwin - startup process, waiting for the signal thread to come alive before - trying to send a signal. - (signals_init): Don't call set_console_handler() here, since it is now - handled much earlier in cygwin initialization. - * shared.cc (shared_init): Move out security setup. - * sigproc.cc (wait_sig): Activate the console_handler_thread_waiter so - that any waiting thread which is handling ctrl-c's will wake up and - send a signal, if appropriate. - -Tue Sep 14 23:49:39 1999 Christopher Faylor - - * exceptions.cc (ctrl_c_handler): Handle ctrl-c events ourself, using - the "UNIX way". - * fhandler_console (tty_list::get_tty): New function. - * shared.h: Add some additional things to tty_min class for handling - ctrl-c. - -1999-09-14 DJ Delorie - - * dir.cc (rmdir): return ENOTDIR for regular files on 9x - -Tue Sep 14 00:01:59 1999 Christopher Faylor - - * debug.h (ForceCloseHandle2): New macro. - * fhandler.cc (set_inheritance): Accept name of handle as optional - third argument. Use this in ForceCloseHandle2/ProtecHandle2. - * fhandler.h: Implement bg_check() method. - * fhandler_console.cc (get_tty_stuff): Initialize more tty stuff. - (fhandler_console::read): Check for background read. - * fhandler_termios.cc (fhandler_termios::bg_check): New function. - Performs appropriate action given background read or write. - * fhandler_tty.cc (fhandler_tty_slave::write): Replace background check - code with new method. - (fhandler_tty_slave::read): Ditto. - (fhandler_tty_common::set_close_on_exec): Pass output_mutex name to - set_inheritance. - * select.cc: Throughout check that the fd is still open before polling. - (peek_pipe): Check for background read. - (peek_console): Ditto. - * shared.h: Move ntty from tty into tty_min. - * syscalls.cc (read_handler): Check for background read. - (_write): Check for background write. - -Sat Sep 11 16:24:21 1999 Christopher Faylor - - * path.cc (iscygdrive_device): New macro. - (mount_info::conv_to_win32_path): Only attempt "cygdrive" translation - when passed /cygdrive/something. - (mount_info::write_cygdrive_info_to_registry): Store in-memory copy of - cygdrive prefix automatically. - (mount_info::read_cygdrive_info_from_registry): Reorganize for new - write_cygdrive_info_to_registry functionality. - (mount): Ditto. - -Fri Sep 10 15:44:11 1999 Christopher Faylor - - * syscalls.cc (pathconf): Make first arg 'const'. - -1999-09-10 DJ Delorie - - * exec.cc (_execve): check for an empty environment - -Wed Sep 8 10:24:12 1999 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Generalize test for initial zeroes in - exec/fork block. - * fhandler.cc (fhandler_disk_file::open): Don't attempt #! detection on - non-disk files. - * fhandler.h: Use generic status bit set/clear macros. Use bitmask for - fhandler_termios state. - * fhandler_console.cc: Rename "tty_stuff" to more descriptive - "shared_console_info". - (fhandler_console::read): Reset console state before a read if - appropriate. - (fhandler_console::open): Improve check for setting console state. - (fhandler_console::fixup_after_fork): Ditto. - (set_console_state_for_spawn): New function. - * fhandler_termios.cc (fhandler_termios::tcinit): Use new method for - determining if initialized. - * fhandler_tty.cc (fhandler_tty::init_console): Avoid sending handle to - init or it will be closed. - * fork.cc (per_thread::set): Make this method non-inline, temporarily. - * select.cc (peek_console): Call set_input_state to ensure that the - console is in the correct state. - * shared.h (child_info): Make zero element an array for future - tweaking. - (tty_min): Change initialized element to a bit field. Define bit field - macros for manipulating it. - * sigproc.cc (wait_sig): Wake up every half second in a (vain?) attempt - to work around Windows 98 hanging problem. - (wait_subproc): Ditto. - * spawn.cc (spawn_guts): Use new "set_console_state_for_spawn" prior to - starting a process. - * winsup.h: Define generic macros for manipulating a method's status - field. - (per_thread): Move inline method to fork. - -Mon Sep 6 13:36:34 1999 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_master::init_console): Remove retrieval - of stderr handle since it is not required for correct init operation. - * hinfo.cc (hinfo_init): Reorganize to accommodate potential closing of - console handles by fhandler_console::init. - (init_std_file_from_handle): Set standard handle as appropriate. - (hinfo::de_linearize_fd_arry): Ditto. - * fhandler_console.cc (fhandler_console::init): Conditionally close - handle only if it is valid. - -Sun Sep 5 22:43:21 1999 Christopher Faylor - - * utils/cygcheck.cc: Make sure that GetDiskFreeSpaceExA is defined as a - __stdcall function or the stack will suffer. For now, don't sort mount - output as more work copying the individual mntent elements is required. - -Sat Sep 4 19:01:00 1999 Christopher Faylor - - * include/glob.h: Ensure that glob*() functions can be properly accessed by - programs using the DLL. - -Sat Sep 4 18:49:04 1999 Christopher Faylor - - * heap.cc (heap_init): Tweak debugging output. - * sigproc.cc (sig_send): Catch obvious impossible values from - GetLastError. - -Sat Sep 4 18:43:49 1999 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_slave::open): Protect against signal - dispatch. - (fhandler_tty_slave::write): Only wait a fixed amount of time to - receive a an output_done_event. - (fhandler_tty_slave::tcflush): Protect against signal dispatch. - -Sat Sep 4 18:30:42 1999 Christopher Faylor - - * exceptions.cc (handle_sig): Temporarily remove OutputDebugString. It - seemed to be causing sporadic hangs. - (call_handler): Save and restore di and si. - (sigreturn): Ditto. - -Fri Sep 3 23:07:44 1999 Christopher Faylor - - * fhandler_termios.cc (fhandler_termios::line_edit): Properly deal with - sending characters to slave when !iscanon. - -Fri Sep 3 18:15:00 1999 Corinna Vinschen - - * fhandler_raw.cc (fhandler_dev_raw::fstat): Add S_ISCHR to mode bits. - * fhandler_tape.cc (fhandler_dev_tape::fstat): Erase setting of S_ISCHR - since it's set in fhandler_dev_raw::fstat now. - -Thu Sep 2 22:11:03 1999 Christopher Faylor - - * path.cc (mount_info::conv_to_win32_path): Fix problem with - calculating relative path at root. - -Wed Sep 1 23:24:43 1999 Christopher Faylor - - * fhandler.cc (fhandler_base::fhandler_base): Don't use default binmode - for console. - -Wed Sep 1 20:51:05 1999 Christopher Faylor - - * smallprint.c (__small_vsprintf): Allow field width argument with 'l' - modifier. Consolidate processing of field width. - * uname.cc (uname): Eliminate space in "release" field. - -Tue Aug 24 10:46:24 1999 Kazuhiro Fujieda - - * fhandler_console.cc (write_normal): Write '\n' corresponding to - DWN if the cursor is out of the window. - -Wed Aug 25 22:16:46 1999 Christopher Faylor - - * smallprint.c (rn): Deal with positive as well as negative signs. - (__small_vprintf): Handle '+', 'l', and '%' format types. - -Wed Aug 25 00:38:49 1999 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Zero heap information in user_data to - work around mutant startup code. - -Tue Aug 24 00:03:22 1999 Christopher Faylor - - * sigproc.cc (sig_send): One more end-of-process race detection. - -Mon Aug 23 21:37:07 1999 Christopher Faylor - - Throughout, remove malloc.h. - * debug.cc: Initialize handle list so that it will not be copied on - fork. - * exceptions.cc (_sigreturn): Zero windows error on exit. It's - meaningless after a signal dispatch. - * fhandler_console.cc (fhandler_console::de_linearize): Improve error - messages. - * shared.h: Increment fork magic number. - * sigproc.cc (sigproc_terminate): Close all handles prior to calling - proc_terminate if running in signal thread. - (sig_send): Eliminate bogus ResetEvent on a semaphore. Add code for - potentially dealing with problems when this code is interrupted via a - signal dispatch. - * times.cc (timezone): Use __small_sprintf. - * uname.cc (uname): Ditto. Also use strcpy instead of sprintf where - appropriate. - -1999-08-23 DJ Delorie - - * localtime.c: export timezone, daylight, tzname as _* - * times.cc: don't export timezone, daylight, tzname - (timezone): return TZ if set. - (cygwin_tzset): not needed. - -Thu Aug 19 13:46:47 1999 Christopher Faylor - - * fork.cc (fork): Remove pinfo lock. It is in allocate_pid, now. - * spawn.cc (_spawnve): Ditto. - * pinfo.cc (pinfo_init): Ditto. - (lock_pinfo_for_update): Impreove debug output. - (pinfo_list::allocate_pid): Lock pinfo mutex here. - -1999-08-19 DJ Delorie - - * Makefile.in (tooldir): If we're building natively, drop the - $(target_alias) on include and lib's install (i.e. /usr/include - instead of /usr/include/i686-cygwin). - -Thu Aug 19 01:11:25 1999 Christopher Faylor - - * sigproc.cc (sig_send): Avoid a race with proc thread when executing - due to a signal. - -Wed Aug 18 16:37:59 1999 Kazuhiro Fujieda - - * fhandler_console (fhandler_console::fillin_info): Avoid setting - scroll_region.Bottom when it is not known. - (fhandler_console::write_normal): Add various fixes for console - scrolling. - -Wed Aug 18 16:18:22 1999 Christopher Faylor - - * sigproc.cc: Add more precise end-of-process detection. - -Wed Aug 18 00:03:47 1999 Christopher Faylor - - * sigproc.cc (sig_send): Work around apparent Windows bug which - occasionally results in bogus error messages when a signal is - dispatched. - -1999-08-17 DJ Delorie - - * localtime.c (tzsetwall): Deduce TZ more accurately. - -Tue Aug 17 18:00:03 1999 Christopher Faylor - - * select.cc (peek_pipe): Correct detection of process group for - backgrounded processes. - -Tue Aug 17 10:24:49 1999 Christopher Faylor - - * include/winnt.h: Fix typo in IMAGE_FIRST_SECTION definition. - -Sun Aug 15 19:11:49 1999 Mumit Khan - - * gcrt0.c (__eprol): Avoid namespace pollution. - (_monstartup): Turn into a constructor function and prevent multiple - invocations. - -Mon Aug 16 10:03:00 Corinna Vinschen - - * utils/mkgroup.c: Correct call to LookupAccountSid for retrieval of - 'None'. - -Mon Aug 16 00:24:29 1999 Christopher Faylor - - * debug.cc (locker): Improve signal mutex locking. - * exceptions.cc (sig_handle): Pass STOP signals to call_handler to - ensure honoring of signal_mutex. - (call_handler): Move STOP code here after acquistion of signal_mutex. - * fhandler_tty.cc (fhandler_tty_common::__acquire_output_mutex): Track - lockers for debugging. - (fhandler_tty_common::__release_output_mutex): Ditto. - (fhandler_slave::write): Fix faulty signal blocking code. - * fork.cc (fork_copy): Remove ancient if 0. - (fork): Conditionalize "FORKDEBUG" under DEBUGGING. - * sigproc.cc (proc_terminate): Reduce pinfo lock time. - (sigproc_terminate): Set sig_loop_wait after getting signal_mutex. - (__get_signal_mutex): Reorganize for less strace output when not - DEBUGGING. - (__release_signal_mutex): Ditto. Reorganize case where !sig_loop_wait. - (have_signal_mutex): Returns true if current thread has the mutex. - * wait.cc (wait4): Change debugging message. - -Sat Aug 14 0:10:00 Corinna Vinschen - - * fhandler.cc (fhandler_base::raw_read): Set correct errno from Win32 - error when ReadFile fails. - (fhandler_base::raw_write): In case of ERROR_DISK_FULL, return - bytes_written only if bytes_written > 0. - * errno.cc: Map ERROR_DISK_FULL to ENOSPC. - -Fri Aug 13 14:22:12 1999 Christopher Faylor - - * select.cc (peek_pipe): Honor ignra argument. - -Fri Aug 13 00:45:00 1999 Christopher Faylor - - * spawn.cc (spawn_guts): Ensure that hExeced is set to proper state - when parent has exited. - -Thu Aug 12 14:09:30 1999 Christopher Faylor - - * sigproc.cc (getsem): Fix typo which prevented sending signals to - other processes. - -Wed Aug 11 22:06:33 1999 Christopher Faylor - - * cygwin.din: Export glob and globfree. - * glob.h: Move to include. - * Makefile.in: Correct glob.h dependencies. - -Wed Aug 11 19:41:04 1999 Sergey Okhapkin - - * fhandler.cc (fhandler_disk_file::fstat): Check if the file is unix - domain socket. - (fhandler_disk_file::open): Call set_socket_p(). - * fhandler.h: Add new fhandler type flags (FH_LOCAL, FH_FIFO). - (fhandler_base): get/set_socket_p - new member functions. - (fhandler_socket::addr_family): Add new member, currently unused. - (fhandler_socket::get/set_addr_family): Add new functions to access - addr_family. - * include/sys/un.h: New file. - * net.cc: Include - (cygwin_socket): Always create socket of AF_INET family, store - argument's family. - (get_inet_addr): New static function. Converts AF_UNIX requests into - corresponding AF_INET requests. - (cygwin_sendto): Use get_inet_addr(). - (cygwin_connect): Likewise. - (cygwin_accept): Check for sockaddr length. - (cygwin_bind): Implement AF_UNIX. - * path.h (PATH_SOCKET): Add new enum value. - (path_conv::issocket): Add new member function. - (SOCKET_COOKIE): Add new define. - * syscalls.cc (chmod): Mark socket files with system file attribute. - -Wed Aug 11 17:22:46 1999 Corinna Vinschen - - * utils/mkgroup.c (main): Generate "None" group when - invoked via mkgroup -l. - -Tue Aug 10 21:30:31 1999 Christopher Faylor - - * select.cc (peek_pipe): Handle type ahead where appropriate. - * sigproc.cc (proc_can_be_signalled): Revert to previous method for - determining signalability. - (getsem): Move PID_INITIALIZING test here. - * wait.cc (wait4): Improve debug output slightly. - -Mon Aug 9 23:27:44 1999 Christopher Faylor - - * dcrt0.cc (do_exit): Add additional check for valid hExeced. - * exceptions.cc (call_handler): Implement a raceless way to track - pending_signals. - * signal.cc (kill_worker): Make calls from non-main threads synchronous - or signals from a tty thread don't work right. - * sigproc.cc (sig_send): Localize pending_signals assignment to only - the wait_sig thread. - (__get_signal_mutex): Don't attempt to grab a mutex if signal_mutex - hasn't been assigned yet. Add more strace debugging information when - -DDEBUGGING. - (__release_signal_mutex): Don't attempt to release a mutex if - signal_mutex hasn't been assigned yet. Add more strace debugging - output. - (wait_sig): Attempt to eliminate race in setting of pending_signals. - * spawn.cc (spawn_guts): Set hExeced to INVALID_HANDLE_VALUE so that it - will be obvious when a process is actually just an execed stub. - * strace.cc (strace_vsprintf): Output a "!" after the pid when - executing in an execed stub. - -Mon Aug 9 17:17:13 1999 Christopher Faylor - - Throughout, eliminate in() and out() macros. - * winsup.h (tty_attached): Accept an argument indicating the pinfo - structure to query. - * exceptions.cc (really_exit): Cosmetic change. - * external.cc (fillout_pinfo): Use queried pinfo structure for - determining tty number, not *our* number. - * net.cc: More workarounds. - * path.cc (get_device_number): Supply argument to tty_attached. - * syscalls.cc (ctermid): Ditto. - * strace.cc (strace_dump): Remove. - * include/sys/strace.h: Eliminate obsolete stuff. - -Sun Aug 8 22:54:45 1999 Christopher Faylor - - * exceptions.cc (call_handler): Process all signals on return from a - signal dispatch. - * sigproc.cc (proc_can_be_signalled): Guard against waiting too long - when exiting. - (proc_exists): Don't report an exited process as "existing". - (proc_terminate): Close handle prior to testing for existence so that - proc_exists will not always return TRUE. Eliminate use of zap_subproc. - (stopped_or_terminated): Eliminate use of zap_subproc. - (zap_subproc): Delete. - -Sun Aug 8 22:17:36 1999 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_master::init): hThread must remain - open. Previous change to close it was wrong. - -Sun Aug 8 20:35:33 1999 Christopher Faylor - - * exceptions.cc: Initalize NO_COPY variables. - * pinfo.cc (record_death): Don't be so insistent about getting - the pinfo lock. - * sigproc.cc (proc_terminate): Tighten the region protected by - the pinfo lock. - * spawn.cc (spawn_guts): Eliminate the pinfo lock when reparenting - as it is no longer required. - (_spawnve): Tighten the region protected by the pinfo lock. - -Sun Aug 8 18:26:51 1999 Christopher Faylor - - * sigproc.cc (sig_send): Add more unfortunate guards against a - system call being interrupted by a signal dispatch. - -Sat Aug 7 15:38:42 1999 Christopher Faylor - - * security.cc (get_admin_sid): Ensure that returned buf is not copied - on a fork. - (get_system_sid): Ditto. - (get_create_owner_sid): Ditto. - (get_world_sid): Ditto. - -Sat Aug 7 15:17:25 1999 Christopher Faylor - - * fhandler_tty.cc (process_input): Reset signal_arrived event prior to - calling console read as this is now a requirement for functions which - detect signal_arrived. - (fhandler_tty_master::write): Allow signals to operate prior to raising - SIGTTOU. - (fhandler_tty_master::read): Allow signals to operate prior to raising - SIGTTIN. - * select.cc (peek_pipe): Detect attempt to read from tty not in our - process group as a "read_ready" event. - * include/shellapi.h: Add missing defines. - * utils/ps.cc: Output windows pid as unsigned for Windows 9x. - -Sat Aug 7 14:30:00 Corinna Vinschen - - * security.cc (get_creator_owner_sid): New function. - * shared.cc (sec_user): calls `get_creator_owner_sid' in creation - of the security attributes structure additionally. - -Fri Aug 6 13:04:40 1999 Christopher Faylor - - * spawn.cc (spawn_guts): Allow failure from OpenProcess. The parent - may have exited due to 7/31 change. - -Thu Aug 5 22:54:07 1999 Christopher Faylor - - * sigproc.cc (wait_for_me): Break out as a common function to check - that the current process is ready to handle signals. - (proc_can_be_signalled): Treat myself differently. - -Thu Aug 5 21:24:20 1999 Christopher Faylor - - * fhandler_console.cc (fhandler_console): Don't call tcinit here. - (fhandler_console::read): Don't reset signal_arrived here. - * syscalls.cc (_read): Set it here instead. - * fhandler_termios.cc (fhandler_termios::line_edit): Only call - accept_input when input is ready. Ignore iscanon in this case. - * fhandler_tty.cc (fhandler_tty_slave::init): Don't call tcinit here. - -Thu Aug 5 16:02:25 1999 Christopher Faylor - - * strace.cc (handle_output_debug_string): Ignore errors reading - from child memory as they seem to occur due to a process exiting. - (close_handle): New, defensive code. - -Thu Aug 5 13:32:43 1999 Christopher Faylor - - * strace.cc (remove_handle): New function. - (add_child): Speed up slightly. - (proc_child): Use output of remove_child in CloseHandle. - -Thu Aug 5 12:38:50 1999 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Don't protect subproc_ready if it is NULL. - (do_exit): Avoid calling close_all_files if exiting from exec stub. - * net.cc: Reorganize to work around some compiler bugs. - * spawn.cc (spawn_guts): Set hExeced only after child stuff has been - completely initialized. - * syscalls.cc (_open): Protect against signals. - * utils/strace.cc (warn): New function. - (add_child): Issue warning when can't duplicate child process handle. - -Wed Aug 4 21:35:28 1999 Christopher Faylor - - * psapi.h: New file. - -Thu Aug 4 10:28:00 Corinna Vinschen - - * security.cc: Eliminate MALLOC_CHECK calls. - (lookup_name): New function simplifies the retrieval of user and group - names. - (alloc_sd): Call `lookup_name' instead of `LookupAccountName'. - * shared.cc (sec_user): Call `lookup_name' instead of - `LookupAccountName'. Eliminate 'free' call on stack space. - * winsup.h: Declare `lookup_name'. - -Wed Aug 4 16:24:02 1999 Christopher Faylor - - * a.out.h: Fix cut and paste from mime email typos. - -Mon Aug 2 19:08:48 1999 Christopher Faylor - - * Makefile.in: Fix utils dependency. Make clean more assertive. - * path.cc (mount_info::conv_to_win32_path): Fill in correct destination - when a device name is detected. - * syscalls.cc (chown): Always succeed when referencing a cygwin device. - (chmod): Ditto. - * net.cc (get_ifconf): Eliminate holdover from previous change. - -Mon Aug 2 13:07:44 1999 Christopher Faylor - - * dcrt0.cc (do_global_ctors): Remove previous change. It was just - wrong. - -Sun Aug 1 23:21:28 1999 Christopher Faylor - - Throughout rename 'slave_alive' handle to 'inuse'. - * shared.h: Implement tty_attached() macro to determine when an actual - tty is associated with the process. - (class tty): Add some methods for manipulating an "inuse" event that is - common to both master and slave parts of a tty. - * dcrt0.cc (do_exit): Use tty_attached() to determine if signal should - be sent to process group. - * external.cc (fillout_pinfo): Return -1 if tty is not attached (i.e, - attached to a console). - * fhandler.h: Move more stuff into fhandler_tty_common and out from sub - classes. - * fhandler_console.cc (fhandler_console::read): Send SIGWINCH signal to - *correct* process group. - (fhandler_console::open): Fix incorrect argument ordering in set_ctty. - (fhandler_console::de_linearize): Remove unneeded handle resets. - * fhandler_tty.cc (fhandler_tty_slave::open): Fix incorrect argument - ordering in set_ctty. Use tty create_inuse method to create inuse - event. - (fhandler_tty_slave::close): Delete. - (fhandler_tty_slave::dup): Delete. - (fhandler_tty_slave::write): Minor cleanup of flow of control. - (fhandler_tty_common::dup): Subsume fhandler_tty_slave dup method. - (fhandler_pty_master::fhandler_pty_master): Zero inuse field. - (fhandler_pty_master::open): Set inuse field. - (fhandler_tty_common::close): New, superclass method. - (fhandler_tty_common::set_close_on_exec): Handle inuse field. - (fhandler_tty_common::fixup_after_fork): Ditto. - (fhandler_tty_slave::set_close_on_exec): Delete. - (fhandler_tty_slave::fixup_after_fork): Delete. - * path.cc (get_device_number): Use tty_attached() to figure out - /dev/tty. - * select.cc (peek_console): Send SIGWINCH signal to *correct* process - group. - * tty.cc (tty::master_alive): New method. - (tty::create_inuse): New method. - -Sun Aug 1 16:23:22 1999 Christopher Faylor - - * net.cc (get_ifconf): Use alloca for temporary buffer. - -Sun Aug 1 01:38:20 1999 Christopher Faylor - - Modify de_linearize methods throughout to set unix and msdos path - names. - * dcrt0.cc (do_exit): Only remove shared memory when we're done with - it. - * exceptions.cc (try_to_debug): Move static variable outside of the - function so that it can more easily be set with gdb. - * fhandler_console.cc (fhandler_console::open): Handles are typically - hexadecimal in debugging output. - (fhandler_console::open): Do not open inherit console handles by - default. - (fhandler_console::dup): Just use open method to "duplicate" a console - handle. - (fhandler_console::fixup_after_fork): Do *not* close handles here since - they have not been inherited. - (fhandler_console::de_linearize): Ditto. - * utils/strace.cc (create_child): Correct debugging flags when not - tracking forked processes. - -Sat Jul 31 20:10:58 1999 Christopher Faylor - - * dcrt0.cc (do_global_ctors): Ensure that ctors are not called more - than once per session. - * fork.cc (fork): Use sig_protect to protect against signals during - fork. - * pinfo.cc (lpfu): Show windows pid in debugging message as this is - generally more useful. - * pinfo.cc (unlock_pinfo): Issue an error if ReleaseMutex fails. - (pinfo::record_death): Actually unlock pinfo on exit rather than allow - ExitProcess to do this since ExitProcess can sometimes take a *long* - time. - * spawn.cc (spawn_guts): Ensure that pinfo is always unlocked. - -Thu Jul 29 23:43:24 1999 Christopher Faylor - - Throughout, consolidate pgid processing for console and tty into - fhandler_termios and tty_min. - * debug.h: Make WF?O functions the defaults for dealing with Waits. - These functions attempt to work around signal interrupt problems. - * debug.cc: Ditto. - * exceptions.cc (call_handler): Don't wait a long time for second - attempt to get signal mutex. - * fhandler_console.cc (fhandler_console::open): Set the "controlling - tty". - * fhandler_termios.cc: Move the ctty and pgid functions here. - (fhandler_termios::line_edit): Fix debug output. - * fhandler_tty.cc (fhandler_tty_slave_write): Use sig_protect to - protect against output_mutex deadlock. - * fork.cc (get_vfork_val): Conditionalize with NEWVFORK. - * syscalls.cc (setsid): Add debugging output. - (setpgid): Reorganize and add debugging output. - * tty.cc (tty::init): Use a method to clear the sid. - -Thu Jul 29 23:42:53 1999 Christopher Faylor - - Patch from Egor Duda : - * grp.cc (read_etc_group): Use a default /etc/group entry when one - doesn't exist. - (getgrgid): Ditto. - * passwd.cc (read_etc_passwd): Use a default /etc/passwd entry when one - doesn't exist. - (search_for): Ditto. - * uinfo.cc (read_etc_group): Remove some defines. - * winsup.h: Move them here. - -1999-07-29 Bernd Schmidt - - * Makefile.in (SUBDIRS_AFTER): Build mingw before utils. - * utils/Makefile.in (MINGW_LDFLAGS): Add "-B../mingw/" - - -Tue Jul 27 23:31:28 1999 Christopher Faylor - - * dcrt0.cc: Add experimental vfork_storage initialization. - (do_exit): Ditto. - * exec.cc: Use _spawnve throughout as a common interface for execing a - program. - * fork.cc (vfork): Add beginnings of true vfork support. - * path.cc (sort_by_posix_name): Remove special casing of zero length - names since they should now be eliminated earlier on. - (sort_by_native_name): Ditto. - (mount_info::del_item): Remove hole from mount table specifically, here - or suffer weird behavior. Suggested by Andrew Dalgleish - . - * shared.cc: Make SHAREDVER "unsigned" to avoid a compiler warning. - * spawn.cc : Accommodate additional argument to _spawnve, throughout. - (_spawnve): Make this a global function and take an hToken argument so - that it can be used by sexecve. Accommodate experimental vfork - functionality. - * winsup.h: Add initial support for per-thread vfork stuff. - * include/cygwin/version.h: Bump shared memory version number. - -Mon Jul 26 20:59:58 1999 Christopher Faylor - - * path.cc (sort_by_posix_name): Report two zero length strings as being - equal or suffer an infinite loop. - (sort_by_native_name): Ditto. - * shared.cc (shared_info::initialize): Refuse to use a different DLL's - shared memory. - * shared.h: Fix mask for child_info sanity test. - -Sun Jul 18 16:30:31 1999 Christopher Faylor - - * security.cc: Various changes from Corinna. - -Sat Jul 17 22:33:45 1999 Christopher Faylor - - * fork.cc (fork): Change DuplicateHandle slightly. - * security.cc (get_nt_attribute): Ignore error return from - set_process_privileges. - (set_nt_attribute): Ditto. - -Sat Jul 17 00:45:34 1999 Christopher Faylor - - * debug.h: Fix ForceCloseHandle1 in non-debug case. - -Fri Jul 16 23:47:31 1999 Christopher Faylor - - * sigproc.cc (proc_can_be_signalled): Accommodate different flavors of - myself. - * include/ddeml.h: Add missing struct. - * include/wingdi.h: Add missing defines. - -Fri Jul 16 23:01:30 1999 Christopher Faylor - - * Makefile.in: Attempt to cope when srcdir is a relative pathname. - * fork.cc (fork): Pass handle to parent process to fixup_after_fork. - Eliminate excess unlock_pinfos. - * hinfo.cc (hinfo::fixup_after_fork): Use inherited parent handle - rather than try to open the parent process explicitly. - * pinfo.cc (record_death): Cosmetic change. - * sigproc.cc (wait_sig): Add a debugging statement. - * winsup.h: Reflect change of argument for fixup_after_fork. - -Fri Jul 16 11:07:55 1999 Christopher Faylor - - * shared.h: Eliminate record_death_nolock. Just pass an argument to - record_death. - * pinfo.cc (record_death_nolock): Ditto. - * dcrt0.cc (__api_fatal): Use record_death with FALSE argument rather - than record_death_nolock. - * exceptions.cc (really_exit): Ditto. - * fork.cc (fork): Remove debugging statement. - -Wed Jul 14 22:08:52 1999 Christopher Faylor - - Throughout, make parent_alive a local variable. Rename 'alive_parent' - to 'my_parent_is_alive'. - * autoload.h: Improve the description of the autoload mechanism. - * dcrt0.cc: Define parent_alive here. - (dll_crt0_1): When debugging, rotect handles inherited from fork/exec. - Force signal thread to finish initializing prior to calling main. - (dll_crt0): Reorganize child_info stuff to allow common initialization. - Accept parent_alive handle from invoker and ensure that this is not - inherited by other processes. - (do_exit): Ensure that exit_state is not duplicated by a fork. - (__api_fatal): Call 'try_to_debug' directly. - * debug.cc: Increase the size of the handle list. - (threadname): Add an optional argument to control locking. - * exceptions.cc (error_start_init): Make this a "C" function. - (try_to_debug): Ditto. Also, use Sleep rather than pause and loop so - that gdb can get in to interrupt things. - (sig_handle): - * external.cc (fillout_pinfo): Reorganize slightly and plan for the - future. - * fhandler.h: Add an argument to show the name of the handle for error - messages to fork_fixup. - * fhandler.cc (fhandler_base::fork_fixup): Ditto. - (set_inheriting): Rename a variable for clarity. - (fhandler_base::fixup_after_fork): Pass in the name of the handle to - fork_fixup. - * fhandler_tty (fhandler_tty_common:fixup_after_fork): Ditto. - (fhandler_tty_slave:fixup_after_fork): Ditto. - (fhandler_tty_master:fixup_after_fork): Ditto. - * fhandler_windows.cc (fhandler_windows::fixup_after_fork): Ditto. - * fhandler_console.cc (fhandler_console::open): Specifically open - console with ENABLE_PROCESSED_INPUT. - * fork.cc (sync_with_child): Call abort when DEBUGGING and there's an - error. - (resume_child): Ditto. Also, allow an ERROR_INVALID_HANDLE error if it - can't be duplicated as they seem to occur occasionally when the parent - copies the stack. - (fork): Use init_child_info to initialize structure passed to child. - Remove start time setting in favor of common function. Don't mess with - parent's parent_alive. - * heap.cc (sbrk): Simply code slightly. - * hinfo.cc (hinfo::dup2): Improve error handling. - * pinfo.cc (set_myself): Set start time here since it is called by - everything which sets myself. - (pinfo_init): Remove start_time setting in favor of common function. - * shared.h (pinfo): Reorganize so that signal stuff falls into section - of pinfo which is automatically zeroed when a new pid is initialized. - (PROC_MAGIC): Increment to detect cygwin1.dll's memory passing - disparities. - * sigproc.cc (proc_alive): Make this a function. Wait for target pid - to initialize. - (my_parent_is_alive): Rename from alive_parent. - (proc_can_be_signalled): Renamed from proc_alive macro. - (proc_exits): Use proc_can_be_signaleed(). - (proc_subproc): Don't put parent_alive in child. - (proc_terminate): Close hwait_subproc in a race-safe way. Ditto - sync_proc_subproc. - (sigproc_terminate): Always terminate proc_subproc thread first or it - may try to use signal thread as it is going away. Wait for signal - thread to exit. - (sig_send): Use proc_can_be_signalled(). - (init_child_info): New function. Initializes memory block passed by - spawn/fork. - (mutex_stack): Add thread name field. - (sig_wait): Set active state after all handles have been set up and - before protecting the handles. Use ForceCloseHandle to close - subproc_ready as it is now protected. Close signal_mutex here. - * sigproc.h: Accommodate alive_parent rename. - * spawn.cc Use init_child_info to initilize memory block passed to - subprocess. - * strace.cc (__system_printf): Write to screen before writing to strace - log. Only write to strace log if we're actually stracing. - * winsup.h: Declare the 'action on error' functions. - * utils/Makefile.in: (Patch from Egor Duda ) Compile - strace using -mno-cygwin. - * utils/strace.cc: Allow ingw concession from Egor Duda. Attempt to - allow CTRL-C when stracing. - -Thu Jul 14 0:39:00 Corinna Vinschen - - * security.cc (alloc_sd): Delete special handling of uid/gid 513. - -Thu Jul 13 15:01:00 Corinna Vinschen - - * fhandler.cc (get_file_owner): Fix typo. - * path.cc (path_conv::path_conv) : Change `return' to `goto end' in - case of SYMLINK_IGNORE is set. - -Mon Jul 5 21:33:00 Corinna Vinschen - - * security.cc (WriteSD): Doesn't set errno if BackupWrite() - returns ERROR_INVALID_SECURITY_DESCR (which happens on FAT). - -Sat Jul 10 13:17:20 1999 Christopher Faylor - - * utils/strace.cc (error): Actually output error message. - (add_child): Duplicate inherited child process handle with all of the - privileges that we need. - -Fri Jul 9 01:37:23 1999 Geoffrey Noer - - * include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR to 14 - in honor of snprintf and vnsprintf additions. - -Fri Jul 9 00:04:03 1999 Christopher Faylor - - * path.cc (path_conv::path_conv): Correct buffer overflow condition. - * fhandler_console.cc (fhandler_console::open): *Need* to enable - processed input or CTRL-C won't stop anything unless it's at a prompt. - (fhandler_console::input_tcsetattr): Ditto. - -Thu Jul 8 18:27:49 1999 Christopher Faylor - - * Makefile.in: Add malloc debugging options. - * dcrt0.cc (api_fatal): Call abort when debugging so that the debugger - will pop up. - * debug.cc (close_handle): Unlock in pathological case. - * fhandler_console.cc (fhandler_console::read): Always respond to - windows size changes. - (fhandler_console::open): Always set things to ~ENABLE_PROCESSED_INPUT - so that we can control INTR character. Don't set pgid here. - (fhandler_console::input_tcsetattr): Turn on windows event so that we - can see screen resizes. - (fhandler_console::init): Don't set pgid here. - * fhandler_termios (fhandler_termios::tcinit): Set pgid here. - * fhandler.h: Fix set_has_acls method return. - * utils/strace.h: Pass CTRL-Cs to child process. - -Wed Jul 7 23:59:50 1999 Christopher Faylor - - * Makefile.in: Improve dependencies. - * autoload.h: Work around "function unused" messages for autoload init - functions. - * configure.in: Use CHECK_TOOL to find CC so that it will get the - proper host alias. - * configure: Regenerate. - * dcrt0.cc (do_exit): Minor reorganization of termination function - calls. - * debug.cc (close_handle): Issue an error when an attempt is makde to - close a handle with a name different from the one used to record it - previously. - * debug.h: Implement new macros for storing arbitrary handle names. - * exceptions.cc (handle_signal): Terminate the main thread when exiting - due to signal in signal thread. - * fhandler.h: Add an extra 'fd' argument to all ready_for_read methods. - * select.cc: Ditto, throughout. - * fhandler_console (get_tty_stuff): Protect the tty_stuff handle here. - * fhandler_termios.cc (fhandler_termios::line_edit): Accommodate fd - argument to ready_for_read. - * fhandler_tty.cc (fhandler_tty_master::init): Close an unneeded thread - handle. - * fork.cc (fork): Use standard name when protecting process handle. - * spawn.cc (spawn_guts): Ditto. - * shared.cc (open_shared_file_map): Protect cygwin_shared handle here. - * sigproc.cc: Throughout, close child process handle using standard - name. - * syscalls.cc (read_handler): Check that fd is still open prior to - performing an operation. Supply fd argument for ready_for_read. - * (_read): Supply fd argument for read_for_read. - * tty.cc (tty_list::terminate): Close unneeded handles as tty is - closing down. - (tty_list::allocate): Protect against signals. - -Mon Jul 5 14:52:40 1999 Christopher Faylor - - * cygwin.din: Export new snprintf and vnsprintf functions courtesy of - Egor Duda . - -Sun Jul 4 23:54:43 1999 Christopher Faylor - - * exceptions.cc (sigbegin): New function. Called prior to dispatching - to signal handler. - (sigreturn): New function. Called after signal handler returns. - (set_process_mask): Make stdcall. - (call_handler): Remove sigwrap asm stuff in favor of new - sigbegin/sigreturn scheme. - * winsup.h: Change set_process_mask declaration. - -Sun Jul 4 22:00:14 1999 Christopher Faylor - - * syscalls.cc (stat_worker): Previous change to check for extension - found dots not in the filename part. Fix this. - -Sat Jul 3 23:22:55 1999 Christopher Faylor - - * include/wincon.h: Add some missing defines. - * environ.cc: Remove extern which is now in winsup.h. - * fhandler.cc (get_file_owner): Rename argument. Test for allow_ntsec. - (get_file_group): Ditto. - (fhandler_disk_file::fstat): Use new method inode checking. - * fhandler.h: Rename a method. - * security.cc (set_file_attribute): Take an additional argument to - determine if ntsec security setting should be used. - * dir.cc (mkdir): Pass acl info to set_file_attribute. - * syscalls.cc (chown): Ditto. - (chmod): Ditto. - * winsup.h: Define allow_ntsec here. - -Sat Jul 3 15:09:34 1999 Christopher Faylor - - * fhandler.cc (fhandler_disk_file:;fstat): Move check of disk volume to - path_conv. Use new methods for determining if file system is ACL - capable. - (fhandler_disk_file::open): Set "has acls" flag here. - * fhandler.h: Store acl information in fhandler base class. - * path.cc (path_conv): Set acl information on successful return. - * path.h: Add acl info to path_conv class. - * security.cc (get_file_attribute): Set ENOSYS if can't get extended - attributes. - * syscalls.cc (chown): Pass acl information from path_conv to - get_file_attributes. - (chmod): Ditto. - (stat_worker): Ditto. - * uinfo.cc: Make all exported functions extern "C". - * winsup.h: Add rootdir() declaration. - -Fri Jul 2 15:13:08 1999 Christopher Faylor - - * autoload.h: New file. - -Thu Jul 1 23:16:34 1999 Christopher Faylor - - * net.cc (cygwin_gethostname): Use new win32_gethostname to - disambiguate between cygwin and winsock version. - * tty.cc (creat_tty_master): Disambiguate by using cygwin_gethostname - to find the hostname. - * winsup.h: Declare cygwin_gethostname. - -Thu Jul 1 22:36:31 1999 Christopher Faylor - - Throughout, remove check for winsock initialization and indirect - references to winsock functions in favor of new dynamic DLL loading - method. - - * Makefile.in: Remove unneeded libraries. - * cygwin.din: Make gethostname == cygwin_gethostname like other network - functions. - * dcrt0.cc: Implement new "autoload" functionality for loading DLLs and - functions as they are needed. Add autoload functions for user32.dll. - (cygwin_dll_func_load): New function. - (dll_crt0): Issue a fatal error message if attempt to mix different - version DLLs is detected. - (api_fatal): Correct inexplicable use of buf + 8 when printing error - message into a buffer. - * fhandler.h: Cosmetic fixes. - * fhandler_tty.cc (fhandler_tty::close): Temporarily "if 0" out code - which sends EOF pulse to children. This should only happen when last - parent fd closes. - * heap.cc (sbrk): Implement new sbrk mechanism which returns memory to - Windows when top of heap decreases beyond a page boundary. - (getpagesize): New function. - * fork.cc (fork): Save new heap values in stuff passed to child. - * hinfo.cc (hinfo::build_fhandler): Don't do any checking on a handle - if the handle is NULL. Assume that it is a disk file. - * net.cc: Redo winsock functions to use dynamic loading scheme. - * shared.cc (shared_info::initialize): Cosmetic change. - * shared.h: Change magic number for memory block sent to child - processes. Accommodate new heap information in child_info. - * sigproc.cc (sig_dispatch_pending): Remove some memory debugging checks. - (__release_signal_mutex): Ditto. - * syscalls.cc (stat_worker): Don't attempt the .exe hack unless the - previous attempt to open the file resulted in an "ERROR_FILE_NOT_FOUND" - and the file did not already contain an extension. - * times.cc: Initialize static NO_COPY variables throughout or they will - not actually be NO_COPY. - * winsup.h: Rename heap fields in per_process to accommodate new sbrk. - Eliminate winsock stuff invalidated by dynamic loading change. - * include/winsock.h: Make this file C++ safe. - -Sun Jun 27 17:07:34 1999 Christopher Faylor - - * debug.h: Don't define MALLOC_DEBUG by default. - * fhandler.cc (fhandler_base::set_name): Always set names to NULL. Add - more slop to end of win32_path_name. - (fhandler_base::de_linearize): Set names to NULL. They'll be assigned - by the caller. - (fhandler_disk_file::get_native): Delete. - * fhandler.h: Ditto. - * hinfo.cc (hinfo::de_linearize_fd_array): Set path names after the - structure has been "delinearized". - * malloc.cc: Add debugging versions of malloc functions. - * syscalls.cc (stat_worker): Eliminate static buffer for thread safety. - -Wed Jun 23 22:53:00 Corinna Vinschen - - * fhandler.cc (fhandler_disk_file::fstat): If get_file_attribute() - signals a nonexistant acl, fstat sets default attributes now. - -Wed Jun 23 10:22:56 1999 Geoffrey Noer - - * include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR to 13. - -Wed Jun 23 10:39:07 1999 Mumit Khan - - * cygwin.din (gamma, gammaf, lgamma, lgammaf): Export. - (j0,j0f,j1,j1f,jn,jnf): Export underscore versions as well. - -Mon Jun 21 21:34:06 1999 Christopher Faylor - - Sprinkle MALLOC_CHECK macro throughout. When turned on, this will give - a slightly better idea of where memory corruption occurs. Add slightly - modified versions of "error_start" code from Egor Duda - . - * Makefile.in: Add `utils' target. - * dcrt0.cc (do_exit): Attempt to detect loop conditions where do_exit - is called reentrantly and avoid the previously executed code in this - case. - * debug.h: Define MALLOC_CHECK macro for use with malloc debugging. - * environ.cc (environ_init): Add more slop at end of environ string - just to work around buggy programs. - (parse_options): Add error_start option to control core dumping or gdb - invocation. - * exceptions.cc (stackdump): New function. Dumps stack to stderr. - (error_start_init): New function. Initialize action on "core dumping" - error. - (handle_exceptions.cc): Use stackdump command to dump stack. Call - try_to_debug. - (set_process_mask): Must be __stdcall or compiler get's confused. - (sig_handle): Detect SIGQUIT and SIGABRT. Do a "stackdump" for these. - * fhandler.cc (get_file_owner): Add an argument to determine if - function should check for NT security. - (get_file_group): Ditto. - (fhandler_base::set_name): Don't free "fhandler_disk_dummy_name" path - names. - (rootdir): New function, pulled from the pages of syscalls.cc. - Determines the root dir of a given path. - (fhandler_disk_file::fstat): Get volume information of file in question - to determine if inodes are permanent and acls are available. This - replaces previous WinNT test. - (fhandler_base::~fhandler_base): free "fhandler_disk_dummy_name" path - names. - * fhandler.h: Change get_file_* declarations. - * fhandler_console.cc: Back out most of scroll fixes from April 17. - They caused weird scrolling behavior. - * fhandler_tty.cc (fhandler_pty_master::accept_input): Add debugging - message. - * security.cc (get_file_attribute): Add additional "check for ACL" - argument. - * path.cc (symlink_check_one): Use new argument to get_file_attribute. - * sigproc.cc (wait_subproc): Don't exit wait loop if WaitForMultipleObject - returns an error. Instead, loop for a while in case this is an expected - error. - * sigproc.h: Remove __stdcall from set_process_mask. - * spawn.cc (linebuf): Use initializers to set initial values. - (linebuf::append): Be defensive and ensure that enough space is - allocated for the new argument. - (linebuf::prepend): Ditto. - (spawn_guts): Correct logic which broke up program argument in a #! - script. - * syscalls.cc (chown): Use new argument to get_file_attribute. - (chmod): Use new argument to get_file_owner and get_file_group. - (stat_worker): Ditto. - (statfs): Break out code that determined the root directory of a given - path. Use new rootdir function instead. - * winsup.h: Reflect new get_file_attribute argument. - * include/sys/strace.h: Add "NOTALL" flag so that voluminous debugging - output can be avoided. - * utils/strace.cc: Honor NOTALL flag. Run at a higher priority. - -Mon Jun 14 18:33:08 1999 Christopher Faylor - - * syscalls.c (stat_worker): Consolidate calls to fh.fstat for both - directories and normal files. - * fhandler_tty.cc (fhandler_pty_master::close): Ensure that an "EOF - pulse" is sent to any executing child processes. - * path.cc (symlink_check_one): Check for ':\n' as well as '#!' to - determine if a file is executable. - -Mon Jun 14 16:04:00 1999 Christopher Faylor - - * fhandler_tty.cc (fhandler_pty_master::accept_input): Set read_retval - prior to performing a write to avoid a potential race condition. - * fhandler_termios.cc (fhandler_termios::line_edit): Don't set - read_retval here. It has to be set in an fhandler_tty accept_input. - * select.cc (peek_pipe): Fix typo which caused read_selected to be - tested twice rather than except_selected. - * shared.h (class tty_min): Remove read_retval from here. - (class tty) Put it here. - -Mon Jun 14 13:08:58 1999 Christopher Faylor - - * utils/Makefile.in: Consolidate and simplify. - -Mon Jun 14 12:43:32 1999 Christopher Faylor - - Throughout, remove reliance on strace_* fields in pinfo class. Use - global instead. Remove STRACE_DUMP and STRACE_CACHE logic. - * pinfo.cc (set_myself): New function. - * dcrt0.cc (dll_crt0_1): Use the new function. - * environ.cc (parse_options): Remove strace environment variable logic. - (environ_init): Ditto. - * exceptions.cc (call_handler): Remove strace mutex considerations. - * fhandler_termios (fhandler_termios::line_edit): Remove STRACE_CACHE - logic. - * localtime.cc: Define 'lint' to eliminate warnings. - * smallprint.c (__small_vsprintf): Remove text formatting of windowss - errors. This is now done in the 'strace' program. - * strace.cc: Define 'strace_active' variable to control whether strace - should be carried out. - (strace_open): Delete. - (strace_init): Delete. - (get_strace_mutex): Delete. - (release_strace_mutex): Delete. - (strace_vsprintf): Preserve last error. - (strace_write): Communicate with strace program using - OutputDebugString. - (strace_dump): Delete. - (mark): Gut. - * winsup.h: Remove a declaration. Add a new one. - * include/sys/strace.h: Modify to accommodate new strace scheme. - * utils/Makefile.in: Build strace.exe - * utils/strace.cc: New file. - -Sat Jun 12 22:22:00 1999 Corinna Vinschen - - * fhandler.cc (fhandler_disk_file::fstat): Must compute i-node numbers - via `get_namehash' for Windows 9x. - -Sat Jun 12 10:54:00 1999 Corinna Vinschen - - * fhandler.cc (fhandler_base::read): Returns correct value - if raw_read fails. - * fhandler_raw.cc: More trace output. - * fhandler_floppy.cc: Ditto. - * fhandler_tape.cc: Ditto. - -Thu Jun 10 14:01:05 1999 Christopher Faylor - - * exceptions.c (handle_exceptions): Use ".stackdump" - extension instead of ".core". - * path.cc (mount_info::read_mounts): Prescan the mount lists - for /cygdrive stuff to delete rather than attempting to - delete it in the main "add mount loop". - (mount_item::getmntent): Fix "system"/"user" determination. - * winsup.h: Use void methods in thread classes where - appropriate. - -Wed Jun 9 23:16:04 1999 Christopher Faylor - - * mkvers.sh: Issue error if can't find version information. - -1999-06-09 DJ Delorie - - * localtime.c: new file; public domain timezone handling routines. - * tz_posixrules.h: new file; POSIX default timezone data - * times.cc: comment out localtime, gmtime, replace tzset with - cygwin_tzset - * Makefile.in: add localtime.c - -Wed Jun 9 00:49:04 1999 Christopher Faylor - - * spawn.cc (spawn_guts): Correctly handle #! processing when line - ends with white space. Also correctly handle scripts that do not - begin with #!. - -Mon Jun 7 17:04:36 1999 Christopher Faylor - - * fhandler_console.cc (fhandler_console::open): Need to initialize - tc here, too. - (fhandler_console::init): Initialize tc earlier. - -Mon Jun 7 00:02:51 1999 Christopher Faylor - - * fhandler.h (fhandler_termios): Move tc initialization - into init method, etc. - (fhandler_tty_common): Ditto. - * fhandler_console.cc (fhandler_console::fhandler_console): - Move tc initialization to init method. - (fhandler_console::init): Initialize tc stuff here. - (fhandler_console::dup): Ditto. - (fhandler_console::fixup_after_fork): Ditto. - (fhandler_console::de_linearize): Ditto. - * fhandler_termios (tcinit): Rename constructor. - Accept force argument to force termios initialization. - * fhandler_tty.cc (fhandler_tty_master::init): Move tc initialization - to common_init. - (fhandler_tty_common::dup): Use tcinit () to initialize tc field. - * tty.cc (tty::common_init): Ditto. - -Sun Jun 6 22:19:09 1999 Christopher Faylor - - * tty.cc (tty_list::terminate): Add \n to output message. - (tty::init): Clear slave_opened field or we can't reopen - ttys. - -Fri Jun 4 23:58:17 1999 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_slave::open): Reorganize - slightly to avoid a race with get_ttyp()->was_opened. - -1999-06-04 DJ Delorie - - * times.cc (totimeval): scale sub properly. - (gettimeofday): don't bias by timezone. - -Thu Jun 3 13:24:17 1999 Christopher Faylor - - * fhandler.h (fhandler_tty_common): Add two new methods. - * fhandler_tty.cc: Use new {acquire,release}_output_mutex - methods throughout for output_mutex. - (fhandler_tty_common::__acquire_output_mutex): New method. - (fhandler_tty_common::__release_output_mutex): New method. - * shared.h (get_output_mutex): Rename to open_output_mutex. - -Wed Jun 2 16:06:26 1999 Geoffrey Noer - - * utils/mkpasswd.c (main): account for long int args to printfs. - -Wed Jun 2 16:08:08 1999 Christopher Faylor - - * smallprint.c (__small_vsprintf): Conditionalize display of - textual messages under CYGWIN_TEXT_ERROR. - * ntea.cc: Remove debugging code. - -Wed Jun 2 16:04:00 1999 Corinna Vinschen - - * dcrt0.cc (dll_crt0_1): Call the functions `get_admin_sid', - `get_system_sid' and `get_world_sid' before heap initialization - to avoid heap fragmentation. - * security.cc (get_nt_attribute): Don't allocate memory - anymore. All memory is taken from stack. - (set_nt_attribute): Ditto. - (alloc_sd): Ditto. Change parameters to get a pointer to a - preallocated security descriptor and a pointer to it's length. - * shared.cc (sec_user): Don't allocate memory anymore. All - memory is taken from stack. Change parameters to receive a - pointer to a preallocated security buffer. - * shared.h: Change prototype for `sec_user' and `sec_user_nih'. - * sigproc.cc (getsem): Change call to `sec_user'. Additonally - buffer for `sec_user'. - * spawn.cc (spawn_guts): Ditto. - Change all error output in function `sec_user' and in module - `security.cc' from error text to error number output. - -Tue Jun 2 21:54:21 1999 Corinna Vinschen - - * net.cc (get_if_flags): Change the UP and RUNNING state - of disconnected RAS interfaces to true. - -Thu Jun 1 22:47:00 1999 Corinna Vinschen - - * security.cc (get_system_sid): New function to create - a SID for the well known group of local system. - (alloc_sd): New function. - (alloc_sd): Give ALL permissions to `system'. - * shared.cc (sec_user): Give ALL permissions to `system'. - (sec_user): Provide additionalparameter for a second SID. - This is used for `CreateProcessAsUser' call. - (sec_user_nih): Ditto. - * shared.h: Change prototypes for `sec_user' and - `sec_user_nih'. - * spawn.cc (spawn_guts): Now using `sec_user' in - `CreateProcessAsUser' call, if ntsec is set. - -Thu Jun 1 14:17:00 1999 Corinna Vinschen - - * utils/mkpasswd.c: Change to output native names of - well known groups `Everyone' (SID 0) and `system' (SID 18). - * utils/mkgroup.c: Ditto plus output of native name of - well known group `None' (SID 513). - -Mon May 31 22:10:57 1999 Christopher Faylor - - * path.h: Use bit mask flags in path_conv to save exec, - symlink, binary status. Use methods to access and set - these flags. - * fhandler.cc: Use methods to access path_conv flags - throughout. - * path.cc: (symlink-check_one): Accept a bitmask flags - variable to accommodate path_conv changes. - (path_conv::path_conv): Propagate path_flags from mount - table to path_conv class. Avoid walking the mount table - twice to find "binary" info. - (mount_info::conv_to_win32_path): Accept additional flags - argument. Don't add trailing slash if not required. - Fill out both paths when cygdrive. - (mount_info::cygdrive_win32_path): Change debugging output - slightly. - (mount_info::set_flags_from_win32_path): Generalize from - mount_info::binary_win32_path_p. - (mount_item::getmntent): Honor MOUNT_EXEC flag. - * shared.h: Add new method to mount_info class. - * include/sys/mount.h: Add a comment. - * utils/mount.cc: Accept -x to force a mountpoint to default - to executable permission. Rename automount stuff to cygdrive. - -Mon May 31 19:00:00 1999 Corinna Vinschen - - * environ.cc (environ_init): Set ntsec option by default - if running under NT. - * security.cc (set_nt_attribute): Delete superfluoues code. - * shared.cc (sec_user): Don't set owner in created security - descriptor. - * sigproc.cc (getsem): Use `sec_user' instead of `sec_user_nih'. - * spawn.cc (spawn_guts): Set security attribute of - `CreateProcess' to `sec_user' if ntsec is set, `sec_all_nih' - otherwise. - -Mon May 31 19:27:36 1999 Christopher Faylor - - Throughout, change "automount" to cygdrive. - Throughout, change mount flags from signed to unsigned. - - * path.cc (iscygdrive): New macro. - (normalize_posix_path): Tack a '/' on the end of constructed - path only if there isn't one there already. - (mount_info::init): Simplify slightly. - (mount_info::conv_to_win32_path): Don't search for automount - stuff in the mount table. Instead special case the cygdrive - handling so that it will always be acceptable to use /cygdrive - regardless of other mounts. - (mount_info::cygdrive_posix_path): Rename from - build_automount_mountpoint_path. Fully build a posix path - given inputs. - (mount_info::cygdrive_win32_path): New function. - (mount_info::conv_to_posix_path): Precalculate the length - of the pathbuf for multiple uses. Just use cygdrive_posix_path - to derive a /cygdrive/x/foo style path. - (mount_info::read_mounts): Don't read /cygdrive/x mounts from - the registry. Delete them. - (mount_info::from_registry): Read cygdrive info earlier for - subsequent use by other mount routines. - (mount_info::add_reg_mount): Cosmetic changes. - (mount_info::read_cygdrive_info_from_registry): Always add - trailing slash to cygdrive. Precalculate the length of the - cygdrive. - (mount_item::getmntent): Cosmetic changes. - (mount): Return EINVAL on attempt to add a mount point which - begins with the current cygdrive. - * path.h: Remove unused script_p from path_conv class. - * shared.h: Add cygdrive_length to mount_list. Add new - cygdrive_win32_path method. - * include/sys/mount.h: Use enums for MOUNT_ constants. - -1999-05-29 Keith Seitz - - * errno.cc (errmap): Map ERROR_NEGATIVE_SEEK to EINVAL. - -Fri May 28 21:43:56 1999 Christopher Faylor - - * times.cc (to_time_t): Rewrite slightly to avoid compiler - overoptimization. - -Fri May 28 21:10:33 1999 Corinna Vinschen - - * sigproc.cc (getsem): Set security attribute of process - semaphore to `sec_user_nih()', if ntsec is set, `sec_none_nih' - otherwise. - -Wed May 26 22:56:51 1999 Christopher Faylor - - Rename inuse_event and inuse_event_exists to "slave_alive" - throughout. - * shared.h: Eliminate inuse_event. Replace with a boolean. - Elminate slave_opened. - Add some function declarations used by new methods. - * fhandler_tty.cc (fhandler_pty_master::hit_eof): Use better - method for determining EOF for pty master. - (fhandler_tty_slave::open): Use method to acquire output_mutex. - Always create "inuse_event". Delete call to slave_opened. - (fhandler_tty_slave::write): Reorganize debugging output - slightly. - (fhandler_tty_master::close): Eliminate reference to inuse_event. - * tty.cc (tty_list::terminate): Eliminate call to slave_opened. - (tty_list::connect_tty): Use new exists() method to find out if - a tty exists. - (tty_list::allocate_tty): Rename argument for clarity. Use - new exists method to determine tty existence. - (tty::inuse): Delete. - (tty::init): Remove reference to inuse_event. - (tty::common_init): Ditto. - (tty::slave_opened): Delete. - * winsup.h: Move some function declarations to shared.h. - -Mon May 24 22:10:34 1999 Corinna Vinschen - - * security.cc (WriteSD): Don't set errno, if BackupWrite() - returns ERROR_NOT_SUPPORTED. - * security.cc (set_nt_attribute): Change condition for - calling LookupAccountName() with domain name again. - * shared.cc (sec_user): Ditto. - -Mon May 24 22:10:34 1999 Corinna Vinschen - - * include/winnt.h: Temporary erased definitions of QuadPart - in LARGE_INTEGER and ULARGE_INTEGER. - * security.cc (set_nt_attribute): Set standard attributes so - that reading and writing attributes for user and administrators - isn't hindered. - -Mon May 24 22:10:34 1999 Corinna Vinschen - - * security.cc (ReadSD): New function. - * security.cc (WriteSD): Ditto. - * security.cc (get_admin_sid): Moved from shared.cc. - * security.cc (set_process_privileges): Moved from syscalls.cc, - shortened, changed return typ to int. Sets errno now. - * security.cc (set_file_attributes): Return type changed to int. - * security.cc (get_file_attributes): Ditto. - * security.cc (set_nt_attributes): Ditto. Cares for setting - of S_ISVTX now. - * security.cc (get_nt_attributes): Ditto. - * syscalls.cc (rel2abssd): #if 0'ed. - * syscalls.cc (set_process_privileges): Moved to security.cc. - * syscalls.cc (chown): Rewritten. - * syscalls.cc (chmod): Change call order of the functions - set_file_attributes() and SetFileAttributesA(). - * fhandler.cc (fhandler_base::fstat): Change check for - return value of get_file_attributes(). - * ntea.cc (NTReadEA): returns TRUE now, if allow_ntea is unset. - * ntea.cc (NTWriteEA): returns TRUE now, if allow_ntea is unset. - * shared.cc (get_admin_sid): Moved to security.cc. - * path.cc (symlink_check_one): Change check for return value - of get_file_attributes(). - -Mon May 24 22:10:34 1999 Corinna Vinschen - - * security.cc (get_world_sid): Rewrite. - * security.cc (world_full_access): Delete. - * grp.cc: Use gid 0 as default gid. - * grp.cc (read_etc_group): Look for account name of world group. - * fhandler.cc (fhandler_base::open): Call `set_file_attribute' - only in case of disk file. - -Mon May 24 22:10:34 1999 Corinna Vinschen - - * security.cc (get_file_attribute): Patched incorrect test - for symlink. - * security.cc (set_file_attribute): ditto. - -Mon May 24 22:10:34 1999 Corinna Vinschen - - * security.cc: Special handling for user and/or administrators - permissions to write (extended) attributes. - -Mon May 24 22:10:34 1999 Corinna Vinschen - - * security.cc: Don't allow 513(none) as user or group. - -Mon May 24 22:10:34 1999 Corinna Vinschen - - * security.cc: new functions `set_nt_attribute()', `get_nt_attribute()' - and `set_file_attribute()' with additional parameters `uid' and `gid', - to support real NT security. - * winsup.h: Prototype for `set_file_attribute()' with four - parameters. - * dir.cc (mkdir): Calls `set_file_attribute()' now. - * syscalls.cc (chown): ditto. - * syscalls.cc (chmod): ditto, with correct uid/gid. - -Mon May 24 22:10:34 1999 Corinna Vinschen - - * shared.cc: New function `get_admin_sid()' to get a SID - of the administrators group or of administrator. - New functions `sec_user()' and `sec_user_nih()' to get - SECURITY_ATTRIBUTES with all permissions for the user and - the administtrator group. - * shared.h: Prototypes for the above new functions `sec_user()' - and `sec_user_nih()'. - * sigproc.cc (getsem): Create process semaphore with - permissions set by `sec_user()'. - -Mon May 24 20:29:29 1999 Christopher Faylor - - * fhandler_console.cc (fhandler_console::output_tcsetattr): - ONLRET was erroneously used in place of ONLCR. - (fhandler_console::read): Honor get_r_no_interrupt () so - that interrupts don't screw up tty reading. - * fhandler.h: Add some methods to fhandler_tty_master. - * fhandler_termios.cc (fhandler_termios::fhandler_termios): - ONLRET was erroneously used in place of ONLCR. - * fhandler_tty.cc (fhandler_tty_master::init): Associating - console capabilities with the tty capabilities is a bad - idea. Go back to using the console's own. - (fhandler_tty_master::fixup_after_fork): New method. - (fhandler_tty_master::de_linearize): New method. - (fhandler_tty_master::init_console): New method. - -Mon May 24 09:58:02 1999 Christopher Faylor - - * include/rapi.h: Add some more definitions. - -Sat May 22 21:45:01 1999 Mumit Khan - - * scandir.cc (scandir): Handle errno correctly. Do preallocation to - reduce realloc calls. - (alphasort): Use strcoll, not strcmp. - -Sat May 22 19:03:47 1999 Mumit Khan - - * dll_init.cc (DllList::recordDll): Forkee must reload dlopened - DLLs. Also use strcasematch, not strcmp to compare file name. - -Wed May 19 14:38:57 1999 Christopher Faylor - - * spawn.cc (linebuf::prepend): Fix possible reference to - uninitialized memory. - * winsup.h: Remove WINSUP_NO_CLASS_DEFS workaround. - * libccrt0.cc: Ditto. - * utils/cygwin.cc: Ditto. - * utils/mount.cc: Ditto. - * utils/ps.cc: Ditto. - -Sun May 16 17:22:50 1999 Christopher Faylor - - * include/winnt.h: Revert the previous reversion. The problem - with this include file was completely misdiagnosed. - -Sun May 16 16:05:07 1999 Christopher Faylor - - * sysdef/rapi.def: New definition file for RAPI.DLL. - * include/rapi.h: Preliminary RAPI declarations. - -Sun May 16 15:37:15 1999 Christopher Faylor - - * Makefile.in: Remove more obsolete code. - -Fri May 14 19:30:53 1999 Christopher Faylor - - * include/winbase.h: Change conditional to correctly refer - to UNDER_CE rather than UNICODE. - * include/winnt.h: Update MIPS and SHx CONTEXT definitions. - -Tue May 11 21:19:59 1999 Christopher Faylor - - * exceptions.cc (call_handler): Restore previously removed - 'leave' command as its absence causes programs to crash. It - should never have been deleted. - -Tue May 11 12:04:02 1999 Norbert Schulze - - * times.cc (timezone): Properly adjust for daylight savings time. - (gettimeofday): Ditto. - (localtime): Ditto. - (tzset): Ditto. - -Mon May 10 23:31:36 1999 Christopher Faylor - - * include/winnt.h: Revert to previous version. There are problems - with the previous checkin. - * fhandler_console.cc (fhandler_console::de_linearize): Add defensive - code to ensure that console handles are opened correctly. - -Sun May 9 22:31:31 1999 Christopher Faylor - - * Makefile.in: Forgot to remove a reference to the deleted targets - below. - -Fri May 7 17:28:12 1999 Christopher Faylor - - * Makefile.in: Remove obsolete code. - * exceptions.cc (set_process_mask): Make this a __stdcall. - * sigproc.h: Fix declaration of set_process_mask. - * include/winnls.h: Add new code page defines. - * include/winnt.h: Various fixes from Anders Norlander - . - -Tue May 4 22:20:05 1999 Christopher Faylor - - * include/winnt.h: Fix CONTEXT pointer typedefs. - -Mon May 3 11:32:32 1999 Mumit Khan - - * smallprint.c (__small_vsprintf): Display textual messages - for "%E" format type. - * dlfcn.cc (set_dl_error): Lose the "Win32 ". - -Sun May 2 12:22:17 1999 Mumit Khan - - * utils/Makefile.in (EXE_LDFLAGS): Provide default. - -1999-04-30 DJ Delorie - - * winsup.h (WINSUP_NO_CLASS_DEFS): if defined, don't include class - definitions (work around gcc bug) - * libccrt0.cc (WINSUP_NO_CLASS_DEFS): define - * utils/cygwin.cc (WINSUP_NO_CLASS_DEFS): define - * utils/mount.cc (WINSUP_NO_CLASS_DEFS): define - * utils/ps.cc (WINSUP_NO_CLASS_DEFS): define - -Thu Apr 29 13:55:57 1999 Mumit Khan - - * shared.h (read_mounts): Change prototype to accept a reference - to reg_key, not a copy. - * path.cc (read_mounts): Likewise. - -Thu Apr 29 11:06:37 1999 Mumit Khan - - * configure.in (EXE_LDFLAGS): Always add newlib if part of the - build tree. - * configure: Regenerate. - - * utils/Makefile.in (INCLUDES): Add newlib include directories. - (LDFLAGS): Replace this with - (ALL_LDFLAGS): this to avoid being overridden from higher level - Makefiles. - -Wed Apr 28 17:01:12 1999 Christopher Faylor - - * include/winnt.h: Add some handheld support. - * shared.cc (open_shared): Don't call OpenFileMapping with - a null name pointer. If the name is NULL it can't be opened. - -Fri Apr 23 00:28:38 1999 Christopher Faylor - - * winsup.h: Always clear memory in thread .create method or - suffer uninitialized pointers, etc. - -Wed Apr 21 03:56:54 1999 Christopher Faylor - - * fhandler_console.cc (fhandler_console::fhandler_console): - Set fork_fixup flag to ensure that shared info is duplicated. - (get_tty_stuff): Ensure that tty_stuff is initialized. - (fhandler_console::fixup_after_fork): Really force tc and - tty_stuff initialization. Close console handles or suffer - handle leak. (needs to be fixed) - (fhandler_console::de_linearize): Force tc and tty_stuff - initialization. - -Mon Apr 19 14:54:46 1999 Geoffrey Noer - - * include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR to 12. - -Sat Apr 17 15:35:34 1999 Christopher Faylor - - * fhandler_console (fhandler_console::fixup_after_fork): Make sure - that new shared memory for console is initialized. - (fhandler_console::scroll_screen): Set region bottom correctly. - (fhandler_console::write_normal): Fix win95 problem where attribute - was propagated to scrolled region. - * include/wingdi.h: Fix GOBJENUMPROC prototype. - -Wed Apr 7 20:00:00 1999 John Fortin (fortinj@ibm.net) - - * pthread.cc (pthread_suspend): New function. - (pthread_continue): Ditto. - * include/pthread.h: added pthread_suspend and pthread_continue - prototypes. - * cygwin.din: added above functions. - * thread.h: Add 'bool suspended' to class MTitem. Prototype - __pthread_suspend __pthread_continue. - * thread.cc (__pthread_suspend): New function. - (__pthread_continue): New function. - -Sun Apr 4 23:00:00 1999 John Fortin (fortinj@ibm.net) - - * pthread.cc (pthread_join): New function. - (pthread_detach): New function. - * include/pthread.h: added pthread_join and pthread_detach prototypes. - * cygwin.din: added above functions for exports. - * thread.h: Added char joinable to MTitem class. Add void * - return_ptr to ThreadItem class to receive pointer from pthread_exit - and pthread_join. Add __pthread_join and __pthread_detach prototypes. - * thread.cc: Change thread_init_wrapper to set item->return_ptr=ret - and comment out item->used = false. Need to look at this more. - (__pthread_join): New function. - (__pthread_detach): New function. - (__pthread_exit): Implement ( was NOT_IMP ). - * thread.cc (MTinterface::FindNextUnused) : Use joinable != 'Y' as - an additional conditional. We may need to use this info in - pthread_join. - -Mon Apr 5 23:09:06 1999 Christopher Faylor - - * dcrt0.cc (do_exit): Change a variable name to minimize confusion. - * fhandler.h (fhandler_tty): Remove ttyp field in favor of get_ttyp - method. - * fhandler_tty.cc: Use get_ttyp () method to retrieve pointer to - tty device throughout. - (fhandler_tty_master::init): Point console tc at tty's tc so - that they share the same termios structure. - * select.cc (fhandler_tty_common::ready_for_read): Use get_ttyp - method. - * tty.cc (tty::common_init): Ditto. - -Mon Apr 5 00:22:30 1999 Christopher Faylor - - * fhandler_console.cc (fhandler_console::char_command): Make - setting of scrolling region cause the cursor to be placed at - the beginning of the scrolling region. - * thread.cc (__pthread_kill): Defend against item->sigs being - uninitialized. - (__pthread_sigmask): Defened against item->sigs being uninitialized. - -Wed Mar 31 22:52:18 1999 Christopher Faylor - - * dcrt0.cc (dll_crt0): Restore pointer to shared console - terminfo structure. This allows subprocesses to set - sticky console attributes. - * fhandler_console.cc (get_tty_styff): New function. Returns - pointer to shared console terminfo structure, allocating shared - memory if required. - (fhandler_console::fhandler_console): Use get_tty_stuff(). - (fhandler_console::de_linearize): Ditto. - * fork.cc (fork): Save shared console handle for export to - subprocesses. - * spawn.cc (spawn_guts): Ditto. - * shared.cc (open_shared_file_map): Rewrite to use generic - open_shared() function. - (open_shared): New function. Generic shared memory open - used by console and cygwin shared memory. - * shared.h: Define new stuff used by above. - -Wed Mar 31 01:46:23 1999 Christopher Faylor - - * fhandler.h (fhandler_tty): Set tc = ttyp. - * fhandler_tty.cc (fhandler_tty_master::init): Ditto. - (fhandler_tty_common::dup): Ditto. - * tty.cc (tty::common_init): Ditto. - -Wed Mar 31 01:43:06 1999 Christopher Faylor - - * path.cc (mount_info::conv_to_win32_path): Reorganize to - correctly handle //x syntax. - -Tue Mar 30 14:42:05 1999 Christopher Faylor - - * strace.cc (strace_vsprintf): Fix incorrect buffer reference. - -Mon Mar 29 22:46:16 1999 Christopher Faylor - - * debug.cc (__lock): Return value for gcc bug workaround. - (__unlock): Ditto. - * fhandler_tty.cc (fhandler_tty_master::init): Remove extraneous - console initialization. Set termios to sensical values before - initializing the console. - (fhandler_tty_slave): Add some debugging output. - * strace.cc: Conditionalize stuff not required by STRACE_HHMMSS. - (strace_vsprintf): Remove dependency on time() for STRACE_HHMMSS. - -Mon Mar 29 10:50:00 Corinna Vinschen - - * utils/passwd.c (GetPW): Correct cast in call to `NetUserGetInfo'. - -Sun Mar 28 16:54:57 1999 Christopher Faylor - - * fhandler.h: Remove tty_stuff field from fhandler_console - class. Use global instead to allow all console opens to - use same settings. - * fhandler_console.cc: Add new global. - (fhandler_console::tcgetattr): Use new global for initialization. - (fhandler_console::de_linearize): Ditto. - * fhandler_termios.cc (fhandler_termios::fhandler_termios): Don't - reinitialize an already initialized termios. Do not honor - CYGWIN=binmode for console output. It's too confusing. - * shared.h: Add `initialized' field to tty_min. - -Sun Mar 28 01:55:32 1999 Christopher Faylor - - * path.cc (path_prefix_p_): Add defensive code. - (slash_drive_prefix_p): Use macro to detect whether a character - is a path separator. - (mount_info::conv_to_win32_path): Rewrite to correctly handle - relative paths. - * strace.cc (strace_printf): Remove extraneous save of LastError. - * winsup.h (per_thread): Return TlsSetValue value. This seems - to work around a g++ bug. - -Thu Mar 25 13:00:00 Corinna Vinschen - - * fhandler_raw.cc (fhandler_dev_raw::dup): New method. - * fhandler_tape.cc (fhandler_dev_tape::dup(): Ditto. - * fhandler.h: Added prototypes for the formentioned methods. - -Wed Mar 24 23:00:00 Corinna Vinschen - - * fhandler_raw.cc (fhandler_dev_raw::linearize): - Only calling base class implementation now. - * fhandler_raw.cc (fhandler_dev_raw::de_linearize): - Only calling base class implementation and allocating devbuf now. - * fhandler_tape.cc (fhandler_dev_tape::linearize): Erased. - * fhandler_tape.cc (fhandler_dev_tape::de_linearize): Erased. - * fhandler_tape.cc (fhandler_dev_tape::fhandler_dev_tape): - Additional call to `set_cb()'. - * fhandler_floppy.cc (fhandler_dev_floppy::fhandler_dev_floppy): - Ditto. - * fhandler.h: Erased prototypes for linearize and de_linearize - methods of class fhandler_dev_tape. - -Thu Mar 25 14:05:57 1999 Christopher Faylor - - * signal.cc (pause): Make sure that signal has been dispatched - prior to pause returning. - -Wed Mar 24 20:04:21 1999 Christopher Faylor - - Change get_input_handle to get_io_handle throughout. - Change output_handle_ to output_handle throughout. - Use sys/termios.h only where needed. - * Makefile.in: Add new object. - * fhandler.cc (fhandler_base::puts_readahead): New function. - Adds a string to the read ahead buffer. - (fhandler_base::put_readahead): New function. Adds a character - to the read ahead buffer. - (fhandler_base::get_readahead): New function. Gets a character - from the read ahead buffer. - (fhandler_base::peek_readahead): New function. Returns character - at beginning or end of read ahead buffer. - (fhandler_base::set_readahead_valid): Augmented from fhandler.h. - (fhandler_base::eat_readahead): Eat a character from the read - ahead buffer. - (fhandler_base::de_linearize): Reset read ahead info. - (fhandler_base::read): Honor new read ahead mechanism. - (fhandler_base::fhandler_base): Don't set binmode to default - if it has already been explicitly set. - * fhandler.h: Add *BINSET flags to track whether the binary - mode has been turned on or off explicitly. - (fhandler_base): Add elements for new read ahead method. Remove - old `readahead_'. - (fhandler_termios): New base class. - (fhandler_console): Use fhandler_termios base class. - Add new de_linearize method. - (fhandler_tty_common): Rewrite to use fhandler_termios base class. - (fhandler_pty_master): Ditto. - (fhandler_tty_master): Ditto. - * fhandler_console (fhandler_console::read): Rewrite to use functions - from fhandler_termios and read ahead for line editing. - (fhandler_console::read1): Remove. - (fhandler_console::open): Interruptible I/O is now handled in the - read function. Mark this. - (fhandler_console::output_tcsetattr): Use ONLRET to control - binary behavior since it is more closely analgous. - (fhandler_console::input_tcsetattr): Don't set console flags if - there is no change or Windows 95 will eat input. - (fhandler_console::tcsetattr): Use ONLRET to control binary behavior - since it is more closely analgous. - (fhandler_console::fhandler_console): Accommodate fhandler_termios - base class. - (fhandler_console::init): Ditto. - (fhandler_console::igncr_enabled): Ditto. - (fhandler_console::char_command): Use new read ahead method. - (fhandler_console::de_linearize): New function. - * fhandler_serial.cc: Need additional include. - * fhandler_tty.cc (fhandler_tty_master::fhandler_tty_master): - Accommodate fhandler_termios base class. - (fhandler_tty_master::init): Ditto. - (fhandler_tty_master::accept_input): New function. Sends - (possibly line-edited) input to slave. - (process_input): Use line editing capabilities of fhandler_termios - base class when processing input. - (fhandler_tty_slave::open): Accommodate fhandler_termios base class. - (fhandler_tty_slave::tcgetattr): Ditto. - (fhandler_tty_slave::ioctl): Ditto. - (fhandler_pty_master::fhandler_pty_master): Ditto. - (fhandler_pty_master::read): Ditto. - (fhandler_tty_slave::dup): Be more paranoid about setting output - handle in case of error. - * fhandler_tty.h: Accommodate new tty_min base class in tty class. - * hinfo.cc (hinfo::build_fhandler): Send tty 'unit' to constructor. - * select.cc (peek_console): Send resize event to window regardless - of tty setting. Eliminate ReadFile kludge. - * shared.h (tty_min): Rename termios field to avoid conflict. - * tty.cc (create_tty_master): Send tty number to build_fhandler. - (tty::common_init): Remove termios initialization. It's handled - via fhandler_termios, now. - * fhandler_termios: New file. Contains methods for dealing with - fhandler_termios class. - -Wed Mar 24 19:22:04 1999 Christopher Faylor - - * exceptions.cc (call_handler): Reorder to work around - gcc bug. - -Sun Mar 21 21:26:43 1999 Christopher Faylor - - * fhandler_serial.cc (fhandler_serial::raw_read): Protect - against uninitialized variable. Output debug info if - ClearCommError fails. Clear overlapped I/O on error or - signal. - (fhandler_serial::tcflow): Output debug info at start of - routine. - (fhandler_serial::tcsetattr): Add more debugging output. - Avoid re-setting parameters if there has been no change. - Setting parameters via SetCommState seems to cause loss of - input on Windows 9[58]. - -Wed Mar 17 12:56:25 1999 Geoffrey Noer - - * include/winbase.h: Fix AllocateAndInitializeSid proto. - -Tue Mar 16 21:55:12 1999 Christopher Faylor - - * exceptions.cc (handle_exceptions): Always wait for sig_send - to exit or races can result. - -Tue Mar 16 13:04:34 1999 Geoffrey Noer - - * include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR to 11. - -Tue Mar 16 15:44:10 1999 Christopher Faylor - - * cygwin.din: Export telldir/seekdir. - -Tue Mar 16 13:50:51 1999 Corinna Vinschen - - * dir.cc: Change unused struct member __d_find_first_called to - __d_position for use in new functions. - (telldir): New function. Returns current position in DIR stream. - (seekdir): New function. Seeks to new position in DIR stream. - -Mon Mar 15 19:17:23 1999 Geoffrey Noer - - * sysdef/comctl32.def: Add InitCommonControlsEx. - -Mon Mar 15 19:45:10 1999 Christopher Faylor - - * dir.cc (mkdir): Remove final slash from a directory if - appropriate or windwows won't create the directory. - * errno.cc: Change text for EAGAIN to something a little - more sensical. - * exceptions.cc (call_handler): Add a debug message. - * fhandler.cc (fhandler_base::open): Don't attempt to set - the position of a com device. - * fhandler_serial.cc (fhandler_serial::raw_read): Reset - overlapped event if not armed. Don't attempt to find out - if characters are available if vmin_. - (fhandler_serial::raw_write): Clear pending I/O when - necessary. - (fhandler_serial::open): Set comm state to current rather - than zeroing. - (fhandler_serial::tcflush): Don't use "queue" as a flag. - TCI* defines are not bit masks. - * select.cc (peek_serial): Add debugging output. - * sigproc.cc (wait_sig): Minor cleanup. - * path.cc (nofinalslash): Make global. - * winsup.h: Ditto. - -Mon Mar 15 16:31:29 1999 Geoffrey Noer - - * include/winnt.h: Add RID defs/protos from MSDN docs. - (SECURITY_*_RID, DOMAIN_*_RID*, etc.) - * include/richedit.h: Add missing SCF_* defines. - * include/commctrl.h: Add missing PBM_ defines, PBRANGE struct. - -Mon Mar 15 12:54:48 1999 Geoffrey Noer - - * Makefile.in: Don't install include/Windows32 since it doesn't - exist any more. - * include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR to 10. - -1999-03-12 DJ Delorie - - * net.cc (gethostbyname): support a.b.c.d notation internally, - in case there's no DNS at least partial support is there. - -Thu Mar 11 21:27:41 1999 Jeff Johnston - - * cygwin.din: Added references to new fast-math routines. - -Wed Mar 10 19:22:46 1999 Geoffrey Noer - - * include/commdlg.h: Add missing PageSetupDlg defines. - -Tue Mar 9 14:28:14 1999 Geoffrey Noer - - * include/*.h: Switch Win32 API header file set to the one written - by Anders Norlander . Headers now - fit the standard Win32 API header layout and are more complete. - These correspond to Anders' headers, version 0.1.5. Please read - sysdef/README for more information. - * include/Windows32/*.h: Delete in favor of above definitions. - - Changes to support the above: - * fhandler_console.cc (fhandler_console::char_command): Add newly - needed cast to DWORD *. - * fhandler_serial.cc (fhandler_serial::raw_read): Make n, minchars - DWORDs. - * fhandler_tty.cc: Include limits.h. - (fhandler_pty_master::doecho): Second arg is now DWORD. - (fhandler_pty_master::process_input_to_sl): Make n, written DWORD. - (fhandler_pty_master::process_slave_outpu): Make n DWORD. - (fhandler_tty_slave::close): Make towrite, n DWORDs. - (fhandler_tty_slave::write): Make n DWORD. - * fhandler.h: Adjust fhandler_pty_master::doecho proto. - * hinfo.cc: Include file reordering. - * malloc.cc: Ditto. - * net.cc: Ditto. - * fhandler_tape.cc (get_ll): Need to reference .u in - LARGE_INTEGER usages. - * ntea.cc: Ditto. - * pinfo.cc: Include limits.h. - * spawn.cc: Ditto. - * uinfo.cc: Ditto. - * uname.cc (uname): sysinfo struct now has anon union. - Adjust sprintf for dwProcessorType being a long now. - * syscalls.cc: Include limits.h and lmcons.h. Throughout, - reference .u in LARGE_INTEGER usages. - (logout): Make rd a DWORD. - - * utils/mkgroup.c: Always include lmaccess.h and lmapibuf.h. - Include stdio.h. - (enum_groups): Adjust for longs in fprintfs. - (main): Ditto. - * utils/mkpasswd.c: Include lmaccess.h and lmapibuf.h. - (enum_users): Adjust for longs in fprintfs. - (main): Ditto. - (enum_local_groups): Ditto. - * utils/passwd.c: Remove many Win32 API defines now in new - Win32 headers. Include lmaccess.h, lmerr.h, lmcons.h, - lmapibuf.h. - (PrintPW): Adjust for longs in fprintfs. - -Wed Mar 3 21:14:45 1999 Christopher Faylor - - * environ.cc (environ_init): Fix off-by-one error in initial - environment allocation. - * fhandler_serial.cc (fhandler_serial::tcflush): Use different - method for flushing since serial handles are now opened for - overlapped I/O. - * select.cc (cygwin_select): Make degenerate case interruptible. - * sigproc.cc (proc_exists): Recognize all kinds of myself pointers - as "existing". - -Tue Feb 16 23:00:48 1999 Christopher Faylor - - * include/Windows32/Functions.h: Correct two #ifndefs that were - switched. - -Mon Feb 15 22:41:54 1999 Christopher Faylor - - * spawn.cc (spawn_guts): Fix incorrect arg length when - constructing new arguments for #!. - -Fri Feb 12 13:25:50 1999 Drew Moseley - - * Makefile.in (install-info): Test for file existence before installing. - -Fri Feb 12 13:17:49 1999 Corinna Vinschen - - * fhandler.cc (fhandler_disk_file::fstat): Handles directories, - returns unique i-node number. - * syscalls.cc (stat_worker): On WinNT, stat_worker calls - fhandler_disk_file::fstat for directories, too. - -1999-02-10 DJ Delorie - - * doc/doctool.c (scan_directory): check for opendir failing, - add closedir. - -Tue Feb 9 13:02:25 1999 Geoffrey Noer - - * utils/mount.cc: Add fixme. - * doc/doctool.c: Correct typo in comment. - -Mon Feb 8 17:29:58 1999 Christopher Faylor - - * include/Windows32/UnicodeFunctions.h: Fix incorrect use of - BOOL -> WINBOOL. - * Windows32/ASCIIFunctions.h: Ditto. - -Fri Feb 5 09:38:25 1999 Christopher Faylor - - * path.cc (mount_info::add_item): Ensure that drive names - are added using X: notation. - -Thu Feb 4 00:28:58 1999 Christopher Faylor - - * path.cc (path_prefix_p_): Recognize ':' as a path separator. - (mount_info::conv_to_posix_path): Detect case where a '/' has - to be added to a path being constructed. - (realpath): Ensure that the full path name is returned. - -Wed Feb 3 22:57:42 1999 Christopher Faylor - - * shared.h (mount_info): Add two separate arrays to track - reverse sorting of win32/posix paths. - * path.cc (sort_by_posix_name): New function. Sorts by - posix path. - (sort_by_native_name): Rename from sort_by_name. - (mount_info::conv_to_win32_path): Use native sort order - when iterating through mount table. - (mount_info::binary_win32_path_p): Ditto. - (mount_info::getmntent): Ditto. - (mount_info::conv_to_posix_path): Use posix sort order - when iterating through mount table. - (sort): Use two arrays to track sorting of mount table. - (mount_info::add_item): Simplify slightly. - -Wed Feb 3 15:17:54 1999 Christopher Faylor - - * cygwin.din: Remove DATA attribute which was erroneously - added to __errno. - -Tue Feb 2 23:10:18 1999 Geoffrey Noer - - * path.cc: Fix comment regarding UNC paths in mount table. - (mount_info::conv_to_win32_path): Add back code to handle - // paths for now. The plan is still to remove it again at - a later date. - (mount_info::slash_drive_to_win32_path): New. Convert a // - path to a Win32 path. Bring back from among the recently departed - path functions. - * shared.h: Add mount_info proto for slash_drive_to_win32_path. - -Tue Feb 2 22:52:43 1999 Geoffrey Noer - - * include/lmaccess.h: Add stub. - * include/shlobj.h: Add stub. - -Tue Feb 2 22:34:06 1999 Christopher Faylor - - * shared.h: Change magic number associated with fork/exec - information as a temporary measure to eliminate strange - core dumps with multiple versions of cygwin1.dll. - -1999-02-02 Brendan Kehoe - - * Makefile.in (readme.txt): Add missing -I$(srcdir)/doc. - -Tue Feb 2 01:10:31 1999 Geoffrey Noer - - * sysdef/*: Replace all files with new ones by Anders - Norlander . Please read sysdef/README - for more information. - -Mon Feb 1 14:55:11 1999 Christopher Faylor - - * path.cc (sort_by_name): Sort based on length of native_path - to ensure maximal match when converting from native -> UNIX. - * cygwin.din: Make more data variables DATA. - -Mon Feb 1 13:31:43 1999 Geoffrey Noer - - * fhandler_tape.cc: Change all fhandler_tape private functions - to be named foo_bar_baz-style instead of FooBarBaz. Add some - parens around logical ors/ands for clarity. Respace. - * fhandler.h: Change protos here in light of above. - -Thu Jan 28 11:00:00 Corinna Vinschen - - * errno.cc: Support for Windows errors ERROR_CRC and ERROR_NO_READY - and for error ENOMEDIUM. - -Wed Jan 27 01:05:39 1999 Christopher Faylor - - * dir.cc (rmdir): Correct errno setting when attempting to rmdir - a non-directory. - -Tue Jan 26 17:36:12 1999 Geoffrey Noer - - * registry.cc (reg_key::build_reg): Add FIXME. - -Tue Jan 26 01:30:48 1999 Geoffrey Noer - - * path.cc (mount_info::from_registry): Import old v1 mounts - only if current mount layout doesn't exist yet in both user - and system areas (when had_to_create_mount_areas == 2). - (mount_info::import_v1_mounts): New, was upgrade_v1_mounts. - (mount_info::from_v1_registry): Add missing comma in reg_key - creation call. - (mount_info::init): Init had_to_create_mount_areas to zero. - * external.cc (cygwin_internal): Fix reference to - upgrade_v1_mounts. - * shared.h: Change upgrade_v1_mounts proto to import_v1_mounts. - Add new had_to_create_mount_areas variable in mount_info class. - * registry.cc (reg_key::build_reg): Increment - had_to_create_mount_areas whenever we create a new mount area. - - * include/sys/mount.h: Don't define MOUNT_EXEC until we actually - implement this functionality. - - * utils/mount.cc (do_mount): Print warning messages after the - actual mount attempt so we don't see warnings when mount fails. - (usage): Change name of --upgrade-old-mounts flag to - --import-old-mounts. - (main): Ditto. - -Mon Jan 25 23:56:50 1999 Geoffrey Noer - - * errno.cc (seterrno_from_win_error): New. Given a Windows - error code, set errno accordingly. - (seterrno): Just call seterrno_from_win_error with the - error code returned by a call to GetLastError. - * winsup.h: Define __seterrno_from_win_error. - * path.cc: Clean up more function description comments. - (mount_info::add_reg_mount): Don't need res, just return the - right values. - (del_reg_mount): Return int, not void. If we're deleting a - system mount, set errno to EACCES and return -1 if we don't - have a valid key handle. If mount delete fails, set errno - accordingly and return -1. Otherwise, return zero for success. - (cygwin_umount): Delete mount from registry first, only remove - from internal table if successful. - * shared.h: Make del_reg_mount proto return int. - -Mon Jan 25 22:40:15 1999 Geoffrey Noer - - * path.cc (mount_info::mount_slash): Add mount to registry - first, only add to internal table if successful. - (mount_info::conv_to_posix_path): Ditto. - (mount): Ditto. - (mount_info::add_reg_mount): Return int, not void. If we're - writing a system mount, first check if we have a valid key handle. - If we don't, set errno to EACCES and return -1. Otherwise return - zero for success. - * shared.h: Make add_reg_mount proto return int. - -Mon Jan 25 20:40:26 1999 Geoffrey Noer - - * path.cc (mount_info::init): Don't read automount info here. - (mount_info::from_registry): Read it here instead. Also, read - system registry info in KEY_READ mode. - (mount_info::read_mounts): Read mount info with KEY_READ access - permissions. - -Mon Jan 25 19:12:31 1999 Geoffrey Noer - - * path.cc: Improve several function description comments. - (mount_info::init): Read automount information from the - registry before potentially automounting slash. - (mount_info::conv_to_posix_path): Create automount with - automount_flags flags. - (mount): Now flags is more than just a toggle so we - must check it in a different manner. And simply check - MOUNT_AUTO as the indicator. If we want to change the - automount_prefix, also change automount_flags as appropriate. - Fix args to syscall_printf. - (write_automount_info_to_registry): New. Was - write_automount_prefix_to_registry. - (read_automount_info_from_registry): New. Was - read_automount_prefix_from_registry. - * shared.h: Adjust protos for function renames just mentioned. - * include/sys/mount.h: Delete MOUNT_CHANGE_AUTOMOUNT_PREFIX - since we don't really need it. - * utils.cc (mount): Pass MOUNT_AUTO as indicator of desire to - change automount prefix. - (show_mounts): Change spacing so there's room for "system,auto" - in Type column. - -Mon Jan 25 13:17:40 1999 Geoffrey Noer - - * path.cc: Change all references from "automount root" to - "automount prefix", avoiding potential nomenclature confusion - with the root of the file system. - (read_automount_prefix_from_registry): New. Was - read_automount_root_from_registry. - (read_automount_prefix_from_registry): New. Was - read_automount_root_from_registry. Also read the default - flags for automounts from registry at the same time. - (write_automount_prefix_to_registry): New. Was - write_automount_root_to_registry. Also set automount flags - in registry using new auto_flags arg. - (mount): Add flags arg to write_automount_prefix_to_registry call. - * shared.h: Add automount_flags variable to mount_info class. - Adjust protos for function renames listed above. - - * include/sys/mount.h: Comment out MOUNT_MIXED and MOUNT_SILENT - whose values could be reused now that we're using a new mount - layout. Change MOUNT_CHANGE_AUTOROOT to - MOUNT_CHANGE_AUTOMOUNT_PREFIX. - - * utils/mount.cc (change_automount_prefix): New. Was - change_automount_root. Add new flags argument so it's possible - to change the default automount flags. - (main): Option name change from --change-automount-root to - --change-automount-prefix. - (usage): Update in light of option changes. - * utils/umount.cc (remove_all_automounts): Also need to check - for mnt_type looking like "system,auto" now that it's possible - for automounts to be located in the system registry. - -Mon Jan 25 08:59:04 1999 Christopher Faylor - - * spawn.cc (linebuf::add): Ensure that there is always - enough space for line being added. Always null terminate. - (linebuf::prepend): Ditto. - -Sat Jan 23 01:30:16 1999 Geoffrey Noer - - Make mount.exe able to upgrade mounts: - * external.cc: Fix file description. - (cygwin_internal): Handle CW_READ_V1_MOUNT_TABLES case, in - which case call upgrade_v1_mounts to upgrade old registry - area mounts. - * external.h: Add CW_READ_V1_MOUNT_TABLES to enum. - * shared.h: Make upgrade_v1_mounts public. - - * utils/mount.cc: Include winsup.h, external.h, undef errno since - it's defined by winsup.h. - (usage): Add --upgrade-old-mounts option to usage info. - (main): Handle --upgrade-old-mounts flag by calling - cygwin_internal with the right constant. - -Sat Jan 23 00:40:17 1999 Geoffrey Noer - - First pass at mount table backwards compatibility with v1 - mounts: - * path.cc (mount_info::from_registry): For now, upgrade from - old v1 mount registry area if nmounts==0 after reading new mount - areas. - (mount_info::read_v1_mounts): New function. Given a regkey, read - the mounts in the old v1 registry layout corresponding to the key. - A "which" arg tells us which registry we're reading so that we - can include MOUNT_SYSTEM when reading old system mounts. - (mount_info::from_v1_registry): New function. Retrieve old v1 - mount table area mounts. - (mount_info::upgrade_v1_mounts): New function. Retrieve old - v1 mounts, add them to the current registry mount location. - (mount_info::to_registry): New function. For every mount in - the internal mount table, add it to the correct registry. - * shared.h: Add protos for new mount_info functions -- - from_v1_registry, read_v1_mounts, upgrade_v1_mounts, to_registry. - Don't need class name in protos for - build_automount_mountpoint_path, write_automount_root_to_registry, - and read_automount_root_from_registry. - -Fri Jan 22 22:45:07 1999 Christopher Faylor - - * spawn.cc (spawn_guts): Arg 2 missing from special case - command/cmd handling. - -Fri Jan 22 22:40:32 1998 Corinna Vinschen - - * fhandler_raw.cc (fhandler_dev_raw::raw_read): bytes_to_read - corrected to multiple of 512 bytes instead of multiple to - devbufsiz. Insert break on ReadFile returned 0 Bytes. - -Fri Jan 22 15:50:49 1999 Christopher Faylor - - * mkvers.sh: Fix handling of CVS tag output. - * errno.cc: Mark exported data as __declspec(dllexport). - * times.cc: Ditto. - * fhandler.cc (fhandler_base::open): Yet another stab - at correcting handling of binmode/textmode ramifications. - * path.cc (hash_path_name): Make /. == '' for purposes - of generating a hash. - -Fri Jan 22 11:45:28 1999 Christopher Faylor - - * path.cc (slash_unc_prefix_p): Generalize to allow - either type of slash. - (mount_info::add_item): Don't disallow UNC specs in - the mount table. - * utils/Makefile.in: Always use current stub library. - -Fri Jan 22 08:52:36 1999 Christopher Faylor - - * environ.cc (regopt): Use correct registry key for Program - Options given new mount layout. - * cygwin.din: export __mb_cur_max from newlib. - -Thu Jan 21 16:52:20 1999 Geoffrey Noer - - * path.cc (cygwin_split_path): Adjust two FIXMEs. - (mount_info::write_automount_root_to_registry): Return int, - 0 on success, -1 if path is problematic. - (mount): Check return of write_automount_root_to_registry - and act appropriately. Do syscall_printf when adjusting automount - as well as regular mount. - * shared.h: mount_info::write_automount_root_to_registry now - returns an int. - * utils/mount.cc (main): don't sanity-check automount path - here, instead let the DLL take care of that. - -Thu Jan 21 17:12:26 1999 Christopher Faylor - - * spawn.cc (spawn_guts): Rewrite argument handling for - cleaner, one-pass operation. - (linebuf::add): New method for adding arguments to end - of the argument list. - (linebuf::prepend): New method for pushing arguments on - the front of the argument list. - -Wed Jan 20 19:06:30 1999 Geoffrey Noer - - * path.cc (mount_info::mount_slash): only call add_reg_mount if - add_item succeeded. - (mount_info::add_item): Fail if native path doesn't start with - : or if posix path doesn't start with a slash. - -Wed Jan 20 19:06:30 1999 Geoffrey Noer - - * fhandler_raw.cc: Correct copyright date, reformat. - * fhandler_floppy.cc: Ditto. - * fhandler_tape.cc: Ditto. - -Wed Jan 20 17:54:02 1999 Geoffrey Noer - - Remove /// support. Add support for automounts in - user registry area. - * path.cc: Rewrite, reformat docs at top in light of removing - /// support and new automount support. Add more function - description comments. - (slash_drive_prefix_p): Remove function. - (build_slash_drive_prefix): Ditto. - (slash_drive_to_win32_path): Ditto. - (mount_info::init): After everything else, read the automount_root - by calling read_automount_root_from_registry(). - (mount_info::mount_slash): Automount slash with MOUNT_AUTO. - (mount_info::conv_to_win32_path): Remove /// support code. - (mount_info::build_automount_mountpoint_path): Construct the name - of an automount POSIX path, given automount_root and the Win32 - path that needs to be automounted. - (mount_info::conv_to_posix_path): Automount missing drive letter - and call conv_to_posix_path again if path isn't covered by the - mount table but starts with ":". - (mount_info::read_automount_root_from_registry): New function. - Read in the value of automount_root from the current_user - registry mount area. If there isn't one, use default of - "/cygdrive" and write that to the registry by calling - write_automount_root_to_registry(). - (write_automount_root_to_registry): Write a value of - automount_root to the user registry area. - (mount_info::del_item): Add new flags arg to specify which - registry to delete the mount from. - (mount_info::del_reg_mount): Ditto. - (mount_item::getmntent): Use mount_info mnt_foo strings to store - strings passed back in the mntent struct. Otherwise if you - delete a mount item while using getmntent, the pointer may - change on the user. Add ",auto" to mnt_type if MOUNT_AUTO flag is - set. - (mount): Add support to set auto_root to path if flags is set - to the special MOUNT_CHANGE_AUTOROOT flag otherwise do the normal - thing. - (umount): Call cygwin_umount with flags value of 0. - (cygwin_umount): New exported function. Same as umount but - takes an additional flag argument that specifies which registry - area from which umount should remove the mount point. - * cygwin.din: Export the cygwin_umount call. - * shared.h (mount_info): Add public automount_root string. - Add public proto for write_automount_root_to_registry(). - Add private protos for build_automount_mountpoint_path() and - read_automount_root_from_registry(). Add flags arg to del_item - and del_reg_mount protos. Add strings used by getmntent et al - including mnt_type, mnt_opts, mnt_fsname, mnt_dir. (Can't just - pass back pointers to mount paths because they may change as - a result of a umount call. - - * include/sys/mount.h: Add new MOUNT_AUTO and - MOUNT_CHANGE_AUTOROOT flags. Add proto for cygwin_umount - function. - * include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR to 9. - - * utils/mount.cc: Change missing_dir_warning flag to force - and init to FALSE instead of TRUE. Throughout swap names and - setting as appropriate. Include errno.h. - (usage): Remove info about --reset. Add info for new - --change-automount-root option. - (main): Don't check the --reset flag. Call change_automount_root - if invoked with --change-automount-root. Only call do_mount - if !mount_already_exists unless force flag is TRUE. Otherwise - fail. - (mount_already_exists): New helper function. Returns 1 - if the mount point of the same registry location is already - mounted. - (reset_mounts): Remove function. - (change_automount_root): New function that changes the - automount root in the registry via Cygwin by passing the new - path to mount() with the special MOUNT_CHANGE_AUTOROOT flag. - * utils/umount.cc: Add progname, set to argv[0]. Include string.h. - (usage): New function to print out usage info. - (main): Loop through argcs. Handle new flags to remove all mounts - of a specific type including --remove-all-mounts, - --remove-user-mounts, --remove-system-mounts, and - --remove-auto-mounts. New flag to specify removing a system - mount. Call cygwin_umount instead of umount, providing flags - as appropriate. - (remove_all_mounts): New function. Remove all mounts in - both tables. - (remove_all_automounts): Remove all mounts marked auto. - (remove_all_user_mounts): Remove all user mounts, including auto - mounts. - (remove_all_system_mounts): Remove all system mounts. - - * registry.cc (reg_key::get_string): Fix description comment. - * strace.cc: Minor reformatting. - -Wed Jan 20 17:49:20 1999 DJ Delorie - - * fhandler.cc (raw_write): Make sure that a disk full error - is properly signalled. - (fhandler_base::open): Only tapes are read/write, cd-roms may be - read-only (from Corinna). - -Wed Jan 20 10:46:48 Corinna Vinschen - - [applied by DJ Delorie ] - - * fhandler_raw.cc (fhandler_dev_raw::writebuf): Writes only - as much bytes as needed, instead of full buffer size. - - * fhandler_tape.cc (fhandler_dev_tape::close): Corrected error - handling in case of error while writing buffer content to dev. - - * fhandler_floppy.cc (fhandler_dev_floppy::close): Ditto. - - * fhandler_tape.cc (fhandler_dev_tape::writebuf): Delete function - - * fhandler_floppy.cc (fhandler_dev_floppy::writebuf): Ditto. - - Patch suggested by Ron Parker - * path.cc (mount_info::conv_to_win32_path): Change the - recognition of UNC devices, to support also paths of type - `\\.\UNC\'. - - * fhandler_tape.cc (fhandler_dev_tape::close): Fixed rewind - to block 1 instead of block 0 on rewind tapes in case of - uncaught signal (e.g. Ctrl-C). - - * path.cc (get_raw_device_number): New static function, - checks path for windows raw device. - - * path.cc (get_device_number): Change for recognition of - windows raw device paths by calling `get_raw_device_number()'. - - * path.h: Change prototype for `get_device_number()'. - - * Makefile.in: Added file 'fhandler_raw.o' to dependencies. - - * include/cygwin/rdevio.h: New file to support ioctl commands - on random access raw devices. At the time only get/set buffersize - for raw_read/raw_write. - - * fhandler.h: Change class hierarchy. 'fhandler_dev_floppy' - and 'fhandler_dev_tape' are now derived classes of - 'fhandler_dev_raw', which is derived from 'fhandler_base'. - - * fhandler_raw.cc: New file for implementation of class - 'fhandler_dev_raw' which is now base class for support of - mass storage raw devices. - - * fhandler_dev_tape.cc: Rewritten. - - * fhandler_dev_floppy.cc: Rewritten. Now supporting correct - lseek (seeking only to positions on 512 byte boundaries, - like supported from WinNT). - - * Makefile.in: Added file 'fhandler_floppy.o' to dependencies. - - * fhandler_floppy.cc: New file to support raw devices - including multi volume operations. - - * fhandler.cc: Delete 'fhandler_dev_floppy' implementation. - - * fhandler.h: Extend class fhandler_dev_floppy. - - * fhandler_tape.cc: Rewrite for correct support - of multi volume operations. Supports Setmarks now. - - * fhandler.h: Add private method `clear()' to class - fhandler_dev_tape. - - * Makefile.in: Add file 'fhandler_tape.o' to dependencies. - - * path.cc (mount_info::conv_to_win32_path): Change the - recognition of UNC devices, to support devices, which - are not partitions, too. - - * fhandler.h: Extend struct 'fhandler_dev_tape' for tape support. - Add method 'fstat' to fhandler_dev_floppy to get S_ISBLK(). - - * fhandler.cc (fhandler_base::open): In any case 'access_' has to - be GENERIC_READ | GENERIC_WRITE for tapes, to allow tape control. - No 'SetFilePointer' for tapes. - - * fhandler_tape.cc: New file to support rewind (/dev/stX) and - norewind (/dev/nstX) tapes. Supports ioctl() calls, described - in... - - * include/sys/mtio.h, include/cygwin/mtio.h: New header files - for tape support. - -Sat Jan 16 21:59:36 1999 Geoffrey Noer - - * registry.h: Delete; move contents into shared.h except for - posix_path_p() routine which disappears. - * {Makefile.in, environ.cc, net.cc, path.cc, registry.cc, - shared.cc}: No longer include registry.h. - * dcrt0.cc (dll_crt0_1): don't check posix_path_p() - - * include/mntent.h (struct mntent): Drop const from strings. - * include/sys/mount.h: Change MOUNT_GLOBAL flag that nobody has - used yet to MOUNT_SYSTEM. Add MOUNT_EXEC flag. - * include/cygwin/version.h: Bump CYGWIN_VERSION_MOUNT_REGISTRY to - 2. Change CYGWIN_INFO_CYGWIN_REGISTRY_NAME to "Cygwin". - Change CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME to "mounts v2". - - * registry.cc (reg_key::reg_key): Default key doesn't end in - "mounts" any more. - (reg_key::kill): Return error code from RegDeleteKeyA. - * path.cc: Reformat, reorder functionality, add comments - throughout. - (mount_info::init): Automount slash if it's not already mounted. - (mount_info::mount_slash): New private helper function. - (mount_info::binary_win32_path_p): Check flags to determine - if mount is binary or not, not binary_p. - (mount_info::read_mounts): Remove unneeded access argument. Use - RegEnumKeyEx to enumerate mount points in current registry - location where each key name returned is a posix_path mount - location. Use a subkey reg_key to read the posix_path's - corresponding native_path and flags. - (mount_info::from_registry): Access HKEY_LOCAL_MACHINE registry - with full access privs (which will fail if not administrator). - Fix registry path used to initialize HKEY_LOCAL_MACHINE reg_key. - (mount_info::to_registry): Delete function. Replaced by - add_reg_mount. - (mount_info::add_reg_mount): New function which adds a specified - mount point to the registry. - (mount_info::del_reg_mount): New function which deletes the - posix_path argument from the highest priority registry table it - can (first user, than system-wide). - (sort_by_name): If the two posix_paths are the same, then - differentiate between them looking at MOUNT_SYSTEM in their flags. - (mount_info::add_item): Also make sure that neither path is NULL. - Never claim mount point is busy: replace an existing posix_path - as long as it came from the same registry location. - (mount_info::del_item): Also make sure that neither path is NULL. - (mount_item::getmntent): Use mnt_type field to store user vs. - system registry location string. Cast all strings to char *. - Handle flags instead of binary_p. Change names of strings - returned in mnt_opts field. - (mount_item::init): Set flags, instead of dealing with binary_p - and silent_p. - (mount): Call add_reg_mount instead of to_registry. - (umount): Call del_reg_mount instead of to_registry. - (path_conv::path_conv): Remove reference to silent_p. - * path.h (path_conv): Remove silent_p. - - * utils/mount.cc: Add -s to usage (was a commented-out -g). - Or in MOUNT_SYSTEM if -s flag given. Add similar commented-out - support for future MOUNT_EXEC flag that will be added with -e. - (reset_mounts): Automount slash with zero for flags, not - MOUNT_SILENT which we no longer use for anything. - * utils/umount.cc: Also print out usage if the first argument - starts with a dash. - -Fri Jan 15 11:27:51 1999 DJ Delorie - - * strace.cc: add macros to protect against buffer overruns - (strace_printf): increase buffer from 6000 to 1000 to build devo - * include/sys/strace.h: allow -DNOSTRACE again - -Fri Jan 15 11:27:51 1999 DJ Delorie - - * dcrt0.cc (alloc_stack): add 16384 to work around Win95 page - fault during builds - * fork.cc (fork): try various things to avoid page faults during - win95 builds. - -Fri Jan 15 11:18:23 1999 DJ Delorie - - * fhandler.cc (raw_write): check for disk full. - -Fri Jan 15 11:18:23 1999 DJ Delorie - - * init.cc (dll_entry): if the DLL is being LoadLibrary'd, - initialize some things. - * heap.cc (_sbrk): detect uninitialized heap and initialize - * dcrt0.cc (user_data): initialize to something useful. - (do_global_ctors): make global for init.cc - -Thu Jan 14 02:16:44 1999 Geoffrey Noer - - * dll_init.cc: Add missing FIXME in comment. - * fhandler_console: Ditto. - -Thu Jan 14 00:53:25 1999 Christopher Faylor - - * spawn.cc (iscmd): New function. - (spawn_guts): Treat command /c and cmd /c as special - cases. Don't quote arguments to these programs if - there are exactly three arguments. - * dcrt0.cc (dll_crt0_1): Initialize exceptions prior - to fork to allow forked processes to "dump core". - * errno.cc (seterrno): No need for this to be extern "C". - * winsup.h: Ditto. - -Wed Jan 13 19:06:08 1999 Geoffrey Noer - - * registry.cc: Add comments corresponding to various reg_key - functions, minor reformatting. - (reg_key::reg_key): Delete already-commented-out function - -Wed Jan 13 15:41:34 1999 DJ Delorie - - * errno.cc (_sys_errlist): Add "extern" to work around new gcc - restrictions. - -Mon Jan 11 14:56:27 1999 Christopher Faylor - - * spawn.cc (spawn_guts): Fix problem with #! and relative - directories. - -Mon Jan 11 09:00:29 1999 Christopher Faylor - - * fhandler_console.cc (fhandler_console::read1): Handle EOF as a - specific case. - -Sun Jan 10 23:44:22 1999 Christopher Faylor - - * fhandler.h: Define __fmode for convenience. Use throughout. - * environ.cc (parse_options): Use O_TEXT when nobinmode. - * fhandler.cc (fhandler_base::open): Don't honor __fmode - when disk file. Default to O_TEXT if no mode is specified. - (fhandler_base::fhandler_base): Don't honor __fmode when disk - file. Otherwise default to O_BINARY. - * pipe.cc (make_pipe): Default to O_BINARY if no mode specified. - -Sat Jan 9 20:58:34 1999 Christopher Faylor - - * Makefile.in: Correct previously messed up patch. - * thread.h: Add back a needed include. - * sigproc.cc (sigproc_init): Work around problem with older - compilers. - * wait.cc (wait4): Ditto. - * winsup.h (per_thread_waitq): Ditto. - * include/Windows32/CommonFunctions.h: Temporary change to - work around problems with older compilers. - -Fri Jan 8 12:53:53 1999 Christopher Faylor - - * environ.cc (parse_options): Add "forkchunk" debug setting. - Takes a value which is used to limit the size of individual memory - copies in a fork. - * fork.cc (fork_copy): Rewrite slightly to allow copying of - individual chunks of memory rather than all in one gulp. - Controlled by chunksize global variable. - -Thu Jan 7 22:02:18 1999 Christopher Faylor - - patch from Corinna Vinschen : - * utils/passwd.c: New file. - * utils/Makefile.in: Add dependencies for passwd. - * syscalls.cc (chmod): Change permission checking in case - of readonly test. - (stat_dev): Change default permission bits to allow writing - for all users. - (chown): Retry LookupAccountName with username set to domain\\username, - if returned SID-Type is not SidTypeUser. - - -Thu Jan 7 17:50:49 1999 Christopher Faylor - - * fhandler.cc (fhandler_base::set_name): Fix bug which - disallowed '%' in a file name. - -Thu Jan 7 00:21:41 1999 Geoffrey Noer - - * path.cc: Add comments. - * path.h: Correct file description comment. - -Tue Jan 5 16:07:15 1999 Christopher Faylor - - * fhandler_serial.cc (fhandler_serial::raw_read): Be more defensive - about not calling problematic functions when the overlapped I/O is - armed. Reset the overlapped event prior to calling read or suffer - an "operation aborted". - * select.cc (peek_serial): Ditto. - -Mon Jan 4 15:16:22 1999 Geoffrey Noer - - Eliminate warnings: - * utils/mount.cc (show_mounts): make format a const char *. - * utils/ps.cc (main): make literal strings const char *s. - * utils/cygpath.cc (long_options): cast literal strings to char *s. - (main): - -Sun Jan 3 20:46:12 1999 Christopher Faylor - - * select.cc (peek_console): Remove #if 0 around NT code workaround. - -Sat Jan 2 00:04:01 1999 Christopher Faylor - - * Makefile.in: Remove include directories made obsolete by - recent changes to mmap.cc. Also remove libraries that appear - to be unnecessary for linking. - * mkvers.sh: Put contents of .snapshot-date, if available, into - the DLL. - -Fri Jan 1 22:44:49 1999 Christopher Faylor - - * fhandler.h (fhandler_serial): Add flag to track state of - overlapped serial I/O. Add overlapped_setup method for common - setup of overlapped structure. - * fhandler_serial.cc (fhandler_serial::overlapped_setup): New - method. Sets up the overlapped structure for overlapped serial I/O. - (fhandler_serial::raw_read): Use overlapped_armed flag to avoid - calling functions which perform overlapped operations if overlapped - I/O is in already progress. This should only be the case if a - previous operation was interrupted or select has detected serial I/O. - (fhandler_serial::open): Use overlapped_setup. - (fhandler_serial::fixup_after_fork): Ditto. - (fhandler_serial::de_linearize): Ditto. - (fhandler_serial::dup): Ditto. - (fhandler_serial::tcsetattr): Fix typo which caused IGNPAR - to be ignored. - * hinfo.cc (hinfo::select_read): Set saw_error to zero explicitly - to avoid spurious reporting of select errors. - (hinfo::select_write): Ditto. - (hinfo::select_except): Ditto. - * select.cc (peek_serial): Use overlapped_armed to avoid calling - functions which perform overlapped operations if overlapped I/O - is already in progress. diff --git a/winsup/cygwin/ChangeLog-2000 b/winsup/cygwin/ChangeLog-2000 deleted file mode 100644 index 54494e610..000000000 --- a/winsup/cygwin/ChangeLog-2000 +++ /dev/null @@ -1,4150 +0,0 @@ -Tue Dec 27 1:08:00 2000 Corinna Vinschen - - * cygwin.din: Add symbols for `getrlimit' and `setrlimit'. - * exceptions.cc (stackdump): Avoid creating stackdump when - `rlim_core' is 0. - * resource.cc: New global variable `rlim_core'. - (getrlimit): New function. - (setrlimit): Ditto. - include/cygwin/version.h: Bump minor API version to 32 due to - adding `getrlimit' and `setrlimit'. - include/sys/resource.h: Add defines, types and prototypes for - `getrlimit' and `setrlimit'. - -Mon Dec 25 22:18:42 2000 Christopher Faylor - - * autoload.h: Make DLL initializers global to avoid inlining. - * exceptions.cc (interrupt_setup): Reorganize arguments to allow use of - regparm. - (interrupt_now): Ditto. - (interrupt_on_return): Ditto. - (call_handler): Ditto. - -Mon Dec 25 13:36:44 2000 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor version number to 8. - -Wed Dec 20 13:37:00 2000 Corinna Vinschen - - * autoload.cc: Add load statement for SetSecurityDescriptorControl. - * security.cc (alloc_sd): Always set SE_DACL_PROTECTED flag on - Win2K and higher. - -Wed Dec 20 01:02:13 2000 Christopher Faylor - - * exceptions.cc (reset_signal_arrived): Make global to avoid inlining. - -Wed Dec 20 00:57:10 2000 Christopher Faylor - - * fhandler_serial.cc (fhandler_serial::raw_read): Always find number of - bytes ready to be read whether overlapped_armed or not. - -Tue Dec 19 21:39:00 2000 Corinna Vinschen - - * syscalls.cc (remove): New function, overriding the newlib - implementation. - -Tue Dec 19 16:26:00 2000 Corinna Vinschen - - * environ.cc (struct parse_thing): Add entry for new CYGWIN option - `smbntsec'. - * path.cc (path_conv::check): Check path for being a remote path. - If so and `allow_smbntsec' is set to FALSE, set has_acls to FALSE. - * security.cc: Add global definition for `allow_smbntsec'. - * security.h: Add extern declaration for `allow_smbntsec'. - * fhandler.cc (fhandler_disk_file::open): Eliminate extern declaration - of `allow_ntsec'. - * syscalls.cc: Ditto. - -Fri Dec 15 18:54:42 2000 Bradley A. Town - - * fhandler_console.cc (read): Add support for xterm-style mouse event - reporting. - (fhandler_console::char_command): Honor mouse events. - (fhandler_console::open): Enable mouse input events. - (fhandler_console::input_tcsetattr): Ditto. - * select.cc (peek_console): Add check for mouse events. - -Fri Dec 15 17:23:17 2000 Christopher Faylor - - * path.cc (normalize_posix_path): Calculate path name length overruns - more dynamically. - (normalize_win32_path): Ditto. - * Makefile.in: Avoid scanning the directory twice for *.d files. - -Thu Dec 14 23:37:51 2000 Christopher Faylor - - * fhandler.h (fhandler_console): Add additional argument to - char_command method. - * fhandler_console.cc (fhandler_console::read): Revert previously - misapplied patch. - (fhandler_console::char_command): Add a second argument. - (fhandler_console::write): Recognize when a '?' is found after a - [. - -Tue Dec 5 17:06:00 2000 Corinna Vinschen - - * net.cc (cygwin_rexec): Eliminate superfluous call to - `set_socket_inheritance'. - * include/sys/socket.h: Add SUS defines for option values to `shutdown'. - -Sun Dec 10 17:19:04 2000 Christopher Faylor - - * include/sysexits: New file. - -2000-12-09 Egor Duda - - * autoload.cc: Autoload CharToOemA. - * dcrt0.cc (dll_crt0_1): Translate command line to OEM if current - codepage is OEM. - * environ.cc: Add new option 'codepage' to CYGWIN environment variable. - * fhandler_clipboard.cc (fhandler_clipboard::read): Read clipboard in - OEM mode if current codepage is OEM. - * fhandler_console.cc (fhandler_console::read): Only translate console - input if current codepage is ANSI. - * fhandler_console.cc (fhandler_console::write_normal): Translate - output data if current codepage is ANSI. - * pinfo.cc (codepage_init): New function. Setup current codepage from - CYGWIN environment variable and set codepage for file APIs. - * security.cc (read_sd): Translate file name to it if current codepage - is OEM. - * winsup.h: (sys_wcstombs,sys_mbstowcs): Use current codepage for - translations between multibyte and widechar string and vice versa. - -Sat Dec 9 16:29:45 2000 Christopher Faylor - - * path.cc (normalize_win32_path): Check for explicit use of two slashes - at the beginning of a path. These should be treated specially - regardless of whether they are UNC paths or old-style //a paths. Avoid - adding cwd to a path if the path already begins with '/'. - -Fri Dec 8 22:21:01 2000 Christopher Faylor - - * path.cc (normalize_win32_path): Reorganize logic to accommodate - chroot. Always check for MAX_PATH overrun. Avoid adding one too many - backslashes when src path begins with a slash. From Corinna Vinschen. - * winsup.h: Force demangling for dll_crt0 for newer compilers. - -Thu Dec 7 12:10:00 2000 Edward M. Lee - - * cygwin.din: Declare strtok_r for the import lib. Already in the DLL. - -Wed Dec 6 15:39:18 2000 Earnie Boyd - - * include/sys/uio.h (readv): Correct prototype. - (writev): Ditto. - -Tue Dec 5 17:06:00 2000 Corinna Vinschen - - * include/sys/uio.h: Include . Use __BEGIN_DECL and - __END_DECL. - Add declarations for `readv' and `writev'. - -Mon Dec 4 20:49:00 2000 Corinna Vinschen - - * Makefile.in: Change `-nostartfiles' to `-nostdlib' to avoid - automatic linking with default libraries when linking new-cygwin1.dll. - Link with libgcc.a and libstdc++.a explicitly. - -Sun Dec 3 01:20:25 2000 Christopher Faylor - - * path.cc (normalize_win32_path): Handle UNC paths better. - (slash_unc_prefix_p): Allow backslash UNC paths. - -Sun Dec 3 00:20:25 2000 Christopher Faylor - - * Makefile.in: Remove some extra cruft. - -Sun Dec 3 00:13:26 2000 Christopher Faylor - - * Makefile.in: Use CXX to build the DLL. - * configure.in: Find correct c++ compiler. - * configure: Regenerate. - * path.cc (normalize_posix_path): Put correct drive at beginning of \foo style paths. - (chdir): Don't send non-posix path to cygcwd.set. - -Sat Dec 2 22:26:00 2000 Corinna Vinschen - - * net.cc (get_inet_addr ): Close AF_UNIX socket file after reading. - -Wed Nov 29 18:25:53 2000 Kazuhiro Fujieda - - * cygheap.cc (chgheap_root::operator =): Check root dir properly. - -Thu Nov 29 18:11:00 2000 Corinna Vinschen - - * net.cc (cygwin_inet_aton): Return nonzero if the address - is valid, zero if not according to Linux man page. - -Mon Nov 27 21:09:50 2000 Kelley Cook - - * mmap.cc (munmap): Check that mmap and munmap length match. - -Tue Nov 28 18:08:00 2000 Corinna Vinschen - - * fhandler.cc (fhandler_disk_file::open): Check for buggy CreateFile - condition. - * path.cc (path_conv::check): Get file system type in call to - GetVolumeInformation to check for file systems with buggy CreateFile. - * path.h (enum path_types): Add PATH_HASBUGGYOPEN. - (class path_conv): Add methods `has_buggy_open' and - `set_has_buggy_open'. - -Sun Nov 26 16:26:14 2000 Christopher Faylor - - * fhandler.cc (is_at_eof): New function. - (fhandler_base::raw_read): Detect special case where last error == - ERROR_NOACCESS but the file is at EOF. Most UNIXes do not consider - this to be an error. - -Sun Nov 26 14:37:29 2000 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor version number to 7. - -Sat Nov 25 11:27:00 2000 Corinna Vinschen - - * include/cygwin/version.h: Bump minor API version due to adding - inet_aton. - -Sat Nov 25 11:07:00 2000 Corinna Vinschen - - * net.cc (cygwin_inet_aton): New function. - * cygwin.din: Export cygwin_inet_aton as inet_aton. - -Sat Nov 25 01:57:42 2000 Kazuhiro Fujieda - - * path.cc (mount_info::read_cygdrive_info_from_registry): Read system - cygdrive prefix with KEY_READ. - (mount_info::get_cygdrive_info): Ditto. - -Wed Nov 22 11:18:02 2000 Christopher Faylor - - * Makefile.in: new-temp.a -> new-templib.a - -Mon Nov 20 17:04:43 2000 Christopher Faylor - - * spawn.cc (spawn_guts): Quoting was still wrong. Keep trying to - fix it. - -Mon Nov 20 14:26:38 2000 Christopher Faylor - - * spawn.cc (spawn_guts): YA tweak for dealing with arcane rules of - quoting in "normal" Microsoft programs. - * child_info.h: Bump fork magic number. - * include/sys/mount.h: Add an entry for mixed mode. - -Fri Nov 17 12:28:00 2000 Corinna Vinschen - - * path.cc (normalize_posix_path): Special care for root directory - in case of files beginning with a dot. - -Fri Nov 17 12:28:00 2000 Corinna Vinschen - - * syslog.cc (syslog): Add users SID to NT syslog entry. - -Thu Nov 16 15:59:58 2000 Bradley A. Town - - * fhandler_console.cc: New member variable `dwBufferSize' for `info'. - (fillin_info): Set `dwBufferSize' to the size of the console buffer. - (clear_screen): Use width of console buffer to calculate how many - spaces to clear. - -Thu Nov 16 15:24:45 2000 Christopher Faylor - - * Makefile.in: Make import library creation 'make -j2' friendly. - -Thu Nov 16 10:28:00 2000 Corinna Vinschen - - * uinfo.cc (uinfo_init): Call `cygwin_set_impersonation_token' to - reset `cygheap->user.token' to INVALID_HANDLE_VALUE. - -Thu Nov 16 00:18:15 2000 Christopher Faylor - - * exceptions.cc (interrupt_setup): Don't set signal mask here or races - occur with main thread. Set it in sigdelayed instead. - (sigreturn): Reflect change in stack order of ebp and flags. - (sigdelayed): Set stack frame correctly. Call set_process_mask here - with flags for last trapped signal. - (signal_dispatch): Add newmask. - * sigproc.cc (wait_sig): Eliminate ill-considered attempt to halt - looping signal processors. - * perthread.h (signal_dispatch): Add newmask field. - -Wed Nov 15 22:08:00 2000 Corinna Vinschen - - * uinfo.cc (internal_getlogin): Change parameter list to reflect - that `token' is member of cygheap_user now. - (uinfo_init): Use modified internal_getlogin. - * syscalls.cc (seteuid): Ditto. - -Wed Nov 15 21:56:00 2000 Corinna Vinschen - - * cygheap.h: Move `token' and `impersonated' from class _pinfo - to class cygheap_user. - * pinfo.h: Ditto. - * fork.cc (fork_child): Change usage of `token' and `impersonated' - accordingly. - (fork_parent): Ditto. - * security.cc (cygwin_set_impersonation_token): Ditto. - * sigproc.cc (proc_subproc): Ditto. - * spawn.cc (spawn_guts): Ditto. - * syscalls.cc (seteuid): Ditto. - * uinfo.cc (uinfo_init): Ditto. - -Wed Nov 15 9:59:00 2000 Corinna Vinschen - - * spawn.cc (spawn_guts): Revert patch to ignore chroot settings - on creating native Win32 environment. - -Wed Nov 15 01:44:37 2000 Christopher Faylor - - * fork.cc (slow_pid_reuse): Off-by-one. - -Wed Nov 15 01:20:24 2000 Christopher Faylor - - Throughout use myself->ppid_handle rather than parent_alive. - * child_info.h (child_info): Eliminate parent_alive. - * dcrt0.cc (dll_crt0_1): Call fork_init for debugging pid creation. - * fork.cc (fork_child): Reflect change to fixup_mmaps_after_fork - arguments. - (slow_pid_reuse): New function to grab last 'n' pids to prevent pid - reuse. - (fork_parent): Move last_fork_proc into slow_pid_reuse. - fork_pids debugging. Eliminate unnecessary call to set_child_mmap_ptr. - (fork_init): New debugging function. - * mmap.cc (fixup_mmaps_after_fork): Renamed from - recreate_mmaps_after_fork. Rely on copied data after a fork. - (set_child_mmap_ptr): Eliminate. - * pinfo.h (_pinfo): Eliminate parent_alive, mmap_ptr and reflect above - changes. - * spawn.cc (spawn_guts): Eliminate vestiges of "old way" of sending new - hProc to parent process. - -Wed Nov 15 0:51:00 2000 Corinna Vinschen - - * cygheap.cc (cygheap_root::cygheap_root): New function. - (cygheap_root::~cygheap_root): Ditto. - (cygheap_root::operator=): Ditto. - (cygheap_user::~cygheap_user): Ditto. - (cygheap_user::set_name): Ditto. - (cygheap_user::set_logsrv): Ditto. - (cygheap_user::set_domain): Ditto. - (cygheap_user::set_sid): Ditto. - * cygheap.h (cygheap_root): New class. - (cygheap_user): Ditto. - (init_cygheap): Change type of `root' member to cygheap_root. - Add `user' member. - * dir.cc (opendir): Use new `cygheap_root' class. - * dcrt0.cc (dll_crt0_1): Use new `cygheap_user' class. - * fork.cc (fork_parent): Ditto. - * grp.cc (getgroups): Ditto. - * passwd.cc (search_for): Ditto. - * path.cc: Use new `cygheap_root' class throughout. - * pinfo.h (_pinfo): Remove `use_psid'. Move `username', `psid', - `logsrv', `domain', `orig_{uid,gid}' and `real_{uid,gid}' to - cygheap_user class. - * security.cc: Use new `cygheap_user' class throughout. - * shared.cc (sec_user): Ditto. - * sigproc.cc (proc_subproc): Remove copy statements for user - related information moved to `cygheap_user' class. - * spawn.cc (spawn_guts): Invalidate current chroot settings - when creating Windows environment. Use new `cygheap_user' class. - * syscalls.cc: Use new `cygheap_user' class throughout. - * uinfo.cc: Ditto. - (internal_getlogin): Change parameters to reflect the - move of user information to cygheap. - -Tue Nov 14 17:05:00 2000 Eric Fifer - - * dir.cc (rewinddir): Always set __d_position = 0, so next - call to readdir() will restart the directory scan. - -Tue Nov 14 00:51:28 2000 Christopher Faylor - - * cygheap.h (init_cygheap): New struct holding values that live in the - Cygwin heap. - * child_info.h (child_info): Change pointer type of cygheap to - init_cygheap. - * cygheap.cc (init_cheap): Point cygheap_max after contents of cygheap. - Move some stuff into cygheap.h. - * dir.cc (opendir): Change to use root and rootlen in cygheap rather - than in myself. - (mkdir): Change to use umask in cygheap rather than in myself. - * path.cc: Ditto, throughout. - * syscalls.cc (_open): Ditto. Change to use umask in cygheap rather - than in myself. - (chroot): Change to allocate root dir on the cygwin heap. - (umask): Change to use umask in cygheap rather than in myself. - (cygwin_bind): Ditto. - * sigproc.cc (proc_subproc): Don't copy umask or root stuff as this - happens automatically now. - * pinfo.h (_pinfo): Migrate stuff out of here and into init_cheap. - * dcrt0.cc (dll_crt0_1): Call cygheap_init later in startup for first - cygwin process. - -Sun Nov 12 23:01:35 2000 Christopher Faylor - - * path.cc (get_device_number): Allow /dev/ttySn to designate a com - port. - -Sat Nov 11 23:55:19 2000 Christopher Faylor - - * path.h: Add __attribute__ ((regparm(x))) to commonly used functions. - * pinfo.h: Ditto. - * sigproc.h: Ditto. - * sync.h: Ditto. - -Fri Nov 10 13:48:44 2000 Bradley A. Town - - * dcrt0.cc: New global variable `ignore_case_with_glob'. - (dll_crt0_1): Disable case-insensitive globbing before calling `main'. - * environ.cc (glob_init): New static function to set or clear - `ignore_case_with_glob'. - (known): Changed "glob" entry to call `glob_init'. - * glob.c (match): Use case-insensitive globbing if needed. - -Thu Nov 9 14:30:00 2000 Corinna Vinschen - - * dir.cc (readdir): Avoid reading from the beginning when - readdir is called after a previous call has returned NULL. - -Wed Nov 8 21:00:31 2000 Christopher Faylor - - * select.cc (peek_pipe): Deal with pending newline in pty_master. - -Wed Nov 8 15:35:32 2000 Christopher Faylor - - * environ.cc (_addenv): malloc space for setenv if cygwin1.dll is used - in conjunction with older binaries. - (environ_init): Ditto. - -Wed Nov 8 08:49:27 2000 Jason Tishler - - * external.cc (get_cygdrive_info): New function. - * external.cc (get_cygdrive_prefixes): Change to use get_cygdrive_info - but toss the user and system flags. - * external.cc (cygwin_internal): Add new CW_GET_CYGDRIVE_INFO case. - * path.cc (mount_info::get_cygdrive_prefixes): Remove method. - * path.cc (mount_info::get_cygdrive_info): New method. Actually, - get_cygdrive_info is really an enhanced version of - get_cygdrive_prefixes renamed to get_cygdrive_info that also gets the - user and system flags. - * shared_info.h (get_cygdrive_prefixes): Remove method. - * shared_info.h (get_cygdrive_info): New method. - * include/cygwin/version.h: Bump minor API version due to adding - CW_GET_CYGDRIVE_INFO to cygwin_internal. - * include/sys/cygwin.h (cygwin_getinfo_types): Add - CW_GET_CYGDRIVE_INFO. - -Tue Nov 7 20:58:00 2000 Corinna Vinschen - - * autoload.cc: Add autoload statement for `WSASetLastError'. - * net.cc (cygwin_connect): Change error code to WSAEINPROGRESS - when connect returns WSAEWOULDBLOCK. - -Mon Nov 6 15:11:57 2000 Christopher Faylor - - * dcrt0.cc (sigthread::init): Reinstitute sigthread lock as a critical - section. - (dll_crt0_1): Move sigthread lock initialization to earlier in startup. - * exceptions.cc (interrupt_on_return): Remove previous kludgy attempt - to detect an invalid frame. - (call_handler): Eliminate inner for loop. Grab signal critical section - lock where appropriate. - * sigproc.cc (proc_subproc): Restore uid setting. - * sigproc.h (sigthread): Reinstitute sigthread lock as a critical - section. - (sigframe): Grab the sigthread lock before clearing frame to avoid - having the signal thread use an invalid frame. - -Mon Nov 6 11:11:42 2000 Jason Tishler - - * path.cc (mount_info::read_cygdrive_info_from_registry): Use - CYGWIN_INFO_CYGDRIVE_PREFIX, CYGWIN_INFO_CYGDRIVE_DEFAULT_PREFIX, and - CYGWIN_INFO_CYGDRIVE_FLAGS. - * path.cc (mount_info::write_cygdrive_info_to_registry): Use - CYGWIN_INFO_CYGDRIVE_PREFIX and CYGWIN_INFO_CYGDRIVE_FLAGS. - * path.cc (mount_info::remove_cygdrive_info_from_registry): Ditto. - * path.cc (mount_info::get_cygdrive_prefixes): Use - CYGWIN_INFO_CYGDRIVE_PREFIX. - * include/cygwin/version.h: Add CYGWIN_INFO_CYGDRIVE_FLAGS, - CYGWIN_INFO_CYGDRIVE_PREFIX, and CYGWIN_INFO_CYGDRIVE_DEFAULT_PREFIX. - -Mon Nov 6 11:10:44 2000 Jason Tishler - - * errno.cc (strerror): Change EAGAIN case to return "Resource - temporarily unavailable" instead of "No more processes". - -Mon Nov 6 01:04:35 2000 Christopher Faylor - - * child_info.h (child_info): Add pppid_handle for closing the parent's - parent handle. - * dcrt0.cc (_dll_crt0): Close parent's parent handle when spawned or - forked. - * debug.cc (add_handle): Correct erroneous reference to handle - structure when printing warning. - * exceptions.cc (interrupt_now): Always return 1. - (interrupt_on_return): Accept a sigthread argument. Check to see if - this argument has been trashed prior to setting up the stack return. - (call_handler): Add a loop around attempts to dispatch signals to - detect case where interrupt_on_return fails. - (_sigdelayed): Set up a temporary frame pointer prior to calling stuff - that could trigger an interrupt or the stack walking code will be very - confused. - * fork.cc (fork_parent): Move a lot of the setup of the child process - into proc_subproc. - * spawn.cc (spawn_guts): Ditto. Use ppid_handle to contact logical - parent when reparenting execed process. - * pinfo.h (_pinfo): Remember the logical handle of the parent process. - * sigproc.cc (proc_subproc): Record most stuff necessary for the _pinfo - structure that is inferrable from myself when adding children. - (wait_sig): Always set 'pending_signals' flag when about to kick off - the signal scanning loop. Reset it only if there are no pending - signals. - -Sun Nov 5 13:46:23 2000 Christopher Faylor - - * pinfo (wait_subproc): Son of neverending debug tweaking. - -Sun Nov 5 11:45:15 2000 Christopher Faylor - - * pinfo (wait_subproc): Neverending debug tweaking. - -Sun Nov 5 01:34:51 2000 Christopher Faylor - - * pinfo.cc (winpids:add): New method. - (winpids::enumNT): New method renamed from EnumProcessesNT. - Use add method to add elements to the lists. - (winpids::enum9x): New method renamed from EnumProcesses9x. - Use add method to add elements to the lists. - (winpids::enum_init): Accept 'winpid' parameter to control whether - to add all windows pids to the list. - (winpids::release): New method. - * pinfo.h (winpids): Reflect above changes. - * signal.cc (kill_pgrp): Ditto. - * external.cc (fillout_pinfo): Ditto. - -Sat Nov 4 22:07:03 2000 Christopher Faylor - - * exceptions.cc (handle_sigsuspend): Record frame here for signalling. - (set_process_mask): Ditto. - -Sat Nov 4 14:24:10 2000 Christopher Faylor - - * sigproc.cc (wait_subproc): Still more debugging cleanup. - -Sat Nov 4 00:51:38 2000 Christopher Faylor - - * pinfo.cc (EnumProcessesNT): Avoid 0 pids. - (EnumProcesses9x): Ditto. - * sigproc.cc (remove_child): Eliminate. - (proc_subproc): Move remove_child stuff here. - (wait_subproc): Synchronize with proc_subproc when error occurs. Add - more debugging info. - * sigproc.h (procstuff): Add an entry. - * spawn.cc (spawn_guts): Add sigframe here. - -Fri Nov 3 20:07:14 2000 Christopher Faylor - - * sigproc.cc (wait_subproc): Refine debug output. - -Thu Nov 2 23:01:20 2000 Christopher Faylor - - * pinfo.cc (pinfo::init): Reverse order of setting status and pid info - in an execed process to avoid a race. - * sigproc.cc (wait_subproc): Print more info when a WFSO error occurs. - * automode.c: New file. - * syscalls.cc (close_all_files): Streamline slightly. - * cygheap.cc (ccalloc): Clear *entire* allocated array. - -Thu Nov 2 01:58:03 2000 Christopher Faylor - - * ntdll.h: Remove IO_COUNTERS definition since it is now in winnt.h. - -Thu Nov 2 00:10:23 2000 Christopher Faylor - - * pinfo.cc (EnumProcessesNT): New function. Eliminates dependence on - psapi.h. - (EnumProcesses9x): Rename from EnumProcessesW95. Change arguments to - be more useful for cygwin. - (winpids::init): Accommodate argument changes. - (enum_init): Ditto. - * pinfo.h (winpids): Make pidlist dynamically extendable by storing it - as a pointer and remembering the size. - * ntdll.h: Add extra definitions needed for EnumProcessesNT. Reformat - via 'indent'. - -Wed Nov 1 21:08:23 2000 Christopher Faylor - - * exceptions.cc (interruptible): Remove obsolete tests. - (sigreturn): Construct pseudo-frame-pointer so that signal handler can - figure out where to put return address when signals are coming in - quickly. - * path.cc (cwdstuff::get): Allow length 0 buffer length when buffer - when NULL. - -Tue Oct 31 18:12:56 2000 Christopher Faylor - - * path.h (has_exec_chars): Standard function for checking for - executable magic numbers. - * path.cc (symlink_info::check): Use the above function. - * fhandler.cc (fhandler_disk_file::open): Ditto. - -Tue Oct 31 17:57:52 2000 Christopher Faylor - - * path.cc (_readlink): Return ENOENT when file does not exist. - -Tue Oct 31 23:35:00 2000 Corinna Vinschen - - * fhandler.h (fhandler_dev_raw): Add method `fixup_after_exec'. - -Tue Oct 31 22:39:00 2000 Corinna Vinschen - - * fhandler.h (fhandler_dev_raw): Add definition for method - `fixup_after_fork'. - * fhandler_raw.cc (fhandler_dev_raw::fhandler_dev_raw): Add - `set_need_fixup_after_fork' call. - (fhandler_dev_raw::~fhandler_dev_raw): Revert to user space - allocation. - (fhandler_dev_raw::open): Ditto. - (fhandler_dev_raw::dup): Ditto. Reset buffer pointer. - (fhandler_dev_raw::fixup_after_fork): New function. - * fhandler_tape.cc (fhandler_dev_tape::open): Revert to user space - memory allocation. - (fhandler_dev_tape::ioctl): Ditto. Change behaviour on MTSETBLK when - new size is 1. - -Tue Oct 31 20:56:00 2000 Corinna Vinschen - - * fhandler_tape.cc (fhandler_dev_tape::open): Fix memory allocation. - Use Cygwin heap instead of user heap. - (fhandler_dev_tape::ioctl): Ditto. - -Tue Oct 31 12:00:06 2000 Christopher Faylor - - * pinfo.cc (enum_init): Don't suffer silently if we can't load the - process enumerators. - -Mon Oct 30 16:54:26 2000 Christopher Faylor - - * signal.cc (kill_pgrp): Revert 25-Oct change. - (kill_worker): Ditto. - -Sun Oct 29 20:52:31 2000 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor version number to 6. - -Sat Oct 28 01:39:53 2000 Christopher Faylor - - * configure.in: Eliminate subdir stuff. - * configure: Regenerate. - * include/getopt.h (option): Make name field 'const'. - -Fri Oct 27 20:51:00 2000 Corinna Vinschen - - * autoload.cc: New file keeping all autoload stuff. - * Makefile.in: Add autoload.o to dependencies. - * dcrt0.cc: Move all autoload stuff to autoload.cc. - * fhandler_mem.cc: Ditto. - * net.cc: Ditto. - * uinfo.cc: Ditto. - -Fri Oct 27 11:37:20 2000 Christopher Faylor - - * sigproc.cc (wait_sig): Add braces to avoid confusion. - -Fri Oct 27 11:48:00 2000 Corinna Vinschen - - * fhandler_socket.cc: New file. - * Makefile.in: Add fhandler_socket.o to dependencies. - * fhandler.h: Change comment. - * net.cc Move all fhandler_socket methods to fhandler_socket.cc. - * winsup.h: Add declaration for `ws2_32_handle'. - -Thu Oct 26 11:51:59 2000 Corinna Vinschen - - * dtable.cc (dtable::release): Check for socket. Change - cnt_need_fixup_before accordingly. - (dtable::dup2): Ditto. - (dtable::fixup_before_fork): New method. - (dtable::fixup_before_exec): Ditto. - * dtable.h (class dtable): Add member `cnt_need_fixup_before'. Add - definition for methods `dec_need_fixup_before', `inc_need_fixup_before', - `need_fixup_before', `fixup_before_exec' and `fixup_before_fork'. - * fhandler.h (class fhandler_base): Slight rearrangements. Add - definitions for methods `fixup_before_fork_exec'. - (class fhandler_socket): Eliminate superfluous constructor. - Add member `prot_info_ptr'. Add destructor. Add definitions for - methods `dup', `fixup_before_fork_exec', `fixup_after_fork' and - `fixup_after_exec'. - * fork.cc (fork_parent): Care for file types which need a fixup - before fork. Start child in suspended state then. - * net.cc: New global variable `ws2_32_handle' and `wsadata'. - (fdsock): Check for Winsock version. Call `set_socket_inheritance' - only if Winsock version < 2.0. Care for `need_fixup' count in fdtab. - (cygwin_socket): Eliminate call to `set_socket_inheritance'. - (cygwin_accept): Ditto. - (cygwin_rcmd): Ditto. - (cygwin_rresvport): Ditto. - (cygwin_rexec): Ditto. - (socketpair): Ditto. - (fhandler_socket::fhandler_socket): Set `need_fork_fixup'. Allocate - space for the WSAPROTOCOL_INFOA struct used in fixup. - (fhandler_socket::~fhandler_socket): New destructor. - (fhandler_socket::fixup_before_fork_exec): New method. - (fhandler_socket::fixup_after_fork): Ditto. - (fhandler_socket::dup): Ditto. - (wsock_init): New static function. - (LoadDLLinitfunc (wsock32)): Rearranged. - (LoadDLLinitfunc (ws2_32)): New function. - (dummy_autoload): Add autoload statemants for `WSADuplicateSocketA' - and `WSASocketA'. - * spawn.cc (spawn_guts): Care for file types which need a fixup - before exec. Start child in suspended state then. - -Wed Oct 25 20:49:59 2000 Christopher Faylor - - * signal.cc (kill_pgrp): Don't limit sending of signals to stopped - processes when sig < 0. - (kill_worker): Only send SIGCONT to stopped processes when sendSIGCONT. - -Wed Oct 25 13:56:39 2000 Christopher Faylor - - * exceptions.cc (sig_handle): Just make sure that wait_sig loops when - receiving a SIGCONT. Don't block waiting for completion that will - never occur. - -Wed Oct 25 09:59:14 2000 Christopher Faylor - - * dtable.cc (dtable::fixup_after_exec): Use variable rather than - constantly indexing into fds array. - (dtable::fixup_after_fork): Ditto. - -Wed Oct 25 10:43:00 2000 Corinna Vinschen - - * fhandler.cc (fhandler_base::fcntl): Treat O_NONBLOCK and OLD_O_NDELAY - as exactly the same. If one is set, both are set. - * net.cc (fhandler_socket::fcntl): Ditto. - -Tue Oct 24 23:58:35 2000 Christopher Faylor - - * dcrt0.cc (do_exit): Remove debugging statement. - -Tue Oct 24 23:45:09 2000 Christopher Faylor - - * dcrt0.cc (do_exit): Don't bother looking for pgrp children to send - SIGHUP if process has never created any children. - * fork.cc (fork): Set flag indicating that there is another process - with our process group. - * spawn.cc (spawn_guts): Ditto. - * pinfo.h (set_has_pgid_children): New methods for setting when process - has children in its process group. - * syscalls.cc (setpgid): Clear has_gid_children if pgid changes. - -Tue Oct 24 20:38:00 2000 Corinna Vinschen - - * ntdll.h: New file. - * fhandler_mem.cc: Move ntdll.dll specific definitions and - declarations to ntdll.h. - * sysconf.cc (sysconf): Add support for _SC_NPROCESSORS_CONF, - _SC_NPROCESSORS_ONLN, _SC_PHYS_PAGES and _SC_AVPHYS_PAGES. - -Tue Oct 24 20:00:00 2000 Corinna Vinschen - - * fhandler.cc (fhandler_base::fcntl): Behave properly when passed - previous version of O_NDELAY. - * syscalls.cc: Move OLD_O_NDELAY to winsup.h. - * winsup.h: Define OLD_O_NDELAY now. - -Mon Oct 23 21:47:55 2000 Christopher Faylor - - * exceptions.cc (signal_exit): Kill any executing child process if - we're dying. - * path.h: Remove unneeded extern. - * spawn.cc (std_suffixes): Make static. Don't set dwProcessId here - since it makes the process unsignalable. Set strace flag that this is - an execed process stub. - * strace.cc (strace::vsprntf): Use strace flag to indicate when to - visually flag that this is an exec stub. - * include/sys/strace.h (strace): Add 'execing' flag. - -Mon Oct 23 16:43:33 2000 Christopher Faylor - - * sigproc.cc (proc_subproc): Don't send a false positive if WNOHANG and - no processes are available for waiting. - -Mon Oct 23 22:27:00 2000 Corinna Vinschen - - * fhandler.cc (fhandler_base::fcntl): Setting flags in F_SETFL - branch according to Linux documentation. - -Mon Oct 23 21:43:00 2000 Corinna Vinschen - - * fcntl.cc (_fcntl): Rearrange as wrapper function. Move all - functionality except F_DUPFD to fhandler classes. - * fhandler.cc (fhandler_base::fcntl): New method. - * net.cc (fhandler_socket::fcntl): Ditto. - * fhandler.h (class fhandler_base): Add method prototype for fcntl(). - (class fhandler_socket): Ditto. - -Mon Oct 23 12:44:35 2000 Christopher Faylor - - * sigproc.cc (proc_subproc): Correctly handle flags for WNOHANG case. - -Mon Oct 23 10:00:00 2000 Corinna Vinschen - - * security.cc: Eliminate C++ comments throughout. - -Sun Oct 22 23:33:00 2000 Christopher Faylor - - * fork.cc (fork): Set sigframe here, since it can pause for a - considerable amount of time. - * environ.cc (_addenv): Add debugging. - * fhandler.cc: Eliminate unneeded include. - * smallprint.c: Ditto. - -Sun Oct 22 12:07:00 2000 Corinna Vinschen - - * pinfo.cc (pinfo_init): Eliminate call to `set_process_privileges'. - * security.cc (write_sd): Call `set_process_privileges' on the first - call to `write_sd'. - (set_process_privileges): Eliminate adjusting SE_BACKUP_NAME privilege. - -Sat Oct 21 16:57:23 2000 Christopher Faylor - - * pinfo.cc (pinfo::init): Make PID_EXECED signal creation as well as - PID_IN_USE. - -Sat Oct 21 01:52:54 2000 Christopher Faylor - - * spawn.cc (spawn_guts): Don't do the reparenting step if we notice - that the child has exited prior to sending the subprocess_ready signal - (?). - -Sat Oct 21 00:46:36 2000 Christopher Faylor - - * fhandler.h (fhandler_console): Remove tcsetpgrp. - * fhandler_console.cc (fhandler_console::tcsetpgrp): Eliminate. - * fork.cc (fork_parent): Avoid returning same pid twice in a row - regardless of OS. - * pinfo.cc (pinfo::init): Rename create argument to flags and treat it - as such. - * signal.cc (set_sigcatchers): New function. - (signal): Use set_sigcatchers to increment or decrement sigcatcher - tracker. - (sigaction): Ditto. Add debugging output. - * spawn.cc (spawn_guts): Always quote first argv[0] argument when it's - a COMSPEC shell. - -2000-10-20 DJ Delorie - - * times.cc (to_time_t): pass zero time as epoch - * fhandler.cc (fstat): copy atime/ctime from mtime if they're zero - -Thu Oct 19 23:31:41 2000 Christopher Faylor - - * external.cc (fillout_pinfo): Pass PID_NOREDIR flag to pinfo init to - avoid finding execed processes twice. - * signal.cc (kill_pgrp): Ditto. - * spawn.cc (spawn_guts): Avoid passing first argument to CreateProcess - when running a windows shell so that CreateProcess will locate the - shell. Reorganize so that correct error is returned when CreateProcess - fails. - -Thu Oct 19 13:55:31 2000 Christopher Faylor - - * dcrt0.cc (sigthread::init): Correct overzealous ifdef. - * exceptions.cc (call_handler): Avoid calling sigthread acquire lock. - * sigproc.h (sigthread): Comment out lock for now. - * sync.cc (muto::acquire): Add a minor optimization. - -2000-10-18 DJ Delorie - - * Makefile.in: add miscfuncs.cc - * miscfuncs.cc: new, miscellaneous functions - * winsup.h: define table-driven tolower/toupper - * environ.cc: use them - * fhandler_console.cc: ditto - * fhandler_termios: ditto - * path.cc: ditto - (strncasematch, strcasematch, strcasestr): move to miscfuncs.cc - -Wed Oct 18 20:50:27 2000 Christopher Faylor - - * sigproc.h (sigthread): Eliminate locking for now since per thread - signalling is not available. - * dcrt0.cc (sigthread::init): Ditto. - (dll_crt0_1): Move set_process_privileges call (temporarily?) to - pinfo_init. - (pinfo_init): Only call set_process_privileges when allow_ntsec. - -2000-10-18 DJ Delorie - - * dcrt0.cc (dll_crt0_1): init cygcwd before forkee branch - - * environ.cc (conv_start_chars): Cache a table of "first - characters" for environment variables needing conversion. - (getwinenv): Use it. - (environ_init): Create it, also check first chars for TERM and - CYGWIN. - - * path.cc: Use lookup table for case insensitive comparisons. - -Wed Oct 18 00:48:49 2000 Christopher Faylor - - * exceptions.cc (call_handler): Make signal pending if sigsave.sig is - still active. - * syscalls.cc (_read): Don't clear errno. - * sigproc.cc (wait_sig): Don't scan the waiting process list after a - SIGCHLD if there are no zombies to reap. - * winsup.h: Use __builtin_strcmp. - * environ.cc (posify): Don't initialize len unless it is required - (from DJ Delorie ). - -Tue Oct 17 14:50:31 2000 Christopher Faylor - - * sigproc.cc (proc_subproc): Remove unneeded test for correct process - in PROC_ADDCHILD. Return 0 when terminated child has just been - reparented. - (wait_subproc): Only send SIGCHLD when proc_subproc returns != 0. - * strace.cc (strace::vsprntf): Only strip .exe extension from program - name. - -2000-10-16 Charles Wilson - - * fhandler_clipboard.cc: new file - * Makefile.in: include fhandler_clipboard.o in DLL_OFILES list. - * fhandler.h: add FH_CLIPBOARD to the devices enum. - (fhandler_dev_clipboard): new - * path.cc (windows_device_names): add "\\dev\\clipboard" - (get_device_number): check for "clipboard" - * dcrt0.cc: declare a few more functions from winuser.h - * dtable.cc (dtable::build_fhandler): check for FH_CLIPBOARD in - switch(). - -Mon Oct 16 21:36:57 2000 Christopher Faylor - - * debug.cc (add_handle): Issue warning on attempts to add the same - handle more than once. - * fhandler_tty.cc (fhandler_tty_slave::open): Protect some handles. - (fhandler_tty_common::close): Use proper name when closing handles. - (fhandler_pty_master::close): Don't close to_slave or from_slave since - they've already been closed earlier in the function. - * sigproc.cc (proc_subproc): Don't protect vchild->hProcess. Expect - that the caller will do this, instead. - * tty.cc (tty_list::terminate): Use proper name when closing handles. - (tty::make_pipes): Protect some handles. - -Mon Oct 16 18:37:22 2000 Christopher Faylor - - * Makefile.in: Remove some obsolete stuff. - * dcrt0.cc (dll_crt0_1): Call signal_fixup_after_exec where appropriate. - Set myself->uid from parent version. - Just use ThreadItem Init method. Close or store hexec_proc as appropriate. - (_dll_crt0): Store user_data->forkee here so that proper tests can be made - subsequently. - (do_exit): Remove hExeced stuff. - * environ.cc (environ_init): Accept environ count as well as environ pointer. - * environ.h: Reflect above change. - * pinfo.cc (pinfo_init): Ditto. Accept environ count. - (fixup_in_spawned_child): Remove. - * spawn.cc (spawn_guts): Move signal code to dll_crt0_1. Don't suspend - execing process since it is no longer necessary. Store envc. - * exceptions.cc (signal_fixup_after_exec): New function. - (call_handler): Remove hExeced test. - * child_info.h (cygheap_exec_info): Store envc as well as envp. - (child_info_spawn): Store hexec_proc so that it can be closed in child. - * path.cc (normalize_posix_path): Avoid intermediate use of temporary cwd buf. - (normalize_win32_path): Ditto. - (cwdstuff::get_initial): Always set lock. - * sigproc.h: Remove hExeced. - * strace.cc (strace::vsprntf): Modify to accommodate for lack of hExeced. - * thread.cc (MTinterface::Init): Merge Init1 and ClearReent into this method. - (MTinterface::Init1): Eliminate. - (MTinterface::ClearReent): Eliminate. - * thread.h: Reflect above changes. - * include/sys/strace.h (strace): Make microseconds() public. - -Sun Oct 15 21:54:52 2000 Christopher Faylor - - Make various functions 'regparm', throughout. - * pinfo.h (_pinfo): Inline simple signal manipulation functions. - Requires inclusion of thread.h which was removed from .cc files, where - appropriate. throughout. - * pinfo.cc: Eliminate signal manipulation functions. - (_pinfo::exit): Calculate total rusage for exiting process here. - * cygheap.cc (size2bucket): Eliminate. - (init_buckets): Ditto. - (_cmalloc): Calculate size and bits in a loop rather than going through - a function call. - (_crealloc): Use stored array index to calculate allocated size. - * spawn.cc (spawn_guts): Use _pinfo exit method to exit, calculating - cpu usage. - -Sat Oct 14 21:24:16 2000 Christopher Faylor - - * exceptions.cc (set_console_handler): Don't allocate - console_handler_thread_waiter. It is obsolete. - (ctrl_c_handler): Don't use console_handler_thread_waiter. - * path.cc (hash_path_name): Fix handling of relative names. Make case - insensitive. - * path.h (suffix_info): Use initializers. - * pinfo.h (_pinfo): Avoid initializers for null case. - * resource.cc (fill_rusage): Zero rest of rusage structure. - * security.cc (set_process_privileges): Don't reopen parent process. - Just use hMainProc. - * signal.cc (signal): Track when a signal handler has been used. - (sigaction): Ditto. - * sigproc.cc (pchildren): Use default initializer. - (zombies): Ditto. - (sigproc_terminate): Avoid closing handles that will be closed on exit - anyway. - (wait_sig): Send signal to "parent" on EXECing, not FORKing. - (wait_subproc): Send SIGCHLD here rather than in proc_wait to avoid - potential muto conflicts. - * sigproc.h (sigthread): Don't initialize to zero. It's the default. - * spawn.cc (spawn_guts): Fill in resources from exec parent prior to - termination. - * sync.h (muto): Don't initialize to zero. - * syscalls.cc (close_all_files): Use one lock around entire loop and - call fhandler close/release stuff directly. - (_read): Don't use ready_for_read if there are not signal handlers - active. - -Sat Oct 14 12:24:24 2000 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Fix display of "title". - (do_exit): Use pinfo exit method to exit. - (__api_fatal): Ditto. - * exceptions.cc (signal_exit): Ditto. - * fork.cc (fork_child): Remove debugging stuff. Use pinfo_fixup_after - fork in place of exec_fixup_after_fork. - * pinfo.cc (pinfo_fixup_after_fork): New method. - (pinfo_fixup_in_spawned_child): Ditto. - (_pinfo::exit): New method. - (_pinfo::init): Remove recursion. Detect pathological case where pinfo - structure already exists for new pid. - * pinfo.h (_pinfo): Reorganize slightly. Add new method and new - function declarations. - * sigproc.cc (proc_exists): Previous simplification was a little to - simple. Try harder to detect if a process exists. - (proc_terminate): Use PID_EXITED setting to determine if process is - still around. - (WFSO): Remove debugging statement. - (WFMO): Ditto. - * spawn.cc (exec_fixup_after_fork): Eliminate. - (spawn_guts): Always set old_title to NULL. Is it really needed? Move - hexec_proc to pinfo.cc. Call pinfo_fixup_in_spawned_child to eliminate - handle link after a spawn. - * include/sys/cygwin.h: Remove PID_NOT_IN_USE. Add PID_EXITED. - -Sat Oct 14 10:54:00 2000 Corinna Vinschen - - * cygwin.din: Add symbol hstrerror. - * net.cc: Change meaning of member `s' of struct host_errmap. - (set_host_errno): Fix error in loop condition. - (hstrerror): Ditto. - (herror): Add appropriate functionality. - * include/netdb.h: Add declaration of hstrerror. - * include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR to 29. - -Sat Oct 14 01:45:25 2000 Christopher Faylor - - * cygheap.cc (cygheap_fixup_in_child): Don't page round cygheap copied - from parent. - * dcrt0.cc (do_exit): Don't cleanup pinfo on exit. That happens - automatically now. - * exceptions.cc (signal_exit): Ditto. - * fork.cc (fork_parent): Use stack_here value passed in from fork(). - (fork): Figure out top of stack here and pass it to fork_parent. - * pinfo.cc (_pinfo::record_death): Eliminate. - * pinfo.h (_pinfo): Ditto. - * sigproc.cc (proc_exists): Simplify. - (proc_terminate): Ditto. - (remove_zombie): Don't cleanup pinfo stuff. - (wait_sig): Send subproc_ready signal whether execed or spawned. - * spawn.cc (spawn_guts): Always create subproc_ready event. Use it for - both exec and spawn. - (_spawnve): Send proper mode to spawn_guts when mode != _P_OVERLAY. - -Thu Oct 12 23:11:05 2000 Christopher Faylor - - * dtable.cc (dtable::fixup_after_fork): Revert thinko below. - * pinfo.cc (set_myself): Show pid in initial strace line. - -Thu Oct 12 17:58:03 2000 Christopher Faylor - - * child_info: Bump child_info "version". - (child_info): Move some fields from child_info_spawn to here. - * cygheap.cc: Make cygheap pointers NOCOPY. - * dcrt0.cc (dll_crt0_1): Copy cygwin heap here regardless of whether - we've been forked or execed. - * dtable.cc (dtable::fixup_after_fork): Just release close-on-exec fds. - * exceptions.cc (stackdump): Respond to C warning. - * fork.cc: Reorganize to minimize stack copying. - (fork_child): New function. - (fork_parent): Ditto. - (sync_with_child): Don't suspend the forkee. - (sync_with_parent): Ditto. Make into a function. - * heap.cc (heap_init): Add some debugging output. - * path.cc (path_conv::check): Add an assertion. - (has_suffix): Ditto. - * security.cc (get_pw_sid): Defend against NULL. - * sigproc.cc (proc_subproc): Fix debugging output. - (wait_sig): Ditto. - * strace.cc: Make statics NO_COPY throughout. - (strace::vsprntf): Defend against NULL. - -Thu Oct 12 00:25:29 2000 Christopher Faylor - - * errno.cc (seterrno_from_win_error): Fix debugging output. - * fhandler.cc (fhandler_base::fstat): Move to inline method in - fhandler.h. - (fhandler_base::set_io_handle): Ditto. - * fhandler.h (fhandler_base): Make some methods inline. - * fhandler_console.cc (fhandler_console::write_normal): Make buffer - larger. - * sigproc.h (sigframe::sigframe): Actually use set ebp parameter - correctly. - * spawn.cc (spawn_guts): Set dwProcessId when exec'ing. Just exit - immediately after reparenting. - * syscalls.cc: Sprinkle sigframe stuff throughout. - * wait.cc (wait4): Set signal frame here. - -Tue Oct 10 19:54:06 2000 Christopher Faylor - - * dcrt0.cc (__api_fatal): Don't rely on small_printf to display errors. - Always display problems to the console, if possible. - -Tue Oct 10 15:21:10 2000 Christopher Faylor - - * path.cc (cwdstuff::get): Set EINVAL when length is zero. - -Mon Oct 9 14:07:04 2000 Christopher Faylor - - * path.cc (mount_info::cygdrive_posix_path): Handle e:foo construction - correctly. - -Mon Oct 9 16:44:00 2000 Corinna Vinschen - - * fhandler_mem.cc (fhandler_dev_mem::fhandler_dev_mem): - Fix debug output. - -Mon Oct 9 15:58:00 2000 Corinna Vinschen - - * fhandler_mem.cc: Eliminate unused include statements. - (fhandler_dev_mem::fhandler_dev_mem): Check for 9X/ME. - -Mon Oct 9 15:11:00 2000 Corinna Vinschen - - * fhandler.h (fhandler_dev_mem): Erase member `init_phase' and - member function `init'. - * fhandler_mem.cc: Add typedefs for NT internal data types - `SYSTEM_INFORMATION_CLASS' and `SYSTEM_BASIC_INFORMATION'. - Add prototype for `NtQuerySystemInformation' function. - (fhandler_dev_mem::fhandler_dev_mem): Takes over initialization task - from `init'. Use `NtQuerySystemInformation' function to evaluate the - size of physical memory instead of interval search. - (fhandler_dev_mem::init): Eliminated. - (fhandler_dev_mem::open): Don't call `init'. - (fhandler_dev_mem::read): Eliminate check for `init_phase'. - (dummy_autoload): Add load statement for `NtQuerySystemInformation'. - -Sun Oct 8 22:38:40 2000 Christopher Faylor - - * dtable.cc (set_std_handle): Use std_consts array to control - SetStdHandle settings. - (dtable::fixup_after_fork): Ditto. - * exceptions.cc (set_sig_errno): Remove some debugging output. - * path.cc (path_conv::check): Don't OR need_directory with flags sent - to symlink_info::check. - (symlink_info::check): Use PATH_ALL_EXEC to determine when a file is - executable. - * path.h (path_types): Add PATH_ALL_EXEC. - (isexec): Use PATH_ALL_EXEC so that cygexec types will be considered - executable. - * pinfo.h (_pinfo): Add a process handle that is kept open throughout - the life of a cygwin pid. - * sigproc.cc (proc_exists): Remove hopefully obsolete stuff. - (proc_subproc): Set up process handle that is kept open throughout the - life of a cygwin pid. Reorganize PROC_WAIT stuff to use common code. - (proc_terminate): Close pid lifetime process handle. - (checkstate): Cleanup. - (stopped_or_terminated): Move zombie cleanup. - (remove_zombie): To here. - * spawn.cc (spawn_guts): Reorganize reparenting code for 1247th time. - -Sat Oct 7 13:59:15 2000 Christopher Faylor - - * fhandler.h (fhandler_base): Remove obsolete _rpos and _rsize - elements. - * fhandler.cc (fhandler_base::open): Ditto. - * fhandler.cc (fhandler_base::fhandler_base): Ditto. - (fhandler_base::read): Ditto. Add more debugging output. Don't issue - a \r when \r\n detected. - * pipe.cc (make_pipe): Streamline slightly. Make debug output more - interesting. - * strace.cc (strace::vsprintf): Use __progname where appropriate to - distinguish strace output when exec'ing. - -Sat Oct 7 19:25:00 2000 Corinna Vinschen - - * fhandler.h (fhandler_dev_mem): Add methods mmap, munmap and msync. - Add `unit' member. - * fhandler_mem.cc (fhandler_dev_mem): Initialize `unit' as well. - (init): Care for differences between /dev/mem, /dev/kmem (not - implemented yet) and /dev/port. - (open): Change debug message to reflect the device. - (mmap): New function. - (munmap): Ditto. - (msync): Ditto. - (fstat): Use unit when setting st_dev in stat structure. - * mmap.cc (mmap): Handle MAP_ANONYMOUS flag. - Change error handling slightly. - * path.cc (get_device_number): Handle /dev/port. - -Fri Oct 6 23:21:29 2000 Christopher Faylor - - * syscalls.cc (_read): Behave properly when passed previous version of - O_NDELAY. Fix up debugging output. - -Thu Oct 5 20:34:48 2000 Christopher Faylor - - * net.cc (set_socket_inheritance): Rename from duplicate_socket. Use - NT specific call when appropriate. - (__set_winsock_errno): Rename from set_winsock_errno. Accept function - and line as arguments. - * path.cc (path_conv::check): Continue the neverending battle to make - cygwin properly understand that path specs ending in a slash require - that the path refer to a directory. Windows does not do this by - default. - (symlink_info::check): Remove ENOTDIR test. Move it to - path_conv::check. - * path.h: Remove obsolete constant. - * winsup.h (set_winsock_errno): New macro. - -Thu Oct 5 14:58:00 2000 Corinna Vinschen - - * fhandler.h: Add mmap(), munmap() and msync() to fhandler_base - and fhandler_disk_file. - * mmem.cc (mmap): Eliminated device dependent implementation details. - These are moved to the appropriate fhandler class. - (munmap): Ditto. - (msync): Ditto. - (fhandler_base::mmap): New method. - (fhandler_base::munmap): Ditto. - (fhandler_base::msync): Ditto. - (fhandler_disk_file::mmap): Ditto. - (fhandler_disk_file::munmap): Ditto. - (fhandler_disk_file::msync): Ditto. - -Thu Oct 5 01:52:43 2000 Christopher Faylor - - * net.cc: General cleanup. - (fdsock): Return pointer to created fhandler_socket. - (cygwin_socket): Use pointer returned by fdsock. Return correct errno - when fd < 0. - -Thu Oct 5 00:48:40 2000 Christopher Faylor - - * exceptions.cc (interruptible): Add extra debugging. - * sigproc.h (wait_sig): Fill in frame pointer, by default, prior to - calling or suffer confusion due to September 7 change below. - -Wed Oct 4 23:10:27 2000 Christopher Faylor - - * include/netinet/tcp.h: Remove winsock.h include. - * include/sys/cygwin.h: Move windows specific reference within - conditional. - -Thu Oct 5 1:13:00 2000 Corinna Vinschen - - * include/sys/mman.h: Add missing MAP_FAILED macro. - -Wed Oct 4 18:48:00 2000 Corinna Vinschen - - * fhandler.h (fhandler_dev_mem): Add method `init'. Add members - `mem_size' and `init_phase'. - * fhandler_mem.cc (init): New function to figure out the size of - the physical memory. - (open): Add checking for illegal flags. Change usage of access mode. - (write): Add intended functionality. - (read): Add parameter checking. Eliminate page size constant. Use - getpagesize() instead. Don't touch errno and don't create debug output - while init() is running. - (lseek): Add bounds checking. Fix SEEK_END. - (fstat): Eliminate page size constant. Use getpagesize() instead. - (dup): Add intended functionality. - -Mon Oct 2 22:15:00 2000 Corinna Vinschen - - * dcrt0.cc: Add LoadDLLFunc statement for RegEnumValueA(). - * net.cc: Change comments related to get_ifconf. - (get_2k_ifconf): Eliminate `type' variable. Eliminate `sa' parameter. - (get_nt_ifconf): Ditto. - (get_9x_ifconf): Ditto. Rewritten. - (get_ifconf): Change calls to OS specific functions. - -Mon Oct 2 15:15:01 2000 Christopher Faylor - - * signal.cc (sigaction): Allow new action == oldaction. - -Mon Oct 2 11:05:00 2000 Corinna Vinschen - - * fhandler_mem.cc: Load ntdll functions via autoload method. - (load_ntdll_funcs): Eliminated. - -Sun Oct 1 16:36:00 2000 Corinna Vinschen - - * fhandler_mem.cc (load_ntdll_funcs): Add missing __stdcall qualifiers. - -Sun Oct 1 22:20:39 2000 Christopher Faylor - - * cygheap.cc (cygheap_init): Born again function. - (_cmalloc): Reorganize to accommodate muto locking. - (_cfree): Use muto lock to avoid multi-thread problems. - * cygheap.h (incygheap): Just use cygheap_max to find upper cygwin heap - bounds. - * dcrt0.cc (dll_crt0_1): Reinstitute cygheap_init call. - * path.cc (getcwd): Just return cwdstuff::get result, allowing correct - handling of negative length. - (cwdstuff::get): Malloc a buffer if one is not available. - -Sun Oct 1 2:56:00 2000 Corinna Vinschen - - * Makefile.in: Add fhandler_mem.o to the dependencies. - * dtable.cc (dtable::build_fhandler): Add case for FH_MEM. - * fhandler.h: Add FH_MEM device type. Add class fhandler_dev_mem. - * fhandler_mem.cc: New file. Implementation of class fhandler_dev_mem. - * path.cc: Add /dev/mem to windows_device_names. - (get_device_number): Add FH_MEM type. - -Sat Sep 30 00:43:42 2000 Christopher Faylor - - * cygheap.cc (init_cheap): Set aside space for heap walk pointer. - (_csbrk): Make logic for detecting when to alloc cognizant of - initialization condition. - (_cmalloc): Use a structure to hold bucket size and heap chain pointer. - Store pointer to next freed block in bucket size location so that it - will be easy to see if a block is allocated. - (_cfree): Store pointer to next freed block in bucket size location. - (_crealloc): Use macro to retrieve bucket size. - (cygheap_init): Eliminate. - (cygheap_fixup_in_child): Add second argument to determine if we were - execed or not. In execed case, walk the heap, cleaning up any orphaned - blocks. - * cygheap.h: Add a "MAX" value to cygheap_types. Remove cygheap_init - declaration. Accommodate new argument to cygheap_fixup_in child. - * fork.cc (fork): Accommodate extra argument to cygheap_fixup_in_child. - * dcrt0.cc (dll_crt0_1): Ditto. Remove call to cygheap_init. - -Fri Sep 29 21:49:27 2000 Christopher Faylor - - * path.cc (symlink_info::check): Set executable bit for a file if the - first two characters are 'MZ' to mirror spawn_guts check. - -Sat Sep 30 03:34:00 2000 Corinna Vinschen - - * winsup.h: Add `winME' to os_type symbols. - * dcrt0.cc (set_os_type): Identify Windows ME systems. - * (host_dependent_constants::init): Care for winME. - * uname.cc (uname): Ditto. - -Thu Sep 28 01:46:00 2000 Corinna Vinschen - - * net.cc (get_ifconf): Code cleanup. Split. Call os dependent - subfunctions instead. - (get_9x_ifconf): New function for 9X systems, called by get_ifconf. - (get_nt_ifconf): New function for NT systems, called by get_ifconf. - (get_2k_ifconf): New function for W2K systems, called by get_ifconf. - -Wed Sep 27 01:10:07 2000 Christopher Faylor - - * spawn.cc (spawn_guts): Attempt to accommodate archaic windows quoting - mechanism when dealing with '\' and '"'. - -Mon Sep 25 20:47:04 2000 Christopher Faylor - - * dcrt0.cc (quoted): Fix problem where ' quoted strings were skipped. - * fhandler.h (fhandler_socket::~fhandler_socket): Delete declaration. - * net.cc: Remove unnecessary "number_of_sockets" usage. - (fhandler_socket::fhandler_socket): Ditto. - (fhandler_socket::~fhandler_socket): Delete definition. - * spawn.cc (spawn_guts): Force first argument passed to CreateProcess - as a command line to be windows style. - -2000-09-25 Christopher Faylor - - * spawn.cc (av::dup_maybe): Make function void rather than void *. - * environ.cc (environ_init): Remember to reparse CYGWIN if envp is - supplied. - * heap.cc (_sbrk): Remember frame for signal handling. - * syscalls.cc (read_handler): Eliminate. - (_read): Move read_handler code here. Reorganize for one path through - 'ready_for_read'. - -Tue Sep 19 09:46:36 2000 Christopher Faylor - - * spawn.cc (spawn_guts): Use actual program argument passed in for - argv[0] as originally suggested by Kazuhiro Fujieda - . - -Mon Sep 18 23:17:19 2000 Christopher Faylor - - * path.h: Create new input path flag PATH_NEEDDIR. - * path.cc (path::check): Detect trailing slash before converting to - windows path. Tell symlink_info::check to check for directory if one is - found. - (symlink_info::check): Set errno when path is not a directory if - pflags & PATH_NEEDDIR. - -Mon Sep 18 19:44:08 2000 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_slave::write): Correct typo which - caused resetting of windows error to ERROR_IO_DEVICE to be ignored. - -Mon Sep 18 17:15:37 2000 Kazuhiro Fujieda - - * path.cc (mount_info::read_mounts): Don't delete mount entries of - which mount points have the cygdrive prefix. - * (mount_info::add_reg_mount): Properly catch errors on registry - operations. - * (mount_info::write_cygdrive_info_to_registry): Ditto. - * (mount_info::del_reg_mount): Cosmetic changes to be consistent - with other methods. - * (mount_info::add_item): Check arguments more precisely. - Increment nmounts only when registry operations succeed. - -Sun Sep 17 22:18:39 2000 Christopher Faylor - - * exceptions.cc (interruptible): Return 0 if given an address in - uncommitted memory. - -2000-09-16 Egor Duda - - * signal.cc (sleep): If interrupted by signal, return the - requested time minus the time actually slept. - -Fri Sep 15 22:30:40 2000 Christopher Faylor - - * exceptions.cc (handle_exceptions): Just "core dump" if SIGSEGV in - signal thread. - * external.cc (fillout_pinfo): Fix compiler warning. - * sigproc.h: Eliminate special asm naming for sig_dispatch_pending. - * sigproc.cc (sig_send): Remove debugging statements. - -Wed Sep 13 14:56:47 2000 Christopher Faylor - - * spawn.cc (av): Hide 'calloced' field and limit cstrduping to class - methods only. - (spawn_guts): Use methods for manipulating most newargv stuff. - -2000-09-13 Egor Duda - - * child_info.h (child_info_spawn::~child_info_spawn): Avoid - memory leaks in cygheap. - * spawn.cc (spawn_guts): Ditto. - -Wed Sep 13 14:28:03 2000 Christopher Faylor - - * dcrt0.cc (quoted): Return next character after a quoted string when - not doing special quote processing. Also ensure that non-NULL is - returned in all circumstances. - -Wed Sep 13 10:26:16 2000 Christopher Faylor - - * spawn.cc (spawn_guts): Ensure that argv[0] is correctly set to the - full path when a script is detected. Suggested by Kazuhiro Fujieda - . - -Tue Sep 12 22:33:30 2000 Christopher Faylor - - * external.cc (fillout_pinfo): Handle explicit pids correctly. - -Tue Sep 12 14:37:32 2000 Christopher Faylor - - * path.cc (normalize_posix_path): Fix more slashdot madness. - -Tue Sep 12 12:29:29 2000 Christopher Faylor - - * Makefile.in: Make clean target remove *.d. - -Mon Sep 11 13:19:15 2000 Christopher Faylor - - * path.cc (normalize_posix_path): Correctly deal with a "." parameter. - -Sun Sep 10 20:23:35 2000 Christopher Faylor - - * cygheap.cc (init_cheap): Just use any old address for the cygwin - heap. - * exceptions.cc (signal_exit): Don't terminate the main thread. Just - try to exit in this thread really quickly. - * signal.cc (kill_pgrp): Fix typo which caused pinfo structure to be - assigned incorrectly. - -Sun Sep 10 12:40:49 2000 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Initialize thread and debug stuff before - handling exec/fork. - * dtable.cc (dtable::fixup_after_exec): Always clear out the read ahead - buffer whether closing or adjusting. - * path.cc (chdir): Avoid a compiler warning. - -Sat Sep 9 23:29:17 2000 Christopher Faylor - - * path.cc (chdir): Use the full path for cwd_win32. Consider attempts - to chdir to strings of dots > 2 to be an error. Pass 'dir' argument to - cygcwd.set. - (cwdstuff::set): Need to treat arguments from chdir differently. - * path.h (cwdstuff): Add an argument to set. - -Fri Sep 8 11:50:09 2000 Christopher Faylor - - * lib/_cygwin_crt0_common.cc: Add missing header files. - -Thu Sep 7 23:07:21 2000 Christopher Faylor - - * sigproc.h (sigframe::set): Eliminate second argument. Default bp to - current frame pointer rather than using this within the function, which - is unstable when this method is not inlined. - * net.cc: Eliminate use of second argument to sigframe.set throughout. - * select.cc (cygwin_select): Ditto. - * sigproc.cc (sig_send): Ditto. - -Thu Sep 7 22:45:16 2000 Christopher Faylor - - Break out more header info into separate files. Use appropriate - header files throughout. - * shared.h: Remove. - * cygwin_version.h: New file. - * delqueue.h: New file. - * environ.h: New file. - * host_dependent.h: New file. - * perprocess.h: New file. - * registry.h: New file. - * security.h: New file. - -Thu Sep 7 12:14:43 2000 Christopher Faylor - - Split out tty and shared_info stuff into their own headers and use - throughout. Include sys/termios.h for files which need it. - * tty.h: New file. - * shared_info.h: New file. - * fhandler.h: Move inline methods that rely on tty stuff to - fhandler_console.cc. - * fhandler_tty.cc (fhandler_pty_master::process_slave_output): Set - output_done_event immediately after reading data to speed up tty output - processing. - (process_output): Set write_error to errno or zero. - (fhandler_tty_slave::write): Check previous write error prior to - writing to slave end of pipe. This allows tty output to be slightly - less synchronous. - * fhandler_console.cc (fhandler_console::tcsetpgrp): Moved here from - fhandler.h. - (fhandler_console::set_input_state): Ditto. - -Wed Sep 6 21:11:13 2000 Christopher Faylor - - * exceptions.cc (signal_exit): Reset all mutos owned by the main - thread. - * fhandler.h: Define *_output_mutex macros for serializing tty output. - (fhandler_termios): Remove restart_output_event. Define dummy output - mutex methods. - (fhandler_pty_master): Remove unneeded fixup_after_fork method. - * fhandler_termios.cc (fhandler_termios::line_edit): Acquire - output_mutex when CTRL-S is hit. Release it on CTRL-Q. - * fhandler_tty.cc (fhandler_pty_master::process_slave_output): Remove - inappropriate OutputStopped test here. Just use the output mutex. - (fhandler_pty_master::fhandler_pty_master): Remove obsolete reference - to restart_output_event. - (fhandler_tty_common::close): Ditto. - (fhandler_pty_master::set_close_on_exec): Ditto. - (fhandler_pty_master::fixup_after_fork): Delete. - * tty.cc (tty::common_init): Ditto. - * sync.cc (muto::reset): New method. - * sync.h: Declare above method. - -Wed Sep 6 16:56:38 2000 Christopher Faylor - - * sigproc.cc: Add include file for proper definitions. - * spawn.cc: Ditto. - * winsup.h: Define cfree to avoid newlib pollution. - -Wed Sep 6 14:11:51 2000 Christopher Faylor - - * Makefile.in (CFLAGS): Ensure that -MD is always added even when - CFLAGS is overwritten. - -Wed Sep 6 02:40:12 2000 Christopher Faylor - - * path.cc (cwdstuff::get_initial): Keep caching alive. - (mount_info::conv_to_win32_path): Fill out relative path in failing - case. - -Tue Sep 5 21:36:15 2000 Christopher Faylor - - * path.cc (normalize_posix_path): Deal with error return from cygcwd.get. - (normalize_win32_path): Ditto. - (mount_info::conv_to_win32_path): Ditto. - (cwdstuff::get): Set buf to NULL on error. - -Tue Sep 5 17:49:34 2000 Christopher Faylor - - * path.cc (readlink): 'max' should be a 'min' or we'll suffer - buffer overflow. - -Mon Sep 4 22:53:58 2000 Christopher Faylor - - * path.cc (cwd_win32): Eliminate. - (cwd_posix): Eliminate. - (cwd_hash): Eliminate. - (cwdstuff::init): Rename from cwd_init. - (cwdstuff::fixup_after_exec): Rename from cwd_fixup_after_exec. - (cwdstuff::get): Rename from get_cwd_inner. - (normalize_posix_path): Eliminate cwd argument. Just calculate when - necessary. - (normalize_win32_path): Ditto. - (mount_info::conv_to_win32_path): Eliminate cwd retrieval here. - (mount_info::conv_to_posix_path): Ditto. - (hash_path_name): Accommodate additional methods in cwdstuff. - (get_cwd_win32): Eliminate. - (getcwd): Use cwdstuff methods. Properly handle case where buf == NULL - and len < 0. - (cwdstuff::get_hash): New method. - (cwdstuff::get_initial): New method. - (cwdstuff::set): New method. - (cwdstuff::get): New method. - (cwdstuff::copy): New method. - * path.h: Move cwdstuff struct here. Add a bunch of stuff to cwdstuff. - Make cygcwd an extern. - * spawn.cc (spawn_guts): Use copy method to get copies of cwd info to - pass to execed process. - * dcrt0.cc (dll_crt0_1): Use cygcwd methods for cwd initialization. - -2000-09-03 Egor Duda - - * path.cc (readlink): Check if buffer length is positive. - Truncate output to buffer length. Don't terminate buffer - with '\0'. - -Sun Sep 3 00:38:40 2000 Christopher Faylor - - * environ.cc (environ_init): Don't free the new environment table after - we've just copied stuff to it. - -Sun Sep 3 00:07:32 2000 Christopher Faylor - - * Makefile.in: Add cygheap.o. - * child_info.h: Add specific exec class. - * cygheap.h: New file. Contains declarations for cygwin heap. - * cygheap.cc: New file. Implements cygwin heap functions. - * dcrt0.cc (quoted): Simplify due to new method for passing arguments - between cygwin programs. - (alloc_stack_hard_way): Attempt to handle overlapped stack. - (dll_crt0_1): Move child_info processing here. Accommodate new method - for passing arguments between cygwin programs. Initialize cygwin heap. - Establish __argc and __argv variables. - (_dll_crt0): Move most of child_info processing to dll_crt0_1. - (cygwin_dll_init): Remove duplication. - * dtable.cc (dtable::extend): Allocate dtable using cygwin heap. - (dtable::build_fhandler): Ditto for fhandler type being constructed. - (dtable::dup_worker): Free new fhandler from cygwin heap on error. - (dtable::select_*): Don't assume that this == fdtab. - (dtable::linearize_fd_array): Delete. - (dtable::delinearize_fd_array): Delete. - (dtable::fixup_after_exec): New file. - (dtable::vfork_child_dup): Use cygwin heap. - (dtable::vfork_parent_restore): Ditto. - * dtable.h: Remove obsolete methods. Add new method. - * environ.cc (posify): Eliminate already_posix parameter and logic. - (envsize): New function. - (_addenv): Use envsize. - (environ_init): Accept an argument pointing to an existing environment - list. If supplied, allocate space for this in the the program's heap. - * fhandler.cc (fhandler_base::operator =): Move here from fhandler.h. - Use cygwin heap to allocate filenames. - (fhandler_base::set_name): Allocate/free names from cygwin heap. - (fhandler_base::linearize): Delete. - (fhandler_base::de_linearize): Delete. - (fhandler_base::operator delete): Free from cygwin heap. - (fhandler_base::~fhandler_base): Ditto. - * fhandler.h: Accommodate elimination of *linearize and other changes - above. - * fhandler_console.cc (fhandler_console::fixup_after_exec): Rename from - de_linearize. - * heap.h: New file. - * fhandler_tty.cc (fhandler_tty_slave::fhandler_tty_slave): Use cygwin - heap for name. fhandler_tty::fixup_after_exec): Rename from - de_linearize. - * fork.cc (fork): Call cygheap_fixup_in_child. - * heap.cc: Use declarations in heap.h. - * malloc.cc: Sprinkle assertions throughout to catch attempts to - free/realloc something from the cygwin heap. - * path.cc: Throughout, eliminate use of per-thread cache for cwd. Use - cwd_* functions rather than cwd_* variables to access cwd_win32 and - cwd_posix. - (cwd_win32): New function. - (cwd_posix): New function. - (cwd_hash): New function. - (cwd_fixup_after_exec): New function. - * path.h: Accommodate path.cc changes. - * pinfo.cc (pinfo_init): Accept a pointer to an environment table. - Pass this to environ_init. Eliminate old 'title' tests. - * pinfo.h: Accommodate above change in argument. - * spawn.cc (struct av): New method for building argv list. - (av::unshift): New method. - (spawn_guts): Allocate everything that the child process needs in the - cygwin heap and pass a pointer to this to the child. Build argv list - using new method. Eliminate delinearize stuff. - * thread.h: Eliminate _cwd_win32 and _cwd_posix buffers. - * winsup.h: Eliminate obsolete functions. Add envsize() declaration. - -2000-09-02 Egor Duda - - * Makefile.in: Remove "make check" support. It is now in - winsup/Makefile.in. - -Fri Sep 1 21:17:03 2000 Christopher Faylor - - * sigproc.cc (mychild): New function. - (proc_subproc): Use mychild() to determine if a specific pid is valid - for wait()ing. - -Fri Sep 1 16:57:44 2000 Christopher Faylor - - * sigproc.cc (sigproc_init): Create wait_sig_inited without auto-reset - to avoid potential races. - (init_child_info): Avoid unneeded test. - -Fri Sep 1 16:51:26 2000 Christopher Faylor - - * sigproc.cc (proc_info): Rename proc_exists which takes a pid to - "pid_exists". - * shared.h: Split out "child_info" stuff into a new header file and - use where necessary. - Declare pid_exists. - * child_info.h: New file. - -Thu Aug 31 16:06:21 2000 Christopher Faylor - - * errno.cc (set_errno_from_win_error): Actually use arguments to - strace_printf. - -2000-08-30 DJ Delorie - - * times.cc (gettimeofday): use GetSystemTimeAsFileTime to avoid a - conversion - (FACTOR): correct value - (genf): set milliseconds to zero, DOW to 4. - -2000-08-29 Egor Duda - - * grp.cc (getgroups): fail with EINVAL if array is not large - enough to hold all supplementary group IDs. - -Mon Aug 28 22:03:21 2000 Christopher Faylor - - * signal.cc (_raise): New function. - * exceptions.cc (unused_sig_wrapper): Remove _raise. - * sigproc.h (class sigframe): Default frames to skip to zero or suffer - from exuberant optimization. - * fhandler_tty.cc (fhandler_tty::write): Set appropriate errno when - WriteFile to pipe fails. - -Fri Aug 25 23:44:48 2000 Christopher Faylor - - * pinfo.h (pinfo): Un-inline release. - * pinfo.cc (pinfo::release): Move here from pinfo.h. - * sigproc.cc (proc_terminate): Remove bogus 'pinfo child' which caused - strange destruction of random regions of memory when destructor was - invoked. - -Fri Aug 25 21:25:32 2000 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Move set_os_type. - (_dll_crt0): To here. - (cygwin_dll_init): And here. - * external.cc (fillout_pinfo): Use more foolproof method for scanning - for pids. - * pinfo.cc (set_myself): Eliminate myself_identity.init. - * sigproc.cc (wait_sig): Do it here instead to reduce the amount of - time where there could potentially be two processes with the same pid. - * spawn.cc (spawn_guts): Eliminate duplicate initialization. - * include/sys/cygwin.h: Mark unused PID_* elements. - -Fri Aug 25 21:49:00 2000 Corinna Vinschen - - * exec.cc (_execve): Change definition according to declaration in - newlib/libc/include/sys/unistd.h. - -Thu Aug 24 22:17:19 2000 Christopher Faylor - - * external.cc (cygwin_internal): Add CW_INIT_EXCEPTIONS to allow cygwin - exception handling on threads not created by cygwin. - * sigproc.cc (proc_terminate): Don't release pinfo structs since we are - exiting. - * include/sys/cygwin.h: Add CW_INIT_EXCEPTIONS. - -Thu Aug 24 17:16:14 2000 Christopher Faylor - - * select.cc (cygwin_select): Correct logic for "always_ready" fds or - when there is no wait specified. - * syslog.cc (pass_handler::set_message): Zero the buffer prior to - setting it. - -2000-08-24 Egor Duda - - * include/cygwin/core_dump.h: New file, contains structures used in - cygwin core core files. - * include/sys/procfs.h: New file, needed to autoconfigure cygwin core - dumps support in bfd. - -Thu Aug 24 13:50:15 2000 Christopher Faylor - - * environ.cc (parse_thing): nobinmode should force O_TEXT. - (regopt): Use correct path to find LOCAL_MACHINE registry options. - * fhandler.cc (fhandler_base::open): Set binary mode only when binmode - == O_BINARY. - * pipe.cc (pipe): Pipe handling should rely on binmode not _fmode now - that the two are different. - -Thu Aug 24 13:21:09 2000 Christopher Faylor - - * include/sys/cygwin.h (strace_printf_wrap): Force printing when - _STRACE_SYSTEM. - (strace_printf_wrap1): Ditto. - -Thu Aug 24 12:30:17 2000 Christopher Faylor - - * debug.h: Allow some debug defines for use in header files. - -Wed Aug 23 23:00:24 2000 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Move exception list and constructor stuff - earlier in the process. Use new second argument to set_myself. - (cygwin_dll_init): Initialize exception list and constructor stuff - here. - (_dll_crt0): And here. Also, deal with inherited pinfo shared memory - region from parent. - * pinfo.cc (set_myself): Accept a second argument signifying the a - shared memory region, passed from an execing parent. - (pinfo_init): Ditto. - * pinfo.h: Ditto. - * shared.h (child_info): Add a handle field to pass to child. - * spawn.cc (spawn_guts): Create a shared handle to pass to an execed - child. - * winsup.h: Remove extraneous declaration. - -Wed Aug 23 10:51:57 2000 Christopher Faylor - - * include/sys/cygwin.h: Protect class definitions. - -Tue Aug 22 13:57:36 2000 Christopher Faylor - - * path.cc (symlink_info::check): Clear error on each iteration of - extension check. - -Tue Aug 22 11:23:59 2000 Christopher Faylor - - * Makefile.in: Don't include '.d' file if there are none generated yet. - -Tue Aug 22 11:08:11 2000 Christopher Faylor - - * include/sys/cygwin.h: Declare some thread classes. - * include/mntent.h: Avoid declaring functions. - -Tue Aug 22 01:08:01 2000 Christopher Faylor - - * winsup.h: Eliminate inclusion of most of the cygwin .h files. Use .h - files only in sources which require them. - * Makefile.in: Generate dependencies with -MD option. - -Mon Aug 21 23:49:05 2000 Christopher Faylor - - * cygerrno.h: New file. Use this throughout whenever errno - manipulation is required. - * errno.cc: Use DWORD to hold Windows errors. - (geterrno_from_win_error): New function. - (seterrno_from_win_error): Use geterrno_from_win_error to convert - supplied windows error (suggested by Corinna Vinschen). - * path.cc (symlink_info): Add error element. - * path.cc (path_conv::check): Remove errno setting. Use new - symlink_info errno element to set path_conv error, where appropriate. - (symlink_info::check): Set error element rather than attempting to - manipulate errno. Add more checks for trailing / and /.. even though - they are currently useless. Avoid setting EINVAL. - -Mon Aug 21 23:49:05 2000 Corinna Vinschen - - * path.cc (normalize_posix_path): Correct check for trailing /. - -2000-08-21 DJ Delorie - - * include/cygwin/cygwin_dll.h (DECLARE_CYGWIN_DLL): hinstance, - not handle. - -Fri Aug 18 11:11:00 2000 Corinna Vinschen - - * dtable.cc (dtable::dup2): Extend fdtab if newfd is out of current - allocated bounds. - -Sat Aug 12 01:47:28 2000 Christopher Faylor - - * mkvers.sh: Properly trap exit removal of temp file. Remove debugging - statement. - -Sat Aug 12 01:37:56 2000 Christopher Faylor - - * poll.cc: Make winsup.h the first include file, re 2000-08-02 change. - -Sat Aug 12 01:33:12 2000 Christopher Faylor - - * winsup.h: Split out dtable definitions into separate header file. - * dtable.h: New file. - * sigproc.h: Eliminate pinfo.h usage here. Use it in source files that - need it. - -Sat Aug 12 01:08:11 2000 Christopher Faylor - - * Makefile.in: Use dtable.o rather than hinfo.o. - -Sat Aug 12 00:47:11 2000 Christopher Faylor - - Rename hinfo -> dtable. Name the former dtable array 'fdtab'. - -Fri Aug 11 14:47:00 2000 Corinna Vinschen - - * poll.cc: Allow any descriptor and any number of descriptors. - Allocate fd_set struct sdynamically. - -Fri Aug 11 14:47:00 2000 Corinna Vinschen - - * poll.cc: Add bounds checking for file descriptors. Return POLLNVAL - if fd is invalid. Return POLLERR for each valid fd if cygwin_select - returned with error. - include/sys/poll.h: Change POLLERR comment according to above change. - -Thu Aug 10 21:54:29 2000 Christopher Faylor - - * syslog.cc (syslog): Use a less malloc-intensive method for allocating - the buffer. Also fix a buffer overrun. - -Thu Aug 10 15:31:39 2000 Christopher Faylor - - * winsup.h: Change strchr inline for strange gcc problem. - * select.cc (select_stuff::wait): Bounds check w4 array. - -Thu Aug 10 15:17:53 2000 Christopher Faylor - - * dir.cc (readdir): Ensure that errno is *only* set when we've run out - of filenames. - * fhandler.cc (fhandler_disk_file::fstat): Use modern method for saving - errno, making it effective for the whole function. - -Tue Aug 8 22:25:39 2000 Christopher Faylor - - * select.cc (allocfd_set): Zero allocated fd_set. - (cygwin_select): Move fd_set copying logic from ::wait to here. Use - common return through sell.poll. - (select_stuff::wait): Just return success or failure and let caller - fill in fd_set. - * pinfo.h (pinfo): Eliminate self-referential pointer to sidbuf since - pinfo structure exists at random locations now. - * fork.cc (fork): Use 'use_psid' element to control when the psid is - relevant. - * shared.cc (sec_user): Ditto. - * spawn.cc (spawn_guts): Ditto. - * uinfo.cc (internal_getlogin): Ditto. - * syscall.cc (seteuid): Ditto. Set use_psid element. - -Tue Aug 8 13:20:00 2000 Bob Wilson - - * fhandler_serial.cc (tcsendbreak): "sleeptime" argument to usleep() - must be in units of microseconds, not milliseconds. - -Mon Aug 7 00:11:35 2000 Christopher Faylor - - * include/cygwin/cygwin_dll.h: Remove extraneous (and incorrect) - declarations. - -Fri Aug 4 00:00:46 2000 Christopher Faylor - - * hinfo.cc (hinfo::find_unused_handle): Just check for table entry == - NULL since we are already bounds checked by default. - * thread.cc (ResourceLocks::Lock): Streamline this function since it is - called a lot. - (ReleaseResourceLock): Ditto. - -Thu Aug 3 20:44:39 2000 Christopher Faylor - - * select.cc (fhandler_console::select_read): Call set_cursor_maybe - since select may block and cursor may not be visible. - * select.cc (fhandler_console::select_write): Ditto. - * select.cc (fhandler_console::select_except): Ditto. - -Thu Aug 3 09:01:14 2000 Christopher Faylor - - * fhandler_tty.cc (fhandler_pty_master::process_slave_output): Set - length field correctly when "need_nl". - -Wed Aug 2 22:58:07 2000 Christopher Faylor - - * fork.cc (vfork): Store complete stack frame in vfork_save structure - for later recovery. - * spawn.cc (spawn_guts): Reorganize slightly to consolidate handling - when there is a CreateProcess error. - (_spawnve): Only longjmp back to vfork handling when a process has been - successfuly started. - * winsup.h (vfork_save): Extend to include frame info. Remove obsolete - cpplus conditionals. - -Wed Aug 2 15:14:51 2000 Christopher Faylor - - * strace.cc (strace::prntf): Make second argument the function name, - rather than use special format options. - (strace::vprntf): Ditto. - (getfunc): New function. - * include/sys/strace.h: Reflect above changes. - * smallprint.c (__small_vsprintf): Eliminate '%F' formatting. - * pinfo.cc (set_myself): Modify for new strace::prntf parameter. - * errno.cc (seterrno_from_win_error): Ditto. - * fhandler_tty.cc (fhandler_tty_common::__acquire_output_mutex): Ditto. - * fhandler_tty.cc (fhandler_tty_common::__release_output_mutex): Ditto. - -Wed Aug 2 13:20:04 2000 Christopher Faylor - - * regexp/regexp.c: Add winsup.h. - -2000-08-02 DJ Delorie - - * winsup.h: take out protections of environ, errno, allow C use - * *.cc: put winsup.h before other headers (for __INSIDE_CYGWIN__); - use cur_environ() instead of just environ - * times.cc: remove import protections - * glob.c: add winsup.h - * localtime.c: ditto - * smallprint.c: ditto - * Makefile.in: don't __INSIDE_CYGWIN__ as it messes up profiling. - -Wed Aug 2 11:22:53 2000 Christopher Faylor - - * include/sys/strace.h: Fix strace definition. - -Tue Aug 1 23:37:08 2000 Christopher Faylor - - * strace.h: Add kludgy workarounds to avoid using deprecated methods - for variable argument macros when possible. - * sigproc.cc: Throughout, use sigproc_printf rather than sip_printf. - * strace.cc (strace::prntf): Remove 'active' check, since callers are - supposed to ensure this. - (__system_printf): Remove. Subsumed by strace::prntf. - * winsup.h: Define "NEW_MACRO_VARARGS" to indicate when to use new - macro varargs capability. - -Sun Jul 30 13:54:35 2000 Christopher Faylor - - * fhandler_console.cc: Remove VK_DIVIDE detection. - (get_nonascii_key): Simplify previous patch to return ascii char if it - is non-zero. Add a second "temporary buffer" argument to help with - thread safety. - * select.cc (peek_console): Pass a temporary buffer argument to - get_nonascii_key. - -Sat Jul 29 14:32:12 2000 Christopher Faylor - - * fhandler_console.cc: Add VK_DIVIDE detection. Return virtual keycode - if it is not detected and it is less than ' '. - -Sat Jul 29 13:33:49 2000 Christopher Faylor - - * path.cc (chdir): Avoid trailing dot calculation when chdir == '/' - or we end up with an empty string. - -Sat Jul 29 12:11:33 2000 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor version number to 5 due - to all of the changes below. - -Sat Jul 29 12:01:32 2000 Christopher Faylor - - Redefine process structure to avoid a fixed size table. Redefine - pinfo/_pinfo classes. Use these throughout. - * dcrt0.cc (dll_crt0_1): Accommodate set_myself argument change. - (__api_fatal): Accommodate _pinfo::record_death argument change. - * exceptions.cc (really_exit): Ditto. - (sig_handle_tty_stop): Use pinfo constructor to access process info. - (events_init): Don't create pinfo_mutex since it is no longer required. - * external.cc (fillout_pinfo): Use winpids class to iterate over all - system pids. - (cygwin_internal): lock_pinfo_for_update and unlock_pinfo are now - noops. - * fhandler_termios.cc (fhandler_termios::set_ctty): Use pinfo - constructor to access process info. - * fork.cc (fork): Reorganize to initialize child info after the child - has started since that is when we know the child's winpid, which is - necessary to allocate the pinfo shared memory. - * mmap.cc (recreate_mmaps_after_fork): Change arg type to _pinfo. - * pinfo.cc: Rename pinfo methods to _pinfo throughout. Eliminate - pinfo_list stuff. - (set_myself): Accept a pid argument now. Call pinfo initializer to - initialize myself. Detect when this is an "execed" process and create - an "indirect" pid block. - (pinfo_init): Accommodate set_myself arg change. - (procinfo): Remove. - (pinfo::lock_pinfo): Remove. - (pinfo::unlock_pinfo): Remove. - (pinfo::init): New method. Allocates shared memory space for process - pinfo structure. - (pinfo::record_death): Don't call locking functions. - (cygwin_winpid_to_pid): Simplify by using new pinfo constructor. - (EnumProcessesW95): New function for iterating over processes on - Windows 95. - (winpids::winpids): New constructor for winpids class. Sets up a list - of process ids. - (enum_init): Initialize w95/wnt pid enumerators. - * shared.cc (shared-info::initialize): Remove pid initialization. - * shared.h: Move pinfo stuff into pinfo.h. - (class shared_info): Remove pinfo_list element. - * signal.cc (kill_worker): Use pinfo constructor to access process - info. - (kill_pgrp): Ditto. Use winpids methods to access list of processes. - * sigproc.cc: Throughout, modify to use _pinfo where appropriate. - (proc_exists (pid_t)): New function. Determines if a process exists - based on the pid. - (proc_exists (_pinfo *p): Use new proc_exists function above. - (proc_subproc): Copy pinfo stuff around rather than _pinfo pointers. - Try to be careful about releasing shared memory when we don't need it - anymore. Remove pinfo locks. - (remove_zombies): Remove pinfo memory when zombie is going away. - * sigproc.h: Reflect _pinfo/pinfo changes in sigproc.cc. - * spawn.cc (spawn_guts): Eliminate pinfo *child argument. Reorganize - to only initialize child pinfo after process has been started and we - know the windows pid. - (_spawnve): Reflect spawn_guts changes. - * syscalls.cc (setpgid): Use pinfo constructor to access process info. - (getpgid): Ditto. - (internal_getlogin): Use _pinfo. - * winsup.h: Eliminate pinfo_mutex. Eliminate spawn_guts declaration - since it is static now. Reflect set_myself argument change. - * include/sys/cygwin.h: Add some PID_* enums to accommodate new pinfo - stuff. - -Sat Jul 29 12:13:27 2000 Christopher Faylor - - * include/cygwin/version.h: Update minor version for cygdrive changes - below. - -Sat Jul 29 11:59:29 2000 Christopher Faylor - - * environ.cc (parse_thing): Make binmode a DWORD. - * hinfo.cc (hinfo::init_std_file_from_handle): Use 'binmode' to - determine default open mode. - * winsup.h: Declare binmode. - -Sat Jul 29 00:16:35 2000 Christopher Faylor - - * include/cygwin/cygwin_dll.h: Update for modern compilers. - * lib/cygwin_crt0.c: Inexplicably need to define alloca for newer - compilers. - * fhandler.h (fhandler_console): Add new method. - * fhandler.cc (fhandler_console::set_cursor_maybe): New method. - (fhandler_console::read): Set cursor if it has moved to make it - visible. - -Thu Jul 27 22:54:28 2000 Jason Tishler - - * dcrt0.cc (dummy_autoload): Add load statement for RegDeleteValueA. - * external.cc (get_cygdrive_prefixes): New function. - (cygwin_internal): Add CW_GET_CYGDRIVE_PREFIXES case. - * path.cc (mount_info::read_cygdrive_info_from_registry): Read system - cygdrive prefix if user one is undefined. - (mount_info::write_cygdrive_info_to_registry): Write cygdrive prefix to - the appropriate registry hive. Overwrite in-memory copy of cygdrive, - if appropriate. - (mount_info::remove_cygdrive_info_from_registry): New method. - (mount_info::get_cygdrive_prefixes): New method. - (cygwin_umount): Remove cygdrive prefix, if appropriate. - * registry.cc (reg_key::killvalue): New method. - * shared.h (class reg_key): Add killvalue, - remove_cygdrive_info_to_registry, and get_cygdrive_prefixes - declarations. - * include/sys/cygwin.h (cygwin_getinfo_types): Add - CW_GET_CYGDRIVE_PREFIXES. - -Thu Jul 27 23:33:32 2000 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor version number to 4. - -2000-07-27 DJ Delorie - - * testsuite/winsup.api/winsup.exp: ignore stdout by default - * testsuite/winsup.api/crlf.c: non-verbose by default - - * winsup.h: prune out windows headers we don't normally need - * assert.cc: add wingdi.h and winuser.h - * fhandler_console.cc: ditto - * fhandler_windows.cc: ditto - * select.cc: ditto - * spawn.cc: ditto - * strace.cc: ditto - * tty.cc: ditto - * window.cc: ditto - * hinfo.cc: add winsock.h - * syscalls.cc: add winnls.h - * uinfo.cc: ditto - -Thu Jul 27 10:24:36 2000 Egor Duda - - * fhandler.cc (fhandler_disk_file::fstat): Allow block calculation to - succeed for files >= 2GB and <= 4GB. - -Wed Jul 26 16:05:04 2000 Christopher Faylor - - * exceptions.cc (signal_exit): Renamed from "really_exit". Always sets - EXIT_SIGNAL bit and reorganizes exit value for backwards cygwin - handling. - (handle_exceptions): Call signal_exit. Set "core dumped" bit. - (sig_handle): Call signal_exit. Set "core dumped" bit appropriately. - -Wed Jul 26 20:44:00 2000 Corinna Vinschen - - * environ.cc (posify): Revert previous patch. - (_addenv): Remove check_null_empty_path from here. - (putenv): Call check_nullempty_path. - (setenv): Call check_nullempty_path for name as well here. - Don't report an error if value is empty string. - (environ_init): Revert usage of newp. - -Wed Jul 26 14:32:38 2000 Egor Duda - - * syscalls.cc (stat_worker): Make stat return correct st_blocks for - files with size bigger than 2Gb and less than 4Gb - -Wed Jul 26 17:43:00 2000 Corinna Vinschen - - * security.cc (lookup_name): Search on local machine first if - myself->domain is not empty. - -2000-07-26 DJ Delorie - - * fhandler_console.cc (fhandler_console::read): Explicitly set cursor - to make it visible while waiting in WaitForMultipleObjects. - -Wed Jul 26 10:59:00 2000 Corinna Vinschen - - * passwd.cc: Change name of passwd_in_memory_p to passwd_state. - Change type to enum. Change storage class to static. Adjust comments. - (read_etc_passwd): Set passwd_state to different values when loaded - from file in contrast to being emulated. - (search_for): Return default passwd entry if passwd is emulated or - it's a request for the current user. Otherwise return NULL. - -Tue Jul 25 21:50:42 2000 Christopher Faylor - - * syscalls.cc (statfs): Use path_conv method to convert input path. - -Tue Jul 25 21:40:51 2000 Christopher Faylor - - * syscalls.cc (_link): Avoid extraneous call to - cygwin_conv_to_win32_path. - -Tue Jul 25 21:11:15 2000 Christopher Faylor - - * environ.cc (_addenv): New function. Subsumes functionality of - putenv/setenv. Does not allocate space for putenv case. - (putenv): Use _addenv to add a value to the environment. - (setenv): Ditto. - (environ_init): Don't malloc space for each entry in the environment - table. Just use the space from GetEnvironmentStrings. - (posify): Don't free the src argument since it is no longer malloced. - -Mon Jul 24 21:10:00 2000 Corinna Vinschen - - * syscalls.cc (_link): Corrected previous patch. - -Mon Jul 24 13:26:00 2000 Corinna Vinschen - - * fhandler.h (class fhandler_dev_random): Add members for managing - pseudo randomness. - * fhandler_random.cc: Rearrange. Use pseudo random number generator - as entropy source if system entropy isn't available and if device is - used as /dev/urandom. Allow initializing device by calling write(). - -Sun Jul 23 23:11:00 2000 Corinna Vinschen - - * fhandler.h: Add comment. - -Sun Jul 23 20:00:00 2000 Corinna Vinschen - - * fhandler.h (class fhandler_dev_raw): Add private member `varblkop' - to be set when variable blocksize mode is on. - * fhandler_raw.cc: Eliminate `\n' from trace output. - (clear): Set `varblkop' to 0. - (dup): Copy varblkop as well. - (writebuf): Care for variable blocksize. - (open): Ditto. - (raw_read): Ditto. - (raw_write): Ditto. - * fhandler_tape.cc (open): Ditto. - (ioctl): Ditto. Some cleanups. - -Sat Jul 22 18:40:00 2000 Corinna Vinschen - - Patch suggested by Kazuhiro Fujieda . - * winsup.h: Add new macros sys_wcstombs and sys_mbstowcs. - * syscalls.cc (_link): Replace calls to mbstowcs by call to - sys_mbstowcs. - * uinfo.cc (internal_getlogin): Replace calls to wcstombs and - mbstowcs by calls to sys_wcstombs and sys_mbstowcs. Replace - usage of constants by meaningful defines. Use result of - GetSystemDirectory for HOMEPATH and HOMEDRIVE as a last resort. - -Fri Jul 21 21:33:00 2000 Corinna Vinschen - - * spawn.cc (span_guts): Retrieve security attributes before setting - psid to NULL. - -Fri Jul 21 12:03:00 2000 Corinna Vinschen - - * security.cc (acl_worker): Use stat_suffixes in call to path_conv - just as in `stat_worker'. - -Wed Jul 19 22:24:00 2000 Corinna Vinschen - - * spawn.cc (spawn_guts): Don't restore impersonation in case - of _P_OVERLAY. Clean up slightly. Accommodate comments. - -Wed Jul 19 22:11:00 2000 Corinna Vinschen - - * shared.h (class pinfo): New members `root' and `rootlen'. - * syscalls.cc (chroot): Set new root for process. - * path.cc (getcwd_inner): Add parameter to force use of - new root from chroot() call. - (ischrootpath): New macro. - (normalize_posix_path): Care for changed root dir. - (normalize_win32_path): Ditto. - (getcwd_inner): Ditto. - (chdir): Eliminate trailing path component consisting - entirely of dots. - * fork.cc (fork): Copy pinfo members regarding chroot(). - * spawn.cc (_spawnve): Ditto. - * dir.cc (opendir): Don't use computed win32 path if - chroot() took place. - -Mon Jul 17 22:21:34 2000 Christopher Faylor - - * dll_init.cc (dll_list::alloc): Fix debugging output. - -Mon Jul 17 14:57:53 2000 Christopher Faylor - - Throughout, eliminate third argument to path_conv and use new PC_* - constants for second argument. - * dcrt0.cc (dll_crt0_1): Reorganize to allow more initialization prior - to returning due to dynamic loading. - * path.h: Generalize SYMLINK_* constants to PC_*. - (path_conv): Create a new method. Fold third argument into second. - * dll_init.cc (dll_list::alloc): Try harder to find space to allocate - dll struct. - (dll_dllcrt0): Don't check sanity if we've already called dll_crt0. - * path.cc (path_conv::check): Don't check for a null or empty path - unless specifically told with a flag setting. - (check_null_empty_path): New function, adapted from macro. - * syscalls.cc (_rename): Use already-determined file attributes rather - than checking again. - * lib/cygwin/cygwin_attach.dll.c (cygwin_attach_dll): Use a static - per_process structure since this is apparently supposed to be zeroed. - * lib/cygwin_crt0.c (cygwin_crt0): Zero per_process structure sent to - older DLLs. - -Mon Jul 17 19:39:00 2000 Corinna Vinschen - - Patch suggested by Eric Fifer - * poll.cc (poll): Fix erroneous negations. - -Mon Jul 17 17:56:00 2000 Corinna Vinschen - - * environ.cc (setenv): Use __cygwin_environ instead of - environ after reallocating environment space. - -Sun Jul 16 20:23:21 2000 Christopher Faylor - - * _cygwin_crt0_common.cc: Undef 'environ' or suffer compiler error. - -Sun Jul 16 16:03:00 2000 Christopher Faylor - - * environ.cc: Use new definition of "environ" throughout. - (environ_init): Explicitly initialize __cygwin_environ. - (cur_environ): New function. Detects when user has updated - their environment. - * exec.cc: Use 'environ' define throughout rather than __cygwin_environ. - * spawn.cc: Ditto. - * winsup.h: Declare cur_environ, main_environ, environ. - -Sun Jul 16 13:23:04 2000 Christopher Faylor - - * acconfig.h: Add support for NEWVFORK. - * config.h.in: Ditto. - * configure.in: Add --enable-vfork option. - * configure: Regenerate. - * dcrt0.cc (quoted): Detect and fix up quoted backslashes. - * sigproc.cc (proc_subproc): Correctly name handle of newly added child - process to avoid erroneous debugging messages about closing the wrong - handle. - -Sun Jul 16 02:30:09 2000 Christopher Faylor - - * spawn.cc (spawn_guts): Use \ for quoting '"'. - * dcrt0.cc (quoted): Understand \ quoting for '"'. - -Sun Jul 16 00:32:58 2000 Christopher Faylor - - * dcrt0.cc (build_argv): Strip quotes from argv[0] since it should - never be globified. - -Sat Jul 15 00:32:41 2000 Christopher Faylor - - * dll_init.cc (dll_list::alloc): Round correctly. Use VirtualAlloc - since shared file mapping is unnecessary. - (dll_list::detach): Release memory via VirtualFree since there we no - longer use shared file mapping. - -Fri Jul 14 22:40:22 2000 Christopher Faylor - - * hinfo.cc (hinfo::linearize_fd_array): Make max_used_fd an int so that - we can detect when there are no fds to pass. - * dcrt0.cc (host_dependent_constants::init): Revert Sat Mar 18 01:32:04 - 2000 change. - (dll_crt0_1): Set "cygwin_finished_initializing" flag. - (dll_crt0): Don't perform memcpy if uptr is already set to internal - structure. - (_dll_crt0): Remember location of programs envptr. - * dll_init.h (per_module, dll, dll_list): Revamp. - * dll_init.cc: Revamp. Use new classes. - * fork.cc (fork): Use new revamped dll, dll_list, and per_module stuff. - * environ.cc: Use __cygwin_environ throughout rather than the - user_data->envptr. - * exec.cc: Ditto. - * spawn.cc: Ditto. - * winsup.h: Declare update_envptrs, cygwin_finished_initializing. - * lib/_cygwin_crt0_common.cc (_cygwin_crt0_common): Revert previous - change. - * lib/cygwin_attach_dll.cc (cygwin_attach_dll): Always pass in own - per_process structure or we end up overwriting information from the - main program. - -Wed Jul 12 00:46:00 2000 Christopher Faylor - - * debug.cc (thread_stub): Use impure_ptr in place of reent_data. - * dll_init.cc (dll_dllcrt0): Replace erroneous use of local symbol with - correct __cygwin_user_data->impure_ptr. - -Wed Jul 12 00:01:03 2000 Christopher Faylor - - * lib/_cygwin_crt0_common.cc (_cygwin_crt0_common): Don't reset - environ if already set. - -Mon Jul 10 19:07:03 2000 Christopher Faylor - - * fhandler_console.cc (fhandler_console::read): Unicode interface - to ReadConsoleInput only exists on W2K, so use workaround from - Kazuhiro Fujieda . - -Mon Jul 10 11:30:00 2000 Christopher Faylor - - * Makefile.in (install): Install textmode.o as well as binmode.o. - * fhandler_console.cc (fhandler_console::read): Use UNICODE when - reading from the console and translate to ASCII from that. - -Sun Jul 9 21:52:00 2000 Corinna Vinschen - - * spawn.cc (spawn_guts): Close handle `hToken' only if it's not - copied from myself->token. - * syscalls.cc (seteuid): Replace CopySid by memcpy which is foolproof - here. - -Sun Jul 9 01:19:06 2000 Christopher Faylor - - * cygwin.din: Export _getmode and getmode to allow querying of binary - state of an fd. - * external.cc (cygwin_internal): Add handling of perfile_table setting. - * fhandler.cc (perfile_table): New global. - (fhandler_base::get_default_fmode): New method to return a file's - default mode based on its name. - (fhandler_base::open): Use get_default_mode method to determine a - file's mode. Record file mode in file flags. - * fhandler.h (fhandler_base): Declare get_default_fmode - * syscalls.cc (getmode): New function. - * sys/cygwin.h (__cygwin_perfile): New structure. - (cygwin_getinfo_types): Move outside of WINVER conditional. - (per_process): Move inside of WINVER conditional. - -Sat Jul 8 00:15:01 2000 Christopher Faylor - - * external.cc (cygwin_internal): Export __cygwin_user_data. - * include/sys/cygwin.h: Allow definition of per_process even when not - compiling with C++. - (cygwin_getinfo_types): Add CW_USER_DATA. - * lib/_cygwin_crt0_common.cc (_cygwin_crt0_common): Get - __cygwin_user_data pointer from cygwin_internal. If it doesn't exist, - return failure. Use either this pointer or passed in pointer - throughout. Clear forkee. - * lib/crt0.h: Accommodate argument changes to _cygwin_crt0_common. - * lib/cygwin_attach_dll.c (cygwin_attach_dll): Reorganize to allow use - of newer binaries with older DLLs. Detect older DLLs when - _cygwin_crt0_common returns 0 and allocate space for a per_process - structure on the stack. - * lib/cygwin_crt0.c (cygwin_crt0): Ditto. - -Fri Jul 7 10:31:00 2000 Corinna Vinschen - - * include/sys/cygwin.h: Hide internal data types in per_process - when not __INSIDE_CYGWIN__. - -Wed Jul 5 18:56:58 2000 Christopher Faylor - - * dcrt0.cc (__cygwin_user_data): Initialize. - (dll_crt0_1): Eliminate user_data initialization. - (dll_crt0): Set up impure_ptr_ptr for older executables. - (cygwin_dll_init): Eliminate user_data initializations. - (__api_fatal): Don't check for user_data initialization. - * dll_init.cc (struct dll): Store entire contents of per_process rather - than just a pointer. - (add): Ditto. - (initOneDll): Don't check for user_data initialization. - (DllList::recordDll): Store contents of per_process argument. - (DllList::detachDll): Pass address of per_process field. - (DllList::initAll): Ditto. - (DllList::doGlobalDestructorsOfDlls): Ditto. - (DllListIterator::operator *): Ditto. - (dll_dllcrt0): Default to __cygwin_user_data if arg is NULL. - * include/sys/cygwin.h: Reorganize per_process to eliminate obsolete - fields and accommodate new way of initializing. - * lib/_cygwin_crt0_common: Initialize _impure_ptr from - __cygwin_user_data.impure_ptr. - -2000-07-04 Vadim Egorov - - * exceptions.cc (try_to_debug): Prevent recursive spawning of JIT - debugger. Treat special event from debugger as command to continue. - -Mon Jul 4 19:29:00 2000 Corinna Vinschen - - * poll.cc (poll): Zero out `open_fds' as well. - -Mon Jul 4 1:22:00 2000 Corinna Vinschen - - * include/cygwin/version.h: Bump API minor version to 24. - -2000-07-04 Kazuhiro Fujieda - - * security.cc (read_sd): Eliminate OemToChar. - -Mon Jul 4 18:57:00 2000 Corinna Vinschen - - * poll.cc: New file. Implement `poll' system call. - * include/poll.h: Ditto. - * include/sys/poll.h: Ditto. - * Makefile.in: Add poll.o as dependency. - * cygwin.din: Add poll and _poll symbols. - -2000-07-04 Kazuhiro Fujieda - - * dcrt0.cc (dll_crt0_1): Eliminate SetFileApisToOEM and CharToOem. - * (dummy_autoload): Add functions used in fhandler_console. - * fhandler_console.cc (fhandler_console::read): Use ENCHANCED_KEY flag - to distinguish extended keys. Translate an input character from the - OEM code page to the ANSI code page. - * (fhandler_console::write_normal): Translate output characters from - the ANSI code page to the OEM code page. - * syscalls.cc (_link): Use MultiByteToWideChar instead of OemToCharW. - -Mon Jul 3 16:09:16 2000 Christopher Faylor - - * exceptions.cc (stack_info::walk): Use method to find offset. - (handle_exceptions): Be more assertive in finding ebp for use under - W2K. Create a dummy stack frame for cases where program is dying and a - stack dump is being output. - (sig_handle): Fill out a GetThreadContext for use with a user-generated - "core dump". - -Mon Jul 3 10:53:00 2000 Corinna Vinschen - - * include/cygwin/socket.h: Remove SOCK_PACKET define since it's - not supported by Windows sockets. - -Sun Jul 2 21:50:48 2000 Christopher Faylor - - * dcrt0.cc (user32_init): Add primitive guard against concurrent - attempts to call this function. Also add temporary debugging code to - display a message if the function is called multiple times. - (api32_init): Ditto. - -Sun Jul 2 10:39:00 2000 Corinna Vinschen - - * winsup.h: Define MAX_SID_LEN and new MAX_HOST_NAME. - * fork.cc (fork): Use above defines instead of numerical constants. - * shared.cc (sec_user): Ditto. - * shared.h (class pinfo): Ditto. - * syscall.cc (seteuid): Ditto. - * spawn.cc (_spawnve): Ditto. Eliminate conditional. - (spawn_guts): Set child->uid = USHRT_MAX when user context will be - changed in child process. - * uinfo.cc (uinfo_init): Check for myself->uid instead of myself->psid - to avoid reloading of /etc/passwd on process startup if ntsec is off. - Use above defines instead of numerical constants. - * security.cc: Move define for MAX_SID_LEN to winsup.h. - -Sun Jul 2 1:57:00 2000 Corinna Vinschen - - * uinfo.cc (uinfo_init): Eliminate calls to read_etc_group() - and read_etc_passwd(). - -2000-06-28 Kazuhiro Fujieda - - * assert.cc (__assert): Reduce dependency on newlib. - * exec.cc: Eliminate unnecessary inclusion of ctype.h. - * glob.c: Ditto. - * hinfo.cc: Ditto. - * init.cc: Ditto. - * strace.cc: Ditto. - * tty.cc: Ditto. - * grp.cc (parse_grp): Eliminate atoi. - * passwd.cc (grab_int): Ditto. - * grp.cc (getgroups): Eliminate str{n,}casecmp. - * path.cc (get_raw_device_number): Ditto. - * path.cc (sort_by_native_name): Ditto. - * spawn.cc (iscmd): Ditto. - * uinfo.cc (internal_getlogin): Ditto. - -Sat Jul 1 11:43:32 2000 Christopher Faylor - - * binmode.c (cygwin_premain0): Fix erroneous clearing of bit. - * textmode.c (cygwin_premain0): Ditto. - -Sat Jul 1 00:24:04 2000 Christopher Faylor - - * dcrt0.cc (_dll_crt0): Renamed from dll_crt0 (). - * winsup.h: Accommodate above change. - * cygwin.din: Ditto. - * lib/cygwin_crt0.c: Ditto. - -Fri Jun 30 23:21:40 2000 Christopher Faylor - - * Makefile.in: Use variables rather than configure constructs where - appropriate. - (LIBCOS): Find additional stub library stuff in their own subdirectory. - * dcrt0.cc: Convert user_data pointer to static __cygwin_user_data - area. - (do_global_ctors): Check magic_bisquit for initialization. - (dll_crt0_1): First group of premain functions prior to fd - initialization. Run second group before calling main. - (dll_crt0 ()): New function, called from new initialization code. - (dll_crt0 (per_process *uptr)): Call new dll_crt0 () function on - initialization. - * debug.cc (thread_stub): Initialize bottom of stack with per-thread - info. - * environ.cc (parse_thing): Use binmode global to control - CYGWIN=binmode behavior. - * fhandler.cc (fhandler_base::open): Allow explicit setting of __fmode - to O_BINARY or O_TEXT to override disk mount settings. - * libcmain.cc: Move to lib subdirectory. - * libccrt0.cc: Ditto. - * dll_main.cc: Ditto. - * dll_entry.cc: Ditto. - * getopt.c: Ditto. - * thread.cc (thread_init_wrapper): Call ExitThread explicitly rather - than returning, as a preliminary step towards placing per thread info - at the bottom of the stack. - * winsup.h: Move per_process class to include/sys/cygwin.h. Declare - new dll_crt0(). - * include/cygwin/version.h: Bump API minor version. - * binmode.c: New file. - * textmode.c: Ditto. - * perthread.h: Ditto. - * lib/_cygwin_crt0_common.cc: Ditto. - * lib/crt0.h: Ditto. - * lib/cygwin_attach_dll.c: Ditto. - * lib/cygwin_crt0.c: Ditto. - * lib/dll_entry.cc: Ditto. - * lib/dll_main.cc: Ditto. - * lib/getopt.c: Ditto. - * lib/libcmain.c: Ditto. - * lib/premain0.c: Ditto. - * lib/premain1.c: Ditto. - * lib/premain2.c: Ditto. - * lib/premain3.c: Ditto. - -Wed Jun 28 19:36:00 2000 Corinna Vinschen - - * syscalls.cc (seteuid): Initialize pi.token before calling - internal_getlogin(). - * uinfo.cc (internal_getlogin): Use impersonation token instead - of process token in case of active impersonation. Add some comments. - (uinfo_init): Initializing myself->token and myself->impersonated - before calling internal_getlogin(). Add some comments. - -Mon Jun 26 18:32:41 2000 Christopher Faylor - - * windows.cc (setitimer): Round up when < 1000 usecs. - -Mon Jun 26 17:34:54 2000 Christopher Faylor - - * hinfo.cc (hinfo::dup2): Eliminate compiler warning. - -Mon Jun 26 11:25:29 2000 Christopher Faylor - - * hinfo.cc (hinfo::dup2): Guard against out of bounds newfd. - -Sat Jun 24 23:43:06 2000 Christopher Faylor - - * grp.cc (read_etc_group): Open file in text mode. - * pwd.cc (read_etc_passwd): Ditto. - * shared.h: Bump PROC_MAGIC. - -Sat Jun 24 19:30:00 2000 Corinna Vinschen - - * fork.cc (fork): Fix error in copying SID pointer. - * spawn.cc (_spawnve): Ditto. - * passwd.cc: Remove static from `passwd_in_memory_p'. - (read_etc_passwd): Remove static. - * uinfo.cc: Move global declaration of `read_etc_group' and - `group_in_memory_p' into `uinfo_init'. - (internal_getlogin): Try to get SID from current process first. - (uinfo_init): Don't set uid and gid if `myself' has a valid SID. - Only load /etc/passwd and /etc/group in that case. - -Sat Jun 24 12:29:59 2000 Christopher Faylor - - * shared.cc (shared_info::initialize): Improve error message clarity. - * mkvers.sh: Eliminate debugging output. - -Thu Jun 22 17:50:59 2000 Christopher Faylor - - * Makefile.in: Autogenerate cygwin.def when appropriate. - * include/sys/cygwin.h: Correct prototype. - -Thu Jun 22 17:05:04 2000 Christopher Faylor - - * include/sys/cygwin.h: Don't define parts of this file that rely on - Windows headers unless the Windows header was previously included. - -Thu Jun 22 20:45:00 2000 Corinna Vinschen - - * registry.cc (load_registry_hive): Use HKEY_USERS when checking - for existing user hive. - Use MAX_PATH instead of numerical constant for array size. - Use return code of RegLoadKeyA instead of GetLastError for error output. - -Thu Jun 22 14:27:04 2000 Christopher Faylor - - * Makefile.in: Add new-libcygwin.a back to all_host target. - -Wed Jun 21 14:32:42 2000 Christopher Faylor - - * Makefile.in: Add *.def to clean operation. - -Wed Jun 21 13:18:23 2000 Christopher Faylor - - * Makefile.in: Add *.exe to clean operation. - -Wed Jun 21 01:02:38 2000 Christopher Faylor - - * mkvers.sh: Fix sed usage for older seds. - -Tue Jun 20 20:46:28 2000 Christopher Faylor - - * Makefile.in: Don't touch winver_stamp if mkvers.sh was unsuccessful. - -Tue Jun 20 17:41:30 2000 Christopher Faylor - - * mkvers.sh: Fix problem with handling of CVS tags causing .rc syntax - errors. - -Tue Jun 20 13:38:12 2000 Christopher Faylor - - * Makefile.in: Change to build the DLL during a cross-compiler build. - -Mon Jun 19 20:46:33 2000 Christopher Faylor - - * select.cc (socket_cleanup): Shutdown I/O on dummy sockets prior to - closing them. - -Mon Jun 19 19:35:00 2000 Corinna Vinschen - - * dcrt0.cc: Add load statements for `GetSidIdentifierAuthority' - and `RegLoadKeyA'. - * registry.cc (get_registry_hive_path): New function. - (load_registry_hive): Ditto. - * security.cc (convert_sid_to_string_sid): New function. - (get_ssid): Renamed to `convert_string_sid_to_sid'. - (get_pw_sid): Call `convert_string_sid_to_sid' instead of `get_ssid'. - (get_gr_sid): Ditto. - (get_admin_sid): Ditto. - (get_system_sid): Ditto. - (get_creator_owner_sid): Ditto. - (get_world_sid): Ditto. - * shared.h: New prototypes for `get_registry_hive_path' and - `load_registry_hive'. - * spawn.cc (spawn_guts): Set child->psid to NULL to force calling - `internal_getlogin' from child process in case of changing user context. - Call `load_registry_hive' in case of changing user context. - (_spawnve): Copy user infos only if user context remains the same. - * uinfo.cc: Add load statement for `NetUserGetInfo'. - Remove load statement for `NetGetDCName'. - (internal_getlogin): Rewrite to speed up process startup - and to correct user environment in case user context changes. - (uinfo_init): Call internal_getlogin only if myself->psid is NULL, - that is user context changes. - * winsup.h: Add prototypes for `convert_sid_to_string_sid', - `convert_string_sid_to_sid' and `get_pw_sid'. - -Sun Jun 18 13:42:50 2000 Christopher Faylor - - * fhandler.h (set_name): Don't use 'unix' as name since this is defined - by gcc now. - * fhandler.cc (set_name): Ditto. - -2000-06-17 Kazuhiro Fujieda - - * winsup.h (isabspath): Don't report `C:foo' as an absolute path. - -Sat Jun 17 13:51:48 2000 Christopher Faylor - - * configure.in: Detect "cross-hosting" situation and set appropriate - variables in Makefile to avoid building excess stuff. - * configure: Regenerate. - * Makefile.in: Accommodate above change. - -Sat Jun 17 19:52:00 2000 Corinna Vinschen - - * pinfo.cc (pinfo_init): Revert previous patch. - -Sat Jun 17 13:29:00 2000 Corinna Vinschen - - * pinfo.cc (pinfo_init): Add missing initializers. - * uinfo.cc (internal_getlogin): Request domain infos only - when ntsec is ON. - -Fri Jun 16 19:27:27 2000 Christopher Faylor - - * Makefile.in: Just use library files from this tree when building - cygrun.exe. - * path.cc (chdir): Don't set cache to offending chdir. Change comment - to reflect current reality. - -Fri Jun 16 20:55:00 2000 Corinna Vinschen - - * cygwin.din: Define symbols for `cygwin_logon_user' and - `cygwin_set_impersonation_token'. - * dcrt0.cc (dll_crt0_1): Eliminate superfluous conditional - statements. - Add load statements for `ImpersonateLoggedOnUser', `LogonUserA' - and `RevertToSelf'. - * fork.cc (fork): Care for correct impersonation of parent - and child process. - * security.cc (cygwin_set_impersonation_token): New function. - (cygwin_logon_user): Ditto. - shared.h (class pinfo): New members `orig_uid', `orig_gid', - `real_uid' nad `real_gid'. - spawn.cc (spawn_guts): Care for impersonation when starting - child process in a different user context. - * syscalls.cc (setgid): Call `setegid' now. Set real_gid. - (setuid): Call `seteuid' now. Set real_uid. - (seteuid): Functionality moved from setuid to here. Care for - correct impersonation. - (setegid): Functionality moved from setgid to here. - * uinfo.cc (uinfo_init): Initialization of additional pinfo - members. - (getuid): Return real uid. - (getgid): Return real gid. - (geteuid): Return effective uid. - (getegid): Return effective gid. - include/sys/cygwin.h: Add prototypes for `cygwin_logon_user' and - `cygwin_set_impersonation_token'. - include/cygwin/version.h: Bump API minor version to 22. - -Thu Jun 15 15:43:50 2000 Christopher Faylor - - * path.cc (normalize_posix_path): Convert path to POSIX if it seems to - be a Windows path. - -2000-06-15 Kazuhiro Fujieda - - * path.cc (mount_info::add_item): Eliminate a trailing backslash - included in a native path starting with '//[A-Za-z]/...'. - * path.cc (mount_info::del_item): Accept a native path as its target. - -Wed Jun 14 23:47:19 2000 Christopher Faylor - - * environ.cc (conv_envvars): Detect and convert all environment - variables used by libiberty's choose-temp.c - -Tue Jun 13 12:41:41 2000 Kazuhiro Fujieda - - * path.cc (mount_info::add_item): The previous patch can't handle - the case of overwriting a mount entry. - -Tue Jun 13 00:17:04 2000 Christopher Faylor - - * thread.h: Shorten "current_directory" variables to "cwd_*" - throughout. - * path.cc: Ditto. - (normalize_posix_path): Add some extra debugging info. - (chdir): Ditto. Store chdir'ed posix and MS-DOS directory names in - "cache" here rather than trying to derive them later. - -Sun Jun 11 15:57:00 2000 Corinna Vinschen - - * fhandler_random.cc (read): Call CryptAquireContext with - CRYPT_VERIFYCONTEXT. - -Thu Jun 8 22:49:00 2000 Corinna Vinschen - - * path.cc (path_conv::check): Erase two lines checked in - by mistake. - -Thu Jun 8 15:53:00 2000 Corinna Vinschen - - * fhandler.cc (fhandler_disk_file::open): Check for directory - to set O_DIROPEN on directories anyway. - -2000-06-07 Kazuhiro Fujieda - - * path.cc (mount_info::init): Eliminate the mount_slash feature. - (mount_slash): Eliminated. - (mount_info::read_mounts): Eliminate looking up existing entries. The - loop for deleting cygpath entries is done only when such entries exist. - (mount_info::from_registry): Eliminate sorting. - (mount_info::add_item): Call add_reg_mount if necessary. Check nmounts - more precisely. Use strcasematch in looking up existing entries. - (mount_info::del_item): Call del_reg_mount if necessary. Use - strcasematch. Use memmove instead of memcpy. - (mount_info::import_v1_registry): Everything is done in this method. - (mount_info::to_registry): Eliminated. - (mount_info::from_v1_registry): Eliminated. - (cygwin_umount): Simply call del_item. - * shared.h: Modify the declaration of add_item and del_item. Remove the - declaration of from_v1_registry. - -Wed Jun 7 23:56:10 2000 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor version number to 3. - -2000-06-07 DJ Delorie - - * cygwin.din: add cygwin_dll_init - * dcrt0.cc (cygwin_dll_init): new - (dll_crt0_1): short circuit if manually loaded - * path.cc (mount_info::init): don't init if manually loaded - -Wed Jun 7 13:47:00 2000 Corinna Vinschen - - * include/netinet/in_systm.h: New file. - * include/cygwin/in_systm.h: Ditto. - -Thu Jun 1 01:55:45 2000 Christopher Faylor - - * exceptions.cc: Remove unneeded include. - * dcrt0.cc: Wrap LoadDLLfunc stuff in dummy function. - * init.cc: Ditto. - * uinfo.cc: Ditto. - -2000-05-31 DJ Delorie - - * include/cygwin/version.h: use decimal, NOT octal - -Wed May 31 16:40:00 2000 Corinna Vinschen - - * fhandler.cc (fhandler_disk_file::open): Check for executable - even if ntsec is on if filesystem doesn't support ACLs. - -Wed May 31 15:57:00 2000 Corinna Vinschen - - * dcrt0.cc: Use LoadDLLfuncEx for loading Crypto API functions - with parameter `notimp' set to 1. - -Tue May 30 16:58:33 2000 Christopher Faylor - - * path.cc (mount_info::conv_to_win32_path): Previous patch was too - aggressive in adding a trailing slash. - -Mon May 29 20:31:01 2000 Christopher Faylor - - * Makefile.in: Remove libadvapi32.a. - * autoload.h: Add additional field to autoload block for handling - unimplemented functions. - (LoadDLLfuncEx): New function which accepts additional parameter for - controlling unimplemented function behavior. - (LoadDLLfunc): Use LoadDLLfuncEx. - * dcrt0.cc: Use new arguments for LoadDLLfunc. Add advapi32 routines. - (noload): Rewrite in assembler. Handle new unimplemented function - type. - * exceptions.cc: Eliminate another vestige of StackWalk stuff. - * net.cc: Use new arguments for LoadDLLfunc. - * uinfo.cc: Ditto. - -Mon May 29 20:18:47 2000 Christopher Faylor - - * config.h.in: Remove obsolete define. - * path.h (isdrive): New macro. - * dcrt0.cc (globify): Use new macro to determine if a string refers to - an MS-DOS drive. - * environ.cc (winenv): Ditto. - * spawn.cc (find_exec): Ditto. - * path.cc (get_raw_device_number): Ditto. - (mount_info::conv_to_posix_path): Ditto. - (chdir): Ditto. - (cygwin_posix_path_list_p): Ditto. - (cygwin_split_path): Ditto. - (path_conv::check): Move tmp_buf to beginning of function since it can - be used earlier in the loop. Use tmp_buf rather than 'root' to hold - root information. - (mount_info::conv_to_win32_path): Add trailing slash to end of mount - path when it translates to a drive. Add defensive code to avoid - writing beyond the end of 'dst'. - -Sat May 27 15:57:00 2000 Corinna Vinschen - - * fhandler_random.cc (read): Use CRYPT_MACHINE_KEYSET in - call to CryptAcquireContext() to serve users that did not - log in interactively. - -Fri May 26 11:16:00 2000 Corinna Vinschen - - * errno.cc (errmap): Map ERROR_BAD_NET_NAME to errno ENOSHARE. - -Fri May 26 02:23:35 2000 Christopher Faylor - - * sigproc.h (sigframe::set): Accept a default frame pointer. - * sigproc.cc (sig_send): Use passed in frame pointer, if appropriate. - -Thu May 25 17:44:25 2000 Christopher Faylor - - * dir.cc (rmdir): Use file attributes that have already been discovered - by path_conv. - -2000-05-25 Kazuhiro Fujieda - - * dir.cc (rmdir): Correct the manner in checking the target directory. - -Wed May 24 21:59:00 2000 Corinna Vinschen - - * dir.cc (writable_directory): Comment out previous code, - return always 1 for now. - (mkdir): Call set_file_attribute explicitely with S_IFDIR mode bit. - * syscalls.cc (chown_worker): Ditto. - (chmod): Ditto. - * security.cc (get_nt_attribute): Fix error in debug output. - Never set FILE_DELETE_CHILD for files. - Construct appropriate inherit attribute according to file type. - -2000-05-23 DJ Delorie - - * syscalls.cc (_cygwin_istext_for_stdio): New, for newlib - * include/cygwin/version.h: Bump API number for detect old - programs using old getc/putc macros - -2000-05-23 DJ Delorie - - * dir.cc (writable_directory): handle root directories - -Tue May 23 10:09:26 2000 Christopher Faylor - - * uname.cc (uname): Use a "s" to denote a snapshot to avoid confusion - with the number "5". - -Tue May 23 10:01:07 2000 Christopher Faylor - - * path.cc (mount_info::conv_to_posix_path): Avoid putting a trailing - slash on a directory name when the ms-dos path spec is a root directory - of a device. - * registry.cc (reg_key::build_reg): Set 'key_is_invalid' flag rather - than using an INVALID_HANDLE_KEY. - (reg_key::get_int): Test for key validity before performing registry - operations. - (reg_key::set_int): Ditto. - (reg_key::get_string): Ditto. - (reg_key::set_string): Ditto. - (reg_key::kill): Ditto. - (reg_key::~reg_key): Ditto. - -Tue May 23 01:13:33 2000 Christopher Faylor - - * mkvers.sh: Use snapshot date as build date since it is more - interesting. - * uname.cc (uname): Detect if this is a snapshot build and add an "S" - to the version number. Report the snapshot date as the release date. - -Mon May 22 17:11:25 2000 Christopher Faylor - - * environ.cc (regopt): Scan HKLM if HKCU scan fails. - -Mon May 16 23:39:00 2000 Corinna Vinschen - - * dir.cc (rmdir): Care for misleading error messages - when trying to remove a directory on a samba share. - Eliminate superfluous else branch. - * syscalls.cc (_rename): Additional check for ERROR_FILE_EXISTS - if MoveFile fails. - -Sun May 21 20:51:44 2000 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Move uinfo_init call to before sigproc_init to - avoid a race. - (noload): Add an extra argument for debugging. - * uinfo.cc (uinfo_init): Eliminate test for multiple calls. - (getlogin): Assume that uinfo_init has already been called. - -Sat May 20 01:34:57 2000 Christopher Faylor - - * exceptions.cc (interruptible): Add an argument to control whether - function just checks for validity. Flag module handle == 0 as - noninterrupible. - (call_handler): Always acquire and release ebp lock. Loop for only a - fixed amount of time attempting to grab mutos and find an interruptible - PC. - -2000-05-19 DJ Delorie - - * syscalls.cc (setmode): change mode of any matching FILE* also. - -Thu May 18 17:28:19 2000 Christopher Faylor - - * Makefile.in: Remove external.h dependency. - * dcrt0.cc (sigthread::init): Move here from sigproc.h. - * sigproc.h (sigthread): Move init to dcrt0.cc. - -Thu May 18 01:28:02 2000 Christopher Faylor - - * select.cc (thread_pipe): Add paranoid check to ensure thread - termination. - * external.cc: Eliminate obsolete include. - * getopt.c (getopt_long): Fix compiler warning. - * shared.h: Moved PID_ definitions to include/sys/cygwin so that they - can be used by external programs. - * include/sys/cygwin.h: Move external definitions here. Include - sys/resource.h to avoid having to do this everywhere. - -Thu May 18 01:04:02 2000 Christopher Faylor - - * sigproc.h (sigframe): Don't set frame info unless tid matches this - thread id. - -Wed May 17 23:13:32 2000 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Initialize mainthread stuff here before - anything needs it. - * sigproc.cc (sigproc_init): Move mainthread initialization out of - here. - * sigproc.h (sigthread): Add init() method. - (sigframe): Don't try to initialize muto. - * sync.cc: Undef WaitForSingleObject to avoid recursion. - -2000-05-17 DJ Delorie - - * testsuite/winsup.api/crlf.c: New - * testsuite/winsup.api/iospeed.c: New - -Wed May 17 01:05:52 2000 Christopher Faylor - - * path.cc (mount_info::cygdrive_posix_path): Don't add trailing slash - if referring to something like c:\. - * dcrt0.cc (dll_crt0_1): Move uinfo initialization prior to sig_send - initialization to give signal thread a chance to finish. - * debug.cc (WFSO): Move to sigproc.cc - (WFMO): Ditto. - * exceptions.cc (interruptible): Allocate slightly more space for - directory just for paranoia's sake. - (call_handler): Eliminate nonmain argument. Determine if main thread - has set a frame pointer and use it if so. - (sig_handle): Eliminate nonmain argument. - * net.cc: Record frame information in appropriate routines throughout. - * select.cc (select): Ditto. - * sigproc.cc: Use sigthread structure to record mainthread id - throughout. - (sig_send): Record frame information for signal handler. - (wait_sig): Reflect argument change in sig_handle. - (WFSO): Move here and record frame information for signal handler. - (WFMO): Ditto. - * sigproc.h: Implement new "sigthread" class. Implement "sigframe" - class for manipulating signal frame info. - * thread.cc (__pthread_kill): Use standard _kill() function rather than - calling sig_send directly. - * winsup.h: Eliminate ebp element from signal_dispatch class. - -Tue May 16 23:39:00 2000 Corinna Vinschen - - Patch suggested by John Rowley - * fhandler_tape.cc (fhandler_dev_tape::ioctl): Check - for filemark feature on MTWEOF operation. - -Tue May 16 11:49:13 2000 Christopher Faylor - - * include/cygwin/in.h (AF_INET6): Use correct in6_addr struct. - -Mon May 15 00:35:35 2000 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor version number to 2. - -Sun May 14 23:41:24 2000 Christopher Faylor - - * shared.h: Bump PROC_MAGIC. - * include/cygwin/version.h: Bump API minor to accommodate two recent - exports. - -2000-05-13 Mumit Khan - - * include/cygwin/socket.h (AF_INET6): Use same value as winsock2. - -2000-05-12 Mumit Khan - - * include/cygwin/in.h (struct in6_addr): Fix spelling. - * include/cygwin/socket.h (AF_INET6, PF_INET6): Define macros. - (AF_MAX, PF_MAX): Bump to 32 to leave room for future expansion. - -Fri May 12 21:35:54 2000 Christopher Faylor - - * dcrt0.cc (build_argv): Remove unneeded variable. - * select.cc (peek_pipe): Don't check for "ready" if it's already set. - (peek_console): Ditto. - (peek_serial): Ditto. - (peek_socket): Ditto. - (peek_windows): Ditto. - -Fri May 12 20:31:00 2000 Corinna Vinschen - - * fhandler_raw.cc (write_file, read_file): New wrapper functions - for WriteFile and ReadFile to get rid of ERROR_MEDIA_CHANGED - and ERROR_BUS_RESET in case of first access to tape. - (fhandler_dev_raw::raw_write): Use write_file instead of WriteFile. - (fhandler_dev_raw::raw_read): Use read_file instead of ReadFile. - -Fri May 12 01:04:57 2000 Christopher Faylor - - * Makefile.in (DLL_OFILES): Sort. - * fhandler_tty.cc (fhandler_tty_slave::send_ioctl_request): Eliminate. - (fhandler_tty_slave::ioctl): Rewrite to avoid races. - -2000-05-11 Mumit Khan - - * mmap.cc (list::erase): Increment loop counter. - (map::erase): Likewise. - -Thu May 11 00:54:00 2000 Charles Wilson - - * cygwin.din: insure that regsub() is included in - cygwin1.dll - -Tue May 9 18:59:41 2000 Christopher Faylor - - * Makefile.in: Use appropriate VARIABLE to refer to cygwin.def in load - line. - -Thu May 9 23:53:00 2000 Corinna Vinschen - - * fhandler.cc (fhandler_base::puts_readahead): Change - while condition to disallow wild runs. - -Thu May 9 15:24:00 2000 Corinna Vinschen - - Patch suggested by - * window.cc (setitimer): Check for overflow condition - in tv_sec. - -Thu May 9 0:47:00 2000 Corinna Vinschen - - Patch suggested by Eric Fifer - * errno.cc: Change mapping of ERROR_BAD_PATHNAME to ENOENT. - -Thu May 9 0:47:00 2000 Corinna Vinschen - - * path.cc (symlink::info): Treat non readable files - as normal non symlink files. - -2000-05-08 Paul K. Fisher - - * include/pthread.h (pthread_detach): Add missing prototype. - (pthread_join): same. - -2000-05-08 DJ Delorie - - * fhandler.cc (lock): use signed math to allow checking ranges - properly. - -Sat May 6 23:22:25 2000 Christopher Faylor - - * dcrt0.cc (insert_file): Eliminate unused parameter. - (build_argv): Ditto. - * exceptions.cc (stack): Eliminate unused parameters. - (stackdump): Ditto. - (cygwin_stackdump): Reflect above changes. - (sig_handle): Ditto. - * fhandler.cc (fhandler_base::set_inheritance): Use kludge to avoid - unused parameter warning. - -2000-05-06 Mumit Khan - - * include/wchar.h (wcscmp, wcslen): Fix prototypes. - * syscalls.cc (wcslen, wcscmp): Adjust. - -Fri May 5 23:32:07 2000 Christopher Faylor - - * errno.cc (errmap): Correct DIRECTORY mapping to ENOTDIR. - -2000-05-04 Mumit Khan - - * Makefile.in (install): Install profile startup and library. - -Wed May 3 21:54:11 2000 Christopher Faylor - - * configure.in: Use -gstabs+ as compile debug option. This seems to - promote better handling of symbols. - * configure: Regenerate. - * delqueue.cc (delqueue_list::process_queue): Allow ERROR_ACCESS_DENIED - to indicate that a file is being shared under Windows 95. - * syscalls.cc (_unlink): Use full path name. Take special action for - Windows 95. Assume that an ERROR_ACCESS_DENIED indicates a sharing - violation unless it's on a remote drive. Punt if there is an - ERROR_ACCESS_DENIED on a remote drive. - -Wed May 3 18:07:00 2000 Corinna Vinschen - - * errno.cc (errmap): Map ERROR_BAD_NETPATH to new errno ENOSHARE. - (_sys_errlist): Add entry for ENOSHARE. - (strerror): Add case for ENOSHARE. - * syscalls.cc (stat_worker): Check for errno ENOSHARE. - -Wed May 3 17:28:00 2000 Corinna Vinschen - - * Makefile.in: Add dependencies for fhandler_random.o - * fhandler.h: Add device type FH_RANDOM. Add class - fhandler_dev_random. - * fhandler_random.cc: New file. Implementation of - fhandler_dev_random. - * hinfo.cc (build_fhandler): Add case for FH_RANDOM. - * path.cc: Add device names for random devices to - windows_device_names. - (get_device_number): Add if branch for random devices. - (win32_device_name): Add device name generation for - random devices. - winsup.h: Include . - -2000-05-02 Kazuhiro Fujieda - - * path.cc (mount_info::conv_to_win32_path): Previous patch - failed to set flags on a win32 path. - -Tue May 2 11:34:00 2000 Corinna Vinschen - - * security.cc (read_sd): Return 1 on success because we - can't rely on the returned SD size from GetFileSecurity. - -Tue May 2 2:22:00 2000 Corinna Vinschen - - * dcrt0.cc: Add dynamic load code for `OemToCharA' from user32.dll. - * security.cc (read_sd): Call `OemToCharA' to make - `GetFileSecurity' happy on filenames with umlauts. - -Wed Apr 26 23:23:23 2000 Christopher Faylor - - * path.cc (normalize_win32_path): Don't add a trailing slash when one - already exists. - (mount_info::conv_to_win32_path): Use existing code for dealing with - relative path names when input is already a win32 path. - -2000-04-26 DJ Delorie - - * Makefile.in (install): install regexp.h - -Wed Apr 26 16:20:00 2000 Corinna Vinschen - - * syscalls.cc (stat_worker): Previous patch could succeed - in stating a non-existant file. - -Wed Apr 26 01:07:16 2000 Christopher Faylor - - * exceptions.cc (interruptible): Allocate slightly more space for - directory name check. Windows 95 seems to null-terminate the directory - otherwise. - (interrupt_on_return): Issue a fatal error if we can't find the - caller's stack. - -Tue Apr 25 16:50:54 2000 Christopher Faylor - - * spawn.cc (find_exec): Accept a path_conv argument rather than a - buffer so that the caller can find things out about a translated path. - (perhaps_suffix): Ditto. - (spawn_guts): Allocate path_conv stuff here so that we can find out - stuff about the translated path (this is work in progress). - * environ.cc (environ_init): Accept an as-yet unused argument - indicating whether we were invoked from a cygwin parent or not. - (winenv): Ditto. - (posify): Accept an argument indicating whether the path has already - been translated. - * dlfcn.cc (check_access): Provide a path_conv buffer to find_exec. - * exec.cc (sexecvpe): Ditto. - * path.cc (path_conv::check): Rename from path_conv::path_conv. - (mount_item::getmntent): Recognize "Cygwin executable" bit. - (symlink_info::check): Remove debugging statements. - * path.h (class path_conv): Add iscygexec method. Rewrite constructor - to call "check" method to allow multiple operations on a path_conv - variable. - * pinfo.cc (pinfo_init): Pass argument to environ_init. - * shared.h: Bump PROC_MAGIC. - * winsup.h: Reflect above changes to function arguments. - * include/sys/mount.h: Add MOUNT_CYGWIN_EXEC type. - -Thu Apr 25 21:35:00 2000 Corinna Vinschen - - * syscalls.cc (stat_worker): Previous patch failed to stat - each drives root dir on 9X. - -Thu Apr 25 16:37:00 2000 Corinna Vinschen - - * fhandler.cc (fhandler_disk_file::open): Check for allow_ntsec - when determining exec flag. - * path.cc (symlink_info::check): Remove call to get_file_attribute(). - * security.cc (read_sd): Rename, ditto for variables to conform - to common naming convention. Use GetFileSecurity() instead of - BackupRead() to avoid permission problems when reading ACLs. - (write_sd): Same renaming as for read_sd(). - (alloc_sd): Change default permissions according to Linux permissions - for group and world when write permission is set. - * syscalls.cc (stat_worker): Avoid different permission problems - when requesting file informations. - -Thu Apr 25 10:50:00 2000 Corinna Vinschen - - * net.cc: Avoid a warning in declaration inet_network. - -Mon Apr 24 17:38:25 2000 Thorsten Otto - - * fhandler_console.cc (fhandler_console::read): Detect extended keycode - information for Windows 9x so that function keys will work correctly. - -2000-04-24 Vadim Egorov - - * net.cc (cygwin_inet_network): new function. - * cygwin.din (inet_network): new export - -Fri Apr 21 10:37:08 2000 Christopher Faylor - - * path.cc (normalize_posix_path): Previous two patches were still - incorrect so rewrite this function to deal with trailing dots. - (mount_info::conv_to_win32_path): Just check for '/' where appropriate. - Eliminate nofinalslash call since it is handled in normalize_posix_path - now. - -Thu Apr 20 17:32:42 2000 Christopher Faylor - - * exceptions.cc (handle_exceptions): Search further for stack info to - accommodate Windows 95. - -Thu Apr 20 16:39:18 2000 Christopher Faylor - - * path.cc (normalize_posix_path): Previous change failed to take root - access into account. - -Thu Apr 20 11:26:00 2000 Corinna Vinschen - - * syscalls.cc (_link): Check new link path for trailing dot. - -Thu Apr 20 00:32:03 2000 Christopher Faylor - - * fhandler.h (fhandler_base::hclose): New virtual method. - (fhandler_base::set_inheritance): Make this a method so that we can use - the appropriate close methods. - * fhandler.cc (fhandler_base::set_inheritance): Ditto. - * path.cc (normalize_posix_path): Eliminate /. trailing path - component. - -Wed Apr 20 0:19:00 2000 Corinna Vinschen - - * syscalls.cc (setuid): Allow switching user context after - successful call to ImpersonateLogedOnUser (NT only). - (setgid): Ditto. - (seteuid): Call setuid. - (setegid): Call setgid. - -Wed Apr 19 22:00:00 2000 Corinna Vinschen - - * uinfo.cc (internal_getlogin): Use NetGetDCName() instead - of NetGetAnyDCName(). - -Mon Apr 17 12:08:47 2000 Kazuhiro Fujieda - - * syscalls.cc (_rename): Try MoveFile() at first before - MoveFileEx(..., MOVEFILE_REPLACE_EXISTING). - -Tue Apr 18 19:15:29 2000 Christopher Faylor - - * dcrt0.cc (globify): Don't use \ quoting when apparently quoting a DOS - path spec, even within a quoted string. - -Sun Apr 16 18:54:21 2000 Christopher Faylor - - * init.cc (dll_entry): Use better check for determining when to set - thread specific stuff. - * syscalls.cc (_unlink): Continue with chmod'ing file even if - DELETE_ON_CLOSE succeeds, if file still exists. - -Fri Apr 14 23:51:15 2000 Christopher Faylor - - * fhandler_console.cc (keytable): Add support for keypad 5 key, which - MS seems to think is equivalent to VK_CLEAR. - * debug.cc (thread_stub): Eliminate initialization of reent stuff. - * init.cc (dll_entry): Move it here. - -Thu Apr 13 18:32:26 2000 Christopher Faylor - - * dcrt0.cc (insert_file): Avoid freeing previously allocated argument - list. - * path.cc (symlink_info::check): Rename from symlink_check_one. Use - new symlink_info struct for communication. - (path_conv::path_conv): Use symlink_info structure for communication - with symlink_info::check. Fix typo which resulted in symbolic links - always being resolved. - (readlink): Use stat_suffixes array when resolving a link. - * syscalls.cc (stat_suffixes): Make global. - -Thu Apr 13 20:50:00 2000 Corinna Vinschen - - * include/cygwin/version.h: Bump minor api to reflect export change. - -Thu Apr 13 8:48:00 2000 Corinna Vinschen - - * path.cc (conv_to_win32_path): Detect a win32 path - if path contains backslashes. - * cygwin.din: Add symbol for `lacl'. - * security.cc (ReadSD): Add debug output. - (acl_worker): New static function. - (acl): Call acl_worker now. - (lacl): New function. - (facl): Call acl_worker now. - * include/cygwin/acl.h: Add prototype for `lacl'. - -Wed Apr 12 18:48:33 2000 Christopher Faylor - - * path.cc (path_conv::path_conv): Ensure that suffix is correctly - copied to path when we've found a symlink but aren't following - symlinks. - -Sat Apr 8 00:46:14 2000 Christopher Faylor - - * fhandler.cc (fhandler_disk_file::fstat): Allocate enough space for - root dir determination or overflow an array. - -Sat Apr 8 00:08:53 2000 Christopher Faylor - - * exceptions.cc (sigsave): Copy on fork so that we can restore correct - behavior in forked process. - (interruptible): Flag as interruptible when running in main process - module. - (interrupt_setup): Save return address and address of return address. - (signal_fixup_after_fork): New function. Uses above two values to - restore proper behavior to forked process. - (interrupt_on_return): Pass return address address to interupt_setup. - (interrupt_now): Pass NULL for return address address to - interrupt_setup. - * fork.cc (fork): Call signal_fixup_after_fork. - * shared.h: Lint cleanups. - * winsup.h: Ditto. - -Mon Apr 3 14:10:44 2000 Christopher Faylor - - * fhandler.h (select_stuff): Eliminate use of 'total'. - * select.cc (cygwin_select): Ditto. - (select_stuff::wait): Use maximum size for w4 rather than calculating - what will fit. - -Mon Apr 03 13:58:00 2000 Corinna Vinschen - - * grp.cc (parse_grp): Save empty array instead of - NULL in gr_mem if no supplementary group is given. - -Sun Apr 02 16:02:00 2000 Corinna Vinschen - - * syscalls.cc (chown_worker): Use previous uid/gid if - new uid/gid is -1. - -Fry Mar 31 22:55:00 2000 Corinna Vinschen - - * syscalls.cc (chown_worker): New static function with - chown functionality. - (chown): Call chown_worker with SYMLINK_FOLLOW. - (fchown): New function. Call chown_worker with SYMLINK_FOLLOW. - (lchown): New function. Call chown_worker with SYMLINK_IGNORE. - * cygwin.din: Add symbols for fchown, lchown. - -Fry Mar 31 11:18:00 2000 Corinna Vinschen - - * path.cc (symlink): Call `set_file_attribute()' and - `SetFileAttributeA()' instead of `chmod()' to set - uid/gid correct. - -Wed Mar 29 22:49:56 2000 Christopher Faylor - - * fhandler.h (select_record): Explicitly zero elements of this class. - (select_stuff): Ditto. - * select.cc (cygwin_select): Eliminate memset zero of sel. - -Tue Mar 28 16:45:42 2000 Christopher Faylor - - * Makefile.in: Use default rules when compiling cygrun.o. - * dcrt0.cc (host_dependent_constants::init): Limit non-NT platforms to - 32K chunks when copying regions during a fork. - * path.cc (symlink_check_one): Add temporary debugging output. - Simplify PATH_EXEC test. - * syscalls.cc (stat_suffixes): Null terminate this list. - -Sat Mar 25 20:46:39 2000 Christopher Faylor - - * path.cc (symlink_check_one): Recognize symlink settings from the - mount table. - * path.h: Make PATH_SYMLINK an alias for MOUNT_SYMLINK. - * syscalls.cc (stat_worker): Use extension search mechanism in - path_conv to look for .exe rather than trying to special case it here. - * mount.h: Make MOUNT_SYMLINK a real option. - -Sat Mar 25 00:22:32 2000 Christopher Faylor - - * environ.cc: Add TMPDIR to the list of environment variables which are - converted to POSIX format. - * sigproc.cc (proc_terminate): Don't attempt to delete when a muto - pointer is NULL. - -Sun Mar 19 12:01:00 2000 Corinna Vinschen - - * syscalls.cc (stat_worker): Set st_nlink to 1 on remote drives. - -Sat Mar 18 23:04:27 2000 Christopher Faylor - - * times.cc: Fix extern declarations for variables that are exported but - used by this modules. - -Sat Mar 18 01:32:04 2000 Christopher Faylor - - * dcrt0.cc (host_dependent_constants::init): Eliminate DELETE flag - from shared constant. - -Sat Mar 18 01:24:25 2000 Christopher Faylor - - * delqueue.cc (delqueue_list::queue_file): Add some debugging. - * path.h (class path_conv): Add a char * operator for the most common - case. - * syscalls.cc (_unlink): Rewrite to use FILE_FLAG_DELETE_ON_CLOSE when - possible (i.e., on NT). - -Fri Mar 17 18:16:00 2000 Corinna Vinschen - - Patch suggested by Eric Fifer - * fhandler.cc (fhandler_base::open): Call set_file_attribute() - only if a file is really created. - -Thu Mar 16 14:15:00 2000 Corinna Vinschen - - * security.cc (set_process_privileges): Remove `static'. - (get_nt_attribute): Returns uid and gid additionally. Remove call - to set_process_privileges(). - (get_file_attribute): Returns uid and gid additionally. Don't - call ntea if ntsec is ON. - (set_nt_attribute): Remove call to set_process_privileges(). - Don't call ntea if ntsec is ON. - (acl): Remove call to set_process_privileges(). - * dcrt0.cc (dll_crt0_1): Call set_process_privileges(). - * winsup.h: New prototype for set_process_privileges(), - changed prototype for get_file_attribute(). - * fhandler.cc (get_file_owner): Discard function. - (get_file_group): Ditto. - (fhandler_disk_file::fstat): Discard calls to get_file_owner() and - get_file_group(). - * path.cc (path_conv::path_conv): New debugging output for result - of GetVolumeInformation(). - (mount_info::conv_to_win32_path): Call backslashify() with pathbuf - instead of src_path. - * syscalls.cc (chown): Reformat slightly. - (chmod): Replace get_file_owner() and get_file_group() calls - by a call to get_file_attribute(). Discard local variable has_acls. - Reformat slightly. - (stat_worker): Root dir check now done by a call to rootdir(). - Don't call num_entries() on remote drives. - Discard local variable has_acls. - -Wed Mar 15 20:38:06 2000 Corinna Vinschen - - * errno.cc: Map ERROR_NOACCESS to EFAULT. - -Wed Mar 15 14:25:38 2000 Christopher Faylor - - * spawn.cc (spawn_guts): Restore dependency on signal_arrived. It's - needed to wake up the WaitForSingleObject. - -Tue Mar 14 23:41:16 2000 Christopher Faylor - - Pipe changes throughout suggested by Eric Fifer - * debug.cc (threadname_init): Pass name of lock as arg 2 of new_muto. - * malloc.cc (malloc_init): Ditto. - * sigproc.cc (sigproc_init): Ditto. - * exceptions.cc (events_init): Ditto. - (call_handler): Eliminate special case for hExeced. Report locked - thread in debugging output. - * fhandler.cc (fhandker_pipe::fhandler_pipe): Propagate device type to - base class. - * fhandler.h (fhandler_pipe): Ditto. - * hinfo.cc (hinfo::build_fhandler): Pass specific type of pipe to - constructor. - * spawn.cc (spawn_guts): Eliminate dependency on signal when waiting - for subprocess. - * strace.cc: Remove obsolete #ifdef. - * sync.cc (muto::muto): Save the name of the muto. - (muto:~muto): Also release the muto. - * sync.h: Add a muto name field. - * select.cc (peek_pipe): Avoid doing a PeekNamedPipe on the write end - of a pipe. - -Sun Mar 12 01:14:33 2000 Christopher Faylor - - * fhandler.cc (fhandler_base::get_readahead_into_buffer): New function. - * fhandler.h: Declare new function. Add extra argument to - process_slave_output. - * fhandler_console.cc (fhandler_console::read): Move read ahead code to - new function. - * fhandler_tty.cc (fhandler_pty_master::process_slave_output): Move - common code here. - (fhandler_tty_slave::read): Understand readahead. - (fhandler_pty_master::read): Move code to process_slave_output. - * select.cc (peek_pipe): Avoid performing certain checks when non-read - and on inappropriate fh types. - -Sat Mar 11 22:47:43 2000 Christopher Faylor - - * fhandler_console.cc (fhandler_console::read): Don't even think about - breaking on interrupt if executing in a "cygwin" thread. - * fhandler_tty.cc (fhandler_pty_master::process_slave_output): - Streamline, simplify code. - * sigproc.cc (sig_send): Remove debugging statement. - -Fri Mar 10 13:20:50 2000 Christopher Faylor - - * sigproc.cc: Set wait_sig priority to normal. - -Fri Mar 10 13:03:06 2000 Christopher Faylor - - * sigproc.cc (wait_sig): Add addtional debugging output. - -Thu Mar 9 15:25:01 2000 Christopher Faylor - - * environ.cc: Eliminate oldstack CYGWIN option. - * exceptions.cc (sfta): Eliminate obsolete function. - (sgmb): Eliminate obsolete function. - (class stack_info): Remove MS method for walking the stack. - (stack_info::init): Just initialize required fields. - (stack_info::brute_force): Rename to stack_info::walk. - (handle_exceptions): Pass derived frame pointer to sig_send. - (interrupt_setup): Clear saved frame pointer here. - (interrupt_on_return): thestack is no longer a pointer. - (call_handler): Accept a flag to indicate when a signal was sent from - other than the main thread. Use saved frame pointer for determining - where to place signal handler call. - (sig_handle): Accept "nonmain" argument. Pass it to call_handler. - * fhandler_tty.cc (fhandler_tty_common::__acquire_output_mutex): Change - debugging output slightly. - * (fhandler_tty_common::__release_output_mutex): Ditto. - (fhandler_tty_slave::read): Fix a comment, remove a goto. - * sigproc.cc (sig_send): Accept an optional frame pointer argument for - use when suspending the main process. sigcomplete_main is an autoreset - event now. Save frame pointer for non-main operation. - (wait_sig): Make sigcomplete_main an autoreset event. Eliminate - NOSIGQUEUE. Pass rc to sig_handle to signify if this was a nonmain - process. - * sigproc.h: Reflect change to sig_send argument. - * syscalls.cc (swab): Eliminate swab function since it is now available - in newlib. - * winsup.h (signal_dispatch): Change CONTEXT cx to DWORD ebp. - -Tue Mar 7 13:31:10 2000 Christopher Faylor - - * sigproc.cc (sig_send): Eliminate sync_sig_send synchronization since - it didn't seem to affect the "bash hangs" problem. - -Tue Mar 7 13:17:56 2000 Christopher Faylor - - * mcount.c: Remove strace.h include. - -Tue Mar 7 00:29:34 2000 Christopher Faylor - - Throughout use strace class in place of individual functions and - variables. - * cygwin.din: Eliminate _strace_wm. - * sigproc.cc (wait_sig): Temporarily add more debugging output. - * include/cygwin/version.h: Bump minor api to reflect export change. - -Sun Mar 5 01:17:05 2000 Christopher Faylor - - * exceptions.cc (call_handler): Streamline to use only one call to - ResumeThread. - * sigproc.cc (sig_send): Use a muto around the ReleaseSemaphore. - Remove priority setting since it didn't solve anything. - -Tue Feb 29 00:46:09 2000 Christopher Faylor - - * sigproc.cc (sig_send): Temporarily set priority to highest while - sending a signal. - -Mon Feb 28 11:23:29 2000 Christopher Faylor - - * pinfo.cc (set_myself): Add build date to strace output. - -Mon Feb 28 11:17:30 2000 Eric Fifer - - * sigproc.cc (proc_subproc): Only clear wait event when not attending - to a signal. - -Mon Feb 28 00:08:09 2000 Christopher Faylor - - * configure.in: Remove --enable-strace-hhmmss option. - * configure: Regenerate. - -Sun Feb 27 23:11:57 2000 Christopher Faylor - - * dcrt0.cc (set_os_type): Record OS name string. - (getprogname): Eliminate obsolete function. - (dll_crt0_1): Move initial strace initialization output to set_myself. - * exceptions.cc (interruptible): Add debugging output. - (interrupt_setup): New function. - (interrupt_now): Use interrupt_setup to set up common interrupt handler - stuff. - (interrupt_on_return): Ditto. - (call_handler): Move signal_arrived arm and clear threads to region - where signalled thread is suspended or suffer races. - * pinfo.cc (set_myself): Output interesting information when strace is - first initialized. Initialize progname here. - * sigproc.cc (sig_dispatch_pending): Modify to ensure that flush signal - are sent synchronously. - * strace.cc (strace_vsprintf): Move code into strace program. - * uname.cc (uname): Use 'osname' global to construct cygwin name + - Windows type + version. - -Fri Feb 25 19:26:42 2000 Christopher Faylor - - * exceptions.cc (interruptible): Make a little more structured. - (call_handler): Allow signals to be sent even if signalled thread is - stopped. Change order of signal_arrived arming/waiting threads - clearing to eliminate a race. - (reset_signal_arrived): New helper function. - * malloc.cc (malloc_init): Use mutos so that signal handler can keep - track of who owns the lock. - (__malloc_lock): Ditto. - (__malloc_unlock): Ditto. - * sync.h (new_muto): Actually use a muto for the "buffer". - * Makefile.in: Fix a dependency. - -2000-02-25 DJ Delorie - - * Makefile.in: fix "make check" support and cygrun. - -Thu Feb 24 15:56:00 2000 Christopher Faylor - - * syscalls.c (_read): Clear errno before doing any read operation. - -Thu Feb 24 14:45:06 2000 Christopher Faylor - - * exceptions.cc (call_handler): Use new muto linked list to look for - all potential mutos owned by suspended thread. Clear waiting threads - while thread is stopped. - (proc_subproc): Clarify debugging output. - * sync.h (class muto): Add 'next' field. - (new_muto): Keep linked list alive. - -Thu Feb 24 00:59:15 2000 Christopher Faylor - - Fix final round of gcc warnings relating to unused parameters. - * debug.cc (iscygthread): New function. - * debug.h: Declare it. - * exceptions.cc (set_process_mask): Flush pending signals. - (handle_sigsuspend): No need to flush pending signals. - (call_handler): Refine previous tests of muto ownership. Only clear - wait()'s when we have definitely responded to a signal. - * fhandler_console.cc (fhandler_console::read): Don't set EINTR if - executing in a "cygwin" thread. - * sigproc.cc (proc_subproc): Use second argument to control whether - CLEARWAIT actually sets "signalled" flag. - * sync.h (muto): Add 'unstable' method. - -Wed Feb 23 21:59:44 2000 Christopher Faylor - - * hinfo.cc (hinfo::extend): Clean up debugging output. - -Wed Feb 23 21:34:58 2000 Christopher Faylor - - * exceptions.cc (interruptible): Change method for determining if - something is interruptible. - (call_handler): Avoid suspending a thread if it owns a muto. Only set - signal_arrived if the thread was actually interrupted. - (events_init): Initialize module information needed by interruptible(). - * init.cc (dll_entry): Record module handle of main for use by - interruptible(). - (proc_subproc): Reorganize handling of terminated child so that the - bulk of the processing comes from the signal thread. - (wait_sig): Force processing of waiting threads if SIGCHLD is not - processed. - -Tue Feb 22 23:06:01 2000 Christopher Faylor - - Respond to more g++ warnings relating to initializing structures. - -Mon Feb 21 18:36:37 2000 Christopher Faylor - - * fhandler.cc (set_inheritance): Revert previous patch which got rid of - 'name' parameter. - -Mon Feb 21 00:19:40 2000 Christopher Faylor - - Respond to a multitude of new g++ warnings. - -Sun Feb 20 22:10:21 2000 Christopher Faylor - - * environ.cc (getwinenv): Make __stdcall. - (winenv): Ditto. - * malloc.cc (strdup): New function. Occludes newlib version. - (_strdup_r): Ditto. - * winsup.h: Reflect above __stdcall changes. - -Sun Feb 20 21:31:00 2000 Corinna Vinschen - - * fhandler.cc (fhandler_disk_file::fstat): Modify get_file_attribute - return value if FILE_ATTRIBUTE_READONLY is set. - -Thu Feb 17 11:00:23 2000 Christopher Faylor - - * environ.cc (environ_init): Cosmetic change. - -Mon Feb 7 16:50:44 2000 Christopher Faylor - - * Makefile.in: cygrun needs libshell32.a. - -Sun Feb 6 22:17:58 2000 Christopher Faylor - - * sigproc.cc (proc_subproc): Simplify case for when a child process is - stopped since new signal handler ensures the desired behavior. - -Sun Feb 6 21:52:33 2000 Christopher Faylor - - * Makefile.in: Fix install target so that directories will be created - when necessary. - -Sun Feb 6 18:12:17 2000 Christopher Faylor - - * Makefile.in: exceptions.cc should depend on autoload.h. - * exceptions.cc: Undef DECLSPEC_IMPORT prior to including imagehlp.h to - avoid defining StackWalk as "import". - (call_handler): Minor optimizations. - (sig_handle_tty_stop): Fix typo in previous checkin. - * sigproc.cc (sigproc_init): Ditto, for signal_arrived initialization. - -Sat Feb 5 15:37:37 2000 Christopher Faylor - - * dcrt0.cc (isquote): Convert to inline function. - -Sat Feb 5 00:26:01 2000 Christopher Faylor - - Throughout, rename global_signal_arrived to signal_arrived. - Throughout, eliminate use of arm_signals and __signal_arrived. - Throughout, revert to use of simple call to WaitForSingleObject or - WaitForMultipleObjects. - * debug.h: Eliminate obsolete function declaration. - * exceptions.cc (sigWaitForSingleObject): Eliminate obsolete function - definition. - * fhandler.h: Reflect change to select_stuff wait method. - * fhandler_tape.cc (get_ll): Accommodate new w32api LARGE_INTEGER - definition. - * ntea.c (NTReadEARaw): Ditto. - (NTWriteEA): Ditto. - * security.cc (ReadSD): Ditto. - (WriteSD): Ditto. - * syscalls.cc (_link): Ditto. - * uname.cc (uname): Eliminate PPC switch. - -2000-02-01 Salvador Eduardo Tropea - - * include/io.h: add return type to setmode() - -2000-01-27 DJ Delorie - - * include/netdb.h (h_errno): change __imp_ to dllimport - * cygwin.din (reent_data): add DATA - -Thu Jan 27 01:07:14 2000 Christopher Faylor - - * exceptions.cc (call_handler): Add debugging output. - * select.cc (MAKEready): Arm signals earlier. - * sigproc.cc (__signal_arrived:arm): Move debugging version of this - method here. - (__signal_arrived::release): Ditto. - * sigproc.h: Recognize debugging versions of above two methods. - (arm_signals::WaitForMultipleObjects): Don't release signal lock unless - signal arrived. - (arm_signals::WaitForMultipleSingleObject): Ditto. - (arm_signals::MsgWaitForMultipleObjects): Ditto. - -Thu Jan 27 00:19:26 2000 Christopher Faylor - - * sync.h (new_muto): Workaround change in gcc behavior. - -Wed Jan 26 12:57:13 2000 Christopher Faylor - - * Makefile.in: Ensure that all required libraries are built prior - to linking cygrun.exe. - -Tue Jan 25 21:26:57 2000 Christopher Faylor - - * exceptions.cc (sig_handle): Crudely work around potential problem - when main thread has a lock but is killed by a fatal signal. - * fhandler_tty.cc (fhandler_pty_master::write): Don't perform line - editing on the pty master (so why do we need the second argument to - line_edit, then?) - * thread.cc: Reformat to GNU standards. - -2000-01-11 DJ Delorie - - * ROADMAP: new - -2000-01-11 DJ Delorie - - * fhandler_zero.cc: new, emulate /dev/zero - * testsuite/winsup.api/devzero.c: new, test /dev/zero - * Makefile.in: build fhandler_zero.o - * fhandler.h: add support for /dev/zero - * hinfo.cc: ditto - * path.cc: ditto - -2000-01-11 DJ Delorie - - * mmap.cc (mmap): MSDN says *one* of FILE_MAP_*, fix flags for - MAP_PRIVATE. - -Mon Jan 10 01:11:00 2000 Corinna Vinschen - - * security.cc (acl_access): New function. - * syscalls.cc (access): Call acl_access if ntsec is on. - -Mon Jan 10 01:11:00 2000 Corinna Vinschen - - * fhandler.cc (get_file_owner): Use of ReadSD() instead of - GetFileSecurity(). - (get_file_group): Ditto. - -Sun Jan 9 15:43:07 2000 Christopher Faylor - - * debug.cc (struct thread_start): Add a flag to determine whether a - field is in use. Eliminate thread_start_ix since it was not - thread-safe. - (thread_stub): Use notavail flag to control whether the entry in - start_buf can be reused. - (makethread): Ditto. - -Sun Jan 9 20:18:00 2000 Corinna Vinschen - - * security.cc (alloc_sd): Rearrange order of ACE creation. - (setacl): Optimize creation of ACEs related to inheritance. Code - cleanup. - (aclcheck): Disable check for existance of DEF_)CLASS_OBJ. - -Sat Jan 8 18:42:32 2000 Christopher Faylor - - * mkvers.h: Reorg fix. - -Sat Jan 8 20:00:00 2000 Corinna Vinschen - - * cygwin.din: Add new acl API calls. - * grp.cc (getgroups): Change to work for any username. - * security.cc (get_id_from_sid): Change to work with acl API. - (is_grp_member): New function. - (get_nt_attribute): Rewritten. - (add_access_allowed_ace): New function. - (add_access_denied_ace): Ditto. - (alloc_sd): Rewritten. - (setacl): New function. - (getace): Ditto. - (searchace): Ditto. - (getacl): Ditto. - (acl): Ditto. - (facl): Ditto. - (aclcheck): Ditto. - (acecmp): Ditto. - (aclsort): Ditto. - (acltomode): Ditto. - (aclfrommode): Ditto. - (acltopbits): Ditto. - (aclfrompbits): Ditto. - (permtostr): Ditto. - (acltotext): Ditto. - (permfromstr): Ditto. - (aclfromtext): Ditto. - * syscalls.cc (access): Set errno again when needed. - * include/cygwin/acl.h: New file. - * include/sys/acl.h: Ditto. - -Sat Jan 8 14:46:19 2000 Christopher Faylor - - * Makefile.in: Add cygwin DLL specific CFLAGS define. - -Fri Jan 7 21:01:57 2000 Christopher Faylor - - * exceptions.cc (interrupt_on_return): Properly coerce assignment of - sigsave.func. - -2000-01-07 Mumit Khan - - * acconfig.h: New file. - * configure.in Add check for memset builtin. - (AC_CONFIG_HEADER): Use. - (STRACE_HHMMSS): Define instead of substituting. - (_MT_SAFE): Likewise. - (_CYG_THREAD_FAILSAFE): Likewise. - (DEBUGGING): Likewise. - (MT_SAFE): Substitute as a yes/no variable. - * Makefile.in: Remove DEBUGGING, STRACE_HHMMSS, and THREAD_FAILSAFE - variables and add DEFS. Update usage of MT_SAFE to reflect yes/no - values. Add config.h to winsup.h dependency. - (CFLAGS_CONFIG): Update. - (INCLUDES): Prepend `-I.'. - * utils/Makefile.in (INCLUDES): Likewise. - * winsup.h: Conditionally include config.h. - * thread.cc: Likewise. - * config.h.in: Generate new file. - * configure: Regenerate. - - -Fri Jan 7 16:21:01 2000 Christopher Faylor - - * dcrt0.cc (dll_crt0): Allow signal handling for dynamically loaded - case. - -Thu Jan 6 00:30:12 2000 Corinna Vinschen - - * path.cc (symlink_check_one): Initialize local variable `unixattr' - before calling `get_file_attribute'. - * syscalls.cc (chown): Ditto. - * security.cc (get_nt_attribute): Eliminate attribute copying from - world to user/group in case of missing ACEs. - (alloc_sd): Set special rights for administrators group only if it's - neither owner nor group. - * utils/mkpasswd.c: Create entry for local group administrators (SID - 544). - -Thu Jan 6 00:21:31 2000 Christopher Faylor - - Change function calls to __stdcall throughout. - * exceptions.cc (handle_exceptions): Probe stack for return address to - use with new signal method. Fill out sigsave.cx with this information. - (call_handler): Use sigsave.cx if it is available, rather than trying - to find the context of the main thread. - (interrupt_on_return): Use address of context rather than - pass-by-reference. - (interrupt_now): Ditto. - -Thu Jan 6 00:21:31 2000 Corinna Vinschen - - * grp.cc (getgroups): Return supplementary groups now. - * include/limits.h: Define NGROUP_MAX as 16 now. diff --git a/winsup/cygwin/ChangeLog-2001 b/winsup/cygwin/ChangeLog-2001 deleted file mode 100644 index 140b2a9e9..000000000 --- a/winsup/cygwin/ChangeLog-2001 +++ /dev/null @@ -1,5337 +0,0 @@ -2001-12-31 Christopher Faylor - - * Makefile.in: Strip path when installing library. - -2001-12-30 Christopher Faylor - - * include/getopt.h: Fix define. - -2001-12-30 Christopher Faylor - Ralf Habacker - - * speclib: New file. - * Makefile.in: Create library versions of automode.o, textmode.o, and - binmode.o for easier use on command line. Create libpthread.a, libm.a, - and libc.a with subsets of exports found in libcygwin.a. - -2001-12-30 Ralf Habacker - - * cygmagic: Eliminate unneeded use of 'tr' and 'bc'. - -2001-12-30 Corinna Vinschen - - * security.cc (open_local_policy): Use POLICY_EXECUTE instead of - enumerating user rights. - -2001-12-29 Corinna Vinschen - - * security.cc (open_local_policy): Initialize lsa handle to NULL. - Request only needed access rights in call to LsaOpenPolicy(). - (create_token): Check for NULL lsa pointer. - -2001-12-28 Corinna Vinschen - - * cygwin.din: Add symbols for endutent(), getutent(), getutid(), - getutline(), setutent() and utmpname(). - * syscalls.cc (setutent): New function. - (endutent): Ditto. - (utmpname): Ditto. - (getutent): Ditto. - (getutid): Ditto. - (getutline): Ditto. - * include/cygwin/version.h: Bump API minor version. - -2001-12-26 Christopher Faylor - - * cygmagic: Add define name to warning. - * dcrt0.cc (_dll_crt0): Check for changes in child_info size. - (multiple_cygwin_problem): Avoid "proc" errors when testing. Just - assume new cygwin proc. - * shared_info.h (mount_info): Add 'cb' element for sanity checks. - (shared_info): Ditto. - * child_info.h (child_info): Add fhandler_union_size element for sanity - checking. - * shared.cc (open_shared): Detect shared region size mismatch between - parent and child. - (shared_info::initialize): Detect shared region size mismatch with - expectation. - (memory_Init): Ditto. - * sigproc.cc (init_child_info): Correctly set cb in passed structure. - * shared.cc (open_shared): - -2001-12-26 Christopher Faylor - - * include/getopt.h: Protect a declaratin. - -2001-12-26 Robert Collins - - * thread.cc (pthread_cond::Signal): Use a separate flag for signal - detection and broadcast semantics. - (__pthread_cond_dowait): Ditto. - * thread.h (pthread_cond): New flag for testing when a waiter has - woken. - -2001-12-26 Christopher Faylor - - * Makefile.in: Quote arguments to shell scripts. - (clean): Remove new *_magic.h autogenerated files. - -2001-12-25 Christopher Faylor - - * Makefile.in: Autogenerate some header files which provide magic - numbers. Force dependencies for files which depend on autogenerated - headers to ensure that they are always built. - * child_info.h (child_info): Add new fields to accommodate new magic - number header stuff. - * dcrt0.cc: Rely on "child_info_magic.h" to ensure that correct - child_info magic numbers are used. - (dll_crt0_1): Temporarily remove _cygwin_testing_magic test. - (_dll_crt0): Do more testing on magic numbers from fork_info structure. - Call "multiple_cygwin_problem" where appropriate. - (multiple_cygwin_problem): Rename from multiple_cygwin_die. Issue a - warning or die, as appropriate based on cygwin version/magic number - mismatch. - * pinfo.cc (pinfo::exit): Don't attempt to dereference `this' if it - doesn't exist. This can happen when a fatal error occurs early in - process initialization. - * shared.cc: Rely on "shared_info_magic.h" to accommodate that new - magic number header stuff. - (shared_info::initialize): Use new magic number stuff, for shared - region. - (memory_init): Ditto, for mount table. - * shared_info.h: Accomodate new magic number stuff for shared region - and mount table. - * sigproc.cc: Rely on "child_info_magic.h" to accommodate new magic - number header stuff. - (init_child_info): Initialize new fields in child_info) to accomodate - magic numbers. - * winsup.h: Rename multiple_cygwin_die to multiple_cygwin_problem. - * include/cygwin/version.h: Define macros for manipulating version - magic. - * cygmagic: New shell script for generating magic numbers. - -2001-12-20 Christopher Faylor - - * include/cygwin/version.h: Bump API minor version for below changes. - -2001-12-19 Christopher Faylor - - * Makefile.in (VPATH): Add regex directory. - (NM): new variable. - (OBSOLETE_FUNCTIONS): Ditto. - (NEW_FUNCTIONS): Ditto. - (install-headers): Install regex.h. - (install-man): New target. - (install): Use new target. - (DLL_OFILES): Add v8_reg* stuff. - (new-cygwin1.dll): Eliminate stamp-cygwin-lib creation. - (libcygwin.a): Remove obsolete functions from import lib. Add new functions. - * configure.in: Detect 'nm' tool. - * configure: Regenerate. - * cygwin.din: Export posix_reg* functions. Eliminate export of v8 reg* functions. - This is now handled in object files themselves. - * regex/*: New files. - * regexp/v8_*.c: New files, renamed from non v8_ equivalents. - -2001-12-17 Corinna Vinschen - - * include/getopt.h: Don't define getopt_long() and friends when - included through unistd.h. - -2001-12-17 Christopher Faylor - - * dtable.cc (dtable::init_std_file_from_handle): Avoid initializing - using an invalid handle. - -2001-12-16 David Billinghurst - - * include/limits.h: Define LLONG_MIN, LLONG_MAX, ULLONG_MAX. - -2001-12-11 Christopher Faylor - - * include/getopt.h: Add HAVE_DECL_GETOPT to save pain elsewhere. - -2001-12-10 Christopher Faylor - - * fhandler.h (fhandler_serial::ev): New class member. - * fhandler_serial.cc (fhandler_serial::raw_read): Use class member for - event status. - * select.cc (peek_serial): Ditto. - -2001-12-07 Christopher Faylor - - * path.cc (path_conv::check): Use full path name for determining - attributes when /cygdrive/x/foo. - -2001-12-06 Christopher Faylor - - * path.cc (path_conv::check): Reset FH_CYGDRIVE if iterating through - path. - -2001-12-06 Christopher Faylor - - * path.cc (path_conv::check): Don't complain if /dev/x/foo when x - doesn't exist. - (mount_info::conv_to_win32_path): Keep translating when a /cygdrive is - found. Don't attempt to translate to a device name when devn == - FH_CYGDRIVE. - (cygwin_conv_to_win32_path): Set buffer to empty on error. - (cygwin_conv_to_full_win32_path): Ditto. - - * window.cc: Include unistd.h to verify definitions. - -2001-12-05 Christopher Faylor - - * dir.cc (opendir): Detect error return from build_fhandler_from_name. - -2001-12-04 David Rothenberger - - * net.cc (cygwin_getsockopt): Dereference optlen pointer when passing - to __check_null_invalid_struct_errno. - -2001-12-03 Christopher Faylor - - * net.cc (cygwin_getsockopt): Allow NULL optval. - (cygwin_setsockopt): Ditto. - (cygwin_recvfrom): Allow NULL from. - - * path.cc (mount_info::read_cygdrive_info_from_registry): Don't write - cygdrive to registry if it doesn't exist. - -2001-12-03 Christopher Faylor - - * path.cc (mount_info::conv_to_win32_path): Avoid returning error if - cygdrive == '/'. - (mount_info::cygdrive_win32_path): Return 0 if invalid cygdrive path. - -2001-11-30 Christopher Faylor - - * debug.cc (makethread): Eliminate unneeded function call. - * miscfuncs.cc (tls_ix): Predefine. - * perthread.h (set_reent): Eliminate. - (get_reent): Ditto. - * winbase.h (my_tlsalloc): Use global stack base pointer. Set newly - allocated location to NULL. - (my_tlssetvalue): Use global stack base pointer. - (my_tlsgetvalue): Ditto. - -2001-11-27 Christopher Faylor - - * winsup.h: Reorganize to avoid use of experimental stuff. - * shortcut.cc: Move winsup.h first in include order. - -2001-11-27 Christopher Faylor - - * cygwin.din (ualarm): New export. - * dcrt0.cc (_dll_crt0): Add experimental tls storage declaration. - (dll_crt0): Ditto. - * debug.cc (thread_stub): Ditto. - * thread.cc: Minor cleanup. - (__pthread_create): Add experimental tls storage declaration. - * miscfuncs.cc: Define tls index. - * winsup.h: Declare experimental tls storage. - - * window.cc (alarm): Use old timer return from setitimer. - (ualarm): New function. From Alexandr V. Shutko. - -2001-11-26 Christopher Faylor - - * Makefile.in (libcygwin.a): Use ar commands to build libcygwin.a since - adding an archive doesn't work the way we want it to. - -2001-11-24 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_cygdrive::readdir): Avoid reporting - inaccessible drives. - -2001-11-24 Corinna Vinschen - - * net.cc (cygwin_hstrerror): Allow s == NULL. - (cygwin_rcmd): Add parameter checking. - (cygwin_rexec): Ditto. - -2001-11-24 Corinna Vinschen - - * net.cc (cygwin_inet_ntoa): Add parameter checking. - (cygwin_inet_network): Return INADDR_NONE instead of 0 in case of - EFAULT. - (cygwin_hstrerror): Add parameter checking. - (cygwin_rresvport): Ditto. - (socketpair): Ditto. - * winsup.h (check_null_str): Add extern declaration. - -2001-11-24 Christopher Faylor - - * path.cc (path_conv::check): Tighten FH_CYGDRIVE check to avoid - matching trailing component, like other devices. - -2001-11-24 Christopher Faylor - - * autoload.cc (IsDebuggerPresent): Make conditional load since it is - not available everywhere. - - * path.cc (mount_info::conv_to_win32_path): Only consider /cygdrive to - be FH_CYGDRIVE, not /cygdrive/x. - -2001-11-24 Christopher Faylor - - * net.cc (inet_makeaddr): Revert previous change. - -2001-11-23 Christopher Faylor - - * path.cc (chdir): Allow 'cd /cygdrive'. - -2001-11-23 Christopher Faylor - - * dtable.cc (dtable::vfork_parent_restore): Add debugging statement. - - * exceptions.cc (try_to_debug): Spin only as long as we don't have a - debugger attached. - - * fhandler.h (fhandler_base::set_nohandle): New method. - (fhandler_base::get_nohandle): New method. - * fhandler.cc (fhandler_base::dup): Avoid duplicating handle if there - is no handle. - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Set nohandle - flag on dummy fd. - -2001-11-23 Christopher Faylor - - * Makefile.in: Make intermediate library for eventual inclusion in - libcygwin.a - - * fhandler.h (fhandler_pipe::fhandler_pipe): Remove default argument - setting since it is no longer used. - - * miscfuncs.cc (check_null_str): New function. - (check_null_str_errno): Ditto. - * net.cc: Add defensive buffer checking throughout. - (cygwin_sendto): Protect against invalid fd. - (cygwin_recvfrom): Ditto. - (cygwin_getpeername): Ditto. - (cygwin_recv): Ditto. - (cygwin_send): Ditto. - * winsup.h: Declare a new function. - -2001-11-23 Corinna Vinschen - - * select.cc (set_bits): Fix conditional for setting fd in exceptfds. - * dtable.cc (dtable::build_fhandler): Create fhandler_pipe using - correct device type. - * path.cc (get_devn): Set correct pipe device type from device name. - -2001-11-22 Christopher Faylor - - * path.cc (conv_path_list): Fix wild indexing into path due to - conflicting methods for setting src pointer. - - * dir.cc (opendir): Only pass path_conv argument to opendir, since name - is already part of the fhandler. - * dtable.cc (dtable::build_fhandler): Accomodate new FH_CYGDRIVE type. - * fhandler.cc (fhandler_base::opendir): Nuke name argument. - * fhandler.h: Add FH_CYGDRIVE to "device" enum. - (fhandler_base::opendir): Nuke name argument. - (fhandler_disk_file::opendir): Ditto. - (fhandler_disk_file::fhandler_disk_file): Declare new method which - passes devtype through. - (fhandler_cygdrive): Add elements for tracking drives. - (fhandler_cygdrive::set_drives): Declare new method. - (fhandler_cygdrive::iscygdrive_root): Declare new method. - (fhandler_cygdrive::opendir): Declare new method. - (fhandler_cygdrive::readdir): Declare new method. - (fhandler_cygdrive::telldir): Declare new method. - (fhandler_cygdrive::seekdir): Declare new method. - (fhandler_cygdrive::rewinddir): Declare new method. - (fhandler_cygdrive::closedir): Declare new method. - (fhandler_cygdrive::fstat): Declare new method. - * fhandler_disk_file.cc (fhandler_disk_file::fhandler_disk_file): - Define new method which passes devtype through. - (fhandler_disk_file::open): Tweak debug output. - (fhandler_disk_file::opendir): Nuke first argument. Use info from - path_conv and class rather than calling fstat. - (fhandler_cygdrive::set_drives): New method. - (fhandler_cygdrive::iscygdrive_root): New method. - (fhandler_cygdrive::opendir): New method. - (fhandler_cygdrive::readdir): New method. - (fhandler_cygdrive::telldir): New method. - (fhandler_cygdrive::seekdir): New method. - (fhandler_cygdrive::rewinddir): New method. - (fhandler_cygdrive::closedir): New method. - (fhandler_cygdrive::fstat): New method. - * path.cc (iscygdrive_device): Assume cygdriveness is already verified. - (path_conv::check): Treat FH_CYGDRIVE "method" as a special case, - setting file attributes as needed. - (mount_info::conv_to_win32_path): Allow stand-alone /cygdrive, meaning - "the directory which contains all of the drives on the system". - (fillout_mntent): Use cyg_tolower for conversions. - (mount_info::cygdrive_win32_path): Replace unused argument with unit - number. - * shared_info.h (mount_info::cygdrive_win32_path): Reflect argument - change. - -2001-11-21 Christopher Faylor - - * Makefile.in (DLL_OFILES): Add fhandler_disk_file.o. - * cygheap.h (cygheap_fdnew::operator =): New operator. - * dir.cc: Add invalid struct checking throughout. Use methods for all - directory manipulation throughout. - * fhandler.cc: Move fhandler_disk_file stuff to own file. - (fhandler_base::opendir): New method. - (fhandler_base::readdir): New method. - (fhandler_base::telldir): New method. - (fhandler_base::seekdir): New method. - (fhandler_base::rewinddir): New method. - (fhandler_base::closedir): New method. - * fhandler_disk_file.cc: New file. - * fhandler.h (fhandler_base): Declare new virtual methods. - (fhandler_disk_file): Ditto. - (fhandler_cygdrive): New class. - - * path.cc (conv_path_list): Use strccpy to break apart path. - -2001-11-17 Nick Duffek - - * path.cc (conv_path_list): Copy source paths before modifying them. - -2001-11-17 Corinna Vinschen - - * fhandler_raw.cc (fhandler_dev_raw::clear): Don't reset unit. - * fhandler_tape.cc (fhandler_dev_tape::fhandler_dev_tape): Add debug - output. - -2001-11-15 Egor Duda - - * include/pthread.h (PTHREAD_COND_INITIALIZER): Define. - * thread.cc (__pthread_cond_destroy): Add support for - PTHREAD_COND_INITIALIZER. - (__pthread_cond_init): Ditto. - (__pthread_cond_broadcast): Ditto. - (__pthread_cond_signal): Ditto. - (__pthread_cond_dowait): Ditto. - (__pthread_mutex_init): Handle PTHREAD_MUTEX_INITIALIZER correctly, - don't return error when it's passed as parameter. - * winsup.h (check_null_invalid_struct): Call correct function. - -2001-11-14 Christopher Faylor - - * exceptions.cc: Add stdlib.h include for alloca declaration. - * poll.cc: Ditto. - * termios.cc: Ditto. - -2001-11-14 Christopher Faylor - - * syscalls.cc (_write): Only allow zero length when fd is valid. - -2001-11-14 Corinna Vinschen - - * fhandler.cc (fhandler_disk_file::fstat): Add setting access time - and creation time to last modification time for files on filesystems - not supporting multiple timestamps. - (fhandler_disk_file::fstat_helper): Set access time and creation - time in incoming Windows structure instead of in stat buf to avoid - incorrectly overwriting Epoch timestamp. - -2001-11-14 Corinna Vinschen - - * winsup.h: Remove alloca definition since it's now defined through - inclusion of stdlib.h. - * lib/cygwin_crt0.c: Ditto. - -2001-11-13 Christopher Faylor - - * syscalls.cc (_write): Allow zero length as per SUSv2. - -2001-11-13 Corinna Vinschen - - * dir.cc (mkdir): Add HIDDEN file attribute if file has leading dot - and HIDDEN_DOT_FILES is defined. - * fhandler.cc (fhandler_base::open): Ditto. - * path.cc (symlink): Ditto. - * syscalls.cc (_rename): Ditto and remove HIDDEN file attribute if - new filename does not begin with a dot. - -2001-11-12 Christopher Faylor - - * fhandler_console.cc (fhandler_console::read): Revert 2001-10-23 - change to only honor keydown events. - -2001-11-11 Christopher Faylor - - * include/cygwin/version.h: Bump version to 1.3.6. - -2001-11-10 Christopher Faylor - - * dtable.cc (dtable::build_fhandler): Don't increment console fd count - if new operation fails. Increment fork_fixup field here. - (dtable::dup2): Don't increment fork_fixup field here. - * net.cc (fdsock): Ditto. - -2001-11-08 Corinna Vinschen - - * select.cc: Set errno using set_sig_errno() throughout. - * signal.cc (signal): Always set SA_RESTART flag. - * syscalls.cc (_read): Revert previous patch. - -2001-11-08 Corinna Vinschen - - * select.cc (fhandler_tty_slave::ready_for_read): Return 0 on EBADF. - * syscalls.cc (_read): If ready_for_read() failed, save errno from - being overwritten by signal handler call. - -2001-11-07 Corinna Vinschen - - * lib/getopt.c (getopt_internal): Reset optind to 1 only if optreset - is not set. - -2001-11-06 Christopher Faylor - - * select.cc (fhandler_tty_slave::ready_for_read): Correct inverted - not_open test. - -2001-11-05 Christopher Faylor - - * include/cygwin/version.h: Bump version to 1.3.5. - -2001-11-05 Corinna Vinschen - - * mmap.cc (mmap_record::find_empty): Add input parameter check. - -2001-11-04 Christopher Faylor - - * dtable.cc (dtable::build_fhandler): Fix debug_printf to avoid SEGV - due to incorrect parameter placement. - -2001-11-04 Christopher Faylor - - * fhandler.h (fhandler_pipe::broken_pipe): Renamed from saweof. - (fhandler_pipe::set_eof): Reflect above change. - * pipe.cc (fhandler_pipe::fhandler_pipe): Ditto. - (fhandler_pipe::read): Ditto. - (fhandler_pipe::hiteof): Ditto. - -2001-11-04 Christopher Faylor - - * pipe.cc (fhandler_pipe::read): Narrow eof return to just the "broken - pipe" test. - -2001-11-04 Christopher Faylor - - * select.cc: Add more comments throughout. Use bool 'true' where - appropriate throughout. - (fhandler_socket::select_read): Remove duplicate setting for *_ready - which inadvertently overrode previous, correct setting. - (fhandler_socket::select_write): Ditto. - -2001-11-03 Christopher Faylor - - * select.cc (verify_console): New function. - (verify_windows): Ditto. - (fhandler_console::select_read): Really do need to verify that there is - something to read. - (fhandler_console::select_windows): Ditto. - -2001-11-03 Christopher Faylor - - * fhandler.h (fhandler_base::ready_for_read): Remove unused argument. - (fhandler_tty_slave::ready_for_read): Ditto. - (select_record): Remove poll, initialize peek. - * select.cc: Remove all poll functions, throughout. Change second - argument of peek_* functions to 'bool' throughout. Specifically - initialize *_ready variables throughout. - (select_stuff::poll): Subsume previous poll functionality. - (peek_pipe): Don't grab guard mutex when in select loop. - select()/read() is racy by design so there is no need to worry about a - race in select(). - (fhandler_base::ready_for_read): Remove unused argument. - (fhandler_tty_slave::ready_for_read): Ditto. - * syscalls.cc (_read): Eliminate third argument in ready_for_read call. - -2001-11-03 Corinna Vinschen - - * security.cc (get_supplementary_group_sidlist): New function. - (get_group_sidlist): Call get_supplementary_group_sidlist() to - retrieve list of supplementary groups SIDs from /etc/group and - add them to the user's group list. - -2001-11-03 Christopher Faylor - - * fhandler.cc (fhandler_base::read): Return just read ahead characters - if slow device. - * fhandler.h (fhandler_base::set_eof): New virtual method. - (fhandler_pipe::set_eof): New method. - * pipe.cc (fhandler_pipe::fhandler_pipe): Clear saweof flag. - (fhandler_pipe::read): Return immediately if hit eof. - (fhandler_pipe::hit_eof): Return true if saweof flag is set. - * select.cc (peek_pipe): Don't call PeekNamedPipe if we couldn't grab - the guard mutex. - -2001-11-02 Egor Duda - - * dll_init.h (class dll_list): Reorder functions to avoid compiler - "can't inline" warnings. - * security.h (class cygsid): Ditto. - * sigproc.cc (get_proc_lock): Ditto. - * sigproc.h (class sigframe): Ditto. - * sync.h (class muto): Ditto. - -2001-11-02 Christopher Faylor - - * fhandler.h (fhandler_base::get_guard): Actually MAKE virtual as - previously indicated. - * pipe.cc (make_pipe): Remove extraneous set_errno. - * syscalls.cc (_open): Ditto. - * select.cc (peek_pipe): Need to check that there is still something to - read from the pipe after acquiring the mutex since another - process/thread could have eaten the input before we got to acquiring - the lock. (Thanks to Nick Duffek for this inspiration.) - -2001-11-01 Christopher Faylor - - * fhandler.h: Change Windows 'BOOL's to c++ 'bool's for all variables. - * select.cc (fhandler_base::ready_for_read): Set read_ready to zero - prior to testing it or it will be uninitialized. - - * Makefile.in (CFLAGS): Move setting to Makefile.common. - -2001-11-01 Christopher Faylor - - * cygheap.h (cygheap_fdmanip::isopen): Set appropriate errno if fd not - open. - * select.cc (fhandler_base::ready_for_read): Release an open guard - mutex when exiting with an error condition. - * syscalls.cc (_read): Check frequently for closed fd as a kludge until - something better is invented. - -2001-11-01 Christopher Faylor - - * dtable.cc (dtable::build_fhandler): Issue internal error on unknown - device. - * fhandler.cc (fhandler_base::close): Show both name and handle in - debugging output. - - * fhandler.h (fhandler_base::get_guard): New virtual method. - (fhandler_pipe::get_guard): New method. - (fhandler_socket::ready_for_read): Delete declaration. - (fhandler_pipe::ready_for_read): Ditto. - (fhandler_serial::ready_for_read): Ditto. - (fhandler_console::ready_for_read): Ditto. - (fhandler_tty_common::ready_for_read): Ditto. - (fhandler_windows::ready_for_read): Ditto. - (struct select_record::peek): Declare new method. - * select.cc (MAKEready): Delete. - (peek_pipe): Use get_guard method to retrieve potential guard mutex - handle. - (fhandler_base::ready_for_read): Rewrite as generic ready-for-read - handler. Should only be called for "slow" devices. - (fhandler_socket::ready_for_read): Delete definition. - (fhandler_pipe::ready_for_read): Ditto. - (fhandler_serial::ready_for_read): Ditto. - (fhandler_console::ready_for_read): Ditto. - (fhandler_tty_common::ready_for_read): Ditto. - (fhandler_windows::ready_for_read): Ditto. - (fhandler_pipe::select_read): Fill in new peek record in select_record - structure. - (fhandler_console::select_read): Ditto. - (fhandler_tty_common::select_read): Ditto. - (fhandler_serial::select_read): Ditto. - (fhandler_socket::select_read): Ditto. - (fhandler_socket::select_read): Ditto. - (fhandler_tty_slave::ready_for_read): Check for tty not open. Set - errnos appropriately. - * syscalls.cc (_read): Allow ready_for_read to set errno. - - * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it - is initializing. - * sigproc.cc (getsem): Adjust wait for process to initialize downward - to avoid huge waits. - -2001-10-31 Christopher Faylor - - * environ.cc: Set reset_com to false to mimic linux behavior more - closely. - -2001-10-31 Corinna Vinschen - - * dtable.cc (dtable::vfork_child_dup): Revert impersonation - before duplicating fhandler. - -2001-10-30 Christopher Faylor - - * exceptions.cc (signal_exit): Weight the odds against the main thread - running when signal thread is exiting. - -2001-10-30 Christopher Faylor - - * sigproc.cc (sigproc_terminate): Don't signal main thread when exiting. - * sigproc.h (sigframe): Decorate some methods with `inline'. - (new_muto): Coerce pointer to new to void *. - -2001-10-30 Christopher Faylor - - * fhandler.cc (fhandler_base::fork_fixup): Pass old handle to - setclexec_pid. - -2001-10-30 Christopher Faylor - - * cygheap.h (cygheap_fdmanip::cygheap_fdmanip): Clear fh. - (cygheap_fdmanip::isopen): New method. - * syscalls.cc (_read): Avoid accessing closed fd. - - * path.h (fe_types): New enum. - (path_conv::set_path): New method. - (find_exec): Change null_if_not_found argument to something more - generic. - * spawn.cc (find_exec): Default to returning the POSIX path rather than - the windows path, unless instructed otherwise. - (spawn_guts): Force call to find_exec to use native paths. - * dlfcn.cc (check_path_access): Accommodate new find_exec arguments. - * environ.h (win_env::get_posix): New method. - -2001-10-30 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::close): Add error handling. - -2001-10-30 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::dup): Revert previous change. - -2001-10-30 Christopher Faylor - - * dtable.cc (dtable::dup2): Add some debugging. Use methods from - passed in class rather than cygheap->fdtab. - * fhandler_socket.cc (fhandler_socket::fixup_before_fork_exec): Add - more debugging output. - (fhandler_socket::dup): Allocate new space for prot_info_ptr for - duplicated entry. - (fhandler_socket::close): Loop closesocket() as long as WSAEWOULDBLOCK - is returned. - * syscalls.cc (stat_worker): Always delete fh if it has been created. - -2001-10-29 Corinna Vinschen - - * security.cc (is_group_member): Call NetLocalGroupGetMembers() for - local machine only. - (get_user_local_groups): Ditto for NetLocalGroupEnum(). - -2001-10-29 Christopher Faylor - - * fhandler.cc (fhandler_base::set_name): Set namehash here to catch - name changes. - (fhandler_base::open): Remove namehash setting. - (fhandler_base::fstat): Subtract 1 from arbitrary time setting to avoid - strange ls -l granularity problem. - -2001-10-29 Christopher Faylor - - * select.cc (MAKEready): Remove extraneous select_read. - -2001-10-29 Corinna Vinschen - - * uinfo.cc (internal_getlogin): Set environment variable $HOME - from either /etc/passwd or $HOMEDRIVE/$HOMEPATH if necessary. - -2001-10-29 Christopher Faylor - - * fhandler.h (fhandler_serial::fhandler_serial): Change to only accept - unit argument. - * fhandler_serial.cc (fhandler_serial::fhandler_serial): Ditto. - (fhandler_serial::open): Avoid else when previous clause is a return(). - * path.cc (get_devn): Alias /dev/ttyS0 -> /dev/com1, etc. - (get_device_number): Reallow standalone "com1" as a valid name for - /dev/com1. - -2001-10-26 Christopher Faylor - - * select.cc (MAKEready): Check for read_ready in loop since select_read - could set it. - (peek_socket): Check ready/write/except specifically since they could - have been set even prior to peek_socket call. - -2001-10-24 Christopher Faylor - - * shared_info.h (MOUNT_VERSION): Change to a smaller, still arbitrary - number. - * shared.cc (open_shared): Accept a number to denote the shared memory - region. - (memory_init): Use shared memory version as part of the object name of - the shared region. Ditto for the mount table. - * path.cc (CYGWIN_REGNAME): New define used in place of - CYGWIN_INFO_CYGWIN_REGISTRY_NAME throughout. - * external.cc (cygwin_internal): Implement CW_[GS]ET_CYGWIN_REGISTRY_NAME. - * cygheap.h (init_cygheap::cygwin_regname): New element. - -2001-10-23 Christopher Faylor - - Ensure that all fhandler_*::read definitions are __stdcall throughout. - * fhandler.cc (fhandler_base::set_inheritance): Be more defensive in - debugging code. - * fhandler.h: Adjust regparms throughout to reflect passing 'this' - parameter. - * fhandler_console.cc (fhandler_console::read): Remove unneeded test. - Only honor "key down" events. - * miscfuncs.cc (strcasestr): Reorganize for efficient code use. - (check_null_empty_str_errno): Ditto. - (__check_null_invalid_struct_errno): Ditto. - (__check_invalid_read_ptr_errno): Ditto. - * syscalls.cc (_read): Return 0 when length == 0, as per Single UNIX - Specification. - -2001-10-22 Christopher Faylor - - * debug.cc (set_errno): Return value of errno that was set, just like - the macro. - (setclexec_pid): Replace old handle with new handle. - * debug.h: Reflect change in arguments for setclexec_pid. - * fhandler.cc (fhandler_base::set_inheritance): Ditto. - (fhandler_base::fork_fixup): Ditto. - * cygerrno.h: Reflect return value change for set_errno. - -2001-10-22 Christopher Faylor - - Remove 'cb' parameter and modify fhandler_* constructors throughout. - * dtable.cc (dtable::build_fhandler): Remove debugging output which - uses 'cb'. - * exec.cc (execvp): New function. - (execvpe): Ditto. - * fhandler.cc (fhandler_base::fhandler_base): Use constructor - initialization. - * fhandler.h (fhandler_tty_common::fhandler_tty_common): Ditto. - * fhandler_clipboard.cc (fhandler_dev_clipboard::fhandler_dev_clipboard): - Ditto. - * fhandler_console.cc (fhandler_console::fhandler_console): Ditto. - * fhandler_raw.cc (fhandler_dev_raw::fhandler_dev_raw): Ditto. - * fhandler_serial.cc (fhandler_serial::fhandler_serial): Ditto. - * fhandler_tty.cc (fhandler_tty_master::fhandler_tty_master): Ditto. - (fhandler_tty_slave::fhandler_tty_slave): Ditto. - (fhandler_pty_master::fhandler_pty_master): Ditto. - * fhandler_windows.cc (fhandler_windows::fhandler_windows): Ditto. - -2001-10-22 Corinna Vinschen - - Patch suggested by Ian Ray : - * syscalls.cc (seteuid): Unset environment variables HOMEDRIVE and - HOMEPATH before calling internal_getlogin(). - * uinfo.cc (internal_getlogin): Use default HOMEPATH and HOMEDRIVE - from environment if both are present, else query NetUserGetInfo(). - -2001-10-22 Corinna Vinschen - - * net.cc (get_2k_ifconf): Change multiple IP address naming scheme - to Linux style. - -Sun Oct 21 19:04:37 2001 Alexander Gottwald - - * net.cc (get_2k_ifconf): Added support for multiple IP addresses on - one interface. - -2001-10-22 Corinna Vinschen - - * miscfuncs.cc (__check_invalid_read_ptr_errno): Return error, if any. - -2001-10-21 Christopher Faylor - - * resource.cc (fill_rusage): Perform paranoid zero structure passed to - GetProcessMemoryInfo. - -2001-10-22 Robert Collins - - * autoload.cc: Autoload GetProcessMemoryInfo. - * resource.cc (fill_rusage): Calculate ru_maxrss and ru_majflt entries. - (Bug report on this from Guido Serassio in the squid project). - This requires including psapi.h. - -2001-10-20 Christopher Faylor - - * dll_init.cc (dll_list::alloc): Increase retry count to 1000. - -2001-10-20 Christopher Faylor - - * miscfuncs.cc (__check_invalid_read_ptr_errno): New function. - * syscalls.c (_write): Validate that write buffer is accessible for - reading, not writing. - * winsup.h: Declare new function, increase regparmization of check_* - functions. - -2001-10-19 Corinna Vinschen - - * path.cc (getcwd): Allow len == 0 when buf == NULL. - -2001-10-18 Christopher Faylor - - * syscalls.cc (_read): Validate input pointer. - (_write): Ditto. - (system): Ditto. - -2001-10-16 Frederic Devernay - - * poll.cc (poll): Call cygwin_select() if any fd is valid. - -2001-10-16 Corinna Vinschen - - * fhandler_raw.cc (fhandler_dev_raw::open): Eliminate compatibility - code since no Win32 device names are used anymore. - * fhandler_tape.cc (fhandler_dev_tape::tape_set_blocksize): Allow - 0 as blocksize to indicate variable blocksize. - * path.cc (win32_device_name): Generate NT internal device names - using upper/lower case names for readability. - Generate \DosDevices\: device name for mount table - compatibility devices. - -2001-10-16 Corinna Vinschen - - * fhandler_tape.cc (fhandler_dev_tape::tape_status): Report - EOTWarningZoneSize in get->mt_eotwarningzonesize. - * include/cygwin/mtio.h: Define DEFTAPE. - (struct mtget): Add member `mt_eotwarningzonesize'. Add a comment. - * include/cygwin/version.h: Bump API minor version to 47. - -2001-10-16 Christopher Faylor - - * fhandler.cc (fhandler_base::fork_fixup): Guard against compiler - warning. - -2001-10-16 Corinna Vinschen - - * autoload.cc: Add load statement for `NtOpenFile'. - * fhandler.h (fhandler_dev_raw::get_unit): New method. - (fhandler_dev_tape::norewind): Eliminate. - (fhandler_dev_tape::is_rewind_device): New method. - * fhandler_raw.cc (fhandler_dev_raw::open): Open new - fixed device name devices using NT internal method. - Keep calling fhandler_base::open() for old mount table - device mapping compatibility devices. - (fhandler_dev_raw::fstat): Eliminate. Settings are done - by fhandler_base::fstat() already. - * fhandler_tape.cc: Remove `norewind' usage throughout. - * ntdll.h: Define FILE_SYNCHRONOUS_IO_NONALERT. - Define struct _IO_STATUS_BLOCK. - Declare NtOpenFile(). - * path.cc (get_raw_device_number): Add new approach for - using fixed device names. - (win32_device_name): Ditto. - (get_device_number): Ditto. Require POSIX path to begin - with "/dev/". - (mount_info::conv_to_win32_path): Call win32_device_name() - instead of get_device_number() after evaluating mount points - to allow changing the win32 destination path again. - * security.cc (str2buf2uni): Remove `static' to be able to - call function from fhandler_dev_raw::open(). - * wincap.cc: Set flag has_raw_devices appropriately. - * wincap.h: Add flag has_raw_devices. - -2001-10-16 Christopher Faylor - - * cygheap.h (cygheap_fdget::cygheap_fdget): Remove debugging operation - from set_errno. - -2001-10-16 Christopher Faylor - - * mmap.cc (mmap): Assign 'fh' from cygheap_fdget. Use 'fh' everywhere. - -2001-10-15 Christopher Faylor - - * cygerrno.h (set_errno): Define more informative version of this - function for debugging. - (__set_errno): Declare when DEBUGGING. - * cygheap.h (cygheap_fdget::cygheap_fdget): Add a flag to control when - errno is set. - * debug.cc (__set_errno): New function. - * fcntl.cc (_fcntl): Fix so that correct fd is used for second argument - to dup2. - * syscalls.cc (_cygwin_istext_for_stdio): Don't set errno here when - using cygheap_fdget. - -2001-10-15 Christopher Faylor - - * fhandler.cc (fhandler_base::fork_fixup): Don't protect handle. - - * dlfcn.cc: Fix to confirm to coding standards. - - Reorganize includes throughout to accommodate new cygheap.h usage. - * cygheap.h (cygheap_fdmanip): New class: simplifies locking and - retrieval of fds from cygheap->fdtab. - (cygheap_fdget): Ditto. - (cygheap_fdnew): Ditto. - * fcntl.cc (_fcntl): Use new method to lock fdtab and retrieve info. - * ioctl.cc (ioctl): Ditto. - * mmap.cc (mmap): Ditto. - * net.cc: Ditto, throughout. - * passwd.cc (getpass): Ditto. - * path.cc (fchdir): Ditto. - * pipe.cc (make_pipe): Ditto. - * sec_acl.cc (facl): Ditto. - * syscalls.cc: Ditto, throughout. - * termios.cc: Ditto, throughout. - -2001-10-15 Corinna Vinschen - - * uname.cc (uname): Use `wProcessorLevel' unless OS sets it wrong. - Use `dwProcessorType' then instead. - * wincap.cc: Set flag has_valid_processorlevel appropriately. - * wincap.h: Add flag has_valid_processorlevel. - -2001-10-14 Christopher Faylor - - * dtable.cc (dtable::build_fhandler_from_name): Use PC_FULL to - determine path name. - * path.cc (fchdir): Remove rel -> abs path conversion. - -Sun Oct 14 08:10:12 2001 Gary R. Van Sickle - - * fork.cc (fork_parent): Correct the "unable to allocate - forker_finished event" error message. It named the wrong event before. - -2001-10-13 Christopher Faylor - - * autoload.cc (load_wsock32): Declare dummy function to force loading - of winsock. - * fhandler.cc (fhandler_base::set_inheritance): Make debugging output - more verbose. - * fhandler_socket.cc (fhandler_socket::fixup_after_fork): Force loading - of winsock32 if winsock2 not available. - * net.cc (set_socket_inheritance): Use DuplicateHandle in all cases to - set inheritance correctly. - (fdsock): Use winsock2_active macro to determine when to set socket - inheritance. Remove fdtab resource locking since this function should - already be protected. - (cygwin_accept): Simplify logic. Ensure that fdtab unlock is not - called inappropriately. - (cygwin_rcmd): Use fdtab locking. - (cygwin_rresvport): Ditto. - (cygwin_rexec): Ditto. - * select.cc (peek_socket): Set errno appropriately if winsock select - fails. - -2001-10-13 Kazuhiro Fujieda - - * winsup.h: Declare check_pty_fds. - * syscalls.cc (check_pty_fds): Rename from check_ttys_fds. Also check - pty master. - (setsid): Use check_pty_fds. - * dtable.cc (dtable::dec_console_fds): Add check on pty fds. - -2001-10-13 Ralf Habacker - - * fhandler_dsp.cc (fhandler_dsp::ioctl): Return 0 for successful - SNDCTL_DSP_GETBLKSIZE operation. - -2001-10-13 Christopher Faylor - - Remove obsolete 'name' arg from fhandler_* constructors throughout. - * winsup.h (winsock_active): New macro. - (winsock2_active): Ditto. - * autoload.cc (wsock_init): Use new macros to decide if winsock or - winsock2 is loaded. - (nonexist_wsock32): Dummy function to force winsock load. - (nonexist_ws2_32): Dummy function to force winsock2 load. - * fhandler.h (fhandler_socket::fstat): Declare new method. Currently - unused. - * fhandler_socket.cc (fhandler_socket::fixup_before_fork_exec): Check - that winsock2 is active before trying WSADuplicateSocketA. - (fhandler_socket::fixup_after_fork): Add extra check for - winsock2_active. Otherwise use iffy procedures for Windows 95. - (fhandler_socket::fixup_after_exec): Add debugging. - (fhandler_socket::dup): Add debugging. - (fhandler_socket::fstat): New method. - (fhandler_socket::set_close_on_exec): Attempt to perform iffy stuff on - Windows 95. - - * errno.cc (_sys_nerr): Work around compiler strangeness. - - * pinfo.cc (winpids::add): Add extra element at end of allocated array - for setting to NULL. - (winpids::enumNT): Ditto. - (winpids::init): Don't modify pidlist if it hasn't been allocated - (possibly due to malloc problem). - -2001-10-12 Christopher Faylor - - * autoload.cc (wsock_init): Reorganize slightly to accommodate a new - compiler. - -2001-10-11 Egor Duda - - * net.cc (cygwin_sendto): Use correct socket address when sending - data to AF_UNIX socket. - -Wed Oct 10 16:10:41 2001 Alexander Gottwald - - * net.cc (get_95_ifconf): Using other registry values pointing to - correct networkdevice identification for Windows95. - -Tue Oct 9 22:22:45 2001 Christopher Faylor - - Throughout, rename PROC_FORK1 to PROC_FORK. - * child_info.h: Rename PROC_* to _PROC_*. Define PROC_* with - additional testing magic. Eliminate old PROC_FORK and rename - PROC_FORK1 to PROC_FORK. - * dcrt0.cc (_cygwin_testing_magic): New variable. Added to magic - number in proc_info. - (alloc_stack): Eliminate old PROC_FORK test. - (dll_crt0_1): Ditto. Use _PROC_* enums for test. Subtract - _cygwin_testing_magic from child_proc_info->type so that normal cygwin - programs invoked by test suite programs do not consider themselves to - be in a cygwin environment. - (_dll_crt0): Ditto. Move environment checks to initial_env function to - conserve on stack space. - (initial_env): New function. Checks for testing and debugging - environment variables. - * init.cc (cygwin_hmodule): Move declaration. - * winsup.h: Declare variables used for cygwin testing. - -Tue Oct 9 19:17:53 2001 Christopher Faylor - - * uinfo.cc (internal_getlogin): Reorganize slightly to minimize work in - default condition. - -Tue Oct 9 18:53:00 2001 Corinna Vinschen - - * fhandler.cc (fhandler_disk_file::open): Add missing case clash check. - -Mon Oct 8 01:47:27 2001 Christopher Faylor - - * dtable.cc (dtable::build_fhandler): Allocate correct amount for given - fhandler class. - * fhandler.h (fhandler_union): Properly define rather than relying on - fhandler_console being "big enough". - -Mon Oct 8 00:25:18 2001 Christopher Faylor - - * external.cc (fillout_pinfo): Reset counter whenever we initialize the - pid list. - -Sun Oct 7 17:16:05 2001 Christopher Faylor - - * path.cc (normalize_posix_path): Don't eat a '.' after a '\\' since it - has special meaning on NT. - - * syscalls.cc (access): Use stat_worker. - -Fri Oct 5 21:01:14 2001 Christopher Faylor - - * fhandler.cc (fhandler_base::fork_fixup): Protect dup'ed handle and - record it as non-inheritable for debugging purposes in case there is a - subsequent fork or exec. - * fhandler_tty.cc (fhandler_tty_common::fixup_after_fork): Allow - fork_fixup to call ProtectHandle. - -Fri Oct 5 14:22:47 2001 Christopher Faylor - - * path.cc (get_raw_device_number): Correct length arguments for - wdeveqn. - -Fri Oct 5 11:05:32 2001 Christopher Faylor - - * path.cc (getcwd): Allow NULL first argument. - -Fri Oct 5 00:31:35 2001 Christopher Faylor - - * heap.h (inheap): Check for NULL. - -Thu Oct 4 23:17:49 2001 Christopher Faylor - - Add second path_conv * argument to fstat()s throughout. - * fhandler.h: Change read and fstat to regparm/stdcall throughout. - (fhandler_base::fstat): Just declare. Don't define. - (fhandler_disk_file::fstat_helper): Declare. - * fhandler.cc (fhandler_base::fstat): Move here from fhandler.h, adapt - from former stat_dev(). - (fhandler_disk_file::fstat): Move most of the disk-file-specific logic - from stat_worker to here. Use fstat_helper to derive final fstat - output. - (fhandler_disk_file::fstat_helper): New method, renamed from former - fstat method. - (num_entries): Moved here from syscalls.cc. - * fhandler_mem.cc (fhandler_dev_mem::fstat): Use base class to - initialize most stuff. Invert has_physical_mem_access test for - establishing permissions. - * fhandler_raw.cc (fhandler_dev_raw::fstat): Eliminate unneed test and - memory clearing. Use base class to initialize most stuff. - * syscalls.cc (stat_dev): Eliminate. - (stat_worker): Simply call fstat method to generate fstat output. Move - all device specific code to appropriate fstats. - - * dir.cc (opendir): Pass correct arg to stat_worker to allow following - symlinks. - -Thu Oct 4 21:37:57 2001 Christopher Faylor - - * spawn.cc (perhaps_suffix): Return NULL on non-existence of file as - well as "directoryness". Previous code modified on 2001/09/30 actually - had an arguable bug which was unmasked by the change on that day. - -Thu Oct 4 20:52:42 2001 Christopher Faylor - - * path.cc (path_conv::check): Return ENOTDIR when leading device and - trailing component. - -Thu Oct 4 18:49:23 2001 Christopher Faylor - - * syscalls.cc (stat_worker): Make global. Accept path_conv parameter - for passing information back to caller. - * winsup.h: Declare stat_worker. - * dir.cc (opendir): Use stat_worker rather than stat and pass path_conv - parameter to stat_worker for later inspection. - -2001-10-04 Karellen (karellen@boreworms.com) - - * syslog.cc (syslog): Teach syslog about syslog priorities other than - LOG_ERR, LOG_WARNING and LOG_INFO - -Thu Oct 4 15:50:03 2001 Christopher Faylor - - * path.cc (path_conv::check): Don't perform file system or rootdir - checks on devices. - -Wed Oct 3 19:40:36 2001 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Don't close hexec_proc if it is NULL. - - * fork.cc (vfork): Add debugging statements. - - * path.cc (get_device_number): Make static. Rewrite to inspect both unix - and windows paths. - (get_raw_device_number): Just check for parts of raw device that we - care about. - (get_devn): New function, pulled from get_device_number. - (win32_device_name): Accommodate arg changes to get_device_number. - (mount_info::get_device_number): Call get_device_number on translated - Windows path. - - * spawn.cc (spawn_guts): Don't treat P_VFORK differently from P_NOWAIT. - Add handle to child's shared region to child so that it will be - preserved if the parent goes away. - * fhandler.h: Throughout, simplify to one open method for all fhandler - classes, requiring a path_conv first element. - * fhandler.cc (fhandler_base::open): Remove obsolete method. - Generalize to require path_conv * as first argument. - (fhandler_disk_file::open): Remove obsolete method. - (fhandler_disk_file::open): Use path_conv pointer rather than - reference. - * fhandler_clipboard.cc (fhandler_dev_clipboard::dup): Use new open - method. - (fhandler_dev_clipboard::open): Accommodate new argument for open - methods. - * fhandler_console.cc (fhandler_console::open): Ditto. - (fhandler_console::dup): Use new open method. - (fhandler_console::fixup_after_fork): Ditto. - (fhandler_console::fixup_after_exec): Ditto. - * fhandler_dsp.cc (fhandler_dev_dsp::open): Accommodate new argument for - open methods. - * fhandler_floppy.cc (fhandler_dev_floppy::open): Ditto. - * fhandler_mem.cc (fhandler_dev_mem::open): Ditto. - * fhandler_random (fhandler_dev_random::open): Ditto. - * fhandler_raw.cc (fhandler_dev_raw::open): Ditto. - * fhandler_serial.cc (fhandler_serial::open): Ditto. - * fhandler_tape.cc (fhandler_dev_tape::open): Ditto. - * fhandler_tty.cc (fhandler_tty_slave::open): Ditto. - (fhandler_pty_master::open): Ditto. - * fhandler_windows.cc (fhandler_windows::open): Ditto. - * fhandler_zero.cc (fhandler_dev_zero::open): Ditto. - * fhandler_socket.cc (fhandler_socket::set_connect_secret): Accommodate - new argument for open methods. - * syscalls.cc (_open): Ditto. - (stat_worker): Ditto. - -Tue Oct 2 23:49:18 2001 Christopher Faylor - - * cygheap.cc (cfree): Remove malloc debugging probe. - * dlmalloc.c (errprint): Remove abort() call which causes interesting - error message printing to abort prematurely. - * environ.cc: Sprinkle MALLOC_CHECKs liberally throughout. - (_addenv): Allocate two empty elements at end of environ to - (apparently) work around problems with some buggy applications. - (winenv): Avoid calling alloca if no forced environment variable is - present. - - * exceptions.cc (open_stackdumpfile): Don't print "Dumping stack trace - to..." when running in a cygwin environment (i.e., the parent is a - cygwin process). - - * dtable.cc (dtable::init_std_file_from_handle): Move device type - detection code from build_fhandler here since it is only used by this - function. - (dtable::build_fhandler_from_name): New method. Renamed from - dtable::build_fhandler. - (dtable::build_fhandler): Use build_fhandler_from_name. - (cygwin_attach_handle_to_fd): Ditto. - * syscalls.cc (_open): Ditto. - (stat_worker): Ditto. - * dtable.h (dtable::build_fhandler_from_name): Rename declaration from - dtable::build_fhandler. - -Mon Oct 1 16:52:23 2001 Christopher Faylor - - * dtable.h (dtable::build_fhandler): Make path_conv parameter - non-optional. - (dtable::init_std_file_from_handle): Eliminate name parameter. - * dtable.cc (stdio_init): Don't pass bogus name to - init_std_file_from_handle. The function will figure out the name - itself. - (dtable::init_std_file_from_handle): Eliminate name parameter. Assume - that we're always called with an appropriate fd. Pass name as NULL if - we can't simply figure it out from context. - (cygwin_attach_handle_to_fd): Pass path_conv argument to - build_fhandler. - (dtable::build_fhandler): Make path_conv argument mandatory. Eliminate - specific call to get_device_number. With unknown device names, set - name from handle context for parsing by path_conv. - (dtable::build_fhandler): Pass path_conv argument to build_fhandler. - * path.h (path_conv::set_isdisk): Set disk device type. - (path_conv::is_device): Don't consider FH_DISK a "device". - * syscalls.cc (_open): Pass path_conv argument by reference. - (stat_worker): Ditto. - (_rename): Use path_conv operators. Add bounds to DeleteFile/MoveFile - for loop. - -Mon Oct 1 14:25:00 2001 Charles Wilson - - * cygwin.din: export strtoll and strtoull - -Sun Sep 30 22:51:41 2001 Christopher Faylor - - Add "path.h" include throughout, where needed. Use new path_conv - methods and operators to simplify testing for directory and attributes, - throughout. - * path.h (path_conv::exists): New method. - (path_conv::has_attribute): Ditto. - (path_conv::isdir): Ditto. - (path_conv::DWORD &): New operator. - (path_conv::int &): Ditto. - * dir.cc (rmdir): Eliminate a goto. - * dtable.cc (dtable::build_fhandler): Accept opt and suffix info for - path_conv.check. Return fh == NULL on path_conv error. Pass unit to - set_name as appropriate. - (dtable::reset_unix_path_name): New method. - * dtable.h (dtable): Declare new method. Reflect arg changes to - build_fhandler. - * fhandler.cc (fhandler_disk_dummy_name): Eliminate. - (fhandler_base::set_name): Expect paths to be NULL. Build - unix_path_name from win32_path_name when it is a device. - (fhandler_base::reset_unix_path_name): New method. - (fhandler_base::raw_read): Report EISDIR when ERROR_INVALID_FUNCTION - or ERROR_INVALID_PARAMETER and reading a directory. - (fhandler_disk_file::fstat): Don't call stat_dev since we should now - never be calling fhandler_disk_file methods with devices. - (fhandler_base::fhandler_base): Clear {unix,win32}_path_name. - (fhandler_base::~fhandler_base): Always free {unix,win32}_path_name. - (fhandler_disk_file::fhandler_disk_file): Remove set_no_free_names - kludge. - (fhandler_disk_file::open): Ditto. - * fhandler.h (fhandler_base::no_free_names): Eliminate. - (fhandler_base::set_no_free_names): Ditto. - * fhandler_tty.cc (fhandler_tty_slave::fhandler_tty_slave): Don't set - unix_path_name here. - * path.cc (fchdir): Lock fd table throughout. Use new - dtable::reset_unix_path_name method to reset path. - * syscalls.cc (stat_worker): Reorganize to always call fstat method. - Pass path_conv method to fhandler_*::open. - (chroot): Elminate a goto. - -Sun Sep 30 17:37:43 2001 Christopher Faylor - - * environ.cc (winenv): Allocate exact amount of space needed for forced - windows environment variable rather than just using MAX_PATH. - -Sun Sep 30 17:10:18 2001 Christopher Faylor - - * Makefile.in: Depend on stamp to ensure rebuilding. Remove stamp file - when we've just built the DLL. - -Mon Oct 1 00:34:00 2001 Robert Collins - - * thread.cc (pthread_cond_dowait): Hopefully eliminate a race on multiple thread - wakeups. - -Sat Sep 29 18:26:00 2001 Robert Collins - - * pthread.cc (pthread_cond_timedwait): Deleted - exported from thread.cc. - (pthread_cond_wait): Deleted - exported from thread.cc. - * thread.cc (pthread_cond::BroadCast): Update to use the new syntax for - verifyable_object_isvalid (). - (pthread_cond::Signal): Ditto. Also attempt to fix the lost signal race - with pthread_cond::TimedWait(). - (check_valid_pointer): Change definiton to void const *. - (verifyable_object_isvalid): Add new parameter to allow identification of - static initializers, and return a enum rather than magic numbers. - (__pthread_create): Ditto. - (__pthread_cleanup): Ditto. - (__pthread_attr_init): Ditto. - (__pthread_attr_getinheritsched): Ditto. - (__pthread_attr_getschedparam): Ditto. - (__pthread_attr_getschedpolicy): Ditto. - (__pthread_attr_getscope): Ditto. - (__pthread_attr_setdetachstate): Ditto. - (__pthread_attr_getdetachstate): Ditto. - (__pthread_attr_setinheritsched): Ditto. - (__pthread_attr_setschedparam): Ditto. - (__pthread_attr_setschedpolicy): Ditto. - (__pthread_attr_setscope): Ditto. - (__pthread_attr_setstacksize): Ditto. - (__pthread_attr_getstacksize): Ditto. - (__pthread_attr_destroy): Ditto. - (__pthread_join): Ditto. - (__pthread_detach): Ditto. - (__pthread_suspend): Ditto. - (__pthread_continue): Ditto. - (__pthread_getschedparam): Ditto. - (__pthread_getsequence_np): Ditto. - (__pthread_key_create): Ditto. - (__pthread_key_delete): Ditto. - (__pthread_setschedparam): Ditto. - (__pthread_setspecific): Ditto. - (__pthread_getspecific): Ditto. - (__pthread_cond_destroy): Ditto. - (__pthread_cond_init): Ditto. - (__pthread_cond_broadcast): Ditto. - (__pthread_cond_signal): Ditto. - (__pthread_condattr_init): Ditto. - (__pthread_condattr_getpshared): Ditto. - (__pthread_condattr_setpshared): Ditto. - (__pthread_condattr_destroy): Ditto. - (__pthread_kill): Ditto. - (__pthread_mutex_init): Ditto. - (__pthread_mutex_getprioceiling): Ditto. - (__pthread_mutex_lock): Ditto. - (__pthread_mutex_trylock): Ditto. - (__pthread_mutex_unlock): Ditto. - (__pthread_mutex_destroy): Ditto. - (__pthread_mutex_setprioceiling): Ditto. - (__pthread_mutexattr_getprotocol): Ditto. - (__pthread_mutexattr_getpshared): Ditto. - (__pthread_mutexattr_gettype): Ditto. - (__pthread_mutexattr_init): Ditto. - (__pthread_mutexattr_destroy): Ditto. - (__pthread_mutexattr_setprotocol): Ditto. - (__pthread_mutexattr_setprioceiling): Ditto. - (__pthread_mutexattr_getprioceiling): Ditto. - (__pthread_mutexattr_setpshared): Ditto. - (__pthread_mutexattr_settype): Ditto. - (__sem_init): Ditto. - (__sem_destroy): Ditto. - (__sem_wait): Ditto. - (__sem_trywait): Ditto. - (__sem_post): Ditto. - (__pthread_cond_dowait): New function, contains core logic from - __pthread_cond_wait and __pthread_cond_timedwait. Decrement (*cond)->waiting - before reentering the cond access mutex to allow detection of lost signals. - (__pthread_cond_timedwait): Rename to pthread_cond_timedwait, and call - __pthread_cond_dowait after calculating the wait length. - (__pthread_cond_wait): Rename to pthread_cond_wait, and call - __pthread_cond_dowait. - * thread.h: New enum for use with verifyable_object_isvalid. - Remove the extern exporting of __pthread_cond_timedwait and __pthread_cond_wait. - -Fri Sep 28 21:18:50 2001 Christopher Faylor - - * pipe.cc (fhandler_pipe::fixup_after_fork): New method. - * fhandler.h (fhandler_pipe::fixup_after_fork): Declare new method. - -Fri Sep 28 03:23:04 2001 Christopher Faylor - - * passwd.cc (read_etc_passwd): Bother with unlocking when not - in cygwin initialization. - * grp.cc (read_etc_group): Ditto. - -Fri Sep 28 02:57:03 2001 Christopher Faylor - - * passwd.cc (read_etc_passwd): Don't bother with locking when - in cygwin initialization since there is only one thread. - * grp.cc (read_etc_group): Ditto. - -Fri Sep 28 01:50:09 2001 Christopher Faylor - - * pipe.cc (fhandler_pipe::hit_eof): Return correct value when there is - no EOF event available. - -Sat Sep 28 00:34:00 2001 Corinna Vinschen - - * mmap.cc (mmap): Move setting the access after evaluating fd. - Remove useless comment. Explain copy-on-write problem of 9x - more detailed. Don't set access to FILE_MAP_COPY on 9x only - when anonymous mapping is requested. - (fhandler_disk_file::mmap): Remove useless device check. - Add debug output. - -Fri Sep 27 07:35:00 2001 Robert Collins - - * Makefile.in: Only stamp winver_stamp on success. - -Wed Sep 26 16:02:35 2001 Christopher Faylor - - * select.cc (peek_pipe): REALLY only grab mutex when we actually got - something from the pipe. - -Tue Sep 25 21:25:00 2001 Robert Collins - - * thread.cc (pthread_cond::BroadCast): Use address with verifyable_object_isvalid(). - (pthread_cond::Signal): Ditto. - (__pthread_create): Ditto. - (__pthread_cleanup): Ditto. - (__pthread_attr_init): Ditto. - (__pthread_attr_getinheritsched): Ditto. - (__pthread_attr_getschedparam): Ditto. - (__pthread_attr_getschedpolicy): Ditto. - (__pthread_attr_getscope): Ditto. - (__pthread_attr_setdetachstate): Ditto. - (__pthread_attr_getdetachstate): Ditto. - (__pthread_attr_setinheritsched): Ditto. - (__pthread_attr_setschedparam): Ditto. - (__pthread_attr_setschedpolicy): Ditto. - (__pthread_attr_setscope): Ditto. - (__pthread_attr_setstacksize): Ditto. - (__pthread_attr_getstacksize): Ditto. - (__pthread_attr_destroy): Ditto. - (__pthread_join): Ditto. - (__pthread_detach): Ditto. - (__pthread_suspend): Ditto. - (__pthread_continue): Ditto. - (__pthread_getschedparam): Ditto. - (__pthread_getsequence_np): Ditto. - (__pthread_key_create): Ditto. - (__pthread_key_delete): Ditto. - (__pthread_setschedparam): Ditto. - (__pthread_setspecific): Ditto. - (__pthread_getspecific): Ditto. - (__pthread_cond_destroy): Ditto. - (__pthread_cond_init): Ditto. - (__pthread_cond_broadcast): Ditto. - (__pthread_cond_signal): Ditto. - (__pthread_cond_timedwait): Ditto. - (__pthread_cond_wait): Ditto. - (__pthread_condattr_init): Ditto. - (__pthread_condattr_getpshared): Ditto. - (__pthread_condattr_setpshared): Ditto. - (__pthread_condattr_destroy): Ditto. - (__pthread_kill): Ditto. - (__pthread_mutex_init): Ditto. - (__pthread_mutex_getprioceiling): Ditto. - (__pthread_mutex_lock): Ditto. - (__pthread_mutex_trylock): Ditto. - (__pthread_mutex_unlock): Ditto. - (__pthread_mutex_destroy): Ditto. - (__pthread_mutex_setprioceiling): Ditto. - (__pthread_mutexattr_getprotocol): Ditto. - (__pthread_mutexattr_getpshared): Ditto. - (__pthread_mutexattr_gettype): Ditto. - (__pthread_mutexattr_init): Ditto. - (__pthread_mutexattr_destroy): Ditto. - (__pthread_mutexattr_setprotocol): Ditto. - (__pthread_mutexattr_setprioceiling): Ditto. - (__pthread_mutexattr_getprioceiling): Ditto. - (__pthread_mutexattr_setpshared): Ditto. - (__pthread_mutexattr_settype): Ditto. - (__sem_init): Ditto. - (__sem_destroy): Ditto. - (__sem_wait): Ditto. - (__sem_trywait): Ditto. - (__sem_post): Ditto. - (verifyable_object_isvalid): Recieve a pointer to a pointer for verification. - (__pthread_mutexattr_getprotocol): Fix typo in magic number. - (__pthread_mutexattr_getpshared): Ditto. - (__pthread_mutexattr_gettype): Ditto. - * thread.h (verifyable_object_isvalid): Change prototype to recieve a pointer to a - pointer for verification. - * include/pthread.h: Fix typo for __cleanup_routine_type typedef. (Contrib from Net). - -Tue Sep 25 02:09:42 2001 Christopher Faylor - - * select.cc (fhandler_tty_common::ready_for_read): Rewrite to correctly - call peek_pipe. - -Mon Sep 24 18:46:39 2001 Christopher Faylor - - * select.cc (peek_pipe): Only grab mutex when we actually got something - from the pipe. - -Mon Sep 24 17:41:03 2001 Christopher Faylor - - * fhandler.h (fhandler_pipe::hit_eof): New method. - (writepipe_exists): New class element. - (orig_pid): Ditto. - (id): Ditto. - (is_slow): Eliminate. - * pipe.cc (fhandler_pipe::set_close_on_exec): Set inheritance on - writepipe_exists, if it exists. - (fhandler_pipe::hit_eof): New method, modelled after tty. - (fhandler_pipe::dup): Duplicate writepipe_exists, if it exists. - (make_pipe): Set up a dummy event for pipes on windows 9x. The - nonexistence of this event means that the write side of the - pipe has closed. - (_dup): Move to syscalls.cc - (_dup2): Ditto. - - * dtable.cc (dtable::build_fhandler): Fill out set_names here, if - appropriate. - * syscalls.cc (_open): Call set_names in build_fhandler. - -Sun Sep 23 16:55:00 2001 Corinna Vinschen - - * syscalls.cc (_open): Set name in fhandler object after successful - creation. - (stat_dev): Set device type to block device in FH_FLOPPY case. - -Sun Sep 23 11:15:00 2001 Corinna Vinschen - - * dtable.cc (dtable::build_fhandler): Initialize unit when using - optional path_conv argument. - -Sat Sep 22 17:33:45 2001 Christopher Faylor - Corinna Vinschen - - * dtable.cc (dtable::build_fhandler): Accept an optional path_conv - argument. If available, use this to calculate path name and device - number. - * dtable.h (dtable): Reflect above change. - * fhandler.h (fhandler_base): Declare virtual method which accepts - path_conv rather than path string as first argument. - * fhandler.cc (fhandler_base::open): Define above new method. - * syscalls.cc (_open): Set aside a path_conv variable for use in - build_fhandler and subsequent call to open. - -Sat Sep 22 12:44:57 2001 Christopher Faylor - - * exceptions.cc (setup_handler): Always relinquish lock after we've - interrupted. - * fhandler.cc: Move pipe methods to pipe.cc. - * fhandler.h (fhandler_pipe): Add new methods. - * fork.cc (sync_with_parent): Make error messages more informative. - * pipe.cc (fhandler_pipe::fhandler_pipe): Move here from fhandler.cc. - (fhandler_pipe::lseek): Ditto. - (fhandler_pipe::set_close_on_exec): New method. - (fhandler_pipe::read): Ditto. - (fhandler_pipe::close): Ditto. - (fhandler_pipe::dup): Ditto. - (make_pipe): Create the guard mutex on the read side of the pipe. - * select.cc (peek_pipe): Use guard_mutex to discover if we have the - right to read on this pipe. - (fhandler_pipe::readh_for_read): Pass the read pipe guard mutex to - peek_pipe. - * syscalls.cc (_read): Always detect signal catchers, for now. - - * debug.cc (makethread): Eliminate hack to make thread inheritable. - * sigproc.cc (subproc_init): Don't use hack to make thread inheritable. - -Thu Sep 20 16:48:44 2001 Christopher Faylor - - * fhandler.cc (fhandler_base::set_inheritance): Just use - DUPLICATE_CLOSE_SOURCE to change inheritance. Eliminate all other - logic dealing with closed handles. - * fhandler.h (fhandler_base::set_inheritance): Reflect above change. - * fhandler_tty.cc (fhandler_tty_common::set_close_on_exec): Ditto. - -Thu Sep 20 13:34:00 2001 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::fixup_after_exec): Close - socket only when not using Winsock2. - -Thu Sep 20 13:20:00 2001 Corinna Vinschen - - * fhandler.h (fhandler_socket::fixup_after_exec): Remove inline - implementation. - (fhandler_dev_raw::fixup_after_exec): Ditto. - * fhandler_raw.cc (fhandler_dev_raw::fixup_after_fork): Don't - duplicate buffer on fork to avoid memory leak. - (fhandler_dev_raw::fixup_after_exec): New implementation equal to - former fixup_after_fork() implementation. - * fhandler_socket.cc (fhandler_socket::fixup_after_fork): Do - nothing when not using Winsock2. - (fhandler_socket::fixup_after_exec): New implementation. - (fhandler_socket::set_close_on_exec): Never call set_inheritance(). - -Thu Sep 20 9:55:00 2001 Corinna Vinschen - - * fhandler.cc (fhandler_base::set_inheritance): If available, - use SetHandleInformation() to set inheritance. - * wincap.cc: Set flag has_set_handle_information_on_console_handles - appropriately. - * wincap.h: Add flag has_set_handle_information_on_console_handles. - -Wed Sep 19 12:24:09 2001 Christopher Faylor - - * lib/getopt.c (__progname): Don't declare if not compiling for cygwin. - -Wed Sep 19 18:07:00 2001 Corinna Vinschen - - * lib/getopt.c (getopt_long): Avoid compiler warning. - -Wed Sep 19 11:52:42 2001 Christopher Faylor - - * lib/getopt.c: Use __progname==__argv[0] when not compiling for cygwin. - - * scandir.cc (scandir): Use correct default when compar == NULL. - -Wed Sep 19 17:49:00 2001 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::fhandler_socket): Revert - memory allocation to use cmalloc again. - -Tue Sep 18 21:04:26 2001 Christopher Faylor - - * cygwin.din (__argv): Export. - (__argc): Ditto. - (__progname): Ditto. - * include/getopt.h (getopt_long): constify arguments. - * lib/getopt.c: Import new file from NetBSD. - -Tue Sep 18 18:21:00 2001 Corinna Vinschen - - * mmap.cc (mmap): Don't reuse anonymous memory in MAP_FIXED case. - -Mon Sep 17 17:29:25 2001 Christopher Faylor - - * include/io.h: Add access declaration. - -Mon Sep 17 14:04:27 2001 Christopher Faylor - - * syscalls.cc (rmdir): Set cwd to some other location if attempting to - rmdir current working directory. - -Sun Sep 16 23:04:31 2001 Christopher Faylor - - * dtable.h (not_open): Assure inline. - * fhandler.h (operator []): Make const. - -Sun Sep 16 23:02:57 2001 Robert Collins - - * sync.cc (muto::~muto): Fix typo which stopped muto event handle from - ever being closed. - -2001-09-16 Egor Duda - - * path.cc (symlink): Check arguments for validity. - (getcwd): Ditto. - * syscalls.cc (ftruncate): Ditto. - * times.cc (times): Ditto. - * uname.cc (uname): Ditto. - -Sat Sep 15 22:54:49 2001 Christopher Faylor - - * net.cc (dup_servent_ptr): Detect old Windows 95 misaligned structure - and realign appropriately. - -Sat Sep 15 00:28:40 2001 Christopher Faylor - - * Makefile.in: Generate libcygwin.a during the link pass rather than as - a separate dlltool step. - * dcrt0.cc (_dll_crt0): pppid_handle could be NULL. Don't close it if - so. - -Fri Sep 14 20:48:18 2001 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Create vfork main storage here so that it can - be queried in waitsig later. - * sigproc.cc (wait_sig): Don't deliver a signal if in a vfork. - * sigproc.h (sigframe::init): New method. - (sigframe): Use init. - * perthread.h: Declare main_vfork. - * fork.cc (vfork): Deliver all signals on parent return from vfork. - -Fri Sep 14 10:21:00 2001 Corinna Vinschen - - * dcrt0.cc (_dll_crt0()): Don't call wincap.init() here. - -Fri Sep 14 00:37:54 2001 Christopher Faylor - - * fork.cc (vfork): Avoid recursive vforks. - -Fri Sep 14 00:18:52 2001 Christopher Faylor - - * fhandler.h (fhandler_pipe::is_slow): Return true only if pipes are - reliable (i.e., not Win9x). - * wincap.cc: Make statics NO_COPY to avoid fork overhead. - -Thu Sep 13 23:01:00 2001 Christopher Faylor - - * grp.cc (read_etc_group): Just reuse group_buf storage for subsequent - reread of /etc/group. - * passwd.cc (read_etc_passwd): Just reuse passwd_buf storage for - subsequent reread of /etc/passwd. - -Thu Sep 13 20:46:05 2001 Christopher Faylor - - * cygheap.cc (dup_now): New function. - (cygheap_setup_for_child): Accept new argument controlling whether to - delay copying of cygheap to shared memory region. - (cygheap_setup_for_child_cleanup): Accept new arguments controlling - whether to copy cygheap at this point. - * cygheap.h: Reflect above changes. - * fork.cc (fork_parent): Break copying of cygheap into two parts when - fork_fixup is required so that the child can see the parent's changes. - (vfork): Do stack cleanup prior to forcing a fork error. - * spawn.cc (spawn_guts): Ditto. - -Thu Sep 13 17:14:59 2001 Christopher Faylor - - * cygheap.cc (ccalloc): Pass correct length to creturn so that - cygheap_max is correctly calculated. - -Wed Sep 12 21:06:38 2001 Christopher Faylor - - * sync.cc (muto::acquire): Fix while/if typo. - -Wed Sep 12 23:06:00 2001 Corinna Vinschen - - * wincap.cc (wincapc::init): Simplify W2K/XP case. - -Wed Sep 12 23:02:00 2001 Corinna Vinschen - - * wincap.cc (wincapc::init): Set os name to "NT" on XP, too. - -Wed Sep 12 19:00:00 2001 Corinna Vinschen - - * Makefile.in: Build wincap.o. - * wincap.cc: New file. - * wincap.h: Ditto. - * autoload.cc: Add dynamic load statement for `CreateHardLinkA'. - * dcrt0.cc (os_being_run): Eliminated. - (osname): Ditto. - (iswinnt): Ditto. - (set_os_type): Ditto. - (dll_crt0_1): Call wincap.init() instead of set_os_type(). - (_dll_crt0): Ditto. - * environ.cc (set_chunksize): New function. - (parse_thing): `forkchunk' setting now invokes function `set_chunksize'. - * fork.cc (chunksize): Eliminated. Moved to be member of wincap. - * host_dependent.h: Removed. - * syscalls.cc (_link): Try using `CreateHardLinkA' first, if available. - * cygheap.cc, dcrt0.cc, delqueue.cc, dir.cc, - environ.cc, fhandler.cc, fhandler.h, fhandler_console.cc, - fhandler_mem.cc, fork.cc, mmap.cc, net.cc, pinfo.cc, pinfo.h, - security.cc, syscalls.cc, sysconf.cc, syslog.cc, thread.cc, - times.cc, tty.cc, uinfo.cc, uname.cc, winsup.h: Use new wincap - capability check throughout. - * winsup.h: Include wincap.h. Eliminate extern declarations of - `os_being_run' and `iswinnt'. Eliminate `os_type" definition. - * include/cygwin/version.h: Bump version to 1.3.4. - -Wed Sep 12 01:03:36 2001 Christopher Faylor - - * exceptions.cc (call_signal_handler_now): Add additional guard against - inappropriately calling signal handler. - * syscalls.cc (_read): Reset errno if not exiting due to signal. - -Wed Sep 12 13:03:00 2001 Robert Collins - - * autoload.cc (LoadDLLfuncEx): Auto load TryEnterCriticalSection - it's - an NT only call. - * thread.cc (pthread_cond::TimedWait): Use critical sections for NT. - (pthread_cond::fixup_after_fork): Don't detect bad apps. - (pthread_mutex::pthread_mutex): Use critical sections for NT. - (pthread_mutex::~pthread_mutex): Ditto. - (pthread_mutex::Lock): Ditto. - (pthread_mutex::TryLock): Ditto. - (pthread_mutex::UnLock): Ditto. - (pthread_mutex::fixup_after_fork): Ditto. Also do not detect bad apps. - (__pthread_mutex_trylock): Move WIN32 specific test into the class - method. - (__pthread_mutex_destroy): Prevent dereferencing passed pointer without - valid address. - * thread.h (pthread_mutex): Use critical sections for NT. - -Tue Sep 11 21:55:37 2001 Christopher Faylor - - * sigproc.h (sigframe::unregister): Return true/false whether this - frame is capable of responding to signals. - * exceptions.cc (sigframe::call_signal_handler): Don't call signal - handler if it is not armed for this thread. - -Tue Sep 11 11:23:10 2001 Christopher Faylor - - * cygwin.din: Remove cygwin_getshared. - * shared.cc: Ditto. - * include/cygwin/version.h: Bump API minor number. - -Tue Sep 11 11:14:11 2001 Dmitry Timoshkov - - * dtable.cc (dtable::build_fhandler): Fix incorrect test for socket. - -Tue Sep 11 21:22:00 2001 Robert Collins - - * thread.cc (pthread_cond::~pthread_cond): Fix incorrect use of - InterlockExchangePointer. - (pthread_mutex::~pthread_mutex): Ditto. - (semaphore::~semaphore): Ditto. - -Tue Sep 11 18:15:00 2001 Robert Collins - - * dcrt0.cc (cygwin_finished_initializing): Copy _mtinterf on fork. - * fork.cc (fork_child): Fixup thread-related structures after fork. - * thread.cc (MTinterface::Init): Initialise the new mutex, condition - and semaphore lists. - (MTinterface::fixup_after_fork): Iterate through each list and fixup - the objects. - (pthread_cond::pthread_cond): Add this to the condition list. - (pthread_cond::~pthread_cond): Remove this from the condition list. - (pthread_cond::fixup_after_fork): Recreate as best we can the pre-fork - state. - (pthread_mutex::pthread_mutex): Add this to the mutex list. - (pthread_mutex::~pthread_mutex): Remove this from the mutex list. - (pthread_mutex::fixup_after_fork): Recreate as best we can the pre-fork - state. - (semaphore::semaphore): Store the initial value, and add this to the - semaphore list. - (semaphore::~semaphore): Remove this from the semaphore list. - (semaphore::Post): Increment the current semaphore value. - (semaphore::TryWait): Decrement the current semaphore value. - (semaphore::Wait): Ditto. - (semaphore::fixup_after_fork): Recreate the pre-fork state as best we - can. - * thread.h (pthread_mutex): New members to allow fixup_after_fork. - (pthread_cond): Ditto. - (semaphore): Ditto. - (MTinterface): New list heads for tracking conds and semaphores. - -Sun Sep 9 22:11:27 2001 Christopher Faylor - - * dtable.cc (dtable::fixup_after_fork): Use SetStdHandle appropriately - on inherited fds. - -Sun Sep 9 20:09:11 2001 Christopher Faylor - - * sigproc.cc (NZOMBIES): Reduce substantially to minimize memory use. - -Mon Sep 10 08:28:00 2001 Robert Collins - - * thread.h (MT_Interface): Remove pshared mutex array. Add a - threadsafe list for mutex tracking (for fixup after fork). - * thread.cc (MTInterface::Init): Remove pshared mutex array. - (pthread_mutex::pthread_mutex): Remove pshared mutex functionality. - Fail with EINVAL on attempts to use pshared functionality. - (__pthread_mutex_getpshared): Remove. - (__pthread_cond_timedwait): Remove pshared mutex functionality. - (__pthread_cond_wait): Ditto. - (__pthread_mutex_init): Ditto. - (__pthread_mutex_getprioceiling): Ditto. - (__pthread_mutex_lock): Ditto. - (__pthread_mutex_trylock): Ditto. - (__pthread_mutex_unlock): Ditto. - (__pthread_mutex_destroy): Ditto. - (__pthread_mutex_setprioceiling): Ditto. - (__pthread_mutexattr_setpshared): Ditto. - -Sun Sep 9 23:09:00 2001 Corinna Vinschen - - * pwdgrp.h (pwdgrp_check::set_last_modified): Call GetFileTime() - instead of GetFileInformationByHandle(). - -Sun Sep 9 15:59:53 2001 Christopher Faylor - - * heap.h (inheap): Rewrite macro to accommodate removal of brk macros - below. - -Sun Sep 9 15:02:44 2001 Christopher Faylor - - * cygheap.cc (cygheap_fixup_in_child): Clear cygheap->base so that heap - is not forced to start at the same place in execed process. - * heap.cc: Remove brk* macros for clarity throughout. - * heap.h: Ditto. - * shared.cc (shared_info::initialize): Move heap_chunk test into - heap_chunk_size(). - (heap_chunk_size): Check for chunk size here. Don't go to registry if - heap_chunk_in_mb is already set. - - * smallprint.c (console_printf): Add Windows 95 concessions. - -Sun Sep 9 13:01:06 2001 Christopher Faylor - - * child_info.h (PROC_MAGIC): Bump magic number. - -Sun Sep 9 18:36:00 2001 Corinna Vinschen - Christopher Faylor - - * cygheap.cc (init_cygheap::etc_changed): New method to signal - a change in /etc. - * cygheap.h (struct init_cygheap): Add member `etc_changed_h' - and method `etc_changed'. - * grp.cc (enum grp_state): Eliminate. - (class grp_check): Ditto. - (group_state): Define as `class pwdgrp_check'. - (parse_grp): Remeber path and modification time of /etc/group file. - * passwd.cc (enum_pwd_state): Eliminate. - (class pwd_check): Ditto. - (passwd_state): Define as `class pwdgrp_check'. - (read_etc_passwd): Remember path and modification time of /etc/passwd - file. - * pwdgrp.h: New file. - (enum pwdgrp_state): Substitutes `pwd_state' and `grp_state'. - (class pwdgrp_check): Substitutes `pwd_check' and `grp_check'. - -Sun Sep 9 14:31:00 2001 Corinna Vinschen - - * include/cygwin/version.h: Bump API minor version to 45 according - to adding the gamm*_r functions. - -Sat Sep 8 23:32:18 2001 Christopher Faylor - - * fork.cc (fork_parent): Stop malloc activity while fork is in control - of the heap. - * sigproc.cc (NZOMBIES): Rename from ZOMBIEMAX for clarity. - (zombies): Revert to original behavior. Allocating zombie array - resulted in performance hit. - * winsup.h: Declare malloc lock routines. - -Fri Sep 7 21:35:35 2001 Christopher Faylor - - * cygwin.din: Add gamm*_r function exports. - -Fri Sep 7 17:11:11 2001 Christopher Faylor - - * cygheap.h (init_cygheap): Move heap pointers here. - * include/sys/cygwin.h (perprocess): Remove heap pointers. - * dcrt0.cc (__cygwin_user_data): Reflect obsolete perprocess stuff. - (_dll_crt0): Don't initialize heap pointers. - (cygwin_dll_init): Ditto. - (release_upto): Use heap pointers from cygheap. - * heap.h: Ditto. - * fork.cc (fork_parent): Ditto. Don't set heap pointers in ch. - (fork_child): Remove obsolete sigproc_fixup_after_fork. - * shared.cc (memory_init): Reorganize so that cygheap initialization is - called prior to regular heap since regular heap uses cygheap now. - * sigproc.cc (proc_subproc): Eliminate zombies allocation. - (sigproc_init): Move zombies alloation here. Don't free up array on - fork, just reuse it. - (sigproc_fixup_after_fork): Eliminate. - * sigproc.h: Ditto. - * include/cygwin/version.h: Reflect change to perprocess structure. - -Fri Sep 7 10:53:34 2001 Jason Tishler - - * poll.cc (poll): Change implementation to only call select() when no - invalid file descriptors are specified. - -Fri Sep 7 10:27:00 2001 Corinna Vinschen - - * include/limits.h: Define PIPE_BUF. - * syscalls.cc (fpathconf): Use PIPE_BUF instead of numerical constant. - (pathconf): Ditto. - -Thu Sep 6 20:04:05 2001 Christopher Faylor - - * fhandler_socket.cc (fhandler_socket::fhandler_socket): Ensure that - prot_info_ptr is zeroed for later use. - -Thu Sep 6 14:03:49 2001 Christopher Faylor - - * cygheap.cc (cygheap_fixup_in_child): Don't consider a NULL bucket as - a candidate for deletion. It is actually the end of a linked list - chain. - - * exceptions.cc (open_stackdumpfile): Default to "unknown" program name - if myself->progname hasn't been filled out yet. - -Thu Sep 6 01:16:44 2001 Christopher Faylor - - Move appropriate variables to NO_COPY segment, throughout. - -Thu Sep 6 00:40:35 2001 Christopher Faylor - - Remove initialization of static or global values to zero, throughout. - This just needlessly grows the size of the DLL. - * tty.cc (tty::alive): Make inuse handle non-inheriting on open, just - for thread safety. - -Wed Sep 5 23:36:03 2001 Christopher Faylor - - * cygheap.h (init_cygheap): Move bucket array here from cygheap.cc. - * cygheap.cc: Throughout use bucket array from cygheap. - - * sigproc.cc (proc_subproc): Dynamically allocate zombie buffer to save - DLL space. - (sigproc_fixup_after_fork): Free zombie array after a fork. - * sigproc.h (sigproc_fixup_after_fork): Declare. - -2001-09-06 Egor Duda - - * dir.cc (mkdir): Expand buffer for security descriptor to 4K to avoid - stack corruption. - * fhandler.cc (fhandler_base::open): Ditto. - * path.cc (symlink): Ditto. - -Wed Sep 5 21:35:00 2001 Corinna Vinschen - - * winver.rc: Change copyright to include 2001. - -Wed Sep 5 12:12:00 2001 Corinna Vinschen - - * fhandler_floppy.cc (fhandler_floppy::lseek): Remove iswinnt check. - -Wed Sep 5 11:34:00 2001 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::close): Change 2MSL value - according to MSDN. - -Wed Sep 5 10:14:00 2001 Corinna Vinschen - - * net.cc (cygwin_connect): Add WSAEALREADY and WSAEINVAL handling - for non-blocking sockets. - -Tue Sep 4 22:42:13 2001 Christopher Faylor - - * exceptions.cc (ctrl_c_handler): Only send SIGINT when we have a - controlling terminal and we are the head of the process group. - -Tue Sep 4 16:48:14 2001 Christopher Faylor - - * thread.cc (InterlockedExchangePointer): Don't define if it already - exists. - -Tue Sep 4 22:14:00 2001 Corinna Vinschen - - * uname.cc (uname): Eliminate os specific retrieving of x86 - processor type. - -2001-09-04 Kazuhiro Fujieda - - * fhandler_console.cc (fhandler_console::char_command): Save the cursor - position relative to the top of the window. - * fhandler_cc (fhandler_console::write): Ditto. - -Mon Sep 3 21:06:00 2001 Corinna Vinschen - - * dir.cc (opendir): Write version information to __d_dirent->d_version. - -Mon Sep 3 18:34:00 2001 Corinna Vinschen - - * cygwin.din: Add `dirfd'. - * dir.cc (dirfd): New function. - (opendir): Open a directory file descriptor and save it in - __d_dirent->d_fd. - (closedir): Close directory file descriptor. - * include/cygwin/version.h: Bump API minor version to 44. - -Sun Sep 2 22:09:31 2001 Christopher Faylor - - * child_info.h: Modify magic number. - * dcrt0.cc (_cygwin_testing): Define. - (_dll_crt0): Set _cygwin_testing if CYGWIN_TESTING environment variable - exists. Don't issue "conflicting versions" error if _cygwin_testing is - true. - * shared.cc (shared_name): Use _cygwin_testing global rather than - testing the environment. - * syscalls.cc (_write): Remove debugging info. - -Sat Sep 1 01:37:13 2001 Christopher Faylor - - * tty.cc (tty::create_inuse): Eliminate unneeded argument. - * tty.h: Reflect above change. - * fhandler_tty.cc: Reflect argument reduction in tty::create_inuse, - throughout. Always make inuse inheritable. - -Sat Sep 1 01:10:07 2001 Christopher Faylor - - * debug.cc (mark_closed): Rename from debug_mark_closed and make - static. - (setclexec_pid): New function for marking saved handle as - close-on-exec. - (delete_handle): New function. - (debug_fixup_after_fork): New function. - * debug.h: Declare new functions, remove obsolete ones. - * fork.cc (debug_fixup_after_fork): Call to cleanup close-on-exec - handles. - - * fhandler.cc (fhandler_disk_file::close): Minor reorg. - (fhandler_base::set_inheritance): Set flag appropriately for debugging - when close-on-exec so forked process can delete closed handles. - * tty.h (open_output_mutex): Eliminate unneeded argument. - (open_input_mutex): Ditto. - * fhandler_tty.cc (fhandler_tty_slave::open): reflect open_*_mutex - argument changes. - * fhandler.h (fhandler_socket): Make saw_shutdown_* functions type - bool. - * tty.cc (tty::get_event): Eliminate unneeded argument. - (tty::common_init): Reflect change to get_event. Events should always - be inherited. - -Fri Aug 31 21:39:00 2001 Corinna Vinschen - - * security.cc (create_token): Change initialization of `exp' to comply - with new LARGE_INTEGER definition in winnt.h. - -Fri Aug 31 13:58:51 2001 Christopher Faylor - - * cygwin.sc: Revert to previous NO_COPY behavior. - * winsup.h: Ditto. - * sigproc.cc: Ditto. - * autoload.cc: Ditto. - -Fri Aug 31 00:56:26 2001 Christopher Faylor - - * cygwin.sc: New file -- linker script for building cygwin DLL. - * Makefile.in: Use linker script to control location of cygheap. - * cygheap.cc (buckets): Make static. - (init_cheap): Remove special iswinnt handling. Allocate cygheap at a - fixed location. Display more info when allocation fails. - (cygheap_fixup_in_child): Try harder to move cygheap to correct - location. Display more info when allocation fails. - * fhandler.h (fhandler_socket): Add macros for tracking socket shutdown - state. - * net.cc (cygwin_shutdown): Set appropriate shutdown value for future - use. - * select.cc (select_stuff::cleanup): New method. - (cygwin_select): Call cleanup explicitly to avoid a race. - (select_stuff:~select_stuff): Call cleanup chain via cleanup method. - (fhandler_socket::select_read): Set *_ready when shutdown has been - called on the socket. - (fhandler_socket::select_write): Ditto. - (fhandler_socket::select_except): Ditto. - - * winsup.h: Move NO_COPY to "COMMON" section. - * autoload.cc (wsock_started): Avoid initializing NO_COPY value. - * sigproc.cc: Remove initialization from NO_COPY variables. - (sigproc_init): Initialize sig_loop_wait here, rather than via - initialization. - (subproc_init): Initialize proc_loop_wait here, rather than via - initialization. - -Thu Aug 30 10:19:00 2001 Christopher Faylor - - * select.cc (select_read): Add setting read_ready flag. - (select_write): Add setting write_ready flag. - -Wed Aug 29 00:40:42 2001 Christopher Faylor - - * path.cc (path_conv::check): Avoid splitting off leading '/' in path - component when building a symlink. - -Wed Aug 29 0:45:00 2001 Corinna Vinschen - - * resource.cc (getrlimit): Return actual values on RLIMIT_STACK. - -Tue Aug 28 16:37:17 2001 Christopher Faylor - - * dir.cc (rmdir): Report ENOENT when file doesn't exist rather than - ENOTDIR. - -Mon Aug 27 11:58:19 2001 Christopher Faylor - - * select.cc (cygwin_select): Ensure that arguments are zeroed on - timeout. - (select_stuff::wait): Ditto. - -2001-08-24 Kazuhiro Fujieda - - * syscalls.cc (check_tty_fds): New function. Check whether there is a - fd referring to pty slave. - (setsid): Don't detach console if the process has a pty slave. - -Fri Aug 24 8:54:00 2001 Corinna Vinschen - - * net.cc (free_addr_list): Add define for symmetry. - (free_hostent_ptr): Use free_addr_list to free h_addr_list element. - -Thu Aug 23 16:00:09 2001 Jason Tishler - - * net.cc (dup_addr_list): New static function. - (dup_hostent_ptr): Use dup_addr_list instead of dup_char_list in order - to handle embedded null characters. - -Wed Aug 22 22:23:14 2001 Christopher Faylor - - * dtable.cc (dtable::dup2): Allow extension of fd table by dup2. - * syscalls.cc: Minor code cleanup. - (fpathconf): Check for bad fd before doing anything else. - * termios.cc (tcsetattr): Don't convert to new termios if bad fd. - (tcgetattr): Minor debugging tweak. - -Wed Aug 22 23:41:00 2001 Corinna Vinschen - - * net.cc (cygwin_inet_ntoa): Rearrange previous patch to use - thread local buffer space when compiled thread safe. - (cygwin_getprotobyname): Ditto. - (cygwin_getprotobynumber): Ditto. - (cygwin_getservbyname): Ditto. - (cygwin_getservbyport): Ditto. - (cygwin_gethostbyname): Ditto. - (cygwin_gethostbyaddr): Ditto. Move near to cygwin_gethostbyname. - * thread.h (struct _winsup_t): Add pointers for above used buffer space. - * passwd.cc (getpwduid): Remove initializing passwd. - (setpwent): Ditto. - (endpwent): Ditto. - (setpassent): Ditto. - -Wed Aug 22 13:41:09 2001 Christopher Faylor - - * smallprint.c (console_printf): New function. - * dcrt0.cc (dll_crt0_1): Use console_printf for debugging output. - * debug.cc (debug_mark_closed): New function. - (close_handle): Use debug_mark_closed. - * debug.h: Declare new functions. - * dtable.cc (dtable::build_fhandler): Remove unneeded extern. - * spawn.cc: Cosmetic changes. - * winsup.h: Define NO_COPY for C files, too. Declare a global. - -Wed Aug 22 17:31:00 2001 Corinna Vinschen - - * net.cc (free_char_list): New static function. - (dup_char_list): Ditto. - (free_protoent_ptr): Ditto. - (dup_protoent_ptr): Ditto. - (free_servent_ptr): Ditto. - (dup_servent_ptr): Ditto. - (free_hostent_ptr): Ditto. - (dup_hostent_ptr): Ditto. - (cygwin_inet_ntoa): Use local static buffer to allow propagating of - the result to child processes. - (cygwin_getprotobyname): Ditto. - (cygwin_getprotobynumber): Ditto. - (cygwin_getservbyname): Ditto. - (cygwin_getservbyport): Ditto. - (cygwin_gethostbyname): Ditto. - (cygwin_gethostbyaddr): Ditto. - -Mon Aug 20 11:56:19 2001 Christopher Faylor - - * cygheap.cc (init_cheap): Allocate cygheap in shared memory for Windows NT. - -Thu Aug 16 09:38:59 2001 Jason Tishler - - * fhandler_socket.cc (fhandler_socket::create_secret_event): Relax - security of secret_event so AF_UNIX socket clients can connect to - servers even if running under a different user account. - (fhandler_socket::check_peer_secret_event): Ditto. - -Thu Aug 16 16:26:00 2001 Corinna Vinschen - - * resource.cc (getrlimit): Return getdtablesize () as current limit - on RLIMIT_NOFILE. - * syscalls.cc (getdtablesize): Return OPEN_MAX if current dtable size - is less than OPEN_MAX, the current dtable size otherwise. - * sysconf.cc (sysconf): Return getdtablesize () on _SC_OPEN_MAX. - -Thu Aug 16 16:17:00 2001 Corinna Vinschen - - * resource.cc (getrlimit): Return OPEN_MAX as current limit - on RLIMIT_NOFILE. - * syscalls.cc (getdtablesize): Return OPEN_MAX. - * sysconf.cc (sysconf): Return OPEN_MAX on _SC_OPEN_MAX. - * include/limits.h (OPEN_MAX): Define as 256. - -Wed Aug 15 12:43:00 2001 Corinna Vinschen - - * times.cc (utimes): Revert previous change. Just open the - file using FILE_WRITE_ATTRIBUTES instead of GENERIC_WRITE - on NT/W2K. - -Wed Aug 15 12:18:00 2001 Corinna Vinschen - - * security.cc (set_nt_attribute): Return always -1 in case of - a failure. - * times.cc (utimes): On NTFS with ntsec ON, change the file's - security descriptor temporarily to acquire write access if - opening the file failed. - -Wed Aug 15 9:42:00 2001 Corinna Vinschen - - * fhandler.cc (fhandler_base::is_nonblocking): New method. - (fhandler_base::set_nonblocking): Ditto. - * fhandler.h (fhandler_base): Declare new methods `is_nonblocking' and - `set_nonblocking'. - * fhandler_socket.cc (fhandler_socket::ioctl): Use `set_nonblocking'. - * fhandler_tty.cc (fhandler_pty_master::process_slave_output): - Use `is_nonblocking'. - (fhandler_tty_slave::read): Ditto. - (fhandler_tty_slave::ioctl): Use `set_nonblocking'. - (fhandler_pty_master::ioctl): Ditto. - * net.cc (cygwin_sendto): Fallback to winsock 1 functionality - in case of nonblocking IO. - (cygwin_recvfrom): Ditto. - (cygwin_recv): Ditto. - (cygwin_send): Ditto. - * syscalls.cc (_read): Use `is_nonblocking'. - -Tue Aug 14 11:05:26 2001 Christopher Faylor - - * include/cygwin/version.h: Bump API version. - -2001-08-14 Egor Duda - - * spawn.cc (spawn_guts): Enable appropriate privilege before - loading user's registry hive. - -Mon Aug 13 22:34:00 2001 Corinna Vinschen - - * fhandler.cc (fhandler_base::fcntl): Use new O_NONBLOCK_MASK define. - * fhandler.h: Move definitions of O_NOSYMLINK, O_DIROPEN and - OLD_O_NDELAY from winsup.h to here. Add O_NONBLOCK_MASK define. - * fhandler_socket.cc (fhandler_socket::close): Add hack to allow - a graceful shutdown even if shutdown() hasn't been called by the - application. Add debug output. - (fhandler_socket::ioctl): Set fhandler's NONBLOCK flag according - to FIONBIO setting. - (fhandler_socket::fcntl): Use new O_NONBLOCK_MASK define. Actually - set `request' before using it. - * fhandler_tty.cc: Use new O_NONBLOCK_MASK define throughout. - (fhandler_tty_slave::ioctl): Set fhandler's NONBLOCK flag according - to FIONBIO setting. - (fhandler_pty_master::ioctl): Ditto. - * net.cc (wsock_event::prepare): Compare WSACreateEvent return code - with `WSA_INVALID_EVENT' according to MSDN. - * syscalls.cc (_read): Use new O_NONBLOCK_MASK define. - -Wed Aug 8 15:24:59 2001 Christopher Faylor - - * include/wchar.h: Define __need_wint_t. - -Wed Aug 8 11:46:00 2001 Corinna Vinschen - - * security.cc (alloc_sd): Revert to setting inheritance attribute for - permissions given to directories. Never set inheritance on NULL ACE. - -Tue Aug 7 18:11:00 2001 Corinna Vinschen - - * security.cc (alloc_sd): Don't set FILE_DELETE_CHILD for group - if S_ISVTX attribute is given. - * dir.cc (mkdir): Allow immediate setting of S_ISUID, S_ISGID and - S_ISVTX attribute. - * syscalls.cc (_open): Ditto. - -Tue Aug 7 16:24:00 2001 Corinna Vinschen - - * dir.cc (mkdir): Set security attributes correctly for - CreateDirectoryA () call if ntsec is on. Don't call - set_file_attributes () then. - * fhandler.cc (fhandler_base::open): Ditto for CreateFileA () call. - * path.cc (symlink): Ditto. - * security.cc (set_security_attribute): New function. - * security.h: Add declaration for `allow_ntea' and - `set_security_attribute'. - -Tue Aug 7 10:54:00 2001 Corinna Vinschen - - * grp.cc (class grp_check): New class. Make `group_state' - a member of class grp_check. - (read_etc_group): Free former allocated memory on reread. - * passwd.cc (class pwd_check): New class Make `passwd_state' - a member of class pwd_check. - (read_etc_passwd): Free former allocated memory on reread. - -Tue Aug 7 01:13:58 2001 Christopher Faylor - - * fhandler_console.cc (get_tty_stuff): Don't initialize shared memory - console area if it is already initialized. - - * fhandler_termios.cc (fhandler_termios::tcsetpgrp): Augment debugging - info. - -Mon Aug 6 19:58:43 2001 Christopher Faylor - - * cygheap.cc (cygheap_root::set): Avoid treating '/' specially. - - * fhandler.cc (fhandler_base::fcntl): Only set specific O_NDELAY style - flag passed in from application. - * fhandler_socket.cc (fhandler_socket::fcntl): Ditto. - * fhandler.h: Set constant for future use. - * winsup.h: Define OLD_O_NDELAY only for old programs. - * include/cygwin/version.h: Define - CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK. - -Sat Aug 4 16:52:03 2001 Christopher Faylor - - Throughout, change check for running under Windows NT to 'iswinnt'. - * dcrt0.cc (set_os_type): Set 'iswinnt' appropriately. - * cygheap.cc (init_cheap): Revert to using VirtualAlloc for allocating - cygheap. - (cygheap_setup_for_child_cleanup): New function. Standard function to - call after calling CreateProcess to cleanup cygheap info passed to - child. - (cygheap_fixup_in_child): Copy cygheap from shared memory into - allocated space under Windows 9x or if can't relocate shared space - under NT. - * cygheap.h: Declare new function. - * spawn.cc (spawn_guts): Use cygheap_fixup_in_child. - * fork.cc (fork_parent): Ditto. - * winsup.h: Declare iswinnt. - -2001-08-04 Egor Duda - - * dtable.cc (dtable::release): Avoid messing with console when - closing socket. - -Fri Aug 3 14:02:00 2001 Corinna Vinschen - - * net.cc (cygwin_accept): Allow NULL peer and len parameters. - * include/cygwin/socket.h: Define socklen_t as int. - -Fri Aug 3 13:04:00 2001 Corinna Vinschen - - * path.cc (fchdir): Set the fhandler's path to absolute value to ensure - changing to the correct directory even if the fhandler originally - points to a relative path. - -Thu Aug 2 17:59:00 2001 Corinna Vinschen - - * security.cc (set_file_attribute): Clean up. Don't call - `set_nt_attribute' when ntsec isn't set. - -Sat Jul 28 22:30:55 2001 Christopher Faylor - - * dcrt0.cc (alloc_stack_hard_way): Make half-hearted attempt to deal - with growing stack under Windows 95. - -Fri Jul 27 12:36:07 2001 Christopher Faylor - - * Makefile.in: Add install-lib and install-headers. - -Fri Jul 27 12:28:12 2001 Christopher Faylor - - * cygwin.din: Export sys_errlist, sys_nerr. - * include/cygwin/version.h: Bump minor version number. - -Fri 27 Jul 2001 10:29:00 Corinna Vinschen - - * security.cc (get_user_primary_group): Fix compiler warning. - (alloc_sd): Add DELETE permission for user when S_IWUSR is given. - -Thu Jul 26 16:43:39 2001 Pieter de Visser - - * thread.cc (__pthread_equal): Invert return value so that true is - returned when threads are equal. - -Thu Jul 26 15:50:38 2001 Charles Wilson - Christopher Faylor - - * cygwin.din: Export __signgam. - * include/cygwin/version.h: Bump minor version number. - -Thu Jul 26 15:19:50 2001 Christopher Faylor - - Throughout, reorganize header file inclusion to put security.h prior to - fhandler.h. - * fhandler.h (fhandler_base::get_inheritance): New method. - * fhandler_socket.cc (fhandler_socket::create_secret_event): Use proper - close-on-exec inheritance when creating. - (fhandler_socket::check_peer_secret_event): Create handle as - non-inheritable. - -2001-07-25 Kazuhiro Fujieda - - * syscalls.cc (setsid): Detach process from its console if the current - controlling tty is the console and already closed. - * dtable.h (class dtable): Add members to count descriptors referring - to the console. - * dtable.cc (dtable::dec_console_fds): New function to detach process - from its console. - (dtable::release): Decrement the counter of console descriptors. - (dtable::build_fhandler): Increment it. - * exception.cc (ctrl_c_handler): Send SIGTERM to myself when catch - CTRL_SHUTDOWN_EVENT. - -Tue 24 Jul 2001 02:28:00 PM Trevor Forbes - - * thread.cc (verifyable_object_isvalid): Don't validate - PTHREAD_MUTEX_INITIALIZER pointer as it will cause an exception - in IsBadWritePtr() when running GDB. - -Wed 25 Jul 2001 23:46:00 Corinna Vinschen - - * localtime.c: Changed whole file to become C++ clean. Rename to - localtime.cc. - * localtime.cc (tzload): Preserve errno. - -Fri 20 Jul 2001 11:15:50 PM EDT Christopher Faylor - - * cygheap.cc (cygheap_fixup_in_child): Attempt Win95 workaround. - * dtable.cc (dtable::dup_worker): Add debugging output. - (dtable::vfork_child_dup): Correctly set close_on_exec. - * fhandler.cc (fhandler_base::fork_fixup): Don't mess with handle if - there is no need to get it from the parent. - * fhandler_tty.cc (fhandler_tty_common::close): Add debugging output. - -Fri 20 Jul 2001 09:15:00 Mark Bradshaw - - * dir.cc (readdir): Protect FindNextFileA against INVALID_HANDLE_VALUE. - -Wed 18 Jul 2001 01:00:47 PM EDT Christopher Faylor - - * cygheap.cc (_cmalloc): Use correct constants for size calculation. - * dcrt0.cc (dll_crt0_1): Move uid initialization earlier. - * fork.cc (fork_parent): Move cygheap_setup_in_child to just prior to - CreateProcess so that all contents of cygheap are copied. - * spawn.cc (spawn_guts): Ditto. - -Wed 18 Jul 2001 12:54:17 Corinna Vinschen - - * security.cc (get_user_groups): Call Net function with NULL server - name under specific error conditions. - (is_group_member): Ditto. - (get_user_local_groups): Ditto. - (get_user_primary_group): Ditto. - -Wed 18 Jul 2001 11:56:00 Corinna Vinschen - - * syscalls.cc (_unlink): Explicitly check for non-existant file. - -Tue 17 Jul 2001 10:19:00 Corinna Vinschen - - * delqueue.h: Remove obsolete file. - -Mon 16 Jul 2001 10:47:17 PM EDT Christopher Faylor - - * child_info.h: Bump magic number. - (class child_info): Add an element. - * cygheap.cc (init_cheap): Allocate cygwin heap in shared memory area. - (cygheap_fixup_in_child): Map cygwin heap, passed from parent via - shared memory into correct address. - (cygheap_setup_for_child): New function. - * cygheap.h: Declare new functions. - * dcrt0.cc (dll_crt0_1): Accommodate new cygheap_fixup_in_child - arguments. Avoid protecting subproc_ready unless it is spawn/nowait. - * fork.cc (fork_parent): Use new cygheap_setup_for_child function to - setup cygwin heap info. Close passed cygheap shared memory handle. - * spawn.cc (spawn_guts): Ditto. Also, reorganize to avoid - synchronization between parent and child in non-P_OVERLAY case. - * sigproc.cc (wait_sig): Only signal subproc_ready when execing. - -Mon 16 Jul 2001 15:21:00 Corinna Vinschen - - * grp.cc: Add missing Copyright date 2001. - -Mon 16 Jul 2001 00:11:00 Corinna Vinschen - - Change well_known_admin_sid to well_known_admins_sid throughout. - * sec_acl.cc (setacl): Never set DELETE permission. Set - FILE_DELETE_CHILD only on readable and executable directories. - * sec_helper.cc: Add constructor for `well_known_null_sid'. - * security.cc (get_nt_attribute): Set S_ISVTX for directories if - FILE_WRITE_DATA and FILE_EXECUTE but not FILE_DELETE_CHILD is set. - Add evaluation of S_ISVTX, S_ISGID and S_ISUID from NULL ACE. - (alloc_sd): Never set DELETE permission. Set FILE_DELETE_CHILD - only on readable and executable directories. - Add creation of NULL ACE for S_ISVTX, S_ISGID and S_ISUID permissions. - * security.h: Add extern declaration for `well_known_null_sid'. - -Fri 13 Jul 2001 08:08:49 PM EDT Christopher Faylor - - * syscalls.cc (stat_worker): Simplify previous change. - -Fri Jul 13 13:13:09 2001 Christopher Faylor - - * syscalls.cc (_unlink): Correct (?) logic which determines when - to report an access violation and when to queue file for eventual - deletion. - (stat_worker): Check for invalid buf argument. - -Tue Jul 10 23:01:00 2001 Corinna Vinschen - - * mmap.cc (fhandler_disk_file::mmap): Try to open file mappings - by a unified name when running under 9x/ME. If that failes, create - the file mapping using the unified name. - -Mon Jul 9 10:43:00 2001 Corinna Vinschen - - * uinfo.cc (internal_getlogin): Add pointer check. - -Mon Jul 9 10:05:00 2001 Corinna Vinschen - - * security.cc (alloc_sd): Don't set inheritance attribute for - permissions given to directories. - -Thu Jun 28 22:19:08 2001 Christopher Faylor - - * fhandler_dsp.cc (fhandler_dev_dsp::ioctl): Return 0 for success. - -Wed Jun 27 22:19:07 2001 Christopher Faylor - - * path.cc (path_conv::check): Add signal protection here since - retrieving info about remote shares can take some time. - -Wed Jun 27 23:30:00 2001 Robert Collins - Christopher Faylor - - Change check_null_empty_path* to check_null_empty_str* throughout. - * path.h (check_null_empty_str_errno): Convert to a function prototype. - * path.cc (check_null_empty_str): Move to miscfuncs.cc. - * miscfuncs.cc (check_null_empty_str_errno): New function. - (__check_null_invalid_struct): Ditto. - (__check_null_invalid_struct_errno): Ditto. - (check_null_empty_str): Change from VirtualQuery to IsBadWritePtr. - * thread.cc (check_valid_pointer): Ditto. - * resource.cc (getrlimit): Use check_null_invalid_struct macro for - checking validity of pointer. - (setrlimit): Ditto. - -Tue Jun 26 16:59:16 2001 Christopher Faylor - - * fhandler.cc (fhandler_disk_file::fstat): Don't rely on exactly 3 - characters being read for executable test since we could be checking - for less than that. - * syscalls.cc (stat_worker): Try opening the file the "correct" way - first so that #! processing can potentially happen. If that fails, - then use "query open" method. - - * spawn.cc (spawn_guts): Delay processing of signal until after we've - notified parent about reparenting. - -Tue Jun 26 10:47:24 2001 Christopher Faylor - - * mmap.cc: Clean up *ResourceLock calls throughout. - -Tue Jun 26 22:10:00 2001 Robert Collins rbtcollins@hotmail.com - - * thread.cc (pthread_cond::TimedWait): Check for WAIT_TIMEOUT as well - as WAIT_ABANDONED. - (__pthread_cond_timedwait): Calculate a relative wait from the abstime - parameter. - -Sun Jun 24 17:38:19 2001 Christopher Faylor - - * exceptions.cc (interrupt_setup): Move actions from setup_handler to - here. - (setup_handler): Move actions after a successful interrupt to - interrupt_setup. - * fork.cc (vfork): Augment debugging output. - * sigproc.cc (proc_subproc): Ditto. - * spawn.cc (spawn_guts): Ditto. Correctly fill out progname when spawn - NO_WAIT. Call signal handler when a signal arrives. - * sigproc.h: Declare a function. - -Fri Jun 22 16:50:00 2001 Corinna Vinschen - - * fhandler.h class fhandler_socket): Declare new method - `set_close_on_exec'. - * fhandler_socket.cc (fhandler_socket::set_close_on_exec): - New method. - -Fri Jun 22 16:12:00 2001 Corinna Vinschen - - * fhandler_tape.cc (fhandler_dev_tape::tape_erase): Set size - parameter to value expected by GetTapeParameters(). - -Thu Jun 21 22:01:39 2001 Marius Gedminas - - * fhandler_console.cc (fhandler_console::read): Detect AltGr more - robustly on WinNT. - -2001-06-22 Robert Collins - - * thread.cc (__pthread_cond_timedwait): Lock the waiting mutex before - the condition protect mutex to avoid deadlocking. (Found by Greg Smith). - (__pthread_cond_wait): Ditto. - -2001-06-30 Egor Duda - - * fhandler.cc (fhandler_base::open): Work around windows bug when - CreateFile() with dwDesiredAccess == 0 called on remote share returns - valid handle even if file doesn't exist. - -2001-06-20 Egor Duda - - * fhandler_socket.cc (fhandler_socket::signal_secret_event): New - function. - * fhandler.h: Declare it. - * fhandler_socket.cc (fhandler_socket::create_secret_event): Don't - signal secret event immediately. - (fhandler_socket::check_peer_secret_event): Do it after peer event - was opened. - * net.cc (cygwin_connect): Or if socket is non-blocking. - (cygwin_accept): Ditto. - -Mon Jun 18 17:09:25 2001 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_slave::init): Revert 2001-06-16 change. - - * fork.cc (fork_copy): Print more debugging info. - (fork_parent): Change order of arguments to accomdate buggy gcc. - (fork): Ditto. - -Sun Jun 17 18:54:46 2001 Christopher Faylor - - * syscalls.cc (_unlink): Reorganize to try harder to delete file with - DeleteFile and to recover more gracefully if FILE_FLAG_DELETE_ON_CLOSE - doesn't work properly. - -Sat Jun 16 13:06:49 2001 Christopher Faylor - - * exceptions.cc (sig_handle_tty_stop): Reset PID_STOPPED if not - actually stopping. - * fhandler_console.cc (fhandler_console::fixup_after_fork): Don't set - controlling terminal if just inheriting a handle. - (fhandler_console::fixup_after_exec): Ditto. - * fhandler_tty.cc (fhandler_tty_slave::init): Ditto. - * signal.cc (kill_worker): Set appropriate errno if proc_exists - determines that process does not really exist. - -Fri Jun 15 14:34:19 2001 Christopher Faylor - - * path.cc (path_conv::check): Deal more robustly with foo/ behavior. - -Fri Jun 15 11:15:00 2001 Corinna Vinschen - - * fhandler_tape.cc (fhandler_dev_tape::tape_status): Set size - parameter to value expected by GetTapeParameters(). - -Thu Jun 14 20:19:46 2001 Christopher Faylor - - * fhandler.cc (fhandler_disk_file::fstat): Properly set executable bits - for directory when !ntsec && !ntea. Also move common code prior to - call to get_attributes. - -Fri June 15 09:25:00 Robert Collins - - * thread.cc (pthread_cond::Signal): Release the condition access - variable correctly. - -2001-06-14 Egor Duda - - * fhandler.cc (fhandler_base::open): Set win32 access flags to 0, when - requested. - * fhandler.h: New status flag FH_QUERYOPEN. - (fhandler::get_query_open): New function. - (fhandler::set_query_open): Ditto. - * syscalls.cc (stat_worker): Request query-only open mode. - -2001-06-12 Egor Duda - - * environ.cc (set_file_api_mode): New function. Move setting - of file APIs mode (OEM/ANSI) here. - (codepage_init): From here. - * winsup.h (set_file_api_mode): Declare it. - * fork.cc (fork_child): Set file APIs mode in forkee. - -Mon Jun 11 14:19:49 2001 Christopher Faylor - - * pinfo.cc: Use autoloaded ToolHelp functions throughout for Win9x. - * autoload.cc: Autoload ToolHelp functions. - - * sigproc.cc (proc_subproc): Incorporate SIGCHLD == SIG_IGN special - handling of zombie processes. Ensure that zombie processes which are - at the end of the zombie array are properly cleaned up. - -Mon Jun 11 11:18:56 2001 Christopher Faylor - - * path.cc (chdir): Fix call to path_conv constructor so that it REALLY - doesn't check for the null/non-empty path. - -Sun Jun 10 23:34:09 2001 Christopher Faylor - - * path.cc (path_conv::update_fs_info): Don't consider remote drives to - be NTFS. Set root_dir before invoking GetDriveType (from Kazuhiro - Fujieda ). Eliminate extra checks for rootdir. - -Sun Jun 10 20:19:47 2001 Christopher Faylor - - * path.cc (chdir): Pre-check path for validity before eating trailing - space. Then, ensure that path_conv doesn't check the path for validity - again. - -Sun Jun 10 12:56:00 2001 Christopher Faylor - - * exceptions.cc (sigdelayed): Ensure that signal is cleared as - the last operation or suffer races. - * sigproc.cc (proc_subproc): Deal with zombie array overflow. - -Sun Jun 10 11:56:00 2001 Corinna Vinschen - - * cygwin.din: Add fchdir symbols. - * path.cc (chdir): Guard against invalid parameter. - (fchdir): New function. - * include/cygwin/version.h: Bump API minor version to 40. - * uinfo.cc (internal_getlogin): Remove unused variable. - -Sat Jun 9 23:20:00 2001 Corinna Vinschen - - * syscalls.cc (seteuid): Set environment variables USERNAME and - USERDOMAIN before impersonation to workaround a LookupAccountSid() - misbehaviour. - * uinfo.cc (internal_getlogin): Revert most of the previous change. - Don't set environment variables USERNAME and USERDOMAIN. That's - the job of seteuid() now. Try to get logon server from Lsa - only if logon server isn't already known. - -Thu Jun 7 15:54:32 2001 Robert Collins - - * thread.cc (pthread_cond::Broadcast): Don't print error messages on - invalid mutexs - user programs are allowed to call - pthread_cond_broadcast like that. - (__pthread_cond_timedwait): Initialise themutex properly. - (__pthread_cond_wait): Initialise themutex properly. - -Tue Jun 5 19:56:00 2001 Corinna Vinschen - - * fhandler_console.cc (fhandler_console::dup): Allocate space for - savebuf on Cygwin heap. - (fhandler_console::char_command): Ditto. Use correct values for size. - -2001-06-05 Egor Duda - - * security.h (NTWriteEA): Change prototype. - * ntea.cc (NTReadEA): Don't check for global ntea setting, now - it's caller responsibility. - (NTWriteEA): Ditto. - * security.cc (get_file_attribute): Read attribute from EA only - if 'ntea' is enabled. - (set_file_attribute): Ditto. - * path.h: (class path_conv): Add members to store file system - information. - (path_conv::get_drive_type): New function. - * syscalls.cc (stat_worker): Use it. - * path.cc (path_conv::update_fs_info): New functions. - (path_conv::check): Get file system information from device where - file resides. On NTFS, try to read symlink contents from EA. - (get_symlink_ea): New function. - (set_symlink_ea): Ditto. - (symlink): Store symlink in extended attribute, if possible. - -Tue Jun 5 11:18:00 2001 Corinna Vinschen - - * fhandler.cc (fhandler_disk_file::fstat): Always reset file position - to original value after checking for executable magic. - -Mon Jun 4 16:21:00 2001 Corinna Vinschen - - * cygheap.h (cygheap_user::cygheap_user): Initialize token to - INVALID_HANDLE_VALUE. - * uinfo.cc (uinfo_init): Close token handle if needed. - -Sun Jun 3 20:52:13 2001 Christopher Faylor - - * path.cc (normalize_posix_path): Revert .. check removed by previous - changes. - * cygheap.h: Temporarily declare path_prefix_p here. - -Mon Jun 4 0:14:00 2001 Corinna Vinschen - - * net.cc (wsock_event): Add destructor. - -Sun Jun 3 09:49:55 2001 Robert Collins - - * dlfcn.cc (dlclose): Do not call FreeLibrary if the symbol to close - was obtained by dlopen(NULL,...). - -Sat Jun 2 23:11:52 2001 Christopher Faylor - - * syscalls.cc (sleep): Try to be a little more accomodating of signal - arrival. Ensure that the signal handler is called. - -Sat Jun 2 14:07:28 2001 Christopher Faylor - - * cygheap.cc (cygheap_root::cygheap_root): Remove constructor. - (cygheap_root::~cygheap_root): Remove destructor. - (cygheap_root::operator =): Remove. - (cygheap_root::set): New method. - * cygheap.h (cygheap_root): Reflect above changes. Store root info in - mount-like structure. - (cygheap_root:posix_ok): New method. - (cygheap_root::ischroot_native): Ditto. - (cygheap_root::unchroot): Ditto. - (cygheap_root::exists): Ditto. - (cygheap_root::posix_length): Ditto. - (cygheap_root::posix_path): Ditto. - (cygheap_root::native_length): Ditto. - (cygheap_root::native_path): Ditto. - * dir.cc (opendir): Remove special chroot test. - * path.cc (path_prefix_p): Remove front end. - (normalize_posix_path): Reorganize chroot tests to accommodate new - convention of allowing paths using posix chroot prefix. - (path_conv::check): Pass a "already ran normalize" option to - conv_to_win32_path. Return if there is an error from this function. - (mount_info::conv_to_win32_path): Add extra argument. Don't call - normalize_posix_path if caller has already done so. Substitute chroot - setting, if any, for root translation. Add chroot checking to final - output step. - * shared_info (mount_info): Accommodate additional argument to - conv_to_win32_path. - * syscalls.cc (chroot): Store both normalized posix path and native - path in chroot. - -Fri Jun 1 10:57:19 2001 Christopher Faylor - - * path.cc (chdir): Really make sure that isspace gets only an unsigned - char. - -Fri Jun 1 13:45:00 2001 Corinna Vinschen - - * syscalls.cc (_rename): Handle the case that `foo' is renamed to - `bar' while `bar.lnk' is an existing shortcut-symlink. - -Thu May 31 15:57:57 2001 Christopher Faylor - - * fhandler.cc (fhandler_disk_file::fstat): Avoid clearing S_IFMT bits - since we've already pre-cleared everything anyway. - -Wed May 30 23:51:32 2001 Earnie Boyd - - * path.cc (chdir): Always send unsigned chars to isspace since newlib's - isspace doesn't deal well with "negative" chars. - -Wed May 30 23:51:32 2001 Christopher Faylor - - * fhandler.cc (fhandler_disk_file::open): Propagate remote status of - file garnered from path_conv. Move #! checking to fstat. - (fhandler_disk_file::fstat): Reorganize st_mode setting to eliminate - duplication. Move check for #! here from fhandler::open. - - * fhandler.h (fhandler_base::isremote): New method. - (fhandler_base::set_isremote): Ditto. - (fhandler_base::set_execable_p): Also record "don't care if executable - state". - (fhandler_base::dont_care_if_execable): New method. - * path.cc (path_conv::check): Clear new flags. Appropriately set - vol_flags, drive_type, and is_remote_drive. - * path.h: Add new flags and methods for manipulating them. - * syscalls.cc (_unlink): Use isremote() to determine if a path is - remote rather than calling GetDriveType. - (stat_worker): Ditto. - * security.cc (get_file_attribute): Or attribute with result of - NTReadEA to be consistent with get_nt_attribute. - -Tue May 29 19:02:00 2001 Corinna Vinschen - - * sec_helper.cc (cygsid::getfrompw): Change parameter to `const'. - (cygsid::getfromgr): Ditto. - * security.cc: Use `sys_mbstowcs' and `sys_wcstombs' throughout. - (extract_nt_dom_user): Try to get user and domain from SID in - pw->pw_gecos first. - * security.h (class cygsid): Change parameter of getfrompw() and - getfromgr() to `const'. - * uinfo.cc (internal_getlogin): Change order for evaluating user - information in winNT case. Drop usage of NetWkstaUserGetInfo(). - -Mon May 28 21:34:00 2001 Corinna Vinschen - - * shortcut.c (check_shortcut): Treat only Cygwin shortcuts as symlinks. - -Fri May 25 11:07:07 2001 Christopher Faylor - - * path.cc (symlink_info::check): Correctly set 'ext_tacked_on'. Use - this to determine if user specified 'foo.lnk' explicitly. Reorganize - slightly to get rid of one goto. - -Fri May 25 10:15:00 2001 Corinna Vinschen - - * path.cc (symlink_info::check): Add a check to return correctly - if incoming `*.lnk' file is not a symlink. - -Thu May 24 15:46:50 2001 Christopher Faylor - - * path.cc (slash_drive_prefix_p): Remove. - (mount_info::slash_drive_to_win32_path): Ditto. - (mount_info::conv_to_win32_path): Remove slash drive prefix check. - (mount_info::add_item): Ditto. - (mount_info::del_item): Ditto. - * shared_info.h (mount_info): Remove slash_drive_to_win32_path - declaration. - -Thu May 24 01:17:33 2001 Christopher Faylor - - * exceptions.cc (handle_exceptions): Bump repeat count for debugging - kick out. - - * fhandler.h (fhandler_dev_dsp): Add a fixup_after_exec. - * fhandler_dsp.cc (class Audio): Add TOT_BLOCK_SIZE to enum. - (operator new): New. - (bigwavebuffer): Declare using TOT_BLOCK_SIZE to avoid buffer overruns. - (Audio::Audio): Optimize slightly. - (fhandler_dev_dsp::open): Allocate s_audio using static buffer. - (fhandler_dev_dsp::fixup_after_exec): New function. Ditto. - -Wed May 23 17:45:00 2001 Corinna Vinschen - - * syscalls.cc (seteuid): Restrict overriding external provided - user tokens to ntsec. Don't test external tokens for primary - group to evaluate if it should be overridden. Restrict creating - internal tokens to ntsec. - -Wed May 23 10:11:00 2001 Corinna Vinschen - - * syscalls.cc (chown_worker): Don't check for ENOSYS. - -Tue May 22 12:20:07 2001 Christopher Faylor - - * signal.cc (sleep): Protect with sigframe. - -Tue May 22 17:58:00 2001 Corinna Vinschen - - * security.cc (get_file_attribute): Don't set errno. - -Mon May 21 15:08:00 2001 Christopher Faylor - - * configure.in: Allow --enable-newvfork to turn NEWVFORK on and off. - * configure: Regenerate. - -Mon May 21 11:46:01 2001 Christopher Faylor - - * include/cygwin/version.h: Bump minor version number. - -Sun May 20 13:26:25 2001 Christopher Faylor - - * fhandler_dsp.cc: Reformat to GNU standards. - (s_audio): Change to a pointer throughout. - (fhandler_dev_dsp::open): Initialize s_audio, if required. - -Sat May 19 23:40:00 2001 Corinna Vinschen - - * autoload.cc: Add load statements for `LookupAccountNameW', - `LsaClose', `LsaEnumerateAccountRights', `LsaFreeMemory', - `LsaOpenPolicy', `LsaQueryInformationPolicy', `NetLocalGroupEnum', - `NetLocalGroupGetMembers', `NetServerEnum', `NetUserGetGroups' and - `NtCreateToken'. - * ntdll.h: Add declaration for `NtCreateToken'. - * sec_helper.cc: Add `well_known_local_sid', `well_known_dialup_sid', - `well_known_network_sid', `well_known_batch_sid', - `well_known_interactive_sid', `well_known_service_sid' and - `well_known_authenticated_users_sid'. - (cygsid::string): Define as const method. - (cygsid::get_sid): Set psid to NO_SID on error. - (cygsid::getfromstr): Ditto. - (cygsid::getfrompw): Simplify. - (cygsid::getfromgr): Check for gr == NULL. - (legal_sid_type): Move to security.h. - (set_process_privilege): Return -1 on error, otherwise 0 or 1 related - to previous privilege setting. - * security.cc (extract_nt_dom_user): Remove `static'. - (lsa2wchar): New function. - (open_local_policy): Ditto. - (close_local_policy): Ditto. - (get_lsa_srv_inf): Ditto. - (get_logon_server): Ditto. - (get_logon_server_and_user_domain): Ditto. - (get_user_groups): Ditto. - (is_group_member): Ditto. - (get_user_local_groups): Ditto. - (sid_in_token_groups): Ditto. - (get_user_primary_group): Ditto. - (get_group_sidlist): Ditto. - (get_system_priv_list): Ditto. - (get_priv_list): Ditto. - (get_dacl): Ditto. - (create_token): Ditto. - (subauth): Return immediately if SE_TCB_NAME can't be assigned. - Change all return statements in case of error to jumps to `out' - label. Add `out' label to support cleanup. - * security.h: Add extern declarations for `well_known_local_sid', - `well_known_dialup_sid', `well_known_network_sid', - `well_known_batch_sid', `well_known_interactive_sid', - `well_known_service_sid' and `well_known_authenticated_users_sid'. - Add extern declarations for functions `create_token', - `extract_nt_dom_user' and `get_logon_server_and_user_domain'. - (class cygsid): Add method `assign'. Change operator= to call new - `assign' method. Add `debug_print' method. - (class cygsidlist): New class. - (legal_sid_type): Moved from sec_helper.cc to here. - * spawn.cc (spawn_guts) Revert reversion of previous patch. - Call `RevertToSelf' and `ImpersonateLoggedOnUser' instead of `seteuid' - again. - * syscalls.cc (seteuid): Rearranged. Call `create_token' now when - needed. Call `subauth' if `create_token' fails. Try setting token - owner and primary group only if token was not explicitely created - by `create_token'. - * uinfo.cc (internal_getlogin): Try harder to generate correct user - information. Especially don't trust return value of `GetUserName'. - -Sat May 19 21:16:07 2001 Christopher Faylor - - * fork.cc (fork_parent): Move atforkprepare call here. - (fork): From here. - -Sat May 19 18:35:00 2001 Corinna Vinschen - - * autoload.cc: Add missing load statement for `CancelIo'. - -Sat May 19 01:22:43 2001 Christopher Faylor - - * grp.cc (read_etc_group): Don't copy mutex on fork. - * pwd.cc (read_etc_passwd): Ditto. - * autoload.cc (LoadDLLfuncEx): Use LoadDLLprime to initialize DLL - specific area. - -Fri May 18 10:31:00 2001 Corinna Vinschen - - * net.cc (wsock_event::wait): Explicitely cancel IO when a signal - arrived to avoid data loss. Fallback to blocking IO when canceling - fails. - -Thu May 17 15:29:00 2001 Corinna Vinschen - - * security.cc (cygwin_set_impersonation_token): Never destroy - previous token object. - (subauth): Create token source with well defined identifier. - -Wed May 16 23:27:00 2001 Corinna Vinschen - - * uinfo.cc (uinfo_init): Just set user token to INVALID_HANDLE_VALUE. - Token value is already invalid at that point. - -Wed May 16 21:34:00 2001 Fred Yankowski - - * net.cc (errmap): Add missing mapping from WSAEINTR to EINTR. - -Wed May 16 09:20:00 2001 Corinna Vinschen - - * sec_helper.cc (legal_sid_type): Fix conditional. Change to - inline function. - -Wed May 16 01:01:48 2001 Christopher Faylor - - * autoload.h: Eliminate. - * autoload.cc: Pull in autoload.h. Eliminate many macros. Rewrite to - avoid necessity of initialization routines. Just use a standard one. - (wsock_init): New function. Moved from net.cc. - * net.cc (wsock_init): Move to autoload.cc. - (wsadata): Make global. - * dtable.cc (dtable::build_fhandler): Use more reliable method for - checking if net stuff has been loaded. - -Tue May 15 19:52:00 2001 Corinna Vinschen - - * fork.cc (fork): Eliminate superfluous call to getuid(). - * security.h: New define `NO_SID'. Remove declarations of functions - moved to methods into class cygsid. - (class cygsid): Declare new methods `getfromstr', `get_sid', - `getfrompw', `getfromgr', `get_rid', `get_uid', `get_gid', `string' - and new constructors and operators =, == and !=. - Declare new global cygsids `well_known_XXX_sid' substituting the - corresponding `get_XXX_sid' functions. Remove declarations of - these functions. - * sec_helper.cc (well_known_admin_sid): New global variable. - (well_known_system_sid): Ditto - (well_known_creator_owner_sid): Ditto - (well_known_world_sid): Ditto - (cygsid::string): New method, substituting `convert_sid_to_string_sid'. - (cygsid::get_sid): New method, substituting `get_sid'. - (cygsid::getfromstr): New method, substituting - `convert_string_sid_to_sid'. - (cygsid::getfrompw): New method, substituting `get_pw_sid'. - (cygsid::getfromgr): New method, substituting `get_gr_sid'. - (cygsid::get_id): New method, substituting `get_id_from_sid'. - (get_admin_sid): Eliminated. - (get_system_sid): Ditto. - (get_creator_owner_sid): Ditto. - (get_world_sid): Ditto. - * grp.cc: Use new cygsid methods and well known sids throughout. - * registry.cc: Ditto. - * sec_acl.cc: Ditto. - * security.cc: Ditto. - * shared.cc: Ditto. - * syscalls.cc (seteuid): Ditto. Eliminate redundant conditional. - * uinfo.cc (internal_getlogin): Ditto. - * spawn.cc (spawn_guts) Revert previous patch. - -Tue May 15 10:20:00 2001 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::ioctl): Convert s_addr - field to host byte order before comparing with INADDR_LOOPBACK. - -Tue May 15 9:03:00 2001 Corinna Vinschen - - * autoload.cc: Add autoload statements for ws2_32 functions - `WSACloseEvent', `WSACreateEvent', `WSAGetOverlappedResult', - `WSARecv', `WSARecvFrom', `WSASend', `WSASendTo' and `WSASetEvent', - `WSAWaitForMultipleEvents'. - * net.cc: Define wsock_evt. - (wsock_event): New class. - (cygwin_sendto): Use overlapped socket io if available. - (cygwin_recvfrom): Ditto. - (cygwin_recv): Ditto. - (cygwin_send): Ditto. - * security.cc (subauth): Set Win32 error to 0 to safely ask for the - error code of dynamically loaded function `LsaRegisterLogonProcess'. - -Mon May 14 15:37:29 2001 Christopher Faylor - - * errno.cc (_sys_errlist): Add missing commas. - -Mon May 14 16:13:00 2001 Corinna Vinschen - - * security.cc (subauth): Check if Secur32.dll could be loaded. - -Sun May 13 22:49:04 2001 Christopher Faylor - - * path.cc (path_conv::check): Revert allow_ntsec check so that volume - info is always retrieved and isdisk setting is properly set. - -Sun May 13 14:02:36 2001 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_common::dup): Preserve O_NOCTTY when - duping a filehandle. - -Sat May 12 18:19:00 2001 Corinna Vinschen - - * dir.cc (rmdir): Rearrange slightly to allow removing directories - even when R/O attribute is set. - -Fri May 11 16:53:38 2001 Christopher Faylor - - * external.cc (fillout_pinfo): Use correct pids. - * path.cc (mount_info::conv_to_win32_path): Correct test for whether to - include a slash. - -Fri May 11 01:04:17 2001 Christopher Faylor - - * exceptions.cc (handle_exceptions): Don't print message when executing - from a cygwin program. - -2001-05-10 Egor Duda - Christopher Faylor - - * environ.cc (winenv): Always add SYSTEMDRIVE and SYSYEMROOT to - win32-style environment if they don't already exist. - -2001-05-10 Kazuhiro Fujieda - - * path.cc (mount_info::conv_to_win32_path): Treat UNC paths the same as - paths including `:' or `\'. - -Wed May 9 14:46:32 2001 Christopher Faylor - - * fhandler.h (fhandler_termios::echo_erase): Declare new method. - * fhandler_termios.cc (fhandler_termios::echo_erase): New method for - echoing erase characters. - (fhandler_termios::line_edit): Check the echo flag before echoing - control characters (from Kazuhiro Fujieda ). - -Wed May 9 10:43:30 2001 Christopher Faylor - - * include/pthread.h: Remove C++ comment. - -Tue May 8 11:09:59 2001 Christopher Faylor - - * cygheap.cc (_cfree): Add regparm attribute. - (_crealloc): Ditto. - - * dcrt0.cc (dll_crt0_1): Default to always checking for executable for now. - - * dtable.cc (dtable::not_open): Move method. - * dtable.h (dtable): Here. - - * exceptions.cc (ctrl_c_handler): Don't expect process group leader to - handle a signal if it doesn't exist. - - * fhandler.h (fhandler_base): Make openflags protected. - - * localtime.c (tzsetwall): Check for __CYGWIN__ as well as __WIN32__. - - * path.cc (path_conv::check): Add some comments. Change strcat to assignment. - - * lib/_cygwin_S_IEXEC.cc (_cygwin_bob__): Eliminate. - - * fhandler_tty.cc (fhandler_console::dup): Set controlling terminal if necessary. - * fhandler_tty.cc (fhandler_tty_slave::dup): Ditto. - -Mon May 7 21:33:17 2001 Christopher Faylor - - * include/sys/file.h: Revert special X_OK usage. Just make it a - constant. - -Sun May 6 17:05:00 2001 Robert Collins - - * thread.h (pthread_cond): New element cond_access to allow atomic - broadcasts. - * thread.cc (pthread_cond::pthread_cond): Initialise cond_access. - (pthread_cond::~pthread_cond): Destroy cond_access. - (pthread_cond::Broadcast): Use cond_access. - (pthread_cond::Signal): Use cond_access. - (pthread_cond_wait): Use cond_access. - (pthread_cond_timedwait): Use cond_access. - -Sun May 6 11:55:40 2001 Christopher Faylor - - * string.h (cygwin_strchr): Make 'static inline' so that things will - still work when optimized. - -Sat May 5 01:04:11 2001 Christopher Faylor - - * exceptions.cc (handle_exceptions): Vastly increase test for exception - loop guard variable. - -Fri May 4 22:23:33 2001 Christopher Faylor - - * exceptions.cc (stack_info): Add some controls. - (stack_info::init): Add extra arguments to control method of - initialization.. If we have a known good frame, set things up so that - this frame is not skipped the first time through. Record whether - caller cares about arguments or not. - (stack_info::walk): Don't store arguments if they're unwanted. - (stackdump): Add isexception parameter for use when called by exception - handler. - (cygwin_stackdump): Accommodate extra argument to stackdump. - (handle_exceptions): Ditto. - (sig_handle): Ditto. - (interrupt_on_return): Accommodate extra arguments to stack walk - initialization. - -Fri May 4 21:05:20 2001 Christopher Faylor - - * localtime.c: Revert exclusion of windows.h. - -Fri May 4 17:03:16 2001 Christopher Faylor - - * string.h: Fix last-minute typo. - -Fri May 4 16:49:34 2001 Christopher Faylor - - * pinfo.h: Correctly set __SIGOFFSET. - - * path.cc (hash_path_name): Avoid calling library functions for simple - copying of characters. - - * shortcut.c: Use WIN32_LEAN_AND_MEAN. - * smallprint.c: Ditto. - - * environ.cc (getwinenv): Minor clarity fix. - - * localtime.c: No need to include windows.h - - * string.h: New file. - -Fri May 4 16:37:30 2001 Christopher Faylor - - * exceptions.cc (ctrl_c_handler): Always send signal to process if it - has no tty. - -2001-05-04 Egor Duda - - * fhandler_socket.cc (set_connect_secret): Use /dev/urandom to - generate secret cookie. - -Thu May 3 16:37:55 2001 Christopher Faylor - - * include/pthread.h (pthread_cleanup_push): Eliminate space preceding - arguments. - (pthread_cleanup_pop): Ditto. - -Thu May 3 18:16:00 2001 Corinna Vinschen - - * net.cc (wsock_init): Rename `was_in_progress' to `wsock_started' - for clearness. - -Thu May 3 10:44:16 2001 Christopher Faylor - - * exceptions.cc (handle_exceptions): Break out of "loop" if the - debugger doesn't seem to be attaching to our process. - -Wed May 2 20:18:00 2001 Corinna Vinschen - - * autoload.cc: Use new definition of LoadDLLinitfunc throughout. - Redefine wrapper for wsock32.dll and ws2_32.dll. - (std_dll_init): New function. - * autoload.h: Rename LoadDLLinitfunc to LoadDLLinitfuncdef. - Add new defines LoadDLLinitfunc and LoadDLLstdfunc. - * net.cc (wsock_init): Add guard variable handling. Take care - to call WSAStartup only once. Load WSAStartup without using - autoload wrapper to eliminate recursion. Eliminate FIONBIO - and srandom stuff. - -Tue May 1 01:26:15 2001 Christopher Faylor - - * path.cc (mount_info::conv_to_win32_path): More path tweaking. - -Tue May 1 00:34:46 2001 Christopher Faylor - - * path.cc (mount_info::conv_to_win32_path): Fix debugging output to - avoid a SIGSEGV. Avoid double backslashes in middle of filename. - -Mon Apr 30 21:51:14 2001 Christopher Faylor - - * path.cc (mkrelpath): New function. - (mount_info::conv_to_win32_path): Eliminate now-unneeded relative path - name arg and processing. - (path_conv::check): Accommodate relative path names again. Accommodate - one extra argument in mount_info::conv_to_win32_path. Tack trailing - slash on end of relative path as a side effect, like before. - * shared_info.h (mount_info::conv_to_win32_path): Reflect new argument - ordering. - -Mon Apr 30 22:09:00 2001 Corinna Vinschen - - * autoload.cc: Add LoadDLLinitfunc for secur32.dll. - Add LoadDLLfuncEx statements for AllocateLocallyUniqueId@4, - DuplicateTokenEx@24, LsaNtStatusToWinError@4, - LsaDeregisterLogonProcess@4, LsaFreeReturnBuffer@4, - LsaLogonUser@56, LsaLookupAuthenticationPackage@12, - LsaRegisterLogonProcess@12, - * environ.cc: Add extern declaration for `subauth_id'. - (subauth_id_init): New function for setting `subauth_id'. - (struct parse_thing): Add entry for `subauth_id'. - * fork.cc (fork_parent): Call `RevertToSelf' and - `ImpersonateLoggedOnUser' instead of `seteuid'. - * security.cc: Define global variable `subauth_id'. - (extract_nt_dom_user): New function. - (cygwin_logon_user): Call `extract_nt_dom_user' now. - (str2lsa): New static function. - (str2buf2lsa): Ditto. - (str2buf2uni): Ditto. - (subauth): Ditto. - * security.h: Add prototype for `subauth'. - * spawn.cc (spawn_guts): Use cygheap->user.token only if impersonated. - Use `cygsid' type. Remove impersonation before allowing access to - workstation/desktop to everyone. Call `RevertToSelf' and - `ImpersonateLoggedOnUser' instead of `seteuid'. - * syscalls.cc (seteuid): Rearranged to allow using subauthentication - to retrieve user tokens when needed. - -Mon Apr 30 20:26:00 2001 Corinna Vinschen - - * uinfo.cc (internal_getlogin): Formatting change. - -Mon Apr 30 19:58:00 2001 Corinna Vinschen - - * grp.cc: Eliminate MAX_DOMAIN_NAME define. - (read_etc_group): Substitute MAX_DOMAIN_NAME by - INTERNET_MAX_HOST_NAME_LENGTH. - * passwd.cc (parse_pwd): Don't force pw_name to be lower case. - * sec_helper.cc: Substitute MAX_USER_NAME by UNLEN, - MAX_COMPUTERNAME_LENGTH by INTERNET_MAX_HOST_NAME_LENGTH throughout. - (lookup_name): Slight cleanup. - * security.cc (alloc_sd): Substitute MAX_USER_NAME by UNLEN. - * security.h: Define DEFAULT_UID as DOMAIN_USER_RID_ADMIN and - DEFAULT_GID as DOMAIN_ALIAS_RID_ADMINS. - * shared.cc (memory_init): Substitute MAX_USER_NAME by UNLEN. - * thread.h: Ditto. - * uinfo.cc (internal_getlogin): Substitute MAX_USER_NAME by UNLEN. - Substitute MAX_COMPUTERNAME_LENGTH and MAX_HOST_NAME by - INTERNET_MAX_HOST_NAME_LENGTH. - * winsup.h: Include lmcons.h. Eliminate MAX_USER_NAME and - MAX_HOST_NAME. Move DEFAULT_UID and DEFAULT_GID to security.h. - -Mon Apr 30 12:35:40 2001 Christopher Faylor - - * path.cc (path_conv::check): Don't use path_flags when converting to - MS-DOS syntax unless parsing tail of path component. Stop parsing path - when we reach the 'root' of the path. Correctly copy tail to path - component. - -Sun Apr 29 22:28:06 2001 Christopher Faylor - - * exceptions.cc (INIT_EXCEPTION_HANDLER): Eliminate. - (init_exceptions): Just use init_exception_handler. - (open_stackdumpfile): New function. - (stack_info::first_time): Eliminate. - (stack_info::init): Set up fields to avoid "first_time" consideration. - (stack_info::walk): Remove "first_time" consideration. - (stackdump): Change arguments to accept initial frame pointer and open - stack file flag. - (stack): Eliminate. - (cygwin_stackdump): Use stackdump() rather than stack(). - (try_to_debug): Remove all synchronization logic. Just keep looping in - exception handler until debugger notices us. Return 1 if successfully - started debugger. - (handle_exceptions): Just return if we know that we're debugging. - Reorganize to avoid creating a stackdump file if we are starting a - debugger. Return from exception handler if debugger started - successfully. - (sig_handle): Create a stackdump only if debugger wasn't started. - * winsup.h (try_to_debug): Add an argument. - -Sun Apr 29 21:41:25 2001 Christopher Faylor - - * path.cc (symlink_info::check): Remove extra arguments, move - functionality back to path_conv::check. Clear symlink bit from pflags - argument before detecting if this is a symlink. - (path_conv::check): Convert posix path here instead of - symlink_info::check. Only grab volflags when using ntsec. - (symlink_info::check_case): Just replace appropriate part of input - path. - -Sat Apr 28 19:36:13 2001 Christopher Faylor - - Throughout, change 'tty_attached' to 'real_tty_attached', for clarity. - Throughout, change 'OutputStopped' to 'output_stopped', for - consistency. - * dtable.cc (stdio_init): Set controlling tty if not set by stdio - opens. - * exceptions.cc (ctrl_c_handler): Avoid special pgid checking if no tty - is associated with the process. - (Suggested by Tim Baker ) - * external.cc (fillout_pinfo): Return actual tty number for ctty. - * fhandler_console.cc (get_tty_stuff): Set ctty when shared memory is - allocated. Accept flags input from open(). - (set_console_ctty): New function. - (fhandler_console::open): Pass flags to get_tty_stuff and rely on this - function to set the ctty, if appropriate. - * fhandler_termios.cc (fhandler_termios::set_ctty): Move to tty_min - class. - * fhandler_tty.cc (fhandler_tty_slave::open): Use tc field to access - set_ctty(). - * tty.h (TTY_CONSOLE): Move to include/sys/cygwin.h. - (tty_min): Add set_ctty class here. - * include/sys/cygwin.h (TTY_CONSOLE): New home here. - - * path.cc (symlink_info): Make contents an actual buffer. Pass more - flags to case_check. - (path_conv::check): Reorganize to do parsing based on posix path rather - than native path. - (symlink_info::check): Expect posix path as input. Translate to native - path here. Accept path_conv flags. Stop parsing if not a symlink - regardless of whether previous path was a symlink. - -2001-04-27 Kazuhiro Fujieda - - * thread.cc (thread_init_wrapper): Use _REENT_INIT to initialize the - reent structure of newlib. - -Fri Apr 27 14:02:24 2001 Christopher Faylor - - * sigproc.h (sig_send): Add exception parameter to sig_send. - * sigproc.cc (sig_send): Ditto. Use it when setting frame info. - * exceptions.cc (handle_exceptions): Use exception flag when calling - sig_send. - -2001-04-27 Egor Duda - - * tty.cc (tty::make_pipes): Set to_slave pipe mode to nonblocking. - * fhandler_tty.cc (fhandler_pty_master::accept_input): If pipe buffer - is full, give slave a chance to read data. - -2001-04-26 Kazuhiro Fujieda - - * security.cc (alloc_sd): Add unrelated ACCESS_ALLOWED_ACE behind - the `everyone' ACE. - -Wed Apr 25 15:07:37 2001 Christopher Faylor - - * sigproc.h [sigthread]: Add exception field. - [sigframe::~sigframe]: Clear exception field. - [sigframe::set]: Set exception field from caller. - * sigproc.cc (sig_send): Set exception field when frame pointer is - passed in. - * exceptions.cc (interrupt_on_return): Always treat exception as - interruptible. - -2001-04-25 Egor Duda - - * cygwin.din: Export asctime_r, ctime_r, gmtime_r, localtime_r - * include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR to 39 - -Wed Apr 25 10:57:36 2001 Christopher Faylor - - * include/cygwin/version.h: Bump minor version number. - * childinfo.h: Bump child structure magic number. - -2001-04-25 Kazuhiro Fujieda - - * uinfo.cc (internal_getlogin): Return pointer to struct passwd. - (uinfo_init): Accommodate the above change. - * syscalls.cc (seteuid): Ditto. - -Tue Apr 25 11:08:00 2001 Corinna Vinschen - - * autoload.cc: Add LoadDLLfunc statements for SetTokenInformation@16. - * cygheap.cc: Include security.h. - * grp.cc (internal_getgrent): New function. - (getgroups): Rearranged using `internal_getgrent' and the new - `cygsid' class. - * passwd.cc (internal_getpwent): New function. - * sec_acl.cc: Use new `cygsid' class throughout. - (acl_access): Use `internal_getgrent' instead of `getgrent'. - * sec_helper.cc: Use new `cygsid' class throughout. - (get_id_from_sid): Use `internal_getgrent' instead of `getgrent'. - Use `internal_getpwent' instead of `getpwent'. - * security.cc: Use new `cygsid' class throughout. - * security.h: Move `MAX_SID_LEN' from winsup.h to here. - Add extern declarations for `internal_getgrent' and `internal_getpwent'. - (class cygsid): New class. - * shared.cc (sec_user): Use new `cygsid' class. - * syscalls.cc (seteuid): Try to set owner to user and primary group to - current group in impersonation token before performing impersonation. - (setegid): Try to set primary group in process token to the new group - if ntsec is on. - * uinfo.cc (internal_getlogin): Use new `cygsid' class. - Try to set owner to user and primary group to current group in process - token if the process has been started from a non cygwin process. - (uinfo_init): Set primary group only if the process has been started - from a non cygwin process. - * winsup.h: Move define for `MAX_SID_LEN' to security.h. - -Mon Apr 16 23:20:00 2001 Andy Younger - - * fhandler_dsp.cc: Improved handling of 8 bit playback modes. - Put in mock support for SNDCTL_DSP_SETFRAGMENT. - -Tue Apr 24 23:51:00 2001 Corinna Vinschen - - * passwd.cc (getpwnam_r): Add pw_passwd handling as well. - (getpwuid_r): Ditto. - -Tue Apr 24 23:43:00 2001 Corinna Vinschen - - * passwd.cc (getpwnam_r): Use correct offsets into buffer. - Copy pw_gecos field as well. - (getpwuid_r): Ditto. - -2001-04-24 Egor Duda - - * dlmalloc.c: New file. Port of Doug Lea's malloc - * dlmalloc.h: Ditto. - * Makefile.in: Add support for MALLOC_DEBUG - * config.h.in: Ditto. - * winsup.h: Ditto. - * configure.in: Add --enable-malloc-debugging option. - * configure: Regenerate. - * debug.h: Include declarations for debugging malloc. - * tty.cc (grantpt): Fix definition. - (unlockpt): Ditto. - -Mon Apr 23 22:00:29 2001 Christopher Faylor - - Remove trailing underscore from fhandler_base and friends, throughout. - * fhandler.h (fhandler_base::set_open_status): New method. Stores - original open status. - (fhandler_base::get_open_status): New method. Retrieves original open - status. - (fhandler_base::reset_to_open_binmode): New method. - * fhandler.cc (fhandler_base::open): Save open status. - (fhandler_base::init): Ditto. - * fhandler_clipboard.cc (fhandler_clipboard::open): Ditto. - * fhandler_console.cc (fhandler_console::open): Ditto. - * fhandler_dsp.cc (fhandler_dsp::open): Ditto. - * fhandler_dev_mem.cc (fhandler_dev_mem::open): Ditto. - * fhandler_dev_random.cc (fhandler_dev_random::open): Ditto. - * fhandler_serial.cc (fhandler_serial::open): Ditto. - * fhandler_tty_slave.cc (fhandler_tty_slave::open): Ditto. - * fhandler_tty_master.cc (fhandler_tty_master::open): Ditto. - * fhandler_dev_zero.cc (fhandler_dev_zero::open): Ditto. - * syscalls.cc (setmode): Rework so that 0 mode value causes reversion - to open state. - - * fhandler_tty_slave.cc (fhandler_tty_slave::read): Use correct - multiplier when converting from deciseconds to milliseconds. - -Mon Apr 23 13:28:35 2001 Christopher Faylor - - * fhandler.h (fhandler_base::clear_r_binary): New method. - (fhandler_base::clear_w_binary): New method. - * syscalls.cc (setmode): Accept 0 as mode value. Resets text/binary - behavior for fd to default. - -Mon Apr 23 12:46:07 2001 Christopher Faylor - - * net.cc [errmap]: Add '0' condition. - (find_winsock_errno): Don't translate no error to EPERM. - -Sun Apr 22 20:48:24 2001 Christopher Faylor - - * include/cygwin/version.h: Bump Cygwin version and API version. - -Mon Apr 23 9:27:00 2001 Robert Collins - - * thread.cc (MTinterface::Init): Always initialise per process variables. - -Sun Apr 22 19:18:18 2001 Christopher Faylor - - * features.h: Reinstate as wrapper for sys/features.h. - -Mon Apr 23 0:10:00 2001 Corinna Vinschen - - * security.cc (alloc_sd): Reformat comment. - * shared.cc: Drop function declarations already in security.h. - -Sun Apr 22 12:17:57 2001 Christopher Faylor - - * shortcut.c (check_shortcut): Close input file handle before - returning. - * path.cc (check_sysfile): Ditto. - (symlink_info::check): Rely on opened file handle being closed by - symlink checking routines. Set ext_tacked_on when .lnk is detected. - -Sat Apr 21 19:26:05 2001 Christopher Faylor - - * thread.cc (MTinterface::Init): Remove accidentally checked in code. - -Sun Apr 22 00:22:00 2001 Robert Collins - - * passwd.cc (getpwuid): Check for thread cancellation. - (getpwuid_r): Ditto. - (getpwname): Ditto. - (getpwnam_r): Ditto. - * thread.h (pthread_mutex): New constructors for pshared operation. - (MTinterface): Associative array for pshared mutex's. - * thread.cc (MTinterface::Init): Initailize pshared mutex array. - (pthread_cond::BroadCast): Implementation notes. - (pthread_cond::TimedWait): Remove use of SignalObjectAndWait on non-NT systems. - (pthread_mutex::pthread_mutex(unsigned short)): New function. - (pthread_mutex::pthread_mutex (pthread_mutex_t *, pthread_mutexattr *)):New function. - (pthread_mutex::pthread_mutex(pthread_mutexattr *)): Fail on pshared mutex's. - (__pthread_mutex_getpshared): New function. - (__pthread_join): Check for thread cancellation. - (__pthread_cond_timedwait): Support pshared mutex's. - (__pthread_cond_wait): Ditto. - (__pthread_condattr_setpshared): Error on PROCESS_SHARED requests. - (__pthread_mutex_init): Support pshared mutex's. - (__pthread_mutex_getprioceiling): Ditto. - (__pthread_mutex_lock): Ditto. - (__pthread_mutex_trylock): Ditto. - (__pthread_mutex_unlock): Ditto. - (__pthread_mutex_destroy): Ditto. - (__pthread_mutex_setprioceiling): Ditto. - (__pthread_mutexattr_setpshared): Support PTHREAD_PROCESS_PSHARED requests. - -Fri Apr 20 19:38:29 2001 Christopher Faylor - - * cygwin.din: Add *scanf and *scan_r functions. - -Fri Apr 20 22:25:00 2001 Corinna Vinschen - - * security.cc (set_process_privileges): Swap out. - * sec_helper.cc (set_process_privilege): Rename from - `set_process_privileges'. Takes the privilege to enable or disable - as parameter now. - * security.h: Add prototype for `set_process_privileges'. - -2001-04-19 Egor Duda - - * path.cc (path_conv::check): Always initialize member variables. - -Fri Apr 20 12:27:49 2001 Christopher Faylor - - * include/sys/file.h: More cleanup for X_OK. - -Fri Apr 20 11:48:45 2001 Christopher Faylor - - * include/sys/file.h: Move X_OK protection earlier. - - * dtable.cc (dtable::vfork_child_fixup): Avoid closing already closed - handles. - -Fri Apr 20 16:29:00 2001 Corinna Vinschen - - * grp.cc (getgroups): Change so that SIDs get compared instead - of strings to SIDs. - -Fri Apr 20 14:50:00 2001 Corinna Vinschen - - * Makefile.in: Add object files `sec_helper.cc' and `sec_acl.cc'. - * security.cc: Swap out several functions. - * sec_acl.cc: New file. Move Sun compatibel ACL functions from - `security.cc' to here. - * sec_helper.cc: New file. Move security helper functions from - `security.cc' to here. - * security.h: Changed to accommodate the above changes. - -Fri Apr 20 14:12:00 2001 Corinna Vinschen - - * grp.cc: Replace `group_in_memory_p' by `group_state'. - Eliminate group_sem throughout. - (enum grp_state): New enumeration type. - (read_etc_group): Make race safe. - * security.cc: Eliminate group_sem throughout. - -Thu Apr 19 9:40:00 2001 Corinna Vinschen - - * mmap.cc (mmap): Drop usage of the same memory area if the same - region of the same file is mapped twice. - -Wed Apr 18 16:53:54 2001 Christopher Faylor - - Throughout, change fdtab references to cygheap->fdtab. - * child_info.h (cygheap_exec_info): Eliminate special fdtab stuff. - * spawn.cc (spawn_guts): Ditto. - * cygheap.cc (cygheap_init): Initialize fdtab, if appropriate. - * cygheap.h (CYGHEAPSIZE): Include size of init_cygheap. - (_cmalloc_entry): Include fdtab here. - * dtable.h (dtable): Declare/define new methods. - * dtable.cc (dtable::vfork_child_fixup): New method. - (dtable::fixup_after_exec): Remove unneeded extra arguments. - * dcrt0.cc (dll_crt0_1): Ditto. - - * environ.cc (getwinenv): Use case sensitive comparison. - (winenv): Make a copy of environment cache to avoid realloc problems - when duplicate environment variables exist in the environment. (From - Egor Duda) - - * net.cc (cygwin_socket): Revert Apr 14 change. - - * include/sys/file.h: Protect against previous X_OK definition. - -Tue Apr 17 12:18:28 2001 Christopher Faylor - - * passwd.cc: Eliminate passwd_sem throughout. - * security.cc: Ditto. - -Tue Apr 17 12:18:28 2001 Robert Collins - - * cygwin.din: Export New functions. - * passwd.cc (read_etc_passwd): Make race safe. - (getpwuid_r): New function. - (getpwnam_r): New function. - -2001-04-18 Egor Duda - - * grp.cc (getgroups): Avoid crash if passwd field if /etc/group is - empty. - -Tue Apr 17 19:05:44 2001 Christopher Faylor - - * path.h (path_conv::add_ext_from_sym): Declare. - * path.cc (path_conv::add_ext_from_sym): Convert to pure inline method. - -Tue Apr 17 18:50:00 2001 Corinna Vinschen - - * path.cc (windows_device_names): Add missing NULL element. - -Tue Apr 17 12:14:54 2001 Christopher Faylor - - * path.cc (windows_device_names): Move dsp to proper location. - -Tue Apr 17 13:44:00 2001 Corinna Vinschen - - * path.cc (path_conv::check): Set case_clash even if pcheck_case - is set to PCHECK_ADJUST when a case clash is given for the last - component in path. - (symlink_info::case_check): Ditto. - * syscalls.cc (_rename): Avoid overwriting an already existing file - if a case clash is given even if pcheck_case is set to PCHECK_ADJUST. - -Tue Apr 17 2:07:07 2001 Christopher Faylor - - * config.h.in: Turn off VFORK again. - -Mon Apr 16 23:45:24 2001 Christopher Faylor - - * path.h (cwdstuff): Move class. - * cygheap.h (cwdstuff): To here. - (init_cygheap): Add cwd field. - * child_info.h (cygheap_exec_info): Eliminate cwd stuff. - (child_info_spawn): Ditto. - * dcrt0.cc (dll_crt0_1): Remove cygcwd.fixup_after_exec call. Convert - cygcwd reference to cygheap->cwd. - * path.cc: Ditto, throughout. - (cwdstuff::copy): Eliminate. - (cwdstuff::fixup_after_exec): Ditto. - * spawn.cc (spawn_guts): Eliminate call to cygcwd.copy. - - * fhandler.h (FH_OSS_DSP): Move into "fast" device category. - -Mon Apr 16 19:19:00 2001 Corinna Vinschen - - * mmap.cc: Move fh_paging_file from some functions to be - a global static variable. - (class mmap_record): Add `devtype_' member to remember - the device type of the file. Add declaration for methods - `get_device', `alloc_fh' and `free_fh'. - (mmap_record::mmap_record): Initialize `devtype_' correctly. - (mmap_record::alloc_fh): New method. - (mmap_record::free_fh): Ditto. - (munmap): Use new mmap_record::alloc_fh and mmap_record::free_fh - methods to create a correct fhandler. - (msync): Ditto. - (fixup_mmaps_after_fork): Ditto. - -Mon Apr 16 16:01:00 2001 Corinna Vinschen - - * grp.cc (getgroups): If `allow_ntsec' is set, use the process token - information to evaluate the groups list. - -Mon Apr 16 00:08:02 2001 Christopher Faylor - - * features.h: Remove this file as it is now being supplied by newlib. - -Sun Apr 15 23:23:29 2001 Christopher Faylor - - * autoload.cc: Add winmm functions needed by fhandler_dsp.cc. - -Sun Apr 15 22:53:52 2001 Andy Younger - - * fhandler_dsp.cc: New file. Implements OSS like /dev/dsp. - * include/sys/soundcard.h: New file. User land includes for OSS - /dev/dsp. - * fhandler.h: Add new class fhandler_dev_dsp and a FH_OSS_DSP - definition. - * dtable.cc (dtable::build_fhandler): Allow creation of the /dev/dsp - device. - * path.cc (windows_device_names): Add /dev/dsp into list of device - names. - * Makefile.in (DLL_OFILES): Add fhandler_dsp.o. - -Sun Apr 15 16:36:27 2001 Christopher Faylor - - * uname.c (uname): Default n in in86 to 6 if Windows returns > 6. - -Sun Apr 15 15:56:00 2001 Corinna Vinschen - - * path.cc (add_ext_from_sym): Redefine to call `add_ext_from_sym_'. - (add_ext_from_sym_): New inline function. - -Sat Apr 14 19:23:52 2001 Christopher Faylor - - * config.h.in: Turn on VFORK by default. - -Sat Apr 14 18:04:35 2001 Christopher Faylor - - * net.cc (cygwin_socket): Set SO_LINGER to small value so closed UNIX - domain sockets will not stay around. - -Sat Apr 14 18:01:43 2001 Pierre A. Humblet - - * select.cc (socket_cleanup): Set SO_LINGER to small value so closed - dummy sockets do not stay around. Use correct value for second argument - to shutdown. - -Sat Apr 14 17:04:00 2001 Robert Collins - - * thread.h (MTinterface): Add threadcount. - * thread.cc (MTinterface::Init): Set threadcount to 1. - (__pthread_create): Increment threadcount. - (__pthread_exit): Decrement threadcount and call exit() from the last thread. - -Fri Apr 13 11:34:24 2001 Robert Collins - - * fork.cc (fork_child): Call the __pthread_atforkchild function. - (fork_parent): Call the __pthread_atforkparent function. - * cygwin.din: Export pthread_atfork. - * thread.h (callback): New class. - (MTinterface): Use it. - * thread.cc (__pthread_atforkprepare): New function. - (__pthread_atforkparent): New function. - (__pthread_atforkchild): New function. - (__pthread_atfork): New function. - * pthread.cc (pthread_atfork): New function. - -Fri Apr 13 9:52:00 2001 Corinna Vinschen - - * path.cc (add_ext_from_sym): New define evaluating `known'suffix'. - (path_conv::check): Use add_ext_from_sym throughout. - -Thu Apr 12 23:19:00 2001 Corinna Vinschen - - * dir.cc (mkdir): Check for case clash. - * environ.cc: Add extern declaration for `pcheck_case'. - (check_case_init): New function. - (struct parse_thing): Add "check_case" option. - * errno.cc (_sys_nerrlist): Add text for ECASECLASH. - (strerror): Add case branch for ECASECLASH. - * fhandler.cc (fhandler_disk_file::open): Check for case clash. - * path.cc: Add global variable `pcheck_case'. - (struct symlink_info): Add member `case_clash' and method `case_check'. - (path_prefix_p_): Call `pathnmatch' instead of `strncasematch'. - (pathnmatch): New funtion. - (pathmatch): Ditto. - (path_conv::check): Add handling for case checking. - (symlink): Check for case clash. - (symlink_info::check): Add parameter for case checking. - Handle case checking. - (symlink_info::case_check): New method. - (chdir): Don't use unconverted path if pcheck_case==PCHECK_STRICT. - * path.h: Add extern declarations for `pathmatch' and - `pathnmatch'. - (enum case_checking): New enumeration type describing - the case checking behaviour of path conversion routines. - (class path_conv): Add member `case_clash'. - * syscalls.cc (_link): Check for case clash. - -Thu Apr 12 12:49:53 2001 Christopher Faylor - - * syscalls.cc (mkfifo): New function stub. - -2001-04-12 Robert Collins - - * configure.in: Remove PTH_ALLOW. - * cygwin.din: Remove @PTH_ALLOW@ prefixes to pthread functions. Add - new pthread exports. - * pthread.cc: New wrapper functions for the above new exports. - * sched.cc (valid_sched_parameters): New function. - (sched_setparam): Use it. - (sched_set_thread_priority): New function. Used by pthread_sched*. - * thread.cc (pthread_key_destructor::InsertAfter): New function. - (pthread_key_destructor::UnlinkNext): New function. - (pthread_key_destructor::Next): New function. - (pthread_key_destructor_list::Insert): New function. - (pthread_key_destructor_list::Remove): New function. - (pthread_key_destructor_list::Pop): New function. - (pthread_key_destructor::pthread_key_destructor): New function. - (pthread_key_destructor_list::IterateNull): New function. - (MTinterface::Init): Initialise new member. - (pthread::pthread): Initialise new members. - (pthread::create): Copy new attributes. Set the new thread priority. - (pthread_attr::pthread_attr): Initialise new members. - (pthread_key::pthread_key): Setup destructor function. - (pthread_key::~pthread_key): Remove destructor function. - (pthread_mutexattr::pthread_mutexattr): New function. - (pthread_mutexattr::~pthread_mutexattr): New function. - (__pthread_once): New function. - (__pthread_cleanup): New function. - (__pthread_cancel): New function. - (__pthread_setcancelstate): New function. - (__pthread_setcanceltype): New function. - (__pthread_testcancel): New function. - (__pthread_attr_getinheritsched): New function. - (__pthread_attr_getschedparam): New function. - (__pthread_attr_getschedpolicy): New function. - (__pthread_attr_getscope): New function. - (__pthread_attr_setinheritsched): New function. - (__pthread_attr_setschedparam): New function. - (__pthread_attr_setschedpolicy): New function. - (__pthread_attr_setscope): New function. - (__pthread_exit): Call any key destructors on thread exit. - (__pthread_join): Use the embedded attr values. - (__pthread_detach): Use the embedded attr values. - (__pthread_getconcurrency): New function. - (__pthread_getschedparam): New function. - (__pthread_key_create): Pass the destructor on object creation. - (__pthread_key_delete): Correct incorrect prototype. - (__pthread_setconcurrency): New function. - (__pthread_setschedparam): New function. - (__pthread_cond_timedwait): Support static mutex initialisers. - (__pthread_cond_wait): Ditto. - (__pthread_mutex_getprioceiling): New function. - (__pthread_mutex_lock): Support static mutex initialisers. - (__pthread_mutex_trylock): Ditto. - (__pthread_mutex_unlock): Ditto. - (__pthread_mutex_destroy): Ditto. - (__pthread_mutex_setprioceiling): New function. - (__pthread_mutexattr_getprotocol): New function. - (__pthread_mutexattr_getpshared): New function. - (__pthread_mutexattr_gettype): New function. - (__pthread_mutexattr_init): New function. - (__pthread_mutexattr_destroy): New function. - (__pthread_mutexattr_setprotocol): New function. - (__pthread_mutexattr_setprioceiling): New function. - (__pthread_mutexattr_getprioceiling): New function. - (__pthread_mutexattr_setpshared): New function. - (__pthread_mutexattr_settype): New function. Remove stubs for non - MT_SAFE compilation. - * thread.h: Remove duplicate #defines. Add prototypes for new - functions in thread.cc. - (pthread_key_destructor): New class. - (pthread_key_destructor_list): New class. - (pthread_attr): Add new members. - (pthread): Remove members that are duplicated in the pthread_attr - class. - (pthread_mutex_attr): Add new members. - (pthread_once): New class. - * include/pthread.h: Add prototypes for new functions exported from - cygwin1.dll. Remove typedefs. - * include/sched.h: Add prototypes for new functions in sched.cc. - * include/cygwin/types.h: Add typedefs from pthread.h - -Tue Apr 10 22:02:53 2001 Christopher Faylor - - * path.cc (struct symlink_info): Add extn and ext_tacked_on fields. - (path_conv::check): Only tack on extension if a known one didn't - already exist. - (suffix_scan::has): Return pointer to known extension. - (symlink_info::check): Record location of extension, if any. - -2001-04-09 Egor Duda - - * fhandler.h (class fhandler_socket): Add members and methods to - support secure connections on AF_UNIX sockets. - * fhandler_socket.cc (fhandler_socket::set_connect_secret): New method. - (fhandler_socket::get_connect_secret): Ditto. - (fhandler_socket::create_secret_event): Ditto. - (fhandler_socket::close_secret_event): Ditto. - (fhandler_socket::check_peer_secret_event): Ditto. - (fhandler_socket::fixup_after_fork): Duplicate secret event to child. - (fhandler_socket::dup): Copy address family. - (fhandler_socket::close): Close secret event. - * net.cc (get_inet_addr): Read secret cookie. - (cygwin_connect): Check if peer knows secret cookie value. - (cygwin_accept): Ditto. Copy address family to newly created socket. - (cygwin_bind): Generate and write secret cookie. - (wsock_init): Initialize random number generator. - -Sun Apr 8 20:40:58 2001 Christopher Faylor - - * Makefile.in: Put -lgcc last in list of libraries, since stdc++ - library needs it. - * cygwin.din: Remove obsolete "__empty" export. - * exceptions.cc (call_signal_handler_now): Force inclusion of function - even when -finline-functions is specified. - * sigproc.h: Remove obsolete call_signal_handler declaration. - -Sun Apr 8 20:36:55 2001 Benjamin Riefenstahl - - * fhandler_console.cc (cp_get_internal): New function. - (cp_convert): New function. - (con_to_str): New function. - (str_to_con): New function. - (fhandler_console::read): Replace OemToCharBuff with con_to_str. - (fhandler_console::write_normal): Replace CharToOemBuff with str_to_con. - -Thu Apr 5 22:41:00 2001 Corinna Vinschen - - * syscalls.cc (stat_worker): Fix conditional which still allowed - successful stat'ing of non-existant files. - -Wed Apr 4 10:37:44 2001 Christopher Faylor - - * child_info.h: Bump magic number for fork/exec/spawn. - -Tue Apr 3 20:06:00 2001 Corinna Vinschen - - * errno.cc (errmap): Map ERROR_FILE_INVALID to ENXIO. - -Mon Apr 2 22:48:58 2001 Christopher Faylor - - * cygrun.c (main): Fix compiler warning. - * gmon.c (_mcleanup): Ditto. - * profil.c (profile_off): Ditto. - - * net.cc (find_winsock_errno): New function. - (__set_winsock_errno): Use find_winsock_errno. - (cygwin_setsockopt): Detect SO_ERROR for debugging. - (cygwin_getsockopt): Ditto. Translate error when getsockopt returns - SO_ERROR. - * winsup.h: regparmize __set_winsock_errno. - * include/sys/strace.h: Document that strace functions can't use - regparm. - -2001-04-02 Kazuhiro Fujieda - - * fhandler.cc (fhandler_disk_file::open): Avoid checking a magic - number of a directory. - -Mon Apr 2 00:24:08 2001 Christopher Faylor - - * shared_info.h (mount_info): Remove mnt_ elements. - * thread.h (struct _winsup_t): Add mnt_ elements. - * path.cc (fillout_mntent): Use mnt_ elements from reent_winsup (). - -Sun Apr 1 20:10:34 2001 Christopher Faylor - - * exceptions.cc (sigframe::call_signal_handler): Return value of - call_signal_handler_now. - * sigproc.h (sigframe): Use constructor. - * syscalls.cc (_read): Correct errno test prior to calling signal - handler. - -Sun Apr 1 00:38:06 2001 Christopher Faylor - - * exceptions.cc (sigframe::call_signal_handler): Move outside of "C" - block or some compilers will complain. - -Sun Apr 1 00:24:14 2001 Christopher Faylor - - * exceptions.cc (call_signal_handler_now): Rename from - call_signal_handler to avoid C++ confusion. - -Sun Apr 1 00:08:15 2001 Christopher Faylor - - * path.cc (fillout_mntent): Always remove drive root directories from - future consideration by "/cygdrive" reporting. - (cygdrive_getmnt): Avoid reporting removable drives or drives with no - media mounted. - -Sat Mar 31 21:56:19 2001 Christopher Faylor - - * thread.h (struct _winsup_t): Remove obsolete elements. Add - available_drives element. - * path.cc (mount_info::getmntent): Report "/cygdrive" drives when - mounted drives are exhausted. - (fillout_mntent): New function. - (mount_item::getmntent): Use fillout_mntent. - (cygdrives_mntent): New function. Returns next available "/cygdrive". - (setmntent): Initialize available "/cygdrives". - * syscalls.cc: Remove some if 0'ed code. - * times.cc (timezone): Use more descriptive variable name. - -Sat Mar 31 18:59:52 2001 Christopher Faylor - - * sigproc.h (class sigframe): Implement 'unregister()' method. - (sigframe::~sigframe): Use unregister method. - (sigframe::call_signal_handler): Declare new method. - * exceptions.cc (sigframe::call_signal_handler): New method. - Unregisters current sigframe before calling signal handler. - (setup_handler): Clear waiting threads prior to arming signal_arrived. - * syscalls.cc (_read): Change goto to loop. Recalculate sigframe - inside of loop so that constructor is called when appropriate. - * wait.cc (wait4): Ditto. - - * signal.cc: Change "sig" to "signal" in debugging messages throughout. - * sigproc.cc: Ditto. - -Sat Mar 31 17:12:08 2001 Christopher Faylor - - * fhandler_serial.cc (fhandler_serial::raw_write): Close protected - handles with ForceCloseHandle or suffer spurious warnings. - -Sat Mar 31 16:23:32 2001 Christopher Faylor - - * fhandler.cc (fhandler_base::read): Remove special handling of CTRL-Z. - -Sat Mar 31 11:09:00 2001 Corinna Vinschen - - * fhandler.h (class fhandler_console): Add members `insert_mode'. - * fhandler_console.cc (fhandler_console::dup): Duplicate `insert_mode'. - (fhandler_console::fhandler_console): Initialize `insert_mode'. - (fhandler_console::char_command): Add terminal capabilities - "enter insert mode" = \E[4h and "exit insert mode" = \E[4l. - Care for insert mode on terminal capability "repeat char" = \E[x;yb. - (fhandler_console::write_normal): Care for insert mode before writing - to the console. - (array keytable): Add keymapping for modified cursor and control - block keys (xterm like). - -Fri Mar 30 13:02:00 2001 Corinna Vinschen - - * fhandler.h (class fhandler_console): Add members `savebufsiz' and - `savebuf' to allow save/restore of screen. - * fhandler_console.cc (fhandler_console::dup): Duplicate `savebufsiz' - and `savebuf'. - (fhandler_console::fhandler_console): Initialize `savebufsiz' and - `savebuf'. - (fhandler_console::char_command): Add terminal capabilities - "save screen content" = \E[?47h and "restore screen content" = \E[?47l. - -Wed Mar 28 19:28:50 2001 Christopher Faylor - - * path.cc (chdir): Eat trailing whitespace on input path. - -Tue Mar 27 22:38:42 2001 Christopher Faylor - - * lib/_cygwin_S_IEXEC.c: Remove "const" from globals or they never seem - to be defined. Wrap definitions in extern "C". Include winsup.h to - assure proper definitions. - - * dcrt0.cc (dll_crt0_1): Call stdio_init after premain run so that - binmode.o, etc., will control default stdio settings. - * dtable.cc (dtable::init_std_file_from_handle): Allow __fmode to force - binmode/textmode settings. Default pipes to binmode. - -Tue Mar 27 11:31:00 2001 Corinna Vinschen - - * mmap.cc (mmap): Fix conditional for previous patch. - -Mon Mar 26 18:48:00 2001 Corinna Vinschen - - * mmap.cc (mmap): Outflank copy-on-write problem on 9x by - setting access mode to FILE_MAP_READ when read access is requested. - -Sun Mar 25 20:12:21 2001 Christopher Faylor - - * dlfcn.cc (check_access): Eliminate. - (check_path_access): Use passed in path_conv buf. - (get_full_path_of_dll): Use passed in name buf to avoid a static. Rip - out most of the path checking since LoadLibrary will do all of this - automatically. - (dlopen): Set errno when appropriate (may not be compliant?). - * environ.cc (posify): Don't pass in "native" path if it seems to - actually be posix. - -Thursday Mar 22 2001 Robert Collins - - * fhandler.h (fhandler_dev_clipboard): Extend to support writing. - * fhandler_clipboard.cc (fhandler_dev_clipboard::fhandler_dev_clipboard): - Initialize new fields. Open clipboard here. - (fhandler_dev_clipboard::dup): New method. - (fhandler_dev_clipboard::open): Accommodate new fields. Register - clipboard here, if appropriate. - (set_clipboard): New function. Moves buffer to clipboard. - (fhandler_dev_clipboard::write): Truly implement clipboard writing. - (fhandler_dev_clipboard::read): Reimplement to allow successive reads. - (fhandler_dev_clipboard::lseek): Truly implement seeks in clipboard. - (fhandler_dev_clipboard::close): Clear out new fields. Support - sequential reads and sequential writes. Support for binary data via a - native clipboard format. - -2001-03-22 Egor Duda - - * fhandler_console.cc (fhandler_console::set_default_attr): Update - console color attributes on tty reset. - -Wed Mar 21 22:12:36 2001 Christopher Faylor - - * autoload.cc (kernel32_init): New function for kernel32 autoload - initialization. - (SignalObjectAndWait): Add conditional load of this function when it is - available. - -2001-03-21 Robert Collins - - * sched.cc: New file. Implement sched*. - * include/sched.h: New file. User land includes for sched*. - * Makefile.in: Add sched.o - * cygwin.din: Add exports for sched*. - -Tue Mar 20 14:48:46 2001 Christopher Faylor - - * dtable.cc: Guard against new winsock.h/winsock2.h warnings when - mixing winsock*.h and sys/types.h. - * fhandler_socket.cc: Ditto. - * net.cc: Ditto. - * select.cc: Ditto. - * exceptions.cc: Remove unneeded define. - -Mon Mar 19 17:43:29 2001 Christopher Faylor - - * exceptions.cc (interruptible): Update debugging output. - (setup_handler): Ensure that wait_sig loop wakes up when we punt on - sending a signal. - * poll.cc (poll): Add signal guard here. - -2001-03-19 Egor Duda - - * tty.h (tty::create_inuse): Add new parameter to allow non- - inheritable 'inuse' events. - * tty.cc (tty::create_inuse): Use new parameter. - * fhandler_tty.cc (fhandler_tty_master::init): Ditto. - * fhandler_tty.cc (fhandler_pty_master::open): Ditto. - * fhandler_tty.cc (fhandler_tty_master::init): Create master_alive - event. - * tty.cc (tty_list::terminate): Close master_alive event. - * fhandler_tty.cc (fhandler_tty_common::close): Send EOF to slaves - when master side is closed. - -Mon Mar 19 14:32:00 2001 Corinna Vinschen - - * mmap.cc (map::get_list_by_fd): Avoid calling `get_namehash' when - file descriptor is -1. - -Sat Mar 17 18:30:00 2001 Corinna Vinschen - - * syscalls.cc (check_posix_perm): New static function. - (fpathconf): Add _PC_POSIX_PERMISSIONS and _PC_POSIX_SECURITY - support. - (pathconf): Ditto. - * include/cygwin/version.h: Bump API minor number to 37. - -2001-03-18 Egor Duda - - * fhandler.h (fhandler_tty_slave): Declare new methods. - * select.cc (fhandler_tty_slave::select_read): New method. - * select.cc (fhandler_tty_slave::ready_for_read): Ditto. - * select.cc (verify_tty_slave): New function. - * fhandler_termios.cc (fhandler_termios::line_edit): Empty input - buffer on signal. - * fhandler_tty.cc (fhandler_tty_slave::read): Check for input data - after reading from pipe. Reset event if input pipe is empty. - * tty.h (class tty): Allow creating events with manual reset. - * tty.cc (tty::get_event): Use manual_reset flag. - * tty.cc (tty::common_init): Create input_available_event with - manual reset. - -Sat Mar 17 21:48:03 2001 Christopher Faylor - - * external.cc (fillout_pinfo): Match windows pid, as well as cygwin pid - when passed in pid. Don't prematurely break when searching for a pid. - - * thread.h (_winsup_t): Eliminate unneeded field. - -Sat Mar 17 20:46:00 2001 Corinna Vinschen - - * net.cc (get_95_ifconf): Use strcasematch instead of strcasecmp. - * syscalls.cc (_unlink): Ditto. - (_rename): Ditto. - -Sat Mar 17 12:43:15 2001 Christopher Faylor - - * path.cc (suffix_scan::next): Avoid searching for foo.lnk twice when - input is "foo". - -Sat Mar 17 18:10:00 2001 Corinna Vinschen - - * net.cc (cygwin_socket): Set protocol to 0 when address family is - AF_UNIX to avoid WSAEPROTONOSUPPORT error. - -Sat Mar 17 09:51:32 2001 Mathew Brozowski - - * net.cc (cygwin_socket): Pass protocol parameter to socket call. - -Sat Mar 17 02:05:38 2001 Christopher Faylor - - * dir.cc (readdir): Use strcasematch for consistency. - * path.cc (symlink_info): Eliminate known_suffix. - (path_conv::check): Always copy ext_here to end of buffer, if found. - (suffix_scan): Eliminate ext_here, add suffixes_start. - (suffix_scan::has): Eliminate an argument. Reorganize. Always return - pointer to end of input path. - (suffix_scan::next): Take a second pass through the suffix list looking - for .lnk. - (symlink_info::check): Eliminate known_suffix usage. - -Sat Mar 17 00:10:52 2001 Christopher Faylor - - * syscalls.cc (stat_dev): Give devices full read/write by default. - -Saturday Mar 17 3:45 2001 Robert Collins - - * thread.cc (MTinterface::CreateCond): Check for null attr pointer. - -Fri Mar 16 21:13:23 2001 Christopher Faylor - - * fhandler_termios.cc (fhandler_termios::line_edit): Don't accept input - when a signal is sent or we'll end up in an EOF/signal race. - -Fri Mar 16 20:25:40 2001 Christopher Faylor - - * path.cc: Translate scan states from defines to enums. - (suffix_scan): Rename state to nextstate for clarity. - (lnk_match): Change to allow multiple states to indicate that a .lnk - has been matched. - (suffix_scan::has): Eliminate a goto. Handle .lnk as a special case, - since a .lnk may also need to be tacked on the end of a .lnk. - (suffix_scan::next): Don't increment next state. Set it specifically. - Recognize new .lnk states. - -Saturday Mar 17 01:19 2001 Robert Collins rbtcollins@hotmail.com - - * cygwin.din: Export the new functions. - * pthread.cc (pthread_cond_*): Add wrapper functions that call - __pthread_cond* functions. - * thread.cc (__pthread_cond_*): Implement the pthread_cond* functions. - * thread.h: Add new class entries and prototypes for __pthread_cond* - functions. - * include/pthread.h: user land header prototypes for pthread_cond* - functions and related defines. - -Wed Mar 14 16:30:00 2001 Corinna Vinschen - - * environ.cc (parse_options): Use strtok_r instead of strtok. - * security.cc (convert_string_sid_to_sid): Ditto. - (aclfromtext): Ditto. Fix buffer usage. - -Wed Mar 14 10:11:00 2001 Corinna Vinschen - - * path.cc (lnk_suffixes): Remove. - (class suffix_scan): Add `lnk_state' flag. - (suffix_scan::lnk_match): Return state of `lnk_state' now. - (suffix_scan::has): Changed behaviour if file has `.lnk' suffix. - (suffix_scan::next): Set `lnk_state' where appropriate. - (symlink_info::check): Fix a wrong `break'. - * syscalls.cc (chown_worker): Change debug statement to reflect - lchown fix. - (lchown): Call chown_worker with `PC_SYM_NOFOLLOW' instead of - `PC_SYM_IGNORE'. - -Tue Mar 13 13:52:00 2001 Corinna Vinschen - - * fhandler.cc (fhandler_disk_file::fstat): Add correct modes to - symlinks when stat'ing on FAT or FAT32 file systems. - -2001-03-12 Egor Duda - - * fhandler.h (fhandler_termios::fixup_after_exec): New function. - * fhandler_termios.cc (fhandler_termios::fixup_after_fork): New - function. Fixup output handle. - * fhandler_tty.cc (fhandler_tty_common::fixup_after_fork): Output - handle is now fixed up in fhandler_termios::fixup_after_fork(). - -2001-03-12 Egor Duda - - * fhandler.h (fhandler_termios::fhandler_termios): Enable fixup - after fork. - * fhandler_console.cc (fhandler_console::fhandler_console): Fixup - after fork is now enabled in the base class constructor. - -Mon Mar 12 11:19:41 2001 Christopher Faylor - - * mkvers.sh: Include config.h so that DEBUGGING is correctly defined. - -Mon Mar 12 09:47:55 2001 Christopher Faylor - - * spawn.cc (spawn_guts): Don't set EXIT_REPARENTING if parent process - is not a cygwin process (suggested by Jason Gouger - ). - -Sun Mar 11 16:00:58 2001 Christopher Faylor - - * child_info.h: Bump magic number for fork/exec/spawn. - -Sat Mar 10 20:54:47 2001 Christopher Faylor - - * autoload.cc (noload): Use proper method for multiline strings or - newer gcc's complain. - * exceptions.cc (unused_sig_wrapper): Ditto. - * fhandler.h (fhandler_base): Make get_io_handle and friends return - self. - * fhandler_tty.cc (fhandler_pty_common::close_on_exec): Accommodate - DEBUGGING flag to avoid spurious warnings when inheritance is set. - -Sat Mar 10 16:52:12 2001 Christopher Faylor - - * shortcut.c (PATH_ALL_EXEC): Add parentheses to avoid a compiler - warning. - - * exceptions.cc (setup_handler): Clarify debugging message. - * sigproc.cc (proc_subproc): Remove PROC_CHILDSTOPPED test. It is - handled by normal PROC_CLEARWAIT case. - (wait_sig): Eliminate "dispatched" tracking. Remove __SIGCHILDSTOPPED - test. Decrement counter again before jumping out of - InterlockedDecrement loop so that subsequent InterlockedIncrement will - keep the counter at the correctly decremented value and also detect - when there are pending signals. - * sigproc.h: Remove __SIGCHILDSTOPPED element. - (procstuff): Remove PROC_CHILDSTOPPED element. - -Sat Mar 10 15:22:44 2001 Christopher Faylor - - * syscalls.cc (_rename): Set errno to ENOENT when an old path doesn't - exist (from Kazuhiro Fujieda ). Also set EACCES - when directory is not writable. - -Wed Mar 7 15:49:47 2001 Christopher Faylor - - * syscalls.cc (_read): Change definition to return ssize_t to be - consistent with read. - (_write): Change definition to return ssize_t to be consistent with - write. - -Wed Mar 7 01:08:21 2001 Christopher Faylor - - * sigproc.h (sigthread): Declare new methods. Create new winapi_lock - field. - (sigframe:;set): Call get_winapi_lock after frame is set so that signal - handler thread knows not to call SuspendThread. - (sigframe::~sigframe): Release winapi_lock. - * exceptions.cc (sigthread::get_winapi_lock): New method. - (sigthread::release_winapi_lock): New method. - (setup_handler): Use get_winapi_lock to ensure that signalled thread is - not blocked in a Windows API. - - * path.h (path_types): Avoid broken GCC warning. - -Tue Mar 6 14:02:00 2001 Corinna Vinschen - - * path.cc (suffix_scan::has): Change order of conditionals - to allow checking for .lnk suffixes even if in_suffixes is empty. - -Tue Mar 6 13:02:00 2001 Corinna Vinschen - - * autoload.c (cygwin_premain0): Add missing parameter. - * binmode.c (cygwin_premain0): Ditto. - * textmode.c (cygwin_premain0): Ditto. - -Tue Mar 6 12:04:00 2001 Jason Tiller - - * auto_load.cc: Add "GetKeyboardLayout" entry in the list of - Win32 User32.DLL exports to provide. - * fhandler.h (class fhandler_console): Add meta_mask private - member to remember which keystroke modifiers should generate - META. - * fhandler_console.cc (fhandler_console::read): Modify code that - tests a keystroke for a META-escaped key to use the 'meta_mask' - variable. - (fhandler_console::fhandler_console): Add definition for - variable "meta_mask" used to determine if a keystroke should be - preceded by META in the client console stream. Set meta_mask - based on whether or not user's keyboard language is English - - non-English keyboards pass AltGr (right ) unmolested, - whereas English keyboards now interpret left- and right- - as META. - -Mon Mar 5 20:15:00 2001 Corinna Vinschen - - * include/a.out.h: Add copyright hint. - * include/fcntl.h: Ditto. - * include/lastlog.h: Ditto. - * include/memory.h: Ditto. - * include/mntent.h: Ditto. - * include/paths.h: Ditto. - * include/poll.h: Ditto. - * include/syslog.h: Ditto. - * include/termio.h: Ditto. - * include/tzfile.h: Ditto. - * include/arpa/inet.h: Ditto. - * include/asm/byteorder.h: Ditto. - * include/asm/socket.h: Ditto. - * include/asm/types.h: Ditto. - * include/cygwin/if.h: Ditto. - * include/cygwin/mtio.h: Ditto. - * include/cygwin/rdevio.h: Ditto. - * include/cygwin/socket.h: Ditto. - * include/net/if.h: Ditto. - * include/netinet/in.h: Ditto. - * include/netinet/in_systm.h: Ditto. - * include/netinet/ip.h: Ditto. - * include/netinet/ip_icmp.h: Ditto. - * include/netinet/tcp.h: Ditto. - * include/sys/cdefs.h: Ditto. - * include/sys/cygwin.h: Ditto. - * include/sys/ioctl.h: Ditto. - * include/sys/mman.h: Ditto. - * include/sys/mount.h: Ditto. - * include/sys/mtio.h: Ditto. - * include/sys/procfs.h: Ditto. - * include/sys/resource.h: Ditto. - * include/sys/smallprint.h: Ditto. - * include/sys/socket.h: Ditto. - * include/sys/strace.h: Ditto. - * include/sys/syslog.h: Ditto. - * include/sys/sysmacros.h: Ditto. - * include/sys/termio.h: Ditto. - * include/sys/termios.h: Ditto. - * include/sys/uio.h: Ditto. - * include/sys/un.h: Ditto. - * include/sys/utsname.h: Ditto. - * include/sys/vfs.h: Ditto. - * include/sys/wait.h: Ditto. - * regexp/regerror.c: Ditto. - * regexp/regexp.h: Ditto. - * regexp/regmagic.h: Ditto. - -Mon Mar 5 01:25:03 2001 Christopher Faylor - - * dlopen.c (dlopen): Return NULL when name is NULL (suggested by - chrisiasci@aol.com). - - * cygwin.din: Add a new, internally used export - - _check_for_executable. - * dcrt0.cc (dll_crt0_1): Set _check_for_executable for older binaries. - Pass user_data to premain functions. - * fhandler.cc (fhandler_disk_file::open): Only check for executable if - the linked program is interested in the executable bit. - (fhandler_disk_file::check_execable_p): Delete. - * fhandler.h (executable_states): New enumeration of various states of - executable bit caring. - (fhandler_base::set_execable_p): New method. - - * fhandler_termios.cc (fhandler_termios::line_edit): Flag when a signal - has been sent to the tty. Return -1 when this is so. - * fhandler_console.cc (fhandler_console::read): Return -1 when signal - sending character encountered. - - * path.cc (path_conv::check): Record when path refers to a disk device. - Move executable extension check here. - (check_sysfile): Accommodate new EXEC path states. - (has_suffix): Remove. - (next_suffix): Remove. - (class suffix_scan): New clas. - (suffix_scan::has): New method. - (suffix_scan:next): New method. - (symlink_info::check): Use suffix_scan method to control for scanning - for suffixes. - * path.h (path_conv::exec_state): New method. - * perprocess.h: Make "C" friendly. - * include/cygwin/version.h: Define CYGWIN_VERSION_CHECK_FOR_S_IEXEC. - Bump CYGWIN_VERSION_API_MINOR. - * include/sys/cygwin.h: Change premain declarations. - - * winsup.h: Move __cplusplus test to after builtin defines. - -2001-03-04 Egor Duda - - * fhandler.h (class fhandler_tty_common): New mutex and event to - syncronize input on master tty with slave tty. - * fhandler_tty.cc (fhandler_pty_master::accept_input): Use them to - syncronize with slave. - * fhandler_tty.cc (fhandler_tty_slave::read): Use input mutex and - event to syncronize with master. Do not limit amount of data read - from master to vmin value. Interrupt on signal and return already - read data, if any. - * fhandler_tty.cc (fhandler_tty_slave::open): Handle input mutex and - event. - * fhandler_tty.cc (fhandler_tty_common::close): Ditto. - * fhandler_tty.cc (fhandler_tty_common::set_close_on_exec): Ditto. - * fhandler_tty.cc (fhandler_tty_common::fixup_after_fork): Ditto. - * fhandler_tty.cc (fhandler_tty_common::dup): Ditto. - * tty.h (tty::open_input_mutex): New function. - * tty.cc (tty::common_init): Create input mutex and event. - -Fri Mar 2 13:32:00 2001 Corinna Vinschen - - * dir.cc (readdir): Fix creating path in symlink check. - -Fri Mar 2 12:33:00 2001 Corinna Vinschen - - * dir.cc (readdir): Fix shortcut==symlink condition. - * environ.cc: Add extern decl for `allow_winsymlinks'. - (struct parse_thing): Add entry for `[no]winsymlinks'. - * path.cc (symlink): Change to be able to create both, - symlink==shortcut and symlink==systemfile, dependent of - the setting of `allow_winsymlinks'. - * security.cc (cygwin_logon_user): Add debug output. - * shortcut.c: Add defines from path.h. - (has_exec_chars): Copy from path.h. - (check_shortcut): Check for executable file condition if not a - shortcut. - -Thu Mar 1 21:06:07 2001 Christopher Faylor - - * exceptions.cc (sig_handle_tty_stop): Ignore attempts to suspend a - process if started by non-cygwin parent. - -Thu Mar 1 20:48:11 2001 Christopher Faylor - - * select.cc (peek_console): Don't report read_ready on mouse events - unless we are looking for mouse events. - * fhandler.h (fhandler_console::mouse_aware): New method. - -Wed Feb 28 15:10:00 2001 Corinna Vinschen - - * uinfo.cc: Eliminate `#include '. - -2001-02-28 Egor Duda - - * fhandler_floppy.cc (fhandler_dev_floppy::lseek): Determine - drive geometry or partition size to allow seeking from the end of - raw floppy device. Don't allow positioning past the end of media or - to offsets bigger then max off_t. - -2001-02-27 Egor Duda - - * fhandler.h (class fhandler_console): Make all variables that - describe "state" of console to be members of fhandler_console. - default_color is now the color which is set when console recieves - reset command. - * fhandler_console.cc (fhandler_console::fhandler_console): Turn - mouse handling and raw keyboard mode off by default. Initialize - state information. - * fhandler.cc (fhandler_console::set_raw_win32_keyboard_mode): New - function. - * fhandler_console.cc (fhandler_console::set_default_attr): New - function. Reset console attributes to default values. - * fhandler_console.cc (fhandler_console::open): Reset attributes. - * fhandler_console.cc (fhandler_console::get_win32_attr): New function. - Calculate win32-style console attribute based on terminal attributes. - * fhandler_console.cc (fhandler_console::set_cursor_maybe): Use - member variable. - * fhandler_console.cc (fhandler_console::read): If in raw-win32 - keyboard mode, encode win32 keyboard events in \033{x;y;z;t;u;wK - sequences. - * fhandler_console.cc (fhandler_console::dup): Copy all state - information to the dup()ed handle. - * fhandler_console.cc (fhandler_console::scroll_screen): Use current - fill-in attribute. - * fhandler_console.cc (fhandler_console::clear_screen): Ditto. - * fhandler_console.cc (fhandler_console::char_command): Check if we - saw '?' symbol by member variable. Set terminal attributes on \033[Xm - commands. \033[24m - turn off underline mode, \033[27m - turn off - reverse mode, \033[39m - restore default foreground color. - \033[49m - restore default background color. \033[2000h - turn on raw - keyboard mode, \033[2000l - turn off raw keyboard mode. - * fhandler_console.cc (fhandler_console::write): Set attribues to - default values on reset command. - -2001-02-26 Mike Simons - - * times.cc (settimeofday): Replace function stub with working code. - -Mon Feb 26 10:42:00 2001 Corinna Vinschen - - * strace.cc (strace::vprntf): Move prntf functionality to this function - adding an va_list interface to strace. - (strace::printf): Calls strace::vprntf now. - (strace_printf): New function providing an extern "C" interface to - trace output. - * include/sys/strace.h: Make plain C clean. - (class strace): Add `vprntf' method. - -Mon Feb 26 0:10:00 2001 Corinna Vinschen - - * shortcut.c: Remove #include . - -Sun Feb 25 10:32:00 2001 Corinna Vinschen - - * path.cc (symlink): Add a ".lnk" suffix regardless. Add a comment. - -Sun Feb 25 10:18:00 2001 Corinna Vinschen - - * shortcut.c (check_shortcut): Change symlink condition. - -Fri Feb 23 10:42:00 2001 Corinna Vinschen - - * mmap.cc (fhandler_disk_file::mmap): Use `addr' correctly. - * fhandler_mem.cc (fhandler_dev_mem::mmap): Ditto. - -Thu Feb 22 17:09:00 2001 Corinna Vinschen - - * path.cc (symlink): Keep relative paths relative in the DOS - path inside of a shortcut. If that's impossible or the target - path is already absolute save an absolute path. - -Thu Feb 22 15:33:00 2001 Corinna Vinschen - - * cygerrno.h: Revert previous patch. - * errno.cc: Ditto. - * dir.cc: Eliminate `dir_suffixes'. - (opendir): Remove usage of `dir_suffixes'. - (rmdir): Ditto. - * fhandler.cc (fhandler_disk_file::open): Remove usage of - `inner_suffixes'. - * path.cc: Rename `inner_suffixes' to `lnk_suffixes'. - (path_conv::check): Remove usage of `inner_suffixes'. - (symlink): Ditto. - (symlink_info::check): Handle checking for `.lnk' in path_conv - exclusively here. - (chdir): Remove usage of `dir_suffixes'. - * shortcut.c: Eliminate debug_printf lines. - (check_shortcut): Don't set error except on failing ReadFile. - * spawn.cc: Remove ".lnk" from `std_suffixes'. - * syscalls.cc (_unlink): Remove usage of `inner_suffixes'. - Remove ".lnk" from `stat_suffixes'. - (_rename): Add check for renaming a symlink to keep the ".lnk" - suffix after renaming. - -Thu Feb 22 13:38:00 2001 Corinna Vinschen - - * shortcut.c: New file. Provides a C interface to reading of - Windows shortcuts to avoid compiler flag `-fvtable-thunks'. - * shortcut.h: Ditto. - * Makefile.in: Add shortcut.o to DLL_OFILES. - * cygerrno.h: Provide a C interface to `geterrno_from_win_error' for - using in shortcut.c. - * errno.cc (geterrno_from_win_error): Define as extern "C". - * path.cc (struct symlink_info): Remove methods `check_shortcut' and - `check_sysfile'. - (shortcut_header): Move to shortcut.c. - (shortcut_initalized): Ditto. - (create_shortcut_header): Ditto. - (cmp_shortcut_header): Ditto. - (symlink_info::check_shortcut): Ditto. Reorganize as a plain C function. - (symlink_info::check_sysfile): Redefine as a global function using the - same parameter list as `check_shortcut' for clearness. - (symlink_info::check): Change parameter list for calls to - `check_shortcut' and `check_sysfile'. - -Thu Feb 22 12:04:00 2001 Corinna Vinschen - - * fhandler.cc (fhandler_disk_file::open): Use `inner_suffixes' when - resolving real_path. - * path.cc (symlink): Ditto for win32_topath. - -Wed Feb 21 22:41:00 2001 Corinna Vinschen - - * Makefile.in: Add `-lshell32 -luuid' to link pass for new-cygwin1.dll. - * autoload.cc: Add LoadDLLinitfunc for ole32.dll. - Add LoadDLLfuncEx statements for CoInitialize@4, CoUninitialize@0 - and CoCreateInstance@20. - * dir.cc (dir_suffixes): New datastructure. - (readdir): Check for R/O *.lnk files to hide the suffix. - (opendir): Use `dir_suffixes' in path conversion. - (rmdir): Ditto. - * fhandler.cc (fhandler_disk_file::fstat): Add S_IFLNK flag - before calling `get_file_attribute'. Take FILE_ATTRIBUTE_READONLY - into account only if the file is no symlink. - * path.cc (inner_suffixes): New datastructure. - (SYMLINKATTR): Eliminated. - (path_conv::check): Use `inner_suffixes' on inner path components. - (shortcut_header): New global static variable. - (shortcut_initalized): Ditto. - (create_shortcut_header): New function. - (cmp_shortcut_header): Ditto. - (symlink): Create symlinks by creating windows shortcuts. Preserve - the old code. - (symlink_info::check_shortcut): New method. - (symlink_info::check_sysfile): Ditto. - (symlink_info::check): Check for shortcuts. Move code reading - old system attribute symlinks into symlink_info::check_sysfile(). - (chdir): Use `dir_suffixes' in path conversion. - * security.cc (get_file_attribute): Check for S_IFLNK flag. - Force 0777 permissions then. - * spawn.cc (std_suffixes): Add ".lnk" suffix. - * syscalls.cc (_unlink): Use `inner_suffixes' in path conversion. - Check for shortcut symlinks to eliminate R/O attribute before - calling DeleteFile(). - (stat_suffixes): Add ".lnk" suffix. - (stat_worker): Force 0777 permissions if file is a symlink. - -2001-02-21 Egor Duda - - * sigproc.cc (getsem): Make semaphore always non-inheritable. - -Mon Feb 19 22:25:53 2001 Christopher Faylor - - * dcrt0.cc (locale_init): Remove. - -2001-02-15 Kazuhiro Fujieda - - * cygwin.din: Export rand48 functions. - * thread.cc (MTinterface::Init): Remove the initialization of - `reent_data'. - * dcrt0.cc: Add the initalizer to the declaration of `reent_data'. - * include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR to 35. - -2001-02-16 Egor Duda - - * signal.cc (signal): Prohibit setting handlers for SIGKILL and - SIGSTOP - * signal.cc (sigaction): Ditto - * syscalls.cc (_lseek): Return EINVAL on invalid input - -Wed Feb 14 14:54:40 2001 Christophe Iasci - - * dlfcn.cc (dlopen): Do not call LoadLibrary with a NULL pointer, when - the library is not found - -2001-02-14 Egor Duda - - * fhandler_console.cc (fhandler_console::char_command): Ignore unknown - rendition codes in \033[xx;yym control sequences - -Fri Feb 9 23:19:01 2001 Christopher Faylor - - * fork.cc (fork_parent): Return EAGAIN when can't record pid. - * pinfo.h (pinfo::remember): Return value of call to proc_subproc. - * sigproc.cc (proc_subproc): Return error if can't record pid. - -Fri Feb 9 12:17:27 2001 Christopher Faylor - - * syscalls.cc (mknod): Add valid parameters. - -Thu Feb 8 22:09:00 2001 Corinna Vinschen - - * mmap.cc (mmap): Check for reusing a mapping only on MAP_SHARED - and on MAP_PRIVATE|MAP_ANON in the special case of offset 0. - -Thu Feb 8 21:57:00 2001 Corinna Vinschen - - * mmap.cc (class list): Add member `hash'. - (list::list): Initialize `hash'. - (list::get_list_by_fd): Use filepath hash value to get the correct - mapping list if it's not an anonymous mapping. - (map::add_list): Initialize `hash' with filepath hash value. - (mmap): Check for reusing a mapping only on MAP_SHARED. - -Wed Feb 7 18:47:36 2001 Christopher Faylor - - * signal.cc (killpg): Correct first argument. - -Wed Feb 7 22:22:00 2001 Corinna Vinschen - - * autoload.cc: Add LoadDLLinitfunc for iphlpapi.dll. - Add LoadDLLfuncEx statements for GetIfTable@12 and GetIpAddrTable@12. - * fhandler_socket.cc (fhandler_socket::ioctl): Move variable - definitions to the beginning of the function to allow better debugging. - Add handling for SIOCGIFHWADDR, SIOCGIFMETRIC and SIOCGIFMTU. - * net.cc: Include iphlpapi.h. - (get_2k_ifconf): Rewritten. Uses IP Helper API now. - (get_nt_ifconf): Add handling for SIOCGIFHWADDR, SIOCGIFMETRIC - and SIOCGIFMTU. - (get_95_ifconf): Ditto. Renamed from `get_9x_ifconf'. - (get_ifconf): Name loopback `lo' instead of `lo0' as in Linux. - Add handling for SIOCGIFHWADDR, SIOCGIFMETRIC and SIOCGIFMTU. - Call `get_95_ifconf' only on Windows 95, `get_nt_ifconf' only - on Windows NT < Service Pack 3, `get_2k_ifconf otherwise. - * include/asm/socket.h: Add defines for SIOCGIFHWADDR, SIOCGIFMETRIC - and SIOCGIFMTU. - * include/cygwin/if.h: Add `ifr_hwaddr', `ifr_metric' and `ifr_mtu'. - (struct ifreq): Add `ifru_hwaddr'. - -Tue Feb 6 15:04:00 2001 Corinna Vinschen - - * syscalls.cc (stat_worker): Add a check for the special case when - a process creates a file using mode 000 using ntsec. - -Mon Feb 5 17:00:00 2001 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Always add GENERIC_READ access - when opening raw disk devices. - * fhandler_floppy.cc (fhandler_dev_floppy::lseek): Implement bytewise - access. - * fhandler_raw.cc (fhandler_dev_raw::open): Always open raw disk device - binary. - (fhandler_dev_raw::raw_write): Don't drop read buffer content when - writing after read. - -Mon Feb 5 13:30:00 2001 Corinna Vinschen - - * mmap.cc (mmap_record::fixup_map): New method to duplicate - the memory protection in a just forked child. - (mmap): Realign gran_len to page boundary only on anonymous - mapping before saving in the mmap_record. - (munmap): Cleanup code. - (msync): Ditto. - (fixup_mmaps_after_fork): Ditto. Call mmap_record::fixup_map now. - -Thu Feb 1 23:08:29 2001 Christopher Faylor - - * cygheap.cc (creturn): Correctly calculate cygheap_max. - -Wed Jan 31 10:04:58 2001 Christopher Faylor - - * shared.cc (shared_info::initialize): Reduce size of heap. - -Wed Jan 31 13:22:00 2001 Corinna Vinschen - - * include/sys/resource.h: Fix typo. - -Wed Jan 31 13:20:00 2001 Corinna Vinschen - - * include/sys/resource.h: Add RLIMIT_NLIMITS and RLIM_NLIMITS. - -Tue Jan 30 18:15:23 2001 Christopher Faylor - - * include/cygwin/version.h: Bump version to 1.3.0. - -Tue Jan 30 8:55:00 2001 Corinna Vinschen - - * pinfo.cc (pinfo::init): Use INVALID_HANDLE_VALUE instead of - explicit cast (HANDLE) 0xffffffff. - * shared.cc (open_shared): Ditto. - -Mon Jan 29 17:15:22 2001 Bill Hegardt - - * fhandler_serial.cc (raw_write): Use local copy of OVERLAPPED - structure instead of shared structure to fix a race condition between - read/write. - -Mon Jan 29 14:30:00 2001 Corinna Vinschen - - * mmap.cc (mmap): Remove obsolete check for MAP_SHARED|MAP_ANON as - being invalid. - -Mon Jan 29 10:23:00 2001 Corinna Vinschen - - * mmap.cc (mmap_record::find_empty): Fix loop condition. - -Sun Jan 28 19:40:40 2001 Christopher Faylor - - * syscalls.cc (_link): Make sure that newpath does not exist. Set - errno if it does. - -Sun Jan 28 19:29:08 2001 Christopher Faylor - - * cygheap.cc (init_cheap): Don't specify a load address for the heap. - It doesn't work on #!*& Windows 9x. - (cygheap_init): Move GetUserName to memory_init. - * dcrt0.cc (dll_crt0_1): Call new memory_init functin, eliminate call - to heap_init. - * heap.cc (heap_init): Improve error output. - * heap.h: Correct some declarations. - * shared.cc (mount_table_init): Remove. - (memory_init): Renamed from shared_init. Reorganize to accommodate - strange Windows 9x problems with cygheap/heap interaction. - * shared_info.h: Rename shared_init to memory_init. - -Sun Jan 28 01:25:33 2001 Christopher Faylor - - * include/cygwin/version.h: Bump API version. - -Sun Jan 28 01:18:22 2001 Christopher Faylor - - * cygheap.cc (init_cheap): Move username initialization. - (cygheap_init): Here. - * shared_info.h (mount_info): Add a sys_mount_table_counter field. - (shared_info): Ditto. - * path.cc (mount_info::conv_to_win32_path): Check that our mount table - is in sync with the system mount table and reinitialize it if not. - (mount_info::add_reg_mount): Bump sys_mount_table counters if the - system mount table changes. - (mount_info::del_reg_mount): Ditto. - (mount_info::write_cygdrive_info_to_registry): Ditto. - (mount_info::remove_cygdrive_info_from_registry): Ditto. - -Sun Jan 28 00:28:30 2001 Christopher Faylor - - Throughout, change 'cygwin_shared.mount' to 'mount_table'. - * child_info.h (child_info): Move shared_h, console_h to cygheap. Add - mount_h. - * cygheap.h (init_cygheap): Add shared_h, console_h. - * cygheap.cc (init_cheap): Initialize heap at a fixed location after - the shared memory regions. Initialize cygheap->user name here. - * dcrt0.cc (dll_crt0_1): Call getpagesize () to initialize constants. - Remove cygheap_init since it is done in shared_init now. - (_dll_crt0): Initialize mount_h, remove shared_h and console_h - initialization. - * fhandler_console.cc (console_shared_h): Eliminate. - (get_tty_stuff): Use cygheap->console_h rather than console_shared_h. - * heap.cc (heap_init): Use page size constant calculated earlier in - initialization. - * shared.cc: Eliminate cygwin_shared_h. Add cygwin_mount_h. - (mount_table_init): New function for initializing a user mount table. - (open_shared_file_map): Use constant for shared memory region. - Initialize cygheap and mount table here. - (open_shared): Improve debugging output. - (shared_info::initialize): Eliminate call to mount.init. - (shared_terminate): Use cygheap->shared_h. Close cygwin_mount_h. - (open_shared_file_map): Eliminate. - * shared_info.h (mount_info): Add a version field. - (shared_align_past): New macro for calculating location for shared - memory regions. - * sigproc.cc (init_child_info): Eliminate shared_h, console_h. - * spawn.cc (spawn_guts): Pass on cygwin_mount_h iff not a different - user. - * syscalls.cc (system_info): New global holding system memory defaults. - (getpagesize): Use system_info. - * uinfo.cc (internal_getlogin): Only fill in user name if nonexistent. - * winsup.h: Declare system_info. - - * passwd.cc (read_etc_passwd): Use cygheap->user.name () rather than - retrieving the name again. - -Sat Jan 27 10:18:02 2001 Christopher Faylor - - * path.cc (path_conv::check): Detect when path has symlinks. - (symlink_info::check): Remove debugging stuff. - (chdir): Use posix'ized win32 path if cd'ed to a path using symlinks. - -Fri Jan 26 21:20:28 2001 Christopher Faylor - - * exceptions.cc (sigreturn): Call any pending signals prior to - resetting the signal mask so that stacked signals behave correctly. - (sigdelayed): Avoid a race where a signal could end up calling an - incorrect signal handler if two signals come in close together. - -Tue Jan 23 21:56:00 2001 Corinna Vinschen - - * mmap.cc (fhandler_disk_file::mmap): Call CreateFileMapping with - len != 0 only when performing an anonymous mapping. - -Mon Jan 22 15:35:28 2001 Christopher Faylor - - * path.h: Add a new constant. - * syscalls.cc (_read): Oscillate errno check. - -Mon Jan 22 15:27:12 2001 Christopher Faylor - - * include/cygwin/version.h: Bump API to reflect setlogmask. - -Sun Jan 21 22:40:25 2001 Jason Tishler - - * cygwin.din: Add export for setlogmask(). - * syslog.cc (setlogmask): New function. - -Thu Jan 18 10:27:00 2001 Corinna Vinschen - - * resource.cc (setrlimit): Support RLIMIT_NOFILE. - -Wed Jan 17 23:23:12 2001 Christopher Faylor - - * syscalls.cc (setdtablesize): Call with amount to increment not total - amount. Return success or failure error code. - -Wed Jan 17 09:47:13 2001 Christopher Faylor - - * autoload.cc (LoadDLLinitfunc): Remove debugging statement. - - * exceptions.cc (sig_handle_tty_stop): Move setting of PID_STOPPED to - earlier in interrupt. - (interrupt_setup): i.e., here. - (sig_handle): Don't queue multiple SIGSTOPS. - * fhandler.h (bg_check_types): Enumerate return value of bg_check for - clarity. - * signal.cc (kill_pgrp): Minor cleanup. - * fhandler_termios.cc (fhandler_termios::bg_check): Use enumerated type - for function return. Don't raise signal if a signal is already queued. - * fhandler_console.cc (fhandler_console::read): Use enumerated return - type for bg_check. - * select.cc: Ditto, throughout. - * read.cc: Ditto, throughout. - * termios.cc: Ditto, throughout. - (_read): YA interrupt detect simplification. - * wait.cc (wait4): Ditto. - -Wed Jan 17 10:56:00 2001 Corinna Vinschen - - * cygheap.cc (cygheap_user::~cygheap_user): Temporarily - disable free'ing memory. - -Tue Jan 16 18:01:00 2001 Corinna Vinschen - - * mmap.cc (mmap): Initialize fh to avoid compiler warnings. - -Mon Jan 15 21:07:00 2001 Christopher Faylor - - * wait.cc (wait4): Rename variable for consistency. Allow restartable - signal behavior. - -Mon Jan 15 23:15:00 2001 Corinna Vinschen - - * mmap.cc (mmap): Add more parameter checking. Change error output - in case of EINVAL. Treat mmapping /dev/zero like MAP_ANONYMOUS. - -Mon Jan 15 20:34:00 2001 Corinna Vinschen - - * mmap.cc: include . Define some bit operations for - the new page map. - (mmap_record): Change type of base_address_ to caddr_t. - Add map_map_ member. Add several methods to manipulate map_map_. - (mmap_record::alloc_map): New method. - (mmap_record::free_map): Ditto. - (mmap_record::find_empty): Ditto. - (mmap_record::map_map): Ditto. - (mmap_record::unmap_map): Ditto. - (list::add_record): Change return type to `mmap_record *'. - Allocate page map. - (list::match): New method. - (mmap): Partly rewritten to take care for the new page map. Add some - parameter checking. - (munmap): Ditto. - -Mon Jan 15 13:50:00 2001 Corinna Vinschen - - * heap.cc (heap_init): Fix extern declaration of getpagesize. - * syscalls.cc (getpagesize): Fix another typo. - -Mon Jan 15 12:48:00 2001 Corinna Vinschen - - * syscalls.cc (getpagesize): Save pagesize in global variable to - avoid calling GetSystemInfo too often. - * heap.cc (getpagesize): Eliminate. - (heap_init): Use getpagesize function from syscalls.cc. - -Mon Jan 15 11:56:00 2001 Corinna Vinschen - - * sysconf.cc (sysconf): return `getpagesize ()' on _SC_PAGESIZE - request to avoid implementing the same twice. - -Sun Jan 14 14:07:50 2001 Christopher Faylor - - * syscalls.cc (_read): Use more lightweight method for determining if - read has been interrupted by a signal. - -Fri Jan 12 00:35:15 2001 Christopher Faylor - - * debug.h: Add regparm attributes to some functions. - - * signal.cc (sigaction): Don't treat SIGCONT specially. - - * exceptions.cc (interrupt_setup): Save sa_flags of interrupted signal - for later use. - (sig_handler): Default any stopping signal to SIGSTOP. - (call_signal_handler): New function. - (sigdelayed0): New function. - * sigproc.cc (sigproc_init): Initialize SIGSTOP sigaction for special - behavior. - * sigproc.h: Define call_signal_handler. - * syscalls.cc (_read): Allow restartable signal behavior. - -Thu Jan 11 13:17:00 2001 Corinna Vinschen - - * fhandler.h (fhandler_base): New method `fixup_mmap_after_fork'. - (fhandler_disk_file: Ditto. - (fhandler_dev_mem): Ditto. - * fhandler_mem.cc (fhandler_dev_mem::open): Set OBJ_INHERIT attribute - for device\physicalmemory handle. - (fhandler_dev_mem::mmap): Ditto. - * fhandler_mem.cc (fhandler_dev_mem::fixup_mmap_after_fork): New - method. - * mmap.cc (mmap_record): Add private `fdesc_' member. Change - constructor accordingly. - (get_fd): New method. - (mmap): Use new mmap_record constructor. - (fhandler_base::fixup_mmap_after_fork): New method. - (fhandler_disk_file::fixup_mmap_after_fork): Ditto. - (fixup_mmaps_after_fork): Call `fixup_mmap_after_fork' of appropriate - fhandler class. - -Wed Jan 10 22:08:30 2001 Kazuhiro Fujieda - - * sigproc.cc (wait_sig): Allow SIGCONT when stopped. - -Tue Jan 9 16:55:00 2001 Corinna Vinschen - - Patch suggested by René Møller Fonseca - * include/sys/socket.h: Change prototype to have 2nd parameter `const'. - * net.cc (cygwin_bind): Change 2nd parameter to `const'. - -Sun Jan 7 22:59:37 2001 Christopher Faylor - - * pinfo.cc (codepage_init): Move function. - * environ.cc (codepage_init): To here. - * exceptoins.cc (SIG_NONMASKABLE): Remove SIGCONT from consideration - since it is supposed to be maskable. - * signal.cc (sigaction): Ditto. - * sigproc.cc (wait_sig): Ditto. - * winsup.h: Eliminate global declaration of codepage_init. - -Thu Jan 5 9:33:00 2001 Corinna Vinschen - - * resource.cc (getrlimit): Set errno on EFAULT instead of returning - it. - (setrlimit): Ditto. - -Thu Jan 5 3:38:00 2001 David Sainty - - * resource.cc (setrlimit): Prevent failing with an error when the - operation would not have changed anything. - -Thu Jan 4 10:29:54 2001 Earnie Boyd - - * thread.cc: Need LONG_MAX definition. - -Wed Jan 3 13:47:23 2001 Christopher Faylor - - * thread.cc (MTinterface::CreateSemaphore): Correctly set semaphore - max. - -Wed Jan 3 09:44:51 2001 Christopher Faylor - - * fhandler_console.cc (fhandler_console::read): Restore missing test - for code page before doing OemToCharBuff. - -Wed Jan 3 09:20:20 2001 Jason Tishler - - * include/cygwin/version.h: Fix typo in CYGWIN_VERSION_DLL_COMBINED - macro. diff --git a/winsup/cygwin/ChangeLog-2002 b/winsup/cygwin/ChangeLog-2002 deleted file mode 100644 index 21fcf2a18..000000000 --- a/winsup/cygwin/ChangeLog-2002 +++ /dev/null @@ -1,6655 +0,0 @@ -2002-12-30 Christopher Faylor - - * exceptions.cc (events_init): Display name of mutex on failure. - -2002-12-30 Christopher Faylor - - * windows.cc (setitimer): Return ENOSYS on invalid argument. - -2002-12-28 Christopher Faylor - - * fhandler_termios.cc (fhandler_termios::line_edit): Perform echo - before input is accepted or suffer a "race". - -2002-12-27 Christopher Faylor - - * fhandler.h (fhandler_tty_master::set_winsize): Declare new function. - * fhandler_console.cc (fhandler_console::send_winch_maybe): If - appropriate, call tty master function to handle screen size change. - * fhandler_tty.cc (fhandler_tty_master::set_winsize): New function. - (fhandler_tty_master::init): Call set_winsize to set initial screen - size. - -2002-12-26 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_master::init): Set initial size of tty - to that of console in which tty is operating. - (process_input): Semi-revert previous change. Need to just use current - terminfo settings since this function is running in a thread, blocked - when the terminfo changes. - -2002-12-26 Christopher Faylor - - * fhandler.h (fhandler_termios::line_edit): Replace third argument with - passed-in termios struct. - * fhandler_console.cc (fhandler_console::read): Prior to loop, make a - copy of current termios for passing to line_edit prior so that all - characters are processed consistently. - * fhandler_tty.cc (fhandler_pty_master::write): Ditto. - (process_input): Make a copy of curent termios prior to read for use in - subsequent line_edit. - * fhandler_termios.cc (fhandler_termios::line_edit): Replace third - parameter with passed-in termios struct and use it throughout rather - than the data from the current fhandler_termios class. - -2002-12-25 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number. - -2002-12-25 Christopher Faylor - - * exceptions.cc (events_init): Initialize critical section to control - exiting via signal. - (signal_exit): Enter critical section early to avoid exit races with - main thread. - * dcrt0.cc (do_exit): Use exit_lock critical section to avoid races. - -2002-12-25 Christopher Faylor - - * cygthread.cc (cygthread::detach): Set errno with set_sig_errno so - that EINTR is properly restored after signal. - -2002-12-21 Christopher Faylor - - * Makefile.in: Default fhandler objects to -fomit-frame-pointer. - Eliminate redundant CFLAGS settings. - -2002-12-20 Christopher Faylor - - * fhandler.h (line_edit_status): Reorganize so that tests for error - condition can be < or >. - * fhandler_tty.cc (fhandler_pty_master::write): Don't return after - sending a signal. - - * fhandler_termios.cc (fhandler_termios::line_edit): Trivial change to - use built-in bool types. - -2002-12-19 Pierre Humblet - - * localtime.cc (tzsetwall): Set lcl_is_set and lcl_TZname - in the Cygwin specific part of the routine. - -2002-12-19 Pierre Humblet - - * fhandler.cc (fhandler_base::open): Use "flags" rather than "mode" - in Win9X directory code. - -2002-12-19 Steve Osborn - - * fhandler.h (line_edit_status): Add a new element. - * fhandler_termios.cc (fhandler_termios::line_edit): After - accept_input, handle both potential error condition and pipe full - conditions. - * fhandler_tty.cc (fhandler_pty_master::accept_input): Return -1 on - error. - (fhandler_pty_master::write): Handle pipe full condition. - -2002-12-16 Steve Osborn - Christopher Faylor - - * fhandler_termios.cc (fhandler_termios::line_edit): Return - line_edit_error and remove last char from readahead buffer if - accept_input() fails. - * fhandler_tty.cc (fhandler_pty_master::accept_input): Return 0 and - restore readahead buffer when tty slave pipe is full. - -2002-12-16 Christopher Faylor - - * pinfo.cc (_pinfo::cmdline): Allocate sufficient space for myself - command line args. - -2002-12-14 Steve Osborn - - * fhandler_termios.cc (fhandler_termios::line_edit): Call - accept_input() in character processing loop. Set return value - independently of input_done. - -2002-12-14 Christopher Faylor - - * fhandler.cc (fhandler_base::read): Signal event, if necessary, and - raw_read hasn't done so. - -2002-12-14 Christopher Faylor - - * fhandler.cc (fhandler_base::raw_read): Reset priorities to minimize - window where thread termination may cause data loss. - (fhandler_base::read): Always return at end of function. Just set len - to copied_chars when len is zero. Return immediately after raw_read if - len <= 0. Remove in_len setting and just check end instead. Fix CRLF - handling at end of buffer. - -2002-12-14 Corinna Vinschen - - * dcrt0.cc (dll_crt0_1): Call well known SID initializer function. - * security.h (cygsid::init): Declare new static method. - * sec_helper.cc (cygsid::init): New method for initializing well - known SIDs. - -2002-12-14 Pierre Humblet - - * security.h: Declare well_known_creator_group_sid. - * sec_helper.cc: Define and initialize well_known_creator_group_sid. - -2002-12-14 Corinna Vinschen - - * netdb.cc: Remove strtok_r comment. - -2002-12-14 Pierre Humblet - - * security.cc (get_user_local_groups): Use LookupAccountSid to find the - local equivalent of BUILTIN. - -2002-12-14 Christopher Faylor - - * pipe.cc (make_pipe): Set fork fixup flag for read pipe. - -2002-12-14 Christopher Faylor - - * winbase.h: Turn on inline versions of Interlocked* by default. - -2002-12-14 Gary R. Van Sickle - - * winbase.h: Fixup inline asm functions. Add ilockcmpexch. - -2002-12-13 Christopher Faylor - - Throughout, change fhandler_*::read and fhandler_*::raw_read to void - functions whose second arguments are both the length and the return - value. - * fhandler.cc (fhandler_base::read): Rework slightly to use second - argument as input/output. Tweak CRLF stuff. - (fhandler_base::readv): Accommodate fhandler_*::read changes. - * cygthread.h (cygthread::detach): Declare as taking optional handle - argument. - (cygthread::detach): When given a handle argument, wait for the handle - to be signalled before waiting for thread to detach. Return true when - signal detected. - -2002-12-12 Corinna Vinschen - - * Makefile.in: Add MINGW_LDFLAGS when linking cygrun.exe. - -2002-12-10 Christopher Faylor - - * cygthread.h (cygthread::stack_ptr): New element. - (cygthread::detach): Accept a "wait_for_signal" argument. - (cygthread::terminate_thread): New function. - * cygthread.cc (cygthread::stub): Set stack pointer argument. - (cygthread::terminate_thread): New function. Forcibly terminate - thread. - (cygthread::detach): Optionally wait for signals and kill thread when - signal arrives. - * exceptions.cc (signal_exit): Set signal_arrived prior to exiting to - wake up anything blocking on signals. - * fhandler.h (fhandler_base::set_r_no_interrupt): Change to accept bool - argument. - (fhandler_pipe::ready_for_read): Declare. - * pipe.cc (pipeargs): New structure. - (read_pipe): New thread stub wrapper for normal pipe read. - (fhandler_pipe::read): Modify to call reader in a cygthread, - terminating on signal, as appropriate. - * select.cc (fhandler_pipe::ready_for_read): Define new function. - -2002-12-10 Corinna Vinschen - - * net.cc (free_protoent_ptr): Add missing free() for base structure. - (free_servent_pt): Ditto. - (free_hostent_pt): Ditto. - -2002-12-10 Craig McGeachie - - * netdb.cc (parse_alias_list): Change strtok calls to strtok_r. - (parse_services_line): Ditto. - (parse_protocol_line): Ditto. - -2002-12-10 Pierre Humblet - - * pwdgrp.h (pwdgrp_check::pwdgrp_state): Replace by - pwdgrp_check::isinitializing (). - (pwdgrp_check::isinitializing): Create. - * passwd.cc (grab_int): Change type to unsigned, use strtoul and set - the pointer content to 0 if the field is invalid. - (parse_pwd): Move validity test after getting pw_gid. - (read_etc_passwd): Replace "passwd_state <= " by - passwd_state::isinitializing (). - (internal_getpwuid): Ditto. - (internal_getpwnam): Ditto. - (getpwent): Ditto. - (getpass): Ditto. - * grp.cc (parse_grp): Use strtoul for gr_gid and verify the validity. - (read_etc_group): Replace "group_state <= " by - group_state::isinitializing (). - (internal_getgrgid): Ditto. - (getgrent32): Ditto. - (internal_getgrent): Ditto. - -2002-12-10 Pierre Humblet - - * security.h: Move declarations of internal_getgrent, - internal_getpwsid and internal_getgrsid to pwdgrp.h. - * pwdgrp.h: Declare internal_getpwsid, internal_getpwnam, - internal_getpwuid, internal_getgrsid, internal_getgrgid, - internal_getgrnam, internal_getgrent and internal_getgroups. - Delete "emulated" from enum pwdgrp_state. - (pwdgrp_check::isuninitialized): Create. - (pwdgrp_check::pwdgrp_state): Change state to initializing - rather than to uninitialized. - (pwdgrp_read::gets): Remove trailing CRs. - * passwd.cc (grab_string): Don't look for NLs. - (grab_int): Ditto. - (parse_pwd): Don't look for CRs. Return 0 if entry is too short. - (search_for): Delete. - (read_etc_passwd): Simplify tests to actually read the file. - Set state to loaded before making internal_getpwXX calls. - Replace search_for calls by equivalent internal_pwgetXX calls. - (internal_getpwsid): Use passwd_state.isuninitialized to decide - to call read_etc_passwd. - (internal_getpwuid): Create. - (internal_getpwnam): Create. - (getpwuid32): Simply call internal_getpwuid. - (getpwuid_r32): Call internal_getpwuid. - (getpwnam): Simply call internal_getpwnam. - (getpwnam_r): Call internal_getpwnam. - * grp.cc (parse_grp): Don't look for CRs. Adjust blank space. - (add_grp_line): Adjust blank space. - (class group_lock): Ditto. - (read_etc_group): Simplify tests to actually read the file. - Set state to loaded before making internal_getgrXX calls. - Replace getgrXX calls by equivalent internal calls. - (internal_getgrsid): Use group_state.isuninitialized to decide - to call read_etc_group. - (internal_getgrgid): Create. - (internal_getgrnam): Create. - (getgroups32): Simply call internal_getgrgid. - (getgrnam32): Simply call internal_getgrnam. - (internal_getgrent): Call group_state.isuninitialized. - (internal_getgroups): Create from the former getgroups32, using - two of the four arguments. Set gid to myself->gid and username - to cygheap->user.name (). - (getgroups32): Simply call internal_getgroup. - (getgroups): Call internal_getgroup instead of getgroups32. - (setgroups32): Call internal versions of get{pw,gr}XX. - * sec_helper.cc: Include pwdgrp.h. - (is_grp_member): Call internal versions of get{pw,gr}XX. - * security.cc: Include pwdgrp.h. - (alloc_sd): Call internal versions of get{pw,gr}XX. - * syscalls.cc: Include pwdgrp.h. - (seteuid32): Call internal versions of get{pw,gr}XX. - (setegid32): Ditto. - * uinfo.cc: Include pwdgrp.h. - (internal_getlogin): Call internal versions of get{pw,gr}XX. - (cygheap_user::ontherange): Ditto. - * sec_acl.cc: Include pwdgrp.h. - (setacl): Call internal versions of get{pw,gr}XX. - (acl_access): Ditto and simplify logic. - (aclfromtext): Ditto. - -2002-12-09 2002-12-02 Egor Duda - - * lib/pseudo-reloc.c: New file. - * lib/_cygwin_crt0_common.cc: Perform pseudo-relocs during - initialization of cygwin binary (.exe or .dll). - -2002-12-06 Christopher Faylor - - * cygwin.din: Reflect name change from strtodf to strtof. Export - strtof. - * include/cygwin/version.h: Bump API minor number. - -2002-12-04 Steve Osborn - - * fhandler.h (fhandler_termios::line_edit): Change return from an int - to an enum to allow the function to return an error. - * fhandler_console.cc (fhandler_console::read): Update the line_edit - call to use the new enum. - * fhandler_termios.cc (fhandler_termios::line_edit): Change return from - an int to an enum to allow the function to return an error. Put - put_readahead call before doecho for future patch. - * fhandler_tty.cc (fhandler_pty_master::write): Change to call - line_edit one character at a time, and stop if an error occurs. - -2002-12-04 Craig McGeachie - - * netdb.cc: New file. - * Makeile.in (DLL_OFILES): Add reference to the new netdb.cc file. - * cygwin.din : Add new aliased exports for service and protocol - enumerations in netdb.cc. - -2002-12-04 Thomas Pfaff - - * cxx.cc: New file. Implement new, new[], delete and delete[] - operators and __cxa_pure_virtual if compiled by gcc >=3. - * Makefile.in (DLL_OFILES): Add cxx.o. - Remove libstdc++.a from cygwin1.dll link step. - -2002-11-29 Steve Osborn - - * fhandler_tty.cc (fhandler_pty_master::accept_input): Move - read_retval assignment to prevent race condition. Remove read_retval - from return statement. - -2002-11-29 Christopher Faylor - - * pinfo.h (winpids::set): Renamed from init. - (winpids::init): New declaration. - (winpids::cs): Ditto. - (winpids::winpids): Use set rather than init. - * external.cc (fillout_pinfo): Ditto. - * dcrt0.cc (dll_crt0_1): Call winpids::init. - * pinfo.cc (winpids::set): Renamed from init. Wrap calls in critical - section. - (winpids::init): New function. - (winpids::cs): Define. - -2002-11-28 Christopher Faylor - - * sigproc.cc (sig_dispatch_pending): Remove assertion. - -2002-11-27 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number. - -2002-11-27 Mikael Ylikoski - - * fhandler_socket.cc (fhandler_socket::sendto): Fix potential - unitialized value return. - -2002-11-27 Christopher Faylor - - * cygwin.din: Export pthread_getsequence_np. - * include/cygwin/version.h: Bump API minor version. - -2002-11-26 Jason Tishler - - * cygwin.din: Export nl_langinfo(). - * include/cygwin/version.h: Bump API minor version. - -2002-11-26 Christopher Faylor - - * fhandler_tty.cc (fhandler_pty_master::accept_input): Just use a - normal Sleep or suffer amazing pauses when other tty apps are running. - (fhandler_pty_master::process_slave_output): Ditto. - -2002-11-25 Pierre Humblet - - * passwd.cc (read_etc_passwd): Never add an entry when starting - on Win95/98/ME if a default entry is present. - * uinfo.cc (internal_getlogin): Look for the default uid if needed. - Always call user.set_name (). - -2002-11-25 Corinna Vinschen - - * sec_acl.cc (getacl): Set errno to ENOSPC if command is GETACL and - nentries is less than the number of entries in the file's ACL. - -2002-11-24 Corinna Vinschen - - * sec_acl.cc: Fix some formatting. Only set and check `other' bits in - a_perm throughout. Use ILLEGAL_GID id for all entries having no id. - (setacl): Fix inheritance condition. - (getacl): Set all permission bits in CLASS_OBJ and DEF_CLASS_OBJ - entries. Remove DENY bits before returning to calling function. - (acltomode): Fix usage of searchace(). If available, use CLASS_OBJ - to mask GROUP_OBJ permissions. - (aclfrommode): Fix usage of searchace(). If available, set CLASS_OBJ - permissions to same value as GROUP_OBJ permissions. - -2002-11-24 Pierre Humblet - - * sec_acl.cc (getace): Fix the behavior when allow and - deny entries are present in arbitrary order. - (getacl): Report the actual number of entries when - aclbufp is NULL, even if nentries is zero. Fix the mask - reporting, handle the case where the owner and group sids - are equal and streamline the code. - (acl_worker): Take allow_ntsec into account. - -2002-11-05 Thomas Pfaff - - * dcrt0.cc (dll_crt0_1): Add call to pthread::initMainThread to - initialize mainthread when it is safe to call new. - * init.cc (dll_entry): Change call to store reents in tls key. - * thread.cc (_reent_clib) : Change call to get reents from tls - key. - (_reent_winsup): Ditto. - (MTinterface::Init): Key handling changed. Remove initialization - of member variables. - (MTinterface::fixup_after_fork): Reinitialize mainthread object - after fork. Reset threadount to 1. - (pthread::initMainThread): Create mainthread object dynamically. - and initialize with valid handles. - (pthread::self): Remove calls to create thread objects. - (pthread::setTlsSelfPointer): Change call to store thread self - handle in tls key. - (pthread::getTlsSelfPointer): New static method. - (pthread::exit): Remove setTlsSelfPointer call. - (pthread::initCurrentThread): New method. - (pthread::thread_init_wrapper): Change call to store thread self - handle in tls key. - (pthread::join): Check for a valid joiner. - (pthreadNull::pthreadNull): Mark Null object as detached. - (pthreadNull::exit): Terminate thread via ExitThread. - * thread.h (pthread::initMainThread): Change parameter in function - call. - (pthread::getTlsSelfPointer): New static method. - (pthread::initCurrentThread): New method. - (MTinterface::reent_key): Remove. - (MTinterface::thread_self_dwTlsIndex): Ditto.. - (MTinterface::indexallocated): Ditto. - (MTinterface::mainthread): Ditto. - (MTinterface::reent_key): New member. - (MTinterface::thread_self_key): Ditto. - (MTinterface::MTinterface): Initialize all members. - -2002-11-23 Christopher Faylor - - * wait.cc (wait4): Force pending signal delivery before waiting for - process completion. - -2002-11-23 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number. - -2002-11-22 Christopher Faylor - - * exceptions.cc (handle_sigsuspend): Force pending signal delivery - before waiting for signals to happen. - * signal.cc (sleep): Force pending signal delivery before sleeping. - (usleep): Ditto. - (signal): Force pending signal delivery before manipulating signal - stuff. - (sigprocmask): Ditto. - (kill_worker): Ditto. - (abort): Ditto. - (sigaction): Ditto. - * syscalls.cc (readv): Force pending signal delivery before I/O. - (writev): Ditto. - (open): Ditto. - * net.cc: Ditto, throughout. - * sigproc.cc (sig_dispatch_pending): Deliver any pending signals prior - to returning. - - * tty.cc (tty::make_pipes): Increase pipe buffer size. - -2002-11-22 Christopher Faylor - - * include/cygwin/version.h: Fix comment. - -2002-11-21 Igor Pechtchanski - - * external.cc (cygwin_internal): Fix va_arg references. - -2002-11-21 Christopher Faylor - - * exceptions.cc (sigthread::get_winapi_lock): Just do standard 'give up - timeslice' wait. - (setup_handler): Revamp YA to attempt to deliver signal multiple times - on failure rather than punting to wait_sig. - * miscfuncs.cc (low_priority_sleep): Accept INFINITE sleep to mean - "don't reset the priority after setting it to idle". Return previous - priority. - * winsup.h (SLEEP_0_STAY_LOW): Define. - (low_priority_sleep): Return an int. - * sigproc.h: Define WAIT_SIG_PRIORITY here. - * sigproc.cc: Remove WAIT_SIG_PRIORITY definition. - -2002-11-20 Pierre Humblet - - * security.h: Declare internal_getpwsid and internal_getgrsid. - Undeclare internal_getpwent. Define DEFAULT_UID_NT. Change - DEFAULT_GID. - * passwd.cc (internal_getpwsid): New function. - (internal_getpwent): Suppress. - (read_etc_passwd): Make static. Rewrite the code for the completion - line. Set curr_lines to 0. - (parse_pwd): Change type to static int. Return 0 for short lines. - (add_pwd_line): Pay attention to the value of parse_pwd. - (search_for): Do not look for nor return the DEFAULT_UID. - * grp.cc (read_etc_group): Make static. Free gr_mem and set - curr_lines to 0. Always call add_pwd_line. Rewrite the code for the - completion line. - (internal_getgrsid): New function. - (parse_grp): If grp.gr_mem is empty, set it to &null_ptr. - Never NULL gr_passwd. - (getgrgid32): Only return the default if ntsec is off and the gid is - ILLEGAL_GID. - * sec_helper.cc (cygsid::get_id): Use getpwsid and getgrsid. - (cygsid_getfrompw): Clean up last line. - (cygsid_getfromgr): Ditto. - (is_grp_member): Use getpwuid32 and getgrgid32. - * uinfo.cc (internal_getlogin): Set DEFAULT_GID at start. - Use getpwsid. Move the read of /etc/group after the second access - to /etc/passwd. Change some debug_printf. - -2002-11-20 Steven O'Brien - - * poll.cc (poll): ...but set POLLIN instead. - -2002-11-20 Pierre Humblet - - * security.cc (get_attribute_from_acl): Always test "anti", - just in case an access_denied ACE follows an access_allowed. - Handle the case owner_sid == group_sid, with a FIXME. - Remove unnecessary tests for non-NULL PSIDs. - (alloc_sd): Use existing owner and group sids if {ug}id == -1. - Handle case where owner_sid == group_sid. - Do not call is_grp_member. Try to preserve canonical ACE order. - Remove unnecessary tests for non-NULL PSIDs. Reorganize - debug_printf's. - (get_initgroups_sidlist): Put well_known_system_sid on left - side of ==. - (add_access_denied_ace): Only call GetAce if inherit != 0. - (add_access_allowed_ace): Ditto. Use appropriate sizeof. - * syscalls.cc (chown_worker): Pass {ug}id equal to -1 to - alloc_sd, which removes the need to obtain old_{ug}id. - (chmod): Remove call to get_file_attribute (), simply pass - {ug}id equal to -1 to alloc_sd. - -2002-11-20 Corinna Vinschen - - * poll.cc (poll): Don't set POLLERR if a listening socket has a - pending connect. Don't use errno value from call to - fhandler_socket::recvfrom(). - -2002-11-19 Christopher Faylor - - * net.cc: Sprinkle sigframes throughout. - -2002-11-16 Christopher Faylor - - * tty.cc (tty::make_pipes): Make pipe buffer larger. - -2002-11-15 Pierre Humblet - - * grp.cc (getgroups32): Protect against closing cygheap->user.token. - -2002-11-15 Christopher Faylor - - * include/cygwin/version.h: Bump API_MINOR to accommodate below - changes. - -2002-11-14 Sergey Okhapkin - - * cygwin.din (siginterrupt): New export. - * signal.cc (siginterrupt): New. - -2002-11-15 Sergey Okhapkin - - * select.cc (peek_serial): Don't call PurgeComm() to avoid characters - loss. - -2002-11-14 Christopher Faylor - - * exceptions.cc (setup_handler): Add debugging output. Set thread - priority to idle if pending signals to allow other threads to get into - interruptible state. - * miscfuncs.cc (sys_mbstowcs): Save current thread in variable to avoid - an OS call. - * wait.cc (wait_sig): Reset thread priority each time through loop - since the priority may have been set down to deal with pending signals. - -2002-11-14 Christopher Faylor - - * fhandler_serial.cc (fhandler_serial::tcgetattr): Don't take any - special action when vmin_ == 0. - -2002-11-14 Corinna Vinschen - - * grp.cc (getgroups32): Revert previous patch. Use impersonation - token if process is in impersonated state. - * sec_helper.cc (is_grp_member): Rewrite. Call getgroups32 only - for current user. Scan passwd and group info otherwise. - -2002-11-14 Christopher Faylor - - * fhandler_console.cc (fhandler_console::write): Allow characters >= - 0177 to be displayed in the title bar. - -2002-11-14 Corinna Vinschen - - * grp.cc (getgroups32): Don't use access token of current user when - retrieving group info for another user. - -2002-11-13 Christopher Faylor - - * dll_init.cc (dll_list::detach): Eliminate reliance on passed in dll - address. Infer from module of caller instead. - (cygwin_detach_dll): Ignore dll_index argument. - * dll_init.h (dll_list::detach): Reflect argument change above. - -2002-11-13 Christopher Faylor - - * ioctl.cc (ioctl): Always print ioctl results, even when it's a tty. - -2002-11-13 Christopher Faylor - - * winsup.h (low_priority_sleep): Declare. - -2002-11-13 Christopher Faylor - - * miscfuncs.cc (low_priority_sleep): New function. Use throughout - where code is supposed to be giving up time slice. - - * fhandler_console.cc (fhandler_console::read): Switch button 2/3 - output escape sequences to be consistent with xterm. - -2002-11-12 Pierre Humblet - - * syscalls.cc (chmod): Simplify conditional. - * sec_helper (cygsid::getfromstr): Reorganize to remove - calls to strcpy and strtok_r. - (cygsid::getfromgr): Change type to __uid32_t instead of int. - Keep only the allow_ntsec branch. Never call LookupAccountSid - which calls PDCs, simply return -1 in case of failure. - Use cygsid == instead of calling EqualSid and remove test - for NULL psid. - * security.h: Declare cygsid::getfromgr as __uid32_t. - -2002-11-10 Corinna Vinschen - - * net.cc: Run indent. - -2002-11-10 Alexander Gottwald - - * autoload.cc (GetIfEntry): Add symbol. - * net.cc (get_2k_ifconf): Get the interface entries with the GetIfEntry - call intead of the GetIfTable call. Clean-up multiple IP address naming. - -2002-11-09 Sergey Okhapkin - - * fhandler.h (class fhandler_pipe): New ioctl() method. - * pipe.cc (fhandler_pipe::ioctl): New. - -2002-11-07 Christopher Faylor - - * fhandler_serial.cc (fhandler_serial::ioctl): Fix typo. - -2002-11-07 Christopher January - - * include/cygwin/fs.h: New file. - * include/cygwin/hdreg.h: New file. - * fhandler_floppy.cc (fhandler_floppy::ioctl): Add implementation for - HDIO_GETGEO, BLKGETSIZE, BLKGETSIZE64, BLKRRPART and BLKSSZGET ioctls. - -2002-11-07 Gilles Courcoux - - * fhandler_socket.cc (fhandler_socket::ioctl): Return correct flags - for loopback interface when name is given on input instead of address. - -2002-11-07 Jason Tishler - - * cygwin.din: Export fseeko() and ftello(). - * include/cygwin/version.h: Bump API minor version. - -2002-11-06 Christopher Faylor - - * fhandler_console.cc (keytable[]): Revert previous change. It would - break too many things. - -2002-11-06 Christopher Faylor - - * fhandler_console.cc (keytable[]): Redefine F1 - F5 to something a - little more sensical. - -2002-11-06 Sergey Okhapkin - - * syscalls.cc (getutid): Use UT_IDLEN where appropriate. - -2002-11-06 Christopher Faylor - - * include/cygwin/version.h: Bump API minor number for below export. - -2002-11-06 Sergey Okhapkin - - * cygwin.din (pututline): New exported function. - * syscalls.cc (login): Use pututiline(). - (setutent): Open utmp as read/write. - (endutent): Check if utmp file is open. - (utmpname): call endutent() to close current utmp file. - (getutid): Enable all cases, use strncmp() to compare ut_id fields. - (pututline): New. - * tty.cc (create_tty_master): Set ut_pid to current pid. - -2002-11-05 Christopher Faylor - - * fhandler_serial.cc (fhandler_serial::ioctl): Don't try to figure out - if OS has the capability to retrieve RTS/CTS. Just set default values - if DeviceIoControl fails. (suggested by Sergey Okhapkin) - -2002-11-05 Sergey Okhapkin - - * fhandler_serial.cc (fhandler_serial::raw_read): Use correct type for - minchars. - (fhandler_serial::ioctl): Set errno if the ClearCommError fails. - (fhandler_serial::tcsetattr): Use correct value for vmin_. - (fhandler_serial::tcgetattr): Ditto. - -2002-11-05 Thomas Pfaff - - * fhandler_socket.cc (fhandler_socket::recvmsg): Call if from == NULL - WSARecvFrom with fromlen = NULL. - -2002-11-04 Christopher Faylor - - * pinfo.cc (_pinfo::commune_send): Fix thinko in previous checkin. - -2002-11-04 Christopher Faylor - - * pinfo.cc (_pinfo::commune_send): Set priority low when sleeping, - waiting for commune completion so that we don't spin waiting for lower - priority processes. - -2002-11-04 Christopher Faylor - - * sigproc.cc (WAIT_SIG_PRIORITY): Bump to THREAD_PRIORITY_TIME_CRITICAL. - -2002-11-04 Christopher Faylor - - * pinfo.cc (_pinfo::commune_send): Initialize buffer or suffer random - crashes. - -2002-11-04 Christopher Faylor - - * fhandler_process.cc (fhandler_process::fill_filebuf): Deal with error - condition from cmdline retrieval. - -2002-11-04 Christopher Faylor - - * sigproc.cc (WAIT_SIG_PRIORITY): Bump to highest priority. - -2002-11-04 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number. - -2002-11-03 Christopher Faylor - - * fhandler_serial.cc (fhandler_serial::ioctl): Reformat. Set errno - appropriately. Exit from the bottom. Correctly deal with third - argument for TCFLSH. (Suggested by Sergey Okhapkin) - -2003-11-03 Sergey Okhapkin - - * fhandler_tty.cc (fhandler_tty_slave::ioctl): Do nothing if the new - window size is equal to the old one. Send SIGWINCH if slave connected - to a pseudo tty. - (fhandler_pty_master::ioctl): Do nothing if the new window size is - equal to the old one. - -2002-10-31 Pierre Humblet - - * fhandler.cc (fhandler_base::open): Verify pc isn't NULL. - -2002-10-30 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number. - -2002-10-30 Christopher Faylor - - * external.cc (cygwin_internal): Implement CW_CMDLINE. - * pinfo.h (SIGCOMMUNE): New signal type. - (commune_result): New structure for commune functions. - (picom): New enum for commune functions. - (_pinfo::hello_pid): New. Pid who's communicating with me. - (_pinfo::tothem): New. Handle of communicating pipe. - (_pinfo::fromthem): Ditto. - (_pinfo::commune_recv): Declare. - (_pinfo::commune_send): Declare. - (_pinfo::alive): Declare. - (_pinfo::cmdline): Declare. - (_pinfo::lock): Declare. - * pinfo.cc (set_myself): Initialize new _pinfo lock. - (_pinfo::alive): Define. Determines if process still exists. - (_pinfo::commune_recv): Define. Receive info from another cooperating process. - (_pinfo::commune_send): Define. Send info to another cooperating process. - (_pinfo::cmdline): Define. Determine command line of a given process. - * include/sys/cygwin.h (CW_CMDLINE): Define. - - *sigproc.cc (talktome): Communicate with any processes who want to talk - to me. - (wait_sig): Honor __SIGCOMMUNE. - - * fhandler.cc (fhandler_virtual::fixup_after_exec): Declare. - * fhandler_proc.cc: Use malloc/free/realloc throughout rather than - cmalloc since buffers don't need to be propagated to subprocesses. - * fhandler_registry.cc: Ditto. - * fhandler_virtual.cc: Ditto. - (fhandler_virtual::fixup_after_exec): Define. - * fhandler_process.cc: Ditto for malloc/free/realloc. - (process_listin): Add "cmdline". - (fhandler_process::fill_filebuf): Implement PROCESS_CMDLINE. - - * miscfuncs.cc (isalpha_array): New array populated with xor values for - alpha characters to switch from one case to another. - * string.h (cygwin_strcasematch): New asm implementation of case match. - * string.h (cygwin_nstrcasematch): New asm implementation of counted - case match. - -2002-10-24 Pierre Humblet - - * pwdgrp.h (pwdgrp_read::open): Compare fh to INVALID_HANDLE_VALUE. - -2002-10-22 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): Nevermind. - Revert everything to previous state wrt ntsec and exec bits. - -2002-10-22 Christopher Faylor - - * shared.cc (shared_info::initialize): Use correct value for version - comparison. - * include/cygwin/version.h (CYGWIN_VERSION_MAGIC): Use all of a DWORD - for magic calculation. - -2002-10-22 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): Oops. Only - do the executable thing for #! scripts since .exe files wouldn't be - executable in ntsec case regardless. - -2002-10-22 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): Always - consider .exe files and '#!' shell scripts to be executable. - -2002-10-22 Christopher Faylor - - * cygthread.cc (cygthread::exiting): New variable. - (cygthread::initialized): Delete. - (cygthread::stub): Use exiting variable to determine when to exit. - (cygthread::runner): Delete. - (cygthread_protect): New variable. - (cygthread::init): Don't start runner thread. Initialize muto for list - protection. - (cygthread::freerange): Return pointer to cygthread. - (cygthread::operator new): Change logic to start threads on an - as-needed basis. - (cygthread::detach): Don't zero id. - (cygthread::terminate): Don't kill any executing threads. Just set - exiting flag. - * cygthread.h (cygthread): Reflect above changes. - * dcrt0.cc (dll_crt0_1): Move cygthread initialization later. - - * fork.cc (fork_child): Do fdtab fixup after dll fixup or (apparently) - winsock may allocate memory in dll load address. - -2002-10-22 Pierre Humblet - - * sec_helper.cc (cygsid::get_id): If the sid matches a sid stored in - cygheap->user, return the uid or gid from myself. - * security.cc (alloc_sd): If gid == myself->gid, return the group sid - from cygheap->user. Remove the test for uid == original_uid, which is - counter-productive. - -2002-10-22 Christopher Faylor - - * cygheap.cc (cygheap_fixup_in_child): Use user_heap element in - cygheap. - (init_cheap): Ditto for declaration. - * fork.cc (fork_parent): Use user_heap element in cygheap. - * heap.h (inheap): Ditto. - * heap.cc (sbrk): Ditto. - (heap_init): Ditto. Reorganize to shrink heap chunk as required and - record new value in cygheap. - * dcrt0.cc (dll_crt0_1): More "move the cygthread init" games. - * shared.cc (open_shared): Rework memory protection to properly deal - with relocated shared segment. - (shared_info::heap_chunk_size): Rename element to 'heap_chunk'. - * shared_info.h (shared_info): Ditto for declaration. - * strace.cc (strace::hello): Report on heap chunk size from cygheap - since it may shrink. - -2002-10-20 Christopher Faylor - - Change _function() to function() throughout. - * cygwin.din: Remove last vestiges (?) of newlib wrappers. - -2002-10-20 Christopher Faylor - - * cygthread.cc (cygthread::detach): Always wait for event or suffer an - apparently inavoidable race. - * dcrt0.cc (dll_crt0_1): Allocate threads after stack has been - relocated. - * debub.cc (lock_debug): Don't acquire lock on exit. - * fork.cc (fork_child): Recreate mmaps before doing anything else since - Windows has a habit of using blocks of memory in the child that could - previously have been occupied by shared memory in the parent. - * mmap.cc (fhandler_disk_file::fixup_mmap_after_fork): Issue error here - and provide some details about what went wrong. - (fixup_mmaps_after_fork): Remove error message. - * shared.cc (open_shared): Move warning message so that more detail is - possible. - * sigproc.cc (sigproc_init): Initialize sync_proc_subproc to avoid a - race. - (sigproc_terminate): Specifically wait for process thread to terminate. - -2002-10-20 Christopher Faylor - - * cygthread.cc (cygthread::stub): Fix typo. - (cygthread::terminate): Don't zero thread handle prior to using it. - -2002-10-20 Christopher Faylor - - * sigproc.cc (wait_sig): Remove obsolete sigchld logic. - -2002-10-20 Christopher Faylor - - Rename _kill() to kill() throughout. Rename _raise() to raise() - throughout. Rename _pid() to pid() throughout. - * Makefile.in: Compile some objects with -fomit-frame-pointer. - * cygwin.din: Reverse aliasing for _kill. - * syscalls.cc (_getpid_r): New function, implemented for newlib - compatibility. - - * shared.cc (open_shared): Remove reserving of memory since previous - change eliminate the need for this hack. - -2002-10-19 Christopher Faylor - - * fork.cc (fork_child): Move pinfo fixup later to attempt some minor - gains from concurrency with cythread::init. - -2002-10-18 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Initialize cygwin threads here only when not - forking. - * fork.cc (fork_child): Initialize cygwin thread later in process to - avoid allocating memory for thread stacks. - * shared.cc (open_shared): Issue warning if NT and shared segment is - relocated. - -2002-10-18 Christopher Faylor - - * cygthread.cc: Bump number of cygthreads up to accommodate - applications which use ttys. - -2002-10-18 Christopher Faylor - - * fork.cc (fork_child): Move mmap initialization. - * shared.cc (shared_info::heap_chunk_size): Store info as megabytes. - Search HKEY_LOCAL_MACHINE as well as HKEY_CURRENT_USER. - * shared_info.h (shared_info::initial_heap_size): Change element name - to reflect new functionality. - * strace.cc (strace::hello): Report on initial heap size. - -2002-10-18 Thomas Pfaff - - * thread.cc (verifyable_object_isvalid): Test for a valid object - pointer before testing for static ptr. - -2002-10-17 Christopher Faylor - - * dtable.cc (dtable::init_std_file_from_handle): Force "devices" to - always be in binary mode. Temporary fix until ssh is rebuilt? - -2002-10-17 Christopher Faylor - - * dtable.cc (dtable::set_file_pointers_for_exec): New function. - * dtable.h (dtable::set_file_pointers_for_exec): Declare new function. - * spawn.cc (spawn_guts): Call dtable::set_file_pointers_for_exec to set - pointers to EOF when execing non-cygwin applications. - -2002-10-17 Robert Collins - - * thread.h (pthread_mutex::isGoodInitializerOrBadObject): Declare. - * thread.cc (pthread_mutex::isGoodInitializerOrBadObject): Implement. - (pthread_mutex::init): Use isGoodInitializerOrBadObject to avoid - unneeded SEGV's during debugging. - -2002-10-17 Thomas Pfaff - - * thread.cc (verifyable_object_isvalid): Test for static object first. - -2002-10-16 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_slave::read): Attempt #527 to properly - implement VMIN/VTIME. - -2002-10-15 Christopher Faylor - - * shared.cc (open_shared): Revert to "old" method for shared memory - location if !wincap.needs_memory_protection. - * wincap.cc: Implement needs_memory_protection throughout. - * wincap.h: Ditto. - -2002-10-15 Christopher Faylor - - * child_info.h (CURR_CHILD_INFO_MAGIC): Reset. - (child_info_fork::mount_table): Remove. - (child_info_fork::myself_addr): Remove. - * fork.cc (fork_child): Don't set either of the above. - * dcrt0.cc (dll_crt0_1): Call memory_init as early as possible. - * fhandler_console.cc (console_state): Move to shared_info.h. - (fhandler_console::get_tty_stuff): Reflect open_shared arg change. - * pinfo.cc (myself_addr): Remove definition. - (pinfo::init): Get myself address from open_shared. - * pinfo.h (myself_addr): Remove declaration. - * shared.cc (open_shared): Rework so that known shared memory locations - are protected. Take shared memory type as fifth argument. - (memory_init): Reflect open_shared arg change. - * shared_info.h (shared_locations): New enum. - (console_state): Move here. - (open_shared): Reflect open_shared arg change in declaration. - -2002-10-14 Christopher Faylor - - * child_info.h (CURR_CHILD_INFO_MAGIC): Reset. - (child_info_fork::heaptop): Remove obsolete element. - (child_info_fork::heabbase): Ditto. - (child_info_fork::heapptr): Ditto. - (child_info_fork::mount_table): New element. - (child_info_fork::myself_addr): Ditto. - * dcrt0.cc (dll_crt0_1): Set mount_table and myself_addr when forking. - (initial_env): Add newline to "sleeping" message. - * dll_init.cc (reserve_upto): Accommodate cygwin heap when freeing - memory. Make debugging output a little more descriptive. - * fork.cc (fork_parent): Save mount_table and myself_addr. - * pinfo.cc (myself_addr): New variable. - (set_myself): Pass PID_MYSELF flag to init. - (pinfo::init): Honor PID_MYSELF. Save address where myself shared - memory resides in myself_addr, for fork. - * pinfo.h (myself_addr): Declare. - * shared.cc (memory_init): On fork, use previously saved address for - location of mount table. - * include/sys/cygwin.h (PID_MYSELF): New value. - - * dtable.cc (dtable::stdio_init): Don't pass access type to - init_std_file_from_handle. It's always the same. - (dtable::init_std_file_from_handle): Remove access type argument. - Assume read/write. - * dtable.h (dtable::init_std_file_from_handle): Ditto for declaration. - - * exceptions.cc (try_to_debug): Don't try to debug if already being - debugged. - - * fhandler_console.cc (shared_console_info_save): New variable. - (fhandler_console::get_tty_stuff): Save address of shared console stuff - for fork. - -2002-10-13 Christopher Faylor - - * cygthread.cc (cygthread::stub): Reintroduce clearing of __name but do - it before SetEvent to eliminate a race. - (cygthread::terminate): Accumulate list of threads to check for - termination and call WaitForMultipleObjects on list rather than waiting - for each thread individually. - * sigproc.cc (subproc_init): Zap hwait_subproc thread handle since it - is no longer used. - -2002-10-13 Christopher Faylor - - * spawn.cc (spawn_guts): Fix so that cygthread::terminate is *really* - called only for exec. - -2002-10-13 Christopher Faylor - - * cygthread.cc (cygthread::stub): Don't zero __name here. That - introduces a race. - -2002-10-13 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number. - -2002-10-13 Christopher Faylor - - * cygthread.cc (cygthread::stub): Don't create event for long-running - threads. Initialize thread_sync event here which is used to Suspend - using an event rather than relying on SuspendThread/ResumeThread. - (cygthread::init): Save handle to runner thread for future termination. - (cygthread::cygthread): Only resume thread when it is actually - suspended. Otherwise signal thread completion event. - (cygthread::terminate): Forcibly terminate runner thread and any helper - threads. Call DisableThreadLibrary calls if execing. - * cygthread.h (cygthread::thread_sync): Declare. - * dcrt0.cc (do_exit): Eliminate calls to obsolete window_terminate and - shared_terminate. - * exceptions.cc (events_terminate): Don't bother closing title_mutex - since it is going away anyway. - * pinfo.cc (_pinfo::exit): Call cygthread::terminate to ensure that - threads are shut down before process exit or otherwise strange races - seem to occur. - * shared.cc (shared_terminate): Eliminate. - * shared.h (shared_terminate): Eliminate declaration. - * winsup.h (window_terminate): Eliminate declaration. - * spawn.cc (spawn_guts): Call cygthread::terminate early in process if - execing. Call DisableThreadLibrary calls if execing. - * window.cc (Winmain): Call ExitThread to force exit. - (window_terminate): Eliminate. - - * dcrt0.cc (do_exit): Track exit state more closely. - -2002-10-10 Christopher Faylor - - * window.cc (gethwnd): Use SetThreadPriority method. - -2002-10-10 Christopher Faylor - - * Makefile.in (new-cygwin1.dll): Reorganize library order. - - * dcrt0.cc (do_exit): Move thread stuff after vfork stuff or threads - are terminated during vfork. - * sigproc.cc (proc_terminate): Grab proc lock prior to signalling - subproc thread exit to avoid an extra "wait-for-thread-to-exit". - -2002-10-09 Christopher Faylor - - * cygthread.cc (cygthread::stub): Don't create an event for "cygself" - threads. Assume that they exit via an ExitThread call. - * cygthread.h (cygthread::SetThreadPriority): New function. - (cygthread::zap_h): New function. - * dcrt0.cc (do_exit): Move cygthread::terminate earlier and establish - exit_state guard. - * fhandler.h (fhandler_tty_master::output_thread): Delete. - * fhandler_tty.cc (fhandler_tty_master::init): Set priority for threads - via method. Zap handles when done. Don't treat process_output - specially. - (process_output): Call ExitThread directly. - (fhandler_tty_master::fixup_after_fork): Don't worry about - output_thread. - (fhandler_tty_master::fixup_after_exec): Ditto. - * sigproc.cc (proc_terminate): Don't detach from hwait_subproc. Just - let it exit. - (sigproc_init): Close thread handle after initialization. - (wait_sig): Use GetCurrentThread() as SetThreadPriority call rather - than *event* handle. Call ExitThread directly on termination. - (wait_subproc): Call ExitThread directly on termination. - * tty.cc (tty_list::terminate): Don't attempt to detach from - output_thread. - -2002-10-08 Christopher Faylor - - * cygheap.cc (dup_now): Make fatal error a little more informative. - (cygheap_setup_for_child): Detect when default size of shared region is - less than the current size and allocate that much. - (_cbrk): Just return NULL on inability to allocate. - (_cmalloc): Ditto. - * cygheap.h (CYGHEAPSIZE): Change size to reflect newer, tinier - fhandler sizes. - * spawn.cc (av::error): New element, reflects potential errno from cmalloc. - (av::~av): Don't free NULL pointers. - (av::replace0_maybe): Detect out-of-memory conditions. - (av::dup_maybe): Ditto. - (av::dup_all): Ditto. - (av::unshift): Ditto. - (spawn_guts): Set errno and return if argv creation ran into problems. - - * fhandler.h (fhandler_union): Change member names to something safer. - - * fhandler_console.cc (fhandler_console::get_tty_stuff): Always set - fhandler_console::dev_state regardless of whether shared region is - initialized. - - * cygthread.cc (cygthread::runner): Use ExitThread rather than return - (planning for future). - -2002-10-08 Christopher Faylor - - * fhandler.h (dev_console): New class. - (fhandler_console::dev_state): New class element. - (fhandler_console::mouse_aware): Use dev_state element. - (fhandler_console::get_tty_stuff): Declare new function. - * fhandler_console.cc: Use dev_state fhandler_console element, - throughout. - (fhandler_console::get_tty_stuff): Move to fhandler_console class. - Incorporate dev_console information. Move constructor stuff here. - -2002-10-07 Christopher Faylor - - * dtable.cc (dtable::init_std_file_from_handle): Try to mimic standard - open behavior with files redirected from stdin/stdout/stderr, i.e., - fmode settings take precedence over mount settings. - -2002-10-07 Christopher Faylor - - * dtable.cc (unknown_file): New variable. - (dtable::init_std_file_from_handle): Don't set binmode if we couldn't - determine the actual file name on stdin/stdout/stderr. - (handle_to_fn): Return unknown_file when can't determine filename. - -2002-10-07 Christopher Faylor - - * dcrt0.cc (do_exit): Call DisableThreadLibraryCalls since we don't - need to track thread detaches. - * init.cc (dll_entry): Reorganize slightly. Fix api_fatal message. - -2002-10-05 Christopher Faylor - - * cygthread.cc (cygthread::stub): Very minor cleanup. - (cygthread::stub): Report overflows in cygwin thread pool when - DEBUGGING is on and special environment variable is not set. - (cygthread::terminate): Set event only when event actually exists. - * exceptions.cc (signal_exit): Set priority of main thread to low - before setting current thread to high. - -2002-10-01 Robert Collins - - * thread.cc (pthread_key::keys): Copy on fork. Add a comment explaining - why. - (pthreadNull::_instance): Copy on fork. Absolutely no state exists - in pthreadNull. - -2002-09-30 Conrad Scott - - * cygserver_transport_pipes.cc (transport_layer_pipes::accept): - Remove trailing \n from debug_printf. - -2002-09-30 Christopher Faylor - - * thread.cc (pthread_mutex::initMutex): Remove \n from api_fatal. - -2002-09-30 Christopher Faylor - - * thread.cc (pthread::precreate): Use explicit "no inherit" option when - creating mutex. - (pthread_mutex::nativeMutex::init): Ditto. - -2002-09-30 Christopher Faylor - - * thread.cc (pthread_key::keys): Do not copy on fork. - (pthread_mutex::mutexInitializationLock): Ditto. - (pthreadNull::_instance): Ditto. - -2002-09-30 Christopher Faylor - - * exceptions.cc (unused_sig_wrapper): Still need additional level of - indirection when setting errno. - -2002-09-30 Robert Collins - - * thread.cc (pthread_mutex::initMutex): Use the wrapper init call. - (pthread_mutex::nativeMutex::init): Implement. - (pthread_mutex::nativeMutex::lock): Ditto. - (pthread_mutex::nativeMutex::unlock): Ditto. - (pthread_mutex::init): Use the wrapper lock and unlockcalls. - * thread.h (pthread_mutex): Move mutexInitializationLock into a - nativeMutex wrapper class. - -2002-09-30 Christopher Faylor - - Remove \n from calls to strace class printfs throughout. - -2002-09-30 Christopher Faylor - - * exceptions.cc (unused_sig_wrapper): Accommodate newer compilers. - -2002-09-29 Christopher Faylor - - * security.cc (allow_ntsec): Default to zero. - * environ.cc (environ_init): Set allow_ntsec to TRUE by default, - assuming OS allows it. - -2002-09-29 Christopher Faylor - - * environ.cc (environ_init): Avoid a compiler warning. - * path.cc (path_conv::check): Ditto. - * path.h (path_conv::operator int): Ditto. - * regex/engine.c: Ditto throughout. - * regex/regcomp.c: Ditto throughout. - * regex/regexec.c: Ditto throughout. - -2002-09-29 Christopher Faylor - - * thread.cc: Use "%E" in *_printf throughout rather than calling - GetLastError. GNUify comments. - (__pthread_mutex_lock): Don't return error on EBUSY since that just - means that the mutex has already been initialized. - -2002-09-30 Robert Collins - - * pthread.cc (pthread_mutex_init): Use new pthread_mutex::init. - * thread.cc: Change __pthread_mutex_init to pthread_mutex::init - throughout. - (MTinterface::Init): Initialise pthread_mutex support. - (pthread_mutex::mutexInitializationLock): Instantiate. - (pthread_mutex::initMutex): New method. - (__pthread_cond_dowait): Don't dereference untrusted pointers. - Use the new pthread_mutex::init method. - (__pthread_condattr_init): Don't dereference untrusted pointers. - (__pthread_mutex_init): Rename to pthread_mutex::init. - Lock and release mutexInitializationLock to prevent races on - mutex initialisation. - * thread.h (pthread_mutex::initMutex): New method, initialise - pthread_mutex supporting state on process initialisation. - (pthread_mutex::init): Initialise a single mutex. - (pthread_mutex::mutexInitializationLock): A win32 mutex for - syncronising pthread mutex initialisation. - (__pthread_mutex_init): Remove this. - -2002-09-28 Christopher Faylor - - * thread.h (verifyable_object:~verifyable_object): Make virtual. - -2002-09-28 Christopher Faylor - - * cygthread.h (cygthread::terminate): Declare new function. - (cygthread::initialized): Change to 'int'. - * cygthread.cc (cygthread::stub): Exit thread if initialized < 0. - (cygthread::new): Ditto. - (cygthread::runner): Ditto. Set initialized using xor to preserve - sign. - (cygthread::terminate): New function. - * dcrt0.cc (do_exit): Call cygthread::terminate. - -2002-09-27 Robert Collins - - * thread.cc (pthread_key::run_destructor): Run_destructor is not - const as it needs to set the key value. - * thread.h (pthread_key::run_destructor): Ditto. - -2002-09-27 Robert Collins - - * thread.cc (pthread_key::run_destructor): Follow opengroup algorithm. - I.e. only run the destructor NON-NULL key values, and reset the key - to NULL before running the destructor. Reported by Thomas Pfaff. - -2002-09-25 Christopher Faylor - - * cygrun.c (main): Fix setting of CYGWIN environment variable. - - * Makefile.in: Remove linking of unnecessary libraries. - -2002-09-24 Christopher January - - * fhandler_proc.cc (format_process_stat): make ctty a real device - number. - (format_process_status): use effective uid/gid as real and saved - uid/gid. - -2002-09-24 Corinna Vinschen - - * errno.cc (errmap): Map ERROR_INVALID_ADDRESS to new errno code - EOVERFLOW. - (_sys_errlist): Add entries for EILSEQ and EOVERFLOW. - (strerror): Ditto. - * mmap.cc (map_map): Set errno in case of error. - (mmap64): Remove setting errno explicitely to ENOMEM. - -2002-09-24 Corinna Vinschen - - * mmap.cc (map_map): Add debug output. - (mmap64): Evaluate gran_len correctly even if offset isn't 0. - -2002-09-22 Christopher Faylor - - More GNUify non-GNU formatted functions calls throughout. - -2002-09-22 Christopher Faylor - - * Makefile.in (DLL_O_FILES): Restore formatting. - -2002-09-22 Conrad Scott - - GNUify non-GNU formatted functions calls throughout. - -2002-09-22 Conrad Scott - - * cygserver_shm.cc (with_strerr): Remove macro. - (server_shmmgr::segment_t::~segment_t): Remove calls to with_strerr. - (server_shmmgr::segment_t::attach): Ditto. - (server_shmmgr::new_segment): Ditto. - * shm.cc (with_strerr): Remove macro. - (client_shmmgr::shmdt): Remove calls to with_strerr. - (client_shmmgr::attach): Ditto. - -2002-09-22 Conrad Scott - - * include/sys/ipc.h: Move to "include/cygwin/ipc.h". - * include/sys/msg.h: Move to "include/cygwin/msg.h". - * include/sys/sem.h: Move to "include/cygwin/sem.h". - * include/sys/shm.h: Move to "include/cygwin/shm.h". - * include/cygwin/ipc.h: New file. - * include/cygwin/msg.h: Ditto. - * include/cygwin/sem.h: Ditto. - * include/cygwin/shm.h: Ditto. - * cygserver_shm.h: Update includes. - * msg.cc: Ditto. - * sem.cc: Ditto. - -2002-09-22 Conrad Scott - - * safe_memory.h (safe_delete): Make a templated function. - * cygserver.cc (~server_request): Update use of safe_delete. - (main): Ditto. - * cygserver_client.cc (client_request::handle_request): Ditto. - (client_request::make_request): Ditto. - * cygserver_process.cc (~process_cleanup): Ditto. - (process::remove): Ditto. - (process::cleanup): Ditto. - (process_cache::process): Ditto. - * cygserver_shm.cc (server_shmmgr::segment_t::detach): Ditto. - (server_shmmgr::delete_segment): Ditto. - * shm.cc (client_shmmgr::shmdt): Ditto. - * threaded_queue.cc (~threaded_queue): Ditto. - (threaded_queue::worker_loop): Ditto. - -2002-09-22 Conrad Scott - - * safe_memory.h: Replace #include with an explicit - definition of the placement new operator. - (safe_delete): Remove unnecessary ## operator. - -2002-09-22 Conrad Scott - - * cygserver_shm.cc (class server_shmmgr): Remove `cleanup_t' - friend declaration. - (cleanup_t::cleanup_t): Use the segment's shmid as the key rather - than the segment pointer itself. - (cleanup_t::segptr): Remove method. - (cleanup_t::shmid): New method. - (cleanup_t::cleanup): Update for new key value. - (server_shmmgr::find (segment_t *)): Remove method. - * include/cygwin/cygserver_process.h (cleanup_routine::key): Make - method const. - -2002-09-22 Conrad Scott - - * include/cygwin/cygserver_process.h - (cleanup_routine::_key): New field. - (cleanup_routine::cleanup_routine): Initialise new field with new - argument. - (cleanup_routine::operator==): New method. - (cleanup_routine::key): New method. - (cleanup_routine::cleanup): Make argument non-const. - (process::is_active): New method. - (process::remove): Ditto. - (process::check_exit_code): Rename method. - * cygserver_process.cc (process::add): Reorganize code. - (process::remove): New method. - (process::check_exit_code): Rename method. - (process::cleanup): Use new `process::is_active' method. - (process_cache::process): Ditto. - (process_cache::sync_wait_array): Ditto. - (process_cache::check_and_remove_process): Ditto. - * cygserver_shm.cc (server_shmmgr): Make `cleanup_t' a friend. - (segment_t::detach): Make argument non-const. Remove cleanup - object from client if appropriate. - (cleanup_t::_segptr): Remove field. - (cleanup_t::cleanup_t): Initialise parent explicitly. Remove - field. - (cleanup_t::segptr): New method. - (cleanup_t::cleanup): Add error checking and reporting. - (server_shmmgr::shmdt): Make argument non-const. - (server_shmmgr::find (segment_t *)): New method. - -2002-09-22 Conrad Scott - - * cygserver.cc (client_request_shutdown::client_request_shutdown): - Comment out verbose tracing statement. - * cygserver_client.cc - (client_request_get_version::client_request_get_version): Ditto. - (client_request_attach_tty::client_request_attach_tty): Ditto. - * cygserver_shm.cc (client_request_shm::client_request_shm): - Ditto. - -2002-09-22 Conrad Scott - - * cygserver_transport_pipes.cc (transport_layer_pipes::listen): - Set `_is_listening_endpoint' appropriately. - -2002-09-22 Conrad Scott - - * include/cygwin/cygserver_transport.h - (transport_layer_base::listen): Change return type. - (transport_layer_base::connect): Ditto. - * include/cygwin/cygserver_transport_pipes.h - (transport_layer_pipes::listen): Change return type. - (transport_layer_pipes::connect): Ditto. - (transport_layer_pipes::_sec_none_nih): Remove unused field. - (transport_layer_pipes::_is_listening_endpoint): New field. - * cygserver_transport_pipes.cc: Synchronize with sockets code. - (transport_layer_pipes::transport_layer_pipes): Initialise new - field. Separate out asserts. - (transport_layer_pipes::listen): Change return type. Add asserts. - (transport_layer_pipes::accept): Add asserts. - (transport_layer_pipes::read): Change conditional to an assert. - Add assert. - (transport_layer_pipes::write): Ditto. - (transport_layer_pipes::connect): Change return type. Change - conditional to an assert. Add asserts. Rationalize error code - slightly. - (transport_layer_pipes::impersonate_client): Add asserts. - * include/cygwin/cygserver_transport_sockets.h - (transport_layer_sockets::listen): Change return type. - (transport_layer_sockets::connect): Ditto. - (transport_layer_sockets::_addr): Change type of field. - (transport_layer_sockets::_addr_len): Ditto. - (transport_layer_sockets::_is_accepted_endpoint): New field. - (transport_layer_sockets::_is_listening_endpoint): Ditto. - * cygserver_transport_sockets.cc - (MAX_CONNECT_RETRY): New constant. - (transport_layer_sockets::transport_layer_sockets): Initialise new - fields. Only initialise the socket address where necessary. - (transport_layer_sockets::listen): Change return type. Rewrite. - (transport_layer_sockets::accept): Add asserts. Add tracing - statements. Use a local variable to hold the accepted address. - (transport_layer_sockets::close): Add tracing statements. Unlink - the UNIX domain socket file as appropriate. Close the socket - cleanly. - (transport_layer_sockets::read): Rewrite method. - (transport_layer_sockets::write): Ditto. - (transport_layer_sockets::connect): Change return type. Rewrite. - * cygserver.cc (server_submission_loop::request_loop): Run the - listening thread at high priority with special handling for - shutdown. - (main): Print the request error code rather than errno in shutdown - request code. Install signal handlers with sigaction(2) to avoid - setting SA_RESTART. Check value of the listen method call, now it - has one. - * cygserver_client.cc (client_request::make_request): Check new - return value on connect method call. - -2002-09-22 Conrad Scott - - * include/cygwin/cygserver_transport_pipes.h - (cygserver_transport_pipes::_sd): Rename field. - (cygserver_transport_pipes::_sec_none_nih): Ditto. - (cygserver_transport_pipes::_sec_all_nih): Ditto. - (cygserver_transport_pipes::_pipe_name): Ditto. - (cygserver_transport_pipes::_hPipe): Ditto. - (cygserver_transport_pipes::_is_accepted_endpoint): Ditto. - * cygserver_transport_pipes.cc - (transport_layer_pipes::transport_layer_pipes): Rename fields. - (transport_layer_pipes::init_security): Ditto. - (transport_layer_pipes::listen): Ditto. - (transport_layer_pipes::accept): Ditto. - (transport_layer_pipes::close): Ditto. - (transport_layer_pipes::read): Ditto. - (transport_layer_pipes::write): Ditto. - (transport_layer_pipes::connect): Ditto. - (transport_layer_pipes::impersonate_client): Ditto. - (transport_layer_pipes::revert_to_self): Ditto. - * include/cygwin/cygserver_transport_sockets.h - (cygserver_transport_sockets::_fd): Rename field. - (cygserver_transport_sockets::_addr): Ditto. - (cygserver_transport_sockets::_addr_len): Ditto. - * cygserver_transport_sockets.cc - (transport_layer_sockets::transport_layer_sockets): Rename fields. - (transport_layer_sockets::listen): Ditto. - (transport_layer_sockets::accept): Ditto. - (transport_layer_sockets::close): Ditto. - (transport_layer_sockets::read): Ditto. - (transport_layer_sockets::write): Ditto. - (transport_layer_sockets::connect): Ditto. - -2002-09-22 Conrad Scott - - * cygserver_shm.cc (with_strerr): Fix use of %p format. - * shm.cc (client_shmmgr::shmat): Ditto. - (client_shmmgr::shmctl): Ditto. - (client_shmmgr::shmdt): Ditto. - (client_shmmgr::attach): Ditto. - -2002-09-22 Christopher Faylor - - * woutsup.h (system_printf): Remove extraneous semicolon from macro - definition. - -2002-09-22 Conrad Scott - - * cygserver_transport_pipes.cc - (transport_layer_pipes::connect): Use ProtectHandle in DLL code. - (transport_layer_pipes::close): Use ForceCloseHandle in DLL code. - -2002-09-22 Nicholas Wourms - - * threaded_queue.h (class queue_submission_loop): Correct friend - declaration for GCC 3.1.1. - * include/cygwin/cygserver_process.h (class process): Ditto. - (class process_cache): Ditto. - -2002-09-22 Conrad Scott - - * cygserver_shm.cc (server_shmmgr::shmdt): Only call - delete_segment if the segment exists [sic]. - -2002-09-22 Conrad Scott - - * safe_memory.h: Include rather than for gcc 3. - -2002-09-22 Conrad Scott - - * safe_memory.h: New file extracted from "woutsup.h". - * woutsup.h: Move the "safe" new/delete macros into the new - "safe_memory.h" header file and include that here. - * cygserver_client.cc: Explicitly include "safe_memory.h" for - client-side code. - (client_request::make_request): Use the "safe" new/delete macros - unconditionally, i.e. use them on the client side as well as on - the server side. - * cygserver_transport.cc: Explicitly include "safe_memory.h" for - client-side code. - (create_server_transport): Use the "safe" new/delete macros - unconditionally, i.e. use them on the client side as well as on - the server side. - * shm.cc: Include "safe_memory.h". - (client_shmmgr::instance): Use the "safe" new/delete macros. - (client_shmmgr::shmdt): Ditto. - (client_shmmgr::new_segment): Ditto. - -2002-09-22 Conrad Scott - - * cygserver_process (process::process): Add the client's cygpid - and winpid to all tracing statements as appropriate. - (process::exit_code): Ditto. - (process_cache::check_and_remove_process): Ditto. - * cygserver_shm.cc (server_shmmgr::shmat): Ditto. - (server_shmmgr::shmdt): Ditto. - (server_shmmgr::shmctl): Add a process object argument and remove - the explicit cygpid argument. Add the client's cygpid and winpid - to all tracing statements as appropriate. - (server_shmmgr::shmget): Ditto. - (client_request_shm::serve): Update for the new signature of the - shmctl and shmget methods. - -2002-09-22 Conrad Scott - - * cygserver.cc (client_request_shutdown::serve): Don't set the - shutdown flag directly, but send a SIGINT, as the signal handler - sets the flag and the signal breaks the pause(2) in the main loop. - (print_usage): Add new options. - (main): Add new --cleanup-threads and --request-threads options to - set the number of threads used by the daemon. Use pause(2) rather - the win32 Sleep in the main loop. - * shm.cc (shmat): Add sigframe. - (shmctl): Ditto. - (shmdt): Ditto. - (shmget): Ditto. - -2002-09-22 Conrad Scott - - * cygserver_shm.cc: Automatically detach processes from any - segments they are attached to at exit. - (class server_shmmgr::attach_t): New class. - (server_shmmgr::segment_t::IS_DELETED): Rename and make private. - (server_shmmgr::segment_t::_sequence): Make private. - (server_shmmgr::segment_t::_flg): Ditto. - (server_shmmgr::segment_t::_hFileMap): Ditto. - (server_shmmgr::segment_t::_attach_head): New private field. - (server_shmmgr::segment_t::segment_t): Initialise new fields. - Make non-inline. - (server_shmmgr::segment_t::~segment_t): New method. - (server_shmmgr::segment_t::is_deleted): Ditto. - (server_shmmgr::segment_t::is_pending_delete): Ditto. - (server_shmmgr::segment_t::mark_deleted): Ditto. - (server_shmmgr::segment_t::attach): Ditto. - (server_shmmgr::segment_t::detach): Ditto. - (server_shmmgr::segment_t::find): Ditto. - (class server_shmmgr::cleanup_t): New class. - (server_shmmgr::_shm_atts): New private field. - (server_shmmgr::shmat): Add a process object argument to replace - the removed process_cache, cygpid and winpid arguments. Remove - the process_cache manipulations. Move body of code to the - segment_t::attach method. Increment _shm_atts when required. - Update tracing statements. - (server_shmmgr::shmdt): Add a process object argument to replace - the removed cygpid argument. Move body of code to the - segment_t::detach method. Decrement _shm_atts when required. - Update tracing statements. - (server_shmmgr::shmget): Use the new segment_t::is_deleted method. - (server_shmmgr::server_shmmgr): Initialise the new _shm_atts - field. - (server_shmmgr::delete_segment): Remove the CloseHandle code, as - this is now done in the segment_t destructor. - (client_request_shm::serve): Look up the client's process object - and pass to the server_shmmgr::shmat and server_shmmgr::shmdt - methods rather than passing the cache, winpid and cygpid. - * cygserver_process.h: Add a cygpid to the process object to make - it more useful and then pass process objects rather than winpids - where possible. - (cleanup_routine::cleanup): Change argument to be a pointer to a - process object. - (class process): Re-order fields for no discernible reason. - (process::_cygpid): New field. - (process::process): Add a cygpid argument. - (process::winpid): New method. - (process::cygpid): Ditto. - (process::add): Make public, as it always should have been. - (process_cache::process): Add a cygpid argument. - * cygserver_process.cc (process::process): Add a cygpid argument - and use it to initialise the `_cygpid' field. Re-order - initialisers to match new field order. - (process::cleanup): Pass `this' rather than just the winpid to - cleanup_routine::cleanup. - (process_cache::process): Add a cygpid argument and pass it to the - process object constructor. - * include/sys/shm.h (shmatt_t): Make unsigned as per SUSv3. - (shm_info::shm_atts): New field. - -2002-09-22 Conrad Scott - - * cygserver_shm.cc (class server_shmmgr::segment_t): Add `_' - prefix to the names of all fields. - -2002-09-22 Conrad Scott - - * msg.cc: New file of stub functions, no functionality. - * sem.cc: Ditto. - * shm.cc (client_shmmgr::shmctl): Add support for an out shm_info - buffer for the SHM_INFO command. - (client_shmmgr::shmget): Use %X to print keys. - * include/sys/ipc.h: Comment all fields and values. - (IPC_PRIVATE): Change to be non-negative. - * include/sys/msg.h: New file with SUSv3 and ipcs(8) interfaces. - * include/sys/sem.h: Ditto. - * include/sys/shm.h: Comment all fields and values. - (struct shm_info): New struct. - * cygserver_shm.h (client_request_shm::shminfo): Rename. - (client_request_shm::shm_info): New method. - (client_request_shm::_parameters.out.hFileMap): Move into union. - (client_request_shm::_parameters.out.shminfo): Rename. - (client_request_shm::_parameters.out.shm_info): New field. - * cygserver_shm.cc (server_shmmgr::_shm_ids): Rename. - (server_shmmgr::_shm_tot): New field. - (server_shmmgr::shmctl): Rename `out_shminfo' argument. Add - `out_shm_info' argument. Fill in the `out_shm_info' argument in - the SHM_INFO command. - (server_shmmgr::shmget): Check `shmflg' against the mode of - existing segments as per Stevens 1990, p. 123. - (server_shmmgr::server_shmmgr): Initialise the new `_shm_tot' - field. - (server_shmmgr::new_segment): Set ENOMEM if CreateFileMapping - fails. Pass `size' to new_segment. - (server_shmmgr::new_segment): Add size argument and use it to - check against and update the new `_shm_tot' field. - (server_shmmgr::delete_segment): Update the new `_shm_tot' field. - * Makefile.in (DLL_OFILES): Add new DLL object files. - -2002-09-22 Conrad Scott - - * cygserver_transport_pipes.cc: The main change is to make the - client try harder to connect to the server if it's previously - connected, and so has good grounds for believing that the server - is running. - (MAX_WAIT_NAMED_PIPE_RETRY): Change to be an enumerator. - (WAIT_NAMED_PIPE_TIMEOUT): Ditto. - (transport_layer_pipes::accept): Use interlocked operators on - `pipe_instance'. - (transport_layer_pipes::close): Rearrange so that FlushFileBuffers - and DisconnectNamedPipe are only called for accepted endpoints. - Use interlocked operators on `pipe_instance'. - (transport_layer_pipes::read): Use set_errno where required. - (transport_layer_pipes::write): Ditto. - (transport_layer_pipes::connect): Add local static variable - `assume_cygserver'. Set it if a connection is made to cygserver, - clear it if a connection is not made even after retrying. If set, - ignore all errors from CreateFile and retry the connection. Catch - the situation where WaitNamedPipe fails to wait [sic] and add a - `Sleep (0)' so that the server gets a chance to run. - -2002-09-22 Conrad Scott - - * dcrt0.cc: Only check for cygserver if and when required. - (dll_crt0_1): Remove call to `cygserver_init ()'. - * fhandler_tty.cc (fhandler_tty_slave::open): Change the cygserver - logic to allow for the fact that `cygserver_init ()' may not yet - have been called. - (fhandler_tty_slave::cygserver_attach_tty): Tweak the cygserver - request logic to conform to the practice elsewhere in the code. - * tty.cc (tty::common_init): Add an explicit call to - `cygserver_init ()' if it hasn't already been called. - * include/cygwin/cygserver.h (CYGSERVER_UNAVAIL): Rename from - `CYGSERVER_DEAD'. - (client_request_get_version::check_version): Make available in - cygserver as well the DLL. - (check_cygserver_available): Ditto. Remove `check_version_too' - argument. - (cygserver_init): Ditto. And likewise. - * cygserver_client.cc (client_request_get_version::check_version): - Make available in cygserver as well the DLL. - (client_request::make_request): This may now be called without - `cygserver_init ()' having been called first. Detect this and - call it as required. Add tracing. - (check_cygserver_available): Make available in cygserver as well - the DLL. Remove `check_version_too' argument and always check the - version information. And since this is called from within - `cygserver_init ()', force `cygserver_running' before calling - `client_request::make_request ()'. - (cygserver_init): Make available in cygserver as well the DLL. - Remove `check_version_too' argument. - -2002-09-22 Conrad Scott - - * cygserver_shm.cc: Implement the ipcs(8) interfaces, IPC_INFO, - SHM_STAT and SHM_INFO. - (server_shmmgr::segment_t::sequence): New static field. - (server_shmmgr::segment_t::key): Remove field, use the new - ds.shm_perm.key field instead. - (server_shmmgr::segment_t::shmid): Remove field. - (server_shmmgr::segment_t::intid): New field. - (server_shmmgr::segment_t::segment_t): Use the `key' argument to - initialise `ds.shm_perm.key'. Change from using `shmid' to - `intid'. - (server_shmmgr::_shmseg_cnt): Renamed from `_shmid_cnt'. - (server_shmmgr::_intid_max): Renamed from `_shmid_max. - (server_shmmgr::shmat): Move the out arguments to the start of the - argument list. Rename the `pid' argument as `cygpid'. Add - tracing. Pass an intid to `find ()', not a shmid. - (server_shmmgr::shmctl): Add separate out arguments. Rename the - `pid' argument as `cygpid'. Add support for the ipcs(8) - interfaces. Add tracing. Pass an intid to `find ()', not a - shmid. - (server_shmmgr::shmdt): Rename the `pid' argument as `cygpid'. - Add tracing. Pass an intid to `find ()', not a shmid. - (server_shmmgr::shmget): Add a separate out arguments. Rename the - `pid' argument as `cygpid'. Add tracing. - (server_shmmgr::server_shmmgr): Update for new field names. - (server_shmmgr::find_by_key): Update for the new `ds.shm_perm.key' - field. - (server_shmmgr::find): Update to use the new `segment_t::intid' - field. - (server_shmmgr::new_segment): Rename the `pid' argument as - `cygpid'. Check that the requested size is within bounds. Handle - new error result from `new_segment (key, HANDLE)'. - (server_shmmgr::new_segment): Work with intids, not shmids. Check - that the new intid is within bounds. Update for new field names. - (server_shmmgr::delete_segment): Pass an intid to `find ()', not a - shmid. Update for new field names. - (client_request_shm::serve): Check that the incoming message - length is the size of the `_parameters.in' struct, not of the - whole in/out parameter union. Likewise, set the outgoing message - length to the size of the `_parameters.out' struct. Update for - the new server_shmmgr interfaces. - * include/sys/ipc.h (ipc_perm::key): New field. - * include/sys/shm.h (SHM_INFO): New constant. - * cygserver_ipc.h (IPCMNI): New constant. - (ipc_int2ext): Add `sequence' argument and munge this into the - external ipc id. - (ipc_ext2int_subsys): Unmunge the sequence number from the - external ipc id. - (ipc_ext2int): Ditto. - (ipc_inc_id): Remove. - (ipc_dec_id): Remove. - * cygserver_shm.h (SHMMAX): New constant. - (SHMMIN): Ditto. - (SHMMNI): Ditto. - (SHMSEG): Ditto. - (SHMALL): Ditto. - (client_request_shm::_parameters): Re-arrange as a union of two - separate structs, one for in arguments, the other for out. - (client_request_shm::shmid): Update for the new parameter layout. - (client_request_shm::ds): Ditto. - (client_request_shm::info): New method. - * shm.cc (client_shmmgr::_shmat_cnt): New static field. - (client_shmmgr::shmat): Add locking. Add tracing. - (client_shmmgr::shmctl): Update for ipcs(8) commands. Add - tracing. Add more argument checking. - (client_shmmgr::shmdt): Add locking. Add tracing. Update the new - `_shmat_cnt' field. - (client_shmmgr::shmget): Add tracing. - (client_shmmgr::fixup_shms_after_fork): Add tracing. Add - consistency checking. - (client_shmmgr::attach): Add more tracing. - (client_shmmgr::new_segment): Update the new `_shmat_cnt' field. - (client_request_shm::client_request_shm): Update for the new - parameter layout. Set the outgoing message length to the size of - the `_parameters.in' struct, not of the whole in/out parameter - union. - -2002-09-22 Conrad Scott - - * shm.cc: Remove the use of a static client_shmmgr object. - (client_shmmgr::_instance): New static variable. - (client_shmmgr::instance): Allocate a new shmmgr on the heap, - rather than using a local static object. - -2002-09-22 Conrad Scott - - * cygserver_transport.cc (create_server_transport): Fix - cut-and-paste error. - -2002-09-22 Conrad Scott - - * cygserver_client.cc (client_request::handle_request): Don't - bother with the client request activity marker when compiled with - debugging output. - -2002-09-22 Conrad Scott - - * cygserver_transport_pipes.cc - (MAX_WAIT_NAMED_PIPE_RETRY): New constant. - (WAIT_NAMED_PIPE_TIMEOUT): Ditto. - (transport_layer_pipes::close): The `pipe' field is now either - NULL or a valid handle, and it should never have the value - `INVALID_HANDLE_VALUE'. - (transport_layer_pipes::read): Ditto. - (transport_layer_pipes::write): Ditto. - (transport_layer_pipes::connect): Ditto. - (transport_layer_pipes::impersonate_client): Ditto. - (transport_layer_pipes::connect): Ditto. New, but still bogus, - retry logic. - -2002-09-22 Conrad Scott - - * cygserver_shm.cc (server_shmmgr::server_shmmgr): All fields have - to be initialized now that the singleton is no longer static. - -2002-09-22 Conrad Scott - - * cygserver_shm.cc (server_shmmgr::_instance): New static field. - (server_shmmgr::_instance_once): Ditto. - (server_shmmgr::initialise_instance): New static method. - (server_shmmgr::instance): Use a pthread_once_t rather than - relying on a local static variable. - -2002-09-22 Conrad Scott - - * woutsup.h: Remove all uses of the C++ new and delete operators - throughout cygserver until they are fully thread-safe. - (safe_new0): New macro to replace the C++ new operator. - (safe_new): Ditto. - (safe_delete): New macro to replace the C++ delete operator. - * cygserver_client.cc (client_request::handle_request): Replace - all uses of the C++ new and delete operators with the new macros - from "woutsup.h". - (client_request::make_request): Ditto. - * cygserver_process.cc (~process_cleanup): Ditto. - (process::cleanup): Ditto. - (process_cache::process): Ditto. - (process_cache::check_and_remove_process): Ditto. - * cygserver_shm.cc (server_shmmgr::new_segment): Ditto. - (server_shmmgr::delete_segment): Ditto. - * cygserver_transport.cc (create_server_transport): Ditto. - * cygserver_transport_pipes.cc - (transport_layer_pipes::accept): Ditto. - * cygserver_transport_sockets.cc - (transport_layer_sockets::accept): Ditto. - * threaded_queue.cc (~threaded_queue): Ditto. - (threaded_queue::worker_loop): Ditto. - (threaded_queue::stop): Replace sleep(3) with win32 Sleep. - * cygserver.cc (~server_request): Replace all uses of the C++ new - and delete operators with the new macros from "woutsup.h". - (server_submission_loop::request_loop): Ditto. - (main): Ditto. Replace sleep(3) with win32 Sleep. Replace - iostreams with FILEs. - (print_usage): Replace iostreams with FILEs. - (print_version): Ditto. - -2002-09-22 Conrad Scott - - * cygserver_transport_sockets.cc - (transport_layer_sockets::accept): Rename local variable - `accept_fd' to avoid shadowing the `fd' field. - -2002-09-22 Conrad Scott - - * cygwin_ipc.h: Moved (back) to "include/sys/ipc.h". - * cygwin_shm.h: Moved (back) to "include/sys/shm.h". - * include/sys/ipc.h: New file. - * include/sys/shm.h: New file. - * cygserver_shm.h: Update for new header file locations. - * ipc.cc: Ditto. - -2002-09-22 Conrad Scott - - * cygserver_client.cc (client_request::make_request): Comment out - a verbose tracing statement. - * cygserver_process.cc (process_cache::sync_wait_array): Fix - broken assert. - * include/cygwin/cygserver.h (class client_request): Remove excess - use of `class' qualifier in declarations. - (class client_request_get_version): Ditto. - (class client_request_shutdown): Ditto. - (class client_request_attach_tty): Ditto. - -2002-09-22 Conrad Scott - - * cygserver_ipc.h: New file. - * cygserver_shm.h: Re-written from scratch. - * cygserver_shm.cc: Ditto. - * shm.cc: Ditto. - -2002-09-22 Conrad Scott - - * threaded_queue.h (class queue_request): Re-write. - (threaded_queue_thread_function): Remove. - (class queue_process_param): Remove. - (class threaded_queue): Re-write. - (class queue_submission_loop): New version of the old - `queue_process_param' class. - (TInterlockedExchangePointer): New templated function. - (TInterlockedCompareExchangePointer): Ditto. - * threaded_queue.cc (worker_function): Remove. - (class threaded_queue): Re-write. - (class queue_process_param): Remove. - (class queue_submission_loop): New version of the old - `queue_process_param' class. - * include/cygwin/cygserver_process.h (process_cleanup): Re-write. - (class process_process_param): Remove. - (class cleanup_routine): Re-write. - (class process): Re-write. - (class process_cache): Re-write. - * cygserver_process.cc (process_cleanup): Re-write. - (class process_process_param): Remove. - (class cleanup_routine): Re-write. - (class process): Re-write. - (class process_cache): Re-write. - * cygserver.cc (request_count): Remove unused variable. - (class server_request): Move methods inline. - (class server_process_param): Remove. - (class server_request_queue): Remove. - (request_queue): Move into `main ()' and change type to - `threaded_queue'. - (request_loop): Remove. - (class server_submission_loop): New version of the old - `server_process_param' class. - (shutdown_server): New variable. - (client_request_shutdown::serve): Set `shutdown_server' to trigger - shutdown. - (handle_signal): Ditto. - (main): Install signal handler for SIGINT rather than SIGQUIT. - Use new interfaces for the `request_queue' and the `cache'. - Create a `server_submission_loop' and add to the `request_queue'. - Add check for the `shutdown_server' variable to the main loop. - * cygserver_shm.cc (client_request_shm::serve): Release the - process object after use. - -2002-09-22 Conrad Scott - - * cygserver_client.cc (client_request::handle_request): Correct - tracing statement. - * cygserver_transport_pipes.cc: Remove local definition of - FILE_FLAG_FIRST_PIPE_INSTANCE constant. - * cygwin_ipc.h: Update copyright notice. - * cygwin_shm.h: Ditto. - * woutsup.h: Add definition of _WIN32_WINNT. - -2002-09-22 Conrad Scott - - * cygserver_client (client_request::make_request): Replace my - inappropriate use of set_errno () with error_code () throughout. - -2002-09-22 Conrad Scott - - * include/cygwin/cygserver.h: Add forward declarations of class - transport_layer_base and class process_cache to reduce - dependencies between header files. - * include/cygwin/cygserver_process.h: Add include of - "threaded_queue.h". - * cygserver.cc: Remove unnecessary cygserver header files. - * cygserver_client.cc: Ditto. - * cygserver_process.cc: Ditto. - * cygserver_shm.cc: Ditto. - * cygserver_shm.h: Ditto. - * cygserver_transport_pipes.cc: Ditto. - * dcrt0.cc: Ditto. - * fhandler_tty.cc: Ditto. - * tty.cc: Ditto. - -2002-09-22 Conrad Scott - - * cygserver_shm.h: Replace with "cygwin_shm.h" after - merge from HEAD. - * cygwin_ipc.h: Update with changes to include/sys/ipc.h lost in - merge from HEAD. - * cygwin_shm.h: Ditto. - -2002-09-22 Conrad Scott - - * cygserver.cc: The tests for a duplicate server instance are now - the responsibility of the transport layer. - (request_loop): Use new `recoverable' flag in call to - `cygserver_transport::accept ()' and shutdown on an unrecoverable - error. - (main): Never call `cygserver_init ()'. Fake `cygserver_running' - just for sending a shutdown request. - * cygserver_client.cc (client_request::send): Comment out - message-size tracing statements as verbose. - (client_request::handle): Ditto. - (client_request_get_version::check_version): #ifdef as DLL-only. - (check_cygserver_available): Ditto. - (cygserver_init): Ditto. - * include/cygwin/cygserver.h - (client_request_get_version::check_version): #ifdef as DLL-only. - (check_cygserver_available): Ditto. - (cygserver_init): Ditto. - * include/cygwin/cygserver_transport.h - (transport_layer_base::impersonate_client): #ifdef as - cygserver-only. - (transport_layer_base::revert_to_self): Ditto. - (transport_layer_base::listen): Ditto. - (transport_layer_base::accept): Ditto. Add a `recoverable' out - flag for error handling. - * include/cygwin/cygserver_transport_sockets.h: Ditto. - * include/cygwin/cygserver_transport_pipes.h: Ditto. - (transport_layer_pipes): Change type of the `pipe_name' field. - Remove the `inited' field, as unnecessary. Add new - `is_accepted_endpoint' field. - * include/cygwin/cygserver_transport.cc - (transport_layer_base::impersonate_client): #ifdef as - cygserver-only. - (transport_layer_base::revert_to_self): Ditto. - * include/cygwin/cygserver_transport_sockets.cc - (transport_layer_sockets::listen): #ifdef as cygserver-only. - (transport_layer_sockets::accept): #ifdef as cygserver-only. - Analyse any errno from `accept ()' and set `recoverable' as - appropriate. - * cygserver_transport_pipes.cc: Add local #define of - `FILE_FLAG_FIRST_PIPE_INSTANCE'. - (pipe_instance_lock_once): New variable. - (pipe_instance_lock): Ditto. - (pipe_instance): Ditto. - (initialise_pipe_instance_lock): New function. - (transport_layer_pipes::transport_layer_pipes): Change - initialization of `pipe_name'. Initialize `is_accepted_endpoint' - as appropriate. Remove use of `inited'. - (transport_layer_pipes::impersonate_client): #ifdef as - cygserver-only. - (transport_layer_pipes::revert_to_self): Ditto. - (transport_layer_pipes::listen): Ditto. - (transport_layer_pipes::accept): Ditto. Keep track of how often - many named pipes have been created, in the `pipe_instance' - variable, and pass the `FILE_FLAG_FIRST_PIPE_INSTANCE' flag on the - open of the first instance. Analyse the error code from - `CreateNamedPipe ()' and set the `recoverable' flag as - appropriate. - (transport_layer_pipes::close): Update the `pipe_instance' count. - -2002-09-22 Conrad Scott - - * woutsup.h (cygserver_running): Add declaration. - (api_fatal): Eliminate. - * include/cygwin/cygserver.h - (client_request_get_version::check_version): Change return type to - bool. - (check_cygserver_available): New function. - (cygserver_init): Add check_version_too argument. - * cygserver_client.cc (allow_daemon): Make a bool. - (client_request_get_version::make_request): See errno on error. - Remove special case for CYGSERVER_REQUEST_GET_VERSION; this is now - handled in cygserver_init(). - (client_request_get_version::check_version): Use syscall_printf() - instead of api_fatal(). Return true if cygserver version is - compatible. - (check_cygserver_available): New function; code moved here from - cygserver_init(). - (cygserver_init): Move some code into check_cygserver_available(). - * cygserver.cc (__set_errno): Copy from debug.cc so that - set_errno() can be used when __OUTSIDE_CYGWIN__. - (main): Call cygserver_init() to set up cygserver_running and add - checks against this to (try and) prevent multiple copies of - cygserver running simultaneously. Remember to delete all - transport connections so that (one day) the transport classes can - tidy up on cygserver shutdown. - -2002-09-22 Conrad Scott - - * cygserver.cc (main): Adjust tracing output for a cleaner display - when compiled without --enable-debugging. - * threaded_queue.cc (threaded_queue::cleanup): Ditto. - (queue_process_param::stop): Ditto. - * include/cygwin/cygserver.h - (client_request::make_request): Make non-virtual. - (client_request::send): Make virtual and protected, not private. - (client_request_attach_tty::send): New virtual method. - * cygserver_client.cc: Use the `msglen()' accessor rather than - `_header.msglen' throughout. - (client_request_attach_tty::send): New method. - (client_request::make_request): Remove the explicit close of - `transport' as it is closed on deletion. - -2002-09-22 Conrad Scott - - * include/cygwin/cygserver.h: Change the client_request classes to - give greater encapsulation and to allow variable length requests - and replies. - (enum cygserver_request_code): Now client_request::request_code_t. - (class request_header): Now client_request::header_t. Make a - union of the request_code and the error_code. The `cb' field, - which was the buffer length, is now the `size_t msglen' field. - (struct request_get_version): Now - client_request_get_version::request_get_version. - (struct request_shutdown): Remove unused type. - (struct request_attach_tty): Now - client_request_attach_tty::request_attach_tty. - (client_request::_buf): Make field const. - (client_request::_buflen): New const private field. - (client_request::request_code): New accessor. - (client_request::error_code): Ditto. - (client_request::msglen): Ditto. - (client_request::handle_request): New static method. - (client_request::make_request): New virtual method. - (client_request::handle): New method. - (client_request::send): Make private. - (client_request_get_version::check_version): New method. - (client_request_get_version::serve): Make private. - (client_request_get_version::version): Ditto. - (client_request_shutdown::serve): Ditto. - (client_request_attach_tty::req): Ditto. - (client_request_attach_tty::serve): Ditto. - (client_request_attach_tty::from_master): Make method const. - (client_request_attach_tty::from_master): Ditto. - * cygserver_client.cc - (client_request_get_version::client_request_get_version): Track - changes to the client_request classes. - (client_request_attach_tty::client_request_attach_tty): Ditto. - (client_request_get_version::check_version): New method to - encapsulate code from cygserver_init(). - (client_request_shutdown::client_request_shutdown): Move into - "cygserver.cc". - (client_request::send): Track changes to the client_request - classes. Add more error checking. - (client_request::handle_request): New static method containing the - first half of the old server_request::process() code. - (client_request::make_request): New method to replace the old - cygserver_request() function. - (client_request::handle): New method containing the second half of - the old server_request::process() code. - (cygserver_init): Track changes to the client_request classes. In - particular, some code moved into the - client_request_get_version::check_version() method. - * cygserver.cc (client_request_attach_tty::serve): Track changes - to the client_request classes. In particular, only return a reply - body if some handles are successfully duplicated for the client. - And remove goto's. - (client_request_get_version::serve): Track changes to the - client_request classes. - (client_request_shutdown::serve): Ditto. - (class client_request_invalid): Dead, and so young too. - (server_request::request_buffer): Remove unnecessary field. - (client_request_shutdown::client_request_shutdown): Moved here - from "cygserver_client.cc". - (server_request::process): Implementation moved into the new - client_request::handle_request() and client_request::handle() - methods. - * cygserver_shm.h (class client_request_shm): Put client- and - server-specific interfaces inside #ifdef/#ifndef __INSIDE_CYGWIN__ - guards. - (client_request_shm::serve): Make private. - * cygserver_shm.cc - (client_request_shm::client_request_shm): Track changes to the - client_request classes. - (client_request_shm::serve): Ditto - * shm.cc (client_request_shm::client_request_shm): Ditto. Use - alloc_sd() rather than set_security_attribute() to get access to - the SECURITY_DESCRIPTOR length, so that we can use it to set the - request body length. - (shmat): Track changes to the client_request classes. In - particular, allocate client_request objects on the stack rather - than on the heap, and use the client_request::make_request() - method rather than the old cygserver_request() function. - (shmdt): Ditto. - (shmctl): Ditto. - (shmget): Ditto. - * fhandler_tty.cc (fhandler_tty_slave::cygserver_attach_tty): Ditto. - -2002-09-22 Conrad Scott - - * include/cygwin/cygserver_transport.h - (cygserver_transport::read): Change buffer type to void *. - (cygserver_transport::write): Ditto. - * include/cygwin/cygserver_transport_sockets.h - (cygserver_transport_sockets::read): Ditto. - (cygserver_transport_sockets::write): Ditto. - * include/cygwin/cygserver_transport_pipes.h - (cygserver_transport_pipes::read): Ditto. - (cygserver_transport_pipes::write): Ditto. - * cygserver_transport_sockets.cc - (cygserver_transport_sockets::read): Ditto. - (cygserver_transport_sockets::write): Ditto. - * cygserver_transport_pipes.cc - (cygserver_transport_pipes::read): Ditto. Set errno on error, to - match behaviour of cygserver_transport_sockets class. - (cygserver_transport_pipes::write): Ditto. - -2002-09-22 Conrad Scott - - * cygserver.cc (version): New static variable. - (server_request_queue::add_connection): Remove my gratuitous use - of studly caps. - (setup_privileges): Declare static. - (handle_signal): Ditto. - (longopts): Make a local variable of main(). - (opts): Ditto. - (print_usage): New function. - (print_version): Ditto (tip of the hat to Joshua Daniel Franklin - for inspiration here). - (main): More argument checking. Add --help and --version options. - -2002-09-22 Conrad Scott - - * include/cygwin/cygserver.h (client_request::serve): Make pure - virtual. - * cygserver.cc (client_request::serve): Remove definition of pure - virtual method. - (class client_request_invalid): New class. - (server_request::process): Use new client_request_invalid - class. And remove goto's. - -2002-09-22 Conrad Scott - - * cygserver.cc (class server_request): Add virtual destructor. - (server_request_queue::addConnection): New method to replace bad - virtual add() method. - (request_loop): Replace call to queue->add() with call to - queue->addConnection(). - (server_request::server_request): Use field initialization. - (server_request::~server_request): New virtual destructor. - (server_request::process): Remove close and delete of - transport_layer_base object. It is deleted by the server_request's - own destructor and closed by its own destructor. - * include/cygwin/cygserver.h - (client_request::operator request_header): Remove unused method. - * cygserver_client.cc: Ditto. - * include/cygwin/cygserver_process.h - (class cleanup_routine): Add virtual destructor. - (cleanup_routine::cleanup): Make pure virtual. - (class process_cache): Make destructor non-virtual. - (process_cache::add): Ditto. - * cygserver_process.cc - (cleanup_routine::~cleanup_routine): New virtual destructor. - * include/cygwin/cygserver_transport.h - (class transport_layer_base): Add virtual destructor. - * cygserver_transport.cc - (transport_layer_base::~transport_layer_base): New virtual - destructor. - * include/cygwin/cygserver_transport_pipes.h - (class transport_layer_pipes): Add virtual destructor. - * cygserver_transport_pipes.cc - (transport_layer_pipes::~transport_layer_pipes): New virtual - destructor. - (transport_layer_pipes::close): Null out handle after closing. - * include/cygwin/cygserver_transport_sockets.h - (class transport_layer_sockets): Add virtual destructor. - * cygserver_transport_sockets.cc - (transport_layer_sockets::~transport_layer_sockets): New virtual - destructor. - (transport_layer_sockets::close): Null out fd after closing. - * threaded_queue.h (class queue_request): Add virtual destructor. - (queue_request::process): Make pure virtual. - * threaded_queue.cc (~queue_request): New virtual destructor. - (queue_request::process): Remove definition of pure virtual - method. - -2002-09-22 Conrad Scott - - * include/cygwin/cygserver.h (client_request::send): Make - non-virtual. - (class client_request_attach_tty): Put client- and server-specific - interfaces inside #ifdef/#ifndef __INSIDE_CYGWIN__ guards. - * cygserver_client.cc: Ditto. - (cygserver_init): Fix error handling. - -2002-09-22 Conrad Scott - - * cygserver.cc: Throughout the code, check and correct level of - the XXX_printf() functions used. Comment out several of the - debug_printf() calls with "// verbose:". Reformat and correct - typos of some of the XXX_printf() formats. - * cygserver_process.cc: Ditto. - * cygserver_shm.cc: Ditto. - * cygserver_transport_pipes.cc: Ditto. - * cygserver_transport_sockets.cc: Ditto. - * shm.cc (hi_ulong): New function to allow printing of a 64-bit - key with current small_printf implementation. - (lo_ulong): Ditto. - (client_request_shm::client_request_shm): Use hi_ulong() and - lo_ulong() in call to debug_printf(). - -2002-09-22 Conrad Scott - - * cygserver_shm.cc: Remove #define __INSIDE_CYGWIN__ from around - as it no longer contains any internal code. - -2002-09-22 Conrad Scott - - * include/sys/ipc.h (IPC_PRIVATE): Add cast to key_t. - (IPC_INFO): New flag for ipcs(8). - (IPC_RMID IPC_SET IPC_STAT): Renumber. - * include/sys/shm.h (SHM_RDONLY SHM_RND): Renumber with distinct - values [sic]. - (class _shmattach): Internal type moved to "cygserver_shm.h". - (class shmnode): Ditto. - (class shmid_ds): Ditto. - (struct shmid_ds): Add spare fields. - (struct shminfo): New type for IPC_INFO interface. - * cygserver_shm.h: Remove obsolete #if 0 ... #endif block. - (class shm_cleanup): Remove unused class. - (struct _shmattach): Internal type moved from . - (struct shmnode): Ditto. - (struct int_shmid_ds): Ditto. Renamed to avoid name clash with - public interface struct shmid_ds. Use the shmid_bs structure as a - field. - * cygserver_shm.cc: Remove obsolete #if 0 ... #endif block. - (client_request_shm::serve): Update for redefinition of - int_shmid_ds structure. - * shm.cc (build_inprocess_shmds): Ditto. - (fixup_shms_after_fork): Ditto. - (shmctl): Ditto. - (shmget): Ditto. Remove obsolete #if 0 ... #endif code. - -2002-09-22 Conrad Scott - - * include/cygwin/cygserver_transport.h - (transport_layer_base::transport_layer_base): Remove since it is - now redundant. - (transport_layer_base::listen): Make a pure virtual method. - (transport_layer_base::accept): Ditto. - (transport_layer_base::close): Ditto. - (transport_layer_base::read): Ditto. - (transport_layer_base::write): Ditto. - (transport_layer_base::connect): Ditto. - * cygserver_transport.cc - (transport_layer_base::transport_layer_base): Remove since it is - now redundant. - (transport_layer_base::listen): Remove since it is now a pure - virtual method. - (transport_layer_base::accept): Ditto. - (transport_layer_base::close): Ditto. - (transport_layer_base::read): Ditto. - (transport_layer_base::write): Ditto. - (transport_layer_base::connect): Ditto. - -2002-09-22 Conrad Scott - - * cygserver.cc (check_and_dup_handle): Only use security code if - running on NT, i.e. if wincap.has_security(). - (client_request_attach_tty::serve): Add check for has_security(). - * cygserver_process.cc (process_cache::process): Use DWORD winpid - throughout to avoid win32 vs. cygwin pid confusion. - (process::process): Ditto. - * cygserver_shm.cc (client_request_shm::serve): Only use security - code if running on NT, i.e. if wincap.has_security(). - * cygserver_shm.h (client_request_shm::parameters.in): Replace the - ambiguous pid field with cygpid and winpid fields. - (client_request_shm::client_request_shm): Reduce to only two - client-side constructors: one for SHM_CREATE, another for all the - other requests. - * shm.cc (client_request_shm::client_request_shm): - Ditto. Initialize cygpid and winpid fields here. On NT initialize - sd_buf here using set_security_attribute() to make use of the euid - and egid. - (shmat): Use new client_request_shm constructor. - (shmdt): Ditto. - (shmctl): Ditto. - (shmget): Ditto. Remove security code, now performed in the - relevant client_request_shm constructor. - * include/cygwin/cygserver_process.h: (class cleanup_routine): - Change winpid type to DWORD. - (class process): Ditto. - -2002-09-22 Conrad Scott - - * woutsup.h: New file. - * cygserver.cc: Use "woutsup.h" and new XXX_printf macros. - (getfunc): New function, copied verbatim from "strace.cc". - (__cygserver__printf): New function. - * cygserver_client.cc: Use "woutsup.h" and new XXX_printf macros. - * cygserver_process.cc: Ditto. - * cygserver_shm.cc: Ditto. - * cygserver_transport.cc: Ditto. - * cygserver_transport_pipes.cc: Ditto. - * cygserver_transport_sockets.cc: Ditto. - * threaded_queue.cc: Ditto. - * shm.cc: Remove trailing \n from XXX_printf format strings. - * Makefile.in: Remove special __OUTSIDE_CYGWIN__ case for - cygserver_shm.cc. - -2002-09-21 Christopher Faylor - - * init.cc (dll_entry): Temporarily disable thread detach code. - -2002-09-21 Christopher Faylor - - * fhandler.cc (fhandler_base::dup): Don't set handle on failure. - Caller has already taken care of that. - * fhandler_console.cc (fhandler_console::open): Initialize handles to - NULL. - (fhandler_console::close): Ditto. - -2002-09-21 Christopher Faylor - - GNUify non-GNU formatted functions calls throughout. - -2002-09-21 Conrad Scott - - * cygwin_ipc.h: Move to "include/cygwin/ipc.h". - * cygwin_shm.h: Move to "include/cygwin/shm.h". - * include/cygwin/ipc.h: New file. - * include/cygwin/shm.h: New file. - * ipc.c:c Update include. - * cygserver_shm.cc: Update include. - * shm.cc: Ditto. - -2002-09-21 Robert Collins - - * pthread.cc: Use class::call for converted pthread and semaphore - calls. - * thread.cc: Convert various __pthread_call and __sem_call to - pthread::call and sem::call throughout. - * pthread.h (__pthread_cancel): Convert to pthread::cancel. - (__pthread_join): Convert to pthread::join. - (__pthread_detach): Convert to pthread::detach. - (__pthread_create): Convert to pthread::create. - (__pthread_once): Convert to pthread::once. - (__pthread_atfork): Convert to pthread::atfork. - (__pthread_suspend): Convert to pthread::suspend. - (__pthread_continue): Convert to pthread::resume. - (__sem_init): Convert to semaphore::init. - (__sem_destroy): Convert to semaphore::destroy. - (__sem_wait): Convert to semaphore::wait. - (__sem_trywait): Convert to semaphore::trywait. - (__sem_post): Convert to semaphore::post. - -2002-09-21 Robert Collins - - * thread.cc: Finish the removal of the separate pthread_key - destructor list. - Remove all pthread_key_destructor and pthread_key_destructor_list - references throughout. - (pthread::exit): Call the new pthread_key interface to activate - destructors. - (pthread_key::keys): Change into a list. - (pthread_key::saveAKey): New method, used via forEach. - (pthread_key::restoreAKey): Ditto. - (pthread_key::destroyAKey): Ditto. - (pthread_key::fixup_before_fork): Use the List::forEach functionality. - (pthread_key::fixup_after_fork): Ditto. - (pthread_key::runAllDestructors): New method implementation. - (pthread_key::pthread_key): Use List::Insert rather than custom list - code. - (pthread_key::~pthread_key): Use List::Remove for the same reason. - * thread.h: Remove all pthread_key_destructor and - pthread_key_destructor_list references throughout. - (List): Move the interface above pthread_key in the header. - Use atomic operations during insert and delete. - (List::forEach): A generic interface for doing something on each node. - (pthread_key::runAllDestructors): New method, run all destructors. - (pthread_key::fork_buf): Make private. - (pthread_key::run_destructor): Ditto. - (pthread_key::saveAKey): New method for clearer source. - (pthread_key::restoreAKey): Ditto. - (pthread_key::destroyAKey): Ditto. - (MTinterface::destructors): Remove. - -2002-09-21 Robert Collins - - * thread.cc: Partial refactoring of pthread_key destructor - handling. Loosely based on Thomas Pfaff's work. - (pthread_key_destructor_list::Insert): Remove. - (pthread_key_destructor_list::Pop): Remove. - (pthread_key_destructor_list::IterateNull): Call the key's - run_destructor method. - (pthread_key::pthread_key): Initialize new member. - (pthread_key::get): Mark as const for correctness. - (pthread_key::run_destructor): Implement. - * thread.h (pthread_key::get): Mark as const for correctness. - (pthread_key::run_destructor): Declare. - (List): New template class that implements a generic list. - (pthread_key_destructor_list): Inherit from List, and remove - now duplicate functions. - -2002-09-21 Robert Collins - - * thread.cc: Change verifyable_object_isvalid calls with - PTHREAD_CONDATTR_MAGIC, PTHREAD_MUTEXATTR_MAGIC, PTHREAD_COND_MAGIC, - SEM_MAGIC to objecttype::isGoodObject() calls throughout. - (pthread_condattr::isGoodObject): Implement. - (pthread_mutex::isGoodInitializer): Implement. - (pthread_mutex::isGoodInitializerOrObject): Minor bugfix in the - check for verifyable_object_isvalid result. - (pthread_mutexattr::isGoodObject): Implement. - (pthread_cond::isGoodObject): Ditto. - (pthread_cond::isGoodInitializer): Ditto. - (pthread_cond::isGoodInitializerOrObject): Ditto. - (semaphore::isGoodObject): Ditto. - * thread.h (pthread_mutex::isGoodInitializer): Declare. - (pthread_condattr::isGoodObject): Ditto. - (pthread_cond::isGoodObject): Const correctness. - (pthread_cond::isGoodInitializer): Declare. - (pthread_cond::isGoodInitializerOrObject): Ditto. - (semaphore::isGoodObject): Const correctness. - -2002-09-21 Robert Collins - - * thread.cc: Change verifyable_object_isvalid calls with - PTHREAD_MUTEX_MAGIC and PTHREAD_KEY_MAGIC and PTHREAD_ATTR_MAGIC to - ::isGoodObject() calls throughout. - (MTinterface::Init): Remove dead code. - (pthread_attr::isGoodObject): Implement. - (pthread_key::isGoodObject): Implement. - (pthread_mutex::isGoodObject): Implement. - (pthread_mutex::isGoodInitializerOrObject): Implement. - (pthread::isGoodObject): Update signature. - * thread.h (pthread_key::isGoodObject): Declare. - (pthread_attr::isGoodObject): Ditto. - (pthread_mutex::isGoodObject): Ditto. - (pthread_mutex::isGoodInitializerOrObject): Ditto. - (pthread::isGoodObject): Change to a const parameter for const - correctness. - (pthread_mutexattr::isGoodObject): Declare. - (pthread_condattr::isGoodObject): Ditto. - (pthread_cond::isGoodObject): Ditto. - (semaphore::isGoodObject): Ditto. - -2002-09-19 Christopher Faylor - - Cleanup calls to CreateFile throughout. - * dcrt0.cc (__api_fatal): Correctly check for failing return from CreateFile. - * assert.cc (__assert): Don't check return value from CreateFile for NULL. - * fhandler_console.cc (set_console_state_for_spawn): Ditto. - * fork.cc (fork_parent): Ditto. - -2002-09-18 Christopher Faylor - - * cygthread.cc (cygthread::initialized): Avoid copying on fork or some - threads may not end up in the pool. - (cygthread::new): Avoid race when checking for initialized. Add - debugging code. - -2002-09-18 Pierre Humblet - - * fhandler.cc (fhandler_base::raw_read): Add case for - ERROR_INVALID_HANDLE due to Win95 directories. - (fhandler_base::open): Handle errors due to Win95 directories. - (fhandler_base::close): Add get_nohandle () test. - (fhandler_base::set_close_on_exec): Ditto. - (fhandler_base::fork_fixup): Ditto. - (fhandler_base::lock): Change error code to Posix EINVAL. - (fhandler_base::dup): If get_nohandle (), set new value to - INVALID_HANDLE_VALUE instead of NULL. - * fhandler_disk_file.cc (fhandler_disk_file::fstat): Call fstat_by_name - if get_nohandle (). Remove extraneous element from strpbrk. - (fhandler_disk_file::open): Remove test for Win95 directory. - - * fhandler_random.cc (fhandler_dev_random::open): Add set_nohandle (). - * fhandler_clipboard.cc (fhandler_dev_clipboard::open): Ditto. - * fhandler_zero.cc (fhandler_dev_zero::open): Ditto. - (fhandler_dev_zero::close): Delete. - * fhandler.h (class fhandler_dev_zero): Ditto. - -2002-09-17 Robert Collins - - * thread.cc (pthread_key::set): Preserve GetLastError(). Reported - by Thomas Pffaf. - -2002-09-17 Robert Collins - - This work inspires by Thomas Pfaff's pthread_fork patch (1). - * fork.cc (fork_child): Remove MTinterface fixup call, it's - adsorbed by pthread::atforkchild. - Rename __pthread_atforkchild to pthread::atforkchild to give - access to private members. - (fork_parent): Rename __pthread_atforkparent to - pthread::atforkparent to give it access to private members. - Ditto for __pthread_atforkprepare. - * thread.cc: Fix some formatting problems throughout. - (MTinterface::fixup_before_fork): Implement. - (MTinterface::fixup_after_fork): Fix pthread_keys. - (pthread_key::keys): Implement. - (pthread_key::fixup_before_fork): Ditto. - (pthread_key::fixup_after_fork): Ditto. - (pthread_key::pthread_key): Add to pthread_key::keys. - (pthread_key::~pthread_key): Remove from pthread_key::keys. - (pthread_key::saveKeyToBuffer): Implement. - (pthread_key::recreateKeyFromBuffer): Ditto. - (pthread::atforkprepare): Prepare all MT classes for fork. - (pthread::atforkchild): And fix them up afterwards. - * thread.h (pthread_key): Buffer the key value during - fork in fork_buf. - List the keys needing to be fixed up in a linked list with - head pthread_key::keys. - (pthread): Move atfork cygwin internal calls into the class. - (MTInterface): Provide a fixup_before_fork for objecst that - need to save state. - (__pthread_atforkprepare): Remove. - (__pthread_atforkparent): Remove. - (__pthread_atforkchild): Remove. - -2002-09-16 Christopher Faylor - - * init.cc: Cleanup slightly and remove obsolete code. - -2002-09-11 Robert Collins - - * init.cc (dll_entry): On thread detach, if the thread hasn't - exit()ed, do so. - * pthread.cc (pthread_getsequence_np): Remove the - __pthread_getsequence_np wrapper. This requires errno.h. - * thread.cc (pthread::self): Instantiate a new pthread object - when called and none exists. return a NULL object if instantiation - fails. - (pthread::precreate): Factor out common code. - (pthread::postcreate): Ditto. - (pthread::create): Ditto. - (pthread::exit): Remove the TLS value when we exit to prevent - double exits. - (MTinterface::Init): Bugfix - don't mark the TLS index as created - if one was not allocated. - Apply Extract Method to move pthread specific initialisation into - pthread. - (pthread::initMainThread): Extracted method from MTinterface::Init. - (pthread::setTlsSelfPointer): Extracted method from various pthread - calls, to make reading those functions easier. - (pthread::setThreadIdtoCurrent): Ditto. - (pthread::cancel_self): Bring into the .cc file, it's only used - within the class. - (pthread::getThreadId): Ditto. - (pthread::thread_init_wrapper): Apply Extract Method to the TLS - setting logic. - (pthread::isGoodObject): Extracted method from various pthread - wrapper calls, for clarity of reading. - (pthread::getsequence_np): Converted from __pthread_getsquence_np. - (__pthread_create): Apply Extract Method to the object validation. - (__pthread_cancel): Ditto. - (__pthread_join): Ditto. - (__pthread_detach): Ditto. - (__pthread_suspend): Ditto. - (__pthread_continue): Ditto. - (__pthread_getschedparam): Ditto. - (__pthread_getsequence_np): Remove. - (__pthread_setschedparam): Apply Extract Method to the object - validation. - (pthreadNull::getNullpthread): New method, return the pthreadNull - object. - (pthreadNull::pthreadNull): Private constructor to prevent accidental - use. - (pthreadNull::~pthreadNull): Prevent compile warnings. - (pthreadNull::create): Override pthread behaviour. - (pthreadNull::exit): Ditto. - (pthreadNull::cancel): Ditto. - (pthreadNull::testcancel): Ditto. - (pthreadNull::setcancelstate): Ditto. - (pthreadNull::setcanceltype): Ditto. - (pthreadNull::push_cleanup_handler): Ditto. - (pthreadNull::pop_cleanup_handler): Ditto. - (pthreadNull::getsequence_np): Ditto. - (pthreadNull::_instance): Ditto. - * thread.h (pthread): Declare pre- and post-create. - Move GetThreadId to private scope and rename to getThreadId. - Move setThreadIdtoCurrent to private scope. - Make create virtual. - Make ~pthread virtual. - Declare initMainThread. - Declare isGoodObject. - Make exit virtual. - Make cancel virtual. - Make testcancel virtual. - Make setcancelstate virtual. - Make setcanceltype virtual. - Make push_cleanup_handler virtual. - Make pop_cleanup_handler virtual. - Declare getsequence_np. - Declare setTlsSelfPointer. - (pthreadNull): New null object class for pthread. - (__pthread_getsequence_np): Remove. - -2002-09-13 Corinna Vinschen - - * syscalls.cc (seteuid32): Treat ILLEGAL_UID invalid. - (setegid32): Treat ILLEGAL_GID invalid. - -2002-09-10 Pierre Humblet - - * grp.cc (initgroups): Call groups::clear_supp to free the - supplementary group sids that may have been set by setgroups. - * security.cc (cygsidlist::free_sids): Also zero the class members. - * security.h (groups::clear_supp): New. - Rename cygsidlist_unknown to cygsidlist_empty. - -2002-09-08 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_slave::open): Don't protect - input/output handles since they are not properly manipulated later. - * tty.cc (tty::make_pipes): Ditto. - -2002-09-06 Christopher Faylor - - * winsup.h (_WIN32_WINNT): Protect. - -2002-09-06 Christopher Faylor - - * winsup.h (_WIN32_WINNT): Define. - -2002-09-03 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Drop shortcut.o. - * path.cc: Move all shortcut functions from shortcut.c to here. - (check_shortcut): Implement without using COM interface. - * path.h: Move definition of SHORTCUT_HDR_SIZE to here. - * shortcut.c: Remove. - * shortcut.h: Ditto. - -2002-09-03 Conrad Scott - - * fhandler.h (fhandler_socket::read): Remove method. - (fhandler_socket::write): Ditto. - (fhandler_socket::readv): New method. - (fhandler_socket::writev): Ditto. - (fhandler_socket::recvmsg): Add new optional argument. - (fhandler_socket::sendmsg): Ditto. - * fhandler.cc (fhandler_socket::read): Remove method. - (fhandler_socket::write): Ditto. - (fhandler_socket::readv): New method. - (fhandler_socket::writev): Ditto. - (fhandler_socket::recvmsg): Use win32's scatter/gather IO where - possible. - (fhandler_socket::sendmsg): Ditto. - * net.cc (cygwin_recvmsg): Check the msghdr's iovec fields. - (cygwin_sendmsg): Ditto. Add omitted sigframe. - -2002-09-02 Kazuhiro Fujieda - - * cygwin.din: Revert exporting new wchar functions. - * include/cygwin/version.h: Change comment for API minor 62. - -2002-09-02 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Remove getpagesize() call. - * shared.cc (memory_init): Move it here. - -2002-08-31 Christopher January - - * fhandler_proc.cc: Add include. - (format_proc_uptime): Use KernelTime and UserTime only as they include - the other counters. - (format_proc_stat): KernelTime includes IdleTime, so subtract IdleTime - from KernelTime. Make number of 'jiffies' per second same as HZ define. - * fhandler_process.cc: Add include. - (format_process_stat): Make number of 'jiffies' per second same as - HZ define. Use KernelTime and UserTime only to calculate start_time. - -2002-08-30 Christopher Faylor - - (inspired by a patch from Egor Duda) - * select.cc (fhandler_tty_slave::ready_for_read): Remove. - * fhandler.h (fhandler_tty_slave::ready_for_read): Remove declaration. - * fhandler_tty.cc (fhandler_tty_slave::fhandler_tty_slave): Set "don't - need ready for read" flag. - (fhandler_tty_slave::read): Don't do anything special with vtime when - vmin == 0. - -2002-08-30 Egor Duda - - * autoload.cc (GetConsoleWindow): Correct parameter count. - -2002-08-30 Christopher January - Christopher Faylor - - * tty.cc (tty_list::allocate_tty): Use GetConsoleWindow, if available. - Call FindWindow in a loop. - * autoload.cc (GetConsoleWindow): Export - -2002-08-30 Christopher Faylor - - * miscfuncs.cc (check_iovec_for_read): Don't check buffer when zero - length iov_len. - (check_iovec_for_write): Ditto. - -2002-08-27 Conrad Scott - - * fhandler.h (fhandler_base::readv): New method. - (fhandler_base::writev): Ditto. - * fhandler.cc (fhandler_base::readv): New method. - (fhandler_base::writev): Ditto. - * syscalls.cc (_read): Delegate to readv(2). - (_write): Ditto, mutatis mutandi. - (readv): Rewrite, based on the old _read code, to use the new - fhandler_base::readv method. Improve access mode handling and ensure - all calls reach the final strace statement. - (writev): Ditto, mutatis mutandi. - * include/sys/uio.h (struct iovec): Change field types to match SUSv3. - * winsup.h (check_iovec_for_read): New function. - (check_iovec_for_write): Ditto. - * miscfuncs.cc (check_iovec_for_read): Ditto. - (check_iovec_for_write): Ditto. - -2002-08-30 Corinna Vinschen - - * cygwin.din: Add more prototypes for new wchar functions in newlib. - -2002-08-30 Corinna Vinschen - - * cygwin.din: Add prototypes for new wchar functions in newlib. - * include/cygwin/version.h: Bump API minor number. - -2002-08-29 Boris Schaeling - Corinna Vinschen - - * poll.cc (poll): Peek sockets ready for read to see if there's - actually data. - -2002-08-28 Christopher Faylor - - * cygthread.cc (hthreads): Remove unneeded global. - (cygthread::simplestub): New static member function. - (cygthread::runner): Don't set hthreads. - (cygthread::freerange): New member function. - (cygthread::operator new): Call freerange if all cygwin slots are used - up. - (cygthread::exit_thread): Don't mess with event if freerange thread. - (cygthread::detach): Ditto. - * cygthread.h (class cygthread): Declare new member functions and - variables. - -2002-08-28 Christopher Faylor - - * malloc.cc: Protect some definitions to avoid a compile time warning. - -2002-08-27 Nicholas Wourms - - * cygwin.din: Export getc_unlocked, getchar_unlocked, - putc_unlocked, putchar_unlocked functions. - * include/cygwin/version.h: Bump api minor. - -2002-08-28 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::recvfrom): Eliminate flags - not understood by WinSock. - (fhandler_socket::sendto): Ditto. If WinSock sendto() returns - WSAESHUTDOWN, change errno to EPIPE and raise SIGPIPE if MSG_NOSIGNAL - isn't set in flags. - * include/cygwin/socket.h: Define MSG_WINMASK and MSG_NOSIGNAL. - * include/cygwin/version.h: Bump API minor number. - -2002-08-28 Corinna Vinschen - - * poll.cc (poll): Eliminate erroneous POLLERR conditional. - -2002-08-26 Conrad Scott - - * fhandler_socket.cc (fhandler_socket::check_peer_secret_event): - Fix strace message. - (fhandler_socket::connect): Remove sigframe. - (fhandler_socket::accept): Ditto. - (fhandler_socket::getsockname): Ditto. - (fhandler_socket::getpeername): Ditto. - (fhandler_socket::recvfrom): Ditto. - (fhandler_socket::recvmsg): Ditto. - (fhandler_socket::sendto): Ditto. - (fhandler_socket::sendmsg): Ditto. - (fhandler_socket::close): Ditto. - (fhandler_socket::ioctl): Ditto. - * ioctl.cc (ioctl): Add sigframe. - * net.cc (cygwin_sendto): Ditto. - (cygwin_recvfrom): Ditto. - (cygwin_recvfrom): Ditto. - (cygwin_connect): Ditto. - (cygwin_shutdown): Ditto. - (cygwin_getpeername): Ditto. - (cygwin_accept): Ditto. Improve strace message. - (cygwin_getsockname): Ditto. Ditto. - (cygwin_recvmsg): Ditto. Ditto. - (cygwin_sendmsg): Fix strace message. - -2002-08-27 Christopher Faylor - - * child_info.h: Add _PROC_WHOOPS enum value. - (CURR_CHILD_INFO_MAGIC): Update. - (child_info::magic): Make 'long'. - * cygheap.h: Export _cygheap_start. - * cygheap.cc: Don't declare _cygheap_start. - * cygmagic: Use cksum to produce checksums. Append 'U' to end of - checksum. - * dcrt0.cc (initial_env): Calculate sleep ms before reusing buffer. - (_dll_crt0): Detect cygheap mismatch as indicative of different cygwin - version. Set child_proc_info to NULL when _PROC_WHOOPS. - (multiple_cygwin_problem): If child_info specific problem, then set - child_proc_info type to _PROC_WHOOPS. - * shared_info.h (CURR_MOUNT_MAGIC): Update. - (CURR_SHARED_MAGIC): Ditto. - -2002-08-25 Conrad Scott - - * fhandler.h (fhandler_socket::recvfrom): Fix prototype. - (fhandler_socket::sendto): Ditto. - * fhandler_socket.cc (fhandler_socket::recvfrom): Ditto. - (fhandler_socket::sendto): Ditto. - * include/sys/socket.h (recv): Fix prototype. - (recvfrom): Ditto. - (send): Ditto. - (sendto): Ditto. - * net.cc (cygwin_sendto): Ditto. Improve strace message - (cygwin_recvfrom): Ditto. Ditto. - (cygwin_setsockopt): Improve strace message. - (cygwin_getsockopt): Ditto. - (cygwin_connect): Ditto. - (cygwin_accept): Ditto. - (cygwin_bind): Ditto. - (cygwin_getsockname): Ditto. - (cygwin_getpeername): Ditto. - (cygwin_recv): Fix prototype. - (cygwin_send): Ditto. - (cygwin_recvmsg): Improve strace message. - (cygwin_sendmsg): Ditto. - -2002-08-25 Pierre Humblet - - * sec_acl.cc (getacl): Check ace_sid == well_known_world_sid - before owner_sid and group_sid so that well_known_world_sid - means "other" even when owner_sid and/or group_sid are Everyone. - * security.cc (get_attribute_from_acl): Created from code common - to get_nt_attribute() and get_nt_object_attribute(), with same - reordering as in getacl() above. - (get_nt_attribute): Call get_attribute_from_acl(). - (get_nt_object_attribute): Ditto. - -2002-08-26 Christopher Faylor - - * Makefile.in (cygrunk.exe): Make a -mno-cygwin program. - * cygrun.c (main): Export CYGWIN=ntsec unless otherwise set. - - * shared.cc (shared_name): Only add build date to shared name when - *testing*. - -2002-08-24 Christopher Faylor - - * Makefile.in (DLL_IMPORTS): Move libuuid.a and libshell32.a to list - rather than referring to them via -l. Add DLL imports last in link - line for new-cygwin.dll and cygrun.exe. - -2002-08-19 Christopher Faylor - - * pinfo.h (pinfo::remember): Arrange for destructor call if - proc_subproc returns error. - * sigproc.cc (zombies): Store 1 + total zombies since proc_subproc uses - NZOMBIES element. - -2002-08-19 Corinna Vinschen - - * pwdgrp.h (pwdgrp_read::pwdgrp_read): Remove. - (pwdgrp_read::~pwdgrp_read): Ditto. - (pwdgrp_read::open): Reset fh to NULL instead of INVALID_HANDLE_VALUE. - (pwdgrp_read::close): Ditto. - -2002-08-19 Christopher Faylor - - * fhandler.h (fhandler_console::send_winch_maybe): New method. - * fhandler_console.cc (set_console_state_for_spawn): Remove if 0'ed - code. - (fhandler_console::send_winch_maybe): Define new method. - (fhandler_console::read): Use send_winch_maybe where appropriate. - (fhandler_console::init): Just call all tcsetattr rather than - output_tcsetattr. - * select.cc (peek_console): Reorganize so that send_winch_maybe is - called for everything but keyboard input. - -2002-08-18 Christopher Faylor - - * perthread.h (vfork_save): Add ctty, sid, pgid, exitval fields. - (vfork_save::restore_pid): New method. - (vfork_save::restore_exit): New method. - * fork.cc (vfork): Save ctty, sid, pgid and restore them when returning - to "parent". Use exitval field if exiting but never created a new - process. - * syscalls.cc (setsid): Detect when in "vfork" and force an actual fork - so that pid will be allocated (UGLY!). - (getsid): New function. - * dcrt0.cc (do_exit): Use vfork_save::restore_exit method for returning - from a vfork. - * spawn.cc (spawnve): Use vfork_save::{restore_pid,restore_exit} - methods for returning from vfork. - * cygwin.din: Export getsid. - * include/cygwin/version.h: Bump api minor number. - - * malloc.cc: #ifdef sYSTRIm for when MORECORE_CANNOT_TRIM is true. - -2002-08-18 Christopher Faylor - - * cygmalloc.h (MORECORE_CANNOT_TRIM): Define. - -2002-08-18 Christopher Faylor - - * sigproc.cc (sigCONT): Define. - * sigproc.h (sigCONT): Declare. - (wait_sig): Create sigCONT event here. - * exceptions.cc (sig_handle_tty_stop): Wait for sigCONT event rather - than stopping thread. - (sig_handle): Set sigCONT event as appropriate on SIGCONT rather than - calling ResumeThread. - -2002-08-17 Christopher Faylor - - * malloc.cc: Update to 2.7.2. - * malloc_wrapper.cc (malloc_init): Call user level mallocs to determine - if the malloc routines have been overridden. - -2002-08-16 Christopher Faylor - - * winsup.h: Remove malloc_*lock functions. - -2002-08-16 Christopher Faylor - - * Makefile.in: Add support for new malloc.o and renamed - malloc_wrapper.o. Use -fomit-frame-pointer for malloc.o compilation. - * malloc_wrapper.cc: New file. Rename from malloc.cc. Add support for - more malloc functions. Eliminate export_* calls. Just use straight - malloc names. Remove unused argument from malloc lock functions. - * cygwin.din: Just export straight malloc names. Add malloc_stats, - malloc_trim, malloc_usable_size, mallopt, memalign, valloc. - * dcrt0.cc (__cygwin_user): Eliminate export_* malloc entries. - * fork.cc (fork_parent): Remove unused argument from malloc_lock - argument. - * malloc.cc: New file. Doug Lea's malloc v2.7.1. - * cygmalloc.h: New file. - * include/cygwin/version.h: Bump API_MINOR. - - * sync.h (muto::acquire): Use appropriate number for regparm attribute. - (muto::reset): Ditto. - (muto::release): Ditto. - -2002-08-16 Pavel Tsekov - - * exceptions.cc (interrupt_setup): Ensure that the previous signal mask - is properly saved. - -2002-08-15 Thomas Pfaff - - * dcrt0.cc: Modify define for CYGWIN_GUARD. - (alloc_stack_hard_way): Just use CYGWIN_GUARD in VirtualAlloc call. - -2002-08-11 Conrad Scott - - * fhandler.h (fhandler_socket::recv): Remove method. - (fhandler_socket::send): Ditto. - * fhandler_socket.cc (fhandler_socket::recv): Ditto. - (fhandler_socket::send): Ditto. - (fhandler_socket::read): Delegate to fhandler_socket::recvfrom. - (fhandler_socket::write): Delegate to fhandler_socket::sendto. - (fhandler_socket::sendto): Check for null `to' address. - * net.cc (cygwin_sendto): Check for zero request length. - (cygwin_recvfrom): Ditto. Fix signature, use void *buf. - (cygwin_recv): Delegate to cygwin_recvfrom. - (cygwin_send): Delegate to cygwin_sendto. - -2002-08-11 Christopher Faylor - - * cygthread.cc (cygthread::cygthread): Close another race. - -2002-08-11 Christopher Faylor - - * assert.cc (__assert): Call debugger on assertion failure if - debugging. - * dcrt0.cc (dll_crt0_1): Just wait for signal thread to go live rather - than going through the overhead of invoking it. - * fork.cc (fork_child): Ditto. - * exceptions.cc (signal_fixup_after_fork): Call sigproc_init here. - * sigproc.cc (proc_can_be_signalled): Assume that the signal thread is - live. - (sig_dispatch): Ditto. - (sig_send): Ditto. - (wait_for_sigthread): Rename from "wait_for_me". Assume that - wait_sig_inited has been set and that this function is only called from - the main thread. - * sigproc.h (wait_for_sigthread): Declare new function. - -2002-08-08 Christopher Faylor - - * environ.cc (parse_options): Remember the "no" part of any options for - later export. - -2002-08-07 Conrad Scott - - * winsup.h (__check_null_invalid_struct): Make ptr argument non-const. - (__check_null_invalid_struct_errno): Ditto. - * miscfuncs.cc (__check_null_invalid_struct): Ditto. - (__check_null_invalid_struct_errno): Ditto. - (__check_invalid_read_ptr_errno): Remove superfluous cast. - * net.cc (get): Set appropriate errno if fd is not a socket. - (cygwin_sendto): Fix parameter checking. - (cygwin_recvfrom): Ditto. - (cygwin_setsockopt): Ditto. - (cygwin_getsockopt): Ditto. - (cygwin_connect): Ditto. - (cygwin_gethostbyaddr): Ditto. - (cygwin_accept): Ditto. - (cygwin_bind): Ditto. - (cygwin_getsockname): Ditto. - (cygwin_listen): Ditto. - (cygwin_getpeername): Ditto. - (cygwin_send): Ditto. - (cygwin_shutdown): Ditto. Move sigframe to fhandler_socket. - (cygwin_recvmsg): Fix parameter checking. Add tracing. - (cygwin_sendmsg): Ditto. - * fhandler_socket.cc (fhandler_socket::shutdown): Add sigframe. - * resource.cc (setrlimit): Fix parameter checking. - -2002-08-08 Joe Buehler - - * fhandler_socket.cc (fhandler_socket::accept): Fix FIONBIO call. - -2002-08-06 Christopher Faylor - - * cygheap.cc (_csbrk): Avoid !cygheap considerations. - (cygheap_init): Deal with unintialized cygheap issues here. - (cheap_init): Move cygheap_max setting here. - -2002-08-06 Christopher Faylor - Conrad Scott - - * spawn.cc (spawn_guts): Don't set mount_h here. - * sigproc.cc (init_child_info): Set it here instead. - * shared.cc (cygwin_mount_h): Make NO_COPY. - -2002-08-06 Christopher Faylor - - * cygthread.cc (cygthread::stub): Accept flag to pass info structure to - thread function. - (cygthread::operator new): Add defensive debugging output. - (cygthread::cygthread): Add debugging output. Set name after thread - has been awakened to avoid a race. - (cygthread::exit_thread): Use handle operator rather than using ev - directly. - (cygthread::exit_thread): Reorganize to provide debugging. Set __name - to NULL. - * cygthread.h (cygself): Define. - * fhandler_tty.cc (fhandler_tty_master::init): Use cygself as argument - so that invoked thread can access its own info. - (process_output): Derive cygthread info of thread from thread argument. - * sigproc.cc (sigproc_init): Use cygself as argument so that invoked - thread can access its own info. - (wait_sig): Derive cygthread info of thread from thread argument. - -2002-08-06 Conrad Scott - - * debug.h (handle_list::allocated): Remove field. - * debug.cc (newh): Don't malloc extra entries. - (add_handle): Downgrade strace message level. - (delete_handle): Remove case for `allocated' entries. - -2002-08-05 Christopher Faylor - - * cygthread.cc (cygthread::stub): Change event creation to manual - reset. Set __name after calling SetEvent to prevent races. - (cygthread::detach): Always reset event here to prevent races. - -2002-08-03 Conrad Scott - - * debug.h (WaitForMultipleObjects): Correct typo. - -2002-08-01 Pierre Humblet - - * security.cc (verify_token): Do not reject a token just because - the supplementary group list is missing Everyone or a groupsid - equal to usersid, or because the primary group is not in the token, - as long as it is equal to the usersid. - * syscalls.cc (seteuid32): Use common code for all successful returns. - * grp.cc (getgroups32): Never includes Everyone in the output. - -2002-08-01 Christopher Faylor - - * cygthread.cc (cygthread::exit_thread): Define new method. - * cygthread.h (cygthread::exit_thread): Declare new method. - * fhandler.h (fhandler_tty_master::hThread): Delete. - (fhandler_tty_master::output_thread): Define. - * fhandler_tty.cc (fhandler_tty_master::fhandler_tty_master): Adjust - constructor. - (fhandler_tty_master::init): Use cygthread rather than handle. - (process_output): Use cygthread method to exit. - (fhandler_tty_master::fixup_after_fork): Set output_thread to NULL - after fork. - (fhandler_tty_master::fixup_after_exec): Set output_thread to NULL - after spawn/exec. - * tty.cc (tty_list::terminate): Detach from output_thread using - cygthread method. - -2002-08-01 Christopher Faylor - - * syscalls.cc (_link): Revert previous change and just always - dereference the oldpath. - -2002-08-01 Christopher Faylor - - * syscalls.cc (link): Properly deal with a link to a symlink. - -2002-08-01 Christopher Faylor - - * cygthread.cc: Remove cruft. - -2002-08-01 Christopher Faylor - - * Makefile.in (DLL_OFILES): Add cygthread.o. - * dcrt0.cc (dll_crt0_1): Eliminate various thread initialization - functions in favor of new cygthread class. - * debug.cc: Remove thread manipulation functions. - * debug.h: Ditto. - * external.cc (cygwin_internal): Use cygthread method for determining - thread name. Remove capability for setting thread name. - * fhandler_console.cc (fhandler_console::read): Use cygthread method - rather than iscygthread function. - * fhandler_tty.cc (fhandler_tty_master::fhandler_tty_master): Use - cygthread methods to create threads. - (fhandler_tty_common::__acquire_output_mutex): Use cygthread method to - retrieve thread name. - * select.cc (pipeinf): Use cygthread pointer rather than handle. - (start_thread_pipe): Ditto. - (pipe_cleanup): Ditto. - (serialinf): Ditto. - (start_thread_serial): Ditto. - (serial_cleanup): Ditto. - (socketinf): Ditto. - (start_thread_socket): Ditto. - (socket_cleanup): Ditto. - * sigproc.cc (hwait_sig): Ditto. - (hwait_subproc): Ditto. - (proc_terminate): Ditto. - (sigproc_terminate): Ditto. - (sigproc_init): Initialize cygthread hwait_sig pointer. - (subproc_init): Initialize cygthread hwait_subproc pointer. - (wait_sig): Rely on cygthread HANDLE operator. - * strace.cc (strace::vsprntf): Use cygthread::name rather than threadname. - * window.cc (gethwnd): Use cygthread method to initialize thread. - -2002-07-31 Conrad Scott - - * fhandler.h (fhandler_base::get_r_no_interrupt): Make non-virtual. - * net.cc (fdsock): Call set_r_no_interrupt. - -2002-07-30 Christopher Faylor - - * syscalls.cc (_read): Clarify debugging output. - -2002-07-30 Christopher Faylor - - * fhandler.h (fhandler_base::get_r_no_interrupt): Make virtual. - -2002-07-30 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_cygdrive::set_drives): Incorporate . - and .. processing here. - (fhandler_cygdrive::readdir): Assume . and .. are already in pdrive. - (fhandler_cygdrive::seekdir): Ditto. - -2002-07-29 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Move debug_fixup_after_fork_exec. - * cygheap.cc (cygheap_fixup_in_child): Call debug_fixup_after_fork_exec - immediately after cygheap has been set up. - -2002-07-29 Corinna Vinschen - - * security.cc: Change some formatting. - * include/cygwin/version.h: Bump API minor version. - -2002-07-28 Pierre Humblet - - * cygheap.h (class cygheap_user): Add member groups. - * security.h (class cygsidlist): Add members type and maxcount, methods - position, addfromgr, alloc_sids and free_sids and operator+= (const - PSID psid). Modify contains () to call position () and optimize add () - to use maxcount. - (class user_groups): Create. Update declarations of verify_token and - create_token. - * security.cc (cygsidlist::alloc_sids): New. - (cygsidlist::free_sids): New. - (get_token_group_sidlist): Create from get_group_sidlist. - (get_initgroups_sidlist): Create from get_group_sidlist. - (get_group_sidlist): Suppress. - (get_setgroups_sidlist): Create. - (verify_token): Modify arguments. Add setgroups case. - (create_token): Modify arguments. Call get_initgroups_sidlist and - get_setgroups_sidlist as needed. Set SE_GROUP_LOGON_ID from auth_pos - outside of the loop. Rename the various group sid lists consistently. - * syscalls.cc (seteuid32): Modify to use cygheap->user.groups. - (setegid32): Call cygheap->user.groups.update_pgrp. - * grp.cc (setgroups): Create. - (setgroups32): Create. - * uinfo.cc (internal_getlogin): Initialize and update - user.groups.pgsid. - * cygwin.din: Add setgroups and setgroups32. - -2002-07-28 Christopher Faylor - - * fhandler_console.cc (fhandler_console::read): Use appropriate - kill_pgrp method. - * select.cc (peek_console): Ditto. - * fhandler_termios.cc (fhandler_termios::bg_check): Send "stopped" - signal to entire process group as dictated by SUSv3. - * termios.cc (tcsetattr): Detect when stopped signal sent and force a - stop before setting anything. - -2002-07-26 Christopher Faylor - - * include/cygwin/version.h: Bump API version to indicate that ntsec is - on by default now. - -2002-07-26 Conrad Scott - - * fhandler_registry.cc (fhandler_registry::close): Return any error - result to the caller. - * syscalls.cc (_close): Return result of fhandler::close to the caller. - -2002-07-25 Christopher Faylor - - * security.cc (allow_ntsec): Default to on. - (allow_smbntsec): Default to off. - -2002-07-24 David MacMahon - - * times.cc (to_time_t): Always round time_t down to nearest second. - -2002-07-25 Egor Duda - - * Makefile.in: Check if API version is updated when exports are - changed and stop if not so. - -2002-07-24 Egor Duda - - * include/cygwin/version.h: Bump minor API version. - -2002-07-24 Corinna Vinschen - - * fhandler_serial.cc: Change 'must_init_serial_line capability' - to 'supports_reading_modem_output_lines' throughout (negated meaning). - * wincap.cc: Ditto. - * wincap.h: Ditto. - -2002-07-23 Nicholas Wourms - - * cygwin.din (fcloseall): Add symbol for export. - (fcloseall_r): Ditto. - -2002-07-24 Christopher Faylor - - * path.cc (path_conv::check): Always set fileattr when component == 0. - (readlink): Use path_conv method rather than field. - * fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): Ditto, - throughout. - * path.h (path_conv): Make fileattr private. - * exceptions.cc (try_to_debug): Default to idle priority when looping. - -2002-07-23 Corinna Vinschen - - * fhandler_serial.cc: Use must_init_serial_line capability throughout. - * wincap.cc: Set flag must_init_serial_line appropriately. - * wincap.h: Add flag must_init_serial_line. - -2002-07-23 Corinna Vinschen - - * security.cc (get_group_sidlist): Create group list from /etc files - even if DC is available but access fails. - -2002-07-22 Christopher Faylor - - * fhandler_serial.cc: Fix formatting problems introduced by below - changes. - -2002-07-22 Jacek Trzcinski - - * fhandler.h (class fhandler_serial): Add new members of the class - - rts,dtr and method ioctl(). Variables rts and dtr important for Win 9x - only. - * fhandler_serial.cc (fhandler_serial::open): Add initial setting of - dtr and rts. Important for Win 9x only. - (fhandler_serial::ioctl): New function. Implements commands TIOCMGET, - TIOCMSET and TIOCINQ. - (fhandler_serial::tcflush): Fix found error. - (fhandler_serial::tcsetattr): Add settings of rts and dtr. Important - for Win 9x only. - * termios.h: Add new defines as a support for ioctl() function on - serial device. - -2002-07-20 Christopher Faylor - - * autoload.cc (LoadDLLprime): Add jmp call to allow streamlining of - later jmp rewrite. - (doit): Avoid use of cx register. Just change one word to avoid races. - -2002-07-18 Pierre Humblet - - * security.cc (get_unix_group_sidlist): Create. - (get_supplementary_group_sidlist): Evolve into get_unix_group_sidlist. - (get_user_local_groups): Add check for duplicates. - (get_user_primary_group): Suppress. - (get_group_sidlist): Silently ignore PDC unavailability. - Call get_unix_group_sidlist() before get_user_local_groups(). - Remove call to get_supplementary_group_sidlist(). Never call - get_user_primary_group() as the passwd group is always included. - Add well_known_authenticated_users_sid in only one statement. - -2002-07-19 Christopher Faylor - - * fhandler_serial.cc (fhandler_serial::tcflush): Fix typo. - -2002-07-15 Corinna Vinschen - - * security.cc (get_group_sidlist): Fix formatting. - -2002-07-14 Christopher Faylor - - * dcrt0.cc (initial_env): Force path and CYGWIN_DEBUG contents to lower - case. - * exceptions.cc (error_start_init): Use the name derived from - GetModuleName rather than myself->progname. - -2002-07-14 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Move debug_init call back to here. Avoid a - compiler warning. - * shared.cc (memory_init): Remove debug_init call. - * debug.h (handle_list): Change "clexec" to "inherited". - * debug.cc: Remove a spurious declaration. - (setclexec): Conditionalize away since it is currently unused. - (add_handle): Use inherited field rather than clexec. - (debug_fixup_after_fork_exec): Ditto. Move debugging output to - delete_handle. - (delete_handle): Add debugging output. - * fhandler.cc (fhandler_base::set_inheritance): Don't bother setting - inheritance in debugging table since the handle was never protected - anyway. - (fhandler_base::fork_fixup): Ditto. - - * exceptions.cc (debugger_command): Revert. - -2002-07-14 Conrad Scott - - * debug.cc (clexec): Add missing `hl = hl->next'. - -2002-07-14 Christopher Faylor - - * Makefile.in (cygrun.exe): Add a -lcygwin on the end. - -2002-07-14 Christopher Faylor - - * Makefile.in (cygserver.exe): Add -lstdc++. - (cygrun.exe): Move -lgcc last. - -2002-07-13 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Delay closing of some handles until cygheap - has been set up. - (break_here): New function, for debugging. - (initial_env): Add program name to "Sleeping" message. Implement new - "CYGWIN_DEBUG" environment variable option. - * exceptions.cc (debugger_command): Add argument to dumper call. - * strace.cc (strace::hello): Use winpid if cygwin pid is unavailable. - (strace::vsprntf): Ditto. - -2002-07-13 Christopher Faylor - - * debug.h (handle_list): Move here from debug.cc. Add "inherit" flag - functionality. - * cygheap.cc (init_cheap): Move cygheap_max calculation to _csbrk. - (_csbrk): Reorganize to not assume first allocation is <= 1 page. - (cygheap_setup_for_child): Mark protected handle as inheritable. - * cygheap.h (cygheap_debug): New struct. - (init_cygheap): Add new structure when debugging. - * dcrt0.cc (dll_crt0_1): Remove call to debug_init. Close ppid_handle - here, if appropriate. Don't protect subproc_ready, since it is already - protected in the parent. Call memory_init prior to ProtectHandle to - ensure that cygheap is set up. Call debug_fixup_after_fork_exec when - appropriate. - (_dll_crt0): Don't close ppid_handle here. - * debug.cc: Use cygheap debug structure rather than static elements - throughout. - (add_handle): Don't issue a warning if attempt to protect handle in - exactly the same way from exactly the same place. Add pid info to - warning output. Accept additional argument controlling whether handle - is to be inherited. Add pid to stored information. - (debug_fixup_after_fork_exec): Renamed from debug_fixup_after_fork. - Reorganize to avoid erroneously skipping handles. - (mark_closed): Add pid info to warning output. - (setclexec): Rename from setclexec_pid. - * fhandler.cc (fhandler_base::get_default_fmode): Minor reorg. - (fhandler_base::fstat): Add debugging output. - (fhandler_base::set_inheritance): Call setclexec rather than - setclexec_pid. - (fhandler_base::fork_fixup): Ditto. - * fhandler_console.cc (get_tty_stuff): Mark protected handle as - inheritable. - * fhandler_tty.cc (fhandler_tty_slave::open): Ditto. - * tty.cc (tty::make_pipes): Ditto. - (tty::common_init): Ditto. - * fork.cc (fork_parent): Ditto. - (fork_child): Close protected handles with correct name. Remove - debug_fixup_after_fork call. - * fhandler_socket.cc (fhandler_socket::create_secret_event): Mark - protected handle as inheritable/non-inheritable, as appropriate. - * shared.cc (memory_init): Mark protected handle as inheritable. - Call debug_init here. - * sigproc.cc (wait_sig): Close protected handle with correct name. - * spawn.cc (spawn_guts): Rename spr to subproc_ready and mark it as - inheritable. - - * exceptions.cc (debugger_command): Try to run dumper.exe, if found. - - * syscalls.cc (fstat64): Don't follow symlinks for path_conv lookup - since path is already resolved. - -2002-07-12 Christopher Faylor - - * cygwin.din: Change erroneous entries. - -2002-07-11 Pavel Tsekov - - * fhandler_disk_file.cc (fhandler_disk_file::open): Don't - move the file pointer to the end of file if O_APPEND is - specified in the open flags. - -2002-07-09 Christopher Faylor - - * debug.cc: Avoid explicit zeroing of globals. - (lock_debug): Make locker a static member. Avoid unlocking when - already unlocked (from Conrad Scott). - (debug_init): Initialize lock_debug::locker here. - * fork.cc (fork_child): Fix up fdtab earlier to avoid some (but not - all) confusion with close-on-exec craziness. - -2002-07-05 Corinna Vinschen - - * fhandler.h (fhandler_socket::is_unconnected): Constify. - (fhandler_socket::is_connect_pending): Ditto. - (fhandler_socket::is_connected): Ditto. - (fhandler_socket::set_connect_state): New method. - (struct select_record): Add member `except_on_write'. - (select_record::select_record): Initialize all bool values to `false'. - * fhandler_socket.cc: Use set_connect_state() method throughout. - (fhandler_socket::connect): Set state always to connected if connection - isn't pending. - * net.cc (cygwin_getsockopt): Revert erroneous previous patch. - * select.cc (set_bits): Check for `except_on_write'. Set fd in - write_fds if set. Set connect state to connected if fd has been - returned by WINSOCK_SELECT. - (peek_socket): Check for `except_on_write'. - (start_thread_socket): Ditto. - (fhandler_socket::select_write): Don't set `write_ready' if connect - is pending. Set `except_on_write' if connect is pending. - -2002-07-05 Christopher Faylor - - * ntdll.h (_SYSTEM_PROCESSOR_TIMES): Force eight byte alignment. - (_SYSTEM_TIME_OF_DAY_INFORMATION): Ditto. - - * path.cc (suffix_scan::has): Reorganize to eliminate double scanning - for for .exe (in the typical case). - -2002-07-05 Corinna Vinschen - - * fhandler.h (UNCONNECTED): New define. - (CONNECT_PENDING): Ditto. - (CONNECTED): Ditto. - (class fhandler_socket): Add member `had_connect_or_listen'. - Add member functions `is_unconnected', `is_connect_pending' and - `is_connected'. - * fhandler_socket.cc (fhandler_socket::connect): Set member - `had_connect_or_listen' according to return code of WinSock - call. - (fhandler_socket::listen): Ditto. - * net.cc (cygwin_getsockopt): Modify SO_ERROR return value in - case of socket with pending connect(). - * select.cc (peek_socket): Only add socket to matching fd_set - if it's not "ready". Call WINSOCK_SELECT only if at least one - socket is in one of the fd_sets. - (start_thread_socket): Only add socket to matching fd_set - if it's not "ready". - (fhandler_socket::select_write): Set write_ready to true also - if socket isn't connected or listening. - -2002-07-04 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::set_sun_path): Don't free - memory here. Allow NULL parameter. - -2002-07-04 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::dup): Add missing copy operation - on sun_path. - -2002-07-03 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number. - -2002-07-03 Christopher Faylor - - * include/sys/statfs.h: New header file. - -2002-07-03 Christopher Faylor - - * dtable.cc (cygwin_attach_handle_to_fd): Default to implicit bin mode - if none specified. - * fhandler.cc (fhandler_base::init): Make bin argument a guarantee - rather than a suggestion. - * path.cc (path_conv::check): Load flag returned from - cygwin_conv_to_win32_path into path_flags. - -2002-07-03 Conrad Scott - - * tty.cc (tty::common_init): Reverse logic of cygserver check in - call to SetKernelObjectSecurity. - -2002-07-03 Thomas Pfaff - - * autoload.cc (WSAEventSelect): Define new autoload function. - (WSAEnumNetworkEvents): Ditto. - * fhandler_socket.cc (fhandler_socket::accept): If socket is - in blocking mode wait for incoming connection and signal. - -2002-07-02 Christopher Faylor - - * cygheap.cc (init_cheap): Rearrange error message. - (cygheap_fixup_in_child): Ditto. - * dtable.cc: Remove if 0'ed code. - * fhandler_dsp.cc (fhandler_dev_dsp::open): Force binmode. - * sec_helper.cc (cygsid::get_id): Use system_printf for error message. - * tty.cc (tty::common_init): Ditto. - -2002-07-02 Christopher Faylor - - * net.cc (cygwin_getpeername): Defend against NULL pointer dereference. - -2002-07-02 Egor Duda - - * include/cygwin/version.h: Bump API minor version. - -2002-07-01 Pierre Humblet - - * security.cc (get_logon_server): Interpret a zero length - domain as the local domain. - (get_group_sidlist): Add authenticated users SID to SYSTEM's group - list instead of SYSTEM itself. - (verify_token): Accept the primary group sid if it equals - the token user sid. - -2002-07-02 Corinna Vinschen - - * cygwin.din (__fpclassifyd): Add symbol. - (__fpclassifyf): Ditto. - (__signbitd): Ditto. - (__signbitf): Ditto. - -2002-07-02 Corinna Vinschen - - * security.h (DONT_INHERIT): Eliminate definition. - (INHERIT_ALL): Ditto. - (INHERIT_ONLY): Ditto. - * sec_acl.cc: Use appropriate defines from accctrl.h instead of the - above throughout. - * security.cc: Ditto. - -2002-07-01 Pierre Humblet - - * syscalls.c (seteuid32): Return immediately if the program is not - impersonated and both uid and gid are original. - (setegid32): Return immediately if the new gid is the current egid. - -2002-07-01 Christopher Faylor - - * syscalls.cc (seteuid32): Fix incorrect placement of Pierre's patch - below. - -2002-07-01 Christopher Faylor - - * syscalls.cc (seteuid32): Fix incorrect use of system_printf. - -2002-07-02 Christopher January - - * autoload.cc (GetSecurityInfo): Define new autoload function. - (RegQueryInfoKeyA): Ditto. - * fhandler.h (fhandler_virtual::fill_filebuf): Change return type to - bool. - (fhandler_proc::fill_filebuf): Ditto. - (fhandler_registry::fill_filebuf): Ditto. - (fhandler_process::fill_filebuf): Ditto. - (fhandler_registry::value_name): Add new member. - (fhandler_registry::close): Add new method. - (fhandler_process::p): Remove member. - * fhandler_proc.cc (fhandler_proc::open): Add set_nohandle after - calling superclass method. Check return value of fill_filebuf. - (fhandler_proc::fill_filebuf): Change return type to bool. Add return - statement. - * fhandler_process.cc (fhandler_process::open): Add set_nohandle after - calling superclass method. Remove references to p. Check return value - of fill_filebuf. - (fhandler_process::fill_filebuf): Change return type to bool. Don't - use dereference operator on p. Add return statement. - (fhandler_process::format_process_stat): Fix typo. - * fhandler_registry.cc: Add static open_key declaration. - (fhandler_registry::exists): Assume path is already normalised. Try - opening the path as a key in its own right first, before reverting to - enumerating subkeys and values of the parent key. - (fhandler_registry::fstat): Add additional code to return more relevant - information about the registry key/value. - (fhandler_registry::readdir): Explicitly set desired access when - opening registry key. Remove output of buf from debug_printf format - string. - (fhandler_registry::open): Use set_io_handle to store registry key - handle. Set value_name member. Move code to read a value from the - registry to fill_filebuf. Add call to fill_filebuf. - (fhandler_registry::close): New method. - (fhandler_registry::fill_filebuf): Change return type to bool. Add - code to read a value from registry. - (fhandler_registry::open_key): Make function static. Use KEY_READ as - desired access unless this is the last path component. Check the - return value of RegOpenKeyEx for an error instead of hKey. - * fhandler_virtual.cc (fhandler_virtual::lseek): Check the return value - of fill_filebuf. - (fhandler_virtual::open): Remove call to set_nohandle. - (fhandler_virtual::fill_filebuf): Change return type to bool. Add - return statement. - * security.cc (get_nt_object_attribute): New function. - (get_object_attribute): New function. - * security.h (get_object_attribute): New function declaration. - -2002-07-01 Pierre Humblet - - * syscalls.c (seteuid32): Do not return an error when the token cannot - be created only because of a problem with the gid. - -2002-07-01 Christopher Faylor - - * fhandler_clipboard.c (fhandler_dev_clipboard::open): Force text mode. - * fhandler_console.cc (fhandler_console::open): *Really* force binary - mode rather than make it optional. - * fhandler_proc.cc (fhandler_proc::open): Ditto. - * fhandler_process.cc (fhandler_process::open): Ditto. - * fhandler_random.cc (fhandler_dev_random::fhandler_dev_random): Ditto. - * fhandler_raw.cc (fhandler_dev_raw::open): Ditto. - * fhandler_registry.cc (fhandler_registry::open): Ditto. - * fhandler_tty.cc (fhandler_tty_slave::open): Ditto. - * fhandler_virtual.cc (fhandler_virtual::open): Ditto. - * fhandler_windows.cc (fhandler_windows::open): Ditto. - * fhandler_zero.cc (fhandler_dev_zero::open): Ditto. - * net.cc (fdsock): Ditto. - * path.cc (set_flags): Add more debugging. - -2002-07-01 Christopher Faylor - - * debug.cc (threads): Avoid initialization. - * uinfo.cc (cygheap_user::ontherange): (from Corinna Vinschen) Actually - make below changes work. - -2002-07-01 Christopher Faylor - - * uinfo.cc (cygheap_user::ontherange): Make cygwin root the last resort - for HOMEPATH/HOMEDRIVE for consistency with HOME. - -2002-07-01 Corinna Vinschen - - * shared.cc (sec_none): Move to sec_helper.cc. - (sec_none_nih): Ditto. - (sec_all): Ditto. - (sec_all_nih): Ditto. - (get_null_sd): Ditto. - (sec_acl): Ditto. - (__sec_user): Ditto. - * sec_helper.cc (sec_none): Move from shared.cc to here. - (sec_none_nih): Ditto. - (sec_all): Ditto. - (sec_all_nih): Ditto. - (get_null_sd): Ditto. - (sec_acl): Ditto. - (__sec_user): Ditto. - -2002-06-30 Christopher Faylor - - * uinfo.cc (cygheap_user::ontherange): Potentially set HOME from - existing homepath and homedrive cygheap_user fields (not currently used - yet). Set HOME to / if no other alternative. - (cygheap_user::test_uid): Simplify. - -2002-06-30 Christopher Faylor - - * environ.cc (parse_options): Use setenv to potentially replace CYGWIN - value on export. Fixes broken behavior since November 2000 changes. - (regopt): Return indication of whether or not something has been parsed - from the registry. - (environ_init): Only attempt to export CYGWIN variable when values were - set from the registry. It is exported automatically otherwise. - -2002-06-30 Christopher Faylor - - * fhandler.h (fhandler_process::pid): New field. - (fhandler_process::fstat): Remove unneeded array. Set pid element. - (fhandler_process::open): Ditto. - (fhandler_process::fill_filebuf): Handle case where 'p' field is NULL. - -2002-06-30 Christopher Faylor - - * fhandler.h (fhandler_process::p): New field. - (fhandler_process:fill_filebuf): Revert to same definition as virtual - in parent class. - (fhandler_process::open): Fill out p field rather than passing as an - argument. - (fhandler_process::fill_filebuf): Use p pointer rather than argument. - -2002-06-29 Pierre Humblet - - * security.cc (extract_nt_dom_user): Check for all buffer overflows. - Call LookupAccountSid after trying to get domain & user from passwd. - (get_group_sidlist): Obtain the domain and user by calling - extract_nt_dom_user instead of LookupAccountSid. - -2002-06-29 Christopher Faylor - - * uinfo.cc (cygheap_user::test_uid): Use standard issetuid test. - -2002-06-29 Christopher Faylor - - * autoload.cc (NetGetDCName): Change to make this an optional load - function. - * cygheap.h (cygheap_user::logsrv): Return NULL when operation fails. - (cygheap_user::winname): Ditto. - (cygheap_user::domain): Ditto. - * uinfo.cc (cygheap_user::env_logsrv): Save results in temp variable. - (cygheap_user::env_userprofile): Ditto. - -2002-06-29 Christopher Faylor - - * environ.cc (spenv::retrieve): Detect return of env_dontadd from - cygheap_user methods. - (build_env): Avoid incrementing environment pointer if not actually - adding to the environment. That could result in garbage in the - environment table. Be more defensive when reallocing envblock. - -2002-06-29 Christopher Faylor - - * uinfo.cc (cygheap_user::test_uid): Return NULL or further tests are - sorta useless. - (cygheap_user::env_domain): Recalculate if name is missing. - -2002-06-29 Christopher Faylor - - * environ.cc (spenv::from_cygheap): Still need to take setuid into - consideration. - -2002-06-28 Christopher Faylor - - * uinfo.cc (cygheap_user::env_logsrv): Return "almost_null" in case - where no domain or username is "SYSTEM". - -2002-06-28 Christopher Faylor - - * cygheap.h (cygheap_user): Reorg to accommodate environment caching. - (cygheap_user::logsrv): New method. - (cygheap_user::winname): Ditto. - (cygheap_user::domain): Ditto. - (cygheap_user::test_uid): Ditto. - * cygheap.cc (cygheap_user::set_name): Reflect name "pwinname" name - change. - * environ.cc (getwinenveq): New function. - (penv::from_cygheap): penv::from_cygheap): Change arguments. - (spenv::retrieve): Ditto for call. Use getwinenveq to retrieve info - from environment. Always return value from cygwin environment, if it - exists. - * environ.h (getwinenveq): Declare. - * uinfo.cc (cygheap_user::ontherange): Use logsrv() rather than - env_logsrv(). - (cygheap_user::test_uid): Define new method. - (cygheap_user::env_logsrv): Accept environment arguments. Use test_uid - to find info. - (cygheap_user::env_domain): Ditto. - (cygheap_user::env_userprofile): Ditto. - (cygheap_user::env_homepath): Ditto. - (cygheap_user::env_homedrive): Ditto. - (cygheap_user::env_name): Ditto. - -2002-06-27 Christopher Faylor - - * cygheap.cc (cfree_and_set): New function. - (cygheap_user::set_name): Use cfree_and_set to reset members. - * cygheap.h (cygheap_user): Delete static members. - (cygheap_user::puserprof): New member. - (cfree_and_set): Declare. - * dcrt0.cc (almost_null): Define. - * environ.cc (env_dontadd): Redefine as "almost_null". - * winsup.h (almost_null): Declare. - * syscalls.cc (cfree_and_set): Remove unused variable. - * uinfo.cc (cygheap_user::homepath_env_buf): Eliminate. - (cygheap_user::homedrive_env_buf): Ditto. - (cygheap_user::userprofile_env_buf): Ditto. - (cygheap_user::ontherange): YA change to try to preserve existing - HOMEPATH and HOMEDRIVE. Return almost_null values when variables - should not actually exist. - (cygheap_user::env_logsrv): Ditto. - (cygheap_user::env_domain): Ditto. - (cygheap_user::env_userprofile): Ditto. - -2002-06-27 Corinna Vinschen - - * dcrt0.cc (dll_crt0_1): Let __progname point to the applications - basename. Move eliminating ".exe" suffix from argv[0] so that it - always also affects __progname. - -2002-06-27 Thomas Pfaff - - * thread.cc (pthread::create): Add trace printf to get CreateThread - LastError. - -2002-06-27 Corinna Vinschen - - * mmap.cc (list::match): Check using pagesize aligned size. - -2002-06-26 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_disk_file::fstat_by_name): Force - FindFirstFile on first file of directory when asking for x:\ . - -2002-06-26 Christopher Faylor - - * cygheap.cc (cygheap_user::set_name): Correct thinko in below change. - -2002-06-26 Christopher Faylor - - * cygheap.cc (cygheap_user::set_name): Avoid clearing things when just - setting name to itself or during first time initialization. - - * environ.cc (check_case_init): Make case insensitive. - -2002-06-26 Corinna Vinschen - - * fhandler.h (fhandler_socket::bind): Add method definition. - (fhandler_socket::connect): Ditto. - (fhandler_socket::listen): Ditto. - (fhandler_socket::accept): Ditto. - (fhandler_socket::getsockname): Ditto. - (fhandler_socket::getpeername): Ditto. - (fhandler_socket::recvfrom): Ditto. - (fhandler_socket::recvmsg): Ditto. - (fhandler_socket::sendto): Ditto. - (fhandler_socket::sendmsg): Ditto. - (fhandler_socket::shutdown): Ditto. - * fhandler_socket.cc (get_inet_addr): Move here from net.cc. - (fhandler_socket::bind): New method. - (fhandler_socket::connect): Ditto. - (fhandler_socket::listen): Ditto. - (fhandler_socket::accept): Ditto. - (fhandler_socket::getsockname): Ditto. - (fhandler_socket::getpeername): Ditto. - (fhandler_socket::recvfrom): Ditto. - (fhandler_socket::recvmsg): Ditto. - (fhandler_socket::sendto): Ditto. - (fhandler_socket::sendmsg): Ditto. - (fhandler_socket::shutdown): Ditto. - * net.cc: Various formatting cleanups throughout. - (get_inet_addr): Move to fhandler_socket.cc. - (cygwin_bind): Move base functionality to appropriate fhandler_socket - method. - (cygwin_connect): Ditto. - (cygwin_listen): Ditto. - (cygwin_accept): Ditto. - (cygwin_getsockname): Ditto. - (cygwin_getpeername): Ditto. - (cygwin_recvfrom): Ditto. - (cygwin_recvmsg): Ditto. - (cygwin_sendto): Ditto. - (cygwin_sendmsg): Ditto. - (cygwin_shutdown): Ditto. - -2002-06-26 Corinna Vinschen - - * pwdgrp.h (pwdgrp_read::~pwdgrp_read): Avoid compiler warning. - -2002-06-26 Christopher Faylor - - * dcrt0.cc (_dcrt0): Be more defensive when reserved block is used and - it's not cygwin info. - -2002-06-26 Christopher Faylor - - * autoload (noload): Avoid clobbering bx register. - - * environ.cc (codepage_init): Use case insensitive match. - - * fhandler_console.cc (cp_get_internal): Delete. - (con_to_str): Use get_cp to derive code page. - (str_to_con): Ditto. - * miscfuncs.cc (get_cp): New function. - (sys_wcstombs): New function. Converted from macro. - (sys_mbstowcs): Ditto. - * winsup.h: Reflect above changes. - -2002-06-26 Christopher Faylor - - * winsup.h: Minor cleanup. - * path.h (path_conv::[]): New operator. - * syscalls.cc (_link): Use path_conv operators rather than methods, - where appropriate. Minor white space cleanup. - -2002-06-26 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number. - -2002-06-25 Thomas Pfaff - - * include/pthread.h (PTHREAD_CANCELED): Define a reasonable value. - * pthread.cc (pthread_exit): Call method instead of function. - (pthread_setcancelstate): Ditto. - (pthread_setcanceltype): Ditto. - (pthread_testcancel): Ditto. - * thread.h (pthread::cancel_event): New member. - (__pthread_cancel_self): New prototype. - (pthread::exit): New Method. - (pthread::cancel): Ditto. - (pthread::testcancel): Ditto. - (pthread::cancel_self): Ditto. - (pthread::static_cancel_self): Ditto. - (pthread::setcancelstate): Ditto. - (pthread::setcanceltype): Ditto. - (__pthread_cancel): Give c++ linkage. - (__pthread_exit): Remove. - (__pthread_setcancelstate): Ditto. - (__pthread_setcanceltype): Ditto. - (__pthread_testcancel): Ditto. - * thread.cc (pthread::pthread): Inititialize cancel_event. - (pthread::~pthread): Close cancel_event if needed. - (pthread::create): Create cancel_event. - (pthread::exit): New method. Replacement for __pthread_exit. - (pthread::cancel): New method. - (pthread::testcancel): Ditto. - (pthread::static_cancel_self); New static method. - (pthread::setcancelstate): New method. Replacement for - __pthread_setcancelstate. - (pthread::setcanceltype): New method. Replacement for - __pthread_setcanceltype. - (pthread::pop_cleanup_handler): Add lock for async cancel safe - cancellation. - (pthread::thread_init_wrapper): Change __pthread_exit to - thread->exit(). - (__pthread_cancel): Call method thread->cancel(). - (__pthread_exit): Remove. - (__pthread_setcancelstate): Ditto. - (__pthread_setcanceltype): Ditto. - (__pthread_testcancel): Ditto. - -2002-06-25 Christopher Faylor - - * dcrt0.cc (sm): Make NO_COPY. - -2002-06-25 Corinna Vinschen - - * syscalls.cc (chown): Convert uid to 32 bit. - (lchown): Ditto. - (fchown): Ditto. - -2002-06-24 Christopher Faylor - - * dtable.cc (dtable::find_unused_handle): Avoid coercion. - -2002-06-24 Christopher Faylor - - * dtable.cc (fhandler_base::dup2): Cleanup. Ensure that lock is turned - off in error condition. - -2002-06-24 Corinna Vinschen - - * uinfo.cc (internal_getlogin): Set myself->uid and myself->gid instead - of user.real_uid and user.real_gid. - (uinfo_init): Evaluate orig_uid and real_uid from myself->uid. Ditto - for gid. - -2002-06-23 Pierre Humblet - - * security.cc (get_group_sidlist): Add pw argument and use pw->pw_name - in call to get_supplementary_group_sidlist. - (create_token): Add pw argument and use it in call to - get_group_sidlist. - * security.h: Add pw argument in declaration of create_token. - * syscalls.cc (seteuid32): Add pw argument in call to create_token. - -2002-06-23 Conrad Scott - - * fhandler.cc (fhandler_base::fstat): Set S_IFIFO for pipes. - * fhandler_socket.cc (fhandler_socket.cc::fstat): Set S_IFSOCK. - -2002-06-23 Christopher Faylor - - * lib/_cygwin_S_IEXEC.cc: Remove obsolete file. - -2002-06-23 Christopher Faylor - - Use cygwin_{shm,ipc}.h instead of /sys/{shm,ipc}.h throughout. - * sys/ipc.h: Remove. - * sys/shm.h: Remove. - * cygwin_ipc.h: New file. - * cygwin_shm.h: New file. - -2002-06-23 Christopher Faylor - - * cygwin.sc: Add recent changes from ld sources. - -2002-06-23 Conrad Scott - - * winsup.h: Move #ifdef EXPCGF code into "winbase.h". - * winbase.h: #ifdef EXPCGF code moved here from "winsup.h". - -2002-06-12 Thomas Pfaff - - * thread.h (pthread::cleanup_stack): Rename cleanup_handlers to - cleanup_stack. - * thread.cc (pthread::pthread): Ditto. - (pthread::create): Fix mutex verification. - (pthread::push_cleanup_handler): Renam cleanup_handlers to - cleanup_stack. Remvoe Mutex calls, use InterlockedExchangePointer - instead. - (pthread::pop_cleanup_handler): Rename cleanup_handlers to - cleanup_stack. - (pthread::pop_all_cleanup_handlers): Ditto. - (__pthread_once): Check state first and return if already done. - (__pthread_join): Revert DEADLOCK test to __pthread_equal call. - (__pthread_detach): Unlock mutex before deletion. - -2002-06-21 Christopher Faylor - - * Makefile.in (cygrun.exe): Move -lgcc where it will do some good. - -2002-06-21 Corinna Vinschen - - * syscalls.cc (stat64_to_stat32): Correctly evaluate st_rdev. - (fstat64): Set st_rdev to same value as st_dev. - (stat_worker): Ditto. - -2002-06-21 Corinna Vinschen - - * security.cc (alloc_sd): Carefully check owner_sid again after trying - SIDs from cygheap. - -2002-06-21 Corinna Vinschen - - * security.cc (alloc_sd): Remove unnecessary retrieval of owner name. - Check uid for current user first and use SIDs from cygheap if so. - Set errno to EINVAL if user SID isn't retrievable. Just print user SID - as debug output. - Don't bail out if group SID isn't retrievable. Change debug output - appropriately. - -2002-06-21 Christopher Faylor - - * errno.cc: Change text description for EBADF throughout. - -2002-06-20 Pierre Humblet - - * uinfo.cc (cygheap_user::ontherange): Use env_name for NetUserGetInfo. - (cygheap_user::env_logsrv): Verify env_domain is valid. - * environ.cc: Include child_info.h and keep spenvs[] sorted. - (environ_init): Check child_proc_info instead of myself->ppid_handle. - -2002-06-19 Christopher Faylor - - * fhandler.cc (fhandler_base::set_flags): Change priority of "linked - in" default binmode setting so that it has priority over optional - setting. - -2002-06-19 Christopher Faylor - - Use hMainProc where appropriate, throughout. - * environ.cc (spenv::retrieve): Add debugging statements. - - * pinfo.cc (set_myself): Don't call strace.hello if already stracing. - * strace.cc (strace): Move NO_COPY keyword so that it will actually - take effect. - -2002-06-19 Corinna Vinschen - - * uinfo.cc (cygheap_user::ontherange): Call NetUserGetInfo() only with - non-NULL logserver parameter. - -2002-06-16 Christopher Faylor - - * cygheap.h (cygheap_user::issetuid): New method. - * dtable.cc (dtable::vfork_child_dup): Use new method to determine if - we are in "setuid mode." - * fork.cc (fork_parent): Ditto. - * spawn.cc (spawn_guts): Ditto. - * syscalls.cc (seteuid32): Ditto. - (setegid32): Ditto. - * environ.cc (spenv::retrieve): (Suggested by Pierre Humblet) Do - potential recalculation of cygheap_user stuff when in setuid mode. - Return special value when environment variable should be calculated but - not added. - (build_env): Don't add retrieved value to dstp if it is 'dont_add'. - -2002-06-16 Christopher Faylor - - Changes suggested by Pierre Humblet. - * environ.cc (NL): New macro. - (conv_envvars): Use NL macro to fill in name and namelen. - (spenv::namelen): New field. - (spenvs): Use NL to fill in name and namelen. - (spenv::retrieve): Eliminate length argument. Instead, use namelen - throughout. - (build_env): Don't calculate length of initial FOO= part of - environment. Accommodate spenv::retrive argument change. - -2002-06-16 Christopher Faylor - - * cygheap.h (cygheap_user::winname): New field. - * cygheap.cc (cygheap_user::set_name): Clear winname when name changes. - * uinfo.cc (cygheap_user::env_logsrv): Avoid calculating server when - Windows user == SYSTEM. - (cygheap_user::env_domain): Set winname here too. - (cygheap_user::env_userprofile): Eliminate superfluous tests. - (cygheap_user::env_name): Seed winname by calling env_domain(). - -2002-06-12 Pierre Humblet - - * spawn.cc (spawn_guts): Revert removal of ciresrv.moreinfo->uid = - ILLEGAL_UID. - -2002-06-15 Christopher Faylor - - * child_info.h (child_proc_info): Declare as base class. - (spawn_info): Declare as alias of child_proc_info to aid debugging. - (fork_info): Ditto. - * cygheap.cc (cygheap_fixup_in_child): Use child_proc_info global - rather than parameter. - * cygheap.h (cygheap_fixup_in_child): Reflect above change in - declaration. - * dcrt0.cc (_dll_crt0): Move 'si' definition here. Assign - child_proc_info. - (dll_crt0_1): Accommodate cygheap_fixup_in_child and *_info changes. - * environ.cc (spenv::retrieve): Make regparm. - * environ.h (environ_init): Ditto. - (win_env::add_cache): Ditto. - (build_env): Ditto. - (getwinenv): Ditto. - * fork.cc (sync_with_parent): Use fork_info global. - (fork_child): Ditto. - -2002-06-14 Christopher Faylor - - * uinfo.cc (cygheap_user::ontherange): Don't set HOMEDRIVE or HOMEPATH - unless one or the other is specified. - -2002-06-14 Christopher Faylor - - * cygheap.h (cygheap_user::userprofile_env_buf): New static member. - * environ.cc (build_env): Add debugging statement. - (spenvs): Switch functions for USERDOMAIN and USERNAME. - * spawn.cc (spawn_guts): Move environment initialization prior to - cygheap_setup_for_child or environment info will never be copied to - child. - -2002-06-14 Christopher Faylor - - * cygheap.h (cygheap_user): Add static members to hold home{drive,path} - info. - * uinfo.cc (cygheap_user::ontherange): Use static class members for - local HOME* storage. - -2002-06-14 Christopher Faylor - - * cygheap.cc (cygheap_user::set_logsrv): Remove. - (cygheap_user::set_domain): Ditto. - * cygheap.h (cygheap_user::set_logsrv): Remove declaration. - (cygheap_user::set_domain): Ditto. - (cygheap_user::env_domain): Declare new method. - (cygheap_user::env_name): Ditto. - * environ.cc (spenvs): Add two environment variables. - * spawn.cc (spawn_guts): Call build_env after RevertToSelf. Always set - ciresrv.mount_h. - (cygheap_user::ontherange): Recalculate homedrive/homepath if they are - empty. Use env_logsrv to get logon server. - (cygheap_user::env_logsrv): Calculate server name here rather than - relying on it having been previously calculated. - (cygheap_user::env_domain): Ditto for domain name. - (cygheap-user::env_name): New method. - -2002-06-12 Pierre Humblet - - * syscalls.cc (seteuid32): Do not get or set the environment. Do not - call LookupAccountSid nor internal_getlogin. Set cygheap->user name - and sid from the passwd entry. - * uinfo.cc (uinfo_init): Only call internal_getlogin when starting from - a non Cygwin process and use the values returned in user. - (internal_getlogin): Simplify to case where starting from a non Cygwin - process. Store return values in user and return void. Do not set the - Windows default environment. - * dcrt0.cc (dll_crt0_1): Call uinfo_init only when needed. Do not set - myself->uid nor reset user.sid. - * spawn.cc (spawn_guts): Get the sid from cygheap->user. Always - RevertToSelf(). Don't set uid in impersonated case. - * cygheap.cc (cygheap_user::set_sid): Do not set orig_sig. - (cygheap_user::set_orig_sid): New. - * cygheap.h: Declare cygheap_user::set_sid. - * winsup.h: Add argument to uinfo_init(). - -2002-06-14 Corinna Vinschen - - * environ.cc (build_env): If realloc moves envblock, move s with it. - -2002-06-13 Nicholas S. Wourms - - * winver.rc: Add more words to copyright. - -2002-06-13 Corinna Vinschen - - * cygheap.cc (cygheap_user::set_name): Revert previous change. - * environ.cc (spenv::retrieve): Check return value of call to - cygheap->user.*from_cygheap(). - -2002-06-13 Corinna Vinschen - - * cygheap.cc (cygheap_user::set_name): Remove setting homedrive and - homepath to NULL. - (cygheap_user::set_logsrv): Fix free'ing of plogsrv. - * cygheap.h (cygheap_user::cygheap_user): Initialize homedrive and - homepath to NULL. - -2002-06-13 Christopher Faylor - - * security.cc (get_logon_server): Use strcasematch rather than - strcasecmp. - -2002-06-12 Christopher Faylor - - * path.cc (chdir): Minor cleanup. - -2002-06-12 Christopher Faylor - - * environ.cc (build_env): Correctly fill out windows environment block - with win32 paths rather than posix paths. - -2002-06-12 Christopher Faylor - - * cygheap.cc (cygheap_user::set_name): Set homedrive and homepath to - NULL on user name change. - (cygheap_user::set_logsrv): Allocate enough space for leading \\ so - that we can put this in the environment, if needed. - * cygheap.h (homebodies): New enum. - (cygheap_user::homedrive): New field. - (cygheap_user::homepath): Ditto. - (cygheap_user::env_logsrv): New method. - (cygheap_user::env_homepath): New method. - (cygheap_user::env_homedrive): New method. - (cygheap_user::env_userprofile): New method. - (cygheap_user::ontherange): New method. - * environ.cc (envsize): Eliminate debugging argument. - (environ_init): Assume that envc counts number of elments not total - size. - (spenv): New class. - (spenvs): New array, rename from forced_winenv_vars, using spenv. - (spenv::retrieve): New method. - (build_env): Rename from 'winenv' -- one stop shopping for building new - environment blocks for both windows and "unix". - * environ.h (build_env: Declare. - (winenv): Delete declaration. - (envsize): Ditto. - * spawn.cc (spawn_guts): Use build_env to build windows and cygwin - environment blocks. - * uinfo.cc (internal_getlogin): Eliminate environment manipulation. - Default to info from GetUserName if it exists. Move HOMEPATH and - HOMEDRIVE stuff elsewhere. Move HOME setting elsewhere. Only set HOME - environment variable in processes that are not parented by a cygwin - process. - (cygheap_user::ontherange): Define new method. - (cygheap_user::env_logsrv): Ditto. - (cygheap_user::env_homepath): Ditto. - (cygheap_user::env_homedrive): Ditto. - (cygheap_user::env_userprofile): Ditto. - -2002-06-11 Christopher Faylor - - * spawn.cc (spawn_guts): More hToken removal cleanup. - -2002-06-09 Pierre Humblet - - * spawn.cc (spawn_guts): Define sec_attribs and call sec_user_nih() - only once. - -2002-06-10 Christopher Faylor - - * Makefile.in: Ensure that -MD gets added to CFLAGS regardless of - CFLAGS command-line setting. - - * cygwin.din: Export sexec* functions as function which returns ENOSYS - (i.e., sexec* is deprecated). - * dtable.cc (dtable::vfork_child_dup): Ensure that impersonation is - restored even on failure. - * exec.cc: Throughout, remove references to sexec* and _spawnve. - * pinfo.h: Remove _spawnve declaration. - * spawn.cc: Rename _spawnve to spawnve and use throughout. - (spawn_guts): Eliminate hToken argument and processing of same. Just - perform special actions if impersonating. - (spawnve): Rename from _spawnve. - -2002-06-10 Christopher Faylor - - * include/sys/strace.h (strace): Avoid use of constructor. - -2002-06-10 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Initialize wincap and check for sanity before - running global ctors. - * wincap.h (wincap): Eliminate constructor. Default is to zero memory, - anyway. - * wincap.cc (wincap): Copy this on fork to avoid initialization in - forked processes. - -2002-06-10 Corinna Vinschen - - * fhandler.h (fhandler_socket::fixup_after_fork): Revert patch from - 2002-06-04. - * fhandler_socket.cc (fhandler_socket::fixup_after_fork): Ditto. - (fhandler_socket::dup): Ditto. - * net.cc (fdsock): Make sockets explicitely noninheritable on NT. - -2002-06-09 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): Correctly - set number of links for directory, if appropriate. - -2002-06-10 Robert Collins - - * thread.cc: Variation of a patch from Thomas Pffaf. - (__pthread_detach): Cleanup thread object if the thread has terminated. - (__pthread_join): Change order of error checks, and lock against - join/detach/exit races. - (__pthread_exit): Lock object against join/detach/exit races. - (pthread::thread_init_wrapper): Ditto. - (thread_init_wrapper): Rename to pthread::thread_init_wrapper. - (pthread::create): Check that the mutex initialized correctly. - (pthread::push_cleanup_handler): Lock against potential cancellation - race. NB: this may not be required if pthread_cleanup_push is non- - cancelable. - * thread.h (pthread::mutex): New member. - (thread_init_wrapper): Rename to pthread::thread_init_wrapper. - (pthread::thread_init_wrapper_: New static member. - -2002-06-10 Robert Collins - - * cygwin.din: Add _pthread_cleanup_push and _pthread_cleanup_pop. - * pthread.cc: Change __pthread_self to pthread::self() thruoghout. - (_pthread_cleanup_push): New function. - (_pthread_cleanup_pop): Ditto. - * thread.cc: Thanks to Thomas Pfaff for the pthread cleanup_push,_pop - patch, this work is derived from that. - Change __pthread_self to pthread::self() thruoghout. - (__pthread_self): Rename to pthread::self. - (pthread::self): New method. - (pthread::pthread): Initialize new member. - (pthread::push_cleanup_handler): New method. - (pthread::pop_cleanup_handler): New method. - (pthread::pop_all_cleanup_handlers): New method. - (__pthread_exit): Pop all cleanup handlers. - * thread.h (pthread::push_cleanup_handler): Declare. - (pthread::pop_cleanup_handler): Ditto. - (pthread::pop_all_cleanup_handlers): Ditto. - (pthread::self): New static method. - (__pthread_exit): Give C++ linkage. - (__pthread_join): Ditto. - (__pthread_detach): Ditto. - (__pthread_self): Remove. - -2002-04-24 Thomas Pfaff - - * include/pthread.h (__pthread_cleanup_handler): New structure. - (pthread_cleanup_push): Rewritten. - (pthread_cleanup_pop): Ditto. - (_pthread_cleanup_push): New prototype. - (_pthread_cleanup_pop): Ditto. - -2002-04-24 Thomas Pfaff - - * thread.cc (thread_init_wrapper): Check if thread is already joined. - (__pthread_join): Set joiner first. - (__pthread_detach): Ditto. - -2002-06-10 Robert Collins - - * cygserver_transport.cc (create_server_transport): Finish the split - out of sockets code from transport_layer_base. Thanks to Nicholas - Wourms and Conrad Scott for catching this. - -2002-06-08 Christopher Faylor - - * pinfo.cc (pinfo_dummy): Initialize to correct size. - -2002-06-08 Christopher Faylor - - * path.cc: Change MOUNT_AUTO to MOUNT_CYGDRIVE throughout. - * shared_info.h (CURR_MOUNT_MAGIC): Update. - -2002-06-08 Christopher Faylor - - * external.cc (cygwin_internal): Make v1 mount table access invalid. - * path.cc (mount_info::init): Remove had_to_create_mount_areas initialization. - (mount_info::from_registry): Remove v1 table import. - (mount_info::read_v1_mounts): Eliminate. - (mount_info::import_v1_mounts): Ditto. - * shared_info.h (mount_info): Ditto for both of above. - * sys/mount.h (MOUNT_DEVFS): New enum. - (MOUNT_PROC): Ditto. - -2002-06-08 Christopher Faylor - - * include/wchar.h: Define __need_size_t. - -2002-06-07 Christopher Faylor - - * fhandler_socket.cc (fhandler_socket::fstat): Don't assume that socket - is unix-domain socket. - -2002-06-07 Christopher Faylor - - * times.cc (hires_ms::prime): Set init flag. - -2002-06-07 Conrad Scott - - * times.cc (hires_ms::prime): Adjust epoch of initime_us from 1601 to - 1970. - -2002-06-06 Christopher Faylor - - * autoload.cc (timeGetDevCaps): Define new autoload function. - (timeGetTime): Ditto. - (timeBeginPeriod): Ditto. - (timeEndPeriod): Ditto. - * hires.h (hires_base): New class. Rename from hires. - (hires_us): New class. - (hires_ms): New class. - * strace.cc (strace::microseconds): Use hires_us class. - * times.cc (gettimeofday): Use hires-ms class. - (hires_us::prime): Rename from hires::prime. - (hires_us::usecs): Rename from hires:usecs. - (hires_ms::prime): New method. - (hires_ms::usecs): New method. - (hires_ms::~hires_ms): New destructor. - -2002-06-06 Christopher Faylor - - * autoload.cc (noload): Correctly save argument count register. - -2002-06-05 Conrad Scott - - * fhandler.cc (fhandler_base::fstat): Initialise tv_nsec member of - st_atim, st_mtim, and st_ctim fields. - * fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): Ditto. - * fhandler_process.cc (fhandler_process::fstat): Ditto. - * glob.c (stat32_to_STAT): Copy across the whole st_atim, st_mtime, and - st_ctim fields. - * syscalls.cc (stat64_to_stat32): Ditto. - * times.cc (to_timestruc_t): New function. - (time_as_timestruc_t): New function. - * winsup.h: Add to_timestruc_t and time_as_timestruc_t functions. - * include/cygwin/stat.h: Replace time_t with timestruc_t throughout for - all file times, removing the st_spare1, st_spare2, and st_spare3 fields - in the process. Add macros to access tv_sec fields by old names. - * include/cygwin/types.h: Typedef timespec_t and timestruc_t as struct - timespec. - -2002-06-03 Pierre Humblet - - * sec_helper.cc (lookup_name): Suppress. - * security.cc (alloc_sd): Remove logsrv argument. - Remove two calls to lookup_name. - (set_security_attribute): Remove logsrv argument. - Remove logsrv argument in call to alloc_sd. - (set_nt_attribute): Remove logsrv argument. - Remove logsrv argument in call to set_security_attribute. - (set_file_attribute): Remove logsrv argument. - Remove logsrv argument in call to set_nt_attribute. - (set_file_attribute): Remove logsrv argument. - Remove logsrv argument in call to set_file_attribute. - * syscalls.cc (chown_worker): Remove logserver argument in - call to set_file_attribute. - (chmod): Ditto. - * shm.cc (shmget): Remove logsrv argument in call to alloc_sd. - * uinfo.cc (internal_getlogin): Replace calls to - lookup_name by call to LookupAccountName. - * security.h: Remove logsrv in declarations of set_file_attribute - and alloc_sd. Remove declaration of lookup_name. - -2002-06-05 Christopher Faylor - - * child_info.h (CHILD_INFO_MAGIC): Oops. Revert previous change. gcc - 3.1 bug? - -2002-06-05 Christopher Faylor - - * child_info.h (CHILD_INFO_MAGIC): Update. - -2002-06-05 Christopher Faylor - - * strace.cc (strace::hello): Set inited, when appropriate. - -2002-06-05 Christopher Faylor - - * cygwin.din: Eliminate some newlib wrappers. - * path.cc (get_devn): Only consider first 99 potential com devices. - (get_device_number): Ditto. - * times.cc (_times): Eliminate. - (_times): Rename from times(). - -2002-06-05 Christopher Faylor - - * dir.cc (rmdir): Streamline. Detect attempts to remove directories - from "read-only" virtual devices. (Suggested by Pavel Tsekov) - * syscalls.cc (unlink): Detect attempts to remove directories from - "read-only" virtual devices. (From Pavel Tsekov) - -2002-06-05 Christopher Faylor - - * dtable.cc (handle_to_fn): Check error return value from NtQueryObject - first before seeing if name buffer is NULL. - - * grp.cc (read_etc_group): Fix gcc warning regarding snprintf format. - * passwd.cc (read_etc_passwd): Ditto. - -2002-04-18 Thomas Pfaff - - * thread.h (pthread::joiner): New member. - * thread.cc (pthread::pthread): Initialize joiner to NULL - (pthread::create): Increment of thread counter moved from - __pthread_create to this location. - (__pthread_create): Increment thread counter removed. - (thread_init_wrapper): Set joiner to self when thread was created - detached. - (__pthread_exit): delete thread when it is detached and not - joined. - (__pthread_join): Check for deadlock and delete thread when it has - terminated. - (__pthread_detach): Set joiner to self when thread state - changed to detached. - -2002-06-05 Corinna Vinschen - - * grp.cc (read_etc_group): When emulating nonexisting group file on - NT systems, read primary group SID from process token. Use that info - to create correct group entry. On error or on 9x systems fallback - to emulating Administrators group as before. - * passwd.cc (read_etc_passwd): When emulating nonexisting passwd file - on NT systems, read user and primary group SID from process token. - Use that info to create correct passwd entry. On error or on 9x - systems fallback to emulating user with Administrator user id and - Administrators group as before. - -2002-06-05 Corinna Vinschen - - * grp.cc (etc_group): Removed. - (parse_grp): Make line parameter nonconst. Don't copy data into new - allocated memory. Check for CR instead of LF to accomodate new - read method. - (add_grp_line): Make line parameter nonconst. - (read_etc_group): Rearrange using new pwdgrp_read class. - * passwd.cc (parse_pwd): Don't copy data into new allocated memory. - Check for CR instead of LF to accomodate new read method. - (read_etc_passwd): Rearrange using new pwdgrp_read class. - * pwdgrp.h (pwdgrp_check::set_last_modified): Use different - parameters. - (class pwdgrp_read): New class for opening and reading passwd and - group files. - -2002-06-04 Christopher Faylor - - * dtable.cc (handle_to_fn): Attempt to handle "raw" accesses to remote - shares. - * path.cc (mount_info::conv_to_win32_path): Set flags to binary when - mount entry is not found. - (mount_info::set_flags_from_win32_path): Ditto. - -2002-06-04 Christopher Faylor - - * dtable.cc (handle_to_fn): Correct placement and length of name - buffer. (Suggested by Pavel Tsekov) - -2002-06-04 Christopher Faylor - - Remove fcntl.h includes throughout. - * fhandler.h: Move fcntl.h include here. - (fhandler_base::set_flags): Accept supplied_bin argument. Make - non-inlined. - * dtable.cc (dtable::init_std_file_from_handle): Just use binmode from - pc. - (reset_to_open_binmode): Use set_flags. - * cygwin.din (open): Avoid newlib wrapper. - (read): Ditto. - (unlink): Ditto. - (write): Ditto. - * fhandler.cc (fhandler_base::set_flags): Accept supplied_bin argument. - Make binmode decisions here. - (fhandler_base::open): Avoid using pc if it is NULL. Eliminate binmode - logic. Just call set_flags with binmode argument. - (fhandler_base::init): Call set_flags with binmode argument. - * fhandler_clipboard.cc (fhandler_dev_clipboard::open): Ditto. - * fhandler_console.cc (fhandler_console::open): Ditto. - (fhandler_console::init): Force binary on open. - * fhandler_disk_file.cc (fhandler_disk_file::open): Don't set binmode - here. Let it happen in base class. - * fhandler_dsp.cc (fhandler_dev_dsp::open): Force binmode open. Set - return value appropriately if unable to open. - * fhandler_proc.cc (fhandler_proc::open): Make sure flags are set - before open_status. - * fhandler_process.cc (fhandler_process::open): Ditto. - * fhandler_registry.cc (fhandler_registry::open): Ditto. - * fhandler_random.cc (fhandler_dev_random::fhandler_dev_random): Ditto. - * fhandler_raw.cc (fhandler_dev_raw::open): Force O_BINARY by default. - * fhandler_serial.cc (fhandler_serial::init): Ditto. - * fhandler_tty.cc (fhandler_tty_slave::open): Ditto. - (fhandler_pty_master::open): Ditto. - * fhandler_virtual.cc (fhandler_virtual::open): Ditto. - * fhandler_windows.cc (fhandler_windows::open): Ditto. - * fhandler_zero.cc (fhandler_dev_zero::open): Ditto. - * net.cc (fdsock): Ditto. - * path.cc (path_conv::check): Avoid checking for executable extension - when directory. (Suggested by Pavel Tsekov) - (set_flags): Set PATH_TEXT explicitly, when appropriate. - (mount_info::conv_to_win32_path): Use set_flags() to set path flags. - * path.h (PATH_TEXT): New enum. - (path_conv::binmode): Return appropriate constant based on binmode. - * pipe.cc (make_pipe): Set binmode to O_TEXT xor O_BINARY. - * syscalls.cc (setmode_helper): Make debugging message a little - clearer. - (setmode): Set binmode via set_flags. - -2002-06-04 Corinna Vinschen - - * fhandler.h (class fhandler_socket): Add private method - fixup_after_fork (bool, HANDLE). - * fhandler_socket.cc (fhandler_socket::fixup_after_fork): Move - functionality to new private method. Add closing parent socket - if not called from dup(). Create method new calling private method - with appropriate parameter. - (fhandler_socket::fixup_after_exec): Call private method - fixup_after_fork with appropriate parameter. - (fhandler_socket::dup): Ditto. - -2002-06-04 Corinna Vinschen - - * fhandler_dsp.cc (fhandler_dev_dsp::open): Set errno to EACCES if - requested mode isn't supported. - -2002-06-03 Christopher Faylor - - * fhandler.cc (fhandler_base::open): Don't set binmode if already set. - Don't check for file. Files should already be set. Report on binary - mode for debugging. - (fhandler_base::fhandler_base): Don't set default binmode here. That's - for later. - * fhandler_console.cc (fhandler_console::output_tcsetattr): Don't set - binmode, ever, for console. - * fhandler_disk_file.cc (fhandler_disk_file::open): Always set the - binary mode to the value derived from mount table. - * path.cc (mount_info::conv_to_win32_path): Default to binmode if path - does not translate into anything in the mount table. - -2002-06-03 Corinna Vinschen - - * external.cc (cygwin_internal): Add CW_EXTRACT_DOMAIN_AND_USER - handling to call extract_nt_dom_user() from applications. - * include/sys/cygwin.h (cygwin_getinfo_types): Add - CW_EXTRACT_DOMAIN_AND_USER. - -2002-06-03 Corinna Vinschen - - * syscalls.cc (stat64_to_stat32): Transform st_dev correctly. - (fstat64): Add evaluating st_ino and st_dev. - (stat_worker): Evaluate st_dev as 32 bit value. - * include/cygwin/stat.h: Use new dev_t definition throughout. - * include/cygwin/types.h: Define __dev16_t and __dev32_t. Define - dev_t according to __CYGWIN_USE_BIG_TYPES__ setting. - * include/sys/sysmacros.h: Define major, minor and makedev - according to __CYGWIN_USE_BIG_TYPES__ setting. - -2002-06-03 Pierre Humblet - - * syscalls.cc (setegid32): Verify the correctness of the gid - of the group returned by getgrgid32. - -2002-06-03 Pierre Humblet - - * security.cc (lsa2wchar): Suppressed. - (get_lsa_srv_inf): Suppressed. - (get_logon_server_and_user_domain): Suppressed. - (get_logon_server): Essentially new. - (get_user_groups): Add "domain" argument. Only lookup the - designated server and use "domain" in LookupAccountName. - (is_group_member): Simplify the arguments. - (get_user_local_groups): Simplify the arguments. Do only a - local lookup. Use "BUILTIN" and local domain in LookupAccountName. - (get_user_primary_group). Only lookup the designated server. - (get_group_sidlist): Remove logonserver argument. Do not lookup - any server for the SYSTEM account. - (create_token): Delete logonserver and call to get_logon_server. - Adjust arguments of get_group_sidlist, see above. - * security.h: Delete declaration of get_logon_server_and_user_domain - and add declaration of get_logon_server. - * uinfo.cc (internal_get_login): Call get_logon_server instead of - get_logon_server_and_user_domain. - -2002-06-02 Christopher Faylor - - * dtable.cc (handle_to_fn): Use largest match for device. Correctly - (?) deal with remote drive weirdness. - -2002-06-02 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_disk_file::fstat_by_name): Check - specifically for non-existent file, first. - (fhandler_disk_file::fstat): Perform fd open on files with funny - characters. - -2002-06-02 Christopher January - - * fhandler_process.cc (fhandler_process::open): Set fileid. - -2002-06-02 Christopher Faylor - - Remove unneeded sigproc.h includes throughout. - * fhandler.h (fhandler_proc::fill_filebuf): Take a pinfo argument. - * fhandler_proc.cc (fhandler_proc::get_proc_fhandler): Simplify search - for given pid. - (fhandler_proc::readdir): Assume that pid exists if it shows up in the - winpid list. - * fhandler_process.cc (fhandler_process::open): Simplify search for - given pid. Call fill_filebuf with pinfo argument. - (fhandler_process::fill_filebuf): Pass pinfo here and assume that it - exists. - * pinfo.h (pinfo::remember): Define differently if sigproc.h is not - included. - -2002-06-02 Christopher Faylor - - * dll_init.cc (dll_list::detach): Don't run destructor on exit. - -2002-06-01 Christopher Faylor - - * fhandler.cc (fhandler_base::fstat): Move dev and ino calculation into - caller. - * syscalls.cc (stat_worker): Calculate dev and ino calculation here, if - zero. - * fhandler_proc.cc (fhandler_proc::fhandler_proc): Minor reorg for - debugging. - * fhandler_process.cc (fhandler_process::exists): Return 0 on - nonexistence. - (fhandler_process::fstat): Simplify pid logic. - * fhandler_tape.cc (fhandler_dev_tape::fstat): Minor reformatting. - -2002-06-01 Christopher Faylor - - * path.cc (chdir): Don't allow cd'ing to a non-directory virtual path. - -2002-05-31 Christopher Faylor - - * fhandler_disk_file.cc (readdir): Move inode calculation into caller. - (fhandler_cygdrive::readdir): Add "." and "..". - * dir.cc (readdir): Move inode calculation here so that fhandler - readdirs can benefit. - -2002-05-31 Christopher Faylor - - * fhandler_console.cc (fhandler_console::open): Reinstate setting of - flags. - - * dtable.cc (dtable::init_std_file_from_handle): Default to using - binmode derived from path_conv, when required. - * fhandler.h (fhandler_base::get_w_binary): Default to binmode if - nothing else is specified. - * fhandler.h (fhandler_base::get_r_binary): Ditto. - - * fhandler_disk_file.cc (fhandler_disk_file::fstat_by_handle): Work - around g++ warning. - - * path.cc (path_conv::check): Remove a debugging statement. - -2002-05-31 Christopher Faylor - - * fhandler_console.cc (fhandler_console::open): Always default to - binmode. - (fhandler_console::write_normal): Don't honor binmode setting. There - is already a termios setting for this. - (fhandler_console::init): Correct argument order in init call. - -2002-05-31 Christopher Faylor - - * fhandler.cc (fhandler_base::open): Make default open mode == binmode. - (fhandler_base::init): Set open flags based on derived binmode argument. - -2002-05-31 Christopher Faylor - - * dll_init.cc (dll_list::init): Eliminate unneeded debugging statement. - -2002-05-31 Christopher Faylor - - * fhandler_proc.cc (fhandler_proc::readdir): Set errno when no more - files. - * fhandler_process.cc (fhandler_process::readdir): Ditto. - * fhandler_registry.cc (fhandler_registry::readdir): Ditto. - -2002-05-30 Christopher Faylor - - * path.cc (path_conv::check): Set fileattr to INVALID_FILE_ATTRIBUTES - for nonexistent virtual device path. - (chdir): Set correct errno when attempt is made to cd to nonexistent - virtual device path. - -2002-05-30 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_disk_file::fstat): Always call - fstat_by_name if fd is not opened to allow fstat_by_name to properly - set errno. - -2002-05-30 Corinna Vinschen - - * autoload.cc: Replace autoload statments for ZwXXX by NtXXX. - Drop ZwQuerySystemInformation since NtQuerySystemInformation was - already available. - * fhandler_proc.cc (format_proc_uptime): Replace call to - ZwQuerySystemInformation by call to NtQuerySystemInformation. - (format_proc_stat): Ditto. - * fhandler_process.cc (format_process_stat): Replace call to - ZwQueryInformationProcess by call to NtQueryInformationProcess. - (get_process_state): Ditto. - (get_mem_values): Ditto. Replace call to ZwQueryVirtualMemory by - call to NtQueryVirtualMemory. - * ntdll.h: Cleanup. Drop ZwQuerySystemInformation since - NtQuerySystemInformation was already available. Replace declarations - of ZwXXX functions by declarations of NtXXX. - * pinfo.cc (winpids::enumNT): Replace call to ZwQuerySystemInformation - by call to NtQuerySystemInformation. - -2002-05-29 Christopher Faylor - - * fhandler.cc (binmode): Default to binmode when mode is not known. - -2002-05-29 Christopher Faylor - - * include/sys/cygwin.h (EXTERNAL_PINFO_VERSION): Reinstate. - * external.cc (fillout_pinfo): Use it. - -2002-05-29 Corinna Vinschen - - * external.cc (fillout_pinfo): Use new version define. - * include/sys/cygwin.h (external_pinfo): Define - EXTERNAL_PINFO_VERSION_16_BIT and EXTERNAL_PINFO_VERSION_32_BIT - instead of just EXTERNAL_PINFO_VERSION. - -2002-05-29 Christopher Faylor - - * external.cc (fillout_pinfo): Set new version field in external_pinfo - structure. - * include/sys/cygwin.h (external_pinfo): Replace strace_file with - version field. - -2002-05-29 Corinna Vinschen - - Change internal uid datatype from __uid16_t to __uid32_t - throughout. - * cygwin.din: Export new symbols getpwuid32, getpwuid_r32, getuid32, - geteuid32, setuid32, seteuid32. - * passwd.cc (getpwuid32): New function. - (getpwuid_r32): Ditto. - * syscalls.cc (seteuid32): Ditto. - (setuid32): Ditto. - * uinfo.cc (getuid32): Ditto. - (geteuid32): Ditto. - * winsup.h (uid16touid32): New macro, correct casting from __uid16_t - to __uid32_t. - (gid16togid32): Ditto fir gids. - (getuid32): Declare. - (geteuid32): Ditto. - (getpwuid32): Ditto. - * include/sys/cygwin.h (struct external_pinfo): Add members uid32 and - gid32. - -2002-05-29 Corinna Vinschen - - * include/cygwin/socket.h: Protect some symbols against multiple - definition. - * include/netinet/ip.h: Ditto. - * include/netinet/tcp.h: Ditto. - -2002-05-29 Wu Yongwei - - * include/netinet/ip.h: Replace by BSD derived version of the file. - * include/netinet/tcp.h: Ditto. - * include/netinet/udp.h: New file. - * include/cygwin/ip.h: Remove. - -2002-05-29 Christopher Faylor - - * dtable.cc (dtable::init_std_file_from_handle): Attempt stronger - detection of invalid handle. - (handle_to_fn): Detect pathological condition where NT resets the - buffer pointer to NULL on an invalid handle. - -2002-05-28 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): Properly - check for whether we should be opening the file to search for #! - characters. Set path_conv structure execability, too, when - appropriate. - -2002-05-28 Corinna Vinschen - - * security.cc (set_security_attribute): Call getegid32() instead of - getegid(). - * include/cygwin/grp.h: Declare getegid32(). - -2002-05-28 Corinna Vinschen - - Change internal gid datatype from __gid16_t to __gid32_t - throughout. - * cygwin.din: Export new symbols chown32, fchown32, getegid32, - getgid32, getgrgid32, getgrnam32, getgroups32, initgroups32, lchown32, - setgid32, setegid32, getgrent32. - * grp.cc (grp32togrp16): New static function. - (getgrgid32): New function. - (getgrnam32): Ditto. - (getgrent32): Ditto. - (getgroups32): Change name of internal function from getgroups. - (getgroups32): New function. - (initgroups32): Ditto. - * syscalls.cc (chown32): Ditto. - (lchown32): Ditto. - (fchown32): Ditto. - (setegid32): Ditto. - (setgid32): Ditto. - * uinfo.cc (getgid32): Ditto. - (getegid32): Ditto. - * include/cygwin/grp.h: Remove declaration of getgrgid() and getgrnam(). - Declare getgrgid32() and getgrnam32() instead. Declare getgid32(). - -2002-05-27 Christopher Faylor - - * autoload.cc (noload): Properly mask low order word for determining - number of bytes to pop. - -2002-05-27 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_disk_file::fstat): Minor logic - cleanup. - -2002-05-27 Christopher Faylor - - * autoload.cc (LoadFuncEx): Define via new LoadFuncEx2 macro. - (LoadFuncEx2): Adapt from LoadFuncEx. Provides control of return - value for nonexistent function. - (NtQueryObject): Declare. - (IsDebuggerPresent): Declare via LoadFuncEx2 and always return true if - not available. - * debug.h (being_debugged): Just rely on IsDebuggerPresent return - value. - * dtable.cc (handle_to_fn): New function. - (dtable::init_std_file_from_handle): Attempt to derive std handle's - name via handle_to_fn. - (dtable::build_fhandler_from_name): Fill in what we can in path_conv - structure when given a handle and path doesn't exist. - * fhandler.cc (fhandler_base::open): Don't set the file pointer here. - Use pc->exists () to determine if file exists rather than calling - GetFileAttributes again. - * fhandler.h (fhandler_base::exec_state_isknown): New method. - (fhandler_base::fstat_helper): Add extra arguments to declaration. - (fhandler_base::fstat_by_handle): Declare new method. - (fhandler_base::fstat_by_name): Declare new method. - * fhandler_disk_file (num_entries): Make __stdcall. - (fhandler_base::fstat_by_handle): Define new method. - (fhandler_base::fstat_by_name): Define new method. - (fhandler_base:fstat): Call fstat_by_{handle,name} as appropriate. - (fhandler_disk_file::fstat_helper): Accept extra arguments for filling - out stat structure. Move handle or name specific stuff to new methods - above. - (fhandler_disk_file::open): Use real_path->exists rather than calling - GetFileAttributes again. - * ntdll.h (FILE_NAME_INFORMATION): Define new structure. - (OBJECT_INFORMATION_CLASS): Partially define new enum. - (OBJECT_NAME_INFORMATION): Define new structure. - (NtQueryInformationFile): New declaration. - (NtQueryObject): New declaration. - * path.cc (path_conv::fillin): Define new method. - * path.h (path_conv::fillin): Declare new method. - (path_conv::drive_thpe): Rename from 'get_drive_type'. - (path_conv::volser): Declare new method. - (path_conv::volname): Declare new method. - (path_conv::root_dir): Declare new method. - * syscalls.cc (fstat64): Send real path_conv to fstat as second - argument. - -2002-05-24 Pierre Humblet - - * security.cc (lsa2str): New function. - (get_priv_list): Call lsa2str instead of sys_wcstombs. - -2002-05-22 Pierre Humblet - - * syscalls.cc (seteuid): Do not take allow_ntsec into account. - Attempt to use an existing or new token even when the uid - matches orig_uid, but the gid is not in the process token. - Major reorganization after several incremental changes. - (setegid): Do not take allow_ntsec into account. Minor - reorganization after several incremental changes. - -2002-05-26 Christopher Faylor - - * debug.h (being_debugged): New macro. - * dtable.cc (dtable::extend): Use new macro. - * exceptions.cc (try_to_debug): Ditto. - * strace.cc (strace::hello): Only output debugging info when we think - we're being debugged. - -2002-05-25 Robert Collins - - * winsup.h: Remove duplicate declarations of malloc_lock and - malloc_unlock. - -2002-05-24 Christopher Faylor - - Remove unneeded sync.h, where appropriate, throughout. - Remove unneeded heap.h, where appropriate, throughout. - Remove unneeded exceptions.h, where appropriate, throughout. - Remove unneeded perprocess.h, where appropriate, throughout. - -2002-05-22 Pierre Humblet - - * security.cc (create_token): Call __sec_user() instead of - sec_user() to remove dependence on allow_ntsec. Verify that - the returned sd is non-null. - -2002-05-25 Robert Collins - - * gmon.c (fake_sbrk): Correctly return -1 on failed malloc's. - -2002-05-24 Christopher Faylor - - * dtable.cc (dtable::build_fhandler_from_name): Just pass posix path - along to set_name via return_and_clear_normalized_path. - (dtable::build_fhandler): New method with const char * argument. - (dtable::reset_unix_path_name): Eliminate. - (dtable::dup_worker): Use correct build_fhandler method. - * mmap.cc (mmap_record::alloc_fh): Ditto. - * dtable.h (dtable::build_fhandler): New method. - (dtable::reset_unix_path_name): Eliminate. - * fhandler.cc (fhandler_base::set_name): Assume that unix_name has - already been cmalloced. - (fhandler_base::reset_unix_path_name): Eliminate. - (fhandler_base::~fhandler_base): Coercion for cfree. - * fhandler.h (fhandler_base::unix_path_name): Make const char *. - (fhandler_base::win32_path_name): Ditto. - (fhandler_base::reset_unix_path_name): Eliminate. - * fhandler_disk_file.cc (fhandler_cygdrive::set_drives): Accommodate - const char *ness of win32_path_name. - * fhandler_socket.cc (fhandler_socket::fstat): Accommodate new set_name - requirements. - * path.cc (path_conv::return_and_clear_normalized_path): New method. - (path_conv::clear_normalized_path): Eliminate. - (path_conv::~path_conv): Ditto. - (path_conv::check): Accommodate new build_fhandler method. - * path.h (path_conv::~path_conv): Eliminate. - (path_conv::clear_normalized_path): Ditto. - (path_conv::return_and_clear_normalized_path): Declare new method. - -2002-05-23 Christopher Faylor - - * path.cc (path_conv::check): Make sure any trailing path component is - part of potential normalized posix path. - -2002-05-23 Christopher Faylor - - * smallprint.c (__small_vsprintf): Implement '%o' after all these - years. - -2002-05-22 Christopher Faylor - - * fhandler.h (fhandler_virtual::exists): Eliminate path argument. - (fhandler_proc::exists): Ditto. - (fhandler_registry::exists): Ditto. - (fhandler_process::exists): Ditto. - * fhandler_proc.cc (fhandler_proc::exists): Ditto. Use built-in name. - * fhandler_process.cc (fhandler_process::exists): Ditto. - (fstat): Ditto. - * fhandler_registry.cc (fhandler_registry::exists): Ditto. - (fhandler_registry::fstat): Ditto. - * fhandler_virtual.cc (fhandler_virtual::opendir): Ditto. - * path.cc (path_conv::check): Ditto. Add debugging. - -2002-05-22 Christopher Faylor - - * syscalls.cc (dup): Always call dup2 for error handling. - -2002-05-22 Corinna Vinschen - - * include/cygwin/types.h: Revert previous patch. - -2002-05-22 Corinna Vinschen - - * include/cygwin/types.h: Define pthread stuff only if _POSIX_THREADS - is defined. - -2002-05-19 Pierre Humblet - - * security.cc (open_local_policy): Initialize lsa to - INVALID_HANDLE_VALUE instead of NULL. - (get_logon_server_and_user_domain): Test for INVALID_HANDLE_VALUE - instead of NULL. - (create_token): Both of the above. - -2002-05-18 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_disk_file::fstat): Make handling of - nlink consistent for remote files. - -2002-05-18 Christopher Faylor - - * path.cc (path_conv::check): Always set executable bit for executable - extension. - -2002-05-17 Christopher Faylor - - * fhandler.cc (fhandler_base::lseek): Avoid calling SetFilePointer with - high order part of 64 bit address on OS's which do not support that - kind of operation. Otherwise Windows 95 will become confused. - -2002-05-16 Pierre Humblet - - * fhandler_raw.cc (fhandler_dev_raw::open): Replace set_errno() - by __seterrno_from_win_error(). - * security.cc (open_local_policy): Ditto. - (get_lsa_srv_inf): Ditto. - (get_user_groups): Ditto. - (get_user_primary_group): Ditto. - (create_token): Ditto. - (subauth): Ditto. - -2002-05-17 Corinna Vinschen - - * times.cc (utimes): Use FILE_WRITE_ATTRIBUTES even on 9x/Me when - opening file for writing timestamp. - * wincap.cc: Remove flag has_specific_access_rights. - * wincap.h: Ditto. - -2002-05-13 Pierre Humblet - - * syscalls.cc (seteuid): Set default dacl in process token. - Replace in-line code by call to verify_token(). - (setegid): Reverse change from 2002-01-21. Add call to - RevertToSelf and set primary group in impersonation token. - * security.cc (create_token): Store pgrpsid in token security - descriptor, except if it already appears in my_grps. - Use sec_acl() in place of get_dacl(). - (verify_token): Create from code in seteuid(), with tighter checks. - (get_dacl): Deleted. - (get_group_sidlist): Add argument to indicate if pgrpsid is already - in the groups. - * security.h: Define verify_token(). - * autoload.cc: Load GetKernelObjectSecurity(). - -2002-05-13 Mark Bradshaw - - * cygwin.din: Add strlcat and strlcpy. - * include/cygwin/version.h: Increment API minor version number. - -2002-05-09 Pierre Humblet - - * shared.cc (__sec_user): Split into sec_acl() and call orig_sid(). - (sec_acl): Create from part of __sec_user(), except creator/owner. - * security.h: Define sec_acl() and MAX_DACL_LEN. - -2002-05-12 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_disk_file::open): Avoid using - O_DIROPEN when OS doesn't support it. Return proper errno in that - case. - -2002-05-12 Christopher Faylor - - * syscalls.cc (_read): Change error to EBADF if attempt to read from a - non-readable fd. - -2002-05-11 Christopher Faylor - - * fhandler.h (executable_states): For now, make dont_care_if_executable - equivalent to not_executable. - * sys/mount.h: Define MOUNT_NOTEXEC. - * path.h (fs_info): New class. - (path_conv): Move fs-specific fields to new 'fs' structure. - (path_conv::update_fs_info): Move to fs_info and rename to just 'update'. - * path.cc (fs_info::update): Ditto. Return 'true' if successful. - (fillout_mntent): Add ',noexec' to list of reported options. - -2002-05-11 Christopher Faylor - - * fhandler_virtual.cc (fhandler_virtual::close): Quiet a compiler - warning. - -2002-05-10 Christopher January - - * autoload.cc: Add dynamic load statements for - 'ZwQueryInformationProcess' and 'ZwQueryVirtualMemory'. - * fhandler.h: Change type of bufalloc and filesize members of - fhandler_virtual from int to size_t. Change type of position member - from __off32_t to __off64_t. Add new fileid member to fhandler_virtual - class. Make seekdir take an __off64_t argument. Make lseek take an - __off64_t argument. Add fill_filebuf method to fhandler_virtual. Add - fill_filebuf method to fhandler_proc. Add fill_filebuf method to - fhandler_registry. Add fill_filebuf method to fhandler_process. Add - saved_pid and saved_p members to fhandler_process. - * fhandler_proc.cc (proc_listing_array): Add 'loadavg', 'meminfo', and 'stat'. - (proc_fhandlers array): Ditto. - (fhandler_proc::open): Use fill_filebuf to flesh out the file contents. - (fhandler_proc::fill_filebuf): New method. - (fhandler_proc::format_proc_meminfo): Ditto. - (fhandler_proc::format_proc_stat): Ditto. - (fhandler_proc::format_proc_uptime): Ditto. - * fhandler_process.cc (process_listing): Add 'stat' and 'statm'. - (fhandler_process::fstat): Find the _pinfo structure for the process - named in the filename. Return ENOENT if the process is no longer - around. Set the gid and uid fields of the stat structure. - (fhandler_process::open): Store pid and pointer to _pinfo structure in - saved_pid and saved_p respectively. Use fill_filebuf to flesh out file - contents. - (fhandler_proc::fill_filebuf): New method. - (format_process_stat): New function. - (format_process_status): Ditto. - (format_process_statm): Ditto. - (get_process_state): Ditto. - (get_mem_values): Ditto. - * fhandler_registry.cc (fhandler_registry::seekdir): Change argument - type from __off32_t to __off64_t. - (fhandler_registry::fill_filebuf): New method. - * fhandler_virtual.cc (fhandler_virtual::seekdir): Change argument type - from __off32_t to __off64_t. - (fhandler_virtual::lseek): Ditto. - (fhandler_virtual::fill_filebuf): New method. - (fhandler_virtual::fhandler_virtual): Initialise fileid to -1. - * wincap.cc: Set flag has_process_io_counters appropriately. - * wincap.h: Add flag has_process_io_counters. - -2002-05-09 Christopher Faylor - - * syscalls.cc (_write): Change error to EBADF if attempt to write to a - non-writeable fd. - -2002-05-08 Corinna Vinschen - - * cygheap.h (class cygheap_user): Add member `orig_psid'. - Add method `orig_sid()'. - * cygheap.cc (cygheap_user::set_sid): Maintain orig_psid. - -2002-04-28 Norbert Schulze - - * localtime.cc (tzsetwall): Use wildabbr if generated timezone name - length < 3. - -2002-05-05 Pierre Humblet - - * spawn.cc (spawn_guts): Move call to set_process_privilege() - to load_registry_hive(). - * registry.cc (load_registry_hive): ditto. - * fork.cc (fork_parent): Call sec_user_nih() only once. - -2002-05-04 Christopher January - - * path.h (path_conv::path_conv): Initialise normalized_path to NULL. - -2002-05-03 Christopher Faylor - - * net.cc (getdomainname): Change second argument of getdomainname to - size_t. - -2002-05-03 Christopher January - - * fhandler_proc.cc (proc_listing): Add '.' and '..' to directory - listing. - (fhandler_proc::open): Change use of mode to flags. If the file does - not exist already, fail with EROFS if O_CREAT flag is set. Change - EROFS error to EACCES error when writing to a file. Use cmalloc to - allocate memory for filebuf. - (fhandler_proc::close): Use cfree to free filebuf. - (fhandler_proc::get_proc_fhandler): Properly detect attempts to access - unknown subdir. - * fhandler_process.cc (process_listing): Add '.' and '..' to directory - listing. - (fhandler_process::open): Use cmalloc to allocate memory for filebuf. - (fhandler_process::close): Use cfree to free filebuf. - * fhandler_registry.cc (registry_listing): Add . and '..' to directory - listing. - (fhandler_registry::open): Move check for open for writing before - open_key. Use cmalloc to allocate memory for filebuf. - (fhandler_registry::close): Use cfree to free filebuf. - (fhandler_registry::telldir): Use lower 16 bits of __d_position as - position in directory. - (fhandler_registry::seekdir): Ditto. - * fhandler_virtual.cc (fhandler_virtual::write): Change EROFS error to - EACCES error. - (fhandler_virtual::open): Set the NOHANDLE flag. - (fhandler_virtual::dup): Add call to fhandler_base::dup. Allocate - child's filebuf using cmalloc. Copy filebuf from parent to child. - (fhandler_virtual::close): Use cfree to free filebuf. - (fhandler_virtual::~fhandler_virtual): Ditto. - (from Chris Faylor ). - (fhandler_registry::readdir): Add support for '.' and '..' files in - subdirectories of /proc/registry. - * path.cc (path_conv::check): Do not return ENOENT if a file is not - found in /proc. - -2002-05-02 Christopher Faylor - - * fhandler_proc.cc (fhandler_proc::fstat): Use fhandler name rather - than path_conv name. - (fhandler_proc::open): Ditto. - * fhandler_process.cc (fhandler_process::fstat): Use fhandler name - rather than path_conv name. - (fhandler_process::open): Ditto. - * fhandler_registry.cc (fhandler_registry::fstat): Use fhandler name - rather than path_conv name. - (fhandler_registry::open): Ditto. - * path.cc (path_conv::check): Don't copy posix path when virtual. - (mount_info::conv_to_win32_path): Don't zero string when isproc. Just - derive normal windows path. - - * path.h (path_conv::clear_normalized_path): Declare new method. - * path.cc (path_conv::clear_normalized_path): Define new method. - * dtable.cc (build_fhandler_from_name): Clear normalized path when - finished to conserve space. - -2002-05-02 Christopher Faylor - - * fhandler_proc.cc (fhandler_proc::fstat): Prime with information from - fhandler_base::fstat. Use defines rather than constants for permission - settings. - -2002-04-30 Eric Blake - - * path.cc (hash_path_name): Improve hash function strength. - -2002-05-02 Robert Collins - - * thread.cc (__pthread_cond_dowait): Fix a race on signalling from a - thread woken by the same condition variable it's signalling on. Thanks - to Michael Beach for the report and test case. - -2002-05-02 Christopher Faylor - - * path.h (pathconv_arg): Add PC_POSIX. - (path_conv): Add normalized_path field. - * path.cc (path_conv::~path_conv): New destructor. - (path_conv::check): Set normalized_path, where appropriate. - * dtable.cc (build_fhandler_from_name): Use normalized path from - path_conv. - * syscalls.cc (chroot): Ditto. - - * cygheap.h: Remove path_prefix_p declaration. - -2002-02-26 Christopher January - Christopher Faylor (minor fixups) - - * Makefile.in: Add fhandler_proc.o, fhandler_registry.o, - fhandler_process.o and fhandler_virtual.o. - * dtable.cc (dtable::build_fhandler): Add entries for FH_PROC, - FH_REGISTRY and FH_PROCESS. Set unix_name to the normalized posix - path. - * fhandler.h: Add constants for FH_PROC, FH_REGISTRY and FH_PROCESS. - Add class declarations for fhandler_virtual, fhandler_proc, - fhandler_registry and fhandler_virtual. Update fhandler_union - accordingly. - * fhandler_proc.cc: New file. Add implementation for fhandler_proc. - * fhandler_virtual.cc: New file. Add implementation for - fhandler_virtual. - * fhandler_process.cc: New file. Add implementation for - fhandler_process. - * fhandler_registry.cc: New file. Add implementation for - fhandler_registry. - * path.cc (isproc): New macro. - (isvirtual_dev): Ditto. - * path.cc (path_conv::check): Add check for virtual devices. - * path.cc (mount_info::conv_to_win32_path): Convert paths in /proc to - empty Win32 paths. - * path.cc (chdir): Replace check for FH_CYGDRIVE with more generic - isvirtual_dev macro. Force setting of posix path for virtual - fhandlers. - * path.h (path_prefix_p): Declare. - - -Wed May 1 16:06:02 2002 Jason Tishler - - * include/cygwin/types.h: Include . - -Wed Apr 17 11:27:04 2002 Jason Tishler - - * security.cc (get_lsa_srv_inf): Prevent extraneous backslashes for - the NT Domain case. - -2002-04-12 Corinna Vinschen - - * net.cc (cygwin_accept): Set socket type for accepted socket. - (socketpair): Set socket type for both sockets. - -2002-04-12 Egor Duda - - * fhandler.h (class fhandler_socket): New member to store socket type. - (fhandler_socket::get_socket_type): Access it. - (fhandler_socket::set_socket_type): Ditto. - * net.cc (cygwin_socket): Store socket type. - (cygwin_connect): Disable security checks for connectionless sockets. - (cygwin_accept): Ditto. - -2002-04-09 Mark Bradshaw - - * cygwin.din: Add strptime. - * include/cygwin/version.h: Increment API version number. - -2002-04-09 Corinna Vinschen - - * fork.cc (fork_child): Call fixup_mmaps_after_fork() somewhat earlier. - -2002-04-09 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Set read-only bit in - file_attributes when adequate. - -2002-03-28 Christopher Faylor - - * times.cc (gettimeofday): Fix typo in previous patch. - -2002-03-27 Wu Yongwei - - * times.cc (gettimeofday): Revert to setting timezone info if tz != - NULL. - -2002-03-21 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): Always set - st_[ug]id to value derived from get_file_attributes. - -2002-03-21 Christopher Faylor - - * spawn.cc (find_exec): Return input if file not found. - -2002-03-19 Boris Schaeling - - * poll.cc (poll): Add support for invalid descriptors. - -2002-03-15 Robert Collins - - * fhandler.h (fhandler_termios::lseek): Override lseek. - * fhandler_termios.cc (fhandler_termios::lseek): Implement this. - -2002-03-15 Christopher Faylor - - * cygserver.cc: Include stdlib.h for exit declaration. - * threaded_queue.cc: Ditto. - -2002-03-15 Christopher Faylor - - * pinfo.cc (pinfo::init): Use PID_ALLPIDS flag to control when a - redirected block should be marked as nonexistent. - (winpids::add): Use PID_ALLPIDS when looking for all pids. - * cygwin.h (PID_ALLPIDS): New enum element. - -2002-03-15 Corinna Vinschen - - * glob.c (stat32_to_STAT): New function. - (g_lstat): Call user space functions always with 32 bit struct stat - as a workaround. - (g_stat): Ditto. - * include/glob.h (struct glob): Don't prototype function pointers - when compiling Cygwin. - -2002-03-14 Christopher Faylor - - * pinfo.cc (pinfo::init): Properly handle execed process stub when - PID_NOREDIR is specified. - -2002-03-13 Boris Schaeling - - * poll.cc (poll): Remove variable open_fds. Rearrange and add code to - fix settings of revents. - -2002-03-13 Corinna Vinschen - - * mmap.cc (mmap_record::map_map): Return -1 if VirtualProtect fails. - (list::erase): New method with no argument. Erase latest record - added. - (mmap64): Fail if map_map() fails. - -2002-03-12 Corinna Vinschen - - * sysconf.cc (sysconf): Fix condition. - -2002-03-11 Corinna Vinschen - - * mmap.cc (msync): Check area given by addr and len for being a - contigeous mmap'd region. - -2002-03-11 Corinna Vinschen - - * fork.cc (fork_child): Call fixup_mmaps_after_fork() before - closing parent process handle. Call fixup_mmaps_after_fork() - with parent process handle as parameter. - * mmap.cc (mmap_record::access): New method. - (fixup_mmaps_after_fork): Take process handle as parameter. - In case of FILE_MAP_COPY access, copy valid memory regions to child. - * pinfo.h (fixup_mmaps_after_fork): Change prototype accordingly. - -2002-03-07 Corinna Vinschen - - * autoload.cc (NetGetDCName): Add symbol. - (NetServerEnum): Remove symbol. - * security.cc (get_lsa_srv_inf): Call NetGetDCName() instead of - NetServerEnum() since it's faster. Don't call it at all if machine - is not a domain member. - -2002-03-06 Christopher Faylor - - * path.cc (normalize_posix_path): Avoid runs of '.'s > 2. - -2002-03-05 Christopher Faylor - - * errno.cc: Change EPERM associated text to "Operation not permitted" - throughout. - -2002-03-05 Christopher Faylor - - * fhandler_socket.cc (fhandler_socket::close): Respond to signals while - looping, waiting for socket to close. Superstitiously clear last error - when WSAEWOULDBLOCK. - -2002-03-05 Robert Collins - - * cygserver_transport_pipes.cc (transport_layer_pipes::transport_layer_pipes): - Always init - until static members work correctly. - * shm.cc (shmget): Initialize the security descriptor - thanks Corinna! - * include/sys/ipc.h: Make the ipc control constants partitioned off from the sem - control constants. - -2002-03-04 Christian Lestrade - - * include/sys/termios.h: Define _POSIX_VDISABLE. Define CCEQ macro. - * fhandler_termios.cc: Include . - (line_edit): Recognize disabled c_cc[] chars. Ignore VDISCARD when - not in ICANON mode. - -2002-03-04 Dmitry Timoshkov - - * syscalls.cc (truncate64): Use ftruncate64 directly to not lose - upper 32 bits. - -2002-03-04 Robert Collins - - * cygserver_shm.cc (delete_shmnode): New function. - (client_request_shm::serve): Use it. - -2002-03-04 Robert Collins - - * cygserver_shm.cc (client_request_shm::serve): Implement SHM_DETACH. - * shm.cc (shmdt): Implement. - -2002-03-04 Robert Collins - - * cygserver_shm.cc: Run indent. - (deleted_head): New global for storing shm id's pending deletion. - (client_request_shm::serve): Return ENOSYS for invalid request types. - Implement SHM_DEL - delete a shm id. - * cygserver_shm.h (SHM_DEL): New type value. - * shm.cc (delete_inprocess_shmds): New function, does what it's name implies. - (shmctl): Implement shm_rmid control type. - -2002-03-04 Robert Collins - - * Makefile.in (install): Remove install-bin to allow make install to work. - -2002-03-03 Robert Collins - - * shm.cc (shmat): Prevent a compile error. - (shmdt): Set errno as this function is incomplete. - -2002-02-28 Christopher Faylor - - * times.cc: Remove if 0'd code. Clean up slightly. - -2002-02-28 Robert Collins - - * Merge cygwin_daemon into head minus the new shm and ipc exports. - -2002-02-28 Robert Collins - - * fhandler_tty.cc (fhandler_tty_slave::open): More debugging. - (fhandler_tty_slave::read): Fix printf type for the handle. - * tty.cc (tty::common_init): Add a FIXME for security. - -2002-01-29 Robert Collins - - * Makefile.in (OBJS): Remove duplicate localtime.o. - -2002-01-17 Robert Collins - - * cygserver.cc (check_and_dup_handle): Consolidate the two variants for - simplicity. - Add Some basic debug output. - (client_request_attach_tty::serve): Use the new debug_printf for clarity. - Mark the duplicated handles as inheritable - fixup_after_fork() doesn't reopen - tty's. - -2002-01-16 Robert Collins - - * cygserver.cc (transport): Correct scope. - (client_request_attach_tty::serve): Add more debug information. - Fix erroneous use of transport instead of conn. - * cygserver_transport_pipes.cc (transport_layer_pipes::close): More debug. - (transport_layer_pipes::read): Ditto. - (transport_layer_pipes::write): Ditto. - (transport_layer_pipes::impersonate_client): Ditto. - -Mon Oct 8 7:41:00 2001 Robert Collins - - * cygserver.cc (server_request::process): Rename client_request_shm_get to - client_request_shm. - * cygserver_process.cc (process_cache::add): Rename to add_task. - Use process_cleanup instead of process_request. - (process_cache::remove_process): New method. - (process::process): Initialize new members. - (process::~process): New member. - (process::cleanup): New method. - (process::add_cleanup_routine): New method. - (process_request::process): Rename to process_cleanup. - Call the process object's cleanup method and then delete it. - (process_process_param::request_loop): Remove the signalling process. - * cygserver_shm.cc: Globally rename client_request_shm_get to client_request_shm. - (client_request_shm_get::serve): Handle attach request counting. - * cygserver_shm.h: Globally rename client_request_shm_get to client_request_shm. - (class shm_cleanup): New class. - * shm.cc: Globally rename client_request_shm_get to client_request_shm. - (client_request_shm::client_request_shm): New constructor for attach requests. - (shmat): Use it. - * include/cygwin/cygserver_process.h (class process_request): Rename to - process_cleanup. - (class cleanup_routine): New class. - (class process): New members and methods to allow calling back when the process - terminates. - -Thu Oct 4 14:12:00 2001 Robert Collins - * cygserver.cc (request_loop): Make static. - (main): Use new cache constructor syntax. - Start cache worker threads. - Cleanup the cache at shutdown. - * cygserver_process.cc: Run indent. - (process_cache::process_cache): Add a trigger to use when adding a process. - (process_cache::process): Move process_entry to process. - Insert at the end of the list. - Trigger the request loop when new process's inserted. - (process_cache::process_requests): Do it. - (process_cache::add): New method. - (process_cache::handle_snapshot): New method. - (process::process): Merge in the process_entry fields. - (process::handle): Make a stub function. - (process::exit_code): New method. - (process_request::process): New method. - (process_process_param::request_loop): New method. - * cygserver_shm.cc: New header dependency - threaded_queue.h. - * threaded_queue.cc (threaded_queue::cleanup): Clearer messages. - (queue_process_param::stop): Short spinlock on interruptible threads. - * threaded_queue.h (class threaded_queue): New constructor. - * include/cygwin/cygserver_process.h (process_request): New class. - (process_entry): Remove. - (process): Merge in process_entry. - (process_cache): Inherit from threaded_queue. - -Tue Oct 2 23:24:00 2001 Robert Collins - - * cygserver.cc (class server_process_param): Use new constructor syntax. - * cygserver_process.cc (process_cache::~process_cache): New function. - * threaded_queue.cc: Define condition debug_printf. - Run indent. - (threaded_queue::cleanup): Move queue_process_param guts to a method. - (threaded_queue::process_requests): Ditto. - (queue_process_param::queue_process_param): New method. - (queue_process_param::~queue_process_param): Ditto. - (queue_process_param::start): Ditto. - (queue_process_param::stop): Ditto. - * threaded_queue.h (class queue_process_param): Add support for - interruptible request loops. - * cygwin/include/cygwin/cygserver_process.h (class process_cache): Add - destructor. - -Tue Oct 2 23:24:00 2001 Robert Collins - - * cygserver_client.cc: New flag allow_daemon to disable the daemon completely. - (cygserver_request): Check it. - (cygserver_init): Ditto. - * environ.cc (parse_thing): Add (no)daemon option. - -Tue Oct 2 23:00:00 2001 Robert Collins - - * shm.cc: Update to handle include changes from HEAD. - -Tue Oct 2 16:06:00 2001 Robert Collins - - * Makefile.in: Remove cygserver_shm.o from cygwin1.dll. - Rename cygserver_shm_outside.o to cygserver_shm.o. - * cygserver.cc (server_request::process): Use the new client_request - constructor. - * cygserver_client.cc: Remove the #ifdef's stubs for the server method - within cygwin. - (client_request_attach_tty::client_request_attach_tty): Use the new - client_request constructor. - (client_request_shutdown::client_request_shutdown): Ditto. - (client_request::client_request): Ditto. - * cygserver_shm.cc (client_request_shm_get::serve): Remove the - #ifdef'd stub for in-cygwin builds. - (client_request_shm_get::client_request_shm_get): Use the new - client_request constructor, and remove the in-cygwin variants. - * cygserver_shm.h (class client_request_shm_get): #ifndef test the - serve method - it's only used in cygserver. - * shm.cc (client_request_shm_get::client_request_shm_get): New function. - * include/cygwin/cygserver.h (request_header): New constructor. - (class client_request): Use it. - New constructor accepting the header size. - #ifndef test the server method - it's only used within cygserver. - (client_request_get_version): #ifdef test the server method. - (client_request_shutdown): Ditto. - (client_request_attach_tty): Ditto. - -Tue Oct 2 9:57:00 2001 Robert Collins - - * Makefile.in: add threaded_queue.o to cygserver.exe. - * cygserver.cc: Include threaded_queue.h - (class server_request): Inherit from queue_request. - (class server_process_param): Inherit from queue_process_param. - (class server_request_queue): Inherit from threaded_queue. - (request_loop): Adjust for new types. - (server_request_queue::process_requests): Remove guts to - threaded_queue::process_requests. - (server_request::server_request): Adjust for new types. - (worker_function): Delete. - (server_request_queue::create_workers): Delete. - (server_request_queue::cleanup): Delete. - (server_request_queue::add): Move guts to threaded_queue::add. - * threaded_queue.cc: New file. - * threaded_queue.h: New file. - -Mon Oct 1 12:38:00 2001 Robert Collins - - * cygserver.cc (client_request::serve): New function. - * cygserver_process.cc: Inlude for pthread_once. - (process_cache::process_cache): Initialise a crtiical section for write access. - (process_cache::process): Use the critical section. Also add missing entries to - the cache. - (do_process_init): New function to initalise class process static variables. - (process::process): Ensure that the process access critical section is - initialised. - (process::handle): Close the handle of old process's when they have terminated - and we are returning the handle for a process with the same pid. - * cygserver_shm.cc: Run indent. - Include cygserver_process.h to allow process cache functionality. - (client_request_shm_get::serve): New parameter for process cache support. - Use the process cache, not OpenProcess to get a handle to the originating process. - Fix a handle leak with token_handle. - * cygserver_shm.h (class client_request_shm_get): Update ::serve for process - cache support. - * cygserver_transport_pipes.cc: Redefine debug_printf to be conditional on DEBUG. - * include/cygwin/cygserver.h: Do not implement client_request::serve in the - header. - * include/cygwin/cygserver_process.h (class process_cache): Add a write access - critical section to prevent races when requests from a multithreaded - application arrive. - -Sun Sep 30 23:41:00 2001 Robert Collins - - * Makefile.in: Add cygserver_process.o to cygserver.exe. - * cygserver.cc: Include signal.h and cygwin_version.h. - Define debug_printf as a macro. - Define DEBUG to a value. - (client_request_attach_tty::serve): Add beginning of process cache support. - Change from #ifdef DEBUG to work with new DEBUG style. - (client_request_get_version::serve): Add beginning of process cache support. - (class server_request): New prototype for support of process cache. - (class queue_process_param): New class to allow request loop threading. - (class server_request_queue): Add beginning of process cache support. - Allow request loop threading. - (request_loop): Thread function for request loops. - (server_request_queue::process_requests): Initiator for threaded request loops. - (client_request_shutdown::serve): Add beginning of process cache support. - (server_request::server_request): Ditto. - (server_request::process): Use debug_printf. Add beginning of process cache - support. - (server_request_queue::cleanup): Kill off any request loop threads. - (server_request_queue::add): Add beginning of process cache support. - (handle_signal): Trigger a shutdown. - (main): Print out some useful info at startup - version, date time. - Add process cache support. - Spawn a separate thread for the transport request loop, thus allowing concurrent - support for multiple transports. - * cygserver_client.cc (client_request_get_version::serve): Add process cache - support. - (client_request_attach_tty::serve): Add process cache support. - (client_request_shutdown::serve): Add process cache support. - * cygsserver_process.cc: New file with the process cache support. - * cygserver_shm.cc: Redefine debug_printf to allow conditional output. - * cygwin.din: Export shmdt(). - * shm.cc: Run indent. - Update FIXME's. - (shmdt): New function. - * include/cygwin/cygserver.h (class client_request): Add process cache support. - (class client_request_get_version): Ditto. - (class client_request_shutdown): Ditto. - (class client_request_attach_tty): Ditto. - * include/cygwin/cygserver_process.h: New header for process cache support. - -Sun Sep 30 8:52:00 2001 Robert Collins - - * include/cygwin/cygserver_transport.h: Add copyright header. - * include/cygwin/cygserver_transport_pipes.h: Ditto. - * include/cygwin/cygserver_transport_sockets.h: Ditto. - -Sat Sep 29 20:40:00 2001 Robert Collins - - * Makefile.in: Add cygserver_transport_sockets.o to DLL_OFILES. - Add cygserver_transport_sockets_outside.o to cygserver.exe. - * cygserver.cc: Include new include files. - * cygserver_client.cc: Ditto. - * cygserver_shm.h: No need to include now. - * cygerver_transport.cc: Include new include files. - (transport_layer_base::transport_layer_base): Strip back to a stub. - (transport_layer_base::listen): Ditto. - (transport_layer_base::accept): Ditto. - (transport_layer_base::close): Ditto. - (transport_layer_base::read): Ditto. - (transport_layer_base::write): Ditto. - (transport_layer_base::connect): Ditto. - * cygserver_transport_pipes.cc: Include new header - "cygwin/cygserver_transport_pipes.h". - * cygserver_transport_sockets.cc: New file. - * dcrt0.cc: No need to include now. - * fhandler_tty.cc: Ditto. - * tty.cc: Ditto. - * include/cygwin/cygserver_transport.h: Strip the base class to a stub. - Remove the cygserver_transport_pipes class. - * include/cygwin/cygserver_transport_pipes.h: New file. - * include/cygwin/cygserver_transport_sockets.h: New file. - -Tue Sep 25 16:22:00 2001 Robert Collins - - * autoload.cc: Add dynamic load statement for 'ImpersonateNamedPipeClient'. - * Makefile.in: Add new object files, and build instructions for cygserver.exe. - * cygwin.din: Export ftok, shmat, shmctl and shmget. - * dcrt0.cc: Additional includes for cygserver support. - (dll_crt0_1): Initialise the cygserver client. - * fhandler.h (fhandler_tty): New method cygserver_attach_tty. - * fhandler_tty.cc: Additional includes for cygserver support. - (fhandler_tty_slave::open): Attempt to use the cygserver when obtaining - handles from the parent process. On failure or 9x use the current method. - (fhandler_tty_slave::cygserver_attach_tty): New function. - * fork.cc (fork_child): Fixup shm memory mapped areas. - * pinfo.h: Declare fixup_shms_after_fork(). - * security.h: Declare alloc_sd(). - * tty.cc: Additonal includes to support cygserver. - (tty::common_init): Don't allow others to open us if the cygserver is running. - * winsup.h: Declare cygserver_running. - * cygserver.cc: New file. - * cygserver_client.cc: New file. - * cygserver_shm.cc: New file. - * cygserver_shm.h: New file. - * cygserver_transport.cc: New file. - * cygserver_transport_pipes.cc: New file. - * ipc.cc: New file. - * shm.cc: New file. - * include/cygwin/cygserver.h: New file. - * include/cygwin/cygserver_transport.h: New file. - * include/sys/ipc.h: New file. - * include/sys/shm.h: New file. - -2002-02-28 Robert Collins - - * thread.cc (semaphore::TryWait): Set errno as required by posix 1003.1. - (__sem_wait): Ditto. - (__sem_trywait): Ditto. - -2002-02-27 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number. - -2002-02-23 Corinna Vinschen - - * cygwin.din (fstat64): New symbol. - (ftruncate64): Ditto. - (lseek64): Ditto. - (lstat64): Ditto. - (mmap64): Ditto. - (seekdir64): Ditto. - (stat64): Ditto. - (telldir64): Ditto. - (truncate64): Ditto. - * dir.cc (telldir64): New function. - (telldir): Call telldir64(). - (seekdir64): New function. - (seekdir): Call seekdir64(). - * fhandler.h: Redefine all methods using __off32_t to use __off64_t. - * fhandler.cc: Use __off64_t and struct __stat64 throughout. - * fhandler_clipboard.cc: Ditto. - * fhandler_disk_file.cc: Ditto. - * fhandler_dsp.cc: Ditto. - * fhandler_floppy.cc: Ditto. - * fhandler_mem.cc: Ditto. - * fhandler_random.cc: Ditto. - * fhandler_socket.cc: Ditto. - * fhandler_tape.cc: Ditto. - * fhandler_zero.cc: Ditto. - * pipe.cc: Ditto. - * glob.c: Ditto, call lstat64 and stat64 in Cygwin. - * mmap.cc: Use __off64_t throughout. - (mmap64): New function. - * sec_acl.cc (acl_worker): Use struct __stat64, call stat64 and lstat64. - * syscalls.cc (lseek64): New function. - (stat64_to_stat32): Ditto. - (fstat64): Ditto. - (stat64): Ditto. - (lstat64): Ditto. - (ftruncate64): Ditto. - (truncate64): Ditto. - (_fstat): Call fstat64. - (_stat): Call stat64. - (cygwin_lstat): Rename to avoid declaration problem. Call lstat64. - (stat_worker): Use struct __stat64. - (access): Ditto. - (ftruncate): Call ftruncate64. - (truncate): Call truncate64. - * wincap.cc: Set flag has_64bit_file_access appropriately. - * wincap.h: Add flag has_64bit_file_access. - * winsup.h (ILLEGAL_SEEK): Define as __off64_t. - (stat_dev): Declare using struct __stat64. - (stat_worker): Ditto. - * include/cygwin/stat.h (struct __stat32): Define if compiling Cygwin. - (struct __stat64): Ditto. - (struct stat): Revert definition with explicitly sized datatypes. - Eliminate sized field names. - * include/cygwin/types.h (blksize_t): New type. - (__blkcnt32_t): Ditto. - (__blkcnt64_t): Ditto. - (blkcnt_t): Ditto. - -2002-02-22 Christopher Faylor - - * sync.h (new_muto): Just accept an argument which denotes the name of - the muto. Use this argument to construct static storage. - * cygheap.cc (cygheap_init): Reflect above change. - * exceptions.cc (events_init): Ditto. - * malloc.cc (malloc_init): Ditto. - * path.cc (cwdstuff::init): Ditto. - * cygheap.h (cwdstuff): Change name of lock element to make it less - generic. - * path.cc (cwdstuff::get_hash): Ditto. - (cwdstuff::get_initial): Ditto. - (cwdstuff::set): Ditto. - (cwdstuff::get): Ditto. - * sigproc.cc (proc_subproc): Ditto. - - * debug.cc (lock_debug): Change to method. Use method rather than - macro throughout. - - * tty.h (tty_min::kill_pgrp): Declare new method. - * fhandler_termios.cc (tty_min::kill_pgrp): New method. - (fhandler_termios::line_edit): Use new method for killing process. - * dcrt0.cc (do_exit): Ditto. - - * dtable.cc (dtable::get_debugger_info): New method for inheriting - dtable info from a debugger. - * tty.cc (tty_init): Attempt to grab file handle info from parent - debugger, if appropriate. - - # dtable.cc (dtable::stdio_init): Make this a method. - (dtable::init_std_file_from_handle): Don't set fd unless it's not open. - (dtable::build_fhandler_from_name): Move name setting to - dtable::build_fhandler. - (dtable::build_fhandler): Add win32 name parameter. - * dcrt0.cc (dll_crt0_1): Change to use dtable stdio_init. - * dtable.h (dtable): Reflect build_fhandler parameter change. - * mmap.cc (mmap_record::alloc_fh): Don't set name parameter in - build_fhandler. - * net.cc (fdsock): Remove set_name call since it is now handled by - build_fhandler. - - * sigproc.cc (proc_subproc): Release muto as early as possible. - -2001-02-22 Corinna Vinschen - - * smallprint.c (rn): Allow long long values. - (__small_vsprintf): Add 'D', 'U' and 'X' formats for long long - parameters. - -2002-02-19 Christopher Faylor - - * fhandler.cc (fhandler_base::puts_readahead): Remove default parameter - setting. Newer gcc's complain about this. - (fhandler_base::set_readahead_valid): Ditto. - * fhandler_dsp.cc (Audio::open): Ditto. - (fhandler_dev_dsp::open): Ditto. - -2002-02-19 Christopher Faylor - - * fork.cc (fork_parent): Use sec_user_nih to control process/thread - inheritance/permission. - * spawn.cc (spawn_guts): Ditto. - * security.cc (create_token): Initialize token so that it is not tested - for bogus value later. Use sec_user to control process/thread - creation. - * security.h (__sec_user): Rename declaration from sec_user. - (sec_user_nih): Declare here as inline function wrapper for __sec_user. - (sec_user): Ditto. - * sigproc.cc (czombies): Allocate a character array for zombies to - avoid constructor overhead - (extremely hackish, I know). - (cpchildren): Ditto. - (pchildren): New define. - (zombies): Ditto. - (getsem): Use sec_user_nih to control semaphore inheritance/permission. - -2002-02-16 Christopher Faylor - - * times.cc (hires::prime): Restore thread priority on failure - condition. - - * uinfo.cc (uinfo_init): Use more robust method for determining if - process was invoked from a non-cygwin process. - - * sync.h (muto::init): Eliminate "inheritance" parameter. - (new_muto): Reflect removal of parameter. - * sync.cc (muto::init): Ditto. - * cygheap.cc (cygheap_init): Ditto. - * debug.cc (threadname_init): Ditto. - * exceptions.cc (events_init): Ditto. - * malloc.cc (malloc_init): Ditto. - * path.cc (cwdstuff::init): Ditto. - * sigproc.cc (sigproc_init): Ditto. - - * grp.cc (group_lock): Use different method for locking with static - member. - (read_etc_group): REALLY ensure that read lock mutex is released. - * passwd.cc (passwd_lock): Use different method for locking with static - member. - (read_etc_passwd): REALLY ensure that read lock mutex is released. - - * shared.cc (sec_user): Correct reversed inheritance test. - -2002-02-15 Christopher Faylor - - * hires.h (hires::usecs): Rename from utime. Accept an argument. - * strace.cc (strace::microseconds): Use hires class for calculating - times. - * sync.h (new_muto): Use NO_COPY explicitly in declaration. - * times.cc (gettimeofday): Reflect change in usecs argument. - (hires::usecs): Ditto. Changed name from utime. - * winsup.h (NO_COPY): Add nocommon attribute to force setting aside - space for variable. - * regcomp.c (REQUIRE): Add a void cast to bypass a warning. - -2002-02-15 Christopher Faylor - - * hires.h: New file. - * times.cc (gettimeofday): Use hires class for calculating current time. - (hires::prime): New method. - (hires::utime): Ditto. - -2002-02-14 Christopher Faylor - - * include/sys/cygwin.h (cygwin_getinfo_types): New CW_STRACE_ACTIVE. - * external.cc (cygwin_internal): Handle CW_STRACE_ACTIVE. - -2002-02-14 Christopher Faylor - - * exceptions.cc (unused_sig_wrapper): Eliminate unused parameter to - asm. - * external.cc (cygwin_internal): Change CW_STRACE_ON to - CW_STRACE_TOGGLE. - * strace.cc (strace::hello): Toggle strace on and off. - * sync.cc (muto::init): Rename from constructor. - * sync.h (muto::new): Delete. - (muto::delete): Ditto. - (new_muto): Simplify. Use muto.init for nearly everything. - * uinfo.cc (uinfo_init): Avoid closing a NULL handle. - * include/sys/cygwin.h (cygwin_getinfo_types): Rename CW_STRACE_OFF to - CW_STRACE_TOGGLE. Delete CW_STRACE_OFF. - * include/sys/strace.h (strace): Add "inited" field. - -2001-02-12 Corinna Vinschen - - * include/cygwin/acl.h: Fix definition of aclent_t. - -2002-02-10 Christopher Faylor - - * Makefile.in (DLL_OFILES): Consolidate object files. - -2002-02-10 Corinna Vinschen - - * child_info.h, cygheap.h, fhandler_clipboard.cc, fhandler_dsp.cc, - fhandler_floppy.cc, fhandler_mem.cc, fhandler_random.cc, - fhandler_tape.cc, fhandler_zero.cc, grp.cc, mmap.cc, passwd.cc, - pinfo.cc, pinfo.h, pipe.cc, sec_acl.cc, sec_helper.cc, security.cc, - security.h, thread.h, uinfo.cc, include/cygwin/acl.h: Fix copyright. - -2002-02-10 Corinna Vinschen - - * child_info.h, cygheap.h, dcrt0.cc, dir.cc, fhandler.cc, fhandler.h, - fhandler_clipboard.cc, fhandler_disk_file.cc, fhandler_dsp.cc, - fhandler_floppy.cc, fhandler_mem.cc, fhandler_random.cc, - fhandler_tape.cc, fhandler_zero.cc, grp.cc, mmap.cc, passwd.cc, - pinfo.cc, pinfo.h, pipe.cc, sec_acl.cc, sec_helper.cc, security.cc, - security.h, spawn.cc, syscalls.cc, thread.h, uinfo.cc, winsup.h: - Change usage of uid_t to __uid16_t, gid_t to __gid16_t and - off_t to __off32_t throughout. Use INVALID_UID, INVALID_GID and - INVALID_SEEK instead casting -1 to the appropriate type. - * winsup.h: Define INVALID_UID, INVALID_GID and INVALID_SEEK. - * include/cygwin/acl.h: Define internal __aclent16_t and __aclent32_t - types. Don't declare acl functions when compiling Cygwin. - * include/cygwin/grp.h: Declare getgrgid() and getgrnam() with - correct types for internal usage. - -2002-02-10 Corinna Vinschen - - Patch suggested by Pierre A. Humblet : - * uinfo.cc (internal_getlogin): Try evaluating user by SID even if - ntsec is off. - (uinfo_init): Set primary group even if ntsec is off. - -2002-02-09 Corinna Vinschen - - * include/cygwin/grp.h: New file. - * include/cygwin/stat.h: Ditto. - * include/cygwin/types.h: Add definitions for __off32_t, - __off64_t, off_t, __uid16_t, __uid32_t, uid_t, __gid16_t, - __gid32_t and gid_t. - * include/sys/cygwin.h: Use correct uid and gid types. - -2002-02-09 Corinna Vinschen - - * dtable.cc (dtable::dup2): Revert previous patch. - * fhandler.h: Ditto. - (fhandler_socket::recv): Define new method. - (fhandler_socket::send): Ditto. - * fhandler_socket.cc (fhandler_socket::recv): New method. - (fhandler_socket::send): Ditto. - (fhandler_socket::read): Call fhandler_socket::recv() now. - (fhandler_socket::write): Call fhandler_socket::send() now. - * net.cc (class wsock_event): Move definition to wsock_event.h. - (fdsock): Revert previous patch. - (cygwin_recv): Move implementation to fhandler_socket::recv(). - (cygwin_send): Move implementation to fhandler_socket::send(). - * wsock_event.h: New file. - -2002-02-06 Alexander Gottwald - - * net.cc (get_2k_ifconf): Create interface entries for tokenring cards. - -2002-02-08 Corinna Vinschen - - * dtable.cc (dtable::dup2): Store fd for fhandler_socket. - * fhandler.h (fhandler_base::set_fd): New virtual method. - (fhandler_base::get_fd): Ditto. - (fhandler_socket::set_fd): Ditto. - (fhandler_socket::get_fd): Ditto. - * fhandler_socket.cc (fhandler_socket::read): Call cygwin_recv instead - of native Winsock recv. - (fhandler_socket::write): Call cygwin_send instead of native Winsock - send. - * net.cc (fdsock): Store fd in fhandler_socket. - -2002-02-07 Corinna Vinschen - - * net.cc (cygwin_getsockname): Fix handling of NULL sun_path. - -2002-01-29 Corinna Vinschen - - * net.cc (getdomainname): Fix registry key for 9x systems, too. - -2002-01-29 Corinna Vinschen - - * net.cc (getdomainname): Fix registry key for NT systems. - -2002-01-28 Christopher Faylor - - * external.cc (cygwin_internal): Initialize various internal settings - if required to allow use of some things from user loaded DLL. - (CW_STRACE_ON): Add new feature. - (CW_CYGWIN_PID_TO_WINPID): Ditto. - * pinfo.cc (set_myself): Call "strace.hello" to initiate possible - strace session. - (pinfo::init): Guard against dereferencing uninitialized myself. - * sigproc.cc (wait_sig): Call strace.hello() when __SIGTRACE "signal" - received. - * strace.cc (strace::hello): New method. - * wincap.cc (wincapc::init): Avoid initializing if already initialized. - * wincap.h (wincapc::wincapc): New method. - * include/sys/cygwin.h: Add new CW_ enums. Kludge typedefs of - {g,u}id_t if required. - * strace.h (strace::hello): Declare new method. - -2002-01-28 Earnie Boyd - - * include/sys/strace.h (_STRACE_ON): Define. - (_STRACE_OFF): Ditto. - -2002-01-24 Christopher Faylor - - * speclib: Ensure that temporary def file is removed. - -2002-01-23 Christopher Faylor - - * speclib: Use rm -f to remove temp file just to quiet any potential - warnings. - -2002-01-23 Corinna Vinschen - - * security.cc (create_token): Use sec_user() to create - SECURITY_ATTRIBUTES structure for primary token. Use - MAXIMUM_ALLOWED access rights instead of TOKEN_ALL_ACCESS. - -2002-01-23 Corinna Vinschen - - * path.cc (symlink): Fix check for already existing file. - -2002-01-21 Christopher Faylor - - * cygmagic: Suppress error output when figuring out if sum takes an - option. - -2002-01-21 Christopher Faylor - - * cygmagic: Attempt to figure out if sum takes an option. - -2002-01-21 DJ Delorie - - * Makefile.in (libpthread.a): Pass the assembler also. - (libm.a): Ditto. - (libc.a): Ditto. - * speclib: Specify the assembler to dlltool. - -2002-01-21 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number. - -2002-01-21 Corinna Vinschen - - * grp.cc (getgrgid): Don't return default gid entry when ntsec is on. - * syscalls.cc (setegid): Don't set primary group in process token. - -2002-01-21 Christopher Faylor - - * speclib: Don't use /dev/null as DLL name. Just default to what's - already in .def file. - -2002-01-21 Christopher Faylor - - * exceptions.cc (sig_handle): Remove last vestiges of SA_NOCLDSTOP code - which caused SIGCHLD to be ignored. - -2002-01-20 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number. - -2002-01-20 Christopher Faylor - - * syscalls.cc (regfree): Make dll_export. - -2002-01-20 Christopher Faylor - - * exceptions.cc (ctrl_c_handler): Convert windows pid to cygwin pid - when detecting if we should actually handle CTRL-C. - -2002-01-19 Christopher Faylor - - * Makefile.in (new-cygwin1.dll): Revert previous change. libsupc++.a - is only available in libstdc++-v3. - -2002-01-19 Christopher Faylor - - * exceptions.cc (sig_handle_tty_stop): Don't send SIGCHLD if parent - doesn't want it. - (sig_handle): Don't check for SA_NOCLDSTOP here. We don't have enough - information. - -2002-01-19 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number. - -2002-01-19 Christopher Faylor - - * Makefile.in (new-cygwin1.dll): Just use -lsupc++ for link. - * sigproc.cc (proc_exists): Change existence criteria. - * sync.h (new_muto): Add volatile to definition to avoid gcc - optimization problems. - -2002-01-19 Corinna Vinschen - - * include/cygwin/version.h: Bump API minor version to 51. - -2002-01-19 Mark Bradshaw - - * cygwin.din: Add recvmsg and sendmsg. - * net.cc: Add cygwin_recvmsg and cygwin_sendmsg. - * /usr/include/sys/socket.h: Add recvmsg and sendmsg. - -2002-01-19 Corinna Vinschen - - * security.cc (create_token): Close processes token handle as soon - as it's not used anymore. - -2002-01-17 Corinna Vinschen - - * Makefile.in: Add fnmatch.o to DLL_OFILES. - * cygwin.din: Add fnmatch export symbol. - * fnmatch.c: New file. - * include/fnmatch.h: Ditto. - * include/cygwin/version.h: Bump API minor version to 50. - -2002-01-15 Corinna Vinschen - - * path.cc (fchdir): Call chdir with full windows path. - -2002-01-14 Corinna Vinschen - - * dir.cc: Use INVALID_FILE_ATTRIBUTES instead of "(DWORD) -1" - for file attributes throughout. - * fhandler.cc: Ditto. - * fhandler_disk_file.cc: Ditto. - * path.cc: Ditto. - * path.h: Ditto. - * syscalls.cc: Ditto. - * times.cc (utimes): Use path_conv::isdir() instead of explicit - GetFileAttributes() call. - -2002-01-13 Christopher Faylor - - * dcrt0.cc (multiple_cygwin_problem): Clarify logic and make - CYGWIN_MISMATCH_OK more powerful. - -2002-01-10 Christopher Faylor - - * exceptions.cc (sig_handle): Accept a second argument indicating - whether the signal came from this process or not. - * sigproc.h: Reflect sig_handle arg change. - * signal.cc (kill_pgrp): Add sigframe info. - (abort): New function. Eliminates newlib function of same name. - * sigproc.cc (wait_sig): Pass "signal from this process" value as arg - 2. - -2002-01-10 Corinna Vinschen - - * syscalls.cc (pathconf): Guard _PC_PATH_MAX branch against invalid - file parameter. - -2002-01-09 Christopher Faylor - Robert Collins - - * exceptions.cc (early_stuff_init): Rename from misnamed - set_console_handler. - (ctrl_c_handler): Attempt to work around potential signal duplication - during process startup. - (sig_handle): Ignore SIGINT when we're just an "exec stub". - * spawn.cc (spawn_guts): Store pid of spawned process in global for use - by ctrl_c_handler. - * dcrt0.cc (dll_crt0_1): Call renamed initialization function. - * winsup.h: Reflect function name change. - -2002-01-08 Corinna Vinschen - - * net.cc (cygwin_accept): Set sun_path for newly connected socket. - -2002-01-07 Ralf Habacker - - * Makefile.in: Add uninstall target. - -2002-01-07 Christopher Faylor - - * sigproc.cc (getsem): Clean up debugging output. - -2002-01-07 Christopher Faylor - - * sigproc.cc (getsem): Set errno when unable to create own semaphore. - Reorganize to make clearer that error should only come from initial - creation of process semaphore. - -2002-01-06 Christopher Faylor - - * dtable.cc (dtable::init_std_file_from_handle): Add some defensive - code to invalid handle case. - -2002-01-06 Corinna Vinschen - - * ioctl.cc (ioctl): Make third argument optional. - * include/sys/ioctl.h: Ditto in declaration. - * dtable.cc (dtable::init_std_file_from_handle): Revert previous - bogus patch. - * window.cc (WndProc): Raise SIGURG instead of SIGIO in case of FD_OOB - message. - -2002-01-05 Christopher Faylor - - * dir.cc (opendir): Guarantee release of alloced fhandler structure on - error. - -2002-01-05 Corinna Vinschen - - * exceptions.cc (sig_handle): Set default action for SIGURG to SIG_IGN. - -2002-01-05 Corinna Vinschen - - * dtable.cc (dtable::init_std_file_from_handle): Don't treat NULL - handle as errorneous. - -2002-01-04 Christopher Faylor - - * cygmagic: Change logic for equality test. - -2002-01-04 Christopher Faylor - - * dir.cc (opendir): Don't attempt to call sub-opendir if ENOENT. - -2002-01-04 Corinna Vinschen - - * net.cc: Replace usage of AF_UNIX by Posix compliant AF_LOCAL - throughout. - (socketpair): Explicitly allow SOCK_STREAM and SOCK_DGRAM socket types - in families AF_UNIX and AF_LOCAL. Explicitly allow PF_UNSPEC, PF_LOCAL - and PF_INET protocols. Return error otherwise. Implement datagram - socketpairs. - -2002-01-01 Christopher Faylor - - * speclib: Remove temp files automatically. - -2002-01-01 Corinna Vinschen - * fhandler.h (fhandler_socket::sun_path): New private member. - (fhandler_socket::set_sun_path): New method. - (fhandler_socket::get_sun_path): Ditto. - * fhandler_socket.cc (fhandler_socket::fhandler_socket): Initialize - sun_path to NULL. - (fhandler_socket::~fhandler_socket): Free sun_path if needed. - (fhandler_socket::set_sun_path): New method. - * net.cc (cygwin_bind): Set sun_path to path of local socket file. - (cygwin_getsockname): Add code to return correct sockaddr for unix - domain sockets. diff --git a/winsup/cygwin/ChangeLog-2003 b/winsup/cygwin/ChangeLog-2003 deleted file mode 100644 index 6c16579a2..000000000 --- a/winsup/cygwin/ChangeLog-2003 +++ /dev/null @@ -1,5678 +0,0 @@ -2003-12-31 Christopher Faylor - - * cygwin.din: Make crt0 functions NOSIGFE. - * include/cygwin/version.h: Gratuitous comment change. - * lib/_cygwin_crt0_common.cc: Remove unneeded declaration. - -2003-12-29 Christopher Faylor - - * cygtls.h (_threadinfo::stack): Increase stack size to accommodate - nested signal handlers. Reorganize to cause potential SEGV on stack - overflow. - * sigproc.cc (no_signals_available): Check sendsig value rather than - relying on obsolete sig_loop_wait. - (sigproc_terminate): Ditto. - (proc_can_be_signalled): Check sendsig value even for myself. - * tlsoffsets.h: Regenerate. - -2003-12-29 Christopher Faylor - - Move open_fhs from fhandler.h to cygheap.h for easier tracking. - Accommodate this change throughout. - * dtable.cc (dtable::add_archetype): Use correct count when iterating - through *active* archetypes. - * dtable.cc (dtable::fixup_after_exec): Close handle if close_on_exec - and archetype exists since archetype currently does not set windows - close-on-exec flag (FIXME). - * fhandler_tty.cc (fhandler_tty_slave::open): Change debugging output - slightly. - (fhandler_tty_slave::close): Ditto. - (fhandler_tty_slave::fixup_after_fork): Just report on inherited use - counts since since archetype currently does not set windows - close-on-exec flag (FIXME). - * pinfo.cc (_pinfo::set_ctty): Change debugging output slightly. - * cygheap.cc (cygheap_init): Remove open_fhs accommodation and use - count reporting. - * perthread.h (vfork_save::fhctty): New element. - * perthread.h (vfork_save::open_fhs): New element. - * fork.cc (vfork): Muck around with ctty and open_fhs stuff, both of - which are now saved in the vfork_save structure. - -2003-12-27 Christopher Faylor - - * fhandler.h (fhandler_tty_slave::archetype): Make public. - (report_tty_counts): New macro. Use throughout for reporting tty use - counts. - * dtable.cc (dtable::vfork_child_dup): Add debugging output for - usecount increment. Increment open_fhs if appropriate. - (dtable::vfork_parent_restore): "Close" artificially bumped ctty. - (dtable::vfork_child_fixup): Close ctty since it was bumped prior to - vfork. Save open_fhs around close since the closing of these handles - has no effect on the console. - * fhandler_tty.cc (fhandler_tty_slave::open): Reorganize calls to allow - for easier tracking of usecount modification. - (fhandler_tty_slave::open): Ditto. - -2003-12-26 Christopher Faylor - - * syscalls.cc (close_all_files): Simplify logic around closing ctty. - -2003-12-26 Christopher Faylor - - * pinfo.cc (_pinfo::set_ctty): *Always* call close on opened ctty since - it counts as an opened handle. - -2003-12-26 Christopher Faylor - - * fhandler.h (fhandler_tty_master::fixup_after_fork): Remove - declaration. - (fhandler_tty_master::fixup_after_exec): Ditto. - * fhandler_tty.cc (fhandler_tty_master::init): Fix so that children do - not inherit master tty handles. - (fhandler_tty_master::fixup_after_fork): Remove, since it was never - used. - (fhandler_tty_master::fixup_after_exec): Ditto. - * pinfo.cc (_pinfo::set_ctty): Increment open_fhs when ctty is set. - * cygheap.cc (cygheap_init): Ditto. - * syscalls.cc (setsid): *Always* call close on opened ctty since the - archetype is associated with the ctty and it counts as an opened - handle. - * tty.cc (tty::common_init): Don't protect input/output mutex since it - confuses subsequent fork/execs when CYGWIN=tty. - - * fhandler_process.cc (fhandler_process::fill_filebuf): Properly set - "file size" for "" reporting when filebuf is zero length. - -2003-12-26 Christopher Faylor - - * exceptions.cc (try_to_debug): Fix off-by-one problem when resetting - environment variable after error_start detected. - - * fhandler_tty_slave.cc (fhandler_tty_slave::close): Clarify debug - message. - * syscalls.cc (setsid): Don't increment usecount here, since it will be - automatically decremented on close. - -2003-12-26 Christopher Faylor - - * exceptions.cc (setup_handler): Protect against a race. - -2003-12-26 Christopher Faylor - - * path.cc (mount_item::build_win32): Backslashify paths in non-managed - case. - -2003-12-25 Christopher Faylor - - * dcrt0.cc (reent_data): Reluctantly resurrect. - (__cygwin_user_data::impure_ptr): Ditto. - (_dll_crt0): Reluctantly initialize _impure_ptr here. - (initialize_main_tls): Eliminate local_clib initialization since it now - happens in init_thread. - * init.cc (dll_entry): Reluctantly remove code which set _impure_ptr to - the main thread's local_clib. - * perthread.h (reent_data): Remove obsolete declaration. - - * sigproc.cc (proc_subproc): Add more debugging output. - (get_proc_lock): Ditto. - - *dcrt0.cc (dll_crt0_1): Allocate argv[0] via malloc since main thread - could exit. - -2003-12-23 Christopher Faylor - - * fork.cc (fork_child): After a pthread/fork, ensure that impure - pointer stuff which resides in parent is propagated to child thread. - -2003-12-23 Christopher Faylor - - * exceptions.cc (set_signal_mask): Redefine to not pass by address. - Report calculated mask in debugging output. - * sigproc.h (set_signal_mask): Reflect above change in declaration. - -2003-12-22 Christopher Faylor - - * path.cc (mount_item::build_win32): Take path apart before feeding it - to fnmunge. - -2003-12-21 Christopher Faylor - - Throughout, change use of _reent_winsup()-> to _my_tls.locals. - instead. - Throughout, remove obsolete MT_SAFE/_CYG_THREAD_FAILSAFE considerations. - Througout, add cygtls.h include. - * Makefile.in (DLL_OFILES): Add cygtls.o. Add some more objects to the - -fomit-frame-pointer list. - * acconfig.h: Remove obsolete settings. - * config.h.in: Ditto. - * bsdlib.cc: Add cygtls.h include. - * configure.in: Remove --enable-extra-threadsafe-checking. - * configure: Regenerate. - * cygtls.h (_local_storage): New struct renamed from _winsup_t (sic). - (_threadinfo:local_clib): Add new field. - (_threadinfo::locals): Ditto. - (_threadinfo::init_thread): Accept second _reent * argument. - (_threadinfo::call): Define as regparm. - (CYGTLS_PADSIZE): Remove unnecessary slop. - (_getreent): Define as a macro. - * thread.h: Remove _CYG_THREAD_FAILSAFE and MT_SAFE stuff. - (_winsup_t): Move to cygtls.h. - (ResourceLocks::ResourceLocks): Eliminate empty constructor. - (MTinterface::reents): Eliminate. - (MTinterface::thread_self_key): Eliminate. - (MTinterface::MTinterface): Eliminate. - * dcrt0.cc: Include stdio.h for _impure_ptr initialization. - (do_global_ctors): Remove run_ctors_p (sic) considerations. Don't call - atexit here. - (__main): Initialize destructors for user here. - (dll_crt0_1): Accept a dummy argument. Don't call init_thread here. - Don't set _impure_ptr here. Call do_global_ctors after more things - have been initialized. - (_dll_crt0): Define zeros buffer as max of needed size of - CYGTLS_PADSIZE so that it can be used for two purposes while minimizing - stack usage. Initialize _impure_ptr specifically, for speed. Call - dll_crt0_1 with buffer argument. - (cygwin_dll_init): Call dll_crt0_1 with dummy argument. - * dtable.cc (dtable::find_unused_handle): Remove call to - AssertResourceOwner. - * exceptions.cc: Move _threadinfo stuff to new file. - * cygtls.cc: New file. - * gentls_offsets: Accommodate increasing complexity of cygtls.h. - * hires.h (hires_base::~hires_base): Remove. - * init.cc (dll_entry): Remove setting of reents. - * thread.cc: Remove syslog.h include. - (__getreent): Simplify to use _my_tls. - (_reent_winsup): Delete. - (AssertResourceOwner): Delete. - (MTinterface::Init): Remove setting of _clib and _winsup, with all that - entails. - (MTinterface::fixup_after_fork): Ditto. - (pthread::thread_init_wrapper): Ditto. Also remove call to - set_tls_self_pointer. - (pthread::set_tls_self_pointer): Eliminate. - (pthread::get_tls_self_pointer): Just return _my_tls.tid; - (__reent_t::init_clib): Eliminate. - * tlsoffsets.h: Regenerate. - -2003-12-17 Christopher Faylor - - * sigproc.cc (proc_subproc): Simplify code to just remove all zombies - if SIGCHLD == SIG_IGN. - -2003-12-17 Christopher Faylor - - * pinfo.h (pinfo::operator ==): Add a way to check for _pinfo types. - * sigproc.cc (proc_subproc): Ensure that zombie is removed when SIGCHLD - == SIG_IGN but still allow wait()ing threads to wake up. - -2003-12-16 Christopher Faylor - - * exceptions.cc (set_signal_mask): Report on input argument rather than - getsigmask. - - * fhandler.h (fhandler_base): Make friends with close_all_files. - * pinfo.cc (_pinfo::set_ctty): Add more debugging. - * sigproc.cc (proc_can_be_signalled): Detect state when signal handler - thread is gone in target process as an EPERM situation. Set errno to - ESRCH if process doesn't exist. - (sigproc_terminate): Set sendsig to illegal value when closed. - (sig_send): Rely on proc_can_be_signalled setting the proper errno. - * syscalls.cc (close_all_files): Detect when all ttys are closed prior - to calling close_all_files. The ctty needs to be closed explicitly in - this case. - -2003-12-16 Corinna Vinschen - - * include/cygwin/ipc.h: Include sys/types.h. - -2003-12-15 Thomas Pfaff - - * thread.cc (pthread::init_main_thread): Make sure that the main thread - has valid handles. - (pthread::create_cancel_event): Fix error message. - -2003-12-14 Christopher Faylor - - * winsup.h (access_worker): Declare with added fhandler_base parameter. - * syscalls.cc (access_worker): Accommodate extra fhandler_base - argument. Use it instead of stat_worker to determine stat information, - when appropriate. - * fhandler.cc (fhandler_base::device_access_denied): Pass fhandler - pointer to access_worker so that it can use the proper method for - determining stat information. - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Ditto. - * path.cc (path_conv::check): Add read-only attribute to /cygdrive - default settings. - -2003-12-14 Christopher Faylor - - * exceptions.cc (ctrl_c_handler): Remove this thread from the signal - handler chain. - -2003-12-14 Christopher Faylor - - * cygthread.cc (cygthread::stub): Revert previous change and again - subsume cygthread::stub2. Just return from function now since - ExitThread is guaranteed by automatic _threadinfo wrapper. Define as - per ThreadProc convention. - (cygthread::stub2): Remove. - (cygthread::simplestub): Perform similar operations to cygthread::stub. - (cygthread::simplestub2): Remove. - * cygthread.h (cygthread::stub): Declare as per ThreadProc convention. - (cygthread::stub2): Remove declaration. - (cygthread::simplestub): Declare as per ThreadProc convention. - (cygthread::simplestub2): Remove declaration. - * cygtls.h (_threadinfo::call): Define first argument as per ThreadProc - convention. - (_threadinfo::call2): Ditto. - (_tlsbase): Define as char * pointer. - (_tlstop): New definition. - (_main_tls): Define here. - * dcrt0.cc (alloc_stack): Revert previous change which called - init_thread since information would be overwritten by fork later - anyway. - (dll_crt0_1): Use _tlsbase and _tlstop for setting stack bottom, top. - * exceptions.cc: Move _main_tls declaration to cygtls.h. - (_threadinfo::call): Define first argument as per ThreadProc - convention. - (_threadinfo::call2): Call ExitThread with thread function return - value. - (_threadinfo::init_thread): Don't initialize cygtls to zero if input - arg is NULL. - * fork.cc (fork_child): Reset _main_tls here. Reinitialize parts of - _my_tls after copying data from parent. - * init.cc (threadfunc_fe): New function. Front-end for all threads - created in cygwin processes. - (munge_threadfunc): New function. - (dll_entry): Call munge_threadfunc to force the call of a thread - wrapper. - * thread.cc (pthread::thread_init_wrapper): Perform similar operations - to cygthread::stub. - (pthread::thread_init_wrapper2): Remove. - * thread.h (pthread::thread_init_wrapper): Declare as per ThreadProc - convention. - (pthread::thread_init_wrapper2): Remove declaration. - * window.cc (Winmain): Just return from function now since ExitThread - is guaranteed by automatic _threadinfo wrapper. - -2003-12-12 Christopher Faylor - - * dtable.cc (dtable::delete_archetype): Add debugging. - (dtable::release): Move archetype deletion here. - (dtable::vfork_child_dup): Increment ctty usecount to catch later - close_all_files case in parent/child. - (dtable::vfork_child_fixup): Avoid using cygheap->foo where this should - really be using local references. Call close on archetyped handles - since the handles haven't had the noninherit flag set. - * fhandler_tty.cc (fhandler_tty_slave::close): Remove archetype - deletion code. Add defensive error message when DEBUGGING. - (fhandler_tty_common::set_close_on_exec): Use more robust method for - checking whether to set handles into noninherit if there is an - archetype associated with the fhandler. - -2003-12-12 Christopher Faylor - - * dcrt0.cc (alloc_stack): Move _main_tls if stack is relocated. - -2003-12-11 Christopher Faylor - - * miscfuncs.cc (low_priority_sleep): Correct thinko which caused - SetPriority to be called unnecessarily. - * thread.cc (pthread::init_main_thread): Call new create_cancel_event - function. - (pthread::precreate): Ditto. - (pthread::postcreate): Remove cancel_event creation. - (pthread::create_cancel_event): Define new function. - * thread.h (pthread::create_cancel_event): Declare new function. - -2003-12-11 Brian Ford - - * fhandler_serial.cc (fhandler_serial::tcflush): Simplify. Remove - read polling loop to avoid a hang with streaming devices. - -2003-12-11 Christopher Faylor - - * pinfo.cc (_pinfo::set_ctty): Correct stupid typo. - -2003-12-11 Christopher Faylor - - * cygheap.h (cygheap_types): Add HEAP_ARCHETYPES. - (init_cheap::ctty): Change to pointer. - * dtable.h (dtable::find_archetype): Declare new function. - (dtable::add_archetype): Declare new function. - (dtable::delete_archetype): Declare new function. - (dtable::narchetypes): Declare. - (dtable::farchetypes): Declare. - (dtable::initial_archetype_size): Declare. - (dtable::dtable): Initialize new fields. - (dtable::initial_archetype_size): Declare. - * dtable.cc (dtable::find_archetype): Define new function. - (dtable::add_archetype): Define new function. - (dtable::delete_archetype): Define new function. - (dtable::initial_archetype_size): Define. - * fhandler.h (fhandler_base::archetype): Declare. - (fhandler_base::usecount): Declare. - * fhandler.cc (fhandler_base::fhandler_base): Initialize new fields. - * fhandler_console.cc (fhandler_console::get_tty_stuff): Pass NULL to - third argument of set_ctty. - * fhandler_tty.cc (fhandler_tty_slave::open): Accommodate new archetype - method to create only one instance of a tty. - (fhandler_tty_slave::close): Don't close handles unless archetype - usecount is zero. When that happens, close archetype too. - (fhandler_tty_slave::dup): Just copy archetype. Set use count - appropriately. Set ctty, if appropriate. - (fhandler_tty_common::dup): Remove slave considerations. - (fhandler_tty_common::set_close_on_exec): Remove cygheap->ctty - considerations. - * pinfo.cc (_pinfo::set_ctty): Accommodate new archetype methods. - * pinfo.h (_pinfo::set_ctty): Make third argument explicit. - * syscalls.cc (close_all_files): Decrement controlling tty use count - before closing all handles to allow controlling tty to be closed. - Remove previous controlling tty considerations. - -2003-12-09 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_common::dup): Just copy cygheap->ctty - to child if duping the current ctty. - (fhandler_tty_common::close): Move debugging statement earlier in function. - (fhandler_tty_slave::close): Return success when closing ctty. - * syscalls.cc (close_all_files): Avoid calling fhandler_tty_slave close - method so that open_fhs will not be decremented when closing cygheap - ctty. - (setsid): Ditto. - * dcrt0.cc (do_exit): Reorganize to avoid leaving a critical section - active after vfork. - * fhandler.h (fhandler_tty_slave::get_unit): Remove regparm parameter - since it can't work in a virtualized function. - -2003-12-08 Christopher Faylor - - * pinfo.cc (_pinfo::set_ctty): Don't copy over existing ctty if it is - active. - -2003-12-08 Christopher Faylor - - * thread.cc (pthread::precreate): Delete duplicate setting of - cancel_event. - -2003-12-08 Christopher Faylor - - * fhandler.h (fhandler_tty_slave::ttyname): Use name from pc since it - is guaranteed to be accurate. - * fhandler_tty.cc (fhandler_tty_slave::open): Increment open_fhs - appropriate when copying ctty. - (fhandler_tty_slave::close): Remove special case handling for - exit_state. Use ctty < 0 check instead. - (fhandler_tty_common::close): Set io_handle to NULL after closing. - * syscalls.cc (close_all_files): Specifically close cygheap->ctty, if - appropriate. - -2003-12-07 Christopher Faylor - - * spawn.cc (spawn_guts): Change type back to 'int' after erroneous - change below. - * wait.cc (wait4): Move sawsig initialization inside loop. - -2003-12-07 Christopher Faylor - - Change use of BOOL, TRUE, FALSE to bool, true, false, as appropriate, - throughout. - -2003-12-07 Pierre Humblet - - * tty.cc (tty::common_init): Remove call to SetKernelObjectSecurity and - edit some comments. - -2003-12-07 Christopher Faylor - - * cygheap.h (init_cygheap::ctty): Add new element. - * devices.in (device::parse): Remove special handling for /dev/tty. - * devices.cc: Regenerate. - * dtable.cc (build_fh_pc): Don't reset /dev/tty device. Let the device - opener do that. - * fhandler_termios.cc (tty_min::set_ctty): Redefine to _pinfo class. - * fhandler_tty.cc (fhandler_tty_common::set_close_on_exec): Avoid - setting noninherit flag for ctty. - * tty.h: Move BOOLs to bools. - (tty_min::set_ctty): Redeclare to _pinfo class. - * pinfo.cc (_pinfo::set_ctty): Define new function based on - tty_min::set_ctty. Change first argument from tty number to tty_min - class. - * pinfo.h (_pinfo::set_ctty): Declare. - * fhandler_console.cc (fhandler_console::get_tty_stuff): Reflect move - of set_ctty to _pinfo class. - * fhandler_tty.cc (fhandler_tty_slave::open): Treat FH_TTY specially. - Use saved cygheap value if it exists. Otherwise convert to real device - and save on first time open. - (fhandler_tty_common::dup): Potentially set controlling tty if duping a - slave tty. - * syscalls.cc (setsid): Close controlling tty in cygheap. - * tty.cc: Change some BOOLs to bools. - -2003-12-07 Pierre Humblet - - * syscalls.cc (locked_append): New. - (updwtmp): Remove mutex code and call locked_append. - (pututline): Ditto. - -2003-12-06 Christopher Faylor - - * exceptions.cc (_threadinfo::remove): Avoid a linked list walk. - -2003-12-06 Christopher Faylor - - * cygtls.h (_threadinfo::find_tls): New function. - * exceptions.cc (_threadinfo::find_tls): Rename from find_tls. Use - critical section to protect access to linked list. - -2003-12-06 Christopher Faylor - - * exceptions.cc (_threadinfo::remove): Avoid returning without - unlocking critical section in the (hopefully impossible) case of an - unrecognized thread. - -2003-12-06 Christopher Faylor - - * cygtls.h: Add more "don't parse this" guards. - (_threadinfo::init_thread): Rename from 'init'. - (_threadinfo::init): Declare new function. - (_threadinfo::protect_linked_list): Declare new critical section. - * dcrt0.cc (dll_crt0_1): Call init_thread to initialize thread stuff. - (_dll_crt0): Call _threadinfo::init prior to invoking dll_crt0_1. - * exceptions.cc (_threadinfo::init_thread): Rename from 'init'. - (_threadinfo::init): Define new function. Protect linked list - manipulation with new critical section. - (_threadinfo::call): Reflect function name change. - (_threadinfo::remove): Protect linked list manipulation with new - critical section - * gentls_offsets: Rework to allow multi-line "don't parse this" - protection. - * init.cc (dll_entry): Don't remove threads info stuff here since the - remove function uses a critical section which can't be used during - thread creation or destruction. - * thread.cc (pthread::exit): Call _threadinfo remove function here. - -2003-12-05 Christopher Faylor - - * cygthread.cc (cygthread::stub2): Remove myself from the list of - threads monitored by signals since this thread will never call raise or - sigwait. - (cygthread::simplestub2): Ditto. Set ev here. - (cygthread::cygthread): Don't set ev here for freerange thread. - -2003-12-04 Christopher Faylor - - * path.cc (slash_unc_prefix_p): Allow '.' as a valid character after - '\\' in a UNC path. - -2003-12-04 Christopher Faylor - - * exceptions.cc (setup_handler): Remove ill-advised debugging output. - -2003-12-04 Corinna Vinschen - - * include/cygwin/types.h (struct __fcntl64): Fix datatype of l_start. - -2003-12-03 Corinna Vinschen - - Substitute 0x7fffffff and 0xffffffff by INT32_MAX and UINT32_MAX - throughout, except in assembler code. - -2003-12-03 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::lock): Use UINT32_MAX - instead of 0xffffffff. Accommodate Win 9x bug in evaluating length - of area to lock when given length is 0. - -2003-12-03 Pierre Humblet - - * fhandler_disk_file.cc (fhandler_disk_file::lock): Interchange - values of off_low and off_high. - -2003-12-03 Corinna Vinschen - - * fcntl.cc (fcntl_worker): Remove static storage class. - * flock.cc (flock): Use struct __flock64. Call fcntl_worker. - Use Cygwin errno functions instead of accessing errno directly. - * winsup.h: Declare fcntl_worker. - -2003-12-03 Corinna Vinschen - - * fcntl.cc: Whitespace cleanup. - -2003-12-03 Christopher Faylor - - * cygthread.cc (cygthread::stub): Properly establish _threadinfo - environment. - (cygthread::stub2): New function. - (cygthread::simplestub): Ditto. - (cygthread::simplestub2): New function. - * cygthread.h (cygthread::stub2): Declare new function. - (cygthread::simplestub2): Ditto. - * cygtls.h (_threadinfo::call): Declare new function. - (_threadinfo::call2): Ditto. - * dcrt0.cc (dll_crt0_1): Accommodate new _threadinfo::init which - doesn't return pointer to tls. - (_dll_crt0): Remove obsolete DECLARE_TLS_STORAGE. - (dll_crt0): Ditto. - * exceptions.cc (_threadinfo::call): New function. - (_threadinfo::call2): Ditto. - (_threadinfo::init): Don't return pointer. - * thread.cc (pthread::thread_init_wrapper): Properly establish - _threadinfo environment. - (pthread::thread_init_wrapper2): New function. - * thread.h (pthread::thread_init_wrapper): Remove noreturn attribute - (pthread::thread_init_wrapper2): Declare new function. - * winbase.h: Remove obsolete code. - -2003-12-02 Christopher Faylor - - * Makefile.in: Change the way that -f options are appended to CFLAGS, - slightly. - -2003-12-02 Christopher Faylor - - * fcntl.cc (_fcntl): Silence a compiler warning. - -2003-12-02 Pierre Humblet - - * pinfo.cc (pinfo::init): Use shared_name to construct the mapname. - -2003-12-01 Thomas Pfaff - - * thread.cc (pthread_rwlock::add_reader): Remove mx parameter for - List_insert call. - (pthread::prepare): Ensure race safeness when adding function - pointers to atfork lists by using List_insert. - * thread.h (List_insert): Use InterlockedCompareExchangePointer to - ensure race safeness without using a mutex. - (List_remove): Use InterlockedCompareExchangePointer to - ensure race safeness with List_insert. - (List::insert): Remove mx parameter for List_insert call. - -2003-12-01 Corinna Vinschen - - * Makefile.in (OBSOLETE_FUNCTIONS): Add fcntl. - (NEW_FUNCTIONS): Add fcntl64. - * cygwin.din: Export fcntl64. Make fcntl being SIGFE. - * fcntl.cc (fcntl_worker): New function. - (fcntl64): New function. - (_fcntl): Call fcntl_worker. Convert 32 bit flock structure into - 64 bit flock structure and vice versa. - * fhandler.cc (fhandler_base::lock): Change 2nd parameter to - struct __flock64 *. - * fhandler_disk_file.cc (fhandler_disk_file::lock): Ditto. Rework - to be 64 bit aware. - * fhandler.h: Accommodate above method argument changes. - * include/cygwin/types.h: Add struct __flock32 and __flock64. - Define struct flock according to setting of __CYGWIN_USE_BIG_TYPES__. - * include/cygwin/version.h: Bump API minor number. - -2003-12-01 Corinna Vinschen - - * cygheap.cc (cygheap_init): Set cygheap->shared_prefix. - * cygheap.h (struct init_cygheap): Add shared_prefix. - * shared.cc (shared_name): Use cygheap->shared_prefix. - -2003-12-01 Pierre Humblet - - * shared.cc (shared_name): Take into account the SE_CREATE_GLOBAL_NAME - privilege when building the name string. - (open_shared): Remove the call to OpenFileMapping. - (shared_info::initialize): Move cygheap initialization to ... - (memory_init): ... here. Suppress now useless shared_h variable. - (user_shared_initialize): Make tu a cygpsid. - -2003-12-01 Dr. Volker Zell - - * include/tzfile.h: Remove duplicate definition of TM_SUNDAY. - * localtime.cc: Point TZDIR to the /usr/share/zoneinfo directory used - by the tzcode package. - -2003-11-30 Corinna Vinschen - - * flock.cc: Renamed from flock.c. - -2003-11-29 Christopher Faylor - - * pinfo.h: Remove global_sigs declaration. - * siginfo.h: Move global_sigs declaration here. - * Makefile.in: Remove duplicate compiler flag. - -2003-11-29 Christopher Faylor - - * exceptions.cc (_threadinfo::pop): Zero *contents* of popped stack - location rather than the actual stack pointer. - -2003-11-29 Nicholas Wourms - - * Makefile.in: (DLL_OFILES): Add flock.o. - * cygwin.din: Export flock. - * flock.c: New file. - * include/sys/file.h: Include sys/cdefs.h. - Add function prototype for flock(). - Add some comments from BSD's header for further clarity. - (L_SET, L_CURR, L_INCR, L_XTND): Redefine as the macros - SEEK_SET, SEEK_CUR, SEEK_CUR, & SEEK_END respectively. - (LOCK_SH,LOCK_EX,LOCK_NB,LOCK_UN): New macros for flock(). - * include/cygwin/version.h: Bump API minor number. - -2003-11-28 Christopher Faylor - - * sigproc.cc (no_signals_available): Fix so that non-zero exit state is - a true condition rather than errnoneously only checking other states - when exist_state was zero. - -2003-11-28 Christopher Faylor - - * pinfo.h (_pinfo::getthread2signal): Remove obsolete function. - * cygtls.h (_threadinfo): Define tid more precisely. - (_threadinfo::operator HANDLE): Define. - * exceptions.cc (_threadinfo::interupt_now): Use _threadinfo HANDLE - operator to derive thread handle. - (setup_handler): Ditto. - * sigproc.cc: Reorganize includes. Fix no_signals_available test to - properly return true when !sig_wait_loop. - -2003-11-28 Christopher Faylor - - * pinfo.h (_pinfo::getsig): Remove obsolete function, here and - throughout. - * exceptions.cc: Ditto. - * fhandler_termios.cc: Ditto. - * signal.cc: Ditto. - * sigproc.cc: Ditto. - - * Makefile.in: Revert previous change which made a cygwin.din newer - than a version.h a warning rather than an error. - -2003-11-28 Christopher Faylor - - * cygwin.din: Re-add inexplicably missing semaphore/msg functions. - -2003-11-28 Christopher Faylor - - * gendevices: Issue error when shilka is missing. - -2003-11-28 Christopher Faylor - - * include/cygwin/signal.h: New file. - -2003-11-28 Christopher Faylor - - Eliminate use of sigframe and sigthread throughout. - * Makefile.in (DLL_OFILES): Add sigfe.o. Remove reliance on cygwin.def - from cygwin0.dll dependency since dependence on sigfe.o implies that. - Generate def file on the fly using 'gendef'. - * configure.in: Don't auto-generate cygwin.def. - * configure: Regenerate. - * cygwin.din: Add SIGFE stuff where appropriate. - * dcrt0.cc (dll_crt0_1): Initialize cygwin tls early in process - startup. Set _main_tls to address of the main thread's cygwin tls. - * debug.h: Remove now unneeded WFSO and WFMO declarations. - * exceptions.cc (_last_thread): Define. - (set_thread_state_for_signals): New function. - (reset_thread_exception_for_signals): Ditto. - (init_thread_for_signals): Ditto. - (delete_thread_for_signals): Ditto. - (capture_thread_for_signals): Ditto. - (handle_exceptions): Set return address explicitly for exceptions prior - to calling sig_send. - (interrupt_on_return): Eliminate. - (setup_handler): Add preliminary implementation for dealing with - thread-specific signals by querying _main_tls. - (signal_exit): Use cygthread::main_thread_id instead of mainthread.id. - (call_signal_handler_now): For now, just handle the main thread. - * fork.cc (vfork): Save and restore main _my_tls. - * gendef: New file. Generates def file and sigfe.s file. - * gentls_offsets: New file. Generates offsets for perl to use in - sigfe.s. - * how-signals-work.txt: Mention that info is obsolete. - * init.cc (dll_entry): Initialize cygwin tls storage here. - * miscfuncs.cc (low_priority_sleep): Make a C function for easier - calling from asm. - * perthread.h (vfork_save::tls): New element. - * signal.cc (nanosleep): Replace previous use of - sigframe.call_signal_handler_now with straight call to - call_signal_handler_now. - (abort): Ditto. - * syscalls.cc (readv): Ditto. - * termios.cc (tcsetattr): Ditto. - * wait.cc (wait4): Ditto. - * sigproc.cc (sig_dispatch_pending): Ditto. - (sig_send): Ditto. - * sigproc.h: Declare call_signal_handler_now. - * thread.cc (pthread::thread_init_wrapper): Initialize cygwin tls. - Remove obsolete and unworking signal stuff. - * thread.h (verifyable_object::sigs): Eliminate. - (verifyable_object::sigmask): Eliminate. - (verifyable_object::sigtodo): Eliminate. - (verifyable_object::exit): Make attribute noreturn. - (verifyable_object::thread_init_wrapper): Ditto. - (pthread_null::exit): Ditto. - * winbase.h (__stackbase): Always define. - * winsup.h (low_priority_sleep): Declare as a "C" function. - * include/cygwin/version.h: Bump API version to reflect sigwait export. - - * include/sys/queue.h: Protect SLIST_ENTRY from previous declaration. - - * signal.cc (sigwait): Implement. - - * select.cc (fhandler_base::ready_for_read): Add debugging output. - - * devices.h: Define more device pointers via their storage. - * devices.in: Don't parse things like /dev/inet/tcp, as they really - have no meaning. - * devices.cc: Regenerate. - * gendevices: Set proper protection for output file. - - * cygtls.h: New file. - * gendef: New file. - * gentls_offsets: New file. - * tlsoffsets.h: New file. Autogenerated. - * config/i386/longjmp.c: Remove. File subsumed by gendef output. - * config/i386/makefrag: Remove obsolete file. - - * fhandler.cc: Remove spurious access_worker declaration. - - * spawn.cc (spawnve): Make debugging output more accurate. - - * cygwin-gperf: Remove. - * devices.cc: Remove. - -2003-11-28 Christopher Faylor - - * speclib: Use correct EOF marker. Ensure that directory is actually - deleted when running under Windows. - -2003-11-27 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_disk_file::readdir): Reorganize to - avoid inappropriate .lnk extensions with munged filenames under managed - mode. - -2003-11-26 Corinna Vinschen - - * sec_helper.cc (set_process_privilege): Rename restore_priv to - priv_luid. - -2003-11-26 Pierre Humblet - - * sec_helper.cc (set_process_privilege): Call LookupPrivilegeValue - before opening the token. - -2003-11-26 Corinna Vinschen - - * dir.cc (mkdir): Use local security_descriptor. Call - set_security_attribute appropriately. - * external.cc (cygwin_internal): Ditto. - * fhandler.cc (fhandler_base::open): Ditto. - * fhandler_socket.cc (fhandler_socket::bind): Ditto. - * path.cc (symlink_worker): Ditto. - * sec_acl.cc (setacl): Ditto. Call read_sd appropriately. - (getace): Ditto. - * sec_helper.cc (security_descriptor::malloc): New method. - (security_descriptor::realloc): New method. - (security_descriptor::free): New method. - * security.cc (read_sd): Get security_descriptor as parameter instead - of PSECURITY_DESCRIPTOR and a size. Drop unnecessary parameter check. - Allocate the security_descriptor buffer according to size returned by - a call to GetFileSecurity. Return buffer size on success. - (write_sd): Get security_descriptor as parameter instead of - PSECURITY_DESCRIPTOR and a size. - (get_nt_attribute): Use local security_descriptor. - (get_nt_object_attribute): Ditto in case of type == SE_REGISTRY_KEY. - Allocate security_descriptor buffer according to size returned by - a call to RegGetKeySecurity. - (alloc_sd): Make static. Get security_descriptor as parameter instead - of PSECURITY_DESCRIPTOR and a size. Drop unnecessary parameter check. - (set_security_attribute): Get security_descriptor as parameter instead - of PSECURITY_DESCRIPTOR and a size. - (set_nt_attribute): Use local security_descriptor. - (check_file_access): Ditto. - * security.h: Add class security_descriptor. - (read_sd): Change declaration to get security_descriptor as parameter - instead of PSECURITY_DESCRIPTOR and a size. - (write_sd): Ditto. - (set_security_attribute): Ditto. - (alloc_sd): Remove declaration. - * thread.cc (semaphore::semaphore): Use local security_descriptor. Call - set_security_attribute appropriately. - -2003-11-26 Corinna Vinschen - - * sec_acl.h (getace): Use FILE_*_BITS as permission mask. - * security.cc (get_attribute_from_acl): Ditto. - * security.h (FILE_READ_BITS): Define to match also GENERIC bits. - (FILE_WRITE_BITS): Ditto. - (FILE_EXEC_BITS): Ditto. - -2003-11-25 Christopher Faylor - - * thread.cc: Minor whitespace cleanup. Remove some obsolete code. - -2003-11-24 Christopher Faylor - - * dtable.cc (build_fh_name): Set error in dummy fhandler when one is - noted during path_conv. - * fhandler.h (fhandler_base::set_error): New method. - -2003-11-24 Christopher Faylor - - * configure.in: Avoid using cygserver unless hosting on cygwin. - -2003-11-23 Christopher Faylor - - * sigproc.cc (sig_send): Correct below checkin. Use - thisframe.call_signal_handler. - -2003-11-23 Christopher Faylor - - * sigproc.cc (proc_exists): A zombie process does not exist. - (sig_send): Improve debugging output. Wait for pipe to be created - before trying to send to it. Call call_signal_handler_now if sending a - signal to myself. - -2003-11-22 Christopher Faylor - - * dcrt0.cc (check_sanity_and_sync): Correct api major version check so - that newer dlls will work with older apps but not vice versa. - -2003-11-21 Christopher Faylor - - * sem.cc: Always include signal.h to handle SIGSYS raise when - !USE_SERVER. - * shm.cc: Ditto. - -2003-11-21 Christopher Faylor - - * msg.cc: Always include signal.h to handle SIGSYS raise when - !USE_SERVER. - -2003-11-20 Christopher Faylor - - * configure.in: Make --use-server the default. Remove powerpc target. - * configure: Regenerate. - -2003-11-20 Corinna Vinschen - - * msg.cc (msgctl): Raise SIGSYS if call not available. - (msgget): Ditto. - (msgrcv): Ditto. - (msgsnd): Ditto. - * sem.cc (semctl): Ditto. - (semget): Ditto. - (semop): Ditto. - * shm.cc (shmat): Ditto. - (shmctl): Ditto. - (shmget): Ditto. - (shmdt): Ditto. - -2003-11-19 Corinna Vinschen - - * cygserver.h (client_request::request_code_t): Add - CYGSERVER_REQUEST_MSG and CYGSERVER_REQUEST_SEM. - (admininstrator_group_sid): Add extern declaration. - * cygserver_ipc.h: Rewrite. - * cygserver_msg.h: New file. - * cygserver_sem.h: New file. - * cygserver_shm.h: More or less rewrite. - * cygwin.din: Add msgctl, msgget, msgrcv, msgsnd, semctl, semget and - semop. - * msg.cc: Rewrite. - * safe_memory.h: Remove. - * sem.cc: Rewrite. - * shm.cc: Rewrite. - * include/cygwin/ipc.h: Use appropriate guard. - (struct ipc_perm): Add seq. - (IPCID_TO_IX): New define from BSD. - (IPCID_TO_SEQ): Ditto. - (IXSEQ_TO_IPCID): Ditto. - (IPC_R): Ditto. - (IPC_W): Ditto. - (IPC_M): Ditto. - * include/cygwin/msg.h: Use appropriate guard. #ifdef _KERNEL all stuff - not explicitely defined by SUSv3. Use signed types in structs to match - types used in BSD. - (msgqnum_t): Define unsigned. - (msglen_t): Ditto. - (struct msqid_ds): Add msg_first and msg_last. - (struct msginfo): Remove msgpool. Add msgssz and msgseg. - * include/cygwin/sem.h: Use appropriate guard. #ifdef _KERNEL all stuff - not explicitely defined by SUSv3. Use signed types in structs to match - types used in BSD. - (SEM_UNDO): Define appropriately. - (struct semid_ds): Add sem_base. - (struct seminfo): Add semmap and semusz. - (SEM_A): New define from BSD. - (SEM_R): Ditto. - (SEM_ALLOC): Ditto. - (union semun): Define. - * include/cygwin/shm.h: Use appropriate guard. #ifdef _KERNEL all stuff - not explicitely defined by SUSv3. Use signed types in structs to match - types used in BSD. - (SHMLBA): Define using cygwin_internal(CW_GET_SHMLBA) call. - (struct shmid_ds): Add shm_internal. - (struct shm_info): Rename shm_ids to used_ids as in BSD. Add define - for shm_ids. - * include/cygwin/sysproto.h: New file. - * include/cygwin/version.h: Bump API minor number. - * include/sys/ipc.h: New file. - * include/sys/msg.h: New file. - * include/sys/queue.h: New file from BSD. - * include/sys/sem.h: New file. - * include/sys/shm.h: New file. - * include/sys/sysproto.h: New file. - -2003-11-19 Corinna Vinschen - - * dtable.cc (build_fh_pc): Resurrect accidentally removed - DEV_CYGDRIVE_MAJOR case. - -2003-11-17 Brian Ford - - * fhandler.cc (fhandler_base::lseek): Include high order offset - bits in return value. - -2003-11-17 Corinna Vinschen - - * bsdlib.cc (getprogname): New function. - (setprogname): New funtion. - * cygwin.din: Export getprogname and setprogname. - * include/cygwin/version.h: Bumb API version number. - -2003-11-15 Christopher Faylor - - * include/limits.h: Revert unsanctioned changes below. - * include/cygwin/config.h: Ditto. - * include/sys/param.h: Ditto. - -2003-11-14 Robert Collins - Ron Parker - - * bsdlib.cc: Update throughout to use CYG_MAX_PATH rather than MAX_PATH. - * cygheap.h: Ditto. - * dcrt0.cc: Ditto. - * delqueue.cc: Ditto. - * dlfcn.cc: Ditto. - * dll_init.cc: Ditto. - * dll_init.h: Ditto. - * dtable.cc: Ditto. - * environ.cc: Ditto. - * environ.h: Ditto. - * exceptions.cc: Ditto. - * external.cc: Ditto. - * fhandler_disk_file.cc: Ditto. - * fhandler_proc.cc: Ditto. - * fhandler_process.cc: Ditto. - * fhandler_raw.cc: Ditto. - * fhandler_registry.cc: Ditto. - * fhandler_socket.cc: Ditto. - * fhandler_virtual.cc: Ditto. - * miscfuncs.cc: Ditto. - * mmap.cc: Ditto. - * netdb.cc: Ditto. - * path.cc: Ditto. - * path.h: Ditto. - * pinfo.cc: Ditto. - * pinfo.h: Ditto. - * pthread.cc: Ditto. - * registry.cc: Ditto. - * shared.cc: Ditto. - * shared_info.h: Ditto. - * smallprint.c: Ditto. - * spawn.cc: Ditto. - * strace.cc: Ditto. - * syscalls.cc: Ditto. - * thread.h: Ditto. - * uinfo.cc: Ditto. - * winsup.h: Ditto. - * include/limits.h: Ditto. - * include/cygwin/config.h: Ditto. - * include/sys/param.h: Ditto. - -2003-11-12 Brian Ford - - * dtable.cc (build_fh_pc): Use DEV_SERIAL_MAJOR to catch all serial - ports. Remove redundant FH_CYGDRIVE case since it is handled by - DEV_CYGDRIVE_MAJOR. - -2003-11-11 Christopher Faylor - Thomas Pfaff - - * thread.cc (pthread::exit): Cleanup on thread exit. - (__reent_t::init_clib): Set thread local clib __cleanup var - appropriately. - -2003-11-10 Christopher Faylor - - * miscfuncs.cc (low_priority_sleep): Make a "C" function. - * winsup.h (low_priority_sleep): Revert previous change to declaration. - -2003-11-10 Corinna Vinschen - - * winsup.h (low_priority_sleep): Fix declaration to avoid linker - warning. - -2003-11-10 Thomas Pfaff - - * thread.cc (__reent_t::init_clib): Set thread local clib - __sdidinit var appropriately. - -2003-11-08 Corinna Vinschen - - * syscalls.cc (ftruncate64): Log length as long long. - (logout): Erase ut_host. Don't write wtmp entry. Return 1 only - if matching utmp entry has been found, 0 otherwise. - -2003-11-08 Corinna Vinschen - - * external.cc (cygwin_internal): Add CW_GET_UID_FROM_SID and - CW_GET_GID_FROM_SID handling. - * include/cygwin/version.h: Bump API minor number. - * include/sys/cygwin.h (cygwin_getinfo_types): Add - CW_GET_UID_FROM_SID and CW_GET_GID_FROM_SID. - -2003-11-07 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Reorganize to - handle freeing of memory on error condition. - -2003-11-07 Christopher Faylor - - * cygthread.cc (cygthread::freerange): Set inuse count. Avoid setting - ev from h as h would be NULL at this point. - (cygthread::operator new): Issue debugging info when overflowing the - thread pool. - (cygthread::cygthread): Set ev from h here after h has been initialized. - -2003-11-06 Corinna Vinschen - - * bsdlib.cc (_vwarnx): New function. - (vwarn): Ditto. - (vwarnx): Ditto. - (warn): Ditto. - (warnx): Ditto. - (verr): Ditto. - (verrx): Ditto. - (err): Ditto. - (errx): Ditto. - * cygwin.din: Export above functions. - * include/err.h: New file. - * include/cygwin/version.h: Bump API minor number. - -2003-11-06 Corinna Vinschen - - * syscalls.cc (getshmlba): New function. - * external.cc (cygwin_internal): Add CW_GET_SHMLBA handling. - * mmap.cc (mmap64): Call getshmlba to evaluate granularity. - * winsup.h (getshmlba): Add declaration. - * include/cygwin/version.h: Bump API minor number. - * include/sys/cygwin.h (cygwin_getinfo_types): Add CW_GET_SHMLBA. - -2003-11-06 Christopher Faylor - - * winsup.h: Declare access_worker. - -2003-11-05 Corinna Vinschen - - * include/cygwin/types.h: Fix preprocessor guards for vm_offset_t and - vm_size_t. Add typedef for vm_object_t. - -2003-11-05 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Detect attempt - to open a directory which lacks read privileges. - -2003-11-04 Corinna Vinschen - - * external.cc (cygwin_internal): Add CW_GET_POSIX_SECURITY_ATTRIBUTE - handling. - * include/cygwin/version.h: Bump API minor number. - * include/sys/cygwin.h (cygwin_getinfo_types): Add - CW_GET_POSIX_SECURITY_ATTRIBUTE. - - * exceptions.cc (init_global_security): Move from here... - * sec_helper.cc (init_global_security): ...to here. - -2003-11-04 Christopher Faylor - - * net.cc (dup_ent): Use IsBadStringPtr for alignment checks. Don't use - a known bad pointer. - -2003-11-03 Corinna Vinschen - - * net.cc (dup_ent): Move Win 95 misalignment recogition before - trying to evaluate string length. - -2003-10-31 Thomas Pfaff - - * thread.cc (pthread::thread_init_wrapper): Initialize exception - handling. - -2003-10-31 Thomas Pfaff - - Rename pthread::running to pthread::valid throughout. - - * thread.h: (pthread::suspend_all_except_self): New static method. - (pthread::resume_all): Ditto. - (pthread::suspend_except_self): New method. - (pthread::resume): Ditto. - * thread.cc (pthread::suspend_except_self): Implement. - (pthread::resume): Ditto. - -2003-10-29 Danny Smith - - * include/stdint.h: Prevent signed->unsigned conversion for 32 and - 64 bit min value constants. - -2003-10-28 Igor Pechtchanski - - * path.cc (dot_special_chars): New global variable. - (special_name): Make files ending in "." special. - (fnunmunge): Allow encoded ".". - (mount_item::fnmunge): Handle trailing ".". - -2003-10-28 Christopher Faylor - - * include/stdint.h: Duplicate below effort for rest of *64_*. - -2003-10-28 Christopher Faylor - - * include/stdint.h: Correctly define INT64_MAX. - -2003-10-27 Thomas Pfaff - - * thread.h (fast_mutex::init): Initialize lock_counter. - -2003-10-27 Corinna Vinschen - - * Makefile.in (OBSOLETE_FUNCTION): Add tmpfile. - (NEW_FUNCTIONS): Add _tmpfile64 -> tmpfile translation. - * cygwin.din: Export _tmpfile64 - * include/cygwin/version.h: Bump api minor number. - -2003-10-27 Corinna Vinschen - - * cygwin.din: Add sem_close, sem_getvalue, sem_open and sem_timedwait. - * pthread.cc (+mangle_sem_name): New function. - (sem_open): Ditto. - (sem_close: Ditto. - (sem_timedwait): Ditto. - (sem_getvalue): Ditto. - * thread.cc (semaphore::semaphore): Rearrange member initialization. - Use appropriate security attribute for process shared semaphores. - (semaphore::semaphore): New constructor for named semaphores. - (semaphore::~semaphore): Care for semaphore name. - (semaphore::_post): Accommodate failing ReleaseSemaphore. Use value - returned by ReleaseSemaphore vor currentvalue. - (semaphore::_getvalue): New method. - (semaphore::_timedwait): Ditto. - (semaphore::_fixup_after_fork): Rearrange. Don't fail for process - shared semaphores. - (semaphore::open): New method. - (semaphore::timedwait): Ditto. - (semaphore::post): Fix return value. Set errno appropriately. - (semaphore::getvalue): New method. - * thread.h (class semaphore): Add prototypes for open, getvalue, - timedwait, _getvalue, _timedwait. Add prototypes for new constructor. - Add name member. - * include/semaphore.h: Add prototypes for sem_open, sem_close, - sem_timedwait and sem_getvalue. - include/cygwin/version.h: Bump API minor number. - -2003-10-27 Corinna Vinschen - - * miscfunc.cc (__check_invalid_read_ptr): New function. - * winsup.h: Declare. - -2003-10-26 Corinna Vinschen - - * security.h (cygpsid::debug_print): Avoid compiler warnings. - -2003-10-25 Corinna Vinschen - - * path.cc (normalize_posix_path): Test runs of more than two - dots for being a run of only dots. Let it pass if not. - -2003-10-25 Brian Ford - - * fhandler.cc (fhandler_base::ioctl): Handle FIONBIO. - -2003-10-24 Thomas Pfaff - - Rename native_mutex to fast_mutex throughout. - Rename pthread_key::save_key_to_buffer to - pthread_key::_fixup_before_fork throughout. - Rename pthread_key::recreate_key_from_buffer to - pthread_key::_fixup_after_fork throughout. - - * thread.cc (native_mutex::init): Remove. - (native_mutex::lock): Ditto. - (native_mutex::unlock): Ditto. - (pthread::push_cleanup_handler): InterlockedExchangePointer - is not needed here. - (pthread_rwlock::pthread_rwlock): Initialize readers list mutex. - (pthread_rwlock::add_reader): Add reader via List_insert. - (pthread_rwlock::lookup_reader): Lock list while walking through. - (pthread_cond::init): Locking the init mutex is now void. - (pthread_rwlock::init): Ditto. - (pthread_mutex::init): Ditto. - * thread.h: Include security.h. - (fast_mutex): New class. Replacement for native_mutex. - (List_insert): New template function. - (List_remove): Ditto. - (List::List): Initialize synchronising mutex. - (List::fixup_after_fork): New method. - (List::insert): Add node via List_insert. - (List::remove): Remove node via List_remove. - (List::pop): Remove. - (List::for_each): Lock list while walking through. - (List::mx_init): New method. - (pthread_mutex::fixup_after_fork): Fixup mutex list after fork. - (pthread::fixup_after_fork): Ditto. - (pthread_conds::fixup_after_fork): Ditto. - (pthread_rwlock::fixup_after_fork): Ditto. - (semaphore::fixup_after_fork): Ditto. - (pthread_rwlock::readers_mx): New member. - -2003-10-24 Brian Ford - - * fhandler.cc (fhandler_base::fcntl): Don't clobber O_APPEND when - both O_NONBLOCK/O_NDELAY are set for F_SETFL. - -2003-10-24 Corinna Vinschen - - * path.cc (win32_device_name): Fix comment. - -2003-10-23 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_slave::ioctl): Properly set return - value in FIONBIO case. - -2003-10-23 Corinna Vinschen - - * fhandler_proc.cc (format_proc_partitions): Use new device code - to get major and minor device numbers. Fix size evaluation. - -2003-10-22 Corinna Vinschen - - * external.cc (cygwin_internal): Add CW_GET_ERRNO_FROM_WINERROR - handling. - * include/cygwin/version.h: Bump API minor number. - * include/sys/cygwin.h (cygwin_getinfo_types): Add - CW_GET_ERRNO_FROM_WINERROR. - -2003-10-22 Corinna Vinschen - - * Makefile.in: Add $(LIBSERVER) rule. - * cygserver.h: Moved from include/cygwin to here. - * cygserver_ipc.h: Moved from ../cygserver to here. - * cygserver_shm.h: Ditto. - * cygwin.din: Add shmat, shmctl, shmdt and shmget. - * fhandler_tty.cc (fhandler_tty_slave::open): Don't warn about handle - dup'ing if not build with USE_SERVER. - * shm.cc: Include cygerrno.h unconditionally. - (shmat): Set errno to ENOSYS and return -1 if not build with - USE_SERVER. - (shmctl): Ditto. - (shmdt): Ditto. - (shmget): Ditto. - * woutsup.h: Remove. - * include/cygwin/cygserver_process.h: Moved to ../cygserver directory. - * include/cygwin/cygserver_transport.h: Ditto. - * include/cygwin/cygserver_transport_pipes.h: Ditto. - * include/cygwin/cygserver_transport_sockets.h: Ditto. - * include/cygwin/version.h: Bump API minor number. - -2003-10-16 Pierre Humblet - - * syscalls.cc (seteuid32): Always construct a default DACL including - the new sid, Admins and SYSTEM and copy it to the new thread token. - * security.cc (create_token): Use a NULL default DACL in NtCreateToken. - -2003-10-14 Micha Nelissen - - * dcrt0.cc: Remove local variable alternate_charset_active. - * fhandler.h: Add variable alternate_charset_active, functions - str_to_con, con_to_str to dev_console structure. - * fhandler_console.cc (con_to_str): Move function into dev_console - class. - (str_to_con): Ditto. - (fhandler_console::read): Call con_to_str on dev_state. - (fhandler_console::write_normal): Call str_to_con on dev_state. - (fhandler_console::char_command): Change active_charset_active - assignment to be on dev_state. - * winsup.h: Remove global external variable alternate_charset_active. - -2003-10-13 Micha Nelissen - - * fhandler_console.cc (char_command): Add escape sequence for codepage - ansi <-> oem switching for ncurses frame drawing capabilities. - * dcrt0.cc: Add local variable alternate_charset_active. - * winsup.h: Add global external variable alternate_charset_active. - -2003-10-14 Corinna Vinschen - - * exceptions.cc (ctrl_c_handler): Don't send SIGHUP on - CTRL_LOGOFF_EVENT to processes running in invisible Windows Stations. - * window.cc (has_visible_window_station): New function. - * winsup.h: Add declaration for has_visible_window_station. - -2003-10-10 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_slave::open): Don't create a new window - station if one already exists. - -2003-10-10 Christopher Faylor - - * shared.cc (shared_info::initialize): Remove myself check since - hMainProc initialization will allow user initialization to work. - -2003-10-09 Yitzchak Scott-Thoennes - - * include/sys/mman.h (MAP_FAILED): Define as void *. - -2003-10-08 Christopher Faylor - - * dcrt0.cc (hMainProc): Initialize to useful value for use when dll is - dynamically loaded. - * shared.cc (shared_info::initialize): Don't initialize user stuff if - myself doesn't exist. - -2003-10-08 Corinna Vinschen - - * syscalls.cc (unlink): Don't even try DELETE_ON_CLOSE technique on - systems not supporting it. - -2003-10-02 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Call newlib __sinit routine to ensure that - stdio buffers are initialized to avoid thread initialization races. - -2003-10-01 Christopher Faylor - - * path.cc (win32_device_name): Only fill out destination buffer when - it's really a device. - -2003-09-30 Christopher Faylor - - * Makefile.in: Add YA method for generating devices.cc. - * child_info.h: YA update of another magic number. - * gendevices: New file. - * devices.in: New file. - * devices.cc: Regenerate. - * devices.shilka: Remove. - * devices.h: Correctly define device pointers. - (device): Remove now obsolete fields. - (device::native): Renamed from device::fmt. - * dtable.cc (build_fh_dev): Simplify in light of new unit parsing - scheme. - (build_fh_pc): Ditto. - * path.cc (win32_device_name): Ditto. - * fhandler.h (fhandler_base::get_native_name): Reflect renaming of fmt - to native. - * fhandler_tty.cc (fhandler_tty_mster::init): Initialize slave device - prior to reporting unit. - -2003-09-30 Corinna Vinschen - - * fhandler.cc (fhandler_base::fstat): Drop FH_FLOPPY case. - -2003-09-30 Corinna Vinschen - - * fhandler.h (class fhandler_dev_raw): Add method fstat. - * fhandler_raw.cc (fhandler_dev_raw::fstat): New method. - -2003-09-30 Corinna Vinschen - - * devices.h (enum fh_devices): Remove DEV_RAWDRIVE_MAJOR and - FH_RAWDRIVE. - * devices.shilka (dev_rawdrive_storage): Remove. - (unit_devices): Remove pointer to dev_rawdrive_storage. - (uniq_devices): Remove rawdrive entry. - * dtable.cc (build_fh_pc): Remove DEV_RAWDRIVE_MAJOR case. - * path.cc (win32_device_name): ditto. - -2003-09-29 Corinna Vinschen - - * syslog.cc (vsyslog): Print debug message if ReportEventA fails. - -2003-09-28 Pierre Humblet - - * sigproc.cc (proc_subproc): Restrict permissions on ppid_handle. - -2003-09-28 Christopher Faylor - - * devices.shilka (device::parse): Restore check for tty in unit - handling, but without the previous typo. - * devices.cc: Regenerate. - * devices.h (DEV_CYGDRIVE_MAJOR): Change major number to one used by - linux for "user-mode virtual block device". - -2003-09-28 Corinna Vinschen - - * devices.h: Move a few device major numbers. Fix typo of FH_UDP. - * device.shilka: Remove /dev/hd device entries, rename all device_hd* - to device_sd*. - (device::parse): Disallow units outside lower and upper bounds. - * dtable.cc (build_fh_pc): Fix typo of FH_UDP. - * path.cc (win32_device_name): Fix win32 name creation to match new - device handling. - -2003-09-27 Christopher Faylor - - * device.shilka (device::parse): Allow units on other than tty. - -2003-09-27 Corinna Vinschen - - * wincap.cc (wincapc::init): Allow requesting server info for NT4 SP6. - -2003-09-27 Christopher Faylor - - * path.cc (symlink_info::check): Use new introducer for mknod'ed files. - (parse_device): Ditto. - * syscalls.cc (mknod_worker): Ditto. - -2003-09-27 Christopher Faylor - - * devices.shilka: Add /dev/sda disk devices. - * devices.cc: Regenerate. - -2003-09-27 Christopher Faylor - - * cygwin-shilka: Remove '#line directives' or suffer debugging oddities. - Use -length option so that device prefixes are used. - * devices.cc: Regenerate. - * syscalls.cc (ttyname): Add debugging output. - -2003-09-26 Vaclav Haisman - - * wincap.h (wincaps::is_server): New flag. - (wincapc::version): Change type to OSVERSIONINFOEX. - (wincapc::is_server): New function. - * wincap.cc (wincap_unknown::is_server): New initializer. - (wincap_95): Ditto. - (wincap_95osr2): Ditto. - (wincap_98): Ditto. - (wincap_me): Ditto. - (wincap_nt3): Ditto. - (wincap_nt4): Ditto. - (wincap_nt4sp4): Ditto. - (wincap_2000): Ditto. - (wincap_xp): Ditto. - (wincapc::init): Adapt to OSVERSIONINFOEX. Add detection of NT server - systems. - * sched.cc: Include windows.h and registry.h. - (sched_rr_get_interval): Re-implement for NT systems. - -2003-09-26 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_slave::ioctl): Properly set - ioctl_request event when window size changes. Store failing errno in - ioctl_retval (needed?). - -2003-09-26 Pavel Tsekov - - * fhandler_console.c (fhandler_console::read): Record the state of the - SHIFT, CTRL and ALT keys at the time of the last keyboard input event. - (fhandler_console::ioctl): Handle requests to retrieve the keyboard - modifiers via the TIOCLINUX command. - * fhandler_tty.c (fhandler_tty_slave::read): Ditto. - * include/sys/termios.h (TIOCLINUX): New macro definition. - -2003-09-26 Pierre Humblet - - * pinfo.cc (pinfo::init): Do not give FILE_MAP_WRITE access to Everybody. - * exceptions.cc (sig_handle_tty_stop): Do not create pinfo parent with - PID_MAP_WRITE. - * fhandler_process.cc (fhandler_process::fill_filebuf): Ditto for pinfo p. - * signal.cc (kill_worker): Ditto for pinfo dest. - -2003-09-26 Pierre Humblet - - * pinfo.h (pinfo::set_acl): Declare. - * pinfo.cc (pinfo_fixup_after_fork): Duplicate with no rights. - (pinfo::set_acl): New. - * spawn.cc (spawn_guts): Call myself.set_acl. - -2003-09-26 Pierre Humblet - - * uinfo.cc (cygheap_user::init): Make sure the current user appears - in the default DACL. Rearrange to decrease the indentation levels. - Initialize the effec_cygsid directly. - (internal_getlogin): Do not reinitialize myself->gid. Open the process - token with the required access. - * cygheap.h (class cygheap_user): Delete members pid and saved_psid. - Create members effec_cygsid and saved_cygsid. - (cygheap_user::set_sid): Define inline. - (cygheap_user::set_saved_sid): Ditto. - (cygheap_user::sid): Modify. - (cygheap_user::saved_sid): Modify. - * cygheap.cc (cygheap_user::set_sid): Delete. - (cygheap_user::set_saved_sid): Ditto. - * sec_helper.cc (sec_acl): Set the correct acl size. - * autoload.cc (FindFirstFreeAce): Add. - * security.h: Define ACL_DEFAULT_SIZE. - -2003-09-26 Corinna Vinschen - - * mmap.cc (munmap): Use correct address and length parameters when - calling fhandler's munmap. - -2003-09-26 Corinna Vinschen - - * spawn.cc (spawn_guts): Set errno to E2BIG if command line is - longer than CreateProcess allows (32K). - -2003-09-25 Christopher Faylor - - * dtable.cc (build_fh_name): Return pointer to a 'nodevice' rather than - a NULL pointer or suffer SEGVs with invalid paths. - -2003-09-25 Christopher Faylor - - * fork.cc (fork_parent): Detect failed pinfo constructor. - * spawn.cc (spawn_guts): Don't overwrite ENOMEM errno on failed pinfo - constructor. - -2003-09-25 Christopher Faylor - - * spawn.cc (spawnve): Remove vfork short circuit and let caller deal - with error return. - -2003-09-25 Pierre Humblet - Christopher Faylor - - * spawn.cc (spawn_guts): Catch potential error from pinfo.remember. - Change debug messages to make sense. Pass correct value to pinfo - constructor. Ensure cleanup after errors. Always reimpersonate after - errors. - -2003-09-25 Christopher Faylor - - * spawn.cc (spawn_guts): Move system signal handling stuff after - CreateProcess error check. - -2003-09-25 Pierre Humblet - - * shared_info.h: Update CURR_USER_MAGIC, CURR_SHARED_MAGIC and - SHARED_INFO_CB. - (mount_info::cb): Delete. - (mount_info::version): Delete. - (shared_info::delqueue): Delete. - * Makefile.in: Do magic for USER_MAGIC, class user_info, instead - of for mount_info. - -2003-09-24 Christopher Faylor - - * include/tzfile.h: Add some missing entries. - -2003-09-24 Christopher Faylor - - * include/paths.h: Add some missing entries. - -2003-09-24 Christopher Faylor - - * shared_info.h (CURR_MOUNT_MAGIC): Fix. - - * sigproc.cc (sigpacket): New structure. - (sig_send): Fill out sigpacket structure to send to signal thread - rather than racily sending separate packets. - (wait_sig): Use sigpacket structure to receive info from signal sender. - -2003-09-24 Pierre Humblet - - * shared_info.h (class user_info): New. - (cygwin_user_h): New. - (user_shared): New. - (enum shared_locations): Replace SH_MOUNT_TABLE by SH_USER_SHARED; - (mount_table): Change from variable to macro. - * shared.cc: Use sizeof(user_info) in "offsets". - (user_shared_initialize): Add "reinit" argument to indicate need - to reinitialize the mapping. Replace "mount_table" by "user_shared" - throughout. Call user_shared->mountinfo.init and - user_shared->delqueue.init. - (shared_info::initialize): Do not call delqueue.init. - (memory_init): Add argument to user_shared_initialize. - * child_info.h (child_info::mount_h): Delete. - (child_info::user_h): New. - * sigpproc.cc (init_child_info): Use user_h instead of mount_h. - * dcrt0.cc (_dll_crt0): Ditto. - * fhandler_disk_file.cc (fhandler_disk_file::close): Use - user_shared->delqueue instead of cygwin_shared->delqueue. - * fhandler_virtual.cc (fhandler_virtual::close): Ditto. - * syscalls.cc (close_all_files): Ditto. - (unlink): Ditto. - (seteuid32): Add argument to user_shared_initialize. - -2003-09-24 Christopher Faylor - - * devices.cc: New file. - * devices.gperf: New file. - * devices.shilka: New file. - * cygwin-gperf: New file. - * cygwin-shilka: New file. - * fhandler_fifo.cc: New file. - * fhandler_nodevice.cc : New file. - -2003-09-24 Christopher Faylor - - Reorganize headers so that path.h precedes fhandler.h throughout. - Remove device argument and unit arguments from fhandler constructors - throughout. Remove pc arguments to fhandler functions and use internal - pc element instead, throughout. Use dev element in pc throughout. Use - major/minor elements rather than units and device numbers previously in - fhandler class. Use correct methods for fhandler file names rather - than directly accessing file name variables, throughout. - * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o - * dcrt0.cc (dll_crt0_1): Call device::init. - * devices.h: Renumber devices based on more Linux-like major/minor - numbers. Add more devices. Declare standard device storage. - (device): Declare struct. - * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* - type. - * dtable.cc (dtable::get_debugger_info): Ditto. - (cygwin_attach_handle_to_fd): Ditto. - (dtable::release): Remove special FH_SOCKET case in favor of generic - "need_fixup_before" test. - (dtable::init_std_file_from_handle): Use either build_fh_dev or - build_fh_name to build standard fhandler. - (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. - Move out of dtable class. Don't accept a path_conv argument. Just - build it here and pass it to: - (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable - class. Use intrinsic device type in path_conv to create new fhandler. - (build_fh_dev): Renamed from dtable::build_fhandler. Move out of - dtable class. Simplify arguments to just take new 'device' type and a - name. Just return pointer to fhandler rather than trying to insert - into dtable. - (dtable::dup_worker): Accommodate above build_fh name changes. - (dtable::find_fifo): New (currently broken) function. - (handle_to_fn): Use strechr for efficiency. - * dtable.h: Reflect above build_fh name changes and argument - differences. - (fhandler_base *&operator []): Return self rather than copy of self. - * fhandler.cc (fhandler_base::operator =): Use pc element to set - normalized path. - (fhandler_base::set_name): Ditto. - (fhandler_base::raw_read): Use method to access name. - (fhandler_base::write): Correctly use get_output_handle rather than - get_handle. - (handler_base::device_access_denied): New function. - (fhandler_base::open): Eliminate pc argument and use pc element of - fhandler_base throughout. - (fhandler_base::fstat): Detect if device is based in filesystem and use - fstat_fs to calculate stat, if so. - (fhandler_base::fhandler_base): Eliminate handling of file names and, - instead, just free appropriate component from pc. - (fhandler_base::opendir): Remove path_conv parameter. - * fhandler.h: Remove all device flags. - (fhandler_base::pc): New element. - (fhandler_base::set_name): Change argument to path_conv. - (fhandler_base::error): New function. - (fhandler_base::exists): New function. - (fhandler_base::pc_binmode): New function. - (fhandler_base::dev): New function. - (fhandler_base::open_fs): New function. - (fhandler_base::fstat_fs): New function. - (fhandler_base::fstat_by_name): New function. - (fhandler_base::fstat_by_handle): New function. - (fhandler_base::isfifo): New function. - (fhandler_base::is_slow): New function. - (fhandler_base::is_auto_device): New function. - (fhandler_base::is_fs_special): New function. - (fhandler_base::device_access_denied): New function. - (fhandler_base::operator DWORD&): New operator. - (fhandler_base::get_name): Return normalized path from pc. - (fhandler_base::get_win32_name): Return windows path from pc. - (fhandler_base::isdevice): Renamed from is_device. - (fhandler_base::get_native_name): Return device format. - (fhandler_fifo): New class. - (fhandler_nodevice): New class. - (select_stuff::device_specific): Remove array. - (select_stuff::device_specific_pipe): New class element. - (select_stuff::device_specific_socket): New class element. - (select_stuff::device_specific_serial): New class element. - (select_stuff::select_stuff): Initialize new elements. - * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base - class from fhandler_disk_file. - (fhandler_base::fstat_by_name): Ditto. - (fhandler_base::fstat_by_name): Ditto. - (fhandler_disk_file::open): Move most functionality into - fhandler_base::open_fs. - (fhandler_base::open_fs): New function. - (fhandler_disk_file::close): Move most functionality into - fhandler_base::close_fs. - (fhandler_base::close_fs): New function. - * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in - debugging output. - * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy - standard urandom device into appropriate place. - (fhandler_socket::accept): Reflect change in fdsock return value. - * fhandler_tty.cc: See "throughouts" above. - * net.cc: Accommodate fdsock change throughout. - (fdsock): Return success or failure, accept fd argument and device - argument. - * path.cc (symlink_info::major): New element. - (symlink_info::minor): New element. - (symlink_info::parse_device): Declare new function. - (fs_info::update): Accommodate changes in path_conv class. - (path_conv::fillin): Ditto. - (path_conv::return_and_clear_normalized_path): Eliminate. - (path_conv::set_normalized_path): New function. - (path_conv::path_conv): Set info in dev element. Use path_conv methods - Check for FH_FS rather than FH_BAD to indicate when to fill in - filesystem stuff. where appropriate rather than direct access. Use - set_normalized_path to set normalized path. - (windows_device_names): Eliminate. - (get_dev): Ditto. - (get_raw_device_number): Ditto. - (get_device_number): Ditto. - (win32_device_name): Call new device name parser to do most of the - heavy lifting. - (mount_info::conv_to_win32_path): Fill in dev field as appropriate. - (symlink_worker): Handle new device files. - (symlink_info::check): Ditto. - (symlink_info::parse_device): Define new function. - * path.h (executable_states): Move here from fhandler.h. - (fs_info): Rename variables to *_storage and create methods for - accessing same. - (path_conv): Add dev element, remove devn and unit and adjust inline - methods to accommodate. - (set_normalized_path): Declare new function. - * pinfo.cc (_pinfo::commune_recv): Add broken support for handling - fifos. - (_pinfo::commune_send): Ditto. - * pipe.cc (fhandler_pipe::close): check for existence of handle before - closing it. - (handler_pipe::create): Rename from make_pipe. Change arguments to - accept fhandler_pipe array. Accommodate fifos. - (pipe): Rework to deal with fhandler_pipe::create changes. - (_pipe): Ditto. - * select.cc: Use individual device_specific types throughout rather - than indexing with obsolete device number. - (set_bits): Use is_socket call rather than checking device number. - * shared_info.h (CURR_MOUNT_MAGIC): Update. - (conv_to_win32_path): Reflect addition of device argument. - * syscalls.cc (mknod_worker): New function. - (open): Use build_fh_name to build fhandler. - (chown_worker): Detect if this is an 'auto' device rather than an - on-filesystem device and handle appropriately. - (chmod_device): New function. - (chmod): Detect if this is an 'auto' device rather than an - on-filesystem device and handle appropriately. Use chmod_device to set - mode of in-filesystem devices. - (stat_worker): Eliminate path_conv argument. Call build_fh_name to - construct fhandler. Use fh->error() rather than pc->error to detect - errors in fhandler construction. - (access_worker): New function pulled from access. Accommodate - in-filesystem devices. - (access): Use access_worker. - (fpathconf): Detect if this is an 'auto' device rather than an - on-filesystem device and handle appropriately. - (mknod_worker): New function. - (mknod32): New function. - (chroot): Free normalized path -- assuming it was actually cmalloced. - * tty.cc (create_tty_master): Tweak for new device class. - (tty::common_init): Ditto. - * winsup.h (stat_worker): Remove. - (symlink_worker): Declare. - - * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and - don't worry about pending_signals since sig_dispatch_pending should - always do the right thing now. - (sig_handle): Reorganize SIGCONT handling to more closely conform to - SUSv3. - * pinfo.h: Move __SIG enum to sigproc.h. - (PICOM_FIFO): New enum element. - (_pinfo): Remove 'thread2signal' stuff throughout class. - (_pinfo::commune_send): Make varargs. - (_pinfo::sigtodo): Eliminate. - (_pinfo::thread2signal): Ditto. - * signal.cc (kill_worker): Eliminate call to setthread2signal. - * sigproc.cc (local_sigtodo): Eliminate. - (getlocal_sigtodo): Ditto. - (sigelem): New class. - (pending_signals): New class. - (sigqueue): New variable, start of sigqueue linked list. - (sigcatch_nonmain): Eliminate. - (sigcatch_main): Eliminate. - (sigcatch_nosync): Eliminate. - (sigcomplete_nonmain): Eliminate. - (pending_signals): Eliminate. - (sig_clear): Call signal thread to clear pending signals, unless - already in signal thread. - (sigpending): Call signal thread to get pending signals. - (sig_dispatch_pending): Eliminate use of pending_signals and just check - sigqueue. - (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. - Close signal pipe handle. - (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe - to send signals. - (getevent): Eliminate. - (pending_signals::add): New function. - (pending_signals::del): New function. - (pending_signals::next): New function. - (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to - communicate and maintain a linked list of signals. - * sigproc.h: Move __SIG defines here. Add __SIGPENDING. - (sig_dispatch_pending): Remove "C" specifier. - (sig_handle): Accept a mask argument. - * thread.cc: Remove signal handling considerations throughout. - -2003-09-22 Christopher Faylor - - * dcrt0.cc (do_exit): Eliminate "C" linkage. Call events_terminate - early. - (exit_states): Move out of source file into header file. - * winsup.h: Move exit_states here. Remove "C" linkage from do_exit - declaration. - * debug.cc (lock_debug): Remove explicit (and incorrect) external for - exit_state. - * sigproc.cc (sig_dispatch_pending): Don't flush signals if exiting. - -2003-09-20 Christopher Faylor - - * spawn.cc (pthread_cleanup): New struct. - (do_cleanup): New function. - (spawn_guts): Initialize struct for pthread_cleanup handling to ensure - proper restoration of signals if/when thread is cancelled. Restore - settings using pthread_cancel_pop. - -2003-09-19 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number to 6. - -2003-09-19 Christopher Faylor - - * thread.h (__reent_t::init_clib): Declare new function. - * thread.cc (__reent_t::init_clib): Define new function. - (pthread::thread_init_wrapper): Use __reent_t::init_clib to init local - clib storage and set std{in,out,err} appropriately. - -2003-09-19 Christopher Faylor - - * syscalls.cc (system): Strip signal considerations from here so that - they are not inherited by a child process. - * spawn.cc (spawn_guts): Handle system() signal stuff here. - * winsup.h (_P_SYSTEM): Define. - -2003-09-18 Corinna Vinschen - - * fhandler_tty.cc (fhandler_pty_master::process_slave_output): - Handle buf == NULL as flushing the buffer. - (fhandler_tty_slave::read): Handle ptr == NULL as flushing the buffer. - (fhandler_tty_slave::tcflush): Implement input queue flushing by - calling read with NULL buffer. - (fhandler_pty_master::tcflush): Ditto, calling process_slave_output. - * termios.cc (tcflush): Check for legal `queue' value. Return - EINVAL otherwise. - -2003-09-16 Brian Ford - - * syscalls.cc (gethostid): Add lpFreeBytesAvailable argument to - GetDiskFreeSpaceEx call since NT4 requires it. - -2003-09-16 Christopher Faylor - - * fhandler_process.cc (fhandler_process::fill_filebuf): Open pinfo with - PID_MAP_RW. - * sigproc.cc (talktome): Ditto for winpids. - -2003-09-16 Christopher Faylor - - * pinfo.h (winpids::pid_access): New element. - (winpids::winpids): Rejigger to set pinfo_access. - * pinfo.cc (winpids::add): Try to open shared memory region with - supplied pinfo_access first, then default to readonly. - * fhandler_termios.cc (tty_min::kill_pgrp): When getting list of pids - to work with, suggest opening with PID_MAP_RW. - * signal.cc (kill_pgrp): Ditto. - * sigproc.cc (sig_send): Perform a write check on todo prior to - attempting to increment it. Return EACCES if we can't write to it. - -2003-09-16 Corinna Vinschen - - * cygheap.cc (cygheap_user::set_saved_sid): Rename from set_orig_sid. - * cygheap.h (class cygheap_user): Rename orig_psid, orig_uid and - orig_gid to saved_psid, saved_uid and saved_gid respectively. - Rename methods orig_sid and set_orig_sid to saved_sid and set_saved_sid - respectively. - * sec_helper.cc (sec_acl): Accommodate above changes. - * spawn.cc (spawn_guts): Ditto. - * uinfo.cc (uinfo_init): Ditto. - -2003-09-15 Christopher Faylor - - * getopt.c (opterr): Reinstate initialization. - (optind): Ditto. - (optopt): Ditto. - * pinfo.cc: Include cygheap.h or suffer compile error. - * shared.h: Reset magic number. - -2003-09-15 Christopher Faylor - - * exceptions.cc (sig_handle_tty_stop): Fix boneheaded mistake by using - correct check for parent state rather than inverted check. - -2003-09-15 Pierre Humblet - - * security.h (__sec_user): Add "access2" argument. - (sec_acl): Add "original" and "access2" arguments. - (sec_user): Add "sid2" and "access2" argument. Remove dependence on - allow_ntsec. - (sec_user_nih): Ditto. - * sec_helper.cc (__sec_user): Add "has_security" test. - Call sec_acl with new arguments, letting it handle original_sid. - (sec_acl): Add "original" and "access2" arguments. Handle original_sid - depending on flag but avoiding duplicates. Use "access2" for sid2. - * pinfo.cc (pinfo::init): Use security attributes created by sec_user - when creating the mapping. - * security.cc (create_token): Adjust arguments in call to sec_acl. - Call sec_user instead of __sec_user. - * syscall.cc (seteuid32): Adjust arguments in call to sec_acl. Remove - now unnecessary test. Remove useless conversions to psid. - * dcrt0.cc (dll_crt0_1): Call cygsid::init before pinfo_init. - -2003-09-13 Christopher Faylor - - * Makefile.in: Make malloc_wrapper -fomit-frame-pointer. - - * cygwin.din: Remove extraneous mallinfo definition. - - * dcrt0.cc (quoted): Use strechr for efficiency. - - * fhandler.cc (fhandler_base::write): Correctly use get_output_handle - rather than get_handle. - (fhandler_base::lseek): Use method for accessing name in debug output. - -2003-09-13 Christopher Faylor - - * fhandler_disk_file.cc (path_conv::ndisk_links): Fix potential - off-by-one problem when first file in a directory is a directory. - -2003-09-13 Pierre Humblet - - * include/sys/cygwin.h: Rename PID_UNUSED to PID_MAP_RW. - * pinfo.cc (pinfo_init): Initialize myself->gid. - (pinfo::init): Create the "access" variable, set it appropriately and - use it to specify the requested access. - * exceptions.cc (sig_handle_tty_stop): Add PID_MAP_RW in pinfo parent. - * signal.cc (kill_worker): Ditto for pinfo dest. - * syscalls.cc (setpgid): Ditto for pinfo p. - -2003-09-13 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number to 5. - -2003-09-12 Christopher Faylor - - * thread.cc (MTinterface::fixup_after_fork): Remove code which - potentially overwrote _impure pointer with contents of thread which - invoked fork since this eliminates important information like the - pointer to the atexit queue. - -2003-09-12 Christopher Faylor - - * fhandler_disk_file.cc (path_conv::ndisk_links): Fix problem where - search characters overwrote the path instead of being tacked on the - end. - -2003-09-12 Christopher Faylor - - * dcrt0.cc (_dll_crt0): Accommodate breaking apart of early_stuff_init. - * exceptions.cc (early_stuff_init): Delete. - (init_console_handler): New function - top half of early_stuff_init. - (init_global_security): New function - bottom half of early_stuff_init. - (sig_handle): Avoid special hExeced test for SIGINT. Just terminate - the captive process. - (signal_exit): Add debugging output. - * fhandler_tty.cc (fhandler_tty_slave::open): Don't allocate a console - if one already seems to exist. Properly initialize ctrl-c handling if - we do allocate a console. - * winsup.h (early_stuff_init): Delete declaration. - (init_console_handler): New declaration. - (init_global_security): New declaration. - -2003-09-11 Christopher Faylor - - * fhandler_disk_file.cc (path_conv::ndisk_links): Rename from - num_entries. Accept an argument and calculate any extra links needed - based on missing . and .. entries. - (fhandler_disk_file::fstat_helper): Always call pc->ndisks_links() to - calculate the number of links. - * path.h (path_conv::ndisk_links): Declare. - -2003-09-11 Christopher Faylor - - * path.cc (normalize_posix_path): Put check for '//' prefix back to - denote a UNC path. - (slash_unc_prefix_p): Remove vestige of old //c method for accessing - drives. - -2003-09-11 Christopher Faylor - - * dir.cc (rmdir): Add more samba workarounds. - -2003-09-11 Corinna Vinschen - - * shared.cc (user_shared_initialize): Revert length attribute for name - variable to be just UNLEN + 1. - -2003-09-10 Pierre Humblet - - * shared_info.h (shared_info::initialize): Remove argument. - * cygheap.h (cygheap_user::init): New declaration. - * uinfo.cc (cygheap_user::init): New. - (internal_getlogin): Move functionality to cygheap_user::init. Open - the process token to update the group sid. - * shared.cc (user_shared_initialize): Get the user information from - cygheap->user. - (shared_info::initialize): Remove argument. Call cygheap->user.init - instead of cygheap->user.set_name. - (memory_init): Do not get the user name and do not pass it to - shared_info::initialize. - * registry.cc (get_registry_hive_path): Make csid a cygpsid. - (load_registry_hive): Ditto. - -2003-09-10 Christopher Faylor - - * fhandler_disk_file.cc (num_entries): Take . and .. into account if - they do not exist since cygwin simulates them. - (fhandler_cygdrive::fstat): Ditto. - (fhandler_cygdrive::readdir): Don't do any specific tests on - __d_position when seeing if a drive exists. - -2003-09-10 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Add getopt.o and iruserok.o. - * cygwin.din: Export __check_rhosts_file, __rcmd_errstr, optarg, - opterr, optind, optopt, optreset, getopt, getopt_long, iruserok - and ruserok. - * getopt.c: Moved from lib to here. Define opt* variables as - dllexport. - * iruserok.c: Moved from lib to here. Rearrange function order. - Prefer using 64/32 bit functions. - * syscalls.cc (shell_fp): Define as struct __sFILE64. - (getusershell): Use fopen64 instead of fopen. - * winsup.h: Add declarations for seteuid32, fopen64, - cygwin_gethostbyname and cygwin_inet_addr. - * include/getopt.h: Declare opt* variables dllimport. - * include/cygwin/version.h: Bump API minor number. - -2003-09-10 Christopher Faylor - - * exceptions.cc (sig_handle_tty_stop): Check parent PID_NOCLDSTOP - rather than erroneously checking *my own* sigtodo. - -2003-09-10 Christopher Faylor - - * Makefile.in: Add some more -fomit-frame-pointer files. - - * path.cc (conv_path_list_buf_size): Free normalized_path or suffer - memory leak. - * syscalls.cc (chroot): Ditto. - -2003-09-10 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Add bsdlib.o. - * autoload.cc (RegisterServiceProcess): Add. - * bsdlib.cc: New file. - (daemon): New function. - (login_tty): Ditto. - (openpty): Ditto. - (forkpty): Ditto. - * cygwin.din: Export daemon, forkpty, login_tty, logwtmp, updwtmp, - openpty and revoke. - * syscalls.cc (updwtmp): New function, writing to wtmp exclusively. - (logwtmp): Ditto. - (login): Call updwtmp instead of writing to wtmp by itself. - (logout): Ditto. - * tty.cc (revoke): New funtion. - * include/paths.h: Define _PATH_DEVNULL. - * include/pty.h: New header. - * include/cygwin/version.h: Bump API minor number. - * include/sys/utmp.h: Declare logwtmp with const arguments. - Declare updwtmp. - * lib/iruserok.c: New file. - (ruserok): New function. - (iruserok): Ditto. - (__ivaliduser): Ditto. - (__icheckhost): Ditto. - -2003-09-10 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::fstat): Don't use PC_POSIX. - -2003-09-09 Pierre Humblet - - * shared_info.h: Include security.h. - (open_shared): Add psa argument. - (user_shared_initialize): New declaration. - * security.h: Add _SECURITY_H guard. - (sec_user): Use sec_none in the no ntsec case. - * spawn.cc (spawn_guts): Remove call to load_registry_hive. - * syscalls (seteuid32): If warranted, call load_registry_hive, - user_shared_initialize and RegCloseKey(HKEY_CURRENT_USER). - * shared.cc (user_shared_initialize): New. - (open_shared): Add and use psa argument. - (memory_init): Move mount table initialization to - user_shared_initialize. Call it. - -2003-09-09 Corinna Vinschen - - * mmap.cc (mmap64): Change address types from caddr_t to void * - according to SUSv3. - (mmap): Ditto. - (munmap): Ditto. - (msync): Ditto. - (mprotect): Ditto. Move to before the fhandler methods. - * include/sys/mman.h: Change prototypes accordingly. - -2003-09-08 Christopher Faylor - - * dcrt0.cc (dlL_crt0_1): Set __argc_safe after __argc is absolutely - know to be set. - * exceptions.cc (sig_handle_tty_stop): Don't reset sigCONT event since - it is reset automatically. - * fork.cc (fork): Remove obsolete usage of PID_SPLIT_HEAP. - * include/sys/cygwin.h: Ditto. - * sigproc.cc (sig_send): Use sigframe init method to set frame since it - checks for previous ownership of the frame. - * sigproc.h (sigframe::init): Accept an "is_exception" argument. - -2003-09-08 Christopher Faylor - - * dir.cc (readdir): Reinstate setting of old ino field for legacy - applications. - * dirent.h (dirent): Rename unused field to __ino32. - -2003-09-08 Christopher Faylor - - * passwd.cc (getpwnam_r): Initialize pw_comment field. - -2003-09-08 Christopher Faylor - - * passwd.cc (getpwuid_r32): Initialize pw_comment field. - -2003-09-08 Christopher Faylor - - * sigproc.cc (wait_sig_inited): Remove assertion since it is racy. - -2003-09-08 Corinna Vinschen - - * cygwin.din: Export endusershell, getusershell and setusershell. - * syscalls.cc (getusershell): New function. - (setusershell): Ditto. - (endusershell): Ditto. - * include/cygwin/version.h: Bump API minor number. - -2003-09-08 Nicholas Wourms - - * cygwin.din: Export argz_add argz_add_sep argz_append argz_count - argz_create argz_create_sep argz_delete argz_extract argz_insert - argz_next argz_replace argz_stringify envz_add envz_entry envz_get - envz_merge envz_remove envz_strip - * include/cygwin/version.h: Bump api minor number. - -2003-09-07 Christopher Faylor - - Throughout, remove __d_u.__d_data fields from DIR structure. - * include/sys/dirent.h (dirent): Remvoe old_d_ino. - (DIR): Make __d_dirhash a 64 bit value. Remove __d_data and __d_u. - Add __flags. - * dir.cc (opendir_states): New enum. - (opendir): Clear new DIR __flags field. - (readdir): Fill in '.' and '..' entries if we hit EOF and we haven't - seen them already. Nuke setting of old_d_ino. - (rewinddir): Reset DIR __flags field. - (seekdir64): Ditto. - * fhandler_disk_file.cc (fhandler_cygdrive::fhandler_cygdrive): Remove - special handling of "." and ".." since they are now handled - automatically. - -2003-09-07 Christopher Faylor - - * include/cygwin/in.h: Don't define ipv6 stuff unless we call for it - specifically since it isn't really implemented yet. - -2003-09-07 Christopher Faylor - - * cygheap.cc (_csbrk): More left coercion cleanup. - * fhandler_tty.cc (fhandler_tty_slave::read): Ditto. - (fhandler_tty_slave::write): Ditto. - * fhandler_windows.cc (fhandler_windows::read): Ditto. - * heap.cc (sbrk): Ditto. - -2003-09-07 Pierre Humblet - - * signal.cc (nanosleep): Improve test for valid values. Round delay up - to resolution. Fix test for negative remainder. Use timeGetTime - through gtod. - (sleep): Round up return value. - -2003-09-07 Pierre Humblet - Christopher Faylor - - * hires.h (HIRES_DELAY_MAX): Define. - (hires_ms::minperiod): Declare static. - (hires_ms::resolution): New. - (hires_ms::dmsecs): New. - (hires_ms::prime): Return UINT. - (gtod): Declare. - * times.cc (hires_ms::prime): Always calculate minperiod and set it to - 1 in case of failure. Return minperiod. - (hires_ms::resolution): Define. - (hires_ms::~hires_ms): Delete. - (hires_ms::usecs): Check minperiod to prime. - (gtod) Define as global. - -2003-09-06 Christopher Faylor - - Remove left coercion throughout. - -2003-09-04 Pierre Humblet - - * hires.h (hires_ms::~hires_ms): Delete declaration. - * times.cc (hires_ms::~hires_ms): Delete definition.. - -2003-09-04 Christopher Faylor - - * dcrt0.cc (__argc_safe): New variable. - (dll_crt0_1): Store argc in __argc_safe, which will theoretically - remain untouched by the user. - * fhandler_console.cc (fhandler_console::read): Silence some compiler - warnings. - * fhandler_raw.cc (fhandler_dev_raw::raw_read): Ditto. - * pinfo.cc (_pinfo::commune_recv): Carefully bound argv scan and check - for potentially bad pointers since user could have set argv cell to - anythinw. - * cygheap.h (CYGHEAPSIZE): Bump up size. - -2003-09-04 Corinna Vinschen - - * sysconf.cc (sysconf): Return more accurate value for _SC_AVPHYS_PAGES. - -2003-09-04 Corinna Vinschen - - * mmap.cc: Restructure. Add, remove and rewrite comments throughout - for better readability. Change function names for better - understanding. - (MAP_SET): Accommodate name change from map_map_ to page_map_. - (MAP_CLR): Ditto. - (MAP_ISSET): Ditto. - (mmap_record::page_map_): Rename from page_map_. - (mmap_record::get_map): Remove. - (mmap_record::alloc_page_map): Rename from alloc_map. Return bool - indicating success of cygheap memory allocation. - (mmap_record::free_page_map): Rename from free_map. - (mmap_record::fixup_page_map): Rename from fixup_map. - (mmap_record::find_unused_pages): Rename from find_empty. - (mmap_record::map_pages): Rename from map_map. - (mmap_record::unmap_pages): Rename from unmap_map. - (class list): Make all class members private. - (list::list): Remove. - (list::~list): Remove. - (list::get_fd): New attribute reader. - (list::get_hash): Ditto. - (list::get_record): Ditto. - (list::add_record): Manage all allocation for mmap_records. Check - for failed memory allocation and return NULL if so. - (list::set): New function. - (list::del_record): Rename from erase. Return true if last mmap_record - has been deleted, false otherwise. Check for legal incoming index - value. - (list::erase): Remove erase/0. - (list::search_record): Rename from match. - (map::map): Remove. - (map::~map): Remove. - (map::add_list): Manage all allocation for lists. Check for failed - memory allocation and return NULL if so. - (map::get_list): New method. - (map::del_list): Rename from erase. Check for legal incoming index - value. - (mmap64): Check for failed mmap_record memory allocation. Return - with MAP_FAILED and errno set to ENOMEM if so. - (munmap): Rearrange loop using new list and mmap_record accessor - functions. Rename loop index variables for better understanding. - Check if list can be deleted after last mmap_record in it has been - deleted. - (msync): Rearrange loop using new list and mmap_record accessor - functions. Rename loop index variables for better understanding. - (fixup_mmaps_after_fork): Ditto. - -2003-09-03 Christopher Faylor - - * cxx.cc (new): Fix formatting. Just return result of ccalloc rather - than calling memset explicitly. - -2003-09-03 Christopher Faylor - - * exceptions.cc (set_process_mask): Set pending signals only when - signals become unmasked. - * sigproc.cc (pending_signals): Flip back to a global. - (wait_sig): Don't set pending signals when there is an armed semaphore - or signal is blocked. - - * shared.cc (shared_info::initialize): Add a username parameter for - user-mode mounts. Reorganize to try to avoid startup race. - (memory_init): Move some stuff into shared_info::initialize. - * shared_info.h (shared_info::initialize): Change declaration. - (CURR_SHARED_MAGIC): Update. - -2003-09-01 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number to 4. - -2003-09-01 Christopher Faylor - - * net.cc (dup_ent): Restore check for NULL input. - -2003-08-31 Christopher Faylor - - * include/sys/cygwin.h: Don't define cygwin-specific things if - !__CYGWIN__. - -2003-08-31 Christopher Faylor - - * cygheap.cc (cygheap_init): Allocate space for sigaction array in - cygheap. - * cygheap.h (cygheap_types): Add HEAP_SIGS. - * exceptions.cc (signal_fixup_after_exec): Remove from this file. - * pinfo.h (pinfo::getsig): Just return global_sigs array. - (pinfo::sigs): Delete. - * sigproc.cc (signal_fixup_after_exec): Move it here. - (global_sigs): New global array, moved from pinfo structure. - (sigalloc): New function. Allocate global sigaction array here. - (proc_subproc): Remove copysigs call. It's automatic now. - * include/sys/cygwin.h (PID_NOCLDSTOP): New value. - * signal.cc (sigaction): Set myself->PID_NODCLDSTOP when appropriate. - * sigproc.h (sigalloc): Declare. - - * fnmatch.c (fnmatch): Use C90 parameters. - (rangematch): Ditto. - - * fhandler.cc (fhandler_base::raw_read): Use right coercion to avoid a - compiler warning. - -2003-08-31 Christopher Faylor - - * net.cc (dup_ent): Make debugging output consistent. - -2003-08-31 Christopher Faylor - - Use dup_ent rather than specific dup_*_ptr functions throughout. - * (gen_ent): Delete. - (dup_ent): Subsume gen_ent functionality. - (dup_host_ptr): Delete. - (dup_proto_ptr): Ditto. - (dup_servent_ptr): Ditto. - -2003-08-31 Christopher Faylor - - * net.cc (gen_ent): Invert sense of null check so that debug output - makes sense. - -2003-08-31 Christopher Faylor - - * net.cc (free_char_list): Delete. - (dup_addr_list): Delete. - (dup_char_list): Delete. - (free_hostent_ptr): Delete. - (free_protoent_ptr): Delete. - (free_servent_ptr): Delete. - (DWORD_round): New function. - (strlen_round): New function. Returns strlen rounded up to word size. - (dup_ent): New, generic function to duplicate a {host,proto,serv}ent - structure. - (gen_ent): New macro. Generates a generic dup_{host,proto,serv}ent_ptr - function. - (cygwin_getservbyname): Remove call to free_servent_ptr, pass - servent_buf to dup_servent_ptr. - (cygwin_getservbyport): Ditto. - (cygwin_gethostbyname): Ditto for hostent. - (cygwin_gethostbyaddr): Ditto. - (cygwin_getprotobyname): Ditto for protoent. - (cygwin_getprotobynumber): Ditto. - -2003-08-31 Christopher Faylor - - * Makefile.in (MALLOC_OFILES): Always fill in with correct malloc - object. - * configure.in: Fill in MALLOC_OFILES with either debugging or regular - malloc. - * configure: Regenerate. - * dlmalloc.c: Make various fruitless changes to attempt to get to work. - * dlmalloc.h: Ditto. - * malloc.cc (free): Check malloc pool when debugging. - - * path.cc (win32_device_name): Eliminate compiler warning. - - * sigproc.cc (sig_dispatch_pending): Remove use of was_pending. Let - thisframe.call_signal_handler decide if handler should be called rather - than using bogus was_pending check. - - * exceptions.cc (interrupt_setup): Remove accidentally checked in - debugging code. - -2003-08-30 Christopher Faylor - - * heap.cc (sbrk): Save rounded address in user_heap_max. - -2003-08-30 Christopher Faylor - - * sigproc.cc (sig_dispatch_pending): Remove explicit call to - thisframe.call_signal_handler. - -2003-08-30 Christopher Faylor - - Remove some cygserver files. - -2003-08-28 Christopher Faylor - - * sigproc.h: Make some functions regparm. - * sigproc.cc (checkstate): Make regparm. - (getevent): Change parameters in declaration, rename from getsem, make regparm. - (sig_send): Recognize that nosync is now an event. Remove some old - cruft from previous interrupt anywhere signal handler. - (getevent): Change parameters in definition, rename from getsem. - Allocate event rather than semaphore. - (wait_sig): Treat sigcatch_nosync as an event. - -2003-08-28 Christopher Faylor - - * exceptions.cc (sigreturn): Fix problem where old return address was - not properly restored for a nested signal. - -2003-08-27 Christopher Faylor - - * autoload.cc (SwitchToThread): Declare as autoload function. - * cygthread.h (cygthread::main_thread_id): Make public. - * exceptions.cc (setup_handler): Remove unneeded priority stuff. - Rename label to reflect what it does. Add debugging for idiotic - Windows NT problem. Change debugging output to include signal number. - * miscfuncs.cc (low_priority_sleep): If available, use SwitchToThread - function to give time slice to other threads. - * wincap.cc: Properly define have_switch_to_thread throughout. - * wincap.h (wincap::switch_to_thread): New element. - -2003-08-27 Christopher Faylor - - * syscalls.cc (mount): Don't check win32_path when doing cygdrive - mount. - -2003-08-27 Christopher Faylor - - * specdir: Correctly remove temporary directory prior to use. - -2003-08-27 Christopher Faylor - - * sigproc.cc (wait_sig): Count number of iterations through - 'more_signals' loop and issue a warning if DEBUGGING and excessive. - (WFSO): When debugging and infinite timeout, loop. - -2003-08-26 Corinna Vinschen - - * include/cygwin/stat.h: Allow definition of internal stat structures - also when compiling newlib. - -2003-08-25 Christopher Faylor - - Throughout, change USE_CYGSERVER to USE_SERVER. - * Makefile.in (LIBSERVER): Define and use. - * configure.in: Set LIBSERVER as appropriate. - * configure: Regenerate. - * acconfig.h: Regenerate. - * environ.cc: Rename allow_daemon to allow_server. Only recognize when - USE_SERVER is defined. - -2003-08-23 Christopher Faylor - - * syscalls.cc (_remove_r): Define. - -2003-08-22 Corinna Vinschen - - * cygheap.h (enum cygheap_types): Add HEAP_MMAP. - (CYGHEAPSIZE): Add another 64K. - * mmap.cc: Use cmalloc, ccalloc and crealloc with HEAP_MMAP type - throughout. - -2003-08-22 Christopher Faylor - - * cygheap.cc (user_heap_info::max): New field. - * heap.cc (heap_init): Save pointer to end of heap reserved memory. - (sbrk): Don't attempt to commit memory beyond end of heap reserved - memory. Attempt to honor comment and reserve commitbytes if heapchunk - fails. - -2003-08-20 Pierre Humblet - - * exceptions.cc (sigreturn): Don't clobber ebp in recursive signal - calls. - -2003-08-22 Christopher Faylor - - * exceptions.cc (sig_handle): Change so that default signals indicate - success. - -2003-08-21 Christopher Faylor - - * sigproc.cc (wait_sig): Remove redundant test in do/while. - -2003-08-21 Christopher Faylor - - * sigproc.cc (wait_sig): Avoid infinite loop. - -2003-08-20 Christopher Faylor - - * speclib: Reenable removal of temp files. - -2003-08-20 Christopher Faylor - - * miscfuncs.cc (low_priority_sleep): Sleep at same priority as main - thread. - * sigproc.cc (wait_sig): Keep looping if there are more signals to - consider and we are flushing signals. - (sig_send): Put nonsync signals in the correct bucket. - -2003-08-20 Christopher Faylor - - * speclib: Fix created lib to avoid "File truncated" problems. - -2003-08-20 Pierre Humblet - - * exceptions.cc (interrupt_setup): Set sigsave.sig last to avoid a - race. - -2003-08-20 Christopher Faylor - - * sigproc.cc (wait_sig): Ensure that myself->getsigtodo array is - flushed on a __SIGFLUSH. - -2003-08-20 Pierre Humblet - Christopher Faylor - - * exceptions.cc (_sigreturn): Handle nested signals without growing the - stack. - -2003-08-19 Christopher Faylor - - * exceptions.cc (pending_signals): Remove unneeded declaration. - * sigproc.cc (pending_signals): Make static. - (wait_sig): Use defined values rather than integers for rc. Never scan - both todo arrays as this could cause hangs if signals arrive from two - different sources. Rename saw_pending_signals to saw_failed_interrupt. - Exit loop when signal found. Enter low-priority sleep, if necessary, - after finished signalling completion. Set pending_signals when blocked - (from Pierre Humblet). - -2003-08-19 Christopher Faylor - - * signal.cc (sigpending): Move. - * sigproc.cc (sigpending): To here. - (getlocal_sigtodo): Return process-local signal array. - (sigpending): Accommodate new process-local signal array. - (sig_send): Ditto. - (sig_set_pending): Ditto. - (wait_sig): Ditto. - -2003-08-19 Christopher Faylor - - Throughout, eliminate argument to sig_dispatch_pending. - * exceptions.cc (setup_handler): Move non-interruptible condition - handling (back) to wait_sig. - (set_process_mask): Don't worry about calling sig_dispatch_pending from - sigthread since it is detected in the function anyway. - (sig_handle): Eliminate thisproc arg. Don't call sig_dispatch_pending - on SIGCONT since that should happen automatically. - * sigproc.cc (sig_dispatch_pending): Eliminate justwake argument. Just - return when called from sigthread. - (wait_sig): Change some variables to bool. Change inner while to an - if. Move uninterruptible signal handling here. - (sigproc_terminate): Don't call sig_dispatch_pending. Just increment - semaphore on exit. - - * speclib: Use slightly different (but still flawed) method for - determining symbols to extract from libraries. - -2003-08-18 Christopher Faylor - - * exceptions.cc (sigdelayed): Fix race where signal handler could get - the wrong mask (as suggested by Pierre Humblet). - -2003-08-18 Christopher Faylor - - * path.cc (mount): Add null/empty check for input parameters. - (umount): Add null/empty check for input parameters. - -2003-08-17 Pierre Humblet - - * grp.cc (read_group): Revert previous change. - * uinfo.cc (pwdgrp::load): Always reset curr_lines. - -2003-08-17 Corinna Vinschen - - * errno.cc (errmap): Map ERROR_INVALID_BLOCK_LENGTH to EIO. - * fhandler_raw.cc (fhandler_dev_raw::raw_read): Set more accurate - errnos instead of EACCES. - (fhandler_dev_raw::raw_write): Ditto. - -2003-08-17 Christopher Faylor - - * path.cc (special_name): Accommodate all special names with - extensions. - -2003-08-15 Corinna Vinschen - - * mmap.cc (mmap64): Avoid crash if file size is less than requested - map length. - -2003-08-13 Igor Pechtchanski - - * path.cc (special_name): Add checks for some specials followed by - a "." and a FIXME comment. - -2003-08-13 Corinna Vinschen - - * cygwin.din: Accommodate change from cygwin_lstat to lstat. - * syscalls.cc: Add defines to avoid declaration issues when - renaming cygwin_lstat back to lstat. - (lstat): Reverted name change from cygwin_lstat. - -2003-08-12 Corinna Vinschen - - * include/sys/param.h (NBBY): Define if not defined. - -2003-08-12 Nicholas Wourms - - * include/sys/param.h (setbit): Add new bitmap related macro. - (clrbit): Likewise. - (isset): Likewise. - (isclr): Likewise. - (howmany): Add new counting/rounding macro. - (rounddown): Likewise. - (roundup): Likewise. - (roundup2): Likewise. - (powerof2): Likewise - (MIN): Add macro for calculating min. - (MAX): Add macro for calculating max. - -2003-08-09 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number to 3. - -2003-08-08 Gerrit P. Haase - - * include/stdint.h: Correctly define INT32_MIN. - -2003-08-08 David Rothenberger - - * grp.cc (read_group): Set __group32.gr_mem pointer back to &null_ptr - after free() is called. - -2003-08-05 Christopher Faylor - - * Makefile.in: Rework to accommodate new speclib arguments. - * speclib: Rework to extract everything from libcygwin.a rather than - building things from existing object files. - -2003-08-05 Pavel Tsekov - - * path.cc (cygdrive_getmntent): Do not skip over drives of type - DRIVE_REMOVABLE. - -2003-08-05 Christopher Faylor - - * fhandler.cc (fhandler_base::lseek): Be more paranoid when - constructing offsets from 64 bit value. - * syscalls.cc (logout): Avoid temp buffer memcpy since new scheme does - not require it. - (utmp_data): Rework as a macro which returns a pointer into a buffer. - (getutent): Use new buffer allocation mechanism to grab a utmp buffer. - (getutid): Ditto. - (pututline): Ditto. - -2003-08-05 Pavel Tsekov - - * fhandler_disk_file.cc (fhandler_cygdrive::readdir): Do not change - 'errno' if end of directory condition is encountered as per SUSv2. - * fhandler_proc.cc (fhandler_proc::readdir): Ditto. - * fhandler_process (fhandler_process::readdir): Ditto. - * fhandler_registry (fhandler_registry::readdir): Ditto. - -2003-07-30 Christopher Faylor - - * dcrt0.cc (_dll_crt0): Move strace.microseconds initialization to - after pthread initialization. - (dll_crt0_1): i.e., here. - -2003-07-28 Christopher Faylor - - * fhandler_base.cc (fhandler_base::readv): Rework to properly return - number of bytes from read. - -2003-07-28 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number to 2. - -2003-07-26 Christopher Faylor - - * exceptions.cc (ctrl_c_handler): Send SIGHUP when events occur only if - there is a tty associated with the process. Send SIGHUP on - CTRL_LOGOFF_EVENT. - - * fhandler_tty.cc (fhandler_tty_slave::open): Adjust console open - handle counter regardless of whether this is a pty or tty. - (fhandler_tty_slave::open): Ditto. - (fhandler_tty_slave::dup): Ditto. - (fhandler_tty_common::set_close_on_exec): Ditto. - (fhandler_tty_master::init_console): Decrement console open handle - counter after init since it will now be handled by all tty open. - * syscalls.cc (setsid): Rework debugging output slightly. - -2003-07-25 Christopher Faylor - - * configure.in: Use 'install-sh -c'. - * configure: Regenerate. - -2003-07-25 Christopher Faylor - - * configure.in: Always use install-sh. - * configure: Regenerate. - -2003-07-25 Christopher Faylor - - * include/cygwin/socket.h: Conditionalize [AP]F_INET6 define. - -2003-07-25 Christopher Faylor - - * Makefile.in (OBSOLETE_FUNCTION): Add fdopen. - -2003-07-25 Christopher Faylor - - * cygwin.din: Export _fdopen64 - * Makefile.in (NEW_FUNCTIONS): Add _fdopen64 -> fdopen translation. - * include/cygwin/version.h: Bump api minor number. - - * ntdll.h: Remove (now) duplicate FILE_SYNCHRONOUS_IO_NONALERT - definition. - -2003-07-24 Christopher Faylor - - * environ.cc (check_case_init): Use strncasematch. - - * cygwin.din: Export __mempcpy. - * cygwin/version.h: Bump api minor number. - -2003-07-21 Pavel Tsekov - - * mmap.cc: Use proper format specifiers for _off64_t and size_t in - format strings passed to syscall_printf () and debug_printf () - throughout. - -2003-07-18 Pierre Humblet - - * security.cc (verify_token): Fix white space and style. - Use type bool instead of BOOL and char. Use alloca - instead of malloc and free for my_grps. - -2003-07-17 Corinna Vinschen - - * sysconf.cc (sysconf): Fix OPEN_MAX patch. Return page size on - _SC_PAGESIZE again. - -2003-07-14 Corinna Vinschen - - * cygheap.h (class cygheap_user): Use INVALID_HANDLE_VALUE as invalid - value for tokens. - * syscalls.cc (seteuid32): Ditto. Set new_token to process token if - process token is suitable. - * uinfo.cc (uinfo_init): Initialize tokens in cygheap user info - to INVALID_HANDLE_VALUE. - -2003-07-14 Pierre Humblet - - * cygheap.h (enum impersonation): Delete. - (cygheap_user::impersonation_state): Delete. - (cygheap_user::current_token): New. - (cygheap_user::issetuid): Modify to use current_token. - (cygheap_user::token): Ditto. - (cygheap_user::deimpersonate): Ditto. - (cygheap_user::reimpersonate): Ditto. - (cygheap_user::has_impersonation_tokens): Ditto. - (cygheap_user::close_impersonation_tokens): Ditto. - * security.cc (cygwin_set_impersonation_token): Always set the token. - (verify_token): Change type of gsid to cygpsid. - (get_file_attribute): Use the effective ids. - * syscalls.cc (seteuid32): Modify to use cygheap_user::current_token. - * uinfo.cc (uinfo_init) Do not set cygheap->user.impersonation_state. - -2003-07-12 Christopher Faylor - - * pinfo.cc (_pinfo::commune_send): Fix bounds test so that poll of - communicating pid actually stops eventually. - -2003-07-10 Christopher Faylor - - * path.cc (get_device_number): Remove special com? consideration. - (special_chars): Make static. - (special_introducers): New. - (special_char): Allow specified valid_chars args. - (fnunmunge): Handle aux-like filenames correctly. - (special_name): Add con, conin$, conout$. - (mount_item::fnmunge): Use __small_sprintf return value to calculate - increments. - -2003-07-09 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number to 1. - -2003-07-09 Christopher Faylor - - * fhandler_proc.cc (format_proc_stat): Use correctly sized constants - for filling in zeros on 98. - -2003-07-09 Christopher Faylor - - * fhandler_proc.cc (fhandler_proc::fill_filebuf): Allocate more space - for stat buffer. - (format_proc_stat): Reorganize to accumulate and report on all cpus. - -2003-07-09 Christopher Faylor - - * sysconf.cc (sysconf): Return processors online rather than bitmask - for _SC_NPROCESSORS_ONLN. - -2003-07-08 Christopher Faylor - - * cygheap.cc (creturn): Set appropriate errno when out of memory. - (ccalloc): Only issue system_printf when debugging. - * dtable.cc (dtable::extend): Only allocate 100 * the incremental growth - size max. Set errno appropriately. - (dtable::build_fhandler): Check for error from set_name. - * fhandler.cc (fhandler_base::set_name): Set errno and return error on OOM. - * fhandler.h (fhandler_base::set_name): Change to bool. - * fhandler_process.cc (format_process_stat): Fix formatting. - * resource.cc (getrlimit): Return greater of OPEN_MAX or fd table size. - * sysconf.cc (sysconf): Ditto. - -2003-07-07 Christopher Faylor - - * rmsym: Don't use ranlib. - -2003-07-07 Christopher Faylor - - * newsym: Reenable removal of tmp directory. Just use ar to generate - archive index. - * Makefile.in: Don't send ranlib to newsym or rmsym. - -2003-07-07 Christopher Faylor - - * newsym: Create objects that are closer to those created by dlltool so - as not to confuse --export-all-symbols. - * rmsym: Be a little more accepting of object filenames now that - dlltool can create different format files. - -2003-07-06 Christopher Faylor - - * newsym: Oops. Revert below change. - -2003-07-06 Christopher Faylor - - * newsym: Use correct prefix for generating imports. - * pinfo.cc (_pinfo::commune_send): Don't wait forever for a response - from another process. - -2003-07-06 Christopher Faylor - - * syscalls.cc (gethostid): Set thread affinity so that results are - predictable. - -2003-07-05 Corinna Vinschen - - * mmap.cc (list::match): Add parameters to return valid address and - length back to munmap(). Evaluate intersection between given - area and mapped area and return it, if any. - (mmap64): On regular files, don't allow mappings beginning beyond - EOF. Return with errno set to ENXIO instead. - (munmap): Rewrite SUSv3 conformant. Check if given memory area is - valid. Unmap all maps inside given memory area. Don't return error - if no mapping has been unmapped. - -2003-07-05 N Stephens - - * fhandler.h (fhandler_socket::get_connect_state): New method to - return socket connection state. - * fhandler_socket.cc (dup): Copy socket connect state to new file - handle. - * net.cc (cygwin_rcmd): Mark file handles of sockets returned by - rcmd() as CONNECTED state. - (cygwin_rexec): Similarly for rexec(). - (socketpair): Mark both ends of a new socket pair as CONNECTED. - -2003-07-04 Corinna Vinschen - - * mmap.cc (fhandler_disk_file::mmap): Fix address test. - -2003-07-03 Christopher Faylor - - * path.cc (fillout_mntent): Change "posix" to "managed". - -2003-07-02 Christopher Faylor - - * fhandler.h (FH_ENC): New enum. - (fhandler_base::get_encoded): New function. - (fhandler_base::set_encoded): Ditto. - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Set encoded flag - in fhandler, as appropriate. - (fhandler_disk_file::readdir): Unmunge filename as appropriate based on - new encoding flag. - * path.cc (normalize_posix_path): Don't punt on files with colons. - (special_char): New function. - (mount_item::fnmunge): Ditto. - (fnunmunge): Ditto. - (special_name): Ditto. - (mount_item::build_win32): Avoid drive considerations when file is - encoded. - (mount_info::conv_to_win32_path): Handle encoded filenames. - (mount_info::conv_to_posix_path): Ditto. - (fillout_mntent): Add posix string when directory is encoded. - * path.h (fnunmunge): Declare. - (path_conv::is_encoded): Declare. - -2003-07-03 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_slave::open): Conditionalize a little - more of the cygserver stuff so that ttys actually work. - -2003-07-03 Corinna Vinschen - - * mmap.cc (mmap64): Allow MAP_FIXED with pagesize granularity (4K). - If a non-zero addr is given, align it to the next lower 64K boundary. - (fhandler_disk_file::mmap): If a non-zero address is given, try - mapping using the given address first. If it fails and flags is not - MAP_FIXED, try again with NULL address. - -2003-07-01 Christopher Faylor - - * thread.cc: Remove _MT_SAFE conditional. - -2003-07-01 Christopher Faylor - - * configure.in: Fix --enable-server option. - * configure: Regenerate. - -2003-07-01 Christopher Faylor - - * Makefile.in: Remove cygserver stuff. - * acconfig.h: Add USE_CYGSERVER define. - * config.h.in: Regenerate. - * configure.in: Add --enable-server setting. - * configure: Regenerate. - * fhandler_tty.cc (fhandler_tty_slave::open): Conditionalize - compilation of cygserver stuff. - * fork.cc (fork_child): Ditto. - * shm.cc: Ditto. - * tty.cc (tty::common_init): Ditto. - - * dcrt0.cc: Use bool rather than BOOL for CYGWIN environment variable - definitions. - * environ.cc: Ditto. - * ntea.cc: Ditto. - * security.cc: Ditto. - * security.h: Ditto. - * syscalls.cc (check_posix_perm): Remove externs that were already - declared in a header. - * winsup.h: Ditto. Declare _MT_SAFE here. Delete it someday since - cygwin should always be _MT_SAFE. - -2003-07-01 Christopher Faylor - - * thread.cc: Remove _MT_SAFE conditional. - -2003-07-01 Christopher Faylor - - * configure.in: Fix --enable-server option. - * configure: Regenerate. - -2003-07-01 Christopher Faylor - - * Makefile.in: Remove cygserver stuff. - * acconfig.h: Add USE_CYGSERVER define. - * config.h.in: Regenerate. - * configure.in: Add --enable-server setting. - * configure: Regenerate. - * fhandler_tty.cc (fhandler_tty_slave::open): Conditionalize - compilation of cygserver stuff. - * fork.cc (fork_child): Ditto. - * shm.cc: Ditto. - * tty.cc (tty::common_init): Ditto. - - * dcrt0.cc: Use bool rather than BOOL for CYGWIN environment variable - definitions. - * environ.cc: Ditto. - * ntea.cc: Ditto. - * security.cc: Ditto. - * security.h: Ditto. - * syscalls.cc (check_posix_perm): Remove externs that were already - declared in a header. - * winsup.h: Ditto. Declare _MT_SAFE here. Delete it someday since - cygwin should always be _MT_SAFE. - -2003-06-30 Pierre Humblet - - * cygheap.h (enum impersonation): New enum. - (cygheap_user::token): Delete. - (cygheap_user::impersonated): Delete. - (cygheap_user::external_token): New member. - (cygheap_user::internal_token): New member. - (cygheap_user::impersonation_state): New member. - (cygheap_user::issetuid): Modify. - (cygheap_user::token): New method. - (cygheap_user::deimpersonate): New method. - (cygheap_user::reimpersonate): New method. - (cygheap_user::has_impersonation_tokens): New method. - (cygheap_user::close_impersonation_tokens): New method. - * dtable.cc (dtable::vfork_child_dup): Use new cygheap_user methods. - * fhandler_socket.cc (fhandler_socket::dup): Ditto. - * fork.cc (fork_child): Ditto. - (fork_parent): Ditto. - * grp.cc (internal_getgroups): Ditto. - * security.cc (verify_token): Ditto. - (check_file_access): Ditto. - (cygwin_set_impersonation_token): Detect conflicts. Set - user.external_token. - * spawn.cc (spawn_guts): Use new cygheap_user methods. - * syscalls.cc (seteuid32): Rearrange to use the two tokens - in cygheap_user. - (setegid32): Use new cygheap_user methods. - * uinfo.cc: (internal_getlogin): Ditto. - -2003-06-25 Doru Carastan - - * Makefile.in: Use INSTALL_PROGRAM to install the cygwin DLL. - -2003-06-24 Thomas Pfaff - - * thread.cc (MTinterface::fixup_after_fork): Fix thread list after - fork. - (pthread::threads): Instantiate. - (pthread::pthread): Initialize running and suspendend. - Initialize next with NULL. - Add thread to thread list if it is not the null_pthread. - (pthread::~pthread): Remove thread from thread list if it is - not the null_pthread. - (pthread::postcreate): Set running flag. - (pthread::exit): Reset running flag. - (pthread::cancel): Try to cancel thread only if still running. - (pthread::_fixup_after_fork): Implement. - (pthread::detach): Check if thread is still running before detach. - * thread.h (pthread::running): New member. - (pthread::next): Ditto. - (pthread::fixup_after_fork): New static method. - (pthread::threads): New static method. - (pthread::_fixup_after_fork): New method. - -2003-06-20 Christopher Faylor - - * pinfo.cc (_pinfo::commune_send): Don't attempt to communicate with a - pure windows process. - -2003-06-18 Pierre Humblet - - * autoload.cc (GetNetworkParams): Add. - * net.cc (getdomainname): Call GetNetworkParams and read the - DhcpDomain registry value if warranted. - -2003-06-17 Christopher Faylor - - * path.cc (mount): Do more strict checking on posix path arguments. - -2003-06-15 Christopher Faylor - - Throughout, remove "include " from files which already include - cygerrno.h. - -2003-06-15 Thomas Pfaff - - * include/cygwin/config.h (__DYNAMIC_REENT__): Define. - * include/cygwin/version.h: Bump API minor version. - * cygwin.din: Export __getreent - * cygerrno.h: Include errno.h. Fix places where _impure_ptr is used - directly to store the errno value. - * debug.cc (__set_errno): Ditto. - * errno.cc: Remove _RRENT_ONLY define to get errno.cc compiled. - * signal.cc: Rename _reent_clib to _REENT throughout. - * thread.h (reent_clib): Remove prototype. - * thread.cc (reent_clib): Rename reent_clib to __getreent. Return - _impure_ptr until MTinterface is initialized. - (reent_winsup): Fix a possible SEGV when _r == NULL. Return NULL - instead. - * MTinterface::fixup_after_fork: Switch reent back to _impure_ptr to - keep signal handling running when fork is called from a thread other - than the mainthread. - -2003-06-12 Thomas Pfaff - - * thread.cc (pthread_attr_init): Revert change from 2003-06-11 - to return 0 if attribute is already initialized back to EBUSY. - (pthread_condattr_init): Ditto. - (pthread_rwlockattr_init): Ditto. - (pthread_mutexattr_init): Ditto. - -2003-06-12 Corinna Vinschen - - * exceptions.cc (ctrl_c_handler): Don't send a signal on - CTRL_SHUTDOWN_EVENT. Add a comment to rationalize the patch. - -2003-06-11 Thomas Pfaff - - * thread.cc (pthread_attr_init): Return 0 if attribute is already - initialized. - Fix return code if out of memory. - (pthread_condattr_init): Ditto. - (pthread_rwlockattr_init): Ditto. - (pthread_mutexattr_init): Return 0 if attribute is already - initialized. - -2003-06-09 Pierre Humblet - - * spawn.cc (spawn_guts): Call CreateProcess while impersonated, - when the real {u,g}ids and the groups are original. - Move RevertToSelf and ImpersonateLoggedOnUser to the main line. - * uinfo.cc (uinfo_init): Reorganize. If CreateProcess was called - while impersonated, preserve the uids and gids and call - ImpersonateLoggedOnUser. Preserve the uids and gids on Win9X. - - * exceptions.cc (error_start_init): Quote the pgm in the command. - -2003-06-07 Christopher Faylor - - * poll.cc: Define FD_SETSIZE to ridiculously large number so that there - will be no artificially small limits. - -2003-06-07 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_slave::close): Free the console when - last tty closes. - -2003-06-07 Thomas Pfaff - - * fhandler_socket.cc (fhandler_socket::connect): Change error - handling for nonblocking connects to return EALREADY when - connect is called more than once for the same socket. - -2003-06-06 Corinna Vinschen - - * cygwin.din: Add vsyslog. - * fhandler.cc (fhandler_base::write): Only make file sparse if the - seeked area is >= 128K. - * syslog.cc (vsyslog): New function, overtaking functionality from - syslog. - (syslog): Just call vsyslog. - * include/cygwin/version.h: Bump API minor. - * include/sys/syslog.h: Add vsyslog declaration. - -2003-06-05 Christopher Faylor - - * cygthread.cc (cygthread::terminate_thread): Change system_printf to - debug_printf. - -2003-06-04 Christopher Faylor - - * shared.cc (shared_info::heap_chunk_size): Be really defensive about - making sure that heap_chunk is set. - -2003-06-04 Christopher Faylor - - * path.cc (conv_path_list): Use correct value when calculating length - to avoid a potential SEGV. - -2003-06-03 Pierre Humblet - - * fhandler_disk_file.cc (fhandler_disk_file::fstat): Mark the pc - as non-executable if the file cannot be opened for read. Retry query - open only if errno is EACCES. Never change the mode, even if it is 000 - when query open() fails. - -2003-06-03 Christopher Faylor - - * configure.in: Allow any i?86 variant. - * configure: Regenerate. - -2003-06-03 Corinna Vinschen - Thomas Pfaff - - * fhandler_socket.cc (connect_thread): Remove. - (accept_thread): Remove. - (fhandler_socket::connect): Remove all special blocking handling. - (fhandler_socket::accept): Ditto. - * net.cc (cygwin_connect): Make blocking sockets temporarily - non-blocking and call cygwin_select on them to be interruptible. - (cygwin_accept): Ditto. - -2003-06-02 Christopher Faylor - - * spawn.cc (spawn_guts): Don't hang around if the parent doesn't exist. - -2003-06-02 Christopher Faylor - - * cygthread.h (cygthread::terminate_thread): Mark private. - * cygthread.cc (cygthread::terminate_thread): Deallocate free_range - thread stuff. - -2003-06-02 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::accept): Rename `signalled' - to `interrupted' as used in fhandler_socket::connect. - -2003-06-02 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::connect): Simplify previous - patch. - (fhandler_socket::accept): Ditto. - -2003-06-02 Corinna Vinschen - - * fhandler_socket.cc: Include cygthread.h. - (class sock_event): Remove. - (thread_connect): New function. - (thread_accept): Ditto. - (fhandler_socket::connect): Use cygthread instead of socket event - handling for blocking sockets. - (fhandler_socket::accept): Ditto. - -2003-06-02 Christopher Faylor - - * fhandler.cc (fhandler_base::write): Correct minor printf formatting - style glitch. - -2003-06-01 Pierre Humblet - - * fhandler_disk_file.cc (fhandler_disk_file::fstat_by_name): Assume - an existing directory is a root if FindFirstFile fails. - -2003-05-30 Christopher Faylor - - * path.cc (mount_info::conv_to_win32_path): gcc warning about chroot_ok - was actually valid. Fix it. - -2003-05-30 Christopher Faylor - - * cygheap.cc (init_cheap): Temporarily remove inline that newer gcc's - have problems with. - - * path.cc (path_conv::check): Rework has_acls logic slightly. Uncouple - exec tests away from filesystem tests. - -2003-05-30 Corinna Vinschen - - * include/sys/param.h: Add DEV_BSIZE. - -2003-05-29 Pierre Humblet - Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::dup): Rearrange. Fix - conditional. - -2003-05-28 Christopher Faylor - - * mkvers.sh: Avoid "-dontuse" tags. - - * path.cc (path_conv::check): Set exec state based on known situations. - - * path.cc (mount_item::fnmunge): New function. - (mount_item::build_win32): New function. - (mount_info::conv_to_win32_path): Use build_win32 to build windows - path. - * path.h (mount_item::fnmunge): Declare new function. - (mount_item::build_win32): Ditto. - * sys/mount.h (MOUNT_ENC): Define. - -2003-05-28 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::dup): If running impersonated, - revert to original account before calling fixup_before_fork_exec - and impersonate again afterwards. Change comment accordingly. - Clean up error handling and debug output. - -2003-05-27 Thomas Pfaff - - * fhandler_socket.cc (sock_event::~sock_event): New method. - (sock_event::load): Change to void. Check if winsock2 is available. - (socke_event::wait): Return 0 if interruptible mode is not available. - (fhandler_socket::connect): Remove checks for winsock2 availability. - (fhandler_socket::accept): Ditto. - -2003-05-27 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::dup): First try duplicating - using WSADuplicateSocket/WSASocket, if that fails, try DuplicateHandle. - -2003-05-27 Bill C. Riemers - - * fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): Filter - permissions through umask on FAT or if ntsec is off. - -2003-05-26 Pierre Humblet - - * syscalls.cc (statfs): Call GetDiskFreeSpaceEx before GetDiskFreeSpace. - -2003-05-26 Corinna Vinschen - - * fhandler.cc (is_at_eof): Fix conditional. Use INVALID_FILE_SIZE - instead of numeric constant. - -2003-05-26 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::connect): Guard calls to - sock_event methods by a check for WinSock2 availability. - (fhandler_socket::accept): Ditto. - -2003-05-26 Corinna Vinschen - - * fhandler.h: Rename FH_W95LSBUG flag to FH_LSEEKED. - (fhandler_base::set_did_lseek): Rename from set_check_win95_lseek_bug. - (fhandler_base::get_did_lseek): Rename from get_check_win95_lseek_bug. - (fhandler_base::set_fs_flags): New method. - (fhandler_base::get_fs_flags): Ditto. - * fhandler.cc (fhandler_base::write): Make 64 bit clean. Convert file - to a "sparse" file when writing after a long lseek (>64K) beyond EOF. - (fhandler_base::lseek): Call set_did_lseek() instead of - set_check_win95_lseek_bug(). - (fhandler_base::fhandler_base): Initialize fs_flags to 0. - * fhandler_disk_file.cc (fhandler_disk_file::open): Don't create files - as "sparse" unconditionally. Set fs_flags member. - -2003-05-25 Pierre Humblet - - * autoload.cc (GetDiskFreeSpaceEx): Add. - * syscalls.cc (statfs): Call full_path.root_dir() instead of - rootdir(full_path). Use GetDiskFreeSpaceEx when available and - report space available in addition to free space. - * fhandler_disk_file.cc (fhandler_disk_file::fstat_by_name): - Do not call FindFirstFile for disk root directories. - -2003-05-24 Joe Buehler - - * fhandler_process.cc (format_process_stat): Use PagefileUsage - instead of VirtualSize. - (get_mem_values): Ditto. - -2003-05-21 Corinna Vinschen - - * shared_info.h: Match shared_name declaration with below change. - * shared.cc (shared_name): Use incoming char * parameter instead of - local static buffer. - (open_shared): Accommodate new calling convention for shared_name. - * exceptions.cc (events_init): Ditto. - * sigproc.cc (getsem): Ditto. - * syscalls.cc (login): Ditto. - (logout): Ditto. - (pututline): Ditto. - -2003-05-20 Corinna Vinschen - - * fhandler_socket.cc (secret_event_name): Return void. Use incoming - char * parameter instead of local static buffer. - (fhandler_socket::create_secret_event): Accommodate new calling - convention for secret_event_name. - (fhandler_socket::close_secret_event): Ditto. - -2003-05-20 Corinna Vinschen - - * fhandler_socket.cc (SECRET_EVENT_NAME): Remove. - (ENTROPY_SOURCE_NAME): Ditto. - (secret_event_name): New static function. Create shared event name - with "Global\" prefix on systems supporting terminal services. - (fhandler_socket::set_connect_secret): Fix conditional. - (fhandler_socket::create_secret_event): Create secret event using - secret_event_name(). - (fhandler_socket::close_secret_event): Ditto. - * shared.cc (shared_name): Create shared object name with "Global\" - prefix on systems supporting terminal services. - * wincap.cc: Set has_terminal_services capability throughout. - (wincap_2003): New global object representing Windows 2003 Server - capabilities. - (wincapc::init): Accommodate Windows 2003 Server. - * wincap.h (struct wincaps): Add has_terminal_services capability. - -2003-05-20 Charles Wilson - - * winsup/cygwin/include/cygwin/version.h: Bump API minor version. - * winsup/cygwin/include/cygwin/types.h: Define key_t as long long. - * winsup/cygwin/cygwin.din: Add ftok, _ftok. - * winsup/cygwin/ipc.cc (ftok): Rework implementation. - -2003-05-18 Joe Buehler - - * spawn.cc (spawn_guts): Show more of command line in strace output. - -2003-05-15 Thomas Pfaff - - * thread.h (pthread::init_mainthread): Remove function parameter. - (MTinterface::Init): Ditto. - * thread.cc (MTinterface::Init): Remove function parameter. - Always initialize reent_key. - (pthread::init_mainthread): Remove function parameter. - (MTinterface::fixup_after_fork): Fix pthread::init_mainthread call. - * dcrt0.cc (dll_crt_0_1) Fix calls to MTinterface::Init and - pthread::init_mainthread. - Call pthread::init_mainthread only when not forked. - -2003-05-15 Corinna Vinschen - - * fhandler_proc.cc (format_proc_meminfo): Make swap memory output - Linux style values. - -2003-05-13 Corinna Vinschen - - * include/cygwin/config.h: Define __USE_INTERNAL_STAT64 appropriately. - -2003-05-12 Corinna Vinschen - - * Makefile.in (CYGWIN_START): Define as crt0.o. Add to TARGET_LIBS. - * fhandler.h (fhandler_virtual::fstat): Remove useless declaration. - * fhandler_virtual.cc: Remove _COMPILING_NEWLIB define. - * ipc.cc (ftok): Use stat64. - * syscalls.cc (_fstat64): Remove alias. - (_fstat): Ditto. - (_stat): Ditto. - (_fstat64_r): New function. - (_fstat_r): Ditto. - (_stat64_r): Ditto. - (stat_r): Ditto. - * crt0.o: New file, moved from newlib. - * include/sys/param.h: Ditto. - * include/sys/utime.h: Ditto. - * include/sys/utmp.h: Ditto. - * include/sys/dirent.h: Ditto. Expose different struct dirent, - dependening of the environment. - -2003-05-11 Corinna Vinschen - - Replace ino_t by __ino64_t throughout. - -2003-05-11 Corinna Vinschen - - * include/cygwin/types.h: Add key_t typedef. - -2003-05-10 Christopher Faylor - - * dir.cc (readdir): Fill out new old_d_ino field. - * fhandler.h (fhandler_base::namehash): Define as ino_t. - (fhandler_base::get_namehash): Ditto. - * fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): Accommodate - new 64 bit st_ino. - * fhandler_socket.cc (fhandler_socket::fstat): Ditto. - * path.cc (hash_path_name): Return ino_t. - * syscalls.cc (stat64_to_stat32): Convert 64 bit inode to 32 bit. - * winsup.h (hash_path_name): Declare as returning ino_t. - * include/cygwin/stat.h (__stat32): Use 32 bit st_ino. - (__stat64): Use 64 bit st_ino. - * include/cygwin/types.h (__ino64_t): Define. - (__ino32_t): Ditto. - (ino_t): Define appropriately. - -2003-05-10 Corinna Vinschen - - * Makefile.in (NEW_FUNCTIONS): All 32/64 from 0.79 API get - leading underscore. - * cygwin.din: Ditto. - * include/cygwin/version.h: Bump API minor number. - -2003-05-09 Corinna Vinschen - - * include/cygwin/config.h: New file. - -2003-05-09 Christopher Faylor - - * cygthread.cc (cygthread::detach): Prioritize waiting for I/O - completion over waiting for signal delivery. - -2003-05-06 Thomas Pfaff - - * signal.cc (nanosleep): Do not wait twice for signal arrival. - -2003-05-03 Corinna Vinschen - - * include/cygwin/types.h: Fix erroneous definition of ino_t from - 2003-04-28. - -2003-05-03 Corinna Vinschen - - * syscalls.cc (chown_worker): Allow chown'ing of socket files. - -2003-04-30 Thomas Pfaff - - * Makefile.in: Revert patch from 2003-04-17. - -2003-04-28 Brian Ford - - * profil.h (PROFADDR): Prevent overflow when text segments are larger - than 256k. - * profil.c (profthr_func): Raise thread priority for more accurate - sampling. - -2003-04-26 Christopher Faylor - - * path.cc (hash_path_name): Use ino_t as type. - -2003-04-26 Christopher Faylor - - * errno.cc (_sys_nerr): Fix compile error erroneously checked in on - 2003-04-23. - -2003-04-25 Corinna Vinschen - - * include/netinet/ip.h: Include netinet/in_systm.h and netinet/in.h - to allow standalone usage (autoconf). - -2003-04-23 Christopher Faylor - - * fork.cc: Change SLOW_PID_REUSE to NO_SLOW_PID_REUSE and invert ifdef - sense throughout. - -2003-04-22 Christopher Faylor - - * select.cc (fhandler_pipe::ready_for_read): Assure that get_guard is - called for successful non-blocking pipe reads. - -2003-04-22 Corinna Vinschen - - * include/inttypes.h: New file. - * include/stdint.h: New file. - * include/cygwin/in.h: Include stdint.h instead of sys/types.h. - * include/cygwin/types.h: Include stdint.h. Remove typedefs for - intN_t and uintN_t since these are defined in stdint.h now. - -2003-04-21 Christopher Faylor - - * include/cygwin/version.h: Bump DLL major number to 1005. Change DLL - minor number to 0. Bump API minor number. - -2003-04-20 Corinna Vinschen - - * autoload.cc (CreateWindowStationA): Add. - (SetProcessWindowStation): Add. - -2003-04-19 Christopher Faylor - - * wincap.h (wincaps:pty_needs_alloc_console): New element. - (wincapc:pty_needs_alloc_console): New function. - * wincap.cc: Add pty_needs_alloc_console throughout. - * fhandler_tty.cc (fhandler_tty_slave::open): Open an "invisible" - console on first pty allocation. - -2003-04-18 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_slave::open): Allocate a console - whenever a pty is allocated. - -2003-04-18 Christopher Faylor - - * Makefile.in: Use ${nostdlib} variable. - -2003-04-18 Diego Biurrun - - * fhandler_proc.cc (format_proc_cpuinfo): Change /proc/cpuinfo "vendor - id" string to "vendor_id" to conform with Linux systems. - -2003-04-17 Christopher Faylor - - * syscalls.cc (setsid): Don't call FreeConsole if ctty is already < 0. - -2003-04-17 Thomas Pfaff - - * Makefile.in: Add finline-functions optimization to CXXFLAGS. - * autoload.cc (LoadDLLprime): Rename std_dll_init to - _std_dll_init. - (std_dll_init): Remove name mangling prototype. Add attributes - used and noinline. - (wsock_init): Ditto. - Change wsock_init to _wsock_init in wsock32 and ws2_32 - LoadDLLprime. - * exceptions.cc (unused_sig_wrapper): Remove prototype. Add - attributes used and noinline. - * pwdgrp.h ((pwdgrp (passwd *&)): Remove inline code. - (pwdgrp (__group32 *&)): Ditto. - * grp.cc (pwdgrp (passwd *&)): Outline constructor. - (pwdgrp (__group32 *&)): Ditto. - -2003-04-17 Thomas Pfaff - - * thread.h (pthread::equal): New static method. - * thread.cc: Rename pthread_equal to pthread::equal throughout. - (pthread_equal): Use pthread::equal to compare threads ids. - -2003-04-15 Christopher Faylor - - * termios.cc (setspeed): New function. - (cfsetospeed): Use setspeed to set speed. - (cfsetispeed): Use setspeed to set speed. - -2003-04-15 Chris January - - * autoload.cc: Add load statement for UuidCreate, and - UuidCreateSequential. - * cpuid.h: New file. - * cygwin.din: Export gethostid. - * fhandler_proc.cc (cpuid): Move to cpuid.h. - (can_set_flag): Move to cpuid.h. - * syscalls.cc (gethostid): New function. - * version.h: Bump api minor version number to 83. - -2003-04-15 Thomas Pfaff - - * thread.h (pthread_rwlock::release): New method. - * thread.cc (pthread_rwlock::unlock): Use release to signal waiting - threads. - (pthread_rwlock::rdlock_cleanup): Signal waiting threads after a - cancelation. - (pthread_rwlock::wrlock_cleanup): Ditto. - -2003-04-13 Pierre Humblet - - * mkvers.sh: Prefix day with 0 in date only when day < 10. - -2003-04-11 Pierre Humblet - - * security.cc (get_info_from_sd): New function. - (get_nt_attribute): Only call read_sd and get_info_from_sd. - Return void. - (get_file_attribute): Move sd error handling to get_info_from_sd. - and symlink handling to fhandler_disk_file::fstat_helper. - (get_nt_object_attribute): Only call read_sd and get_info_from_sd. - Return void. - (get_object_attribute): Remove symlink handling and simply return -1 - when ntsec is off. - * fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): For - symlinks set the attribute, call get_file_attribute to get the ids - and return. In the normal case call get_file_attribute with the - addresses of the buffer ids and do not recheck if the file is a socket. - -2003-04-10 Christopher Faylor - - * cygthread.cc (cygthread::stub): Initialize stack pointer earlier. - (cygthread::simplestub): Initialize stack pointer. - (cygthread::terminate_thread): Account for possibility that stack - pointer has not been set. Issue warnings for unusual conditions. - -2003-04-10 Corinna Vinschen - - * regex/regex.h: Define regoff_t as _off_t. - * regex/regex2.h: Ditto. - -2003-04-10 Corinna Vinschen - - * cygwin.din: Export wcscoll, wcswidth and wcwidth. - * include/cygwin/version.h: Bump API minor number. - -2003-04-10 Christopher Faylor - - * cygthread.h: Change 'avail' cygthread element to 'inuse' throughout. - * cygthread.cc: Ditto. - (cygthread::stub): Don't initialize already initialized events. - (cygthread::freerange): Don't create thread here. - (cygthread::cygthread): Create thread here. Die if thread not created. - (cygthread::operator new): Simplify. Just grab a thread structure from - the pool. Don't try to start the thread. - (cygthread::terminate_thread): Don't close event handles. Just reuse - them. Call MEM_RELEASE rather than MEM_DECOMMIT (from Joe uehler). - -2003-04-08 Bob Cassels - - * fhandler_console.cc (fhandler_console::read) Handle certain key up - events, to allow pasting accented characters and typing them using the - "alt + numerics" sequences. - -2003-04-07 Christopher Faylor - - * include/limits.h (IOV_MAX): Set to a number which is small enough to - use in an array. - -2003-04-04 Christopher Faylor - - * cygthread.h (cygthread::avail): Make LONG for easier use with - Interlocked* functions. - * cygthread.cc (cygthread::init): Eliminate unneeded muto. - (cygthread::operator new): Don't lock. Instead change use of avail - variable into tri-state: available (1), not available (-1), - uninitialized (0). - (cygthread::terminate_thread): Set avail to uninitialized. - (cygthread::detach): Eliminate local 'avail'. Always set avail to 1 - unless signalled. - -2003-04-04 Christopher Faylor - - * cygthread.cc (cygthread::operator new): Be more defensive when messing with - threads that are marked "unavailable". - -2003-04-03 Christopher Faylor - - * fhandler_console.cc (CONVERT_LIMIT): Use a size for the 21st century. - -2003-04-03 Corinna Vinschen - - * external.cc (check_ntsec): Return general ntsec state on NULL - filename. Check wincap.is_security() additionally. - -2003-04-02 Christopher Faylor - - * Makefile.in (EXTRA_OFILES): Remove debugging object. - -2003-04-02 Jason Tishler - Christopher Faylor - - * external.cc (check_ntsec): New function. - (cygwin_internal): Add CW_CHECK_NTSEC handling to call check_ntsec() - from applications. - * include/cygwin/version.h: Bump API minor number. - * include/sys/cygwin.h (cygwin_getinfo_types): Add CW_CHECK_NTSEC. - -2003-04-02 Christopher Faylor - - * cygthread.cc (cygthread::new): Add more defensive debugging. - -2003-04-01 Pierre Humblet - - * fhandler.cc (fhandler_base::fstat): Set the uid and gid fields - from the current effective ids. - * fhandler_socket.cc (fhandler_socket::fstat): Keep the uid and gid set - by fhandler_base::fstat. - * security.cc (get_nt_attribute): Do not test wincap.has_security (). - (get_nt_object_attribute): Ditto. - (get_file_attribute): Add test for wincap.has_security (). - (get_object_attribute): Ditto. - -2003-04-01 Corinna Vinschen - - * dir.cc: Change __off32_t to _off_t and __off64_t to _off64_t - throughout. - * fhandler.cc: Ditto. - * fhandler.h: Ditto. - * fhandler_clipboard.cc: Ditto. - * fhandler_disk_file.cc: Ditto. - * fhandler_dsp.cc: Ditto. - * fhandler_floppy.cc: Ditto. - * fhandler_mem.cc: Ditto. - * fhandler_proc.cc: Ditto. - * fhandler_process.cc: Ditto. - * fhandler_random.cc: Ditto. - * fhandler_registry.cc: Ditto. - * fhandler_tape.cc: Ditto. - * fhandler_termios.cc: Ditto. - * fhandler_virtual.cc: Ditto. - * fhandler_zero.cc: Ditto. - * mmap.cc: Ditto. - * pipe.cc: Ditto. - * syscalls.cc: Ditto. - * winsup.h: Ditto. - * include/cygwin/stat.h: Ditto. - * include/cygwin/types.h: Ditto. Remove definition of __off32_t - and __off64_t. - -2003-03-31 Christopher Faylor - - * exceptions.cc (setup_handler): Make sure winapi lock is released when - exiting loop. - -2003-03-30 Christopher Faylor - - * include/cygwin/fs.h: Remove unneeded include. - * include/cygwin/in.h: Include sys/types.h rather than cygwin/types.h. - -2003-03-29 Corinna Vinschen - - * syscalls.cc (login): Fix comment. - (logout): Ditto. - -2003-03-29 Corinna Vinschen - - * syscalls.cc: Slightly cleanup all utmp functions. - (login): Use mutex to secure against concurrent access to wtmp file. - (logout): Rewrite using POSIX calls. - (utmp_fd): Initialized to -1 now. Any value < 0 is treated as closed - in subsequent functions. - (utmp_readonly): New variable, indicating utmp file open for reading - only. - (internal_setutent): New function implementing setutent(). - (setutent): Call internal_setutent now. - (endutent): Reset utmp_readonly. - (getutent): Return immediately if utmp file can't be opened. - (getutid): Ditto. - (getutline): Ditto. - (pututline): Ditto. Use mutex to secure against concurrent access to - utmp file. - -2003-03-28 Christopher Faylor - - * Makefile.in: Remove EXE_LDFLAGS. Fix fhandler_CFLAGS typo. Recognize .s suffix. - * configure.in: Remove EXE_LDFLAGS. - * configure: Regenerate. - -2003-03-28 Christopher Faylor - - * include/sys/cygwin.h: Declare cygwin_internal as unsigned long. - * external.cc (cygwin_internal): Define as unsigned long. - -2003-03-27 Christopher Faylor - - * include/sys/cygwin.h: Move cygwin_internal outside of WINVER - conditional. - -2003-03-27 Thomas Pfaff - - * thread.cc: Change 1==foo equations to foo==1 throughout. - -2003-03-27 Thomas Pfaff - - * thread.h: Change class names, methods, members and local vars - according to the GNU coding style. - * thread.cc: Ditto. - * dcrt0.cc (dll_crt0_1): Rename pthread::initMainThread call to - pthread::init_mainthread. - * pthread.cc (pthead_getsequence_np): Rename pthread::isGoodObject - call to pthread::is_good_object. - -2003-03-27 Joe Buehler - - * autoload.cc: Add RegGetKeySecurity(). - * security.cc (get_nt_object_attribute): Use RegGetKeySecurity() for - performance. - -2003-03-25 Christopher Faylor - Joe Buehler - - * fork.cc (fork_parent): Don't copy signals from parent to child here. - * sigproc.cc (proc_subproc): Copy signals from parent to child pinfo - here. - -2003-03-23 Thomas Pfaff - - * thread.h (class List): Move inline code inside class declaration. - (List::forEach): Change callback parameter to template class member - function pointer. - (pthread_keys::fixup_before_fork): Change to inline. Use List::forEach - to fixup keys. - (pthread_keys::fixup_after_fork): Ditto. - (pthread_keys::runAllDestructors): Ditto. - (pthread_key::saveAKey): Remove. - (pthread_key::restoreAKey): Ditto. - (pthread_key::destroyAKey): Ditto. - (pthread_key::run_destructor): Rename to runDestructor. - (pthread_mutex::fixup_after_fork): Change to inline. Use List::forEach - to fixup mutexes after a fork. - (pthread_mutex::FixupAfterFork): New method. - (pthread_mutex::mutexes): New member. - (pthread_cond::fixup_after_fork): Change to inline. Use List::forEach - to fixup conds after a fork. - (pthread_cond::FixupAfterFork): New method. - (pthread_cond::conds): New member. - (pthread_rwlock::fixup_after_fork): Change to inline. Use - List::forEach to fixup rwlocks after a fork. - (pthread_rwlock::FixupAfterFork): New method. - (pthread_rwlock::rwlocks): New member. - (semaphore::fixup_after_fork): Change to inline. Use List::forEach to - fixup mutexes after a fork. - (semaphore::FixupAfterFork): New method. - (semaphore::semaphores): New member. - (MTinterface::mutexs): Remove. - (MTinterface::conds): Ditto. - (MTinterface::rwlocks): Ditto. - (MTinterface::semaphores): Ditto. - (pthread_equal): Add extern "C". - (pthread_mutex_lock): Ditto. - - * thread.cc (MTinterface::fixup_after_fork): Change fixup_after_fork - calls for pthread objects. - (semaphore::conds): Instantiate. - (pthread_cond::pthread_cond): Use List::Insert rather than custom list - code. - (pthread_cond::~pthread_cond): Use List::Remove rather than custom list - code. - (pthread_cond::fixup_after_fork): Rename to FixupAfterFork. - (pthread_rwlock::rwlocks): Instantiate. - (pthread_rwlock::pthread_crwlock): Use List::Insert rather than custom - list code. - (pthread_rwlock::~pthread_rwlock): Use List::Remove rather than custom - list code. - (pthread_rwlock::fixup_after_fork): Rename to FixupAfterFork. - (pthread_key::saveAKey): Remove. - (pthread_key::fixup_before_fork): Ditto. - (pthread_key::restoreAKey): Ditto. - (pthread_key::fixup_after_fork): Ditto. - (pthread_key::destroyAKey): Ditto. - (pthread_key::runAllDestructors): Ditto. - (pthread_key::run_destructor): Rename to runDestructor. - (pthread_mutex::mutexes): Instantiate. - (pthread_mutex::pthread_mutex): Use List::Insert rather than custom - list code. - (pthread_mutex::~pthread_mutex): Use List::Remove rather than custom - list code. - (pthread_mutex::fixup_after_fork): Rename to FixupAfterFork. - (semaphore::conds): Instantiate. - (semaphore::semaphore): Use List::Insert rather than custom list code. - (semaphores::~semaphore): Use List::Remove rather than custom list - code. - (semaphore::fixup_after_fork): Rename to FixupAfterFork. - -2003-03-22 Christopher Faylor - - * pipe.cc (fhandler_pipe::dup): Don't dup input_handle if it doesn't - exist. - -2003-03-22 Christopher Faylor - - * syscalls.cc (unlink): Be more defensive when SetFileAttributes is - called. Fix typo in debugging output. - -2003-03-21 Christopher Faylor - - * fork.cc: Conditionalize use of slow_pid_reuse throughout. It's not - necessary for newer versions of bash. - -2003-03-20 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::sendto): Restrict EPIPE and - SIGPIPE handling to connection oriented sockets. Add comment. - -2003-03-19 Christopher Faylor - - * sigproc.h (signal_fixup_after_exec): Eliminate argument in declaration. - * exceptions.cc (signal_fixup_after_exec): Eliminate argument in - definition. Don't reset signal handlers after spawm. Just treat like - fork/exec. - * dcrt0.cc (dll_crt0_1): Don't pass PROC_SPAWN argument to - signal_fixup_after_exec. - * syscalls.cc (unlink): Don't change attributes of file if not readonly/system. - Ditto for resetting of arguments. - -2003-03-19 Corinna Vinschen - - * glob.c: Eliminate __INSIDE_CYGWIN__ preprocessor conditionals - throughout. - -2003-03-19 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): Fix - wrong usage of S_IFDIR. - * security.cc (get_attribute_from_acl): Ditto. - (get_file_attribute): Fix wrong usage of S_IFLNK. - (get_object_attribute): Ditto. - (alloc_sd): Fix wrong usage of S_IFDIR. - * syscalls.cc (chmod): Allow chmod'ing of socket files. - -2003-03-19 Corinna Vinschen - - * include/cygwin/version.h (CYGWIN_VERSION_CHECK_FOR_USING_BIG_TYPES): - Define. - * glob.c (g_lstat): Use CYGWIN_VERSION_CHECK_FOR_USING_BIG_TYPES - instead of numerical constants. - (g_stat): Ditto. - -2003-03-18 Thomas Pfaff - - * pthread.cc (pthread_attr_init): Remove - (pthread_attr_destroy): Ditto. - (pthread_attr_setdetachstate): Ditto. - (pthread_attr_getdetachstate): Ditto. - (pthread_attr_setstacksize): Ditto. - (pthread_attr_getstacksize): Ditto. - (pthread_attr_setinheritsched): Ditto. - (pthread_attr_getinheritsched): Ditto. - (pthread_attr_setschedparam): Ditto. - (pthread_attr_getschedparam): Ditto. - (pthread_attr_setschedpolicy): Ditto. - (pthread_attr_getschedpolicy): Ditto. - (pthread_attr_setscope): Ditto. - (pthread_attr_getscope): Ditto. - (pthread_attr_setstackaddr): Ditto. - (pthread_attr_getstackaddr): Ditto. - (pthread_key_create): Ditto. - (pthread_key_delete): Ditto. - (pthread_setspecific): Ditto. - (pthread_getspecific): Ditto. - (pthread_kill): Ditto. - (pthread_sigmask): Ditto. - (pthread_equal): Ditto. - (pthread_mutex_lock): Ditto. - (pthread_mutex_trylock): Ditto. - (pthread_mutex_unlock): Ditto. - (pthread_mutex_destroy): Ditto. - (pthread_mutex_setprioceiling): Ditto. - (pthread_mutex_getprioceiling): Ditto. - (pthread_mutexattr_destroy): Ditto. - (pthread_mutexattr_getprioceiling): Ditto. - (pthread_mutexattr_getprotocol): Ditto. - (pthread_mutexattr_getpshared): Ditto. - (pthread_mutexattr_gettype): Ditto. - (pthread_mutexattr_init): Ditto. - (pthread_mutexattr_setprioceiling): Ditto. - (pthread_mutexattr_setprotocol): Ditto. - (pthread_mutexattr_setpshared): Ditto. - (pthread_mutexattr_settype): Ditto. - (pthread_cond_destroy): Ditto. - (pthread_cond_signal): Ditto. - (pthread_cond_broadcast): Ditto. - (pthread_condattr_init): Ditto. - (pthread_condattr_destroy): Ditto. - (pthread_condattr_getpshared): Ditto. - (pthread_condattr_setpshared): Ditto. - (pthread_rwlock_destroy): Ditto. - (pthread_rwlock_rdlock): Ditto. - (pthread_rwlock_tryrdlock): Ditto. - (pthread_rwlock_wrlock): Ditto. - (pthread_rwlock_trywrlock): Ditto. - (pthread_rwlock_unlock): Ditto. - (pthread_rwlockattr_init): Ditto. - (pthread_rwlockattr_getpshared): Ditto. - (pthread_rwlockattr_setpshared): Ditto. - (pthread_rwlockattr_destroy): Ditto. - (pthread_getconcurrency): Ditto. - (pthread_setconcurrency): Ditto. - (pthread_getschedparam): Ditto. - (pthread_setschedparam): Ditto. - - * thread.h (__pthread_attr_init): Remove prototype. - (__pthread_attr_destroy): Ditto. - (__pthread_attr_setdetachstate): Ditto. - (__pthread_attr_getdetachstate): Ditto. - (__pthread_attr_setstacksize): Ditto. - (__pthread_attr_getstacksize): Ditto. - (__pthread_attr_setinheritsched): Ditto. - (__pthread_attr_getinheritsched): Ditto. - (__pthread_attr_setschedparam): Ditto. - (__pthread_attr_getschedparam): Ditto. - (__pthread_attr_setschedpolicy): Ditto. - (__pthread_attr_getschedpolicy): Ditto. - (__pthread_attr_setscope): Ditto. - (__pthread_attr_getscope): Ditto. - (__pthread_attr_setstackaddr): Ditto. - (__pthread_attr_getstackaddr): Ditto. - (__pthread_key_create): Ditto. - (__pthread_key_delete): Ditto. - (__pthread_setspecific): Ditto. - (__pthread_getspecific): Ditto. - (__pthread_kill): Ditto. - (__pthread_sigmask): Ditto. - (__pthread_equal): Ditto. - (__pthread_mutex_lock): Ditto. - (__pthread_mutex_trylock): Ditto. - (__pthread_mutex_unlock): Ditto. - (__pthread_mutex_destroy): Ditto. - (__pthread_mutex_setprioceiling): Ditto. - (__pthread_mutex_getprioceiling): Ditto. - (__pthread_mutexattr_destroy): Ditto. - (__pthread_mutexattr_getprioceiling): Ditto. - (__pthread_mutexattr_getprotocol): Ditto. - (__pthread_mutexattr_getpshared): Ditto. - (__pthread_mutexattr_gettype): Ditto. - (__pthread_mutexattr_init): Ditto. - (__pthread_mutexattr_setprioceiling): Ditto. - (__pthread_mutexattr_setprotocol): Ditto. - (__pthread_mutexattr_setpshared): Ditto. - (__pthread_mutexattr_settype): Ditto. - (__pthread_cond_destroy): Ditto. - (__pthread_cond_signal): Ditto. - (__pthread_cond_broadcast): Ditto. - (__pthread_condattr_init): Ditto. - (__pthread_condattr_destroy): Ditto. - (__pthread_condattr_getpshared): Ditto. - (__pthread_condattr_setpshared): Ditto. - (__pthread_rwlock_destroy): Ditto. - (__pthread_rwlock_rdlock): Ditto. - (__pthread_rwlock_tryrdlock): Ditto. - (__pthread_rwlock_wrlock): Ditto. - (__pthread_rwlock_trywrlock): Ditto. - (__pthread_rwlock_unlock): Ditto. - (__pthread_rwlockattr_init): Ditto. - (__pthread_rwlockattr_getpshared): Ditto. - (__pthread_rwlockattr_setpshared): Ditto. - (__pthread_rwlockattr_destroy): Ditto. - (__pthread_getconcurrency): Ditto. - (__pthread_setconcurrency): Ditto. - (__pthread_getschedparam): Ditto. - (__pthread_setschedparam): Ditto. - - * thread.cc: Rename __pthread_equal to pthread_equal throughout. - Change pthread_self parameter appropriate. - (__pthread_attr_init): Remove __ prefix. Change to extern "C". - (__pthread_attr_destroy): Ditto. - (__pthread_attr_setdetachstate): Ditto. - (__pthread_attr_getdetachstate): Ditto. - (__pthread_attr_setstacksize): Ditto. - (__pthread_attr_getstacksize): Ditto. - (__pthread_attr_setinheritsched): Ditto. - (__pthread_attr_getinheritsched): Ditto. - (__pthread_attr_setschedparam): Ditto. - (__pthread_attr_getschedparam): Ditto. - (__pthread_attr_setschedpolicy): Ditto. - (__pthread_attr_getschedpolicy): Ditto. - (__pthread_attr_setscope): Ditto. - (__pthread_attr_getscope): Ditto. - (__pthread_attr_setstackaddr): Ditto. - (__pthread_attr_getstackaddr): Ditto. - (__pthread_key_create): Ditto. - (__pthread_key_delete): Ditto. - (__pthread_setspecific): Ditto. - (__pthread_getspecific): Ditto. - (__pthread_kill): Ditto. - (__pthread_sigmask): Ditto. - (__pthread_equal): Ditto. - (__pthread_mutex_lock): Ditto. - (__pthread_mutex_trylock): Ditto. - (__pthread_mutex_unlock): Ditto. - (__pthread_mutex_destroy): Ditto. - (__pthread_mutex_setprioceiling): Ditto. - (__pthread_mutex_getprioceiling): Ditto. - (__pthread_mutexattr_destroy): Ditto. - (__pthread_mutexattr_getprioceiling): Ditto. - (__pthread_mutexattr_getprotocol): Ditto. - (__pthread_mutexattr_getpshared): Ditto. - (__pthread_mutexattr_gettype): Ditto. - (__pthread_mutexattr_init): Ditto. - (__pthread_mutexattr_setprioceiling): Ditto. - (__pthread_mutexattr_setprotocol): Ditto. - (__pthread_mutexattr_setpshared): Ditto. - (__pthread_mutexattr_settype): Ditto. - (__pthread_cond_destroy): Ditto. - (__pthread_cond_signal): Ditto. - (__pthread_cond_broadcast): Ditto. - (__pthread_condattr_init): Ditto. - (__pthread_condattr_destroy): Ditto. - (__pthread_condattr_getpshared): Ditto. - (__pthread_condattr_setpshared): Ditto. - (__pthread_rwlock_destroy): Ditto. - (__pthread_rwlock_rdlock): Ditto. - (__pthread_rwlock_tryrdlock): Ditto. - (__pthread_rwlock_wrlock): Ditto. - (__pthread_rwlock_trywrlock): Ditto. - (__pthread_rwlock_unlock): Ditto. - (__pthread_rwlockattr_init): Ditto. - (__pthread_rwlockattr_getpshared): Ditto. - (__pthread_rwlockattr_setpshared): Ditto. - (__pthread_rwlockattr_destroy): Ditto. - (__pthread_getconcurrency): Ditto. - (__pthread_setconcurrency): Ditto. - (__pthread_getschedparam): Ditto. - (__pthread_setschedparam): Ditto. - -2003-03-18 Thomas Pfaff - - * cygwin.din: Add pthread_rwlock_destroy, pthread_rwlock_init, - pthread_rwlock_rdlock, pthread_rwlock_tryrdlock, - pthread_rwlock_wrlock, pthread_rwlock_trywrlock, - pthread_rwlock_unlock, pthread_rwlockattr_init, - pthread_rwlockattr_getpshared, pthread_rwlockattr_setpshared, - and pthread_rwlockattr_destroy. - * include/cygwin/version.h: Bump API minor number. - * include/pthread.h (PTHREAD_RWLOCK_INITIALIZER): Define a - reasonable value. - Add prototypes for pthread_rwlock_destroy, pthread_rwlock_init, - pthread_rwlock_rdlock, pthread_rwlock_tryrdlock, - pthread_rwlock_wrlock, pthread_rwlock_trywrlock, - pthread_rwlock_unlock, pthread_rwlockattr_init, - pthread_rwlockattr_getpshared, pthread_rwlockattr_setpshared, - and pthread_rwlockattr_destroy. - * thread.h (PTHREAD_ONCE_MAGIC): Remove superflous semicolon. - (PTHREAD_RWLOCK_MAGIC): New define. - (PTHREAD_RWLOCKATTR_MAGIC): Ditto. - (pthread_rwlockattr): New class. - (pthread_rwlock): Ditto. - (MTinterface::rwlocks): New member. - (MTinterface::MTinterface): Initialize rwlocks. - Add prototypes for __pthread_rwlock_destroy, - __pthread_rwlock_wrlock, __pthread_rwlock_trywrlock, - __pthread_rwlock_unlock, __pthread_rwlockattr_init, - __pthread_rwlockattr_getpshared, __pthread_rwlockattr_setpshared, - and __pthread_rwlockattr_destroy. - * thread.cc (MTinterface::Init): Initialize rwlock internal mutex. - (MTinterface::fixup_after_fork): Fixup rwlocks after fork. - (pthread_rwlockattr::isGoodObject): Implement. - (pthread_rwlockattr::pthread_rwlockattr): Ditto. - (pthread_rwlockattr::~pthread_rwlockattr): Ditto. - (pthread_rwlock::initMutex): Ditto. - (pthread_rwlock::pthread_rwlock): Ditto. - (pthread_rwlock::~pthread_rwlock): Ditto. - (pthread_rwlock::RdLock): Ditto. - (pthread_rwlock::TryRdLock): Ditto. - (pthread_rwlock::WrLock): Ditto. - (pthread_rwlock::TryWrLock): Ditto. - (pthread_rwlock::UnLock): Ditto. - (pthread_rwlock::addReader): Ditto. - (pthread_rwlock::removeReader): Ditto. - (pthread_rwlock::lookupReader): Ditto. - (pthread_rwlock::RdLockCleanup): Ditto. - (pthread_rwlock::WrLockCleanup): Ditto. - (pthread_rwlock::fixup_after_fork): Ditto. - (pthread_rwlock::isGoodObject): Ditto. - (pthread_rwlock::isGoodInitializer): Ditto. - (pthread_rwlock::isGoodInitializerOrObject): Ditto. - (pthread_rwlock::isGoodInitializerOrBadObject): Ditto. - (__pthread_rwlock_destroy): Ditto. - (pthread_rwlock::init): Ditto. - (__pthread_rwlock_rdlock): Ditto. - (__pthread_rwlock_tryrdlock): Ditto. - (__pthread_rwlock_wrlock): Ditto. - (__pthread_rwlock_trywrlock): Ditto. - -2003-03-18 Thomas Pfaff - - * thread.h (pthread_cond::ExitingWait): Remove. - (pthread_cond::mutex): Ditto. - (pthread_cond::cond_access): Ditto. - (pthread_cond::win32_obj_id): Ditto. - (pthread_cond::TimedWait): Ditto. - (pthread_cond::BroadCast): Ditto. - (pthread_cond::Signal): Ditto. - (pthread_cond::waiting): Change type to unsigned long. - (pthread_cond::pending): New member. - (pthread_cond::semWait): Ditto. - (pthread_cond::mtxIn): Ditto. - (pthread_cond::mtxOut): Ditto. - (pthread_cond::mtxCond): Ditto. - (pthread_cond::UnBlock): New method. - (pthread_cond::Wait): Ditto. - * thread.cc: Update list of cancellation points. - (pthread_cond::pthread_cond): Rewrite. - (pthread_cond::~pthread_cond): Ditto. - (pthread_cond::TimedWait): Remove. - (pthread_cond::BroadCast): Ditto. - (pthread_cond::Signal): Ditto. - (pthread_cond::UnBlock): Implement. - (pthread_cond::Wait): Ditto. - (pthread_cond::fixup_after_fork): Rewrite. - (pthread_mutex::fixup_after_fork): Remove DETECT_BAD_APP - conditional. - (__pthread_cond_broadcast): Just return 0 if the condition is - not initialized. Call pthread_cond::UnBlock to release blocked - threads. - (__pthread_cond_signal): Ditto. - (__pthread_cond__dowait): Rewrite. - (pthread_cond_timedwait): Add pthread_testcancel call. Fix - waitlength calculation. - (pthread_cond_wait): Add pthread_testcancel call. - -2003-03-18 Thomas Pfaff - - * include/pthread.h (PTHREAD_MUTEX_NORMAL): New define. - * thread.cc: Remove errno.h include. - (pthread::precreate): Change internal mutex type to normal. - (pthread_mutex::canBeUnlocked): Implement. - (pthread_mutex::pthread_mutex): Initialize lock_counter with 0. - (pthread_mutex::Lock): Rename to _Lock. Add self parameter. - Change lock_counter logic. Update SetOwner call. - (pthread_mutex::TryLock): Rename to _TryLock. Add self parameter. - Change lock_counter logic. Update SetOwner call. - (pthread_mutex::UnLock): Rename to _UnLock. Add self parameter. - Change lock_counter logic. - (pthread_mutex::Destroy): Rename to _Destroy. Update TryLock call. - (pthread_mutex::SetOwner): Move to thread.h as inline. - (pthread_mutex::LockRecursive): Ditto. - (pthread_mutex::fixup_after_fork): Change lock_counter logic. - (__pthread_mutexattr_settype): Add PTHREAD_MUTEX_NORMAL to valid - types check. - * thread.h: Include errno.h and limits.h. - (MUTEX_LOCK_COUNTER_INITIAL): Remove. - (MUTEX_OWNER_ANONYMOUS): New define. - (pthread_mutex::canBeUnlocked): New static method. - (pthread_mutex::lock_counter): Change type to unsigned long. - (pthread_mutex::GetPthreadSelf): New method. - (pthread_mutex::Lock): Call _Lock with pthread_self pointer. - (pthread_mutex::TryLock): Call _TryLock with pthread_self pointer. - (pthread_mutex::UnLock): Call _UnLock with pthread_self pointer. - (pthread_mutex::Destroy): Call _Destroy with pthread_self pointer. - (pthread_mutex::SetOwner): Moved from thread.cc as inline. - (pthread_mutex::LockRecursive): Ditto. - (pthread_mutex::_Lock): New method. - (pthread_mutex::_TryLock): New method. - (pthread_mutex::_UnLock): New method. - (pthread_mutex::_Destroy): New method. - -2003-03-18 Christopher January - - * fhandler_proc.cc (format_proc_cpuinfo): Use IsProcessorFeaturePresent - only on Windows NT. Read CPU Mhz value only on NT. Revert previous - change so cpuid instruction is called even on non-NT systems. - -2003-03-17 Corinna Vinschen - - * glob.c (g_lstat): Change API minor test to match API minor number - change in previous patch. - (g_stat): Ditto. - -2003-03-17 Christopher Faylor - - * include/cygwin/version.h: Reorganize last two api versions so that - btowc and trunc exports show up before previous bump since there has - been no exported version of the DLL with the 64 bit changes yet but - 1.3.22 will have the btowc and trunc. - -2003-03-17 Christopher Faylor - - * cygwin.din: Export btowc, trunc. - * include/cygwin/version.h: Reflect new exports. - * syscalls.cc (_stat): Rename to stat to avoid newlib wrapper. - * syscalls.cc (_fstat): Ditto. - -2003-03-16 Christopher Faylor - - * fhandler_console.cc (fhandler_console::close): Correct check for - current tty. Add debugging output when console is freed. - (set_console_state_for_spawn): Add debugging output. - * fhandler_tty.cc (fhandler_tty_slave::open): Don't decrement console - open flag when vforking. - * sigproc.cc (sigproc_terminate): Fix debugging output. - * spawn.cc (handle): Eliminate second argument. - (spawn_guts): Reflect elimination of argument change to handle. - * syscalls.cc (setsid): Add debugging output when console is freed. - -2003-03-14 Christopher Faylor - - * syscalls.cc (rename): Revert assumption that DELETE_ON_CLOSE works on - Win9x. - -2003-03-13 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number to 23. - -2003-03-13 Corinna Vinschen - - * autoload.cc (IsProcessorFeaturePresent): Add. - * fhandler_proc.cc (format_proc_cpuinfo): Add case for 9x systems. - -2003-03-13 Corinna Vinschen - - * fhandler_proc.cc (format_proc_cpuinfo): Fix vendor id in cpuid case. - -2003-03-13 Corinna Vinschen - - * net.cc (cygwin_rcmd): Use correct file descriptor in call to fdsock. - (cygwin_rexec): Ditto. - -2003-03-13 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_slave::close): Fix typo in debug - output. - - * syscalls.cc (rename): Assume that DELETE_ON_CLOSE works on Win9x. - -2003-03-11 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::dup): Don't call - fhandler_base::dup() but call DuplicateHandle directly instead to have - control over socket inheritence. - -2003-03-11 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::dup): On NT systems avoid - using WinSock2 socket duplication methods. Add comment. - -2003-03-11 Pierre Humblet - - * fhandler_socket.cc (fhandler_socket::fixup_after_fork): - Set io_handle to INVALID_SOCKET in case of failure. - (fhandler_socket::dup): Return 0 if the io_handle is valid. - -2003-03-10 Corinna Vinschen - - * sec_acl.cc (setacl): Don't handle DELETE flag specially. - * security.cc (alloc_sd): Ditto. - -2003-03-09 Corinna Vinschen - - * winver.rc: Change Copyright hint to include 2003. - -2003-03-09 Corinna Vinschen - - Switch to 32/64 datatypes: - * Makefile.in (OBSOLETE_FUNCTIONS): Add open acl aclcheck aclfrommode - aclfrompbits aclfromtext aclsort acltomode acltopbits acltotext chown - facl fchown fgetpos fopen freopen fseeko fsetpos fstat ftello - ftruncate getegid geteuid getgid getgrent getgrgid getgrnam getgroups - getpwuid getpwuid_r getuid initgroups lchown lseek lstat mknod mmap - seekdir setegid seteuid setgid setgroups setregid setreuid setuid stat - telldir truncate. - (NEW_FUNCTIONS): Add _open64 acl32 aclcheck32 aclfrommode32 - aclfrompbits32 aclfromtext32 aclsort32 acltomode32 acltopbits32 - acltotext32 chown32 facl32 fchown32 fgetpos64 fopen64 freopen64 - fseeko64 fsetpos64 fstat64 ftello64 ftruncate64 getegid32 geteuid32 - getgid32 getgrent32 getgrgid32 getgrnam32 getgroups32 getpwuid32 - getpwuid_r32 getuid32 initgroups32 lchown32 lseek64 lstat64 mknod32 - mmap64 seekdir64 setegid32 seteuid32 setgid32 setgroups32 setregid32 - setreuid32 setuid32 stat64 telldir64 truncate64 to substitute the - above. - * cygserver_shm.h (class client_request_shm): Change uid_t and gid_t - members to __uid32_t and __gid32_t. - * cygwin.din: Add symbols acl32 aclcheck32 aclfrommode32 - aclfrompbits32 aclfromtext32 aclsort32 acltomode32 acltopbits32 - acltotext32 facl32 fgetpos64 fopen64 freopen64 fseeko64 fsetpos64 - _fstat64 ftello64 _lseek64 mknod32 _open64. - * glob.c: Include perprocess.h. - (globtilde): Call getpwuid32 and getuid32 instead of getpwuid and - getuid. - (g_lstat): Check for applications API version to call the appropriate - typed gl_lstat function. - (g_stat): Ditto for gl_stat. - * shm.cc (client_request_shm::client_request_shm): Call geteuid32 - and getegid32 instead of geteuid and getegid throughout. - * syscalls.cc (_open64): New alias for open. - (_lseek64): New alias for lseek64. - (_fstat64): New alias for fseek64. - (mknod32): New function. - (mknod): Calls mknod32 now. - * winsup.h: Make function declarations for getuid32, geteuid32, - and getpwuid32 accessible for plain C sources. Add declarations - for getegid32 and getpwnam. - * include/cygwin/version.h: Bum API minor number to 78. - * include/sys/cygwin.h: Guard C++ specific members of struct - per_process against inclusion in plain C sources. - * include/sys/mman.h (mman): Add guard to avoid type clash when - compiling Cygwin. - -2003-03-09 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number to 22. - -2003-03-09 Christopher Faylor - - Do some minor reformatting of 'extern "C"' use throughout. - -2003-03-06 Christopher January - - * autoload.cc (GetSystemTimes): Define new autoload function. - * fhandler_proc.cc (proc_listing): Add cpuinfo and partitions entries. - (fhandler_proc::fill_filebuf): Add PROC_CPUINFO and PROC_PARTITIONS - cases. - (format_proc_uptime): Use GetSystemTimes if available. - (read_value): New macro. - (print): New macro. - (cpuid): New function. - (can_set_flag): New function. - (format_proc_cpuinfo): New function. - (format_proc_partitions): New function. - -2003-03-09 Christopher Faylor - - * syscalls.cc (unlink): Attempt to be more clever about setting - attributes of file. Only open file in query mode to avoid having to - mess with security stuff for reading. - -2003-03-09 Corinna Vinschen - - * rmsym: Fix regular expression. - -2003-03-09 Christopher Faylor - - * Makefile.in: Change from using new-* to cygwin0 for temporary - targets. - -2003-03-09 Corinna Vinschen - - * include/cygwin/socket.h: Set SOMAXCONN to Winsock2 value. - -2003-03-08 Christopher Faylor - - * syscalls.cc (unlink): Always attempt to use FILE_FLAG_CLOSE_ON_DELETE - to delete files since this allows us to preserve the protection of hard - linked files. - (link): Generate full path for potentially recalculated .lnk target. - -2003-03-08 Christopher Faylor - - Revert below changes regarding _pinfo::cmdline. - -2003-03-08 Corinna Vinschen - - * external.cc (cygwin_internal): Change n to __off64_t to match change - of _pinfo::cmdline. - * fhandler.h (class fhandler_virtual): Change filesize member to - __off64_t. - * fhandler_proc.cc (format_proc_meminfo): Change to return __off64_t. - (format_proc_stat): Ditto. - (format_proc_uptime): Ditto. - * fhandler_process.cc (format_process_stat): Ditto. - (format_process_status): Ditto. - (format_process_statm): Ditto. - * pinfo.cc (_pinfo::cmdline): Expect __off64_t parameter. - * pinfo.h (class _pinfo): Change declaration of cmdline accordingly. - -2003-03-07 Christopher Faylor - - * path.h (PATH_LNK): New enum val. - (path_conv::is_lnk_symlink): New function. True if path represents - .lnk style symlink. - * path.cc (check_shortcut): Set PATH_LNK in pflags when appropriate. - (symlink_info::check): Ditto. Remove PATH_LNK from pflags initially. - * syscalls.cc (unlink): Always remove readonly attribute from a symlink - regardless of type. - (link): (from Corinna Vinschen) Allow links to symlinks. Reset - attributes on a symlink after successful link creation. - (chmod): Use is_lnk_symlink where appropriate. - (rename): Ditto. - -2003-03-07 Pierre Humblet - - * tty.cc (create_tty_master): Call GetComputerName instead of - cygwin_gethostname. Set ut_id. - * syscalls.cc (login): Call endutent. - (setutent): Do not seek after a fresh open. - -2003-03-07 Corinna Vinschen - - * syscalls.cc (seteuid32): Fix formatting. - -2003-03-04 Thomas Pfaff - - * thread.cc (MTinterface::fixup_after_fork): Initialize mainthread - prior to pthread objects. - -2003-03-04 Jason Tishler - - * fhandler_socket.cc (fhandler_socket::dup): Initialize type. - -2003-03-03 Christopher Faylor - - * fhandler.h (fhandler_tty_slave::close): Declare new function. - (fhandler_tty_slave::dup): Declare new function. - (fhandler_tty_slave::fixup_after_function): Declare new function. - * fhandler_tty.cc (fhandler_tty_slave_open): Only increment - fhandler_console::open_fhs when associated with a pty. - (fhandler_tty_slave::close): Define new function. Decrement - fhandler_console::open_fhs when associated with a pty. - (fhandler_tty_slave::dup): Define new function. Increment - fhandler_console::open_fhs when associated with a pty. - (fhandler_tty_slave::fixup_after_fork): Define new function. Increment - fhandler_console::open_fhs when associated with a pty. - -2003-03-03 Christopher Faylor - - * fhandler_tty.cc (fhandler_pty_slave::open): Grudgingly increment - fhandler_console::open_fhs here. - (fhandler_pty_slave::close): Ditto for close. - -2003-03-02 Christopher Faylor - - * lib/getopt.c: Refresh from NetBSD sources. - -2003-03-02 Christopher Faylor - - * fhandler_console.cc (fhandler_console::close): Don't decrement - in use counter if in vfork fixup stage. - -2003-03-02 Christopher Faylor - - * lib/getopt.c: Nuke use of unneeded BSDisms. - -2003-03-02 Christopher Faylor - - * dll_init.cc (dll_list::load_after_fork): Don't revert to LoadLibrary - if LoadLibraryEx fails. - * dtable.cc (dtable::dec_console_fds): Eliminate. - (dtable::release): Don't treat console specially. - (dtable::build_fhandler): Ditto. - * dtable.h (console_fds): Eliminate. - (dtable::dec_console_fds): Eliminate. - (dtable::inc_console_fds): Eliminate. - * fhandler.h (fhandler_console::open_fhs): New static element. - * fhandler_console.cc (fhandler_console::open): Increment open_fs. - (fhandler_console::close): Call FreeConsole if no more open consoles - and ctty is not associated with the console. - * syscalls.cc (setsid): Simplify check for when to call FreeConsole. - (check_pty_fds): Eliminate definition. - * winsup.h (check_pty_fds): Eliminate declaration. - -2003-03-02 Christopher Faylor - - * dll_init.cc (dll_list::load_after_fork): Fix typo where result of - LoadLibrary was ignored. - -2003-03-01 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::bind): Open and write socket - file using Win32 calls. - -2003-03-01 Corinna Vinschen - - * fhandler_socket.cc (get_inet_addr): Open and read socket file using - Win32 calls. - -2003-02-28 Christopher Faylor - - * cygwin.din: Wrap atexit and exit with cygwin, thread-safe functions. - * dcrt0.cc (cygwin_atexit): New function. - (cygwin_exit): Ditto. - -2003-02-28 Pierre Humblet - - * syscalls.cc (fstat64): Pass get_name () to pc. - (access): Pass fn to stat_worker. - -2003-03-27 Corinna Vinschen - - * fhandler_socket.cc (class sock_event): New class managing Winsock - events for interruptible socket calls. - (fhandler_socket::connect): Move support for interruptible call to - class sock_event. Use class object instead. - (fhandler_socket::accept): Ditto. Remove useless casts. - -2003-03-27 Thomas Pfaff - - * fhandler_socket.cc (fhandler_socket::connect): Add support for - an interruptable connect. - -2003-02-27 Pierre Humblet - - * uinfo.cc (internal_getlogin): Only update user.groups.pgsid - if the call to set the primary group succeeds. - -2003-02-27 Christopher Faylor - - * cygthread::detach: Improve error message. - -2003-02-26 Pierre Humblet - - * sec_helper.cc (get_sids_info): debug_print owner_sid and group_sid. - -2003-02-25 Corinna Vinschen - - * mmap.cc (mmap64): Fix returned address by taking the granularity - into account. - -2003-02-23 Pierre Humblet - - * syslog.cc (syslog): Do not unlock the file before closing it - and remove debug_printf about stream errors. - -2003-02-22 Christopher Faylor - - * cygmalloc.h: Remove MORECORE_CANNOT_TRIM. It's not true. - # cygwin.din: Export mallinfo. - # malloc_wrapper.cc (mallinfo): New function. - -2003-02-22 Pierre Humblet - - * syslog.cc (syslog): Do not print the Windows pid. Print the Cygwin - pid as an unsigned decimal. On Win95 print a timestamp and attempt to - lock the file up to four times in 3 ms. - -2003-02-21 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::fhandler_socket): Fix compiler - warning. - (fhandler_socket::fstat): Simplify. Set st_uid/st_gid to effective - uid/gid of current process in case of open sockets. - -2003-02-21 Corinna Vinschen - - * dtable.cc (dtable::build_fhandler_from_name): Set some fhandler - data on sockets to evaluate AF_LOCAL sockets correctly. - (dtable::build_fhandler): Set unit number on sockets. - * fhandler.h (fhandler_socket): Add unit number. - (fhandler_socket::get_unit): New method. - * fhandler_socket.cc (fhandler_socket::fhandler_socket): Set unit - number. - (fhandler_socket::fstat): Reorganize to return more Linux-like - values. - * net.cc: include ctype.h. - (fdsock): Set unit number when building fhandler. - * path.cc (path_conv::check): Set device type to FH_SOCKET if file - is a AF_UNIX socket. - (get_devn): Evaluate unit for virtual socket devices. - (win32_device_name): Set windows path for sockets to unix_path with - just backslashes to keep the different names. - * syscalls.cc (fstat64): Don't override st_ino, st_dev and st_rdev - for sockets. - (stat_worker): Ditto. - -2003-02-21 Pierre Humblet - - * autoload.cc (AccessCheck): Add. - (DuplicateToken): Add. - * security.h (check_file_access): Declare. - * syscalls.cc (access): Convert path to Windows, check existence - and readonly attribute. Call check_file_access instead of acl_access. - * security.cc (check_file_access): Create. - * sec_acl (acl_access): Delete. - -2003-02-19 Christopher Faylor - - * fhandler.cc (fhandler_base::open): Move some filesystem specific - stuff. - (fhandler_disk_file::open): Accept some filesystem specific stuff. - * sigproc.cc (wait_for_sigthread): Become slightly more thread safe. - (sig_send): Don't assume that signal thread is ready. - -2003-02-20 Corinna Vinschen - - * wincap.h (wincap): Remove unnecessary definition of - supports_sparse_files. - * wincap.cc: Ditto. - -2003-02-20 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Check descriptor - created by cygheap_fdnew constructor. - * fhandler_virtual.cc (fhandler_virtual::opendir): Ditto. - * fhandler_socket.cc (fhandler_socket::accept): Ditto and move - creation of file descriptor behind blocking OS call. - * net.cc (cygwin_socket): Ditto. - (cygwin_rcmd): Ditto. - (cygwin_rresvport): Ditto. - (cygwin_rexec): Ditto. - (socketpair): Ditto. - -2003-02-20 Corinna Vinschen - - * autoload.cc (GetCompressedFileSize): Add. - * fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): Compute - st_blocks value from GetCompressedFileSize() if available. - -2003-02-18 Vaclav Haisman - - * wincap.h (wincaps::supports_sparse_files): New flag. - (wincapc::supports_sparse_files): New method. - * wincap.cc (wincap_unknown): Define value for the new flag. - (wincap_95): Ditto. - (wincap_95osr2): Ditto. - (wincap_98): Ditto. - (wincap_98se): Ditto. - (wincap_me): Ditto. - (wincap_nt3): Ditto. - (wincap_nt4): Ditto. - (wincap_nt4sp4): Ditto. - (wincap_2000): Ditto. - (wincap_xp): Ditto. - * path.h (path_conv::fs_flags): New method. - * fhandler_disk_file.cc: Include winioctl.h for DeviceIoControl. - (fhandler_disk_file::open): Set newly created and truncated files as - sparse on platforms that support it. - -2003-02-17 Pierre Humblet - - * grp.cc (internal_getgroups): Handle properly tokens with - no groups. Fix bug introduced on 2003-02-04. - -2003-02-16 Christopher Faylor - - * cygwin.din: Export all appropriate newlib libm functions. Sort. - * include/cygwin/version.h: Bump API minor number. - -2003-02-15 Christopher Faylor - - * cygwin.din: Export all appropriate newlib libc functions. - * include/cygwin/version.h: Bump API minor number. - -2003-02-14 Jason Tishler - - * mmap.cc (mprotect): Add missing break. - -2003-02-13 Christopher Faylor - - * exceptions.cc (try_to_debug): Don't reset priority when returning - from non-waitloop call. - -2003-02-13 Vaclav Haisman - Christopher Faylor - - * fhandler_console.cc (fhandler_console::write_normal): Use MessageBeep - for bell sound. - * autoload.cc (MessageBeep): Add. - -2003-02-13 Christopher Faylor - - * include/cygwin/types.h: Use correct ifdef guard for u_ definitions. - -2003-02-13 Christopher Faylor - - * environ.cc (environ_init): Use strechr. - -2003-02-13 Christopher Faylor - - * include/cygwin/in.h (sockaddr_in): Fix typo. - -2003-02-12 Christopher Faylor - - * path.h (path_conv): Reorganize slightly. - -2003-02-12 Christopher Faylor - - * fhandler_tty.cc (process_input): Add sanity check to ensure that - console typeahead is cleared on signal. - -2003-02-12 Christopher Faylor - - * spawn.cc (linebuf::~linebuf): Resurrect commented out (for - debugging?) code. - -2003-02-10 Ralf Habacker - - * include/cygwin/in.h (in_attr_t): Define new type. - * include/arpa/inet.h (inet_addr): Change return type to in_addr_t. - (inet_lnaof): Ditto. - (inet_netof): Ditto. - (inet_network): Ditto. - -2003-02-10 Christopher Faylor - - * include/cygwin/types.h: Move many *_t typedefs here. Protect them - with ifdefs. - * fhandler_disk_file.cc (fhandler_disk_file::fstat): Change ntsec_atts to mode_t. - * security.cc (get_attribute_from_acl): Accept mode_t attribute. - (get_nt_attribute): Ditto. - (get_file_attribute): Ditto. - (get_nt_object_attribute): Ditto. - (get_object_attribute): Ditto. - * security.h: Reflect above changes. - * syscalls.cc (chown_worker): Change attrib to mode_t. - -2003-02-08 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number to 21. - -2003-02-07 Christopher Faylor - - * malloc.cc (DEFAULT_MMAP_THRESHOLD): Bump down to 16MB thanks to below - changes. - -2003-02-07 Corinna Vinschen - - * mmap.cc (mmap_record::alloc_map): De-inline. Add offset and length - parameter. Only protect pages actually unused currently. Do job - of map_map() when initializing a map. - (mmap_record::map_map): Reduce functionality for the reuse case - of private anonymous mapping. - (mmap_record::fixup_map): Format change. - (list::add_record): Add offset and length parameter to call - mmap_record::alloc_map() correctly. - (mmap64): Rename `l' variable to `map_list'. Accommodate above changes. - (munmap): Rename `l' variable to `map_list'. - (msync): Ditto. - (fhandler_disk_file::mmap): Streamline code. - (mprotect): Ditto. - (fixup_mmaps_after_fork): Rename `l' variable to `map_list'. - -2003-02-07 Vaclav Haisman - Christopher Faylor - - * exceptions.cc (try_to_debug): Set priority of current thread rather - than the main thread. Make busy waiting loop less busy. Restore - priority when function returns. - -2003-02-07 Christopher Faylor - - * malloc.cc (DEFAULT_MMAP_THRESHOLD): Set high to avoid mmaps. - -2003-02-07 Christopher Faylor - - * pipe.cc (fhandler_pipe::close): Avoid extraneous this->. - -2003-02-06 Christopher Faylor - - * heap.cc (heap_init): Remove debugging code. - -2003-02-06 Pierre Humblet - - * security.h: Introduce names UNKNOWN_UID and UNKNOWN_GID and delete - declaration of is_grp_member. - * uinfo.cc (internal_getlogin): Use UNKNOWN_GID. - * passwd.cc (pwdgrp::read_passwd): Use UNKNOWN_UID. - * grp.cc (pwdgrp::read_group): Change group name to provide better - feedback. - (getgrgid): Use gid16togid32. - * sec_helper.cc (is_grp_member): Delete. - -2003-02-05 Christopher Faylor - - * path.cc: Change 'to_posix_p' to 'to_posix' throughout. - (conv_path_list_buf_size): Accommodate relative paths. - -2003-02-05 Christopher Faylor - - * path.cc (etc::dir_changed): Fix debug printf. - -2003-02-05 Corinna Vinschen - - * sec_acl.cc (setacl): Move all permission settings to beginning of - loop. Set default rights to same values as in alloc_sd(). Set DELETE - for owner and default owner only if S_IWOTH is given. - -2003-02-05 Pierre Humblet - - * sec_acl.cc: Change all __aclent16_t to __aclent32_t except in - wrapper function definitions. Replace call to the aclXYZ functions by - calls aclXYZ32. - (searchace): Change type of third argument to __uid32_t and use - ILLEGAL_UID instead of -1; - (setacl): Remove some initializations. Only give STANDARD_RIGHTS_WRITE - for S_IWOTH. Replace -1 by ILLEGAL_UID. - (getacl): Change type of owner_sid, group_sid and ace_sid to cygpsid. - In last else clause, suppress second call to ace_sid.get_id and use - TRUE in first call. Replace EqualSid by ==. - (acl_access): Call internal_getgroups in USER and GROUP cases. - (acecmp: Define static. - (acl32): Create from 16 bit type. - (facl32): Ditto. - (lacl32): Ditto. - (aclcheck32): Ditto. - (aclsort32): Ditto. - (acltomode32): Ditto. - (aclfrommode32): Ditto. - (acltopbits32): Ditto. - (aclfrompbits32): Ditto. - (acltotext32): Ditto. - (aclfromtext32): Ditto, and use strechr. - (acl16to32): Create. - (acl): Make it a wrapper function. - (facl): Ditto. - (lacl): Ditto. - (aclcheck): Ditto. - (aclsort): Ditto. - (acltomode): Ditto. - (aclfrommode): Ditto. - (acltopbits): Ditto. - (aclfrompbits): Ditto. - (acltotext): Ditto. - (aclfromtext): Ditto. - * security.cc (write_sd): Call set_process_privilege and check - ownership. - (alloc_sd): Remove call to set_process_privilege and the owner check. - -2003-02-05 Christopher Faylor - - * include/sys/cygwin.h: Use C-style comments. - -2003-02-05 Pierre Humblet - - * sec_helper.cc (get_sids_info): New function. - * security.cc (extract_nt_dom_user): Simplify with strechr. - (get_user_groups): Initialize glen to MAX_SID_LEN. - (get_user_local_groups): Ditto. - (get_attribute_from_acl): Define ace_sid as cygpsid. - (get_nt_attribute): Define owner_sid and group_sid as cygpsid. - Call get_sids_info instead of cygsid.get_{u,g}id and is_grp_member. - (get_nt_object_attribute): Ditto. - (alloc_sd): Define ace_sid as cygpsid. - -2003-02-04 Thomas Pfaff - - * syscalls.cc (struct system_cleanup_args): New struct. - (system_cleanup): New function. - (system): Use pthread_cleanup_push and _pop to save and restore - signal handlers and sigprocmask. - -2003-02-04 Corinna Vinschen - - * path.cc (symlink): Create security attributes so that only the - user can modify the symlink. - * security.cc (set_security_attribute): Remove symlink special - handling. - -2003-02-04 Pierre Humblet - - * grp.cc (internal_getgroups): Do not return without closing - the process handle. - -2003-02-04 Pierre Humblet - - * security.h (class cygpsid): New class. - (class cygsid): Use cygpsid as base. Remove members psid, get_id, - get_uid, get_gid, string, debug_printf and the == and != operators. - (cygsidlist::clear_supp): Only do work if setgroups has been called. - * sec_helper.cc: Define sid_auth NO_COPY. - (cygpsid::operator==): New operator. - (cygpsid::get_id): New function. - (cygpsid::string): New function. - (cygsid::string): Delete. - (cygsid::get_id): Delete. - * pwdgrp.h: Change arguments of internal_getpwsid, - internal_getgrsid and internal_getgroups to cygpsid. - * passwd.cc (internal_getpwsid): Change argument from cygsid to cygpsid. - * grp.cc (internal_getgrsid): Ditto. - (internal_getgroups): Ditto. - -2003-02-03 Christopher Faylor - - Eliminate most unneeded this-> pointers throughout. - -2003-02-03 Pierre Humblet - - * security.h: Add third argument to set_process_privilege. - * autoload.cc: Add OpenThreadToken. - * sec_helper.cc (set_process_privilege): Add and use use_thread - argument. - * security.cc (alloc_sd): Modify call to set_process_privilege. - Remember the result in each process. If failed and file owner is not - the user, fail. - -2003-02-03 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::recvfrom): Return buffer - length and don't set errno in case of WSAEMSGSIZE error. - (fhandler_socket::recvmsg): Ditto. - -2003-02-01 Christopher Faylor - - * grp.cc (getgrent32): Only refresh group entries when at beginning. - (internal_getgrsid): Only refresh if uninitialized. - (internal_getgrent): Ditto. - * passwd.cc (getpwent): Only refresh passwd entries when at beginning. - (pwdgrp::read_passwd): linebuf *cannot* be NO_COPY. - (internal_getpwsid): Only refresh if uninitialized. - (getpass): No need to refresh passwd data here. - * pwdgrp.h (refresh): Eliminate default. - -2003-01-31 Christopher Faylor - - * dlfcn.cc (dlerror): Only report load errors once per error. - -2003-01-31 Christopher Faylor - - * fhandler_serial.cc (fhandler_serial::open): Avoid extraneous setting - of res. - - * termios.cc (tcsetattr): Correctly record errno after tcsetattr call. - -2003-01-31 Troy Curtiss - - * fhandler_serial.cc (fhandler_serial::tcsetattr): Add error-checking - so that if any Win32 SetComm*() calls fail, errno gets set to EINVAL - and tcsetattr() returns -1. Catch invalid bitrates, mostly. If baud - rate setting is B0, just drop DTR and leave Win32 DCB bitrate as-is - since 0 is not a valid Win32 setting. - (fhandler_serial::tcgetattr): If DTR is low, populate the bitrate as - B0, otherwise get it from the DCB. - -2003-01-31 Christopher Faylor - - * passwd.cc (pwdgrp::read_passwd): linebuf *must* be static (from - Pierre Humblet). - * pwdgrp.h (pwdgrp::refresh): Avoid calling read function if we already - have lock since that means we are in the process of reading the file. - -2003-01-31 Jason Tishler - - * shared.cc (shared_info::heap_chunk_size): Use correct variable when - reading HKLM. - -2003-01-30 Christopher Faylor - - * fhandler_registry.cc (fhandler_registry::exists): Fix off-by-one - error when inspecting path. - -2003-01-29 Christopher Faylor - - * lib/getopt.c: Allow environment variable control of POSIXLY_INCORRECT - behavior. - -2003-01-28 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::accept): On successful execution - set connection state of returned socket to CONNECTED. - -2003-01-27 Christopher Faylor - - * passwd.cc (pwdgrp::parse_passwd): Be more unforgiving about - non-numeric fields. - -2003-01-26 Christopher Faylor - - * uinfo.cc (pwdgrp::next_num): Remove check for NULL since it is no - longer a valid return from next_str. - (pwdgrp::add_line): Duh. Revert to use strchr. - -2003-01-26 Christopher Faylor - - * string.h (strechr): New function. - * uinfo.cc (pwdgrp::next_str): Search only for input char in string. - Return EOS on failure. Don't check for NULL since it shouldn't be - possible. - (pwdgrp::add_line): Revert to replacing '\n' in input line with '\0'. - (pwdgrp::next_num): Pass explicit separator character to next_str. - * grp.cc (pwdgrp::parse_group): Ditto. - * passwd.cc (pwdgrp::parse_passwd): Ditto. Revamp test for garbage - input. - * pwdgrp.h (pwdgrp::next_str): Don't use default parameter. - -2003-01-26 Christopher Faylor - - * uinfo.cc (pwdgrp::load): Regularize strace output. Add warning for - CreateFile failure. - -2003-01-26 Christopher Faylor - - * passwd.cc (pwdgrp::parse_passwd): Eliminate use of memset. The - structure should always be completely filled out. - * grp.cc (pwdgrp::parse_group): Ditto. - -2003-01-26 Christopher Faylor - - * grp.cc (pwdgrp::parse_group): Fix off-by-one problem in allocating - gr_mem. - -2003-01-26 Christopher Faylor - - * include/sys/strace.h (paranoid_printf): Define as not being part of - "all" output. - -2003-01-25 Christopher Faylor - - * pwdgrp.h (pwdgrp::next_num): Rename from next_int. Returns - true/false if parse operation succeeded. - (pwdgrp::reparse): Remove. - (pwdgrp::raw_ptr): New function. Returns pointer in line. - (pwdgrp::next_num): New functions for parsing other than unsigned long. - * grp.cc (pwdgrp::parse_group): Reinstate previous parsing behavior. - Don't fill in fields with NULL and assign empty gr_mem to known pointer - rather than doing a pointless calloc. Streamline gr_mem parsing. - Don't increment curr_lines here. - * passwd.cc (pwdgrp::parse_passwd): Use new behavior of next_num. - Don't increment curr_lines here. - * uinfo.cc (pwdgrp::next_str): Keep returning EOL if out of data. - (pwdgrp::reparse): Remove. - (pwdgrp::next_num): Rename from next_int. Return bool indicating - success of parse, argument returns value parsed. - (pwdgrp::add_line): Increment curr_lines here on successful parse. - (pwdgrp::load): (from Pierre Humblet) Don't return status. Just report - it here. - -2003-01-25 Christopher Faylor - - * pwdgrp.cc (pwdgrp::reparse): Declare. - * uinfo.cc (pwdgrp::reparse): Define. - * grp.cc (pwdgrp::parse_group): Use reparse. - -2003-01-25 Pierre Humblet - - * syscalls.cc (seteuid32): On Win95 get the pw entry. If it exists - update the euid and call cygheap->user.set_name. Remove special - handling of ILLEGAL_UID. - (setgid32): Add a debug_printf. On Win95, always set the egid. - Remove special handling of ILLEGAL_GID. Do not compare gid and gr_gid. - * child_info.h (class cygheap_exec_info): Remove uid. - * spawn.cc (spawn_guts): Do not set ciresrv.moreinfo->uid. - * dcrto.cc (dll_crt0_1): Always call uinfo_init. - * uinfo.cc (uinfo_init): Reorganize and close handle if needed. - (cygheap_user::ontherange): Do not call internal_getpwnam if pw is NULL. - -2003-01-24 Christopher Faylor - - * fhandler_console.cc (fhandler_console::send_winch_maybe): Reset - scroll region if size changes. - -2003-01-24 Pierre Humblet - Jason Tishler - - * cygwin.din: Export setreuid32, setreuid, setregid32, setregid. - * syscalls.cc (setreuid32): New function. - (setreuid): Ditto. - (setregid32): Ditto. - (setregid): Ditto. - * include/cygwin/version.h: Bump API minor number. - -2003-01-23 Christopher Faylor - - * pwdrp.h (pwdgrp::refresh): Lock entire test prior to reading. - -2003-01-23 Christopher Faylor - - * grp.cc (pwdgrp::parse_group): Eliminate arg and use class member - instead. Use next_str and next_int to parse arguments. - * passwd.cc (pwdgrp::parse_passwd): Ditto. - (grab_string): Eliminate. - (grab_int): Ditto. - * pwdgrp.h (pwdgrp::parse): Eliminate input arg. - (pwdgrp::parse_passwd): Reflect above change. - (pwdgrp::parse_group): Reflect above change. - (pwdgrp::next_str): New function. - (pwdgrp::next_int): Ditto. - (pwdgrp::gets): Eliminate. - * uinfo.cc (pwdgrp::next_str): New function. - (pwdgrp::next_int): Ditto. - (pwdgrp::add_line): Subsume gets. - (pwdgrp::gets): Eliminate. - (pwdgrp::load): Just call add_line to parse input buffer. - -2003-01-22 Thomas Pfaff - - * include/pthread.h (PTHREAD_MUTEX_RECURSIVE): Revert changes from - 2003-01-09 mutex patch. - (PTHREAD_MUTEX_ERRORCHECK): Ditto. - -2003-01-22 Corinna Vinschen - - * cygrun.c: Move from here to ../testsuite. - * Makefile.in: Remove cygrun.exe dependencies. - -2003-01-21 Jason Tishler - - * cygwin.din: Export nanosleep(). - * signal.cc (nanosleep): New function. - (sleep): Move old functionality to nanosleep(). Call nanosleep(). - (usleep): Remove old functionality. Call nanosleep(). - * include/cygwin/version.h: Bump API minor number. - -2003-01-21 Christopher Faylor - - * grp.cc: Call gr.refresh() rather than doing isunitialized tests - throughout. - (gr): Use constructor (sigh). - (pwdgrp::parse_group): Rename from parse_grp. - (pwdgrp::read_group): Rename from read_etc_group. Just call gr.load - with a single argument. - * passwd.cc: Call pr.refresh() rather than doing isunitialized tests - throughout. - (pr): Use constructor (sigh). - (pwdgrp::parse_passwd): Rename from "parse_pwd". - (pwdgrp::read_passwd): Rename from read_etc_passwd. Just call pr.load - with a single argument. - * pwdgrp.h (pwdgrp_state): Eliminate. - (pwdgrp): Reflect above renamings. - (pwdgrp::etc_ix): Rename from pwd_ix. - (pwdgrp::read): New element. - (pwdgrp::lock): New element. - (pwdgrp::refresh): New function. - (pwdgrp::load): Eliminate variations which take buffer arguments. - (pwdgrp::pwdgrp): New constructors. Initialize mutex here. - * uinfo.cc (pwdgrp::load): Accommodate pwd_ix -> etc_ix renaming. - (pwdgrp::load): Set initialized state to true rather than setting state - to loaded. - -2003-01-21 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number. - -2003-01-21 Pierre Humblet - - * path.h (etc::change_possible): Revert the type to bool. - (etc::set_last_modified): Remove obsolete function. - * path.cc (etc::change_possible): Revert type to bool. - (etc::test_file_change): Do not test for negative values of - change_possible and do not set it to -res. - (etc::dir_changed): When the handle is NULL, call memset instead of - test_file_changed. When the handle is invalid, return true. Detect - filename change in /etc. - (etc::file_changed): Remove unneeded check for !fn[n]. - * uinfo.cc (pwdgrp::load): Eliminate spurious setting of fh to NULL. - * pwdgrp.h (pwdgrp::operator =): Eliminate. - -2003-01-19 Christopher Faylor - - * pwdgrp.h (etc): Move to path.h. - (pwdgrp::max_lines): New field. - (pwdgrp::curr_lines): New field. - (pwdgrp::pwdgrp_buf): Ditto. - (pwdgrp_buf_elem_size): Ditto. - (pwdgrp_parse): Ditto. - (pwdgrp::gets): Just declare here. - (pwdgrp::load): Ditto. Just take one argument. - (pwdgrp::load): Define overloaded function accepting passwd buf. - (pwdgrp::load): Define overloaded function accepting group buf. - * grp.cc: Use pwdgrp elements rather than standalone static variables - throughout. - (curr_lines): Eliminate. - (max_lines): Ditto. - (add_grp_line): Ditto. - (parse_grp): Define as returning boolean. Accept void * arg and line - count. Coerce first argument into __group32 buf reference. Increment - curr_line as appropriate. - (read_etc_group): Pass pwdgrp buffer to gr.load. - * passwd.cc: Use pwdgrp elements rather than standalone static variables - throughout. - (curr_lines): Eliminate. - (max_lines): Ditto. - (add_grp_line): Ditto. - (parse_passwd): Define as returning boolean. Accept void * arg and line - count. Coerce first argument into passwd buf reference. Increment - curr_line as appropriate. - (read_etc_group): Pass pwdgrp buffer to pr.load. - * path.cc (etc::fn): Extend buffer size to allow index by 1 rather than - zero. - (etc::last_modified): Ditto. - (etc::change_possible): Ditto. Renamed from sawchange. Change to - signed char since elements are now tri-state. - (etc::init): Assume "handle" is 1 based rather than 0. - (etc::test_file_change): New function. Sets change_possible based on - file date comparison. - (etc::dir_changed): Check file states immediately after changed_h is - initialized to avoid a race. - (etc::file_changed): Use test_file_change to detect if file needs to be - updated. - * path.h (etc): Move class here from pwdgrp.h. - * uinfo.cc: Move etc:: functions to path.cc. Move pwdgrp functions - here. - (pwdgrp::gets): Eliminate buf checks. Just check eptr and set lptr. - (pwdgrp::add_line): New function. - (pwdgrp::load): Call generic add_line function which will call correct - parser. - -2003-01-17 Christopher Faylor - - * cygheap.cc: Change most 'int's to 'unsigned's. - (_cmalloc): Only check for size of malloced region when calculating - bucket. Add overhead when performing the sbrk. Previous change broke - _crealloc. - -2003-01-17 Christopher Faylor - - * dcrt0.cc (initialize_env): Use colon for CYGWIN_DEBUG separator. - * grp.cc: Change most statics to NO_COPY throughout. - * passwd.cc: Ditto. - -2003-01-17 Christopher Faylor - - * pwdgrp.h: Change some BOOLs to bools. - (pwdgrp::pwdgrp): Remove unneeded constructor. - * passwd.cc: Change BOOL to bool throughout. - -2003-01-17 Corinna Vinschen - - * cygwin.din: Add strerror_r. - * include/cygwin/version.h: Bump API minor number. - -2003-01-17 Christopher Faylor - - * uinfo.cc (etc::dir_changed): Don't print a warning if can't open - /etc, unless debugging. - -2003-01-17 Pierre Humblet - - * grp.cc (read_etc_group): On NT, add a line for gid = -1. Change name - "unknown" to "mkgroup". - (internal_getgrgid): Do not return default in nontsec case. - (internal_getgroups): Add argument srchsid and look for it in groups if - not NULL. - * passwd.cc (read_etc_passwd): On NT, add a line for uid = -1. Use - same default uid for Win95 and NT. Call cygheap_user::ontherange to - initialize HOME. - -2003-01-16 Christopher Faylor - - * cygheap.cc (init_cygheap::etc_changed): Move to uinfo.cc. - * cygheap.h (init_cygheap::etc_changed_h): Remove. - (init_cygheap::etc_changed): Ditto. - * grp.cc (group_state): Remove. Use gr instead throughout. - (gr): Define as class pwdgrp. - (read_etc_group): Remove gr definition. Remove calls to - set_last_modified and close. Pass add_grp to gr.load to load file. - * passwd.cc (passwd_state): Remove. Use pr instead, throughout. - (pr): Define as class pwdgrp. - (read_etc_passwd): Remove pr definition. Remove calls to - set_last_modified and close. Pass add_pwd_line to pr.load to load - file. - * pwdgrp.h (etc): New helper class for pwdgrp. - (pwdgrp): Combine pwdgrp_check and pwdgrp_read into one class. Remove - file_w32 and last_modified fields. - (pwdgrp::set_last_modified): Remove. - (pwdgrp::isinitializing): Remove FindFirstFile stuff. Move to - etc::file_changed. - (pwdgrp::load): Rename from 'open'. Call etc::init to initialize etc - scanning. Close file handle after reading buffer into memory. Parse - buffer by calling second argument. - (pwdgrp::gets): Reorganize slightly to rely on eptr starting at - beginning of buffer. - (pwdgrp::close): Remove. - * uinfo.cc (etc::dir_changed): New function. - (etc::init): Ditto. - (etc::file_changed): Ditto. - (etc::set_last_modified): Ditto. - -2003-01-16 Jason Tishler - - * mmap.cc (fixup_mmaps_after_fork): Add ERROR_NOACCESS to the list of - ReadProcessMemory() error codes that trigger a retry with temporary - PAGE_READONLY access. Note that this can occur on NT 4.0. - -2003-01-15 Christopher Faylor - - * path.cc (normalize_posix_path): Convert win32 path separators to - slashes when full path is specified. - -2003-01-15 Pierre Humblet - - * cmalloc.cc (_cmalloc): Fix memory leak. - -2003-01-15 Corinna Vinschen - - * autoload.cc: Fix copyright date. - * fhandler_dsp.cc: Ditto. - * mmap.cc: Ditto. - * net.cc: Ditto. - * ntdll.h: Ditto. - * signal.cc: Ditto. - * syscalls.cc: Ditto. - * uname.cc: Ditto. - * wait.cc: Ditto. - -2003-01-14 Corinna Vinschen - - * mmap.cc (fixup_mmaps_after_fork): Copy protection to child process. - Change ambiguous debug output. - -2003-01-14 Corinna Vinschen - - * mmap.cc (mmap_record::access): Change argument type to caddr_t - for strictness. - (mprotect): Protect against calling VirtualProtect() for shared - pages on 9x/Me. - (fixup_mmaps_after_fork): If ReadProcessMemory() fails, try to - change protection of parent page to PAGE_READONLY, then try again. - Revert protection afterwards. - -2003-01-14 Thomas Pfaff - - * syscalls.cc (system): Add pthread_testcancel call. - * thread.cc: Update list of cancellation points. - -2003-01-14 Thomas Pfaff - - * wait.cc: Include thread.h - (wait4): Add pthread_testcancel call. - Wait for child process and cancellation event. - * thread.cc: Update list of cancellation points. - -2003-01-14 Thomas Pfaff - - * signal.cc (sleep): Add pthread_testcancel call. - Wait for signal and cancellation event. - (usleep): Ditto. - -2003-01-14 Thomas Pfaff - - * exceptions.cc (handle_sigsuspend): Add pthread_testcancel call. - Wait for signal and cancellation event. - * thread.cc: Update list of cancellation points. - -2003-01-14 David Huang - - * fhandler_dsp.cc (fhandler_dsp::ioctl): Add limited support for - SNDCTL_DSP_GETFMTS. - -2003-01-12 Christopher Faylor - - * ntdll.h: Fix typo. - -2003-01-12 Corinna Vinschen - - * uname.cc (uname): Use cygwin_gethostname() to retrieve hostname. - -2003-01-12 Pierre Humblet - - * sec_acl.cc (search_ace): Use id == -1, instead of < 0, as wildcard. - (setacl): Start the search for a matching default at the next entry. - Invalidate the type of merged entries instead of clearing it. - Use well_known_creator for default owner and owning group and do - not try to merge non-default and default entries in these cases. - (getacl): Recognize well_known_creator for default owner and group. - (acl_worker): Improve errno settings and streamline the nontsec case. - * security.cc (write_sd): Remove the call to set_process_privilege. - (alloc_sd): If the owner changes, call set_process_privilege and return - immediately on failure. Change inheritance rules: on new directories add - inherit only allow ACEs for creator_owner, creator_group and everyone. - Preserve all inheritances through chmod and chown calls. Introduce - isownergroup to implement the uid == gid case, to keep the inheritance - code simple. Do not initialize owner_sid and group_sid and stop using - the variable psd. - -2003-01-10 Christopher Faylor - - * net.cc: Use gethostname define from winsock2.h. - -2003-01-10 Christopher Faylor - - * path.cc: Unrevert below reversion except for - mount_info::conv_to_posix_path part. - -2003-01-10 Corinna Vinschen - - * path.cc: Revert patch from 2003-01-09 to normalize a windows path - rather than converting to posix. - -2003-01-10 Corinna Vinschen - - * autoload.cc (gethostname): Make call optional, return 1 if function - can't get loaded. - * net.cc (cygwin_gethostname): Call GetComputerName if return value - of gethostname is non-zero. - -2003-01-10 Charles Wilson - - * cygwin.din: Add asprintf and vasprintf, as well as the reentrant - versions and underscore variants. - * include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR. - -2003-01-10 Corinna Vinschen - - * net.cc (cygwin_gethostname): Fix call to wsock function gethostname. - -2003-01-09 Christopher Faylor - - * cygthread.cc (cygthread::cygthread): Be more noisy about odd - condition. - * miscfuncs.cc (low_priority_sleep): Sleep in regular priority if - that's what we're currently running at. - -2003-01-09 Thomas Pfaff - - * include/semaphore.h: Modify typedef for sem_t. - * include/cygwin/types.h: Modify typedefs for pthread_t, - pthread_mutex_t, pthread_key_t, pthread_attr_t, - pthread_mutexattr_t, pthread_condattr_t, pthread_cond_t, - pthread_rwlock_t and pthread_rwlockattr_t. - -2003-01-09 Thomas Pfaff - - * thread.h (WAIT_CANCELED): New define. - (pthread::cancelable_wait): New static method. - * thread.cc (pthread::cancelable_wait): Implement. - (semaphore::Wait): Wait on semaphore and thread cancellation. - (pthread::join): Wait on joined thread and thread cancellation. - (semaphore::wait): Add testcancel to check for thread - cancellation even if the semaphore is available. - -2003-01-09 Thomas Pfaff - - * include/pthread.h: Add define for errorchecking mutexes. - Change default mutex type. - * thread.cc (pthread_cond::TimedWait): Update mutex unlock - calls. - (pthread_mutex::pthread_mutex): New implement. - (pthread_mutex::~pthread_mutex): Ditto. - (pthread_mutex::Lock): Ditto. - (pthread_mutex::TryLock): Ditto. - (pthread_mutex::UnLock): Ditto. - (pthread_mutex::Destroy): Implement new method. - (pthread_mutex::SetOwner): Ditto. - (pthread_mutex::LockRecursive): Ditto. - (pthread_mutex::fixup_after_fork): Restore locking state after - fork. - (__pthread_mutex_lock): Return pthread_mutex::Lock errorcode. - (__pthread_mutex_trylock): Return pthread_mutex::TryLock - errorcode. - (__pthread_mutex_unlock): Return pthread_mutex::UnLock - errorcode. - (__pthread_mutex_destroy): Call pthread_mutex::Destroy to - destroy mutex. - (__pthread_mutexattr_settype): Allow errorchecking and recursive - types. - * thread.h (MUTEX_LOCK_COUNTER_INITIAL): New define. - (pthread_mutex::criticalsection): Remove. - (pthread_mutex::lock_counter): New member. - (pthread_mutex::recursion_counter): Ditto. - (pthread_mutex::owner): Ditto. - (pthread_mutex::type): Ditto. - (pthread_mutex::Destroy): New method. - (pthread_mutex::SetOwner): Ditto. - (pthread_mutex::LockRecursive): Ditto. - -2003-01-09 Thomas Pfaff - - * pthread.cc (pthread_cond_init): Use new pthread_cond::init. - * thread.cc: Some white spaces cleanups. - Change __pthread_cond_init to pthread_cond::init throughout. - (nativeMutex): Move class methods outside pthread_mutex. - (MTinterface::Init): Initialize pthread_cond init lock. - (pthread_cond::condInitializationLock): Instantiate. - (pthread_cond::initMutex): New Method. - (pthread_cond::isGoodInitializerOrBadObject): Ditto. - * thread.h: Some white spaces cleanups. - (nativeMutex): Move class declaration outside pthread_mutex. - (pthread_cond::condInitializationLock): New static member. - (pthread_cond::initMutex): New Method. - (pthread_cond::isGoodInitializerOrBadObject): Ditto. - (__pthread_cond_init): Remove prototype. - -2003-01-09 Corinna Vinschen - - * fhandler_disk_file.cc (num_entries): Return 2 as link count if - directory unreadable. - -2003-01-09 Corinna Vinschen - - * security.cc (get_nt_attribute): Always return -1 when read_sd() - fails. - (get_file_attribute): Set permissions to 0 and owner/group to -1 - if security descriptor is unreadable. - -2003-01-09 Christopher Faylor - - Use isdirsep rather than SLASH_P throughout. - * path.cc (iscygdrive): Disallow /cygdrive\x. - (normalize_posix_path): "Normalize" a windows path, if detected, rather - than converting to posix. - -2003-01-06 Troy Curtiss - - * fhandler_serial.cc (fhandler_serial::tcsetattr): Add support and - capability checking for B230400 bitrate. - (fhandler_serial::tcgetattr): Add support for B230400 bitrate. - * include/sys/termios.h: Add B230400 definition for Posix support of - 230.4Kbps. - -2003-01-05 Christopher Faylor - - * pinfo.cc (_pinfo::commune_send): Use myself->lock rather than just - lock when leaving. - -2003-01-03 Christopher Faylor - - * dtable.h (dtable::in_vfork_cleanup): New function. True if vfork - cleanup needed. - * dtable.cc (dtable::vfork_parent_restore): Remove assertion. - * pipe.cc (fhandler_pipe::close): Don't close read_state during - fork_fixup since it wasn't inherited. - -2003-01-01 Christopher Faylor - - * passwd.cc (getpwuid_r32): Revert previous change. - -2003-01-01 Christopher Faylor - - * sysconf.cc (sysconf): Return arbitrary values for - _SC_GETGR_R_SIZE_MAX, _SC_LOGIN_NAME_MAX, _SC_GETPW_R_SIZE_MAX. - - * passwd.cc (getpwuid_r32): Add uid/gid fields to size check - calculation. - diff --git a/winsup/cygwin/ChangeLog-2004 b/winsup/cygwin/ChangeLog-2004 deleted file mode 100644 index ebb696237..000000000 --- a/winsup/cygwin/ChangeLog-2004 +++ /dev/null @@ -1,3848 +0,0 @@ -2004-12-30 Christopher Faylor - - * devices.cc (device::isfs): Return true for the logical case of - devn == FH_FS. - -2004-12-28 Christopher Faylor - - * pinfo.cc (_pinfo::dup_proc_pipe): DUPLICATE_CLOSE_SOURCE closes the - handle regardless, so revert previous change. - -2004-12-27 Christopher Faylor - - * cygthread.cc (cygthread::stub): Add better debug output. - (cygthread::cygthread): Ditto. - (cygthread::terminate_thread): Ditto. Move inuse test earlier or - suffer infinite loop. - * pinfo.cc (_pinfo::dup_proc_pipe): Close handle if DuplicateHandle - fails and process no longer exists. - * spawn.cc (spawn_guts): Create process in suspended state if OS - demands it. - * wincap.cc: Add "start_proc_suspended" throughout. - * wincap.h (wincaps): Ditto. - (wincapc): Ditto. - -2004-12-27 Christopher Faylor - - * pinfo.cc (_pinfo::exit): Beef up debugging output. - * sigproc.cc (proc_subproc): Detached children apparently need a ppid - of 1. - -2004-12-26 Christopher Faylor - - * init.cc (dll_entry): Previous code reversion was ill-advised. Revert - it. - * sigproc.cc (child_info::sync): Ditto. - * pinfo.cc (_pinfo::exit): Don't set myself.procinfo to NULL since it - is no longer required. - -2004-12-26 Christopher Faylor - - * init.cc (dll_entry): Remove exit code setting. - * pinfo.cc (pinfo::init): Initialize exitcode to unset state rather - than SIGTERM. - (proc_waiter): Detect if exit code is unset and use status from - GetExitCodeProcess. - * sigproc.cc (child_info::sync): Remove exit code detection here since - proc_waiter now (again) detects it. - -2004-12-25 Christopher Faylor - - * fhandler.cc (fhandler_base::fchmod): Do the right thing when changing - an "on disk" device or fifo. - (fhandler_base::fchown): Ditto for changing ownership. - * fhandler_disk_file.cc (fhandler_base::fstat_helper): Accommodate - device files on ntfs partitions. - * path.cc (path_conv::check): Use isfs function to figure out if a path - exists on a filesystem to make sure that device files are caught. - -2004-12-24 Christopher Faylor - - * child_info.h (CURR_CHILD_INFO_MAGIC): Update. - (child_info::parent_wr_proc_pipe): Eliminate. - * pinfo.h (_pinfo::alert_parent): Move here from pinfo class. - (_pinfo::dup_proc_pipe): New method. - (_pinfo::sync_proc_pipe): Ditto. - * exceptions.cc (sig_handle_tty_stop): Reflect move of alert_parent. - * init.cc (dll_entry): Exit with status one if main process called - ExitProcess. - * pinfo.cc (set_myself): Remove handling of parent_wr_proc_pipe. - (_pinfo::exit): Reflect move of alert_parent. Set procinfo to NULL to - flag that we are exiting normally. Always use exitcode when exiting - (although this could be a little racy). - (pinfo::init): Set default exit to SIGTERM. This will be the exit code - reported if process is terminated. - (_pinfo::dup_proc_pipe): New function. - (pinfo::wait): Duplicate wr_proc_pipe to the right place. Use - dup_proc_pipe to move the pipe to the child. - (_pinfo::sync_proc_pipe): New function. - (_pinfo::alert_parent): Move to _pinfo. Make sure that wr_proc_pipe is - ours before using it. - * sigproc.cc (child_info::child_info): Remove handling of - parent_wr_proc_pipe. - * spawn.cc (spawn_guts): Pass our wr_proc_pipe to the child when - execing. Ensure that exit code of cygwin process started from windows - is correctly set. - -2004-12-23 Pierre Humblet - Christopher Faylor - - * path.h (path_conv::set_normalized_path): Add second argument and fill - it in throughout. - * path.cc (path_conv::check): Declare, set and use "strip_tail". - (path_conv::set_normalized_path): Add and use second argument, - replacing all tail stripping tests. - -2004-12-23 Christopher Faylor - - * cygthread.cc (cygthread::cygthread): Guard debugging variable with - "ifdef DEBUGGING". - (cygthread::release): Ditto. - -2004-12-23 Christopher Faylor - Corinna Vinschen - - * path.cc (path_conv::check): Don't strip the trailing slash from a - path consisting only of two slashes. - -2004-12-23 Christopher Faylor - - * cygthread.cc (cygthread::stub): Detect if thread function wants to - release itself here, to avoid a race. - (cygthread::release): Clear more stuff. Add a diagnostic for an - internal error. - * cygthread.h (auto_release): New function. - * pinfo.h (pinfo::remember): Add an argument to denote whether child is - detached. - * fork.cc (fork_parent): Reflect change in arguments to - pinfo::remember. - * pinfo.cc (_pinfo::exit): Signal exit more forcibly. - (proc_waiter): Use cygthread::auto_release to signify that - cygthread::stub should release the thread. This should avoid a race. - (pinfo::alert_parent): Don't signify an error when wr_proc_pipe == NULL. - * sigproc.cc (proc_subproc): Add support for PROC_DETACHED_CHILD. - * sigproc.h: Ditto. - * spawn.cc (spawn_guts): Specify whether child is detached or not when - calling pinfo::remember. - -2004-12-22 Christopher Faylor - - * cygheap.cc (cygheap_setup_for_child): Add api_fatal to catch failing - MapViewOfFileEx. - * cygthread.cc (cygthread::stub): Previous change to make diagnostic - output more informative was really a bust. Try again. Capture previous - name in a new field in cygthread for diagnostic purposes. - (cygthread::cygthread): Ditto. - (cygthread::release): Add an argument to control whether h should be cleared - or not. - (cygthread::terminate_thread): Use 'inuse' for tests rather than 'h'. - (cygthread): Add some diagnostic fields. - (cygthread::release): Add an argument. - * pinfo.cc (proc_waiter): Accommodate change to cygthread::release. - -2004-12-22 Christopher Faylor - - * cygthread.cc (cygthread::stub): Make diagnostic output more informative. - -2004-12-22 Christopher Faylor - - * pinfo.cc (proc_waiter): Zero wait_thread in child to avoid races with - process termination. - * cygthread.cc (cygthread::terminate): Clumsily detect when h has gone away - and attempt no further action. - -2004-12-22 Christopher Faylor - - * cygthread.h (cygthread::release): Just declare here. - * cygthread.cc (cygthread::release): Define here. Use - InterlockedExchange to set inuse or suffer potential races. - (cygthread::terminate): Use release(). - -2004-12-22 Chris January - - * fhandler_process.cpp (format_process_status): Use tabs in formatting - instead of spaces. - -2004-12-22 Corinna Vinschen - - * path.cc (set_normalized_path): Allow empty pathnames. - -2004-12-21 Christopher Faylor - - * spawn.cc (spawn_guts): Force parent to forget about P_DETACH'ed - process. - -2004-12-20 Christopher Faylor - - * path.cc (normalize_win32_path): Remove unneeded check for dots. - -2004-12-20 Christopher Faylor - - * path.cc (normalize_posix_path): Remove unneeded check for dots. - (path_conv::set_normalized_path): Strip trailing dots, similarly to - what had previously been done for the win32 path. - -2004-12-18 Christopher Faylor - - * path.cc (normalize_win32_path): Make third arg pass-by reference. - Reorganize slightly to eliminate extra variables. - (normalize_posix_path): Ditto. - (path_conv::check): Reflect change in arguments. - (mount_info::conv_to_posix_path): Ditto. - (mount_info::add_item): Ditto. - -2004-12-18 Christopher Faylor - - * child_info.h (CURR_CHILD_INFO_MAGIC): Use updated value. - -2004-12-18 Christopher Faylor - Pierre Humblet - - * path.cc (path_conv::check): Check the output Win32 path for trailing - spaces and dots, not the input path. Disallow all use of foo./bar - since consistently getting this right is time consuming. Remove - strange test for "unc\" since no one seems to know what it's for. - -2004-12-18 Chris January - - * fhandler_proc.cc (proc_listing): Add entry for "self". - (proc_fhandlers): Add entry for "self". - * fhandler_process.cc (fhandler_process::fstate): Handle "self". - (fhandler_process::open): Handle "self". - -2004-12-17 Christopher Faylor - - * sigproc.cc (proc_subproc): Fix long-standing problem. Only wait for - "all processes" if pid == -1 -- not just if pid is negative. - (proc_can_be_signalled): Fix another long-standing problem. Set - correct errno when detecting an exited process. - -2004-12-16 Thomas Wolff - - * fhandler_console.cc (get_win32_attr): Avoid inappropriate intensity - interchanging that used to render reverse output unreadable when - non-reversed text is bright. - -2004-12-15 Corinna Vinschen - - * cygwin.din: Add utmpx symbols. - * syscalls.cc: Include utmpx.h. Implement utmpx functions as stubs - to utmp functions. - (copy_ut_to_utx): New static function. - (pututline): Change from void to struct utmp * as on Linux. - (setutxent): New function. - (endutxent): New function. - (getutxent): New function. - (getutxid): New function. - (getutxline): New function. - (pututxline): New function. - * include/utmpx.h: New file. - * include/cygwin/utmp.h: New file. - * include/cygwin/version.h: Bump API minor number. - * include/sys/utmp.h: Include cygwin/utmp.h. Move stuff common with - utmpx functionality there. - (pututline): Declare struct utmp *. - -2004-12-14 Corinna Vinschen - - * tty.cc (tty_list::terminate): Guard releasing the tty with tty_mutex. - (tty::init): Set master_pid to 0. - -2004-12-14 Thomas Wolff - - * fhandler_console.cc (read): Consider offset within scrolling - region of the console window. - -2004-12-13 Corinna Vinschen - - * cygheap.h (cwdstuff::get_drive): Release cwd_lock. - -2004-12-12 Bas van Gompel - - * fhandler.cc (fhandler_base::puts_readahead): Fix end-condition. - -2004-12-10 Corinna Vinschen - - * errno.cc (errmap): Map ERROR_INVALID_ADDRESS to EINVAL instead of - EOVERFLOW. - -2004-12-10 Christopher Faylor - - * include/sys/strace.h: Don't output paranoid_printf by default. - -2004-12-09 Christopher Faylor - - * lib/libcmain.c (main): Properly deal with quoted first argument. - -2004-12-06 Christopher Faylor - - * pinfo.h (proc_pipe::*): Delete class. - * pinfo.cc (proc_pipe::*): Ditto. - -2004-12-05 Christopher Faylor - - * fork.cc (fork_parent): Reinstate "childhProc" protection. Don't - close hProcess handle here since it is used to ensure that a new - process isn't created with the old pid after the old pid exits. - * spawn.cc (spawn_guts): Ditto. - * pinfo.cc (proc_waiter): Don't send any signals if we've execed since - this process doesn't officially exist. - * pinfo.h (pinfo::pid_handle): Eliminate. Just use hProc. - * sigproc.cc (sig_send): Don't send any signals if our sendsig doesn't - exist. That's a sign that we are execing. - (remove_proc): Eliminate pid_handle close. - -2004-12-05 Christopher Faylor - - * cygthread.h (cygthread::terminate_thread): Make public. - * pinfo.h (pinfo::wait_thread): New element. - * pinfo.cc (pinfo::wait): Store "handle" to started thread in pinfo. - * sigproc.cc (proc_terminate): Kill any threads waiting for a process - pipe. - -2004-12-05 Christopher Faylor - - * sigproc.cc (mychild): Reimplement as list scan. - (proc_subproc): Don't mess with pinfo if it's myself. - -2004-12-05 Christopher Faylor - - * child_info.h (child_info_types): Label enum for _PROC constants. - (child_info::child_info): New constructor. - (child_info::~child_info): New destructor. - (child_info::sync): Declare new function. - (child_info_fork::child_info_fork): New constructor. - (child_info_spawn::child_info_spawn): Remove old constructor. - (child_info_spawn::child_info_spawn): New constructor. - * dcrt0.cc (dll_crt0_0): Use correct sizeof when doing sanity check on - passed in child_info. Signal readiness to parent when not forking (and - not spawning). - * fork.cc (sync_with_child): Delete. - (resume_child): Remove extra argument. - (sync_with_parent): Use child_info method to sync with parent. - (fork_child): Don't close fork_info->subproc_ready since that is now - handled by the destructor. - (fork_parent): Remove subproc_ready stuff. Use child_info sync method - for waiting.. Set start time here for child. Rename "forked" to - "child". - (fork): Check ch.subproc_ready for validity here. - * pinfo.h (_pinfo::exec_sendsig): Temp storage for exec stub which may - be staying around to handle non-cygwin captive process. - (_pinfo::exec_dwProcessId): Ditto. - (_pinfo::_lock): Renamed from lock. - (_pinfo::lock): New method. - (_pinfo::unlock): Ditto. - (_pinfo::initialize_lock): Ditto. - * pinfo.cc (set_myself): Use initialize_lock method to initialize - myself lock. Set "exec" fields in _pinfo to zero to indicate that - we've started successfully. Set start time here when appropriate. - (_pinfo::commune_send): Use pinfo lock/unlock methods. - (proc_waiter): Remove special case for non-cywin processes. - Reinstitute handling for PID_NOCLDSTOP. - * sigproc.cc (proc_subproc): Set proper EAGAIN errno when process table - is filled. - (sig_send): Use exec_* fields from _pinfo for sending signals if the - the _pinfo sendsig never materializes. - (child_info::child_info): New constructor, renamed from init_child_info. - Zeroes child_info structure and sets appropriate fields in structure - based on chtype. - (child_info::~child_info): New destructor. Closes subproc_ready if it - exists. - (child_info_fork::child_info_fork): New constructor. - (child_info_spawn::child_info_spawn): New constructor. - (child_info::ready): New function. Signals parent when child is ready. - (child_info::sync): New function. Wait for child to signal us or - process to die. - (remove_proc): Remove closing of hProcess since this should now be - handled shortly after process creation. - * spawn.cc (spawn_guts): Use child_info_spawn constructor rather than - init_child_info. Save exec_sendsig and exec_dwProcessId in execing - _pinfo. Rely on child_info constructor to properly set - parent_wr_proc_pipe in ciresrv. Revert to previous determination on - whether to start a process in suspended mode. Remove reparenting - stuff. Just keep a stub around if starting a non-cygwin process. - -2004-12-05 Bas van Gompel - - * fhandler.cc (fhandler_base::read): Remove superfluous check in - __small_printf format for strace. - -2004-12-05 Bas van Gompel - - * fhandler.cc (fhandler_base::read): Don't debug_printf garbage when - copied_chars is zero. - -2004-12-03 Christopher Faylor - - * environ.cc (environ_init): Alloc space for TERM if it is not set, - like all of the other environment variables. - -2004-12-02 Christopher Faylor - - * child_info.h (child_info_fork::parent_wr_proc_pipe): New element. - * fork.cc (fork_parent): Set parent_wr_proc. - * pinfo.cc (set_myself): Close child_proc_info->parent_wr_proc if it - exists rather than trying to get value from parent _pinfo. - -2004-12-02 Christopher Faylor - - * pinfo.h (enum parent_aleter): New enum. - (pinfo::alert_parent): Declare as returning a value. - (pinfo::parent_alive): New function. - * pinfo.cc (pinfo::alert_parent): Set wr_proc_pipe to invalid non-NULL - value when parent disappears. Return success of operation. - (proc_waiter): Use __ALERT_* enum for control since these are not really signals. - Implement __ALERT_ALIVE. - * sigproc.cc (my_parent_is_alive): Eliminate. - * sigproc.h (my_parent_is_alive): Ditto for declaration. - (__SIGREPARENT): Eliminate. - -2004-12-02 Christopher Faylor - - * pinfo.cc (pinfo::wait): Use better name for cygthread. - -2004-12-03 Pierre Humblet - - * registry.h (reg_key::reg_key): Change arguments. - * shared_info.h (class mount_info): Remove had_to_create_mount_areas. - * registry.cc (reg_key::reg_key): Change constructors to always handle - HKLM and to avoid relying on HKCU. - Do not set mount_table->had_to_create_mount_areas. - * path.cc (mount_info::conv_to_win32_path): Improve update of - sys_mount_table_counter. - (mount_info::read_mounts): Use new reg_key constructor. - (mount_info::add_reg_mount): Ditto. - (mount_info::del_reg_mount): Ditto. - (mount_info::read_cygdrive_info_from_registry): Ditto. - (mount_info::write_cygdrive_info_to_registry): Ditto. - Update cygwin_shared->sys_mount_table_counter after registry update. - (mount_info::get_cygdrive_info): Ditto. - * shared.cc (shared_info::heap_chunk_size): Use new reg_key constructor. - * environ.cc (regopt): Ditto. - -2004-12-01 Christopher Faylor - - * include/features.h: Include sys/cdefs.h, like linux. - -2004-12-01 Christopher Faylor - - * syscalls.cc (truncate64): Don't second-guess errno if open fails. - * devices.in: Don't allow /dev/com0. - -2004-11-25 Christopher Faylor - - * environ.cc (putenv): Accommodate recent newlib change in argument to - putenv. - -2004-11-25 Christopher Faylor - - * child_info.h (child_info_spawn::hexec_proc): Eliminate. - * dcrt0.cc (dll_crt0_0): Remove hexec_proc stuff. - * fork.cc (fork_child): Remove call to pinfo_fixup_after_fork. - * pinfo.cc (set_myself): Close and zero pid_handle if set. - (pinfo_fixup_after_fork): Delete. - (proc_waiter): Don't close vchild.hProcess here. Do that when we are - remove the vchild from procs. Save hProcess as pid_handle only on - first reparent operation. - (pinfo::wait): Don't set pid_handle here. - (pinfo::alert_parent): Always try to send signal. If unsuccessful then - close and zero wr_proc_pipe. - * pinfo.h (pinfo::pinfo): Make sure that appropriate parts of the class - are zeroed on construction. - (pinfo::alert_parent): Take char argument. - (pinfo_fixup_after_fork): Delete declaration. - (hexec_proc): Ditto. - * sigproc.cc (remove_proc): Close pid_handle and hProcess if - appropriate. - * spawn.cc (spawn_guts): Set cygheap->pid_handle on first exec. - -2004-11-25 Christopher Faylor - - * cygheap.h (init_cygheap::pid_handle): New element. - * pinfo.cc (set_myself): Clear previously existing cygheap->pid_handle - when a new process has been started. - (pinfo::wait): Make sure that a handle to the newly forked/spawned - process is kept around so that the pid will not be reused. - * pinfo.h (_pinfo::pid_handle): Move. - (pinfo::pid_handle): to here. - * spawn.cc (spawn_guts): Create a pid_handle in cygheap prior to - spawning to ensure that the pid does not get reused during the lifetime - of the "cygwin pid". - -2004-11-25 Christopher Faylor - - * pinfo.h (pinfo::alert_parent): New function. - * exceptions.cc (sig_handle_tty_stop): Use alert_parent to send - "signals" to parent. - * fork.cc (fork_parent): Don't close pi.hProcess. Let the waiter - thread do that. - * pinfo.cc (proc_waiter): Detect case where process exits without - setting the exit code and use value from GetExitCodeProcess. - Reluctantly implement __SIGREPARENT. - (pinfo::alert_parent): Define. - * sigproc.h (__SIGREPARENT): New enum. - * spawn.cc (spawn_guts): Send reparent signal to parent on exec. - Always create process in suspended state to avoid races. - -2004-11-25 Christopher Faylor - - Remove cygthread.h in favor of cygtls.h throughout since cygtls now - includes cygthread.h. Eliminate ppid_handle usage throughout. - * child_info.h: Regenerate magic number - (child_info): Remove pppid_handle. - * cygthread.h (cygthread::release): New method. Frees thread without - waiting. - * cygthread.cc (cygthread::stub): Set _ctinfo in _mytls to point to - information for executing thread. Don't call SetEvent if thread is no - longer in use. - (cygthread::simplestub): Ditto. - * cygtls.h (_cygtls::_ctinfo): New element contains pointer to - information about executing cygthread, if any. - * dcrt0.cc: Remove last vestiges of per_thread stuff. - (dll_crt0_0): Ditto. Remove accommodation for ppid_handle. - (do_exit): Remove obsolete reparenting test. - (_exit): Exit with a more SUSv3-like exit value. - * dtable.cc (dtable::stdio_init): Check for myself->cygstarted rather - than myself->ppid_handle to see if we were started by a cygwin process. - * exceptions.cc (open_stackdumpfile): Ditto. - (handle_exceptions): Ditto. - (ctrl_c_handler): Ditto. - (sig_handle_tty_stop): Ditto. Let parent send signal to itself on - STOP. - (sigpacket::process): Comment out vfork test. - (signal_exit): Use more SUSv3-like exit value on signal. - * external.cc (fillout_pinfo): Don't set hProcess. - * fork.cc: Remove VFORK cruft. - (per_thread::set): Delete. - (fork_child): Remove perthread stuff. - (fork_parent): Remove obsolete subproc_init. Accommodate new method - for tracking subprocesses. - * pinfo.cc (set_myself): Accommodate new pinfo/_pinfo layout. Set some - things here that used to be set in wait_sig. - (_pinfo::exit): Set exitcode here. Close process pipe. - (_pinfo::commune_send): Accommodeate new pinfo/_pinfo layout. - (proc_waiter): New function. Waits, in a thread for subprocess to go - away. - (pinfo::wait): New function. Initialization for proc_waiter. - * pinfo.h (_pinfo::exitcode): New element. - (_pinfo::cygstarted): Ditto. - (_pinfo::wr_proc_pipe): Ditto. - (_pinfo::ppid_handle): Delete. - (_pinfo::hProcess): Delete. - (_pinfo::lock): Delete. - (pinfo::hProcess): New element. - (pinfo::lock): Ditto. - (pinfo::wait): Declare new function. - (pinfo::preserve): Define new function. - * sigproc.cc: Remove old stuff from wait_subproc thread based method. - (zombies): Remove. - (procs): New. - (my_parent_is_alive): Just check that the parent pid exists. - (mychild): Just use pinfo methods to determine if child is mine. - (proc_subproc): Revamp PROC_ADDCHILD to use pinfo::wait. Remove - PROC_CHILDTERMINATED logic. Use different method to remove processes - from list when SIGCHLD == SIG_IGN. - (proc_terminate): Gut. - (subproc_init): Delete. - (init_child_info): Remove setting of pppid_handle. - (checkstate): Revamp to only scan procs array. - (remove_proc): Rename from remove_zombie. Don't close hProcess or - pid_handle. Don't release memory if it's myself. - (stopped_or_terminated): Change logic to handle new consolidated - proc/zombie array. - (wait_subproc): Delete. - * sigproc.h: Remove obsolete EXIT_* defines. - (subproc_init): Remove declaration. - * spawn.cc (spawn_guts): Remove reparenting stuff. Use standard wait - logic to wait for child if started from a non-cygwin process. - * tlsoffsets.h: Regenerate. - * tty.cc (tty_init): Check for myself->cygstarted rather than - myself->ppid_handle to see if we were started by a cygwin process. - * include/sys/signal.h (external_pinfo::exitcode): Replace hProcess. - * include/sys/wait.h (WCOREDUMP): Define. - - * fhandler_tty.cc (fhandler_tty_slave::read): Add debugging output for - timeout case. - * signal.cc (abort): Flag that we are exiting with the ABORT signal. - -2004-11-22 Christopher Faylor - - * select.cc (select_stuff::test_and_set): Remove extraneous tests of - "window_handle". - -2004-11-20 Pierre Humblet - - * fhandler.cc (fhandler::write): Remove debug_printf. - * pipe.cc (fhandler_pipe::create): Edit syscall_printf format. - -2004-11-20 Pierre Humblet - - * cygheap.h (cygheap_user::get_windows_id): New method. - * registry.h (get_registry_hive_path): Change argument type. - (load_registry_hive): Ditto. - * registry.cc (get_registry_hive_path): Change argument type and take - Win9x keys into account. - (load_registry_hive): Ditto. - * uinfo.cc (cygheap_user::env_userprofile): Use get_windows_id, even - for SYSTEM. - * shared.cc (user_shared_initialize): Use get_windows_id. - * syscalls.cc (seteuid32): Load the registry hive and reload the user - shared also on Win9x. - -2004-11-11 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number to 13. - -2004-10-28 Christopher Faylor - - * fork.cc (NPIDS_HELD): Reduce to former number now that bash problem - has been identified. - -2004-10-28 Pierre Humblet - - * path.cc (mount_info::from_registry): Deimpersonate while - accessing HKLM. - (mount_info::read_cygdrive_info_from_registry): Ditto. - * cygheap.h: Define NO_IMPERSONATION. - (cygheap_user::issetuid): Replace INVALID_HANDLE_VALUE by - NO_IMPERSONATION. - (cygheap_user::has_impersonation_tokens): Ditto. - (cygheap_user::close_impersonation_tokens): Ditto. - * uinfo.cc (uinfo_init): Ditto. - * syscalls.cc (seteuid32): Ditto. - * security.cc (set_impersonation_token): Ditto. - -2004-10-26 Christopher Faylor - - * cygtls.cc (_cygtls::fixup_after_fork): Wipe out exitsock local since - it should not be used by the child. - * select.cc (start_thread_socket): Turn off inheritance for exitsock. - Don't add exitsock to exception mask since it should never get an - exception. - (socket_cleanup): Change some debug messages for consistency. - * fhandler_socket.cc (fhandler_socket::dup): Change comment wording - slightly. - -2004-10-26 Pierre Humblet - - * registry.cc (get_registry_hive_path): Simplify and add a - debug_printf in case of failure. - (load_registry_hive): Revert the 2004-04-19 change. - -2004-10-20 Christopher Faylor - - * select.cc (start_thread_socket): Remove attempt to delay reading of - exitsock or suffer occasional mysterious 60 second hangs. - (socket_cleanup): Empty the exitsock here after the thread has - terminated. - -2004-10-19 Christopher Faylor - - * fhandler_console.cc (fhandler_console::fixup_after_exec): Fix error - message. - -2004-10-12 Christopher Faylor - - * select.cc (start_thread_socket): Remove unused code. - -2004-10-11 Christopher Faylor - - * fhandler_termios.cc (fhandler_termios::tcsetpgrp): Revert previous checkin. - -2004-10-10 Christopher Faylor - - * cygtls.h (exitsock): New element. - (exitsock_sin): Ditto. - * cygtls.cc (_cygtls::init_thread): Initialize exitsock to invalid handle. - (_cygtls::call2): Close exitsock if it is valid. - * select.cc (struct socketinf): Remove sin element. - (start_thread_socket): Initialize one SOCK_DGRAM socket per thread - instead of (apparently) expensive opening and closing of socket with - each select call. - (socket_cleanup): Send a byte to the exitsock socket as a way to - potentially signal a waiting-for-socket thread to exit. - * tlsoffsets.h: Regenerate. - -2004-10-07 Corinna Vinschen - - * cygheap.h (class cygheap_user): Add psystemroot member and - env_systemroot method. - * environ.cc (struct spenv): Add add_always member. - (spenvs): Accommodate new add_always member. Add - cygheap_user::env_systemroot method to SYSTEMROOT entry. - (build_env): Check add_always member when adding missing environment - variables from spenvs. - * uinfo.cc (cygheap_user::env_systemroot): New method. - -2004-10-07 Corinna Vinschen - - * dcrt0.cc (dll_crt0_0): Drop duplicated line. - -2004-10-07 Christopher Faylor - - * spawn.cc (pthread_cleanup::oldmask): Default to invalid signal mask. - (do_cleanup): Test for invalid signal mask to decide whether to restore - the mask rather than assuming zero mask indicates that there is nothing - to do. - -2004-10-07 Mark Paulus - - * fhandler_tty.cc (fhandler_tty_slave::read): Use previously - evaluated time_to_wait value. - -2004-10-05 Pierre Humblet - - * external.cc (check_ntsec): Do not call wincap.has_security. - * path.cc (path_conv::check): Ditto. - * security.cc (get_object_attribute): Ditto. - (get_file_attribute): Ditto. - -2004-10-05 Bas van Gompel - - * pinfo.cc (_pinfo::commune_send): Correct debugging output. - -2004-10-04 Christopher Faylor - - * include/cygwin/signal.h: Add siginterrupt definition. - -2004-10-02 Pierre Humblet - - * path.h (enum path_types): Delete PATH_ISDISK. - (path_conv::isdisk): Delete method. - (path_conv::set_isdisk): Ditto. - * path.cc (path_conv::check): Do not call set_isdisk. - * uinfo.cc(pwdgrp::load): Do not call pc.isdisk. - -2004-09-28 Christopher Faylor - - * fhandler_termios.cc (fhandler_termios::tcsetpgrp): Disallow attempts - to set the process group to a nonexistent process group. - -2004-09-27 Corinna Vinschen - - * lib/_cygwin_crt0_common.cc: Revert patch from 2004-09-16. Brakes - newly built DLLs. - -2004-09-24 Christopher Faylor - Sergey Ivanov - - * path.cc (mount_info::read_cygdrive_info_from_registry): Default - /cygdrive to binary mode. - -2004-09-22 Pierre Humblet - - * path.cc (normalize_win32_path): Only look for : in second position. - Avoid infinite loop with names starting in double dots. - (mount_info::conv_to_win32_path): Do not worry about a trailing dot. - (hash_path_name): Ditto. - -2004-09-20 Christopher Faylor - - * exceptions.cc (sig_handle_tty_stop): Set flag earlier. - -2004-09-20 Christopher Faylor - - * exceptions.cc (sig_handle_tty_stop): Set flag that we are in a cygwin - function to avoid a probably erroneous stack walk. - -2004-09-17 Corinna Vinschen - - * syscalls.cc (unlink): Don't use "delete on close" on remote shares. - -2004-09-17 Corinna Vinschen - - * cygwin.din (_impure_ptr): Add export again. There are libs out there. - -2004-09-16 Corinna Vinschen - - * cygwin.din (_impure_ptr): Don't export. - (reent_data): Export. - * lib/_cygwin_crt0_common.cc (_impure_ptr): Drop entirely. Don't - initialize _impure_ptr or u->impure_ptr_ptr. - -2004-09-15 Corinna Vinschen - - * cygwin.din (_impure_ptr): Export. - (reent_data): Don't export. - * dcrt0.cc (reent_data): Drop. - (__cygwin_user_data): Initialize impure_ptr as GLOBAL_REENT. - (_dll_crt0): Initialize _impure_ptr as GLOBAL_REENT. - * lib/_cygwin_crt0_common.cc (_impure_ptr): Drop. Declare extern as - dllimport instead. - -2004-09-14 Christopher Faylor - - * cygtls.h: Add alignment kludge to fix disparity between compilers. - * tlsoffsets.h: Regenerate. - - * fork.cc (slow_pid_reuse): Use define to control number of pids held - to prevent pid reuse. - -2004-09-14 Sam Steingold - - * autoload.cc (EnumProcessModules): Add. - * dlfcn.cc (dlsym): Handle RTLD_DEFAULT using EnumProcessModules(). - * include/dlfcn.h (RTLD_DEFAULT): Define to NULL. - -2004-09-13 Christopher Faylor - - * fork.cc (slow_pid_reuse): Temporarily double the number of pids held - to prevent pid reuse. - -2004-09-12 Christopher Faylor - - * sigproc.cc (wait_sig): Ensure that waiting threads are awoken after - returning from a hold condition. - -2004-09-12 Christopher Faylor - - * child_info.h (CURR_CHILD_INFO_MAGIC): Update. - -2004-09-11 Pierre Humblet - Christopher Faylor - - * exceptions.cc: (ctrl_c_handler): Do nothing while a Cygwin subprocess - is starting. - -2004-09-10 Christopher Faylor - - * child_info.h (init_child_info): Remove pid argument from declaration. - * cygheap.h (init_cygheap::pid): New element. - * dcrt0.cc (dll_crt0_0): Eliminate handling of now-noexistent cygpid - parameter in child_info struct. Set forkee to 'true' rather than - cygpid since the pid value was never used. - (dll_crt0_1): Ditto. - (_dll_crt0): Ditto. - * fork.cc (fork_child): Don't wait for sigthread. This is handled in - the fork call now. - (fork_parent): Remove obsolete pid argument from init_child_info call. - Don't do anything special with cygpid when DEBUGGING. - (fork): Delay all signals during fork. - (fork_init): Don't do anything special when DEBUGGING. - * pinfo.cc (set_myself): Remove pid parameter. Use new pid field in - cygheap. - (pinfo_init): Don't pass pid argument to set_myself. - * sigproc.cc (sig_send): Wait for dwProcessId to be non-zero as well as - sendsig. - (init_child_info): Eliminate handling of pid. - (wait_sig): Implement method to temporarily hold off sending signals. - * sigproc.h (__SIGHOLD): New enum. - (__SIGNOHOLD): Ditto. - * spawn.cc (spawn_guts): Remove obsolete pid argument from - init_child_info call. - -2004-09-10 Corinna Vinschen - - * fhandler.cc (fhandler_base::dup): Use debug_printf. - -2004-09-10 Corinna Vinschen - - * Makefile.in: Create libutil.a from bsdlib.o exports. - * bsdlib.cc (logwtmp): Move from syscalls.cc to here. - (login): Ditto. - (logout): Ditto. - - * winsup.h (EXPORT_ALIAS): New macro. - * exec.cc: Define alias symbols using EXPORT_ALIAS macro. - * syscalls.cc: Ditto. - * times.cc: Ditto. - -2004-09-09 Corinna Vinschen - - * fhandler_tape.cc (fhandler_dev_tape::open): Fix typo. - -2004-09-09 Bas van Gompel - - * pipe.cc (create_selectable_pipe): Work around bug in Windows 95 - where CreateNamedPipe returns NULL. - -2004-09-08 Pierre Humblet - - * cygheap.h (cwdstuff::drive_length): New member. - (cwdstuff::get_drive): New method. - * path.cc (normalize_win32_path): Simplify by using cwdstuff::get_drive. - (mount_info::conv_to_win32_path): Use cwdstuff::get_drive as default for /. - (cwdstuff::set): Initialize drive_length. - -2004-09-07 Christopher Faylor - - * cygtls.cc (_cygtls::init_thread): Set __sdidinit to negative value to - indicate that it is "special". - * thread.cc (pthread::exit): If __sdidinit is < 0, it was never really - initialized so reset it to 0 before calling _reclaim_reent. - -2004-09-05 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number to 12. - -2004-09-03 Corinna Vinschen - - * security.cc: Fix a few more strace_prints. - -2004-09-02 Christopher Faylor - - Regularize most strace_prints throughout so that %E is always preceded - by a comma and elminate most uses of "foo = %s" to "foo %s". - -2004-09-02 Bob Byrnes - Christopher Faylor - - * autoload.cc (NtQueryInformationFile): Return nonzero on error. - * ntdll.h (FILE_PIPE_LOCAL_INFORMATION): Add. - (NtQueryInformationFile): Fix types for last two arguments. - * pipe.cc: Include stdlib.h, limits.h, and ntdll.h. - (create_selectable_pipe): New function to create a pipe that can be - used with NtQueryInformationFile for select. - (fhandler_pipe::create): Call create_selectable_pipe instead of - CreatePipe. - (pipe): Use DEFAULT_PIPEBUFSIZE as argument to create_pipe. - * select.cc: Include limits.h and ntdll.h. - (peek_pipe): Add select_printf output. Call NtQueryInformationFile to - implement select for write on pipes. - (fhandler_pipe::select_read): Reorder field assignments to be - consistent with fhandler_pipe::select_write. - (fhandler_pipe::select_write): Initialize startup, verify, cleanup, and - write_ready fields for select_record. - (fhandler_pipe::select_except): Tweak indentation to be consistent with - fhandler_pipe::select_write. - -2004-08-30 Pierre Humblet - - * fork.cc (fork_parent): Return the cygpid directly derived from the - winpid. - -2004-08-30 Christopher Faylor - - * fork.cc (fork_parent): Record child's pid when we're sure that it has - been filled out by the child. - * pinfo.cc (pinfo::init): Trivial change. - -2004-08-29 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Allow to report - success on systems with ntsec and ntea set. - -2004-08-28 Pierre Humblet - - * fhandler.cc (fhandler_base::write): In the lseek_bug case, set EOF - before zero filling. Combine similar error handling statements. - -2004-08-28 Pierre Humblet - - * syscalls.cc (ftruncate64): On 9x, call write with a zero length - to zero fill when the file is extended. - -2004-08-24 Corinna Vinschen - - * syscalls.cc (link): Avoid compiler warning. - -2004-08-21 Corinna Vinschen - - * environ.cc (set_ntea): New function. - (set_ntsec): Ditto. - (set_smbntsec): Ditto. - (parse_thing): Change ntea, ntsec and smbntsec settings to call - appropriate functions. - -2004-08-20 Corinna Vinschen - - * fhandler_tape.cc (fhandler_dev_tape::raw_read): Use ?: instead of - if/else. - (fhandler_dev_tape::raw_write): Return -1 in case of error. - -2004-08-19 Corinna Vinschen - - * errno.cc (_sys_errlist): Change various text to their english Linux - counterparts. Unify layout. - (strerror): Remove switch statement. - -2004-08-19 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Set shared flags to 0 when - opening a tape device. - -2004-08-19 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::dup): Increment dtable's - need_fixup_before counter on successful dup. - * net.cc (cygwin_getpeername): Add file descriptor to debug output. - -2004-08-17 Pierre Humblet - - * fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. - (fhandler_dev_dsp::open_count): Delete. - (fhandler_dev_dsp::close_audio_in): New method declaration. - (fhandler_dev_dsp::close_audio_in): Ditto. - * fhandler_dsp.cc: Add and edit debug_printf throughout. - (fhandler_dev_dsp::Audio::denyAccess): Delete. - (fhandler_dev_dsp::Audio::fork_fixup): Ditto. - (fhandler_dev_dsp::Audio::getOwner): Ditto. - (fhandler_dev_dsp::Audio::clearOwner): Ditto. - (fhandler_dev_dsp::Audio::owner_): Ditto. - (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. - (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. - (fhandler_dev_dsp::Audio::unlock): Ditto. - (fhandler_dev_dsp::Audio::lock_): Ditto. - (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out - and Audio_in. - (fhandler_dev_dsp::Audio::pHdr_): Ditto. - (fhandler_dev_dsp::Audio::wavehdr_): Ditto. - (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. - (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. - (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. - (fhandler_dev_dsp::Audio::queue::lock): New method. - (fhandler_dev_dsp::Audio::queue::unlock): Ditto. - (fhandler_dev_dsp::Audio::queue::dellock): Ditto. - (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. - (fhandler_dev_dsp::Audio::queue::lock_): New member. - (fhandler_dev_dsp::Audio::queue::depth1_): Delete. - (fhandler_dev_dsp::Audio_out::fork_fixup): New method. - (fhandler_dev_dsp::Audio_out::isvalid): New method. - (fhandler_dev_dsp::Audio_out::start): Remove arguments. - (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set - internal state. - (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. - (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. - (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. - (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. - (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. - (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. - (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. - (fhandler_dev_dsp::Audio_out::freq_): New member. - (fhandler_dev_dsp::Audio_out::bits_): New member. - (fhandler_dev_dsp::Audio_out::channels_): New member. - (fhandler_dev_dsp::Audio_in::fork_fixup): New method. - (fhandler_dev_dsp::Audio_in::isvalid): New method. - (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. - (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. - (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. - (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. - (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. - (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. - (fhandler_dev_dsp::Audio::queue::queue): Simplify. - (fhandler_dev_dsp::Audio::queue::send): Use lock. - (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. - (fhandler_dev_dsp::Audio::queue::recv): Ditto. - (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. - (fhandler_dev_dsp::Audio::~Audio): Ditto - (fhandler_dev_dsp::Audio_out::start): Reorganize. - (fhandler_dev_dsp::Audio_out::stop): Simplify. - (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. - (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. - (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. - (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. - (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. - (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. - (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. - Clear flag before requeuing. - (fhandler_dev_dsp::Audio_out::parsewav): - (fhandler_dev_dsp::Audio_in::start): Reorganize. - (fhandler_dev_dsp::Audio_in::stop): Simplify. - (fhandler_dev_dsp::Audio_in::queueblock): Ditto. - Requeue header in case of error. - (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. - (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. - Do not UnprepareHeader if the flag is zero. - (fhandler_dev_dsp::Audio_in::buf_info): Ditto. - (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. - (fhandler_dev_dsp::open_count): Delete. - (fhandler_dev_dsp::open): Only check existence, do not allocate - anything. Set flags appropriately. Create archetype. - (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. - (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. - (fhandler_dev_dsp::close): Call archetype as needed. - Call close_audio_in and close_audio_out. - (fhandler_dev_dsp::close_audio_in): New function. - (fhandler_dev_dsp::close_audio_out): New function. - (fhandler_dev_dsp::dup): Use archetypes. - (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for - new structures. - (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. - (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. - Clear audio_in and audio_out. - -2004-08-14 Pierre Humblet - - * fhandler.cc (fhandler_base::open_9x): Set file attributes - for new files. - -2004-08-11 Christopher Faylor - - * net.cc (cygwin_gethostbyname): Show failing host name on error. - -2004-08-10 Christopher Faylor - - * select.cc (select_stuff::wait): Correctly check for w4 array bounds. - -2004-08-03 Corinna Vinschen - - * errno.cc (errmap): Add ERROR_TOO_MANY_LINKS -> EMLINK mapping. - * syscalls.cc (link): Only copy files if FS doesn't support hard links. - -2004-07-26 Christopher January - - * fhandler_proc.cc (format_proc_cpuinfo): Remove Intel-specific flags - from /proc/cpuinfo on non-Intel processors. Added new AMD-specific - flags. Changed Intel flag names to match Linux. - -2004-07-24 Christopher Faylor - - * dcrt0.cc (dll_crt0_0): Use proper boolean arguments. - * pinfo.cc (pinfo::init): Don't consider MapViewOfFileEx error to be - fatal if exiting. - * pinfo.h (pinfo::init): Eliminate default argument and supply the - argument in the one case that needed it. - -2004-07-24 Corinna Vinschen - Christopher Faylor - - * autoload.cc (GetNativeSystemInfo): Add. - (IsWow64Process): Add. - * init.cc (respawn_wow64_process): New function. - (dll_entry): If process has been started from a 64 bit - process, call respawn_wow64_process. - * uname.cc (uname): On 64 bit systems, use GetNativeSystemInfo. - Show actual CPU type. - -2004-07-23 Corinna Vinschen - - * dtable.cc (dtable::get_debugger_info): Make stderr r/w according - to SUSv3. - -2004-07-22 Corinna Vinschen - - * fhandler_tty.cc (fhandler_tty_slave::open): Use requested flag - values also when copying fhandler from archetype. - -2004-07-22 Christopher Faylor - - * pinfo.cc (pinfo::init): Print handle in hex when MapViewOfFile fails. - -2004-07-20 Corinna Vinschen - - * shm.cc: Whitespace fixes. - -2004-07-20 Christopher Faylor - - * Makefile.in (clean): Remove cygwin.def since it is autogenerated. - -2004-07-19 Corinna Vinschen - - * fhandler_dsp.cc (fhandler_dev_dsp::Audio_out::init): Fix non-ISO - expression. - * fhandler_floppy.cc (fhandler_dev_floppy::open): Remove unused - variable. - * fhandler_proc.cc (format_proc_meminfo): Fix compiler warning. - -2004-07-16 Christopher Faylor - - * pinfo.cc (pinfo::init): Guard against MapViewOfFileEx failure. - -2004-07-15 Corinna Vinschen - - * mmap.cc (mmap_record::alloc_page_map): Mark pages as allocated even - on Windows 9x, FWIW. - -2004-07-15 Corinna Vinschen - - * mmap.cc (mprotect): When MAP_WRITE protection is requested, use - READWRITE or WRITECOPY protection, whatever has been used when the - page has been allocated initially. - -2004-07-15 Corinna Vinschen - - * fhandler.h (class fhandler_dev_raw): Remove is_writing flag. - Remove declaration of writebuf. - (class fhandler_dev_floppy): Remove declaration of close. - * fhandler_floppy.cc (fhandler_dev_floppy::close): Delete. - (fhandler_dev_floppy::lseek): Remove calls to writebuf. Set - eom_detected to false after successful seek. - * fhandler_raw.cc (fhandler_dev_raw::writebuf): Delete. - (fhandler_dev_raw::raw_read): Remove calls to writebuf. - (fhandler_dev_raw::raw_write): Always invalidate buffer. - -2004-07-15 Corinna Vinschen - - * mmap.cc (class mmap_record): Fix return type of get_offset. - (mmap_record::fixup_page_map): Fix off by one error. - (list::search_record): Use long as type of "start" argument in both, - declaration and definition. Use long as type for local variable "i". - -2004-07-14 Dave Korn - - * fhandler_registry.cc (registry_listing): Correct typo. - (fhandler_registry::fill_filebuf): Set size of newly expanded buffer - prior to calling RegQueryValueEx. - -2004-07-14 Corinna Vinschen - - * fhandler_raw.cc (fhandler_dev_raw::raw_write): Remove buffered - write entirely. - -2004-07-07 Corinna Vinschen - - * spawn.cc (spawn_guts): Check if script is executable. - -2004-06-30 Corinna Vinschen - - * times.cc (hires_ms::usecs): Don't overreact. - -2004-06-30 Corinna Vinschen - - * times.cc (hires_ms::usecs): Reinit timer when system time overflows. - -2004-06-27 Christopher Faylor - - * thread.cc (__cygwin_lock_lock): Don't bother locking when there is - only one known thread. - (__cygwin_lock_unlock): Ditto for unlocking. - -2004-06-23 Tomas Ukkonen - - * fhandler_proc.cc (format_proc_cpuinfo): Test CPU vendor and print - AMD specific 3dnow capabilities. - -2004-06-23 Pierre Humblet - - * fhandler_socket.cc (fhandler_socket::release): Call - WSASetLastError last. - -2004-06-21 Christopher Faylor - - * autoload.cc (wsock_init): Keep lock while modifying return address. - -2004-06-17 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Remove 9x specific code. - -2004-06-17 Pierre Humblet - - * fhandler.cc (fhandler_base::open_9x): Do not check for null name. - Move debug_printf to common code line. - (fhandler_base::open): Ditto. Initialize upath. Remove second argument - of pc.get_nt_native_path. - * path.h (path_conv::get_nt_native_path): Remove second argument. - * path.cc (path_conv::get_nt_native_path): Ditto. Call str2uni_cat. - * security.h (str2buf2uni_cat): Delete declaration. - (str2uni_cat): New declaration. - * security.cc (str2buf2uni): Get length from sys_mbstowcs call. - (str2buf2uni_cat): Delete function. - (str2uni_cat): New function. - * miscfuncs.cc (sys_mbstowcs): Add debug_printf. - -2004-06-17 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Substitute FILE_SUPERSEDE with - FILE_OVERWRITE_IF. - -2004-06-09 Christopher Faylor - - * include/cygwin/version.h: REALLY bump dll minor version to 11. - -2004-06-08 Egor Duda - - * include/cygwin/ipc.h: Make IPC_INFO visible only for ipc system - utilities, to make it consistent with declaration of struct seminfo. - -2004-06-08 Pierre Humblet - - * path.cc (fchdir): Pass the Posix path to chdir. - -2004-06-07 Christopher Faylor - - * dtable.cc (dtable::find_fifo): Release lock after fifo found (still - racy). - * fhandler.h (fhandler_fifo::get_io_handle): New fifo-specific method. - * fhandler_fifo.cc (fhandler_fifo::close): Close output_handle only if - it is open. - (fhandler_fifo::open_not_mine): Reorganize slightly. Don't call _pinfo - methods when the fifo is owned by me or suffer dtable lock_cs deadlock. - (fhandler_fifo::open): Call open_not_mine first, otherwise open myself - (racy). - * pinfo.cc (_pinfo::commune_recv): Duplicate fifo handles here in - requesting processes arena to avoid one potential race (of many). - (_pinfo::commune_send): Move all PICOM_FIFO code under one case - statement. - - * thread.cc (pthread::init_mainthread) Use existing hMainProc handle - rather than calling GetCurrentProcess. - -2004-06-04 Christopher Faylor - - * winbase.h (ilockincr): Add more neverending changes from the - inexplicable world of gcc asm constraint magic. Should stop random - crashes. - (ilockdecr): Ditto. - -2004-06-03 Christopher Faylor - - * autoload.cc (IsDosDeviceName_U): Define. - * ntdll.h (IsDosDeviceName_U): Declare. - * fhandler.cc (fhandler_base::open): Check to see if win32_name is a - dos device and just call the 9x open if so. - -2004-06-03 Christopher Faylor - - * winbase.h (ilockincr): More changes from the inexplicable world of - gcc asm magic. - (ilockdecr): Ditto. - -2004-06-03 Christopher Faylor - - * winbase.h (ilockincr): YA correction to ensure correct operation with - no optimization. - (ilockdecr): Ditto. - -2004-06-03 Corinna Vinschen - - * cygserver.h (CYGWIN_SERVER_VERSION_API): Bump. - -2004-06-03 Corinna Vinschen - - * include/cygwin/ipc.h (IPC_KEY_IS_SHMID): Redefine to a more sensible - value. - -2004-06-02 Christopher Faylor - - * cygheap.cc (cmalloc): Add debugging hook. - -2004-06-02 Christophe Jaillet - - * spawn.cc (find_exec): Use has_slash to determine if path has a slash - rather than calculating this twice. - -2004-05-30 Pierre Humblet - - * path.cc (mount_info::add_item): Make sure native path has drive - or UNC form. Call normalize_xxx_path instead of [back]slashify. - Remove test for double slashes. Reorganize to always debug_print. - -2004-05-28 Pierre Humblet - - * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Only try to open - the file if it uses an acl. - -2004-05-28 Pierre Humblet - - * path.cc (chdir): Always use the normalized_path as posix_cwd, except - if it starts with a drive. - -2004-05-25 Christopher Faylor - - * winbase.h: Semi-revert previous patch as it caused strange behavior. - Use syntax similar to that recommended in mingw-dvlpr. - -2004-05-25 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number to 11. - -2004-05-25 Christopher Faylor - - * winbase.h: Add proper attributions for memory operands throughout. - -2004-05-24 Christopher Faylor - - * include/cygwin/version.h: Bump api minor version number. - -2004-05-24 Christopher Faylor - - * cygwin.din: Export atoll. - -2004-05-20 Christopher Faylor - - * tty.cc (tty_list::allocate_tty): Leave tty_mutex armed on successful - return from !with_console - * fhandler_tty.cc (fhandler_pty_master::open): Release tty_mutex here - after all initialization is done. - -2004-05-17 Corinna Vinschen - - * grp.cc (getgrgid_r): Replace struct group by struct __group32 in - argument definition. - (getgrnam_r): Ditto. - -2004-05-17 Corinna Vinschen - - * cygwin.din: Add symbols flockfile, ftrylockfile, funlockfile, - getgrgid_r, getgrnam_r and getlogin_r. - * grp.cc (getgrgid_r): New function. - (getgrnam_r): Ditto. - * syscalls.cc (flockfile): Ditto. - (ftrylockfile): Ditto. - (funlockfile): Ditto. - * sysconf.cc (sysconf): Return LOGIN_NAME_MAX in case of - _SC_LOGIN_NAME_MAX. - * thread.cc (__cygwin_lock_trylock): Define int. Return value from - call to pthread_mutex_trylock. - * uinfo.cc (getlogin_r): New function. - * include/limits.h: Define LOGIN_NAME_MAX. - * include/cygwin/version.h: Bump API minor number. - * include/sys/lock.h: Add declarations for __cygwin_lock_xxx functions. - * include/sys/stdio.h: Add define for _ftrylockfile. - -2004-05-17 Christopher Faylor - - * tty.cc (tty_list::init): Move hmaster initialization earlier to - prevent compilation error. - -2004-05-17 Christopher Faylor - - Change the name "title_mutex" to "tty_mutex" throughout. - * tty.h (tty_list::allocate_tty): Turn argument into a boolean. - * tty.cc (tty_list::init): Protect entire allocation operation with - tty_mutex (formerly title_mutex) to protect against allocation races. - -2004-05-16 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::recvfrom): Use original flags - value in each WSARecvFrom call. - (fhandler_socket::recvmsg): Ditto. Reformat slightly. - -2004-05-15 Christopher Faylor - - * cygthread.cc (cygthread::is): Eliminate. - * cygthread.h (cygthread::is): Eliminate declaratin. - * fhandler_console.cc (fhandler_console::read): Only wait for - signal_arrived in the main thread. - * fhandler_socket.cc: Include new "wininfo.h". - (fhandler_socket::ioctl): Use 'winmsg' rather than 'gethwnd()'. - * sync.cc (muto::grab): Define new function. - (muto::acquire): Use tls pointer rather than tid. - (muto::acquired): Ditto. - (muto::reset): Delete. - (muto::release): Ditto. Also implement "close on last release". - * sync.h (muto::tid): Delete. - (muto::tls): New field. - (muto::ismine): Delete. - (muto::owner): Delete. - (muto::unstable): Delete. - (muto::reset): Delete. - (muto::upforgrabs): New method. - (muto::grab): Ditto. - (new_muto_name): New define. - * wininfo.h: New file. - (wininfo): New class. - * window.cc: Rework throughout to use winfo class for controlling - invisible window operation. - (gethwnd): Delete definition. - * winsup.h (gethwnd): Delete declaration. - -2004-05-15 Christopher Faylor - - * cygheap.h: Remove some parameter names from declarations throughout. - (cygheap::set): Reflect changes in declaration for arguments and return - value from previous checkin. - -2004-05-15 Pierre Humblet - - * cygheap.h (cwdstuff::set): Modify return value and arguments. - * path.cc (chdir): Specify PC_POSIX. Do not call SetCurrentDirectory. - Set posix_cwd in a way that does not break find.exe. Change call to - cwd.set. - (cwdstuff::get_initial): Do not call GetCurrentDirectory here. - (cwdstuff::set): Call SetCurrentDirectory and GetCurrentDirectory as - needed. - -2004-05-12 Corinna Vinschen - - * path.cc (path_conv::check): Don't bail out with error if path is "//". - -2004-05-12 Corinna Vinschen - - * cygheap.h (struct init_cygheap): Add mt_h member. - * fhandler_tape.cc (mt_h): Drop in favor of cygheap based handle. - (mtinfo_init): Use cygheap->mt_h handle. Protect it. - -2004-05-12 Pierre Humblet - - * tty.h: Remove the %d or %x from all cygtty strings. - (tty::open_output_mutex): Only declare. - (tty::open_input_mutex): Ditto. - (tty::open_mutex): New definition. - * fhandler_tty.cc (fhandler_tty_slave::open): Declare buf with - size CYG_MAX_PATH and replace __small_printf calls by shared_name. - * tty.cc (tty::create_inuse): Ditto. - (tty::get_event): Ditto. - (tty::common_init): Ditto. - (tty::open_output_mutex): New method definition. - (tty::open_input_mutex): Ditto. - (tty::open_mutex): New method. - -2004-05-11 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Set file attributes to correct - value when creating files. - * path.h (class path_conv): Add write accessor for file_attributes. - -2004-05-10 Corinna Vinschen - - * fhandler.h (class fhandler_socket): Add "owner" status flag. - * fhandler_socket.cc (wait): Take flag parameter to take FD_OOB into - account. Don't wait infinitely. - (fhandler_socket::recvfrom): Also wait for FD_OOB if socket owner. - (fhandler_socket::recvmsg): Ditto. - (fhandler_socket::sendto): Ditto. - (fhandler_socket::sendmsg): Ditto. - (fhandler_socket::fcntl): Set owner status flag if F_SETOWN with own - pid is called. - -2004-05-09 Pierre Humblet - - * environ.cc (build_env): Only try to construct required-but-missing - variables while issetuid. - -2004-05-08 Pierre Humblet - Christopher Faylor - - * syscalls.cc: Include environ.h. - (chroot): Set errno in case of path error. Call getwinenv. - * environ.cc: Remove the NO_COPY attribute of conv_envvars. - -2004-05-07 Corinna Vinschen - - * fhandler_mem.cc (fhandler_dev_mem::fhandler_dev_mem): Move - initialization of "mem_size" from here... - (fhandler_dev_mem::open): ...to here. Fix typo in FH_PORT case. - -2004-05-07 Gerd Spalink - - * fhandler_dsp.cc (fhandler_dev_dsp::Audio_out::stop): Move delete of - bigwavebuffer_ so that it is always cleaned, also in child processes. - (fhandler_dev_dsp::Audio_in::stop): Ditto. - (fhandler_dev_dsp::close): Stop audio play immediately in case of - abnormal exit. - -2004-05-07 Corinna Vinschen - - Revert code reversion from 2004-04-03. So, revert to async I/O again. - * fhandler.h (status): Add "closed" flag. - (prepare): New method declaration. - (wait): Ditto. - (release): Ditto. - * fhandler_socket.cc: Don't include wsock_event.h. - (fhandler_socket::prepare): New method, moved from wsock_event. - (fhandler_socket::wait): Ditto. - (fhandler_socket::release): New method. - (fhandler_socket::recvfrom): Simplify loop. - (fhandler_socket::recvmsg): Ditto. - (fhandler_socket::sendto): Ditto. - (fhandler_socket::sendmsg): Ditto. - * net.cc: Don't include wsock_event.h. - (wsock_event::prepare): Remove. - (wsock_event::wait): Ditto. - * wsock_event.h: Remove. - -2004-05-06 Christopher Faylor - - * thread.cc (pthread::create): Move postcreate call to avoid a - potential race. - (pthread::cancelable_wait): Don't allow signal interrupt unless main - thread. - -2004-05-07 Pierre Humblet - Christopher Faylor - - * path.cc (mount_info::conv_to_posix_path): Return proper status when - chrooted. - -2004-05-06 Pierre Humblet - - * path.cc (path_conv::check): Strip trailing dots and spaces and - return error if the final component had only dots and spaces. - (normalize_posix_path): Revert 2004-04-30. - (chdir): Do not check for trailing spaces. Do not set native_dir - to c:\ for virtual devices. Pass only native_dir to cwd.set. - (cwdstuff::set): Assume posix_cwd is already normalized. - -2004-05-04 Christopher Faylor - - * path.cc (normalize_win32_path): Detect components with only dots. - Remove a final . if it follows '\\'. - (mount_info::conv_to_win32_path): Only backslashify the path when no - mount is found. - (chdir): Do not look for components with only dots. - -2004-05-04 Pierre Humblet - Christopher Faylor - - * path.cc (is_unc_share): Remove redundant tests. - -2004-05-04 Corinna Vinschen - - * crt0.o (mainCRTStartup): 16 byte align stack for main function. - -2004-05-04 Corinna Vinschen - - * path.cc (check_sysfile): Don't scan string twice. - -2004-05-03 Corinna Vinschen - - * dir.cc (writable_directory): Remove. - (mkdir): Remove call to writable_directory. - * syscalls.cc (unlink): Ditto. - (rename): Ditto. - * winsup.h (writable_directory): Remove declaration. - -2004-04-30 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Call path_conv::get_nt_native_path - for evaluating NT path. - * path.cc (normalize_posix_path): Remove trailing dots and spaces. - (path_conv::get_nt_native_path): New function. - * path.h (class path_conv): Declare get_nt_native_path method. - -2004-04-30 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Fix NT native path evaluation - to allow opening serial ports. - -2004-04-30 DJ Delorie - - * init.cc (threadfunc_fe): Hack to make thread stacks always 16 - byte aligned. - -2004-04-21 Yitzchak Scott-Thoennes - - * syscalls.cc (lseek64): Fix debug_printf format string. - (truncate64): Ditto. - -2004-04-21 Corinna Vinschen - - * fhandler.cc (fhandler_base::lseek): Force res to -1 on error. - -2004-04-20 Christopher Faylor - - * path.cc (is_unc_share): Rename from slash_unc_prefix_p throughout. - -2004-04-20 Pierre Humblet - - * path.cc (normalize_posix_path): Process all Posix paths and map three - or more initial slashes to a single one. Simplify processing following - two initial slashes. - (normalize_win32_path): Make last argument non-optional and do not - check for NULL value. - -2004-04-20 Pierre Humblet - - * fhandler_disk_file.cc (fhandler_base::open_fs): Change - set_file_attribute call to indicate that NT security isn't used. - (fhandler_disk_file::fchmod): Rearrange to isolate 9x related - statements. - Do not set FILE_ATTRIBUTE_SYSTEM. - (fhandler_disk_file::fchown): Check noop case first. - * fhandler.cc (fhandler_base::open9x): Remove ntsec related statements. - (fhandler_base::set_name): Do not set namehash. - * fhandler.h (fhandler_base::get_namehash): Compute and set namehash if - needed. - * syscalls.cc (access): Verify that fh is not NULL. Do not set PC_FULL. - (chmod): Ditto. - (chown_worker): Ditto. - (stat_worker): Ditto. Verify if the path exists. - -2004-04-20 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Remove special DEV_FLOPPY_MAJOR - treatment. - * fhandler_raw.cc (fhandler_dev_raw::open): Simplify write-only case. - * fhandler_tape.cc (fhandler_dev_tape::raw_write): Add accidentally - dropped condition. - -2004-04-20 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Add FILE_READ_ATTRIBUTES when - only GENERIC_WRITE access is requested. - -2004-04-19 Corinna Vinschen - - * include/cygwin/mtio.h (GMT_ASYNC): New define. - (MT_ST_ASYNC_WRITES): Remove "Not supported" comment. - -2004-04-19 Corinna Vinschen - - * errno.cc (errmap): Handle ERROR_IO_PENDING. - * fhandler.cc (fhandler_base::open): Make tape I/O asynchronous. - * fhandler.h (class fhandler_dev_tape): Add mt_evt member. - * fhandler_tape.cc (mtinfo_drive::initialize): Initialize async_writes. - (mtinfo_drive::close): Handle async writes. - (mtinfo_drive::read): Add mt_evt parameter. Use overlapped I/O. - (mtinfo_drive::async_wait): New function. - (mtinfo_drive::write): Add mt_evt parameter. Use overlapped I/O. - Handle async writes. - (mtinfo_drive::_set_pos): Handle async writes. - (mtinfo_drive::set_partition): Ditto. - (mtinfo_drive::prepare): Ditto. - (mtinfo_drive::get_status): Drop useless "else". Handle async_writes - flag. - (mtinfo_drive::set_options): Handle async_writes flags. - (fhandler_dev_tape::close): Close mt_evt handle. - (fhandler_dev_tape::raw_read): Create mt_evt handle and use in call - to mtinfo_drive::read. - (fhandler_dev_tape::raw_write): Create mt_evt handle and use in call - to mtinfo_drive::write. - * mtinfo.h (MTINFO_VERSION): Bump. - (enum dirty_state): Add async_write_pending state. - (class mtinfo_drive): Add OVERLAPPED struct "ov". Add async_writes - flag. - (mtinfo_drive::async_wait): Add declaration. - (mtinfo_drive::read): Add mt_evt parameter. - (mtinfo_drive::write): Ditto. - - * registry.cc (load_registry_hive): Call enable_restore_privilege - instead of set_process_privilege. - -2004-04-19 Corinna Vinschen - - * fhandler_tape.cc (mtinfo_drive::_set_pos): Take additional dont_wait - parameter. Use in call to SetTapePosition. - (mtinfo_drive::set_pos): Accommodate _set_pos calls to above change. - (mtinfo_drive::set_partition): Ditto. - * mtinfo.h (mtinfo_drive::_set_pos): Change declaration accordingly. - -2004-04-16 Corinna Vinschen - - * autoload.cc (NtCreateFile): Add. - * dir.cc (mkdir): Change set_file_attribute call to indicate that - NT security isn't used. - * fhandler.cc (fhandler_base::open_9x): New method, created from - fhandler_base::open. - (fhandler_base::open): Rearrange to use NtCreateFile instead of - CreateFile. - * fhandler.h (enum query_state): Redefine query_null_access to - query_stat_control. query_null_access isn't allowed in NtCreateFile. - (fhandler_base::open_9x): Declare. - * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use - query_stat_control first, query_read_control if that fails. - (fhandler_disk_file::fchmod): Call enable_restore_privilege before - trying to open for query_write_control. Don't fall back to - opening for query_read_control. - (fhandler_disk_file::fchown): Ditto. - (fhandler_disk_file::facl): Only request restore privilege and query - access necessary for given cmd. - * fhandler_raw.cc (fhandler_dev_raw::open): Call fhandler_base::open - instead of opening device here. - * ntdll.h (NtCreateFile): Declare. - * path.cc (symlink_worker): Change set_file_attribute call to indicate - that NT security isn't used. - * sec_acl.cc (getacl): Fix bracketing. - * sec_helper.cc (enable_restore_privilege): New function. - * security.cc (str2buf2uni_cat): New function. - (write_sd): Don't request restore permission here. - * security.h (set_process_privileges): Drop stale declaration. - (str2buf2uni): Declare. - (str2buf2uni_cat): Declare. - (enable_restore_privilege): Declare. - * syscalls.cc (fchown32): Return immediate success on 9x. - -2004-04-15 Christopher Faylor - - * autoload.cc (dll_chain1): Rename to dll_chain. Remove old dll_chain - code. - (wsock_init): Avoid unneeded winsock_active tests. - * winsup.h (winsock_active): Delete. - -2004-04-15 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Try opening - in query_read mode if query_write fails. - * fhandler_disk_file.cc (fhandler_disk_file::fchown): Ditto. - * fhandler_disk_file.cc (fhandler_disk_file::facl): Ditto. - -2004-04-14 Corinna Vinschen - - * ntdll.h: Fix copyright date. - * sec_acl.cc (acl_worker): Delete allocated fhandler. - * syscalls.cc (chown_worker): Ditto. - (chmod): Ditto. - (stat_worker): Use get_namehash instead of hash_path_name. - -2004-04-14 Corinna Vinschen - - * sec_acl.cc (getacl): Avoid compiler warning. - * security.cc (write_sd): Ditto. Fix error handling. - -2004-04-14 Corinna Vinschen - - * syscalls.cc (fstat64): Use get_namehash instead of hash_path_name. - -2004-04-14 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Simplify access evaluation - expression. - (fhandler_base::facl): New method. - * fhandler.h: Declare facl method in fhandler_base, - fhandler_disk_file and fhandler_virtual. - * fhandler_disk_file.cc (fhandler_disk_file::facl): New method. - * fhandler_virtual.cc (fhandler_virtual::facl): New method. - * sec_acl.cc: Remove forward declaration for aclsort32 and acl32. - (setacl): Remove static. Add and use handle parameter. - (getacl): Ditto. - (acl_worker): Reorganize to call fhandler's facl method eventually. - (facl32): Ditto. - * security.cc (get_nt_object_security): Remove static. - * security.h: Add extern declarations for get_nt_object_security, - aclsort32, acl32, getacl and setacl. - -2004-04-14 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Accommodate query_write_control - query_state. - (fhandler_base::fchown): New method. - * fhandler.h: Declare fchown method in fhandler_base, - fhandler_disk_file and fhandler_virtual. - (enum query_state): Add query_write_control. - * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Set query_state - to query_write_control. Only remove FILE_ATTRIBUTE_READONLY if not - setting security descriptor. - (fhandler_disk_file::fchown): New method. - * fhandler_virtual.cc (fhandler_virtual::fchown): New method. - * sec_acl.cc (setacl): Call write_sd with additional handle attribute. - * security.cc (write_sd): Take handle argument. Only request owner - if getting SE_RESTORE_NAME privilege failed. Only open file if - NtSetSecurityObject failed or handle is NULL. - (set_nt_attribute): Call write_sd with additional handle attribute. - * security.h (write_sd): Declare with additional handle argument. - * syscalls.cc (chown_worker): Reorganize to call fhandler's fchown - method eventually. - (fchown): Ditto. - -2004-04-14 Corinna Vinschen - - * autoload.cc (NtSetSecurityObject): Add. - * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Only request - READ_CONTROL rights when opening the file. - * ntdll.h (NtSetSecurityObject): Add declaration. - * security.cc (write_sd): Call NtSetSecurityObject instead of - BackupWrite. - (get_nt_object_security): Don't free security descriptor here. - -2004-04-14 Corinna Vinschen - - * syscalls.cc (ttyname): Use buffer of length TTY_NAME_MAX + 1. - * sysconf.cc (sysconf): Handle _SC_TTY_NAME_MAX request. - * include/limits.h: Define TTY_NAME_MAX and _POSIX_TTY_NAME_MAX. - -2004-04-14 Corinna Vinschen - - * cygwin.din: Export rand_r and ttyname_r. - * syscalls.cc (ttyname_r): New function. - (ttyname): Move functionality to ttyname_r. Call it from here. - * include/cygwin/version.h: Bump API minor number. - -2004-04-14 Pierre Humblet - - * path.h (path_conv::set_symlink): Add argument. - (path_conv::get_symlink_length): New method. - (path_conv::symlink_length): New member. - * path.cc (path_conv::check): Pass symlen to set_symlink. - * fhandler_disk_file.cc (fhandler_base::fstat_helper): For symlinks - set st_size from get_symlink_length. - -2004-04-13 Corinna Vinschen - - * security.cc (set_nt_attribute): Only call get_nt_object_security - if handle is NULL. - -2004-04-13 Corinna Vinschen - - * dir.cc (mkdir): Call set_file_attribute with additional handle - argument. - * fhandler.cc (fhandler_base::fchmod): New method. - * fhandler.h: Declare fchmod method in fhandler_base, - fhandler_disk_file and fhandler_virtual. - * fhandler_disk_file.cc (fhandler_disk_file::fchmod): New method. - (fhandler_base::open_fs): Call set_file_attribute with additional - handle argument. - * fhandler_virtual.cc (fhandler_virtual::fchmod): New method. - * path.cc (symlink_worker): Call set_file_attribute with additional - handle argument. - * security.cc (get_nt_object_security): New function. - (get_nt_object_attribute): Call get_nt_object_security. - (set_nt_attribute): Add handle argument. Call get_nt_object_security - first, read_sd only if that fails. - (set_file_attribute): Add handle argument. - * security.h (set_file_attribute): Declare with additional handle - argument. - * syscalls.cc (stat_suffixes): Move to beginning of file. - (chown_worker): Call set_file_attribute with additional handle argument. - (chmod): Reorganize to call fhandler's fchmod method eventually. - (fchmod): Ditto. - -2004-04-13 Corinna Vinschen - - * autoload.cc (NtQuerySecurityObject): Add. - * ntdll.h (STATUS_BUFFER_TOO_SMALL): Add definition. - (NtQuerySecurityObject): Add declaration. - * security.cc (get_nt_object_attribute): Always use - NtQuerySecurityObject to retrieve security descriptor. - -2004-04-13 Gerd Spalink - - * fhandler_dsp.cc (fhandler_dev_dsp::Audio_out::stop): Add optional - boolean argument so that playing can be stopped without playing - pending buffers. - (fhandler_dev_dsp::ioctl): Stop playback immediately for - SNDCTL_DSP_RESET. Do not reset audio parameters in this case. - Add support for ioctl SNDCTL_DSP_GETISPACE. - (fhandler_dev_dsp::Audio_out::emptyblocks): Now returns the number of - completely empty blocks. - (fhandler_dev_dsp::Audio_out::buf_info): p->fragments is now the number - of completely empty blocks. This conforms with the OSS specification. - (fhandler_dev_dsp::Audio_out::parsewav): Ignore wave headers that are - not aligned on four byte boundary. - (fhandler_dev_dsp::Audio_in::buf_info): New, needed for - SNDCTL_DSP_GETISPACE. - -2004-04-13 Corinna Vinschen - - * winsup.h (IMPLEMENT_STATUS_FLAG): New macro to define status flag - accessor methods unambiguously. - * fhandler.h: Use IMPLEMENT_STATUS_FLAG throughout where possible. - * fhandler_termios.cc (fhandler_termios::tcinit): Call corrected - accessor for initialized status flag. - * mtinfo.h (class mtinfo_drive): Use IMPLEMENT_STATUS_FLAG throughout. - * path.cc (fs_info::update): Remove duplicate call to flags(). - * path.h (struct fs_info): Use IMPLEMENT_STATUS_FLAG where possible. - (path_conv::is_auto_device): Fix spacing. - * tty.h (class tty_min): Use IMPLEMENT_STATUS_FLAG throughout. - -2004-04-12 Christopher Faylor - - * thread.cc (pthread::thread_init_wrapper): Wait later to get more - parallel behavior. - -2004-04-12 Christopher Faylor - - * thread.cc (pthread::create): Use thread mutex to control - synchronization rather than creating a suspended thread. Wait for - "cancellation event" to indicate that started thread has been properly - initialized. - (pthread::thread_init_wrapper): Use set_tls_self_pointer() to set tid - and cygtls. Signal with cancel_event when done. - -2004-04-12 Pierre Humblet - - * path.cc (path_conv::check): Fix "tail filling" logic. - -2004-04-11 Christopher Faylor - - * cygheap.h: Replace inexplicably removed closing brace. - -2004-04-11 Christopher Faylor - - * cygheap.h (CYGHEAP_SLOP): Reduce drastically to avoid collisions. - -2004-04-11 Pierre Humblet - - * dtable.cc (dtable::extend): Change order of memcpy and cfree. - -2004-04-10 Corinna Vinschen - - * syscalls.cc (sync): Define void according to SUSv3. - -2004-04-10 Corinna Vinschen - - * sec_acl.cc (setacl): Use correct offset when trying to combine - standard and default entry of same type. - -2004-04-10 Pierre Humblet - - * fhandler.cc (rootdir): Add and use second argument. - * winsup.h (rootdir): Add second argument in declaration. - * path.cc (fs_info::update): Modify call to rootdir. - * syscalls.cc (check_posix_perm): Ditto. - (statfs): Ditto. Move syscall_printf near top. - -2004-04-10 Corinna Vinschen - - * Use new unified status_flag accessor methods from classes fhandler_*, - tty_min, mtinfo and fs_info thoroughout. - * fhandler.h: Redefine all set_close_on_exec methods to take a bool - argument. - (enum conn_state): Rename from connect_state. - (class fhandler_base): Rename some status flags to align with - accessor method names. Drop encoded flag entirely. Unify status - accessor methods. Const'ify all read accessor methods. - (class fhandler_socket): Ditto. - (class fhandler_dev_raw): Ditto. - * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() - instead of evaluating FATness of file system here. - (fhandler_disk_file::opendir): Drop call to set_encoded(). - (fhandler_disk_file::readdir): Use pc.isencoded() directly. - * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. - * path.cc (fsinfo_cnt): Add. - (fs_info::update): Accommodate class changes. Evaluate file system - name specific flags right here. Add thread safety for reading and - writing global fsinfo array. - * path.h (enum path_types): Drop values for flags kept in fs already. - (struct fs_info): Move status informatin into private struct type - status_flags. Add accessor methods. Remove path and file system - name string arrays in favor of status bits. - (class path_conv): Use new fs_info status information where - appropriate. - (path_conf::fs_has_ea): Rename from fs_fast_ea. - (path_conf::fs_has_acls): New method. - (path_conf::root_dir): Remove. - (path_conf::volname): Remove. - * syscalls (statfs): Evaluate root dir locally. - * tty.h (class tty_min): Unify status accessor methods. Const'ify - all read accessor methods. - -2004-04-09 Thomas Pfaff - - * thread.h (pthread::init_mainthread): Remove parameter forked. - (pthread::set_tls_self_pointer): New static function. - * thread.cc (MTinterface::fixup_after_fork): Change call to - pthread::init_mainthread. - (pthread::init_mainthread): Remove parameter forked. Simplify thread - self pointer handling. - (pthread::self): Set thread self pointer to null_pthread if thread has - not been initialized. - (pthread::set_tls_self_pointer): New static function. - -2004-04-05 Pierre Humblet - - * path.cc (path_conv::check): Optimize symlink replacements. - -2004-04-09 Pierre Humblet - - * path.cc (normalize_posix_path): Add "tail" argument and set it. - Always have a final slash for directories. Pass 3rd argument to - normalize_win32_path. - (path_conv::check): Pass tail to normalize_posix_path. Set - need_directory and remove final slash after that call. Remove last - argument to mount_table->conv_to_win32_path(). Remove noop dostail - check. Remove fs.update() from inner loop. Improve tail finding - search. - (normalize_win32_path): Add and set tail argument. - (mount_item::build_win32): Avoid calling strcpy. - (mount_info::conv_to_win32_path): Remove third argument and simplify - because the source is normalized. Keep /proc path in Posix form. Call - win32_device_name() only once. - (mount_info::conv_to_posix_path): Add and use 3rd argument to - normalize_win32_path to avoid calling strlen. - (cwdstuff::set): Add 3rd argument to normalize_posix_path and remove - final slash if any. - * shared_info.h (mount_info::conv_to_win32_path): Remove last argument - in declaration. - -2004-04-09 Corinna Vinschen - - * fhandler.h (class fhandler_dev_raw): Move status bits into protected - bitfield struct type status_flags. Drop unused has_written bit. - Add accessor methods. - (fhandler_dev_raw::clear): Remove. - (fhandler_dev_raw::reset_devbuf): Remove. - * fhandler_floppy.cc (fhandler_dev_floppy::lseek): Use accessor method - for is_writing. - * fhandler_raw.cc: Use status accessor methods throughout. - (fhandler_dev_raw::clear): Remove. - (fhandler_dev_raw::fhandler_dev_raw): Drop clear call. - (fhandler_dev_raw::~fhandler_dev_raw): Ditto. - * fhandler_tape.cc: Use mtinfo::status accessor methods throughout. - (mtinfo_drive::close): Fix conditional to enable BSD semantics - correctly. - (mtinfo_drive::get_status): Rename from mtinfo_drive::status. - * mtinfo.h (class mtinfo_drive): Move status bits into private bitfield - struct type status_flags. Add accessor methods. - Rename status method to get_status. - -2004-04-09 Corinna Vinschen - - * path.cc (fsinfo): Global storage for file system information. - (fs_info::update): Store file system information also in fsinfo and - short circuit GetVolumeInformation by using alredy stored file system - information. - -2004-04-09 Corinna Vinschen - - * fhandler.h (fhandler_base::status): Declare private. - (fhandler_base::open_status): Ditto. - (class fhandler_socket): Move status bits into private bitfield struct - type status_flags. Change accessor methods appropriately. - * fhandler_socket.cc (fhandler_socket::fhandler_socket): Accommodate - above status bit changes. - * tty.h: Remove status bit enumerator. - (TTYISSETF): Remove. - (TTYSETF): Remove. - (TTYCLEARF): Remove. - (TTYCONDSETF): Remove. - (tty_min::status): Define as private bitfield struct type status_flags. - Add appropriate accessor methods. - * fhandler_console.cc: Use tty_min::status accessor methods throughout. - * fhandler_termios.cc: Ditto. - * winsup.h (__ISSETF): Remove. - (__SETF): Remove. - (__CLEARF): Remove. - (__CONDSETF): Remove. - -2004-04-09 Corinna Vinschen - - * fhandler.cc (fhandler_base::write): Use bool parameter in calls to - set_did_lseek. - (fhandler_base::fhandler_base): Accommodate new status and open_status - constructor. - * fhandler.h: Remove status bit enumerator. - (FHDEVN): Remove. - (FHISSETF): Remove. - (FHSETF): Remove. - (FHCLEARF): Remove. - (FHCONDSETF): Remove. - (FHSTATOFF): Remove. - (UNCONNECTED, CONNECT_PENDING, CONNECTED): Substitute by enum - connect_state. - (fhandler_base::status): Define as bitfield struct type status_flags. - Remove unused flags entirely. Accommodate all status access methods. - (open_status): Define as bitfield struct type status_flags. - (fhandler_socket): Move socket related status bits to here. Redefine - had_connect_or_listen to be part of these status bits. Accommodate - related access methods. - * fhandler_disk_file.cc (fhandler_base::fstat_helper): Use pc.issymlink - instead of dropped method get_symlink_p. - (fhandler_base::open_fs): Remove setting dropped status flags. - * fhandler_socket.cc: Use values from enum connect_state throughout. - (fhandler_socket::fhandler_socket): Initialize status bits. - * fhandler_virtual.cc (fhandler_virtual::open): Remove setting dropped - status flags. - * net.cc: Use values from enum connect_state throughout. - * select.cc: Ditto. - * shared_info.h: Protect struct console_state using _FHANDLER_H_ - instead of FHDEVN. - -2004-04-09 Corinna Vinschen - - * security.cc (get_file_attribute): Fix conditional. - -2004-04-08 Christopher Faylor - - * child_info.h: Update CHILD_INFO_MAGIC after 2004-04-03 change. - -2004-04-08 Corinna Vinschen - - * path.cc (hash_path_name): Replace hash algorithm with SDBM. - -2004-04-08 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Set query access mode according - to query_open setting. - (fhandler_base::fhandler_base): Initialize query_open. - * fhandler.h (FH_QUERYOPEN): Drop. - (enum query_state): Add. - (class fhandler_base): Add query_open member. - (fhandler_base::get_query_open): Redefine to use query_open. - (fhandler_base::set_query_open): Ditto. - * fhandler_disk_file.cc (fhandler_base::fstat_fs): Remove O_DIROPEN - from open_flags since it's added in open_fs anyway. Remove - query_open_already. Use new query_open settings. Rearrange slightly. - (fhandler_base::fstat_helper): Add get_io_handle as parameter to - get_file_attribute. - * security.cc (get_nt_object_attribute): Make returning an int. - Return -1 on error, 0 otherwise. - (get_file_attribute): Take an object handle as argument. Move down - to allow calling get_nt_object_attribute in case a non-NULL handle - is given. - * security.h (get_file_attribute): Add handle to argument list. - * syscalls.cc (chown_worker): Accommodate new definition of - get_file_attribute. - -2004-04-07 Pierre Humblet - - * path.cc (path_prefix_p): Optimize test order. - -2004-04-06 Corinna Vinschen - - * Makefile.in (EXTRALIBS): Add libtextreadmode.a. - (INSTOBJS): Add textreadmode.o. - * textreadmode.c: New file. - -2004-04-06 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::fstat_helper): Request - compressed size only if the matching attributes are set. Use - NtQueryInformationFile instead of GetCompressedFileSize. - (fhandler_base::fstat_by_handle): Remove NT 3.5 cruft since - local.dwVolumeSerialNumber isn't used subsequently. - * ntdll.h: Add typedefs for FILE_COMPRESSION_INFORMATION and - FILE_INFORMATION_CLASS. - -2004-04-06 Corinna Vinschen - - * fhandler_raw.cc (fhandler_dev_raw::open): Actually use "options". - -2004-04-04 Gerd Spalink - - * fhandler_dsp.cc (fhandler_dev_dsp::ioctl): Add implementation - for ioctl codes SNDCTL_DSP_CHANNELS and SNDCTL_DSP_GETCAPS. - -2004-04-03 Christopher Faylor - - * child_info.h (child_info::cygheap_reserve_sz): Rename from - cygheap_alloc_sz. - * cygheap.cc: Rename alloc_sz to reserve_sz throughout. - -2004-04-03 Corinna Vinschen - - * fhandler.h (class fhandler_socket): Remove has_been_closed member. - * fhandler_socket.cc (fhandler_socket::recvfrom): Revert to - overlapped I/O. - (fhandler_socket::recvmsg): Ditto. - (fhandler_socket::sendto): Ditto. - (fhandler_socket::sendmsg): Ditto. - * net.cc (wsock_event::prepare): Ditto. - (wsock_event::wait): Ditto. Evaluate overlapped result also after - calling CancelIo (thanks to Patrick Samson ). - (wsock_event::release): Remove. - * wsock_event.h: Revert to overlapped I/O. - -2004-04-02 Corinna Vinschen - - * net.cc (wsock_event::release): Use NULL handle in call to - WSAEventSelect to resolve KB 168349. - -2004-04-01 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::recvfrom): Rearrange loop - so that WSARecvFrom is always called before waiting. - (fhandler_socket::recvmsg): Ditto. - -2004-04-01 Corinna Vinschen - - * net.cc (wsock_event::wait): Make wsa_err an int. Don't set - ret to 0 if any error has happened. - -2004-04-01 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::sendto): Drop out of loop if - has_been_closed gets set. - (fhandler_socket::sendmsg): Ditto. - * net.cc (wsock_event::wait): Don't initialize evts. Don't try to - evaluate network events if WSAEnumNetworkEvents fails. - (wsock_event::release): Save last WSA error and set it again unless - resetting to blocking socket fails. - * wsock_event.h (class wsock_event): Remove destructor. - -2004-03-31 Corinna Vinschen - - * fhandler_tape.cc (mtinfo::initialize): Fix fatal error message. - -2004-03-31 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::recvfrom): Always initialize - ret to 0 when using in Winsock call. - (fhandler_socket::recvmsg): Ditto. - (fhandler_socket::sendto): Ditto. - (fhandler_socket::sendmsg): Ditto. - -2004-03-31 Corinna Vinschen - - * fhandler_tape.cc (mtinfo_drive::get_pos): Only set partition if - GetTapePosition returned a non-zero partition number. - (mtinfo_drive::create_partitions): Reinitialize to partition 0. - Support TAPE_DRIVE_INITIATOR and TAPE_DRIVE_FIXED partitioning. - (mtinfo_drive::set_partition): Initialize new partition. - (mtinfo_drive::status): Readd accidentally dropped setting of mt_resid. - - * net.cc (wsock_event::prepare): Always print debug output in case - of error. - -2004-03-31 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::sendmsg): Add SIGPIPE handling. - -2004-03-31 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::recvfrom): Initialize res to - SOCKET_ERROR. Use SOCKET_ERROR instead of -1 throughout. - (fhandler_socket::recvmsg): Ditto. - (fhandler_socket::sendto): Ditto. - (fhandler_socket::sendmsg): Ditto. - * net.cc (wsock_event::prepare): Call WSASetLastError instead of - SetLastError. - (wsock_event::wait): Use SOCKET_ERROR instead of -1. - -2004-03-30 Thomas Pfaff - - * thread.h (pthread::init_mainthread): Add parameter forked. Set - forked default to false.. - * thread.cc (MTinterface::fixup_after_fork): Call - pthread::init_mainthread with forked = true. - (pthread::init_mainthread): Add parameter forked. Do not change thread - self pointer when forked. - -2004-03-30 Corinna Vinschen - - * shm.cc (shmat): If shmid is unknown, call a special variation - of shmget to retrieve the shared memory segment from Cygserver - instead of failing immediately. - * include/cygwin/ipc.h (IPC_KEY_IS_SHMID): New internal flag for - shmget when called from shmat. - -2004-03-29 Corinna Vinschen - - * fhandler.h (class fhandler_socket): Add has_been_closed member. - * fhandler_socket.cc (fhandler_socket::fhandler_socket): Initialize - has_been_closed to 0. - (fhandler_socket::recvfrom): Use new asynchronous I/O driven - wsock_event methods. - (fhandler_socket::recvmsg): Ditto. - (fhandler_socket::sendto): Ditto. - (fhandler_socket::sendmsg): Ditto. - * net.cc (wsock_event::prepare): Reimplement using asynchronous I/O. - (wsock_event::wait): Ditto. - (wsock_event::release): New method. - * wsock_event.h (class wsock_event): Remove ovr member. Accommodate - new implementation of prepare and wait methods. Add release method. - -2004-03-29 Thomas Pfaff - - * thread.cc (pthread::atforkprepare): Call - MT_INTERFACE->fixup_before_fork at the end of atforkprepare. - -2004-03-29 Corinna Vinschen - - * net.cc (wsock_event::wait): Change scope of local "len" variable. - -2004-03-28 Corinna Vinschen - - * shm.cc (shmat): Return (void *) -1 on error instead of NULL. - -2004-03-27 Christopher Faylor - - * fhandler_nodevice.cc (fhandler_nodevice::open): Assume that errno has - already been set if pc.error is nonzero. - -2004-03-26 Christopher Faylor - - * cygheap.cc (cygheap_fixup_in_child): Improve strace output. - -2004-03-26 Corinna Vinschen - - * errno.cc (errmap): Map ERROR_SHARING_VIOLATION to EBUSY, - ERROR_EOM_OVERFLOW and ERROR_NO_DATA_DETECTED to EIO. Add mappings - for ERROR_NO_MEDIA_IN_DRIVE, ERROR_DEVICE_REQUIRES_CLEANING and - ERROR_DEVICE_DOOR_OPEN. - * fhandler.h (class fhandler_dev_raw): Drop varblkop member. - (fhandler_dev_raw::is_eom): De-virtualize. - (fhandler_dev_raw::is_eof): Ditto. - (class fhandler_dev_tape): Drop lasterr and dp member. Add mt_mtx - member. Drop all private methods formerly used by ioctl. - (fhandler_dev_tape::is_rewind_device): Use get_minor for clarity. - (fhandler_dev_tape::driveno): New method. - (fhandler_dev_tape::drive_init): New method. - (fhandler_dev_tape::clear): Remove method. - (fhandler_dev_tape::is_eom): Ditto. - (fhandler_dev_tape::is_eof): Ditto. - (fhandler_dev_tape::write_file): Ditto. - (fhandler_dev_tape::read_file): Ditto. - (fhandler_dev_tape::_lock): New method. - (fhandler_dev_tape::unlock): New method. - (fhandler_dev_tape::raw_read): New method. - (fhandler_dev_tape::raw_write): New method. - * fhandler_raw.cc (fhandler_dev_raw::is_eom): New method. - (fhandler_dev_raw::is_eof): New method. - (fhandler_dev_raw::open): Allow setting write through option by - using the O_TEXT flag as ... flag. - (fhandler_dev_raw::writebuf): Remove usage of varblkop and other - tape specific code. - (fhandler_dev_raw::raw_read): Ditto. - (fhandler_dev_raw::dup): Ditto. - * fhandler_tape.cc: Rewrite tape operations entirely. Implement - new tape driver classes mtinfo, mtinfo_drive and mtinfo_part. - Reduce fhandler_dev_tape methods to mostly just calling appropriate - mtinfo_drive methods. - (mtinfo_init): New function adding the mtinfo shared memory area. - * mtinfo.h: New file, containing the definition of the new tape - driver classes. - * shared.cc: Include mtinfo.h. - (offsets): Add entry for mtinfo shared memory area. - (memory_init): Call mtinfo_init. - * shared_info.h (shared_locations): Add SH_MTINFO shared location. - * include/cygwin/mtio.h: Change and add various comments. Add GMT_xxx - macros for new generic flags. Add MT_ST_xxx bitfield definitions - for MTSETDRVBUFFER ioctl. - * include/cygwin/version.h: Bump API minor version number. - -2004-03-26 Christopher Faylor - - * path.cc (path_conv::check): Use 'strchr' rather than 'strrchr' to - find end of string, for efficiency. - -2004-03-26 Thomas Pfaff - - * include/cygwin/_types.h: New file. - * include/sys/lock.h: Ditto. - * include/sys/stdio.h: Ditto. - * thread.cc: Include sys/lock.h - (__cygwin_lock_init): New function. - (__cygwin_lock_init_recursive): Ditto. - (__cygwin_lock_fini): Ditto. - (__cygwin_lock_lock): Ditto. - (__cygwin_lock_trylock): Ditto. - (__cygwin_lock_unlock): Ditto. - (pthread::atforkprepare): Lock file pointer before fork. - (pthread::atforkparent): Unlock file pointer after fork. - (pthread::atforkchild): Ditto. - -2004-03-26 Corinna Vinschen - - * sem.cc (semget): Fix debug string. - (semop): Ditto. - * shm.cc (fixup_shms_after_fork): Ditto. - (shmat): Ditto. - (shmdt): Ditto. - (shmget): Ditto. - -2004-03-26 Christopher Faylor - - * sigproc.cc (wait_sig): Make sure that SIGCHLD is handled regardless - of whether a signal is queued. - -2004-03-26 Christopher Faylor - - * sigproc.cc (wait_sig): Report if not trying to send signal due to - queued signal. - -2004-03-25 Christopher Faylor - - * path.cc (normalize_posix_path): Reorganize to short circuit to DOS - path handling whenever a '\' is detected. - - * signal.cc (sigaction): Make strace output more informative. - * sigproc.cc (pending_signals::add): Just index directly into signal - array rather than treating the array as a heap. - (pending_signals::del): Ditto. - (wait_sig): Don't send signal if we already have a similar signal - queued. - * sigproc.h (call_signal_handler_now): Remove obsolete declaration. - -2004-03-23 Gerd Spalink - - * fhandler_dsp.cc (fhandler_dev_dsp::write): Remove type - cast from argument to audio_out_->parsewav() to make reference - work properly. Now .wav file headers are properly discarded. - -2004-03-23 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use created - handle regardless of nohandle state. Clean up afterwards. - -2004-03-23 Gerd Spalink - - * autoload.cc: Load eight more functions for waveIn support. - * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in - and class Audio_out members and audio_in_, audio_out_ pointers so - that future changes are restricted to file fhandler_dsp.cc. - * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat - things common to audio recording and playback. - Add more format conversions. - (fhandler_dev_dsp::Audio::queue): New queues for buffer management - to fix incomplete cleanup of buffers passed to the wave device. - (fhandler_dev_dsp::Audio_in): New, added class to implement audio - recording. - (fhandler_dev_dsp::Audio_out): Rework to use functionality provided - by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, - just before write. - (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated - here depends on audio rate/bits/channels. - (fhandler_dev_dsp::Audio_in::start): Ditto. - (fhandler_dev_dsp::setupwav): Replaced by following function. - (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device - any more. Discard wave header properly. - (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. - Protect against re-open. Activate fork_fixup. - (fhandler_dev_dsp::ioctl): Protect against actions when audio is - active. SNDCTL_DSP_GETFMTS only returns formats supported by - mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE - result now depends on current audio format. - (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio - classes to let them duplicate the CRITICAL_SECTION. - -2004-03-19 Pierre Humblet - Christopher Faylor - - * init.cc (munge_threadfunc): Handle all instances of search_for. - (prime_threads): Test threadfunc_ix[0]. - -2004-03-21 Christopher Faylor - - * cygheap.cc (init_cheap): Set initial_sz to something or suffer - spurious output. - (cygheap_fixup_in_child): Set alloc_sz to passed in size to ensure that - children will have the right size heap. - (_csbrk): Make output conditional on DEBUGGING. - -2004-03-21 Christopher Faylor - - * cygheap.cc (init_cheap): Conditionalize debugging code. - -2004-03-21 Christopher Faylor - - * cygheap.cc (init_cheap): Add ability to specify minimal cygwin heap - size when debugging. - (_csbrk): Report error in allocation to stderr. - (ccalloc): Ditto. - * dtable.cc (dtable::find_fifo): Remove use of atoms. - * dtable.h (dtable::find_fifo): Ditto. - * fhandler.h (fhandler_fifo): Ditto. - * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Ditto. - (fhandler_fifo::set_use): Ditto. - (fhandler_fifo::open_not_mine): Ditto. - (fhandler_fifo::open): Ditto. - * pinfo.cc (_pinfo::commune_recv): Ditto. - (_pinfo::commune_send): Ditto. - -2004-03-19 Pierre Humblet - - * dir.cc (rmdir): Reorganize error handling to reduce indentation. - -2004-03-19 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number to 10. - -2004-03-18 Christopher Faylor - - * child_info.h (CURR_CHILD_INFO_MAGIC): Reset to new value. - (child_info::cygheap_alloc_sz): New field. - * cygheap.cc (init_cheap): Reduce size of cygwin stack until minimal - hit when attempting initial allocation. - (cygheap_setup_for_child): Use alloc_sz to create secondary memory - mapped entry. Store alloc_sz in cygheap_alloc_sz. - (cygheap_fixup_in_child): Use cygheap_alloc_sz to map parent's cygheap. - * cygheap.h (_CYGHEAPSIZE_SLOP): New define. - (CYGHEAPSIZE): Use _CYGHEAPSIZE_SLOP. - -2004-03-18 Corinna Vinschen - - * fhandler_proc.cc (format_proc_meminfo): On NT, try to figure out - real swap file usage by requesting SystemPagefileInformation. Use - GlobalMemoryStatus as fallback. - * ntdll.h (_SYSTEM_INFORMATION_CLASS): Add SystemPagefileInformation. - (struct _SYSTEM_PAGEFILE_INFORMATION): Define. - -2004-03-17 Christopher Faylor - - * pipe.cc (fhandler_pipe::dup): Fix debugging message. - -2004-03-17 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number to 9. - -2004-03-16 Christopher Faylor - - * sigproc.cc (proc_terminate): Release sync_proc_subproc when done - terminating or suffer potential hangs. - (get_proc_lock): Reorganize debugging output slightly. - -2004-03-15 Christopher Faylor - - * cygtls.cc (_cygtls::fixup_after_fork): Just manipulate the signal - stack if a signal occurred during the parent's fork. Otherwise leave - it alone. - -2004-03-15 Christopher Faylor - - * exceptions.cc (try_to_debug): Report on tid of caller. - - * sync.cc (muto::acquire): Fix some races. - * sync.h (muto): Expose some fields for easier debugging. - -2004-03-15 Corinna Vinschen - - * fhandler.h (fhandler_dev_tape::tape_get_pos): Declare with extra - parameter for partition number. - (fhandler_dev_tape::_tape_set_pos): Ditto. - (fhandler_dev_tape::tape_partition): New method. - (fhandler_dev_tape::tape_set_partition): New method. - * fhandler_tape.cc (fhandler_dev_tape::open): Call private methods - directly instead of ioctl. - (fhandler_dev_tape::ioctl): Use long erase on MTERASE by default. - Don't use absolute positioning on MTSEEK. Call tape_set_partition - on MTSETPART, tape_partition on MTMKPART. - (fhandler_dev_tape::tape_get_pos): Add partition number parameter. - Prefer logical position information over absolute position information. - Return partition number. - (fhandler_dev_tape::_tape_set_pos): Add partition number parameter. - Use in SetTapePosition. - (fhandler_dev_tape::tape_set_pos): Remove special TAPE_ABSOLUTE_BLOCK - handling. - (fhandler_dev_tape::tape_erase): Rewind before erasing. - (fhandler_dev_tape::tape_status): Rearrange slightly. Try to get a - MediaType even if no tape is loaded. Store active partition in - mt_resid as on Linux. - (fhandler_dev_tape::tape_partition): New method. - (fhandler_dev_tape::tape_set_partition): New method. - * include/cygwin/mtio.h: Fix copyright. Add comment to explain - mt_resid content. - * include/cygwin/version.h: Bump API minor number. - -2004-03-14 Christopher Faylor - - * cygtls.cc (_cygtls::remove): Call remove_wq even when we can't - necessarily get the cygtls table lock. - * cygtls.h (_cygtls::remove_wq): Add wait argument. - * sigproc.cc (_cygtls::remove_wq): Honor wait argument when acquiring - lock. - (proc_terminate): Don't NULL sync_proc_subproc since other threads may - still try to access it. - -2004-03-14 Corinna Vinschen - - * errno.cc (errmap): Map ERROR_BEGINNING_OF_MEDIA and - ERROR_SETMARK_DETECTED to EIO instead of ESPIPE. - Handle ERROR_FILEMARK_DETECTED. - * fhandler_tape.cc (TAPE_FUNC): Add comment that ERROR_BUS_RESET - has still to be handled correctly. - (fhandler_dev_tape::open): Accommodate fact that get.mt_dsreg - also contains density code. - (fhandler_dev_tape::ioctl): Rearrange slightly. Reset devbuf also on - MTNOP, MTWSM, MTSETBLK, MTSETDRVBUFFER, MTSETPART and MTMKPART. - (fhandler_dev_tape::tape_set_pos): Rearrange. Match behaviour to - the Linux tape driver. - (fhandler_dev_tape::tape_status): Call IOCTL_STORAGE_GET_MEDIA_TYPES_EX - if available. Return device type and density code in appropriate - mtget members. - * wincap.h (wincaps::has_ioctl_storage_get_media_types_ex): New element. - * wincap.cc: Implement above element throughout. - * include/cygwin/mtio.h: Add tape device types as returned by - IOCTL_STORAGE_GET_MEDIA_TYPES_EX. - (MT_TAPE_INFO): Use above type codes. - (struct mtget): Change mt_dsreg comment. - -2004-03-14 Pierre Humblet - - * dir.cc (rmdir): Construct real_dir with flag PC_FULL. - Use a loop instead of recursion to handle the current directory. - -2004-03-14 Christopher Faylor - - * cygtls.cc (_cygtls::remove): Call remove_wq to ensure that wait stuff - is removed from proc_subproc linked list. - * cygtls.h (_cygtls::remove_wq): Declare. - * sigproc.cc (_cygtls::remove_wq): Define. - (proc_subproc): Label event handle appropriately. - * spawn.cc (spawn_guts): Return -1 when wait() fails for spawn types - that require waiting. - -2004-03-13 Corinna Vinschen - - * errno.cc (errmap): Handle ERROR_BUS_RESET. - * fhandler.h (fhandler_dev_raw::write_file): New method, created - from former static function. - (fhandler_dev_raw::read_file): Ditto. - (reset_devbuf): New inline method. - (class fhandler_dev_tape): Add TAPE_GET_DRIVE_PARAMETERS - member `dp'. - (fhandler_dev_tape::write_file): New method. - (fhandler_dev_tape::read_file): Ditto. - (fhandler_dev_tape::tape_get_feature): Convert to inline method. - (fhandler_dev_tape::tape_error): New method, created from former - static function. - (fhandler_dev_tape::tape_get_blocksize): Remove declaration. - * fhandler_raw.cc (fhandler_dev_raw::write_file): New method, created - from former static function. - (fhandler_dev_raw::read_file): Ditto. - (fhandler_dev_raw::writebuf): Accommodate the fact that no devbuf - exists under variable block size condition. - (fhandler_dev_raw::raw_read): Ditto. Add local p pointer to simplify - pointer arithmetic. - (fhandler_dev_raw::raw_write): Always set devbufend to 0 when starting - with writing. Accommodate the fact that no devbuf exists under - variable block size condition. - * fhandler_tape.cc: Various formatting changes. - (TAPE_FUNC): New macro. Use throughout as tape function loop. - (get_ll): Convert into macro. - (IS_EOM): New macro. - (IS_EOF): New macro. - (fhandler_dev_tape::is_eom): Use IS_EOM macro. - (fhandler_dev_tape::is_eof): Use IS_EOF macro. - (fhandler_dev_tape::write_file): New method. - (fhandler_dev_tape::read_file): New method. - (fhandler_dev_tape::open): Get drive information block here once. - (fhandler_dev_tape::lseek): Remove unneeded duplicate code. - (fhandler_dev_tape::dup): Duplicate drive information block. - (fhandler_dev_tape::ioctl): Remove drvbuf in variable block size mode. - Return ERROR_INVALID_BLOCK_LENGTH instead of ERROR_MORE_DATA if - buffer contains data which would get lost on buffer size changing. - Use absolute tape positioning also if drive only supports logical - block positioning. - (fhandler_dev_tape::tape_error): New method, created from former - static function. - (fhandler_dev_tape::tape_get_pos): Allow logical block reporting. - Workaround tape driver bug. - (fhandler_dev_tape::_tape_set_pos): Reset device buffer and flags - after successful repositioning. - (fhandler_dev_tape::tape_set_pos): Allow logical block positioning. - Workaround tape driver bug. - (fhandler_dev_tape::tape_erase): Use dp instead of calling - GetTapeParameters. - (fhandler_dev_tape::tape_prepare): Ditto. - (fhandler_dev_tape::tape_get_blocksize): Remove. - (fhandler_dev_tape::tape_set_blocksize): Don't call tape_get_blocksize. - Error handling already done in fhandler_dev_tape::ioctl. - (fhandler_dev_tape::tape_status): Remove local `dp' variable. - Accommodate logical tape reporting. Call tape_get_feature instead - of accessing feature words directly. - (fhandler_dev_tape::tape_compression): Use dp instead of calling - GetTapeParameters. Fix resetting datcompression. - -2004-03-12 Christopher Faylor - - * wait.cc (wait4): Initialize pointer on entry. Avoid calling - call_signal_handler twice since that guarantees exiting with errno set - to EINTR. - -2004-03-12 Corinna Vinschen - - * exceptions.cc (sigpacket::process): Simplify code slightly. - -2004-03-11 Christopher Faylor - - * cygtls.h (waitq): Declare structure here. - (_cygtls::wq): Declare. - * cygtls.cc (_cygtls::fixup_after_fork): Clear wq.thread_ev to avoid - using an invalid event handle in forked process. - * dcrt0.cc (waitq_storage): Delete. - (threadstuff): Remove waitq_storage. - * perthread.h (per_thread_waitq): Delete. - (waitq_storage): Delete declaration. - * sigproc.cc (sigproc_init): Remove perthread waitq consideration. - * sigproc.h (waitq): Delete declaration. - * wait.cc (wait4): Use _my_tls waitq structure rather than per_thread. - -2004-03-11 Pierre Humblet - - * cygtls.h (_cygtls::newmask): Delete member. - (_cygtls::deltamask): New member. - * gendef (_sigdelayed): Replace the call to set_process_mask by a call - to set_process_mask_delta. - * exceptions.cc (handle_sigsuspend): Do not filter tempmask. Or - SIG_NONMASKABLE in deltamask as a flag. - (_cygtls::interrupt_setup): Set deltamask only. - (set_process_mask_delta): New function. - (_cygtls::call_signal_handler): Replace the first call to - set_process_mask by a call to set_process_mask_delta. - * tlsoffsets.h: Regenerate. - -2004-03-11 Christopher Faylor - - * cygtls.cc (_cygtls::fixup_after_fork): Remove unneeded setting of - oldmask. - * exceptions.cc: Remove some __I386__ conditionals. - (handle_exceptions): Move ppid test to outside of a loop for - efficiency. - (setup_handler): Make debugging output more wordy. - (_cygtls::call_signal_handler): To avoid a race, use lock/unlock to - synchronize with signal thread and ensure that signal_arrived event has - actually been set. - * gendef (_sigfe): Use ebx for all sigstack manipulations to ensure - that the register is saved. Move setting of incyg to within stack lock - to avoid setup_handler confusion. - (_sigbe): Use ebx for all sigstack manipulations to ensure that the - register is saved. - (_cygtls::pop): Ditto. - (_cygtls::lock): Ditto. - (stabilize_sig_stack): Ditto. - (setjmp): Ditto. - (longjmp): Ditto. - -2004-03-08 Jaakko Hyvatti - - * fhandler_serial.cc (fhandler_serial::ioctl): Implement TIOCSBRK and - TIOCCBRK. - * include/sys/termios.h: Define TIOCSBRK and TIOCCBRK. - -2004-03-08 Christopher Faylor - - * exceptions.cc (setup_handler): Avoid suspending a thread if it is in - a cygwin function, in an exception, spinning, or locked. - * gendef (_sigfe): Move incyg setting earlier. - (sigreturn): Set incyg flag to avoid interrupting called cygwin - functions. - (sigdelayed): Ditto. - (stabilize_sig_stack): Ditto. - - * sigproc.cc (proc_subproc): Don't restore process lock early in exec - case. - - * cygtls.h: Reorganize fields in _cygtls slightly. - * tlsoffsets.h: Regenerate. - -2004-03-06 Christopher Faylor - - * fork.cc (fork_parent): Save parent pid in a temporary variable since - child could conceivably exit before function returns, rendering the - child's shared memory area invalid. - - * cygtls.h (_cygtls::incyg): Declare new field. - (_cygtls::in_exception): Define new function. - * exceptions.cc (setup_handler): Remove locked flag. Use 'incyg' flag - and in_exception function to determine when we're in a cygwin function. - (_cygtls::call_signal_handler): Decrement incyg flag prior to calling a - handler. Increment it on return. - * gendef (_sigfe): Increment incyg flag. Use testl for zero testing - rather than orl, for consistency. - (_sigbe): Decrement incyg flag. Use testl for zero testing rather than - orl, for consistency. - (_cygtls::pop): Use testl for zero testing rather than orl, for - consistency. - (stabilize_sig_stack): Ditto. - - * tlsoffsets.h: Regenerate. - -2004-03-05 Christopher Faylor - - * gendef (sigdelayed): Handle return here rather than going through - sigbe to ensure that flags are properly restored. - -2004-03-04 Thomas Pfaff - - * include/pthread.h (PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP): New - define. - (PTHREAD_NORMAL_MUTEX_INITIALIZER_NP): Ditto. - (PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP): Ditto. - * thread.cc (pthread_mutex::is_good_initializer): Check for all - posssible initializers - (pthread_mutex::is_good_initializer_or_object): Ditto. - (pthread_mutex::is_good_initializer_or_bad_object): Ditto. - (verifyable_object_isvalid): Support up to three static initializers. - (verifyable_object_isvalid (void const *,long)): Remove. - (pthread_cond::is_good_initializer_or_bad_object): Remove unneeded - objectState var. - (pthread_cond::init): Condition remains unchanged when creation has - failed. - (pthread_rwlock::is_good_initializer_or_bad_object): Remove unneeded - objectState var. - (pthread_rwlock::init): Rwlock remains unchanged when creation has - failed. - (pthread_mutex::init): Remove obsolete comment. Mutex remains - unchanged when creation has failed. Add support for new initializers. - (pthread_mutex_getprioceiling): Do not create mutex, just return - ENOSYS. - (pthread_mutex_lock): Simplify. - (pthread_mutex_trylock): Remove unneeded local themutex. - (pthread_mutex_unlock): Just return EPERM if mutex is not initialized. - (pthread_mutex_setprioceiling): Do not create mutex, just return - ENOSYS. - * thread.h (verifyable_object_isvalid): Support up to three static - initializers. - (verifyable_object_isvalid (void const *,long)): Remove prototype. - (pthread_mutex::init): Add optional initializer to parameter list. - -2004-03-03 Christopher Faylor - - * gendef (sigreturn): Call stabilize_sig_stack to ensure that there are - no pending signals. Restore edx later. - (sigdelayed): Save edx earlier. - - * malloc_wrapper.cc (malloc_init): Add some more debugging output. - -2004-03-02 Corinna Vinschen - - * fhandler_raw.cc (fhandler_dev_raw::raw_read): When reading with - variable block size, read only one block, read directly into user - supplied buffer, return ENOMEM if user supplied buffer is smaller - than size of next block to read. Use read2 instead of bytes_to_read - to count number of bytes read. - * fhandler_tape.cc (fhandler_dev_tape::open): Add debug output. - -2004-02-26 Brian Ford - - * miscfuncs.cc (check_invalid_virtual_addr): Assure the last page - in the range is always tested. Add appropriate const. - * mmap.cc (mmap_record::alloc_fh): Remove unused static path_conf object. - -2004-02-25 Christopher Faylor - - * exceptions.cc (setup_handler): Signal event for any sigwaitinfo, if it - exists, to force signal to be handled. Zero event here to prevent - races. - * signal.cc (sigwaitinfo): Use local handle value for everything since - signal thread could zero event element at any time. Detect when - awaking due to thread not in mask and set return value and errno - accordingly. Don't set signal number to zero unless we've recognized - the signal. - * sigproc.cc (sigq): Rename from sigqueue throughout. - - * thread.cc (pthread::join): Handle signals received while waiting for - thread to terminate. - -2004-02-25 Christopher Faylor - - * cygwin.din: Export sighold, sigqueue. - * exceptions.cc (sighold): Define new function. - * signal.cc (handle_sigprocmask): Set correct errno for invalid signal. - Simplify debugging output. - (sigqueue): Define new function. - * include/cygwin/signal.h (sighold): Declare new function. - (sigqueue): Ditto. - * include/cygwin/version.h: Bump API minor version number. - * include/limits.h (TIMER_MAX): Define. - (_POSIX_TIMER_MAX): Ditto. - -2004-02-25 Brian Ford , - Corinna Vinschen - - * miscfuncs.cc (check_invalid_virtual_addr): New function. - * winsup.h (check_invalid_virtual_addr): Declare. - * mmap.cc (munmap): Call check_invalid_virtual_addr instead of - IsBadReadPtr. - -2004-02-24 Christopher Faylor - - * gendef (stabilize_sig_stack): Correctly align this pointer for call - to _cygtls::call_signal_handler. - * gentls_offsets: Output sizeof field. - * tlsoffsets.h: Regenerate. - -2004-02-24 Christopher Faylor - - * dcrt0.cc (_dll_crt0): Don't check sync_startup if threadfunc_ix is set. - - * external.cc (cygwin_internal): Implement CW_GET_BINMODE. - * include/sys/cygwin.h: Declare CW_GET_BINMODE. - -2004-02-24 Christopher Faylor - - * dcrt0.cc (_dll_crt0): Add some stern internal errors. - -2004-02-24 Corinna Vinschen - - * thread.cc (pthread::cancelable_wait): Rearrange slightly. - Add do_sig_wait parameter. Wait for signal_arrived if set to true. - Return WAIT_SIGNALED if signal arrived. - (pthread_cond::wait): Accommodate change to pthread::cancelable_wait. - (pthread::join): Ditto. - (semaphore::_timedwait): Ditto. - (semaphore::_wait): Ditto. Change to return int to allow status - feedback. - (semaphore::wait): Return return value from semaphore::_wait. - * thread.h (WAIT_SIGNALED): New definition. - (pthread::cancelable_wait): Change declaration. Define do_sig_wait - as false by default to not interfere with existing calls accidentally. - (semaphore::_wait): Declare int. - -2004-02-21 Christopher Faylor - - * exceptions.cc (sigpacket::process): Make sure that tls is filled in - for SIGSTOP condition. - (_cygtls::call_signal_handler): Restore signal mask using saved oldmask - rather than current oldmask. - -2004-02-20 Christopher Faylor - - * path.cc (conv_path_list): Return error condition. - (copy1): New function. - (copyenc): New function. - (mount_item::fnmunge): Return error condition. Use new functions to - copy strings. - (mount_item::build_win32): Ditto. - (mount_info::conv_to_win32_path): Return error condition. - (cygwin_conv_to_posix_path): Return result of path conversion. - (cygwin_conv_to_full_posix_path): Ditto. - (return_with_errno): New macro. - (cygwin_win32_to_posix_path_list): Use new macro to potentially set - errno. - (cygwin_posix_to_win32_path_list): Ditto. - * path.h (mount_item::fnmunge): Add size argument. - (mount_item::build_win32): Ditto. - -2004-02-20 Corinna Vinschen - - * getopt.c: Avoid useless compiler warnings. - -2004-02-20 Corinna Vinschen - - * getopt.c: Replace with latest vanilla(!) OpenBSD version 1.16. - -2004-02-18 Christopher Faylor - - * fork.cc (fork_child): Invert sense of test which defeated correct - handling in a fork from a non-main thread. - - * dcrt0.cc (initial_env): Eliminate parameter and just send DebugBreak - when appropriate. - (dll_crt0_0): Reflect parameter change to initial_env. - (dll_crt0_1): Don't call initial_env. - -2004-02-18 Christopher Faylor - - * gendef (stabilize_sig_stack): New function. - (setjmp): Import, add sig stack handling. Store sig stack info. - (longjmp): Call stabilize_sig_stack. Restore sig stack info. - * config/i386/setjmp.c: Remove. - -2004-02-17 Corinna Vinschen - - * fork.cc (fork_child): Move fixup_shms_after_fork so that - signal_arrived is initialized when calling it. - -2004-02-17 Christopher Faylor - - * Makefile.in (clean): Clean libserver, too. - - * fhandler.cc (fhandler_base::~fhandler_base): Remove path_conv cleanup. - * syscalls.cc (chroot): Ditto. - * path.cc (path_conv::~path_conv): Define new destructor. - (conv_path_list_buf_size): Remove explicit path_conv cleanup. - * path.h (path_conv::~path_conv): Declare new destructor. - -2004-02-16 Christopher Faylor - - * Makefile.in: Compile flock.o with -fomit-frame-pointer. - -2004-02-16 Christopher Faylor - - * Makefile.in: Compile dlfcn.o with -fomit-frame-pointer. - -2004-02-16 Christopher Faylor - - * Makefile.in: Compile delqueue.o with -fomit-frame-pointer. - -2004-02-16 Pierre Humblet - - * syscalls.cc (rename): Do not test the MoveFile error code - where MoveFileEx exists. - -2004-02-15 Christopher Faylor - - * cygheap.cc (_csbrk): Report more debugging details on failing - condition. - -2004-02-14 Christopher Faylor - - * Makefile.in: Compile syscalls.o with -fomit-frame-pointer. - - * sigproc.cc: Eliminate unused variable. - -2004-02-14 Corinna Vinschen - - * getopt.c: Replace with latest NetBSD version 1.16. Keep Cygwin - specific changes as minimal as possible. - -2004-02-13 Christopher Faylor - - * sigproc.cc (proc_subproc): Change warning back to silent debug - output. - -2004-02-13 Christopher Faylor - - * dcrt0.cc (alloc_stack_hard_way): Revert to previous implementation. - (alloc_stack): Ditto. - * exceptions.cc (ctrl_c_handler): Add debugging output. - -2004-02-13 Christopher Faylor - - * Makefile.in (clean): Remove sigfe.s. - (sigfe.s): Ensure that sigfe.s will be regenerated if it does not exist. - * dll_init.cc (dll_dllcrt0): Simplify initializing tests. - - * exceptions.cc (setup_handler): Detect when stub caller is either - spinning or has acquired the lock after being suspended to avoid - windows problems with suspending a win32 API call. - - * cygtls.h (_cygtls::spinning): Declare new element. - * gendef: Remove unused _siglist_index and _siglist declaration. - (_sigfe): Set spinning element when potentially looping, waiting for lock. - (_sigbe): Ditto. - (_cygtls::lock): Ditto. - (_longjmp): Ditto. - * tlsoffsets.h: Regenerate. - * pinfo.cc (_pinfo::exit): Set final exit state here. Call sigproc_terminate if - invoked with 'norecord'. Clear any residual _cygtls stuff. - * winsup.h (exit_states): Define ES_FINAL. - * spawn.cc (spawn_guts): Don't call proc_terminate specifically when - execing. Let _pinfo::exit handle that case. - - * sigproc.cc (wait_subproc): Always exit loop early when proc_loop_wait. - - * init.cc (munge_threadfunc): Eliminate unused argument. - (dll_entry): Reflect above change in call to munge_threadfunc. - -2004-02-11 Christopher Faylor - - * gendef (_sigbe): Zero location on pop. - (_cygtls::pop): Ditto. - -2004-02-11 Christopher Faylor - - * dcrt0.cc (alloc_stack_hard_way): Eliminate second argument. - (alloc_stack): Remove use of 'b' throughout. - -2004-02-11 Christopher Faylor - - Rename _threadinfo to _cygtls, throughout. - * cygtls.h (_cygtls::call_signal_handler): Rename from - call_signal_handler_now. - (_cygtls::push): Make second argument mandatory. - (_cygtls::fixup_after_fork): Declare new function. - (_cygtls::lock): Ditto. - * cygtls.cc (_cygtls::fixup_after_fork): Define new function. - * dcrt0.cc (cygwin_finished_initializing): Define as bool. - (alloc_stack): Use _tlstop rather than arbitrary variable in probably - vain attempt to avoid strange fork problem on CTRL-C. - (dll_crt0_0): Remove obsolete winpids::init call. - * dll_init.cc (dll_dllcrt0): Detect forkee condition as equivalent to - initializing. - * winsup.h (cygwin_finished_initializing): Declare as bool. - * exceptions.cc (handle_exceptions): Rely on - cygwin_finished_initializing to determine how to handle exception - during process startup. - (_cygtls::call_signal_handler): Rename from call_signal_handler_now. - (_cygtls::interrupt_now): Fill in second argument to push. - (signal_fixup_after_fork): Eliminate. - (setup_handler): Initialize locked to avoid potential inappropriate - unlock. Resume thread if it has acquired the stack lock. - (ctrl_c_handler): Just exit if ctrl-c is hit before cygiwn has finished - initializing. - * fork.cc (sync_with_child): Don't call abort since it can cause exit - deadlocks. - (sync_with_child): Change debugging output slightly. - (fork_child): Set cygwin_finished_initializing here. Call _cygtls fork - fixup and explicitly call sigproc_init. - (fork_parent): Release malloc lock on fork failure. - (vfork): Call signal handler via _my_tls. - * sigproc.cc (sig_send): Ditto. - * syscalls.cc (readv): Ditto. - * termios.cc (tcsetattr): Ditto. - * wait.cc (wait4): Ditto. - * signal.cc (nanosleep): Ditto. - (abort): Ditto. - (kill_pgrp): Avoid killing self if exiting. - * sync.cc (muto::acquire): Remove (temporarily?) ill-advised - exiting_thread check. - * gendef (_sigfe): Be more agressive in protecting stack pointer from - other access by signal thread. - (_cygtls::locked): Define new function. - (_sigbe): Ditto. - (_cygtls::pop): Protect edx. - (_cygtls::lock): Use guaranteed method to set eax to 1. - (longjmp): Aggressively protect signal stack. - * miscfuncs.cc (low_priority_sleep): Reduce "sleep time" for secs == 0. - * pinfo.cc (winpids::set): Counterintuitively use malloc's lock to - protect simultaneous access to the pids list since there are - pathological conditions which can cause malloc to call winpid. - (winpids::init): Eliminate. - * pinfo.h (winpids::cs): Eliminate declaration. - * pinfo.h (winpids::init): Eliminate definition. - -2004-02-11 Corinna Vinschen - - * security.cc (get_nt_object_attribute): Fix error handling. - -2004-02-09 Ralf Habacker - - * fhandler_socket.cc (fhandler_socket::ioctl): Add FIONREAD handling. - -2004-02-08 Christopher Faylor - - * debug.h (console_printf): Define for non-debugging condition. - - * cygtls.h (_threadinfo::lock): Remove wait argument. - (_threadinfo::interrupt_setup): Remove retaddr argument. - * exceptions.cc (_threadinfo::interrupt_setup): Ditto. - (_threadinfo::interrupt_now): Accommodate change to interrupt_setup - argument. - (setup_handler): Ditto. Always lock sig stack prior to determining - interrupt method. - * gendef (_sigfe): Correct thinko regarding cmpxchg. - (_sigbe): Ditto. - (_threadinfo::lock): Ditto. - (_threadinfo::pop): Eliminate left-over stack unlock. - * sigproc.cc (proc_subproc): Change debugging output to printed - warning. - -2004-02-08 Christopher Faylor - - * localtime.cc (localtime_r): Call tzset. - - * Makefile.in: Make version.h/cygwin.din version check a warning since - it is not foolproof. - - * cygheap.h (CYGHEAPSIZE): Bump size down. - - * cygtls.h (_threadinfo::stacklock): New element. - (_threadinfo::pop): Make regparm. - (_threadinfo::lock): New function. - (_threadinfo::unlock): New function. - * cygtls.cc (_threadinfo::push): Wait for a lock on the stack before - performing the operation. - (_threadinfo::pop): Move to another file. - * cygwin.din: More SIGFE changes. - * exceptions.cc (try_to_debug): Always display messages on console. - (handle_exceptions): Unwind stack only when actually about to call - sig_send. - (setup_handler): Lock stack prior to performing any operations. - * gendef (_sigfe): Ditto. - (_sigbe): Ditto. - (_threadinfo::pop): Ditto. Move here. - * gen_tlsoffsets: Generate positive offsets. - * tlsoffsets.h: Regenerate. - -2004-02-06 Corinna Vinschen - - * cygserver.h (CYGWIN_SERVER_VERSION_API): Bump. - * cygserver_ipc.h (struct proc): Add signal_arrived member. - (ipc_set_proc_info): Inititalize blk.signal_arrived. - -2004-02-06 Pierre Humblet - - * uinfo.cc (cygheap_user::init): Use sec_user_nih to build a - security descriptor. Set both the process and the default DACLs. - * fork.cc (fork_parent): Use sec_none_nih security attributes. - * spawn.cc (spawn_guts): Ditto. - -2004-02-05 Christopher Faylor - - * cygwin.din: Make many more functions SIGFE. - * include/cygwin/version.h (CYGWIN_VERSION_SHARED_DATA): Bump. - -2004-02-05 Pierre Humblet - - * security.h (SID): New macro. - (well_known_*_sid): Change type to cygpsid. - (cygsid::init): Delete declaration. - * sec_helper.cc (well_known_*_sid): Define using above SID macro. - (cygsid::init): Delete. - * dcrt0.cc (dll_crt0_0): Do not call cygsid::init. - * security.cc (get_user_local_groups): Change the second argument type - to cygpsid. - -2004-02-03 Christopher Faylor - - * cygtls.h (_local_storage::signamebuf): Increase size to prevent - overflow on really odd values. - * tlsoffsets.h: Regenerate. - -2004-02-03 Christopher Faylor - - * Makefile.in (DLL_OFILES): Add strsig.o. - * cygtls.h (_local_storage::signamebuf): New element. - * sysconf.cc (sysconf): Implement _SC_RTSIG_MAX. - * tlsoffsets.h: Regenerate. - * include/limits.h (_POSIX_RTSIG_MAX): New define. - (RTSIG_MAX): Ditto. - * include/cygwin/signal.h (SIGRTMIN): New define. - (SIGRTMAX): Ditto. - (NSIG): Bump. - * strsig.cc: New file. - -2004-02-03 Jason Tishler - - * window.cc (Winmain): Show windows error code in error output when - RegisterClass fails. - -2004-02-02 Christopher Faylor - - * fhandler.h (*::fixup_after_exec): Eliminate unused handle argument. - * fhandler.h (dtable::fixup_after_exec): Eliminate unused handle - argument. - * dcrt0.cc (dll_crt0_1): Reflect elimination of unused handle argument - to fixup_after_exec. - * dtable.cc (dtable::fixup_after_exec): Ditto. - * fhandler_console.cc (fhandler_console::fixup_after_exec): Ditto. - * fhandler_dsp.cc (fhandler_dsp::fixup_after_exec): Ditto. - * fhandler_raw.cc (fhandler_raw::fixup_after_exec): Ditto. - * fhandler_socket.cc (fhandler_socket::fixup_after_exec): Ditto. - * fhandler_virtual.cc (fhandler_virtual::fixup_after_exec): Ditto. - * pipe.cc (fhandler_pipe::fixup_after_exec): Ditto. - -2004-02-02 Pierre Humblet - - * spawn.cc (spawn_guts): Do not set ciresrv.parent. - * child_info.h (child_info_spawn::~child_info_spawn): Do not close - parent. Update CURR_CHILD_INFO_MAGIC. - * dcrt0.cc (dll_crt0_0): Do not close spawn_info->parent. Pass NULL to - cygheap->fdtab.fixup_after_exec(). - -2004-02-02 Christopher Faylor - - Throughout, change name from set_inheritance to set_no_inheritance to - better reflect input arguments of this function. - - * cygheap.h (CYGHEAPSIZE): Increase size of cygheap to something closer - to the 21st century. - -2004-02-02 Corinna Vinschen - - * cygerrno.h (set_errno): Replace semicolon with comma in non-DEBUGGING - version to avoid compile time error. - -2004-02-01 Christopher Faylor - - * cygerrno.h (set_errno): Set global errno whenever setting thread - specific version. - * debug.cc (__set_errno): Ditto. - - * exceptions.cc (handle_sigsuspend): Remove spurious - sig_dispatch_pending call. - (set_signal_mask): When there seem to be pending signals to dispatch, - tell signal_dispatch_pending/sig_send not to specifically call any - handlers. - * sigproc.h (sig_dispatch_pending): Change declaration to void. - * sigproc.cc (sig_dispatch_pending): Change definition to void. Take - an argument to determine whether to tell sig_send to wait for handler - to be called. - * sigproc.cc (sig_send): Don't call signal handler when sig == - __SIGFLUSHFAST. - (wait_sig): Honor __SIGFLUSHFAST. Guard against sigpacket::process - nuking si_signo. - * sigproc.h (__SIGFLUSHFAST): Define new special signal. - (sig_dispatch_pending): Change declaration to void. Take optional - boolean argument. - - * fork.cc (vfork): Add debugging output. - -2004-01-26 Christopher Faylor - - * exceptions.cc (sig_handle_tty_stop): Avoid races by waiting for both - signal_arrived and for sigCONT. - (sigpacket::process): Enforce sending of both signal_arrived and - sigCONT, where appropriate. - * gendef (sigreturn): Save tls pointer in ebx so that it can jump into - sigdelayed and use the same register. - -2004-01-26 Christopher Faylor - - * cygtls.cc (_threadinfo::init_thread): Add more local reent stdio - initialization. - * dcrt0.cc (initial_env): Can it really be true that XP doesn't allow - attaching a debugger during DLL attach? Add temporary workaround. - (dll_crt0_0): Ensure that _impure_ptr stdio is initialized before any - threads. - (dll_crt0_1): Move _impure_ptr initialization to dll_crt0_0. - * exceptions.cc (try_to_debug): Reinstate old method for looping while - debugging. - * syscalls.cc (_cygwin_istext_for_stdio): Regularize debugging output. - Remove hopefully extraneous check. - (setmode_helper): Add debugging output for improbable case. Use - "binary" rather "raw" for consistency. - -2004-01-25 Christopher Faylor - - * fhandler.cc (fhandler_base::fhaccess): Avoid always setting errno to - EACCESS when return value is < 0. Rely on errno being set properly. - -2004-01-25 Christopher Faylor - - * sigproc.cc (proc_subproc): Don't protect *child's* handle. - -2004-01-24 Christopher Faylor - - * fhandler.h (fhandler_base::fhaccess): Return int for compatibility - with access. - * fhandler.cc (fhandler_base::fhaccess): Return int. Use consistent - variable name for exit value. Exit at bottom, printing debugging - information, like other cygwin functions. - -2004-01-23 Christopher Faylor - - * cygheap.cc (init_cygheap::close_ctty): Protect YA vforkism. - * fhandler.h (fhandler_base::has_acls): Make pass through for path_conv - method. - (fhandler_base::isremote): Ditto. - (fhandler_base::is_fs_special): Ditto. - (fhandler_base::has_attribute): Ditto. Define new function. - (fhandler_base::fhaccess): Declare new function based on access_worker. - (fhandler_base::set_has_acls): Eliminate obsolete function. - (fhandler_base::set_isremote): Ditto. - * fhandler.cc (fhandler_base::fhaccess): Move from syscalls.cc and into - fhandler_base class. Use fhandler methods to access data rather than - path_conv stuff. - (fhandler_base::device_access_denied): Use fhaccess method. - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Ditto. - (fhandler_base::open_fs): Remove calls to obsolete functions. - * fhandler_virtual.cc (fhandler_virtual::open): Ditto. - * winsup.h (access_worker): Remove obsolete access_worker declaration. - *syscalls.cc (access_worker): Move function to fhandler.cc. - (access): Use fhaccess method. - - * pinfo.cc (_pinfo::set_ctty): Clarify debugging output. - * sigproc.cc (sig_dispatch_pending): Ditto. - * syscalls.cc (setsid): Perform minor rearrangement. - -2004-01-23 Pierre Humblet - - * fhandler_socket.cc (fhandler_socket::create_secret_event): Avoid - creating multiple handles. Always allow event inheritance but set the - handle inheritance appropriately. Improve error handling. - (fhandler_socket::check_peer_secret_event): Improve error handling. - (fhandler_socket::close_secret_event): Simply call CloseHandle. - (fhandler_socket::set_close_on_exec): Set secret event inheritance. - -2004-01-23 Christopher Faylor - - * configure.in: Remove NEWVFORK default. - * configure: Regenerate. - * dcrt0.cc: Conditionalize vfork stuff throughout. - * dtable.cc: Ditto. - * perthread.h: Ditto. - * pipe.cc (fhandler_pipe::close): Ditto. - * spawn.cc (spawnve): Ditto. - * syscalls.cc (setsid): Ditto. - * exceptions.cc (sigpacket::process): Use macro to refer to vfork pid. - - * debug.cc (verify_handle): Define new function. - * debug.h (VerifyHandle): Define new macro. - (verify_handle): Declare new function - * fhandler.cc (fhandler_base::dup): Verify that dup'ed handle is not - supposed to be in use. - (fhandler_base::set_inheritance): Ditto. - (fhandler_base::fork_fixup): Ditto. - * fhandler_socket.cc (fhandler_socket::dup): Ditto. - * fhandler_tty.cc (fhandler_tty_slave::open): Ditto. - * net.cc (set_socket_inheritance): Ditto. - * pinfo.cc (pinfo_fixup_after_exec): Ditto. - * sigproc.cc (proc_subproc): Ditto. - (sig_send): Ditto. - * spawn.cc (spawn_guts): Ditto. - * thread.cc (pthread::init_mainthread): Ditto. - * pipe.cc (fhandler_pipe::close): Close read_state with - ForceCloseHandle since it was protected. - (fhandler_pipe::fixup_after_exec): Protect read_state handle. - (fhandler_pipe::dup): Correctly close open handles on error condition. - Verify that dup'ed handle is not supposed to be in use. - (fhandler_pipe::create): Protect read_state. - -2004-01-23 Christopher Faylor - - * exceptions.cc (sig_handle_tty_stop): Fix boneheaded mistake by using - correct check for parent state rather than inverted check mistakenly - introduced on 2003-09-15. - -2004-01-22 Brian Ford - - * fhandler_serial.cc (fhandler_serial::raw_write): Prevent a deadlock - when the input buffer overflows. - (fhandler_serial::raw_read): Correct to print the actual error and only - call PurgeComm when necessary. - -2004-01-22 Christopher Faylor - - * dcrt0.cc (reent_data): Make global. - * cygwin.din: Reexport reent_data. - -2004-01-22 Christopher Faylor - - * cygtls.cc (_threadinfo::remove): Don't assume that we are removing - _my_tls. - * exceptions.cc (setup_handler): Improve debugging output. - (call_signal_handler_now): Remove ill-advised debugger call. - * sigproc.cc (sigcomplete_main): Delete. - (sig_send): Honor FIXME and avoid using main thread's completion event - for everything or suffer races. - (pending_signals::add): Default stored mask to current process mask - rather than mask at time of signal send. - (wait_sig): Add debugging output. - * sigproc.h (sigpacket::mask_storage): Delete. - -2004-01-22 Christopher Faylor - - * fhandler.cc (fhandler_base::open): Revert isfs change. - -2004-01-21 Christopher Faylor - - * devices.in: Change raw com device to more correct form. - -2004-01-21 Christopher Faylor - - * fhandler.cc (fhandler_base::open): Use major numbers rather than - device numbers to control special behavior for devices which take - units. - * fhandler_raw.cc (fhandler_dev_raw::writebuf): Ditto. - (fhandler_dev_raw::fstat): Ditto. - (fhandler_dev_raw::open): Ditto. - (fhandler_dev_raw::ioctl): Ditto. - -2004-01-21 Nicholas Wourms - - * signal.cc (sigaction): Fix if-statement typo. - -2004-01-21 Christopher Faylor - - * cygtls.cc (handle_threadlist_exception): Change logic, improve - debugging output. - -2004-01-21 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty::ioctl): Semi-revert 2003-09-26 change - for TIOCSWINSZ. It is not an error for ioctl_request_event to be - missing. - -2004-01-20 Christopher Faylor - - * sigproc.cc (pending_signals::save): New function. - (pending_signals::restore): Ditto. - (sig_clear): Save/restore current queue pointer. - (wait_sig): Delete signals marked as such. - * sigproc.h (__SIGDELETE): New enum. - -2004-01-20 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number to 8. - - * cygmalloc.h: Make more concessions to attempts to get debugging - malloc working. - * debug.h: Ditto. - * dlmalloc.cc: Ditto. - * dlmalloc.h: Ditto. - * malloc_wrapper.cc: Ditto. - - * perthread.h (perthread::create): Use calloc to ensure zeroed memory. - -2004-01-20 Christopher Faylor - - * sec_acl.cc (setacl): Make sure sd_ret is large enough. - -2004-01-19 Christopher Faylor - - * sigproc.cc (sigproc_terminate): Don't close sendsig handle when - execing since we're not closing what we think we're closing. - (sig_send): Improve debugging when exiting due to no_signals_available. - - * wincap.h (wincaps::cant_debug_dll_entry): New element. - * wincap.cc: Implement above element throughout. - * dcrt0.cc (initial_env): Accommodate changes necessary to allow - initial debugging for systems which do not allow debugging in - dll_entry. - (dll_crt0_0): Add initial_env call back here. - - * Makefile.in (install-man): Use mandir as target for installation. - -2004-01-19 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number to 7 (should have been - done earlier). - -2004-01-19 Christopher Faylor - - * cygwin/include/signal.h: Add copyright notice. - - * cygwin.din: Make clock SIGFE. Add clock_gettime, sigwaitinfo, - timer_create, timer_delete, timer_settime. - * include/cygwin/version.h: Reflect above additions. - * fork.cc (fork_child): Call fixup_timers_after_fork. - * signal.cc (sigwait): Remove unused variable. - * timer.cc: New file. - (clock_gettime): Define new function. - (timer_tracker): Define new struct used by timer functions. - (timer_tracker::timer_tracker): New function. - (to_us): New function. - (timer_thread): New function. - (timer_tracker::settime): New function. - (timer_create): New function. - (timer_settime): New function. - (timer_delete): New function. - (fixup_timers_after_fork): New function. - * cygthread.cc: Bump thread count. - -2004-01-17 Christopher Faylor - - * signal.cc (sigwaitinfo): Define new function. - (sigwait): Redefine based on sigwaitinfo. - * include/cygwin/signal.h (sigwaitinfo): Declare. - (sigwait): Ditto. - -2004-01-17 Christopher Faylor - - * dtable.cc (dtable::vfork_parent_restore): Avoid double close of ctty - when ctty == ctty_on_hold. - -2004-01-16 Christopher Faylor - - * cygtls.h (_threadinfo::threadkill): New element. - (_threadinfo::set_threadkill): Declare new function. - (_threadinfo::reset_threadkill): Declare new function. - * dcrt0.cc (dcrt0_1): Call here so that it will be possible to attach - to running process with #(*& Windows Me/9x. - (initial_env): Try to initialize strace if uninitialized. - * gendef: Don't zero signal if threadkill is set since that will happen - in the called function. - * signal.cc (sigwait): Ensure cleanup in error conditions. - * sigproc.cc (sig_send): Clear packet mask storage. - (wait_subproc): Fill in child exit code in siginfo_t structure. - * thread.cc (pthread_kill): Set threadkill flag. - * tlsoffsets.h: Regenerate. - -2004-01-16 Christopher Faylor - - Throughout, use siginfo_t to fill out all signal information for - "kernel" signals. - * cygtls.h (_threadinfo::set_siginfo): Declare new function. - * cygtls.cc (_threadinfo::set_siginfo): Define new function. - * dcrt0.cc (do_exit): Accommodate siginfo_t considerations. - * exceptions.cc (handle_exceptions): Ditto. - (sig_handle_tty_stop): Ditto. - (ctrl_c_handler): Use killsys() to send signal. - (sigpacket::process): Rename from sig_handle. Use siginfo_t field from - sigpacket for everything. - (tty_min::kill_pgrp): Accommodate siginfo_t considerations. - (fhandler_termios::bg_check): Ditto. - * fhandler_tty.cc (fhandler_tty_slave::ioctl): Use killsys() to send signal. - * signal.cc (kill_worker): Rewrite to use siginfo_t second argument. - (kill_pgrp): Ditto. - (kill0): Define new function pulled from kill(). - (kill): Rewrite as frontend to kill0. - (killsys): Define new function. - * sigproc.cc (sigelem): Eliminate. - (sigpacket): Move to sigproc.h. Subsume sigelem. - (pending_signals): Use sigpacket rather than sigelem for everything. - (sig_clear): Ditto. - (wait_sig): Ditto. - (sig_send): Rewrite to use siginfo_t argument. - (sig_send): New function wratpper to sig_send with siginfo_t argument. - (wait_subproc): Accommodate siginfo_t considerations. - * thread.cc (pthread_kill): Ditto. - * sigproc.h (sigpacket): Move here. - (sigpacket::process): Declare "new" function. - (sig_handle): Eliminate declaration. - (sig_send): Declare with new paramaters. - (killsys): Declare new function. - (kill_pgrp): Declare. - * winsup.h: Move some signal-specific stuff to sigproc.h. - * include/cygwin/signal.h: Tweak some siginfo_t stuff. - -2004-01-16 Christopher Faylor - - * fhandler_console.cc (fhandler_console::close): Remove obsolete test - for vfork_cleanup. - * pipe.cc (fhandler_pipe::close): Add comment. - -2004-01-16 Christopher Faylor - - * cygheap.cc (init_cygheap::close_ctty): Don't NULL ctty if it is still - active. - -2004-01-16 Christopher Faylor - - * dtable.cc (dtable::vfork_parent_restore): Store ctty_on_hold prior to - calling close_all_files since it will be zeroed. - -2004-01-15 Christopher Faylor - - * gentls_offsets: Reinstate unlink of temp files. - -2004-01-14 Christopher Faylor - - * fhandler_console.cc (fhandler_console::close): Fix debugging output. - (fhandler_console::fixup_after_fork): Decrement open_fhs prior to call - to fhandler_console::open since this would cause incrementing too much - incrementing in child processes. (Probably needs to be handled more - elegantly someday) - (fhandler_console::fixup_after_exec): Ditto. - -2004-01-14 Christopher Faylor - - * cygtls.h (_threadinfo::call): Remove regparm declaration to work - around compiler bug. - -2004-01-13 Christopher Faylor - - * autoload.cc (TryEnterCriticalSection): Remove. - * dcrt0.cc (dll_crt0_0): Delete inappropriate setting of - _my_tls.stackptr to NULL since it has really bad consequences. Make - 'si' an automatic variable. - -2004-01-13 Christopher Faylor - - * cygtls.cc (_threadinfo::init_thread): Correct thinko which caused - thread list to be allocated every time. - * cygtls.h (CYGTLS_PADSIZE): Define as const int. - * sync.h: Make multiple inclusion safe. - (muto::next): Eliminate. - (muto::exiting_thread): New variable. - (muto::set_exiting_thread): New function. - (new_muto): Change to use different section for mutos since c++ give - inexplicable warning in some cases otherwise. - (new_muto1): Ditto. - * dcrt0.cc (do_exit): Call muto::set_exiting_thread here. - * sync.cc (muto_start): Eliminate. - (muto::acquire): Always give exiting thread a lock. Never give thread - a lock if exiting. - (muto::release): Ditto for releasing. - * dtable.cc (dtable::init_lock): Unline function and define here. - * dtable.h (lock_cs): Define as a muto since critical sections seem to - work oddly on Windows Me. - (lock): Accommodate switch to muto. - (unlock): Ditto. - * exceptions.cc (setup_handler): Don't worry about acquiring mutos - since that hasn't mattered for a long time. - (signal_exit): Ditto: muto stuff will be handled automatically on exit - now. - -2004-01-12 Christopher Faylor - - * Makefile.in (DLL_IMPORTS): Link advapi32 to ensure proper DLL - initialization. - * autoload.cc (RegCloseKey): Arbitrarily choose this function as a - "seed" to pull the advapi32 link library in. So, comment out the - autoloading. - * cygtls.cc (_threadinfo::init_thread): Just clear CYGTLS_PADSIZE. - (_threadinfo::remove): Add debugging. - (_threadinfo::find_tls): Ditto. - * cygtls.h (_threadinfo::padding): Make zero length (for now?). - * dcrt0.cc (dll_crt0_0): Move more initialization here from dll_crt0_1. - (dll_crt0_1): See above. - * dtable.h (dtable::lock): Remove commented out critical section - locking. - * dtable.h (dtable::init_lock): Remove commented out critical section - locking. - * dtable.h (dtable::unlock): Remove commented out critical section - locking. - * exceptions.cc (interruptible): bool'ize. - * init.cc (threadfunc_fe): Revert to storing threadfunc at stack - bottom. - (munge_threadfunc): Ditto. Avoid adding overhead to - calibration_thread. - (prime_threads): Don't initialize tls stuff. - (dll_entry): Make minor change to initialization order. - * tlsoffsets.h: Regenerate. - - * sigproc.cc (wait_sig): Add sanity check for end of process thread - exit. - - * select.h: Make minor formatting change. - -2004-01-10 Christopher Faylor - - * Makefile.in: Add still more -fomit-frame-pointer functions. - * dtable.h (dtable::lock): New function. - (dtable::unlock): New function. - (dtable::init_lock): New function. - * cygheap.h (HEAP_TLS): Declare new enum value. - (init_cygheap::threadlist): Declare new array. - (init_cygheap::sthreads): Declare new variable. - (cygheap_fdmanip::~cygheap_fdmanip): Use new dtable lock/unlock - functions. - (cygheap_fdnew::cygheap_fdnew): Ditto. - (cygheap_fdget::cygheap_fdget): Ditto. - * dtable.cc (dtable_init): Initialize fdtab critical section. - (dtable::fixup_after_fork): Ditto. - (dtable::fixup_after_exec): Ditto. - (dtable::dup2): Use lock/unlock calls to protect access to fdtab. - (dtable::find_fifo): Ditto. - (dtable::fixup_before_fork): Ditto. - (dtable::fixup_before_exec): Ditto. - (dtable::set_file_pointers_for_exec): Ditto. - (dtable::vfork_child_dup): Ditto. - (dtable::vfork_parent_restore): Ditto. - * syscalls.cc (close_all_files): Ditto. - * sync.h (muto::acquired): Declare new function. - (new_muto1): Declare new macro used to specify name of muto storage. - * sync.cc (muto::acquired): Define new function. - - * cygthread.cc (cygthread::stub): Remove signal chain removal call - since it is handled during initialization now. - * cygthread.cc (cygthread::simplestub): Remove signal chain removal - call since it is handled during initialization now. - * cygtls.cc (sentry): New class used for locking. Use throughout. - (_threadinfo::reset_exception): Don't pop stack. - (_threadinfo::find_tls): Move from exceptions.cc. - (_threadinfo::init_thread): Initialize array of threads rather than - linked list. Take second argument indicating thread function for this - thread. - (_threadinfo::remove): Search thread array rather than linked list. - Use sentry to lock. Only unlock if we got the lock. - (_threadinfo::find_tls): Ditto for first two. - (handle_threadlist_exception): Handle exceptions when manipulating the - thread list in case of premature thread termination. - (_threadinfo::init_threadlist_exceptions): Ditto. - * cygtls.h (TLS_STACK_SIZE): Decrease size. - (_threadinfo::padding): Add element to avoid overwriting lower part of - stack. - (_threadinfo::remove): Add a "wait" argument to control how long we - wait for a lock before removing. - * exceptions.cc (init_exception_handler): Make global. Take argument - to control exception handler being set. - (ctrl_c_handler): Wait forever when removing self from signal chain. - (_threadinfo::find_tls): Move to cygtls.cc. - (sig_handle): Reorganize detection for thread-specific signals. - * heap.cc (heap_init): Rework slightly. Make fatal error more verbose. - Remove malloc initialization since it can't happen during dll attach. - * init.cc (search_for): Move address to search for on stack here. - (threadfunc_ix): Ditto for stack offset. Make shared so that stack - walk potentially only has to be done once when cygwin processes are - running. - (threadfunc_fe): Use standard tls to store thread function (may change - back later). - (calibration_thread): New function. Potentially called to find - threadfunc_ix. - (munge_threadfunc): Search for "search_for" value on stack. Output - warning when thread func not found on stack. Use standard tls to store - thread function. - (prime_threads): New function. Called to prime thread front end. - (dll_entry): Call dll_crt0_0 here when DLL_PROCESS_ATTACH. Call - prime_threads here. Try to remove thread from signal list here. - * sigproc.cc (wait_sig): Initialize threadlist exception stuff here. - * thread.cc (pthread::exit): Pass argument to signal list remove - function. - * thread.h: Remove obsolete *ResourceLock defines. - - * tlsoffsets.h: Regenerate. - - * winsup.h (spf): Define temporary debug macro to be deleted later. - - * dcrt0.cc (dll_crt0_0): New function, called during DLL - initialization. Mainly consists of code pulled from dll_crt0_1. - (dll_crt0_1): See above. - (_dll_crt0): Wait for initial calibration thread to complete, if - appropriate. Move some stuff to dll_crt0_0. - (initialize_main_tls): Accommodate argument change to - _thread_info::init_thread. - * fork.cc (fork_child): Ditto. - (sync_with_child): Fix debug message. - * external.cc (cygwin_internal): Remove special considerations for - uninitialized dll since initialization happens during dll attach now. - - * dlfcn.cc (dlopen): Remove obsolete *ResourceLock calls. - (dlclose): Ditto. - -2004-01-05 Christopher Faylor - - * cygheap.h (init_cygheap::close_ctty): Declare new function. - * cygheap.cc (init_cygheap::close_ctty): Define new function. - * syscalls.cc (close_all_files): Use close_ctty. - (setsid): Ditto. - - * cygthread.cc (cygthread::stub): Remove exception initialization. - * cygthread.cc (cygthread::stub): Remove exception initialization. - (cygthread::simplestub): Ditto. - * thread.cc (pthread::thread_init_wrapper): Ditto. - * cygtls.cc (_last_thread): Make static. - (_threadinfo::call2): Initialize exception handler here. - (_threadinfo::find_tls): Move here. - * exceptions.cc (_threadinfo::find_tls): Move. - - * dcrt0.cc (__api_fatal): Add prefix info to message here rather than - including it in every call to function. - * winsup.h (api_fatal): Accommodate above change. - * debug.cc (add_handle): Don't do anything if cygheap not around. - (mark_closed): Ditto. - - * dll_init.cc (dll_list::detach): Fix debug output. - * fork.cc (sync_with_child): Ditto. - (vfork): Improve debug output. - * heap.cc (heap_init): Ditto. - - * exceptions.cc (try_to_debug): Clarify message when debugger attaches. - -2004-01-03 Christopher Faylor - - * exceptions.cc (_threadinfo::interrupt_now): Avoid double call to - sigdelayed. - * pinfo.cc (_pinfo::commune_send): Avoid inexplicable test which caused - most pids to be shown as "" on Win9x. - -2004-01-02 Christopher Faylor - - * cygheap.h (init_cygheap): Play more vfork shell games and move - ctty_on_hold and open_fhs_on_hold (back) here. - * dcrt0.cc (_dll_crt0): Just set impure_ptr_ptr here and let later - initialization deal with tls. - * dtable.cc (dtable::vfork_child_fixup): Move ctty considerations here. - (dtable:vfork_parent_restore): And here. - * fork.cc (vfork): Reflect change to ctty handling. - * perthread.h (vfork_save::fhctty): Eliminate. - - * cygwin.din: Make more exports NOSIGFE that will never be interrupted - by a signal. - - * init.cc (dll_entry): Set stackptr to NULL to catch problems earlier. diff --git a/winsup/cygwin/ChangeLog-2005 b/winsup/cygwin/ChangeLog-2005 deleted file mode 100644 index a44ab5832..000000000 --- a/winsup/cygwin/ChangeLog-2005 +++ /dev/null @@ -1,5813 +0,0 @@ -2005-12-31 Corinna Vinschen - - * syslog.cc (vsyslog): Decrement len if trailing \n has been removed. - Add \n when writing to stderr if LOG_PERROR option is set. - -2005-12-31 Corinna Vinschen - - * include/cygwin/in.h: Drop including stdint.h. Move definition - of in_port_t and in_addr_t to top of file and use throughout. Use - sa_family_t type where appropriate. - (struct in6_addr): Change `unsigned char' to `uint8_t'. - (struct sockaddr_in6): Add sin6_scope_id member. Add comments. - * include/cygwin/socket.h: Include stdint.h. Move definition of - socklen_t to top of file. Define sa_family_t. Define struct - sockaddr_storage as per SUSv3. - * include/sys/un.h: Include cygwin/socket.h. Use sa_family_t type. - -2005-12-29 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_common::__acquire_output_mutex): Use - strace method rather than accessing field directly. - (fhandler_tty_common::__release_output_mutex): Ditto. - -2005-12-29 Christopher Faylor - - * child_info.h (CURR_CHILD_INFO_MAGIC): Reset. - (child_info::dwProcessId): Delete. - (child_info::straced): New variable. - (child_info::handle_fork): New member function. - * dcrt0.cc (in_forkee): New global variable. - (__cygwin_user_data::forkee): Mark as obsolete. - (do_global_ctors): Use in_forkee rather than user_data->forkee. - (get_cygwin_startup_info): Ditto. Deal with new straced field to allow - strace to deal with children of attached processes. - (initial_env): Accommodate changes to strace::hello. - (child_info_fork::handle_fork): Rename from plain old 'handle_fork'. - Move alloc_stack() call elsewhere. - (dll_crt0_0): Fill out more of user_data. Reference handle_fork via - fork_info. Add some debugging output. - (_dll_crt0): Don't wait for sync thread if sync_startup is invalid. - Zero sync_startup here. Call alloc_stack() here, if appropriate. - (dll_crt0_1): Use in_forkee rather than user_data->forkee. - (dll_crt0): Ditto. - * malloc_wrapper.cc (malloc_init): Ditto. - * dll_init.cc (in_forkee): Remove local static version of this - variable. - (dll_list::load_after_fork): Don't set in_forkee here. - * external.cc (cygwin_internal): Use strace method rather than - accessing field directly. - * fhandler.cc (fhandler_base::read): Ditto. - * fhandler_tty.cc (fhandler_tty_common::__acquire_output_mutex): Ditto. - * fork.cc (frok::parent): Invoke strace write_childpid to communicate - with potential strace. - (child_copy): Add more detail to debugging output. - * init.cc (calibration_id): New static variable. - (prime_threads): Set sync_startup to invalid handle if we already know - about thread_func_ix. Use static calibration_id to hold calibration - thread id. - * munge_threadfunc (munge_threadfunc): Don't try to debug if we don't - find threadfunc_ix. - (dll_entry): Avoid calling munge_threadfunc and _cygtls::remove on - non-cygwin threads invoked during process startup. - * pinfo.cc (set_myself): Always call strace.hello here regardless of - DEBUGGING. - * sigproc.cc (child_info::child_info): Remove spurious handling of - dwProcessId. Set straced as appropriate. - * spawn.cc (spawn_guts): Rename ciresrv to ch. Invoke strace - write_childpid to communicate with potential strace. - * strace.cc: Include child_info.h. - (strace::hello): Remove inited test. Use active() method to test if - strace has been activated. Handle case where we are started before - (mypid): New function. - (strace::vsprntf): Try to deal more intelligently with case where - progname may not be filled out. Put pid in parentheses if it is a - windows pid rather than a cygwin pid. myself has been filled out. - (strace::write_childpid): New function for notifying strace about the - creation of children. - (strace::vprntf): Use strace method rather than accessing field - directly. - (strace_printf): Ditto. - (strace::wm): Ditto. - * winsup.h (in_forkee): Declare. - * include/sys/strace.h (strace::write_childpid): Declare new function. - (strace::attached): Define new function. - (strace::active): Ditto. - (strace::active_val): Ditto. - (_STRACE_ON): Delete. - (_STRACE_OFF): Ditto. - (define_strace0): Use strace method rather than accessing field - directly. - (strace_printf_wrap): Ditto. - (strace_printf_wrap1): Ditto. - -2005-12-28 Christopher Faylor - - * environ.cc (win_env::add_cache): Don't add variables to the - environment during initialization. - -2005-12-27 Corinna Vinschen - - * exceptions.cc (_cygtls::handle_exceptions): Drop redundant `break'. - -2005-12-27 Corinna Vinschen - - * exceptions.cc (inside_kernel): Rename from interruptible. - Accommodate change throughout file. - -2005-12-27 Corinna Vinschen - - * exceptions.cc (interruptible): New function, code stripped from - _cygtls::interrupt_now. - (_cygtls::handle_exceptions): Handle STATUS_DATATYPE_MISALIGNMENT as - SIGBUS error. Differ between unmapped memory (SEGV_MAPERR) and access - violation (SEGV_ACCERR) in case of STATUS_ACCESS_VIOLATION. Write - kernel log message in case of uncatched STATUS_ACCESS_VIOLATION. - (_cygtls::interrupt_now): Just call interruptible now instead of - evaluating interruptibility here. - -2005-12-27 Corinna Vinschen - - * path.cc (path_conv::check): Rework loop removing trailing dots - and spaces. - - * syslog.cc (vklog): Set facility to LOG_KERN if not set. - -2005-12-26 Christopher Faylor - - * dcrt0.cc (__api_fatal): Simplify to just use strace mechamisms. - (do_exit): Move minimal_printf... - * pinfo.cc (pinfo::exit): ...into here. - * strace.cc (strace::vprntf): Guarantee output to the console when - system_printf/api_fatal. - - * heap.cc (heap_init): Wait a second before issuing an error when - ERROR_INVALID_ADDRESS since this is probably due to a CTRL-C handler - sneaking in, using the memory that we want to use for the heap, and, - eventually exiting. - -2005-12-23 Christopher Faylor - - * cygtls.cc (_cygtls::handle_threadlist_exception): Make an error - fatal. - * cygtls.h (sockaddr_in): Use header rather than defining our own - structure. - * exceptions.cc (_cygtls::interrupt_setup): Use exact contents of - sa_mask rather than assuming that current sig should be masked, too. - (_cygtls::call_signal_handler): Use more aggressive locking. - * gendef (_sigbe): Wait until later before releasing incyg. - (_sigreturn): Remove more arguments to accommodate quasi-sa_sigaction - support. - (_sigdelayed): Push arguments for sa_sigaction. More work needed here. - * signal.cc (sigaction): Implement SA_NODEFER. - * tlsoffsets.h: Regenerate. - - * sigproc.cc (wait_sig): Use default buffer size or Windows 9x - complains. - - * pinfo.cc (_onreturn::dummy_handle): Remove. - (_onreturn::h): Make this a pointer. - (_onreturn::~_onreturn): Detect whether pointer is NULL rather than - value is NULL. - (_onreturn::_onreturn): Set h to NULL initially. - (_onreturn::no_close_p_handle): Set h to NULL. - (winpids::add): Initialize onreturn with value from p.hProcess - immediately. - -2005-12-22 Christopher Faylor - - * fork.cc (fork): Honor error return from sig_send. Don't continue - with fork if we couldn't suspend signals. - * sigproc.cc (sig_send): Set sigCONT event when we see __SIGNOHOLD. - (wait_sig): Remove holding_signals. Create pipe with a buffer which - will theoretically cause blocking if there is nothing reading on the - pipe. Wait for sigCONT at end of loop when we have a __SIGHOLD. - -2005-12-22 Corinna Vinschen - - * fhandler.h (fhandler_base::issymlink): New method. - * syscalls.cc (open): Handle O_NOFOLLOW flag. - * include/fcntl.h (_FNOFOLLOW): New define. - (O_NOFOLLOW): Ditto. - * include/cygwin/version.h: Bump API minor number. - -2005-12-22 Christopher Faylor - - * pinfo.cc (winpids::add): Increment nelem when winpid is true since we - don't care if it's a cygwin process in that case. - -2005-12-22 Christopher Faylor - - * pinfo.cc (winpids::release): Fix typo. - -2005-12-21 Christopher Faylor - - * pinfo.cc (pinfo::init): Clarify comment slightly. - (_onreturn): New helper class. - (winpids:add): Remove copied stuff. Try to put process handle into - pinfo in question and use _onreturn class to control when to close it. - (winpids::release): Remove use of copied array. Free procinfo when - hProcess is NULL. Otherwise call release and call CloseHandle on - hProcess. - * pinfo.h (winpids::copied): Remove throughout class. - -2005-12-21 Christopher Faylor - - * pinfo.cc (pinfo::init): Remove spurious low_priority_sleep. - -2005-12-21 Christopher Faylor - - * spawn.cc (spawn_guts): Hide the window whenever ctty == -1, not just - when we have no console. - -2005-12-21 Christopher Faylor - - * cygheap.cc (init_cygheap::manage_console_count): Revert previous - change. Handle this a different way. - * external.cc (cygwin_internal): Accommodate extra - hook_or_detect_cygwin argument. - * hookapi.cc (cygwin_internal): Fill in subsys variable with the - subsystem of the executable. - * spawn.cc (av::iscui): New variable. - (spawn_guts): Hide window when we don't have a console and this isn't - NT/XP/2003. - (av::fixup): Set iscui flag. - * winsup.h (hook_or_detect_cygwin): Accommodate extra argument. - -2005-12-21 Christopher Faylor - - * cygheap.cc (init_cygheap::manage_console_count): Don't call - FreeConsole on 9x/Me. - -2005-12-21 Corinna Vinschen - - * (fhandler_disk_file::fchown): Remove execute bits from "sensible" - permissions. Use same setting as in symlink. - -2005-12-21 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::fstat_helper): Fix inode number - debug output. - (fhandler_disk_file::fchown): Always set sensible permission values - when creating the ACL for symlinks. - -2005-12-20 Corinna Vinschen - - * winsup.h (flush_file_buffers): Define as inline function. - * miscfuncs.cc (flush_file_buffers): Remove. - -2005-12-20 Corinna Vinschen - - * winsup.h (flush_file_buffers): Declare new function. - (FLushFileBuffers): New define. - * miscfuncs.cc (flush_file_buffers): Define new function. - -2005-12-20 Christopher Faylor - - * fhandler.h (fhandler_termios::fixup_after_exec): Make non-inlined. - * fhandler_termios.cc (fhandler_termios::fixup_after_exec): Don't call - fixup_after_fork if close_on_exec'ed. - -2005-12-19 Christopher Faylor - - * cygtls.h (_cygtls::interrupt_now): Subsume interruptible(). - (interruptible): Delete. - (setup_handler): Remove interruptible call and just use return from - interrupt_now. - -2005-12-19 Christopher Faylor - - * fhandler.h (set_console_state_for_spawn): Add an argument to the - declaration. - * fhandler_console.cc (set_console_state_for_spawn): Ditto for the - definition. Only set invisible console for non-cygwin process. Remove - debugging leftover. - * spawn.cc (spawn_guts): Pass argument denoting whether this is a - cygwin process to set_console_state_for_spawn and only call this - function when exec'ing. - -2005-12-19 Corinna Vinschen - - * mmap.cc (fhandler_dev_zero::mmap): Call VirtualFree(MEM_RELEASE) - with zero length parameter, otherwise it fails. - (fhandler_dev_zero::munmap): Ditto. - -2005-12-18 Christopher Faylor - - * fhandler.h (fhandler_console::invisible_console): Declare new - variable. - (fhandler_pipe::fixup_in_child): Declare new function. - (fhandler_console::need_invisible): Ditto. - (fhandler_console::has_a): Ditto. - * fhandler_console.cc (set_console_state_for_spawn): Eliminate return - value. Set up an invisible console if necessary prior to spawning. - (fhandler_console::invisible_console): Define. - * fhandler_tty.cc (fhandler_tty_slave::open): Use - fhandler_console::invisible_console to setup an invisible console. - * pipe.cc (fhandler_pipe::fixup_in_child): Define new function from - fixup_after_exec. - (fhandler_pipe::fixup_after_exec): Use fixup_in_child when appropriate. - (fhandler_pipe::fixup_after_fork): Ditto. - * spawn.cc (handle): Reorganize and modernize a little. - (spawn_guts): Rely on set_console_state_for_spawn to set the console - into the right state but don't create the process with "detached" flag - if we have no controlling tty since that confuses 'cmd'. - * dtable.cc (dtable::stdio_init): Don't set console as controlling - terminal if we have an invisible console. - - * sigproc.cc (child_info::sync): Use correct name in ForceCloseHandle1. - -2005-12-18 Christopher Faylor - - * include/sys/dirent.h: Change __deprecated_d_ino to __invalid_d_ino - throughout to make things a little clearer. - * dir.cc (readdir_worker): Reflect above change. - -2005-12-16 Christopher Faylor - - * winsup.h (child_copy): Change prototype to match new functionality. - * cygheap.cc (cygheap_fixup_in_child): Accommodate new child_copy - arguments. - * dcrt0.cc (dll_data_start): Move definition here from fork. - (dll_data_end): Ditto. - (dll_bss_start): Ditto. - (dll_bss_end): Ditto. - (handle_fork): New function. Called when forked to deal with fork - issues and copy data to this process from the parent. - (dll_crt0_0): Call handle_fork when _PROC_FORK condition. - (dll_crt0): Don't copy user_data when we've forked. Don't zero first - element of main_environment ever. - (cygwin_dll_init): Ditto. - * fork.cc (child_copy): Rename from fork_copy and change arguments so - that each pair of things to copy gets its own descriptor. - (frok::child): Remove fixup_mmaps_after_fork call here. Move to - handle_fork in dcrt0.cc. - (frok::parent): Use child_copy rather than fork_copy and accommodate - changes in parameters. - - * exceptions.cc (setup_handler): Delay test of whether we're locked - until after GetThreadContext has been called since there are apparently - cases where SuspendThread does not cause an immediate thread - suspension. - -2005-12-16 Christopher Faylor - - * init.cc (dll_entry): Call prime_threads after dll_crt0_0 to avoid - conflicts between heap allocation and thread stack allocation. - -2005-12-16 Christopher Faylor - - * hookapi.cc (putmem): Remove query of previous memory protection since - we get that for free the first time we call VirtualProtect. - -2005-12-15 Corinna Vinschen - - * mmap.cc (fhandler_dev_zero::fixup_mmap_after_fork): Use - system_printf like any other fixup_mmap_after_fork. - -2005-12-14 Corinna Vinschen - - * fhandler.cc (ACCFLAGS): Remove macro. - (fhandler_base::get_default_fmode): Use O_ACCMODE instead of ACCFLAGS - and or'ed read/write flags. - (fhandler_base::open_9x): Use O_ACCMODE instead of or'ed read/write - flags. - (fhandler_base::open): Ditto. - * fhandler_disk_file.cc (fhandler_base::open_fs): Ditto. - * fhandler_mem.cc (fhandler_dev_mem::open): Ditto. - * fhandler_raw.cc (fhandler_dev_raw::open): Ditto. - -2005-12-14 Corinna Vinschen - - * fhandler.cc (fhandler_base::open_9x): Handle O_SYNC and O_DIRECT - flags. - (fhandler_base::open): Ditto. - * fhandler_floppy.cc (fhandler_dev_floppy::open): Don't allocate devbuf - in O_DIRECT case. - * fhandler_raw.cc (fhandler_dev_raw::ioctl): Don't allow buffer - changes in O_DIRECT case. Allow returning a buffer size 0, which - indicates O_DIRECT. - * fhandler_tape.cc (fhandler_dev_tape::open): Use O_SYNC flag to - hand down the !buffer_writes case. Don't allocate devbuf in O_DIRECT - case. - (fhandler_dev_tape::raw_read): Don't mess with devbuf if it's NULL. - * include/fcntl.h: Define _FDIRECT, O_DIRECT, O_DSYNC and O_RSYNC. - * include/cygwin/version.h: Bump API minor version. - -2005-12-13 Christopher Faylor - - * cygtls.cc (_cygtls::remove): Don't bother if we're exiting. - * sigproc.cc (_cygtls::remove_wq): Ditto. - -2005-12-13 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty::open): Enhance comment. - -2005-12-13 Corinna Vinschen - - * fhandler_tty.cc (fhandler_tty::open): Close newly created window - station after switching to original window station. - -2005-12-13 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty::open): Add a comment. - -2005-12-12 Christopher Faylor - - * times.cc (hires_ms::usecs): Subtract from slop from system time or - we'll always end up priming the pump. - -2005-12-12 Nick Duffek - - * times.cc (systime): Correct precision referenced in comment. - -2005-12-12 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_slave::open): Don't free original - windows station since that will cause strange problems displaying - fonts. Reset windows station to original station after creating - console. - * times.cc (hires_ms::usecs): Only reprime when calculated time is less - than system time. - -2005-12-12 Christopher Faylor - - * pinfo.cc (winpids::add): Don't copy procinfo when there is no cygwin - process associated with the pid, i.e., procinfo == NULL. - -2005-12-12 Christopher Faylor - - * times.cc (hires_ms::usecs): Correct order when checking if high - precision time is <= current time. - -2005-12-12 Christopher Faylor - - * pinfo.cc (size_copied): New convenience macro. - (winpids::add): Alias the element that we are working on for slightly - better clarity. Honor the "make_copy" flag. - (winpids::release): Free and zero procinfo field if it was allocated - via malloc. - (winpids::~winpids): Free copied array. - * pinfo.h (class pinfo): Make winpids class a friend. - (winpids::make_copy): New field. - (winpids::copied): New array. - (winpids::reset): Reset npids after releasing pinfos or suffer a memory - leak. - (winpids::winpids): Try harder to zero all fields in the class. - -2005-12-12 Corinna Vinschen - - * autoload.cc (GetSystemTimes): Remove. - -2005-12-12 Corinna Vinschen - - * fhandler_proc.cc (format_proc_uptime): Drop usage of GetSystemTimes. - Use NtQuerySystemInformation to evaluate uptime and idle_time from - all CPU's processor times. Fallback to GetTickCount. - -2005-12-12 Corinna Vinschen - - * mmap.cc (gen_create_protect): Always generate WRITECOPY protection - for private maps. - (fixup_mmaps_after_fork): Fix calculation of WRITECOPY protection for - VirtualProtect. Add some words to the comment. - -2005-12-10 Christopher Faylor - - * dirent.h: Change the rest of the d_ino's to __deprecated_d_ino. - -2005-12-10 Christopher Faylor - - * malloc.cc: Update to version 2.8.3. - * cygmalloc.h (MSPACE): Remove unneeded definition. - -2005-12-08 Corinna Vinschen - - * fhandler_raw.cc (fhandler_dev_raw::ioctl): Only allow 0, 1 or a - multiple of 512 as new buffersize. - -2005-12-08 Pekka Pessi - Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::recvfrom): Mask flags with - MSG_WINMASK for Windows socket calls. - (fhandler_socket::recvmsg): Ditto. - (fhandler_socket::sendmsg): Ditto. - -2005-12-07 Christopher Faylor - - * hires.h (hires_ms::initime_ms): Delete. - (hires_ms::initime_us): Just define as LONGLONG. - (hires_ms::uptime): New function. - * select.cc (select_stuff::wait): Use gtod for timing to attempt to - avoid windows 32 bit wraparound. - * times.cc (systime): New function. - (times): Replace GetTickCount with gtod.uptime. - (hires_us::prime): Use systime() to calculate system time rather than - calling GetSystemTimeAsFileTime directly. - (hires_ms::prime): Ditto. Eliminate initime_ms. - (hires_ms::usecs): Try harder to detect wraparound. - - * fhandler_proc.cc (format_proc_partitions): Set drive_size to zero to - avoid a compiler warning. - -2005-12-07 Corinna Vinschen - - * fhandler_proc.cc (format_proc_partitions): Use modern IOCTLs - to determine drive size as far as possible. - -2005-12-07 Corinna Vinschen - - * fhandler_raw.cc (fhandler_dev_raw::ioctl): Fix INVALID_PARAMETER - condition. Only copy devbuf to buf if buf is non-NULL. - -2005-12-07 Corinna Vinschen - - * fhandler_raw.cc (fhandler_dev_raw::ioctl): Fix setting devbuf - when rd_parm is 0 or 1. - -2005-12-07 Corinna Vinschen - - * fhandler_floppy.cc (fhandler_dev_floppy::lseek): Fix test for - valid file position at EOM. - -2005-12-07 Christopher Faylor - - * include/cygwin/stdlib.h: Guard compilation of *unsetenv* in newlib. - -2005-12-07 Corinna Vinschen - - * exceptions.cc (_cygtls::handle_exceptions): In case of a - STATUS_ACCESS_VIOLATION, check if the page is a mmaped page beyond - a file's EOF. Generate SIGBUS instead of SIGSEGV then. - * mmap.cc (__PROT_ATTACH): New define. - (__PROT_FILLER): Ditto. - (fh_anonymous): Rename from fh_paging_file; - (fh_disk_file): New global static variable. - (attached): New inline function. - (filler): Ditto. - (gen_create_protect): Split off from gen_protect to use the file's - access mode to create mapping always with maximum allowed protections. - (gen_protect): Accommodate pages attached beyond EOF. Use symbolic - values instead of numerics when possible. Drop create parameter. - (gen_access): Use file's access mode instead of protection. - (CreateMapping9x): Create named mapping names so that different - creation access modes result in different mappings. - (CreateMappingNT): Only reserve attached pages, don't commit them. - (MapViewNT): Ditto. Set AT_ROUND_TO_PAGE for all non-NULL base - addresses. - (mmap_func_t): Define CreateMapping and MapView function pointers - with additional openflags parameter. - (class mmap_record): Add openflags member. - (mmap_record::mmap_record): Add openflags parameter. - (mmap_record::get_openflags): New accessor. - (mmap_record::attached): Call global attached function. - (mmap_record::filler): Call global filler function. - (mmap_record::gen_create_protect): Call global gen_create_protect - function. - (mmap_record::gen_protect): Drop create parameter. - (mmap_record::alloc_fh): Set fhandler's access flags. - (list::search_record): Accommodate filler pages. - (list::set): Use inode number as hash value. - (map::get_list_by_fd): Check hash value against file's inode number. - (mmap_is_attached_page): New function to evaluate if a given address - is on a attached page. Called from _cygtls::handle_exceptions. - (mmap_worker): New function to do mapping and bookkeeping in a - single call. - (mmap64): Use roundup2 to round length to pagesize alignment. - Initialize global fhandlers. Simplify anonymous initialization. - Add SUSv3 compatible check of file open mode vs. requested protection. - Try creating new file handles to allow maximum page protection. - Allow creating attached pages in case of mapping beyond EOF. - Close new file handle if one has been created. - (munmap): Align len to pagesize. - (msync): Rework argument checks. Align len to pagesize. - (mprotect): Ditto. Accommodate attached pages. - (mlock): Use roundup/rounddown macros instead of homemade expressions. - (munlock): Add page alignment as in mlock. - (fhandler_dev_zero::munmap): Fix unmapping of non-private mappings. - (fhandler_dev_zero::fixup_mmap_after_fork): Accommodate filler pages. - (fixup_mmaps_after_fork): Don't fail if attached pages couldn't be - created in child. Avoid superfluous call to VirtualFree. Check for - original allocation protection to fix PAGE_WRITECOPY protection. - * ntdll.h: Revert deletion of AT_ROUND_TO_PAGE define. - * winsup.h (mmap_is_attached_page): Declare. - -2005-12-05 Christopher Faylor - - * include/cygwin/stdlib.h: New file. - * environ.cc (unsetenv): Change to return -1 on input error. - * include/cygwin/version.h: Add more description to latest api bump. - -2005-12-05 Christopher Faylor - - * dir.cc (readdir_workdir): Only fill out d_ino when linked into older - app. - * include/cygwin/version.h: Bump api minor number to 147, reflecting - obsolescence of d_ino. - (CYGWIN_VERSION_USER_API_VERSION_COMBINED): New convenience macro. - (CYGWIN_VERSION_CHECK_FOR_NEEDS_D_INO): New convenience macro. - * include/sys/dirent.h: Change d_ino field to __deprecated_d_ino. - -2005-12-05 Christopher Faylor - - Remove unneeded whitespace. - * cygtls.cc (_cygtls::set_state): Delete. - (_cygtls::reset_exception): Ditto. - (_cygtls::init_thread): Set initialized state directly here. - (_cygtls::push): Remove exception argument. Don't treat exceptions - specially. - * cygtls.h (_cygtls::push): Ditto. - (_cygtls::isinitialized): Don't treat exceptions specially. - (_cygtls::reset_exception): Delete. - (_cygtls::set_state): Ditto. - (_cygtls::handle_exceptions): Don't push ebp on the stack prior to - calling sig_send. Just set incyg instead. - (_cygtls::interrupt_setup): Accommodate _cygtls::push argument change. - (_cygtls::interrupt_now): Ditto. - (setup_handler): Don't treat exceptions specially. - * gendef (longjmp): Always zero incyg flag. - -2005-12-04 Corinna Vinschen - - * environ.cc (spenvs): Add "windir" as an "always export" variable - to accommodate WinSock on Windows 95. - -2005-12-02 Christopher Faylor - - * include/exceptions.h (exception_list): Revert previous change. - Windows doesn't care. - (exception_handler): Use real exception_list parameter type rather than - void * - * tlsoffsets.h: Regenerate. - * cygtls.h (_cygtls::handle_exceptions): Use real exception_list - parameter type rather than void *. - (handle_threadlist_exception): Ditto. - (init_exception_handler): Ditto. - * cygtls.cc (_cygtls::handle_threadlist_exception ): Ditto. - (_cygtls::init_exception_handler): Add kludge to terminate linked list - with a loop, which seems to solve problem of RtlUnwind causing problems - * exceptions.cc (rtl_unwind): Use real exception_list parameter type - rather than void *. - (_cygtls::handle_exceptions): Ditto. - -2005-12-02 Christopher Faylor - - * cygtls.h (_cygtls::el): New field. - (_cygtls::handle_exceptions): New function declaration. - (_cygtls::handle_threadlist_exception): Ditto. - (_cygtls::init_exception_handler): Ditto. - (_cygtls::init_threadlist_exceptions): Remove arg from declaration. - * cygtls.cc (_cygtls::call2): Don't initialize exceptions here. - (_cygtls::init_thread): Do it here instead and use member function. - (_cygtls::handle_threadlist_exception): Move into _cygtls class. - (_cygtls::init_exception_handler): Ditto. Rely on existence of 'el' - memmber in _cygtls. - (_cygtls::init_threadlist_exceptions): Ditto. - * dcrt0.cc (dll_crt0_1): Remove exception_list definition and setting - since it now commonly resides in the tls. - * exceptions.cc (init_exception_handler): Move to cygtls.cc. - (init_exceptions): Ditto. - (rtl_unwind): New, safe wrapper function for RtlUnwind. - (_cygtls::handle_exceptions): Move to _cygtls. Call rtl_unwind to - unwind frames and eliminate copying of structures. Put address of - failing instruction in si_addr, not the address on the stack. Return 0 - to indicate that we've handled this exception. - * external.cc (cygwin_internal): Make CW_INIT_EXCEPTIONS a no-op. - * sigproc.cc (wait_sig): Accommodate argument change to - _cygtls::init_threadlist_exceptions. - * tlsoffsets.h: Regenerate. - * include/exceptions.h (exception_list): Add more stuff to the - exception list. Apparently windows needs this? - (init_exceptions): Remove bogus declaration. - - * include/cygwin/signal.h (SI_USER): Redefine as zero as per SUSv3. - * include/cygwin/version.h: Bump API minor version number to 146. - - * thread.cc (pthread_kill): Set si_pid and si_uid. - - * timer.cc (timer_thread): Set si_code to SI_TIMER. - -2005-12-01 Christopher Faylor - - * dcrt0.cc (getstack): Try harder to modify memory. - (alloc_stack): Alloc page prior to stack top, too. - -2005-12-01 Christopher Faylor - - * devices.h (_major): Revert previous ill-advised change. - (_minor): Ditto. - -2005-12-01 Christopher Faylor - - * exceptions.cc (handle_exceptions): Translate a guard page exception - to a "SIGBUS". - -2005-12-01 Corinna Vinschen - - * mmap.cc: Make debug output more consistently. Fix some comments. - (gen_protect): Convert to inline function. - (gen_access): Ditto. - (mmap_record::gen_protect): Add create parameter as in global function. - (mmap_record::alloc_page_map): Change condition so that always the - correct protection setting is set after mapping has been established. - (mmap64): For anonymous mappings set offset always to 0. - (fixup_mmaps_after_fork): Always call fixup_mmap_after_fork method - with the MAP_FIXED flag set. - -2005-12-01 Christopher Faylor - - * devices.h (_minor): Coerce argument to proper type before - manipulating. - (_major): Ditto. - (device::is_fs_special): New function. - * fhandler_disk_file.cc (fhandler_base::fstat_helper): Set the size to - 0 for devices rather than reporting the size of the symlink. - (fhandler_disk_file::readdir): Use is_fs_special to determine if .lnk - should be stripped. - * path.cc: Rename symlink_info::is_symlink to symlink_info::issymlink - throughout. - (symlink_info::isdevice): New field. - (path_conv::check): Use 'isdevice' to determine if just-parsed entity - is a device rather than relying on non-zero major/minor. - (symlink_info::parse_device): Set isdevice to true if we've discovered - a device. - (symlink_info::check): Clear isdevice field prior to processing. Use - isdevice to control debugging output. - (symlink_info::set): Set isdevice to false. - * path.h (path_conv::is_fs_special): New function. - * devices.cc: Regenerate. - -2005-11-30 Christopher Faylor - - * times.cc (hires_ms::prime): Remove debugging stuff. - (hires_ms::usecs): Ditto. - -2005-11-30 Corinna Vinschen - - * mmap.cc (list::try_map): New method, implementing trying to map - within another already existing map, moved from mmap64 here. - (mmap64): Just call try_map now. - (fhandler_dev_zero::fixup_mmap_after_fork): Always create new private - map with PAGE_READWRITE protection. - (fixup_mmaps_after_fork): Fix comment. - -2005-11-29 Corinna Vinschen - - * include/cygwin/version.h: Bump API minor version. - -2005-11-29 Corinna Vinschen - - * fhandler.h (fhandler_dev_zero::mmap): Add method. - (fhandler_dev_zero::munmap): Ditto. - (fhandler_dev_zero::msync): Ditto. - (fhandler_dev_zero::fixup_mmap_after_fork): Ditto. - * mmap.cc: Implement anonymous mapping using fhandler_dev_zero class. - Implement private anonymous maps using VirtualAlloc/VirtualFree. Fix - or add some more comments. - (fh_paging_file): Change to type fhandler_dev_zero. - (priv): New static inline function to avoid having lots of flag bit - tests in the code. Use throughout were appropriate. - (fixed): Ditto. - (anonymous): Ditto. - (noreserve): Ditto. - (autogrow): Ditto. - (gen_protect): Never generate PAGE_WRITECOPY protection for - private anonymous maps. - (gen_access): Drop FILE_MAP_EXECUTE handling since it's not supported - correctly on 9x. - (VirtualProt9x): Move comment from mmap64 here. - (mmap_record::mmap_record): Gegerate correct device entry for - anonymous maps, though unused right now. - (mmap_record::priv): Call global priv function. - (mmap_record::fixed): Call global fixed function. - (mmap_record::anonymous): Call global anonymous function. - (mmap_record::noreserve): Call global noreserve function. - (mmap_record::autogrow): Call global autogrow function. - (list::anonymous): New method. Use throughout were appropriate. - (mmap_record::compatible_flags): Drop now useless ifdef. - (mmap_record::alloc_page_map): Accommodate private anonymous maps. - (mmap_record::map_pages): Accommodate MAP_NORESERVE mappings. - (mmap_record::unmap_pages): Accommodate private anonymous maps. - (mmap64): Simplify argument check. Don't remove the MAP_PRIVATE flag - for anonymous mappings on 9x anymore since that's now handled - gracefully. - (mprotect): Accommodate MAP_NORESERVE mappings. Fix case when - non-mmap areas are just MEM_RESERVEd. - (fhandler_dev_zero::mmap): Implement anonymous mapping here. - (fhandler_dev_zero::munmap): Ditto. - (fhandler_dev_zero::msyn): Ditto. - (fhandler_dev_zero::fixup_mmap_after_fork): Ditto. - (fixup_mmaps_after_fork): Accommodate private anonymous maps. Enhance - debug output in case VirtualProtect fails. - * include/sys/mman.h: Really define MAP_NORESERVE now. - -2005-11-28 Corinna Vinschen - - * autoload.cc (NtCreateSection): Define. - * cygheap.cc (_csbrk): Call getpagesize instead of getshmlba. - * dcrt0.cc (dll_crt0_0): Call mmap_init. - * external.cc (cygwin_internal): Call getpagesize instead of getshmlba. - * fhandler.h (fhandler_base::mmap): Change access to prot parameter. - (fhandler_base::fixup_mmap_after_fork): Ditto. - (fhandler_disk_file::mmap): Ditto. - (fhandler_disk_file::fixup_mmap_after_fork): Ditto. - (fhandler_dev_mem::mmap): Ditto. - (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. - * fhandler_mem.cc (fhandler_dev_mem::write): Call getsystempagesize - instead of getpagesize. - (fhandler_dev_mem::read): Ditto. - (fhandler_dev_mem::fstat): Ditto. - (fhandler_dev_mem::mmap): Move to mmap.cc. - (fhandler_dev_mem::munmap): Ditto. - (fhandler_dev_mem::msync): Ditto. - (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. - * fhandler_proc.cc (format_proc_meminfo): Call getsystempagesize - instead of getpagesize. - * fhandler_process.cc (format_process_stat): Ditto. - (format_process_status): Ditto. - (get_mem_values): Ditto. - * mmap.cc: Fix formatting. Try to make more readable and modular. - Take advantage of pagesize==granularity. - (gen_protect): New static function to evaluate Windows - protection bits from POSIX protection and flags. - (gen_access): Ditto for Windows access mode. - (VirtualProt9x): Wrapper function to call VirtualProtect on 9x. - (VirtualProtNT): Ditto for NT. - (VirtualProtEx9x): Ditto for VirtualProtectEx on 9x. - (VirtualProtExNT): Ditto for NT. - (CreateMapping9x): Wrapper function for creating a mapping handle on 9x. - (CreateMappingNT): Ditto for NT. - (MapView9x): Wrapper function to map a view on 9x. - (MapViewNT): Ditto for NT. - (mmap_funcs_9x): Structure containing function pointers to wrapper - functions for 9x. - (mmap_funcs_nt): Ditto for NT. - (mmap_func): Pointer to wrapper functions used in subsequent code. - (mmap_init): Initialize mmap_func depending on OS. - (class mmap_record): Use sensible member names. Add POSIX protection - member. Drop Windows access flags member. Constify more methods. - Use accessors instead of direct member access inside of own methods. - (mmap_record::gen_protect): Class wrapper to evaluate matching - Windows protection bits. - (mmap_record::gen_access): Ditto for Windows access flags. - (mmap_record::compatible_flags): New function to check if flags are - compatible with flags of existing map. - (list::add_record): Drop offset and length arguments. - (class map): Change counters to unsigned. Match usage throughout. - (mmapped_areas): Convert from pointer to global struct. - (mmap_record::alloc_page_map): Simplify. - (mmap_record::map_pages): Ditto. - (mmap_record::fixup_page_map): Delete. - (mmap64): Simplify. Add workaround for Windows 98 bug. Fix bug on - NT that existing anonymous mappings weren't searched for a match. - (munmap): Add workaround for Windows 98 bug. - (msync): Simplify. - (mprotect): Handle existing maps correctly. - (mlock): Add local pagesize variable and enlightening comment. - (fhandler_disk_file::mmap): Main functionality now in CreateMapping/ - MapView wrapper functions. - (fhandler_disk_file::fixup_mmap_after_fork): Call MapView wrapper. - (fhandler_dev_mem::mmap): Moved from fhandler_mem.cc. Simplify by - calling MapViewNT. - (fhandler_dev_mem::munmap): Moved from fhandler_mem.cc. - (fhandler_dev_mem::msync): Ditto. - (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. Call MapViewNT. - (fixup_mmaps_after_fork): Restructure and hopefully speed up loop for - setting protection and memory content on MAP_PRIVATE maps. - * ntdll.h (AT_ROUND_TO_PAGE): Remove define. - (AT_EXTENDABLE_FILE): Add define. - (NtCreateSection): Add prototype. - * syscalls.cc (getpagesize): Return granularity as pagesize now. - (getsystempagesize): New function to retrieve "real" pagesize. - (getshmlba): Delete since it's replaced by getpagesize now. - * wincap.h (wincaps::has_mmap_alignment_bug): New element. - * wincap.cc: Implement above element throughout. - * winsup.h (getshmlba): Drop prototype. - (getsystempagesize): Add prototype. - (mmap_init): Ditto. - * include/sys/mman.h: (Not yet) define MAP_NORESERVE. - -2005-11-28 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::fstat_helper): Don't rely on - has_acl() state for evaluating inodes. Temporarily(?) enable "real" - inodes for remote drives. - -2005-11-25 Christopher Faylor - - * heap.cc: Remove spurious getpagesize declaration. - -2005-11-25 Christian Franke - - * exceptions.cc (ctrl_c_handler): Distinguish CTRL-BREAK from CTRL-C in - some cases. - -2005-11-23 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_slave::open): Reset the current windows - station whenever ctty == -1 regardles of whether there's a windows - station already assigned. Close the old windows station in this - situation. - * pinfo.cc (_pinfo::set_ctty): Reinstate incrementing of console count - when recording ctty so that the current tty is always around. - * autoload.cc (CloseWindowStation): Define. - -2005-11-18 Christopher Faylor - - * strptime.cc (_strptime): Fix gcc warnings. - -2005-11-18 Christopher Faylor - - * memmem.cc: Move from here. - * lib/memmem.cc: Move to here. - -2005-11-18 Corinna Vinschen - - * libc: Add subdirectory. - * Makefile.in (VPATH): Add libc subdir. - (DLL_OFILES): Add strptime.o and timelocal.o. - * cygwin.din: Export timelocal and timegm. - * localtime.cc: Define STD_INSPIRED unconditionally. - * include/cygwin/time.h (timelocal): Add declaration. - (timegm): Ditto. - * include/cygwin/version.h: Bump API minor version. - * libc/strptime.cc: New file. - * libc/timelocal.cc: New file. - * libc/timelocal.h: New file. - -2005-11-18 Christopher Faylor - - * include/cygwin/sys_time.h: Move futimes and lutimes declaration here - from newlib. - -2005-11-18 Christopher Faylor - - * times.cc (timezone): Put back (void). - * include/cygwin/time.h: Add more cygwin stuff from newlib. - -2005-11-18 Christopher Faylor - - * include/cygwin/sys_time.h: Rename from include/cygwin/time.h. - * include/cygwin/time.h: New file. - -2005-11-17 Christopher Faylor - - * fork.cc (fork): Move top-of-stack calculation later. - - * pinfo.cc (_pinfo::set_ctty): Use __ctty to print current console in - debugging output. - -2005-11-17 Corinna Vinschen - - * fhandler_tty.cc (fhandler_tty_slave::open): Don't expect that - service applications have no window station attached. - -2005-11-16 Christopher Faylor - - * times.cc (hires_ms::prime): Don't escalate the priority. - -2005-11-14 Christopher Faylor - - * include/sys/elf64.h: Fix types to reflect linux usage. - -2005-11-14 Corinna Vinschen - Christopher Faylor - - * fhandler.h (fhandler_console::fixup_after_fork_exec): Define with - additional bool parameter. - (fhandler_console::fixup_after_exec): Accommodate - fixup_after_fork_exec's parameter. - (fhandler_console::fixup_after_fork): Ditto. - * fhandler_console.cc (fhandler_console::fixup_after_fork_exec): Avoid - opening new console only when close_on_exec AND execing. - -2005-11-14 Christopher Faylor - - * fhandler.h (fhandler_console::fixup_after_fork_exec): Declare new function. - (fhandler_console::fixup_after_fork): Use fixup_after_fork_exec. - (fhandler_console::fixup_after_exec): Ditto. - * fhandler_console.cc (fhandler_console::fixup_after_fork): Delete definition. - (fhandler_console::fixup_after_fork_exec): Rename from fixup_after_exec. - * pinfo.cc (_pinfo::set_ctty): Don't play with console count here. - * syscalls.cc (close_all_files): Don't close cygheap ctty if hExeced - since the child will be copying information from us. - (setsid): Use myctty() rather than raw ctty #. - -2005-11-13 Christopher Faylor - - * cygheap.h (init_cygheap::manage_console_count): Declare new function. - (init_cygheap::console_count): Renamed from open_fhs. Make private. - * cygheap.cc (init_cygheap::manage_console_count): Define new function. - * dtable.cc (dtable::fixup_after_exec): Always call fixup_after_exec on - elements of fd even when they are about to be closed. - * fhandler.h (report_tty_counts): Remove open_fhs from debugging - output. - * fhandler_console.cc (fhandler_console::open): Use - manage_console_count rather than manipulating count directly. - (fhandler_console::close): Ditto. - (fhandler_console::fixup_after_fork): Ditto. - (fhandler_console::fixup_after_exec): Ditto. Don't close handles if - close_on_exec. - * fhandler_tty.cc (fhandler_tty_slave::open): Use - manage_console_count() rather than manipulating count directly. - Reflect change in arguments to report_tty_counts(). - (fhandler_tty_slave::close): Ditto for both. - (fhandler_tty_slave::dup): Ditto for both. - (fhandler_tty_slave::ioctl): Use myctty() rather than raw ctty #. - (fhandler_tty_slave::fixup_after_fork): Reflect change in arguments to - report_tty_counts(). - (fhandler_tty_master::init_console): Use manage_console_count() rather - than manipulating count directly. - * fhandler_clipboard.cc (fhandler_dev_clipboard::fixup_after_exec): - Don't perform any operations if close_on_exec. - * fhandler_dsp.cc (fhandler_dev_dsp::fixup_after_exec): Ditto. - * fhandler_raw.cc (fhandler_dev_raw::fixup_after_exec): Ditto. - * fhandler_serial.cc (fhandler_serial::fixup_after_exec): Ditto. - * pinfo.h (_pinfo::_ctty): Declare new function. - (myctty): Declare new macro. - (__ctty): Declare new macro. - * pinfo.cc (_pinfo::_ctty): Define new function. - (_pinfo::set_ctty): Use manage_console_count() rather than manipulating - count directly. - * signal.cc (kill_pgrp): Use myctty() and __ctty() macros rather than - raw ctty #. - * syscalls.cc (setsid): Ditto. Use manage_console_count() rather than - manipulating count directly. - -2005-11-13 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::recvfrom): Just return 0 (EOF) - in case of WSAESHUTDOWN. - (fhandler_socket::recvmsg): Ditto. - * poll.cc (poll): Set revents to POLLIN instead of POLLHUP. Add comment. - -2005-11-11 Christopher Faylor - - * cygheap.h (init_cygheap::_gtod): Remove. - * cygwin.din: Export clock_getres and clock_setres. - * hires.h (hires_ms::minperiod): Delete declaration. - (hires_ms::began_period): Ditto. - (hires_ms::prime): Make void. - (hires_ms::resolution): Just define here. - (hires_ms::usecs): Remove unneeded argument. - (gtod): Redeclare as a variable. - * timer.cc (timer_thread): Eliminate argument to gtod.usecs(). - (timer_tracker::gettime): Ditto. - (timer_tracker::settime): Ditto. - * times.cc (gettimeofday): Ditto. - (hires_ms::began_period): Delete declaration. - (hires_us::prime): Remove debugging. - (hires_ms::prime): Make void. Eliminate period stuff. - (hires_ms::usecs): Eliminate argument to gtod.usecs(). - (hires_ms::resolution): New function. - (clock_getres): Ditto. - (clock_setres): Ditto. - * version.h: Bump API version to 143. - * include/cygwin/time.h: New file. - -2005-11-10 Christopher Faylor - - * times.cc (hires_ms::prime): Comment out call to timeBeginPeriod for - now. - (hires_ms::usecs): Call prime if haven't called began_period(). - - * param.h: Don't define stuff that is already defined in endian.h. - -2005-11-10 Christopher Faylor - - * include/endian.h: Remove USE_BSD ifdef since it is never defined on - Cygwin. - -2005-11-10 Corinna Vinschen - - * syslog.cc (setlogmask): Don't mask the mask. - (vsyslog): Fix priority check. - -2005-11-10 Scott Finneran - - * include/cygwin/signal.h: Add missing sigrelse prototype. - -2005-11-08 Christopher Faylor - - * fhandler_base.cc (fhandler_base::readv): Free buf, not a pointer into - the middle of buf. - -2005-11-08 Christopher Faylor - - * memmem.cc: New file. - * include/cygwin/version.h: Bump API version number to 142. - * cygwin.din: Export memmem. - * Makefile.in: Build memmem.o. - -2005-11-08 Christopher Faylor - - * environ.cc (spenvs): Make "SYSTEMDRIVE" an "always export". - -2005-11-07 Corinna Vinschen - - * times.cc (futimes): Redirect to utimes_worker if given file - descriptor is opened R/O. - -2005-11-06 Christopher Faylor - - * dcrt0.cc (dll_crt0_0): Initialize security data first so that it can - be used by subsequent handle creation. - -2005-11-04 Christopher Faylor - - * cygheap.h (init_cygheap::_gtod): New hires_ms element. - * hires.h (hires_ms::minperiod): Remove static designation. - (hires::began_period): New field. - * signal.cc: Include headers required for cygheap.h now that gtod lives - in the cygheap. - * timer.c: Ditto. - * times.cc (gtod): Delete variable. - (gtod::minperiod): Ditto. - (gtod::began_period): Define. - (hires_ms::prime): Add more debugging output. Call timeBeginPeriod - only when !began_period. - -2005-11-04 Christopher Faylor - - * times.cc (hires_ms::prime): More debugging. - (hires_ms::usecs): Ditto. - -2005-11-03 Christopher Faylor - - * times.cc (stupid_printf): Define and use throughout -- temporarily. - -2005-11-03 Christopher Faylor - - * times.cc (hires_ms::prime): Add lots of temporary debugging output. - -2005-11-02 Christopher Faylor - - * times.cc (hires_ms::minperiod): Make copy-on-fork. - (gettimeofday): Remove temporary debugging. - (hires_us::prime): Add lots of temporary debugging output. - -2005-11-02 Christopher Faylor - - * times.cc (gettimeofday): Add temporary debugging output. - -2005-11-01 Christopher Faylor - - * include/sys/cygwin.h: Define CYGWIN_SIGNAL_STRING. - * exceptins.cc (sigpacket::process): Send a _CYGWIN_SIGNAL_STRING to - gdb if the process is being debugged. A WIP. - -2005-10-29 Christopher Faylor - - * exceptions.cc (signal_exit): Eliminate setting of main thread - priority since process lock should make that unnecessary. - * fork.cc (stack_base): Eliminate. - (frok::parent): Subsume stack_base and just set stack stuff here. - Report on priority class in debugging output. - * spawn.cc (spawn_guts): Report on priority class in debugging output. - -2005-10-29 Christopher Faylor - - * fork.cc (frok::child): Change order of cleanup prior to return. - (fork): Save more of the stack. - - * gendef: Fix some comments. - - * sigproc.cc (wait_sig): Clarify debug output. - -2005-10-29 Christopher Faylor - - * child_info.h (CHILD_INFO_MAGIC): Reset. - -2005-10-24 Christopher Faylor - - * pinfo.cc (_pinfo::fds): Lock fdtab while enumerating. - -2005-10-24 Corinna Vinschen - - * spawn.cc (spawn_guts): Don't leave the function with return inside - pthread cleanup brackets. - -2005-10-24 Christopher Faylor - - * cygheap.h (cygheap_fdenum): Remove start_fd stuff. - (cygheap_fdenum::rewind): Ditto. - * pipe.cc (fhandler_pipe::open): Lock fdtab while enumerating. - * times.cc (utimes_worker): Ditto. - -2005-10-23 Christopher Faylor - - * cygheap.h (cygheap_fdenum::cygheap_fdenum): Record locked state or - suffer deadlocks. - (class locked_process): Move to another header. - * sync.h (lock_process): Define here. - * cygtls.cc (_cygtls::fixup_after_fork): Reset spinning state as well - as stacklock state. - * dcrt0.cc (lock_process::locker): Define. - (dtable::lock_cs): Delete. - (dll_crt0_0): Initialize process lock here ASAP. - * dtable.cc (dtable_init): Eliminate call to init_lock(). - (dtable::fixup_after_fork): Ditto. - (dtable::init_lock): Delete definition. - * dtable.h (dtable::init_lock): Delete declaration. - (dtable::lock): Use process lock rather than dtable-specific lock. - (dtable::unlock): Ditto. - - * sigproc.cc (sigproc_init): Minor change to debugging output. - - * times.cc (utime_worker): Use build_fh_pc rather than reinterpreting - the posix path name again. Return any error from path_conv immediately. - -2005-10-22 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::connect): Don't restrict - WSAEINVAL -> WSAEISCONN conversion to nonblocking sockets. - (fhandler_socket::accept): Use event driven technique to implement - interuptible accept. - (fhandler_socket::wait): Allow FD_ACCEPT handling. - * net.cc (cygwin_accept): Remove workaround for allowing blocking - accept. That's entirely in fhandler_socket::accept now. - -2005-10-22 Corinna Vinschen - - * fhandler.h (class fhandler_socket): Add timeout parameter to wait() - method. - * fhandler_socket.cc (fhandler_socket::connect): Use event driven - technique (prepare/wait/release) to implement interuptible connect. - (fhandler_socket::wait): Add timeout parameter. Allow FD_CONNECT - handling. - * net.cc (cygwin_connect): Remove braindead workaround for allowing - blocking connect. That's entirely in fhandler_socket::connect now. - -2005-10-22 Corinna Vinschen - - * include/cygwin/version.h: Fix typo. - -2005-10-21 Christopher Faylor - - * dir.cc (rmdir): Eliminate nonsensical code. - - * fork.cc (fork): Move exit debug_printf to last statement. - -2005-10-20 Corinna Vinschen - - * cygwin.din (futimes): Export. - (lutimes): Export. - * times.cc (utimes_worker): Created from utimes, add nofollow flag - to implement utimes and lutimes. - (utimes): Just call utimes_worker. - (lutimes): New function. - (futimes): Ditto. - * include/cygwin/version.h: Bump API minor version. - -2005-10-19 Christopher Faylor - - * sigproc.cc (child_info::sync): Move check for !wr_proc_pipe lower. - * spawn.cc (spawn_guts): Correct check for top-level process. - -2005-10-19 Corinna Vinschen - - * autoload.cc: Revert loading rcmd, rexec, rresvport and inet_network - from wsock32.dll since these symbols are not exported from ws2_32.dll. - -2005-10-19 Christopher Faylor - - * times.cc (utimes): Only consider fds opened with write access. - -2005-10-19 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_base::utimes_fs): Use existing handle - if fhandler has one. - * times.cc (utimes): Scan open fds for matching paths and use existing - fhandler if one exists. - -2005-10-19 Christopher Faylor - - * pinfo.cc (_pinfo::dup_proc_pipe): Make warning more severe by - actually printing it. - (_pinfo::alert_parent): Fix comment. Don't send to parent if we are in - an exec stub. - -2005-10-18 Christopher Faylor - - * cygtls.cc (handle_threadlist_exception): Improve diagnostic output. - - * sigproc.cc (child_info::sync): Only clear hProcess when execing. - (wait_sig): Protect readsig handle. - -2005-10-18 Corinna Vinschen - - * autoload.cc (NtLockVirtualMemory): Import. - (NtUnlockVirtualMemory): Import. - (GetProcessWorkingSetSize): Import. - (SetProcessWorkingSetSize): Import. - * cygwin.din (mlock): Export. - (munlock): Export. - * mmap.cc (mlock): New function. - (munlock): Ditto. - * ntdll.h (STATUS_WORKING_SET_QUOTA): Define. - (LOCK_VM_IN_WSL): Define. - (LOCK_VM_IN_RAM): Define. - (NtLockVirtualMemory): Declare. - (NtUnlockVirtualMemory): Declare. - * sysconf.cc (sysconf): Implement _SC_MEMLOCK_RANGE. - * wincap.h: Implement has_working_virtual_lock throughout. - * wincap.cc: Ditto. - * include/cygwin/version.h: Bump API minor version. - * include/sys/mman.h (mlock): Declare, - (munlock): Declare. - -2005-10-18 Christopher Faylor - - * sigproc.cc (child_info::sync): Use correct name when closing to - prevent warnings when DEBUGGING. - * spawn.cc (spawn_guts): Set myself.hProcess to pi.hProcess since this - may have been zeroed by the previous sync. - -2005-10-18 Christopher Faylor - - * sigproc.cc (child_info::sync): Fix typo which caused hProcess to - never be cleared. Only clear hProcess when not forking. - -2005-10-17 Christopher Faylor - - Change process_lock to lock_process throughout. - Change all calls to new cygthread to handle extra argument, throughout. - * cygthread.h (cygthread::callproc): Declare new method. - (cygthread::cygthread): Add optional length argument to allow copying - arguments to executing thread. - * cygthread.cc (cygthread::callproc): Define new method. - (cygthread::stub): Use callfunc to invoke thread func to allow - potentially allocating stack memory which will be returned. - (cygthread::simplestub): Ditto. - (cygthread::cygthread): Accept arglen argument. Reset ev here prior to - activating thread. Wait for ev after activating thread if we're - copying contents to the thread. Wait until the end before setting h, - to allow thread synchronization. - (cygthread::release): Don't reset ev here. Rely on that happening the next - time the thread is activated. - * pinfo.h (commune_process): Rename declaration from _pinfo::commune_process. - * pinfo.cc (commune_process): Ditto for definition. Modify slightly to allow - running as a separate cygthread. - * sigproc.cc (child_info::sync): Always wait for both subproc_ready and - any hProcess if we have a cygwin parent. - (talktome): Change argument to be a pointer to siginfo_t. Contiguously - allocate whole siginfo_t structure + any needed extra for eventual passing - to commune_process thread. - (wait_sig): Accommodate change in talktome argument. - - * pipe.cc (fhandler_pipe::fixup_after_exec): Remove debugging. - -2005-10-17 Corinna Vinschen - - * autoload.cc: Never load wsock32.dll. Load all wsock32 function - from ws2_32. Rearrange symbol order accordingly. None of the ws2_32 - functions is optional right now. - (wsadata): Move from net.cc here. Define NO_COPY. - (wsock_init): Drop unused symbols ws2_32_handle and wsock32_handle. - (load_wsock32): Remove. - (WSACleanup): Remove. - * fhandler_socket.cc: Drop Winsock 1 accommodations throughout. - (fhandler_socket::readv): Accommodate new POSIX style struct msghdr. - (fhandler_socket::writev): Ditto. - (fhandler_socket::recvmsg): Ditto. Handle "old" applications using - former struct msghdr correctly. - * net.cc: Drop Winsock 1 accommodations throughout. - (wsadata): Move definition to autoload.cc. - (set_socket_inheritance): Remove. - (convert_ws1_ip_optname): New static function to convert Winsock1 - IPPROTO_IP option values into Winsock2 IPPROTO_IP option values. - (cygwin_setsockopt): Remove wrong and incomplete cleartext printing - of optname. For "old" applications, convert optname from Winsock1 - to Winsock2 values before using them. Add comment to describe the - IP_TOS weirdness on W2K and above. - (cygwin_getsockopt): Remove wrong and incomplete cleartext printing - of optname. For "old" applications, convert optname from Winsock1 - to Winsock2 values before using them. - * select.cc (start_thread_socket): Forget about winsock2_active. - * winsup.h (wsock32_handle): Remove declaration. - (ws2_32_handle): Ditto. - (netapi32_handle): Ditto. - (wsadata): Ditto. - (winsock2_active): Remove definition. - * include/cygwin/socket.h: Change formatting slightly. - (socklen_t): Move definition up in file. - (struct msghdr): Convert to POSIX style. - (struct cmsghdr): New type. - (CMSG_ALIGN): New macro. - (CMSG_LEN): Ditto. - (CMSG_SPACE): Ditto. - (CMSG_FIRSTHDR): Ditto. - (CMSG_NXTHDR): Ditto. - (CMSG_DATA): Ditto. - (SCM_RIGHTS): Ditto. - (struct OLD_msghdr): Define old msghdr structure for Cygwin internal - purposes. - (MSG_TRUNC): New macro. - (MSG_CTRUNC): Ditto. - (IP_OPTIONS): Redefine IPPROTO_IP option values to Winsock2 values. - Keep Winsock1 values for Cygwin internal purposes. - * include/cygwin/version.h: Bump API minor version. - (CYGWIN_VERSION_CHECK_FOR_USING_ANCIENT_MSGHDR): Define to check for - applications using old struct msghdr. - (CYGWIN_VERSION_CHECK_FOR_USING_WINSOCK1_VALUES): Define to check for - applications using old Winsock1 IPPROTO_IP values. - -2005-10-13 David Rothenberger - Christopher Faylor - - * Makefile.in (MKDIRP): Just use raw $(INSTALL) rather than - $(INSTALL_DATA). Create directories with 755 permissions. - -2005-10-12 Christopher Faylor - - * dir.cc (mkdir): Abandon use of PC_WRITABLE. - (rmdir): Ditto. - * path.h (PC_WRITABLE): Delete. - * path.cc (path_conv::check): Remove PC_WRITABLE accommodations. - Revisit later. - -2005-10-12 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::rmdir): Convert an - ERROR_INVALID_FUNCTION into an ERROR_FILE_NOT_FOUND. Add comment - to explain why. - -2005-10-11 Christopher Faylor - - * Makefile.in: Make sure that directories are created prior to copying - to them. - -2005-10-11 Christopher Faylor - - * net.cc (cygwin_gethostbyname): Remove debugging. - -2005-10-11 Corinna Vinschen - - * syslog.cc (try_connect_syslogd): Add priority parameter. Use writev - to add the priority to the message in a syslog conformant way. - (vsyslog): If facility isn't set in the priority, use default facility - as given in call to openlog. Fix agressive use of spaces in syslog - output. Call try_connect_syslogd with priority parameter. - -2005-10-11 Christopher Faylor - - * (symlink_info::set_error): Change to return bool if input error - should be ignored. - (symlink_info::check): Treat path as a normal file if set_error returns - false. - -2005-10-03 Christopher Faylor - - * cygheap.h (class process_lock): New class. - * dtable.h (class dtable): Add class process_lock as a friend. - * dcrt0.cc (get_exit_lock): Delete. - (do_exit): Use process_lock class instead of get_exit_lock. - * exceptions.cc (signal_exit): Ditto. - * pinfo.cc (pinfo::exit): Ditto. - (_pinfo::commune_process): Set process lock around this whole function. - (_pinfo::commune_request): Use process_lock rather than myself.lock. - * pinfo.h (pinfo::_lock): Delete. - (pinfo::initialize_lock): Delete. - (pinfo::lock): Delete. - (pinfo::unlock): Delete. - * winsup.h (get_exit_lock): Delete declaration. - -2005-10-03 Corinna Vinschen - - * uname.cc (uname): Disable use of GetNativeSystemInfo. - -2005-10-01 Christopher Faylor - - * dcrt0.cc (get_exit_lock): Use myself.lock rather than exit_lock. - * exceptions.cc (exit_lock): Delete. - (events_init): Don't init exit_lock. - * (_pinfo::commune_process): Add per-PICOM debugging. - * sigproc.cc (talktome): Add some temporary debugging statements. - - * fhandler_proc.cc (format_proc_cpuinfo): Cosmetic change. - (format_proc_partitions): Ditto. - * syscalls.cc (locked_append): Ditto. - -2005-09-30 Christopher Faylor - - * dcrt0.cc (do_exit): Don't set ES_SET_MUTO here. Call get_exit_lock() - instead. - (get_exit_lock): New function. Grabs the lock and sets initial - exit_state. - * exceptions.cc (try_to_debug): Use low_priority_sleep. - (sigpacket::process): Avoid handler if this is an exec stub. - (signal_exit): Use get_exit_lock rather than manipulating the exit_lock - critical section directly. - * pinfo.cc (pinfo::exit): Ditto. - * winsup.h (get_exit_lock): Declare. - (exit_lock): Delete declaration. - -2005-09-30 Corinna Vinschen - - * fhandler_disk_file.cc: Change calls to pc.set_attributes into - calls to pc.file_attributes throughout. - * path.h (class path_conv): Remove superfluous set_attributes method. - -2005-09-30 Corinna Vinschen - - * fhandler_floppy.cc (fhandler_dev_floppy::get_drive_info): Use - fhandler method to access major device number. Add comment to - explain floppy weirdness. - -2005-09-30 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Also use - attributes stored in this->pc if call to GetFileInformationByHandle - failed. - -2005-09-30 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Only write - attributes if call to GetFileInformationByHandle was successful. - -2005-09-29 Christopher Faylor - - * fork.cc (frok::parent): Simplify error messages. Don't issue an - error when child.remember fails. - (fork): When appropriate, build up an error message from grouped.error. - -2005-09-29 Corinna Vinschen - - * fhandler_floppy.cc (fhandler_dev_floppy::get_drive_info): Don't call - EX ioctls on floppy drives. - -2005-09-29 Corinna Vinschen - - * dir.cc (mkdir): Check for trailing /. or /.. component. - (rmdir): Ditto. - * path.cc (has_dot_last_component): New function. - * path.h (has_dot_last_component): Add declaration. - -2005-09-29 Corinna Vinschen - - * crt0.cc: Remove PPC considerations. - (WinMainCRTStartup): Add symbol as alias to mainCRTStartup. - -2005-09-28 Christopher Faylor - - Change name from commune_recv to commune_process throughout. - Change name from commune_send to commune_request throughout. - * pinfo.h (PICOM_EXTRASTR): New flag. - (PICOM_FIFO): Define with new flag. - (_pinfo::hello_pid): Delete. - (_pinfo::tothem): Delete. - (_pinfo::fromthem): Delete. - (_pinfo::commune_process): Rename from commune_recv. Add a siginfo_t - argument to declaration. - (_pinfo::commune_request): Rename from commune_send. Change DWORD to - __uint32_t in declaration. - * pinfo.cc (_pinfo::commune_process): Rename from commune_recv. Add - siginfo_t argument. Use information from argument rather than reading - from another pipe. Synchronize with other process's commune event. - (_pinfo::commune_request): Rename from commune_send. Change DWORD to - __uint32 in argument. Fill out information in new siginfo_t element - and rely on extended operation of sig_send rather than trying to deal - with synchronization issues here. Use process handle and read pipe - information filled out by sig_send to gather information from the other - process. - * sigproc.cc (sig_send): Take special action if "communing" to ensure - synchronization with the other process and to return information about - the other process to the caller. - (talktome): Accept a siginfo_t and handle arguments. Read additional - information from the signal pipe when _si_commune._si_code has the - PICOM_EXTRASTR flag set. - (wait_sig): Pass the transmitted siginfo_t struct and the pipe handle - to talktome. Close pipe read handle as soon as possible after we - detect that we're exiting. - -2005-09-28 Christopher Faylor - - * hookapi.cc (hook_or_detect_cygwin): Correct inverted test for whether - to allocate a buffer by always allocating a buffer. - -2005-09-28 Corinna Vinschen - - * fhandler.h (class fhandler_dev_raw): Delete current_position and - eof_detected status flag. Delete is_eom and is_eof methods. - Move drive_size, bytes_per_sector, eom_detected status flag, as well - as the methods read_file, write_file, raw_read and raw_write to ... - (class fhandler_dev_floppy): ... here. Remove is_eom and is_eof - methods. Add dup method. - * fhandler_floppy.cc (IS_EOM): New macro. - (fhandler_dev_floppy::is_eom): Remove. - (fhandler_dev_floppy::is_eof): Remove. - (fhandler_dev_floppy::fhandler_dev_floppy): Initialize status flags. - (fhandler_dev_floppy::get_drive_info): Only call EX functions on - systems supporting them and stop suffering strange delays. - (fhandler_dev_floppy::read_file): Move here, drop setting - current_position. - (fhandler_dev_floppy::write_file): Move here, drop setting - current_position. - (fhandler_dev_floppy::open): Rearrange comment. - (fhandler_dev_floppy::dup): New method. - (fhandler_dev_floppy::get_current_position): New inline method. Use - instead of former current_position were appropriate. - (fhandler_dev_floppy::raw_read): Move here. Drop EOF handling. - (fhandler_dev_floppy::raw_write): Move here. Drop EOF handling. - (fhandler_dev_floppy::lseek): Remove useless conditions. Convert - sector_aligned_offset to LARGE_INTEGER to improve SetFilePointer call. - (fhandler_dev_floppy::ioctl): Move blocksize check in RDSETBLK case - to here. - * fhandler_raw.cc (fhandler_dev_raw::is_eom): Remove. - (fhandler_dev_raw::is_eof): Remove. - (fhandler_dev_raw::write_file): Remove. - (fhandler_dev_raw::read_file): Remove. - (fhandler_dev_raw::raw_read): Remove. - (fhandler_dev_raw::raw_write): Remove. - (fhandler_dev_raw::dup): Drop copying removed members. - (fhandler_dev_raw::ioctl): Drop blocksize testing. - * wincap.h: Implement has_disk_ex_ioctls throughout. - * wincap.cc: Ditto. - (wincap_vista): Preliminary wincaps for Windows Vista/Longhorn. - (wincapc::init): Add Vista/Longhorn handling. - -2005-09-28 Christopher Faylor - - * dcrt0.cc (getstack): New function. - (alloc_stack): Use tls stuff for stack info rather than calling - VirtualQuery. - (dll_crt0_0): Initialize _impure_ptr stuff much earlier. Move - init_console_handler here. - * fork.cc (class frok): New class renamed from local fork() struct. - (stack_base): Change argument type. Use tls stuff to determine stack - info rather than calling VirtualQuery. - (frok::child): Rename from fork_child. Eliminate now unneeded - arguments. - (frok::parent): Rename from fork_parent and ditto. Set error and errno - as appropriate. Fixup impersonation in cleanup, if needed. Try harder - to set errno appropriately. - (fork): Define "grouped" as a frok type. Deal with errors from - fork_parent here. - * init.cc (dll_entry): Remove init_console_handler call. - -2005-09-28 Christopher Faylor - - * pinfo.cc (_pinfo::dup_proc_pipe): Ignore error if the child process - has just gone away. - -2005-09-27 Christopher Faylor - - * init.cc (prime_threads): Make this static, as it should be. - (dll_entry): Apply cosmetic changes to define closer to the way MSDN - suggests. - -2005-09-27 Corinna Vinschen - - * pthread.cc (mangle_sem_name): Use cygheap->shared_prefix instead - of fiddling with wincap.has_terminal_services manually. - -2005-09-27 Corinna Vinschen - - * cygheap.cc (cygheap_init): Add GLOBAL_PRIV to hProcToken explicitely - since hProcImpToken isn't initialized here. - * shared.cc (open_shared): Always print mapname instead of name in - debug output. - -2005-09-27 Christopher Faylor - - * strace.cc (strace::vsprntf): Avoid printing a zero pid. - -2005-09-27 Corinna Vinschen - - * init.cc (dll_entry): Call IsWow64Process with GetCurrentProcess - as process handle since hMainProc isn't initialized here. - -2005-09-27 Corinna Vinschen - - * fhandler_floppy.cc (fhandler_dev_floppy::get_drive_info): Always - try IOCTL_DISK_GET_DRIVE_GEOMETRY_EX and - IOCTL_DISK_GET_PARTITION_INFO_EX ioctls first, to allow access to GPT - partitioned disks. Fall back to old non-EX ioctls otherwise. - Add comment to explain NT4 weirdness. - -2005-09-26 Corinna Vinschen - - * errno.cc (errmap): Map ERROR_SEEK and ERROR_SECTOR_NOT_FOUND. - -2005-09-26 Christopher Faylor - - * exceptions.cc (_cygtls::call_signal_handler): Minor cleanup. - -2005-09-26 Corinna Vinschen - - * fhandler.h (class fhandler_dev_raw): Add drive information members - drive_size, current_position and bytes_per_sector. - (fhandler_dev_floppy::get_drive_info): Declare. - * fhandler_floppy.cc (fhandler_dev_floppy::is_eom): Define ERROR_SEEK - and ERROR_SECTOR_NOT_FOUND as end-of-medium conditions. - (fhandler_dev_floppy::get_drive_info): New method to have one function - retrieving drive info. - (fhandler_dev_floppy::open): Call get_drive_info to get drive - information right from the start. - (fhandler_dev_floppy::lseek): Use and set drive information members. - Especially keep track of current_position. - (fhandler_dev_floppy::ioctl): Ditto. - * fhandler_raw.cc (fhandler_dev_raw::write_file): Keep track of - current_position. - (fhandler_dev_raw::read_file): Ditto. - (fhandler_dev_raw::raw_read): Never try to read beyond end-of-medium. - (fhandler_dev_raw::dup): Handle new drive information members. - -2005-09-26 Christopher Faylor - - * exceptions.cc (handle_exceptions): Just set si_code to SI_KERNEL - first and let it be overridden. - -2005-09-26 Yitzchak Scott-Thoennes - - * exceptions.cc (_cygtls::call_signal_handler): Call signal handler - with extra siginfo_t * and void * parameters when SA_SIGINFO flag is - set. - * signal.cc (signal): Clear SA_SIGINFO flag. - (sigqueue): Fix incorrect setting of si_code. - * sigproc.cc (signal_fixup_after_exec): Clear SA_SIGINFO flag when - setting handler to SIG_DFL. - -2005-09-26 Christopher Faylor - - * pinfo.cc (proc_waiter): Properly fill out si_code as according to SUSv3. - -2005-09-26 Christopher Faylor - - * exceptions.cc (handle_exceptions): Properly fill out si_code as - according to SUSv3. - -2005-09-25 Christopher Faylor - - * sigproc.cc (wait_sig): Cosmetic change. - * pinfo.cc (pinfo::exit): Don't explicitly remove myself since some - other thread may still be using it. - -2005-09-24 Christopher Faylor - - * sigproc.cc (sigproc_terminate): More reversion of - always-exit-from-sigthread change. - -2005-09-23 Christopher Faylor - - * shared.cc (open_shared): Add crucial bit of debugging info. - -2005-09-23 Christopher Faylor - - Semi-reversion of always-exit-from-sigthread change of 2005-09-15. - * exceptions.cc (sigpacket::process): Eliminate return after call to - reinstated noreturn function. - (signal_exit): Allow function to exit when a captive process has been - terminated. - * pinfo.cc (pinfo::exit): Enter exit_lock here. Once again exit here - under control of exit_lock. - * sigproc.cc (sig_send): Don't wait for completion if process is exiting. - Remove special __SIGEXIT accommodations. - (wait_sig): Just exit the thread when a __SIGEXIT has been detected. - Don't exit the process. - -2005-09-23 Christopher Faylor - - * net.cc (cygwin_gethostbyname): Remove debugging cruft. - -2005-09-23 Christopher Faylor - - * pinfo.cc (pinfo::exit): Call ExitProcess if called from signal - thread. - -2005-09-23 Christopher Faylor - - * pinfo.cc (pinfo::exit): Eliminate use of _my_tls.thread_handle. - * tlsoffsets.h: Regenerate. - -2005-09-23 Christopher Faylor - - * cygtls.h (struct _cygtls::thread_handle): Remove/revert. - * sigproc.h (struct sipacket::thread_handle): Put thread_handle here. - * sigproc.cc (sigproc_terminate): Move setting of thread_handle... - (sig_send): ...to here. Put it in packet being sent. Only close - pack.wakeup when we're waiting for completion. - (wait_sig): Use thread_handle directly from received packet. - -2005-09-22 Christopher Faylor - - * cygheap.cc (cygheap_fixup_in_child): It's not just for exec. - * cygtls.h (struct _cygtls::thread_handle): New field. - * dcrt0.cc (exit_lock): Remove declaration. - * winsup.h (exit_lock): Add declaration. - * exceptions.cc (sigpacket::process): Properly return after - signal_exit. - * pinfo.cc (pinfo::exit): Only exit the process if - _my_tls.thread_handle has not been filled out -- which should be an - impossible event. - * sigproc.cc (sigproc_terminate): Fillout _my_tls.thread_handle to - provide something for wait_sig to wait for. Use the siginfo_t version - of sig_send and fill out the tls argument with _my_tls. - (wait_sig): Wait for the thread specified in pack.tls or (for now) - complain bitterly if it doesn't exit. - * tlsoffsets.h: Regenerate. - -2005-09-22 Christopher Faylor - - * pinfo.cc (set_myself): Call strace.hello unconditionally when - DEBUGGING. - (pinfo::init): Sleep and issue debugging output before looping when a - PID_EXITED is found. - -2005-09-22 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::fstat_helper): Fix copy/paste - bug. - -2005-09-22 Christopher Faylor - - * strace.cc (strace::vsprntf): Avoid accessing myself->pid if !myself. - -2005-09-22 Christopher Faylor - - * include/sys/strace.h (_STRACE_ON): Remove semicolon from definition. - (_STRACE_OFF): Remove semicolon from definition. - -2005-09-22 Corinna Vinschen - - * fhandler.h (fhandler_base::fstat_helper): Declare with additional - file attributes argument. - * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Use - file attributes evaluated from NtQueryFileInformation or - FileInformationByHandle in call to fstat_helper. - Set pc.fileattr from just evaluated file attributes here. - (fhandler_base::fstat_by_name): Use file attributes evaluated from - FindFileFirst or default attribute in call to fstat_helper. - Set pc.fileattr from just evaluated file attributes here. - (fhandler_base::fstat_helper): Use file attributes given as argument, - not file attributes stored in this fhandler, since this information - is potentially wrong. Add comment to explain this. - * path.h (has_attribute): New global inline function. - (path_conv::set_attributes): New method to change fileattr. - -2005-09-21 Christopher Faylor - - * cygthread.cc (cygthread::operator new): Just use getenv() to look for - CYGWIN_FREERANGE_NOCHECK since the Windows environment may be truncated - by being previously execed. - -2005-09-20 Christopher Faylor - - * spawn.cc (av::fixup): Just blindly run any file if it has a .bat or - .cmd extension. - -2005-09-19 Christopher Faylor - - * dcrt0.cc (do_exit): Only call sigproc_terminate from one location -- - pinfo::exit. - * pinfo.cc (pinfo::exit): Move sigproc_terminate later so that signals - can be processed while waiting for hExeced child. - (pinfo::maybe_set_exit_code_from_windows): Set exit code from sigExeced - if it is non-zero. Set exit_state to ES_EXEC_EXIT prior to waiting for - captive process exit code. - * exceptions.cc (sigExeced): New global variable. - (signal_exit): Remove noreturn attribute from declaration. - (signal_exit): Just terminate captive process and return if hExeced on - the theory that the exit will be subsequently handled in the main - thread. - * sigproc.cc (sigproc_terminate): Eliminate test for - ES_SIGPROCTERMINATE and use ES_FINAL instead. - (sig_send): Use no_signals_available instead of duplicate test. - * winsup.h (ES_EXEC_EXIT): New enum. - (ES_SIGPROCTERMINATE): Delete. - -2005-09-19 Christopher Faylor - - * sigproc.cc (talktome): Take siginfo_t argument. Don't scan all pids - trying to find one that's talking to me. Just use the pid from - siginfo_t. - (wait_pid): Pass siginfo_t argument to talktome. - -2005-09-17 Christopher Faylor - - * pipe.cc (fhandler_pipe::open): Use 'cfree' to free buffer since it is - now allocated by cmalloc. - -2005-09-17 Corinna Vinschen - - * net.cc (cygwin_inet_ntop): Change len argument to socklen_t to - follow SUSv3. - * include/arpa/inet.h (inet_ntop): Ditto. - * include/cygwin/in.h: Include cygwin/socket.h to get socklen_t. - -2005-09-16 Christopher Faylor - - * environ.cc (build_env): Use "kilo"bytes not "mega"bytes. Return - immediately on error. - * spawn.cc (spawn_guts): Set return value to -1 on error from - build_env. - -2005-09-16 Christopher Faylor - - * environ.cc (build_env): Clear envblock and return NULL on attempt to - use env var > 32K. - * spawn.cc (spawn_guts): Set E2BIG if build_env detects an error. - -2005-09-16 Christopher Faylor - - * environ.cc (environ_init): Protect with a 'myfault' in case - GetEnvironmentStrings misbehaves. - -2005-09-16 Christopher Faylor - - * environ.cc (environ_init): Add debugging output with value returned - from GetEnvironmentStrings. - -2005-09-16 Christopher Faylor - - * environ.cc (environ_init): Issue an error if GetEnvironmentStrings - fails and return. - -2005-09-15 Christopher Faylor - - * pinfo.h (EXITCODE_SET): Move out of range of Windows error. - (EXITCODE_NOSET): Ditto. - * sigproc.cc (no_signals_available): Remove check for hwait_sig. Just - rely on my_sendsig. Pass in an argument controlling when it is - appropriate to test EXITCODE_SET. - (proc_can_be_signalled): Remove checks for myself since this function - is never called in that context. - (sigproc_init): Pre-initialize my_sendsig to non-zero so that - proc_can_be_signalled will know that we expect to be signalable soon. - (sig_send): Change debugging output. - -2005-09-15 Christopher Faylor - - * sigproc.cc (no_signals_available): Return true if sending to self - from the signal thread. - (wait_sig): Correct so that WaitForSingleObject is called when - hMainThread is != 0, rather than the reverse. - - * cygheap.cc (cygheap_fixup_in_child): Clarify potential error message. - - * fork.cc (fork_copy): Cosmetic change. - -2005-09-15 Christopher Faylor - - * sigproc.cc (wait_sig): Reorganize exit case so that ExitProcess is - always called, since that is the intent of sending a __SIGEXIT. Wait - forever for main thread to go away since, presumably, the main thread - told us it was going away. - -2005-09-14 Christopher Faylor - - * spawn.cc (av::fixup): Avoid breaking out of the wrong "loop". - -2005-09-14 Christopher Faylor - - * hookapi.cc (hook_or_detect_cygwin): Simplify very slightly. - * spawn.cc (av::fixup): Guard against problems reading an executable - which does not match Microsoft's documentation about PE format. - -2005-09-14 Christopher Faylor - - * spawn.cc (av::error): Eliminate. - (av::av): Remove reference to error. - (av::replace0_maybe): Ditto. - (av::dup_maybe): Ditto. - (av::dup_all): Ditto. - (av::unshift): Ditto. - (spawn_guts): On a fault, return E2BIG only if ENOMEM has been set. - Otherwise return EFAULT. - -2005-09-14 Christopher Faylor - - * cygtls.h (san): New structure. - (cygtls::andreas): New element. Replaces _myfault and _myfault_errno. - (cygtls::fault_guarded): Use andreas. - (cygtls::return_from_fault): Ditto. - (cygtls::setup_fault): Add a parameter denoting where to store old - fault handler, if any and use it to "stack" faults. - (cygtls::reset_fault): Restore fault from parameter. - (myfault::sebastian): New variable. - (myfault::~myfault): Pass sebastian to reset_fault. - (myfault::myfault): Store old fault values in sebastian. - -2005-09-14 Christopher Faylor - - * heap.cc (heap_init): Revert 2005-09-11 patch as it seems to - inexplicably cause problems with emacs. - -2005-09-14 Christopher Faylor - - Remove some more unneeded 'return;'s throughout. - -2005-09-14 Christopher Faylor - - * sigproc.h: Protect declaration so that it only happens when - __INSIDE_CYGWIN__. - -2005-09-14 Christopher Faylor - - * exceptions.cc (sigtid): Remove declaration. - (handle_exceptions): Use _sig_tls rather than sigtid to determine if - this is the signal thread. - (set_signal_mask): Ditto for conditionalized CGF code. - * pinfo.cc (pinfo::exit): Exit the thread if we forcefully terminated - the main thread. - * sigproc.cc (sigtid): Delete. - (_sig_tls): Define. - (sig_clear): Use _sig_tls rather than sigtid to determine if this is - the signal thread. - (sig_dispatch_pending): Ditto. - (wait_sig): Set _sig_tls here. - -2005-09-13 Christopher Faylor - - * dcrt0.cc (do_exit): Move sigproc_terminate call later since signal - handling was still needed for subsequent stuff. Call sigproc_terminate - with new exit_state value. - * pinfo.cc (pinfo::exit): Call sigproc_terminate with new exit_state - value. - * sigproc.cc (proc_terminate): Remove unnecessary (void) parameter. - (sigproc_terminate): Ditto. Add new argument to accept exit state to - be set. - (wait_sig): Reorganize __SIGEXIT handling. Add more debugging output. - * winsup.h (sigproc_terminate): Declare with new exit_state argument. - (exit_states): Reorganize to reflect new exit ordering of - sigproc_terminate. - -2005-09-13 Christopher Faylor - - * dcrt0.cc (do_exit): Rely on sigproc_terminate to set exit_state - appropriately. - * pinfo.cc (pinfo::exit): Always call sigproc_terminate here. Rely on - sigproc_terminate to signal signal thread to handle eventual process - exit. - * sigproc.cc (no_signals_available): Change criteria for determining if - this process can handle signals to itself. - (my_sendsig): New variable. Copy of my sendsig handle. - (proc_can_be_signalled): Don't send signals if exit code is set. - (sigproc_terminate): Use and set exit_state appropriately to determine - when to do anything. Send __SIGEXIT to self to control process exit. - (sig_send): Use my_sendsig for sending signals. Don't call - proc_can_be_signalled for myself since the criteria is now different - for sending signals to myself. - (wait_sig): Copy myself->sendsig to my_sendsig for future use. Exit - signal loop when __SIGEXIT is received. Wait for main thread to exit - and use its exit status to actually exit process. - * sigproc.h (__SIGEXIT): New enum. - -2005-09-13 Christopher Faylor - - * dcrt0.cc (alloc_stack): Eliminate superfluous "return;". - * debug.cc (add_handle): Ditto. - * devices.in (device::parse): Ditto. - * dtable.cc (dtable::vfork_parent_restore): Ditto. - (dtable::vfork_child_fixup): Ditto. - * environ.cc (parse_options): Ditto. - * errno.cc (seterrno_from_win_error): Ditto. - * exceptions.cc (sig_handle_tty_stop): Ditto. - (set_signal_mask): Ditto. - * fhandler.cc (fhandler_base::read): Ditto. - (fhandler_base::operator delete): Ditto. - (fhandler_base::seekdir): Ditto. - (fhandler_base::rewinddir): Ditto. - * fhandler_console.cc (fhandler_console::read): Ditto. - (fhandler_console::fixup_after_exec): Ditto. - * sigproc.cc (sigproc_init): Ditto. - (sigproc_terminate): Ditto. - - * devices.cc: Regenerate. - -2005-09-13 Christopher Faylor - - * sigproc.cc (wait_sig): Be more defensive about detecting when we're - exiting. - -2005-09-12 Christopher Faylor - - * cygthread.cc (cygthread::cygthread): Add more info to fatal error. - - * fhandler_disk_file.cc (fhandler_disk_file::readdir): Temporarily - remove insertion of /dev into root directory. - * path.cc (path_conv::check): Ditto. - -2005-09-11 Christopher Faylor - - * heap.cc (heap_init): Allocate heap from top down as a hedge against - subsequent ERROR_INVALID_ADDRESS in forked processes when CTRL-C is - pressed. - -2005-09-09 Christopher Faylor - - * heap.cc (heap_init): Be slightly more aggressive when trying to - allocate heap. Change fatal error message to avoid confusion with - cygheap. - - * spawn.cc (linebuf::finish): New function. - (linebuf::add): Cosmetic change. - (spawn_guts): Only avoid building windows command line if the program - being executed was actually mounted with -X. Don't return E2BIG if we - hit the 32K size and we're executing a detected cygwin program. Just - silently truncate the windows command line, instead. - -2005-09-08 Christopher Faylor - - * fhandler_serial.cc (fhandler_serial::tcgetattr): Just zero c_cflag - here rather than clearing CBAUD after the fact. - * termios.cc (tcgetattr): Revert previous change. - -2005-09-08 Christopher Faylor - - * fhandler_serial.cc (fhandler_serial::ioctl): Always return 0 for - window size. - * termios.cc (tcgetattr): Clear out baud part of c_cflag since it is - always ignored. - -2005-09-08 Corinna Vinschen - - * exceptions.cc (ctrl_c_handler): Disable any special CTRL_LOGOFF_EVENT - handling and add longish comment about the reasons. - -2005-09-07 Christopher Faylor - - * hookapi.cc (rvadelta): Change argument to DWORD to eliminate a - compiler warning. - - * path.h (path_conv::set_cygexec): New function. - * spawn.cc (av::iscygwin): Eliminate. - (av::av): Don't initialize iscygwin. - (spawn_guts): Just use real_path.iscygexec for all tests. - (av::fixup): Short circuit test if .exe extension and known cygexec. - Set cygexec flag appropriately if we find that program uses cygwin1.dll. - -2005-09-06 Christopher Faylor - - * dcrt0.cc (initial_env): Don't attempt stracing if dynamically loaded. - (dll_crt0_0): Move console initialization earlier. - * init.cc (dll_entry): Move console initialization here. - * exceptions.cc (init_console_handler): Fully remove any old console - handler. - (handle_sigsuspend): Make cancelable when called from non-main thread. - - * spawn.cc (spawn_guts): Don't fill out windows argv if we've deduced - that this is a cygwin-using program. - (av::fixup): Always check executables to see if they are using - cygwin1.dll. Don't consider .com files to be scripts. - * hookapi.cc (rvadelta): New function. - (PEHeaderFromHModule): Simplify slightly. - (hook_or_detect_cygwin): Use passed in name argument for "HMODULE" - rather than incorrectly reading current program. Calculate delta - needed to read image data and file names if this isn't a real - "HMODULE". - -2005-09-06 Corinna Vinschen - - * thread.h: Revert patch from 2005-09-05. - * thread.cc (pthread_mutex::can_be_unlocked): Return true also if - mutex is owned by MUTEX_OWNER_ANONYMOUS. - -2005-09-05 Christopher Faylor - - * cygheap.cc (cygheap_init): Eliminate debugging #if. - - * fork.cc (fork_parent): Don't issue errors if "somebody" has set the - PID_EXITED flag on a child. Don't close process handle if it has - potentially already been closed. - * pinfo.cc (winpids::add): Eliminate PID_ALLPIDS handling which was - obsoleted by previous changes. - - * spawn.cc (av::fixup): Do win16 detection for .com files. Make sure - that buffer has been unmapped in all cases. - -2005-09-05 Corinna Vinschen - - * thread.h (pthread_mutex::get_pthread_self): Remove. - (pthread_mutex::lock): Use ::pthread_self as self parameter. - (pthread_mutex::trylock): Ditto. - (pthread_mutex::unlock): Ditto. - (pthread_mutex::destroy): Ditto. - -2005-09-02 Dave Korn - - * Makefile.in (CXXFLAGS): Use 'override' to correctly set flags to - generate dependencies when invoked from top-level make. - -2005-08-28 Christopher Faylor - - * exceptions.cc (set_process_mask_delta): Conditionalize debugging - output. - * sigproc.cc (proc_subproc): Make strace output a little more verbose. - -2005-08-28 Christopher Faylor - - * cygtls.h (__ljfault): Declare. - (_cygtls::return_from_fault): Use __ljfault. - * exceptions.cc (set_signal_mask): Revert previous checkin. - * gendef (__sjfault): Split out into a separate function which doesn't - bother with any special signal locking. - (_ljfault): Return from a __sjfault without bothering with signals. - -2005-08-28 Christopher Faylor - - * cygtls.h (_local_storage::strerror_buf): Allocate more space. - * errno.cc (strerror_worker): New function, adapted from strerror. - (strerror): Use strerror_worker. - * tlsoffsets.h: Regenerate. - - * exceptions.cc (set_signal_mask): Minimize time during which mask_sync - is held. - -2005-08-28 Christopher Faylor - - * cygwin.din: Correct readdir_r typo. - -2005-08-27 Bas van Gompel - - * dir.cc (readdir_r): Invert sense on error test. - -2005-08-25 Corinna Vinschen - - * path.cc (normalize_posix_path): Keep two leading slashes - intact throughout. - (normalize_win32_path): Revert to only checking for slash. - (realpath): Convert drive letters to cygdrive paths before - doing anything else. - * shared_info.h (mount_info::cygdrive_posix_path): Make public. - -2005-08-25 Corinna Vinschen - - * path.cc (realpath): Drop call to mount_info::conv_to_posix_path - in favor of calling path_conv with PC_POSIX flag. Align error - handling closer to POSIX. As on Linux, return user space allocated - memory if second parameter is NULL. - -2005-08-25 Corinna Vinschen - - * path.cc (normalize_win32_path): Honor network paths. Fold more - than two leading dir separators into one. Check for dir separator - instead of just slashes to handle incoming Win32 paths correctly. - -2005-08-25 Christopher Faylor - - * errno.cc (errmap): Translate ERROR_NO_MORE_ITEMS to ENMFILE. - -2005-08-24 Christopher Faylor - - * exceptions.cc (handle_sigsuspend): Just sleep forever if called from - non-main thread. - (sigpacket:process): Simplify logic which determines when and how a - signal is masked. Don't trigger sigwait if there is a signal handler. - * sigproc.cc (wait_sig): Update comment. Try to process a signal which - is in the queue if it isn't queued for the target thread (this is still - not right). - -2005-08-24 Christopher Faylor - - * spawn.cc (perhaps_suffix): Record errno-type error value in third - argument. - (find_exec): On error, set errno returned from perhaps_suffix. - (spawn_guts): Ditto. - -2005-08-24 Christopher Faylor - - * fhandler_virtual.cc (fhandler_virtual::close): Don't free filebuf if - it's NULL. - * pinfo.cc (_pinfo::commune_send): Fix test for incorrect number of - bytes read from pipe. - -2005-08-24 Corinna Vinschen - - * syscalls.cc (endusershell): Reset shell_fp to NULL to allow - subsequent getusershell calls. - -2005-08-24 Christopher Faylor - - * path.cc (path_conv::check): Fill in fileattr for /dev, defaulting to - directory if /dev doesn't actually exist. - (win32_device_name): Don't consider FH_DEV to be a device since it's - really a directory which should go through mount processing. - -2005-08-24 Christopher Faylor - - * cygheap.h (cygheap_types): Add HEAP_COMMUNE. - * fhandler_proc.cc: Use cygheap rather than user heap for allocation of - filebuf throughout. - * fhandler_registry.cc: Ditto. - * fhandler_virtual.cc: Ditto. - * fhandler_process.cc: Ditto. - (get_mem_values): Use malloc/realloc/free rather than new. - * pinfo.cc (_pinfo::commune_send): Allocate on cygwin heap rather than - user heap. Avoid calling ReadFile when correct number of characters - have been read or suffer buffer corruption. - (_pinfo::fd): Allocate on cygwin heap rather than user heap. - (_pinfo::fds): Ditto. - (_pinfo::root): Ditto. - (_pinfo::cwd): Ditto. - (_pinfo::cmdline): Ditto. - - * devices.h (FH_DEV): New define. - * devices.in: Detect lone /dev. - * devices.cc: Regenerate. - * path.cc (path_conv::check): Treat FH_DEV as a special case. - -2005-08-23 Christopher Faylor - - * sigproc.h (set_signal_mask): Remove default on second parameter and - make pass by reference. - * signal.cc (abort): Accommodate change to set_signal_mask. - * select.cc (pselect): Ditto. - * exceptions.cc (handle_sigsuspend): Ditto. - (ctrl_c_handler): Ditto. - (sighold): Ditto. - (sigrelse): Ditto. - (set_process_mask_delta): Ditto. - (_cygtls::call_signal_handler): Ditto. - - * fhandler_disk_file.cc (fhandler_disk_file::readdir): Return ENMFILE - if __handle is not set. Set __handle to NULL when out of files. - (fhandler_disk_file::rewinddir): Don't close handle if it's NULL. - (fhandler_disk_file::closedir): Ditto. - -2005-08-22 Christopher Faylor - - * dir.cc (readdir_worker): Make static. Only add '.' and '..' when - readdir fails due to ENMFILE. - * fhandler_disk_file.cc (fhandler_disk_file::readdir): Only close - handle on error != ENMFILE. - -2005-08-22 Corinna Vinschen - - * mtinfo.h (mtinfo_drive::error): Fix argument bug in debug_printf call. - -2005-08-20 Christopher Faylor - - * cygerrno.h (geterrno_from_win_error): Change declaration to default - to using GetLastError and EACCESS. - * cygwin.din: Export readdir_r. - * include/cygwin/version.h: Bump API version number to 138. - * syscalls.cc (readdir_worker): New function, renamed from old - readdir() function. - (readdir): Use readdir_worker. - (readdir_r): New function. - * fhandler.h (fhandler_base::readdir): Accommodate second argument - indicating dirent buffer. - (fhandler_disk_file::readdir): Ditto. - (fhandler_cygdrive::readdir): Ditto. - (fhandler_proc::readdir): Ditto. - (fhandler_netdrive::readdir): Ditto. - (fhandler_registry::readdir): Ditto. - (fhandler_process::readdir): Ditto. - * fhandler.cc (fhandler_base::readdir): Ditto. - * fhandler_disk_file.cc (fhandler_disk_file::readdir): Ditto. - * fhandler_cygdrive.cc (fhandler_cygdrive::readdir): Ditto. - * fhandler_proc.cc (fhandler_proc::readdir): Ditto. - * fhandler_netdrive.cc (fhandler_netdrive::readdir): Ditto. - * fhandler_registry.cc (fhandler_registry::readdir): Ditto. - * fhandler_process.cc (fhandler_process::readdir): Ditto. - * include/sys/dirent.h (readdir_r): Add declaration. - -2005-08-19 Christopher Faylor - - * fhandler.h (dirent_states): Add dirent_saw_proc. - * fhandler_disk_file.cc (fhandler_disk_file::readdir): Fill in "proc" - if it is the root dir and it is missing. - -2005-08-19 Christopher Faylor - - * fhandler.h (dirent_states): Add dirent_isroot, dirent_saw_cygdrive, - dirent_saw_dev. - * dir.cc (opendir): Don't zero __flags here. Push that responsibility - to opendir methods. - (seekdir): Preserve dirent_isroot in __flags. - (rewinddir): Ditto. - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Set - dirent_isroot appropriately. - (fhandler_disk_file::readdir): Fill in "cygdrive" and "dev" if it is - the root dir and they are missing. - * fhandler_process.cc (fhandler_process::opendir): Set __flags here. - * fhandler_virtual.cc (fhandler_virtual::opendir): Set __flags here. - -2005-08-19 Christopher Faylor - - * winsup.h (create_pipe): Declare new function. - (CreatePipe): New define. - * miscfuncs.cc (create_pipe): Define new function. - -2005-08-18 Christopher Faylor - - * fhandler.h (fhandler_tty_common::lseek): Declare new method. - (fhandler_tty_slave::lseek): Delete old method. - (fhandler_tty_master::lseek): Delete old method. - * fhandler_tty.cc (fhandler_tty_common::lseek): Define new method. - -2005-08-18 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::recvfrom): Always initialize - ret to 0. - (fhandler_socket::recvmsg): Ditto. - -2005-08-18 Corinna Vinschen - - * errno.cc (strerror): Check errnum for underflow. - -2005-08-17 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Tweak debugging stuff. - -2005-08-17 Pavel Tsekov - - * fhandler_tty.cc (fhandler_tty_common::close): Rearrange the code so - that the master end of the input and output pipes is closed before - signalling an EOF event to the slave. - (fhandler_pty_master::close): Likewise. - -2005-08-14 Corinna Vinschen - - * init.cc (respawn_wow64_process): Make inline function. Remove - "noreturn" attribute. Add additional check if parent process is - actually a 64 bit process. - (dll_entry): Only test WOW64 processes with a stack in the usual - "dangerous" process space area. - -2005-08-11 Troy Curtiss - - * fhandler_serial.cc (fhandler_serial::tcgetattr): Return current baud - rate regardless of current DTR state. - -2005-08-11 Christopher Faylor - - * dcrt0.cc: Remove ld_preload declaration. - * winsup.h: Move ld_preload declaration here. - * fork.cc (fork_child): Call ld_preload() before returning. - -2005-08-11 Christopher Faylor - - * child_info. (CURR_CHILD_INFO_MAGIC): Refresh. - (child_info::child_info()): New constructor. - (child_info_spawn::child_info_spawn()): Ditto. - (child_info_spawn::operator new): New operator. - (child_info_spawn::set): New function. - * spawn.cc (av()): New constructor. - (av::operator new): New operator. - (av::set): New function. - (spawn_guts): Reorganize so that classes which allocate are defined - early in the function so that it can be properly cleaned up after an - efault. Set errno to E2BIG in the event of a SEGV situation. - -2005-08-08 Christopher Faylor - - * include/sys/cdefs.h: Remove extra line. - -2005-08-08 Corinna Vinschen - - * security.cc (get_reg_security): New static function. - (get_nt_object_security): Call get_reg_security for registry keys - to circumvent problems with predefined registry keys. - -2005-08-08 Corinna Vinschen - - * fhandler_process.cc (fhandler_process::open): Allow opening of - /proc//fd for reading. - * fhandler_registry.cc (fhandler_registry::open): Ditto for registry - keys. - -2005-08-08 Christopher Faylor - - * include/sys/cdefs.h (__CONCAT): Define. - * include/elf.h: New file. - * include/sys/elf32.h: Ditto. - * include/sys/elf64.h: Ditto. - * include/sys/elf_common.h: Ditto. - * include/sys/elf_generic.h: Ditto. - -2005-08-08 Christopher Faylor - - * cygwin.sc: Use simpler method to align .cygheap. - * dllfixdbg: Just copy .stab and .stabstr sections when making - cygwin1.dbg, rather than relying on objcopy to keep only the debug - sections since objcopy seems to get it wrong. - -2005-08-08 Corinna Vinschen - - * dtable.cc (build_fh_pc): Check setting fh to fhandler_nodevice for - NULL, too. - -2005-08-08 Corinna Vinschen - - * ftw.c: Include winsup.h. - * nftw.c: Ditto. - * include/ftw.h: Guard declarations appropriately. - -2005-08-08 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Add fts.o, ftw.o, nftw.o. - * cygwin.din: Export fts_children, fts_close, fts_get_clientptr, - fts_get_stream, fts_open, fts_read, fts_set, fts_set_clientptr, - ftw, nftw. - * fts.c: New file, imported from FreeBSD. - * ftw.c: Ditto. - * nftw.c: Ditto. - * include/fts.h: Ditto. - * include/ftw.h: Ditto. - * include/cygwin/version.h: Bump API minor number. - -2005-08-07 Christopher Faylor - - * Makefile.in (dtable_CFLAGS): Use -fomit-frame-pointer and - -fcheck-new. - * cygheap.cc (cmalloc): Only emit system_printf warnings on failure if - DEBUGGING. - (crealloc): Ditto. - (ccalloc): Ditto. - * dtable.cc (build_fh_name): Treat NULL return from cnew as indicative - of EMFILE condition. - (build_fh_dev): Ditto. - (dtable::dup_worker): Handle NULL return from build_fh_pc. - (dtable::vfork_child_dup): Trust dup_worker to set errno. - * fhandler.h (fhandler_base::new): Mark as nothrow. - -2005-08-07 Christopher Faylor - - * dllfixdbg: New perl script. - * configure.in: Detect objcopy, objdump, strip. - * configure: Regenerate. - * Makefile.in: Pass target objcopy/objdump to new dllfixdbg script. - Remove previous perl check. - * cygwin.sc: Add .gnu_debuglink_overlay section for eventual - replacement with .gnu_debuglink section. Revert move of cygheap to end - of image. - -2005-08-06 Corinna Vinschen - - * Makefile.in: Allow previous patch to work in a 64 bit environment. - -2005-08-06 Christopher Faylor - - * Makefile.in: Warn when end of cygheap is not on 64k boundary. - * cygwin.sc: Try harder to ensure that cygheap is on a 64k boundary. - Move cygheap to end of image to stop interference from unstripped debug - regions. - -2005-08-06 Christopher Faylor - - * include/endian.h: Move everything into this file and define things - more like linux. - * include/cygwin/types.h: Include endian.h. - * include/sys/dirent.h: Define DT_* types and conversion macros. - - * pinfo.cc (pinfo::init): Remove special handling for PID_ALLPIDS and - execed code, even though it probably still isn't quite right. - -2005-08-05 Michael Gorse - - * thread.cc (pthread::create(3 args)): Make bool. - (pthread_null::create): Ditto. - (pthread::create(4 args)): Check return of inner create rather than - calling is_good_object(). - * thread.h: Ditto. - -2005-08-05 Vaclav Haisman - - * fhandler_tty.cc (fhandler_tty_slave::tcflush): Return either 0 or -1. - -2005-08-05 Corinna Vinschen - - * thread.cc (pthread_cond_timedwait): Check abstime for validity - according to SUSv3. Rewrite timeout check and waitlength calculation - to avoid overflow problems. - -2005-08-02 Yitzchak Scott-Thoennes - - * include/sys/termios.h: Define TIOCMBIS and TIOCMBIC. - * fhandler.h (class fhandler_serial): Declare switch_modem_lines. - * fhandler_serial.cc (fhandler_serial::switch_modem_lines): New - static function to set or clear DTR and/or RTS. - (fhandler_serial::ioctl): Use switch_modem_lines for TIOCMSET - and new TIOCMBIS and TIOCMBIC. - * include/cygwin/version.h: Bump API minor number. - -2005-07-29 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_base::pread): Don't move file offset - pointer after I/O. - (fhandler_base::pwrite): Ditto. - -2005-07-29 Christopher Faylor - - * fhandler.h (fhandler_base::pread): Declare new function. - (fhandler_base::pwrite): Ditto. - (fhandler_disk_file::pread): Ditto. - (fhandler_disk_file::pwrite): Ditto. - * fhandler.cc (fhandler_base::pread): Define new function. - (fhandler_base::pwrite): Ditto. - * fhandler_disk_file.cc (fhandler_base::pread): Ditto. - (fhandler_base::pwrite): Ditto. - * syscalls.cc (pread): Define new function. - (pwrite): Ditto. - * cygwin.din: Export pread, pwrite. - - * include/sys/ioctl.h: Guard some _IO* declarations to avoid conflict - with socket.h. - -2005-07-29 Christopher Faylor - - * include/sys/ioctl.h: Add some linux defines. - -2005-07-29 Christopher Faylor - - * pinfo.cc (pinfo::init): Put back accidentally removed debug_printf. - -2005-07-29 Arto Huusko - - * cygthread.cc (cygthread::simplestub): Wait for h to be filled out - by main thread before assigning it. - -2005-07-29 Arto Huusko - - * pinfo.cc (pinfo::init): Sleep before retrying open_shared(). - -2005-07-29 Arto Huusko - - * fork.cc (fork_parent): Fix null deref if pinfo creation fails. - -2005-07-28 Christopher Faylor - - * cygmalloc.h (MSPACES): Define. This dropped through the cracks after - the last malloc update. - * dcrt0.cc: Fix a comment. - * malloc.cc (internal_malloc): Fix definition so that it can be safely - coerced. - -2005-07-27 Christopher Faylor - - * include/cygwin/in.h (INET_ADDRSTRLEN): Add new definition. - -2005-07-27 Christopher Faylor - - * gendef: Use nocr to remove \r's from input. - gendef (nocr): New function. - -2005-07-27 Christopher Faylor - - * fhandler_clipboard.cc (fhandler_dev_clipboard::close): Set membuffer - to NULL. - (fhandler_dev_clipboard::fixup_after_exec): Don't call close here. - Just set variables directly. - -2005-07-25 Christopher Faylor - - * include/byteswap.h: New file. - -2005-07-25 Christopher Faylor - - * include/cygwin/types.h: Define loff_t. - -2005-07-16 Christopher Faylor - - * child_info.h (child_info::sync): Pass pid and HANDLE rather than - using pinfo. - (child_info::child_info): Accept an argument controlling whether to - create proc_subproc. - (child_info_spawn::child_info_spawn): Ditto. - * sigproc.cc (child_info::child_info): Ditto. - (child_info_spawn::child_info_spawn): Ditto. - (child_info::sync): Use passed in pid and HANDLE. - * fork.cc (fork_parent): Reflect additional arguments required for - child_info::sync. - * hookapi.cc (hook_or_detect_cygwin): Rename. Change so that NULL 'fn' - argument just returns "true", indicating that program uses cygwin1.dll. - * spawn.cc (av::win16_exe): New element. - * spawn.cc (av::iscygwin): New element. - (av::fixup): New function. - (spawn_guts): Protect against SEGV. Use fixup function to detect when - it is safe to wait for a spawned (as opposed to an execed) program. - Reflect changes in child_info::sync arguments. - * external.cc (cygwin_internal): Reflect function renaming to - hook_or_detect_cygwin. - - * cygheap.cc (cygheap_fixup_in_child): Close handle after debug fixup - has been done to prevent false positives in handle collision. - - * exceptions.cc (try_to_debug): Notify debugger if already being - debugged. - -2005-07-09 Christopher Faylor - - * path.cc (mount): Only check win32_path when we know we need it. - -2005-07-09 Nicholas Wourms - - * cygwin.din (getline): Export. - (getdelim): Export. - * include/sys/stdio.h (getline): Replace macro with function prototype. - (getdelim): Likewise. - * include/cygwin/version.h: Bump API minor number. - -2005-07-08 Corinna Vinschen - - * cygwin.din (__getline): Export. - (__getdelim): Export. - * include/sys/stdio.h (getline): Define as __getline. - (getdelim): Define as __getdelim. - * include/cygwin/version.h: Bump API minor number. - -2005-07-06 Christopher Faylor - - Eliminate (void) cast on standalone function calls throughout. - -2005-07-05 Christopher Faylor - - * dcrt0.cc (cygwin_exit): Mark as "noreturn". - * sigproc.cc (child_info::ready): Don't signal parent that we are a - cygwin process if we are dynamically loaded. - -2005-07-05 Christopher Faylor - - * malloc.cc: Update to version 2.8.2. - -2005-07-05 Corinna Vinschen - - * fhandler_tape.cc (fhandler_dev_tape::close): Don't do "extra stuff" - when we know we're execing. - -2005-07-04 Christopher Faylor - - Change foo (void) to foo () for all c++ functions throughout. - Remove all fhandler_*::dump functions throughout. - - * fhandler.h (fhandler_dev_mem::close): Remove pass-through function in - favor of virtual method. - (handler_dev_raw::close): Ditto. - (fhandler_dev_clipboard::fixup_after_exec): New method. - * fhandler_dev_mem.cc (fhandler_dev_mem::close): Eliminate pass through - function in favor of virtual method. - * fhandler_dev_raw.cc (fhandler_dev_raw::close): Ditto. - * fhandler_clipboard.cc (fhandler_dev_clipboard::close): Don't go to - extra effort when execing. - (fhandler_dev_clipboard::fixup_after_exec): New function. - * fhandler_console.cc (fhandler_console::close): Don't do "extra stuff" - when we know we're execing. - * fhandler_disk_file.cc (fhandler_disk_file::close): Ditto. - * fhandler_dsp.cc (fhandler_dev_dsp::close): Ditto. - * fhandler_fifo.cc (fhandler_fifo.cc::close): Ditto. function in favor - of base function. - * fhandler_random.cc (fhandler_dev_random::close): Ditto. - * fhandler_registry.cc (fhandler_registry::close): Ditto. - * fhandler_tty.cc (fhandler_tty_slave::close): Ditto. - * fhandler_virtual.cc (fhandler_virtual::close): Ditto. - - * pinfo.cc (proc_waiter): Remove unneeded hExeced declaration. - * sigproc.cc: Ditto. - * winsup.h (hExeced): Define here. - - * fhandler_virtual.cc (fhandler_virtual::fixup_after_exec): Just call - close() to reinitialize things to known state. - -2005-07-04 Christopher Faylor - - * cygtls.h (_cygtls): Perform minor reformatting. - - * winsup.h (close_all_files): Reflect argument change. - * dtable.cc (close_all_files): Ditto. - * dtable.h: Ditto. - * fhandler.h: Ditto. - * spawn.cc (spawn_guts): Move close_all_files back to its original - location in first P_OVERLAY test but use argument denoting that handles - are only supposed to be closed, not released (more work to be done - here). - * syscalls.cc (close_all_files): Take an argument denoting whether to - release closed files or not. - - * path.cc (symlink): Change argument names to reflect linux man page. - (symlink_worker): Ditto. Also appropriately set ENOENT for empty - strings. - - -2005-07-04 Pierre Humblet - - * cygheap.h (struct init_cygheap): Delete cygwin_regname member. - * external.cc (cygwin_internal): Use cygpsid::get_id for - CW_GET_UID_FROM_SID and CW_GET_GID_FROM_SID. - Turn CW_SET_CYGWIN_REGISTRY_NAME and CW_GET_CYGWIN_REGISTRY_NAME - into noops. - -2005-07-03 Christopher Faylor - - * thread.cc (pthread_mutex::init): Remove unneeded efault/mutex check. - -2005-07-02 Christopher Faylor - - * thread.h (verifyable_object_state verifyable_object_isvalid): Delete - function declaration that should have been static. - * thread.cc (verifyable_object_state verifyable_object_isvalid): Make - inline static. - (pthread*::is_good_object): Move to directly after - verifyable_object_state verifyable_object_isvalid and make inline. - (check_valid_pointer): Delete function. - (pthread_cond_timedwait): Use myfault to detect valid pointer. - (pthread_mutex::init): Ditto. - -2005-07-02 Christopher Faylor - - Replace valid memory checks with new myfault class "exception - handling", almost everywhere. Leave some thread.cc stuff alone for - now. - * cygtls.h: Kludge some definitions to avoid including a problematic - windows header. - (_cygtls::_myfault): New entry. - (_cygtls::_myfault_errno): Ditto. - (_cygtls::fault_guarded): New function. - (_cygtls::setup_fault): Ditto. - (_cygtls::return_from_fault): Ditto. - (_cygtls::clear_fault): Ditto. - (myfault): New class. - * exceptions.cc (handle_exceptions): Handle case of guarded fault in - system routine. - * gendef: Add another entry point for setjmp that the compiler doesn't - know about and won't complain about. - * gentls_offsets: Just include windows.h rather than kludging a HANDLE - def. - * miscfuncs.cc (check_null_str): Delete. - (check_null_empty_str): Ditto. - (check_null_empty_str_errno): Ditto. - (check_null_str_errno): Ditto. - (__check_null_invalid_struct): Ditto. - (__check_null_invalid_struct_errno): Ditto. - (__check_invalid_read_ptr): Ditto. - (__check_invalid_read_ptr_errno): Ditto. - (dummytest): New function. - (check_iovec_for_read): Delete. - (chec_iovec): Rename from check_iovec_for_write. Take a read/write - parameter. - * tlsoffsets.h: Regenerate. - * winsup.h: Remove check_* declarations. - (check_iovec_for_read): Delete declaration. Turn into a define - instead. - (check_iovec_for_write): Ditto. - (check_iovec): New declaration. - - * thread.h: Use ifdef guard name consistent with other header files. - -2005-07-02 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number to 19. - -2005-06-30 Corinna Vinschen - - * fhandler.cc (fhandler_base::readv): Use malloc/free instead of alloca. - (fhandler_base::writev): Ditto. - -2005-06-29 Christopher Faylor - - * cygerrno.h: Make multi-inclusion safe. - * fhandler_termios.cc (fhandler_termios::tcsetpgrp): Deal with EINTR. - * dcrt0.cc (dll_crt0_0): Accommodate init_console_handler argument - change. - * winsup.h: Ditto. - * fhandler_tty.cc (fhandler_tty_slave::open): Ditto. - * exceptions.cc (init_console_handler): Ditto. Ignore console events - if we're not attached to a terminal. - * fhandler_tty.cc (fhandler_tty_slave::open): Ditto. - * wincap.cc: Implement has_null_console_handler_routine throughout. - * wincap.h: Ditto. - -2005-06-29 Christopher Faylor - - * autoload.cc (LoadDLLprime): Use a more descriptive name for autoload - text sections. - * cygwin.sc: Ditto. - -2005-06-27 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::facl): Add missing break. - -2005-06-24 Corinna Vinschen - - * path.cc (path_conv::check): Don't strip trailing dots and spaces - at the start of the path. - -2005-06-24 Corinna Vinschen - - * fhandler.cc (rootdir): Don't set errno. - * syscalls.cc (statvfs): Set errno to ENOTDIR if rootdir() failed. - -2005-06-22 Corinna Vinschen - - * fhandler.h (class fhandler_dev_tape): Add declaration for - fixup_after_fork and set_close_on_exec. - * fhandler_tape.cc (fhandler_dev_tape::open): Create mt_mtx mutex - inheritable. - (fhandler_dev_tape::close): Close mt_mtx. - (fhandler_dev_tape::dup): Duplicate mt_mtx and mt_evt as necessary. - (fhandler_dev_tape::fixup_after_fork): New method. - (fhandler_dev_tape::set_close_on_exec): New method. - -2005-06-21 Corinna Vinschen - - * security.cc (get_initgroups_sidlist): Drop special_pgrp parameter. - (get_setgroups_sidlist): Avoid duplicate groups in group list. - (create_token): Remove special_pgrp local variable. Accommodate - change to get_initgroups_sidlist call. - -2005-06-21 Corinna Vinschen - - * uinfo.cc (uinfo_init): Call reimpersonate to set the main thread's - impersonation token. - -2005-06-20 Corinna Vinschen - - * fhandler_proc.cc (format_proc_partitions): Only list recognized - partitions. Use partition number given by PartitionNumber member. - -2005-06-18 Corinna Vinschen - - * glob.c: (glob0): New local variable `limit`. Use in calls to glob1 - and globextend. - (glob1): Add `limit' parameter. - (glob2): Ditto. - (glob3): Ditto. - (globextend): Ditto. Implement GLOB_LIMIT handling. - * include/glob.h (GLOB_LIMIT): New define. - * include/cygwin/version.h: Bump API minor number. - -2005-06-17 Christopher Faylor - - * wincap.h (wincaps::detect_win16_exe): Declare. - (wincapc::detect_win16_exe): Implement. - * wincap.cc: Populate detect_win16_exe where appropriate. - * spawn.cc (spawn_guts): Only go out of the way to detect 16-bit apps - on systems which are flummoxed by them. - -2005-06-17 Christopher Faylor - - * spawn.cc (spawn_guts): Detect when executing a 16-bit application and - avoid setting the process pipe since this causes conniptions in Windows - 9x. - -2005-06-17 Corinna Vinschen - - * cygwin.din (inet_pton): Export. - (inet_ntop): Export. - * net.cc (cygwin_inet_pton): Implement inet_pton for AF_INET for now. - (cygwin_inet_ntop): Implement inet_ntop for AF_INET for now. - * include/arpa/inet.h (inet_pton): Declare. - (inet_ntop): Declare. - * include/cygwin/version.h: Bump API minor number. - -2005-06-17 Corinna Vinschen - - * fhandler.h (fhandler_union): Add missing members corresponding to - fhandler_fifo and fhandler_netdrive. - -2005-06-16 Corinna Vinschen - - * syscalls.cc (statvfs): Handle the case when GetDiskFreeSpaceEx - succeeds but GetDiskFreeSpace fails by faking bytes-per-sector and - sectors-per-cluster values. - -2005-06-15 Christopher Faylor - - * cygthread.cc (cygthread::detach): Fix debugging output. - * dcrt0.cc (dll_crt0_1): Create signal_arrived early -- before any - filename manipulation. - * sigproc.cc (sigproc_init): Don't create signal_arrived here. - * fork.cc (fork_child): Ditto. - * sigproc.h (create_signal_arrived): Declare. - -2005-06-14 Christopher Faylor - - * path.cc (path_conv::check): Always reset to FH_FS when component != 0 - and FH_NETDRIVE to fix problems with strict case checking. - -2005-06-12 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::recvmsg): Avoid SEGV in OpenSSH - when trying to pass file descriptor by setting msg->msg_accrightslen - to 0. - -2005-06-11 Christopher Faylor - - * Makefile.in: Avoid initial heap allocation since cygwin has its own - heap. - -2005-06-11 Christopher Faylor - - * fhandler_console.cc (fhandler_console::read): Fix a compiler warning. - -2005-06-10 Christopher Faylor - - * include/pthread.h: Change PTHREAD_MUTEX_DEFAULT to - PTHREAD_MUTEX_NORMAL. Revert PTHREAD_MUTEX_INITIALIZER to - PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP since that is actually closer - to what linux does. - * thread.h (cw_cancel_action): New enum. - (cancelable_wait): Use cw_cancel_action as third argument. - * thread.cc (cancelable_wait): Ditto. Don't wait for cancel if - cancel_action == cw_no_cancel. - (pthread::create): Don't wait for cancel event since that is racy. - (pthread_mutex::pthread_mutex): Set default to PTHREAD_MUTEX_ERRORCHECK. - (pthread_mutexattr::pthread_mutexattr): Ditto. - (pthread_mutex::_lock): Tell cancelable_wait not to wait for - cancellation event. - (semaphore::_timedwait): Accommodate change in cancelable_wait args. - (pthread::join): Ditto. - -2005-06-10 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::sendto): Always initialize - ret to 0. - (fhandler_socket::sendmsg): Ditto. - -2005-06-10 Corinna Vinschen - - * cygwin.din (imaxabs): Export. - (imaxdiv): Export. - (llabs): Export. - (lldiv): Export. - (strtoimax): Export. - (strtoumax): Export. - * include/inttypes.h (imaxabs): Activate declaration. - (imaxdiv): Ditto. - (strtoimax): Ditto. - (strtoumax): Ditto. - * include/cygwin/version.h: Bump API minor. - -2005-06-09 Christopher Faylor - - * cygthread.cc (cygthread::detach): Improve diagnostics for what should - be an impossible failure condition. - -2005-06-09 Christopher Faylor - - * cygtls.h (_local_storage::setmode_file): New element. - (_local_storage::setmode_mode): New element. - * tlsoffsets.h: Regenerate. - * cygwin.din (setmode): Define as cygwin_getmode. - * syscalls.cc (setmode_helper): Use setmode_* variables from tls rather - than using unthreadsafe static. - (setmode): Break out fwalk stuff. - (cygwin_setmode): New function. Put fwalk stdio stuff here. - -2005-06-09 Christopher Faylor - - * thread.cc (pthread_mutex::_lock): Use cancelable_wait rather than - WaitForSingleObject. - -2005-06-09 Christopher Faylor - - * cygwin.sc: Place .cygwin_dll_common in a more sensible spot. - -2005-06-09 Christopher Faylor - - * cygwin.sc: Place .cygwin_dll_common. - * init.cc (threadfunc_ix): Use a more common name for the section name. - -2005-06-09 Christopher Faylor - - * include/pthread.h (PTHREAD_MUTEX_INITIALIZER): Change to - PTHREAD_NORMAL_MUTEX_INITIALIZER_NP to be closer to linux default. - -2005-06-09 Christopher Faylor - - * thread.cc (cancelable_wait): No-op change to make sure that res is - always a valid WFMO return. - -2005-06-09 Christopher Faylor - - Change pthread::cancelable_wait to just cancelable_wait, throughout. - * thread.h (cw_sig_wait): New enum. - (fast_mutex::lock): Use cancelable_wait with resumable signal. - (cancelable_wait): Change fourth argument to cw_sig_wait enum. - * thread.cc (cancelable_wait): Ditto. Loop on signal detection if - fourth argument == cw_sig_resume. - -2005-06-08 Christopher Faylor - - * cygwin.sc: Apparently nonloading sections need to go last. - -2005-06-08 Christopher Faylor - - * cygwin.sc: Restore resource and reloc sections and use more modern - syntax for stabs sections. - -2005-06-08 Christopher Faylor - - * environ.cc (spenvs): Remove cut/paste error which associated - CYGWIN_DEBUG with HOME. - -2005-06-08 Corinna Vinschen - - * security.cc (cygwin_logon_user): Run LogonUser in the primary - process token context. Fix potential handle leak. - -2005-06-07 Corinna Vinschen - - * pinfo.cc (pinfo::init): Define sa_buf as PSECURITY_ATTRIBUTES and - allocate dynamically. - (pinfo::set_acl): Replace sa_buf by dynamically allocated acl_buf. - * sec_acl.cc (setacl): Allocate acl dynamically. - * sec_helper.cc (sec_acl): Add test for alignment of acl when - DEBUGGING is defined. - (__sec_user): Same for sa_buf. - * security.cc (verify_token): Define sd_buf as PSECURITY_DESCRIPTOR - and allocate dynamically. - (alloc_sd): Allocate acl dynamically. - security.h (sec_user_nih): Change first parameter to - SECURITY_ATTRIBUTES *. - (sec_user): Ditto. - * sigproc.cc (wait_sig): Define sa_buf as PSECURITY_ATTRIBUTES and - allocate dynamically. - * syscalls.cc (seteuid32): Define dacl_buf as PACL and allocate - dynamically. - * uinfo.cc (cygheap_user::init): Define sa_buf as PSECURITY_ATTRIBUTES - and allocate dynamically. - * winbase.h (ilockincr): Mark first argument of inline assembly as - earlyclobber. - (ilockdecr): Ditto. - -2005-06-07 Christopher Faylor - - * cygthread.cc (cygthread::detach): Make error message a little more - detailed. - * fhandler.cc (fhandler_base::raw_read): Ditto for debug message. - * dcrt0.cc (do_exit): Add some more synchronization tests. - * fhandler_fifo.cc (fhandler_fifo::dup): Don't duplicate a nonexistent - handle. Use derived return value rather than always retuning 0. - * fhandler_netdrive.cc (fhandler_netdrive::exists): Wnet -> WNet. - * winsup.h (exit_states): Add a couple of new exit states. - -2005-06-06 Corinna Vinschen - - * path.cc (symlink_info::check): If GetFileAttributes returns - with ERROR_SHARING_VIOLATION, the file exists. - -2005-06-06 Corinna Vinschen - - * uname.cc (uname): Change "amd64" to "x86_64" as on Linux. - -2005-06-06 Corinna Vinschen - - * uname.cc (uname): Add missing break. - -2005-06-05 Christopher Faylor - - * Makefile.in: Build sync.o with -fomit-frame-pointer and -O3. - -2005-06-05 Christopher Faylor - - * sync.cc (muto::acquire): Remove unneeded brackets and fix whitespace. - -2005-06-04 Christopher Faylor - - * malloc.cc: Update to Doug Lea's malloc v2.8.0. - -2005-06-03 Max Kaehn - - * dcrt0.cc (cygwin_dll_init): Initialize main_environ and cygtls. Add - comment to explain the caveats of this method. - * how-cygtls-works.txt: New file. - -2005-06-02 Christopher Faylor - - * dlfcn.cc (get_full_path_of_dll): Use a relative path when converting - so that the standard Windows rules for finding a library will be used - if no path is given. Stop explicitly searching /usr/bin since that is - now in effect. - -2005-06-01 Christopher Faylor - - Revert 2005-05-30 close_all_files changes. - * spawn.cc (spawn_guts): When execing, close all files after the child - has synced with us. - -2005-06-01 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_disk_file::fchown): Make sure that - disk open is called in case we're passed in a non-existent device. - -2005-06-01 Christopher Faylor - - * include/machine/stdlib.h: New file. - -2005-06-01 Christopher Faylor - - * thread.h (List_remove): Revert most of 2005-05-30 change. - -2005-06-01 Christopher Faylor - - * cygwin.sc: Don't output .reloc or .rsrc sections. Clean up stuff - around .cygheap and use a workaround to get things working with newer - (broken?) binutils. - -2005-05-31 Christopher Faylor - - * cygheap.cc (cygheap_end): Remove bogus section attribute. - * cygwin.sc: Make __cygheap_mid absolute. Remove unused _cygheap_foo. - -2005-05-30 Christopher Faylor - - * child_info.h (child_info::cygheap_h): Delete. - (child_info::dwProcessId): New field. - * cygheap.cc (init_cheap): Delete. - (dup_now): Ditto. - (cygheap_setup_for_child): Ditto. - (cygheap_setup_for_child_cleanup): Ditto. - (cygheap_fixup_in_child): Simplify. Use new "child_copy" function to - copy heap from parent. - (_csbrk): Don't attempt allocation if within cygheap section. Fix so - that more than one allocation will succeed. - (cygheap_init): Reset possibly-nonzero region to zero. - * cygheap.h (cygheap_setup_for_child): Delete declaration. - (cygheap_setup_for_child_cleanup): Ditto. - (cygheap_start): Define as an array. - * cygwin.sc: Modernize. Remove unneeded sections. Define cygheap - here. - * dcrt0.cc (do_exit): Reflect argument change to close_all_files. - * dtable.cc (dtable::vfork_parent_restore): Ditto. - * dtable.h: Ditto. - * fhandler.h: Ditto. - * fork.cc (fork_copy): Call ReadProcessMemory if there is no thread - (indicating that we're execing). - (fork_child): Don't mess with hParent. - (fork_parent): Remove hParent stuff. It happens earlier now. - Remove call to cygheap_setup_for_child* stuff. - (fork): Put child_info_stuff in grouped structure. Issue error if - parent handle is not set. - (child_copy): New function. - * sigproc.cc (child_info::child_info): Put cygheap settings here. Set - parent handle. - (child_info::~child_info): Close parent handle if it exists. - * spawn.cc (spawn_guts): Reorganize so that ciresrv is allocated at - only the last minute so that cygheap changes are reflected. Delete - cygheap_setup* calls. - * syscalls.cc (close_all_files): Add an argument to flag when the fd - entry should be released. - * winsup.h (close_all_files): Add an argument to close_all_files - declaration. Declare child_copy. - -2005-05-30 Vaclav Haisman - - * thread.h (List_remove): Make node parameter const. Use simple - comparison and assignment rather than InterlockedCompareExchangePointer - since access is already synchronized. - -2005-05-30 Christopher Faylor - - * dlfcn.cc (set_dl_error): Use UNIX error rather than Windows error. - -2005-05-29 Christopher Faylor - - * cygmagic: Remove debugging cruft missed on 2005-05-21. - -2005-05-29 Corinna Vinschen - - * path.cc (path_conv::check): Move component to function scope. Set - PATH_RO only on *real* FH_NETDRIVEs or on non-FH_NETDRIVE virtual - paths. Allow non-retrievable shares to be handled as files. - -2005-05-29 Eric Blake - - * include/limits.h (LLONG_MIN, LLONG_MAX, ULLONG_MAX): Always define. - -2005-05-28 Christopher Faylor - - * thread.h (pthread_key::set): Inline. - (pthread_key::get): Ditto. - * thread.cc (pthread::set): Delete. - (pthread::get): Ditto. - -2005-05-28 Christopher Faylor - - * cygwin.din: Remove signal front end from pthread_[gs]etspecific. - -2005-05-28 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_slave:tcflush): Use signed comparison. - -2005-05-28 Christopher Faylor - - * times.cc (time_ms::usecs): Coerce comparison to signed or whole test - is a no-op. - -2005-05-27 Christopher Faylor - - * cygheap.h: Reference _cygheap_start via .cygheap section. - - * environ.cc: Fix force_into_environment typo throughout. - (spenvs): Export CYGWIN_DEBUG if DEBUGGING. - -2005-05-26 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number to 18. - -2005-05-25 Pierre Humblet - - * fhandler.h (fhandler_base::mkdir): New virtual method. - (fhandler_base::rmdir): Ditto. - (fhandler_disk_file:mkdir): New method. - (fhandler_disk_file:rmdir): Ditto. - * dir.cc (mkdir): Implement with fhandlers. - (rmdir): Ditto. - * fhandler.cc (fhandler_base::mkdir): New virtual method. - (fhandler_base::rmdir): Ditto. - (fhandler_disk_file::mkdir): New method. - (fhandler_disk_file::rmdir): Ditto. - -2005-05-24 Christopher Faylor - - * include/cygwin/version.h: Bump API minor number to 129. - -2005-05-24 Christopher Faylor - - * cygwin.din: Export mkdtemp. - * mktemp.cc: New file. - * Makefile.in (DLL_OFILES): Add mktemp.o - -2005-05-23 Eric Blake - - * include/stdint.h (INTMAX_C, UINTMAX_C): Fix definition. - -2005-05-21 Christopher Faylor - - * spawn.cc (find_exec): Accept a PATH-like string in place of an - environment variable. - * dlfcn.cc (get_full_path_of_dll): Search /usr/bin (for windows - compatibility) and /usr/lib (for UNIX compatibility) when looking for - shared libraries. - * environ.cc (conv_envvars): Put back LD_LIBRARY_PATH since it is used - by get_full_path_of_dll(). - * errno.cc (errmap): Map MOD_NOT_FOUND to ENOENT. - - * cygmagic: Remove debugging cruft. - -2005-05-19 Corinna Vinschen - - * include/cygwin/in.h: Add comment. - -2005-05-19 Corinna Vinschen - - * include/cygwin/in.h: Define IPPROTO_xxx values as macros to - accommodate SUSv3. - -2005-05-19 Christopher Faylor - - * include/limits.h: Include features.h, as on linux. - -2005-05-19 Christopher Faylor - - * include/endian.h: New file. - -2005-05-19 Corinna Vinschen - - * cygwin.sc: Add Dwarf-2 debug sections. - -2005-05-19 Corinna Vinschen - - * mmap.cc (mmap64): Make granularity an automatic variable. - -2005-05-19 Christopher Faylor - - * fhandler.h (fhandler_cygdrive::seekdir): Delete declaration. - (fhandler_cygdrive::seekdir): Delete. - -2005-05-19 Pierre Humblet - - * fhandler.h (fhandler_cygdrive::iscygdrive_root): Delete method. - (fhandler_cygdrive::telldir): Delete declaration. - * fhandler_disk_file.cc: Remove all uses of - fhandler_cygdrive::iscygdrive_root. - (fhandler_disk_file::mkdir): New method. - (fhandler_disk_file::rmdir): Ditto. - (fhandler_cygdrive::telldir): Delete. - -2005-05-18 Christopher Faylor - - * external.cc: Move pids declaration to file scope and use less - enthusiastic constructor. - * pinfo.h (winpids::winpids): Remove default setting. - * fhandler_fifo.cc (fhandler_fifo::open_not_mine): Accommodate removal - of default setting. - * fhandler_proc.cc (fhandler_proc::readdir): Ditto. - -2005-05-18 Christopher Faylor - - * cygtls.h (_local_storage::unknown_thread_name): New buffer. - * tlsoffsets.h: Regenerate. - * cygthread.cc (cygthread::name): Use new thread-local buffer. - * exceptions.cc (handle_exceptions): Avoid unnecessary initialization - of static variables to zero. - * fork.cc (slow_pid_reuse) Ditto. - -2005-05-18 Corinna Vinschen - - * mmap.cc (mmap64): Avoid compiler warning. - * ntea.cc (NTReadEA): Ditto. - * hires.h (hires_base): Remove useless usecs function. - -2005-05-18 Corinna Vinschen - - * fhandler_netdrive.cc (fhandler_netdrive::telldir): Remove since it's - equivalent to fhandler_virtual::telldir now anyway. - * fhandler.h (class fhandler_netdrive): Remove telldir. - -2005-05-18 Corinna Vinschen - - * fhandler_netdrive.cc (fhandler_netdrive::telldir): Implement. - (fhandler_netdrive::seekdir): Implement. - (fhandler_netdrive::closedir): Call rewinddir to have only one point - of calling WNetCloseEnum. - -2005-05-17 Corinna Vinschen - - * fhandler.h (class fhandler_netdrive): Add method rewinddir. - * fhandler_netdrive.cc (struct netdriveinf): New structure to - store thread arguments. - (thread_netdrive): Thread handling all potentially blocking - WNet... calls. - (create_thread_and_wait): Start and wait for above thread. - (fhandler_netdrive::exists): Change to call create_thread_and_wait - instead of calling WNet... function. - (fhandler_netdrive::readdir): Ditto. Fix error handling. - (fhandler_netdrive::rewinddir): New method. - -2005-05-17 Corinna Vinschen - - * external.cc (cygwin_internal): Avoid compiler warning. - -2005-05-16 Christopher Faylor - - * dcrt0.cc (dll_crt0_0): Don't do fixup_after_exec if dynamically - loaded since the state of fds is unknown at this point. - -2005-05-16 Christopher Faylor - - * include/sys/cygwin.h (enum cygwin_getinfo_types): Add CW_DEBUG_SELF. - * external.cc (cygwin_internal): Implement CW_DEBUG_SELF. - - * init.cc (dll_entry): Minor rearrangement of code. - -2005-05-16 Christopher Faylor - - * path.cc (path_conv::check): Remove embedded dots before slashes. - -2005-05-16 Corinna Vinschen - - * environ.cc (conv_envvars): Remove LD_LIBRARY_PATH entirely. - It doesn't belong here. - -2005-05-15 Corinna Vinschen - - * environ.cc (conv_envvars): Treat LD_LIBRARY_PATH as path list. - -2005-05-14 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Check - return code from GetFileSize and set file size to 0 if necessary. - * fhandler_netdrive.cc (fhandler_netdrive::fstat): Set permissions - to read/execute for all. - -2005-05-13 Christopher Faylor - - * path.cc (normalize_posix_path): Do normalization on . and .. after - a '//'. - -2005-05-13 Corinna Vinschen - - * fhandler.h (fhandler_netdrive::readdir): Remove useless comment. - -2005-05-13 Corinna Vinschen - - * autoload.cc (WNetGetResourceParentA): Import. - (WNetOpenEnumA): Import. - (WNetEnumResourceA): Import. - (WNetCloseEnum): Import. - * fhandler.h (fhandler_netdrive::telldir): Add declaration. - (fhandler_netdrive::seekdir): Ditto. - (fhandler_netdrive::closedir): Ditto. - * fhandler_netdrive.cc: Drop explicit including windows.h. Include - winnetwk.h instead of shlwapi.h. Include dirent.h. - (fhandler_netdrive::readdir): Implement. - (fhandler_netdrive::telldir): New method. - (fhandler_netdrive::seekdir): New method. - (fhandler_netdrive::closedir): Ditto. - -2005-05-13 Christopher Faylor - - Remove PC_FULL from path_conv usage throughout. - * path.h (enum pathconv_arg): Change PC_FULL to PC_NOFULL. - * path.cc (path_conv::check): Test for PC_NOFULL rather than !PC_FULL. - (cygwin_conv_to_win32_path): Use PC_NOFULL to force non-absolute path. - -2005-05-13 Christopher Faylor - - * fhandler_netdrive.cc (fhandler_netdrive::exists): Assert that "//" - exists. - -2005-05-12 Christopher Faylor - - * cygtls.cc (_cygtls::remove): Eliminate compiler warning. - - * dir.cc (mkdir): Check path for writability. - (rmdir): Ditto. Remove check for special directories. - * path.cc (path_conv::check): Set PATH_RO for virtual devices. Set - error if read-only and asked for writability. - * path.h (pathconv_arg): Add PC_WRITABLE. - (path_types): Add PATH_RO. - (path_conv::isro): Add (currently unused) check for read-only - filesystem. Return "ENOSHARE" when we know a share doesn't exist. - * include/sys/mount.h: Add MOUNT_RO flag. - * autoload.cc (WNetGetResourceInformationA): Import. - * fhandler_netdrive.cc (fhandler_netdrive::exists): Detect actual - existence of remote system rather than always assuming that it exists. - -2005-05-11 Christopher Faylor - - * dcrt0.cc (do_global_dtors): Don't call dll_global_dtors here. - (__main): Reinstate atexit of do_global_dtors. - (cygwin_exit): Call dll_global_dtors here. - (do_exit): And here. - - -2005-05-10 Christopher Faylor - - * cygtls.cc (_cygtls::remove): Clear exitsock after close. - * fhandler_console.cc (fhandler_console::write_normal): Store character - in a local variable for potential future inspection. - -2005-05-10 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Add fhandler_mailslot.o. - * devices.h (FH_KMSG): Define new device. - * devices.in: Add "/dev/kmsg" entry. - * devices.cc: Regenerate. - * dtable.cc (build_fh_pc): Handle case FH_KMSG. - * fhandler.h (class fhandler_mailslot): New class. - (class select_stuff): Add device_specific_mailslot pointer. - * fhandler_mailslot.cc: New file. - * select.cc (peek_mailslot): New function. - (verify_mailslot): Ditto. - (struct mailslotinf): New stuct to handle select on mailslots. - (thread_mailslot): New function. - (start_thread_mailslot): Ditto. - (mailslot_cleanup): Ditto. - (fhandler_mailslot::select_read): New method. - * syslog.cc (klog_guard): New muto. - (dev_kmsg): Local mailslot for kernel message device. - (vklog): New function. - (klog): Ditto. - * winsup.h (vklog): Declare. - (klog): Ditto. - * include/sys/syslog.h: Define _PATH_KLOG. - -2005-05-10 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Call cygwin_exit to ensure that destructors - are handled correctly. - -2005-05-10 Corinna Vinschen - - * path.cc (path_conv::check): Set correct file attributes for socket - files. - -2005-05-09 Pierre Humblet - - * fhandler.h (class fhandler_netdrive): New class. - * fhandler_netdrive.cc (fhandler_netdrive::fhandler_netdrive): New constructor. - (fhandler_netdrive::exists): New method. - (fhandler_netdrive::fstat): Ditto. - (fhandler_netdrive::readdir): Ditto. - (fhandler_netdrive::open): Ditto. - * dtable.cc (build_fh_pc): Handle case FH_NETDRIVE. - * path.cc (isvirtual_dev): Add FH_NETDRIVE. - (mount_info::conv_to_win32_path): Detect netdrive device and bypass mount - search for network paths. - -2005-05-08 Christopher Faylor - - * dcrt0.cc (get_cygwin_startup_info): New function pulled from - dll_crt0_0. - (dll_crt0_0): Use get_cygwin_startup_info to retrieve cygwin-specific - startup pointer. - * external.cc (cygwin_internal): Implement CW_ARGV and CW_ENVP. - * include/sys/cygwin.h: Implement CW_ARGV and CW_ENVP. - -2005-05-07 Christopher Faylor - - * path.cc (normalize_posix_path): Don't treat '//' specially since - newer versions of bash now get this right. - -2005-05-07 Christopher Faylor - - * devices.cc: Regenerate with correct name for dev_netdrive_storage. - -2005-05-06 Christopher Faylor - - * Makefile.in (DLL_O_FILES): Add fhandler_netdrive.o. - * fhandler_netdrive.cc: Placeholder file for future development. - * devices.h (FH_NETDRIVE): Define new virtual device type. - (netdrive_dev): Define. - * devices.in (dev_netdrive_storage): Define. - * devices.cc: Regenerate. - -2005-05-04 Corinna Vinschen - - * cygerrno.h (__set_errno): Remove useless parentheses. - -2005-05-04 Corinna Vinschen - - * cygerrno.h (__set_errno): Define as inline function here. - (set_errno): Always define as call to __set_errno. - * debug.cc (__set_errno): Move to cygerrno.h. - -2005-05-03 Christopher Faylor - - * shared.cc (user_shared_initialize): Rework locking so that nothing is - checked until cb is non-zero. - -2005-05-03 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Don't treat - inability to open file as failure if only SetFileAttributes is - going to be called. Only call set_file_attribute if really necessary. - -2005-05-03 Corinna Vinschen - - * fhandler_socket.cc (get_inet_addr): Add missing __seterrno call. - -2005-05-01 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_slave::read): Actually read input when - vmin == vtime == 0. - -2005-04-30 Christopher Faylor - - * environ.cc (spenv::force_into_environment): Rename from add_always. - (spenv::add_if_exists): Rename from force. - (build_env): Accommodate name changes. Make sure that stuff that is - always supposed to be in the environment is actually added to the - environment. - - * shared.cc (open_shared): Restore VirtualFree eliminated by 2005-04-28 - change. - -2005-04-30 Christopher Faylor - - * errno.cc (errmap): Sort table. - -2005-04-29 Christopher Faylor - - * errno.cc (errmap): Map ERROR_NETNAME_DELETED to ENOSHARE. - -2005-04-28 Corinna Vinschen - - * shared_info.h (cygwin_shared_address): Bump to a higher value to avoid - collision with large data areas. - -2005-04-28 Christopher Faylor - - * fhandler_console.cc (fhandler_console::get_tty_stuff): Accommodate - changes to open_shared arguments. - * fhandler_tape.cc (mtinfo_init): Ditto. - * pinfo.cc (pinfo::init): Use open_shared rather than win32 mmap calls. - * shared.cc (user_shared_initialize): Ditto. - (memory_init): Ditto. - (open_shared): Change to allow use a smore general mmap handler. - * shared_info.h (shared_locations): Add SH_JUSTCREATE, SH_JUSTOPEN. - (open_shared): Change declaration to match new usage. - - * autoload.cc (LoadDLLfuncEx2): Define in terms of LoadDLLfuncEx3. - (LoadDLLfuncEx3): New macro. - -2005-04-27 Christopher Faylor - - * fhandler.cc (fhandler_base::open_9x): Remove (broken) check for - O_CREAT|O_EXCL. - * syscalls.cc (open): Do O_CREAT|O_EXCL check here first. - -2005-04-26 Christopher Faylor - - * environ.cc (build_env): Ensure that win32 array is properly filled in - when a missing value has to be generated. - -2005-04-26 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number to 17. - -2005-04-24 Pavel Tsekov - - * how-to-debug-cygwin.txt: Fix typo. - -2005-04-22 Christopher Faylor - - * shared.cc (user_shared_initialize): Implement locking similar to - shared_info when initializing shared region. - -2005-04-22 Christopher Faylor - - * fhandler.h (dev_console::set_color): Define new function. - (dev_console::set_default_attr): Ditto, moved from fhandler_console. - (dev_console::fillin_info): Ditto. Accommodate this change throughout - this file. - (fhandler_console::get_win32_attr): Eliminate. - * fhandler_console.cc (fhandler_console::get_tty_stuff): Properly set - default attributes on initialization. - (fhandler_console::open): Set current attributes rather than default - color on open. - (fhandler_console::get_win32_attr): Eliminate. - (dev_console::set_color): New function. Move get_win32_attr stuff - here. - (dev_console::set_default_attr): New function, moved from - fhandler_console. - (dev_console::fillin_info): Ditto. - (fhandler_console::char_command): Call set_color to set screen - characteristics. - -2005-04-22 Christopher Faylor - - * fhandler.cc (fhandler_base::read): Remove unused signal state tweaks. - * fhandler.h (fhandler_pipe::create_selectable): Declare. - (fhandler_fifo::close_one_end): Declare. - * fhandler_fifo.cc (fhandler_fifo::close_one_end): Define. - (fhandler_fifo::open_not_mine): Use close_one_end to close appropriate - end of pipe. - * pinfo.cc (_pinfo::commune_recv): Ditto. - * pipe.cc (fhandler_pipe::create_selectable): Rename from - create_selectable_pipe. Reorganize. - (fhandler_pipe::create): Use create_selectable. - -2005-04-21 Christopher Faylor - - * shared.cc (shared_info::initialize): Test previous version of shared - memory magic rather than current version when determining if there has - been a shared memory mismatch. - -2005-04-20 Christopher Faylor - - * sigproc.cc (proc_subproc): Fix handling of waiting for pids with zero - value. - - * strace.cc (strace::hello): Report parent pid of executing process. - -2005-04-20 Christopher Faylor - - * path.cc (path_conv::check): Fix problem reading symlinks introduced - in below change by reverting the change and adding an additional test - for nonexistent files in /proc. - -2005-04-20 Christopher Faylor - - * path.cc (path_conv::check): Punt when attempting to access a - nonexistent directory or file in /proc. - -2005-04-19 Corinna Vinschen - - * security.cc (alloc_sd): Remove DELETE bit from user's ACE if - allow_traverse is set. - -2005-04-19 Corinna Vinschen - - * cygwin.din (pselect): Export. - * select.cc (pselect): New function. - * include/cygwin/version.h: Bump API minor number. - * include/sys/select.h: Include signal.h. Declare pselect. - -2005-04-18 Corinna Vinschen - - * fhandler.h (enum conn_state): Add connect_failed state. - * fhandler_socket.cc (fhandler_socket::connect): Set connect_state to - connect_failed when connect failed. - * poll.cc (poll): Change errno to EINVAL if allocating memory fails, - according to SUSv3. Add socket descriptors always to except_fds. Test - for failed connect and set revents flags appropriately. - * select.cc (set_bits): Set connect_state to connect_failed when - select indicates failed nonblocking connect. - (fhandler_dev_null::select_except): Set except_ready to false so that - /dev/null is not always in except state. - (peek_socket): Fix bogus conditional. - (fhandler_socket::select_write): Treat all connect_states except - unconnected equivalent to return consistent results. - (fhandler_windows::select_except): Set except_ready to false so that - /dev/windows is not always in except state. - -2005-04-18 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number to 16. - -2005-04-18 Pierre Humblet - - * grp.cc (initgroups32): Return the correct value. - -2005-04-16 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::utimes_fs): Ignore - ERROR_NOT_SUPPORTED to workaround Win9x weirdness. - * path.cc (symlink_info::check): Remap ERROR_INVALID_FUNTION to - ERROR_FILE_NOT_FOUND for the same reason. - -2005-04-16 Corinna Vinschen - Pierre Humblet - - * security.h (cygsidlist::addfromgr): Allow duplicate entries. - (get_server_groups): Declare new function. - * security.cc (is_group_member): Simplify. - (get_server_groups): New function. - (get_initgroups_sidlist): Call get_server_groups. - (verify_token): Allow token when supplementary sids are not in - /etc/group but are in the token. - Streamline the code. - * grp.cc (initgroups32): New implementation. - (getgroups32): Handle case where the supplementary groups are set. - -2005-04-16 Corinna Vinschen - - * environ.cc (environ_init): Don't set traverse checking as default. - -2005-04-16 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::utimes_fs): Drop touching - ChangeTime. - -2005-04-16 Christopher Faylor - - * fhandler.cc (fhandler::dup): Duplicate flags, too. - * fhandler.h (fhandler_fifo::owner): Eliminate. - * fhandler_disk_file.cc (fhandler_base::fstat_fs): Handle on-disk - devices better. - (fhandler_base::fstat_helper): Ditto. - * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Don't initialize - obsolete "owner". - (fhandler_fifo::open_not_mine): Add some debugging. Duplicate correct - handle when we own it. - (fhandler_fifo::open): Set flags from input, not from first pipe. Flag - that fork fixup is needed. - (fhandler_fifo::dup): Set errno correctly when DuplicateHandle fails. - * pinfo.cc (commune_send): Add debugging for fifo. - - * cygwin/version.h: Bump API minor version to 127 to reflect exporting - of sigrelese. - -2005-04-14 Kazuhiro Fujieda - - * syscalls.cc (setuid32): Correct debugging output. - -2005-04-14 Christopher Faylor - - * dcrt0.cc (do_global_dtors): Run DLL dtors. - (__main): Don't rely on atexit to run dtors. - (do_exit): Specifically call do_global_dtors here. - (cygwin_exit): Ditto. - * dll_init.cc (dll_global_dtors): Make global. Only run dtors once. - (dll_list::init): Just set flag that dtors should be run. Don't rely on atexit. - * dll_init.h (dll_global_dtors): Declare. - - * exceptions.cc (sigrelse): Define. - - * path.h (is_fs_device): New method. - (is_lnk_special): Ditto. - * fhandler_disk_file.cc (fhandler_disk_file::link): Use - "is_lnk_special" rather than "is_lnk_symlink". - * syscalls.cc (rename): Ditto. - - * hookapi.cc (ld_preload): Use colon as a separator rather than space. - -2005-04-13 Corinna Vinschen - - * fhandler.h (class fhandler_socket): Remove utimes. - * fhandler_socket.cc (fhandler_socket::utimes): Remove. - -2005-04-13 Corinna Vinschen - - * cygerrno.h (__seterrno_from_nt_status): Define. Always set Win32 - error code as well as errno. Use throughout where errno is set from - NT status. - (set_errno): Evaluate val only once. - * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Fix typo in - debug output. - * fhandler_mem.cc (fhandler_dev_mem::open): Rely on - __seterrno_from_nt_status setting Win32 error code in debug output. - * fhandler_proc.cc (format_proc_uptime): Ditto. - (format_proc_stat): Ditto. - * fhandler_process.cc (format_process_stat): Ditto. - * sysconf.cc (sysconf): Ditto. - -2005-04-13 Christopher Faylor - - * fhandler.h (fhandler_base::utimes_fs): New method. - * fhandler.cc (fhandler_base::utimes): Call utimes_fs if on-disk - special file. - * fhandler_disk_file.cc (fhandler_disk_file::utimes): Use utimes_fs. - (fhandler_base::utimes_fs): Handle on-disk device files. - -2005-04-13 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::utimes): Don't set errno - if open fails, it has already been set by open. - -2005-04-12 Corinna Vinschen - - * autoload.cc (NtQueryVolumeInformationFile): Add. - * fhandler.cc (fhandler_base::raw_write): Don't touch has_changed flag. - * fhandler.h (enum change_state): Remove. - (fhandler_base::status): Revert has_changed to a simple bit. - (fhandler_base::fstat_helper): Add nAllocSize parameter. Rename - ftCreationTime to ftChangeTime. - * fhandler_disk_file.cc: Call fstat_helper with additional - allocation size throughout. - (fhandler_base::fstat_by_handle): Use NT native functions to get - full file information on NT. Call fstat_helper with LastWriteTime - as ctime, if ChangeTime is not available. - (fhandler_base::fstat_by_name): Call fstat_helper with LastWriteTime - as ctime. - (fhandler_base::fstat_helper): Add comment. Drop special FAT - handling since it's useless. Use nAllocSize for st_blocks if available. - (fhandler_disk_file::touch_ctime): Only touch LastWriteTime. - (fhandler_disk_file::fchmod): Set has_changed on 9x only. - (fhandler_disk_file::fchown): Don't set has_changed. - (fhandler_disk_file::facl): Ditto. - (fhandler_disk_file::ftruncate): Ditto. - (fhandler_disk_file::link): Set has_changed on 9x only and on original - file only. - (fhandler_base::open_fs): Don't set has_changed in O_TRUNC case. - * ntdll.h (FILE_BASIC_INFORMATION): Define. - (FILE_STANDARD_INFORMATION): Define. - (FILE_INTERNAL_INFORMATION): Define. - (FILE_EA_INFORMATION): Define. - (FILE_ACCESS_INFORMATION): Define. - (FILE_POSITION_INFORMATION): Define. - (FILE_MODE_INFORMATION): Define. - (FILE_ALIGNMENT_INFORMATION): Define. - (FILE_NAME_INFORMATION): Don't define with arbitrary FileName size. - (FILE_ALL_INFORMATION): Define. - (FILE_INFORMATION_CLASS): Add FileAllInformation. - (FILE_FS_VOLUME_INFORMATION): Define. - (FS_INFORMATION_CLASS): Define. - (NtQueryVolumeInformationFile): Define. - -2005-04-11 Corinna Vinschen - - Revert previous patch. - * autoload.cc (GetVolumePathNamesForVolumeNameA): Remove. - (GetVolumeNameForVolumeMountPointA): Add. - * syscalls.cc (sync): Rewrite guid case to skip floppies also on - Windows 2000. - -2005-04-11 Corinna Vinschen - - * syscalls.cc (sync): Use renamed has_get_volume_pathnames wincap. - * wincap.h (wincaps::has_get_volume_pathnames): Rename from - has_guid_volumes - * wincap.cc: Accommodate above rename throughout. Set to false on - Windows 2000. - -2005-04-08 Christopher Faylor - - * pipe.cc (fhandler_pipe::open): Remove O_CREAT limitation. - -2005-04-07 Corinna Vinschen - - * syslog.cc (try_connect_guard): Remove useless conditionalized code. - -2005-04-07 Corinna Vinschen - - * syslog.cc: Include sys/socket.h. - (try_connect_guard): New static variable. - (syslogd_inited): Ditto. - (syslogd_sock): Ditto. - (try_connect_syslogd): New function to connect and write syslog to - local syslogd. - (vsyslog): Log to stderr if LOG_PERROR flag has been given to openlog. - Try logging to syslogd. Use Event Log resp. log file as fallback. - (closelog): Close socket to syslogd. - * include/sys/syslog.h (_PATH_LOG): Define. - (INTERNAL_NOPRI): Define if SYSLOG_NAMES is defined. - (INTERNAL_MARK): Ditto. - (struct _code): Ditto. - (prioritynames): Ditto. - (facilitynames): Ditto. - -2005-04-06 Corinna Vinschen - - * fhandler_socket.cc (get_inet_addr): Add type parameter to return - unix socket type. Read socket type from unix socket file. - (fhandler_socket::bind): Write socket type to unix socket file. - (fhandler_socket::connect): Return with errno EPROTOTYPE if - socket type of socket doesn't match socket type of unix socket - trying to connect to. - -2005-04-06 Pierre Humblet - - * security.h (cygsidlist::addfromgr): Avoid duplicate entries. - * grp.cc (initgrousp): Add syscall_printf. - (setgroups): Add syscall_printf and make sure sids are added only once. - -2005-04-06 Christopher Faylor - - * net.cc (cygwin_getservbyname): Return (possibly NULL) return value of - dup_ent rather than assuming that tls buffer is valid. - (cygwin_getservbyport): Ditto. - (cygwin_gethostbyname): Ditto. - (cygwin_gethostbyaddr): Ditto. - -2005-04-05 Christopher Faylor - - * cygtls.cc (_cygtls::remove): Don't free or close stuff if we're being - called in a "non-standard" way. - -2005-04-05 Christopher Faylor - - * sync.h (muto::initforce): Delete flawed implementation. - * pwdgrp.h (pwdgrp::pglock): Make static. - * grp.cc (pwdgrp::pwdgrp): Eliminate use of initforce. - -2005-04-05 Christopher Faylor - - * sync.h (muto::initforce): Force initialization even when name != - NULL. - * grp.cc (pwdgrp::pwdgrp): Use initforce since the enclosing structure - is !NO_COPY. - -2005-04-05 Christopher Faylor - - * sync.h (muto::operator int): New operator. - (locker): Remove unused class. - (new_muto): Delete. - (new_muto1): Ditto. - (new_muto_name): Ditto. - * cygheap.cc (cygheap_setup_for_child): Reflect use of static storage - for muto rather than pointer. - (_csbrk): Ditto. - (_cmalloc): Ditto. - (_cmalloc): Ditto. - (_cfree): Ditto. - * cygheap.h (cwdstuff::cwd_lock): Ditto. - (cwdstuff::get_drive): Ditto. - * cygmalloc.h (__malloc_lock): Ditto. - (__malloc_unlock): Ditto. - * cygtls.cc (sentry::lock): Ditto. - (sentry::sentry): Ditto. - (~sentry): Ditto. - (_cygtls::init): Ditto. - * dcrt0.cc: Ditto. - (cygwin_atexit): Ditto. - (cygwin_exit): Ditto. - * debug.cc (lock_debug::locker): Ditto. - (lock_debug::lock_debug): Ditto. - (lock_debug::unlock): Ditto. - (debug_init): Ditto. - * dtable.cc (dtable::init_lock): Ditto. - * dtable.h (dtable::lock_cs): Ditto. - (dtable::lock): Ditto. - (dtable::unlock): Ditto. - * exceptions.cc (mask_sync): Ditto. - (sighold): Ditto. - (set_process_mask_delta): Ditto. - (set_signal_mask): Ditto. - (events_init): Ditto. - * grp.cc (pwdgrp::pwdgrp): Ditto. - * malloc_wrapper.cc (mallock): Ditto. - (malloc_init): Ditto. - * path.cc (cwdstuff::cwd_lock): Ditto. - (cwdstuff::get_hash): Ditto. - (cwdstuff::get_hash): Ditto. - (cwdstuff::init): Ditto. - (cwdstuff::set): Ditto. - (cwdstuff::get): Ditto. - * pwdgrp.h (pwdgrp::pglock): Ditto. - (pwdgrp::refresh): Ditto. - * sigproc.cc (sync_proc_subproc): Ditto. - (get_proc_lock): Ditto. - (proc_subproc): Ditto. - (_cygtls::remove_wq): Ditto. - (proc_terminate): Ditto. - (sigproc_init): Ditto. - * timer.cc (lock_timer_tracker::protect): Ditto. - (lock_timer_tracker::lock_timer_tracker): Ditto. - (lock_timer_tracker::~lock_timer_tracker): Ditto. - * wininfo.cc (wininfo::_lock;): Ditto. - (wininfo::winthread): Ditto. - (operator HWND): Ditto. - (wininfo::lock): Ditto. - (wininfo::release): Ditto. - * wininfo.h (wininfo::_lock;): Ditto. - -2005-04-04 Christopher Faylor - - * path.cc (path_conv::check): Only check for PC_NO_ACCESS_CHECK in end - component. - -2005-04-04 Corinna Vinschen - - * dcrt0.cc (dll_crt0_1): Don't call set_cygwin_privileges on 9x. - - * fhandler.h (enum change_state): Add. - (fhandler_base::status): Add a bit to has_changed flag. - (fhandler_base::has_changed): Implement with type change_state. - * fhandler.cc (fhandler_base::raw_write): Accommodate type change - of has_changed. - * fhandler_disk_file.cc (fhandler_disk_file::touch_ctime): Also - touch modification time if has_changed == data_changed. - (fhandler_disk_file::fchmod): Also open on 9x, otherwise we can't - touch ctime. Accommodate type change of has_changed. - (fhandler_disk_file::fchown): Accommodate type change of has_changed. - (fhandler_disk_file::facl): Ditto. - (fhandler_disk_file::ftruncate): Ditto. - (fhandler_disk_file::link): Ditto. - (fhandler_base::open_fs): Ditto. - -2005-04-03 Corinna Vinschen - - * cygheap.cc (cygheap_init): Accommodate set_process_privilege change. - * cygheap.h (cygheap_user::curr_primary_token): New member. - (cygheap_user::primary_token): New method. - (cygheap_user::deimpersonate): Always revert to processes' - impersonation token. - (cygheap_user::reimpersonate): Set processes' or setuid token as - necessary. - (cygheap_user::has_impersonation_tokens): Look for curr_primary_token - value. - (cygheap_user::close_impersonation_tokens): Close curr_primary_token - here if necessary. Don't reset token values to NO_IMPERSONATION since - that's done in uinfo_init anyway. - (init_cygheap::luid): New LUID array keeping privilege LUIDs. - * cygtls.cc (_cygtls::init_thread): Call cygheap->user.reimpersonate. - * dcrt0.cc (hProcToken): New global variable to keep process token. - (hProcImpToken): Ditto for process impersonation token. - (dll_crt0_0): Open process token here once. Duplicate to create - hProcImpToken. - (dll_crt0_1): Call set_cygwin_privileges. - * environ.cc (allow_ntea): Drop duplicate declaration. - (allow_smbntsec): Ditto. - (set_traverse): Only set allow_traverse here. - (environ_init): Ditto. - * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Drop call to - enable_restore_privilege. - (fhandler_disk_file::fchown): Ditto. - (fhandler_disk_file::facl): Ditto. - * fork.cc (fork_child): Move call to cygheap->user.reimpersonate after - syn with parent. Call set_cygwin_privileges. - * grp.cc (internal_getgroups): Use hProcImpToken instead of opening - process token. - * path.cc (fs_info::update): Bypass traverse checking when retrieving - volume information using push/pop_thread_privileges. - * registry.cc (load_registry_hive): Drop setting restore privilege - since it's already set if available. - * sec_helper.cc: Include cygtls.h. - (cygpriv): Privilege string array. - (privilege_luid): New function, evaluate LUID from cygpriv_idx. - (privilege_luid_by_name): New function, evaluate LUID from privilege - string. - (privilege_name): New function, evaluate privilege string from - cygpriv_idx. - (set_privilege): New static function called by set_process_privilege - and set_thread_privilege. Call privilege_luid to get privilege LUID. - Fix bug in return value evaluation. Improve debug output. - (set_cygwin_privileges): New function. - (set_process_privilege): Remove. - (enable_restore_privilege): Remove. - * security.cc (allow_traverse): New global variable. - (sys_privs): Change type to cygpriv_idx and store privilege indices - instead of strings. - (SYSTEM_PRIVILEGES_COUNT): Renamed from SYSTEM_PERMISSION_COUNT. - (get_system_priv_list): Don't use numerical constant in malloc call. - Use privilege_luid to get privilege LUIDs. - (get_priv_list): Call privilege_luid_by_name to get LUIDs. Improve - inner privilege LUID comparison loop. - (create_token): Enable create token privilege using - push/pop_self_privileges. Use hProcToken instead of opening process - token. Use default DACL when duplicating token. - (subauth): Enable tcb privilege using push/pop_self_privileges. - Use sec_none instead of homw made security attributes when duplicating - token. - (check_file_access): Don't duplicate access token, use active - impersonation token as is. - * security.h (enum cygpriv_idx): New enumeration type enumerating - possible privileges. - (privilege_luid): Declare new function. - (privilege_luid_by_name): Ditto. - (privilege_name): Ditto. - (allow_traverse): Declare. - (set_privilege): Declare function. - (set_process_privilege): Define as macro. - (enable_restore_privilege): Remove declaration. - (_push_thread_privilege): Define macro. - (push_thread_privilege): Ditto. - (pop_thread_privilege): Ditto. - (pop_self_privilege): Ditto. - * spawn.cc (spawn_guts): Use cygheap->user.primary_token instead of - cygheap->user.token. - * syscalls.cc (statvfs): Bypass traverse checking when retrieving - volume information using push/pop_thread_privileges. Rearrange code - to simplify push/pop bracketing. - (seteuid32): Use hProcToken instead of opening process token. Call - cygheap->user.deimpersonate instead of RevertToSelf. Create - impersonation token from primary internal or external token. Set - cygheap->user.curr_primary_token and cygheap->user.current_token - privileges once here. Drop "failed" and "failed_ptok" labels. - Drop setting DefaultDacl of process token. - (setegid32): Use hProcToken and hProcImpToken instead of opening - process token. Always reimpersonate afterwards. - * uinfo.cc (cygheap_user::init): Use hProcToken instead of opening - process token. - (internal_getlogin): Ditto. Set hProcImpToken, too. - (uinfo_init): Initialize cygheap->user.curr_primary_token. - * winsup.h (hProcToken): Declare. - (hProcImpToken): Declare. - -2005-04-03 Corinna Vinschen - - Unify usage of CYG_MAX_PATH throughout. Change buffers from - size CYG_MAX_PATH + 1 to CYG_MAX_PATH. Change length tests - accordingly. - -2005-04-02 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number to 15. - -2005-04-01 Corinna Vinschen - - * fork.cc (fork_child): Add missing __stdcall. - -2005-04-01 Christopher Faylor - - * sigproc.cc (create_signal_arrive): New (temporary?) function to - create signal_arrived event. - (sigproc_init): Use create_signal_arrived. - * fork.cc (fork_child): Create signal_arrived early. - -2005-04-01 Corinna Vinschen - - * fork.cc (fork_child): Fixup SYSV IPC shared memory before fixing - up fdtab. - -2005-03-31 Corinna Vinschen - - * gentls_offsets: Add '-m32' flag to native compiler call to satisfy - cross platform builds. - -2005-03-31 Corinna Vinschen - - * errno.cc (NO_SYSTEM_RESOURCES): Map to EAGAIN. - (NONPAGED_SYSTEM_RESOURCES): Ditto. - (PAGED_SYSTEM_RESOURCES): Ditto. - (WORKING_SET_QUOTA): Ditto. - (PAGEFILE_QUOTA): Ditto. - (COMMITMENT_LIMIT): Ditto. - -2005-03-30 Christopher Faylor - - * environ.cc (spenvs): Re-force SYSTEMROOT to always be included in - environment. - (build_env): Ditto. - -2005-03-30 Christopher Faylor - - * environ.cc (spenv::retrieve): Revert most of previous change. - (build_env): Ditto. Rework to track environment variables which need - to always be in the windows environment in a separate array. - -2005-03-30 Igor Pechtchanski - - * path.cc (symlink_info::case_check): Ignore trailing characters - in paths when comparing case. - -2005-03-30 Christopher Faylor - - * environ.h (win_env::immediate): Declare new field. - (win_env::operator = ): Declare new operator. - (win_env::reset): Declare new function. - (win_env::~win_env): Declare new destructor. - (getwinenv): Add optional third argument to declaration. - * environ.cc (conv_envvars): Accommodate immediate field. - (win_env::operator =): Define new operator. - (win_env::~win_env): Define new destructor. - (win_env::add_cache): Add value to environment immediately if - "immediate" is set. - (getwinenv): Accept optional third argument which will be used to store - "cached" values to avoid overwriting real cache. - (spenv::force): Declare new field. - (spenvs): Accommodate force field. Add "PATH=" with force set to true. - (spenv::retrieve): Avoid duping anything if we're not building an - envblock. - (build_env): Ditto. Use size of potentially constructed new - environment block to determine if we need to create an environment - block. Pass getwinenv temporary storage to avoid inappropriately - overwriting the environment cache. - -2005-03-29 Eric Blake - - * include/limits.h (NAME_MAX): New define. - (PATH_MAX): POSIX allows PATH_MAX to include trailing NUL. - -2005-03-29 Corinna Vinschen - - * path.cc (is_floppy): Make externally available. - * path.h (is_floppy): Declare. - * syscalls.cc (sync): Check for floppies on A: and B: in guid case. - Don't call setmntent in non-guid case but evaluate drive bit mask - locally. - -2005-03-29 Corinna Vinschen - - * fhandler_process.cc: Re-add exename. - -2005-03-28 Christopher Faylor - - * include/ctype.h: Accommodate building in newlib. - -2005-03-28 Christopher Faylor - - * timer.cc (getitimer): Check that ovalue is a valid pointer, not just - NULL. - -2005-03-28 Christopher Faylor - - * timer.cc (timer_tracker::settime): Set times to zero when just - cancelling a timer. - -2005-03-28 Christopher Faylor - - * cygthread.cc (cygthread::detach): Revert to just waiting for thread - event since waiting for anything else is racy. - * timer.cc (timer_tracker::hcancel): Rename from cancel. - (timer_tracker::cancel): New method. - (timer_tracker::th): Remove. - (timer_tracker::~timer_tracker): Call cancel method. - (timer_tracker::timer_tracker): Ditto. - (timer_tracker::timer_tracker): Always, clear cancel, even though it is - probably not strictly necessary for ttstart. - (timer_thread): Accommodate cancel -> hcancel rename. - (timer_tracker::settime): Ditto. - (timer_tracker::gettime): Ditto. - (timer_delete): Ditto. - - * cygwin.din: Export _ctype_. - * include/ctype.h: Mark that _ctype_ is imported. - -2005-03-28 Christopher Faylor - - * timer.cc (timer_tracker::timer_tracker): Eliminate simple - constructor. - (ttstart): Fully initialize. - - * errno.cc: Fix typo introduced in previous change. - -2005-03-28 Eric Blake - - * errno.cc (FILENAME_EXCED_RANGE): Map to ENAMETOOLONG. - -2005-03-27 Christopher Faylor - - * signal.cc (nanosleep): Revert tv_sec < 0 check as it is fixed - properly in the below change to hires.h. - -2005-03-27 Pierre Humblet - - * times.cc (hires_ms::usecs): Compare the difference. - * hires.h: Add parentheses to HIRES_DELAY_MAX. - -2005-03-26 Christopher Faylor - - * timer.cc (nanosleep): Treat tv_sec < 0 as invalid. - - * include/search.h: Make declarations consistent with newlib. - -2005-03-26 Pierre Humblet - Christopher Faylor - - * wininfo.h (wininfo::timer_active): Delete. - (wininfo::itv): Ditto. - (wininfo::start_time): Ditto. - (wininfo::window_started): Ditto. - (wininfo::getitimer): Ditto. - (wininfo::setitimer): Ditto. - (wininfo::wininfo): Ditto. - (wininfo::lock): New method. - (wininfo::release): Ditto. - * window.cc: Use new lock/acquire wininfo methods throughout. - (wininfo::wininfo): Delete - (wininfo::getitimer): Ditto. - (wininfo::setitimer): Ditto. - (getitimer): Ditto. - (setitimer): Ditto. - (ualarm): Ditto. - (alarm): Ditto. - (wininfo::lock): Define new function. - (wininfo::release): Ditto. - (wininfo::process): Delete WM_TIMER handling. - * timer.cc (struct timetracker): Delete it, flags. Add it_interval, - interval_us, sleepto_us, running, init_muto(), syncthread, and - gettime(). - (ttstart): Make NO_COPY. - (lock_timer_tracker): New class. - (timer_tracker::timer_tracker): Distinguish ttstart case. - (timer_tracker::~timer_tracker): New destructor. Clean out events, and - reset magic. - (timer_tracker::init_muto): New method. - (to_us): Round up as per POSIX. - (timer_thread): Reorganize to match timer_tracker::settime and - timer_tracker::gettime. Call sig_send without wait. Call - auto_release. - (timer_tracker::settime): Reorganize logic to avoid race. Call gettime - to recover old value. - (timer_tracker::gettime): New method. - (timer_create): Properly set errno on invalid timerid. Use new - lock_timer_tracker method. - (timer_delete): Ditto. Simplify code slightly. - (timer_gettime): New function. - (fixup_timers_after_fork): Reinit ttstart. - (getitimer): New implementation. - (setitimer): Ditto. - (ualarm): Ditto. - (alarm): Ditto. - * cygwin.din: Export timer_gettime. - * winsup.h: Remove has has_visible_window_station declaration. - -2005-03-26 Christopher Faylor - - * Makefile.in (DLL_OFILES): Add lsearch.o. - * cygthread.h (cygthread::notify_detached): New element. - (cygthread::cygthread): Take optional fourth argument signifying event - to signal on thread completion. - * cygthread.cc (cygthread::stub): Signal notify_detached event, if it - exists. - (cygthread::cygthread): Initialize notify_detached from fourth argument. - (cygthread::detach): Wait for notify_detached field is present. - - * lsearch.cc: New file. - * search.h: Ditto. - * include/cygwin/version.h: Bump API minor number to 126. - * cygwin.din: Export lsearch, lfind. - -2005-03-23 Corinna Vinschen - - * fhandler.h (fhandler_socket::secret_event): Remove. - (fhandler_socket::af_local_set_secret): New function combining former - set_connect_secret and get_connect_secret into one function. - (fhandler_socket::af_local_setblocking): Rename from eid_setblocking. - (fhandler_socket::af_local_unsetblocking): Rename from - eid_unsetblocking. - (fhandler_socket::af_local_set_cred): New method. - (fhandler_socket::af_local_copy): New method. - (fhandler_socket::af_local_recv_secret): New method. - (fhandler_socket::af_local_send_secret): New method. - (fhandler_socket::af_local_recv_cred): Rename from eid_recv. - (fhandler_socket::af_local_send_cred): Rename from eid_send. - (fhandler_socket::af_local_accept): New method. - (fhandler_socket::af_local_set_sockpair_cred): Rename from - set_socketpair_eids. - (fhandler_socket::eid_accept): Remove. - (fhandler_socket::eid_connect): Remove. - (fhandler_socket::set_connect_secret): Remove. - (fhandler_socket::get_connect_secret): Remove. - (fhandler_socket::create_secret_event): Remove. - (fhandler_socket::check_peer_secret_event): Remove. - (fhandler_socket::signal_secret_event): Remove. - (fhandler_socket::close_secret_event): Remove. - (fhandler_socket::sec_event_accept): Remove. - (fhandler_socket::sec_event_connect): Remove. - * fhandler_socket.cc (secret_event_name): Remove. - (fhandler_socket::af_local_set_sockpair_cred): Rename from - set_socketpair_eids. - (fhandler_socket::af_local_setblocking): Rename from eid_setblocking. - (fhandler_socket::af_local_unsetblocking): Rename from - eid_unsetblocking. - (fhandler_socket::af_local_recv_secret): New function to receive - AF_LOCAL connect secret over socket itself. - (fhandler_socket::af_local_send_secret): New function to send AF_LOCAL - connect secret over socket itself. - (fhandler_socket::af_local_recv_cred): Rename from eid_recv. - (fhandler_socket::af_local_send_cred): Rename from eid_send. - (fhandler_socket::eid_connect): Remove. - (fhandler_socket::af_local_connect): Take over connect side handling - of AF_LOCAL secret and credential handshake. - (fhandler_socket::eid_accept): Remove. - (fhandler_socket::af_local_accept): New method, take over accept side - handling of AF_LOCAL secret and credential handshake. - (fhandler_socket::af_local_set_cred): New method, set eid credentials - to start values. - (fhandler_socket::af_local_copy): New method, copy secret and - credentials to another socket. - (fhandler_socket::af_local_set_secret): New function combining former - set_connect_secret and get_connect_secret into one function. - (fhandler_socket::create_secret_event): Remove. - (fhandler_socket::signal_secret_event): Remove. - (fhandler_socket::close_secret_event): Remove. - (fhandler_socket::check_peer_secret_event): Remove. - (fhandler_socket::sec_event_connect): Remove. - (fhandler_socket::sec_event_accept): Remove. - (fhandler_socket::fixup_after_fork): Drop secret_event handling. - (fhandler_socket::bind): Call af_local_set_secret. - (fhandler_socket::connect): Call af_local_set_cred and af_local_connect. - (fhandler_socket::listen): Call af_local_set_cred. - (fhandler_socket::accept): Call af_local_copy and af_local_accept on - accepted socket. - (fhandler_socket::close): Don't call close_secret_event. - (fhandler_socket::set_close_on_exec): Don't set secret_event - inheritance. - * net.cc (cygwin_getsockopt): Add debug output. - (socketpair): Call af_local_set_sockpair_cred instead of - set_socketpair_eids. - * select.cc (set_bits): Drop AF_LOCAL special handling in case - of except bit set. - -2005-03-23 Christopher Faylor - - * include/ctype.h: Always define macros when inside cygwin. - (isblank): New macro. - -2005-03-23 Corinna Vinschen - - * fhandler.h (fhandler_socket::eid_connect): Make private. - (fhandler_socket::set_connect_secret): Ditto. - (fhandler_socket::get_connect_secret): Ditto. - (fhandler_socket::create_secret_event): Ditto. Remove secret argument. - (fhandler_socket::check_peer_secret_event): Ditto. - (fhandler_socket::signal_secret_event): Make private. - (fhandler_socket::close_secret_event): Ditto. - (fhandler_socket::sec_event_accept): New private method. - (fhandler_socket::sec_event_connect): Ditto. - (fhandler_socket::af_local_connect): New public method. - * fhandler_socket.cc: Use 'struct sockaddr' and 'struct sockaddr_in' - rather than just 'sockaddr' and 'sockaddr_in' throughout. - (fhandler_socket::eid_connect): Drop AF_LOCAL/SOCK_STREAM test. - (fhandler_socket::create_secret_event): Remove secret argument. - Always use connect_secret instead. - (fhandler_socket::check_peer_secret_event): Ditto. - (fhandler_socket::sec_event_connect): New method, combining entire - secret event handshake on connect side. - (fhandler_socket::af_local_connect): New method, combining secret - event handshake and eid credential transaction on connect side, to - be called from select. - (fhandler_socket::sec_event_accept): New method, combining entire - secret event handshake on accept side. - (fhandler_socket::connect): Drop secret, use connect_secret instead. - Move entire secret event handshake to sec_event_connect. - (fhandler_socket::accept): Move entire secret event handshake to - sec_event_accept. - * select.cc (set_bits): Just call af_local_connect here. - -2005-03-23 Christopher Faylor - - * include/cygwin/version.h: Change comment for most recent API version - bump to reflect new additions to the DLL and to remove change obsoleted - by the previous checkin. - -2005-03-23 Christopher Faylor - - * include/ctype.h: New file. - * ctype.cc: Ditto. - * Makefile.in: Add ctype.o to DLL_OFILES. - * cygwin.din: Remove _ctype_ptr (for now?). - -2005-03-22 Christopher Faylor - - * Makefile.in (DLL_OFILES): Add hookapi.o. Eliminate some cruft. - * cygheap.h (cygheap_types): Add new enum: HEAP_1_HOOK. - (hook_chain): New struct. - (init_cygheap::hooks): Define new element. - * cygheap.cc (cygheap_fixup_in_child): Zero hook chain on exec. - * dcrt0.cc (dll_crt0_1): Call ld_preload just before calling main function. - * external.cc (cygwin_internal): Implement CW_HOOK. - * fork.cc (fork_child): Call fixup_hooks_after_fork. - * init.cc (cygwin_hmodule): Reinstate after a long absence. - * include/sys/cygwin.h: Define CW_HOOK. - * hookapi.cc: New file. - - * select.cc (start_thread_socket): Add debugging output. - - * fhandler_disk_file.cc (fhandler_disk_file::fchmod): gcc 4.x - accommodation. - - * fhandler_socket.cc (fhandler_socket::connect): Make sure that err is - initialized. - -2005-03-22 Corinna Vinschen - - * cygwin.din (__ctype_ptr): Export. - * include/cygwin/version.h: Bump API minor version. - -2005-03-21 Corinna Vinschen - - * fhandler.h (class cygthread): Remove forward declaration. - -2005-03-21 Corinna Vinschen - - * fhandler.h (class cygthread): Forward declare. - (fhandler_socket::sec_pipe): Remove. - (fhandler_socket::eid_pipe_name): Remove. - (fhandler_socket::eid_setblocking): New private method. - (fhandler_socket::eid_unsetblocking): Ditto - (fhandler_socket::eid_recv): Ditto - (fhandler_socket::eid_send): Ditto - (fhandler_socket::eid_accept): Ditto - (fhandler_socket::eid_connect): New public method. - * fhandler_socket.cc (ASYNC_MASK): Move to beginning of file. - (fhandler_socket::eid_pipe_name): Remove. - (fhandler_socket::set_socketpair_eids): Move down to fhandler_socket - methods. - (fhandler_socket::fhandler_socket): Drop initializing sec_pipe. - (fhandler_socket::~fhandler_socket): Drop closing sec_pipe. - (fhandler_socket::eid_setblocking): New method. - (fhandler_socket::eid_unsetblocking): New method. - (fhandler_socket::eid_recv): New method. - (fhandler_socket::eid_send): New method. - (fhandler_socket::eid_connect): New method. - (fhandler_socket::eid_accept): New method. - (fhandler_socket::dup): Drop sec_pipe handling. - (fhandler_socket::connect): Fix WinSock error handling. Prepare - eid credential transaction. Call eid_connect on successful connect. - (fhandler_socket::listen): Drop creating sec_pipe. - (fhandler_socket::accept): Slightly simplify code. Call eid_accept - on accepted socket. - (fhandler_socket::getpeereid): Reshuffle code for readability. Fix - test for invalid pid. - * select.cc (set_bits): Call eid_connect on successfully connected - socket. - -2005-03-19 Christopher Faylor - - * child_info.h (fork_info): Use different method to alias variable. - (spawn_info): Ditto. - * cxx.cc (__cxa_guard_acquire): New function (needed for gcc 4.x). - (__cxa_guard_release): Ditto. - * devices.in: Make sure stuff is correctly bracketed (for gcc 4.x). - * devices.cc: Regenerate. - * fhandler.h (fhandler_disk_file::fchmod): Avoid left coercion (for gcc - 4.x). - * smallprint.c (__rn): Declare as __fastcall since gcc 4.x complains - about use of regparm, for some reason. - * sync.h (sync::init_lock): Remove. - * sync.cc (sync::init_lock): Ditto. - -2005-03-18 Christopher Faylor - - * net.cc (cygwin_getprotobyname): Don't try to be fancy with return - values. - (cygwin_getprotobynumber): Ditto. - -2005-03-17 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::utimes): Handle opening - directories under 9x gracefully. - -2005-03-17 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::connect): Always set sun_path - in case of a successful or pending connect. - (fhandler_socket::accept): Don't run secret event and eid credential - transactions if OS accept returned WSAEWOULDBLOCK. - -2005-03-16 Christopher Faylor - - * fhandler_tape.cc (get_ll): This is a generally useful function so - move it - * winsup.h (get_ll): to here. - * security.cc (get_token_group_sidlist): Use get_ll to figure out the - long long version of the luid since QuadPart is not part of the - standard Windows API. - -2005-03-16 Christopher Faylor - - * dir.cc: Rename opendir_* to dirent_* throughout. - (opendir_states): Move and rename. - * fhandler.h (dirent_states): to here. - * fhandler_disk_file.cc (fhandler_disk_file::readdir): Use raw readdir - when skipping through entries since it is keeping track of "." and - "..". - (fhandler_cygdrive::seekdir): Use fhandler_disk_file::readdir to do - everything. - * fhandler_virtual.cc (fhandler_virtual::opendir): Set flag indicating - that we provide . and .. - (fhandler_virtual::seekdir): Ditto. - (fhandler_virtual::rewinddir): Ditto. - * fhandler_registry.cc (fhandler_registry::rewinddir): Ditto. - -2005-03-16 Christopher Faylor - - * cygtls.cc (free_local): New macro. - (_cygtls::remove): Use free_local to free known-malloced local - variables. - * cygtls.h: Mark some variables as "malloced". - * net.cc (enum struct_type): Rename from is_* to t_* for clarity. - (dump_protoent): Delete. - (dup_ent): New macro. - (__dup_ent): Renamed from dup_ent. Change arguments for convenience. - Replace first argument with newly alloced value. Allocate a rounded - number of bytes in an attempt to try to reuse space. Subsume - "dump_protent". - (cygwin_getprotobyname): Simplify using new dup_ent functionality. - (cygwin_getprotobynumber): Ditto. - (cygwin_getservbyname): Ditto. - (cygwin_getservbyport): Ditto. - (cygwin_gethostname): Ditto. - (cygwin_gethostbyname): Ditto. - * tlsoffsets.h: Regenerate. - - * syslog.cc (openlog): Use NULL rather than 0, for consistency with the - rest of cygwin. - (pass_handler::initialize): Use unbuffered I/O in pass one. - -2005-03-15 Christopher Faylor - - * errno.cc (errmap): Correct typo in previous change. - -2005-03-15 Christopher Faylor - - * cygtls.cc (_cygtls::remove): Free process_ident, if it exists. - - * errno.cc (errmap): ERROR_DISK_CORRUPT -> EIO. - -2005-03-11 Christopher Faylor - - * path.h (pathconv_arg): Define PC_NO_ACCESS_CHECK. - (path_types): Define PATH_NO_ACCESS_CHECK == PC_NO_ACCESS_CHECK. - * path.cc (symlink_info::check_sysfile): Move to symlink_info class and - eliminate arguments that are part of class. Use set_error. - (symlink_info::check_shortcut): Ditto. - (symlink_info::set_error): New function. - (path_conv::check): Pass PC_NO_ACCESS_CHECK to symlink_info::check. - (symlink_info::check): Preserve PC_NO_ACCESS_CHECK in pflags. Use - set_error. - -2005-03-10 Corinna Vinschen - - * path.cc (is_floppy): New function. - (setmntent): Drop floppy drives on A: and B: from logical drive DWORD. - * syscalls.cc (sync): Don't sync floppies on A: and B:. - -2005-03-10 Christopher Faylor - - * autoload.cc (LoadDLLprime): Use nocopy segment or forked processes - will not initialize properly. - -2005-03-10 Christopher Faylor - - * autoload.cc (LoadDLLprime): Scrap use of .linkonce and just use an - ifdef guard to load .foo_init into data segment. - - * dcrt0.cc (initial_env): Allow colon or space as CYGWIN_DEBUG - separator for consistency. - -2005-03-09 Christopher Faylor - - * pinfo.h (pinfo::pinfo): Clear more elements in the constructor. - -2005-03-09 Christopher Faylor - - * net.cc (dup_ent): Revert older stupid test for null. Don't copy name - if it is NULL. - -2005-03-09 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::eid_pipe_name): Fix format - string. - (fhandler_socket::connect): Set sun_path before running eid credential - transaction. Run transaction only if OS connect was successful. - (fhandler_socket::accept): Run transaction only if OS accept was - successful. - -2005-03-09 Corinna Vinschen - - * signal.cc (sigprocmask): Rename first parameter to "how". - (handle_sigprocmask): Ditto. Check "how" for being a valid "how" value. - Fix call order in case of wrong "how" value. - -2005-03-09 Christopher Faylor - - * net.cc (dup_ent): Revert previous stupid change. - -2005-03-09 Christopher Faylor - - * net.cc (dup_ent): Avoid dereferencing a null pointer in a debug_printf. - -2005-03-09 Christopher Faylor - - * path.cc (path_conv::check): Treat ENOSHARE similarly to ENOENT when - determining if there was a problem with a symlink. - -2005-03-08 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::listen): Don't limit the number - of pipe instances. - -2005-03-08 Christopher Faylor - - * pinfo.cc (pinfo::exit): Right shift exit value by eight when not - started in a cygwin environment. - -2005-03-07 Corinna Vinschen - - * mmap.cc (mmap64): Handle MAP_AUTOGROW flag. - (fhandler_disk_file::mmap): Ditto. Clean conditional for readability. - * include/sys/mman.h: Add MAP_AUTOGROW flag. - * include/cygwin/version.h: Bump API minor version. - -2005-03-08 Christopher Faylor - - * dcrt0.cc (dll_crt0_0): Eliminate muto::init call. - * sync.h (locker): New, currently unused class. - (muto::init): Eliminate. - * sync.cc (muto::init): Ditto. - (muto::init): Eliminate critical section lock and instead use name as a - guard to prevent against multiple attempts to initialize the same muto. - - * pinfo.cc (pinfo::init): Set myself procinfo when not execing and pid - matches windows pid or cygwin pid. - -2005-03-06 Pavel Tsekov - - * path.cc (mount_info::read_cygdrive_info_from_registry): Use the user - prefix if it exists. - -2005-03-06 Christopher Faylor - - * sync.h (sync::init_lock): Declare new static member. - (sync::init()): Declare new static function. - * sync.cc (sync::init): Define. - (sync::init): Lock attempt to initialize a muto to stop multiple - threads from colliding. - * dcrt0.cc (dll_crt0_0): Initialize muto environment. - -2005-03-06 Christopher Faylor - - * path.cc (special_name): Reorganize to always detect the use of - special names first, before detecting special characters. - -2005-03-04 Christopher Faylor - - * fhandler_clipboard.cc: Use int for cygnativeformat rather than UINT - as that is what is returned by GetPriorityClipboardFormat. - (fhandler_dev_clipboard::read): Ditto for the format variable. - -2005-03-04 Corinna Vinschen - - * fhandler.cc (fhandler_base::open_9x): Satisfy query_open values. - -2005-03-04 Pierre Humblet - - * fhandler_socket.cc (fhandler_socket::ioctl): Only cancel - WSAAsyncSelect when async mode is on. - -2005-03-03 Corinna Vinschen - - * cygwin.din (utmpxname): Export. - * syscalls.cc (utmpxname): Create export alias to utmpname. - * include/utmpx.h: Define ut_name and ut_xtime if not already defined. - (utmpxname): Add prototype. - * include/sys/utmp.h: Only define ut_name if not already defined. - * include/cygwin/version.h: Bump API minor version. - -2005-03-03 Christopher Faylor - - * cygthread.cc (cygthread::detach): Use a slightly higher priority when - waiting for thread signalling. - -2005-03-02 Christopher Faylor - - * autoload.cc (std_dll_init): Save and restore fpu control register - around LoadAddress to prevent loaded dlls (like msvcrt.dll) from - setting unwanted stuff. - -2005-03-02 Christopher Faylor - - * cygtls.cc (_cygtls::remove): Don't attempt any removal activities if - exitsock is zero. - -2005-03-02 Christopher Faylor - - * cygtls.cc (_cygtls::init_thread): Move exitsock setting later. It - should always be set. - (_cygtls::remove): Detect zero exitsock. Not quite sure why this is needed. - -2005-03-02 Christopher Faylor - - * autoload.cc (LoadDLLprime): Mask error code to low-order 16 bits. - (noload): Preserve sign when returning error code. - -2005-03-02 Christopher Faylor - - * spawn.cc (do_cleanup): Properly restore SIGINT/SIGQUIT even if they - had previously been SIG_DFL. - -2005-03-01 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::touch_ctime): Replace - GetSystemTime/SystemTimeToFileTime with GetSystemTimeAsFileTime. - * times.cc (time_as_timestruc_t): Ditto. - (time): Ditto. - -2005-03-01 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor number to 14. - -2005-03-01 Corinna Vinschen - - * fhandler_clipboard.cc (fhandler_dev_clipboard::write): Never set - errno to 0. - (fhandler_dev_clipboard::read): Ditto. - * fhandler_windows.cc (fhandler_windows::read): Ditto. - * scandir.cc (scandir): Ditto. - * syscalls.cc (_fstat64_r): Ditto. - (_fstat_r): Ditto. - (_stat64_r): Ditto. - (_stat_r): Ditto. - - * mmap.cc (mmap64): Fix /dev/zero mapping. - -2005-02-28 Corinna Vinschen - - * fhandler.h (class fhandler_socket): Declare new method - set_socketpair_eids. - * fhandler_socket.cc (fhandler_socket::set_socketpair_eids): New method. - (fhandler_socket::dup): Duplicate sec_pipe if necessary. - (fhandler_socket::listen): Only create sec_pipe if named pipes are - available. Initialized sec_peer_pid to 0 as on Linux. - (fhandler_socket::connect): Only run eid credential transaction if - named pipes are available. Fake otherwise. Initialized sec_peer_pid - to 0 as on Linux. - (fhandler_socket::accept): Ditto. - (fhandler_socket::close): Move closing sec_pipe handle from here... - (fhandler_socket::~fhandler_socket): ... to here. - * net.cc (socketpair): Set eid credentials by calling - fhandler_socket::set_socketpair_eids() on both socket ends. - * wincap.h (wincaps::has_named_pipes): New element. - * wincap.cc: Implement above element throughout. - -2005-02-26 Christopher Faylor - - * sigproc.cc (_pinfo::set_ctty): Move function - * pinfo.cc (_pinfo::set_ctty): to here. - - * fhandler_mem.cc (fhandler_dev_mem::fstat): Don't fill out structure - if this is an on-disk device rather than an "auto" device. - * fhandler_raw.cc (fhandler_dev_raw::fstat): Ditto. - - * path.cc (normalize_posix_path): Don't treat a standalone '//' as - introducing a UNC path. - (normalize_win32_path): Ditto. - -2005-02-26 Christopher Faylor - - * debug.cc (delete_handle): Report on handle value in debugging output. - - * pinfo.h (_pinfo::exists): Declare "new" function. - (_pinfo::kill): Ditto. - * fhandler_termios.cc (tty_min::kill_pgrp): Use _pinfo::exists rather - than proc_exists. - * pinfo.cc (pinfo::init): Ditto. Don't do a low_priority_sleep(0) when - looping to find exec'ed procinfo. - (pinfo::release): Be more careful about unmapping and closing. - * signal.cc (_pinfo::kill): Rename from kill_worker. Accommodate entry - into _pinfo class. - (kill0): Use _pinfo::kill rather than kill_worker. - (kill_pgrp): Ditto. Use _pinfo::exists rather than proc_exists. - * sigproc.cc (_pinfo::exists): Rename from proc_exists. - (pid_exists): Use _pinfo::exists rather than proc_exists. - (remove_proc): Ditto. - * sigproc.h (proc_exists): Delete declaration. - -2005-02-25 Corinna Vinschen - - * fhandler.h (class fhandler_base): Declare fixup_mmap_after_fork - with additional flags parameter. Change offset parameter to _off64_t. - (class fhandler_disk_file): Ditto. - (class fhandler_dev_mem): Ditto. - * fhandler_mem.cc (fhandler_dev_mem::fixup_mmap_after_fork): - Accommodate new parameters. - * mmap.cc: Include ntdll.h. - (class mmap_record): Add flags member. - (mmap_record::mmap_record): Add flags parameter. - (mmap_record::get_flags): New method. - (class map): Add next_anon_addr member to store next anonymous mapping - address suggestion. - (map::get_next_anon_addr): New method. - (map::set_next_anon_addr): New method. - (mmap64): Don't align offset and length to granularity in case of - MAP_ANONYMOUS on NT. Check for already existing mapping only on 9x. - Call mmap_record::mmap_record with additional flags argument. - (fhandler_base::fixup_mmap_after_fork): Accommodate new parameters. - (fhandler_disk_file::mmap): Use NtMapViewOfSection with - AT_ROUND_TO_PAGE flag for anonymous mappings on NT. If addr is NULL, - try to map adjacent to previous mapping. - (fhandler_disk_file::fixup_mmap_after_fork): Add flags argument. - Change offset parameter to _off64_t. Use NtMapViewOfSection to - re-create anonymous mappings on NT. - (fixup_mmaps_after_fork): Accommodate new parameters when calling - fhandler's fixup_mmaps_after_fork function. - * ntdll.h (AT_ROUND_TO_PAGE): New define. - -2005-02-25 Corinna Vinschen - - * mmap.cc (mmap64): Handle anonymous MAP_FIXED request on - non-granulation boundary. - -2005-02-25 Corinna Vinschen - - * mmap.cc (class mmap_record): Declare new map_pages method with - address parameter. - (mmap_record::map_pages): New method with address parameter. - (mmap64): Evaluate access mode before checking if already existing - mapping can be used. - Only use existing mapping if requested access mode matches the one - in the existing mapping. - Add check for existing mapping for anonymous MAP_FIXED case. - -2005-02-23 Corinna Vinschen - - * localtime.cc: Implement setting __tzrule's offset member using - newlib's __gettzinfo () interface. - (__tzrule): Remove. - (timezone): Define as long according to POSIX. - -2005-02-23 Eric Blake - - * devices.in (parsedisk): Fix typo. - * devices.cc: Regenerate. - -2005-02-23 Corinna Vinschen - - * cygwin.din (getpeereid): Export. - * fhandler.h (class fhandler_socket): Add pipe and id members to - exchange eid credentials for AF_LOCAL sockets. - (eid_pipe_name): Declare new method. - (getpeereid): Ditto. - * fhandler_socket.cc (fhandler_socket::eid_pipe_name): New method. - (fhandler_socket::fhandler_socket): Initialize sec_pipe. - (fhandler_socket::connect): Exchange eid credentials with accepting - socket process. - (fhandler_socket::listen): Prepare eid credential transaction. - (fhandler_socket::accept): Exchange eid credentials with connecting - socket process. - (fhandler_socket::close): Close eid credentials pipe if open. - (fhandler_socket::getpeereid): New method. - * net.cc (cygwin_getsockopt): Add SO_PEERCRED handling. - (getpeereid): New function. - * include/asm/socket.h (SO_PEERCRED): Define. - * include/cygwin/socket.h (struct ucred): Define new type. - * include/cygwin/version.h: Bump API minor version. - -2005-02-23 Corinna Vinschen - - * include/sys/statvfs.h (ST_RDONLY): Define. - (ST_NOSUID): Define. - -2005-02-23 Corinna Vinschen - - * cygwin.din (fstatvfs): Export. - (statvfs): Export. - * syscalls.cc: Include sys/statvfs.h. - (statvfs): New function. Move statfs functionality here. - (fstatvfs): New function. - (statfs): Just call statvfs and copy structure. Check validity of - incoming struct statfs pointer. - * include/cygwin/types.h (fsblkcnt_t): Define. - (fsfilcnt_t): Define. - * include/cygwin/version.h: Bump API minor version. - * include/sys/statvfs.h: New file. - -2005-02-23 Corinna Vinschen - - * devices.h: Switch FH_ZERO and FH_PORT as on Linux. Add FH_FULL. - * devices.in: Add /dev/full. - * devices.cc: Regenerate. - * dtable.cc (build_fh_pc): Add FH_FULL. - * fhandler.cc (fhandler_base::fstat): Set FH_FULL permission bits - correctly. - * fhandler_zero.cc (fhandler_dev_zero::write): Set errno to ENOSPC - and return -1 if device is FH_FULL. - -2005-02-22 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_cygdrive::closedir): Return 0 when - closing cygdrive_root. - -2005-02-22 Corinna Vinschen - - * cygwin.din (basename): Export. - (dirname): Export. - * path.cc (basename): New function. - (dirname): New function. - * include/libgen.h: New file. - * include/cygwin/version.h: Bump API minor version. - -2005-02-22 Corinna Vinschen - - * select.cc (peek_pipe): Disable new pipe code until there's - a working substitute. - -2005-02-22 Corinna Vinschen - - * cygwin.din (fdatasync): Export. - * fhandler.cc (fhandler_base::fsync): Return with EINVAL if no - handle is available. - * syscalls.cc (fdatasync): Create export alias to fsync. - * include/cygwin/version.h: Bump API minor version. - -2005-02-20 Corinna Vinschen - - * fhandler.h (fhandler_base::fstat_helper): Declare with additional - dwVolumeSerialNumber argument. Drop default values for last three - arguments. - * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Pass - dwVolumeSerialNumber from GetFileInformationByHandle to fstat_helper. - (fhandler_base::fstat_by_name): Pass pc.volser () to fstat_helper. - Accommodate dropping default values for last three arguments of - fstat_helper. - (fhandler_base::fstat_helper): Add dwVolumeSerialNumber argument. - Use for st_dev member unless 0 in which case pc.volser () is used. - -2005-02-20 Corinna Vinschen - - * autoload.cc (FindFirstVolumeA): Add. - (FindNextVolumeA): Add. - (FindVolumeClose): Add. - (GetVolumePathNamesForVolumeNameA): Add. - * fhandler.h (class fhandler_base): Declare new method fsync. - * fhandler.cc (fhandler_base::fsync): New method. - * syscalls.cc (fsync): Move functionality into fhandler method fsync. - Just call this method from here. - (sync_worker): New static function. - (sync): Fill with life for NT systems. - * wincap.h (wincaps::has_guid_volumes): New element. - * wincap.cc: Implement above element throughout. - -2005-02-20 Corinna Vinschen - - * fhandler.h (enum query_state): Add query_write_attributes state. - (fhandler_base::status.query_open): Add a bit to make room for more - states. - (class fhandler_base): Declare new method utimes. - (class fhandler_socket): Ditto. - (class fhandler_disk_file): Ditto. - (fhandler_disk_file::fhandler_disk_file): Add constructor with - path_conv parameter. - * fhandler.cc (fhandler_base::open): Add query_write_attributes - handling. - (fhandler_base::utimes): New method. - * fhandler_disk_file.cc (fhandler_disk_file::link): Simplify. - Open file with query_write_attributes instead of query_write_control. - (fhandler_disk_file::utimes): New method. - (fhandler_disk_file::fhandler_disk_file): Add constructor with - path_conv parameter setting pc member immediately. - * fhandler_socket.cc (fhandler_socket::fchmod): Use new - fhandler_disk_file constructor. - (fhandler_socket::fchown): Ditto. - (fhandler_socket::facl): Ditto. - (fhandler_socket::link): Ditto. - (fhandler_socket::utimes): New method. - * times.cc: Include dtable.h. - (timeval_to_filetime): Make non-static. - (utimes): Move functionality into fhandler method utimes. Just call - this method from here. - * winsup.h: Simplify declarations of time helper functions. - (timeval_to_filetime): Add extern declaration. - -2005-02-19 Corinna Vinschen - - * fhandler.h (class fhandler_base): Declare new method link. - (class fhandler_socket): Ditto. - (class fhandler_disk_file): Ditto. - * fhandler.cc (fhandler_base::open): Add FILE_WRITE_ATTRIBUTES - to query_write_control access flags. - (fhandler_base::link): New method. - * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Don't try to - open with O_WRONLY since query_write_control includes - FILE_WRITE_ATTRIBUTES. - (fhandler_disk_file::fchown): Ditto. - (fhandler_disk_file::facl): Ditto. - (fhandler_disk_file::link): New method. Touch st_ctime on successful - link. - * fhandler_socket.cc (fhandler_socket::link): New method. - * syscalls.cc (link): Move functionality into fhandler method link. - Just call this method from here. - -2005-02-19 Corinna Vinschen - - * fhandler.h (class fhandler_socket): Declare new methods fchown, - fchmod and facl. - * fhandler_socket.cc (fhandler_socket::fstat): Handle AF_LOCAL - sockets. - (fhandler_socket::fchmod): New method. - (fhandler_socket::fchown): New method. - (fhandler_socket::facl): New method. - -2005-02-19 Corinna Vinschen - - * localtime.cc: Temporary implementation of setting __tzrule's offset - member to be used by strftime. - (__tzrule): New global variable. - (tzparse): Set __tzrule's offset member appropriately. - -2005-02-17 Christopher Faylor - - * path.cc (path_conv::check): Set fs flag when a unix-domain socket - is detected. - -2005-02-17 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::fstat): Set st_ctime if - has_changed flag is set. - (fhandler_disk_file::touch_ctime): Reset has_changed flag on success. - -2005-02-17 Corinna Vinschen - - * times.cc (utimes): Open files with FILE_WRITE_ATTRIBUTES first, - if that fails, try opeing with GENERIC_WRITE. Fix comments. - -2005-02-15 Christopher Faylor - - * path.h (path_conv::issocket): Return true if device == FH_UNIX rather - than expecting path_conv to set a flag. - -2005-02-11 Corinna Vinschen - - * fhandler.cc (fhandler_base::raw_write): Mark as changed on - successful write. - * fhandler.h (fhandler_base::status_flags): Add 'has_changed' flag. - * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Call - fhandler_disk_file's own open and close instead of open_fs and - close_fs. Mark as changed on success. - (fhandler_disk_file::fchown): Ditto. - (fhandler_disk_file::facl): Ditto. - (fhandler_disk_file::ftruncate): Ditto. - (fhandler_base::open_fs): Mark as changed when O_TRUNC flag on existing - file is set. - (fhandler_disk_file::close): Set st_ctime if has_changed flag is set. - -2005-02-11 Christopher Faylor - - * cygthread.cc (cygthread::release): Reset ev here if it exists. - (cygthread::terminate_thread): Eliminate racy code which reset ev and - thread_sync. Remove a few nonsensical inuse checks. Exit at the - bottom. - (cygthread::detach): Rewrite to again try to ensure that we don't say - we're signalled when we are not signalled. - * fhandler.cc (fhandler_base::raw_read): Revert to signalling read - success quickly. - * pipe.cc (fhandler_pipe::close): Use base method to close handle. - * sigproc.h (WAIT_SIG_PRIORITY): Just trundle along at normal priority - to allow the pipe thread to do its thing if possible. - - * pinfo.h (pinfo::zap_cwd): Declare new function. - (pinfo::zap_cwd): Move 'cd out of the way code' here. - (pinfo::exit): Use it here. - * spawn.cc (spawn_guts): And here. - -2005-02-11 Corinna Vinschen - - * times.cc (utimes): Open files with GENERIC_WRITE on file systems - not supporting ACLs. - -2005-02-09 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::ftruncate): Fix checking - lseek return code. - -2005-02-08 Corinna Vinschen - - * times.cc (timeval_to_filetime): Define first parameter const. - (utimes): Define second parameter to const according to SUSv3. - (utime): Ditto. - * include/sys/utime.h (utime) : Change declaration accordingly. - -2005-02-08 Corinna Vinschen - - * cygthread.cc (cygthread::detach): Just test thread handle after - signal arrived, don't wait infinitely for it. - -2005-02-08 Christopher Faylor - - * pipe.cc (fhandler_pipe::read): Remove hold over from old read_state - implementation. - -2005-02-06 Yitzchak Scott-Thoennes - - * net.cc (cygwin_gethostbyname): Be more picky about what's a numeric - address string, and use tls in that case too. - -2005-02-07 Christopher Faylor - - * exceptions.cc: Make windows_system_directory non-static. - * pinfo.cc (pinfo::exit): Change innocuous cd'ed location to one that - is more likely to exist. - -2005-02-06 Corinna Vinschen - - * path.cc (path_conv::check): Leave symlink expansion loop in case - a not-ENOENT error happens. - - * cygheap.h (cygheap_fdmanip::fhandler_pipe *): New cast operator. - * pinfo.cc (_pinfo::commune_recv): Add PICOM_PIPE_FHANDLER handling. - (_pinfo::commune_send): Ditto. - (_pinfo::pipe_fhandler): New method. - * pinfo.h (enum picom): Add PICOM_PIPE_FHANDLER. - (_pinfo::pipe_fhandler): Declare. - * pipe.cc (fhandler_pipe::open): Rewrite. Allow to open foreign - pipe handles. - -2005-02-03 Christopher Faylor - - * cygthread.h (cygthread::terminate_thread): Reflect return value. - * cygthread.cc (cygthread::detach): Be more careful about ensuring that - sigwait is properly waited for to avoid later missynchronization. - (cygthread::terminate_thread): Return true if thread was actually - terminated and all handles were closed. - * fhandler_base.cc (fhandler_base::raw_read): Use signal_read_state - rather than raw calls to win32 api. - (fhandler_base::read): Ditto. - * fhandler.h (fhandler_pipe::fixup_after_exec): Use method to create - read_state signalling. - (fhandler_pipe::create): Ditto. - - * Makefile.in: Make some more files -fomit-frame-pointer. - -2005-02-02 Corinna Vinschen - - * fhandler.h (fhandler_base::ftruncate): Define new virtual method. - (fhandler_disk_file::ftruncate): Ditto. - * fhandler.cc (fhandler_base::ftruncate): New method. - * fhandler_disk_file.cc (fhandler_disk_file::ftruncate): Ditto. - * syscalls.cc (ftruncate64): Move functionality into fhandlers. - Call fhandler method from here. - -2005-02-02 Corinna Vinschen - - * pipe.cc (fhandler_pipe::dup): Fix conditionals in case of error. - -2005-02-02 Corinna Vinschen - - * times.cc (utimes): Mark st_ctime for update according to SUSv3. - -2005-02-01 Christopher Faylor - - * fhandler_proc.cc (format_proc_partitions): Remove PartitionType check - since it could skip over partitions that are actually interesting. - -2005-02-01 Christopher Faylor - - * cygthread.cc (cygthread::terminate_thread): Wait briefly for - notification event in the event that the thread was actually in the - process of exiting. - - * pipe.cc (fhandler_pipe::dup): read_state is not supposed to be - inheritable. Fix that. - - * path.cc (path_conv::check): Set symlen = 0 to avoid a compiler - warning. - - * devices.h (devices::parsedisk): Declare new function. - * devices.in (devices::parsedisk): Define new function. - * dtable.cc (dtable::init_std_file_from_handle): Use device numbers - rather than name. - * fhandler_proc.cc (format_proc_partitions): Use parsedisk to generate - disk names from numeric codes. (This was broken on two of my - systems previously and is still broken now) - -2005-02-01 Corinna Vinschen - - * pipe.cc (fhandler_pipe::open): Allow re-opening of /proc//fd - pipes of the current process. - -2005-02-01 Corinna Vinschen - - * fhandler.cc (fhandler_base::get_proc_fd_name): Don't generate - "device:" entry. - * fhandler.h (fhandler_socket::open): New method. - (fhandler_pipe::open): New method. - * fhandler_proc.cc (fhandler_proc::exists): Return -2 in case of - /proc/self. - * fhandler_process.cc (fhandler_process::exists): Return -2 in - case of symlinks, -3 for pipes and -4 for sockets. - (fhandler_process::fstat): Handle pipes and sockets. - (fhandler_process::open): Handle opening /proc//fd. - (fhandler_process::fill_filebuf): Generate empty names for - non exisiting file descriptors. - * fhandler_socket.cc (fhandler_socket::get_proc_fd_name): Always - generate "socket:[number]" strings as on Linux. - (fhandler_socket::open): New method. - (fhandler_socket::fstat): Always return socket type. - * path.cc (symlink_info::set): Remove unused second parameter. - (path_conv::check): Handle pipes and sockets in /proc. - Set correct device type for AF_LOCAL sockets. - * pinfo.cc (_pinfo::commune_recv): Generate empty names for - non exisiting file descriptors. - (_pinfo::fd): Ditto. - * pipe.cc (fhandler_pipe::open): New method. - -2005-01-31 Christopher Faylor - - * path.h (path_conv::set_name): Declare new function. - * path.cc (path_conv::set_name): Define new function. - * fhandler.h (fhandler_dev_null::open): Declare new function. - * fhandler.cc (fhandler_dev_null::open): Define new function. - -2005-01-31 Christopher Faylor - - * smallprint.c (rnarg): Use long rather than unsigned long so that we - get proper sign extension. - -2005-01-31 Corinna Vinschen - - * environ.cc (set_traverse): New function. - (parse_thing): Add "traverse" option. Sort options alphabetically. - (environ_init): On NT, switch on traverse checking by default. - -2005-01-31 Christopher Faylor - - * smallprint.c (__rn): Regparmize. - -2005-01-31 Christopher Faylor - - * smallprint.c (rnarg): New macro. - (rnargLL): Ditto. - (__rn): Rename from 'rn', add a mask argument, and use the mask - argument to control how many significant digits to care about. - (__small_vsprintf): Use __rn, rnarg, rnargLL, as appropriate. - -2005-01-31 Christopher Faylor - - * pinfo.cc (pinfo::exit): Only return low-order 16 bits when exiting. - -2005-01-31 Corinna Vinschen - - * fhandler_process.cc (format_process_maps): Get destbuf argument by - reference. Allow resizing of destbuf as necessary. Fix string - handling. - -2005-01-31 Corinna Vinschen - - * cygheap.h (class cygheap_fdenum): New class to enumerate used - fhandlers. - * dtable.h (class dtable): Add cygheap_fdenum as friend class. - * fhandler.h (fhandler_base::get_proc_fd_name): New virtual method - to return a name for /proc//fd. - (fhandler_socket::get_proc_fd_name): Ditto. - (fhandler_pipe::get_proc_fd_name): Ditto. - (fhandler_virtual::opendir): Make virtual method. - (fhandler_process::opendir): New method. - * fhandler.cc (fhandler_base::get_proc_fd_name): New method. - * fhandler_process.cc: Include ctype.h. - (PROCESS_FD): Define. - (process_listing): Add "fd". - (fhandler_process::exists): Fix comment. Return 1 in case of "fd" - directory. Handle files below "fd". - (fhandler_process::fstat): Drop "self" handling. Set correct link - count for directories. - (fhandler_process::opendir): New method to handle "fd" directory. - (fhandler_process::readdir): Add "fd" handling. - (fhandler_process::open): Drop "self" handling. - (fhandler_process::fill_filebuf): Ditto. Add "fd" handling. Fix - "maps" output string. - * fhandler_registry.cc (fhandler_registry::fstat): Set correct link - count for directories. - * fhandler_socket.cc (fhandler_socket::get_proc_fd_name): New method. - * path.cc (symlink_info::set): Fix thinko. - * pinfo.cc (_pinfo::commune_recv): Rename pathbuf to path throughout. - Drop local path variable in PICOM_FIFO case. Fix debug output. - Close handles as early as possible. Add PICOM_FDS and PICOM_FD - handling. - (_pinfo::commune_send): Add PICOM_FDS and PICOM_FD handling. - (_pinfo::fd): New method. - (_pinfo::fds): New method. - * pinfo.h (enum picom): Add PICOM_FDS and PICOM_FD. - (_pinfo::fd): Declare. - (_pinfo::fds): Declare. - * pipe.cc (fhandler_pipe::get_proc_fd_name): New method. - -2005-01-29 Corinna Vinschen - - * smallprint.c (rn): Change uval to unsigned long long to fix 64 bit - handling. - * fhandler_process.cc (format_process_maps): Print major, minor and - inode numbers correctly. - -2005-01-29 Corinna Vinschen - - * autoload.cc (GetModuleFileNameExA): Add. - (GetModuleInformation): Add. - (QueryWorkingSet): Add. - * fhandler.h (fhandler_virtual::get_filebuf): New method. - * fhandler_proc.cc (PROC_SELF): Define. - (proc_fhandlers): Change type of self to FH_PROC. - (fhandler_proc::exists): Return -3 if self. - (fhandler_proc::fstat): Handle self as symlink. - (fhandler_proc::fill_filebuf): Handle self. - * fhandler_process.cc: Include psapi.h. - (PROCESS_EXENAME): Remove. - (PROCESS_MAPS): Define. - (PROCESS_ROOT): Define. - (PROCESS_EXE): Define. - (PROCESS_CWD): Define. - (process_listing): Remove "exename", add "maps, "root", "exe" and - "cwd" elements. - (fhandler_process::exists): Return -2 for symlinks. - (fhandler_process::fstat): Handle symlinks. - (fill_filebuf): Evaluate pid if pid is 0. Use exename handling for - exe. Handle maps, root and cwd. - (format_process_maps): New function evaluating "maps". - * path.cc (symlink_info::set): New method to fill symlink_info - with data matching virtual symlinks. - (path_conv::check): Handle virtual symlinks. - * pinfo.cc (_pinfo::commune_recv): Add PICOM_CWD and PICOM_ROOT - handling. - (_pinfo::commune_send): Ditto. - (_pinfo::root): New function. - (_pinfo::cwd): New function. - * pinfo.h (enum picom): Add PICOM_CWD and PICOM_ROOT. - (_pinfo::root): Declare. - (_pinfo::cwd): Declare. - -2005-01-29 Christopher Faylor - - * cygthread.cc (new): Add a little more debugging. - * thread.cc (pthread_null::exit): Add a _my_tls.remove() for safety. - -2005-01-28 Christopher Faylor - - * cygtls.cc (cygtls::call2): Move socket cleanup. - (cygtls::remove): Move socket cleanup here. Don't use _my_tls to - reference it. - -2005-01-26 Christopher Faylor - - * pinfo.cc (pinfo::init): Avoid a compiler warning. - -2005-01-25 Corinna Vinschen - - * syscalls.cc (setpriority): Implement PRIO_PGRP, PRIO_USER and - setting priority in other Cygwin processes. - (getpriority): Implement PRIO_PGRP, PRIO_USER and getting nice value - from other processes. - -2005-01-26 Pierre Humblet - - * path.cc (path_conv::check): Return ENOTDIR rather than ENOENT - when a component is not a directory. Remove unreachable code. - (digits): Delete. - -2005-01-25 Christopher Faylor - - * pinfo.h (pinfo::init): Make third parameter non-optional and - propagate change throughout. - * pinfo.cc (set_myself): Pass INVALID_HANDLE_POINTER if h is NULL. - (pinfo::init): Make third parameter non-optional. Eliminate use of - PID_EXECED as an argument. Put setting of handle back inside loop but - reorganize to try to open it only when necessary. - -2005-01-25 Corinna Vinschen - - * cygwin.din: Export getpriority and setpriority. - * fork.cc (fork_parent): Copy parent's nice value into child. - * spawn.cc (spawn_guts): Ditto. - * miscfuncs.cc (winprio_to_nice): New function. - (nice_to_winprio): Ditto. - * pinfo.cc (pinfo_init): If parent is not a Cygwin process, set - default nice value according to current Win32 priority class. - * pinfo.h (class _pinfo): Add nice member. - * syscalls.cc (setpriority): New function, only implementing - PRIO_PROCESS for now. - (getpriority): Ditto. - (nice): Just call setpriority. - * wincap.h (wincaps::has_extended_priority_class): New element. - * wincap.cc: Implement above element throughout. - * winsup.h: Add prototypes for winprio_to_nice and nice_to_winprio. - * include/limits.h (NZERO): New define. - * include/cygwin/types.h (id_t): New datatype. - * include/cygwin/version.h: Bump API minor version. - * include/sys/resource.h: Add PRIO_XXX defines and prototypes for - getpriority and setpriority. - -2005-01-25 Corinna Vinschen - - * path.cc (realpath): Allow to expand with .exe suffix. - -2005-01-22 Christopher Faylor - - * spawn.cc (spawn_guts): Perform same "cd" as in pinfo::exit below to - make sure that a stub process does not keep the current working - directory busy after the "execed" process has exited. - -2005-01-22 Christopher Faylor - - * pinfo.cc (pinfo::init): Move everything but the MapViewOfFileEx out - of the loop since trying multiple times to call CreateFileMapping - doesn't make much sense. Try to structure the loop a little better so - that exiting with a break does the right thing. - (pinfo::release): Release shared memory area if it exists and close - handle if it exists. - -2005-01-22 Christopher Faylor - - * pinfo.cc (pinfo::maybe_set_exit_code_from_windows): Make sure that - process has exited before getting an error code. - (pinfo::exit): "cd" to innocuous location before exiting to make sure - that process does not keep the current working directory busy while it - is in the process of really exiting. - -2005-01-18 Corinna Vinschen - - * autoload.cc (CoInitialize): Remove. - (CoUninitialize): Remove. - (CoCreateInstance): Remove. - (CoTaskMemFree): Add. - (SHGetDesktopFolder): Add. - * path.cc (shortcut_header): Remove. - (shortcut_initalized): Remove. - (GUID_shortcut): New static GUID. - (struct win_shortcut_hdr): New struct describing Windows shortcut - header structure. - (symlink_worker): Rewrite creating Windows shortcuts. Create - ITEMIDLIST if target exists. Only write once. - (cmp_shortcut_header): Use win_shortcut_hdr structure for comparison. - (check_shortcut): Rewrite to read only once from file. Allow skipping - an ITIMIDLIST in the file. - -2005-01-16 Christopher Faylor - - * pinfo.h (maybe_set_exit_code_from_windows): Renamed from - set_exit_state. - * pinfo.cc (pinfo::exit): Use renamed function. - (proc_waiter): Ditto. Make a copy of input argument to avoid problems - when procs array is shuffled. Flag when copy is made so that - remove_proc knows when it is safe to reshuffle. - * sigproc.cc (proc_terminate): Don't flag process_state as PID_EXITED. - (remove_proc): Wait for waiter to finish copying pinfo element before - moving it (an actual wait should be an extremely rare event). - -2005-01-15 Christopher Faylor - - * init.cc (dll_entry): Remove unused extern. - - * include/sys/cygwin.h: Remove PID_ZOMBIE. - * pinfo.h: Rename EXITCODE_* defines. - (pinfo::set_exit_state): Remove parameter. - * pinfo.cc (set_exit_state): Remove parameter. Reverse sense of test - so that exitcode is checked for having been set rather than not having - been set. Set flag when exitcode has been established. Don't set - PID_STATE here. - (pinfo::init): Remove exitcode initialization. - (pinfo::exit): Reflect change in EXITCODE_* naming. Set flag when - exitcode has been established. Reflect change in arguments to - set_process_state. - (proc_waiter): Reflect change in arguments to set_process_state. Set - process_state here and only here. - * fhandler_process.cc (fhandler_process::fill_filebuf): Reflect removal - of PID_ZOMBIE define. - (format_process_stat): Ditto. - (format_process_status): Ditto. - * sigproc.cc (pid_exists): Ditto. - (stopped_or_terminated): Ditto. Make sure that only low-order 16 bits of - exitcode are used. - * spawn.cc (spawn_guts): Reflect change in EXITCODE_* naming. - -2005-01-15 Christopher Faylor - - * sigproc.cc (sig_send): Don't complain if attempt to send signal to - myself fails after I've "execed". - -2005-01-14 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::facl): Pretend successful - SETACL if no acls are available. - * fhandler.cc (fhandler_base::facl): Implement to return sensible - values on GETACL and GETACLCNT. Pretend successful SETACL. - * fhandler_virtual.cc (fhandler_virtual::facl): Ditto. - -2005-01-13 Corinna Vinschen - - * fhandler.h (fhandler_disk_file::touch_ctime): Declare. - * fhandler_disk_file.cc (fhandler_disk_file::touch_ctime): New method - to set file's ctime. - (fhandler_disk_file::fchmod): Try opening file for writing first. - Set file's ctime on success. - (fhandler_disk_file::fchown): Ditto. - (fhandler_disk_file::facl): Ditto. - -2005-01-13 Corinna Vinschen - - * pinfo.cc (pinfo::exit): Don't access self after releasing it. - * path.h (path_conv::path_conv): Fill path with native device - name in case of device argument. - -2005-01-13 Corinna Vinschen - - * fhandler_serial.cc (fhandler_serial::dup): Call overlapped_setup - for child, not for parent. - -2005-01-13 Christopher Faylor - - * init.cc (dll_entry): Nuke attempt to set exit code since parent will - use windows exit code if needed. - * pinfo.cc (pinfo::exit): Move release() here to minimize pid creation - race (suggested by Pierre Humblet). - -2005-01-12 Christopher Faylor - - Reorganize header file inclusion throughout so that cygerrno.h comes - first. - * fhandler.h (select_record::thread_errno): Save any encountered errno - here. - (select_record::set_select_errno): New function. - (select_record::saw_error): New function. - (select_record::select_record): Initialize thread_errno to zero. - * select.cc (set_handle_or_return_if_not_open): Set thread_errno on - failure. - (select_stuff::wait): Record errno for later resurrection in calling - thread. - (peek_serial): Ditto. - -2005-01-12 Christopher Faylor - - * syscalls.cc (system): Use "/bin/sh" as per linux and (sorta) SUSv3. - -2005-01-12 Christopher Faylor - - * pinfo.cc (pinfo::exit): Don't assume that this == myself. - -2005-01-11 Christopher Faylor - - * pinfo.cc (pinfo::init): Don't close input handle on temporary (?) - failure. - -2005-01-11 Christopher Faylor - - * pinfo.h (_pinfo::set_exit_state): Declare new function. - (pinfo::exit): Move here from _pinfo::exit. - * sigproc.cc (child_info::sync): Use new function to set exitcode and - process_state. - * pinfo.cc (_pinfo::exit): Ditto. - (proc_waiter): Ditto. - (_pinfo::set_exit_state): Define new function. - (_pinfo::dup_proc_pipe): Close handle when there is no parent process - around to care about the exit value. - * dcrt0.cc (dll_crt0_0): Move subproc_ready synchronization later to - make sure that myself is still mapped in parent. - (do_exit): Reflect movement to pinfo::exit. - (__api_fatal): Ditto. - * exceptions.cc (signal_exit): Ditto. - * errno.cc (errmap): Map PROC_NOT_FOUND. - * init.cc (dll_entry): Release myself before exiting. - * sigproc.cc (proc_can_be_signalled): Set errno appropriately. - (sig_send): Ditto. Also remove ill-advised test for !myself->sendsig - since this is an indication of a process which is still initializating - -- it is not an error. - (child_info::sync): Don't set exitcode here. Assume that will happen - in proc_waiter, if necessary. - * spawn.cc (spawn_guts): Delay "wait_for_myself" logic until later. - Don't wait at all if the process has already exited. Reflect movement - to pinfo::exit. - -2005-01-11 Corinna Vinschen - - * environ.cc (build_env): Disallow empty strings and strings starting - with '=' in Win32 environment. - -2005-01-08 Pierre Humblet - - * syscalls.cc (seteuid32): Only change the default dacl when - seteuid succeeds. Do not close HKCU. - -2005-01-06 Corinna Vinschen - - * fhandler_process.cc: Use strcasematch instead of strcasecmp - throughout. - -2005-01-06 Corinna Vinschen - - * syscalls.cc (rename): Fix behaviour in case of renaming directories - according to SUSv3. - -2005-01-06 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::open_fs): Don't allow - opening directories for writing. - -2005-01-06 Christopher Faylor - - * timer.cc (timer_thread): Pass sigev pointer value as per SuSv3 rather - than pointer to sigev. - -2005-01-05 Christopher Faylor - - * dcrt0.cc (multiple_cygwin_problem): Reorganize error message to not - always talk about a "version" when it's not a version. - (dll_crt0_0): Change info passed to multiple_cygwin_problem to be a - little more precise. - * shared.cc (user_shared_initialize): Ditto. - (shared_info::initialize): Ditto. - -2005-01-03 Christopher Faylor - - * pinfo.cc (_pinfo::dup_proc_pipe): Can't close proc pipe when execing - or we will suffer an exit code race. - -2005-01-03 Corinna Vinschen - - * signal.cc (abort): Call _GLOBAL_REENT's __cleanup. - -2005-01-03 Corinna Vinschen - - * syscalls.cc (setmode): Call _fwalk with _GLOBAL_REENT. - -2005-01-01 Christopher Faylor - - * cygthread.cc (cygthread::stub): Set inuse to false when exiting. - (cygthread::cygthread): Actually pass name as argument to debugging - output to avoid SEGV when strace'ing. - (cygthread::release): Don't set stack_ptr to NULL, since it is only set - once on first entry to a stub not on each stub iteration. - (cygthead::exit_thread): Remove obsolete function. - * cygthread.h (cygthread::exit_thread): Ditto. - -2005-01-01 Christopher Faylor - - * shared.cc (open_shared): Don't attempt VirtualAlloc magic if first - attempt to map memory fails. diff --git a/winsup/cygwin/ChangeLog-2006 b/winsup/cygwin/ChangeLog-2006 deleted file mode 100644 index bab33364a..000000000 --- a/winsup/cygwin/ChangeLog-2006 +++ /dev/null @@ -1,3571 +0,0 @@ -2006-12-21 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::readdir): Improve debug - output. - -2006-12-20 Corinna Vinschen - - Partially revert change from 2006-10-22. GetSecurityInfo messes up - user information on NT4. - * sec_helper.cc (security_descriptor::malloc): Drop LocalAlloc - considerations. - (security_descriptor::realloc): Ditto. - (security_descriptor::free): Ditto. - * security.cc (get_reg_security): Reinstantiate. - (get_nt_object_security): Revert to using NtQuerySecurityObject. - * security.h (class security_descriptor): Drop type member. - Accommodate throughout. - (security_descriptor::size): Constify. - (security_descriptor::copy): Ditto. - -2006-12-18 Christopher Faylor - - * pinfo.cc (set_myself): Use a more foolproof method for determining if - the current process was started from another cygwin process. - -2006-12-15 Pierre A. Humblet - - * libc/minires-os-if.c (cygwin_query): Remove ERROR_PROC_NOT_FOUND case. - (get_dns_info): Verify DnsQuery exists. Use autoloaded GetNetworkParams. - -2006-12-13 Corinna Vinschen - - * winsup.h (clear_procimptoken): Close hProcImpToken in a safer way. - -2006-12-13 Corinna Vinschen - - * security.cc (lsaauth): Initialize lsa to INVALID_HANDLE_VALUE to - avoid potential access violation. - -2006-12-12 Corinna Vinschen - - * environ.cc (subauth_id_init): Remove. - (parse_thing): Drop "subauth_id" option. - * security.cc (get_token_group_sidlist): Drop comments concerning - subauthentication. - (create_token): Back out subauthentication related changes. - (subauth): Remove. - * security.h (create_token): Remove declaration. - (subauth): Ditto. - * syscalls.cc (seteuid32): Drop subauthentication handling entirely. - -2006-12-12 Corinna Vinschen - - * environ.cc (set_traverse): Remove. - (parse_thing): Drop "traverse" option. - * path.cc (fs_info::update): Don't request SE_CHANGE_NOTIFY_PRIV - privilege. - * sec_helper.cc (set_cygwin_privileges): Ditto. - * security.cc (allow_traverse): Remove. - (alloc_sd): Drop special allow_traverse code. - * security.h (allow_traverse): Drop declaration. - * syscalls.cc (statvfs): Don't request SE_CHANGE_NOTIFY_PRIV privilege. - -2006-12-12 Corinna Vinschen - - Partially revert change from 2005-04-03, always running under an - impersonation token, which collides with Vista UAC. - * cygheap.h (deimpersonate): revert to self instead of impersonating - hProcImpToken. - (reimpersonate): Only impersonate if setuid. - * dcrt0.cc (dll_crt0_0): Don't initialize hProcImpToken here. - (dll_crt0_1): Set privileges on hProcToken. - * fork.cc (frok::child): Set privileges on hProcToken. Close handle to - hProcImpToken. - * grp.cc (internal_getgroups): Use hProcToken instead of hProcImpToken. - * security.cc (check_access): Create hProcImpToken on demand here. - * security.h (set_process_privilege): Set privileges on hProcToken. - (_push_thread_privilege): Use hProcToken instead of hProcImpToken. - (pop_thread_privilege): If not setuid'ed, revert to self. - * syscalls.cc (setegid32): Drop setting primary group on hProcImpToken. - Close handle to hProcImpToken. - * uinfo.cc (internal_getlogin): Ditto. - * winsup.h (clear_procimptoken): New inline function. - -2006-12-12 Christopher Faylor - - * syscalls.cc (popen): Allow '[rw][bt]'. - -2006-12-12 Corinna Vinschen - - * libc/minires.c (res_ninit): Drop handling for LOCALDOMAIN environment - variable. - -2006-12-11 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Add minires-os-if.o and minires.o. - (SUBLIBS): Add libresolv.a. - Add rule for libresolv.a. - * autoload.cc: Fix return code handling for IP Helper API in case - of being unable to load iphlpapi.dll. - (DnsQuery_A): Define. - (DnsRecordListFree): Define. - * cygwin.din: Export resolver functions. - * include/resolv.h: New header. - * include/arpa/nameser.h: New header. - * include/arpa/nameser_compat.h: New header. - * include/cygwin/version.h: Bump API minor number. - * libc/minires-os-if.c: New file. - * libc/minires.c: New file. - * libc/minires.h: New file. - -2006-12-11 Christopher Faylor - - * sigproc.cc (child_info::child_info): Move old comment about msv_count - here. Edit it slightly to reflect new sensibilities. - -2006-12-11 Christopher Faylor - - * child_info.h (child_info_spawn::__stdin): New element. - (child_info_spawn::__stdin): Ditto. - (CURR_CHILD_INFO_MAGIC): Regenerate. - * dcrt0.cc (check_sanity_and_sync): Minor cleanup. - (child_info_spawn::handle_spawn): Handle new __std* elements by calling - move_fd. - * dtable.cc (dtable::move_fd): Define new function. - * dtable.h (dtable::move_fd): Declare new function. - * fhandler.h (fhandler_pipe::popen_pid): Declare new element. - * fhandler.h (fhandler_pipe::get_popen_pid): Define new function. - * fhandler.h (fhandler_pipe::set_popen_pid): Ditto. - * pipe.cc (fhandler_pipe::fhandler_pipe): Zero popen_pid. - (fhandler_pipe::dup): Ditto. - * spawn.cc (handle): Change second argument to bool. - (spawn_guts): Accept __stdin/__stdout arguments and set them - appropriately in child_info structure and in STARTUPINFO structure. - * syscalls.cc (popen): New cygwin-specific implementation using spawn. - (pclose): Ditto. - * winsup.h (spawn_guts): Accommodate new arguments for spawn_guts. - - * fhandler.cc (fhandler_base::set_no_inheritance): Make second arg a bool. - * fhandler.h (fhandler_base::set_no_inheritance): Ditto for declaration. - - * child_info.h (child_info::msv_count): Rename from the now-inappropriate - "zero". - (child_info_spawn::filler): Add filler to work around Vista bug. - (child_info_fork::filler): Ditto. - * dcrt0.cc (get_cygwin_startup_info): Remove "zero" check since it is - now always filled out. - * fork.cc (frok::parent): Move ch.zero manipulation to constructor. - * spawn.cc (spawn_guts): Ditto. Remove _ch wrapper. - * sigproc.cc (child_info::child_info): Initialize msv_count. - - * shared.cc (shared_info::heap_slop_size): Remove noisy system_printfs. - * shared_info.h (CURR_SHARED_MAGIC): Regenerate. - -2006-12-11 Corinna Vinschen - - * fhandler.cc (rootdir): Fix typo in comment. - * syscalls.cc (try_to_bin): Ditto. - -2006-12-10 Corinna Vinschen - - * autoload.cc (SHFileOperationA): Drop definition. - * ntdll.h (struct _FILE_RENAME_INFORMATION): Define. - * path.cc (fs_info::update): Note length of rootdir prefix in - root_len. - (get_nt_native_path): New function, taking over functionality of - path_conv::get_nt_native_path. - (path_conv::get_nt_native_path): Just call get_nt_native_path. - * path.h (get_nt_native_path): Declare. - (struct fs_info): New member root_len. - (fs_info::length): New inline method returning root_len. - (path_conv::rootdir): New inline method returning rootdir prefix. - * syscalls.cc (try_to_bin): Rewrite using only system calls. - (unlink_nt): Call try_to_bin with additional handle to open file - parameter. - (statvfs): Use path_conv::rootdir method. - * wincap.h: Define has_recycle_dot_bin throughout. - * wincap.cc: Ditto. - -2006-12-10 Corinna Vinschen - - * fhandler.cc (rootdir): Clarify comment. - -2006-12-10 Corinna Vinschen - - * fhandler.cc (rootdir): Don't look for volume mount points on remote - shares. - -2006-12-10 Corinna Vinschen - - * fhandler.cc (rootdir): Drop useless post-increment. Take volume - mount points into account. - (check_posix_perm): Allocate space for root directory big enough. - -2006-12-09 Corinna Vinschen - - * syscalls.cc (try_to_bin): Add comment that this is not possibly - the final version. - -2006-12-07 Corinna Vinschen - - * syscalls.cc (unlink_nt): Open native symlinks with - FILE_OPEN_REPARSE_POINT flag. - -2006-12-07 Corinna Vinschen - - * ntdll.h (STATUS_DELETE_PENDING): Define. - (struct _FILE_DISPOSITION_INFORMATION): Define. - * syscalls.cc (unlink_9x): new function to delete file on 9x. - * syscalls.cc (unlink_nt): new function to delete file on NT. - (unlink): Simplify. Move OS dependent stuff into aforementioned - functions. Also handle FILE_ATTRIBUTE_HIDDEN as R/O-like flag. - -2006-12-07 Corinna Vinschen - - * autoload.cc (SHFileOperationA): Define. - * syscalls.cc (try_to_bin): New function trying to move a file to - the recycle bin. - (unlink): Fix arguments used in CreateFile for delete on close. - Before closing the handle, try to move the file to the recycle bin. - -2006-12-07 Corinna Vinschen - - * cygheap.h (struct cwdstuff): Add "sync" member and accompanying - "keep_in_sync" methods. - * external.cc (cygwin_internal): Call above keep_in_sync method when - CW_SYNC_WINENV is requested. - * path.cc (cwdstuff::init): Don't change to windows_system_directory - if keep_in_sync is requested. - (cwdstuff::keep_in_sync): New method. - (cwdstuff::set): Take sync flag into account. - -2006-12-06 Corinna Vinschen - - * termios.cc: Change include order to accommodate change to sys/ioctl.h. - -2006-12-06 Corinna Vinschen - - * fhandler_mem.cc (fhandler_dev_mem::open): Fix comment. - * wincap.cc (has_physical_mem_access): Reflect the fact that physical - memory access has been made a protected operation beginning with - 2003 Server. - -2006-12-06 Eric Blake - - * include/sys/ioctl.h: Pick up termios.h, for TIOCGWINSZ. - -2006-12-06 Corinna Vinschen - - * winsup.h (WINVER): Set to 0x0600 to cover Vista. - -2006-12-06 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::rmdir): Fix typo. - -2006-12-05 Corinna Vinschen - - * path.cc (cwdstuff::init): Don't change to windows_system_directory - if Cygwin DLL has been loaded dynamically. - -2006-12-05 Corinna Vinschen - - * path.cc (cwdstuff::set): Don't try to open directory on systems not - supporting that. - -2006-12-05 Corinna Vinschen - - * dcrt0.cc (get_cygwin_startup_info): Fix comment. - * wincap.cc (wincapc::init): Always reset needs_count_in_si_lpres2 to - false on non 64-bit systems. - -2006-12-05 Corinna Vinschen - - * dcrt0.cc (get_cygwin_startup_info): Change zeros to DWORD array. - Expect first DWORD in child_info struct being set to non-zero if - wincap.needs_count_in_si_lpres2 is set. Add comment to explain why. - * fork.cc (frok::parent): Set ch.zero[0] to a sensible count value - if wincap.needs_count_in_si_lpres2 is set. - * spawn.cc (spawn_guts): Ditto. Add filler bytes after ch on stack - to accommodate needs_count_in_si_lpres2. - * wincap.h: Define needs_count_in_si_lpres2 throughout. - * wincap.cc: Ditto. - -2006-11-29 Corinna Vinschen - - * dir.cc (mkdir): Check last path component for "..". - (rmdir): Don't check last path component for "..". - * fhandler_disk_file.cc (fhandler_disk_file::rmdir): Drop kludge - which tries to allow deleting the current working directory. - * path.cc (has_dot_last_component): Add parameter to indicate testing - for "..". Take trailing slash into account. - (symlink_info::posixify): Rely on cygheap->cwd.win32 having a - useful value. - (cwdstuff::init): Initialize cygheap->cwd with current working - directory. Change to windows_system_directory afterwards. - (cwdstuff::set): Never call SetCurrentDirectory here. Just check - if changing into target directory would be allowed. Add comment to - explain why. - * path.h (has_dot_last_component): Declare with second parameter. - * pinfo.cc (pinfo::zap_cwd): Remove. - (pinfo::exit): Drop call to zap_cwd. - * pinfo.h (class pinfo): Remove declaration of zap_cwd. - * spawn.cc (spawn_guts): Set current working directory for non-Cygwin - child applications. Drop call to zap_cwd. - -2006-11-28 Corinna Vinschen - - * security.cc (create_token): Revert erroneous change to test - subauth_token for INVAILD_HANDLE_VALUE. - * syscalls.cc (seteuid32): Set create_token's subauth_token parameter - back to NULL. - -2006-11-28 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Fix previous patch to handle the - SYSTEM attribute as well. - -2006-11-27 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Fix handling of files with - HIDDEN attribute set. - -2006-11-27 Christopher Faylor - - * include/cygwin/signal.h: Add __extension__ to various anonymous - unions and structs. (thanks to V.Haisman) - -2006-11-27 Corinna Vinschen - - * cyglsa.h: New header file. - * environ.cc: Disable subauth settings. - * grp.cc: Accommodate cygsidlist's count now being a method. - * sec_helper.cc (SECURITY_MANDATORY_INTEGRITY_AUTHORITY): Remove. - (mandatory_medium_integrity_sid): Remove. - (mandatory_high_integrity_sid): Remove. - (mandatory_system_integrity_sid): Remove. - (fake_logon_sid): Add. - (cygsid::get_sid): Add well_known parameter. Set well_known_sid - accordingly. - (cygsid::getfromstr): Ditto. - (cygsidlist::alloc_sids): Move here from security.cc. - (cygsidlist::free_sids): Ditto. - (cygsidlist::add): Move here from security.h. Add well_known parameter. - Set well_known_sid accordingly. Don't allow duplicate SIDs. - * security.cc: Include cyglsa.h and cygwin/version.h. Throughout - accommodate cygsidlist's count now being a method. Throughout drop - redundant "contains" tests. - (get_user_local_groups): Add local groups as well known SIDs. - (get_token_group_sidlist): Add well known groups as well known SIDs. - (get_server_groups): Ditto. Only call get_unix_group_sidlist after - get_user_local_groups to maintain "well_known_sid" attribute. - (get_initgroups_sidlist): Add well known groups as well known SIDs. - (get_setgroups_sidlist): Add usersid and struct passwd parameter to - allow calling get_server_groups from here. - (get_system_priv_list): Make static. Return size of TOKEN_PRIVILEGES - structure. - (get_priv_list): Ditto. - (create_token): Accommodate above changes. Drop misguided attempt to - add MIC SIDs to created user token. Print returned token as hex value. - (subauth): Disable. - (lsaauth): New function implementing client side of LSA authentication. - * security.h (class cygsid): Add well_known_sid attribute. Accommodate - throughout. Add *= operator to create a well known SID. - (class cygsidlist): Rename count to cnt. Make count a method. - (cygsidlist::add): Move to sec_helper.cc. - (cygsidlist::operator *=): New method to add well known SID. - (cygsidlist::non_well_known_count): New method returning number of - non well known SIDs in list. - (cygsidlist::next_non_well_known_sid): New method returning next non - well known SID by index. - (mandatory_medium_integrity_sid): Drop declaration. - (mandatory_high_integrity_sid): Drop declaration. - (mandatory_system_integrity_sid): Drop declaration. - (fake_logon_sid): Add declaration. - (subauth): Disable declaration. - (lsaauth): Add declaration. - * syscalls.cc (seteuid32): Disable subauthentication. Add LSA - authentication. - * wincap.h: Define needs_logon_sid_in_sid_list throughout. - * wincap.cc: Ditto. - -2006-11-23 Corinna Vinschen - - * security.h (DBGSID): Define for debugging purposes. - (MKSID): Rename from SID so as to not hide SID definition from winnt.h. - * sec_helper.cc: Change SID to MKSID throughout. - -2006-11-23 Corinna Vinschen - - * net.cc (get_ipv6_funcs): Fix formatting. - -2006-11-23 Corinna Vinschen - - * path.cc (fs_info::update): Define GETVOLINFO_VALID_MASK and TEST_GVI. - Change FS_IS_SAMBA and FS_IS_SAMBA_WITH_QUOTA and their usage - accordingly. Define FS_IS_NETAPP_DATAONTAP. Recognize NetApp device - and store in is_netapp flag. Mark NetApp device as having no good - inodes. - * path.h (struct fs_info): Add is_netapp flag. Add matching accessors. - -2006-11-23 Thomas Wolff - - * fhandler_console.cc (set_color): Avoid (again) inappropriate - intensity interchanging that used to render reverse output unreadable - when (non-reversed) text is bright. - See http://sourceware.org/bugzilla/show_bug.cgi?id=514 - -2006-11-23 Joe Loh - - * devices.h: Add additional SCSI disk block device numbers per - http://www.kernel.org/pub/linux/docs/device-list/devices.txt - up to 128 devices. - * devices.in: Ditto. - (device::parsedisk): Add additonal else-if cases for decoding base - and drive indices. - * devices.cc: Regenerate. - * dtable.cc (build_fh_pc): Add additional DEV_SD{2..7}_MAJOR cases. - -2006-11-09 Corinna Vinschen - - * autoload.cc (EqualPrefixSid): Define. - * security.cc (create_token): Drop grps_buf. Use alloca instead. - Only add the MIC SID to the TOKEN_GROUPS list for the NtCreateToken - call. If the subauthentication token exists, use its MIC SID. - Set SID Attributes for the MIC SID to 0. - -2006-11-08 Corinna Vinschen - - * sec_helper.cc (sid_auth): Remove. - (well_known_this_org_sid): New well known sid. - (SECURITY_MANDATORY_INTEGRITY_AUTHORITY): Define. - (mandatory_medium_integrity_sid): New well known sid. - (mandatory_high_integrity_sid): Ditto. - (mandatory_system_integrity_sid): Ditto. - (cygsid::get_sid): Use local SID_IDENTIFIER_AUTHORITY. Allow all - authorities fitting in a UCHAR. - * security.cc (get_token_group_sidlist): Always add the local - group to the token. Add comment. Add "This Organization" group - if available in incoming group list. - (get_server_groups): Only add world and authenticated users groups - if not already in list. - (create_token): Add matching mandatory integrity SID to group list - on systems supporting Mandatory Integrity Control. - * security.h (well_known_this_org_sid): Define. - (mandatory_medium_integrity_sid): Define. - (mandatory_high_integrity_sid): Define. - (mandatory_system_integrity_sid): Define. - * wincap.h: Define has_mandatory_integrity_control throughout. - * wincap.cc: Ditto. - -2006-11-07 Corinna Vinschen - - * fhandler.cc (check_posix_perm): Moved here from syscalls.cc. - (fhandler_base::fpathconf): New method implementing (f)pathconf. - * fhandler.h (class fhandler_base): Declare fpathconf method. - * path.cc (path_conv::check): Replace MAX_LINK_DEPTH with SYMLOOP_MAX. - * path.h (MAX_LINK_DEPTH): Delete. - * syscalls.cc (check_posix_perm): Move to fhandler.cc. - (fpathconf): Call fhandler's fpathconf method. - (pathconf): Build fhandler and call fhandler's fpathconf method. - * sysconf.cc (sysconf): Reorder switch according to order of flags - in sys/unistd.h. Add handling for some missing flags. - * include/limits.h: Reorder according to SUSv3 description. Add some - missing definitions. Add comments. - * include/sys/syslimits.h: New file overriding newlib's syslimits.h - file. - -2006-11-06 Corinna Vinschen - - * dtable.cc (build_fh_pc): Add missing DEV_SD1_MAJOR case (Thanks to - Joe Loh for noticing). - -2006-11-02 Corinna Vinschen - - * path.cc (symlink_info::posixify): Fix comment. - -2006-11-02 Corinna Vinschen - - * path.cc (symlink_info::check): Eliminate PATH_REP bit from pflags. - -2006-11-02 Corinna Vinschen - - * path.cc (symlink_info::posixify): New method converting NT and DOS - paths in symlinks to POSIX. - (symlink_info::check_shortcut): Allocate buf allowing for a trailing 0. - Call posixify on the result. - (symlink_info::check_sysfile): Read from file into local buffer. - Eliminate old b16 considerations. Call posixify on the result. - (symlink_info::check_reparse_point): Don't use PrintName but - SubstituteName which is relevant for Windows' path handling. - Call posixify on the result. - -2006-11-01 Corinna Vinschen - - * security.h (cygpriv_idx): Add privileges new in Vista. - * security.cc (sys_privs): Ditto. - * sec_helper.cc (cygpriv): Ditto. Fix comment. - -2006-10-31 Corinna Vinschen - - * cygheap.h (struct user_heap_info): Add slop member. - * heap.cc (heap_init): Add slop factor to heap allocation. Add - comment. - * mmap.cc (MapViewNT): Allocate memory maps top down. - (fhandler_dev_zero::mmap): Ditto. - * shared.cc (shared_info::heap_slop_size): New method. - (shared_info::heap_chunk_size): Don't use debug_printf at early stage. - * shared_info.h (SHARED_INFO_CB): Accommodate change to shared_info. - (CURR_SHARED_MAGIC): Ditto. - (class shared_info): Add heap_slop member. Declare heap_slop_size. - * wincap.h: Define heapslop throughout. - * wincap.cc: Ditto. - -2006-10-31 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Drop - directory attribute for reparse points to avoid mistreating. - (fhandler_base::fstat_by_name): Ditto. - * path.cc (symlink_info::check_reparse_point): New method testing - reparse points for symbolic links. - (symlink_info::check_shortcut): Move file attribute tesat to calling - function. - (symlink_info::check): Add handling for reparse points. - * path.h (enum path_types): Add PATH_REP to denote reparse point based - symlinks. - (path_conv::is_rep_symlink): New method. - * syscalls.cc (unlink): Handle reparse points. - -2006-10-27 Corinna Vinschen - - * shared.cc (open_shared): Drop useless attempt from 2006-08-11. - -2006-10-27 Corinna Vinschen - - * dcrt0.cc (__api_fatal): Drop spare argument to __small_sprintf. - * smallprint.c (__small_vsprintf): Preserve GetLastError value. - * winsup.h (api_fatal): Simplify. Drop duplicate filename arg. - -2006-10-23 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::rewinddir): Fix comment. - -2006-10-23 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::rewinddir): Accommodate - buggy RestartScan behaviour of Windows 2000. - * wincap.h: Define has_buggy_restart_scan throughout. - * wincap.cc: Ditto. - -2006-10-22 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::facl): Fix whitespace. - * external.cc: Update copyright. - * fhandler.cc: Ditto. - * sec_helper.cc: Ditto. - * security.h: Ditto. - * security.cc: Ditto. - (check_registry_access): Return -1 if W_OK is requested. - -2006-10-22 Corinna Vinschen - - * external.cc (cygwin_internal): Use security_descriptor::copy method. - * sec_helper.cc (security_descriptor::malloc): Use own free method. - Set type. - (security_descriptor::realloc): Handle the case that psd has been - allocated using LocalAlloc. Set type. - (security_descriptor::free): Ditto. - * security.cc (get_nt_attribute): Remove. - (get_reg_security): Remove. - (get_nt_object_security): Use GetSecurityInfo which handles all - securable objects. - (get_nt_object_attribute): Remove. - (get_object_attribute): Call get_nt_object_security instead of - get_nt_object_attribute. - (get_file_attribute): Ditto. - (check_registry_access): Call get_nt_object_security instead of - get_reg_security. - * security.h (cygpsid::operator PSID): Make method const, not the - result. - (class security_descriptor): Add type member. Accommodate throughout. - (security_descriptor::copy): New method. - (security_descriptor::operator PSECURITY_DESCRIPTOR *): New operator. - -2006-10-22 Corinna Vinschen - - * fhandler.cc (fhandler_base::fhaccess): Check if opening registry - actually created a handle. This handles the registry root dir. - * fhandler_registry.cc (fhandler_registry::open): Set io_handle in - case of opening one of the predefined registry keys. - -2006-10-21 Corinna Vinschen - - * fhandler.cc (fhandler_base::fhaccess): Call check_registry_access - for registry keys/values if ntsec is on. - * security.cc (check_access): New static function derived from - check_file_access, but object type agnostic. - (check_file_access): Only do file specific stuff. Call check_access. - (check_registry_access): New access check function for registry keys/ - values. - * security.h (check_registry_access): Declare. - -2006-10-21 Corinna Vinschen - - * fhandler_registry.cc (fhandler_registry::fstat): Set restrictive - permission and ownership if key can't be opened for reading security. - (open_key): If opening key fails, retry opening with backup intent. - -2006-10-20 Corinna Vinschen - - * net.cc (cygwin_getnameinfo): Fix typo in comment. - -2006-10-19 Corinna Vinschen - - * fhandler.h (fhandler_base::set_name): Make virtual. - (class fhandler_registry): Add wow64 and prefix_len members. - Declare set_name method. - * fhandler_proc.cc (PROC_REGISTRY32): Define. - (PROC_REGISTRY64): Define. - (proc_listing): Add "registry32" and "registry64" elements. - (proc_fhandlers): Add corresponding FH_REGISTRY values. - * fhandler_registry.cc (registry_len): Drop static value in favor of - class member prefix_len. Use preifx_len instead of registry_len - throughout. - (fhandler_registry::set_name): Define. Set wow64 and prefix_len - according to directory prefix. - (fhandler_registry::fhandler_registry): Set wow64 and prefix_len to - default values. - (open_key): Add wow64 argument. Handle wow64 in call to RegOpenKeyEx. - Use fhandler_registry member wow64 in this place throughout. - -2006-10-19 Corinna Vinschen - - * fhandler_proc.cc: Drop superfluous definition of _WIN32_WINNT. - * miscfuncs.cc: Ditto. - * sched.cc: Ditto. - -2006-10-17 Corinna Vinschen - - * glob.c: Remove. - * glob.cc: New file. Latest glob version from FreeBSD plus Cygwin - specific changes (__stat64/__stat32, ignore_case_with_glob, - drop collate functions). - (glob3): Return GLOB_ABORTED in case directory is unreadable and - GLOB_ERR is set, as demanded by SUSv3. - * glob.h: Import latest version from FreeBSD. - -2006-10-17 Corinna Vinschen - - * winsup.h (WINVER): Define instead of _WIN32_WINNT. Set to 0x0502. - (_NO_W32_PSEUDO_MODIFIERS): Define. - -2006-10-16 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Drop redundant - access check. - -2006-10-16 Corinna Vinschen - - * include/asm/byteorder.h: Fix copyright dates. - -2006-10-16 Corinna Vinschen - - * autoload.cc (PrivilegeCheck): Define. - * fhandler.cc (fhandler_base::open): Always try opening with backup - resp. restore intent. - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Always try - opening with backup intent. - (fhandler_disk_file::readdir): Ditto when trying to retrieve file id - explicitely. - * security.cc (check_file_access): Replace pbuf with correctly - PPRIVILEGE_SET typed pset. Check explicitely for backup and/or restore - privileges when AccessCheck fails, to circumvent AccessCheck - shortcoming. Add comment to explain. - -2006-10-13 Christopher Faylor - - * winsup.h: Turn off DEBUGGING. - -2006-10-13 Corinna Vinschen - - * autoload.cc (Wow64DisableWow64FsRedirection): Define. - (Wow64RevertWow64FsRedirection): Define. - * security.cc (cygsuba_installed): New shared variable to store result - of cygsuba.dll installation test. - (subauth): Check if cygsuba.dll has been installed and registered - before issuing the (sub)authentication. - -2006-10-12 Corinna Vinschen - - * security.cc (create_token): Fix condition for source identifier. - -2006-10-11 Corinna Vinschen - - * select.cc (struct socketinf): Convert ser_num and w4 to dynamically - allocated arrays. Add max_w4 member to keep track. - (thread_socket): Make timeout depending on number of sockets to wait - for. Loop WFMO over all sockets. - (start_thread_socket): Handle any number of sockets. Fix typo. Don't - close socket event in out of memory condition. - (socket_cleanup): Free ser_num and w4. - -2006-10-06 David Jade - - * path.cc (path_conv::get_nt_native_path): Properly detect \\?\ paths. - (mount_info::conv_to_win32_path): Update comment. - * fhandler_disk_file.cc (path_conv::ndisk_links): Use backslashes - to make NT kernel functions work for \\?\GLOBALROOT paths. - -2006-10-09 Corinna Vinschen - - * devices.in: Raise number of handled serial ports to 64. - * devices.cc: Regenerate. - -2006-09-17 Danny Smith - - * include/asm/byteorder.h: Correct typo. - -2006-09-17 Danny Smith - - * include/asm/byteorder.h: Don't #define n* macros if -fnoinline is - specified. - -2006-09-07 Christopher Faylor - - * environ.cc (build_env): Don't put an empty environment variable into - the environment. Optimize use of "len". - * errno.cc (ERROR_MORE_DATA): Translate to EMSGSIZE rather than EAGAIN. - -2006-08-31 Corinna Vinschen - - * grp.cc (initgroups32): Run get_server_groups under original token. - * syscalls.cc (seteuid32): Slightly reorganize code creating a token. - -2006-08-27 Christopher Faylor - - * child_info.h (child_info_spawn::~child_info_spawn): Don't close - myself_pinfo handle when spawning. - -2006-08-20 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Fix formatting. - -2006-08-20 Corinna Vinschen - - * fhandler_disk_file.cc (DIR_NUM_ENTRIES): Set to 100 to maximize - performance on remote shares. - (fhandler_disk_file::opendir): Move comment about Samba weirdness into - fhandler_disk_file::readdir. Don't disallow - FileIdBothDirectoryInformation on Samba. - (fhandler_disk_file::readdir): Workaround Samba problem with - FileIdBothDirectoryInformation by rereading already read entries - using FileBothDirectoryInformation. Change comment about Samba - weirdness explaining this change. - -2006-08-20 Hideki Iwamoto - - * fhandler_disk_file.cc (fhandler_disk_file::pread): Properly check for - non-error return from lseek. - -2006-08-17 Corinna Vinschen - - * fhandler_serial.cc (raw_read): Evaluate minchars taking the - vmin_ > ulen case into account. Simplify evaluating the bytes to read. - Don't use bytes in Queue value from ClearCommError call in case vtime_ - is > 0. Reformat GetOverlappedResult call. Simplify call to ReadFile. - -2006-08-14 Corinna Vinschen - - * security.cc (subauth): Initialize user_token to NULL. Add comment. - -2006-08-11 Corinna Vinschen - - * shared.cc (open_shared): Desperately try to get shared memory, only - when DEBUGGING enabled for now. - -2006-08-10 Christopher Faylor - - * pinfo.cc (_onreturn::~onreturn): Don't attempt to close a NULL - handle. - -2006-08-10 Christopher Faylor - - * winsup.h: Turn on DEBUGGING by default for now. - -2006-08-10 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::lock): Handle - ERROR_NOT_LOCKED returned from UnlockFileEx. - -2006-08-09 Corinna Vinschen - - * path.h (SYMLINK_EA_NAME): Remove. - (SHORTCUT_HDR_SIZE): Ditto. - -2006-08-09 Christopher Faylor - - * autoload.cc (GetHandleInformation): Declare new function. - (SetHandleInformation): Ditto. - * debug.cc (add_handle): Use SetHandleInformation to protect handle. - (close_handle): Use SetHandleInformation to unprotect handle. - - * spawn.cc (spawn_guts): Move detached test outside of P_OVERLAY block. - -2006-08-07 Corinna Vinschen - - * autoload.cc (NtSetInformationFile): Define. - * cygwin.din: Export posix_fadvise and posix_fallocate. - * fhandler.cc (fhandler_base::fadvise): New method. - (fhandler_base::ftruncate): Add allow_truncate parameter. - * fhandler.h (class fhandler_base): Add fadvise method. Accommodate - new parameter to ftruncate. - (class fhandler_pipe): Add fadvise and ftruncate methods. - (class fhandler_disk_file): Add fadvise method. Accommodate new - parameter to ftruncate. - * fhandler_disk_file.cc (fhandler_disk_file::fadvise): New method. - (fhandler_disk_file::ftruncate): Accommodate new allow_truncate - parameter. Set EOF using NtSetInformationFile on NT. - * ntdll.h (struct _FILE_END_OF_FILE_INFORMATION): Define. - (NtSetInformationFile): Declare. - * pipe.cc (fhandler_pipe::fadvise): New method. - (fhandler_pipe::ftruncate): Ditto. - * syscalls.cc (posix_fadvise): New function. - (posix_fallocate): Ditto. - (ftruncate64): Accommodate second parameter to fhandler's ftruncate - method. - * include/fcntl.h: Add POSIX_FADV_* flags. Add declarations of - posix_fadvise and posix_fallocate. - * include/cygwin/version.h: Bump API minor number. - -2006-08-02 Christopher Faylor - - * environ.cc (env_win32_to_posix_path_list): Declare. - (conv_envvars): Use env_win32_to_posix_path_list rather than - cygwin_win32_to_posix_path_list. - (posify): Translate back to win32 path if errno is EIDRM. - * environ.h: Update copyright. Define ENV_CVT. - * path.cc (conv_path_list): If converting for the environment and - removed an element set errno to ENV_CVT. - (env_win32_to_posix_path_list): New function. - -2006-08-01 Christopher Faylor - - * environ.cc (dos_file_warning): Declare. - (parse_thing): Add "dosfilewarning". Alphabetize. - * path.cc (normalize_posix_path): Return -1 when MS-DOS path detected. - (warn_msdos): New function. - (path_conv::check): Call if !PC_NOWARN and MS-DOS path detected. - (cygwin_conv_to_win32_path): Set PC_NOWARN when calling path_conv. - (cygwin_conv_to_full_win32_path): Ditto. - * path.h (pathconv_arg::PC_NOWARN): Define. - * shared_info.h (user_info::warned_msdos): New field. - (CURR_USER_MAGIC): Reset. - -2006-07-31 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::recv_internal): Fix a problem - with poll(2) after shutdown(SHUT_RD) has been called on the local side. - * poll.cc (poll): Use POSIX type nfds_t for second parameter. Drop - special socket handling for POLLIN. Add comment to explain why. - * include/sys/poll.h: Declare nfds_t. Use as type for second parameter - in poll(2) declaration. - -2006-07-31 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::evaluate_events): Circumvent - potential race condition. - (fhandler_socket::recv_internal): Fix MSG_PEEK bug on blocking sockets - and simplify recv loop. - (fhandler_socket::send_internal): Only lock when changing wsock_events. - -2006-07-31 Corinna Vinschen - - * autoload.cc: Drop LoadDLLprime for wsock32 since no wsock32 function - is used anymore. Drop all unused ws2_32.dll functions. - -2006-07-28 Corinna Vinschen - - * fhandler.h (struct wsa_event): Define here. - (class fhandler_socket): Make wsock_evt private again. - (fhandler_socket::wsock_event): New read accessor for wsock_evt. - (fhandler_socket::serial_number): New read accessor to get the - socket's serial number. - (fhandler_socket::ready_for_read): Just return true. - * fhandler_socket.cc (struct wsa_event): Move definition to fhandler.h. - * select.cc (struct socketinf): Add serial number vector. - (start_thread_socket): Identify duplicate sockets by their serial - number, not (wrongly) by their wsock_evt. - -2006-07-27 Corinna Vinschen - - * fhandler_socket.cc: Revert misguided attempt to handle FD_CLOSE error - conditions in evaluate_events. - (search_wsa_event_slot): Move wrongly placed memset in - fhandler_socket::init_events here. - (fhandler_socket::init_events): Initially set FD_WRITE event for - connectionless sockets. - * poll.cc (poll): Don't add sockets always to except_fds since select - is now supposed to do it right. - * select.cc (set_bits): Set connection state correctly for failed - af_local_connect on local sockets. Remove socket special handling - for except_selected descriptors. - (peek_socket): Try to set the read/write/exception bits actually - correctly. - -2006-07-27 Brian Ford - - * fhandler_socket.cc (fhandler_socket::recvmsg): Remove unused tot - argument. All callers changed. - (fhandler_socket::sendmsg): Likewise. - * net.cc (cygwin_recvmsg): Likewise. - (cygwin_sendmsg): Likewise, and prevent calling sendmsg whith an - invalid iovec. - * fhandler.h (fhandler_socket::recvmsg): Adjust prototype. - (fhandler_socket::sendmsg): Likewise. - -2006-07-27 Corinna Vinschen - - * fhandler.h (class fhandler_socket): Remove prot_info_ptr. - (fhandler_socket::fixup_before_fork_exec): Remove. - (fhandler_socket::fixup_after_exec): Remove. - (fhandler_socket::need_fixup_before): Remove. - * fhandler_socket.cc (fhandler_socket::fhandler_socket): Drop - initializing prot_info_ptr. Remove unused code. - (fhandler_socket::~fhandler_socket): Drop free'ing prot_info_ptr. - (struct wsa_event): Rename connect_errorcode to errorcode. - (fhandler_socket::evaluate_events): Handle FD_CLOSE error condition - as FD_CONNECT error condition, except, never reset an FD_CLOSE error - condition. Always set FD_WRITE after successfully recorded FD_CONNECT. - (fhandler_socket::fixup_before_fork_exec): Remove. - (fhandler_socket::fixup_after_fork): Revert to using handle duplication. - (fhandler_socket::fixup_after_exec): Remove. - (fhandler_socket::dup): Revert to using handle duplication. - (fhandler_socket::send_internal): Only call wait_for_events in case - of WSAEWOULDBLOCK condition. - (fhandler_socket::set_close_on_exec): Call - fhandler_base::set_close_on_exec. - * net.cc (fdsock): Just set socket to inheritable on non-NT. Don't - call inc_need_fixup_before. - * select.cc (peek_socket): Don't set except_ready on every FD_CLOSE, - just on error. - -2006-07-26 Brian ford - - * fhandler.cc (fhandler_base::read): Call get_readahead_into_buffer - instead of duplicating it. - -2006-07-26 Corinna Vinschen - - * shared.cc (offsets): Define as offsets relative to cygwin_hmodule - instead of addresses. - (off_addr): New macro. - (open_shared): Use offsets array accordingly. Remove unused code. - * shared_info.h (cygwin_shared_address): Remove. - -2006-07-26 Corinna Vinschen - - * cygheap.h (struct init_cygheap): Remove shared_h and mt_h members. - * fhandler_tape.cc (mt): Define as DLL shared area in - .cygwin_dll_common instead of as dynamically allocated area. - Change referencing throughout. - * mtinfo.h (mt_h): Remove entirely. - (mt): Remove extern declaration. - * shared.cc (cygwin_shared_area): New global cygwin_shared - variable located in .cygwin_dll_common. - (offsets): Define shared region addresses descending from - cygwin_shared_address. - (open_shared): Replace usage of SH_CYGWIN_SHARED by SH_USER_SHARED. - (memory_init): Set cygwin_shared just by pointing to cygwin_shared_area. - * shared_info.h (shared_locations): Remove SH_CYGWIN_SHARED and - SH_MTINFO. - (cygwin_shared_address): Define as DLL start address. - * tty.h (tty_min::tty_min): Remove constructor. - -2006-07-25 Corinna Vinschen - - * include/cygwin/in6.h: Guard in_port_t typedef more restrictive to - avoid compiler warning. - -2006-07-25 Christopher Faylor - - * security.cc (get_logon_server): Remove nret and use dret for - everything to avoid a g++ warning. - -2006-07-25 Corinna Vinschen - - * include/cygwin/version.h: Bump DLL version to 1.7.0. - -2006-07-25 Corinna Vinschen - - * select.h: Remove. - * fhandler_socket.cc: Don't include select.h. - * select.cc: Ditto. - -2006-07-25 Corinna Vinschen - - * cygtls.h: Drop socket related includes. - (struct _local_storage): Remove exitsock and exitsock_sin. Add - select_sockevt. - * cygtls.cc: Accommodate above change throughout. - * fhandler.h (class fhandler_socket): Make wsock_evt public. - * fhandler_socket.cc (fhandler_socket::fhandler_socket): Accommodate - reordering members. - (fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as - it gets read once. Never remove FD_WRITE event here. - (fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for - socket events. - (fhandler_socket::accept): Fix conditional. Set wsock_events members - of accepted socket to useful start values. - (fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from - wsock_events after the call to WSARecvFrom. - (fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events - if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value - condition. - * select.cc (struct socketinf): Change to accommodate using socket event - handling. - (peek_socket): Use event handling for peeking socket. - (thread_socket): Ditto. - (start_thread_socket): Ditto. - (socket_cleanup): Same here. - * tlsoffsets.h: Regenerate. - -2006-07-23 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor version number to 22. - -2006-07-20 Corinna Vinschen - - * fhandler.h (class fhandler_socket): Rearrange slightly to keep - event handling methods and members together. Drop owner status flag. - Split wait method. Rename event handling methods for readability. - * fhandler_socket.cc (struct wsa_event): Add owner field. - (LOCK_EVENTS): New macro. - (UNLOCK_EVENTS): Ditto. - (fhandler_socket::init_events): rename from prepare. - (fhandler_socket::evaluate_events): First half of former wait method. - Do everything but wait. Allow specifiying whether or not events from - event_mask should be erased from wsock_events->events. Simplify - OOB handling. Allow sending SIGURG to any process (group). - (fhandler_socket::wait_for_events): Second half of former wait method. - Call evaluate_events and wait in a loop if socket is blocking. - (fhandler_socket::release_events): Rename from release. - (fhandler_socket::connect): Accommodate above name changes. - (fhandler_socket::accept): Ditto. - (fhandler_socket::recv_internal): Ditto. - (fhandler_socket::send_internal): Ditto. - (fhandler_socket::close): Ditto. - (fhandler_socket::fcntl): Always set owner to given input value on - F_SETOWN. Handle F_GETOWN. - * net.cc (fdsock): Accommodate above name changes. - -2006-07-20 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to - WSAEWOULDBLOCK instead of WSAEINPROGRESS. - -2006-07-19 Corinna Vinschen - - * pinfo.cc (commune_process): Don't add extra \0 to cmdline. - (_pinfo::cmdline): Ditto process internal. - -2006-07-19 Corinna Vinschen - - * mmap.cc (msync): Disable rounding up len. Fix bug in access check - loop. - -2006-07-19 Corinna Vinschen - - * path.cc (symlink_worker): Return EEXIST if newpath exists. - -2006-07-18 Christopher Faylor - - * tty.cc (tty_list::terminate): Don't enter the busy loop if we don't - own the master. - -2006-07-18 Silvio Laguzzi - - * sec_acl.cc (acltotext32): Add missing handling of default ACL entry - types. - -2006-07-18 Brian Ford - Corinna Vinschen - - * winsup.h (mmap_region_status): New enum. - (mmap_is_attached_or_noreserve_page): Adjust prototype and rename - as below. - * mmap.cc (mmap_is_attached_or_noreserve_page): Rename - mmap_is_attached_or_noreserve. Add region length parameter. - Return enum above. - * exceptions.cc (_cygtls::handle_exceptions): Accommodate above. - * fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS - errors and retry on success to allow reads into untouched - MAP_NORESERVE buffers. - -2006-07-18 Corinna Vinschen - - * fhandler_floppy.cc (fhandler_dev_floppy::ioctl): Fix typo in lint - directive. - -2006-07-18 Corinna Vinschen - - * cygwin.din (posix_openpt): Export. - * tty.cc (posix_openpt): New function. - * include/cygwin/stdlib.h (posix_openpt): Declare. - * include/cygwin/version.h: Bump API minor number. - -2006-07-17 Christopher Faylor - - GCC 4.1 fixes. - * cygheap.h (cygheap_user): Remove unneeded class names from function - declaration. - * fhandler.h (fhandler_base): Ditto. - (fhandler_dev_floppy): Ditto. - (fhandler_console): Ditto. - * wininfo.h (wininfo): Ditto. - * exceptions.cc (sigpacket::process): Avoid compiler errors about gotos - and initialization. - * fhandler_fifo.cc (fhandler_fifo::open): Ditto. - * fhandler_floppy.cc (fhandler_dev_floppy::ioctl): Ditto. - * fhandler_tty.cc (fhandler_tty_slave::ioctl): Ditto. - * mmap.cc (mmap64): Ditto. - * pipe.cc (fhandler_pipe::open): Ditto. - * spawn.cc (spawn_guts): Ditto. - - * sec_helper.cc: Fix some comments. - (get_null_sd): Move file-scope static to only function where it is - used. - -2006-07-14 Christopher Faylor - - * fork.cc (fork): Lock the process before forking to prevent things - like new fds from being opened, etc. - * sync.h (lock_process::dont_bother): New function. - -2006-07-14 Christopher Faylor - - * include/cygwin/types.h: Update copyright. - -2006-07-14 Christopher Faylor - - * cygwin.sc: Make sure there's something in the cygheap. - * dllfixdbg: Accommodate newer binutils which put the gnu_debuglink at - the end rather than at the beginning. - -2006-07-14 Corinna Vinschen - - * security.cc (get_token_group_sidlist): Always add the interactive - group to the token. Add comment. Create logon_id group SID by - copying it from incoming group list. - (create_token): Add subauth_token parameter. Use information in - subauth_token if present. Tweak SourceIdentifier if subauth_token - is present for debugging purposes. - * security.h (create_token): Add subauth_token parameter in declaration. - * syscalls.cc (seteuid32): Call subauth first. Call create_token - regardless. Use subauth token in call to create_token if subauth - succeeded. - -2006-07-13 Christopher Faylor - - * sigproc.cc (waitq_head): Don't initialize to zero. - * sigproc.h: Update copyright, fix whitespace. - -2006-07-13 Christopher Faylor - - * fhandler.cc (fhandler_base::raw_read): Only return EISDIR when we're - really trying to read a directory. - - * sigproc.cc: Use "Static" where appropriate. - -2006-07-13 Corinna Vinschen - - * include/netinet/in.h: Update copyright. - -2006-07-13 Corinna Vinschen - - * fhandler_socket.cc: Update copyright. - * include/pthread.h: Ditto. - -2006-07-13 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::wait): Rework function so that - WaitForMultipleObjects is really only called when necessary. - -2006-07-13 Corinna Vinschen - - * mmap.cc (mmap64): Drop MAP_NORESERVE flag for non-anonymous, - non-private mappings. - (mmap_record::unmap_pages): Only check noreserve flag which now implies - anonymous and private. - (mprotect): Ditto. - (fixup_mmaps_after_fork): Ditto. - -2006-07-13 Corinna Vinschen - - * mmap.cc (mmap64): Drop MAP_RESERVED flag for all non-anonymous, - non-private mappings. - -2006-07-13 Corinna Vinschen - - * exceptions.cc (_cygtls::handle_exceptions): Call new - mmap_is_attached_or_noreserve_page function in case of access violation - and allow application to retry access on noreserve pages. - * mmap.cc (mmap_is_attached_or_noreserve_page): Changed from - mmap_is_attached_page. Handle also noreserve pages now. Change - comment accordingly. - * winsup.h (mmap_is_attached_or_noreserve_page): Declare instead of - mmap_is_attached_page. - -2006-07-12 Corinna Vinschen - - * mmap.cc (mmap_record::alloc_page_map): Don't call VirtualProtect - on maps created with MAP_NORESERVE. - -2006-07-12 Corinna Vinschen - - * include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport, - rresvport_af, iruserok, iruserok_sa, ruserok. - -2006-07-12 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o. - * autoload.cc (rcmd): Drop definition. - * cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa, - rcmd_af, rresvport_af. - * net.cc (cygwin_rcmd): Remove. - (last_used_bindresvport): Rename from last_used_rrecvport. - (cygwin_bindresvport_sa): New function implementing bindresvport_sa. - (cygwin_bindresvport): New function implementing bindresvport. - (cygwin_rresvport): Remove. - * include/cygwin/version.h: Bump API minor number. - * include/netinet/in.h: Declare bindresvport and bindresvport_sa. - * libc/iruserok.c: Remove file. - * libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport, - rresvport_af, iruserok_sa, iruserok and ruserok. - -2006-07-12 Corinna Vinschen - - * include/pthread.h: Define PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT and - PTHREAD_PRIO_PROTECT only if _POSIX_THREAD_PRIO_INHERIT is defined. - -2006-07-12 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::getsockname): Return valid - result for unbound sockets. - -2006-07-11 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle - wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly. - (fhandler_socket::fixup_after_exec): Drop misguided attempt to handle - close_on_exec here. - (fhandler_socket::dup): Call fixup_after_fork with NULL parent. - Add comment. - (fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt. - -2006-07-10 Corinna Vinschen - - * fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt - and wsock_events members. Remove closed status flag, add listener - status flag. Accommodate new implementation of socket event handling - methods. Declare recv* and send* functions ssize_t as the POSIX - equivalents. - (fhandler_socket::recv_internal): Declare. - (fhandler_socket::send_internal): Ditto. - * fhandler_socket.cc (EVENT_MASK): Define mask of selected events. - (fhandler_socket::fhandler_socket): Initialize new members. - (fhandler_socket::af_local_setblocking): Don't actually set the - socket to blocking mode. Keep sane event selection. - (fhandler_socket::af_local_unsetblocking): Don't actually set the - socket to previous blocking setting, just remember it. - (struct wsa_event): New structure to keep event data per shared - socket. - (NUM_SOCKS): Define number of shared sockets concurrently handled by - all active Cygwin processes. - (wsa_events): New shared datastructure keeping all wsa_event records. - (socket_serial_number): New shared variable to identify shared sockets. - (wsa_slot_mtx): Global mutex to serialize wsa_events access. - (search_wsa_event_slot): New static function to select a new wsa_event - slot for a new socket. - (fhandler_socket::prepare): Rewrite. Prepare event selection - per new socket. - (fhandler_socket::wait): Rewrite. Wait for socket events in thread - safe and multiple process safe. - (fhandler_socket::release): Rewrite. Close per-socket descriptor - mutex handle and event handle. - (fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix - copy-paste error in debug output. - (fhandler_socket::connect): Accommodate new event handling. - (fhandler_socket::listen): Set listener flag on successful listen. - (fhandler_socket::accept): Accommodate new event handling. - (fhandler_socket::recv_internal): New inline method centralizing - common recv code. - (fhandler_socket::recvfrom): Call recv_internal now. - (fhandler_socket::recvmsg): Ditto. Streamline copying from iovec - to WSABUF. - (fhandler_socket::send_internal): New inline method centralizing - common send code. - (fhandler_socket::sendto): Call send_internal now. - (fhandler_socket::sendmsg): Ditto. Streamline copying from iovec - to WSABUF. - (fhandler_socket::close): Call release now. - (fhandler_socket::ioctl): Never actually switch to blocking mode. - Just keep track of the setting. - * net.cc (fdsock): Call prepare now. - (cygwin_connect): Revert again to event driven technique. - (cygwin_accept): Ditto. - * poll.cc (poll): Don't call recvfrom on a listening socket. - Remove special case for failing recvfrom. - * include/sys/socket.h: Declare recv* and send* functions ssize_t as - requested by POSIX. - -2006-07-10 Corinna Vinschen - - * libc/inet_addr.c: Define __INSIDE_CYGWIN_NET__. - * libc/inet_network.c: Ditto. - -2006-07-07 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::wait): Disable SA_RESTART - handling for now. - -2006-07-07 Corinna Vinschen - - * net.cc (cygwin_inet_ntop): Fix data type of forth parameter. - -2006-07-07 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Add inet_addr.o and inet_network.o. - * autoload.cc (inet_addr): Drop definition. - (inet_ntoa): Ditto. - * net.cc: Forward declare cygwin_inet_aton and cygwin_inet_ntop. - (cygwin_inet_ntoa): Call cygwin_inet_ntop instead of Winsock inet_ntoa. - (cygwin_inet_addr): Remove here. - (cygwin_inet_aton): Ditto. - (cygwin_inet_network): Ditto. - * libc/inet_addr.c: New file implementing cygwin_inet_aton and - cygwin_inet_addr. - * libc/inet_network.c: New file implementing cygwin_inet_network. - -2006-07-06 Christopher Faylor - - * hookapi.cc: Add comment header - (putmem): Make static. - (get_export): Ditto. - (rvadelta): Ditto. Don't assume that a section which ends where the - import_rva begins is the import list. - - * child_info.h: Update copyright. - * fork.cc: Ditto. - -2006-07-06 Corinna Vinschen - - * include/cygwin/in6.h (struct in6_addr): Fix typo. - -2006-07-06 Corinna Vinschen - - * cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo, - gai_strerror, getaddrinfo, getnameinfo. - * fhandler_socket.cc: Include cygwin/in6.h. - (get_inet_addr): Accommodate AF_INET6 usage. - (fhandler_socket::connect): Ditto. - (fhandler_socket::listen): Ditto. - (fhandler_socket::sendto): Ditto. - * net.cc: Include cygwin/in6.h. - (in6addr_any): Define. - (in6addr_loopback): Define. - (cygwin_socket): Accommodate AF_INET6 usage. - (socketpair): Bind socketpairs only to loopback for security. - (inet_pton4): New static function. - (inet_pton6): Ditto. - (cygwin_inet_pton): New AF_INET6 aware inet_pton implementation. - (inet_ntop4): New static function. - (inet_ntop6): Ditto. - (cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation. - (ga_aistruct): New static function. - (ga_clone): Ditto. - (ga_echeck): Ditto. - (ga_nsearch): Ditto. - (ga_port): Ditto. - (ga_serv): Ditto. - (ga_unix): Ditto. - (gn_ipv46): Ditto. - (ipv4_freeaddrinfo): Ditto. - (ipv4_getaddrinfo): Ditto. - (ipv4_getnameinfo): Ditto. - (gai_errmap_t): New structure holding error code - error string mapping. - (cygwin_gai_strerror): New function implementing gai_strerror. - (w32_to_gai_err): New static function. - (get_ipv6_funcs): Ditto. - (load_ipv6_funcs): Ditto. - (cygwin_freeaddrinfo): New function implementing freeaddrinfo. - (cygwin_getaddrinfo): New function implementing getaddrinfo. - (cygwin_getnameinfo): New function implementing getnameinfo. - * include/netdb.h: Include stdint.h and cygwin/socket.h. Define - data types and macros used by getaddrinfo and friends. Declare - freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo. - * include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition - of struct sockaddr_in6. Include cygwin/in6.h instead. - * include/cygwin/in6.h: New header file defining IPv6 releated - data types and macros. - * include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add - IPv6 related socket options. - * include/cygwin/version.h: Bump API minor number. - -2006-07-06 Corinna Vinschen - - * autoload.cc (DsGetDcNameA): Define. - (NetGetAnyDCName): Define. - * security.cc: Include dsgetdc.h. - (DsGetDcNameA): Declare. - (DS_FORCE_REDISCOVERY): Define. - (get_logon_server): Add bool parameter to control rediscovery of DC. - Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName - otherwise. - (get_server_groups): Rediscover DC if get_user_groups fails and - try again. - (get_reg_security): Use correct error code macro when testing - RegGetKeySecurity return value. - * security.h (get_logon_server): Remove default vaue from wserver - parameter. Add rediscovery parameter. - * uinfo.cc (cygheap_user::env_logsrv): Accommodate rediscovery parameter - in call to get_logon_server. - -2006-07-05 Christopher Faylor - - * sortdin: Ignore all leading underscores when deriving a sort key. - * cygwin.din: Resort. - -2006-07-05 Christopher Faylor - - * sortdin: New program. - * cygwin.din: Sort. - -2006-07-05 Corinna Vinschen - - * fhandler.h (fhandler_socket::wait): Reset default timeout to 10ms. - -2006-07-05 Corinna Vinschen - - * path.cc (path_conv::check): Ignore has_ea setting, it's always unset - at this point anyway. - (get_symlink_ea): Remove. - (set_symlink_ea): Remove. - (symlink_worker): Drop writing symlink into NTFS extended attributes. - (symlink_info::check): Drop reading symlinks from NTFS extended - attributes. - -2006-07-04 Christopher Faylor - - * libc/rexec.cc (cygwin_rexec): Obvious (?) fix to correct a gcc - warning - set port to zero first thing in the function. - -2006-07-04 Corinna Vinschen - - * signal.cc (signal): Set sa_mask to sig. - -2006-07-04 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Add rexec.o. - * autoload.cc (inet_network): Drop definition. - (rexec): Ditto. - * net.cc (rexec): Drop extern declaration. - (inet_network): Ditto. - (cygwin_inet_network): Implement using inet_addr. - (cygwin_rexec): Remove. - * libc/rexec.cc: New file. - -2006-07-04 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::listen): Allow listening on - unbound INET socket. - -2006-07-04 Corinna Vinschen - - * fhandler.h (fhandler_socket::wait): Set default timeout to INFINITE. - -2006-07-03 Corinna Vinschen - - * autoload.cc (NtQueryEaFile): Define. - (NtSetEaFile): Define. - * fhandler.cc (fhandler_base::open): Use appropriate open flags - in query case when allow_ntea is set. - * ntdll.h (struct _FILE_GET_EA_INFORMATION): Define. - (struct _FILE_FULL_EA_INFORMATION): Define. - (NtQueryEaFile): Declare. - (NtSetEaFile): Declare. - * ntea.cc (read_ea): Rename from NTReadEA and rewrite using - NtQueryEaFile. - (write_ea): Rename from NTWriteEA and rewrite using NtSetEaFile. - * path.cc (get_symlink_ea): Make static. Add handle parameter to - accommodate new read_ea call. - (set_symlink_ea): Make static. Add handle parameter to accommodate new - write_ea call. - (symlink_worker): Call set_symlink_ea while file is still open. - (symlink_info::check): Call get_symlink_ea after file has been opened. - * security.cc (get_file_attribute): Accommodate new read_ea call. - (set_file_attribute): Accommodate new write_ea call. - * security.h (read_ea): Change declaration accordingly. - (write_ea): Ditto. - -2006-07-03 Kazuhiro Fujieda - - * fhandler.h (class dev_console): Add `metabit' indicating the - current meta key mode. - * fhandler_console.cc (fhandler_console::read): Set the top bit of - the character if metabit is true. - * fhandler_console.cc (fhandler_console::ioctl): Implement - KDGKBMETA and KDSKBMETA commands. - * fhandler_tty.cc (process_ioctl): Support KDSKBMETA. - (fhandler_tty_slave::ioctl): Send KDGKBMETA and KDSKBMETA to the - master. - * include/cygwin/kd.h: New file for the meta key mode. - * include/sys/kd.h: New file. - -2006-07-03 Eric Blake - - * include/stdint.h (UINT8_C, UINT16_C): Unsigned types smaller - than int promote to signed int. - -2006-07-03 Corinna Vinschen - - * net.cc (cygwin_sendto): Define appropriate parameters using - socklen_t type according to SUSv3. - (cygwin_recvfrom): Ditto. - (cygwin_setsockopt): Ditto. - (cygwin_getsockopt): Ditto. - (cygwin_connect): Ditto. - (cygwin_accept): Ditto. - (cygwin_bind): Ditto. - (cygwin_getsockname): Ditto. - (cygwin_getpeername): Ditto. - (cygwin_recv): Ditto. - (cygwin_send): Ditto. - * include/cygwin/socket.h (socklen_t): Typedef and define. - * include/sys/socket.h: Declare socket functions using socklen_t type. - -2006-07-02 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor version number to 21. - -2006-06-30 Corinna Vinschen - - * net.cc (cygwin_sendto): Allow zero-sized packets. - (cygwin_sendmsg): Ditto. - -2006-06-26 Corinna Vinschen - - Revert patches from 2005-10-22 and 2006-06-14 to use event driven - accept and connect back to using select: - * fhandler.h (class fhandler_socket): Remove accept_mtx. - * fhandler_socket.cc (fhandler_socket::fhandler_socket): Drop - initializing accept_mtx. - (fhandler_socket::accept): Drop event handling. - (fhandler_socket.cc (fhandler_socket::connect): Ditto. - (fhandler_socket::dup): Drop accept_mtx handling. - (fhandler_socket::listen): Ditto. - (fhandler_socket::prepare): Ditto. - (fhandler_socket::release): Ditto. - (fhandler_socket::close): Ditto. - * net.cc (cygwin_accept): Revert to calling cygwin_select to - implement interuptible accept. - (cygwin_connect): Ditto for connect. - -2006-06-22 Christopher Faylor - - * fhandler_fifo.cc (fhandler_fifo::open): Release process lock and grab - a system-wide mutex to prevent a deadlock and a race. - * sync.h (lock_process): Make fhandler_fifo a friend. - - * smallprint.c (__small_vsprintf): Cosmetic change. - -2006-06-15 Corinna Vinschen - - * cygwin.din: Export __srget_r, __swbuf_r. - * include/cygwin/version.h: Bump API minor number to 156. - -2006-06-14 Corinna Vinschen - - * fhandler.h (class fhandler_socket): Add private mutex handle - accept_mtx. - * fhandler_socket.cc (fhandler_socket::fhandler_socket): Initialize - accept_mtx to NULL. - (fhandler_socket::dup): Duplicate accept_mtx, if available. - (fhandler_socket::listen): Create accept_mtx before trying to listen. - (fhandler_socket::prepare): Wait for accept_mtx if available to - serialize accepts on the same socket. - (fhandler_socket::release): Release accept_mtx. - (fhandler_socket::close): Close accept_mtx on successful closesocket. - -2006-06-12 Christopher Faylor - - * fhandler_tty.cc (fhandler_pty_master::close): Always close - from_master/to_master since we always have copies of these handles. - -2006-06-12 Corinna Vinschen - - * include/sys/wait.h: Move definition of wait constants from here... - * include/cygwin/wait.h: ...to here. New file. - * include/cygwin/stdlib.h: Include cygwin/wait.h to conform with SUSv3. - -2006-06-12 Pierre Humblet Pierre.Humblet@ieee.org - - * heap.cc (heap_init): Only commit if allocsize is not zero. - -2006-06-12 Corinna Vinschen - - * net.cc (fdsock): Disable raising buffer sizes. Add comment to - explain why. - -2006-06-04 Christopher Faylor - - * ioctl.cc (ioctl): Accommodate change in reported pty master device - number. - * select.cc (peek_pipe): Ditto. - -2006-06-04 Christopher Faylor - - * cygtls.h (CYGTLS_PADSIZE): Reset to a size that XP SP1 seems to like. - * tlsoffsets.h: Regenerate. - -2006-06-03 Christopher Faylor - - * cygthread.cc (cygthread::terminate_thread): In debugging output, use - name of thread being terminated rather than thread doing the - terminating. - - * fhandler.h (fhandler_pty_master::slave): Delete. - (fhandler_pty_master::get_unit): Ditto. - (fhandler_pty_master::setup): Change argument declaration to - accommodate new usage. - * fhandler_tty.cc (fhandler_tty_master::init): Remove obsolete slave - assignment. Pass argument to setup indicating that this is a tty. - (fhandler_tty_slave::open): Use dev() method rather than referencing - pc.dev directly. - (fhandler_pty_master::open): Don't create archetype based on ptym - device number. Set device number to use DEV_TTYM_MAJOR and tty number. - Pass argument to setup indicating that this is a pty. - (fhandler_pty_master::setup): Change single argument to a flag - indicating whether we're creating a pty and use appropriately. - Calculate 't' variable here rather than in caller. - - * fhandler_dsp.cc (fhandler_dev_dsp::open): Use dev() method rather - than referencing pc.dev directly. - -2006-06-03 Christopher Faylor - - * dcrt0.cc (dll_crt0_0): Call tty_list::init_session here. - (dll_crt0_1): Reflect renaming from tty_init to tty::init_session. - (do_exit): Reflect moving of tty_terminate into tty_list. - * exceptions.cc (events_init): Move tty_mutex stuff elsewhere. - * fhandler_console.cc (set_console_title): Use lock_ttys class. - * fhandler_termios.cc (fhandler_termios::bg_check): Make debug output - more accurate. - * fhandler_tty.cc (fhandler_tty_slave::open): Reflect move of - attach_tty into tty_list class. Don't attempt to grab master end of - pty if master doesn't exist. - (fhandler_pty_master::open): Reflect move of allocate_tty into tty_list - class. Use lock_ttys::release to release mutex. Improve debugging - output. - (fhandler_pty_master::setup): Remove if 0'ed block. Fix argument to - SetNamedPipeHandleState. - * pinfo.cc (_pinfo::set_ctty): Lock ttys before setting sid/pgid. - Improve debugging. Add temporary debugging. - * tty.cc (tty_list::init_session): New function. - (tty::init_session): Rename from tty_init. Reflect move of attach_tty - to tty_list class. - (tty::create_master): Rename from create_tty_master. - (tty_list::attach): Rename from attach_tty. Reflect renaming of - connect_tty to connect. Ditto for allocate_tty. - (tty_terminate): Delete. - (tty_list::terminate): Subsume tty_terminate. Use lock_ttys rather - than manipulating mutex directly. - (tty_list::allocate): Rename from allocate_tty. Use lock_ttys rather - than manipulating mutex directly. Don't set sid here since linux - apparently doesn't do this. Reflect move of create_tty_master into - tty. - (lock_ttys::lock_ttys): Define new constructor. - (lock_ttys::release): New function. - * tty.h (tty::exists): Return false immediately if !master_pid. - (tty::set_master_closed): Define new function. - (tty::create_master): Ditto. - (tty::init_session): Ditto. - (tty_list::mutex): New field. - (tty_list::allocate): Define new function. - (tty_list::connect): Ditto. - (tty_list::attach): Ditto. - (tty_list::init_session): Ditto. - (lock_ttys): New class. - (tty_init): Delete declaration. - (tty_terminate): Ditto. - (attach_tty): Ditto. - (create_tty_master): Ditto. - -2006-06-03 Christopher Faylor - - * Makefile.in (libdl.a): New library. - -2006-06-03 Christopher Faylor - - * fhandler_tty.cc (fhandler_pty_master::close): Don't close handles if - we don't own them. - (fhandler_pty_master::setup): Make sure that original handle is closed - when changing inheritance. - (fhandler_pty_master::fixup_after_fork): Set from_master/to_master to - arch value always. - (fhandler_pty_master::fixup_after_exec): Clear from_master/to_master - when close_on_exec. - -2006-06-03 Christopher Faylor - - * cygheap.cc (init_cygheap::close_ctty): Remove obsolete code. - * dcrt0.cc (child_info_spawn::handle_spawn): Signal ready after we've - run fixup_after_exec. - * dtable.cc (dtable::fixup_after_exec): Add debugging output. - * fhandler_tty.cc (fhandler_pty_master::doecho): Use class version of - to_master. - (fhandler_tty_common::close): Remove obsolete code. - (fhandler_tty_slave::fixup_after_exec): Don't close, since this is done - in dtable's fixup_after_exec. (revisit later?) - (fhandler_pty_master::fixup_after_exec): Ditto. - -2006-06-02 Christopher Faylor - - * cygtls.h (CYGTLS_PADSIZE): Bump up or suffer a regrettable collision - with the call chain. - * tlsoffsets.h: Regenerate. - - * dcrt0.cc (break_here): Define unconditionally for use elsewhere. - Call DebugBreak, if appropriate. - (initial_env): Rely on break_here() to call DebugBreak. - * exceptions.cc (try_to_debug): Ditto. - -2006-06-02 Christopher Faylor - - * fhandler.cc (fhandler_base::fixup_after_exec): Declare here. - * fhandler.h (fhandler_base::fixup_after_exec): Make non-inline. - (fhandler_termios::fixup_after_fork): Delete declaration. - (fhandler_termios::fixup_after_exec): Ditto. - (fhandler_tty_common::inuse): Remove. - (fhandler_tty_common::dup): Delete declaration. - (fhandler_tty_common::fixup_after_fork): Ditto. - (fhandler_tty_slave::fixup_after_exec): Declare new function. - (fhandler_pty_master::dwProcessId): New variable. - (fhandler_pty_master::from_master): Ditto. - (fhandler_pty_master::to_master): Ditto. - (fhandler_pty_master::setup): New function. - (fhandler_pty_master::fixup_after_fork): Ditto. - (fhandler_pty_master::fixup_after_exec): Ditto. - * fhandler_termios.cc (fhandler_termios::fixup_after_exec): Delete - definition. - (fhandler_termios::fixup_after_fork): Ditto. - * fhandler_tty.cc (fhandler_tty_master::init): Use fhandler_pty_master - setup function rather than obsolete tty::common_init. Delete obsolete - inuse setting. - (fhandler_tty_slave::fhandler_tty_slave): Set inuse to NULL here. - (fhandler_tty_slave::open): Change debugging output for clarity. Check - for different things when doing a sanity check on the tty. Reflect the - fact that master_pid now is the cygwin pid rather than the windows pid. - Use "arch" rather than "archetype" for consistency. - (fhandler_tty_slave::close): Close inuse here. - (fhandler_tty_slave::dup): Remove old if 0'ed code. - (fhandler_pty_master::dup): New function. Handles pty master - archetype. - (fhandler_pty_master::fhandler_pty_master): Zero pty_master specific - fields. - (fhandler_pty_master::open): Implement using archetypes, similar to - slave. Use fhandler_pty_master setup function rather than obsolete - tty::common_init. Don't set inuse. - (fhandler_tty_common::close): Don't deal with inuse. Delete old if - 0'ed code. - (fhandler_pty_master::close): Implement using archetypes. Close - from_master and to_master. - (fhandler_tty_common::set_close_on_exec): Just set close_on_exec flag - here since everything uses archetypes now. - (fhandler_tty_common::fixup_after_fork): Delete definition. - (fhandler_tty_slave::fixup_after_exec): Define new function. - (fhandler_pty_master::setup): New function, derived from - tty::common_init. - (fhandler_pty_master::fixup_after_fork): New function. - (shared_info.h): Reset SHARED_INFO_CB to reflect new tty size. - * tty.cc (tty_list::terminate): Close individual handles from - tty_master. - (tty::master_alive): Delete. - (tty::make_pipes): Ditto. - (tty::common_init): Ditto. - * tty.h (tty::from_slave): Delete. - (tty::to_slave): Ditto. - (tty::common_init): Delete declaration. - (tty::make_pipes): Ditto. - (tty::master_pid): Define as pid_t since it is now a cygwin pid. - -2006-06-01 Christopher Faylor - - * cygheap.cc (cygheap_fixup_in_child): Don't close parent handle here. - Let the caller do that. - * dcrt0.cc (child_info_spawn::handle_spawn): Close parent handle here - to allow fixup_after_exec functions to use it. - - * cygtls.cc (_cygtls::call2): Avoid calling exit thread if called with - *crt0_1 functions. - * cygtls.h (_cygtls::isinitialized): Check that we actually have a tls - before seeing if it is initialized. - * gendef (_sigfe_maybe): Ditto. - * dcrt0.cc (dll_crt0_1): Remove static, use just one argument. - * dll_init.cc (dllcrt0_info): New structure. - (dll_dllcrt0): Change into a front-end to renamed dll_dllcrt0_1 so that - we'll always be assured of having something like a tls. - (dll_dllcrt0_1): New function, basically renamed from from dll_dllcrt0. - Unconditionally call _my_tls.init_exception_handler now that we are - assured of having a tls. Change variable name from "linking" to "linked". - * winsup.h (dll_crt0_1): Declare. - (dll_dllcrt0_1): Ditto. - -2006-05-30 Christopher Faylor - - * cygtls.cc (_cygtls::call2): Don't call ExitThread on the main thread. - -2006-05-29 Christopher Faylor - - * winf.h (MAXCYGWINCMDLEN): Set down size to 30000 or suffer fork - errors. - -2006-05-28 Christopher Faylor - - * sigproc.cc (child_info::proc_retry): Mask all of the bits we're - interested in, which includes bits above and below 0xc0000000. - -2006-05-27 Christopher Faylor - - * dll_init.cc (dll_dllcrt0): Previous change didn't work very well with - fork. Semi-revert it but change name of variable to something that - makes better sense. - -2006-05-27 Christopher Faylor - - * thread.cc (verifyable_object_isvalid): Check for NULL specifically. - -2006-05-27 Christopher Faylor - - * dll_init.cc (dll_dllcrt0): Call _my_tls.init_exception_handler if - we've finished initializing (Thanks to Gary Zablackis for noticing this - problem). Just use cygwin_finished_initializing rather than defining a - separate variable. - -2006-05-25 Christopher Faylor - - * debug.h (ModifyHandle): Define new macro. - (modify_handle): Declare new function. - * debug.cc (modify_handle): Define new function. - * fhandler.h (fhandler_base::fork_fixup): Change return value from void - to bool. - * fhandler.cc (fhandler_base::fork_fixup): Return true if fork fixup has - been done. - * pipe.cc (fhandler_pipe::set_close_on_exec): Set inheritance of - protected handle via ModifyHandle if DEBUGGING. - (fhandler_pipe::fixup_after_fork): Protect guard handle if fork fixup - has been done. - -2006-05-24 Christopher Faylor - - * cygtls.cc (_cygtls::call): Call call2 using _my_tls. - (_cygtls::init_exception_handler): Always replace existing exception - handler with cygwin exception handler. - * cygtls.h (_cygtls::call2): Remove static designation. - * dcrto.cc (dll_crt0_1): Define in a way that allows calling via - _cygtls::call. - (_initialize_main_tls): Delete. - (_dll_crt0): Call dll_crt0_1 via cygtls::call. Set _main_tls here. - * external.cc (cygwin_internal): Implement CW_CYGTLS_PADSIZE. - * include/sys/cygwin.h (CW_CYGTLS_PADSIZE): Define. - * tlsoffsets.h: Regenerate. - -2006-05-24 Christopher Faylor - - * configure.in: Update to newer autoconf. - (thanks to Steve Ellcey) - * configure: Regenerate. - * aclocal.m4: New file. - -2006-05-23 Lev Bishop - - * fhandler.cc (readv): Remove nonsensical assert. - -2006-05-23 Christopher Faylor - - * select.cc (start_thread_socket): Delay setting thread local exitsock - until we know it's correct. Return correct value on error. - -2006-05-23 Lev Bishop - Christopher Faylor - - * select.cc (start_thread_socket): Clean up exitsock in case of error. - Use si->exitcode consistently. - -2006-05-21 Christopher Faylor - - * child_info.h (_CI_SAW_CTRL_C): New enum. - (CURR_CHILD_INFO_MAGIC): Reset. - (saw_ctrl_c): New function. - (set_saw_ctrl_c): Ditto. - * sigproc.cc (child_info::proc_retry): Return EXITCODE_OK if we get - STATUS_CONTROL_C_EXIT and we actually saw a CTRL-C. - * spawn.cc (dwExeced): Delete. - (chExeced): New variable. - (spawn_guts): Set chExeced; - * exceptions.cc (dwExeced): Delete declaration. - (chExeced): Declare. - (ctrl_c_handler): Detect if we're an exec stub process and set a flag, - if so. - - * fhandler_tty.cc (fhandler_tty_common::__release_output_mutex): Add - extra DEBUGGING test. - - * pinfo.cc: Fix comment. - -2006-05-21 Christopher Faylor - - * fhandle.h (fhandler_pipe::create_guard): Revert change which - eliminated SECURITY_ATTRIBUTES argument. - * pipe.cc (fhandler_pipe::open): Duplicate guard from other process and - protect it appropriately. Eliminate unneeded writepipe_exists - temporary variable. Set inheritance appropriately. - (fhandler_pipe::set_close_on_exec): Revert change which eliminated - handling guard inheritance. - (fhandler_pipe::fixup_after_fork): Ditto. Use correct name of entity - being checked by fork_fixup. - (fhandler_pipe::fixup_after_exec): Don't bother with guard here. - (fhandler_pipe::dup): Cosmetic changes and revert creation of - writepipe_exists as noninheritable. - (fhandler_pipe::create): Revert change which eliminated - SECURITY_ATTRIBUTES argument. Revert change which always made - writepipe_exists noninheritable. - -2006-05-21 Christopher Faylor - - * debug.cc (add_handle): Print handle value when collision detected. - * dtable.cc (dtable::stdio_init): Cosmetic change. - * fhandler.h (fhandler_base::create_read_state): Protect handle. - (fhandler_pipe::create_guard): Ditto. Always mark the handle as - inheritable. - (fhandler_pipe::is_slow): Return boolean value rather than numeric 1. - * pipe.cc (fhandler_pipe::fhandler_pipe): Always flag that we need fork - fixup. - (fhandler_pipe::open): Don't pass security attributes to create_guard. - (fhandler_pipe::set_close_on_exec): Don't handle guard here. - (fhandler_pipe::close): Accommodate now-protected guard handle. - (fhandler_pipe::fixup_in_child): Don't protect read_state here. - (fhandler_pipe::fixup_after_exec): Close guard handle if close_on_exec. - (fhandler_pipe::fixup_after_fork): Don't bother with guard here. - (fhandler_pipe::dup): Don't set res to non-error prematurely. Use - boolean values where appropriate. Protect guard and read_state. - (fhandler_pipe::create): Don't call need_fork_fixup since it is now the - default. Don't protect read_state or guard. - - * pipe.cc (fhandler_base::ready_for_read): Use bool values for "avail". - - * spawn.cc (spawn_guts): Set cygheap->pid_handle as inheritable when - protecting. - -2006-05-15 Lev Bishop - Christopher Faylor - - * select.cc (fhandler_pipe::ready_for_read): Actually get the guard - mutex for blocking reads. - -2006-05-20 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty::close): Remove problematic hExeced guard. - -2006-05-20 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_slave::open): Reinstate call to - need_invisible on first pty open. - -2006-05-18 Christopher Faylor - - * fhandler_console.cc (fhandler_console::need_invisible): Allocate an - invisible window station when ctty != TTY_CONSOLE. - -2006-05-16 Christopher Faylor - - * cygtls.cc (_cygtls::remove): Don't test for initialization since - this function will always be called when _my_tls is initialized. - * init.cc (dll_entry): Don't attempt to remove tls info if _my_tls is - obviously not even available. - -2006-05-15 Christopher Faylor - - * sigproc.cc (no_signals_available): Detect hwait_sig == - INVALID_HANDLE_VALUE. - (wait_sig): Set hwait_sig to INVALID_HANDLE_VALUE on __SIGEXIT. - -2006-05-15 Christopher Faylor - - * cygtls.cc (_cygtls::init_thread): Zero entire _my_tls structure and - no more. - * cygtls.h (_my_tls::padding): Delete. - (CYGTLS_PADSIZE): Redefine concept of padding to mean padding at the - end of the stack. - * dcrt0.cc (initialize_main_tls): Change return to void. - * gentls_offsets: Treat const specially, too. Keep going after a '}' - is found. Change negative offset calculation to use CYGTLS_PADSIZE. - * init.cc (_my_oldfunc): New variable. - (threadfunc_fe): Use stored tls value for oldfunc rather than blindly - writing to the stack. - (munge_threadfunc): Set oldfunc in tls. - (dll_entry): Initialize tls allocation. - * tlsoffsets.h: Regenerate. - -2006-05-13 Christopher Faylor - - * ntdll.h (STATUS_INVALID_INFO_CLASS): Conditionalize. - -2006-05-10 Brian Dessent - - * Makefile.in (clean): Also delete *.dbg. - -2006-05-08 Christian Franke - - * fhandler_disk_file.cc (fhandler_disk_file::readdir): Fix typo which - caused test for ".." to be skipped. - -2006-05-02 Christopher Faylor - - * external.cc (cygwin_internal): Set errno on failure. - -2006-04-27 Corinna Vinschen - - * pipe.cc (DEFAULT_PIPEBUFSIZE): Raise to 64K. - -2006-04-26 Corinna Vinschen - - * fhandler.h (fhandler_base): Change fstat_helper prototype - to take file size and inode number as 64 bit values. - * fhandler_disk_file.cc (FS_IS_SAMBA): Move to path.cc - (FS_IS_SAMBA_WITH_QUOTA): Ditto. - (path_conv::hasgood_inode): Delete. - (path_conv::is_samba): Delete. - (path_conv::isgood_inode): Centralized function to recognize - a good inode number. - (fhandler_base::fstat_by_handle): Constify fvi_size and fai_size. - Accommodate argument change in fstat_helper. - (fhandler_base::fstat_by_name): Ditto. - (fhandler_base::fstat_helper): Accommodate argument change. Call - path_conv::isgood_inode to recognize good inodes. - (fhandler_disk_file::opendir): Explain Samba weirdness here. - Call path_conv::fs_is_samba instead of path_conv::is_samba. - (fhandler_disk_file::readdir): Add STATUS_INVALID_INFO_CLASS - as valid return code from NtQueryDirectoryFile to indicate that - FileIdBothDirectoryInformation is not supported. - Call path_conv::isgood_inode to recognize good inodes. - * ntdll.h (STATUS_INVALID_INFO_CLASS): Define. - * path.cc (fs_info::update): Rework file system recognition - and set appropriate flags. - * path.h (struct fs_info): Add is_ntfs, is_samba and is_nfs flags. - Constify pure read accessors. - -2006-04-24 Christopher Faylor - - * environ.cc (getearly): Force correct dereference order when - inspecting environ table. - -2006-04-24 Corinna Vinschen - - * select.cc (thread_pipe): Raise sleep time only every 8th iteration. - (thread_mailslot): Ditto. - -2006-04-23 Corinna Vinschen - Christopher Faylor - - * select.cc (thread_pipe): Raise sleep time dynamically to speed up - select on pipes when copying lots of data. - (thread_mailslot): Ditto for mailslots. - -2006-04-22 Christopher Faylor - - * signal.cc (abort): On second thought, just set incyg once. - -2006-04-22 Christopher Faylor - - * signal.cc (abort): Set incyg manually to help get a reliable gdb - stack trace. - * cygwin.din (abort): Make NOSIGFE. - -2006-04-21 Pierre Humblet Pierre.Humblet@ieee.org - Christopher Faylor - - * environ.cc (getearly): Use GetEnvironmentVariable and cmalloc instead - of GetEnvironmentStrings. - (environ_init): Revert rawenv stuff. - -2006-04-21 Christopher Faylor - - * environ.cc (rawenv): Make this variable a file-scope static. - (getearly): Rename 's' variable to 'len' since 's' is used fairly - consistently throughout cygwin as a string variable. Remove rawenv - declaration. Perform other minor cleanups. - (environ_init): Remove rawenv declaration. Only set rawenv to - GetEnvironmentStrings() if it has not already been set. Properly free - rawenv in all cases. - -2006-04-21 Christopher Faylor - - * tty.h (tty::hwnd): Move to tty_min. - (tty::gethwnd): Ditto. - (tty::sethwnd): Ditto. - (tty_min::hwnd): Receive variable from tty class. - (tty_min::gethwnd): Receive function from tty classs. - (tty_min::sethwnd): Ditto. - * dtable.cc (dtable::stdio_init): Only call init_console_handler when - we actually own the console. - * fhandler_console.cc (fhandler_console::get_tty_stuff): Set tty's hwnd - to non-zero value. - * fhandler_termios.cc (fhandler_termios::tcsetpgrp): Semi-reinstate - handling of console when pgrp is set. - -2006-04-21 Pierre Humblet - Corinna Vinschen - - * environ.cc (getearly): New function. - (findenv_func): New function pointer, predefined to getearly. - (getenv): Call findenv function over the findenv_func pointer. - (environ_init): Change findenv_func pointer to my_findenv after Cygwin - environment is initialized. - -2006-04-21 Lars Munch - - * include/asm/byteorder.h (__ntohl): Fix the missing uint32_t. - -2006-04-21 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::wait): Reorder setting - WSAError to avoid spurious errors with WSAError set to 0. - -2006-04-21 Corinna Vinschen - - * include/asm/byteorder.h: Include stdint.h. Per standard, change - datatypes in ntohX and htonX functions to uintXX_t types. - -2006-04-18 Christopher Faylor - - * exceptions.cc (ctrl_c_handler): Only exit TRUE on CTRL_LOGOFF_EVENT - when we have actually handled the event. - -2006-04-17 Eric Blake - - * mktemp.cc (_gettemp): Open temp files in binary mode. - -2006-04-14 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::readdir): Use UINT32_MAX - instead of UINT_MAX. - -2006-04-14 Corinna Vinschen - - * fhandler_disk_file.cc (path_conv::hasgood_inode): Make inline. - Drop remote fs handling entirely since unreliable inode numbers - are now recognized differently. - (path_conv::is_samba): Make inline. - (fhandler_disk_file::opendir): Reformat comment. - (fhandler_base::fstat_helper): Special case remote file systems - returning (unreliable) 32 bit inode numbers. - (fhandler_disk_file::readdir): Ditto. - * fhandler_netdrive.cc (fhandler_netdrive::readdir): Ditto. - -2006-04-13 Christopher Faylor - - * spawn.cc (spawn_guts): Move ch.set() call back to where it was - supposed to be. - -2006-04-13 Corinna Vinschen - - * sysconf.cc (sysconf): Add _SC_THREADS, _SC_THREAD_ATTR_STACKSIZE, - _SC_THREAD_PRIORITY_SCHEDULING, _SC_THREAD_PROCESS_SHARED, - _SC_THREAD_SAFE_FUNCTIONS, _SC_TIMERS handling. - -2006-04-12 Corinna Vinschen - Christopher Faylor - - * spawn.cc (spawn_guts): Revert patch which treated derived cygwin - programs differently from those which are mounted with -X. Pass extra - argument to linebuf::fromargv. - * winf.h (MAXCYGWINCMDLEN): New define. - (linebuf::finish): Add a new argument denoting when command line - overflow is ok. - (linebuf::fromargv): Ditto. - * winf.cc (linebuf::finish): Implement above change. - (linebuf::fromargv): Ditto. - -2006-04-11 Christopher Faylor - - * Makefile.in (DLL_OFILES): Add winf.o. - * spawn.cc: Move command line handling stuff into winf.cc. - * winf.h: New file. - * winf.cc: New file. - -2006-04-05 Christopher Faylor - - * fhandler_socket.cc: Move iptypes.h include after winsock2 since it - now relies on it. - * net.cc: Ditto. - -2006-04-05 Christopher Faylor - - * dcrt0.cc (dll_crt0_0): Move user_data->{resourcelocks,threadinterface} - initialization here from dll_crt0_1. - (dll_crt0_1): See above. - -2006-04-04 Corinna Vinschen - - * net.cc (fdsock): Raise default SO_RCVBUF/SO_SNDBUF buffer sizes to - the same values as on Linux. - -2006-04-03 Christopher Faylor - - * child_info.h (CURR_CHILD_INFO_MAGIC): Update. - (child_info_fork::alloc_stack): Move into this class. - (child_info_fork::alloc_stack_hard_way): Ditto. - * dcrt0.cc (child_info_fork::alloc_stack): Ditto. - (child_info_fork::alloc_stack_hard_way): Ditto. - (_dll_crt0): Reference alloc_stack via fork_info. - -2006-04-03 Corinna Vinschen - - * spawn.cc (linebuf::finish): Drop argument. Don't check command line - length. - (spawn_guts): Remove wascygexec. Check real_path.iscygexec instead. - Accommodate change to linebuf::finish. - -2006-04-03 Christopher Faylor - - * dcrt0.cc (sm): Delete. - (alloc_stack_hard_way): Figure out where the stack lives here rather - than relying on previously filled out information which has been - invalid since 1.5.19. - -2006-03-31 Corinna Vinschen - - * fhandler_disk_file.cc (FS_IS_SAMBA_WITH_QUOTA): New define. - (path_conv::hasgood_inode): Recognize Samba with quota support - compiled in. - (path_conv::is_samba): Ditto. Fix comment to include Samba version - numbers for later reference. - -2006-03-30 Corinna Vinschen - - * security.h (sec_user_nih): Make sid1 argument mandatory. - (sec_user): Ditto. - -2006-03-29 Christopher Faylor - - * sigproc.cc (wait_for_sigthread): Use the current user sid when - setting up the signal pipe rather than relying on (eventually) the - effective sid. - -2006-03-29 Christopher Faylor - - * dcrt0.cc (child_info_fork::handle_fork): Set uid/gid in myself so - that it can be used by subsequent startup functions. - (dll_crt0_0): Issue a warning if DuplicateTokenEx fails and DEBUGGING. - (dll_crt0_1): Move user_data->{resourcelocks,threadinterface} - initialization here from dll_crt0_0. - * fork.cc (frok::child): Tell wait_for_sigthread that this is fork. - (frok::parent): Only initialize start_time once. Tighten time when - we're "deimpersonated". - * sigproc.cc (signal_fixup_after_exec): Rework (futiley) sa_buf stuff. - Add debugging output. - (wait_for_sigthread): Accept an argument which illustrates whether we - are forked or not. - (wait_sig): Avoid using myself pointer. - * winsup.h ((wait_for_sigthread): Reflect change to argument. - -2006-03-26 Christopher Faylor - - * spawn.cc (spawn_guts): Close handles if we know that we will not be - seeing a sync event from the child. - -2006-03-26 Christopher Faylor - - * sigproc.cc (wait_sig): Move myself manipulation... - (wait_for_sigthread): ...to here. - -2006-03-24 Corinna Vinschen - - * fhandler_floppy.cc: Include ntdef.h and ntdll.h. - (fhandler_dev_floppy::get_drive_info): Rearrange so that now - NtQueryVolumeInformationFile is called on drives which don't support - IOCTL_DISK_GET_DRIVE_GEOMETRY. - * ntdll.h (struct _FILE_FS_SIZE_INFORMATION): Add. - (enum _FSINFOCLASS): Add missing values. - -2006-03-23 Christopher Faylor - - * fhandler_console.cc (fhandler_console::fixup_after_fork_exec): Make - error message more explicit. - * pinfo.cc (_pinfo::commune_request): Don't lock process unless we're - looking for fifos. - -2006-03-23 Christopher Faylor - - * dcrt0.cc (child_info_spawn::handle_spawn): Don't initialize the - console handler here. - * dtable.cc (dtable::stdio_init): Initialize console handler here. - -2006-03-23 Christopher Faylor - - * sigproc.cc (sigalloc): Don't set SA_RESTART here. - * signal.cc (_SA_NORESTART): New flag. - (sigaction_worker): New function, derived from sigaction. Don't set - internal flags unless called internally. - (sigaction): Use sigaction_worker. - (signal): Honor new _SA_NORESTART flag. - (siginterrupt): Set _SA_NORESTART flag appropriately. Use - sigaction_worker to set flags. - * include/cygwin/signal.h: Define _SA_INTERNAL_MASK here. - -2006-03-22 Corinna Vinschen - - * thread.cc (pthread_mutex::is_good_initializer_or_bad_object): Delete. - (pthread_cond::is_good_initializer_or_bad_object): Delete. - (pthread_rwlock::is_good_initializer_or_bad_object): Delete. - (pthread_cond::init): Remove disabled code. Guard assignment to - object to initialize against access violation. - (pthread_rwlock::init): Ditto. - (pthread_mutex::init): Ditto. - -2006-03-22 Eric Blake - - * fhandler.cc (fcntl): Print flags in hex. - -2006-03-22 Christopher Faylor - - * dcrt0.cc (dll_crt0_0): Semi-revert 2006-03-14 change which moved - pinfo_init and uinfo_init here. - (dll_crt0_1): Ditto. - (__dll_crt0): Ditto. Don't call update_envptrs here. - (dll_crt0_1): Ditto. Move wait_for_sigthread call here from dll_crt0_0. - * environ.cc (environ_init): Call it here instead. - * sigproc.cc (my_readsig): New static variable. - (wait_for_sigthread): Set up read pipe here since we are assured that - we have the proper privileges when this is called. - (talktome): Eliminate second argument since it is available as a global - now. - (wait_sig): Reflect use of my_readsig. - -2006-03-22 Corinna Vinschen - - * thread.cc (pthread_cond::init): Disable validity test of object - to initialize since test of uninitialized content is unreliable. - (pthread_rwlock::init): Ditto. - (pthread_mutex::init): Ditto. - -2006-03-21 Christopher Faylor - - * signal.cc (signal): Don't set SA_RESTART here. - (siginterrupt): White space. - * sigproc.cc (sigalloc): Set SA_RESTART here, on initialization. - -2006-03-21 Christopher Faylor - - * child_info.h (child_status): Fix typo which made it impossible to set - iscygwin. - (child_info::isstraced): Booleanize. - (child_info::iscygwin): Ditto. - * sigproc.cc (child_info::child_info): Minor cleanup of flag setting. - * spawn.cc (spawn_guts): Only close_all_files when we know the process - has started successfully. - - * exceptions.cc (init_console_handler): Fix indentation. - -2006-03-20 Christopher Faylor - - * dcrt0.cc (dll_crt0_0): Call SetErrorMode earlier. - * pinfo.cc (_pinfo::dup_proc_pipe): Reset wr_proc_pipe on failure. - Return previous pipe handle. - * pinfo.h (_pinfo::dup_proc_pipe): Reflect change to return value. - * spawn.cc (spawn_guts): Restore previous proc pipe on retry or if - process exits before synchronization. - -2006-03-20 Christopher Faylor - - * child_info.h (child_status): New enum. - (child_info::flag): Rename from 'straced'. - (child_info::isstraced): New function. - (child_info::iscygwin): Ditto. - (child_info_fork::handle_fork): Reparmize. - (child_info_fork::handle_failure): Ditto. - (child_info_spawn::handle_spawn): New function. - * dcrt0.cc (get_cygwin_startup_info): Use isstraced method. - (child_info_spawn::handle_spawn): Define new function from code - previously in dll_crt0_0. - (dll_crt0_0): Move spawn stuff into handle_spawn. Only call - init_console_handler for fork case. - * sigproc.cc (child_info::child_info): Set flag appropriately. - (child_info::proc_retry): Treat exit code as "funny" if it's a cygwin - process. - * spawn.cc (spawn_guts): Remove commented out flag setting. - -2006-03-19 Christopher Faylor - - * pinfo.cc (commune_process): Fix randomly invalid pointer which caused - fifos to work incorrectly. - -2006-03-19 Christopher Faylor - - * dcrt0.cc (dll_crt0_0): Oops. We need to bother with setting - init_console_handler in the fork/exec case. - -2006-03-19 Christopher Faylor - - * dcrt0.cc (dll_crt0_0): Don't bother with setting init_console_handler - here since it will be set later when we discover if we have a ctty or - not. - * exceptions.cc (init_console_handler): Properly remove NULL handler. - -2006-03-18 Christopher Faylor - - * pinfo.h (EXITCODE_OK): Define new constant. - * sigproc.cc (child_info::sync): Return EXITCODE_OK if entering with - exit_code == 0. - (sig_send): Don't complain if sending signals while blocked if the - sender isn't in the main thread. - -2006-03-18 Christopher Faylor - - * child_info.h (CURR_CHILD_INFO_MAGIC): Regenerate. - (child_info::retry): Move here from fork subclass. - (child_info::exit_code): New field. - (child_info::retry_count): Max retry count for process start. - (child_info::proc_retry): Declare new function. - (child_info_fork::retry): Move to parent. - (child_info_fork::fork_retry): Ditto. - * dcrt0.cc (child_info::fork_retry): Rename and move. - (child_info_fork::handle_failure): Move. - (dll_crt0_0): Initialize console handler based on whether we have a - controlling tty or not. Avoid nonsensical check for fork where it can - never occur. - * environ.cc (set_proc_retry): Rename from set_fork_retry. Set - retry_count in child_info. - (parse_thing): Reflect above change. - * exceptions.cc (dummy_ctrl_c_handler): Remove unused variable name. - (ctrl_c_handler): Always return TRUE for the annoying - CTRL_LOGOFF_EVENT. - * fhandler_termios.cc (fhandler_termios::tcsetpgrp): Remove call to - init_console_handler. - * fhandler_tty.cc (fhandler_tty_slave::open): Just call - mange_console_count here and let it decide what to do with initializing - console control handling. - * fork.cc (fork_retry): Remove definition. - (frok::parent): Define static errbuf and use in error messages (not - thread safe yet). Close pi.hThread as soon as possible. Protect - pi.hProcess as soon as possible. Don't set retry_count. That happens - automatically in the constructor now. Accommodate name change from - fork_retry to proc_retry. - * init.cc (dll_entry): Turn off ctrl-c handling early until we know how - it is supposed to be handled. - * pinfo.cc (_pinfo::dup_proc_pipe): Remember original proc pipe value - for failure error message. Tweak debug message slightly. - * sigproc.cc (child_info::retry_count): Define. - (child_info::child_info): Initialize retry count. - (child_info::sync): Set exit code if process dies before - synchronization. - (child_info::proc_retry): Rename from child_info_fork::fork_retry. Use - previously derived exit code. Be more defensive about what is - classified as an error exit. - (child_info_fork::handle_failure): Move here from dcrt0.cc. - * spawn.cc (spawn_guts): Maintain error mode when starting new process - to avoid annoying pop ups. Move deimpersonate call within new loop. - Move envblock freeing to end. Loop if process dies prematurely with - bad exit code. - * syscalls.cc (setpgid): Remove hopefully unneeded call to - init_console_handler. - -2006-03-15 Christopher Faylor - - * cygheap.cc (init_cygheap::manage_console_count): Turn console control - handler on/off depending on whether we have allocated a console or not. - * dcrt0.cc (child_info_fork::fork_retry): Add more potential retry - statuses. - (dll_crt0_0): Turn on/off console control depending on whether we have - a controlling tty or not. - * exceptions.cc (init_console_handler): Change BOOL to bool. - * fhandler_console.cc (fhandler_console::need_invisible): Cosmetic - change. - * winsup.h (init_console_handler): Reflect argument type change. - - * wincap.h (supports_setconsolectrlhandler_null): Remove duplicate - capability throughout. - * wincap.cc: Ditto. - -2006-03-14 Christopher Faylor - - * child_info.h (child_info_fork::fork_retry): Declare new function. - * dcrt0.cc (child_info_fork::fork_retry): Define new function. - * fork.cc (frok::parent): Move retry decision into - child_info_fork::fork_retry and honor what it tells us to do. - * sigproc.cc (sig_send): Unhold signals on __SIGEXIT. - -2006-03-14 Christopher Faylor - - * fork.cc (frok::parent): Improve error message. - -2006-03-14 Christopher Faylor - - * dcrt0.cc (main_environ): Initialize to &__cygwin_environment. - (dll_crt0_1): Move resourcelocks, thread interface, pinfo_init, and - uinfo_init... - (dll_crt0_0): ...to here. - (_dll_crt0): Call update_envptrs here after setting main_environ. - * environ.cc (environ_init): Eliminate initted variable. Don't call - update_envptrs here. - * sigproc.cc (wait_sig): Use my_sendsig when calling CreatePipe to - avoid a dereference. - -2006-03-13 Christopher Faylor - - * child_info.h (child_info_fork::handle_failure): Declare new function. - (child_info_fork::retry): New field. - * dcrt0.cc (__api_fatal_exit_val): Define. - (child_info_fork::handle_failure): Define new function. - (__api_fatal): Exit using __api_fatal_exit_val value. - * environ.cc (set_fork_retry): Set fork_retry based on CYGWIN - environment variable. - (parse_thing): Add "fork_retry" setting. - * fork.cc (fork_retry): Define. - (frok::parent): Reorganize to allow retry of failed child creation if - child signalled that it was ok to do so. - * heap.cc (heap_init): Signal parent via handle_failure when - VirtualAlloc fails. - * pinfo.h (EXITCODE_RETRY): Declare. - * sigproc.cc (child_info::sync): Properly exit with failure condition - if called for fork and didn't see subproc_ready. - * spawn.cc (spawn_guts): Use windows pid as first argument. - * winsup.h: Remove obsolete NEW_MACRO_VARARGS define. - (__api_fatal_exit_val): Declare. - (set_api_fatal_return): Define. - (in_dllentry): Declare. - * exceptions.cc (inside_kernel): Remove unneeded in_dllentry - declaration. - -2006-03-13 Christopher Faylor - - * dcrt0.cc (dll_crt0_0): Reorganize so that sigproc_init is called a - little later. Add a comment. - * fork.cc (resume_child): Make void. - (frok::parent): Only zero pi when necessary. Explicitly zero si. Set - this_errno when child_copy fails. Accommodate change to resume_child. - * sigproc.cc (sigalloc): Move global_sigs initialization here. - (sigproc_init): Move global_sigs. - (sig_send): Just check for flush signals once. - - * wincap.h: Define supports_setconsolectrlhandler_null throughout. - * wincap.cc: Ditto. - -2006-03-13 Corinna Vinschen - - * autoload.cc (LoadDLLfuncNt): New define to wrap NT native functions. - Use for NT native functions throughout. - * dtable.cc (handle_to_fn): Treat return value of NtQueryObject as - NTSTATUS value. - -2006-03-12 Christopher Faylor - - * cygtls.cc (_cygtls::remove): Reset initialized flag right away if we - were previously initialized. - * cygtls.h (_cygtls::initialized): Move nearer to the end to catch - situation when Windows 98 mysteriously changes parts of _my_tls when - thread is detaching. - * gendef (__sigfe_maybe): Simplify slightly. - * tlsoffsets.h: Regenerate. - -2006-03-12 Christopher Faylor - - * cygtls.h (CYGTLS_INITIALIZED): Change to a little more unlikely value. - (CYGTLSMAGIC): Delete. - * dcrt0.cc (dll_crt0_0): Call sigproc_init during init startup. - (_dll_crt0): Don't worry about sync_startup. Just wait for sigthread here. - * dll_init.cc (cygwin_detach_dll): Only pick up tls version of retaddr - if we have a valid tls. - * fork.cc (frok::child): Remove sigproc_init initialization since it - happens much earlier now. - * gendef: Recognize SIGFE_MAYBE. - (fefunc): Generate calls to _sigfe_maybe, if appropriate. - (_sigfe_maybe): New function. - * init.cc (search_for): Always initialize search_for, even on fork. - (calibration_thread): Delete. - (calibration_id): Delete. - (prime_threads): Delete. - (munge_threadfunc): Remove calibration_thread special case. Avoid - calling thread function if we haven't yet hit the "search_for" thread. - (dll_entry): Remove prime_threads call. Only call munge_threadfunc - when hwait_sig is active. Ditto. for _my_tls.remove (); - * sigproc.cc (hwait_sig): Make global. - (sigproc_init): Don't bother with sync_startup. - (sig_send): Treat flush as a no-op when signals are held. - (wait_sig): Cause signals to be held after fork. - -2006-03-09 Corinna Vinschen - - * syscalls.cc (rename): Move existance check for oldpath further up - to the start of the function. Avoid another case of a name collision - if oldpath is a shortcut and a file or directory newpath already exists. - -2006-03-09 Corinna Vinschen - - * autoload.cc (NtClose): Define. - (NtOpenDirectoryObject): Define. - (NtQueryDirectoryObject): Define. - * fhandler_proc.cc: Include ctype.h and wchar.h. - (format_proc_partitions): Revamp loop over existing harddisks by - scanning the NT native \Device object directory and looking for - Harddisk entries. - * ntdll.h: Rearrange system call declarations alphabetically. - (DIRECTORY_QUERY): Define. - (struct _DIRECTORY_BASIC_INFORMATION): Define. - (NtOpenDirectoryObject): Declare. - (NtQueryDirectoryObject): Declare. - -2006-03-08 Christopher Faylor - - * cygtls.h (_cygtls::retaddr): New method. - * dll_init.cc (cygwin_detach_dll): Use new tls method to find return - address since this function is now signal guarded. - (update_envptrs): Remove unneeded braces. - * syscalls.cc (statvfs): Coerce full_path to avoid a gcc warning. - -2006-03-08 Corinna Vinschen - - * syscalls.cc (statvfs): Simplify path name expression. - -2006-03-08 Corinna Vinschen - - * syscalls.cc: Include winioctl.h. - (statvfs): Request correct volume size using DeviceIoControl if - quotas are enforced on the file system. - -2006-03-03 Corinna Vinschen - - * dir.cc (opendir): Fix indentation. - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Move storing - fhandler in file descriptor table to some point very late in function - to avoid double free'ing. Add comment to explain what happens. - Add label free_mounts and don't forget to delete __DIR_mounts structure - if NtOpenFile fails. - -2006-03-02 Corinna Vinschen - - * syscalls.cc (chroot): Disallow chroot into special directories. - Return EPERM instead. - -2006-03-02 Corinna Vinschen - - * fhandler_disk_file.cc (__DIR_mounts::check_missing_mount): Check - cygdrive string length for those who have cygdrive mapped to "/". - -2006-03-01 Corinna Vinschen - - * sec_helper.cc (set_cygwin_privileges): Request SE_BACKUP_NAME - privileges. - -2006-03-01 Corinna Vinschen - - * fhandler_proc.cc (fhandler_proc::fstat): Always return fixed link - count of 1 for /proc directory instead of incorrect PROC_LINK_COUNT. - -2006-03-01 Corinna Vinschen - - * fhandler.h (enum dirent_states): Remove dirent_saw_cygdrive, - dirent_saw_dev and dirent_saw_proc. - (fhandler_cygdrive::open): Declare. - (fhandler_cygdrive::close): Declare. - * fhandler_disk_file.cc (class __DIR_mounts): Move to beginning of file. - (__DIR_mounts::check_mount): New parameter to indicate if inode number - is needed in calling function or not. Add /proc and /cygdrive handling. - (__DIR_mounts::check_missing_mount): Ditto. - (path_conv::ndisk_links): Use __DIR_mounts class to create correct - hardlink count for directories with mount points in them. - (fhandler_disk_file::readdir_helper): Remove /dev, /proc and /cygdrive - handling. - (fhandler_cygdrive::open): New method. - (fhandler_cygdrive::close): New method. - (fhandler_cygdrive::fstat): Always return fixed inode number 2 and - fixed link count of 1. Drop call to set_drives. - (fhandler_cygdrive::opendir): Drop call to get_namehash. - (fhandler_cygdrive::readdir): Handle "." entry to return fixed inode - number 2. - -2006-03-01 Christopher Faylor - - * cygwin.din: Fix some erroneous SIGFE/NOSIGFE settings. - -2006-03-01 Christopher Faylor - - * cygthread.cc (cygthread::callfunc): Revert below change. Make ev a - manual reset event again. so that it will be reset by WaitFor*Object - as appropriate. - (cygthread::stub): Ditto. - (cygthread::terminate_thread): Reset ev if it was found to have been - set. - -2006-03-01 Christopher Faylor - - * analyze_sigfe: New script. - * dllfixdbg: Add copyright. - * gendef: Ditto. - * gendevices: Ditto. - * gentls_offsets: Ditto. - -2006-03-01 Christopher Faylor - - * cygthread.cc (cygthread::callfunc): Create ev as an auto-reset event - so that it will be reset by WaitFor*Object as appropriate. - (cygthread::stub): Ditto. - (cygthread::terminate_thread): Remove forced setting of thread - termination. - -2006-03-01 Corinna Vinschen - - * include/sys/dirent.h (struct __DIR): Rename __d_unused to - __d_internal. - * fhandler_disk_file.cc (struct __DIR_cache): Remove useless "typedef". - (d_dirname): Remove useless "struct". - (d_cachepos): Ditto. - (d_cache): Ditto. - (class __DIR_mounts): New class, implementing mount point tracking - for readdir. - (d_mounts): New macro for easy access to __DIR_mounts structure. - (fhandler_disk_file::opendir): Allocate __DIR_mounts structure and - let __d_internal element of dir point to it. - (fhandler_disk_file::readdir_helper): Add mount points in the current - directory, which don't have a real directory backing them. - Don't generate an inode number for /dev. Add comment, why. - (fhandler_disk_file::readdir): Move filling fname to an earlier point. - Check if current entry is a mount point and evaluate correct inode - number for it. - (fhandler_disk_file::readdir_9x): Ditto. - (fhandler_disk_file::rewinddir): Set all mount points in this directory - to "not found" so that they are listed again after calling rewinddir(). - (fhandler_disk_file::closedir): Deallocate __DIR_mounts structure. - * path.cc (mount_info::get_mounts_here): New method to evaluate a list - of mount points in a given parent directory. - * shared_info.h (class mount_info): Declare get_mounts_here. - -2006-02-28 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Use iscygdrive - instead of isspecial. - * path.h (path_conv::iscygdrive): New method. - -2006-02-28 Christopher Faylor - - * exceptions.cc (_cygtls::interrupt_now): Remove "inside cygwin" check - since some cygwin functions are meant to be interrupted. - -2006-02-28 Corinna Vinschen - - * cygwin.din: Export __isinff, __isinfd, __isnanf, __isnand. - * include/cygwin/version.h: Bump API minor number to 155. - -2006-02-28 Corinna Vinschen - - * dir.cc (readdir_worker): Use slash as path separator when evaluating - namehash for paths below /proc. - * fhandler_netdrive.cc (fhandler_netdrive::readdir): Use expensive - inode number evaluation on share names. - -2006-02-27 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Only set - d_cachepos under NT or suffer memory corruption. - (fhandler_disk_file::readdir_helper): Avoid else with a return. Just - calculate extension location once when doing symlink checks. - (fhandler_disk_file::readdir): Make debug output more useful. - (fhandler_disk_file::readdir_9x): Ditto. Eliminate redundant variable. - -2006-02-27 Christopher Faylor - - * include/sys/termios.h (cfsetispeed): Just define as a function rather - than resorting to a macro. - (cfsetospeed): Ditto. - -2006-02-27 Christopher Faylor - - * sigproc.cc: Fix a comment. - -2006-02-27 Christopher Faylor - - * cygthread.cc (cygthread::release): Add a comment. - -2006-02-27 Corinna Vinschen - - * fhandler_netdrive.cc (fhandler_netdrive::fstat): Create unambiguous - inode number. - (fhandler_netdrive::readdir): Ditto. - -2006-02-24 Christopher Faylor - - * sigproc.cc (sigheld): Define new variable. - (sig_dispatch_pending): Don't check sigq since that's racy. - (sig_send): Set sigheld flag if __SIGHOLD is specified, reset it if - __SIGNOHOLD is specified. Ignore flush signals if we're holding - signals. - -2006-02-23 Christopher Faylor - - * cygwin.din (_exit): Use signal front end. - (exit): Ditto. - -2006-02-23 Christopher Faylor - - * winsup.h (cygwin_hmodule): Declare. - * exceptions.cc (inside_kernel): Reverse return values to reflect - function name. Return true if we're in cygwin1.dll or if we're - executing in dll_entry. - (_cygtls::interrupt_now): Reflect reversal of inside_kernel return - value. - * hookapi.cc (cygwin_hmodule): Remove declaration. - * init.cc (dll_entry): Use in_dllentry global to record that we are - executing in dllentry. - -2006-02-22 Corinna Vinschen - - * exceptions.cc (_cygtls::interrupt_now): Reorder conditional - to call inside_kernel only if this isn't locked. - -2006-02-22 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Add FILE_READ_ATTRIBUTES to - access flags in case of query_read_control case, add FILE_READ_DATA - in case of query_stat_control. - -2006-02-20 Christopher Faylor - - * spawn.cc (av::fixup): Check for .bat and friends specifically now - since these extensions are no longer automatically detected. - -2006-02-19 Christopher Faylor - - * exceptions.cc (stackdump): Avoid dumping more than once. - -2006-02-19 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Use NtOpenFile - to open the directory. - (fhandler_disk_file::readdir): Use NT_SUCCESS to determine if status - represents success. - -2006-02-19 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Drop generating - path_conv for root. - -2006-02-18 Corinna Vinschen - - * fhandler_disk_file.cc (FS_IS_SAMBA): Move out of - path_conv::hasgood_inode. - (path_conv::is_samba): New method. - (fhandler_base::fstat_by_handle): Don't even try to use - FileIdBothDirectoryInformation on Samba. - * path.h (class path_conv): Declare is_samba method. - -2006-02-17 Christopher Faylor - - * path.cc (conv_path_list): Eat empty paths when converting to POSIX. - (cygwin_conv_to_win32_path): Deal with Cygwin's necessity of adding a - '/' to the end of a path ending in '.'. - -2006-02-16 Corinna Vinschen - - * cygwin.din: Export sigignore and sigset. - * exceptions.cc (sigset): New function. - (sigignore): New function. - * include/cygwin/signal.h (SIG_HOLD): Define. - (sigignore): Declare. - (sigset): Declare. - * include/cygwin/version.h: Bump API minor number to 154. - -2006-02-13 Igor Peshansky - - * include/mntent.h: Add missing #include. - -2006-02-13 Igor Peshansky - - * gentls_offsets: Fix typo in error message. - -2006-02-10 Christopher Faylor - - * fhandler_process.cc (format_process_stat): Use cygwin-derived start - time even on NT since it is the logical start time of the "process". - * pinfo.cc (set_myself): Don't set start time when it should have - already been set previously. - -2006-02-10 Brian Ford - - * times.cc (clock_getres): Use correct conversion from milliseconds to - seconds/nanoseconds. - (clock_setres): Use correct conversion to nanoseconds. - -2006-02-10 Christopher Faylor - - * external.cc (sync_winenv): Rename from "setup_winenv". Use same - mechanism as spawn to determine environment variables which should be - converted back to windows form. - (cygwin_internal): Reflect setup_winenv -> sync_winenv name change. - * include/sys/cygwin.h: Ditto. - -2006-02-09 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Only set - the dirent_get_d_ino flag on filesystems having useful File IDs. - Add comment explaining why. - -2006-02-07 Corinna Vinschen - - * dtable.cc (handle_to_fn): Accommodate new argument order in call to - sys_wcstombs. - * fhandler_disk_file.cc (fhandler_disk_file::readdir): Call sys_wcstombs - instead of just wcstombs to accommodate OEM codepages. - * miscfuncs.cc (sys_wcstombs): Split len argument in source and target - length. Always 0-terminate result in target string. - * security.cc (lsa2wchar): Remove unused function. - (lsa2str): Ditto. - (get_lsa_srv_inf): Ditto. - (get_logon_server): Accommodate new argument order in call to - sys_wcstombs. - (get_user_groups): Ditto. - (get_user_local_groups): Ditto. - (get_priv_list): Call sys_wcstombs directly instead of lsa2str. - * uinfo.cc (cygheap_user::ontherange): Accommodate new argument order - in call to sys_wcstombs. - * winsup.h (sys_wcstombs): Change prototype to match new argument order. - -2006-02-07 Corinna Vinschen - - * init.cc (respawn_wow64_process): Exit with the exit code returned - by the respawned process. - -2006-02-06 Christopher Faylor - - Always zero all elements of siginfo_t throughout. - * cygtls.h (_cygtls::thread_context): Declare new field. - (_cygtls::thread_id): Ditto. - (_cygtls::signal_exit): Move into this class. - (_cygtls::copy_context): Declare new function. - (_cygtls::signal_debugger): Ditto. - * cygtls.cc (_cygtls::init_thread): Fill out thread id field. - * exceptions.cc (exception): Change message when exception info is - unknown. Copy context to thread local storage. - (_cygtls::handle_exceptions): Avoid double test for fault_guarded. - Reflect move of signal_exit to _cygtls class. - (sigpacket::process): Copy context to thread local storage. - (_cygtls::signal_exit): Move to _cygtls class. Call signal_debugger to - notify debugger of exiting signal (WIP). Call stackdump here (WIP). - (_cygtls::copy_context): Define new function. - (_cygtls::signal_debugger): Ditto. - * tlsoffsets.h: Regenerate. - * include/cygwin.h (_fpstate): New internal structure. - (ucontext): Declare new structure (WIP). - (__COPY_CONTEXT_SIZE): New define. - - * exceptions.cc (_cygtls::interrupt_setup): Clear "threadkill" field - when there is no sigwaiting thread. - (setup_handler): Move event handling into interrupt_setup. - -2006-02-06 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::connect): Fix formatting. - (fhandler_socket::wait): Handle SA_RESTART when signal arrives. - -2006-02-06 Corinna Vinschen - - * include/cygwin/socket.h (CMSG_FIRSTHDR): Avoid compiler warning. - -2006-02-05 Corinna Vinschen - - * include/features.h: Add comment to explain what's going to happen - here at one point. - * include/sys/stdio.h: Guard getline and getdelim prototypes with - _GNU_SOURCE to avoid collision with old-style declarations. - -2006-02-05 Corinna Vinschen - - * environ.cc (struct parse_thing): Add transparent_exe option. - * fhandler_disk_file.cc (fhandler_disk_file::link): Accommodate - transparent_exe option. Add .exe suffix for links to executable files, - if transparent_exe is set. - * fhandler_process.cc (fhandler_process::fill_filebuf): Remove .exe - suffix if transparent_exe option is set. - * path.cc (symlink_worker): Accommodate transparent_exe option. - (realpath): Don't tack on .exe suffix if transparent_exe is set. - * syscalls.cc (transparent_exe): New global variable. - (unlink): Accommodate transparent_exe option. - (open): Ditto. - (link): Ditto. - (rename): Ditto. Maybe add .exe suffix when renaming executable files. - (pathconf): Accommodate transparent_exe option. - * winsup.h: Declare transparent_exe. - -2006-02-05 Christopher Faylor - Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::readdir_9x): Remove - useless code. - -2006-02-05 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::rewinddir): Remove label - "out". Move test for NULL __handle ... - (fhandler_disk_file::rewinddir_9x): ... here. - -2006-02-05 Corinna Vinschen - - * dir.cc (rewinddir): Keep dirent_get_d_ino and dirent_set_d_ino flags. - -2006-02-05 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_disk_file::readdir): Don't close dir - handle when we hit EOF since rewwindir may reactivate it. - (fhandler_disk_file::readdir_9x): Eliminate superfluous temporary - variable. - (fhandler_disk_file::closedir): Return EBADF when trying to close - unopened DIR. Reorganize slightly. Return actual derived error value - rather than always returning 0. - -2006-02-04 Christopher Faylor - - * dir.cc (rmdir): Reorganize check for trailing dot to return correct - error when directory does not exist. - -2006-02-03 Christopher Faylor - - * dir.cc (mkdir): Reorganize check for trailing dot to return correct - error when directory exists. - * fhandler_disk_file.cc (fhandler_disk_file::mkdir): Remove special - test for path ending in '.'. - -2006-02-03 Corinna Vinschen - - * path.cc (suffix_scan::lnk_match): Return true beginning with - SCAN_APPENDLNK. - (suffix_scan::next): Rearrange code to make .lnk append order slightly - more deterministic. - * spawn.cc (exe_suffixes): Try no suffix before .exe suffix to align - evaluation with stat_suffixes. - (dll_suffixes): Ditto. - -2006-02-02 Christopher Faylor - - * cygwin/version.h: Mention CW_SETUP_WINENV in comment for API minor - 153. - -2006-02-02 Corinna Vinschen - - * cygwin.din (updwtmpx): Export. - * syscalls.cc (updwtmpx): New function. - * include/utmpx.h (updwtmpx): Declare. - * include/cygwin/version.h: Bump API minor number to 153. - -2006-02-02 Christopher Faylor - - * external.cc (setup_winenv): New function. - (cygwin_internal): Implement CW_SETUP_WINENV. - * sys/cygwin.h (cygwin_getinfo_types): Define CW_SETUP_WINENV. - -2006-02-02 Corinna Vinschen - - * security.cc (is_group_member): Fix comment. - -2006-02-02 Corinna Vinschen - - * security.cc (is_group_member): Use local group info type 1. Test - group for being a global group or a well-known SID before adding it - to the group list. Add comment. - -2006-02-01 Corinna Vinschen - - * autoload.cc (GetTcpTable): Define. - * fhandler_socket.cc (address_in_use): New function to check if - sockaddr_in address is already in use. - (fhandler_socket::bind): Check if address is alreay in use in case of - SO_REUSEADDR, to circumvent WinSock non-standard behaviour. - -2006-02-01 Corinna Vinschen - - * spawn.cc (dll_suffixes): Add .exe and "no suffix" to the list. - -2006-01-31 Corinna Vinschen - - * dlfcn.cc (check_path_access): Call find_exec with FE_DLL option. - * path.h (enum fe_types): Add FE_DLL value. - * spawn.cc (std_suffixes): Remove. - (exe_suffixes): New suffix_info for executing files. - (dll_suffixes): New suffix_info for searching shared libraries. - (perhaps_suffix): Add opt argument. Use dll_suffixes if FE_DLL - option is given, exe_suffixes otherwise. - (find_exec): Propagate opt argument to perhaps_suffix. Drop suffix - check when testing execute permission. - (spawn_guts): Call perhaps_suffix with FE_NADA opt argument. - -2006-01-31 Christopher Faylor - - * spawn.cc (av::fixup): Remove unused argument. - (spawn_guts): Remove capitalization in debugging. - -2006-01-31 Corinna Vinschen - - * spawn.cc (find_exec): Only return files with execute permission set - if ntsec is on. Don't check execute permission of Windows batch files. - (av::fixup): Handle empty files gracefully. Drop execute permission - test here. - * path.cc (suffix_scan::next): Don't skip any suffix on first run. - -2006-01-31 Corinna Vinschen - - * path.cc (cwdstuff::set): Don't set win32 error, only POSIX errno. - -2006-01-31 Corinna Vinschen - - * path.cc (cwdstuff::set): When SetCurrentDirectory returns - ERROR_INVALID_FUNCTION, bend it over to ERROR_FILE_NOT_FOUND. Add - comment to explain why. - -2006-01-31 Corinna Vinschen - - * dir.cc (readdir_worker): Add comment about writing old 32 bit d_ino. - * include/cygwin/version.h: Bump API minor number to 152. - (CYGWIN_VERSION_CHECK_FOR_NEEDS_D_INO): Remove. - -2006-01-30 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::rewinddir): Simplify - conditional. - -2006-01-30 Corinna Vinschen - - * fhandler_disk_file.cc (d_cachepos): Rename from d_pos to distinct - clearly from __d_position. Change throughout. - (fhandler_disk_file::rewinddir): Reset readdir cache on NT. - -2006-01-29 Corinna Vinschen - - * fhandler_disk_file.cc (readdir_get_ino): Don't follow symlinks. - -2006-01-29 Corinna Vinschen - - * fhandler.h (class fhandler_socket): Add saw_reuseaddr status flag. - * fhandler_socket.cc (fhandler_socket::bind): Set socket to - SO_EXCLUSIVEADDRUSE if application didn't explicitely set SO_REUSEADDR - socket option, on systems supporting SO_EXCLUSIVEADDRUSE. - * net.cc (cygwin_setsockopt): Set fhandler's saw_reuseaddr status flag - if SO_REUSEADDR socket option has been successsfully set. - * wincap.h (wincaps::has_exclusiveaddruse): New element. - * wincap.cc: Implement above element throughout. - -2006-01-28 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::mkdir): In case or error, - check for existance explicitely and set errno to EEXIST. - -2006-01-28 Corinna Vinschen - - * fhandler_disk_file.cc (DIR_NUM_ENTRIES): New define determining - minimum number of dir entries which fit into the readdir cache. - (DIR_BUF_SIZE): Define globally as size of readdir cache. - (struct __DIR_cache): New structure used for readdir caching on NT. - (d_dirname): Accessor for struct __DIR_cache, use throughout. - (d_pos): Ditto. - (d_cache): Ditto. - (fhandler_disk_file::opendir): Allocate __d_dirname to contain readdir - cache on NT. - (fhandler_disk_file::readdir): Use buf as pointer into readdir cache. - Implement readdir caching. - -2006-01-28 Corinna Vinschen - - * include/sys/dirent.h (struct dirent): Revert misguided attempt to - rename __d_unused1 to __d_fd. - -2006-01-27 Corinna Vinschen - - * autoload.cc (NtQueryDirectoryFile): Define. - * dir.cc (__opendir_with_d_ino): Just call opendir. - (opendir): Remove CYGWIN_VERSION_CHECK_FOR_NEEDS_D_INO handling. - (readdir_worker): Only try generating d_ino if it's 0. - Utilize namehash of directories fhandler. Call readdir_get_ino to - generate d_ino for "..". - (seekdir64): Keep dirent_set_d_ino flag. - * fhandler.h (enum dirent_states): Add dirent_get_d_ino. - (class fhandler_disk_file): Declare new private methods readdir_helper - and readdir_9x. - * fhandler_disk_file.cc (path_conv::hasgood_inode): New method to - evaluate if a filesystem has reliable inode numbers. - (fhandler_base::fstat_by_handle): Accommodate structure member name - change from IndexNumber to FileId. - (fhandler_base::fstat_helper): Call hasgood_inode here. - (fhandler_disk_file::opendir): Call fhaccess only for real files. - Don't append '*' to __d_dirname here, move to readdir_9x. On NT, - open directory handle here. Set dirent_get_d_ino and dirent_set_d_ino - flags according to wincap and filesystem. - (fhandler_disk_file::readdir_helper): New method to implement readdir - postprocessing only once. - (readdir_get_ino_by_handle): New static function. - (readdir_get_ino): New function to centralize inode number evaluation - in case inode number hasn't been returned by NtQueryDirectoryFile. - (fhandler_disk_file::readdir): Move old functionality to readdir_9x. - Call readdir_9x when on 9x/Me. Implement NT specific readdir here. - (fhandler_disk_file::readdir_9x): Move 9x specific readdir here. - (fhandler_disk_file::seekdir): Accommodate new NT readdir method. - (fhandler_disk_file::closedir): Ditto. - (fhandler_cygdrive::fstat): Set d_ino to namehash. Add comment. - (fhandler_cygdrive::opendir): Call get_namehash to prepare later - correct evaluation of d_ino. - (fhandler_cygdrive::readdir): Replace recursion with loop. Evaluate - drive's d_ino by calling readdir_get_ino. - * fhandler_proc.cc (fhandler_proc::readdir): Set dirent_saw_dot and - dirent_saw_dot_dot to avoid seeing . and .. entries twice. - * fhandler_process.cc (fhandler_process::readdir): Ditto. - * fhandler_registry.cc (fhandler_registry::readdir): Ditto. - * ntdll.h (STATUS_INVALID_PARAMETER): New define. - (STATUS_INVALID_LEVEL): New define. - (struct _FILE_INTERNAL_INFORMATION): Rename member IndexNumber to - FileId (as in Nebbitt). - * path.h (path_conv::hasgood_inode): Now implemented in - fhandler_disk_file.cc. - * wincap.h (wincaps::has_fileid_dirinfo): New element. - * wincap.cc: Implement above element throughout. - * winsup.h (readdir_get_ino): Add declaration. - * include/sys/dirent.h (struct dirent): Slightly rename structure - members to accommodate changes. - Remove __USE_EXPENSIVE_CYGWIN_D_INO handling and declaration of - __opendir_with_d_ino. - -2006-01-27 Christopher Faylor - - * spawn.cc (spawn_guts): Fix potential handle leak when failing exec. - -2006-01-27 Christopher Faylor - - * exceptions.cc (inside_kernel): Fix to return true if we can't get the - name of the DLL for the given memory block since we are not in kernel - code. - -2006-01-26 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Fix bug in argument order to - InitializeObjectAttributes call. - -2006-01-25 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::readdir): Fix test for - dirent_isroot to use the correct boolean operator. - -2006-01-25 Christopher Faylor - - * ntdll.h: (temporarily?) Add more functions for querying directory. - -2006-01-24 Christopher Faylor - - * dir.cc (readdir_worker): Turn off expensive inode calculation. - -2006-01-24 Corinna Vinschen - - * fhandler_process.cc (fhandler_process::fill_filebuf): Disable - stripping the .exe suffix from the link target in PROCESS_EXE and - PROCESS_EXENAME case. - * path.cc (realpath): Tack on .exe suffix if necessary. - -2006-01-24 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::fstat_helper): Try harder - to determine remote file systems with reliable inode numbers. Add - longish comment. - -2006-01-23 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::fixup_after_fork): Reset - inheritance for duplicated socket. - -2006-01-20 Christopher Faylor - - * include/cygwin/version.h: Bump API minor number to 151. - * dir.cc (__opendir_with_d_ino): New function. - (opendir): Set flag if we should be calculating inodes. - (readdir_worker): Calculate d_ino by calling stat if the user has asked - for it. - (seekdir64): Maintain all persistent flag settings. - * fhandler.h (dirent_states): Add dirent_set_d_ino. - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Reflect changes - to dirent structure. - * fhandler_virtual.cc (fhandler_virtual::opendir): Ditto. - * include/sys/dirent.h (struct dirent): Coalesce two similar - structures. Remove all shreds of the apparently highly confusing - references to inodes. Add support for calculating a real inode if - __USE_EXPENSIVE_CYGWIN_D_INO is defined. - -2006-01-20 Christopher Faylor - - * include/sys/dirent.h: Add comments for people who are REALLY confused - about whether they should be using something called __invalid_d_ino or - not. - -2006-01-20 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::prepare): Fix debug output. - (fhandler_socket::release): Add debug output for WSAEventSelect failure. - (fhandler_socket::ioctl): Always cancel WSAEventSelect before switching - to blocking mode. Only set nonblocking flag if ioctlsocket call - succeeded. Only print new socket state if ioctlsocket call succeeded. - -2006-01-19 Christopher Faylor - - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Check posix path - for root rather than windows path. - -2006-01-19 Christopher Faylor - - * dir.cc (readdir_worker): Fill in invalid fields with -1. Accommodate - name change from __ino32 to __invalid_ino32. - * include/sys/dirent.h (__invalid_ino32): Rename from __ino32. Don't - define unused d_type macros. - -2006-01-18 Christopher Faylor - - * heap.cc (heap_init): Remove Sleep. - -2006-01-18 Corinna Vinschen - - * net.cc (rresvport): Remove extern declaration. - -2006-01-18 Corinna Vinschen - - * autoload.cc (rresvport): Remove. - * net.cc (last_used_rrecvport): New global shared variable. - (cygwin_rresvport): Implement rresvport without using rresvport from - wsock32. - -2006-01-18 Corinna Vinschen - - * include/cygwin/socket.h (struct sockaddr_storage): Fix typo in - ss_family member name. - -2006-01-16 Christopher Faylor - - * include/cygwin/version.h: Bump DLL minor version number to 20. - -2006-01-13 Corinna Vinschen - - * uname.cc (uname): Concatenate a "-WOW64" to utsname's sysname - member to see when running under WOW64. - -2006-01-13 Corinna Vinschen - - * net.cc (cygwin_setsockopt): Ignore errors when setting IP_TOS on - Windows 2000 and above. Clarify the comment about IP_TOS and move - to the place where the magic happens. - (get_ifconf): Remove unused code. - * wincap.h (wincaps::has_disabled_user_tos_setting): New element. - * wincap.cc: Implement above element throughout. - -2006-01-12 Christopher Faylor - - * fhandler_console.cc (set_console_state_for_spawn): Fix to recognize - ttys >= 0. - -2006-01-12 Christopher Faylor - - * fhandler.h (set_console_state_for_spawn): Whackamole the argument - back to a bool. - * spawn.cc (spawn_guts): Ditto, i.e., once again call - set_console_state_for_spawn with an indication of whether we're about - to start a cygwin process. - * fhandler_console.cc (set_console_state_for_spawn): Don't set the - console state if we know we're starting a cygwin process or if we're - using a "real" tty. - -2006-01-10 Corinna Vinschen - - * dcrt0.cc (dll_crt0_0): Remove call to wincap.init. - * init.cc (dll_entry): Rename is_wow64_proc to wow64_test_stack_marker. - Call wincap.init here before doing anything else. Use wincap.is_wow64 - to determine if we're running in a WOW64 emulator. - * mmap.cc (MapViewNT): Don't use AT_ROUND_TO_PAGE in WOW64, it's - apparently not supported. - (mmap64): Don't create mappings beyond EOF, which would need to use - AT_ROUND_TO_PAGE, on WOW64. - * wincap.cc (wincap): Throw into the .cygwin_dll_common section. - (wincapc::init): Determine if running in WOW64 and set wow_64 flag. - * wincap.h (class wincapc): Add wow64 member. - (wincapc::is_wow64): New method. - -2006-01-10 Christopher Faylor - - * fhandler_proc.cc (format_proc_cpuinfo): Avoid leading whitespace in - model name. - -2006-01-09 Christopher Faylor - - * spawn.cc (spawn_guts): Reorganize slightly so that 16 bit check is - done prior to check for command.com/cmd.com. Don't bother setting - CREATE_SUSPENDED flag for a MS-DOS process since it doesn't work - anyway. Avoid calling remember() when the child process has already - exited. - (av::fixup): Explicitly set cygexec flag to false on a 16 bit process. - -2006-01-09 Corinna Vinschen - - * include/getopt.h (getopt_long_only): Declare. - -2006-01-09 Eric Blake - - * cygwin.din: Export getsubopt. - * include/cygwin/version.h: Bump API minor version. - -2006-01-08 Christopher Faylor - - * fhandler_tty.cc (fhandler_tty_slave::dup): Don't assign a controlling - terminal to a process when duped. Linux doesn't do this, so we won't - either. - -2006-01-08 Christopher Faylor - - * environ.cc (spenvs[]): windir -> WINDIR. - -2006-01-07 Christopher Faylor - - * fhandler_console.cc (fhandler_console::need_invisible): Remove - duplicate test. - -2006-01-07 Christopher Faylor - - * fhandler.h (set_console_state_for_spawn): Eliminate argument from - declaration. - * fhandler.cc (set_console_state_for_spawn): Eliminate argument from - definition. Always check for invisible console. - (fhandler_console::need_invisible): Don't do anything if the windows - station is already not visible. - * spawn.cc (spawn_guts): Accommodate change of argument to - set_console_state_for_spawn. - -2006-01-05 Christopher Faylor - - * sigproc.cc (no_signals_available): Use existence of signal thread - handle to figure out if we can actually send signals rather than - relying on my_sendsig. - (hwait_sig): Make static. - (sigproc_init): Don't set my_sendsig to anything special. Use new - global static hwait_sig. - (wait_sig): Set hwait_sig to NULL when we are exiting. - -2006-01-05 Christopher Faylor - - * include/getopt.h: Accommodate recent unfortunate newlib changes. - -2006-01-05 Christopher Faylor - - * cygtls.cc (_cygtls::remove): Don't output debugging info if this - isn't a cygwin thread. - * sigproc.cc (sigproc_init): Move clearing of sync_startup here to - lessen the likelihood of trying to deal with non-cygwin threads in - dll_entry. - - * fhandler_console: Fix set_console_state_for_spawn comment. - -2006-01-05 Igor Peshansky - - * spawn.cc (spawn_guts): Invert the argument to - set_console_state_for_spawn. - -2006-01-04 Christopher Faylor - - * fhandler_console.cc (fhandler_console::need_invisible): Only try to - open "CygwinInvisible" windows station if opening of default station - fails. Use CloseWindowStation to close window station handle. - -2006-01-04 Christopher Faylor - - * fhandler_console.cc (fhandler_console::need_invisible): Open up the - security of the newly created windows station. - -2006-01-04 Eric Blake - - * path.cc (dot_special_chars): Add ", <, >, and |. - -2006-01-03 Christopher Faylor - - * fhandler_console.cc (beep): Use MB_OK which is documented as using - the default bell rather than -1 which seems to behave differently on - different versions of Windows. - -2006-01-03 Christopher Faylor - - * fhandler_process.cc (fhandler_process::readdir): Add missing argument - to syscall_printf. - - * fhandler_console.cc (fhandler_console::need_invisible): Use made-up - name for windows station rather than asking Windows to create one for - us. - - * spawn.cc (spawn_guts): Don't mess with console if we're detaching. - -2006-01-03 Christopher Faylor - - * dir.cc (readdir_worker): Minor code cleanup. - - * fhandler_console.cc (beep): Use a more Windows-generic wav file if - the beep is missing. Use a more foolproof way to find out whether we - should be recreating the missing key. - - * registry.h (reg_key::_disposition): New field. - (reg_key::created): New function. - * registry.cc (reg_key::reg_key): Set _disposition to zero by default. - (reg_key::build_key): Fill in _disposition field. - -2006-01-03 Eric Blake - - * dir.cc (readdir_worker): Ensure that saw_dot* flags are updated when - not handling inodes. - -2006-01-02 Christopher Faylor - - * fhandler_console.cc (beep): New function. Restores missing "Default - Beep", if necessary. - (fhandler_console::write_normal): Use beep(). - -2006-01-02 Christopher Faylor - - * dcrt0.cc (_dll_crt0): Remove more leftover debugging stuff. - (cygwin_dll_init): Remove unneeded initializations. Call _dll_crt0 - rather than dll_crt0_1. - -2006-01-02 Corinna Vinschen - - * syslog.cc: Include sys/un.h instead of sys/socket.h. - (syslogd_inited): Convert to enum type noting the exact result of - trying to connect to syslog daemon. Use this way throughout. - (connect_syslogd): New static function taking over the task to - connect to syslog socket. Use correct struct sockaddr_un instead of - struct sockaddr. - (try_connect_syslogd): Call connect_syslogd. If write fails on - connection oriented socket, try to reconnect to syslog socket and - try to write again. - -2006-01-01 Christopher Faylor - - * pinfo.cc (pinfo::exit): Swap signal and normal exit value when not - started from a cygwin process - just like the good-old-days of B20. - -2006-01-01 Christopher Faylor - - * strace.cc (strace::write_childpid): Remove debugging output. - -2006-01-01 Christopher Faylor - - * cygtls.cc (_cygtls::remove): Remove left over debugging cruft which - caused this function to always return prematurely. - -2006-01-01 Christopher Faylor - - * exceptions.cc (sigpacket::process): Pass actual reference to signal's - sigaction structure to setup_handler. - -2006-01-01 Christopher Faylor - - * exceptions.cc (_cygtls::interrupt_setup): Implement SA_RESETHAND. - * include/cygwin/signal.h: Define SA_ONESHOT and SA_NOMASK. - - * dcrt0.cc (get_cygwin_startup_info): Remove commented out code. - -2006-01-01 Corinna Vinschen - - * syslog.cc (vklog): Never log kernel messages using the vsyslog - interface. diff --git a/winsup/cygwin/ChangeLog-2007 b/winsup/cygwin/ChangeLog-2007 deleted file mode 100644 index 66cb33130..000000000 --- a/winsup/cygwin/ChangeLog-2007 +++ /dev/null @@ -1,2769 +0,0 @@ -2007-12-30 Dave Korn - - * cygwin.din (_f_llrint, _f_llrintf, _f_llrintl, _f_lrint, _f_lrintf, - _f_lrintl, _f_rint, _f_rintf, _f_rintl): Export fast *rint* functions. - (lrint, lrintf, rint, rintf): Redirect exports to alias _f_ versions. - (llrint, llrintf, llrintl, lrintl, rintl): Add exports aliasing _f_* - versions likewise. - * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. - -2007-12-22 Corinna Vinschen - - * fhandler.h (class fhandler_dev_random): Add dummy_offset member. - * fhandler_random.cc (fhandler_dev_random::lseek): Fake seeking - capability as on Linux. - -2007-12-20 Eric Blake - - * libc/memmem.cc (memmem): Fix bug when searching for empty string. - -2007-12-19 Corinna Vinschen - - * cygwin.din: Export wcpcpy, wcpncpy. - * include/cygwin/version.h: Bump API minor number. - -2007-12-16 Christopher Faylor - - * dtable.cc (POSIX_NAMED_PIPE): New define. - (POSIX_NAMED_PIPE_LEN): Ditto. - (dtable::add_archetype): Use crealloc_abort. - (dtable::init_std_file_from_handle): Specifically detect pipe - stdin/stdout. Pass name to build_fh_dev so that proper name is - recorded. Use binmode of fh if it is set before using - get_default_mode. Set proper read/write access when calling init(). - (handle_to_fn): Handle pipes. - * fhandler.cc (fhandler_base::wait_overlapped): Add some debugging. - * fhandler.h (fhandler_base::set_name): Default to just setting the - path_conv name. - (fhandler_pipe::init): Declare. - * pipe.cc (struct pipesync): New struct. - (getov_result): New function. Blocks and retrieves the result of an - overlay I/O operation. - (pipe_handler): New function. - (pipesync::pipesync): New function. Initializer for pipesync struct. - (handler_pipe::init): Define. Detects attempts to set up a "native" - pipe fhandler and creates a thread which accepts input from or output - to the non-cygwin pipe, creating a cygwin pipe wrapper around the - non-cygwin pipe. - (fhandler_pipe::create): Add pipe-specific flags to call to init(). - - * exceptions.cc (ctrl_c_handler): Lock process while we determine what - to do. - -2007-12-14 Corinna Vinschen - - * include/cygwin/socket.h: Include sys/uio.h instead of cygwin/uio.h. - * include/cygwin/uio.h: Remove. - -2007-12-14 Corinna Vinschen - - * dtable.cc (dtable::set_file_pointers_for_exec): Reenable. Fix - comment. - * spawn.cc (spawn_guts): Call cygheap->fdtab.set_file_pointers_for_exec - only for non-Cygwin processes. - -2007-12-13 Craig MacGregor - Corinna Vinschen - - * poll.cc (poll): Return count of fds with events instead of total - event count. - -2007-12-13 Corinna Vinschen - - * string.h: Guard cygwin internal string function definitions with - __INSIDE_CYGWIN__. - -2007-12-12 Corinna Vinschen - - * dcrt0.cc: Include string.h. - (initial_env): Use small_printf's %P specifier. - * dll_init.cc (dll_list::alloc): Use PATH_MAX instead of CYG_MAX_PATH - for path name buffer size. - * dll_init.h (struct dll): Ditto. - * environ.cc: Include string.h. - (win_env::add_cache): Use temporary local buffer for path conversion. - (posify): Ditto. - * exceptions.cc (try_to_debug): Use CreateProcessW to allow long path - names. - * miscfuncs.cc: Drop unused implementations of strcasematch and - strncasematch. - (ch_case_eq): Drop. - (strcasestr): Drop. - (cygwin_wcscasecmp): New function. - (cygwin_wcsncasecmp): New function. - (cygwin_strcasecmp): New function. - (cygwin_strncasecmp): New function. - (cygwin_wcslwr): New function. - (cygwin_wcsupr): New function. - (cygwin_strlwr): New function. - (cygwin_strupr): New function. - * ntdll.h (RtlDowncaseUnicodeString): Declare. - (RtlUpcaseUnicodeString): Declare. - (RtlInt64ToHexUnicodeString): Fix typo in comment. - * string.h: Disable not NLS aware implementations of strcasematch - and strncasematch. - (cygwin_strcasecmp): Declare. - (strcasecmp): Define as cygwin_strcasecmp. - (cygwin_strncasecmp): Declare. - (strncasecmp): Define as cygwin_strncasecmp. - (strcasematch):Define using cygwin_strcasecmp. - (strncasematch):Define using cygwin_strncasecmp. - (cygwin_strlwr): Declare. - (strlwr): Define as cygwin_strlwr. - (cygwin_strupr): Declare. - (strupr): Define as cygwin_strupr. - * wchar.h: New file. - * wincap.cc (wincapc::init): Use "NT" as fix OS string. - * winsup.h (strcasematch): Drop declaration. - (strncasematch): Ditto. - (strcasestr): Ditto. - -2007-12-11 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::fstat_helper): Fix R/O bit - handling on filesystems without ACL support. - -2007-12-11 Corinna Vinschen - - * localtime.cc (tzset): Guard by a muto for thread safety. - -2007-12-11 Dave Korn - - * cygheap.cc (_csbrk): Don't request zero bytes from VirtualAlloc, - as windows treats that as an invalid parameter and returns an error. - -2007-12-11 Corinna Vinschen - - * localtime.cc (tzset): Call tzsetwall only if it hasn't been - called before. - -2007-12-07 Corinna Vinschen - - * include/sys/cygwin.h: Include limits.h. - -2007-12-06 Corinna Vinschen - - * dcrt0.cc (initial_env): Use PATH_MAX instead of CYG_MAX_PATH for path - name buffer size. - (dll_crt0_1): Allocate new_argv0 with PATH_MAX size. - * exceptions.cc (debugger_command): Set size to 2 * PATH_MAX + 20; - (error_start_init): Use PATH_MAX instead of CYG_MAX_PATH for path - name buffer size. - * external.cc (fillout_pinfo): Always fill out ep.progname 0-terminated. - Fill out ep.progname_long. - * fhandler_process.cc (fhandler_process::fill_filebuf): Allocate - buffer for executable filename with PATH_MAX size. - * pinfo.cc: Throughout use PATH_MAX instead of CYG_MAX_PATH. - * pinfo.h (class _pinfo): Set progname size to PATH_MAX. - * smallprint.cc: Include limits.h. Use PATH_MAX instead of CYG_MAX_PATH - for path name buffer size. - * strace.cc (strace::vsprntf): Ditto. - * include/sys/cygwin.h (EXTERNAL_PINFO_VERSION_32_LP): Define. - (EXTERNAL_PINFO_VERSION): Set to EXTERNAL_PINFO_VERSION_32_LP. - (struct external_pinfo): Add progname_long member. - * include/sys/dirent.h: Correctly include limits.h instead of - sys/limits.h. - -2007-12-05 Corinna Vinschen - - * fhandler_tty.cc (fhandler_tty_slave::open): Use MAX_PATH instead of - CYG_MAX_PATH for event name buffer size. - (fhandler_pty_master::setup): Use MAX_PATH instead of CYG_MAX_PATH for - mutex name buffer size. - * netdb.cc: Drop old comment. - (open_system_file): Set path buffer size to MAX_PATH instead of - CYG_MAX_PATH. Drop conversion to posix path. Open file using win32 - path. - -2007-12-05 Corinna Vinschen - - * fhandler_registry.cc: Use NAME_MAX + 1 instead of CYG_MAX_PATH - throughout for subkey name buffer size. - * fhandler_socket.cc (search_wsa_event_slot): Use MAX_PATH instead of - CYG_MAX_PATH for mutex name buffer size. - (fhandler_socket::init_events): Ditto. - * fhandler_virtual.cc (fhandler_virtual::opendir): Check path length - against PATH_MAX instead of against CYG_MAX_PATH. - * registry.cc (get_registry_hive_path): Use PATH_MAX instead of - CYG_MAX_PATH for registry value path buffer size. - * shared.cc (open_shared): Use MAX_PATH instead of CYG_MAX_PATH - for shared memory name buffer size. - * thread.cc (semaphore::semaphore): Use MAX_PATH instead of CYG_MAX_PATH - for semaphore name buffer size. - * uinfo.cc (cygheap_user::env_userprofile): Use PATH_MAX instead of - CYG_MAX_PATH for temporary path name buffer size. - * winf.h (LINE_BUF_CHUNK): Define as MAX_PATH * 2. - * include/sys/dirent.h: Include sys/limits.h. Define name buffer sizes - using NAME_MAX. - -2007-12-04 Corinna Vinschen - - * fhandler_fifo.cc (fhandler_fifo::open): Use MAX_NAME for pipe name - buffer size. - (fhandler_fifo::fstatvfs): Use same technique as in fhandler_socket. - * fhandler_proc.cc (format_proc_partitions): Use NAME_MAX+1 for - device name buffer size. Use MAX_PATH for device path buffer size. - -2007-12-03 Corinna Vinschen - - * autoload.cc (GetModuleFileNameExW): Replace definition of - GetModuleFileNameExA. - * fhandler_process.cc (format_process_maps): Change modname type to - WCHAR. Set buffer sizes to PATH_MAX. Call GetModuleFileNameExW - instead of GetModuleFileNameExA. Call mount_info::conv_to_posix_path - instead of cygwin_conv_to_full_posix_path. Set posix_modname to - modname if that call fails. - (format_process_stat): Set cmd buffer size to NAME_MAX + 1. Simplify - setting cmd to process name. - (format_process_status): Ditto. - * path.cc (mount_info::conv_to_posix_path): Call sys_wcstombs - correctly. - -2007-12-03 Corinna Vinschen - - * include/cygwin/time.h: Remove redundant #endif. - -2007-12-01 Corinna Vinschen - - * include/cygwin/time.h (daylight): Declare as extern symbol referring - _daylight variable. - (timezone): Only define if __timezonefunc__ is undefined. - -2007-12-01 Corinna Vinschen - Brian Dessent - - * Makefile.in (OBSOLETE_FUNCTIONS): Add timezone. - * include/cygwin/time.h: Drop conditional timezone definitions. - (timezone): Declare as extern symbol referring _timezone variable. - -2007-11-28 Corinna Vinschen - - * fhandler_tape.cc (mtinfo::initialize): Use MAX_PATH instead of - CYG_MAX_PATH. - * fhandler_tty.cc (fhandler_pty_master::ptsname): Set buffer size to - TTY_NAME_MAX. - * syscalls.cc (ttyname): Eliminate the `+ 1' from the name buffer size - since TTY_NAME_MAX already counts the trailing NUL. - * libc/bsdlib.cc (openpty): Set pts buffer size to TTY_NAME_MAX. - -2007-11-28 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::recv_internal): Add MSG_WAITALL - handling. Use explicit flag values instead of MSG_WINMASK. - (fhandler_socket::send_internal): Use explicit flag values instead of - MSG_WINMASK. - * include/cygwin/socket.h (MSG_WINMASK): Remove definition. - (MSG_WAITALL): Define. - -2007-11-27 Corinna Vinschen - - * posix_ipc.cc (ipc_names): Rename max_len to prefix_len. Store - the prefix len in it. - (check_path): Take length parameter. Use this length insetad of - calling strlen. Allow PATH_MAX length paths. - (ipc_mutex_init): Use MAX_PATH instead of CYG_MAX_PATH. - (ipc_cond_init): Ditto. - (shm_open): Allocate local name buffer not bigger than necessary. Call - check_path with additional length argument. - (shm_unlink): Ditto. - (mq_open): Ditto. - (mq_unlink): Ditto. - (sem_open): Ditto. - (sem_unlink): Ditto. - -2007-11-27 Corinna Vinschen - - Drop old SetResourceLock stuff in favor of mutos. - * dcrt0.cc (_reslock): Remove. - (__cygwin_user_data): Accommodate removal of resourcelocks member. - (dll_crt0_0): Don't initialize resourcelocks. - * exceptions.cc (_cygtls::signal_exit): Drop resourcelocks handling. - * mmap.cc (mmap_guard): New muto. - (LIST_LOCK): Define. - (LIST_UNLOCK): Define. - (mmap_list::search_record): Remove. - (mmap_list::try_map): Include code for anonymous case from - mmap_list::search_record. - (mmap_is_attached_or_noreserve): Access bookkeeping lists in a thread - safe way. - (mmap64): Replace SetResourceLock/ReleaseResourceLock by - LIST_LOCK/LIST_UNLOCK. Lock at the latest possible point. - (munmap): Replace SetResourceLock/ReleaseResourceLock by - LIST_LOCK/LIST_UNLOCK. - (msync): Ditto. - (mprotect): Ditto. - * thread.cc (ResourceLocks::Lock): Remove. - (SetResourceLock): Remove. - (ReleaseResourceLock): Remove. - (ResourceLocks::Init): Remove. - (ResourceLocks::Delete): Remove. - * thread.h (SetResourceLock): Drop declaration. - (ReleaseResourceLock): Ditto. - (class ResourceLocks): Drop definition. - * include/sys/cygwin.h (class ResourceLocks): Drop forward declaration. - (struct per_process): Replace resourcelocks with additional unused2 - element. - (per_process_overwrite): Accommodate above change. - -2007-11-27 Corinna Vinschen - - * mmap.cc: Convert usage of dynamically growing cmalloced arrays to - cmalloced linked lists throughout. - (class mmap_record): Add LIST_ENTRY element. - (mmap_record::match): New method, taking over match algorithm from - list::search_record. - (class mmap_list): Rename from class list. Add LIST_ENTRY. Convert - recs to a LIST_HEAD. Drop nrecs and maxrecs members. - (mmap_list::get_record): Drop entirely. - (mmap_list::free_recs): Drop entirely. - (mmap_list::del_record): Take mmap_record to delete as parameter. - (mmap_list::search_record): Convert to mmap_record::match. - (class mmap_areas): Rename from class map. Convert lists to LIST_HEAD. - (mmap_areas::get_list): Drop entirely. - (mmap_areas::del_list): Take mmap_list to delete as parameter. - (mprotect): Fix indentation. - -2007-11-26 Christopher Faylor - - Change many cygheap allocation routines to their *_abort analogs. - * cygheap.cc (cmalloc_abort): New function. - (crealloc_abort): Ditto. - (ccalloc_abort): Ditto. - -2007-11-23 Christopher Faylor - - * cygheap.cc (_crealloc): Avoid memcpy when _cmalloc returns NULL. - -2007-11-08 Christopher Faylor - - * dllfixdbg: Eliminate extra objcopy step. - -2007-11-07 Pedro Alves - - * dllfixdbg: Pass --only-keep-debug to objcopy, instead of - selecting the sections manually. - -2007-11-06 Corinna Vinschen - - * thread.cc (pthread_key_create): Drop check for incoming valid object. - -2007-11-06 Corinna Vinschen - - * shm.cc: Include sync.h - (struct shm_shmid_list): Add ref_count member. - (struct shm_attached_list): Remove hdl and size members. Add a parent - member pointing to referenced shm_shmid_list entry. - (shm_guard): New muto. - (SLIST_LOCK): Define. - (SLIST_UNLOCK): Define. - (fixup_shms_after_fork): Use hdl and size members of parent - shm_shmid_list entry. - (shmat): Access sequential bookkeeping lists in a thread safe way. - Accommodate change in list element layout. Align comments. - (shmctl): Ditto. - (shmdt): Ditto. - (shmget): Ditto. - -2007-11-05 Corinna Vinschen - - * shm.cc (shmctl): On IPC_RMID don't unmap views and don't close handle - if the map is still referenced to emulate Linux and BSD behaviour. - -2007-11-05 Corinna Vinschen - - * shm.cc (shmctl): On IPC_RMID also unmap all views on shared mem - as well as connected shm_attached_list entry. - -2007-10-31 Corinna Vinschen - - * net.cc (load_ipv6_funcs): Use MAX_PATH instead of CYG_MAX_PATH. - (cygwin_getaddrinfo): Simplify formatting. - (cygwin_getnameinfo): Ditto. - -2007-10-31 Corinna Vinschen - - * external.cc (get_cygdrive_info): Make inline. - (get_cygdrive_prefixes): Remove. - (cygwin_internal): Call get_cygdrive_info with NULL flag parameters - instead of get_cygdrive_prefixes. - * path.cc (mount_info::get_cygdrive_info): Allow NULL flag parameters. - -2007-10-30 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::fstat_helper): Don't remove - write bits for directories with R/O attribute. - (fhandler_base::fhaccess): Don't shortcircuit R/O attribute with W_OK - scenarios for directories. - -2007-10-22 Corinna Vinschen - - * cygheap.h (struct cwdstuff): Drop hash member. Drop get_hash, - get_initial, and fixup_after_exec declarations. - Convert win32 to UNICODE_STRING. - (cwdstuff::get_drive): Convert win32 path in current codepage. - (cwdstuff::set): Take native NT path. - * ntdll.h (struct _TEB): Typedef. - * path.cc (mount_info::conv_to_posix_path): Add variant taking - wide char DOS paths. - (symlink_info::posixify): Simplify concatenating cwd and relative path. - (hash_path_name): Drop special relative path handling. - (chdir): Drop special "drive only" handling. Call cwdstuff::set with - native path. - (cwdstuff::get_hash): Remove. - (windows_system_directory): Remove. - (_upp): Remove. - (get_user_proc_parms): Make inline. Get PEB pointer by calling - NtCurrentTeb. - (cwdstuff::init): Simplify. - (cwdstuff::set): Rework to handle incoming native NT path. Workaround - a Vista problem with CWD handle in the user process parameter block. - (cwdstuff::get): Simplify locking. Accommodate type change of win32. - * shared_info.h (mount_info): Add declaration for new conv_to_posix_path - method. - * strfuncs.cc (sys_wcstombs): Return correct length of created - multi-byte string. - -2007-10-19 Corinna Vinschen - - * fhandler_disk_file.cc (__DIR_mounts::eval_ino): Make fname big enough - to allow multibyte chars. - -2007-10-18 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Open native symlinks with - FILE_OPEN_REPARSE_POINT flag. Fix typo in comment. - -2007-10-18 Corinna Vinschen - - * include/sys/param.h (MAXPATHLEN): Define as PATH_MAX. - -2007-10-14 Corinna Vinschen - - * fhandler.cc (is_at_eof): Rewrite using NT functions. - (off_current): New static variable. - (off_append): Ditto. - (fhandler_base::raw_write): Use NtWriteFile. Accommodate O_APPEND here. - (fhandler_base::write): Drop O_APPEND hack. Use NT functions. - (fhandler_base::lseek): Rewrite using NT functions. - * fhandler_disk_file.cc (fhandler_disk_file::fstatvfs): Add space in - debug output. - (fhandler_disk_file::ftruncate): Ditto. - * ntdll.h (STATUS_DISK_FULL): Define. - (FILE_USE_FILE_POINTER_POSITION): Define. - (FILE_WRITE_TO_END_OF_FILE): Define. - -2007-10-13 Corinna Vinschen - - * ntdll.h (STATUS_END_OF_FILE): Define. - * path.cc (symlink_info::check_shortcut): Use NT function to get file - size. Reintroduce checking file size before reading it. Eliminiate - close_it label. - (symlink_info::check_sysfile): Check for EOF condition. - -2007-10-11 Corinna Vinschen - - * path.cc (basename): Return pointer into the path argument itself. - Shrink buf to 4 bytes. Use buf only for border cases. - (dirname): Ditto. - -2007-10-10 Corinna Vinschen - - * path.cc (struct symlink_info): Change size of contents member to - be able to keep SYMLINK_MAX sized strings. - (symlink_worker): Rework for long path names. When writing windows - shortcuts, store pathname additionally "hidden" after the actual - shortcut data to workaround size limitations of the description field. - (symlink_info::check_shortcut): Drop file name parameter. Drop max - file size check. Use NT functions. Use appended full path if - available, description otherwise. Check symlink string length for - not exceeding SYMLINK_MAX. Don't close file here. - (symlink_info::check_sysfile): Drop file name parameter. Use NT - functions. Check symlink string length for not exceeding SYMLINK_MAX. - Don't close file here. - (symlink_info::check_reparse_point): Drop file name parameter. Drop - useless length checks. Allow SYMLINK_MAX length symlink strings. - Don't close file here. - (symlink_info::posixify): Allow SYMLINK_MAX length symlink strings. - (symlink_info::check): Turn around checking for symlink file attributes. - Use NT functions. Close symlink file here. - * include/limits.h (PATH_MAX): Define as 32760. Change comment. - (SYMLINK_MAX): Define as PATH_MAX - 1. - -2007-10-10 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::bind): Open file for deletion, - too. Don't write to file and especially don't close handle if file - couldn't be created. Set delete disposition if writing failed, - instead of calling unlink_nt. - -2007-09-27 Corinna Vinschen - - * ntdll.h (struct _FILE_COMPRESSION_INFORMATION): Align with definition - in w32api / MSDN. - * fhandler_disk_file.cc (fhandler_base::fstat_helper): Accommodate - change to struct _FILE_COMPRESSION_INFORMATION. - -2007-09-26 Corinna Vinschen - - * termios.cc (setspeed): Support new baud rates introduced 2007-02-05. - -2007-09-20 Corinna Vinschen - - * ntdll.h (STATUS_OBJECT_NAME_INVALID): Define. - -2007-09-18 Corinna Vinschen - - * mmap.cc (fh_disk_file): Delete as global static variable and... - (mmap64): ...define as local pointer to make mmap thread-safe. - Accommodate throughout. Only initialize fh_disk_file after file could - be opened with GENERIC_EXECUTE access. Call fstat_by_handle instead of - fstat to avoid overhead. - -2007-09-18 Corinna Vinschen - - * security.cc (set_file_sd): Open file with FILE_OPEN_FOR_BACKUP_INTENT - too. - -2007-09-17 Corinna Vinschen - - * path.cc (symlink_info::check): Check for STATUS_OBJECT_NAME_INVALID. - Add comment. - -2007-09-17 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Partly revert change from - 2007-08-24: Call has_acls to avoid permission problems getting - a handle to a file on a remote share. Add comment. - -2007-09-08 Brian Dessent - - * include/cygwin/config.h: Conditionalize inline __getreent() - definition on _COMPILING_NEWLIB. - -2007-09-06 Brian Dessent - - * include/cygwin/config.h (__getreent): Define inline version. - -2007-09-06 Brian Dessent - - * include/sys/stdio.h (_flockfile): Don't try to lock a FILE - that has the __SSTR flag set. - (_ftrylockfile): Likewise. - (_funlockfile): Likewise. - -2007-08-24 Corinna Vinschen - - * syscalls.cc (open): Don't follow symlinks if O_EXCL is given. - -2007-08-23 Corinna Vinschen - - * ntdll.h (STATUS_NO_SUCH_FILE): Define. - * path.cc (get_nt_native_path): Reset upath.Length to 0 on each - invocation. - (symlink_info::check): Use NT native functions. - -2007-08-21 Corinna Vinschen - - * uinfo.cc (pwdgrp::load): Use NT native functions. - -2007-08-21 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::fstat_helper): Rewrite checking - for executable file magic using a thread safe method and re-enable this - code. - -2007-08-21 Corinna Vinschen - - * syscalls.cc (unlink_nt): Drop one local FILE_BASIC_INFORMATION struct. - -2007-08-21 Corinna Vinschen - - * ntdll.h (NtNotifyChangeDirectoryFile): Declare. - (NtQueryAttributesFile): Move to maintain alphabetical order of - declarations. Add comment to note that timestamp information returned - by NtQueryAttributesFile is unreliable. - * path.h (etc::changed_h): Move here. - (etc::fn): Change type to OBJECT_ATTRIBUTES. - (etc::last_modified): Change type to LARGE_INTEGER. - (etc::init): Take PUNICODE_STRING as second argument. - * path.cc: Accomodate above changes. - (etc::test_file_change): Use NT native functions. - (etc::dir_changed): Ditto. - * uinfo.cc (pwdgrp::load): Call etc::init with NT native path. - -2007-08-21 Corinna Vinschen - - * fhandler_disk_file.cc: Change debugging output througout to print - the NT status consistently. Use UNICODE path information if available. - -2007-08-20 Corinna Vinschen - - * hookapi.cc (ld_preload): Call LoadLibraryW. - * path.h (path_conv::get_wide_win32_path_len): Define. - -2007-08-20 Corinna Vinschen - - * fhandler.cc (rootdir): Delete. - * winsup.h (rootdir): Drop declaration. - -2007-08-19 Corinna Vinschen - - * path.cc (fillout_mntent): Append backslash to drive-only paths before - calling fs_info::update. - * path.h (fs_info::clear): Simplify. - (fs_info::fs_info): Add constructor. - -2007-08-17 Corinna Vinschen - - * spawn.cc (spawn_guts): Fix typo in comment. - -2007-08-17 Corinna Vinschen - - * autoload.cc (CloseDesktop): Define. - (CreateDesktopA): Define. - (SetThreadDesktop): Define. - * spawn.cc (spawn_guts): When starting a process under another user - account, don't open up permissions on current window station and - desktop. Instead, if not in interactive session, create a new per-user - window station plus default desktop and use that for the child process. - -2007-08-16 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Handle S_IFSOCK - mode bit by setting the SYSTEM attribute. - * fhandler_socket.cc (fhandler_socket::fchmod): Add S_IFSOCK mode bit - when calling fhandler_disk_file::fchmod. Don't set attributes here. - -2007-08-16 Corinna Vinschen - - * path.h (path_conv::operator char *): Delete. - (path_conv::operator const char *): Delete. - * dlfcn.cc: Throughout, replace path_conv::operator char * and - path_conv::operator const char * by call to path_conv::get_win32 - for easier transition to UNICODE_PATHs. - * fhandler_socket.cc: Ditto. - * hookapi.cc: Ditto. - * path.cc: Ditto. - * spawn.cc: Ditto. - * syscalls.cc: Ditto. - * uinfo.cc: Ditto. - -2007-08-16 Corinna Vinschen - - * dir.cc (readdir_worker): Convert w32name to PUNICODE_STRING. - * sec_acl.cc (getacl): Convert debug output to print native NT path. - * security.cc (set_file_attribute): Ditto. - * syscalls.cc (try_to_bin): Ditto and fix buggy debug statement. - -2007-08-16 Corinna Vinschen - - * ntdll.h (RtlAcquirePebLock): Declare. - (RtlReleasePebLock): Declare. - * path.cc (cwdstuff::set): Change PEB only while it's locked. - -2007-08-16 Corinna Vinschen - - * fhandler.h (fhandler_base::get_namehash): Use NT native path. - * fhandler_disk_file.cc (readdir_get_ino): Ditto in call to - hash_path_name. - -2007-08-16 Corinna Vinschen - - * ntdll.h (RtlCreateUnicodeStringFromAsciiz): Fix declaration. - (RtlUpcaseUnicodeChar): Declare. - * path.cc (hash_path_name): Split into three functions, taking - the path as char *, PWCSTR, or PUNICODE_STRING. Move implementation - into PUNICODE_STRING-based function. Drop old drive-relative path - consideration. - * winsup.h (iswdirsep): Like isdirsep but for WCHARs. - (isabspath_u): Like isabspath, for PUNICODE_STRINGs. - (iswabspath): Like isabspath, for PWCHARs. - (hash_path_name): Add new declarations. - -2007-08-15 Corinna Vinschen - - * path.cc (get_nt_native_path): Allow to convert special paths which - have no native NT path representation for simplified debug output. - * syscalls.cc: Convert debug output to print native NT path. - (unlink): Drop redundant debug output. - -2007-08-15 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::link): Drop superfluous - test for trailing dot. - * path.h (path_conv::operator []): Remove. - -2007-08-15 Corinna Vinschen - - * fhandler_socket.cc (get_inet_addr): Use NT native functions for - accessing the file representing the local socket. - (fhandler_socket::bind): Ditto. - * ntdll.h: Declare NtReadFile. - -2007-08-14 Corinna Vinschen - - * path.cc (symlink_info::check): In case of ERROR_SHARING_VIOLATION and - ERROR_ACCESS_DENIED, try to get file attributes by using directory - functions. - -2007-08-14 Corinna Vinschen - - * path.cc (fs_info::update): Correctly handle the volume root directory. - -2007-08-14 Corinna Vinschen - - * fhandler.h (fhandler_base::pc): Make public. - * fhandler_disk_file.cc (fhandler_disk_file::link): Drop extern - declaration of stat_suffixes. Use NT native path in debug output. - (fhandler_base::utimes_fs): Simplify closeit case. Use close_fs - to close newly opened file handle. - (fhandler_base::open_fs): Use NT native path in debug output. - * path.cc: Throughout drop extern declaration of stat_suffixes. - * path.h (stat_suffixes): Declare. - * sec_acl.cc (acl_worker): Drop extern declaration of stat_suffixes. - * times.cc (utimes_worker): Take path_conv as parameter instead of - single-byte pathnam, drop nofollow argument, accommodate throughout. - Compare UNICODE paths when enumerating file descriptors. Fix - formatting. Use NT native path in debug output. - -2007-08-13 Corinna Vinschen - - * mmap.cc: Call NtClose instead of CloseHandle throughout. - (CreateMapping): Drop unused last argument. Accommodate throughout. - (mmap64): Re-open file with execute permissions using NtOpenFile. - -2007-08-13 Corinna Vinschen - - * fhandler.h (fhandler_base::close_fs): Reintroduce (as inline function) - for clearness. - * fhandler_disk_file.cc (fhandler_base::fstat_fs): Revert previous - change. - (fhandler_base::open_fs): Ditto. - * fhandler_socket.cc (fhandler_socket::close): Ditto. - -2007-08-13 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Remove delqueue.o. - * delqueue.cc: Delete. - * fhandler.h (fhandler_base::close_fs): Drop declaration. - (fhandler_disk_file::close): Drop declaration. - * fhandler_disk_file.cc (fhandler_base::fstat_fs): Call close instead of - close_fs. - (fhandler_base::fstat_helper): Use open FH_UNIX handle in call to - get_file_attribute. - (fhandler_base::open_fs): Call close instead of get_file_attribute. - (fhandler_disk_file::close): Remove. - (fhandler_base::close_fs): Remove. - * fhandler_socket.cc (fhandler_socket::close): Just call - fhandler_base::close for FH_UNIX sockets. - * shared.cc (user_shared_initialize): Drop call to - user_shared->delqueue.init. - * shared_info.h (CURR_USER_MAGIC): Change according to below change. - (MAX_DELQUEUES_PENDING): Remove. - (class delqueue_list): Remove. - (class user_info): Remove delqueue. - * syscalls.cc (close_all_files): Drop call to - user_shared->delqueue.process_queue. - (unlink): Drop delqueue handling. - -2007-08-13 Corinna Vinschen - - * devices.in (dev_storage): Use native NT device name for kmsg mailslot. - * devices.cc: Regenerate. - * fhandler.cc (fhandler_base::operator =): Use path_conv assignment - operator. - (fhandler_base::set_name): Ditto. - (fhandler_base::open): Use NT native path in debug output. - * fhandler_mailslot.cc: Convert to NT native function calls. - * ntdll.h (struct _FILE_MAILSLOT_SET_INFORMATION): Define. - (NtCreateMailslotFile): Declare. - * path.cc (path_conv::set_normalized_path): Don't set wide_path to NULL. - (path_conv::set_name): Remove unused function. - * path.h (path_conv::set_name): Drop declaration. - (path_conv::operator =): Define. - -2007-08-12 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Remove HIDDEN_DOT_FILES code. - * fhandler_disk_file.cc (fhandler_disk_file::mkdir): Ditto. - * path.cc (symlink_worker): Ditto. - -2007-08-12 Corinna Vinschen - - * syscalls.cc (getw): Remove redundant implementation. - (putw): Ditto. - (wcscmp): Ditto. - (wcslen): Ditto. - (memccpy): Ditto. - -2007-08-12 Corinna Vinschen - - * ntdll.h: Add descriptive comments to special Rtl functions. - (STATUS_OBJECT_PATH_NOT_FOUND): Define. - (STATUS_BUFFER_OVERFLOW): Define. - (FILE_SUPERSEDED): Define. - (FILE_OPENED): Define. - (FILE_CREATED): Define. - (FILE_OVERWRITTEN): Define. - (FILE_EXISTS): Define. - (FILE_DOES_NOT_EXIST): Define. - (PIO_APC_ROUTINE): Typedef. - (NtFsControlFile): Fix parameter types to use PIO_APC_ROUTINE. - (NtWriteFile): Declare. - (RtlInt64ToHexUnicodeString): Declare. - * strfuncs.cc: Include ntdll.h. - (RtlInt64ToHexUnicodeString): New function. - * syscalls.cc (try_to_bin): Rewrite using native NT functions. - Only try to create recycle bin after unsuccessfully trying to move - file. Also try to create special files in recycle bin so that Windows - Explorer isn't unnecessarily stampeded. - -2007-08-10 Corinna Vinschen - - * path.cc (fillout_mntent): Fix calculation of unicode buffer size. - -2007-08-10 Corinna Vinschen - - * syscalls.cc (rename): Check oldpath and newpath for trailing dir - separators, require them to be existing directories if so. Check - for a request to change only the case of the filename. Check paths - for case insensitve equality only once. Handle renaming a directory - to another, existing directory by unlinking the destination directory - first. If newpath points to an existing file with R/O attribute set, - try to unset R/O attribute first. Augment hardlink test by not - checking directories. If renaming fails with STATUS_ACCESS_DENIED, - try to unlink existing destination filename and try renaming again. - Drop useless test for non-empty directory. Always close fh at the - end of the function. - -2007-08-09 Ernie Coskrey - - * gendef (sigbe): Reset "incyg" while the stack lock is active to avoid - a potential race. - -2007-08-09 Corinna Vinschen - - * syscalls.cc (rename): Close oldpath file handle immediately after - trying to rename it. Use nfh handle when checking for non-empty - newpath directory. Only change status if check_dir_not_empty really - returns STATUS_DIRECTORY_NOT_EMPTY. - -2007-08-02 Corinna Vinschen - - * fhandler_disk_file.cc (readdir_get_ino): Accommodate native symlinks. - * syscalls.cc (rename): Ditto. - -2007-08-02 Christopher Faylor - - * lib/Makefile: Add missed file to accommodate below changes. - -2007-08-02 Christopher Faylor - - * lib/cygwin_attach_dll.c: Fix compiler warning. - * lib/cygwin_crt0.c: Ditto. - -2007-08-02 Christopher Faylor - - * dcrt0.cc (codepage_type): Remove definition. - * strfuncs.cc: Move it here. New file with bits of miscfuncs.cc. - * miscfuncs.cc: Remove wide character stuff. - -2007-08-02 Corinna Vinschen - - * syscalls.cc (rename): Move and add text to comment about testing - oldpath and newpath referring to the same file. Test if oldpath - has more than one hardlink before opening oldpath (idea by Eric Blake). - Reorder test so that file id is tested before volume serial number. - -2007-08-02 Corinna Vinschen - - * path.h (struct fs_info): Drop root_len and name_hash members. - (fsinfo::length): Remove. - (path_conv::rootdir): Remove. - * syscalls.cc (try_to_bin): Use rootdir function instead of - path_conv::rootdir method. - -2007-08-02 Corinna Vinschen - - * fhandler_disk_file.cc (path_conv::ndisk_links): Fix typo in call to - NtClose. - -2007-08-01 Corinna Vinschen - - * syscalls.cc (rename): Check if oldpath and newpath refer to the - same file. If so, return successfully and perform no other action, - as per SUSv3. - -2007-08-01 Corinna Vinschen - - * ntdll.h (STATUS_ACCESS_DENIED): Define. - * syscalls.cc (check_dir_not_empty): New static function. - (unlink_nt): Move code checking for non-empty dir to check_dir_not_empty - and call check_dir_not_empty instead. - (rename): Add fault handler. Check oldpath and newpath for trailing - . and .. path components and return EINVAL if so. Check oldpath - for being on a vrtual file system. If renaming a dir fails with - STATUS_ACCESS_DENIED, check if the target dir is non-empty and return - ENOTEMPTY if so. - -2007-08-01 Corinna Vinschen - - * localtime.cc (tzsetwall): Don't set TZ. - -2007-08-01 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Drop - usage of path_conv::volser(). - (fhandler_base::fstat_by_name): Ditto. - * ntdll.h (STATUS_NO_MEDIA_IN_DEVICE): Define. - (STATUS_OBJECT_NAME_NOT_FOUND): Define. - (FILE_REMOVABLE_MEDIA, FILE_READ_ONLY_DEVICE, FILE_FLOPPY_DISKETTE) - (FILE_WRITE_ONCE_MEDIA, FILE_REMOTE_DEVICE, FILE_DEVICE_IS_MOUNTED) - (FILE_VIRTUAL_VOLUME, FILE_AUTOGENERATED_DEVICE_NAME) - FILE_DEVICE_SECURE_OPEN): Define Device Characteristics. - (struct _FILE_FS_DEVICE_INFORMATION): Define. - * path.cc (MAX_FS_INFO_CNT): Remove. - (fsinfo): Remove. - (fsinfo_cnt): Remove. - (fs_info::update): Rewrite using native NT functions. Drop fs_info - cashing since it's incorrect. - (path_conv::fillin): Use NtQueryInformationFile. Drop setting serial - number. - (path_conv::check): Accommodate new fs_info::update parameters. - (fillout_mntent): Ditto. - * path.h (fs_info): Drop serial, has_ea and drive_type status - flags. - (fs_info::update): Declare with new parameters. - (path_conf::drive_type): Remove. - (path_conf::fs_has_ea): Remove. - (path_conf::volser): Remove. - -2007-08-01 Corinna Vinschen - - * fhandler.cc (check_posix_perms): Remove. - (fhandler_base::fpathconf): Return value of pc.has_acls () instead - of calling check_posix_perms. - -2007-08-01 Corinna Vinschen - - * syscalls.cc (rename): Use unchanged path_conv in condition. - -2007-08-01 Corinna Vinschen - - * smallprint.cc (__small_vsprintf): Add format specifier 'W' for - PWCHAR arguments. Move wide char handling after char handling. - -2007-07-31 Corinna Vinschen - - * ntdll.h (RtlFreeAnsiString): Declare. - * ntdll.h (RtlFreeOemString): Declare. - * ntdll.h (RtlUnicodeStringToAnsiString): Declare. - * ntdll.h (RtlUnicodeStringToOemString): Declare. - * smallprint.cc: Renamed from smallprint.c. Drop unnecessary - forward declarations. - (__small_vsprintf): Add format specifiers 'C' for WCHAR arguments - and 'S' for PUNICODE_STRING arguments. - -2007-07-31 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::link): Revert to checking - for binary in case of .exe files. - * ntdll.h (RtlPrefixUnicodeString): Declare. - * path.cc (path_conv::is_binary): New method. - * path.h (path_conv::is_binary): Declare. - * syscalls.cc (rename_append_suffix): New static helper function for - rename. - (rename): Rewrite. New suffix tests. Use native NT functions. - -2007-07-30 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::facl): If file can't be - opened for reading the ACLs, fall back to faking them. - * sec_acl.cc (acl_worker): Handle non-existing files. - * security.cc (get_file_attribute): Return ILLEGAL_UID/ILLEGAL_GID - as owner/group for non-readable ACLs on file systems supporting them. - -2007-07-30 Corinna Vinschen - - * syscalls.cc (stat_worker): Don't call build_fh_pc with invalid pc. - -2007-07-29 Christopher Faylor - - * fhandler.cc (fhandler_base::wait_overlapped): Handle read EOF better - and issue a SIGPIPE when we get ERROR_NO_DATA. - -2007-07-29 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Don't allow - FileAttributes set to 0 when calling NtSetInformationFile since it has - a special meaning. - (fhandler_disk_file::facl): Ditto. - (fhandler_disk_file::link): Only set attributes after copying files. - Use SetFileAttributesW. - * syscalls.cc (unlink_nt): Only care for actual FILE_ATTRIBUTE_READONLY. - Don't allow FileAttributes set to 0 when calling NtSetInformationFile. - After marking for deletion, restore R/O attribute on files to - accommodate hardlinks. - -2007-07-29 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::link): Use FILE_ANY_ACCESS. - (fhandler_base::utimes_fs): Fix white space. - (fhandler_disk_file::lock): Remove 9x blurb from comment. - (fhandler_disk_file::mkdir): Use NtCreateFile/NtClose instead of - CreateDirectoryA. - (fhandler_disk_file::rmdir): Accommodate changes to unlink_nt. - Simplify post-delete SMB-related tests. Use NtQueryAttributesFile - instead of GetFileAttributes. - * ntdll.h (STATUS_DIRECTORY_NOT_EMPTY): Define. - (NtQueryAttributesFile): Declare. - * syscalls.cc (unlink_nt): Return NTSTATUS. Drop setattrs parameter. - Never use FILE_DELETE_ON_CLOSE, always use - NtSetInformationFile(FileDispositionInformation) instead. - Check for R/O attributes and open file with FILE_WRITE_ATTRIBUTES - access if any of them are set. Remove R/O attributes before - marking for delete if necessary. Revert them afterwards if necessary. - (unlink): Accommodate changes to unlink_nt. - -2007-07-29 Corinna Vinschen - - * fhandler_disk_file.cc: Use get_handle throughout. - (fhandler_disk_file::fchmod): Always try to open file with required - access rights. Use NtSetInformationFile instead of SetFileAttributes. - (fhandler_disk_file::facl): Use NtSetInformationFile instead of - SetFileAttributes. - (fhandler_base::utimes_fs): Change lastaccess and lastwrite to - LARGE_INTEGER. Drop 9x directory case. Use NtSetInformationFile - instead of SetFileAttributes. Drop temporarily changing R/O attribute - since NtSetInformationFile(FileBasicInformation) also works on R/O - files. - * ntdll.h (STATUS_NOT_SUPPORTED): Define. - -2007-07-29 Christopher Faylor - - * cygtls.h (_cygtls::inside_kernel): Move function declaration into - _cygtls class. - * exceptions.cc (_cygtls::inside_kernel): Move function definition into - _cygtls class. - - * fhandler.cc (fhandler_base::wait_overlapped): Make return tri-state - to detect when there is a EINTR situation. Add a pointer to a length - parameter. Move GetOverlappedResult into this function. - (fhandler_base::read_overlapped): Accommodate above changes and loop if - we receive a restartable signal. - (fhandler_base::write_overlapped): Ditto. - * fhandler.h (fhandler_base::wait_overlapped): Reflect above changes. - * fhandler_fifo.cc (fhandler_fifo::wait): Ditto. - -2007-07-28 Corinna Vinschen - - * ntdll.h (RtlEqualUnicodePathPrefix): Rename from RtlEqualPathPrefix. - (RtlEqualUnicodePathSuffix): Rename from RtlEqualPathSuffix. - * fhandler_disk_file.cc (fhandler_disk_file::link): Accommodate above - change. - -2007-07-28 Corinna Vinschen - - * ntdll.h (RtlInitCountedUnicodeString): Swap order of string and length - parameters to be the same as for RtlInitEmptyUnicodeString. - (RtlEqualPathPrefix): New inline function. - (RtlEqualPathSuffix): New inline function. - * fhandler_disk_file.cc: Accommodate parameter order change of - RtlInitEmptyUnicodeString throughout. - (fhandler_disk_file::link): Do path checking in unicode. Call - CopyFileW instead of CopyFileA. - -2007-07-27 Corinna Vinschen - - * autoload.cc (CreateHardLinkA): Remove. - * fhandler_disk_file.cc (fhandler_disk_file::link): Drop GetBinaryType - test. Just check exe suffix instead. Tune creating new file name. - Implement creating hard link using native NT functions which works - on all platforms. - * ntdll.h (STATUS_INVALID_DEVICE_REQUEST): Define. - (struct _FILE_LINK_INFORMATION): Define. - -2007-07-27 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::ftruncate): Use - NtQueryInformationFile instead of GetFileSize, NtFsControlFile instead - of DeviceIoControl. - -2007-07-27 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::fstat_by_name): Use - RtlSplitUnicodePath. - (fhandler_disk_file::fstat): Rename oret to opened. Open file using NT - functions right here. Try to open parent dir instead of root directory - to avoid call to rootdir. Use NtFsControlFile. - * ntdll.h (RtlSplitUnicodePath): Define. - -2007-07-27 Corinna Vinschen - - * fhandler_disk_file.cc (is_volume_mountpoint): New static inline - function. - (path_conv::ndisk_links): Call is_volume_mountpoint. - (fhandler_disk_file::readdir_helper): Ditto. - -2007-07-27 Corinna Vinschen - - * fhandler.h (enum query_state): Drop redundant query_stat_control. - * fhandler.cc (fhandler_base::open): Ditto. Add READ_CONTROL to - access and FILE_OPEN_FOR_BACKUP_INTENT to create_options when opening - for writing. Always set security attributes to avoid calling - has_acls. - * fhandler_disk_file.cc (fhandler_base::fstat_fs): Don't try to - open file twice. - -2007-07-26 Corinna Vinschen - - * dir.cc (readdir_worker): Drop dir parameter from call to - readdir_get_ino. - * fhandler.h (fhandler_disk_file::readdir_helper): Switch file name - parameter to PUNICODE_STRING. - * fhandler_disk_file.cc: Drop including ntdef.h. - (class __DIR_mounts): Store mount points in UNICODE. Additionally - store cygdrive prefix in unicode here. Change methods accordingly. - (__DIR_mounts::eval_ino): Call new stat_worker instead of lstat64. - (__DIR_mounts::~__DIR_mounts): New destructor to free UNICODE buffers. - (path_conv::ndisk_links): Rewrite using native NT functions. - (fhandler_base::fstat_by_handle): Use NAME_MAX instead of CYG_MAX_PATH. - Always set pfvi->VolumeSerialNumber to non-0. Remove last resort - code. - (fhandler_base::fstat_by_name): Rewrite using native NT functions. - (fhandler_base::fstat_fs): Always call fstat_by_name if fstat_by_handle - fails. - (fhandler_base::fstat_helper): Rely on dwVolumeSerialNumber. - (fhandler_disk_file::facl): Call fstat_by_name if fstat_by_handle fails. - (DIR_BUF_SIZE): Define using NAME_MAX instead of CYG_MAX_PATH. - (__DIR_cache): Remove __name. - (d_dirname): Remove. - (fhandler_disk_file::opendir): Drop pathname length check. - Remove outdated comment. Use get_name method instead of accessing - pc.normalized_path directly. - (readdir_get_ino): Drop unused dir parameter. Accomodate throughout. - Allocate fname dynamically. Call new stat_worker instead of lstat64. - Call NtOpenFile instead of CreateFile. Call NtClose instead of - CloseHandle. - (fhandler_disk_file::readdir_helper): Use native NT functions. - Check for volume mount points and use correct inode number. - (fhandler_disk_file::readdir): Simplify slightly. - Use get_name instead of pc.normalized_path. - (fhandler_disk_file::rewinddir): Use RtlInitUnicodeString. - (fhandler_cygdrive::fstat): Ignore floppy drives. Set st_nlink - correctly. - (fhandler_cygdrive::readdir): Ignore floppy drives. - * fhandler_netdrive.cc (fhandler_netdrive::readdir): Accommodate - change to readdir_get_ino. - * fhandler_proc.cc (PROC_DIR_COUNT): Define. - (fhandler_proc::fstat): Evaluate correct link count for /proc. - * ntdll.h (struct _FILE_DIRECTORY_INFORMATION): Define. - (NtFsControlFile): Declare. - (RtlAppendUnicodeToString): Declare. - (RtlAppendUnicodeStringToString): Declare. - (RtlCompareUnicodeString): Declare. - (RtlCopyUnicodeString): Declare. - (RtlCreateUnicodeStringFromAsciiz): Declare. - (RtlEqualUnicodeString): Declare. - (RtlFreeUnicodeString): Declare. - (RtlInitEmptyUnicodeString): Declare. - (RtlSecondsSince1970ToTime): Declare. - (RtlInitEmptyUnicodeString): Define as inline function. - (RtlInitCountedUnicodeString): Define as inline function. - * path.cc (path_conv::check): New method with PUNICODE_STRING as path, - preliminary implementation. - (mount_info::get_mounts_here): Change to create UNICODE_STRINGs. - Also copy cygpath prefix into UNICODE_STRING. - (is_floppy): Drop 9x consideration. - * path.h: Drop including ntdef.h. - (path_conv::check): Add declaration. - (path_conv::path_conv): Add constructor for UNICODE_STRING paths. - * shared_info.h (mount_info::get_mounts_here): Change declaration. - * syscalls.cc: Drop forward declaration of stat_worker. - (stat_worke): Take path_conv as parameter. Drop nofollow flag. - (stat64): Create matching path_conv and call stat_worker with it. - (lstat64): Ditto. - * winsup.h: Include ntdef.h. - (stat_worker): Declare. - (readdir_get_ino): Change declaration. - -2007-07-25 Corinna Vinschen - - * autoload.cc (CreateToolhelp32Snapshot): Remove. - -2007-07-25 Corinna Vinschen - - * autoload.cc (Process32First): Remove. - (Process32Next): Remove. - -2007-07-25 Corinna Vinschen - - * autoload.cc (NetWkstaUserGetInfo): Remove. - (CharToOemBuffA): Remove. - (KillTimer): Remove. - (OemToCharBuffA): Remove. - (SetTimer): Remove. - -2007-07-20 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Add sec_auth.o. - * fhandler.cc (fhandler_base::fhaccess): Accommodate interface changes - of access control functions throughout. - * fhandler_disk_file.cc: Ditto. - * fhandler_registry.cc: Ditto. - * sec_acl.cc: Drop unnecessary includes. - (setacl): Take path_conv instead of file name as parameter. - Accommodate interface changes of access control functions. - (getacl): Ditto. - * sec_auth.cc: New file, taking over all authentication related - functions from security.cc. - * sec_helper.cc: Drop unnecessary includes. - * security.cc: Ditto. Move all authentication related functions to - sec_auth.cc. - (ALL_SECURITY_INFORMATION): New define. Use throughout. - (set_file_sd): New function, replacing read_sd and the file related - part of get_nt_object_security. - (get_reg_sd): Rename from get_reg_security. Drop type parameter. - (get_reg_attribute): New function, replacing the registry related part - of get_nt_object_security. - (get_file_attribute): Take path_conv instead of file name as parameter. - Use new get_file_sd call. - (set_file_attribute): Ditto plus new set_file_sd. Drop unnecessary - implementation without uid/gid parameters. - (check_file_access): Take path_conv instead of file name as parameter. - Use new get_file_sd call. - (check_registry_access): Use new get_reg_sd call. - * security.h: Accommodate above interface changes. - -2007-07-19 Corinna Vinschen - - * security.cc (set_nt_attribute): Remove. - (set_file_attribute): Do it yourself instead of calling - set_nt_attribute. - -2007-07-19 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::fstat_by_name): Use - NtQueryFullAttributesFile instead of FindFirstFile. - (fhandler_base::fstat_fs): Drop check for exec_state. Drop check for - invalid characters. - * ntdll.h (struct _FILE_NETWORK_OPEN_INFORMATION): Define. - (NtQueryFullAttributesFile): Declare. - -2007-07-19 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Drop local wpath and upath - variables. Call pc.get_object_attr to create object attributes. - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Ditto. - * syscalls.cc (unlink_nt): Ditto. - * path.cc (path_conv::set_normalized_path): Set wide_path to NULL. - (path_conv::get_nt_native_path): Drop parameter. Create path in - wide_path/uni_path members. - (path_conv::get_object_attr): New method to create object attributes. - (path_conv::get_wide_win32_path): New method to create Win32 wide path. - (path_conv::check): Initialize wide_path to NULL. - (path_conv::~path_conv): cfree wide_path. - * path.h (class path_conv): New members wide_path and uni_path. - Add declarations of get_object_attr and get_wide_win32_path. - (path_conv::path_conv): Initialize wide_path to NULL. - (path_conv::get_nt_native_path): Drop parameter. - -2007-07-19 Corinna Vinschen - - * sec_helper.cc: Remove unused code. - -2007-07-19 Corinna Vinschen - - * autoload.cc (SetSecurityDescriptorControl): Drop. - * security.cc (alloc_sd): Set security descriptor control flag without - calling SetSecurityDescriptorControl function. - * wincap.h (wincapc::has_dacl_protect): Rename from - has_security_descriptor_control. - * wincap.cc: Ditto throughout. - -2007-07-19 Corinna Vinschen - - * autoload.cc (SetUserObjectSecurity): Drop. - * pinfo.cc (pinfo::set_acl): Use NtSetSecurityObject instead of - SetKernelObjectSecurity. - * spawn.cc (spawn_guts): Use NtSetSecurityObject instead of - SetUserObjectSecurity. - * uinfo.cc (cygheap_user::init): Ditto. - -2007-07-19 Corinna Vinschen - - * cygheap.h (init_cygheap::luid): Remove. - * mmap.cc (mlock): Accommodate parameter change in call to - push_thread_privilege. - (munlock): Ditto. - * ntdll.h (STATUS_NOT_ALL_ASSIGNED): Define. - (NtAdjustPrivilegesToken): Declare. - * sec_helper.cc (cygpriv): Reorder to match numerical privilege order. - (privilege_luid): Take job of privilege_luid_by_name, using new - cygpriv. - (privilege_luid_by_name): Remove. - (privilege_name): Accommodate new cygpriv array. - (set_privilege): Call NtAdjustPrivilegesToken to avoid using advapi32. - Accommodate changes to privilege_name. - (set_cygwin_privileges): Simplify. Don't try to set - SE_CREATE_GLOBAL_PRIVILEGE on systems not supporting it. - * security.cc (sys_privs): Reorder to match numerical privilege order. - Use real privilege values as defined in security.h. - (get_system_priv_list): Drop unused grp_list argument. Create - list of privileges according to new wincapc::max_sys_priv value. - (get_priv_list): Call privilege_luid instead of privilege_luid_by_name. - Make priv a local value instead of a pointer. - (create_token): Accommodate parameter change in call to - push_self_privilege. - (lsaauth): Ditto. - (check_access): Use privilege values directly instead of calling - privilege_luid. - * security.h: Define real privilege values. - (cygpriv_idx): Remove. - (privilege_luid): Change declaration. - (privilege_luid_by_name): Drop declaration. - (set_privilege): Change declaration. - (set_process_privilege): Drop definition. - (_push_thread_privilege): Accomodate new set_privilege parameters. - * wincap.h (wincapc::max_sys_priv): New element. - * wincap.cc: Implement above element throughout. - (wincap_2000sp4): New wincaps structure. - (wincap_xpsp1): Ditto. - (wincap_xpsp2): Ditto. - (wincapc::init): Use new wincaps. - (wincapc::max_sys_priv): New element. - -2007-07-19 Corinna Vinschen - - * dcrt0.cc (dll_crt0_0): Call set_cygwin_privileges here, after - initializing hProcToken. - * sec_helper.cc (init_global_security): Don't call set_cygwin_privileges here. - -2007-07-18 Corinna Vinschen - - * cygheap.h (shared_prefix): De-const. - (shared_prefix_buf): Add static buffer for shared prefix to avoid - additional allocation. - * cygheap.cc (cygheap_init): Set cygheap->shared_prefix to - cygheap->shared_prefix_buf and strcpy. - -2007-07-17 Corinna Vinschen - - * fhandler.cc (fhandler_base::fhaccess): Add check for R/O file system. - * security.cc (check_registry_access): Set errno to EROFS when checking - for W_OK. - -2007-07-17 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Move setting - cfd->nohandle where it won't crash. - -2007-07-16 Corinna Vinschen - - * cygheap.h (cygheap_user::curr_imp_token): Rename from current_token. - Accommodate change throughout Cygwin. - (cygheap_user::imp_token): Rename from token. Accommodate change - throughout Cygwin. - (rcygheap_user::eimpersonate): Use primary token for impersonation. - * grp.cc (internal_getgroups): Use primary impersonation token when - impersonated. - * security.h (_push_thread_privilege): Use primary impersonation token - when impersonated. - -2007-07-14 Christopher Faylor - - * init.cc (in_dllentry): Delete. - (dll_entry): Remove assignment to deleted variable. - * winsup.h (in_dllentry): Delete declaration. - * exceptions.cc (inside_kernel): Use another method to see if we are in - dll_entry phase. - -2007-07-13 Christopher Faylor - - * init.cc (in_dllentry): Make NO_COPY to avoid spurious false - positives. - -2007-07-09 Christopher Faylor - - * debug.cc (close_handle): Change debug output format slightly. - - * dlfcn.cc (dlclose): Don't close handle returned from - GetModuleHandle(NULL). - - * fhandler.h (fhandler_pipe::create): Remove obsolete argument. - (fhandler_pipe::create): Ditto. - * fhandler.cc (fhandler_pipe::create): Ditto. - (fhandler_pipe::create): Ditto. - -2007-07-09 Christopher Faylor - - * strsig.cc (__signals): New macro. - (sys_sigabbrev): New array of signal strings, patterned after linux. - (siglist): Use __signals. - * include/cygwin/signal.h (sys_sigabbrev): Define. - * include/cygwin/version.h: Bump API minor version to 177. - -2007-07-09 Corinna Vinschen - - * dir.cc (closedir): Revert change from 2007-06-29. - * fhandler.h (dirent_valid_fd): Drop. - * fhandler_disk_file.cc (fhandler_disk_file::opendir): If opening a - real dir, use the underlying fhandler to keep track of the directory - handle. In fdopendir case use original io_handle from fhandler. Use - fhandler's io_handle in subsequent directory functions throughout. - Create handle non-inheritable and set close-on-exec flag. - (readdir_get_ino): Drop dirent_isroot case. - (fhandler_disk_file::readdir): Handle dirent_isroot case here. - (fhandler_disk_file::rewinddir): Revert change from 2007-07-05. Use - NtClose instead of CloseHandle. - * fhandler_virtual.cc (fhandler_virtual::opendir): Drop adding - dirent_valid_fd flag. Set close-on-exec flag. - -2007-07-08 Christopher Faylor - - * Makefile.in (DLL_OFILES): Add newly-imported random.o. Eliminate - reliance on libiberty. - * random.cc: Import from FreeBSD. Modify for Cygwin environment. - * include/cygwin/stdlib.h (random): Reflect change in return value to - be more linux/freebsd-like. - (srandom): Ditto. - -2007-07-07 Christopher Faylor - - * fhandler.h (fhandler_base::write): Remove __stdcall decoration. - (fhandler_pipe::write): Ditto. - (fhandler_fifo::write): Ditto. - -2007-07-07 Christopher Faylor - - Preliminary change to make pipes interruptible and fifos reliable. - * dtable.cc (dtable::find_fifo): Eliminate definition. - * dtable.h (dtable::find_fifo): Ditto for declaration. - * fhandler.cc (fhandler_base::raw_read): Remove pipe-specific stuff. - (fhandler_base::fhandler_base): Ditto. - (fhandler_base::close): Handle overlapped I/O structure if appropriate. - (fhandler_base::dup): Ditto. - (fhandler_base::fork_fixup): Ditto. - (fhandler_base::setup_overlapped): Define new function. - (fhandler_base::destroy_overlapped): Ditto. - (fhandler_base::wait_overlapped): Ditto. - (fhandler_base::read_overlapped): Ditto. - (fhandler_base::write_overlapped): Ditto. - * fhandler.h (fhandler_base::get_overlapped): Declare new function. - (fhandler_base::setup_overlapped): Ditto. - (fhandler_base::destroy_overlapped): Ditto. - (fhandler_base::wait_overlapped): Ditto. - (fhandler_base::read_overlapped): Ditto. - (fhandler_base::write_overlapped): Ditto. - (fhandler_base::get_guard): Eliminate. - (fhandler_pipe::*): Rework to eliminate most Win9x related cruft, - removing many variables and defining a new overlapped capability. - (fhandler_fifo::*): Ditto. - (fifo_state): Declare new enum. - * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove old Win9x - stuff. Initialize overlapped handle to NULL. - (fhandler_fifo::set_use): Eliminate. - (fhandler_fifo::open_nonserver): Define. - (fhandler_fifo::open): Rework to use named pipes and overlapped I/O. - (fhandler_fifo::wait): Define new function to wait for named pipe - connection. - (fhandler_fifo::read): Rework to use wait() and new overlapped I/O - functionality. - (fhandler_fifo::write): Ditto. - (fhandler_fifo::dup): Eliminate. - * pinfo.cc (commune_process): Remove fifo handling. - (_pinfo::commune_request): Ditto. - * pinfo.h (picom): Ditto. - * pipe.cc (fhandler_pipe::fhandler_pipe): Remove Win9x stuff. - Initialize overlapped handle to NULL. - (fhandler_pipe::open): Eliminate Win9x stuff. - (fhandler_pipe::set_close_on_exec): Eliminate. - (read_pipe): Eliminate. - (fhandler_pipe::close): Ditto. - (fhandler_pipe::fixup_after_exec): Ditto. - (fhandler_pipe::fixup_in_child): Ditto. - (fhandler_pipe::read): Rework to use overlapped I/O. - (fhandler_pipe::write): New function using overlapped I/O. - (fhandler_pipe::dup): Rework to eliminate Win9x stuff. - (fhandler_pipe::create_selectable): Rework to eliminate Win9x and use - overlapped I/O. - * select.cc (peek_pipe): Rework to eliminate Win9x stuff and use - overlapped I/O. - (fhandler_base::ready_for_read): Ditto. - -2007-07-07 Christopher Faylor - - * path.cc (symlink_info::check_shortcut): Handle device "symlinks" - specially - don't posixify them. - -2007-07-07 Christopher Faylor - - * fhandler_disk_file.cc: White space. - * fhandler_proc.cc: Ditto. - * fhandler_virtual.cc: Ditto. - -2007-07-07 Christopher Faylor - - * fork.cc: White space. - * net.cc: Ditto. - * posix_ipc.cc: Ditto. - -2007-07-06 Corinna Vinschen - - * times.cc (gettimeofday): Align definition to POSIX. - -2007-07-06 Corinna Vinschen - - * cygwin.din: Export wcstol, wcstoll, wcstoul, wcstoull, wcsxfrm. - * include/cygwin/version.h: Bump API minor number. - -2007-07-05 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Add missing - OBJ_INHERIT flag when creating OBJECT_ATTRIBUTES. - (fhandler_disk_file::rewinddir): Ditto. - -2007-07-04 Corinna Vinschen - - * times.cc: Define __timezonefunc__ before including time.h to protect - definition of timezone function. - -2007-07-04 Corinna Vinschen - - * include/cygwin/time.h: Switch to timezone variable by default. Add - comment. - -2007-06-29 Corinna Vinschen - - * cygwin.din: Export fdopendir. - * dir.cc (opendir): Call fhandler's opendir with fd set to -1. - (fdopendir): New function. - (seekdir64): Use dirent_info_mask. - (rewinddir): Ditto. - (closedir): Only release underlying file descriptor if it has been - reserved by opendir itself. - * fhandler.cc (fhandler_base::opendir): Accommodate new parameter. - * fhandler.h (dirent_states): Add dirent_valid_fd and dirent_info_mask. - (fhander_XXX::opendir): Add file descriptor parameter. Use regparms. - (fhandler_procnet::opendir): Drop declaration. - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Ditto. - If called from fdopendir, use existing handle to re-open directory - with valid flags. Rename fd to cfd. Use only if no valid incoming fd. - (fhandler_cygdrive::opendir): Accommodate new parameter. - * fhandler_process.cc (fhandler_process::opendir): Ditto. - * fhandler_procnet.cc (fhandler_procnet::opendir): Drop definition. - * fhandler_virtual.cc (fhandler_virtual::opendir): Accommodate new - parameter. Only create new file descriptor entry if called from - opendir. Remove duplicated setting of dir->__flags. - * posix.sgml: Add fdopendir to list of implemented Solaris functions. - * include/cygwin/version.h: Bump API minor number. - * include/sys/dirent.h: Declare fdopendir. - -2007-06-28 Brian Dessent - - * include/cygwin/version.h: Fix comment typo. - -2007-06-28 Corinna Vinschen - - * cygwin.din: Export stpcpy, stpncpy. - * posix.sgml: Add stpcpy and stpncpy to list of implemented - GNU extensions. - * include/cygwin/version.h: Bump API minor number. - -2007-06-27 Corinna Vinschen - - * shared_info.h (SHARED_INFO_CB): Accommodate change to shared_info. - (CURR_SHARED_MAGIC): Ditto. - (class shared_info): Add heap_slop_inited member. - * shared.cc (shared_info::heap_slop_size): Use heap_slop_inited to - track initializing heap_slop since 0 is a valid value for heap_slop. - Drop useless < 0 consideration. - -2007-06-27 Eric Blake - - * assert.cc (__assert_func): New function, to match newlib header - change. - * cygwin.din: Export __assert_func. - * include/cygwin/version.h: Bump API minor number. - -2007-06-21 Corinna Vinschen - - * autoload.cc (WSAIoctl): Remove. - * cygwin.din: Export freeifaddrs, getifaddrs. - * fhandler_socket.cc (fhandler_socket::ioctl): Drop SOCKET parameter - from get_ifconf. - * net.cc: Include ifaddrs.h. - (in_are_prefix_equal): Match addresses in network byte order. - (ip_addr_prefix): Convert address into host byte order before - testing with IN_LOOPBACK. - (struct ifall): Define. - (get_xp_ifs): Replace get_xp_ifconf. Return struct ifall array. - (get_2k_ifs): Ditto, replace get_2k_ifconf. - (get_nt_ifs): Ditto, replace get_nt_ifconf. - (getifaddrs): New function. - (freeifaddrs): New function. - (get_ifconf): Call matching get_XX_ifs function and create - ifc content from here. Drop lo fake since it's now in get_nt_ifs. - * posix.sgml: Add freeifaddrs and getifaddrs to list of implemented - BSD functions. - * wincap.h (wincapc::has_broken_if_oper_status): New element. - * wincap.cc: Implement above element throughout. - * include/ifaddrs.h: New file. - * include/cygwin/version.h: Bump API minor number. - -2007-06-20 Eric Blake - - * cygwin.din: Export exp10, exp10f, pow10, pow10f, strcasestr, - funopen, fopencookie. - * include/cygwin/version.h: Bump API minor number. - * posix.sgml: Minor improvements. - -2007-06-20 Corinna Vinschen - - * include/cygwin/if.h (IFF_POINTOPOINT): Fix typo. - -2007-06-16 Christopher Faylor - - * include/search.h: Reinstate node_t definition. - -2007-06-16 Christopher Faylor - - * include/sys/cdefs.h: Remove in favor of newlib version. - -2007-06-14 Corinna Vinschen - - * autoload.cc (GetIpForwardTable): Define. - * fhandler_socket.cc (fhandler_socket::ioctl): Handle SIOCGIFDSTADDR. - * net.cc (get_routedst): New static function to get destination - address of point-to-point interfaces. - (get_xp_ifconf): Handle SIOCGIFDSTADDR. - (get_2k_ifconf): Ditto. - (get_nt_ifconf): Ditto. - (get_ifconf): Ditto. - * include/asm/socket.h (SIOCGIFDSTADDR): Define. - * include/cygwin/if.h (struct ifreq): Add ifru_dstaddr member. - (ifr_dstaddr): Define. - * include/cygwin/in.h: Cast ipv4 addresses correctly to in_addr_t in - definitions. - -2007-06-12 Christopher Faylor - - * signal.cc (usleep): Use useconds_t for the type as per POSIX. - -2007-06-12 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Add xsique.o. - * cygwin.din (confstr): Make NOSIGFE. - (insque): Export. - (remque): Export. - * lsearch.cc: Remove superfluous _SEARCH_PRIVATE define. - * posix.sgml: Move insque to defined SUSv3 interfaces. Remove - comment for remque. - * include/search.h: Remove _SEARCH_PRIVATE guarded definitions. - Add struct qelem definition. Add insque and remque declarations. - * include/cygwin/version.h: Bump API minor number. - * include/sys/queue.h: Remove insque/remque definitions so as not - to collide with SUSv3 compatible declaration in search.h. - * libc/xsique.cc: New file implementing insque and remque. - -2007-06-12 Corinna Vinschen - - * fhandler.cc (fhandler_base::fstat): Set pipe permission bits more - correctly. - -2007-06-11 Corinna Vinschen - - * cygwin.din (confstr): Export. - * posix.sgml (confstr): Move to list of implemented SUSv3 functions. - * sysconf.cc (confstr): Implement. - * include/cygwin/version.h: Bump API minor number. - -2007-06-05 Corinna Vinschen - - * ansi.sgml: Delete. - * misc-std.sgml: Delete. - * posix.sgml: Rework entirely. - -2007-05-29 Corinna Vinschen - - * dtable.cc (dtable::set_file_pointers_for_exec): Call SetFilePointer - correctly for 64 bit file access. Comment out functionality. - * fhandler.cc (fhandler_base::open): Don't set append_mode. - (fhandler_base::write): Check for O_APPEND instead of append_mode. - Call SetFilePointer correctly for 64 bit file access. Handle - errors from SetFilePointer. - * fhandler.h (class fhandler_base): Drop append_mode status flag. - * fhandler_disk_file.cc (fhandler_base::fstat_helper): Handle - seeking correctly for 64 bit file access. - -2007-05-22 Corinna Vinschen - - * path.cc (cwdstuff::set): Revert useless acquire check. - -2007-05-22 Corinna Vinschen - - * path.cc (cwdstuff::set): Avoid double aquiring of cwd_lock. - Open directory with inheriting enabled. - -2007-05-21 Christian Franke - - * fhandler_floppy.cc (fhandler_dev_floppy::lseek): Don't invalidate - devbuf if new position is within buffered range. - -2007-05-21 Eric Blake - - * include/search.h (hsearch_r): Provide declaration. - -2007-05-21 Christian Franke - Corinna Vinschen - - * fhandler_floppy.cc (fhandler_dev_floppy::lseek): Set buf size to - sector size. Simplify non-sector aligned case. Handle errors from - raw_read. - -2007-05-15 Corinna Vinschen - - * fhandler_socket.cc (adjust_socket_file_mode): New inline function. - (fhandler_socket::fchmod): Squeeze mode through adjust_socket_file_mode - before using it. - (fhandler_socket::bind): Ditto. - -2007-03-19 Ryan C. Gordon - - * path.cc (fs_info::update): Set and use is_cdrom. - * path.cc (fillout_mntent): Set ret.mnt_type to something more - Linux-like, based on data from fs_info. Move "system" and "user" - strings from mnt_type to mnt_opts. - * path.h (struct fs_info): Add is_cdrom field. - * path.h (fs_info::clear): Initialize is_cdrom. - * path.h (struct fs_info): Add IMPLEMENT_STATUS_FLAG(bool,is_cdrom). - * path.h (class path_conv): Add fs_is_cdrom method. Add missing - fs_is_netapp method. - -2007-05-14 Eric Blake - - * cygwin.din (asnprintf, dprint, _Exit, vasnprintf, vdprintf): Export. - * include/cygwin/version.h: Bump API minor number. - -2007-04-18 Brian Dessent - - * cygwin.sc: Remove duplicated .debug_macinfo section. - * dllfixdbg: Also copy DWARF-2 sections into .dbg file. - -2007-04-06 Eric Blake - - * include/stdint.h (WINT_MIN): Fix sign. - -2007-04-04 Eric Blake - - * include/stdint.h (WINT_MIN, WINT_MAX): Fix definition. - -2007-03-30 Christopher Faylor - - * external.cc (cygwin_internal): Implement CW_SET_DOS_FILE_WARNING. - * include/sys/cygwin.h: Define CW_SET_DOS_FILE_WARNING. - -2007-03-29 Corinna Vinschen - - * cygheap.cc (cygheap_init): Fix formatting. Remove comment. Set - shared_prefix depending only on terminal service capability. - * dcrt0.cc (dll_crt0_1): Don't call set_cygwin_privileges here. - * fhandler_fifo.cc (fhandler_fifo::open): Create the mutex as global - object. - * posix_ipc.cc (ipc_mutex_init): Use cygheap->shared_prefix. - (ipc_cond_init): Ditto. - * sec_helper.cc (privilege_name): Make static. Use LookupPrivilegeName - directly to be independent of the state of cygheap. - (set_privilege): Take a LUID as parameter instead of an index value. - Only print debug output in case of failure. - (set_cygwin_privileges): Add comment. Use LookupPrivilegeValue to - get privilege LUIDs. - (init_global_security): Call set_cygwin_privileges here. - * security.h (privilege_name): Drop declaration. - (set_privilege): Declare according to above change. - (set_process_privilege): Call privilege_luid to get LUID. - (_push_thread_privilege): Ditto. - * shared.cc (open_shared): Add comment. On systems supporting the - SeCreateGlobalPrivilege, try to create/open global shared memory first. - Fall back to local shared memory if that fails. - * thread.cc (semaphore::semaphore): Use cygheap->shared_prefix. - * wincap.h (wincapc::has_create_global_privilege): New element. - * wincap.cc: Implement above element throughout. - -2007-03-28 Christopher Faylor - - * spawn.cc (spawn_guts): Start pure-windows processes in a suspended - state to avoid potential DuplicateHandle problems. - -2007-03-13 Eric Blake - - * include/cygwin/stat.h (S_TYPEISMQ, S_TYPEISSEM, S_TYPEISSHM): - Avoid compiler warnings. - -2007-03-07 Christopher Faylor - - * signal.cc (handle_sigprocmask): Remove extraneous - sig_dispatch_pending. - -2007-03-07 Corinna Vinschen - - * fhandler_proc.cc: Fix formatting. Drop setting errno when creating - proc file content. - (format_proc_uptime): Simplify. - (format_proc_cpuinfo): Align more closely to output of Linux 2.6 kernel. - Evaluate more data, especially for AMD CPUs. - -2007-03-06 Corinna Vinschen - - * fhandler.h (fhandler_base::fstat_helper): Add creation time parameter. - * glob.cc (stat32_to_stat64): Set st_birthtim to st_mtim. - -2007-03-06 Corinna Vinschen - - * include/cygwin/stat.h (S_TYPEISMQ): Define. - (S_TYPEISSEM): Dttio. - (S_TYPEISSHM): Ditto. - -2007-03-06 Corinna Vinschen - - * fhandler_mailslot.cc (fhandler_mailslot::fstat): Set new stat member - st_birthtim to useful value. - * fhandler_process.cc (fhandler_process::fstat): Ditto. - * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Take - additional parameter for creation time. Fill st_birthtim with it. - Accomodate additional creation time parameter throughout. - * fhandler_raw.cc (fhandler_dev_raw::fstat): Set new stat member - st_birthtim to useful value. - * fhandler.cc (fhandler_base::fstat): Ditto. - * fhandler_registry.cc (fhandler_registry::fstat): Ditto. - * include/cygwin/version.h: Bump API minor number. - * include/cygwin/stat.h (struct __stat64): Replace st_spare4 with - timestruc_t st_birthtim. - (struct stat): Ditto if __CYGWIN_USE_BIG_TYPES__ is defined. - (st_birthtime): Define if __CYGWIN_USE_BIG_TYPES__ is defined. - -2007-03-02 Corinna Vinschen - - * ntdll.h (struct _FILE_NAMES_INFORMATION): Define. - * syscalls.cc (unlink_nt): Check shared directory for being empty - before trying to move and mark for deletion. - -2007-03-02 Corinna Vinschen - - * security.cc (get_file_attribute): Avoid compiler warning. - -2007-03-01 Christopher Faylor - - * fork.cc (fork): Reset child to true after fork since it may have been - reset by fork memory copies. - -2007-03-01 Christopher Faylor - - * Makefile (DLL_OFILES): Remove ntea.o - * environ.cc (set_ntea): Delete. - (parse_thing): Delete "ntea" setting. - * fhandler.cc (fhandler_base::open): Remove allow_ntea considerations. - (check_posix_perm): Ditto. - * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Ditto. - (fhandler_base::open_fs): Ditto. - (fhandler_disk_file::mkdir): Ditto. - * path.cc (symlink_worker): Ditto. - * security.cc (get_file_attribute): Ditto. - (set_file_attribute): Ditto. - * security.h: Remove allow_ntea declaration. - -2007-02-27 Corinna Vinschen - - * path.cc (close_user_proc_parms_cwd_handle): Remove. - (cwdstuff::init): Don't call close_user_proc_parms_cwd_handle. - Call set to set cwd with all-sharing handle. - (cwdstuff::set): Fix comment. Don't close cwd handle. Set in - user parameter block instead and close old cwd handle. - * syscalls.cc (rename): Call unlink_nt instead of RemoveDirectory or - DeleteFile to allow deleting shared files/directories. - -2007-02-27 Corinna Vinschen - - * fhandler.cc(fhandler_base::open): Open with READ_CONTROL only in - case of query_open flag set to query_read_control. Add case for - new query_read_attributes flag. - (fhandler_base::fstatvfs): New method. - * fhandler.h (enum query_state): Add query_read_attributes flag. - (class fhandler_base): Declare new virtual fstatvfs method. - (class fhandler_socket): Ditto. - (class fhandler_pipe): Ditto. - (class fhandler_fifo): Ditto. - (class fhandler_disk_file): Ditto. - (class fhandler_virtual): Ditto. - * fhandler_disk_file.cc (fhandler_base::fstat_fs): Open with - query_read_attributes instead of query_read_control. - (fhandler_disk_file::fstatvfs): New method. - (fhandler_disk_file::facl): Open with query_read_attributes instead of - query_read_control. - * fhandler_fifo.cc (fhandler_fifo::fstatvfs): New method. - * fhandler_socket.cc (fhandler_socket::fstatvfs): New method. - (fhandler_socket::fchmod): Return with EBADF in the default case. - (fhandler_socket::fchown): Ditto. - (fhandler_socket::facl): Ditto. - * fhandler_virtual.cc (fhandler_virtual::fstatvfs): Ditto. - * ntdll.h (struct _FILE_FS_ATTRIBUTE_INFORMATION): Define. - (struct _FILE_FS_FULL_SIZE_INFORMATION): Define. - * pipe.cc (fhandler_pipe::fstatvfs): New method. - * syscalls.cc (fstatvfs): Just call the fhandler's fstatvfs. - (statvfs): Ditto. - (fstatfs): Call fstatvfs. - (statfs): Drop EFAULT handling. - -2007-02-26 Corinna Vinschen - - * fhandler.cc (fhandler_base::fstat): Set all file times to arbitrary - fixed value. - -2007-02-26 Corinna Vinschen - - * fhandler_registry.cc (registry_listing): Drop name of HKEY_DYN_DATA. - (registry_keys): Drop HKEY_DYN_DATA. - * net.cc: Fix comment. - * syslog.cc: Ditto. - -2007-02-26 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Drop comment. - * mmap.cc (gen_access): Remove. - (mmap_record::gen_access): Remove. - (mmap64): Don't mention 9x any longer. - * syscalls.cc (statvfs): Drop status code consideration for 9x. - * libc/minires-os-if.c (get_registry_dns_items): Don't mention 9x any - longer. - (get_registry_dns): Drop getting registry key on 9x. Drop is9x - variable. - -2007-02-23 Corinna Vinschen - - Throughout remove all usage of wincap.has_security. - * environ.cc (environ_init): Drop setting allow_ntsec here. - * grp.cc (initgroups32): Drop usage of label "out". - * security.cc (allow_ntsec): Set to true by default. - * syscalls.cc (seteuid32): Remove label success_9x. - * wincap.cc: Remove has_security throughout. - * wincap.h: Ditto. - -2007-02-23 Corinna Vinschen - - * fhandler.h (class fhandler_pipe): Remove members writepipe_exists, - orig_pid and id. Make hit_eof inline. - * fhandler_fifo.cc (fhandler_fifo::open): Drop handling of - writepipe_exists, orig_pid and id. - * pipe.cc: Ditto throughout. - (pipecount): Remove. - (pipeid_fmt): Remove. - (fhandler_pipe::hit_eof): Simplify. Move to fhandler.h. - (fhandler_pipe::dup): Drop leave label. - (fhandler_pipe::create): Drop has_unreliable_pipes case. - * wincap.cc: Remove has_unreliable_pipes throughout. - * wincap.h: Ditto. - -2007-02-23 Corinna Vinschen - - * devices.in: Change native device name to native NT device name for - /dev/null, /dev/comX and /dev/ttySx. - * devices.cc: Regenerate. - * fhandler.cc (fhandler_base::open_9x): Remove. - (fhandler_base::open): Don't test for DOS device name, don't call - open_9x. - (fhandler_dev_null::open): Remove. - * fhandler.h (class fhandler_base): Drop open_9x declaration. - (class fhandler_dev_null): Drop open declaration. - -2007-02-23 Corinna Vinschen - - * fhandler_console.cc (fhandler_console::need_invisible): Drop - pty_needs_alloc_console check. - * spawn.cc (spawn_guts): Ditto. - (av::fixup): Remove setting iscui. - * syscalls.cc (rename): Drop has_move_file_ex checks. Remove 9x - specific code. - * wincap.cc: Remove has_move_file_ex and pty_needs_alloc_console - throughout. - * wincap.h: Ditto. - -2007-02-23 Corinna Vinschen - - * exceptions.cc (dummy_ctrl_c_handler): Remove. - (init_console_handler): Drop has_null_console_handler_routine checks. - * fhandler_raw.cc (fhandler_dev_raw::open): Drop has_raw_devices check. - * fhandler_serial.cc (fhandler_serial::open): Drop - .supports_reading_modem_output_lines check. - * miscfuncs.cc (low_priority_sleep): Drop has_switch_to_thread check. - * shared.cc (open_shared): Drop needs_memory_protection checks. - * spawn.cc (spawn_guts): Drop start_proc_suspended check. - * uname.cc (uname): Drop has_valid_processorlevel check. - * wincap.cc: Remove has_raw_devices, has_valid_processorlevel, - supports_reading_modem_output_lines, needs_memory_protection, - has_switch_to_thread, start_proc_suspended and - has_null_console_handler_routine throughout. - * wincap.h: Ditto. - -2007-02-23 Corinna Vinschen - - * fhandler.cc (fhandler_base::lseek): Drop 9x considerations. - * fhandler_disk_file.cc (fhandler_disk_file::lock): Ditto. - * wincap.cc: Remove lock_file_highword and has_64bit_file_access - throughout. - * wincap.h: Ditto. - -2007-02-22 Corinna Vinschen - - * cygheap.h (struct cwdstuff): Remove sync member and keep_in_sync - accessors. - * external.cc (cygwin_internal): Drop call to cygheap->cwd.keep_in_sync. - * fhandler_disk_file.cc (fhandler_disk_file::link): Always presume - ability to create hard links. - * path.cc (cwdstuff::init): Drop 9x considerations. - (cwdstuff::keep_in_sync): Remove. - (cwdstuff::set): Take NT for granted. - * pinfo.h (cygwin_pid): Just return pid. - * wincap.cc: Remove has_hard_links, can_open_directories, - has_negative_pids, has_named_pipes, has_try_enter_critical_section, - cant_debug_dll_entry and detect_win16_exe throughout. - * wincap.h: Ditto. - -2007-02-22 Corinna Vinschen - - * fhandler_console.cc (fhandler_console::read): Drop 9x specific - handling of AltGr key. - * mmap.cc: Take NT for granted throughout. - * wincap.cc: Remove map_view_of_file_ex_sucks, altgr_is_ctrl_alt, - has_working_copy_on_write, share_mmaps_only_by_name, - virtual_protect_works_on_shared_pages, has_mmap_alignment_bug and - has_working_virtual_lock throughout. - * wincap.h: Ditto. - -2007-02-22 Corinna Vinschen - - * fhandler.cc (fhandler_base::set_no_inheritance): Always use - SetHandleInformation. - * fhandler_disk_file.cc (fhandler_disk_file::lock): Always use - UnlockFileEx/LockFileEx functions. - * net.cc (fdsock): Don't bother to duplicate socket for inheritance. - * sysconf.cc (get_nproc_values): Take NT for granted. - (get_avphys): Ditto. - * syslog.cc (WIN95_EVENT_LOG_PATH): Remove define. - (get_win95_event_log_path): Remove. - (vsyslog): Fix formatting. Take NT for granted. - * wincap.cc: Remove has_lock_file_ex, has_signal_object_and_wait, - has_eventlog, has_set_handle_information, - has_set_handle_information_on_console_handles and supports_smp - throughout. - * wincap.h: Ditto. - -2007-02-22 Corinna Vinschen - - * dir.cc (rmdir): Move existance check in front of - has_dot_last_component check. Simplify setting errno in latter case. - -2007-02-22 Corinna Vinschen - - * fhandler.cc (fhandler_base::write): Remove wincap.has_lseek_bug case. - Simplify seek beyond EOF case. - * times.cc (times): Remove wincap.has_get_process_times case. - * wincap.cc: Remove has_delete_on_close, has_page_guard, - has_get_process_times and has_lseek_bug throughout. - * wincap.h: Ditto. - -2007-02-22 Corinna Vinschen - - Throughout remove all usage of wincap.access_denied_on_delete. - * dir.cc (rmdir): Add existance check to be errno-compatible with Linux. - * fhandler_disk_file.cc (fhandler_disk_file::rmdir): Drop test for - non-existent dir on 9x share. - * syscalls.cc (unlink): Add comment. - * wincap.cc: Remove access_denied_on_delete flag throughout. - * wincap.h: Ditto. - -2007-02-22 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::closedir): Fix bug - introduced by switching to NtClose. - -2007-02-22 Christopher Faylor - - * dcrt0.cc (child_info_fork::alloc_stack_hard_way): Change sense of - guard test. Increase size of stack reserved and increase size before - the current stack pointer. Use pointers when doing arithmetic. - (dll_crt0_1): Initialize exception handler when we notice we're the - child of a fork from non-main thread. - * fork.cc (frok::parent): Make argument volatile. - (frok::child): Ditto. - (lock_signals): New class. - (lock_pthread): Ditto. - (hold_everhthing): Ditto. - (frok::parent): Move atforkprepare and atforkparent to lock_pthread - class. - (fork): Make ischild boolean. Use hold_everything variable within - limited scope to set various mutexes in such a way as to avoid - deadlocks. - * thread.h (pthread_mutex::tid): New variable, active when debugging - for tracking thread id of owner. - (pthread_mutex::set_owner): Set tid when debugging. - * thread.cc (pthread_mutex::pthread_mutex): Clear tid. - (pthread_mutex::_unlock): Ditto when unlocking. - (pthread_mutex::fixup_after_fork): Set tid to special value after - forking since owner is unknown. - -2007-02-22 Corinna Vinschen - - Throughout replace all usage of wincap.shared with the constant - FILE_SHARE_VALID_FLAGS. - * fhandler.cc (fhandler_base::open_9x): Drop local variable shared. - * wincap.cc: Remove shared member throughout. - * wincap.h: Ditto. - -2007-02-22 Corinna Vinschen - - * Makefile.in (DLL_IMPORTS): Add libntdll.a. - * autoload.cc: Remove all symbols from advapi32.dll, kernel32.dll and - ntdll.dll available on all platforms since NT4. - - Throughout remove all usage of wincap.is_winnt. - * dcrt0.cc (dll_crt0_0): Remove call to mmap_init. - * fhandler.h (class fhandler_base): Remove has_changed flag. - (fhandler_disk_file::touch_ctime): Remove declaration. - (fhandler_disk_file::readdir_9x): Ditto. - (fhandler_disk_file::touch_ctime): Remove. - (fhandler_disk_file::readdir_9x): Remove. - (fhandler_disk_file::closedir): Call NtClose instead of CloseHandle. - * mmap.cc: Throughout call CreateMapping and MapView directly. - (VirtualProt9x): Remove. - (VirtualProtNT): Remove. - (VirtualProtEx9x): Remove. - (VirtualProtExNT): Remove. - (VirtualProtect): Remove define. - (VirtualProtectEx): Remove define. - (CreateMapping9x): Remove. - (CreateMappingNT): Rename to CreateMapping. - (MapView9x): Remove. - (MapViewNT): Rename to MapView. - (struct mmap_func_t): Remove definition. - (mmap_funcs_9x): Remove. - (mmap_funcs_nt): Remove. - (mmap_func): Remove. - (mmap_init): Remove. - * net.cc (getdomainname): Drop comment. Use NT4 registry key only. - (get_95_ifconf): Remove. - * pinfo.cc (winpids::enumNT): Rename to winpids::enum_processes. - (winpids::enum9x): Remove. - (winpids::set): Just call enum_processes directly. - (winpids::enum_init): Ditto. - * pinfo.h (class winpids): Drop enum_processes pointer. Rename - enumNT to enum_processes. Drop enum9x declaration. Drop initialization - of enum_processes throughout. - * registry.cc (get_registry_hive_path): Just create NT key. - (load_registry_hive): Only load NT specific file. - * syscalls.cc (unlink_9x): Remove. - (unlink): Just call unlink_nt. - * wincap.cc: Remove is_winnt flag throughout. - * wincap.h: Ditto. - * winsup.h: Remove mmap_init declaration. - -2007-02-21 Corinna Vinschen - - * wincap.cc (wincap_unknown): Change settings for unknown to reflect - the capabilities of NT4. - (wincap_95): Remove. - (wincap_95osr2): Remove. - (wincap_98): Remove. - (wincap_98se): Remove. - (wincap_me): Remove. - (wincap_nt3): Remove. - (wincapc::init): Temporarily bail out on any 9x system. - -2007-02-20 Corinna Vinschen - - * cygwin.din (sem_unlink): Export. - * posix_ipc.cc: Include thread.h and semaphore.h. Remove TODO - comment. - (ipc_names): Add max_len member. Set to maximum length of the path - before tacking on the prefix path. Set prefix path for named semaphors - to /dev/shm, as on Linux. - (enum ipc_type_t): Change sem to semaphore to avoid name conflicts. - (check_path): Detect empty paths. Use ipc_names's max_len member. - Use __small_sprintf to create full object path name. Special case - semaphores. - (ipc_cond_init): Drop superfluous strcpy. - (class ipc_flock): New class to simplify file locking in subsequent - code. - (struct mq_hdr): Raise size of mqh_uname to allow adding a unique - LUID to the name. - (mq_open): Fix formatting. Create unique synchronization object names - using AllocateLocallyUniqueId. - (struct sem_finfo): New structure defining named semaphore file content. - (sem_open): Move here. Rework implementation to allow kernel - persistent implementation of POSIX named semaphores. - (_sem_close): Implement sem_close. - (sem_close): Move here. Just call _sem_close with do_close parameter - set to true. - (sem_unlink): New function. - * pthread.cc (mangle_sem_name): Remove. - (sem_open): Move to posix_ipc.cc. - (sem_close): Ditto. - * syscalls.cc (close_all_files): Call semaphore::terminate here. - * thread.cc: Fix formatting. Rearrange semaphore functions so that - they are close together. - (semaphore::semaphore): Rework to play nicely with new named semaphore - implementation. - (semaphore::_terminate): Call _sem_close if semaphore is a named - semaphore. - (semaphore::destroy): Don't destroy named semaphores. Return EINVAL - instead. - (semaphore::close): Only destroy named semaphores. Return EINVAL - otherwise. - (semaphore::open): Rework to play nicely with new named semaphore - implementation. Loop through existing semaphores to be able to - return same sem_t pointer as a former call on the same named semaphore. - (semaphore::getinternal): New function called from _sem_close. - * thread.h (class List): Make mx and head public. - (class semaphore): Fix formatting. Align method declarations with - implementation in thread.cc. Add members used for named semaphores. - (semaphore::terminate): New static method. - * include/semaphore.h: Redefine SEM_FAILED. Fix formatting. - (sem_unlink): Add declaration. - * include/cygwin/version.h: Bump API minor number. - -2007-02-20 Christopher Faylor - - * exceptions.cc (_cygtls::signal_exit): Only call myself.exit when when - exit_state indicates that we've visited do_exit. - * sync.h (lock_process::lock_process): Use renamed exit_state - - ES_PROCESS_LOCKED. - * winsup.h: Rename ES_MUTO_SET to ES_PROCESS_LOCKED. - -2007-02-20 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::bind): Remove printing wrong - errno in debug output. - -2007-02-19 Christopher Faylor - - Remove extraneous whitespace. - * pinfo.cc (commune_process): Use default argument to lock_process. - * sigproc.cc: Update copyright. - * select.cc: Ditto. - -2007-02-15 Corinna Vinschen - - * posix_ipc.cc (mq_open): Avoid compiler warning. Initialize mqhdr - before using it in file exists case. - * include/mqueue.h (mqd_t): Make non-pointer type. - -2007-02-15 Corinna Vinschen - - * posix_ipc.cc (ipc_mutex_init): Create global object name. - (ipc_cond_init): Ditto. - (struct mq_hdr): Add mqh_uname member to store synchronization object - name. - (mq_open): Create unique synchronization object name and store in - mq_hdr->mqh_uname. Use this name in calls to ipc_mutex_init and - ipc_cond_init. - -2007-02-14 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Add posix_ipc.o. - * cygwin.din (mq_close): Export. - (mq_getattr): Export. - (mq_notify): Export. - (mq_open): Export. - (mq_receive): Export. - (mq_send): Export. - (mq_setattr): Export. - (mq_timedreceive): Export. - (mq_timedsend): Export. - (mq_unlink): Export. - * posix_ipc.cc: New file implementing the above functions. Move - shm_open and shm_unlink from syscalls.cc here. - * sysconf.cc (sca): Set value of _SC_MQ_OPEN_MAX to MQ_OPEN_MAX, - _SC_MQ_PRIO_MAX to MQ_PRIO_MAX, _SC_MESSAGE_PASSING to - _POSIX_MESSAGE_PASSING. - * include/limits.h (MQ_OPEN_MAX): Define. - (MQ_PRIO_MAX): Define. - * include/mqueue.h: New file. - * include/cygwin/version.h: Bump API minor number. - -2007-02-13 Corinna Vinschen - - * include/cygwin/stdlib.h (valloc): Declare. - (memalign): Declare. - -2007-02-09 Pierre A. Humblet - - * libc/minires-os-if.c (write_record): Handle DNS_TYPE_SRV and - some obsolete types. - -2007-02-08 Corinna Vinschen - - * syscalls.cc (check_shm): New static function to do path checking - common to shm_open and shm_unlink. Check for /dev/shm existance. - (shm_open): Call check_shm. - (shm_unlink): Ditto. - -2007-02-08 Corinna Vinschen - - * cygwin.din (shm_open): Export. - (shm_unlink): Export. - * syscalls.cc (shm_open): New function. - (shm_unlink): New function. - * sysconf.cc (sca): Set value of _SC_SHARED_MEMORY_OBJECTS to - _POSIX_SHARED_MEMORY_OBJECTS. - * include/cygwin/version.h: Bump API minor number. - * include/sys/mman.h (shm_open): Add prototype. - (shm_unlink): Ditto. - -2007-02-08 Christopher Faylor - Corinna Vinschen - - * cygmalloc.h (__set_ENOMEM): Declare. - (MALLOC_FAILURE_ACTION): Call __set_ENOMEM. - * malloc_wrapper.cc (malloc) Remove setting errno here. - (realloc): Ditto. - (calloc): Ditto. - (memalign): Ditto. - (valloc): Ditto. - (posix_memalign): Save and restore errno. - -2007-02-07 Corinna Vinschen - - * cygmalloc.h (MALLOC_FAILURE_ACTION): Move to correct #if branch. - -2007-02-07 Corinna Vinschen - - * cygmalloc.h (MALLOC_FAILURE_ACTION): Define empty. - * cygwin.din (posix_madvise): Export. - (posix_memalign): Export. - * fhandler.cc (fhandler_base::fpathconf): Return useful values in - _PC_VDISABLE, _PC_SYNC_IO and _PC_SYMLINK_MAX cases. - * malloc_wrapper.cc (malloc): Set errno here since it's not set in - dlmalloc.c anymore. - (realloc): Ditto. - (calloc): Ditto. - (memalign): Ditto. - (valloc): Ditto. - (posix_memalign): New function. - * mmap.cc (posix_madvise): New function. - * sysconf.cc (get_open_max): New function. - (get_page_size): Ditto. - (get_nproc_values): Ditto. - (get_avphys): Ditto. - (sc_type): New type. - (sca): New array to map _SC_xxx options to sysconf return values. - (sysconf): Reimplement using sca array. - * include/limits.h: Add all missing values as defined by SUSv3. - * include/pthread.h (PTHREAD_DESTRUCTOR_ITERATIONS): Move definition - to sys/limits.h. - (PTHREAD_KEYS_MAX): Ditto. - * include/semaphore.h (SEM_VALUE_MAX): Ditto. - * include/cygwin/stdlib.h (posix_memalign): Declare. - * include/cygwin/version.h: Bump API minor number. - * include/sys/mman.h: Add posix_madvise flags. - (posix_madvise): Declare. - * include/sys/termios.h (_POSIX_VDISABLE): Move definition to - sys/limits.h. - -2007-02-05 Corinna Vinschen - - * fhandler_serial.cc (fhandler_serial::tcsetattr): Add support for - baud rates up to 3000000 baud. Add missing 128K and 256K cases. - (fhandler_serial::tcgetattr): Ditto. - * include/sys/termios.h: Add baud rate definitions from B460800 up to - B3000000. - -2007-02-02 Corinna Vinschen - - * syscalls.cc (unlink_nt): Add missing assignment in case NtClose fails. - -2007-02-01 Corinna Vinschen - - * net.cc (ga_dup): New function, taken from ga_clone with v4-in-v6 - mapping addition. - (ga_clone): Just call ga_dup from here. - (ga_duplist): New function to duplicate list of struct addrinfo. - (ga_echeck): Don't check ai_flags, it already happened in - cygwin_getaddrinfo. - (cygwin_freeaddrinfo): Always call ipv4_freeaddrinfo. - (cygwin_getaddrinfo): Use new wincap.supports_all_posix_ai_flags - flag rather than wincap.has_gaa_on_link_prefix. Always duplicate - WinSock's addrinfo list to a self-allocated list. Handle AI_V4MAPPED - for pre-Vista platforms supporting getaddrinfo. - * wincap.h (wincapc::supports_all_posix_ai_flags): New element. - * wincap.cc: Implement above element throughout. - * include/netdb.h: Note how AI_ADDRCONFIG is not supported pre-Vista. - Remove superfluous comment. - -2007-02-01 Corinna Vinschen - - * include/cygwin/socket.h: Add IPv6 socket options. - -2007-01-31 Corinna Vinschen - - * net.cc (cygwin_getaddrinfo): Fix thinko in AI_ADDRCONFIG handling. - -2007-01-31 Corinna Vinschen - - * net.cc (cygwin_getaddrinfo): Check ai_flags for valid values. - Handle AI_NUMERICSERV. Handle AI_ADDRCONFIG behaviour on Vista. - * include/netdb.h (AI_NUMERICSERV): Add missing flag. - -2007-01-30 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::closedir): Add dir name - to debug output. - * syscalls.cc (try_to_bin): Enable code to move file to user specific - recycler dir to eliminate Vista problem. - (unlink_nt): Add comment that rename after opening for delete on close - only fails on XP. - -2007-01-30 Corinna Vinschen - - * sigproc.cc (child_info::child_info): Set msv_count to non-zero - value only on systems requiring it. - -2007-01-28 Corinna Vinschen - - * include/ftw.h: Include sys/cdefs.h. - -2007-01-26 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::rmdir): Implement rmdir - on NT by calling unlink_nt. Check for directory here. - * syscalls.cc (try_to_bin): Fix buggy debug_printf statement. - (unlink_nt): Make non-static. Don't use delete-on-close semantics on - directories. Explain why. - -2007-01-24 Corinna Vinschen - - * net.cc (if_nametoindex): This time, really free IP_ADAPTER_ADDRESSES - memory. - (if_indextoname): Ditto. - -2007-01-24 Corinna Vinschen - - * security.h (pop_thread_privilege): Revert to previous state, not - to token used for impersonation. - -2007-01-24 Corinna Vinschen - - * cygheap.h (cygheap_user::deimpersonate): Always RevertToSelf. - -2007-01-23 Corinna Vinschen - - * net.cc (gai_errmap): Add EAI_OVERFLOW entry. Fix formatting. - (cygwin_gai_strerror): Drop using EAI_MAX. - (w32_to_gai_err): Ditto. - * include/netdb.h: Define EAI_OVERFLOW. Remove EAI_MAX. - -2007-01-23 Corinna Vinschen - - * include/netdb.h: Add AI_xxx flags available since Vista. - -2007-01-23 Corinna Vinschen - - * net.cc (if_nametoindex): Free IP_ADAPTER_ADDRESSES memory. - (if_indextoname): Ditto. - (if_nameindex): Ditto. Remove duplicate indexed entries in result. - -2007-01-21 Corinna Vinschen - - * autoload.cc (WSAIoctl): Define. - (SendARP): Define. - * cygwin.din: Export if_freenameindex, if_indextoname, if_nameindex and - if_nametoindex. - * fhandler_procnet.cc: Drop including wchar.h. Drop definitions of - GAA_FLAG_INCLUDE_ALL_INTERFACES, IP_ADAPTER_UNICAST_ADDRESS_VISTA. - (fhandler_procnet::exists): Check for has_gaa_prefixes. Call - get_adapters_addresses here. - (fhandler_procnet::readdir): Ditto. - (prefix): Move to net.cc. - (fhandler_procnet::fill_filebuf): Call get_adapters_addresses here. - Simplify allocation. Use AdapterName rather than FriendlyName as - interface name. Use IfIndex if available, Ipv6IfIndex otherwise. - (in6_are_prefix_equal): Move to net.cc. - * fhandler_socket.cc: Define old SIOCGxxx values. - (CONV_OLD_TO_NEW_SIO): Convert old SIOCGxxx value to new one. - (struct __old_ifreq): Define old struct ifreq. - (fhandler_socket::ioctl): Handle old SIOCGxxx values. Handle new - SIOCGIFFRNDLYNAM command. Simplify copying ifreq data to user space. - Call get_ifconf with additional SOCKET parameter. - * net.cc (IP_ADAPTER_UNICAST_ADDRESS_LH): Define. - (IP_ADAPTER_ADDRESSES_LH): Define. - (SIO_GET_INTERFACE_LIST): Define. - (sockaddr_in6_old): Define. - (sockaddr_gen): Define. - (INTERFACE_INFO): Define. - (IN_LOOPBACK): Define. - (in_are_prefix_equal): New static function. - (ip_addr_prefix): New function, replaces prefix function, add AF_INET - handling. - (GAA_FLAG_INCLUDE_ALL_INTERFACES): Define. - (get_adapters_addresses): New function. - (WS_IFF_xxx): Define Winsock interface flag values. - (convert_ifr_flags): New function to convert Winsock interface flag - values to Cygwin interface flag values. - (get_xp_ifconf): New get_ifconf implementation for XP SP1 and above. - (get_2k_ifconf): Fix interface index. Fix formatting. - (get_nt_ifconf): Fix formatting. - (get_95_ifconf): Ditto. - (get_ifconf): Take additional SOCKET parameter. Call get_xp_ifconf - on XP SP1 and above. - (if_nametoindex): New function. - (if_indextoname): New function. - (if_nameindex): New function. - (if_freenameindex): New function. - (in6_are_prefix_equal): Moved here from fhandler_procnet.cc. - * wincap.cc (wincap_xp): Define has_gaa_prefixes as true by default. - (wincapc::init): Assume has_osversioninfoex by default. Call - GetVersionEx with OSVERSIONINFOEX first. Call with OSVERSIONINFO only - if that fails. Simplify NT4 case and try to avoid strcmp. Check XP - Service Pack using version.wServicePackMajor to avoid strcmp. - * include/asm/socket.h (SIOCGIFFRNDLYNAM): Define. - * include/cygwin/if.h: Fix formatting. - (IFF_POINTTOPOINT): Define. - (IFF_NOARP): Define. - (IFF_LOWER_UP): Define. - (IFF_DORMANT): Define. - (struct if_nameindex): Define. - (IFRF_FRIENDLYNAMESIZ): Define. - (struct ifreq_frndlyname): Define. - (IFNAMSIZ): Redefine as 44. - (IF_NAMESIZE): Define. - (struct ifreq): Redefine ifru_flags as int. Define ifru_data. Pad size - to sizeof sockaddr_in6 for further extensions. - (ifr_data): Define. - (ifr_frndlyname): Define. - (if_nametoindex): Declare. - (if_indextoname): Declare. - (if_nameindex): Declare. - (if_freenameindex): Declare. - * include/cygwin/version.h: Bump API minor number. - (CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ): Define check for old vs. new - ifreq structure. - -2007-01-18 Corinna Vinschen - - * spawn.cc (spawn_guts): Don't set cwd for non-Cygwin child processes - on NT to allow starting them in virtual directories. - -2007-01-18 Corinna Vinschen - - * mmap.cc (list::hash): Fix type to __ino64_t. - (list::get_hash): Ditto. - (list::set): Add struct stat parameter. Use that instead of calling - fstat. - (map::get_list_by_fd): Ditto. - (map::add_list): Ditto. - (mmap_is_attached_or_noreserve): Call get_list_by_fd appropriately. - (mmap_worker): Add pameters for map list and file stat information. - Propagate to called functions. - (mmap64): Use fstat on files early. Replace call to GetFileSize. - Call get_list_by_fd and mmap_worker appropriately. - -2007-01-18 Corinna Vinschen - - * fhandler_procnet.cc: Drop declaration of htonl and ntohs. Include - asm/byteorder.h instead. - -2007-01-18 Corinna Vinschen - - * include/cygwin/in6.h: Drop inclusion of asm/byteorder.h. - * fhandler_procnet.cc: Declare htonl and ntohs here. - -2007-01-17 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Add fhandler_procnet.o. - * autoload.cc (GetAdaptersAddresses): Define. - * devices.h (FH_PROCNET): Define new device. - * devices.in (dev_procnet_storage): Add "/proc/net" entry. - * devices.cc: Regenerate. - * dir.cc (readdir_worker): Use isproc_dev macro. - * dtable.cc (build_fh_pc): Add FH_PROCNET. - * fhandler.h (class fhandler_procnet): New class. - * fhandler_proc.cc: Add "net" subdirectory handling. - * fhandler_procnet.cc: New file handling "/proc/net" directory. - * path.cc (isvirtual_dev): Move to path.h. - * path.h (isproc_dev): New macro to identify /proc files by device. - (isvirtual_dev): Moved here. Define using isproc_dev. - * syscalls.cc (unlink): Use isproc_dev macro. - * wincap.h (wincapc::has_gaa_prefixes): New element. - (wincapc::has_gaa_on_link_prefix): New element. - * wincap.cc: Implement above elements throughout. - (wincapc::init): Check XP for service pack and set has_gaa_prefixes - appropriately. - * include/cygwin/in6.h: Include asm/byteorder.h. - -2007-01-17 Corinna Vinschen - - * include/asm/socket.h (SIOGIFINDEX): Define. - -2007-01-17 Corinna Vinschen - - * mmap.cc (MapView9x): Note possible uselessness of retrying. - (MapViewNT): Ditto. - (mmap64): Fix pre-reservation to work for non NULL, non MAP_FIXED. - -2007-01-16 Corinna Vinschen - - * autoload.cc (RtlAnsiStringToUnicodeString): Define. - (RtlOemStringToUnicodeString): Define. - * ntdll.h (struct _RTL_USER_PROCESS_PARAMETERS): Define. - (struct _PEB): Redefine with a bit of content. - (RtlAnsiStringToUnicodeString): Declare. - (RtlOemStringToUnicodeString): Declare. - * path.cc: Include ntdll.h. - (_upp): New global variable pointing to user process parameter block. - (get_user_proc_parms): New static function to retrieve user process - parameter block. - (close_user_proc_parms_cwd_handle): New function to close handle to - current working directory in user process parameter block. - (cwdstuff::init): Drop redundant declaration of dynamically_loaded. - Set current dir only on 9x. Call close_user_proc_parms_cwd_handle - on NT instead. - (cwdstuff::keep_in_sync): Only on 9x. - (cwdstuff::set): Keep behaviour on 9x. On NT write cwd path into user - process parameter block and set cwd handle to NULL. Fix comments to - reflect new behaviour. - -2007-01-16 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::ioctl): Handle SIOCGIFINDEX. - * net.cc (get_2k_ifconf): Ditto. - (get_nt_ifconf): Fake SIOCGIFINDEX. - (get_95_ifconf): Ditto. - (get_ifconf): Handle SIOCGIFINDEX. Fake it for loopback on systems - not supporting IP Helper Lib. - * include/asm/socket.h (SIOCGIFINDEX): Define. - * include/cygwin/if.h (struct ifreq): Add member for interface index. - (ifr_ifindex): Define. - -2007-01-16 Corinna Vinschen - - * include/cygwin/in6.h (struct ipv6_mreq): Change type of interface - member to uint32_t. - (struct in6_pktinfo): Ditto. - -2007-01-16 Corinna Vinschen - - * include/cygwin/in.h (struct ip_mreq_source): Define. - (struct ip_msfilter): Define. - (IP_MSFILTER_SIZE): Define. - (struct in_pktinfo): Define. - (struct group_req): Define. - (struct group_source_req): Define. - (struct group_filter): Define. - (GROUP_FILTER_SIZE): Define. - (INADDR_ALLRTRS_GROUP): Define. - * include/cygwin/socket.h: Define protocol agnostic multicast options. - -2007-01-15 Corinna Vinschen - - * CYGWIN_LICENSE: Fix web pages and contact information. - -2007-01-15 Corinna Vinschen - - * ntdll.h: Adjust status definitions. - -2007-01-15 Corinna Vinschen - - * cygheap.cc (cygheap_init): Add TODO comment. - -2007-01-15 Corinna Vinschen - - * ntdll.h (STATUS_SHARING_VIOLATION): Define. - -2007-01-13 Corinna Vinschen - - * syscalls.cc (unlink_nt): Don't move files to recycle bin which are - not in use. - -2007-01-13 Christopher Faylor - - * glob.cc: Update copyright notice with latest from FreeBSD. - (glob0): Use correct type for c variable to propagate previously - detected protection. - -2007-01-12 Corinna Vinschen - - * cygheap.cc (_csbrk): Fix off-by-one error. - * cygwin.sc: Give .cygheap a minimum size of 512K. - -2007-01-12 Christopher Faylor - - * external.cc (sync_winenv): Use cur_environ () rather than - __cygwin_environ. - -2007-01-12 Corinna Vinschen - - * fork.cc (child_copy): Add missing Windows PID in debug output. - -2007-01-12 Corinna Vinschen - - * syscalls.cc: Update copyright. - -2007-01-10 Corinna Vinschen - - * mmap.cc (mmap64): Pre-Reserve space for the whole mapping to get a - useful, valid address before the actual mappings take place. - Fix typo in comment. - -2007-01-10 Corinna Vinschen - - * syscalls.cc (sync): Use b_drive for B: drive (Thanks to Howard Chu). - -2007-01-09 Corinna Vinschen - - * syscalls.cc (getpagesize): Change condition for clarity. - (getsystempagesize): Ditto. - -2007-01-09 Corinna Vinschen - - * mmap.cc: Do bookkeeping in 4K pages, rather than in 64K chunks. - -2007-01-07 Corinna Vinschen - - * security.h (setacl): Add parameter for writability flag. - * sec_acl.cc (setacl): Ditto. Set to true if any ACE with write - permissions is created. - * fhandler_disk_file.cc (fhandler_disk_file::facl): Reset - FILE_ATTRIBUTE_READONLY if ACL contains an ACE with write permissions. - -2007-01-05 Corinna Vinschen - - * include/strings.h: Don't include string.h. Only declare functions - according to SUSv3. - -2007-01-04 Corinna Vinschen - - (get_ifconf): Set MTU for loopback to more correct value. - -2007-01-04 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::ioctl): Don't fake results - for SIOCGIFFLAGS here. Call get_ifconf instead. - * net.cc (get_2k_ifconf): Clean up code to generate interface name. - Handle SIOCGIFFLAGS here. - (get_nt_ifconf): Fake SIOCGIFFLAGS here. - (get_95_ifconf): Ditto. - (get_ifconf): Don't fake loopback on systems with IP Helper Lib. - Set MTU for loopback to a more "modern" value. - -2007-01-04 Brian Ford - Corinna Vinschen - - * fhandler.h (PREFERRED_IO_BLKSIZE): Define as 64K. - * fhandler.cc (fhandler_base::fstat): Set st_blksize to - PREFERRED_IO_BLKSIZE. - * fhandler_disk_file.cc (fhandler_base::fstat_helper): Ditto. - * fhandler_mailslot.cc (fhandler_mailslot::fstat): Ditto. - * fhandler_raw.cc (fhandler_dev_raw::fstat): Ditto. - -2007-01-01 Christopher Faylor - - * spawn.cc (spawn_guts): Don't expect synchronization from a non-cygwin - _P_NOWAIT process. diff --git a/winsup/cygwin/ChangeLog-2008 b/winsup/cygwin/ChangeLog-2008 deleted file mode 100644 index 313830261..000000000 --- a/winsup/cygwin/ChangeLog-2008 +++ /dev/null @@ -1,3341 +0,0 @@ -2008-12-31 Christopher Faylor - - * include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR to 191. - -2008-12-31 Christopher Faylor - - * glob_pattern_p.cc: New file. - * Makefile.in (DLL_OFILES): Add glob_pattern_p.o. - * glob.h: Add declaration for glob_pattern_p. - - * pinfo.cc (pinfo::thisproc): Remove __stdcall attribute. - -2008-12-30 Christopher Faylor - - * include/bits/wordsize.h: New linux-compatibility header. - -2008-12-30 Christopher Faylor - - * exceptions.cc (try_to_debug): Avoid creating a huge buffer on the - stack. - -2008-12-25 Christopher Faylor - - * mount.cc: Change comment. - (smb_extended_info): Move here from path.cc. - (fs_info::update): Ditto. - (mount_info::create_root_entry): Delay conversion to slashes and use - passed in buffer to figure out fs type. - * path.cc (smb_extended_info): Move. - (fs_info::update): Ditto. - * mount.h: New file. Move mount information here. - * path.h: (fs_info::update): Move. - * shared_info.h (mount_item): Ditto. - -2008-12-24 Christopher Faylor - - * path.cc (symlink_info::check_shortcut): Ensure that symlink handle is - closed on successful return. - -2008-12-23 Christopher Faylor - - * fhandler.h (fhandler_base_setup_overlapped): Add new argument. - (fhandler_base::get_overlapped_buffer): Declare new function. - (fhandler_base::set_overlapped): Ditto. - (fhandler_pipe::overlapped): New variable. - (fhandler_pipe::get_overlapped): Rework to return contents of - overlapped variable. - (fhandler_pipe::set_overlapped): Set overlapped variable based on - argument. - (fhandler_fifo::get_overlapped_buffer): Return pointer to io_status. - * fhandler.cc (handler_base::setup_overlapped): Set to overlapped - pointer to NULL if new doit parameter is false. Otherwise set up - overlapped event as usual. - (fhandler_base::wait_overlapped): Return inres if this isn't an - overlapped operation. - (fhandler_base::read_overlapped): Remove inappropriate asserts. - * pipe.cc (fhandler_pipe::fhandler_pipe): Zero overlapped element. - (struct pipesync): Delete. - (getov_result): Ditto. - (pipe_handler): Ditto. - (pipesync::pipesync): Ditto. - (fhandler_pipe::init): Don't set up pipesync thread. Just pass - opened_properly flag along to overlapped setup. - -2008-12-22 Christopher Faylor - - * pipe.cc (getov_result): Minor cleanup. - -2008-12-20 Christopher Faylor - - * pipe.cc (getov_result): Add parameters to facilitate better EOF - checking. - (pipe_handler): Pass extra arguments to getov_result. - -2008-12-20 Christopher Faylor - - * fhandler.cc (fhandler_base::wait_overlapped): Reorganize to eliminate - gotos and to hopefully eliminate one race when a signal is detected or - there is a WFMO error. - -2008-12-20 Christopher Faylor - - * pinfo.h (pinfo::thisproc): Declare. Rename from set_myself. - * pinfo.cc (pinfo::thisproc): Define. Rename from set_myself. Set - procinfo to NULL to avoid confusing subsequent init. - (pinfo_init): Accommodate set_myself -> pinfo::thisproc rename. - * dcrt0.cc (child_info_fork::handle_fork): Ditto. - (child_info_spawn::handle_spawn): Ditto. - -2008-12-20 Corinna Vinschen - - * pwdgrp.h (pwdgrp::refresh): Fix indentation. - * uinfo.cc (pwdgrp::load): Open file synchronized to avoid truncated - read. Drop local variable off. - -2008-12-19 Christopher Faylor - - * pinfo.cc (pinfo_basic): New class. - (pinfo_basic::pinfo_basic): Define constructor for new class. - (myself): Initialize from myself_initial. - (set_myself): Set pid and progname from already myself_initial. - * strace.cc (strace::strace): Split apart strace::hello. Send - notification to strace as early as possible. - (strace::hello): Just send clause which describes the current process. - This can now be preceded by early initialization strace output. - * include/sys/strace.h (strace::strace): Declare new constructor. - -2008-12-19 Christian Franke - - * fhandler_registry.cc (perf_data_files): New table. - (PERF_DATA_FILE_COUNT): New constant. - (fhandler_registry::exists): Add check for HKEY_PERFORMANCE_DATA - value names. - (fhandler_registry::fstat): For HKEY_PERFORMANCE_DATA, return - default values only. - (fhandler_registry::readdir): For HKEY_PERFORMANCE_DATA, list - names from perf_data_files only. - (fhandler_registry::fill_filebuf): Use larger buffer to speed up - access to HKEY_PERFORMANCE_DATA values. Remove check for possible - subkey. Add RegCloseKey (). - (open_key): Replace goto by break, remove label. Do not try to - open subkey of HKEY_PERFORMANCE_DATA. Add missing RegCloseKey () - after open subkey error. - -2008-12-19 Corinna Vinschen - - * path.cc (path_conv::check): Handle incoming DOS paths non-POSIXy, - always case-insensitive, always ignoring ACLs. - -2008-12-18 Corinna Vinschen - - * fhandler_disk_file.cc: Set 4th parameter of NtQueryDirectoryFile to - NULL throughout. - (fhandler_disk_file::facl): Fix a condition so that fstat_by_handle - is actually used. - (fhandler_disk_file::readdir): Don't print debug message on a simple - STATUS_NO_MORE_FILES status code. - -2008-12-18 Corinna Vinschen - - * path.cc (symlin_info::check): Set 4th parameter of - NtQueryDirectoryFile to NULL instead of 0 since it's a pointer. - Simplify label and break from loop handling in symlink evaluation - conditional expression. Drop a now useless break statement. Fix - behaviour when searching for `foo' and then finding a `foo.lnk' - which is no shortcut. - -2008-12-16 Christian Franke - - * fhandler_registry.cc (DEFAULT_VALUE_NAME): Remove constant. - (encode_regname): Encode empty (default) name to "@". - Encode "@" to "%40". Change error return to -1. - (decode_regname): Decode "@" to empty name. Decode "%40" to "@". - (fhandler_registry::exists): Skip check for keys if name is empty. - Remove check for DEFAULT_VALUE_NAME, now handled by decode_regname (). - (fhandler_registry::readdir): Remove check for empty name, now - handled by encode_regname (). - (fhandler_registry::open): Remove check for DEFAULT_VALUE_NAME. - (fhandler_registry::open_key): Fail with ENOENT if key name is empty. - -2008-12-15 Corinna Vinschen - - * syscalls.cc (gen_full_path_at): Use isabspath instead of isdirsep - to recognize absolute path. - -2008-12-15 Corinna Vinschen - - * sec_auth.cc (open_local_policy): Set lsa handle to - INVALID_HANDLE_VALUE when LsaOpenPolicy fails. Explain why. - -2008-12-15 Corinna Vinschen - - * setlsapwd.cc (setlsapwd): Simplify code. Only try to call cygserver - if opening local policy fails. Don't treat removing non-existant - private data as error. - -2008-12-15 Corinna Vinschen - - * setlsapwd.cc (setlsapwd): Explicitely erase password buffer content - after usage. - -2008-12-15 Corinna Vinschen - - * fhandler_registry.cc (fhandler_registry::exists): Handle EACCES. - (fhandler_registry::open): Ditto. - -2008-12-15 Corinna Vinschen - - * cygwin.din: Export fgetwc, fgetws, fputwc, fputws, fwide, getwc, - getwchar, putwc, putwchar, ungetwc. - * posix.sgml: Move above functions (add missing) into "implemented - SUSv3" section. - * include/cygwin/version.h: Bump api minor number. - -2008-12-15 Corinna Vinschen - - * fhandler.h (class fhandler_registry): Declare dup method. - * fhandler_registry.cc (fhandler_registry::exists): Fix missing - parenthesis. - (fhandler_registry::dup): New method. - -2008-12-14 Christopher Faylor - - * fhandler_disk_file.cc (readdir_get_ino): Don't complain about MS-DOS - paths since the function could be fed one by an internal call. - -2008-12-13 Christopher Faylor - - * cygheap.cc (cygheap_user::~cygheap_user): Remove unneeded if 0'ed - code. - - * fhandler_registry.cc (fhandler_registry::exists): Recode goto as - if/else to avoid a gcc4 compiler warning. - (fhandler_registry::open): Ditto. Use one goto rather than two. - - * gentls_offsets: Fix compiler warning in generated output. - * tlsoffsets.h: Regenerate. - - * mount.cc (fillout_mntent): slashify native paths returned via - getmntent. - -2008-12-08 Yaakov Selkowitz - - * resolv.h: #include for sockaddr_in typedef. - -2008-12-07 Christian Franke - - * fhandler_registry.cc (encode_regname): Add Parameter add_val. - Append "%val" if add_val is set. - (decode_regname): Remove trailing "%val". Change returncode accordingly. - (__DIR_hash): New class. - (d_hash): New macro. - (key_exists): New function. - (fhandler_registry::exists): Remove encode of registry name before path - compare, decode file part of path instead. Skip checks for keys if - trailing "%val" detected. - (fhandler_registry::fstat): Change check of return value of - decode_regname (). - (fhandler_registry::readdir): Allocate __DIR_hash. Record key names in - hash table. Append "%val" if key with same name exists. Fix error - handling of encode_regname (). Set dirent.d_type. - (fhandler_registry::closedir): Delete __DIR_hash. - (fhandler_registry::open): Don't open key if trailing "%val" detected - by decode_regname (). - (open_key): Ditto. - -2008-12-03 Pierre A. Humblet - - * libc/minires.c (open_sock): Set non blocking and close on exec. - (res_ninit): Set id pseudo-randomly. - (res_nsend): Do not set close on exec. Initialize server from id. - Flush socket. Tighten rules for answer acceptance. - (res_nmkquery): Update id using current data. - -2008-12-02 Corinna Vinschen - - * fhandler_registry.cc (must_encode): Fix condition changed for testing. - -2008-12-01 Christian Franke - - * fhandler_registry.cc (must_encode): New function. - (encode_regname): Ditto. - (decode_regname): Ditto. - (fhandler_registry::exists): Encode name before path compare. - (fhandler_registry::fstat): Pass decoded name to win32 registry call. - (fhandler_registry::readdir): Return encoded name to user. - (fhandler_registry::open): Store decoded name into value_name. - (open_key): Pass decoded name to win32 registry call - -2008-11-28 Christopher Faylor - - * exceptions.c (sigpacket::process): Set tls on return since it is - assumed to be set to a valid value by the caller. - -2008-11-28 Christopher Faylor - - * include/cygwin/version.h: Bump api minor number to 189 to flag the - implementation of dirent.d_type. - -2008-11-28 Christopher Faylor - - * exceptions.cc (sigpacket::process): Rework previous change. tls - could still become NULL. - -2008-11-28 Christian Franke - - * dir.cc (readdir_worker): Initialize dirent.d_type and __d_unused1. - * fhandler_disk_file.cc (fhandler_disk_file::readdir_helper): - Set dirent.d_type based on FILE_ATTRIBUTE_*. - * include/sys/dirent.h: Define _DIRENT_HAVE_D_TYPE (enables DT_* - declarations). - (struct dirent): Add d_type. Adjust __d_unused1 size to preserve layout. - -2008-11-27 Christopher Faylor - - * exceptions.cc (sigpacket::process): Make sure that 'tls' is never - NULL when used. - -2008-11-26 Christopher Faylor - - Remove unneeded whitespace throughout. - - * fhandler_fifo.cc (fhandler_fifo::open): Rework to cause errno to be - set to ENXIO when opening a fifo write/nonblocking. - - * environ.cc (ucreqenv): Rename to ucenv. Move code from old ucenv - here and conditionalize it on create_upcaseenv. - (ucenv): Delete. - (environ_init): Fix compiler warning by moving create_upcaseenv test to - ucenv. Don't bother checking for child_proc_info when calling ucenv - since it is assumed to be NULL at the point where the function is - called. - - * path.cc (symlink_worker): Turn off MS-DOS path warnings when dealing - with devices since the device handler passes in a translated MS-DOS - path. - - * sec_auth.cc (lsaprivkeyauth): Avoid variable initialization which - causes a compiler error. - - * fhandler_netdrive.cc: Update copyright. - -2008-11-26 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Add setlsapwd.o. - * cygserver.h (CYGWIN_SERVER_VERSION_API): Bump. - (request_code_t): Define CYGSERVER_REQUEST_SETPWD request type. - * cygserver_msg.h (client_request_msg::retval): Use default value of -1 - for retval if msglen is 0. - * cygserver_sem.h (client_request_sem::retval): Ditto. - * cygserver_shm.h (client_request_shm::retval): Ditto. - * cygserver_setpwd.h: New file. - * external.cc (cygwin_internal): Implement new CW_SET_PRIV_KEY type. - * sec_auth.cc (open_local_policy): Make externally available. - Get ACCESS_MASK as argument. - (create_token): Accommodate change to open_local_policy. - (lsaauth): Ditto. - (lsaprivkeyauth): New function fetching token by retrieving - password stored in Cygwin or Interix LSA private data area and - calling LogonUser with it. - * security.h (lsaprivkeyauth): Declare. - (open_local_policy): Declare. - * setlsapwd.cc: New file implementing setting LSA private data password - using LsaStorePrivateData or by calling cygserver if available. - * syscalls.cc (seteuid32): Add workaround to get the original token - when switching back to the original privileged user, even if - setgroups group list is still active. Add long comment to explain why. - Call lsaprivkeyauth first, only if that fails call lsaauth or - create_token. - * include/cygwin/version.h: Bump API minor number. - * include/sys/cygwin.h (cygwin_getinfo_types): Add CW_SET_PRIV_KEY. - -2008-11-21 Corinna Vinschen - - * fhandler_floppy.cc (fhandler_dev_floppy::raw_read): Drop - initialization of bytes_to_read. Set bytes_to_read to len in - non-buffered case. Call read_bytes correctly with bytes_to_read - instead of len. - -2008-11-21 Corinna Vinschen - - * mmap.cc (MapView): Add NT status to debug output. - -2008-11-11 Corinna Vinschen - - * autoload.cc (GetSystemDEPPolicy): Define. - (GetProcessDEPPolicy): Ditto. - (SetProcessDEPPolicy): Ditto. - * dcrt0.cc (disable_dep): New static function. - (dll_crt0_0): Call disable_dep on platforms requiring it. Add longish - comment to explain the circumstances. - * wincap.h (wincaps::ts_has_dep_problem): New element. - * wincap.cc: Implement above element throughout. - (wincapc::init): Set ts_has_dep_problem to true on 2008 Terminal - Servers. - * winsup.h (WINVER): Set to 0x0601. - -2008-11-11 Corinna Vinschen - - * mount.cc (mount_info::cygdrive_win32_path): Always upper case - DOS drive letter to accommodate case sensitivity. - (cygdrive_getmntent): Ditto. - * path.cc (path_conv::check): Invalidate wide_path after making path - relative. - -2008-11-11 Corinna Vinschen - - * environ.cc (create_upcaseenv): New static variable. - (renv_arr): New static array to keep track of environment variables - which have to be always uppercased. - (idx_arr): Ditto. - (start_at): Ditto. - (ucreqenv): New function to uppercase only the environment variables - from renv_arr. - (parse_thing): Add "upcaseenv" setting. - (environ_init): Parse $CYGWIN before doing anything else. Call - ucreqenv instead of ucenv if CYGWIN=noupcaseenv is set. - -2008-11-10 Christopher Faylor - - * path.cc (normalize_win32_path): Don't add a trailing '\' if the cwd - returns a path with a trailing '\'. - -2008-11-07 Christopher Faylor - - * pthread.cc (pthread_mutex::_unlock): Avoid unlocking a mutex if the - recursion_counter is already 0. - (pthread_mutex::_destroy): Don't consider a mutex busy if its - recursion_counter == 0. - (pthread_mutex::_fixup_after_fork): Set recursion_counter to 0 to flag - that we've just forked. Don't reset the owner of this mutex since the - forkee may think it still owns the mutex. Reinstate initialization of - win32_obj_id. - - * fhandler_floppy.cc (fhandler_dev_floppy::raw_read): Initialize a - variable to bypass a C++ warning. - -2008-11-05 Corinna Vinschen - - * environ.cc (environ_init): Avoid evaluating $CYGWIN twice. - -2008-10-23 Corinna Vinschen - - * wincap.cc (all wincaps): Store in .cygwin_dll_common section same as - wincap. Add comment to explain why. - -2008-10-22 Corinna Vinschen - - * autoload.cc (GetSystemWindowsDirectoryW): Define. - * kernel32.cc (GetWindowsDirectoryW): Implement to abstract from - running under Terminal Services or not. - (GetWindowsDirectoryA): Ditto. - -2008-10-21 Corinna Vinschen - - * passwd.cc (pwdgrp::read_passwd): Check if we're called within - user_shared initialization and ignore myself, if so. Reformat - conditional expression. - -2008-10-20 Corinna Vinschen - - * ntdll.h (NtSetAttributesFile): New inline function. - * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Use - NtSetAttributesFile. - * path.cc (symlink_worker): Ditto. - * syscalls.cc (unlink_nt): Ditto. - (rename): Omit FILE_SHARE_DELETE when opening files on Samba. Add - comment to explain why. - -2008-10-17 Corinna Vinschen - - * dtable.cc (dtable::get_debugger_info): Call SetStdHandle - for the newly opened handle. Explain why. - (dtable::stdio_init): Don't duplicate standard error handle - when stderr has already been created under debugger control. - -2008-10-13 Corinna Vinschen - - * sec_acl.cc (setacl): Align standard owner and group permissions - with alloc_sd. Strip FILE_READ_ATTRIBUTES fromn setting - FILE_GENERIC_EXECUTE permissions same as in alloc_sd. - * security.cc (alloc_sd): Reformat expression. Strip EA permission - bits from owner_deny and group_deny computation. - -2008-10-09 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::fstat_helper): Check - for executable suffixes here in case we're on a file system - not supporting permission. - * path.cc (path_conv::check): Drop check for executable suffixes. - -2008-10-09 Corinna Vinschen - - * fhandler_floppy.cc (fhandler_dev_floppy::raw_read): Keep track of - current position in non-buffered case, too. - -2008-10-09 Corinna Vinschen - - * grp.cc (pwdgrp::read_group): Generate more speaking group name - if passwd gid exists under different gid in /etc/group. - -2008-10-09 Corinna Vinschen - - * path.cc (path_conv::is_binary): Always check for GetBinaryType. - * syscalls.cc (rename): Fix test for just changing case of name on - case insensitive filesystems. - -2008-10-09 Corinna Vinschen - - * path.cc (symlink_info::check_shortcut): Don't check for executability - here. - (symlink_info::check_sysfile): Ditto. - -2008-10-08 Corinna Vinschen - - * path.cc (path_conv::check): Only assume executability by suffix - on file systems not supporting permissions. - -2008-10-07 Christopher Faylor - - * pthread.cc (pthread_create): Very minor formatting change. - * timer.cc (timer_thread): Ensure that any created thread defaults to - detached state. - -2008-10-06 Christopher Faylor - - * cygtls.h (_cygtls::initialized): Remove bogus stack check which would - crash when checking the current thread from the current thread. - * tlsoffsets.h: Regenerate. - -2008-10-05 Christopher Faylor - - * dcrt0.cc (dll_crt0_0): Don't initialize signals early when - dynamically loaded. - (dll_crt0_1): Wait until this phase to initialize signals when - dynamically loaded. - -2008-09-29 Christopher Faylor - - * thread.cc (pthread_mutex::_fixup_after_fork): Reinstate DEBUGGING - conditional. - -2008-09-29 Christopher Faylor - - * thread.cc (pthread_mutex::_fixup_after_fork): Just reset lock to - pristine state after fork. Don't recreate a mutex since it may not - actually be needed. - -2008-09-29 Corinna Vinschen - - * flock.cc (inode_t::get_all_locks_list): Fix typo. - * posix.sgml: Add cfmakeraw to list of implemented BSD functions. - -2008-09-19 Eric Blake - - * errno.cc (_sys_errlist): Add ECANCELED, ENOTRECOVERABLE, - EOWNERDEAD. - -2008-09-15 Christopher Faylor - - * cygtls.h (unionent): Move from net.cc. - (unionent::struct_type): Move enum here. - (_local_storage::hostent_buf): Define as unionent. - (_local_storage::protoent_buf): Ditto. - (_local_storage::servent_buf): Ditto. - * net.cc (unionent): Move to cygtls.h. - (struct_type): Ditto. - (dup_ent): Define one function per {host,proto,serv}ent type. - (cygwin_getprotobyname): Simplify dup_ent call. Removed now-unneeded - return type coercion. - (cygwin_getprotobynumber): Ditto. - (cygwin_getservbyname): Ditto. - (cygwin_getservbyport): Ditto. - (cygwin_gethostbyname): Ditto. - (cygwin_gethostbyaddr): Ditto. - tlsoffsets.h: Regenerate. - -2008-09-12 Christopher Faylor - - * Makefile.in: Add -c option which is now removed from COMPILE_C*. - * cygwin.din (cfmakeraw): Export. - * termios.cc (cfmakeraw): Implement. - * include/sys/termios.h (cfmakeraw): Declare. - * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. - -2008-09-11 Christopher Faylor - - * cygwin.din (sys_sigabbrev): Add this here. - * dcrt0.cc (__argc,__argv,_check_for_executable): Remove dllexport - decoration since it is already handled in cygwin.din. - * errno.cc (_sys_errlist): Ditto. - * strsig.cc (sys_sigabbrev): Ditto. - * include/cygwin/signal.h: Protect use of dllimport when - __INSIDE_CYGWIN__. - * libc/getopt.c: Revert previous changes. Define __INSIDE_CYGWIN__. - -2008-09-11 Christopher Faylor - - * localtime.cc (increment_overflow): Mark as non-inline to prevent - compiler from complaining about the very thing we're trying to test. - * ntea.cc (read_ea): Reorganize to avoid a new compiler warning/error. - * sched.cc (sched_rr_get_interval): Ditto. - * select.cc (peek_serial): Ditto. - * libc/rexec.cc (ruserpass): Ditto. - * posix_ipc.cc (ipc_names): Make static to avoid a compiler warning - (and it's the right thing to do anyway). - -2008-09-11 Christopher Faylor - - * net.cc (in6addr_any, in6addr_loopback): Add appropriate number of - braces around initializer. - (dup_ent): Try harder to coerce the first argument to deal with more - stringent compiler. - (get_2k_ifs): Remove extraneous typedef. - (get_2k_ifs): Reorganize expression to avoid a compiler warning. - (get_xp_ifs): Ditto. - (get_nt_ifs): Ditto. - -2008-09-11 Christopher Faylor - - * fhandler.h (fhandler_pipe::raw_read): Remove __stdcall decoration. - * pipe.cc (fhandler_pipe::raw_read): Ditto. - -2008-09-11 Christopher Faylor - - * cygheap.cc (creturn): Reorganize to avoid a new compiler - warning/error. - * dtable.cc (handle_to_fn): Ditto. - * fhandler_console.cc (fhandler_console::read): Ditto. - (fhandler_console::scroll_screen): Ditto. - (dev_console::set_color): Ditto. - * fhandler_dsp.cc (fhandler_dev_dsp::write): Ditto. - (fhandler_dev_dsp::read): Ditto. - * fhandler_tape.cc (mtinfo_drive::get_status): Ditto. - * hookapi.cc (find_first_notloaded_dll): Ditto. - * mmap.cc (msync): Ditto. - * pipe.cc (pipesync::pipesync): Ditto. - * sec_acl.cc (getace): Ditto. - * sec_auth.cc (create_token): Ditto. - (lsaauth): Ditto. - * select.cc (peek_pipe): Ditto. - * spawn.cc (av::fixup): Ditto. - * syscalls.cc (popen): Ditto. - * tty.cc (tty::init_session): Ditto. - * uinfo.cc (pwdgrp::load): Ditto. - * fhandler.cc (fhandler_base::setup_overlapped): Ditto. - (fhandler_base::wait_overlapped): Rename second use of res variable to - wres or errors are not returned correctly. - * dcrt0.cc: Remove obsolete variable. - * dll_init.cc (release_upto): Fix typo involving incorrect use of '|'. - * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Avoid a - compiler warning regarding coercing type-punned variables. - (fhandler_base::fstat_by_name): Ditto. - * fhandler_fifo.cc (fhandler_fifo::open_nonserver): Fix = vs. == typo. - (fhandler_fifo::wait): Add all conditions to switch statement to avoid - a compiler warning. - * fhandler_process.cc: Avoid unneeded initialization of variables to - zero. - * fhandler_socket.cc (fhandler_socket::listen): Add braces around - initializer. - * flock.cc (inode_t::get_all_locks_list): Reorganize to avoid a - compiler warning. Fix problem with EWOULDBLOCK error return. - * path.cc (GUID_shortcut): Use braces around struct initializer. - (cygwin_conv_path): Reorganize to avoid a compiler warning. - * random.cc (dummy): Mark variable as volatile to avoid a "used - uninitialized" warning. - * libc/getopt.c: Mark some variables as dllexport although gcc doesn't - seem to do the right thing with them. - * libc/minires-os-if.c (get_registry_dns_items): Coerce some function - arguments to avoid a compiler warning. - -2008-08-27 Christopher Faylor - - * fhandler_tty.cc (close_maybe): Check for both types of invalid handle - before attempting CloseHandle. - (fhandler_pty_master::setup): Only set inheritance on pty handles, not - tty handles. - -2008-08-26 Christopher Faylor - - * shared_info.h (shared_info::create_root_entry): Remove extraneous - mount_info:: from declaration. - -2008-08-26 Corinna Vinschen - - * fhandler.h (class fhandler_pipe): Rename read and write - declarations to raw_read and raw_write. - * pipe.cc (fhandler_pipe::raw_read): Rename from read. - (fhandler_pipe::raw_write): Rename from write. - -2008-08-21 Christopher Faylor - - * fhandler.cc (fhandler_base::wait_overlapped): Reorganize again to - accommodate what appears to be an MSDN hint about not resetting the - overlapped event prior to calling GetOverlappedResult. - -2008-08-20 Corinna Vinschen - - * path.cc (symlink_info::check_shortcut): If file can't be opened, - treat it as non-symlink rather than generating an EIO error. - (symlink_info::check_sysfile): Ditto. - -2008-08-19 Christopher Faylor - - * fhandler.cc (fhandler_base::wait_overlapped): Always assume that - bytes will be non-NULL. Distinguish input result from result derived - from WFMO and GetOverlappedResult or res can never be -1. Only raise - SIGPIPE when writing. - * fhandler.h (fhandler_base::wait_overlapped): Pass first argument by - value. - * fhandler_fifo.cc (fhandler_fifo::wait): Pass in dummy byte count to - wait_overlapped. - * pipe.cc (DEFAULT_PIPEBUFSIZE): Define to 65536 explicitly. - -2008-08-19 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::mkdir): Drop fattr variable - and use FILE_ATTRIBUTE_DIRECTORY directly in call to NtCreateFile. - * posix_ipc.cc (ipc_mutex_init): Fix format string when creating IPC - object name. - (ipc_cond_init): Ditto. - * security.cc (alloc_sd): Add parentheses to fix setting initial - owner_allow value. - -2008-08-18 Christopher Faylor - - * fhandler.cc (fhandler_base::wait_overlapped): Don't treat - ERROR_BROKEN_PIPE as a non-error. Do raise SIGPIPE when it is - detected. - -2008-08-15 Corinna Vinschen - - * mount.cc (mount_info::get_mounts_here): Don't subtract 2 from - Length if it's 0 anyway. - -2008-08-15 Corinna Vinschen - - * mount.cc (mount_info::create_root_entry): Create default cygdrive - prefix with MOUNT_NOPOSIX flag. - -2008-08-15 Corinna Vinschen - - * path.cc (symlink_info::check): Don't use eabuf when trying to open - file a second time. Call NtOpenFile instead of NtCreateFile in this - case. - -2008-08-14 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::link): Fix linking - against symlinks. - -2008-08-14 Corinna Vinschen - - * external.cc (cygwin_internal): Call set_security_attribute with - additional path_conv argument. - * fhandler.cc (fhandler_base::open): Ditto. - * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Never set DOS - R/O attribute when using ACLs. - (fhandler_disk_file::mkdir): Ditto. Set - security descriptor on remote dirs after creating the dir, same as in - fhandler_base::open. - * fhandler_socket.cc (fhandler_socket::bind): Ditto for remote AF_LOCAL - socket files. - * path.cc (symlink_worker): Ditto. for remote symlinks. - * security.cc (alloc_sd): Take additional path_conv argument. - Accommodate throughout. Drop setting FILE_WRITE_EA/FILE_READ_EA - flags unconditionally (was only necessary for "ntea"). Don't set - FILE_READ_ATTRIBUTES and FILE_WRITE_ATTRIBUTES unconditionally on - Samba. Add comment to explain. Drop useless setting of - STANDARD_RIGHTS_WRITE, it's in FILE_GENERIC_WRITE anyway. - Remove FILE_READ_ATTRIBUTES bit from FILE_GENERIC_EXECUTE so as not - to enforce read permissions on Samba. - (set_security_attribute): Take additional path_conv argument. - * security.h (set_security_attribute): Change prototype accordingly. - -2008-08-13 Corinna Vinschen - - * mount.cc (fillout_mntent): Always print noumount option last. - -2008-08-13 Corinna Vinschen - - * mount.cc (fillout_mntent): Print options as taken in fstab and mount. - -2008-08-13 Corinna Vinschen - - * dll_init.cc: Throughout convert to use long pathnames. - * dll_init.h (struct dll): Change name to WCHAR, change operator [] to - take PWCHAR argument. - -2008-08-11 Corinna Vinschen - - * syscalls.cc (rename): If newpath doesn't exist, check if .exe suffix - in oldpath has been omitted before appending .exe to newpath. - -2008-08-09 Corinna Vinschen - - * fhandler_floppy.cc (fhandler_dev_floppy::raw_read): Don't set - eom_detected when EOF is detected, thus returning 0 instead of - setting errno to ENOSPC. - -2008-08-07 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Use Samba workaround generally - for all remote filesystems supporting ACLs. Change comment and - explain why. Refer to the discussion which led to this. - -2008-08-05 Brian Dessent - - * config/i386/profile.h (mcount): Mark asms volatile. - -2008-08-05 Christopher Faylor - - * dll_init.cc (dll_global_dtors): Add an additional test to avoid - walking the linked list if it is empty. - (dll_list::detach): Don't set dll_global_dtors_recorded if we aren't - actually going to record any dlls. - -2008-08-04 Christopher Faylor - - Changes suggested by Dave Korn. - * dcrt0.cc (cygwin_exit): Remove (hopefully) extraneous call to - dll_global_dtors. - * dll_init.cc (dll_global_dtors): Run destructors in reverse - dependency/load order. - * dll_init.h (dll_list): Add dll_global_dtors as a friend. - -2008-08-01 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Add a symbol denoting return from call to - main(). - * exceptions.cc (stack_info::walk): Stop walking the stack when we - hit _cygwin_exit_return rather than just blindly stopping when PC - becomes zero. - -2008-07-31 Corinna Vinschen - - * path.cc (symlink_info::check): Handle (and explain) a special case - when accessing files matching DOS device names on SMB shares. - -2008-07-31 Corinna Vinschen - - * spawn.cc (spawn_guts): Check constructed short pathname for being - a DOS device name and fall back to long path name, if so. - -2008-07-30 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::fstat_by_name): Check for - file systems incapable of handling FileIdBothDirectoryInformation - correctly. - (fhandler_disk_file::opendir): Ditto. - * path.cc (fs_info::update): Always clear at the start. - Rearrange to make certain tests only on non-Samba, non-NFS remote - drives. - Add test for file systems known to be incapable of handling - FileIdBothDirectoryInformation correctly. Right now that's just - "UNIXFS". - * path.h (struct fs_info): Add has_buggy_fileid_dirinfo flag and - accessor methods. - (class path_conv): Add has_buggy_fileid_dirinfo method. - -2008-07-30 Corinna Vinschen - - * sec_auth.cc (extract_nt_dom_user): Return domain and user name as - WCHAR. - (cygwin_logon_user): Accommodate above change. Convert password to - WCHAR and call LogonUserW. - * external.cc (cygwin_internal): Accommodate above change. - * security.h (extract_nt_dom_user): Change prototype accordingly. - -2008-07-30 Christopher Faylor - - * cygwin.din (_getutline): Remove. - * lib/bsdlib.cc (login): Make argument const as per linux. - (logout): Ditto. - * syscalls.cc (getutid): Ditto. - (getutline): Ditto. - (pututline): Ditto. - (getutxent): Add comment mentioning non-thread-safety. - (getutxid): Ditto. - (getutxline): Ditto. - (pututxline): Ditto. - * sys/utmp.h: Declare arguments to various functions as const as per - linux. Remove bogus _getutline definition. - -2008-07-29 Christopher Faylor - - * include/cygwin/version.h: Add comment indicating that current API number - bump also has another consequence. - -2008-07-29 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Remove v8 regexp files. - (OBSOLETE_FUNCTIONS): Remove v8 regexp functions. - (NEW_FUNCTIONS): Remove POSIX regex functions. - * cygwin.din: Export POSIX regex functions with their correct symbol - name. Export with posix_ prefix for backward compatibility. - * syscalls.cc (regfree): Remove ancient fake function. - * regex/regex.h: Remove renaming regex functions within Cygwin. - * regexp/*: Remove. - * include/cygwin/version.h: Bump API minor number. - -2008-07-27 Corinna Vinschen - Christopher Faylor - - * dcrt0.cc (dll_crt0_0): Remove calling malloc_init and - user_shared_initialize_1 from here. - (dll_crt0_1): Remove dynamically_loaded check. Just call malloc_init - and user_shared_initialize unconditionally. - * shared.cc (user_shared_create): Rename from user_shared_initialize. - (user_shared_initialize): Rename from user_shared_initialize_1. Move - complete user_shared content initialization code here from - user_shared_create. - * syscalls.cc (seteuid32): Remove call to user_shared_initialize_1. - That is implied by the "true" argument to user_shared_create(). - -2008-07-27 Christopher Faylor - - * mount.cc (mount_info::init): Add location where we're looking for - fstab to temporary message. - - * lib/cygwin_crt0.c (cygwin_crt0): Simplify by eliminating - accommodations for ancient cygwin DLLs. - * lib/crt0.h: Include directly since it is needed. - -2008-07-27 Christopher Faylor - - * shared_info.h (shared_destroy): Declare. - * shared.cc (shared_destroy): Define new function to destroy shared - memory regions. - * init.cc (dll_entry): Call shared_destroy when dll detaches from the - process. - -2008-07-27 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::send_internal): Send never more - then 64K bytes at once. For blocking sockets, loop until entire data - has been sent or an error occurs. - (fhandler_socket::sendto): Drop code which sends on 64K bytes. - (fhandler_socket::sendmsg): Ditto. - -2008-07-26 Christopher Faylor - - * fhandler_tty.cc (fhandler_pty_master::setup): Reorganize so that all - operations for each end of the pipe are grouped together. - -2008-07-25 Corinna Vinschen - - * dcrt0.cc (dll_crt0_1): Call malloc_init and user_shared_initialize_1 - only in non-dynamically loaded case. - -2008-07-25 Corinna Vinschen - - * dcrt0.cc (dll_crt0_0): Call malloc_init and user_shared_initialize_1 - here in case we're dynamically loaded. Explain why. - (dll_crt0_1): Call user_shared_initialize_1 from here. - * mount.cc (is_native_path): New inline function testing for native - and long Win32 path prefix. - (is_unc_share): Remove long WIn32 path prefix test. - (mount_info::create_root_entry): Use PATH_MAX buffer. - (mount_info::init): Ditto. - (mount_info::add_item): Test for is_native_path as well. - * path.cc (normalize_win32_path): Simplify native path prefix code. - * shared.cc (user_shared_initialize_1): New function taking user - shared initialization code relying on malloc and cygtls. - (user_shared_initialize): Move mountinfo initialization to - user_shared_initialize_1. - * shared_info.h (user_shared_initialize_1): Declare. - * syscalls.cc (seteuid32): Call user_shared_initialize_1 after user - changed. - -2008-07-24 Corinna Vinschen - - * mount.cc (mount_info::from_fstab): Change system_printf to - debug_printf on NtOpenFile failure. - -2008-07-24 Corinna Vinschen - - * shared.cc (user_shared_initialize): Fetch potentially changed Cygwin - username from /etc/passwd before loading mount table. - (shared_info::init_installation_root): New function fetching Cygwin's - installation root dir and storing as native NT path in global shared - memory. - (shared_info::initialize): Call init_installation_root exactly once at - first startup. - * shared_info.h (SHARED_INFO_CB): Accommodate change to shared_info. - (CURR_SHARED_MAGIC): Ditto. - (class shared_info): Add installation_root member. - (shared_info::init_installation_root): Declare. - - * grp.cc (pwdgrp::read_group): Call pwdgrp::load with native WCHAR path. - * passwd.cc (pwdgrp::read_passwd): Ditto. Avoid recursion. - (etc::init): Take POBJECT_ATTRIBUTES instead of path_conv. - * path.h (etc::init): Change prototype accordingly. - * pwdgrp.h (class pwdgrp): Store path as UNICODE_STRING/PWCHAR instead - of as path_conv. - (pwdgrp::load): Accommodate prototype. - * uinfo.cc (pwdgrp::load): Change argument type from char to wchar_t. - Create native NT path here instead of calling path_conv. - - * mount.cc (find_root_from_cygwin_dll): Drop in favor of global - initializaion in shared_info. - (mount_info::init): Fetch native NT root dir from cygwin_shared. - (mount_info::from_fstab): Expect native NT path and use native NT - functions to access file. Convert username part in user fstab path - according to special char transformation rules. - * path.cc (tfx_chars): Convert slash to backslash. - (transform_chars): Implement for path given as PWCHAR. - (transform_chars): PUNICODE_STRING version calls PWCHAR version. - Remove useless commented code. - -2008-07-22 Corinna Vinschen - - * spawn.cc (spawn_guts): Fix previous patch for UNC paths. - -2008-07-22 Corinna Vinschen - - * spawn.cc (spawn_guts): Remove long path prefix from win32 path - before calling CreateProcess if path length is < MAX_PATH. - -2008-07-22 Corinna Vinschen - - * include/ctype.h: Declare __ctype_ptr__ to keep newlib build happy. - -2008-07-19 Corinna Vinschen - - * autoload.cc (WNetGetProviderNameA): Define. - (WNetGetResourceParentA): Remove. - * fhandler_netdrive.cc (struct net_hdls): New structure to keep - WNet handles. Stored in dir->__handle throughout. - (thread_netdrive): Rewrite to enumerate all servers in all accessible - domains and workgroups. - (fhandler_netdrive::readdir): Simplify toplevel code. Lowercase all - server names in toplevel. - (fhandler_netdrive::rewinddir): Close all WNet handles and free - net_hdls structure. - -2008-07-18 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Rename x to fh. On Samba, always - create file with NULL security descriptor and set the permissions - afterwards. Explain why. - -2008-07-18 Corinna Vinschen - - * environ.cc (known): Remove "binmode" option. - * fhandler.cc (binmode): Remove. - (fhandler_base::set_flags): Accommodate binmode removal. - * path.h (path_conv::set_binary): Remove. - * pipe.cc (pipe): Create pipes always as binary pipes. - * winsup.h (binmode): Remove declaration. - -2008-07-17 Corinna Vinschen - - * mount.cc (mount_info::from_fstab_line): Default to binary mount. - -2008-07-16 Corinna Vinschen - - * path.cc (allow_winsymlinks): Revert default to create system bit - symlinks for speed. - -2008-07-16 Corinna Vinschen - - Add case-sensitivity. - Unconditionally handle mount points case-sensitive. - Unconditionally handle virtual paths case-sensitive. - Unconditionally handle registry paths case-insensitive. - Otherwise, accommodate case-sensitivity of given path throughout. - * cygheap.cc (cygheap_root::set): Get additional caseinsensitive - parameter and store it. - * cygheap.h (struct cygheap_root_mount_info): Add member - caseinsensitive. - * dlfcn.cc (get_full_path_of_dll): Drop PC_NOFULL parameter from call - to path_conv::check. - * environ.cc (pcheck_case): Remove. - (check_case_init): Remove. - (known): Drop "check_case" option. - * exceptions.cc (open_stackdumpfile): Add comment. - * fhandler.cc (fhandler_base::get_default_fmode): Call pathmatch - instead of strcasematch. - * fhandler_disk_file.cc: Accommodate case-sensitivity of given path - throughout. - (__DIR_mounts::check_mount): Unconditionally check virtual paths - case-sensitive. - (fhandler_disk_file::link): Drop case clash handling. - (fhandler_disk_file::open): Ditto. - (fhandler_disk_file::readdir_helper): Drop managed mount code. - * mount.cc: Remove managed mount code and datastructures. - (struct opt): Remove "managed" option. Add "posix=0" and "posix=1" - options. - (fillout_mntent): Remove "managed" output. Add "posix" output. - * path.cc (struct symlink_info): Remove case_clash member and - case_check method. - (pcheck_case): Remove. - (path_prefix_p): Take additional bool parameter "caseinsensitive". - (pathnmatch): Ditto. - (pathmatch): Ditto. - (mkrelpath): Ditto. - (fs_info::update): Set caseinsensitive flag according to file system - name and FILE_CASE_SENSITIVE_SEARCH flag. Add comment. - (tfx_chars_managed): Remove. - (transform_chars): Drop "managed" parameter. Always use tfx_chars. - (get_nt_native_path): Drop "managed" parameter. Make sure drive letters - are always upper case. - (getfileattr): Change second parameter to denote caseinsensitivity. - (path_conv::check): Initialize caseinsensitive to OBJ_CASE_INSENSITIVE. - Set caseinsensitive according to global obcaseinsensitive flag, file - system case sensitivity and MOUNT_NOPOSIX mount flag. - Drop case_clash and all the related code. - (symlink_worker): Drop case clash handling. - (symlink_info::set): Drop setting case_clash. - (symlink_info::case_check): Remove. - (cwdstuff::set): Add comment. - (etc::init): Take path_conv instead of PUNICODE_STRING as parameter to - allow case sensitivity. - * path.h (enum pathconv_arg): Drop PC_SYM_IGNORE. - (enum case_checking): Remove. - (enum path_types): Drop PATH_ENC, add PATH_NOPOSIX flag. - (struct fs_info): Add caseinsensitive flag and accessor methods. - (class path_conv): Add caseinsensitive member and define - objcaseinsensitive method. Drop case_clash member and isencoded method. - (pathmatch): Change prototype according to above change. - (pathnmatch): Ditto. - (path_prefix_p): Ditto. - (get_nt_native_path): Ditto. - (class etc): Ditto. - (fnunmunge): Remove prototype. - * shared.cc (shared_info::init_obcaseinsensitive): Initialize - obcaseinsensitive flag from obcaseinsensitive registry value. - (shared_info::initialize): Call init_obcaseinsensitive here by the - first process creating the shared memory. - * shared_info.h (mount_item::fnmunge): Remove. - (shared_info::obcaseinsensitive): Rename from obcaseinsensitivity. - (shared_info::init_obcaseinsensitive): Declare. - * syscalls.cc (try_to_bin): Add comment. - * include/sys/mount.h (MOUNT_ENC): Remove flag. - (MOUNT_NOPOSIX): Add flag. - -2008-07-15 Corinna Vinschen - - * fhandler_tape.cc (mtinfo::initialize): Remove synchronization stuff. - Just initialize drive data. - * mtinfo.h (MTINFO_MAGIC): Remove. - (MTINFO_VERSION): Remove. - (class mtinfo): Remove magic and version members. - * shared.cc (shared_info::initialize): Move call to - get_session_parent_dir so that the dir creation is only called once. - Move call to mt.initialize so that it's called only by the first - process creating the shared memory. - * shared_info.h (SHARED_INFO_CB): Accommodate change to shared_info. - (CURR_SHARED_MAGIC): Ditto. - (class shared_info): Add obcaseinsensitivity member. - -2008-07-14 Corinna Vinschen - - * fhandler.cc (fhandler_base::fpathconf): On _PC_POSIX_PERMISSIONS - and _PC_POSIX_SECURITY, return true for NFS, too. - -2008-07-14 Corinna Vinschen - - Throughout drop allow_ntsec and allow_smbntsec handling. - * environ.cc (set_ntsec): Remove. - (set_smbntsec): Remove. - (known): Remove ntsec and smbntsec options. - * external.cc (check_ntsec): Return true if no filename is given. - * mount.cc (oopts): Add "acl" and "noacl" options. Set MOUNT_NOACL - flag accordingly. - (fillout_mntent): Handle MOUNT_NOACL flag. - * path.h (enum path_types): Add PATH_NOACL. - * security.cc (allow_ntsec): Remove. - (allow_smbntsec): Remove. - * security.h (allow_ntsec): Drop declaration. - (allow_smbntsec): Drop declaration. - * include/sys/mount.h (MOUNT_NOACL): Define. - -2008-07-14 Corinna Vinschen - - * miscfuncs.cc (cygwin_strncasecmp): Fix bug which results in - prematurely truncated strings. Simplify target length argument to - sys_mbstowcs. - -2008-07-14 Corinna Vinschen - - * autoload.cc (GetExtendedTcpTable): Define. - * fhandler_socket.cc (address_in_use): Take const struct sockaddr - pointer as argument. Implement additional AF_INET6 table check. - (fhandler_socket::bind): Drop AF_INET test before calling - address_in_use. - * net.cc (ipv4_getnameinfo): Return EAI_FAMILY instead of 1 if - called with unsupported af_family. - -2008-07-12 Eric Blake - - Fix usage of recently fixed Interlocked* functions. - * winbase.h (ilockincr, ilockdecr, ilockexch, ilockcmpexch): Add - volatile qualifier, to match Interlocked* functions. - -2008-07-11 Corinna Vinschen - - * select.cc (peek_pipe): Temporarily revert patch from 2008-05-30. - -2008-07-11 Corinna Vinschen - - Change length for domain buffers from INTERNET_MAX_HOST_NAME_LENGTH to - MAX_DOMAIN_NAME_LEN throughout. - * cyglsa.h (CYG_LSA_MAGIC): New value. - (cyglsa_t): Define username and domain as WCHAR arrays. - * errno.cc (errmap): Add mapping for ERROR_NONE_MAPPED. - * sec_auth.cc: Drop 'w' prefix from WCHAR string variable names where - appropriate. - (extract_nt_dom_user): Prefer resolving by SID before resolving by - domain\name pair. - (cygwin_logon_user): Don't print cleartext password in debug output. - Change comment. - (get_user_groups): Revert calls to LookupAccountNameW to use NULL - server instead of explicit server name, according to MSDN. - (get_user_local_groups): Ditto. - (get_server_groups): Fetch domain and user name from usersid per - LookupAccountSidW instead of calling extract_nt_dom_user. - (lsaauth): Fetch domain and user name from usersid per LookupAccountSidW - instead of calling extract_nt_dom_user. - * sec_helper.cc (cygpriv): Convert to wchar_t pointer array. - (privilege_luid): Convert first parameter to PWCHAR. - (privilege_name): Return wchar_t pointer. - (set_privileges): Accommodate debug output. - * security.h (privilege_luid): Change prototype accordingly. - -2008-07-10 Corinna Vinschen - - * cyglsa.h (SECURITY_STRING): Define. - (enum _SECPKG_NAME_TYPE): Define. - (struct _SECPKG_CALL_INFO): Define. - (struct _LSA_SECPKG_FUNCS): Extend to full size. Define unused - functions lazily. - (cygprf_t): Define. - * sec_auth.cc (lsaauth): Use actual primary group if no admins group. - Add (disabled) code to fetch token from profil data. - -2008-07-09 Corinna Vinschen - - * sec_auth.cc (verify_token): Allow builtin groups missing in a token - and it's still valid. Explain why. - -2008-07-09 Corinna Vinschen - - * autoload.cc (DsGetDcNameW): Replace DsGetDcNameA. - * dcrt0.cc (child_info_spawn::handle_spawn): Drop artificial - supplementary group list from calling setgroups in parent. - * grp.cc (internal_getgroups): Drop 9x-only code. Reformat. - * sec_auth.cc (get_logon_server): Do everything in WCHAR only. - (get_user_groups): Ditto. Use wlogonserver in LookupAccountNameW - calls, too. - (is_group_member): Get logon server as first argument and use in call - to NetLocalGroupGetMembers. - (get_user_local_groups): Get logon server as first argument and use in - calls to NetLocalGroupEnum and LookupAccountNameW. Revamp to work - more correctly in domain environments. - (get_server_groups): Accommodate aforementioned changed function calls. - * security.h (get_logon_server): Change prototype accordingly. - * uinfo.cc (cygheap_user::env_logsrv): Accommodate changed - get_logon_server call. - -2008-07-09 Corinna Vinschen - - * grp.cc (internal_getgroups): Also add integrity-enabled groups. - -2008-07-09 Corinna Vinschen - - * sec_auth.cc (verify_token): Disable code which returns false if - the token contains additional groups not requested by setgroups. - Explain why. - -2008-07-08 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::bind): Don't run explicit - local socket test in SO_REUSEADDR case on systems supporting - enhanced socket security. Explain why. Only call address_in_use - for AF_INET sockets. - * net.cc (cygwin_setsockopt): Don't call setsockopt to set SO_REUSEADDR - on systems supporting enhanced socket security. Add comment. - * wincap.h (wincaps::has_enhanced_socket_security): New element. - * wincap.cc: Implement above element throughout. - -2008-07-08 Corinna Vinschen - - * net.cc (ipv6_inited): Make NO_COPY. - -2008-07-02 Corinna Vinschen - - * path.cc (path_conv::is_binary): Fix test. Add comment. - -2008-06-24 Corinna Vinschen - - * net.cc (cygwin_bindresvport_sa): Fix usage of last_used_bindresvport. - -2008-06-21 Corinna Vinschen - - * include/limits.h (PATH_MAX): Add comment. - * include/cygwin/config.h (__FILENAME_MAX__): Define as 4096. Add - comment. - -2008-06-19 Corinna Vinschen - - * fhandler_tty.cc (fhandler_pty_master::setup): Fix pipe inheritance. - -2008-06-18 Christopher Faylor - - * strsig.cc (strsignal): Return non-const buffer to allow building with - recent newlib change. - -2008-06-17 Corinna Vinschen - - * sec_auth.cc (DsGetDcNameA): Drop declaration. - (DS_FORCE_REDISCOVERY): Drop definition. - -2008-06-17 Christopher Faylor - - * spawn.cc (spawn_guts): Reinstate call to - fhandler_console::need_invisible since it is required to prevent - console flashing. - -2008-06-17 Corinna Vinschen - - * include/resolv.h (_getshort): Drop declaration. - (_getlong): Ditto. - -2008-06-12 Corinna Vinschen - - * mount.cc (mount_info::get_cygdrive_info): Fix usage of user and - system arguments. Strip trailing slash from path for backward - compatibility. - -2008-06-12 Corinna Vinschen - - * fhandler.h (set_console_state_for_spawn): Drop declaration. - * fhandler_console.cc (set_console_state_for_spawn): Remove. - (fhandler_console::open): Set console state last. Don't set - ENABLE_PROCESSED_INPUT flag. - * spawn.cc (spawn_guts): Drop call to set_console_state_for_spawn. - -2008-06-11 Corinna Vinschen - - * path.cc (get_nt_native_path): Drop considerations for DOS devices. - Keep relative paths relative. - (cygwin_conv_path): Don't try to skip native NT prefixes on relative - paths. - -2008-06-11 Corinna Vinschen - - * include/cygwin/version.h (CYGWIN_VERSION_MOUNT_REGISTRY): Bump. - (CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME): Remove. - (CYGWIN_INFO_CYGDRIVE_FLAGS): Remove. - (CYGWIN_INFO_CYGDRIVE_PREFIX): Remove. - (CYGWIN_INFO_CYGDRIVE_DEFAULT_PREFIX): Add comment to differ from the - registry related defines. - -2008-06-11 Corinna Vinschen - - * fhandler_procnet.cc (dad_to_flags): Fix comment. - -2008-06-10 Corinna Vinschen - - * fhandler_procnet.cc (get_scope): New static function to evaluate - scope. - (dad_to_flags): New static array to convert Windows DAD state to - Linux values. - (format_procnet_ifinet6): Drop asking for IfIndex, just use Ipv6IfIndex. - Use get_scope and dad_to_flags to generate more accurate linux-like - output. - -2008-06-10 Corinna Vinschen - - * net.cc (if_nametoindex): Fix typo in call to get_adapters_addresses. - (if_indextoname): Prefer IPv6 loopback device name over IPv4 loopback - device name on pre-Vista systems. - (if_nameindex): Ditto. - -2008-06-10 Corinna Vinschen - - * fhandler_procnet.cc (format_procnet_ifinet6): Use sprintf rather than - __small_sprintf. - * net.cc (if_nametoindex): Prefer IPv6IfIndex over IfIndex for - consistency with /proc/net/if_inet6. - (if_indextoname): Ditto. - (if_nameindex): Ditto. - -2008-06-10 Corinna Vinschen - - * mount.cc (mount_info::from_fstab): Read sizeof (buf) - 2 bytes. - Add code to handle overly long lines. - -2008-06-10 Corinna Vinschen - - * sec_auth.cc (lsaauth): Make returned token inheritable. - -2008-06-10 Corinna Vinschen - - * devices.cc: Regenerate. - -2008-06-09 Christopher Faylor - - * devices.in: Remove "Global" from tty device. - -2008-06-09 Eric Blake - - * signal.cc (abort): Only flush streams after signal handler. - -2008-06-02 Christopher Faylor - - * cygwin.sc: Remove unrequired and erroneous definition. - -2008-05-30 Christopher Faylor - - * select.cc (peek_pipe): Semi-reinstate pipe NT-special write - detection. - -2008-05-29 Christopher Faylor - - * devices.in: Change mapping for /dev/ttyS* and /dev/com*. - * devices.cc: Regenerate. - -2008-05-25 Christopher Faylor - - * mount.cc (mount_info::from_fstab): Use proper buffer size. - -2008-05-24 Christopher Faylor - - * mount.cc (mount_info::init): Revert previous change. - (mount_info::from_fstab): Change system_printf to debug_printf. Just - use a local NT_MAX_PATH sized temporary buffer. - -2008-05-24 Corinna Vinschen - - * mount.cc (mount_info::init): Recreate path when trying to read the - user fstab file. - -2008-05-24 Corinna Vinschen - - * path.cc (symlink_info::check): Reorder test for nfs symlinks. - -2008-05-23 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Don't try to - use FileIdBothDirectoryInformation on NFS shares. Fix comment to - explain why. - * path.cc (symlink_info::check): Reinstantiate no_ea. Use in - erroneously changed condition. - -2008-05-23 Christopher Faylor - - * mount.cc (find_root_from_cygwin_dll): New function factored from - from_fstab. Avoid use of tls since it isn't necessarily initialized - when cygwin1.dll is dynamically loaded. - (mount_info::create_root_entry): Ditto. - (mount_info::init): Calculate cygwin root once. Use create_root_entry - to record it. Pass fstab location to from_fstab. - (mount_info::from_fstab): Move root calculation stuff elsewhere, as per - above. - - * shared_info.h (mount_info::from_fstab_line): Make private. - (mount_info::fstab): Ditto. Accommodate new arguments. - -2008-05-23 Christopher Faylor - - * mount.cc (mount_info::from_fstab): Use cygwin_hmodule rather than - trying to find handle based on cygwin1.dll. - - * path.cc (symlink_info::check): Remove unused variable. - -2008-05-23 Corinna Vinschen - - * shared.cc (open_shared): Fix comments. Fix a condition which has - been overlooked to revert to its old state in change from 2008-04-18. - -2008-05-22 Corinna Vinschen - - * path.cc (symlink_info::check): Define eabuf and easize outside of - loop. Set to NULL on first STATUS_EAS_NOT_SUPPORTED. Align comments. - Fix formatting. - -2008-05-23 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::readdir): Eliminate - compiler warning. - -2008-05-23 Christopher Faylor - - * path.cc (symlink_info::check): Don't pass EaBuffer to NtCreateFile if - it has indicated that it isn't appropriate. - * ntdll.h (STATUS_EAS_NOT_SUPPORTED): Define. - - * winsup.h: Remove __builtin* defines. - -2008-05-22 Corinna Vinschen - - * grp.cc (internal_getgroups): Fix thinko. Only add enabled groups to - the group list. - -2008-05-22 Corinna Vinschen - - * grp.cc (internal_getgroups): Don't add deny-only groups to the group - list. - -2008-05-22 Corinna Vinschen - - * cygtls.h (struct san): Add two int values to store the current - tls_pathbuf counters. - (return_from_fault): Restore tls_pathbuf counters. - (setup_fault): Save tls_pathbuf counters. - * tlsoffset.h: Regenerate. - -2008-05-22 Corinna Vinschen - - * sec_acl.cc (setacl): Set errno to EINVAL if user or group don't exist. - -2008-05-22 Corinna Vinschen - - * path.cc (cygwin_conv_path): Define tp before setting up faul handler. - * syscalls.cc: Ditto, throughout. - (gen_full_path_at): Add bool parameter to allow NULL pathname. - (futimesat): Allow NULL pathname as GLIBC. - -2008-05-21 Christopher Faylor - - * string.h (strchr): Eliminate. - - * syscalls.cc (rename): Work around inexplicable C++ warning. - -2008-05-21 Corinna Vinschen - - * fhandler_disk_file.cc (get_ino_by_handle): Rename pfai to fai. - (fhandler_base::fstat_by_handle): Drop fai_size and pfai in favor of - static struct fai_buf. Restructure. - (fhandler_base::fstat_by_name): Drop fvi_size and pfvi. Drop fdi_size - and pfdi in favor of static struct fdi_buf. Drop redundant test for - existance. Use FileDirectoryInformation class instead of - FileBothDirectoryInformation. Drop call to NtQueryVolumeInformationFile - in favor of using pc.fs_serial_number (). Fix FileId information given - to fstat_helper. - (fhandler_disk_file::fstatvfs): Drop fvi_size, pfvi, fai_size and pfai. - Drop getting FileFsVolumeInformation and FileFsAttributeInformation in - favor of using the related path_conv info. - (fhandler_disk_file::opendir): Fix comment. - (fhandler_disk_file::readdir): Ditto. Use FileDirectoryInformation - class instead of FileBothDirectoryInformation. - * path.cc (fs_info::update): Store MaximumComponentNameLength in new - member name_len. - * path.h (struct fs_info): Use ULONG rather than DWORD. Add member - name_len to store MaximumComponentNameLength. Add accessor methods. - (path_conv::fs_name_len): New method. - -2008-05-21 Corinna Vinschen - - * fhandler.h (dirent_states): Add dirent_nfs_d_ino state and add it to - dirent_info_mask. - * fhandler_disk_file.cc (fhandler_disk_file::opendir): Set - dirent_nfs_d_ino flag for NFS shares. Explain why. - (fhandler_disk_file::readdir): Use FileNamesInformation instead of - FileBothDirectoryInformation info class on NFS clients not supporting - the FileIdBothDirectoryInformation info class. Use local pointers to - accommodate different offsets. - * path.cc (symlink_info::check): Don't test directories for symlinks - on NFS shares. Enhance comment. - -2008-05-21 Corinna Vinschen - - * syscalls.cc (FILTERED_MODE): Define valid chmod mode mask. - (chmod): Call fh->fchmod with filtered mode. - (fchmod): Ditto. - -2008-05-20 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Fix test for - S_IFSOCK in mode bits. - -2008-05-20 Corinna Vinschen - - * path.cc (symlink_worker): Fix EA buffer size info given to - NtCreateFile. - (symlink_info::check_nfs_symlink): Get 64K buffer for EA buffer. - Change EA buffer size info given to NtQueryEaFile accordingly. - -2008-05-20 Corinna Vinschen - - * path.cc (symlink_info::check_shortcut): Minimize requested file - access flags. - (symlink_info::check_sysfile): Ditto. Add missing `else'. - (symlink_info::check): Only retry to open file if first try failed - with access denied. - -2008-05-20 Corinna Vinschen - - * path.cc (fs_info::update): Re-add opening the unsplitted path - for fillout_mntent's sake. - -2008-05-20 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::mkdir): Create directories - on NFS shares with correct mode bits. - -2008-05-20 Corinna Vinschen - - * winsup.h (cygwin_inet_addr): Fix type of declaration. - -2008-05-20 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Add nfs.o. - * fhandler.cc (fhandler_base::open): Open files on NFS shares with - correct access flags and EAs. - * fhandler.h (fhandler_base::fstat_by_nfs_ea): Declare. - * fhandler_disk_file.cc (fhandler_base::fstat_by_nfs_ea): New method. - (fhandler_base::fstat_by_handle): Call fstat_by_nfs_ea for files on - NFS shares. - (fhandler_disk_file::fchmod): Use NFS specific method to set mode for - files on NFS shares. Don't overrule errno from call to - set_file_attribute with errno from NtSetInformationFile call. - (fhandler_disk_file::fchown): Add comment. - * mount.cc (fillout_mntent): Accommodate change in second parameter - to fs_info::update. - * nfs.cc: New file. - * nfs.h: New file. - * path.cc (fs_info::update): Take handle instead of bool as second - parameter. Use that handle if it's not NULL. Only close handle if - it has been opened here. Use static defined buffers instead of - alloca'd buffers. - (path_conv::check): Call symlink_info::check with reference to fs. - Don't call fs.update here if file exists. - (conv_path_list): Prefer tmp_pathbuf buffer over using alloca. - (symlink_worker): Use NFS specific method to create symlinks on NFS - shares. Prefer tmp_pathbuf buffer over using alloca. - (symlink_info::check_shortcut): Reopen file from incoming handle - with necessary FILE_GENERIC_READ flag. Prefer tmp_pathbuf buffer over - using alloca. - (symlink_info::check_sysfile): Ditto. - (symlink_info::check_reparse_point): Use tmp_pathbuf buffer to - allocate REPARSE_DATA_BUFFER. - (symlink_info::check_nfs_symlink): New method. - (enum symlink_t): Remove. - (symlink_info::check): Don't use NtQueryAttributesFile. Rather, open - file with necessary access flags and call NtQueryInformationFile. Fix - error handling in case file can't be opened. For existing files, call - fs_info::update here. Restructure symlink checking to accommodate the - fact that the file is already open. Add case for NFS symlinks. - * path.h (fs_info::update): Take handle instead of bool as second - parameter. - -2008-05-20 Corinna Vinschen - - * syscalls.cc (rename): Fix condition when to start a transaction. - -2008-05-20 Corinna Vinschen - - * path.cc (path_conv::check): Free wide_path and normalized_path if - necessary. - * path.h (path_conv::path_conv): Set wide_path, normalized_path and - normalized_path_size to 0 in all constructors. - -2008-05-19 Corinna Vinschen - - * syscalls.cc (rename): Allocate temporary path buffers using - tmp_pathbuf. Don't try to unset R/O attribute on dstpc if a - removepc exists. dstpc is a non-existant file in that case. - -2008-05-17 Christopher Faylor - - * include/stdint.h: Use int rather than long for {u,}int32_t. - -2008-05-16 Corinna Vinschen - - * CYGWIN_LICENSE: Remove duplicate file here. - -2008-05-15 Corinna Vinschen - - * syscalls.cc (rename): ONly start transaction if FS supports them. - -2008-05-15 Corinna Vinschen - - * autoload.cc (LoadDLLfuncNt): Re-invent. - (NtCreateTransaction): Define. - (NtCommitTransaction): Define. - (NtRollbackTransaction): Define. - (RtlGetCurrentTransaction): Define. - (RtlSetCurrentTransaction): Define. - * ntdll.h (TRANSACTION_ALL_ACCESS): Define. - (NtCreateTransaction): Declare. - (NtCommitTransaction): Declare. - (NtRollbackTransaction): Declare. - (RtlGetCurrentTransaction): Declare. - (RtlSetCurrentTransaction): Declare. - * syscalls.cc (start_transaction): New static function to start TxF - transaction. - (stop_transaction): New static function to end TxF transaction. - (rename): Call start_transaction and stop_transaction where appropriate - on systems supporting transactions. - * wincap.h (wincaps::has_transactions): New element. - * wincap.cc: Implement above element throughout. - -2008-05-14 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::readdir_helper): Drop - explicit transformation of special DOS chars. - * strfuncs.cc (sys_wcstombs): Always transform UNICODE private use area - back to ASCII. - -2008-05-13 Corinna Vinschen - - * include/cygwin/stdlib.h (initstate): Declare. - (setstate): Declare. - -2008-05-13 Corinna Vinschen - - * path.cc (path_conv::set_normalized_path): Drop strip_tail argument. - Never strip trailing dots and spaces. - * (path_conv::check): Accomodate above change. - * path.h (path_conv::operator=): Ditto - * dtable.cc (build_fh_dev): Ditto. - * fhandler.h (fhandler_base::set_name): Ditto. - - * path.cc (transform_chars): Disable converting trailing dots and - spaces. - - * path.cc (path_conv::check): Remove two disabled code snippets. - -2008-05-13 Corinna Vinschen - - * random.cc (initstate): Align to POSIX definition. - (setstate): Ditto. - -2008-05-10 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Remove _def_time.o. - * libc/_def_time.c: Remove. Move definitions of _DefaultTimeLocale - and _CurrentTimeLocale ... - * libc/strptime.cc: ... here. - -2008-05-08 Corinna Vinschen - - * include/sys/localedef.h: Remove. - * libc/strptime.cc: Define _TimeLocale and declare _CurrentTimeLocale - as well as _DefaultTimeLocale locally for Cygwin. - -2008-05-08 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Add _def_time.o. Remove timelocal.o. - * include/sys/localedef.h: New file from NetBSD. - * libc/_def_time.c: Ditto. - * libc/getopt.c: Update to latest OpenBSD version 1.23. - * libc/strptime.cc: Replace FreeBSD version 1.35 with latest NetBSD - version 1.28. - * libc/timelocal.cc: Remove. - * libc/timelocal.h: Remove. - -2008-04-30 Corinna Vinschen - - * dtable.cc (dtable::release): Drop fixup_before handling. - (dtable::fixup_before_fork): Remove. - (dtable::fixup_before_exec): Remove. - * dtable.h (class dtable): Remove cnt_need_fixup_before member. - (dtable::dtable): Accommodate above change. - (dtable::dec_need_fixup_before): Remove. - (dtable::inc_need_fixup_before): Remove. - (dtable::need_fixup_before): Remove. - (dtable::fixup_before_exec): Remove declaration. - (dtable::fixup_before_fork): Ditto. - * fhandler.h (fhandler_base::fixup_before_fork_exec): Remove. - (fhandler_base::need_fixup_before): Remove. - * fork.cc (frok::parent): Drop fixup_before handling. - * spawn.cc (spawn_guts): Ditto. - -2008-04-30 Corinna Vinschen - - * mount.cc (is_unc_share): Allow \\?\ prefix as well. Enhance comment. - (mount_info::from_fstab): Remove patch from 2008-04-29. - - * mount.cc (mount_info::conv_to_posix_path): Simplify test for native - UNC path. - * path.cc (normalize_win32_path): Ditto. - (symlink_worker): Ditto. - (symlink_info::posixify): Ditto. - (cygwin_conv_path): Ditto. - -2008-04-29 Corinna Vinschen - - * mount.cc (mount_info::from_fstab): Skip native path prefix in - module path. - -2008-04-29 Corinna Vinschen - - * syscalls.cc (rename): Use volume serial numbers stored in path_conv - rather than fetching them here for the "same file" test. Change - comment to reflect this. - -2008-04-28 Corinna Vinschen - - * path.cc (symlink_info::check): Avoid special handling for - STATUS_BUFFER_OVERFLOW when calling NtQueryDirectoryFile. - * strace.cc (strace::vprntf): Use bigger buffer. - -2008-04-28 Corinna Vinschen - - * kernel32.cc (CreateFileMappingW): Remove stray small_printf. - -2008-04-28 Corinna Vinschen - - * autoload.cc (IsWow64Process): Remove. - (Wow64DisableWow64FsRedirection): Remove. - (Wow64RevertWow64FsRedirection): Remove. - * ntdll.h (enum _PROCESSINFOCLASS): Define ProcessWow64Information. - * init.cc (respawn_wow64_process): Use NtQueryInformationProcess to - get WOW64 state. - * wincap.cc (wincapc::init): Ditto. - * wincap.h (wincapc::wow64): Change type to ULONG. - -2008-04-27 Corinna Vinschen - - * wincap.h (wincapc::wow64): Change type to BOOL. - * wincap.cc: Remove explicit use of this pointer in wincapc methods. - (wincapc::init): Fix bug in IsWow64Process handling. - -2008-04-26 Corinna Vinschen - - * dcrt0.cc (dll_crt0_0): Set SEM_NOGPFAULTERRORBOX error mode, too, - to accommodate Vista/Longhorn. - * spawn.cc (spawn_guts): Move check for CREATE_SUSPENDED condition - after the call to ch.set() since it depends on it. - -2008-04-25 Corinna Vinschen - - * Makefile.in (install): Drop install rules for postinstall script. - -2008-04-25 Corinna Vinschen - - * postinstall: Remove (Moved to base-cygwin package). - -2008-04-25 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Move handling FILE_ATTRIBUTE_NORMAL - back to its old place. Or it to file_attributes instead of setting it. - -2008-04-25 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): *Only* handle SYSTEM and HIDDEN - attributes in FILE_OVERWRITE case. - -2008-04-25 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Handle SYSTEM and HIDDEN attributes - in FILE_OVERWRITE case as well. - -2008-04-24 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::fstat_helper): Disable calling - pc.ndisk_links. Just use nNumberOfLinks instead. - -2008-04-24 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::utimens_fs): Fix typo in - input range check. - -2008-04-24 Corinna Vinschen - - * cygwin.din (futimens): Export. - (utimensat): Export. - * fhandler.cc (fhandler_base::utimens): Replace fhandler_base::utimes. - Call utimens_fs. - * fhandler.h (class fhandler_base): Declare utimens_fs instead of - utimes_fs, utimens instead of utimes. - (class fhandler_disk_file): Declare utimens instead of utimes. - * fhandler_disk_file.cc (fhandler_disk_file::utimens): Replace - fhandler_disk_file::utimes. - (fhandler_base::utimens_fs): Replace fhandler_base::utimes_fs. - Implement tv_nsec handling according to SUSv4. - * syscalls.cc (utimensat): New function. - * times.cc (timespec_to_filetime): New function. - (timeval_to_timespec): New function. - (utimens_worker): Replace utimes_worker. - (utimes): Convert timeval to timespec and call utimens_worker. - (lutimes): Ditto. - (futimens): Take over implementation from futimes. - (futimes): Convert timeval to timespec and call futimens. - * winsup.h (timespec_to_filetime): Declare. - * include/cygwin/version.h: Bump API minor number. - * posix.sgml: Add SUSv4 section. Add futimens and utimensat to it. - -2008-04-24 Yaakov (Cygwin Ports) - - * include/wait.h: New file. - -2008-04-23 Corinna Vinschen - - * posix.sgml: Add openat, faccessat, fchmodat, fchownat, fstatat, - futimesat, linkat, mkdirat, mkfifoat, mknodat, readlinkat, renameat, - symlinkat, unlinkat to list of implemented Solaris functions. - -2008-04-23 Corinna Vinschen - - * cygwin.din: Sort. - (faccessat): Export. - (fchmodat): Export. - (fchownat): Export. - (fstatat): Export. - (futimesat): Export. - (linkat): Export. - (mkdirat): Export. - (mkfifoat): Export. - (mknodat): Export. - (openat): Export. - (readlinkat): Export. - (renameat): Export. - (symlinkat): Export. - (unlinkat): Export. - * path.cc (readlink): Align definition to POSIX. - * syscalls.cc (gen_full_path_at): New static function. - (faccessat): Implement. - (fchmodat): Implement. - (fchownat): Implement. - (fstatat): Implement. - (futimesat): Implement. - (linkat): Implement. - (mkdirat): Implement. - (mkfifoat): Implement. - (mknodat): Implement. - (openat): Implement. - (readlinkat): Implement. - (renameat): Implement. - (symlinkat): Implement. - (unlinkat): Implement. - * include/cygwin/version.h: Bump API minor number. - -2008-04-22 Corinna Vinschen - - * dcrt0.cc (dll_crt0_0): Move CWD initialization from here... - (dll_crt0_1): ...to here. - -2008-04-22 Corinna Vinschen - - * cygwin.din (fmemopen): Export. - (open_memstream): Export. - * include/cygwin/version.h: Bump API minor number. - -2008-04-22 Corinna Vinschen - - * sec_auth.cc (create_token): Add integrity level SID to token on - systems supporting that. Remove useless check for dynamically loading - NtCreateToken function. - * sec_helper.cc (mandatory_medium_integrity_sid): Define. - (mandatory_high_integrity_sid): Define. - (mandatory_system_integrity_sid): Define. - * sec_helper.h (mandatory_medium_integrity_sid): Declare. - (mandatory_high_integrity_sid): Declare. - (mandatory_system_integrity_sid): Declare. - -2008-04-21 Corinna Vinschen - - * mount.cc (mount_info::init): Remove call to from_registry. Print - message that fstab is missing. - (mount_info::from_fstab): Use CYGWIN_INFO_CYGDRIVE_DEFAULT_PREFIX - instead of constant string. - (mount_info::read_mounts): Remove. - (mount_info::from_registry): Remove. - (mount_info::read_cygdrive_info_from_registry): Remove. - * postinstall: Enable code to create fstab entries from old registry - entries. - * registry.cc (reg_key::reg_key): Drop CYGWIN_INFO_CYGNUS_REGISTRY_NAME - from registry key. - * shared_info.h (mount_info::read_mounts): Remove declaration. - (mount_info::from_registry): Ditto. - (mount_info::to_registry): Ditto. - (mount_info::read_cygdrive_info_from_registry): Ditto. - * winver.rc (CYGWIN_REGISTRY_KEY): Remove. - (LegalCopyright): Fix to include 2008. - (RegistryKey): Set to CYGWIN_INFO_CYGWIN_REGISTRY_NAME. - * include/cygwin/version.h (CYGWIN_INFO_CYGNUS_REGISTRY_NAME): Remove. - -2008-04-21 Corinna Vinschen - - * kernel32.cc (CreateFileMappingW): Fix bug in reserve/commit handling. - -2008-04-21 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Add kernel32.o. - * autoload.cc (WSACloseEvent): Remove. - (WSACreateEvent): Remove. - * cygheap.cc (cygheap_init): Drop initializing shared_prefix. - * cygheap.h (struct init_cygheap): Drop shared_prefix and - shared_prefix_buf members. - * fhandler_socket.cc (sock_shared_name): New static function. - (search_wsa_event_slot): Convert name buffers to WCHAR. Call - NtCreateMutant/NtOpenMutant to create mutexes in session local - namespace. - (fhandler_socket::init_events): Ditto. Fix debug output. - (fhandler_socket::release_events): Close mutexes using NtClose. - (fhandler_socket::dup): Ditto. - * kernel32.cc: New file, implementing Win32 calls in a Cygwin-specific - way. - * mmap.cc (MapView): Make static. - * ntdll.h: Fix status code sorting. - (STATUS_OBJECT_NAME_EXISTS): Define. - (SEMAPHORE_QUERY_STATE): Define. - (CYG_SHARED_DIR_ACCESS): Define. - (CYG_MUTANT_ACCESS): Define. - (CYG_EVENT_ACCESS): Define. - (CYG_SEMAPHORE_ACCESS): Define. - (enum _PROCESSINFOCLASS): Define ProcessSessionInformation. - (struct _PROCESS_SESSION_INFORMATION): Define. - (NtCreateSemaphore): Declare. - (NtOpenSemaphore): Declare. - * flock.cc: Use CYG_xxx_ACCESS access masks where appropriate. - * posix_ipc.cc (ipc_mutex_init): Use native functions to create mutex. - Create in cygwin-shared subdir. - (ipc_cond_init): Ditto for event. - (ipc_mutex_close): Use NtClose. - (ipc_cond_close): Ditto. - (mq_open): Drop "cyg" prefix from mqh_uname. - * shared.cc (CYG_SHARED_DIR_ACCESS): Drop definition here. - (_cygwin_testing): Declare extern on file level. - (get_shared_parent_dir): Change name of shared directory. Add name - to api_fatal output. - (get_session_parent_dir): New function. - (shared_name): Simplify. - (shared_info::initialize): Call get_session_parent_dir. - * shared_info.h (get_session_parent_dir): Declare. - * smallprint.cc (__small_vswprintf): Fix bug in multibyte string - conversion. - * thread.cc (semaphore::semaphore): Align semaphore name to object - names in posix IPC functions. - * include/cygwin/version.h (CYGWIN_VERSION_SHARED_DATA): Bump. - -2008-04-18 Corinna Vinschen - - Revert thinko in previous patch. - * fhandler.h (struct wsa_event): Move back from wsa_event.h to here. - * fhandler_socket.cc (NUM_SOCKS): Ditto. - (wsa_events): Move back from cygwin_shared to here. Accommodate - throughout. - (socket_serial_number): Ditto. - * shared_info.h: Accommodate above changes. - * wsa_event.h: Remove. - -2008-04-18 Corinna Vinschen - - * fhandler.h (struct wsa_event): Move to wsa_event.h. Include - wsa_event.h instead. - * fhandler_socket.cc (NUM_SOCKS): Move to wsa_event.h. - (wsa_events): Move from DLL shared area to cygwin_shared shared - memory. Accommodate throughout. - (socket_serial_number): Ditto. - * fhandler_tape.cc (mt): Ditto. - (mtinfo_init): Remove. - (mt): Define as cygwin_shared->mt. - * flock.cc (FLOCK_PARENT_DIR_ACCESS): Remove. - (FLOCK_INODE_DIR_ACCESS): Move up in file. - (FLOCK_MUTANT_ACCESS): Ditto. - (FLOCK_EVENT_ACCESS): Ditto. - (get_lock_parent_dir): Remove. - (inode_t::inode_t): Call get_shared_parent_dir to get parent dir handle. - Add a "flock-" prefix to file's lock directory name for clarity. - * mtinfo.h (mtinfo_init): Drop declaration. - * net.cc (last_used_bindresvport): Move from DLL shared area to - cygwin_shared shared memory. - (cygwin_bindresvport_sa): Accommodate above change. - * sec_helper.cc (_everyone_sd): Move here from flock.cc. - * security.h (SD_MIN_SIZE): Ditto. - (everyone_sd): Ditto. - * shared.cc (cygwin_shared_area): Remove. - (cygwin_shared_h): New handle. - (get_shared_parent_dir): New static function. - (shared_name): Drop session_local argument. Call get_shared_parent_dir - here. Add cygwin-shared subdir to object name. - (offsets): Reinstantiate SH_CYGWIN_SHARED member. - (open_shared): Revert change from 2007-03-29 for systems supporting - SeCreateGlobalPrivilege. - (shared_info::initialize): Call mtinfo's initialize here. - (memory_init): Drop call to mtinfo_init. - * shared_info.h (SHARED_INFO_CB): Accommodate change to shared_info. - (CURR_SHARED_MAGIC): Ditto. - (class shared_info): Add members for global socket and tape info - sharing. - (enum shared_locations): Reinstantiate SH_CYGWIN_SHARED. - (get_shared_parent_dir): Declare. - (shared_name): Drop session_local argument from declaration. - * wsa_event.h: New file. Move definitions of NUM_SOCKS and - struct wsa_event here. - -2008-04-18 Christopher Faylor - - * autoload.cc (noload): Make sure this and succeeding functions are - located in the text segment. - -2008-04-16 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::close): Disable enforced - lingering since the original problem can no longer be reproduced. - -2008-04-16 Corinna Vinschen - - * grp.cc (internal_getgroups): Drop local buf. Allocate groups - directly using alloca. - -2008-04-14 Corinna Vinschen - - * postinstall: Fix copy/paste bug. - -2008-04-14 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::readdir_helper): Fix - thinko in UNC path handling. - * path.cc (symlink_worker): Fix typo in comment. Fix UNC path handling. - -2008-04-13 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::readdir_helper): Simplify - code which checks for symlinks. Fix problem with UNC paths. - - * environ.cc (struct parse_thing): Remove transparent_exe option. - * syscalls.cc (transparent_exe): Remove. - (unlink): Always add stat_suffixes, drop transparent_exe check. - (open): Ditto. - (link): Ditto. - (pathconf): Ditto. - * fhandler_disk_file.cc (fhandler_disk_file::link): Ditto. - * fhandler_process.cc (fhandler_process::fill_filebuf): Always remove - .exe suffix. - * path.cc (realpath): Never attach known_suffix. - -2008-04-10 Corinna Vinschen - - * cygwin.din (wprintf): Remove. - (_wprintf): Ditto. - * syscalls.cc (wprintf): Ditto. - * include/cygwin/version.h: Add FIXME comment. - -2008-04-08 Corinna Vinschen - - * mount.cc (mount_info::from_fstab): Read user fstab files from - /etc/fstab.d/$USER to avoid user write access to /etc. - * postinstall: Use variables for filenames. Create /etc/fstab.d dir - with 01777 permissions. - -2008-04-08 Corinna Vinschen - - * postinstall: Disable adding registry mounts to /etc/fstab for now. - -2008-04-07 Christopher Faylor - - Remove unneeded header files from source files throughout. - -2008-04-07 Corinna Vinschen - - * postinstall: Add function print_flags and call where appropriate. - Omit system and cygdrive flag when testing cygdrive flags. - -2008-04-07 Christopher Faylor - - Add miscfuncs.h to files as needed throughout. - * mount.cc: New file. - * path.cc: Move mount-specific stuff into mount.cc. Move common stuff - into miscfuncs.cc. Remove unneeded includes. - * miscfuncs.cc: Move some common path functions here. - * miscfuncs.h: New file. - * winsup.h: Move miscelleneous functions to miscfuncs.h. - * dcrt0.cc: Remove unneeded includes. - * Makefile.in (DLL_OFILES): Add mount.o. - - * include/cygwin/config.h: Fix a minor typo. - -2008-04-07 Corinna Vinschen - - * postinstall: Set IFS to LF only. Change while loop in subshell to - for loop in parent shell. Add code to read system mount points and - system cygdrive prefix from registry and append them to /etc/fstab. - -2008-04-06 Corinna Vinschen - - * path.cc (struct opt): Rename "system" to "nouser". - * postinsatll: Ditto. - -2008-04-05 Corinna Vinschen - - * postinstall: New script. - * Makefile.in (sysconfdir): Define. - (install): Create $(sysconfdir)/postinstall dir. Install postinstall - script into it. - - * path.cc: Add temorary comments to note later function removal. - (conv_fstab_spaces): New inline function to handle \040 to space - conversion. - (struct opt): Add "system" and "user" mount options. - (mount_info::from_fstab_line): Only allow # to start a comment at - the beginning of the line. Call conv_fstab_spaces on native_path and - posix_path fields. Don't enforce system mounts in /etc/fstab. - Drop last argument in call to add_item. - (mount_info::from_fstab): Create a default cygdrive entry. Load - user mount points from fstab. instead of fstab.. - (mount_info::read_mounts): Drop last argument in call to add_item. - (mount_info::add_reg_mount): Remove. - (mount_info::del_reg_mount): Remove. - (mount_info::write_cygdrive_info): Rename from - mount_info::write_cygdrive_info_to_registry. Don't write to registry. - Disallow to overwrite a system cygdrive prefix. - (mount_info::remove_cygdrive_info_from_registry): Remove. - (mount_info::get_cygdrive_info): Just fetch current cygdrive prefix and - flags. - (mount_info::add_item): Drop last argument. Don't write to registry. - Disallow to overwrite a system mount point. - (mount_info::del_item): Drop last argument. Don't write to registry. - Disallow to remove a system mount point. - (mount): Enforce user mount. - (cygwin_umount): Ditto. - * shared_info.h (mount_info::add_item): Drop last argument. - (mount_info::del_item): Ditto. - (mount_info::add_reg_mount): Remove. - (mount_info::del_reg_mount): Remove. - (mount_info::write_cygdrive_info): Rename from - mount_info::write_cygdrive_info_to_registry. - (mount_info::remove_cygdrive_info_from_registry): Remove. - -2008-04-03 Corinna Vinschen - - * path.cc (mount_info::from_fstab_line): Simplify. Recognize special - "cygdrive" entry from FS type field. - (mount_info::from_fstab): Create a default root dir. - -2008-04-03 Corinna Vinschen - - * dcrt0.cc (insert_file): Fix potential buffer overflow. - -2008-04-03 Corinna Vinschen - - * path.cc (mount_info::from_fstab): Get module path name of the Cygwin - DLL, not the path of the application. - -2008-04-03 Corinna Vinschen - - Cleanup. - * exceptions.cc (windows_system_directory): Make static. Convert to - WCHAR. - (_cygtls::inside_kernel): Accommodate above change. Check module - path name for leading \\?\ and skip, if so. - (try_to_debug): Call GetEnvironmentStringsW and convert evaluation to - WCHAR to avoid truncated environment problem. - (has_visible_window_station): Call GetUserObjectInformationW. - (events_init): Accommodate above conversion of windows_system_directory. - * init.cc (respawn_wow64_process): Use WCHAR functions to start new - process. - * net.cc (__dup_ent): Drop Windows 9x consideration. - (load_ipv6_funcs): Use WCHAR functions to load IPv6 libs. - * syscalls.cc (syscalls.cc): Remove call to GetDiskFreeSpace. - -2008-04-02 Corinna Vinschen - - * path.cc (mount_info::init): First try to fetch mount points from - fstab files. Fallback to registry if none exists. - (skip_ws): New inline function. - (find_ws): Ditto. - (struct opt): New structure for mount options. - (read_flags): New static function to convert a mount flags string into - a flag value. - (mount_info::from_fstab_line): New method to create a mount table - entry from a fstab line. - (mount_info::from_fstab): New method to read fstab file. - * shared_info.h (mount_info::from_fstab_line): Declare. - (mount_info::from_fstab): Declare. - -2008-04-02 Corinna Vinschen - - * path.cc (enum symlink_t): Rename from shortcut_t. - -2008-04-02 Corinna Vinschen - - * path.cc (symlink_info::check_reparse_point): Use NtFsControlFile - to read reparse points. - (enum shortcut_t): New type. - (symlink_info::check): Convert sym_check to shortcut_t. Use shortcut_t - enum values throughout. Check reparse point before checking for - sysfile shortcut. Open reparse points with READ_CONTROL only to - accommodate special Vista reparse points. Add comments. - -2008-04-02 Corinna Vinschen - - * flock.cc (get_lock_parent_dir): Drop call to NtOpenDirectoryObject - and utilize OBJ_OPENIF flag in call to NtCreateDirectoryObject. - (inode_t::inode_t): Ditto. Same for NtOpenMutant/NtCreateMutant. - -2008-04-02 Corinna Vinschen - - * posix.sgml: Change lockf to being implemented. - -2008-04-02 Corinna Vinschen - - * dcrt0.cc (insert_file): Convert filename to WCHAR and call - CreateFileW to allow UTF-8 filenames. - -2008-04-01 Corinna Vinschen - - * Fix copyright dates. - -2008-04-01 Corinna Vinschen - - Throughout, call fcntl64 instead of fcntl or fcntl_worker. - * fcntl.cc (fcntl_worker): Remove. - (fcntl64): Add fault handler. Move fcntl_worker stuff here. Add case - for locking and call fhandler's lock method directly. Make sure that - F_FLOCK flag isn't set in lock call. - (_fcntl): Add fault handler. - * fhandler.cc (fhandler_base::fcntl): Drop lock cases. - * flock.cc (flock): Add fault handler. Simplify code. Call fhandlers - lock method directly instead of fcntl_worker. Add debug output. - (lockf): Add fault handler. Call fhandlers lock method directly - instead of fcntl_worker. Add debug output. - * winsup.h (fcntl_worker): Drop declaration. - (fcntl64): Declare. - -2008-03-31 Corinna Vinschen - - * smallprint.cc (__small_vswprintf): Fix uninitialized usage of `w'. - - Revamp advisory file locking to avoid cross reference pointers as well - as to allow BSD flock semantics. More agressively delete unused nodes - and sync objects. - * fhandler.h (fhandler_base::ino): Rename from namehash. Fix comment. - (fhandler_base::node): Remove. - (fhandler_base::unique_id): Add. - (fhandler_base::del_my_locks): New method. - (get_ino): Rename from get_namehash. Change usage throughout Cygwin. - (get_unique_id): New method. - * fhandler.cc (fhandler_base::close): Call own del_my_locks method. - Fix comment. - (fhandler_base::fhandler_base): Accommodate new and changed members. - (fhandler_base::fixup_after_fork): Call del_my_locks. - (fhandler_base::fixup_after_exec): Ditto for files with close-on-exec - flag set. - * fhandler_disk_file.cc (get_ino_by_handle): Rename from - readdir_get_ino_by_handle. Accommodate throughout. - (fhandler_base::open_fs): Fill ino with inode number if FS has good - inodes. Allocate a LUID and store in unique_id to recognize file - descriptors referencing the same file object. - * flock.cc: Drop flock TODO comments. Use explicit types __dev32_t - and __ino64_t instead of dev_t and ino_t. - (LOCK_OBJ_NAME_LEN): Change to reflect longer lf_id length. - (get_obj_handle_count): New method. - (lockf_t::lf_id): Change type to long long. - (inode_t::get_lock_obj_handle_count): Drop in favor of static function - get_obj_handle_count. - (inode_t::del_locks): Remove. - (inode_t::get): Add create_if_missing flag argument. - (inode_t::del_my_locks): Reimplement to handle POSIX and BSD flock - locks. Return if node can be deleted or not. - (inode_t::~inode_t): Ditto. Close handles to i_dir and i_mtx. - (fixup_lockf_after_fork): Remove. - (fhandler_base::del_my_locks): New method. - (fixup_lockf_after_exec): Check if node can be deleted. - (inode_t::get): Only create node if create_if_missing is set. Lock - the returned node here before unlocking the node list. - (inode_t::get_all_locks_list): Accommodate new lf_id length. - (inode_t::create_lock_obj): Ditto. - (lockf_t::open_lock_obj): Ditto. Change return type to bool. De-const. - Set lf_obj instead of returning a handle. - (lockf_t::del_lock_obj): Call SetEvent only if new incoming parameters - allow it. Explain how it's supposed to work. - (fhandler_disk_file::lock): Only fetch file length in SEEK_END case. - Use NtQueryInformationFile(FileStandardInformation) instead of - calling fstat_by_handle. Always unlock node before returning. - Use fhandler's unique id to create lf_id for BSD flock locks. - Rely on node lock from inode_t::get. Call del_lock_obj on removed - locks here to allow explicit unlocking. Delete node if no lock exists - on the file anymore. - (lf_setlock): Get file handle as additional parameter. Handle the fact - that lf_getblock now always opens the attached event object. Reactivate - erroneously applied patch which deactivates setting thread priority. - Additionally handle blocking on BSD flock locks. - (lf_clearlock): Get file handle as additional parameter. - (lf_getlock): Close event handle opened by lf_getblock. - (lf_getblock): Open potentially blocking event object here and check - its signal state if it's a BSD flock lock. - (lf_wakelock): Get file handle as additional parameter. - * fork.cc (frok::child): Drop call to fixup_lockf_after_fork. - * ntdll.h (struct _EVENT_BASIC_INFORMATION): Define. - (enum _EVENT_INFORMATION_CLASS): Define. - (NtQueryEvent): Declare. - - * fhandler.h (fhandler_base::fs_flags): Remove. - (fhandler_base::set_fs_flags): Remove. - (fhandler_base::get_fs_flags): Remove. - * fhandler.cc (fhandler_base::write): Check for sparse file using - pc.fs_flags(). - * fhandler_disk_file.cc (fhandler_disk_file::ftruncate): Ditto. - - The return of the volume serial number in fs_info. - * fhandler.h (get_dev): New method. - * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Drop call to - NtQueryVolumeInformationFile(FileFsVolumeInformation). Just use - get_dev() method. - * fhandler_fifo.cc (fhandler_fifo::open) Use device ID and inode number - to generate fifo name. - * path.h (fs_info::sernum): New member. - (fs_info::serial_number): New method. - (path_conv::fs_serial_number): New method. - * path.cc (fs_info::update): Fetch volume serial number and store in - sernum. - -2008-03-28 Corinna Vinschen - - * flock.cc (lockf_t::operator new): Add operator taking a pointer. Call - cmalloc instead of ccalloc in the default operator. Add comments. - (inode_t::operator new): Call cmalloc instead of ccalloc. - (inode_t::get_all_locks_list): Return lockf_t pointer. - (inode_t::del_all_locks_list): Delete. Remove calls throughout. - (inode_t::get): Handle failing new gracefully. - (MAX_LOCKF_CNT): Define. - (inode_t::get_all_locks_list): Use pre-allocated buffer in i_all_lf - instead of allocating every lock. Return pointer to start of linked - list of locks. - (lockf_t::open_lock_obj): Create event object non-inheritable. - (fhandler_disk_file::lock): Handle failing new gracefully. - (lf_setlock): Allocate temporary buffer for node->i_all_lf from TLS. - Remove erroneous NtClose call. - (lf_getlock): Allocate temporary buffer for node->i_all_lf from TLS. - (lf_getblock): Set lf to return value of get_all_locks_list. - -2008-03-27 Corinna Vinschen - - * flock.cc (FLOCK_PARENT_DIR_ACCESS): Define. - (FLOCK_INODE_DIR_ACCESS): Define. - (FLOCK_MUTANT_ACCESS): Define. - (FLOCK_EVENT_ACCESS): Define. - (SD_MIN_SIZE): Define. - (everyone_sd): Define to simplify calling _everyone_sd. - (_everyone_sd): Replace everyone_sync_sd. Take SECURITY_DESCRIPTOR as - argument and allow to specify access mask. - (get_lock_parent_dir): Open/Create parent dir with - FLOCK_PARENT_DIR_ACCESS. Add text to api_fatal message. - (inode_t::inode_t): Open/Create dir with FLOCK_INODE_DIR_ACCESS. - Open/Create mutant with FLOCK_MUTANT_ACCESS. Add text to api_fatal - message. - (lockf_t::create_lock_obj): Create event with FLOCK_EVENT_ACCESS. - Add text to api_fatal message. - (lockf_t::open_lock_obj): Open event with FLOCK_EVENT_ACCESS. - On failure, just return NULL pointer instead of calling api_fatal. - (lockf_t::get_lock_obj_handle_count): Replace call to small_printf - with call to debug_printf. - (lf_setlock): Handle a failure to open the lock event object as - EDEADLK. Call system_printf if opening sync objects fail. - * ntdll.h (DIRECTORY_TRAVERSE): Define. - (DIRECTORY_CREATE_OBJECT): Define. - (DIRECTORY_CREATE_SUBDIRECTORY): Define. - (EVENT_QUERY_STATE): Define. - -2008-03-27 Corinna Vinschen - - * syscalls.cc (rename): Fix setting errno in case of trailing "/." - -2008-03-27 Corinna Vinschen - - * fhandler_socket.cc: Create shared objects session local throughout. - * shared.cc (shared_name): Add argument to allow opening session - local shared memory. - * shared_info.h (shared_name): Change declaration accordingly. - -2008-03-26 Christopher Faylor - - Implement method of detecting a missing dll as suggested by Brian - Dessent. - * hookapi.cc (find_first_notloaded_dll): New function. - * pinfo.cc (status_exit): New function. Issue message when dll not - found. Use find_first_notloaded_dll to find a nonexistent dll. - (pinfo::maybe_set_exit_code_from_windows): Call status_exit when exit - code >= 0xc0000000UL. - * sigproc.cc (child_info::proc_retry): Return exit code when - STATUS_DLL_NOT_FOUND. - * spawn.cc (spawn_guts): Minor cleanup. - * syscalls.cc (close_all_files): Don't actually close stderr - filehandle. Just make it noninheritable. - * winsup.h (find_first_notloaded_dll): Declare new function. - -2008-03-26 Brian Dessent - - * ntdll.h: Add several missing NTSTATUS defines. - -2008-03-24 Corinna Vinschen - - * flock.cc (inode_t::get_all_locks_list): Don't allow F_WAIT flag - in lock event object name. - (lockf_t::create_lock_obj): Ditto. - (lockf_t::open_lock_obj): Ditto. - (lf_setlock): Only check POSIX locks for deadlock condition. - (lf_findoverlap): Don't let POSIX and flock locks interact. - -2008-03-24 Corinna Vinschen - - * flock.cc: Clarify a couple of comments. - (lf_setlock): Treat not being able to sync on a process as a potential - deadlock situation. Close process handle using CloseHandle. - -2008-03-24 Corinna Vinschen - - * flock.cc: Fix typo in comment. - -2008-03-24 Corinna Vinschen - - * fhandler.cc (fhandler_base::dup): Drop setting flags in the parent. - - Implement advisory file locking. - * cygheap.h (struct init_cygheap): Add inode_list member. - * cygwin.din (lockf): Export. - * dcrt0.cc (child_info_spawn::handle_spawn): Call - fixup_lockf_after_exec. - * dtable.h (class dtable): Add fhandler_disk_file as friend class. - * fhandler.cc (fhandler_base::close): Call del_my_locks if node is set. - (fhandler_base::fhandler_base): Initialize node to NULL. - (fhandler_base::fixup_after_fork): Ditto. - * fhandler.h (class fhandler_base): Add member node. - * fhandler_disk_file.cc (fhandler_disk_file::lock): Delete. - * flock.cc: Implement all advisory file locking here. - (fhandler_disk_file::lock): Implement here. - (flock): Call fcntl with F_FLOCK bit set. Remove test main function. - (lockf): New function. - * fork.cc (frok::child): Call fixup_lockf_after_fork. - * ntdll.h (DIRECTORY_ALL_ACCESS): Define. - (struct _OBJECT_BASIC_INFORMATION): Define. - (enum _EVENT_TYPE): Define. - (NtCreateDirectoryObject): Declare. - (NtCreateEvent): Declare. - (NtCreateMutant): Declare. - (NtOpenEvent): Declare. - (NtOpenMutant): Declare. - * include/cygwin/version.h: Bump API minor number. - -2008-03-22 Christopher Faylor - - * dtable.cc (handle_to_fn): Modify to return true if handle represents - a cygwin tty. - (dtable::init_std_file_from_handle): Detect when we've seen a cygwin - pipe and use it in overlapped mode by default. - (decode_tty): Make static. - -2008-03-22 Christopher Faylor - - * dtable.cc: Define various device-related string constants as wide - character constants. - (dtable::init_std_file_from_handle): Reorganize pipe handling to try to - catch special tty case. - (build_fh_name_worker): Declare for common use. - (build_fh_name): Define char version. - (build_fh_name): Define (currently unused) UNICODE_STRING version. - (decode_tty): Detect if pipe is actually a cygwin tty, returning the - tty name in the buffer. - (handle_to_fn): Reorganize to use wide characters. - * dtable.h (build_fh_name): Declare (currently unused) UNICODE_STRING - version. - * fhandler_tty.cc (fhandler_pty_master::setup): Use - fhandler_pipe::create_selectable to create a pipe with a given name. - * pipe.cc (pipe_handler): Make returned handle inheritable. - (fhandler_pipe::create_selectable): Take an optional name. Use a - standard cygwin introducer for the name. - - * path.cc (path_conv::check): Make first argument const. - * path.h (path_conv::check): Ditto for declaration. - (path_conv::path_conv): Ditto for UNICODE_STRING version. - -2008-03-18 Corinna Vinschen - - * include/sys/cygwin.h: Revert erroneous move of `#ifdef WINVER' to - another location. - -2008-03-14 Corinna Vinschen - - * fcntl.cc (fcntl_worker): Protect with a 'myfault'. - - * path.cc (normalize_posix_path): Treat X:/ as Win32 path, too. - - * smallprint.cc (__wrn): New static function. - (__small_vswprintf): New function to generate WCHAR strings. - (__small_swprintf): Ditto. - * winsup.h (__small_swprintf): Declare. - (__small_vswprintf): Declare. - -2008-03-13 Corinna Vinschen - - * path.sgml: Remove documentation for old path API. Add documentation - for new path API. - * security.sgml: New file to document cygwin_set_impersonation_token - and cygwin_logon_user with only eight years of delay. - * shared.sgml: Remove file. - * include/sys/cygwin.h (cygwin32_attach_handle_to_fd): Move declaration - into fully deprecated function block. - (cygwin_logon_user): Move declaration down to declaration of - cygwin_set_impersonation_token. - -2008-03-12 Corinna Vinschen - - * syscalls.cc (rename): Just return with 0 if filenames are identical, - per POSIX. Drop comment added in previous patch. - -2008-03-12 Corinna Vinschen - - * syscalls.cc (rename): Handle a special case of trying to rename a - mount point. - -2008-03-12 Corinna Vinschen - - * environ.h: Fix comment. - * winsup.h: Ditto. Reflect the fact that CYG_MAX_PATH is deprecated. - -2008-03-12 Corinna Vinschen - - * pipe.cc (fhandler_pipe::create_selectable): Use MAX_PATH instead of - CYG_MAX_PATH. - * tty.cc (tty_list::init_session): Ditto. - (tty::alive): Ditto. - (tty::open_mutex): Ditto. - (tty::create_inuse): Ditto. - (tty::get_event): Ditto. - -2008-03-12 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::readdir_helper): Disable - munging. Convert all chars in the 0xf0xx area to it's ascii equivalent. - * path.cc (normalize_posix_path): Don't treat "X:foo" as windows path, - only "X:\foo". - (tfx_chars): New transformation table for special DOS chars. - (tfx_chars_managed): Ditto, plus transformation of uppercase ASCII - chars. - (transform_chars): New function. - (get_nt_native_path): Make static. Call transform_chars for all valid - FS paths. Get additional flag if file is managed or not. Accommodate - throughout. - (getfileattr): Get additional flag if file is managed or not. - Accommodate throughout. - (path_conv::check): Disable special handling for trailing dots and - spaces. - (mount_item::build_win32): Disable code for managed paths. - (mount_info::conv_to_posix_path): Ditto. - * path.h (get_nt_native_path): Remove declaration. - -2008-03-12 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::readdir_helper): Don't - copy filename twice in the non-managed case. - -2008-03-12 Corinna Vinschen - - * winsup.h (NT_MAX_PATH): Revert ill-advised change to 32767. - Accommodate change throughout. - - * cygwin.din (cygwin_conv_path): Export. - (cygwin_conv_path_list): Export. - (cygwin_create_path): Export. - * dcrt0.cc (dll_crt0_1): Use cygwin_conv_path. - * dtable.cc (handle_to_fn): Ditto. Don't expect UNICODE_STRING being - 0-terminated. - * environ.cc (env_plist_to_posix): New helper function. - (env_plist_to_win32): Ditto. - (env_path_to_posix): Ditto. - (env_path_to_win32): Ditto. - (return_MAX_PATH): Remove. - (conv_envvars): Use new helper functions. Drop removed members. - (win_env::operator =): Accommodate removal of path length functions. - (win_env::add_cache): Accommodate new env helper function API. - (posify): Ditto. - * environ.h (struct win_env): Ditto. Remove path length function - pointers since they are unused. - * path.cc (warn_msdos): Use cygwin_conv_path. - (getfileattr): Use new tmp_pathbuf::u_get method. - (fillout_mntent): Ditto. - (symlink_info::check): Ditto. - (path_conv::check): Use sizeof (WCHAR) instead of constant 2. - (symlink_info::check_reparse_point): Ditto. - (conv_path_list): Get max size of target string as argument. Call - cygwin_conv_path as helper function. - (cygwin_conv_path): New function. - (cygwin_create_path): New function. - (cygwin_conv_to_win32_path): Just call cygwin_conv_path with size set - to MAX_PATH. - (cygwin_conv_to_full_win32_path): Ditto. - (cygwin_conv_to_posix_path): Ditto. - (cygwin_conv_to_full_posix_path): Ditto. - (conv_path_list_buf_size): Add FIXME comment. - (env_PATH_to_posix): Rename from env_win32_to_posix_path_list. - Add size argument as required for env helper functions. - (cygwin_win32_to_posix_path_list): Call conv_path_list with size set to - MAX_PATH. - (cygwin_posix_to_win32_path_list): Ditto. - (cygwin_conv_path_list): New function. - (cwdstuff::get): Fix length argument in call to sys_wcstombs. - * spawn.cc (find_exec): Use cygwin_conv_path_list. - * tls_pbuf.h (tmp_pathbuf::u_get: New method. - * uinfo.cc (cygheap_user::ontherange): Allocate temporary path buffers - using tmp_pathbuf. Use cygwin_conv_path. - * winf.cc (av::unshift): Use cygwin_conv_path. - * include/cygwin/version.h: Bump API minor number. - * include/sys/cygwin.h: Comment out old cygwin32_XXX API. - Mark old path handling API as deprecated. - (cygwin_conv_path_t): Typedef. Define values. - (cygwin_conv_path): Declare. - (cygwin_create_path): Declare. - (cygwin_conv_path_list): Declare. - -2008-03-11 Corinna Vinschen - - * dlfcn.cc (get_full_path_of_dll): Allow paths up to PATH_MAX. - (dlopen): Call get_full_path_of_dll with path buffer allocate by - tmp_pathbuf. - -2008-03-11 Corinna Vinschen - - * spawn.cc (find_exec): Use tmp_pathbuf to allocate path buffer. - -2008-03-11 Corinna Vinschen - - * dtable.cc (dtable::init_std_file_from_handle): Use tmp_pathbuf to - allocate path buffer. - (handle_to_fn): Ditto. Allocate fnbuf big enough to get long path - names. - -2008-03-11 Corinna Vinschen - - * path.cc (cwdstuff::set): Make sure drive_length is 0 for virtual - paths. Add comments. - * spawn.cc (spawn_guts): Don't allow to start a native Win32 application - from a long path or a virtual path. Print an error message to stderr. - -2008-03-11 Corinna Vinschen - - * environ.cc (parse_options): Use tmp_pathbuf to allocate buffer. - (regopt): Take tmp buffer as additional argument. - (environ_init): Alllcate tmpbuf earlier. Use as temporary buffer in - call to regopt. - * tls_pbuf.cc (tmp_pathbuf::c_get): Allocate one additional char. - (tmp_pathbuf::w_get): Allocate one additional WCHAR. - * winf.cc (av::unshift): Use tmp_pathbuf to allocate buffer. - -2008-03-11 Corinna Vinschen - - * syscalls.cc (sync): Use MAX_PATH rather than CYG_MAX_PATH. - -2008-03-10 Corinna Vinschen - - * fhandler.h (class fhandler_console): Add write_buf as pointer to - temporary buffer space. - * fhandler_console.cc (CONVERT_LIMIT): Define as NT_MAX_PATH. Add - comment. - (fhandler_console::write_normal): Use write_buf throughout. - (fhandler_console::write): Use tmp_pathbuf to allocate write_buf. - -2008-03-10 Corinna Vinschen - - * fhandler_console.cc (fhandler_console::write_normal): Don't print - chars marked as ERR chars. - -2008-03-10 Corinna Vinschen - - * fhandler.h (dev_console::con_to_str): Declare returning DWORD. - * fhandler_console.cc (dev_console::con_to_str): Return number of - multibyte char bytes. - (fhandler_console::read): Set nread to number of multibyte char bytes - returned from con_to_str. - (fhandler_console::write_normal): Reorder trunc buffer preocessing. - Return after writing valid multibyte sequence out of trunc buffer. - Change comments slightly. - -2008-03-08 Corinna Vinschen - - * fhandler_disk_file.cc (DIR_BUF_SIZE): Define required space for file - name in terms of sizeof(WCHAR). - (fhandler_disk_file::readdir_helper): Convert *all* of fname. - * path.cc (fillout_mntent): Use tmp_pathbuf for path buffer. - (symlink_worker): Ditto. - (SCAN_JUSTCHECKTHIS): New state for suffix_scan to define - that only the actual name gets cheked and a suffix is never attached. - (suffix_scan::has): If filename + suffix would be > NAME_MAX, start - in SCAN_JUSTCHECKTHIS state. - (suffix_scan::next): Add case for SCAN_JUSTCHECKTHIS. - (symlink_info::check): Use tmp_pathbuf for path buffer. Goto - file_not_symlink in case of invalid file name. - (realpath): Use tmp_pathbuf for path buffer. - -2008-03-07 Brian Dessent - - * dtable.cc (handle_to_fn): Null-terminate posix_fn in the case - of justslash = true. - -2008-03-07 Brian Dessent - - * fhandler.cc (fhandler_base::open): Use %S for PUNICODE_STRING. - * syscalls.cc (setmode): Ditto. - -2008-03-07 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::sendto): Never send more than - 64K. Add comment to explain why. - (fhandler_socket::sendmsg): Ditto. - -2008-03-07 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Add tls_pbuf.o. - * autoload.cc (CreateDesktopW): Replace CreateDesktopA. - (CreateWindowStationW): Replace CreateWindowStationA. - (GetUserObjectInformationW): Replace GetUserObjectInformationA. - * cygheap.h (cwdstuff::get): Assume default buffer size NT_MAX_PATH. - * cygtls.cc (_cygtls::remove): Free temporary TLS path buffers. - * cygtls.h (TP_NUM_C_BUFS): Define. - (TP_NUM_W_BUFS): Define. - (class tls_pathbuf): New class to store pointers to thread local - temporary path buffers. - (_local_storage::pathbufs): New member. - * environ.cc (win_env::add_cache): Use temporary TLS path buffer instead - of stack based buffer. - (posify): Get temporary outenv buffer from calling function. - (environ_init): Create temporary TLS path buffer for posify. - (build_env): Create Windows environment block as WCHAR buffer. - * environ.h (build_env): Change declaration accordingly. - * external.cc (sync_winenv): Accommodate build_env change. - * fhandler_console.cc (fhandler_console::need_invisible): Use - GetUserObjectInformationW and CreateWindowStationW. - * fhandler_process.cc (format_process_maps): Use temporary TLS path - buffer instead of stack based buffer. - * fork.cc (frok::parent): Convert to use CreateProcessW. - * path.cc: Throughout use temporary TLS path buffers instead of stack - based buffer. Replace checks for CYG_MAX_PATH by checks for - NT_MAX_PATH. - (getfileattr): New function to replace GetFileAttributesA. - (normalize_win32_path): Remove Win32 and NT long path prefixes. - (getwd): Assume PATH_MAX + 1 buffer per SUSv3. - * path.h (class path_conv): Set path buffer to size NT_MAX_PATH. - (iswdrive): Define. - * pinfo.cc (commune_process): Use temporary TLS path buffer instead of - stack based buffer. - * registry.cc (get_registry_hive_path): Ditto. - (load_registry_hive): Ditto. - * spawn.cc (spawn_guts): Convert to use CreateProcessW and - CreateProcessAsUserW. - (av::fixup): Open/close file using NtOpenFile/NtClose. - * syscalls.cc (mknod_worker): Allow PATH_MAX file name. - (mknod32): Ditto. - (getusershell): Ditto. - * tls_pbuf.cc: New file implementing tls_pathbuf and tmp_pathbuf - methods. - * tls_pbuf.h: New header for files using tmp_pathbuf. - * tlsoffsets.h: Regenerate. - * winsup.h (NT_MAX_PATH): Define as 32767 to avoid USHORT overflow. - -2008-03-06 Corinna Vinschen - - * child_info.h (CURR_CHILD_INFO_MAGIC): Reset. - -2008-03-06 Corinna Vinschen - - * fhandler.cc (fhandler_base::open_): Add missing test for O_CREAT. - Fix comment. - -2008-03-05 Corinna Vinschen - - * child_info.h (~child_info_spawn): Check moreinfo->myself_pinfo for - NULL before closing. - * spawn.cc (spawn_guts): Don't close moreinfo->myself_pinfo explicitely - in case of failing CloseProcess. - - * fhandler.cc (fhandler_base::open_): Return EISDIR when trying to - create a directory. - * path.cc (path_conv::check): If input path had a trailing dir - separator, tack it on to the native path if directory doesn't exist. - -2008-03-02 Christopher Faylor - - * cygtls.cc (_cygtls::init_exception_handler): Semi-revert to making - only ourselves the exception handler and nothing else. - * exceptions.cc (open_stackdumpfile): Use correct format specifiers for - unicode when printing the name of the stackdump file. - (stack_info::walk): Stop walking if ebp points into cygwin itself. - (_cygtls::handle_exceptions): Detect when signal is masked and treat as - if it was not caught. Reinitialize exception handler to known state to - avoid subsequent attempts to call Windows exception handlers if an - exception occurs in a signal handler. Revert to a 'return 0' rather - than using a goto. - - * strfuncs.cc (sys_wcstombs_alloc): Minor formatting tweak. - * winsup.h: Fix comment typo. - -2008-03-02 Christopher Faylor - - * smallprint.cc (__small_vsprintf): Free allocated buffer rather than - pointer into the buffer. - -2008-03-01 Christopher Faylor - - * cygtls.h (_cygtls::handle_threadlist_exception): Eliminate. - (_cygtls::init_threadlist_exceptions): Ditto. - * cygtls.cc (_cygtls::handle_threadlist_exception): Eliminate. - (_cygtls::init_threadlist_exceptions): Ditto. - (_cygtls::find_tls): Use myfault handling to deal with errors caused by - nonexistent threads. - * sigproc.cc (wait_sig): Eliminate call to init_threadlist_exceptions. - -2008-03-01 Christopher Faylor - - * cygtls.cc (_cygtls::init_exception_handler): Just return. - -2008-03-01 Corinna Vinschen - - * exceptions.cc (_cygtls::handle_exceptions): Only call rtl_unwind when - exiting. Just return, don't set thread context. - * gendef (_setjmp): Store %fs:0 in jmp_buf. - (_sjfault): Ditto. - (_ljfault): Restore %fs:0 from jmp_buf. - (_longjmp): Ditto. - -2008-02-29 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Call close_fs - instead of close to avoid calling close from wrong class when changing - a file system based device node. - (fhandler_disk_file::fchown): Ditto. - (fhandler_disk_file::facl): Ditto. - -2008-02-28 Corinna Vinschen - - * exceptions.cc (_cygtls::handle_exceptions): When being debugged, - leave through SetThreadContext, too, to keep exception handler stack - intact. - -2008-02-28 Corinna Vinschen - - * exceptions.cc (open_stackdumpfile): Add comments. - -2008-02-28 Corinna Vinschen - - * exceptions.cc (open_stackdumpfile): Use NtCreateFile to create - stackdump file. - -2008-02-27 Corinna Vinschen - - * exceptions.cc (stack_info::walk): Fix typo. - -2008-02-27 Corinna Vinschen - - * cygtls.cc (_cygtls::init_exception_handler): Fix comment. - -2008-02-27 Corinna Vinschen - - * (struct __DIR_cache): Switch order of members so that the buffer - given to NtQueryDirectoryFile is 8 byte aligned. - -2008-02-27 Christopher Faylor - - * cygtls.cc (_cygtls::handle_threadlist_exception): Make it clear that - the function never actually returns. - * exceptions.cc (_cygtls::handle_exceptions): Jump out of function - rather than returning to avoid meddling by previously installed - exception handlers. - -2008-02-25 Corinna Vinschen - - * dcrt0.cc (initial_env): Only use local buffer "buf" if DEBUGGING is - enabled. Replace calls to GetEnvironmentVariable by calls to - GetEnvironmentVariableA for clarity. Call GetEnvironmentVariableA - with NULL buffer. - (cygbench): Ditto, drop local buffer. - * environ.cc (getearly): Call GetEnvironmentVariableA. - (environ_init): Retrieve unicode environment and convert to current - codepage locally. - (getwinenveq): Ditto. - * exceptions.cc (try_to_debug): Accommodate new sys_mbstowcs calling - convention. - * fhandler_clipboard.cc (set_clipboard): Call sys_mbstowcs to retrieve - required buffer length. - * fork.cc (frok::child): Call GetEnvironmentVariableA. - * miscfuncs.cc: Accommodate changed arguments in calls to sys_mbstowcs. - * sec_auth.cc: Ditto. - * strfuncs.cc (sys_wcstombs_alloc): Fix formatting. - (sys_mbstowcs): Change arguments to allow specifying a source string - length. - (sys_mbstowcs_alloc): Ditto. - * uinfo.cc (cygheap_user::ontherange): Accommodate changed arguments in - calls to sys_mbstowcs. - * winsup.h (sys_mbstowcs): Adjust declaration. - (sys_mbstowcs_alloc): Ditto. - -2008-02-20 Corinna Vinschen - - * path.cc (cwdstuff::set): Revert error handling change in case - DuplicateHandle fails, because it breaks Vista/Longhorn workaround. - -2008-02-19 Christopher Faylor - - * sigproc.cc (sig_send): Use sigmask of target thread if it is - specified otherwise default to main sigmask. - -2008-02-16 Corinna Vinschen - - * fhandler.cc (fhandler_base::fpathconf): Fix _PC_NAME_MAX and - _PC_PATH_MAX cases. - -2008-02-15 Corinna Vinschen - - * include/sys/cygwin.h (__INT_MAX_PATH): Remove. - (external_pinfo): Convert program_long to pointer. - * external.cc (fillout_pinfo): Add buffer for program_long value. - -2008-02-15 Corinna Vinschen - - * include/sys/cygwin.h (__INT_MAX_PATH): Define to 32K. - (external_pinfo): Set size of program_long to __INT_MAX_PATH. - -2008-02-15 Christopher Faylor - - * include/sys/cygwin.h (external_pinfo): Define program_long size using - external buffer size rather than cygwin-internal buffer size. - -2008-02-15 Christopher Faylor - - Perform whitespace cleanup throughout. - - * dcrt0.cc (signal_shift_subtract): Eliminate ancient backwards - compatibility. - (check_sanity_and_sync): Ditto. - * winsup.h (SIGTOMASK): Ditto. Just use constant in signal - calculation. - * include/cygwin/version: Remove backwards signal mask compatibility - define. - - * path.cc (symlink_info::check_sysfile): Cosmetic change. - - * registry.cc (get_registry_hive_path): Remove unneeded variable. - - * exceptions.cc (handle_sigsuspend): Eliminate thread signal mask and - use either main sigmask or current thread sigmask. - (set_process_mask): Ditto. - (sighold): Ditto. - (sigrelse): Ditto. - (sigset): Ditto. - (set_process_mask_delta): Ditto. - (_cygtls::call_signal_handler): Ditto. - * fhandler_process.cc (format_process_status): Ditto. - * fhandler_termios.cc (fhandler_termios::bg_check): Ditto. - * pinfo.h (class pinfo): Ditto. - * select.cc (pselect): Ditto. - * signal.cc (sigprocmask): Ditto. - (abort): Ditto. - (sigpause): Ditto. - (sigsend): Ditto. - (wait_sig): Ditto. - * thread.h (pthread::parent_tls): New member. - * thread.cc (pthread::pthread): Record parent_tls here. - (pthread::thread_init_wrapper): Initialize sigmask from parent thread. - -2008-02-14 Corinna Vinschen - - * cygheap.cc (cwcsdup): New function. - (cwcsdup1): New function. - * cygheap.h (cygheap_user::get_windows_id): New method returning PWCHAR. - (cwcsdup): Declare. - (cwcsdup1): Declare. - * registry.cc (get_registry_hive_path): Use WCHAR instead of char - throughout. - (load_registry_hive): Ditto. - * registry.h (get_registry_hive_path): Change declaration accordingly. - (load_registry_hive): Ditto. - * sec_helper.cc (cygpsid::string): New method returning PWCHAR. - * security.h (cygpsid::string): Declare. - * syscalls.cc (seteuid32): Convert local name var to WCHAR. - * uinfo.cc (cygheap_user::env_userprofile): Convert local name buffers - to WCHAR. Call sys_wcstombs_alloc to generate puserprof buffer. - - * winsup.h: Fix comment. - (NT_MAX_PATH): New definition for maximum internal path length. - Use throughout where appropriate. - * include/limits.h (PATH_MAX): Set to 4096 as on Linux. - -2008-02-13 Christopher Faylor - - * configure.in: Remove non-working options. - * configure: Regenerate. - -2008-02-13 Christopher Faylor - - * syscalls.cc (_isatty): Define as an alias to isatty to override - newlib version. - - * thread.cc (pthread_kill): Deal with signal 0 as per POSIX and also - avoid manipulating an invalid thread. - -2008-02-13 Corinna Vinschen - - * posix.sgml: Move llrint, llrintf, llrintl, lrintl, rintl, wcstol, - wcstoll, wcstoul, wcstoull, wcsxfrm from unimplemented to implemented - POSIX interfaces. - Change headline of "GNU extensions" to "GNU and Linux extensions". - Add fgetxattr, flistxattr, fremovexattr, fsetxattr, getxattr, lgetxattr, - listxattr, llistxattr, lremovexattr, lsetxattr, removexattr, setxattr, - wcpcpy and wcpncpy to list of implemented GNU functions. - -2008-02-13 Corinna Vinschen - - * cygtls.cc (_cygtls::init_exception_handler): Revert patch - from 2005-12-02. - * exceptions.cc (stack_info::walk): Add workaround for NT 5.2 - 64 bit OSes. - * wincap.h (wincaps::has_restricted_stack_args): New element. - * wincap.cc: Implement above element throughout. - (wincapc::init): Reset has_restricted_stack_args if not running - under WOW64. - -2008-02-11 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::fgetxattr): Remove unused - attr. - (fhandler_disk_file::fsetxattr): Ditto. - * include/attr/xattr.h: New file. - -2008-02-11 Corinna Vinschen - - * dcrt0.cc (dll_crt0_1): Fix typo in call to sys_wcstombs. - * miscfuncs.cc (next_char): Initialize ret to keep gcc happy. - -2008-02-10 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Add ntea.o. - * cygwin.din (getxattr, listxattr, removexattr, setxattr, lgetxattr, - llistxattr, lremovexattr, lsetxattr, fgetxattr, flistxattr, - fremovexattr, fsetxattr): Export Linux extended attribute functions. - Sort. - * errno.cc (errmap): Add mappings for ERROR_EAS_DIDNT_FIT, - ERROR_EAS_NOT_SUPPORTED, ERROR_EA_LIST_INCONSISTENT, - ERROR_EA_TABLE_FULL, ERROR_FILE_CORRUPT, ERROR_INVALID_EA_NAME. - * fhandler.h (class fhandler_base): Declare new fgetxattr and - fsetxattr methods. - (class fhandler_disk_file): Ditto. - * fhandler.cc (fhandler_base::fgetxattr): New method. - (fhandler_base::fsetxattr): New method. - * fhandler_disk_file.cc (fhandler_disk_file::fgetxattr): New method. - (fhandler_disk_file::fsetxattr): New method. - * ntdll.h (STATUS_EA_TOO_LARGE): Define. - (STATUS_NONEXISTENT_EA_ENTRY): Define. - (STATUS_NO_EAS_ON_FILE): Define. - * ntea.cc (read_ea): Rewrite for long pathnames and for using with - Linux extended attribute functions. - (write_ea): Ditto. - (getxattr_worker): New static function. - (getxattr): New function. - (lgetxattr): New function. - (fgetxattr): New function. - (listxattr): New function. - (llistxattr): New function. - (flistxattr): New function. - (setxattr_worker): New static function. - (setxattr): New function. - (lsetxattr): New function. - (fsetxattr): New function. - (removexattr): New function. - (lsetxattr): New function. - (fsetxattr): New function. - * security.h (read_ea): Change declaration according to above changes. - (write_ea): Ditto. - * include/cygwin/version.h: Bump API minor version. - -2008-02-10 Corinna Vinschen - - * libc/ftw.cc (ftw): Allow nfds <= 0 for glibc compatibility. - * libc/nftw.c (nftw): Ditto. - -2008-02-07 Corinna Vinschen - - * dtable.cc (dtable::init_std_file_from_handle): Set access to - read/write if handle is connected to a tty or console. - * fhandler_dsp.cc (fhandler_dev_dsp::dup): Set open flags correctly - after duplicating from archetype. - * fhandler_tty.cc (fhandler_tty_slave::dup): Ditto. - (fhandler_pty_master::dup): Ditto. - -2008-02-06 Corinna Vinschen - - * miscfuncs.cc (next_char): Fix typos in comment. - * strfuncs.cc: Remove cygserver guards. - -2008-02-06 Corinna Vinschen - - * fhandler.h (fhandler_console::trunc_buf): Add to use as cache for - truncated multibyte characters on input. - (fhandler_console::write_replacement_char): Declare new method. - * fhandler_console.cc (CONVERT_LIMIT): Raise to 64K. - (fhandler_console::fhandler_console): Initialize trunc_buf. - (ERR): Define as independent value again. - (fhandler_console::write_replacement_char): New method to print - replacement chars. - (fhandler_console::write_normal): Add handling for truncated multibyte - sequences. Call next_char instead of pathetic CharNextExA function. - Don't change src, rather just work with found later on. - * miscfuncs.cc (is_cp_multibyte): Move here from strfuncs.cc. - Don't call Windows function, restrict to well-known ANSI/OEM codepages - and UTF-8. - (next_char): Call CharNextExA only for doublebyte codepages. - Implement for UTF-8 here. - * strfuncs.cc (is_cp_multibyte): Move to miscfuncs.cc. - * winsup.h (next_char): Declare. - * include/limits.h (MB_LEN_MAX): Set to maximum value of MB_CUR_MAX - as defined by newlib for now. - -2008-02-05 Corinna Vinschen - - * autoload.cc (CharToOemA): Remove. - (CharNextExA): Define. - * environ.cc (codepage_init): Un-static. Set active_codepage to - active codepage. Default to ansi regardless of buf pointer. - * fhandler.h (dev_console::get_console_cp): New method. - (dev_console::con_to_str): Change declaration according to new - implementation. - (dev_console::str_to_con): Ditto. - * fhandler_console.cc (cp_convert): Remove. - (dev_console::con_to_str): Redefine to take WCHAR as incoming console - char. - (dev_console::get_console_cp): Return correct codepage according to - alternate_charset_active setting. - (dev_console::str_to_con): Redefine to create WCHAR buffer for console - output. - (fhandler_console::read): Read console input as WCHARs. - (base_chars): Fix typo in comment. - (fhandler_console::char_command): Save and restore console output - buffer using UNICODE functions. - (fhandler_console::write_normal): Convert to write output in UNICODE. - Use CharNextExA to recognize multibyte characters in input. Workaround - problem with UTF-8 and MultiByteToWideChar. Simplify the loop for - printing "normal" characters. - * strfuncs.cc (active_codepage): New variable to store active codepage. - (get_cp): Call codepage_init() if active_codepage is uninitialized. - Just return active_codepage. - (is_cp_multibyte): New function. - * winsup.h (active_codepage): Declare. - (codepage_init): Declare. - (is_cp_multibyte): Declare. - -2008-02-03 Brian Dessent - - * smallprint.cc (__small_vsprintf): Use HEAP_NOTHEAP for type. - * strfuncs.cc (sys_wcstombs_alloc): Guard use of ccalloc - to !__OUTSIDE_CYGWIN__ for use in cygserver. - (sys_mbstowcs_alloc): Ditto. - -2008-02-01 Corinna Vinschen - - * miscfuncs.cc (cygwin_wcsncasecmp): Never access more than n - characters. - (cygwin_strncasecmp): Ditto. Fix for strings longer than n. - -2008-02-01 Corinna Vinschen - - * string.h: Re-enable inline strcasematch and strncasematch - implementations and rename to ascii_strcasematch/ascii_strncasematch. - * dcrt0.cc: Replace str[n]casematch with ascii_str[n]casematch where - applicable. - * environ.cc: Ditto. - * fhandler_process.cc: Ditto. - * hookapi.cc: Ditto. - * path.cc: Ditto. - * spawn.cc: Ditto. - * strace.cc: Ditto. - * syscalls.cc: Ditto. - * uinfo.cc: Ditto. - * winf.cc: Ditto. - -2008-01-31 Corinna Vinschen - - * dcrt0.cc (dll_crt0_1): Use GetCommandLineW and convert to current - codepage. - * environ.cc (set_file_api_mode): Always set file api to ANSI if not - using the OEM codepage. - (codepage_init): Allow "utf8" codepage. - * fhandler_clipboard.cc (set_clipboard): Convert clipbuf to void and - cast as needed. Always convert input to wide char and write - CF_UNICODETEXT to clipboard. - (fhandler_dev_clipboard::read): Read CF_UNICODETEXT from clipboard and - convert to current codepage if CYGWIN_NATIVE format is not available. - * fhandler_console.cc: Drop redundant undef. - * smallprint.cc (__small_vsprintf): Convert PWCHAR and UNICODE_STRING - to current codepage for printing. - * strfuncs.cc: Use PWCHAR throughout. - (get_cp): Return CP_UTF8 for utf8_cp codepage setting. - (sys_wcstombs): Allow NULL target buffer. - (sys_wcstombs_alloc): New function. - (sys_mbstowcs_alloc): Ditto. - * winsup.h (codepage_type): Add utf8_cp. - (HEAP_NOTHEAP): Define. - (sys_wcstombs_alloc): Declare. - (sys_mbstowcs_alloc): Declare. - -2008-01-31 Corinna Vinschen - - * cygheap.h (struct cwdstuff): Add dir member to store cwd handle. - (cwdstuff::get_handle): New method. - * path.cc (cwdstuff::set): When doit is true, always try to get - directory handle. Fail if duplicating handle fails. Store handle - in dir. Fix potential SEGV when setting drive_length. - -2008-01-28 Corinna Vinschen - - * path.cc: Fix Samba version in comment. - -2008-01-24 Corinna Vinschen - - * path.cc (fs_info::update): Fix old-style Samba test to support - recent as well as upcoming Samba releases. - -2008-01-22 Corinna Vinschen - - * ntdll.h (struct _FILE_FS_OBJECTID_INFORMATION): Define. - * path.cc (struct smb_extended_info): Define. - (fs_info::update): Request object id info to get Samba information. - Set flags according to new implementation. - * path.h (struct fs_info): Add samba_version to status_flags. - Implement flags() and samba_version() using IMPLEMENT_STATUS_FLAG. - -2008-01-21 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::link): Open file with - READ_CONTROL for Vista/Longhorn's sake. - -2008-01-15 Corinna Vinschen - - * Makefile.in (install-libs): Overwrite newlib's libg.a with symlink - to libcygwin.a. - -2008-01-15 Corinna Vinschen - - * Makefile.in (DLL_OFILES): Remove memmem.o. - * memmem.cc: Remove in favor of newlib implementation. - -2008-01-07 Corinna Vinschen - - * fhandler.h: Update copyright. - * include/limits.h: Ditto. - -2008-01-06 Christopher Faylor - - * fhandler.h (fhandler_base::is_tty): Make bool. - (fhandler_serial::is_tty): Ditto. - (fhandler_termios::is_tty): Ditto. - (fhandler_base::is_slow): Return bool value. - (fhandler_socket::is_slow): Ditto. - (fhandler_serial::is_slow): Ditto. - (fhandler_console::is_slow): Ditto. - (fhandler_tty_common::is_slow): Ditto. - (fhandler_tty_master::is_slow): Ditto. - (fhandler_dev_null::is_slow): Ditto. - -2008-01-06 Christopher Faylor - - * include/limits.h (TTY_NAME_MAX): Increase size to same as linux to - allow for (at least) null terminating byte for "/dev/console". - -2008-01-01 Christopher Faylor - - * tty.cc: Update copyright. - * pipe.cc: Ditto. - -2008-01-01 Christopher Faylor - - * newsym: First stab at understanding data as well as functions. - - * pipe.cc (fhandler_pipe::init): Move more intelligence here. - (fhandler_pipe::create): Simplify based on above change. - - * tty.cc (tty_list::allocate): Remove non-NT code. diff --git a/winsup/cygwin/ChangeLog-2009 b/winsup/cygwin/ChangeLog-2009 deleted file mode 100644 index 5638e460c..000000000 --- a/winsup/cygwin/ChangeLog-2009 +++ /dev/null @@ -1,3483 +0,0 @@ -2009-12-28 Corinna Vinschen - - * fhandler.h (fhandler_socket::wait_for_events): Drop parameter default - value. - * fhandler_socket.cc (fhandler_socket::connect): Add false as second - parameter to wait_for_events call. - (fhandler_socket::accept): Ditto. - (fhandler_socket::send_internal): Fix typo in call to wait_for_events. - -2009-12-26 Eric Blake - - * include/pty.h (openpty, forkpty): Mark last two arguments const, - to match glibc 2.8. - * libc/bsdlib.cc (openpty, forkpty): Likewise. - -2009-12-25 Andy Koppe - - * fhandler_console.cc (handler_console::read): Use the tty's VERASE - character as the backspace keycode. - -2009-12-24 Corinna Vinschen - - * path.cc (symlink_info::check): Set fileattr to - FILE_ATTRIBUTE_DIRECTORY in a certain error condition. Explain why. - -2009-12-22 Christopher Faylor - - * select.cc (fhandler_fifo::select_read): Fill in device specific - record. - (fhandler_fifo::select_write): Ditto. - (fhandler_fifo::select_except): Ditto. - -2009-12-21 Corinna Vinschen - - * path.cc (cygwin_conv_path): Add band-aid including comment to avoid - conversion from POSIX "." to Win32 ".\\". - -2009-12-21 Corinna Vinschen - - * exec.cc (execvp): Call find_exec with FE_NNF flag to enforce - a NULL return when executable isn't found in $PATH. Convert NULL - to "". - (execvpe): Ditto. - * spawn.cc (spawn_guts): Return with EFAULT if prog_arg is NULL. - Return with ENOENT if prog_arg is empty string. Add a comment. - -2009-12-21 Thomas Wolff - - * fhandler_console.cc (get_nonascii_key): Generate ESC prefix - for Alt modifier generically for function keys and keypad keys. - Distinguish Normal, Ctrl, Shift, Ctrl-Shift rather - than Normal, Ctrl, Shift, Alt, so that in combination with generic - Alt handling all 8 combinations of these modifiers are distinguished. - (keytable): Add escape sequences for remaining modified - function keys as a compatible extension using rxvt escape codes. - Also distinguish keypad keys modified with Ctrl, Shift, Ctrl-Shift - using xterm-style modifier coding. - -2009-12-21 Corinna Vinschen - - Throughout, revert ill-conceived replacement of hMainThread with - GetCurrentThread/NtCurrentThread. - * dcrt0.cc (dll_crt0_0): Duplicate main thread handle to hMainThread - again. - -2009-12-19 Corinna Vinschen - - * fhandler_console.cc (__vt100_conv): Minor formatting change. - -2009-12-19 Thomas Wolff - - * fhandler_console.cc (write_console): Check for VT100 - graphics mode and transform wide characters in ASCII small - letter range to corresponding graphics. - (__vt100_conv): Table to transform small ASCII letters to line - drawing graphics for use in VT100 graphics mode. - (write_normal): Check for SO/SI control characters to - enable/disable VT100 graphics mode. - (base_chars): Enable SO/SI control characters for detection. - (write): Check for ESC ( 0 / ESC ( B escape sequences to - enable/disable VT100 graphics mode. Also detect ">" while - parsing ESC [ sequences to distinguish specific requests. - (char_command): Distinguish Secondary from Primary Device Attribute - request to report more details about cygwin console terminal version. - * fhandler.h (vt100_graphics_mode_active): New flag to indicate mode. - (saw_greater_than_sign): New parse flag for ESC [ > sequences. - (gotparen, gotrparen): New state values to parse ESC ( / ) sequences. - - * fhandler_console.cc (read): Allow combined Alt-AltGr modifiers - to also produce an ESC prefix like a plain Alt modifier, e.g. to make - Alt-@ work on a keyboard where @ is AltGr-q. - -2009-12-18 Eric Blake - - * signal.cc (nanosleep): Fix bug in previous patch. - -2009-12-18 Corinna Vinschen - - Throughout, replace hMainProc with GetCurrentProcess/NtCurrentProcess - according to context. Throughout, replace hMainThread with - GetCurrentThread/NtCurrentThread according to context. - * dcrt0.cc (dll_crt0_0): Drop duplication of GetCurrentProcess to - hMainProc. Drop duplication of GetCurrentThread to hMainThread. - * dtable.cc (dtable::stdio_init): Remove useless comment. - * globals.cc (hMainProc): Remove. - (hMainThread): Remove. - * ntdll.h (NtCurrentProcess): Define. - (NtCurrentThread: Define. - -2009-12-18 Corinna Vinschen - - * fhandler.h (fhandler_registry::value_name): Convert to wchar_t*. - * fhandler_registry.cc: Call UNICODE registry functions throughout - and convert to multibyte using current locale's charset. Accommodate - throughout. - (must_encode): Take wchar_t. - (encode_regname): Convert from wchar_t *. - (decode_regname): Convert to wchar_t *. - -2009-12-18 Corinna Vinschen - - * path.sgml (func-cygwin-conv-path): Clarify meaning of size parameter. - (func-cygwin-conv-path-list): Fix typo. - (func-cygwin-posix-path-list-p): Ditto. - -2009-12-17 Corinna Vinschen - - * syscalls.cc (try_to_bin): Handle remote shares as well. Just rename - files in this case, instead of moving them to the recycler. Create - even more unique filename. Add comment to explain filename. - (unlink_nt): Remove code returning with EBUSY on remote shares. - Set bin_stat to move_to_bin except on NFS. Add comment to explain. - -2009-12-17 Eric Blake - - * signal.cc (nanosleep): Support 'infinite' sleep times. - (sleep): Avoid uninitialized memory. - -2009-12-16 Thomas Wolff - - * fhandler_console.cc (read): Detect and handle mouse wheel scrolling - events (for completion of mouse reporting mode 1000) and mouse - movement events (for additional mouse reporting modes 1002 and 1003). - Use mouse_aware() as a guard and only condition for mouse - reporting in order to enforce consistence of read() and select(). - Add focus reports (for additional focus reporting mode 1004). - (mouse_aware): Enable detection of additional mouse events for select(). - Tune function to precisely match actual reporting criteria. - Move adjustment of mouse position (by window scroll offset) - here to avoid duplicate code. - (char_command): Initialization of enhanced mouse reporting modes. - Initialization of focus reporting mode. - * fhandler.h (use_mouse): Change flag (bool->int) to indicate - additional mouse modes. Add flag to indicate focus reporting. - (mouse_aware): Move enhanced function into fhandler_console.cc. - * select.cc (peek_console): Use modified mouse_aware() for more - general detection of mouse events. Also check for focus reports. - -2009-12-16 Corinna Vinschen - - * registry.cc (cygnus_class): Remove. - (reg_key::build_reg): Don't set class when creating key. - -2009-12-15 Corinna Vinschen - - * net.cc (cygwin_setsockopt): Only skip calling setsockopt(SO_REUSEADDR) - on stream sockets under systems supporting enhanced socket security. - -2009-12-15 Thomas Wolff - - * fhandler_console.cc (char_command): Fix code to select dim mode - to 2 rather than 9. Add entries for mode 22 (normal, not bold) - 28 (visible, not invisible), 25 (not blinking). - -2009-12-14 Corinna Vinschen - - * libc/getopt.c (getopt_internal): Set optreset according to optind - setting earlier. Reevaluate POSIXLY_CORRECT if optreset is set to !0. - Handle a leading '-' in options independently of posixly_correct. - -2009-12-09 Christopher Faylor - - * fhandler_fifo.cc (fhandler_fifo::open): Avoid resetting errno after - it has been explicitly set. - - * include/cygwin/version.h: Bump DLL minor version number to 2. - -2009-12-06 Corinna Vinschen - - * include/cygwin/version.h: Bump DLL minor version number to 1. - -2009-12-02 Corinna Vinschen - - * fhandler_socket.cc (send_internal): Don't split datagram messages - into pieces. - - * syslog.cc (vsyslog): Set default facility to LOG_USER if it hasn't - been set yet. - -2009-12-01 Corinna Vinschen - - * fhandler_registry.cc (fhandler_registry::open): Mark /proc/registry - directory and siblings as nohandle fhandler. - -2009-11-30 Christopher Faylor - - * speclib: Use last dll found since that's the real name of the cygwin - DLL. - -2009-11-27 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::fstat_helper): Fix typos in - comments. Always open file synchronized when reading header bytes, - otherwise suffer stack corruption. - -2009-11-26 Corinna Vinschen - - * dtable.cc (dtable::stdio_init): Use GetCurrentProcess() rather than - hMainProc as process handle when duplicating the stdout handle. - Explain why. Add Win32 error code to debug output. - -2009-11-23 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::fixup_before_fork_exec): Add - socket handle value to debug output. - (fhandler_socket::fixup_after_fork): Ditto. Make new socket handle - OVERLAPPED, just as if it has been created with socket(). - * net.cc (fdsock): Close duplicated socket and explain why. Disable - the entire WSADuplicateSocket test for now and explain why. - -2009-11-23 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::set_close_on_exec): Only call - fhandler_base::set_close_on_exec for inheritable sockets. - -2009-11-21 Corinna Vinschen - - * globals.cc (ro_u_dll): New R/O unicode string. - * syscalls.cc (nt_path_has_executable_suffix): Add ro_u_dll to - blessed_executable_suffixes array. Explain why. - -2009-11-18 Corinna Vinschen - - * flock.cc (fhandler_disk_file::lock): Disable a shortcut from the - original BSD code, but keep it in and documented why we can't use it. - -2009-11-18 Corinna Vinschen - - * ntea.cc (read_ea): Always add length of "user." prefix, not only - on Samba. Change comment. - -2009-11-18 Corinna Vinschen - - * ntea.cc (read_ea): Try to open file first to have more sensible - error codes. Always refuse non "user." EAs for Linux compatibility - and return EOPNOTSUPP. Fix handling of empty (== non-existant) EAs. - Always prepend "user." prefix to EA names. - (write_ea): Try to open file first to have more sensible error codes. - Always refuse non "user." EAs for Linux compatibility and return - EOPNOTSUPP. Delay skipping "user." prefix until after potential call - to read_ea. - -2009-11-17 Corinna Vinschen - - Reintegrate socket duplication via WSADuplicateSocket/WSASocket. - * autoload.cc (WSADuplicateSocketW): Define. - (WSASocketW): Define. - * dtable.cc (dtable::release): Call dec_need_fixup_before if necessary. - (dtable::fixup_before_fork): New function. - (dtable::fixup_before_exec): New function. - * dtable.h (class dtable): Add member cnt_need_fixup_before. Add - declarations for above new functions. - (dtable::dec_need_fixup_before): New inline method. - (dtable::inc_need_fixup_before): New inline method. - (dtable::need_fixup_before): New inline method. - * fhandler.h (fhandler_base::fixup_before_fork_exec): New virtual - method. - (fhandler_base::need_fixup_before): New virtual method. - (class fhandler_socket): Add member prot_info_ptr. - (fhandler_socket::init_fixup_before): Declare. - (fhandler_socket::need_fixup_before): New inline method. - (fhandler_socket::fixup_before_fork_exec): Declare. - (fhandler_socket::fixup_after_exec): Declare. - * fhandler_socket.cc (fhandler_socket::fhandler_socket): Initialize - prot_info_ptr to NULL. - (fhandler_socket::~fhandler_socket): Free prot_info_ptr conditionally. - (fhandler_socket::init_fixup_before): New method. - (fhandler_socket::fixup_before_fork_exec): Ditto. - (fhandler_socket::fixup_after_fork): Use WSASocketW to duplicate - socket if necessary. - (fhandler_socket::fixup_after_exec): New method. - (fhandler_socket::dup): Use fixup_before_fork_exec/fixup_after_fork - to duplicate socket if necessary. - * fork.cc (frok::parent): Start child suspended if some fhandler - needs fixup before fork. If so, call dtable::fixup_before_fork after - CreateProcess and resume child. - * net.cc (fdsock): Try to find out if socket needs fixup before and - initialize socket accordingly. Add HUGE comment to explain what happens - and why. - * spawn.cc (spawn_guts): Start child suspended if some fhandler needs - fixup before exec. If so, call dtable::fixup_before_exec after - CreateProcess. - -2009-11-16 Eric Blake - - * environ.cc (setenv): Detect invalid argument. - (unsetenv): Distinguish EFAULT from EINVAL. - -2009-11-13 Corinna Vinschen - - * net.cc (fdsock): Fill _rmem and _wmem with valid values returned - from getsockopt if setsockopt with desired values failed. - -2009-11-12 Yaakov Selkowitz - Corinna Vinschen - - * sysconf.cc (get_nprocs): New function. - (get_nprocs_conf): Ditto. - (get_avphys_pages): Ditto. - (get_phys_pages): Ditto. - * cygwin.din: Export them. - * include/sys/sysinfo.h: New header, decalre above new functions. - * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. - * posix.sgml: Mention them as GNU extensions. - -2009-11-11 Corinna Vinschen - - * fhandler.h (class fhandler_mailslot): Declare new private method - get_object_attr. - * fhandler_mailslot.cc (fhandler_mailslot::get_object_attr): Implement. - (fhandler_mailslot::open): Replace calls to path_conv::get_object_attr - with calls to fhandler_mailslot::get_object_attr. - -2009-11-10 Corinna Vinschen - - * fhandler_console.cc (fhandler_console::read): Revert change from - 2009-11-09. - -2009-11-10 Corinna Vinschen - - * fhandler_disk_file.cc (is_volume_mountpoint): Align check with - symlink_info::check_reparse_point(). - * path.cc (symlink_info::check_reparse_point): Rearrange slightly. - Add code path for unrecognized repare point types. Add comment. - -2009-11-09 Corinna Vinschen - - * path.cc (symlink_info::check_reparse_point): Always check - SubstituteName for volume string to recognize volume mount points. - Reuse subst when calling sys_wcstombs. - * syscalls.cc (rename): Set errno to EBUSY when trying to rename - volume mount points. Explain why. - -2009-11-09 Corinna Vinschen - - * fhandler_console.cc (fhandler_console::read): Restrict generating - META key sequences to singlebyte input chars. - -2009-11-08 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::fstat_helper): Drop all "other" - permissions from st_mode, if the reading the file's security descriptor - failed. Explain why. - -2009-11-06 Corinna Vinschen - - * globals.cc (ro_u_scr): New R/O unicode string. - (ro_u_sys): Ditto. - * syscalls.cc (nt_path_has_suffix): Replace with ... - (nt_path_has_executable_suffix): New function checking for explicit - executable suffixes. - (rename): Call nt_path_has_executable_suffix instead of - nt_path_has_suffix. Check oldpath for nt_path_has_executable_suffix - as well to set old_explicit_suffix. - -2009-11-06 Corinna Vinschen - - * shared.cc (inst_root_inited): New static bool variable. - (init_installation_root): Set inst_root_inited to true. - (memory_init): Print installation root debug output only if - inst_root_inited is true. - -2009-11-05 Corinna Vinschen - - * syscalls.cc (nt_path_has_suffix): New function. - (rename): Don't append .exe suffix if binary target name has any suffix - at all. - -2009-11-05 Corinna Vinschen - - * spawn.cc (dll_suffixes): Disable. Explain why. - (perhaps_suffix): Use stat_suffixes instead of dll_suffixes. - -2009-11-03 Corinna Vinschen - - * security.cc (alloc_sd): Re-introduce setting the SE_DACL_PROTECTED - flag. Remove INHERITED_ACE flag from all inherited ACEs. Add comment. - Fix ace_off counter in unrelated ACE loop. - * wincap.cc: Re-add has_dacl_protect throughout. - * wincap.h: Ditto. - -2009-11-02 Corinna Vinschen - - * security.cc (alloc_sd): Re-enable generating default permission - entries for directories. - -2009-11-02 Corinna Vinschen - - * dlfcn.cc (get_full_path_of_dll): Drop enforcing a .dll suffix. - (dlopen): If last path component has no dot, append one to override - automatic .dll suffix in LoadLibrary. - -2009-11-02 Corinna Vinschen - - * miscfuncs.h (transform_chars): Declare. Define inline variation here. - * mount.cc (mount_info::from_fstab): Remove extern declaration of - transform_chars. - * path.cc (tfx_chars): Move to strfuncs.cc. - (transform_chars): Ditto. - * strfunc.cc (tfx_chars): Moved here from path.cc. - (transform_chars): Ditto. - (sys_cp_wcstombs): Make UNICODE private use area conversion roundtrip - save for all characters. - (sys_cp_mbstowcs): Ditto, by removing special case for UTF-8 sequences - representing U+F0xx UNICODE chars. Fix typo in comment. - -2009-11-02 Corinna Vinschen - - * path.cc (tfx_chars): Constify. - -2009-10-31 Corinna Vinschen - - * cygprops.h: New file. - * dtable.cc (handle_to_fn): Add check for correct installation_key - string in object name for pipes and ttys. - * external.cc (cygwin_internal): Add CW_GET_INSTKEY to allow fetching - the installation_key from cygserver. - * fhandler_fifo.cc (fhandler_fifo::fifo_name): Add installation_key - to fifo name. - * globals.cc: Include cygprops.h. - (_RDATA): Move slightly and add comment. - (cygwin_props): Define. - * mount.cc (mount_info::init): Accommodate the fact that - installation_root is now a global variable in DLL common shared memory, - rather than a member of cygwin_shared. - * pipe.cc (fhandler_pipe::create_selectable): Add installation_key to - pipe name. - * shared.cc (installation_root): Define here for storage in DLL - common shared memory. - (installation_key): Ditto. - (installation_key_buf): Ditto. - (init_installation_root): Convert from shared_info method to ordinary - function. Add initializing installation_key. Invalidate - installation_key depending of value of disable_key property. Add - comment to explain. - (get_shared_parent_dir): Add installation_key to directory name. - (get_session_parent_dir): Ditto. - (shared_info::initialize): Move call to init_installation_root from - here... - (memory_init): ...to here. Add debug output to print installation root - and installation key. Add comment to explain why. - * shared_info.h (SHARED_INFO_CB): Recalculate. - (CURR_SHARED_MAGIC): Ditto. - (class shared_info): Remove definition of installation_root and - declaration of init_installation_root. - (init_installation_root): Declare. - (installation_root): Declare. - (installation_key): Declare. - * uinfo.cc (pwdgrp::load): Accommodate the fact that installation_root - is now a global variable in DLL common shared memory. - * include/cygwin/version.h: Bump API minor number. - (CYGWIN_INFO_INSTALLATIONS_NAME): Add. - * include/sys/cygwin.h (cygwin_getinfo_types): Add CW_GET_INSTKEY. - -2009-10-31 Corinna Vinschen - - * sec_helper.cc (security_descriptor::realloc): Call free first if - current security desriptor has been allocated by GetSecurityInfo. - -2009-10-30 Corinna Vinschen - - * sec_helper.cc (security_descriptor::free): If sd_size is 0, call - LocalFree instead of ::free. - - * sec_acl.cc: Throughout replace old ACE flag definitions with current - definitions as used in MSDN man pages. - * security.cc: Ditto. - - * fhandler.cc (fhandler_base::open): Make sure file has really been - just created before fixing file permissions. Add S_JUSTCREATED - attribute to set_file_attribute call. - * fhandler_disk_file.cc (fhandler_disk_file::mkdir): Always create dir - with default security descriptor and fix descriptor afterwards. - Add S_JUSTCREATED flag to set_file_attribute call. - * fhandler_socket.cc (fhandler_socket::bind): Ditto for AF_LOCAL - socket files. - * path.cc (symlink_worker): Ditto for symlinks. - * security.cc (get_file_sd): Call GetSecurityInfo rather than - NtQuerySecurityObject. Explain why. Change error handling accordingly. - (alloc_sd): Skip non-inherited, non-standard entries in ACL if - S_JUSTCREATED attribute is set. Explain why. Minor format fixes. - * security.h (S_JUSTCREATED): New define. - (security_descriptor::operator=): New operator. - -2009-10-30 Corinna Vinschen - - * fhandler_random.cc (fhandler_dev_random::lseek): Revert change from - 2009-10-23. - -2009-10-30 Corinna Vinschen - - * smallprint.cc (hex_str): New const string. - (__rn): Drop str and use hex_str instead. - (__small_vsprintf): If 'l' modifier has been found, print subsequent - multibyte or wide char string using the s, S, or W options in extended - hex value layout. - - * fhandler_disk_file.cc (fhandler_disk_file::readdir): Print WCHAR - and resulting multibyte filename in extended hex value layout in - debug output. - -2009-10-26 Charles Wilson - - * lib/pseudo-reloc.c (__report_error) [CYGWIN]: Correct size bug - regarding error messages. - -2009-10-25 Charles Wilson - - Sync pseudo-reloc.c with mingw64 - * lib/psuedo-reloc.c: Remove unnecessary includes. - Forward declare _pei386_runtime_relocator. - Decorate _image_base__ symbol with macro for - mingw64 compatibility. Whitespace changes. - (__print_reloc_error): Renamed to... - (__report_error): This. "Returns" void, and - always aborts. Now used on all platforms. - (__write_memory): Remove special case error handling - for different platforms - always call __report_error. - (do_pseudo_reloc): Remove special case error handling - for different platforms - always call __report_error. - (_pei386_runtime_relocator): Decorate _image_base__ - symbol with mingw64 compatibility macro. - -2009-10-24 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Remove unused variables sa and sd. - -2009-10-23 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Always create file with default - security descriptor and fix descriptor afterwards. Change comment to - explain why. - * security.cc (alloc_sd): Drop setting the SE_DACL_PROTECTED flag. - * wincap.cc: Remove has_dacl_protect throughout. - * wincap.h: Ditto. - -2009-10-23 Corinna Vinschen - - * fhandler_random.cc (fhandler_dev_random::lseek): Allow negative - dummy file positions as on Linux. - -2009-10-20 Corinna Vinschen - - * registry.cc (reg_key::get_int): Add alternative implementation - taking WCHAR strings. - (reg_key::set_int): Ditto. - (reg_key::get_string): Ditto. - (reg_key::set_string): Ditto. - * registry.h (struct reg_key): Add prototypes for added methods. - -2009-10-20 Corinna Vinschen - - * smallprint.cc (__small_vsprintf): Simplify UNICODE string handling - and allow empty strings. - -2009-10-20 Corinna Vinschen - - * fhandler_disk_file.cc (fhander_disk_file::readdir): Handle a status - code STATUS_NOT_SUPPORTED. Add matching comment. - -2009-10-19 Corinna Vinschen - - * syscalls.cc (internal_setlocale): Only convert $PATH if there is a - $PATH. - -2009-10-19 Corinna Vinschen - - * spawn.cc (av::fixup): Treat non-readable, but executable files as - Cygwin executables. - -2009-10-18 Corinna Vinschen - - * uinfo.cc (uinfo_init): Deimpersonate, don't reimpersonate, if - not in a setuid condition. - -2009-10-13 Eric Blake - - * external.cc (cygwin_internal): Use va_end. - * fork.cc (child_copy): Likewise. - * libc/bsdlib.cc (warn, warnx, err, errx): Likewise. - * pinfo.cc (commune_request): Likewise. - * strace.cc (strace::prntf, strace_printf): Likewise. - -2009-10-13 Corinna Vinschen - - * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. - -2009-10-13 Christian Franke - Corinna Vinschen - - * include/sys/cygwin.h: Add new cygwin_getinfo_type - CW_SET_EXTERNAL_TOKEN. - Add new enum CW_TOKEN_IMPERSONATION, CW_TOKEN_RESTRICTED. - * cygheap.h (cyguser): New flags ext_token_is_restricted, - curr_token_is_restricted and setuid_to_restricted. - * external.cc (cygwin_internal): Add CW_SET_EXTERNAL_TOKEN. - * sec_auth.cc (set_imp_token): New function. - (cygwin_set_impersonation_token): Call set_imp_token (). - * security.h (set_imp_token): New prototype. - * spawn.cc (spawn_guts): Use CreateProcessAsUserW if restricted token - was enabled by setuid(). Do not create new window station in this case. - * syscalls.cc (seteuid32): Add handling of restricted external tokens. - Set HANDLE_FLAG_INHERIT for primary token. - (setuid32): Set setuid_to_restricted flag. - * uinfo.cc (uinfo_init): Do not reimpersonate if restricted token was - enabled by setuid (). Initialize user.*_restricted flags. - -2009-10-13 Eric Blake - - * hires.h (hires_ms): Change initime_us to initime_ns, with 10x - more resolution. - (hires_ms::nsecs): New prototype. - (hires_ms::usecs, hires_ms::msecs, hires_ms::uptime): Adjust. - * times.cc (systime_ns): New helper function. - (hires_ms::prime): Use it for more resolution. - (hires_ms::usecs): Change to... - (hires_ms::nsecs): ...with more resolution. - (clock_gettime): Use more resolution. - (systime): Rewrite in terms of systime_ns. - (timespec_to_filetime): Rewrite math to reflect true operation. - * fhandler_disk_file.cc (utimens_fs): Use higher resolution. - -2009-10-12 Corinna Vinschen - - * external.cc (cygwin_internal): Return 0 in CW_SET_DOS_FILE_WARNING - and CW_SETERRNO cases. - -2009-10-12 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::link): Only append .lnk - if the original device had one, too. Add comment. - - * fhandler_socket.cc (fhandler_socket::fstat): Always return a size of - 0 on sockets. - -2009-10-09 Corinna Vinschen - - * path.cc (tfx_chars): Convert all ASCII control characters except - ASCII NUL as well. Change layout to make the conversions more clear. - Add comment. - -2009-10-09 Corinna Vinschen - - * include/cygwin/config.h (DEFAULT_LOCALE): Define as "C.UTF-8". - -2009-10-08 Christopher Faylor - - * exceptions.cc (_cygtls::signal_exit): There's no need to set - signal_arrived if we're exiting. - -2009-10-08 Eric Blake - - * fhandler_disk_file.cc (utimens_fs): Plug fd leak on EINVAL. - -2009-10-07 Charles Wilson - - Additional pseudo-reloc-v2 support - * ntdll.h: Add custom NTSTATUS value for pseudo-reloc - errors STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION. - * pinfo.cc (status_exit): Map custom pseudo-reloc - error value STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION to 127. - * sigproc.cc (child_info::proc_retry): Return exit code when - STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION. - - Cygwin modifications to pseudo-reloc.c - * lib/pseudo-reloc.c: Added comments throughout and various - whitespace fixes. Exploit cygwin_internal(CW_EXIT_PROCESS,...) - for fatal error handling that is consistent with cygwin process - life-cycle. Ensure state variable (in _pei386_runtime_relocator) - is unique to each address space, across fork(). - (__print_reloc_error): New function for reporting errors in a - manner supported by cygwin at this early stage of the process - life-cycle. - (_pei386_runtime_relocator): Ensure relocations performed - only once for each address space, but are repeated after fork() - in the new address space. - only once for each address space (e.g. across fork()). - (__write_memory) [MINGW]: Ensure that b is always initialized - by call to VirtualQuery, even if -DNDEBUG. - - * lib/pseudo-reloc.c: Import new implementation to support - v2 pseudo-relocs implemented by Kai Tietz from mingw. - -2009-10-07 Corinna Vinschen - - * syscalls.cc (seteuid32): Call set_cygwin_privileges on primary token - as well. - -2009-10-07 Corinna Vinschen - - * fhandler.h (fhandler_pty_master::tcgetpgrp): Declare. - * fhandler_termios.cc (fhandler_termios::tcgetpgrp): Only return - valid pgid if tty is controlling tty. Set errno to ENOTTY and - return -1 otherwise. - (fhandler_pty_master::tcgetpgrp): New function. Return 0 for - master side of pty if it's not the controlling tty of the process. - -2009-10-05 Charles Wilson - - Add cygwin wrapper for ExitProcess and TerminateProcess. - * include/sys/cygwin.h: Declare new cygwin_getinfo_type - CW_EXIT_PROCESS. - * external.cc (exit_process): New function. - (cygwin_internal): Handle CW_EXIT_PROCESS. - * pinfo.h (pinfo::set_exit_code): New method. - * pinfo.cc (pinfo::set_exit_code): New, refactored from... - (pinfo::maybe_set_exit_code_from_windows): here. Call it. - * include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR - to 215 to reflect the above change. - -2009-10-05 Charles Wilson - - * exceptions.cc: Move global variable sigExeced... - * globals.cc: here. - * pinfo.cc (pinfo::maybe_set_exit_code_from_windows): Remove now - unneeded declaration. - -2009-10-04 Dave Korn - - * Makefile.in (CFLAGS): Add -mno-use-libstdc-wrappers. - -2009-10-04 Corinna Vinschen - - * syscalls.cc (internal_setlocale): Add comment. - -2009-10-02 Corinna Vinschen - - * dcrt0.cc (dll_crt0_1): Drop calls to setlocale/_setlocale_r. Just - call initial_setlocale from here. - * syscalls.cc (initial_setlocale): Set internal charset and revert - application locale to "C". - (setlocale): Don't set Cygwin's internal charset here. - -2009-10-02 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Move cxx_malloc reset kluge from here. - (check_sanity_and_sync): to here. - -2009-09-30 Christopher Faylor - - * path.cc (has_dot_last_component): Rewrite to detect some corner cases - that were previously uncaught. - -2009-09-30 Corinna Vinschen - - * fhandler_console.cc (beep): Move up to avoid forward declaration. - (fhandler_console::read): Just beep on characters invalid in current - charset. Add comment. - -2009-09-29 Eric Blake - - * syscalls.cc (rename): Fix regression in rename("dir","d/"). - -2009-09-29 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::recv_internal): Always call - WSARecv on SOCK_STREAM sockets. - -2009-09-28 Corinna Vinschen - - * fhandler.h (class dev_console): Constify charset parameter of - str_to_con. - * fhandler_console.cc (dev_console::con_to_str): Simplify. Always - default to the current internal locale. - (dev_console::get_console_cp): Always use codepage 437 for alternate - charset. - (dev_console::str_to_con): Constify charset parameter. - (fhandler_console::write_normal): Always use codepage 437 for alternate - charset. Otherwise always default to the current internal locale. - Replace ASCII SO with ASCII CAN. - * strfuncs.cc: Tweak comments according to below changes. - (sys_cp_wcstombs): Constify charset parameter. Convert all wchar_t - values in the Unicode private use area U+F0xx to the singlebyte - counterpart. Drop special handling creating ASCII SO sequence from - U+DCxx value. Rearrange for performance. Replace ASCII SO with - ASCII CAN. - (sys_cp_mbstowcs): Constify charset parameter. Replace ASCII SO with - ASCII CAN. Drop special case for U+DCxx ASCII SO sequences. Always - create a replacement from the Unicode private use area U+F0xx for - invalid byte values in a multibyte sequence. Do the same for wchar_t - values from the U+F0xx range to make them roundtrip safe. - * wchar.h (sys_cp_wcstombs): Constify charset parameter. - (sys_cp_mbstowcs): Ditto. - -2009-09-28 Corinna Vinschen - - * cygheap.cc (cygheap_init): Default locale.charset to "UTF-8". - * dcrt0.cc (dll_crt0_1): Call setlocale (LC_CTYPE, "") here, just - before resetting application locale to "C". - * environ.cc (environ_init): Drop code setting locale here. - * syscalls.cc (check_codepage): Break out check for required codepage - from internal_setlocale. - (internal_setlocale): Just convert CWD and $PATH from old charset to - new charset and set internal charset. - (setlocale): Change accordingly. Don't require LC_ALL or LC_CTYPE to - store old locale value. Always call internal_setlocale if charset - changed due to locale environment changes. - -2009-09-26 Eric Blake - - * exec.cc (fexecve): New function. - * cygwin.din (execvpe, fexecve): Export new fexecve and existing - execvpe. - * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. - * posix.sgml: Mention them. - -2009-09-26 Eric Blake - - * syscalls.cc (link): Delete obsolete comment. Reject directories - and missing source up front. - (rename): Use correct errno for trailing '.'. Detect empty - strings. Allow trailing slash to newpath iff oldpath is - directory. - * dir.cc (mkdir): Reject dangling symlink with trailing slash. - * fhandler_disk_file.cc (fhandler_disk_file::link): Reject - trailing slash. - * fhandler.cc (fhandler_base::link): Match Linux errno. - -2009-09-25 Eric Blake - - * syscalls.cc (fchmodat): lchmod is not yet implemented. - (euidaccess): New function. - * path.cc (realpath): Update comment. - (canonicalize_file_name): New function. - * include/cygwin/stdlib.h (canonicalize_file_name): Declare it. - * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. - * cygwin.din: Export canonicalize_file_name, eaccess, euidaccess. - * posix.sgml: Mention them. - -2009-09-25 Eric Blake - - * fhandler.h (fhandler_base::fhaccess): Add parameter. - * security.h (check_file_access, check_registry_access): Likewise. - * security.cc (check_file_access, check_registry_access) - (check_access): Implement new parameter. - * fhandler.cc (fhandler_base::fhaccess): Likewise. - (device_access_denied): Update caller. - * syscalls.cc (access, faccessat): Update callers. - * spawn.cc (find_exec, fixup): Likewise. - -2009-09-24 Corinna Vinschen - - * posix_ipc.cc (mq_open): Avoid closing the same descriptor twice in - case of errors. - (sem_open): Ditto. - -2009-09-24 Corinna Vinschen - - * kernel32.cc (CreateMutexW): Use correct access mask. - (CreateSemaphoreW): Ditto. - -2009-09-23 Corinna Vinschen - - * strfuncs.cc (__set_charset_from_codepage): Fetch current ANSI - codepage if cp is 0. - -2009-09-23 Corinna Vinschen - - * strfuncs.cc (sys_cp_wcstombs): Convert lone surrogate pair - second halves to unambiguous ASCII SO sequence. When converting - chars invalid in current codepage to ASCII SO sequence, make - sure to check for surrogate pair second half only if at least - one wide characters is left. Decrement nwc if valid second half has - been converted. - (sys_cp_mbstowcs): Improve ASCII SO handling. Never break from loop - if invalid character has been found. Recognize ASCII SO sequence - representing originally invalid mulitbyte char converted into a - lone surrogate pair second half. Convert accordingly. - -2009-09-22 Corinna Vinschen - - * autoload.cc (WSARecv): Define. - * fhandler_socket.cc (fhandler_socket::recv_internal): Call WSARecv - instead of WSARecvFrom if no name parameter is given. Explain why. - -2009-09-22 Eric Blake - - * syscalls.cc (faccessat): Fix typo, reject bad flags. - (fchmodat, fchownat, fstatat, utimensat, linkat, unlinkat): Reject - bad flags. - -2009-09-22 Corinna Vinschen - - * strfuncs.cc (sys_cp_mbstowcs): Reset shift state after handling - invalid multibyte sequence. - -2009-09-22 Corinna Vinschen - - * path.cc (symlink_worker): Rework error handling to generate Linux - compatible errno in case of trailing slash in newpath. - -2009-09-22 Eric Blake - - * dtable.h (OPEN_MAX_MAX): New macro. - * resource.cc (getrlimit) [RLIMIT_NOFILE]: Use it. - * dtable.cc (dtable::extend): Likewise. - * fcntl.cc (fcntl64): Obey POSIX rule with too-large F_DUPFD. - * syscalls.cc (dup2): Likewise. - -2009-09-21 Corinna Vinschen - - * cygheap.h (cwdstuff::get_posix): Convert to const inline method just - returning pointer to posix path. - (cwdstuff::reset_posix): Convert to non-inline method taking a wchar_t - pointer. - * path.cc (cwdstuff::set): Revert change from 2009-05-13. Set posix - to valid incoming path again. - (cwdstuff::reset_posix): New implementation setting posix path from - incoming wchar_t path. Explain usage. - (cwdstuff::get_posix): Drop implementation. - (cwdstuff::get): Drop special case to handle empty posix path. - * syscalls.cc (internal_setlocale): Store old posix cwd as wide char - path. Restore posix cwd using new charset. Explain why. - -2009-09-21 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::link): Drop faking hardlink - creation on filesystems not supporting hardlinks. - -2009-09-20 Christopher Faylor - - * dcrt0.cc (dll_crt0_1): Add another hack to REALLY make sure that - cxx_malloc is always set to the cygwin version. - -2009-09-20 Christopher Faylor - - * external.cc (cygwin_internal): Add hack to always reset cxx_malloc to - proper value. - - * lib/_cygwin_crt0_common.cc (_cygwin_crt0_common): Relocate wayward - comment. - -2009-09-19 Christopher Faylor - - * exceptions.cc (sigpacket::process): Explicitly set thread-specific - handler function to zero to avoid transferring to incorrect location. - (_cygtls::call_signal_handler): Don't transfer to handler if there is - no handler to transfer to. - -2009-09-18 Christopher Faylor - - * exceptions.cc (sigpacket::process): Give sigwait() processing - precedence even when a handler is present. - - * syscalls.cc (getpagesize): Change return to 'int'. - -2009-09-16 Christopher Faylor - - * ntea.c (write_ea): Don't abort if not-samba. - -2009-09-01 Christopher Faylor - - * select.cc (peek_console): Always check window size when there is ANY - keyboard activity. - -2009-08-26 Corinna Vinschen - - * path.h (INTERIX_SYMLINK_COOKIE): Define. - * path.cc (symlink_info::check_sysfile): Read Interix symlinks as well. - -2009-08-26 Corinna Vinschen - - * fhandler.cc (fhandler_base::open): Only set R/O attribute if ACLs - are not used. - -2009-08-24 Corinna Vinschen - - * mount.cc (fs_info::update): Add comment. - * path.cc (symlink_info::check_reparse_point): Return -1 for volume - mount points. Explain why. - (symlink_info::check): Call fs.update again for volume mount points. - Explain why. - -2009-08-24 Corinna Vinschen - - * globals.cc (ro_u_volume): New R/O unicode string. - * path.cc (symlink_info::check_reparse_point): Fix check for volume - mount points to work on Vista and later as well. - -2009-08-22 Corinna Vinschen - - * strfuncs.cc (__set_charset_from_codepage): Add codepages 20866 - (KOI8-R) and 21866 (KOI8-U). - -2009-08-21 Christopher Faylor - - * dll_init.h (has_dtors): New flag. - (run_dtors): New wrapper function which avoids calling dtors more than - once. - * dll_init.cc (dll_global_dtors): Use dll.run_dtors wrapper. - (dll_list::detach): Ditto. - (dll_list::alloc): Set has_dtors flag. - -2009-08-21 Christopher Faylor - - * fcntl.cc (fcntl64): Detect negative fd as error. - -2009-08-21 Corinna Vinschen - - * mmap.cc (mmap64): Allocate fh_disk_file on cygheap. Delete - explicitely before returning. - -2009-08-20 Corinna Vinschen - - * dtable.cc (build_fh_dev): Take additional bool parameter indicating - whether set_name should be called or not. - (dtable::dup_worker): Call build_fh_pc with new second parameter set - to false. Explain why. If fhandler's dup failed, delete rather than - cfree newfh and set newfh to NULL to indicate failure correctly. - * dtable.h (build_fh_pc): Change declaration according to above change. - Default set_name parameter to true. - * mmap.cc (mmap_record::free_fh): Delete rather than cfree fh. - -2009-08-18 Christopher Faylor - - * dtable.cc (dtable::fixup_after_exec): Close any popen'ed file handles here. - * fhandler.h (fhandler_*::ispipe): New function. - (fhandler_base::get_popen_pid): Define virtual function. - (fhandler_*::isdevice): Make const. - (fhandler_*::isfifo): Ditto. - -2009-08-17 Christopher Faylor - - * syscalls.cc (popen): Reorganize slightly for clarity. Fix a comment. - -2009-08-17 Christopher Faylor - - * syscalls.cc (popen): Rewrite to accommodate situations where stdin, - stdout, or stderr are closed. - -2009-08-17 Christopher Faylor - - * pipe.cc (fhandler_pipe::create_selectable): Add -pipe to default pipe names. - - * lib/_cygwin_crt0_common.cc (_cygwin_crt0_common): Use bool/true/false - for what is actually a boolean variable. - -2009-08-14 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::readdir): Fix length - check for ".." dir. - -2009-08-14 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::readdir): Change comment - to be fair. - -2009-08-14 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::readdir_helper): Remove - ill-advised attempt to optimize "." and ".." handling by checking for - specific position in directory listing. Explain why. - (fhandler_disk_file.cc (fhandler_disk_file::readdir): Ditto. - Special-case opening file on NFS to fetch inode number and add longish - comment to explain why. - -2009-08-14 Corinna Vinschen - - * (fhandler_socket::getsockname): Fix length returned for unbound - AF_LOCAL sockets. - (fhandler_socket::getpeername): Ditto. - * net.cc (socketpair): Don't set sun_path and peer_sun_path to - make sure getsockname and getpeername return the correct values - for AF_LOCAL sockets. - -2009-08-13 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::accept): Use sizeof rather - then constant size. Truncate returned data, but return full address - length as per POSIX. - (fhandler_socket::getsockname): Truncate returned data, but return full - address length as per POSIX. - (fhandler_socket::getpeername): Ditto. - -2009-08-13 Corinna Vinschen - - * fhandler.h (class fhandler_socket): Add peer_sun_path member. - (fhandler_socket::set_peer_sun_path): New method. - (fhandler_socket::get_peer_sun_path): New method. - * fhandler_socket.cc (fhandler_socket::fhandler_socket): Initialize - peer_sun_path to NULL. - (fhandler_socket::~fhandler_socket): Free peer_sun_path if necessary. - (fhandler_socket::dup): Duplicate peer_sun_path. - (fhandler_socket::accept): Ditto. Return fake unbound peer content - and len in case of AF_LOCAL sockets. - (fhandler_socket::getsockname): Always use local sockaddr_storage to - store socket address and copy over to incoming address. Handle every - namelen correctly per POSIX. - (fhandler_socket::getpeername): Ditto. Add code path to return - correct value for AF_LOCAL sockets. - (fhandler_socket::set_peer_sun_path): New method. - * net.cc (socketpair): Set peer_sun_path to empty string, just like - sun_path. - -2009-08-13 Corinna Vinschen - Dave Korn - - * cxx.cc (default_cygwin_cxx_malloc): Enhance commenting. - * dll_init.cc (dll_dllcrt0_1): Likewise. - * dlfcn.cc (dlopen): Prevent dlopen()'d DLL from installing any - cxx malloc overrides. - * include/cygwin/cygwin_dll.h (__dynamically_loaded): New variable. - * lib/_cygwin_crt0_common.cc (_cygwin_crt0_common): Check it and only - install cxx malloc overrides when statically loaded. Extend comments. - -2009-08-12 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::accept): Always use local - sockaddr_storage to store peer address and copy over to incoming - peer address if available. Truncate data as necessary according - to POSIX. - -2009-08-11 Corinna Vinschen - - * include/limits.h (NGROUPS_MAX): Set to a more sane value. - * include/sys/param.h (NGROUPS): Ditto. - -2009-08-10 Corinna Vinschen - - * spawn.cc (av::fixup): Check shell scripts for executability only on - filesystems/mounts supporting real permissions. - -2009-08-10 Corinna Vinschen - - * dtable.cc (DEV_SOCKET): New static WCHAR string. Name of - the native NT socket device. - (dtable::init_std_file_from_handle): Remove unused tmp_pathbuf - variable. Move check for sockets into FILE_TYPE_PIPE clause. - Rely on handle_to_fn having recognized socket, or check if - getsockopt works to accommodate NT4 shortcoming. - (handle_to_fn): Use tmp_pathbuf for OBJECT_NAME_INFORMATION - buffer and simplify code due to that. Check name returned by - NtQueryObject for socket device. - -2009-08-10 Christopher Faylor - - * fhandler_console.cc (create_invisible_console_workaround): Fix size - of cmd in the way originally intended. - -2009-08-10 Corinna Vinschen - - * fhandler_console.cc (create_invisible_console_workaround): Fix - size of cmd to take spaces into account. - -2009-08-08 Corinna Vinschen - - * dtable.cc (dtable::init_std_file_from_handle): Fix comment to - document change in the Windows 7 workaround. - * wincap.cc (wincapc::init): Don't set has_console_handle_problem - to false on 32 bit systems. - -2009-08-06 Corinna Vinschen - - * net.cc (cygwin_getnameinfo): Force setting NI_NUMERICSERV only - on Windows 2003 and earlier, only if the port number doesn't - resolve to a well-known service. Change comment accordingly. - -2009-08-05 Christopher Faylor - - * cygheap.h (cygheap_debug::endh): Delete. - * debug.cc (lock_debug::acquired): Delete. - (lock_debug::lock_debug): Simplify. - (lock_debug::unlock): Ditto. - (find_handle): Don't set endh here. - (add_handle): Add new handle to beginning of the list rather than - trying to maintain an end list pointer. - (delete_handle): Minor optimization. - (mark_closed): Make logic clearer. - (verify_handle): Lock handle list before scanning. - (setclexec): Ditto. - (modify_handle): Ditto. - (newh): Don't lock handle list here. Assume caller did this. - (mark_closed): Ditto. - (close_handle): Remove unneeded #if. - * dtable.cc (dtable::dup2): Tweak debug output. - -2009-08-04 Christopher Faylor - - * path.cc (patch_conv::check): Zero path before setting it. - -2009-08-04 Christopher Faylor - - * fhandler_socket.cc (fhandler_socket::send_internal): Just use wmem - size if the length exceeds it. - * net.cc (fdsock): Use 65535 as window size, just like the comment - says or we run into problems with DuplicateHandle. - - * path.cc (patch_conv::check): Use set_path to set invalid filename. - * path.h (path_conv::path_conv): Ditto. - -2009-08-04 Christopher Faylor - - * fhandler.h (pdrive_buf): Defensively allocate one extra byte. - -2009-08-04 Christopher Faylor - - * fhandler.h (fhandler_cygdrive:DRVSZ): New enum. - (pdrive_buf): New place to hold information about cygdrive. - * fhandler_disk_file.cc (fhandler_cygdrive::set_drives): Store drive - info in pdrive_buf since get_win32_name() could now be too small to - hold everything. - (fhandler_cygdrive::rewinddir): Reset pdrive to pdrive_buf. - (fhandler_cygdrive::closedir): Ditto. - * pipe.cc (fhandler_pipe::init): Be more defensive when referencing - get_win32_name(). Rework logic which made a copy of the POSIX path and - then never used it. - -2009-08-02 Christopher Faylor - - * sigproc.cc (stopped_or_terminated): Don't return a match when stopsig - == SIGCONT and not WCONTINUED. - * termios.cc (tcsetpgrp): Improve debugging output. - -2009-08-01 Christopher Faylor - - * cygheap_malloc.h: New file. - * cygheap.h: Remove stuff now included in cygheap_malloc.h and include - that file. Make cygheap_init a standard c++ function. Remove unneeded - child_info declaration. - * path.h: Include cygheap_malloc.h. Remove extra cstrdup declaration. - (path_conv): Reorganize to group variables together. - (path_conv::path): Make const char *. - (path_conv::known_suffix): Ditto. - (path_conv::normalized_path): Ditto. - (path_conv::path_conv): Reorganize initializers to reflect new element - ordering. - (path_conv::get_win32): Change return value to const char *. - (path_conv::set_path): Move back here from spawn.cc. - (parh_conv::modifiable_path): New function. - * path.cc (path_conv::add_ext_from_sym): Accommodate const'ness of - known_suffixes. - (path_conv::set_normalized_path): Ditto for normalized_path. - (path_conv::check): Use modifiable_path whereever we need to modify the - path element. Use set_path to set the path. - (path_conv::~path_conv): Accommodate new const'ness. - * spawn.cc (perhaps_suffix): Declare ext as const since that's what is - being returned. - (path_conv::set_path): Move back to path.h. - * winf.f (linebuf): Perform minor cleanup. - (linebuf::fromargv): Change second parameter to const. - * winf.cc (linebuf::fromargv): Ditto. - -2009-08-01 Christopher Faylor - - * path.h (path_conv::set_path): Change return value. - * spawn.cc (path_conv::set_path): Return newly set value. - (find_exec): Set retval to newly set value when calling set_path. - -2009-07-31 Christopher Faylor - - * spawn.cc (find_exec): Fix one more path where retval was not set. - -2009-07-31 Christopher Faylor - - * spawn.cc (find_exec): Stop relying on the ability to set retval to a - fixed path_conv buffer and set it on the fly instead. - -2009-07-30 Corinna Vinschen - - * path.h (cstrdup): Fix declaration. - -2009-07-29 Dave Korn - - * globals.cc (enum exit_states::ES_GLOBAL_DTORS): Delete. - * dcrt0.cc (__main): Schedule dll_global_dtors to run - atexit before global dtors. - (do_exit): Delete test for ES_GLOBAL_DTORS and call to - dll_global_dtors. - -2009-07-29 Corinna Vinschen - - * path.h (class path_conv): Convert path from char array to char *. - Initialize to NULL in constructors. Drop normalized_path_size member. - (path_conv::size): Remove. - (path_conv::operator =): Always copy with sizeof path_conv. Always - duplicate path on cygheap. - (path_conv::set_path): Move implementation to spawn.cc. - * path.cc (path_conv::set_normalized_path): Always allocate - normalized_path on cygheap. - (path_conv::check): Don't work on path, rather allocate THIS_path in - TLS and use it throughout. When finished, allocate path on cygheap - and copy over. Defer tacking on extension after having copied path. - * spawn.cc (path_conv::set_path): Implement here. - -2009-07-27 Corinna Vinschen - - * mount.h (enum fs_info_type): New type. - (IMPLEMENT_FS_FLAG): New define. - (class fs_info): Convert filesystem type status flags into an enum - fs_info_type. Add cifs FS. Revert change to has_buggy_open and - has_buggy_fileid_dirinfo. Make them normal; status flags again. - Implement is_FS functions using IMPLEMENT_FS_FLAG. - * mount.cc (fs_info::update): Define MINIMAL_WIN_NTFS_FLAGS and - FS_IS_WINDOWS_NTFS. Add comment. Only test remote filesystems - for "NTFS" once. Add is_cifs check using FS_IS_WINDOWS_NTFS. - Set has_buggy_open flag for SUNWNFS. Set has_buggy_fileid_dirinfo - flag for UNIXFS and all cifs type filesystems. Only check for - caseinsensitivity once. - (fillout_mntent): Create locale fs_names array. Use for setting - _my_tls.locals.mnt_type. - -2009-07-27 Yaakov Selkowitz - - * posix.sgml (std-notes): Remove obsolete reference to CYGWIN=server. - -2009-07-25 Corinna Vinschen - - * posix.sgml (std-notes): Add flock restriction. - -2009-07-25 Corinna Vinschen - - * fhandler_console.cc (set_console_title): Set buffer size to - TITLESIZE + 1. Call sys_mbstowcs with correct destination length. - -2009-07-24 Christopher Faylor - - * sigproc.h (wait_for_sigthread): Eliminate parameter. - * sigproc.cc (wait_for_sigthread): Ditto. Don't synchronize with - wait_sig after receiving an event that it is ready to go. - (init_sig_pipe): New function. - (wait_sig): Call init_sig_pipe to create pipes for communicating - signals to this process. Don't send sigCONT signal when initializing. - * fork.cc (frok::child): Accommodate wait_for_sigpipe parameter change. - -2009-07-24 Christopher Faylor - - * fhandler.h (fhandler_*::write): Make ssize_t/__stdcall. - (fhandler_*::write_overlapped): Ditto. - (fhandler_*::raw_write): Ditto. - (fhandler_*::readv): Ditto. - (fhandler_*::writev): Ditto. - (fhandler_*::raw_read): Make __stdcall. - * fhandler: Accommodate changes to read/write functions throughout. - * fhandler_clipboard.cc: Ditto. - * fhandler_console.cc: Ditto. - * fhandler_dsp.cc: Ditto. - * fhandler_fifo.cc: Ditto. - * fhandler_mailslot.cc: Ditto. - * fhandler_mem.cc: Ditto. - * fhandler_mem.cc: Ditto. - * fhandler_random.cc: Ditto. - * fhandler_tape.cc: Ditto. - * fhandler_tty.cc: Ditto. - * fhandler_virtual.cc: Ditto. - * fhandler_windows.cc: Ditto. - * fhandler_zero.cc: Ditto. - * syscalls.cc (readv): Use ssize_t as temp variable. - - * fhandler.cc (fhandler_base::read): Coerce returned len to signed or - it will never be treated as < 0. - (fhandler_base::wait_overlapped): Minimize calls to GetLastError. - Remove duplicate debugging test. Fix error return. - - * fhandler.h (fhandler_fifo::fifo_name): Declare new function. - (fhandler_fifo::close): Ditto. - (fhandler_fifo::dup): Ditto. - (fhandler_fifo::close_on_exec): Ditto. - * fhandler.cc (fhandler_fifo::fifo_name): Define new function. - (FIFO_BUF_SIZE): New define. - (cnp): Ditto. - (fhandler_fifo::open): Rework. Use cnp to open named pipe. Always - open write side as a client. Open dummy client when writing and can't - connect. - (wait): Rework. Implement fifo_wait_for_next_client. Handle signals - during connect better. Add new fifo_wait_for_server code which polls - (sigh) waiting for server. - (fhandler_fifo::raw_read): Handle transition states when one client - closes and another is available. - (fhandler_fifo::close): Define. - (fhandler_fifo::dup): Ditto. - (fhandler_fifo::close_on_exec): Ditto. - -2009-07-24 Corinna Vinschen - - * syscalls.cc (internal_setlocale): Fix typo in GBK codepage. - -2009-07-24 Corinna Vinschen - - * syscalls.cc (unlink_nt): Ignore sharing violation on NFS. Align - comments. - -2009-07-23 Corinna Vinschen - - * mount.h (fs_info::fsn): New member. - (fs_info::clear): Clear fsn. - (fs_info::fsname): New read accessor for fsn. - * mount.cc (fs_info::update): Fill in fsn member with lowercased - filesystem name if filesystem is not well-known. Fall back to - "unknown" if filesystem name is missing. - (fillout_mntent): Print filesystem name retrieved in fs_info::update - rather than static string "unknown". - -2009-07-23 Corinna Vinschen - - * mount.cc (fs_info::update): Revert to open filesystem with access set - to READ_CONTROL. If that fails, try additionally with FILE_READ_DATA. - -2009-07-22 Eric Blake - - * exceptions.cc (handle_exceptions): Set si_addr according to - POSIX for SIGSEGV. - -2009-07-22 Corinna Vinschen - - * mount.cc (fs_info::update): Open filesystem with access set to 0. - Explain why. - -2009-07-22 Corinna Vinschen - - * mount.cc: Revert accidental checkin. - -2009-07-22 Corinna Vinschen - - * path.cc (symlink_info::check): Handle STATUS_NOT_SUPPORTED from - NtCreateFile just like STATUS_EAS_NOT_SUPPORTED. - -2009-07-22 Corinna Vinschen - - * mount.cc (fillout_mntent): Fix typo (noexec -> notexec). - -2009-07-22 Corinna Vinschen - - * path.cc (symlink_info::check): Fix typo in comment. - -2009-07-22 Corinna Vinschen - - * fhandler.h (enum del_lock_called_from): New enumeration. - (fhandler_base::del_my_locks): Declare taking a del_lock_called_from - as argument. - * fhandler.cc (fhandler_base::close): Call del_my_locks with "on_close". - (fhandler_base::fixup_after_fork): Call del_my_locks with "after_fork". - (fhandler_base::fixup_after_exec): Call del_my_locks with "after_exec". - * flock.cc (fhandler_base::del_my_locks): Take del_lock_called_from - as argument. Call node->del_my_locks with NULL handle in after_exec - case. Explain why. - -2009-07-21 Eric Blake - - * dtable.cc (dup2): Correct return value for no-op. - -2009-07-21 Corinna Vinschen - Eric Blake - - * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Add special case - for MVFS. Explain why. - (fhandler_disk_file::utimens): Drop local variables lastaccess and - lastwrite. Copy timestamps right into FILE_BASIC_INFORMATION structure - to avoid copying them twice. - -2009-07-20 Corinna Vinschen - - * wincap.h (wincaps::has_always_all_codepages): New element. - * wincap.cc: Implement above element throughout. - * wchar.h (__sjis_mbtowc): Declare. - (__eucjp_mbtowc): Ditto. - (__gbk_mbtowc): Ditto. - (__kr_mbtowc): Ditto. - (__big5_mbtowc): Ditto. - * syscalls.cc (internal_setlocale): Convert to char * function. - Return parameter by default. Return NULL if request to use a - charset can't be satisfied due to missing codepage support in the - underlying OS. Fix comment. - (setlocale): Store original locale. Restore to original locale if - internal_setlocale returns NULL. - -2009-07-20 Corinna Vinschen - - * fork.cc (fork): Create local tmp_pathbuf. Explain why. - -2009-07-18 Christopher Faylor - - * exceptions.cc (sig_handle_tty_stop): Set stopsig to SIGCONT when - continuing. - (stopped_or_terminated): Honor WCONTINUED. - * wait.cc (wait4): Ditto. - * include/cygwin/wait.h (WCONTINUED): Define. - (__W_CONTINUED): Ditto. - (WIFCONTINUED): Ditto. - -2009-07-18 Dave Korn - - * libstdcxx_wrapper.cc (operator delete): Remove stray space in - asm name. - -2009-07-17 Christopher Faylor - - * cygtls.cc (_cygtls::init_exception_handler): Test for e, not e->prev - or we could still end up adding our handler twice. Add comment - explaining what we're doing. - * dll_init.cc (dll_dllcrt0_1): Clarify comment. - -2009-07-17 Christopher Faylor - - * cygtls.cc (_cygtls::init_exception_handler): Avoid adding our - exception handler twice. - -2009-07-17 Corinna Vinschen - - * syscalls.cc (unlink_nt): Just return when a sharing violation - occurs on remote filesystems. - -2009-07-17 Corinna Vinschen - - * globals.cc: Improve comment on R/O UNICODE_STRINGs. - * mount.h (class fs_info): Add is_mvfs bit. - * mount.cc (fs_info::update): Recognize MVFS remote filesystem. - (fillout_mntent): Reorder filesystem checks for speed. Add - mvfs, unixfs, and sunwnfs filesystem types. - * path.h (class path_conv): Add fs_is_mvfs method. - * path.cc (symlink_worker): On MVFS, always create symlinks as - Windows shortcuts. Explain why. - -2009-07-16 Corinna Vinschen - - * syscalls.cc (unlink_nt): First remove the R/O DOS attribute with - FILE_WRITE_ATTRIBUTES access only, then re-open the file for DELETE. - Explain why. - -2009-07-16 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Remove file - attribute check already done in NtSetAttributesFile. - -2009-07-15 Corinna Vinschen - - * globals.cc: Reorder constant UNICODE_STRINGs for clarity. - * mount.h (fs_info::sttaus): Move filesystem type flags into - substructure. Add union to allow simple test for having set any - one filesystem type flag. Replace has_buggy_open flag with is_sunwnfs - flag. Replace has_buggy_fileid_dirinfo with is_unixfs flag. - (fs_info::got_fs): New private method. - (fs_info::has_buggy_open): New explicit implementation. - (fs_info::has_buggy_fileid_dirinfo): Ditto. - * mount.cc (fs_info::update): Optimize filesystem checks for speed. - * winsup.h (IMPLEMENT_STATUS_FLAG): Change write accessor to return - value just set. - -2009-07-15 Corinna Vinschen - - * fhandler_netdrive.cc (GET_RESOURCE_INFO): Remove. - (thread_netdrive): Drop GET_RESOURCE_INFO case. - (fhandler_netdrive::exists): Use GET_RESOURCE_OPENENUM info class - to check for existance. - -2009-07-15 Corinna Vinschen - - * fhandler_netdrive.cc (fhandler_netdrive::readdir): Remove useless - alloca. - -2009-07-15 Corinna Vinschen - - * path.cc (cwdstuff::set): Only fix up UNC path in win32 so as not - to overwrite incoming path. - -2009-07-14 Corinna Vinschen - - Throughout avoid having to initialize constant UNICODE_STRINGs. - * globals.cc: Define constant UNICODE_STRINGs and store in .rdata - section. - * fhandler_disk_file.cc: Throughout, use readonly UNICODE_STRINGs - rather then initializing local UNICODE_STRING variable where - applicable. - * fhandler_mem.cc (fhandler_dev_mem::open): Ditto. - * flock.cc (inode_t::inode_t): Ditto. - * mmap.cc: Ditto. - * syscalls.cc: Ditto. - * mount.cc (fs_info::update): Ditto. - * path.cc: Ditto. - - * ntdll.h (RtlEqualUnicodePathPrefix): Redefine to take prefix as - UNICODE_STRING. - (RtlEqualUnicodePathSuffix): Redefine to take suffix as UNICODE_STRING. - * fhandler_disk_file.cc: Accommodate throughout. - * mount.cc (fs_info::update): Ditto. - * path.cc (cwdstuff::set): Ditto. - * syscalls.cc: Ditto. - -2009-07-14 Corinna Vinschen - - * globals.cc (active_codepage): Remove. - -2009-07-12 Christopher Faylor - - * how-spawn-works.txt: Add "out of date" note. - * how-vfork-works.txt: Ditto. - -2009-07-12 Christopher Faylor - - * Makefile.in: Don't do anything special with any RCS directories. - - * ntdll.h (PROCESSINFOCLASS): Remove unneeded trailing comma. - - * pinfo.cc (_pinfo::dup_proc_pipe): Remove unneeded assignment. - - * sigproc.cc (sig_send): Don't send signal to myself if this is an exec - stub. - -2009-07-12 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Don't use - FileAllInformation info class since it needs a big buffer. Add a - comment. - -2009-07-07 Dave Korn - - * winbase.h (ilockexch): Avoid making 'ret' volatile. - (ilockcmpexch): Likewise. - -2009-07-07 Dave Korn - - * Makefile.in (DLL_OFILES): Add libstdcxx_wrapper.o - (libstdcxx_wrapper_CFLAGS): Add flags for new module. - (_cygwin_crt0_common_STDINCFLAGS): Define per-file override. - (libstdcxx_wrapper_STDINCFLAGS, cxx_STDINCFLAGS): Likewise. - * cxx.cc: Include "cygwin-cxx.h". - (operator new): Tweak prototype for full standards compliance. - (operator new[]): Likewise. - (operator new (nothrow)): New fallback function. - (operator new[] (nothrow), operator delete (nothrow), - operator delete[] (nothrow)): Likewise. - (default_cygwin_cxx_malloc): New struct of pointers to the above, - for final last-resort fallback default. - * cygwin-cxx.h: New file. - (struct per_process_cxx_malloc): Define. - (default_cygwin_cxx_malloc): Declare extern. - * cygwin.din (__wrap__ZdaPv): Export new wrapper. - (__wrap__ZdaPvRKSt9nothrow_t, __wrap__ZdlPv, - __wrap__ZdlPvRKSt9nothrow_t, __wrap__Znaj, - __wrap__ZnajRKSt9nothrow_t, __wrap__Znwj, - __wrap__ZnwjRKSt9nothrow_t): Likewise. - * globals.cc (__cygwin_user_data): Init newly-repurposed 'forkee' - field (now 'cxx_malloc') to point to default_cygwin_cxx_malloc. - * libstdcxx_wrapper.cc: New file. - (__wrap__ZdaPv, __wrap__ZdaPvRKSt9nothrow_t, __wrap__ZdlPv, - __wrap__ZdlPvRKSt9nothrow_t, __wrap__Znaj, - __wrap__ZnajRKSt9nothrow_t, __wrap__Znwj, - __wrap__ZnwjRKSt9nothrow_t): Define wrapper functions for libstdc++ - malloc operators and their overrides. - * winsup.h (default_cygwin_cxx_malloc): Declare extern. - * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. - * include/sys/cygwin.h (struct per_process_cxx_malloc): Forward - declare here. - (struct per_process::forkee): Rename and repurpose from this ... - (struct per_process::cxx_malloc): ... to this. - * lib/_cygwin_crt0_common.cc: Include cygwin-cxx.h. - (WEAK): Define shorthand helper macro. - (__cygwin_cxx_malloc): Define and populate with weak references - to whatever libstdc++ malloc operators will be visible at final - link time for Cygwin apps and dlls. - (_cygwin_crt0_common): Always look up cygwin DLL's internal - per_process data, and don't test for (impossible) failure. Inherit - any members of __cygwin_cxx_malloc that we don't have overrides - for from the DLL's default and store the resulting overall set of - overrides back into the DLL's global per_process data. - -2009-07-07 Corinna Vinschen - - * cygtls.cc (_cygtls::remove): Fix typo. - -2009-07-06 Christopher Faylor - - * Makefile.in (clean): Clean generated files in srcdir. - * tlsoffsets.h: Regenerate. - -2009-07-06 Christopher Faylor - - * cygtls.cc (_cygtls::remove): Avoid closing a NULL handle. - -2009-07-06 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::recv_internal): Convert wsabuf - and wsacnt to references. Fix handling of WSAEMSGSIZE. - -2009-07-06 Corinna Vinschen - - * cygtls.h (struct _local_storage): Add thread storage pointers for - memory used by socket select functions. Combine them into a single - struct select. - * cygtls.cc: Accommodate above change throughout. - (_cygtls::init_thread): Drop initalizing of sockevt to - INVALID_HANDLE_VALUE. - (_cygtls::fixup_after_fork): Reset sockevt to NULL. - (_cygtls::remove): Don't use sockevt value to bail out prematurely. - Set sockevt to NULL. Free malloced select members. - * select.h (struct select_socket_info): Drop max_w4 member. - * select.cc (thread_socket): Use INFINITE timeout value if number of - objects to wait for is <= MAXIMUM_WAIT_OBJECTS. Use num_w4 member - of select_socket_info struct rather than dropped max_w4. - (init_tls_select_info): New inline function to initialize TLS select - members. - (start_thread_socket): Just call init_tls_select_info to initialize TLS - select members and use them later on. - (socket_cleanup): Don't free select_socket_info pointer members since - they are thread local now. - -2009-07-06 Christopher Faylor - - * dtable.cc (handle_to_fn): Detect failing NtQueryObject. - -2009-07-06 Corinna Vinschen - - * autoload.cc: Delete stray CR. - -2009-07-05 Christopher Faylor - - * fhandler_console.cc: Change workstation -> windows station - throughout. - -2009-07-04 Christopher Faylor - - * autoload.cc (SetParent): Add new import. - * fhandler.h (fhandler_console::create_invisible_console): Declare new - function. - (create_invisible_console_workaround): Ditto. - * fhandler_console.cc (fhandler_console::create_invisible_console): - Define new function. - (create_invisible_console_workaround): Ditto. Add too much code to - deal with broken Windows 7. Use a helper app to start an invisible - console window. - (fhandler_console::need_invisible): Reorganize to use helper functions - to create invisible console. - - * spawn.cc (spawn_guts): Avoid zeroing already zeroed fields in si. - -2009-07-04 Dave Korn - - * autoload.cc (AttachConsole): Correct size of args. - -2009-07-03 Christopher Faylor - - * dcrt0.cc (jit_debug): New global. - (initial_env): Set jit_debug when we are automatically starting a gdb - process. - * dtable.cc (dtable::get_debugger_info): Don't tty tricks when we are - being debugged by our own captive gdb, as determined by jit_debug == - true. - (dtable::init_std_file_from_handle): Detect errors when initializing a - tty early rather than at random points later. - * fhandler.h (fhandler_*::init): Return int to indicate - success/failure. - * fhandler.cc (fhandler_base::init): Reflect change in return value. - * pipe.cc (fhandler_pipe::init): Ditto. - (fhandler_pipe::create_selectable): Don't say we're retrying when we - aren't. - * fhandler_console.cc (fhandler_console::init): Ditto. Return - success/failure. - * fhandler_serial.cc (fhandler_serial::init): Ditto. - * fhandler_tty.cc (fhandler_tty_slave::init): Ditto. - (fhandler_tty_slave::open): Make debugging output more detailed. - * tty.cc (tty_list::terminate): Don't close I/O handles before all - slaves have checked in. - (tty::slave_alive): Make a non-inlined function. Check if tty pipe - handles can be created as an additional exists check. - * tty.h (tty::slave_alive): Just define here. - -2009-07-03 Corinna Vinschen - - * posix.sgml: Add fpurge and mkstemps to BSD list. - -2009-07-03 Eric Blake - - * cygwin.din (fpurge, mkstemps): New exports. - * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. - * mktemp.cc (_gettemp): Add parameter. - (mkstemps): New function. - (mkstemp, mkdtemp, mktemp): Adjust clients. - -2009-07-03 Corinna Vinschen - - * autoload.cc: Fix typo in comment. - (ShowWindowAsync): Define. - (AttachConsole): Define. - * fhandler_console.cc (fhandler_console::need_invisible): Add band-aid - for Windows 7 AllocConsole bug. - -2009-07-01 Corinna Vinschen - - * net.cc (get_xp_ifs): Fix typo in comment. - -2009-07-01 Corinna Vinschen - - * fhandler.h (class fhandler_socket): Add class members and methods - to store and retrieve the SO_RCVBUF and SO_SNDBUF sizes. - * fhandler_socket.cc (fhandler_socket::dup): Duplicate new members. - (fhandler_socket::send_internal): Check for SO_SNDBUF size and - restrict send to 1 byte less per KB 823764. Leave loop immediately - if WSASendMsg has been used. - * net.cc (fdsock): Change comment again. Set buffer sizes to 65536. - Store values in fhandler_socket. - (cygwin_setsockopt): Store SO_RCVBUF and SO_SNDBUF sizes in - fhandler_socket. - (cygwin_sendto): Drop call to sig_dispatch_pending. - (cygwin_recvfrom): Ditto. - (cygwin_recvmsg): Ditto. - (cygwin_sendmsg): Ditto. - -2009-06-30 Christopher Faylor - - * select.h: New file split from fhandler.h. - (select_record::select_record): Define do-nothing constructor for "new" - to avoid gratuitous zeroing. - (select_info): New base class. - (select_pipe_info): New class with methods for dealing with pipes. - (select_socket_info): New class with methods for dealing with sockets. - (select_serial_info): Dummy class for serial. - (select_mailslot_info): Dummy class for mailslots. - (select_stuff): Define device_specific_* as actual classes rather than - void *. - * dtable.h (dtable::select_read): Accommodate return value change to - 'bool' and argument change to "select_stuff". - (dtable::select_write): Ditto. - (dtable::select_except): Ditto. - * dtable.cc (dtable::select_read): Accommodate return value change to - 'bool' and argument change to "select_stuff". - (dtable::select_write): Ditto. - (dtable::select_except): Ditto. - * fhandler.h: Excise select-related classes. - (fhandler_*::select_read): Change argument to select_stuff. - (fhandler_*::select_write): Ditto. - (fhandler_*::select_except): Ditto. - * select.cc (UNIX_FD_ZERO): Use memset rather than bzero. - (select_stuff::test_and_set): Change return type to bool. Allocate - select_record on entry and let fhandler_*::select_* operate on the - start.next field of select_stuff. - (pipeinf): Delete. - (select_pipe_info::select_pipe_info): New constructor. Allocates event - for controlling pipe waits. - (select_pipe_info::~select_pipe_info): New destructor. Destroy event. - Stop thread. - (select_pipe_info::add_watch_handle): New function. - (thread_pipe): Wait for the hEvent part of any overlapped pipes before - peeking. - (start_thread_pipe): Don't allocate device_specific_pipe stuff here. - Assume that it has been allocated earlier. - (pipe_cleanup): Rely on select_pipe_info destructor to clean up pipe - paraphenalia. - (fhandler_*::select_*): Derive select_record from new select_stuff - argument. - (fhandler_pipe::select_*): Ditto. Allocate pipe-specific field if not - already allocated. - (serialinf): Delete. - (thread_serial): serialinf -> select_serial_info. - (fhandler_base::ready_for_read): Rewrite to accommodate change in - argument to fhandler_*::select_*. - (socketinf): Delete. - (thread_socket): socketinf -> select_socket_info. - (mailslotinf): Delete. - (thread_mailslot): mailslotinf -> select_mailslot_info. - -2009-06-30 Christopher Faylor - - * fhandler.cc (fhandler_base::has_ongoing_io): Accept an argument - indicating whether the overlapped event should be tested. - (fhandler_base::read_overlapped): Pass is_overlapped state to - has_ongoing_io. - (fhandler_base::write_overlapped): Ditto. - * fhandler.h (fhandler_base::has_ongoing_io): Accommodate argument - change. - * select.cc (peek_pipe): Ditto. - -2009-06-30 Corinna Vinschen - - * net.cc (fdsock): Set default socket buffer sizes to 65520. Change - comment accordingly. - * fhandler_socket.cc (fhandler_socket::send_internal): Set maximum - send size to 65520 as well. - -2009-06-29 Christopher Faylor - - * select.cc (peek_pipe): Turn on (temporarily?) the experimental code - which tries to determine when a pipe is writable. - -2009-06-28 Christopher Faylor - - * select.cc (peek_pipe): Use has_ongoing_io() to determine if the pipe - is ready for writing rather than performing brute-force checks. - -2009-06-28 Christopher Faylor - - * fhandler.h (fhandler_base::has_ongoing_io): Declare new function. - * fhandler.cc (fhandler_base::has_ongoing_io): Define new function. - (fhandler_base::read_overlapped): Use has_ongoing_io to avoid writing - when handle has not completed last I/O. - (fhandler_base::write_overlapped): Ditto. - * select.cc (peek_pipe): Be more careful about accessing hEvent field - from get_overlapped(). - -2009-06-28 Christopher Faylor - - * gendef (cleanup): Rename from 'nocr'. Remove comments and trailing - spaces. - * cygwin.din: Add long-needed comment describing what - dll_crt0__FP11per_process demangles to. - - * select.cc (peek_pipe): Flag handle as not ready for write if event is - not signalled. - * fhandler.cc (fhandler_base::setup_overlapped): Establish event as - already signalled. - (fhandler_base::wait_overlapped): Don't reset event after we've - successfully waited. MSDN documentation says that this happens - automatically after a WriteFileEx/ReadFileEx. - -2009-06-26 Corinna Vinschen - - * wincap.h (wincaps::has_broken_alloc_console): New element. - * wincap.cc: Implement above element throughout. - -2009-06-25 Corinna Vinschen - - * sec_auth.cc (lsaauth): Close unused handle. - (lsaprivkeyauth): Ditto. - -2009-06-23 Corinna Vinschen - - * sec_auth.cc (get_server_groups): Ignore errors from - get_user_local_groups. - -2009-06-22 Corinna Vinschen - - * spawn.cc (spawn_guts): Don't run additional check for Win32 - incompatible CWD if newargv.fixup bailed out already. - (av::fixup): Check shell scripts for executability. - -2009-06-18 Corinna Vinschen - - * path.cc (chdir): Check error conditions first. - -2009-06-17 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::recv_internal): Mark WSARecvMsg - as NO_COPY. - -2009-06-16 Christopher Faylor - - * fhandler.cc (fhandler_base::read_overlapped): Use a better variable - name. - -2009-06-16 Christopher Faylor - - * fhandler.cc (fhandler_base::read_overlapped): Preserve len when - looping due to received signal. - -2009-06-15 Corinna Vinschen - - * net.cc (get_flags): New static function to generate interface flags - value. - (get_ipv4fromreg_ipcnt): New static function to fetch number of - configured IPv4 addresses for a given NIC from registry. - (get_ipv4fromreg): New static function to fetch configured IPv4 - addresses for a given NIC from registry. - (get_friendlyname): New static function to generate friendly name. - (get_hwaddr): New static function to copy hardware address. - (get_xp_ifs): Restructure slightly. Add code to generate IPv4 entries - entries for interfaces which are disconnected. - -2009-06-14 Christopher Faylor - - * errno.cc (errmap): Add mapping for ERROR_IO_INCOMPLETE. - * fhandler.cc (fhandler_base::fcntl): Fix comment. - (fhandler_base::wait_overlapped): Accept an optional len parameter. - Use the len parameter when WriteFile fails with ERROR_IO_PENDING. Make - debug output less alarming. - (fhandler_base::write_overlapped): Pass len to wait_overlapped. - * fhandler.h (fhandler_base::wait_overlapped): Add an optional argument - denoting the number of characters intended to be written. - - * fhandler_tty.cc (fhandler_pty_master::close): Don't close archetype - handles when cygwin is still initializing since the handles aren't - actually opened at that point. - -2009-06-14 Corinna Vinschen - - * localtime.cc (time2): Take another stab at fixing a compiler warning. - -2009-06-14 Christopher Faylor - - * localtime.cc (time2): Take a stab at fixing a compiler warning. - -2009-06-14 Christopher Faylor - - * fhandler.cc (fhandler_base::wait_overlapped): Honor nonblocking flag - for writes. Don't reset event handle when we see a ERROR_IO_PENDING. - - * sigproc.cc (stopped_or_terminated): Use bool constants for - consistency. - - * wait.cc (wait4): Remove nonsensical comment. - -2009-06-13 Corinna Vinschen - - * fhandler_socket.cc (fhandler_socket::recv_internal): Set namelen - pointer to NULL if name pointer is NULL. Explain why. - -2009-06-12 Corinna Vinschen - - * localtime.cc (time2): Change "spring gap" to "spring forward gap" - in comment. - -2009-06-12 Corinna Vinschen - - * localtime.cc (time2): Add workaround for spring forward gap problem. - Add explaining comment. - -2009-06-12 Corinna Vinschen - - * Makefile.in (SUBLIBS): Add librt.a. - (librt.a): New rule to build librt.a. - -2009-06-12 Corinna Vinschen - - * posix_ipc.cc (check_path): Fix typo in comment. Align naming - convention rules to Linux. Handle backslash same as slash. Add - comment. - -2009-06-09 Corinna Vinschen - - * autoload.cc (GetSystemTimes): Remove. - * fhandler_proc.cc (format_proc_uptime): Use global system_info rather - than retrieving a local copy of the SYSTEM_INFO. Drop call to - GetSystemTimes and retrieve SystemPerformanceInformation on all systems - again with buffer size big enough for 64 bit systems. - (format_proc_stat): Use global system_info rather than retrieving a - local copy of the SYSTEM_INFO. Retrieve SystemPerformanceInformation - with buffer size big enough for 64 bit systems. - -2009-06-08 Corinna Vinschen - - * autoload.cc (GetSystemTimes): Define. - * fhandler_proc.cc (format_proc_uptime): Use GetSystemInfo to retrieve - processor count. Use GetSystemTimes when available to retrieve system - idle time. Improve debug output. - (format_proc_stat): Use GetSystemInfo to retrieve processor - count. Improve debug output. Ignore if SystemPerformanceInformation - returns error. Explain why. - -2009-06-08 Corinna Vinschen - - * fork.cc (frok::parent): Remove ancient code erroneously flushing - stdout. - -2009-06-08 Corinna Vinschen - - * cygerrno.h (save_errno::~save_errno): Set errno directly to avoid - flooding debug output. - -2009-06-08 Corinna Vinschen - - * path.cc (symlink_info::check): Return with error set to ENOENT if - STATUS_NO_MEDIA_IN_DEVICE is returned. - -2009-06-07 Christopher Faylor - - * cygheap.h (mini_cygheap): New struct. - (init_cygheap): Inherit locale field via mini_cygheap. - * cygheap.cc (cygheap_at_start): Define new variable. - (cygheap): Initialize as cygheap_at_start so that locale information is - always available. - (cygheap_init): Initialize cygheap iff it is set to cygheap_at_start. - * shared_info.h (memory_init): Accommodate argument change. - * memory.cc (memory_init): Accept an argument indicating whether - cygheap should be initialized or not. - * dcrt0.cc (child_info_fork::handle_fork): Pass false to memory_init(). - (child_info_spawn::handle_spawn): Ditto. - (dll_crt0_0): Pass true to memory_init when not forking or execing. - - * cygheap.h (cygheap_types::HEAP_2_DLL): New enum. - * dll_init.h (dll): Remove unused namelen field. - (dll_list::load_after_fork): Accommodate change in arguments. - * dll_init.cc (dll_list::alloc): Allocate dll information in the cygwin - heap. - (dll_list::detach): Free dll information from the cygwin heap. - (dll_list::load_after_fork): Use dll information in the cygwin heap - directly rather than querying parent. - * fork.cc (frok::first_dll): Delete. - (frok::child): Don't report on first_dll. Don't pass it to - load_on_fork. - (frok::parent): Don't set first_dll. - (fork): Ditto. - -2009-06-06 Corinna Vinschen - - * dll_init.cc (dll_list::alloc): Allocate memory using a section - object. Explain why. Drop call to GetSystemInfo, rather call - getpagesize to get allocation granularity. Only align to allocation - granularity under WOW64. Use roundup2 to align. - (dll_list::detach): Call NtUnmapViewOfSection instead of VirtualFree. - -2009-06-06 Corinna Vinschen - - * mmap.cc: Use NtUnmapViewOfSection instead of UnmapViewOfFile - throughout for symmetry. - (fhandler_dev_mem::munmap): Use correct process handle in call to - NtUnmapViewOfSection. - -2009-06-06 Corinna Vinschen - - * dll_init.h (struct dll): Set size of name element to ANYSIZE_ARRAY. - * dll_init.cc: Fix formatting. - (dll_list::alloc): Only allocate as much memory for struct dll as - necessary for given DLL name. - (dll_list::load_after_fork): Only read a single page of parent memory. - Only read more if namelen indicates that it's necessary. - -2009-06-05 Dave Korn - - * winbase.h (ilockexch): Fix asm constraints. - (ilockcmpexch): Likewise. - -2009-06-05 Corinna Vinschen - - * heap.cc (heap_init): Fix typo in comment. - -2009-06-04 Corinna Vinschen - - * fhandler_clipboard.cc: Avoid calling system_printf. - (set_clipboard): Add basic error checking. Set errno here. Per MSDN, - don't call GlobalFree on data block transferred to clipboard. - (fhandler_dev_clipboard::write): Drop setting errno after call to - set_clipboard. - (fhandler_dev_clipboard::read): Add basic error checking. Simplify code. - -2009-06-04 Corinna Vinschen - - * fhandler_console.cc (set_console_title): Convert title string to - wchar_t and call SetConsoleTitleW. - -2009-06-04 Corinna Vinschen - - * fhandler_console.cc (fhandler_console::read): Allow Ctrl-Space to - emit a NUL byte. - -2009-06-04 Dave Korn - - * thread.cc (__cygwin_lock_lock): Delete racy optimisation. - (__cygwin_lock_unlock): Likewise. - -2009-06-03 IWAMURO Motnori - - * strfuncs.cc (sys_cp_mbstowcs): Fix condition. - -2009-06-03 Corinna Vinschen - - * strfuncs.cc (sys_cp_wcstombs): Implement reverse functionality - of the change to sys_cp_mbstowcs from 2009-05-30. - (sys_cp_mbstowcs): Slightly reformat. Fix comment to accommodate - change to sys_cp_wcstombs. Don't write to *ptr if dst is NULL. - -2009-06-03 Corinna Vinschen - - * fhandler_console.cc (fhandler_console::read): Convert Alt-Backspace - to \033\177 or to \377 dependent on the setting of dev_state->metabit. - -2009-06-02 Corinna Vinschen - - * path.cc (path_conv::check): Don't call set_exec for files on "noacl" - mount points. - -2009-05-30 Christopher Faylor - - * strfuncs.cc (sys_cp_mbstowcs): Treat src as unsigned char *. Convert - failure of f_mbtowc into a single malformed utf-16 value. - -2009-05-30 Christopher Faylor - - * cygwin/include/sys/termios.h: Make default erase character "^?". - -2009-05-30 Christopher Faylor - - * fhandler_console.cc (fhandler_console::read): Convert backspace key - to DEL. - -2009-05-29 Christopher Faylor - - * path.cc (cwdstuff::set): Rewrite previous change to properly test the - end of the buffer. - -2009-05-28 Christopher Faylor - - * path.cc (cwdstuff::set): Avoid removing a nonexistent trailing slash. - -2009-05-20 Eric Blake - - * net.cc (gethostby_helper): Use correct signedness. - -2009-05-18 Christopher Faylor - - * mount.cc (mount_info::add_item): Avoid using any-old '/' as - indicating root. - -2009-05-18 Christopher Faylor - - * mount.cc (mount_info::got_usr_bin): Mark as NO_COPY. - (mount_info::got_usr_lib): Ditto. - (mount_info::root_idx): Ditto. - -2009-05-14 Corinna Vinschen - - * wchar.h (sys_mbstowcs): Add missing __stdcall attribute. - -2009-05-14 Corinna Vinschen - - * cygheap.cc (cygheap_init): Set Cygwin default locale values. - * cygheap.h (struct cygheap_locale): New structure. - (struct user_heap_info): Add cygheap_locale member locale. - * dcrt0.cc (dll_crt0_1): Revert to calling _setlocale_r so that only - the applications locale is reverted to "C". - * environ.cc (environ_init): Remove unused got_lc variable. - * fhandler.h (class dev_console): Remove now unsed locale variables. - * fhandler_console.cc (fhandler_console::get_tty_stuff): Remove - setting dev_console's locale members. - (dev_console::con_to_str): Use internal locale settings. Default to - __ascii_wctomb if charset is "ASCII". - (fhandler_console::write_normal): Ditto. - * strfuncs.cc (__ascii_wctomb): Drop declaration. - (__db_wctomb): Use fixed value 2 instead of not - necessarily matching MB_CUR_MAX. - (__eucjp_wctomb): Use 3 instead of MB_CUR_MAX. - (sys_cp_wcstombs): Remove special case for "C" locale. - (sys_wcstombs): Implement here. Use internal locale data stored on - cygheap. - (sys_cp_mbstowcs): Remove special case for "C" locale. - (sys_mbstowcs): Implement here. Use internal locale data stored on - cygheap. - * syscalls.cc (internal_setlocale): New function to set cygheap locale - data and to reset CWD posix path. - (setlocale): Just call internal_setlocale from here if necessary. - * wchar.h (__ascii_wctomb): Declare. - (sys_wcstombs): Don't define inline, just declare. - (sys_mbstowcs): Ditto. - -2009-05-14 Christopher Faylor - - * mount.cc (mount_info::init): Remove MOUNT_CYGWIN_EXEC setting when - auto-mounting /usr/bin. - -2009-05-14 Corinna Vinschen - - * mount.cc (oopts): Add a no-op "auto" option. - (mount_info::create_root_entry): Set root dir to MOUNT_IMMUTABLE rather - than to MOUNT_OVERRIDE. - -2009-05-13 Corinna Vinschen - Christopher Faylor - - * mount.cc (mount_info::got_usr_bin): Define. - (mount_info::got_usr_lib): Ditto. - (mount_info::root_idx): Ditto. - (mount_info::create_root_entry): Create root entry as immutable and - flag as automatic. - (mount_info::init): Remove "Huh? No /etc/fstab..." warning. - Unconditionally call from_fstab for user and system tables. Fill in - /usr/bin and /usr/lib if they have not been specified in /etc/fstab. - (oopts): Alphabetize. Add "override" option to allow overriding - immutable mount points. - (mount_info::add_item): Accommodate new MOUNT_IMMUTABLE flag intended - for root mount. - (mount_info::add_item): Detect "/usr/bin", "/usr/lib", and "/" and set - appropriate global state. - (fillout_mntent): Add ,auto to mount points added by Cygwin DLL. - (mount): Remove masking of MOUNT_SYSTEM. Allow user to shoot - themselves. Add comment. - * mount.h (mount_info::got_usr_bin): Declare. - (mount_info::got_usr_lib): Ditto. - (mount_info::root_idx): Ditto. - * include/sys/mount.h: Reformat enum. - Add MOUNT_{OVERRIDE,IMMUTABLE,AUTOMATIC}. - -2009-05-13 Corinna Vinschen - - * cygheap.h (cwdstuff): Convert to class. Make posix and dir private. - (cwdstuff::get_posix): New method. - (cwdstuff::reset_posix): New method. - * dcrt0.cc (dll_crt0_1): Call setlocale rather than _setlocale_r. - * environ.cc (environ_init): Ditto. Prefer "C" locale over current - codepage default locale. - * path.cc (chdir): Use cwdstuff::get_posix method instead of accessing - cwdstuff::posix directly. - (cwdstuff::set): Defer creating posix path to first usage. - (cwdstuff::get_posix): Create posix path if it's empty, and return it. - (cwdstuff::get): Create posix path if it's empty. - * strfuncs.cc (sys_cp_wcstombs): Use UTF-8 conversion in the "C" - locale. - (sys_cp_mbstowcs): Ditto. - * syscalls.cc (gen_full_path_at): Fetch CWD posix path locked. - (setlocale): Implement here. Reset CWD posix path. - -2009-05-09 Christopher Faylor - - * cygwin/version.h (CYGWIN_VERSION_CYGWIN_CONV): New define. - -2009-05-09 Corinna Vinschen - - * dtable.cc (dtable::init_std_file_from_handle): Add workaround for - Windows 7 64 bit issue. Add lengthy comment to explain what happens. - * wincap.h (wincaps::has_console_handle_problem): New element. - * wincap.cc: Implement above element throughout. - (wincap_7): New wincaps structure for NT 6.1 kernels. - (wincapc::init): Set has_console_handle_problem to false for 32 bit - systems. - -2009-05-09 Corinna Vinschen - - * sec_auth.cc (str2uni_cat): Move from here... - * path.cc (str2uni_cat): ...to here. Simplify. Make static inline. - (get_nt_native_path): Use RtlAppendUnicodeToString rather than - str2uni_cat for constant strings for speed. - * security.h (str2uni_cat): Drop declaration. - -2009-05-08 Corinna Vinschen - IWAMURO Motonori - - * strfuncs.cc (sys_cp_wcstombs): save and restore previous errno value. - (sys_cp_mbstowcs): Ditto. - -2009-05-08 IWAMURO Motonori - - * strfuncs.cc (sys_cp_wcstombs): Set errno to 0 before converting - wide char to SO/UTF-8 sequence. - -2009-05-08 Corinna Vinschen - - * include/sys/select.h: Guard definitions with __USE_W32_SOCKETS as - the accompanying fd_set definitions in newlib's sys/types.h. - -2009-05-06 Christopher Faylor - - * fhandler_console.cc (fhandler_console::ioctl): Properly treat - TIOCLINUX argument as a char. - * fhandler_tty.cc (fhandler_tty_slave::ioctl): Use coercion to properly - set char value. - -2009-05-06 Corinna Vinschen - - * libc/minires.c (scanline): Fix type in calls to ctype functions - to stay in unsigned char range for char values >= 0x80. - * regex/regcomp.c: Ditto, throughout. - * regex/regex2.h (ISWORD): Ditto. - -2009-05-06 Corinna Vinschen - - * cygheap.cc (cygheap_init): Set umask to a sane default. - * uinfo.cc (cygheap_user::ontherange): Don't use HOMEDRIVE/HOMEPATH - to set HOME. Default to /home/USERNAME. - -2009-05-03 Corinna Vinschen - - * security.cc (set_file_sd): Drop using FILE_OPEN_FOR_RECOVERY flag in - call to NtOpenFile. - * exceptions.cc (open_stackdumpfile): Ditto in call to NtCreateFile. - * fhandler.cc (fhandler_base::open): Ditto. Simplify setting - create_options. - - * mount.cc (fs_info::update): Recognize offline storage. - (fillout_mntent): Report UDF and offline storage. - * mount.h (class fs_info): Add is_csc_cache status flag. - -2009-05-04 Christopher Faylor - - * fhandler_console.cc (fhandler_console::write_console): Eliminate - unneeded debugging output. - (fhandler_console::write_normal): Eliminate unneeded __seterrno. - -2009-05-04 Christopher Faylor - - * libc/minires.c (scanline): Accommodate ctype changes which disallow - use of an unadorned char argument to is* macros. - * regex/regcomp.c: Ditto, throughout. - * regex/regex2.h (ISWORD): Ditto. - -2009-05-03 Christopher Faylor - - * fhandler.h (fhandler_console::MAX_WRITE_CHARS): Declare. - (fhandler_console::write_replacement_char): Declare as inline. - (fhandler_console::write_console): Declare new function. - * fhandler_console.cc (fhandler_console::MAX_WRITE_CHARS): Define. - (handler_console::write_console): Define. - (fhandler_console::write_replacement_char): Define as inline. - (fhandler_console::write_normal): Use write_console when writing - buffers of unknown length. - -2009-04-26 Yaakov Selkowitz - - * include/cygwin/socket.h: Define SOL_IPV6. - -2009-04-21 Corinna Vinschen - - * ctype.cc (__set_ctype): Copy exact part of the current active - character class array. - -2009-04-20 Corinna Vinschen - - * flock.cc (lf_setlock): Handle border case which results in WFMO loop - exiting with ret == WAIT_TIMEOUT gracefully. Add a system_printf to - uncover other potential problems with WFMO loop. - -2009-04-18 Christopher Faylor - - * mkimport: Specify .text for stub explicitly. - * speclib: Add a dummy '.idata$7' section referring to the dll - associated with the real import library. - -2009-04-18 Corinna Vinschen - - * dcrt0.cc (globify): Only call mbtowc for non-ascii chars. - -2009-04-17 Corinna Vinschen - - * dcrt0.cc (globify): Make multibyte-aware. - -2009-04-17 Corinna Vinschen - - * flock.cc (class inode_t): Add i_wait member and matching methods - wait(), unwait(), and waiting(). - (inode_t::inode_t): Initialize i_wait to 0. - (fhandler_disk_file::lock): Only remove node if no other thread is - waiting for a blocking lock. - (lf_setlock): Manipulate node->i_wait to signal that a thread is - waiting for a blocking lock in this node. - (lf_findoverlap): Reinstantiate SELF test as in original code. - -2009-04-16 Corinna Vinschen - - * dlfcn.cc (get_full_path_of_dll): Just return a bool value. Drop - local path_conv in favor of getting it as parameter. Add local string - buffer instead of getting it as parameter. - (dlopen): Accommodate get_full_path_of_dll change. Fetch WCHAR Windows - path from path_conv variable and call LoadLibraryW. - -2009-04-16 Corinna Vinschen - - * ntdll.h (STATUS_LOCK_NOT_GRANTED): Define. - * syscalls.cc (unlink_nt): Handle STATUS_LOCK_NOT_GRANTED same as - STATUS_SHARING_VIOLATION. Add lengthy comment to explain why. - -2009-04-15 Corinna Vinschen - - * path.cc (path_conv::get_wide_win32_path): Allow relative paths. - (cygwin_conv_path): In case of CCP_POSIX_TO_WIN_W, convert relative - paths to absolute paths if the relative pathname length exceeds - MAX_PATH. - -2009-04-15 Corinna Vinschen - - * libc/bsdlib.cc: Align copyright with upstream. - * libc/fnmatch.c: Ditto. - * libc/fts.c: Ditto. - * libc/inet_addr.c: Ditto. - * libc/inet_network.c: Ditto. - * libc/rcmd.cc: Ditto. - * libc/rexec.cc: Ditto. - -2009-04-14 Christopher Faylor - - * speclib: Really revert to using tempdir. - -2009-04-14 Christopher Faylor - - * speclib: Revert to using tempdir. - -2009-04-14 Corinna Vinschen - - * localtime.cc (tzload): Implement setting __tzrule's offset member - using newlib's __gettzinfo () interface also when tzload returns - successfully. - -2009-04-13 Dave Korn - - * include/stdint.h (intptr_t): Remove long from type. - (uintptr_t): Likewise. - (INTPTR_MIN): Remove 'L' suffix. - (INTPTR_MAX, UINTPTR_MAX): Likewise. - -2009-04-12 Christopher Faylor - - * speclib: Initial stab at cleaning up temp files. More work needed. - * mkimport: Ditto. - -2009-04-12 Christopher Faylor - - * Makefile.in (clean): Clean globals.h. - (LIBCOS): Depend on globals.h. - -2009-04-11 Christopher Faylor - - * mkimport: New script to perform all operations necessary to create - libcygwin.a. - * rmsym: Delete. - * newsym: Delete. - * Makefile.in (toolopts): New variable which holds options relating to - binutils/gcc tools. - (speclib): Use toolopts. Add symbols to avoid copying to special - libraries. - (OBSOLETE_FUNCTIONS): Delete. - (NEW_FUNCTIONS): Change to represent an argument to new mkimport - script. - (libcygwin.a): Use only new mkimport script to create libcygwin.a. - Only rely on ${LIBCOS}. - (*/lib*.a): Simplify speclib dependencies. - (speclib): Accept toolchain options. Convert every argument to - absolute path. Simplify parsing of nm output. Accommodate new - exclude option. - -2009-04-11 Dave Korn - - * include/stdint.h (INTPTR_MIN, INTPTR_MAX): Add 'L' suffix. - (WINT_MAX): Add 'U' suffix. - -2009-04-10 Christopher Faylor - - * speclib: Use a more robust method to derive full file path. - -2009-04-09 Christopher Faylor - - * speclib: Semi-revert to previous version but don't try to generate - well-formed import library. Instead, just extract appropriate symbols - and let later libcygwin.a on link line fill in the rest of the import - stuff. - * gendef: Hopefully no-op modification to allow easier post-processing - on symbol values. - -2009-04-09 Corinna Vinschen - - * syscalls.cc (try_to_bin): Use tmp_pathbuf buffer to allocate infobuf - rather than using the stack. - -2009-04-09 Corinna Vinschen - - * syscalls.cc (try_to_bin): Fix alignment of infobuf. - -2009-04-09 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::fchown): Catch an - error when changing the user account on a standalone Samba server. - Explain why. - * sec_acl.cc (setacl): Accommodate additional parameter to set_file_sd. - * sec_helper.cc (SECURITY_SAMBA_UNIX_AUTHORITY): Define. - (well_known_samba_unix_user_fake_sid): Define. - * security.cc (set_file_sd): Take additional parameter if ownership - should be changed. Restrict requested permissions accordingly. - (set_file_attribute): Accommodate additional parameter to set_file_sd. - * security.h (well_known_samba_unix_user_fake_sid): Declare. - (set_file_sd): Align declaration to above change. - -2009-04-07 Corinna Vinschen - - * include/stdint.h (int_least32_t): Define as int. - (uint_least32_t): Ditto, unsigned. - (int_fast16_t): Define as int. - (int_fast32_t): Ditto. - (uint_fast16_t): Ditto, unsigned. - (uint_fast32_t): Ditto. - (UINT32_MAX): Remove `L' long marker. - (UINT_LEAST32_MAX): Ditto. - (UINT_FAST16_MAX): Ditto. - (UINT_FAST32_MAX): Ditto. - (INT32_C): Ditto. - (UINT32_C): Ditto. - -2009-04-07 Corinna Vinschen - - * strfuncs.cc: Change WCHAR to wchar_t in multibyte<->widechar - conversion functions throughout. - * wchar.h: Ditto in declarations. Guard them __INSIDE_CYGWIN__. - -2009-04-07 Corinna Vinschen - - * fhandler.h (class dev_console): Add members con_mbtowc, con_wctomb, - and con_charset. - (dev_console::str_to_con): Take mbtowc function pointer and charset - as additional parameters. - * fhandler_console.cc (fhandler_console::get_tty_stuff): Initialize - aforementioned new members. Explain why. - (dev_console::con_to_str): Remove useless comment. Call new - sys_cp_wcstombs function rather than sys_wcstombs. - (dev_console::str_to_con): Take mbtowc function pointer and charset - as additional parameters. Call sys_cp_mbstowcs accordingly. - (fhandler_console::write_normal): Only initialize f_mbtowc and charset - once. Accommodate changed str_to_con. - * strfuncs.cc (sys_cp_wcstombs): Renamed from sys_wcstombs. Take - wctomb function pointer and charset as parameters. Use throughout. - (sys_cp_mbstowcs): Take wctomb function pointer and charset as - parameters instead of codepage. Remove matching local variables and - their initialization. - * wchar.h (ENCODING_LEN): Define as in newlib. - (__mbtowc): Use mbtowc_p typedef for declaration. - (wctomb_f): New type. - (wctomb_p): New type. - (__wctomb): Declare. - (__utf8_wctomb): Use wctomb_f typedef for declaration. - (sys_cp_wcstombs): Move declaration from winsup.h here. - (sys_wcstombs): Ditto. - (sys_wcstombs_alloc): Ditto. - (sys_cp_mbstowcs): Ditto. - (sys_mbstowcs): Ditto. - (sys_mbstowcs_alloc): Ditto. - * winsup.h: Move declaration of sys_FOO functions to wchar.h. Include - wchar.h instead. - -2009-04-06 Earl Chew - - * libc/rexec.cc (ruserpass): Use fstat64 instead of fstat. - -2009-04-06 Corinna Vinschen - - * strfuncs.cc: Add comment to explain why we can't support JIS - for now. - (__db_wctomb): Alwaus use WC_NO_BEST_FIT_CHARS. - (__jis_wctomb): Just call __ascii_wctomb from here. - (__eucjp_wctomb): Convert to standalone implementation to fix up the - difference between eucJP and CP 20932 affecting JIS-X-0212 characters. - Explain. - (__kr_wctomb): Use codepage 949. - (__db_mbtowc): Reorder code slightly. Always use MB_ERR_INVALID_CHARS - in call to MultiByteToWideChar. Fix a problem with singlebyte - sequences. Fix a bug in '\0' handling. Reset state->__count on - successful return from non-zero state. - (__jis_mbtowc): Just call __ascii_mbtowc from here. - (__eucjp_mbtowc): Convert to standalone implementation to fix up the - difference between eucJP and CP 20932 affecting JIS-X-0212 characters. - (__kr_mbtowc): Use codepage 949. - (__set_charset_from_codepage): Handle codepage 20932 as eucJP. - -2009-04-05 Christopher Faylor - - * Makefile.in: Use all compile options when calculating magic values. - * shared_info.h (CURR_SHARED_MAGIC): Revert erroneous value. - * child_info.h (CURR_CHILD_INFO_MAGIC): Update. - - * fhandler.h (acquire_output_mutex): Remove unneeded ';'. - (release_output_mutex): Ditto. - -2009-04-05 Christopher Faylor - - * net.cc: Undefine NOERROR and DELETE to avoid compiler warnings. - * shared_info.h (CURR_SHARED_MAGIC): Update. - * spawn.cc (spawn_guts): Avoid copying one line command line argument - if it hasn't been filled out. - -2009-04-04 Yaakov Selkowitz - Corinna Vinschen - - * include/asm/byteorder.h (__ntohl): Prototype before define to avoid - a warning with -Wmissing-prototypes. Use _ELIDABLE_INLINE macro from - _ansi.h. - (__ntohs): Ditto. - -2009-04-02 Corinna Vinschen - - * environ.cc (build_env): Fix length calculation of resulting - wide char environment string. - -2009-04-02 Yaakov Selkowitz - - * include/netdb.h: #include , , - and per SUSv3. - -2009-04-01 Corinna Vinschen - - * strfuncs.cc (sys_cp_mbstowcs): Check if ASCII SO is followed by at - least two chars and the next byte is a valid UTF-8 start byte before - trying to convert the followup bytes as UTF-8 sequence. - -2009-03-31 Corinna Vinschen - - * shm.cc (struct shm_attached_list): Convert access type to ULONG. - (fixup_shms_after_fork): Fix comment. Use NtMapViewOfSection rather - than MapViewOfFileEx to recreate shared memory regions. Add function - name to api_fatal output. - (shmat): Use NtMapViewOfSection to create shared memory region - top-down. - -2009-03-31 Corinna Vinschen - - * ctype.cc: Remove implementation of ctype functions in favor of - pointer-based newlib implementation. - (_ctype_b): Declare. - (__ctype_cp): Move to newlib. Declare. - (__ctype_iso): Ditto. - (__set_ctype): Implement changing __ctype_ptr__. Only copy character - class data in applications built under older Cygwin. - * cygwin.din (__ctype_ptr__): Export. - * include/ctype.h: Remove in favor of newlib implementation. - * include/cygwin/config.h (__EXPORT): Define alongside __IMPORT. - * include/cygwin/version.h (CYGWIN_VERSION_CHECK_FOR_OLD_CTYPE): - Define check for old vs. new ctype implementation. - Bump API minor number. - -2009-03-28 Christopher Faylor - - * Makefile.in: Perform some minor cleanup. Revamp speclib handling. - * speclib: Rewrite to create libraries with dlltool rather than - attempting surgery on libcygwin.a. - -2009-03-27 Corinna Vinschen - - * net.cc (inet_ntop6): Convert to lowercase hex digits on the fly. - -2009-03-27 Corinna Vinschen - - * net.cc (cygwin_getaddrinfo): Check hints for non-NULL before - checking its content. - -2009-03-27 Corinna Vinschen - - * fhandler.h (class fhandler_fifo): Rename read/write methods to - raw_read/raw_write. - * fhandler_fifo.cc: Ditto. - -2009-03-27 Corinna Vinschen - - * syscalls.cc (pathconf): Fix memory leak. - -2009-03-26 Corinna Vinschen - - * path.cc (symlink_worker): Write target filename as UTF-16 string - with leading BOM marker. - (symlink_info::check_shortcut): If check for leading BOM marker - succeeds, read filename as UTF-16 string. - (symlink_info::check_sysfile): Ditto. - -2009-03-26 Yaakov Selkowitz - - * include/asm/byteorder.h (__ntohl): Align definition to ISO C99. - (__ntohs): Ditto. - -2009-03-26 Corinna Vinschen - - * strfuncs.cc (__set_charset_from_codepage): Revert to translating - codepage 936 to "GBK". - -2009-03-25 Corinna Vinschen - - * strfuncs.cc (sys_wcstombs): Don't convert ASCII SO into two - ASCII SO's. - -2009-03-25 Corinna Vinschen - - * environ.cc (environ_init): Break from locale loop after first hit. - * fhandler_console.cc (fhandler_console::write_normal): Print a SO - sequence using always valid Unicode chars. - -2009-03-25 Corinna Vinschen - - * strfuncs.cc (__kr_wctomb): Use codepage 51949 rather than 50949. - (__kr_mbtowc): Ditto. - (__set_charset_from_codepage): Ditto. Translate codepage 936 to - "GB2312" and drop the charset name "GBK". - -2009-03-24 Corinna Vinschen - - * strfuncs.cc (__kr_wctomb): Use codepage 50949 rather than 949. - (__kr_mbtowc): Ditto. - (__set_charset_from_codepage): Translate codepages 949 and 50949 to - "EUCKR" and drop the charset name "CP949". - -2009-03-24 Corinna Vinschen - - * strfuncs.cc (sys_cp_mbstowcs): Don't read beyond src + nms. - -2009-03-24 Corinna Vinschen - - * shared_info.h (CURR_SHARED_MAGIC): Update. - -2009-03-24 Corinna Vinschen - - * wchar.h: Replace UINT with unsigned int. - -2009-03-24 Corinna Vinschen - - * wchar.h: Remove erroneous "C" specifier from extern declaration. - -2009-03-24 Corinna Vinschen - - * ctype.cc (_CTYPE_DATA_0_127): Add _B class to TAB character. - (__ctype_default): New character class array for default ASCII - character set. - (__ctype_iso): New array of character class array for ISO charsets. - (__ctype_cp): Ditto for singlebyte Windows codepages. - (tolower): Implement as distinct function to support any singlebyte - charset. - (toupper): Ditto. - (__set_ctype): New function to copy singlebyte character classes - corresponding to current charset to ctype_b array. - Align copyright text to upstream. - * dcrt0.cc (dll_crt0_1): Reset current locale to "C" per POSIX. - * environ.cc (set_file_api_mode): Remove. - (codepage_init): Remove. - (parse_thing): Remove "codepage" setting. - (environ_init): Set locale according to environment settings, or - to current codepage, before converting environment to multibyte. - * fhandler.h (fhandler_console::write_replacement_char): Drop argument. - * fhandler_console.cc (dev_console::str_to_con): Call sys_cp_mbstowcs - rather than MultiByteToWideChar. - (fhandler_console::write_replacement_char): Always print a funny - half filled square if a character isn't in the current charset. - (fhandler_console::write_normal): Convert to using __mbtowc - rather than next_char. - * fork.cc (frok::child): Drop call to set_file_api_mode. - * globals.cc (enum codepage_type) Remove. - (current_codepage): Remove. - * miscfuncs.cc (cygwin_wcslwr): Unused, dangerous. Remove. - (cygwin_wcsupr): Ditto. - (is_cp_multibyte): Remove. - (next_char): Remove. - * miscfuncs.h (is_cp_multibyte): Drop declaration. - (next_char): Ditto. - * strfuncs.cc (get_cp): Remove. - (__db_wctomb): New function to implement _wctomb_r functionality for - doublebyte charsets using WideCharToMultiByte. - (__sjis_wctomb): New function to replace unusable newlib function. - (__jis_wctomb): Ditto. - (__eucjp_wctomb): Ditto. - (__gbk_wctomb): New function. - (__kr_wctomb): Ditto. - (__big5_wctomb): Ditto. - (__db_mbtowc): New function to implement _mbtowc_r functionality for - doublebyte charsets using MultiByteToWideChar. - (__sjis_mbtowc): New function to replace unusable newlib function. - (__jis_mbtowc): Ditto. - (__eucjp_mbtowc): Ditto. - (__gbk_mbtowc): New function. - (__kr_mbtowc): New function - (__big5_mbtowc): New function - (__set_charset_from_codepage): New function. - (sys_wcstombs): Reimplement, basically using same wide char to multibyte - conversion as newlib's application level functions. Plus extras. - Add lengthy comment to explain. Change return type to size_t. - (sys_wcstombs_alloc): Just use sys_wcstombs. Change return type to - size_t. - (sys_cp_mbstowcs): Replace sys_mbstowcs, take additional codepage - argument. Explain why. Change return type to size_t. - (sys_mbstowcs_alloc): Just use sys_mbstowcs. Change return type to - size_t. - * wchar.h: Declare internal functions implemented in strfuncs.cc. - (wcscasecmp): Remove. - (wcsncasecmp): Remove. - (wcslwr): Remove. - (wcsupr): Remove. - * winsup.h (codepage_init): Remove declaration. - (get_cp): Ditto. - (sys_wcstombs): Align declaration to new implementation. - (sys_wcstombs_alloc): Ditto. - (sys_cp_mbstowcs): Add declaration. - (sys_mbstowcs): Define as inline function. - (sys_mbstowcs_alloc): Align declaration to new implementation. - (set_file_api_mode): Remove declaration. - * include/ctype.h (isblank): Redefine to use _B character class. - (toupper): Remove ASCII-only definition. - (tolower): Ditto. - -2009-03-24 Corinna Vinschen - - * sec_auth.cc (str2buf2uni): Remove. - * security.h (str2buf2uni): Remove declaration. - -2009-03-24 Yaakov Selkowitz - - * include/mntent.h: Remove declarations of nonexistant addmntent - and hasmntopt. Update and clarify the /etc/mtab comment. - -2009-03-23 Corinna Vinschen - - * smallprint.cc (__small_vsprintf): Handle NULL PWCHAR and - PUNICODE_STRING arguments. - (__small_vswprintf): Ditto. - -2009-03-23 Corinna Vinschen - - * include/asm/byteorder.h (__constant_ntohs): Remove declaration. - (__constant_ntohl): Ditto. - -2009-03-23 Corinna Vinschen - - * cygwin.din: Export wordexp, wordfree. - * posix.sgml: Move them to SUSv4 list. - * include/cygwin/version.h: Bump API minor number. - -2009-03-22 Yaakov Selkowitz - - * include/sys/un.h: #include for strlen. - -2009-03-19 Corinna Vinschen - - * dlfcn.cc (get_full_path_of_dll): Revert patch from 2008-07-16. - -2009-03-19 Yaakov Selkowitz - - * cygwin.din: Export log2, log2f as functions. - * posix.sgml: Add them to SUSv4 list. - * include/cygwin/version.h: Bump API minor number. - -2009-03-18 Corinna Vinschen - - * sec_auth.cc (lsaauth): Remove local definitions of struct - _TOKEN_LINKED_TOKEN and TokenLinkedToken in favor of definitions - from winnt.h. - (lsaprivkeyauth): As in lsaauth, fetch linked token if available and - return that in favor of default token. - -2009-03-15 Yaakov Selkowitz - - * errno.cc (_sys_errlist): Add ESTRPIPE. - -2009-03-15 Corinna Vinschen - - * cygwin.din: Export wcsdup. - * posix.sgml: Add wcsdup to SUSv4 list. - * include/cygwin/version.h: Bump API minor number. - -2009-03-15 Corinna Vinschen - - * include/inttypes.h: Remove "l" size specifier from all 16 and 32 bit - definitions. - -2009-03-14 Christopher Faylor - - * path.cc (warn_msdos): Don't warn about MS-DOS filenames encountered - during initialization. - -2009-03-14 Corinna Vinschen - - * gendef: Remove STABS directives. - -2009-03-13 Corinna Vinschen - - * mktemp.cc: Remove STABS specific link-time warning. Align copyright - text to upstream. - -2009-03-13 Corinna Vinschen - - * flock.cc: Fix lockf copyright to latest version. - -2009-03-12 Corinna Vinschen - - * fhandler_disk_file.cc (path_conv::isgood_inode): Move to be defined - earlier. - (get_ino_by_handle): Take additional path_conv argument, accommodate - throughout. Only use FileId if isgood_inode check is true. - (fhandler_base::open_fs): Simplify setting ino due to above change. - (readdir_get_ino): Make sure to return always a non-zero inode number. - (fhandler_disk_file::readdir): Always open file in dir with - FILE_OPEN_REPARSE_POINT so as not to open wrong file. - Drop call to isgood_inode here. - * path.cc (symlink_info::check): Call fs.update in case we're fetching - file information from call to NtQueryDirectoryFile. - -2009-03-12 Corinna Vinschen - - * flock.cc (fhandler_disk_file::lock): Don't test file open mode in - case of flock-type locks. Explain why. - -2009-03-12 Brian Ford - - * gethostby_helper: Fix typos in DEBUGGING case. - -2009-03-11 Corinna Vinschen - - * cygwin.din: Export wcscasecmp, wcsncasecmp. - * posix.sgml: Move wcscasecmp, wcsncasecmp to SUSv4 list. - * include/cygwin/version.h: Bump API minor number. - -2009-03-11 Corinna Vinschen - - * cygwin.din: Export wscanf, fwscanf, swscanf, vwscanf, vfwscanf, - vswscanf. - * posix.sgml: Move fwscanf, swscanf, vwscanf, vfwscanf, vswscanf - to SUSv4 list. - * include/cygwin/version.h: Bump API minor number. - -2009-03-09 Corinna Vinschen - - * fhandler.h (fhandler_socket::wait_for_events): Take additional - parameter "dontwait". - * fhandler_socket.cc (fhandler_socket::wait_for_events): Act as if the - socket is non-blocking if dontwait is true. - (fhandler_socket::recv_internal): Use incoming MSG_DONTWAIT flag to - set the wait_for_events dontwait parameter. - (fhandler_socket::send_internal): Ditto. Optimize code slightly. - * include/cygwin/socket.h (MSG_DONTWAIT): Define. - * include/cygwin/version.h: Bump API minor number. - -2009-03-09 Corinna Vinschen - - * cygwin.din: Export wcsftime. - * posix.sgml: Move wcsftime to SUSv4 list. - * include/cygwin/version.h: Bump API minor number. - -2009-03-06 Pierre A. Humblet - - * cygwin.din: Export gethostbyname2. - * net.cc: define _CYGWIN_IN_H and include resolv.h. - (realloc_ent): New function. - (dup_ent): Call realloc_ent. - (memcpy4to6): New function. - (dn_length1): New function. - (gethostby_helper): New function. - (gethostbyname2): New function. - * posix.sgml: Add gethostbyname2. - * include/cygwin/version.h: Bump API minor number. - * libc/minires.c (get_options): Look for "inet6" and apply bounds - to "retry" and "retrans". - (res_ninit): Set the default options at the beginning. - (dn_expand): Fix "off by one". - -2009-03-06 Corinna Vinschen - - * cygwin.din: Export wprintf, fwprintf, swprintf, vwprintf, vfwprintf, - vswprintf. Sort. - * posix.sgml: Move fwprintf, swprintf, vwprintf, vfwprintf, vswprintf - to SUSv4 list. Sort SUSv4 list. - * include/cygwin/version.h: Bump API minor number. - -2009-03-04 Corinna Vinschen - - * dcrt0.cc (disable_dep): Disable. Explain why. - (dll_crt0_0): Disable calling disable_dep. Explain why. - -2009-03-03 Corinna Vinschen - - * net.cc: Include asm/byteorder.h. - (htonl): Move to end of file. Add comment to explain why. Align - definition to POSIX. Use related macro from asm/byteorder.h. - (ntohl): Ditto. - (htons): Ditto. - (ntohs): Ditto. - * include/asm/byteorder.h: Revert previous patch. - -2009-03-03 Corinna Vinschen - - * include/asm/byteorder.h: Disable optimization when building - Cygwin network code. - -2009-02-26 Christopher Faylor - - * dtable.cc (dtable::select_read): Add ability to override fh. - * fhandler.h (fhandler_fifo::select_read): Declare new function. - (fhandler_fifo::select_write): Ditto. - (fhandler_fifo::select_except): Ditto. - * select.cc (peek_pipe): Treat certain classes of pipe errors as "no - data". - (fhandler_fifo::select_read): Define new function. - (fhandler_fifo::select_write): Ditto. - (fhandler_fifo::select_except): Ditto. - - * shared_info.h (CURR_SHARED_MAGIC): Update. - -2009-02-23 Sjors Gielen - - * Makefile.in: Add DESTDIR functionality. - -2009-02-23 Corinna Vinschen - - * sec_auth.cc (get_user_local_groups): Simplify LookupAccountName code. - -2009-02-20 Corinna Vinschen - - * autoload.cc (NetLocalGroupEnum): Remove. - (NetLocalGroupGetMembers): Remove. - (NetUserGetLocalGroups): Add. - * sec_auth.cc (is_group_member): Remove function. - (get_user_local_groups): Get user as string instead of as SID. - Call NetUserGetLocalGroups instead of NetLocalGroupEnum. Drop call - to is_group_member. - (get_server_groups): Call get_user_local_groups with user name instead - of user SID. - -2009-02-19 Corinna Vinschen - - * winver.rc: Fix Copyright date. - -2009-02-19 Corinna Vinschen - - * cygwin.din: Export mbsnrtowcs and wcsnrtombs. - * posix.sgml: Move mbsnrtowcs and wcsnrtombs to SUSv4 section. - * include/cygwin/version.h: Bump API minor number. - -2009-02-18 Corinna Vinschen - - * cygwin.din: Export open_wmemstream. - * posix.sgml: Move open_wmemstream to SUSv4 section. - * include/cygwin/version.h: Bump API minor number. - -2009-02-16 Corinna Vinschen - - * cygwin.din: Export reallocf. - * malloc_wrapper.cc( reallocf): New function. - * posix.sgml: Add reallocf to BSD section. - * include/cygwin/version.h: Bump API minor number. - * libc/fts.c: Remove erroneous reallocf definition. - -2009-02-16 Corinna Vinschen - - * cygwin.din: Export wcstoimax, wcstoumax. - * posix.sgml: Move wcstoimax and wcstoumax to SUSv4 section. - * include/inttypes.h: Declare wcstoimax and wcstoumax. - * include/cygwin/version.h: Bump API minor number. - -2009-02-13 Corinna Vinschen - - * cygwin.din: Export wcsnlen. - * posix.sgml: Move wcsnlen to SUSv4 section. - * include/cygwin/version.h: Bump API minor number. - -2009-02-13 Corinna Vinschen - - * environ.cc (_getenv_r): New function. - -2009-02-13 Corinna Vinschen - - * posix.sgml: Move dirfd to SUSv4 section. - -2009-02-13 Corinna Vinschen - - * posix.sgml: Move interfaces deprecated in SUSv4 to deprecated - interfaces section. Move interfaces added in SUSv4 to SUSv4 - section or, if unimplemented, add them to the unimplemented interfaces - section. - -2009-02-13 Corinna Vinschen - - * posix.sgml: Merge SUSv3 and SUSv4 section into a single SUSv4 section. - Move Solaris calls now in SUSv4 to SUSv4 section. Rename unimplemented - section to refer to SUSv4. Add note about missing interfaces. - Move wcstod and wcstof from unimplemented to SUSv4 section. - -2009-02-13 Corinna Vinschen - - * mount.cc (mount_info::from_fstab_line): Make cygdrive posix=0 by - default as documented. - -2009-02-13 Corinna Vinschen - - * cygwin.din: Export wcstod and wcstof. - * include/cygwin/version.h: Bump API minor number. - -2009-02-11 Corinna Vinschen - - * syscalls.cc (open): Handle O_DIRECTORY flag. - * include/fcntl.h: Add SUSv4 flags O_DIRECTORY, O_EXEC and O_SEARCH. - * include/cygwin/version.h: Bump API minor number. - -2009-02-09 Corinna Vinschen - - * fhandler_floppy.cc (fhandler_dev_floppy::open): Fix format. Add - code to allow to read disk and CD/DVD devices in full length. Explain - why. - (fhandler_dev_floppy::raw_read): Add current position to debug output. - - * include/sys/sched.h: New stub file to override newlib file with - clashing definitions. - -2009-02-05 Corinna Vinschen - - * cygwin.din: Export wcstok. - * posix.sgml: Move wcstok from unimplemented to susv3. - * include/cygwin/version.h: Bump API minor number. - -2009-02-04 Corinna Vinschen - - * fhandler_proc.cc (proc_tab): Add entry for mounts symlink. - (format_proc_mounts): New function to implement mounts symlink. - * fhandler_process.cc (process_tab): Add entry for mounts file. - (format_process_mounts): New function to implement mounts file. - -2009-02-04 Corinna Vinschen - - * security.cc (alloc_sd): Disable generating default permission entries - for directories. - -2009-01-29 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::readdir): Fix inode number - evaluation for faked "." entry. - - * mount.cc (fs_info::update): Move setting of is_cdrom after checking - for caseinsensitivity. Recognize UDF in is_cdrom case and set - caseinsensitive flag according to UDF brokenness determined by OS. - Add comment to explain why. - * mount.h (class fs_info): Add is_udf status flag. - * path.cc (symlink_info::check): Add workaround for UDF bug in - terms of casesensitivity on certain OSes. - * wincap.h (wincaps::has_broken_udf): New element. - * wincap.cc: Implement above element throughout. - -2009-01-27 Christopher Faylor - - * fhandler.cc (fhandler_base::wait_overlapped): Set bytes to -1 on - EINTR or real error. - (fhandler_base::write_overlapped): Assume that bytes_written will - contain proper error value. - * pipe.cc (fhandler_pipe::fhandler_pipe): Set uninterruptible_io since - signals are handled by pipe functions now. - -2009-01-26 Corinna Vinschen - - * shared.cc (shared_name): New function for WCHAR names. - (open_shared): Take name parameter as WCHAR. Accommodate throughout. - * shared_info.h ((CURR_SHARED_MAGIC): Redefine. - (shared_name): Add declaration for function taking a WCHAR name. - (open_shared): Change declaration according to above change. - * pinfo.cc (pinfo::init) : Accommodate above change. - -2009-01-26 Corinna Vinschen - - * grp.cc (getgrgid_r): Simplify code by using stpcpy. - (getgrnam_r): Ditto. - * passwd.cc (getpwuid_r32): Simplify code by using stpcpy. - (getpwnam_r): Ditto. - -2009-01-26 Corinna Vinschen - - * uinfo.cc (pwdgrp::load): Open file with FILE_OPEN_FOR_BACKUP_INTENT - flag. - -2009-01-24 Corinna Vinschen - - * mount.cc (mount_info::from_fstab): Open fstab file with - FILE_OPEN_FOR_BACKUP_INTENT flag. - -2009-01-23 Corinna Vinschen - - * smallprint.cc (__small_vsprintf): Use already available buffer tmp - in wfillin case. - -2009-01-22 Christopher Faylor - - * select.cc (peek_serial): Add hack to allow proper operation with - com0com driver. - -2009-01-21 Corinna Vinschen - - Remove USE_SERVER define. Accommodate throughout. - * configure.in: Remove --enable-server option. - * configure: Regenerate. - * environ.cc: Remove CYGWIN=server setting. - -2009-01-20 Corinna Vinschen - - * fhandler_procnet.cc: Reorganize global procnet content data into a - new struct virt_tab_t. Accommodate throughout. - - * fhandler.h: Fix copyright dates. - * fhandler_process.cc: Ditto. - * fhandler_registry.cc: Ditto. - -2009-01-20 Corinna Vinschen - - * devices.h (FH_PROCESSFD): New device type. - * dtable.cc (build_fh_pc): Add case for FH_PROCESSFD. - * fhandler.h (class fhandler_virtual): Drop bufalloc member. - * fhandler_virtual.h: New header. - * fhandler_proc.cc: Remove types proc_type_t and proc_tab_t in favor - of types virt_type_t and virt_tab_t from fhandler_virtual.h. - Change prototypes of format_XXX functions accordingly. - (proc_tab): Drop size member info. - (fhandler_proc::fill_filebuf): Don't allocate filebuf here. Allocate - it in the format_XXX functions. - * fhandler_process.cc: Reorganize global process content data into a - new struct virt_tab_t. Accommodate throughout. - (format_process_winexename): New function. - (format_process_winpid): New function. - (format_process_exename): New function. - (format_process_root): New function. - (format_process_cwd): New function. - (format_process_cmdline): New function. - (format_process_ppid): New function. - (format_process_uid): New function. - (format_process_pgid): New function. - (format_process_sid): New function. - (format_process_gid): New function. - (format_process_ctty): New function. - (format_process_fd): New function. - * fhandler_procnet.cc (fhandler_procnet::fill_filebuf): Don't use - bufalloc. - * fhandler_registry.cc (fhandler_registry::fill_filebuf): Define - bufalloc locally. - * fhandler_virtual.cc (fhandler_virtual::fhandler_virtual): Drop - initialization of bufalloc. - (fhandler_virtual::dup): Drop copying bufalloc. - -2009-01-20 Corinna Vinschen - - * thread.h (struct pthread_rwlock::RWLOCK_READER): Add counter n. - * thread.cc (pthread_rwlock::rdlock): If a thread already owns a - read lock, just count the number of locks for it, per SUSv4. - (pthread_rwlock::tryrdlock): Ditto. - (pthread_rwlock::unlock): If a thread has more than one concurrent - read locks, just count down. - -2009-01-20 Corinna Vinschen - - * autoload.cc (WSAIoctl): Reintroduce. - (WSASendMsg): Define. - * fhandler.h (class fhandler_socket): Change definition of recv_internal - and send_internal to take WSAMSG pointer as parameter. - * fhandler_socket.cc (WSAID_WSARECVMSG): Define. - (LPFN_WSARECVMSG): Define. - (WSASendMsg): Declare. - (get_ext_funcptr): New function to fetch address of WSARecvMsg. - (fhandler_socket::recv_internal): Take just a LPWSAMSG parameter. - Change code accordingly. If control information is requested, - fetch address of WSARecvMsg and use that instead of WSARecvFrom. - (fhandler_socket::recvfrom): Change return type to ssize_t as - declared in fhandler.h. Accommodate changes to recv_internal. - (fhandler_socket::recvmsg): Ditto. Make sure that control information - is only requested if system, address family, and socket type support it. - (fhandler_socket::send_internal): Take just a LPWSAMSG parameter - and the flags. Change code accordingly. If control information is - provided, use WSASendMsg instead of WSASendTo. - (fhandler_socket::sendto): Drop useless comment. Accommodate changes - to send_internal. - (fhandler_socket::sendmsg): Ditto. Make sure that control information - is only provided if system, address family, and socket type support it. - * wincap.h (wincaps::has_recvmsg): New element. - (wincaps::has_sendmsg): New element - * wincap.cc: Implement above elements throughout. - * include/cygwin/socket.h (CMSG_ALIGN): Phrase in terms of alignment - of type struct cmsghdr. - -2009-01-17 Corinna Vinschen - - * mmap.cc (mmap64): Fix condition checking if anonymous mapping beyond - EOF is required. - -2009-01-17 Corinna Vinschen - - * fhandler_proc.cc: Reorganize global proc content data into a new - struct proc_tab_t. Accommodate throughout. - (format_proc_version): New function. - (format_proc_loadavg): New function. - (format_proc_self): New function. - - * resource.cc (getrlimit): Return correct rlim_max value for - RLIMIT_NOFILE. - -2009-01-16 Corinna Vinschen - - * Fix copyright dates. - -2009-01-13 Corinna Vinschen - - * libc/getopt.c (parse_long_options): Use fix from NetBSD's getopt - to avoid false ambiguities. - -2009-01-12 Corinna Vinschen - - * syscalls.cc (enum bin_status): New type. - (try_to_bin): Return bin_status. Rename win32_path to pc. Rename h - to fh. Rename fh to tmp_fh. Add code to set delete dispostion and - more code to replace file moved to bin by another, temporary file. - Add comments to explain why. - (unlink_nt): Replace move_to_bin with bin_stat. Only set bin_stat - to move_to_bin for non-remote files. As a last resort, call try_to_bin - if setting delete-on-close failed. Only re-set R/O DOS attribute - and only close handle if it's still valid. - -2009-01-11 Corinna Vinschen - - * errno.cc (errmap): Set errno to ENOENT instead of ENOSHARE throughout. - * path.cc (path_conv::check): Set to and check for ENOENT instead of - ENOSHARE. - - * path.cc (symlink_info::check): Fix Samba 3.2.x comment. - -2009-01-09 Corinna Vinschen - - * mount.cc (mount_info::from_fstab_line): Always convert drive - letter in native path to uppercase. - * path.cc (normalize_win32_path): Ditto. - (path_prefix_p): Revert previous patch. - - * path.cc (symlink_info::check): Check for STATUS_INVALID_PARAMETER - return code to circumvent weird behaviour of Samba 3.2.x shares. - -2009-01-09 Christopher Faylor - - * include/sys/cygwin.h (CW_SETERRNO): Define. - * external.cc (CW_SETERRNO): Implement. - * include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR to 192 to - reflect the above change. - - * path.cc (path_prefix_p): Treat X: as equivalent to x:. - - * mkglobals_h: Remove unneeded #define. - - * spawn.cc (spawn_guts): Avoid overly wordy initialization to zero. - -2009-01-08 Corinna Vinschen - - * libc/fts.c (fts_build): Use DT_DIR case on Cygwin. - (fts_ufslinks): Fix using wrong structure member in Cygwin-specific - code. - -2009-01-07 Corinna Vinschen - - * ntdll.h: Reorder NT status flags. Fix a case difference. Add - STATUS_CANNOT_DELETE flag. - * syscalls.cc (unlink_nt): Change initial NtOpenFile to request - FILE_SHARE_DELETE sharing mode. Change comment accordingly. - If setting delete disposition failed with STATUS_CANNOT_DELETE, try - to delete using delete-on-close. Explain why. - Rearrange setting R/O DOS attribute after trying to delete. Simplify - comment. - -2009-01-07 Corinna Vinschen - - * fhandler_disk_file.cc (fhandler_disk_file::link): Only add .exe if - original file has .exe as well. - * path.cc (path_conv::is_binary): Only recognize Windows 32 and 64 bit - apps as binaries. - -2009-01-02 Christopher Faylor - - Remove unneeded header files from source files throughout. - Update copyrights where appropriate. - - * globals.cc: New file for generic global variables. - * mkglobals_h: New script to generate globals.h. - * mkstatic: New script used to build a (currently non-working) static - libcygwin_s.a. - * Makefile.in: Add unused rule to build a non-working libcygwin_s.a. - (DLL_OFILES): Add globals.o. Make all objects rely on globals.h. - (globals.h): New target. Generate globals.h. - * cygtls.h: Honor new CYGTLS_HANDLE define to control when the HANDLE - operator is allowed in _cygtls. - * dcrt0.cc: Move most globals to globals.cc. - * init.cc: Ditto. - * environ.cc (strip_title_path): Remove now-unneeded extern. - * fhandler_serial.cc (fhandler_serial::open): Ditto. - * pinfo.cc: Ditto. - (commune_process): Ditto. - * shared.cc: Ditto. - * glob.cc: Ditto. - * strace.cc: Ditto. - * exceptions.cc: Define CYGTLS_HANDLE before including winsup.h. - * path.cc (stat_suffixes): Move here. - * security.h: Add forward class path_conv declaration. - * smallprint.cc (__small_vsprintf): Make a true c++ function. - (__small_sprintf): Ditto. - (small_printf): Ditto. - (console_printf): Ditto. - (__small_vswprintf): Ditto. - (__small_swprintf): Ditto. - * spawn.cc (spawn_guts): Remove _stdcall decoration in favor of - regparm. - (hExeced): Move to globals.cc - * strfuncs.cc (current_codepage): Ditto. - (active_codepage): Ditto. - * sync.cc (lock_process::locker): Move here from dcrt0.cc. - * syscalls.cc (stat_suffixes): Move to path.cc. - * tty.cc (tty::create_master): Uncapitalize fatal warning for - consistency. - * winsup.h: Include globals.h to declare most of the grab bag list of - globals which were previously defined here. - - * mount.h: Move USER_* defines back to shared_info.h. - - * speclib: Force temporary directory cleanup. - -2009-01-02 Christopher Faylor - - * speclib: Rewrite completely in perl. Avoid multiple nm calls. - diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in deleted file mode 100644 index 741dd66ff..000000000 --- a/winsup/cygwin/Makefile.in +++ /dev/null @@ -1,504 +0,0 @@ -# Makefile.in for Cygwin. -# Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. -# -# This file is part of Cygwin. -# -# This software is a copyrighted work licensed under the terms of the -# Cygwin license. Please consult the file "CYGWIN_LICENSE" for -# details. - -# This makefile requires GNU make. - -SHELL:=@SHELL@ -srcdir:=@srcdir@ -objdir:=. - -CONFIG_DIR:=$(srcdir)/config/@CONFIG_DIR@ -VPATH:=$(srcdir):$(CONFIG_DIR):$(srcdir)/regex:$(srcdir)/lib:$(srcdir)/libc - -target_alias:=@target_alias@ -build_alias:=@build_alias@ -host_alias:=@host_alias@ -prefix:=@prefix@ - -program_transform_name:=@program_transform_name@ -exec_prefix:=@exec_prefix@ -bindir:=@bindir@ -libdir:=@libdir@ -mandir:=@mandir@ -sysconfdir:=@sysconfdir@ -ifeq ($(target_alias),$(host_alias)) -ifeq ($(build_alias),$(host_alias)) -tooldir:=$(exec_prefix) -else -tooldir:=$(exec_prefix)/$(target_alias) -endif -else -tooldir:=$(exec_prefix)/$(target_alias) -endif -datadir:=@datadir@ -infodir:=@infodir@ -includedir:=@includedir@ - -override INSTALL:=@INSTALL@ -override INSTALL_PROGRAM:=@INSTALL_PROGRAM@ -override INSTALL_DATA:=@INSTALL_DATA@ - -# -# --enable options from configure -# -MT_SAFE:=@MT_SAFE@ -DEFS:=@DEFS@ -CCEXTRA:= -CC:=@CC@ -# FIXME: Which is it, CC or CC_FOR_TARGET? -CC_FOR_TARGET:=$(CC) -CFLAGS=@CFLAGS@ -override CFLAGS+=-MMD ${$(*F)_CFLAGS} -Werror -fmerge-constants -ftracer \ - -mno-use-libstdc-wrappers $(CCEXTRA) -CXX=@CXX@ -override CXXFLAGS=@CXXFLAGS@ - -AR:=@AR@ -AR_FLAGS:=qv -RANLIB:=@RANLIB@ -LD:=@LD@ -DLLTOOL:=@DLLTOOL@ -WINDRES:=@WINDRES@ -AS:=@AS@ -NM:=@NM@ -OBJCOPY:=@OBJCOPY@ -OBJDUMP:=@OBJDUMP@ -STRIP:=@STRIP@ -LDSCRIPT:=cygwin.sc -MKDIRP:=$(INSTALL) -m 755 -d -# -# Include common definitions for winsup directory -# -include $(srcdir)/../Makefile.common - -@SET_MAKE@ - -# Setup the testing framework, if you have one -EXPECT = `if [ -f $${rootme}/../../expect/expect$(EXEEXT) ] ; then \ - echo $${rootme}/../../expect/expect$(EXEEXT) ; \ - else echo expect ; fi` - -RUNTEST = `if [ -f $${srcdir}/../dejagnu/runtest ] ; then \ - echo $${srcdir}/../dejagnu/runtest ; \ - else echo runtest; fi` -RUNTESTFLAGS = - -# Parameters used in building the cygwin.dll. -# We build as cygwin0.dll and rename at install time to overcome -# native rebuilding issues (we don't want the build tools to see a partially -# built cygwin.dll and attempt to use it instead of the old one). - -DLL_NAME:=cygwin1.dll -TEST_DLL_NAME:=cygwin0.dll -TEST_LIB_NAME:=libcygwin0.a -STATIC_LIB_NAME:=libcygwin_s.a -DEF_FILE:=cygwin.def -DLL_ENTRY:=@DLL_ENTRY@ - -LIBGMON_A:=libgmon.a -CYGWIN_START:=crt0.o -GMON_START:=gcrt0.o - -toolopts:=--ar=${AR} --as=${AS} --nm=${NM} --objcopy=${OBJCOPY} -speclib=\ - ${srcdir}/speclib ${toolopts} \ - --exclude='cygwin' \ - --exclude='(?i:dll)' \ - --exclude='reloc' \ - --exclude='^_main$$' \ - $^ - -# Some things want these from libc, but they have their own static -# data which apps can get to, which is a pain in the dll, so we -# include them directly into the library. - -LIBCOS:=${sort ${addsuffix .o,${basename ${notdir ${wildcard $(srcdir)/lib/*.c}}}} \ - ${addsuffix .o,${basename ${notdir ${wildcard $(srcdir)/lib/*.cc}}}}} - -# Build all source files in the config directory - -EXTRA_DLL_OFILES:=${addsuffix .o,${basename ${notdir ${wildcard $(CONFIG_DIR)/*.c}}}} - -EXTRA_OFILES:= - -MALLOC_OFILES:=@MALLOC_OFILES@ - -DLL_IMPORTS:=$(w32api_lib)/libkernel32.a $(w32api_lib)/libadvapi32.a $(w32api_lib)/libntdll.a - -MT_SAFE_OBJECTS:= -# Please maintain this list in sorted order, with maximum files per 86 col line -# -DLL_OFILES:=assert.o autoload.o bsdlib.o ctype.o cxx.o cygheap.o cygthread.o \ - cygtls.o dcrt0.o debug.o devices.o dir.o dlfcn.o dll_init.o \ - dtable.o environ.o errno.o exceptions.o exec.o external.o fcntl.o \ - fhandler.o fhandler_clipboard.o fhandler_console.o fhandler_disk_file.o \ - fhandler_dsp.o fhandler_fifo.o fhandler_floppy.o fhandler_mailslot.o \ - fhandler_mem.o fhandler_netdrive.o fhandler_nodevice.o fhandler_proc.o \ - fhandler_process.o fhandler_procnet.o fhandler_random.o fhandler_raw.o \ - fhandler_registry.o fhandler_serial.o fhandler_socket.o fhandler_tape.o \ - fhandler_termios.o fhandler_tty.o fhandler_virtual.o fhandler_windows.o \ - fhandler_zero.o flock.o fnmatch.o fork.o fts.o ftw.o getopt.o glob.o \ - glob_pattern_p.o globals.o grp.o heap.o hookapi.o inet_addr.o inet_network.o \ - init.o ioctl.o ipc.o kernel32.o libstdcxx_wrapper.o localtime.o lsearch.o \ - malloc_wrapper.o minires-os-if.o minires.o miscfuncs.o mktemp.o mmap.o msg.o \ - mount.o net.o netdb.o nfs.o nftw.o nlsfuncs.o ntea.o passwd.o path.o \ - pinfo.o pipe.o poll.o posix_ipc.o pthread.o random.o regcomp.o \ - regerror.o regexec.o regfree.o registry.o resource.o rexec.o rcmd.o \ - scandir.o sched.o sec_acl.o sec_auth.o sec_helper.o security.o select.o \ - sem.o setlsapwd.o shared.o shm.o sigfe.o signal.o sigproc.o smallprint.o \ - spawn.o strace.o strfmon.o strfuncs.o strptime.o strsep.o strsig.o sync.o \ - syscalls.o sysconf.o syslog.o termios.o thread.o timer.o times.o \ - tls_pbuf.o tty.o uinfo.o uname.o wait.o wincap.o window.o winf.o \ - xsique.o \ - $(EXTRA_DLL_OFILES) $(EXTRA_OFILES) $(MALLOC_OFILES) $(MT_SAFE_OBJECTS) - -EXCLUDE_STATIC_OFILES:=$(addprefix --exclude=,\ - cygtls.o \ - dcrt0.o \ - exceptions.o \ - fork.o \ - signal.o \ - spawn.o \ -) - -GMON_OFILES:=gmon.o mcount.o profil.o - -NEW_FUNCTIONS:=$(addprefix --replace=,\ - acl=_acl32 \ - aclcheck=_aclcheck32 \ - aclfrommode=_aclfrommode32 \ - aclfrompbits=_aclfrompbits32 \ - aclfromtext=_aclfromtext32 \ - aclsort=_aclsort32 \ - acltomode=_acltomode32 \ - acltopbits=_acltopbits32 \ - acltotext=_acltotext32 \ - chown=_chown32 \ - facl=_facl32 \ - fchown=_fchown32 \ - fcntl=_fcntl64 \ - fdopen=_fdopen64 \ - fgetpos=_fgetpos64 \ - fopen=_fopen64 \ - freopen=_freopen64 \ - fseeko=_fseeko64 \ - fsetpos=_fsetpos64 \ - fstat=_fstat64 \ - ftello=_ftello64 \ - ftruncate=_ftruncate64 \ - getegid=_getegid32 \ - geteuid=_geteuid32 \ - getgid=_getgid32 \ - getgrent=_getgrent32 \ - getgrgid=_getgrgid32 \ - getgrnam=_getgrnam32 \ - getgroups=_getgroups32 \ - getpwuid=_getpwuid32 \ - getpwuid_r=_getpwuid_r32 \ - getuid=_getuid32 \ - initgroups=_initgroups32 \ - lchown=_lchown32 \ - lseek=_lseek64 \ - lstat=_lstat64 \ - mknod=_mknod32 \ - mmap=_mmap64 \ - open=_open64 \ - seekdir=_seekdir64 \ - setegid=_setegid32 \ - seteuid=_seteuid32 \ - setgid=_setgid32 \ - setgroups=_setgroups32 \ - setregid=_setregid32 \ - setreuid=_setreuid32 \ - setuid=_setuid32 \ - stat=_stat64 \ - telldir=_telldir64 \ - timezone= \ - tmpfile=_tmpfile64 \ - truncate=_truncate64 \ -) - -API_VER:=$(srcdir)/include/cygwin/version.h - -LIB_NAME:=libcygwin.a -LIBSERVER:=@LIBSERVER@ -SUBLIBS:=libpthread.a libutil.a ${CURDIR}/libm.a ${CURDIR}/libc.a libdl.a libresolv.a librt.a -EXTRALIBS:=libautomode.a libbinmode.a libtextmode.a libtextreadmode.a -INSTOBJS:=automode.o binmode.o textmode.o textreadmode.o -TARGET_LIBS:=$(LIB_NAME) $(CYGWIN_START) $(GMON_START) $(LIBGMON_A) $(SUBLIBS) $(INSTOBJS) $(EXTRALIBS) - -ifneq "${filter -O%,$(CFLAGS)}" "" -cygheap_CFLAGS:=-fomit-frame-pointer -cygthread_CFLAGS:=-fomit-frame-pointer -cygtls_CFLAGS:=-fomit-frame-pointer -delqueue_CFLAGS:=-fomit-frame-pointer -devices_CFLAGS:=-fomit-frame-pointer -Os -dir_CFLAGS:=-fomit-frame-pointer -dlfcn_CFLAGS:=-fomit-frame-pointer -dll_init_CFLAGS:=-fomit-frame-pointer -dtable_CFLAGS:=-fomit-frame-pointer -fcheck-new -fcntl_CFLAGS:=-fomit-frame-pointer -fhandler_CFLAGS:=-fomit-frame-pointer -fhandler_clipboard_CFLAGS:=-fomit-frame-pointer -fhandler_console_CFLAGS:=-fomit-frame-pointer -fhandler_disk_file_CFLAGS:=-fomit-frame-pointer -fhandler_dsp_CFLAGS:=-fomit-frame-pointer -fhandler_floppy_CFLAGS:=-fomit-frame-pointer -fhandler_mem_CFLAGS:=-fomit-frame-pointer -fhandler_netdrive_CFLAGS:=-fomit-frame-pointer -fhandler_proc_CFLAGS:=-fomit-frame-pointer -fhandler_process_CFLAGS:=-fomit-frame-pointer -fhandler_random_CFLAGS:=-fomit-frame-pointer -fhandler_raw_CFLAGS:=-fomit-frame-pointer -fhandler_registry_CFLAGS:=-fomit-frame-pointer -fhandler_serial_CFLAGS:=-fomit-frame-pointer -fhandler_socket_CFLAGS:=-fomit-frame-pointer -fhandler_syslog_CFLAGS:=-fomit-frame-pointer -fhandler_tape_CFLAGS:=-fomit-frame-pointer -fhandler_termios_CFLAGS:=-fomit-frame-pointer -fhandler_tty_CFLAGS:=-fomit-frame-pointer -fhandler_virtual_CFLAGS:=-fomit-frame-pointer -fhandler_windows_CFLAGS:=-fomit-frame-pointer -fhandler_zero_CFLAGS:=-fomit-frame-pointer -flock_CFLAGS:=-fomit-frame-pointer -grp_CFLAGS:=-fomit-frame-pointer -libstdcxx_wrapper_CFLAGS:=-fomit-frame-pointer -malloc_CFLAGS:=-fomit-frame-pointer -malloc_wrapper_CFLAGS:=-fomit-frame-pointer -miscfuncs_CFLAGS:=-fomit-frame-pointer -net_CFLAGS:=-fomit-frame-pointer -passwd_CFLAGS:=-fomit-frame-pointer -regcomp_CFLAGS=-fomit-frame-pointer -regerror_CFLAGS=-fomit-frame-pointer -regexec_CFLAGS=-fomit-frame-pointer -regfree_CFLAGS=-fomit-frame-pointer -shared_CFLAGS:=-fomit-frame-pointer -sync_CFLAGS:=-fomit-frame-pointer -O3 -smallprint_CFLAGS:=-fomit-frame-pointer -syscalls_CFLAGS:=-fomit-frame-pointer -sysconf_CFLAGS:=-fomit-frame-pointer -uinfo_CFLAGS:=-fomit-frame-pointer -endif - -_cygwin_crt0_common_STDINCFLAGS:=yes -libstdcxx_wrapper_STDINCFLAGS:=yes -cxx_STDINCFLAGS:=yes - -.PHONY: all force dll_ofiles install all_target install_target all_host install_host \ - install install-libs install-headers - -.SUFFIXES: -.SUFFIXES: .c .cc .def .a .o .d .s - -all_host=@all_host@ -install_host=@install_host@ - -all: all_target $(all_host) - -all_target: $(TARGET_LIBS) - -all_host: $(TEST_LIB_NAME) - -force: - -install: install-libs install-headers install-man install_target \ - $(install_host) $(install_target) - -uninstall: uninstall-libs uninstall-headers uninstall-man - -install-libs: $(TARGET_LIBS) - @$(MKDIRP) $(DESTDIR)$(bindir) - $(INSTALL_PROGRAM) $(TEST_DLL_NAME) $(DESTDIR)$(bindir)/$(DLL_NAME); \ - for i in $^; do \ - $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/lib/`basename $$i` ; \ - done - cd $(DESTDIR)$(tooldir)/lib && ln -sf libcygwin.a libg.a - -install-headers: - cd $(srcdir); \ - for sub in `find include -name '[a-z]*' -type d -print | sort`; do \ - $(MKDIRP) $(DESTDIR)$(tooldir)/$$sub; \ - for i in $$sub/*.h ; do \ - $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/$$sub/`basename $$i` ; \ - done ; \ - done ; \ - -install-man: - @$(MKDIRP) $(DESTDIR)$(mandir)/man2 $(DESTDIR)$(mandir)/man3 $(DESTDIR)$(mandir)/man5 $(DESTDIR)$(mandir)/man7 - cd $(srcdir); \ - for i in `find . -type f -name '*.2'`; do \ - $(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/man2/`basename $$i` ; \ - done; \ - for i in `find . -type f -name '*.3'`; do \ - $(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/man3/`basename $$i` ; \ - done; \ - for i in `find . -type f -name '*.5'`; do \ - $(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/man5/`basename $$i` ; \ - done; \ - for i in `find . -type f -name '*.7'`; do \ - $(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/man7/`basename $$i` ; \ - done - -install_target: - -install_host: - -uninstall-libs: $(TARGET_LIBS) - rm -f $(bindir)/$(DLL_NAME); \ - for i in $^; do \ - rm -f $(tooldir)/lib/$$i ; \ - done - -uninstall-headers: - cd $(srcdir); \ - for sub in `find include -name '[a-z]*' -type d -print | sort`; do \ - for i in $$sub/*.h ; do \ - rm -f $(tooldir)/$$sub/`basename $$i` ; \ - done ; \ - done ; \ - -uninstall-man: - cd $(srcdir); \ - for i in `find . -type f -name '*.2'`; do \ - rm -f $(tooldir)/man/man2/`basename $$i` ; \ - done; \ - for i in `find . -type f -name '*.3'`; do \ - rm -f $(tooldir)/man/man3/`basename $$i` ; \ - done; \ - for i in `find . -type f -name '*.5'`; do \ - rm -f $(tooldir)/man/man5/`basename $$i` ; \ - done; \ - for i in `find . -type f -name '*.7'`; do \ - rm -f $(tooldir)/man/man7/`basename $$i` ; \ - done - -clean: - -rm -f *.o *.dll *.dbg *.a *.exp junk *.base version.cc regexp/*.o winver_stamp *.exe *.d *stamp* *_magic.h sigfe.s cygwin.def globals.h $(srcdir)/tlsoffsets.h $(srcdir)/devices.cc - -@$(MAKE) -C $(bupdir)/cygserver libclean - -maintainer-clean realclean: clean - @echo "This command is intended for maintainers to use;" - @echo "it deletes files that may require special tools to rebuild." - -rm -fr configure - - -# Rule to build cygwin.dll -$(TEST_DLL_NAME): $(LDSCRIPT) dllfixdbg $(DLL_OFILES) $(DLL_IMPORTS) $(LIBSERVER) $(LIBC) $(LIBM) $(API_VER) Makefile winver_stamp - $(CXX) $(CXXFLAGS) -Wl,--gc-sections $(nostdlib) -Wl,-T$(firstword $^) \ - -Wl,--heap=0 -Wl,--out-implib,cygdll.a -shared -o $@ \ - -e $(DLL_ENTRY) $(DEF_FILE) $(DLL_OFILES) version.o winver.o \ - $(MALLOC_OBJ) $(LIBSERVER) $(LIBM) $(LIBC) \ - -lgcc $(DLL_IMPORTS) -Wl,-Map,cygwin.map - @$(word 2,$^) $(OBJDUMP) $(OBJCOPY) $@ ${patsubst %0.dll,%1.dbg,$@} - @ln -f $@ new-$(DLL_NAME) - -# Rule to build libcygwin.a -$(LIB_NAME): $(LIBCOS) | $(TEST_DLL_NAME) - ${srcdir}/mkimport ${toolopts} ${NEW_FUNCTIONS} $@ cygdll.a $^ - -${STATIC_LIB_NAME}: mkstatic ${TEST_DLL_NAME} - perl -d $< -x ${EXCLUDE_STATIC_OFILES} --library=${LIBC} --library=${LIBM} --ar=${AR} $@ cygwin.map - -# Rule to make stub library used by testsuite -# dependency set to $(LIB_NAME) to accommodate make -j2. -$(TEST_LIB_NAME): $(LIB_NAME) - perl -p -e 'BEGIN{binmode(STDIN); binmode(STDOUT);}; s/cygwin1/cygwin0/g' < $? > $@ - -$(LIBSERVER): $(bupdir)/cygserver/Makefile - $(MAKE) -C $(bupdir)/cygserver libcygserver.a - -dll_ofiles: $(DLL_OFILES) - -$(LIBGMON_A): $(GMON_OFILES) $(GMON_START) - $(AR) rcv $(LIBGMON_A) $(GMON_OFILES) - -$(API_VER): $(srcdir)/cygwin.din - @echo Error: Version info is older than DLL API! - -version.cc winver.o: winver_stamp - @ : - -globals.h: mkglobals_h globals.cc - $^ > $@ - -${DLL_OFILES} ${LIBCOS}: globals.h - -shared_info_magic.h: cygmagic shared_info.h - /bin/sh $(word 1,$^) $@ "${COMPILE_CXX} -E -x c++" $(word 2,$^) SHARED_MAGIC 'class shared_info' USER_MAGIC 'class user_info' - -child_info_magic.h: cygmagic child_info.h - /bin/sh $(word 1,$^) $@ "${COMPILE_CXX} -E -x c++" $(word 2,$^) CHILD_INFO_MAGIC 'class child_info' - -dcrt0.o sigproc.o: child_info_magic.h - -shared.o: shared_info_magic.h - -$(srcdir)/devices.cc: gendevices devices.in devices.h - ${wordlist 1,2,$^} $@ - -${CURDIR}/libc.a: ${LIB_NAME} ./libm.a libpthread.a libutil.a - ${speclib} -v ${@F} - -${CURDIR}/libm.a: ${LIB_NAME} $(LIBM) - ${speclib} ${@F} - -libpthread.a: ${LIB_NAME} pthread.o thread.o - ${speclib} ${@F} - -libutil.a: ${LIB_NAME} bsdlib.o - ${speclib} ${@F} - -libdl.a: ${LIB_NAME} dlfcn.o - ${speclib} ${@F} - -libresolv.a: ${LIB_NAME} minires.o - ${speclib} ${@F} - -librt.a: ${LIB_NAME} posix_ipc.o - ${speclib} ${@F} - -${EXTRALIBS}: lib%.a: %.o - $(AR) cru $@ $? - -winver_stamp: mkvers.sh include/cygwin/version.h winver.rc $(DLL_OFILES) - @echo "Making version.o and winver.o";\ - $(SHELL) ${word 1,$^} ${word 2,$^} ${word 3,$^} $(WINDRES) && \ - $(COMPILE_CXX) -c -o version.o version.cc && \ - touch $@ - -Makefile: cygwin.din - -$(DEF_FILE): gendef cygwin.din $(srcdir)/tlsoffsets.h - $^ $@ sigfe.s - -$(srcdir)/tlsoffsets.h: gentls_offsets cygtls.h - $^ $@ $(COMPILE_CXX) -c - -sigfe.s: $(DEF_FILE) - @[ -s $@ ] || \ - { rm -f $(DEF_FILE); $(MAKE) -s -j1 $(DEF_FILE); }; \ - [ -s $@ ] && touch $@ - -sigfe.o: sigfe.s - $(CC) -c -o $@ $< - -winsup.h: config.h - -ctags: CTAGS -tags: CTAGS -CTAGS: - -cd $(srcdir) && ctags -R --regex-C++='/^([a-zA-Z0-9_]*::[a-zA-Z0-9_]*) /\1/f/' . - -deps:=${wildcard *.d} -ifneq (,$(deps)) -include $(deps) -endif - -%: RCS/%,v diff --git a/winsup/cygwin/ROADMAP b/winsup/cygwin/ROADMAP deleted file mode 100644 index fd0387d59..000000000 --- a/winsup/cygwin/ROADMAP +++ /dev/null @@ -1,129 +0,0 @@ - - WINSUP ROADMAP - -The purpose of this document is to give the briefest overview of how -the various parts of cygwin work together and where everything can be -found. The intended audience is people developing the cygwin dll -itself. Comments to dj@cygnus.com. - -=== cygwin1.dll source files - -- overhead -.h winsup autoload debug external shared sync -.cc assert dcrt0 debug external init ntea registry security - shared smallprint strace sync -.din cygwin -.rc winver -.sgml external shared - -- processes -.h sigproc -.cc exec fork pinfo resource signal sigproc spawn wait - -- signals -.cc exceptions window - -- files and I/O -.h delqueue fhandler path select -.cc delqueue dir fhandler* dtable path pipe select tty -.sgml dtable path - -- common unix functions -.h dll_init tz_posixrules -.cc dlfcn dll_init environ errno fcntl flog grp ioctl localtime - malloc passwd scandir strsep syscalls sysconf syslog termios -.c longjmp setjmp -.sgml dll_init - -- unix emulation -.cc heap mmap net times unifo uname - - ---- if MT_SAFE -.h thread -.cc pthread thread - ---- from other places -regex/* -../libiberty/{random,strsignal} -../newlib/* (libc) - -=== libcygwin.a source files - -libccrt0.cc -libcmain.cc -dll_entry.cc -dll_main.cc -getopt.c - -=== gmon (profiling, -pg) - -gcrt0.c -gmon.c gmon.h -mcount.c -profil.c profil.h - -=== entry points - -- normal cygwin program - -newlib/libc/sys/cygwin/crt0.c has mainCRTStartup() and calls cygwin_crt0() - -libccrt0.cc has cygwin_crt0() and calls dll_crt0() - -dcrt0.cc - has dll_crt0() - -Note: dll_init.cc has nothing to do with initializing the cygwin dll. -It initializes the dlls you have dl_open'd. - -- cygwin-built dll - -dll_entry.cc - has a macro for wrapping your dll startup function - (equivalent of DllMain()) in such a way that you get your - cygwin environment set up automatically when your dll is - loaded. - -dll_main.cc - has empty DllMain() in case you don't have your own - -- manually loading cygwin1.dll - -init.cc - has dll_entry() which is called by the OS when the dll is - loaded. It doesn't do much except note if you linked - cygwin1.dll or are manually loading it. - -=== About "fhandlers" - -An fhandler is a file type handler. This is where the unix device -emulation happens. - -dtable.cc maps posix file descriptors to a table of file handlers (type -fhandler) in the dll. It's mostly concerned with managing the table -of descriptors (open, dup, fork, select). Most of the posix I/O -system calls (syscalls.cc) use the fdtab table to call the right -fhandler directly. - -fhandler.cc is the base class; specific types are derived as -appropriate (see fhandler.h). dtable.cc is in charge of selecting and -creating a suitable fhandler when you open a file. path.cc handles -emulated files in /dev (like /dev/null) by returning an FH_* value -from get_device_number (which dtable.cc calls in dtable::build_fhandler). - -Note: if you're looking for read() and write(), they call _read() and -_write() in syscalls.cc. The non-underscored ones are in -newlib/libc/syscalls and just call the underscored ones. - -=== How "fork" works - -It all starts in fork() in fork.cc. - -Set up a pid in the shared memory area for the new child. Use -setjmp() to capture state. First time (parent), set up some stuff and -use CreateProcess to run a second copy of the same executable. The -second copy will note in the shared memory area that it's a fork, and -do the longjmp. They sync up and the parent copies all it's program -memory to the child's address space. There's also code to reload -dlls, map shared memory and mmap'd files, etc. - -Handling the special startup for the child is done in dcrt0.cc in many -places. This case is triggered by a special StartupInfo structure -that's passed from the parent to the child in CreateProcessA. diff --git a/winsup/cygwin/acconfig.h b/winsup/cygwin/acconfig.h deleted file mode 100644 index 0c1dc6610..000000000 --- a/winsup/cygwin/acconfig.h +++ /dev/null @@ -1,11 +0,0 @@ -/* Define if DEBUGGING support is requested. */ -#undef DEBUGGING - -/* Define if GCC supports builtin memset. */ -#undef HAVE_BUILTIN_MEMSET - -/* Define if MALLOC_DEBUGGING support is requested. */ -#undef MALLOC_DEBUG - -/* Define if using new vfork functionality. */ -#undef NEWVFORK diff --git a/winsup/cygwin/aclocal.m4 b/winsup/cygwin/aclocal.m4 deleted file mode 100644 index ecef4244c..000000000 --- a/winsup/cygwin/aclocal.m4 +++ /dev/null @@ -1,875 +0,0 @@ -dnl aclocal.m4 generated automatically by aclocal 1.4-p6 - -dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl This program is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without -dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A -dnl PARTICULAR PURPOSE. - -# lib-prefix.m4 serial 4 (gettext-0.14.2) -dnl Copyright (C) 2001-2005 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and -dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't -dnl require excessive bracketing. -ifdef([AC_HELP_STRING], -[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], -[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) - -dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed -dnl to access previously installed libraries. The basic assumption is that -dnl a user will want packages to use other packages he previously installed -dnl with the same --prefix option. -dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate -dnl libraries, but is otherwise very convenient. -AC_DEFUN([AC_LIB_PREFIX], -[ - AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) - AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) - dnl By default, look in $includedir and $libdir. - use_additional=yes - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - AC_LIB_ARG_WITH([lib-prefix], -[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib - --without-lib-prefix don't search for libraries in includedir and libdir], -[ - if test "X$withval" = "Xno"; then - use_additional=no - else - if test "X$withval" = "X"; then - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - else - additional_includedir="$withval/include" - additional_libdir="$withval/lib" - fi - fi -]) - if test $use_additional = yes; then - dnl Potentially add $additional_includedir to $CPPFLAGS. - dnl But don't add it - dnl 1. if it's the standard /usr/include, - dnl 2. if it's already present in $CPPFLAGS, - dnl 3. if it's /usr/local/include and we are using GCC on Linux, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_includedir" != "X/usr/include"; then - haveit= - for x in $CPPFLAGS; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-I$additional_includedir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test "X$additional_includedir" = "X/usr/local/include"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - if test -d "$additional_includedir"; then - dnl Really add $additional_includedir to $CPPFLAGS. - CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" - fi - fi - fi - fi - dnl Potentially add $additional_libdir to $LDFLAGS. - dnl But don't add it - dnl 1. if it's the standard /usr/lib, - dnl 2. if it's already present in $LDFLAGS, - dnl 3. if it's /usr/local/lib and we are using GCC on Linux, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_libdir" != "X/usr/lib"; then - haveit= - for x in $LDFLAGS; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test "X$additional_libdir" = "X/usr/local/lib"; then - if test -n "$GCC"; then - case $host_os in - linux*) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - dnl Really add $additional_libdir to $LDFLAGS. - LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" - fi - fi - fi - fi - fi -]) - -dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, -dnl acl_final_exec_prefix, containing the values to which $prefix and -dnl $exec_prefix will expand at the end of the configure script. -AC_DEFUN([AC_LIB_PREPARE_PREFIX], -[ - dnl Unfortunately, prefix and exec_prefix get only finally determined - dnl at the end of configure. - if test "X$prefix" = "XNONE"; then - acl_final_prefix="$ac_default_prefix" - else - acl_final_prefix="$prefix" - fi - if test "X$exec_prefix" = "XNONE"; then - acl_final_exec_prefix='${prefix}' - else - acl_final_exec_prefix="$exec_prefix" - fi - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" - prefix="$acl_save_prefix" -]) - -dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the -dnl variables prefix and exec_prefix bound to the values they will have -dnl at the end of the configure script. -AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], -[ - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - $1 - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" -]) - -# lib-link.m4 serial 6 (gettext-0.14.3) -dnl Copyright (C) 2001-2005 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -AC_PREREQ(2.50) - -dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and -dnl the libraries corresponding to explicit and implicit dependencies. -dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and -dnl augments the CPPFLAGS variable. -AC_DEFUN([AC_LIB_LINKFLAGS], -[ - AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) - AC_REQUIRE([AC_LIB_RPATH]) - define([Name],[translit([$1],[./-], [___])]) - define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) - AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ - AC_LIB_LINKFLAGS_BODY([$1], [$2]) - ac_cv_lib[]Name[]_libs="$LIB[]NAME" - ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" - ac_cv_lib[]Name[]_cppflags="$INC[]NAME" - ]) - LIB[]NAME="$ac_cv_lib[]Name[]_libs" - LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" - INC[]NAME="$ac_cv_lib[]Name[]_cppflags" - AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) - AC_SUBST([LIB]NAME) - AC_SUBST([LTLIB]NAME) - dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the - dnl results of this search when this library appears as a dependency. - HAVE_LIB[]NAME=yes - undefine([Name]) - undefine([NAME]) -]) - -dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode) -dnl searches for libname and the libraries corresponding to explicit and -dnl implicit dependencies, together with the specified include files and -dnl the ability to compile and link the specified testcode. If found, it -dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and -dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and -dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs -dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty. -AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], -[ - AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) - AC_REQUIRE([AC_LIB_RPATH]) - define([Name],[translit([$1],[./-], [___])]) - define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) - - dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME - dnl accordingly. - AC_LIB_LINKFLAGS_BODY([$1], [$2]) - - dnl Add $INC[]NAME to CPPFLAGS before performing the following checks, - dnl because if the user has installed lib[]Name and not disabled its use - dnl via --without-lib[]Name-prefix, he wants to use it. - ac_save_CPPFLAGS="$CPPFLAGS" - AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) - - AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ - ac_save_LIBS="$LIBS" - LIBS="$LIBS $LIB[]NAME" - AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no]) - LIBS="$ac_save_LIBS" - ]) - if test "$ac_cv_lib[]Name" = yes; then - HAVE_LIB[]NAME=yes - AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.]) - AC_MSG_CHECKING([how to link with lib[]$1]) - AC_MSG_RESULT([$LIB[]NAME]) - else - HAVE_LIB[]NAME=no - dnl If $LIB[]NAME didn't lead to a usable library, we don't need - dnl $INC[]NAME either. - CPPFLAGS="$ac_save_CPPFLAGS" - LIB[]NAME= - LTLIB[]NAME= - fi - AC_SUBST([HAVE_LIB]NAME) - AC_SUBST([LIB]NAME) - AC_SUBST([LTLIB]NAME) - undefine([Name]) - undefine([NAME]) -]) - -dnl Determine the platform dependent parameters needed to use rpath: -dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator, -dnl hardcode_direct, hardcode_minus_L. -AC_DEFUN([AC_LIB_RPATH], -[ - dnl Tell automake >= 1.10 to complain if config.rpath is missing. - m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])]) - AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS - AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld - AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host - AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir - AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [ - CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ - ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh - . ./conftest.sh - rm -f ./conftest.sh - acl_cv_rpath=done - ]) - wl="$acl_cv_wl" - libext="$acl_cv_libext" - shlibext="$acl_cv_shlibext" - hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" - hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" - hardcode_direct="$acl_cv_hardcode_direct" - hardcode_minus_L="$acl_cv_hardcode_minus_L" - dnl Determine whether the user wants rpath handling at all. - AC_ARG_ENABLE(rpath, - [ --disable-rpath do not hardcode runtime library paths], - :, enable_rpath=yes) -]) - -dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and -dnl the libraries corresponding to explicit and implicit dependencies. -dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. -AC_DEFUN([AC_LIB_LINKFLAGS_BODY], -[ - define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) - dnl By default, look in $includedir and $libdir. - use_additional=yes - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - AC_LIB_ARG_WITH([lib$1-prefix], -[ --with-lib$1-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib - --without-lib$1-prefix don't search for lib$1 in includedir and libdir], -[ - if test "X$withval" = "Xno"; then - use_additional=no - else - if test "X$withval" = "X"; then - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - else - additional_includedir="$withval/include" - additional_libdir="$withval/lib" - fi - fi -]) - dnl Search the library and its dependencies in $additional_libdir and - dnl $LDFLAGS. Using breadth-first-seach. - LIB[]NAME= - LTLIB[]NAME= - INC[]NAME= - rpathdirs= - ltrpathdirs= - names_already_handled= - names_next_round='$1 $2' - while test -n "$names_next_round"; do - names_this_round="$names_next_round" - names_next_round= - for name in $names_this_round; do - already_handled= - for n in $names_already_handled; do - if test "$n" = "$name"; then - already_handled=yes - break - fi - done - if test -z "$already_handled"; then - names_already_handled="$names_already_handled $name" - dnl See if it was already located by an earlier AC_LIB_LINKFLAGS - dnl or AC_LIB_HAVE_LINKFLAGS call. - uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` - eval value=\"\$HAVE_LIB$uppername\" - if test -n "$value"; then - if test "$value" = yes; then - eval value=\"\$LIB$uppername\" - test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" - eval value=\"\$LTLIB$uppername\" - test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" - else - dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined - dnl that this library doesn't exist. So just drop it. - : - fi - else - dnl Search the library lib$name in $additional_libdir and $LDFLAGS - dnl and the already constructed $LIBNAME/$LTLIBNAME. - found_dir= - found_la= - found_so= - found_a= - if test $use_additional = yes; then - if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then - found_dir="$additional_libdir" - found_so="$additional_libdir/lib$name.$shlibext" - if test -f "$additional_libdir/lib$name.la"; then - found_la="$additional_libdir/lib$name.la" - fi - else - if test -f "$additional_libdir/lib$name.$libext"; then - found_dir="$additional_libdir" - found_a="$additional_libdir/lib$name.$libext" - if test -f "$additional_libdir/lib$name.la"; then - found_la="$additional_libdir/lib$name.la" - fi - fi - fi - fi - if test "X$found_dir" = "X"; then - for x in $LDFLAGS $LTLIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - case "$x" in - -L*) - dir=`echo "X$x" | sed -e 's/^X-L//'` - if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then - found_dir="$dir" - found_so="$dir/lib$name.$shlibext" - if test -f "$dir/lib$name.la"; then - found_la="$dir/lib$name.la" - fi - else - if test -f "$dir/lib$name.$libext"; then - found_dir="$dir" - found_a="$dir/lib$name.$libext" - if test -f "$dir/lib$name.la"; then - found_la="$dir/lib$name.la" - fi - fi - fi - ;; - esac - if test "X$found_dir" != "X"; then - break - fi - done - fi - if test "X$found_dir" != "X"; then - dnl Found the library. - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" - if test "X$found_so" != "X"; then - dnl Linking with a shared library. We attempt to hardcode its - dnl directory into the executable's runpath, unless it's the - dnl standard /usr/lib. - if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then - dnl No hardcoding is needed. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - else - dnl Use an explicit option to hardcode DIR into the resulting - dnl binary. - dnl Potentially add DIR to ltrpathdirs. - dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. - haveit= - for x in $ltrpathdirs; do - if test "X$x" = "X$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - ltrpathdirs="$ltrpathdirs $found_dir" - fi - dnl The hardcoding into $LIBNAME is system dependent. - if test "$hardcode_direct" = yes; then - dnl Using DIR/libNAME.so during linking hardcodes DIR into the - dnl resulting binary. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - else - if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then - dnl Use an explicit option to hardcode DIR into the resulting - dnl binary. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - dnl Potentially add DIR to rpathdirs. - dnl The rpathdirs will be appended to $LIBNAME at the end. - haveit= - for x in $rpathdirs; do - if test "X$x" = "X$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - rpathdirs="$rpathdirs $found_dir" - fi - else - dnl Rely on "-L$found_dir". - dnl But don't add it if it's already contained in the LDFLAGS - dnl or the already constructed $LIBNAME - haveit= - for x in $LDFLAGS $LIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" - fi - if test "$hardcode_minus_L" != no; then - dnl FIXME: Not sure whether we should use - dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" - dnl here. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - else - dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH - dnl here, because this doesn't fit in flags passed to the - dnl compiler. So give up. No hardcoding. This affects only - dnl very old systems. - dnl FIXME: Not sure whether we should use - dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" - dnl here. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" - fi - fi - fi - fi - else - if test "X$found_a" != "X"; then - dnl Linking with a static library. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" - else - dnl We shouldn't come here, but anyway it's good to have a - dnl fallback. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" - fi - fi - dnl Assume the include files are nearby. - additional_includedir= - case "$found_dir" in - */lib | */lib/) - basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'` - additional_includedir="$basedir/include" - ;; - esac - if test "X$additional_includedir" != "X"; then - dnl Potentially add $additional_includedir to $INCNAME. - dnl But don't add it - dnl 1. if it's the standard /usr/include, - dnl 2. if it's /usr/local/include and we are using GCC on Linux, - dnl 3. if it's already present in $CPPFLAGS or the already - dnl constructed $INCNAME, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_includedir" != "X/usr/include"; then - haveit= - if test "X$additional_includedir" = "X/usr/local/include"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - for x in $CPPFLAGS $INC[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-I$additional_includedir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_includedir"; then - dnl Really add $additional_includedir to $INCNAME. - INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" - fi - fi - fi - fi - fi - dnl Look for dependencies. - if test -n "$found_la"; then - dnl Read the .la file. It defines the variables - dnl dlname, library_names, old_library, dependency_libs, current, - dnl age, revision, installed, dlopen, dlpreopen, libdir. - save_libdir="$libdir" - case "$found_la" in - */* | *\\*) . "$found_la" ;; - *) . "./$found_la" ;; - esac - libdir="$save_libdir" - dnl We use only dependency_libs. - for dep in $dependency_libs; do - case "$dep" in - -L*) - additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` - dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. - dnl But don't add it - dnl 1. if it's the standard /usr/lib, - dnl 2. if it's /usr/local/lib and we are using GCC on Linux, - dnl 3. if it's already present in $LDFLAGS or the already - dnl constructed $LIBNAME, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_libdir" != "X/usr/lib"; then - haveit= - if test "X$additional_libdir" = "X/usr/local/lib"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - haveit= - for x in $LDFLAGS $LIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - dnl Really add $additional_libdir to $LIBNAME. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" - fi - fi - haveit= - for x in $LDFLAGS $LTLIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - dnl Really add $additional_libdir to $LTLIBNAME. - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" - fi - fi - fi - fi - ;; - -R*) - dir=`echo "X$dep" | sed -e 's/^X-R//'` - if test "$enable_rpath" != no; then - dnl Potentially add DIR to rpathdirs. - dnl The rpathdirs will be appended to $LIBNAME at the end. - haveit= - for x in $rpathdirs; do - if test "X$x" = "X$dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - rpathdirs="$rpathdirs $dir" - fi - dnl Potentially add DIR to ltrpathdirs. - dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. - haveit= - for x in $ltrpathdirs; do - if test "X$x" = "X$dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - ltrpathdirs="$ltrpathdirs $dir" - fi - fi - ;; - -l*) - dnl Handle this in the next round. - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` - ;; - *.la) - dnl Handle this in the next round. Throw away the .la's - dnl directory; it is already contained in a preceding -L - dnl option. - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` - ;; - *) - dnl Most likely an immediate library name. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" - ;; - esac - done - fi - else - dnl Didn't find the library; assume it is in the system directories - dnl known to the linker and runtime loader. (All the system - dnl directories known to the linker should also be known to the - dnl runtime loader, otherwise the system is severely misconfigured.) - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" - fi - fi - fi - done - done - if test "X$rpathdirs" != "X"; then - if test -n "$hardcode_libdir_separator"; then - dnl Weird platform: only the last -rpath option counts, the user must - dnl pass all path elements in one option. We can arrange that for a - dnl single library, but not when more than one $LIBNAMEs are used. - alldirs= - for found_dir in $rpathdirs; do - alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir" - done - dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl. - acl_save_libdir="$libdir" - libdir="$alldirs" - eval flag=\"$hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" - else - dnl The -rpath options are cumulative. - for found_dir in $rpathdirs; do - acl_save_libdir="$libdir" - libdir="$found_dir" - eval flag=\"$hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" - done - fi - fi - if test "X$ltrpathdirs" != "X"; then - dnl When using libtool, the option that works for both libraries and - dnl executables is -R. The -R options are cumulative. - for found_dir in $ltrpathdirs; do - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" - done - fi -]) - -dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, -dnl unless already present in VAR. -dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes -dnl contains two or three consecutive elements that belong together. -AC_DEFUN([AC_LIB_APPENDTOVAR], -[ - for element in [$2]; do - haveit= - for x in $[$1]; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X$element"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - [$1]="${[$1]}${[$1]:+ }$element" - fi - done -]) - -# lib-ld.m4 serial 3 (gettext-0.13) -dnl Copyright (C) 1996-2003 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl Subroutines of libtool.m4, -dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision -dnl with libtool.m4. - -dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no. -AC_DEFUN([AC_LIB_PROG_LD_GNU], -[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld, -[# I'd rather use --version here, but apparently some GNU ld's only accept -v. -case `$LD -v 2>&1 conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - AC_MSG_CHECKING([for ld used by GCC]) - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [[\\/]* | [A-Za-z]:[\\/]*)] - [re_direlt='/[^/][^/]*/\.\./'] - # Canonicalize the path of ld - ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` - while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do - ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - AC_MSG_CHECKING([for GNU ld]) -else - AC_MSG_CHECKING([for non-GNU ld]) -fi -AC_CACHE_VAL(acl_cv_path_LD, -[if test -z "$LD"; then - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - acl_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some GNU ld's only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in - *GNU* | *'with BFD'*) - test "$with_gnu_ld" != no && break ;; - *) - test "$with_gnu_ld" != yes && break ;; - esac - fi - done - IFS="$ac_save_ifs" -else - acl_cv_path_LD="$LD" # Let the user override the test with a path. -fi]) -LD="$acl_cv_path_LD" -if test -n "$LD"; then - AC_MSG_RESULT($LD) -else - AC_MSG_RESULT(no) -fi -test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) -AC_LIB_PROG_LD_GNU -]) - -dnl This provides configure definitions used by all the winsup -dnl configure.in files. - -# FIXME: We temporarily define our own version of AC_PROG_CC. This is -# copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS. We -# are probably using a cross compiler, which will not be able to fully -# link an executable. This should really be fixed in autoconf -# itself. - -AC_DEFUN([LIB_AC_PROG_CC_GNU], -[AC_CACHE_CHECK(whether we are using GNU C, ac_cv_prog_gcc, -[dnl The semicolon is to pacify NeXT's syntax-checking cpp. -cat > conftest.c </dev/null 2>&1; then - ac_cv_prog_gcc=yes -else - ac_cv_prog_gcc=no -fi])]) - -AC_DEFUN([LIB_AC_PROG_CC], -[AC_BEFORE([$0], [AC_PROG_CPP])dnl -AC_CHECK_TOOL(CC, gcc, gcc) -: ${CC:=gcc} -AC_PROG_CC -test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH]) -]) - -AC_DEFUN([LIB_AC_PROG_CXX], -[AC_BEFORE([$0], [AC_PROG_CPP])dnl -AC_CHECK_TOOL(CXX, g++, g++) -if test -z "$CXX"; then - AC_CHECK_TOOL(CXX, g++, c++, , , ) - : ${CXX:=g++} - AC_PROG_CXX - test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH]) -fi - -CXXFLAGS='$(CFLAGS)' -]) - diff --git a/winsup/cygwin/analyze_sigfe b/winsup/cygwin/analyze_sigfe deleted file mode 100755 index 0b9b7219f..000000000 --- a/winsup/cygwin/analyze_sigfe +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/perl -s -# Copyright 2006 Red Hat, Inc. -# -# This file is part of Cygwin. -# -# This software is a copyrighted work licensed under the terms of the -# Cygwin license. Please consult the file "CYGWIN_LICENSE" for -# details. - -# This will do a crude test to see if the (NO)?SIGFE stuff is used properly -# in cygwin.din. It is not perfect so do not use it to do a wholesale replacement. -# -# Input is the output of 'objdump --disassemble --demangle cygwin0.dll'. -# -use strict; -use vars qw'$v'; -sub star($); - -my %funcs; -my $func = ''; - -$| = 1; -while (<>) { - /^610.....\s+<([^\(>]+).*?:/o and do { - $func = $1; - $funcs{$func} = {} unless defined $funcs{$func}; - next; - }; - $func and /call\s+\S+\s+<([^\(>]+)/o and do { - my $called = $1; - $funcs{$func}{$called} = 1; - if ($called =~ /^[A-Z].*@/o || ($called = $funcs{$called}{-uses_kernel})) { - $funcs{$func}{-uses_kernel} ||= $called; - my @a = ($func); - while (my $f = shift @a) { - for my $k (keys %funcs) { - if ($funcs{$k}{$f} && !$funcs{$k}{-uses_kernel}) { - $funcs{$k}{-uses_kernel} = $called; - push(@a, $k); - } - } - } - } - next; - }; -} - -if ($v) { - for my $k (sort keys %funcs) { - print star($funcs{$k}), $k, $funcs{$k}{-uses_kernel} ? " ($funcs{$k}{-uses_kernel})\n" : "\n"; - my $indent = ' '; - for (sort keys %{$funcs{$k}}) { - next if /^-/o; - print $indent, $_, star($funcs{$k}); - $indent = ' '; - } - print "\n"; - } -} - -open(DIN, '<', 'cygwin.din') or die "$0: couldn't open cygwin.din - $!\n"; -while () { - my $line = $_; - /^LIBRARY\s+/o and next; - /^\s*$/ and next; - /^EXPORTS/o and next; - / DATA$/o and next; - my $sigfe = (/\s+((?:NO)?SIGFE)\s*$/o)[0] !~ /^NO/o; - s/\s+((?:NO)?SIGFE)\s*$//o; - my $func = (/\s+=\s+(\S+)/o)[0] || (/^\s*(\S+)/o)[0]; - if (!defined($funcs{$func})) { - warn "hmm. couldn't find $func in disassembled output\n"; - } elsif (!!$funcs{$func}{-uses_kernel} != $sigfe) { - warn "mismatch detected: $line"; - } -} - -sub star($) { - return $_[0]->{-uses_kernel} ? '*' : ''; -} diff --git a/winsup/cygwin/assert.cc b/winsup/cygwin/assert.cc deleted file mode 100644 index a47a3827f..000000000 --- a/winsup/cygwin/assert.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* assert.cc: Handle the assert macro for WIN32. - - Copyright 1997, 1998, 2000, 2001, 2007, 2008, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include - -#include -#include - -/* This function is called when the assert macro fails. This will - override the function of the same name in newlib. */ - -extern "C" void -__assert (const char *file, int line, const char *failedexpr) -{ - __assert_func (file, line, NULL, failedexpr); -} - -extern "C" void -__assert_func (const char *file, int line, const char *func, - const char *failedexpr) -{ - HANDLE h; - - /* If we don't have a console in a Windows program, then bring up a - message box for the assertion failure. */ - - h = CreateFile ("CONOUT$", GENERIC_WRITE, FILE_SHARE_WRITE, &sec_none_nih, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (h == INVALID_HANDLE_VALUE) - { - char *buf; - - buf = (char *) alloca (100 + strlen (failedexpr)); - __small_sprintf (buf, "Failed assertion\n\t%s\nat line %d of file %s%s%s", - failedexpr, line, file, - func ? "\nin function " : "", func ? func : ""); - MessageBox (NULL, buf, NULL, MB_OK | MB_ICONERROR | MB_TASKMODAL); - } - else - { - CloseHandle (h); - small_printf ("assertion \"%s\" failed: file \"%s\", line %d%s%s\n", - failedexpr, file, line, - func ? ", function: " : "", func ? func : ""); - } - -#ifdef DEBUGGING - try_to_debug (); -#endif - abort (); // FIXME: Someday this should work. - - /* NOTREACHED */ -} diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc deleted file mode 100644 index eb16961c9..000000000 --- a/winsup/cygwin/autoload.cc +++ /dev/null @@ -1,465 +0,0 @@ -/* autoload.cc: all dynamic load stuff. - - Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, - 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "miscfuncs.h" -#define USE_SYS_TYPES_FD_SET -#include - -bool NO_COPY wsock_started; - -/* Macro for defining "auto-load" functions. - * Note that this is self-modifying code *gasp*. - * The first invocation of a routine will trigger the loading of - * the DLL. This will then be followed by the discovery of - * the procedure's entry point, which is placed into the location - * pointed to by the stack pointer. This code then changes - * the "call" operand which invoked it to a "jmp" which will - * transfer directly to the DLL function on the next invocation. - * - * Subsequent calls to routines whose transfer address has not been - * determined will skip the "load the dll" step, starting at the - * "discovery of the entry point" step. - * - * So, immediately following the the call to one of the above routines - * we have: - * DLL info (4 bytes) Pointer to a block of information concerning - * the DLL (see below). - * DLL args (4 bytes) The number of arguments pushed on the stack by - * the call. If this is an odd value then this - * is a flag that non-existence of this function - * is not a fatal error - * func name (n bytes) asciz string containing the name of the function - * to be loaded. - * - * The DLL info block consists of the following - * load_state (4 bytes) Pointer to a word containing the routine used - * to eventually invoke the function. Initially - * points to an init function which loads the - * DLL, gets the process's load address, - * changes the contents here to point to the - * function address, and changes the call *(%eax) - * to a jmp func. If the initialization has been - * done, only the load part is done. - * DLL handle (4 bytes) The handle to use when loading the DLL. - * DLL locker (4 bytes) Word to use to avoid multi-thread access during - * initialization. - * extra init (4 bytes) Extra initialization function. - * DLL name (n bytes) asciz string containing the name of the DLL. - */ - -/* LoadDLLprime is used to prime the DLL info information, providing an - additional initialization routine to call prior to calling the first - function. */ -#define LoadDLLprime(dllname, init_also) __asm__ (" \n\ -.ifndef " #dllname "_primed \n\ - .section .data_cygwin_nocopy,\"w\" \n\ - .align 4 \n\ -."#dllname "_info: \n\ - .long _std_dll_init \n\ - .long 0 \n\ - .long -1 \n\ - .long " #init_also " \n\ - .asciz \"" #dllname "\" \n\ - .text \n\ - .set " #dllname "_primed, 1 \n\ -.endif \n\ -"); - -/* Create a "decorated" name */ -#define mangle(name, n) #name "@" #n - -/* Standard DLL load macro. May invoke a fatal error if the function isn't - found. */ -#define LoadDLLfunc(name, n, dllname) \ - LoadDLLfuncEx (name, n, dllname, 0) -#define LoadDLLfuncEx(name, n, dllname, notimp) \ - LoadDLLfuncEx2(name, n, dllname, notimp, 0) -#define LoadDLLfuncEx2(name, n, dllname, notimp, err) \ - LoadDLLfuncEx3(name, n, dllname, notimp, err, 0) - -/* Main DLL setup stuff. */ -#define LoadDLLfuncEx3(name, n, dllname, notimp, err, fn) \ - LoadDLLprime (dllname, dll_func_load) \ - __asm__ (" \n\ - .section ." #dllname "_autoload_text,\"wx\" \n\ - .global _" mangle (name, n) " \n\ - .global _win32_" mangle (name, n) " \n\ - .align 8 \n\ -_" mangle (name, n) ": \n\ -_win32_" mangle (name, n) ": \n\ - .byte 0xe9 \n\ - .long -4 + 1f - . \n\ -1:movl (2f),%eax \n\ - call *(%eax) \n\ -2:.long ." #dllname "_info \n\ - .long (" #n "+" #notimp ") | (((" #err ") & 0xff) <<16) | (((" #fn ") & 0xff) << 24) \n\ - .asciz \"" #name "\" \n\ - .text \n\ -"); - -/* DLL loader helper functions used during initialization. */ - -/* The function which finds the address, given the name and overwrites - the call so that future invocations go straight to the function in - the DLL. */ -extern "C" void dll_func_load () __asm__ ("dll_func_load"); - -/* Called by the primary initialization function "init_std_dll" to - setup the stack and eliminate future calls to init_std_dll for other - functions from this DLL. */ -extern "C" void dll_chain () __asm__ ("dll_chain"); - -extern "C" { - -__asm__ (" \n\ - .text \n\ -msg1: \n\ - .ascii \"couldn't dynamically determine load address for '%s' (handle %p), %E\\0\"\n\ - \n\ - .align 32 \n\ -noload: \n\ - popl %edx # Get the address of the information block\n\ - movl 4(%edx),%eax # Should we 'ignore' the lack \n\ - test $1,%eax # of this function? \n\ - jz 1f # Nope. \n\ - decl %eax # Yes. This is the # of bytes + 1 \n\ - popl %edx # Caller's caller \n\ - addl %eax,%esp # Pop off bytes \n\ - andl $0xffff0000,%eax# upper word \n\ - subl %eax,%esp # adjust for possible return value \n\ - pushl %eax # Save for later \n\ - movl $127,%eax # ERROR_PROC_NOT_FOUND \n\ - pushl %eax # First argument \n\ - call _SetLastError@4 # Set it \n\ - popl %eax # Get back argument \n\ - sarl $16,%eax # return value in high order word \n\ - jmp *%edx # Return \n\ -1: \n\ - movl (%edx),%eax # Handle value \n\ - pushl 4(%eax) \n\ - leal 8(%edx),%eax # Location of name of function \n\ - push %eax \n\ - push $msg1 # The message \n\ - call ___api_fatal # Print message. Never returns \n\ - \n\ - .globl dll_func_load \n\ -dll_func_load: \n\ - movl (%esp),%eax # 'Return address' contains load info \n\ - addl $8,%eax # Address of name of function to load \n\ - pushl %eax # Second argument \n\ - movl -8(%eax),%eax # Where handle lives \n\ - movl 4(%eax),%eax # Address of Handle to DLL \n\ - pushl %eax # Handle to DLL \n\ - call _GetProcAddress@8# Load it \n\ - test %eax,%eax # Success? \n\ - jne gotit # Yes \n\ - jmp noload # Issue an error or return \n\ -gotit: \n\ - popl %edx # Pointer to 'return address' \n\ - subl %edx,%eax # Make it relative \n\ - addl $7,%eax # Tweak \n\ - subl $12,%edx # Point to jmp \n\ - movl %eax,1(%edx) # Move relative address after jump \n\ - jmp *%edx # Jump to actual function \n\ - \n\ - .global dll_chain \n\ -dll_chain: \n\ - pushl %eax # Restore 'return address' \n\ - jmp *%edx # Jump to next init function \n\ -"); - -/* C representations of the two info blocks described above. - FIXME: These structures confuse gdb for some reason. GDB can print - the whole structure but has problems with the name field? */ -struct dll_info -{ - DWORD load_state; - HANDLE handle; - LONG here; - void (*init) (); - char name[]; -}; - -struct func_info -{ - struct dll_info *dll; - LONG decoration; - char name[]; -}; - -/* Mechanism for setting up info for passing to dll_chain routines. */ -union retchain -{ - struct {long high; long low;}; - long long ll; -}; - -/* The standard DLL initialization routine. */ -__attribute__ ((used, noinline)) static long long -std_dll_init () -{ - HANDLE h; - struct func_info *func = (struct func_info *) __builtin_return_address (0); - struct dll_info *dll = func->dll; - retchain ret; - - if (InterlockedIncrement (&dll->here)) - do - { - InterlockedDecrement (&dll->here); - low_priority_sleep (0); - } - while (InterlockedIncrement (&dll->here)); - else if (!dll->handle) - { - unsigned fpu_control = 0; - __asm__ __volatile__ ("fnstcw %0": "=m" (fpu_control)); - if ((h = LoadLibrary (dll->name)) != NULL) - { - __asm__ __volatile__ ("fldcw %0": : "m" (fpu_control)); - dll->handle = h; - } - else if (!(func->decoration & 1)) - api_fatal ("could not load %s, %E", dll->name); - else - dll->handle = INVALID_HANDLE_VALUE; - } - - InterlockedDecrement (&dll->here); - - /* Kludge alert. Redirects the return address to dll_chain. */ - __asm__ __volatile__ (" \n\ - movl $dll_chain,4(%ebp) \n\ - "); - - /* Set "arguments for dll_chain. */ - ret.low = (long) dll->init; - ret.high = (long) func; - return ret.ll; -} - -/* Initialization function for winsock stuff. */ -WSADATA NO_COPY wsadata; -__attribute__ ((used, noinline, regparm(1))) static long long -wsock_init () -{ - static LONG NO_COPY here = -1L; - struct func_info *func = (struct func_info *) __builtin_return_address (0); - struct dll_info *dll = func->dll; - - while (InterlockedIncrement (&here)) - { - InterlockedDecrement (&here); - low_priority_sleep (0); - } - - if (!wsock_started) - { - int (*wsastartup) (int, WSADATA *); - - /* Don't use autoload to load WSAStartup to eliminate recursion. */ - wsastartup = (int (*)(int, WSADATA *)) - GetProcAddress ((HMODULE) (dll->handle), "WSAStartup"); - if (wsastartup) - { - int res = wsastartup ((2<<8) | 2, &wsadata); - - debug_printf ("res %d", res); - debug_printf ("wVersion %d", wsadata.wVersion); - debug_printf ("wHighVersion %d", wsadata.wHighVersion); - debug_printf ("szDescription %s", wsadata.szDescription); - debug_printf ("szSystemStatus %s", wsadata.szSystemStatus); - debug_printf ("iMaxSockets %d", wsadata.iMaxSockets); - debug_printf ("iMaxUdpDg %d", wsadata.iMaxUdpDg); - debug_printf ("lpVendorInfo %d", wsadata.lpVendorInfo); - - wsock_started = 1; - } - } - - /* Kludge alert. Redirects the return address to dll_chain. */ - __asm__ __volatile__ (" \n\ - movl $dll_chain,4(%ebp) \n\ - "); - - InterlockedDecrement (&here); - - volatile retchain ret; - /* Set "arguments for dll_chain. */ - ret.low = (long) dll_func_load; - ret.high = (long) func; - return ret.ll; -} - -LoadDLLprime (ws2_32, _wsock_init) - -/* 127 == ERROR_PROC_NOT_FOUND */ -LoadDLLfuncEx2 (DsGetDcNameW, 24, netapi32, 1, 127) -LoadDLLfunc (NetApiBufferFree, 4, netapi32) -LoadDLLfuncEx (NetGetAnyDCName, 12, netapi32, 1) -LoadDLLfuncEx (NetGetDCName, 12, netapi32, 1) -LoadDLLfunc (NetUserGetLocalGroups, 32, netapi32) -LoadDLLfunc (NetUserGetGroups, 28, netapi32) -LoadDLLfunc (NetUserGetInfo, 16, netapi32) - -/* 0xc000007a == STATUS_PROCEDURE_NOT_FOUND */ -#define LoadDLLfuncNt(name, n, dllname) \ - LoadDLLfuncEx2(name, n, dllname, 1, 0xc000007a) -LoadDLLfuncNt (NtCommitTransaction, 8, ntdll) -LoadDLLfuncNt (NtCreateTransaction, 40, ntdll) -LoadDLLfuncNt (NtRollbackTransaction, 8, ntdll) -LoadDLLfuncNt (RtlGetCurrentTransaction, 0, ntdll) -LoadDLLfuncNt (RtlSetCurrentTransaction, 4, ntdll) - -LoadDLLfuncEx (EnumProcessModules, 16, psapi, 1) -LoadDLLfuncEx (GetModuleFileNameExW, 16, psapi, 1) -LoadDLLfuncEx (GetModuleInformation, 16, psapi, 1) -LoadDLLfuncEx (GetProcessMemoryInfo, 12, psapi, 1) -LoadDLLfuncEx (QueryWorkingSet, 12, psapi, 1) - -LoadDLLfuncEx (LsaDeregisterLogonProcess, 4, secur32, 1) -LoadDLLfuncEx (LsaFreeReturnBuffer, 4, secur32, 1) -LoadDLLfuncEx (LsaLogonUser, 56, secur32, 1) -LoadDLLfuncEx (LsaLookupAuthenticationPackage, 12, secur32, 1) -LoadDLLfuncEx (LsaRegisterLogonProcess, 12, secur32, 1) - -LoadDLLfunc (CharNextExA, 12, user32) -LoadDLLfunc (CloseClipboard, 0, user32) -LoadDLLfunc (CloseDesktop, 4, user32) -LoadDLLfunc (CloseWindowStation, 4, user32) -LoadDLLfunc (CreateDesktopW, 24, user32) -LoadDLLfunc (CreateWindowExA, 48, user32) -LoadDLLfunc (CreateWindowStationW, 16, user32) -LoadDLLfunc (DefWindowProcA, 16, user32) -LoadDLLfunc (DispatchMessageA, 4, user32) -LoadDLLfunc (EmptyClipboard, 0, user32) -LoadDLLfunc (FindWindowA, 8, user32) -LoadDLLfunc (GetClipboardData, 4, user32) -LoadDLLfunc (GetForegroundWindow, 0, user32) -LoadDLLfunc (GetKeyboardLayout, 4, user32) -LoadDLLfunc (GetMessageA, 16, user32) -LoadDLLfunc (GetPriorityClipboardFormat, 8, user32) -LoadDLLfunc (GetProcessWindowStation, 0, user32) -LoadDLLfunc (GetThreadDesktop, 4, user32) -LoadDLLfunc (GetWindowThreadProcessId, 8, user32) -LoadDLLfunc (GetUserObjectInformationW, 20, user32) -LoadDLLfunc (MessageBeep, 4, user32) -LoadDLLfunc (MessageBoxA, 16, user32) -LoadDLLfunc (MsgWaitForMultipleObjects, 20, user32) -LoadDLLfunc (OpenClipboard, 4, user32) -LoadDLLfunc (PeekMessageA, 20, user32) -LoadDLLfunc (PostMessageA, 16, user32) -LoadDLLfunc (PostQuitMessage, 4, user32) -LoadDLLfunc (RegisterClassA, 4, user32) -LoadDLLfunc (RegisterClipboardFormatA, 4, user32) -LoadDLLfunc (SendMessageA, 16, user32) -LoadDLLfunc (SetClipboardData, 8, user32) -LoadDLLfunc (SetParent, 8, user32) -LoadDLLfunc (SetThreadDesktop, 4, user32) -LoadDLLfunc (SetProcessWindowStation, 4, user32) -LoadDLLfuncEx (ShowWindowAsync, 8, user32, 1) - -LoadDLLfunc (accept, 12, ws2_32) -LoadDLLfunc (bind, 12, ws2_32) -LoadDLLfunc (closesocket, 4, ws2_32) -LoadDLLfunc (connect, 12, ws2_32) -LoadDLLfunc (gethostbyaddr, 12, ws2_32) -LoadDLLfunc (gethostbyname, 4, ws2_32) -LoadDLLfuncEx2 (gethostname, 8, ws2_32, 1, 1) -LoadDLLfunc (getpeername, 12, ws2_32) -LoadDLLfunc (getprotobyname, 4, ws2_32) -LoadDLLfunc (getprotobynumber, 4, ws2_32) -LoadDLLfunc (getservbyname, 8, ws2_32) -LoadDLLfunc (getservbyport, 8, ws2_32) -LoadDLLfunc (getsockname, 12, ws2_32) -LoadDLLfunc (getsockopt, 20, ws2_32) -LoadDLLfunc (ioctlsocket, 12, ws2_32) -LoadDLLfunc (listen, 8, ws2_32) -LoadDLLfunc (setsockopt, 20, ws2_32) -LoadDLLfunc (shutdown, 8, ws2_32) -LoadDLLfunc (socket, 12, ws2_32) -LoadDLLfunc (WSAAsyncSelect, 16, ws2_32) -LoadDLLfunc (WSADuplicateSocketW, 12, ws2_32) -LoadDLLfunc (WSAEnumNetworkEvents, 12, ws2_32) -LoadDLLfunc (WSAEventSelect, 12, ws2_32) -LoadDLLfunc (WSAGetLastError, 0, ws2_32) -LoadDLLfunc (WSAIoctl, 36, ws2_32) -LoadDLLfunc (WSARecv, 28, ws2_32) -LoadDLLfunc (WSARecvFrom, 36, ws2_32) -LoadDLLfunc (WSASendMsg, 24, ws2_32) -LoadDLLfunc (WSASendTo, 36, ws2_32) -LoadDLLfunc (WSASetLastError, 4, ws2_32) -LoadDLLfunc (WSASocketW, 24, ws2_32) -// LoadDLLfunc (WSAStartup, 8, ws2_32) -LoadDLLfunc (WSAWaitForMultipleEvents, 20, ws2_32) - -// 50 = ERROR_NOT_SUPPORTED. Returned if OS doesn't support iphlpapi funcs -LoadDLLfuncEx2 (GetAdaptersAddresses, 20, iphlpapi, 1, 50) -LoadDLLfuncEx2 (GetExtendedTcpTable, 24, iphlpapi, 1, 50) -LoadDLLfuncEx2 (GetIfEntry, 4, iphlpapi, 1, 50) -LoadDLLfuncEx2 (GetIpAddrTable, 12, iphlpapi, 1, 50) -LoadDLLfuncEx2 (GetIpForwardTable, 12, iphlpapi, 1, 50) -LoadDLLfuncEx2 (GetNetworkParams, 8, iphlpapi, 1, 50) -LoadDLLfuncEx2 (GetTcpTable, 12, iphlpapi, 1, 50) -LoadDLLfuncEx2 (SendARP, 16, iphlpapi, 1, 50) - -LoadDLLfunc (CoTaskMemFree, 4, ole32) - -LoadDLLfuncEx (AttachConsole, 4, kernel32, 1) -LoadDLLfuncEx (FindFirstVolumeA, 8, kernel32, 1) -LoadDLLfuncEx (FindNextVolumeA, 12, kernel32, 1) -LoadDLLfuncEx (FindVolumeClose, 4, kernel32, 1) -LoadDLLfuncEx (GetConsoleWindow, 0, kernel32, 1) -LoadDLLfuncEx (GetSystemWindowsDirectoryW, 8, kernel32, 1) -LoadDLLfuncEx (GetVolumeNameForVolumeMountPointA, 12, kernel32, 1) -LoadDLLfuncEx (GetSystemDEPPolicy, 0, kernel32, 1) -LoadDLLfuncEx (GetProcessDEPPolicy, 12, kernel32, 1) -LoadDLLfunc (LocaleNameToLCID, 8, kernel32) -LoadDLLfuncEx (SetProcessDEPPolicy, 4, kernel32, 1) - -LoadDLLfunc (SHGetDesktopFolder, 4, shell32) - -LoadDLLfuncEx (waveOutGetNumDevs, 0, winmm, 1) -LoadDLLfuncEx (waveOutOpen, 24, winmm, 1) -LoadDLLfuncEx (waveOutReset, 4, winmm, 1) -LoadDLLfuncEx (waveOutClose, 4, winmm, 1) -LoadDLLfuncEx (waveOutGetVolume, 8, winmm, 1) -LoadDLLfuncEx (waveOutSetVolume, 8, winmm, 1) -LoadDLLfuncEx (waveOutUnprepareHeader, 12, winmm, 1) -LoadDLLfuncEx (waveOutPrepareHeader, 12, winmm, 1) -LoadDLLfuncEx (waveOutWrite, 12, winmm, 1) -LoadDLLfuncEx (timeGetDevCaps, 8, winmm, 1) -LoadDLLfuncEx (timeGetTime, 0, winmm, 1) -LoadDLLfuncEx (timeBeginPeriod, 4, winmm, 1) -LoadDLLfuncEx (timeEndPeriod, 4, winmm, 1) - -LoadDLLfuncEx (waveInGetNumDevs, 0, winmm, 1) -LoadDLLfuncEx (waveInOpen, 24, winmm, 1) -LoadDLLfuncEx (waveInUnprepareHeader, 12, winmm, 1) -LoadDLLfuncEx (waveInPrepareHeader, 12, winmm, 1) -LoadDLLfuncEx (waveInAddBuffer, 12, winmm, 1) -LoadDLLfuncEx (waveInStart, 4, winmm, 1) -LoadDLLfuncEx (waveInReset, 4, winmm, 1) -LoadDLLfuncEx (waveInClose, 4, winmm, 1) - -LoadDLLfunc (WNetGetProviderNameA, 12, mpr) -LoadDLLfunc (WNetGetResourceInformationA, 16, mpr) -LoadDLLfunc (WNetOpenEnumA, 20, mpr) -LoadDLLfunc (WNetEnumResourceA, 16, mpr) -LoadDLLfunc (WNetCloseEnum, 4, mpr) - -LoadDLLfuncEx (UuidCreate, 4, rpcrt4, 1) -LoadDLLfuncEx (UuidCreateSequential, 4, rpcrt4, 1) - -LoadDLLfuncEx2 (DnsQuery_A, 24, dnsapi, 1, 127) // ERROR_PROC_NOT_FOUND -LoadDLLfuncEx (DnsRecordListFree, 8, dnsapi, 1) -} diff --git a/winsup/cygwin/automode.c b/winsup/cygwin/automode.c deleted file mode 100644 index f7cddfeec..000000000 --- a/winsup/cygwin/automode.c +++ /dev/null @@ -1,26 +0,0 @@ -/* automode.c - - Copyright 2000 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include -#include -#include - -extern int _fmode; -void -cygwin_premain0 (int argc, char **argv, struct per_process *myself) -{ - static struct __cygwin_perfile pf[] = - { - {"", O_RDONLY | O_TEXT}, - {"", O_WRONLY | O_BINARY}, - {NULL, 0} - }; - cygwin_internal (CW_PERFILE, pf); -} diff --git a/winsup/cygwin/binmode.c b/winsup/cygwin/binmode.c deleted file mode 100644 index 50efff46f..000000000 --- a/winsup/cygwin/binmode.c +++ /dev/null @@ -1,21 +0,0 @@ -/* binmode.c - - Copyright 2000 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include -#include -#include - -extern int _fmode; -void -cygwin_premain0 (int argc, char **argv, struct per_process *myself) -{ - _fmode &= ~_O_TEXT; - _fmode |= _O_BINARY; -} diff --git a/winsup/cygwin/child_info.h b/winsup/cygwin/child_info.h deleted file mode 100644 index 44767edc9..000000000 --- a/winsup/cygwin/child_info.h +++ /dev/null @@ -1,146 +0,0 @@ -/* child_info.h: shared child info for cygwin - - Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include - -enum child_info_types -{ - _PROC_EXEC, - _PROC_SPAWN, - _PROC_FORK, - _PROC_WHOOPS -}; - -enum child_status -{ - _CI_STRACED = 0x01, - _CI_ISCYGWIN = 0x02, - _CI_SAW_CTRL_C = 0x04 -}; - -#define OPROC_MAGIC_MASK 0xff00ff00 -#define OPROC_MAGIC_GENERIC 0xaf00f000 - -#define PROC_MAGIC_GENERIC 0xaf00fa00 - -#define PROC_EXEC (_PROC_EXEC) -#define PROC_SPAWN (_PROC_SPAWN) -#define PROC_FORK (_PROC_FORK) - -#define EXEC_MAGIC_SIZE sizeof(child_info) - -/* Change this value if you get a message indicating that it is out-of-sync. */ -#define CURR_CHILD_INFO_MAGIC 0xe850717aU - -/* NOTE: Do not make gratuitous changes to the names or organization of the - below class. The layout is checksummed to determine compatibility between - different cygwin versions. */ -class child_info -{ -public: - DWORD msv_count; // zeroed on < W2K3, set to pseudo-count on Vista - DWORD cb; // size of this record - DWORD intro; // improbable string - unsigned long magic; // magic number unique to child_info - unsigned short type; // type of record, exec, spawn, fork - HANDLE subproc_ready; // used for synchronization with parent - HANDLE user_h; - HANDLE parent; - init_cygheap *cygheap; - void *cygheap_max; - DWORD cygheap_reserve_sz; - unsigned char flag; - unsigned fhandler_union_cb; - int retry; // number of times we've tried to start child process - DWORD exit_code; // process exit code - static int retry_count;// retry count; - child_info (unsigned, child_info_types, bool); - child_info (): subproc_ready (NULL), parent (NULL) {} - ~child_info (); - void ready (bool); - bool sync (int, HANDLE&, DWORD) __attribute__ ((regparm (3))); - DWORD proc_retry (HANDLE) __attribute__ ((regparm (2))); - bool isstraced () const {return !!(flag & _CI_STRACED);} - bool iscygwin () const {return !!(flag & _CI_ISCYGWIN);} - bool saw_ctrl_c () const {return !!(flag & _CI_SAW_CTRL_C);} - void set_saw_ctrl_c () {flag |= _CI_SAW_CTRL_C;} -}; - -class mount_info; -class _pinfo; - -class child_info_fork: public child_info -{ -public: - HANDLE forker_finished;// for synchronization with child - DWORD stacksize; // size of parent stack - jmp_buf jmp; // where child will jump to - void *stacktop; // location of top of parent stack - void *stackbottom; // location of bottom of parent stack - char filler[4]; - child_info_fork (); - void handle_fork () __attribute__ ((regparm (1)));; - bool handle_failure (DWORD) __attribute__ ((regparm (2))); - void alloc_stack (); - void alloc_stack_hard_way (volatile char *); -}; - -class fhandler_base; - -class cygheap_exec_info -{ -public: - char *old_title; - int argc; - char **argv; - int envc; - char **envp; - HANDLE myself_pinfo; -}; - -class child_info_spawn: public child_info -{ -public: - cygheap_exec_info *moreinfo; - int __stdin; - int __stdout; - char filler[4]; - - ~child_info_spawn () - { - if (moreinfo) - { - if (moreinfo->old_title) - cfree (moreinfo->old_title); - if (moreinfo->envp) - { - for (char **e = moreinfo->envp; *e; e++) - cfree (*e); - cfree (moreinfo->envp); - } - if (type != _PROC_SPAWN && moreinfo->myself_pinfo) - CloseHandle (moreinfo->myself_pinfo); - cfree (moreinfo); - } - } - child_info_spawn (): moreinfo (NULL) {}; - child_info_spawn (child_info_types, bool); - void *operator new (size_t, void *p) __attribute__ ((nothrow)) {return p;} - void set (child_info_types ci, bool b) { new (this) child_info_spawn (ci, b);} - void handle_spawn () __attribute__ ((regparm (1))); -}; - -void __stdcall init_child_info (DWORD, child_info *, HANDLE); - -extern "C" { -extern child_info *child_proc_info; -extern child_info_spawn *spawn_info asm ("_child_proc_info"); -extern child_info_fork *fork_info asm ("_child_proc_info"); -} diff --git a/winsup/cygwin/config.h.in b/winsup/cygwin/config.h.in deleted file mode 100644 index 32cba72d8..000000000 --- a/winsup/cygwin/config.h.in +++ /dev/null @@ -1,50 +0,0 @@ -/* config.h.in. Generated from configure.in by autoheader. */ -/* Define if DEBUGGING support is requested. */ -#undef DEBUGGING - -/* Define if GCC supports builtin memset. */ -#undef HAVE_BUILTIN_MEMSET - -/* Define if MALLOC_DEBUGGING support is requested. */ -#undef MALLOC_DEBUG - -/* Define if using new vfork functionality. */ -#undef NEWVFORK - -/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP - systems. This function is required for `alloca.c' support on those systems. - */ -#undef CRAY_STACKSEG_END - -/* Define to 1 if using `alloca.c'. */ -#undef C_ALLOCA - -/* Define to 1 if you have `alloca', as a function or macro. */ -#undef HAVE_ALLOCA - -/* Define to 1 if you have and it should be used (not on Ultrix). - */ -#undef HAVE_ALLOCA_H - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at run-time. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ -#undef STACK_DIRECTION diff --git a/winsup/cygwin/config/i386/profile.h b/winsup/cygwin/config/i386/profile.h deleted file mode 100644 index 748b89aa0..000000000 --- a/winsup/cygwin/config/i386/profile.h +++ /dev/null @@ -1,58 +0,0 @@ -/* $NetBSD: profile.h,v 1.6 1995/03/28 18:17:08 jtc Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - * - * @(#)profile.h 8.1 (Berkeley) 6/11/93 - */ - -#define _MCOUNT_DECL static inline void _mcount - -#define MCOUNT \ -void \ -mcount() \ -{ \ - int selfpc, frompcindex; \ - /* \ - * find the return address for mcount, \ - * and the return address for mcount's caller. \ - * \ - * selfpc = pc pushed by mcount call \ - */ \ - __asm __volatile ("movl 4(%%ebp),%0" : "=r" (selfpc)); \ - /* \ - * frompcindex = pc pushed by call into self. \ - */ \ - __asm __volatile ("movl (%%ebp),%0;movl 4(%0),%0" : "=r" (frompcindex));\ - _mcount(frompcindex, selfpc); \ -} - diff --git a/winsup/cygwin/configure b/winsup/cygwin/configure deleted file mode 100755 index 470a1d12b..000000000 --- a/winsup/cygwin/configure +++ /dev/null @@ -1,6985 +0,0 @@ -#! /bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.63. -# -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - - - -# PATH needs CR -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - { (exit 1); exit 1; } -fi - -# Work around bugs in pre-3.0 UWIN ksh. -for as_var in ENV MAIL MAILPATH -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - - -# Name of the executable. -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# CDPATH. -$as_unset CDPATH - - -if test "x$CONFIG_SHELL" = x; then - if (eval ":") 2>/dev/null; then - as_have_required=yes -else - as_have_required=no -fi - - if test $as_have_required = yes && (eval ": -(as_func_return () { - (exit \$1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = \"\$1\" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test \$exitcode = 0) || { (exit 1); exit 1; } - -( - as_lineno_1=\$LINENO - as_lineno_2=\$LINENO - test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && - test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } -") 2> /dev/null; then - : -else - as_candidate_shells= - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - case $as_dir in - /*) - for as_base in sh bash ksh sh5; do - as_candidate_shells="$as_candidate_shells $as_dir/$as_base" - done;; - esac -done -IFS=$as_save_IFS - - - for as_shell in $as_candidate_shells $SHELL; do - # Try only shells that exist, to save several forks. - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { ("$as_shell") 2> /dev/null <<\_ASEOF -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - -: -_ASEOF -}; then - CONFIG_SHELL=$as_shell - as_have_required=yes - if { "$as_shell" 2> /dev/null <<\_ASEOF -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - -: -(as_func_return () { - (exit $1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = "$1" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test $exitcode = 0) || { (exit 1); exit 1; } - -( - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } - -_ASEOF -}; then - break -fi - -fi - - done - - if test "x$CONFIG_SHELL" != x; then - for as_var in BASH_ENV ENV - do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - done - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} -fi - - - if test $as_have_required = no; then - echo This script requires a shell more modern than all the - echo shells that I found on your system. Please install a - echo modern shell, or manually run the script under such a - echo shell if you do have one. - { (exit 1); exit 1; } -fi - - -fi - -fi - - - -(eval "as_func_return () { - (exit \$1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = \"\$1\" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test \$exitcode = 0") || { - echo No shell found that supports shell functions. - echo Please tell bug-autoconf@gnu.org about your system, - echo including any error possibly output before this message. - echo This can help us improve future autoconf versions. - echo Configuration will now proceed without shell functions. -} - - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line after each line using $LINENO; the second 'sed' - # does the real work. The second script uses 'N' to pair each - # line-number line with the line containing $LINENO, and appends - # trailing '-' during substitution so that $LINENO is not a special - # case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # scripts with optimization help from Paolo Bonzini. Blame Lee - # E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in --n*) - case `echo 'x\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - *) ECHO_C='\c';; - esac;; -*) - ECHO_N='-n';; -esac -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -p' - fi -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - -if mkdir -p . 2>/dev/null; then - as_mkdir_p=: -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - - -exec 7<&0 &1 - -# Name of the host. -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, -# so uname gets run too. -ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` - -# -# Initializations. -# -ac_default_prefix=/usr/local -ac_clean_files= -ac_config_libobj_dir=. -LIBOBJS= -cross_compiling=no -subdirs= -MFLAGS= -MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} - -# Identity of this package. -PACKAGE_NAME= -PACKAGE_TARNAME= -PACKAGE_VERSION= -PACKAGE_STRING= -PACKAGE_BUGREPORT= - -ac_unique_file="init.cc" -# Factoring default headers for most tests. -ac_includes_default="\ -#include -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_STAT_H -# include -#endif -#ifdef STDC_HEADERS -# include -# include -#else -# ifdef HAVE_STDLIB_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# if !defined STDC_HEADERS && defined HAVE_MEMORY_H -# include -# endif -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif -#ifdef HAVE_INTTYPES_H -# include -#endif -#ifdef HAVE_STDINT_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif" - -ac_subst_vars='LTLIBOBJS -LIBOBJS -CONFIG_DIR -DEF_DLL_ENTRY -DLL_ENTRY -LIBSERVER -MALLOC_OFILES -SET_MAKE -EGREP -GREP -CPP -ALLOCA -WINDRES -STRIP -RANLIB -OBJDUMP -OBJCOPY -NM -LD -DLLTOOL -AS -AR -install_host -all_host -ac_ct_CXX -CXXFLAGS -CXX -OBJEXT -EXEEXT -ac_ct_CC -CPPFLAGS -LDFLAGS -CFLAGS -CC -target_os -target_vendor -target_cpu -target -host_os -host_vendor -host_cpu -host -build_os -build_vendor -build_cpu -build -INSTALL_DATA -INSTALL_SCRIPT -INSTALL_PROGRAM -target_alias -host_alias -build_alias -LIBS -ECHO_T -ECHO_N -ECHO_C -DEFS -mandir -localedir -libdir -psdir -pdfdir -dvidir -htmldir -infodir -docdir -oldincludedir -includedir -localstatedir -sharedstatedir -sysconfdir -datadir -datarootdir -libexecdir -sbindir -bindir -program_transform_name -prefix -exec_prefix -PACKAGE_BUGREPORT -PACKAGE_STRING -PACKAGE_VERSION -PACKAGE_TARNAME -PACKAGE_NAME -PATH_SEPARATOR -SHELL' -ac_subst_files='' -ac_user_opts=' -enable_option_checking -enable_debugging -' - ac_precious_vars='build_alias -host_alias -target_alias -CC -CFLAGS -LDFLAGS -LIBS -CPPFLAGS -CXX -CXXFLAGS -CCC -CPP' - - -# Initialize some variables set by options. -ac_init_help= -ac_init_version=false -ac_unrecognized_opts= -ac_unrecognized_sep= -# The variables have the same names as the options, with -# dashes changed to underlines. -cache_file=/dev/null -exec_prefix=NONE -no_create= -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -verbose= -x_includes=NONE -x_libraries=NONE - -# Installation directory options. -# These are left unexpanded so users can "make install exec_prefix=/foo" -# and all the variables that are supposed to be based on exec_prefix -# by default will actually change. -# Use braces instead of parens because sh, perl, etc. also accept them. -# (The list follows the same order as the GNU Coding Standards.) -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datarootdir='${prefix}/share' -datadir='${datarootdir}' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -includedir='${prefix}/include' -oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE}' -infodir='${datarootdir}/info' -htmldir='${docdir}' -dvidir='${docdir}' -pdfdir='${docdir}' -psdir='${docdir}' -libdir='${exec_prefix}/lib' -localedir='${datarootdir}/locale' -mandir='${datarootdir}/man' - -ac_prev= -ac_dashdash= -for ac_option -do - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval $ac_prev=\$ac_option - ac_prev= - continue - fi - - case $ac_option in - *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *) ac_optarg=yes ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case $ac_dashdash$ac_option in - --) - ac_dashdash=yes ;; - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir=$ac_optarg ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build_alias ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build_alias=$ac_optarg ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file=$ac_optarg ;; - - --config-cache | -C) - cache_file=config.cache ;; - - -datadir | --datadir | --datadi | --datad) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=*) - datadir=$ac_optarg ;; - - -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ - | --dataroo | --dataro | --datar) - ac_prev=datarootdir ;; - -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ - | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) - datarootdir=$ac_optarg ;; - - -disable-* | --disable-*) - ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=no ;; - - -docdir | --docdir | --docdi | --doc | --do) - ac_prev=docdir ;; - -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) - docdir=$ac_optarg ;; - - -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) - ac_prev=dvidir ;; - -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) - dvidir=$ac_optarg ;; - - -enable-* | --enable-*) - ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=\$ac_optarg ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix=$ac_optarg ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he | -h) - ac_init_help=long ;; - -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) - ac_init_help=recursive ;; - -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) - ac_init_help=short ;; - - -host | --host | --hos | --ho) - ac_prev=host_alias ;; - -host=* | --host=* | --hos=* | --ho=*) - host_alias=$ac_optarg ;; - - -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) - ac_prev=htmldir ;; - -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ - | --ht=*) - htmldir=$ac_optarg ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir=$ac_optarg ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir=$ac_optarg ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir=$ac_optarg ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir=$ac_optarg ;; - - -localedir | --localedir | --localedi | --localed | --locale) - ac_prev=localedir ;; - -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) - localedir=$ac_optarg ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst | --locals) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) - localstatedir=$ac_optarg ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir=$ac_optarg ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c | -n) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir=$ac_optarg ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=$ac_optarg ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix=$ac_optarg ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix=$ac_optarg ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name=$ac_optarg ;; - - -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) - ac_prev=pdfdir ;; - -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) - pdfdir=$ac_optarg ;; - - -psdir | --psdir | --psdi | --psd | --ps) - ac_prev=psdir ;; - -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) - psdir=$ac_optarg ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir=$ac_optarg ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir=$ac_optarg ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site=$ac_optarg ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir=$ac_optarg ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir=$ac_optarg ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target_alias ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target_alias=$ac_optarg ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers | -V) - ac_init_version=: ;; - - -with-* | --with-*) - ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=\$ac_optarg ;; - - -without-* | --without-*) - ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=no ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes=$ac_optarg ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries=$ac_optarg ;; - - -*) { $as_echo "$as_me: error: unrecognized option: $ac_option -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } - ;; - - *=*) - ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` - # Reject names that are not valid shell variable names. - expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2 - { (exit 1); exit 1; }; } - eval $ac_envvar=\$ac_optarg - export $ac_envvar ;; - - *) - # FIXME: should be removed in autoconf 3.0. - $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 - expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} - ;; - - esac -done - -if test -n "$ac_prev"; then - ac_option=--`echo $ac_prev | sed 's/_/-/g'` - { $as_echo "$as_me: error: missing argument to $ac_option" >&2 - { (exit 1); exit 1; }; } -fi - -if test -n "$ac_unrecognized_opts"; then - case $enable_option_checking in - no) ;; - fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2 - { (exit 1); exit 1; }; } ;; - *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; - esac -fi - -# Check all directory arguments for consistency. -for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ - datadir sysconfdir sharedstatedir localstatedir includedir \ - oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir -do - eval ac_val=\$$ac_var - # Remove trailing slashes. - case $ac_val in - */ ) - ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` - eval $ac_var=\$ac_val;; - esac - # Be sure to have absolute directory names. - case $ac_val in - [\\/$]* | ?:[\\/]* ) continue;; - NONE | '' ) case $ac_var in *prefix ) continue;; esac;; - esac - { $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; } -done - -# There might be people who depend on the old broken behavior: `$host' -# used to hold the argument of --host etc. -# FIXME: To remove some day. -build=$build_alias -host=$host_alias -target=$target_alias - -# FIXME: To remove some day. -if test "x$host_alias" != x; then - if test "x$build_alias" = x; then - cross_compiling=maybe - $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used." >&2 - elif test "x$build_alias" != "x$host_alias"; then - cross_compiling=yes - fi -fi - -ac_tool_prefix= -test -n "$host_alias" && ac_tool_prefix=$host_alias- - -test "$silent" = yes && exec 6>/dev/null - - -ac_pwd=`pwd` && test -n "$ac_pwd" && -ac_ls_di=`ls -di .` && -ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - { $as_echo "$as_me: error: working directory cannot be determined" >&2 - { (exit 1); exit 1; }; } -test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - { $as_echo "$as_me: error: pwd does not report name of working directory" >&2 - { (exit 1); exit 1; }; } - - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then the parent directory. - ac_confdir=`$as_dirname -- "$as_myself" || -$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_myself" : 'X\(//\)[^/]' \| \ - X"$as_myself" : 'X\(//\)$' \| \ - X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_myself" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - srcdir=$ac_confdir - if test ! -r "$srcdir/$ac_unique_file"; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r "$srcdir/$ac_unique_file"; then - test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - { $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 - { (exit 1); exit 1; }; } -fi -ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" -ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2 - { (exit 1); exit 1; }; } - pwd)` -# When building in place, set srcdir=. -if test "$ac_abs_confdir" = "$ac_pwd"; then - srcdir=. -fi -# Remove unnecessary trailing slashes from srcdir. -# Double slashes in file names in object file debugging info -# mess up M-x gdb in Emacs. -case $srcdir in -*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; -esac -for ac_var in $ac_precious_vars; do - eval ac_env_${ac_var}_set=\${${ac_var}+set} - eval ac_env_${ac_var}_value=\$${ac_var} - eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} - eval ac_cv_env_${ac_var}_value=\$${ac_var} -done - -# -# Report the --help message. -# -if test "$ac_init_help" = "long"; then - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat <<_ACEOF -\`configure' configures this package to adapt to many kinds of systems. - -Usage: $0 [OPTION]... [VAR=VALUE]... - -To assign environment variables (e.g., CC, CFLAGS...), specify them as -VAR=VALUE. See below for descriptions of some of the useful variables. - -Defaults for the options are specified in brackets. - -Configuration: - -h, --help display this help and exit - --help=short display options specific to this package - --help=recursive display the short help of all the included packages - -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking...' messages - --cache-file=FILE cache test results in FILE [disabled] - -C, --config-cache alias for \`--cache-file=config.cache' - -n, --no-create do not create output files - --srcdir=DIR find the sources in DIR [configure dir or \`..'] - -Installation directories: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] - -By default, \`make install' will install all the files in -\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify -an installation prefix other than \`$ac_default_prefix' using \`--prefix', -for instance \`--prefix=\$HOME'. - -For better control, use the options below. - -Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] - --datadir=DIR read-only architecture-independent data [DATAROOTDIR] - --infodir=DIR info documentation [DATAROOTDIR/info] - --localedir=DIR locale-dependent data [DATAROOTDIR/locale] - --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] - --htmldir=DIR html documentation [DOCDIR] - --dvidir=DIR dvi documentation [DOCDIR] - --pdfdir=DIR pdf documentation [DOCDIR] - --psdir=DIR ps documentation [DOCDIR] -_ACEOF - - cat <<\_ACEOF - -System types: - --build=BUILD configure for building on BUILD [guessed] - --host=HOST cross-compile to build programs to run on HOST [BUILD] - --target=TARGET configure for building compilers for TARGET [HOST] -_ACEOF -fi - -if test -n "$ac_init_help"; then - - cat <<\_ACEOF - -Optional Features: - --disable-option-checking ignore unrecognized --enable/--with options - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --enable-debugging Build a cygwin DLL which has more consistency checking for debugging - -Some influential environment variables: - CC C compiler command - CFLAGS C compiler flags - LDFLAGS linker flags, e.g. -L if you have libraries in a - nonstandard directory - LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if - you have headers in a nonstandard directory - CXX C++ compiler command - CXXFLAGS C++ compiler flags - CPP C preprocessor - -Use these variables to override the choices made by `configure' or to help -it to find libraries and programs with nonstandard names/locations. - -_ACEOF -ac_status=$? -fi - -if test "$ac_init_help" = "recursive"; then - # If there are subdirs, report their specific --help. - for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d "$ac_dir" || - { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || - continue - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - cd "$ac_dir" || { ac_status=$?; continue; } - # Check for guested configure. - if test -f "$ac_srcdir/configure.gnu"; then - echo && - $SHELL "$ac_srcdir/configure.gnu" --help=recursive - elif test -f "$ac_srcdir/configure"; then - echo && - $SHELL "$ac_srcdir/configure" --help=recursive - else - $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi || ac_status=$? - cd "$ac_pwd" || { ac_status=$?; break; } - done -fi - -test -n "$ac_init_help" && exit $ac_status -if $ac_init_version; then - cat <<\_ACEOF -configure -generated by GNU Autoconf 2.63 - -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. -This configure script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it. -_ACEOF - exit -fi -cat >config.log <<_ACEOF -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by $as_me, which was -generated by GNU Autoconf 2.63. Invocation command line was - - $ $0 $@ - -_ACEOF -exec 5>>config.log -{ -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` - -/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` -/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` -/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` - -_ASUNAME - -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - $as_echo "PATH: $as_dir" -done -IFS=$as_save_IFS - -} >&5 - -cat >&5 <<_ACEOF - - -## ----------- ## -## Core tests. ## -## ----------- ## - -_ACEOF - - -# Keep a trace of the command line. -# Strip out --no-create and --no-recursion so they do not pile up. -# Strip out --silent because we don't want to record it for future runs. -# Also quote any args containing shell meta-characters. -# Make two passes to allow for proper duplicate-argument suppression. -ac_configure_args= -ac_configure_args0= -ac_configure_args1= -ac_must_keep_next=false -for ac_pass in 1 2 -do - for ac_arg - do - case $ac_arg in - -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - continue ;; - *\'*) - ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - case $ac_pass in - 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; - 2) - ac_configure_args1="$ac_configure_args1 '$ac_arg'" - if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. - else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac - fi - ac_configure_args="$ac_configure_args '$ac_arg'" - ;; - esac - done -done -$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } -$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } - -# When interrupted or exit'd, cleanup temporary files, and complete -# config.log. We remove comments because anyway the quotes in there -# would cause problems or look ugly. -# WARNING: Use '\'' to represent an apostrophe within the trap. -# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. -trap 'exit_status=$? - # Save into config.log some information that might help in debugging. - { - echo - - cat <<\_ASBOX -## ---------------- ## -## Cache variables. ## -## ---------------- ## -_ASBOX - echo - # The following way of writing the cache mishandles newlines in values, -( - for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) $as_unset $ac_var ;; - esac ;; - esac - done - (set) 2>&1 | - case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - sed -n \ - "s/'\''/'\''\\\\'\'''\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" - ;; #( - *) - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) - echo - - cat <<\_ASBOX -## ----------------- ## -## Output variables. ## -## ----------------- ## -_ASBOX - echo - for ac_var in $ac_subst_vars - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - - if test -n "$ac_subst_files"; then - cat <<\_ASBOX -## ------------------- ## -## File substitutions. ## -## ------------------- ## -_ASBOX - echo - for ac_var in $ac_subst_files - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - fi - - if test -s confdefs.h; then - cat <<\_ASBOX -## ----------- ## -## confdefs.h. ## -## ----------- ## -_ASBOX - echo - cat confdefs.h - echo - fi - test "$ac_signal" != 0 && - $as_echo "$as_me: caught signal $ac_signal" - $as_echo "$as_me: exit $exit_status" - } >&5 - rm -f core *.core core.conftest.* && - rm -f -r conftest* confdefs* conf$$* $ac_clean_files && - exit $exit_status -' 0 -for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal -done -ac_signal=0 - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -f -r conftest* confdefs.h - -# Predefined preprocessor variables. - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_NAME "$PACKAGE_NAME" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_TARNAME "$PACKAGE_TARNAME" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_VERSION "$PACKAGE_VERSION" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_STRING "$PACKAGE_STRING" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" -_ACEOF - - -# Let the site file select an alternate cache file if it wants to. -# Prefer an explicitly selected file to automatically selected ones. -ac_site_file1=NONE -ac_site_file2=NONE -if test -n "$CONFIG_SITE"; then - ac_site_file1=$CONFIG_SITE -elif test "x$prefix" != xNONE; then - ac_site_file1=$prefix/share/config.site - ac_site_file2=$prefix/etc/config.site -else - ac_site_file1=$ac_default_prefix/share/config.site - ac_site_file2=$ac_default_prefix/etc/config.site -fi -for ac_site_file in "$ac_site_file1" "$ac_site_file2" -do - test "x$ac_site_file" = xNONE && continue - if test -r "$ac_site_file"; then - { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 -$as_echo "$as_me: loading site script $ac_site_file" >&6;} - sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" - fi -done - -if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special - # files actually), so we avoid doing that. - if test -f "$cache_file"; then - { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5 -$as_echo "$as_me: loading cache $cache_file" >&6;} - case $cache_file in - [\\/]* | ?:[\\/]* ) . "$cache_file";; - *) . "./$cache_file";; - esac - fi -else - { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5 -$as_echo "$as_me: creating cache $cache_file" >&6;} - >$cache_file -fi - -# Check that the precious variables saved in the cache have kept the same -# value. -ac_cache_corrupted=false -for ac_var in $ac_precious_vars; do - eval ac_old_set=\$ac_cv_env_${ac_var}_set - eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val=\$ac_cv_env_${ac_var}_value - eval ac_new_val=\$ac_env_${ac_var}_value - case $ac_old_set,$ac_new_set in - set,) - { $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,set) - { $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,);; - *) - if test "x$ac_old_val" != "x$ac_new_val"; then - # differences in whitespace do not lead to failure. - ac_old_val_w=`echo x $ac_old_val` - ac_new_val_w=`echo x $ac_new_val` - if test "$ac_old_val_w" != "$ac_new_val_w"; then - { $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 -$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - ac_cache_corrupted=: - else - { $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 -$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} - eval $ac_var=\$ac_old_val - fi - { $as_echo "$as_me:$LINENO: former value: \`$ac_old_val'" >&5 -$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} - { $as_echo "$as_me:$LINENO: current value: \`$ac_new_val'" >&5 -$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} - fi;; - esac - # Pass precious variables to config.status. - if test "$ac_new_set" = set; then - case $ac_new_val in - *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; - *) ac_arg=$ac_var=$ac_new_val ;; - esac - case " $ac_configure_args " in - *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; - esac - fi -done -if $ac_cache_corrupted; then - { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} - { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 -$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 -$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} - { (exit 1); exit 1; }; } -fi - - - - - - - - - - - - - - - - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -ac_config_headers="$ac_config_headers config.h" - -ac_aux_dir= -for ac_dir in ../.. "$srcdir"/../..; do - if test -f "$ac_dir/install-sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f "$ac_dir/install.sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - elif test -f "$ac_dir/shtool"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/shtool install -c" - break - fi -done -if test -z "$ac_aux_dir"; then - { { $as_echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in ../.. \"$srcdir\"/../.." >&5 -$as_echo "$as_me: error: cannot find install-sh or install.sh in ../.. \"$srcdir\"/../.." >&2;} - { (exit 1); exit 1; }; } -fi - -# These three variables are undocumented and unsupported, -# and are intended to be withdrawn in a future Autoconf release. -# They can cause serious problems if a builder's source tree is in a directory -# whose full name contains unusual characters. -ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. -ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. -ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. - - - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AmigaOS /C/install, which installs bootblocks on floppy discs -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# OS/2's system install, which has a completely different semantic -# ./install, which can be erroneously created by make from ./install.sh. -# Reject install programs that cannot install multiple files. -{ $as_echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 -$as_echo_n "checking for a BSD-compatible install... " >&6; } -if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then - $as_echo_n "(cached) " >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in - ./ | .// | /cC/* | \ - /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ - /usr/ucb/* ) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then - if test $ac_prog = install && - grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - elif test $ac_prog = install && - grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # program-specific install script used by HP pwplus--don't use. - : - else - rm -rf conftest.one conftest.two conftest.dir - echo one > conftest.one - echo two > conftest.two - mkdir conftest.dir - if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && - test -s conftest.one && test -s conftest.two && - test -s conftest.dir/conftest.one && - test -s conftest.dir/conftest.two - then - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 - fi - fi - fi - done - done - ;; -esac - -done -IFS=$as_save_IFS - -rm -rf conftest.one conftest.two conftest.dir - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL=$ac_cv_path_install - else - # As a last resort, use the slow shell script. Don't cache a - # value for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the value is a relative name. - INSTALL=$ac_install_sh - fi -fi -{ $as_echo "$as_me:$LINENO: result: $INSTALL" >&5 -$as_echo "$INSTALL" >&6; } - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - -# Make sure we can run config.sub. -$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - { { $as_echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 -$as_echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} - { (exit 1); exit 1; }; } - -{ $as_echo "$as_me:$LINENO: checking build system type" >&5 -$as_echo_n "checking build system type... " >&6; } -if test "${ac_cv_build+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_build_alias=$build_alias -test "x$ac_build_alias" = x && - ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` -test "x$ac_build_alias" = x && - { { $as_echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 -$as_echo "$as_me: error: cannot guess build type; you must specify one" >&2;} - { (exit 1); exit 1; }; } -ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 -$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} - { (exit 1); exit 1; }; } - -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_build" >&5 -$as_echo "$ac_cv_build" >&6; } -case $ac_cv_build in -*-*-*) ;; -*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 -$as_echo "$as_me: error: invalid value of canonical build" >&2;} - { (exit 1); exit 1; }; };; -esac -build=$ac_cv_build -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_build -shift -build_cpu=$1 -build_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -build_os=$* -IFS=$ac_save_IFS -case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac - - -{ $as_echo "$as_me:$LINENO: checking host system type" >&5 -$as_echo_n "checking host system type... " >&6; } -if test "${ac_cv_host+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test "x$host_alias" = x; then - ac_cv_host=$ac_cv_build -else - ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 -$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} - { (exit 1); exit 1; }; } -fi - -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_host" >&5 -$as_echo "$ac_cv_host" >&6; } -case $ac_cv_host in -*-*-*) ;; -*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 -$as_echo "$as_me: error: invalid value of canonical host" >&2;} - { (exit 1); exit 1; }; };; -esac -host=$ac_cv_host -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_host -shift -host_cpu=$1 -host_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -host_os=$* -IFS=$ac_save_IFS -case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac - - -{ $as_echo "$as_me:$LINENO: checking target system type" >&5 -$as_echo_n "checking target system type... " >&6; } -if test "${ac_cv_target+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test "x$target_alias" = x; then - ac_cv_target=$ac_cv_host -else - ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || - { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&5 -$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&2;} - { (exit 1); exit 1; }; } -fi - -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_target" >&5 -$as_echo "$ac_cv_target" >&6; } -case $ac_cv_target in -*-*-*) ;; -*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical target" >&5 -$as_echo "$as_me: error: invalid value of canonical target" >&2;} - { (exit 1); exit 1; }; };; -esac -target=$ac_cv_target -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_target -shift -target_cpu=$1 -target_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -target_os=$* -IFS=$ac_save_IFS -case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac - - -# The aliases save the names the user supplied, while $host etc. -# will get canonicalized. -test -n "$target_alias" && - test "$program_prefix$program_suffix$program_transform_name" = \ - NONENONEs,x,x, && - program_prefix=${target_alias}- - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="gcc" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -: ${CC:=gcc} -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CC" && break -done - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -fi - -fi - - -test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } - -# Provide some information about the compiler. -$as_echo "$as_me:$LINENO: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -{ (ac_try="$ac_compiler --version >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler --version >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -v >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -v >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -V >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -V >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -{ $as_echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&6; } -ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` - -# The possible output files: -ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" - -ac_rmfiles= -for ac_file in $ac_files -do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - * ) ac_rmfiles="$ac_rmfiles $ac_file";; - esac -done -rm -f $ac_rmfiles - -if { (ac_try="$ac_link_default" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link_default") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. -# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' -# in a Makefile. We should not override ac_cv_exeext if it was cached, -# so that the user can short-circuit this test for compilers unknown to -# Autoconf. -for ac_file in $ac_files '' -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; - then :; else - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - fi - # We set ac_cv_exeext here because the later test for it is not - # safe: cross compilers may not add the suffix if given an `-o' - # argument, so we may need to know it at that point already. - # Even if this section looks crufty: it has the advantage of - # actually working. - break;; - * ) - break;; - esac -done -test "$ac_cv_exeext" = no && ac_cv_exeext= - -else - ac_file='' -fi - -{ $as_echo "$as_me:$LINENO: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } -if test -z "$ac_file"; then - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: C compiler cannot create executables -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: C compiler cannot create executables -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; }; } -fi - -ac_exeext=$ac_cv_exeext - -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:$LINENO: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&6; } -# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 -# If not cross compiling, check that we can run a simple program. -if test "$cross_compiling" != yes; then - if { ac_try='./$ac_file' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } - fi - fi -fi -{ $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } - -rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -{ $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5 -$as_echo_n "checking for suffix of executables... " >&6; } -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - break;; - * ) break;; - esac -done -else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } -fi - -rm -f conftest$ac_cv_exeext -{ $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 -$as_echo "$ac_cv_exeext" >&6; } - -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -{ $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5 -$as_echo_n "checking for suffix of object files... " >&6; } -if test "${ac_cv_objext+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.o conftest.obj -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - for ac_file in conftest.o conftest.obj conftest.*; do - test -f "$ac_file" || continue; - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } -fi - -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 -$as_echo "$ac_cv_objext" >&6; } -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_compiler_gnu=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_compiler_gnu=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC= -fi -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_prog_cc_g=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - CFLAGS="" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_prog_cc_g=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#include -#include -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_prog_cc_c89=$ac_arg -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC - -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:$LINENO: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:$LINENO: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: no acceptable cc found in \$PATH" >&5 -$as_echo "$as_me: error: no acceptable cc found in \$PATH" >&2;} - { (exit 1); exit 1; }; } - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}g++", so it can be a program name with args. -set dummy ${ac_tool_prefix}g++; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CXX+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$CXX"; then - ac_cv_prog_CXX="$CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CXX="${ac_tool_prefix}g++" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -CXX=$ac_cv_prog_CXX -if test -n "$CXX"; then - { $as_echo "$as_me:$LINENO: result: $CXX" >&5 -$as_echo "$CXX" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CXX"; then - ac_ct_CXX=$CXX - # Extract the first word of "g++", so it can be a program name with args. -set dummy g++; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CXX"; then - ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CXX="g++" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_CXX=$ac_cv_prog_ac_ct_CXX -if test -n "$ac_ct_CXX"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 -$as_echo "$ac_ct_CXX" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_CXX" = x; then - CXX="g++" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CXX=$ac_ct_CXX - fi -else - CXX="$ac_cv_prog_CXX" -fi - -if test -z "$CXX"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}g++", so it can be a program name with args. -set dummy ${ac_tool_prefix}g++; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CXX+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$CXX"; then - ac_cv_prog_CXX="$CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CXX="${ac_tool_prefix}g++" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -CXX=$ac_cv_prog_CXX -if test -n "$CXX"; then - { $as_echo "$as_me:$LINENO: result: $CXX" >&5 -$as_echo "$CXX" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CXX"; then - ac_ct_CXX=$CXX - # Extract the first word of "g++", so it can be a program name with args. -set dummy g++; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CXX"; then - ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CXX="g++" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_CXX=$ac_cv_prog_ac_ct_CXX -if test -n "$ac_ct_CXX"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 -$as_echo "$ac_ct_CXX" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_CXX" = x; then - CXX="c++" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CXX=$ac_ct_CXX - fi -else - CXX="$ac_cv_prog_CXX" -fi - - : ${CXX:=g++} - ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -if test -z "$CXX"; then - if test -n "$CCC"; then - CXX=$CCC - else - if test -n "$ac_tool_prefix"; then - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CXX+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$CXX"; then - ac_cv_prog_CXX="$CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -CXX=$ac_cv_prog_CXX -if test -n "$CXX"; then - { $as_echo "$as_me:$LINENO: result: $CXX" >&5 -$as_echo "$CXX" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CXX" && break - done -fi -if test -z "$CXX"; then - ac_ct_CXX=$CXX - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CXX"; then - ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CXX="$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_CXX=$ac_cv_prog_ac_ct_CXX -if test -n "$ac_ct_CXX"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 -$as_echo "$ac_ct_CXX" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CXX" && break -done - - if test "x$ac_ct_CXX" = x; then - CXX="g++" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CXX=$ac_ct_CXX - fi -fi - - fi -fi -# Provide some information about the compiler. -$as_echo "$as_me:$LINENO: checking for C++ compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -{ (ac_try="$ac_compiler --version >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler --version >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -v >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -v >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -V >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -V >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - -{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 -$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } -if test "${ac_cv_cxx_compiler_gnu+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_compiler_gnu=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_compiler_gnu=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_cxx_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 -$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GXX=yes -else - GXX= -fi -ac_test_CXXFLAGS=${CXXFLAGS+set} -ac_save_CXXFLAGS=$CXXFLAGS -{ $as_echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 -$as_echo_n "checking whether $CXX accepts -g... " >&6; } -if test "${ac_cv_prog_cxx_g+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_save_cxx_werror_flag=$ac_cxx_werror_flag - ac_cxx_werror_flag=yes - ac_cv_prog_cxx_g=no - CXXFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_prog_cxx_g=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - CXXFLAGS="" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cxx_werror_flag=$ac_save_cxx_werror_flag - CXXFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_prog_cxx_g=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_cxx_werror_flag=$ac_save_cxx_werror_flag -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 -$as_echo "$ac_cv_prog_cxx_g" >&6; } -if test "$ac_test_CXXFLAGS" = set; then - CXXFLAGS=$ac_save_CXXFLAGS -elif test $ac_cv_prog_cxx_g = yes; then - if test "$GXX" = yes; then - CXXFLAGS="-g -O2" - else - CXXFLAGS="-g" - fi -else - if test "$GXX" = yes; then - CXXFLAGS="-O2" - else - CXXFLAGS= - fi -fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: no acceptable cc found in \$PATH" >&5 -$as_echo "$as_me: error: no acceptable cc found in \$PATH" >&2;} - { (exit 1); exit 1; }; } -fi - -CXXFLAGS='$(CFLAGS)' - - -case "$with_cross_host" in - ""|*cygwin*) - all_host="all_host" - install_host="install_host" - LIBSERVER='$(bupdir)/cygserver/libcygserver.a' - ;; - *) - all_host= - install_host= - LIBSERVER= - ;; -esac - - - - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. -set dummy ${ac_tool_prefix}ar; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_AR+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$AR"; then - ac_cv_prog_AR="$AR" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_AR="${ac_tool_prefix}ar" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -AR=$ac_cv_prog_AR -if test -n "$AR"; then - { $as_echo "$as_me:$LINENO: result: $AR" >&5 -$as_echo "$AR" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_AR"; then - ac_ct_AR=$AR - # Extract the first word of "ar", so it can be a program name with args. -set dummy ar; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_AR+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_AR"; then - ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_AR="ar" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_AR=$ac_cv_prog_ac_ct_AR -if test -n "$ac_ct_AR"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_AR" >&5 -$as_echo "$ac_ct_AR" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_AR" = x; then - AR="ar" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - AR=$ac_ct_AR - fi -else - AR="$ac_cv_prog_AR" -fi - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. -set dummy ${ac_tool_prefix}as; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_AS+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$AS"; then - ac_cv_prog_AS="$AS" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_AS="${ac_tool_prefix}as" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -AS=$ac_cv_prog_AS -if test -n "$AS"; then - { $as_echo "$as_me:$LINENO: result: $AS" >&5 -$as_echo "$AS" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_AS"; then - ac_ct_AS=$AS - # Extract the first word of "as", so it can be a program name with args. -set dummy as; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_AS+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_AS"; then - ac_cv_prog_ac_ct_AS="$ac_ct_AS" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_AS="as" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_AS=$ac_cv_prog_ac_ct_AS -if test -n "$ac_ct_AS"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_AS" >&5 -$as_echo "$ac_ct_AS" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_AS" = x; then - AS="as" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - AS=$ac_ct_AS - fi -else - AS="$ac_cv_prog_AS" -fi - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. -set dummy ${ac_tool_prefix}dlltool; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_DLLTOOL+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$DLLTOOL"; then - ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -DLLTOOL=$ac_cv_prog_DLLTOOL -if test -n "$DLLTOOL"; then - { $as_echo "$as_me:$LINENO: result: $DLLTOOL" >&5 -$as_echo "$DLLTOOL" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_DLLTOOL"; then - ac_ct_DLLTOOL=$DLLTOOL - # Extract the first word of "dlltool", so it can be a program name with args. -set dummy dlltool; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_DLLTOOL+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_DLLTOOL"; then - ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_DLLTOOL="dlltool" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL -if test -n "$ac_ct_DLLTOOL"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_DLLTOOL" >&5 -$as_echo "$ac_ct_DLLTOOL" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_DLLTOOL" = x; then - DLLTOOL="dlltool" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - DLLTOOL=$ac_ct_DLLTOOL - fi -else - DLLTOOL="$ac_cv_prog_DLLTOOL" -fi - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ld", so it can be a program name with args. -set dummy ${ac_tool_prefix}ld; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_LD+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$LD"; then - ac_cv_prog_LD="$LD" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_LD="${ac_tool_prefix}ld" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -LD=$ac_cv_prog_LD -if test -n "$LD"; then - { $as_echo "$as_me:$LINENO: result: $LD" >&5 -$as_echo "$LD" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_LD"; then - ac_ct_LD=$LD - # Extract the first word of "ld", so it can be a program name with args. -set dummy ld; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_LD+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_LD"; then - ac_cv_prog_ac_ct_LD="$ac_ct_LD" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_LD="ld" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_LD=$ac_cv_prog_ac_ct_LD -if test -n "$ac_ct_LD"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_LD" >&5 -$as_echo "$ac_ct_LD" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_LD" = x; then - LD="ld" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - LD=$ac_ct_LD - fi -else - LD="$ac_cv_prog_LD" -fi - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}nm", so it can be a program name with args. -set dummy ${ac_tool_prefix}nm; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_NM+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$NM"; then - ac_cv_prog_NM="$NM" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_NM="${ac_tool_prefix}nm" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -NM=$ac_cv_prog_NM -if test -n "$NM"; then - { $as_echo "$as_me:$LINENO: result: $NM" >&5 -$as_echo "$NM" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_NM"; then - ac_ct_NM=$NM - # Extract the first word of "nm", so it can be a program name with args. -set dummy nm; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_NM+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_NM"; then - ac_cv_prog_ac_ct_NM="$ac_ct_NM" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_NM="nm" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_NM=$ac_cv_prog_ac_ct_NM -if test -n "$ac_ct_NM"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_NM" >&5 -$as_echo "$ac_ct_NM" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_NM" = x; then - NM="nm" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - NM=$ac_ct_NM - fi -else - NM="$ac_cv_prog_NM" -fi - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}objcopy", so it can be a program name with args. -set dummy ${ac_tool_prefix}objcopy; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OBJCOPY+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$OBJCOPY"; then - ac_cv_prog_OBJCOPY="$OBJCOPY" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_OBJCOPY="${ac_tool_prefix}objcopy" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -OBJCOPY=$ac_cv_prog_OBJCOPY -if test -n "$OBJCOPY"; then - { $as_echo "$as_me:$LINENO: result: $OBJCOPY" >&5 -$as_echo "$OBJCOPY" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OBJCOPY"; then - ac_ct_OBJCOPY=$OBJCOPY - # Extract the first word of "objcopy", so it can be a program name with args. -set dummy objcopy; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OBJCOPY+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OBJCOPY"; then - ac_cv_prog_ac_ct_OBJCOPY="$ac_ct_OBJCOPY" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_OBJCOPY="objcopy" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_OBJCOPY=$ac_cv_prog_ac_ct_OBJCOPY -if test -n "$ac_ct_OBJCOPY"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_OBJCOPY" >&5 -$as_echo "$ac_ct_OBJCOPY" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OBJCOPY" = x; then - OBJCOPY="objcopy" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OBJCOPY=$ac_ct_OBJCOPY - fi -else - OBJCOPY="$ac_cv_prog_OBJCOPY" -fi - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. -set dummy ${ac_tool_prefix}objdump; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OBJDUMP+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$OBJDUMP"; then - ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -OBJDUMP=$ac_cv_prog_OBJDUMP -if test -n "$OBJDUMP"; then - { $as_echo "$as_me:$LINENO: result: $OBJDUMP" >&5 -$as_echo "$OBJDUMP" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OBJDUMP"; then - ac_ct_OBJDUMP=$OBJDUMP - # Extract the first word of "objdump", so it can be a program name with args. -set dummy objdump; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OBJDUMP"; then - ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_OBJDUMP="objdump" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP -if test -n "$ac_ct_OBJDUMP"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_OBJDUMP" >&5 -$as_echo "$ac_ct_OBJDUMP" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OBJDUMP" = x; then - OBJDUMP="objdump" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OBJDUMP=$ac_ct_OBJDUMP - fi -else - OBJDUMP="$ac_cv_prog_OBJDUMP" -fi - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. -set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_RANLIB+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -RANLIB=$ac_cv_prog_RANLIB -if test -n "$RANLIB"; then - { $as_echo "$as_me:$LINENO: result: $RANLIB" >&5 -$as_echo "$RANLIB" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_RANLIB"; then - ac_ct_RANLIB=$RANLIB - # Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_RANLIB"; then - ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_RANLIB="ranlib" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB -if test -n "$ac_ct_RANLIB"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 -$as_echo "$ac_ct_RANLIB" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_RANLIB" = x; then - RANLIB="ranlib" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - RANLIB=$ac_ct_RANLIB - fi -else - RANLIB="$ac_cv_prog_RANLIB" -fi - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. -set dummy ${ac_tool_prefix}strip; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_STRIP+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$STRIP"; then - ac_cv_prog_STRIP="$STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_STRIP="${ac_tool_prefix}strip" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -STRIP=$ac_cv_prog_STRIP -if test -n "$STRIP"; then - { $as_echo "$as_me:$LINENO: result: $STRIP" >&5 -$as_echo "$STRIP" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_STRIP"; then - ac_ct_STRIP=$STRIP - # Extract the first word of "strip", so it can be a program name with args. -set dummy strip; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_STRIP"; then - ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_STRIP="strip" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP -if test -n "$ac_ct_STRIP"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 -$as_echo "$ac_ct_STRIP" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_STRIP" = x; then - STRIP="strip" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - STRIP=$ac_ct_STRIP - fi -else - STRIP="$ac_cv_prog_STRIP" -fi - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}windres", so it can be a program name with args. -set dummy ${ac_tool_prefix}windres; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_WINDRES+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$WINDRES"; then - ac_cv_prog_WINDRES="$WINDRES" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_WINDRES="${ac_tool_prefix}windres" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -WINDRES=$ac_cv_prog_WINDRES -if test -n "$WINDRES"; then - { $as_echo "$as_me:$LINENO: result: $WINDRES" >&5 -$as_echo "$WINDRES" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_WINDRES"; then - ac_ct_WINDRES=$WINDRES - # Extract the first word of "windres", so it can be a program name with args. -set dummy windres; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_WINDRES+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_WINDRES"; then - ac_cv_prog_ac_ct_WINDRES="$ac_ct_WINDRES" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_WINDRES="windres" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_WINDRES=$ac_cv_prog_ac_ct_WINDRES -if test -n "$ac_ct_WINDRES"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_WINDRES" >&5 -$as_echo "$ac_ct_WINDRES" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_WINDRES" = x; then - WINDRES="windres" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - WINDRES=$ac_ct_WINDRES - fi -else - WINDRES="$ac_cv_prog_WINDRES" -fi - - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then - $as_echo_n "(cached) " >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Broken: fails on valid input. -continue -fi - -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - # Broken: success on invalid input. -continue -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Passes both tests. -ac_preproc_ok=: -break -fi - -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ $as_echo "$as_me:$LINENO: result: $CPP" >&5 -$as_echo "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Broken: fails on valid input. -continue -fi - -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - # Broken: success on invalid input. -continue -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Passes both tests. -ac_preproc_ok=: -break -fi - -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - : -else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -{ $as_echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if test "${ac_cv_path_GREP+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - ac_count=`expr $ac_count + 1` - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_GREP_found && break 3 - done - done -done -IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - { { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -$as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} - { (exit 1); exit 1; }; } - fi -else - ac_cv_path_GREP=$GREP -fi - -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ $as_echo "$as_me:$LINENO: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - ac_count=`expr $ac_count + 1` - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_EGREP_found && break 3 - done - done -done -IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - { { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -$as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} - { (exit 1); exit 1; }; } - fi -else - ac_cv_path_EGREP=$EGREP -fi - - fi -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - - -{ $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_header_stdc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_header_stdc=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then - : -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_header_stdc=no -fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi - - -fi -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -cat >>confdefs.h <<\_ACEOF -#define STDC_HEADERS 1 -_ACEOF - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. - - - - - - - - - -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default - -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - eval "$as_ac_Header=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_Header=no" -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works -# for constant arguments. Useless! -{ $as_echo "$as_me:$LINENO: checking for working alloca.h" >&5 -$as_echo_n "checking for working alloca.h... " >&6; } -if test "${ac_cv_working_alloca_h+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -int -main () -{ -char *p = (char *) alloca (2 * sizeof (int)); - if (p) return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_working_alloca_h=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_working_alloca_h=no -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_working_alloca_h" >&5 -$as_echo "$ac_cv_working_alloca_h" >&6; } -if test $ac_cv_working_alloca_h = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_ALLOCA_H 1 -_ACEOF - -fi - -{ $as_echo "$as_me:$LINENO: checking for alloca" >&5 -$as_echo_n "checking for alloca... " >&6; } -if test "${ac_cv_func_alloca_works+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifdef __GNUC__ -# define alloca __builtin_alloca -#else -# ifdef _MSC_VER -# include -# define alloca _alloca -# else -# ifdef HAVE_ALLOCA_H -# include -# else -# ifdef _AIX - #pragma alloca -# else -# ifndef alloca /* predefined by HP cc +Olibcalls */ -char *alloca (); -# endif -# endif -# endif -# endif -#endif - -int -main () -{ -char *p = (char *) alloca (1); - if (p) return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_func_alloca_works=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_func_alloca_works=no -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_alloca_works" >&5 -$as_echo "$ac_cv_func_alloca_works" >&6; } - -if test $ac_cv_func_alloca_works = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_ALLOCA 1 -_ACEOF - -else - # The SVR3 libPW and SVR4 libucb both contain incompatible functions -# that cause trouble. Some versions do not even contain alloca or -# contain a buggy version. If you still want to use their alloca, -# use ar to extract alloca.o from them instead of compiling alloca.c. - -ALLOCA=\${LIBOBJDIR}alloca.$ac_objext - -cat >>confdefs.h <<\_ACEOF -#define C_ALLOCA 1 -_ACEOF - - -{ $as_echo "$as_me:$LINENO: checking whether \`alloca.c' needs Cray hooks" >&5 -$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; } -if test "${ac_cv_os_cray+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#if defined CRAY && ! defined CRAY2 -webecray -#else -wenotbecray -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "webecray" >/dev/null 2>&1; then - ac_cv_os_cray=yes -else - ac_cv_os_cray=no -fi -rm -f conftest* - -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_os_cray" >&5 -$as_echo "$ac_cv_os_cray" >&6; } -if test $ac_cv_os_cray = yes; then - for ac_func in _getb67 GETB67 getb67; do - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif - -int -main () -{ -return $ac_func (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - eval "$as_ac_var=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_var=no" -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -as_val=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then - -cat >>confdefs.h <<_ACEOF -#define CRAY_STACKSEG_END $ac_func -_ACEOF - - break -fi - - done -fi - -{ $as_echo "$as_me:$LINENO: checking stack direction for C alloca" >&5 -$as_echo_n "checking stack direction for C alloca... " >&6; } -if test "${ac_cv_c_stack_direction+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then - ac_cv_c_stack_direction=0 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -find_stack_direction () -{ - static char *addr = 0; - auto char dummy; - if (addr == 0) - { - addr = &dummy; - return find_stack_direction (); - } - else - return (&dummy > addr) ? 1 : -1; -} - -int -main () -{ - return find_stack_direction () < 0; -} -_ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_c_stack_direction=1 -else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_c_stack_direction=-1 -fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi - - -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_stack_direction" >&5 -$as_echo "$ac_cv_c_stack_direction" >&6; } - -cat >>confdefs.h <<_ACEOF -#define STACK_DIRECTION $ac_cv_c_stack_direction -_ACEOF - - -fi - -{ $as_echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } -set x ${MAKE-make} -ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.make <<\_ACEOF -SHELL = /bin/sh -all: - @echo '@@@%%%=$(MAKE)=@@@%%%' -_ACEOF -# GNU make sometimes prints "make[1]: Entering...", which would confuse us. -case `${MAKE-make} -f conftest.make 2>/dev/null` in - *@@@%%%=?*=@@@%%%*) - eval ac_cv_prog_make_${ac_make}_set=yes;; - *) - eval ac_cv_prog_make_${ac_make}_set=no;; -esac -rm -f conftest.make -fi -if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } - SET_MAKE= -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } - SET_MAKE="MAKE=${MAKE-make}" -fi - - -# Test for builtin mem* functions. - -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -#include -void foo(char *s, int c, size_t n) -{ - __builtin_memset(s, c, n); -} - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - use_builtin_memset=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - use_builtin_memset=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -if test $use_builtin_memset = "yes"; then - cat >>confdefs.h <<\_ACEOF -#define HAVE_BUILTIN_MEMSET 1 -_ACEOF - -fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -# Check whether --enable-debugging was given. -if test "${enable_debugging+set}" = set; then - enableval=$enable_debugging; case "${enableval}" in -yes) cat >>confdefs.h <<\_ACEOF -#define DEBUGGING 1 -_ACEOF - ;; -no) ;; -esac - -fi - - -MALLOC_OFILES=malloc.o - - - -case "$target_cpu" in - i?86) DLL_ENTRY="_dll_entry@12" - DEF_DLL_ENTRY="dll_entry@12" - ALLOCA="_alloca" - CONFIG_DIR="i386" ;; - *) { { $as_echo "$as_me:$LINENO: error: Invalid target processor \"$target_cpu\"" >&5 -$as_echo "$as_me: error: Invalid target processor \"$target_cpu\"" >&2;} - { (exit 1); exit 1; }; } ;; -esac - - - - - - - -ac_config_files="$ac_config_files Makefile" - -cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, we kill variables containing newlines. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -( - for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) $as_unset $ac_var ;; - esac ;; - esac - done - - (set) 2>&1 | - case $as_nl`(ac_space=' '; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \). - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; #( - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) | - sed ' - /^ac_cv_env_/b end - t clear - :clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ - t end - s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - :end' >>confcache -if diff "$cache_file" confcache >/dev/null 2>&1; then :; else - if test -w "$cache_file"; then - test "x$cache_file" != "x/dev/null" && - { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5 -$as_echo "$as_me: updating cache $cache_file" >&6;} - cat confcache >$cache_file - else - { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 -$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} - fi -fi -rm -f confcache - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -DEFS=-DHAVE_CONFIG_H - -ac_libobjs= -ac_ltlibobjs= -for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`$as_echo "$ac_i" | sed "$ac_script"` - # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR - # will be set to the directory where LIBOBJS objects are built. - ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" - ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' -done -LIBOBJS=$ac_libobjs - -LTLIBOBJS=$ac_ltlibobjs - - - -: ${CONFIG_STATUS=./config.status} -ac_write_fail=0 -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} -cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -#! $SHELL -# Generated by $as_me. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false -SHELL=\${CONFIG_SHELL-$SHELL} -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - - - -# PATH needs CR -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - { (exit 1); exit 1; } -fi - -# Work around bugs in pre-3.0 UWIN ksh. -for as_var in ENV MAIL MAILPATH -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - - -# Name of the executable. -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# CDPATH. -$as_unset CDPATH - - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line after each line using $LINENO; the second 'sed' - # does the real work. The second script uses 'N' to pair each - # line-number line with the line containing $LINENO, and appends - # trailing '-' during substitution so that $LINENO is not a special - # case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # scripts with optimization help from Paolo Bonzini. Blame Lee - # E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in --n*) - case `echo 'x\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - *) ECHO_C='\c';; - esac;; -*) - ECHO_N='-n';; -esac -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -p' - fi -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - -if mkdir -p . 2>/dev/null; then - as_mkdir_p=: -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -exec 6>&1 - -# Save the log message, to keep $[0] and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. -ac_log=" -This file was extended by $as_me, which was -generated by GNU Autoconf 2.63. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -on `(hostname || uname -n) 2>/dev/null | sed 1q` -" - -_ACEOF - -case $ac_config_files in *" -"*) set x $ac_config_files; shift; ac_config_files=$*;; -esac - -case $ac_config_headers in *" -"*) set x $ac_config_headers; shift; ac_config_headers=$*;; -esac - - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# Files that config.status was made for. -config_files="$ac_config_files" -config_headers="$ac_config_headers" - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -ac_cs_usage="\ -\`$as_me' instantiates files from templates according to the -current configuration. - -Usage: $0 [OPTION]... [FILE]... - - -h, --help print this help, then exit - -V, --version print version number and configuration settings, then exit - -q, --quiet, --silent - do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - --header=FILE[:TEMPLATE] - instantiate the configuration header FILE - -Configuration files: -$config_files - -Configuration headers: -$config_headers - -Report bugs to ." - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_cs_version="\\ -config.status -configured by $0, generated by GNU Autoconf 2.63, - with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" - -Copyright (C) 2008 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." - -ac_pwd='$ac_pwd' -srcdir='$srcdir' -INSTALL='$INSTALL' -test -n "\$AWK" || AWK=awk -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# The default lists apply if the user does not specify any file. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=*) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` - ac_shift=: - ;; - *) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - esac - - case $ac_option in - # Handling of the options. - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - $as_echo "$ac_cs_version"; exit ;; - --debug | --debu | --deb | --de | --d | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - CONFIG_FILES="$CONFIG_FILES '$ac_optarg'" - ac_need_defaults=false;; - --header | --heade | --head | --hea ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - CONFIG_HEADERS="$CONFIG_HEADERS '$ac_optarg'" - ac_need_defaults=false;; - --he | --h) - # Conflict between --help and --header - { $as_echo "$as_me: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; };; - --help | --hel | -h ) - $as_echo "$ac_cs_usage"; exit ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) { $as_echo "$as_me: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } ;; - - *) ac_config_targets="$ac_config_targets $1" - ac_need_defaults=false ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -if \$ac_cs_recheck; then - set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion - shift - \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 - CONFIG_SHELL='$SHELL' - export CONFIG_SHELL - exec "\$@" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX - $as_echo "$ac_log" -} >&5 - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - -# Handling of arguments. -for ac_config_target in $ac_config_targets -do - case $ac_config_target in - "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - - *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 -$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;} - { (exit 1); exit 1; }; };; - esac -done - - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files - test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason against having it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Hook for its removal unless debugging. -# Note that there is a small window in which the directory will not be cleaned: -# after its creation but before its name has been assigned to `$tmp'. -$debug || -{ - tmp= - trap 'exit_status=$? - { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status -' 0 - trap '{ (exit 1); exit 1; }' 1 2 13 15 -} -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" -} || -{ - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") -} || -{ - $as_echo "$as_me: cannot create a temporary directory in ." >&2 - { (exit 1); exit 1; } -} - -# Set up the scripts for CONFIG_FILES section. -# No need to generate them if there are no CONFIG_FILES. -# This happens for instance with `./config.status config.h'. -if test -n "$CONFIG_FILES"; then - - -ac_cr=' ' -ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` -if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\\r' -else - ac_cs_awk_cr=$ac_cr -fi - -echo 'BEGIN {' >"$tmp/subs1.awk" && -_ACEOF - - -{ - echo "cat >conf$$subs.awk <<_ACEOF" && - echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && - echo "_ACEOF" -} >conf$$subs.sh || - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } -ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` -ac_delim='%!_!# ' -for ac_last_try in false false false false false :; do - . ./conf$$subs.sh || - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } - - ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` - if test $ac_delim_n = $ac_delim_num; then - break - elif $ac_last_try; then - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done -rm -f conf$$subs.sh - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$tmp/subs1.awk" <<\\_ACAWK && -_ACEOF -sed -n ' -h -s/^/S["/; s/!.*/"]=/ -p -g -s/^[^!]*!// -:repl -t repl -s/'"$ac_delim"'$// -t delim -:nl -h -s/\(.\{148\}\).*/\1/ -t more1 -s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ -p -n -b repl -:more1 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t nl -:delim -h -s/\(.\{148\}\).*/\1/ -t more2 -s/["\\]/\\&/g; s/^/"/; s/$/"/ -p -b -:more2 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t delim -' >$CONFIG_STATUS || ac_write_fail=1 -rm -f conf$$subs.awk -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACAWK -cat >>"\$tmp/subs1.awk" <<_ACAWK && - for (key in S) S_is_set[key] = 1 - FS = "" - -} -{ - line = $ 0 - nfields = split(line, field, "@") - substed = 0 - len = length(field[1]) - for (i = 2; i < nfields; i++) { - key = field[i] - keylen = length(key) - if (S_is_set[key]) { - value = S[key] - line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) - len += length(value) + length(field[++i]) - substed = 1 - } else - len += 1 + keylen - } - - print line -} - -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then - sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" -else - cat -fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ - || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5 -$as_echo "$as_me: error: could not setup config files machinery" >&2;} - { (exit 1); exit 1; }; } -_ACEOF - -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/ -s/:*\${srcdir}:*/:/ -s/:*@srcdir@:*/:/ -s/^\([^=]*=[ ]*\):*/\1/ -s/:*$// -s/^[^=]*=[ ]*$// -}' -fi - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -fi # test -n "$CONFIG_FILES" - -# Set up the scripts for CONFIG_HEADERS section. -# No need to generate them if there are no CONFIG_HEADERS. -# This happens for instance with `./config.status Makefile'. -if test -n "$CONFIG_HEADERS"; then -cat >"$tmp/defines.awk" <<\_ACAWK || -BEGIN { -_ACEOF - -# Transform confdefs.h into an awk script `defines.awk', embedded as -# here-document in config.status, that substitutes the proper values into -# config.h.in to produce config.h. - -# Create a delimiter string that does not exist in confdefs.h, to ease -# handling of long lines. -ac_delim='%!_!# ' -for ac_last_try in false false :; do - ac_t=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_t"; then - break - elif $ac_last_try; then - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_HEADERS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_HEADERS" >&2;} - { (exit 1); exit 1; }; } - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done - -# For the awk script, D is an array of macro values keyed by name, -# likewise P contains macro parameters if any. Preserve backslash -# newline sequences. - -ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* -sed -n ' -s/.\{148\}/&'"$ac_delim"'/g -t rset -:rset -s/^[ ]*#[ ]*define[ ][ ]*/ / -t def -d -:def -s/\\$// -t bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3"/p -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p -d -:bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3\\\\\\n"\\/p -t cont -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p -t cont -d -:cont -n -s/.\{148\}/&'"$ac_delim"'/g -t clear -:clear -s/\\$// -t bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/"/p -d -:bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p -b cont -' >$CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - for (key in D) D_is_set[key] = 1 - FS = "" -} -/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { - line = \$ 0 - split(line, arg, " ") - if (arg[1] == "#") { - defundef = arg[2] - mac1 = arg[3] - } else { - defundef = substr(arg[1], 2) - mac1 = arg[2] - } - split(mac1, mac2, "(") #) - macro = mac2[1] - prefix = substr(line, 1, index(line, defundef) - 1) - if (D_is_set[macro]) { - # Preserve the white space surrounding the "#". - print prefix "define", macro P[macro] D[macro] - next - } else { - # Replace #undef with comments. This is necessary, for example, - # in the case of _POSIX_SOURCE, which is predefined and required - # on some systems where configure will not decide to define it. - if (defundef == "undef") { - print "/*", prefix defundef, macro, "*/" - next - } - } -} -{ print } -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - { { $as_echo "$as_me:$LINENO: error: could not setup config headers machinery" >&5 -$as_echo "$as_me: error: could not setup config headers machinery" >&2;} - { (exit 1); exit 1; }; } -fi # test -n "$CONFIG_HEADERS" - - -eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " -shift -for ac_tag -do - case $ac_tag in - :[FHLC]) ac_mode=$ac_tag; continue;; - esac - case $ac_mode$ac_tag in - :[FHL]*:*);; - :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5 -$as_echo "$as_me: error: invalid tag $ac_tag" >&2;} - { (exit 1); exit 1; }; };; - :[FH]-) ac_tag=-:-;; - :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; - esac - ac_save_IFS=$IFS - IFS=: - set x $ac_tag - IFS=$ac_save_IFS - shift - ac_file=$1 - shift - - case $ac_mode in - :L) ac_source=$1;; - :[FH]) - ac_file_inputs= - for ac_f - do - case $ac_f in - -) ac_f="$tmp/stdin";; - *) # Look for the file first in the build tree, then in the source tree - # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. - test -f "$ac_f" || - case $ac_f in - [\\/$]*) false;; - *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; - esac || - { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 -$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;} - { (exit 1); exit 1; }; };; - esac - case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - ac_file_inputs="$ac_file_inputs '$ac_f'" - done - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - configure_input='Generated from '` - $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' - `' by configure.' - if test x"$ac_file" != x-; then - configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:$LINENO: creating $ac_file" >&5 -$as_echo "$as_me: creating $ac_file" >&6;} - fi - # Neutralize special characters interpreted by sed in replacement strings. - case $configure_input in #( - *\&* | *\|* | *\\* ) - ac_sed_conf_input=`$as_echo "$configure_input" | - sed 's/[\\\\&|]/\\\\&/g'`;; #( - *) ac_sed_conf_input=$configure_input;; - esac - - case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin" \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } ;; - esac - ;; - esac - - ac_dir=`$as_dirname -- "$ac_file" || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - { as_dir="$ac_dir" - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 -$as_echo "$as_me: error: cannot create directory $as_dir" >&2;} - { (exit 1); exit 1; }; }; } - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - - case $ac_mode in - :F) - # - # CONFIG_FILE - # - - case $INSTALL in - [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; - *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; - esac -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# If the template does not know about datarootdir, expand it. -# FIXME: This hack should be removed a few years after 2.60. -ac_datarootdir_hack=; ac_datarootdir_seen= - -ac_sed_dataroot=' -/datarootdir/ { - p - q -} -/@datadir@/p -/@docdir@/p -/@infodir@/p -/@localedir@/p -/@mandir@/p -' -case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in -*datarootdir*) ac_datarootdir_seen=yes;; -*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - ac_datarootdir_hack=' - s&@datadir@&$datadir&g - s&@docdir@&$docdir&g - s&@infodir@&$infodir&g - s&@localedir@&$localedir&g - s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; -esac -_ACEOF - -# Neutralize VPATH when `$srcdir' = `.'. -# Shell code in configure.ac might set extrasub. -# FIXME: do we really want to maintain this feature? -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_sed_extra="$ac_vpsub -$extrasub -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s|@configure_input@|$ac_sed_conf_input|;t t -s&@top_builddir@&$ac_top_builddir_sub&;t t -s&@top_build_prefix@&$ac_top_build_prefix&;t t -s&@srcdir@&$ac_srcdir&;t t -s&@abs_srcdir@&$ac_abs_srcdir&;t t -s&@top_srcdir@&$ac_top_srcdir&;t t -s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t -s&@builddir@&$ac_builddir&;t t -s&@abs_builddir@&$ac_abs_builddir&;t t -s&@abs_top_builddir@&$ac_abs_top_builddir&;t t -s&@INSTALL@&$ac_INSTALL&;t t -$ac_datarootdir_hack -" -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } - -test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&5 -$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&2;} - - rm -f "$tmp/stdin" - case $ac_file in - -) cat "$tmp/out" && rm -f "$tmp/out";; - *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; - esac \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } - ;; - :H) - # - # CONFIG_HEADER - # - if test x"$ac_file" != x-; then - { - $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" - } >"$tmp/config.h" \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } - if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then - { $as_echo "$as_me:$LINENO: $ac_file is unchanged" >&5 -$as_echo "$as_me: $ac_file is unchanged" >&6;} - else - rm -f "$ac_file" - mv "$tmp/config.h" "$ac_file" \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } - fi - else - $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ - || { { $as_echo "$as_me:$LINENO: error: could not create -" >&5 -$as_echo "$as_me: error: could not create -" >&2;} - { (exit 1); exit 1; }; } - fi - ;; - - - esac - -done # for ac_tag - - -{ (exit 0); exit 0; } -_ACEOF -chmod +x $CONFIG_STATUS -ac_clean_files=$ac_clean_files_save - -test $ac_write_fail = 0 || - { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } - - -# configure is writing to config.log, and then calls config.status. -# config.status does its own redirection, appending to config.log. -# Unfortunately, on DOS this fails, as config.log is still kept open -# by configure, so config.status won't be able to write to it; its -# output is simply discarded. So we exec the FD to /dev/null, -# effectively closing config.log, so it can be properly (re)opened and -# appended to by config.status. When coming back to configure, we -# need to make the FD available again. -if test "$no_create" != yes; then - ac_cs_success=: - ac_config_status_args= - test "$silent" = yes && - ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null - $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. - $ac_cs_success || { (exit 1); exit 1; } -fi -if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 -$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} -fi - diff --git a/winsup/cygwin/configure.in b/winsup/cygwin/configure.in deleted file mode 100644 index fcd4f8f7f..000000000 --- a/winsup/cygwin/configure.in +++ /dev/null @@ -1,110 +0,0 @@ -dnl Autoconf configure script for Cygwin. -dnl Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, -dnl 2008, 2009 Red Hat, Inc. -dnl -dnl This file is part of Cygwin. -dnl -dnl This software is a copyrighted work licensed under the terms of the -dnl Cygwin license. Please consult the file "CYGWIN_LICENSE" for -dnl details. -dnl -dnl Process this file with autoconf to produce a configure script. - -AC_PREREQ(2.59)dnl -AC_INIT(init.cc) -AC_CONFIG_HEADER(config.h) -AC_CONFIG_AUX_DIR(../..) - -AC_PROG_INSTALL -AC_CANONICAL_SYSTEM - -LIB_AC_PROG_CC -LIB_AC_PROG_CXX - -case "$with_cross_host" in - ""|*cygwin*) - all_host="all_host" - install_host="install_host" - LIBSERVER='$(bupdir)/cygserver/libcygserver.a' - ;; - *) - all_host= - install_host= - LIBSERVER= - ;; -esac - -AC_SUBST(all_host) -AC_SUBST(install_host) - -AC_CHECK_TOOL(AR, ar, ar) -AC_CHECK_TOOL(AS, as, as) -AC_CHECK_TOOL(DLLTOOL, dlltool, dlltool) -AC_CHECK_TOOL(LD, ld, ld) -AC_CHECK_TOOL(NM, nm, nm) -AC_CHECK_TOOL(OBJCOPY, objcopy, objcopy) -AC_CHECK_TOOL(OBJDUMP, objdump, objdump) -AC_CHECK_TOOL(RANLIB, ranlib, ranlib) -AC_CHECK_TOOL(STRIP, strip, strip) -AC_CHECK_TOOL(WINDRES, windres, windres) - -AC_ALLOCA -AC_PROG_MAKE_SET - -dnl check whether gcc supports __builtin_memset. -# Test for builtin mem* functions. -AC_LANG_SAVE -AC_LANG_CPLUSPLUS -AC_TRY_COMPILE([ -#include -void foo(char *s, int c, size_t n) -{ - __builtin_memset(s, c, n); -} -], [ ], -use_builtin_memset=yes, use_builtin_memset=no) -if test $use_builtin_memset = "yes"; then - AC_DEFINE(HAVE_BUILTIN_MEMSET) -fi -AC_LANG_RESTORE - -AC_ARG_ENABLE(debugging, -[ --enable-debugging Build a cygwin DLL which has more consistency checking for debugging], -[case "${enableval}" in -yes) AC_DEFINE(DEBUGGING) ;; -no) ;; -esac -]) - -MALLOC_OFILES=malloc.o - -dnl The only time we might want to transform the install names -dnl is for unix x cygwin. Otherwise we don't. For now we don't -dnl transform names. - -dnl if test "x$cross_compiling" = "xno" -a ; then -dnl if test "x$program_transform_name" = "xs,x,x,"; then -dnl program_transform_name="" -dnl fi -dnl if test "x$program_transform_name" = "x"; then -dnl program_transform_name="s,^,$target_alias-," -dnl else -dnl program_transform_name="$program_transform_name -e s,^,$target_alias-," -dnl fi -dnl fi - -case "$target_cpu" in - i?86) DLL_ENTRY="_dll_entry@12" - DEF_DLL_ENTRY="dll_entry@12" - ALLOCA="_alloca" - CONFIG_DIR="i386" ;; - *) AC_MSG_ERROR(Invalid target processor \"$target_cpu\") ;; -esac - -AC_SUBST(MALLOC_OFILES) -AC_SUBST(LIBSERVER) -AC_SUBST(DLL_ENTRY) -AC_SUBST(DEF_DLL_ENTRY) -AC_SUBST(ALLOCA) -AC_SUBST(CONFIG_DIR) -AC_OUTPUT(Makefile) diff --git a/winsup/cygwin/cpuid.h b/winsup/cygwin/cpuid.h deleted file mode 100644 index 998bbbf91..000000000 --- a/winsup/cygwin/cpuid.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef CPUID_H -#define CPUID_H - -extern inline void -cpuid (unsigned *a, unsigned *b, unsigned *c, unsigned *d, unsigned in) -{ - asm ("cpuid" - : "=a" (*a), - "=b" (*b), - "=c" (*c), - "=d" (*d) - : "a" (in)); -} - -extern inline bool -can_set_flag (unsigned flag) -{ - unsigned r1, r2; - asm("pushfl\n" - "popl %0\n" - "movl %0, %1\n" - "xorl %2, %0\n" - "pushl %0\n" - "popfl\n" - "pushfl\n" - "popl %0\n" - "pushl %1\n" - "popfl\n" - : "=&r" (r1), "=&r" (r2) - : "ir" (flag) - ); - return ((r1 ^ r2) & flag) != 0; -} - -#endif // !CPUID_H diff --git a/winsup/cygwin/crt0.c b/winsup/cygwin/crt0.c deleted file mode 100644 index 1421f6566..000000000 --- a/winsup/cygwin/crt0.c +++ /dev/null @@ -1,55 +0,0 @@ -/* crt0.c. - - Copyright 2001, 2005 Red Hat, Inc. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* In the following ifdef'd i386 code, the FPU precision is set to 80 bits - and all FPU exceptions are masked. The former is needed to make long - doubles work correctly. The latter causes the FPU to generate NaNs and - Infinities instead of signals for certain operations. -*/ - -#ifdef __i386__ -#define FPU_RESERVED 0xF0C0 -#define FPU_DEFAULT 0x033f - -/* For debugging on *#!$@ windbg. bp for breakpoint. */ -int __cygwin_crt0_bp = 0; -#endif - -extern int main (int argc, char **argv); - -void cygwin_crt0 (int (*main) (int, char **)); - -void -mainCRTStartup () -{ -#ifdef __i386__ - (void)__builtin_return_address(1); - asm volatile ("andl $-16,%%esp" ::: "%esp"); - if (__cygwin_crt0_bp) - asm volatile ("int3"); - - { - volatile unsigned short cw; - - /* Get Control Word */ - __asm__ volatile ("fnstcw %0" : "=m" (cw) : ); - - /* mask in */ - cw &= FPU_RESERVED; - cw |= FPU_DEFAULT; - - /* set cw */ - __asm__ volatile ("fldcw %0" :: "m" (cw)); - } -#endif - - cygwin_crt0 (main); -} - -void WinMainCRTStartup(void) __attribute__ ((alias("mainCRTStartup"))); - diff --git a/winsup/cygwin/ctype.cc b/winsup/cygwin/ctype.cc deleted file mode 100644 index 224db4c19..000000000 --- a/winsup/cygwin/ctype.cc +++ /dev/null @@ -1,90 +0,0 @@ -#include "winsup.h" -extern "C" { -#include -#include -#include - -extern char _ctype_b[128 + 256]; - -/* Called from newlib's setlocale(). What we do here is to copy the - 128 bytes of charset specific ctype data into the array at _ctype_b. - Given that the functionality is usually implemented locally in the - application, that's the only backward compatible way to do it. - Setlocale is usually only called once in an application, so this isn't - time-critical anyway. */ -extern int __iso_8859_index (const char *charset_ext); /* Newlib */ -extern int __cp_index (const char *charset_ext); /* Newlib */ -extern const char __ctype_cp[22][128 + 256]; /* Newlib */ -extern const char __ctype_iso[15][128 + 256]; /* Newlib */ - -void -__set_ctype (const char *charset) -{ - int idx; - - switch (*charset) - { - case 'I': - idx = __iso_8859_index (charset + 9); - /* Our ctype table has a leading ISO-8859-1 element. */ - if (idx < 0) - idx = 0; - else - ++idx; - if (CYGWIN_VERSION_CHECK_FOR_OLD_CTYPE) - { - memcpy (_ctype_b, __ctype_iso[idx], 128); - memcpy (_ctype_b + 256, __ctype_iso[idx] + 256, 128); - } - __ctype_ptr__ = (char *) (__ctype_iso[idx] + 127); - return; - case 'C': - idx = __cp_index (charset + 2); - if (idx < 0) - break; - if (CYGWIN_VERSION_CHECK_FOR_OLD_CTYPE) - { - memcpy (_ctype_b, __ctype_cp[idx], 128); - memcpy (_ctype_b + 256, __ctype_cp[idx] + 256, 128); - } - __ctype_ptr__ = (char *) (__ctype_cp[idx] + 127); - return; - default: - break; - } - if (CYGWIN_VERSION_CHECK_FOR_OLD_CTYPE) - { - memset (_ctype_b, 0, 128); - memset (_ctype_b + 256, 0, 128); - } - __ctype_ptr__ = (char *) _ctype_b + 127; -} - -} /* extern "C" */ - -/* - * Copyright (c) 1989 The Regents of the University of California. - * All rights reserved. - * - * 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. - * - * 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. - */ - diff --git a/winsup/cygwin/cxx.cc b/winsup/cygwin/cxx.cc deleted file mode 100644 index 0faeaf7ee..000000000 --- a/winsup/cygwin/cxx.cc +++ /dev/null @@ -1,108 +0,0 @@ -/* cxx.cc - - Copyright 2002, 2003, 2005, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#if (__GNUC__ >= 3) - -#include "winsup.h" -#include "cygwin-cxx.h" - -/* These implementations of operators new and delete are used internally by - the DLL, and are kept separate from the user's/libstdc++'s versions by - use of LD's --wrap option. */ - -void * -operator new (std::size_t s) -{ - void *p = calloc (1, s); - return p; -} - -void -operator delete (void *p) -{ - free (p); -} - -void * -operator new[] (std::size_t s) -{ - return ::operator new (s); -} - -void -operator delete[] (void *p) -{ - ::operator delete (p); -} - -/* Nothrow versions, provided only for completeness in the fallback array. */ - -void * -operator new (std::size_t s, const std::nothrow_t &) -{ - void *p = calloc (1, s); - return p; -} - -void -operator delete (void *p, const std::nothrow_t &) -{ - free (p); -} - -void * -operator new[] (std::size_t s, const std::nothrow_t &nt) -{ - return ::operator new (s, nt); -} - -void -operator delete[] (void *p, const std::nothrow_t &nt) -{ - ::operator delete (p, nt); -} - - -extern "C" void -__cxa_pure_virtual (void) -{ - api_fatal ("pure virtual method called"); -} - -extern "C" void -__cxa_guard_acquire () -{ -} - -extern "C" void -__cxa_guard_release () -{ -} - -/* These routines are made available as last-resort fallbacks - for the application. Should not be used in practice; the - entries in this struct get overwritten by each DLL as it - is loaded, and libstdc++ will override the whole lot first - thing of all. */ - -struct per_process_cxx_malloc default_cygwin_cxx_malloc = -{ - &(operator new), - &(operator new[]), - &(operator delete), - &(operator delete[]), - &(operator new), - &(operator new[]), - &(operator delete), - &(operator delete[]), -}; - - -#endif diff --git a/winsup/cygwin/cygerrno.h b/winsup/cygwin/cygerrno.h deleted file mode 100644 index e6ec7c556..000000000 --- a/winsup/cygwin/cygerrno.h +++ /dev/null @@ -1,52 +0,0 @@ -/* cygerrno.h: main Cygwin header file. - - Copyright 2000, 2001, 2002, 2003, 2004 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGERRNO_H -#define _CYGERRNO_H -#include - -void __stdcall seterrno_from_win_error (const char *file, int line, DWORD code) __attribute__ ((regparm(3))); -void __stdcall seterrno (const char *, int line) __attribute__ ((regparm(2))); -int __stdcall geterrno_from_win_error (DWORD code = GetLastError (), int deferrno = 13 /*EACCESS*/) __attribute__ ((regparm(2))); - -#define __seterrno() seterrno (__FILE__, __LINE__) -#define __seterrno_from_win_error(val) seterrno_from_win_error (__FILE__, __LINE__, val) -#define __seterrno_from_nt_status(status) \ - ({ \ - DWORD winerr = RtlNtStatusToDosError (status); \ - SetLastError (winerr); \ - __seterrno_from_win_error (winerr); \ - }) - -inline int -__set_errno (const char *fn, int ln, int val) -{ - debug_printf ("%s:%d val %d", fn, ln, val); - return errno = _impure_ptr->_errno = val; -} -#define set_errno(val) __set_errno (__PRETTY_FUNCTION__, __LINE__, (val)) - -#define get_errno() (errno) -extern "C" void __stdcall set_sig_errno (int e); - -class save_errno - { - int saved; - public: - save_errno () {saved = get_errno ();} - save_errno (int what) {saved = get_errno (); set_errno (what); } - void set (int what) {set_errno (what); saved = what;} - void reset () {saved = get_errno ();} - ~save_errno () {errno = _impure_ptr->_errno = saved;} - }; - -extern const char *__sp_fn; -extern int __sp_ln; -#endif /*_CYGERRNO_H*/ diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc deleted file mode 100644 index 7c66d736a..000000000 --- a/winsup/cygwin/cygheap.cc +++ /dev/null @@ -1,461 +0,0 @@ -/* cygheap.cc: Cygwin heap manager. - - Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Red Hat, Inc. - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#include "winsup.h" -#include -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "child_info.h" -#include "heap.h" -#include "sigproc.h" -#include "pinfo.h" -#include -#include - -static mini_cygheap NO_COPY cygheap_at_start = -{ - {__utf8_mbtowc, __utf8_wctomb} -}; - -init_cygheap NO_COPY *cygheap = (init_cygheap *) &cygheap_at_start; -void NO_COPY *cygheap_max; - -extern "C" char _cygheap_mid[] __attribute__((section(".cygheap"))); -extern "C" char _cygheap_end[]; - -static NO_COPY muto cygheap_protect; - -struct cygheap_entry -{ - int type; - struct cygheap_entry *next; - char data[0]; -}; - -#define NBUCKETS (sizeof (cygheap->buckets) / sizeof (cygheap->buckets[0])) -#define N0 ((_cmalloc_entry *) NULL) -#define to_cmalloc(s) ((_cmalloc_entry *) (((char *) (s)) - (unsigned) (N0->data))) - -#define CFMAP_OPTIONS (SEC_RESERVE | PAGE_READWRITE) -#define MVMAP_OPTIONS (FILE_MAP_WRITE) - -extern "C" { -static void __stdcall _cfree (void *) __attribute__((regparm(1))); -static void *__stdcall _csbrk (int); -} - -/* Called by fork or spawn to reallocate cygwin heap */ -void __stdcall -cygheap_fixup_in_child (bool execed) -{ - cygheap_max = child_proc_info->cygheap; - cygheap = (init_cygheap *) cygheap_max; - _csbrk ((char *) child_proc_info->cygheap_max - (char *) cygheap); - child_copy (child_proc_info->parent, false, "cygheap", cygheap, cygheap_max, NULL); - cygheap_init (); - debug_fixup_after_fork_exec (); - if (execed) - { - cygheap->hooks.next = NULL; - cygheap->user_heap.base = NULL; /* We can allocate the heap anywhere */ - /* Walk the allocated memory chain looking for orphaned memory from - previous execs */ - for (_cmalloc_entry *rvc = cygheap->chain; rvc; rvc = rvc->prev) - { - cygheap_entry *ce = (cygheap_entry *) rvc->data; - if (!rvc->ptr || rvc->b >= NBUCKETS || ce->type <= HEAP_1_START) - continue; - else if (ce->type < HEAP_1_MAX) - ce->type += HEAP_1_MAX; /* Mark for freeing after next exec */ - else - _cfree (ce); /* Marked by parent for freeing in child */ - } - } -} - -int -init_cygheap::manage_console_count (const char *something, int amount, bool avoid_freeing_console) -{ - if (console_count == 0 && amount > 0) - init_console_handler (true); - console_count += amount; - debug_printf ("%s: console_count %d, amount %d, %s, avoid_freeing_console %d", - something, console_count, amount, myctty (), avoid_freeing_console); - if (!avoid_freeing_console && amount <= 0 && !console_count && myself->ctty == -1) - { - BOOL res = FreeConsole (); - debug_printf ("freed console, res %d", res); - init_console_handler (false); - } - return console_count; -} - -void -init_cygheap::close_ctty () -{ - debug_printf ("closing cygheap->ctty %p", cygheap->ctty); - cygheap->ctty->close (); - cygheap->ctty = NULL; -} - -#define nextpage(x) ((char *) (((DWORD) ((char *) x + granmask)) & ~granmask)) -#define allocsize(x) ((DWORD) nextpage (x)) -#ifdef DEBUGGING -#define somekinda_printf debug_printf -#else -#define somekinda_printf malloc_printf -#endif - -static void *__stdcall -_csbrk (int sbs) -{ - void *prebrk = cygheap_max; - size_t granmask = getpagesize () - 1; - char *newbase = nextpage (prebrk); - cygheap_max = (char *) cygheap_max + sbs; - if (!sbs || (newbase >= cygheap_max) || (cygheap_max <= _cygheap_end)) - /* nothing to do */; - else - { - if (prebrk <= _cygheap_end) - newbase = _cygheap_end; - - DWORD adjsbs = allocsize ((char *) cygheap_max - newbase); - if (adjsbs && !VirtualAlloc (newbase, adjsbs, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE)) - { - MEMORY_BASIC_INFORMATION m; - if (!VirtualQuery (newbase, &m, sizeof m)) - system_printf ("couldn't get memory info, %E"); - somekinda_printf ("Couldn't reserve/commit %d bytes of space for cygwin's heap, %E", - adjsbs); - somekinda_printf ("AllocationBase %p, BaseAddress %p, RegionSize %p, State %p\n", - m.AllocationBase, m.BaseAddress, m.RegionSize, m.State); - __seterrno (); - cygheap_max = (char *) cygheap_max - sbs; - return NULL; - } - } - - return prebrk; -} - -void __stdcall -cygheap_init () -{ - cygheap_protect.init ("cygheap_protect"); - if (cygheap == &cygheap_at_start) - { - cygheap = (init_cygheap *) memset (_cygheap_start, 0, - _cygheap_mid - _cygheap_start); - cygheap_max = cygheap; - _csbrk (sizeof (*cygheap)); - /* Default locale settings. */ - cygheap->locale.mbtowc = __utf8_mbtowc; - cygheap->locale.wctomb = __utf8_wctomb; - strcpy (cygheap->locale.charset, "UTF-8"); - /* Set umask to a sane default. */ - cygheap->umask = 022; - } - if (!cygheap->fdtab) - cygheap->fdtab.init (); - if (!cygheap->sigs) - sigalloc (); -} - -/* Copyright (C) 1997, 2000 DJ Delorie */ - -static void *_cmalloc (unsigned size) __attribute ((regparm(1))); -static void *__stdcall _crealloc (void *ptr, unsigned size) __attribute ((regparm(2))); - -static void *__stdcall -_cmalloc (unsigned size) -{ - _cmalloc_entry *rvc; - unsigned b, sz; - - /* Calculate "bit bucket" and size as a power of two. */ - for (b = 3, sz = 8; sz && sz < size; b++, sz <<= 1) - continue; - - cygheap_protect.acquire (); - if (cygheap->buckets[b]) - { - rvc = (_cmalloc_entry *) cygheap->buckets[b]; - cygheap->buckets[b] = rvc->ptr; - rvc->b = b; - } - else - { - rvc = (_cmalloc_entry *) _csbrk (sz + sizeof (_cmalloc_entry)); - if (!rvc) - { - cygheap_protect.release (); - return NULL; - } - - rvc->b = b; - rvc->prev = cygheap->chain; - cygheap->chain = rvc; - } - cygheap_protect.release (); - return rvc->data; -} - -static void __stdcall -_cfree (void *ptr) -{ - cygheap_protect.acquire (); - _cmalloc_entry *rvc = to_cmalloc (ptr); - DWORD b = rvc->b; - rvc->ptr = cygheap->buckets[b]; - cygheap->buckets[b] = (char *) rvc; - cygheap_protect.release (); -} - -static void *__stdcall -_crealloc (void *ptr, unsigned size) -{ - void *newptr; - if (ptr == NULL) - newptr = _cmalloc (size); - else - { - unsigned oldsize = 1 << to_cmalloc (ptr)->b; - if (size <= oldsize) - return ptr; - newptr = _cmalloc (size); - if (newptr) - { - memcpy (newptr, ptr, oldsize); - _cfree (ptr); - } - } - return newptr; -} - -/* End Copyright (C) 1997 DJ Delorie */ - -#define sizeof_cygheap(n) ((n) + sizeof (cygheap_entry)) - -#define N ((cygheap_entry *) NULL) -#define tocygheap(s) ((cygheap_entry *) (((char *) (s)) - (int) (N->data))) - -inline static void * -creturn (cygheap_types x, cygheap_entry * c, unsigned len, const char *fn = NULL) -{ - if (c) - /* nothing to do */; - else if (fn) - api_fatal ("%s would have returned NULL", fn); - else - { - set_errno (ENOMEM); - return NULL; - } - c->type = x; - char *cend = ((char *) c + sizeof (*c) + len); - if (cygheap_max < cend) - cygheap_max = cend; - MALLOC_CHECK; - return (void *) c->data; -} - -inline static void * -cmalloc (cygheap_types x, DWORD n, const char *fn) -{ - cygheap_entry *c; - MALLOC_CHECK; - c = (cygheap_entry *) _cmalloc (sizeof_cygheap (n)); - return creturn (x, c, n, fn); -} - -extern "C" void * -cmalloc (cygheap_types x, DWORD n) -{ - return cmalloc (x, n, NULL); -} - -extern "C" void * -cmalloc_abort (cygheap_types x, DWORD n) -{ - return cmalloc (x, n, "cmalloc"); -} - -inline static void * -crealloc (void *s, DWORD n, const char *fn) -{ - MALLOC_CHECK; - if (s == NULL) - return cmalloc (HEAP_STR, n); // kludge - - assert (!inheap (s)); - cygheap_entry *c = tocygheap (s); - cygheap_types t = (cygheap_types) c->type; - c = (cygheap_entry *) _crealloc (c, sizeof_cygheap (n)); - return creturn (t, c, n, fn); -} - -extern "C" void *__stdcall -crealloc (void *s, DWORD n) -{ - return crealloc (s, n, NULL); -} - -extern "C" void *__stdcall -crealloc_abort (void *s, DWORD n) -{ - return crealloc (s, n, "crealloc"); -} - -extern "C" void __stdcall -cfree (void *s) -{ - assert (!inheap (s)); - _cfree (tocygheap (s)); - MALLOC_CHECK; -} - -extern "C" void __stdcall -cfree_and_set (char *&s, char *what) -{ - if (s && s != almost_null) - cfree (s); - s = what; -} - -inline static void * -ccalloc (cygheap_types x, DWORD n, DWORD size, const char *fn) -{ - cygheap_entry *c; - MALLOC_CHECK; - n *= size; - c = (cygheap_entry *) _cmalloc (sizeof_cygheap (n)); - if (c) - memset (c->data, 0, n); - return creturn (x, c, n, fn); -} - -extern "C" void *__stdcall -ccalloc (cygheap_types x, DWORD n, DWORD size) -{ - return ccalloc (x, n, size, NULL); -} - -extern "C" void *__stdcall -ccalloc_abort (cygheap_types x, DWORD n, DWORD size) -{ - return ccalloc (x, n, size, "ccalloc"); -} - -extern "C" PWCHAR __stdcall -cwcsdup (const PWCHAR s) -{ - MALLOC_CHECK; - PWCHAR p = (PWCHAR) cmalloc (HEAP_STR, wcslen (s) + 1); - if (!p) - return NULL; - wcpcpy (p, s); - MALLOC_CHECK; - return p; -} - -extern "C" PWCHAR __stdcall -cwcsdup1 (const PWCHAR s) -{ - MALLOC_CHECK; - PWCHAR p = (PWCHAR) cmalloc (HEAP_1_STR, wcslen (s) + 1); - if (!p) - return NULL; - wcpcpy (p, s); - MALLOC_CHECK; - return p; -} - -extern "C" char *__stdcall -cstrdup (const char *s) -{ - MALLOC_CHECK; - char *p = (char *) cmalloc (HEAP_STR, strlen (s) + 1); - if (!p) - return NULL; - strcpy (p, s); - MALLOC_CHECK; - return p; -} - -extern "C" char *__stdcall -cstrdup1 (const char *s) -{ - MALLOC_CHECK; - char *p = (char *) cmalloc (HEAP_1_STR, strlen (s) + 1); - if (!p) - return NULL; - strcpy (p, s); - MALLOC_CHECK; - return p; -} - -void -cygheap_root::set (const char *posix, const char *native, bool caseinsensitive) -{ - if (*posix == '/' && posix[1] == '\0') - { - if (m) - { - cfree (m); - m = NULL; - } - return; - } - if (!m) - m = (struct cygheap_root_mount_info *) ccalloc (HEAP_MOUNT, 1, sizeof (*m)); - strcpy (m->posix_path, posix); - m->posix_pathlen = strlen (posix); - if (m->posix_pathlen >= 1 && m->posix_path[m->posix_pathlen - 1] == '/') - m->posix_path[--m->posix_pathlen] = '\0'; - - strcpy (m->native_path, native); - m->native_pathlen = strlen (native); - if (m->native_pathlen >= 1 && m->native_path[m->native_pathlen - 1] == '\\') - m->native_path[--m->native_pathlen] = '\0'; - m->caseinsensitive = caseinsensitive; -} - -cygheap_user::~cygheap_user () -{ -} - -void -cygheap_user::set_name (const char *new_name) -{ - bool allocated = !!pname; - - if (allocated) - { - if (strcasematch (new_name, pname)) - return; - cfree (pname); - } - - pname = cstrdup (new_name ? new_name : ""); - if (!allocated) - return; /* Initializing. Don't bother with other stuff. */ - - cfree_and_set (homedrive); - cfree_and_set (homepath); - cfree_and_set (plogsrv); - cfree_and_set (pdomain); - cfree_and_set (pwinname); -} diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h deleted file mode 100644 index b8ffd3fbe..000000000 --- a/winsup/cygwin/cygheap.h +++ /dev/null @@ -1,420 +0,0 @@ -/* cygheap.h: Cygwin heap manager. - - Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "hires.h" -#include "cygheap_malloc.h" - -#define incygheap(s) (cygheap && ((char *) (s) >= (char *) cygheap) && ((char *) (s) <= ((char *) cygheap_max))) - -struct _cmalloc_entry -{ - union - { - DWORD b; - char *ptr; - }; - struct _cmalloc_entry *prev; - char data[0]; -}; - -struct cygheap_root_mount_info -{ - char posix_path[CYG_MAX_PATH]; - unsigned posix_pathlen; - char native_path[CYG_MAX_PATH]; - unsigned native_pathlen; - bool caseinsensitive; -}; - -/* CGF: FIXME This doesn't belong here */ - -class cygheap_root -{ - /* Root directory information. - This is used after a chroot is called. */ - struct cygheap_root_mount_info *m; - -public: - bool posix_ok (const char *path) - { - if (!m) - return 1; - return path_prefix_p (m->posix_path, path, m->posix_pathlen, - m->caseinsensitive); - } - bool ischroot_native (const char *path) - { - if (!m) - return 1; - return strncasematch (m->native_path, path, m->native_pathlen) - && (path[m->native_pathlen] == '\\' || !path[m->native_pathlen]); - } - const char *unchroot (const char *path) - { - if (!m) - return path; - const char *p = path + m->posix_pathlen; - if (!*p) - p = "/"; - return p; - } - bool exists () {return !!m;} - void set (const char *, const char *, bool); - size_t posix_length () const { return m->posix_pathlen; } - const char *posix_path () const { return m->posix_path; } - size_t native_length () const { return m->native_pathlen; } - const char *native_path () const { return m->native_path; } -}; - -enum homebodies -{ - CH_HOMEDRIVE, - CH_HOMEPATH, - CH_HOME -}; - -class cygheap_user -{ - /* Extendend user information. - The information is derived from the internal_getlogin call - when on a NT system. */ - char *pname; /* user's name */ - char *plogsrv; /* Logon server, may be FQDN */ - char *pdomain; /* Logon domain of the user */ - char *homedrive; /* User's home drive */ - char *homepath; /* User's home path */ - char *psystemroot; /* Value of SYSTEMROOT */ - char *pwinname; /* User's name as far as Windows knows it */ - char *puserprof; /* User profile */ - cygsid effec_cygsid; /* buffer for user's SID */ - cygsid saved_cygsid; /* Remains intact even after impersonation */ -public: - __uid32_t saved_uid; /* Remains intact even after impersonation */ - __gid32_t saved_gid; /* Ditto */ - __uid32_t real_uid; /* Remains intact on seteuid, replaced by setuid */ - __gid32_t real_gid; /* Ditto */ - user_groups groups; /* Primary and supp SIDs */ - - /* token is needed if set(e)uid should be called. It can be set by a call - to `set_impersonation_token()'. */ - HANDLE external_token; - HANDLE internal_token; - HANDLE curr_primary_token; - HANDLE curr_imp_token; - bool ext_token_is_restricted; /* external_token is restricted token */ - bool curr_token_is_restricted; /* curr_primary_token is restricted token */ - bool setuid_to_restricted; /* switch to restricted token by setuid () */ - - /* CGF 2002-06-27. I removed the initializaton from this constructor - since this class is always allocated statically. That means that everything - is zero anyway so there is no need to initialize it to zero. Since the - token initialization is always handled during process startup as well, - I've removed the constructor entirely. Please reinstate this if this - situation ever changes. - cygheap_user () : pname (NULL), plogsrv (NULL), pdomain (NULL), - homedrive (NULL), homepath (NULL), - token (INVALID_HANDLE_VALUE) {} - */ - - ~cygheap_user (); - - void init (); - void set_name (const char *new_name); - const char *name () const { return pname; } - - const char *env_logsrv (const char *, size_t); - const char *env_homepath (const char *, size_t); - const char *env_homedrive (const char *, size_t); - const char *env_userprofile (const char *, size_t); - const char *env_domain (const char *, size_t); - const char *env_name (const char *, size_t); - const char *env_systemroot (const char *, size_t); - - const char *logsrv () - { - const char *p = env_logsrv ("LOGONSERVER=", sizeof ("LOGONSERVER=") - 1); - return (p == almost_null) ? NULL : p; - } - const char *winname () - { - const char *p = env_name ("USERNAME=", sizeof ("USERNAME=") - 1); - return (p == almost_null) ? NULL : p; - } - const char *domain () - { - const char *p = env_domain ("USERDOMAIN=", sizeof ("USERDOMAIN=") - 1); - return (p == almost_null) ? NULL : p; - } - BOOL set_sid (PSID new_sid) {return (BOOL) (effec_cygsid = new_sid);} - BOOL set_saved_sid () { return (BOOL) (saved_cygsid = effec_cygsid); } - PSID sid () { return effec_cygsid; } - PSID saved_sid () { return saved_cygsid; } - const char *ontherange (homebodies what, struct passwd * = NULL); -#define NO_IMPERSONATION NULL - bool issetuid () const { return curr_imp_token != NO_IMPERSONATION; } - HANDLE primary_token () { return curr_primary_token; } - HANDLE imp_token () { return curr_imp_token; } - void deimpersonate () - { - RevertToSelf (); - } - bool reimpersonate () - { - if (issetuid ()) - return ImpersonateLoggedOnUser (primary_token ()); - return true; - } - bool has_impersonation_tokens () - { return external_token != NO_IMPERSONATION - || internal_token != NO_IMPERSONATION - || curr_primary_token != NO_IMPERSONATION; } - void close_impersonation_tokens () - { - if (curr_imp_token != NO_IMPERSONATION) - CloseHandle (curr_imp_token); - if (curr_primary_token != NO_IMPERSONATION - && curr_primary_token != external_token - && curr_primary_token != internal_token) - CloseHandle (curr_primary_token); - if (external_token != NO_IMPERSONATION) - CloseHandle (external_token); - if (internal_token != NO_IMPERSONATION) - CloseHandle (internal_token); - } - PWCHAR get_windows_id (PWCHAR buf) - { - return effec_cygsid.string (buf); - } - char *get_windows_id (char *buf) - { - return effec_cygsid.string (buf); - } - - const char *test_uid (char *&, const char *, size_t) - __attribute__ ((regparm (3))); -}; - -/* cwd cache stuff. */ - -class muto; - -class cwdstuff -{ -private: - char *posix; - HANDLE dir; -public: - UNICODE_STRING win32; - DWORD drive_length; - static muto cwd_lock; - const char *get_posix () const { return posix; }; - void reset_posix (wchar_t *); - char *get (char *, int = 1, int = 0, unsigned = NT_MAX_PATH); - HANDLE get_handle () { return dir; } - DWORD get_drive (char * dst) - { - cwd_lock.acquire (); - DWORD ret = sys_wcstombs (dst, NT_MAX_PATH, win32.Buffer, drive_length); - cwd_lock.release (); - return ret; - } - void init (); - int set (PUNICODE_STRING, const char *, bool); -}; - -#ifdef DEBUGGING -struct cygheap_debug -{ - handle_list starth; - handle_list freeh[500]; -}; -#endif - -struct cygheap_locale -{ - mbtowc_p mbtowc; - wctomb_p wctomb; - char charset[ENCODING_LEN + 1]; -}; - -struct user_heap_info -{ - void *base; - void *ptr; - void *top; - void *max; - unsigned chunk; - unsigned slop; -}; - -struct hook_chain -{ - void **loc; - const void *func; - struct hook_chain *next; -}; - -struct mini_cygheap -{ - cygheap_locale locale; -}; - -struct init_cygheap: public mini_cygheap -{ - _cmalloc_entry *chain; - char *buckets[32]; - cygheap_root root; - cygheap_user user; - user_heap_info user_heap; - mode_t umask; - HANDLE console_h; - cwdstuff cwd; - dtable fdtab; -#ifdef DEBUGGING - cygheap_debug debug; -#endif - struct sigaction *sigs; - - fhandler_tty_slave *ctty; /* Current tty */ -#ifdef NEWVFORK - fhandler_tty_slave *ctty_on_hold; -#endif - struct _cygtls **threadlist; - size_t sthreads; - pid_t pid; /* my pid */ - HANDLE pid_handle; /* handle for my pid */ - struct { /* Equivalent to using LIST_HEAD. */ - struct inode_t *lh_first; - } inode_list; /* Global inode pointer for adv. locking. */ - hook_chain hooks; - void close_ctty (); - int manage_console_count (const char *, int, bool = false) __attribute__ ((regparm (3))); -private: - int console_count; -}; - - -#define _CYGHEAPSIZE_SLOP (128 * 1024) -#define CYGHEAPSIZE (sizeof (init_cygheap) + (20000 * sizeof (fhandler_union)) + _CYGHEAPSIZE_SLOP) -#define CYGHEAPSIZE_MIN (sizeof (init_cygheap) + (10000 * sizeof (fhandler_union))) - -extern init_cygheap *cygheap; -extern void *cygheap_max; - -class cygheap_fdmanip -{ - protected: - int fd; - fhandler_base **fh; - bool locked; - public: - cygheap_fdmanip (): fh (NULL) {} - virtual ~cygheap_fdmanip () - { - if (locked) - cygheap->fdtab.unlock (); - } - void release () - { - cygheap->fdtab.release (fd); - } - operator int &() {return fd;} - operator fhandler_base* &() {return *fh;} - operator fhandler_socket* () const {return reinterpret_cast (*fh);} - operator fhandler_pipe* () const {return reinterpret_cast (*fh);} - void operator = (fhandler_base *fh) {*this->fh = fh;} - fhandler_base *operator -> () const {return *fh;} - bool isopen () const - { - if (*fh) - return true; - set_errno (EBADF); - return false; - } -}; - -class cygheap_fdnew : public cygheap_fdmanip -{ - public: - cygheap_fdnew (int seed_fd = -1, bool lockit = true) - { - if (lockit) - cygheap->fdtab.lock (); - if (seed_fd < 0) - fd = cygheap->fdtab.find_unused_handle (); - else - fd = cygheap->fdtab.find_unused_handle (seed_fd + 1); - if (fd >= 0) - { - locked = lockit; - fh = cygheap->fdtab + fd; - } - else - { - set_errno (EMFILE); - if (lockit) - cygheap->fdtab.unlock (); - locked = false; - } - } - void operator = (fhandler_base *fh) {*this->fh = fh;} -}; - -class cygheap_fdget : public cygheap_fdmanip -{ - public: - cygheap_fdget (int fd, bool lockit = false, bool do_set_errno = true) - { - if (lockit) - cygheap->fdtab.lock (); - if (fd >= 0 && fd < (int) cygheap->fdtab.size - && *(fh = cygheap->fdtab + fd) != NULL) - { - this->fd = fd; - locked = lockit; - } - else - { - this->fd = -1; - if (do_set_errno) - set_errno (EBADF); - if (lockit) - cygheap->fdtab.unlock (); - locked = false; - } - } -}; - -class cygheap_fdenum : public cygheap_fdmanip -{ - public: - cygheap_fdenum (bool lockit = false) - { - locked = lockit; - if (lockit) - cygheap->fdtab.lock (); - fd = -1; - } - int next () - { - while (++fd < (int) cygheap->fdtab.size) - if (*(fh = cygheap->fdtab + fd) != NULL) - return fd; - return -1; - } - void rewind () - { - fd = -1; - } -}; - -void __stdcall cygheap_fixup_in_child (bool); -void __stdcall cygheap_init (); -extern char _cygheap_start[] __attribute__((section(".idata"))); diff --git a/winsup/cygwin/cygheap_malloc.h b/winsup/cygwin/cygheap_malloc.h deleted file mode 100644 index 12ed4bd76..000000000 --- a/winsup/cygwin/cygheap_malloc.h +++ /dev/null @@ -1,54 +0,0 @@ -/* cygheap_malloc.h: Cygwin heap manager allocation functions. - - Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGHEAP_MALLOC_H -#define _CYGHEAP_MALLOC_H - -#undef cfree - -enum cygheap_types -{ - HEAP_FHANDLER, - HEAP_STR, - HEAP_ARGV, - HEAP_BUF, - HEAP_MOUNT, - HEAP_SIGS, - HEAP_ARCHETYPES, - HEAP_TLS, - HEAP_COMMUNE, - HEAP_1_START, - HEAP_1_HOOK, - HEAP_1_STR, - HEAP_1_ARGV, - HEAP_1_BUF, - HEAP_1_EXEC, - HEAP_1_MAX = 100, - HEAP_2_STR, - HEAP_2_DLL, - HEAP_MMAP = 200 -}; - -extern "C" { -void __stdcall cfree (void *) __attribute__ ((regparm(1))); -void *__stdcall cmalloc (cygheap_types, DWORD) __attribute__ ((regparm(2))); -void *__stdcall crealloc (void *, DWORD) __attribute__ ((regparm(2))); -void *__stdcall ccalloc (cygheap_types, DWORD, DWORD) __attribute__ ((regparm(3))); -void *__stdcall cmalloc_abort (cygheap_types, DWORD) __attribute__ ((regparm(2))); -void *__stdcall crealloc_abort (void *, DWORD) __attribute__ ((regparm(2))); -void *__stdcall ccalloc_abort (cygheap_types, DWORD, DWORD) __attribute__ ((regparm(3))); -PWCHAR __stdcall cwcsdup (const PWCHAR) __attribute__ ((regparm(1))); -PWCHAR __stdcall cwcsdup1 (const PWCHAR) __attribute__ ((regparm(1))); -char *__stdcall cstrdup (const char *) __attribute__ ((regparm(1))); -char *__stdcall cstrdup1 (const char *) __attribute__ ((regparm(1))); -void __stdcall cfree_and_set (char *&, char * = NULL) __attribute__ ((regparm(2))); -} - -#endif /*_CYGHEAP_MALLOC_H*/ diff --git a/winsup/cygwin/cyglsa.h b/winsup/cygwin/cyglsa.h deleted file mode 100644 index c9edece58..000000000 --- a/winsup/cygwin/cyglsa.h +++ /dev/null @@ -1,213 +0,0 @@ -/* cyglsa.h: Header file for Cygwin LSA authentication - - Copyright 2006 Red Hat, Inc. - - Written by Corinna Vinschen - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for details. */ - -#ifndef _CYGLSA_H -#define _CYGLSA_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define CYG_LSA_PKGNAME "CygwinLsa" - -#define CYG_LSA_MAGIC_OLD1 0x0379f014LU -/* First change to cyglsa_t. - - Username and domain are now of type WCHAR instead of char. - - domain is MAX_DOMAIN_NAME_LEN instead of INTERNET_MAX_HOST_NAME_LENGTH. */ -#define CYG_LSA_MAGIC 0x0379f115LU - -/* Datastructures not defined in w32api. */ -typedef PVOID *PLSA_CLIENT_REQUEST; - -typedef UNICODE_STRING SECURITY_STRING, *PSECURITY_STRING; - -typedef struct _SECPKG_CLIENT_INFO -{ - LUID LogonId; - ULONG ProcessID; - ULONG ThreadID; - BOOLEAN HasTcbPrivilege; - BOOLEAN Impersonating; - BOOLEAN Restricted; -} SECPKG_CLIENT_INFO, *PSECPKG_CLIENT_INFO; - -typedef enum _SECPKG_NAME_TYPE -{ - SecNameSamCompatible, - SecNameAlternateId, - SecNameFlat, - SecNameDN, - SecNameSPN -} SECPKG_NAME_TYPE, *PSECPKG_NAME_TYPE; - -typedef struct _SECPKG_CALL_INFO -{ - ULONG ProcessId; - ULONG ThreadId; - ULONG Attributes; - ULONG CallCount; -} SECPKG_CALL_INFO, *PSECPKG_CALL_INFO; - -/* The table returned by LsaApInitializePackage is actually a - LSA_SECPKG_FUNCTION_TABLE even though that's not documented. - We need only a subset of this table, basically the LSA_DISPATCH_TABLE - plus the pointer to the GetClientInfo function. */ -typedef struct _LSA_SECPKG_FUNCS -{ - NTSTATUS (NTAPI *CreateLogonSession)(PLUID); - NTSTATUS (NTAPI *DeleteLogonSession)(PLUID); - NTSTATUS (NTAPI *AddCredentials)(PLUID, ULONG, PLSA_STRING, PLSA_STRING); - NTSTATUS (NTAPI *GetCredentials)(PVOID); /* wrong prototype, unused */ - NTSTATUS (NTAPI *DeleteCredentials)(PVOID); /* wrong prototype, unused */ - PVOID (NTAPI *AllocateLsaHeap)(ULONG); - VOID (NTAPI *FreeLsaHeap)(PVOID); - NTSTATUS (NTAPI *AllocateClientBuffer)(PLSA_CLIENT_REQUEST, ULONG, PVOID *); - NTSTATUS (NTAPI *FreeClientBuffer)(PLSA_CLIENT_REQUEST, PVOID); - NTSTATUS (NTAPI *CopyToClientBuffer)(PLSA_CLIENT_REQUEST, ULONG, - PVOID, PVOID); - NTSTATUS (NTAPI *CopyFromClientBuffer)(PLSA_CLIENT_REQUEST, ULONG, - PVOID, PVOID); - NTSTATUS (NTAPI *ImpersonateClient)(VOID); - NTSTATUS (NTAPI *UnloadPackage)(VOID); - NTSTATUS (NTAPI *DuplicateHandle)(HANDLE, PHANDLE); - NTSTATUS (NTAPI *SaveSupplementalCredentials)(VOID); - NTSTATUS (NTAPI *CreateThread)(PVOID); /* wrong prototype, unused */ - NTSTATUS (NTAPI *GetClientInfo)(PSECPKG_CLIENT_INFO); - NTSTATUS (NTAPI *RegisterNotification)(PVOID); /* wrong prototype, unused */ - NTSTATUS (NTAPI *CancelNotification)(PVOID); /* wrong prototype, unused */ - NTSTATUS (NTAPI *MapBuffer)(PVOID); /* wrong prototype, unused */ - NTSTATUS (NTAPI *CreateToken)(PVOID); /* wrong prototype, unused */ - NTSTATUS (NTAPI *AuditLogon)(PVOID); /* wrong prototype, unused */ - NTSTATUS (NTAPI *CallPackage)(PVOID); /* wrong prototype, unused */ - NTSTATUS (NTAPI *FreeReturnBuffer)(PVOID); /* wrong prototype, unused */ - BOOLEAN (NTAPI *GetCallInfo)(PSECPKG_CALL_INFO); - NTSTATUS (NTAPI *CallPackageEx)(PVOID); /* wrong prototype, unused */ - NTSTATUS (NTAPI *CreateSharedMemory)(PVOID); /* wrong prototype, unused */ - NTSTATUS (NTAPI *AllocateSharedMemory)(PVOID); /* wrong prototype, unused */ - NTSTATUS (NTAPI *FreeSharedMemory)(PVOID); /* wrong prototype, unused */ - NTSTATUS (NTAPI *DeleteSharedMemory)(PVOID); /* wrong prototype, unused */ - NTSTATUS (NTAPI *OpenSamUser)(PSECURITY_STRING, SECPKG_NAME_TYPE, - PSECURITY_STRING, BOOLEAN, ULONG, PVOID *); - NTSTATUS (NTAPI *GetUserCredentials)(PVOID, PVOID, PULONG, PVOID *, PULONG); - NTSTATUS (NTAPI *GetUserAuthData)(PVOID, PUCHAR *, PULONG); - NTSTATUS (NTAPI *CloseSamUser)(PVOID); - NTSTATUS (NTAPI *ConvertAuthDataToToken)(PVOID, ULONG, - SECURITY_IMPERSONATION_LEVEL, - PTOKEN_SOURCE, SECURITY_LOGON_TYPE, - PUNICODE_STRING, PHANDLE, PLUID, - PUNICODE_STRING, PNTSTATUS); - NTSTATUS (NTAPI *ClientCallback)(PVOID); /* wrong prototype, unused */ - NTSTATUS (NTAPI *UpdateCredentials)(PVOID); /* wrong prototype, unused */ - NTSTATUS (NTAPI *GetAuthDataForUser)(PSECURITY_STRING, SECPKG_NAME_TYPE, - PSECURITY_STRING, PUCHAR *, PULONG, - PUNICODE_STRING); - NTSTATUS (NTAPI *CrackSingleName)(PVOID); /* wrong prototype, unused */ - NTSTATUS (NTAPI *AuditAccountLogon)(PVOID); /* wrong prototype, unused */ - NTSTATUS (NTAPI *CallPackagePassthrough)(PVOID); /* wrong prototype, unused */ -} LSA_SECPKG_FUNCS, *PLSA_SECPKG_FUNCS; - -typedef enum _LSA_TOKEN_INFORMATION_TYPE -{ - LsaTokenInformationNull, - LsaTokenInformationV1, - LsaTokenInformationV2 -} LSA_TOKEN_INFORMATION_TYPE, *PLSA_TOKEN_INFORMATION_TYPE; - -typedef struct _LSA_TOKEN_INFORMATION_V2 -{ - LARGE_INTEGER ExpirationTime; - TOKEN_USER User; - PTOKEN_GROUPS Groups; - TOKEN_PRIMARY_GROUP PrimaryGroup; - PTOKEN_PRIVILEGES Privileges; - TOKEN_OWNER Owner; - TOKEN_DEFAULT_DACL DefaultDacl; -} LSA_TOKEN_INFORMATION_V2, *PLSA_TOKEN_INFORMATION_V2; - -/* These structures are eqivalent to the appropriate Windows structures, - using 32 bit offsets instead of pointers. These datastructures are - used to transfer the logon information to the LSA authentication package. - We can't use the LSA_TOKEN_INFORMATION_V2 structure directly, because - its size differs between 32 bit and 64 bit Windows. */ - -typedef DWORD OFFSET; - -typedef struct _CYG_SID_AND_ATTRIBUTES -{ - OFFSET Sid; - DWORD Attributes; -} CYG_SID_AND_ATTRIBUTES, *PCYG_SID_AND_ATTRIBUTES; - -typedef struct _CYG_TOKEN_USER -{ - CYG_SID_AND_ATTRIBUTES User; -} CYG_TOKEN_USER, *PCYG_TOKEN_USER; - -typedef struct _CYG_TOKEN_GROUPS -{ - DWORD GroupCount; - CYG_SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY]; -} CYG_TOKEN_GROUPS, *PCYG_TOKEN_GROUPS; - -typedef struct _CYG_TOKEN_PRIMARY_GROUP -{ - OFFSET PrimaryGroup; -} CYG_TOKEN_PRIMARY_GROUP, *PCYG_TOKEN_PRIMARY_GROUP; - -typedef struct _CYG_TOKEN_OWNER -{ - OFFSET Owner; -} CYG_TOKEN_OWNER, *PCYG_TOKEN_OWNER; - -typedef struct _CYG_TOKEN_DEFAULT_DACL -{ - OFFSET DefaultDacl; -} CYG_TOKEN_DEFAULT_DACL, *PCYG_TOKEN_DEFAULT_DACL; - -typedef struct _CYG_LSA_TOKEN_INFORMATION -{ - LARGE_INTEGER ExpirationTime; - CYG_TOKEN_USER User; - OFFSET Groups; - CYG_TOKEN_PRIMARY_GROUP PrimaryGroup; - OFFSET Privileges; - CYG_TOKEN_OWNER Owner; - CYG_TOKEN_DEFAULT_DACL DefaultDacl; -} CYG_LSA_TOKEN_INFORMATION, *PCYG_LSA_TOKEN_INFORMATION; - -/* This is the structure created by security.cc:lsaauth(), which is given to - LsaApLogonUser to create the token information returned to the LSA. */ -typedef struct -{ - DWORD magic; - DWORD checksum; - WCHAR username[UNLEN + 1]; - WCHAR domain[MAX_DOMAIN_NAME_LEN + 1]; - ULONG inf_size; - CYG_LSA_TOKEN_INFORMATION inf; - BYTE data[1]; -} cyglsa_t; - -typedef struct -{ - DWORD magic_pre; - HANDLE token; - DWORD magic_post; -} cygprf_t; - -#define MAGIC_PRE 0x12345678UL -#define MAGIC_POST 0x87654321UL - -#ifdef __cplusplus -} -#endif - -#endif /* _CYGLSA_H */ diff --git a/winsup/cygwin/cygmagic b/winsup/cygwin/cygmagic deleted file mode 100755 index a8ccc8c76..000000000 --- a/winsup/cygwin/cygmagic +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# cygmagic - Generate "magic numbers" from a structure. -# -# Copyright 2001, 2002 Red Hat, Inc. -# -# This file is part of Cygwin. -# -# This software is a copyrighted work licensed under the terms of the -# Cygwin license. Please consult the file "CYGWIN_LICENSE" for -# details. - -file_magic=$1; shift -gcc=$1; shift -file=$1; shift -trap "rm -f /tmp/$$.magic" 0 1 2 15 -cat < $file_magic -/* autogenerated - do not edit */ -#include "$file" -EOF -sumit() { - cksum $* -} - -while [ -n "$1" ]; do - define=$1; shift - struct=$1; shift - sum=`$gcc -E $file | sed -n "/^$struct/,/^};/p" | sed -e 's/[ ]//g' -e '/^$/d' | sumit | awk '{printf "0x%xU", $1}'` - echo "#define $define $sum" - curr=`sed -n "s/^#[ ]*define CURR_$define[ ][ ]*\([^ ][^ ]*\)/\1/p" $file` - [ "$curr" != "$sum" ] && echo "*** WARNING WARNING WARNING WARNING WARNING *** -*** $file: magic number for $define changed old $curr != new $sum -*** WARNING WARNING WARNING WARNING WARNING ***" 1>&2 -done >> $file_magic -exit 0 diff --git a/winsup/cygwin/cygmalloc.h b/winsup/cygwin/cygmalloc.h deleted file mode 100644 index 5c2a29a3b..000000000 --- a/winsup/cygwin/cygmalloc.h +++ /dev/null @@ -1,36 +0,0 @@ -/* cygmalloc.h: cygwin DLL malloc stuff - - Copyright 2002, 2003, 2004, 2005, 2007 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifdef __cplusplus -extern "C" { -#endif -void dlfree (void *p) __attribute__ ((regparm (1))); -void *dlmalloc (unsigned size) __attribute__ ((regparm (1))); -void *dlrealloc (void *p, unsigned size) __attribute__ ((regparm (2))); -void *dlcalloc (size_t nmemb, size_t size) __attribute__ ((regparm (2))); -void *dlmemalign (size_t alignment, size_t bytes) __attribute__ ((regparm (2))); -void *dlvalloc (size_t bytes) __attribute__ ((regparm (1))); -size_t dlmalloc_usable_size (void *p) __attribute__ ((regparm (1))); -int dlmalloc_trim (size_t) __attribute__ ((regparm (1))); -int dlmallopt (int p, int v) __attribute__ ((regparm (2))); -void dlmalloc_stats (); - -#ifndef __INSIDE_CYGWIN__ -extern "C" void __set_ENOMEM (); -# define MALLOC_FAILURE_ACTION __set_ENOMEM () -# define USE_DL_PREFIX 1 -#else -# define __malloc_lock() mallock.acquire () -# define __malloc_unlock() mallock.release () -extern muto mallock; -#endif -#ifdef __cplusplus -} -#endif diff --git a/winsup/cygwin/cygprops.h b/winsup/cygwin/cygprops.h deleted file mode 100644 index fa367bc5b..000000000 --- a/winsup/cygwin/cygprops.h +++ /dev/null @@ -1,20 +0,0 @@ -/* cygprops.h: Cygwin DLL properties - - Copyright 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* DLL properties data. */ -struct cygwin_props_t -{ - char magic[68]; - ULONG size; - ULONG disable_key; -}; - -#define CYGWIN_PROPS_MAGIC \ - "Fortunately, I keep my feathers numbered for just such an emergency" diff --git a/winsup/cygwin/cygserver.h b/winsup/cygwin/cygserver.h deleted file mode 100644 index b549ed006..000000000 --- a/winsup/cygwin/cygserver.h +++ /dev/null @@ -1,191 +0,0 @@ -/* cygserver.h - - Copyright 2001, 2002, 2003, 2004, 2008 Red Hat Inc. - - Written by Egor Duda - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGSERVER_H_ -#define _CYGSERVER_H_ - -#ifdef __GNUC__ -#define CYGSERVER_PACKED __attribute__ ((packed)) -#else -#define CYGSERVER_PACKED -#endif - -#define CYGWIN_SERVER_VERSION_MAJOR 1 -#define CYGWIN_SERVER_VERSION_API 4 -#define CYGWIN_SERVER_VERSION_MINOR 0 -#define CYGWIN_SERVER_VERSION_PATCH 0 - -typedef enum { - CYGSERVER_UNKNOWN = 0, - CYGSERVER_OK, - CYGSERVER_UNAVAIL -} cygserver_states; - -/*---------------------------------------------------------------------------* - * class client_request - *---------------------------------------------------------------------------*/ - -class transport_layer_base; - -#ifndef __INSIDE_CYGWIN__ -class process_cache; -#endif - -class client_request -{ -protected: - typedef enum { - CYGSERVER_REQUEST_INVALID, - CYGSERVER_REQUEST_GET_VERSION, - CYGSERVER_REQUEST_SHUTDOWN, - CYGSERVER_REQUEST_ATTACH_TTY, - CYGSERVER_REQUEST_MSG, - CYGSERVER_REQUEST_SEM, - CYGSERVER_REQUEST_SHM, - CYGSERVER_REQUEST_SETPWD, - CYGSERVER_REQUEST_LAST - } request_code_t; - - struct header_t - { - size_t msglen; - union - { - request_code_t request_code; - ssize_t error_code; - }; - - header_t () {}; - header_t (request_code_t, size_t); - } CYGSERVER_PACKED; - -public: -#ifndef __INSIDE_CYGWIN__ - static void handle_request (transport_layer_base *, process_cache *); -#endif - - client_request (request_code_t request_code, - void *buf = NULL, - size_t bufsiz = 0); - virtual ~client_request (); - - request_code_t request_code () const { return _header.request_code; } - - ssize_t error_code () const { return _header.error_code; }; - void error_code (ssize_t error_code) { _header.error_code = error_code; }; - - size_t msglen () const { return _header.msglen; }; - void msglen (size_t len) { _header.msglen = len; }; - - int make_request (); - -protected: - virtual void send (transport_layer_base *); - -private: - header_t _header; - void * const _buf; - const size_t _buflen; - -#ifndef __INSIDE_CYGWIN__ - void handle (transport_layer_base *, process_cache *); - virtual void serve (transport_layer_base *, process_cache *) = 0; -#endif -}; - -/*---------------------------------------------------------------------------* - * class client_request_get_version - *---------------------------------------------------------------------------*/ - -class client_request_get_version : public client_request -{ -private: - struct request_get_version - { - DWORD major, api, minor, patch; - } CYGSERVER_PACKED; - -public: - client_request_get_version (); - bool check_version () const; - -private: - struct request_get_version version; - -#ifndef __INSIDE_CYGWIN__ - virtual void serve (transport_layer_base *, process_cache *); -#endif -}; - -/*---------------------------------------------------------------------------* - * class client_request_shutdown - * - * Nb. This whole class is only !__INSIDE_CYGWIN__ since it is used - * solely by cygserver itself. - *---------------------------------------------------------------------------*/ - -#ifndef __INSIDE_CYGWIN__ - -class client_request_shutdown : public client_request -{ -public: - client_request_shutdown (); - -private: - virtual void serve (transport_layer_base *, process_cache *); -}; - -#endif /* !__INSIDE_CYGWIN__ */ - -/*---------------------------------------------------------------------------* - * class client_request_attach_tty - *---------------------------------------------------------------------------*/ - -class client_request_attach_tty : public client_request -{ -private: - struct request_attach_tty - { - DWORD pid, master_pid; - HANDLE from_master, to_master; - } CYGSERVER_PACKED; - -public: -#ifdef __INSIDE_CYGWIN__ - client_request_attach_tty (DWORD nmaster_pid, - HANDLE nfrom_master, HANDLE nto_master); -#else - client_request_attach_tty (); -#endif - - HANDLE from_master () const { return req.from_master; }; - HANDLE to_master () const { return req.to_master; }; - -protected: - virtual void send (transport_layer_base *); - -private: - struct request_attach_tty req; - -#ifndef __INSIDE_CYGWIN__ - virtual void serve (transport_layer_base *, process_cache *); -#endif -}; - -#ifndef __INSIDE_CYGWIN__ -extern PSID admininstrator_group_sid; -#endif - -extern bool check_cygserver_available (); -extern void cygserver_init (); - -#endif /* _CYGSERVER_H_ */ diff --git a/winsup/cygwin/cygserver_ipc.h b/winsup/cygwin/cygserver_ipc.h deleted file mode 100644 index d25a3bdeb..000000000 --- a/winsup/cygwin/cygserver_ipc.h +++ /dev/null @@ -1,84 +0,0 @@ -/* cygserver_ipc.h - - Copyright 2002, 2003, 2004 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef __CYGSERVER_IPC_H__ -#define __CYGSERVER_IPC_H__ - -/* - * Datastructure which is part of any IPC input parameter block. - */ -struct vmspace { - void *vm_map; /* UNUSED */ - struct shmmap_state *vm_shm; -}; - -struct proc { - pid_t cygpid; - DWORD winpid; - __uid32_t uid; - __gid32_t gid; - int gidcnt; - __gid32_t *gidlist; - bool is_admin; - struct vmspace *p_vmspace; - HANDLE signal_arrived; -}; - -#ifdef __INSIDE_CYGWIN__ -inline void -ipc_set_proc_info (proc &blk) -{ - blk.cygpid = getpid (); - blk.winpid = GetCurrentProcessId (); - blk.uid = geteuid32 (); - blk.gid = getegid32 (); - blk.gidcnt = 0; - blk.gidlist = NULL; - blk.is_admin = false; - blk.signal_arrived = signal_arrived; -} -#endif /* __INSIDE_CYGWIN__ */ - -#ifndef __INSIDE_CYGWIN__ -class ipc_retval { -private: - union { - int i; - unsigned int u; - vm_offset_t off; - vm_object_t obj; - }; - -public: - ipc_retval (int ni) { i = ni; } - - operator int () const { return i; } - int operator = (int ni) { return i = ni; } - - operator unsigned int () const { return u; } - unsigned int operator = (unsigned int nu) { return u = nu; } - - operator vm_offset_t () const { return off; } - vm_offset_t operator = (vm_offset_t noff) { return off = noff; } - - operator vm_object_t () const { return obj; } - vm_object_t operator = (vm_object_t nobj) { return obj = nobj; } -}; - -struct thread { - class process *client; - proc *ipcblk; - ipc_retval td_retval[2]; -}; -#define td_proc ipcblk -#define p_pid cygpid -#endif - -#endif /* __CYGSERVER_IPC_H__ */ diff --git a/winsup/cygwin/cygserver_msg.h b/winsup/cygwin/cygserver_msg.h deleted file mode 100644 index 37616bb1d..000000000 --- a/winsup/cygwin/cygserver_msg.h +++ /dev/null @@ -1,91 +0,0 @@ -/* cygserver_msg.h: Single unix specification IPC interface for Cygwin. - - Copyright 2003, 2008 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef __CYGSERVER_MSG_H__ -#define __CYGSERVER_MSG_H__ - -#include -#include -#ifndef _KERNEL -#define _KERNEL 1 -#endif -#include - -#include "cygserver.h" -#include "cygserver_ipc.h" - -#ifndef __INSIDE_CYGWIN__ -class transport_layer_base; -class process_cache; -#endif - -class client_request_msg : public client_request -{ - friend class client_request; - -public: - enum msgop_t - { - MSGOP_msgctl, - MSGOP_msgget, - MSGOP_msgrcv, - MSGOP_msgsnd - }; - -private: - union - { - struct - { - msgop_t msgop; - proc ipcblk; - union - { - struct msgctl_args ctlargs; - struct msgget_args getargs; - struct msgrcv_args rcvargs; - struct msgsnd_args sndargs; - }; - } in; - - union { - int ret; - ssize_t rcv; - } out; - } _parameters; - -#ifndef __INSIDE_CYGWIN__ - client_request_msg (); - virtual void serve (transport_layer_base *, process_cache *); -#endif - -public: - -#ifdef __INSIDE_CYGWIN__ - client_request_msg (int, int, struct msqid_ds *); // msgctl - client_request_msg (key_t, int); // msgget - client_request_msg (int, void *, size_t, long, int); // msgrcv - client_request_msg (int, const void *, size_t, int); // msgsnd -#endif - - int retval () const { return msglen () ? _parameters.out.ret : -1; } - ssize_t rcvval () const { return _parameters.out.rcv; } -}; - -#ifndef __INSIDE_CYGWIN__ -int msginit (); -int msgunload (); -int msgctl (struct thread *, struct msgctl_args *); -int msgget (struct thread *, struct msgget_args *); -int msgsnd (struct thread *, struct msgsnd_args *); -int msgrcv (struct thread *, struct msgrcv_args *); -#endif - -#endif /* __CYGSERVER_MSG_H__ */ diff --git a/winsup/cygwin/cygserver_sem.h b/winsup/cygwin/cygserver_sem.h deleted file mode 100644 index fdf6f8c39..000000000 --- a/winsup/cygwin/cygserver_sem.h +++ /dev/null @@ -1,87 +0,0 @@ -/* cygserver_sem.h: Single unix specification IPC interface for Cygwin. - - Copyright 2003, 2008 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef __CYGSERVER_SEM_H__ -#define __CYGSERVER_SEM_H__ - -#include -#include -#ifndef _KERNEL -#define _KERNEL 1 -#endif -#include - -#include "cygserver.h" -#include "cygserver_ipc.h" - -#ifndef __INSIDE_CYGWIN__ -class transport_layer_base; -class process_cache; -#endif - -class client_request_sem : public client_request -{ - friend class client_request; - -public: - enum semop_t - { - SEMOP_semctl, - SEMOP_semget, - SEMOP_semop - }; - -private: - union - { - struct - { - semop_t semop; - proc ipcblk; - union - { - struct semctl_args ctlargs; - struct semget_args getargs; - struct semop_args opargs; - }; - } in; - - union { - int ret; - } out; - } _parameters; - -#ifndef __INSIDE_CYGWIN__ - client_request_sem (); - virtual void serve (transport_layer_base *, process_cache *); -#endif - -public: - -#ifdef __INSIDE_CYGWIN__ - client_request_sem (int, int, int, union semun *); // semctl - client_request_sem (key_t, int, int); // semget - client_request_sem (int, struct sembuf *, size_t); // semop -#endif - - int retval () const { return msglen () ? _parameters.out.ret : -1; } -}; - -#ifndef __INSIDE_CYGWIN__ -int seminit (); -int semunload (); -void semexit_myhook(void *arg, struct proc *p); - -int semctl (struct thread *, struct semctl_args *); -int semget (struct thread *, struct semget_args *); -int semop (struct thread *, struct semop_args *); -#endif - -#endif /* __CYGSERVER_SEM_H__ */ diff --git a/winsup/cygwin/cygserver_setpwd.h b/winsup/cygwin/cygserver_setpwd.h deleted file mode 100644 index 94ee2998d..000000000 --- a/winsup/cygwin/cygserver_setpwd.h +++ /dev/null @@ -1,53 +0,0 @@ -/* cygserver_setpwd.h: Set LSA private data password for current user. - - Copyright 2008 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef __CYGSERVER_SETPWD_H__ -#define __CYGSERVER_SETPWD_H__ - -#include -#include "cygserver.h" - -#define CYGWIN_LSA_KEY_PREFIX L"L$CYGWIN_" - -#ifndef __INSIDE_CYGWIN__ -class transport_layer_base; -class process_cache; -#endif - -class client_request_setpwd : public client_request -{ - friend class client_request; - -private: - union - { - struct - { - WCHAR passwd[256]; - } in; - } _parameters; - -#ifndef __INSIDE_CYGWIN__ - client_request_setpwd (); - virtual void serve (transport_layer_base *, process_cache *); -#endif - -public: - -#ifdef __INSIDE_CYGWIN__ - client_request_setpwd (PUNICODE_STRING); -#endif -}; - -#ifdef __INSIDE_CYGWIN__ -unsigned long setlsapwd (const char *passwd); -#endif - -#endif /* __CYGSERVER_SETPWD_H__ */ diff --git a/winsup/cygwin/cygserver_shm.h b/winsup/cygwin/cygserver_shm.h deleted file mode 100644 index baa3e052a..000000000 --- a/winsup/cygwin/cygserver_shm.h +++ /dev/null @@ -1,98 +0,0 @@ -/* cygserver_shm.h: Single unix specification IPC interface for Cygwin. - - Copyright 2003, 2008 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef __CYGSERVER_SHM_H__ -#define __CYGSERVER_SHM_H__ - -#include -#include -#ifndef _KERNEL -#define _KERNEL 1 -#endif -#include - -#include "cygserver.h" -#include "cygserver_ipc.h" - -#ifndef __INSIDE_CYGWIN__ -class transport_layer_base; -class process_cache; -#endif - -class client_request_shm : public client_request -{ - friend class client_request; - -public: - enum shmop_t - { - SHMOP_shmat, - SHMOP_shmctl, - SHMOP_shmdt, - SHMOP_shmget, - SHMOP_shmfork /* Called on fixup_after_fork */ - }; - -private: - union - { - struct - { - shmop_t shmop; - proc ipcblk; - struct shmat_args atargs; - struct shmctl_args ctlargs; - struct shmdt_args dtargs; - struct shmget_args getargs; - struct proc forkargs; - } in; - - struct { - union { - int ret; - vm_offset_t ptr; - }; - vm_object_t obj; - } out; - } _parameters; - -#ifndef __INSIDE_CYGWIN__ - client_request_shm (); - virtual void serve (transport_layer_base *, process_cache *); -#endif - -public: - -#ifdef __INSIDE_CYGWIN__ - client_request_shm (int, const void *, int); // shmat - client_request_shm (int, int, struct shmid_ds *); // shmctl - client_request_shm (const void *); // shmdt - client_request_shm (key_t, size_t, int); // shmget - client_request_shm (proc *); // shmfork -#endif - - int retval () const { return msglen () ? _parameters.out.ret : -1; } - void *ptrval () const { return (void *)_parameters.out.ptr; } - vm_object_t objval () const { return _parameters.out.obj; } -}; - -#ifndef __INSIDE_CYGWIN__ -void shminit (); -int shmunload (); -void shmexit_myhook (struct vmspace *vm); -int cygwin_shmfork_myhook (struct thread *, struct proc *); - -int shmat (struct thread *, struct shmat_args *); -int shmctl (struct thread *, struct shmctl_args *); -int shmdt (struct thread *, struct shmdt_args *); -int shmget (struct thread *, struct shmget_args *); -#endif - -#endif /* __CYGSERVER_SHM_H__ */ diff --git a/winsup/cygwin/cygthread.cc b/winsup/cygwin/cygthread.cc deleted file mode 100644 index b0aea3619..000000000 --- a/winsup/cygwin/cygthread.cc +++ /dev/null @@ -1,510 +0,0 @@ -/* cygthread.cc - - Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 - Red Hat, Inc. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "miscfuncs.h" -#include -#include "sigproc.h" -#include "cygtls.h" - -#undef CloseHandle - -static cygthread NO_COPY threads[32]; -#define NTHREADS (sizeof (threads) / sizeof (threads[0])) - -DWORD NO_COPY cygthread::main_thread_id; -bool NO_COPY cygthread::exiting; - -void -cygthread::callfunc (bool issimplestub) -{ - void *pass_arg; - if (arg == cygself) - pass_arg = this; - else if (!arglen) - pass_arg = arg; - else - { - if (issimplestub) - ev = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL); - pass_arg = alloca (arglen); - memcpy (pass_arg, arg, arglen); - SetEvent (ev); - } - if (issimplestub) - { - /* Wait for main thread to assign 'h' */ - while (!h) - low_priority_sleep (0); - if (ev) - CloseHandle (ev); - ev = h; - } - /* Cygwin threads should not call ExitThread directly */ - func (pass_arg); - /* ...so the above should always return */ -} - -/* Initial stub called by cygthread constructor. Performs initial - per-thread initialization and loops waiting for another thread function - to execute. */ -DWORD WINAPI -cygthread::stub (VOID *arg) -{ - cygthread *info = (cygthread *) arg; - _my_tls._ctinfo = info; - if (info->arg == cygself) - { - if (info->ev) - { - CloseHandle (info->ev); - CloseHandle (info->thread_sync); - } - info->ev = info->thread_sync = info->stack_ptr = NULL; - } - else - { - info->stack_ptr = &arg; - debug_printf ("thread '%s', id %p, stack_ptr %p", info->name (), info->id, info->stack_ptr); - if (!info->ev) - { - info->ev = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL); - info->thread_sync = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL); - } - } - - while (1) - { - if (!info->__name) -#ifdef DEBUGGING - system_printf ("erroneous thread activation, name is NULL prev thread name = '%s'", info->__oldname); -#else - system_printf ("erroneous thread activation, name is NULL"); -#endif - else - { - if (exiting) - { - info->inuse = false; // FIXME: Do we need this? - return 0; - } - - info->callfunc (false); - - HANDLE notify = info->notify_detached; - /* If func is NULL, the above function has set that to indicate - that it doesn't want to alert anyone with a SetEvent and should - just be marked as no longer inuse. Hopefully the function knows - what it is doing. */ - if (!info->func) - info->release (false); - else - { -#ifdef DEBUGGING - info->func = NULL; // catch erroneous activation - info->__oldname = info->__name; -#endif - info->__name = NULL; - SetEvent (info->ev); - } - if (notify) - SetEvent (notify); - } - switch (WaitForSingleObject (info->thread_sync, INFINITE)) - { - case WAIT_OBJECT_0: - continue; - default: - api_fatal ("WFSO failed, %E"); - break; - } - } -} - -/* Overflow stub called by cygthread constructor. Calls specified function - and then exits the thread. */ -DWORD WINAPI -cygthread::simplestub (VOID *arg) -{ - cygthread *info = (cygthread *) arg; - _my_tls._ctinfo = info; - info->stack_ptr = &arg; - info->callfunc (true); - return 0; -} - -/* Start things going. Called from dll_crt0_1. */ -void -cygthread::init () -{ - main_thread_id = GetCurrentThreadId (); -} - -cygthread * -cygthread::freerange () -{ - cygthread *self = (cygthread *) calloc (1, sizeof (*self)); - self->is_freerange = true; - self->inuse = 1; - return self; -} - -void * cygthread::operator -new (size_t) -{ - cygthread *info; - - /* Search the threads array for an empty slot to use */ - for (info = threads; info < threads + NTHREADS; info++) - if (!InterlockedExchange (&info->inuse, 1)) - { - /* available */ -#ifdef DEBUGGING - if (info->__name) - api_fatal ("name not NULL? %s, id %p, i %d", info->__name, info->id, info - threads); -#endif - goto out; - } - -#ifdef DEBUGGING - if (!getenv ("CYGWIN_FREERANGE_NOCHECK")) - api_fatal ("overflowed cygwin thread pool"); - else - thread_printf ("overflowed cygwin thread pool"); -#endif - - info = freerange (); /* exhausted thread pool */ - -out: - return info; -} - -cygthread::cygthread (LPTHREAD_START_ROUTINE start, size_t n, void *param, - const char *name, HANDLE notify) - : __name (name), func (start), arglen (n), arg (param), notify_detached (notify) -{ - thread_printf ("name %s, id %p", name, id); - HANDLE htobe; - if (h) - { - if (ev) - ResetEvent (ev); - while (!thread_sync) - low_priority_sleep (0); - SetEvent (thread_sync); - thread_printf ("activated name '%s', thread_sync %p for thread %p", name, thread_sync, id); - htobe = h; - } - else - { - stack_ptr = NULL; - htobe = CreateThread (&sec_none_nih, 0, is_freerange ? simplestub : stub, - this, 0, &id); - if (!htobe) - api_fatal ("CreateThread failed for %s - %p<%p>, %E", name, h, id); - thread_printf ("created name '%s', thread %p, id %p", name, h, id); -#ifdef DEBUGGING - terminated = false; -#endif - } - - if (n) - { - while (!ev) - low_priority_sleep (0); - WaitForSingleObject (ev, INFINITE); - ResetEvent (ev); - } - h = htobe; -} - -/* Return the symbolic name of the current thread for debugging. - */ -const char * -cygthread::name (DWORD tid) -{ - const char *res = NULL; - if (!tid) - tid = GetCurrentThreadId (); - - if (tid == main_thread_id) - return "main"; - - for (DWORD i = 0; i < NTHREADS; i++) - if (threads[i].id == tid) - { - res = threads[i].__name ?: "exiting thread"; - break; - } - - if (!res) - { - __small_sprintf (_my_tls.locals.unknown_thread_name, "unknown (%p)", tid); - res = _my_tls.locals.unknown_thread_name; - } - - return res; -} - -cygthread::operator -HANDLE () -{ - while (!ev) - low_priority_sleep (0); - return ev; -} - -void -cygthread::release (bool nuke_h) -{ - if (nuke_h) - h = NULL; -#ifdef DEBUGGING - __oldname = __name; - debug_printf ("released thread '%s'", __oldname); -#endif - __name = NULL; - func = NULL; - /* Must be last */ - if (!InterlockedExchange (&inuse, 0)) -#ifdef DEBUGGING - api_fatal ("released a thread that was not inuse"); -#else - system_printf ("released a thread that was not inuse"); -#endif -} - -/* Forcibly terminate a thread. */ -bool -cygthread::terminate_thread () -{ - bool terminated = true; - debug_printf ("thread '%s', id %p, inuse %d, stack_ptr %p", __name, id, inuse, stack_ptr); - while (inuse && !stack_ptr) - low_priority_sleep (0); - - if (!inuse) - goto force_notterminated; - - TerminateThread (h, 0); - WaitForSingleObject (h, INFINITE); - CloseHandle (h); - - if (!inuse || exiting) - goto force_notterminated; - - if (ev && !(terminated = WaitForSingleObject (ev, 0) != WAIT_OBJECT_0)) - ResetEvent (ev); - - MEMORY_BASIC_INFORMATION m; - memset (&m, 0, sizeof (m)); - VirtualQuery (stack_ptr, &m, sizeof m); - - if (!m.RegionSize) - system_printf ("m.RegionSize 0? stack_ptr %p", stack_ptr); - else if (!VirtualFree (m.AllocationBase, 0, MEM_RELEASE)) - debug_printf ("VirtualFree of allocation base %p<%p> failed, %E", - stack_ptr, m.AllocationBase); - - if (is_freerange) - free (this); - else - { -#ifdef DEBUGGING - terminated = true; -#endif - release (true); - } - - goto out; - -force_notterminated: - terminated = false; -out: - return terminated; -} - -/* Detach the cygthread from the current thread. Note that the - theory is that cygthreads are only associated with one thread. - So, there should be never be multiple threads doing waits - on the same cygthread. */ -bool -cygthread::detach (HANDLE sigwait) -{ - bool signalled = false; - bool thread_was_reset = false; - if (!inuse) - system_printf ("called detach but inuse %d, thread %p?", inuse, id); - else - { - DWORD res; - - if (!sigwait) - /* If the caller specified a special handle for notification, wait for that. - This assumes that the thread in question is auto releasing. */ - res = WaitForSingleObject (*this, INFINITE); - else - { - /* Lower our priority and give priority to the read thread */ - HANDLE hth = GetCurrentThread (); - LONG prio = GetThreadPriority (hth); - ::SetThreadPriority (hth, THREAD_PRIORITY_BELOW_NORMAL); - - HANDLE w4[2]; - unsigned n = 2; - DWORD howlong = INFINITE; - w4[0] = sigwait; - w4[1] = signal_arrived; - /* For a description of the below loop see the end of this file */ - for (int i = 0; i < 2; i++) - switch (res = WaitForMultipleObjects (n, w4, FALSE, howlong)) - { - case WAIT_OBJECT_0: - if (n == 1) - howlong = 50; - break; - case WAIT_OBJECT_0 + 1: - n = 1; - if (i--) - howlong = 50; - break; - case WAIT_TIMEOUT: - break; - default: - if (!exiting) - { - system_printf ("WFMO failed waiting for cygthread '%s', %E", __name); - for (unsigned j = 0; j < n; j++) - switch (WaitForSingleObject (w4[j], 0)) - { - case WAIT_OBJECT_0: - case WAIT_TIMEOUT: - break; - default: - system_printf ("%s handle %p is bad", (j ? "signal_arrived" : "semaphore"), w4[j]); - break; - } - api_fatal ("exiting on fatal error"); - } - break; - } - /* WAIT_OBJECT_0 means that the thread successfully read something, - so wait for the cygthread to "terminate". */ - if (res == WAIT_OBJECT_0) - WaitForSingleObject (*this, INFINITE); - else - { - /* Thread didn't terminate on its own, so maybe we have to - do it. */ - signalled = terminate_thread (); - /* Possibly the thread completed *just* before it was - terminated. Detect this. If this happened then the - read was not terminated on a signal. */ - if (WaitForSingleObject (sigwait, 0) == WAIT_OBJECT_0) - signalled = false; - if (signalled) - set_sig_errno (EINTR); - thread_was_reset = true; - } - ::SetThreadPriority (hth, prio); - } - - thread_printf ("%s returns %d, id %p", sigwait ? "WFMO" : "WFSO", - res, id); - - if (thread_was_reset) - /* already handled */; - else if (is_freerange) - { - CloseHandle (h); - free (this); - } - else - { - ResetEvent (*this); - /* Mark the thread as available by setting inuse to zero */ - InterlockedExchange (&inuse, 0); - } - } - return signalled; -} - -void -cygthread::terminate () -{ - exiting = 1; -} - -/* The below is an explanation of synchronization loop in cygthread::detach. - The intent is that the loop will always try hard to wait for both - synchronization events from the reader thread but will exit with - res == WAIT_TIMEOUT if a signal occurred and the reader thread is - still blocked. - - case 0 - no signal - - i == 0 (howlong == INFINITE) - W0 activated - howlong not set because n != 1 - just loop - - i == 1 (howlong == INFINITE) - W0 activated - howlong not set because n != 1 - just loop (to exit loop) - no signal - - i == 2 (howlong == INFINITE) - exit loop - - case 1 - signal before thread initialized - - i == 0 (howlong == INFINITE) - WO + 1 activated - n set to 1 - howlong untouched because i-- == 0 - loop - - i == 0 (howlong == INFINITE) - W0 must be activated - howlong set to 50 because n == 1 - - i == 1 (howlong == 50) - W0 activated - loop (to exit loop) - no signal - - WAIT_TIMEOUT activated - signal potentially detected - loop (to exit loop) - - i == 2 (howlong == 50) - exit loop - - case 2 - signal after thread initialized - - i == 0 (howlong == INFINITE) - W0 activated - howlong not set because n != 1 - loop - - i == 1 (howlong == INFINITE) - W0 + 1 activated - n set to 1 - howlong set to 50 because i-- != 0 - loop - - i == 1 (howlong == 50) - W0 activated - loop (to exit loop) - no signal - - WAIT_TIMEOUT activated - loop (to exit loop) - signal - - i == 2 (howlong == 50) - exit loop -*/ diff --git a/winsup/cygwin/cygthread.h b/winsup/cygwin/cygthread.h deleted file mode 100644 index da7172e63..000000000 --- a/winsup/cygwin/cygthread.h +++ /dev/null @@ -1,57 +0,0 @@ -/* cygthread.h - - Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Red Hat, Inc. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGTHREAD_H -#define _CYGTHREAD_H - -class cygthread -{ - LONG inuse; - DWORD id; - HANDLE h; - HANDLE ev; - HANDLE thread_sync; - void *stack_ptr; - const char *__name; -#ifdef DEBUGGING - const char *__oldname; - bool terminated; -#endif - LPTHREAD_START_ROUTINE func; - unsigned arglen; - VOID *arg; - bool is_freerange; - static bool exiting; - HANDLE notify_detached; - public: - bool terminate_thread (); - static DWORD WINAPI stub (VOID *); - static DWORD WINAPI simplestub (VOID *); - static DWORD main_thread_id; - static const char * name (DWORD = 0); - void callfunc (bool) __attribute__ ((noinline, regparm (2))); - void auto_release () {func = NULL;} - void release (bool); - cygthread (LPTHREAD_START_ROUTINE, unsigned, LPVOID, const char *, HANDLE = NULL); - cygthread () {}; - static void init (); - bool detach (HANDLE = NULL); - operator HANDLE (); - void * operator new (size_t); - static cygthread *freerange (); - static void terminate (); - bool SetThreadPriority (int nPriority) {return ::SetThreadPriority (h, nPriority);} - void zap_h () - { - CloseHandle (h); - h = NULL; - } -}; - -#define cygself NULL -#endif /*_CYGTHREAD_H*/ diff --git a/winsup/cygwin/cygtls.cc b/winsup/cygwin/cygtls.cc deleted file mode 100644 index b90b25fa2..000000000 --- a/winsup/cygwin/cygtls.cc +++ /dev/null @@ -1,264 +0,0 @@ -/* cygtls.cc - - Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Red Hat, Inc. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#define USE_SYS_TYPES_FD_SET -#include "cygtls.h" -#include -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "sigproc.h" - -class sentry -{ - static muto lock; - int destroy; -public: - void init (); - bool acquired () {return lock.acquired ();} - sentry () {destroy = 0;} - sentry (DWORD wait) {destroy = lock.acquire (wait);} - ~sentry () {if (destroy) lock.release ();} - friend void _cygtls::init (); -}; - -muto NO_COPY sentry::lock; - -static size_t NO_COPY nthreads; - -#define THREADLIST_CHUNK 256 - -void -_cygtls::init () -{ - if (cygheap->threadlist) - memset (cygheap->threadlist, 0, cygheap->sthreads * sizeof (cygheap->threadlist[0])); - else - { - cygheap->sthreads = THREADLIST_CHUNK; - cygheap->threadlist = (_cygtls **) ccalloc_abort (HEAP_TLS, cygheap->sthreads, - sizeof (cygheap->threadlist[0])); - } - sentry::lock.init ("sentry_lock"); -} - -/* Two calls to get the stack right... */ -void -_cygtls::call (DWORD (*func) (void *, void *), void *arg) -{ - char buf[CYGTLS_PADSIZE]; - _my_tls.call2 (func, arg, buf); -} - -void -_cygtls::call2 (DWORD (*func) (void *, void *), void *arg, void *buf) -{ - init_thread (buf, func); - DWORD res = func (arg, buf); - remove (INFINITE); - /* Don't call ExitThread on the main thread since we may have been - dynamically loaded. */ - if ((void *) func != (void *) dll_crt0_1 - && (void *) func != (void *) dll_dllcrt0_1) - ExitThread (res); -} - -void -_cygtls::init_thread (void *x, DWORD (*func) (void *, void *)) -{ - if (x) - { - memset (this, 0, sizeof (*this)); - stackptr = stack; - if (_GLOBAL_REENT) - { - local_clib._stdin = _GLOBAL_REENT->_stdin; - local_clib._stdout = _GLOBAL_REENT->_stdout; - local_clib._stderr = _GLOBAL_REENT->_stderr; - local_clib.__sdidinit = _GLOBAL_REENT->__sdidinit ? -1 : 0; - local_clib.__cleanup = _GLOBAL_REENT->__cleanup; - local_clib.__sglue._niobs = 3; - local_clib.__sglue._iobs = &_GLOBAL_REENT->__sf[0]; - } - local_clib._current_locale = "C"; - locals.process_logmask = LOG_UPTO (LOG_DEBUG); - /* Initialize this thread's ability to respond to things like - SIGSEGV or SIGFPE. */ - init_exception_handler (handle_exceptions); - } - - thread_id = GetCurrentThreadId (); - initialized = CYGTLS_INITIALIZED; - errno_addr = &(local_clib._errno); - - if ((void *) func == (void *) cygthread::stub - || (void *) func == (void *) cygthread::simplestub) - return; - - cygheap->user.reimpersonate (); - - sentry here (INFINITE); - if (nthreads >= cygheap->sthreads) - { - cygheap->threadlist = (_cygtls **) - crealloc_abort (cygheap->threadlist, (cygheap->sthreads += THREADLIST_CHUNK) - * sizeof (cygheap->threadlist[0])); - memset (cygheap->threadlist + nthreads, 0, THREADLIST_CHUNK * sizeof (cygheap->threadlist[0])); - } - - cygheap->threadlist[nthreads++] = this; -} - -void -_cygtls::fixup_after_fork () -{ - if (sig) - { - pop (); - sig = 0; - } - stacklock = spinning = 0; - locals.select.sockevt = NULL; - wq.thread_ev = NULL; -} - -#define free_local(x) \ - if (locals.x) \ - { \ - free (locals.x); \ - locals.x = NULL; \ - } - -void -_cygtls::remove (DWORD wait) -{ - initialized = 0; - if (exit_state >= ES_FINAL) - return; - - debug_printf ("wait %p", wait); - if (wait) - { - /* FIXME: Need some sort of atthreadexit function to allow things like - select to control this themselves. */ - if (locals.select.sockevt) - { - CloseHandle (locals.select.sockevt); - locals.select.sockevt = NULL; - free_local (select.ser_num); - free_local (select.w4); - } - free_local (process_ident); - free_local (ntoa_buf); - free_local (protoent_buf); - free_local (servent_buf); - free_local (hostent_buf); - } - - /* Free temporary TLS path buffers. */ - locals.pathbufs.destroy (); - - do - { - sentry here (wait); - if (here.acquired ()) - { - for (size_t i = 0; i < nthreads; i++) - if (this == cygheap->threadlist[i]) - { - if (i < --nthreads) - cygheap->threadlist[i] = cygheap->threadlist[nthreads]; - debug_printf ("removed %p element %d", this, i); - break; - } - } - } while (0); - remove_wq (wait); -} - -void -_cygtls::push (__stack_t addr) -{ - *stackptr++ = (__stack_t) addr; -} - - -_cygtls * -_cygtls::find_tls (int sig) -{ - static int NO_COPY threadlist_ix; - - debug_printf ("sig %d\n", sig); - sentry here (INFINITE); - - _cygtls *res = NULL; - threadlist_ix = -1; - - myfault efault; - if (efault.faulted ()) - cygheap->threadlist[threadlist_ix]->remove (INFINITE); - - while (++threadlist_ix < (int) nthreads) - if (sigismember (&(cygheap->threadlist[threadlist_ix]->sigwait_mask), sig)) - { - res = cygheap->threadlist[threadlist_ix]; - break; - } - return res; -} - -void -_cygtls::set_siginfo (sigpacket *pack) -{ - infodata = pack->si; -} - -/* Set up the exception handler for the current thread. The x86 uses segment - register fs, offset 0 to point to the current exception handler. */ - -extern exception_list *_except_list asm ("%fs:0"); - -void -_cygtls::init_exception_handler (exception_handler *eh) -{ - /* Here in the distant past of 17-Jul-2009, we had an issue where Windows - 2008 became YA perplexed because the cygwin exception handler was added - at the start of the SEH while still being in the list further on. This - was because we added a loop by setting el.prev to _except_list here. - Since el is reused in this thread, and this function can be called - more than once when a dll is loaded, this is not a good thing. - - So, for now, until the next required tweak, we will just avoid adding the - cygwin exception handler if it is already on this list. This could present - a problem if some previous exception handler tries to do things that are - better left to Cygwin. I await the cygwin mailing list notification of - this event with bated breath. - - (cgf 2009-07-17) */ - for (exception_list *e = _except_list; - e != NULL && e != (exception_list *) -1; - e = e->prev) - if (e == &el) - return; - el.handler = eh; - /* Apparently Windows stores some information about an exception and tries - to figure out if the SEH which returned 0 last time actually solved the - problem, or if the problem still persists (e.g. same exception at same - address). In this case Windows seems to decide that it can't trust - that SEH and calls the next handler in the chain instead. - - At one point this was a loop (el.prev = ⪙). This outsmarted the - above behaviour. Unfortunately this trick doesn't work anymore with - Windows 2008, which irremediably gets into an endless loop, taking 100% - CPU. That's why we reverted to a normal SEH chain and changed the way - the exception handler returns to the application. */ - el.prev = _except_list; - _except_list = ⪙ -} diff --git a/winsup/cygwin/cygtls.h b/winsup/cygwin/cygtls.h deleted file mode 100644 index f05379f48..000000000 --- a/winsup/cygwin/cygtls.h +++ /dev/null @@ -1,315 +0,0 @@ -/* cygtls.h - - Copyright 2003, 2004, 2005, 2008, 2009 Red Hat, Inc. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGTLS_H -#define _CYGTLS_H - -#include -#include -#include -#include -#define _NOMNTENT_FUNCS -#include -#undef _NOMNTENT_FUNCS -#include -#include - -#define CYGTLS_INITIALIZED 0xc763173f - -#ifndef CYG_MAX_PATH -# define CYG_MAX_PATH 260 -#endif - -#ifndef UNLEN -# define UNLEN 256 -#endif - -#define TLS_STACK_SIZE 256 - -#include "cygthread.h" - -#define TP_NUM_C_BUFS 10 -#define TP_NUM_W_BUFS 10 - -#ifdef CYGTLS_HANDLE -#include "thread.h" -#endif - -#pragma pack(push,4) -/* Defined here to support auto rebuild of tlsoffsets.h. */ -class tls_pathbuf -{ - int c_cnt; - int w_cnt; - char *c_buf[TP_NUM_C_BUFS]; - WCHAR *w_buf[TP_NUM_W_BUFS]; - -public: - void destroy (); - friend class tmp_pathbuf; - friend class _cygtls; -}; - -class unionent -{ -public: - char *name; - char **list; - short port_proto_addrtype; - short h_len; - union - { - char *s_proto; - char **h_addr_list; - }; - enum struct_type - { - t_hostent, t_protoent, t_servent - }; -}; - -struct _local_storage -{ - /* - Needed for the group functions - */ - struct __group16 grp; - char *namearray[2]; - int grp_pos; - - /* console.cc */ - unsigned rarg; - - /* dlfcn.cc */ - int dl_error; - char dl_buffer[256]; - - /* passwd.cc */ - struct passwd res; - char pass[_PASSWORD_LEN]; - int pw_pos; - - /* path.cc */ - struct mntent mntbuf; - int iteration; - unsigned available_drives; - char mnt_type[80]; - char mnt_opts[80]; - char mnt_fsname[CYG_MAX_PATH]; - char mnt_dir[CYG_MAX_PATH]; - - /* select.cc */ - struct { - HANDLE sockevt; - int max_w4; - LONG *ser_num; // note: malloced - HANDLE *w4; // note: malloced - } select; - - /* strerror */ - char strerror_buf[sizeof ("Unknown error 4294967295")]; - - /* sysloc.cc */ - char *process_ident; // note: malloced - int process_logopt; - int process_facility; - int process_logmask; - - /* times.cc */ - char timezone_buf[20]; - struct tm _localtime_buf; - - /* uinfo.cc */ - char username[UNLEN + 1]; - - /* net.cc */ - char *ntoa_buf; // note: malloced - char signamebuf[sizeof ("Unknown signal 4294967295 ")]; - - unionent *hostent_buf; // note: malloced - unionent *protoent_buf; // note: malloced - unionent *servent_buf; // note: malloced - - /* cygthread.cc */ - char unknown_thread_name[30]; - - /* syscalls.cc */ - int setmode_file; - int setmode_mode; - - /* All functions requiring temporary path buffers. */ - tls_pathbuf pathbufs; -}; - -typedef struct struct_waitq -{ - int pid; - int options; - int status; - HANDLE ev; - void *rusage; /* pointer to potential rusage */ - struct struct_waitq *next; - HANDLE thread_ev; -} waitq; - -typedef struct -{ - void *_myfault; - int _myfault_errno; - int _myfault_c_cnt; - int _myfault_w_cnt; -} san; - -/* Changes to the below structure may require acompanying changes to the very - simple parser in the perl script 'gentls_offsets' (<<-- start parsing here). - The union in this structure is used to force alignment between the version - of the compiler used to generate tlsoffsets.h and the cygwin cross compiler. -*/ - -/*gentls_offsets*/ -#include "cygerrno.h" - -extern "C" int __sjfault (jmp_buf); -extern "C" int __ljfault (jmp_buf, int); - -/*gentls_offsets*/ - -typedef __uint32_t __stack_t; -struct _cygtls -{ - void (*func) /*gentls_offsets*/(int)/*gentls_offsets*/; - exception_list el; - int saved_errno; - int sa_flags; - sigset_t oldmask; - sigset_t deltamask; - HANDLE event; - int *errno_addr; - sigset_t sigmask; - sigset_t sigwait_mask; - siginfo_t *sigwait_info; - struct ucontext thread_context; - DWORD thread_id; - unsigned threadkill; - siginfo_t infodata; - struct pthread *tid; - union - { - struct _reent local_clib; - char __dontuse[8 * ((sizeof(struct _reent) + 4) / 8)]; - }; - struct _local_storage locals; - class cygthread *_ctinfo; - san andreas; - waitq wq; - int sig; - unsigned incyg; - unsigned spinning; - unsigned stacklock; - __stack_t *stackptr; - __stack_t stack[TLS_STACK_SIZE]; - unsigned initialized; - - /*gentls_offsets*/ - static CRITICAL_SECTION protect_linked_list; - static void init (); - void init_thread (void *, DWORD (*) (void *, void *)); - static void call (DWORD (*) (void *, void *), void *); - void call2 (DWORD (*) (void *, void *), void *, void *) __attribute__ ((regparm (3))); - static struct _cygtls *find_tls (int sig); - void remove (DWORD); - void push (__stack_t) __attribute__ ((regparm (2))); - __stack_t pop () __attribute__ ((regparm (1))); - __stack_t retaddr () {return stackptr[-1];} - bool isinitialized () const - { - return initialized == CYGTLS_INITIALIZED; - } - bool interrupt_now (CONTEXT *, int, void *, struct sigaction&) - __attribute__((regparm(3))); - void __stdcall interrupt_setup (int sig, void *handler, - struct sigaction& siga) - __attribute__((regparm(3))); - - /* exception handling */ - static int handle_exceptions (EXCEPTION_RECORD *, exception_list *, CONTEXT *, void *); - bool inside_kernel (CONTEXT *); - void init_exception_handler (int (*) (EXCEPTION_RECORD *, exception_list *, CONTEXT *, void*)); - void signal_exit (int) __attribute__ ((noreturn, regparm(2))); - void copy_context (CONTEXT *) __attribute__ ((regparm(2))); - void signal_debugger (int) __attribute__ ((regparm(2))); - -#ifdef CYGTLS_HANDLE - operator HANDLE () const {return tid->win32_obj_id;} -#endif - void set_siginfo (struct sigpacket *) __attribute__ ((regparm (3))); - void set_threadkill () {threadkill = true;} - void reset_threadkill () {threadkill = false;} - int call_signal_handler () __attribute__ ((regparm (1))); - void remove_wq (DWORD) __attribute__ ((regparm (1))); - void fixup_after_fork () __attribute__ ((regparm (1))); - void lock () __attribute__ ((regparm (1))); - void unlock () __attribute__ ((regparm (1))); - bool locked () __attribute__ ((regparm (1))); - void*& fault_guarded () {return andreas._myfault;} - void return_from_fault () - { - if (andreas._myfault_errno) - set_errno (andreas._myfault_errno); - /* Restore tls_pathbuf counters in case of error. */ - locals.pathbufs.c_cnt = andreas._myfault_c_cnt; - locals.pathbufs.w_cnt = andreas._myfault_w_cnt; - __ljfault ((int *) andreas._myfault, 1); - } - int setup_fault (jmp_buf j, san& old_j, int myerrno) __attribute__ ((always_inline)) - { - old_j._myfault = andreas._myfault; - old_j._myfault_errno = andreas._myfault_errno; - old_j._myfault_c_cnt = andreas._myfault_c_cnt; - old_j._myfault_w_cnt = andreas._myfault_w_cnt; - andreas._myfault = (void *) j; - andreas._myfault_errno = myerrno; - /* Save tls_pathbuf counters. */ - andreas._myfault_c_cnt = locals.pathbufs.c_cnt; - andreas._myfault_w_cnt = locals.pathbufs.w_cnt; - return __sjfault (j); - } - void reset_fault (san& old_j) __attribute__ ((always_inline)) - { - andreas._myfault = old_j._myfault; - andreas._myfault_errno = old_j._myfault_errno; - } - /*gentls_offsets*/ -}; -#pragma pack(pop) - -const int CYGTLS_PADSIZE = 12700; /* FIXME: Find some way to autogenerate - this value */ -/*gentls_offsets*/ - -extern char *_tlsbase __asm__ ("%fs:4"); -extern char *_tlstop __asm__ ("%fs:8"); -#define _my_tls (*((_cygtls *) (_tlsbase - CYGTLS_PADSIZE))) -extern _cygtls *_main_tls; -extern _cygtls *_sig_tls; - -class myfault -{ - jmp_buf buf; - san sebastian; -public: - ~myfault () __attribute__ ((always_inline)) { _my_tls.reset_fault (sebastian); } - inline int faulted (int myerrno = 0) __attribute__ ((always_inline)) - { - return _my_tls.setup_fault (buf, sebastian, myerrno); - } -}; - -#define __getreent() (&_my_tls.local_clib) - -#endif /*_CYGTLS_H*/ /*gentls_offsets*/ diff --git a/winsup/cygwin/cygwin-cxx.h b/winsup/cygwin/cygwin-cxx.h deleted file mode 100755 index b0eb8c25c..000000000 --- a/winsup/cygwin/cygwin-cxx.h +++ /dev/null @@ -1,37 +0,0 @@ -/* cygwin-cxx.h - - Copyright 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGWIN_CXX_H -#define _CYGWIN_CXX_H - -#ifndef __cplusplus -#error This header should not be included by C source files. -#endif - -/* Files including this header must override -nostdinc++ */ -#include - -/* This is an optional struct pointed to by per_process if it exists. */ -struct per_process_cxx_malloc -{ - void *(*oper_new) (std::size_t); - void *(*oper_new__) (std::size_t); - void (*oper_delete) (void *); - void (*oper_delete__) (void *); - void *(*oper_new_nt) (std::size_t, const std::nothrow_t &); - void *(*oper_new___nt) (std::size_t, const std::nothrow_t &); - void (*oper_delete_nt) (void *, const std::nothrow_t &); - void (*oper_delete___nt) (void *, const std::nothrow_t &); -}; - -/* Defined in cxx.cc */ -extern struct per_process_cxx_malloc default_cygwin_cxx_malloc; - -#endif /* _CYGWIN_CXX_H */ diff --git a/winsup/cygwin/cygwin-shilka b/winsup/cygwin/cygwin-shilka deleted file mode 100755 index 9abbf230f..000000000 --- a/winsup/cygwin/cygwin-shilka +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -c="$(basename $1 .shilka).c" -shilka -length -strip -no-definitions $1 && \ -sed -e '1,4d' -e '/KR_reset.*;/d' -e '/KR_output_statistics.*;/d' \ - -e '/KR_reset.*)/,/}/d' -e '/KR_output_statistics.*)/,/}/d' \ - -e '/# *line/d' "$c" > $2 && -rm -f "$c" -# -e "s%$c"'"%'"$2"'"%g' diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din deleted file mode 100644 index 46f03582c..000000000 --- a/winsup/cygwin/cygwin.din +++ /dev/null @@ -1,1831 +0,0 @@ -LIBRARY "cygwin1.dll" BASE=0x61000000 - -EXPORTS -__argc DATA -__argv DATA -_check_for_executable DATA -__check_rhosts_file DATA -_ctype_ DATA -__ctype_ptr__ DATA -__cygwin_environ DATA -__cygwin_user_data DATA -_daylight DATA -h_errno DATA -_impure_ptr DATA -in6addr_any DATA -in6addr_loopback DATA -__mb_cur_max DATA -optarg DATA -opterr DATA -optind DATA -optopt DATA -optreset DATA -__progname DATA -__rcmd_errstr DATA -reent_data DATA -sys_errlist = _sys_errlist DATA -_sys_errlist DATA -sys_nerr = _sys_nerr DATA -_sys_nerr DATA -sys_sigabbrev DATA -_timezone DATA -_tzname DATA -_Exit SIGFE -a64l NOSIGFE -abort NOSIGFE -_abort = abort SIGFE -abs NOSIGFE -_abs = abs NOSIGFE -accept = cygwin_accept SIGFE -accept4 SIGFE -access SIGFE -_access = access SIGFE -acl SIGFE -_acl = acl SIGFE -_acl32 = acl32 SIGFE -aclcheck NOSIGFE -_aclcheck = aclcheck NOSIGFE -_aclcheck32 = aclcheck32 NOSIGFE -aclfrommode SIGFE -_aclfrommode = aclfrommode SIGFE -_aclfrommode32 = aclfrommode32 SIGFE -aclfrompbits SIGFE -_aclfrompbits = aclfrompbits SIGFE -_aclfrompbits32 = aclfrompbits32 SIGFE -aclfromtext SIGFE -_aclfromtext = aclfromtext SIGFE -_aclfromtext32 = aclfromtext32 SIGFE -aclsort SIGFE -_aclsort = aclsort SIGFE -_aclsort32 = aclsort32 SIGFE -acltomode SIGFE -_acltomode = acltomode SIGFE -_acltomode32 = acltomode32 SIGFE -acltopbits SIGFE -_acltopbits = acltopbits SIGFE -_acltopbits32 = acltopbits32 SIGFE -acltotext SIGFE -_acltotext = acltotext SIGFE -_acltotext32 = acltotext32 SIGFE -acos NOSIGFE -_acos = acos NOSIGFE -acosf NOSIGFE -_acosf = acosf NOSIGFE -acosh NOSIGFE -_acosh = acosh NOSIGFE -acoshf NOSIGFE -_acoshf = acoshf NOSIGFE -alarm SIGFE -_alarm = alarm SIGFE -_alloca NOSIGFE -alphasort NOSIGFE -_alphasort = alphasort NOSIGFE -argz_add SIGFE -__argz_add = argz_add SIGFE -argz_add_sep SIGFE -__argz_add_sep = argz_add_sep SIGFE -argz_append SIGFE -__argz_append = argz_append SIGFE -argz_count NOSIGFE -__argz_count = argz_count NOSIGFE -argz_create SIGFE -__argz_create = argz_create SIGFE -argz_create_sep SIGFE -__argz_create_sep = argz_create_sep SIGFE -argz_delete SIGFE -__argz_delete = argz_delete SIGFE -argz_extract NOSIGFE -__argz_extract = argz_extract NOSIGFE -argz_insert SIGFE -__argz_insert = argz_insert SIGFE -argz_next NOSIGFE -__argz_next = argz_next NOSIGFE -argz_replace SIGFE -__argz_replace = argz_replace SIGFE -argz_stringify NOSIGFE -__argz_stringify = argz_stringify NOSIGFE -asctime SIGFE -_asctime = asctime SIGFE -asctime_r SIGFE -_asctime_r = asctime_r SIGFE -asin NOSIGFE -_asin = asin NOSIGFE -asinf NOSIGFE -_asinf = asinf NOSIGFE -asinh NOSIGFE -_asinh = asinh NOSIGFE -asinhf NOSIGFE -_asinhf = asinhf NOSIGFE -asnprintf SIGFE -asprintf SIGFE -_asprintf = asprintf SIGFE -asprintf_r = _asprintf_r SIGFE -_asprintf_r SIGFE -__assert SIGFE -__assert_func SIGFE -__assertfail SIGFE -atan NOSIGFE -_atan = atan NOSIGFE -atan2 NOSIGFE -_atan2 = atan2 NOSIGFE -atan2f NOSIGFE -_atan2f = atan2f NOSIGFE -atanf NOSIGFE -_atanf = atanf NOSIGFE -atanh NOSIGFE -_atanh = atanh NOSIGFE -atanhf NOSIGFE -_atanhf = atanhf NOSIGFE -atexit = cygwin_atexit SIGFE -_atexit = cygwin_atexit SIGFE -atof SIGFE -_atof = atof SIGFE -atoff SIGFE -_atoff = atoff SIGFE -atoi NOSIGFE -_atoi = atoi NOSIGFE -atol NOSIGFE -_atol = atol NOSIGFE -atoll NOSIGFE -basename NOSIGFE -bcmp NOSIGFE -_bcmp = bcmp NOSIGFE -bcopy NOSIGFE -_bcopy = bcopy NOSIGFE -bind = cygwin_bind SIGFE -bindresvport = cygwin_bindresvport SIGFE -bindresvport_sa = cygwin_bindresvport_sa SIGFE -bsearch NOSIGFE -_bsearch = bsearch NOSIGFE -btowc NOSIGFE -bzero NOSIGFE -_bzero = bzero NOSIGFE -cabs NOSIGFE -_cabs = cabs NOSIGFE -cabsf NOSIGFE -_cabsf = cabsf NOSIGFE -calloc SIGFE -_calloc = calloc SIGFE -canonicalize_file_name SIGFE -cbrt NOSIGFE -_cbrt = cbrt NOSIGFE -cbrtf NOSIGFE -_cbrtf = cbrtf NOSIGFE -ceil NOSIGFE -_ceil = ceil NOSIGFE -ceilf NOSIGFE -_ceilf = ceilf NOSIGFE -cfgetispeed NOSIGFE -cfgetospeed NOSIGFE -cfmakeraw NOSIGFE -cfsetispeed SIGFE -cfsetospeed SIGFE -chdir SIGFE -_chdir = chdir SIGFE -chmod SIGFE -_chmod = chmod SIGFE -chown SIGFE -_chown = chown SIGFE -_chown32 = chown32 SIGFE -chroot SIGFE -_chroot = chroot SIGFE -cleanup_glue NOSIGFE -clearerr SIGFE -_clearerr = clearerr SIGFE -clock SIGFE -_clock = clock SIGFE -clock_getres SIGFE -clock_gettime SIGFE -clock_setres SIGFE -close SIGFE -_close = close SIGFE -closedir SIGFE -_closedir = closedir SIGFE -closelog SIGFE -confstr NOSIGFE -connect = cygwin_connect SIGFE -copysign NOSIGFE -_copysign = copysign NOSIGFE -copysignf NOSIGFE -_copysignf = copysignf NOSIGFE -cos NOSIGFE -_cos = cos NOSIGFE -cosf NOSIGFE -_cosf = cosf NOSIGFE -cosh NOSIGFE -_cosh = cosh NOSIGFE -coshf NOSIGFE -_coshf = coshf NOSIGFE -creat SIGFE -_creat = creat SIGFE -ctermid SIGFE -ctime SIGFE -_ctime = ctime SIGFE -ctime_r SIGFE -_ctime_r = ctime_r SIGFE -cuserid NOSIGFE -_cuserid = cuserid NOSIGFE -cwait SIGFE -_cwait = cwait SIGFE -cygwin32_attach_handle_to_fd = cygwin_attach_handle_to_fd SIGFE -cygwin32_conv_to_full_posix_path = cygwin_conv_to_full_posix_path SIGFE -cygwin32_conv_to_full_win32_path = cygwin_conv_to_full_win32_path SIGFE -cygwin32_conv_to_posix_path = cygwin_conv_to_posix_path SIGFE -cygwin32_conv_to_win32_path = cygwin_conv_to_win32_path SIGFE -cygwin32_detach_dll = cygwin_detach_dll SIGFE_MAYBE -cygwin32_internal = cygwin_internal SIGFE -cygwin32_posix_path_list_p = cygwin_posix_path_list_p NOSIGFE -cygwin32_posix_to_win32_path_list = cygwin_posix_to_win32_path_list SIGFE -cygwin32_posix_to_win32_path_list_buf_size = cygwin_posix_to_win32_path_list_buf_size SIGFE -cygwin32_split_path = cygwin_split_path NOSIGFE -cygwin32_win32_to_posix_path_list = cygwin_win32_to_posix_path_list SIGFE -cygwin32_win32_to_posix_path_list_buf_size = cygwin_win32_to_posix_path_list_buf_size SIGFE -cygwin32_winpid_to_pid = cygwin_winpid_to_pid SIGFE -cygwin_attach_handle_to_fd SIGFE -cygwin_conv_path SIGFE -cygwin_conv_path_list SIGFE -cygwin_conv_to_full_posix_path SIGFE -cygwin_conv_to_full_win32_path SIGFE -cygwin_conv_to_posix_path SIGFE -cygwin_conv_to_win32_path SIGFE -cygwin_create_path SIGFE -cygwin_detach_dll SIGFE_MAYBE -cygwin_dll_init NOSIGFE -cygwin_internal NOSIGFE -cygwin_logon_user SIGFE -cygwin_posix_path_list_p NOSIGFE -cygwin_posix_to_win32_path_list SIGFE -cygwin_posix_to_win32_path_list_buf_size SIGFE -cygwin_set_impersonation_token SIGFE -cygwin_split_path NOSIGFE -cygwin_stackdump SIGFE -cygwin_umount SIGFE -cygwin_win32_to_posix_path_list SIGFE -cygwin_win32_to_posix_path_list_buf_size SIGFE -cygwin_winpid_to_pid SIGFE -daemon SIGFE -difftime NOSIGFE -_difftime = difftime NOSIGFE -dirfd SIGFE -_dirfd = dirfd SIGFE -dirname NOSIGFE -div NOSIGFE -_div = div NOSIGFE -dlclose SIGFE -dlerror NOSIGFE -dlfork NOSIGFE -_dll_crt0@0 NOSIGFE -dll_crt0__FP11per_process NOSIGFE # dll_crt0(per_process *) -dll_dllcrt0 NOSIGFE -dll_entry@12 NOSIGFE -dll_noncygwin_dllcrt0 NOSIGFE -dlopen SIGFE -dlsym SIGFE -dn_comp = __dn_comp SIGFE -__dn_comp SIGFE -dn_expand = __dn_expand SIGFE -__dn_expand SIGFE -dn_skipname = __dn_skipname SIGFE -__dn_skipname SIGFE -dprintf SIGFE -drand48 NOSIGFE -_drand48 = drand48 NOSIGFE -drem NOSIGFE -_drem = drem NOSIGFE -dremf NOSIGFE -_dremf = dremf NOSIGFE -dup SIGFE -_dup = dup SIGFE -dup2 SIGFE -_dup2 = dup2 SIGFE -dup3 SIGFE -eaccess = euidaccess SIGFE -ecvt SIGFE -_ecvt = ecvt SIGFE -ecvtbuf SIGFE -_ecvtbuf = ecvtbuf SIGFE -ecvtf SIGFE -_ecvtf = ecvtf SIGFE -endgrent NOSIGFE -_endgrent = endgrent NOSIGFE -endhostent NOSIGFE -endmntent NOSIGFE -_endmntent = endmntent NOSIGFE -endprotoent = cygwin_endprotoent SIGFE -endpwent NOSIGFE -_endpwent = endpwent NOSIGFE -endservent = cygwin_endservent SIGFE -endusershell SIGFE -endutent SIGFE -_endutent = endutent SIGFE -endutxent SIGFE -envz_add SIGFE -__envz_add = envz_add SIGFE -envz_entry NOSIGFE -__envz_entry = envz_entry NOSIGFE -envz_get NOSIGFE -__envz_get = envz_get NOSIGFE -envz_merge SIGFE -__envz_merge = envz_merge SIGFE -envz_remove SIGFE -__envz_remove = envz_remove SIGFE -envz_strip SIGFE -__envz_strip = envz_strip SIGFE -__eprintf SIGFE -erand48 NOSIGFE -_erand48 = erand48 NOSIGFE -erf NOSIGFE -_erf = erf NOSIGFE -erfc NOSIGFE -_erfc = erfc NOSIGFE -erfcf NOSIGFE -_erfcf = erfcf NOSIGFE -erff NOSIGFE -_erff = erff NOSIGFE -err SIGFE -__errno NOSIGFE -errx SIGFE -euidaccess SIGFE -execl SIGFE -_execl = execl SIGFE -execle SIGFE -_execle = execle SIGFE -execlp SIGFE -_execlp = execlp SIGFE -execv SIGFE -_execv = execv SIGFE -execve SIGFE -_execve = execve SIGFE -execvp SIGFE -_execvp = execvp SIGFE -execvpe SIGFE -exit = cygwin_exit SIGFE -_exit SIGFE -exp NOSIGFE -_exp = exp NOSIGFE -exp10 NOSIGFE -exp10f NOSIGFE -exp2 NOSIGFE -exp2f NOSIGFE -expf NOSIGFE -_expf = expf NOSIGFE -expm1 NOSIGFE -_expm1 = expm1 NOSIGFE -expm1f NOSIGFE -_expm1f = expm1f NOSIGFE -_f_atan2 NOSIGFE -__f_atan2 = _f_atan2 NOSIGFE -_f_atan2f NOSIGFE -__f_atan2f = _f_atan2f NOSIGFE -_f_exp NOSIGFE -__f_exp = _f_exp NOSIGFE -_f_expf NOSIGFE -__f_expf = _f_expf NOSIGFE -_f_frexp NOSIGFE -__f_frexp = _f_frexp NOSIGFE -_f_frexpf NOSIGFE -__f_frexpf = _f_frexpf NOSIGFE -_f_ldexp NOSIGFE -__f_ldexp = _f_ldexp NOSIGFE -_f_ldexpf NOSIGFE -__f_ldexpf = _f_ldexpf NOSIGFE -_f_llrint NOSIGFE -_f_llrintf NOSIGFE -_f_llrintl NOSIGFE -_f_log NOSIGFE -__f_log = _f_log NOSIGFE -_f_log10 NOSIGFE -__f_log10 = _f_log10 NOSIGFE -_f_log10f NOSIGFE -__f_log10f = _f_log10f NOSIGFE -_f_logf NOSIGFE -__f_logf = _f_logf NOSIGFE -_f_lrint NOSIGFE -_f_lrintf NOSIGFE -_f_lrintl NOSIGFE -_f_pow NOSIGFE -__f_pow = _f_pow NOSIGFE -_f_powf NOSIGFE -__f_powf = _f_powf NOSIGFE -_f_rint NOSIGFE -_f_rintf NOSIGFE -_f_rintl NOSIGFE -_f_tan NOSIGFE -__f_tan = _f_tan NOSIGFE -_f_tanf NOSIGFE -__f_tanf = _f_tanf NOSIGFE -fabs NOSIGFE -_fabs = fabs NOSIGFE -fabsf NOSIGFE -_fabsf = fabsf NOSIGFE -faccessat SIGFE -facl SIGFE -_facl = facl SIGFE -_facl32 = facl32 SIGFE -fchdir SIGFE -_fchdir = fchdir SIGFE -fchmod SIGFE -_fchmod = fchmod SIGFE -fchmodat SIGFE -fchown SIGFE -_fchown = fchown SIGFE -_fchown32 = fchown32 SIGFE -fchownat SIGFE -fclose SIGFE -_fclose = fclose SIGFE -fcloseall SIGFE -_fcloseall = fcloseall SIGFE -fcloseall_r = _fcloseall_r SIGFE -_fcloseall_r SIGFE -fcntl SIGFE -_fcntl = fcntl SIGFE -_fcntl64 = fcntl64 SIGFE -fcvt SIGFE -_fcvt = fcvt SIGFE -fcvtbuf SIGFE -_fcvtbuf = fcvtbuf SIGFE -fcvtf SIGFE -_fcvtf = fcvtf SIGFE -fdatasync SIGFE -fdim NOSIGFE -fdimf NOSIGFE -fdopen SIGFE -_fdopen = fdopen SIGFE -_fdopen64 = fdopen64 SIGFE -fdopendir SIGFE -feof SIGFE -_feof = feof SIGFE -ferror SIGFE -_ferror = ferror SIGFE -fexecve SIGFE -fflush SIGFE -_fflush = fflush SIGFE -ffs NOSIGFE -_ffs = ffs NOSIGFE -fgetc SIGFE -_fgetc = fgetc SIGFE -fgetpos SIGFE -_fgetpos = fgetpos SIGFE -_fgetpos64 = fgetpos64 SIGFE -fgets SIGFE -_fgets = fgets SIGFE -fgetwc SIGFE -fgetws SIGFE -fgetxattr SIGFE -fileno SIGFE -_fileno = fileno SIGFE -finite NOSIGFE -_finite = finite NOSIGFE -finitef NOSIGFE -_finitef = finitef NOSIGFE -fiprintf SIGFE -_fiprintf = fiprintf SIGFE -flistxattr SIGFE -flock SIGFE -flockfile SIGFE -floor NOSIGFE -_floor = floor NOSIGFE -floorf NOSIGFE -_floorf = floorf NOSIGFE -fma NOSIGFE -fmaf NOSIGFE -fmax NOSIGFE -fmaxf NOSIGFE -fmemopen SIGFE -fmin NOSIGFE -fminf NOSIGFE -fmod NOSIGFE -_fmod = fmod NOSIGFE -fmodf NOSIGFE -_fmodf = fmodf NOSIGFE -fnmatch NOSIGFE -_fnmatch = fnmatch NOSIGFE -fopen SIGFE -_fopen = fopen SIGFE -_fopen64 = fopen64 SIGFE -fopencookie SIGFE -fork SIGFE -_fork = fork SIGFE -forkpty SIGFE -fpathconf SIGFE -__fpclassifyd NOSIGFE -__fpclassifyf NOSIGFE -fprintf SIGFE -_fprintf = fprintf SIGFE -fpurge SIGFE -fputc SIGFE -_fputc = fputc SIGFE -fputs SIGFE -_fputs = fputs SIGFE -fputwc SIGFE -fputws SIGFE -fread SIGFE -_fread = fread SIGFE -free SIGFE -_free = free SIGFE -freeaddrinfo = cygwin_freeaddrinfo SIGFE -freeifaddrs SIGFE -fremovexattr SIGFE -freopen SIGFE -_freopen = freopen SIGFE -_freopen64 = freopen64 SIGFE -frexp NOSIGFE -_frexp = frexp NOSIGFE -frexpf NOSIGFE -_frexpf = frexpf NOSIGFE -fscanf SIGFE -_fscanf = fscanf SIGFE -fscanf_r = _fscanf_r SIGFE -_fscanf_r SIGFE -fseek SIGFE -_fseek = fseek SIGFE -fseeko SIGFE -_fseeko = fseeko SIGFE -_fseeko64 = fseeko64 SIGFE -fsetpos SIGFE -_fsetpos = fsetpos SIGFE -_fsetpos64 = fsetpos64 SIGFE -fsetxattr SIGFE -fstat SIGFE -_fstat = fstat SIGFE -_fstat64 = fstat64 SIGFE -fstatat SIGFE -fstatfs SIGFE -_fstatfs = fstatfs SIGFE -fstatvfs SIGFE -fsync SIGFE -_fsync = fsync SIGFE -ftell SIGFE -_ftell = ftell SIGFE -ftello SIGFE -_ftello = ftello SIGFE -_ftello64 = ftello64 SIGFE -ftime SIGFE -_ftime = ftime SIGFE -ftok SIGFE -_ftok = ftok SIGFE -ftruncate SIGFE -_ftruncate = ftruncate SIGFE -_ftruncate64 = ftruncate64 SIGFE -ftrylockfile SIGFE -fts_children SIGFE -fts_close SIGFE -fts_get_clientptr NOSIGFE -fts_get_stream NOSIGFE -fts_open SIGFE -fts_read SIGFE -fts_set NOSIGFE -fts_set_clientptr NOSIGFE -ftw SIGFE -funlockfile SIGFE -funopen SIGFE -futimens SIGFE -futimes SIGFE -futimesat SIGFE -fwide SIGFE -fwprintf SIGFE -fwrite SIGFE -_fwrite = fwrite SIGFE -fwscanf SIGFE -gai_strerror = cygwin_gai_strerror NOSIGFE -gamma NOSIGFE -_gamma = gamma NOSIGFE -gamma_r NOSIGFE -_gamma_r = gamma_r NOSIGFE -gammaf NOSIGFE -_gammaf = gammaf NOSIGFE -gammaf_r NOSIGFE -_gammaf_r = gammaf_r NOSIGFE -gcvt SIGFE -_gcvt = gcvt SIGFE -gcvtf SIGFE -_gcvtf = gcvtf SIGFE -get_avphys_pages SIGFE -get_nprocs SIGFE -get_nprocs_conf SIGFE -get_osfhandle SIGFE -_get_osfhandle = get_osfhandle SIGFE -get_phys_pages SIGFE -getaddrinfo = cygwin_getaddrinfo SIGFE -getc SIGFE -_getc = getc SIGFE -getc_unlocked SIGFE -_getc_unlocked = getc_unlocked SIGFE -getchar SIGFE -_getchar = getchar SIGFE -getchar_unlocked SIGFE -_getchar_unlocked = getchar_unlocked SIGFE -getcwd SIGFE -_getcwd = getcwd SIGFE -getdelim = __getdelim SIGFE -__getdelim SIGFE -getdomainname SIGFE -_getdomainname = getdomainname SIGFE -getdtablesize NOSIGFE -_getdtablesize = getdtablesize NOSIGFE -getegid NOSIGFE -_getegid = getegid NOSIGFE -_getegid32 = getegid32 NOSIGFE -getenv NOSIGFE -_getenv = getenv NOSIGFE -geteuid NOSIGFE -_geteuid = geteuid NOSIGFE -_geteuid32 = geteuid32 NOSIGFE -getgid NOSIGFE -_getgid = getgid NOSIGFE -_getgid32 = getgid32 NOSIGFE -getgrent SIGFE -_getgrent = getgrent SIGFE -_getgrent32 = getgrent32 SIGFE -getgrgid SIGFE -_getgrgid = getgrgid SIGFE -_getgrgid32 = getgrgid32 SIGFE -getgrgid_r SIGFE -getgrnam SIGFE -_getgrnam = getgrnam SIGFE -_getgrnam32 = getgrnam32 SIGFE -getgrnam_r SIGFE -getgroups SIGFE -_getgroups = getgroups SIGFE -_getgroups32 = getgroups32 SIGFE -gethostbyaddr = cygwin_gethostbyaddr SIGFE -gethostbyname = cygwin_gethostbyname SIGFE -gethostbyname2 SIGFE -gethostid SIGFE -gethostname = cygwin_gethostname SIGFE -_gethostname = cygwin_gethostname SIGFE -getifaddrs SIGFE -getitimer SIGFE -getline = __getline SIGFE -__getline SIGFE -getlogin NOSIGFE -_getlogin = getlogin NOSIGFE -getlogin_r NOSIGFE -getmntent SIGFE -_getmntent = getmntent SIGFE -getmode SIGFE -_getmode = getmode SIGFE -getnameinfo = cygwin_getnameinfo SIGFE -getopt SIGFE -getopt_long SIGFE -getopt_long_only SIGFE -getpagesize SIGFE -_getpagesize = getpagesize SIGFE -getpass SIGFE -_getpass = getpass SIGFE -getpeereid SIGFE -getpeername = cygwin_getpeername SIGFE -getpgid SIGFE -getpgrp SIGFE -_getpgrp = getpgrp SIGFE -getpid NOSIGFE -_getpid = getpid NOSIGFE -getppid NOSIGFE -_getppid = getppid NOSIGFE -getpriority SIGFE -getprogname NOSIGFE -getprotobyname = cygwin_getprotobyname SIGFE -getprotobynumber = cygwin_getprotobynumber SIGFE -getprotoent = cygwin_getprotoent SIGFE -getpwduid NOSIGFE -_getpwduid = getpwduid NOSIGFE -getpwent SIGFE -_getpwent = getpwent SIGFE -getpwnam SIGFE -_getpwnam = getpwnam SIGFE -getpwnam_r SIGFE -getpwuid SIGFE -_getpwuid = getpwuid SIGFE -_getpwuid32 = getpwuid32 SIGFE -getpwuid_r SIGFE -_getpwuid_r32 = getpwuid_r32 SIGFE -__getreent NOSIGFE -getrlimit SIGFE -_getrlimit = getrlimit SIGFE -getrusage SIGFE -_getrusage = getrusage SIGFE -gets SIGFE -_gets = gets SIGFE -getservbyname = cygwin_getservbyname SIGFE -getservbyport = cygwin_getservbyport SIGFE -getservent = cygwin_getservent SIGFE -getsid SIGFE -getsockname = cygwin_getsockname SIGFE -getsockopt = cygwin_getsockopt SIGFE -getsubopt NOSIGFE -gettimeofday SIGFE -_gettimeofday = gettimeofday SIGFE -getuid NOSIGFE -_getuid = getuid NOSIGFE -_getuid32 = getuid32 NOSIGFE -getusershell SIGFE -getutent SIGFE -_getutent = getutent SIGFE -getutid SIGFE -_getutid = getutid SIGFE -getutline SIGFE -getutxent SIGFE -getutxid SIGFE -getutxline SIGFE -getw SIGFE -_getw = getw SIGFE -getwc SIGFE -getwchar SIGFE -getwd SIGFE -_getwd = getwd SIGFE -getxattr SIGFE -glob SIGFE -glob_pattern_p -globfree SIGFE -gmtime SIGFE -_gmtime = gmtime SIGFE -gmtime_r SIGFE -_gmtime_r = gmtime_r SIGFE -grantpt NOSIGFE -hcreate SIGFE -hcreate_r SIGFE -hdestroy SIGFE -hdestroy_r SIGFE -herror = cygwin_herror SIGFE -hsearch SIGFE -hsearch_r SIGFE -hstrerror = cygwin_hstrerror NOSIGFE -htonl NOSIGFE -_htonl = htonl NOSIGFE -htons NOSIGFE -_htons = htons NOSIGFE -hypot NOSIGFE -_hypot = hypot NOSIGFE -hypotf NOSIGFE -_hypotf = hypotf NOSIGFE -if_freenameindex SIGFE -if_indextoname SIGFE -if_nameindex SIGFE -if_nametoindex SIGFE -ilogb NOSIGFE -_ilogb = ilogb NOSIGFE -ilogbf NOSIGFE -_ilogbf = ilogbf NOSIGFE -imaxabs = llabs NOSIGFE -imaxdiv = lldiv NOSIGFE -index NOSIGFE -_index = index NOSIGFE -inet_addr = cygwin_inet_addr SIGFE -inet_aton = cygwin_inet_aton SIGFE -inet_makeaddr NOSIGFE -inet_netof NOSIGFE -inet_network = cygwin_inet_network SIGFE -inet_ntoa = cygwin_inet_ntoa SIGFE -inet_ntop = cygwin_inet_ntop SIGFE -inet_pton = cygwin_inet_pton SIGFE -infinity NOSIGFE -_infinity = infinity NOSIGFE -__infinity NOSIGFE -infinityf NOSIGFE -_infinityf = infinityf NOSIGFE -initgroups SIGFE -_initgroups32 = initgroups32 SIGFE -initstate NOSIGFE -insque NOSIGFE -ioctl SIGFE -_ioctl = ioctl SIGFE -iprintf SIGFE -_iprintf = iprintf SIGFE -iruserok SIGFE -iruserok_sa SIGFE -isalnum NOSIGFE -_isalnum = isalnum NOSIGFE -isalpha NOSIGFE -_isalpha = isalpha NOSIGFE -isascii NOSIGFE -_isascii = isascii NOSIGFE -isatty SIGFE -_isatty = isatty SIGFE -isblank NOSIGFE -iscntrl NOSIGFE -_iscntrl = iscntrl NOSIGFE -isdigit NOSIGFE -_isdigit = isdigit NOSIGFE -isgraph NOSIGFE -_isgraph = isgraph NOSIGFE -isinf NOSIGFE -_isinf = isinf NOSIGFE -__isinfd NOSIGFE -isinff NOSIGFE -_isinff = isinff NOSIGFE -__isinff NOSIGFE -islower NOSIGFE -_islower = islower NOSIGFE -isnan NOSIGFE -_isnan = isnan NOSIGFE -__isnand NOSIGFE -isnanf NOSIGFE -_isnanf = isnanf NOSIGFE -__isnanf NOSIGFE -isprint NOSIGFE -_isprint = isprint NOSIGFE -ispunct NOSIGFE -_ispunct = ispunct NOSIGFE -isspace NOSIGFE -_isspace = isspace NOSIGFE -isupper NOSIGFE -_isupper = isupper NOSIGFE -iswalnum NOSIGFE -iswalpha NOSIGFE -iswblank NOSIGFE -iswcntrl NOSIGFE -iswctype NOSIGFE -iswdigit NOSIGFE -iswgraph NOSIGFE -iswlower NOSIGFE -iswprint NOSIGFE -iswpunct NOSIGFE -iswspace NOSIGFE -iswupper NOSIGFE -iswxdigit NOSIGFE -isxdigit NOSIGFE -_isxdigit = isxdigit NOSIGFE -j0 NOSIGFE -_j0 = j0 NOSIGFE -j0f NOSIGFE -_j0f = j0f NOSIGFE -j1 NOSIGFE -_j1 = j1 NOSIGFE -j1f NOSIGFE -_j1f = j1f NOSIGFE -jn NOSIGFE -_jn = jn NOSIGFE -jnf NOSIGFE -_jnf = jnf NOSIGFE -jrand48 NOSIGFE -_jrand48 = jrand48 NOSIGFE -kill SIGFE -_kill = kill SIGFE -killpg SIGFE -l64a NOSIGFE -labs NOSIGFE -_labs = labs NOSIGFE -lacl SIGFE -_lacl = lacl SIGFE -lchown SIGFE -_lchown = lchown SIGFE -_lchown32 = lchown32 SIGFE -lcong48 NOSIGFE -_lcong48 = lcong48 NOSIGFE -ldexp NOSIGFE -_ldexp = ldexp NOSIGFE -ldexpf NOSIGFE -_ldexpf = ldexpf NOSIGFE -ldiv NOSIGFE -_ldiv = ldiv NOSIGFE -lfind NOSIGFE -lgamma NOSIGFE -_lgamma = lgamma NOSIGFE -lgamma_r NOSIGFE -_lgamma_r = lgamma_r NOSIGFE -lgammaf NOSIGFE -_lgammaf = lgammaf NOSIGFE -lgammaf_r NOSIGFE -_lgammaf_r = lgammaf_r NOSIGFE -lgetxattr SIGFE -link SIGFE -_link = link SIGFE -linkat SIGFE -listen = cygwin_listen SIGFE -listxattr SIGFE -llabs NOSIGFE -lldiv NOSIGFE -llistxattr SIGFE -llrint = _f_llrint NOSIGFE -llrintf = _f_llrintf NOSIGFE -llrintl = _f_llrintl NOSIGFE -localeconv NOSIGFE -_localeconv = localeconv NOSIGFE -localtime SIGFE -_localtime = localtime SIGFE -localtime_r SIGFE -_localtime_r = localtime_r SIGFE -lockf SIGFE -log NOSIGFE -_log = log NOSIGFE -log10 NOSIGFE -_log10 = log10 NOSIGFE -log10f NOSIGFE -_log10f = log10f NOSIGFE -log1p NOSIGFE -_log1p = log1p NOSIGFE -log1pf NOSIGFE -_log1pf = log1pf NOSIGFE -log2 NOSIGFE -log2f NOSIGFE -logb NOSIGFE -_logb = logb NOSIGFE -logbf NOSIGFE -_logbf = logbf NOSIGFE -logf NOSIGFE -_logf = logf NOSIGFE -login SIGFE -login_tty SIGFE -logout SIGFE -logwtmp SIGFE -longjmp NOSIGFE -_longjmp = longjmp NOSIGFE -lrand48 NOSIGFE -_lrand48 = lrand48 NOSIGFE -lremovexattr SIGFE -lrint = _f_lrint NOSIGFE -lrintf = _f_lrintf NOSIGFE -lrintl = _f_lrintl NOSIGFE -lround NOSIGFE -lroundf NOSIGFE -lsearch NOSIGFE -lseek SIGFE -_lseek = lseek SIGFE -_lseek64 = lseek64 SIGFE -lsetxattr SIGFE -lstat SIGFE -_lstat = lstat SIGFE -_lstat64 = lstat64 SIGFE -lutimes SIGFE -__main NOSIGFE -mallinfo SIGFE -malloc SIGFE -_malloc = malloc SIGFE -malloc_stats SIGFE -malloc_trim SIGFE -malloc_usable_size SIGFE -mallopt SIGFE -matherr NOSIGFE -_matherr = matherr NOSIGFE -mblen NOSIGFE -_mblen = mblen NOSIGFE -mbrlen NOSIGFE -mbrtowc NOSIGFE -mbsinit NOSIGFE -mbsnrtowcs NOSIGFE -mbsrtowcs NOSIGFE -mbstowcs NOSIGFE -_mbstowcs = mbstowcs NOSIGFE -mbtowc NOSIGFE -_mbtowc = mbtowc NOSIGFE -memalign SIGFE -memccpy NOSIGFE -_memccpy = memccpy NOSIGFE -memchr NOSIGFE -_memchr = memchr NOSIGFE -memcmp NOSIGFE -_memcmp = memcmp NOSIGFE -memcpy NOSIGFE -_memcpy = memcpy NOSIGFE -memmem NOSIGFE -memmove NOSIGFE -_memmove = memmove NOSIGFE -mempcpy NOSIGFE -__mempcpy = mempcpy NOSIGFE -memset NOSIGFE -_memset = memset NOSIGFE -mkdir SIGFE -_mkdir = mkdir SIGFE -mkdirat SIGFE -mkdtemp SIGFE -mkfifo SIGFE -mkfifoat SIGFE -mknod SIGFE -_mknod = mknod SIGFE -_mknod32 = mknod32 SIGFE -mknodat SIGFE -mkstemp SIGFE -_mkstemp = mkstemp SIGFE -mkstemps SIGFE -mktemp SIGFE -_mktemp = mktemp SIGFE -mktime SIGFE -_mktime = mktime SIGFE -mlock SIGFE -mmap SIGFE -_mmap64 = mmap64 SIGFE -modf NOSIGFE -_modf = modf NOSIGFE -modff NOSIGFE -_modff = modff NOSIGFE -mount SIGFE -_mount = mount SIGFE -mprotect SIGFE -mq_close SIGFE -mq_getattr SIGFE -mq_notify SIGFE -mq_open SIGFE -mq_receive SIGFE -mq_send SIGFE -mq_setattr SIGFE -mq_timedreceive SIGFE -mq_timedsend SIGFE -mq_unlink SIGFE -mrand48 NOSIGFE -msgctl SIGFE -msgget SIGFE -msgrcv SIGFE -msgsnd SIGFE -msync SIGFE -munlock SIGFE -munmap SIGFE -nan NOSIGFE -_nan = nan NOSIGFE -nanf NOSIGFE -_nanf = nanf NOSIGFE -nanosleep SIGFE -_nanosleep = nanosleep SIGFE -nearbyint NOSIGFE -nearbyintf NOSIGFE -nextafter NOSIGFE -_nextafter = nextafter NOSIGFE -nextafterf NOSIGFE -_nextafterf = nextafterf NOSIGFE -nftw SIGFE -nice SIGFE -_nice = nice SIGFE -nl_langinfo SIGFE -_nl_langinfo = nl_langinfo SIGFE -nrand48 NOSIGFE -_nrand48 = nrand48 NOSIGFE -ntohl NOSIGFE -_ntohl = ntohl NOSIGFE -ntohs NOSIGFE -_ntohs = ntohs NOSIGFE -on_exit SIGFE -open SIGFE -_open = open SIGFE -_open64 -open_memstream SIGFE -open_wmemstream SIGFE -openat SIGFE -opendir SIGFE -__opendir_with_d_ino SIGFE -openlog SIGFE -_openlog = openlog SIGFE -openpty SIGFE -pathconf SIGFE -_pathconf = pathconf SIGFE -pause SIGFE -pclose SIGFE -_pclose = pclose SIGFE -perror SIGFE -_perror = perror SIGFE -pipe SIGFE -_pipe SIGFE -pipe2 SIGFE -poll SIGFE -_poll = poll SIGFE -popen SIGFE -_popen = popen SIGFE -posix_fadvise SIGFE -posix_fallocate SIGFE -posix_madvise SIGFE -posix_memalign SIGFE -posix_openpt SIGFE -posix_regcomp = regcomp SIGFE -posix_regerror = regerror SIGFE -posix_regexec = regexec SIGFE -posix_regfree = regfree SIGFE -pow NOSIGFE -_pow = pow NOSIGFE -pow10 NOSIGFE -pow10f NOSIGFE -powf NOSIGFE -_powf = powf NOSIGFE -pread SIGFE -printf SIGFE -_printf = printf SIGFE -pselect SIGFE -pthread_atfork SIGFE -pthread_attr_destroy SIGFE -pthread_attr_getdetachstate SIGFE -pthread_attr_getinheritsched SIGFE -pthread_attr_getschedparam SIGFE -pthread_attr_getschedpolicy SIGFE -pthread_attr_getscope SIGFE -pthread_attr_getstacksize SIGFE -pthread_attr_init SIGFE -pthread_attr_setdetachstate SIGFE -pthread_attr_setinheritsched SIGFE -pthread_attr_setschedparam SIGFE -pthread_attr_setschedpolicy SIGFE -pthread_attr_setscope SIGFE -pthread_attr_setstacksize SIGFE -pthread_cancel SIGFE -_pthread_cleanup_pop SIGFE -_pthread_cleanup_push SIGFE -pthread_cond_broadcast SIGFE -pthread_cond_destroy SIGFE -pthread_cond_init SIGFE -pthread_cond_signal SIGFE -pthread_cond_timedwait SIGFE -pthread_cond_wait SIGFE -pthread_condattr_destroy SIGFE -pthread_condattr_getpshared SIGFE -pthread_condattr_init SIGFE -pthread_condattr_setpshared SIGFE -pthread_continue SIGFE -pthread_create SIGFE -pthread_detach SIGFE -pthread_equal SIGFE -pthread_exit SIGFE -pthread_getconcurrency SIGFE -pthread_getschedparam SIGFE -pthread_getsequence_np SIGFE -pthread_getspecific SIGFE -pthread_join SIGFE -pthread_key_create SIGFE -pthread_key_delete SIGFE -pthread_kill SIGFE -pthread_mutex_destroy SIGFE -pthread_mutex_getprioceiling SIGFE -pthread_mutex_init SIGFE -pthread_mutex_lock SIGFE -pthread_mutex_setprioceiling SIGFE -pthread_mutex_trylock SIGFE -pthread_mutex_unlock SIGFE -pthread_mutexattr_destroy SIGFE -pthread_mutexattr_getprioceiling SIGFE -pthread_mutexattr_getprotocol SIGFE -pthread_mutexattr_getpshared SIGFE -pthread_mutexattr_gettype SIGFE -pthread_mutexattr_init SIGFE -pthread_mutexattr_setprioceiling SIGFE -pthread_mutexattr_setprotocol SIGFE -pthread_mutexattr_setpshared SIGFE -pthread_mutexattr_settype SIGFE -pthread_once SIGFE -pthread_rwlock_destroy SIGFE -pthread_rwlock_init SIGFE -pthread_rwlock_rdlock SIGFE -pthread_rwlock_tryrdlock SIGFE -pthread_rwlock_trywrlock SIGFE -pthread_rwlock_unlock SIGFE -pthread_rwlock_wrlock SIGFE -pthread_rwlockattr_destroy SIGFE -pthread_rwlockattr_getpshared SIGFE -pthread_rwlockattr_init SIGFE -pthread_rwlockattr_setpshared SIGFE -pthread_self SIGFE -pthread_setcancelstate SIGFE -pthread_setcanceltype SIGFE -pthread_setconcurrency SIGFE -pthread_setschedparam SIGFE -pthread_setspecific SIGFE -pthread_sigmask SIGFE -pthread_suspend SIGFE -pthread_testcancel SIGFE -ptsname SIGFE -putc SIGFE -_putc = putc SIGFE -putc_unlocked SIGFE -_putc_unlocked = putc_unlocked SIGFE -putchar SIGFE -_putchar = putchar SIGFE -putchar_unlocked SIGFE -_putchar_unlocked = putchar_unlocked SIGFE -putenv SIGFE -_putenv = putenv SIGFE -puts SIGFE -_puts = puts SIGFE -pututline SIGFE -_pututline = pututline SIGFE -pututxline SIGFE -putw SIGFE -_putw = putw SIGFE -putwc SIGFE -putwchar SIGFE -pwrite SIGFE -qsort NOSIGFE -_qsort = qsort NOSIGFE -raise SIGFE -_raise = raise SIGFE -rand NOSIGFE -_rand = rand NOSIGFE -rand_r NOSIGFE -random NOSIGFE -rcmd = cygwin_rcmd SIGFE -rcmd_af = cygwin_rcmd_af SIGFE -read SIGFE -_read = read SIGFE -readdir SIGFE -_readdir = readdir SIGFE -readdir_r SIGFE -readlink SIGFE -_readlink = readlink SIGFE -readlinkat SIGFE -readv SIGFE -_readv = readv SIGFE -realloc SIGFE -_realloc = realloc SIGFE -reallocf SIGFE -realpath SIGFE -recv = cygwin_recv SIGFE -recvfrom = cygwin_recvfrom SIGFE -recvmsg = cygwin_recvmsg SIGFE -regcomp SIGFE -regerror SIGFE -regexec SIGFE -regfree SIGFE -remainder NOSIGFE -_remainder = remainder NOSIGFE -remainderf NOSIGFE -_remainderf = remainderf NOSIGFE -remove SIGFE -_remove = remove SIGFE -removexattr SIGFE -remque NOSIGFE -remquo NOSIGFE -remquof NOSIGFE -rename SIGFE -_rename = rename SIGFE -renameat SIGFE -res_close = __res_close SIGFE -__res_close SIGFE -res_init = __res_init SIGFE -__res_init SIGFE -res_mkquery = __res_mkquery SIGFE -__res_mkquery SIGFE -res_nclose = __res_nclose SIGFE -__res_nclose SIGFE -res_ninit = __res_ninit SIGFE -__res_ninit SIGFE -res_nmkquery = __res_nmkquery SIGFE -__res_nmkquery SIGFE -res_nquery = __res_nquery SIGFE -__res_nquery SIGFE -res_nquerydomain = __res_nquerydomain SIGFE -__res_nquerydomain SIGFE -res_nsearch = __res_nsearch SIGFE -__res_nsearch SIGFE -res_nsend = __res_nsend SIGFE -__res_nsend SIGFE -res_query = __res_query SIGFE -__res_query SIGFE -res_querydomain = __res_querydomain SIGFE -__res_querydomain SIGFE -res_search = __res_search SIGFE -__res_search SIGFE -res_send = __res_send SIGFE -__res_send SIGFE -__res_state SIGFE -revoke SIGFE -rewind SIGFE -_rewind = rewind SIGFE -rewinddir SIGFE -_rewinddir = rewinddir SIGFE -rexec = cygwin_rexec SIGFE -rindex NOSIGFE -_rindex = rindex NOSIGFE -rint = _f_rint NOSIGFE -rintf = _f_rintf NOSIGFE -rintl = _f_rintl NOSIGFE -rmdir SIGFE -_rmdir = rmdir SIGFE -round NOSIGFE -roundf NOSIGFE -rresvport = cygwin_rresvport SIGFE -rresvport_af = cygwin_rresvport_af SIGFE -ruserok SIGFE -sbrk SIGFE -_sbrk = sbrk SIGFE -scalb NOSIGFE -_scalb = scalb NOSIGFE -scalbf NOSIGFE -_scalbf = scalbf NOSIGFE -scalbln NOSIGFE -scalblnf NOSIGFE -scalbn NOSIGFE -_scalbn = scalbn NOSIGFE -scalbnf NOSIGFE -_scalbnf = scalbnf NOSIGFE -scandir SIGFE -_scandir = scandir SIGFE -scanf SIGFE -_scanf = scanf SIGFE -scanf_r = _scanf_r SIGFE -_scanf_r SIGFE -sched_get_priority_max SIGFE -sched_get_priority_min SIGFE -sched_getparam SIGFE -sched_getscheduler NOSIGFE -sched_rr_get_interval SIGFE -sched_setparam SIGFE -sched_setscheduler SIGFE -sched_yield SIGFE -seed48 NOSIGFE -_seed48 = seed48 NOSIGFE -seekdir SIGFE -_seekdir = seekdir SIGFE -_seekdir64 = seekdir64 SIGFE -select = cygwin_select SIGFE -_select = cygwin_select SIGFE -sem_close SIGFE -sem_destroy SIGFE -sem_getvalue SIGFE -sem_init SIGFE -sem_open SIGFE -sem_post SIGFE -sem_timedwait SIGFE -sem_trywait SIGFE -sem_unlink SIGFE -sem_wait SIGFE -semctl SIGFE -semget SIGFE -semop SIGFE -send = cygwin_send SIGFE -sendmsg = cygwin_sendmsg SIGFE -sendto = cygwin_sendto SIGFE -setbuf SIGFE -_setbuf = setbuf SIGFE -setbuffer SIGFE -setdtablesize SIGFE -_setdtablesize = setdtablesize SIGFE -setegid SIGFE -_setegid = setegid SIGFE -_setegid32 = setegid32 SIGFE -setenv SIGFE -_setenv = setenv SIGFE -seteuid SIGFE -_seteuid = seteuid SIGFE -_seteuid32 = seteuid32 SIGFE -setgid SIGFE -_setgid = setgid SIGFE -_setgid32 = setgid32 SIGFE -setgrent NOSIGFE -_setgrent = setgrent NOSIGFE -setgroups SIGFE -_setgroups = setgroups SIGFE -_setgroups32 = setgroups32 SIGFE -sethostent NOSIGFE -setitimer SIGFE -setjmp NOSIGFE -_setjmp = setjmp NOSIGFE -setlinebuf SIGFE -setlocale NOSIGFE -_setlocale = setlocale NOSIGFE -setlogmask NOSIGFE -setmntent SIGFE -_setmntent = setmntent SIGFE -setmode = cygwin_setmode SIGFE -_setmode = cygwin_setmode SIGFE -setpassent NOSIGFE -_setpassent = setpassent NOSIGFE -setpgid SIGFE -_setpgid = setpgid SIGFE -setpgrp SIGFE -_setpgrp = setpgrp SIGFE -setpriority SIGFE -setprogname NOSIGFE -setprotoent = cygwin_setprotoent SIGFE -setpwent NOSIGFE -_setpwent = setpwent NOSIGFE -setregid SIGFE -_setregid = setregid SIGFE -setregid32 SIGFE -_setregid32 = setregid32 SIGFE -setreuid SIGFE -_setreuid = setreuid SIGFE -setreuid32 SIGFE -_setreuid32 = setreuid32 SIGFE -setrlimit SIGFE -_setrlimit = setrlimit SIGFE -setservent = cygwin_setservent SIGFE -setsid SIGFE -_setsid = setsid SIGFE -setsockopt = cygwin_setsockopt SIGFE -setstate NOSIGFE -settimeofday SIGFE -_settimeofday = settimeofday SIGFE -setuid SIGFE -_setuid = setuid SIGFE -_setuid32 = setuid32 SIGFE -setusershell SIGFE -setutent SIGFE -_setutent = setutent SIGFE -setutxent SIGFE -setvbuf SIGFE -_setvbuf = setvbuf SIGFE -setxattr SIGFE -sexecl = sexecve_is_bad SIGFE -sexecle = sexecve_is_bad SIGFE -sexeclp = sexecve_is_bad SIGFE -sexeclpe = sexecve_is_bad SIGFE -sexecp = sexecve_is_bad SIGFE -sexecv = sexecve_is_bad SIGFE -sexecve = sexecve_is_bad SIGFE -sexecvpe = sexecve_is_bad SIGFE -shm_open SIGFE -shm_unlink SIGFE -shmat SIGFE -shmctl SIGFE -shmdt SIGFE -shmget SIGFE -shutdown = cygwin_shutdown SIGFE -sigaction SIGFE -sigaddset SIGFE -sigdelset SIGFE -sigemptyset NOSIGFE -sigfillset NOSIGFE -sighold SIGFE -sigignore SIGFE -siginterrupt SIGFE -sigismember SIGFE -signal SIGFE -__signbitd NOSIGFE -__signbitf NOSIGFE -__signgam NOSIGFE -significand NOSIGFE -significandf NOSIGFE -sigpause SIGFE -sigpending SIGFE -sigprocmask SIGFE -sigqueue SIGFE -sigrelse SIGFE -sigset SIGFE -sigsuspend SIGFE -sigwait SIGFE -sigwaitinfo SIGFE -sin NOSIGFE -_sin = sin NOSIGFE -sincos NOSIGFE -sincosf NOSIGFE -sinf NOSIGFE -_sinf = sinf NOSIGFE -sinh NOSIGFE -_sinh = sinh NOSIGFE -sinhf NOSIGFE -_sinhf = sinhf NOSIGFE -siprintf SIGFE -_siprintf = siprintf SIGFE -sleep SIGFE -_sleep = sleep SIGFE -snprintf SIGFE -_snprintf = snprintf SIGFE -socket = cygwin_socket SIGFE -socketpair SIGFE -spawnl SIGFE -_spawnl = spawnl SIGFE -spawnle SIGFE -_spawnle = spawnle SIGFE -spawnlp SIGFE -_spawnlp = spawnlp SIGFE -spawnlpe SIGFE -_spawnlpe = spawnlpe SIGFE -spawnv SIGFE -_spawnv = spawnv SIGFE -spawnve SIGFE -_spawnve = spawnve SIGFE -spawnvp SIGFE -_spawnvp = spawnvp SIGFE -spawnvpe SIGFE -_spawnvpe = spawnvpe SIGFE -sprintf SIGFE -_sprintf = sprintf SIGFE -sqrt NOSIGFE -_sqrt = sqrt NOSIGFE -sqrtf NOSIGFE -_sqrtf = sqrtf NOSIGFE -srand NOSIGFE -_srand = srand NOSIGFE -srand48 NOSIGFE -_srand48 = srand48 NOSIGFE -srandom NOSIGFE -__srget SIGFE -__srget_r SIGFE -sscanf SIGFE -_sscanf = sscanf SIGFE -sscanf_r = _sscanf_r SIGFE -_sscanf_r SIGFE -stat SIGFE -_stat = stat SIGFE -_stat64 = stat64 SIGFE -statfs SIGFE -_statfs = statfs SIGFE -statvfs SIGFE -stpcpy NOSIGFE -stpncpy NOSIGFE -strcasecmp NOSIGFE -_strcasecmp = strcasecmp NOSIGFE -strcasestr NOSIGFE -strcat NOSIGFE -_strcat = strcat NOSIGFE -strchr NOSIGFE -_strchr = strchr NOSIGFE -strcmp NOSIGFE -_strcmp = strcmp NOSIGFE -strcoll NOSIGFE -_strcoll = strcoll NOSIGFE -strcpy NOSIGFE -_strcpy = strcpy NOSIGFE -strcspn NOSIGFE -_strcspn = strcspn NOSIGFE -strdup SIGFE -_strdup = strdup SIGFE -strerror SIGFE -_strerror = strerror SIGFE -strerror_r SIGFE -_strerror_r = strerror_r SIGFE -strfmon SIGFE -strftime SIGFE -_strftime = strftime SIGFE -strlcat NOSIGFE -_strlcat = strlcat NOSIGFE -strlcpy NOSIGFE -_strlcpy = strlcpy NOSIGFE -strlen NOSIGFE -_strlen = strlen NOSIGFE -strlwr NOSIGFE -_strlwr = strlwr NOSIGFE -strncasecmp NOSIGFE -_strncasecmp = strncasecmp NOSIGFE -strncat NOSIGFE -_strncat = strncat NOSIGFE -strncmp NOSIGFE -_strncmp = strncmp NOSIGFE -strncpy NOSIGFE -_strncpy = strncpy NOSIGFE -strndup SIGFE -strnlen NOSIGFE -strpbrk NOSIGFE -_strpbrk = strpbrk NOSIGFE -strptime SIGFE -_strptime = strptime SIGFE -strrchr NOSIGFE -_strrchr = strrchr NOSIGFE -strsep NOSIGFE -_strsep = strsep NOSIGFE -strsignal SIGFE -strspn NOSIGFE -_strspn = strspn NOSIGFE -strstr NOSIGFE -_strstr = strstr NOSIGFE -strtod SIGFE -_strtod = strtod SIGFE -strtodf = strtof SIGFE -_strtodf = strtof SIGFE -strtof SIGFE -strtoimax = strtoll NOSIGFE -strtok NOSIGFE -_strtok = strtok NOSIGFE -strtok_r NOSIGFE -_strtok_r = strtok_r NOSIGFE -strtol NOSIGFE -_strtol = strtol NOSIGFE -_strtold SIGFE -strtoll NOSIGFE -_strtoll = strtoll NOSIGFE -strtosigno NOSIGFE -strtoul NOSIGFE -_strtoul = strtoul NOSIGFE -strtoull NOSIGFE -_strtoull = strtoull NOSIGFE -strtoumax = strtoull NOSIGFE -strupr NOSIGFE -_strupr = strupr NOSIGFE -strxfrm NOSIGFE -_strxfrm = strxfrm NOSIGFE -swab NOSIGFE -_swab = swab NOSIGFE -__swbuf SIGFE -__swbuf_r SIGFE -swprintf SIGFE -swscanf SIGFE -symlink SIGFE -_symlink = symlink SIGFE -symlinkat SIGFE -sync SIGFE -sysconf SIGFE -_sysconf = sysconf SIGFE -syslog SIGFE -_syslog = syslog SIGFE -system SIGFE -_system = system SIGFE -tan NOSIGFE -_tan = tan NOSIGFE -tanf NOSIGFE -_tanf = tanf NOSIGFE -tanh NOSIGFE -_tanh = tanh NOSIGFE -tanhf NOSIGFE -_tanhf = tanhf NOSIGFE -tcdrain SIGFE -_tcdrain = tcdrain SIGFE -tcflow SIGFE -_tcflow = tcflow SIGFE -tcflush SIGFE -_tcflush = tcflush SIGFE -tcgetattr SIGFE -_tcgetattr = tcgetattr SIGFE -tcgetpgrp SIGFE -_tcgetpgrp = tcgetpgrp SIGFE -tcsendbreak SIGFE -_tcsendbreak = tcsendbreak SIGFE -tcsetattr SIGFE -_tcsetattr = tcsetattr SIGFE -tcsetpgrp SIGFE -_tcsetpgrp = tcsetpgrp SIGFE -tdelete SIGFE -tdestroy NOSIGFE -telldir SIGFE -_telldir = telldir SIGFE -_telldir64 = telldir64 SIGFE -tempnam SIGFE -_tempnam = tempnam SIGFE -tfind NOSIGFE -tgamma NOSIGFE -tgammaf NOSIGFE -time SIGFE -_time = time SIGFE -timegm NOSIGFE -timelocal SIGFE -timer_create SIGFE -timer_delete SIGFE -timer_gettime SIGFE -timer_settime SIGFE -times SIGFE -_times = times SIGFE -timezone SIGFE -tmpfile SIGFE -_tmpfile = tmpfile SIGFE -_tmpfile64 = tmpfile64 SIGFE -tmpnam SIGFE -_tmpnam = tmpnam SIGFE -toascii NOSIGFE -_toascii = toascii NOSIGFE -tolower NOSIGFE -_tolower = tolower NOSIGFE -toupper NOSIGFE -_toupper = toupper NOSIGFE -towctrans NOSIGFE -towlower NOSIGFE -towupper NOSIGFE -trunc NOSIGFE -truncate SIGFE -_truncate = truncate SIGFE -_truncate64 = truncate64 SIGFE -truncf NOSIGFE -tsearch SIGFE -ttyname SIGFE -_ttyname = ttyname SIGFE -ttyname_r SIGFE -ttyslot NOSIGFE -twalk NOSIGFE -tzset SIGFE -_tzset = tzset SIGFE -ualarm SIGFE -_ualarm = ualarm SIGFE -umask NOSIGFE -_umask = umask NOSIGFE -umount SIGFE -_umount = umount SIGFE -uname SIGFE -_uname = uname SIGFE -ungetc SIGFE -_ungetc = ungetc SIGFE -ungetwc SIGFE -unlink SIGFE -_unlink = unlink SIGFE -unlinkat SIGFE -unlockpt NOSIGFE -unsetenv SIGFE -_unsetenv = unsetenv SIGFE -updwtmp SIGFE -updwtmpx SIGFE -usleep SIGFE -_usleep = usleep SIGFE -utime SIGFE -_utime = utime SIGFE -utimensat SIGFE -utimes SIGFE -_utimes = utimes SIGFE -utmpname SIGFE -_utmpname = utmpname SIGFE -utmpxname SIGFE -valloc SIGFE -vasnprintf SIGFE -vasprintf SIGFE -_vasprintf = vasprintf SIGFE -vasprintf_r = _vasprintf_r SIGFE -_vasprintf_r SIGFE -vdprintf SIGFE -verr SIGFE -verrx SIGFE -vfiprintf SIGFE -_vfiprintf = vfiprintf SIGFE -vfork SIGFE -_vfork = vfork SIGFE -vfprintf SIGFE -_vfprintf = vfprintf SIGFE -vfscanf SIGFE -_vfscanf = vfscanf SIGFE -vfscanf_r = _vfscanf_r SIGFE -_vfscanf_r SIGFE -vfwprintf SIGFE -vfwscanf SIGFE -vhangup SIGFE -_vhangup = vhangup SIGFE -vprintf SIGFE -_vprintf = vprintf SIGFE -vscanf SIGFE -_vscanf = vscanf SIGFE -vscanf_r = _vscanf_r SIGFE -_vscanf_r SIGFE -vsnprintf SIGFE -_vsnprintf = vsnprintf SIGFE -vsprintf SIGFE -_vsprintf = vsprintf SIGFE -vsscanf SIGFE -_vsscanf = vsscanf SIGFE -vsscanf_r = _vsscanf_r SIGFE -_vsscanf_r SIGFE -vswprintf SIGFE -vswscanf SIGFE -vsyslog SIGFE -vwarn SIGFE -vwarnx SIGFE -vwprintf SIGFE -vwscanf SIGFE -wait SIGFE -_wait = wait SIGFE -wait3 SIGFE -wait4 SIGFE -waitpid SIGFE -_waitpid = waitpid SIGFE -warn SIGFE -warnx SIGFE -wcpcpy NOSIGFE -wcpncpy NOSIGFE -wcrtomb NOSIGFE -wcscasecmp NOSIGFE -wcscat NOSIGFE -wcschr NOSIGFE -wcscmp NOSIGFE -_wcscmp = wcscmp NOSIGFE -wcscoll NOSIGFE -wcscpy NOSIGFE -wcscspn NOSIGFE -wcsdup NOSIGFE -wcsftime SIGFE -wcslcat NOSIGFE -wcslcpy NOSIGFE -wcslen NOSIGFE -_wcslen = wcslen NOSIGFE -wcsncasecmp NOSIGFE -wcsncat NOSIGFE -wcsncmp NOSIGFE -wcsncpy NOSIGFE -wcsnlen NOSIGFE -wcsnrtombs NOSIGFE -wcspbrk NOSIGFE -wcsrchr NOSIGFE -wcsrtombs NOSIGFE -wcsspn NOSIGFE -wcsstr NOSIGFE -wcstod NOSIGFE -wcstof NOSIGFE -wcstoimax = wcstoll NOSIGFE -wcstok NOSIGFE -wcstol NOSIGFE -wcstoll NOSIGFE -wcstombs NOSIGFE -_wcstombs = wcstombs NOSIGFE -wcstoul NOSIGFE -wcstoull NOSIGFE -wcstoumax = wcstoull NOSIGFE -wcswidth NOSIGFE -wcsxfrm NOSIGFE -wctob NOSIGFE -wctomb NOSIGFE -_wctomb = wctomb NOSIGFE -wctrans NOSIGFE -wctype NOSIGFE -wcwidth NOSIGFE -wmemchr NOSIGFE -wmemcmp NOSIGFE -wmemcpy NOSIGFE -wmemmove NOSIGFE -wmemset NOSIGFE -wordexp NOSIGFE -wordfree NOSIGFE -wprintf SIGFE -write SIGFE -_write = write SIGFE -writev SIGFE -_writev = writev SIGFE -wscanf SIGFE -y0 NOSIGFE -y0f NOSIGFE -y1 NOSIGFE -y1f NOSIGFE -yn NOSIGFE -ynf NOSIGFE -__wrap__ZdaPv NOSIGFE # void operator delete[](void *p) throw() -__wrap__ZdaPvRKSt9nothrow_t NOSIGFE # void operator delete[](void *p, const std::nothrow_t &nt) throw() -__wrap__ZdlPv NOSIGFE # void operator delete(void *p) throw() -__wrap__ZdlPvRKSt9nothrow_t NOSIGFE # void operator delete(void *p, const std::nothrow_t &nt) throw() -__wrap__Znaj NOSIGFE # void *operator new[](std::size_t sz) throw (std::bad_alloc) -__wrap__ZnajRKSt9nothrow_t NOSIGFE # void *operator new[](std::size_t sz, const std::nothrow_t &nt) throw() -__wrap__Znwj NOSIGFE # void *operator new(std::size_t sz) throw (std::bad_alloc) -__wrap__ZnwjRKSt9nothrow_t NOSIGFE # void *operator new(std::size_t sz, const std::nothrow_t &nt) throw() diff --git a/winsup/cygwin/cygwin.sc b/winsup/cygwin/cygwin.sc deleted file mode 100644 index 78e388ed3..000000000 --- a/winsup/cygwin/cygwin.sc +++ /dev/null @@ -1,141 +0,0 @@ -OUTPUT_FORMAT(pei-i386) -SECTIONS -{ - .text __image_base__ + __section_alignment__ : - { - *(.init) - *(.text) - *(SORT(.text$*)) - *(.glue_7t) - *(.glue_7) - ___CTOR_LIST__ = .; __CTOR_LIST__ = .; - LONG (-1); *(SORT(.ctors.*)); *(.ctors); *(.ctor); LONG (0); - ___DTOR_LIST__ = .; __DTOR_LIST__ = .; - LONG (-1); *(SORT(.dtors.*)); *(.dtors); *(.dtor); LONG (0); - *(.fini) - /* ??? Why is .gcc_exc here? */ - *(.gcc_exc) - etext = .; - *(.gcc_except_table) - } - .autoload_text ALIGN(__section_alignment__) : - { - *(.*_autoload_text); - } - /* The Cygwin DLL uses a section to avoid copying certain data - on fork. This used to be named ".data". The linker used - to include this between __data_start__ and __data_end__, but that - breaks building the cygwin32 dll. Instead, we name the section - ".data_cygwin_nocopy" and explictly include it after __data_end__. */ - .data ALIGN(__section_alignment__) : - { - __data_start__ = .; - *(.data) - *(.data2) - *(SORT(.data$*)) - __data_end__ = .; - *(.data_cygwin_nocopy) - } - .rdata ALIGN(__section_alignment__) : - { - *(.rdata) - *(SORT(.rdata$*)) - *(.eh_frame) - } - .pdata ALIGN(__section_alignment__) : - { - *(.pdata) - } - .bss ALIGN(__section_alignment__) : - { - __bss_start__ = .; - *(.bss) - *(COMMON) - __bss_end__ = .; - } - .edata ALIGN(__section_alignment__) : - { - *(.edata) - } - .rsrc BLOCK(__section_alignment__) : - { - *(.rsrc) - *(SORT(.rsrc$*)) - } - .reloc BLOCK(__section_alignment__) : - { - *(.reloc) - } - .cygwin_dll_common ALIGN(__section_alignment__): - { - *(.cygwin_dll_common) - } - .gnu_debuglink_overlay ALIGN(__section_alignment__) (NOLOAD): - { - BYTE(0) /* c */ - BYTE(0) /* y */ - BYTE(0) /* g */ - BYTE(0) /* w */ - BYTE(0) /* i */ - BYTE(0) /* n */ - BYTE(0) /* 1 */ - BYTE(0) /* . */ - BYTE(0) /* d */ - BYTE(0) /* b */ - BYTE(0) /* g */ - BYTE(0) /* \0 */ - LONG(0) /* checksum */ - } - .idata ALIGN(__section_alignment__) : - { - /* This cannot currently be handled with grouped sections. - See pe.em:sort_sections. */ - SORT(*)(.idata$2) - SORT(*)(.idata$3) - /* These zeroes mark the end of the import list. */ - LONG (0); LONG (0); LONG (0); LONG (0); LONG (0); - SORT(*)(.idata$4) - SORT(*)(.idata$5) - SORT(*)(.idata$6) - SORT(*)(.idata$7) - . = ALIGN(16); - __cygheap_start = ABSOLUTE(.); - . = ALIGN(0x10000); - } - .cygheap ALIGN(__section_alignment__) : - { - __cygheap_mid = .; - *(.cygheap) - . = . + (512 * 1024); - . = ALIGN(512 * 1024); - } - __cygheap_end = ABSOLUTE(.); - __cygheap_end1 = __cygheap_mid + SIZEOF(.cygheap); - /DISCARD/ : - { - *(.debug$S) - *(.debug$T) - *(.debug$F) - *(.drectve) - } - .stab ALIGN(__section_alignment__) (NOLOAD) : - { - *(.stab) - } - .stabstr ALIGN(__section_alignment__) (NOLOAD) : - { - *(.stabstr) - } - /* DWARF 1.1 and DWARF 2 */ - .debug_aranges ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_aranges) } - .debug_pubnames ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_pubnames) } - /* DWARF 2 */ - .debug_info ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_info) } - .debug_abbrev ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_abbrev) } - .debug_line ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_line) } - .debug_frame ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_frame) } - .debug_str ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_str) } - .debug_loc ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_loc) } - .debug_macinfo ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_macinfo) } - .debug_ranges ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_ranges) } -} diff --git a/winsup/cygwin/cygwin_version.h b/winsup/cygwin/cygwin_version.h deleted file mode 100644 index 18bdf2416..000000000 --- a/winsup/cygwin/cygwin_version.h +++ /dev/null @@ -1,31 +0,0 @@ -/* cygwin_version.h: shared info for cygwin - - Copyright 2000, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include - -extern "C" { -/* This is for programs that want to access the shared data. */ -class shared_info *cygwin_getshared (void); - -struct cygwin_version_info -{ - unsigned short api_major; - unsigned short api_minor; - unsigned short dll_major; - unsigned short dll_minor; - unsigned short shared_data; - unsigned short mount_registry; - const char *dll_build_date; - char shared_id[sizeof (CYGWIN_VERSION_DLL_IDENTIFIER) + 64]; -}; - -extern cygwin_version_info cygwin_version; -extern const char *cygwin_version_strings; -} diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc deleted file mode 100644 index 6745f096e..000000000 --- a/winsup/cygwin/dcrt0.cc +++ /dev/null @@ -1,1187 +0,0 @@ -/* dcrt0.cc -- essentially the main() for the Cygwin dll - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010 - Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "miscfuncs.h" -#include -#include -#include "glob.h" -#include -#include -#include "environ.h" -#include "sigproc.h" -#include "pinfo.h" -#include "cygerrno.h" -#define NEED_VFORK -#include "perprocess.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "child_info_magic.h" -#include "cygtls.h" -#include "shared_info.h" -#include "cygwin_version.h" -#include "dll_init.h" -#include "heap.h" -#include "tls_pbuf.h" - -#define MAX_AT_FILE_LEVEL 10 - -#define PREMAIN_LEN (sizeof (user_data->premain) / sizeof (user_data->premain[0])) - - -extern "C" void cygwin_exit (int) __attribute__ ((noreturn)); -extern "C" void __sinit (_reent *); - -static int NO_COPY envc; -static char NO_COPY **envp; - -static char title_buf[TITLESIZE + 1]; - -bool NO_COPY jit_debug; - -static void -do_global_dtors () -{ - void (**pfunc) () = user_data->dtors; - if (pfunc) - { - user_data->dtors = NULL; - while (*++pfunc) - (*pfunc) (); - } -} - -static void __stdcall -do_global_ctors (void (**in_pfunc)(), int force) -{ - if (!force && in_forkee) - return; // inherit constructed stuff from parent pid - - /* Run ctors backwards, so skip the first entry and find how many - there are, then run them. */ - - void (**pfunc) () = in_pfunc; - - while (*++pfunc) - ; - while (--pfunc > in_pfunc) - (*pfunc) (); -} - -/* - * Replaces @file in the command line with the contents of the file. - * There may be multiple @file's in a single command line - * A \@file is replaced with @file so that echo \@foo would print - * @foo and not the contents of foo. - */ -static bool __stdcall -insert_file (char *name, char *&cmd) -{ - HANDLE f; - DWORD size; - tmp_pathbuf tp; - - PWCHAR wname = tp.w_get (); - sys_mbstowcs (wname, NT_MAX_PATH, name + 1); - f = CreateFileW (wname, - GENERIC_READ, /* open for reading */ - FILE_SHARE_READ, /* share for reading */ - &sec_none_nih, /* default security */ - OPEN_EXISTING, /* existing file only */ - FILE_ATTRIBUTE_NORMAL,/* normal file */ - NULL); /* no attr. template */ - - if (f == INVALID_HANDLE_VALUE) - { - debug_printf ("couldn't open file '%s', %E", name); - return false; - } - - /* This only supports files up to about 4 billion bytes in - size. I am making the bold assumption that this is big - enough for this feature */ - size = GetFileSize (f, NULL); - if (size == 0xFFFFFFFF) - { - debug_printf ("couldn't get file size for '%s', %E", name); - return false; - } - - int new_size = strlen (cmd) + size + 2; - char *tmp = (char *) malloc (new_size); - if (!tmp) - { - debug_printf ("malloc failed, %E"); - return false; - } - - /* realloc passed as it should */ - DWORD rf_read; - BOOL rf_result; - rf_result = ReadFile (f, tmp, size, &rf_read, NULL); - CloseHandle (f); - if (!rf_result || (rf_read != size)) - { - debug_printf ("ReadFile failed, %E"); - return false; - } - - tmp[size++] = ' '; - strcpy (tmp + size, cmd); - cmd = tmp; - return true; -} - -static inline int -isquote (char c) -{ - char ch = c; - return ch == '"' || ch == '\''; -} - -/* Step over a run of characters delimited by quotes */ -static /*__inline*/ char * -quoted (char *cmd, int winshell) -{ - char *p; - char quote = *cmd; - - if (!winshell) - { - char *p; - strcpy (cmd, cmd + 1); - if (*(p = strechr (cmd, quote))) - strcpy (p, p + 1); - return p; - } - - const char *s = quote == '\'' ? "'" : "\\\""; - /* This must have been run from a Windows shell, so preserve - quotes for globify to play with later. */ - while (*cmd && *++cmd) - if ((p = strpbrk (cmd, s)) == NULL) - { - cmd = strchr (cmd, '\0'); // no closing quote - break; - } - else if (*p == '\\') - cmd = ++p; - else if (quote == '"' && p[1] == '"') - { - *p = '\\'; - cmd = ++p; // a quoted quote - } - else - { - cmd = p + 1; // point to after end - break; - } - return cmd; -} - -/* Perform a glob on word if it contains wildcard characters. - Also quote every character between quotes to force glob to - treat the characters literally. */ -static int __stdcall -globify (char *word, char **&argv, int &argc, int &argvlen) -{ - if (*word != '~' && strpbrk (word, "?*[\"\'(){}") == NULL) - return 0; - - int n = 0; - char *p, *s; - int dos_spec = isdrive (word); - if (!dos_spec && isquote (*word) && word[1] && word[2]) - dos_spec = isdrive (word + 1); - - /* We'll need more space if there are quoting characters in - word. If that is the case, doubling the size of the - string should provide more than enough space. */ - if (strpbrk (word, "'\"")) - n = strlen (word); - char pattern[strlen (word) + ((dos_spec + 1) * n) + 1]; - - /* Fill pattern with characters from word, quoting any - characters found within quotes. */ - for (p = pattern, s = word; *s != '\000'; s++, p++) - if (!isquote (*s)) - { - if (dos_spec && *s == '\\') - *p++ = '\\'; - *p = *s; - } - else - { - char quote = *s; - while (*++s && *s != quote) - { - if (dos_spec || *s != '\\') - /* nothing */; - else if (s[1] == quote || s[1] == '\\') - s++; - *p++ = '\\'; - size_t cnt = isascii (*s) ? 1 : mbtowc (NULL, s, MB_CUR_MAX); - if (cnt <= 1 || cnt == (size_t)-1) - *p++ = *s; - else - { - --s; - while (cnt-- > 0) - *p++ = *++s; - } - } - if (*s == quote) - p--; - if (*s == '\0') - break; - } - - *p = '\0'; - - glob_t gl; - gl.gl_offs = 0; - - /* Attempt to match the argument. Return just word (minus quoting) if no match. */ - if (glob (pattern, GLOB_TILDE | GLOB_NOCHECK | GLOB_BRACE | GLOB_QUOTE, NULL, &gl) || !gl.gl_pathc) - return 0; - - /* Allocate enough space in argv for the matched filenames. */ - n = argc; - if ((argc += gl.gl_pathc) > argvlen) - { - argvlen = argc + 10; - argv = (char **) realloc (argv, (1 + argvlen) * sizeof (argv[0])); - } - - /* Copy the matched filenames to argv. */ - char **gv = gl.gl_pathv; - char **av = argv + n; - while (*gv) - { - debug_printf ("argv[%d] = '%s'", n++, *gv); - *av++ = *gv++; - } - - /* Clean up after glob. */ - free (gl.gl_pathv); - return 1; -} - -/* Build argv, argc from string passed from Windows. */ - -static void __stdcall -build_argv (char *cmd, char **&argv, int &argc, int winshell) -{ - int argvlen = 0; - int nesting = 0; // monitor "nesting" from insert_file - - argc = 0; - argvlen = 0; - argv = NULL; - - /* Scan command line until there is nothing left. */ - while (*cmd) - { - /* Ignore spaces */ - if (issep (*cmd)) - { - cmd++; - continue; - } - - /* Found the beginning of an argument. */ - char *word = cmd; - char *sawquote = NULL; - while (*cmd) - { - if (*cmd != '"' && (!winshell || *cmd != '\'')) - cmd++; // Skip over this character - else - /* Skip over characters until the closing quote */ - { - sawquote = cmd; - cmd = quoted (cmd, winshell && argc > 0); - } - if (issep (*cmd)) // End of argument if space - break; - } - if (*cmd) - *cmd++ = '\0'; // Terminate `word' - - /* Possibly look for @file construction assuming that this isn't - the very first argument and the @ wasn't quoted */ - if (argc && sawquote != word && *word == '@') - { - if (++nesting > MAX_AT_FILE_LEVEL) - api_fatal ("Too many levels of nesting for %s", word); - if (insert_file (word, cmd)) - continue; // There's new stuff in cmd now - } - - /* See if we need to allocate more space for argv */ - if (argc >= argvlen) - { - argvlen = argc + 10; - argv = (char **) realloc (argv, (1 + argvlen) * sizeof (argv[0])); - } - - /* Add word to argv file after (optional) wildcard expansion. */ - if (!winshell || !argc || !globify (word, argv, argc, argvlen)) - { - debug_printf ("argv[%d] = '%s'", argc, word); - argv[argc++] = word; - } - } - - argv[argc] = NULL; - - debug_printf ("argc %d", argc); -} - -/* sanity and sync check */ -void __stdcall -check_sanity_and_sync (per_process *p) -{ - /* Sanity check to make sure developers didn't change the per_process */ - /* struct without updating SIZEOF_PER_PROCESS [it makes them think twice */ - /* about changing it]. */ - if (sizeof (per_process) != SIZEOF_PER_PROCESS) - api_fatal ("per_process sanity check failed"); - - /* Make sure that the app and the dll are in sync. */ - - /* Complain if older than last incompatible change */ - if (p->dll_major < CYGWIN_VERSION_DLL_EPOCH) - api_fatal ("cygwin DLL and APP are out of sync -- DLL version mismatch %d < %d", - p->dll_major, CYGWIN_VERSION_DLL_EPOCH); - - /* magic_biscuit != 0 if using the old style version numbering scheme. */ - if (p->magic_biscuit != SIZEOF_PER_PROCESS) - api_fatal ("Incompatible cygwin .dll -- incompatible per_process info %d != %d", - p->magic_biscuit, SIZEOF_PER_PROCESS); - - /* Complain if incompatible API changes made */ - if (p->api_major > cygwin_version.api_major) - api_fatal ("cygwin DLL and APP are out of sync -- API version mismatch %d > %d", - p->api_major, cygwin_version.api_major); - - /* This is a kludge to work around a version of _cygwin_common_crt0 - which overwrote the cxx_malloc field with the local DLL copy. - Hilarity ensues if the DLL is not loaded while the process - is forking. */ - __cygwin_user_data.cxx_malloc = &default_cygwin_cxx_malloc; -} - -child_info NO_COPY *child_proc_info = NULL; - -#define CYGWIN_GUARD (PAGE_EXECUTE_READWRITE | PAGE_GUARD) - -void -child_info_fork::alloc_stack_hard_way (volatile char *b) -{ - void *new_stack_pointer; - MEMORY_BASIC_INFORMATION m; - void *newbase; - int newlen; - bool guard; - - if (!VirtualQuery ((LPCVOID) &b, &m, sizeof m)) - api_fatal ("fork: couldn't get stack info, %E"); - - LPBYTE curbot = (LPBYTE) m.BaseAddress + m.RegionSize; - - if (stacktop > (LPBYTE) m.AllocationBase && stacktop < curbot) - { - newbase = curbot; - newlen = (LPBYTE) stackbottom - (LPBYTE) curbot; - guard = false; - } - else - { - newbase = (LPBYTE) stacktop - (128 * 1024); - newlen = (LPBYTE) stackbottom - (LPBYTE) newbase; - guard = true; - } - - if (!VirtualAlloc (newbase, newlen, MEM_RESERVE, PAGE_NOACCESS)) - api_fatal ("fork: can't reserve memory for stack %p - %p, %E", - stacktop, stackbottom); - new_stack_pointer = (void *) ((LPBYTE) stackbottom - (stacksize += 8192)); - if (!VirtualAlloc (new_stack_pointer, stacksize, MEM_COMMIT, - PAGE_EXECUTE_READWRITE)) - api_fatal ("fork: can't commit memory for stack %p(%d), %E", - new_stack_pointer, stacksize); - if (!VirtualQuery ((LPCVOID) new_stack_pointer, &m, sizeof m)) - api_fatal ("fork: couldn't get new stack info, %E"); - - if (guard) - { - m.BaseAddress = (LPBYTE) m.BaseAddress - 1; - if (!VirtualAlloc ((LPVOID) m.BaseAddress, 1, MEM_COMMIT, - CYGWIN_GUARD)) - api_fatal ("fork: couldn't allocate new stack guard page %p, %E", - m.BaseAddress); - } - if (!VirtualQuery ((LPCVOID) m.BaseAddress, &m, sizeof m)) - api_fatal ("fork: couldn't get new stack info, %E"); - stacktop = m.BaseAddress; - b[0] = '\0'; -} - -void *getstack (void *) __attribute__ ((noinline)); -volatile char * -getstack (volatile char * volatile p) -{ - *p ^= 1; - *p ^= 1; - return p - 4096; -} - -/* extend the stack prior to fork longjmp */ - -void -child_info_fork::alloc_stack () -{ - volatile char * volatile esp; - __asm__ volatile ("movl %%esp,%0": "=r" (esp)); - if (_tlsbase != stackbottom) - alloc_stack_hard_way (esp); - else - { - char *st = (char *) stacktop - 4096; - while (_tlstop >= st) - esp = getstack (esp); - stacksize = 0; - } -} - -extern "C" void -break_here () -{ - static int NO_COPY sent_break; - if (!sent_break++) - DebugBreak (); - debug_printf ("break here"); -} - -static void -initial_env () -{ - if (GetEnvironmentVariableA ("CYGWIN_TESTING", NULL, 0)) - _cygwin_testing = 1; - -#ifdef DEBUGGING - char buf[NT_MAX_PATH]; - DWORD len; - - if (GetEnvironmentVariableA ("CYGWIN_SLEEP", buf, sizeof (buf) - 1)) - { - DWORD ms = atoi (buf); - console_printf ("Sleeping %d, pid %u %P\n", ms, GetCurrentProcessId ()); - Sleep (ms); - if (!strace.active () && !dynamically_loaded) - strace.hello (); - } - if (GetEnvironmentVariableA ("CYGWIN_DEBUG", buf, sizeof (buf) - 1)) - { - char buf1[NT_MAX_PATH]; - len = GetModuleFileName (NULL, buf1, NT_MAX_PATH); - strlwr (buf1); - strlwr (buf); - char *p = strpbrk (buf, ":="); - if (!p) - p = (char *) "gdb.exe -nw"; - else - *p++ = '\0'; - if (strstr (buf1, buf)) - { - error_start_init (p); - jit_debug = true; - try_to_debug (); - console_printf ("*** Sending Break. gdb may issue spurious SIGTRAP message.\n"); - break_here (); - } - } -#endif - -} - -child_info * -get_cygwin_startup_info () -{ - STARTUPINFO si; - - GetStartupInfo (&si); - child_info *res = (child_info *) si.lpReserved2; - - if (si.cbReserved2 < EXEC_MAGIC_SIZE || !res - || res->intro != PROC_MAGIC_GENERIC || res->magic != CHILD_INFO_MAGIC) - res = NULL; - else - { - if ((res->intro & OPROC_MAGIC_MASK) == OPROC_MAGIC_GENERIC) - multiple_cygwin_problem ("proc intro", res->intro, 0); - else if (res->cygheap != (void *) &_cygheap_start) - multiple_cygwin_problem ("cygheap base", (DWORD) res->cygheap, - (DWORD) &_cygheap_start); - - unsigned should_be_cb = 0; - switch (res->type) - { - case _PROC_FORK: - in_forkee = true; - should_be_cb = sizeof (child_info_fork); - /* fall through */; - case _PROC_SPAWN: - case _PROC_EXEC: - if (!should_be_cb) - should_be_cb = sizeof (child_info_spawn); - if (should_be_cb != res->cb) - multiple_cygwin_problem ("proc size", res->cb, should_be_cb); - else if (sizeof (fhandler_union) != res->fhandler_union_cb) - multiple_cygwin_problem ("fhandler size", res->fhandler_union_cb, sizeof (fhandler_union)); - if (res->isstraced ()) - { - res->ready (false); - for (unsigned i = 0; !being_debugged () && i < 10000; i++) - low_priority_sleep (0); - strace.hello (); - } - break; - default: - system_printf ("unknown exec type %d", res->type); - /* intentionally fall through */ - case _PROC_WHOOPS: - res = NULL; - break; - } - } - - return res; -} - -#define dll_data_start &_data_start__ -#define dll_data_end &_data_end__ -#define dll_bss_start &_bss_start__ -#define dll_bss_end &_bss_end__ - -void -child_info_fork::handle_fork () -{ - cygheap_fixup_in_child (false); - memory_init (false); - myself.thisproc (NULL); - myself->uid = cygheap->user.real_uid; - myself->gid = cygheap->user.real_gid; - - child_copy (parent, false, - "dll data", dll_data_start, dll_data_end, - "dll bss", dll_bss_start, dll_bss_end, - "user heap", cygheap->user_heap.base, cygheap->user_heap.ptr, - NULL); - /* step 2 now that the dll has its heap filled in, we can fill in the - user's data and bss since user_data is now filled out. */ - child_copy (parent, false, - "data", user_data->data_start, user_data->data_end, - "bss", user_data->bss_start, user_data->bss_end, - NULL); - - if (fixup_mmaps_after_fork (parent)) - api_fatal ("recreate_mmaps_after_fork_failed"); -} - -void -child_info_spawn::handle_spawn () -{ - extern void fixup_lockf_after_exec (); - HANDLE h; - cygheap_fixup_in_child (true); - memory_init (false); - if (!moreinfo->myself_pinfo || - !DuplicateHandle (GetCurrentProcess (), moreinfo->myself_pinfo, - GetCurrentProcess (), &h, 0, - FALSE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE)) - h = NULL; - myself.thisproc (h); - __argc = moreinfo->argc; - __argv = moreinfo->argv; - envp = moreinfo->envp; - envc = moreinfo->envc; - if (!dynamically_loaded) - cygheap->fdtab.fixup_after_exec (); - if (__stdin >= 0) - cygheap->fdtab.move_fd (__stdin, 0); - if (__stdout >= 0) - cygheap->fdtab.move_fd (__stdout, 1); - cygheap->user.groups.clear_supp (); - - ready (true); - - /* Need to do this after debug_fixup_after_fork_exec or DEBUGGING handling of - handles might get confused. */ - CloseHandle (child_proc_info->parent); - child_proc_info->parent = NULL; - - signal_fixup_after_exec (); - if (moreinfo->old_title) - { - old_title = strcpy (title_buf, moreinfo->old_title); - cfree (moreinfo->old_title); - } - fixup_lockf_after_exec (); -} - -#if 0 -/* Setting the TS-aware flag in the application's PE header is sufficient. - Just keep this in as a reminder. */ - -static DEP_SYSTEM_POLICY_TYPE dep_system_policy = (DEP_SYSTEM_POLICY_TYPE) -1; - -static void -disable_dep () -{ - DWORD ppolicy; - BOOL perm; - - if (dep_system_policy < 0) - { - dep_system_policy = GetSystemDEPPolicy (); - debug_printf ("DEP System Policy: %d", (int) dep_system_policy); - } - if (dep_system_policy < OptIn) - return; - if (!GetProcessDEPPolicy (GetCurrentProcess (), &ppolicy, &perm)) - { - debug_printf ("GetProcessDEPPolicy: %E"); - return; - } - debug_printf ("DEP Process Policy: %d (permanent = %d)", ppolicy, perm); - if (ppolicy > 0 && !perm && !SetProcessDEPPolicy (0)) - debug_printf ("SetProcessDEPPolicy: %E"); -} -#endif - -void __stdcall -dll_crt0_0 () -{ - init_global_security (); - initial_env (); - - SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); - - /* Initialize signal processing here, early, in the hopes that the creation - of a thread early in the process will cause more predictability in memory - layout for the main thread. */ - if (!dynamically_loaded) - sigproc_init (); - - lock_process::init (); - _impure_ptr = _GLOBAL_REENT; - _impure_ptr->_stdin = &_impure_ptr->__sf[0]; - _impure_ptr->_stdout = &_impure_ptr->__sf[1]; - _impure_ptr->_stderr = &_impure_ptr->__sf[2]; - _impure_ptr->_current_locale = "C"; - user_data->impure_ptr = _impure_ptr; - user_data->impure_ptr_ptr = &_impure_ptr; - - DuplicateHandle (GetCurrentProcess (), GetCurrentThread (), - GetCurrentProcess (), &hMainThread, - 0, false, DUPLICATE_SAME_ACCESS); - - OpenProcessToken (GetCurrentProcess (), MAXIMUM_ALLOWED, &hProcToken); - set_cygwin_privileges (hProcToken); - - device::init (); - do_global_ctors (&__CTOR_LIST__, 1); - cygthread::init (); - - child_proc_info = get_cygwin_startup_info (); - if (!child_proc_info) - memory_init (true); - else - { - cygwin_user_h = child_proc_info->user_h; - switch (child_proc_info->type) - { - case _PROC_FORK: - fork_info->handle_fork (); - break; - case _PROC_SPAWN: - case _PROC_EXEC: - spawn_info->handle_spawn (); - break; - } - } - - user_data->threadinterface->Init (); - - _cygtls::init (); - - /* Initialize events */ - events_init (); - tty_list::init_session (); - -#if 0 - /* Setting the TS-aware flag in the application's PE header is sufficient. - Just keep this in as a reminder. */ - - /* The disable_dep function disables DEP for all Cygwin processes if - the process runs on a Windows Server 2008 with Terminal Services - installed. This combination (TS+DEP) breaks *some* Cygwin - applications. The Terminal Service specific DLL tsappcmp.dll - changes the page protection of some pages in the application's text - segment from PAGE_EXECUTE_WRITECOPY to PAGE_WRITECOPY for no - apparent reason. This occurs before any Cygwin or applicaton code - had a chance to run. MS has no explanation for this so far, but is - rather busy trying to avoid giving support for this problem (as of - 2008-11-11). - - Unfortunately disabling DEP seems to have a not negligible - performance hit. In the long run, either MS has to fix their - problem, or we have to find a better workaround, if any exists. - Idle idea: Adding EXECUTE protection to all text segment pages? */ - if (wincap.ts_has_dep_problem ()) - disable_dep (); -#endif - - debug_printf ("finished dll_crt0_0 initialization"); -} - -/* Take over from libc's crt0.o and start the application. Note the - various special cases when Cygwin DLL is being runtime loaded (as - opposed to being link-time loaded by Cygwin apps) from a non - cygwin app via LoadLibrary. */ -void -dll_crt0_1 (void *) -{ - extern void initial_setlocale (); - - if (dynamically_loaded) - sigproc_init (); - check_sanity_and_sync (user_data); - - /* Initialize malloc and then call user_shared_initialize since it relies - on a functioning malloc and it's possible that the user's program may - have overridden malloc. We only know about that at this stage, - unfortunately. */ - malloc_init (); - user_shared_initialize (); - -#ifdef CGF - int i = 0; - const int n = 2 * 1024 * 1024; - while (i--) - small_printf ("cmalloc returns %p\n", cmalloc (HEAP_STR, n)); -#endif - - ProtectHandle (hMainThread); - - cygheap->cwd.init (); - - /* Initialize pthread mainthread when not forked and it is safe to call new, - otherwise it is reinitalized in fixup_after_fork */ - if (!in_forkee) - pthread::init_mainthread (); - -#ifdef DEBUGGING - strace.microseconds (); -#endif - - create_signal_arrived (); /* FIXME: move into wait_sig? */ - - /* Initialize debug muto, if DLL is built with --enable-debugging. - Need to do this before any helper threads start. */ - debug_init (); - -#ifdef NEWVFORK - cygheap->fdtab.vfork_child_fixup (); - main_vfork = vfork_storage.create (); -#endif - - cygbench ("pre-forkee"); - if (in_forkee) - { - /* If we've played with the stack, stacksize != 0. That means that - fork() was invoked from other than the main thread. Make sure that - frame pointer is referencing the new stack so that the OS knows what - to do when it needs to increase the size of the stack. - - NOTE: Don't do anything that involves the stack until you've completed - this step. */ - if (fork_info->stacksize) - { - _tlsbase = (char *) fork_info->stackbottom; - _tlstop = (char *) fork_info->stacktop; - _my_tls.init_exception_handler (_cygtls::handle_exceptions); - } - - longjmp (fork_info->jmp, true); - } - -#ifdef DEBUGGING - { - extern void fork_init (); - fork_init (); - } -#endif - pinfo_init (envp, envc); - - if (!old_title && GetConsoleTitle (title_buf, TITLESIZE)) - old_title = title_buf; - - /* Allocate cygheap->fdtab */ - dtable_init (); - - uinfo_init (); /* initialize user info */ - - wait_for_sigthread (); - extern DWORD threadfunc_ix; - if (!threadfunc_ix) - system_printf ("internal error: couldn't determine location of thread function on stack. Expect signal problems."); - - /* Connect to tty. */ - tty::init_session (); - - /* Set internal locale to the environment settings. */ - initial_setlocale (); - - if (!__argc) - { - PWCHAR wline = GetCommandLineW (); - size_t size = sys_wcstombs (NULL, 0, wline); - char *line = (char *) alloca (size); - sys_wcstombs (line, size, wline); - - /* Scan the command line and build argv. Expand wildcards if not - called from another cygwin process. */ - build_argv (line, __argv, __argc, - NOTSTATE (myself, PID_CYGPARENT) && allow_glob); - - /* Convert argv[0] to posix rules if it's currently blatantly - win32 style. */ - if ((strchr (__argv[0], ':')) || (strchr (__argv[0], '\\'))) - { - char *new_argv0 = (char *) malloc (NT_MAX_PATH); - cygwin_conv_path (CCP_WIN_A_TO_POSIX | CCP_RELATIVE, __argv[0], - new_argv0, NT_MAX_PATH); - __argv[0] = (char *) realloc (new_argv0, strlen (new_argv0) + 1); - } - } - - __argc_safe = __argc; - if (user_data->premain[0]) - for (unsigned int i = 0; i < PREMAIN_LEN / 2; i++) - user_data->premain[i] (__argc, __argv, user_data); - - /* Set up standard fds in file descriptor table. */ - cygheap->fdtab.stdio_init (); - - /* Set up __progname for getopt error call. */ - if (__argv[0] && (__progname = strrchr (__argv[0], '/'))) - ++__progname; - else - __progname = __argv[0]; - if (__progname) - { - char *cp = strchr (__progname, '\0') - 4; - if (cp > __progname && ascii_strcasematch (cp, ".exe")) - *cp = '\0'; - } - - /* Set new console title if appropriate. */ - - if (display_title && !dynamically_loaded) - { - char *cp = __progname; - if (strip_title_path) - for (char *ptr = cp; *ptr && *ptr != ' '; ptr++) - if (isdirsep (*ptr)) - cp = ptr + 1; - set_console_title (cp); - } - - cygwin_finished_initializing = true; - /* Call init of loaded dlls. */ - dlls.init (); - - /* Execute any specified "premain" functions */ - if (user_data->premain[PREMAIN_LEN / 2]) - for (unsigned int i = PREMAIN_LEN / 2; i < PREMAIN_LEN; i++) - user_data->premain[i] (__argc, __argv, user_data); - - debug_printf ("user_data->main %p", user_data->main); - - if (dynamically_loaded) - { - set_errno (0); - return; - } - - /* Disable case-insensitive globbing */ - ignore_case_with_glob = false; - - set_errno (0); - - MALLOC_CHECK; - cygbench (__progname); - - /* Flush signals and ensure that signal thread is up and running. Can't - do this for noncygwin case since the signal thread is blocked due to - LoadLibrary serialization. */ - ld_preload (); - /* Per POSIX set the default application locale back to "C". */ - _setlocale_r (_REENT, LC_CTYPE, "C"); - if (user_data->main) - cygwin_exit (user_data->main (__argc, __argv, *user_data->envptr)); - __asm__ (" \n\ - .global __cygwin_exit_return \n\ -__cygwin_exit_return: \n\ -"); -} - -extern "C" void __stdcall -_dll_crt0 () -{ - main_environ = user_data->envptr; - if (in_forkee) - { - fork_info->alloc_stack (); - _main_tls = &_my_tls; - } - else - { - _main_tls = &_my_tls; - __sinit (_impure_ptr); - } - - _main_tls->call ((DWORD (*) (void *, void *)) dll_crt0_1, NULL); -} - -void -dll_crt0 (per_process *uptr) -{ - /* Set the local copy of the pointer into the user space. */ - if (!in_forkee && uptr && uptr != user_data) - { - memcpy (user_data, uptr, per_process_overwrite); - *(user_data->impure_ptr_ptr) = _GLOBAL_REENT; - } - _dll_crt0 (); -} - -/* This must be called by anyone who uses LoadLibrary to load cygwin1.dll. - You must have CYGTLS_PADSIZE bytes reserved at the bottom of the stack - calling this function, and that storage must not be overwritten until you - unload cygwin1.dll, as it is used for _my_tls. It is best to load - cygwin1.dll before spawning any additional threads in your process. - - See winsup/testsuite/cygload for an example of how to use cygwin1.dll - from MSVC and non-cygwin MinGW applications. */ -extern "C" void -cygwin_dll_init () -{ - static char **envp; - static int _fmode; - - user_data->magic_biscuit = sizeof (per_process); - - user_data->envptr = &envp; - user_data->fmode_ptr = &_fmode; - - _dll_crt0 (); -} - -extern "C" void -__main (void) -{ - /* Ordering is critical here. DLL ctors have already been - run as they were being loaded, so we should stack the - queued call to DLL dtors now. */ - atexit (dll_global_dtors); - do_global_ctors (user_data->ctors, false); - /* Now we have run global ctors, register their dtors. */ - atexit (do_global_dtors); - /* At exit, global dtors will run first, so the app can still - use shared library functions while terminating; then the - DLLs will be destroyed; finally newlib will shut down stdio - and terminate itself. */ -} - -void __stdcall -do_exit (int status) -{ - syscall_printf ("do_exit (%d), exit_state %d", status, exit_state); - -#ifdef NEWVFORK - vfork_save *vf = vfork_storage.val (); - if (vf != NULL && vf->pid < 0) - { - exit_state = ES_NOT_EXITING; - vf->restore_exit (status); - } -#endif - - lock_process until_exit (true); - - if (exit_state < ES_EVENTS_TERMINATE) - { - exit_state = ES_EVENTS_TERMINATE; - events_terminate (); - } - - UINT n = (UINT) status; - if (exit_state < ES_THREADTERM) - { - exit_state = ES_THREADTERM; - cygthread::terminate (); - } - - if (exit_state < ES_SIGNAL) - { - exit_state = ES_SIGNAL; - signal (SIGCHLD, SIG_IGN); - signal (SIGHUP, SIG_IGN); - signal (SIGINT, SIG_IGN); - signal (SIGQUIT, SIG_IGN); - } - - if (exit_state < ES_CLOSEALL) - { - exit_state = ES_CLOSEALL; - close_all_files (); - } - - myself->stopsig = 0; - - if (exit_state < ES_HUP_PGRP) - { - exit_state = ES_HUP_PGRP; - /* Kill orphaned children on group leader exit */ - if (myself->has_pgid_children && myself->pid == myself->pgid) - { - siginfo_t si = {0}; - si.si_signo = -SIGHUP; - si.si_code = SI_KERNEL; - sigproc_printf ("%d == pgrp %d, send SIG{HUP,CONT} to stopped children", - myself->pid, myself->pgid); - kill_pgrp (myself->pgid, si); - } - } - - if (exit_state < ES_HUP_SID) - { - exit_state = ES_HUP_SID; - /* Kill the foreground process group on session leader exit */ - if (getpgrp () > 0 && myself->pid == myself->sid && real_tty_attached (myself)) - { - tty *tp = cygwin_shared->tty[myself->ctty]; - sigproc_printf ("%d == sid %d, send SIGHUP to children", - myself->pid, myself->sid); - - /* CGF FIXME: This can't be right. */ - if (tp->getsid () == myself->sid) - tp->kill_pgrp (SIGHUP); - } - - } - - if (exit_state < ES_TITLE) - { - exit_state = ES_TITLE; - /* restore console title */ - if (old_title && display_title) - set_console_title (old_title); - } - - if (exit_state < ES_TTY_TERMINATE) - { - exit_state = ES_TTY_TERMINATE; - cygwin_shared->tty.terminate (); - } - - myself.exit (n); -} - -extern "C" int -cygwin_atexit (void (*fn) (void)) -{ - int res; - dll *d = dlls.find ((void *) _my_tls.retaddr ()); - res = d ? __cxa_atexit ((void (*) (void *)) fn, NULL, d) : atexit (fn); - return res; -} - -extern "C" void -cygwin_exit (int n) -{ - exit (n); -} - -extern "C" void -_exit (int n) -{ - do_exit (((DWORD) n & 0xff) << 8); -} - -extern "C" void -__api_fatal (const char *fmt, ...) -{ - char buf[4096]; - va_list ap; - - va_start (ap, fmt); - int n = __small_sprintf (buf, "%P: *** fatal error - "); - __small_vsprintf (buf + n, fmt, ap); - va_end (ap); - strace.prntf (_STRACE_SYSTEM, NULL, "%s", buf); - -#ifdef DEBUGGING - try_to_debug (); -#endif - myself.exit (__api_fatal_exit_val); -} - -void -multiple_cygwin_problem (const char *what, unsigned magic_version, unsigned version) -{ - if (_cygwin_testing && (strstr (what, "proc") || strstr (what, "cygheap"))) - { - child_proc_info->type = _PROC_WHOOPS; - return; - } - - if (GetEnvironmentVariableA ("CYGWIN_MISMATCH_OK", NULL, 0)) - return; - - if (CYGWIN_VERSION_MAGIC_VERSION (magic_version) == version) - system_printf ("%s magic number mismatch detected - %p/%p", what, magic_version, version); - else - api_fatal ("%s mismatch detected - %p/%p.\n\ -This problem is probably due to using incompatible versions of the cygwin DLL.\n\ -Search for cygwin1.dll using the Windows Start->Find/Search facility\n\ -and delete all but the most recent version. The most recent version *should*\n\ -reside in x:\\cygwin\\bin, where 'x' is the drive on which you have\n\ -installed the cygwin distribution. Rebooting is also suggested if you\n\ -are unable to find another cygwin DLL.", - what, magic_version, version); -} - -#ifdef DEBUGGING -void __stdcall -cygbench (const char *s) -{ - if (GetEnvironmentVariableA ("CYGWIN_BENCH", NULL, 0)) - small_printf ("%05d ***** %s : %10d\n", GetCurrentProcessId (), s, strace.microseconds ()); -} -#endif diff --git a/winsup/cygwin/debug.cc b/winsup/cygwin/debug.cc deleted file mode 100644 index bea256cae..000000000 --- a/winsup/cygwin/debug.cc +++ /dev/null @@ -1,232 +0,0 @@ -/* debug.cc - - Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009 - Red Hat, Inc. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "cygerrno.h" -#ifdef DEBUGGING -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#endif - -#undef CloseHandle - -#ifdef DEBUGGING -/* Here lies extra debugging routines which help track down internal - Cygwin problems when compiled with -DDEBUGGING . */ -#define NFREEH (sizeof (cygheap->debug.freeh) / sizeof (cygheap->debug.freeh[0])) - -class lock_debug -{ - static muto locker; - public: - lock_debug () - { - locker.acquire (INFINITE); - } - void unlock () - { - locker.release (); - } - ~lock_debug () {unlock ();} - friend void debug_init (); -}; - -muto NO_COPY lock_debug::locker; - -static bool __stdcall mark_closed (const char *, int, HANDLE, const char *, bool); - -void -debug_init () -{ - lock_debug::locker.init ("debug_lock"); -} - -/* Find a registered handle in the linked list of handles. */ -static handle_list * __stdcall -find_handle (HANDLE h) -{ - handle_list *hl; - for (hl = &cygheap->debug.starth; hl->next != NULL; hl = hl->next) - if (hl->next->h == h) - goto out; - hl = NULL; - -out: - return hl; -} - -void -verify_handle (const char *func, int ln, HANDLE h) -{ - lock_debug here; - handle_list *hl = find_handle (h); - if (!hl) - return; - system_printf ("%s:%d - multiple attempts to add handle %p", func, ln, h); - - system_printf (" previously allocated by %s:%d(%s<%p>) winpid %d", - hl->func, hl->ln, hl->name, hl->h, hl->pid); -} - -void -setclexec (HANDLE oh, HANDLE nh, bool not_inheriting) -{ - lock_debug here; - handle_list *hl = find_handle (oh); - if (hl) - { - hl = hl->next; - hl->inherited = !not_inheriting; - hl->h = nh; - } -} - -/* Create a new handle record */ -static handle_list * __stdcall -newh () -{ - handle_list *hl; - - for (hl = cygheap->debug.freeh; hl < cygheap->debug.freeh + NFREEH; hl++) - if (hl->name == NULL) - return hl; - - return NULL; -} - -void __stdcall -modify_handle (const char *func, int ln, HANDLE h, const char *name, bool inh) -{ - lock_debug here; - handle_list *hl = find_handle (h); - if (!hl) - { - system_printf ("%s:%d handle %s<%p> not found", func, ln, name, h); - return; - } - hl->next->inherited = inh; - debug_printf ("%s:%d set handle %s<%p> inheritance flag to %d", func, ln, - name, h, inh); -} - -/* Add a handle to the linked list of known handles. */ -void __stdcall -add_handle (const char *func, int ln, HANDLE h, const char *name, bool inh) -{ - handle_list *hl; - - if (!cygheap) - return; - - lock_debug here; - if ((hl = find_handle (h))) - { - hl = hl->next; - if (hl->name == name && hl->func == func && hl->ln == ln) - return; - system_printf ("%s:%d - multiple attempts to add handle %s<%p>", func, - ln, name, h); - system_printf (" previously allocated by %s:%d(%s<%p>) winpid %d", - hl->func, hl->ln, hl->name, hl->h, hl->pid); - return; - } - - if ((hl = newh ()) == NULL) - { - here.unlock (); - debug_printf ("couldn't allocate memory for %s(%d): %s(%p)", - func, ln, name, h); - return; - } - hl->h = h; - hl->name = name; - hl->func = func; - hl->ln = ln; - hl->inherited = inh; - hl->pid = GetCurrentProcessId (); - hl->next = cygheap->debug.starth.next; - cygheap->debug.starth.next = hl; - SetHandleInformation (h, HANDLE_FLAG_PROTECT_FROM_CLOSE, HANDLE_FLAG_PROTECT_FROM_CLOSE); - debug_printf ("protecting handle '%s'(%p), inherited flag %d", hl->name, hl->h, hl->inherited); -} - -static void __stdcall -delete_handle (handle_list *hl) -{ - handle_list *hnuke = hl->next; - debug_printf ("nuking handle '%s' (%p)", hnuke->name, hnuke->h); - hl->next = hnuke->next; - memset (hnuke, 0, sizeof (*hnuke)); -} - -void -debug_fixup_after_fork_exec () -{ - /* No lock needed at this point */ - handle_list *hl; - for (hl = &cygheap->debug.starth; hl->next != NULL; /* nothing */) - if (hl->next->inherited) - hl = hl->next; - else - delete_handle (hl); // removes hl->next -} - -static bool __stdcall -mark_closed (const char *func, int ln, HANDLE h, const char *name, bool force) -{ - handle_list *hl; - - if (!cygheap) - return true; - - if ((hl = find_handle (h)) && !force) - { - hl = hl->next; - system_printf ("attempt to close protected handle %s:%d(%s<%p>) winpid %d", - hl->func, hl->ln, hl->name, hl->h, hl->pid); - system_printf (" by %s:%d(%s<%p>)", func, ln, name, h); - return false; - } - - handle_list *hln; - if (hl && (hln = hl->next) && strcmp (name, hln->name) != 0) - { - system_printf ("closing protected handle %s:%d(%s<%p>)", - hln->func, hln->ln, hln->name, hln->h); - system_printf (" by %s:%d(%s<%p>)", func, ln, name, h); - } - - if (hl) - delete_handle (hl); - - return true; -} - -/* Close a known handle. Complain if !force and closing a known handle or - if the name of the handle being closed does not match the registered name. */ -bool __stdcall -close_handle (const char *func, int ln, HANDLE h, const char *name, bool force) -{ - bool ret; - - lock_debug here; - if (!mark_closed (func, ln, h, name, force)) - return false; - - SetHandleInformation (h, HANDLE_FLAG_PROTECT_FROM_CLOSE, 0); - ret = CloseHandle (h); - - if (!ret) - small_printf ("CloseHandle(%s<%p>) failed %s:%d, %E\n", name, h, func, ln); - return ret; -} -#endif /*DEBUGGING*/ diff --git a/winsup/cygwin/debug.h b/winsup/cygwin/debug.h deleted file mode 100644 index b2333e6fd..000000000 --- a/winsup/cygwin/debug.h +++ /dev/null @@ -1,95 +0,0 @@ -/* debug.h - - Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef MALLOC_DEBUG -#define MALLOC_CHECK do {} while (0) -#else -#include -#include "dlmalloc.h" -#define MALLOC_CHECK ({\ - debug_printf ("checking malloc pool");\ - mallinfo ();\ -}) -#endif - -#if !defined(_DEBUG_H_) -#define _DEBUG_H_ - -#define being_debugged() \ - (IsDebuggerPresent () /* || GetLastError () == ERROR_PROC_NOT_FOUND*/) - -#ifndef DEBUGGING -# define cygbench(s) -# define ForceCloseHandle CloseHandle -# define ForceCloseHandle1(h, n) CloseHandle (h) -# define ForceCloseHandle2(h, n) CloseHandle (h) -# define ModifyHandle(h, n) do {} while (0) -# define ProtectHandle(h) do {} while (0) -# define ProtectHandle1(h,n) do {} while (0) -# define ProtectHandle2(h,n) do {} while (0) -# define ProtectHandleINH(h) do {} while (0) -# define ProtectHandle1INH(h,n) do {} while (0) -# define ProtectHandle2INH(h,n) do {} while (0) -# define debug_init() do {} while (0) -# define setclexec(h, nh, b) do {} while (0) -# define debug_fixup_after_fork_exec() do {} while (0) -# define VerifyHandle(h) do {} while (0) -# define console_printf small_printf - -#else - -# ifdef NO_DEBUG_DEFINES -# undef NO_DEBUG_DEFINES -# else -# define CloseHandle(h) \ - close_handle (__PRETTY_FUNCTION__, __LINE__, (h), #h, FALSE) -# define ForceCloseHandle(h) \ - close_handle (__PRETTY_FUNCTION__, __LINE__, (h), #h, TRUE) -# define ForceCloseHandle1(h,n) \ - close_handle (__PRETTY_FUNCTION__, __LINE__, (h), #n, TRUE) -# define ForceCloseHandle2(h,n) \ - close_handle (__PRETTY_FUNCTION__, __LINE__, (h), n, TRUE) -# endif - -# define ModifyHandle(h, n) modify_handle (__PRETTY_FUNCTION__, __LINE__, (h), #h, n) - -# define ProtectHandle(h) add_handle (__PRETTY_FUNCTION__, __LINE__, (h), #h) -# define ProtectHandle1(h, n) add_handle (__PRETTY_FUNCTION__, __LINE__, (h), #n) -# define ProtectHandle2(h, n) add_handle (__PRETTY_FUNCTION__, __LINE__, (h), n) -# define ProtectHandleINH(h) add_handle (__PRETTY_FUNCTION__, __LINE__, (h), #h, 1) -# define ProtectHandle1INH(h, n) add_handle (__PRETTY_FUNCTION__, __LINE__, (h), #n, 1) -# define ProtectHandle2INH(h, n) add_handle (__PRETTY_FUNCTION__, __LINE__, (h), n, 1) -# define VerifyHandle(h) verify_handle (__PRETTY_FUNCTION__, __LINE__, (h)) - -void debug_init (); -void __stdcall add_handle (const char *, int, HANDLE, const char *, bool = false) - __attribute__ ((regparm (3))); -void __stdcall verify_handle (const char *, int, HANDLE) - __attribute__ ((regparm (3))); -bool __stdcall close_handle (const char *, int, HANDLE, const char *, bool) - __attribute__ ((regparm (3))); -extern "C" void console_printf (const char *fmt,...); -void __stdcall cygbench (const char *s) __attribute__ ((regparm (1))); -void __stdcall modify_handle (const char *, int, HANDLE, const char *, bool) - __attribute__ ((regparm (3))); -void setclexec (HANDLE, HANDLE, bool); -void debug_fixup_after_fork_exec (); - -struct handle_list - { - HANDLE h; - const char *name; - const char *func; - int ln; - bool inherited; - DWORD pid; - struct handle_list *next; - }; - -#endif /*DEBUGGING*/ -#endif /*_DEBUG_H_*/ diff --git a/winsup/cygwin/devices.cc b/winsup/cygwin/devices.cc deleted file mode 100644 index 1f4bb9529..000000000 --- a/winsup/cygwin/devices.cc +++ /dev/null @@ -1,43491 +0,0 @@ - - -#include "winsup.h" -#include "devices.h" -#include "sys/cygwin.h" -#include "tty.h" -#include "pinfo.h" -typedef const device *KR_device_t; - - -static KR_device_t KR_find_keyword (const char *KR_keyword, int KR_length); - - - -const device dev_cygdrive_storage = - {"/cygdrive", {FH_CYGDRIVE}, "/cygdrive"}; - -const device dev_fs_storage = - {"", {FH_FS}, ""}; - -const device dev_proc_storage = - {"", {FH_PROC}, ""}; - -const device dev_procnet_storage = - {"", {FH_PROCNET}, ""}; - -const device dev_netdrive_storage = - {"", {FH_NETDRIVE}, ""}; - -#if 0 -const device dev_dev_storage = - {"/dev", {FH_DEV}, "/dev"}; -#endif - -const device dev_registry_storage = - {"", {FH_REGISTRY}, ""}; - -const device dev_piper_storage = - {"", {FH_PIPER}, ""}; - -const device dev_pipew_storage = - {"", {FH_PIPEW}, ""}; - -const device dev_tcp_storage = - {"", {FH_TCP}, ""}; - -const device dev_udp_storage = - {"", {FH_UDP}, ""}; - -const device dev_stream_storage = - {"", {FH_STREAM}, ""}; - -const device dev_dgram_storage = - {"", {FH_DGRAM}, ""}; - -const device dev_bad_storage = - {"", {FH_BAD}, ""}; -#define BRACK(x) {x} - -static const device dev_storage[] = -{ - {"/dev", BRACK(FH_DEV), "/dev"}, - {"/dev/clipboard", BRACK(FH_CLIPBOARD), "\\dev\\clipboard"}, - {"/dev/com1", BRACK(FHDEV(DEV_SERIAL_MAJOR, 0)), "\\??\\COM1"}, - {"/dev/com2", BRACK(FHDEV(DEV_SERIAL_MAJOR, 1)), "\\??\\COM2"}, - {"/dev/com3", BRACK(FHDEV(DEV_SERIAL_MAJOR, 2)), "\\??\\COM3"}, - {"/dev/com4", BRACK(FHDEV(DEV_SERIAL_MAJOR, 3)), "\\??\\COM4"}, - {"/dev/com5", BRACK(FHDEV(DEV_SERIAL_MAJOR, 4)), "\\??\\COM5"}, - {"/dev/com6", BRACK(FHDEV(DEV_SERIAL_MAJOR, 5)), "\\??\\COM6"}, - {"/dev/com7", BRACK(FHDEV(DEV_SERIAL_MAJOR, 6)), "\\??\\COM7"}, - {"/dev/com8", BRACK(FHDEV(DEV_SERIAL_MAJOR, 7)), "\\??\\COM8"}, - {"/dev/com9", BRACK(FHDEV(DEV_SERIAL_MAJOR, 8)), "\\??\\COM9"}, - {"/dev/com10", BRACK(FHDEV(DEV_SERIAL_MAJOR, 9)), "\\??\\COM10"}, - {"/dev/com11", BRACK(FHDEV(DEV_SERIAL_MAJOR, 10)), "\\??\\COM11"}, - {"/dev/com12", BRACK(FHDEV(DEV_SERIAL_MAJOR, 11)), "\\??\\COM12"}, - {"/dev/com13", BRACK(FHDEV(DEV_SERIAL_MAJOR, 12)), "\\??\\COM13"}, - {"/dev/com14", BRACK(FHDEV(DEV_SERIAL_MAJOR, 13)), "\\??\\COM14"}, - {"/dev/com15", BRACK(FHDEV(DEV_SERIAL_MAJOR, 14)), "\\??\\COM15"}, - {"/dev/com16", BRACK(FHDEV(DEV_SERIAL_MAJOR, 15)), "\\??\\COM16"}, - {"/dev/conin", BRACK(FH_CONIN), "conin"}, - {"/dev/conout", BRACK(FH_CONOUT), "conout"}, - {"/dev/console", BRACK(FH_CONSOLE), "\\dev\\console"}, - {"/dev/dsp", BRACK(FH_OSS_DSP), "\\dev\\dsp"}, - {"/dev/fd0", BRACK(FHDEV(DEV_FLOPPY_MAJOR, 0)), "\\Device\\Floppy0"}, - {"/dev/fd1", BRACK(FHDEV(DEV_FLOPPY_MAJOR, 1)), "\\Device\\Floppy1"}, - {"/dev/fd2", BRACK(FHDEV(DEV_FLOPPY_MAJOR, 2)), "\\Device\\Floppy2"}, - {"/dev/fd3", BRACK(FHDEV(DEV_FLOPPY_MAJOR, 3)), "\\Device\\Floppy3"}, - {"/dev/fd4", BRACK(FHDEV(DEV_FLOPPY_MAJOR, 4)), "\\Device\\Floppy4"}, - {"/dev/fd5", BRACK(FHDEV(DEV_FLOPPY_MAJOR, 5)), "\\Device\\Floppy5"}, - {"/dev/fd6", BRACK(FHDEV(DEV_FLOPPY_MAJOR, 6)), "\\Device\\Floppy6"}, - {"/dev/fd7", BRACK(FHDEV(DEV_FLOPPY_MAJOR, 7)), "\\Device\\Floppy7"}, - {"/dev/fd8", BRACK(FHDEV(DEV_FLOPPY_MAJOR, 8)), "\\Device\\Floppy8"}, - {"/dev/fd9", BRACK(FHDEV(DEV_FLOPPY_MAJOR, 9)), "\\Device\\Floppy9"}, - {"/dev/fd10", BRACK(FHDEV(DEV_FLOPPY_MAJOR, 10)), "\\Device\\Floppy10"}, - {"/dev/fd11", BRACK(FHDEV(DEV_FLOPPY_MAJOR, 11)), "\\Device\\Floppy11"}, - {"/dev/fd12", BRACK(FHDEV(DEV_FLOPPY_MAJOR, 12)), "\\Device\\Floppy12"}, - {"/dev/fd13", BRACK(FHDEV(DEV_FLOPPY_MAJOR, 13)), "\\Device\\Floppy13"}, - {"/dev/fd14", BRACK(FHDEV(DEV_FLOPPY_MAJOR, 14)), "\\Device\\Floppy14"}, - {"/dev/fd15", BRACK(FHDEV(DEV_FLOPPY_MAJOR, 15)), "\\Device\\Floppy15"}, - {"/dev/fifo", BRACK(FH_FIFO), "\\dev\\fifo"}, - {"/dev/full", BRACK(FH_FULL), "\\dev\\full"}, - {"/dev/kmem", BRACK(FH_KMEM), "\\dev\\mem"}, - {"/dev/kmsg", BRACK(FH_KMSG), "\\Device\\MailSlot\\cygwin\\dev\\kmsg"}, - {"/dev/mem", BRACK(FH_MEM), "\\dev\\mem"}, - {"/dev/nst0", BRACK(FHDEV(DEV_TAPE_MAJOR, 128)), "\\Device\\Tape0"}, - {"/dev/nst1", BRACK(FHDEV(DEV_TAPE_MAJOR, 129)), "\\Device\\Tape1"}, - {"/dev/nst2", BRACK(FHDEV(DEV_TAPE_MAJOR, 130)), "\\Device\\Tape2"}, - {"/dev/nst3", BRACK(FHDEV(DEV_TAPE_MAJOR, 131)), "\\Device\\Tape3"}, - {"/dev/nst4", BRACK(FHDEV(DEV_TAPE_MAJOR, 132)), "\\Device\\Tape4"}, - {"/dev/nst5", BRACK(FHDEV(DEV_TAPE_MAJOR, 133)), "\\Device\\Tape5"}, - {"/dev/nst6", BRACK(FHDEV(DEV_TAPE_MAJOR, 134)), "\\Device\\Tape6"}, - {"/dev/nst7", BRACK(FHDEV(DEV_TAPE_MAJOR, 135)), "\\Device\\Tape7"}, - {"/dev/nst8", BRACK(FHDEV(DEV_TAPE_MAJOR, 136)), "\\Device\\Tape8"}, - {"/dev/nst9", BRACK(FHDEV(DEV_TAPE_MAJOR, 137)), "\\Device\\Tape9"}, - {"/dev/nst10", BRACK(FHDEV(DEV_TAPE_MAJOR, 138)), "\\Device\\Tape10"}, - {"/dev/nst11", BRACK(FHDEV(DEV_TAPE_MAJOR, 139)), "\\Device\\Tape11"}, - {"/dev/nst12", BRACK(FHDEV(DEV_TAPE_MAJOR, 140)), "\\Device\\Tape12"}, - {"/dev/nst13", BRACK(FHDEV(DEV_TAPE_MAJOR, 141)), "\\Device\\Tape13"}, - {"/dev/nst14", BRACK(FHDEV(DEV_TAPE_MAJOR, 142)), "\\Device\\Tape14"}, - {"/dev/nst15", BRACK(FHDEV(DEV_TAPE_MAJOR, 143)), "\\Device\\Tape15"}, - {"/dev/nst16", BRACK(FHDEV(DEV_TAPE_MAJOR, 144)), "\\Device\\Tape16"}, - {"/dev/nst17", BRACK(FHDEV(DEV_TAPE_MAJOR, 145)), "\\Device\\Tape17"}, - {"/dev/nst18", BRACK(FHDEV(DEV_TAPE_MAJOR, 146)), "\\Device\\Tape18"}, - {"/dev/nst19", BRACK(FHDEV(DEV_TAPE_MAJOR, 147)), "\\Device\\Tape19"}, - {"/dev/nst20", BRACK(FHDEV(DEV_TAPE_MAJOR, 148)), "\\Device\\Tape20"}, - {"/dev/nst21", BRACK(FHDEV(DEV_TAPE_MAJOR, 149)), "\\Device\\Tape21"}, - {"/dev/nst22", BRACK(FHDEV(DEV_TAPE_MAJOR, 150)), "\\Device\\Tape22"}, - {"/dev/nst23", BRACK(FHDEV(DEV_TAPE_MAJOR, 151)), "\\Device\\Tape23"}, - {"/dev/nst24", BRACK(FHDEV(DEV_TAPE_MAJOR, 152)), "\\Device\\Tape24"}, - {"/dev/nst25", BRACK(FHDEV(DEV_TAPE_MAJOR, 153)), "\\Device\\Tape25"}, - {"/dev/nst26", BRACK(FHDEV(DEV_TAPE_MAJOR, 154)), "\\Device\\Tape26"}, - {"/dev/nst27", BRACK(FHDEV(DEV_TAPE_MAJOR, 155)), "\\Device\\Tape27"}, - {"/dev/nst28", BRACK(FHDEV(DEV_TAPE_MAJOR, 156)), "\\Device\\Tape28"}, - {"/dev/nst29", BRACK(FHDEV(DEV_TAPE_MAJOR, 157)), "\\Device\\Tape29"}, - {"/dev/nst30", BRACK(FHDEV(DEV_TAPE_MAJOR, 158)), "\\Device\\Tape30"}, - {"/dev/nst31", BRACK(FHDEV(DEV_TAPE_MAJOR, 159)), "\\Device\\Tape31"}, - {"/dev/nst32", BRACK(FHDEV(DEV_TAPE_MAJOR, 160)), "\\Device\\Tape32"}, - {"/dev/nst33", BRACK(FHDEV(DEV_TAPE_MAJOR, 161)), "\\Device\\Tape33"}, - {"/dev/nst34", BRACK(FHDEV(DEV_TAPE_MAJOR, 162)), "\\Device\\Tape34"}, - {"/dev/nst35", BRACK(FHDEV(DEV_TAPE_MAJOR, 163)), "\\Device\\Tape35"}, - {"/dev/nst36", BRACK(FHDEV(DEV_TAPE_MAJOR, 164)), "\\Device\\Tape36"}, - {"/dev/nst37", BRACK(FHDEV(DEV_TAPE_MAJOR, 165)), "\\Device\\Tape37"}, - {"/dev/nst38", BRACK(FHDEV(DEV_TAPE_MAJOR, 166)), "\\Device\\Tape38"}, - {"/dev/nst39", BRACK(FHDEV(DEV_TAPE_MAJOR, 167)), "\\Device\\Tape39"}, - {"/dev/nst40", BRACK(FHDEV(DEV_TAPE_MAJOR, 168)), "\\Device\\Tape40"}, - {"/dev/nst41", BRACK(FHDEV(DEV_TAPE_MAJOR, 169)), "\\Device\\Tape41"}, - {"/dev/nst42", BRACK(FHDEV(DEV_TAPE_MAJOR, 170)), "\\Device\\Tape42"}, - {"/dev/nst43", BRACK(FHDEV(DEV_TAPE_MAJOR, 171)), "\\Device\\Tape43"}, - {"/dev/nst44", BRACK(FHDEV(DEV_TAPE_MAJOR, 172)), "\\Device\\Tape44"}, - {"/dev/nst45", BRACK(FHDEV(DEV_TAPE_MAJOR, 173)), "\\Device\\Tape45"}, - {"/dev/nst46", BRACK(FHDEV(DEV_TAPE_MAJOR, 174)), "\\Device\\Tape46"}, - {"/dev/nst47", BRACK(FHDEV(DEV_TAPE_MAJOR, 175)), "\\Device\\Tape47"}, - {"/dev/nst48", BRACK(FHDEV(DEV_TAPE_MAJOR, 176)), "\\Device\\Tape48"}, - {"/dev/nst49", BRACK(FHDEV(DEV_TAPE_MAJOR, 177)), "\\Device\\Tape49"}, - {"/dev/nst50", BRACK(FHDEV(DEV_TAPE_MAJOR, 178)), "\\Device\\Tape50"}, - {"/dev/nst51", BRACK(FHDEV(DEV_TAPE_MAJOR, 179)), "\\Device\\Tape51"}, - {"/dev/nst52", BRACK(FHDEV(DEV_TAPE_MAJOR, 180)), "\\Device\\Tape52"}, - {"/dev/nst53", BRACK(FHDEV(DEV_TAPE_MAJOR, 181)), "\\Device\\Tape53"}, - {"/dev/nst54", BRACK(FHDEV(DEV_TAPE_MAJOR, 182)), "\\Device\\Tape54"}, - {"/dev/nst55", BRACK(FHDEV(DEV_TAPE_MAJOR, 183)), "\\Device\\Tape55"}, - {"/dev/nst56", BRACK(FHDEV(DEV_TAPE_MAJOR, 184)), "\\Device\\Tape56"}, - {"/dev/nst57", BRACK(FHDEV(DEV_TAPE_MAJOR, 185)), "\\Device\\Tape57"}, - {"/dev/nst58", BRACK(FHDEV(DEV_TAPE_MAJOR, 186)), "\\Device\\Tape58"}, - {"/dev/nst59", BRACK(FHDEV(DEV_TAPE_MAJOR, 187)), "\\Device\\Tape59"}, - {"/dev/nst60", BRACK(FHDEV(DEV_TAPE_MAJOR, 188)), "\\Device\\Tape60"}, - {"/dev/nst61", BRACK(FHDEV(DEV_TAPE_MAJOR, 189)), "\\Device\\Tape61"}, - {"/dev/nst62", BRACK(FHDEV(DEV_TAPE_MAJOR, 190)), "\\Device\\Tape62"}, - {"/dev/nst63", BRACK(FHDEV(DEV_TAPE_MAJOR, 191)), "\\Device\\Tape63"}, - {"/dev/nst64", BRACK(FHDEV(DEV_TAPE_MAJOR, 192)), "\\Device\\Tape64"}, - {"/dev/nst65", BRACK(FHDEV(DEV_TAPE_MAJOR, 193)), "\\Device\\Tape65"}, - {"/dev/nst66", BRACK(FHDEV(DEV_TAPE_MAJOR, 194)), "\\Device\\Tape66"}, - {"/dev/nst67", BRACK(FHDEV(DEV_TAPE_MAJOR, 195)), "\\Device\\Tape67"}, - {"/dev/nst68", BRACK(FHDEV(DEV_TAPE_MAJOR, 196)), "\\Device\\Tape68"}, - {"/dev/nst69", BRACK(FHDEV(DEV_TAPE_MAJOR, 197)), "\\Device\\Tape69"}, - {"/dev/nst70", BRACK(FHDEV(DEV_TAPE_MAJOR, 198)), "\\Device\\Tape70"}, - {"/dev/nst71", BRACK(FHDEV(DEV_TAPE_MAJOR, 199)), "\\Device\\Tape71"}, - {"/dev/nst72", BRACK(FHDEV(DEV_TAPE_MAJOR, 200)), "\\Device\\Tape72"}, - {"/dev/nst73", BRACK(FHDEV(DEV_TAPE_MAJOR, 201)), "\\Device\\Tape73"}, - {"/dev/nst74", BRACK(FHDEV(DEV_TAPE_MAJOR, 202)), "\\Device\\Tape74"}, - {"/dev/nst75", BRACK(FHDEV(DEV_TAPE_MAJOR, 203)), "\\Device\\Tape75"}, - {"/dev/nst76", BRACK(FHDEV(DEV_TAPE_MAJOR, 204)), "\\Device\\Tape76"}, - {"/dev/nst77", BRACK(FHDEV(DEV_TAPE_MAJOR, 205)), "\\Device\\Tape77"}, - {"/dev/nst78", BRACK(FHDEV(DEV_TAPE_MAJOR, 206)), "\\Device\\Tape78"}, - {"/dev/nst79", BRACK(FHDEV(DEV_TAPE_MAJOR, 207)), "\\Device\\Tape79"}, - {"/dev/nst80", BRACK(FHDEV(DEV_TAPE_MAJOR, 208)), "\\Device\\Tape80"}, - {"/dev/nst81", BRACK(FHDEV(DEV_TAPE_MAJOR, 209)), "\\Device\\Tape81"}, - {"/dev/nst82", BRACK(FHDEV(DEV_TAPE_MAJOR, 210)), "\\Device\\Tape82"}, - {"/dev/nst83", BRACK(FHDEV(DEV_TAPE_MAJOR, 211)), "\\Device\\Tape83"}, - {"/dev/nst84", BRACK(FHDEV(DEV_TAPE_MAJOR, 212)), "\\Device\\Tape84"}, - {"/dev/nst85", BRACK(FHDEV(DEV_TAPE_MAJOR, 213)), "\\Device\\Tape85"}, - {"/dev/nst86", BRACK(FHDEV(DEV_TAPE_MAJOR, 214)), "\\Device\\Tape86"}, - {"/dev/nst87", BRACK(FHDEV(DEV_TAPE_MAJOR, 215)), "\\Device\\Tape87"}, - {"/dev/nst88", BRACK(FHDEV(DEV_TAPE_MAJOR, 216)), "\\Device\\Tape88"}, - {"/dev/nst89", BRACK(FHDEV(DEV_TAPE_MAJOR, 217)), "\\Device\\Tape89"}, - {"/dev/nst90", BRACK(FHDEV(DEV_TAPE_MAJOR, 218)), "\\Device\\Tape90"}, - {"/dev/nst91", BRACK(FHDEV(DEV_TAPE_MAJOR, 219)), "\\Device\\Tape91"}, - {"/dev/nst92", BRACK(FHDEV(DEV_TAPE_MAJOR, 220)), "\\Device\\Tape92"}, - {"/dev/nst93", BRACK(FHDEV(DEV_TAPE_MAJOR, 221)), "\\Device\\Tape93"}, - {"/dev/nst94", BRACK(FHDEV(DEV_TAPE_MAJOR, 222)), "\\Device\\Tape94"}, - {"/dev/nst95", BRACK(FHDEV(DEV_TAPE_MAJOR, 223)), "\\Device\\Tape95"}, - {"/dev/nst96", BRACK(FHDEV(DEV_TAPE_MAJOR, 224)), "\\Device\\Tape96"}, - {"/dev/nst97", BRACK(FHDEV(DEV_TAPE_MAJOR, 225)), "\\Device\\Tape97"}, - {"/dev/nst98", BRACK(FHDEV(DEV_TAPE_MAJOR, 226)), "\\Device\\Tape98"}, - {"/dev/nst99", BRACK(FHDEV(DEV_TAPE_MAJOR, 227)), "\\Device\\Tape99"}, - {"/dev/nst100", BRACK(FHDEV(DEV_TAPE_MAJOR, 228)), "\\Device\\Tape100"}, - {"/dev/nst101", BRACK(FHDEV(DEV_TAPE_MAJOR, 229)), "\\Device\\Tape101"}, - {"/dev/nst102", BRACK(FHDEV(DEV_TAPE_MAJOR, 230)), "\\Device\\Tape102"}, - {"/dev/nst103", BRACK(FHDEV(DEV_TAPE_MAJOR, 231)), "\\Device\\Tape103"}, - {"/dev/nst104", BRACK(FHDEV(DEV_TAPE_MAJOR, 232)), "\\Device\\Tape104"}, - {"/dev/nst105", BRACK(FHDEV(DEV_TAPE_MAJOR, 233)), "\\Device\\Tape105"}, - {"/dev/nst106", BRACK(FHDEV(DEV_TAPE_MAJOR, 234)), "\\Device\\Tape106"}, - {"/dev/nst107", BRACK(FHDEV(DEV_TAPE_MAJOR, 235)), "\\Device\\Tape107"}, - {"/dev/nst108", BRACK(FHDEV(DEV_TAPE_MAJOR, 236)), "\\Device\\Tape108"}, - {"/dev/nst109", BRACK(FHDEV(DEV_TAPE_MAJOR, 237)), "\\Device\\Tape109"}, - {"/dev/nst110", BRACK(FHDEV(DEV_TAPE_MAJOR, 238)), "\\Device\\Tape110"}, - {"/dev/nst111", BRACK(FHDEV(DEV_TAPE_MAJOR, 239)), "\\Device\\Tape111"}, - {"/dev/nst112", BRACK(FHDEV(DEV_TAPE_MAJOR, 240)), "\\Device\\Tape112"}, - {"/dev/nst113", BRACK(FHDEV(DEV_TAPE_MAJOR, 241)), "\\Device\\Tape113"}, - {"/dev/nst114", BRACK(FHDEV(DEV_TAPE_MAJOR, 242)), "\\Device\\Tape114"}, - {"/dev/nst115", BRACK(FHDEV(DEV_TAPE_MAJOR, 243)), "\\Device\\Tape115"}, - {"/dev/nst116", BRACK(FHDEV(DEV_TAPE_MAJOR, 244)), "\\Device\\Tape116"}, - {"/dev/nst117", BRACK(FHDEV(DEV_TAPE_MAJOR, 245)), "\\Device\\Tape117"}, - {"/dev/nst118", BRACK(FHDEV(DEV_TAPE_MAJOR, 246)), "\\Device\\Tape118"}, - {"/dev/nst119", BRACK(FHDEV(DEV_TAPE_MAJOR, 247)), "\\Device\\Tape119"}, - {"/dev/nst120", BRACK(FHDEV(DEV_TAPE_MAJOR, 248)), "\\Device\\Tape120"}, - {"/dev/nst121", BRACK(FHDEV(DEV_TAPE_MAJOR, 249)), "\\Device\\Tape121"}, - {"/dev/nst122", BRACK(FHDEV(DEV_TAPE_MAJOR, 250)), "\\Device\\Tape122"}, - {"/dev/nst123", BRACK(FHDEV(DEV_TAPE_MAJOR, 251)), "\\Device\\Tape123"}, - {"/dev/nst124", BRACK(FHDEV(DEV_TAPE_MAJOR, 252)), "\\Device\\Tape124"}, - {"/dev/nst125", BRACK(FHDEV(DEV_TAPE_MAJOR, 253)), "\\Device\\Tape125"}, - {"/dev/nst126", BRACK(FHDEV(DEV_TAPE_MAJOR, 254)), "\\Device\\Tape126"}, - {"/dev/nst127", BRACK(FHDEV(DEV_TAPE_MAJOR, 255)), "\\Device\\Tape127"}, - {"/dev/null", BRACK(FH_NULL), "\\Device\\Null"}, - {"/dev/pipe", BRACK(FH_PIPE), "\\dev\\pipe"}, - {"/dev/port", BRACK(FH_PORT), "\\dev\\port"}, - {"/dev/ptmx", BRACK(FH_PTYM), "\\dev\\ptmx"}, - {"/dev/random", BRACK(FH_RANDOM), "\\dev\\random"}, - {"/dev/scd0", BRACK(FHDEV(DEV_CDROM_MAJOR, 0)), "\\Device\\CdRom0"}, - {"/dev/scd1", BRACK(FHDEV(DEV_CDROM_MAJOR, 1)), "\\Device\\CdRom1"}, - {"/dev/scd2", BRACK(FHDEV(DEV_CDROM_MAJOR, 2)), "\\Device\\CdRom2"}, - {"/dev/scd3", BRACK(FHDEV(DEV_CDROM_MAJOR, 3)), "\\Device\\CdRom3"}, - {"/dev/scd4", BRACK(FHDEV(DEV_CDROM_MAJOR, 4)), "\\Device\\CdRom4"}, - {"/dev/scd5", BRACK(FHDEV(DEV_CDROM_MAJOR, 5)), "\\Device\\CdRom5"}, - {"/dev/scd6", BRACK(FHDEV(DEV_CDROM_MAJOR, 6)), "\\Device\\CdRom6"}, - {"/dev/scd7", BRACK(FHDEV(DEV_CDROM_MAJOR, 7)), "\\Device\\CdRom7"}, - {"/dev/scd8", BRACK(FHDEV(DEV_CDROM_MAJOR, 8)), "\\Device\\CdRom8"}, - {"/dev/scd9", BRACK(FHDEV(DEV_CDROM_MAJOR, 9)), "\\Device\\CdRom9"}, - {"/dev/scd10", BRACK(FHDEV(DEV_CDROM_MAJOR, 10)), "\\Device\\CdRom10"}, - {"/dev/scd11", BRACK(FHDEV(DEV_CDROM_MAJOR, 11)), "\\Device\\CdRom11"}, - {"/dev/scd12", BRACK(FHDEV(DEV_CDROM_MAJOR, 12)), "\\Device\\CdRom12"}, - {"/dev/scd13", BRACK(FHDEV(DEV_CDROM_MAJOR, 13)), "\\Device\\CdRom13"}, - {"/dev/scd14", BRACK(FHDEV(DEV_CDROM_MAJOR, 14)), "\\Device\\CdRom14"}, - {"/dev/scd15", BRACK(FHDEV(DEV_CDROM_MAJOR, 15)), "\\Device\\CdRom15"}, - {"/dev/sda", BRACK(FH_SDA), "\\Device\\Harddisk0\\Partition0"}, - {"/dev/sdb", BRACK(FH_SDB), "\\Device\\Harddisk1\\Partition0"}, - {"/dev/sdc", BRACK(FH_SDC), "\\Device\\Harddisk2\\Partition0"}, - {"/dev/sdd", BRACK(FH_SDD), "\\Device\\Harddisk3\\Partition0"}, - {"/dev/sde", BRACK(FH_SDE), "\\Device\\Harddisk4\\Partition0"}, - {"/dev/sdf", BRACK(FH_SDF), "\\Device\\Harddisk5\\Partition0"}, - {"/dev/sdg", BRACK(FH_SDG), "\\Device\\Harddisk6\\Partition0"}, - {"/dev/sdh", BRACK(FH_SDH), "\\Device\\Harddisk7\\Partition0"}, - {"/dev/sdi", BRACK(FH_SDI), "\\Device\\Harddisk8\\Partition0"}, - {"/dev/sdj", BRACK(FH_SDJ), "\\Device\\Harddisk9\\Partition0"}, - {"/dev/sdk", BRACK(FH_SDK), "\\Device\\Harddisk10\\Partition0"}, - {"/dev/sdl", BRACK(FH_SDL), "\\Device\\Harddisk11\\Partition0"}, - {"/dev/sdm", BRACK(FH_SDM), "\\Device\\Harddisk12\\Partition0"}, - {"/dev/sdn", BRACK(FH_SDN), "\\Device\\Harddisk13\\Partition0"}, - {"/dev/sdo", BRACK(FH_SDO), "\\Device\\Harddisk14\\Partition0"}, - {"/dev/sdp", BRACK(FH_SDP), "\\Device\\Harddisk15\\Partition0"}, - {"/dev/sdq", BRACK(FH_SDQ), "\\Device\\Harddisk16\\Partition0"}, - {"/dev/sdr", BRACK(FH_SDR), "\\Device\\Harddisk17\\Partition0"}, - {"/dev/sds", BRACK(FH_SDS), "\\Device\\Harddisk18\\Partition0"}, - {"/dev/sdt", BRACK(FH_SDT), "\\Device\\Harddisk19\\Partition0"}, - {"/dev/sdu", BRACK(FH_SDU), "\\Device\\Harddisk20\\Partition0"}, - {"/dev/sdv", BRACK(FH_SDV), "\\Device\\Harddisk21\\Partition0"}, - {"/dev/sdw", BRACK(FH_SDW), "\\Device\\Harddisk22\\Partition0"}, - {"/dev/sdx", BRACK(FH_SDX), "\\Device\\Harddisk23\\Partition0"}, - {"/dev/sdy", BRACK(FH_SDY), "\\Device\\Harddisk24\\Partition0"}, - {"/dev/sdz", BRACK(FH_SDZ), "\\Device\\Harddisk25\\Partition0"}, - {"/dev/sda1", BRACK(FH_SDA | 1), "\\Device\\Harddisk0\\Partition1"}, - {"/dev/sda2", BRACK(FH_SDA | 2), "\\Device\\Harddisk0\\Partition2"}, - {"/dev/sda3", BRACK(FH_SDA | 3), "\\Device\\Harddisk0\\Partition3"}, - {"/dev/sda4", BRACK(FH_SDA | 4), "\\Device\\Harddisk0\\Partition4"}, - {"/dev/sda5", BRACK(FH_SDA | 5), "\\Device\\Harddisk0\\Partition5"}, - {"/dev/sda6", BRACK(FH_SDA | 6), "\\Device\\Harddisk0\\Partition6"}, - {"/dev/sda7", BRACK(FH_SDA | 7), "\\Device\\Harddisk0\\Partition7"}, - {"/dev/sda8", BRACK(FH_SDA | 8), "\\Device\\Harddisk0\\Partition8"}, - {"/dev/sda9", BRACK(FH_SDA | 9), "\\Device\\Harddisk0\\Partition9"}, - {"/dev/sda10", BRACK(FH_SDA | 10), "\\Device\\Harddisk0\\Partition10"}, - {"/dev/sda11", BRACK(FH_SDA | 11), "\\Device\\Harddisk0\\Partition11"}, - {"/dev/sda12", BRACK(FH_SDA | 12), "\\Device\\Harddisk0\\Partition12"}, - {"/dev/sda13", BRACK(FH_SDA | 13), "\\Device\\Harddisk0\\Partition13"}, - {"/dev/sda14", BRACK(FH_SDA | 14), "\\Device\\Harddisk0\\Partition14"}, - {"/dev/sda15", BRACK(FH_SDA | 15), "\\Device\\Harddisk0\\Partition15"}, - {"/dev/sdb1", BRACK(FH_SDB | 1), "\\Device\\Harddisk1\\Partition1"}, - {"/dev/sdb2", BRACK(FH_SDB | 2), "\\Device\\Harddisk1\\Partition2"}, - {"/dev/sdb3", BRACK(FH_SDB | 3), "\\Device\\Harddisk1\\Partition3"}, - {"/dev/sdb4", BRACK(FH_SDB | 4), "\\Device\\Harddisk1\\Partition4"}, - {"/dev/sdb5", BRACK(FH_SDB | 5), "\\Device\\Harddisk1\\Partition5"}, - {"/dev/sdb6", BRACK(FH_SDB | 6), "\\Device\\Harddisk1\\Partition6"}, - {"/dev/sdb7", BRACK(FH_SDB | 7), "\\Device\\Harddisk1\\Partition7"}, - {"/dev/sdb8", BRACK(FH_SDB | 8), "\\Device\\Harddisk1\\Partition8"}, - {"/dev/sdb9", BRACK(FH_SDB | 9), "\\Device\\Harddisk1\\Partition9"}, - {"/dev/sdb10", BRACK(FH_SDB | 10), "\\Device\\Harddisk1\\Partition10"}, - {"/dev/sdb11", BRACK(FH_SDB | 11), "\\Device\\Harddisk1\\Partition11"}, - {"/dev/sdb12", BRACK(FH_SDB | 12), "\\Device\\Harddisk1\\Partition12"}, - {"/dev/sdb13", BRACK(FH_SDB | 13), "\\Device\\Harddisk1\\Partition13"}, - {"/dev/sdb14", BRACK(FH_SDB | 14), "\\Device\\Harddisk1\\Partition14"}, - {"/dev/sdb15", BRACK(FH_SDB | 15), "\\Device\\Harddisk1\\Partition15"}, - {"/dev/sdc1", BRACK(FH_SDC | 1), "\\Device\\Harddisk2\\Partition1"}, - {"/dev/sdc2", BRACK(FH_SDC | 2), "\\Device\\Harddisk2\\Partition2"}, - {"/dev/sdc3", BRACK(FH_SDC | 3), "\\Device\\Harddisk2\\Partition3"}, - {"/dev/sdc4", BRACK(FH_SDC | 4), "\\Device\\Harddisk2\\Partition4"}, - {"/dev/sdc5", BRACK(FH_SDC | 5), "\\Device\\Harddisk2\\Partition5"}, - {"/dev/sdc6", BRACK(FH_SDC | 6), "\\Device\\Harddisk2\\Partition6"}, - {"/dev/sdc7", BRACK(FH_SDC | 7), "\\Device\\Harddisk2\\Partition7"}, - {"/dev/sdc8", BRACK(FH_SDC | 8), "\\Device\\Harddisk2\\Partition8"}, - {"/dev/sdc9", BRACK(FH_SDC | 9), "\\Device\\Harddisk2\\Partition9"}, - {"/dev/sdc10", BRACK(FH_SDC | 10), "\\Device\\Harddisk2\\Partition10"}, - {"/dev/sdc11", BRACK(FH_SDC | 11), "\\Device\\Harddisk2\\Partition11"}, - {"/dev/sdc12", BRACK(FH_SDC | 12), "\\Device\\Harddisk2\\Partition12"}, - {"/dev/sdc13", BRACK(FH_SDC | 13), "\\Device\\Harddisk2\\Partition13"}, - {"/dev/sdc14", BRACK(FH_SDC | 14), "\\Device\\Harddisk2\\Partition14"}, - {"/dev/sdc15", BRACK(FH_SDC | 15), "\\Device\\Harddisk2\\Partition15"}, - {"/dev/sdd1", BRACK(FH_SDD | 1), "\\Device\\Harddisk3\\Partition1"}, - {"/dev/sdd2", BRACK(FH_SDD | 2), "\\Device\\Harddisk3\\Partition2"}, - {"/dev/sdd3", BRACK(FH_SDD | 3), "\\Device\\Harddisk3\\Partition3"}, - {"/dev/sdd4", BRACK(FH_SDD | 4), "\\Device\\Harddisk3\\Partition4"}, - {"/dev/sdd5", BRACK(FH_SDD | 5), "\\Device\\Harddisk3\\Partition5"}, - {"/dev/sdd6", BRACK(FH_SDD | 6), "\\Device\\Harddisk3\\Partition6"}, - {"/dev/sdd7", BRACK(FH_SDD | 7), "\\Device\\Harddisk3\\Partition7"}, - {"/dev/sdd8", BRACK(FH_SDD | 8), "\\Device\\Harddisk3\\Partition8"}, - {"/dev/sdd9", BRACK(FH_SDD | 9), "\\Device\\Harddisk3\\Partition9"}, - {"/dev/sdd10", BRACK(FH_SDD | 10), "\\Device\\Harddisk3\\Partition10"}, - {"/dev/sdd11", BRACK(FH_SDD | 11), "\\Device\\Harddisk3\\Partition11"}, - {"/dev/sdd12", BRACK(FH_SDD | 12), "\\Device\\Harddisk3\\Partition12"}, - {"/dev/sdd13", BRACK(FH_SDD | 13), "\\Device\\Harddisk3\\Partition13"}, - {"/dev/sdd14", BRACK(FH_SDD | 14), "\\Device\\Harddisk3\\Partition14"}, - {"/dev/sdd15", BRACK(FH_SDD | 15), "\\Device\\Harddisk3\\Partition15"}, - {"/dev/sde1", BRACK(FH_SDE | 1), "\\Device\\Harddisk4\\Partition1"}, - {"/dev/sde2", BRACK(FH_SDE | 2), "\\Device\\Harddisk4\\Partition2"}, - {"/dev/sde3", BRACK(FH_SDE | 3), "\\Device\\Harddisk4\\Partition3"}, - {"/dev/sde4", BRACK(FH_SDE | 4), "\\Device\\Harddisk4\\Partition4"}, - {"/dev/sde5", BRACK(FH_SDE | 5), "\\Device\\Harddisk4\\Partition5"}, - {"/dev/sde6", BRACK(FH_SDE | 6), "\\Device\\Harddisk4\\Partition6"}, - {"/dev/sde7", BRACK(FH_SDE | 7), "\\Device\\Harddisk4\\Partition7"}, - {"/dev/sde8", BRACK(FH_SDE | 8), "\\Device\\Harddisk4\\Partition8"}, - {"/dev/sde9", BRACK(FH_SDE | 9), "\\Device\\Harddisk4\\Partition9"}, - {"/dev/sde10", BRACK(FH_SDE | 10), "\\Device\\Harddisk4\\Partition10"}, - {"/dev/sde11", BRACK(FH_SDE | 11), "\\Device\\Harddisk4\\Partition11"}, - {"/dev/sde12", BRACK(FH_SDE | 12), "\\Device\\Harddisk4\\Partition12"}, - {"/dev/sde13", BRACK(FH_SDE | 13), "\\Device\\Harddisk4\\Partition13"}, - {"/dev/sde14", BRACK(FH_SDE | 14), "\\Device\\Harddisk4\\Partition14"}, - {"/dev/sde15", BRACK(FH_SDE | 15), "\\Device\\Harddisk4\\Partition15"}, - {"/dev/sdf1", BRACK(FH_SDF | 1), "\\Device\\Harddisk5\\Partition1"}, - {"/dev/sdf2", BRACK(FH_SDF | 2), "\\Device\\Harddisk5\\Partition2"}, - {"/dev/sdf3", BRACK(FH_SDF | 3), "\\Device\\Harddisk5\\Partition3"}, - {"/dev/sdf4", BRACK(FH_SDF | 4), "\\Device\\Harddisk5\\Partition4"}, - {"/dev/sdf5", BRACK(FH_SDF | 5), "\\Device\\Harddisk5\\Partition5"}, - {"/dev/sdf6", BRACK(FH_SDF | 6), "\\Device\\Harddisk5\\Partition6"}, - {"/dev/sdf7", BRACK(FH_SDF | 7), "\\Device\\Harddisk5\\Partition7"}, - {"/dev/sdf8", BRACK(FH_SDF | 8), "\\Device\\Harddisk5\\Partition8"}, - {"/dev/sdf9", BRACK(FH_SDF | 9), "\\Device\\Harddisk5\\Partition9"}, - {"/dev/sdf10", BRACK(FH_SDF | 10), "\\Device\\Harddisk5\\Partition10"}, - {"/dev/sdf11", BRACK(FH_SDF | 11), "\\Device\\Harddisk5\\Partition11"}, - {"/dev/sdf12", BRACK(FH_SDF | 12), "\\Device\\Harddisk5\\Partition12"}, - {"/dev/sdf13", BRACK(FH_SDF | 13), "\\Device\\Harddisk5\\Partition13"}, - {"/dev/sdf14", BRACK(FH_SDF | 14), "\\Device\\Harddisk5\\Partition14"}, - {"/dev/sdf15", BRACK(FH_SDF | 15), "\\Device\\Harddisk5\\Partition15"}, - {"/dev/sdg1", BRACK(FH_SDG | 1), "\\Device\\Harddisk6\\Partition1"}, - {"/dev/sdg2", BRACK(FH_SDG | 2), "\\Device\\Harddisk6\\Partition2"}, - {"/dev/sdg3", BRACK(FH_SDG | 3), "\\Device\\Harddisk6\\Partition3"}, - {"/dev/sdg4", BRACK(FH_SDG | 4), "\\Device\\Harddisk6\\Partition4"}, - {"/dev/sdg5", BRACK(FH_SDG | 5), "\\Device\\Harddisk6\\Partition5"}, - {"/dev/sdg6", BRACK(FH_SDG | 6), "\\Device\\Harddisk6\\Partition6"}, - {"/dev/sdg7", BRACK(FH_SDG | 7), "\\Device\\Harddisk6\\Partition7"}, - {"/dev/sdg8", BRACK(FH_SDG | 8), "\\Device\\Harddisk6\\Partition8"}, - {"/dev/sdg9", BRACK(FH_SDG | 9), "\\Device\\Harddisk6\\Partition9"}, - {"/dev/sdg10", BRACK(FH_SDG | 10), "\\Device\\Harddisk6\\Partition10"}, - {"/dev/sdg11", BRACK(FH_SDG | 11), "\\Device\\Harddisk6\\Partition11"}, - {"/dev/sdg12", BRACK(FH_SDG | 12), "\\Device\\Harddisk6\\Partition12"}, - {"/dev/sdg13", BRACK(FH_SDG | 13), "\\Device\\Harddisk6\\Partition13"}, - {"/dev/sdg14", BRACK(FH_SDG | 14), "\\Device\\Harddisk6\\Partition14"}, - {"/dev/sdg15", BRACK(FH_SDG | 15), "\\Device\\Harddisk6\\Partition15"}, - {"/dev/sdh1", BRACK(FH_SDH | 1), "\\Device\\Harddisk7\\Partition1"}, - {"/dev/sdh2", BRACK(FH_SDH | 2), "\\Device\\Harddisk7\\Partition2"}, - {"/dev/sdh3", BRACK(FH_SDH | 3), "\\Device\\Harddisk7\\Partition3"}, - {"/dev/sdh4", BRACK(FH_SDH | 4), "\\Device\\Harddisk7\\Partition4"}, - {"/dev/sdh5", BRACK(FH_SDH | 5), "\\Device\\Harddisk7\\Partition5"}, - {"/dev/sdh6", BRACK(FH_SDH | 6), "\\Device\\Harddisk7\\Partition6"}, - {"/dev/sdh7", BRACK(FH_SDH | 7), "\\Device\\Harddisk7\\Partition7"}, - {"/dev/sdh8", BRACK(FH_SDH | 8), "\\Device\\Harddisk7\\Partition8"}, - {"/dev/sdh9", BRACK(FH_SDH | 9), "\\Device\\Harddisk7\\Partition9"}, - {"/dev/sdh10", BRACK(FH_SDH | 10), "\\Device\\Harddisk7\\Partition10"}, - {"/dev/sdh11", BRACK(FH_SDH | 11), "\\Device\\Harddisk7\\Partition11"}, - {"/dev/sdh12", BRACK(FH_SDH | 12), "\\Device\\Harddisk7\\Partition12"}, - {"/dev/sdh13", BRACK(FH_SDH | 13), "\\Device\\Harddisk7\\Partition13"}, - {"/dev/sdh14", BRACK(FH_SDH | 14), "\\Device\\Harddisk7\\Partition14"}, - {"/dev/sdh15", BRACK(FH_SDH | 15), "\\Device\\Harddisk7\\Partition15"}, - {"/dev/sdi1", BRACK(FH_SDI | 1), "\\Device\\Harddisk8\\Partition1"}, - {"/dev/sdi2", BRACK(FH_SDI | 2), "\\Device\\Harddisk8\\Partition2"}, - {"/dev/sdi3", BRACK(FH_SDI | 3), "\\Device\\Harddisk8\\Partition3"}, - {"/dev/sdi4", BRACK(FH_SDI | 4), "\\Device\\Harddisk8\\Partition4"}, - {"/dev/sdi5", BRACK(FH_SDI | 5), "\\Device\\Harddisk8\\Partition5"}, - {"/dev/sdi6", BRACK(FH_SDI | 6), "\\Device\\Harddisk8\\Partition6"}, - {"/dev/sdi7", BRACK(FH_SDI | 7), "\\Device\\Harddisk8\\Partition7"}, - {"/dev/sdi8", BRACK(FH_SDI | 8), "\\Device\\Harddisk8\\Partition8"}, - {"/dev/sdi9", BRACK(FH_SDI | 9), "\\Device\\Harddisk8\\Partition9"}, - {"/dev/sdi10", BRACK(FH_SDI | 10), "\\Device\\Harddisk8\\Partition10"}, - {"/dev/sdi11", BRACK(FH_SDI | 11), "\\Device\\Harddisk8\\Partition11"}, - {"/dev/sdi12", BRACK(FH_SDI | 12), "\\Device\\Harddisk8\\Partition12"}, - {"/dev/sdi13", BRACK(FH_SDI | 13), "\\Device\\Harddisk8\\Partition13"}, - {"/dev/sdi14", BRACK(FH_SDI | 14), "\\Device\\Harddisk8\\Partition14"}, - {"/dev/sdi15", BRACK(FH_SDI | 15), "\\Device\\Harddisk8\\Partition15"}, - {"/dev/sdj1", BRACK(FH_SDJ | 1), "\\Device\\Harddisk9\\Partition1"}, - {"/dev/sdj2", BRACK(FH_SDJ | 2), "\\Device\\Harddisk9\\Partition2"}, - {"/dev/sdj3", BRACK(FH_SDJ | 3), "\\Device\\Harddisk9\\Partition3"}, - {"/dev/sdj4", BRACK(FH_SDJ | 4), "\\Device\\Harddisk9\\Partition4"}, - {"/dev/sdj5", BRACK(FH_SDJ | 5), "\\Device\\Harddisk9\\Partition5"}, - {"/dev/sdj6", BRACK(FH_SDJ | 6), "\\Device\\Harddisk9\\Partition6"}, - {"/dev/sdj7", BRACK(FH_SDJ | 7), "\\Device\\Harddisk9\\Partition7"}, - {"/dev/sdj8", BRACK(FH_SDJ | 8), "\\Device\\Harddisk9\\Partition8"}, - {"/dev/sdj9", BRACK(FH_SDJ | 9), "\\Device\\Harddisk9\\Partition9"}, - {"/dev/sdj10", BRACK(FH_SDJ | 10), "\\Device\\Harddisk9\\Partition10"}, - {"/dev/sdj11", BRACK(FH_SDJ | 11), "\\Device\\Harddisk9\\Partition11"}, - {"/dev/sdj12", BRACK(FH_SDJ | 12), "\\Device\\Harddisk9\\Partition12"}, - {"/dev/sdj13", BRACK(FH_SDJ | 13), "\\Device\\Harddisk9\\Partition13"}, - {"/dev/sdj14", BRACK(FH_SDJ | 14), "\\Device\\Harddisk9\\Partition14"}, - {"/dev/sdj15", BRACK(FH_SDJ | 15), "\\Device\\Harddisk9\\Partition15"}, - {"/dev/sdk1", BRACK(FH_SDK | 1), "\\Device\\Harddisk10\\Partition1"}, - {"/dev/sdk2", BRACK(FH_SDK | 2), "\\Device\\Harddisk10\\Partition2"}, - {"/dev/sdk3", BRACK(FH_SDK | 3), "\\Device\\Harddisk10\\Partition3"}, - {"/dev/sdk4", BRACK(FH_SDK | 4), "\\Device\\Harddisk10\\Partition4"}, - {"/dev/sdk5", BRACK(FH_SDK | 5), "\\Device\\Harddisk10\\Partition5"}, - {"/dev/sdk6", BRACK(FH_SDK | 6), "\\Device\\Harddisk10\\Partition6"}, - {"/dev/sdk7", BRACK(FH_SDK | 7), "\\Device\\Harddisk10\\Partition7"}, - {"/dev/sdk8", BRACK(FH_SDK | 8), "\\Device\\Harddisk10\\Partition8"}, - {"/dev/sdk9", BRACK(FH_SDK | 9), "\\Device\\Harddisk10\\Partition9"}, - {"/dev/sdk10", BRACK(FH_SDK | 10), "\\Device\\Harddisk10\\Partition10"}, - {"/dev/sdk11", BRACK(FH_SDK | 11), "\\Device\\Harddisk10\\Partition11"}, - {"/dev/sdk12", BRACK(FH_SDK | 12), "\\Device\\Harddisk10\\Partition12"}, - {"/dev/sdk13", BRACK(FH_SDK | 13), "\\Device\\Harddisk10\\Partition13"}, - {"/dev/sdk14", BRACK(FH_SDK | 14), "\\Device\\Harddisk10\\Partition14"}, - {"/dev/sdk15", BRACK(FH_SDK | 15), "\\Device\\Harddisk10\\Partition15"}, - {"/dev/sdl1", BRACK(FH_SDL | 1), "\\Device\\Harddisk11\\Partition1"}, - {"/dev/sdl2", BRACK(FH_SDL | 2), "\\Device\\Harddisk11\\Partition2"}, - {"/dev/sdl3", BRACK(FH_SDL | 3), "\\Device\\Harddisk11\\Partition3"}, - {"/dev/sdl4", BRACK(FH_SDL | 4), "\\Device\\Harddisk11\\Partition4"}, - {"/dev/sdl5", BRACK(FH_SDL | 5), "\\Device\\Harddisk11\\Partition5"}, - {"/dev/sdl6", BRACK(FH_SDL | 6), "\\Device\\Harddisk11\\Partition6"}, - {"/dev/sdl7", BRACK(FH_SDL | 7), "\\Device\\Harddisk11\\Partition7"}, - {"/dev/sdl8", BRACK(FH_SDL | 8), "\\Device\\Harddisk11\\Partition8"}, - {"/dev/sdl9", BRACK(FH_SDL | 9), "\\Device\\Harddisk11\\Partition9"}, - {"/dev/sdl10", BRACK(FH_SDL | 10), "\\Device\\Harddisk11\\Partition10"}, - {"/dev/sdl11", BRACK(FH_SDL | 11), "\\Device\\Harddisk11\\Partition11"}, - {"/dev/sdl12", BRACK(FH_SDL | 12), "\\Device\\Harddisk11\\Partition12"}, - {"/dev/sdl13", BRACK(FH_SDL | 13), "\\Device\\Harddisk11\\Partition13"}, - {"/dev/sdl14", BRACK(FH_SDL | 14), "\\Device\\Harddisk11\\Partition14"}, - {"/dev/sdl15", BRACK(FH_SDL | 15), "\\Device\\Harddisk11\\Partition15"}, - {"/dev/sdm1", BRACK(FH_SDM | 1), "\\Device\\Harddisk12\\Partition1"}, - {"/dev/sdm2", BRACK(FH_SDM | 2), "\\Device\\Harddisk12\\Partition2"}, - {"/dev/sdm3", BRACK(FH_SDM | 3), "\\Device\\Harddisk12\\Partition3"}, - {"/dev/sdm4", BRACK(FH_SDM | 4), "\\Device\\Harddisk12\\Partition4"}, - {"/dev/sdm5", BRACK(FH_SDM | 5), "\\Device\\Harddisk12\\Partition5"}, - {"/dev/sdm6", BRACK(FH_SDM | 6), "\\Device\\Harddisk12\\Partition6"}, - {"/dev/sdm7", BRACK(FH_SDM | 7), "\\Device\\Harddisk12\\Partition7"}, - {"/dev/sdm8", BRACK(FH_SDM | 8), "\\Device\\Harddisk12\\Partition8"}, - {"/dev/sdm9", BRACK(FH_SDM | 9), "\\Device\\Harddisk12\\Partition9"}, - {"/dev/sdm10", BRACK(FH_SDM | 10), "\\Device\\Harddisk12\\Partition10"}, - {"/dev/sdm11", BRACK(FH_SDM | 11), "\\Device\\Harddisk12\\Partition11"}, - {"/dev/sdm12", BRACK(FH_SDM | 12), "\\Device\\Harddisk12\\Partition12"}, - {"/dev/sdm13", BRACK(FH_SDM | 13), "\\Device\\Harddisk12\\Partition13"}, - {"/dev/sdm14", BRACK(FH_SDM | 14), "\\Device\\Harddisk12\\Partition14"}, - {"/dev/sdm15", BRACK(FH_SDM | 15), "\\Device\\Harddisk12\\Partition15"}, - {"/dev/sdn1", BRACK(FH_SDN | 1), "\\Device\\Harddisk13\\Partition1"}, - {"/dev/sdn2", BRACK(FH_SDN | 2), "\\Device\\Harddisk13\\Partition2"}, - {"/dev/sdn3", BRACK(FH_SDN | 3), "\\Device\\Harddisk13\\Partition3"}, - {"/dev/sdn4", BRACK(FH_SDN | 4), "\\Device\\Harddisk13\\Partition4"}, - {"/dev/sdn5", BRACK(FH_SDN | 5), "\\Device\\Harddisk13\\Partition5"}, - {"/dev/sdn6", BRACK(FH_SDN | 6), "\\Device\\Harddisk13\\Partition6"}, - {"/dev/sdn7", BRACK(FH_SDN | 7), "\\Device\\Harddisk13\\Partition7"}, - {"/dev/sdn8", BRACK(FH_SDN | 8), "\\Device\\Harddisk13\\Partition8"}, - {"/dev/sdn9", BRACK(FH_SDN | 9), "\\Device\\Harddisk13\\Partition9"}, - {"/dev/sdn10", BRACK(FH_SDN | 10), "\\Device\\Harddisk13\\Partition10"}, - {"/dev/sdn11", BRACK(FH_SDN | 11), "\\Device\\Harddisk13\\Partition11"}, - {"/dev/sdn12", BRACK(FH_SDN | 12), "\\Device\\Harddisk13\\Partition12"}, - {"/dev/sdn13", BRACK(FH_SDN | 13), "\\Device\\Harddisk13\\Partition13"}, - {"/dev/sdn14", BRACK(FH_SDN | 14), "\\Device\\Harddisk13\\Partition14"}, - {"/dev/sdn15", BRACK(FH_SDN | 15), "\\Device\\Harddisk13\\Partition15"}, - {"/dev/sdo1", BRACK(FH_SDO | 1), "\\Device\\Harddisk14\\Partition1"}, - {"/dev/sdo2", BRACK(FH_SDO | 2), "\\Device\\Harddisk14\\Partition2"}, - {"/dev/sdo3", BRACK(FH_SDO | 3), "\\Device\\Harddisk14\\Partition3"}, - {"/dev/sdo4", BRACK(FH_SDO | 4), "\\Device\\Harddisk14\\Partition4"}, - {"/dev/sdo5", BRACK(FH_SDO | 5), "\\Device\\Harddisk14\\Partition5"}, - {"/dev/sdo6", BRACK(FH_SDO | 6), "\\Device\\Harddisk14\\Partition6"}, - {"/dev/sdo7", BRACK(FH_SDO | 7), "\\Device\\Harddisk14\\Partition7"}, - {"/dev/sdo8", BRACK(FH_SDO | 8), "\\Device\\Harddisk14\\Partition8"}, - {"/dev/sdo9", BRACK(FH_SDO | 9), "\\Device\\Harddisk14\\Partition9"}, - {"/dev/sdo10", BRACK(FH_SDO | 10), "\\Device\\Harddisk14\\Partition10"}, - {"/dev/sdo11", BRACK(FH_SDO | 11), "\\Device\\Harddisk14\\Partition11"}, - {"/dev/sdo12", BRACK(FH_SDO | 12), "\\Device\\Harddisk14\\Partition12"}, - {"/dev/sdo13", BRACK(FH_SDO | 13), "\\Device\\Harddisk14\\Partition13"}, - {"/dev/sdo14", BRACK(FH_SDO | 14), "\\Device\\Harddisk14\\Partition14"}, - {"/dev/sdo15", BRACK(FH_SDO | 15), "\\Device\\Harddisk14\\Partition15"}, - {"/dev/sdp1", BRACK(FH_SDP | 1), "\\Device\\Harddisk15\\Partition1"}, - {"/dev/sdp2", BRACK(FH_SDP | 2), "\\Device\\Harddisk15\\Partition2"}, - {"/dev/sdp3", BRACK(FH_SDP | 3), "\\Device\\Harddisk15\\Partition3"}, - {"/dev/sdp4", BRACK(FH_SDP | 4), "\\Device\\Harddisk15\\Partition4"}, - {"/dev/sdp5", BRACK(FH_SDP | 5), "\\Device\\Harddisk15\\Partition5"}, - {"/dev/sdp6", BRACK(FH_SDP | 6), "\\Device\\Harddisk15\\Partition6"}, - {"/dev/sdp7", BRACK(FH_SDP | 7), "\\Device\\Harddisk15\\Partition7"}, - {"/dev/sdp8", BRACK(FH_SDP | 8), "\\Device\\Harddisk15\\Partition8"}, - {"/dev/sdp9", BRACK(FH_SDP | 9), "\\Device\\Harddisk15\\Partition9"}, - {"/dev/sdp10", BRACK(FH_SDP | 10), "\\Device\\Harddisk15\\Partition10"}, - {"/dev/sdp11", BRACK(FH_SDP | 11), "\\Device\\Harddisk15\\Partition11"}, - {"/dev/sdp12", BRACK(FH_SDP | 12), "\\Device\\Harddisk15\\Partition12"}, - {"/dev/sdp13", BRACK(FH_SDP | 13), "\\Device\\Harddisk15\\Partition13"}, - {"/dev/sdp14", BRACK(FH_SDP | 14), "\\Device\\Harddisk15\\Partition14"}, - {"/dev/sdp15", BRACK(FH_SDP | 15), "\\Device\\Harddisk15\\Partition15"}, - {"/dev/sdq1", BRACK(FH_SDQ | 1), "\\Device\\Harddisk16\\Partition1"}, - {"/dev/sdq2", BRACK(FH_SDQ | 2), "\\Device\\Harddisk16\\Partition2"}, - {"/dev/sdq3", BRACK(FH_SDQ | 3), "\\Device\\Harddisk16\\Partition3"}, - {"/dev/sdq4", BRACK(FH_SDQ | 4), "\\Device\\Harddisk16\\Partition4"}, - {"/dev/sdq5", BRACK(FH_SDQ | 5), "\\Device\\Harddisk16\\Partition5"}, - {"/dev/sdq6", BRACK(FH_SDQ | 6), "\\Device\\Harddisk16\\Partition6"}, - {"/dev/sdq7", BRACK(FH_SDQ | 7), "\\Device\\Harddisk16\\Partition7"}, - {"/dev/sdq8", BRACK(FH_SDQ | 8), "\\Device\\Harddisk16\\Partition8"}, - {"/dev/sdq9", BRACK(FH_SDQ | 9), "\\Device\\Harddisk16\\Partition9"}, - {"/dev/sdq10", BRACK(FH_SDQ | 10), "\\Device\\Harddisk16\\Partition10"}, - {"/dev/sdq11", BRACK(FH_SDQ | 11), "\\Device\\Harddisk16\\Partition11"}, - {"/dev/sdq12", BRACK(FH_SDQ | 12), "\\Device\\Harddisk16\\Partition12"}, - {"/dev/sdq13", BRACK(FH_SDQ | 13), "\\Device\\Harddisk16\\Partition13"}, - {"/dev/sdq14", BRACK(FH_SDQ | 14), "\\Device\\Harddisk16\\Partition14"}, - {"/dev/sdq15", BRACK(FH_SDQ | 15), "\\Device\\Harddisk16\\Partition15"}, - {"/dev/sdr1", BRACK(FH_SDR | 1), "\\Device\\Harddisk17\\Partition1"}, - {"/dev/sdr2", BRACK(FH_SDR | 2), "\\Device\\Harddisk17\\Partition2"}, - {"/dev/sdr3", BRACK(FH_SDR | 3), "\\Device\\Harddisk17\\Partition3"}, - {"/dev/sdr4", BRACK(FH_SDR | 4), "\\Device\\Harddisk17\\Partition4"}, - {"/dev/sdr5", BRACK(FH_SDR | 5), "\\Device\\Harddisk17\\Partition5"}, - {"/dev/sdr6", BRACK(FH_SDR | 6), "\\Device\\Harddisk17\\Partition6"}, - {"/dev/sdr7", BRACK(FH_SDR | 7), "\\Device\\Harddisk17\\Partition7"}, - {"/dev/sdr8", BRACK(FH_SDR | 8), "\\Device\\Harddisk17\\Partition8"}, - {"/dev/sdr9", BRACK(FH_SDR | 9), "\\Device\\Harddisk17\\Partition9"}, - {"/dev/sdr10", BRACK(FH_SDR | 10), "\\Device\\Harddisk17\\Partition10"}, - {"/dev/sdr11", BRACK(FH_SDR | 11), "\\Device\\Harddisk17\\Partition11"}, - {"/dev/sdr12", BRACK(FH_SDR | 12), "\\Device\\Harddisk17\\Partition12"}, - {"/dev/sdr13", BRACK(FH_SDR | 13), "\\Device\\Harddisk17\\Partition13"}, - {"/dev/sdr14", BRACK(FH_SDR | 14), "\\Device\\Harddisk17\\Partition14"}, - {"/dev/sdr15", BRACK(FH_SDR | 15), "\\Device\\Harddisk17\\Partition15"}, - {"/dev/sds1", BRACK(FH_SDS | 1), "\\Device\\Harddisk18\\Partition1"}, - {"/dev/sds2", BRACK(FH_SDS | 2), "\\Device\\Harddisk18\\Partition2"}, - {"/dev/sds3", BRACK(FH_SDS | 3), "\\Device\\Harddisk18\\Partition3"}, - {"/dev/sds4", BRACK(FH_SDS | 4), "\\Device\\Harddisk18\\Partition4"}, - {"/dev/sds5", BRACK(FH_SDS | 5), "\\Device\\Harddisk18\\Partition5"}, - {"/dev/sds6", BRACK(FH_SDS | 6), "\\Device\\Harddisk18\\Partition6"}, - {"/dev/sds7", BRACK(FH_SDS | 7), "\\Device\\Harddisk18\\Partition7"}, - {"/dev/sds8", BRACK(FH_SDS | 8), "\\Device\\Harddisk18\\Partition8"}, - {"/dev/sds9", BRACK(FH_SDS | 9), "\\Device\\Harddisk18\\Partition9"}, - {"/dev/sds10", BRACK(FH_SDS | 10), "\\Device\\Harddisk18\\Partition10"}, - {"/dev/sds11", BRACK(FH_SDS | 11), "\\Device\\Harddisk18\\Partition11"}, - {"/dev/sds12", BRACK(FH_SDS | 12), "\\Device\\Harddisk18\\Partition12"}, - {"/dev/sds13", BRACK(FH_SDS | 13), "\\Device\\Harddisk18\\Partition13"}, - {"/dev/sds14", BRACK(FH_SDS | 14), "\\Device\\Harddisk18\\Partition14"}, - {"/dev/sds15", BRACK(FH_SDS | 15), "\\Device\\Harddisk18\\Partition15"}, - {"/dev/sdt1", BRACK(FH_SDT | 1), "\\Device\\Harddisk19\\Partition1"}, - {"/dev/sdt2", BRACK(FH_SDT | 2), "\\Device\\Harddisk19\\Partition2"}, - {"/dev/sdt3", BRACK(FH_SDT | 3), "\\Device\\Harddisk19\\Partition3"}, - {"/dev/sdt4", BRACK(FH_SDT | 4), "\\Device\\Harddisk19\\Partition4"}, - {"/dev/sdt5", BRACK(FH_SDT | 5), "\\Device\\Harddisk19\\Partition5"}, - {"/dev/sdt6", BRACK(FH_SDT | 6), "\\Device\\Harddisk19\\Partition6"}, - {"/dev/sdt7", BRACK(FH_SDT | 7), "\\Device\\Harddisk19\\Partition7"}, - {"/dev/sdt8", BRACK(FH_SDT | 8), "\\Device\\Harddisk19\\Partition8"}, - {"/dev/sdt9", BRACK(FH_SDT | 9), "\\Device\\Harddisk19\\Partition9"}, - {"/dev/sdt10", BRACK(FH_SDT | 10), "\\Device\\Harddisk19\\Partition10"}, - {"/dev/sdt11", BRACK(FH_SDT | 11), "\\Device\\Harddisk19\\Partition11"}, - {"/dev/sdt12", BRACK(FH_SDT | 12), "\\Device\\Harddisk19\\Partition12"}, - {"/dev/sdt13", BRACK(FH_SDT | 13), "\\Device\\Harddisk19\\Partition13"}, - {"/dev/sdt14", BRACK(FH_SDT | 14), "\\Device\\Harddisk19\\Partition14"}, - {"/dev/sdt15", BRACK(FH_SDT | 15), "\\Device\\Harddisk19\\Partition15"}, - {"/dev/sdu1", BRACK(FH_SDU | 1), "\\Device\\Harddisk20\\Partition1"}, - {"/dev/sdu2", BRACK(FH_SDU | 2), "\\Device\\Harddisk20\\Partition2"}, - {"/dev/sdu3", BRACK(FH_SDU | 3), "\\Device\\Harddisk20\\Partition3"}, - {"/dev/sdu4", BRACK(FH_SDU | 4), "\\Device\\Harddisk20\\Partition4"}, - {"/dev/sdu5", BRACK(FH_SDU | 5), "\\Device\\Harddisk20\\Partition5"}, - {"/dev/sdu6", BRACK(FH_SDU | 6), "\\Device\\Harddisk20\\Partition6"}, - {"/dev/sdu7", BRACK(FH_SDU | 7), "\\Device\\Harddisk20\\Partition7"}, - {"/dev/sdu8", BRACK(FH_SDU | 8), "\\Device\\Harddisk20\\Partition8"}, - {"/dev/sdu9", BRACK(FH_SDU | 9), "\\Device\\Harddisk20\\Partition9"}, - {"/dev/sdu10", BRACK(FH_SDU | 10), "\\Device\\Harddisk20\\Partition10"}, - {"/dev/sdu11", BRACK(FH_SDU | 11), "\\Device\\Harddisk20\\Partition11"}, - {"/dev/sdu12", BRACK(FH_SDU | 12), "\\Device\\Harddisk20\\Partition12"}, - {"/dev/sdu13", BRACK(FH_SDU | 13), "\\Device\\Harddisk20\\Partition13"}, - {"/dev/sdu14", BRACK(FH_SDU | 14), "\\Device\\Harddisk20\\Partition14"}, - {"/dev/sdu15", BRACK(FH_SDU | 15), "\\Device\\Harddisk20\\Partition15"}, - {"/dev/sdv1", BRACK(FH_SDV | 1), "\\Device\\Harddisk21\\Partition1"}, - {"/dev/sdv2", BRACK(FH_SDV | 2), "\\Device\\Harddisk21\\Partition2"}, - {"/dev/sdv3", BRACK(FH_SDV | 3), "\\Device\\Harddisk21\\Partition3"}, - {"/dev/sdv4", BRACK(FH_SDV | 4), "\\Device\\Harddisk21\\Partition4"}, - {"/dev/sdv5", BRACK(FH_SDV | 5), "\\Device\\Harddisk21\\Partition5"}, - {"/dev/sdv6", BRACK(FH_SDV | 6), "\\Device\\Harddisk21\\Partition6"}, - {"/dev/sdv7", BRACK(FH_SDV | 7), "\\Device\\Harddisk21\\Partition7"}, - {"/dev/sdv8", BRACK(FH_SDV | 8), "\\Device\\Harddisk21\\Partition8"}, - {"/dev/sdv9", BRACK(FH_SDV | 9), "\\Device\\Harddisk21\\Partition9"}, - {"/dev/sdv10", BRACK(FH_SDV | 10), "\\Device\\Harddisk21\\Partition10"}, - {"/dev/sdv11", BRACK(FH_SDV | 11), "\\Device\\Harddisk21\\Partition11"}, - {"/dev/sdv12", BRACK(FH_SDV | 12), "\\Device\\Harddisk21\\Partition12"}, - {"/dev/sdv13", BRACK(FH_SDV | 13), "\\Device\\Harddisk21\\Partition13"}, - {"/dev/sdv14", BRACK(FH_SDV | 14), "\\Device\\Harddisk21\\Partition14"}, - {"/dev/sdv15", BRACK(FH_SDV | 15), "\\Device\\Harddisk21\\Partition15"}, - {"/dev/sdw1", BRACK(FH_SDW | 1), "\\Device\\Harddisk22\\Partition1"}, - {"/dev/sdw2", BRACK(FH_SDW | 2), "\\Device\\Harddisk22\\Partition2"}, - {"/dev/sdw3", BRACK(FH_SDW | 3), "\\Device\\Harddisk22\\Partition3"}, - {"/dev/sdw4", BRACK(FH_SDW | 4), "\\Device\\Harddisk22\\Partition4"}, - {"/dev/sdw5", BRACK(FH_SDW | 5), "\\Device\\Harddisk22\\Partition5"}, - {"/dev/sdw6", BRACK(FH_SDW | 6), "\\Device\\Harddisk22\\Partition6"}, - {"/dev/sdw7", BRACK(FH_SDW | 7), "\\Device\\Harddisk22\\Partition7"}, - {"/dev/sdw8", BRACK(FH_SDW | 8), "\\Device\\Harddisk22\\Partition8"}, - {"/dev/sdw9", BRACK(FH_SDW | 9), "\\Device\\Harddisk22\\Partition9"}, - {"/dev/sdw10", BRACK(FH_SDW | 10), "\\Device\\Harddisk22\\Partition10"}, - {"/dev/sdw11", BRACK(FH_SDW | 11), "\\Device\\Harddisk22\\Partition11"}, - {"/dev/sdw12", BRACK(FH_SDW | 12), "\\Device\\Harddisk22\\Partition12"}, - {"/dev/sdw13", BRACK(FH_SDW | 13), "\\Device\\Harddisk22\\Partition13"}, - {"/dev/sdw14", BRACK(FH_SDW | 14), "\\Device\\Harddisk22\\Partition14"}, - {"/dev/sdw15", BRACK(FH_SDW | 15), "\\Device\\Harddisk22\\Partition15"}, - {"/dev/sdx1", BRACK(FH_SDX | 1), "\\Device\\Harddisk23\\Partition1"}, - {"/dev/sdx2", BRACK(FH_SDX | 2), "\\Device\\Harddisk23\\Partition2"}, - {"/dev/sdx3", BRACK(FH_SDX | 3), "\\Device\\Harddisk23\\Partition3"}, - {"/dev/sdx4", BRACK(FH_SDX | 4), "\\Device\\Harddisk23\\Partition4"}, - {"/dev/sdx5", BRACK(FH_SDX | 5), "\\Device\\Harddisk23\\Partition5"}, - {"/dev/sdx6", BRACK(FH_SDX | 6), "\\Device\\Harddisk23\\Partition6"}, - {"/dev/sdx7", BRACK(FH_SDX | 7), "\\Device\\Harddisk23\\Partition7"}, - {"/dev/sdx8", BRACK(FH_SDX | 8), "\\Device\\Harddisk23\\Partition8"}, - {"/dev/sdx9", BRACK(FH_SDX | 9), "\\Device\\Harddisk23\\Partition9"}, - {"/dev/sdx10", BRACK(FH_SDX | 10), "\\Device\\Harddisk23\\Partition10"}, - {"/dev/sdx11", BRACK(FH_SDX | 11), "\\Device\\Harddisk23\\Partition11"}, - {"/dev/sdx12", BRACK(FH_SDX | 12), "\\Device\\Harddisk23\\Partition12"}, - {"/dev/sdx13", BRACK(FH_SDX | 13), "\\Device\\Harddisk23\\Partition13"}, - {"/dev/sdx14", BRACK(FH_SDX | 14), "\\Device\\Harddisk23\\Partition14"}, - {"/dev/sdx15", BRACK(FH_SDX | 15), "\\Device\\Harddisk23\\Partition15"}, - {"/dev/sdy1", BRACK(FH_SDY | 1), "\\Device\\Harddisk24\\Partition1"}, - {"/dev/sdy2", BRACK(FH_SDY | 2), "\\Device\\Harddisk24\\Partition2"}, - {"/dev/sdy3", BRACK(FH_SDY | 3), "\\Device\\Harddisk24\\Partition3"}, - {"/dev/sdy4", BRACK(FH_SDY | 4), "\\Device\\Harddisk24\\Partition4"}, - {"/dev/sdy5", BRACK(FH_SDY | 5), "\\Device\\Harddisk24\\Partition5"}, - {"/dev/sdy6", BRACK(FH_SDY | 6), "\\Device\\Harddisk24\\Partition6"}, - {"/dev/sdy7", BRACK(FH_SDY | 7), "\\Device\\Harddisk24\\Partition7"}, - {"/dev/sdy8", BRACK(FH_SDY | 8), "\\Device\\Harddisk24\\Partition8"}, - {"/dev/sdy9", BRACK(FH_SDY | 9), "\\Device\\Harddisk24\\Partition9"}, - {"/dev/sdy10", BRACK(FH_SDY | 10), "\\Device\\Harddisk24\\Partition10"}, - {"/dev/sdy11", BRACK(FH_SDY | 11), "\\Device\\Harddisk24\\Partition11"}, - {"/dev/sdy12", BRACK(FH_SDY | 12), "\\Device\\Harddisk24\\Partition12"}, - {"/dev/sdy13", BRACK(FH_SDY | 13), "\\Device\\Harddisk24\\Partition13"}, - {"/dev/sdy14", BRACK(FH_SDY | 14), "\\Device\\Harddisk24\\Partition14"}, - {"/dev/sdy15", BRACK(FH_SDY | 15), "\\Device\\Harddisk24\\Partition15"}, - {"/dev/sdz1", BRACK(FH_SDZ | 1), "\\Device\\Harddisk25\\Partition1"}, - {"/dev/sdz2", BRACK(FH_SDZ | 2), "\\Device\\Harddisk25\\Partition2"}, - {"/dev/sdz3", BRACK(FH_SDZ | 3), "\\Device\\Harddisk25\\Partition3"}, - {"/dev/sdz4", BRACK(FH_SDZ | 4), "\\Device\\Harddisk25\\Partition4"}, - {"/dev/sdz5", BRACK(FH_SDZ | 5), "\\Device\\Harddisk25\\Partition5"}, - {"/dev/sdz6", BRACK(FH_SDZ | 6), "\\Device\\Harddisk25\\Partition6"}, - {"/dev/sdz7", BRACK(FH_SDZ | 7), "\\Device\\Harddisk25\\Partition7"}, - {"/dev/sdz8", BRACK(FH_SDZ | 8), "\\Device\\Harddisk25\\Partition8"}, - {"/dev/sdz9", BRACK(FH_SDZ | 9), "\\Device\\Harddisk25\\Partition9"}, - {"/dev/sdz10", BRACK(FH_SDZ | 10), "\\Device\\Harddisk25\\Partition10"}, - {"/dev/sdz11", BRACK(FH_SDZ | 11), "\\Device\\Harddisk25\\Partition11"}, - {"/dev/sdz12", BRACK(FH_SDZ | 12), "\\Device\\Harddisk25\\Partition12"}, - {"/dev/sdz13", BRACK(FH_SDZ | 13), "\\Device\\Harddisk25\\Partition13"}, - {"/dev/sdz14", BRACK(FH_SDZ | 14), "\\Device\\Harddisk25\\Partition14"}, - {"/dev/sdz15", BRACK(FH_SDZ | 15), "\\Device\\Harddisk25\\Partition15"}, - {"/dev/sdaa", BRACK(FH_SDAA), "\\Device\\Harddisk26\\Partition0"}, - {"/dev/sdab", BRACK(FH_SDAB), "\\Device\\Harddisk27\\Partition0"}, - {"/dev/sdac", BRACK(FH_SDAC), "\\Device\\Harddisk28\\Partition0"}, - {"/dev/sdad", BRACK(FH_SDAD), "\\Device\\Harddisk29\\Partition0"}, - {"/dev/sdae", BRACK(FH_SDAE), "\\Device\\Harddisk30\\Partition0"}, - {"/dev/sdaf", BRACK(FH_SDAF), "\\Device\\Harddisk31\\Partition0"}, - {"/dev/sdag", BRACK(FH_SDAG), "\\Device\\Harddisk32\\Partition0"}, - {"/dev/sdah", BRACK(FH_SDAH), "\\Device\\Harddisk33\\Partition0"}, - {"/dev/sdai", BRACK(FH_SDAI), "\\Device\\Harddisk34\\Partition0"}, - {"/dev/sdaj", BRACK(FH_SDAJ), "\\Device\\Harddisk35\\Partition0"}, - {"/dev/sdak", BRACK(FH_SDAK), "\\Device\\Harddisk36\\Partition0"}, - {"/dev/sdal", BRACK(FH_SDAL), "\\Device\\Harddisk37\\Partition0"}, - {"/dev/sdam", BRACK(FH_SDAM), "\\Device\\Harddisk38\\Partition0"}, - {"/dev/sdan", BRACK(FH_SDAN), "\\Device\\Harddisk39\\Partition0"}, - {"/dev/sdao", BRACK(FH_SDAO), "\\Device\\Harddisk40\\Partition0"}, - {"/dev/sdap", BRACK(FH_SDAP), "\\Device\\Harddisk41\\Partition0"}, - {"/dev/sdaq", BRACK(FH_SDAQ), "\\Device\\Harddisk42\\Partition0"}, - {"/dev/sdar", BRACK(FH_SDAR), "\\Device\\Harddisk43\\Partition0"}, - {"/dev/sdas", BRACK(FH_SDAS), "\\Device\\Harddisk44\\Partition0"}, - {"/dev/sdat", BRACK(FH_SDAT), "\\Device\\Harddisk45\\Partition0"}, - {"/dev/sdau", BRACK(FH_SDAU), "\\Device\\Harddisk46\\Partition0"}, - {"/dev/sdav", BRACK(FH_SDAV), "\\Device\\Harddisk47\\Partition0"}, - {"/dev/sdaw", BRACK(FH_SDAW), "\\Device\\Harddisk48\\Partition0"}, - {"/dev/sdax", BRACK(FH_SDAX), "\\Device\\Harddisk49\\Partition0"}, - {"/dev/sday", BRACK(FH_SDAY), "\\Device\\Harddisk50\\Partition0"}, - {"/dev/sdaz", BRACK(FH_SDAZ), "\\Device\\Harddisk51\\Partition0"}, - {"/dev/sdaa1", BRACK(FH_SDAA | 1), "\\Device\\Harddisk26\\Partition1"}, - {"/dev/sdaa2", BRACK(FH_SDAA | 2), "\\Device\\Harddisk26\\Partition2"}, - {"/dev/sdaa3", BRACK(FH_SDAA | 3), "\\Device\\Harddisk26\\Partition3"}, - {"/dev/sdaa4", BRACK(FH_SDAA | 4), "\\Device\\Harddisk26\\Partition4"}, - {"/dev/sdaa5", BRACK(FH_SDAA | 5), "\\Device\\Harddisk26\\Partition5"}, - {"/dev/sdaa6", BRACK(FH_SDAA | 6), "\\Device\\Harddisk26\\Partition6"}, - {"/dev/sdaa7", BRACK(FH_SDAA | 7), "\\Device\\Harddisk26\\Partition7"}, - {"/dev/sdaa8", BRACK(FH_SDAA | 8), "\\Device\\Harddisk26\\Partition8"}, - {"/dev/sdaa9", BRACK(FH_SDAA | 9), "\\Device\\Harddisk26\\Partition9"}, - {"/dev/sdaa10", BRACK(FH_SDAA | 10), "\\Device\\Harddisk26\\Partition10"}, - {"/dev/sdaa11", BRACK(FH_SDAA | 11), "\\Device\\Harddisk26\\Partition11"}, - {"/dev/sdaa12", BRACK(FH_SDAA | 12), "\\Device\\Harddisk26\\Partition12"}, - {"/dev/sdaa13", BRACK(FH_SDAA | 13), "\\Device\\Harddisk26\\Partition13"}, - {"/dev/sdaa14", BRACK(FH_SDAA | 14), "\\Device\\Harddisk26\\Partition14"}, - {"/dev/sdaa15", BRACK(FH_SDAA | 15), "\\Device\\Harddisk26\\Partition15"}, - {"/dev/sdab1", BRACK(FH_SDAB | 1), "\\Device\\Harddisk27\\Partition1"}, - {"/dev/sdab2", BRACK(FH_SDAB | 2), "\\Device\\Harddisk27\\Partition2"}, - {"/dev/sdab3", BRACK(FH_SDAB | 3), "\\Device\\Harddisk27\\Partition3"}, - {"/dev/sdab4", BRACK(FH_SDAB | 4), "\\Device\\Harddisk27\\Partition4"}, - {"/dev/sdab5", BRACK(FH_SDAB | 5), "\\Device\\Harddisk27\\Partition5"}, - {"/dev/sdab6", BRACK(FH_SDAB | 6), "\\Device\\Harddisk27\\Partition6"}, - {"/dev/sdab7", BRACK(FH_SDAB | 7), "\\Device\\Harddisk27\\Partition7"}, - {"/dev/sdab8", BRACK(FH_SDAB | 8), "\\Device\\Harddisk27\\Partition8"}, - {"/dev/sdab9", BRACK(FH_SDAB | 9), "\\Device\\Harddisk27\\Partition9"}, - {"/dev/sdab10", BRACK(FH_SDAB | 10), "\\Device\\Harddisk27\\Partition10"}, - {"/dev/sdab11", BRACK(FH_SDAB | 11), "\\Device\\Harddisk27\\Partition11"}, - {"/dev/sdab12", BRACK(FH_SDAB | 12), "\\Device\\Harddisk27\\Partition12"}, - {"/dev/sdab13", BRACK(FH_SDAB | 13), "\\Device\\Harddisk27\\Partition13"}, - {"/dev/sdab14", BRACK(FH_SDAB | 14), "\\Device\\Harddisk27\\Partition14"}, - {"/dev/sdab15", BRACK(FH_SDAB | 15), "\\Device\\Harddisk27\\Partition15"}, - {"/dev/sdac1", BRACK(FH_SDAC | 1), "\\Device\\Harddisk28\\Partition1"}, - {"/dev/sdac2", BRACK(FH_SDAC | 2), "\\Device\\Harddisk28\\Partition2"}, - {"/dev/sdac3", BRACK(FH_SDAC | 3), "\\Device\\Harddisk28\\Partition3"}, - {"/dev/sdac4", BRACK(FH_SDAC | 4), "\\Device\\Harddisk28\\Partition4"}, - {"/dev/sdac5", BRACK(FH_SDAC | 5), "\\Device\\Harddisk28\\Partition5"}, - {"/dev/sdac6", BRACK(FH_SDAC | 6), "\\Device\\Harddisk28\\Partition6"}, - {"/dev/sdac7", BRACK(FH_SDAC | 7), "\\Device\\Harddisk28\\Partition7"}, - {"/dev/sdac8", BRACK(FH_SDAC | 8), "\\Device\\Harddisk28\\Partition8"}, - {"/dev/sdac9", BRACK(FH_SDAC | 9), "\\Device\\Harddisk28\\Partition9"}, - {"/dev/sdac10", BRACK(FH_SDAC | 10), "\\Device\\Harddisk28\\Partition10"}, - {"/dev/sdac11", BRACK(FH_SDAC | 11), "\\Device\\Harddisk28\\Partition11"}, - {"/dev/sdac12", BRACK(FH_SDAC | 12), "\\Device\\Harddisk28\\Partition12"}, - {"/dev/sdac13", BRACK(FH_SDAC | 13), "\\Device\\Harddisk28\\Partition13"}, - {"/dev/sdac14", BRACK(FH_SDAC | 14), "\\Device\\Harddisk28\\Partition14"}, - {"/dev/sdac15", BRACK(FH_SDAC | 15), "\\Device\\Harddisk28\\Partition15"}, - {"/dev/sdad1", BRACK(FH_SDAD | 1), "\\Device\\Harddisk29\\Partition1"}, - {"/dev/sdad2", BRACK(FH_SDAD | 2), "\\Device\\Harddisk29\\Partition2"}, - {"/dev/sdad3", BRACK(FH_SDAD | 3), "\\Device\\Harddisk29\\Partition3"}, - {"/dev/sdad4", BRACK(FH_SDAD | 4), "\\Device\\Harddisk29\\Partition4"}, - {"/dev/sdad5", BRACK(FH_SDAD | 5), "\\Device\\Harddisk29\\Partition5"}, - {"/dev/sdad6", BRACK(FH_SDAD | 6), "\\Device\\Harddisk29\\Partition6"}, - {"/dev/sdad7", BRACK(FH_SDAD | 7), "\\Device\\Harddisk29\\Partition7"}, - {"/dev/sdad8", BRACK(FH_SDAD | 8), "\\Device\\Harddisk29\\Partition8"}, - {"/dev/sdad9", BRACK(FH_SDAD | 9), "\\Device\\Harddisk29\\Partition9"}, - {"/dev/sdad10", BRACK(FH_SDAD | 10), "\\Device\\Harddisk29\\Partition10"}, - {"/dev/sdad11", BRACK(FH_SDAD | 11), "\\Device\\Harddisk29\\Partition11"}, - {"/dev/sdad12", BRACK(FH_SDAD | 12), "\\Device\\Harddisk29\\Partition12"}, - {"/dev/sdad13", BRACK(FH_SDAD | 13), "\\Device\\Harddisk29\\Partition13"}, - {"/dev/sdad14", BRACK(FH_SDAD | 14), "\\Device\\Harddisk29\\Partition14"}, - {"/dev/sdad15", BRACK(FH_SDAD | 15), "\\Device\\Harddisk29\\Partition15"}, - {"/dev/sdae1", BRACK(FH_SDAE | 1), "\\Device\\Harddisk30\\Partition1"}, - {"/dev/sdae2", BRACK(FH_SDAE | 2), "\\Device\\Harddisk30\\Partition2"}, - {"/dev/sdae3", BRACK(FH_SDAE | 3), "\\Device\\Harddisk30\\Partition3"}, - {"/dev/sdae4", BRACK(FH_SDAE | 4), "\\Device\\Harddisk30\\Partition4"}, - {"/dev/sdae5", BRACK(FH_SDAE | 5), "\\Device\\Harddisk30\\Partition5"}, - {"/dev/sdae6", BRACK(FH_SDAE | 6), "\\Device\\Harddisk30\\Partition6"}, - {"/dev/sdae7", BRACK(FH_SDAE | 7), "\\Device\\Harddisk30\\Partition7"}, - {"/dev/sdae8", BRACK(FH_SDAE | 8), "\\Device\\Harddisk30\\Partition8"}, - {"/dev/sdae9", BRACK(FH_SDAE | 9), "\\Device\\Harddisk30\\Partition9"}, - {"/dev/sdae10", BRACK(FH_SDAE | 10), "\\Device\\Harddisk30\\Partition10"}, - {"/dev/sdae11", BRACK(FH_SDAE | 11), "\\Device\\Harddisk30\\Partition11"}, - {"/dev/sdae12", BRACK(FH_SDAE | 12), "\\Device\\Harddisk30\\Partition12"}, - {"/dev/sdae13", BRACK(FH_SDAE | 13), "\\Device\\Harddisk30\\Partition13"}, - {"/dev/sdae14", BRACK(FH_SDAE | 14), "\\Device\\Harddisk30\\Partition14"}, - {"/dev/sdae15", BRACK(FH_SDAE | 15), "\\Device\\Harddisk30\\Partition15"}, - {"/dev/sdaf1", BRACK(FH_SDAF | 1), "\\Device\\Harddisk31\\Partition1"}, - {"/dev/sdaf2", BRACK(FH_SDAF | 2), "\\Device\\Harddisk31\\Partition2"}, - {"/dev/sdaf3", BRACK(FH_SDAF | 3), "\\Device\\Harddisk31\\Partition3"}, - {"/dev/sdaf4", BRACK(FH_SDAF | 4), "\\Device\\Harddisk31\\Partition4"}, - {"/dev/sdaf5", BRACK(FH_SDAF | 5), "\\Device\\Harddisk31\\Partition5"}, - {"/dev/sdaf6", BRACK(FH_SDAF | 6), "\\Device\\Harddisk31\\Partition6"}, - {"/dev/sdaf7", BRACK(FH_SDAF | 7), "\\Device\\Harddisk31\\Partition7"}, - {"/dev/sdaf8", BRACK(FH_SDAF | 8), "\\Device\\Harddisk31\\Partition8"}, - {"/dev/sdaf9", BRACK(FH_SDAF | 9), "\\Device\\Harddisk31\\Partition9"}, - {"/dev/sdaf10", BRACK(FH_SDAF | 10), "\\Device\\Harddisk31\\Partition10"}, - {"/dev/sdaf11", BRACK(FH_SDAF | 11), "\\Device\\Harddisk31\\Partition11"}, - {"/dev/sdaf12", BRACK(FH_SDAF | 12), "\\Device\\Harddisk31\\Partition12"}, - {"/dev/sdaf13", BRACK(FH_SDAF | 13), "\\Device\\Harddisk31\\Partition13"}, - {"/dev/sdaf14", BRACK(FH_SDAF | 14), "\\Device\\Harddisk31\\Partition14"}, - {"/dev/sdaf15", BRACK(FH_SDAF | 15), "\\Device\\Harddisk31\\Partition15"}, - {"/dev/sdag1", BRACK(FH_SDAG | 1), "\\Device\\Harddisk32\\Partition1"}, - {"/dev/sdag2", BRACK(FH_SDAG | 2), "\\Device\\Harddisk32\\Partition2"}, - {"/dev/sdag3", BRACK(FH_SDAG | 3), "\\Device\\Harddisk32\\Partition3"}, - {"/dev/sdag4", BRACK(FH_SDAG | 4), "\\Device\\Harddisk32\\Partition4"}, - {"/dev/sdag5", BRACK(FH_SDAG | 5), "\\Device\\Harddisk32\\Partition5"}, - {"/dev/sdag6", BRACK(FH_SDAG | 6), "\\Device\\Harddisk32\\Partition6"}, - {"/dev/sdag7", BRACK(FH_SDAG | 7), "\\Device\\Harddisk32\\Partition7"}, - {"/dev/sdag8", BRACK(FH_SDAG | 8), "\\Device\\Harddisk32\\Partition8"}, - {"/dev/sdag9", BRACK(FH_SDAG | 9), "\\Device\\Harddisk32\\Partition9"}, - {"/dev/sdag10", BRACK(FH_SDAG | 10), "\\Device\\Harddisk32\\Partition10"}, - {"/dev/sdag11", BRACK(FH_SDAG | 11), "\\Device\\Harddisk32\\Partition11"}, - {"/dev/sdag12", BRACK(FH_SDAG | 12), "\\Device\\Harddisk32\\Partition12"}, - {"/dev/sdag13", BRACK(FH_SDAG | 13), "\\Device\\Harddisk32\\Partition13"}, - {"/dev/sdag14", BRACK(FH_SDAG | 14), "\\Device\\Harddisk32\\Partition14"}, - {"/dev/sdag15", BRACK(FH_SDAG | 15), "\\Device\\Harddisk32\\Partition15"}, - {"/dev/sdah1", BRACK(FH_SDAH | 1), "\\Device\\Harddisk33\\Partition1"}, - {"/dev/sdah2", BRACK(FH_SDAH | 2), "\\Device\\Harddisk33\\Partition2"}, - {"/dev/sdah3", BRACK(FH_SDAH | 3), "\\Device\\Harddisk33\\Partition3"}, - {"/dev/sdah4", BRACK(FH_SDAH | 4), "\\Device\\Harddisk33\\Partition4"}, - {"/dev/sdah5", BRACK(FH_SDAH | 5), "\\Device\\Harddisk33\\Partition5"}, - {"/dev/sdah6", BRACK(FH_SDAH | 6), "\\Device\\Harddisk33\\Partition6"}, - {"/dev/sdah7", BRACK(FH_SDAH | 7), "\\Device\\Harddisk33\\Partition7"}, - {"/dev/sdah8", BRACK(FH_SDAH | 8), "\\Device\\Harddisk33\\Partition8"}, - {"/dev/sdah9", BRACK(FH_SDAH | 9), "\\Device\\Harddisk33\\Partition9"}, - {"/dev/sdah10", BRACK(FH_SDAH | 10), "\\Device\\Harddisk33\\Partition10"}, - {"/dev/sdah11", BRACK(FH_SDAH | 11), "\\Device\\Harddisk33\\Partition11"}, - {"/dev/sdah12", BRACK(FH_SDAH | 12), "\\Device\\Harddisk33\\Partition12"}, - {"/dev/sdah13", BRACK(FH_SDAH | 13), "\\Device\\Harddisk33\\Partition13"}, - {"/dev/sdah14", BRACK(FH_SDAH | 14), "\\Device\\Harddisk33\\Partition14"}, - {"/dev/sdah15", BRACK(FH_SDAH | 15), "\\Device\\Harddisk33\\Partition15"}, - {"/dev/sdai1", BRACK(FH_SDAI | 1), "\\Device\\Harddisk34\\Partition1"}, - {"/dev/sdai2", BRACK(FH_SDAI | 2), "\\Device\\Harddisk34\\Partition2"}, - {"/dev/sdai3", BRACK(FH_SDAI | 3), "\\Device\\Harddisk34\\Partition3"}, - {"/dev/sdai4", BRACK(FH_SDAI | 4), "\\Device\\Harddisk34\\Partition4"}, - {"/dev/sdai5", BRACK(FH_SDAI | 5), "\\Device\\Harddisk34\\Partition5"}, - {"/dev/sdai6", BRACK(FH_SDAI | 6), "\\Device\\Harddisk34\\Partition6"}, - {"/dev/sdai7", BRACK(FH_SDAI | 7), "\\Device\\Harddisk34\\Partition7"}, - {"/dev/sdai8", BRACK(FH_SDAI | 8), "\\Device\\Harddisk34\\Partition8"}, - {"/dev/sdai9", BRACK(FH_SDAI | 9), "\\Device\\Harddisk34\\Partition9"}, - {"/dev/sdai10", BRACK(FH_SDAI | 10), "\\Device\\Harddisk34\\Partition10"}, - {"/dev/sdai11", BRACK(FH_SDAI | 11), "\\Device\\Harddisk34\\Partition11"}, - {"/dev/sdai12", BRACK(FH_SDAI | 12), "\\Device\\Harddisk34\\Partition12"}, - {"/dev/sdai13", BRACK(FH_SDAI | 13), "\\Device\\Harddisk34\\Partition13"}, - {"/dev/sdai14", BRACK(FH_SDAI | 14), "\\Device\\Harddisk34\\Partition14"}, - {"/dev/sdai15", BRACK(FH_SDAI | 15), "\\Device\\Harddisk34\\Partition15"}, - {"/dev/sdaj1", BRACK(FH_SDAJ | 1), "\\Device\\Harddisk35\\Partition1"}, - {"/dev/sdaj2", BRACK(FH_SDAJ | 2), "\\Device\\Harddisk35\\Partition2"}, - {"/dev/sdaj3", BRACK(FH_SDAJ | 3), "\\Device\\Harddisk35\\Partition3"}, - {"/dev/sdaj4", BRACK(FH_SDAJ | 4), "\\Device\\Harddisk35\\Partition4"}, - {"/dev/sdaj5", BRACK(FH_SDAJ | 5), "\\Device\\Harddisk35\\Partition5"}, - {"/dev/sdaj6", BRACK(FH_SDAJ | 6), "\\Device\\Harddisk35\\Partition6"}, - {"/dev/sdaj7", BRACK(FH_SDAJ | 7), "\\Device\\Harddisk35\\Partition7"}, - {"/dev/sdaj8", BRACK(FH_SDAJ | 8), "\\Device\\Harddisk35\\Partition8"}, - {"/dev/sdaj9", BRACK(FH_SDAJ | 9), "\\Device\\Harddisk35\\Partition9"}, - {"/dev/sdaj10", BRACK(FH_SDAJ | 10), "\\Device\\Harddisk35\\Partition10"}, - {"/dev/sdaj11", BRACK(FH_SDAJ | 11), "\\Device\\Harddisk35\\Partition11"}, - {"/dev/sdaj12", BRACK(FH_SDAJ | 12), "\\Device\\Harddisk35\\Partition12"}, - {"/dev/sdaj13", BRACK(FH_SDAJ | 13), "\\Device\\Harddisk35\\Partition13"}, - {"/dev/sdaj14", BRACK(FH_SDAJ | 14), "\\Device\\Harddisk35\\Partition14"}, - {"/dev/sdaj15", BRACK(FH_SDAJ | 15), "\\Device\\Harddisk35\\Partition15"}, - {"/dev/sdak1", BRACK(FH_SDAK | 1), "\\Device\\Harddisk36\\Partition1"}, - {"/dev/sdak2", BRACK(FH_SDAK | 2), "\\Device\\Harddisk36\\Partition2"}, - {"/dev/sdak3", BRACK(FH_SDAK | 3), "\\Device\\Harddisk36\\Partition3"}, - {"/dev/sdak4", BRACK(FH_SDAK | 4), "\\Device\\Harddisk36\\Partition4"}, - {"/dev/sdak5", BRACK(FH_SDAK | 5), "\\Device\\Harddisk36\\Partition5"}, - {"/dev/sdak6", BRACK(FH_SDAK | 6), "\\Device\\Harddisk36\\Partition6"}, - {"/dev/sdak7", BRACK(FH_SDAK | 7), "\\Device\\Harddisk36\\Partition7"}, - {"/dev/sdak8", BRACK(FH_SDAK | 8), "\\Device\\Harddisk36\\Partition8"}, - {"/dev/sdak9", BRACK(FH_SDAK | 9), "\\Device\\Harddisk36\\Partition9"}, - {"/dev/sdak10", BRACK(FH_SDAK | 10), "\\Device\\Harddisk36\\Partition10"}, - {"/dev/sdak11", BRACK(FH_SDAK | 11), "\\Device\\Harddisk36\\Partition11"}, - {"/dev/sdak12", BRACK(FH_SDAK | 12), "\\Device\\Harddisk36\\Partition12"}, - {"/dev/sdak13", BRACK(FH_SDAK | 13), "\\Device\\Harddisk36\\Partition13"}, - {"/dev/sdak14", BRACK(FH_SDAK | 14), "\\Device\\Harddisk36\\Partition14"}, - {"/dev/sdak15", BRACK(FH_SDAK | 15), "\\Device\\Harddisk36\\Partition15"}, - {"/dev/sdal1", BRACK(FH_SDAL | 1), "\\Device\\Harddisk37\\Partition1"}, - {"/dev/sdal2", BRACK(FH_SDAL | 2), "\\Device\\Harddisk37\\Partition2"}, - {"/dev/sdal3", BRACK(FH_SDAL | 3), "\\Device\\Harddisk37\\Partition3"}, - {"/dev/sdal4", BRACK(FH_SDAL | 4), "\\Device\\Harddisk37\\Partition4"}, - {"/dev/sdal5", BRACK(FH_SDAL | 5), "\\Device\\Harddisk37\\Partition5"}, - {"/dev/sdal6", BRACK(FH_SDAL | 6), "\\Device\\Harddisk37\\Partition6"}, - {"/dev/sdal7", BRACK(FH_SDAL | 7), "\\Device\\Harddisk37\\Partition7"}, - {"/dev/sdal8", BRACK(FH_SDAL | 8), "\\Device\\Harddisk37\\Partition8"}, - {"/dev/sdal9", BRACK(FH_SDAL | 9), "\\Device\\Harddisk37\\Partition9"}, - {"/dev/sdal10", BRACK(FH_SDAL | 10), "\\Device\\Harddisk37\\Partition10"}, - {"/dev/sdal11", BRACK(FH_SDAL | 11), "\\Device\\Harddisk37\\Partition11"}, - {"/dev/sdal12", BRACK(FH_SDAL | 12), "\\Device\\Harddisk37\\Partition12"}, - {"/dev/sdal13", BRACK(FH_SDAL | 13), "\\Device\\Harddisk37\\Partition13"}, - {"/dev/sdal14", BRACK(FH_SDAL | 14), "\\Device\\Harddisk37\\Partition14"}, - {"/dev/sdal15", BRACK(FH_SDAL | 15), "\\Device\\Harddisk37\\Partition15"}, - {"/dev/sdam1", BRACK(FH_SDAM | 1), "\\Device\\Harddisk38\\Partition1"}, - {"/dev/sdam2", BRACK(FH_SDAM | 2), "\\Device\\Harddisk38\\Partition2"}, - {"/dev/sdam3", BRACK(FH_SDAM | 3), "\\Device\\Harddisk38\\Partition3"}, - {"/dev/sdam4", BRACK(FH_SDAM | 4), "\\Device\\Harddisk38\\Partition4"}, - {"/dev/sdam5", BRACK(FH_SDAM | 5), "\\Device\\Harddisk38\\Partition5"}, - {"/dev/sdam6", BRACK(FH_SDAM | 6), "\\Device\\Harddisk38\\Partition6"}, - {"/dev/sdam7", BRACK(FH_SDAM | 7), "\\Device\\Harddisk38\\Partition7"}, - {"/dev/sdam8", BRACK(FH_SDAM | 8), "\\Device\\Harddisk38\\Partition8"}, - {"/dev/sdam9", BRACK(FH_SDAM | 9), "\\Device\\Harddisk38\\Partition9"}, - {"/dev/sdam10", BRACK(FH_SDAM | 10), "\\Device\\Harddisk38\\Partition10"}, - {"/dev/sdam11", BRACK(FH_SDAM | 11), "\\Device\\Harddisk38\\Partition11"}, - {"/dev/sdam12", BRACK(FH_SDAM | 12), "\\Device\\Harddisk38\\Partition12"}, - {"/dev/sdam13", BRACK(FH_SDAM | 13), "\\Device\\Harddisk38\\Partition13"}, - {"/dev/sdam14", BRACK(FH_SDAM | 14), "\\Device\\Harddisk38\\Partition14"}, - {"/dev/sdam15", BRACK(FH_SDAM | 15), "\\Device\\Harddisk38\\Partition15"}, - {"/dev/sdan1", BRACK(FH_SDAN | 1), "\\Device\\Harddisk39\\Partition1"}, - {"/dev/sdan2", BRACK(FH_SDAN | 2), "\\Device\\Harddisk39\\Partition2"}, - {"/dev/sdan3", BRACK(FH_SDAN | 3), "\\Device\\Harddisk39\\Partition3"}, - {"/dev/sdan4", BRACK(FH_SDAN | 4), "\\Device\\Harddisk39\\Partition4"}, - {"/dev/sdan5", BRACK(FH_SDAN | 5), "\\Device\\Harddisk39\\Partition5"}, - {"/dev/sdan6", BRACK(FH_SDAN | 6), "\\Device\\Harddisk39\\Partition6"}, - {"/dev/sdan7", BRACK(FH_SDAN | 7), "\\Device\\Harddisk39\\Partition7"}, - {"/dev/sdan8", BRACK(FH_SDAN | 8), "\\Device\\Harddisk39\\Partition8"}, - {"/dev/sdan9", BRACK(FH_SDAN | 9), "\\Device\\Harddisk39\\Partition9"}, - {"/dev/sdan10", BRACK(FH_SDAN | 10), "\\Device\\Harddisk39\\Partition10"}, - {"/dev/sdan11", BRACK(FH_SDAN | 11), "\\Device\\Harddisk39\\Partition11"}, - {"/dev/sdan12", BRACK(FH_SDAN | 12), "\\Device\\Harddisk39\\Partition12"}, - {"/dev/sdan13", BRACK(FH_SDAN | 13), "\\Device\\Harddisk39\\Partition13"}, - {"/dev/sdan14", BRACK(FH_SDAN | 14), "\\Device\\Harddisk39\\Partition14"}, - {"/dev/sdan15", BRACK(FH_SDAN | 15), "\\Device\\Harddisk39\\Partition15"}, - {"/dev/sdao1", BRACK(FH_SDAO | 1), "\\Device\\Harddisk40\\Partition1"}, - {"/dev/sdao2", BRACK(FH_SDAO | 2), "\\Device\\Harddisk40\\Partition2"}, - {"/dev/sdao3", BRACK(FH_SDAO | 3), "\\Device\\Harddisk40\\Partition3"}, - {"/dev/sdao4", BRACK(FH_SDAO | 4), "\\Device\\Harddisk40\\Partition4"}, - {"/dev/sdao5", BRACK(FH_SDAO | 5), "\\Device\\Harddisk40\\Partition5"}, - {"/dev/sdao6", BRACK(FH_SDAO | 6), "\\Device\\Harddisk40\\Partition6"}, - {"/dev/sdao7", BRACK(FH_SDAO | 7), "\\Device\\Harddisk40\\Partition7"}, - {"/dev/sdao8", BRACK(FH_SDAO | 8), "\\Device\\Harddisk40\\Partition8"}, - {"/dev/sdao9", BRACK(FH_SDAO | 9), "\\Device\\Harddisk40\\Partition9"}, - {"/dev/sdao10", BRACK(FH_SDAO | 10), "\\Device\\Harddisk40\\Partition10"}, - {"/dev/sdao11", BRACK(FH_SDAO | 11), "\\Device\\Harddisk40\\Partition11"}, - {"/dev/sdao12", BRACK(FH_SDAO | 12), "\\Device\\Harddisk40\\Partition12"}, - {"/dev/sdao13", BRACK(FH_SDAO | 13), "\\Device\\Harddisk40\\Partition13"}, - {"/dev/sdao14", BRACK(FH_SDAO | 14), "\\Device\\Harddisk40\\Partition14"}, - {"/dev/sdao15", BRACK(FH_SDAO | 15), "\\Device\\Harddisk40\\Partition15"}, - {"/dev/sdap1", BRACK(FH_SDAP | 1), "\\Device\\Harddisk41\\Partition1"}, - {"/dev/sdap2", BRACK(FH_SDAP | 2), "\\Device\\Harddisk41\\Partition2"}, - {"/dev/sdap3", BRACK(FH_SDAP | 3), "\\Device\\Harddisk41\\Partition3"}, - {"/dev/sdap4", BRACK(FH_SDAP | 4), "\\Device\\Harddisk41\\Partition4"}, - {"/dev/sdap5", BRACK(FH_SDAP | 5), "\\Device\\Harddisk41\\Partition5"}, - {"/dev/sdap6", BRACK(FH_SDAP | 6), "\\Device\\Harddisk41\\Partition6"}, - {"/dev/sdap7", BRACK(FH_SDAP | 7), "\\Device\\Harddisk41\\Partition7"}, - {"/dev/sdap8", BRACK(FH_SDAP | 8), "\\Device\\Harddisk41\\Partition8"}, - {"/dev/sdap9", BRACK(FH_SDAP | 9), "\\Device\\Harddisk41\\Partition9"}, - {"/dev/sdap10", BRACK(FH_SDAP | 10), "\\Device\\Harddisk41\\Partition10"}, - {"/dev/sdap11", BRACK(FH_SDAP | 11), "\\Device\\Harddisk41\\Partition11"}, - {"/dev/sdap12", BRACK(FH_SDAP | 12), "\\Device\\Harddisk41\\Partition12"}, - {"/dev/sdap13", BRACK(FH_SDAP | 13), "\\Device\\Harddisk41\\Partition13"}, - {"/dev/sdap14", BRACK(FH_SDAP | 14), "\\Device\\Harddisk41\\Partition14"}, - {"/dev/sdap15", BRACK(FH_SDAP | 15), "\\Device\\Harddisk41\\Partition15"}, - {"/dev/sdaq1", BRACK(FH_SDAQ | 1), "\\Device\\Harddisk42\\Partition1"}, - {"/dev/sdaq2", BRACK(FH_SDAQ | 2), "\\Device\\Harddisk42\\Partition2"}, - {"/dev/sdaq3", BRACK(FH_SDAQ | 3), "\\Device\\Harddisk42\\Partition3"}, - {"/dev/sdaq4", BRACK(FH_SDAQ | 4), "\\Device\\Harddisk42\\Partition4"}, - {"/dev/sdaq5", BRACK(FH_SDAQ | 5), "\\Device\\Harddisk42\\Partition5"}, - {"/dev/sdaq6", BRACK(FH_SDAQ | 6), "\\Device\\Harddisk42\\Partition6"}, - {"/dev/sdaq7", BRACK(FH_SDAQ | 7), "\\Device\\Harddisk42\\Partition7"}, - {"/dev/sdaq8", BRACK(FH_SDAQ | 8), "\\Device\\Harddisk42\\Partition8"}, - {"/dev/sdaq9", BRACK(FH_SDAQ | 9), "\\Device\\Harddisk42\\Partition9"}, - {"/dev/sdaq10", BRACK(FH_SDAQ | 10), "\\Device\\Harddisk42\\Partition10"}, - {"/dev/sdaq11", BRACK(FH_SDAQ | 11), "\\Device\\Harddisk42\\Partition11"}, - {"/dev/sdaq12", BRACK(FH_SDAQ | 12), "\\Device\\Harddisk42\\Partition12"}, - {"/dev/sdaq13", BRACK(FH_SDAQ | 13), "\\Device\\Harddisk42\\Partition13"}, - {"/dev/sdaq14", BRACK(FH_SDAQ | 14), "\\Device\\Harddisk42\\Partition14"}, - {"/dev/sdaq15", BRACK(FH_SDAQ | 15), "\\Device\\Harddisk42\\Partition15"}, - {"/dev/sdar1", BRACK(FH_SDAR | 1), "\\Device\\Harddisk43\\Partition1"}, - {"/dev/sdar2", BRACK(FH_SDAR | 2), "\\Device\\Harddisk43\\Partition2"}, - {"/dev/sdar3", BRACK(FH_SDAR | 3), "\\Device\\Harddisk43\\Partition3"}, - {"/dev/sdar4", BRACK(FH_SDAR | 4), "\\Device\\Harddisk43\\Partition4"}, - {"/dev/sdar5", BRACK(FH_SDAR | 5), "\\Device\\Harddisk43\\Partition5"}, - {"/dev/sdar6", BRACK(FH_SDAR | 6), "\\Device\\Harddisk43\\Partition6"}, - {"/dev/sdar7", BRACK(FH_SDAR | 7), "\\Device\\Harddisk43\\Partition7"}, - {"/dev/sdar8", BRACK(FH_SDAR | 8), "\\Device\\Harddisk43\\Partition8"}, - {"/dev/sdar9", BRACK(FH_SDAR | 9), "\\Device\\Harddisk43\\Partition9"}, - {"/dev/sdar10", BRACK(FH_SDAR | 10), "\\Device\\Harddisk43\\Partition10"}, - {"/dev/sdar11", BRACK(FH_SDAR | 11), "\\Device\\Harddisk43\\Partition11"}, - {"/dev/sdar12", BRACK(FH_SDAR | 12), "\\Device\\Harddisk43\\Partition12"}, - {"/dev/sdar13", BRACK(FH_SDAR | 13), "\\Device\\Harddisk43\\Partition13"}, - {"/dev/sdar14", BRACK(FH_SDAR | 14), "\\Device\\Harddisk43\\Partition14"}, - {"/dev/sdar15", BRACK(FH_SDAR | 15), "\\Device\\Harddisk43\\Partition15"}, - {"/dev/sdas1", BRACK(FH_SDAS | 1), "\\Device\\Harddisk44\\Partition1"}, - {"/dev/sdas2", BRACK(FH_SDAS | 2), "\\Device\\Harddisk44\\Partition2"}, - {"/dev/sdas3", BRACK(FH_SDAS | 3), "\\Device\\Harddisk44\\Partition3"}, - {"/dev/sdas4", BRACK(FH_SDAS | 4), "\\Device\\Harddisk44\\Partition4"}, - {"/dev/sdas5", BRACK(FH_SDAS | 5), "\\Device\\Harddisk44\\Partition5"}, - {"/dev/sdas6", BRACK(FH_SDAS | 6), "\\Device\\Harddisk44\\Partition6"}, - {"/dev/sdas7", BRACK(FH_SDAS | 7), "\\Device\\Harddisk44\\Partition7"}, - {"/dev/sdas8", BRACK(FH_SDAS | 8), "\\Device\\Harddisk44\\Partition8"}, - {"/dev/sdas9", BRACK(FH_SDAS | 9), "\\Device\\Harddisk44\\Partition9"}, - {"/dev/sdas10", BRACK(FH_SDAS | 10), "\\Device\\Harddisk44\\Partition10"}, - {"/dev/sdas11", BRACK(FH_SDAS | 11), "\\Device\\Harddisk44\\Partition11"}, - {"/dev/sdas12", BRACK(FH_SDAS | 12), "\\Device\\Harddisk44\\Partition12"}, - {"/dev/sdas13", BRACK(FH_SDAS | 13), "\\Device\\Harddisk44\\Partition13"}, - {"/dev/sdas14", BRACK(FH_SDAS | 14), "\\Device\\Harddisk44\\Partition14"}, - {"/dev/sdas15", BRACK(FH_SDAS | 15), "\\Device\\Harddisk44\\Partition15"}, - {"/dev/sdat1", BRACK(FH_SDAT | 1), "\\Device\\Harddisk45\\Partition1"}, - {"/dev/sdat2", BRACK(FH_SDAT | 2), "\\Device\\Harddisk45\\Partition2"}, - {"/dev/sdat3", BRACK(FH_SDAT | 3), "\\Device\\Harddisk45\\Partition3"}, - {"/dev/sdat4", BRACK(FH_SDAT | 4), "\\Device\\Harddisk45\\Partition4"}, - {"/dev/sdat5", BRACK(FH_SDAT | 5), "\\Device\\Harddisk45\\Partition5"}, - {"/dev/sdat6", BRACK(FH_SDAT | 6), "\\Device\\Harddisk45\\Partition6"}, - {"/dev/sdat7", BRACK(FH_SDAT | 7), "\\Device\\Harddisk45\\Partition7"}, - {"/dev/sdat8", BRACK(FH_SDAT | 8), "\\Device\\Harddisk45\\Partition8"}, - {"/dev/sdat9", BRACK(FH_SDAT | 9), "\\Device\\Harddisk45\\Partition9"}, - {"/dev/sdat10", BRACK(FH_SDAT | 10), "\\Device\\Harddisk45\\Partition10"}, - {"/dev/sdat11", BRACK(FH_SDAT | 11), "\\Device\\Harddisk45\\Partition11"}, - {"/dev/sdat12", BRACK(FH_SDAT | 12), "\\Device\\Harddisk45\\Partition12"}, - {"/dev/sdat13", BRACK(FH_SDAT | 13), "\\Device\\Harddisk45\\Partition13"}, - {"/dev/sdat14", BRACK(FH_SDAT | 14), "\\Device\\Harddisk45\\Partition14"}, - {"/dev/sdat15", BRACK(FH_SDAT | 15), "\\Device\\Harddisk45\\Partition15"}, - {"/dev/sdau1", BRACK(FH_SDAU | 1), "\\Device\\Harddisk46\\Partition1"}, - {"/dev/sdau2", BRACK(FH_SDAU | 2), "\\Device\\Harddisk46\\Partition2"}, - {"/dev/sdau3", BRACK(FH_SDAU | 3), "\\Device\\Harddisk46\\Partition3"}, - {"/dev/sdau4", BRACK(FH_SDAU | 4), "\\Device\\Harddisk46\\Partition4"}, - {"/dev/sdau5", BRACK(FH_SDAU | 5), "\\Device\\Harddisk46\\Partition5"}, - {"/dev/sdau6", BRACK(FH_SDAU | 6), "\\Device\\Harddisk46\\Partition6"}, - {"/dev/sdau7", BRACK(FH_SDAU | 7), "\\Device\\Harddisk46\\Partition7"}, - {"/dev/sdau8", BRACK(FH_SDAU | 8), "\\Device\\Harddisk46\\Partition8"}, - {"/dev/sdau9", BRACK(FH_SDAU | 9), "\\Device\\Harddisk46\\Partition9"}, - {"/dev/sdau10", BRACK(FH_SDAU | 10), "\\Device\\Harddisk46\\Partition10"}, - {"/dev/sdau11", BRACK(FH_SDAU | 11), "\\Device\\Harddisk46\\Partition11"}, - {"/dev/sdau12", BRACK(FH_SDAU | 12), "\\Device\\Harddisk46\\Partition12"}, - {"/dev/sdau13", BRACK(FH_SDAU | 13), "\\Device\\Harddisk46\\Partition13"}, - {"/dev/sdau14", BRACK(FH_SDAU | 14), "\\Device\\Harddisk46\\Partition14"}, - {"/dev/sdau15", BRACK(FH_SDAU | 15), "\\Device\\Harddisk46\\Partition15"}, - {"/dev/sdav1", BRACK(FH_SDAV | 1), "\\Device\\Harddisk47\\Partition1"}, - {"/dev/sdav2", BRACK(FH_SDAV | 2), "\\Device\\Harddisk47\\Partition2"}, - {"/dev/sdav3", BRACK(FH_SDAV | 3), "\\Device\\Harddisk47\\Partition3"}, - {"/dev/sdav4", BRACK(FH_SDAV | 4), "\\Device\\Harddisk47\\Partition4"}, - {"/dev/sdav5", BRACK(FH_SDAV | 5), "\\Device\\Harddisk47\\Partition5"}, - {"/dev/sdav6", BRACK(FH_SDAV | 6), "\\Device\\Harddisk47\\Partition6"}, - {"/dev/sdav7", BRACK(FH_SDAV | 7), "\\Device\\Harddisk47\\Partition7"}, - {"/dev/sdav8", BRACK(FH_SDAV | 8), "\\Device\\Harddisk47\\Partition8"}, - {"/dev/sdav9", BRACK(FH_SDAV | 9), "\\Device\\Harddisk47\\Partition9"}, - {"/dev/sdav10", BRACK(FH_SDAV | 10), "\\Device\\Harddisk47\\Partition10"}, - {"/dev/sdav11", BRACK(FH_SDAV | 11), "\\Device\\Harddisk47\\Partition11"}, - {"/dev/sdav12", BRACK(FH_SDAV | 12), "\\Device\\Harddisk47\\Partition12"}, - {"/dev/sdav13", BRACK(FH_SDAV | 13), "\\Device\\Harddisk47\\Partition13"}, - {"/dev/sdav14", BRACK(FH_SDAV | 14), "\\Device\\Harddisk47\\Partition14"}, - {"/dev/sdav15", BRACK(FH_SDAV | 15), "\\Device\\Harddisk47\\Partition15"}, - {"/dev/sdaw1", BRACK(FH_SDAW | 1), "\\Device\\Harddisk48\\Partition1"}, - {"/dev/sdaw2", BRACK(FH_SDAW | 2), "\\Device\\Harddisk48\\Partition2"}, - {"/dev/sdaw3", BRACK(FH_SDAW | 3), "\\Device\\Harddisk48\\Partition3"}, - {"/dev/sdaw4", BRACK(FH_SDAW | 4), "\\Device\\Harddisk48\\Partition4"}, - {"/dev/sdaw5", BRACK(FH_SDAW | 5), "\\Device\\Harddisk48\\Partition5"}, - {"/dev/sdaw6", BRACK(FH_SDAW | 6), "\\Device\\Harddisk48\\Partition6"}, - {"/dev/sdaw7", BRACK(FH_SDAW | 7), "\\Device\\Harddisk48\\Partition7"}, - {"/dev/sdaw8", BRACK(FH_SDAW | 8), "\\Device\\Harddisk48\\Partition8"}, - {"/dev/sdaw9", BRACK(FH_SDAW | 9), "\\Device\\Harddisk48\\Partition9"}, - {"/dev/sdaw10", BRACK(FH_SDAW | 10), "\\Device\\Harddisk48\\Partition10"}, - {"/dev/sdaw11", BRACK(FH_SDAW | 11), "\\Device\\Harddisk48\\Partition11"}, - {"/dev/sdaw12", BRACK(FH_SDAW | 12), "\\Device\\Harddisk48\\Partition12"}, - {"/dev/sdaw13", BRACK(FH_SDAW | 13), "\\Device\\Harddisk48\\Partition13"}, - {"/dev/sdaw14", BRACK(FH_SDAW | 14), "\\Device\\Harddisk48\\Partition14"}, - {"/dev/sdaw15", BRACK(FH_SDAW | 15), "\\Device\\Harddisk48\\Partition15"}, - {"/dev/sdax1", BRACK(FH_SDAX | 1), "\\Device\\Harddisk49\\Partition1"}, - {"/dev/sdax2", BRACK(FH_SDAX | 2), "\\Device\\Harddisk49\\Partition2"}, - {"/dev/sdax3", BRACK(FH_SDAX | 3), "\\Device\\Harddisk49\\Partition3"}, - {"/dev/sdax4", BRACK(FH_SDAX | 4), "\\Device\\Harddisk49\\Partition4"}, - {"/dev/sdax5", BRACK(FH_SDAX | 5), "\\Device\\Harddisk49\\Partition5"}, - {"/dev/sdax6", BRACK(FH_SDAX | 6), "\\Device\\Harddisk49\\Partition6"}, - {"/dev/sdax7", BRACK(FH_SDAX | 7), "\\Device\\Harddisk49\\Partition7"}, - {"/dev/sdax8", BRACK(FH_SDAX | 8), "\\Device\\Harddisk49\\Partition8"}, - {"/dev/sdax9", BRACK(FH_SDAX | 9), "\\Device\\Harddisk49\\Partition9"}, - {"/dev/sdax10", BRACK(FH_SDAX | 10), "\\Device\\Harddisk49\\Partition10"}, - {"/dev/sdax11", BRACK(FH_SDAX | 11), "\\Device\\Harddisk49\\Partition11"}, - {"/dev/sdax12", BRACK(FH_SDAX | 12), "\\Device\\Harddisk49\\Partition12"}, - {"/dev/sdax13", BRACK(FH_SDAX | 13), "\\Device\\Harddisk49\\Partition13"}, - {"/dev/sdax14", BRACK(FH_SDAX | 14), "\\Device\\Harddisk49\\Partition14"}, - {"/dev/sdax15", BRACK(FH_SDAX | 15), "\\Device\\Harddisk49\\Partition15"}, - {"/dev/sday1", BRACK(FH_SDAY | 1), "\\Device\\Harddisk50\\Partition1"}, - {"/dev/sday2", BRACK(FH_SDAY | 2), "\\Device\\Harddisk50\\Partition2"}, - {"/dev/sday3", BRACK(FH_SDAY | 3), "\\Device\\Harddisk50\\Partition3"}, - {"/dev/sday4", BRACK(FH_SDAY | 4), "\\Device\\Harddisk50\\Partition4"}, - {"/dev/sday5", BRACK(FH_SDAY | 5), "\\Device\\Harddisk50\\Partition5"}, - {"/dev/sday6", BRACK(FH_SDAY | 6), "\\Device\\Harddisk50\\Partition6"}, - {"/dev/sday7", BRACK(FH_SDAY | 7), "\\Device\\Harddisk50\\Partition7"}, - {"/dev/sday8", BRACK(FH_SDAY | 8), "\\Device\\Harddisk50\\Partition8"}, - {"/dev/sday9", BRACK(FH_SDAY | 9), "\\Device\\Harddisk50\\Partition9"}, - {"/dev/sday10", BRACK(FH_SDAY | 10), "\\Device\\Harddisk50\\Partition10"}, - {"/dev/sday11", BRACK(FH_SDAY | 11), "\\Device\\Harddisk50\\Partition11"}, - {"/dev/sday12", BRACK(FH_SDAY | 12), "\\Device\\Harddisk50\\Partition12"}, - {"/dev/sday13", BRACK(FH_SDAY | 13), "\\Device\\Harddisk50\\Partition13"}, - {"/dev/sday14", BRACK(FH_SDAY | 14), "\\Device\\Harddisk50\\Partition14"}, - {"/dev/sday15", BRACK(FH_SDAY | 15), "\\Device\\Harddisk50\\Partition15"}, - {"/dev/sdaz1", BRACK(FH_SDAZ | 1), "\\Device\\Harddisk51\\Partition1"}, - {"/dev/sdaz2", BRACK(FH_SDAZ | 2), "\\Device\\Harddisk51\\Partition2"}, - {"/dev/sdaz3", BRACK(FH_SDAZ | 3), "\\Device\\Harddisk51\\Partition3"}, - {"/dev/sdaz4", BRACK(FH_SDAZ | 4), "\\Device\\Harddisk51\\Partition4"}, - {"/dev/sdaz5", BRACK(FH_SDAZ | 5), "\\Device\\Harddisk51\\Partition5"}, - {"/dev/sdaz6", BRACK(FH_SDAZ | 6), "\\Device\\Harddisk51\\Partition6"}, - {"/dev/sdaz7", BRACK(FH_SDAZ | 7), "\\Device\\Harddisk51\\Partition7"}, - {"/dev/sdaz8", BRACK(FH_SDAZ | 8), "\\Device\\Harddisk51\\Partition8"}, - {"/dev/sdaz9", BRACK(FH_SDAZ | 9), "\\Device\\Harddisk51\\Partition9"}, - {"/dev/sdaz10", BRACK(FH_SDAZ | 10), "\\Device\\Harddisk51\\Partition10"}, - {"/dev/sdaz11", BRACK(FH_SDAZ | 11), "\\Device\\Harddisk51\\Partition11"}, - {"/dev/sdaz12", BRACK(FH_SDAZ | 12), "\\Device\\Harddisk51\\Partition12"}, - {"/dev/sdaz13", BRACK(FH_SDAZ | 13), "\\Device\\Harddisk51\\Partition13"}, - {"/dev/sdaz14", BRACK(FH_SDAZ | 14), "\\Device\\Harddisk51\\Partition14"}, - {"/dev/sdaz15", BRACK(FH_SDAZ | 15), "\\Device\\Harddisk51\\Partition15"}, - {"/dev/sdba", BRACK(FH_SDBA), "\\Device\\Harddisk52\\Partition0"}, - {"/dev/sdbb", BRACK(FH_SDBB), "\\Device\\Harddisk53\\Partition0"}, - {"/dev/sdbc", BRACK(FH_SDBC), "\\Device\\Harddisk54\\Partition0"}, - {"/dev/sdbd", BRACK(FH_SDBD), "\\Device\\Harddisk55\\Partition0"}, - {"/dev/sdbe", BRACK(FH_SDBE), "\\Device\\Harddisk56\\Partition0"}, - {"/dev/sdbf", BRACK(FH_SDBF), "\\Device\\Harddisk57\\Partition0"}, - {"/dev/sdbg", BRACK(FH_SDBG), "\\Device\\Harddisk58\\Partition0"}, - {"/dev/sdbh", BRACK(FH_SDBH), "\\Device\\Harddisk59\\Partition0"}, - {"/dev/sdbi", BRACK(FH_SDBI), "\\Device\\Harddisk60\\Partition0"}, - {"/dev/sdbj", BRACK(FH_SDBJ), "\\Device\\Harddisk61\\Partition0"}, - {"/dev/sdbk", BRACK(FH_SDBK), "\\Device\\Harddisk62\\Partition0"}, - {"/dev/sdbl", BRACK(FH_SDBL), "\\Device\\Harddisk63\\Partition0"}, - {"/dev/sdbm", BRACK(FH_SDBM), "\\Device\\Harddisk64\\Partition0"}, - {"/dev/sdbn", BRACK(FH_SDBN), "\\Device\\Harddisk65\\Partition0"}, - {"/dev/sdbo", BRACK(FH_SDBO), "\\Device\\Harddisk66\\Partition0"}, - {"/dev/sdbp", BRACK(FH_SDBP), "\\Device\\Harddisk67\\Partition0"}, - {"/dev/sdbq", BRACK(FH_SDBQ), "\\Device\\Harddisk68\\Partition0"}, - {"/dev/sdbr", BRACK(FH_SDBR), "\\Device\\Harddisk69\\Partition0"}, - {"/dev/sdbs", BRACK(FH_SDBS), "\\Device\\Harddisk70\\Partition0"}, - {"/dev/sdbt", BRACK(FH_SDBT), "\\Device\\Harddisk71\\Partition0"}, - {"/dev/sdbu", BRACK(FH_SDBU), "\\Device\\Harddisk72\\Partition0"}, - {"/dev/sdbv", BRACK(FH_SDBV), "\\Device\\Harddisk73\\Partition0"}, - {"/dev/sdbw", BRACK(FH_SDBW), "\\Device\\Harddisk74\\Partition0"}, - {"/dev/sdbx", BRACK(FH_SDBX), "\\Device\\Harddisk75\\Partition0"}, - {"/dev/sdby", BRACK(FH_SDBY), "\\Device\\Harddisk76\\Partition0"}, - {"/dev/sdbz", BRACK(FH_SDBZ), "\\Device\\Harddisk77\\Partition0"}, - {"/dev/sdba1", BRACK(FH_SDBA | 1), "\\Device\\Harddisk52\\Partition1"}, - {"/dev/sdba2", BRACK(FH_SDBA | 2), "\\Device\\Harddisk52\\Partition2"}, - {"/dev/sdba3", BRACK(FH_SDBA | 3), "\\Device\\Harddisk52\\Partition3"}, - {"/dev/sdba4", BRACK(FH_SDBA | 4), "\\Device\\Harddisk52\\Partition4"}, - {"/dev/sdba5", BRACK(FH_SDBA | 5), "\\Device\\Harddisk52\\Partition5"}, - {"/dev/sdba6", BRACK(FH_SDBA | 6), "\\Device\\Harddisk52\\Partition6"}, - {"/dev/sdba7", BRACK(FH_SDBA | 7), "\\Device\\Harddisk52\\Partition7"}, - {"/dev/sdba8", BRACK(FH_SDBA | 8), "\\Device\\Harddisk52\\Partition8"}, - {"/dev/sdba9", BRACK(FH_SDBA | 9), "\\Device\\Harddisk52\\Partition9"}, - {"/dev/sdba10", BRACK(FH_SDBA | 10), "\\Device\\Harddisk52\\Partition10"}, - {"/dev/sdba11", BRACK(FH_SDBA | 11), "\\Device\\Harddisk52\\Partition11"}, - {"/dev/sdba12", BRACK(FH_SDBA | 12), "\\Device\\Harddisk52\\Partition12"}, - {"/dev/sdba13", BRACK(FH_SDBA | 13), "\\Device\\Harddisk52\\Partition13"}, - {"/dev/sdba14", BRACK(FH_SDBA | 14), "\\Device\\Harddisk52\\Partition14"}, - {"/dev/sdba15", BRACK(FH_SDBA | 15), "\\Device\\Harddisk52\\Partition15"}, - {"/dev/sdbb1", BRACK(FH_SDBB | 1), "\\Device\\Harddisk53\\Partition1"}, - {"/dev/sdbb2", BRACK(FH_SDBB | 2), "\\Device\\Harddisk53\\Partition2"}, - {"/dev/sdbb3", BRACK(FH_SDBB | 3), "\\Device\\Harddisk53\\Partition3"}, - {"/dev/sdbb4", BRACK(FH_SDBB | 4), "\\Device\\Harddisk53\\Partition4"}, - {"/dev/sdbb5", BRACK(FH_SDBB | 5), "\\Device\\Harddisk53\\Partition5"}, - {"/dev/sdbb6", BRACK(FH_SDBB | 6), "\\Device\\Harddisk53\\Partition6"}, - {"/dev/sdbb7", BRACK(FH_SDBB | 7), "\\Device\\Harddisk53\\Partition7"}, - {"/dev/sdbb8", BRACK(FH_SDBB | 8), "\\Device\\Harddisk53\\Partition8"}, - {"/dev/sdbb9", BRACK(FH_SDBB | 9), "\\Device\\Harddisk53\\Partition9"}, - {"/dev/sdbb10", BRACK(FH_SDBB | 10), "\\Device\\Harddisk53\\Partition10"}, - {"/dev/sdbb11", BRACK(FH_SDBB | 11), "\\Device\\Harddisk53\\Partition11"}, - {"/dev/sdbb12", BRACK(FH_SDBB | 12), "\\Device\\Harddisk53\\Partition12"}, - {"/dev/sdbb13", BRACK(FH_SDBB | 13), "\\Device\\Harddisk53\\Partition13"}, - {"/dev/sdbb14", BRACK(FH_SDBB | 14), "\\Device\\Harddisk53\\Partition14"}, - {"/dev/sdbb15", BRACK(FH_SDBB | 15), "\\Device\\Harddisk53\\Partition15"}, - {"/dev/sdbc1", BRACK(FH_SDBC | 1), "\\Device\\Harddisk54\\Partition1"}, - {"/dev/sdbc2", BRACK(FH_SDBC | 2), "\\Device\\Harddisk54\\Partition2"}, - {"/dev/sdbc3", BRACK(FH_SDBC | 3), "\\Device\\Harddisk54\\Partition3"}, - {"/dev/sdbc4", BRACK(FH_SDBC | 4), "\\Device\\Harddisk54\\Partition4"}, - {"/dev/sdbc5", BRACK(FH_SDBC | 5), "\\Device\\Harddisk54\\Partition5"}, - {"/dev/sdbc6", BRACK(FH_SDBC | 6), "\\Device\\Harddisk54\\Partition6"}, - {"/dev/sdbc7", BRACK(FH_SDBC | 7), "\\Device\\Harddisk54\\Partition7"}, - {"/dev/sdbc8", BRACK(FH_SDBC | 8), "\\Device\\Harddisk54\\Partition8"}, - {"/dev/sdbc9", BRACK(FH_SDBC | 9), "\\Device\\Harddisk54\\Partition9"}, - {"/dev/sdbc10", BRACK(FH_SDBC | 10), "\\Device\\Harddisk54\\Partition10"}, - {"/dev/sdbc11", BRACK(FH_SDBC | 11), "\\Device\\Harddisk54\\Partition11"}, - {"/dev/sdbc12", BRACK(FH_SDBC | 12), "\\Device\\Harddisk54\\Partition12"}, - {"/dev/sdbc13", BRACK(FH_SDBC | 13), "\\Device\\Harddisk54\\Partition13"}, - {"/dev/sdbc14", BRACK(FH_SDBC | 14), "\\Device\\Harddisk54\\Partition14"}, - {"/dev/sdbc15", BRACK(FH_SDBC | 15), "\\Device\\Harddisk54\\Partition15"}, - {"/dev/sdbd1", BRACK(FH_SDBD | 1), "\\Device\\Harddisk55\\Partition1"}, - {"/dev/sdbd2", BRACK(FH_SDBD | 2), "\\Device\\Harddisk55\\Partition2"}, - {"/dev/sdbd3", BRACK(FH_SDBD | 3), "\\Device\\Harddisk55\\Partition3"}, - {"/dev/sdbd4", BRACK(FH_SDBD | 4), "\\Device\\Harddisk55\\Partition4"}, - {"/dev/sdbd5", BRACK(FH_SDBD | 5), "\\Device\\Harddisk55\\Partition5"}, - {"/dev/sdbd6", BRACK(FH_SDBD | 6), "\\Device\\Harddisk55\\Partition6"}, - {"/dev/sdbd7", BRACK(FH_SDBD | 7), "\\Device\\Harddisk55\\Partition7"}, - {"/dev/sdbd8", BRACK(FH_SDBD | 8), "\\Device\\Harddisk55\\Partition8"}, - {"/dev/sdbd9", BRACK(FH_SDBD | 9), "\\Device\\Harddisk55\\Partition9"}, - {"/dev/sdbd10", BRACK(FH_SDBD | 10), "\\Device\\Harddisk55\\Partition10"}, - {"/dev/sdbd11", BRACK(FH_SDBD | 11), "\\Device\\Harddisk55\\Partition11"}, - {"/dev/sdbd12", BRACK(FH_SDBD | 12), "\\Device\\Harddisk55\\Partition12"}, - {"/dev/sdbd13", BRACK(FH_SDBD | 13), "\\Device\\Harddisk55\\Partition13"}, - {"/dev/sdbd14", BRACK(FH_SDBD | 14), "\\Device\\Harddisk55\\Partition14"}, - {"/dev/sdbd15", BRACK(FH_SDBD | 15), "\\Device\\Harddisk55\\Partition15"}, - {"/dev/sdbe1", BRACK(FH_SDBE | 1), "\\Device\\Harddisk56\\Partition1"}, - {"/dev/sdbe2", BRACK(FH_SDBE | 2), "\\Device\\Harddisk56\\Partition2"}, - {"/dev/sdbe3", BRACK(FH_SDBE | 3), "\\Device\\Harddisk56\\Partition3"}, - {"/dev/sdbe4", BRACK(FH_SDBE | 4), "\\Device\\Harddisk56\\Partition4"}, - {"/dev/sdbe5", BRACK(FH_SDBE | 5), "\\Device\\Harddisk56\\Partition5"}, - {"/dev/sdbe6", BRACK(FH_SDBE | 6), "\\Device\\Harddisk56\\Partition6"}, - {"/dev/sdbe7", BRACK(FH_SDBE | 7), "\\Device\\Harddisk56\\Partition7"}, - {"/dev/sdbe8", BRACK(FH_SDBE | 8), "\\Device\\Harddisk56\\Partition8"}, - {"/dev/sdbe9", BRACK(FH_SDBE | 9), "\\Device\\Harddisk56\\Partition9"}, - {"/dev/sdbe10", BRACK(FH_SDBE | 10), "\\Device\\Harddisk56\\Partition10"}, - {"/dev/sdbe11", BRACK(FH_SDBE | 11), "\\Device\\Harddisk56\\Partition11"}, - {"/dev/sdbe12", BRACK(FH_SDBE | 12), "\\Device\\Harddisk56\\Partition12"}, - {"/dev/sdbe13", BRACK(FH_SDBE | 13), "\\Device\\Harddisk56\\Partition13"}, - {"/dev/sdbe14", BRACK(FH_SDBE | 14), "\\Device\\Harddisk56\\Partition14"}, - {"/dev/sdbe15", BRACK(FH_SDBE | 15), "\\Device\\Harddisk56\\Partition15"}, - {"/dev/sdbf1", BRACK(FH_SDBF | 1), "\\Device\\Harddisk57\\Partition1"}, - {"/dev/sdbf2", BRACK(FH_SDBF | 2), "\\Device\\Harddisk57\\Partition2"}, - {"/dev/sdbf3", BRACK(FH_SDBF | 3), "\\Device\\Harddisk57\\Partition3"}, - {"/dev/sdbf4", BRACK(FH_SDBF | 4), "\\Device\\Harddisk57\\Partition4"}, - {"/dev/sdbf5", BRACK(FH_SDBF | 5), "\\Device\\Harddisk57\\Partition5"}, - {"/dev/sdbf6", BRACK(FH_SDBF | 6), "\\Device\\Harddisk57\\Partition6"}, - {"/dev/sdbf7", BRACK(FH_SDBF | 7), "\\Device\\Harddisk57\\Partition7"}, - {"/dev/sdbf8", BRACK(FH_SDBF | 8), "\\Device\\Harddisk57\\Partition8"}, - {"/dev/sdbf9", BRACK(FH_SDBF | 9), "\\Device\\Harddisk57\\Partition9"}, - {"/dev/sdbf10", BRACK(FH_SDBF | 10), "\\Device\\Harddisk57\\Partition10"}, - {"/dev/sdbf11", BRACK(FH_SDBF | 11), "\\Device\\Harddisk57\\Partition11"}, - {"/dev/sdbf12", BRACK(FH_SDBF | 12), "\\Device\\Harddisk57\\Partition12"}, - {"/dev/sdbf13", BRACK(FH_SDBF | 13), "\\Device\\Harddisk57\\Partition13"}, - {"/dev/sdbf14", BRACK(FH_SDBF | 14), "\\Device\\Harddisk57\\Partition14"}, - {"/dev/sdbf15", BRACK(FH_SDBF | 15), "\\Device\\Harddisk57\\Partition15"}, - {"/dev/sdbg1", BRACK(FH_SDBG | 1), "\\Device\\Harddisk58\\Partition1"}, - {"/dev/sdbg2", BRACK(FH_SDBG | 2), "\\Device\\Harddisk58\\Partition2"}, - {"/dev/sdbg3", BRACK(FH_SDBG | 3), "\\Device\\Harddisk58\\Partition3"}, - {"/dev/sdbg4", BRACK(FH_SDBG | 4), "\\Device\\Harddisk58\\Partition4"}, - {"/dev/sdbg5", BRACK(FH_SDBG | 5), "\\Device\\Harddisk58\\Partition5"}, - {"/dev/sdbg6", BRACK(FH_SDBG | 6), "\\Device\\Harddisk58\\Partition6"}, - {"/dev/sdbg7", BRACK(FH_SDBG | 7), "\\Device\\Harddisk58\\Partition7"}, - {"/dev/sdbg8", BRACK(FH_SDBG | 8), "\\Device\\Harddisk58\\Partition8"}, - {"/dev/sdbg9", BRACK(FH_SDBG | 9), "\\Device\\Harddisk58\\Partition9"}, - {"/dev/sdbg10", BRACK(FH_SDBG | 10), "\\Device\\Harddisk58\\Partition10"}, - {"/dev/sdbg11", BRACK(FH_SDBG | 11), "\\Device\\Harddisk58\\Partition11"}, - {"/dev/sdbg12", BRACK(FH_SDBG | 12), "\\Device\\Harddisk58\\Partition12"}, - {"/dev/sdbg13", BRACK(FH_SDBG | 13), "\\Device\\Harddisk58\\Partition13"}, - {"/dev/sdbg14", BRACK(FH_SDBG | 14), "\\Device\\Harddisk58\\Partition14"}, - {"/dev/sdbg15", BRACK(FH_SDBG | 15), "\\Device\\Harddisk58\\Partition15"}, - {"/dev/sdbh1", BRACK(FH_SDBH | 1), "\\Device\\Harddisk59\\Partition1"}, - {"/dev/sdbh2", BRACK(FH_SDBH | 2), "\\Device\\Harddisk59\\Partition2"}, - {"/dev/sdbh3", BRACK(FH_SDBH | 3), "\\Device\\Harddisk59\\Partition3"}, - {"/dev/sdbh4", BRACK(FH_SDBH | 4), "\\Device\\Harddisk59\\Partition4"}, - {"/dev/sdbh5", BRACK(FH_SDBH | 5), "\\Device\\Harddisk59\\Partition5"}, - {"/dev/sdbh6", BRACK(FH_SDBH | 6), "\\Device\\Harddisk59\\Partition6"}, - {"/dev/sdbh7", BRACK(FH_SDBH | 7), "\\Device\\Harddisk59\\Partition7"}, - {"/dev/sdbh8", BRACK(FH_SDBH | 8), "\\Device\\Harddisk59\\Partition8"}, - {"/dev/sdbh9", BRACK(FH_SDBH | 9), "\\Device\\Harddisk59\\Partition9"}, - {"/dev/sdbh10", BRACK(FH_SDBH | 10), "\\Device\\Harddisk59\\Partition10"}, - {"/dev/sdbh11", BRACK(FH_SDBH | 11), "\\Device\\Harddisk59\\Partition11"}, - {"/dev/sdbh12", BRACK(FH_SDBH | 12), "\\Device\\Harddisk59\\Partition12"}, - {"/dev/sdbh13", BRACK(FH_SDBH | 13), "\\Device\\Harddisk59\\Partition13"}, - {"/dev/sdbh14", BRACK(FH_SDBH | 14), "\\Device\\Harddisk59\\Partition14"}, - {"/dev/sdbh15", BRACK(FH_SDBH | 15), "\\Device\\Harddisk59\\Partition15"}, - {"/dev/sdbi1", BRACK(FH_SDBI | 1), "\\Device\\Harddisk60\\Partition1"}, - {"/dev/sdbi2", BRACK(FH_SDBI | 2), "\\Device\\Harddisk60\\Partition2"}, - {"/dev/sdbi3", BRACK(FH_SDBI | 3), "\\Device\\Harddisk60\\Partition3"}, - {"/dev/sdbi4", BRACK(FH_SDBI | 4), "\\Device\\Harddisk60\\Partition4"}, - {"/dev/sdbi5", BRACK(FH_SDBI | 5), "\\Device\\Harddisk60\\Partition5"}, - {"/dev/sdbi6", BRACK(FH_SDBI | 6), "\\Device\\Harddisk60\\Partition6"}, - {"/dev/sdbi7", BRACK(FH_SDBI | 7), "\\Device\\Harddisk60\\Partition7"}, - {"/dev/sdbi8", BRACK(FH_SDBI | 8), "\\Device\\Harddisk60\\Partition8"}, - {"/dev/sdbi9", BRACK(FH_SDBI | 9), "\\Device\\Harddisk60\\Partition9"}, - {"/dev/sdbi10", BRACK(FH_SDBI | 10), "\\Device\\Harddisk60\\Partition10"}, - {"/dev/sdbi11", BRACK(FH_SDBI | 11), "\\Device\\Harddisk60\\Partition11"}, - {"/dev/sdbi12", BRACK(FH_SDBI | 12), "\\Device\\Harddisk60\\Partition12"}, - {"/dev/sdbi13", BRACK(FH_SDBI | 13), "\\Device\\Harddisk60\\Partition13"}, - {"/dev/sdbi14", BRACK(FH_SDBI | 14), "\\Device\\Harddisk60\\Partition14"}, - {"/dev/sdbi15", BRACK(FH_SDBI | 15), "\\Device\\Harddisk60\\Partition15"}, - {"/dev/sdbj1", BRACK(FH_SDBJ | 1), "\\Device\\Harddisk61\\Partition1"}, - {"/dev/sdbj2", BRACK(FH_SDBJ | 2), "\\Device\\Harddisk61\\Partition2"}, - {"/dev/sdbj3", BRACK(FH_SDBJ | 3), "\\Device\\Harddisk61\\Partition3"}, - {"/dev/sdbj4", BRACK(FH_SDBJ | 4), "\\Device\\Harddisk61\\Partition4"}, - {"/dev/sdbj5", BRACK(FH_SDBJ | 5), "\\Device\\Harddisk61\\Partition5"}, - {"/dev/sdbj6", BRACK(FH_SDBJ | 6), "\\Device\\Harddisk61\\Partition6"}, - {"/dev/sdbj7", BRACK(FH_SDBJ | 7), "\\Device\\Harddisk61\\Partition7"}, - {"/dev/sdbj8", BRACK(FH_SDBJ | 8), "\\Device\\Harddisk61\\Partition8"}, - {"/dev/sdbj9", BRACK(FH_SDBJ | 9), "\\Device\\Harddisk61\\Partition9"}, - {"/dev/sdbj10", BRACK(FH_SDBJ | 10), "\\Device\\Harddisk61\\Partition10"}, - {"/dev/sdbj11", BRACK(FH_SDBJ | 11), "\\Device\\Harddisk61\\Partition11"}, - {"/dev/sdbj12", BRACK(FH_SDBJ | 12), "\\Device\\Harddisk61\\Partition12"}, - {"/dev/sdbj13", BRACK(FH_SDBJ | 13), "\\Device\\Harddisk61\\Partition13"}, - {"/dev/sdbj14", BRACK(FH_SDBJ | 14), "\\Device\\Harddisk61\\Partition14"}, - {"/dev/sdbj15", BRACK(FH_SDBJ | 15), "\\Device\\Harddisk61\\Partition15"}, - {"/dev/sdbk1", BRACK(FH_SDBK | 1), "\\Device\\Harddisk62\\Partition1"}, - {"/dev/sdbk2", BRACK(FH_SDBK | 2), "\\Device\\Harddisk62\\Partition2"}, - {"/dev/sdbk3", BRACK(FH_SDBK | 3), "\\Device\\Harddisk62\\Partition3"}, - {"/dev/sdbk4", BRACK(FH_SDBK | 4), "\\Device\\Harddisk62\\Partition4"}, - {"/dev/sdbk5", BRACK(FH_SDBK | 5), "\\Device\\Harddisk62\\Partition5"}, - {"/dev/sdbk6", BRACK(FH_SDBK | 6), "\\Device\\Harddisk62\\Partition6"}, - {"/dev/sdbk7", BRACK(FH_SDBK | 7), "\\Device\\Harddisk62\\Partition7"}, - {"/dev/sdbk8", BRACK(FH_SDBK | 8), "\\Device\\Harddisk62\\Partition8"}, - {"/dev/sdbk9", BRACK(FH_SDBK | 9), "\\Device\\Harddisk62\\Partition9"}, - {"/dev/sdbk10", BRACK(FH_SDBK | 10), "\\Device\\Harddisk62\\Partition10"}, - {"/dev/sdbk11", BRACK(FH_SDBK | 11), "\\Device\\Harddisk62\\Partition11"}, - {"/dev/sdbk12", BRACK(FH_SDBK | 12), "\\Device\\Harddisk62\\Partition12"}, - {"/dev/sdbk13", BRACK(FH_SDBK | 13), "\\Device\\Harddisk62\\Partition13"}, - {"/dev/sdbk14", BRACK(FH_SDBK | 14), "\\Device\\Harddisk62\\Partition14"}, - {"/dev/sdbk15", BRACK(FH_SDBK | 15), "\\Device\\Harddisk62\\Partition15"}, - {"/dev/sdbl1", BRACK(FH_SDBL | 1), "\\Device\\Harddisk63\\Partition1"}, - {"/dev/sdbl2", BRACK(FH_SDBL | 2), "\\Device\\Harddisk63\\Partition2"}, - {"/dev/sdbl3", BRACK(FH_SDBL | 3), "\\Device\\Harddisk63\\Partition3"}, - {"/dev/sdbl4", BRACK(FH_SDBL | 4), "\\Device\\Harddisk63\\Partition4"}, - {"/dev/sdbl5", BRACK(FH_SDBL | 5), "\\Device\\Harddisk63\\Partition5"}, - {"/dev/sdbl6", BRACK(FH_SDBL | 6), "\\Device\\Harddisk63\\Partition6"}, - {"/dev/sdbl7", BRACK(FH_SDBL | 7), "\\Device\\Harddisk63\\Partition7"}, - {"/dev/sdbl8", BRACK(FH_SDBL | 8), "\\Device\\Harddisk63\\Partition8"}, - {"/dev/sdbl9", BRACK(FH_SDBL | 9), "\\Device\\Harddisk63\\Partition9"}, - {"/dev/sdbl10", BRACK(FH_SDBL | 10), "\\Device\\Harddisk63\\Partition10"}, - {"/dev/sdbl11", BRACK(FH_SDBL | 11), "\\Device\\Harddisk63\\Partition11"}, - {"/dev/sdbl12", BRACK(FH_SDBL | 12), "\\Device\\Harddisk63\\Partition12"}, - {"/dev/sdbl13", BRACK(FH_SDBL | 13), "\\Device\\Harddisk63\\Partition13"}, - {"/dev/sdbl14", BRACK(FH_SDBL | 14), "\\Device\\Harddisk63\\Partition14"}, - {"/dev/sdbl15", BRACK(FH_SDBL | 15), "\\Device\\Harddisk63\\Partition15"}, - {"/dev/sdbm1", BRACK(FH_SDBM | 1), "\\Device\\Harddisk64\\Partition1"}, - {"/dev/sdbm2", BRACK(FH_SDBM | 2), "\\Device\\Harddisk64\\Partition2"}, - {"/dev/sdbm3", BRACK(FH_SDBM | 3), "\\Device\\Harddisk64\\Partition3"}, - {"/dev/sdbm4", BRACK(FH_SDBM | 4), "\\Device\\Harddisk64\\Partition4"}, - {"/dev/sdbm5", BRACK(FH_SDBM | 5), "\\Device\\Harddisk64\\Partition5"}, - {"/dev/sdbm6", BRACK(FH_SDBM | 6), "\\Device\\Harddisk64\\Partition6"}, - {"/dev/sdbm7", BRACK(FH_SDBM | 7), "\\Device\\Harddisk64\\Partition7"}, - {"/dev/sdbm8", BRACK(FH_SDBM | 8), "\\Device\\Harddisk64\\Partition8"}, - {"/dev/sdbm9", BRACK(FH_SDBM | 9), "\\Device\\Harddisk64\\Partition9"}, - {"/dev/sdbm10", BRACK(FH_SDBM | 10), "\\Device\\Harddisk64\\Partition10"}, - {"/dev/sdbm11", BRACK(FH_SDBM | 11), "\\Device\\Harddisk64\\Partition11"}, - {"/dev/sdbm12", BRACK(FH_SDBM | 12), "\\Device\\Harddisk64\\Partition12"}, - {"/dev/sdbm13", BRACK(FH_SDBM | 13), "\\Device\\Harddisk64\\Partition13"}, - {"/dev/sdbm14", BRACK(FH_SDBM | 14), "\\Device\\Harddisk64\\Partition14"}, - {"/dev/sdbm15", BRACK(FH_SDBM | 15), "\\Device\\Harddisk64\\Partition15"}, - {"/dev/sdbn1", BRACK(FH_SDBN | 1), "\\Device\\Harddisk65\\Partition1"}, - {"/dev/sdbn2", BRACK(FH_SDBN | 2), "\\Device\\Harddisk65\\Partition2"}, - {"/dev/sdbn3", BRACK(FH_SDBN | 3), "\\Device\\Harddisk65\\Partition3"}, - {"/dev/sdbn4", BRACK(FH_SDBN | 4), "\\Device\\Harddisk65\\Partition4"}, - {"/dev/sdbn5", BRACK(FH_SDBN | 5), "\\Device\\Harddisk65\\Partition5"}, - {"/dev/sdbn6", BRACK(FH_SDBN | 6), "\\Device\\Harddisk65\\Partition6"}, - {"/dev/sdbn7", BRACK(FH_SDBN | 7), "\\Device\\Harddisk65\\Partition7"}, - {"/dev/sdbn8", BRACK(FH_SDBN | 8), "\\Device\\Harddisk65\\Partition8"}, - {"/dev/sdbn9", BRACK(FH_SDBN | 9), "\\Device\\Harddisk65\\Partition9"}, - {"/dev/sdbn10", BRACK(FH_SDBN | 10), "\\Device\\Harddisk65\\Partition10"}, - {"/dev/sdbn11", BRACK(FH_SDBN | 11), "\\Device\\Harddisk65\\Partition11"}, - {"/dev/sdbn12", BRACK(FH_SDBN | 12), "\\Device\\Harddisk65\\Partition12"}, - {"/dev/sdbn13", BRACK(FH_SDBN | 13), "\\Device\\Harddisk65\\Partition13"}, - {"/dev/sdbn14", BRACK(FH_SDBN | 14), "\\Device\\Harddisk65\\Partition14"}, - {"/dev/sdbn15", BRACK(FH_SDBN | 15), "\\Device\\Harddisk65\\Partition15"}, - {"/dev/sdbo1", BRACK(FH_SDBO | 1), "\\Device\\Harddisk66\\Partition1"}, - {"/dev/sdbo2", BRACK(FH_SDBO | 2), "\\Device\\Harddisk66\\Partition2"}, - {"/dev/sdbo3", BRACK(FH_SDBO | 3), "\\Device\\Harddisk66\\Partition3"}, - {"/dev/sdbo4", BRACK(FH_SDBO | 4), "\\Device\\Harddisk66\\Partition4"}, - {"/dev/sdbo5", BRACK(FH_SDBO | 5), "\\Device\\Harddisk66\\Partition5"}, - {"/dev/sdbo6", BRACK(FH_SDBO | 6), "\\Device\\Harddisk66\\Partition6"}, - {"/dev/sdbo7", BRACK(FH_SDBO | 7), "\\Device\\Harddisk66\\Partition7"}, - {"/dev/sdbo8", BRACK(FH_SDBO | 8), "\\Device\\Harddisk66\\Partition8"}, - {"/dev/sdbo9", BRACK(FH_SDBO | 9), "\\Device\\Harddisk66\\Partition9"}, - {"/dev/sdbo10", BRACK(FH_SDBO | 10), "\\Device\\Harddisk66\\Partition10"}, - {"/dev/sdbo11", BRACK(FH_SDBO | 11), "\\Device\\Harddisk66\\Partition11"}, - {"/dev/sdbo12", BRACK(FH_SDBO | 12), "\\Device\\Harddisk66\\Partition12"}, - {"/dev/sdbo13", BRACK(FH_SDBO | 13), "\\Device\\Harddisk66\\Partition13"}, - {"/dev/sdbo14", BRACK(FH_SDBO | 14), "\\Device\\Harddisk66\\Partition14"}, - {"/dev/sdbo15", BRACK(FH_SDBO | 15), "\\Device\\Harddisk66\\Partition15"}, - {"/dev/sdbp1", BRACK(FH_SDBP | 1), "\\Device\\Harddisk67\\Partition1"}, - {"/dev/sdbp2", BRACK(FH_SDBP | 2), "\\Device\\Harddisk67\\Partition2"}, - {"/dev/sdbp3", BRACK(FH_SDBP | 3), "\\Device\\Harddisk67\\Partition3"}, - {"/dev/sdbp4", BRACK(FH_SDBP | 4), "\\Device\\Harddisk67\\Partition4"}, - {"/dev/sdbp5", BRACK(FH_SDBP | 5), "\\Device\\Harddisk67\\Partition5"}, - {"/dev/sdbp6", BRACK(FH_SDBP | 6), "\\Device\\Harddisk67\\Partition6"}, - {"/dev/sdbp7", BRACK(FH_SDBP | 7), "\\Device\\Harddisk67\\Partition7"}, - {"/dev/sdbp8", BRACK(FH_SDBP | 8), "\\Device\\Harddisk67\\Partition8"}, - {"/dev/sdbp9", BRACK(FH_SDBP | 9), "\\Device\\Harddisk67\\Partition9"}, - {"/dev/sdbp10", BRACK(FH_SDBP | 10), "\\Device\\Harddisk67\\Partition10"}, - {"/dev/sdbp11", BRACK(FH_SDBP | 11), "\\Device\\Harddisk67\\Partition11"}, - {"/dev/sdbp12", BRACK(FH_SDBP | 12), "\\Device\\Harddisk67\\Partition12"}, - {"/dev/sdbp13", BRACK(FH_SDBP | 13), "\\Device\\Harddisk67\\Partition13"}, - {"/dev/sdbp14", BRACK(FH_SDBP | 14), "\\Device\\Harddisk67\\Partition14"}, - {"/dev/sdbp15", BRACK(FH_SDBP | 15), "\\Device\\Harddisk67\\Partition15"}, - {"/dev/sdbq1", BRACK(FH_SDBQ | 1), "\\Device\\Harddisk68\\Partition1"}, - {"/dev/sdbq2", BRACK(FH_SDBQ | 2), "\\Device\\Harddisk68\\Partition2"}, - {"/dev/sdbq3", BRACK(FH_SDBQ | 3), "\\Device\\Harddisk68\\Partition3"}, - {"/dev/sdbq4", BRACK(FH_SDBQ | 4), "\\Device\\Harddisk68\\Partition4"}, - {"/dev/sdbq5", BRACK(FH_SDBQ | 5), "\\Device\\Harddisk68\\Partition5"}, - {"/dev/sdbq6", BRACK(FH_SDBQ | 6), "\\Device\\Harddisk68\\Partition6"}, - {"/dev/sdbq7", BRACK(FH_SDBQ | 7), "\\Device\\Harddisk68\\Partition7"}, - {"/dev/sdbq8", BRACK(FH_SDBQ | 8), "\\Device\\Harddisk68\\Partition8"}, - {"/dev/sdbq9", BRACK(FH_SDBQ | 9), "\\Device\\Harddisk68\\Partition9"}, - {"/dev/sdbq10", BRACK(FH_SDBQ | 10), "\\Device\\Harddisk68\\Partition10"}, - {"/dev/sdbq11", BRACK(FH_SDBQ | 11), "\\Device\\Harddisk68\\Partition11"}, - {"/dev/sdbq12", BRACK(FH_SDBQ | 12), "\\Device\\Harddisk68\\Partition12"}, - {"/dev/sdbq13", BRACK(FH_SDBQ | 13), "\\Device\\Harddisk68\\Partition13"}, - {"/dev/sdbq14", BRACK(FH_SDBQ | 14), "\\Device\\Harddisk68\\Partition14"}, - {"/dev/sdbq15", BRACK(FH_SDBQ | 15), "\\Device\\Harddisk68\\Partition15"}, - {"/dev/sdbr1", BRACK(FH_SDBR | 1), "\\Device\\Harddisk69\\Partition1"}, - {"/dev/sdbr2", BRACK(FH_SDBR | 2), "\\Device\\Harddisk69\\Partition2"}, - {"/dev/sdbr3", BRACK(FH_SDBR | 3), "\\Device\\Harddisk69\\Partition3"}, - {"/dev/sdbr4", BRACK(FH_SDBR | 4), "\\Device\\Harddisk69\\Partition4"}, - {"/dev/sdbr5", BRACK(FH_SDBR | 5), "\\Device\\Harddisk69\\Partition5"}, - {"/dev/sdbr6", BRACK(FH_SDBR | 6), "\\Device\\Harddisk69\\Partition6"}, - {"/dev/sdbr7", BRACK(FH_SDBR | 7), "\\Device\\Harddisk69\\Partition7"}, - {"/dev/sdbr8", BRACK(FH_SDBR | 8), "\\Device\\Harddisk69\\Partition8"}, - {"/dev/sdbr9", BRACK(FH_SDBR | 9), "\\Device\\Harddisk69\\Partition9"}, - {"/dev/sdbr10", BRACK(FH_SDBR | 10), "\\Device\\Harddisk69\\Partition10"}, - {"/dev/sdbr11", BRACK(FH_SDBR | 11), "\\Device\\Harddisk69\\Partition11"}, - {"/dev/sdbr12", BRACK(FH_SDBR | 12), "\\Device\\Harddisk69\\Partition12"}, - {"/dev/sdbr13", BRACK(FH_SDBR | 13), "\\Device\\Harddisk69\\Partition13"}, - {"/dev/sdbr14", BRACK(FH_SDBR | 14), "\\Device\\Harddisk69\\Partition14"}, - {"/dev/sdbr15", BRACK(FH_SDBR | 15), "\\Device\\Harddisk69\\Partition15"}, - {"/dev/sdbs1", BRACK(FH_SDBS | 1), "\\Device\\Harddisk70\\Partition1"}, - {"/dev/sdbs2", BRACK(FH_SDBS | 2), "\\Device\\Harddisk70\\Partition2"}, - {"/dev/sdbs3", BRACK(FH_SDBS | 3), "\\Device\\Harddisk70\\Partition3"}, - {"/dev/sdbs4", BRACK(FH_SDBS | 4), "\\Device\\Harddisk70\\Partition4"}, - {"/dev/sdbs5", BRACK(FH_SDBS | 5), "\\Device\\Harddisk70\\Partition5"}, - {"/dev/sdbs6", BRACK(FH_SDBS | 6), "\\Device\\Harddisk70\\Partition6"}, - {"/dev/sdbs7", BRACK(FH_SDBS | 7), "\\Device\\Harddisk70\\Partition7"}, - {"/dev/sdbs8", BRACK(FH_SDBS | 8), "\\Device\\Harddisk70\\Partition8"}, - {"/dev/sdbs9", BRACK(FH_SDBS | 9), "\\Device\\Harddisk70\\Partition9"}, - {"/dev/sdbs10", BRACK(FH_SDBS | 10), "\\Device\\Harddisk70\\Partition10"}, - {"/dev/sdbs11", BRACK(FH_SDBS | 11), "\\Device\\Harddisk70\\Partition11"}, - {"/dev/sdbs12", BRACK(FH_SDBS | 12), "\\Device\\Harddisk70\\Partition12"}, - {"/dev/sdbs13", BRACK(FH_SDBS | 13), "\\Device\\Harddisk70\\Partition13"}, - {"/dev/sdbs14", BRACK(FH_SDBS | 14), "\\Device\\Harddisk70\\Partition14"}, - {"/dev/sdbs15", BRACK(FH_SDBS | 15), "\\Device\\Harddisk70\\Partition15"}, - {"/dev/sdbt1", BRACK(FH_SDBT | 1), "\\Device\\Harddisk71\\Partition1"}, - {"/dev/sdbt2", BRACK(FH_SDBT | 2), "\\Device\\Harddisk71\\Partition2"}, - {"/dev/sdbt3", BRACK(FH_SDBT | 3), "\\Device\\Harddisk71\\Partition3"}, - {"/dev/sdbt4", BRACK(FH_SDBT | 4), "\\Device\\Harddisk71\\Partition4"}, - {"/dev/sdbt5", BRACK(FH_SDBT | 5), "\\Device\\Harddisk71\\Partition5"}, - {"/dev/sdbt6", BRACK(FH_SDBT | 6), "\\Device\\Harddisk71\\Partition6"}, - {"/dev/sdbt7", BRACK(FH_SDBT | 7), "\\Device\\Harddisk71\\Partition7"}, - {"/dev/sdbt8", BRACK(FH_SDBT | 8), "\\Device\\Harddisk71\\Partition8"}, - {"/dev/sdbt9", BRACK(FH_SDBT | 9), "\\Device\\Harddisk71\\Partition9"}, - {"/dev/sdbt10", BRACK(FH_SDBT | 10), "\\Device\\Harddisk71\\Partition10"}, - {"/dev/sdbt11", BRACK(FH_SDBT | 11), "\\Device\\Harddisk71\\Partition11"}, - {"/dev/sdbt12", BRACK(FH_SDBT | 12), "\\Device\\Harddisk71\\Partition12"}, - {"/dev/sdbt13", BRACK(FH_SDBT | 13), "\\Device\\Harddisk71\\Partition13"}, - {"/dev/sdbt14", BRACK(FH_SDBT | 14), "\\Device\\Harddisk71\\Partition14"}, - {"/dev/sdbt15", BRACK(FH_SDBT | 15), "\\Device\\Harddisk71\\Partition15"}, - {"/dev/sdbu1", BRACK(FH_SDBU | 1), "\\Device\\Harddisk72\\Partition1"}, - {"/dev/sdbu2", BRACK(FH_SDBU | 2), "\\Device\\Harddisk72\\Partition2"}, - {"/dev/sdbu3", BRACK(FH_SDBU | 3), "\\Device\\Harddisk72\\Partition3"}, - {"/dev/sdbu4", BRACK(FH_SDBU | 4), "\\Device\\Harddisk72\\Partition4"}, - {"/dev/sdbu5", BRACK(FH_SDBU | 5), "\\Device\\Harddisk72\\Partition5"}, - {"/dev/sdbu6", BRACK(FH_SDBU | 6), "\\Device\\Harddisk72\\Partition6"}, - {"/dev/sdbu7", BRACK(FH_SDBU | 7), "\\Device\\Harddisk72\\Partition7"}, - {"/dev/sdbu8", BRACK(FH_SDBU | 8), "\\Device\\Harddisk72\\Partition8"}, - {"/dev/sdbu9", BRACK(FH_SDBU | 9), "\\Device\\Harddisk72\\Partition9"}, - {"/dev/sdbu10", BRACK(FH_SDBU | 10), "\\Device\\Harddisk72\\Partition10"}, - {"/dev/sdbu11", BRACK(FH_SDBU | 11), "\\Device\\Harddisk72\\Partition11"}, - {"/dev/sdbu12", BRACK(FH_SDBU | 12), "\\Device\\Harddisk72\\Partition12"}, - {"/dev/sdbu13", BRACK(FH_SDBU | 13), "\\Device\\Harddisk72\\Partition13"}, - {"/dev/sdbu14", BRACK(FH_SDBU | 14), "\\Device\\Harddisk72\\Partition14"}, - {"/dev/sdbu15", BRACK(FH_SDBU | 15), "\\Device\\Harddisk72\\Partition15"}, - {"/dev/sdbv1", BRACK(FH_SDBV | 1), "\\Device\\Harddisk73\\Partition1"}, - {"/dev/sdbv2", BRACK(FH_SDBV | 2), "\\Device\\Harddisk73\\Partition2"}, - {"/dev/sdbv3", BRACK(FH_SDBV | 3), "\\Device\\Harddisk73\\Partition3"}, - {"/dev/sdbv4", BRACK(FH_SDBV | 4), "\\Device\\Harddisk73\\Partition4"}, - {"/dev/sdbv5", BRACK(FH_SDBV | 5), "\\Device\\Harddisk73\\Partition5"}, - {"/dev/sdbv6", BRACK(FH_SDBV | 6), "\\Device\\Harddisk73\\Partition6"}, - {"/dev/sdbv7", BRACK(FH_SDBV | 7), "\\Device\\Harddisk73\\Partition7"}, - {"/dev/sdbv8", BRACK(FH_SDBV | 8), "\\Device\\Harddisk73\\Partition8"}, - {"/dev/sdbv9", BRACK(FH_SDBV | 9), "\\Device\\Harddisk73\\Partition9"}, - {"/dev/sdbv10", BRACK(FH_SDBV | 10), "\\Device\\Harddisk73\\Partition10"}, - {"/dev/sdbv11", BRACK(FH_SDBV | 11), "\\Device\\Harddisk73\\Partition11"}, - {"/dev/sdbv12", BRACK(FH_SDBV | 12), "\\Device\\Harddisk73\\Partition12"}, - {"/dev/sdbv13", BRACK(FH_SDBV | 13), "\\Device\\Harddisk73\\Partition13"}, - {"/dev/sdbv14", BRACK(FH_SDBV | 14), "\\Device\\Harddisk73\\Partition14"}, - {"/dev/sdbv15", BRACK(FH_SDBV | 15), "\\Device\\Harddisk73\\Partition15"}, - {"/dev/sdbw1", BRACK(FH_SDBW | 1), "\\Device\\Harddisk74\\Partition1"}, - {"/dev/sdbw2", BRACK(FH_SDBW | 2), "\\Device\\Harddisk74\\Partition2"}, - {"/dev/sdbw3", BRACK(FH_SDBW | 3), "\\Device\\Harddisk74\\Partition3"}, - {"/dev/sdbw4", BRACK(FH_SDBW | 4), "\\Device\\Harddisk74\\Partition4"}, - {"/dev/sdbw5", BRACK(FH_SDBW | 5), "\\Device\\Harddisk74\\Partition5"}, - {"/dev/sdbw6", BRACK(FH_SDBW | 6), "\\Device\\Harddisk74\\Partition6"}, - {"/dev/sdbw7", BRACK(FH_SDBW | 7), "\\Device\\Harddisk74\\Partition7"}, - {"/dev/sdbw8", BRACK(FH_SDBW | 8), "\\Device\\Harddisk74\\Partition8"}, - {"/dev/sdbw9", BRACK(FH_SDBW | 9), "\\Device\\Harddisk74\\Partition9"}, - {"/dev/sdbw10", BRACK(FH_SDBW | 10), "\\Device\\Harddisk74\\Partition10"}, - {"/dev/sdbw11", BRACK(FH_SDBW | 11), "\\Device\\Harddisk74\\Partition11"}, - {"/dev/sdbw12", BRACK(FH_SDBW | 12), "\\Device\\Harddisk74\\Partition12"}, - {"/dev/sdbw13", BRACK(FH_SDBW | 13), "\\Device\\Harddisk74\\Partition13"}, - {"/dev/sdbw14", BRACK(FH_SDBW | 14), "\\Device\\Harddisk74\\Partition14"}, - {"/dev/sdbw15", BRACK(FH_SDBW | 15), "\\Device\\Harddisk74\\Partition15"}, - {"/dev/sdbx1", BRACK(FH_SDBX | 1), "\\Device\\Harddisk75\\Partition1"}, - {"/dev/sdbx2", BRACK(FH_SDBX | 2), "\\Device\\Harddisk75\\Partition2"}, - {"/dev/sdbx3", BRACK(FH_SDBX | 3), "\\Device\\Harddisk75\\Partition3"}, - {"/dev/sdbx4", BRACK(FH_SDBX | 4), "\\Device\\Harddisk75\\Partition4"}, - {"/dev/sdbx5", BRACK(FH_SDBX | 5), "\\Device\\Harddisk75\\Partition5"}, - {"/dev/sdbx6", BRACK(FH_SDBX | 6), "\\Device\\Harddisk75\\Partition6"}, - {"/dev/sdbx7", BRACK(FH_SDBX | 7), "\\Device\\Harddisk75\\Partition7"}, - {"/dev/sdbx8", BRACK(FH_SDBX | 8), "\\Device\\Harddisk75\\Partition8"}, - {"/dev/sdbx9", BRACK(FH_SDBX | 9), "\\Device\\Harddisk75\\Partition9"}, - {"/dev/sdbx10", BRACK(FH_SDBX | 10), "\\Device\\Harddisk75\\Partition10"}, - {"/dev/sdbx11", BRACK(FH_SDBX | 11), "\\Device\\Harddisk75\\Partition11"}, - {"/dev/sdbx12", BRACK(FH_SDBX | 12), "\\Device\\Harddisk75\\Partition12"}, - {"/dev/sdbx13", BRACK(FH_SDBX | 13), "\\Device\\Harddisk75\\Partition13"}, - {"/dev/sdbx14", BRACK(FH_SDBX | 14), "\\Device\\Harddisk75\\Partition14"}, - {"/dev/sdbx15", BRACK(FH_SDBX | 15), "\\Device\\Harddisk75\\Partition15"}, - {"/dev/sdby1", BRACK(FH_SDBY | 1), "\\Device\\Harddisk76\\Partition1"}, - {"/dev/sdby2", BRACK(FH_SDBY | 2), "\\Device\\Harddisk76\\Partition2"}, - {"/dev/sdby3", BRACK(FH_SDBY | 3), "\\Device\\Harddisk76\\Partition3"}, - {"/dev/sdby4", BRACK(FH_SDBY | 4), "\\Device\\Harddisk76\\Partition4"}, - {"/dev/sdby5", BRACK(FH_SDBY | 5), "\\Device\\Harddisk76\\Partition5"}, - {"/dev/sdby6", BRACK(FH_SDBY | 6), "\\Device\\Harddisk76\\Partition6"}, - {"/dev/sdby7", BRACK(FH_SDBY | 7), "\\Device\\Harddisk76\\Partition7"}, - {"/dev/sdby8", BRACK(FH_SDBY | 8), "\\Device\\Harddisk76\\Partition8"}, - {"/dev/sdby9", BRACK(FH_SDBY | 9), "\\Device\\Harddisk76\\Partition9"}, - {"/dev/sdby10", BRACK(FH_SDBY | 10), "\\Device\\Harddisk76\\Partition10"}, - {"/dev/sdby11", BRACK(FH_SDBY | 11), "\\Device\\Harddisk76\\Partition11"}, - {"/dev/sdby12", BRACK(FH_SDBY | 12), "\\Device\\Harddisk76\\Partition12"}, - {"/dev/sdby13", BRACK(FH_SDBY | 13), "\\Device\\Harddisk76\\Partition13"}, - {"/dev/sdby14", BRACK(FH_SDBY | 14), "\\Device\\Harddisk76\\Partition14"}, - {"/dev/sdby15", BRACK(FH_SDBY | 15), "\\Device\\Harddisk76\\Partition15"}, - {"/dev/sdbz1", BRACK(FH_SDBZ | 1), "\\Device\\Harddisk77\\Partition1"}, - {"/dev/sdbz2", BRACK(FH_SDBZ | 2), "\\Device\\Harddisk77\\Partition2"}, - {"/dev/sdbz3", BRACK(FH_SDBZ | 3), "\\Device\\Harddisk77\\Partition3"}, - {"/dev/sdbz4", BRACK(FH_SDBZ | 4), "\\Device\\Harddisk77\\Partition4"}, - {"/dev/sdbz5", BRACK(FH_SDBZ | 5), "\\Device\\Harddisk77\\Partition5"}, - {"/dev/sdbz6", BRACK(FH_SDBZ | 6), "\\Device\\Harddisk77\\Partition6"}, - {"/dev/sdbz7", BRACK(FH_SDBZ | 7), "\\Device\\Harddisk77\\Partition7"}, - {"/dev/sdbz8", BRACK(FH_SDBZ | 8), "\\Device\\Harddisk77\\Partition8"}, - {"/dev/sdbz9", BRACK(FH_SDBZ | 9), "\\Device\\Harddisk77\\Partition9"}, - {"/dev/sdbz10", BRACK(FH_SDBZ | 10), "\\Device\\Harddisk77\\Partition10"}, - {"/dev/sdbz11", BRACK(FH_SDBZ | 11), "\\Device\\Harddisk77\\Partition11"}, - {"/dev/sdbz12", BRACK(FH_SDBZ | 12), "\\Device\\Harddisk77\\Partition12"}, - {"/dev/sdbz13", BRACK(FH_SDBZ | 13), "\\Device\\Harddisk77\\Partition13"}, - {"/dev/sdbz14", BRACK(FH_SDBZ | 14), "\\Device\\Harddisk77\\Partition14"}, - {"/dev/sdbz15", BRACK(FH_SDBZ | 15), "\\Device\\Harddisk77\\Partition15"}, - {"/dev/sdca", BRACK(FH_SDCA), "\\Device\\Harddisk78\\Partition0"}, - {"/dev/sdcb", BRACK(FH_SDCB), "\\Device\\Harddisk79\\Partition0"}, - {"/dev/sdcc", BRACK(FH_SDCC), "\\Device\\Harddisk80\\Partition0"}, - {"/dev/sdcd", BRACK(FH_SDCD), "\\Device\\Harddisk81\\Partition0"}, - {"/dev/sdce", BRACK(FH_SDCE), "\\Device\\Harddisk82\\Partition0"}, - {"/dev/sdcf", BRACK(FH_SDCF), "\\Device\\Harddisk83\\Partition0"}, - {"/dev/sdcg", BRACK(FH_SDCG), "\\Device\\Harddisk84\\Partition0"}, - {"/dev/sdch", BRACK(FH_SDCH), "\\Device\\Harddisk85\\Partition0"}, - {"/dev/sdci", BRACK(FH_SDCI), "\\Device\\Harddisk86\\Partition0"}, - {"/dev/sdcj", BRACK(FH_SDCJ), "\\Device\\Harddisk87\\Partition0"}, - {"/dev/sdck", BRACK(FH_SDCK), "\\Device\\Harddisk88\\Partition0"}, - {"/dev/sdcl", BRACK(FH_SDCL), "\\Device\\Harddisk89\\Partition0"}, - {"/dev/sdcm", BRACK(FH_SDCM), "\\Device\\Harddisk90\\Partition0"}, - {"/dev/sdcn", BRACK(FH_SDCN), "\\Device\\Harddisk91\\Partition0"}, - {"/dev/sdco", BRACK(FH_SDCO), "\\Device\\Harddisk92\\Partition0"}, - {"/dev/sdcp", BRACK(FH_SDCP), "\\Device\\Harddisk93\\Partition0"}, - {"/dev/sdcq", BRACK(FH_SDCQ), "\\Device\\Harddisk94\\Partition0"}, - {"/dev/sdcr", BRACK(FH_SDCR), "\\Device\\Harddisk95\\Partition0"}, - {"/dev/sdcs", BRACK(FH_SDCS), "\\Device\\Harddisk96\\Partition0"}, - {"/dev/sdct", BRACK(FH_SDCT), "\\Device\\Harddisk97\\Partition0"}, - {"/dev/sdcu", BRACK(FH_SDCU), "\\Device\\Harddisk98\\Partition0"}, - {"/dev/sdcv", BRACK(FH_SDCV), "\\Device\\Harddisk99\\Partition0"}, - {"/dev/sdcw", BRACK(FH_SDCW), "\\Device\\Harddisk100\\Partition0"}, - {"/dev/sdcx", BRACK(FH_SDCX), "\\Device\\Harddisk101\\Partition0"}, - {"/dev/sdcy", BRACK(FH_SDCY), "\\Device\\Harddisk102\\Partition0"}, - {"/dev/sdcz", BRACK(FH_SDCZ), "\\Device\\Harddisk103\\Partition0"}, - {"/dev/sdca1", BRACK(FH_SDCA | 1), "\\Device\\Harddisk78\\Partition1"}, - {"/dev/sdca2", BRACK(FH_SDCA | 2), "\\Device\\Harddisk78\\Partition2"}, - {"/dev/sdca3", BRACK(FH_SDCA | 3), "\\Device\\Harddisk78\\Partition3"}, - {"/dev/sdca4", BRACK(FH_SDCA | 4), "\\Device\\Harddisk78\\Partition4"}, - {"/dev/sdca5", BRACK(FH_SDCA | 5), "\\Device\\Harddisk78\\Partition5"}, - {"/dev/sdca6", BRACK(FH_SDCA | 6), "\\Device\\Harddisk78\\Partition6"}, - {"/dev/sdca7", BRACK(FH_SDCA | 7), "\\Device\\Harddisk78\\Partition7"}, - {"/dev/sdca8", BRACK(FH_SDCA | 8), "\\Device\\Harddisk78\\Partition8"}, - {"/dev/sdca9", BRACK(FH_SDCA | 9), "\\Device\\Harddisk78\\Partition9"}, - {"/dev/sdca10", BRACK(FH_SDCA | 10), "\\Device\\Harddisk78\\Partition10"}, - {"/dev/sdca11", BRACK(FH_SDCA | 11), "\\Device\\Harddisk78\\Partition11"}, - {"/dev/sdca12", BRACK(FH_SDCA | 12), "\\Device\\Harddisk78\\Partition12"}, - {"/dev/sdca13", BRACK(FH_SDCA | 13), "\\Device\\Harddisk78\\Partition13"}, - {"/dev/sdca14", BRACK(FH_SDCA | 14), "\\Device\\Harddisk78\\Partition14"}, - {"/dev/sdca15", BRACK(FH_SDCA | 15), "\\Device\\Harddisk78\\Partition15"}, - {"/dev/sdcb1", BRACK(FH_SDCB | 1), "\\Device\\Harddisk79\\Partition1"}, - {"/dev/sdcb2", BRACK(FH_SDCB | 2), "\\Device\\Harddisk79\\Partition2"}, - {"/dev/sdcb3", BRACK(FH_SDCB | 3), "\\Device\\Harddisk79\\Partition3"}, - {"/dev/sdcb4", BRACK(FH_SDCB | 4), "\\Device\\Harddisk79\\Partition4"}, - {"/dev/sdcb5", BRACK(FH_SDCB | 5), "\\Device\\Harddisk79\\Partition5"}, - {"/dev/sdcb6", BRACK(FH_SDCB | 6), "\\Device\\Harddisk79\\Partition6"}, - {"/dev/sdcb7", BRACK(FH_SDCB | 7), "\\Device\\Harddisk79\\Partition7"}, - {"/dev/sdcb8", BRACK(FH_SDCB | 8), "\\Device\\Harddisk79\\Partition8"}, - {"/dev/sdcb9", BRACK(FH_SDCB | 9), "\\Device\\Harddisk79\\Partition9"}, - {"/dev/sdcb10", BRACK(FH_SDCB | 10), "\\Device\\Harddisk79\\Partition10"}, - {"/dev/sdcb11", BRACK(FH_SDCB | 11), "\\Device\\Harddisk79\\Partition11"}, - {"/dev/sdcb12", BRACK(FH_SDCB | 12), "\\Device\\Harddisk79\\Partition12"}, - {"/dev/sdcb13", BRACK(FH_SDCB | 13), "\\Device\\Harddisk79\\Partition13"}, - {"/dev/sdcb14", BRACK(FH_SDCB | 14), "\\Device\\Harddisk79\\Partition14"}, - {"/dev/sdcb15", BRACK(FH_SDCB | 15), "\\Device\\Harddisk79\\Partition15"}, - {"/dev/sdcc1", BRACK(FH_SDCC | 1), "\\Device\\Harddisk80\\Partition1"}, - {"/dev/sdcc2", BRACK(FH_SDCC | 2), "\\Device\\Harddisk80\\Partition2"}, - {"/dev/sdcc3", BRACK(FH_SDCC | 3), "\\Device\\Harddisk80\\Partition3"}, - {"/dev/sdcc4", BRACK(FH_SDCC | 4), "\\Device\\Harddisk80\\Partition4"}, - {"/dev/sdcc5", BRACK(FH_SDCC | 5), "\\Device\\Harddisk80\\Partition5"}, - {"/dev/sdcc6", BRACK(FH_SDCC | 6), "\\Device\\Harddisk80\\Partition6"}, - {"/dev/sdcc7", BRACK(FH_SDCC | 7), "\\Device\\Harddisk80\\Partition7"}, - {"/dev/sdcc8", BRACK(FH_SDCC | 8), "\\Device\\Harddisk80\\Partition8"}, - {"/dev/sdcc9", BRACK(FH_SDCC | 9), "\\Device\\Harddisk80\\Partition9"}, - {"/dev/sdcc10", BRACK(FH_SDCC | 10), "\\Device\\Harddisk80\\Partition10"}, - {"/dev/sdcc11", BRACK(FH_SDCC | 11), "\\Device\\Harddisk80\\Partition11"}, - {"/dev/sdcc12", BRACK(FH_SDCC | 12), "\\Device\\Harddisk80\\Partition12"}, - {"/dev/sdcc13", BRACK(FH_SDCC | 13), "\\Device\\Harddisk80\\Partition13"}, - {"/dev/sdcc14", BRACK(FH_SDCC | 14), "\\Device\\Harddisk80\\Partition14"}, - {"/dev/sdcc15", BRACK(FH_SDCC | 15), "\\Device\\Harddisk80\\Partition15"}, - {"/dev/sdcd1", BRACK(FH_SDCD | 1), "\\Device\\Harddisk81\\Partition1"}, - {"/dev/sdcd2", BRACK(FH_SDCD | 2), "\\Device\\Harddisk81\\Partition2"}, - {"/dev/sdcd3", BRACK(FH_SDCD | 3), "\\Device\\Harddisk81\\Partition3"}, - {"/dev/sdcd4", BRACK(FH_SDCD | 4), "\\Device\\Harddisk81\\Partition4"}, - {"/dev/sdcd5", BRACK(FH_SDCD | 5), "\\Device\\Harddisk81\\Partition5"}, - {"/dev/sdcd6", BRACK(FH_SDCD | 6), "\\Device\\Harddisk81\\Partition6"}, - {"/dev/sdcd7", BRACK(FH_SDCD | 7), "\\Device\\Harddisk81\\Partition7"}, - {"/dev/sdcd8", BRACK(FH_SDCD | 8), "\\Device\\Harddisk81\\Partition8"}, - {"/dev/sdcd9", BRACK(FH_SDCD | 9), "\\Device\\Harddisk81\\Partition9"}, - {"/dev/sdcd10", BRACK(FH_SDCD | 10), "\\Device\\Harddisk81\\Partition10"}, - {"/dev/sdcd11", BRACK(FH_SDCD | 11), "\\Device\\Harddisk81\\Partition11"}, - {"/dev/sdcd12", BRACK(FH_SDCD | 12), "\\Device\\Harddisk81\\Partition12"}, - {"/dev/sdcd13", BRACK(FH_SDCD | 13), "\\Device\\Harddisk81\\Partition13"}, - {"/dev/sdcd14", BRACK(FH_SDCD | 14), "\\Device\\Harddisk81\\Partition14"}, - {"/dev/sdcd15", BRACK(FH_SDCD | 15), "\\Device\\Harddisk81\\Partition15"}, - {"/dev/sdce1", BRACK(FH_SDCE | 1), "\\Device\\Harddisk82\\Partition1"}, - {"/dev/sdce2", BRACK(FH_SDCE | 2), "\\Device\\Harddisk82\\Partition2"}, - {"/dev/sdce3", BRACK(FH_SDCE | 3), "\\Device\\Harddisk82\\Partition3"}, - {"/dev/sdce4", BRACK(FH_SDCE | 4), "\\Device\\Harddisk82\\Partition4"}, - {"/dev/sdce5", BRACK(FH_SDCE | 5), "\\Device\\Harddisk82\\Partition5"}, - {"/dev/sdce6", BRACK(FH_SDCE | 6), "\\Device\\Harddisk82\\Partition6"}, - {"/dev/sdce7", BRACK(FH_SDCE | 7), "\\Device\\Harddisk82\\Partition7"}, - {"/dev/sdce8", BRACK(FH_SDCE | 8), "\\Device\\Harddisk82\\Partition8"}, - {"/dev/sdce9", BRACK(FH_SDCE | 9), "\\Device\\Harddisk82\\Partition9"}, - {"/dev/sdce10", BRACK(FH_SDCE | 10), "\\Device\\Harddisk82\\Partition10"}, - {"/dev/sdce11", BRACK(FH_SDCE | 11), "\\Device\\Harddisk82\\Partition11"}, - {"/dev/sdce12", BRACK(FH_SDCE | 12), "\\Device\\Harddisk82\\Partition12"}, - {"/dev/sdce13", BRACK(FH_SDCE | 13), "\\Device\\Harddisk82\\Partition13"}, - {"/dev/sdce14", BRACK(FH_SDCE | 14), "\\Device\\Harddisk82\\Partition14"}, - {"/dev/sdce15", BRACK(FH_SDCE | 15), "\\Device\\Harddisk82\\Partition15"}, - {"/dev/sdcf1", BRACK(FH_SDCF | 1), "\\Device\\Harddisk83\\Partition1"}, - {"/dev/sdcf2", BRACK(FH_SDCF | 2), "\\Device\\Harddisk83\\Partition2"}, - {"/dev/sdcf3", BRACK(FH_SDCF | 3), "\\Device\\Harddisk83\\Partition3"}, - {"/dev/sdcf4", BRACK(FH_SDCF | 4), "\\Device\\Harddisk83\\Partition4"}, - {"/dev/sdcf5", BRACK(FH_SDCF | 5), "\\Device\\Harddisk83\\Partition5"}, - {"/dev/sdcf6", BRACK(FH_SDCF | 6), "\\Device\\Harddisk83\\Partition6"}, - {"/dev/sdcf7", BRACK(FH_SDCF | 7), "\\Device\\Harddisk83\\Partition7"}, - {"/dev/sdcf8", BRACK(FH_SDCF | 8), "\\Device\\Harddisk83\\Partition8"}, - {"/dev/sdcf9", BRACK(FH_SDCF | 9), "\\Device\\Harddisk83\\Partition9"}, - {"/dev/sdcf10", BRACK(FH_SDCF | 10), "\\Device\\Harddisk83\\Partition10"}, - {"/dev/sdcf11", BRACK(FH_SDCF | 11), "\\Device\\Harddisk83\\Partition11"}, - {"/dev/sdcf12", BRACK(FH_SDCF | 12), "\\Device\\Harddisk83\\Partition12"}, - {"/dev/sdcf13", BRACK(FH_SDCF | 13), "\\Device\\Harddisk83\\Partition13"}, - {"/dev/sdcf14", BRACK(FH_SDCF | 14), "\\Device\\Harddisk83\\Partition14"}, - {"/dev/sdcf15", BRACK(FH_SDCF | 15), "\\Device\\Harddisk83\\Partition15"}, - {"/dev/sdcg1", BRACK(FH_SDCG | 1), "\\Device\\Harddisk84\\Partition1"}, - {"/dev/sdcg2", BRACK(FH_SDCG | 2), "\\Device\\Harddisk84\\Partition2"}, - {"/dev/sdcg3", BRACK(FH_SDCG | 3), "\\Device\\Harddisk84\\Partition3"}, - {"/dev/sdcg4", BRACK(FH_SDCG | 4), "\\Device\\Harddisk84\\Partition4"}, - {"/dev/sdcg5", BRACK(FH_SDCG | 5), "\\Device\\Harddisk84\\Partition5"}, - {"/dev/sdcg6", BRACK(FH_SDCG | 6), "\\Device\\Harddisk84\\Partition6"}, - {"/dev/sdcg7", BRACK(FH_SDCG | 7), "\\Device\\Harddisk84\\Partition7"}, - {"/dev/sdcg8", BRACK(FH_SDCG | 8), "\\Device\\Harddisk84\\Partition8"}, - {"/dev/sdcg9", BRACK(FH_SDCG | 9), "\\Device\\Harddisk84\\Partition9"}, - {"/dev/sdcg10", BRACK(FH_SDCG | 10), "\\Device\\Harddisk84\\Partition10"}, - {"/dev/sdcg11", BRACK(FH_SDCG | 11), "\\Device\\Harddisk84\\Partition11"}, - {"/dev/sdcg12", BRACK(FH_SDCG | 12), "\\Device\\Harddisk84\\Partition12"}, - {"/dev/sdcg13", BRACK(FH_SDCG | 13), "\\Device\\Harddisk84\\Partition13"}, - {"/dev/sdcg14", BRACK(FH_SDCG | 14), "\\Device\\Harddisk84\\Partition14"}, - {"/dev/sdcg15", BRACK(FH_SDCG | 15), "\\Device\\Harddisk84\\Partition15"}, - {"/dev/sdch1", BRACK(FH_SDCH | 1), "\\Device\\Harddisk85\\Partition1"}, - {"/dev/sdch2", BRACK(FH_SDCH | 2), "\\Device\\Harddisk85\\Partition2"}, - {"/dev/sdch3", BRACK(FH_SDCH | 3), "\\Device\\Harddisk85\\Partition3"}, - {"/dev/sdch4", BRACK(FH_SDCH | 4), "\\Device\\Harddisk85\\Partition4"}, - {"/dev/sdch5", BRACK(FH_SDCH | 5), "\\Device\\Harddisk85\\Partition5"}, - {"/dev/sdch6", BRACK(FH_SDCH | 6), "\\Device\\Harddisk85\\Partition6"}, - {"/dev/sdch7", BRACK(FH_SDCH | 7), "\\Device\\Harddisk85\\Partition7"}, - {"/dev/sdch8", BRACK(FH_SDCH | 8), "\\Device\\Harddisk85\\Partition8"}, - {"/dev/sdch9", BRACK(FH_SDCH | 9), "\\Device\\Harddisk85\\Partition9"}, - {"/dev/sdch10", BRACK(FH_SDCH | 10), "\\Device\\Harddisk85\\Partition10"}, - {"/dev/sdch11", BRACK(FH_SDCH | 11), "\\Device\\Harddisk85\\Partition11"}, - {"/dev/sdch12", BRACK(FH_SDCH | 12), "\\Device\\Harddisk85\\Partition12"}, - {"/dev/sdch13", BRACK(FH_SDCH | 13), "\\Device\\Harddisk85\\Partition13"}, - {"/dev/sdch14", BRACK(FH_SDCH | 14), "\\Device\\Harddisk85\\Partition14"}, - {"/dev/sdch15", BRACK(FH_SDCH | 15), "\\Device\\Harddisk85\\Partition15"}, - {"/dev/sdci1", BRACK(FH_SDCI | 1), "\\Device\\Harddisk86\\Partition1"}, - {"/dev/sdci2", BRACK(FH_SDCI | 2), "\\Device\\Harddisk86\\Partition2"}, - {"/dev/sdci3", BRACK(FH_SDCI | 3), "\\Device\\Harddisk86\\Partition3"}, - {"/dev/sdci4", BRACK(FH_SDCI | 4), "\\Device\\Harddisk86\\Partition4"}, - {"/dev/sdci5", BRACK(FH_SDCI | 5), "\\Device\\Harddisk86\\Partition5"}, - {"/dev/sdci6", BRACK(FH_SDCI | 6), "\\Device\\Harddisk86\\Partition6"}, - {"/dev/sdci7", BRACK(FH_SDCI | 7), "\\Device\\Harddisk86\\Partition7"}, - {"/dev/sdci8", BRACK(FH_SDCI | 8), "\\Device\\Harddisk86\\Partition8"}, - {"/dev/sdci9", BRACK(FH_SDCI | 9), "\\Device\\Harddisk86\\Partition9"}, - {"/dev/sdci10", BRACK(FH_SDCI | 10), "\\Device\\Harddisk86\\Partition10"}, - {"/dev/sdci11", BRACK(FH_SDCI | 11), "\\Device\\Harddisk86\\Partition11"}, - {"/dev/sdci12", BRACK(FH_SDCI | 12), "\\Device\\Harddisk86\\Partition12"}, - {"/dev/sdci13", BRACK(FH_SDCI | 13), "\\Device\\Harddisk86\\Partition13"}, - {"/dev/sdci14", BRACK(FH_SDCI | 14), "\\Device\\Harddisk86\\Partition14"}, - {"/dev/sdci15", BRACK(FH_SDCI | 15), "\\Device\\Harddisk86\\Partition15"}, - {"/dev/sdcj1", BRACK(FH_SDCJ | 1), "\\Device\\Harddisk87\\Partition1"}, - {"/dev/sdcj2", BRACK(FH_SDCJ | 2), "\\Device\\Harddisk87\\Partition2"}, - {"/dev/sdcj3", BRACK(FH_SDCJ | 3), "\\Device\\Harddisk87\\Partition3"}, - {"/dev/sdcj4", BRACK(FH_SDCJ | 4), "\\Device\\Harddisk87\\Partition4"}, - {"/dev/sdcj5", BRACK(FH_SDCJ | 5), "\\Device\\Harddisk87\\Partition5"}, - {"/dev/sdcj6", BRACK(FH_SDCJ | 6), "\\Device\\Harddisk87\\Partition6"}, - {"/dev/sdcj7", BRACK(FH_SDCJ | 7), "\\Device\\Harddisk87\\Partition7"}, - {"/dev/sdcj8", BRACK(FH_SDCJ | 8), "\\Device\\Harddisk87\\Partition8"}, - {"/dev/sdcj9", BRACK(FH_SDCJ | 9), "\\Device\\Harddisk87\\Partition9"}, - {"/dev/sdcj10", BRACK(FH_SDCJ | 10), "\\Device\\Harddisk87\\Partition10"}, - {"/dev/sdcj11", BRACK(FH_SDCJ | 11), "\\Device\\Harddisk87\\Partition11"}, - {"/dev/sdcj12", BRACK(FH_SDCJ | 12), "\\Device\\Harddisk87\\Partition12"}, - {"/dev/sdcj13", BRACK(FH_SDCJ | 13), "\\Device\\Harddisk87\\Partition13"}, - {"/dev/sdcj14", BRACK(FH_SDCJ | 14), "\\Device\\Harddisk87\\Partition14"}, - {"/dev/sdcj15", BRACK(FH_SDCJ | 15), "\\Device\\Harddisk87\\Partition15"}, - {"/dev/sdck1", BRACK(FH_SDCK | 1), "\\Device\\Harddisk88\\Partition1"}, - {"/dev/sdck2", BRACK(FH_SDCK | 2), "\\Device\\Harddisk88\\Partition2"}, - {"/dev/sdck3", BRACK(FH_SDCK | 3), "\\Device\\Harddisk88\\Partition3"}, - {"/dev/sdck4", BRACK(FH_SDCK | 4), "\\Device\\Harddisk88\\Partition4"}, - {"/dev/sdck5", BRACK(FH_SDCK | 5), "\\Device\\Harddisk88\\Partition5"}, - {"/dev/sdck6", BRACK(FH_SDCK | 6), "\\Device\\Harddisk88\\Partition6"}, - {"/dev/sdck7", BRACK(FH_SDCK | 7), "\\Device\\Harddisk88\\Partition7"}, - {"/dev/sdck8", BRACK(FH_SDCK | 8), "\\Device\\Harddisk88\\Partition8"}, - {"/dev/sdck9", BRACK(FH_SDCK | 9), "\\Device\\Harddisk88\\Partition9"}, - {"/dev/sdck10", BRACK(FH_SDCK | 10), "\\Device\\Harddisk88\\Partition10"}, - {"/dev/sdck11", BRACK(FH_SDCK | 11), "\\Device\\Harddisk88\\Partition11"}, - {"/dev/sdck12", BRACK(FH_SDCK | 12), "\\Device\\Harddisk88\\Partition12"}, - {"/dev/sdck13", BRACK(FH_SDCK | 13), "\\Device\\Harddisk88\\Partition13"}, - {"/dev/sdck14", BRACK(FH_SDCK | 14), "\\Device\\Harddisk88\\Partition14"}, - {"/dev/sdck15", BRACK(FH_SDCK | 15), "\\Device\\Harddisk88\\Partition15"}, - {"/dev/sdcl1", BRACK(FH_SDCL | 1), "\\Device\\Harddisk89\\Partition1"}, - {"/dev/sdcl2", BRACK(FH_SDCL | 2), "\\Device\\Harddisk89\\Partition2"}, - {"/dev/sdcl3", BRACK(FH_SDCL | 3), "\\Device\\Harddisk89\\Partition3"}, - {"/dev/sdcl4", BRACK(FH_SDCL | 4), "\\Device\\Harddisk89\\Partition4"}, - {"/dev/sdcl5", BRACK(FH_SDCL | 5), "\\Device\\Harddisk89\\Partition5"}, - {"/dev/sdcl6", BRACK(FH_SDCL | 6), "\\Device\\Harddisk89\\Partition6"}, - {"/dev/sdcl7", BRACK(FH_SDCL | 7), "\\Device\\Harddisk89\\Partition7"}, - {"/dev/sdcl8", BRACK(FH_SDCL | 8), "\\Device\\Harddisk89\\Partition8"}, - {"/dev/sdcl9", BRACK(FH_SDCL | 9), "\\Device\\Harddisk89\\Partition9"}, - {"/dev/sdcl10", BRACK(FH_SDCL | 10), "\\Device\\Harddisk89\\Partition10"}, - {"/dev/sdcl11", BRACK(FH_SDCL | 11), "\\Device\\Harddisk89\\Partition11"}, - {"/dev/sdcl12", BRACK(FH_SDCL | 12), "\\Device\\Harddisk89\\Partition12"}, - {"/dev/sdcl13", BRACK(FH_SDCL | 13), "\\Device\\Harddisk89\\Partition13"}, - {"/dev/sdcl14", BRACK(FH_SDCL | 14), "\\Device\\Harddisk89\\Partition14"}, - {"/dev/sdcl15", BRACK(FH_SDCL | 15), "\\Device\\Harddisk89\\Partition15"}, - {"/dev/sdcm1", BRACK(FH_SDCM | 1), "\\Device\\Harddisk90\\Partition1"}, - {"/dev/sdcm2", BRACK(FH_SDCM | 2), "\\Device\\Harddisk90\\Partition2"}, - {"/dev/sdcm3", BRACK(FH_SDCM | 3), "\\Device\\Harddisk90\\Partition3"}, - {"/dev/sdcm4", BRACK(FH_SDCM | 4), "\\Device\\Harddisk90\\Partition4"}, - {"/dev/sdcm5", BRACK(FH_SDCM | 5), "\\Device\\Harddisk90\\Partition5"}, - {"/dev/sdcm6", BRACK(FH_SDCM | 6), "\\Device\\Harddisk90\\Partition6"}, - {"/dev/sdcm7", BRACK(FH_SDCM | 7), "\\Device\\Harddisk90\\Partition7"}, - {"/dev/sdcm8", BRACK(FH_SDCM | 8), "\\Device\\Harddisk90\\Partition8"}, - {"/dev/sdcm9", BRACK(FH_SDCM | 9), "\\Device\\Harddisk90\\Partition9"}, - {"/dev/sdcm10", BRACK(FH_SDCM | 10), "\\Device\\Harddisk90\\Partition10"}, - {"/dev/sdcm11", BRACK(FH_SDCM | 11), "\\Device\\Harddisk90\\Partition11"}, - {"/dev/sdcm12", BRACK(FH_SDCM | 12), "\\Device\\Harddisk90\\Partition12"}, - {"/dev/sdcm13", BRACK(FH_SDCM | 13), "\\Device\\Harddisk90\\Partition13"}, - {"/dev/sdcm14", BRACK(FH_SDCM | 14), "\\Device\\Harddisk90\\Partition14"}, - {"/dev/sdcm15", BRACK(FH_SDCM | 15), "\\Device\\Harddisk90\\Partition15"}, - {"/dev/sdcn1", BRACK(FH_SDCN | 1), "\\Device\\Harddisk91\\Partition1"}, - {"/dev/sdcn2", BRACK(FH_SDCN | 2), "\\Device\\Harddisk91\\Partition2"}, - {"/dev/sdcn3", BRACK(FH_SDCN | 3), "\\Device\\Harddisk91\\Partition3"}, - {"/dev/sdcn4", BRACK(FH_SDCN | 4), "\\Device\\Harddisk91\\Partition4"}, - {"/dev/sdcn5", BRACK(FH_SDCN | 5), "\\Device\\Harddisk91\\Partition5"}, - {"/dev/sdcn6", BRACK(FH_SDCN | 6), "\\Device\\Harddisk91\\Partition6"}, - {"/dev/sdcn7", BRACK(FH_SDCN | 7), "\\Device\\Harddisk91\\Partition7"}, - {"/dev/sdcn8", BRACK(FH_SDCN | 8), "\\Device\\Harddisk91\\Partition8"}, - {"/dev/sdcn9", BRACK(FH_SDCN | 9), "\\Device\\Harddisk91\\Partition9"}, - {"/dev/sdcn10", BRACK(FH_SDCN | 10), "\\Device\\Harddisk91\\Partition10"}, - {"/dev/sdcn11", BRACK(FH_SDCN | 11), "\\Device\\Harddisk91\\Partition11"}, - {"/dev/sdcn12", BRACK(FH_SDCN | 12), "\\Device\\Harddisk91\\Partition12"}, - {"/dev/sdcn13", BRACK(FH_SDCN | 13), "\\Device\\Harddisk91\\Partition13"}, - {"/dev/sdcn14", BRACK(FH_SDCN | 14), "\\Device\\Harddisk91\\Partition14"}, - {"/dev/sdcn15", BRACK(FH_SDCN | 15), "\\Device\\Harddisk91\\Partition15"}, - {"/dev/sdco1", BRACK(FH_SDCO | 1), "\\Device\\Harddisk92\\Partition1"}, - {"/dev/sdco2", BRACK(FH_SDCO | 2), "\\Device\\Harddisk92\\Partition2"}, - {"/dev/sdco3", BRACK(FH_SDCO | 3), "\\Device\\Harddisk92\\Partition3"}, - {"/dev/sdco4", BRACK(FH_SDCO | 4), "\\Device\\Harddisk92\\Partition4"}, - {"/dev/sdco5", BRACK(FH_SDCO | 5), "\\Device\\Harddisk92\\Partition5"}, - {"/dev/sdco6", BRACK(FH_SDCO | 6), "\\Device\\Harddisk92\\Partition6"}, - {"/dev/sdco7", BRACK(FH_SDCO | 7), "\\Device\\Harddisk92\\Partition7"}, - {"/dev/sdco8", BRACK(FH_SDCO | 8), "\\Device\\Harddisk92\\Partition8"}, - {"/dev/sdco9", BRACK(FH_SDCO | 9), "\\Device\\Harddisk92\\Partition9"}, - {"/dev/sdco10", BRACK(FH_SDCO | 10), "\\Device\\Harddisk92\\Partition10"}, - {"/dev/sdco11", BRACK(FH_SDCO | 11), "\\Device\\Harddisk92\\Partition11"}, - {"/dev/sdco12", BRACK(FH_SDCO | 12), "\\Device\\Harddisk92\\Partition12"}, - {"/dev/sdco13", BRACK(FH_SDCO | 13), "\\Device\\Harddisk92\\Partition13"}, - {"/dev/sdco14", BRACK(FH_SDCO | 14), "\\Device\\Harddisk92\\Partition14"}, - {"/dev/sdco15", BRACK(FH_SDCO | 15), "\\Device\\Harddisk92\\Partition15"}, - {"/dev/sdcp1", BRACK(FH_SDCP | 1), "\\Device\\Harddisk93\\Partition1"}, - {"/dev/sdcp2", BRACK(FH_SDCP | 2), "\\Device\\Harddisk93\\Partition2"}, - {"/dev/sdcp3", BRACK(FH_SDCP | 3), "\\Device\\Harddisk93\\Partition3"}, - {"/dev/sdcp4", BRACK(FH_SDCP | 4), "\\Device\\Harddisk93\\Partition4"}, - {"/dev/sdcp5", BRACK(FH_SDCP | 5), "\\Device\\Harddisk93\\Partition5"}, - {"/dev/sdcp6", BRACK(FH_SDCP | 6), "\\Device\\Harddisk93\\Partition6"}, - {"/dev/sdcp7", BRACK(FH_SDCP | 7), "\\Device\\Harddisk93\\Partition7"}, - {"/dev/sdcp8", BRACK(FH_SDCP | 8), "\\Device\\Harddisk93\\Partition8"}, - {"/dev/sdcp9", BRACK(FH_SDCP | 9), "\\Device\\Harddisk93\\Partition9"}, - {"/dev/sdcp10", BRACK(FH_SDCP | 10), "\\Device\\Harddisk93\\Partition10"}, - {"/dev/sdcp11", BRACK(FH_SDCP | 11), "\\Device\\Harddisk93\\Partition11"}, - {"/dev/sdcp12", BRACK(FH_SDCP | 12), "\\Device\\Harddisk93\\Partition12"}, - {"/dev/sdcp13", BRACK(FH_SDCP | 13), "\\Device\\Harddisk93\\Partition13"}, - {"/dev/sdcp14", BRACK(FH_SDCP | 14), "\\Device\\Harddisk93\\Partition14"}, - {"/dev/sdcp15", BRACK(FH_SDCP | 15), "\\Device\\Harddisk93\\Partition15"}, - {"/dev/sdcq1", BRACK(FH_SDCQ | 1), "\\Device\\Harddisk94\\Partition1"}, - {"/dev/sdcq2", BRACK(FH_SDCQ | 2), "\\Device\\Harddisk94\\Partition2"}, - {"/dev/sdcq3", BRACK(FH_SDCQ | 3), "\\Device\\Harddisk94\\Partition3"}, - {"/dev/sdcq4", BRACK(FH_SDCQ | 4), "\\Device\\Harddisk94\\Partition4"}, - {"/dev/sdcq5", BRACK(FH_SDCQ | 5), "\\Device\\Harddisk94\\Partition5"}, - {"/dev/sdcq6", BRACK(FH_SDCQ | 6), "\\Device\\Harddisk94\\Partition6"}, - {"/dev/sdcq7", BRACK(FH_SDCQ | 7), "\\Device\\Harddisk94\\Partition7"}, - {"/dev/sdcq8", BRACK(FH_SDCQ | 8), "\\Device\\Harddisk94\\Partition8"}, - {"/dev/sdcq9", BRACK(FH_SDCQ | 9), "\\Device\\Harddisk94\\Partition9"}, - {"/dev/sdcq10", BRACK(FH_SDCQ | 10), "\\Device\\Harddisk94\\Partition10"}, - {"/dev/sdcq11", BRACK(FH_SDCQ | 11), "\\Device\\Harddisk94\\Partition11"}, - {"/dev/sdcq12", BRACK(FH_SDCQ | 12), "\\Device\\Harddisk94\\Partition12"}, - {"/dev/sdcq13", BRACK(FH_SDCQ | 13), "\\Device\\Harddisk94\\Partition13"}, - {"/dev/sdcq14", BRACK(FH_SDCQ | 14), "\\Device\\Harddisk94\\Partition14"}, - {"/dev/sdcq15", BRACK(FH_SDCQ | 15), "\\Device\\Harddisk94\\Partition15"}, - {"/dev/sdcr1", BRACK(FH_SDCR | 1), "\\Device\\Harddisk95\\Partition1"}, - {"/dev/sdcr2", BRACK(FH_SDCR | 2), "\\Device\\Harddisk95\\Partition2"}, - {"/dev/sdcr3", BRACK(FH_SDCR | 3), "\\Device\\Harddisk95\\Partition3"}, - {"/dev/sdcr4", BRACK(FH_SDCR | 4), "\\Device\\Harddisk95\\Partition4"}, - {"/dev/sdcr5", BRACK(FH_SDCR | 5), "\\Device\\Harddisk95\\Partition5"}, - {"/dev/sdcr6", BRACK(FH_SDCR | 6), "\\Device\\Harddisk95\\Partition6"}, - {"/dev/sdcr7", BRACK(FH_SDCR | 7), "\\Device\\Harddisk95\\Partition7"}, - {"/dev/sdcr8", BRACK(FH_SDCR | 8), "\\Device\\Harddisk95\\Partition8"}, - {"/dev/sdcr9", BRACK(FH_SDCR | 9), "\\Device\\Harddisk95\\Partition9"}, - {"/dev/sdcr10", BRACK(FH_SDCR | 10), "\\Device\\Harddisk95\\Partition10"}, - {"/dev/sdcr11", BRACK(FH_SDCR | 11), "\\Device\\Harddisk95\\Partition11"}, - {"/dev/sdcr12", BRACK(FH_SDCR | 12), "\\Device\\Harddisk95\\Partition12"}, - {"/dev/sdcr13", BRACK(FH_SDCR | 13), "\\Device\\Harddisk95\\Partition13"}, - {"/dev/sdcr14", BRACK(FH_SDCR | 14), "\\Device\\Harddisk95\\Partition14"}, - {"/dev/sdcr15", BRACK(FH_SDCR | 15), "\\Device\\Harddisk95\\Partition15"}, - {"/dev/sdcs1", BRACK(FH_SDCS | 1), "\\Device\\Harddisk96\\Partition1"}, - {"/dev/sdcs2", BRACK(FH_SDCS | 2), "\\Device\\Harddisk96\\Partition2"}, - {"/dev/sdcs3", BRACK(FH_SDCS | 3), "\\Device\\Harddisk96\\Partition3"}, - {"/dev/sdcs4", BRACK(FH_SDCS | 4), "\\Device\\Harddisk96\\Partition4"}, - {"/dev/sdcs5", BRACK(FH_SDCS | 5), "\\Device\\Harddisk96\\Partition5"}, - {"/dev/sdcs6", BRACK(FH_SDCS | 6), "\\Device\\Harddisk96\\Partition6"}, - {"/dev/sdcs7", BRACK(FH_SDCS | 7), "\\Device\\Harddisk96\\Partition7"}, - {"/dev/sdcs8", BRACK(FH_SDCS | 8), "\\Device\\Harddisk96\\Partition8"}, - {"/dev/sdcs9", BRACK(FH_SDCS | 9), "\\Device\\Harddisk96\\Partition9"}, - {"/dev/sdcs10", BRACK(FH_SDCS | 10), "\\Device\\Harddisk96\\Partition10"}, - {"/dev/sdcs11", BRACK(FH_SDCS | 11), "\\Device\\Harddisk96\\Partition11"}, - {"/dev/sdcs12", BRACK(FH_SDCS | 12), "\\Device\\Harddisk96\\Partition12"}, - {"/dev/sdcs13", BRACK(FH_SDCS | 13), "\\Device\\Harddisk96\\Partition13"}, - {"/dev/sdcs14", BRACK(FH_SDCS | 14), "\\Device\\Harddisk96\\Partition14"}, - {"/dev/sdcs15", BRACK(FH_SDCS | 15), "\\Device\\Harddisk96\\Partition15"}, - {"/dev/sdct1", BRACK(FH_SDCT | 1), "\\Device\\Harddisk97\\Partition1"}, - {"/dev/sdct2", BRACK(FH_SDCT | 2), "\\Device\\Harddisk97\\Partition2"}, - {"/dev/sdct3", BRACK(FH_SDCT | 3), "\\Device\\Harddisk97\\Partition3"}, - {"/dev/sdct4", BRACK(FH_SDCT | 4), "\\Device\\Harddisk97\\Partition4"}, - {"/dev/sdct5", BRACK(FH_SDCT | 5), "\\Device\\Harddisk97\\Partition5"}, - {"/dev/sdct6", BRACK(FH_SDCT | 6), "\\Device\\Harddisk97\\Partition6"}, - {"/dev/sdct7", BRACK(FH_SDCT | 7), "\\Device\\Harddisk97\\Partition7"}, - {"/dev/sdct8", BRACK(FH_SDCT | 8), "\\Device\\Harddisk97\\Partition8"}, - {"/dev/sdct9", BRACK(FH_SDCT | 9), "\\Device\\Harddisk97\\Partition9"}, - {"/dev/sdct10", BRACK(FH_SDCT | 10), "\\Device\\Harddisk97\\Partition10"}, - {"/dev/sdct11", BRACK(FH_SDCT | 11), "\\Device\\Harddisk97\\Partition11"}, - {"/dev/sdct12", BRACK(FH_SDCT | 12), "\\Device\\Harddisk97\\Partition12"}, - {"/dev/sdct13", BRACK(FH_SDCT | 13), "\\Device\\Harddisk97\\Partition13"}, - {"/dev/sdct14", BRACK(FH_SDCT | 14), "\\Device\\Harddisk97\\Partition14"}, - {"/dev/sdct15", BRACK(FH_SDCT | 15), "\\Device\\Harddisk97\\Partition15"}, - {"/dev/sdcu1", BRACK(FH_SDCU | 1), "\\Device\\Harddisk98\\Partition1"}, - {"/dev/sdcu2", BRACK(FH_SDCU | 2), "\\Device\\Harddisk98\\Partition2"}, - {"/dev/sdcu3", BRACK(FH_SDCU | 3), "\\Device\\Harddisk98\\Partition3"}, - {"/dev/sdcu4", BRACK(FH_SDCU | 4), "\\Device\\Harddisk98\\Partition4"}, - {"/dev/sdcu5", BRACK(FH_SDCU | 5), "\\Device\\Harddisk98\\Partition5"}, - {"/dev/sdcu6", BRACK(FH_SDCU | 6), "\\Device\\Harddisk98\\Partition6"}, - {"/dev/sdcu7", BRACK(FH_SDCU | 7), "\\Device\\Harddisk98\\Partition7"}, - {"/dev/sdcu8", BRACK(FH_SDCU | 8), "\\Device\\Harddisk98\\Partition8"}, - {"/dev/sdcu9", BRACK(FH_SDCU | 9), "\\Device\\Harddisk98\\Partition9"}, - {"/dev/sdcu10", BRACK(FH_SDCU | 10), "\\Device\\Harddisk98\\Partition10"}, - {"/dev/sdcu11", BRACK(FH_SDCU | 11), "\\Device\\Harddisk98\\Partition11"}, - {"/dev/sdcu12", BRACK(FH_SDCU | 12), "\\Device\\Harddisk98\\Partition12"}, - {"/dev/sdcu13", BRACK(FH_SDCU | 13), "\\Device\\Harddisk98\\Partition13"}, - {"/dev/sdcu14", BRACK(FH_SDCU | 14), "\\Device\\Harddisk98\\Partition14"}, - {"/dev/sdcu15", BRACK(FH_SDCU | 15), "\\Device\\Harddisk98\\Partition15"}, - {"/dev/sdcv1", BRACK(FH_SDCV | 1), "\\Device\\Harddisk99\\Partition1"}, - {"/dev/sdcv2", BRACK(FH_SDCV | 2), "\\Device\\Harddisk99\\Partition2"}, - {"/dev/sdcv3", BRACK(FH_SDCV | 3), "\\Device\\Harddisk99\\Partition3"}, - {"/dev/sdcv4", BRACK(FH_SDCV | 4), "\\Device\\Harddisk99\\Partition4"}, - {"/dev/sdcv5", BRACK(FH_SDCV | 5), "\\Device\\Harddisk99\\Partition5"}, - {"/dev/sdcv6", BRACK(FH_SDCV | 6), "\\Device\\Harddisk99\\Partition6"}, - {"/dev/sdcv7", BRACK(FH_SDCV | 7), "\\Device\\Harddisk99\\Partition7"}, - {"/dev/sdcv8", BRACK(FH_SDCV | 8), "\\Device\\Harddisk99\\Partition8"}, - {"/dev/sdcv9", BRACK(FH_SDCV | 9), "\\Device\\Harddisk99\\Partition9"}, - {"/dev/sdcv10", BRACK(FH_SDCV | 10), "\\Device\\Harddisk99\\Partition10"}, - {"/dev/sdcv11", BRACK(FH_SDCV | 11), "\\Device\\Harddisk99\\Partition11"}, - {"/dev/sdcv12", BRACK(FH_SDCV | 12), "\\Device\\Harddisk99\\Partition12"}, - {"/dev/sdcv13", BRACK(FH_SDCV | 13), "\\Device\\Harddisk99\\Partition13"}, - {"/dev/sdcv14", BRACK(FH_SDCV | 14), "\\Device\\Harddisk99\\Partition14"}, - {"/dev/sdcv15", BRACK(FH_SDCV | 15), "\\Device\\Harddisk99\\Partition15"}, - {"/dev/sdcw1", BRACK(FH_SDCW | 1), "\\Device\\Harddisk100\\Partition1"}, - {"/dev/sdcw2", BRACK(FH_SDCW | 2), "\\Device\\Harddisk100\\Partition2"}, - {"/dev/sdcw3", BRACK(FH_SDCW | 3), "\\Device\\Harddisk100\\Partition3"}, - {"/dev/sdcw4", BRACK(FH_SDCW | 4), "\\Device\\Harddisk100\\Partition4"}, - {"/dev/sdcw5", BRACK(FH_SDCW | 5), "\\Device\\Harddisk100\\Partition5"}, - {"/dev/sdcw6", BRACK(FH_SDCW | 6), "\\Device\\Harddisk100\\Partition6"}, - {"/dev/sdcw7", BRACK(FH_SDCW | 7), "\\Device\\Harddisk100\\Partition7"}, - {"/dev/sdcw8", BRACK(FH_SDCW | 8), "\\Device\\Harddisk100\\Partition8"}, - {"/dev/sdcw9", BRACK(FH_SDCW | 9), "\\Device\\Harddisk100\\Partition9"}, - {"/dev/sdcw10", BRACK(FH_SDCW | 10), "\\Device\\Harddisk100\\Partition10"}, - {"/dev/sdcw11", BRACK(FH_SDCW | 11), "\\Device\\Harddisk100\\Partition11"}, - {"/dev/sdcw12", BRACK(FH_SDCW | 12), "\\Device\\Harddisk100\\Partition12"}, - {"/dev/sdcw13", BRACK(FH_SDCW | 13), "\\Device\\Harddisk100\\Partition13"}, - {"/dev/sdcw14", BRACK(FH_SDCW | 14), "\\Device\\Harddisk100\\Partition14"}, - {"/dev/sdcw15", BRACK(FH_SDCW | 15), "\\Device\\Harddisk100\\Partition15"}, - {"/dev/sdcx1", BRACK(FH_SDCX | 1), "\\Device\\Harddisk101\\Partition1"}, - {"/dev/sdcx2", BRACK(FH_SDCX | 2), "\\Device\\Harddisk101\\Partition2"}, - {"/dev/sdcx3", BRACK(FH_SDCX | 3), "\\Device\\Harddisk101\\Partition3"}, - {"/dev/sdcx4", BRACK(FH_SDCX | 4), "\\Device\\Harddisk101\\Partition4"}, - {"/dev/sdcx5", BRACK(FH_SDCX | 5), "\\Device\\Harddisk101\\Partition5"}, - {"/dev/sdcx6", BRACK(FH_SDCX | 6), "\\Device\\Harddisk101\\Partition6"}, - {"/dev/sdcx7", BRACK(FH_SDCX | 7), "\\Device\\Harddisk101\\Partition7"}, - {"/dev/sdcx8", BRACK(FH_SDCX | 8), "\\Device\\Harddisk101\\Partition8"}, - {"/dev/sdcx9", BRACK(FH_SDCX | 9), "\\Device\\Harddisk101\\Partition9"}, - {"/dev/sdcx10", BRACK(FH_SDCX | 10), "\\Device\\Harddisk101\\Partition10"}, - {"/dev/sdcx11", BRACK(FH_SDCX | 11), "\\Device\\Harddisk101\\Partition11"}, - {"/dev/sdcx12", BRACK(FH_SDCX | 12), "\\Device\\Harddisk101\\Partition12"}, - {"/dev/sdcx13", BRACK(FH_SDCX | 13), "\\Device\\Harddisk101\\Partition13"}, - {"/dev/sdcx14", BRACK(FH_SDCX | 14), "\\Device\\Harddisk101\\Partition14"}, - {"/dev/sdcx15", BRACK(FH_SDCX | 15), "\\Device\\Harddisk101\\Partition15"}, - {"/dev/sdcy1", BRACK(FH_SDCY | 1), "\\Device\\Harddisk102\\Partition1"}, - {"/dev/sdcy2", BRACK(FH_SDCY | 2), "\\Device\\Harddisk102\\Partition2"}, - {"/dev/sdcy3", BRACK(FH_SDCY | 3), "\\Device\\Harddisk102\\Partition3"}, - {"/dev/sdcy4", BRACK(FH_SDCY | 4), "\\Device\\Harddisk102\\Partition4"}, - {"/dev/sdcy5", BRACK(FH_SDCY | 5), "\\Device\\Harddisk102\\Partition5"}, - {"/dev/sdcy6", BRACK(FH_SDCY | 6), "\\Device\\Harddisk102\\Partition6"}, - {"/dev/sdcy7", BRACK(FH_SDCY | 7), "\\Device\\Harddisk102\\Partition7"}, - {"/dev/sdcy8", BRACK(FH_SDCY | 8), "\\Device\\Harddisk102\\Partition8"}, - {"/dev/sdcy9", BRACK(FH_SDCY | 9), "\\Device\\Harddisk102\\Partition9"}, - {"/dev/sdcy10", BRACK(FH_SDCY | 10), "\\Device\\Harddisk102\\Partition10"}, - {"/dev/sdcy11", BRACK(FH_SDCY | 11), "\\Device\\Harddisk102\\Partition11"}, - {"/dev/sdcy12", BRACK(FH_SDCY | 12), "\\Device\\Harddisk102\\Partition12"}, - {"/dev/sdcy13", BRACK(FH_SDCY | 13), "\\Device\\Harddisk102\\Partition13"}, - {"/dev/sdcy14", BRACK(FH_SDCY | 14), "\\Device\\Harddisk102\\Partition14"}, - {"/dev/sdcy15", BRACK(FH_SDCY | 15), "\\Device\\Harddisk102\\Partition15"}, - {"/dev/sdcz1", BRACK(FH_SDCZ | 1), "\\Device\\Harddisk103\\Partition1"}, - {"/dev/sdcz2", BRACK(FH_SDCZ | 2), "\\Device\\Harddisk103\\Partition2"}, - {"/dev/sdcz3", BRACK(FH_SDCZ | 3), "\\Device\\Harddisk103\\Partition3"}, - {"/dev/sdcz4", BRACK(FH_SDCZ | 4), "\\Device\\Harddisk103\\Partition4"}, - {"/dev/sdcz5", BRACK(FH_SDCZ | 5), "\\Device\\Harddisk103\\Partition5"}, - {"/dev/sdcz6", BRACK(FH_SDCZ | 6), "\\Device\\Harddisk103\\Partition6"}, - {"/dev/sdcz7", BRACK(FH_SDCZ | 7), "\\Device\\Harddisk103\\Partition7"}, - {"/dev/sdcz8", BRACK(FH_SDCZ | 8), "\\Device\\Harddisk103\\Partition8"}, - {"/dev/sdcz9", BRACK(FH_SDCZ | 9), "\\Device\\Harddisk103\\Partition9"}, - {"/dev/sdcz10", BRACK(FH_SDCZ | 10), "\\Device\\Harddisk103\\Partition10"}, - {"/dev/sdcz11", BRACK(FH_SDCZ | 11), "\\Device\\Harddisk103\\Partition11"}, - {"/dev/sdcz12", BRACK(FH_SDCZ | 12), "\\Device\\Harddisk103\\Partition12"}, - {"/dev/sdcz13", BRACK(FH_SDCZ | 13), "\\Device\\Harddisk103\\Partition13"}, - {"/dev/sdcz14", BRACK(FH_SDCZ | 14), "\\Device\\Harddisk103\\Partition14"}, - {"/dev/sdcz15", BRACK(FH_SDCZ | 15), "\\Device\\Harddisk103\\Partition15"}, - {"/dev/sdda", BRACK(FH_SDDA), "\\Device\\Harddisk104\\Partition0"}, - {"/dev/sddb", BRACK(FH_SDDB), "\\Device\\Harddisk105\\Partition0"}, - {"/dev/sddc", BRACK(FH_SDDC), "\\Device\\Harddisk106\\Partition0"}, - {"/dev/sddd", BRACK(FH_SDDD), "\\Device\\Harddisk107\\Partition0"}, - {"/dev/sdde", BRACK(FH_SDDE), "\\Device\\Harddisk108\\Partition0"}, - {"/dev/sddf", BRACK(FH_SDDF), "\\Device\\Harddisk109\\Partition0"}, - {"/dev/sddg", BRACK(FH_SDDG), "\\Device\\Harddisk110\\Partition0"}, - {"/dev/sddh", BRACK(FH_SDDH), "\\Device\\Harddisk111\\Partition0"}, - {"/dev/sddi", BRACK(FH_SDDI), "\\Device\\Harddisk112\\Partition0"}, - {"/dev/sddj", BRACK(FH_SDDJ), "\\Device\\Harddisk113\\Partition0"}, - {"/dev/sddk", BRACK(FH_SDDK), "\\Device\\Harddisk114\\Partition0"}, - {"/dev/sddl", BRACK(FH_SDDL), "\\Device\\Harddisk115\\Partition0"}, - {"/dev/sddm", BRACK(FH_SDDM), "\\Device\\Harddisk116\\Partition0"}, - {"/dev/sddn", BRACK(FH_SDDN), "\\Device\\Harddisk117\\Partition0"}, - {"/dev/sddo", BRACK(FH_SDDO), "\\Device\\Harddisk118\\Partition0"}, - {"/dev/sddp", BRACK(FH_SDDP), "\\Device\\Harddisk119\\Partition0"}, - {"/dev/sddq", BRACK(FH_SDDQ), "\\Device\\Harddisk120\\Partition0"}, - {"/dev/sddr", BRACK(FH_SDDR), "\\Device\\Harddisk121\\Partition0"}, - {"/dev/sdds", BRACK(FH_SDDS), "\\Device\\Harddisk122\\Partition0"}, - {"/dev/sddt", BRACK(FH_SDDT), "\\Device\\Harddisk123\\Partition0"}, - {"/dev/sddu", BRACK(FH_SDDU), "\\Device\\Harddisk124\\Partition0"}, - {"/dev/sddv", BRACK(FH_SDDV), "\\Device\\Harddisk125\\Partition0"}, - {"/dev/sddw", BRACK(FH_SDDW), "\\Device\\Harddisk126\\Partition0"}, - {"/dev/sddx", BRACK(FH_SDDX), "\\Device\\Harddisk127\\Partition0"}, - {"/dev/sdda1", BRACK(FH_SDDA | 1), "\\Device\\Harddisk104\\Partition1"}, - {"/dev/sdda2", BRACK(FH_SDDA | 2), "\\Device\\Harddisk104\\Partition2"}, - {"/dev/sdda3", BRACK(FH_SDDA | 3), "\\Device\\Harddisk104\\Partition3"}, - {"/dev/sdda4", BRACK(FH_SDDA | 4), "\\Device\\Harddisk104\\Partition4"}, - {"/dev/sdda5", BRACK(FH_SDDA | 5), "\\Device\\Harddisk104\\Partition5"}, - {"/dev/sdda6", BRACK(FH_SDDA | 6), "\\Device\\Harddisk104\\Partition6"}, - {"/dev/sdda7", BRACK(FH_SDDA | 7), "\\Device\\Harddisk104\\Partition7"}, - {"/dev/sdda8", BRACK(FH_SDDA | 8), "\\Device\\Harddisk104\\Partition8"}, - {"/dev/sdda9", BRACK(FH_SDDA | 9), "\\Device\\Harddisk104\\Partition9"}, - {"/dev/sdda10", BRACK(FH_SDDA | 10), "\\Device\\Harddisk104\\Partition10"}, - {"/dev/sdda11", BRACK(FH_SDDA | 11), "\\Device\\Harddisk104\\Partition11"}, - {"/dev/sdda12", BRACK(FH_SDDA | 12), "\\Device\\Harddisk104\\Partition12"}, - {"/dev/sdda13", BRACK(FH_SDDA | 13), "\\Device\\Harddisk104\\Partition13"}, - {"/dev/sdda14", BRACK(FH_SDDA | 14), "\\Device\\Harddisk104\\Partition14"}, - {"/dev/sdda15", BRACK(FH_SDDA | 15), "\\Device\\Harddisk104\\Partition15"}, - {"/dev/sddb1", BRACK(FH_SDDB | 1), "\\Device\\Harddisk105\\Partition1"}, - {"/dev/sddb2", BRACK(FH_SDDB | 2), "\\Device\\Harddisk105\\Partition2"}, - {"/dev/sddb3", BRACK(FH_SDDB | 3), "\\Device\\Harddisk105\\Partition3"}, - {"/dev/sddb4", BRACK(FH_SDDB | 4), "\\Device\\Harddisk105\\Partition4"}, - {"/dev/sddb5", BRACK(FH_SDDB | 5), "\\Device\\Harddisk105\\Partition5"}, - {"/dev/sddb6", BRACK(FH_SDDB | 6), "\\Device\\Harddisk105\\Partition6"}, - {"/dev/sddb7", BRACK(FH_SDDB | 7), "\\Device\\Harddisk105\\Partition7"}, - {"/dev/sddb8", BRACK(FH_SDDB | 8), "\\Device\\Harddisk105\\Partition8"}, - {"/dev/sddb9", BRACK(FH_SDDB | 9), "\\Device\\Harddisk105\\Partition9"}, - {"/dev/sddb10", BRACK(FH_SDDB | 10), "\\Device\\Harddisk105\\Partition10"}, - {"/dev/sddb11", BRACK(FH_SDDB | 11), "\\Device\\Harddisk105\\Partition11"}, - {"/dev/sddb12", BRACK(FH_SDDB | 12), "\\Device\\Harddisk105\\Partition12"}, - {"/dev/sddb13", BRACK(FH_SDDB | 13), "\\Device\\Harddisk105\\Partition13"}, - {"/dev/sddb14", BRACK(FH_SDDB | 14), "\\Device\\Harddisk105\\Partition14"}, - {"/dev/sddb15", BRACK(FH_SDDB | 15), "\\Device\\Harddisk105\\Partition15"}, - {"/dev/sddc1", BRACK(FH_SDDC | 1), "\\Device\\Harddisk106\\Partition1"}, - {"/dev/sddc2", BRACK(FH_SDDC | 2), "\\Device\\Harddisk106\\Partition2"}, - {"/dev/sddc3", BRACK(FH_SDDC | 3), "\\Device\\Harddisk106\\Partition3"}, - {"/dev/sddc4", BRACK(FH_SDDC | 4), "\\Device\\Harddisk106\\Partition4"}, - {"/dev/sddc5", BRACK(FH_SDDC | 5), "\\Device\\Harddisk106\\Partition5"}, - {"/dev/sddc6", BRACK(FH_SDDC | 6), "\\Device\\Harddisk106\\Partition6"}, - {"/dev/sddc7", BRACK(FH_SDDC | 7), "\\Device\\Harddisk106\\Partition7"}, - {"/dev/sddc8", BRACK(FH_SDDC | 8), "\\Device\\Harddisk106\\Partition8"}, - {"/dev/sddc9", BRACK(FH_SDDC | 9), "\\Device\\Harddisk106\\Partition9"}, - {"/dev/sddc10", BRACK(FH_SDDC | 10), "\\Device\\Harddisk106\\Partition10"}, - {"/dev/sddc11", BRACK(FH_SDDC | 11), "\\Device\\Harddisk106\\Partition11"}, - {"/dev/sddc12", BRACK(FH_SDDC | 12), "\\Device\\Harddisk106\\Partition12"}, - {"/dev/sddc13", BRACK(FH_SDDC | 13), "\\Device\\Harddisk106\\Partition13"}, - {"/dev/sddc14", BRACK(FH_SDDC | 14), "\\Device\\Harddisk106\\Partition14"}, - {"/dev/sddc15", BRACK(FH_SDDC | 15), "\\Device\\Harddisk106\\Partition15"}, - {"/dev/sddd1", BRACK(FH_SDDD | 1), "\\Device\\Harddisk107\\Partition1"}, - {"/dev/sddd2", BRACK(FH_SDDD | 2), "\\Device\\Harddisk107\\Partition2"}, - {"/dev/sddd3", BRACK(FH_SDDD | 3), "\\Device\\Harddisk107\\Partition3"}, - {"/dev/sddd4", BRACK(FH_SDDD | 4), "\\Device\\Harddisk107\\Partition4"}, - {"/dev/sddd5", BRACK(FH_SDDD | 5), "\\Device\\Harddisk107\\Partition5"}, - {"/dev/sddd6", BRACK(FH_SDDD | 6), "\\Device\\Harddisk107\\Partition6"}, - {"/dev/sddd7", BRACK(FH_SDDD | 7), "\\Device\\Harddisk107\\Partition7"}, - {"/dev/sddd8", BRACK(FH_SDDD | 8), "\\Device\\Harddisk107\\Partition8"}, - {"/dev/sddd9", BRACK(FH_SDDD | 9), "\\Device\\Harddisk107\\Partition9"}, - {"/dev/sddd10", BRACK(FH_SDDD | 10), "\\Device\\Harddisk107\\Partition10"}, - {"/dev/sddd11", BRACK(FH_SDDD | 11), "\\Device\\Harddisk107\\Partition11"}, - {"/dev/sddd12", BRACK(FH_SDDD | 12), "\\Device\\Harddisk107\\Partition12"}, - {"/dev/sddd13", BRACK(FH_SDDD | 13), "\\Device\\Harddisk107\\Partition13"}, - {"/dev/sddd14", BRACK(FH_SDDD | 14), "\\Device\\Harddisk107\\Partition14"}, - {"/dev/sddd15", BRACK(FH_SDDD | 15), "\\Device\\Harddisk107\\Partition15"}, - {"/dev/sdde1", BRACK(FH_SDDE | 1), "\\Device\\Harddisk108\\Partition1"}, - {"/dev/sdde2", BRACK(FH_SDDE | 2), "\\Device\\Harddisk108\\Partition2"}, - {"/dev/sdde3", BRACK(FH_SDDE | 3), "\\Device\\Harddisk108\\Partition3"}, - {"/dev/sdde4", BRACK(FH_SDDE | 4), "\\Device\\Harddisk108\\Partition4"}, - {"/dev/sdde5", BRACK(FH_SDDE | 5), "\\Device\\Harddisk108\\Partition5"}, - {"/dev/sdde6", BRACK(FH_SDDE | 6), "\\Device\\Harddisk108\\Partition6"}, - {"/dev/sdde7", BRACK(FH_SDDE | 7), "\\Device\\Harddisk108\\Partition7"}, - {"/dev/sdde8", BRACK(FH_SDDE | 8), "\\Device\\Harddisk108\\Partition8"}, - {"/dev/sdde9", BRACK(FH_SDDE | 9), "\\Device\\Harddisk108\\Partition9"}, - {"/dev/sdde10", BRACK(FH_SDDE | 10), "\\Device\\Harddisk108\\Partition10"}, - {"/dev/sdde11", BRACK(FH_SDDE | 11), "\\Device\\Harddisk108\\Partition11"}, - {"/dev/sdde12", BRACK(FH_SDDE | 12), "\\Device\\Harddisk108\\Partition12"}, - {"/dev/sdde13", BRACK(FH_SDDE | 13), "\\Device\\Harddisk108\\Partition13"}, - {"/dev/sdde14", BRACK(FH_SDDE | 14), "\\Device\\Harddisk108\\Partition14"}, - {"/dev/sdde15", BRACK(FH_SDDE | 15), "\\Device\\Harddisk108\\Partition15"}, - {"/dev/sddf1", BRACK(FH_SDDF | 1), "\\Device\\Harddisk109\\Partition1"}, - {"/dev/sddf2", BRACK(FH_SDDF | 2), "\\Device\\Harddisk109\\Partition2"}, - {"/dev/sddf3", BRACK(FH_SDDF | 3), "\\Device\\Harddisk109\\Partition3"}, - {"/dev/sddf4", BRACK(FH_SDDF | 4), "\\Device\\Harddisk109\\Partition4"}, - {"/dev/sddf5", BRACK(FH_SDDF | 5), "\\Device\\Harddisk109\\Partition5"}, - {"/dev/sddf6", BRACK(FH_SDDF | 6), "\\Device\\Harddisk109\\Partition6"}, - {"/dev/sddf7", BRACK(FH_SDDF | 7), "\\Device\\Harddisk109\\Partition7"}, - {"/dev/sddf8", BRACK(FH_SDDF | 8), "\\Device\\Harddisk109\\Partition8"}, - {"/dev/sddf9", BRACK(FH_SDDF | 9), "\\Device\\Harddisk109\\Partition9"}, - {"/dev/sddf10", BRACK(FH_SDDF | 10), "\\Device\\Harddisk109\\Partition10"}, - {"/dev/sddf11", BRACK(FH_SDDF | 11), "\\Device\\Harddisk109\\Partition11"}, - {"/dev/sddf12", BRACK(FH_SDDF | 12), "\\Device\\Harddisk109\\Partition12"}, - {"/dev/sddf13", BRACK(FH_SDDF | 13), "\\Device\\Harddisk109\\Partition13"}, - {"/dev/sddf14", BRACK(FH_SDDF | 14), "\\Device\\Harddisk109\\Partition14"}, - {"/dev/sddf15", BRACK(FH_SDDF | 15), "\\Device\\Harddisk109\\Partition15"}, - {"/dev/sddg1", BRACK(FH_SDDG | 1), "\\Device\\Harddisk110\\Partition1"}, - {"/dev/sddg2", BRACK(FH_SDDG | 2), "\\Device\\Harddisk110\\Partition2"}, - {"/dev/sddg3", BRACK(FH_SDDG | 3), "\\Device\\Harddisk110\\Partition3"}, - {"/dev/sddg4", BRACK(FH_SDDG | 4), "\\Device\\Harddisk110\\Partition4"}, - {"/dev/sddg5", BRACK(FH_SDDG | 5), "\\Device\\Harddisk110\\Partition5"}, - {"/dev/sddg6", BRACK(FH_SDDG | 6), "\\Device\\Harddisk110\\Partition6"}, - {"/dev/sddg7", BRACK(FH_SDDG | 7), "\\Device\\Harddisk110\\Partition7"}, - {"/dev/sddg8", BRACK(FH_SDDG | 8), "\\Device\\Harddisk110\\Partition8"}, - {"/dev/sddg9", BRACK(FH_SDDG | 9), "\\Device\\Harddisk110\\Partition9"}, - {"/dev/sddg10", BRACK(FH_SDDG | 10), "\\Device\\Harddisk110\\Partition10"}, - {"/dev/sddg11", BRACK(FH_SDDG | 11), "\\Device\\Harddisk110\\Partition11"}, - {"/dev/sddg12", BRACK(FH_SDDG | 12), "\\Device\\Harddisk110\\Partition12"}, - {"/dev/sddg13", BRACK(FH_SDDG | 13), "\\Device\\Harddisk110\\Partition13"}, - {"/dev/sddg14", BRACK(FH_SDDG | 14), "\\Device\\Harddisk110\\Partition14"}, - {"/dev/sddg15", BRACK(FH_SDDG | 15), "\\Device\\Harddisk110\\Partition15"}, - {"/dev/sddh1", BRACK(FH_SDDH | 1), "\\Device\\Harddisk111\\Partition1"}, - {"/dev/sddh2", BRACK(FH_SDDH | 2), "\\Device\\Harddisk111\\Partition2"}, - {"/dev/sddh3", BRACK(FH_SDDH | 3), "\\Device\\Harddisk111\\Partition3"}, - {"/dev/sddh4", BRACK(FH_SDDH | 4), "\\Device\\Harddisk111\\Partition4"}, - {"/dev/sddh5", BRACK(FH_SDDH | 5), "\\Device\\Harddisk111\\Partition5"}, - {"/dev/sddh6", BRACK(FH_SDDH | 6), "\\Device\\Harddisk111\\Partition6"}, - {"/dev/sddh7", BRACK(FH_SDDH | 7), "\\Device\\Harddisk111\\Partition7"}, - {"/dev/sddh8", BRACK(FH_SDDH | 8), "\\Device\\Harddisk111\\Partition8"}, - {"/dev/sddh9", BRACK(FH_SDDH | 9), "\\Device\\Harddisk111\\Partition9"}, - {"/dev/sddh10", BRACK(FH_SDDH | 10), "\\Device\\Harddisk111\\Partition10"}, - {"/dev/sddh11", BRACK(FH_SDDH | 11), "\\Device\\Harddisk111\\Partition11"}, - {"/dev/sddh12", BRACK(FH_SDDH | 12), "\\Device\\Harddisk111\\Partition12"}, - {"/dev/sddh13", BRACK(FH_SDDH | 13), "\\Device\\Harddisk111\\Partition13"}, - {"/dev/sddh14", BRACK(FH_SDDH | 14), "\\Device\\Harddisk111\\Partition14"}, - {"/dev/sddh15", BRACK(FH_SDDH | 15), "\\Device\\Harddisk111\\Partition15"}, - {"/dev/sddi1", BRACK(FH_SDDI | 1), "\\Device\\Harddisk112\\Partition1"}, - {"/dev/sddi2", BRACK(FH_SDDI | 2), "\\Device\\Harddisk112\\Partition2"}, - {"/dev/sddi3", BRACK(FH_SDDI | 3), "\\Device\\Harddisk112\\Partition3"}, - {"/dev/sddi4", BRACK(FH_SDDI | 4), "\\Device\\Harddisk112\\Partition4"}, - {"/dev/sddi5", BRACK(FH_SDDI | 5), "\\Device\\Harddisk112\\Partition5"}, - {"/dev/sddi6", BRACK(FH_SDDI | 6), "\\Device\\Harddisk112\\Partition6"}, - {"/dev/sddi7", BRACK(FH_SDDI | 7), "\\Device\\Harddisk112\\Partition7"}, - {"/dev/sddi8", BRACK(FH_SDDI | 8), "\\Device\\Harddisk112\\Partition8"}, - {"/dev/sddi9", BRACK(FH_SDDI | 9), "\\Device\\Harddisk112\\Partition9"}, - {"/dev/sddi10", BRACK(FH_SDDI | 10), "\\Device\\Harddisk112\\Partition10"}, - {"/dev/sddi11", BRACK(FH_SDDI | 11), "\\Device\\Harddisk112\\Partition11"}, - {"/dev/sddi12", BRACK(FH_SDDI | 12), "\\Device\\Harddisk112\\Partition12"}, - {"/dev/sddi13", BRACK(FH_SDDI | 13), "\\Device\\Harddisk112\\Partition13"}, - {"/dev/sddi14", BRACK(FH_SDDI | 14), "\\Device\\Harddisk112\\Partition14"}, - {"/dev/sddi15", BRACK(FH_SDDI | 15), "\\Device\\Harddisk112\\Partition15"}, - {"/dev/sddj1", BRACK(FH_SDDJ | 1), "\\Device\\Harddisk113\\Partition1"}, - {"/dev/sddj2", BRACK(FH_SDDJ | 2), "\\Device\\Harddisk113\\Partition2"}, - {"/dev/sddj3", BRACK(FH_SDDJ | 3), "\\Device\\Harddisk113\\Partition3"}, - {"/dev/sddj4", BRACK(FH_SDDJ | 4), "\\Device\\Harddisk113\\Partition4"}, - {"/dev/sddj5", BRACK(FH_SDDJ | 5), "\\Device\\Harddisk113\\Partition5"}, - {"/dev/sddj6", BRACK(FH_SDDJ | 6), "\\Device\\Harddisk113\\Partition6"}, - {"/dev/sddj7", BRACK(FH_SDDJ | 7), "\\Device\\Harddisk113\\Partition7"}, - {"/dev/sddj8", BRACK(FH_SDDJ | 8), "\\Device\\Harddisk113\\Partition8"}, - {"/dev/sddj9", BRACK(FH_SDDJ | 9), "\\Device\\Harddisk113\\Partition9"}, - {"/dev/sddj10", BRACK(FH_SDDJ | 10), "\\Device\\Harddisk113\\Partition10"}, - {"/dev/sddj11", BRACK(FH_SDDJ | 11), "\\Device\\Harddisk113\\Partition11"}, - {"/dev/sddj12", BRACK(FH_SDDJ | 12), "\\Device\\Harddisk113\\Partition12"}, - {"/dev/sddj13", BRACK(FH_SDDJ | 13), "\\Device\\Harddisk113\\Partition13"}, - {"/dev/sddj14", BRACK(FH_SDDJ | 14), "\\Device\\Harddisk113\\Partition14"}, - {"/dev/sddj15", BRACK(FH_SDDJ | 15), "\\Device\\Harddisk113\\Partition15"}, - {"/dev/sddk1", BRACK(FH_SDDK | 1), "\\Device\\Harddisk114\\Partition1"}, - {"/dev/sddk2", BRACK(FH_SDDK | 2), "\\Device\\Harddisk114\\Partition2"}, - {"/dev/sddk3", BRACK(FH_SDDK | 3), "\\Device\\Harddisk114\\Partition3"}, - {"/dev/sddk4", BRACK(FH_SDDK | 4), "\\Device\\Harddisk114\\Partition4"}, - {"/dev/sddk5", BRACK(FH_SDDK | 5), "\\Device\\Harddisk114\\Partition5"}, - {"/dev/sddk6", BRACK(FH_SDDK | 6), "\\Device\\Harddisk114\\Partition6"}, - {"/dev/sddk7", BRACK(FH_SDDK | 7), "\\Device\\Harddisk114\\Partition7"}, - {"/dev/sddk8", BRACK(FH_SDDK | 8), "\\Device\\Harddisk114\\Partition8"}, - {"/dev/sddk9", BRACK(FH_SDDK | 9), "\\Device\\Harddisk114\\Partition9"}, - {"/dev/sddk10", BRACK(FH_SDDK | 10), "\\Device\\Harddisk114\\Partition10"}, - {"/dev/sddk11", BRACK(FH_SDDK | 11), "\\Device\\Harddisk114\\Partition11"}, - {"/dev/sddk12", BRACK(FH_SDDK | 12), "\\Device\\Harddisk114\\Partition12"}, - {"/dev/sddk13", BRACK(FH_SDDK | 13), "\\Device\\Harddisk114\\Partition13"}, - {"/dev/sddk14", BRACK(FH_SDDK | 14), "\\Device\\Harddisk114\\Partition14"}, - {"/dev/sddk15", BRACK(FH_SDDK | 15), "\\Device\\Harddisk114\\Partition15"}, - {"/dev/sddl1", BRACK(FH_SDDL | 1), "\\Device\\Harddisk115\\Partition1"}, - {"/dev/sddl2", BRACK(FH_SDDL | 2), "\\Device\\Harddisk115\\Partition2"}, - {"/dev/sddl3", BRACK(FH_SDDL | 3), "\\Device\\Harddisk115\\Partition3"}, - {"/dev/sddl4", BRACK(FH_SDDL | 4), "\\Device\\Harddisk115\\Partition4"}, - {"/dev/sddl5", BRACK(FH_SDDL | 5), "\\Device\\Harddisk115\\Partition5"}, - {"/dev/sddl6", BRACK(FH_SDDL | 6), "\\Device\\Harddisk115\\Partition6"}, - {"/dev/sddl7", BRACK(FH_SDDL | 7), "\\Device\\Harddisk115\\Partition7"}, - {"/dev/sddl8", BRACK(FH_SDDL | 8), "\\Device\\Harddisk115\\Partition8"}, - {"/dev/sddl9", BRACK(FH_SDDL | 9), "\\Device\\Harddisk115\\Partition9"}, - {"/dev/sddl10", BRACK(FH_SDDL | 10), "\\Device\\Harddisk115\\Partition10"}, - {"/dev/sddl11", BRACK(FH_SDDL | 11), "\\Device\\Harddisk115\\Partition11"}, - {"/dev/sddl12", BRACK(FH_SDDL | 12), "\\Device\\Harddisk115\\Partition12"}, - {"/dev/sddl13", BRACK(FH_SDDL | 13), "\\Device\\Harddisk115\\Partition13"}, - {"/dev/sddl14", BRACK(FH_SDDL | 14), "\\Device\\Harddisk115\\Partition14"}, - {"/dev/sddl15", BRACK(FH_SDDL | 15), "\\Device\\Harddisk115\\Partition15"}, - {"/dev/sddm1", BRACK(FH_SDDM | 1), "\\Device\\Harddisk116\\Partition1"}, - {"/dev/sddm2", BRACK(FH_SDDM | 2), "\\Device\\Harddisk116\\Partition2"}, - {"/dev/sddm3", BRACK(FH_SDDM | 3), "\\Device\\Harddisk116\\Partition3"}, - {"/dev/sddm4", BRACK(FH_SDDM | 4), "\\Device\\Harddisk116\\Partition4"}, - {"/dev/sddm5", BRACK(FH_SDDM | 5), "\\Device\\Harddisk116\\Partition5"}, - {"/dev/sddm6", BRACK(FH_SDDM | 6), "\\Device\\Harddisk116\\Partition6"}, - {"/dev/sddm7", BRACK(FH_SDDM | 7), "\\Device\\Harddisk116\\Partition7"}, - {"/dev/sddm8", BRACK(FH_SDDM | 8), "\\Device\\Harddisk116\\Partition8"}, - {"/dev/sddm9", BRACK(FH_SDDM | 9), "\\Device\\Harddisk116\\Partition9"}, - {"/dev/sddm10", BRACK(FH_SDDM | 10), "\\Device\\Harddisk116\\Partition10"}, - {"/dev/sddm11", BRACK(FH_SDDM | 11), "\\Device\\Harddisk116\\Partition11"}, - {"/dev/sddm12", BRACK(FH_SDDM | 12), "\\Device\\Harddisk116\\Partition12"}, - {"/dev/sddm13", BRACK(FH_SDDM | 13), "\\Device\\Harddisk116\\Partition13"}, - {"/dev/sddm14", BRACK(FH_SDDM | 14), "\\Device\\Harddisk116\\Partition14"}, - {"/dev/sddm15", BRACK(FH_SDDM | 15), "\\Device\\Harddisk116\\Partition15"}, - {"/dev/sddn1", BRACK(FH_SDDN | 1), "\\Device\\Harddisk117\\Partition1"}, - {"/dev/sddn2", BRACK(FH_SDDN | 2), "\\Device\\Harddisk117\\Partition2"}, - {"/dev/sddn3", BRACK(FH_SDDN | 3), "\\Device\\Harddisk117\\Partition3"}, - {"/dev/sddn4", BRACK(FH_SDDN | 4), "\\Device\\Harddisk117\\Partition4"}, - {"/dev/sddn5", BRACK(FH_SDDN | 5), "\\Device\\Harddisk117\\Partition5"}, - {"/dev/sddn6", BRACK(FH_SDDN | 6), "\\Device\\Harddisk117\\Partition6"}, - {"/dev/sddn7", BRACK(FH_SDDN | 7), "\\Device\\Harddisk117\\Partition7"}, - {"/dev/sddn8", BRACK(FH_SDDN | 8), "\\Device\\Harddisk117\\Partition8"}, - {"/dev/sddn9", BRACK(FH_SDDN | 9), "\\Device\\Harddisk117\\Partition9"}, - {"/dev/sddn10", BRACK(FH_SDDN | 10), "\\Device\\Harddisk117\\Partition10"}, - {"/dev/sddn11", BRACK(FH_SDDN | 11), "\\Device\\Harddisk117\\Partition11"}, - {"/dev/sddn12", BRACK(FH_SDDN | 12), "\\Device\\Harddisk117\\Partition12"}, - {"/dev/sddn13", BRACK(FH_SDDN | 13), "\\Device\\Harddisk117\\Partition13"}, - {"/dev/sddn14", BRACK(FH_SDDN | 14), "\\Device\\Harddisk117\\Partition14"}, - {"/dev/sddn15", BRACK(FH_SDDN | 15), "\\Device\\Harddisk117\\Partition15"}, - {"/dev/sddo1", BRACK(FH_SDDO | 1), "\\Device\\Harddisk118\\Partition1"}, - {"/dev/sddo2", BRACK(FH_SDDO | 2), "\\Device\\Harddisk118\\Partition2"}, - {"/dev/sddo3", BRACK(FH_SDDO | 3), "\\Device\\Harddisk118\\Partition3"}, - {"/dev/sddo4", BRACK(FH_SDDO | 4), "\\Device\\Harddisk118\\Partition4"}, - {"/dev/sddo5", BRACK(FH_SDDO | 5), "\\Device\\Harddisk118\\Partition5"}, - {"/dev/sddo6", BRACK(FH_SDDO | 6), "\\Device\\Harddisk118\\Partition6"}, - {"/dev/sddo7", BRACK(FH_SDDO | 7), "\\Device\\Harddisk118\\Partition7"}, - {"/dev/sddo8", BRACK(FH_SDDO | 8), "\\Device\\Harddisk118\\Partition8"}, - {"/dev/sddo9", BRACK(FH_SDDO | 9), "\\Device\\Harddisk118\\Partition9"}, - {"/dev/sddo10", BRACK(FH_SDDO | 10), "\\Device\\Harddisk118\\Partition10"}, - {"/dev/sddo11", BRACK(FH_SDDO | 11), "\\Device\\Harddisk118\\Partition11"}, - {"/dev/sddo12", BRACK(FH_SDDO | 12), "\\Device\\Harddisk118\\Partition12"}, - {"/dev/sddo13", BRACK(FH_SDDO | 13), "\\Device\\Harddisk118\\Partition13"}, - {"/dev/sddo14", BRACK(FH_SDDO | 14), "\\Device\\Harddisk118\\Partition14"}, - {"/dev/sddo15", BRACK(FH_SDDO | 15), "\\Device\\Harddisk118\\Partition15"}, - {"/dev/sddp1", BRACK(FH_SDDP | 1), "\\Device\\Harddisk119\\Partition1"}, - {"/dev/sddp2", BRACK(FH_SDDP | 2), "\\Device\\Harddisk119\\Partition2"}, - {"/dev/sddp3", BRACK(FH_SDDP | 3), "\\Device\\Harddisk119\\Partition3"}, - {"/dev/sddp4", BRACK(FH_SDDP | 4), "\\Device\\Harddisk119\\Partition4"}, - {"/dev/sddp5", BRACK(FH_SDDP | 5), "\\Device\\Harddisk119\\Partition5"}, - {"/dev/sddp6", BRACK(FH_SDDP | 6), "\\Device\\Harddisk119\\Partition6"}, - {"/dev/sddp7", BRACK(FH_SDDP | 7), "\\Device\\Harddisk119\\Partition7"}, - {"/dev/sddp8", BRACK(FH_SDDP | 8), "\\Device\\Harddisk119\\Partition8"}, - {"/dev/sddp9", BRACK(FH_SDDP | 9), "\\Device\\Harddisk119\\Partition9"}, - {"/dev/sddp10", BRACK(FH_SDDP | 10), "\\Device\\Harddisk119\\Partition10"}, - {"/dev/sddp11", BRACK(FH_SDDP | 11), "\\Device\\Harddisk119\\Partition11"}, - {"/dev/sddp12", BRACK(FH_SDDP | 12), "\\Device\\Harddisk119\\Partition12"}, - {"/dev/sddp13", BRACK(FH_SDDP | 13), "\\Device\\Harddisk119\\Partition13"}, - {"/dev/sddp14", BRACK(FH_SDDP | 14), "\\Device\\Harddisk119\\Partition14"}, - {"/dev/sddp15", BRACK(FH_SDDP | 15), "\\Device\\Harddisk119\\Partition15"}, - {"/dev/sddq1", BRACK(FH_SDDQ | 1), "\\Device\\Harddisk120\\Partition1"}, - {"/dev/sddq2", BRACK(FH_SDDQ | 2), "\\Device\\Harddisk120\\Partition2"}, - {"/dev/sddq3", BRACK(FH_SDDQ | 3), "\\Device\\Harddisk120\\Partition3"}, - {"/dev/sddq4", BRACK(FH_SDDQ | 4), "\\Device\\Harddisk120\\Partition4"}, - {"/dev/sddq5", BRACK(FH_SDDQ | 5), "\\Device\\Harddisk120\\Partition5"}, - {"/dev/sddq6", BRACK(FH_SDDQ | 6), "\\Device\\Harddisk120\\Partition6"}, - {"/dev/sddq7", BRACK(FH_SDDQ | 7), "\\Device\\Harddisk120\\Partition7"}, - {"/dev/sddq8", BRACK(FH_SDDQ | 8), "\\Device\\Harddisk120\\Partition8"}, - {"/dev/sddq9", BRACK(FH_SDDQ | 9), "\\Device\\Harddisk120\\Partition9"}, - {"/dev/sddq10", BRACK(FH_SDDQ | 10), "\\Device\\Harddisk120\\Partition10"}, - {"/dev/sddq11", BRACK(FH_SDDQ | 11), "\\Device\\Harddisk120\\Partition11"}, - {"/dev/sddq12", BRACK(FH_SDDQ | 12), "\\Device\\Harddisk120\\Partition12"}, - {"/dev/sddq13", BRACK(FH_SDDQ | 13), "\\Device\\Harddisk120\\Partition13"}, - {"/dev/sddq14", BRACK(FH_SDDQ | 14), "\\Device\\Harddisk120\\Partition14"}, - {"/dev/sddq15", BRACK(FH_SDDQ | 15), "\\Device\\Harddisk120\\Partition15"}, - {"/dev/sddr1", BRACK(FH_SDDR | 1), "\\Device\\Harddisk121\\Partition1"}, - {"/dev/sddr2", BRACK(FH_SDDR | 2), "\\Device\\Harddisk121\\Partition2"}, - {"/dev/sddr3", BRACK(FH_SDDR | 3), "\\Device\\Harddisk121\\Partition3"}, - {"/dev/sddr4", BRACK(FH_SDDR | 4), "\\Device\\Harddisk121\\Partition4"}, - {"/dev/sddr5", BRACK(FH_SDDR | 5), "\\Device\\Harddisk121\\Partition5"}, - {"/dev/sddr6", BRACK(FH_SDDR | 6), "\\Device\\Harddisk121\\Partition6"}, - {"/dev/sddr7", BRACK(FH_SDDR | 7), "\\Device\\Harddisk121\\Partition7"}, - {"/dev/sddr8", BRACK(FH_SDDR | 8), "\\Device\\Harddisk121\\Partition8"}, - {"/dev/sddr9", BRACK(FH_SDDR | 9), "\\Device\\Harddisk121\\Partition9"}, - {"/dev/sddr10", BRACK(FH_SDDR | 10), "\\Device\\Harddisk121\\Partition10"}, - {"/dev/sddr11", BRACK(FH_SDDR | 11), "\\Device\\Harddisk121\\Partition11"}, - {"/dev/sddr12", BRACK(FH_SDDR | 12), "\\Device\\Harddisk121\\Partition12"}, - {"/dev/sddr13", BRACK(FH_SDDR | 13), "\\Device\\Harddisk121\\Partition13"}, - {"/dev/sddr14", BRACK(FH_SDDR | 14), "\\Device\\Harddisk121\\Partition14"}, - {"/dev/sddr15", BRACK(FH_SDDR | 15), "\\Device\\Harddisk121\\Partition15"}, - {"/dev/sdds1", BRACK(FH_SDDS | 1), "\\Device\\Harddisk122\\Partition1"}, - {"/dev/sdds2", BRACK(FH_SDDS | 2), "\\Device\\Harddisk122\\Partition2"}, - {"/dev/sdds3", BRACK(FH_SDDS | 3), "\\Device\\Harddisk122\\Partition3"}, - {"/dev/sdds4", BRACK(FH_SDDS | 4), "\\Device\\Harddisk122\\Partition4"}, - {"/dev/sdds5", BRACK(FH_SDDS | 5), "\\Device\\Harddisk122\\Partition5"}, - {"/dev/sdds6", BRACK(FH_SDDS | 6), "\\Device\\Harddisk122\\Partition6"}, - {"/dev/sdds7", BRACK(FH_SDDS | 7), "\\Device\\Harddisk122\\Partition7"}, - {"/dev/sdds8", BRACK(FH_SDDS | 8), "\\Device\\Harddisk122\\Partition8"}, - {"/dev/sdds9", BRACK(FH_SDDS | 9), "\\Device\\Harddisk122\\Partition9"}, - {"/dev/sdds10", BRACK(FH_SDDS | 10), "\\Device\\Harddisk122\\Partition10"}, - {"/dev/sdds11", BRACK(FH_SDDS | 11), "\\Device\\Harddisk122\\Partition11"}, - {"/dev/sdds12", BRACK(FH_SDDS | 12), "\\Device\\Harddisk122\\Partition12"}, - {"/dev/sdds13", BRACK(FH_SDDS | 13), "\\Device\\Harddisk122\\Partition13"}, - {"/dev/sdds14", BRACK(FH_SDDS | 14), "\\Device\\Harddisk122\\Partition14"}, - {"/dev/sdds15", BRACK(FH_SDDS | 15), "\\Device\\Harddisk122\\Partition15"}, - {"/dev/sddt1", BRACK(FH_SDDT | 1), "\\Device\\Harddisk123\\Partition1"}, - {"/dev/sddt2", BRACK(FH_SDDT | 2), "\\Device\\Harddisk123\\Partition2"}, - {"/dev/sddt3", BRACK(FH_SDDT | 3), "\\Device\\Harddisk123\\Partition3"}, - {"/dev/sddt4", BRACK(FH_SDDT | 4), "\\Device\\Harddisk123\\Partition4"}, - {"/dev/sddt5", BRACK(FH_SDDT | 5), "\\Device\\Harddisk123\\Partition5"}, - {"/dev/sddt6", BRACK(FH_SDDT | 6), "\\Device\\Harddisk123\\Partition6"}, - {"/dev/sddt7", BRACK(FH_SDDT | 7), "\\Device\\Harddisk123\\Partition7"}, - {"/dev/sddt8", BRACK(FH_SDDT | 8), "\\Device\\Harddisk123\\Partition8"}, - {"/dev/sddt9", BRACK(FH_SDDT | 9), "\\Device\\Harddisk123\\Partition9"}, - {"/dev/sddt10", BRACK(FH_SDDT | 10), "\\Device\\Harddisk123\\Partition10"}, - {"/dev/sddt11", BRACK(FH_SDDT | 11), "\\Device\\Harddisk123\\Partition11"}, - {"/dev/sddt12", BRACK(FH_SDDT | 12), "\\Device\\Harddisk123\\Partition12"}, - {"/dev/sddt13", BRACK(FH_SDDT | 13), "\\Device\\Harddisk123\\Partition13"}, - {"/dev/sddt14", BRACK(FH_SDDT | 14), "\\Device\\Harddisk123\\Partition14"}, - {"/dev/sddt15", BRACK(FH_SDDT | 15), "\\Device\\Harddisk123\\Partition15"}, - {"/dev/sddu1", BRACK(FH_SDDU | 1), "\\Device\\Harddisk124\\Partition1"}, - {"/dev/sddu2", BRACK(FH_SDDU | 2), "\\Device\\Harddisk124\\Partition2"}, - {"/dev/sddu3", BRACK(FH_SDDU | 3), "\\Device\\Harddisk124\\Partition3"}, - {"/dev/sddu4", BRACK(FH_SDDU | 4), "\\Device\\Harddisk124\\Partition4"}, - {"/dev/sddu5", BRACK(FH_SDDU | 5), "\\Device\\Harddisk124\\Partition5"}, - {"/dev/sddu6", BRACK(FH_SDDU | 6), "\\Device\\Harddisk124\\Partition6"}, - {"/dev/sddu7", BRACK(FH_SDDU | 7), "\\Device\\Harddisk124\\Partition7"}, - {"/dev/sddu8", BRACK(FH_SDDU | 8), "\\Device\\Harddisk124\\Partition8"}, - {"/dev/sddu9", BRACK(FH_SDDU | 9), "\\Device\\Harddisk124\\Partition9"}, - {"/dev/sddu10", BRACK(FH_SDDU | 10), "\\Device\\Harddisk124\\Partition10"}, - {"/dev/sddu11", BRACK(FH_SDDU | 11), "\\Device\\Harddisk124\\Partition11"}, - {"/dev/sddu12", BRACK(FH_SDDU | 12), "\\Device\\Harddisk124\\Partition12"}, - {"/dev/sddu13", BRACK(FH_SDDU | 13), "\\Device\\Harddisk124\\Partition13"}, - {"/dev/sddu14", BRACK(FH_SDDU | 14), "\\Device\\Harddisk124\\Partition14"}, - {"/dev/sddu15", BRACK(FH_SDDU | 15), "\\Device\\Harddisk124\\Partition15"}, - {"/dev/sddv1", BRACK(FH_SDDV | 1), "\\Device\\Harddisk125\\Partition1"}, - {"/dev/sddv2", BRACK(FH_SDDV | 2), "\\Device\\Harddisk125\\Partition2"}, - {"/dev/sddv3", BRACK(FH_SDDV | 3), "\\Device\\Harddisk125\\Partition3"}, - {"/dev/sddv4", BRACK(FH_SDDV | 4), "\\Device\\Harddisk125\\Partition4"}, - {"/dev/sddv5", BRACK(FH_SDDV | 5), "\\Device\\Harddisk125\\Partition5"}, - {"/dev/sddv6", BRACK(FH_SDDV | 6), "\\Device\\Harddisk125\\Partition6"}, - {"/dev/sddv7", BRACK(FH_SDDV | 7), "\\Device\\Harddisk125\\Partition7"}, - {"/dev/sddv8", BRACK(FH_SDDV | 8), "\\Device\\Harddisk125\\Partition8"}, - {"/dev/sddv9", BRACK(FH_SDDV | 9), "\\Device\\Harddisk125\\Partition9"}, - {"/dev/sddv10", BRACK(FH_SDDV | 10), "\\Device\\Harddisk125\\Partition10"}, - {"/dev/sddv11", BRACK(FH_SDDV | 11), "\\Device\\Harddisk125\\Partition11"}, - {"/dev/sddv12", BRACK(FH_SDDV | 12), "\\Device\\Harddisk125\\Partition12"}, - {"/dev/sddv13", BRACK(FH_SDDV | 13), "\\Device\\Harddisk125\\Partition13"}, - {"/dev/sddv14", BRACK(FH_SDDV | 14), "\\Device\\Harddisk125\\Partition14"}, - {"/dev/sddv15", BRACK(FH_SDDV | 15), "\\Device\\Harddisk125\\Partition15"}, - {"/dev/sddw1", BRACK(FH_SDDW | 1), "\\Device\\Harddisk126\\Partition1"}, - {"/dev/sddw2", BRACK(FH_SDDW | 2), "\\Device\\Harddisk126\\Partition2"}, - {"/dev/sddw3", BRACK(FH_SDDW | 3), "\\Device\\Harddisk126\\Partition3"}, - {"/dev/sddw4", BRACK(FH_SDDW | 4), "\\Device\\Harddisk126\\Partition4"}, - {"/dev/sddw5", BRACK(FH_SDDW | 5), "\\Device\\Harddisk126\\Partition5"}, - {"/dev/sddw6", BRACK(FH_SDDW | 6), "\\Device\\Harddisk126\\Partition6"}, - {"/dev/sddw7", BRACK(FH_SDDW | 7), "\\Device\\Harddisk126\\Partition7"}, - {"/dev/sddw8", BRACK(FH_SDDW | 8), "\\Device\\Harddisk126\\Partition8"}, - {"/dev/sddw9", BRACK(FH_SDDW | 9), "\\Device\\Harddisk126\\Partition9"}, - {"/dev/sddw10", BRACK(FH_SDDW | 10), "\\Device\\Harddisk126\\Partition10"}, - {"/dev/sddw11", BRACK(FH_SDDW | 11), "\\Device\\Harddisk126\\Partition11"}, - {"/dev/sddw12", BRACK(FH_SDDW | 12), "\\Device\\Harddisk126\\Partition12"}, - {"/dev/sddw13", BRACK(FH_SDDW | 13), "\\Device\\Harddisk126\\Partition13"}, - {"/dev/sddw14", BRACK(FH_SDDW | 14), "\\Device\\Harddisk126\\Partition14"}, - {"/dev/sddw15", BRACK(FH_SDDW | 15), "\\Device\\Harddisk126\\Partition15"}, - {"/dev/sddx1", BRACK(FH_SDDX | 1), "\\Device\\Harddisk127\\Partition1"}, - {"/dev/sddx2", BRACK(FH_SDDX | 2), "\\Device\\Harddisk127\\Partition2"}, - {"/dev/sddx3", BRACK(FH_SDDX | 3), "\\Device\\Harddisk127\\Partition3"}, - {"/dev/sddx4", BRACK(FH_SDDX | 4), "\\Device\\Harddisk127\\Partition4"}, - {"/dev/sddx5", BRACK(FH_SDDX | 5), "\\Device\\Harddisk127\\Partition5"}, - {"/dev/sddx6", BRACK(FH_SDDX | 6), "\\Device\\Harddisk127\\Partition6"}, - {"/dev/sddx7", BRACK(FH_SDDX | 7), "\\Device\\Harddisk127\\Partition7"}, - {"/dev/sddx8", BRACK(FH_SDDX | 8), "\\Device\\Harddisk127\\Partition8"}, - {"/dev/sddx9", BRACK(FH_SDDX | 9), "\\Device\\Harddisk127\\Partition9"}, - {"/dev/sddx10", BRACK(FH_SDDX | 10), "\\Device\\Harddisk127\\Partition10"}, - {"/dev/sddx11", BRACK(FH_SDDX | 11), "\\Device\\Harddisk127\\Partition11"}, - {"/dev/sddx12", BRACK(FH_SDDX | 12), "\\Device\\Harddisk127\\Partition12"}, - {"/dev/sddx13", BRACK(FH_SDDX | 13), "\\Device\\Harddisk127\\Partition13"}, - {"/dev/sddx14", BRACK(FH_SDDX | 14), "\\Device\\Harddisk127\\Partition14"}, - {"/dev/sddx15", BRACK(FH_SDDX | 15), "\\Device\\Harddisk127\\Partition15"}, - {"/dev/sr0", BRACK(FHDEV(DEV_CDROM_MAJOR, 0)), "\\Device\\CdRom0"}, - {"/dev/sr1", BRACK(FHDEV(DEV_CDROM_MAJOR, 1)), "\\Device\\CdRom1"}, - {"/dev/sr2", BRACK(FHDEV(DEV_CDROM_MAJOR, 2)), "\\Device\\CdRom2"}, - {"/dev/sr3", BRACK(FHDEV(DEV_CDROM_MAJOR, 3)), "\\Device\\CdRom3"}, - {"/dev/sr4", BRACK(FHDEV(DEV_CDROM_MAJOR, 4)), "\\Device\\CdRom4"}, - {"/dev/sr5", BRACK(FHDEV(DEV_CDROM_MAJOR, 5)), "\\Device\\CdRom5"}, - {"/dev/sr6", BRACK(FHDEV(DEV_CDROM_MAJOR, 6)), "\\Device\\CdRom6"}, - {"/dev/sr7", BRACK(FHDEV(DEV_CDROM_MAJOR, 7)), "\\Device\\CdRom7"}, - {"/dev/sr8", BRACK(FHDEV(DEV_CDROM_MAJOR, 8)), "\\Device\\CdRom8"}, - {"/dev/sr9", BRACK(FHDEV(DEV_CDROM_MAJOR, 9)), "\\Device\\CdRom9"}, - {"/dev/sr10", BRACK(FHDEV(DEV_CDROM_MAJOR, 10)), "\\Device\\CdRom10"}, - {"/dev/sr11", BRACK(FHDEV(DEV_CDROM_MAJOR, 11)), "\\Device\\CdRom11"}, - {"/dev/sr12", BRACK(FHDEV(DEV_CDROM_MAJOR, 12)), "\\Device\\CdRom12"}, - {"/dev/sr13", BRACK(FHDEV(DEV_CDROM_MAJOR, 13)), "\\Device\\CdRom13"}, - {"/dev/sr14", BRACK(FHDEV(DEV_CDROM_MAJOR, 14)), "\\Device\\CdRom14"}, - {"/dev/sr15", BRACK(FHDEV(DEV_CDROM_MAJOR, 15)), "\\Device\\CdRom15"}, - {"/dev/st0", BRACK(FHDEV(DEV_TAPE_MAJOR, 0)), "\\Device\\Tape0"}, - {"/dev/st1", BRACK(FHDEV(DEV_TAPE_MAJOR, 1)), "\\Device\\Tape1"}, - {"/dev/st2", BRACK(FHDEV(DEV_TAPE_MAJOR, 2)), "\\Device\\Tape2"}, - {"/dev/st3", BRACK(FHDEV(DEV_TAPE_MAJOR, 3)), "\\Device\\Tape3"}, - {"/dev/st4", BRACK(FHDEV(DEV_TAPE_MAJOR, 4)), "\\Device\\Tape4"}, - {"/dev/st5", BRACK(FHDEV(DEV_TAPE_MAJOR, 5)), "\\Device\\Tape5"}, - {"/dev/st6", BRACK(FHDEV(DEV_TAPE_MAJOR, 6)), "\\Device\\Tape6"}, - {"/dev/st7", BRACK(FHDEV(DEV_TAPE_MAJOR, 7)), "\\Device\\Tape7"}, - {"/dev/st8", BRACK(FHDEV(DEV_TAPE_MAJOR, 8)), "\\Device\\Tape8"}, - {"/dev/st9", BRACK(FHDEV(DEV_TAPE_MAJOR, 9)), "\\Device\\Tape9"}, - {"/dev/st10", BRACK(FHDEV(DEV_TAPE_MAJOR, 10)), "\\Device\\Tape10"}, - {"/dev/st11", BRACK(FHDEV(DEV_TAPE_MAJOR, 11)), "\\Device\\Tape11"}, - {"/dev/st12", BRACK(FHDEV(DEV_TAPE_MAJOR, 12)), "\\Device\\Tape12"}, - {"/dev/st13", BRACK(FHDEV(DEV_TAPE_MAJOR, 13)), "\\Device\\Tape13"}, - {"/dev/st14", BRACK(FHDEV(DEV_TAPE_MAJOR, 14)), "\\Device\\Tape14"}, - {"/dev/st15", BRACK(FHDEV(DEV_TAPE_MAJOR, 15)), "\\Device\\Tape15"}, - {"/dev/st16", BRACK(FHDEV(DEV_TAPE_MAJOR, 16)), "\\Device\\Tape16"}, - {"/dev/st17", BRACK(FHDEV(DEV_TAPE_MAJOR, 17)), "\\Device\\Tape17"}, - {"/dev/st18", BRACK(FHDEV(DEV_TAPE_MAJOR, 18)), "\\Device\\Tape18"}, - {"/dev/st19", BRACK(FHDEV(DEV_TAPE_MAJOR, 19)), "\\Device\\Tape19"}, - {"/dev/st20", BRACK(FHDEV(DEV_TAPE_MAJOR, 20)), "\\Device\\Tape20"}, - {"/dev/st21", BRACK(FHDEV(DEV_TAPE_MAJOR, 21)), "\\Device\\Tape21"}, - {"/dev/st22", BRACK(FHDEV(DEV_TAPE_MAJOR, 22)), "\\Device\\Tape22"}, - {"/dev/st23", BRACK(FHDEV(DEV_TAPE_MAJOR, 23)), "\\Device\\Tape23"}, - {"/dev/st24", BRACK(FHDEV(DEV_TAPE_MAJOR, 24)), "\\Device\\Tape24"}, - {"/dev/st25", BRACK(FHDEV(DEV_TAPE_MAJOR, 25)), "\\Device\\Tape25"}, - {"/dev/st26", BRACK(FHDEV(DEV_TAPE_MAJOR, 26)), "\\Device\\Tape26"}, - {"/dev/st27", BRACK(FHDEV(DEV_TAPE_MAJOR, 27)), "\\Device\\Tape27"}, - {"/dev/st28", BRACK(FHDEV(DEV_TAPE_MAJOR, 28)), "\\Device\\Tape28"}, - {"/dev/st29", BRACK(FHDEV(DEV_TAPE_MAJOR, 29)), "\\Device\\Tape29"}, - {"/dev/st30", BRACK(FHDEV(DEV_TAPE_MAJOR, 30)), "\\Device\\Tape30"}, - {"/dev/st31", BRACK(FHDEV(DEV_TAPE_MAJOR, 31)), "\\Device\\Tape31"}, - {"/dev/st32", BRACK(FHDEV(DEV_TAPE_MAJOR, 32)), "\\Device\\Tape32"}, - {"/dev/st33", BRACK(FHDEV(DEV_TAPE_MAJOR, 33)), "\\Device\\Tape33"}, - {"/dev/st34", BRACK(FHDEV(DEV_TAPE_MAJOR, 34)), "\\Device\\Tape34"}, - {"/dev/st35", BRACK(FHDEV(DEV_TAPE_MAJOR, 35)), "\\Device\\Tape35"}, - {"/dev/st36", BRACK(FHDEV(DEV_TAPE_MAJOR, 36)), "\\Device\\Tape36"}, - {"/dev/st37", BRACK(FHDEV(DEV_TAPE_MAJOR, 37)), "\\Device\\Tape37"}, - {"/dev/st38", BRACK(FHDEV(DEV_TAPE_MAJOR, 38)), "\\Device\\Tape38"}, - {"/dev/st39", BRACK(FHDEV(DEV_TAPE_MAJOR, 39)), "\\Device\\Tape39"}, - {"/dev/st40", BRACK(FHDEV(DEV_TAPE_MAJOR, 40)), "\\Device\\Tape40"}, - {"/dev/st41", BRACK(FHDEV(DEV_TAPE_MAJOR, 41)), "\\Device\\Tape41"}, - {"/dev/st42", BRACK(FHDEV(DEV_TAPE_MAJOR, 42)), "\\Device\\Tape42"}, - {"/dev/st43", BRACK(FHDEV(DEV_TAPE_MAJOR, 43)), "\\Device\\Tape43"}, - {"/dev/st44", BRACK(FHDEV(DEV_TAPE_MAJOR, 44)), "\\Device\\Tape44"}, - {"/dev/st45", BRACK(FHDEV(DEV_TAPE_MAJOR, 45)), "\\Device\\Tape45"}, - {"/dev/st46", BRACK(FHDEV(DEV_TAPE_MAJOR, 46)), "\\Device\\Tape46"}, - {"/dev/st47", BRACK(FHDEV(DEV_TAPE_MAJOR, 47)), "\\Device\\Tape47"}, - {"/dev/st48", BRACK(FHDEV(DEV_TAPE_MAJOR, 48)), "\\Device\\Tape48"}, - {"/dev/st49", BRACK(FHDEV(DEV_TAPE_MAJOR, 49)), "\\Device\\Tape49"}, - {"/dev/st50", BRACK(FHDEV(DEV_TAPE_MAJOR, 50)), "\\Device\\Tape50"}, - {"/dev/st51", BRACK(FHDEV(DEV_TAPE_MAJOR, 51)), "\\Device\\Tape51"}, - {"/dev/st52", BRACK(FHDEV(DEV_TAPE_MAJOR, 52)), "\\Device\\Tape52"}, - {"/dev/st53", BRACK(FHDEV(DEV_TAPE_MAJOR, 53)), "\\Device\\Tape53"}, - {"/dev/st54", BRACK(FHDEV(DEV_TAPE_MAJOR, 54)), "\\Device\\Tape54"}, - {"/dev/st55", BRACK(FHDEV(DEV_TAPE_MAJOR, 55)), "\\Device\\Tape55"}, - {"/dev/st56", BRACK(FHDEV(DEV_TAPE_MAJOR, 56)), "\\Device\\Tape56"}, - {"/dev/st57", BRACK(FHDEV(DEV_TAPE_MAJOR, 57)), "\\Device\\Tape57"}, - {"/dev/st58", BRACK(FHDEV(DEV_TAPE_MAJOR, 58)), "\\Device\\Tape58"}, - {"/dev/st59", BRACK(FHDEV(DEV_TAPE_MAJOR, 59)), "\\Device\\Tape59"}, - {"/dev/st60", BRACK(FHDEV(DEV_TAPE_MAJOR, 60)), "\\Device\\Tape60"}, - {"/dev/st61", BRACK(FHDEV(DEV_TAPE_MAJOR, 61)), "\\Device\\Tape61"}, - {"/dev/st62", BRACK(FHDEV(DEV_TAPE_MAJOR, 62)), "\\Device\\Tape62"}, - {"/dev/st63", BRACK(FHDEV(DEV_TAPE_MAJOR, 63)), "\\Device\\Tape63"}, - {"/dev/st64", BRACK(FHDEV(DEV_TAPE_MAJOR, 64)), "\\Device\\Tape64"}, - {"/dev/st65", BRACK(FHDEV(DEV_TAPE_MAJOR, 65)), "\\Device\\Tape65"}, - {"/dev/st66", BRACK(FHDEV(DEV_TAPE_MAJOR, 66)), "\\Device\\Tape66"}, - {"/dev/st67", BRACK(FHDEV(DEV_TAPE_MAJOR, 67)), "\\Device\\Tape67"}, - {"/dev/st68", BRACK(FHDEV(DEV_TAPE_MAJOR, 68)), "\\Device\\Tape68"}, - {"/dev/st69", BRACK(FHDEV(DEV_TAPE_MAJOR, 69)), "\\Device\\Tape69"}, - {"/dev/st70", BRACK(FHDEV(DEV_TAPE_MAJOR, 70)), "\\Device\\Tape70"}, - {"/dev/st71", BRACK(FHDEV(DEV_TAPE_MAJOR, 71)), "\\Device\\Tape71"}, - {"/dev/st72", BRACK(FHDEV(DEV_TAPE_MAJOR, 72)), "\\Device\\Tape72"}, - {"/dev/st73", BRACK(FHDEV(DEV_TAPE_MAJOR, 73)), "\\Device\\Tape73"}, - {"/dev/st74", BRACK(FHDEV(DEV_TAPE_MAJOR, 74)), "\\Device\\Tape74"}, - {"/dev/st75", BRACK(FHDEV(DEV_TAPE_MAJOR, 75)), "\\Device\\Tape75"}, - {"/dev/st76", BRACK(FHDEV(DEV_TAPE_MAJOR, 76)), "\\Device\\Tape76"}, - {"/dev/st77", BRACK(FHDEV(DEV_TAPE_MAJOR, 77)), "\\Device\\Tape77"}, - {"/dev/st78", BRACK(FHDEV(DEV_TAPE_MAJOR, 78)), "\\Device\\Tape78"}, - {"/dev/st79", BRACK(FHDEV(DEV_TAPE_MAJOR, 79)), "\\Device\\Tape79"}, - {"/dev/st80", BRACK(FHDEV(DEV_TAPE_MAJOR, 80)), "\\Device\\Tape80"}, - {"/dev/st81", BRACK(FHDEV(DEV_TAPE_MAJOR, 81)), "\\Device\\Tape81"}, - {"/dev/st82", BRACK(FHDEV(DEV_TAPE_MAJOR, 82)), "\\Device\\Tape82"}, - {"/dev/st83", BRACK(FHDEV(DEV_TAPE_MAJOR, 83)), "\\Device\\Tape83"}, - {"/dev/st84", BRACK(FHDEV(DEV_TAPE_MAJOR, 84)), "\\Device\\Tape84"}, - {"/dev/st85", BRACK(FHDEV(DEV_TAPE_MAJOR, 85)), "\\Device\\Tape85"}, - {"/dev/st86", BRACK(FHDEV(DEV_TAPE_MAJOR, 86)), "\\Device\\Tape86"}, - {"/dev/st87", BRACK(FHDEV(DEV_TAPE_MAJOR, 87)), "\\Device\\Tape87"}, - {"/dev/st88", BRACK(FHDEV(DEV_TAPE_MAJOR, 88)), "\\Device\\Tape88"}, - {"/dev/st89", BRACK(FHDEV(DEV_TAPE_MAJOR, 89)), "\\Device\\Tape89"}, - {"/dev/st90", BRACK(FHDEV(DEV_TAPE_MAJOR, 90)), "\\Device\\Tape90"}, - {"/dev/st91", BRACK(FHDEV(DEV_TAPE_MAJOR, 91)), "\\Device\\Tape91"}, - {"/dev/st92", BRACK(FHDEV(DEV_TAPE_MAJOR, 92)), "\\Device\\Tape92"}, - {"/dev/st93", BRACK(FHDEV(DEV_TAPE_MAJOR, 93)), "\\Device\\Tape93"}, - {"/dev/st94", BRACK(FHDEV(DEV_TAPE_MAJOR, 94)), "\\Device\\Tape94"}, - {"/dev/st95", BRACK(FHDEV(DEV_TAPE_MAJOR, 95)), "\\Device\\Tape95"}, - {"/dev/st96", BRACK(FHDEV(DEV_TAPE_MAJOR, 96)), "\\Device\\Tape96"}, - {"/dev/st97", BRACK(FHDEV(DEV_TAPE_MAJOR, 97)), "\\Device\\Tape97"}, - {"/dev/st98", BRACK(FHDEV(DEV_TAPE_MAJOR, 98)), "\\Device\\Tape98"}, - {"/dev/st99", BRACK(FHDEV(DEV_TAPE_MAJOR, 99)), "\\Device\\Tape99"}, - {"/dev/st100", BRACK(FHDEV(DEV_TAPE_MAJOR, 100)), "\\Device\\Tape100"}, - {"/dev/st101", BRACK(FHDEV(DEV_TAPE_MAJOR, 101)), "\\Device\\Tape101"}, - {"/dev/st102", BRACK(FHDEV(DEV_TAPE_MAJOR, 102)), "\\Device\\Tape102"}, - {"/dev/st103", BRACK(FHDEV(DEV_TAPE_MAJOR, 103)), "\\Device\\Tape103"}, - {"/dev/st104", BRACK(FHDEV(DEV_TAPE_MAJOR, 104)), "\\Device\\Tape104"}, - {"/dev/st105", BRACK(FHDEV(DEV_TAPE_MAJOR, 105)), "\\Device\\Tape105"}, - {"/dev/st106", BRACK(FHDEV(DEV_TAPE_MAJOR, 106)), "\\Device\\Tape106"}, - {"/dev/st107", BRACK(FHDEV(DEV_TAPE_MAJOR, 107)), "\\Device\\Tape107"}, - {"/dev/st108", BRACK(FHDEV(DEV_TAPE_MAJOR, 108)), "\\Device\\Tape108"}, - {"/dev/st109", BRACK(FHDEV(DEV_TAPE_MAJOR, 109)), "\\Device\\Tape109"}, - {"/dev/st110", BRACK(FHDEV(DEV_TAPE_MAJOR, 110)), "\\Device\\Tape110"}, - {"/dev/st111", BRACK(FHDEV(DEV_TAPE_MAJOR, 111)), "\\Device\\Tape111"}, - {"/dev/st112", BRACK(FHDEV(DEV_TAPE_MAJOR, 112)), "\\Device\\Tape112"}, - {"/dev/st113", BRACK(FHDEV(DEV_TAPE_MAJOR, 113)), "\\Device\\Tape113"}, - {"/dev/st114", BRACK(FHDEV(DEV_TAPE_MAJOR, 114)), "\\Device\\Tape114"}, - {"/dev/st115", BRACK(FHDEV(DEV_TAPE_MAJOR, 115)), "\\Device\\Tape115"}, - {"/dev/st116", BRACK(FHDEV(DEV_TAPE_MAJOR, 116)), "\\Device\\Tape116"}, - {"/dev/st117", BRACK(FHDEV(DEV_TAPE_MAJOR, 117)), "\\Device\\Tape117"}, - {"/dev/st118", BRACK(FHDEV(DEV_TAPE_MAJOR, 118)), "\\Device\\Tape118"}, - {"/dev/st119", BRACK(FHDEV(DEV_TAPE_MAJOR, 119)), "\\Device\\Tape119"}, - {"/dev/st120", BRACK(FHDEV(DEV_TAPE_MAJOR, 120)), "\\Device\\Tape120"}, - {"/dev/st121", BRACK(FHDEV(DEV_TAPE_MAJOR, 121)), "\\Device\\Tape121"}, - {"/dev/st122", BRACK(FHDEV(DEV_TAPE_MAJOR, 122)), "\\Device\\Tape122"}, - {"/dev/st123", BRACK(FHDEV(DEV_TAPE_MAJOR, 123)), "\\Device\\Tape123"}, - {"/dev/st124", BRACK(FHDEV(DEV_TAPE_MAJOR, 124)), "\\Device\\Tape124"}, - {"/dev/st125", BRACK(FHDEV(DEV_TAPE_MAJOR, 125)), "\\Device\\Tape125"}, - {"/dev/st126", BRACK(FHDEV(DEV_TAPE_MAJOR, 126)), "\\Device\\Tape126"}, - {"/dev/st127", BRACK(FHDEV(DEV_TAPE_MAJOR, 127)), "\\Device\\Tape127"}, - {"/dev/tty", BRACK(FH_TTY), "\\dev\\tty"}, - {"/dev/tty0", BRACK(FHDEV(DEV_TTYS_MAJOR, 0)), "\\dev\\tty0"}, - {"/dev/tty1", BRACK(FHDEV(DEV_TTYS_MAJOR, 1)), "\\dev\\tty1"}, - {"/dev/tty2", BRACK(FHDEV(DEV_TTYS_MAJOR, 2)), "\\dev\\tty2"}, - {"/dev/tty3", BRACK(FHDEV(DEV_TTYS_MAJOR, 3)), "\\dev\\tty3"}, - {"/dev/tty4", BRACK(FHDEV(DEV_TTYS_MAJOR, 4)), "\\dev\\tty4"}, - {"/dev/tty5", BRACK(FHDEV(DEV_TTYS_MAJOR, 5)), "\\dev\\tty5"}, - {"/dev/tty6", BRACK(FHDEV(DEV_TTYS_MAJOR, 6)), "\\dev\\tty6"}, - {"/dev/tty7", BRACK(FHDEV(DEV_TTYS_MAJOR, 7)), "\\dev\\tty7"}, - {"/dev/tty8", BRACK(FHDEV(DEV_TTYS_MAJOR, 8)), "\\dev\\tty8"}, - {"/dev/tty9", BRACK(FHDEV(DEV_TTYS_MAJOR, 9)), "\\dev\\tty9"}, - {"/dev/tty10", BRACK(FHDEV(DEV_TTYS_MAJOR, 10)), "\\dev\\tty10"}, - {"/dev/tty11", BRACK(FHDEV(DEV_TTYS_MAJOR, 11)), "\\dev\\tty11"}, - {"/dev/tty12", BRACK(FHDEV(DEV_TTYS_MAJOR, 12)), "\\dev\\tty12"}, - {"/dev/tty13", BRACK(FHDEV(DEV_TTYS_MAJOR, 13)), "\\dev\\tty13"}, - {"/dev/tty14", BRACK(FHDEV(DEV_TTYS_MAJOR, 14)), "\\dev\\tty14"}, - {"/dev/tty15", BRACK(FHDEV(DEV_TTYS_MAJOR, 15)), "\\dev\\tty15"}, - {"/dev/tty16", BRACK(FHDEV(DEV_TTYS_MAJOR, 16)), "\\dev\\tty16"}, - {"/dev/tty17", BRACK(FHDEV(DEV_TTYS_MAJOR, 17)), "\\dev\\tty17"}, - {"/dev/tty18", BRACK(FHDEV(DEV_TTYS_MAJOR, 18)), "\\dev\\tty18"}, - {"/dev/tty19", BRACK(FHDEV(DEV_TTYS_MAJOR, 19)), "\\dev\\tty19"}, - {"/dev/tty20", BRACK(FHDEV(DEV_TTYS_MAJOR, 20)), "\\dev\\tty20"}, - {"/dev/tty21", BRACK(FHDEV(DEV_TTYS_MAJOR, 21)), "\\dev\\tty21"}, - {"/dev/tty22", BRACK(FHDEV(DEV_TTYS_MAJOR, 22)), "\\dev\\tty22"}, - {"/dev/tty23", BRACK(FHDEV(DEV_TTYS_MAJOR, 23)), "\\dev\\tty23"}, - {"/dev/tty24", BRACK(FHDEV(DEV_TTYS_MAJOR, 24)), "\\dev\\tty24"}, - {"/dev/tty25", BRACK(FHDEV(DEV_TTYS_MAJOR, 25)), "\\dev\\tty25"}, - {"/dev/tty26", BRACK(FHDEV(DEV_TTYS_MAJOR, 26)), "\\dev\\tty26"}, - {"/dev/tty27", BRACK(FHDEV(DEV_TTYS_MAJOR, 27)), "\\dev\\tty27"}, - {"/dev/tty28", BRACK(FHDEV(DEV_TTYS_MAJOR, 28)), "\\dev\\tty28"}, - {"/dev/tty29", BRACK(FHDEV(DEV_TTYS_MAJOR, 29)), "\\dev\\tty29"}, - {"/dev/tty30", BRACK(FHDEV(DEV_TTYS_MAJOR, 30)), "\\dev\\tty30"}, - {"/dev/tty31", BRACK(FHDEV(DEV_TTYS_MAJOR, 31)), "\\dev\\tty31"}, - {"/dev/tty32", BRACK(FHDEV(DEV_TTYS_MAJOR, 32)), "\\dev\\tty32"}, - {"/dev/tty33", BRACK(FHDEV(DEV_TTYS_MAJOR, 33)), "\\dev\\tty33"}, - {"/dev/tty34", BRACK(FHDEV(DEV_TTYS_MAJOR, 34)), "\\dev\\tty34"}, - {"/dev/tty35", BRACK(FHDEV(DEV_TTYS_MAJOR, 35)), "\\dev\\tty35"}, - {"/dev/tty36", BRACK(FHDEV(DEV_TTYS_MAJOR, 36)), "\\dev\\tty36"}, - {"/dev/tty37", BRACK(FHDEV(DEV_TTYS_MAJOR, 37)), "\\dev\\tty37"}, - {"/dev/tty38", BRACK(FHDEV(DEV_TTYS_MAJOR, 38)), "\\dev\\tty38"}, - {"/dev/tty39", BRACK(FHDEV(DEV_TTYS_MAJOR, 39)), "\\dev\\tty39"}, - {"/dev/tty40", BRACK(FHDEV(DEV_TTYS_MAJOR, 40)), "\\dev\\tty40"}, - {"/dev/tty41", BRACK(FHDEV(DEV_TTYS_MAJOR, 41)), "\\dev\\tty41"}, - {"/dev/tty42", BRACK(FHDEV(DEV_TTYS_MAJOR, 42)), "\\dev\\tty42"}, - {"/dev/tty43", BRACK(FHDEV(DEV_TTYS_MAJOR, 43)), "\\dev\\tty43"}, - {"/dev/tty44", BRACK(FHDEV(DEV_TTYS_MAJOR, 44)), "\\dev\\tty44"}, - {"/dev/tty45", BRACK(FHDEV(DEV_TTYS_MAJOR, 45)), "\\dev\\tty45"}, - {"/dev/tty46", BRACK(FHDEV(DEV_TTYS_MAJOR, 46)), "\\dev\\tty46"}, - {"/dev/tty47", BRACK(FHDEV(DEV_TTYS_MAJOR, 47)), "\\dev\\tty47"}, - {"/dev/tty48", BRACK(FHDEV(DEV_TTYS_MAJOR, 48)), "\\dev\\tty48"}, - {"/dev/tty49", BRACK(FHDEV(DEV_TTYS_MAJOR, 49)), "\\dev\\tty49"}, - {"/dev/tty50", BRACK(FHDEV(DEV_TTYS_MAJOR, 50)), "\\dev\\tty50"}, - {"/dev/tty51", BRACK(FHDEV(DEV_TTYS_MAJOR, 51)), "\\dev\\tty51"}, - {"/dev/tty52", BRACK(FHDEV(DEV_TTYS_MAJOR, 52)), "\\dev\\tty52"}, - {"/dev/tty53", BRACK(FHDEV(DEV_TTYS_MAJOR, 53)), "\\dev\\tty53"}, - {"/dev/tty54", BRACK(FHDEV(DEV_TTYS_MAJOR, 54)), "\\dev\\tty54"}, - {"/dev/tty55", BRACK(FHDEV(DEV_TTYS_MAJOR, 55)), "\\dev\\tty55"}, - {"/dev/tty56", BRACK(FHDEV(DEV_TTYS_MAJOR, 56)), "\\dev\\tty56"}, - {"/dev/tty57", BRACK(FHDEV(DEV_TTYS_MAJOR, 57)), "\\dev\\tty57"}, - {"/dev/tty58", BRACK(FHDEV(DEV_TTYS_MAJOR, 58)), "\\dev\\tty58"}, - {"/dev/tty59", BRACK(FHDEV(DEV_TTYS_MAJOR, 59)), "\\dev\\tty59"}, - {"/dev/tty60", BRACK(FHDEV(DEV_TTYS_MAJOR, 60)), "\\dev\\tty60"}, - {"/dev/tty61", BRACK(FHDEV(DEV_TTYS_MAJOR, 61)), "\\dev\\tty61"}, - {"/dev/tty62", BRACK(FHDEV(DEV_TTYS_MAJOR, 62)), "\\dev\\tty62"}, - {"/dev/tty63", BRACK(FHDEV(DEV_TTYS_MAJOR, 63)), "\\dev\\tty63"}, - {"/dev/ttyS0", BRACK(FHDEV(DEV_SERIAL_MAJOR, 0)), "\\??\\COM1"}, - {"/dev/ttyS1", BRACK(FHDEV(DEV_SERIAL_MAJOR, 1)), "\\??\\COM2"}, - {"/dev/ttyS2", BRACK(FHDEV(DEV_SERIAL_MAJOR, 2)), "\\??\\COM3"}, - {"/dev/ttyS3", BRACK(FHDEV(DEV_SERIAL_MAJOR, 3)), "\\??\\COM4"}, - {"/dev/ttyS4", BRACK(FHDEV(DEV_SERIAL_MAJOR, 4)), "\\??\\COM5"}, - {"/dev/ttyS5", BRACK(FHDEV(DEV_SERIAL_MAJOR, 5)), "\\??\\COM6"}, - {"/dev/ttyS6", BRACK(FHDEV(DEV_SERIAL_MAJOR, 6)), "\\??\\COM7"}, - {"/dev/ttyS7", BRACK(FHDEV(DEV_SERIAL_MAJOR, 7)), "\\??\\COM8"}, - {"/dev/ttyS8", BRACK(FHDEV(DEV_SERIAL_MAJOR, 8)), "\\??\\COM9"}, - {"/dev/ttyS9", BRACK(FHDEV(DEV_SERIAL_MAJOR, 9)), "\\??\\COM10"}, - {"/dev/ttyS10", BRACK(FHDEV(DEV_SERIAL_MAJOR, 10)), "\\??\\COM11"}, - {"/dev/ttyS11", BRACK(FHDEV(DEV_SERIAL_MAJOR, 11)), "\\??\\COM12"}, - {"/dev/ttyS12", BRACK(FHDEV(DEV_SERIAL_MAJOR, 12)), "\\??\\COM13"}, - {"/dev/ttyS13", BRACK(FHDEV(DEV_SERIAL_MAJOR, 13)), "\\??\\COM14"}, - {"/dev/ttyS14", BRACK(FHDEV(DEV_SERIAL_MAJOR, 14)), "\\??\\COM15"}, - {"/dev/ttyS15", BRACK(FHDEV(DEV_SERIAL_MAJOR, 15)), "\\??\\COM16"}, - {"/dev/ttyS16", BRACK(FHDEV(DEV_SERIAL_MAJOR, 16)), "\\??\\COM17"}, - {"/dev/ttyS17", BRACK(FHDEV(DEV_SERIAL_MAJOR, 17)), "\\??\\COM18"}, - {"/dev/ttyS18", BRACK(FHDEV(DEV_SERIAL_MAJOR, 18)), "\\??\\COM19"}, - {"/dev/ttyS19", BRACK(FHDEV(DEV_SERIAL_MAJOR, 19)), "\\??\\COM20"}, - {"/dev/ttyS20", BRACK(FHDEV(DEV_SERIAL_MAJOR, 20)), "\\??\\COM21"}, - {"/dev/ttyS21", BRACK(FHDEV(DEV_SERIAL_MAJOR, 21)), "\\??\\COM22"}, - {"/dev/ttyS22", BRACK(FHDEV(DEV_SERIAL_MAJOR, 22)), "\\??\\COM23"}, - {"/dev/ttyS23", BRACK(FHDEV(DEV_SERIAL_MAJOR, 23)), "\\??\\COM24"}, - {"/dev/ttyS24", BRACK(FHDEV(DEV_SERIAL_MAJOR, 24)), "\\??\\COM25"}, - {"/dev/ttyS25", BRACK(FHDEV(DEV_SERIAL_MAJOR, 25)), "\\??\\COM26"}, - {"/dev/ttyS26", BRACK(FHDEV(DEV_SERIAL_MAJOR, 26)), "\\??\\COM27"}, - {"/dev/ttyS27", BRACK(FHDEV(DEV_SERIAL_MAJOR, 27)), "\\??\\COM28"}, - {"/dev/ttyS28", BRACK(FHDEV(DEV_SERIAL_MAJOR, 28)), "\\??\\COM29"}, - {"/dev/ttyS29", BRACK(FHDEV(DEV_SERIAL_MAJOR, 29)), "\\??\\COM30"}, - {"/dev/ttyS30", BRACK(FHDEV(DEV_SERIAL_MAJOR, 30)), "\\??\\COM31"}, - {"/dev/ttyS31", BRACK(FHDEV(DEV_SERIAL_MAJOR, 31)), "\\??\\COM32"}, - {"/dev/ttyS32", BRACK(FHDEV(DEV_SERIAL_MAJOR, 32)), "\\??\\COM33"}, - {"/dev/ttyS33", BRACK(FHDEV(DEV_SERIAL_MAJOR, 33)), "\\??\\COM34"}, - {"/dev/ttyS34", BRACK(FHDEV(DEV_SERIAL_MAJOR, 34)), "\\??\\COM35"}, - {"/dev/ttyS35", BRACK(FHDEV(DEV_SERIAL_MAJOR, 35)), "\\??\\COM36"}, - {"/dev/ttyS36", BRACK(FHDEV(DEV_SERIAL_MAJOR, 36)), "\\??\\COM37"}, - {"/dev/ttyS37", BRACK(FHDEV(DEV_SERIAL_MAJOR, 37)), "\\??\\COM38"}, - {"/dev/ttyS38", BRACK(FHDEV(DEV_SERIAL_MAJOR, 38)), "\\??\\COM39"}, - {"/dev/ttyS39", BRACK(FHDEV(DEV_SERIAL_MAJOR, 39)), "\\??\\COM40"}, - {"/dev/ttyS40", BRACK(FHDEV(DEV_SERIAL_MAJOR, 40)), "\\??\\COM41"}, - {"/dev/ttyS41", BRACK(FHDEV(DEV_SERIAL_MAJOR, 41)), "\\??\\COM42"}, - {"/dev/ttyS42", BRACK(FHDEV(DEV_SERIAL_MAJOR, 42)), "\\??\\COM43"}, - {"/dev/ttyS43", BRACK(FHDEV(DEV_SERIAL_MAJOR, 43)), "\\??\\COM44"}, - {"/dev/ttyS44", BRACK(FHDEV(DEV_SERIAL_MAJOR, 44)), "\\??\\COM45"}, - {"/dev/ttyS45", BRACK(FHDEV(DEV_SERIAL_MAJOR, 45)), "\\??\\COM46"}, - {"/dev/ttyS46", BRACK(FHDEV(DEV_SERIAL_MAJOR, 46)), "\\??\\COM47"}, - {"/dev/ttyS47", BRACK(FHDEV(DEV_SERIAL_MAJOR, 47)), "\\??\\COM48"}, - {"/dev/ttyS48", BRACK(FHDEV(DEV_SERIAL_MAJOR, 48)), "\\??\\COM49"}, - {"/dev/ttyS49", BRACK(FHDEV(DEV_SERIAL_MAJOR, 49)), "\\??\\COM50"}, - {"/dev/ttyS50", BRACK(FHDEV(DEV_SERIAL_MAJOR, 50)), "\\??\\COM51"}, - {"/dev/ttyS51", BRACK(FHDEV(DEV_SERIAL_MAJOR, 51)), "\\??\\COM52"}, - {"/dev/ttyS52", BRACK(FHDEV(DEV_SERIAL_MAJOR, 52)), "\\??\\COM53"}, - {"/dev/ttyS53", BRACK(FHDEV(DEV_SERIAL_MAJOR, 53)), "\\??\\COM54"}, - {"/dev/ttyS54", BRACK(FHDEV(DEV_SERIAL_MAJOR, 54)), "\\??\\COM55"}, - {"/dev/ttyS55", BRACK(FHDEV(DEV_SERIAL_MAJOR, 55)), "\\??\\COM56"}, - {"/dev/ttyS56", BRACK(FHDEV(DEV_SERIAL_MAJOR, 56)), "\\??\\COM57"}, - {"/dev/ttyS57", BRACK(FHDEV(DEV_SERIAL_MAJOR, 57)), "\\??\\COM58"}, - {"/dev/ttyS58", BRACK(FHDEV(DEV_SERIAL_MAJOR, 58)), "\\??\\COM59"}, - {"/dev/ttyS59", BRACK(FHDEV(DEV_SERIAL_MAJOR, 59)), "\\??\\COM60"}, - {"/dev/ttyS60", BRACK(FHDEV(DEV_SERIAL_MAJOR, 60)), "\\??\\COM61"}, - {"/dev/ttyS61", BRACK(FHDEV(DEV_SERIAL_MAJOR, 61)), "\\??\\COM62"}, - {"/dev/ttyS62", BRACK(FHDEV(DEV_SERIAL_MAJOR, 62)), "\\??\\COM63"}, - {"/dev/ttyS63", BRACK(FHDEV(DEV_SERIAL_MAJOR, 63)), "\\??\\COM64"}, - {"/dev/ttym", BRACK(FH_TTYM), "\\dev\\ttym"}, - {"/dev/urandom", BRACK(FH_URANDOM), "\\dev\\urandom"}, - {"/dev/windows", BRACK(FH_WINDOWS), "\\dev\\windows"}, - {"/dev/zero", BRACK(FH_ZERO), "\\dev\\zero"} -}; - -const device *console_dev = dev_storage + 20; -const device *ttym_dev = dev_storage + 2513; -const device *ttys_dev = dev_storage + 2385; -const device *urandom_dev = dev_storage + 2514; - - -static KR_device_t KR_find_keyword (const char *KR_keyword, int KR_length) -{ - - switch (KR_length) - { - case 4: - if (strncmp (KR_keyword, "/dev", 4) == 0) - { -{ -return dev_storage + 0; - -} - } - else - { -{ -return NULL; - -} - } - case 8: - switch (KR_keyword [7]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdz", 8) == 0) - { -{ -return dev_storage + 217; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty", 8) == 0) - { -{ -return dev_storage + 2384; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdy", 8) == 0) - { -{ -return dev_storage + 216; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdx", 8) == 0) - { -{ -return dev_storage + 215; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdw", 8) == 0) - { -{ -return dev_storage + 214; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdv", 8) == 0) - { -{ -return dev_storage + 213; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdu", 8) == 0) - { -{ -return dev_storage + 212; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdt", 8) == 0) - { -{ -return dev_storage + 211; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sds", 8) == 0) - { -{ -return dev_storage + 210; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdr", 8) == 0) - { -{ -return dev_storage + 209; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdq", 8) == 0) - { -{ -return dev_storage + 208; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - switch (KR_keyword [5]) - { - case 's': - if (strncmp (KR_keyword, "/dev/sdp", 8) == 0) - { -{ -return dev_storage + 207; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/dsp", 8) == 0) - { -{ -return dev_storage + 21; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdo", 8) == 0) - { -{ -return dev_storage + 206; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdn", 8) == 0) - { -{ -return dev_storage + 205; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - switch (KR_keyword [5]) - { - case 's': - if (strncmp (KR_keyword, "/dev/sdm", 8) == 0) - { -{ -return dev_storage + 204; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/mem", 8) == 0) - { -{ -return dev_storage + 42; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdl", 8) == 0) - { -{ -return dev_storage + 203; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdk", 8) == 0) - { -{ -return dev_storage + 202; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdj", 8) == 0) - { -{ -return dev_storage + 201; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdi", 8) == 0) - { -{ -return dev_storage + 200; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdh", 8) == 0) - { -{ -return dev_storage + 199; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdg", 8) == 0) - { -{ -return dev_storage + 198; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdf", 8) == 0) - { -{ -return dev_storage + 197; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sde", 8) == 0) - { -{ -return dev_storage + 196; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdd", 8) == 0) - { -{ -return dev_storage + 195; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdc", 8) == 0) - { -{ -return dev_storage + 194; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdb", 8) == 0) - { -{ -return dev_storage + 193; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sda", 8) == 0) - { -{ -return dev_storage + 192; - -} - } - else - { -{ -return NULL; - -} - } - case '9': - switch (KR_keyword [6]) - { - case 't': - if (strncmp (KR_keyword, "/dev/st9", 8) == 0) - { -{ -return dev_storage + 2265; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sr9", 8) == 0) - { -{ -return dev_storage + 2249; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/fd9", 8) == 0) - { -{ -return dev_storage + 31; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '8': - switch (KR_keyword [6]) - { - case 't': - if (strncmp (KR_keyword, "/dev/st8", 8) == 0) - { -{ -return dev_storage + 2264; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sr8", 8) == 0) - { -{ -return dev_storage + 2248; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/fd8", 8) == 0) - { -{ -return dev_storage + 30; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '7': - switch (KR_keyword [6]) - { - case 't': - if (strncmp (KR_keyword, "/dev/st7", 8) == 0) - { -{ -return dev_storage + 2263; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sr7", 8) == 0) - { -{ -return dev_storage + 2247; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/fd7", 8) == 0) - { -{ -return dev_storage + 29; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '6': - switch (KR_keyword [6]) - { - case 't': - if (strncmp (KR_keyword, "/dev/st6", 8) == 0) - { -{ -return dev_storage + 2262; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sr6", 8) == 0) - { -{ -return dev_storage + 2246; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/fd6", 8) == 0) - { -{ -return dev_storage + 28; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '5': - switch (KR_keyword [6]) - { - case 't': - if (strncmp (KR_keyword, "/dev/st5", 8) == 0) - { -{ -return dev_storage + 2261; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sr5", 8) == 0) - { -{ -return dev_storage + 2245; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/fd5", 8) == 0) - { -{ -return dev_storage + 27; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '4': - switch (KR_keyword [6]) - { - case 't': - if (strncmp (KR_keyword, "/dev/st4", 8) == 0) - { -{ -return dev_storage + 2260; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sr4", 8) == 0) - { -{ -return dev_storage + 2244; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/fd4", 8) == 0) - { -{ -return dev_storage + 26; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '3': - switch (KR_keyword [6]) - { - case 't': - if (strncmp (KR_keyword, "/dev/st3", 8) == 0) - { -{ -return dev_storage + 2259; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sr3", 8) == 0) - { -{ -return dev_storage + 2243; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/fd3", 8) == 0) - { -{ -return dev_storage + 25; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '2': - switch (KR_keyword [6]) - { - case 't': - if (strncmp (KR_keyword, "/dev/st2", 8) == 0) - { -{ -return dev_storage + 2258; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sr2", 8) == 0) - { -{ -return dev_storage + 2242; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/fd2", 8) == 0) - { -{ -return dev_storage + 24; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [6]) - { - case 't': - if (strncmp (KR_keyword, "/dev/st1", 8) == 0) - { -{ -return dev_storage + 2257; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sr1", 8) == 0) - { -{ -return dev_storage + 2241; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/fd1", 8) == 0) - { -{ -return dev_storage + 23; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '0': - switch (KR_keyword [6]) - { - case 't': - if (strncmp (KR_keyword, "/dev/st0", 8) == 0) - { -{ -return dev_storage + 2256; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sr0", 8) == 0) - { -{ -return dev_storage + 2240; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/fd0", 8) == 0) - { -{ -return dev_storage + 22; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 9: - switch (KR_keyword [7]) - { - case 'z': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/sdz9", 9) == 0) - { -{ -return dev_storage + 601; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/sdz8", 9) == 0) - { -{ -return dev_storage + 600; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/sdz7", 9) == 0) - { -{ -return dev_storage + 599; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/sdz6", 9) == 0) - { -{ -return dev_storage + 598; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/sdz5", 9) == 0) - { -{ -return dev_storage + 597; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/sdz4", 9) == 0) - { -{ -return dev_storage + 596; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/sdz3", 9) == 0) - { -{ -return dev_storage + 595; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/sdz2", 9) == 0) - { -{ -return dev_storage + 594; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdz1", 9) == 0) - { -{ -return dev_storage + 593; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'y': - switch (KR_keyword [8]) - { - case 'm': - if (strncmp (KR_keyword, "/dev/ttym", 9) == 0) - { -{ -return dev_storage + 2513; - -} - } - else - { -{ -return NULL; - -} - } - case '9': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty9", 9) == 0) - { -{ -return dev_storage + 2394; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdy9", 9) == 0) - { -{ -return dev_storage + 586; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '8': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty8", 9) == 0) - { -{ -return dev_storage + 2393; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdy8", 9) == 0) - { -{ -return dev_storage + 585; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '7': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty7", 9) == 0) - { -{ -return dev_storage + 2392; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdy7", 9) == 0) - { -{ -return dev_storage + 584; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '6': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty6", 9) == 0) - { -{ -return dev_storage + 2391; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdy6", 9) == 0) - { -{ -return dev_storage + 583; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '5': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty5", 9) == 0) - { -{ -return dev_storage + 2390; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdy5", 9) == 0) - { -{ -return dev_storage + 582; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '4': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty4", 9) == 0) - { -{ -return dev_storage + 2389; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdy4", 9) == 0) - { -{ -return dev_storage + 581; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '3': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty3", 9) == 0) - { -{ -return dev_storage + 2388; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdy3", 9) == 0) - { -{ -return dev_storage + 580; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '2': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty2", 9) == 0) - { -{ -return dev_storage + 2387; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdy2", 9) == 0) - { -{ -return dev_storage + 579; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty1", 9) == 0) - { -{ -return dev_storage + 2386; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdy1", 9) == 0) - { -{ -return dev_storage + 578; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/tty0", 9) == 0) - { -{ -return dev_storage + 2385; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'x': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/sdx9", 9) == 0) - { -{ -return dev_storage + 571; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/sdx8", 9) == 0) - { -{ -return dev_storage + 570; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/sdx7", 9) == 0) - { -{ -return dev_storage + 569; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/sdx6", 9) == 0) - { -{ -return dev_storage + 568; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/sdx5", 9) == 0) - { -{ -return dev_storage + 567; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/sdx4", 9) == 0) - { -{ -return dev_storage + 566; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/sdx3", 9) == 0) - { -{ -return dev_storage + 565; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/sdx2", 9) == 0) - { -{ -return dev_storage + 564; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdx1", 9) == 0) - { -{ -return dev_storage + 563; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'w': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/sdw9", 9) == 0) - { -{ -return dev_storage + 556; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/sdw8", 9) == 0) - { -{ -return dev_storage + 555; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/sdw7", 9) == 0) - { -{ -return dev_storage + 554; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/sdw6", 9) == 0) - { -{ -return dev_storage + 553; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/sdw5", 9) == 0) - { -{ -return dev_storage + 552; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/sdw4", 9) == 0) - { -{ -return dev_storage + 551; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/sdw3", 9) == 0) - { -{ -return dev_storage + 550; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/sdw2", 9) == 0) - { -{ -return dev_storage + 549; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdw1", 9) == 0) - { -{ -return dev_storage + 548; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'v': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/sdv9", 9) == 0) - { -{ -return dev_storage + 541; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/sdv8", 9) == 0) - { -{ -return dev_storage + 540; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/sdv7", 9) == 0) - { -{ -return dev_storage + 539; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/sdv6", 9) == 0) - { -{ -return dev_storage + 538; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/sdv5", 9) == 0) - { -{ -return dev_storage + 537; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/sdv4", 9) == 0) - { -{ -return dev_storage + 536; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/sdv3", 9) == 0) - { -{ -return dev_storage + 535; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/sdv2", 9) == 0) - { -{ -return dev_storage + 534; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdv1", 9) == 0) - { -{ -return dev_storage + 533; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'u': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/sdu9", 9) == 0) - { -{ -return dev_storage + 526; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/sdu8", 9) == 0) - { -{ -return dev_storage + 525; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/sdu7", 9) == 0) - { -{ -return dev_storage + 524; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/sdu6", 9) == 0) - { -{ -return dev_storage + 523; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/sdu5", 9) == 0) - { -{ -return dev_storage + 522; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/sdu4", 9) == 0) - { -{ -return dev_storage + 521; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/sdu3", 9) == 0) - { -{ -return dev_storage + 520; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/sdu2", 9) == 0) - { -{ -return dev_storage + 519; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdu1", 9) == 0) - { -{ -return dev_storage + 518; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 't': - switch (KR_keyword [8]) - { - case '9': - switch (KR_keyword [5]) - { - case 's': - if (strncmp (KR_keyword, "/dev/sdt9", 9) == 0) - { -{ -return dev_storage + 511; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst9", 9) == 0) - { -{ -return dev_storage + 52; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '8': - switch (KR_keyword [5]) - { - case 's': - if (strncmp (KR_keyword, "/dev/sdt8", 9) == 0) - { -{ -return dev_storage + 510; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst8", 9) == 0) - { -{ -return dev_storage + 51; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '7': - switch (KR_keyword [5]) - { - case 's': - if (strncmp (KR_keyword, "/dev/sdt7", 9) == 0) - { -{ -return dev_storage + 509; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst7", 9) == 0) - { -{ -return dev_storage + 50; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '6': - switch (KR_keyword [5]) - { - case 's': - if (strncmp (KR_keyword, "/dev/sdt6", 9) == 0) - { -{ -return dev_storage + 508; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst6", 9) == 0) - { -{ -return dev_storage + 49; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '5': - switch (KR_keyword [5]) - { - case 's': - if (strncmp (KR_keyword, "/dev/sdt5", 9) == 0) - { -{ -return dev_storage + 507; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst5", 9) == 0) - { -{ -return dev_storage + 48; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '4': - switch (KR_keyword [5]) - { - case 's': - if (strncmp (KR_keyword, "/dev/sdt4", 9) == 0) - { -{ -return dev_storage + 506; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst4", 9) == 0) - { -{ -return dev_storage + 47; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '3': - switch (KR_keyword [5]) - { - case 's': - if (strncmp (KR_keyword, "/dev/sdt3", 9) == 0) - { -{ -return dev_storage + 505; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst3", 9) == 0) - { -{ -return dev_storage + 46; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '2': - switch (KR_keyword [5]) - { - case 's': - if (strncmp (KR_keyword, "/dev/sdt2", 9) == 0) - { -{ -return dev_storage + 504; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst2", 9) == 0) - { -{ -return dev_storage + 45; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [5]) - { - case 's': - if (strncmp (KR_keyword, "/dev/sdt1", 9) == 0) - { -{ -return dev_storage + 503; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst1", 9) == 0) - { -{ -return dev_storage + 44; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/nst0", 9) == 0) - { -{ -return dev_storage + 43; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 's': - switch (KR_keyword [8]) - { - case 'g': - if (strncmp (KR_keyword, "/dev/kmsg", 9) == 0) - { -{ -return dev_storage + 41; - -} - } - else - { -{ -return NULL; - -} - } - case '9': - if (strncmp (KR_keyword, "/dev/sds9", 9) == 0) - { -{ -return dev_storage + 496; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/sds8", 9) == 0) - { -{ -return dev_storage + 495; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/sds7", 9) == 0) - { -{ -return dev_storage + 494; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/sds6", 9) == 0) - { -{ -return dev_storage + 493; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/sds5", 9) == 0) - { -{ -return dev_storage + 492; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/sds4", 9) == 0) - { -{ -return dev_storage + 491; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/sds3", 9) == 0) - { -{ -return dev_storage + 490; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/sds2", 9) == 0) - { -{ -return dev_storage + 489; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sds1", 9) == 0) - { -{ -return dev_storage + 488; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'r': - switch (KR_keyword [8]) - { - case 't': - if (strncmp (KR_keyword, "/dev/port", 9) == 0) - { -{ -return dev_storage + 173; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/zero", 9) == 0) - { -{ -return dev_storage + 2516; - -} - } - else - { -{ -return NULL; - -} - } - case '9': - if (strncmp (KR_keyword, "/dev/sdr9", 9) == 0) - { -{ -return dev_storage + 481; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/sdr8", 9) == 0) - { -{ -return dev_storage + 480; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/sdr7", 9) == 0) - { -{ -return dev_storage + 479; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/sdr6", 9) == 0) - { -{ -return dev_storage + 478; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/sdr5", 9) == 0) - { -{ -return dev_storage + 477; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/sdr4", 9) == 0) - { -{ -return dev_storage + 476; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/sdr3", 9) == 0) - { -{ -return dev_storage + 475; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/sdr2", 9) == 0) - { -{ -return dev_storage + 474; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdr1", 9) == 0) - { -{ -return dev_storage + 473; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'q': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/sdq9", 9) == 0) - { -{ -return dev_storage + 466; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/sdq8", 9) == 0) - { -{ -return dev_storage + 465; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/sdq7", 9) == 0) - { -{ -return dev_storage + 464; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/sdq6", 9) == 0) - { -{ -return dev_storage + 463; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/sdq5", 9) == 0) - { -{ -return dev_storage + 462; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/sdq4", 9) == 0) - { -{ -return dev_storage + 461; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/sdq3", 9) == 0) - { -{ -return dev_storage + 460; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/sdq2", 9) == 0) - { -{ -return dev_storage + 459; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdq1", 9) == 0) - { -{ -return dev_storage + 458; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'p': - switch (KR_keyword [8]) - { - case 'e': - if (strncmp (KR_keyword, "/dev/pipe", 9) == 0) - { -{ -return dev_storage + 172; - -} - } - else - { -{ -return NULL; - -} - } - case '9': - if (strncmp (KR_keyword, "/dev/sdp9", 9) == 0) - { -{ -return dev_storage + 451; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/sdp8", 9) == 0) - { -{ -return dev_storage + 450; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/sdp7", 9) == 0) - { -{ -return dev_storage + 449; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/sdp6", 9) == 0) - { -{ -return dev_storage + 448; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/sdp5", 9) == 0) - { -{ -return dev_storage + 447; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/sdp4", 9) == 0) - { -{ -return dev_storage + 446; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/sdp3", 9) == 0) - { -{ -return dev_storage + 445; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/sdp2", 9) == 0) - { -{ -return dev_storage + 444; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdp1", 9) == 0) - { -{ -return dev_storage + 443; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'o': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/sdo9", 9) == 0) - { -{ -return dev_storage + 436; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/sdo8", 9) == 0) - { -{ -return dev_storage + 435; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/sdo7", 9) == 0) - { -{ -return dev_storage + 434; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/sdo6", 9) == 0) - { -{ -return dev_storage + 433; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/sdo5", 9) == 0) - { -{ -return dev_storage + 432; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/sdo4", 9) == 0) - { -{ -return dev_storage + 431; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/sdo3", 9) == 0) - { -{ -return dev_storage + 430; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/sdo2", 9) == 0) - { -{ -return dev_storage + 429; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdo1", 9) == 0) - { -{ -return dev_storage + 428; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'n': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/sdn9", 9) == 0) - { -{ -return dev_storage + 421; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/sdn8", 9) == 0) - { -{ -return dev_storage + 420; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/sdn7", 9) == 0) - { -{ -return dev_storage + 419; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/sdn6", 9) == 0) - { -{ -return dev_storage + 418; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/sdn5", 9) == 0) - { -{ -return dev_storage + 417; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/sdn4", 9) == 0) - { -{ -return dev_storage + 416; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/sdn3", 9) == 0) - { -{ -return dev_storage + 415; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/sdn2", 9) == 0) - { -{ -return dev_storage + 414; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdn1", 9) == 0) - { -{ -return dev_storage + 413; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'm': - switch (KR_keyword [5]) - { - case 's': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/sdm9", 9) == 0) - { -{ -return dev_storage + 406; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/sdm8", 9) == 0) - { -{ -return dev_storage + 405; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/sdm7", 9) == 0) - { -{ -return dev_storage + 404; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/sdm6", 9) == 0) - { -{ -return dev_storage + 403; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/sdm5", 9) == 0) - { -{ -return dev_storage + 402; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/sdm4", 9) == 0) - { -{ -return dev_storage + 401; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/sdm3", 9) == 0) - { -{ -return dev_storage + 400; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/sdm2", 9) == 0) - { -{ -return dev_storage + 399; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdm1", 9) == 0) - { -{ -return dev_storage + 398; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/ptmx", 9) == 0) - { -{ -return dev_storage + 174; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/com9", 9) == 0) - { -{ -return dev_storage + 10; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/com8", 9) == 0) - { -{ -return dev_storage + 9; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/com7", 9) == 0) - { -{ -return dev_storage + 8; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/com6", 9) == 0) - { -{ -return dev_storage + 7; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/com5", 9) == 0) - { -{ -return dev_storage + 6; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/com4", 9) == 0) - { -{ -return dev_storage + 5; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/com3", 9) == 0) - { -{ -return dev_storage + 4; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/com2", 9) == 0) - { -{ -return dev_storage + 3; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/com1", 9) == 0) - { -{ -return dev_storage + 2; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'l': - switch (KR_keyword [8]) - { - case 'l': - switch (KR_keyword [5]) - { - case 'n': - if (strncmp (KR_keyword, "/dev/null", 9) == 0) - { -{ -return dev_storage + 171; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/full", 9) == 0) - { -{ -return dev_storage + 39; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '9': - if (strncmp (KR_keyword, "/dev/sdl9", 9) == 0) - { -{ -return dev_storage + 391; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/sdl8", 9) == 0) - { -{ -return dev_storage + 390; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/sdl7", 9) == 0) - { -{ -return dev_storage + 389; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/sdl6", 9) == 0) - { -{ -return dev_storage + 388; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/sdl5", 9) == 0) - { -{ -return dev_storage + 387; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/sdl4", 9) == 0) - { -{ -return dev_storage + 386; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/sdl3", 9) == 0) - { -{ -return dev_storage + 385; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/sdl2", 9) == 0) - { -{ -return dev_storage + 384; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdl1", 9) == 0) - { -{ -return dev_storage + 383; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'k': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/sdk9", 9) == 0) - { -{ -return dev_storage + 376; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/sdk8", 9) == 0) - { -{ -return dev_storage + 375; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/sdk7", 9) == 0) - { -{ -return dev_storage + 374; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/sdk6", 9) == 0) - { -{ -return dev_storage + 373; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/sdk5", 9) == 0) - { -{ -return dev_storage + 372; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/sdk4", 9) == 0) - { -{ -return dev_storage + 371; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/sdk3", 9) == 0) - { -{ -return dev_storage + 370; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/sdk2", 9) == 0) - { -{ -return dev_storage + 369; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdk1", 9) == 0) - { -{ -return dev_storage + 368; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'j': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/sdj9", 9) == 0) - { -{ -return dev_storage + 361; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/sdj8", 9) == 0) - { -{ -return dev_storage + 360; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/sdj7", 9) == 0) - { -{ -return dev_storage + 359; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/sdj6", 9) == 0) - { -{ -return dev_storage + 358; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/sdj5", 9) == 0) - { -{ -return dev_storage + 357; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/sdj4", 9) == 0) - { -{ -return dev_storage + 356; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/sdj3", 9) == 0) - { -{ -return dev_storage + 355; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/sdj2", 9) == 0) - { -{ -return dev_storage + 354; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdj1", 9) == 0) - { -{ -return dev_storage + 353; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'i': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/sdi9", 9) == 0) - { -{ -return dev_storage + 346; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/sdi8", 9) == 0) - { -{ -return dev_storage + 345; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/sdi7", 9) == 0) - { -{ -return dev_storage + 344; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/sdi6", 9) == 0) - { -{ -return dev_storage + 343; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/sdi5", 9) == 0) - { -{ -return dev_storage + 342; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/sdi4", 9) == 0) - { -{ -return dev_storage + 341; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/sdi3", 9) == 0) - { -{ -return dev_storage + 340; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/sdi2", 9) == 0) - { -{ -return dev_storage + 339; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdi1", 9) == 0) - { -{ -return dev_storage + 338; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'h': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/sdh9", 9) == 0) - { -{ -return dev_storage + 331; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/sdh8", 9) == 0) - { -{ -return dev_storage + 330; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/sdh7", 9) == 0) - { -{ -return dev_storage + 329; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/sdh6", 9) == 0) - { -{ -return dev_storage + 328; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/sdh5", 9) == 0) - { -{ -return dev_storage + 327; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/sdh4", 9) == 0) - { -{ -return dev_storage + 326; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/sdh3", 9) == 0) - { -{ -return dev_storage + 325; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/sdh2", 9) == 0) - { -{ -return dev_storage + 324; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdh1", 9) == 0) - { -{ -return dev_storage + 323; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'g': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/sdg9", 9) == 0) - { -{ -return dev_storage + 316; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/sdg8", 9) == 0) - { -{ -return dev_storage + 315; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/sdg7", 9) == 0) - { -{ -return dev_storage + 314; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/sdg6", 9) == 0) - { -{ -return dev_storage + 313; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/sdg5", 9) == 0) - { -{ -return dev_storage + 312; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/sdg4", 9) == 0) - { -{ -return dev_storage + 311; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/sdg3", 9) == 0) - { -{ -return dev_storage + 310; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/sdg2", 9) == 0) - { -{ -return dev_storage + 309; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdg1", 9) == 0) - { -{ -return dev_storage + 308; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'f': - switch (KR_keyword [8]) - { - case 'o': - if (strncmp (KR_keyword, "/dev/fifo", 9) == 0) - { -{ -return dev_storage + 38; - -} - } - else - { -{ -return NULL; - -} - } - case '9': - if (strncmp (KR_keyword, "/dev/sdf9", 9) == 0) - { -{ -return dev_storage + 301; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/sdf8", 9) == 0) - { -{ -return dev_storage + 300; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/sdf7", 9) == 0) - { -{ -return dev_storage + 299; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/sdf6", 9) == 0) - { -{ -return dev_storage + 298; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/sdf5", 9) == 0) - { -{ -return dev_storage + 297; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/sdf4", 9) == 0) - { -{ -return dev_storage + 296; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/sdf3", 9) == 0) - { -{ -return dev_storage + 295; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/sdf2", 9) == 0) - { -{ -return dev_storage + 294; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdf1", 9) == 0) - { -{ -return dev_storage + 293; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'e': - switch (KR_keyword [8]) - { - case 'm': - if (strncmp (KR_keyword, "/dev/kmem", 9) == 0) - { -{ -return dev_storage + 40; - -} - } - else - { -{ -return NULL; - -} - } - case '9': - if (strncmp (KR_keyword, "/dev/sde9", 9) == 0) - { -{ -return dev_storage + 286; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/sde8", 9) == 0) - { -{ -return dev_storage + 285; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/sde7", 9) == 0) - { -{ -return dev_storage + 284; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/sde6", 9) == 0) - { -{ -return dev_storage + 283; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/sde5", 9) == 0) - { -{ -return dev_storage + 282; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/sde4", 9) == 0) - { -{ -return dev_storage + 281; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/sde3", 9) == 0) - { -{ -return dev_storage + 280; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/sde2", 9) == 0) - { -{ -return dev_storage + 279; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sde1", 9) == 0) - { -{ -return dev_storage + 278; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'd': - switch (KR_keyword [8]) - { - case 'x': - if (strncmp (KR_keyword, "/dev/sddx", 9) == 0) - { -{ -return dev_storage + 1879; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sddw", 9) == 0) - { -{ -return dev_storage + 1878; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sddv", 9) == 0) - { -{ -return dev_storage + 1877; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sddu", 9) == 0) - { -{ -return dev_storage + 1876; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sddt", 9) == 0) - { -{ -return dev_storage + 1875; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdds", 9) == 0) - { -{ -return dev_storage + 1874; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sddr", 9) == 0) - { -{ -return dev_storage + 1873; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sddq", 9) == 0) - { -{ -return dev_storage + 1872; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sddp", 9) == 0) - { -{ -return dev_storage + 1871; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sddo", 9) == 0) - { -{ -return dev_storage + 1870; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sddn", 9) == 0) - { -{ -return dev_storage + 1869; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sddm", 9) == 0) - { -{ -return dev_storage + 1868; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sddl", 9) == 0) - { -{ -return dev_storage + 1867; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sddk", 9) == 0) - { -{ -return dev_storage + 1866; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sddj", 9) == 0) - { -{ -return dev_storage + 1865; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sddi", 9) == 0) - { -{ -return dev_storage + 1864; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sddh", 9) == 0) - { -{ -return dev_storage + 1863; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sddg", 9) == 0) - { -{ -return dev_storage + 1862; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sddf", 9) == 0) - { -{ -return dev_storage + 1861; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdde", 9) == 0) - { -{ -return dev_storage + 1860; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sddd", 9) == 0) - { -{ -return dev_storage + 1859; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sddc", 9) == 0) - { -{ -return dev_storage + 1858; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sddb", 9) == 0) - { -{ -return dev_storage + 1857; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdda", 9) == 0) - { -{ -return dev_storage + 1856; - -} - } - else - { -{ -return NULL; - -} - } - case '9': - switch (KR_keyword [6]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdd9", 9) == 0) - { -{ -return dev_storage + 271; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/scd9", 9) == 0) - { -{ -return dev_storage + 185; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '8': - switch (KR_keyword [6]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdd8", 9) == 0) - { -{ -return dev_storage + 270; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/scd8", 9) == 0) - { -{ -return dev_storage + 184; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '7': - switch (KR_keyword [6]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdd7", 9) == 0) - { -{ -return dev_storage + 269; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/scd7", 9) == 0) - { -{ -return dev_storage + 183; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '6': - switch (KR_keyword [6]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdd6", 9) == 0) - { -{ -return dev_storage + 268; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/scd6", 9) == 0) - { -{ -return dev_storage + 182; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '5': - switch (KR_keyword [6]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdd5", 9) == 0) - { -{ -return dev_storage + 267; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/scd5", 9) == 0) - { -{ -return dev_storage + 181; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '4': - switch (KR_keyword [6]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdd4", 9) == 0) - { -{ -return dev_storage + 266; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/scd4", 9) == 0) - { -{ -return dev_storage + 180; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '3': - switch (KR_keyword [6]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdd3", 9) == 0) - { -{ -return dev_storage + 265; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/scd3", 9) == 0) - { -{ -return dev_storage + 179; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '2': - switch (KR_keyword [6]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdd2", 9) == 0) - { -{ -return dev_storage + 264; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/scd2", 9) == 0) - { -{ -return dev_storage + 178; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [6]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdd1", 9) == 0) - { -{ -return dev_storage + 263; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/scd1", 9) == 0) - { -{ -return dev_storage + 177; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/scd0", 9) == 0) - { -{ -return dev_storage + 176; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'c': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdcz", 9) == 0) - { -{ -return dev_storage + 1465; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdcy", 9) == 0) - { -{ -return dev_storage + 1464; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdcx", 9) == 0) - { -{ -return dev_storage + 1463; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdcw", 9) == 0) - { -{ -return dev_storage + 1462; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdcv", 9) == 0) - { -{ -return dev_storage + 1461; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdcu", 9) == 0) - { -{ -return dev_storage + 1460; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdct", 9) == 0) - { -{ -return dev_storage + 1459; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdcs", 9) == 0) - { -{ -return dev_storage + 1458; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdcr", 9) == 0) - { -{ -return dev_storage + 1457; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdcq", 9) == 0) - { -{ -return dev_storage + 1456; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdcp", 9) == 0) - { -{ -return dev_storage + 1455; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdco", 9) == 0) - { -{ -return dev_storage + 1454; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdcn", 9) == 0) - { -{ -return dev_storage + 1453; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdcm", 9) == 0) - { -{ -return dev_storage + 1452; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdcl", 9) == 0) - { -{ -return dev_storage + 1451; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdck", 9) == 0) - { -{ -return dev_storage + 1450; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdcj", 9) == 0) - { -{ -return dev_storage + 1449; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdci", 9) == 0) - { -{ -return dev_storage + 1448; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdch", 9) == 0) - { -{ -return dev_storage + 1447; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdcg", 9) == 0) - { -{ -return dev_storage + 1446; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdcf", 9) == 0) - { -{ -return dev_storage + 1445; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdce", 9) == 0) - { -{ -return dev_storage + 1444; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdcd", 9) == 0) - { -{ -return dev_storage + 1443; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcc", 9) == 0) - { -{ -return dev_storage + 1442; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdcb", 9) == 0) - { -{ -return dev_storage + 1441; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdca", 9) == 0) - { -{ -return dev_storage + 1440; - -} - } - else - { -{ -return NULL; - -} - } - case '9': - if (strncmp (KR_keyword, "/dev/sdc9", 9) == 0) - { -{ -return dev_storage + 256; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/sdc8", 9) == 0) - { -{ -return dev_storage + 255; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/sdc7", 9) == 0) - { -{ -return dev_storage + 254; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/sdc6", 9) == 0) - { -{ -return dev_storage + 253; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/sdc5", 9) == 0) - { -{ -return dev_storage + 252; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/sdc4", 9) == 0) - { -{ -return dev_storage + 251; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/sdc3", 9) == 0) - { -{ -return dev_storage + 250; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/sdc2", 9) == 0) - { -{ -return dev_storage + 249; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdc1", 9) == 0) - { -{ -return dev_storage + 248; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'b': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdbz", 9) == 0) - { -{ -return dev_storage + 1049; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdby", 9) == 0) - { -{ -return dev_storage + 1048; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdbx", 9) == 0) - { -{ -return dev_storage + 1047; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdbw", 9) == 0) - { -{ -return dev_storage + 1046; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdbv", 9) == 0) - { -{ -return dev_storage + 1045; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdbu", 9) == 0) - { -{ -return dev_storage + 1044; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdbt", 9) == 0) - { -{ -return dev_storage + 1043; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdbs", 9) == 0) - { -{ -return dev_storage + 1042; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdbr", 9) == 0) - { -{ -return dev_storage + 1041; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdbq", 9) == 0) - { -{ -return dev_storage + 1040; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdbp", 9) == 0) - { -{ -return dev_storage + 1039; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdbo", 9) == 0) - { -{ -return dev_storage + 1038; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdbn", 9) == 0) - { -{ -return dev_storage + 1037; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdbm", 9) == 0) - { -{ -return dev_storage + 1036; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdbl", 9) == 0) - { -{ -return dev_storage + 1035; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdbk", 9) == 0) - { -{ -return dev_storage + 1034; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdbj", 9) == 0) - { -{ -return dev_storage + 1033; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdbi", 9) == 0) - { -{ -return dev_storage + 1032; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdbh", 9) == 0) - { -{ -return dev_storage + 1031; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdbg", 9) == 0) - { -{ -return dev_storage + 1030; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdbf", 9) == 0) - { -{ -return dev_storage + 1029; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdbe", 9) == 0) - { -{ -return dev_storage + 1028; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdbd", 9) == 0) - { -{ -return dev_storage + 1027; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdbc", 9) == 0) - { -{ -return dev_storage + 1026; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbb", 9) == 0) - { -{ -return dev_storage + 1025; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdba", 9) == 0) - { -{ -return dev_storage + 1024; - -} - } - else - { -{ -return NULL; - -} - } - case '9': - if (strncmp (KR_keyword, "/dev/sdb9", 9) == 0) - { -{ -return dev_storage + 241; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/sdb8", 9) == 0) - { -{ -return dev_storage + 240; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/sdb7", 9) == 0) - { -{ -return dev_storage + 239; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/sdb6", 9) == 0) - { -{ -return dev_storage + 238; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/sdb5", 9) == 0) - { -{ -return dev_storage + 237; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/sdb4", 9) == 0) - { -{ -return dev_storage + 236; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/sdb3", 9) == 0) - { -{ -return dev_storage + 235; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/sdb2", 9) == 0) - { -{ -return dev_storage + 234; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdb1", 9) == 0) - { -{ -return dev_storage + 233; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'a': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdaz", 9) == 0) - { -{ -return dev_storage + 633; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sday", 9) == 0) - { -{ -return dev_storage + 632; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdax", 9) == 0) - { -{ -return dev_storage + 631; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdaw", 9) == 0) - { -{ -return dev_storage + 630; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdav", 9) == 0) - { -{ -return dev_storage + 629; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdau", 9) == 0) - { -{ -return dev_storage + 628; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdat", 9) == 0) - { -{ -return dev_storage + 627; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdas", 9) == 0) - { -{ -return dev_storage + 626; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdar", 9) == 0) - { -{ -return dev_storage + 625; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdaq", 9) == 0) - { -{ -return dev_storage + 624; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdap", 9) == 0) - { -{ -return dev_storage + 623; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdao", 9) == 0) - { -{ -return dev_storage + 622; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdan", 9) == 0) - { -{ -return dev_storage + 621; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdam", 9) == 0) - { -{ -return dev_storage + 620; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdal", 9) == 0) - { -{ -return dev_storage + 619; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdak", 9) == 0) - { -{ -return dev_storage + 618; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdaj", 9) == 0) - { -{ -return dev_storage + 617; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdai", 9) == 0) - { -{ -return dev_storage + 616; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdah", 9) == 0) - { -{ -return dev_storage + 615; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdag", 9) == 0) - { -{ -return dev_storage + 614; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdaf", 9) == 0) - { -{ -return dev_storage + 613; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdae", 9) == 0) - { -{ -return dev_storage + 612; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdad", 9) == 0) - { -{ -return dev_storage + 611; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdac", 9) == 0) - { -{ -return dev_storage + 610; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdab", 9) == 0) - { -{ -return dev_storage + 609; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaa", 9) == 0) - { -{ -return dev_storage + 608; - -} - } - else - { -{ -return NULL; - -} - } - case '9': - if (strncmp (KR_keyword, "/dev/sda9", 9) == 0) - { -{ -return dev_storage + 226; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/sda8", 9) == 0) - { -{ -return dev_storage + 225; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/sda7", 9) == 0) - { -{ -return dev_storage + 224; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/sda6", 9) == 0) - { -{ -return dev_storage + 223; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/sda5", 9) == 0) - { -{ -return dev_storage + 222; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/sda4", 9) == 0) - { -{ -return dev_storage + 221; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/sda3", 9) == 0) - { -{ -return dev_storage + 220; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/sda2", 9) == 0) - { -{ -return dev_storage + 219; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sda1", 9) == 0) - { -{ -return dev_storage + 218; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '9': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/st99", 9) == 0) - { -{ -return dev_storage + 2355; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/st98", 9) == 0) - { -{ -return dev_storage + 2354; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/st97", 9) == 0) - { -{ -return dev_storage + 2353; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/st96", 9) == 0) - { -{ -return dev_storage + 2352; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/st95", 9) == 0) - { -{ -return dev_storage + 2351; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/st94", 9) == 0) - { -{ -return dev_storage + 2350; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/st93", 9) == 0) - { -{ -return dev_storage + 2349; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/st92", 9) == 0) - { -{ -return dev_storage + 2348; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/st91", 9) == 0) - { -{ -return dev_storage + 2347; - -} - } - else - { -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/st90", 9) == 0) - { -{ -return dev_storage + 2346; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '8': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/st89", 9) == 0) - { -{ -return dev_storage + 2345; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/st88", 9) == 0) - { -{ -return dev_storage + 2344; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/st87", 9) == 0) - { -{ -return dev_storage + 2343; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/st86", 9) == 0) - { -{ -return dev_storage + 2342; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/st85", 9) == 0) - { -{ -return dev_storage + 2341; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/st84", 9) == 0) - { -{ -return dev_storage + 2340; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/st83", 9) == 0) - { -{ -return dev_storage + 2339; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/st82", 9) == 0) - { -{ -return dev_storage + 2338; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/st81", 9) == 0) - { -{ -return dev_storage + 2337; - -} - } - else - { -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/st80", 9) == 0) - { -{ -return dev_storage + 2336; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '7': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/st79", 9) == 0) - { -{ -return dev_storage + 2335; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/st78", 9) == 0) - { -{ -return dev_storage + 2334; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/st77", 9) == 0) - { -{ -return dev_storage + 2333; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/st76", 9) == 0) - { -{ -return dev_storage + 2332; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/st75", 9) == 0) - { -{ -return dev_storage + 2331; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/st74", 9) == 0) - { -{ -return dev_storage + 2330; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/st73", 9) == 0) - { -{ -return dev_storage + 2329; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/st72", 9) == 0) - { -{ -return dev_storage + 2328; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/st71", 9) == 0) - { -{ -return dev_storage + 2327; - -} - } - else - { -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/st70", 9) == 0) - { -{ -return dev_storage + 2326; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '6': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/st69", 9) == 0) - { -{ -return dev_storage + 2325; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/st68", 9) == 0) - { -{ -return dev_storage + 2324; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/st67", 9) == 0) - { -{ -return dev_storage + 2323; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/st66", 9) == 0) - { -{ -return dev_storage + 2322; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/st65", 9) == 0) - { -{ -return dev_storage + 2321; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/st64", 9) == 0) - { -{ -return dev_storage + 2320; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/st63", 9) == 0) - { -{ -return dev_storage + 2319; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/st62", 9) == 0) - { -{ -return dev_storage + 2318; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/st61", 9) == 0) - { -{ -return dev_storage + 2317; - -} - } - else - { -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/st60", 9) == 0) - { -{ -return dev_storage + 2316; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '5': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/st59", 9) == 0) - { -{ -return dev_storage + 2315; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/st58", 9) == 0) - { -{ -return dev_storage + 2314; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/st57", 9) == 0) - { -{ -return dev_storage + 2313; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/st56", 9) == 0) - { -{ -return dev_storage + 2312; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/st55", 9) == 0) - { -{ -return dev_storage + 2311; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/st54", 9) == 0) - { -{ -return dev_storage + 2310; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/st53", 9) == 0) - { -{ -return dev_storage + 2309; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/st52", 9) == 0) - { -{ -return dev_storage + 2308; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/st51", 9) == 0) - { -{ -return dev_storage + 2307; - -} - } - else - { -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/st50", 9) == 0) - { -{ -return dev_storage + 2306; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '4': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/st49", 9) == 0) - { -{ -return dev_storage + 2305; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/st48", 9) == 0) - { -{ -return dev_storage + 2304; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/st47", 9) == 0) - { -{ -return dev_storage + 2303; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/st46", 9) == 0) - { -{ -return dev_storage + 2302; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/st45", 9) == 0) - { -{ -return dev_storage + 2301; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/st44", 9) == 0) - { -{ -return dev_storage + 2300; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/st43", 9) == 0) - { -{ -return dev_storage + 2299; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/st42", 9) == 0) - { -{ -return dev_storage + 2298; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/st41", 9) == 0) - { -{ -return dev_storage + 2297; - -} - } - else - { -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/st40", 9) == 0) - { -{ -return dev_storage + 2296; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '3': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/st39", 9) == 0) - { -{ -return dev_storage + 2295; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/st38", 9) == 0) - { -{ -return dev_storage + 2294; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/st37", 9) == 0) - { -{ -return dev_storage + 2293; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/st36", 9) == 0) - { -{ -return dev_storage + 2292; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/st35", 9) == 0) - { -{ -return dev_storage + 2291; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/st34", 9) == 0) - { -{ -return dev_storage + 2290; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/st33", 9) == 0) - { -{ -return dev_storage + 2289; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/st32", 9) == 0) - { -{ -return dev_storage + 2288; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/st31", 9) == 0) - { -{ -return dev_storage + 2287; - -} - } - else - { -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/st30", 9) == 0) - { -{ -return dev_storage + 2286; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '2': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/st29", 9) == 0) - { -{ -return dev_storage + 2285; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/st28", 9) == 0) - { -{ -return dev_storage + 2284; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/st27", 9) == 0) - { -{ -return dev_storage + 2283; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/st26", 9) == 0) - { -{ -return dev_storage + 2282; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/st25", 9) == 0) - { -{ -return dev_storage + 2281; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/st24", 9) == 0) - { -{ -return dev_storage + 2280; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/st23", 9) == 0) - { -{ -return dev_storage + 2279; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/st22", 9) == 0) - { -{ -return dev_storage + 2278; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/st21", 9) == 0) - { -{ -return dev_storage + 2277; - -} - } - else - { -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/st20", 9) == 0) - { -{ -return dev_storage + 2276; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/st19", 9) == 0) - { -{ -return dev_storage + 2275; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/st18", 9) == 0) - { -{ -return dev_storage + 2274; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/st17", 9) == 0) - { -{ -return dev_storage + 2273; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/st16", 9) == 0) - { -{ -return dev_storage + 2272; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - switch (KR_keyword [6]) - { - case 't': - if (strncmp (KR_keyword, "/dev/st15", 9) == 0) - { -{ -return dev_storage + 2271; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sr15", 9) == 0) - { -{ -return dev_storage + 2255; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/fd15", 9) == 0) - { -{ -return dev_storage + 37; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '4': - switch (KR_keyword [6]) - { - case 't': - if (strncmp (KR_keyword, "/dev/st14", 9) == 0) - { -{ -return dev_storage + 2270; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sr14", 9) == 0) - { -{ -return dev_storage + 2254; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/fd14", 9) == 0) - { -{ -return dev_storage + 36; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '3': - switch (KR_keyword [6]) - { - case 't': - if (strncmp (KR_keyword, "/dev/st13", 9) == 0) - { -{ -return dev_storage + 2269; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sr13", 9) == 0) - { -{ -return dev_storage + 2253; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/fd13", 9) == 0) - { -{ -return dev_storage + 35; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '2': - switch (KR_keyword [6]) - { - case 't': - if (strncmp (KR_keyword, "/dev/st12", 9) == 0) - { -{ -return dev_storage + 2268; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sr12", 9) == 0) - { -{ -return dev_storage + 2252; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/fd12", 9) == 0) - { -{ -return dev_storage + 34; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [6]) - { - case 't': - if (strncmp (KR_keyword, "/dev/st11", 9) == 0) - { -{ -return dev_storage + 2267; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sr11", 9) == 0) - { -{ -return dev_storage + 2251; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/fd11", 9) == 0) - { -{ -return dev_storage + 33; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '0': - switch (KR_keyword [6]) - { - case 't': - if (strncmp (KR_keyword, "/dev/st10", 9) == 0) - { -{ -return dev_storage + 2266; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sr10", 9) == 0) - { -{ -return dev_storage + 2250; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/fd10", 9) == 0) - { -{ -return dev_storage + 32; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 10: - switch (KR_keyword [9]) - { - case 'n': - if (strncmp (KR_keyword, "/dev/conin", 10) == 0) - { -{ -return dev_storage + 18; - -} - } - else - { -{ -return NULL; - -} - } - case '9': - switch (KR_keyword [8]) - { - case 'z': - switch (KR_keyword [7]) - { - case 'c': - if (strncmp (KR_keyword, "/dev/sdcz9", 10) == 0) - { -{ -return dev_storage + 1849; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbz9", 10) == 0) - { -{ -return dev_storage + 1433; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaz9", 10) == 0) - { -{ -return dev_storage + 1017; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'y': - switch (KR_keyword [7]) - { - case 'c': - if (strncmp (KR_keyword, "/dev/sdcy9", 10) == 0) - { -{ -return dev_storage + 1834; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdby9", 10) == 0) - { -{ -return dev_storage + 1418; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sday9", 10) == 0) - { -{ -return dev_storage + 1002; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'x': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddx9", 10) == 0) - { -{ -return dev_storage + 2233; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcx9", 10) == 0) - { -{ -return dev_storage + 1819; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbx9", 10) == 0) - { -{ -return dev_storage + 1403; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdax9", 10) == 0) - { -{ -return dev_storage + 987; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'w': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddw9", 10) == 0) - { -{ -return dev_storage + 2218; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcw9", 10) == 0) - { -{ -return dev_storage + 1804; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbw9", 10) == 0) - { -{ -return dev_storage + 1388; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaw9", 10) == 0) - { -{ -return dev_storage + 972; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'v': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddv9", 10) == 0) - { -{ -return dev_storage + 2203; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcv9", 10) == 0) - { -{ -return dev_storage + 1789; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbv9", 10) == 0) - { -{ -return dev_storage + 1373; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdav9", 10) == 0) - { -{ -return dev_storage + 957; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'u': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddu9", 10) == 0) - { -{ -return dev_storage + 2188; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcu9", 10) == 0) - { -{ -return dev_storage + 1774; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbu9", 10) == 0) - { -{ -return dev_storage + 1358; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdau9", 10) == 0) - { -{ -return dev_storage + 942; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 't': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddt9", 10) == 0) - { -{ -return dev_storage + 2173; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdct9", 10) == 0) - { -{ -return dev_storage + 1759; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbt9", 10) == 0) - { -{ -return dev_storage + 1343; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdat9", 10) == 0) - { -{ -return dev_storage + 927; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 's': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdds9", 10) == 0) - { -{ -return dev_storage + 2158; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcs9", 10) == 0) - { -{ -return dev_storage + 1744; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbs9", 10) == 0) - { -{ -return dev_storage + 1328; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdas9", 10) == 0) - { -{ -return dev_storage + 912; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'r': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddr9", 10) == 0) - { -{ -return dev_storage + 2143; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcr9", 10) == 0) - { -{ -return dev_storage + 1729; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbr9", 10) == 0) - { -{ -return dev_storage + 1313; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdar9", 10) == 0) - { -{ -return dev_storage + 897; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'q': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddq9", 10) == 0) - { -{ -return dev_storage + 2128; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcq9", 10) == 0) - { -{ -return dev_storage + 1714; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbq9", 10) == 0) - { -{ -return dev_storage + 1298; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaq9", 10) == 0) - { -{ -return dev_storage + 882; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'p': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddp9", 10) == 0) - { -{ -return dev_storage + 2113; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcp9", 10) == 0) - { -{ -return dev_storage + 1699; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbp9", 10) == 0) - { -{ -return dev_storage + 1283; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdap9", 10) == 0) - { -{ -return dev_storage + 867; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'o': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddo9", 10) == 0) - { -{ -return dev_storage + 2098; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdco9", 10) == 0) - { -{ -return dev_storage + 1684; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbo9", 10) == 0) - { -{ -return dev_storage + 1268; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdao9", 10) == 0) - { -{ -return dev_storage + 852; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'n': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddn9", 10) == 0) - { -{ -return dev_storage + 2083; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcn9", 10) == 0) - { -{ -return dev_storage + 1669; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbn9", 10) == 0) - { -{ -return dev_storage + 1253; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdan9", 10) == 0) - { -{ -return dev_storage + 837; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'm': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddm9", 10) == 0) - { -{ -return dev_storage + 2068; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcm9", 10) == 0) - { -{ -return dev_storage + 1654; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbm9", 10) == 0) - { -{ -return dev_storage + 1238; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdam9", 10) == 0) - { -{ -return dev_storage + 822; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'l': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddl9", 10) == 0) - { -{ -return dev_storage + 2053; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcl9", 10) == 0) - { -{ -return dev_storage + 1639; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbl9", 10) == 0) - { -{ -return dev_storage + 1223; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdal9", 10) == 0) - { -{ -return dev_storage + 807; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'k': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddk9", 10) == 0) - { -{ -return dev_storage + 2038; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdck9", 10) == 0) - { -{ -return dev_storage + 1624; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbk9", 10) == 0) - { -{ -return dev_storage + 1208; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdak9", 10) == 0) - { -{ -return dev_storage + 792; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'j': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddj9", 10) == 0) - { -{ -return dev_storage + 2023; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcj9", 10) == 0) - { -{ -return dev_storage + 1609; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbj9", 10) == 0) - { -{ -return dev_storage + 1193; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaj9", 10) == 0) - { -{ -return dev_storage + 777; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'i': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddi9", 10) == 0) - { -{ -return dev_storage + 2008; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdci9", 10) == 0) - { -{ -return dev_storage + 1594; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbi9", 10) == 0) - { -{ -return dev_storage + 1178; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdai9", 10) == 0) - { -{ -return dev_storage + 762; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'h': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddh9", 10) == 0) - { -{ -return dev_storage + 1993; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdch9", 10) == 0) - { -{ -return dev_storage + 1579; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbh9", 10) == 0) - { -{ -return dev_storage + 1163; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdah9", 10) == 0) - { -{ -return dev_storage + 747; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'g': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddg9", 10) == 0) - { -{ -return dev_storage + 1978; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcg9", 10) == 0) - { -{ -return dev_storage + 1564; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbg9", 10) == 0) - { -{ -return dev_storage + 1148; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdag9", 10) == 0) - { -{ -return dev_storage + 732; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'f': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddf9", 10) == 0) - { -{ -return dev_storage + 1963; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcf9", 10) == 0) - { -{ -return dev_storage + 1549; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbf9", 10) == 0) - { -{ -return dev_storage + 1133; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaf9", 10) == 0) - { -{ -return dev_storage + 717; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'e': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdde9", 10) == 0) - { -{ -return dev_storage + 1948; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdce9", 10) == 0) - { -{ -return dev_storage + 1534; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbe9", 10) == 0) - { -{ -return dev_storage + 1118; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdae9", 10) == 0) - { -{ -return dev_storage + 702; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'd': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddd9", 10) == 0) - { -{ -return dev_storage + 1933; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcd9", 10) == 0) - { -{ -return dev_storage + 1519; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbd9", 10) == 0) - { -{ -return dev_storage + 1103; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdad9", 10) == 0) - { -{ -return dev_storage + 687; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'c': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddc9", 10) == 0) - { -{ -return dev_storage + 1918; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcc9", 10) == 0) - { -{ -return dev_storage + 1504; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbc9", 10) == 0) - { -{ -return dev_storage + 1088; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdac9", 10) == 0) - { -{ -return dev_storage + 672; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'b': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddb9", 10) == 0) - { -{ -return dev_storage + 1903; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcb9", 10) == 0) - { -{ -return dev_storage + 1489; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbb9", 10) == 0) - { -{ -return dev_storage + 1073; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdab9", 10) == 0) - { -{ -return dev_storage + 657; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'a': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdda9", 10) == 0) - { -{ -return dev_storage + 1888; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdca9", 10) == 0) - { -{ -return dev_storage + 1474; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdba9", 10) == 0) - { -{ -return dev_storage + 1058; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaa9", 10) == 0) - { -{ -return dev_storage + 642; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'S': - if (strncmp (KR_keyword, "/dev/ttyS9", 10) == 0) - { -{ -return dev_storage + 2458; - -} - } - else - { -{ -return NULL; - -} - } - case '9': - if (strncmp (KR_keyword, "/dev/nst99", 10) == 0) - { -{ -return dev_storage + 142; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/nst89", 10) == 0) - { -{ -return dev_storage + 132; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/nst79", 10) == 0) - { -{ -return dev_storage + 122; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/nst69", 10) == 0) - { -{ -return dev_storage + 112; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty59", 10) == 0) - { -{ -return dev_storage + 2444; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst59", 10) == 0) - { -{ -return dev_storage + 102; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '4': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty49", 10) == 0) - { -{ -return dev_storage + 2434; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst49", 10) == 0) - { -{ -return dev_storage + 92; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '3': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty39", 10) == 0) - { -{ -return dev_storage + 2424; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst39", 10) == 0) - { -{ -return dev_storage + 82; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '2': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty29", 10) == 0) - { -{ -return dev_storage + 2414; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst29", 10) == 0) - { -{ -return dev_storage + 72; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty19", 10) == 0) - { -{ -return dev_storage + 2404; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/st119", 10) == 0) - { -{ -return dev_storage + 2375; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst19", 10) == 0) - { -{ -return dev_storage + 62; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/st109", 10) == 0) - { -{ -return dev_storage + 2365; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '8': - switch (KR_keyword [8]) - { - case 'z': - switch (KR_keyword [7]) - { - case 'c': - if (strncmp (KR_keyword, "/dev/sdcz8", 10) == 0) - { -{ -return dev_storage + 1848; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbz8", 10) == 0) - { -{ -return dev_storage + 1432; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaz8", 10) == 0) - { -{ -return dev_storage + 1016; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'y': - switch (KR_keyword [7]) - { - case 'c': - if (strncmp (KR_keyword, "/dev/sdcy8", 10) == 0) - { -{ -return dev_storage + 1833; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdby8", 10) == 0) - { -{ -return dev_storage + 1417; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sday8", 10) == 0) - { -{ -return dev_storage + 1001; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'x': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddx8", 10) == 0) - { -{ -return dev_storage + 2232; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcx8", 10) == 0) - { -{ -return dev_storage + 1818; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbx8", 10) == 0) - { -{ -return dev_storage + 1402; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdax8", 10) == 0) - { -{ -return dev_storage + 986; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'w': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddw8", 10) == 0) - { -{ -return dev_storage + 2217; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcw8", 10) == 0) - { -{ -return dev_storage + 1803; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbw8", 10) == 0) - { -{ -return dev_storage + 1387; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaw8", 10) == 0) - { -{ -return dev_storage + 971; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'v': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddv8", 10) == 0) - { -{ -return dev_storage + 2202; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcv8", 10) == 0) - { -{ -return dev_storage + 1788; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbv8", 10) == 0) - { -{ -return dev_storage + 1372; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdav8", 10) == 0) - { -{ -return dev_storage + 956; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'u': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddu8", 10) == 0) - { -{ -return dev_storage + 2187; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcu8", 10) == 0) - { -{ -return dev_storage + 1773; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbu8", 10) == 0) - { -{ -return dev_storage + 1357; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdau8", 10) == 0) - { -{ -return dev_storage + 941; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 't': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddt8", 10) == 0) - { -{ -return dev_storage + 2172; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdct8", 10) == 0) - { -{ -return dev_storage + 1758; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbt8", 10) == 0) - { -{ -return dev_storage + 1342; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdat8", 10) == 0) - { -{ -return dev_storage + 926; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 's': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdds8", 10) == 0) - { -{ -return dev_storage + 2157; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcs8", 10) == 0) - { -{ -return dev_storage + 1743; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbs8", 10) == 0) - { -{ -return dev_storage + 1327; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdas8", 10) == 0) - { -{ -return dev_storage + 911; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'r': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddr8", 10) == 0) - { -{ -return dev_storage + 2142; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcr8", 10) == 0) - { -{ -return dev_storage + 1728; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbr8", 10) == 0) - { -{ -return dev_storage + 1312; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdar8", 10) == 0) - { -{ -return dev_storage + 896; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'q': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddq8", 10) == 0) - { -{ -return dev_storage + 2127; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcq8", 10) == 0) - { -{ -return dev_storage + 1713; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbq8", 10) == 0) - { -{ -return dev_storage + 1297; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaq8", 10) == 0) - { -{ -return dev_storage + 881; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'p': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddp8", 10) == 0) - { -{ -return dev_storage + 2112; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcp8", 10) == 0) - { -{ -return dev_storage + 1698; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbp8", 10) == 0) - { -{ -return dev_storage + 1282; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdap8", 10) == 0) - { -{ -return dev_storage + 866; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'o': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddo8", 10) == 0) - { -{ -return dev_storage + 2097; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdco8", 10) == 0) - { -{ -return dev_storage + 1683; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbo8", 10) == 0) - { -{ -return dev_storage + 1267; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdao8", 10) == 0) - { -{ -return dev_storage + 851; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'n': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddn8", 10) == 0) - { -{ -return dev_storage + 2082; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcn8", 10) == 0) - { -{ -return dev_storage + 1668; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbn8", 10) == 0) - { -{ -return dev_storage + 1252; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdan8", 10) == 0) - { -{ -return dev_storage + 836; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'm': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddm8", 10) == 0) - { -{ -return dev_storage + 2067; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcm8", 10) == 0) - { -{ -return dev_storage + 1653; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbm8", 10) == 0) - { -{ -return dev_storage + 1237; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdam8", 10) == 0) - { -{ -return dev_storage + 821; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'l': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddl8", 10) == 0) - { -{ -return dev_storage + 2052; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcl8", 10) == 0) - { -{ -return dev_storage + 1638; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbl8", 10) == 0) - { -{ -return dev_storage + 1222; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdal8", 10) == 0) - { -{ -return dev_storage + 806; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'k': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddk8", 10) == 0) - { -{ -return dev_storage + 2037; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdck8", 10) == 0) - { -{ -return dev_storage + 1623; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbk8", 10) == 0) - { -{ -return dev_storage + 1207; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdak8", 10) == 0) - { -{ -return dev_storage + 791; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'j': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddj8", 10) == 0) - { -{ -return dev_storage + 2022; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcj8", 10) == 0) - { -{ -return dev_storage + 1608; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbj8", 10) == 0) - { -{ -return dev_storage + 1192; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaj8", 10) == 0) - { -{ -return dev_storage + 776; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'i': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddi8", 10) == 0) - { -{ -return dev_storage + 2007; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdci8", 10) == 0) - { -{ -return dev_storage + 1593; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbi8", 10) == 0) - { -{ -return dev_storage + 1177; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdai8", 10) == 0) - { -{ -return dev_storage + 761; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'h': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddh8", 10) == 0) - { -{ -return dev_storage + 1992; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdch8", 10) == 0) - { -{ -return dev_storage + 1578; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbh8", 10) == 0) - { -{ -return dev_storage + 1162; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdah8", 10) == 0) - { -{ -return dev_storage + 746; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'g': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddg8", 10) == 0) - { -{ -return dev_storage + 1977; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcg8", 10) == 0) - { -{ -return dev_storage + 1563; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbg8", 10) == 0) - { -{ -return dev_storage + 1147; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdag8", 10) == 0) - { -{ -return dev_storage + 731; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'f': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddf8", 10) == 0) - { -{ -return dev_storage + 1962; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcf8", 10) == 0) - { -{ -return dev_storage + 1548; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbf8", 10) == 0) - { -{ -return dev_storage + 1132; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaf8", 10) == 0) - { -{ -return dev_storage + 716; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'e': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdde8", 10) == 0) - { -{ -return dev_storage + 1947; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdce8", 10) == 0) - { -{ -return dev_storage + 1533; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbe8", 10) == 0) - { -{ -return dev_storage + 1117; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdae8", 10) == 0) - { -{ -return dev_storage + 701; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'd': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddd8", 10) == 0) - { -{ -return dev_storage + 1932; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcd8", 10) == 0) - { -{ -return dev_storage + 1518; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbd8", 10) == 0) - { -{ -return dev_storage + 1102; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdad8", 10) == 0) - { -{ -return dev_storage + 686; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'c': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddc8", 10) == 0) - { -{ -return dev_storage + 1917; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcc8", 10) == 0) - { -{ -return dev_storage + 1503; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbc8", 10) == 0) - { -{ -return dev_storage + 1087; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdac8", 10) == 0) - { -{ -return dev_storage + 671; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'b': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddb8", 10) == 0) - { -{ -return dev_storage + 1902; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcb8", 10) == 0) - { -{ -return dev_storage + 1488; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbb8", 10) == 0) - { -{ -return dev_storage + 1072; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdab8", 10) == 0) - { -{ -return dev_storage + 656; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'a': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdda8", 10) == 0) - { -{ -return dev_storage + 1887; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdca8", 10) == 0) - { -{ -return dev_storage + 1473; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdba8", 10) == 0) - { -{ -return dev_storage + 1057; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaa8", 10) == 0) - { -{ -return dev_storage + 641; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'S': - if (strncmp (KR_keyword, "/dev/ttyS8", 10) == 0) - { -{ -return dev_storage + 2457; - -} - } - else - { -{ -return NULL; - -} - } - case '9': - if (strncmp (KR_keyword, "/dev/nst98", 10) == 0) - { -{ -return dev_storage + 141; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/nst88", 10) == 0) - { -{ -return dev_storage + 131; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/nst78", 10) == 0) - { -{ -return dev_storage + 121; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/nst68", 10) == 0) - { -{ -return dev_storage + 111; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty58", 10) == 0) - { -{ -return dev_storage + 2443; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst58", 10) == 0) - { -{ -return dev_storage + 101; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '4': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty48", 10) == 0) - { -{ -return dev_storage + 2433; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst48", 10) == 0) - { -{ -return dev_storage + 91; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '3': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty38", 10) == 0) - { -{ -return dev_storage + 2423; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst38", 10) == 0) - { -{ -return dev_storage + 81; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '2': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty28", 10) == 0) - { -{ -return dev_storage + 2413; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst28", 10) == 0) - { -{ -return dev_storage + 71; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty18", 10) == 0) - { -{ -return dev_storage + 2403; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/st118", 10) == 0) - { -{ -return dev_storage + 2374; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst18", 10) == 0) - { -{ -return dev_storage + 61; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/st108", 10) == 0) - { -{ -return dev_storage + 2364; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '7': - switch (KR_keyword [8]) - { - case 'z': - switch (KR_keyword [7]) - { - case 'c': - if (strncmp (KR_keyword, "/dev/sdcz7", 10) == 0) - { -{ -return dev_storage + 1847; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbz7", 10) == 0) - { -{ -return dev_storage + 1431; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaz7", 10) == 0) - { -{ -return dev_storage + 1015; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'y': - switch (KR_keyword [7]) - { - case 'c': - if (strncmp (KR_keyword, "/dev/sdcy7", 10) == 0) - { -{ -return dev_storage + 1832; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdby7", 10) == 0) - { -{ -return dev_storage + 1416; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sday7", 10) == 0) - { -{ -return dev_storage + 1000; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'x': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddx7", 10) == 0) - { -{ -return dev_storage + 2231; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcx7", 10) == 0) - { -{ -return dev_storage + 1817; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbx7", 10) == 0) - { -{ -return dev_storage + 1401; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdax7", 10) == 0) - { -{ -return dev_storage + 985; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'w': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddw7", 10) == 0) - { -{ -return dev_storage + 2216; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcw7", 10) == 0) - { -{ -return dev_storage + 1802; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbw7", 10) == 0) - { -{ -return dev_storage + 1386; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaw7", 10) == 0) - { -{ -return dev_storage + 970; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'v': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddv7", 10) == 0) - { -{ -return dev_storage + 2201; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcv7", 10) == 0) - { -{ -return dev_storage + 1787; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbv7", 10) == 0) - { -{ -return dev_storage + 1371; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdav7", 10) == 0) - { -{ -return dev_storage + 955; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'u': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddu7", 10) == 0) - { -{ -return dev_storage + 2186; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcu7", 10) == 0) - { -{ -return dev_storage + 1772; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbu7", 10) == 0) - { -{ -return dev_storage + 1356; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdau7", 10) == 0) - { -{ -return dev_storage + 940; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 't': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddt7", 10) == 0) - { -{ -return dev_storage + 2171; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdct7", 10) == 0) - { -{ -return dev_storage + 1757; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbt7", 10) == 0) - { -{ -return dev_storage + 1341; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdat7", 10) == 0) - { -{ -return dev_storage + 925; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 's': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdds7", 10) == 0) - { -{ -return dev_storage + 2156; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcs7", 10) == 0) - { -{ -return dev_storage + 1742; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbs7", 10) == 0) - { -{ -return dev_storage + 1326; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdas7", 10) == 0) - { -{ -return dev_storage + 910; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'r': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddr7", 10) == 0) - { -{ -return dev_storage + 2141; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcr7", 10) == 0) - { -{ -return dev_storage + 1727; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbr7", 10) == 0) - { -{ -return dev_storage + 1311; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdar7", 10) == 0) - { -{ -return dev_storage + 895; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'q': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddq7", 10) == 0) - { -{ -return dev_storage + 2126; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcq7", 10) == 0) - { -{ -return dev_storage + 1712; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbq7", 10) == 0) - { -{ -return dev_storage + 1296; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaq7", 10) == 0) - { -{ -return dev_storage + 880; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'p': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddp7", 10) == 0) - { -{ -return dev_storage + 2111; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcp7", 10) == 0) - { -{ -return dev_storage + 1697; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbp7", 10) == 0) - { -{ -return dev_storage + 1281; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdap7", 10) == 0) - { -{ -return dev_storage + 865; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'o': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddo7", 10) == 0) - { -{ -return dev_storage + 2096; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdco7", 10) == 0) - { -{ -return dev_storage + 1682; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbo7", 10) == 0) - { -{ -return dev_storage + 1266; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdao7", 10) == 0) - { -{ -return dev_storage + 850; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'n': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddn7", 10) == 0) - { -{ -return dev_storage + 2081; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcn7", 10) == 0) - { -{ -return dev_storage + 1667; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbn7", 10) == 0) - { -{ -return dev_storage + 1251; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdan7", 10) == 0) - { -{ -return dev_storage + 835; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'm': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddm7", 10) == 0) - { -{ -return dev_storage + 2066; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcm7", 10) == 0) - { -{ -return dev_storage + 1652; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbm7", 10) == 0) - { -{ -return dev_storage + 1236; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdam7", 10) == 0) - { -{ -return dev_storage + 820; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'l': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddl7", 10) == 0) - { -{ -return dev_storage + 2051; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcl7", 10) == 0) - { -{ -return dev_storage + 1637; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbl7", 10) == 0) - { -{ -return dev_storage + 1221; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdal7", 10) == 0) - { -{ -return dev_storage + 805; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'k': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddk7", 10) == 0) - { -{ -return dev_storage + 2036; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdck7", 10) == 0) - { -{ -return dev_storage + 1622; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbk7", 10) == 0) - { -{ -return dev_storage + 1206; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdak7", 10) == 0) - { -{ -return dev_storage + 790; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'j': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddj7", 10) == 0) - { -{ -return dev_storage + 2021; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcj7", 10) == 0) - { -{ -return dev_storage + 1607; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbj7", 10) == 0) - { -{ -return dev_storage + 1191; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaj7", 10) == 0) - { -{ -return dev_storage + 775; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'i': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddi7", 10) == 0) - { -{ -return dev_storage + 2006; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdci7", 10) == 0) - { -{ -return dev_storage + 1592; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbi7", 10) == 0) - { -{ -return dev_storage + 1176; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdai7", 10) == 0) - { -{ -return dev_storage + 760; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'h': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddh7", 10) == 0) - { -{ -return dev_storage + 1991; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdch7", 10) == 0) - { -{ -return dev_storage + 1577; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbh7", 10) == 0) - { -{ -return dev_storage + 1161; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdah7", 10) == 0) - { -{ -return dev_storage + 745; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'g': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddg7", 10) == 0) - { -{ -return dev_storage + 1976; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcg7", 10) == 0) - { -{ -return dev_storage + 1562; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbg7", 10) == 0) - { -{ -return dev_storage + 1146; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdag7", 10) == 0) - { -{ -return dev_storage + 730; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'f': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddf7", 10) == 0) - { -{ -return dev_storage + 1961; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcf7", 10) == 0) - { -{ -return dev_storage + 1547; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbf7", 10) == 0) - { -{ -return dev_storage + 1131; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaf7", 10) == 0) - { -{ -return dev_storage + 715; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'e': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdde7", 10) == 0) - { -{ -return dev_storage + 1946; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdce7", 10) == 0) - { -{ -return dev_storage + 1532; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbe7", 10) == 0) - { -{ -return dev_storage + 1116; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdae7", 10) == 0) - { -{ -return dev_storage + 700; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'd': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddd7", 10) == 0) - { -{ -return dev_storage + 1931; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcd7", 10) == 0) - { -{ -return dev_storage + 1517; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbd7", 10) == 0) - { -{ -return dev_storage + 1101; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdad7", 10) == 0) - { -{ -return dev_storage + 685; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'c': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddc7", 10) == 0) - { -{ -return dev_storage + 1916; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcc7", 10) == 0) - { -{ -return dev_storage + 1502; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbc7", 10) == 0) - { -{ -return dev_storage + 1086; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdac7", 10) == 0) - { -{ -return dev_storage + 670; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'b': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddb7", 10) == 0) - { -{ -return dev_storage + 1901; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcb7", 10) == 0) - { -{ -return dev_storage + 1487; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbb7", 10) == 0) - { -{ -return dev_storage + 1071; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdab7", 10) == 0) - { -{ -return dev_storage + 655; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'a': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdda7", 10) == 0) - { -{ -return dev_storage + 1886; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdca7", 10) == 0) - { -{ -return dev_storage + 1472; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdba7", 10) == 0) - { -{ -return dev_storage + 1056; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaa7", 10) == 0) - { -{ -return dev_storage + 640; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'S': - if (strncmp (KR_keyword, "/dev/ttyS7", 10) == 0) - { -{ -return dev_storage + 2456; - -} - } - else - { -{ -return NULL; - -} - } - case '9': - if (strncmp (KR_keyword, "/dev/nst97", 10) == 0) - { -{ -return dev_storage + 140; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/nst87", 10) == 0) - { -{ -return dev_storage + 130; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/nst77", 10) == 0) - { -{ -return dev_storage + 120; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/nst67", 10) == 0) - { -{ -return dev_storage + 110; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty57", 10) == 0) - { -{ -return dev_storage + 2442; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst57", 10) == 0) - { -{ -return dev_storage + 100; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '4': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty47", 10) == 0) - { -{ -return dev_storage + 2432; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst47", 10) == 0) - { -{ -return dev_storage + 90; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '3': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty37", 10) == 0) - { -{ -return dev_storage + 2422; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst37", 10) == 0) - { -{ -return dev_storage + 80; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '2': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty27", 10) == 0) - { -{ -return dev_storage + 2412; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/st127", 10) == 0) - { -{ -return dev_storage + 2383; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst27", 10) == 0) - { -{ -return dev_storage + 70; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty17", 10) == 0) - { -{ -return dev_storage + 2402; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/st117", 10) == 0) - { -{ -return dev_storage + 2373; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst17", 10) == 0) - { -{ -return dev_storage + 60; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/st107", 10) == 0) - { -{ -return dev_storage + 2363; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '6': - switch (KR_keyword [8]) - { - case 'z': - switch (KR_keyword [7]) - { - case 'c': - if (strncmp (KR_keyword, "/dev/sdcz6", 10) == 0) - { -{ -return dev_storage + 1846; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbz6", 10) == 0) - { -{ -return dev_storage + 1430; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaz6", 10) == 0) - { -{ -return dev_storage + 1014; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'y': - switch (KR_keyword [7]) - { - case 'c': - if (strncmp (KR_keyword, "/dev/sdcy6", 10) == 0) - { -{ -return dev_storage + 1831; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdby6", 10) == 0) - { -{ -return dev_storage + 1415; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sday6", 10) == 0) - { -{ -return dev_storage + 999; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'x': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddx6", 10) == 0) - { -{ -return dev_storage + 2230; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcx6", 10) == 0) - { -{ -return dev_storage + 1816; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbx6", 10) == 0) - { -{ -return dev_storage + 1400; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdax6", 10) == 0) - { -{ -return dev_storage + 984; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'w': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddw6", 10) == 0) - { -{ -return dev_storage + 2215; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcw6", 10) == 0) - { -{ -return dev_storage + 1801; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbw6", 10) == 0) - { -{ -return dev_storage + 1385; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaw6", 10) == 0) - { -{ -return dev_storage + 969; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'v': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddv6", 10) == 0) - { -{ -return dev_storage + 2200; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcv6", 10) == 0) - { -{ -return dev_storage + 1786; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbv6", 10) == 0) - { -{ -return dev_storage + 1370; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdav6", 10) == 0) - { -{ -return dev_storage + 954; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'u': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddu6", 10) == 0) - { -{ -return dev_storage + 2185; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcu6", 10) == 0) - { -{ -return dev_storage + 1771; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbu6", 10) == 0) - { -{ -return dev_storage + 1355; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdau6", 10) == 0) - { -{ -return dev_storage + 939; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 't': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddt6", 10) == 0) - { -{ -return dev_storage + 2170; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdct6", 10) == 0) - { -{ -return dev_storage + 1756; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbt6", 10) == 0) - { -{ -return dev_storage + 1340; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdat6", 10) == 0) - { -{ -return dev_storage + 924; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 's': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdds6", 10) == 0) - { -{ -return dev_storage + 2155; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcs6", 10) == 0) - { -{ -return dev_storage + 1741; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbs6", 10) == 0) - { -{ -return dev_storage + 1325; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdas6", 10) == 0) - { -{ -return dev_storage + 909; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'r': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddr6", 10) == 0) - { -{ -return dev_storage + 2140; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcr6", 10) == 0) - { -{ -return dev_storage + 1726; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbr6", 10) == 0) - { -{ -return dev_storage + 1310; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdar6", 10) == 0) - { -{ -return dev_storage + 894; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'q': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddq6", 10) == 0) - { -{ -return dev_storage + 2125; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcq6", 10) == 0) - { -{ -return dev_storage + 1711; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbq6", 10) == 0) - { -{ -return dev_storage + 1295; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaq6", 10) == 0) - { -{ -return dev_storage + 879; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'p': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddp6", 10) == 0) - { -{ -return dev_storage + 2110; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcp6", 10) == 0) - { -{ -return dev_storage + 1696; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbp6", 10) == 0) - { -{ -return dev_storage + 1280; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdap6", 10) == 0) - { -{ -return dev_storage + 864; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'o': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddo6", 10) == 0) - { -{ -return dev_storage + 2095; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdco6", 10) == 0) - { -{ -return dev_storage + 1681; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbo6", 10) == 0) - { -{ -return dev_storage + 1265; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdao6", 10) == 0) - { -{ -return dev_storage + 849; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'n': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddn6", 10) == 0) - { -{ -return dev_storage + 2080; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcn6", 10) == 0) - { -{ -return dev_storage + 1666; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbn6", 10) == 0) - { -{ -return dev_storage + 1250; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdan6", 10) == 0) - { -{ -return dev_storage + 834; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'm': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddm6", 10) == 0) - { -{ -return dev_storage + 2065; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcm6", 10) == 0) - { -{ -return dev_storage + 1651; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbm6", 10) == 0) - { -{ -return dev_storage + 1235; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdam6", 10) == 0) - { -{ -return dev_storage + 819; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'l': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddl6", 10) == 0) - { -{ -return dev_storage + 2050; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcl6", 10) == 0) - { -{ -return dev_storage + 1636; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbl6", 10) == 0) - { -{ -return dev_storage + 1220; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdal6", 10) == 0) - { -{ -return dev_storage + 804; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'k': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddk6", 10) == 0) - { -{ -return dev_storage + 2035; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdck6", 10) == 0) - { -{ -return dev_storage + 1621; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbk6", 10) == 0) - { -{ -return dev_storage + 1205; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdak6", 10) == 0) - { -{ -return dev_storage + 789; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'j': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddj6", 10) == 0) - { -{ -return dev_storage + 2020; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcj6", 10) == 0) - { -{ -return dev_storage + 1606; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbj6", 10) == 0) - { -{ -return dev_storage + 1190; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaj6", 10) == 0) - { -{ -return dev_storage + 774; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'i': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddi6", 10) == 0) - { -{ -return dev_storage + 2005; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdci6", 10) == 0) - { -{ -return dev_storage + 1591; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbi6", 10) == 0) - { -{ -return dev_storage + 1175; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdai6", 10) == 0) - { -{ -return dev_storage + 759; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'h': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddh6", 10) == 0) - { -{ -return dev_storage + 1990; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdch6", 10) == 0) - { -{ -return dev_storage + 1576; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbh6", 10) == 0) - { -{ -return dev_storage + 1160; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdah6", 10) == 0) - { -{ -return dev_storage + 744; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'g': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddg6", 10) == 0) - { -{ -return dev_storage + 1975; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcg6", 10) == 0) - { -{ -return dev_storage + 1561; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbg6", 10) == 0) - { -{ -return dev_storage + 1145; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdag6", 10) == 0) - { -{ -return dev_storage + 729; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'f': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddf6", 10) == 0) - { -{ -return dev_storage + 1960; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcf6", 10) == 0) - { -{ -return dev_storage + 1546; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbf6", 10) == 0) - { -{ -return dev_storage + 1130; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaf6", 10) == 0) - { -{ -return dev_storage + 714; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'e': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdde6", 10) == 0) - { -{ -return dev_storage + 1945; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdce6", 10) == 0) - { -{ -return dev_storage + 1531; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbe6", 10) == 0) - { -{ -return dev_storage + 1115; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdae6", 10) == 0) - { -{ -return dev_storage + 699; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'd': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddd6", 10) == 0) - { -{ -return dev_storage + 1930; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcd6", 10) == 0) - { -{ -return dev_storage + 1516; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbd6", 10) == 0) - { -{ -return dev_storage + 1100; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdad6", 10) == 0) - { -{ -return dev_storage + 684; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'c': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddc6", 10) == 0) - { -{ -return dev_storage + 1915; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcc6", 10) == 0) - { -{ -return dev_storage + 1501; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbc6", 10) == 0) - { -{ -return dev_storage + 1085; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdac6", 10) == 0) - { -{ -return dev_storage + 669; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'b': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sddb6", 10) == 0) - { -{ -return dev_storage + 1900; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcb6", 10) == 0) - { -{ -return dev_storage + 1486; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbb6", 10) == 0) - { -{ -return dev_storage + 1070; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdab6", 10) == 0) - { -{ -return dev_storage + 654; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'a': - switch (KR_keyword [7]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdda6", 10) == 0) - { -{ -return dev_storage + 1885; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdca6", 10) == 0) - { -{ -return dev_storage + 1471; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdba6", 10) == 0) - { -{ -return dev_storage + 1055; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaa6", 10) == 0) - { -{ -return dev_storage + 639; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'S': - if (strncmp (KR_keyword, "/dev/ttyS6", 10) == 0) - { -{ -return dev_storage + 2455; - -} - } - else - { -{ -return NULL; - -} - } - case '9': - if (strncmp (KR_keyword, "/dev/nst96", 10) == 0) - { -{ -return dev_storage + 139; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/nst86", 10) == 0) - { -{ -return dev_storage + 129; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/nst76", 10) == 0) - { -{ -return dev_storage + 119; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/nst66", 10) == 0) - { -{ -return dev_storage + 109; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty56", 10) == 0) - { -{ -return dev_storage + 2441; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst56", 10) == 0) - { -{ -return dev_storage + 99; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '4': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty46", 10) == 0) - { -{ -return dev_storage + 2431; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst46", 10) == 0) - { -{ -return dev_storage + 89; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '3': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty36", 10) == 0) - { -{ -return dev_storage + 2421; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst36", 10) == 0) - { -{ -return dev_storage + 79; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '2': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty26", 10) == 0) - { -{ -return dev_storage + 2411; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/st126", 10) == 0) - { -{ -return dev_storage + 2382; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst26", 10) == 0) - { -{ -return dev_storage + 69; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty16", 10) == 0) - { -{ -return dev_storage + 2401; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/st116", 10) == 0) - { -{ -return dev_storage + 2372; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst16", 10) == 0) - { -{ -return dev_storage + 59; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/com16", 10) == 0) - { -{ -return dev_storage + 17; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/st106", 10) == 0) - { -{ -return dev_storage + 2362; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '5': - switch (KR_keyword [7]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdz15", 10) == 0) - { -{ -return dev_storage + 607; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - switch (KR_keyword [8]) - { - case 'S': - if (strncmp (KR_keyword, "/dev/ttyS5", 10) == 0) - { -{ -return dev_storage + 2454; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/tty55", 10) == 0) - { -{ -return dev_storage + 2440; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/tty45", 10) == 0) - { -{ -return dev_storage + 2430; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/tty35", 10) == 0) - { -{ -return dev_storage + 2420; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/tty25", 10) == 0) - { -{ -return dev_storage + 2410; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty15", 10) == 0) - { -{ -return dev_storage + 2400; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdy15", 10) == 0) - { -{ -return dev_storage + 592; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdx15", 10) == 0) - { -{ -return dev_storage + 577; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdw15", 10) == 0) - { -{ -return dev_storage + 562; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdv15", 10) == 0) - { -{ -return dev_storage + 547; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdu15", 10) == 0) - { -{ -return dev_storage + 532; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/nst95", 10) == 0) - { -{ -return dev_storage + 138; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/nst85", 10) == 0) - { -{ -return dev_storage + 128; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/nst75", 10) == 0) - { -{ -return dev_storage + 118; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/nst65", 10) == 0) - { -{ -return dev_storage + 108; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/nst55", 10) == 0) - { -{ -return dev_storage + 98; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/nst45", 10) == 0) - { -{ -return dev_storage + 88; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/nst35", 10) == 0) - { -{ -return dev_storage + 78; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/nst25", 10) == 0) - { -{ -return dev_storage + 68; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [5]) - { - case 's': - if (strncmp (KR_keyword, "/dev/sdt15", 10) == 0) - { -{ -return dev_storage + 517; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst15", 10) == 0) - { -{ -return dev_storage + 58; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sds15", 10) == 0) - { -{ -return dev_storage + 502; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdr15", 10) == 0) - { -{ -return dev_storage + 487; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdq15", 10) == 0) - { -{ -return dev_storage + 472; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdp15", 10) == 0) - { -{ -return dev_storage + 457; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdo15", 10) == 0) - { -{ -return dev_storage + 442; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdn15", 10) == 0) - { -{ -return dev_storage + 427; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - switch (KR_keyword [5]) - { - case 's': - if (strncmp (KR_keyword, "/dev/sdm15", 10) == 0) - { -{ -return dev_storage + 412; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/com15", 10) == 0) - { -{ -return dev_storage + 16; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdl15", 10) == 0) - { -{ -return dev_storage + 397; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdk15", 10) == 0) - { -{ -return dev_storage + 382; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdj15", 10) == 0) - { -{ -return dev_storage + 367; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdi15", 10) == 0) - { -{ -return dev_storage + 352; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdh15", 10) == 0) - { -{ -return dev_storage + 337; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdg15", 10) == 0) - { -{ -return dev_storage + 322; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdf15", 10) == 0) - { -{ -return dev_storage + 307; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sde15", 10) == 0) - { -{ -return dev_storage + 292; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - switch (KR_keyword [8]) - { - case 'x': - if (strncmp (KR_keyword, "/dev/sddx5", 10) == 0) - { -{ -return dev_storage + 2229; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sddw5", 10) == 0) - { -{ -return dev_storage + 2214; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sddv5", 10) == 0) - { -{ -return dev_storage + 2199; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sddu5", 10) == 0) - { -{ -return dev_storage + 2184; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sddt5", 10) == 0) - { -{ -return dev_storage + 2169; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdds5", 10) == 0) - { -{ -return dev_storage + 2154; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sddr5", 10) == 0) - { -{ -return dev_storage + 2139; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sddq5", 10) == 0) - { -{ -return dev_storage + 2124; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sddp5", 10) == 0) - { -{ -return dev_storage + 2109; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sddo5", 10) == 0) - { -{ -return dev_storage + 2094; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sddn5", 10) == 0) - { -{ -return dev_storage + 2079; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sddm5", 10) == 0) - { -{ -return dev_storage + 2064; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sddl5", 10) == 0) - { -{ -return dev_storage + 2049; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sddk5", 10) == 0) - { -{ -return dev_storage + 2034; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sddj5", 10) == 0) - { -{ -return dev_storage + 2019; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sddi5", 10) == 0) - { -{ -return dev_storage + 2004; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sddh5", 10) == 0) - { -{ -return dev_storage + 1989; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sddg5", 10) == 0) - { -{ -return dev_storage + 1974; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sddf5", 10) == 0) - { -{ -return dev_storage + 1959; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdde5", 10) == 0) - { -{ -return dev_storage + 1944; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sddd5", 10) == 0) - { -{ -return dev_storage + 1929; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sddc5", 10) == 0) - { -{ -return dev_storage + 1914; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sddb5", 10) == 0) - { -{ -return dev_storage + 1899; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdda5", 10) == 0) - { -{ -return dev_storage + 1884; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [6]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdd15", 10) == 0) - { -{ -return dev_storage + 277; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/scd15", 10) == 0) - { -{ -return dev_storage + 191; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'c': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdcz5", 10) == 0) - { -{ -return dev_storage + 1845; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdcy5", 10) == 0) - { -{ -return dev_storage + 1830; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdcx5", 10) == 0) - { -{ -return dev_storage + 1815; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdcw5", 10) == 0) - { -{ -return dev_storage + 1800; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdcv5", 10) == 0) - { -{ -return dev_storage + 1785; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdcu5", 10) == 0) - { -{ -return dev_storage + 1770; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdct5", 10) == 0) - { -{ -return dev_storage + 1755; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdcs5", 10) == 0) - { -{ -return dev_storage + 1740; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdcr5", 10) == 0) - { -{ -return dev_storage + 1725; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdcq5", 10) == 0) - { -{ -return dev_storage + 1710; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdcp5", 10) == 0) - { -{ -return dev_storage + 1695; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdco5", 10) == 0) - { -{ -return dev_storage + 1680; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdcn5", 10) == 0) - { -{ -return dev_storage + 1665; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdcm5", 10) == 0) - { -{ -return dev_storage + 1650; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdcl5", 10) == 0) - { -{ -return dev_storage + 1635; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdck5", 10) == 0) - { -{ -return dev_storage + 1620; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdcj5", 10) == 0) - { -{ -return dev_storage + 1605; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdci5", 10) == 0) - { -{ -return dev_storage + 1590; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdch5", 10) == 0) - { -{ -return dev_storage + 1575; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdcg5", 10) == 0) - { -{ -return dev_storage + 1560; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdcf5", 10) == 0) - { -{ -return dev_storage + 1545; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdce5", 10) == 0) - { -{ -return dev_storage + 1530; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdcd5", 10) == 0) - { -{ -return dev_storage + 1515; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcc5", 10) == 0) - { -{ -return dev_storage + 1500; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdcb5", 10) == 0) - { -{ -return dev_storage + 1485; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdca5", 10) == 0) - { -{ -return dev_storage + 1470; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdc15", 10) == 0) - { -{ -return dev_storage + 262; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'b': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdbz5", 10) == 0) - { -{ -return dev_storage + 1429; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdby5", 10) == 0) - { -{ -return dev_storage + 1414; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdbx5", 10) == 0) - { -{ -return dev_storage + 1399; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdbw5", 10) == 0) - { -{ -return dev_storage + 1384; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdbv5", 10) == 0) - { -{ -return dev_storage + 1369; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdbu5", 10) == 0) - { -{ -return dev_storage + 1354; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdbt5", 10) == 0) - { -{ -return dev_storage + 1339; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdbs5", 10) == 0) - { -{ -return dev_storage + 1324; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdbr5", 10) == 0) - { -{ -return dev_storage + 1309; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdbq5", 10) == 0) - { -{ -return dev_storage + 1294; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdbp5", 10) == 0) - { -{ -return dev_storage + 1279; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdbo5", 10) == 0) - { -{ -return dev_storage + 1264; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdbn5", 10) == 0) - { -{ -return dev_storage + 1249; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdbm5", 10) == 0) - { -{ -return dev_storage + 1234; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdbl5", 10) == 0) - { -{ -return dev_storage + 1219; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdbk5", 10) == 0) - { -{ -return dev_storage + 1204; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdbj5", 10) == 0) - { -{ -return dev_storage + 1189; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdbi5", 10) == 0) - { -{ -return dev_storage + 1174; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdbh5", 10) == 0) - { -{ -return dev_storage + 1159; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdbg5", 10) == 0) - { -{ -return dev_storage + 1144; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdbf5", 10) == 0) - { -{ -return dev_storage + 1129; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdbe5", 10) == 0) - { -{ -return dev_storage + 1114; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdbd5", 10) == 0) - { -{ -return dev_storage + 1099; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdbc5", 10) == 0) - { -{ -return dev_storage + 1084; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbb5", 10) == 0) - { -{ -return dev_storage + 1069; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdba5", 10) == 0) - { -{ -return dev_storage + 1054; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdb15", 10) == 0) - { -{ -return dev_storage + 247; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'a': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdaz5", 10) == 0) - { -{ -return dev_storage + 1013; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sday5", 10) == 0) - { -{ -return dev_storage + 998; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdax5", 10) == 0) - { -{ -return dev_storage + 983; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdaw5", 10) == 0) - { -{ -return dev_storage + 968; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdav5", 10) == 0) - { -{ -return dev_storage + 953; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdau5", 10) == 0) - { -{ -return dev_storage + 938; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdat5", 10) == 0) - { -{ -return dev_storage + 923; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdas5", 10) == 0) - { -{ -return dev_storage + 908; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdar5", 10) == 0) - { -{ -return dev_storage + 893; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdaq5", 10) == 0) - { -{ -return dev_storage + 878; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdap5", 10) == 0) - { -{ -return dev_storage + 863; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdao5", 10) == 0) - { -{ -return dev_storage + 848; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdan5", 10) == 0) - { -{ -return dev_storage + 833; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdam5", 10) == 0) - { -{ -return dev_storage + 818; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdal5", 10) == 0) - { -{ -return dev_storage + 803; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdak5", 10) == 0) - { -{ -return dev_storage + 788; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdaj5", 10) == 0) - { -{ -return dev_storage + 773; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdai5", 10) == 0) - { -{ -return dev_storage + 758; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdah5", 10) == 0) - { -{ -return dev_storage + 743; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdag5", 10) == 0) - { -{ -return dev_storage + 728; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdaf5", 10) == 0) - { -{ -return dev_storage + 713; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdae5", 10) == 0) - { -{ -return dev_storage + 698; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdad5", 10) == 0) - { -{ -return dev_storage + 683; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdac5", 10) == 0) - { -{ -return dev_storage + 668; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdab5", 10) == 0) - { -{ -return dev_storage + 653; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaa5", 10) == 0) - { -{ -return dev_storage + 638; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sda15", 10) == 0) - { -{ -return dev_storage + 232; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [8]) - { - case '2': - if (strncmp (KR_keyword, "/dev/st125", 10) == 0) - { -{ -return dev_storage + 2381; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/st115", 10) == 0) - { -{ -return dev_storage + 2371; - -} - } - else - { -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/st105", 10) == 0) - { -{ -return dev_storage + 2361; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '4': - switch (KR_keyword [7]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdz14", 10) == 0) - { -{ -return dev_storage + 606; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - switch (KR_keyword [8]) - { - case 'S': - if (strncmp (KR_keyword, "/dev/ttyS4", 10) == 0) - { -{ -return dev_storage + 2453; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/tty54", 10) == 0) - { -{ -return dev_storage + 2439; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/tty44", 10) == 0) - { -{ -return dev_storage + 2429; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/tty34", 10) == 0) - { -{ -return dev_storage + 2419; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/tty24", 10) == 0) - { -{ -return dev_storage + 2409; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty14", 10) == 0) - { -{ -return dev_storage + 2399; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdy14", 10) == 0) - { -{ -return dev_storage + 591; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdx14", 10) == 0) - { -{ -return dev_storage + 576; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdw14", 10) == 0) - { -{ -return dev_storage + 561; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdv14", 10) == 0) - { -{ -return dev_storage + 546; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdu14", 10) == 0) - { -{ -return dev_storage + 531; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/nst94", 10) == 0) - { -{ -return dev_storage + 137; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/nst84", 10) == 0) - { -{ -return dev_storage + 127; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/nst74", 10) == 0) - { -{ -return dev_storage + 117; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/nst64", 10) == 0) - { -{ -return dev_storage + 107; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/nst54", 10) == 0) - { -{ -return dev_storage + 97; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/nst44", 10) == 0) - { -{ -return dev_storage + 87; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/nst34", 10) == 0) - { -{ -return dev_storage + 77; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/nst24", 10) == 0) - { -{ -return dev_storage + 67; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [5]) - { - case 's': - if (strncmp (KR_keyword, "/dev/sdt14", 10) == 0) - { -{ -return dev_storage + 516; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst14", 10) == 0) - { -{ -return dev_storage + 57; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sds14", 10) == 0) - { -{ -return dev_storage + 501; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdr14", 10) == 0) - { -{ -return dev_storage + 486; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdq14", 10) == 0) - { -{ -return dev_storage + 471; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdp14", 10) == 0) - { -{ -return dev_storage + 456; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdo14", 10) == 0) - { -{ -return dev_storage + 441; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdn14", 10) == 0) - { -{ -return dev_storage + 426; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - switch (KR_keyword [5]) - { - case 's': - if (strncmp (KR_keyword, "/dev/sdm14", 10) == 0) - { -{ -return dev_storage + 411; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/com14", 10) == 0) - { -{ -return dev_storage + 15; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdl14", 10) == 0) - { -{ -return dev_storage + 396; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdk14", 10) == 0) - { -{ -return dev_storage + 381; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdj14", 10) == 0) - { -{ -return dev_storage + 366; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdi14", 10) == 0) - { -{ -return dev_storage + 351; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdh14", 10) == 0) - { -{ -return dev_storage + 336; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdg14", 10) == 0) - { -{ -return dev_storage + 321; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdf14", 10) == 0) - { -{ -return dev_storage + 306; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sde14", 10) == 0) - { -{ -return dev_storage + 291; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - switch (KR_keyword [8]) - { - case 'x': - if (strncmp (KR_keyword, "/dev/sddx4", 10) == 0) - { -{ -return dev_storage + 2228; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sddw4", 10) == 0) - { -{ -return dev_storage + 2213; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sddv4", 10) == 0) - { -{ -return dev_storage + 2198; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sddu4", 10) == 0) - { -{ -return dev_storage + 2183; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sddt4", 10) == 0) - { -{ -return dev_storage + 2168; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdds4", 10) == 0) - { -{ -return dev_storage + 2153; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sddr4", 10) == 0) - { -{ -return dev_storage + 2138; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sddq4", 10) == 0) - { -{ -return dev_storage + 2123; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sddp4", 10) == 0) - { -{ -return dev_storage + 2108; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sddo4", 10) == 0) - { -{ -return dev_storage + 2093; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sddn4", 10) == 0) - { -{ -return dev_storage + 2078; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sddm4", 10) == 0) - { -{ -return dev_storage + 2063; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sddl4", 10) == 0) - { -{ -return dev_storage + 2048; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sddk4", 10) == 0) - { -{ -return dev_storage + 2033; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sddj4", 10) == 0) - { -{ -return dev_storage + 2018; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sddi4", 10) == 0) - { -{ -return dev_storage + 2003; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sddh4", 10) == 0) - { -{ -return dev_storage + 1988; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sddg4", 10) == 0) - { -{ -return dev_storage + 1973; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sddf4", 10) == 0) - { -{ -return dev_storage + 1958; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdde4", 10) == 0) - { -{ -return dev_storage + 1943; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sddd4", 10) == 0) - { -{ -return dev_storage + 1928; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sddc4", 10) == 0) - { -{ -return dev_storage + 1913; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sddb4", 10) == 0) - { -{ -return dev_storage + 1898; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdda4", 10) == 0) - { -{ -return dev_storage + 1883; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [6]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdd14", 10) == 0) - { -{ -return dev_storage + 276; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/scd14", 10) == 0) - { -{ -return dev_storage + 190; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'c': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdcz4", 10) == 0) - { -{ -return dev_storage + 1844; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdcy4", 10) == 0) - { -{ -return dev_storage + 1829; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdcx4", 10) == 0) - { -{ -return dev_storage + 1814; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdcw4", 10) == 0) - { -{ -return dev_storage + 1799; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdcv4", 10) == 0) - { -{ -return dev_storage + 1784; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdcu4", 10) == 0) - { -{ -return dev_storage + 1769; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdct4", 10) == 0) - { -{ -return dev_storage + 1754; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdcs4", 10) == 0) - { -{ -return dev_storage + 1739; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdcr4", 10) == 0) - { -{ -return dev_storage + 1724; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdcq4", 10) == 0) - { -{ -return dev_storage + 1709; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdcp4", 10) == 0) - { -{ -return dev_storage + 1694; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdco4", 10) == 0) - { -{ -return dev_storage + 1679; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdcn4", 10) == 0) - { -{ -return dev_storage + 1664; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdcm4", 10) == 0) - { -{ -return dev_storage + 1649; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdcl4", 10) == 0) - { -{ -return dev_storage + 1634; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdck4", 10) == 0) - { -{ -return dev_storage + 1619; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdcj4", 10) == 0) - { -{ -return dev_storage + 1604; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdci4", 10) == 0) - { -{ -return dev_storage + 1589; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdch4", 10) == 0) - { -{ -return dev_storage + 1574; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdcg4", 10) == 0) - { -{ -return dev_storage + 1559; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdcf4", 10) == 0) - { -{ -return dev_storage + 1544; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdce4", 10) == 0) - { -{ -return dev_storage + 1529; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdcd4", 10) == 0) - { -{ -return dev_storage + 1514; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcc4", 10) == 0) - { -{ -return dev_storage + 1499; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdcb4", 10) == 0) - { -{ -return dev_storage + 1484; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdca4", 10) == 0) - { -{ -return dev_storage + 1469; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdc14", 10) == 0) - { -{ -return dev_storage + 261; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'b': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdbz4", 10) == 0) - { -{ -return dev_storage + 1428; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdby4", 10) == 0) - { -{ -return dev_storage + 1413; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdbx4", 10) == 0) - { -{ -return dev_storage + 1398; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdbw4", 10) == 0) - { -{ -return dev_storage + 1383; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdbv4", 10) == 0) - { -{ -return dev_storage + 1368; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdbu4", 10) == 0) - { -{ -return dev_storage + 1353; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdbt4", 10) == 0) - { -{ -return dev_storage + 1338; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdbs4", 10) == 0) - { -{ -return dev_storage + 1323; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdbr4", 10) == 0) - { -{ -return dev_storage + 1308; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdbq4", 10) == 0) - { -{ -return dev_storage + 1293; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdbp4", 10) == 0) - { -{ -return dev_storage + 1278; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdbo4", 10) == 0) - { -{ -return dev_storage + 1263; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdbn4", 10) == 0) - { -{ -return dev_storage + 1248; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdbm4", 10) == 0) - { -{ -return dev_storage + 1233; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdbl4", 10) == 0) - { -{ -return dev_storage + 1218; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdbk4", 10) == 0) - { -{ -return dev_storage + 1203; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdbj4", 10) == 0) - { -{ -return dev_storage + 1188; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdbi4", 10) == 0) - { -{ -return dev_storage + 1173; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdbh4", 10) == 0) - { -{ -return dev_storage + 1158; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdbg4", 10) == 0) - { -{ -return dev_storage + 1143; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdbf4", 10) == 0) - { -{ -return dev_storage + 1128; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdbe4", 10) == 0) - { -{ -return dev_storage + 1113; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdbd4", 10) == 0) - { -{ -return dev_storage + 1098; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdbc4", 10) == 0) - { -{ -return dev_storage + 1083; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbb4", 10) == 0) - { -{ -return dev_storage + 1068; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdba4", 10) == 0) - { -{ -return dev_storage + 1053; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdb14", 10) == 0) - { -{ -return dev_storage + 246; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'a': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdaz4", 10) == 0) - { -{ -return dev_storage + 1012; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sday4", 10) == 0) - { -{ -return dev_storage + 997; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdax4", 10) == 0) - { -{ -return dev_storage + 982; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdaw4", 10) == 0) - { -{ -return dev_storage + 967; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdav4", 10) == 0) - { -{ -return dev_storage + 952; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdau4", 10) == 0) - { -{ -return dev_storage + 937; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdat4", 10) == 0) - { -{ -return dev_storage + 922; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdas4", 10) == 0) - { -{ -return dev_storage + 907; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdar4", 10) == 0) - { -{ -return dev_storage + 892; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdaq4", 10) == 0) - { -{ -return dev_storage + 877; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdap4", 10) == 0) - { -{ -return dev_storage + 862; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdao4", 10) == 0) - { -{ -return dev_storage + 847; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdan4", 10) == 0) - { -{ -return dev_storage + 832; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdam4", 10) == 0) - { -{ -return dev_storage + 817; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdal4", 10) == 0) - { -{ -return dev_storage + 802; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdak4", 10) == 0) - { -{ -return dev_storage + 787; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdaj4", 10) == 0) - { -{ -return dev_storage + 772; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdai4", 10) == 0) - { -{ -return dev_storage + 757; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdah4", 10) == 0) - { -{ -return dev_storage + 742; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdag4", 10) == 0) - { -{ -return dev_storage + 727; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdaf4", 10) == 0) - { -{ -return dev_storage + 712; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdae4", 10) == 0) - { -{ -return dev_storage + 697; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdad4", 10) == 0) - { -{ -return dev_storage + 682; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdac4", 10) == 0) - { -{ -return dev_storage + 667; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdab4", 10) == 0) - { -{ -return dev_storage + 652; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaa4", 10) == 0) - { -{ -return dev_storage + 637; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sda14", 10) == 0) - { -{ -return dev_storage + 231; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [8]) - { - case '2': - if (strncmp (KR_keyword, "/dev/st124", 10) == 0) - { -{ -return dev_storage + 2380; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/st114", 10) == 0) - { -{ -return dev_storage + 2370; - -} - } - else - { -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/st104", 10) == 0) - { -{ -return dev_storage + 2360; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '3': - switch (KR_keyword [7]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdz13", 10) == 0) - { -{ -return dev_storage + 605; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - switch (KR_keyword [8]) - { - case 'S': - if (strncmp (KR_keyword, "/dev/ttyS3", 10) == 0) - { -{ -return dev_storage + 2452; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/tty63", 10) == 0) - { -{ -return dev_storage + 2448; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/tty53", 10) == 0) - { -{ -return dev_storage + 2438; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/tty43", 10) == 0) - { -{ -return dev_storage + 2428; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/tty33", 10) == 0) - { -{ -return dev_storage + 2418; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/tty23", 10) == 0) - { -{ -return dev_storage + 2408; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty13", 10) == 0) - { -{ -return dev_storage + 2398; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdy13", 10) == 0) - { -{ -return dev_storage + 590; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdx13", 10) == 0) - { -{ -return dev_storage + 575; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdw13", 10) == 0) - { -{ -return dev_storage + 560; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdv13", 10) == 0) - { -{ -return dev_storage + 545; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdu13", 10) == 0) - { -{ -return dev_storage + 530; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/nst93", 10) == 0) - { -{ -return dev_storage + 136; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/nst83", 10) == 0) - { -{ -return dev_storage + 126; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/nst73", 10) == 0) - { -{ -return dev_storage + 116; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/nst63", 10) == 0) - { -{ -return dev_storage + 106; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/nst53", 10) == 0) - { -{ -return dev_storage + 96; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/nst43", 10) == 0) - { -{ -return dev_storage + 86; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/nst33", 10) == 0) - { -{ -return dev_storage + 76; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/nst23", 10) == 0) - { -{ -return dev_storage + 66; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [5]) - { - case 's': - if (strncmp (KR_keyword, "/dev/sdt13", 10) == 0) - { -{ -return dev_storage + 515; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst13", 10) == 0) - { -{ -return dev_storage + 56; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sds13", 10) == 0) - { -{ -return dev_storage + 500; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdr13", 10) == 0) - { -{ -return dev_storage + 485; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdq13", 10) == 0) - { -{ -return dev_storage + 470; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdp13", 10) == 0) - { -{ -return dev_storage + 455; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdo13", 10) == 0) - { -{ -return dev_storage + 440; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdn13", 10) == 0) - { -{ -return dev_storage + 425; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - switch (KR_keyword [5]) - { - case 's': - if (strncmp (KR_keyword, "/dev/sdm13", 10) == 0) - { -{ -return dev_storage + 410; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/com13", 10) == 0) - { -{ -return dev_storage + 14; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdl13", 10) == 0) - { -{ -return dev_storage + 395; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdk13", 10) == 0) - { -{ -return dev_storage + 380; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdj13", 10) == 0) - { -{ -return dev_storage + 365; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdi13", 10) == 0) - { -{ -return dev_storage + 350; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdh13", 10) == 0) - { -{ -return dev_storage + 335; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdg13", 10) == 0) - { -{ -return dev_storage + 320; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdf13", 10) == 0) - { -{ -return dev_storage + 305; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sde13", 10) == 0) - { -{ -return dev_storage + 290; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - switch (KR_keyword [8]) - { - case 'x': - if (strncmp (KR_keyword, "/dev/sddx3", 10) == 0) - { -{ -return dev_storage + 2227; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sddw3", 10) == 0) - { -{ -return dev_storage + 2212; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sddv3", 10) == 0) - { -{ -return dev_storage + 2197; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sddu3", 10) == 0) - { -{ -return dev_storage + 2182; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sddt3", 10) == 0) - { -{ -return dev_storage + 2167; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdds3", 10) == 0) - { -{ -return dev_storage + 2152; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sddr3", 10) == 0) - { -{ -return dev_storage + 2137; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sddq3", 10) == 0) - { -{ -return dev_storage + 2122; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sddp3", 10) == 0) - { -{ -return dev_storage + 2107; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sddo3", 10) == 0) - { -{ -return dev_storage + 2092; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sddn3", 10) == 0) - { -{ -return dev_storage + 2077; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sddm3", 10) == 0) - { -{ -return dev_storage + 2062; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sddl3", 10) == 0) - { -{ -return dev_storage + 2047; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sddk3", 10) == 0) - { -{ -return dev_storage + 2032; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sddj3", 10) == 0) - { -{ -return dev_storage + 2017; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sddi3", 10) == 0) - { -{ -return dev_storage + 2002; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sddh3", 10) == 0) - { -{ -return dev_storage + 1987; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sddg3", 10) == 0) - { -{ -return dev_storage + 1972; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sddf3", 10) == 0) - { -{ -return dev_storage + 1957; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdde3", 10) == 0) - { -{ -return dev_storage + 1942; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sddd3", 10) == 0) - { -{ -return dev_storage + 1927; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sddc3", 10) == 0) - { -{ -return dev_storage + 1912; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sddb3", 10) == 0) - { -{ -return dev_storage + 1897; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdda3", 10) == 0) - { -{ -return dev_storage + 1882; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [6]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdd13", 10) == 0) - { -{ -return dev_storage + 275; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/scd13", 10) == 0) - { -{ -return dev_storage + 189; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'c': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdcz3", 10) == 0) - { -{ -return dev_storage + 1843; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdcy3", 10) == 0) - { -{ -return dev_storage + 1828; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdcx3", 10) == 0) - { -{ -return dev_storage + 1813; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdcw3", 10) == 0) - { -{ -return dev_storage + 1798; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdcv3", 10) == 0) - { -{ -return dev_storage + 1783; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdcu3", 10) == 0) - { -{ -return dev_storage + 1768; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdct3", 10) == 0) - { -{ -return dev_storage + 1753; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdcs3", 10) == 0) - { -{ -return dev_storage + 1738; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdcr3", 10) == 0) - { -{ -return dev_storage + 1723; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdcq3", 10) == 0) - { -{ -return dev_storage + 1708; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdcp3", 10) == 0) - { -{ -return dev_storage + 1693; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdco3", 10) == 0) - { -{ -return dev_storage + 1678; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdcn3", 10) == 0) - { -{ -return dev_storage + 1663; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdcm3", 10) == 0) - { -{ -return dev_storage + 1648; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdcl3", 10) == 0) - { -{ -return dev_storage + 1633; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdck3", 10) == 0) - { -{ -return dev_storage + 1618; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdcj3", 10) == 0) - { -{ -return dev_storage + 1603; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdci3", 10) == 0) - { -{ -return dev_storage + 1588; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdch3", 10) == 0) - { -{ -return dev_storage + 1573; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdcg3", 10) == 0) - { -{ -return dev_storage + 1558; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdcf3", 10) == 0) - { -{ -return dev_storage + 1543; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdce3", 10) == 0) - { -{ -return dev_storage + 1528; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdcd3", 10) == 0) - { -{ -return dev_storage + 1513; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcc3", 10) == 0) - { -{ -return dev_storage + 1498; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdcb3", 10) == 0) - { -{ -return dev_storage + 1483; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdca3", 10) == 0) - { -{ -return dev_storage + 1468; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdc13", 10) == 0) - { -{ -return dev_storage + 260; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'b': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdbz3", 10) == 0) - { -{ -return dev_storage + 1427; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdby3", 10) == 0) - { -{ -return dev_storage + 1412; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdbx3", 10) == 0) - { -{ -return dev_storage + 1397; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdbw3", 10) == 0) - { -{ -return dev_storage + 1382; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdbv3", 10) == 0) - { -{ -return dev_storage + 1367; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdbu3", 10) == 0) - { -{ -return dev_storage + 1352; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdbt3", 10) == 0) - { -{ -return dev_storage + 1337; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdbs3", 10) == 0) - { -{ -return dev_storage + 1322; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdbr3", 10) == 0) - { -{ -return dev_storage + 1307; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdbq3", 10) == 0) - { -{ -return dev_storage + 1292; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdbp3", 10) == 0) - { -{ -return dev_storage + 1277; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdbo3", 10) == 0) - { -{ -return dev_storage + 1262; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdbn3", 10) == 0) - { -{ -return dev_storage + 1247; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdbm3", 10) == 0) - { -{ -return dev_storage + 1232; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdbl3", 10) == 0) - { -{ -return dev_storage + 1217; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdbk3", 10) == 0) - { -{ -return dev_storage + 1202; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdbj3", 10) == 0) - { -{ -return dev_storage + 1187; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdbi3", 10) == 0) - { -{ -return dev_storage + 1172; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdbh3", 10) == 0) - { -{ -return dev_storage + 1157; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdbg3", 10) == 0) - { -{ -return dev_storage + 1142; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdbf3", 10) == 0) - { -{ -return dev_storage + 1127; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdbe3", 10) == 0) - { -{ -return dev_storage + 1112; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdbd3", 10) == 0) - { -{ -return dev_storage + 1097; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdbc3", 10) == 0) - { -{ -return dev_storage + 1082; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbb3", 10) == 0) - { -{ -return dev_storage + 1067; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdba3", 10) == 0) - { -{ -return dev_storage + 1052; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdb13", 10) == 0) - { -{ -return dev_storage + 245; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'a': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdaz3", 10) == 0) - { -{ -return dev_storage + 1011; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sday3", 10) == 0) - { -{ -return dev_storage + 996; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdax3", 10) == 0) - { -{ -return dev_storage + 981; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdaw3", 10) == 0) - { -{ -return dev_storage + 966; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdav3", 10) == 0) - { -{ -return dev_storage + 951; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdau3", 10) == 0) - { -{ -return dev_storage + 936; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdat3", 10) == 0) - { -{ -return dev_storage + 921; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdas3", 10) == 0) - { -{ -return dev_storage + 906; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdar3", 10) == 0) - { -{ -return dev_storage + 891; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdaq3", 10) == 0) - { -{ -return dev_storage + 876; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdap3", 10) == 0) - { -{ -return dev_storage + 861; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdao3", 10) == 0) - { -{ -return dev_storage + 846; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdan3", 10) == 0) - { -{ -return dev_storage + 831; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdam3", 10) == 0) - { -{ -return dev_storage + 816; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdal3", 10) == 0) - { -{ -return dev_storage + 801; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdak3", 10) == 0) - { -{ -return dev_storage + 786; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdaj3", 10) == 0) - { -{ -return dev_storage + 771; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdai3", 10) == 0) - { -{ -return dev_storage + 756; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdah3", 10) == 0) - { -{ -return dev_storage + 741; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdag3", 10) == 0) - { -{ -return dev_storage + 726; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdaf3", 10) == 0) - { -{ -return dev_storage + 711; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdae3", 10) == 0) - { -{ -return dev_storage + 696; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdad3", 10) == 0) - { -{ -return dev_storage + 681; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdac3", 10) == 0) - { -{ -return dev_storage + 666; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdab3", 10) == 0) - { -{ -return dev_storage + 651; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaa3", 10) == 0) - { -{ -return dev_storage + 636; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sda13", 10) == 0) - { -{ -return dev_storage + 230; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [8]) - { - case '2': - if (strncmp (KR_keyword, "/dev/st123", 10) == 0) - { -{ -return dev_storage + 2379; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/st113", 10) == 0) - { -{ -return dev_storage + 2369; - -} - } - else - { -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/st103", 10) == 0) - { -{ -return dev_storage + 2359; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '2': - switch (KR_keyword [7]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdz12", 10) == 0) - { -{ -return dev_storage + 604; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - switch (KR_keyword [8]) - { - case 'S': - if (strncmp (KR_keyword, "/dev/ttyS2", 10) == 0) - { -{ -return dev_storage + 2451; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/tty62", 10) == 0) - { -{ -return dev_storage + 2447; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/tty52", 10) == 0) - { -{ -return dev_storage + 2437; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/tty42", 10) == 0) - { -{ -return dev_storage + 2427; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/tty32", 10) == 0) - { -{ -return dev_storage + 2417; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/tty22", 10) == 0) - { -{ -return dev_storage + 2407; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty12", 10) == 0) - { -{ -return dev_storage + 2397; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdy12", 10) == 0) - { -{ -return dev_storage + 589; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdx12", 10) == 0) - { -{ -return dev_storage + 574; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdw12", 10) == 0) - { -{ -return dev_storage + 559; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdv12", 10) == 0) - { -{ -return dev_storage + 544; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdu12", 10) == 0) - { -{ -return dev_storage + 529; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/nst92", 10) == 0) - { -{ -return dev_storage + 135; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/nst82", 10) == 0) - { -{ -return dev_storage + 125; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/nst72", 10) == 0) - { -{ -return dev_storage + 115; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/nst62", 10) == 0) - { -{ -return dev_storage + 105; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/nst52", 10) == 0) - { -{ -return dev_storage + 95; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/nst42", 10) == 0) - { -{ -return dev_storage + 85; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/nst32", 10) == 0) - { -{ -return dev_storage + 75; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/nst22", 10) == 0) - { -{ -return dev_storage + 65; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [5]) - { - case 's': - if (strncmp (KR_keyword, "/dev/sdt12", 10) == 0) - { -{ -return dev_storage + 514; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst12", 10) == 0) - { -{ -return dev_storage + 55; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sds12", 10) == 0) - { -{ -return dev_storage + 499; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdr12", 10) == 0) - { -{ -return dev_storage + 484; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdq12", 10) == 0) - { -{ -return dev_storage + 469; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdp12", 10) == 0) - { -{ -return dev_storage + 454; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdo12", 10) == 0) - { -{ -return dev_storage + 439; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdn12", 10) == 0) - { -{ -return dev_storage + 424; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - switch (KR_keyword [5]) - { - case 's': - if (strncmp (KR_keyword, "/dev/sdm12", 10) == 0) - { -{ -return dev_storage + 409; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/com12", 10) == 0) - { -{ -return dev_storage + 13; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdl12", 10) == 0) - { -{ -return dev_storage + 394; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdk12", 10) == 0) - { -{ -return dev_storage + 379; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdj12", 10) == 0) - { -{ -return dev_storage + 364; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdi12", 10) == 0) - { -{ -return dev_storage + 349; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdh12", 10) == 0) - { -{ -return dev_storage + 334; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdg12", 10) == 0) - { -{ -return dev_storage + 319; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdf12", 10) == 0) - { -{ -return dev_storage + 304; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sde12", 10) == 0) - { -{ -return dev_storage + 289; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - switch (KR_keyword [8]) - { - case 'x': - if (strncmp (KR_keyword, "/dev/sddx2", 10) == 0) - { -{ -return dev_storage + 2226; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sddw2", 10) == 0) - { -{ -return dev_storage + 2211; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sddv2", 10) == 0) - { -{ -return dev_storage + 2196; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sddu2", 10) == 0) - { -{ -return dev_storage + 2181; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sddt2", 10) == 0) - { -{ -return dev_storage + 2166; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdds2", 10) == 0) - { -{ -return dev_storage + 2151; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sddr2", 10) == 0) - { -{ -return dev_storage + 2136; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sddq2", 10) == 0) - { -{ -return dev_storage + 2121; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sddp2", 10) == 0) - { -{ -return dev_storage + 2106; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sddo2", 10) == 0) - { -{ -return dev_storage + 2091; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sddn2", 10) == 0) - { -{ -return dev_storage + 2076; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sddm2", 10) == 0) - { -{ -return dev_storage + 2061; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sddl2", 10) == 0) - { -{ -return dev_storage + 2046; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sddk2", 10) == 0) - { -{ -return dev_storage + 2031; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sddj2", 10) == 0) - { -{ -return dev_storage + 2016; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sddi2", 10) == 0) - { -{ -return dev_storage + 2001; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sddh2", 10) == 0) - { -{ -return dev_storage + 1986; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sddg2", 10) == 0) - { -{ -return dev_storage + 1971; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sddf2", 10) == 0) - { -{ -return dev_storage + 1956; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdde2", 10) == 0) - { -{ -return dev_storage + 1941; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sddd2", 10) == 0) - { -{ -return dev_storage + 1926; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sddc2", 10) == 0) - { -{ -return dev_storage + 1911; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sddb2", 10) == 0) - { -{ -return dev_storage + 1896; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdda2", 10) == 0) - { -{ -return dev_storage + 1881; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [6]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdd12", 10) == 0) - { -{ -return dev_storage + 274; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/scd12", 10) == 0) - { -{ -return dev_storage + 188; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'c': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdcz2", 10) == 0) - { -{ -return dev_storage + 1842; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdcy2", 10) == 0) - { -{ -return dev_storage + 1827; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdcx2", 10) == 0) - { -{ -return dev_storage + 1812; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdcw2", 10) == 0) - { -{ -return dev_storage + 1797; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdcv2", 10) == 0) - { -{ -return dev_storage + 1782; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdcu2", 10) == 0) - { -{ -return dev_storage + 1767; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdct2", 10) == 0) - { -{ -return dev_storage + 1752; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdcs2", 10) == 0) - { -{ -return dev_storage + 1737; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdcr2", 10) == 0) - { -{ -return dev_storage + 1722; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdcq2", 10) == 0) - { -{ -return dev_storage + 1707; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdcp2", 10) == 0) - { -{ -return dev_storage + 1692; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdco2", 10) == 0) - { -{ -return dev_storage + 1677; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdcn2", 10) == 0) - { -{ -return dev_storage + 1662; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdcm2", 10) == 0) - { -{ -return dev_storage + 1647; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdcl2", 10) == 0) - { -{ -return dev_storage + 1632; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdck2", 10) == 0) - { -{ -return dev_storage + 1617; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdcj2", 10) == 0) - { -{ -return dev_storage + 1602; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdci2", 10) == 0) - { -{ -return dev_storage + 1587; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdch2", 10) == 0) - { -{ -return dev_storage + 1572; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdcg2", 10) == 0) - { -{ -return dev_storage + 1557; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdcf2", 10) == 0) - { -{ -return dev_storage + 1542; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdce2", 10) == 0) - { -{ -return dev_storage + 1527; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdcd2", 10) == 0) - { -{ -return dev_storage + 1512; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcc2", 10) == 0) - { -{ -return dev_storage + 1497; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdcb2", 10) == 0) - { -{ -return dev_storage + 1482; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdca2", 10) == 0) - { -{ -return dev_storage + 1467; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdc12", 10) == 0) - { -{ -return dev_storage + 259; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'b': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdbz2", 10) == 0) - { -{ -return dev_storage + 1426; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdby2", 10) == 0) - { -{ -return dev_storage + 1411; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdbx2", 10) == 0) - { -{ -return dev_storage + 1396; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdbw2", 10) == 0) - { -{ -return dev_storage + 1381; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdbv2", 10) == 0) - { -{ -return dev_storage + 1366; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdbu2", 10) == 0) - { -{ -return dev_storage + 1351; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdbt2", 10) == 0) - { -{ -return dev_storage + 1336; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdbs2", 10) == 0) - { -{ -return dev_storage + 1321; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdbr2", 10) == 0) - { -{ -return dev_storage + 1306; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdbq2", 10) == 0) - { -{ -return dev_storage + 1291; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdbp2", 10) == 0) - { -{ -return dev_storage + 1276; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdbo2", 10) == 0) - { -{ -return dev_storage + 1261; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdbn2", 10) == 0) - { -{ -return dev_storage + 1246; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdbm2", 10) == 0) - { -{ -return dev_storage + 1231; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdbl2", 10) == 0) - { -{ -return dev_storage + 1216; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdbk2", 10) == 0) - { -{ -return dev_storage + 1201; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdbj2", 10) == 0) - { -{ -return dev_storage + 1186; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdbi2", 10) == 0) - { -{ -return dev_storage + 1171; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdbh2", 10) == 0) - { -{ -return dev_storage + 1156; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdbg2", 10) == 0) - { -{ -return dev_storage + 1141; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdbf2", 10) == 0) - { -{ -return dev_storage + 1126; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdbe2", 10) == 0) - { -{ -return dev_storage + 1111; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdbd2", 10) == 0) - { -{ -return dev_storage + 1096; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdbc2", 10) == 0) - { -{ -return dev_storage + 1081; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbb2", 10) == 0) - { -{ -return dev_storage + 1066; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdba2", 10) == 0) - { -{ -return dev_storage + 1051; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdb12", 10) == 0) - { -{ -return dev_storage + 244; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'a': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdaz2", 10) == 0) - { -{ -return dev_storage + 1010; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sday2", 10) == 0) - { -{ -return dev_storage + 995; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdax2", 10) == 0) - { -{ -return dev_storage + 980; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdaw2", 10) == 0) - { -{ -return dev_storage + 965; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdav2", 10) == 0) - { -{ -return dev_storage + 950; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdau2", 10) == 0) - { -{ -return dev_storage + 935; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdat2", 10) == 0) - { -{ -return dev_storage + 920; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdas2", 10) == 0) - { -{ -return dev_storage + 905; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdar2", 10) == 0) - { -{ -return dev_storage + 890; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdaq2", 10) == 0) - { -{ -return dev_storage + 875; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdap2", 10) == 0) - { -{ -return dev_storage + 860; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdao2", 10) == 0) - { -{ -return dev_storage + 845; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdan2", 10) == 0) - { -{ -return dev_storage + 830; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdam2", 10) == 0) - { -{ -return dev_storage + 815; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdal2", 10) == 0) - { -{ -return dev_storage + 800; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdak2", 10) == 0) - { -{ -return dev_storage + 785; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdaj2", 10) == 0) - { -{ -return dev_storage + 770; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdai2", 10) == 0) - { -{ -return dev_storage + 755; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdah2", 10) == 0) - { -{ -return dev_storage + 740; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdag2", 10) == 0) - { -{ -return dev_storage + 725; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdaf2", 10) == 0) - { -{ -return dev_storage + 710; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdae2", 10) == 0) - { -{ -return dev_storage + 695; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdad2", 10) == 0) - { -{ -return dev_storage + 680; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdac2", 10) == 0) - { -{ -return dev_storage + 665; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdab2", 10) == 0) - { -{ -return dev_storage + 650; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaa2", 10) == 0) - { -{ -return dev_storage + 635; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sda12", 10) == 0) - { -{ -return dev_storage + 229; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [8]) - { - case '2': - if (strncmp (KR_keyword, "/dev/st122", 10) == 0) - { -{ -return dev_storage + 2378; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/st112", 10) == 0) - { -{ -return dev_storage + 2368; - -} - } - else - { -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/st102", 10) == 0) - { -{ -return dev_storage + 2358; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [7]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdz11", 10) == 0) - { -{ -return dev_storage + 603; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - switch (KR_keyword [8]) - { - case 'S': - if (strncmp (KR_keyword, "/dev/ttyS1", 10) == 0) - { -{ -return dev_storage + 2450; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/tty61", 10) == 0) - { -{ -return dev_storage + 2446; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/tty51", 10) == 0) - { -{ -return dev_storage + 2436; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/tty41", 10) == 0) - { -{ -return dev_storage + 2426; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/tty31", 10) == 0) - { -{ -return dev_storage + 2416; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/tty21", 10) == 0) - { -{ -return dev_storage + 2406; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty11", 10) == 0) - { -{ -return dev_storage + 2396; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdy11", 10) == 0) - { -{ -return dev_storage + 588; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdx11", 10) == 0) - { -{ -return dev_storage + 573; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdw11", 10) == 0) - { -{ -return dev_storage + 558; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdv11", 10) == 0) - { -{ -return dev_storage + 543; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdu11", 10) == 0) - { -{ -return dev_storage + 528; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/nst91", 10) == 0) - { -{ -return dev_storage + 134; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/nst81", 10) == 0) - { -{ -return dev_storage + 124; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/nst71", 10) == 0) - { -{ -return dev_storage + 114; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/nst61", 10) == 0) - { -{ -return dev_storage + 104; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/nst51", 10) == 0) - { -{ -return dev_storage + 94; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/nst41", 10) == 0) - { -{ -return dev_storage + 84; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/nst31", 10) == 0) - { -{ -return dev_storage + 74; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/nst21", 10) == 0) - { -{ -return dev_storage + 64; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [5]) - { - case 's': - if (strncmp (KR_keyword, "/dev/sdt11", 10) == 0) - { -{ -return dev_storage + 513; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst11", 10) == 0) - { -{ -return dev_storage + 54; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sds11", 10) == 0) - { -{ -return dev_storage + 498; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdr11", 10) == 0) - { -{ -return dev_storage + 483; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdq11", 10) == 0) - { -{ -return dev_storage + 468; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdp11", 10) == 0) - { -{ -return dev_storage + 453; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdo11", 10) == 0) - { -{ -return dev_storage + 438; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdn11", 10) == 0) - { -{ -return dev_storage + 423; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - switch (KR_keyword [5]) - { - case 's': - if (strncmp (KR_keyword, "/dev/sdm11", 10) == 0) - { -{ -return dev_storage + 408; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/com11", 10) == 0) - { -{ -return dev_storage + 12; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdl11", 10) == 0) - { -{ -return dev_storage + 393; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdk11", 10) == 0) - { -{ -return dev_storage + 378; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdj11", 10) == 0) - { -{ -return dev_storage + 363; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdi11", 10) == 0) - { -{ -return dev_storage + 348; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdh11", 10) == 0) - { -{ -return dev_storage + 333; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdg11", 10) == 0) - { -{ -return dev_storage + 318; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdf11", 10) == 0) - { -{ -return dev_storage + 303; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sde11", 10) == 0) - { -{ -return dev_storage + 288; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - switch (KR_keyword [8]) - { - case 'x': - if (strncmp (KR_keyword, "/dev/sddx1", 10) == 0) - { -{ -return dev_storage + 2225; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sddw1", 10) == 0) - { -{ -return dev_storage + 2210; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sddv1", 10) == 0) - { -{ -return dev_storage + 2195; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sddu1", 10) == 0) - { -{ -return dev_storage + 2180; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sddt1", 10) == 0) - { -{ -return dev_storage + 2165; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdds1", 10) == 0) - { -{ -return dev_storage + 2150; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sddr1", 10) == 0) - { -{ -return dev_storage + 2135; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sddq1", 10) == 0) - { -{ -return dev_storage + 2120; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sddp1", 10) == 0) - { -{ -return dev_storage + 2105; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sddo1", 10) == 0) - { -{ -return dev_storage + 2090; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sddn1", 10) == 0) - { -{ -return dev_storage + 2075; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sddm1", 10) == 0) - { -{ -return dev_storage + 2060; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sddl1", 10) == 0) - { -{ -return dev_storage + 2045; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sddk1", 10) == 0) - { -{ -return dev_storage + 2030; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sddj1", 10) == 0) - { -{ -return dev_storage + 2015; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sddi1", 10) == 0) - { -{ -return dev_storage + 2000; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sddh1", 10) == 0) - { -{ -return dev_storage + 1985; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sddg1", 10) == 0) - { -{ -return dev_storage + 1970; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sddf1", 10) == 0) - { -{ -return dev_storage + 1955; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdde1", 10) == 0) - { -{ -return dev_storage + 1940; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sddd1", 10) == 0) - { -{ -return dev_storage + 1925; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sddc1", 10) == 0) - { -{ -return dev_storage + 1910; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sddb1", 10) == 0) - { -{ -return dev_storage + 1895; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdda1", 10) == 0) - { -{ -return dev_storage + 1880; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [6]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdd11", 10) == 0) - { -{ -return dev_storage + 273; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/scd11", 10) == 0) - { -{ -return dev_storage + 187; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'c': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdcz1", 10) == 0) - { -{ -return dev_storage + 1841; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdcy1", 10) == 0) - { -{ -return dev_storage + 1826; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdcx1", 10) == 0) - { -{ -return dev_storage + 1811; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdcw1", 10) == 0) - { -{ -return dev_storage + 1796; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdcv1", 10) == 0) - { -{ -return dev_storage + 1781; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdcu1", 10) == 0) - { -{ -return dev_storage + 1766; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdct1", 10) == 0) - { -{ -return dev_storage + 1751; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdcs1", 10) == 0) - { -{ -return dev_storage + 1736; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdcr1", 10) == 0) - { -{ -return dev_storage + 1721; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdcq1", 10) == 0) - { -{ -return dev_storage + 1706; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdcp1", 10) == 0) - { -{ -return dev_storage + 1691; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdco1", 10) == 0) - { -{ -return dev_storage + 1676; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdcn1", 10) == 0) - { -{ -return dev_storage + 1661; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdcm1", 10) == 0) - { -{ -return dev_storage + 1646; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdcl1", 10) == 0) - { -{ -return dev_storage + 1631; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdck1", 10) == 0) - { -{ -return dev_storage + 1616; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdcj1", 10) == 0) - { -{ -return dev_storage + 1601; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdci1", 10) == 0) - { -{ -return dev_storage + 1586; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdch1", 10) == 0) - { -{ -return dev_storage + 1571; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdcg1", 10) == 0) - { -{ -return dev_storage + 1556; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdcf1", 10) == 0) - { -{ -return dev_storage + 1541; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdce1", 10) == 0) - { -{ -return dev_storage + 1526; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdcd1", 10) == 0) - { -{ -return dev_storage + 1511; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcc1", 10) == 0) - { -{ -return dev_storage + 1496; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdcb1", 10) == 0) - { -{ -return dev_storage + 1481; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdca1", 10) == 0) - { -{ -return dev_storage + 1466; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdc11", 10) == 0) - { -{ -return dev_storage + 258; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'b': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdbz1", 10) == 0) - { -{ -return dev_storage + 1425; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdby1", 10) == 0) - { -{ -return dev_storage + 1410; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdbx1", 10) == 0) - { -{ -return dev_storage + 1395; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdbw1", 10) == 0) - { -{ -return dev_storage + 1380; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdbv1", 10) == 0) - { -{ -return dev_storage + 1365; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdbu1", 10) == 0) - { -{ -return dev_storage + 1350; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdbt1", 10) == 0) - { -{ -return dev_storage + 1335; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdbs1", 10) == 0) - { -{ -return dev_storage + 1320; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdbr1", 10) == 0) - { -{ -return dev_storage + 1305; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdbq1", 10) == 0) - { -{ -return dev_storage + 1290; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdbp1", 10) == 0) - { -{ -return dev_storage + 1275; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdbo1", 10) == 0) - { -{ -return dev_storage + 1260; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdbn1", 10) == 0) - { -{ -return dev_storage + 1245; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdbm1", 10) == 0) - { -{ -return dev_storage + 1230; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdbl1", 10) == 0) - { -{ -return dev_storage + 1215; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdbk1", 10) == 0) - { -{ -return dev_storage + 1200; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdbj1", 10) == 0) - { -{ -return dev_storage + 1185; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdbi1", 10) == 0) - { -{ -return dev_storage + 1170; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdbh1", 10) == 0) - { -{ -return dev_storage + 1155; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdbg1", 10) == 0) - { -{ -return dev_storage + 1140; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdbf1", 10) == 0) - { -{ -return dev_storage + 1125; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdbe1", 10) == 0) - { -{ -return dev_storage + 1110; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdbd1", 10) == 0) - { -{ -return dev_storage + 1095; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdbc1", 10) == 0) - { -{ -return dev_storage + 1080; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbb1", 10) == 0) - { -{ -return dev_storage + 1065; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdba1", 10) == 0) - { -{ -return dev_storage + 1050; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sdb11", 10) == 0) - { -{ -return dev_storage + 243; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'a': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdaz1", 10) == 0) - { -{ -return dev_storage + 1009; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sday1", 10) == 0) - { -{ -return dev_storage + 994; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdax1", 10) == 0) - { -{ -return dev_storage + 979; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdaw1", 10) == 0) - { -{ -return dev_storage + 964; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdav1", 10) == 0) - { -{ -return dev_storage + 949; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdau1", 10) == 0) - { -{ -return dev_storage + 934; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdat1", 10) == 0) - { -{ -return dev_storage + 919; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdas1", 10) == 0) - { -{ -return dev_storage + 904; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdar1", 10) == 0) - { -{ -return dev_storage + 889; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdaq1", 10) == 0) - { -{ -return dev_storage + 874; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdap1", 10) == 0) - { -{ -return dev_storage + 859; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdao1", 10) == 0) - { -{ -return dev_storage + 844; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdan1", 10) == 0) - { -{ -return dev_storage + 829; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdam1", 10) == 0) - { -{ -return dev_storage + 814; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdal1", 10) == 0) - { -{ -return dev_storage + 799; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdak1", 10) == 0) - { -{ -return dev_storage + 784; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdaj1", 10) == 0) - { -{ -return dev_storage + 769; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdai1", 10) == 0) - { -{ -return dev_storage + 754; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdah1", 10) == 0) - { -{ -return dev_storage + 739; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdag1", 10) == 0) - { -{ -return dev_storage + 724; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdaf1", 10) == 0) - { -{ -return dev_storage + 709; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdae1", 10) == 0) - { -{ -return dev_storage + 694; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdad1", 10) == 0) - { -{ -return dev_storage + 679; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdac1", 10) == 0) - { -{ -return dev_storage + 664; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdab1", 10) == 0) - { -{ -return dev_storage + 649; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaa1", 10) == 0) - { -{ -return dev_storage + 634; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/sda11", 10) == 0) - { -{ -return dev_storage + 228; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [8]) - { - case '2': - if (strncmp (KR_keyword, "/dev/st121", 10) == 0) - { -{ -return dev_storage + 2377; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/st111", 10) == 0) - { -{ -return dev_storage + 2367; - -} - } - else - { -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/st101", 10) == 0) - { -{ -return dev_storage + 2357; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '0': - switch (KR_keyword [7]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdz10", 10) == 0) - { -{ -return dev_storage + 602; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - switch (KR_keyword [8]) - { - case 'S': - if (strncmp (KR_keyword, "/dev/ttyS0", 10) == 0) - { -{ -return dev_storage + 2449; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/tty60", 10) == 0) - { -{ -return dev_storage + 2445; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/tty50", 10) == 0) - { -{ -return dev_storage + 2435; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/tty40", 10) == 0) - { -{ -return dev_storage + 2425; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/tty30", 10) == 0) - { -{ -return dev_storage + 2415; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/tty20", 10) == 0) - { -{ -return dev_storage + 2405; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/tty10", 10) == 0) - { -{ -return dev_storage + 2395; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdy10", 10) == 0) - { -{ -return dev_storage + 587; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdx10", 10) == 0) - { -{ -return dev_storage + 572; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdw10", 10) == 0) - { -{ -return dev_storage + 557; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdv10", 10) == 0) - { -{ -return dev_storage + 542; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdu10", 10) == 0) - { -{ -return dev_storage + 527; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - switch (KR_keyword [8]) - { - case '9': - if (strncmp (KR_keyword, "/dev/nst90", 10) == 0) - { -{ -return dev_storage + 133; - -} - } - else - { -{ -return NULL; - -} - } - case '8': - if (strncmp (KR_keyword, "/dev/nst80", 10) == 0) - { -{ -return dev_storage + 123; - -} - } - else - { -{ -return NULL; - -} - } - case '7': - if (strncmp (KR_keyword, "/dev/nst70", 10) == 0) - { -{ -return dev_storage + 113; - -} - } - else - { -{ -return NULL; - -} - } - case '6': - if (strncmp (KR_keyword, "/dev/nst60", 10) == 0) - { -{ -return dev_storage + 103; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/nst50", 10) == 0) - { -{ -return dev_storage + 93; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/nst40", 10) == 0) - { -{ -return dev_storage + 83; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/nst30", 10) == 0) - { -{ -return dev_storage + 73; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/nst20", 10) == 0) - { -{ -return dev_storage + 63; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [5]) - { - case 's': - if (strncmp (KR_keyword, "/dev/sdt10", 10) == 0) - { -{ -return dev_storage + 512; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst10", 10) == 0) - { -{ -return dev_storage + 53; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sds10", 10) == 0) - { -{ -return dev_storage + 497; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdr10", 10) == 0) - { -{ -return dev_storage + 482; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdq10", 10) == 0) - { -{ -return dev_storage + 467; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdp10", 10) == 0) - { -{ -return dev_storage + 452; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdo10", 10) == 0) - { -{ -return dev_storage + 437; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdn10", 10) == 0) - { -{ -return dev_storage + 422; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - switch (KR_keyword [5]) - { - case 's': - if (strncmp (KR_keyword, "/dev/sdm10", 10) == 0) - { -{ -return dev_storage + 407; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/com10", 10) == 0) - { -{ -return dev_storage + 11; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdl10", 10) == 0) - { -{ -return dev_storage + 392; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdk10", 10) == 0) - { -{ -return dev_storage + 377; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdj10", 10) == 0) - { -{ -return dev_storage + 362; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdi10", 10) == 0) - { -{ -return dev_storage + 347; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdh10", 10) == 0) - { -{ -return dev_storage + 332; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdg10", 10) == 0) - { -{ -return dev_storage + 317; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdf10", 10) == 0) - { -{ -return dev_storage + 302; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sde10", 10) == 0) - { -{ -return dev_storage + 287; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - switch (KR_keyword [6]) - { - case 'd': - if (strncmp (KR_keyword, "/dev/sdd10", 10) == 0) - { -{ -return dev_storage + 272; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/scd10", 10) == 0) - { -{ -return dev_storage + 186; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdc10", 10) == 0) - { -{ -return dev_storage + 257; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdb10", 10) == 0) - { -{ -return dev_storage + 242; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sda10", 10) == 0) - { -{ -return dev_storage + 227; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [8]) - { - case '2': - if (strncmp (KR_keyword, "/dev/st120", 10) == 0) - { -{ -return dev_storage + 2376; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/st110", 10) == 0) - { -{ -return dev_storage + 2366; - -} - } - else - { -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/st100", 10) == 0) - { -{ -return dev_storage + 2356; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 11: - switch (KR_keyword [10]) - { - case 't': - if (strncmp (KR_keyword, "/dev/conout", 11) == 0) - { -{ -return dev_storage + 19; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/random", 11) == 0) - { -{ -return dev_storage + 175; - -} - } - else - { -{ -return NULL; - -} - } - case '9': - switch (KR_keyword [9]) - { - case '5': - if (strncmp (KR_keyword, "/dev/ttyS59", 11) == 0) - { -{ -return dev_storage + 2508; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/ttyS49", 11) == 0) - { -{ -return dev_storage + 2498; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/ttyS39", 11) == 0) - { -{ -return dev_storage + 2488; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/ttyS29", 11) == 0) - { -{ -return dev_storage + 2478; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/ttyS19", 11) == 0) - { -{ -return dev_storage + 2468; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst119", 11) == 0) - { -{ -return dev_storage + 162; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/nst109", 11) == 0) - { -{ -return dev_storage + 152; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '8': - switch (KR_keyword [9]) - { - case '5': - if (strncmp (KR_keyword, "/dev/ttyS58", 11) == 0) - { -{ -return dev_storage + 2507; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/ttyS48", 11) == 0) - { -{ -return dev_storage + 2497; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/ttyS38", 11) == 0) - { -{ -return dev_storage + 2487; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/ttyS28", 11) == 0) - { -{ -return dev_storage + 2477; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/ttyS18", 11) == 0) - { -{ -return dev_storage + 2467; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst118", 11) == 0) - { -{ -return dev_storage + 161; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/nst108", 11) == 0) - { -{ -return dev_storage + 151; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '7': - switch (KR_keyword [9]) - { - case '5': - if (strncmp (KR_keyword, "/dev/ttyS57", 11) == 0) - { -{ -return dev_storage + 2506; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/ttyS47", 11) == 0) - { -{ -return dev_storage + 2496; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/ttyS37", 11) == 0) - { -{ -return dev_storage + 2486; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/ttyS27", 11) == 0) - { -{ -return dev_storage + 2476; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst127", 11) == 0) - { -{ -return dev_storage + 170; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/ttyS17", 11) == 0) - { -{ -return dev_storage + 2466; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst117", 11) == 0) - { -{ -return dev_storage + 160; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/nst107", 11) == 0) - { -{ -return dev_storage + 150; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '6': - switch (KR_keyword [9]) - { - case '5': - if (strncmp (KR_keyword, "/dev/ttyS56", 11) == 0) - { -{ -return dev_storage + 2505; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/ttyS46", 11) == 0) - { -{ -return dev_storage + 2495; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/ttyS36", 11) == 0) - { -{ -return dev_storage + 2485; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/ttyS26", 11) == 0) - { -{ -return dev_storage + 2475; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst126", 11) == 0) - { -{ -return dev_storage + 169; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [5]) - { - case 't': - if (strncmp (KR_keyword, "/dev/ttyS16", 11) == 0) - { -{ -return dev_storage + 2465; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/nst116", 11) == 0) - { -{ -return dev_storage + 159; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/nst106", 11) == 0) - { -{ -return dev_storage + 149; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '5': - switch (KR_keyword [7]) - { - case 'y': - switch (KR_keyword [9]) - { - case '5': - if (strncmp (KR_keyword, "/dev/ttyS55", 11) == 0) - { -{ -return dev_storage + 2504; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/ttyS45", 11) == 0) - { -{ -return dev_storage + 2494; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/ttyS35", 11) == 0) - { -{ -return dev_storage + 2484; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/ttyS25", 11) == 0) - { -{ -return dev_storage + 2474; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/ttyS15", 11) == 0) - { -{ -return dev_storage + 2464; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 't': - switch (KR_keyword [9]) - { - case '2': - if (strncmp (KR_keyword, "/dev/nst125", 11) == 0) - { -{ -return dev_storage + 168; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/nst115", 11) == 0) - { -{ -return dev_storage + 158; - -} - } - else - { -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/nst105", 11) == 0) - { -{ -return dev_storage + 148; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'd': - switch (KR_keyword [8]) - { - case 'x': - if (strncmp (KR_keyword, "/dev/sddx15", 11) == 0) - { -{ -return dev_storage + 2239; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sddw15", 11) == 0) - { -{ -return dev_storage + 2224; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sddv15", 11) == 0) - { -{ -return dev_storage + 2209; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sddu15", 11) == 0) - { -{ -return dev_storage + 2194; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sddt15", 11) == 0) - { -{ -return dev_storage + 2179; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdds15", 11) == 0) - { -{ -return dev_storage + 2164; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sddr15", 11) == 0) - { -{ -return dev_storage + 2149; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sddq15", 11) == 0) - { -{ -return dev_storage + 2134; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sddp15", 11) == 0) - { -{ -return dev_storage + 2119; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sddo15", 11) == 0) - { -{ -return dev_storage + 2104; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sddn15", 11) == 0) - { -{ -return dev_storage + 2089; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sddm15", 11) == 0) - { -{ -return dev_storage + 2074; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sddl15", 11) == 0) - { -{ -return dev_storage + 2059; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sddk15", 11) == 0) - { -{ -return dev_storage + 2044; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sddj15", 11) == 0) - { -{ -return dev_storage + 2029; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sddi15", 11) == 0) - { -{ -return dev_storage + 2014; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sddh15", 11) == 0) - { -{ -return dev_storage + 1999; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sddg15", 11) == 0) - { -{ -return dev_storage + 1984; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sddf15", 11) == 0) - { -{ -return dev_storage + 1969; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdde15", 11) == 0) - { -{ -return dev_storage + 1954; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sddd15", 11) == 0) - { -{ -return dev_storage + 1939; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sddc15", 11) == 0) - { -{ -return dev_storage + 1924; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sddb15", 11) == 0) - { -{ -return dev_storage + 1909; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdda15", 11) == 0) - { -{ -return dev_storage + 1894; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'c': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdcz15", 11) == 0) - { -{ -return dev_storage + 1855; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdcy15", 11) == 0) - { -{ -return dev_storage + 1840; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdcx15", 11) == 0) - { -{ -return dev_storage + 1825; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdcw15", 11) == 0) - { -{ -return dev_storage + 1810; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdcv15", 11) == 0) - { -{ -return dev_storage + 1795; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdcu15", 11) == 0) - { -{ -return dev_storage + 1780; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdct15", 11) == 0) - { -{ -return dev_storage + 1765; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdcs15", 11) == 0) - { -{ -return dev_storage + 1750; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdcr15", 11) == 0) - { -{ -return dev_storage + 1735; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdcq15", 11) == 0) - { -{ -return dev_storage + 1720; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdcp15", 11) == 0) - { -{ -return dev_storage + 1705; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdco15", 11) == 0) - { -{ -return dev_storage + 1690; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdcn15", 11) == 0) - { -{ -return dev_storage + 1675; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdcm15", 11) == 0) - { -{ -return dev_storage + 1660; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdcl15", 11) == 0) - { -{ -return dev_storage + 1645; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdck15", 11) == 0) - { -{ -return dev_storage + 1630; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdcj15", 11) == 0) - { -{ -return dev_storage + 1615; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdci15", 11) == 0) - { -{ -return dev_storage + 1600; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdch15", 11) == 0) - { -{ -return dev_storage + 1585; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdcg15", 11) == 0) - { -{ -return dev_storage + 1570; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdcf15", 11) == 0) - { -{ -return dev_storage + 1555; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdce15", 11) == 0) - { -{ -return dev_storage + 1540; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdcd15", 11) == 0) - { -{ -return dev_storage + 1525; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcc15", 11) == 0) - { -{ -return dev_storage + 1510; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdcb15", 11) == 0) - { -{ -return dev_storage + 1495; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdca15", 11) == 0) - { -{ -return dev_storage + 1480; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'b': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdbz15", 11) == 0) - { -{ -return dev_storage + 1439; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdby15", 11) == 0) - { -{ -return dev_storage + 1424; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdbx15", 11) == 0) - { -{ -return dev_storage + 1409; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdbw15", 11) == 0) - { -{ -return dev_storage + 1394; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdbv15", 11) == 0) - { -{ -return dev_storage + 1379; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdbu15", 11) == 0) - { -{ -return dev_storage + 1364; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdbt15", 11) == 0) - { -{ -return dev_storage + 1349; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdbs15", 11) == 0) - { -{ -return dev_storage + 1334; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdbr15", 11) == 0) - { -{ -return dev_storage + 1319; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdbq15", 11) == 0) - { -{ -return dev_storage + 1304; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdbp15", 11) == 0) - { -{ -return dev_storage + 1289; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdbo15", 11) == 0) - { -{ -return dev_storage + 1274; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdbn15", 11) == 0) - { -{ -return dev_storage + 1259; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdbm15", 11) == 0) - { -{ -return dev_storage + 1244; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdbl15", 11) == 0) - { -{ -return dev_storage + 1229; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdbk15", 11) == 0) - { -{ -return dev_storage + 1214; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdbj15", 11) == 0) - { -{ -return dev_storage + 1199; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdbi15", 11) == 0) - { -{ -return dev_storage + 1184; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdbh15", 11) == 0) - { -{ -return dev_storage + 1169; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdbg15", 11) == 0) - { -{ -return dev_storage + 1154; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdbf15", 11) == 0) - { -{ -return dev_storage + 1139; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdbe15", 11) == 0) - { -{ -return dev_storage + 1124; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdbd15", 11) == 0) - { -{ -return dev_storage + 1109; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdbc15", 11) == 0) - { -{ -return dev_storage + 1094; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbb15", 11) == 0) - { -{ -return dev_storage + 1079; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdba15", 11) == 0) - { -{ -return dev_storage + 1064; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'a': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdaz15", 11) == 0) - { -{ -return dev_storage + 1023; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sday15", 11) == 0) - { -{ -return dev_storage + 1008; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdax15", 11) == 0) - { -{ -return dev_storage + 993; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdaw15", 11) == 0) - { -{ -return dev_storage + 978; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdav15", 11) == 0) - { -{ -return dev_storage + 963; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdau15", 11) == 0) - { -{ -return dev_storage + 948; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdat15", 11) == 0) - { -{ -return dev_storage + 933; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdas15", 11) == 0) - { -{ -return dev_storage + 918; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdar15", 11) == 0) - { -{ -return dev_storage + 903; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdaq15", 11) == 0) - { -{ -return dev_storage + 888; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdap15", 11) == 0) - { -{ -return dev_storage + 873; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdao15", 11) == 0) - { -{ -return dev_storage + 858; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdan15", 11) == 0) - { -{ -return dev_storage + 843; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdam15", 11) == 0) - { -{ -return dev_storage + 828; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdal15", 11) == 0) - { -{ -return dev_storage + 813; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdak15", 11) == 0) - { -{ -return dev_storage + 798; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdaj15", 11) == 0) - { -{ -return dev_storage + 783; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdai15", 11) == 0) - { -{ -return dev_storage + 768; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdah15", 11) == 0) - { -{ -return dev_storage + 753; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdag15", 11) == 0) - { -{ -return dev_storage + 738; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdaf15", 11) == 0) - { -{ -return dev_storage + 723; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdae15", 11) == 0) - { -{ -return dev_storage + 708; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdad15", 11) == 0) - { -{ -return dev_storage + 693; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdac15", 11) == 0) - { -{ -return dev_storage + 678; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdab15", 11) == 0) - { -{ -return dev_storage + 663; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaa15", 11) == 0) - { -{ -return dev_storage + 648; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '4': - switch (KR_keyword [7]) - { - case 'y': - switch (KR_keyword [9]) - { - case '5': - if (strncmp (KR_keyword, "/dev/ttyS54", 11) == 0) - { -{ -return dev_storage + 2503; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/ttyS44", 11) == 0) - { -{ -return dev_storage + 2493; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/ttyS34", 11) == 0) - { -{ -return dev_storage + 2483; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/ttyS24", 11) == 0) - { -{ -return dev_storage + 2473; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/ttyS14", 11) == 0) - { -{ -return dev_storage + 2463; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 't': - switch (KR_keyword [9]) - { - case '2': - if (strncmp (KR_keyword, "/dev/nst124", 11) == 0) - { -{ -return dev_storage + 167; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/nst114", 11) == 0) - { -{ -return dev_storage + 157; - -} - } - else - { -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/nst104", 11) == 0) - { -{ -return dev_storage + 147; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'd': - switch (KR_keyword [8]) - { - case 'x': - if (strncmp (KR_keyword, "/dev/sddx14", 11) == 0) - { -{ -return dev_storage + 2238; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sddw14", 11) == 0) - { -{ -return dev_storage + 2223; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sddv14", 11) == 0) - { -{ -return dev_storage + 2208; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sddu14", 11) == 0) - { -{ -return dev_storage + 2193; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sddt14", 11) == 0) - { -{ -return dev_storage + 2178; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdds14", 11) == 0) - { -{ -return dev_storage + 2163; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sddr14", 11) == 0) - { -{ -return dev_storage + 2148; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sddq14", 11) == 0) - { -{ -return dev_storage + 2133; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sddp14", 11) == 0) - { -{ -return dev_storage + 2118; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sddo14", 11) == 0) - { -{ -return dev_storage + 2103; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sddn14", 11) == 0) - { -{ -return dev_storage + 2088; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sddm14", 11) == 0) - { -{ -return dev_storage + 2073; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sddl14", 11) == 0) - { -{ -return dev_storage + 2058; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sddk14", 11) == 0) - { -{ -return dev_storage + 2043; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sddj14", 11) == 0) - { -{ -return dev_storage + 2028; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sddi14", 11) == 0) - { -{ -return dev_storage + 2013; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sddh14", 11) == 0) - { -{ -return dev_storage + 1998; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sddg14", 11) == 0) - { -{ -return dev_storage + 1983; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sddf14", 11) == 0) - { -{ -return dev_storage + 1968; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdde14", 11) == 0) - { -{ -return dev_storage + 1953; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sddd14", 11) == 0) - { -{ -return dev_storage + 1938; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sddc14", 11) == 0) - { -{ -return dev_storage + 1923; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sddb14", 11) == 0) - { -{ -return dev_storage + 1908; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdda14", 11) == 0) - { -{ -return dev_storage + 1893; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'c': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdcz14", 11) == 0) - { -{ -return dev_storage + 1854; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdcy14", 11) == 0) - { -{ -return dev_storage + 1839; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdcx14", 11) == 0) - { -{ -return dev_storage + 1824; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdcw14", 11) == 0) - { -{ -return dev_storage + 1809; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdcv14", 11) == 0) - { -{ -return dev_storage + 1794; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdcu14", 11) == 0) - { -{ -return dev_storage + 1779; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdct14", 11) == 0) - { -{ -return dev_storage + 1764; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdcs14", 11) == 0) - { -{ -return dev_storage + 1749; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdcr14", 11) == 0) - { -{ -return dev_storage + 1734; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdcq14", 11) == 0) - { -{ -return dev_storage + 1719; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdcp14", 11) == 0) - { -{ -return dev_storage + 1704; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdco14", 11) == 0) - { -{ -return dev_storage + 1689; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdcn14", 11) == 0) - { -{ -return dev_storage + 1674; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdcm14", 11) == 0) - { -{ -return dev_storage + 1659; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdcl14", 11) == 0) - { -{ -return dev_storage + 1644; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdck14", 11) == 0) - { -{ -return dev_storage + 1629; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdcj14", 11) == 0) - { -{ -return dev_storage + 1614; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdci14", 11) == 0) - { -{ -return dev_storage + 1599; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdch14", 11) == 0) - { -{ -return dev_storage + 1584; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdcg14", 11) == 0) - { -{ -return dev_storage + 1569; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdcf14", 11) == 0) - { -{ -return dev_storage + 1554; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdce14", 11) == 0) - { -{ -return dev_storage + 1539; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdcd14", 11) == 0) - { -{ -return dev_storage + 1524; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcc14", 11) == 0) - { -{ -return dev_storage + 1509; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdcb14", 11) == 0) - { -{ -return dev_storage + 1494; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdca14", 11) == 0) - { -{ -return dev_storage + 1479; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'b': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdbz14", 11) == 0) - { -{ -return dev_storage + 1438; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdby14", 11) == 0) - { -{ -return dev_storage + 1423; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdbx14", 11) == 0) - { -{ -return dev_storage + 1408; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdbw14", 11) == 0) - { -{ -return dev_storage + 1393; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdbv14", 11) == 0) - { -{ -return dev_storage + 1378; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdbu14", 11) == 0) - { -{ -return dev_storage + 1363; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdbt14", 11) == 0) - { -{ -return dev_storage + 1348; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdbs14", 11) == 0) - { -{ -return dev_storage + 1333; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdbr14", 11) == 0) - { -{ -return dev_storage + 1318; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdbq14", 11) == 0) - { -{ -return dev_storage + 1303; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdbp14", 11) == 0) - { -{ -return dev_storage + 1288; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdbo14", 11) == 0) - { -{ -return dev_storage + 1273; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdbn14", 11) == 0) - { -{ -return dev_storage + 1258; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdbm14", 11) == 0) - { -{ -return dev_storage + 1243; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdbl14", 11) == 0) - { -{ -return dev_storage + 1228; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdbk14", 11) == 0) - { -{ -return dev_storage + 1213; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdbj14", 11) == 0) - { -{ -return dev_storage + 1198; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdbi14", 11) == 0) - { -{ -return dev_storage + 1183; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdbh14", 11) == 0) - { -{ -return dev_storage + 1168; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdbg14", 11) == 0) - { -{ -return dev_storage + 1153; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdbf14", 11) == 0) - { -{ -return dev_storage + 1138; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdbe14", 11) == 0) - { -{ -return dev_storage + 1123; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdbd14", 11) == 0) - { -{ -return dev_storage + 1108; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdbc14", 11) == 0) - { -{ -return dev_storage + 1093; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbb14", 11) == 0) - { -{ -return dev_storage + 1078; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdba14", 11) == 0) - { -{ -return dev_storage + 1063; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'a': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdaz14", 11) == 0) - { -{ -return dev_storage + 1022; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sday14", 11) == 0) - { -{ -return dev_storage + 1007; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdax14", 11) == 0) - { -{ -return dev_storage + 992; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdaw14", 11) == 0) - { -{ -return dev_storage + 977; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdav14", 11) == 0) - { -{ -return dev_storage + 962; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdau14", 11) == 0) - { -{ -return dev_storage + 947; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdat14", 11) == 0) - { -{ -return dev_storage + 932; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdas14", 11) == 0) - { -{ -return dev_storage + 917; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdar14", 11) == 0) - { -{ -return dev_storage + 902; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdaq14", 11) == 0) - { -{ -return dev_storage + 887; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdap14", 11) == 0) - { -{ -return dev_storage + 872; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdao14", 11) == 0) - { -{ -return dev_storage + 857; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdan14", 11) == 0) - { -{ -return dev_storage + 842; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdam14", 11) == 0) - { -{ -return dev_storage + 827; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdal14", 11) == 0) - { -{ -return dev_storage + 812; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdak14", 11) == 0) - { -{ -return dev_storage + 797; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdaj14", 11) == 0) - { -{ -return dev_storage + 782; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdai14", 11) == 0) - { -{ -return dev_storage + 767; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdah14", 11) == 0) - { -{ -return dev_storage + 752; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdag14", 11) == 0) - { -{ -return dev_storage + 737; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdaf14", 11) == 0) - { -{ -return dev_storage + 722; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdae14", 11) == 0) - { -{ -return dev_storage + 707; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdad14", 11) == 0) - { -{ -return dev_storage + 692; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdac14", 11) == 0) - { -{ -return dev_storage + 677; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdab14", 11) == 0) - { -{ -return dev_storage + 662; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaa14", 11) == 0) - { -{ -return dev_storage + 647; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '3': - switch (KR_keyword [7]) - { - case 'y': - switch (KR_keyword [9]) - { - case '6': - if (strncmp (KR_keyword, "/dev/ttyS63", 11) == 0) - { -{ -return dev_storage + 2512; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/ttyS53", 11) == 0) - { -{ -return dev_storage + 2502; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/ttyS43", 11) == 0) - { -{ -return dev_storage + 2492; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/ttyS33", 11) == 0) - { -{ -return dev_storage + 2482; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/ttyS23", 11) == 0) - { -{ -return dev_storage + 2472; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/ttyS13", 11) == 0) - { -{ -return dev_storage + 2462; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 't': - switch (KR_keyword [9]) - { - case '2': - if (strncmp (KR_keyword, "/dev/nst123", 11) == 0) - { -{ -return dev_storage + 166; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/nst113", 11) == 0) - { -{ -return dev_storage + 156; - -} - } - else - { -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/nst103", 11) == 0) - { -{ -return dev_storage + 146; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'd': - switch (KR_keyword [8]) - { - case 'x': - if (strncmp (KR_keyword, "/dev/sddx13", 11) == 0) - { -{ -return dev_storage + 2237; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sddw13", 11) == 0) - { -{ -return dev_storage + 2222; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sddv13", 11) == 0) - { -{ -return dev_storage + 2207; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sddu13", 11) == 0) - { -{ -return dev_storage + 2192; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sddt13", 11) == 0) - { -{ -return dev_storage + 2177; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdds13", 11) == 0) - { -{ -return dev_storage + 2162; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sddr13", 11) == 0) - { -{ -return dev_storage + 2147; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sddq13", 11) == 0) - { -{ -return dev_storage + 2132; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sddp13", 11) == 0) - { -{ -return dev_storage + 2117; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sddo13", 11) == 0) - { -{ -return dev_storage + 2102; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sddn13", 11) == 0) - { -{ -return dev_storage + 2087; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sddm13", 11) == 0) - { -{ -return dev_storage + 2072; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sddl13", 11) == 0) - { -{ -return dev_storage + 2057; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sddk13", 11) == 0) - { -{ -return dev_storage + 2042; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sddj13", 11) == 0) - { -{ -return dev_storage + 2027; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sddi13", 11) == 0) - { -{ -return dev_storage + 2012; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sddh13", 11) == 0) - { -{ -return dev_storage + 1997; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sddg13", 11) == 0) - { -{ -return dev_storage + 1982; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sddf13", 11) == 0) - { -{ -return dev_storage + 1967; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdde13", 11) == 0) - { -{ -return dev_storage + 1952; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sddd13", 11) == 0) - { -{ -return dev_storage + 1937; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sddc13", 11) == 0) - { -{ -return dev_storage + 1922; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sddb13", 11) == 0) - { -{ -return dev_storage + 1907; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdda13", 11) == 0) - { -{ -return dev_storage + 1892; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'c': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdcz13", 11) == 0) - { -{ -return dev_storage + 1853; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdcy13", 11) == 0) - { -{ -return dev_storage + 1838; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdcx13", 11) == 0) - { -{ -return dev_storage + 1823; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdcw13", 11) == 0) - { -{ -return dev_storage + 1808; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdcv13", 11) == 0) - { -{ -return dev_storage + 1793; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdcu13", 11) == 0) - { -{ -return dev_storage + 1778; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdct13", 11) == 0) - { -{ -return dev_storage + 1763; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdcs13", 11) == 0) - { -{ -return dev_storage + 1748; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdcr13", 11) == 0) - { -{ -return dev_storage + 1733; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdcq13", 11) == 0) - { -{ -return dev_storage + 1718; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdcp13", 11) == 0) - { -{ -return dev_storage + 1703; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdco13", 11) == 0) - { -{ -return dev_storage + 1688; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdcn13", 11) == 0) - { -{ -return dev_storage + 1673; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdcm13", 11) == 0) - { -{ -return dev_storage + 1658; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdcl13", 11) == 0) - { -{ -return dev_storage + 1643; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdck13", 11) == 0) - { -{ -return dev_storage + 1628; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdcj13", 11) == 0) - { -{ -return dev_storage + 1613; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdci13", 11) == 0) - { -{ -return dev_storage + 1598; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdch13", 11) == 0) - { -{ -return dev_storage + 1583; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdcg13", 11) == 0) - { -{ -return dev_storage + 1568; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdcf13", 11) == 0) - { -{ -return dev_storage + 1553; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdce13", 11) == 0) - { -{ -return dev_storage + 1538; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdcd13", 11) == 0) - { -{ -return dev_storage + 1523; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcc13", 11) == 0) - { -{ -return dev_storage + 1508; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdcb13", 11) == 0) - { -{ -return dev_storage + 1493; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdca13", 11) == 0) - { -{ -return dev_storage + 1478; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'b': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdbz13", 11) == 0) - { -{ -return dev_storage + 1437; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdby13", 11) == 0) - { -{ -return dev_storage + 1422; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdbx13", 11) == 0) - { -{ -return dev_storage + 1407; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdbw13", 11) == 0) - { -{ -return dev_storage + 1392; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdbv13", 11) == 0) - { -{ -return dev_storage + 1377; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdbu13", 11) == 0) - { -{ -return dev_storage + 1362; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdbt13", 11) == 0) - { -{ -return dev_storage + 1347; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdbs13", 11) == 0) - { -{ -return dev_storage + 1332; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdbr13", 11) == 0) - { -{ -return dev_storage + 1317; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdbq13", 11) == 0) - { -{ -return dev_storage + 1302; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdbp13", 11) == 0) - { -{ -return dev_storage + 1287; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdbo13", 11) == 0) - { -{ -return dev_storage + 1272; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdbn13", 11) == 0) - { -{ -return dev_storage + 1257; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdbm13", 11) == 0) - { -{ -return dev_storage + 1242; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdbl13", 11) == 0) - { -{ -return dev_storage + 1227; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdbk13", 11) == 0) - { -{ -return dev_storage + 1212; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdbj13", 11) == 0) - { -{ -return dev_storage + 1197; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdbi13", 11) == 0) - { -{ -return dev_storage + 1182; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdbh13", 11) == 0) - { -{ -return dev_storage + 1167; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdbg13", 11) == 0) - { -{ -return dev_storage + 1152; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdbf13", 11) == 0) - { -{ -return dev_storage + 1137; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdbe13", 11) == 0) - { -{ -return dev_storage + 1122; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdbd13", 11) == 0) - { -{ -return dev_storage + 1107; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdbc13", 11) == 0) - { -{ -return dev_storage + 1092; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbb13", 11) == 0) - { -{ -return dev_storage + 1077; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdba13", 11) == 0) - { -{ -return dev_storage + 1062; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'a': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdaz13", 11) == 0) - { -{ -return dev_storage + 1021; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sday13", 11) == 0) - { -{ -return dev_storage + 1006; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdax13", 11) == 0) - { -{ -return dev_storage + 991; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdaw13", 11) == 0) - { -{ -return dev_storage + 976; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdav13", 11) == 0) - { -{ -return dev_storage + 961; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdau13", 11) == 0) - { -{ -return dev_storage + 946; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdat13", 11) == 0) - { -{ -return dev_storage + 931; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdas13", 11) == 0) - { -{ -return dev_storage + 916; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdar13", 11) == 0) - { -{ -return dev_storage + 901; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdaq13", 11) == 0) - { -{ -return dev_storage + 886; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdap13", 11) == 0) - { -{ -return dev_storage + 871; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdao13", 11) == 0) - { -{ -return dev_storage + 856; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdan13", 11) == 0) - { -{ -return dev_storage + 841; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdam13", 11) == 0) - { -{ -return dev_storage + 826; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdal13", 11) == 0) - { -{ -return dev_storage + 811; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdak13", 11) == 0) - { -{ -return dev_storage + 796; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdaj13", 11) == 0) - { -{ -return dev_storage + 781; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdai13", 11) == 0) - { -{ -return dev_storage + 766; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdah13", 11) == 0) - { -{ -return dev_storage + 751; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdag13", 11) == 0) - { -{ -return dev_storage + 736; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdaf13", 11) == 0) - { -{ -return dev_storage + 721; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdae13", 11) == 0) - { -{ -return dev_storage + 706; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdad13", 11) == 0) - { -{ -return dev_storage + 691; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdac13", 11) == 0) - { -{ -return dev_storage + 676; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdab13", 11) == 0) - { -{ -return dev_storage + 661; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaa13", 11) == 0) - { -{ -return dev_storage + 646; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '2': - switch (KR_keyword [7]) - { - case 'y': - switch (KR_keyword [9]) - { - case '6': - if (strncmp (KR_keyword, "/dev/ttyS62", 11) == 0) - { -{ -return dev_storage + 2511; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/ttyS52", 11) == 0) - { -{ -return dev_storage + 2501; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/ttyS42", 11) == 0) - { -{ -return dev_storage + 2491; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/ttyS32", 11) == 0) - { -{ -return dev_storage + 2481; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/ttyS22", 11) == 0) - { -{ -return dev_storage + 2471; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/ttyS12", 11) == 0) - { -{ -return dev_storage + 2461; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 't': - switch (KR_keyword [9]) - { - case '2': - if (strncmp (KR_keyword, "/dev/nst122", 11) == 0) - { -{ -return dev_storage + 165; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/nst112", 11) == 0) - { -{ -return dev_storage + 155; - -} - } - else - { -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/nst102", 11) == 0) - { -{ -return dev_storage + 145; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'd': - switch (KR_keyword [8]) - { - case 'x': - if (strncmp (KR_keyword, "/dev/sddx12", 11) == 0) - { -{ -return dev_storage + 2236; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sddw12", 11) == 0) - { -{ -return dev_storage + 2221; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sddv12", 11) == 0) - { -{ -return dev_storage + 2206; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sddu12", 11) == 0) - { -{ -return dev_storage + 2191; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sddt12", 11) == 0) - { -{ -return dev_storage + 2176; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdds12", 11) == 0) - { -{ -return dev_storage + 2161; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sddr12", 11) == 0) - { -{ -return dev_storage + 2146; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sddq12", 11) == 0) - { -{ -return dev_storage + 2131; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sddp12", 11) == 0) - { -{ -return dev_storage + 2116; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sddo12", 11) == 0) - { -{ -return dev_storage + 2101; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sddn12", 11) == 0) - { -{ -return dev_storage + 2086; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sddm12", 11) == 0) - { -{ -return dev_storage + 2071; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sddl12", 11) == 0) - { -{ -return dev_storage + 2056; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sddk12", 11) == 0) - { -{ -return dev_storage + 2041; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sddj12", 11) == 0) - { -{ -return dev_storage + 2026; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sddi12", 11) == 0) - { -{ -return dev_storage + 2011; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sddh12", 11) == 0) - { -{ -return dev_storage + 1996; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sddg12", 11) == 0) - { -{ -return dev_storage + 1981; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sddf12", 11) == 0) - { -{ -return dev_storage + 1966; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdde12", 11) == 0) - { -{ -return dev_storage + 1951; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sddd12", 11) == 0) - { -{ -return dev_storage + 1936; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sddc12", 11) == 0) - { -{ -return dev_storage + 1921; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sddb12", 11) == 0) - { -{ -return dev_storage + 1906; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdda12", 11) == 0) - { -{ -return dev_storage + 1891; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'c': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdcz12", 11) == 0) - { -{ -return dev_storage + 1852; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdcy12", 11) == 0) - { -{ -return dev_storage + 1837; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdcx12", 11) == 0) - { -{ -return dev_storage + 1822; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdcw12", 11) == 0) - { -{ -return dev_storage + 1807; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdcv12", 11) == 0) - { -{ -return dev_storage + 1792; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdcu12", 11) == 0) - { -{ -return dev_storage + 1777; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdct12", 11) == 0) - { -{ -return dev_storage + 1762; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdcs12", 11) == 0) - { -{ -return dev_storage + 1747; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdcr12", 11) == 0) - { -{ -return dev_storage + 1732; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdcq12", 11) == 0) - { -{ -return dev_storage + 1717; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdcp12", 11) == 0) - { -{ -return dev_storage + 1702; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdco12", 11) == 0) - { -{ -return dev_storage + 1687; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdcn12", 11) == 0) - { -{ -return dev_storage + 1672; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdcm12", 11) == 0) - { -{ -return dev_storage + 1657; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdcl12", 11) == 0) - { -{ -return dev_storage + 1642; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdck12", 11) == 0) - { -{ -return dev_storage + 1627; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdcj12", 11) == 0) - { -{ -return dev_storage + 1612; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdci12", 11) == 0) - { -{ -return dev_storage + 1597; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdch12", 11) == 0) - { -{ -return dev_storage + 1582; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdcg12", 11) == 0) - { -{ -return dev_storage + 1567; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdcf12", 11) == 0) - { -{ -return dev_storage + 1552; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdce12", 11) == 0) - { -{ -return dev_storage + 1537; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdcd12", 11) == 0) - { -{ -return dev_storage + 1522; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcc12", 11) == 0) - { -{ -return dev_storage + 1507; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdcb12", 11) == 0) - { -{ -return dev_storage + 1492; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdca12", 11) == 0) - { -{ -return dev_storage + 1477; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'b': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdbz12", 11) == 0) - { -{ -return dev_storage + 1436; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdby12", 11) == 0) - { -{ -return dev_storage + 1421; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdbx12", 11) == 0) - { -{ -return dev_storage + 1406; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdbw12", 11) == 0) - { -{ -return dev_storage + 1391; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdbv12", 11) == 0) - { -{ -return dev_storage + 1376; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdbu12", 11) == 0) - { -{ -return dev_storage + 1361; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdbt12", 11) == 0) - { -{ -return dev_storage + 1346; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdbs12", 11) == 0) - { -{ -return dev_storage + 1331; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdbr12", 11) == 0) - { -{ -return dev_storage + 1316; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdbq12", 11) == 0) - { -{ -return dev_storage + 1301; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdbp12", 11) == 0) - { -{ -return dev_storage + 1286; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdbo12", 11) == 0) - { -{ -return dev_storage + 1271; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdbn12", 11) == 0) - { -{ -return dev_storage + 1256; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdbm12", 11) == 0) - { -{ -return dev_storage + 1241; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdbl12", 11) == 0) - { -{ -return dev_storage + 1226; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdbk12", 11) == 0) - { -{ -return dev_storage + 1211; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdbj12", 11) == 0) - { -{ -return dev_storage + 1196; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdbi12", 11) == 0) - { -{ -return dev_storage + 1181; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdbh12", 11) == 0) - { -{ -return dev_storage + 1166; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdbg12", 11) == 0) - { -{ -return dev_storage + 1151; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdbf12", 11) == 0) - { -{ -return dev_storage + 1136; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdbe12", 11) == 0) - { -{ -return dev_storage + 1121; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdbd12", 11) == 0) - { -{ -return dev_storage + 1106; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdbc12", 11) == 0) - { -{ -return dev_storage + 1091; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbb12", 11) == 0) - { -{ -return dev_storage + 1076; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdba12", 11) == 0) - { -{ -return dev_storage + 1061; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'a': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdaz12", 11) == 0) - { -{ -return dev_storage + 1020; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sday12", 11) == 0) - { -{ -return dev_storage + 1005; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdax12", 11) == 0) - { -{ -return dev_storage + 990; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdaw12", 11) == 0) - { -{ -return dev_storage + 975; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdav12", 11) == 0) - { -{ -return dev_storage + 960; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdau12", 11) == 0) - { -{ -return dev_storage + 945; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdat12", 11) == 0) - { -{ -return dev_storage + 930; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdas12", 11) == 0) - { -{ -return dev_storage + 915; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdar12", 11) == 0) - { -{ -return dev_storage + 900; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdaq12", 11) == 0) - { -{ -return dev_storage + 885; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdap12", 11) == 0) - { -{ -return dev_storage + 870; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdao12", 11) == 0) - { -{ -return dev_storage + 855; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdan12", 11) == 0) - { -{ -return dev_storage + 840; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdam12", 11) == 0) - { -{ -return dev_storage + 825; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdal12", 11) == 0) - { -{ -return dev_storage + 810; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdak12", 11) == 0) - { -{ -return dev_storage + 795; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdaj12", 11) == 0) - { -{ -return dev_storage + 780; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdai12", 11) == 0) - { -{ -return dev_storage + 765; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdah12", 11) == 0) - { -{ -return dev_storage + 750; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdag12", 11) == 0) - { -{ -return dev_storage + 735; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdaf12", 11) == 0) - { -{ -return dev_storage + 720; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdae12", 11) == 0) - { -{ -return dev_storage + 705; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdad12", 11) == 0) - { -{ -return dev_storage + 690; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdac12", 11) == 0) - { -{ -return dev_storage + 675; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdab12", 11) == 0) - { -{ -return dev_storage + 660; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaa12", 11) == 0) - { -{ -return dev_storage + 645; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '1': - switch (KR_keyword [7]) - { - case 'y': - switch (KR_keyword [9]) - { - case '6': - if (strncmp (KR_keyword, "/dev/ttyS61", 11) == 0) - { -{ -return dev_storage + 2510; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/ttyS51", 11) == 0) - { -{ -return dev_storage + 2500; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/ttyS41", 11) == 0) - { -{ -return dev_storage + 2490; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/ttyS31", 11) == 0) - { -{ -return dev_storage + 2480; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/ttyS21", 11) == 0) - { -{ -return dev_storage + 2470; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/ttyS11", 11) == 0) - { -{ -return dev_storage + 2460; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 't': - switch (KR_keyword [9]) - { - case '2': - if (strncmp (KR_keyword, "/dev/nst121", 11) == 0) - { -{ -return dev_storage + 164; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/nst111", 11) == 0) - { -{ -return dev_storage + 154; - -} - } - else - { -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/nst101", 11) == 0) - { -{ -return dev_storage + 144; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'd': - switch (KR_keyword [8]) - { - case 'x': - if (strncmp (KR_keyword, "/dev/sddx11", 11) == 0) - { -{ -return dev_storage + 2235; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sddw11", 11) == 0) - { -{ -return dev_storage + 2220; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sddv11", 11) == 0) - { -{ -return dev_storage + 2205; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sddu11", 11) == 0) - { -{ -return dev_storage + 2190; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sddt11", 11) == 0) - { -{ -return dev_storage + 2175; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdds11", 11) == 0) - { -{ -return dev_storage + 2160; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sddr11", 11) == 0) - { -{ -return dev_storage + 2145; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sddq11", 11) == 0) - { -{ -return dev_storage + 2130; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sddp11", 11) == 0) - { -{ -return dev_storage + 2115; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sddo11", 11) == 0) - { -{ -return dev_storage + 2100; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sddn11", 11) == 0) - { -{ -return dev_storage + 2085; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sddm11", 11) == 0) - { -{ -return dev_storage + 2070; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sddl11", 11) == 0) - { -{ -return dev_storage + 2055; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sddk11", 11) == 0) - { -{ -return dev_storage + 2040; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sddj11", 11) == 0) - { -{ -return dev_storage + 2025; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sddi11", 11) == 0) - { -{ -return dev_storage + 2010; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sddh11", 11) == 0) - { -{ -return dev_storage + 1995; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sddg11", 11) == 0) - { -{ -return dev_storage + 1980; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sddf11", 11) == 0) - { -{ -return dev_storage + 1965; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdde11", 11) == 0) - { -{ -return dev_storage + 1950; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sddd11", 11) == 0) - { -{ -return dev_storage + 1935; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sddc11", 11) == 0) - { -{ -return dev_storage + 1920; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sddb11", 11) == 0) - { -{ -return dev_storage + 1905; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdda11", 11) == 0) - { -{ -return dev_storage + 1890; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'c': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdcz11", 11) == 0) - { -{ -return dev_storage + 1851; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdcy11", 11) == 0) - { -{ -return dev_storage + 1836; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdcx11", 11) == 0) - { -{ -return dev_storage + 1821; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdcw11", 11) == 0) - { -{ -return dev_storage + 1806; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdcv11", 11) == 0) - { -{ -return dev_storage + 1791; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdcu11", 11) == 0) - { -{ -return dev_storage + 1776; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdct11", 11) == 0) - { -{ -return dev_storage + 1761; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdcs11", 11) == 0) - { -{ -return dev_storage + 1746; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdcr11", 11) == 0) - { -{ -return dev_storage + 1731; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdcq11", 11) == 0) - { -{ -return dev_storage + 1716; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdcp11", 11) == 0) - { -{ -return dev_storage + 1701; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdco11", 11) == 0) - { -{ -return dev_storage + 1686; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdcn11", 11) == 0) - { -{ -return dev_storage + 1671; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdcm11", 11) == 0) - { -{ -return dev_storage + 1656; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdcl11", 11) == 0) - { -{ -return dev_storage + 1641; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdck11", 11) == 0) - { -{ -return dev_storage + 1626; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdcj11", 11) == 0) - { -{ -return dev_storage + 1611; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdci11", 11) == 0) - { -{ -return dev_storage + 1596; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdch11", 11) == 0) - { -{ -return dev_storage + 1581; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdcg11", 11) == 0) - { -{ -return dev_storage + 1566; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdcf11", 11) == 0) - { -{ -return dev_storage + 1551; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdce11", 11) == 0) - { -{ -return dev_storage + 1536; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdcd11", 11) == 0) - { -{ -return dev_storage + 1521; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcc11", 11) == 0) - { -{ -return dev_storage + 1506; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdcb11", 11) == 0) - { -{ -return dev_storage + 1491; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdca11", 11) == 0) - { -{ -return dev_storage + 1476; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'b': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdbz11", 11) == 0) - { -{ -return dev_storage + 1435; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdby11", 11) == 0) - { -{ -return dev_storage + 1420; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdbx11", 11) == 0) - { -{ -return dev_storage + 1405; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdbw11", 11) == 0) - { -{ -return dev_storage + 1390; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdbv11", 11) == 0) - { -{ -return dev_storage + 1375; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdbu11", 11) == 0) - { -{ -return dev_storage + 1360; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdbt11", 11) == 0) - { -{ -return dev_storage + 1345; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdbs11", 11) == 0) - { -{ -return dev_storage + 1330; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdbr11", 11) == 0) - { -{ -return dev_storage + 1315; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdbq11", 11) == 0) - { -{ -return dev_storage + 1300; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdbp11", 11) == 0) - { -{ -return dev_storage + 1285; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdbo11", 11) == 0) - { -{ -return dev_storage + 1270; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdbn11", 11) == 0) - { -{ -return dev_storage + 1255; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdbm11", 11) == 0) - { -{ -return dev_storage + 1240; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdbl11", 11) == 0) - { -{ -return dev_storage + 1225; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdbk11", 11) == 0) - { -{ -return dev_storage + 1210; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdbj11", 11) == 0) - { -{ -return dev_storage + 1195; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdbi11", 11) == 0) - { -{ -return dev_storage + 1180; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdbh11", 11) == 0) - { -{ -return dev_storage + 1165; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdbg11", 11) == 0) - { -{ -return dev_storage + 1150; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdbf11", 11) == 0) - { -{ -return dev_storage + 1135; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdbe11", 11) == 0) - { -{ -return dev_storage + 1120; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdbd11", 11) == 0) - { -{ -return dev_storage + 1105; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdbc11", 11) == 0) - { -{ -return dev_storage + 1090; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbb11", 11) == 0) - { -{ -return dev_storage + 1075; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdba11", 11) == 0) - { -{ -return dev_storage + 1060; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'a': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdaz11", 11) == 0) - { -{ -return dev_storage + 1019; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sday11", 11) == 0) - { -{ -return dev_storage + 1004; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdax11", 11) == 0) - { -{ -return dev_storage + 989; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdaw11", 11) == 0) - { -{ -return dev_storage + 974; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdav11", 11) == 0) - { -{ -return dev_storage + 959; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdau11", 11) == 0) - { -{ -return dev_storage + 944; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdat11", 11) == 0) - { -{ -return dev_storage + 929; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdas11", 11) == 0) - { -{ -return dev_storage + 914; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdar11", 11) == 0) - { -{ -return dev_storage + 899; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdaq11", 11) == 0) - { -{ -return dev_storage + 884; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdap11", 11) == 0) - { -{ -return dev_storage + 869; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdao11", 11) == 0) - { -{ -return dev_storage + 854; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdan11", 11) == 0) - { -{ -return dev_storage + 839; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdam11", 11) == 0) - { -{ -return dev_storage + 824; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdal11", 11) == 0) - { -{ -return dev_storage + 809; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdak11", 11) == 0) - { -{ -return dev_storage + 794; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdaj11", 11) == 0) - { -{ -return dev_storage + 779; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdai11", 11) == 0) - { -{ -return dev_storage + 764; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdah11", 11) == 0) - { -{ -return dev_storage + 749; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdag11", 11) == 0) - { -{ -return dev_storage + 734; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdaf11", 11) == 0) - { -{ -return dev_storage + 719; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdae11", 11) == 0) - { -{ -return dev_storage + 704; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdad11", 11) == 0) - { -{ -return dev_storage + 689; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdac11", 11) == 0) - { -{ -return dev_storage + 674; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdab11", 11) == 0) - { -{ -return dev_storage + 659; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaa11", 11) == 0) - { -{ -return dev_storage + 644; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case '0': - switch (KR_keyword [7]) - { - case 'y': - switch (KR_keyword [9]) - { - case '6': - if (strncmp (KR_keyword, "/dev/ttyS60", 11) == 0) - { -{ -return dev_storage + 2509; - -} - } - else - { -{ -return NULL; - -} - } - case '5': - if (strncmp (KR_keyword, "/dev/ttyS50", 11) == 0) - { -{ -return dev_storage + 2499; - -} - } - else - { -{ -return NULL; - -} - } - case '4': - if (strncmp (KR_keyword, "/dev/ttyS40", 11) == 0) - { -{ -return dev_storage + 2489; - -} - } - else - { -{ -return NULL; - -} - } - case '3': - if (strncmp (KR_keyword, "/dev/ttyS30", 11) == 0) - { -{ -return dev_storage + 2479; - -} - } - else - { -{ -return NULL; - -} - } - case '2': - if (strncmp (KR_keyword, "/dev/ttyS20", 11) == 0) - { -{ -return dev_storage + 2469; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/ttyS10", 11) == 0) - { -{ -return dev_storage + 2459; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 't': - switch (KR_keyword [9]) - { - case '2': - if (strncmp (KR_keyword, "/dev/nst120", 11) == 0) - { -{ -return dev_storage + 163; - -} - } - else - { -{ -return NULL; - -} - } - case '1': - if (strncmp (KR_keyword, "/dev/nst110", 11) == 0) - { -{ -return dev_storage + 153; - -} - } - else - { -{ -return NULL; - -} - } - case '0': - if (strncmp (KR_keyword, "/dev/nst100", 11) == 0) - { -{ -return dev_storage + 143; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'd': - switch (KR_keyword [8]) - { - case 'x': - if (strncmp (KR_keyword, "/dev/sddx10", 11) == 0) - { -{ -return dev_storage + 2234; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sddw10", 11) == 0) - { -{ -return dev_storage + 2219; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sddv10", 11) == 0) - { -{ -return dev_storage + 2204; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sddu10", 11) == 0) - { -{ -return dev_storage + 2189; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sddt10", 11) == 0) - { -{ -return dev_storage + 2174; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdds10", 11) == 0) - { -{ -return dev_storage + 2159; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sddr10", 11) == 0) - { -{ -return dev_storage + 2144; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sddq10", 11) == 0) - { -{ -return dev_storage + 2129; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sddp10", 11) == 0) - { -{ -return dev_storage + 2114; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sddo10", 11) == 0) - { -{ -return dev_storage + 2099; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sddn10", 11) == 0) - { -{ -return dev_storage + 2084; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sddm10", 11) == 0) - { -{ -return dev_storage + 2069; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sddl10", 11) == 0) - { -{ -return dev_storage + 2054; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sddk10", 11) == 0) - { -{ -return dev_storage + 2039; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sddj10", 11) == 0) - { -{ -return dev_storage + 2024; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sddi10", 11) == 0) - { -{ -return dev_storage + 2009; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sddh10", 11) == 0) - { -{ -return dev_storage + 1994; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sddg10", 11) == 0) - { -{ -return dev_storage + 1979; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sddf10", 11) == 0) - { -{ -return dev_storage + 1964; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdde10", 11) == 0) - { -{ -return dev_storage + 1949; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sddd10", 11) == 0) - { -{ -return dev_storage + 1934; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sddc10", 11) == 0) - { -{ -return dev_storage + 1919; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sddb10", 11) == 0) - { -{ -return dev_storage + 1904; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdda10", 11) == 0) - { -{ -return dev_storage + 1889; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'c': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdcz10", 11) == 0) - { -{ -return dev_storage + 1850; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdcy10", 11) == 0) - { -{ -return dev_storage + 1835; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdcx10", 11) == 0) - { -{ -return dev_storage + 1820; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdcw10", 11) == 0) - { -{ -return dev_storage + 1805; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdcv10", 11) == 0) - { -{ -return dev_storage + 1790; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdcu10", 11) == 0) - { -{ -return dev_storage + 1775; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdct10", 11) == 0) - { -{ -return dev_storage + 1760; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdcs10", 11) == 0) - { -{ -return dev_storage + 1745; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdcr10", 11) == 0) - { -{ -return dev_storage + 1730; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdcq10", 11) == 0) - { -{ -return dev_storage + 1715; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdcp10", 11) == 0) - { -{ -return dev_storage + 1700; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdco10", 11) == 0) - { -{ -return dev_storage + 1685; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdcn10", 11) == 0) - { -{ -return dev_storage + 1670; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdcm10", 11) == 0) - { -{ -return dev_storage + 1655; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdcl10", 11) == 0) - { -{ -return dev_storage + 1640; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdck10", 11) == 0) - { -{ -return dev_storage + 1625; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdcj10", 11) == 0) - { -{ -return dev_storage + 1610; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdci10", 11) == 0) - { -{ -return dev_storage + 1595; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdch10", 11) == 0) - { -{ -return dev_storage + 1580; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdcg10", 11) == 0) - { -{ -return dev_storage + 1565; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdcf10", 11) == 0) - { -{ -return dev_storage + 1550; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdce10", 11) == 0) - { -{ -return dev_storage + 1535; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdcd10", 11) == 0) - { -{ -return dev_storage + 1520; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdcc10", 11) == 0) - { -{ -return dev_storage + 1505; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdcb10", 11) == 0) - { -{ -return dev_storage + 1490; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdca10", 11) == 0) - { -{ -return dev_storage + 1475; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'b': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdbz10", 11) == 0) - { -{ -return dev_storage + 1434; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sdby10", 11) == 0) - { -{ -return dev_storage + 1419; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdbx10", 11) == 0) - { -{ -return dev_storage + 1404; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdbw10", 11) == 0) - { -{ -return dev_storage + 1389; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdbv10", 11) == 0) - { -{ -return dev_storage + 1374; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdbu10", 11) == 0) - { -{ -return dev_storage + 1359; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdbt10", 11) == 0) - { -{ -return dev_storage + 1344; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdbs10", 11) == 0) - { -{ -return dev_storage + 1329; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdbr10", 11) == 0) - { -{ -return dev_storage + 1314; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdbq10", 11) == 0) - { -{ -return dev_storage + 1299; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdbp10", 11) == 0) - { -{ -return dev_storage + 1284; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdbo10", 11) == 0) - { -{ -return dev_storage + 1269; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdbn10", 11) == 0) - { -{ -return dev_storage + 1254; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdbm10", 11) == 0) - { -{ -return dev_storage + 1239; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdbl10", 11) == 0) - { -{ -return dev_storage + 1224; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdbk10", 11) == 0) - { -{ -return dev_storage + 1209; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdbj10", 11) == 0) - { -{ -return dev_storage + 1194; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdbi10", 11) == 0) - { -{ -return dev_storage + 1179; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdbh10", 11) == 0) - { -{ -return dev_storage + 1164; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdbg10", 11) == 0) - { -{ -return dev_storage + 1149; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdbf10", 11) == 0) - { -{ -return dev_storage + 1134; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdbe10", 11) == 0) - { -{ -return dev_storage + 1119; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdbd10", 11) == 0) - { -{ -return dev_storage + 1104; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdbc10", 11) == 0) - { -{ -return dev_storage + 1089; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdbb10", 11) == 0) - { -{ -return dev_storage + 1074; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdba10", 11) == 0) - { -{ -return dev_storage + 1059; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 'a': - switch (KR_keyword [8]) - { - case 'z': - if (strncmp (KR_keyword, "/dev/sdaz10", 11) == 0) - { -{ -return dev_storage + 1018; - -} - } - else - { -{ -return NULL; - -} - } - case 'y': - if (strncmp (KR_keyword, "/dev/sday10", 11) == 0) - { -{ -return dev_storage + 1003; - -} - } - else - { -{ -return NULL; - -} - } - case 'x': - if (strncmp (KR_keyword, "/dev/sdax10", 11) == 0) - { -{ -return dev_storage + 988; - -} - } - else - { -{ -return NULL; - -} - } - case 'w': - if (strncmp (KR_keyword, "/dev/sdaw10", 11) == 0) - { -{ -return dev_storage + 973; - -} - } - else - { -{ -return NULL; - -} - } - case 'v': - if (strncmp (KR_keyword, "/dev/sdav10", 11) == 0) - { -{ -return dev_storage + 958; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/sdau10", 11) == 0) - { -{ -return dev_storage + 943; - -} - } - else - { -{ -return NULL; - -} - } - case 't': - if (strncmp (KR_keyword, "/dev/sdat10", 11) == 0) - { -{ -return dev_storage + 928; - -} - } - else - { -{ -return NULL; - -} - } - case 's': - if (strncmp (KR_keyword, "/dev/sdas10", 11) == 0) - { -{ -return dev_storage + 913; - -} - } - else - { -{ -return NULL; - -} - } - case 'r': - if (strncmp (KR_keyword, "/dev/sdar10", 11) == 0) - { -{ -return dev_storage + 898; - -} - } - else - { -{ -return NULL; - -} - } - case 'q': - if (strncmp (KR_keyword, "/dev/sdaq10", 11) == 0) - { -{ -return dev_storage + 883; - -} - } - else - { -{ -return NULL; - -} - } - case 'p': - if (strncmp (KR_keyword, "/dev/sdap10", 11) == 0) - { -{ -return dev_storage + 868; - -} - } - else - { -{ -return NULL; - -} - } - case 'o': - if (strncmp (KR_keyword, "/dev/sdao10", 11) == 0) - { -{ -return dev_storage + 853; - -} - } - else - { -{ -return NULL; - -} - } - case 'n': - if (strncmp (KR_keyword, "/dev/sdan10", 11) == 0) - { -{ -return dev_storage + 838; - -} - } - else - { -{ -return NULL; - -} - } - case 'm': - if (strncmp (KR_keyword, "/dev/sdam10", 11) == 0) - { -{ -return dev_storage + 823; - -} - } - else - { -{ -return NULL; - -} - } - case 'l': - if (strncmp (KR_keyword, "/dev/sdal10", 11) == 0) - { -{ -return dev_storage + 808; - -} - } - else - { -{ -return NULL; - -} - } - case 'k': - if (strncmp (KR_keyword, "/dev/sdak10", 11) == 0) - { -{ -return dev_storage + 793; - -} - } - else - { -{ -return NULL; - -} - } - case 'j': - if (strncmp (KR_keyword, "/dev/sdaj10", 11) == 0) - { -{ -return dev_storage + 778; - -} - } - else - { -{ -return NULL; - -} - } - case 'i': - if (strncmp (KR_keyword, "/dev/sdai10", 11) == 0) - { -{ -return dev_storage + 763; - -} - } - else - { -{ -return NULL; - -} - } - case 'h': - if (strncmp (KR_keyword, "/dev/sdah10", 11) == 0) - { -{ -return dev_storage + 748; - -} - } - else - { -{ -return NULL; - -} - } - case 'g': - if (strncmp (KR_keyword, "/dev/sdag10", 11) == 0) - { -{ -return dev_storage + 733; - -} - } - else - { -{ -return NULL; - -} - } - case 'f': - if (strncmp (KR_keyword, "/dev/sdaf10", 11) == 0) - { -{ -return dev_storage + 718; - -} - } - else - { -{ -return NULL; - -} - } - case 'e': - if (strncmp (KR_keyword, "/dev/sdae10", 11) == 0) - { -{ -return dev_storage + 703; - -} - } - else - { -{ -return NULL; - -} - } - case 'd': - if (strncmp (KR_keyword, "/dev/sdad10", 11) == 0) - { -{ -return dev_storage + 688; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/sdac10", 11) == 0) - { -{ -return dev_storage + 673; - -} - } - else - { -{ -return NULL; - -} - } - case 'b': - if (strncmp (KR_keyword, "/dev/sdab10", 11) == 0) - { -{ -return dev_storage + 658; - -} - } - else - { -{ -return NULL; - -} - } - case 'a': - if (strncmp (KR_keyword, "/dev/sdaa10", 11) == 0) - { -{ -return dev_storage + 643; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 12: - switch (KR_keyword [5]) - { - case 'w': - if (strncmp (KR_keyword, "/dev/windows", 12) == 0) - { -{ -return dev_storage + 2515; - -} - } - else - { -{ -return NULL; - -} - } - case 'u': - if (strncmp (KR_keyword, "/dev/urandom", 12) == 0) - { -{ -return dev_storage + 2514; - -} - } - else - { -{ -return NULL; - -} - } - case 'c': - if (strncmp (KR_keyword, "/dev/console", 12) == 0) - { -{ -return dev_storage + 20; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } - case 14: - if (strncmp (KR_keyword, "/dev/clipboard", 14) == 0) - { -{ -return dev_storage + 1; - -} - } - else - { -{ -return NULL; - -} - } - default: -{ -return NULL; - -} - } -} - - - - - - -#undef BRACK -void -device::parse (const char *s) -{ - size_t len = strlen (s); - const device *dev = KR_find_keyword (s, len); - - if (!dev) - *this = *fs_dev; - else - *this = *dev; -} - -void -device::init () -{ - /* nothing to do... yet */ -} - -void -device::parse (_major_t major, _minor_t minor) -{ - _dev_t dev = FHDEV (major, minor); - - devn = 0; - - for (unsigned i = 0; i < (sizeof (dev_storage) / sizeof (dev_storage[0])); i++) - if (dev_storage[i].devn == dev) - { - *this = dev_storage[i]; - break; - } - - if (!*this) - devn = FHDEV (major, minor); -} - -void -device::parse (_dev_t dev) -{ - parse (_major (dev), _minor (dev)); -} - -void -device::tty_to_real_device () -{ - if (!real_tty_attached (myself)) - *this = myself->ctty < 0 ? dev_bad_storage : *console_dev; - else - parse (DEV_TTYS_MAJOR, myself->ctty); -} - -void -device::parsedisk (int drive, int part) -{ - int base; - if (drive < ('q' - 'a')) /* /dev/sda -to- /dev/sdp */ - base = DEV_SD_MAJOR; - else if (drive < 32) /* /dev/sdq -to- /dev/sdaf */ - { - base = DEV_SD1_MAJOR; - drive -= 'q' - 'a'; - } - else if (drive < 48) /* /dev/sdag -to- /dev/sdav */ - { - base = DEV_SD2_MAJOR; - drive -= 32; - } - else if (drive < 64) /* /dev/sdaw -to- /dev/sdbl */ - { - base = DEV_SD3_MAJOR; - drive -= 48; - } - else if (drive < 80) /* /dev/sdbm -to- /dev/sdcb */ - { - base = DEV_SD4_MAJOR; - drive -= 64; - } - else if (drive < 96) /* /dev/sdcc -to- /dev/sdcr */ - { - base = DEV_SD5_MAJOR; - drive -= 80; - } - else if (drive < 112) /* /dev/sdcs -to- /dev/sddh */ - { - base = DEV_SD6_MAJOR; - drive -= 96; - } - /* NOTE: This will cause multiple /dev/sddx entries in - /proc/partitions if there are more than 128 devices */ - else /* /dev/sddi -to- /dev/sddx */ - { - base = DEV_SD7_MAJOR; - drive -= 112; - } - parse (base, part + (drive * 16)); -} - - diff --git a/winsup/cygwin/devices.h b/winsup/cygwin/devices.h deleted file mode 100644 index d1a76a4ff..000000000 --- a/winsup/cygwin/devices.h +++ /dev/null @@ -1,298 +0,0 @@ -/* devices.h - - Copyright 2002, 2003, 2004, 2005 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -typedef unsigned short _major_t; -typedef unsigned short _minor_t; -typedef mode_t _mode_t; -typedef __dev32_t _dev_t; - -#define FHDEV(maj, min) ((((unsigned) (maj)) << (sizeof (_major_t) * 8)) | (unsigned) (min)) -#define _minor(dev) ((dev) & ((1 << (sizeof (_minor_t) * 8)) - 1)) -#define _major(dev) ((dev) >> (sizeof (_major_t) * 8)) - -enum fh_devices -{ - FH_TTY = FHDEV (5, 0), - FH_CONSOLE = FHDEV (5, 1), - FH_PTYM = FHDEV (5, 2), /* /dev/ptmx */ - FH_CONIN = FHDEV (5, 255), - FH_CONOUT = FHDEV (5, 254), - - DEV_TTYM_MAJOR = 128, - FH_TTYM = FHDEV (DEV_TTYM_MAJOR, 0), - FH_TTYM_MAX= FHDEV (DEV_TTYM_MAJOR, 255), - - DEV_TTYS_MAJOR = 136, - FH_TTYS = FHDEV (DEV_TTYS_MAJOR, 0), /* FIXME: Should separate ttys and ptys */ - FH_TTYS_MAX= FHDEV (DEV_TTYS_MAJOR, 255), /* FIXME: Should separate ttys and ptys */ - - DEV_SERIAL_MAJOR = 117, - FH_SERIAL = FHDEV (117, 0), /* /dev/ttyS? */ - - FH_WINDOWS = FHDEV (13, 255), - FH_CLIPBOARD=FHDEV (13, 254), - - FH_PIPE = FHDEV (0, 255), - FH_PIPER = FHDEV (0, 254), - FH_PIPEW = FHDEV (0, 253), - FH_FIFO = FHDEV (0, 252), - FH_PROC = FHDEV (0, 250), - FH_REGISTRY= FHDEV (0, 249), - FH_PROCESS = FHDEV (0, 248), - - FH_FS = FHDEV (0, 247), /* filesystem based device */ - - FH_NETDRIVE= FHDEV (0, 246), - FH_DEV = FHDEV (0, 245), - FH_PROCNET = FHDEV (0, 244), - FH_PROCESSFD = FHDEV (0, 243), - - DEV_FLOPPY_MAJOR = 2, - FH_FLOPPY = FHDEV (DEV_FLOPPY_MAJOR, 0), - - DEV_CDROM_MAJOR = 11, - FH_CDROM = FHDEV (DEV_CDROM_MAJOR, 0), - - DEV_TAPE_MAJOR = 9, - FH_TAPE = FHDEV (DEV_TAPE_MAJOR, 0), - FH_NTAPE = FHDEV (DEV_TAPE_MAJOR, 128), - FH_MAXNTAPE= FHDEV (DEV_TAPE_MAJOR, 255), - - DEV_SD_MAJOR = 8, - DEV_SD1_MAJOR = 65, - DEV_SD2_MAJOR = 66, - DEV_SD3_MAJOR = 67, - DEV_SD4_MAJOR = 68, - DEV_SD5_MAJOR = 69, - DEV_SD6_MAJOR = 70, - DEV_SD7_MAJOR = 71, - FH_SD = FHDEV (DEV_SD_MAJOR, 0), - FH_SD1 = FHDEV (DEV_SD1_MAJOR, 0), - FH_SD2 = FHDEV (DEV_SD2_MAJOR, 0), - FH_SD3 = FHDEV (DEV_SD3_MAJOR, 0), - FH_SD4 = FHDEV (DEV_SD4_MAJOR, 0), - FH_SD5 = FHDEV (DEV_SD5_MAJOR, 0), - FH_SD6 = FHDEV (DEV_SD6_MAJOR, 0), - FH_SD7 = FHDEV (DEV_SD7_MAJOR, 0), - FH_SDA = FHDEV (DEV_SD_MAJOR, 0), - FH_SDB = FHDEV (DEV_SD_MAJOR, 16), - FH_SDC = FHDEV (DEV_SD_MAJOR, 32), - FH_SDD = FHDEV (DEV_SD_MAJOR, 48), - FH_SDE = FHDEV (DEV_SD_MAJOR, 64), - FH_SDF = FHDEV (DEV_SD_MAJOR, 80), - FH_SDG = FHDEV (DEV_SD_MAJOR, 96), - FH_SDH = FHDEV (DEV_SD_MAJOR, 112), - FH_SDI = FHDEV (DEV_SD_MAJOR, 128), - FH_SDJ = FHDEV (DEV_SD_MAJOR, 144), - FH_SDK = FHDEV (DEV_SD_MAJOR, 160), - FH_SDL = FHDEV (DEV_SD_MAJOR, 176), - FH_SDM = FHDEV (DEV_SD_MAJOR, 192), - FH_SDN = FHDEV (DEV_SD_MAJOR, 208), - FH_SDO = FHDEV (DEV_SD_MAJOR, 224), - FH_SDP = FHDEV (DEV_SD_MAJOR, 240), - FH_SDQ = FHDEV (DEV_SD1_MAJOR, 0), - FH_SDR = FHDEV (DEV_SD1_MAJOR, 16), - FH_SDS = FHDEV (DEV_SD1_MAJOR, 32), - FH_SDT = FHDEV (DEV_SD1_MAJOR, 48), - FH_SDU = FHDEV (DEV_SD1_MAJOR, 64), - FH_SDV = FHDEV (DEV_SD1_MAJOR, 80), - FH_SDW = FHDEV (DEV_SD1_MAJOR, 96), - FH_SDX = FHDEV (DEV_SD1_MAJOR, 112), - FH_SDY = FHDEV (DEV_SD1_MAJOR, 128), - FH_SDZ = FHDEV (DEV_SD1_MAJOR, 144), - FH_SDAA = FHDEV (DEV_SD1_MAJOR, 160), - FH_SDAB = FHDEV (DEV_SD1_MAJOR, 176), - FH_SDAC = FHDEV (DEV_SD1_MAJOR, 192), - FH_SDAD = FHDEV (DEV_SD1_MAJOR, 208), - FH_SDAE = FHDEV (DEV_SD1_MAJOR, 224), - FH_SDAF = FHDEV (DEV_SD1_MAJOR, 240), - FH_SDAG = FHDEV (DEV_SD2_MAJOR, 0), - FH_SDAH = FHDEV (DEV_SD2_MAJOR, 16), - FH_SDAI = FHDEV (DEV_SD2_MAJOR, 32), - FH_SDAJ = FHDEV (DEV_SD2_MAJOR, 48), - FH_SDAK = FHDEV (DEV_SD2_MAJOR, 64), - FH_SDAL = FHDEV (DEV_SD2_MAJOR, 80), - FH_SDAM = FHDEV (DEV_SD2_MAJOR, 96), - FH_SDAN = FHDEV (DEV_SD2_MAJOR, 112), - FH_SDAO = FHDEV (DEV_SD2_MAJOR, 128), - FH_SDAP = FHDEV (DEV_SD2_MAJOR, 144), - FH_SDAQ = FHDEV (DEV_SD2_MAJOR, 160), - FH_SDAR = FHDEV (DEV_SD2_MAJOR, 176), - FH_SDAS = FHDEV (DEV_SD2_MAJOR, 192), - FH_SDAT = FHDEV (DEV_SD2_MAJOR, 208), - FH_SDAU = FHDEV (DEV_SD2_MAJOR, 224), - FH_SDAV = FHDEV (DEV_SD2_MAJOR, 240), - FH_SDAW = FHDEV (DEV_SD3_MAJOR, 0), - FH_SDAX = FHDEV (DEV_SD3_MAJOR, 16), - FH_SDAY = FHDEV (DEV_SD3_MAJOR, 32), - FH_SDAZ = FHDEV (DEV_SD3_MAJOR, 48), - FH_SDBA = FHDEV (DEV_SD3_MAJOR, 64), - FH_SDBB = FHDEV (DEV_SD3_MAJOR, 80), - FH_SDBC = FHDEV (DEV_SD3_MAJOR, 96), - FH_SDBD = FHDEV (DEV_SD3_MAJOR, 112), - FH_SDBE = FHDEV (DEV_SD3_MAJOR, 128), - FH_SDBF = FHDEV (DEV_SD3_MAJOR, 144), - FH_SDBG = FHDEV (DEV_SD3_MAJOR, 160), - FH_SDBH = FHDEV (DEV_SD3_MAJOR, 176), - FH_SDBI = FHDEV (DEV_SD3_MAJOR, 192), - FH_SDBJ = FHDEV (DEV_SD3_MAJOR, 208), - FH_SDBK = FHDEV (DEV_SD3_MAJOR, 224), - FH_SDBL = FHDEV (DEV_SD3_MAJOR, 240), - FH_SDBM = FHDEV (DEV_SD4_MAJOR, 0), - FH_SDBN = FHDEV (DEV_SD4_MAJOR, 16), - FH_SDBO = FHDEV (DEV_SD4_MAJOR, 32), - FH_SDBP = FHDEV (DEV_SD4_MAJOR, 48), - FH_SDBQ = FHDEV (DEV_SD4_MAJOR, 64), - FH_SDBR = FHDEV (DEV_SD4_MAJOR, 80), - FH_SDBS = FHDEV (DEV_SD4_MAJOR, 96), - FH_SDBT = FHDEV (DEV_SD4_MAJOR, 112), - FH_SDBU = FHDEV (DEV_SD4_MAJOR, 128), - FH_SDBV = FHDEV (DEV_SD4_MAJOR, 144), - FH_SDBW = FHDEV (DEV_SD4_MAJOR, 160), - FH_SDBX = FHDEV (DEV_SD4_MAJOR, 176), - FH_SDBY = FHDEV (DEV_SD4_MAJOR, 192), - FH_SDBZ = FHDEV (DEV_SD4_MAJOR, 208), - FH_SDCA = FHDEV (DEV_SD4_MAJOR, 224), - FH_SDCB = FHDEV (DEV_SD4_MAJOR, 240), - FH_SDCC = FHDEV (DEV_SD5_MAJOR, 0), - FH_SDCD = FHDEV (DEV_SD5_MAJOR, 16), - FH_SDCE = FHDEV (DEV_SD5_MAJOR, 32), - FH_SDCF = FHDEV (DEV_SD5_MAJOR, 48), - FH_SDCG = FHDEV (DEV_SD5_MAJOR, 64), - FH_SDCH = FHDEV (DEV_SD5_MAJOR, 80), - FH_SDCI = FHDEV (DEV_SD5_MAJOR, 96), - FH_SDCJ = FHDEV (DEV_SD5_MAJOR, 112), - FH_SDCK = FHDEV (DEV_SD5_MAJOR, 128), - FH_SDCL = FHDEV (DEV_SD5_MAJOR, 144), - FH_SDCM = FHDEV (DEV_SD5_MAJOR, 160), - FH_SDCN = FHDEV (DEV_SD5_MAJOR, 176), - FH_SDCO = FHDEV (DEV_SD5_MAJOR, 192), - FH_SDCP = FHDEV (DEV_SD5_MAJOR, 208), - FH_SDCQ = FHDEV (DEV_SD5_MAJOR, 224), - FH_SDCR = FHDEV (DEV_SD5_MAJOR, 240), - FH_SDCS = FHDEV (DEV_SD6_MAJOR, 0), - FH_SDCT = FHDEV (DEV_SD6_MAJOR, 16), - FH_SDCU = FHDEV (DEV_SD6_MAJOR, 32), - FH_SDCV = FHDEV (DEV_SD6_MAJOR, 48), - FH_SDCW = FHDEV (DEV_SD6_MAJOR, 64), - FH_SDCX = FHDEV (DEV_SD6_MAJOR, 80), - FH_SDCY = FHDEV (DEV_SD6_MAJOR, 96), - FH_SDCZ = FHDEV (DEV_SD6_MAJOR, 112), - FH_SDDA = FHDEV (DEV_SD6_MAJOR, 128), - FH_SDDB = FHDEV (DEV_SD6_MAJOR, 144), - FH_SDDC = FHDEV (DEV_SD6_MAJOR, 160), - FH_SDDD = FHDEV (DEV_SD6_MAJOR, 176), - FH_SDDE = FHDEV (DEV_SD6_MAJOR, 192), - FH_SDDF = FHDEV (DEV_SD6_MAJOR, 208), - FH_SDDG = FHDEV (DEV_SD6_MAJOR, 224), - FH_SDDH = FHDEV (DEV_SD6_MAJOR, 240), - FH_SDDI = FHDEV (DEV_SD7_MAJOR, 0), - FH_SDDJ = FHDEV (DEV_SD7_MAJOR, 16), - FH_SDDK = FHDEV (DEV_SD7_MAJOR, 32), - FH_SDDL = FHDEV (DEV_SD7_MAJOR, 48), - FH_SDDM = FHDEV (DEV_SD7_MAJOR, 64), - FH_SDDN = FHDEV (DEV_SD7_MAJOR, 80), - FH_SDDO = FHDEV (DEV_SD7_MAJOR, 96), - FH_SDDP = FHDEV (DEV_SD7_MAJOR, 112), - FH_SDDQ = FHDEV (DEV_SD7_MAJOR, 128), - FH_SDDR = FHDEV (DEV_SD7_MAJOR, 144), - FH_SDDS = FHDEV (DEV_SD7_MAJOR, 160), - FH_SDDT = FHDEV (DEV_SD7_MAJOR, 176), - FH_SDDU = FHDEV (DEV_SD7_MAJOR, 192), - FH_SDDV = FHDEV (DEV_SD7_MAJOR, 208), - FH_SDDW = FHDEV (DEV_SD7_MAJOR, 224), - FH_SDDX = FHDEV (DEV_SD7_MAJOR, 240), - - FH_MEM = FHDEV (1, 1), - FH_KMEM = FHDEV (1, 2), /* not implemented yet */ - FH_NULL = FHDEV (1, 3), - FH_PORT = FHDEV (1, 4), - FH_ZERO = FHDEV (1, 5), - FH_FULL = FHDEV (1, 7), - FH_RANDOM = FHDEV (1, 8), - FH_URANDOM = FHDEV (1, 9), - FH_KMSG = FHDEV (1, 11), - FH_OSS_DSP = FHDEV (14, 3), - - DEV_CYGDRIVE_MAJOR = 98, - FH_CYGDRIVE= FHDEV (DEV_CYGDRIVE_MAJOR, 0), - - DEV_TCP_MAJOR = 30, - FH_TCP = FHDEV (DEV_TCP_MAJOR, 36), - FH_UDP = FHDEV (DEV_TCP_MAJOR, 39), - FH_ICMP = FHDEV (DEV_TCP_MAJOR, 33), - FH_UNIX = FHDEV (DEV_TCP_MAJOR, 120), - FH_STREAM = FHDEV (DEV_TCP_MAJOR, 121), - FH_DGRAM = FHDEV (DEV_TCP_MAJOR, 122), - - FH_BAD = FHDEV (0, 0) -}; - -struct device -{ - const char *name; - union - { - _dev_t devn; - struct - { - _minor_t minor; - _major_t major; - }; - }; - const char *native; - _mode_t mode; - bool dev_on_fs; - static const device *lookup (const char *, unsigned int = UINT32_MAX); - void parse (const char *); - void parse (_major_t major, _minor_t minor); - void parse (_dev_t dev); - void parsedisk (int, int); - inline bool setunit (unsigned n) - { - minor = n; - return true; - } - static void init (); - void tty_to_real_device (); - inline operator int () const {return devn;} - inline void setfs (bool x) {dev_on_fs = x;} - inline bool isfs () const {return dev_on_fs || devn == FH_FS;} - inline bool is_fs_special () const {return dev_on_fs && devn != FH_FS;} -}; - -extern const device *console_dev; -extern const device *ttym_dev; -extern const device *ttys_dev; -extern const device *urandom_dev; - -extern const device dev_dgram_storage; -#define dgram_dev (&dev_dgram_storage) -extern const device dev_stream_storage; -#define stream_dev (&dev_stream_storage) -extern const device dev_tcp_storage; -#define tcp_dev (&dev_tcp_storage) -extern const device dev_udp_storage; -#define udp_dev (&dev_udp_storage) - -extern const device dev_piper_storage; -#define piper_dev (&dev_piper_storage) -extern const device dev_pipew_storage; -#define pipew_dev (&dev_pipew_storage) -extern const device dev_proc_storage; -#define proc_dev (&dev_proc_storage) -extern const device dev_netdrive_storage; -#define netdrive_dev (&dev_netdrive_storage) -extern const device dev_cygdrive_storage; -#define cygdrive_dev (&dev_cygdrive_storage) -extern const device dev_fh_storage; -#define fh_dev (&dev_fh_storage) -extern const device dev_fs_storage; -#define fs_dev (&dev_fs_storage) diff --git a/winsup/cygwin/devices.in b/winsup/cygwin/devices.in deleted file mode 100644 index bbe829683..000000000 --- a/winsup/cygwin/devices.in +++ /dev/null @@ -1,196 +0,0 @@ -%import { -#include "winsup.h" -#include "devices.h" -#include "sys/cygwin.h" -#include "tty.h" -#include "pinfo.h" -typedef const device *KR_device_t; -} -%type KR_device_t -%local { -const device dev_cygdrive_storage = - {"/cygdrive", {FH_CYGDRIVE}, "/cygdrive"}; - -const device dev_fs_storage = - {"", {FH_FS}, ""}; - -const device dev_proc_storage = - {"", {FH_PROC}, ""}; - -const device dev_procnet_storage = - {"", {FH_PROCNET}, ""}; - -const device dev_netdrive_storage = - {"", {FH_NETDRIVE}, ""}; - -#if 0 -const device dev_dev_storage = - {"/dev", {FH_DEV}, "/dev"}; -#endif - -const device dev_registry_storage = - {"", {FH_REGISTRY}, ""}; - -const device dev_piper_storage = - {"", {FH_PIPER}, ""}; - -const device dev_pipew_storage = - {"", {FH_PIPEW}, ""}; - -const device dev_tcp_storage = - {"", {FH_TCP}, ""}; - -const device dev_udp_storage = - {"", {FH_UDP}, ""}; - -const device dev_stream_storage = - {"", {FH_STREAM}, ""}; - -const device dev_dgram_storage = - {"", {FH_DGRAM}, ""}; - -const device dev_bad_storage = - {"", {FH_BAD}, ""}; -#define BRACK(x) {x} - -%storage_here -} -%% -"/dev/tty", BRACK(FH_TTY), "\\dev\\tty" -"/dev/tty%(0-63)d", BRACK(FHDEV(DEV_TTYS_MAJOR, {$1})), "\\dev\\tty{$1}", ttys_dev -"/dev/console", BRACK(FH_CONSOLE), "\\dev\\console", console_dev -"/dev/ttym", BRACK(FH_TTYM), "\\dev\\ttym", ttym_dev -"/dev/ptmx", BRACK(FH_PTYM), "\\dev\\ptmx" -"/dev/windows", BRACK(FH_WINDOWS), "\\dev\\windows" -"/dev/dsp", BRACK(FH_OSS_DSP), "\\dev\\dsp" -"/dev/conin", BRACK(FH_CONIN), "conin" -"/dev/conout", BRACK(FH_CONOUT), "conout" -"/dev/null", BRACK(FH_NULL), "\\Device\\Null" -"/dev/zero", BRACK(FH_ZERO), "\\dev\\zero" -"/dev/full", BRACK(FH_FULL), "\\dev\\full" -"/dev/random", BRACK(FH_RANDOM), "\\dev\\random" -"/dev/urandom", BRACK(FH_URANDOM), "\\dev\\urandom", urandom_dev -"/dev/mem", BRACK(FH_MEM), "\\dev\\mem" -"/dev/kmem", BRACK(FH_KMEM), "\\dev\\mem" -"/dev/clipboard", BRACK(FH_CLIPBOARD), "\\dev\\clipboard" -"/dev/port", BRACK(FH_PORT), "\\dev\\port" -"/dev/com%(1-16)d", BRACK(FHDEV(DEV_SERIAL_MAJOR, {$1 - 1})), "\\??\\COM{$1}" -"/dev/ttyS%(0-63)d", BRACK(FHDEV(DEV_SERIAL_MAJOR, {$1})), "\\??\\COM{$1 + 1}" -"/dev/pipe", BRACK(FH_PIPE), "\\dev\\pipe" -"/dev/fifo", BRACK(FH_FIFO), "\\dev\\fifo" -"/dev/st%(0-127)d", BRACK(FHDEV(DEV_TAPE_MAJOR, {$1})), "\\Device\\Tape{$1}" -"/dev/nst%(0-127)d", BRACK(FHDEV(DEV_TAPE_MAJOR, {$1 + 128})), "\\Device\\Tape{$1}" -"/dev/fd%(0-15)d", BRACK(FHDEV(DEV_FLOPPY_MAJOR, {$1})), "\\Device\\Floppy{$1}" -"/dev/scd%(0-15)d", BRACK(FHDEV(DEV_CDROM_MAJOR, {$1})), "\\Device\\CdRom{$1}" -"/dev/sr%(0-15)d", BRACK(FHDEV(DEV_CDROM_MAJOR, {$1})), "\\Device\\CdRom{$1}" -"/dev/sd%{a-z}s", BRACK(FH_SD{uc $1}), "\\Device\\Harddisk{ord($1) - ord('a')}\\Partition0" -"/dev/sda%{a-z}s", BRACK(FH_SDA{uc $1}), "\\Device\\Harddisk{26 + ord($1) - ord('a')}\\Partition0" -"/dev/sdb%{a-z}s", BRACK(FH_SDB{uc $1}), "\\Device\\Harddisk{52 + ord($1) - ord('a')}\\Partition0" -"/dev/sdc%{a-z}s", BRACK(FH_SDC{uc $1}), "\\Device\\Harddisk{78 + ord($1) - ord('a')}\\Partition0" -"/dev/sdd%{a-x}s", BRACK(FH_SDD{uc $1}), "\\Device\\Harddisk{104 + ord($1) - ord('a')}\\Partition0" -"/dev/sd%{a-z}s%(1-15)d", BRACK(FH_SD{uc $1} | {$2}), "\\Device\\Harddisk{ord($1) - ord('a')}\\Partition{$2 % 16}" -"/dev/sda%{a-z}s%(1-15)d", BRACK(FH_SDA{uc $1} | {$2}), "\\Device\\Harddisk{26 + ord($1) - ord('a')}\\Partition{$2 % 16}" -"/dev/sdb%{a-z}s%(1-15)d", BRACK(FH_SDB{uc $1} | {$2}), "\\Device\\Harddisk{52 + ord($1) - ord('a')}\\Partition{$2 % 16}" -"/dev/sdc%{a-z}s%(1-15)d", BRACK(FH_SDC{uc $1} | {$2}), "\\Device\\Harddisk{78 + ord($1) - ord('a')}\\Partition{$2 % 16}" -"/dev/sdd%{a-x}s%(1-15)d", BRACK(FH_SDD{uc $1} | {$2}), "\\Device\\Harddisk{104 + ord($1) - ord('a')}\\Partition{$2 % 16}" -"/dev/kmsg", BRACK(FH_KMSG), "\\Device\\MailSlot\\cygwin\\dev\\kmsg" -"/dev", BRACK(FH_DEV), "/dev" -%other {return NULL;} -%% -#undef BRACK -void -device::parse (const char *s) -{ - size_t len = strlen (s); - const device *dev = KR_find_keyword (s, len); - - if (!dev) - *this = *fs_dev; - else - *this = *dev; -} - -void -device::init () -{ - /* nothing to do... yet */ -} - -void -device::parse (_major_t major, _minor_t minor) -{ - _dev_t dev = FHDEV (major, minor); - - devn = 0; - - for (unsigned i = 0; i < (sizeof (dev_storage) / sizeof (dev_storage[0])); i++) - if (dev_storage[i].devn == dev) - { - *this = dev_storage[i]; - break; - } - - if (!*this) - devn = FHDEV (major, minor); -} - -void -device::parse (_dev_t dev) -{ - parse (_major (dev), _minor (dev)); -} - -void -device::tty_to_real_device () -{ - if (!real_tty_attached (myself)) - *this = myself->ctty < 0 ? dev_bad_storage : *console_dev; - else - parse (DEV_TTYS_MAJOR, myself->ctty); -} - -void -device::parsedisk (int drive, int part) -{ - int base; - if (drive < ('q' - 'a')) /* /dev/sda -to- /dev/sdp */ - base = DEV_SD_MAJOR; - else if (drive < 32) /* /dev/sdq -to- /dev/sdaf */ - { - base = DEV_SD1_MAJOR; - drive -= 'q' - 'a'; - } - else if (drive < 48) /* /dev/sdag -to- /dev/sdav */ - { - base = DEV_SD2_MAJOR; - drive -= 32; - } - else if (drive < 64) /* /dev/sdaw -to- /dev/sdbl */ - { - base = DEV_SD3_MAJOR; - drive -= 48; - } - else if (drive < 80) /* /dev/sdbm -to- /dev/sdcb */ - { - base = DEV_SD4_MAJOR; - drive -= 64; - } - else if (drive < 96) /* /dev/sdcc -to- /dev/sdcr */ - { - base = DEV_SD5_MAJOR; - drive -= 80; - } - else if (drive < 112) /* /dev/sdcs -to- /dev/sddh */ - { - base = DEV_SD6_MAJOR; - drive -= 96; - } - /* NOTE: This will cause multiple /dev/sddx entries in - /proc/partitions if there are more than 128 devices */ - else /* /dev/sddi -to- /dev/sddx */ - { - base = DEV_SD7_MAJOR; - drive -= 112; - } - parse (base, part + (drive * 16)); -} diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc deleted file mode 100644 index 641aabe4b..000000000 --- a/winsup/cygwin/dir.cc +++ /dev/null @@ -1,352 +0,0 @@ -/* dir.cc: Posix directory-related routines - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2006, 2007, - 2008, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include - -#define _COMPILING_NEWLIB -#include - -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "cygtls.h" -#include "tls_pbuf.h" - -extern "C" int -dirfd (DIR *dir) -{ - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - if (dir->__d_cookie != __DIRENT_COOKIE) - { - set_errno (EBADF); - syscall_printf ("-1 = dirfd (%p)", dir); - return -1; - } - return dir->__d_fd; -} - -/* Symbol kept for backward compatibility. Don't remove. Don't declare - in public header file. */ -extern "C" DIR * -__opendir_with_d_ino (const char *name) -{ - return opendir (name); -} - -/* opendir: POSIX 5.1.2.1 */ -extern "C" DIR * -opendir (const char *name) -{ - fhandler_base *fh; - DIR *res; - - fh = build_fh_name (name, PC_SYM_FOLLOW); - if (!fh) - res = NULL; - else if (fh->exists ()) - res = fh->opendir (-1); - else - { - set_errno (ENOENT); - res = NULL; - } - - if (!res && fh) - delete fh; - return res; -} - -extern "C" DIR * -fdopendir (int fd) -{ - DIR *res = NULL; - - cygheap_fdget cfd (fd); - if (cfd >= 0) - res = cfd->opendir (fd); - return res; -} - -static int -readdir_worker (DIR *dir, dirent *de) -{ - myfault efault; - if (efault.faulted ()) - return EFAULT; - - if (dir->__d_cookie != __DIRENT_COOKIE) - { - syscall_printf ("%p = readdir (%p)", NULL, dir); - return EBADF; - } - - de->d_ino = 0; - de->d_type = DT_UNKNOWN; - memset (&de->__d_unused1, 0, sizeof (de->__d_unused1)); - - int res = ((fhandler_base *) dir->__fh)->readdir (dir, de); - - if (res == ENMFILE) - { - if (!(dir->__flags & dirent_saw_dot)) - { - strcpy (de->d_name, "."); - dir->__flags |= dirent_saw_dot; - dir->__d_position++; - res = 0; - } - else if (!(dir->__flags & dirent_saw_dot_dot)) - { - strcpy (de->d_name, ".."); - dir->__flags |= dirent_saw_dot_dot; - dir->__d_position++; - res = 0; - } - } - - if (!res && !de->d_ino) - { - bool is_dot = false; - bool is_dot_dot = false; - - if (de->d_name[0] == '.') - { - if (de->d_name[1] == '\0') - is_dot = true; - else if (de->d_name[1] == '.' && de->d_name[2] == '\0') - is_dot_dot = true; - } - - if (is_dot_dot && !(dir->__flags & dirent_isroot)) - de->d_ino = readdir_get_ino (((fhandler_base *) dir->__fh)->get_name (), - true); - else - { - /* Compute d_ino by combining filename hash with directory hash. */ - de->d_ino = ((fhandler_base *) dir->__fh)->get_ino (); - if (!is_dot && !is_dot_dot) - { - PUNICODE_STRING w32name = - ((fhandler_base *) dir->__fh)->pc.get_nt_native_path (); - DWORD devn = ((fhandler_base *) dir->__fh)->get_device (); - /* Paths below /proc don't have a Win32 pendant. */ - if (isproc_dev (devn)) - de->d_ino = hash_path_name (de->d_ino, L"/"); - else if (w32name->Buffer[w32name->Length / sizeof (WCHAR) - 1] - != L'\\') - de->d_ino = hash_path_name (de->d_ino, L"\\"); - de->d_ino = hash_path_name (de->d_ino, de->d_name); - } - } - } - /* This fills out the old 32 bit d_ino field for old applications, - build under Cygwin before 1.5.x. */ - de->__d_internal1 = de->d_ino; - - return res; -} - -/* readdir: POSIX 5.1.2.1 */ -extern "C" struct dirent * -readdir (DIR *dir) -{ - int res = readdir_worker (dir, dir->__d_dirent); - if (res == 0) - return dir->__d_dirent; - if (res != ENMFILE) - set_errno (res); - return NULL; -} - -extern "C" int -readdir_r (DIR *dir, dirent *de, dirent **ode) -{ - int res = readdir_worker (dir, de); - if (!res) - *ode = de; - else - { - *ode = NULL; - if (res == ENMFILE) - res = 0; - } - return res; -} - -extern "C" _off64_t -telldir64 (DIR *dir) -{ - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - if (dir->__d_cookie != __DIRENT_COOKIE) - return 0; - return ((fhandler_base *) dir->__fh)->telldir (dir); -} - -/* telldir */ -extern "C" _off_t -telldir (DIR *dir) -{ - return telldir64 (dir); -} - -extern "C" void -seekdir64 (DIR *dir, _off64_t loc) -{ - myfault efault; - if (efault.faulted (EFAULT)) - return; - - if (dir->__d_cookie != __DIRENT_COOKIE) - return; - dir->__flags &= dirent_info_mask; - return ((fhandler_base *) dir->__fh)->seekdir (dir, loc); -} - -/* seekdir */ -extern "C" void -seekdir (DIR *dir, _off_t loc) -{ - seekdir64 (dir, (_off64_t)loc); -} - -/* rewinddir: POSIX 5.1.2.1 */ -extern "C" void -rewinddir (DIR *dir) -{ - myfault efault; - if (efault.faulted (EFAULT)) - return; - - if (dir->__d_cookie != __DIRENT_COOKIE) - return; - dir->__flags &= dirent_info_mask; - return ((fhandler_base *) dir->__fh)->rewinddir (dir); -} - -/* closedir: POSIX 5.1.2.1 */ -extern "C" int -closedir (DIR *dir) -{ - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - if (dir->__d_cookie != __DIRENT_COOKIE) - { - set_errno (EBADF); - syscall_printf ("-1 = closedir (%p)", dir); - return -1; - } - - /* Reset the marker in case the caller tries to use `dir' again. */ - dir->__d_cookie = 0; - - int res = ((fhandler_base *) dir->__fh)->closedir (dir); - - cygheap->fdtab.release (dir->__d_fd); - - free (dir->__d_dirname); - free (dir->__d_dirent); - free (dir); - syscall_printf ("%d = closedir (%p)", res); - return res; -} - -/* mkdir: POSIX 5.4.1.1 */ -extern "C" int -mkdir (const char *dir, mode_t mode) -{ - int res = -1; - fhandler_base *fh = NULL; - tmp_pathbuf tp; - - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - /* POSIX says mkdir("symlink-to-missing/") should create the - directory "missing", but Linux rejects it with EEXIST. Copy - Linux behavior for now. */ - - if (!*dir) - { - set_errno (ENOENT); - goto done; - } - if (isdirsep (dir[strlen (dir) - 1])) - { - /* This converts // to /, but since both give EEXIST, we're okay. */ - char *buf; - char *p = stpcpy (buf = tp.c_get (), dir) - 1; - dir = buf; - while (p > dir && isdirsep (*p)) - *p-- = '\0'; - } - if (!(fh = build_fh_name (dir, PC_SYM_NOFOLLOW))) - goto done; /* errno already set */; - - if (fh->error ()) - { - debug_printf ("got %d error from build_fh_name", fh->error ()); - set_errno (fh->error ()); - } - else if (has_dot_last_component (dir, true)) - set_errno (fh->exists () ? EEXIST : ENOENT); - else if (!fh->mkdir (mode)) - res = 0; - delete fh; - - done: - syscall_printf ("%d = mkdir (%s, %d)", res, dir, mode); - return res; -} - -/* rmdir: POSIX 5.5.2.1 */ -extern "C" int -rmdir (const char *dir) -{ - int res = -1; - fhandler_base *fh = NULL; - - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - if (!(fh = build_fh_name (dir, PC_SYM_NOFOLLOW))) - goto done; /* errno already set */; - - if (fh->error ()) - { - debug_printf ("got %d error from build_fh_name", fh->error ()); - set_errno (fh->error ()); - } - else if (!fh->exists ()) - set_errno (ENOENT); - else if (has_dot_last_component (dir, false)) - set_errno (EINVAL); - else if (!fh->rmdir ()) - res = 0; - - delete fh; - - done: - syscall_printf ("%d = rmdir (%s)", res, dir); - return res; -} diff --git a/winsup/cygwin/dlfcn.cc b/winsup/cygwin/dlfcn.cc deleted file mode 100644 index e62d74cb3..000000000 --- a/winsup/cygwin/dlfcn.cc +++ /dev/null @@ -1,180 +0,0 @@ -/* dlfcn.cc - - Copyright 1998, 2000, 2001, 2002, 2003, 2004, 2008, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include -#include "path.h" -#include "perprocess.h" -#include "dlfcn.h" -#include "cygtls.h" -#include "tls_pbuf.h" - -static void __stdcall -set_dl_error (const char *str) -{ - strcpy (_my_tls.locals.dl_buffer, strerror (get_errno ())); - _my_tls.locals.dl_error = 1; -} - -/* Look for an executable file given the name and the environment - variable to use for searching (eg., PATH); returns the full - pathname (static buffer) if found or NULL if not. */ -inline const char * __stdcall -check_path_access (const char *mywinenv, const char *name, path_conv& buf) -{ - return find_exec (name, buf, mywinenv, FE_NNF | FE_NATIVE | FE_CWD | FE_DLL); -} - -/* Search LD_LIBRARY_PATH for dll, if it exists. - Return Windows version of given path. */ -static bool __stdcall -get_full_path_of_dll (const char* str, path_conv &real_filename) -{ - int len = strlen (str); - - /* empty string? */ - if (len == 0) - { - set_errno (EINVAL); - return false; /* Yes. Let caller deal with it. */ - } - - tmp_pathbuf tp; - char *name = tp.c_get (); - - strcpy (name, str); /* Put it somewhere where we can manipulate it. */ - - if (isabspath (name) || - (check_path_access ("LD_LIBRARY_PATH=", name, real_filename) - ?: check_path_access ("/usr/lib", name, real_filename)) == NULL) - real_filename.check (name, PC_SYM_FOLLOW | PC_NOFULL | PC_NULLEMPTY); - - if (!real_filename.error) - return true; - - set_errno (real_filename.error); - return false; -} - -void * -dlopen (const char *name, int) -{ - void *ret; - - if (name == NULL) - ret = (void *) GetModuleHandle (NULL); /* handle for the current module */ - else - { - /* handle for the named library */ - path_conv pc; - if (!get_full_path_of_dll (name, pc)) - ret = NULL; - else - { - tmp_pathbuf tp; - wchar_t *path = tp.w_get (); - - pc.get_wide_win32_path (path); - /* Check if the last path component contains a dot. If so, - leave the filename alone. Otherwise add a traiing dot - to override LoadLibrary's automatic adding of a ".dll" suffix. */ - wchar_t *last_bs = wcsrchr (path, L'\\'); - if (last_bs && !wcschr (last_bs, L'.')) - wcscat (last_bs, L"."); - - /* Workaround for broken DLLs built against Cygwin versions 1.7.0-49 - up to 1.7.0-57. They override the cxx_malloc pointer in their - DLL initialization code even if loaded dynamically. This is a - no-no since a later dlclose lets cxx_malloc point into nirvana. - The below kludge "fixes" that by reverting the original cxx_malloc - pointer after LoadLibrary. This implies that their overrides - won't be applied; that's OK. All overrides should be present at - final link time, as Windows doesn't allow undefined references; - it would actually be wrong for a dlopen'd DLL to opportunistically - override functions in a way that wasn't known then. We're not - going to try and reproduce the full ELF dynamic loader here! */ - - /* Store original cxx_malloc pointer. */ - struct per_process_cxx_malloc *tmp_malloc; - tmp_malloc = __cygwin_user_data.cxx_malloc; - - ret = (void *) LoadLibraryW (path); - - /* Restore original cxx_malloc pointer. */ - __cygwin_user_data.cxx_malloc = tmp_malloc; - - if (ret == NULL) - __seterrno (); - } - } - - if (!ret) - set_dl_error ("dlopen"); - debug_printf ("ret %p", ret); - - return ret; -} - -void * -dlsym (void *handle, const char *name) -{ - void *ret = NULL; - if (handle == RTLD_DEFAULT) - { /* search all modules */ - HANDLE cur_proc = GetCurrentProcess (); - HMODULE *modules; - DWORD needed, i; - if (!EnumProcessModules (cur_proc, NULL, 0, &needed)) - { - dlsym_fail: - set_dl_error ("dlsym"); - return NULL; - } - modules = (HMODULE*) alloca (needed); - if (!EnumProcessModules (cur_proc, modules, needed, &needed)) - goto dlsym_fail; - for (i = 0; i < needed / sizeof (HMODULE); i++) - if ((ret = (void *) GetProcAddress (modules[i], name))) - break; - } - else - ret = (void *) GetProcAddress ((HMODULE)handle, name); - if (!ret) - set_dl_error ("dlsym"); - debug_printf ("ret %p", ret); - return ret; -} - -int -dlclose (void *handle) -{ - int ret = -1; - if (handle == GetModuleHandle (NULL) || FreeLibrary ((HMODULE) handle)) - ret = 0; - if (ret) - set_dl_error ("dlclose"); - return ret; -} - -char * -dlerror () -{ - char *res; - if (!_my_tls.locals.dl_error) - res = NULL; - else - { - _my_tls.locals.dl_error = 0; - res = _my_tls.locals.dl_buffer; - } - return res; -} diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc deleted file mode 100644 index 055b1060f..000000000 --- a/winsup/cygwin/dll_init.cc +++ /dev/null @@ -1,431 +0,0 @@ -/* dll_init.cc - - Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009 Red Hat, Inc. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "cygerrno.h" -#include "perprocess.h" -#include "dll_init.h" -#include "environ.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "pinfo.h" -#include "cygtls.h" -#include -#include - -extern void __stdcall check_sanity_and_sync (per_process *); - -dll_list dlls; - -static bool dll_global_dtors_recorded; - -/* Run destructors for all DLLs on exit. */ -void -dll_global_dtors () -{ - int recorded = dll_global_dtors_recorded; - dll_global_dtors_recorded = false; - if (recorded && dlls.start.next) - for (dll *d = dlls.end; d != &dlls.start; d = d->prev) - d->run_dtors (); -} - -/* Run all constructors associated with a dll */ -void -per_module::run_ctors () -{ - void (**pfunc)() = ctors; - - /* Run ctors backwards, so skip the first entry and find how many - there are, then run them. */ - - if (pfunc) - { - int i; - for (i = 1; pfunc[i]; i++); - - for (int j = i - 1; j > 0; j--) - (pfunc[j]) (); - } -} - -/* Run all destructors associated with a dll */ -void -per_module::run_dtors () -{ - void (**pfunc)() = dtors; - while (*++pfunc) - (*pfunc) (); -} - -/* Initialize an individual DLL */ -int -dll::init () -{ - int ret = 1; - - /* Why didn't we just import this variable? */ - *(p.envptr) = __cygwin_environ; - - /* Don't run constructors or the "main" if we've forked. */ - if (!in_forkee) - { - /* global contructors */ - p.run_ctors (); - - /* entry point of dll (use main of per_process with null args...) */ - if (p.main) - ret = (*(p.main)) (0, 0, 0); - } - - return ret; -} - -/* Look for a dll based on name */ -dll * -dll_list::operator[] (const PWCHAR name) -{ - dll *d = &start; - while ((d = d->next) != NULL) - if (!wcscasecmp (name, d->name)) - return d; - - return NULL; -} - -#define RETRIES 1000 - -/* Allocate space for a dll struct. */ -dll * -dll_list::alloc (HINSTANCE h, per_process *p, dll_type type) -{ - WCHAR name[NT_MAX_PATH]; - DWORD namelen = GetModuleFileNameW (h, name, sizeof (name)); - - /* Already loaded? */ - dll *d = dlls[name]; - if (d) - { - if (!in_forkee) - d->count++; /* Yes. Bump the usage count. */ - return d; /* Return previously allocated pointer. */ - } - - /* FIXME: Change this to new at some point. */ - d = (dll *) cmalloc (HEAP_2_DLL, sizeof (*d) + (namelen * sizeof (*name))); - - /* Now we've allocated a block of information. Fill it in with the supplied - info about this DLL. */ - d->count = 1; - wcscpy (d->name, name); - d->handle = h; - d->has_dtors = true; - d->p = p; - d->type = type; - if (end == NULL) - end = &start; /* Point to "end" of dll chain. */ - end->next = d; /* Standard linked list stuff. */ - d->next = NULL; - d->prev = end; - end = d; - tot++; - if (type == DLL_LOAD) - loaded_dlls++; - return d; -} - -dll * -dll_list::find (void *retaddr) -{ - MEMORY_BASIC_INFORMATION m; - if (!VirtualQuery (retaddr, &m, sizeof m)) - return NULL; - HMODULE h = (HMODULE) m.AllocationBase; - - dll *d = &start; - while ((d = d->next)) - if (d->handle == h) - break; - return d; -} - -/* Detach a DLL from the chain. */ -void -dll_list::detach (void *retaddr) -{ - dll *d; - if (!myself || exit_state || !(d = find (retaddr))) - return; - if (d->count <= 0) - system_printf ("WARNING: trying to detach an already detached dll ..."); - if (--d->count == 0) - { - __cxa_finalize (d); - d->run_dtors (); - d->prev->next = d->next; - if (d->next) - d->next->prev = d->prev; - if (d->type == DLL_LOAD) - loaded_dlls--; - if (end == d) - end = d->prev; - cfree (d); - } -} - -/* Initialization for all linked DLLs, called by dll_crt0_1. */ -void -dll_list::init () -{ - /* Walk the dll chain, initializing each dll */ - dll *d = &start; - dll_global_dtors_recorded = d->next != NULL; - while ((d = d->next)) - d->init (); -} - -#define A64K (64 * 1024) - -/* Mark every memory address up to "here" as reserved. This may force - Windows NT to load a DLL in the next available, lowest slot. */ -static void -reserve_upto (const PWCHAR name, DWORD here) -{ - DWORD size; - MEMORY_BASIC_INFORMATION mb; - for (DWORD start = 0x10000; start < here; start += size) - if (!VirtualQuery ((void *) start, &mb, sizeof (mb))) - size = A64K; - else - { - size = A64K * ((mb.RegionSize + A64K - 1) / A64K); - start = A64K * (((DWORD) mb.BaseAddress + A64K - 1) / A64K); - - if (start + size > here) - size = here - start; - if (mb.State == MEM_FREE && - !VirtualAlloc ((void *) start, size, MEM_RESERVE, PAGE_NOACCESS)) - api_fatal ("couldn't allocate memory %p(%d) for '%W' alignment, %E\n", - start, size, name); - } -} - -/* Release all of the memory previously allocated by "upto" above. - Note that this may also free otherwise reserved memory. If that becomes - a problem, we'll have to keep track of the memory that we reserve above. */ -static void -release_upto (const PWCHAR name, DWORD here) -{ - DWORD size; - MEMORY_BASIC_INFORMATION mb; - for (DWORD start = 0x10000; start < here; start += size) - if (!VirtualQuery ((void *) start, &mb, sizeof (mb))) - size = 64 * 1024; - else - { - size = mb.RegionSize; - if (!(mb.State == MEM_RESERVE && mb.AllocationProtect == PAGE_NOACCESS - && (((void *) start < cygheap->user_heap.base - || (void *) start > cygheap->user_heap.top) - && ((void *) start < (void *) cygheap - || (void *) start - > (void *) ((char *) cygheap + CYGHEAPSIZE))))) - continue; - if (!VirtualFree ((void *) start, 0, MEM_RELEASE)) - api_fatal ("couldn't release memory %p(%d) for '%W' alignment, %E\n", - start, size, name); - } -} - -/* Reload DLLs after a fork. Iterates over the list of dynamically loaded - DLLs and attempts to load them in the same place as they were loaded in the - parent. */ -void -dll_list::load_after_fork (HANDLE parent) -{ - for (dll *d = &dlls.start; (d = d->next) != NULL; ) - if (d->type == DLL_LOAD) - for (int i = 0; i < 2; i++) - { - /* See if DLL will load in proper place. If so, free it and reload - it the right way. - It stinks that we can't invert the order of the initial LoadLibrary - and FreeLibrar since Microsoft documentation seems to imply that - should do what we want. However, once a library is loaded as - above, the second LoadLibrary will not execute its startup code - unless it is first unloaded. */ - HMODULE h = LoadLibraryExW (d->name, NULL, DONT_RESOLVE_DLL_REFERENCES); - - if (!h) - system_printf ("can't reload %W, %E", d->name); - else - { - FreeLibrary (h); - if (h == d->handle) - h = LoadLibraryW (d->name); - } - /* If we reached here on the second iteration of the for loop - then there is a lot of memory to release. */ - if (i > 0) - release_upto (d->name, (DWORD) d->handle); - if (h == d->handle) - break; /* Success */ - - if (i > 0) - /* We tried once to relocate the dll and it failed. */ - api_fatal ("unable to remap %W to same address as parent: %p != %p", - d->name, d->handle, h); - - /* Dll loaded in the wrong place. Dunno why this happens but it - always seems to happen when there are multiple DLLs attempting to - load into the same address space. In the "forked" process, the - second DLL always loads into a different location. So, block all - of the memory up to the new load address and try again. */ - reserve_upto (d->name, (DWORD) d->handle); - } - in_forkee = false; -} - -struct dllcrt0_info -{ - HMODULE h; - per_process *p; - int res; - dllcrt0_info (HMODULE h0, per_process *p0): h(h0), p(p0) {} -}; - -extern "C" int -dll_dllcrt0 (HMODULE h, per_process *p) -{ - dllcrt0_info x (h, p); - - if (_my_tls.isinitialized ()) - dll_dllcrt0_1 (&x); - else - _my_tls.call ((DWORD (*) (void *, void *)) dll_dllcrt0_1, &x); - return x.res; -} - -void -dll_dllcrt0_1 (VOID *x) -{ - HMODULE& h = ((dllcrt0_info *)x)->h; - per_process*& p = ((dllcrt0_info *)x)->p; - int& res = ((dllcrt0_info *)x)->res; - - /* Make sure that our exception handler is installed. - That should always be the case but this just makes sure. - - At some point, we may want to just remove this code since - the exception handler should be guaranteed to be installed. - I'm leaving it in until potentially after the release of - 1.7.1 */ - _my_tls.init_exception_handler (_cygtls::handle_exceptions); - - if (p == NULL) - p = &__cygwin_user_data; - else - *(p->impure_ptr_ptr) = __cygwin_user_data.impure_ptr; - - bool linked = !in_forkee && !cygwin_finished_initializing; - - /* Broken DLLs built against Cygwin versions 1.7.0-49 up to 1.7.0-57 - override the cxx_malloc pointer in their DLL initialization code, - when loaded either statically or dynamically. Because this leaves - a stale pointer into demapped memory space if the DLL is unloaded - by a call to dlclose, we prevent this happening for dynamically - loaded DLLS in dlopen by saving and restoring cxx_malloc around - the call to LoadLibrary, which invokes the DLL's startup sequence. - Modern DLLs won't even attempt to override the pointer when loaded - statically, but will write their overrides directly into the - struct it points to. With all modern DLLs, this will remain the - default_cygwin_cxx_malloc struct in cxx.cc, but if any broken DLLs - are in the mix they will have overridden the pointer and subsequent - overrides will go into their embedded cxx_malloc structs. This is - almost certainly not a problem as they can never be unloaded, but - if we ever did want to do anything about it, we could check here to - see if the pointer had been altered in the early parts of the DLL's - startup, and if so copy back the new overrides and reset it here. - However, that's just a note for the record; at the moment, we can't - see any need to worry about this happening. */ - - /* Partially initialize Cygwin guts for non-cygwin apps. */ - if (dynamically_loaded && user_data->magic_biscuit == 0) - dll_crt0 (p); - else - check_sanity_and_sync (p); - - dll_type type; - - /* If this function is called before cygwin has finished - initializing, then the DLL must be a cygwin-aware DLL - that was explicitly linked into the program rather than - a dlopened DLL. */ - if (linked) - type = DLL_LINK; - else - { - type = DLL_LOAD; - dlls.reload_on_fork = 1; - } - - /* Allocate and initialize space for the DLL. */ - dll *d = dlls.alloc (h, p, type); - - /* If d == NULL, then something is broken. - Otherwise, if we've finished initializing, it's ok to - initialize the DLL. If we haven't finished initializing, - it may not be safe to call the dll's "main" since not - all of cygwin's internal structures may have been set up. */ - if (!d || (!linked && !d->init ())) - res = -1; - else - res = (DWORD) d; -} - -/* OBSOLETE: This function is obsolete and will go away in the - future. Cygwin can now handle being loaded from a noncygwin app - using the same entry point. */ - -extern "C" int -dll_noncygwin_dllcrt0 (HMODULE h, per_process *p) -{ - return dll_dllcrt0 (h, p); -} - -extern "C" void -cygwin_detach_dll (dll *) -{ - HANDLE retaddr; - if (_my_tls.isinitialized ()) - retaddr = (void *) _my_tls.retaddr (); - else - retaddr = __builtin_return_address (0); - dlls.detach (retaddr); -} - -extern "C" void -dlfork (int val) -{ - dlls.reload_on_fork = val; -} - -/* Called from various places to update all of the individual - ideas of the environ block. Explain to me again why we didn't - just import __cygwin_environ? */ -void __stdcall -update_envptrs () -{ - for (dll *d = dlls.istart (DLL_ANY); d; d = dlls.inext ()) - *(d->p.envptr) = __cygwin_environ; - *main_environ = __cygwin_environ; -} diff --git a/winsup/cygwin/dll_init.h b/winsup/cygwin/dll_init.h deleted file mode 100644 index b37406e82..000000000 --- a/winsup/cygwin/dll_init.h +++ /dev/null @@ -1,108 +0,0 @@ -/* dll_init.h - - Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2008, - 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -struct per_module -{ - char ***envptr; - void (**ctors)(void); - void (**dtors)(void); - void *data_start; - void *data_end; - void *bss_start; - void *bss_end; - int (*main)(int, char **, char **); - per_module &operator = (per_process *p) - { - envptr = p->envptr; - ctors = p->ctors; - dtors = p->dtors; - data_start = p->data_start; - data_end = p->data_end; - bss_start = p->bss_start; - bss_end = p->bss_end; - main = p->main; - return *this; - } - void run_ctors (); - void run_dtors (); -}; - - -typedef enum -{ - DLL_NONE, - DLL_LINK, - DLL_LOAD, - DLL_ANY -} dll_type; - -struct dll -{ - struct dll *next, *prev; - per_module p; - HMODULE handle; - int count; - bool has_dtors; - dll_type type; - WCHAR name[1]; - void detach (); - int init (); - void run_dtors () - { - if (has_dtors) - { - has_dtors = 0; - p.run_dtors (); - } - } -}; - -#define MAX_DLL_BEFORE_INIT 100 - -class dll_list -{ - dll *end; - dll *hold; - dll_type hold_type; -public: - dll start; - int tot; - int loaded_dlls; - int reload_on_fork; - dll *operator [] (const PWCHAR name); - dll *alloc (HINSTANCE, per_process *, dll_type); - dll *find (void *); - void detach (void *); - void init (); - void load_after_fork (HANDLE); - dll *inext () - { - while ((hold = hold->next)) - if (hold_type == DLL_ANY || hold->type == hold_type) - break; - return hold; - } - dll *istart (dll_type t) - { - hold_type = t; - hold = &start; - return inext (); - } - friend void dll_global_dtors (); -}; - -extern dll_list dlls; -void dll_global_dtors (); - -/* These probably belong in a newlib header but we can keep them here - for now. */ -extern "C" int __cxa_atexit(void (*)(void*), void*, void*); -extern "C" int __cxa_finalize(void*); diff --git a/winsup/cygwin/dll_init.sgml b/winsup/cygwin/dll_init.sgml deleted file mode 100644 index a66c43cb6..000000000 --- a/winsup/cygwin/dll_init.sgml +++ /dev/null @@ -1,11 +0,0 @@ - - -cygwin_detach_dll - - -extern "C" void -cygwin_detach_dll -int dll_index - - - diff --git a/winsup/cygwin/dllfixdbg b/winsup/cygwin/dllfixdbg deleted file mode 100755 index e3875a67a..000000000 --- a/winsup/cygwin/dllfixdbg +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/perl -# Copyright 2006, 2007 Red Hat, Inc. -# -# This file is part of Cygwin. -# -# This software is a copyrighted work licensed under the terms of the -# Cygwin license. Please consult the file "CYGWIN_LICENSE" for -# details. -# -use integer; -use strict; -sub xit($@); -my $strip = $ARGV[0] eq '-s'; -shift if $strip; -my $objdump = shift; -my @objcopy = ((shift)); -my $dll = shift; -my $dbg = shift; -xit 0, @objcopy, '-R', '.gnu_debuglink_overlay', '--only-keep-debug', $dll, $dbg; -xit 0, @objcopy, '-g', '--add-gnu-debuglink=' . $dbg, $dll; -open(OBJDUMP, '-|', "$objdump --headers $dll"); -my %section; -while () { - my ($idx, $name, $size, $vma, $lma, $fileoff, $algn) = /^\s*(\d+)\s+(\.\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s*$/; - if ($name eq '.gnu_debuglink') { - push(@objcopy, '--set-section-flag', '.gnu_debuglink=contents,readonly,debug,noload'); - $idx = $section{'.gnu_debuglink'}{-idx} if defined($section{'.gnu_debuglink'}{-idx}); - } elsif ($name eq '.gnu_debuglink_overlay') { - push (@objcopy, '-R', '.gnu_debuglink_overlay'); - $section{'.gnu_debuglink'}{-idx} = $idx; - next; - } - defined($idx) and - $section{$name} = {-idx=>int($idx), -size=>hex($size), -vma=>hex($vma), -lma=>hex($lma), -fileoff=>hex($fileoff), - -algn=>0x00001000}; -} -close OBJDUMP; -my $vma; -for my $k (sort {$section{$a}{-idx} <=> $section{$b}{-idx}} keys %section) { - if ($strip && $k =~ /\.(?:stab|debug)/o) { - push(@objcopy, '-R', $k); - next; - } - if (!defined($vma)) { - $vma = $section{$k}{-vma}; - } - if ($vma != $section{$k}{-vma}) { - my $newvma = align($vma, $section{$k}{-algn}); - if ($newvma != $vma) { - printf STDERR "$0: ERROR $k VMA 0x%08x != 0x%08x\n", $vma, $newvma; - exit 1; - } - push(@objcopy, '--change-section-address', sprintf "$k=0x%08x", $vma); - } - $vma = align($vma + $section{$k}{-size}, $section{$k}{-algn}); -} - -warn "$0: ERROR final VMA (" . sprintf("0x%08x", $vma) . ") not on 64K boundary\n" if $vma != align($vma, 64 * 1024); -push(@objcopy, $dll, @ARGV); -xit 1, @objcopy; -sub align { - my $n = $_[0]; - my $align = $_[1] - 1; - return ($n + $align) & ~$align; -} - -sub xit($@) { - my $execit = shift; - print "+ @_\n"; - if ($execit) { - exec @_ or die "$0: couldn't exec $_[0] - $!\n"; - } else { - system @_ and die "$0: couldn't exec $_[0] - $!\n"; - } -} diff --git a/winsup/cygwin/dlmalloc.c b/winsup/cygwin/dlmalloc.c deleted file mode 100644 index b64bed8eb..000000000 --- a/winsup/cygwin/dlmalloc.c +++ /dev/null @@ -1,3815 +0,0 @@ -/* - * To do: - * - strdup? maybe shouldn't bother yet, it seems difficult to get includes - * right using dlmalloc.h - * - add STD_C prototyping - * - adhere to comment conventions - * - maybe fix ALLOCFILL vs. MOATFILL in do_init_realloced_chunk() - * - keep a list of mmaped regions for checking in malloc_update_mallinfo() - * - I think memalign() is wrong: it aligns the chunk rather than the memory - * portion of the chunk. - * - "& -alignment" in memalign() is suspect: should use "& ~alignment" - * instead? - * - malloc.h doesn't need malloc_COPY or probably a bunch of other stuff - * - add mallopt options for e.g. fill? - * - come up with a non-BBC version of M_C - * - document necessity of checking chunk address in do_check_chunk prior to - * accessing any of its fields - * Done: - * minor speedup due to extend check before mremap - * minor speedup due to returning malloc() result in memalign() if aligned - * made malloc_update_mallinfo() check alloced regions at start of sbrk area - * fixed bug: After discovering foreign sbrk, if old_top was MINSIZE, would - * reduce old_top_size to 0, thus making inuse(old_top) return 0; other - * functions would consequently attempt to access old_top->{fd,bk}, which - * were invalid. This is in malloc_extend_top(), in the "double - * fencepost" section. - * Documentation: - * malloc_usable_size(P) is equivalent to realloc(P, malloc_usable_size(P)) - * - * $Log$ - * Revision 1.9 2004/05/12 16:21:18 cgf - * remove keyword stuff - * - * Revision 1.1 1997/12/24 18:34:47 nsd - * Initial revision - * - */ -/* ---------- To make a malloc.h, start cutting here ------------ */ - -/* - A version of malloc/free/realloc written by Doug Lea and released to the - public domain. Send questions/comments/complaints/performance data - to dl@cs.oswego.edu - -* VERSION 2.6.4 Thu Nov 28 07:54:55 1996 Doug Lea (dl at gee) - - Note: There may be an updated version of this malloc obtainable at - ftp://g.oswego.edu/pub/misc/malloc.c - Check before installing! - -* Why use this malloc? - - This is not the fastest, most space-conserving, most portable, or - most tunable malloc ever written. However it is among the fastest - while also being among the most space-conserving, portable and tunable. - Consistent balance across these factors results in a good general-purpose - allocator. For a high-level description, see - http://g.oswego.edu/dl/html/malloc.html - -* Synopsis of public routines - - (Much fuller descriptions are contained in the program documentation below.) - - malloc(size_t n); - Return a pointer to a newly allocated chunk of at least n bytes, or null - if no space is available. - free(Void_t* p); - Release the chunk of memory pointed to by p, or no effect if p is null. - realloc(Void_t* p, size_t n); - Return a pointer to a chunk of size n that contains the same data - as does chunk p up to the minimum of (n, p's size) bytes, or null - if no space is available. The returned pointer may or may not be - the same as p. If p is null, equivalent to malloc. Unless the - #define realloc_ZERO_BYTES_FREES below is set, realloc with a - size argument of zero (re)allocates a minimum-sized chunk. - memalign(size_t alignment, size_t n); - Return a pointer to a newly allocated chunk of n bytes, aligned - in accord with the alignment argument, which must be a power of - two. - valloc(size_t n); - Equivalent to memalign(pagesize, n), where pagesize is the page - size of the system (or as near to this as can be figured out from - all the includes/defines below.) - pvalloc(size_t n); - Equivalent to valloc(minimum-page-that-holds(n)), that is, - round up n to nearest pagesize. - calloc(size_t unit, size_t quantity); - Returns a pointer to quantity * unit bytes, with all locations - set to zero. - cfree(Void_t* p); - Equivalent to free(p). - malloc_trim(size_t pad); - Release all but pad bytes of freed top-most memory back - to the system. Return 1 if successful, else 0. - malloc_usable_size(Void_t* p); - Report the number usable allocated bytes associated with allocated - chunk p. This may or may not report more bytes than were requested, - due to alignment and minimum size constraints. - malloc_stats(); - Prints brief summary statistics on stderr. - mallinfo() - Returns (by copy) a struct containing various summary statistics. - mallopt(int parameter_number, int parameter_value) - Changes one of the tunable parameters described below. Returns - 1 if successful in changing the parameter, else 0. - -* Vital statistics: - - Alignment: 8-byte - 8 byte alignment is currently hardwired into the design. This - seems to suffice for all current machines and C compilers. - - Assumed pointer representation: 4 or 8 bytes - Code for 8-byte pointers is untested by me but has worked - reliably by Wolfram Gloger, who contributed most of the - changes supporting this. - - Assumed size_t representation: 4 or 8 bytes - Note that size_t is allowed to be 4 bytes even if pointers are 8. - - Minimum overhead per allocated chunk: 4 or 8 bytes - Each malloced chunk has a hidden overhead of 4 bytes holding size - and status information. - - Minimum allocated size: 4-byte ptrs: 16 bytes (including 4 overhead) - 8-byte ptrs: 24/32 bytes (including, 4/8 overhead) - - When a chunk is freed, 12 (for 4byte ptrs) or 20 (for 8 byte - ptrs but 4 byte size) or 24 (for 8/8) additional bytes are - needed; 4 (8) for a trailing size field - and 8 (16) bytes for free list pointers. Thus, the minimum - allocatable size is 16/24/32 bytes. - - Even a request for zero bytes (i.e., malloc(0)) returns a - pointer to something of the minimum allocatable size. - - Maximum allocated size: 4-byte size_t: 2^31 - 8 bytes - 8-byte size_t: 2^63 - 16 bytes - - It is assumed that (possibly signed) size_t bit values suffice to - represent chunk sizes. `Possibly signed' is due to the fact - that `size_t' may be defined on a system as either a signed or - an unsigned type. To be conservative, values that would appear - as negative numbers are avoided. - Requests for sizes with a negative sign bit will return a - minimum-sized chunk. - - Maximum overhead wastage per allocated chunk: normally 15 bytes - - Alignnment demands, plus the minimum allocatable size restriction - make the normal worst-case wastage 15 bytes (i.e., up to 15 - more bytes will be allocated than were requested in malloc), with - two exceptions: - 1. Because requests for zero bytes allocate non-zero space, - the worst case wastage for a request of zero bytes is 24 bytes. - 2. For requests >= mmap_threshold that are serviced via - mmap(), the worst case wastage is 8 bytes plus the remainder - from a system page (the minimal mmap unit); typically 4096 bytes. - -* Limitations - - Here are some features that are NOT currently supported - - * No user-definable hooks for callbacks and the like. - * No automated mechanism for fully checking that all accesses - to malloced memory stay within their bounds. - * No support for compaction. - -* Synopsis of compile-time options: - - People have reported using previous versions of this malloc on all - versions of Unix, sometimes by tweaking some of the defines - below. It has been tested most extensively on Solaris and - Linux. It is also reported to work on WIN32 platforms. - People have also reported adapting this malloc for use in - stand-alone embedded systems. - - The implementation is in straight, hand-tuned ANSI C. Among other - consequences, it uses a lot of macros. Because of this, to be at - all usable, this code should be compiled using an optimizing compiler - (for example gcc -O2) that can simplify expressions and control - paths. - - __STD_C (default: derived from C compiler defines) - Nonzero if using ANSI-standard C compiler, a C++ compiler, or - a C compiler sufficiently close to ANSI to get away with it. - DEBUG (default: NOT defined) - Define to enable debugging. Adds fairly extensive assertion-based - checking to help track down memory errors, but noticeably slows down - execution. - realloc_ZERO_BYTES_FREES (default: NOT defined) - Define this if you think that realloc(p, 0) should be equivalent - to free(p). Otherwise, since malloc returns a unique pointer for - malloc(0), so does realloc(p, 0). - HAVE_memcpy (default: defined) - Define if you are not otherwise using ANSI STD C, but still - have memcpy and memset in your C library and want to use them. - Otherwise, simple internal versions are supplied. - USE_memcpy (default: 1 if HAVE_memcpy is defined, 0 otherwise) - Define as 1 if you want the C library versions of memset and - memcpy called in realloc and calloc (otherwise macro versions are used). - At least on some platforms, the simple macro versions usually - outperform libc versions. - HAVE_MMAP (default: defined as 1) - Define to non-zero to optionally make malloc() use mmap() to - allocate very large blocks. - HAVE_MREMAP (default: defined as 0 unless Linux libc set) - Define to non-zero to optionally make realloc() use mremap() to - reallocate very large blocks. - malloc_getpagesize (default: derived from system #includes) - Either a constant or routine call returning the system page size. - HAVE_USR_INCLUDE_malloc_H (default: NOT defined) - Optionally define if you are on a system with a /usr/include/malloc.h - that declares struct mallinfo. It is not at all necessary to - define this even if you do, but will ensure consistency. - INTERNAL_SIZE_T (default: size_t) - Define to a 32-bit type (probably `unsigned int') if you are on a - 64-bit machine, yet do not want or need to allow malloc requests of - greater than 2^31 to be handled. This saves space, especially for - very small chunks. - INTERNAL_LINUX_C_LIB (default: NOT defined) - Defined only when compiled as part of Linux libc. - Also note that there is some odd internal name-mangling via defines - (for example, internally, `malloc' is named `mALLOc') needed - when compiling in this case. These look funny but don't otherwise - affect anything. - WIN32 (default: undefined) - Define this on MS win (95, nt) platforms to compile in sbrk emulation. - LACKS_UNISTD_H (default: undefined) - Define this if your system does not have a . - MORECORE (default: sbrk) - The name of the routine to call to obtain more memory from the system. - MORECORE_FAILURE (default: -1) - The value returned upon failure of MORECORE. - MORECORE_CLEARS (default 0) - True (1) if the routine mapped to MORECORE zeroes out memory (which - holds for sbrk). - DEFAULT_TRIM_THRESHOLD - DEFAULT_TOP_PAD - DEFAULT_MMAP_THRESHOLD - DEFAULT_MMAP_MAX - Default values of tunable parameters (described in detail below) - controlling interaction with host system routines (sbrk, mmap, etc). - These values may also be changed dynamically via mallopt(). The - preset defaults are those that give best performance for typical - programs/systems. - - -*/ - - - - -/* Preliminaries */ - - -#ifndef __STD_C -#ifdef __STDC__ -#define __STD_C 1 -#else -#if __cplusplus -#define __STD_C 1 -#else -#define __STD_C 0 -#endif /*__cplusplus*/ -#endif /*__STDC__*/ -#endif /*__STD_C*/ - -#ifndef Void_t -#if __STD_C -#define Void_t void -#else -#define Void_t char -#endif -#endif /*Void_t*/ - -#define __MALLOC_H_INCLUDED - -#if __STD_C -#include /* for size_t */ -#else -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "cygmalloc.h" -#define __INSIDE_CYGWIN__ -#include /* needed for malloc_stats */ -#include - -/* - Compile-time options -*/ - - -/* - Debugging: - - Because freed chunks may be overwritten with link fields, this - malloc will often die when freed memory is overwritten by user - programs. This can be very effective (albeit in an annoying way) - in helping track down dangling pointers. - - If you compile with -DDEBUG, a number of assertion checks are - enabled that will catch more memory errors. You probably won't be - able to make much sense of the actual assertion errors, but they - should help you locate incorrectly overwritten memory. The - checking is fairly extensive, and will slow down execution - noticeably. Calling malloc_stats or mallinfo with DEBUG set will - attempt to check every non-mmapped allocated and free chunk in the - course of computing the summmaries. (By nature, mmapped regions - cannot be checked very much automatically.) - - Setting DEBUG may also be helpful if you are trying to modify - this code. The assertions in the check routines spell out in more - detail the assumptions and invariants underlying the algorithms. - -*/ - -#ifdef MALLOC_DEBUG -#define DEBUG 1 -#define DEBUG1 1 -#define DEBUG2 1 -#define DEBUG3 1 -#endif - -#if DEBUG -#include -#else -#define assert(x) ((void)0) -#endif - -/* - INTERNAL_SIZE_T is the word-size used for internal bookkeeping - of chunk sizes. On a 64-bit machine, you can reduce malloc - overhead by defining INTERNAL_SIZE_T to be a 32 bit `unsigned int' - at the expense of not being able to handle requests greater than - 2^31. This limitation is hardly ever a concern; you are encouraged - to set this. However, the default version is the same as size_t. -*/ - -#ifndef INTERNAL_SIZE_T -#define INTERNAL_SIZE_T size_t -#endif - -/* - realloc_ZERO_BYTES_FREES should be set if a call to - realloc with zero bytes should be the same as a call to free. - Some people think it should. Otherwise, since this malloc - returns a unique pointer for malloc(0), so does realloc(p, 0). -*/ - - -/* #define realloc_ZERO_BYTES_FREES */ - - -/* - WIN32 causes an emulation of sbrk to be compiled in - mmap-based options are not currently supported in WIN32. -*/ - -/* #define WIN32 */ -#ifdef WIN32 -#define MORECORE wsbrk -#define HAVE_MMAP 0 -#endif - - -/* - HAVE_memcpy should be defined if you are not otherwise using - ANSI STD C, but still have memcpy and memset in your C library - and want to use them in calloc and realloc. Otherwise simple - macro versions are defined here. - - USE_memcpy should be defined as 1 if you actually want to - have memset and memcpy called. People report that the macro - versions are often enough faster than libc versions on many - systems that it is better to use them. - -*/ - -#define HAVE_memcpy - -#ifndef USE_memcpy -#ifdef HAVE_memcpy -#define USE_memcpy 1 -#else -#define USE_memcpy 0 -#endif -#endif - -#if (__STD_C || defined(HAVE_memcpy)) - -#if __STD_C -void* memset(void*, int, size_t); -void* memcpy(void*, const void*, size_t); -#else -Void_t* memset(); -Void_t* memcpy(); -#endif -#endif - -#ifndef DEBUG3 - -#if USE_memcpy - -/* The following macros are only invoked with (2n+1)-multiples of - INTERNAL_SIZE_T units, with a positive integer n. This is exploited - for fast inline execution when n is small. */ - -#define malloc_ZERO(charp, nbytes) \ -do { \ - INTERNAL_SIZE_T mzsz = (nbytes); \ - if(mzsz <= 9*sizeof(mzsz)) { \ - INTERNAL_SIZE_T* mz = (INTERNAL_SIZE_T*) (charp); \ - if(mzsz >= 5*sizeof(mzsz)) { *mz++ = 0; \ - *mz++ = 0; \ - if(mzsz >= 7*sizeof(mzsz)) { *mz++ = 0; \ - *mz++ = 0; \ - if(mzsz >= 9*sizeof(mzsz)) { *mz++ = 0; \ - *mz++ = 0; }}} \ - *mz++ = 0; \ - *mz++ = 0; \ - *mz = 0; \ - } else memset((charp), 0, mzsz); \ -} while(0) - -#define malloc_COPY(dest,src,nbytes) \ -do { \ - INTERNAL_SIZE_T mcsz = (nbytes); \ - if(mcsz <= 9*sizeof(mcsz)) { \ - INTERNAL_SIZE_T* mcsrc = (INTERNAL_SIZE_T*) (src); \ - INTERNAL_SIZE_T* mcdst = (INTERNAL_SIZE_T*) (dest); \ - if(mcsz >= 5*sizeof(mcsz)) { *mcdst++ = *mcsrc++; \ - *mcdst++ = *mcsrc++; \ - if(mcsz >= 7*sizeof(mcsz)) { *mcdst++ = *mcsrc++; \ - *mcdst++ = *mcsrc++; \ - if(mcsz >= 9*sizeof(mcsz)) { *mcdst++ = *mcsrc++; \ - *mcdst++ = *mcsrc++; }}} \ - *mcdst++ = *mcsrc++; \ - *mcdst++ = *mcsrc++; \ - *mcdst = *mcsrc ; \ - } else memcpy(dest, src, mcsz); \ -} while(0) - -#else /* !USE_memcpy */ - -/* Use Duff's device for good zeroing/copying performance. */ - -#define malloc_ZERO(charp, nbytes) \ -do { \ - INTERNAL_SIZE_T* mzp = (INTERNAL_SIZE_T*)(charp); \ - long mctmp = (nbytes)/sizeof(INTERNAL_SIZE_T), mcn; \ - if (mctmp < 8) mcn = 0; else { mcn = (mctmp-1)/8; mctmp %= 8; } \ - switch (mctmp) { \ - case 0: for(;;) { *mzp++ = 0; \ - case 7: *mzp++ = 0; \ - case 6: *mzp++ = 0; \ - case 5: *mzp++ = 0; \ - case 4: *mzp++ = 0; \ - case 3: *mzp++ = 0; \ - case 2: *mzp++ = 0; \ - case 1: *mzp++ = 0; if(mcn <= 0) break; mcn--; } \ - } \ -} while(0) - -#define malloc_COPY(dest,src,nbytes) \ -do { \ - INTERNAL_SIZE_T* mcsrc = (INTERNAL_SIZE_T*) src; \ - INTERNAL_SIZE_T* mcdst = (INTERNAL_SIZE_T*) dest; \ - long mctmp = (nbytes)/sizeof(INTERNAL_SIZE_T), mcn; \ - if (mctmp < 8) mcn = 0; else { mcn = (mctmp-1)/8; mctmp %= 8; } \ - switch (mctmp) { \ - case 0: for(;;) { *mcdst++ = *mcsrc++; \ - case 7: *mcdst++ = *mcsrc++; \ - case 6: *mcdst++ = *mcsrc++; \ - case 5: *mcdst++ = *mcsrc++; \ - case 4: *mcdst++ = *mcsrc++; \ - case 3: *mcdst++ = *mcsrc++; \ - case 2: *mcdst++ = *mcsrc++; \ - case 1: *mcdst++ = *mcsrc++; if(mcn <= 0) break; mcn--; } \ - } \ -} while(0) - -#endif - -#else /* DEBUG3 */ - -/* The trailing moat invalidates the above prediction about the nbytes - parameter to malloc_ZERO and malloc_COPY. */ - -#define malloc_ZERO(charp, nbytes) \ -do { \ - char *mzp = (char *)(charp); \ - long mzn = (nbytes); \ - while (mzn--) \ - *mzp++ = '\0'; \ -} while(0) - -#define malloc_COPY(dest,src,nbytes) \ -do { \ - char *mcsrc = (char *)(src); \ - char *mcdst = (char *)(dest); \ - long mcn = (nbytes); \ - while (mcn--) \ - *mcdst++ = *mcsrc++; \ -} while(0) - -#endif /* DEBUG3 */ - -/* - Define HAVE_MMAP to optionally make malloc() use mmap() to - allocate very large blocks. These will be returned to the - operating system immediately after a free(). -*/ - -#ifndef HAVE_MMAP -#define HAVE_MMAP 1 -#endif - -/* - Define HAVE_MREMAP to make realloc() use mremap() to re-allocate - large blocks. This is currently only possible on Linux with - kernel versions newer than 1.3.77. -*/ - -#ifndef HAVE_MREMAP -#ifdef INTERNAL_LINUX_C_LIB -#define HAVE_MREMAP 1 -#else -#define HAVE_MREMAP 0 -#endif -#endif - -#if HAVE_MMAP - -#include -#include -#include - -#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) -#define MAP_ANONYMOUS MAP_ANON -#endif - -#endif /* HAVE_MMAP */ - -/* - Access to system page size. To the extent possible, this malloc - manages memory from the system in page-size units. - - The following mechanics for getpagesize were adapted from - bsd/gnu getpagesize.h -*/ - -#ifndef LACKS_UNISTD_H -# include -#endif - -#ifndef malloc_getpagesize -# ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */ -# ifndef _SC_PAGE_SIZE -# define _SC_PAGE_SIZE _SC_PAGESIZE -# endif -# endif -# ifdef _SC_PAGE_SIZE -# define malloc_getpagesize sysconf(_SC_PAGE_SIZE) -# else -# if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE) -# if __STD_C - extern size_t getpagesize(void); -# else - extern size_t getpagesize(); -# endif -# define malloc_getpagesize getpagesize() -# else -# include -# ifdef EXEC_PAGESIZE -# define malloc_getpagesize EXEC_PAGESIZE -# else -# ifdef NBPG -# ifndef CLSIZE -# define malloc_getpagesize NBPG -# else -# define malloc_getpagesize (NBPG * CLSIZE) -# endif -# else -# ifdef NBPC -# define malloc_getpagesize NBPC -# else -# ifdef PAGESIZE -# define malloc_getpagesize PAGESIZE -# else -# define malloc_getpagesize (4096) /* just guess */ -# endif -# endif -# endif -# endif -# endif -# endif -#endif - - - -/* - - This version of malloc supports the standard SVID/XPG mallinfo - routine that returns a struct containing the same kind of - information you can get from malloc_stats. It should work on - any SVID/XPG compliant system that has a /usr/include/malloc.h - defining struct mallinfo. (If you'd like to install such a thing - yourself, cut out the preliminary declarations as described above - and below and save them in a malloc.h file. But there's no - compelling reason to bother to do this.) - - The main declaration needed is the mallinfo struct that is returned - (by-copy) by mallinfo(). The SVID/XPG malloinfo struct contains a - bunch of fields, most of which are not even meaningful in this - version of malloc. Some of these fields are are instead filled by - mallinfo() with other numbers that might possibly be of interest. - - HAVE_USR_INCLUDE_malloc_H should be set if you have a - /usr/include/malloc.h file that includes a declaration of struct - mallinfo. If so, it is included; else an SVID2/XPG2 compliant - version is declared below. These must be precisely the same for - mallinfo() to work. - -*/ - -/* #define HAVE_USR_INCLUDE_malloc_H */ - -#if HAVE_USR_INCLUDE_malloc_H -#include "/usr/include/malloc.h" -#else - -/* SVID2/XPG mallinfo structure */ - -struct mallinfo { - int arena; /* total space allocated from system */ - int ordblks; /* number of non-inuse chunks */ - int smblks; /* unused -- always zero */ - int hblks; /* number of mmapped regions */ - int hblkhd; /* total space in mmapped regions */ - int usmblks; /* unused -- always zero */ - int fsmblks; /* unused -- always zero */ - int uordblks; /* total allocated space */ - int fordblks; /* total non-inuse space */ - int keepcost; /* top-most, releasable (via malloc_trim) space */ -}; - -/* SVID2/XPG mallopt options */ - -#define M_MXFAST 1 /* UNUSED in this malloc */ -#define M_NLBLKS 2 /* UNUSED in this malloc */ -#define M_GRAIN 3 /* UNUSED in this malloc */ -#define M_KEEP 4 /* UNUSED in this malloc */ - -#endif - -/* mallopt options that actually do something */ - -#define M_TRIM_THRESHOLD -1 -#define M_TOP_PAD -2 -#define M_MMAP_THRESHOLD -3 -#define M_MMAP_MAX -4 -#define M_SCANHEAP -5 -#define M_FILL - - - -#ifndef DEFAULT_TRIM_THRESHOLD -#define DEFAULT_TRIM_THRESHOLD (128 * 1024) -#endif - -/* - M_TRIM_THRESHOLD is the maximum amount of unused top-most memory - to keep before releasing via malloc_trim in free(). - - Automatic trimming is mainly useful in long-lived programs. - Because trimming via sbrk can be slow on some systems, and can - sometimes be wasteful (in cases where programs immediately - afterward allocate more large chunks) the value should be high - enough so that your overall system performance would improve by - releasing. - - The trim threshold and the mmap control parameters (see below) - can be traded off with one another. Trimming and mmapping are - two different ways of releasing unused memory back to the - system. Between these two, it is often possible to keep - system-level demands of a long-lived program down to a bare - minimum. For example, in one test suite of sessions measuring - the XF86 X server on Linux, using a trim threshold of 128K and a - mmap threshold of 192K led to near-minimal long term resource - consumption. - - If you are using this malloc in a long-lived program, it should - pay to experiment with these values. As a rough guide, you - might set to a value close to the average size of a process - (program) running on your system. Releasing this much memory - would allow such a process to run in memory. Generally, it's - worth it to tune for trimming rather tham memory mapping when a - program undergoes phases where several large chunks are - allocated and released in ways that can reuse each other's - storage, perhaps mixed with phases where there are no such - chunks at all. And in well-behaved long-lived programs, - controlling release of large blocks via trimming versus mapping - is usually faster. - - However, in most programs, these parameters serve mainly as - protection against the system-level effects of carrying around - massive amounts of unneeded memory. Since frequent calls to - sbrk, mmap, and munmap otherwise degrade performance, the default - parameters are set to relatively high values that serve only as - safeguards. - - The default trim value is high enough to cause trimming only in - fairly extreme (by current memory consumption standards) cases. - It must be greater than page size to have any useful effect. To - disable trimming completely, you can set to (unsigned long)(-1); - - -*/ - - -#ifndef DEFAULT_TOP_PAD -#define DEFAULT_TOP_PAD (0) -#endif - -/* - M_TOP_PAD is the amount of extra `padding' space to allocate or - retain whenever sbrk is called. It is used in two ways internally: - - * When sbrk is called to extend the top of the arena to satisfy - a new malloc request, this much padding is added to the sbrk - request. - - * When malloc_trim is called automatically from free(), - it is used as the `pad' argument. - - In both cases, the actual amount of padding is rounded - so that the end of the arena is always a system page boundary. - - The main reason for using padding is to avoid calling sbrk so - often. Having even a small pad greatly reduces the likelihood - that nearly every malloc request during program start-up (or - after trimming) will invoke sbrk, which needlessly wastes - time. - - Automatic rounding-up to page-size units is normally sufficient - to avoid measurable overhead, so the default is 0. However, in - systems where sbrk is relatively slow, it can pay to increase - this value, at the expense of carrying around more memory than - the program needs. - -*/ - - -#ifndef DEFAULT_MMAP_THRESHOLD -#define DEFAULT_MMAP_THRESHOLD (128 * 1024) -#endif - -/* - - M_MMAP_THRESHOLD is the request size threshold for using mmap() - to service a request. Requests of at least this size that cannot - be allocated using already-existing space will be serviced via mmap. - (If enough normal freed space already exists it is used instead.) - - Using mmap segregates relatively large chunks of memory so that - they can be individually obtained and released from the host - system. A request serviced through mmap is never reused by any - other request (at least not directly; the system may just so - happen to remap successive requests to the same locations). - - Segregating space in this way has the benefit that mmapped space - can ALWAYS be individually released back to the system, which - helps keep the system level memory demands of a long-lived - program low. Mapped memory can never become `locked' between - other chunks, as can happen with normally allocated chunks, which - menas that even trimming via malloc_trim would not release them. - - However, it has the disadvantages that: - - 1. The space cannot be reclaimed, consolidated, and then - used to service later requests, as happens with normal chunks. - 2. It can lead to more wastage because of mmap page alignment - requirements - 3. It causes malloc performance to be more dependent on host - system memory management support routines which may vary in - implementation quality and may impose arbitrary - limitations. Generally, servicing a request via normal - malloc steps is faster than going through a system's mmap. - - All together, these considerations should lead you to use mmap - only for relatively large requests. - - -*/ - - - -#ifndef DEFAULT_MMAP_MAX -#if HAVE_MMAP -#define DEFAULT_MMAP_MAX (64) -#else -#define DEFAULT_MMAP_MAX (0) -#endif -#endif - -/* - M_MMAP_MAX is the maximum number of requests to simultaneously - service using mmap. This parameter exists because: - - 1. Some systems have a limited number of internal tables for - use by mmap. - 2. In most systems, overreliance on mmap can degrade overall - performance. - 3. If a program allocates many large regions, it is probably - better off using normal sbrk-based allocation routines that - can reclaim and reallocate normal heap memory. Using a - small value allows transition into this mode after the - first few allocations. - - Setting to 0 disables all use of mmap. If HAVE_MMAP is not set, - the default value is 0, and attempts to set it to non-zero values - in mallopt will fail. -*/ - - - - -/* - - Special defines for linux libc - - Except when compiled using these special defines for Linux libc - using weak aliases, this malloc is NOT designed to work in - multithreaded applications. No semaphores or other concurrency - control are provided to ensure that multiple malloc or free calls - don't run at the same time, which could be disasterous. A single - semaphore could be used across malloc, realloc, and free (which is - essentially the effect of the linux weak alias approach). It would - be hard to obtain finer granularity. - -*/ - - -#ifdef INTERNAL_LINUX_C_LIB - -#if __STD_C - -Void_t * __default_morecore_init (ptrdiff_t); -Void_t *(*__morecore)(ptrdiff_t) = __default_morecore_init; - -#else - -Void_t * __default_morecore_init (); -Void_t *(*__morecore)() = __default_morecore_init; - -#endif - -#define MORECORE (*__morecore) -#define MORECORE_FAILURE 0 -#define MORECORE_CLEARS 1 - -#else /* INTERNAL_LINUX_C_LIB */ - -#if __STD_C -/* extern Void_t* sbrk(ptrdiff_t);*/ -#else -extern Void_t* sbrk(); -#endif - -#ifndef MORECORE -#define MORECORE sbrk -#endif - -#ifndef MORECORE_FAILURE -#define MORECORE_FAILURE -1 -#endif - -#ifndef MORECORE_CLEARS -#define MORECORE_CLEARS 0 -#endif - -#endif /* INTERNAL_LINUX_C_LIB */ - -#if defined(INTERNAL_LINUX_C_LIB) && defined(__ELF__) - -#define cALLOc __libc_calloc -#define fREe __libc_free -#define mALLOc __libc_malloc -#define mEMALIGn __libc_memalign -#define rEALLOc __libc_realloc -#define vALLOc __libc_valloc -#define pvALLOc __libc_pvalloc -#define mALLINFo __libc_mallinfo -#define mALLOPt __libc_mallopt - -#pragma weak calloc = __libc_calloc -#pragma weak free = __libc_free -#pragma weak cfree = __libc_free -#pragma weak malloc = __libc_malloc -#pragma weak memalign = __libc_memalign -#pragma weak realloc = __libc_realloc -#pragma weak valloc = __libc_valloc -#pragma weak pvalloc = __libc_pvalloc -#pragma weak mallinfo = __libc_mallinfo -#pragma weak mallopt = __libc_mallopt - -#else - -#ifndef cALLOc -#define cALLOc dlcalloc -#endif -#ifndef fREe -#define fREe dlfree -#endif -#ifndef mALLOc -#define mALLOc dlmalloc -#endif -#ifndef mEMALIGn -#define mEMALIGn dlmemalign -#endif -#ifndef rEALLOc -#define rEALLOc dlrealloc -#endif -#ifndef vALLOc -#define vALLOc dlvalloc -#endif -#ifndef pvALLOc -#define pvALLOc dlpvalloc -#endif -#ifndef mALLINFo -#define mALLINFo dlmallinfo -#endif -#ifndef mALLOPt -#define mALLOPt dlmallopt -#endif - -#endif - -/* Public routines */ - -#ifdef DEBUG2 -#define malloc(size) malloc_dbg(size, __FILE__, __LINE__) -#define free(p) free_dbg(p, __FILE__, __LINE__) -#define realloc(p, size) realloc_dbg(p, size, __FILE__, __LINE__) -#define calloc(n, size) calloc_dbg(n, size, __FILE__, __LINE__) -#define memalign(align, size) memalign_dbg(align, size, __FILE__, __LINE__) -#define valloc(size) valloc_dbg(size, __FILE__, __LINE__) -#define pvalloc(size) pvalloc_dbg(size, __FILE__, __LINE__) -#define malloc_trim(pad) malloc_trim_dbg(pad, __FILE__, __LINE__) -#define malloc_usable_size(p) malloc_usable_size_dbg(p, __FILE__, __LINE__) -#define malloc_stats(void) malloc_stats_dbg(__FILE__, __LINE__) -#define mallopt(flag, val) mallopt_dbg(flag, val, __FILE__, __LINE__) -#define mallinfo(void) mallinfo_dbg(__FILE__, __LINE__) - -#if __STD_C -Void_t* malloc_dbg(size_t, const char *, int); -void free_dbg(Void_t*, const char *, int); -Void_t* realloc_dbg(Void_t*, size_t, const char *, int); -Void_t* calloc_dbg(size_t, size_t, const char *, int); -Void_t* memalign_dbg(size_t, size_t, const char *, int); -Void_t* valloc_dbg(size_t, const char *, int); -Void_t* pvalloc_dbg(size_t, const char *, int); -int malloc_trim_dbg(size_t, const char *, int); -size_t malloc_usable_size_dbg(Void_t*, const char *, int); -void malloc_stats_dbg(const char *, int); -int mallopt_dbg(int, int, const char *, int); -struct mallinfo mallinfo_dbg(const char *, int); -#else -Void_t* malloc_dbg(); -void free_dbg(); -Void_t* realloc_dbg(); -Void_t* calloc_dbg(); -Void_t* memalign_dbg(); -Void_t* valloc_dbg(); -Void_t* pvalloc_dbg(); -int malloc_trim_dbg(); -size_t malloc_usable_size_dbg(); -void malloc_stats_dbg(); -int mallopt_dbg(); -struct mallinfo mallinfo_dbg(); -#endif /* !__STD_C */ - -#else /* !DEBUG2 */ - -#if __STD_C - -Void_t* mALLOc(size_t); -void fREe(Void_t*); -Void_t* rEALLOc(Void_t*, size_t); -Void_t* cALLOc(size_t, size_t); -Void_t* mEMALIGn(size_t, size_t); -Void_t* vALLOc(size_t); -Void_t* pvALLOc(size_t); -int malloc_trim(size_t); -size_t malloc_usable_size(Void_t*); -void malloc_stats(void); -int mALLOPt(int, int); -struct mallinfo mALLINFo(void); -#else -Void_t* mALLOc(); -void fREe(); -Void_t* rEALLOc(); -Void_t* cALLOc(); -Void_t* mEMALIGn(); -Void_t* vALLOc(); -Void_t* pvALLOc(); -int malloc_trim(); -size_t malloc_usable_size(); -void malloc_stats(); -int mALLOPt(); -struct mallinfo mALLINFo(); -#endif -#endif /* !DEBUG2 */ - -#ifdef __cplusplus -}; /* end of extern "C" */ -#endif - -/* ---------- To make a malloc.h, end cutting here ------------ */ - -#ifdef DEBUG2 - -#ifdef __cplusplus -extern "C" { -#endif - -#undef malloc -#undef free -#undef realloc -#undef calloc -#undef memalign -#undef valloc -#undef pvalloc -#undef malloc_trim -#undef malloc_usable_size -#undef malloc_stats -#undef mallopt -#undef mallinfo - -#if __STD_C -Void_t* mALLOc(size_t); -void fREe(Void_t*); -Void_t* rEALLOc(Void_t*, size_t); -Void_t* cALLOc(size_t, size_t); -Void_t* mEMALIGn(size_t, size_t); -Void_t* vALLOc(size_t); -Void_t* pvALLOc(size_t); -int malloc_trim(size_t); -size_t malloc_usable_size(Void_t*); -void malloc_stats(void); -int mALLOPt(int, int); -struct mallinfo mALLINFo(void); -#else -Void_t* mALLOc(); -void fREe(); -Void_t* rEALLOc(); -Void_t* cALLOc(); -Void_t* mEMALIGn(); -Void_t* vALLOc(); -Void_t* pvALLOc(); -int malloc_trim(); -size_t malloc_usable_size(); -void malloc_stats(); -int mALLOPt(); -struct mallinfo mALLINFo(); -#endif - -#include /* isprint() */ -#ifdef DEBUG3 -#include /* atexit() */ -#endif - -#ifdef __cplusplus -}; /* end of extern "C" */ -#endif - -#endif /* DEBUG2 */ - -/* - Emulation of sbrk for WIN32 - All code within the ifdef WIN32 is untested by me. -*/ - - -#ifdef WIN32 - -#define AlignPage(add) (((add) + (malloc_getpagesize-1)) & \ - ~(malloc_getpagesize-1)) - -/* resrve 64MB to insure large contiguous space */ -#define RESERVED_SIZE (1024*1024*64) -#define NEXT_SIZE (2048*1024) -#define TOP_MEMORY ((unsigned long)2*1024*1024*1024) - -struct GmListElement; -typedef struct GmListElement GmListElement; - -struct GmListElement -{ - GmListElement* next; - void* base; -}; - -static GmListElement* head = 0; -static unsigned int gNextAddress = 0; -static unsigned int gAddressBase = 0; -static unsigned int gAllocatedSize = 0; - -static -GmListElement* makeGmListElement (void* bas) -{ - GmListElement* this; - this = (GmListElement*)(void*)LocalAlloc (0, sizeof (GmListElement)); - ASSERT (this); - if (this) - { - this->base = bas; - this->next = head; - head = this; - } - return this; -} - -void gcleanup () -{ - BOOL rval; - ASSERT ( (head == NULL) || (head->base == (void*)gAddressBase)); - if (gAddressBase && (gNextAddress - gAddressBase)) - { - rval = VirtualFree ((void*)gAddressBase, - gNextAddress - gAddressBase, - MEM_DECOMMIT); - ASSERT (rval); - } - while (head) - { - GmListElement* next = head->next; - rval = VirtualFree (head->base, 0, MEM_RELEASE); - ASSERT (rval); - LocalFree (head); - head = next; - } -} - -static -void* findRegion (void* start_address, unsigned long size) -{ - MEMORY_BASIC_INFORMATION info; - while ((unsigned long)start_address < TOP_MEMORY) - { - VirtualQuery (start_address, &info, sizeof (info)); - if (info.State != MEM_FREE) - start_address = (char*)info.BaseAddress + info.RegionSize; - else if (info.RegionSize >= size) - return start_address; - else - start_address = (char*)info.BaseAddress + info.RegionSize; - } - return NULL; - -} - - -void* wsbrk (long size) -{ - void* tmp; - if (size > 0) - { - if (gAddressBase == 0) - { - gAllocatedSize = max (RESERVED_SIZE, AlignPage (size)); - gNextAddress = gAddressBase = - (unsigned int)VirtualAlloc (NULL, gAllocatedSize, - MEM_RESERVE, PAGE_NOACCESS); - } else if (AlignPage (gNextAddress + size) > (gAddressBase + -gAllocatedSize)) - { - long new_size = max (NEXT_SIZE, AlignPage (size)); - void* new_address = (void*)(gAddressBase+gAllocatedSize); - do - { - new_address = findRegion (new_address, new_size); - - if (new_address == 0) - return (void*)-1; - - gAddressBase = gNextAddress = - (unsigned int)VirtualAlloc (new_address, new_size, - MEM_RESERVE, PAGE_NOACCESS); - // repeat in case of race condition - // The region that we found has been snagged - // by another thread - } - while (gAddressBase == 0); - - ASSERT (new_address == (void*)gAddressBase); - - gAllocatedSize = new_size; - - if (!makeGmListElement ((void*)gAddressBase)) - return (void*)-1; - } - if ((size + gNextAddress) > AlignPage (gNextAddress)) - { - void* res; - res = VirtualAlloc ((void*)AlignPage (gNextAddress), - (size + gNextAddress - - AlignPage (gNextAddress)), - MEM_COMMIT, PAGE_READWRITE); - if (res == 0) - return (void*)-1; - } - tmp = (void*)gNextAddress; - gNextAddress = (unsigned int)tmp + size; - return tmp; - } - else if (size < 0) - { - unsigned int alignedGoal = AlignPage (gNextAddress + size); - /* Trim by releasing the virtual memory */ - if (alignedGoal >= gAddressBase) - { - VirtualFree ((void*)alignedGoal, gNextAddress - alignedGoal, - MEM_DECOMMIT); - gNextAddress = gNextAddress + size; - return (void*)gNextAddress; - } - else - { - VirtualFree ((void*)gAddressBase, gNextAddress - gAddressBase, - MEM_DECOMMIT); - gNextAddress = gAddressBase; - return (void*)-1; - } - } - else - { - return (void*)gNextAddress; - } -} - -#endif - - - -/* - Type declarations -*/ - -#ifdef DEBUG3 -# define MOATWIDTH 4 /* number of guard bytes at each end of - allocated region */ -# define MOATFILL 5 /* moat fill character */ -# define ALLOCFILL 1 /* fill char for allocated */ -# define FREEFILL 2 /* and freed regions */ -#endif - -typedef struct malloc_chunk -{ - INTERNAL_SIZE_T prev_size; /* Size of previous chunk (if free). */ - INTERNAL_SIZE_T size; /* Size in bytes, including overhead. */ - struct malloc_chunk* fd; /* double links -- used only if free. */ - struct malloc_chunk* bk; -#ifdef DEBUG3 - const char *file; /* file and */ - int line; /* line number of [re]allocation */ - size_t pad; /* nr pad bytes at mem end, excluding moat */ - int alloced; /* whether the chunk is allocated -- less prone - to segv than inuse(chunk) */ - char moat[MOATWIDTH]; /* actual leading moat is last MOATWIDTH bytes - of chunk header; those bytes may follow this - field due to header alignment padding */ -#endif -} Chunk; - -typedef Chunk* mchunkptr; - -/* - - malloc_chunk details: - - (The following includes lightly edited explanations by Colin Plumb.) - - Chunks of memory are maintained using a `boundary tag' method as - described in e.g., Knuth or Standish. (See the paper by Paul - Wilson ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps for a - survey of such techniques.) Sizes of free chunks are stored both - in the front of each chunk and at the end. This makes - consolidating fragmented chunks into bigger chunks very fast. The - size fields also hold bits representing whether chunks are free or - in use. - - An allocated chunk looks like this: - - - chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of previous chunk, if allocated | | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of chunk, in bytes |P| - mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | User data starts here... . - . . - . (malloc_usable_space() bytes) . - . | -nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of chunk | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - - Where "chunk" is the front of the chunk for the purpose of most of - the malloc code, but "mem" is the pointer that is returned to the - user. "Nextchunk" is the beginning of the next contiguous chunk. - - Chunks always begin on even word boundries, so the mem portion - (which is returned to the user) is also on an even word boundary, and - thus double-word aligned. - - Free chunks are stored in circular doubly-linked lists, and look like this: - - chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of previous chunk | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - `head:' | Size of chunk, in bytes |P| - mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Forward pointer to next chunk in list | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Back pointer to previous chunk in list | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Unused space (may be 0 bytes long) . - . . - . | -nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - `foot:' | Size of chunk, in bytes | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - The P (PREV_INUSE) bit, stored in the unused low-order bit of the - chunk size (which is always a multiple of two words), is an in-use - bit for the *previous* chunk. If that bit is *clear*, then the - word before the current chunk size contains the previous chunk - size, and can be used to find the front of the previous chunk. - (The very first chunk allocated always has this bit set, - preventing access to non-existent (or non-owned) memory.) - - Note that the `foot' of the current chunk is actually represented - as the prev_size of the NEXT chunk. (This makes it easier to - deal with alignments etc). - - The two exceptions to all this are - - 1. The special chunk `top', which doesn't bother using the - trailing size field since there is no - next contiguous chunk that would have to index off it. (After - initialization, `top' is forced to always exist. If it would - become less than MINSIZE bytes long, it is replenished via - malloc_extend_top.) - - 2. Chunks allocated via mmap, which have the second-lowest-order - bit (IS_MMAPPED) set in their size fields. Because they are - never merged or traversed from any other chunk, they have no - foot size or inuse information. - - Available chunks are kept in any of several places (all declared below): - - * `av': An array of chunks serving as bin headers for consolidated - chunks. Each bin is doubly linked. The bins are approximately - proportionally (log) spaced. There are a lot of these bins - (128). This may look excessive, but works very well in - practice. All procedures maintain the invariant that no - consolidated chunk physically borders another one. Chunks in - bins are kept in size order, with ties going to the - approximately least recently used chunk. - - The chunks in each bin are maintained in decreasing sorted order by - size. This is irrelevant for the small bins, which all contain - the same-sized chunks, but facilitates best-fit allocation for - larger chunks. (These lists are just sequential. Keeping them in - order almost never requires enough traversal to warrant using - fancier ordered data structures.) Chunks of the same size are - linked with the most recently freed at the front, and allocations - are taken from the back. This results in LRU or FIFO allocation - order, which tends to give each chunk an equal opportunity to be - consolidated with adjacent freed chunks, resulting in larger free - chunks and less fragmentation. - - * `top': The top-most available chunk (i.e., the one bordering the - end of available memory) is treated specially. It is never - included in any bin, is used only if no other chunk is - available, and is released back to the system if it is very - large (see M_TRIM_THRESHOLD). - - * `last_remainder': A bin holding only the remainder of the - most recently split (non-top) chunk. This bin is checked - before other non-fitting chunks, so as to provide better - locality for runs of sequentially allocated chunks. - - * Implicitly, through the host system's memory mapping tables. - If supported, requests greater than a threshold are usually - serviced via calls to mmap, and then later released via munmap. - -*/ - - - - - - -/* sizes, alignments */ - -#define SIZE_SZ sizeof(INTERNAL_SIZE_T) -#define ALIGNMENT (SIZE_SZ + SIZE_SZ) -#define ALIGN_MASK (ALIGNMENT - 1) -#ifndef DEBUG3 -# define MEMOFFSET (2*SIZE_SZ) -# define OVERHEAD SIZE_SZ -# define MMAP_EXTRA SIZE_SZ /* for correct alignment */ -# define MINSIZE sizeof(Chunk) -#else -typedef union { - char strut[(sizeof(Chunk) - 1) / ALIGNMENT + 1][ALIGNMENT]; - Chunk chunk; -} PaddedChunk; -# define MEMOFFSET sizeof(PaddedChunk) -# define OVERHEAD (MEMOFFSET + MOATWIDTH) -# define MMAP_EXTRA 0 -# define MINSIZE ((OVERHEAD + ALIGN_MASK) & ~ALIGN_MASK) -#endif - -/* conversion from malloc headers to user pointers, and back */ - -#define chunk2mem(p) ((Void_t*)((char*)(p) + MEMOFFSET)) -#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - MEMOFFSET)) - -/* pad request bytes into a usable size, including overhead */ - -#define request2size(req) \ - ((long)((req) + OVERHEAD) < (long)MINSIZE ? MINSIZE : \ - ((req) + OVERHEAD + ALIGN_MASK) & ~ALIGN_MASK) - -/* Check if m has acceptable alignment */ - -#define aligned_OK(m) (((unsigned long)((m)) & ALIGN_MASK) == 0) - - - - -/* - Physical chunk operations -*/ - - -/* size field is or'ed with PREV_INUSE when previous adjacent chunk in use */ - -#define PREV_INUSE 0x1 - -/* size field is or'ed with IS_MMAPPED if the chunk was obtained with mmap() */ - -#define IS_MMAPPED 0x2 - -/* Bits to mask off when extracting size */ - -#define SIZE_BITS (PREV_INUSE|IS_MMAPPED) - - -/* Ptr to next physical malloc_chunk. */ - -#define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->size & ~PREV_INUSE) )) - -/* Ptr to previous physical malloc_chunk */ - -#define prev_chunk(p)\ - ((mchunkptr)( ((char*)(p)) - ((p)->prev_size) )) - - -/* Treat space at ptr + offset as a chunk */ - -#define chunk_at_offset(p, s) ((mchunkptr)(((char*)(p)) + (s))) - - - - -/* - Dealing with use bits -*/ - -/* extract p's inuse bit */ - -#define inuse(p)\ -((((mchunkptr)(((char*)(p))+((p)->size & ~PREV_INUSE)))->size) & PREV_INUSE) - -/* extract inuse bit of previous chunk */ - -#define prev_inuse(p) ((p)->size & PREV_INUSE) - -/* check for mmap()'ed chunk */ - -#if HAVE_MMAP -# define chunk_is_mmapped(p) ((p)->size & IS_MMAPPED) -#else -# define chunk_is_mmapped(p) 0 -#endif - -/* set/clear chunk as in use without otherwise disturbing */ - -#define set_inuse(p)\ -((mchunkptr)(((char*)(p)) + ((p)->size & ~PREV_INUSE)))->size |= PREV_INUSE - -#define clear_inuse(p)\ -((mchunkptr)(((char*)(p)) + ((p)->size & ~PREV_INUSE)))->size &= ~(PREV_INUSE) - -/* check/set/clear inuse bits in known places */ - -#define inuse_bit_at_offset(p, s)\ - (((mchunkptr)(((char*)(p)) + (s)))->size & PREV_INUSE) - -#define set_inuse_bit_at_offset(p, s)\ - (((mchunkptr)(((char*)(p)) + (s)))->size |= PREV_INUSE) - -#define clear_inuse_bit_at_offset(p, s)\ - (((mchunkptr)(((char*)(p)) + (s)))->size &= ~(PREV_INUSE)) - - - - -/* - Dealing with size fields -*/ - -/* Get size, ignoring use bits */ - -#define chunksize(p) ((p)->size & ~(SIZE_BITS)) - -/* Set size at head, without disturbing its use bit */ - -#define set_head_size(p, s) ((p)->size = (((p)->size & PREV_INUSE) | (s))) - -/* Set size/use ignoring previous bits in header */ - -#define set_head(p, s) ((p)->size = (s)) - -/* Set size at footer (only when chunk is not in use) */ - -#define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_size = (s)) - - - - - -/* - Bins - - The bins, `av_' are an array of pairs of pointers serving as the - heads of (initially empty) doubly-linked lists of chunks, laid out - in a way so that each pair can be treated as if it were in a - malloc_chunk. (This way, the fd/bk offsets for linking bin heads - and chunks are the same). - - Bins for sizes < 512 bytes contain chunks of all the same size, spaced - 8 bytes apart. Larger bins are approximately logarithmically - spaced. (See the table below.) The `av_' array is never mentioned - directly in the code, but instead via bin access macros. - - Bin layout: - - 64 bins of size 8 - 32 bins of size 64 - 16 bins of size 512 - 8 bins of size 4096 - 4 bins of size 32768 - 2 bins of size 262144 - 1 bin of size what's left - - There is actually a little bit of slop in the numbers in bin_index - for the sake of speed. This makes no difference elsewhere. - - The special chunks `top' and `last_remainder' get their own bins, - (this is implemented via yet more trickery with the av_ array), - although `top' is never properly linked to its bin since it is - always handled specially. - -*/ - -#define NAV 128 /* number of bins */ - -typedef Chunk* mbinptr; - -/* access macros */ - -#define bin_at(i) ((mbinptr)((char*)&(av_[2*(i) + 2]) - 2*SIZE_SZ)) -#define next_bin(b) ((mbinptr)((char*)(b) + 2 * sizeof(mbinptr))) -#define prev_bin(b) ((mbinptr)((char*)(b) - 2 * sizeof(mbinptr))) - -/* - The first 2 bins are never indexed. The corresponding av_ cells are instead - used for bookkeeping. This is not to save space, but to simplify - indexing, maintain locality, and avoid some initialization tests. -*/ - -#define top (bin_at(0)->fd) /* The topmost chunk */ -#define last_remainder (bin_at(1)) /* remainder from last split */ - - -/* - Because top initially points to its own bin with initial - zero size, thus forcing extension on the first malloc request, - we avoid having any special code in malloc to check whether - it even exists yet. But we still need to in malloc_extend_top. -*/ - -#define initial_top ((mchunkptr)(bin_at(0))) - -/* Helper macro to initialize bins */ - -#define IAV(i) bin_at(i), bin_at(i) - -static mbinptr av_[NAV * 2 + 2] = { - 0, 0, - IAV(0), IAV(1), IAV(2), IAV(3), IAV(4), IAV(5), IAV(6), IAV(7), - IAV(8), IAV(9), IAV(10), IAV(11), IAV(12), IAV(13), IAV(14), IAV(15), - IAV(16), IAV(17), IAV(18), IAV(19), IAV(20), IAV(21), IAV(22), IAV(23), - IAV(24), IAV(25), IAV(26), IAV(27), IAV(28), IAV(29), IAV(30), IAV(31), - IAV(32), IAV(33), IAV(34), IAV(35), IAV(36), IAV(37), IAV(38), IAV(39), - IAV(40), IAV(41), IAV(42), IAV(43), IAV(44), IAV(45), IAV(46), IAV(47), - IAV(48), IAV(49), IAV(50), IAV(51), IAV(52), IAV(53), IAV(54), IAV(55), - IAV(56), IAV(57), IAV(58), IAV(59), IAV(60), IAV(61), IAV(62), IAV(63), - IAV(64), IAV(65), IAV(66), IAV(67), IAV(68), IAV(69), IAV(70), IAV(71), - IAV(72), IAV(73), IAV(74), IAV(75), IAV(76), IAV(77), IAV(78), IAV(79), - IAV(80), IAV(81), IAV(82), IAV(83), IAV(84), IAV(85), IAV(86), IAV(87), - IAV(88), IAV(89), IAV(90), IAV(91), IAV(92), IAV(93), IAV(94), IAV(95), - IAV(96), IAV(97), IAV(98), IAV(99), IAV(100), IAV(101), IAV(102), IAV(103), - IAV(104), IAV(105), IAV(106), IAV(107), IAV(108), IAV(109), IAV(110), IAV(111), - IAV(112), IAV(113), IAV(114), IAV(115), IAV(116), IAV(117), IAV(118), IAV(119), - IAV(120), IAV(121), IAV(122), IAV(123), IAV(124), IAV(125), IAV(126), IAV(127) -}; - - - -/* field-extraction macros */ - -#define first(b) ((b)->fd) -#define last(b) ((b)->bk) - -/* - Indexing into bins -*/ - -#define bin_index(sz) \ -(((((unsigned long)(sz)) >> 9) == 0) ? (((unsigned long)(sz)) >> 3): \ - ((((unsigned long)(sz)) >> 9) <= 4) ? 56 + (((unsigned long)(sz)) >> 6): \ - ((((unsigned long)(sz)) >> 9) <= 20) ? 91 + (((unsigned long)(sz)) >> 9): \ - ((((unsigned long)(sz)) >> 9) <= 84) ? 110 + (((unsigned long)(sz)) >> 12): \ - ((((unsigned long)(sz)) >> 9) <= 340) ? 119 + (((unsigned long)(sz)) >> 15): \ - ((((unsigned long)(sz)) >> 9) <= 1364) ? 124 + (((unsigned long)(sz)) >> 18): \ - 126) -/* - bins for chunks < 512 are all spaced 8 bytes apart, and hold - identically sized chunks. This is exploited in malloc. -*/ - -#define MAX_SMALLBIN 63 -#define MAX_SMALLBIN_SIZE 512 -#define SMALLBIN_WIDTH 8 - -#define smallbin_index(sz) (((unsigned long)(sz)) >> 3) - -/* - Requests are `small' if both the corresponding and the next bin are small -*/ - -#define is_small_request(nb) (nb < MAX_SMALLBIN_SIZE - SMALLBIN_WIDTH) - - - -/* - To help compensate for the large number of bins, a one-level index - structure is used for bin-by-bin searching. `binblocks' is a - one-word bitvector recording whether groups of BINBLOCKWIDTH bins - have any (possibly) non-empty bins, so they can be skipped over - all at once during during traversals. The bits are NOT always - cleared as soon as all bins in a block are empty, but instead only - when all are noticed to be empty during traversal in malloc. -*/ - -#define BINBLOCKWIDTH 4 /* bins per block */ - -#define binblocks (bin_at(0)->size) /* bitvector of nonempty blocks */ - -/* bin<->block macros */ - -#define idx2binblock(ix) ((unsigned)1 << (ix / BINBLOCKWIDTH)) -#define mark_binblock(ii) (binblocks |= idx2binblock(ii)) -#define clear_binblock(ii) (binblocks &= ~(idx2binblock(ii))) - - - - - -/* Other static bookkeeping data */ - -/* variables holding tunable values */ - -static unsigned long trim_threshold = DEFAULT_TRIM_THRESHOLD; -static unsigned long top_pad = DEFAULT_TOP_PAD; -static unsigned int n_mmaps_max = DEFAULT_MMAP_MAX; -static unsigned long mmap_threshold = DEFAULT_MMAP_THRESHOLD; -#ifdef DEBUG2 -static int scanheap = 1; -#endif - -/* The first value returned from sbrk */ -static char* sbrk_base = (char*)(-1); - -/* The maximum memory obtained from system via sbrk */ -static unsigned long max_sbrked_mem = 0; - -/* The maximum via either sbrk or mmap */ -static unsigned long max_total_mem = 0; - -/* internal working copy of mallinfo */ -static struct mallinfo current_mallinfo = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - -/* The total memory obtained from system via sbrk */ -#define sbrked_mem (current_mallinfo.arena) - -/* Tracking mmaps */ - -static unsigned int n_mmaps = 0; -static unsigned long mmapped_mem = 0; -#if HAVE_MMAP -static unsigned int max_n_mmaps = 0; -static unsigned long max_mmapped_mem = 0; -#endif - - - -/* - Debugging support -*/ - -#if DEBUG - -#ifndef DEBUG2 -# define unless(cond, err, p) assert(cond) -#else -# define unless(cond, err, p) do { if (!(cond)) malloc_err(err, p); } while (0) - -/* - * When debug_file is non-null, it and debug_line respectively contain the - * file and line number of the current invocation of malloc(), calloc(), - * realloc(), or free(). - */ -static const char *debug_file = NULL; -static int debug_line; - -/* - * Avoid dereferencing invalid chunk.file pointers by tracking the range of - * valid ones. Could add an "unallocated" flag to init_freed_chunk() for - * more protection, but that's probably not necessary. - */ -static const char *debug_file_min = (char *)~0; -static const char *debug_file_max = NULL; - -static char *itos(int n) -{ -#define NDIGITS (sizeof(int) * 3) - static char s[NDIGITS + 1]; - int i = NDIGITS; - do { - s[--i] = '0' + n % 10; - n /= 10; - } while (n); - return s + i; -#undef NDIGITS -} - -static int recurs = 0; - -static void errprint(const char *file, int line, const char *err) -{ - if (recurs++) { - recurs--; - return; - } - - if (file) { - write(2, file, strlen(file)); - if (line) { - write(2, ":", 1); - write(2, itos(line), strlen(itos(line))); - } - write(2, ": ", 2); - } - write(2, err, strlen(err)); - write(2, "\n", 1); - recurs--; -} - -static void malloc_err(const char *err, mchunkptr p) -{ - /* - * Display ERR on stderr, accompanying it with the caller's file and line - * number if available. If P is non-null, also attempt to display the file - * and line number at which P was most recently [re]allocated. - * - * This function's name begins with "malloc_" to make setting debugger - * breakpoints here more convenient. - */ - errprint(debug_file, debug_line, err); - -# ifndef DEBUG3 - p = 0; /* avoid "unused param" warning */ -# else - if (p && p->file && - /* avoid invalid pointers */ - debug_file_min && - p->file >= debug_file_min && - p->file <= debug_file_max) - errprint(p->file, p->line, "in block allocated here"); -# endif -} - -#undef malloc -#undef free -#undef realloc -#undef memalign -#undef valloc -#undef pvalloc -#undef calloc -#undef malloc_trim -#undef malloc_usable_size -#undef malloc_stats -#undef mallopt -#undef mallinfo - -static void malloc_update_mallinfo(void); - -/* - * Define front-end functions for all user-visible entry points that may - * trigger error(). - */ -#define skel(retdecl, retassign, call, retstmt) \ - retdecl \ - debug_file = file; \ - debug_line = line; \ - if (debug_file < debug_file_min) \ - debug_file_min = debug_file; \ - if (debug_file > debug_file_max) \ - debug_file_max = debug_file; \ - if (scanheap) \ - malloc_update_mallinfo(); \ - retassign call; \ - if (scanheap) \ - malloc_update_mallinfo(); \ - debug_file = NULL; \ - retstmt - -/* - * The final letter of the names of the following macros is either r or v, - * indicating that the macro handles functions with or without a return value, - * respectively. - */ -# define skelr(rettype, call) \ - skel(rettype ret;, ret = , call, return ret) -/* - * AIX's xlc compiler doesn't like empty macro args, so specify useless but - * compilable retdecl, retassign, and retstmt args: - */ -#define skelv(call) \ - skel(line += 0;, if (1), call, return) - -#define dbgargs const char *file, int line - -/* - * Front-end function definitions: - */ -Void_t* malloc_dbg(size_t bytes, dbgargs) { - skelr(Void_t*, malloc(bytes)); -} -void free_dbg(Void_t *mem, dbgargs) { - skelv(free(mem)); -} -Void_t* realloc_dbg(Void_t *oldmem, size_t bytes, dbgargs) { - skelr(Void_t*, realloc(oldmem, bytes)); -} -Void_t* memalign_dbg(size_t alignment, size_t bytes, dbgargs) { - skelr(Void_t*, dlmemalign(alignment, bytes)); -} -Void_t* valloc_dbg(size_t bytes, dbgargs) { - skelr(Void_t*, dlvalloc(bytes)); -} -Void_t* pvalloc_dbg(size_t bytes, dbgargs) { - skelr(Void_t*, dlpvalloc(bytes)); -} -Void_t* calloc_dbg(size_t n, size_t elem_size, dbgargs) { - skelr(Void_t*, calloc(n, elem_size)); -} -int malloc_trim_dbg(size_t pad, dbgargs) { - skelr(int, malloc_trim(pad)); -} -size_t malloc_usable_size_dbg(Void_t *mem, dbgargs) { - skelr(size_t, malloc_usable_size(mem)); -} -void malloc_stats_dbg(dbgargs) { - skelv(malloc_stats()); -} -int mallopt_dbg(int flag, int value, dbgargs) { - skelr(int, dlmallopt(flag, value)); -} -struct mallinfo mallinfo_dbg(dbgargs) { - skelr(struct mallinfo, dlmallinfo()); -} - -#undef skel -#undef skelr -#undef skelv -#undef dbgargs - -#endif /* DEBUG2 */ - -/* - These routines make a number of assertions about the states - of data structures that should be true at all times. If any - are not true, it's very likely that a user program has somehow - trashed memory. (It's also possible that there is a coding error - in malloc. In which case, please report it!) -*/ - -#ifdef DEBUG3 -static int memtest(void *s, int c, size_t n) -{ - /* - * Return whether the N-byte memory region starting at S consists - * entirely of bytes with value C. - */ - unsigned char *p = (unsigned char *)s; - size_t i; - for (i = 0; i < n; i++) - if (p[i] != (unsigned char)c) - return 0; - return 1; -} -#endif /* DEBUG3 */ - -#ifndef DEBUG3 -#define check_moats(P) -#else -#define check_moats do_check_moats -static void do_check_moats(mchunkptr p) -{ - INTERNAL_SIZE_T sz = chunksize(p); - unless(memtest((char *)chunk2mem(p) - MOATWIDTH, MOATFILL, - MOATWIDTH), "region underflow", p); - unless(memtest((char *)p + sz - MOATWIDTH - p->pad, MOATFILL, - MOATWIDTH + p->pad), "region overflow", p); -} -#endif /* DEBUG3 */ - -#if __STD_C -static void do_check_chunk(mchunkptr p) -#else -static void do_check_chunk(p) mchunkptr p; -#endif -{ - /* Try to ensure legal addresses before accessing any chunk fields, in the - * hope of issuing an informative message rather than causing a segv. - * - * The following chunk_is_mmapped() call accesses p->size #if HAVE_MMAP. - * This is unavoidable without maintaining a record of mmapped regions. - */ - if (!chunk_is_mmapped(p)) - { - INTERNAL_SIZE_T sz; - - unless((char*)p >= sbrk_base, "chunk precedes sbrk_base", p); - unless((char*)p + MINSIZE <= (char*)top + chunksize(top), - "chunk past sbrk area", p); - - sz = chunksize(p); - if (p != top) - unless((char*)p + sz <= (char*)top, "chunk extends beyond top", p); - else - unless((char*)p + sz <= sbrk_base + sbrked_mem, - "chunk extends past sbrk area", p); - } - check_moats(p); -} - -#if __STD_C -static void do_check_free_chunk(mchunkptr p) -#else -static void do_check_free_chunk(p) mchunkptr p; -#endif -{ - INTERNAL_SIZE_T sz = chunksize(p); - mchunkptr next = chunk_at_offset(p, sz); - - do_check_chunk(p); - - /* Check whether it claims to be free ... */ - unless(!inuse(p), "free chunk marked inuse", p); - - /* Unless a special marker, must have OK fields */ - if ((long)sz >= (long)MINSIZE) - { - unless((sz & ALIGN_MASK) == 0, "freed size defies alignment", p); - unless(aligned_OK(chunk2mem(p)), "misaligned freed region", p); - /* ... matching footer field */ - unless(next->prev_size == sz, "chunk size mismatch", p); - /* ... and is fully consolidated */ - unless(prev_inuse(p), "free chunk not joined with prev", p); - unless(next == top || inuse(next), "free chunk not joined with next", p); - - /* ... and has minimally sane links */ - unless(p->fd->bk == p, "broken forward link", p); - unless(p->bk->fd == p, "broken backward link", p); - } - else /* markers are always of size SIZE_SZ */ - unless(sz == SIZE_SZ, "invalid small chunk size", p); -} - -#if __STD_C -static void do_check_inuse_chunk(mchunkptr p) -#else -static void do_check_inuse_chunk(p) mchunkptr p; -#endif -{ - mchunkptr next; - do_check_chunk(p); - - if (chunk_is_mmapped(p)) - return; - - /* Check whether it claims to be in use ... */ -#ifdef DEBUG3 - unless(p->alloced, "memory not allocated", p); -#endif - unless(inuse(p), "memory not allocated", p); - - /* ... and is surrounded by OK chunks. - Since more things can be checked with free chunks than inuse ones, - if an inuse chunk borders them and debug is on, it's worth doing them. - */ - if (!prev_inuse(p)) - { - mchunkptr prv = prev_chunk(p); - unless(next_chunk(prv) == p, "prev link scrambled", p); - do_check_free_chunk(prv); - } - next = next_chunk(p); - if (next == top) - { - unless(prev_inuse(next), "top chunk wrongly thinks prev is unused", p); - unless(chunksize(next) >= MINSIZE, "top chunk too small", p); - } - else if (!inuse(next)) - do_check_free_chunk(next); -} - -#if __STD_C -static void do_check_malloced_chunk(mchunkptr p, INTERNAL_SIZE_T s) -#else -static void do_check_malloced_chunk(p, s) mchunkptr p; INTERNAL_SIZE_T s; -#endif -{ - INTERNAL_SIZE_T sz = chunksize(p); - long room = sz - s; - - do_check_inuse_chunk(p); - - /* Legal size ... */ - unless((long)sz >= (long)MINSIZE, "chunk size too small", p); - unless((sz & ALIGN_MASK) == 0, "malloced size defies alignment", p); - unless(room >= 0, "chunk size too small for contents", p); - unless(room < (long)MINSIZE, "chunk size leaves too much spare room", p); - - /* ... and alignment */ - unless(aligned_OK(chunk2mem(p)), "misaligned malloced region", p); - - - /* ... and was allocated at front of an available chunk */ - unless(prev_inuse(p), "malloced from the middle of a free chunk", p); -} - -#ifdef DEBUG3 -static void init_alloced_chunk(mchunkptr p, size_t bytes) -{ - Void_t* mem = chunk2mem(p); - p->file = debug_file; - p->line = debug_line; - p->pad = chunksize(p) - OVERHEAD - bytes; - p->alloced = 1; - memset((char *)mem + bytes, MOATFILL, p->pad + MOATWIDTH); -} - -static void do_init_malloced_chunk(mchunkptr p, size_t bytes) -{ - Void_t* mem = chunk2mem(p); - init_alloced_chunk(p, bytes); - memset((char *)mem - MOATWIDTH, MOATFILL, MOATWIDTH); - memset(mem, ALLOCFILL, bytes); -} - -static void do_init_realloced_chunk(mchunkptr p, size_t bytes, - INTERNAL_SIZE_T oldsize) -{ - Void_t* mem = chunk2mem(p); - INTERNAL_SIZE_T newsize = chunksize(p); - init_alloced_chunk(p, bytes); - if (oldsize < newsize) - /* This incorrectly leaves the leading pad area of the old trailing moat - * set to MOATFILL rather than ALLOCFILL. An alternative is to save the - * old p->pad in rEALLOc() below and pass it to this function. - */ - memset((char *)mem + oldsize - OVERHEAD, ALLOCFILL, - bytes - (oldsize - OVERHEAD)); -} - -static void do_check_freefill(mchunkptr p, long newsize, - INTERNAL_SIZE_T oldsize) -{ - /* The first newsize bytes of oldsize-byte chunk p are about to be - * allocated. Issue a warning if any freefill locations in p that are about - * to be overwritten do not contain the character FREEFILL. - */ - size_t bytes, maxbytes; - if (newsize <= 0) - return; - bytes = newsize - MEMOFFSET /* don't check p's header */ - + MEMOFFSET; /* header of split-off remainder */ - maxbytes = oldsize - OVERHEAD; - if (bytes > maxbytes) - bytes = maxbytes; - unless(memtest(chunk2mem(p), FREEFILL, bytes), - "detected write to freed region", p); -} - -static void do_init_freed_chunk(mchunkptr p, INTERNAL_SIZE_T freehead, - INTERNAL_SIZE_T freetail) -{ - /* freehead and freetail are the number of bytes at the beginning of p and - * end of p respectively that should already be initialized as free regions. - */ - Void_t* mem = chunk2mem(p); - size_t size = chunksize(p); - size_t bytes = size - OVERHEAD; - p->pad = 0; - p->alloced = 0; - memset((char *)mem - MOATWIDTH, MOATFILL, MOATWIDTH); - memset((char *)mem + bytes, MOATFILL, MOATWIDTH); - - /* To avoid terrible O(n^2) performance when free() repeatedly grows a free - * chunk, it's important not to free-fill regions that are already - * free-filled. - */ - if (freehead + freetail < size) { - Void_t* start = !freehead ? mem : (char *)p + freehead - MOATWIDTH; - size_t len = (char *)p + size - (char *)start - - (!freetail ? MOATWIDTH : freetail - OVERHEAD); - memset(start, FREEFILL, len); - } -} - -static void do_init_freeable_chunk(mchunkptr p) -{ - /* Arrange for the subsequent fREe(p) not to generate any warnings. */ - init_alloced_chunk(p, chunksize(p) - OVERHEAD); - memset((char *)chunk2mem(p) - MOATWIDTH, MOATFILL, MOATWIDTH); -} - -static void do_maximize_chunk(mchunkptr p) -{ - if (p->pad) { - Void_t* mem = chunk2mem(p); - size_t bytes = chunksize(p) - OVERHEAD - p->pad; - memset((char *)mem + bytes, ALLOCFILL, p->pad); - p->pad = 0; - } -} - -static int do_check_init(void) -{ - /* Called from the first invocation of malloc_extend_top(), as detected by - * sbrk_base == -1. Return whether this function allocated any memory. - */ - static int state = 0; /* 1 => initializing, 2 => initialized */ - if (state == 1) - return 0; - unless(state == 0, "multiple calls to check_init", NULL); - state++; - atexit(malloc_update_mallinfo); /* calls malloc on WinNT */ - return sbrk_base != (char *)-1; -} -#endif /* DEBUG3 */ - -static mchunkptr lowest_chunk; - -#define check_free_chunk(P) do_check_free_chunk(P) -#define check_inuse_chunk(P) do_check_inuse_chunk(P) -#define check_chunk(P) do_check_chunk(P) -#define check_malloced_chunk(P,N) do_check_malloced_chunk(P,N) -#else /* !DEBUG */ -#define check_free_chunk(P) -#define check_inuse_chunk(P) -#define check_chunk(P) -#define check_malloced_chunk(P,N) -#endif /* !DEBUG */ - -#ifdef DEBUG3 -#define check_init do_check_init -#define init_malloced_chunk do_init_malloced_chunk -#define init_realloced_chunk do_init_realloced_chunk -#define check_freefill do_check_freefill -#define init_freed_chunk do_init_freed_chunk -#define init_freeable_chunk do_init_freeable_chunk -#define maximize_chunk do_maximize_chunk -#else -#define check_init() 0 -#define init_malloced_chunk(P,B) -#define init_realloced_chunk(P,B,O) -#define check_freefill(P,N,O) -#define init_freed_chunk(P,H,T) -#define init_freeable_chunk(P) -#define maximize_chunk(P) -#endif /* !DEBUG3 */ - - - -/* - Macro-based internal utilities -*/ - - -/* - Linking chunks in bin lists. - Call these only with variables, not arbitrary expressions, as arguments. -*/ - -/* - Place chunk p of size s in its bin, in size order, - putting it ahead of others of same size. -*/ - - -#define frontlink(P, S, IDX, BK, FD) \ -{ \ - if (S < MAX_SMALLBIN_SIZE) \ - { \ - IDX = smallbin_index(S); \ - mark_binblock(IDX); \ - BK = bin_at(IDX); \ - FD = BK->fd; \ - P->bk = BK; \ - P->fd = FD; \ - FD->bk = BK->fd = P; \ - } \ - else \ - { \ - IDX = bin_index(S); \ - BK = bin_at(IDX); \ - FD = BK->fd; \ - if (FD == BK) mark_binblock(IDX); \ - else \ - { \ - while (FD != BK && S < chunksize(FD)) FD = FD->fd; \ - BK = FD->bk; \ - } \ - P->bk = BK; \ - P->fd = FD; \ - FD->bk = BK->fd = P; \ - } \ -} - - -/* take a chunk off a list */ - -#define unlink(P, BK, FD) \ -{ \ - BK = P->bk; \ - FD = P->fd; \ - FD->bk = BK; \ - BK->fd = FD; \ -} \ - -/* Place p as the last remainder */ - -#define link_last_remainder(P) \ -{ \ - last_remainder->fd = last_remainder->bk = P; \ - P->fd = P->bk = last_remainder; \ -} - -/* Clear the last_remainder bin */ - -#define clear_last_remainder \ - (last_remainder->fd = last_remainder->bk = last_remainder) - - - - - - -/* Routines dealing with mmap(). */ - -#if HAVE_MMAP - -#if __STD_C -static mchunkptr mmap_chunk(size_t size) -#else -static mchunkptr mmap_chunk(size) size_t size; -#endif -{ - size_t page_mask = malloc_getpagesize - 1; - mchunkptr p; - -#ifndef MAP_ANONYMOUS - static int fd = -1; -#endif - - if(n_mmaps >= n_mmaps_max) return 0; /* too many regions */ - - size = (size + MMAP_EXTRA + page_mask) & ~page_mask; - -#ifdef MAP_ANONYMOUS - p = (mchunkptr)mmap(0, size, PROT_READ|PROT_WRITE, - MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); -#else /* !MAP_ANONYMOUS */ - if (fd < 0) - { - fd = open("/dev/zero", O_RDWR); - if(fd < 0) return 0; - } - p = (mchunkptr)mmap(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); -#endif - - if(p == (mchunkptr)-1) return 0; - - n_mmaps++; - if (n_mmaps > max_n_mmaps) max_n_mmaps = n_mmaps; - - /* We demand that eight bytes into a page must be 8-byte aligned. */ - assert(aligned_OK(chunk2mem(p))); - - /* The offset to the start of the mmapped region is stored - * in the prev_size field of the chunk; normally it is zero, - * but that can be changed in memalign(). - */ - p->prev_size = 0; - set_head(p, size|IS_MMAPPED); - - mmapped_mem += size; - if ((unsigned long)mmapped_mem > (unsigned long)max_mmapped_mem) - max_mmapped_mem = mmapped_mem; - if ((unsigned long)(mmapped_mem + sbrked_mem) > (unsigned long)max_total_mem) - max_total_mem = mmapped_mem + sbrked_mem; - return p; -} - -#if __STD_C -static void munmap_chunk(mchunkptr p) -#else -static void munmap_chunk(p) mchunkptr p; -#endif -{ - INTERNAL_SIZE_T size = chunksize(p); - int ret; - - assert (chunk_is_mmapped(p)); - assert(! ((char*)p >= sbrk_base && (char*)p < sbrk_base + sbrked_mem)); - assert((n_mmaps > 0)); - assert(((p->prev_size + size) & (malloc_getpagesize-1)) == 0); - - n_mmaps--; - mmapped_mem -= (size + p->prev_size); - - ret = munmap((char *)p - p->prev_size, size + p->prev_size); - - /* munmap returns non-zero on failure */ - assert(ret == 0); -} - -#if HAVE_MREMAP - -#if __STD_C -static mchunkptr mremap_chunk(mchunkptr p, size_t new_size) -#else -static mchunkptr mremap_chunk(p, new_size) mchunkptr p; size_t new_size; -#endif -{ - size_t page_mask = malloc_getpagesize - 1; - INTERNAL_SIZE_T offset = p->prev_size; - INTERNAL_SIZE_T size = chunksize(p); - char *cp; - - assert (chunk_is_mmapped(p)); - assert(! ((char*)p >= sbrk_base && (char*)p < sbrk_base + sbrked_mem)); - assert((n_mmaps > 0)); - assert(((size + offset) & (malloc_getpagesize-1)) == 0); - - new_size = (new_size + offset + MMAP_EXTRA + page_mask) & ~page_mask; - - cp = (char *)mremap((char *)p - offset, size + offset, new_size, 1); - - if (cp == (char *)-1) return 0; - - p = (mchunkptr)(cp + offset); - - assert(aligned_OK(chunk2mem(p))); - - assert(p->prev_size == offset); - set_head(p, (new_size - offset)|IS_MMAPPED); - - mmapped_mem -= size + offset; - mmapped_mem += new_size; - if ((unsigned long)mmapped_mem > (unsigned long)max_mmapped_mem) - max_mmapped_mem = mmapped_mem; - if ((unsigned long)(mmapped_mem + sbrked_mem) > (unsigned long)max_total_mem) - max_total_mem = mmapped_mem + sbrked_mem; - return p; -} - -#endif /* HAVE_MREMAP */ - -#endif /* HAVE_MMAP */ - - - - -/* - Extend the top-most chunk by obtaining memory from system. - Main interface to sbrk (but see also malloc_trim). -*/ - -#if __STD_C -static void malloc_extend_top(INTERNAL_SIZE_T nb) -#else -static void malloc_extend_top(nb) INTERNAL_SIZE_T nb; -#endif -{ - char* lim; /* return value from sbrk */ - INTERNAL_SIZE_T front_misalign; /* unusable bytes at front of sbrked space */ - INTERNAL_SIZE_T correction; /* bytes for 2nd sbrk call */ - char* new_lim; /* return of 2nd sbrk call */ - INTERNAL_SIZE_T top_size; /* new size of top chunk */ - - mchunkptr old_top = top; /* Record state of old top */ - INTERNAL_SIZE_T old_top_size = chunksize(old_top); - char* old_end = (char*)(chunk_at_offset(old_top, old_top_size)); - - /* Pad request with top_pad plus minimal overhead */ - - INTERNAL_SIZE_T sbrk_size = nb + top_pad + MINSIZE; - unsigned long pagesz = malloc_getpagesize; - - /* If not the first time through, round to preserve page boundary */ - /* Otherwise, we need to correct to a page size below anyway. */ - /* (We also correct below if an intervening foreign sbrk call.) */ - - if (sbrk_base != (char*)(-1)) - sbrk_size = (sbrk_size + (pagesz - 1)) & ~(pagesz - 1); - - else if (check_init()) { - if (chunksize(top) - nb < (long)MINSIZE) - malloc_extend_top(nb); - return; - } - - lim = (char*)(MORECORE (sbrk_size)); - - /* Fail if sbrk failed or if a foreign sbrk call killed our space */ - if (lim == (char*)(MORECORE_FAILURE) || - (lim < old_end && old_top != initial_top)) - return; - - sbrked_mem += sbrk_size; - - if (lim == old_end) /* can just add bytes to current top */ - { - top_size = sbrk_size + old_top_size; - set_head(top, top_size | PREV_INUSE); - } - else - { -#ifdef SBRKDBG - INTERNAL_SIZE_T padding = (char *)sbrk (0) - (lim + sbrk_size); - sbrk_size += padding; - sbrked_mem += padding; -#endif - - if (sbrk_base == (char*)(-1)) /* First time through. Record base */ - sbrk_base = lim; - else /* Someone else called sbrk(). Count those bytes as sbrked_mem. */ - sbrked_mem += lim - (char*)old_end; - - /* Guarantee alignment of first new chunk made from this space */ - front_misalign = (unsigned long)chunk2mem(lim) & ALIGN_MASK; - if (front_misalign > 0) - { - correction = (ALIGNMENT) - front_misalign; - lim += correction; - } - else - correction = 0; - - /* Guarantee the next brk will be at a page boundary */ - correction += pagesz - ((unsigned long)(lim + sbrk_size) & (pagesz - 1)); - - /* Allocate correction */ - new_lim = (char*)(MORECORE (correction)); - if (new_lim == (char*)(MORECORE_FAILURE)) return; - - sbrked_mem += correction; - - top = (mchunkptr)lim; - top_size = new_lim - lim + correction; - set_head(top, top_size | PREV_INUSE); -#if DEBUG - lowest_chunk = top; -#endif - -#ifdef OTHER_SBRKS - if (old_top != initial_top) - { - - /* There must have been an intervening foreign sbrk call. */ - /* A double fencepost is necessary to prevent consolidation */ - - /* If not enough space to do this, then user did something very wrong */ - if (old_top_size < MINSIZE) - { - set_head(top, PREV_INUSE); /* will force null return from malloc */ - return; - } - - old_top_size -= 2*SIZE_SZ; - chunk_at_offset(old_top, old_top_size )->size = - SIZE_SZ|PREV_INUSE; - chunk_at_offset(old_top, old_top_size + SIZE_SZ)->size = - SIZE_SZ|PREV_INUSE; - set_head_size(old_top, old_top_size); - /* If possible, release the rest. */ - if (old_top_size >= MINSIZE) { - init_freeable_chunk(old_top); - fREe(chunk2mem(old_top)); - } - } -#endif /* OTHER_SBRKS */ - } - - init_freed_chunk(top, old_top == initial_top ? old_top_size : 0, 0); - - if ((unsigned long)sbrked_mem > (unsigned long)max_sbrked_mem) - max_sbrked_mem = sbrked_mem; - if ((unsigned long)(mmapped_mem + sbrked_mem) > (unsigned long)max_total_mem) - max_total_mem = mmapped_mem + sbrked_mem; - - /* We always land on a page boundary */ - assert(((unsigned long)((char*)top + top_size) & (pagesz - 1)) == 0); -} - - - - -/* Main public routines */ - - -/* - Malloc Algorthim: - - The requested size is first converted into a usable form, `nb'. - This currently means to add 4 bytes overhead plus possibly more to - obtain 8-byte alignment and/or to obtain a size of at least - MINSIZE (currently 16 bytes), the smallest allocatable size. - (All fits are considered `exact' if they are within MINSIZE bytes.) - - From there, the first successful of the following steps is taken: - - 1. The bin corresponding to the request size is scanned, and if - a chunk of exactly the right size is found, it is taken. - - 2. The most recently remaindered chunk is used if it is big - enough. This is a form of (roving) first fit, used only in - the absence of exact fits. Runs of consecutive requests use - the remainder of the chunk used for the previous such request - whenever possible. This limited use of a first-fit style - allocation strategy tends to give contiguous chunks - coextensive lifetimes, which improves locality and can reduce - fragmentation in the long run. - - 3. Other bins are scanned in increasing size order, using a - chunk big enough to fulfill the request, and splitting off - any remainder. This search is strictly by best-fit; i.e., - the smallest (with ties going to approximately the least - recently used) chunk that fits is selected. - - 4. If large enough, the chunk bordering the end of memory - (`top') is split off. (This use of `top' is in accord with - the best-fit search rule. In effect, `top' is treated as - larger (and thus less well fitting) than any other available - chunk since it can be extended to be as large as necessary - (up to system limitations). - - 5. If the request size meets the mmap threshold and the - system supports mmap, and there are few enough currently - allocated mmapped regions, and a call to mmap succeeds, - the request is allocated via direct memory mapping. - - 6. Otherwise, the top of memory is extended by - obtaining more space from the system (normally using sbrk, - but definable to anything else via the MORECORE macro). - Memory is gathered from the system (in system page-sized - units) in a way that allows chunks obtained across different - sbrk calls to be consolidated, but does not require - contiguous memory. Thus, it should be safe to intersperse - mallocs with other sbrk calls. - - - All allocations are made from the the `lowest' part of any found - chunk. (The implementation invariant is that prev_inuse is - always true of any allocated chunk; i.e., that each allocated - chunk borders either a previously allocated and still in-use chunk, - or the base of its memory arena.) - -*/ - -#if __STD_C -Void_t* mALLOc(size_t bytes) -#else -Void_t* mALLOc(bytes) size_t bytes; -#endif -{ - mchunkptr victim; /* inspected/selected chunk */ - INTERNAL_SIZE_T victim_size; /* its size */ - int idx; /* index for bin traversal */ - mbinptr bin; /* associated bin */ - mchunkptr remainder; /* remainder from a split */ - long remainder_size; /* its size */ - int remainder_index; /* its bin index */ - unsigned long block; /* block traverser bit */ - int startidx; /* first bin of a traversed block */ - mchunkptr fwd; /* misc temp for linking */ - mchunkptr bck; /* misc temp for linking */ - mbinptr q; /* misc temp */ - - INTERNAL_SIZE_T nb = request2size(bytes); /* padded request size; */ - - /* Check for exact match in a bin */ - - if (is_small_request(nb)) /* Faster version for small requests */ - { - idx = smallbin_index(nb); - - /* No traversal or size check necessary for small bins. */ - - q = bin_at(idx); - victim = last(q); - - /* Also scan the next one, since it would have a remainder < MINSIZE */ - if (victim == q) - { - q = next_bin(q); - victim = last(q); - } - if (victim != q) - { - victim_size = chunksize(victim); - unlink(victim, bck, fwd); - set_inuse_bit_at_offset(victim, victim_size); - check_freefill(victim, victim_size, victim_size); - init_malloced_chunk(victim, bytes); - check_malloced_chunk(victim, nb); - - return chunk2mem(victim); - } - - idx += 2; /* Set for bin scan below. We've already scanned 2 bins. */ - - } - else - { - idx = bin_index(nb); - bin = bin_at(idx); - - for (victim = last(bin); victim != bin; victim = victim->bk) - { - victim_size = chunksize(victim); - remainder_size = victim_size - nb; - - if (remainder_size >= (long)MINSIZE) /* too big */ - { - --idx; /* adjust to rescan below after checking last remainder */ - break; - } - - else if (remainder_size >= 0) /* exact fit */ - { - unlink(victim, bck, fwd); - set_inuse_bit_at_offset(victim, victim_size); - check_freefill(victim, victim_size, victim_size); - init_malloced_chunk(victim, bytes); - check_malloced_chunk(victim, nb); - return chunk2mem(victim); - } - } - - ++idx; - - } - - /* Try to use the last split-off remainder */ - - if ( (victim = last_remainder->fd) != last_remainder) - { - victim_size = chunksize(victim); - remainder_size = victim_size - nb; - - if (remainder_size >= (long)MINSIZE) /* re-split */ - { - remainder = chunk_at_offset(victim, nb); - set_head(victim, nb | PREV_INUSE); - check_freefill(victim, nb, victim_size); - init_malloced_chunk(victim, bytes); - link_last_remainder(remainder); - set_head(remainder, remainder_size | PREV_INUSE); - set_foot(remainder, remainder_size); - init_freed_chunk(remainder, remainder_size, 0); - check_malloced_chunk(victim, nb); - return chunk2mem(victim); - } - - clear_last_remainder; - - if (remainder_size >= 0) /* exhaust */ - { - set_inuse_bit_at_offset(victim, victim_size); - check_freefill(victim, victim_size, victim_size); - init_malloced_chunk(victim, bytes); - check_malloced_chunk(victim, nb); - return chunk2mem(victim); - } - - /* Else place in bin */ - - frontlink(victim, victim_size, remainder_index, bck, fwd); - } - - /* - If there are any possibly nonempty big-enough blocks, - search for best fitting chunk by scanning bins in blockwidth units. - */ - - if ( (block = idx2binblock(idx)) <= binblocks) - { - - /* Get to the first marked block */ - - if ( (block & binblocks) == 0) - { - /* force to an even block boundary */ - idx = (idx & ~(BINBLOCKWIDTH - 1)) + BINBLOCKWIDTH; - block <<= 1; - while ((block & binblocks) == 0) - { - idx += BINBLOCKWIDTH; - block <<= 1; - } - } - - /* For each possibly nonempty block ... */ - for (;;) - { - startidx = idx; /* (track incomplete blocks) */ - q = bin = bin_at(idx); - - /* For each bin in this block ... */ - do - { - /* Find and use first big enough chunk ... */ - - for (victim = last(bin); victim != bin; victim = victim->bk) - { - victim_size = chunksize(victim); - remainder_size = victim_size - nb; - - if (remainder_size >= (long)MINSIZE) /* split */ - { - remainder = chunk_at_offset(victim, nb); - set_head(victim, nb | PREV_INUSE); - check_freefill(victim, nb, victim_size); - unlink(victim, bck, fwd); - init_malloced_chunk(victim, bytes); - link_last_remainder(remainder); - set_head(remainder, remainder_size | PREV_INUSE); - set_foot(remainder, remainder_size); - init_freed_chunk(remainder, remainder_size, 0); - check_malloced_chunk(victim, nb); - return chunk2mem(victim); - } - - else if (remainder_size >= 0) /* take */ - { - check_freefill(victim, victim_size, victim_size); - set_inuse_bit_at_offset(victim, victim_size); - unlink(victim, bck, fwd); - init_malloced_chunk(victim, bytes); - check_malloced_chunk(victim, nb); - return chunk2mem(victim); - } - - } - - bin = next_bin(bin); - - } while ((++idx & (BINBLOCKWIDTH - 1)) != 0); - - /* Clear out the block bit. */ - - do /* Possibly backtrack to try to clear a partial block */ - { - if ((startidx & (BINBLOCKWIDTH - 1)) == 0) - { - binblocks &= ~block; - break; - } - --startidx; - q = prev_bin(q); - } while (first(q) == q); - - /* Get to the next possibly nonempty block */ - - if ( (block <<= 1) <= binblocks && (block != 0) ) - { - while ((block & binblocks) == 0) - { - idx += BINBLOCKWIDTH; - block <<= 1; - } - } - else - break; - } - } - - - /* Try to use top chunk */ - - /* Require that there be a remainder, ensuring top always exists */ - if ( (remainder_size = chunksize(top) - nb) < (long)MINSIZE) - { - -#if HAVE_MMAP - /* If big and would otherwise need to extend, try to use mmap instead */ - if ((unsigned long)nb >= (unsigned long)mmap_threshold && - (victim = mmap_chunk(nb)) != 0) { - init_malloced_chunk(victim, bytes); - return chunk2mem(victim); - } -#endif - - /* Try to extend */ - malloc_extend_top(nb); - if ( (remainder_size = chunksize(top) - nb) < (long)MINSIZE) - return 0; /* propagate failure */ - } - - victim = top; - set_head(victim, nb | PREV_INUSE); - check_freefill(victim, nb, nb + remainder_size); - init_malloced_chunk(victim, bytes); - top = chunk_at_offset(victim, nb); - set_head(top, remainder_size | PREV_INUSE); - init_freed_chunk(top, remainder_size, 0); - check_malloced_chunk(victim, nb); - return chunk2mem(victim); - -} - - - - -/* - - free() algorithm : - - cases: - - 1. free(0) has no effect. - - 2. If the chunk was allocated via mmap, it is release via munmap(). - - 3. If a returned chunk borders the current high end of memory, - it is consolidated into the top, and if the total unused - topmost memory exceeds the trim threshold, malloc_trim is - called. - - 4. Other chunks are consolidated as they arrive, and - placed in corresponding bins. (This includes the case of - consolidating with the current `last_remainder'). - -*/ - - -#if __STD_C -void fREe(Void_t* mem) -#else -void fREe(mem) Void_t* mem; -#endif -{ - mchunkptr p; /* chunk corresponding to mem */ - INTERNAL_SIZE_T hd; /* its head field */ - INTERNAL_SIZE_T sz; /* its size */ - int idx; /* its bin index */ - mchunkptr next; /* next contiguous chunk */ - INTERNAL_SIZE_T nextsz; /* its size */ - INTERNAL_SIZE_T prevsz; /* size of previous contiguous chunk */ - mchunkptr bck; /* misc temp for linking */ - mchunkptr fwd; /* misc temp for linking */ - int islr; /* track whether merging with last_remainder */ - - if (mem == 0) /* free(0) has no effect */ - return; - - p = mem2chunk(mem); - check_inuse_chunk(p); - - hd = p->size; - -#if HAVE_MMAP - if (hd & IS_MMAPPED) /* release mmapped memory. */ - { - munmap_chunk(p); - return; - } -#endif - - sz = hd & ~PREV_INUSE; - next = chunk_at_offset(p, sz); - nextsz = chunksize(next); - prevsz = 0; /* avoid compiler warnings */ - - if (next == top) /* merge with top */ - { - sz += nextsz; - - if (!(hd & PREV_INUSE)) /* consolidate backward */ - { - prevsz = p->prev_size; - p = chunk_at_offset(p, -(long)prevsz); - sz += prevsz; - unlink(p, bck, fwd); - } - - set_head(p, sz | PREV_INUSE); - top = p; - init_freed_chunk(top, !(hd & PREV_INUSE) ? prevsz : 0, nextsz); - if ((unsigned long)(sz) >= trim_threshold) - malloc_trim(top_pad); - return; - } - - set_head(next, nextsz); /* clear inuse bit */ - - islr = 0; - - if (!(hd & PREV_INUSE)) /* consolidate backward */ - { - prevsz = p->prev_size; - p = chunk_at_offset(p, -(long)prevsz); - sz += prevsz; - - if (p->fd == last_remainder) /* keep as last_remainder */ - islr = 1; - else - unlink(p, bck, fwd); - } - - if (!(inuse_bit_at_offset(next, nextsz))) /* consolidate forward */ - { - sz += nextsz; - - if (!islr && next->fd == last_remainder) /* re-insert last_remainder */ - { - islr = 1; - link_last_remainder(p); - } - else - unlink(next, bck, fwd); - } - - - set_head(p, sz | PREV_INUSE); - set_foot(p, sz); - if (!islr) - frontlink(p, sz, idx, bck, fwd); - init_freed_chunk(p, !(hd & PREV_INUSE) ? prevsz : 0, - !inuse_bit_at_offset(next, nextsz) ? nextsz : 0); -} - - - - - -/* - - Realloc algorithm: - - Chunks that were obtained via mmap cannot be extended or shrunk - unless HAVE_MREMAP is defined, in which case mremap is used. - Otherwise, if their reallocation is for additional space, they are - copied. If for less, they are just left alone. - - Otherwise, if the reallocation is for additional space, and the - chunk can be extended, it is, else a malloc-copy-free sequence is - taken. There are several different ways that a chunk could be - extended. All are tried: - - * Extending forward into following adjacent free chunk. - * Shifting backwards, joining preceding adjacent space - * Both shifting backwards and extending forward. - * Extending into newly sbrked space - - Unless the #define realloc_ZERO_BYTES_FREES is set, realloc with a - size argument of zero (re)allocates a minimum-sized chunk. - - If the reallocation is for less space, and the new request is for - a `small' (<512 bytes) size, then the newly unused space is lopped - off and freed. - - The old unix realloc convention of allowing the last-free'd chunk - to be used as an argument to realloc is no longer supported. - I don't know of any programs still relying on this feature, - and allowing it would also allow too many other incorrect - usages of realloc to be sensible. - - -*/ - - -#if __STD_C -Void_t* rEALLOc(Void_t* oldmem, size_t bytes) -#else -Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes; -#endif -{ - INTERNAL_SIZE_T nb; /* padded request size */ - - mchunkptr oldp; /* chunk corresponding to oldmem */ - INTERNAL_SIZE_T oldsize; /* its size */ - - mchunkptr newp; /* chunk to return */ - INTERNAL_SIZE_T newsize; /* its size */ - Void_t* newmem; /* corresponding user mem */ - - mchunkptr next; /* next contiguous chunk after oldp */ - INTERNAL_SIZE_T nextsize; /* its size */ - - mchunkptr prev; /* previous contiguous chunk before oldp */ - INTERNAL_SIZE_T prevsize; /* its size */ - - mchunkptr remainder; /* holds split off extra space from newp */ - INTERNAL_SIZE_T remainder_size; /* its size */ - - mchunkptr bck; /* misc temp for linking */ - mchunkptr fwd; /* misc temp for linking */ - -#ifdef realloc_ZERO_BYTES_FREES - if (bytes == 0) { fREe(oldmem); return 0; } -#endif - - - /* realloc of null is supposed to be same as malloc */ - if (oldmem == 0) return mALLOc(bytes); - - newp = oldp = mem2chunk(oldmem); - newsize = oldsize = chunksize(oldp); - - - nb = request2size(bytes); - - check_inuse_chunk(oldp); - -#if HAVE_MMAP - if (chunk_is_mmapped(oldp)) - { - if (oldsize - MMAP_EXTRA >= nb) { - init_realloced_chunk(oldp, bytes, oldsize); - return oldmem; /* do nothing */ - } -#if HAVE_MREMAP - newp = mremap_chunk(oldp, nb); - if (newp) { - init_realloced_chunk(newp, bytes, oldsize); - return chunk2mem(newp); - } -#endif - /* Must alloc, copy, free. */ - newmem = mALLOc(bytes); - if (newmem == 0) return 0; /* propagate failure */ - malloc_COPY(newmem, oldmem, oldsize - OVERHEAD - MMAP_EXTRA); - munmap_chunk(oldp); - return newmem; - } -#endif - - if (oldsize < nb) - { - - /* Try expanding forward */ - - next = chunk_at_offset(oldp, oldsize); - if (next == top || !inuse(next)) - { - nextsize = chunksize(next); - - /* Forward into top only if a remainder */ - if (next == top) - { - if ((long)(nextsize + newsize) >= (long)(nb + MINSIZE)) - { - check_freefill(next, nb - oldsize, nextsize); - newsize += nextsize; - top = chunk_at_offset(oldp, nb); - set_head(top, (newsize - nb) | PREV_INUSE); - init_freed_chunk(top, newsize - nb, 0); - set_head_size(oldp, nb); - init_realloced_chunk(oldp, bytes, oldsize); - return chunk2mem(oldp); - } - } - - /* Forward into next chunk */ - else if (((long)(nextsize + newsize) >= (long)nb)) - { - check_freefill(next, nb - oldsize, nextsize); - unlink(next, bck, fwd); - newsize += nextsize; - goto split; - } - } - else - { - next = 0; - nextsize = 0; - } - - /* Try shifting backwards. */ - - if (!prev_inuse(oldp)) - { - prev = prev_chunk(oldp); - prevsize = chunksize(prev); - - /* try forward + backward first to save a later consolidation */ - - if (next != 0) - { - /* into top */ - if (next == top) - { - if ((long)(nextsize + prevsize + newsize) >= (long)(nb + MINSIZE)) - { - check_freefill(prev, nb, prevsize); - check_freefill(next, nb - (prevsize + newsize), nextsize); - unlink(prev, bck, fwd); - newp = prev; - newsize += prevsize + nextsize; - newmem = chunk2mem(newp); - malloc_COPY(newmem, oldmem, oldsize - OVERHEAD); - top = chunk_at_offset(newp, nb); - set_head(top, (newsize - nb) | PREV_INUSE); - init_freed_chunk(top, newsize - nb, 0); - set_head_size(newp, nb); - init_realloced_chunk(newp, bytes, oldsize); - return newmem; - } - } - - /* into next chunk */ - else if (((long)(nextsize + prevsize + newsize) >= (long)(nb))) - { - check_freefill(prev, nb, prevsize); - check_freefill(next, nb - (prevsize + newsize), nextsize); - unlink(next, bck, fwd); - unlink(prev, bck, fwd); - newp = prev; - newsize += nextsize + prevsize; - newmem = chunk2mem(newp); - malloc_COPY(newmem, oldmem, oldsize - OVERHEAD); - goto split; - } - } - - /* backward only */ - if (prev != 0 && (long)(prevsize + newsize) >= (long)nb) - { - check_freefill(prev, nb, prevsize); - unlink(prev, bck, fwd); - newp = prev; - newsize += prevsize; - newmem = chunk2mem(newp); - malloc_COPY(newmem, oldmem, oldsize - OVERHEAD); - goto split; - } - } - - /* Must allocate */ - - newmem = mALLOc (bytes); - - if (newmem == 0) /* propagate failure */ - return 0; - - /* Avoid copy if newp is next chunk after oldp. */ - /* (This can only happen when new chunk is sbrk'ed.) */ - - if ( (newp = mem2chunk(newmem)) == next_chunk(oldp)) - { - newsize += chunksize(newp); - newp = oldp; - goto split; - } - - /* Otherwise copy, free, and exit */ - malloc_COPY(newmem, oldmem, oldsize - OVERHEAD); - fREe(oldmem); - return newmem; - } - - - split: /* split off extra room in old or expanded chunk */ - - if (newsize - nb >= MINSIZE) /* split off remainder */ - { - remainder = chunk_at_offset(newp, nb); - remainder_size = newsize - nb; - set_head_size(newp, nb); - set_head(remainder, remainder_size | PREV_INUSE); - set_inuse_bit_at_offset(remainder, remainder_size); - init_malloced_chunk(remainder, remainder_size - OVERHEAD); - fREe(chunk2mem(remainder)); /* let free() deal with it */ - } - else - { - set_head_size(newp, newsize); - set_inuse_bit_at_offset(newp, newsize); - } - - init_realloced_chunk(newp, bytes, oldsize); - check_inuse_chunk(newp); - return chunk2mem(newp); -} - - - - -/* - - memalign algorithm: - - memalign requests more than enough space from malloc, finds a spot - within that chunk that meets the alignment request, and then - possibly frees the leading and trailing space. - - The alignment argument must be a power of two. This property is not - checked by memalign, so misuse may result in random runtime errors. - - 8-byte alignment is guaranteed by normal malloc calls, so don't - bother calling memalign with an argument of 8 or less. - - Overreliance on memalign is a sure way to fragment space. - -*/ - - -#if __STD_C -Void_t* mEMALIGn(size_t alignment, size_t bytes) -#else -Void_t* mEMALIGn(alignment, bytes) size_t alignment; size_t bytes; -#endif -{ - INTERNAL_SIZE_T nb; /* padded request size */ - char* m; /* memory returned by malloc call */ - mchunkptr p; /* corresponding chunk */ - char* lim; /* alignment point within p */ - mchunkptr newp; /* chunk to return */ - INTERNAL_SIZE_T newsize; /* its size */ - INTERNAL_SIZE_T leadsize; /* leading space befor alignment point */ - mchunkptr remainder; /* spare room at end to split off */ - long remainder_size; /* its size */ - - /* If need less alignment than we give anyway, just relay to malloc */ - - if (alignment <= ALIGNMENT) return mALLOc(bytes); - - /* Otherwise, ensure that it is at least a minimum chunk size */ - - if (alignment < MINSIZE) alignment = MINSIZE; - - /* Call malloc with worst case padding to hit alignment. */ - - nb = request2size(bytes); - m = (char*)mALLOc(nb + alignment + MINSIZE); - - if (m == 0) return 0; /* propagate failure */ - - p = mem2chunk(m); - - if ((((unsigned long)(m)) % alignment) == 0) /* aligned */ - { - init_realloced_chunk(p, bytes, chunksize(p)); - return chunk2mem(p); /* nothing more to do */ - } - else /* misaligned */ - { - /* - Find an aligned spot inside chunk. - Since we need to give back leading space in a chunk of at - least MINSIZE, if the first calculation places us at - a spot with less than MINSIZE leader, we can move to the - next aligned spot -- we've allocated enough total room so that - this is always possible. - */ - - lim = (char*)mem2chunk(((unsigned long)(m + alignment - 1)) & - ~(alignment - 1)); - if ((lim - (char*)p) < (long)MINSIZE) lim = lim + alignment; - - newp = (mchunkptr)lim; - leadsize = lim - (char*)p; - newsize = chunksize(p) - leadsize; - -#if HAVE_MMAP - if(chunk_is_mmapped(p)) - { - newp->prev_size = p->prev_size + leadsize; - set_head(newp, newsize|IS_MMAPPED); - init_malloced_chunk(newp, bytes); - return chunk2mem(newp); - } -#endif - - /* give back leader, use the rest */ - - set_head(newp, newsize | PREV_INUSE); - set_inuse_bit_at_offset(newp, newsize); - set_head_size(p, leadsize); - init_freeable_chunk(p); - fREe(chunk2mem(p)); - p = newp; - - assert (newsize >= nb && (((unsigned long)(chunk2mem(p))) % alignment) == 0); - } - - /* Also give back spare room at the end */ - - remainder_size = chunksize(p) - nb; - - if (remainder_size >= (long)MINSIZE) - { - remainder = chunk_at_offset(p, nb); - set_head(remainder, remainder_size | PREV_INUSE); - set_head_size(p, nb); - init_freeable_chunk(remainder); - fREe(chunk2mem(remainder)); - } - - init_malloced_chunk(p, bytes); - check_inuse_chunk(p); - return chunk2mem(p); - -} - - - - -/* - valloc just invokes memalign with alignment argument equal - to the page size of the system (or as near to this as can - be figured out from all the includes/defines above.) -*/ - -#if __STD_C -Void_t* vALLOc(size_t bytes) -#else -Void_t* vALLOc(bytes) size_t bytes; -#endif -{ - return mEMALIGn (malloc_getpagesize, bytes); -} - -/* - pvalloc just invokes valloc for the nearest pagesize - that will accommodate request -*/ - - -#if __STD_C -Void_t* pvALLOc(size_t bytes) -#else -Void_t* pvALLOc(bytes) size_t bytes; -#endif -{ - size_t pagesize = malloc_getpagesize; - return mEMALIGn (pagesize, (bytes + pagesize - 1) & ~(pagesize - 1)); -} - -/* - - calloc calls malloc, then zeroes out the allocated chunk. - -*/ - -#if __STD_C -Void_t* cALLOc(size_t n, size_t elem_size) -#else -Void_t* cALLOc(n, elem_size) size_t n; size_t elem_size; -#endif -{ - mchunkptr p; - INTERNAL_SIZE_T csz; - - INTERNAL_SIZE_T sz = n * elem_size; - - /* check if expand_top called, in which case don't need to clear */ -#if MORECORE_CLEARS - mchunkptr oldtop = top; - INTERNAL_SIZE_T oldtopsize = chunksize(top); -#endif - Void_t* mem = mALLOc (sz); - - if (mem == 0) - return 0; - else - { - p = mem2chunk(mem); - - /* Two optional cases in which clearing not necessary */ - - -#if HAVE_MMAP - if (chunk_is_mmapped(p)) return mem; -#endif - - csz = chunksize(p); - -#if MORECORE_CLEARS - if (p == oldtop && csz > oldtopsize) - { - /* clear only the bytes from non-freshly-sbrked memory */ - csz = oldtopsize; - } -#endif - - malloc_ZERO(mem, csz - OVERHEAD); - /* reinstate moat fill in pad region */ - init_realloced_chunk(p, sz, chunksize(p)); - return mem; - } -} - - - -/* - - Malloc_trim gives memory back to the system (via negative - arguments to sbrk) if there is unused memory at the `high' end of - the malloc pool. You can call this after freeing large blocks of - memory to potentially reduce the system-level memory requirements - of a program. However, it cannot guarantee to reduce memory. Under - some allocation patterns, some large free blocks of memory will be - locked between two used chunks, so they cannot be given back to - the system. - - The `pad' argument to malloc_trim represents the amount of free - trailing space to leave untrimmed. If this argument is zero, - only the minimum amount of memory to maintain internal data - structures will be left (one page or less). Non-zero arguments - can be supplied to maintain enough trailing space to service - future expected allocations without having to re-obtain memory - from the system. - - Malloc_trim returns 1 if it actually released any memory, else 0. - -*/ - -#if __STD_C -int dlmalloc_trim(size_t pad) -#else -int malloc_trim(pad) size_t pad; -#endif -{ - long top_size; /* Amount of top-most memory */ - long extra; /* Amount to release */ - char* current_lim; /* address returned by pre-check sbrk call */ - char* new_lim; /* address returned by negative sbrk call */ - - unsigned long pagesz = malloc_getpagesize; - - top_size = chunksize(top); - extra = ((top_size - pad - MINSIZE + (pagesz-1)) / pagesz - 1) * pagesz; - - if (extra < (long)pagesz) /* Not enough memory to release */ - return 0; - - else - { -#ifdef OTHER_SBRKS - /* Test to make sure no one else called sbrk */ - current_lim = (char*)(MORECORE (0)); - if (current_lim != (char*)(top) + top_size) - return 0; /* Apparently we don't own memory; must fail */ - - else -#endif - { - new_lim = (char*)(MORECORE (-extra)); - - if (new_lim == (char*)(MORECORE_FAILURE)) /* sbrk failed? */ - { - /* Try to figure out what we have */ - current_lim = (char*)(MORECORE (0)); - top_size = current_lim - (char*)top; - if (top_size >= (long)MINSIZE) /* if not, we are very very dead! */ - { - sbrked_mem = current_lim - sbrk_base; - set_head(top, top_size | PREV_INUSE); - init_freed_chunk(top, top_size, 0); - } - check_chunk(top); - return 0; - } - - else - { - /* Success. Adjust top accordingly. */ - set_head(top, (top_size - extra) | PREV_INUSE); - sbrked_mem -= extra; - init_freed_chunk(top, top_size - extra, 0); - check_chunk(top); - return 1; - } - } - } -} - - - -/* - malloc_usable_size: - - This routine tells you how many bytes you can actually use in an - allocated chunk, which may be more than you requested (although - often not). You can use this many bytes without worrying about - overwriting other allocated objects. Not a particularly great - programming practice, but still sometimes useful. - -*/ - -#if __STD_C -size_t dlmalloc_usable_size(Void_t* mem) -#else -size_t malloc_usable_size(mem) Void_t* mem; -#endif -{ - mchunkptr p; - if (mem == 0) - return 0; - else - { - p = mem2chunk(mem); - check_inuse_chunk(p); - maximize_chunk(p); - if(!chunk_is_mmapped(p)) - { - if (!inuse(p)) return 0; - return chunksize(p) - OVERHEAD; - } - return chunksize(p) - OVERHEAD - MMAP_EXTRA; - } -} - - - - -/* Utility to update current_mallinfo for malloc_stats and mallinfo() */ - -static void malloc_update_mallinfo(void) -{ - int i; - mbinptr b; - mchunkptr p; -#if DEBUG - mchunkptr q; -#endif - - INTERNAL_SIZE_T avail = chunksize(top); - int navail = avail >= MINSIZE ? 1 : 0; - check_freefill(top, avail, avail); - -#if DEBUG - if (lowest_chunk) - for (p = lowest_chunk; - p < top && inuse(p) && chunksize(p) >= MINSIZE; - p = next_chunk(p)) - check_inuse_chunk(p); -#endif - - for (i = 1; i < NAV; ++i) - { - b = bin_at(i); - for (p = last(b); p != b; p = p->bk) - { -#if DEBUG - check_free_chunk(p); - check_freefill(p, chunksize(p), chunksize(p)); - for (q = next_chunk(p); - q < top && inuse(q) && chunksize(q) >= MINSIZE; - q = next_chunk(q)) - check_inuse_chunk(q); -#endif - avail += chunksize(p); - navail++; - } - } - - current_mallinfo.ordblks = navail; - current_mallinfo.uordblks = sbrked_mem - avail; - current_mallinfo.fordblks = avail; - current_mallinfo.hblks = n_mmaps; - current_mallinfo.hblkhd = mmapped_mem; - current_mallinfo.keepcost = chunksize(top); - -} - - - -/* - - malloc_stats: - - Prints on stderr the amount of space obtain from the system (both - via sbrk and mmap), the maximum amount (which may be more than - current if malloc_trim and/or munmap got called), the maximum - number of simultaneous mmap regions used, and the current number - of bytes allocated via malloc (or realloc, etc) but not yet - freed. (Note that this is the number of bytes allocated, not the - number requested. It will be larger than the number requested - because of alignment and bookkeeping overhead.) - -*/ - -void dlmalloc_stats(void) -{ - malloc_update_mallinfo(); - fprintf(stderr, "max system bytes = %10u\n", - (unsigned int)(max_total_mem)); - fprintf(stderr, "system bytes = %10u\n", - (unsigned int)(sbrked_mem + mmapped_mem)); - fprintf(stderr, "in use bytes = %10u\n", - (unsigned int)(current_mallinfo.uordblks + mmapped_mem)); -#if HAVE_MMAP - fprintf(stderr, "max mmap regions = %10u\n", - (unsigned int)max_n_mmaps); -#endif -} - -/* - mallinfo returns a copy of updated current mallinfo. -*/ - -struct mallinfo mALLINFo(void) -{ - malloc_update_mallinfo(); - return current_mallinfo; -} - - - - -/* - mallopt: - - mallopt is the general SVID/XPG interface to tunable parameters. - The format is to provide a (parameter-number, parameter-value) pair. - mallopt then sets the corresponding parameter to the argument - value if it can (i.e., so long as the value is meaningful), - and returns 1 if successful else 0. - - See descriptions of tunable parameters above. - -*/ - -#if __STD_C -int mALLOPt(int param_number, int value) -#else -int mALLOPt(param_number, value) int param_number; int value; -#endif -{ - switch(param_number) - { - case M_TRIM_THRESHOLD: - trim_threshold = value; return 1; - case M_TOP_PAD: - top_pad = value; return 1; - case M_MMAP_THRESHOLD: - mmap_threshold = value; return 1; - case M_MMAP_MAX: -#if HAVE_MMAP - n_mmaps_max = value; return 1; -#else - if (value != 0) return 0; else n_mmaps_max = value; return 1; -#endif - case M_SCANHEAP: -#ifdef DEBUG2 - scanheap = value; -#endif - return 1; - - default: - return 0; - } -} - -/* - -History: - - V2.6.3 Sun May 19 08:17:58 1996 Doug Lea (dl at gee) - * Added pvalloc, as recommended by H.J. Liu - * Added 64bit pointer support mainly from Wolfram Gloger - * Added anonymously donated WIN32 sbrk emulation - * Malloc, calloc, getpagesize: add optimizations from Raymond Nijssen - * malloc_extend_top: fix mask error that caused wastage after - foreign sbrks - * Add linux mremap support code from HJ Liu - - V2.6.2 Tue Dec 5 06:52:55 1995 Doug Lea (dl at gee) - * Integrated most documentation with the code. - * Add support for mmap, with help from - Wolfram Gloger (Gloger@lrz.uni-muenchen.de). - * Use last_remainder in more cases. - * Pack bins using idea from colin@nyx10.cs.du.edu - * Use ordered bins instead of best-fit threshhold - * Eliminate block-local decls to simplify tracing and debugging. - * Support another case of realloc via move into top - * Fix error occuring when initial sbrk_base not word-aligned. - * Rely on page size for units instead of SBRK_UNIT to - avoid surprises about sbrk alignment conventions. - * Add mallinfo, mallopt. Thanks to Raymond Nijssen - (raymond@es.ele.tue.nl) for the suggestion. - * Add `pad' argument to malloc_trim and top_pad mallopt parameter. - * More precautions for cases where other routines call sbrk, - courtesy of Wolfram Gloger (Gloger@lrz.uni-muenchen.de). - * Added macros etc., allowing use in linux libc from - H.J. Lu (hjl@gnu.ai.mit.edu) - * Inverted this history list - - V2.6.1 Sat Dec 2 14:10:57 1995 Doug Lea (dl at gee) - * Re-tuned and fixed to behave more nicely with V2.6.0 changes. - * Removed all preallocation code since under current scheme - the work required to undo bad preallocations exceeds - the work saved in good cases for most test programs. - * No longer use return list or unconsolidated bins since - no scheme using them consistently outperforms those that don't - given above changes. - * Use best fit for very large chunks to prevent some worst-cases. - * Added some support for debugging - - V2.6.0 Sat Nov 4 07:05:23 1995 Doug Lea (dl at gee) - * Removed footers when chunks are in use. Thanks to - Paul Wilson (wilson@cs.texas.edu) for the suggestion. - - V2.5.4 Wed Nov 1 07:54:51 1995 Doug Lea (dl at gee) - * Added malloc_trim, with help from Wolfram Gloger - (wmglo@Dent.MED.Uni-Muenchen.DE). - - V2.5.3 Tue Apr 26 10:16:01 1994 Doug Lea (dl at g) - - V2.5.2 Tue Apr 5 16:20:40 1994 Doug Lea (dl at g) - * realloc: try to expand in both directions - * malloc: swap order of clean-bin strategy; - * realloc: only conditionally expand backwards - * Try not to scavenge used bins - * Use bin counts as a guide to preallocation - * Occasionally bin return list chunks in first scan - * Add a few optimizations from colin@nyx10.cs.du.edu - - V2.5.1 Sat Aug 14 15:40:43 1993 Doug Lea (dl at g) - * faster bin computation & slightly different binning - * merged all consolidations to one part of malloc proper - (eliminating old malloc_find_space & malloc_clean_bin) - * Scan 2 returns chunks (not just 1) - * Propagate failure in realloc if malloc returns 0 - * Add stuff to allow compilation on non-ANSI compilers - from kpv@research.att.com - - V2.5 Sat Aug 7 07:41:59 1993 Doug Lea (dl at g.oswego.edu) - * removed potential for odd address access in prev_chunk - * removed dependency on getpagesize.h - * misc cosmetics and a bit more internal documentation - * anticosmetics: mangled names in macros to evade debugger strangeness - * tested on sparc, hp-700, dec-mips, rs6000 - with gcc & native cc (hp, dec only) allowing - Detlefs & Zorn comparison study (in SIGPLAN Notices.) - - Trial version Fri Aug 28 13:14:29 1992 Doug Lea (dl at g.oswego.edu) - * Based loosely on libg++-1.2X malloc. (It retains some of the overall - structure of old version, but most details differ.) - -*/ diff --git a/winsup/cygwin/dlmalloc.h b/winsup/cygwin/dlmalloc.h deleted file mode 100644 index d7bd86927..000000000 --- a/winsup/cygwin/dlmalloc.h +++ /dev/null @@ -1,93 +0,0 @@ - -/* - * Header file for BBCized version of Doug Lea's malloc.c, automatically - * generated by - * /source/prod/libbbc/compat/dlmalloc/cvt - * from - * /source/prod/libbbc/compat/dlmalloc/malloc.c - * - * bbclabel: autogenerated - */ -#define _INCLUDE_MALLOC_H_ 1 -void malloc_outofmem(void (*)(void)); - - -struct mallinfo { - int arena; /* total space allocated from system */ - int ordblks; /* number of non-inuse chunks */ - int smblks; /* unused -- always zero */ - int hblks; /* number of mmapped regions */ - int hblkhd; /* total space in mmapped regions */ - int usmblks; /* unused -- always zero */ - int fsmblks; /* unused -- always zero */ - int uordblks; /* total allocated space */ - int fordblks; /* total non-inuse space */ - int keepcost; /* top-most, releasable (via malloc_trim) space */ -}; - - -#define M_MXFAST 1 /* UNUSED in this malloc */ -#define M_NLBLKS 2 /* UNUSED in this malloc */ -#define M_GRAIN 3 /* UNUSED in this malloc */ -#define M_KEEP 4 /* UNUSED in this malloc */ - - -#define M_TRIM_THRESHOLD -1 -#define M_TOP_PAD -2 -#define M_MMAP_THRESHOLD -3 -#define M_MMAP_MAX -4 -#define M_SCANHEAP -5 -#define M_FILL - -#ifdef MALLOC_DEBUG - -#define dlmalloc(size) malloc_dbg(size, __FILE__, __LINE__) -#define dlfree(p) free_dbg(p, __FILE__, __LINE__) -#define dlrealloc(p, size) realloc_dbg(p, size, __FILE__, __LINE__) -#define dlcalloc(n, size) calloc_dbg(n, size, __FILE__, __LINE__) -#define dlmemalign(align, size) memalign_dbg(align, size, __FILE__, __LINE__) -#define dlvalloc(size) valloc_dbg(size, __FILE__, __LINE__) -#define dlpvalloc(size) pvalloc_dbg(size, __FILE__, __LINE__) -#define dlmalloc_trim(pad) malloc_trim_dbg(pad, __FILE__, __LINE__) -#define dlmalloc_usable_size(p) malloc_usable_size_dbg(p, __FILE__, __LINE__) -#define dlmalloc_stats() malloc_stats_dbg(__FILE__, __LINE__) -#define dlmallopt(flag, val) mallopt_dbg(flag, val, __FILE__, __LINE__) -#define dlmallinfo() mallinfo_dbg(__FILE__, __LINE__) - - -#ifdef __cplusplus -extern "C" { -#endif -void* malloc_dbg(size_t, const char *, int); -void free_dbg(void*, const char *, int); -void* realloc_dbg(void*, size_t, const char *, int); -void* calloc_dbg(size_t, size_t, const char *, int); -void* memalign_dbg(size_t, size_t, const char *, int); -void* valloc_dbg(size_t, const char *, int); -void* pvalloc_dbg(size_t, const char *, int); -int malloc_trim_dbg(size_t, const char *, int); -size_t malloc_usable_size_dbg(void*, const char *, int); -void malloc_stats_dbg(const char *, int); -int mallopt_dbg(int, int, const char *, int); -struct mallinfo mallinfo_dbg(const char *, int); -#ifdef __cplusplus -} -#endif - -#endif /* MALLOC_DEBUG */ - -#ifndef MALLOC_DEBUG - -void* malloc(size_t); -void free(void*); -void* realloc(void*, size_t); -void* calloc(size_t, size_t); -void* memalign(size_t, size_t); -void* valloc(size_t); -void* pvalloc(size_t); -int malloc_trim(size_t); -size_t malloc_usable_size(void*); -void malloc_stats(void); -int mallopt(int, int); -struct mallinfo mallinfo(void); -#endif /* !MALLOC_DEBUG */ diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc deleted file mode 100644 index f0738adc2..000000000 --- a/winsup/cygwin/dtable.cc +++ /dev/null @@ -1,1038 +0,0 @@ -/* dtable.cc: file descriptor support. - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#define __INSIDE_CYGWIN_NET__ - -#include "winsup.h" -#include -#include -#include -#include -#include - -#define USE_SYS_TYPES_FD_SET -#include -#include "pinfo.h" -#include "cygerrno.h" -#include "perprocess.h" -#include "path.h" -#include "fhandler.h" -#include "select.h" -#include "dtable.h" -#include "cygheap.h" -#include "tls_pbuf.h" -#include "ntdll.h" -#include "shared_info.h" - -static const NO_COPY DWORD std_consts[] = {STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, - STD_ERROR_HANDLE}; - -static bool handle_to_fn (HANDLE, char *); - -#define WCLEN(x) ((sizeof (x) / sizeof (WCHAR)) - 1) -char unknown_file[] = "some disk file"; -const WCHAR DEV_NULL[] = L"\\Device\\Null"; -static const WCHAR DEV_SOCKET[] = L"\\Device\\Afd"; - -const WCHAR DEVICE_PREFIX[] = L"\\device\\"; -const size_t DEVICE_PREFIX_LEN WCLEN (DEVICE_PREFIX); - -static const WCHAR DEV_NAMED_PIPE[] = L"\\Device\\NamedPipe\\"; -static const size_t DEV_NAMED_PIPE_LEN = WCLEN (DEV_NAMED_PIPE); - -static const WCHAR DEV_REMOTE[] = L"\\Device\\LanmanRedirector\\"; -static const size_t DEV_REMOTE_LEN = WCLEN (DEV_REMOTE); - -static const WCHAR DEV_REMOTE1[] = L"\\Device\\WinDfs\\Root\\"; -static const size_t DEV_REMOTE1_LEN = WCLEN (DEV_REMOTE1); - -/* Set aside space for the table of fds */ -void -dtable_init () -{ - if (!cygheap->fdtab.size) - cygheap->fdtab.extend (NOFILE_INCR); -} - -void __stdcall -set_std_handle (int fd) -{ - if (fd == 0) - SetStdHandle (std_consts[fd], cygheap->fdtab[fd]->get_handle ()); - else if (fd <= 2) - SetStdHandle (std_consts[fd], cygheap->fdtab[fd]->get_output_handle ()); -} - -int -dtable::extend (int howmuch) -{ - int new_size = size + howmuch; - fhandler_base **newfds; - - if (howmuch <= 0) - return 0; - - if (new_size > OPEN_MAX_MAX) - { - set_errno (EMFILE); - return 0; - } - - /* Try to allocate more space for fd table. We can't call realloc () - here to preserve old table if memory allocation fails */ - - if (!(newfds = (fhandler_base **) ccalloc (HEAP_ARGV, new_size, sizeof newfds[0]))) - { - debug_printf ("calloc failed"); - set_errno (ENOMEM); - return 0; - } - if (fds) - { - memcpy (newfds, fds, size * sizeof (fds[0])); - cfree (fds); - } - - size = new_size; - fds = newfds; - debug_printf ("size %d, fds %p", size, fds); - return 1; -} - -void -dtable::get_debugger_info () -{ - extern bool jit_debug; - if (!jit_debug && being_debugged ()) - { - char std[3][sizeof ("/dev/ttyNNNN")]; - std[0][0] = std[1][0] = std [2][0] = '\0'; - char buf[sizeof ("cYgstd %x") + 32]; - sprintf (buf, "cYgstd %x %x %x", (unsigned) &std, sizeof (std[0]), 3); - OutputDebugString (buf); - for (int i = 0; i < 3; i++) - if (std[i][0]) - { - HANDLE h = GetStdHandle (std_consts[i]); - fhandler_base *fh = build_fh_name (std[i]); - if (!fh) - continue; - fds[i] = fh; - if (!fh->open ((i ? (i == 2 ? O_RDWR : O_WRONLY) : O_RDONLY) - | O_BINARY, 0777)) - release (i); - else - CloseHandle (h); - /* Copy to Windows' idea of a standard handle, otherwise - we have invalid standard handles when calling Windows - functions (small_printf and strace might suffer, too). */ - SetStdHandle (std_consts[i], i ? fh->get_output_handle () - : fh->get_handle ()); - } - } -} - -/* Initialize the file descriptor/handle mapping table. - This function should only be called when a cygwin function is invoked - by a non-cygwin function, i.e., it should only happen very rarely. */ - -void -dtable::stdio_init () -{ - extern void set_console_ctty (); - /* Set these before trying to output anything from strace. - Also, always set them even if we're to pick up our parent's fds - in case they're missed. */ - - if (myself->cygstarted || ISSTATE (myself, PID_CYGPARENT)) - { - tty_min *t = cygwin_shared->tty.get_tty (myself->ctty); - if (t && t->getpgid () == myself->pid && t->gethwnd ()) - init_console_handler (true); - return; - } - - HANDLE in = GetStdHandle (STD_INPUT_HANDLE); - HANDLE out = GetStdHandle (STD_OUTPUT_HANDLE); - HANDLE err = GetStdHandle (STD_ERROR_HANDLE); - - init_std_file_from_handle (0, in); - - /* STD_ERROR_HANDLE has been observed to be the same as - STD_OUTPUT_HANDLE. We need separate handles (e.g. using pipes - to pass data from child to parent). */ - /* CV 2008-10-17: Under debugger control, std fd's have been potentially - initialized in dtable::get_debugger_info (). In this case - init_std_file_from_handle is a no-op, so, even if out == err we don't - want to duplicate the handle since it will be unused. */ - if (out == err && (!being_debugged () || !not_open (2))) - { - /* Since this code is not invoked for forked tasks, we don't have - to worry about the close-on-exec flag here. */ - if (!DuplicateHandle (GetCurrentProcess (), out, - GetCurrentProcess (), &err, - 0, TRUE, DUPLICATE_SAME_ACCESS)) - { - /* If that fails, do this as a fall back. */ - err = out; - system_printf ("couldn't make stderr distinct from stdout, %E"); - } - } - - init_std_file_from_handle (1, out); - init_std_file_from_handle (2, err); - - /* Assign the console as the controlling tty for this process if we actually - have a console and no other controlling tty has been assigned. */ - if (!fhandler_console::need_invisible () && myself->ctty < 0) - set_console_ctty (); -} - -const int dtable::initial_archetype_size; - -fhandler_base * -dtable::find_archetype (device& dev) -{ - for (unsigned i = 0; i < farchetype; i++) - if (archetypes[i]->get_device () == (unsigned) dev) - return archetypes[i]; - return NULL; -} - -fhandler_base ** -dtable::add_archetype () -{ - if (farchetype++ >= narchetypes) - archetypes = (fhandler_base **) crealloc_abort (archetypes, (narchetypes += initial_archetype_size) * sizeof archetypes[0]); - return archetypes + farchetype - 1; -} - -void -dtable::delete_archetype (fhandler_base *fh) -{ - for (unsigned i = 0; i < farchetype; i++) - if (fh == archetypes[i]) - { - debug_printf ("deleting element %d for %s", i, fh->get_name ()); - if (i < --farchetype) - archetypes[i] = archetypes[farchetype]; - break; - } - - delete fh; -} - -int -dtable::find_unused_handle (int start) -{ - do - { - for (size_t i = start; i < size; i++) - /* See if open -- no need for overhead of not_open */ - if (fds[i] == NULL) - return i; - } - while (extend (NOFILE_INCR)); - return -1; -} - -void -dtable::release (int fd) -{ - if (!not_open (fd)) - { - if (fds[fd]->need_fixup_before ()) - dec_need_fixup_before (); - fhandler_base *arch = fds[fd]->archetype; - delete fds[fd]; - if (arch && !arch->usecount) - cygheap->fdtab.delete_archetype (arch); - fds[fd] = NULL; - } -} - -extern "C" int -cygwin_attach_handle_to_fd (char *name, int fd, HANDLE handle, mode_t bin, - DWORD myaccess) -{ - if (fd == -1) - fd = cygheap->fdtab.find_unused_handle (); - fhandler_base *fh = build_fh_name (name); - cygheap->fdtab[fd] = fh; - fh->init (handle, myaccess, bin ?: fh->pc_binmode ()); - return fd; -} - -void -dtable::init_std_file_from_handle (int fd, HANDLE handle) -{ - CONSOLE_SCREEN_BUFFER_INFO buf; - DCB dcb; - unsigned bin = O_BINARY; - device dev; - - dev.devn = 0; /* FIXME: device */ - first_fd_for_open = 0; - - if (!not_open (fd)) - return; - - SetLastError (0); - DWORD access = 0; - DWORD ft = GetFileType (handle); - char name[NT_MAX_PATH]; - name[0] = '\0'; - if (ft == FILE_TYPE_UNKNOWN && GetLastError () == ERROR_INVALID_HANDLE) - /* can't figure out what this is */; - else if (ft == FILE_TYPE_PIPE) - { - int rcv = 0, len = sizeof (int); - - if (handle_to_fn (handle, name)) - /* ok */; - else if (strcmp (name, ":sock:") == 0 - /* On NT4, NtQueryObject returns STATUS_NOT_IMPLEMENTED when - called for a socket handle. */ - || (strcmp (name, unknown_file) == 0 - && !::getsockopt ((SOCKET) handle, SOL_SOCKET, SO_RCVBUF, - (char *) &rcv, &len))) - { - /* socket */ - dev = *tcp_dev; - name[0] = '\0'; - } - else if (fd == 0) - dev = *piper_dev; - else - dev = *pipew_dev; - if (name[0]) - access = FILE_CREATE_PIPE_INSTANCE; - } - else if (GetConsoleScreenBufferInfo (handle, &buf)) - { - /* Console output */ - if (ISSTATE (myself, PID_USETTY)) - dev.parse (FH_TTY); - else - dev = *console_dev; - } - else if (GetNumberOfConsoleInputEvents (handle, (DWORD *) &buf)) - { - /* Console input */ - if (ISSTATE (myself, PID_USETTY)) - dev.parse (FH_TTY); - else - dev = *console_dev; - } - else if (GetCommState (handle, &dcb)) - /* serial */ - dev.parse (DEV_TTYS_MAJOR, 0); - else - /* Try to figure it out from context - probably a disk file */ - handle_to_fn (handle, name); - - if (!name[0] && !dev) - fds[fd] = NULL; - else - { - fhandler_base *fh; - - if (dev) - fh = build_fh_dev (dev); - else - fh = build_fh_name (name); - - if (fh) - cygheap->fdtab[fd] = fh; - - if (name[0]) - { - bin = fh->pc_binmode (); - if (!bin) - { - bin = fh->get_default_fmode (O_RDWR); - if (!bin && dev) - bin = O_BINARY; - } - } - - if (dev == FH_TTY || dev == FH_CONSOLE) - access |= GENERIC_READ | GENERIC_WRITE; - else if (fd == 0) - access |= GENERIC_READ; - else - access |= GENERIC_WRITE; /* Should be rdwr for stderr but not sure that's - possible for some versions of handles */ - /* FIXME: Workaround Windows 7 issue. If the parent process of - the process tree closes the original handles to the console window, - strange problems occur when starting child processes later on if - stdio redirection is used. - - CV 2009-08-08: It looks like this problem has been fixed only - half-heartedly in RTM. Unfortunately the new implementation - has still a problem which now also occurs on the 32 bit release - of Windows 7. It's still not quite clear what happens but it's - easily reproducible. Just start X via the start menu entry. - This opens an xterm window with a shell. Exit from the shell, - and you get a Windows error box reporting a crash in the - Console Window Host application (conhost.exe) due to an access - violation. - - This needs further investigation but the workaround not to close - the handles will have a marginal hit of three extra handles per - process at most. */ - if (fh->init (dev == FH_CONSOLE && wincap.has_console_handle_problem () - ? INVALID_HANDLE_VALUE : handle, access, bin)) - set_std_handle (fd); - else - api_fatal ("couldn't initialize fd %d for %s", fd, fh->get_name ()); - paranoid_printf ("fd %d, handle %p", fd, handle); - } -} - -#define cnew(name) new ((void *) ccalloc (HEAP_FHANDLER, 1, sizeof (name))) name - -fhandler_base * -build_fh_name (const char *name, unsigned opt, suffix_info *si) -{ - path_conv pc (name, opt | PC_NULLEMPTY | PC_POSIX, si); - if (pc.error) - { - fhandler_base *fh = cnew (fhandler_nodevice) (); - if (fh) - fh->set_error (pc.error); - set_errno (fh ? pc.error : EMFILE); - return fh; - } - - return build_fh_pc (pc); -} - -fhandler_base * -build_fh_dev (const device& dev, const char *unix_name) -{ - path_conv pc (dev); - if (unix_name) - pc.set_normalized_path (unix_name); - else - pc.set_normalized_path (dev.name); - return build_fh_pc (pc); -} - -#define fh_unset ((fhandler_base *) 1) -fhandler_base * -build_fh_pc (path_conv& pc, bool set_name) -{ - fhandler_base *fh = fh_unset; - - switch (pc.dev.major) - { - case DEV_TTYS_MAJOR: - fh = cnew (fhandler_tty_slave) (); - break; - case DEV_TTYM_MAJOR: - fh = cnew (fhandler_tty_master) (); - break; - case DEV_CYGDRIVE_MAJOR: - fh = cnew (fhandler_cygdrive) (); - break; - case DEV_FLOPPY_MAJOR: - case DEV_CDROM_MAJOR: - case DEV_SD_MAJOR: - case DEV_SD1_MAJOR: - case DEV_SD2_MAJOR: - case DEV_SD3_MAJOR: - case DEV_SD4_MAJOR: - case DEV_SD5_MAJOR: - case DEV_SD6_MAJOR: - case DEV_SD7_MAJOR: - fh = cnew (fhandler_dev_floppy) (); - break; - case DEV_TAPE_MAJOR: - fh = cnew (fhandler_dev_tape) (); - break; - case DEV_SERIAL_MAJOR: - fh = cnew (fhandler_serial) (); - break; - default: - switch (pc.dev) - { - case FH_CONSOLE: - case FH_CONIN: - case FH_CONOUT: - fh = cnew (fhandler_console) (); - break; - case FH_PTYM: - fh = cnew (fhandler_pty_master) (); - break; - case FH_WINDOWS: - fh = cnew (fhandler_windows) (); - break; - case FH_FIFO: - fh = cnew (fhandler_fifo) (); - break; - case FH_PIPE: - case FH_PIPER: - case FH_PIPEW: - fh = cnew (fhandler_pipe) (); - break; - case FH_TCP: - case FH_UDP: - case FH_ICMP: - case FH_UNIX: - case FH_STREAM: - case FH_DGRAM: - fh = cnew (fhandler_socket) (); - break; - case FH_FS: - fh = cnew (fhandler_disk_file) (); - break; - case FH_NULL: - fh = cnew (fhandler_dev_null) (); - break; - case FH_ZERO: - case FH_FULL: - fh = cnew (fhandler_dev_zero) (); - break; - case FH_RANDOM: - case FH_URANDOM: - fh = cnew (fhandler_dev_random) (); - break; - case FH_MEM: - case FH_PORT: - fh = cnew (fhandler_dev_mem) (); - break; - case FH_CLIPBOARD: - fh = cnew (fhandler_dev_clipboard) (); - break; - case FH_OSS_DSP: - fh = cnew (fhandler_dev_dsp) (); - break; - case FH_PROC: - fh = cnew (fhandler_proc) (); - break; - case FH_REGISTRY: - fh = cnew (fhandler_registry) (); - break; - case FH_PROCESS: - case FH_PROCESSFD: - fh = cnew (fhandler_process) (); - break; - case FH_PROCNET: - fh = cnew (fhandler_procnet) (); - break; - case FH_NETDRIVE: - fh = cnew (fhandler_netdrive) (); - break; - case FH_TTY: - { - if (myself->ctty == TTY_CONSOLE) - fh = cnew (fhandler_console) (); - else if (myself->ctty >= 0) - fh = cnew (fhandler_tty_slave) (); - break; - } - case FH_KMSG: - fh = cnew (fhandler_mailslot) (); - break; - } - } - - if (fh == fh_unset) - fh = cnew (fhandler_nodevice) (); - - if (!fh) - set_errno (EMFILE); - else if (set_name) - fh->set_name (pc); - - debug_printf ("fh %p", fh); - return fh; -} - -fhandler_base * -dtable::dup_worker (fhandler_base *oldfh, int flags) -{ - /* Don't call set_name in build_fh_pc. It will be called in - fhandler_base::operator= below. Calling it twice will result - in double allocation. */ - fhandler_base *newfh = build_fh_pc (oldfh->pc, false); - if (!newfh) - debug_printf ("build_fh_pc failed"); - else - { - *newfh = *oldfh; - newfh->set_io_handle (NULL); - if (oldfh->dup (newfh)) - { - delete newfh; - newfh = NULL; - debug_printf ("oldfh->dup failed"); - } - else - { - /* The O_CLOEXEC flag enforces close-on-exec behaviour. */ - if (flags & O_CLOEXEC) - newfh->set_close_on_exec (true); - else - newfh->close_on_exec (false); - debug_printf ("duped '%s' old %p, new %p", oldfh->get_name (), oldfh->get_io_handle (), newfh->get_io_handle ()); - } - } - return newfh; -} - -int -dtable::dup3 (int oldfd, int newfd, int flags) -{ - int res = -1; - fhandler_base *newfh = NULL; // = NULL to avoid an incorrect warning - - MALLOC_CHECK; - debug_printf ("dup3 (%d, %d, %p)", oldfd, newfd, flags); - lock (); - - if (not_open (oldfd)) - { - syscall_printf ("fd %d not open", oldfd); - set_errno (EBADF); - goto done; - } - if (newfd < 0) - { - syscall_printf ("new fd out of bounds: %d", newfd); - set_errno (EBADF); - goto done; - } - if ((flags & ~O_CLOEXEC) != 0) - { - syscall_printf ("invalid flags value %x", flags); - set_errno (EINVAL); - return -1; - } - - if ((newfh = dup_worker (fds[oldfd], flags)) == NULL) - { - res = -1; - goto done; - } - - debug_printf ("newfh->io_handle %p, oldfh->io_handle %p, new win32_name %p, old win32_name %p", - newfh->get_io_handle (), fds[oldfd]->get_io_handle (), newfh->get_win32_name (), fds[oldfd]->get_win32_name ()); - - if (!not_open (newfd)) - close (newfd); - else if ((size_t) newfd < size) - /* nothing to do */; - else if (find_unused_handle (newfd) < 0) - { - newfh->close (); - res = -1; - goto done; - } - - fds[newfd] = newfh; - - if ((res = newfd) <= 2) - set_std_handle (res); - -done: - MALLOC_CHECK; - unlock (); - syscall_printf ("%d = dup3 (%d, %d, %p)", res, oldfd, newfd, flags); - - return res; -} - -bool -dtable::select_read (int fd, select_stuff *ss) -{ - if (not_open (fd)) - { - set_errno (EBADF); - return false; - } - fhandler_base *fh = fds[fd]; - select_record *s = fh->select_read (ss); - s->fd = fd; - if (!s->fh) - s->fh = fh; - s->thread_errno = 0; - debug_printf ("%s fd %d", fh->get_name (), fd); - return true; -} - -bool -dtable::select_write (int fd, select_stuff *ss) -{ - if (not_open (fd)) - { - set_errno (EBADF); - return NULL; - } - fhandler_base *fh = fds[fd]; - select_record *s = fh->select_write (ss); - s->fd = fd; - s->fh = fh; - s->thread_errno = 0; - debug_printf ("%s fd %d", fh->get_name ()); - return true; -} - -bool -dtable::select_except (int fd, select_stuff *ss) -{ - if (not_open (fd)) - { - set_errno (EBADF); - return NULL; - } - fhandler_base *fh = fds[fd]; - select_record *s = fh->select_except (ss); - s->fd = fd; - s->fh = fh; - s->thread_errno = 0; - debug_printf ("%s fd %d", fh->get_name (), fd); - return true; -} - -void -dtable::move_fd (int from, int to) -{ - // close (to); /* It is assumed that this is close-on-exec */ - fds[to] = fds[from]; - fds[from] = NULL; -} - -void -dtable::set_file_pointers_for_exec () -{ -/* This is not POSIX-compliant so the function is only called for - non-Cygwin processes. */ - LONG off_high = 0; - lock (); - fhandler_base *fh; - for (size_t i = 0; i < size; i++) - if ((fh = fds[i]) != NULL && fh->get_flags () & O_APPEND) - SetFilePointer (fh->get_handle (), 0, &off_high, FILE_END); - unlock (); -} - -void -dtable::fixup_after_exec () -{ - first_fd_for_open = 0; - fhandler_base *fh; - for (size_t i = 0; i < size; i++) - if ((fh = fds[i]) != NULL) - { - fh->clear_readahead (); - fh->fixup_after_exec (); - if (fh->close_on_exec ()) - { - if (fh->archetype) - { - debug_printf ("closing fd %d since it is an archetype", i); - fh->close (); - } - release (i); - } - else if (fh->get_popen_pid ()) - close (i); - else if (i == 0) - SetStdHandle (std_consts[i], fh->get_io_handle ()); - else if (i <= 2) - SetStdHandle (std_consts[i], fh->get_output_handle ()); - } -} - -void -dtable::fixup_after_fork (HANDLE parent) -{ - fhandler_base *fh; - for (size_t i = 0; i < size; i++) - if ((fh = fds[i]) != NULL) - { - if (fh->close_on_exec () || fh->need_fork_fixup ()) - { - debug_printf ("fd %d (%s)", i, fh->get_name ()); - fh->fixup_after_fork (parent); - } - if (i == 0) - SetStdHandle (std_consts[i], fh->get_io_handle ()); - else if (i <= 2) - SetStdHandle (std_consts[i], fh->get_output_handle ()); - } -} - -#ifdef NEWVFORK -int -dtable::vfork_child_dup () -{ - fhandler_base **newtable; - lock (); - newtable = (fhandler_base **) ccalloc (HEAP_ARGV, size, sizeof (fds[0])); - int res = 1; - - /* Remove impersonation */ - cygheap->user.deimpersonate (); - if (cygheap->ctty) - { - cygheap->ctty->usecount++; - cygheap->console_count++; - report_tty_counts (cygheap->ctty, "vfork dup", "incremented ", ""); - } - - for (size_t i = 0; i < size; i++) - if (not_open (i)) - continue; - else if ((newtable[i] = dup_worker (fds[i])) != NULL) - newtable[i]->set_close_on_exec (fds[i]->close_on_exec ()); - else - { - res = 0; - goto out; - } - - fds_on_hold = fds; - fds = newtable; - -out: - /* Restore impersonation */ - cygheap->user.reimpersonate (); - - unlock (); - return 1; -} - -void -dtable::vfork_parent_restore () -{ - lock (); - - fhandler_tty_slave *ctty_on_hold = cygheap->ctty_on_hold; - close_all_files (); - fhandler_base **deleteme = fds; - fds = fds_on_hold; - fds_on_hold = NULL; - cfree (deleteme); - unlock (); - - if (cygheap->ctty != ctty_on_hold) - { - cygheap->ctty = ctty_on_hold; // revert - cygheap->ctty->close (); // Undo previous bump of this archetype - } - cygheap->ctty_on_hold = NULL; -} - -void -dtable::vfork_child_fixup () -{ - if (!fds_on_hold) - return; - debug_printf ("here"); - fhandler_base **saveme = fds; - fds = fds_on_hold; - - fhandler_base *fh; - for (int i = 0; i < (int) size; i++) - if ((fh = fds[i]) != NULL) - { - fh->clear_readahead (); - if (!fh->archetype && fh->close_on_exec ()) - release (i); - else - { - fh->close (); - release (i); - } - } - - fds = saveme; - cfree (fds_on_hold); - fds_on_hold = NULL; - - if (cygheap->ctty_on_hold) - { - cygheap->ctty_on_hold->close (); - cygheap->ctty_on_hold = NULL; - } -} -#endif /*NEWVFORK*/ - -static void -decode_tty (char *buf, WCHAR *w32) -{ - int ttyn = wcstol (w32, NULL, 10); - __small_sprintf (buf, "/dev/tty%d", ttyn); -} - -/* Try to derive posix filename from given handle. Return true if - the handle is associated with a cygwin tty. */ -static bool -handle_to_fn (HANDLE h, char *posix_fn) -{ - tmp_pathbuf tp; - ULONG len = 0; - WCHAR *maxmatchdos = NULL; - int maxmatchlen = 0; - OBJECT_NAME_INFORMATION *ntfn = (OBJECT_NAME_INFORMATION *) tp.w_get (); - - NTSTATUS status = NtQueryObject (h, ObjectNameInformation, ntfn, 65536, &len); - if (!NT_SUCCESS (status)) - debug_printf ("NtQueryObject failed, %p", status); - // NT seems to do this on an unopened file - else if (!ntfn->Name.Buffer) - debug_printf ("nt->Name.Buffer == NULL"); - else - { - WCHAR *w32 = ntfn->Name.Buffer; - size_t w32len = ntfn->Name.Length / sizeof (WCHAR); - w32[w32len] = L'\0'; - - if (wcscasecmp (w32, DEV_NULL) == 0) - { - strcpy (posix_fn, "/dev/null"); - return false; - } - - if (wcscasecmp (w32, DEV_SOCKET) == 0) - { - strcpy (posix_fn, ":sock:"); - return false; - } - - if (wcsncasecmp (w32, DEV_NAMED_PIPE, DEV_NAMED_PIPE_LEN) == 0) - { - w32 += DEV_NAMED_PIPE_LEN; - if (wcsncmp (w32, L"cygwin-", WCLEN (L"cygwin-")) != 0) - return false; - w32 += WCLEN (L"cygwin-"); - /* Check for installation key and trailing dash. */ - w32len = installation_key.Length / sizeof (WCHAR); - if (w32len && wcsncmp (w32, installation_key.Buffer, w32len) != 0) - return false; - w32 += w32len; - if (*w32 != L'-') - return false; - ++w32; - bool istty = wcsncmp (w32, L"tty", WCLEN (L"tty")) == 0; - if (istty) - decode_tty (posix_fn, w32 + WCLEN (L"tty")); - else if (wcsncmp (w32, L"pipe", WCLEN (L"pipe")) == 0) - strcpy (posix_fn, "/dev/pipe"); - return istty; - } - - WCHAR fnbuf[64 * 1024]; - if (wcsncasecmp (w32, DEVICE_PREFIX, DEVICE_PREFIX_LEN) != 0 - || !QueryDosDeviceW (NULL, fnbuf, sizeof (fnbuf))) - { - sys_wcstombs (posix_fn, NT_MAX_PATH, w32, w32len); - return false; - } - - for (WCHAR *s = fnbuf; *s; s = wcschr (s, '\0') + 1) - { - WCHAR device[NT_MAX_PATH]; - if (!QueryDosDeviceW (s, device, sizeof (device))) - continue; - if (wcschr (s, ':') == NULL) - continue; - WCHAR *q = wcsrchr (device, ';'); - if (q) - { - WCHAR *r = wcschr (q, '\\'); - if (r) - wcscpy (q, r + 1); - } - int devlen = wcslen (device); - if (device[devlen - 1] == L'\\') - device[--devlen] = L'\0'; - if (devlen < maxmatchlen) - continue; - if (wcsncmp (device, w32, devlen) != 0|| - (w32[devlen] != L'\0' && w32[devlen] != L'\\')) - continue; - maxmatchlen = devlen; - maxmatchdos = s; - debug_printf ("current match '%W' = '%W'\n", s, device); - } - - if (maxmatchlen) - { - WCHAR *p = wcschr (w32 + DEVICE_PREFIX_LEN, L'\\'); - size_t n = wcslen (maxmatchdos); - WCHAR ch; - if (!p) - ch = L'\0'; - else - { - if (maxmatchdos[n - 1] == L'\\') - n--; - w32 += maxmatchlen - n; - ch = L'\\'; - } - memcpy (w32, maxmatchdos, n * sizeof (WCHAR)); - w32[n] = ch; - } - else if (wcsncmp (w32, DEV_REMOTE, DEV_REMOTE_LEN) == 0) - { - w32 += DEV_REMOTE_LEN - 2; - *w32 = L'\\'; - debug_printf ("remote drive"); - } - else if (wcsncmp (w32, DEV_REMOTE1, DEV_REMOTE1_LEN) == 0) - { - w32 += DEV_REMOTE1_LEN - 2; - *w32 = L'\\'; - debug_printf ("remote drive"); - } - - cygwin_conv_path (CCP_WIN_W_TO_POSIX | CCP_ABSOLUTE, w32, posix_fn, - NT_MAX_PATH); - - debug_printf ("derived path '%W', posix '%s'", w32, posix_fn); - return false; - } - - strcpy (posix_fn, unknown_file); - return false; -} - -void -dtable::fixup_before_fork (DWORD target_proc_id) -{ - lock (); - fhandler_base *fh; - for (size_t i = 0; i < size; i++) - if ((fh = fds[i]) != NULL) - { - debug_printf ("fd %d (%s)", i, fh->get_name ()); - fh->fixup_before_fork_exec (target_proc_id); - } - unlock (); -} -void -dtable::fixup_before_exec (DWORD target_proc_id) -{ - lock (); - fhandler_base *fh; - for (size_t i = 0; i < size; i++) - if ((fh = fds[i]) != NULL && !fh->close_on_exec ()) - { - debug_printf ("fd %d (%s)", i, fh->get_name ()); - fh->fixup_before_fork_exec (target_proc_id); - } - unlock (); -} - diff --git a/winsup/cygwin/dtable.h b/winsup/cygwin/dtable.h deleted file mode 100644 index e3aa2625b..000000000 --- a/winsup/cygwin/dtable.h +++ /dev/null @@ -1,105 +0,0 @@ -/* dtable.h: fd table definition. - - Copyright 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, - 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* Initial and increment values for cygwin's fd table */ -#define NOFILE_INCR 32 -/* Maximum size we allow expanding to. */ -#define OPEN_MAX_MAX (100 * NOFILE_INCR) - -#include "thread.h" -#include "sync.h" - -class suffix_info; - -#define BFH_OPTS (PC_NULLEMPTY | PC_FULL | PC_POSIX) -class dtable -{ - fhandler_base **fds; -#ifdef NEWVFORK - fhandler_base **fds_on_hold; -#endif - fhandler_base **archetypes; - unsigned narchetypes; - unsigned farchetype; - static const int initial_archetype_size = 8; - int first_fd_for_open; - int cnt_need_fixup_before; - void lock () {lock_process::locker.acquire ();} - void unlock () {lock_process::locker.release ();} -public: - size_t size; - - dtable () : archetypes (NULL), narchetypes (0), farchetype (0), first_fd_for_open(3), cnt_need_fixup_before(0) {} - void init () {first_fd_for_open = 3;} - - void dec_need_fixup_before () - { if (cnt_need_fixup_before > 0) --cnt_need_fixup_before; } - void inc_need_fixup_before () - { cnt_need_fixup_before++; } - bool need_fixup_before () - { return cnt_need_fixup_before > 0; } - - void move_fd (int, int); - int vfork_child_dup (); - void vfork_parent_restore (); - void vfork_child_fixup (); - fhandler_base *dup_worker (fhandler_base *oldfh, int flags); - int extend (int howmuch); - void fixup_after_fork (HANDLE); - inline int not_open (int fd) - { - lock (); - int res = fd < 0 || fd >= (int) size || fds[fd] == NULL; - unlock (); - return res; - } - int find_unused_handle (int start); - int find_unused_handle () { return find_unused_handle (first_fd_for_open);} - void release (int fd); - void init_std_file_from_handle (int fd, HANDLE handle); - int dup3 (int oldfd, int newfd, int flags); - void fixup_after_exec (); - inline fhandler_base *&operator [](int fd) const { return fds[fd]; } - bool select_read (int fd, select_stuff *); - bool select_write (int fd, select_stuff *); - bool select_except (int fd, select_stuff *); - operator fhandler_base **() {return fds;} - void stdio_init (); - void get_debugger_info (); - void set_file_pointers_for_exec (); -#ifdef NEWVFORK - bool in_vfork_cleanup () {return fds_on_hold == fds;} -#endif - fhandler_base *find_archetype (device& dev); - fhandler_base **add_archetype (); - void delete_archetype (fhandler_base *); - void fixup_before_exec (DWORD win_proc_id); - void fixup_before_fork (DWORD win_proc_id); - friend void dtable_init (); - friend void __stdcall close_all_files (bool); - friend class fhandler_disk_file; - friend class cygheap_fdmanip; - friend class cygheap_fdget; - friend class cygheap_fdnew; - friend class cygheap_fdenum; - friend class lock_process; -}; - -fhandler_base *build_fh_dev (const device&, const char * = NULL); -fhandler_base *build_fh_name (const char *, unsigned = 0, suffix_info * = NULL); -fhandler_base *build_fh_pc (path_conv& pc, bool set_name = true); - -void dtable_init (); -void stdio_init (); -extern dtable fdtab; - -extern "C" int getfdtabsize (); -extern "C" void setfdtabsize (int); diff --git a/winsup/cygwin/dtable.sgml b/winsup/cygwin/dtable.sgml deleted file mode 100644 index 73d8b78cc..000000000 --- a/winsup/cygwin/dtable.sgml +++ /dev/null @@ -1,20 +0,0 @@ - - -cygwin_attach_handle_to_fd - - -extern "C" int -cygwin_attach_handle_to_fd -char *name -int fd -HANDLE handle -int bin -int access - - -This function can be used to turn a Win32 "handle" into a -posix-style file handle. fd may be -1 to -make cygwin allocate a handle; the actual handle is returned -in all cases. - - diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc deleted file mode 100644 index 4935bc815..000000000 --- a/winsup/cygwin/environ.cc +++ /dev/null @@ -1,1113 +0,0 @@ -/* environ.cc: Cygwin-adopted functions from newlib to manipulate - process's environment. - - Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009 Red Hat, Inc. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "pinfo.h" -#include "perprocess.h" -#include "path.h" -#include "cygerrno.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "cygtls.h" -#include "tls_pbuf.h" -#include "registry.h" -#include "environ.h" -#include "child_info.h" - -extern bool dos_file_warning; -extern bool ignore_case_with_glob; -extern bool allow_winsymlinks; -bool reset_com = false; -static bool envcache = true; -static bool create_upcaseenv = false; - -static char **lastenviron; - -/* Helper functions for the below environment variables which have to - be converted Win32<->POSIX. */ -extern "C" ssize_t env_PATH_to_posix (const void *, void *, size_t); - -ssize_t -env_plist_to_posix (const void *win32, void *posix, size_t size) -{ - return cygwin_conv_path_list (CCP_WIN_A_TO_POSIX | CCP_RELATIVE, win32, - posix, size); -} - -ssize_t -env_plist_to_win32 (const void *posix, void *win32, size_t size) -{ - return cygwin_conv_path_list (CCP_POSIX_TO_WIN_A | CCP_RELATIVE, posix, - win32, size); -} - -ssize_t -env_path_to_posix (const void *win32, void *posix, size_t size) -{ - return cygwin_conv_path (CCP_WIN_A_TO_POSIX | CCP_ABSOLUTE, win32, - posix, size); -} - -ssize_t -env_path_to_win32 (const void *posix, void *win32, size_t size) -{ - return cygwin_conv_path (CCP_POSIX_TO_WIN_A | CCP_ABSOLUTE, posix, - win32, size); -} - -#define ENVMALLOC \ - (CYGWIN_VERSION_DLL_MAKE_COMBINED (user_data->api_major, user_data->api_minor) \ - <= CYGWIN_VERSION_DLL_MALLOC_ENV) - -#define NL(x) x, (sizeof (x) - 1) -/* List of names which are converted from dos to unix - on the way in and back again on the way out. - - PATH needs to be here because CreateProcess uses it and gdb uses - CreateProcess. HOME is here because most shells use it and would be - confused by Windows style path names. */ -static win_env conv_envvars[] = - { - {NL ("PATH="), NULL, NULL, env_PATH_to_posix, env_plist_to_win32, true}, - {NL ("HOME="), NULL, NULL, env_path_to_posix, env_path_to_win32, false}, - {NL ("LD_LIBRARY_PATH="), NULL, NULL, - env_plist_to_posix, env_plist_to_win32, true}, - {NL ("TMPDIR="), NULL, NULL, env_path_to_posix, env_path_to_win32, false}, - {NL ("TMP="), NULL, NULL, env_path_to_posix, env_path_to_win32, false}, - {NL ("TEMP="), NULL, NULL, env_path_to_posix, env_path_to_win32, false}, - {NULL, 0, NULL, NULL, 0, 0} - }; - -static unsigned char conv_start_chars[256] = {0}; - -struct win_env& -win_env::operator = (struct win_env& x) -{ - name = x.name; - namelen = x.namelen; - toposix = x.toposix; - towin32 = x.towin32; - immediate = false; - return *this; -} - -win_env::~win_env () -{ - if (posix) - free (posix); - if (native) - free (native); -} - -void -win_env::add_cache (const char *in_posix, const char *in_native) -{ - MALLOC_CHECK; - posix = (char *) realloc (posix, strlen (in_posix) + 1); - strcpy (posix, in_posix); - if (in_native) - { - native = (char *) realloc (native, namelen + 1 + strlen (in_native)); - strcpy (native, name); - strcpy (native + namelen, in_native); - } - else - { - tmp_pathbuf tp; - char *buf = tp.c_get (); - strcpy (buf, name + namelen); - towin32 (in_posix, buf, NT_MAX_PATH); - native = (char *) realloc (native, namelen + 1 + strlen (buf)); - strcpy (native, name); - strcpy (native + namelen, buf); - } - MALLOC_CHECK; - if (immediate && cygwin_finished_initializing) - { - char s[namelen]; - size_t n = namelen - 1; - memcpy (s, name, n); - s[n] = '\0'; - SetEnvironmentVariable (s, native + namelen); - } - debug_printf ("posix %s", posix); - debug_printf ("native %s", native); -} - - -/* Check for a "special" environment variable name. *env is the pointer - to the beginning of the environment variable name. *in_posix is any - known posix value for the environment variable. Returns a pointer to - the appropriate conversion structure. */ -win_env * __stdcall -getwinenv (const char *env, const char *in_posix, win_env *temp) -{ - if (!conv_start_chars[(unsigned char)*env]) - return NULL; - - for (int i = 0; conv_envvars[i].name != NULL; i++) - if (strncmp (env, conv_envvars[i].name, conv_envvars[i].namelen) == 0) - { - win_env *we = conv_envvars + i; - const char *val; - if (!cur_environ () || !(val = in_posix ?: getenv (we->name))) - debug_printf ("can't set native for %s since no environ yet", - we->name); - else if (!envcache || !we->posix || strcmp (val, we->posix) != 0) - { - if (temp) - { - *temp = *we; - we = temp; - } - we->add_cache (val); - } - return we; - } - return NULL; -} - -/* Convert windows path specs to POSIX, if appropriate. - */ -static void __stdcall -posify (char **here, const char *value, char *outenv) -{ - char *src = *here; - win_env *conv; - - if (!(conv = getwinenv (src))) - return; - - int len = strcspn (src, "=") + 1; - - /* Turn all the items from c:; into their - mounted equivalents - if there is one. */ - - memcpy (outenv, src, len); - char *newvalue = outenv + len; - if (!conv->toposix (value, newvalue, NT_MAX_PATH - len) - || _impure_ptr->_errno != EIDRM) - conv->add_cache (newvalue, *value != '/' ? value : NULL); - else - { - /* The conversion routine removed elements from a path list so we have - to recalculate the windows path to remove elements there, too. */ - char cleanvalue[strlen (value) + 1]; - conv->towin32 (newvalue, cleanvalue, sizeof cleanvalue); - conv->add_cache (newvalue, cleanvalue); - } - - debug_printf ("env var converted to %s", outenv); - *here = strdup (outenv); - free (src); - MALLOC_CHECK; -} - -/* Returns pointer to value associated with name, if any, else NULL. - Sets offset to be the offset of the name/value combination in the - environment array, for use by setenv(3) and unsetenv(3). - Explicitly removes '=' in argument name. */ - -static char * __stdcall -my_findenv (const char *name, int *offset) -{ - register int len; - register char **p; - const char *c; - - c = name; - len = 0; - while (*c && *c != '=') - { - c++; - len++; - } - - for (p = cur_environ (); *p; ++p) - if (!strncmp (*p, name, len)) - if (*(c = *p + len) == '=') - { - *offset = p - cur_environ (); - return (char *) (++c); - } - MALLOC_CHECK; - return NULL; -} - -/* Primitive getenv before the environment is built. */ - -static char __stdcall * -getearly (const char * name, int *) -{ - char *ret; - char **ptr; - int len; - - if (spawn_info && (ptr = spawn_info->moreinfo->envp)) - { - len = strlen (name); - for (; *ptr; ptr++) - if (strncasematch (name, *ptr, len) && (*ptr)[len] == '=') - return *ptr + len + 1; - } - else if ((len = GetEnvironmentVariableA (name, NULL, 0)) - && (ret = (char *) cmalloc_abort (HEAP_2_STR, len)) - && GetEnvironmentVariableA (name, ret, len)) - return ret; - - return NULL; -} - -static char * (*findenv_func)(const char *, int *) = (char * (*)(const char *, int *)) getearly; - -/* Returns ptr to value associated with name, if any, else NULL. */ - -extern "C" char * -getenv (const char *name) -{ - int offset; - return findenv_func (name, &offset); -} - -/* This function is required so that newlib uses the same environment - as Cygwin. */ -extern "C" char * -_getenv_r (struct _reent *, const char *name) -{ - int offset; - return findenv_func (name, &offset); -} - -static int __stdcall -envsize (const char * const *in_envp) -{ - const char * const *envp; - for (envp = in_envp; *envp; envp++) - continue; - return (1 + envp - in_envp) * sizeof (const char *); -} - -/* Takes similar arguments to setenv except that overwrite is - either -1, 0, or 1. 0 or 1 signify that the function should - perform similarly to setenv. Otherwise putenv is assumed. */ -static int __stdcall -_addenv (const char *name, const char *value, int overwrite) -{ - int issetenv = overwrite >= 0; - int offset; - char *p; - - unsigned int valuelen = strlen (value); - if ((p = my_findenv (name, &offset))) - { /* Already exists. */ - if (!overwrite) /* Ok to overwrite? */ - return 0; /* No. Wanted to add new value. FIXME: Right return value? */ - - /* We've found the offset into environ. If this is a setenv call and - there is room in the current environment entry then just overwrite it. - Otherwise handle this case below. */ - if (issetenv && strlen (p) >= valuelen) - { - strcpy (p, value); - return 0; - } - } - else - { /* Create new slot. */ - int sz = envsize (cur_environ ()); - int allocsz = sz + (2 * sizeof (char *)); - - offset = (sz - 1) / sizeof (char *); - - /* Allocate space for additional element plus terminating NULL. */ - if (cur_environ () == lastenviron) - lastenviron = __cygwin_environ = (char **) realloc (cur_environ (), - allocsz); - else if ((lastenviron = (char **) malloc (allocsz)) != NULL) - __cygwin_environ = (char **) memcpy ((char **) lastenviron, - __cygwin_environ, sz); - - if (!__cygwin_environ) - { -#ifdef DEBUGGING - try_to_debug (); -#endif - return -1; /* Oops. No more memory. */ - } - - __cygwin_environ[offset + 1] = NULL; /* NULL terminate. */ - update_envptrs (); /* Update any local copies of 'environ'. */ - } - - char *envhere; - if (!issetenv) - /* Not setenv. Just overwrite existing. */ - envhere = cur_environ ()[offset] = (char *) (ENVMALLOC ? strdup (name) : name); - else - { /* setenv */ - /* Look for an '=' in the name and ignore anything after that if found. */ - for (p = (char *) name; *p && *p != '='; p++) - continue; - - int namelen = p - name; /* Length of name. */ - /* Allocate enough space for name + '=' + value + '\0' */ - envhere = cur_environ ()[offset] = (char *) malloc (namelen + valuelen + 2); - if (!envhere) - return -1; /* Oops. No more memory. */ - - /* Put name '=' value into current slot. */ - strncpy (envhere, name, namelen); - envhere[namelen] = '='; - strcpy (envhere + namelen + 1, value); - } - - /* Update cygwin's cache, if appropriate */ - win_env *spenv; - if ((spenv = getwinenv (envhere))) - spenv->add_cache (value); - - MALLOC_CHECK; - return 0; -} - -/* Set an environment variable */ -extern "C" int -putenv (char *str) -{ - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - if (*str) - { - char *eq = strchr (str, '='); - if (eq) - return _addenv (str, eq + 1, -1); - - /* Remove str from the environment. */ - unsetenv (str); - } - return 0; -} - -/* Set the value of the environment variable "name" to be - "value". If overwrite is set, replace any current value. */ -extern "C" int -setenv (const char *name, const char *value, int overwrite) -{ - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - if (!name || !*name || strchr (name, '=')) - { - set_errno (EINVAL); - return -1; - } - return _addenv (name, value, !!overwrite); -} - -/* Delete environment variable "name". */ -extern "C" int -unsetenv (const char *name) -{ - register char **e; - int offset; - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - if (!name || *name == '\0' || strchr (name, '=')) - { - set_errno (EINVAL); - return -1; - } - - while (my_findenv (name, &offset)) /* if set multiple times */ - /* Move up the rest of the array */ - for (e = cur_environ () + offset; ; e++) - if (!(*e = *(e + 1))) - break; - - return 0; -} - -/* Minimal list of Windows vars which must be converted to uppercase. - Either for POSIX compatibility of for backward compatibility with - existing applications. */ -static struct renv { - const char *name; - const size_t namelen; -} renv_arr[] = { - { NL("ALLUSERSPROFILE=") }, // 0 - { NL("COMMONPROGRAMFILES=") }, // 1 - { NL("COMPUTERNAME=") }, - { NL("COMSPEC=") }, - { NL("HOME=") }, // 4 - { NL("HOMEDRIVE=") }, - { NL("HOMEPATH=") }, - { NL("NUMBER_OF_PROCESSORS=") }, // 7 - { NL("OS=") }, // 8 - { NL("PATH=") }, // 9 - { NL("PATHEXT=") }, - { NL("PROCESSOR_ARCHITECTURE=") }, - { NL("PROCESSOR_IDENTIFIER=") }, - { NL("PROCESSOR_LEVEL=") }, - { NL("PROCESSOR_REVISION=") }, - { NL("PROGRAMFILES=") }, - { NL("SYSTEMDRIVE=") }, // 16 - { NL("SYSTEMROOT=") }, - { NL("TEMP=") }, // 18 - { NL("TERM=") }, - { NL("TMP=") }, - { NL("TMPDIR=") }, - { NL("WINDIR=") } // 22 -}; -#define RENV_SIZE (sizeof (renv_arr) / sizeof (renv_arr[0])) -/* Set of first characters of the above list of variables. */ -static const char idx_arr[] = "ACHNOPSTW"; -/* Index into renv_arr at which the variables with this specific character - starts. */ -static const int start_at[] = { 0, 1, 4, 7, 8, 9, 16, 18, 22 }; - -/* Turn environment variable part of a=b string into uppercase. - Conditionally controlled by upcaseenv CYGWIN setting. */ -static __inline__ void -ucenv (char *p, const char *eq) -{ - if (create_upcaseenv) - { - /* Amazingly, NT has a case sensitive environment name list, - but only sometimes. - It's normal to have NT set your "Path" to something. - Later, you set "PATH" to something else. This alters "Path". - But if you try and do a naive getenv on "PATH" you'll get nothing. - - So we upper case the labels here to prevent confusion later but - we only do it for processes that are started by non-Cygwin programs. */ - for (; p < eq; p++) - if (islower (*p)) - *p = cyg_toupper (*p); - } - else - { - /* Hopefully as quickly as possible - only upcase specific set of important - Windows variables. */ - char first = cyg_toupper (*p); - const char *idx = strchr (idx_arr, first); - if (idx) - for (size_t i = start_at[idx - idx_arr]; - i < RENV_SIZE && renv_arr[i].name[0] == first; - ++i) - if (strncasematch (p, renv_arr[i].name, renv_arr[i].namelen)) - { - strncpy (p, renv_arr[i].name, renv_arr[i].namelen); - break; - } - } -} - -/* Parse CYGWIN options */ - -static NO_COPY bool export_settings = false; - -enum settings - { - justset, - isfunc, - setbit, - set_process_state, - }; - -/* When BUF is: - null or empty: disables globbing - "ignorecase": enables case-insensitive globbing - anything else: enables case-sensitive globbing */ -static void -glob_init (const char *buf) -{ - if (!buf || !*buf) - { - allow_glob = false; - ignore_case_with_glob = false; - } - else if (ascii_strncasematch (buf, "ignorecase", 10)) - { - allow_glob = true; - ignore_case_with_glob = true; - } - else - { - allow_glob = true; - ignore_case_with_glob = false; - } -} - -static void -set_chunksize (const char *buf) -{ - wincap.set_chunksize (strtoul (buf, NULL, 0)); -} - -static void -set_proc_retry (const char *buf) -{ - child_info::retry_count = strtoul (buf, NULL, 0); -} - -/* The structure below is used to set up an array which is used to - parse the CYGWIN environment variable or, if enabled, options from - the registry. */ -static struct parse_thing - { - const char *name; - union parse_setting - { - bool *b; - DWORD *x; - int *i; - void (*func)(const char *); - } setting; - - enum settings disposition; - char *remember; - union parse_values - { - DWORD i; - const char *s; - } values[2]; - } known[] NO_COPY = -{ - {"dosfilewarning", {&dos_file_warning}, justset, NULL, {{false}, {true}}}, - {"envcache", {&envcache}, justset, NULL, {{true}, {false}}}, - {"error_start", {func: &error_start_init}, isfunc, NULL, {{0}, {0}}}, - {"export", {&export_settings}, justset, NULL, {{false}, {true}}}, - {"forkchunk", {func: set_chunksize}, isfunc, NULL, {{0}, {0}}}, - {"glob", {func: &glob_init}, isfunc, NULL, {{0}, {s: "normal"}}}, - {"proc_retry", {func: set_proc_retry}, isfunc, NULL, {{0}, {5}}}, - {"reset_com", {&reset_com}, justset, NULL, {{false}, {true}}}, - {"strip_title", {&strip_title_path}, justset, NULL, {{false}, {true}}}, - {"title", {&display_title}, justset, NULL, {{false}, {true}}}, - {"tty", {NULL}, set_process_state, NULL, {{0}, {PID_USETTY}}}, - {"upcaseenv", {&create_upcaseenv}, justset, NULL, {{false}, {true}}}, - {"winsymlinks", {&allow_winsymlinks}, justset, NULL, {{false}, {true}}}, - {NULL, {0}, justset, 0, {{0}, {0}}} -}; - -/* Parse a string of the form "something=stuff somethingelse=more-stuff", - silently ignoring unknown "somethings". */ -static void __stdcall -parse_options (char *buf) -{ - int istrue; - char *p, *lasts; - parse_thing *k; - - if (buf == NULL) - { - tmp_pathbuf tp; - char *newbuf = tp.c_get (); - newbuf[0] = '\0'; - for (k = known; k->name != NULL; k++) - if (k->remember) - { - strcat (strcat (newbuf, " "), k->remember); - free (k->remember); - k->remember = NULL; - } - - if (export_settings) - { - debug_printf ("%s", newbuf + 1); - setenv ("CYGWIN", newbuf + 1, 1); - } - return; - } - - buf = strcpy ((char *) alloca (strlen (buf) + 1), buf); - for (p = strtok_r (buf, " \t", &lasts); - p != NULL; - p = strtok_r (NULL, " \t", &lasts)) - { - char *keyword_here = p; - if (!(istrue = !ascii_strncasematch (p, "no", 2))) - p += 2; - else if (!(istrue = *p != '-')) - p++; - - char ch, *eq; - if ((eq = strchr (p, '=')) != NULL || (eq = strchr (p, ':')) != NULL) - ch = *eq, *eq++ = '\0'; - else - ch = 0; - - for (parse_thing *k = known; k->name != NULL; k++) - if (ascii_strcasematch (p, k->name)) - { - switch (k->disposition) - { - case isfunc: - k->setting.func ((!eq || !istrue) ? - k->values[istrue].s : eq); - debug_printf ("%s (called func)", k->name); - break; - case justset: - if (!istrue || !eq) - *k->setting.x = k->values[istrue].i; - else - *k->setting.x = strtol (eq, NULL, 0); - debug_printf ("%s %d", k->name, *k->setting.x); - break; - case set_process_state: - k->setting.x = &myself->process_state; - /* fall through */ - case setbit: - *k->setting.x &= ~k->values[istrue].i; - if (istrue || (eq && strtol (eq, NULL, 0))) - *k->setting.x |= k->values[istrue].i; - debug_printf ("%s %x", k->name, *k->setting.x); - break; - } - - if (eq) - *--eq = ch; - - int n = eq - p; - p = strdup (keyword_here); - if (n > 0) - p[n] = ':'; - k->remember = p; - break; - } - } - debug_printf ("returning"); -} - -/* Set options from the registry. */ -static bool __stdcall -regopt (const char *name, char *buf) -{ - bool parsed_something = false; - char lname[strlen (name) + 1]; - strlwr (strcpy (lname, name)); - - for (int i = 0; i < 2; i++) - { - reg_key r (i, KEY_READ, CYGWIN_INFO_PROGRAM_OPTIONS_NAME, NULL); - - if (r.get_string (lname, buf, NT_MAX_PATH, "") == ERROR_SUCCESS) - { - parse_options (buf); - parsed_something = true; - break; - } - } - - MALLOC_CHECK; - return parsed_something; -} - -/* Initialize the environ array. Look for the CYGWIN environment - environment variable and set appropriate options from it. */ -void -environ_init (char **envp, int envc) -{ - PWCHAR rawenv, w; - int i; - char *p; - char *newp; - int sawTERM = 0; - bool envp_passed_in; - bool got_something_from_registry; - static char NO_COPY cygterm[] = "TERM=cygwin"; - myfault efault; - tmp_pathbuf tp; - - if (efault.faulted ()) - api_fatal ("internal error reading the windows environment - too many environment variables?"); - - if (!conv_start_chars[0]) - for (int i = 0; conv_envvars[i].name != NULL; i++) - { - conv_start_chars[(int) cyg_tolower (conv_envvars[i].name[0])] = 1; - conv_start_chars[(int) cyg_toupper (conv_envvars[i].name[0])] = 1; - } - - char *tmpbuf = tp.t_get (); - got_something_from_registry = regopt ("default", tmpbuf); - if (myself->progname[0]) - got_something_from_registry = regopt (myself->progname, tmpbuf) - || got_something_from_registry; - - if (!envp) - envp_passed_in = 0; - else - { - envc++; - envc *= sizeof (char *); - char **newenv = (char **) malloc (envc); - memcpy (newenv, envp, envc); - cfree (envp); - - /* Older applications relied on the fact that cygwin malloced elements of the - environment list. */ - envp = newenv; - if (ENVMALLOC) - for (char **e = newenv; *e; e++) - { - char *p = *e; - *e = strdup (p); - cfree (p); - } - envp_passed_in = 1; - goto out; - } - - /* Allocate space for environment + trailing NULL + CYGWIN env. */ - lastenviron = envp = (char **) malloc ((4 + (envc = 100)) * sizeof (char *)); - - /* We also need the CYGWIN variable early to know the value of the - CYGWIN=upcaseenv setting for the below loop. */ - if ((i = GetEnvironmentVariableA ("CYGWIN", NULL, 0))) - { - char *buf = (char *) alloca (i); - GetEnvironmentVariableA ("CYGWIN", buf, i); - parse_options (buf); - } - - rawenv = GetEnvironmentStringsW (); - if (!rawenv) - { - system_printf ("GetEnvironmentStrings returned NULL, %E"); - return; - } - debug_printf ("GetEnvironmentStrings returned %p", rawenv); - - /* Current directory information is recorded as variables of the - form "=X:=X:\foo\bar; these must be changed into something legal - (we could just ignore them but maybe an application will - eventually want to use them). */ - for (i = 0, w = rawenv; *w != L'\0'; w = wcschr (w, L'\0') + 1, i++) - { - sys_wcstombs_alloc (&newp, HEAP_NOTHEAP, w); - if (i >= envc) - envp = (char **) realloc (envp, (4 + (envc += 100)) * sizeof (char *)); - envp[i] = newp; - if (*newp == '=') - *newp = '!'; - char *eq = strechr (newp, '='); - ucenv (newp, eq); /* (possibly conditionally) uppercase env vars. */ - if (*newp == 'T' && strncmp (newp, "TERM=", 5) == 0) - sawTERM = 1; - if (*eq && conv_start_chars[(unsigned char) envp[i][0]]) - posify (envp + i, *++eq ? eq : --eq, tmpbuf); - debug_printf ("%p: %s", envp[i], envp[i]); - } - - if (!sawTERM) - envp[i++] = strdup (cygterm); - envp[i] = NULL; - FreeEnvironmentStringsW (rawenv); - -out: - findenv_func = (char * (*)(const char*, int*)) my_findenv; - __cygwin_environ = envp; - update_envptrs (); - if (envp_passed_in) - { - p = getenv ("CYGWIN"); - if (p) - parse_options (p); - } - - if (got_something_from_registry) - parse_options (NULL); /* possibly export registry settings to - environment */ - MALLOC_CHECK; -} - -/* Function called by qsort to sort environment strings. */ -static int -env_sort (const void *a, const void *b) -{ - const char **p = (const char **) a; - const char **q = (const char **) b; - - return strcmp (*p, *q); -} - -char * __stdcall -getwinenveq (const char *name, size_t namelen, int x) -{ - WCHAR name0[namelen - 1]; - WCHAR valbuf[32768]; /* Max size of an env.var including trailing '\0'. */ - - name0[sys_mbstowcs (name0, sizeof name0, name, namelen - 1)] = L'\0'; - int totlen = GetEnvironmentVariableW (name0, valbuf, 32768); - if (totlen > 0) - { - totlen = sys_wcstombs (NULL, 0, valbuf); - if (x == HEAP_1_STR) - totlen += namelen; - else - namelen = 0; - char *p = (char *) cmalloc_abort ((cygheap_types) x, totlen); - if (namelen) - strcpy (p, name); - sys_wcstombs (p + namelen, totlen, valbuf); - debug_printf ("using value from GetEnvironmentVariable for '%W'", name0); - return p; - } - - debug_printf ("warning: %s not present in environment", name); - return NULL; -} - -struct spenv -{ - const char *name; - size_t namelen; - bool force_into_environment; /* If true, always add to env if missing */ - bool add_if_exists; /* if true, retrieve value from cache */ - const char * (cygheap_user::*from_cygheap) (const char *, size_t); - - char *retrieve (bool, const char * const = NULL) - __attribute__ ((regparm (3))); -}; - -#define env_dontadd almost_null - -/* Keep this list in upper case and sorted */ -static NO_COPY spenv spenvs[] = -{ -#ifdef DEBUGGING - {NL ("CYGWIN_DEBUG="), false, true, NULL}, -#endif - {NL ("HOMEDRIVE="), false, false, &cygheap_user::env_homedrive}, - {NL ("HOMEPATH="), false, false, &cygheap_user::env_homepath}, - {NL ("LOGONSERVER="), false, false, &cygheap_user::env_logsrv}, - {NL ("PATH="), false, true, NULL}, - {NL ("SYSTEMDRIVE="), false, true, NULL}, - {NL ("SYSTEMROOT="), true, true, &cygheap_user::env_systemroot}, - {NL ("USERDOMAIN="), false, false, &cygheap_user::env_domain}, - {NL ("USERNAME="), false, false, &cygheap_user::env_name}, - {NL ("USERPROFILE="), false, false, &cygheap_user::env_userprofile}, - {NL ("WINDIR="), true, true, &cygheap_user::env_systemroot} -}; - -char * -spenv::retrieve (bool no_envblock, const char *const env) -{ - if (env && !ascii_strncasematch (env, name, namelen)) - return NULL; - - debug_printf ("no_envblock %d", no_envblock); - - if (from_cygheap) - { - const char *p; - if (env && !cygheap->user.issetuid ()) - { - debug_printf ("duping existing value for '%s'", name); - /* Don't really care what it's set to if we're calling a cygwin program */ - return cstrdup1 (env); - } - - /* Calculate (potentially) value for given environment variable. */ - p = (cygheap->user.*from_cygheap) (name, namelen); - if (!p || (no_envblock && !env) || (p == env_dontadd)) - return env_dontadd; - char *s = (char *) cmalloc_abort (HEAP_1_STR, namelen + strlen (p) + 1); - strcpy (s, name); - strcpy (s + namelen, p); - debug_printf ("using computed value for '%s'", name); - return s; - } - - if (env) - return cstrdup1 (env); - - return getwinenveq (name, namelen, HEAP_1_STR); -} - -#define SPENVS_SIZE (sizeof (spenvs) / sizeof (spenvs[0])) - -/* Create a Windows-style environment block, i.e. a typical character buffer - filled with null terminated strings, terminated by double null characters. - Converts environment variables noted in conv_envvars into win32 form - prior to placing them in the string. */ -char ** __stdcall -build_env (const char * const *envp, PWCHAR &envblock, int &envc, - bool no_envblock) -{ - int len, n; - const char * const *srcp; - char **dstp; - bool saw_spenv[SPENVS_SIZE] = {0}; - - debug_printf ("envp %p", envp); - - /* How many elements? */ - for (n = 0; envp[n]; n++) - continue; - - /* Allocate a new "argv-style" environ list with room for extra stuff. */ - char **newenv = (char **) cmalloc_abort (HEAP_1_ARGV, sizeof (char *) * - (n + SPENVS_SIZE + 1)); - - int tl = 0; - char **pass_dstp; - char **pass_env = (char **) alloca (sizeof (char *) * (n + SPENVS_SIZE + 1)); - /* Iterate over input list, generating a new environment list and refreshing - "special" entries, if necessary. */ - for (srcp = envp, dstp = newenv, pass_dstp = pass_env; *srcp; srcp++) - { - bool calc_tl = !no_envblock; - /* Look for entries that require special attention */ - for (unsigned i = 0; i < SPENVS_SIZE; i++) - if (!saw_spenv[i] && (*dstp = spenvs[i].retrieve (no_envblock, *srcp))) - { - saw_spenv[i] = 1; - if (*dstp == env_dontadd) - goto next1; - if (spenvs[i].add_if_exists) - calc_tl = true; - goto next0; - } - - /* Add entry to new environment */ - *dstp = cstrdup1 (*srcp); - - next0: - if (calc_tl) - { - *pass_dstp++ = *dstp; - tl += strlen (*dstp) + 1; - } - dstp++; - next1: - continue; - } - - assert ((srcp - envp) == n); - /* Fill in any required-but-missing environment variables. */ - for (unsigned i = 0; i < SPENVS_SIZE; i++) - if (!saw_spenv[i] && (spenvs[i].force_into_environment || cygheap->user.issetuid ())) - { - *dstp = spenvs[i].retrieve (false); - if (*dstp && *dstp != env_dontadd) - { - *pass_dstp++ = *dstp; - tl += strlen (*dstp) + 1; - dstp++; - } - } - - envc = dstp - newenv; /* Number of entries in newenv */ - assert ((size_t) envc <= (n + SPENVS_SIZE)); - *dstp = NULL; /* Terminate */ - - size_t pass_envc = pass_dstp - pass_env; - if (!pass_envc) - envblock = NULL; - else - { - *pass_dstp = NULL; - debug_printf ("env count %d, bytes %d", pass_envc, tl); - win_env temp; - temp.reset (); - - /* Windows programs expect the environment block to be sorted. */ - qsort (pass_env, pass_envc, sizeof (char *), env_sort); - - /* Create an environment block suitable for passing to CreateProcess. */ - PWCHAR s; - envblock = (PWCHAR) malloc ((2 + tl) * sizeof (WCHAR)); - int new_tl = 0; - for (srcp = pass_env, s = envblock; *srcp; srcp++) - { - const char *p; - win_env *conv; - len = strcspn (*srcp, "=") + 1; - const char *rest = *srcp + len; - - /* Check for a bad entry. This is necessary to get rid of empty - strings, induced by putenv and changing the string afterwards. - Note that this doesn't stop invalid strings without '=' in it - etc., but we're opting for speed here for now. Adding complete - checking would be pretty expensive. */ - if (len == 1 || !*rest) - continue; - - /* See if this entry requires posix->win32 conversion. */ - conv = getwinenv (*srcp, rest, &temp); - if (conv) - p = conv->native; /* Use win32 path */ - else - p = *srcp; /* Don't worry about it */ - - len = sys_mbstowcs (NULL, 0, p); - new_tl += len; /* Keep running total of block length so far */ - - /* See if we need to increase the size of the block. */ - if (new_tl > tl) - { - tl = new_tl + 100; - PWCHAR new_envblock = - (PWCHAR) realloc (envblock, (2 + tl) * sizeof (WCHAR)); - /* If realloc moves the block, move `s' with it. */ - if (new_envblock != envblock) - { - s += new_envblock - envblock; - envblock = new_envblock; - } - } - - int slen = sys_mbstowcs (s, len, p); - - /* See if environment variable is "special" in a Windows sense. - Under NT, the current directories for visited drives are stored - as =C:=\bar. Cygwin converts the '=' to '!' for hopefully obvious - reasons. We need to convert it back when building the envblock */ - if (s[0] == L'!' && (iswdrive (s + 1) || (s[1] == L':' && s[2] == L':')) - && s[3] == L'=') - *s = L'='; - s += slen + 1; - } - *s = L'\0'; /* Two null bytes at the end */ - assert ((s - envblock) <= tl); /* Detect if we somehow ran over end - of buffer */ - } - - debug_printf ("envp %p, envc %d", newenv, envc); - return newenv; -} - -/* This idiocy is necessary because the early implementers of cygwin - did not seem to know about importing data variables from the DLL. - So, we have to synchronize cygwin's idea of the environment with the - main program's with each reference to the environment. */ -extern "C" char ** __stdcall -cur_environ () -{ - if (*main_environ != __cygwin_environ) - { - __cygwin_environ = *main_environ; - update_envptrs (); - } - - return __cygwin_environ; -} diff --git a/winsup/cygwin/environ.h b/winsup/cygwin/environ.h deleted file mode 100644 index 78305a8b0..000000000 --- a/winsup/cygwin/environ.h +++ /dev/null @@ -1,49 +0,0 @@ -/* environ.h: Declarations for environ manipulation - - Copyright 2000, 2001, 2002, 2003, 2005, 2006, 2008 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* Initialize the environment */ -void environ_init (char **, int) - __attribute__ ((regparm (2))); - -/* The structure below is used to control conversion to/from posix-style - file specs. Currently, only PATH and HOME are converted, but PATH - needs to use a "convert path list" function while HOME needs a simple - "convert to posix/win32". */ -struct win_env - { - const char *name; - size_t namelen; - char *posix; - char *native; - ssize_t (*toposix) (const void *, void *, size_t); - ssize_t (*towin32) (const void *, void *, size_t); - bool immediate; - void add_cache (const char *in_posix, const char *in_native = NULL) - __attribute__ ((regparm (3))); - const char * get_native () const {return native ? native + namelen : NULL;} - const char * get_posix () const {return posix ? posix : NULL;} - struct win_env& operator = (struct win_env& x); - void reset () {native = posix = NULL;} - ~win_env (); - }; - -win_env * __stdcall getwinenv (const char *name, const char *posix = NULL, win_env * = NULL) - __attribute__ ((regparm (3))); -char * __stdcall getwinenveq (const char *name, size_t len, int) - __attribute__ ((regparm (3))); - -void __stdcall update_envptrs (); -extern "C" char **__cygwin_environ, ***main_environ; -extern "C" char __stdcall **cur_environ (); -char ** __stdcall build_env (const char * const *envp, PWCHAR &envblock, - int &envc, bool need_envblock) - __attribute__ ((regparm (3))); - -#define ENV_CVT -1 diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc deleted file mode 100644 index 617970a72..000000000 --- a/winsup/cygwin/errno.cc +++ /dev/null @@ -1,365 +0,0 @@ -/* errno.cc: errno-related functions - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2008, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#define _sys_nerr FOO_sys_nerr -#define sys_nerr FOOsys_nerr -#define _sys_errlist FOO_sys_errlist -#include "winsup.h" -#include "cygtls.h" -#undef _sys_nerr -#undef sys_nerr -#undef _sys_errlist - -/* Table to map Windows error codes to Errno values. */ -/* FIXME: Doing things this way is a little slow. It's trivial to change - this into a big case statement if necessary. Left as is for now. */ - -#define X(w, e) {ERROR_##w, #w, e} - -static NO_COPY struct -{ - DWORD w; /* windows version of error */ - const char *s; /* text of windows version */ - int e; /* errno version of error */ -} errmap[] = -{ - /* FIXME: Some of these choices are arbitrary! */ - X (ACCESS_DENIED, EACCES), - X (ACTIVE_CONNECTIONS, EAGAIN), - X (ALREADY_EXISTS, EEXIST), - X (BAD_DEVICE, ENODEV), - X (BAD_NETPATH, ENOENT), - X (BAD_NET_NAME, ENOENT), - X (BAD_PATHNAME, ENOENT), - X (BAD_PIPE, EINVAL), - X (BAD_UNIT, ENODEV), - X (BAD_USERNAME, EINVAL), - X (BEGINNING_OF_MEDIA, EIO), - X (BROKEN_PIPE, EPIPE), - X (BUSY, EBUSY), - X (BUS_RESET, EIO), - X (CALL_NOT_IMPLEMENTED, ENOSYS), - X (CANNOT_MAKE, EPERM), - X (CHILD_NOT_COMPLETE, EBUSY), - X (COMMITMENT_LIMIT, EAGAIN), - X (CRC, EIO), - X (DEVICE_DOOR_OPEN, EIO), - X (DEVICE_IN_USE, EAGAIN), - X (DEVICE_REQUIRES_CLEANING, EIO), - X (DIRECTORY, ENOTDIR), - X (DIR_NOT_EMPTY, ENOTEMPTY), - X (DISK_CORRUPT, EIO), - X (DISK_FULL, ENOSPC), - X (DUP_NAME, ENOTUNIQ), - X (EAS_DIDNT_FIT, ENOSPC), - X (EAS_NOT_SUPPORTED, ENOTSUP), - X (EA_LIST_INCONSISTENT, EINVAL), - X (EA_TABLE_FULL, ENOSPC), - X (END_OF_MEDIA, ENOSPC), - X (EOM_OVERFLOW, EIO), - X (FILEMARK_DETECTED, EIO), - X (FILENAME_EXCED_RANGE, ENAMETOOLONG), - X (FILE_CORRUPT, EEXIST), - X (FILE_EXISTS, EEXIST), - X (FILE_INVALID, ENXIO), - X (FILE_NOT_FOUND, ENOENT), - X (HANDLE_DISK_FULL, ENOSPC), - X (HANDLE_EOF, ENODATA), - X (INVALID_ADDRESS, EINVAL), - X (INVALID_AT_INTERRUPT_TIME, EINTR), - X (INVALID_BLOCK_LENGTH, EIO), - X (INVALID_DATA, EINVAL), - X (INVALID_DRIVE, ENODEV), - X (INVALID_EA_NAME, EINVAL), - X (INVALID_FUNCTION, EBADRQC), - X (INVALID_HANDLE, EBADF), - X (INVALID_NAME, ENOENT), - X (INVALID_PARAMETER, EINVAL), - X (INVALID_SIGNAL_NUMBER, EINVAL), - X (IO_DEVICE, EIO), - X (IO_PENDING, EAGAIN), - X (LOCK_VIOLATION, EACCES), - X (MAX_THRDS_REACHED, EAGAIN), - X (META_EXPANSION_TOO_LONG, EINVAL), - X (MOD_NOT_FOUND, ENOENT), - X (MORE_DATA, EMSGSIZE), - X (NEGATIVE_SEEK, EINVAL), - X (NETNAME_DELETED, ENOENT), - X (NOACCESS, EFAULT), - X (NONPAGED_SYSTEM_RESOURCES, EAGAIN), - X (NONE_MAPPED, EINVAL), - X (NOT_CONNECTED, ENOLINK), - X (NOT_ENOUGH_MEMORY, ENOMEM), - X (NOT_OWNER, EPERM), - X (NOT_READY, ENOMEDIUM), - X (NOT_SAME_DEVICE, EXDEV), - X (NOT_SUPPORTED, ENOSYS), - X (NO_DATA, EPIPE), - X (NO_DATA_DETECTED, EIO), - X (NO_MEDIA_IN_DRIVE, ENOMEDIUM), - X (NO_MORE_FILES, ENMFILE), - X (NO_MORE_ITEMS, ENMFILE), - X (NO_MORE_SEARCH_HANDLES, ENFILE), - X (NO_PROC_SLOTS, EAGAIN), - X (NO_SIGNAL_SENT, EIO), - X (NO_SYSTEM_RESOURCES, EAGAIN), - X (NO_TOKEN, EINVAL), - X (OPEN_FAILED, EIO), - X (OPEN_FILES, EAGAIN), - X (OUTOFMEMORY, ENOMEM), - X (PAGED_SYSTEM_RESOURCES, EAGAIN), - X (PAGEFILE_QUOTA, EAGAIN), - X (PATH_NOT_FOUND, ENOENT), - X (PIPE_BUSY, EBUSY), - X (PIPE_CONNECTED, EBUSY), - X (PIPE_LISTENING, ECOMM), - X (PIPE_NOT_CONNECTED, ECOMM), - X (POSSIBLE_DEADLOCK, EDEADLOCK), - X (PROCESS_ABORTED, EFAULT), - X (PROC_NOT_FOUND, ESRCH), - X (REM_NOT_LIST, ENONET), - X (SETMARK_DETECTED, EIO), - X (SHARING_BUFFER_EXCEEDED, ENOLCK), - X (SHARING_VIOLATION, EBUSY), - X (SIGNAL_PENDING, EBUSY), - X (SIGNAL_REFUSED, EIO), - X (THREAD_1_INACTIVE, EINVAL), - X (TOO_MANY_LINKS, EMLINK), - X (TOO_MANY_OPEN_FILES, EMFILE), - X (WAIT_NO_CHILDREN, ECHILD), - X (WORKING_SET_QUOTA, EAGAIN), - X (WRITE_PROTECT, EROFS), - X (SEEK, EINVAL), - X (SECTOR_NOT_FOUND, EINVAL), - X (IO_INCOMPLETE, EAGAIN), - { 0, NULL, 0} -}; - -extern "C" { -const char *_sys_errlist[] NO_COPY_INIT = -{ -/* NOERROR 0 */ "No error", -/* EPERM 1 */ "Operation not permitted", -/* ENOENT 2 */ "No such file or directory", -/* ESRCH 3 */ "No such process", -/* EINTR 4 */ "Interrupted system call", -/* EIO 5 */ "Input/Output error", -/* ENXIO 6 */ "No such device or address", -/* E2BIG 7 */ "Argument list too long", -/* ENOEXEC 8 */ "Exec format error", -/* EBADF 9 */ "Bad file descriptor", -/* ECHILD 10 */ "No child processes", -/* EAGAIN 11 */ "Resource temporarily unavailable", -/* ENOMEM 12 */ "Cannot allocate memory", -/* EACCES 13 */ "Permission denied", -/* EFAULT 14 */ "Bad address", -/* ENOTBLK 15 */ "Block device required", -/* EBUSY 16 */ "Device or resource busy", -/* EEXIST 17 */ "File exists", -/* EXDEV 18 */ "Invalid cross-device link", -/* ENODEV 19 */ "No such device", -/* ENOTDIR 20 */ "Not a directory", -/* EISDIR 21 */ "Is a directory", -/* EINVAL 22 */ "Invalid argument", -/* ENFILE 23 */ "Too many open files in system", -/* EMFILE 24 */ "Too many open files", -/* ENOTTY 25 */ "Inappropriate ioctl for device", -/* ETXTBSY 26 */ "Text file busy", -/* EFBIG 27 */ "File too large", -/* ENOSPC 28 */ "No space left on device", -/* ESPIPE 29 */ "Illegal seek", -/* EROFS 30 */ "Read-only file system", -/* EMLINK 31 */ "Too many links", -/* EPIPE 32 */ "Broken pipe", -/* EDOM 33 */ "Numerical argument out of domain", -/* ERANGE 34 */ "Numerical result out of range", -/* ENOMSG 35 */ "No message of desired type", -/* EIDRM 36 */ "Identifier removed", -/* ECHRNG 37 */ "Channel number out of range", -/* EL2NSYNC 38 */ "Level 2 not synchronized", -/* EL3HLT 39 */ "Level 3 halted", -/* EL3RST 40 */ "Level 3 reset", -/* ELNRNG 41 */ "Link number out of range", -/* EUNATCH 42 */ "Protocol driver not attached", -/* ENOCSI 43 */ "No CSI structure available", -/* EL2HLT 44 */ "Level 2 halted", -/* EDEADLK 45 */ "Resource deadlock avoided", -/* ENOLCK 46 */ "No locks available", - "error 47", - "error 48", - "error 49", -/* EBADE 50 */ "Invalid exchange", -/* EBADR 51 */ "Invalid request descriptor", -/* EXFULL 52 */ "Exchange full", -/* ENOANO 53 */ "No anode", -/* EBADRQC 54 */ "Invalid request code", -/* EBADSLT 55 */ "Invalid slot", -/* EDEADLOCK 56 */ "File locking deadlock error", -/* EBFONT 57 */ "Bad font file format", - "error 58", - "error 59", -/* ENOSTR 60 */ "Device not a stream", -/* ENODATA 61 */ "No data available", -/* ETIME 62 */ "Timer expired", -/* ENOSR 63 */ "Out of streams resources", -/* ENONET 64 */ "Machine is not on the network", -/* ENOPKG 65 */ "Package not installed", -/* EREMOTE 66 */ "Object is remote", -/* ENOLINK 67 */ "Link has been severed", -/* EADV 68 */ "Advertise error", -/* ESRMNT 69 */ "Srmount error", -/* ECOMM 70 */ "Communication error on send", -/* EPROTO 71 */ "Protocol error", - "error 72", - "error 73", -/* EMULTIHOP 74 */ "Multihop attempted", -/* ELBIN 75 */ "Inode is remote (not really error)", -/* EDOTDOT 76 */ "RFS specific error", -/* EBADMSG 77 */ "Bad message", - "error 78", -/* EFTYPE 79 */ "Inappropriate file type or format", -/* ENOTUNIQ 80 */ "Name not unique on network", -/* EBADFD 81 */ "File descriptor in bad state", -/* EREMCHG 82 */ "Remote address changed", -/* ELIBACC 83 */ "Can not access a needed shared library", -/* ELIBBAD 84 */ "Accessing a corrupted shared library", -/* ELIBSCN 85 */ ".lib section in a.out corrupted", -/* ELIBMAX 86 */ "Attempting to link in too many shared libraries", -/* ELIBEXEC 87 */ "Cannot exec a shared library directly", -/* ENOSYS 88 */ "Function not implemented", -/* ENMFILE 89 */ "No more files", -/* ENOTEMPTY 90 */ "Directory not empty", -/* ENAMETOOLONG 91 */ "File name too long", -/* ELOOP 92 */ "Too many levels of symbolic links", - "error 93", - "error 94", -/* EOPNOTSUPP 95 */ "Operation not supported", -/* EPFNOSUPPORT 96 */ "Protocol family not supported", - "error 97", - "error 98", - "error 99", - "error 100", - "error 101", - "error 102", - "error 103", -/* ECONNRESET 104 */ "Connection reset by peer", -/* ENOBUFS 105 */ "No buffer space available", -/* EAFNOSUPPORT 106 */ "Address family not supported by protocol", -/* EPROTOTYPE 107 */ "Protocol wrong type for socket", -/* ENOTSOCK 108 */ "Socket operation on non-socket", -/* ENOPROTOOPT 109 */ "Protocol not available", -/* ESHUTDOWN 110 */ "Cannot send after transport endpoint shutdown", -/* ECONNREFUSED 111 */ "Connection refused", -/* EADDRINUSE 112 */ "Address already in use", -/* ECONNABORTED 113 */ "Software caused connection abort", -/* ENETUNREACH 114 */ "Network is unreachable", -/* ENETDOWN 115 */ "Network is down", -/* ETIMEDOUT 116 */ "Connection timed out", -/* EHOSTDOWN 117 */ "Host is down", -/* EHOSTUNREACH 118 */ "No route to host", -/* EINPROGRESS 119 */ "Operation now in progress", -/* EALREADY 120 */ "Operation already in progress", -/* EDESTADDRREQ 121 */ "Destination address required", -/* EMSGSIZE 122 */ "Message too long", -/* EPROTONOSUPPORT 123 */ "Protocol not supported", -/* ESOCKTNOSUPPORT 124 */ "Socket type not supported", -/* EADDRNOTAVAIL 125 */ "Cannot assign requested address", -/* ENETRESET 126 */ "Network dropped connection on reset", -/* EISCONN 127 */ "Transport endpoint is already connected", -/* ENOTCONN 128 */ "Transport endpoint is not connected", -/* ETOOMANYREFS 129 */ "Too many references: cannot splice", -/* EPROCLIM 130 */ "Too many processes", -/* EUSERS 131 */ "Too many users", -/* EDQUOT 132 */ "Disk quota exceeded", -/* ESTALE 133 */ "Stale NFS file handle", -/* ENOTSUP 134 */ "Not supported", -/* ENOMEDIUM 135 */ "No medium found", -/* ENOSHARE 136 */ "No such host or network path", -/* ECASECLASH 137 */ "Filename exists with different case", -/* EILSEQ 138 */ "Invalid or incomplete multibyte or wide character", -/* EOVERFLOW 139 */ "Value too large for defined data type", -/* ECANCELED 140 */ "Operation canceled", -/* ENOTRECOVERABLE 141 */ "State not recoverable", -/* EOWNERDEAD 142 */ "Previous owner died", -/* ESTRPIPE 143 */ "Streams pipe error" -}; - -int NO_COPY_INIT _sys_nerr = sizeof (_sys_errlist) / sizeof (_sys_errlist[0]); -}; - -int __stdcall -geterrno_from_win_error (DWORD code, int deferrno) -{ - for (int i = 0; errmap[i].w != 0; ++i) - if (code == errmap[i].w) - { - syscall_printf ("windows error %u == errno %d", code, errmap[i].e); - return errmap[i].e; - } - - syscall_printf ("unknown windows error %u, setting errno to %d", code, - deferrno); - return deferrno; /* FIXME: what's so special about EACCESS? */ -} - -/* seterrno_from_win_error: Given a Windows error code, set errno - as appropriate. */ -void __stdcall -seterrno_from_win_error (const char *file, int line, DWORD code) -{ - syscall_printf ("%s:%d windows error %d", file, line, code); - set_errno (geterrno_from_win_error (code, EACCES)); -} - -/* seterrno: Set `errno' based on GetLastError (). */ -void __stdcall -seterrno (const char *file, int line) -{ - seterrno_from_win_error (file, line, GetLastError ()); -} - -extern char *_user_strerror _PARAMS ((int)); - -static char * -strerror_worker (int errnum) -{ - char *res; - if (errnum >= 0 && errnum < _sys_nerr) - res = (char *) _sys_errlist [errnum]; - else - res = NULL; - return res; -} - -/* strerror: convert from errno values to error strings */ -extern "C" char * -strerror (int errnum) -{ - char *errstr = strerror_worker (errnum); - if (!errstr) - __small_sprintf (errstr = _my_tls.locals.strerror_buf, "Unknown error %u", - (unsigned) errnum); - return errstr; -} - -#if 0 -extern "C" int -strerror_r (int errnum, char *buf, size_t n) -{ - char *errstr = strerror_worker (errnum); - if (!errstr) - return EINVAL; - if (strlen (errstr) >= n) - return ERANGE; - strcpy (buf, errstr); - return 0; -} -#endif diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc deleted file mode 100644 index e1bb7056c..000000000 --- a/winsup/cygwin/exceptions.cc +++ /dev/null @@ -1,1435 +0,0 @@ -/* exceptions.cc - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#define CYGTLS_HANDLE -#include "winsup.h" -#include "miscfuncs.h" -#include -#include -#include -#include -#include -#include - -#include "pinfo.h" -#include "cygtls.h" -#include "sigproc.h" -#include "shared_info.h" -#include "perprocess.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "child_info.h" -#include "ntdll.h" - -#define CALL_HANDLER_RETRY 20 - -char debugger_command[2 * NT_MAX_PATH + 20]; - -extern "C" { -extern void sigdelayed (); -}; - -extern child_info_spawn *chExeced; - -static BOOL WINAPI ctrl_c_handler (DWORD); -static WCHAR windows_system_directory[1024]; -static size_t windows_system_directory_length; - -/* This is set to indicate that we have already exited. */ - -static NO_COPY int exit_already = 0; -static muto NO_COPY mask_sync; - -NO_COPY static struct -{ - unsigned int code; - const char *name; -} status_info[] = -{ -#define X(s) s, #s - { X (STATUS_ABANDONED_WAIT_0) }, - { X (STATUS_ACCESS_VIOLATION) }, - { X (STATUS_ARRAY_BOUNDS_EXCEEDED) }, - { X (STATUS_BREAKPOINT) }, - { X (STATUS_CONTROL_C_EXIT) }, - { X (STATUS_DATATYPE_MISALIGNMENT) }, - { X (STATUS_FLOAT_DENORMAL_OPERAND) }, - { X (STATUS_FLOAT_DIVIDE_BY_ZERO) }, - { X (STATUS_FLOAT_INEXACT_RESULT) }, - { X (STATUS_FLOAT_INVALID_OPERATION) }, - { X (STATUS_FLOAT_OVERFLOW) }, - { X (STATUS_FLOAT_STACK_CHECK) }, - { X (STATUS_FLOAT_UNDERFLOW) }, - { X (STATUS_GUARD_PAGE_VIOLATION) }, - { X (STATUS_ILLEGAL_INSTRUCTION) }, - { X (STATUS_INTEGER_DIVIDE_BY_ZERO) }, - { X (STATUS_INTEGER_OVERFLOW) }, - { X (STATUS_INVALID_DISPOSITION) }, - { X (STATUS_IN_PAGE_ERROR) }, - { X (STATUS_NONCONTINUABLE_EXCEPTION) }, - { X (STATUS_NO_MEMORY) }, - { X (STATUS_PENDING) }, - { X (STATUS_PRIVILEGED_INSTRUCTION) }, - { X (STATUS_SINGLE_STEP) }, - { X (STATUS_STACK_OVERFLOW) }, - { X (STATUS_TIMEOUT) }, - { X (STATUS_USER_APC) }, - { X (STATUS_WAIT_0) }, - { 0, 0 } -#undef X -}; - -/* Initialization code. */ - -void -init_console_handler (bool install_handler) -{ - BOOL res; - - SetConsoleCtrlHandler (ctrl_c_handler, FALSE); - SetConsoleCtrlHandler (NULL, FALSE); - if (install_handler) - res = SetConsoleCtrlHandler (ctrl_c_handler, TRUE); - else - res = SetConsoleCtrlHandler (NULL, TRUE); - if (!res) - system_printf ("SetConsoleCtrlHandler failed, %E"); -} - -extern "C" void -error_start_init (const char *buf) -{ - if (!buf || !*buf) - { - debugger_command[0] = '\0'; - return; - } - - char pgm[NT_MAX_PATH]; - if (!GetModuleFileName (NULL, pgm, NT_MAX_PATH)) - strcpy (pgm, "cygwin1.dll"); - for (char *p = strchr (pgm, '\\'); p; p = strchr (p, '\\')) - *p = '/'; - - __small_sprintf (debugger_command, "%s \"%s\"", buf, pgm); -} - -static void -open_stackdumpfile () -{ - if (myself->progname[0]) - { - const char *p; - /* write to progname.stackdump if possible */ - if (!myself->progname[0]) - p = "unknown"; - else if ((p = strrchr (myself->progname, '\\'))) - p++; - else - p = myself->progname; - - WCHAR corefile[strlen (p) + sizeof (".stackdump")]; - UNICODE_STRING ucore; - OBJECT_ATTRIBUTES attr; - /* Create the UNICODE variation of .stackdump. */ - RtlInitEmptyUnicodeString (&ucore, corefile, - sizeof corefile - sizeof (WCHAR)); - ucore.Length = sys_mbstowcs (ucore.Buffer, - ucore.MaximumLength / sizeof (WCHAR), - p, strlen (p)) * sizeof (WCHAR); - RtlAppendUnicodeToString (&ucore, L".stackdump"); - /* Create an object attribute which refers to .stackdump - in Cygwin's cwd. Stick to caseinsensitivity. */ - InitializeObjectAttributes (&attr, &ucore, OBJ_CASE_INSENSITIVE, - cygheap->cwd.get_handle (), NULL); - HANDLE h; - IO_STATUS_BLOCK io; - NTSTATUS status; - /* Try to open it to dump the stack in it. */ - status = NtCreateFile (&h, GENERIC_WRITE | SYNCHRONIZE, &attr, &io, - NULL, FILE_ATTRIBUTE_NORMAL, 0, FILE_OVERWRITE_IF, - FILE_SYNCHRONOUS_IO_NONALERT - | FILE_OPEN_FOR_BACKUP_INTENT, NULL, 0); - if (NT_SUCCESS (status)) - { - if (!myself->cygstarted) - system_printf ("Dumping stack trace to %S", &ucore); - else - debug_printf ("Dumping stack trace to %S", &ucore); - SetStdHandle (STD_ERROR_HANDLE, h); - } - } -} - -/* Utilities for dumping the stack, etc. */ - -static void -exception (EXCEPTION_RECORD *e, CONTEXT *in) -{ - const char *exception_name = NULL; - - if (e) - { - for (int i = 0; status_info[i].name; i++) - { - if (status_info[i].code == e->ExceptionCode) - { - exception_name = status_info[i].name; - break; - } - } - } - - if (exception_name) - small_printf ("Exception: %s at eip=%08x\r\n", exception_name, in->Eip); - else - small_printf ("Signal %d at eip=%08x\r\n", e->ExceptionCode, in->Eip); - small_printf ("eax=%08x ebx=%08x ecx=%08x edx=%08x esi=%08x edi=%08x\r\n", - in->Eax, in->Ebx, in->Ecx, in->Edx, in->Esi, in->Edi); - small_printf ("ebp=%08x esp=%08x program=%s, pid %u, thread %s\r\n", - in->Ebp, in->Esp, myself->progname, myself->pid, cygthread::name ()); - small_printf ("cs=%04x ds=%04x es=%04x fs=%04x gs=%04x ss=%04x\r\n", - in->SegCs, in->SegDs, in->SegEs, in->SegFs, in->SegGs, in->SegSs); -} - -/* A class for manipulating the stack. */ -class stack_info -{ - int walk (); /* Uses the "old" method */ - char *next_offset () {return *((char **) sf.AddrFrame.Offset);} - bool needargs; - DWORD dummy_frame; -public: - STACKFRAME sf; /* For storing the stack information */ - void init (DWORD, bool, bool); /* Called the first time that stack info is needed */ - - /* Postfix ++ iterates over the stack, returning zero when nothing is left. */ - int operator ++(int) { return walk (); } -}; - -/* The number of parameters used in STACKFRAME */ -#define NPARAMS (sizeof (thestack.sf.Params) / sizeof (thestack.sf.Params[0])) - -/* This is the main stack frame info for this process. */ -static NO_COPY stack_info thestack; - -/* Initialize everything needed to start iterating. */ -void -stack_info::init (DWORD ebp, bool wantargs, bool goodframe) -{ -# define debp ((DWORD *) ebp) - memset (&sf, 0, sizeof (sf)); - if (!goodframe) - sf.AddrFrame.Offset = ebp; - else - { - dummy_frame = ebp; - sf.AddrFrame.Offset = (DWORD) &dummy_frame; - } - sf.AddrReturn.Offset = debp[1]; - sf.AddrFrame.Mode = AddrModeFlat; - needargs = wantargs; -# undef debp -} - -extern "C" void _cygwin_exit_return (); - -/* Walk the stack by looking at successive stored 'bp' frames. - This is not foolproof. */ -int -stack_info::walk () -{ - char **ebp; - - if ((void (*) ()) sf.AddrPC.Offset == _cygwin_exit_return) - return 0; /* stack frames are exhausted */ - - if (((ebp = (char **) next_offset ()) == NULL) || (ebp >= (char **) cygwin_hmodule)) - return 0; - - sf.AddrFrame.Offset = (DWORD) ebp; - sf.AddrPC.Offset = sf.AddrReturn.Offset; - - /* The return address always follows the stack pointer */ - sf.AddrReturn.Offset = (DWORD) *++ebp; - - if (needargs) - { - unsigned nparams = NPARAMS; - - /* The arguments follow the return address */ - sf.Params[0] = (DWORD) *++ebp; - /* Hack for XP/2K3 WOW64. If the first stack param points to the - application entry point, we can only fetch one additional - parameter. Accessing anything beyond this address results in - a SEGV. This is fixed in Vista/2K8 WOW64. */ - if (wincap.has_restricted_stack_args () && sf.Params[0] == 0x401000) - nparams = 2; - for (unsigned i = 1; i < nparams; i++) - sf.Params[i] = (DWORD) *++ebp; - } - - return 1; -} - -static void -stackdump (DWORD ebp, int open_file, bool isexception) -{ - extern unsigned long rlim_core; - static bool already_dumped; - - if (rlim_core == 0UL || (open_file && already_dumped)) - return; - - if (open_file) - open_stackdumpfile (); - - already_dumped = true; - - int i; - - thestack.init (ebp, 1, !isexception); /* Initialize from the input CONTEXT */ - small_printf ("Stack trace:\r\nFrame Function Args\r\n"); - for (i = 0; i < 16 && thestack++; i++) - { - small_printf ("%08x %08x ", thestack.sf.AddrFrame.Offset, - thestack.sf.AddrPC.Offset); - for (unsigned j = 0; j < NPARAMS; j++) - small_printf ("%s%08x", j == 0 ? " (" : ", ", thestack.sf.Params[j]); - small_printf (")\r\n"); - } - small_printf ("End of stack trace%s\n", - i == 16 ? " (more stack frames may be present)" : ""); -} - -bool -_cygtls::inside_kernel (CONTEXT *cx) -{ - int res; - MEMORY_BASIC_INFORMATION m; - - if (!isinitialized ()) - return true; - - memset (&m, 0, sizeof m); - if (!VirtualQuery ((LPCVOID) cx->Eip, &m, sizeof m)) - sigproc_printf ("couldn't get memory info, pc %p, %E", cx->Eip); - - size_t size = (windows_system_directory_length + 6) * sizeof (WCHAR); - PWCHAR checkdir = (PWCHAR) alloca (size); - memset (checkdir, 0, size); - -# define h ((HMODULE) m.AllocationBase) - /* Apparently Windows 95 can sometimes return bogus addresses from - GetThreadContext. These resolve to a strange allocation base. - These should *never* be treated as interruptible. */ - if (!h || m.State != MEM_COMMIT) - res = true; - else if (h == user_data->hmodule) - res = false; - else if (!GetModuleFileNameW (h, checkdir, windows_system_directory_length + 6)) - res = false; - else - { - /* Skip potential long path prefix. */ - if (!wcsncmp (checkdir, L"\\\\?\\", 4)) - checkdir += 4; - res = !wcsncasecmp (windows_system_directory, checkdir, - windows_system_directory_length); - } - sigproc_printf ("pc %p, h %p, inside_kernel %d", cx->Eip, h, res); -# undef h - return res; -} - -/* Temporary (?) function for external callers to get a stack dump */ -extern "C" void -cygwin_stackdump () -{ - CONTEXT c; - c.ContextFlags = CONTEXT_FULL; - GetThreadContext (GetCurrentThread (), &c); - stackdump (c.Ebp, 0, 0); -} - -#define TIME_TO_WAIT_FOR_DEBUGGER 10000 - -extern "C" int -try_to_debug (bool waitloop) -{ - debug_printf ("debugger_command '%s'", debugger_command); - if (*debugger_command == '\0') - return 0; - if (being_debugged ()) - { - extern void break_here (); - break_here (); - return 0; - } - - __small_sprintf (strchr (debugger_command, '\0'), " %u", GetCurrentProcessId ()); - - LONG prio = GetThreadPriority (GetCurrentThread ()); - SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_HIGHEST); - PROCESS_INFORMATION pi = {NULL, 0, 0, 0}; - - STARTUPINFOW si = {0, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL}; - si.lpReserved = NULL; - si.lpDesktop = NULL; - si.dwFlags = 0; - si.cb = sizeof (si); - - /* FIXME: need to know handles of all running threads to - suspend_all_threads_except (current_thread_id); - */ - - /* if any of these mutexes is owned, we will fail to start any cygwin app - until trapped app exits */ - - lock_ttys::release (); - - /* prevent recursive exception handling */ - PWCHAR rawenv = GetEnvironmentStringsW () ; - for (PWCHAR p = rawenv; *p != L'\0'; p = wcschr (p, L'\0') + 1) - { - if (wcsncmp (p, L"CYGWIN=", wcslen (L"CYGWIN=")) == 0) - { - PWCHAR q = wcsstr (p, L"error_start") ; - /* replace 'error_start=...' with '_rror_start=...' */ - if (q) - { - *q = L'_' ; - SetEnvironmentVariableW (L"CYGWIN", p + wcslen (L"CYGWIN=")) ; - } - break ; - } - } - - console_printf ("*** starting debugger for pid %u, tid %u\n", - cygwin_pid (GetCurrentProcessId ()), GetCurrentThreadId ()); - BOOL dbg; - WCHAR dbg_cmd[strlen(debugger_command)]; - sys_mbstowcs (dbg_cmd, strlen(debugger_command) + 1, debugger_command); - dbg = CreateProcessW (NULL, - dbg_cmd, - NULL, - NULL, - FALSE, - CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP, - NULL, - NULL, - &si, - &pi); - - if (!dbg) - system_printf ("Failed to start debugger, %E"); - else - { - if (!waitloop) - return dbg; - SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_IDLE); - while (!being_debugged ()) - low_priority_sleep (0); - Sleep (2000); - } - - console_printf ("*** continuing pid %u from debugger call (%d)\n", - cygwin_pid (GetCurrentProcessId ()), dbg); - - SetThreadPriority (GetCurrentThread (), prio); - return dbg; -} - -extern "C" DWORD __stdcall RtlUnwind (void *, void *, void *, DWORD); -static void __stdcall rtl_unwind (exception_list *, PEXCEPTION_RECORD) __attribute__ ((noinline, regparm (3))); -void __stdcall -rtl_unwind (exception_list *frame, PEXCEPTION_RECORD e) -{ - __asm__ ("\n\ - pushl %%ebx \n\ - pushl %%edi \n\ - pushl %%esi \n\ - pushl $0 \n\ - pushl %1 \n\ - pushl $1f \n\ - pushl %0 \n\ - call _RtlUnwind@16 \n\ -1: \n\ - popl %%esi \n\ - popl %%edi \n\ - popl %%ebx \n\ -": : "r" (frame), "r" (e)); -} - -/* Main exception handler. */ - -extern exception_list *_except_list asm ("%fs:0"); - -int -_cygtls::handle_exceptions (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT *in, void *) -{ - static bool NO_COPY debugging; - static int NO_COPY recursed; - _cygtls& me = _my_tls; - - if (debugging && ++debugging < 500000) - { - SetThreadPriority (hMainThread, THREAD_PRIORITY_NORMAL); - return 0; - } - - /* If we've already exited, don't do anything here. Returning 1 - tells Windows to keep looking for an exception handler. */ - if (exit_already || e->ExceptionFlags) - return 1; - - siginfo_t si = {0}; - si.si_code = SI_KERNEL; - /* Coerce win32 value to posix value. */ - switch (e->ExceptionCode) - { - case STATUS_FLOAT_DENORMAL_OPERAND: - case STATUS_FLOAT_DIVIDE_BY_ZERO: - case STATUS_FLOAT_INVALID_OPERATION: - case STATUS_FLOAT_STACK_CHECK: - si.si_signo = SIGFPE; - si.si_code = FPE_FLTSUB; - break; - case STATUS_FLOAT_INEXACT_RESULT: - si.si_signo = SIGFPE; - si.si_code = FPE_FLTRES; - break; - case STATUS_FLOAT_OVERFLOW: - si.si_signo = SIGFPE; - si.si_code = FPE_FLTOVF; - break; - case STATUS_FLOAT_UNDERFLOW: - si.si_signo = SIGFPE; - si.si_code = FPE_FLTUND; - break; - case STATUS_INTEGER_DIVIDE_BY_ZERO: - si.si_signo = SIGFPE; - si.si_code = FPE_INTDIV; - break; - case STATUS_INTEGER_OVERFLOW: - si.si_signo = SIGFPE; - si.si_code = FPE_INTOVF; - break; - - case STATUS_ILLEGAL_INSTRUCTION: - si.si_signo = SIGILL; - si.si_code = ILL_ILLOPC; - break; - - case STATUS_PRIVILEGED_INSTRUCTION: - si.si_signo = SIGILL; - si.si_code = ILL_PRVOPC; - break; - - case STATUS_NONCONTINUABLE_EXCEPTION: - si.si_signo = SIGILL; - si.si_code = ILL_ILLADR; - break; - - case STATUS_TIMEOUT: - si.si_signo = SIGALRM; - break; - - case STATUS_GUARD_PAGE_VIOLATION: - si.si_signo = SIGBUS; - si.si_code = BUS_OBJERR; - break; - - case STATUS_DATATYPE_MISALIGNMENT: - si.si_signo = SIGBUS; - si.si_code = BUS_ADRALN; - break; - - case STATUS_ACCESS_VIOLATION: - switch (mmap_is_attached_or_noreserve ((void *)e->ExceptionInformation[1], - 1)) - { - case MMAP_NORESERVE_COMMITED: - return 0; - case MMAP_RAISE_SIGBUS: /* MAP_NORESERVE page, commit failed, or - access to mmap page beyond EOF. */ - si.si_signo = SIGBUS; - si.si_code = BUS_OBJERR; - break; - default: - MEMORY_BASIC_INFORMATION m; - VirtualQuery ((PVOID) e->ExceptionInformation[1], &m, sizeof m); - si.si_signo = SIGSEGV; - si.si_code = m.State == MEM_FREE ? SEGV_MAPERR : SEGV_ACCERR; - break; - } - break; - - case STATUS_ARRAY_BOUNDS_EXCEEDED: - case STATUS_IN_PAGE_ERROR: - case STATUS_NO_MEMORY: - case STATUS_INVALID_DISPOSITION: - case STATUS_STACK_OVERFLOW: - si.si_signo = SIGSEGV; - si.si_code = SEGV_MAPERR; - break; - - case STATUS_CONTROL_C_EXIT: - si.si_signo = SIGINT; - break; - - case STATUS_INVALID_HANDLE: - /* CloseHandle will throw this exception if it is given an - invalid handle. We don't care about the exception; we just - want CloseHandle to return an error. This can be revisited - if gcc ever supports Windows style structured exception - handling. */ - return 0; - - default: - /* If we don't recognize the exception, we have to assume that - we are doing structured exception handling, and we let - something else handle it. */ - return 1; - } - - debug_printf ("In cygwin_except_handler exc %p at %p sp %p", e->ExceptionCode, in->Eip, in->Esp); - debug_printf ("In cygwin_except_handler sig %d at %p", si.si_signo, in->Eip); - - bool masked = !!(me.sigmask & SIGTOMASK (si.si_signo)); - if (masked) - syscall_printf ("signal %d, masked %p", si.si_signo, - global_sigs[si.si_signo].sa_mask); - - debug_printf ("In cygwin_except_handler calling %p", - global_sigs[si.si_signo].sa_handler); - - DWORD *ebp = (DWORD *) in->Esp; - for (DWORD *bpend = (DWORD *) __builtin_frame_address (0); ebp > bpend; ebp--) - if (*ebp == in->SegCs && ebp[-1] == in->Eip) - { - ebp -= 2; - break; - } - - if (me.fault_guarded ()) - me.return_from_fault (); - - me.copy_context (in); - - /* Temporarily replace windows top level SEH with our own handler. - We don't want any Windows magic kicking in. This top level frame - will be removed automatically after our exception handler returns. */ - _except_list->handler = _cygtls::handle_exceptions; - - if (masked - || &me == _sig_tls - || !cygwin_finished_initializing - || (void *) global_sigs[si.si_signo].sa_handler == (void *) SIG_DFL - || (void *) global_sigs[si.si_signo].sa_handler == (void *) SIG_IGN - || (void *) global_sigs[si.si_signo].sa_handler == (void *) SIG_ERR) - { - /* Print the exception to the console */ - if (!myself->cygstarted) - for (int i = 0; status_info[i].name; i++) - if (status_info[i].code == e->ExceptionCode) - { - system_printf ("Exception: %s", status_info[i].name); - break; - } - - /* Another exception could happen while tracing or while exiting. - Only do this once. */ - if (recursed++) - system_printf ("Error while dumping state (probably corrupted stack)"); - else - { - if (try_to_debug (0)) - { - debugging = true; - return 0; - } - - rtl_unwind (frame, e); - open_stackdumpfile (); - exception (e, in); - stackdump ((DWORD) ebp, 0, 1); - } - - if (e->ExceptionCode == STATUS_ACCESS_VIOLATION) - { - int error_code = 0; - if (si.si_code == SEGV_ACCERR) /* Address present */ - error_code |= 1; - if (e->ExceptionInformation[0]) /* Write access */ - error_code |= 2; - if (!me.inside_kernel (in)) /* User space */ - error_code |= 4; - klog (LOG_INFO, "%s[%d]: segfault at %08x rip %08x rsp %08x error %d", - __progname, myself->pid, - e->ExceptionInformation[1], in->Eip, in->Esp, - ((in->Eip >= 0x61000000 && in->Eip < 0x61200000) - ? 0 : 4) | (e->ExceptionInformation[0] << 1)); - } - - me.signal_exit (0x80 | si.si_signo); // Flag signal + core dump - } - - si.si_addr = (si.si_signo == SIGSEGV || si.si_signo == SIGBUS - ? (void *) e->ExceptionInformation[1] - : (void *) in->Eip); - si.si_errno = si.si_pid = si.si_uid = 0; - me.incyg++; - sig_send (NULL, si, &me); // Signal myself - me.incyg--; - e->ExceptionFlags = 0; - return 0; -} - -/* Utilities to call a user supplied exception handler. */ - -#define SIG_NONMASKABLE (SIGTOMASK (SIGKILL) | SIGTOMASK (SIGSTOP)) - -/* Non-raceable sigsuspend - * Note: This implementation is based on the Single UNIX Specification - * man page. This indicates that sigsuspend always returns -1 and that - * attempts to block unblockable signals will be silently ignored. - * This is counter to what appears to be documented in some UNIX - * man pages, e.g. Linux. - */ -int __stdcall -handle_sigsuspend (sigset_t tempmask) -{ - if (&_my_tls != _main_tls) - { - cancelable_wait (signal_arrived, INFINITE, cw_cancel_self); - return -1; - } - - sigset_t oldmask = _my_tls.sigmask; // Remember for restoration - - set_signal_mask (tempmask, _my_tls.sigmask); - sigproc_printf ("oldmask %p, newmask %p", oldmask, tempmask); - - pthread_testcancel (); - cancelable_wait (signal_arrived, INFINITE); - - set_sig_errno (EINTR); // Per POSIX - - /* A signal dispatch function will have been added to our stack and will - be hit eventually. Set the old mask to be restored when the signal - handler returns and indicate its presence by modifying deltamask. */ - - _my_tls.deltamask |= SIG_NONMASKABLE; - _my_tls.oldmask = oldmask; // Will be restored by signal handler - return -1; -} - -extern DWORD exec_exit; // Possible exit value for exec - -extern "C" { -static void -sig_handle_tty_stop (int sig) -{ - _my_tls.incyg = 1; - /* Silently ignore attempts to suspend if there is no accommodating - cygwin parent to deal with this behavior. */ - if (!myself->cygstarted) - { - myself->process_state &= ~PID_STOPPED; - return; - } - - myself->stopsig = sig; - myself->alert_parent (sig); - sigproc_printf ("process %d stopped by signal %d", myself->pid, sig); - HANDLE w4[2]; - w4[0] = sigCONT; - w4[1] = signal_arrived; - switch (WaitForMultipleObjects (2, w4, TRUE, INFINITE)) - { - case WAIT_OBJECT_0: - case WAIT_OBJECT_0 + 1: - reset_signal_arrived (); - myself->stopsig = SIGCONT; - myself->alert_parent (SIGCONT); - break; - default: - api_fatal ("WaitSingleObject failed, %E"); - break; - } - _my_tls.incyg = 0; -} -} - -bool -_cygtls::interrupt_now (CONTEXT *cx, int sig, void *handler, - struct sigaction& siga) -{ - bool interrupted; - - if (incyg || spinning || locked () || inside_kernel (cx)) - interrupted = false; - else - { - push ((__stack_t) cx->Eip); - interrupt_setup (sig, handler, siga); - cx->Eip = pop (); - SetThreadContext (*this, cx); /* Restart the thread in a new location */ - interrupted = true; - } - return interrupted; -} - -void __stdcall -_cygtls::interrupt_setup (int sig, void *handler, struct sigaction& siga) -{ - push ((__stack_t) sigdelayed); - deltamask = siga.sa_mask & ~SIG_NONMASKABLE; - sa_flags = siga.sa_flags; - func = (void (*) (int)) handler; - if (siga.sa_flags & SA_RESETHAND) - siga.sa_handler = SIG_DFL; - saved_errno = -1; // Flag: no errno to save - if (handler == sig_handle_tty_stop) - { - myself->stopsig = 0; - myself->process_state |= PID_STOPPED; - } - - this->sig = sig; // Should always be last thing set to avoid a race - - if (!event) - threadkill = false; - else - { - HANDLE h = event; - event = NULL; - SetEvent (h); - } - - /* Clear any waiting threads prior to dispatching to handler function */ - int res = SetEvent (signal_arrived); // For an EINTR case - proc_subproc (PROC_CLEARWAIT, 1); - sigproc_printf ("armed signal_arrived %p, sig %d, res %d", signal_arrived, - sig, res); -} - -extern "C" void __stdcall -set_sig_errno (int e) -{ - *_my_tls.errno_addr = e; - _my_tls.saved_errno = e; - // sigproc_printf ("errno %d", e); -} - -static int setup_handler (int, void *, struct sigaction&, _cygtls *tls) - __attribute__((regparm(3))); -static int -setup_handler (int sig, void *handler, struct sigaction& siga, _cygtls *tls) -{ - CONTEXT cx; - bool interrupted = false; - - if (tls->sig) - { - sigproc_printf ("trying to send sig %d but signal %d already armed", - sig, tls->sig); - goto out; - } - - for (int i = 0; i < CALL_HANDLER_RETRY; i++) - { - tls->lock (); - if (tls->incyg) - { - sigproc_printf ("controlled interrupt. stackptr %p, stack %p, stackptr[-1] %p", - tls->stackptr, tls->stack, tls->stackptr[-1]); - tls->interrupt_setup (sig, handler, siga); - interrupted = true; - tls->unlock (); - break; - } - - tls->unlock (); - DWORD res; - HANDLE hth = (HANDLE) *tls; - - /* Suspend the thread which will receive the signal. - For Windows 95, we also have to ensure that the addresses returned by - GetThreadContext are valid. - If one of these conditions is not true we loop for a fixed number of times - since we don't want to stall the signal handler. FIXME: Will this result in - noticeable delays? - If the thread is already suspended (which can occur when a program has called - SuspendThread on itself) then just queue the signal. */ - -#ifndef DEBUGGING - sigproc_printf ("suspending mainthread"); -#else - cx.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER; - if (!GetThreadContext (hth, &cx)) - memset (&cx, 0, sizeof cx); - sigproc_printf ("suspending mainthread PC %p", cx.Eip); -#endif - res = SuspendThread (hth); - /* Just set pending if thread is already suspended */ - if (res) - { - ResumeThread (hth); - break; - } - cx.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER; - if (!GetThreadContext (hth, &cx)) - system_printf ("couldn't get context of main thread, %E"); - else - interrupted = tls->interrupt_now (&cx, sig, handler, siga); - - res = ResumeThread (hth); - if (interrupted) - break; - - sigproc_printf ("couldn't interrupt. trying again."); - low_priority_sleep (0); - } - -out: - sigproc_printf ("signal %d %sdelivered", sig, interrupted ? "" : "not "); - return interrupted; -} - -static inline bool -has_visible_window_station () -{ - HWINSTA station_hdl; - USEROBJECTFLAGS uof; - DWORD len; - - /* Check if the process is associated with a visible window station. - These are processes running on the local desktop as well as processes - running in terminal server sessions. - Processes running in a service session not explicitely associated - with the desktop (using the "Allow service to interact with desktop" - property) are running in an invisible window station. */ - if ((station_hdl = GetProcessWindowStation ()) - && GetUserObjectInformationW (station_hdl, UOI_FLAGS, &uof, - sizeof uof, &len) - && (uof.dwFlags & WSF_VISIBLE)) - return true; - return false; -} - -/* Keyboard interrupt handler. */ -static BOOL WINAPI -ctrl_c_handler (DWORD type) -{ - static bool saw_close; - lock_process now; - - if (!cygwin_finished_initializing) - { - if (myself->cygstarted) /* Was this process created by a cygwin process? */ - return TRUE; /* Yes. Let the parent eventually handle CTRL-C issues. */ - debug_printf ("exiting with status %p", STATUS_CONTROL_C_EXIT); - ExitProcess (STATUS_CONTROL_C_EXIT); - } - - _my_tls.remove (INFINITE); - -#if 0 - if (type == CTRL_C_EVENT || type == CTRL_BREAK_EVENT) - proc_subproc (PROC_KILLFORKED, 0); -#endif - - /* Return FALSE to prevent an "End task" dialog box from appearing - for each Cygwin process window that's open when the computer - is shut down or console window is closed. */ - - if (type == CTRL_SHUTDOWN_EVENT) - { -#if 0 - /* Don't send a signal. Only NT service applications and their child - processes will receive this event and the services typically already - handle the shutdown action when getting the SERVICE_CONTROL_SHUTDOWN - control message. */ - sig_send (NULL, SIGTERM); -#endif - return FALSE; - } - - if (myself->ctty != -1) - { - if (type == CTRL_CLOSE_EVENT) - { - sig_send (NULL, SIGHUP); - saw_close = true; - return FALSE; - } - if (!saw_close && type == CTRL_LOGOFF_EVENT) - { - /* The CTRL_LOGOFF_EVENT is sent when *any* user logs off. - The below code sends a SIGHUP only if it is not performing the - default activity for SIGHUP. Note that it is possible for two - SIGHUP signals to arrive if a process group leader is exiting - too. Getting this 100% right is saved for a future cygwin mailing - list goad. */ - if (global_sigs[SIGHUP].sa_handler != SIG_DFL) - { - sig_send (myself_nowait, SIGHUP); - return TRUE; - } - return FALSE; - } - } - - if (chExeced) - { - chExeced->set_saw_ctrl_c (); - return TRUE; - } - - /* We're only the process group leader when we have a valid pinfo structure. - If we don't have one, then the parent "stub" will handle the signal. */ - if (!pinfo (cygwin_pid (GetCurrentProcessId ()))) - return TRUE; - - tty_min *t = cygwin_shared->tty.get_tty (myself->ctty); - /* Ignore this if we're not the process group leader since it should be handled - *by* the process group leader. */ - if (myself->ctty != -1 && t->getpgid () == myself->pid && - (GetTickCount () - t->last_ctrl_c) >= MIN_CTRL_C_SLOP) - /* Otherwise we just send a SIGINT to the process group and return TRUE (to indicate - that we have handled the signal). At this point, type should be - a CTRL_C_EVENT or CTRL_BREAK_EVENT. */ - { - int sig = SIGINT; - /* If intr and quit are both mapped to ^C, send SIGQUIT on ^BREAK */ - if (type == CTRL_BREAK_EVENT - && t->ti.c_cc[VINTR] == 3 && t->ti.c_cc[VQUIT] == 3) - sig = SIGQUIT; - t->last_ctrl_c = GetTickCount (); - killsys (-myself->pid, sig); - t->last_ctrl_c = GetTickCount (); - return TRUE; - } - - return TRUE; -} - -/* Function used by low level sig wrappers. */ -extern "C" void __stdcall -set_process_mask (sigset_t newmask) -{ - set_signal_mask (newmask, _my_tls.sigmask); -} - -extern "C" int -sighold (int sig) -{ - /* check that sig is in right range */ - if (sig < 0 || sig >= NSIG) - { - set_errno (EINVAL); - syscall_printf ("signal %d out of range", sig); - return -1; - } - mask_sync.acquire (INFINITE); - sigset_t mask = _my_tls.sigmask; - sigaddset (&mask, sig); - set_signal_mask (mask, _my_tls.sigmask); - mask_sync.release (); - return 0; -} - -extern "C" int -sigrelse (int sig) -{ - /* check that sig is in right range */ - if (sig < 0 || sig >= NSIG) - { - set_errno (EINVAL); - syscall_printf ("signal %d out of range", sig); - return -1; - } - mask_sync.acquire (INFINITE); - sigset_t mask = _my_tls.sigmask; - sigdelset (&mask, sig); - set_signal_mask (mask, _my_tls.sigmask); - mask_sync.release (); - return 0; -} - -extern "C" _sig_func_ptr -sigset (int sig, _sig_func_ptr func) -{ - sig_dispatch_pending (); - _sig_func_ptr prev; - - /* check that sig is in right range */ - if (sig < 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP) - { - set_errno (EINVAL); - syscall_printf ("SIG_ERR = sigset (%d, %p)", sig, func); - return (_sig_func_ptr) SIG_ERR; - } - - mask_sync.acquire (INFINITE); - sigset_t mask = _my_tls.sigmask; - /* If sig was in the signal mask return SIG_HOLD, otherwise return the - previous disposition. */ - if (sigismember (&mask, sig)) - prev = SIG_HOLD; - else - prev = global_sigs[sig].sa_handler; - /* If func is SIG_HOLD, add sig to the signal mask, otherwise set the - disposition to func and remove sig from the signal mask. */ - if (func == SIG_HOLD) - sigaddset (&mask, sig); - else - { - /* No error checking. The test which could return SIG_ERR has already - been made above. */ - signal (sig, func); - sigdelset (&mask, sig); - } - set_signal_mask (mask, _my_tls.sigmask); - mask_sync.release (); - return prev; -} - -extern "C" int -sigignore (int sig) -{ - return sigset (sig, SIG_IGN) == SIG_ERR ? -1 : 0; -} - -/* Update the signal mask for this process and return the old mask. - Called from sigdelayed */ -extern "C" sigset_t -set_process_mask_delta () -{ - mask_sync.acquire (INFINITE); - sigset_t newmask, oldmask; - - if (_my_tls.deltamask & SIG_NONMASKABLE) - oldmask = _my_tls.oldmask; /* from handle_sigsuspend */ - else - oldmask = _my_tls.sigmask; - newmask = (oldmask | _my_tls.deltamask) & ~SIG_NONMASKABLE; - sigproc_printf ("oldmask %p, newmask %p, deltamask %p", oldmask, newmask, - _my_tls.deltamask); - _my_tls.sigmask = newmask; - mask_sync.release (); - return oldmask; -} - -/* Set the signal mask for this process. - Note that some signals are unmaskable, as in UNIX. */ -extern "C" void __stdcall -set_signal_mask (sigset_t newmask, sigset_t& oldmask) -{ -#ifdef CGF - if (&_my_tls == _sig_tls) - small_printf ("********* waiting in signal thread\n"); -#endif - mask_sync.acquire (INFINITE); - newmask &= ~SIG_NONMASKABLE; - sigset_t mask_bits = oldmask & ~newmask; - sigproc_printf ("oldmask %p, newmask %p, mask_bits %p", oldmask, newmask, - mask_bits); - oldmask = newmask; - if (mask_bits) - sig_dispatch_pending (true); - else - sigproc_printf ("not calling sig_dispatch_pending"); - mask_sync.release (); -} - -int __stdcall -sigpacket::process () -{ - DWORD continue_now; - struct sigaction dummy = global_sigs[SIGSTOP]; - - if (si.si_signo != SIGCONT) - continue_now = false; - else - { - continue_now = myself->process_state & PID_STOPPED; - myself->stopsig = 0; - myself->process_state &= ~PID_STOPPED; - /* Clear pending stop signals */ - sig_clear (SIGSTOP); - sig_clear (SIGTSTP); - sig_clear (SIGTTIN); - sig_clear (SIGTTOU); - } - - int rc = 1; - - sigproc_printf ("signal %d processing", si.si_signo); - struct sigaction& thissig = global_sigs[si.si_signo]; - - myself->rusage_self.ru_nsignals++; - - bool masked; - void *handler; - if (!hExeced || (void *) thissig.sa_handler == (void *) SIG_IGN) - handler = (void *) thissig.sa_handler; - else if (tls) - return 1; - else - handler = NULL; - - _cygtls *use_tls = tls ?: _main_tls; - - if (si.si_signo == SIGKILL) - goto exit_sig; - if (si.si_signo == SIGSTOP) - { - sig_clear (SIGCONT); - goto stop; - } - - bool insigwait_mask; - if ((masked = ISSTATE (myself, PID_STOPPED))) - insigwait_mask = false; - else if (tls) - insigwait_mask = sigismember (&tls->sigwait_mask, si.si_signo); - else if (!(tls = _cygtls::find_tls (si.si_signo))) - insigwait_mask = false; - else - { - use_tls = tls; - insigwait_mask = true; - } - - if (insigwait_mask) - goto thread_specific; - - if (masked) - /* nothing to do */; - else if (sigismember (mask, si.si_signo)) - masked = true; - else if (tls) - masked = sigismember (&tls->sigmask, si.si_signo); - - if (masked) - { - sigproc_printf ("signal %d blocked", si.si_signo); - rc = -1; - goto done; - } - - /* Clear pending SIGCONT on stop signals */ - if (si.si_signo == SIGTSTP || si.si_signo == SIGTTIN || si.si_signo == SIGTTOU) - sig_clear (SIGCONT); - -#ifdef CGF - if (being_debugged ()) - { - char sigmsg[sizeof (_CYGWIN_SIGNAL_STRING " 0xffffffff")]; - __small_sprintf (sigmsg, _CYGWIN_SIGNAL_STRING " %p", si.si_signo); - OutputDebugString (sigmsg); - } -#endif - - if (handler == (void *) SIG_DFL) - { - if (insigwait_mask) - goto thread_specific; - if (si.si_signo == SIGCHLD || si.si_signo == SIGIO || si.si_signo == SIGCONT || si.si_signo == SIGWINCH - || si.si_signo == SIGURG) - { - sigproc_printf ("default signal %d ignored", si.si_signo); - if (continue_now) - SetEvent (signal_arrived); - goto done; - } - - if (si.si_signo == SIGTSTP || si.si_signo == SIGTTIN || si.si_signo == SIGTTOU) - goto stop; - - goto exit_sig; - } - - if (handler == (void *) SIG_IGN) - { - sigproc_printf ("signal %d ignored", si.si_signo); - goto done; - } - - if (handler == (void *) SIG_ERR) - goto exit_sig; - - use_tls->set_siginfo (this); - goto dosig; - -stop: - /* Eat multiple attempts to STOP */ - if (ISSTATE (myself, PID_STOPPED)) - goto done; - handler = (void *) sig_handle_tty_stop; - thissig = dummy; - -dosig: - /* Dispatch to the appropriate function. */ - sigproc_printf ("signal %d, about to call %p", si.si_signo, handler); - rc = setup_handler (si.si_signo, handler, thissig, use_tls); - -done: - tls = use_tls; - if (continue_now) - SetEvent (sigCONT); - sigproc_printf ("returning %d", rc); - return rc; - -thread_specific: - use_tls->sig = si.si_signo; - use_tls->set_siginfo (this); - use_tls->func = NULL; - sigproc_printf ("releasing sigwait for thread"); - SetEvent (use_tls->event); - goto done; - -exit_sig: - if (si.si_signo == SIGQUIT || si.si_signo == SIGABRT) - { - CONTEXT c; - c.ContextFlags = CONTEXT_FULL; - GetThreadContext (hMainThread, &c); - use_tls->copy_context (&c); - si.si_signo |= 0x80; - } - sigproc_printf ("signal %d, about to call do_exit", si.si_signo); - use_tls->signal_exit (si.si_signo); /* never returns */ -} - -/* Cover function to `do_exit' to handle exiting even in presence of more - exceptions. We used to call exit, but a SIGSEGV shouldn't cause atexit - routines to run. */ -void -_cygtls::signal_exit (int rc) -{ - if (hExeced) - { - sigproc_printf ("terminating captive process"); - TerminateProcess (hExeced, sigExeced = rc); - } - - signal_debugger (rc & 0x7f); - if ((rc & 0x80) && !try_to_debug ()) - stackdump (thread_context.ebp, 1, 1); - - lock_process until_exit (true); - if (hExeced || exit_state > ES_PROCESS_LOCKED) - myself.exit (rc); - - /* Starve other threads in a vain attempt to stop them from doing something - stupid. */ - SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_TIME_CRITICAL); - - sigproc_printf ("about to call do_exit (%x)", rc); - do_exit (rc); -} - -void -events_init () -{ - mask_sync.init ("mask_sync"); - windows_system_directory[0] = L'\0'; - GetSystemDirectoryW (windows_system_directory, sizeof (windows_system_directory) / sizeof (WCHAR) - 2); - PWCHAR end = wcschr (windows_system_directory, L'\0'); - if (end == windows_system_directory) - api_fatal ("can't find windows system directory"); - if (end[-1] != L'\\') - { - *end++ = L'\\'; - *end = L'\0'; - } - windows_system_directory_length = end - windows_system_directory; - debug_printf ("windows_system_directory '%W', windows_system_directory_length %d", - windows_system_directory, windows_system_directory_length); -} - -void -events_terminate () -{ - exit_already = 1; -} - -int -_cygtls::call_signal_handler () -{ - int this_sa_flags = 0; - /* Call signal handler. */ - while (sig && func) - { - lock (); - this_sa_flags = sa_flags; - int thissig = sig; - - pop (); - reset_signal_arrived (); - sigset_t this_oldmask = set_process_mask_delta (); - int this_errno = saved_errno; - sig = 0; - unlock (); // make sure synchronized - incyg = 0; - if (!(this_sa_flags & SA_SIGINFO)) - { - void (*sigfunc) (int) = func; - sigfunc (thissig); - } - else - { - siginfo_t thissi = infodata; - void (*sigact) (int, siginfo_t *, void *) = (void (*) (int, siginfo_t *, void *)) func; - /* no ucontext_t information provided yet */ - sigact (thissig, &thissi, NULL); - } - incyg = 1; - set_signal_mask (this_oldmask, _my_tls.sigmask); - if (this_errno >= 0) - set_errno (this_errno); - } - - return this_sa_flags & SA_RESTART; -} - -extern "C" void __stdcall -reset_signal_arrived () -{ - // NEEDED? WaitForSingleObject (signal_arrived, 10); - ResetEvent (signal_arrived); - sigproc_printf ("reset signal_arrived"); - if (_my_tls.stackptr > _my_tls.stack) - debug_printf ("stackptr[-1] %p", _my_tls.stackptr[-1]); -} - -void -_cygtls::copy_context (CONTEXT *c) -{ - memcpy (&thread_context, c, (&thread_context._internal - (unsigned char *) &thread_context)); -} - -void -_cygtls::signal_debugger (int sig) -{ - if (isinitialized () && being_debugged ()) - { - char sigmsg[2 * sizeof (_CYGWIN_SIGNAL_STRING " ffffffff ffffffff")]; - __small_sprintf (sigmsg, _CYGWIN_SIGNAL_STRING " %d %p %p", sig, thread_id, &thread_context); - OutputDebugString (sigmsg); - } -} diff --git a/winsup/cygwin/exec.cc b/winsup/cygwin/exec.cc deleted file mode 100644 index b1fd52783..000000000 --- a/winsup/cygwin/exec.cc +++ /dev/null @@ -1,109 +0,0 @@ -/* exec.cc: exec system call support. - - Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#define _execve __FOO_execve_ -#include "winsup.h" -#include -#include "cygerrno.h" -#include "path.h" -#include "environ.h" -#include "sync.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#undef _execve - -/* This is called _execve and not execve because the real execve is defined - in libc/posix/execve.c. It calls us. */ - -extern "C" int -execve (const char *path, char *const argv[], char *const envp[]) -{ - static char *const empty_env[] = { 0 }; - MALLOC_CHECK; - if (!envp) - envp = empty_env; - return spawnve (_P_OVERLAY, path, argv, envp); -} - -EXPORT_ALIAS (execve, _execve) - -extern "C" int -execl (const char *path, const char *arg0, ...) -{ - int i; - va_list args; - const char *argv[1024]; - - va_start (args, arg0); - argv[0] = arg0; - i = 1; - do - argv[i] = va_arg (args, const char *); - while (argv[i++] != NULL); - va_end (args); - MALLOC_CHECK; - return execve (path, (char * const *) argv, cur_environ ()); -} - -extern "C" int -execv (const char *path, char * const *argv) -{ - MALLOC_CHECK; - return execve (path, (char * const *) argv, cur_environ ()); -} - -extern "C" pid_t -sexecve_is_bad () -{ - set_errno (ENOSYS); - return 0; -} - -/* Copy string, until c or is encountered. - NUL-terminate the destination string (s1). - Return pointer to terminating byte in dst string. */ - -char * __stdcall -strccpy (char *s1, const char **s2, char c) -{ - while (**s2 && **s2 != c) - *s1++ = *((*s2)++); - *s1 = 0; - - MALLOC_CHECK; - return s1; -} - -extern "C" int -execvp (const char *path, char * const *argv) -{ - path_conv buf; - return execv (find_exec (path, buf, "PATH=", FE_NNF) ?: "", argv); -} - -extern "C" int -execvpe (const char *path, char * const *argv, char *const *envp) -{ - path_conv buf; - return execve (find_exec (path, buf, "PATH=", FE_NNF) ?: "", argv, envp); -} - -extern "C" int -fexecve (int fd, char * const *argv, char *const *envp) -{ - cygheap_fdget cfd (fd); - if (cfd < 0) - { - syscall_printf ("-1 = fexecve (%d, %p, %p)", fd, argv, envp); - return -1; - } - return execve (cfd->pc.get_win32 (), argv, envp); -} diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc deleted file mode 100644 index bbf675a64..000000000 --- a/winsup/cygwin/external.cc +++ /dev/null @@ -1,483 +0,0 @@ -/* external.cc: Interface to Cygwin internals from external programs. - - Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. - - Written by Christopher Faylor - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "sigproc.h" -#include "pinfo.h" -#include "shared_info.h" -#include "cygwin_version.h" -#include "cygerrno.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "heap.h" -#include "cygtls.h" -#include "child_info.h" -#include "environ.h" -#include "cygserver_setpwd.h" -#include -#include -#include -#include - -child_info *get_cygwin_startup_info (); -static void exit_process (UINT, bool) __attribute__((noreturn)); - -static winpids pids; - -static external_pinfo * -fillout_pinfo (pid_t pid, int winpid) -{ - BOOL nextpid; - static external_pinfo ep; - static char ep_progname_long_buf[NT_MAX_PATH]; - - if ((nextpid = !!(pid & CW_NEXTPID))) - pid ^= CW_NEXTPID; - - - static unsigned int i; - if (!pids.npids || !nextpid) - { - pids.set (winpid); - i = 0; - } - - if (!pid) - i = 0; - - memset (&ep, 0, sizeof ep); - while (i < pids.npids) - { - DWORD thispid = pids.winpid (i); - _pinfo *p = pids[i]; - i++; - - if (!p) - { - if (!nextpid && thispid != (DWORD) pid) - continue; - ep.pid = cygwin_pid (thispid); - ep.dwProcessId = thispid; - ep.process_state = PID_IN_USE; - ep.ctty = -1; - break; - } - else if (nextpid || p->pid == pid || (winpid && thispid == (DWORD) pid)) - { - ep.ctty = p->ctty; - ep.pid = p->pid; - ep.ppid = p->ppid; - ep.dwProcessId = p->dwProcessId; - ep.uid = p->uid; - ep.gid = p->gid; - ep.pgid = p->pgid; - ep.sid = p->sid; - ep.umask = 0; - ep.start_time = p->start_time; - ep.rusage_self = p->rusage_self; - ep.rusage_children = p->rusage_children; - ep.progname[0] = '\0'; - strncat (ep.progname, p->progname, MAX_PATH - 1); - ep.strace_mask = 0; - ep.version = EXTERNAL_PINFO_VERSION; - - ep.process_state = p->process_state; - - ep.uid32 = p->uid; - ep.gid32 = p->gid; - - ep.progname_long = ep_progname_long_buf; - strcpy (ep.progname_long, p->progname); - break; - } - } - - if (!ep.pid) - { - i = 0; - pids.reset (); - return 0; - } - return &ep; -} - -static inline DWORD -get_cygdrive_info (char *user, char *system, char *user_flags, - char *system_flags) -{ - int res = mount_table->get_cygdrive_info (user, system, user_flags, - system_flags); - return (res == ERROR_SUCCESS) ? 1 : 0; -} - -static DWORD -check_ntsec (const char *filename) -{ - if (!filename) - return true; - path_conv pc (filename); - return pc.has_acls (); -} - -/* Copy cygwin environment variables to the Windows environment. */ -static void -sync_winenv () -{ - int unused_envc; - PWCHAR envblock = NULL; - char **envp = build_env (cur_environ (), envblock, unused_envc, false); - PWCHAR p = envblock; - - if (envp) - { - for (char **e = envp; *e; e++) - cfree (*e); - cfree (envp); - } - if (!p) - return; - while (*p) - { - PWCHAR eq = wcschr (p, L'='); - if (eq) - { - *eq = L'\0'; - SetEnvironmentVariableW (p, ++eq); - p = eq; - } - p = wcschr (p, L'\0') + 1; - } - free (envblock); -} - -/* - * Cygwin-specific wrapper for win32 ExitProcess and TerminateProcess. - * It ensures that the correct exit code, derived from the specified - * status value, will be made available to this process's parent (if - * that parent is also a cygwin process). If useTerminateProcess is - * true, then TerminateProcess(GetCurrentProcess(),...) will be used; - * otherwise, ExitProcess(...) is called. - * - * Used by startup code for cygwin processes which is linked statically - * into applications, and is not part of the cygwin DLL -- which is why - * this interface is exposed. "Normal" programs should use ANSI exit(), - * ANSI abort(), or POSIX _exit(), rather than this function -- because - * calling ExitProcess or TerminateProcess, even through this wrapper, - * skips much of the cygwin process cleanup code. - */ -static void -exit_process (UINT status, bool useTerminateProcess) -{ - pid_t pid = getpid (); - external_pinfo * ep = fillout_pinfo (pid, 1); - DWORD dwpid = ep ? ep->dwProcessId : pid; - pinfo p (pid, PID_MAP_RW); - if ((dwpid == GetCurrentProcessId()) && (p->pid == ep->pid)) - p.set_exit_code ((DWORD)status); - if (useTerminateProcess) - TerminateProcess (GetCurrentProcess(), status); - /* avoid 'else' clause to silence warning */ - ExitProcess (status); -} - - -extern "C" unsigned long -cygwin_internal (cygwin_getinfo_types t, ...) -{ - va_list arg; - unsigned long res = -1; - va_start (arg, t); - - switch (t) - { - case CW_LOCK_PINFO: - res = 1; - break; - - case CW_UNLOCK_PINFO: - res = 1; - break; - - case CW_GETTHREADNAME: - res = (DWORD) cygthread::name (va_arg (arg, DWORD)); - break; - - case CW_SETTHREADNAME: - { - set_errno (ENOSYS); - res = 0; - } - break; - - case CW_GETPINFO: - res = (DWORD) fillout_pinfo (va_arg (arg, DWORD), 0); - break; - - case CW_GETVERSIONINFO: - res = (DWORD) cygwin_version_strings; - break; - - case CW_READ_V1_MOUNT_TABLES: - set_errno (ENOSYS); - res = 1; - break; - - case CW_USER_DATA: - /* This is a kludge to work around a version of _cygwin_common_crt0 - which overwrote the cxx_malloc field with the local DLL copy. - Hilarity ensues if the DLL is not loaded like while the process - is forking. */ - __cygwin_user_data.cxx_malloc = &default_cygwin_cxx_malloc; - res = (DWORD) &__cygwin_user_data; - break; - - case CW_PERFILE: - perfile_table = va_arg (arg, struct __cygwin_perfile *); - res = 0; - break; - - case CW_GET_CYGDRIVE_PREFIXES: - { - char *user = va_arg (arg, char *); - char *system = va_arg (arg, char *); - res = get_cygdrive_info (user, system, NULL, NULL); - } - break; - - case CW_GETPINFO_FULL: - res = (DWORD) fillout_pinfo (va_arg (arg, pid_t), 1); - break; - - case CW_INIT_EXCEPTIONS: - /* noop */ /* init_exceptions (va_arg (arg, exception_list *)); */ - res = 0; - break; - - case CW_GET_CYGDRIVE_INFO: - { - char *user = va_arg (arg, char *); - char *system = va_arg (arg, char *); - char *user_flags = va_arg (arg, char *); - char *system_flags = va_arg (arg, char *); - res = get_cygdrive_info (user, system, user_flags, system_flags); - } - break; - - case CW_SET_CYGWIN_REGISTRY_NAME: - case CW_GET_CYGWIN_REGISTRY_NAME: - res = 0; - break; - - case CW_STRACE_TOGGLE: - { - pid_t pid = va_arg (arg, pid_t); - pinfo p (pid); - if (p) - { - sig_send (p, __SIGSTRACE); - res = 0; - } - else - { - set_errno (ESRCH); - res = (DWORD) -1; - } - } - break; - - case CW_STRACE_ACTIVE: - { - res = strace.active (); - } - break; - - case CW_CYGWIN_PID_TO_WINPID: - { - pinfo p (va_arg (arg, pid_t)); - res = p ? p->dwProcessId : 0; - } - break; - case CW_EXTRACT_DOMAIN_AND_USER: - { - WCHAR nt_domain[MAX_DOMAIN_NAME_LEN + 1]; - WCHAR nt_user[UNLEN + 1]; - - struct passwd *pw = va_arg (arg, struct passwd *); - char *domain = va_arg (arg, char *); - char *user = va_arg (arg, char *); - extract_nt_dom_user (pw, nt_domain, nt_user); - if (domain) - sys_wcstombs (domain, MAX_DOMAIN_NAME_LEN + 1, nt_domain); - if (user) - sys_wcstombs (user, UNLEN + 1, nt_user); - res = 0; - } - break; - case CW_CMDLINE: - { - size_t n; - pid_t pid = va_arg (arg, pid_t); - pinfo p (pid); - res = (DWORD) p->cmdline (n); - } - break; - case CW_CHECK_NTSEC: - { - char *filename = va_arg (arg, char *); - res = check_ntsec (filename); - } - break; - case CW_GET_ERRNO_FROM_WINERROR: - { - int error = va_arg (arg, int); - int deferrno = va_arg (arg, int); - res = geterrno_from_win_error (error, deferrno); - } - break; - case CW_GET_POSIX_SECURITY_ATTRIBUTE: - { - path_conv dummy; - security_descriptor sd; - int attribute = va_arg (arg, int); - PSECURITY_ATTRIBUTES psa = va_arg (arg, PSECURITY_ATTRIBUTES); - void *sd_buf = va_arg (arg, void *); - DWORD sd_buf_size = va_arg (arg, DWORD); - set_security_attribute (dummy, attribute, psa, sd); - if (!psa->lpSecurityDescriptor) - res = sd.size (); - else - { - psa->lpSecurityDescriptor = sd_buf; - res = sd.copy (sd_buf, sd_buf_size); - } - } - break; - case CW_GET_SHMLBA: - { - res = getpagesize (); - } - break; - case CW_GET_UID_FROM_SID: - { - cygpsid psid = va_arg (arg, PSID); - res = psid.get_id (false, NULL); - } - break; - case CW_GET_GID_FROM_SID: - { - cygpsid psid = va_arg (arg, PSID); - res = psid.get_id (true, NULL); - } - break; - case CW_GET_BINMODE: - { - const char *path = va_arg (arg, const char *); - path_conv p (path, PC_SYM_FOLLOW | PC_NULLEMPTY); - if (p.error) - { - set_errno (p.error); - res = (unsigned long) -1; - } - else - res = p.binmode (); - } - break; - case CW_HOOK: - { - const char *name = va_arg (arg, const char *); - const void *hookfn = va_arg (arg, const void *); - WORD subsys; - res = (unsigned long) hook_or_detect_cygwin (name, hookfn, subsys); - } - break; - case CW_ARGV: - { - child_info_spawn *ci = (child_info_spawn *) get_cygwin_startup_info (); - res = (unsigned long) (ci ? ci->moreinfo->argv : NULL); - } - break; - case CW_ENVP: - { - child_info_spawn *ci = (child_info_spawn *) get_cygwin_startup_info (); - res = (unsigned long) (ci ? ci->moreinfo->envp : NULL); - } - break; - case CW_DEBUG_SELF: - error_start_init (va_arg (arg, const char *)); - try_to_debug (); - break; - case CW_SYNC_WINENV: - sync_winenv (); - res = 0; - break; - case CW_CYGTLS_PADSIZE: - res = CYGTLS_PADSIZE; - break; - case CW_SET_DOS_FILE_WARNING: - { - extern bool dos_file_warning; - dos_file_warning = va_arg (arg, int); - res = 0; - } - break; - case CW_SET_PRIV_KEY: - { - const char *passwd = va_arg (arg, const char *); - res = setlsapwd (passwd); - } - break; - case CW_SETERRNO: - { - const char *file = va_arg (arg, const char *); - int line = va_arg (arg, int); - seterrno(file, line); - res = 0; - } - break; - case CW_EXIT_PROCESS: - { - UINT status = va_arg (arg, UINT); - int useTerminateProcess = va_arg (arg, int); - exit_process (status, !!useTerminateProcess); /* no return */ - } - case CW_SET_EXTERNAL_TOKEN: - { - HANDLE token = va_arg (arg, HANDLE); - int type = va_arg (arg, int); - set_imp_token (token, type); - res = 0; - } - break; - case CW_GET_INSTKEY: - { - extern WCHAR installation_key_buf[18]; - PWCHAR dest = va_arg (arg, PWCHAR); - wcscpy (dest, installation_key_buf); - res = 0; - } - break; - case CW_INT_SETLOCALE: - { - extern void internal_setlocale (); - internal_setlocale (); - res = 0; - } - - default: - set_errno (ENOSYS); - } - va_end (arg); - return res; -} diff --git a/winsup/cygwin/external.sgml b/winsup/cygwin/external.sgml deleted file mode 100644 index bbfdd0fb8..000000000 --- a/winsup/cygwin/external.sgml +++ /dev/null @@ -1,18 +0,0 @@ - - -cygwin_internal - - -extern "C" DWORD -cygwin_internal -cygwin_getinfo_types t -... - - -This function gives you access to various internal data and functions. -It takes two arguments. The first argument is a type from the 'cygwin_getinfo_types' -enum. The second is an optional pointer. -Stay away unless you know what you're doing. - - - diff --git a/winsup/cygwin/fcntl.cc b/winsup/cygwin/fcntl.cc deleted file mode 100644 index de13f10bf..000000000 --- a/winsup/cygwin/fcntl.cc +++ /dev/null @@ -1,107 +0,0 @@ -/* fcntl.cc: fcntl syscall - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2008, - 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "cygtls.h" - -extern "C" int -fcntl64 (int fd, int cmd, ...) -{ - int res = -1; - void *arg = NULL; - va_list args; - - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - cygheap_fdget cfd (fd, true); - if (cfd < 0) - goto done; - - va_start (args, cmd); - arg = va_arg (args, void *); - va_end (args); - - switch (cmd) - { - case F_DUPFD: - case F_DUPFD_CLOEXEC: - if ((int) arg >= 0 && (int) arg < OPEN_MAX_MAX) - res = dup3 (fd, cygheap_fdnew (((int) arg) - 1), - cmd == F_DUPFD_CLOEXEC ? O_CLOEXEC : 0); - else - { - set_errno (EINVAL); - res = -1; - } - break; - case F_GETLK: - case F_SETLK: - case F_SETLKW: - { - struct __flock64 *fl = (struct __flock64 *) arg; - fl->l_type &= F_RDLCK | F_WRLCK | F_UNLCK; - res = cfd->lock (cmd, fl); - } - break; - default: - res = cfd->fcntl (cmd, arg); - break; - } -done: - syscall_printf ("%d = fcntl (%d, %d, %p)", res, fd, cmd, arg); - return res; -} - -extern "C" int -_fcntl (int fd, int cmd, ...) -{ - void *arg = NULL; - va_list args; - struct __flock32 *src = NULL; - struct __flock64 dst; - - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - va_start (args, cmd); - arg = va_arg (args, void *); - va_end (args); - if (cmd == F_GETLK || cmd == F_SETLK || cmd == F_SETLKW) - { - src = (struct __flock32 *) arg; - dst.l_type = src->l_type; - dst.l_whence = src->l_whence; - dst.l_start = src->l_start; - dst.l_len = src->l_len; - dst.l_pid = src->l_pid; - arg = &dst; - } - int res = fcntl64 (fd, cmd, arg); - if (cmd == F_GETLK) - { - src->l_type = dst.l_type; - src->l_whence = dst.l_whence; - src->l_start = dst.l_start; - src->l_len = dst.l_len; - src->l_pid = (short) dst.l_pid; - } - return res; -} diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc deleted file mode 100644 index 8e8438314..000000000 --- a/winsup/cygwin/fhandler.cc +++ /dev/null @@ -1,1783 +0,0 @@ -/* fhandler.cc. See console.cc for fhandler_console functions. - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include -#include -#include "cygerrno.h" -#include "perprocess.h" -#include "security.h" -#include "cygwin/version.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "pinfo.h" -#include -#include -#include "ntdll.h" -#include "cygtls.h" -#include "sigproc.h" -#include "nfs.h" - -static NO_COPY const int CHUNK_SIZE = 1024; /* Used for crlf conversions */ - -struct __cygwin_perfile *perfile_table; - -inline fhandler_base& -fhandler_base::operator =(fhandler_base& x) -{ - memcpy (this, &x, sizeof *this); - pc = x.pc; - rabuf = NULL; - ralen = 0; - raixget = 0; - raixput = 0; - rabuflen = 0; - return *this; -} - -int -fhandler_base::puts_readahead (const char *s, size_t len) -{ - int success = 1; - while ((len == (size_t) -1 ? *s : len--) - && (success = put_readahead (*s++) > 0)) - continue; - return success; -} - -int -fhandler_base::put_readahead (char value) -{ - char *newrabuf; - if (raixput < rabuflen) - /* Nothing to do */; - else if ((newrabuf = (char *) realloc (rabuf, rabuflen += 32))) - rabuf = newrabuf; - else - return 0; - - rabuf[raixput++] = value; - ralen++; - return 1; -} - -int -fhandler_base::get_readahead () -{ - int chret = -1; - if (raixget < ralen) - chret = ((unsigned char) rabuf[raixget++]) & 0xff; - /* FIXME - not thread safe */ - if (raixget >= ralen) - raixget = raixput = ralen = 0; - return chret; -} - -int -fhandler_base::peek_readahead (int queryput) -{ - int chret = -1; - if (!queryput && raixget < ralen) - chret = ((unsigned char) rabuf[raixget]) & 0xff; - else if (queryput && raixput > 0) - chret = ((unsigned char) rabuf[raixput - 1]) & 0xff; - return chret; -} - -void -fhandler_base::set_readahead_valid (int val, int ch) -{ - if (!val) - ralen = raixget = raixput = 0; - if (ch != -1) - put_readahead (ch); -} - -int -fhandler_base::eat_readahead (int n) -{ - int oralen = ralen; - if (n < 0) - n = ralen; - if (n > 0 && ralen) - { - if ((int) (ralen -= n) < 0) - ralen = 0; - - if (raixget >= ralen) - raixget = raixput = ralen = 0; - else if (raixput > ralen) - raixput = ralen; - } - - return oralen; -} - -int -fhandler_base::get_readahead_into_buffer (char *buf, size_t buflen) -{ - int ch; - int copied_chars = 0; - - while (buflen) - if ((ch = get_readahead ()) < 0) - break; - else - { - buf[copied_chars++] = (unsigned char)(ch & 0xff); - buflen--; - } - - return copied_chars; -} - -/* Record the file name. and name hash */ -void -fhandler_base::set_name (path_conv &in_pc) -{ - pc = in_pc; -} - -char *fhandler_base::get_proc_fd_name (char *buf) -{ - if (get_name ()) - return strcpy (buf, get_name ()); - if (dev ().name) - return strcpy (buf, dev ().name); - return strcpy (buf, ""); -} - -/* Detect if we are sitting at EOF for conditions where Windows - returns an error but UNIX doesn't. */ -static int __stdcall -is_at_eof (HANDLE h, DWORD err) -{ - IO_STATUS_BLOCK io; - FILE_POSITION_INFORMATION fpi; - FILE_STANDARD_INFORMATION fsi; - - if (NT_SUCCESS (NtQueryInformationFile (h, &io, &fsi, sizeof fsi, - FileStandardInformation)) - && NT_SUCCESS (NtQueryInformationFile (h, &io, &fpi, sizeof fpi, - FilePositionInformation)) - && fsi.EndOfFile.QuadPart == fpi.CurrentByteOffset.QuadPart) - return 1; - SetLastError (err); - return 0; -} - -void -fhandler_base::set_flags (int flags, int supplied_bin) -{ - int bin; - int fmode; - debug_printf ("flags %p, supplied_bin %p", flags, supplied_bin); - if ((bin = flags & (O_BINARY | O_TEXT))) - debug_printf ("O_TEXT/O_BINARY set in flags %p", bin); - else if (rbinset () && wbinset ()) - bin = rbinary () ? O_BINARY : O_TEXT; // FIXME: Not quite right - else if ((fmode = get_default_fmode (flags)) & O_BINARY) - bin = O_BINARY; - else if (fmode & O_TEXT) - bin = O_TEXT; - else if (supplied_bin) - bin = supplied_bin; - else - bin = wbinary () || rbinary () ? O_BINARY : O_TEXT; - - openflags = flags | bin; - - bin &= O_BINARY; - rbinary (bin ? true : false); - wbinary (bin ? true : false); - syscall_printf ("filemode set to %s", bin ? "binary" : "text"); -} - -/* Normal file i/o handlers. */ - -/* Cover function to ReadFile to achieve (as much as possible) Posix style - semantics and use of errno. */ -void __stdcall -fhandler_base::raw_read (void *ptr, size_t& ulen) -{ -#define bytes_read ulen - - int try_noreserve = 1; - DWORD len = ulen; - -retry: - ulen = (size_t) -1; - BOOL res = ReadFile (get_handle (), ptr, len, (DWORD *) &ulen, NULL); - if (!res) - { - /* Some errors are not really errors. Detect such cases here. */ - - DWORD errcode = GetLastError (); - switch (errcode) - { - case ERROR_BROKEN_PIPE: - /* This is really EOF. */ - bytes_read = 0; - break; - case ERROR_MORE_DATA: - /* `bytes_read' is supposedly valid. */ - break; - case ERROR_NOACCESS: - if (is_at_eof (get_handle (), errcode)) - { - bytes_read = 0; - break; - } - if (try_noreserve) - { - try_noreserve = 0; - switch (mmap_is_attached_or_noreserve (ptr, len)) - { - case MMAP_NORESERVE_COMMITED: - goto retry; - case MMAP_RAISE_SIGBUS: - raise(SIGBUS); - case MMAP_NONE: - break; - } - } - /*FALLTHRU*/ - case ERROR_INVALID_FUNCTION: - case ERROR_INVALID_PARAMETER: - case ERROR_INVALID_HANDLE: - if (pc.isdir ()) - { - set_errno (EISDIR); - bytes_read = (size_t) -1; - break; - } - default: - syscall_printf ("ReadFile %s(%p) failed, %E", get_name (), get_handle ()); - __seterrno_from_win_error (errcode); - bytes_read = (size_t) -1; - break; - } - } -#undef bytes_read -} - -/* Cover function to WriteFile to provide Posix interface and semantics - (as much as possible). */ -static LARGE_INTEGER off_current = { QuadPart:FILE_USE_FILE_POINTER_POSITION }; -static LARGE_INTEGER off_append = { QuadPart:FILE_WRITE_TO_END_OF_FILE }; - -ssize_t __stdcall -fhandler_base::raw_write (const void *ptr, size_t len) -{ - NTSTATUS status; - IO_STATUS_BLOCK io; - - status = NtWriteFile (get_output_handle (), NULL, NULL, NULL, &io, - (PVOID) ptr, len, - (get_flags () & O_APPEND) ? &off_append : &off_current, - NULL); - if (!NT_SUCCESS (status)) - { - if (status == STATUS_DISK_FULL && io.Information > 0) - goto written; - __seterrno_from_nt_status (status); - if (get_errno () == EPIPE) - raise (SIGPIPE); - return -1; - } -written: - return io.Information; -} - -int -fhandler_base::get_default_fmode (int flags) -{ - int fmode = __fmode; - if (perfile_table) - { - size_t nlen = strlen (get_name ()); - unsigned accflags = (flags & O_ACCMODE); - for (__cygwin_perfile *pf = perfile_table; pf->name; pf++) - if (!*pf->name && (pf->flags & O_ACCMODE) == accflags) - { - fmode = pf->flags & ~O_ACCMODE; - break; - } - else - { - size_t pflen = strlen (pf->name); - const char *stem = get_name () + nlen - pflen; - if (pflen > nlen || (stem != get_name () && !isdirsep (stem[-1]))) - continue; - else if ((pf->flags & O_ACCMODE) == accflags - && pathmatch (stem, pf->name, !!pc.objcaseinsensitive ())) - { - fmode = pf->flags & ~O_ACCMODE; - break; - } - } - } - return fmode; -} - -bool -fhandler_base::device_access_denied (int flags) -{ - int mode = 0; - - if (flags & O_RDWR) - mode |= R_OK | W_OK; - if (flags & (O_WRONLY | O_APPEND)) - mode |= W_OK; - if (!mode) - mode |= R_OK; - - return fhaccess (mode, true); -} - -int -fhandler_base::fhaccess (int flags, bool effective) -{ - int res = -1; - if (error ()) - { - set_errno (error ()); - goto done; - } - - if (!exists ()) - { - set_errno (ENOENT); - goto done; - } - - if (!(flags & (R_OK | W_OK | X_OK))) - return 0; - - if (is_fs_special ()) - /* short circuit */; - else if (has_attribute (FILE_ATTRIBUTE_READONLY) && (flags & W_OK) - && !pc.isdir ()) - goto eaccess_done; - else if (has_acls ()) - { - res = check_file_access (pc, flags, effective); - goto done; - } - else if (get_device () == FH_REGISTRY && open (O_RDONLY, 0) && get_handle ()) - { - res = check_registry_access (get_handle (), flags, effective); - close (); - return res; - } - - struct __stat64 st; - if (fstat (&st)) - goto done; - - if (flags & R_OK) - { - if (st.st_uid == (effective ? myself->uid : cygheap->user.real_uid)) - { - if (!(st.st_mode & S_IRUSR)) - goto eaccess_done; - } - else if (st.st_gid == (effective ? myself->gid : cygheap->user.real_gid)) - { - if (!(st.st_mode & S_IRGRP)) - goto eaccess_done; - } - else if (!(st.st_mode & S_IROTH)) - goto eaccess_done; - } - - if (flags & W_OK) - { - if (st.st_uid == (effective ? myself->uid : cygheap->user.real_uid)) - { - if (!(st.st_mode & S_IWUSR)) - goto eaccess_done; - } - else if (st.st_gid == (effective ? myself->gid : cygheap->user.real_gid)) - { - if (!(st.st_mode & S_IWGRP)) - goto eaccess_done; - } - else if (!(st.st_mode & S_IWOTH)) - goto eaccess_done; - } - - if (flags & X_OK) - { - if (st.st_uid == (effective ? myself->uid : cygheap->user.real_uid)) - { - if (!(st.st_mode & S_IXUSR)) - goto eaccess_done; - } - else if (st.st_gid == (effective ? myself->gid : cygheap->user.real_gid)) - { - if (!(st.st_mode & S_IXGRP)) - goto eaccess_done; - } - else if (!(st.st_mode & S_IXOTH)) - goto eaccess_done; - } - - res = 0; - goto done; - -eaccess_done: - set_errno (EACCES); -done: - if (!res && (flags & W_OK) && get_device () == FH_FS - && (pc.fs_flags () & FILE_READ_ONLY_VOLUME)) - { - set_errno (EROFS); - res = -1; - } - debug_printf ("returning %d", res); - return res; -} - -/* Open system call handler function. */ -int -fhandler_base::open (int flags, mode_t mode) -{ - int res = 0; - HANDLE fh; - ULONG file_attributes = 0; - ULONG shared = (get_major () == DEV_TAPE_MAJOR ? 0 : FILE_SHARE_VALID_FLAGS); - ULONG create_disposition; - ULONG create_options = FILE_OPEN_FOR_BACKUP_INTENT; - OBJECT_ATTRIBUTES attr; - IO_STATUS_BLOCK io; - NTSTATUS status; - PFILE_FULL_EA_INFORMATION p = NULL; - ULONG plen = 0; - - syscall_printf ("(%S, %p)", pc.get_nt_native_path (), flags); - - pc.get_object_attr (attr, *sec_none_cloexec (flags)); - - switch (query_open ()) - { - case query_read_control: - access = READ_CONTROL; - break; - case query_read_attributes: - access = READ_CONTROL | FILE_READ_ATTRIBUTES; - break; - case query_write_control: - access = READ_CONTROL | WRITE_OWNER | WRITE_DAC | FILE_WRITE_ATTRIBUTES; - break; - case query_write_attributes: - access = READ_CONTROL | FILE_WRITE_ATTRIBUTES; - break; - default: - if ((flags & O_ACCMODE) == O_RDONLY) - access = GENERIC_READ; - else if ((flags & O_ACCMODE) == O_WRONLY) - access = GENERIC_WRITE | READ_CONTROL | FILE_READ_ATTRIBUTES; - else - access = GENERIC_READ | GENERIC_WRITE; - if (flags & O_SYNC) - create_options |= FILE_WRITE_THROUGH; - if (flags & O_DIRECT) - create_options |= FILE_NO_INTERMEDIATE_BUFFERING; - if (get_major () != DEV_SERIAL_MAJOR && get_major () != DEV_TAPE_MAJOR) - { - create_options |= FILE_SYNCHRONOUS_IO_NONALERT; - access |= SYNCHRONIZE; - } - break; - } - - if (query_open () && pc.fs_is_nfs ()) - { - /* Make sure we can read EAs of files on an NFS share. Also make - sure that we're going to act on the file itself, even if it'a - a symlink. */ - access |= FILE_READ_EA; - if (query_open () >= query_write_control) - access |= FILE_WRITE_EA; - plen = sizeof nfs_aol_ffei; - p = (PFILE_FULL_EA_INFORMATION) &nfs_aol_ffei; - } - - if ((flags & O_TRUNC) && ((flags & O_ACCMODE) != O_RDONLY)) - { - if (flags & O_CREAT) - create_disposition = FILE_OVERWRITE_IF; - else - create_disposition = FILE_OVERWRITE; - } - else if (flags & O_CREAT) - create_disposition = FILE_OPEN_IF; - else - create_disposition = FILE_OPEN; - - if ((flags & O_EXCL) && (flags & O_CREAT)) - create_disposition = FILE_CREATE; - - if (get_device () == FH_FS) - { - /* Add the reparse point flag to native symlinks, otherwise we open the - target, not the symlink. This would break lstat. */ - if (pc.is_rep_symlink ()) - create_options |= FILE_OPEN_REPARSE_POINT; - - /* Starting with Windows 2000, when trying to overwrite an already - existing file with FILE_ATTRIBUTE_HIDDEN and/or FILE_ATTRIBUTE_SYSTEM - attribute set, CreateFile fails with ERROR_ACCESS_DENIED. - Per MSDN you have to create the file with the same attributes as - already specified for the file. */ - if (((flags & O_CREAT) || create_disposition == FILE_OVERWRITE) - && has_attribute (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) - file_attributes |= pc.file_attributes (); - - if (flags & O_CREAT) - { - file_attributes |= FILE_ATTRIBUTE_NORMAL; - - if (pc.fs_is_nfs ()) - { - /* When creating a file on an NFS share, we have to set the - file mode by writing a NFS fattr3 structure with the - correct mode bits set. */ - access |= FILE_WRITE_EA; - plen = sizeof (FILE_FULL_EA_INFORMATION) + sizeof (NFS_V3_ATTR) - + sizeof (fattr3); - p = (PFILE_FULL_EA_INFORMATION) alloca (plen); - p->NextEntryOffset = 0; - p->Flags = 0; - p->EaNameLength = sizeof (NFS_V3_ATTR) - 1; - p->EaValueLength = sizeof (fattr3); - strcpy (p->EaName, NFS_V3_ATTR); - fattr3 *nfs_attr = (fattr3 *) (p->EaName - + p->EaNameLength + 1); - memset (nfs_attr, 0, sizeof (fattr3)); - nfs_attr->type = NF3REG; - nfs_attr->mode = mode; - } - else if (!has_acls () && !(mode & (S_IWUSR | S_IWGRP | S_IWOTH))) - /* If mode has no write bits set, and ACLs are not used, we set - the DOS R/O attribute. */ - file_attributes |= FILE_ATTRIBUTE_READONLY; - /* The file attributes are needed for later use in, e.g. fchmod. */ - pc.file_attributes (file_attributes); - } - } - - status = NtCreateFile (&fh, access, &attr, &io, NULL, file_attributes, shared, - create_disposition, create_options, p, plen); - if (!NT_SUCCESS (status)) - { - /* Trying to create a directory should return EISDIR, not ENOENT. */ - PUNICODE_STRING upath = pc.get_nt_native_path (); - if (status == STATUS_OBJECT_NAME_INVALID && (flags & O_CREAT) - && upath->Buffer[upath->Length / sizeof (WCHAR) - 1] == '\\') - set_errno (EISDIR); - else - __seterrno_from_nt_status (status); - if (!nohandle ()) - goto done; - } - - /* Always create files using a NULL SD. Create correct permission bits - afterwards, maintaining the owner and group information just like chmod. - - This is done for two reasons. - - On Windows filesystems we need to create the file with default - permissions to allow inheriting ACEs. When providing an explicit DACL - in calls to [Nt]CreateFile, the created file will not inherit default - permissions from the parent object. This breaks not only Windows - inheritance, but also POSIX ACL inheritance. - - Another reason to do this are remote shares. Files on a remote share - are created as the user used for authentication. In a domain that's - usually the user you're logged in as. Outside of a domain you're - authenticating using a local user account on the sharing machine. - If the SIDs of the client machine are used, that's entirely - unexpected behaviour. Doing it like we do here creates the expected SD - in a domain as well as on standalone servers. - This is the result of a discussion on the samba-technical list, starting at - http://lists.samba.org/archive/samba-technical/2008-July/060247.html */ - if (io.Information == FILE_CREATED && has_acls ()) - set_file_attribute (fh, pc, ILLEGAL_UID, ILLEGAL_GID, S_JUSTCREATED | mode); - - set_io_handle (fh); - set_flags (flags, pc.binmode ()); - - res = 1; - set_open_status (); -done: - debug_printf ("%x = NtCreateFile " - "(%p, %x, %S, io, NULL, %x, %x, %x, %x, NULL, 0)", - status, fh, access, pc.get_nt_native_path (), file_attributes, - shared, create_disposition, create_options); - - syscall_printf ("%d = fhandler_base::open (%S, %p)", - res, pc.get_nt_native_path (), flags); - return res; -} - -/* states: - open buffer in binary mode? Just do the read. - - open buffer in text mode? Scan buffer for control zs and handle - the first one found. Then scan buffer, converting every \r\n into - an \n. If last char is an \r, look ahead one more char, if \n then - modify \r, if not, remember char. -*/ -void __stdcall -fhandler_base::read (void *in_ptr, size_t& len) -{ - char *ptr = (char *) in_ptr; - ssize_t copied_chars = get_readahead_into_buffer (ptr, len); - - if (copied_chars && is_slow ()) - { - len = (size_t) copied_chars; - goto out; - } - - len -= copied_chars; - if (!len) - { - len = (size_t) copied_chars; - goto out; - } - - raw_read (ptr + copied_chars, len); - if (!copied_chars) - /* nothing */; - else if ((ssize_t) len > 0) - len += copied_chars; - else - len = copied_chars; - - if (rbinary () || (ssize_t) len <= 0) - goto out; - - /* Scan buffer and turn \r\n into \n */ - char *src, *dst, *end; - src = (char *) ptr; - dst = (char *) ptr; - end = src + len - 1; - - /* Read up to the last but one char - the last char needs special handling */ - while (src < end) - { - if (*src == '\r' && src[1] == '\n') - src++; - *dst++ = *src++; - } - - /* If not beyond end and last char is a '\r' then read one more - to see if we should translate this one too */ - if (src > end) - /* nothing */; - else if (*src != '\r') - *dst++ = *src; - else - { - char c1; - size_t c1len = 1; - raw_read (&c1, c1len); - if (c1len <= 0) - /* nothing */; - else if (c1 == '\n') - *dst++ = '\n'; - else - { - set_readahead_valid (1, c1); - *dst++ = *src; - } - } - - len = dst - (char *) ptr; - -#ifndef NOSTRACE - if (strace.active ()) - { - char buf[16 * 6 + 1]; - char *p = buf; - - for (int i = 0; i < copied_chars && i < 16; ++i) - { - unsigned char c = ((unsigned char *) ptr)[i]; - __small_sprintf (p, " %c", c); - p += strlen (p); - } - *p = '\0'; - debug_printf ("read %d bytes (%s%s)", copied_chars, buf, - copied_chars > 16 ? " ..." : ""); - } -#endif - -out: - debug_printf ("returning %d, %s mode", len, rbinary () ? "binary" : "text"); -} - -ssize_t __stdcall -fhandler_base::write (const void *ptr, size_t len) -{ - int res; - IO_STATUS_BLOCK io; - FILE_POSITION_INFORMATION fpi; - FILE_STANDARD_INFORMATION fsi; - - if (did_lseek ()) - { - did_lseek (false); /* don't do it again */ - - if (!(get_flags () & O_APPEND) - && NT_SUCCESS (NtQueryInformationFile (get_output_handle (), - &io, &fsi, sizeof fsi, - FileStandardInformation)) - && NT_SUCCESS (NtQueryInformationFile (get_output_handle (), - &io, &fpi, sizeof fpi, - FilePositionInformation)) - && fpi.CurrentByteOffset.QuadPart - >= fsi.EndOfFile.QuadPart + (128 * 1024) - && (pc.fs_flags () & FILE_SUPPORTS_SPARSE_FILES)) - { - /* If the file system supports sparse files and the application - is writing after a long seek beyond EOF, convert the file to - a sparse file. */ - NTSTATUS status; - status = NtFsControlFile (get_output_handle (), NULL, NULL, NULL, - &io, FSCTL_SET_SPARSE, NULL, 0, NULL, 0); - syscall_printf ("%p = NtFsControlFile(%S, FSCTL_SET_SPARSE)", - status, pc.get_nt_native_path ()); - } - } - - if (wbinary ()) - { - debug_printf ("binary write"); - res = raw_write (ptr, len); - } - else - { - debug_printf ("text write"); - /* This is the Microsoft/DJGPP way. Still not ideal, but it's - compatible. - Modified slightly by CGF 2000-10-07 */ - - int left_in_data = len; - char *data = (char *)ptr; - res = 0; - - while (left_in_data > 0) - { - char buf[CHUNK_SIZE + 1], *buf_ptr = buf; - int left_in_buf = CHUNK_SIZE; - - while (left_in_buf > 0 && left_in_data > 0) - { - char ch = *data++; - if (ch == '\n') - { - *buf_ptr++ = '\r'; - left_in_buf--; - } - *buf_ptr++ = ch; - left_in_buf--; - left_in_data--; - if (left_in_data > 0 && ch == '\r' && *data == '\n') - { - *buf_ptr++ = *data++; - left_in_buf--; - left_in_data--; - } - } - - /* We've got a buffer-full, or we're out of data. Write it out */ - int nbytes; - int want = buf_ptr - buf; - if ((nbytes = raw_write (buf, want)) == want) - { - /* Keep track of how much written not counting additional \r's */ - res = data - (char *)ptr; - continue; - } - - if (nbytes == -1) - res = -1; /* Error */ - else - res += nbytes; /* Partial write. Return total bytes written. */ - break; /* All done */ - } - } - - return res; -} - -ssize_t __stdcall -fhandler_base::readv (const struct iovec *const iov, const int iovcnt, - ssize_t tot) -{ - assert (iov); - assert (iovcnt >= 1); - - size_t len = tot; - if (iovcnt == 1) - { - len = iov->iov_len; - read (iov->iov_base, len); - return len; - } - - if (tot == -1) // i.e. if not pre-calculated by the caller. - { - len = 0; - const struct iovec *iovptr = iov + iovcnt; - do - { - iovptr -= 1; - len += iovptr->iov_len; - } - while (iovptr != iov); - } - - if (!len) - return 0; - - char *buf = (char *) malloc (len); - - if (!buf) - { - set_errno (ENOMEM); - return -1; - } - - read (buf, len); - ssize_t nbytes = (ssize_t) len; - - const struct iovec *iovptr = iov; - - char *p = buf; - while (nbytes > 0) - { - const int frag = min (nbytes, (ssize_t) iovptr->iov_len); - memcpy (iovptr->iov_base, p, frag); - p += frag; - iovptr += 1; - nbytes -= frag; - } - - free (buf); - return len; -} - -ssize_t __stdcall -fhandler_base::writev (const struct iovec *const iov, const int iovcnt, - ssize_t tot) -{ - assert (iov); - assert (iovcnt >= 1); - - if (iovcnt == 1) - return write (iov->iov_base, iov->iov_len); - - if (tot == -1) // i.e. if not pre-calculated by the caller. - { - tot = 0; - const struct iovec *iovptr = iov + iovcnt; - do - { - iovptr -= 1; - tot += iovptr->iov_len; - } - while (iovptr != iov); - } - - assert (tot >= 0); - - if (tot == 0) - return 0; - - char *const buf = (char *) malloc (tot); - - if (!buf) - { - set_errno (ENOMEM); - return -1; - } - - char *bufptr = buf; - const struct iovec *iovptr = iov; - int nbytes = tot; - - while (nbytes != 0) - { - const int frag = min (nbytes, (ssize_t) iovptr->iov_len); - memcpy (bufptr, iovptr->iov_base, frag); - bufptr += frag; - iovptr += 1; - nbytes -= frag; - } - ssize_t ret = write (buf, tot); - free (buf); - return ret; -} - -_off64_t -fhandler_base::lseek (_off64_t offset, int whence) -{ - NTSTATUS status; - IO_STATUS_BLOCK io; - FILE_POSITION_INFORMATION fpi; - FILE_STANDARD_INFORMATION fsi; - - /* Seeks on text files is tough, we rewind and read till we get to the - right place. */ - - if (whence != SEEK_CUR || offset != 0) - { - if (whence == SEEK_CUR) - offset -= ralen - raixget; - set_readahead_valid (0); - } - - switch (whence) - { - case SEEK_SET: - fpi.CurrentByteOffset.QuadPart = offset; - break; - case SEEK_CUR: - status = NtQueryInformationFile (get_handle (), &io, &fpi, sizeof fpi, - FilePositionInformation); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - return -1; - } - fpi.CurrentByteOffset.QuadPart += offset; - break; - default: /* SEEK_END */ - status = NtQueryInformationFile (get_handle (), &io, &fsi, sizeof fsi, - FileStandardInformation); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - return -1; - } - fpi.CurrentByteOffset.QuadPart = fsi.EndOfFile.QuadPart + offset; - break; - } - - debug_printf ("setting file pointer to %U", fpi.CurrentByteOffset.QuadPart); - status = NtSetInformationFile (get_handle (), &io, &fpi, sizeof fpi, - FilePositionInformation); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - return -1; - } - _off64_t res = fpi.CurrentByteOffset.QuadPart; - - /* When next we write(), we will check to see if *this* seek went beyond - the end of the file and if so, potentially sparsify the file. */ - did_lseek (true); - - /* If this was a SEEK_CUR with offset 0, we still might have - readahead that we have to take into account when calculating - the actual position for the application. */ - if (whence == SEEK_CUR) - res -= ralen - raixget; - - return res; -} - -ssize_t __stdcall -fhandler_base::pread (void *, size_t, _off64_t) -{ - set_errno (ESPIPE); - return -1; -} - -ssize_t __stdcall -fhandler_base::pwrite (void *, size_t, _off64_t) -{ - set_errno (ESPIPE); - return -1; -} - -int -fhandler_base::close () -{ - int res = -1; - - syscall_printf ("closing '%s' handle %p", get_name (), get_handle ()); - /* Delete all POSIX locks on the file. Delete all flock locks on the - file if this is the last reference to this file. */ - if (unique_id) - del_my_locks (on_close); - if (nohandle () || CloseHandle (get_handle ())) - res = 0; - else - { - paranoid_printf ("CloseHandle (%d <%s>) failed", get_handle (), - get_name ()); - - __seterrno (); - } - destroy_overlapped (); - return res; -} - -int -fhandler_base::ioctl (unsigned int cmd, void *buf) -{ - int res; - - switch (cmd) - { - case FIONBIO: - set_nonblocking (*(int *) buf); - res = 0; - break; - default: - set_errno (EINVAL); - res = -1; - break; - } - - syscall_printf ("%d = ioctl (%x, %p)", res, cmd, buf); - return res; -} - -int -fhandler_base::lock (int, struct __flock64 *) -{ - set_errno (EINVAL); - return -1; -} - -int __stdcall -fhandler_base::fstat (struct __stat64 *buf) -{ - debug_printf ("here"); - - if (is_fs_special ()) - return fstat_fs (buf); - - switch (get_device ()) - { - case FH_PIPE: - buf->st_mode = S_IFIFO | S_IRUSR | S_IWUSR; - break; - case FH_PIPEW: - buf->st_mode = S_IFIFO | S_IWUSR; - break; - case FH_PIPER: - buf->st_mode = S_IFIFO | S_IRUSR; - break; - case FH_FULL: - buf->st_mode = S_IFCHR | S_IRUSR | S_IWUSR | S_IWGRP | S_IWOTH; - break; - default: - buf->st_mode = S_IFCHR | STD_RBITS | STD_WBITS | S_IWGRP | S_IWOTH; - break; - } - - buf->st_uid = geteuid32 (); - buf->st_gid = getegid32 (); - buf->st_nlink = 1; - buf->st_blksize = PREFERRED_IO_BLKSIZE; - buf->st_ctim.tv_sec = 1164931200L; /* Arbitrary value: 2006-12-01 */ - buf->st_ctim.tv_nsec = 0L; - buf->st_atim = buf->st_mtim = buf->st_birthtim = buf->st_ctim; - return 0; -} - -int __stdcall -fhandler_base::fstatvfs (struct statvfs *sfs) -{ - /* If we hit this base implementation, it's some device in /dev. - Just call statvfs on /dev for simplicity. */ - path_conv pc ("/dev"); - fhandler_disk_file fh (pc); - return fh.fstatvfs (sfs); -} - -int -fhandler_base::init (HANDLE f, DWORD a, mode_t bin) -{ - set_io_handle (f); - access = a; - a &= GENERIC_READ | GENERIC_WRITE; - int flags = 0; - if (a == GENERIC_READ) - flags = O_RDONLY; - else if (a == GENERIC_WRITE) - flags = O_WRONLY; - else if (a == (GENERIC_READ | GENERIC_WRITE)) - flags = O_RDWR; - set_flags (flags | bin); - set_open_status (); - debug_printf ("created new fhandler_base for handle %p, bin %d", f, rbinary ()); - return 1; -} - -int -fhandler_base::dup (fhandler_base *child) -{ - debug_printf ("in fhandler_base dup"); - - HANDLE nh; - if (!nohandle ()) - { - if (!DuplicateHandle (GetCurrentProcess (), get_handle (), - GetCurrentProcess (), &nh, - 0, TRUE, DUPLICATE_SAME_ACCESS)) - { - debug_printf ("dup(%s) failed, handle %x, %E", - get_name (), get_handle ()); - __seterrno (); - return -1; - } - - VerifyHandle (nh); - child->set_io_handle (nh); - } - if (get_overlapped ()) - child->setup_overlapped (); - return 0; -} - -int fhandler_base::fcntl (int cmd, void *arg) -{ - int res; - - switch (cmd) - { - case F_GETFD: - res = close_on_exec () ? FD_CLOEXEC : 0; - break; - case F_SETFD: - set_close_on_exec (((int) arg & FD_CLOEXEC) ? 1 : 0); - res = 0; - break; - case F_GETFL: - res = get_flags (); - debug_printf ("GETFL: %p", res); - break; - case F_SETFL: - { - /* Only O_APPEND, O_ASYNC and O_NONBLOCK/O_NDELAY are allowed. - Each other flag will be ignored. - Since O_ASYNC isn't defined in fcntl.h it's currently - ignored as well. */ - const int allowed_flags = O_APPEND | O_NONBLOCK_MASK; - int new_flags = (int) arg & allowed_flags; - /* Carefully test for the O_NONBLOCK or deprecated OLD_O_NDELAY flag. - Set only the flag that has been passed in. If both are set, just - record O_NONBLOCK. */ - if ((new_flags & OLD_O_NDELAY) && (new_flags & O_NONBLOCK)) - new_flags &= ~OLD_O_NDELAY; - set_flags ((get_flags () & ~allowed_flags) | new_flags); - } - res = 0; - break; - default: - set_errno (EINVAL); - res = -1; - break; - } - return res; -} - -/* Base terminal handlers. These just return errors. */ - -int -fhandler_base::tcflush (int) -{ - set_errno (ENOTTY); - return -1; -} - -int -fhandler_base::tcsendbreak (int) -{ - set_errno (ENOTTY); - return -1; -} - -int -fhandler_base::tcdrain () -{ - set_errno (ENOTTY); - return -1; -} - -int -fhandler_base::tcflow (int) -{ - set_errno (ENOTTY); - return -1; -} - -int -fhandler_base::tcsetattr (int, const struct termios *) -{ - set_errno (ENOTTY); - return -1; -} - -int -fhandler_base::tcgetattr (struct termios *) -{ - set_errno (ENOTTY); - return -1; -} - -int -fhandler_base::tcsetpgrp (const pid_t) -{ - set_errno (ENOTTY); - return -1; -} - -int -fhandler_base::tcgetpgrp () -{ - set_errno (ENOTTY); - return -1; -} - -void -fhandler_base::operator delete (void *p) -{ - cfree (p); -} - -/* Normal I/O constructor */ -fhandler_base::fhandler_base () : - status (), - open_status (), - access (0), - io_handle (NULL), - ino (0), - openflags (0), - rabuf (NULL), - ralen (0), - raixget (0), - raixput (0), - rabuflen (0), - unique_id (0), - archetype (NULL), - usecount (0) -{ -} - -/* Normal I/O destructor */ -fhandler_base::~fhandler_base () -{ - if (rabuf) - free (rabuf); -} - -/**********************************************************************/ -/* /dev/null */ - -fhandler_dev_null::fhandler_dev_null () : - fhandler_base () -{ -} - -void -fhandler_base::set_no_inheritance (HANDLE &h, bool not_inheriting) -{ - if (!SetHandleInformation (h, HANDLE_FLAG_INHERIT, - not_inheriting ? 0 : HANDLE_FLAG_INHERIT)) - debug_printf ("SetHandleInformation failed, %E"); -#ifdef DEBUGGING_AND_FDS_PROTECTED - if (h) - setclexec (oh, h, not_inheriting); -#endif -} - -bool -fhandler_base::fork_fixup (HANDLE parent, HANDLE &h, const char *name) -{ - HANDLE oh = h; - bool res = false; - if (/* !is_socket () && */ !close_on_exec ()) - debug_printf ("handle %p already opened", h); - else if (!DuplicateHandle (parent, h, GetCurrentProcess (), &h, - 0, !close_on_exec (), DUPLICATE_SAME_ACCESS)) - system_printf ("%s - %E, handle %s<%p>", get_name (), name, h); - else - { - if (oh != h) - VerifyHandle (h); - res = true; - } - if (get_overlapped ()) - setup_overlapped (); - return res; -} - -void -fhandler_base::set_close_on_exec (bool val) -{ - if (!nohandle ()) - set_no_inheritance (io_handle, val); - close_on_exec (val); - debug_printf ("set close_on_exec for %s to %d", get_name (), val); -} - -void -fhandler_base::fixup_after_fork (HANDLE parent) -{ - debug_printf ("inheriting '%s' from parent", get_name ()); - if (!nohandle ()) - fork_fixup (parent, io_handle, "io_handle"); - if (get_overlapped ()) - setup_overlapped (); - /* POSIX locks are not inherited across fork. */ - if (unique_id) - del_my_locks (after_fork); -} - -void -fhandler_base::fixup_after_exec () -{ - debug_printf ("here for '%s'", get_name ()); - if (get_overlapped ()) - setup_overlapped (); - if (unique_id && close_on_exec ()) - del_my_locks (after_exec); -} - -bool -fhandler_base::is_nonblocking () -{ - return (openflags & O_NONBLOCK_MASK) != 0; -} - -void -fhandler_base::set_nonblocking (int yes) -{ - int current = openflags & O_NONBLOCK_MASK; - int new_flags = yes ? (!current ? O_NONBLOCK : current) : 0; - openflags = (openflags & ~O_NONBLOCK_MASK) | new_flags; -} - -int -fhandler_base::mkdir (mode_t) -{ - if (exists ()) - set_errno (EEXIST); - else - set_errno (EROFS); - return -1; -} - -int -fhandler_base::rmdir () -{ - if (!exists ()) - set_errno (ENOENT); - else if (!pc.isdir ()) - set_errno (ENOTDIR); - else - set_errno (EROFS); - return -1; -} - -DIR * -fhandler_base::opendir (int fd) -{ - set_errno (ENOTDIR); - return NULL; -} - -int -fhandler_base::readdir (DIR *, dirent *) -{ - return ENOTDIR; -} - -_off64_t -fhandler_base::telldir (DIR *) -{ - set_errno (ENOTDIR); - return -1; -} - -void -fhandler_base::seekdir (DIR *, _off64_t) -{ - set_errno (ENOTDIR); -} - -void -fhandler_base::rewinddir (DIR *) -{ - set_errno (ENOTDIR); -} - -int -fhandler_base::closedir (DIR *) -{ - set_errno (ENOTDIR); - return -1; -} - -int -fhandler_base::fchmod (mode_t mode) -{ - extern int chmod_device (path_conv& pc, mode_t mode); - if (pc.is_fs_special ()) - return chmod_device (pc, mode); - /* By default, just succeeds. */ - return 0; -} - -int -fhandler_base::fchown (__uid32_t uid, __gid32_t gid) -{ - if (pc.is_fs_special ()) - return ((fhandler_disk_file *) this)->fhandler_disk_file::fchown (uid, gid); - /* By default, just succeeds. */ - return 0; -} - -int -fhandler_base::facl (int cmd, int nentries, __aclent32_t *aclbufp) -{ - int res = -1; - switch (cmd) - { - case SETACL: - /* By default, just succeeds. */ - res = 0; - break; - case GETACL: - if (!aclbufp) - set_errno(EFAULT); - else if (nentries < MIN_ACL_ENTRIES) - set_errno (ENOSPC); - else - { - aclbufp[0].a_type = USER_OBJ; - aclbufp[0].a_id = myself->uid; - aclbufp[0].a_perm = (S_IRUSR | S_IWUSR) >> 6; - aclbufp[1].a_type = GROUP_OBJ; - aclbufp[1].a_id = myself->gid; - aclbufp[1].a_perm = (S_IRGRP | S_IWGRP) >> 3; - aclbufp[2].a_type = OTHER_OBJ; - aclbufp[2].a_id = ILLEGAL_GID; - aclbufp[2].a_perm = S_IROTH | S_IWOTH; - aclbufp[3].a_type = CLASS_OBJ; - aclbufp[3].a_id = ILLEGAL_GID; - aclbufp[3].a_perm = S_IRWXU | S_IRWXG | S_IRWXO; - res = MIN_ACL_ENTRIES; - } - break; - case GETACLCNT: - res = MIN_ACL_ENTRIES; - break; - default: - set_errno (EINVAL); - break; - } - return res; -} - -ssize_t -fhandler_base::fgetxattr (const char *name, void *value, size_t size) -{ - set_errno (ENOTSUP); - return -1; -} - -int -fhandler_base::fsetxattr (const char *name, const void *value, size_t size, - int flags) -{ - set_errno (ENOTSUP); - return -1; -} - -int -fhandler_base::fadvise (_off64_t offset, _off64_t length, int advice) -{ - set_errno (EINVAL); - return -1; -} - -int -fhandler_base::ftruncate (_off64_t length, bool allow_truncate) -{ - set_errno (EINVAL); - return -1; -} - -int -fhandler_base::link (const char *newpath) -{ - set_errno (EPERM); - return -1; -} - -int -fhandler_base::utimens (const struct timespec *tvp) -{ - if (is_fs_special ()) - return utimens_fs (tvp); - - set_errno (EINVAL); - return -1; -} - -int -fhandler_base::fsync () -{ - if (!get_handle () || nohandle ()) - { - set_errno (EINVAL); - return -1; - } - if (pc.isdir ()) /* Just succeed. */ - return 0; - if (FlushFileBuffers (get_handle ())) - return 0; - __seterrno (); - return -1; -} - -int -fhandler_base::fpathconf (int v) -{ - int ret; - - switch (v) - { - case _PC_LINK_MAX: - return pc.fs_is_ntfs () || pc.fs_is_samba () || pc.fs_is_nfs () - ? LINK_MAX : 1; - case _PC_MAX_CANON: - if (is_tty ()) - return MAX_CANON; - set_errno (EINVAL); - break; - case _PC_MAX_INPUT: - if (is_tty ()) - return MAX_INPUT; - set_errno (EINVAL); - break; - case _PC_NAME_MAX: - /* NAME_MAX is without trailing \0 */ - if (!pc.isdir ()) - return NAME_MAX; - ret = NT_MAX_PATH - strlen (get_name ()) - 2; - return ret < 0 ? 0 : ret > NAME_MAX ? NAME_MAX : ret; - case _PC_PATH_MAX: - /* PATH_MAX is with trailing \0 */ - if (!pc.isdir ()) - return PATH_MAX; - ret = NT_MAX_PATH - strlen (get_name ()) - 1; - return ret < 0 ? 0 : ret > PATH_MAX ? PATH_MAX : ret; - case _PC_PIPE_BUF: - if (pc.isdir () - || get_device () == FH_FIFO || get_device () == FH_PIPE - || get_device () == FH_PIPER || get_device () == FH_PIPEW) - return PIPE_BUF; - set_errno (EINVAL); - break; - case _PC_CHOWN_RESTRICTED: - return 1; - case _PC_NO_TRUNC: - return 1; - case _PC_VDISABLE: - if (is_tty ()) - return _POSIX_VDISABLE; - set_errno (EINVAL); - break; - case _PC_ASYNC_IO: - case _PC_PRIO_IO: - break; - case _PC_SYNC_IO: - return 1; - case _PC_FILESIZEBITS: - return FILESIZEBITS; - case _PC_2_SYMLINKS: - return 1; - case _PC_SYMLINK_MAX: - return SYMLINK_MAX; - case _PC_POSIX_PERMISSIONS: - case _PC_POSIX_SECURITY: - if (get_device () == FH_FS) - return pc.has_acls () || pc.fs_is_nfs (); - set_errno (EINVAL); - break; - default: - set_errno (EINVAL); - break; - } - return -1; -} - -/* Overlapped I/O */ - -bool -fhandler_base::setup_overlapped (bool doit) -{ - OVERLAPPED *ov = get_overlapped_buffer (); - memset (ov, 0, sizeof (*ov)); - bool res; - if (doit) - { - set_overlapped (ov); - res = !!(ov->hEvent = CreateEvent (&sec_none_nih, true, false, NULL)); - } - else - { - set_overlapped (NULL); - res = false; - } - return res; -} - -void -fhandler_base::destroy_overlapped () -{ - OVERLAPPED *ov = get_overlapped (); - if (ov && ov->hEvent) - { - CloseHandle (ov->hEvent); - ov->hEvent = NULL; - } -} - -int -fhandler_base::wait_overlapped (bool inres, bool writing, DWORD *bytes, DWORD len) -{ - if (!get_overlapped ()) - return inres; - - int res = 0; - - DWORD err = GetLastError (); - if (is_nonblocking ()) - { - if (inres || err == ERROR_IO_PENDING) - { - if (writing && !inres) - *bytes = len; /* This really isn't true but it seems like - this is a corner-case for linux's - non-blocking I/O implementation. How can - you know how many bytes were written until - the I/O operation really completes? */ - res = 1; - err = 0; - } - } - else if (inres || err == ERROR_IO_PENDING) - { -#ifdef DEBUGGING - if (!get_overlapped ()->hEvent) - system_printf ("hEvent is zero?"); -#endif - DWORD n = 1; - HANDLE w4[2]; - w4[0] = get_overlapped ()->hEvent; - if (&_my_tls == _main_tls) - w4[n++] = signal_arrived; - HANDLE h = writing ? get_output_handle () : get_handle (); - DWORD wfres = WaitForMultipleObjects (n, w4, false, INFINITE); - if (wfres != WAIT_OBJECT_0) - CancelIo (h); - BOOL wores = GetOverlappedResult (h, get_overlapped (), bytes, false); - bool signalled = !wores && (wfres == WAIT_OBJECT_0 + 1); - if (signalled) - { - debug_printf ("got a signal"); - set_errno (EINTR); - *bytes = (DWORD) -1; - res = 0; - err = 0; - } - else if (!wores) - { - err = GetLastError (); - debug_printf ("GetOverLappedResult failed"); - } - else - { - debug_printf ("normal %s, %u bytes", writing ? "write" : "read", *bytes); - res = 1; - err = 0; - } - } - - if (!err) - /* nothing to do */; - else if (err != ERROR_HANDLE_EOF && err != ERROR_BROKEN_PIPE) - { - debug_printf ("err %u", err); - __seterrno_from_win_error (err); - *bytes = (DWORD) -1; - res = 0; - } - else - { - res = 1; - *bytes = 0; - err = 0; - debug_printf ("EOF"); - } - - if (writing && (err == ERROR_NO_DATA || err == ERROR_BROKEN_PIPE)) - raise (SIGPIPE); - return res; -} - -void __stdcall -fhandler_base::read_overlapped (void *ptr, size_t& len) -{ - DWORD nbytes; - while (1) - { - bool res = ReadFile (get_handle (), ptr, len, &nbytes, - get_overlapped ()); - int wres = wait_overlapped (res, false, &nbytes); - if (wres || !_my_tls.call_signal_handler ()) - break; - } - len = (size_t) nbytes; -} - -ssize_t __stdcall -fhandler_base::write_overlapped (const void *ptr, size_t len) -{ - DWORD nbytes; - while (1) - { - bool res = WriteFile (get_output_handle (), ptr, len, &nbytes, - get_overlapped ()); - int wres = wait_overlapped (res, true, &nbytes, (size_t) len); - if (wres || !_my_tls.call_signal_handler ()) - break; - } - debug_printf ("returning %u", nbytes); - return nbytes; -} diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h deleted file mode 100644 index d1130d4ea..000000000 --- a/winsup/cygwin/fhandler.h +++ /dev/null @@ -1,1446 +0,0 @@ -/* fhandler.h - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _FHANDLER_H_ -#define _FHANDLER_H_ - -/* fcntl flags used only internaly. */ -#define O_NOSYMLINK 0x080000 -#define O_DIROPEN 0x100000 - -/* newlib used to define O_NDELAY differently from O_NONBLOCK. Now it - properly defines both to be the same. Unfortunately, we have to - behave properly the old version, too, to accommodate older executables. */ -#define OLD_O_NDELAY (CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK ? 4 : 0) - -/* Care for the old O_NDELAY flag. If one of the flags is set, - both flags are set. */ -#define O_NONBLOCK_MASK (O_NONBLOCK | OLD_O_NDELAY) - -/* It appears that 64K is the block size used for buffered I/O on NT. - Using this blocksize in read/write calls in the application results - in a much better performance than using smaller values. */ -#define PREFERRED_IO_BLKSIZE ((blksize_t) 65536) - -extern const char *windows_device_names[]; -extern struct __cygwin_perfile *perfile_table; -#define __fmode (*(user_data->fmode_ptr)) -extern const char proc[]; -extern const int proc_len; - -class select_record; -class select_stuff; -class fhandler_disk_file; -class inode_t; -typedef struct __DIR DIR; -struct dirent; -struct iovec; -struct __acl32; - -enum dirent_states -{ - dirent_ok = 0x0000, - dirent_saw_dot = 0x0001, - dirent_saw_dot_dot = 0x0002, - dirent_saw_eof = 0x0004, - dirent_isroot = 0x0008, - dirent_set_d_ino = 0x0010, - dirent_get_d_ino = 0x0020, - dirent_nfs_d_ino = 0x0040, - - /* Global flags which must not be deleted on rewinddir or seekdir. */ - dirent_info_mask = 0x0078 -}; - -enum conn_state -{ - unconnected = 0, - connect_pending = 1, - connected = 2, - connect_failed = 3 -}; - -enum line_edit_status -{ - line_edit_ok = 0, - line_edit_input_done = 1, - line_edit_signalled = 2, - line_edit_error = 3, - line_edit_pipe_full = 4 -}; - -enum bg_check_types -{ - bg_error = -1, - bg_eof = 0, - bg_ok = 1, - bg_signalled = 2 -}; - -enum query_state { - no_query = 0, - query_read_control = 1, - query_read_attributes = 2, - query_write_control = 3, - query_write_attributes = 4 -}; - -enum del_lock_called_from { - on_close, - after_fork, - after_exec -}; - -class fhandler_base -{ - friend class dtable; - friend void close_all_files (bool); - - struct status_flags - { - unsigned rbinary : 1; /* binary read mode */ - unsigned rbinset : 1; /* binary read mode explicitly set */ - unsigned wbinary : 1; /* binary write mode */ - unsigned wbinset : 1; /* binary write mode explicitly set */ - unsigned nohandle : 1; /* No handle associated with fhandler. */ - unsigned uninterruptible_io : 1; /* Set if I/O should be uninterruptible. */ - unsigned did_lseek : 1; /* set when lseek is called as a flag that - _write should check if we've moved - beyond EOF, zero filling or making - file sparse if so. */ - unsigned query_open : 3; /* open file without requesting either - read or write access */ - unsigned close_on_exec : 1; /* close-on-exec */ - unsigned need_fork_fixup : 1; /* Set if need to fixup after fork. */ - - public: - status_flags () : - rbinary (0), rbinset (0), wbinary (0), wbinset (0), nohandle (0), - uninterruptible_io (0), did_lseek (0), - query_open (no_query), close_on_exec (0), need_fork_fixup (0) - {} - } status, open_status; - - private: - int access; - HANDLE io_handle; - - __ino64_t ino; /* file ID or hashed filename, depends on FS. */ - - protected: - /* File open flags from open () and fcntl () calls */ - int openflags; - - char *rabuf; /* used for crlf conversion in text files */ - size_t ralen; - size_t raixget; - size_t raixput; - size_t rabuflen; - - /* Used for advisory file locking. See flock.cc. */ - long long unique_id; - void del_my_locks (del_lock_called_from); - - HANDLE read_state; - int wait_overlapped (bool, bool, DWORD *, DWORD = 0) __attribute__ ((regparm (3))); - bool setup_overlapped (bool doit = true) __attribute__ ((regparm (2))); - void destroy_overlapped () __attribute__ ((regparm (1))); - - public: - class fhandler_base *archetype; - int usecount; - - path_conv pc; - - virtual void set_name (path_conv &pc); - virtual void set_name (const char *s) {pc.set_normalized_path (s);} - int error () const {return pc.error;} - void set_error (int error) {pc.error = error;} - bool exists () const {return pc.exists ();} - int pc_binmode () const {return pc.binmode ();} - device& dev () {return pc.dev;} - operator DWORD& () {return (DWORD&) pc;} - virtual size_t size () const {return sizeof (*this);} - - virtual fhandler_base& operator =(fhandler_base &x); - fhandler_base (); - virtual ~fhandler_base (); - - /* Non-virtual simple accessor functions. */ - void set_io_handle (HANDLE x) { io_handle = x; } - - DWORD& get_device () { return dev ().devn; } - DWORD get_major () { return dev ().major; } - DWORD get_minor () { return dev ().minor; } - virtual int get_unit () { return dev ().minor; } - - int get_access () const { return access; } - void set_access (int x) { access = x; } - - int get_flags () { return openflags; } - void set_flags (int x, int supplied_bin = 0); - - bool is_nonblocking (); - void set_nonblocking (int); - - bool wbinary () const { return status.wbinset ? status.wbinary : 1; } - bool rbinary () const { return status.rbinset ? status.rbinary : 1; } - - void wbinary (bool b) {status.wbinary = b; status.wbinset = 1;} - void rbinary (bool b) {status.rbinary = b; status.rbinset = 1;} - - void set_open_status () {open_status = status;} - void reset_to_open_binmode () - { - set_flags ((get_flags () & ~(O_TEXT | O_BINARY)) - | ((open_status.wbinary || open_status.rbinary) - ? O_BINARY : O_TEXT)); - } - - IMPLEMENT_STATUS_FLAG (bool, wbinset) - IMPLEMENT_STATUS_FLAG (bool, rbinset) - IMPLEMENT_STATUS_FLAG (bool, nohandle) - IMPLEMENT_STATUS_FLAG (bool, uninterruptible_io) - IMPLEMENT_STATUS_FLAG (bool, did_lseek) - IMPLEMENT_STATUS_FLAG (query_state, query_open) - IMPLEMENT_STATUS_FLAG (bool, close_on_exec) - IMPLEMENT_STATUS_FLAG (bool, need_fork_fixup) - - int get_default_fmode (int flags); - - virtual void set_close_on_exec (bool val); - - LPSECURITY_ATTRIBUTES get_inheritance (bool all = 0) - { - if (all) - return close_on_exec () ? &sec_all_nih : &sec_all; - else - return close_on_exec () ? &sec_none_nih : &sec_none; - } - - virtual int fixup_before_fork_exec (DWORD) { return 0; } - virtual void fixup_after_fork (HANDLE); - virtual void fixup_after_exec (); - void create_read_state (LONG n) - { - read_state = CreateSemaphore (&sec_none_nih, 0, n, NULL); - ProtectHandle (read_state); - } - - void signal_read_state (LONG n) - { - ReleaseSemaphore (read_state, n, NULL); - } - - bool get_readahead_valid () { return raixget < ralen; } - int puts_readahead (const char *s, size_t len = (size_t) -1); - int put_readahead (char value); - - int get_readahead (); - int peek_readahead (int queryput = 0); - - int eat_readahead (int n); - - void set_readahead_valid (int val, int ch = -1); - - int get_readahead_into_buffer (char *buf, size_t buflen); - - bool has_acls () const { return pc.has_acls (); } - - bool isremote () { return pc.isremote (); } - - bool has_attribute (DWORD x) const {return pc.has_attribute (x);} - const char *get_name () const { return pc.normalized_path; } - const char *get_win32_name () { return pc.get_win32 (); } - __dev32_t get_dev () { return pc.fs_serial_number (); } - __ino64_t get_ino () { return ino ?: ino = hash_path_name (0, pc.get_nt_native_path ()); } - long long get_unique_id () const { return unique_id; } - /* Returns name used for /proc//fd in buf. */ - virtual char *get_proc_fd_name (char *buf); - - virtual void hclose (HANDLE h) {CloseHandle (h);} - virtual void set_no_inheritance (HANDLE &, bool); - - /* fixup fd possibly non-inherited handles after fork */ - bool fork_fixup (HANDLE, HANDLE &, const char *); - virtual bool need_fixup_before () const {return false;} - - virtual int open (int, mode_t = 0); - int open_fs (int, mode_t = 0); - virtual int close (); - int close_fs () { return fhandler_base::close (); } - virtual int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2))); - int __stdcall fstat_fs (struct __stat64 *buf) __attribute__ ((regparm (2))); - int __stdcall fstat_helper (struct __stat64 *buf, - PLARGE_INTEGER ChangeTime, - PLARGE_INTEGER LastAccessTime, - PLARGE_INTEGER LastWriteTime, - PLARGE_INTEGER CreationTime, - DWORD dwVolumeSerialNumber, - ULONGLONG nFileSize, - LONGLONG nAllocSize, - ULONGLONG nFileIndex, - DWORD nNumberOfLinks, - DWORD dwFileAttributes) - __attribute__ ((regparm (3))); - int __stdcall fstat_by_nfs_ea (struct __stat64 *buf) __attribute__ ((regparm (2))); - int __stdcall fstat_by_handle (struct __stat64 *buf) __attribute__ ((regparm (2))); - int __stdcall fstat_by_name (struct __stat64 *buf) __attribute__ ((regparm (2))); - virtual int __stdcall fstatvfs (struct statvfs *buf) __attribute__ ((regparm (2))); - int utimens_fs (const struct timespec *) __attribute__ ((regparm (2))); - virtual int __stdcall fchmod (mode_t mode) __attribute__ ((regparm (1))); - virtual int __stdcall fchown (__uid32_t uid, __gid32_t gid) __attribute__ ((regparm (2))); - virtual int __stdcall facl (int, int, __acl32 *) __attribute__ ((regparm (3))); - virtual ssize_t __stdcall fgetxattr (const char *, void *, size_t) __attribute__ ((regparm (3))); - virtual int __stdcall fsetxattr (const char *, const void *, size_t, int) __attribute__ ((regparm (3))); - virtual int __stdcall fadvise (_off64_t, _off64_t, int) __attribute__ ((regparm (3))); - virtual int __stdcall ftruncate (_off64_t, bool) __attribute__ ((regparm (3))); - virtual int __stdcall link (const char *) __attribute__ ((regparm (2))); - virtual int __stdcall utimens (const struct timespec *) __attribute__ ((regparm (2))); - virtual int __stdcall fsync () __attribute__ ((regparm (1))); - virtual int ioctl (unsigned int cmd, void *); - virtual int fcntl (int cmd, void *); - virtual char const *ttyname () { return get_name (); } - virtual void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); - virtual void __stdcall read_overlapped (void *ptr, size_t& len) __attribute__ ((regparm (3))); - virtual ssize_t __stdcall write (const void *ptr, size_t len); - virtual ssize_t __stdcall write_overlapped (const void *ptr, size_t len); - virtual ssize_t __stdcall readv (const struct iovec *, int iovcnt, ssize_t tot = -1); - virtual ssize_t __stdcall writev (const struct iovec *, int iovcnt, ssize_t tot = -1); - virtual ssize_t __stdcall pread (void *, size_t, _off64_t) __attribute__ ((regparm (3))); - virtual ssize_t __stdcall pwrite (void *, size_t, _off64_t) __attribute__ ((regparm (3))); - virtual _off64_t lseek (_off64_t offset, int whence); - virtual int lock (int, struct __flock64 *); - virtual int dup (fhandler_base *child); - virtual int fpathconf (int); - - virtual HANDLE mmap (caddr_t *addr, size_t len, int prot, - int flags, _off64_t off); - virtual int munmap (HANDLE h, caddr_t addr, size_t len); - virtual int msync (HANDLE h, caddr_t addr, size_t len, int flags); - virtual bool fixup_mmap_after_fork (HANDLE h, int prot, int flags, - _off64_t offset, DWORD size, - void *address); - - void *operator new (size_t, void *p) __attribute__ ((nothrow)) {return p;} - - virtual int init (HANDLE, DWORD, mode_t); - - virtual int tcflush (int); - virtual int tcsendbreak (int); - virtual int tcdrain (); - virtual int tcflow (int); - virtual int tcsetattr (int a, const struct termios *t); - virtual int tcgetattr (struct termios *t); - virtual int tcsetpgrp (const pid_t pid); - virtual int tcgetpgrp (); - virtual bool is_tty () const { return false; } - virtual bool ispipe () const { return false; } - virtual pid_t get_popen_pid () const {return 0;} - virtual bool isdevice () const { return true; } - virtual bool isfifo () const { return false; } - virtual char *ptsname () { return NULL;} - virtual class fhandler_socket *is_socket () { return NULL; } - virtual class fhandler_console *is_console () { return 0; } - virtual int is_windows () {return 0; } - - virtual void __stdcall raw_read (void *ptr, size_t& ulen); - virtual ssize_t __stdcall raw_write (const void *ptr, size_t ulen); - virtual OVERLAPPED *get_overlapped () {return NULL;} - virtual OVERLAPPED *get_overlapped_buffer () {return NULL;} - virtual void set_overlapped (OVERLAPPED *) {} - - /* Virtual accessor functions to hide the fact - that some fd's have two handles. */ - virtual HANDLE& get_handle () { return io_handle; } - virtual HANDLE& get_io_handle () { return io_handle; } - virtual HANDLE& get_output_handle () { return io_handle; } - virtual bool hit_eof () {return false;} - virtual select_record *select_read (select_stuff *); - virtual select_record *select_write (select_stuff *); - virtual select_record *select_except (select_stuff *); - virtual int ready_for_read (int fd, DWORD howlong); - virtual const char *get_native_name () - { - return dev ().native; - } - virtual bg_check_types bg_check (int) {return bg_ok;} - void clear_readahead () - { - raixput = raixget = ralen = rabuflen = 0; - rabuf = NULL; - } - void operator delete (void *); - virtual void set_eof () {} - virtual int mkdir (mode_t mode); - virtual int rmdir (); - virtual DIR *opendir (int fd) __attribute__ ((regparm (2))); - virtual int readdir (DIR *, dirent *) __attribute__ ((regparm (3))); - virtual _off64_t telldir (DIR *); - virtual void seekdir (DIR *, _off64_t); - virtual void rewinddir (DIR *); - virtual int closedir (DIR *); - virtual bool is_slow () {return false;} - bool is_auto_device () {return isdevice () && !dev ().isfs ();} - bool is_fs_special () {return pc.is_fs_special ();} - bool issymlink () {return pc.issymlink ();} - bool device_access_denied (int) __attribute__ ((regparm (2))); - int fhaccess (int flags, bool) __attribute__ ((regparm (3))); -}; - -class fhandler_mailslot : public fhandler_base -{ - POBJECT_ATTRIBUTES get_object_attr (OBJECT_ATTRIBUTES &, PUNICODE_STRING, int); - public: - fhandler_mailslot (); - int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2))); - int open (int flags, mode_t mode = 0); - ssize_t __stdcall write (const void *ptr, size_t len); - int ioctl (unsigned int cmd, void *); - select_record *select_read (select_stuff *); -}; - -struct wsa_event -{ - LONG serial_number; - long events; - int connect_errorcode; - pid_t owner; -}; - -class fhandler_socket: public fhandler_base -{ - private: - int addr_family; - int type; - int connect_secret[4]; - - wsa_event *wsock_events; - HANDLE wsock_mtx; - HANDLE wsock_evt; - public: - bool init_events (); - int evaluate_events (const long event_mask, long &events, const bool erase); - const HANDLE wsock_event () const { return wsock_evt; } - const LONG serial_number () const { return wsock_events->serial_number; } - private: - int wait_for_events (const long event_mask, bool dontwait); - void release_events (); - - pid_t sec_pid; - __uid32_t sec_uid; - __gid32_t sec_gid; - pid_t sec_peer_pid; - __uid32_t sec_peer_uid; - __gid32_t sec_peer_gid; - void af_local_set_secret (char *); - void af_local_setblocking (bool &, bool &); - void af_local_unsetblocking (bool, bool); - void af_local_set_cred (); - void af_local_copy (fhandler_socket *); - bool af_local_recv_secret (); - bool af_local_send_secret (); - bool af_local_recv_cred (); - bool af_local_send_cred (); - int af_local_accept (); - public: - int af_local_connect (); - void af_local_set_sockpair_cred (); - - private: - int _rmem; - int _wmem; - public: - int &rmem () { return _rmem; } - int &wmem () { return _wmem; } - void rmem (int nrmem) { _rmem = nrmem; } - void wmem (int nwmem) { _wmem = nwmem; } - - private: - struct _WSAPROTOCOL_INFOW *prot_info_ptr; - public: - void init_fixup_before (); - bool need_fixup_before () const {return prot_info_ptr != NULL;} - - private: - char *sun_path; - char *peer_sun_path; - struct status_flags - { - unsigned async_io : 1; /* async I/O */ - unsigned saw_shutdown_read : 1; /* Socket saw a SHUT_RD */ - unsigned saw_shutdown_write : 1; /* Socket saw a SHUT_WR */ - unsigned saw_reuseaddr : 1; /* Socket saw SO_REUSEADDR call */ - unsigned listener : 1; /* listen called */ - unsigned connect_state : 2; - public: - status_flags () : - async_io (0), saw_shutdown_read (0), saw_shutdown_write (0), - listener (0), connect_state (unconnected) - {} - } status; - - public: - fhandler_socket (); - ~fhandler_socket (); - int get_socket () { return (int) get_handle(); } - fhandler_socket *is_socket () { return this; } - - IMPLEMENT_STATUS_FLAG (bool, async_io) - IMPLEMENT_STATUS_FLAG (bool, saw_shutdown_read) - IMPLEMENT_STATUS_FLAG (bool, saw_shutdown_write) - IMPLEMENT_STATUS_FLAG (bool, saw_reuseaddr) - IMPLEMENT_STATUS_FLAG (bool, listener) - IMPLEMENT_STATUS_FLAG (conn_state, connect_state) - - int bind (const struct sockaddr *name, int namelen); - int connect (const struct sockaddr *name, int namelen); - int listen (int backlog); - int accept4 (struct sockaddr *peer, int *len, int flags); - int getsockname (struct sockaddr *name, int *namelen); - int getpeername (struct sockaddr *name, int *namelen); - int getpeereid (pid_t *pid, __uid32_t *euid, __gid32_t *egid); - - int open (int flags, mode_t mode = 0); - ssize_t __stdcall readv (const struct iovec *, int iovcnt, ssize_t tot = -1); - inline ssize_t recv_internal (struct _WSAMSG *wsamsg); - ssize_t recvfrom (void *ptr, size_t len, int flags, - struct sockaddr *from, int *fromlen); - ssize_t recvmsg (struct msghdr *msg, int flags); - - ssize_t __stdcall writev (const struct iovec *, int iovcnt, ssize_t tot = -1); - inline ssize_t send_internal (struct _WSAMSG *wsamsg, int flags); - ssize_t sendto (const void *ptr, size_t len, int flags, - const struct sockaddr *to, int tolen); - ssize_t sendmsg (const struct msghdr *msg, int flags); - - int ioctl (unsigned int cmd, void *); - int fcntl (int cmd, void *); - _off64_t lseek (_off64_t, int) { return 0; } - int shutdown (int how); - int close (); - void hclose (HANDLE) {close ();} - int dup (fhandler_base *child); - - void set_close_on_exec (bool val); - int fixup_before_fork_exec (DWORD); - void fixup_after_fork (HANDLE); - void fixup_after_exec (); - char *get_proc_fd_name (char *buf); - - select_record *select_read (select_stuff *); - select_record *select_write (select_stuff *); - select_record *select_except (select_stuff *); - int ready_for_read (int, DWORD) { return true; } - void set_addr_family (int af) {addr_family = af;} - int get_addr_family () {return addr_family;} - void set_socket_type (int st) { type = st;} - int get_socket_type () {return type;} - void set_sun_path (const char *path); - char *get_sun_path () {return sun_path;} - void set_peer_sun_path (const char *path); - char *get_peer_sun_path () {return peer_sun_path;} - - int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2))); - int __stdcall fstatvfs (struct statvfs *buf) __attribute__ ((regparm (2))); - int __stdcall fchmod (mode_t mode) __attribute__ ((regparm (1))); - int __stdcall fchown (__uid32_t uid, __gid32_t gid) __attribute__ ((regparm (2))); - int __stdcall facl (int, int, __acl32 *) __attribute__ ((regparm (3))); - int __stdcall link (const char *) __attribute__ ((regparm (2))); - bool is_slow () {return true;} -}; - -class fhandler_pipe: public fhandler_base -{ -private: - pid_t popen_pid; - OVERLAPPED io_status; - OVERLAPPED *overlapped; -public: - fhandler_pipe (); - - OVERLAPPED *get_overlapped () {return overlapped;} - OVERLAPPED *get_overlapped_buffer () {return &io_status;} - void set_overlapped (OVERLAPPED *ov) {overlapped = ov;} - - bool ispipe() const { return true; } - - void set_popen_pid (pid_t pid) {popen_pid = pid;} - pid_t get_popen_pid () const {return popen_pid;} - _off64_t lseek (_off64_t offset, int whence); - select_record *select_read (select_stuff *); - select_record *select_write (select_stuff *); - select_record *select_except (select_stuff *); - char *get_proc_fd_name (char *buf); - void __stdcall raw_read (void *ptr, size_t& len); - ssize_t __stdcall raw_write (const void *, size_t); - int open (int flags, mode_t mode = 0); - int dup (fhandler_base *child); - int ioctl (unsigned int cmd, void *); - int __stdcall fstatvfs (struct statvfs *buf) __attribute__ ((regparm (2))); - int __stdcall fadvise (_off64_t, _off64_t, int) __attribute__ ((regparm (3))); - int __stdcall ftruncate (_off64_t, bool) __attribute__ ((regparm (3))); - int ready_for_read (int fd, DWORD howlong); - int init (HANDLE, DWORD, mode_t); - static int create (fhandler_pipe *[2], unsigned, int); - static int create_selectable (LPSECURITY_ATTRIBUTES, HANDLE&, HANDLE&, DWORD, const char * = NULL); - friend class fhandler_fifo; -}; - -class fhandler_fifo: public fhandler_base -{ - enum fifo_state - { - fifo_unknown, - fifo_wait_for_client, - fifo_wait_for_server, - fifo_wait_for_next_client, - fifo_eof, - fifo_error, - fifo_eintr, - fifo_ok - }; - fifo_state wait_state; - HANDLE dummy_client; - HANDLE open_nonserver (const char *, unsigned, LPSECURITY_ATTRIBUTES); - OVERLAPPED io_status; - bool wait (bool) __attribute__ ((regparm (1))); - char *fifo_name (char *) __attribute__ ((regparm (2))); -public: - fhandler_fifo (); - void __stdcall raw_read (void *, size_t&); - ssize_t __stdcall raw_write (const void *, size_t); - int open (int, mode_t); - int close (); - int dup (fhandler_base *child); - bool isfifo () const { return true; } - void set_close_on_exec (bool val); - int __stdcall fstatvfs (struct statvfs *buf) __attribute__ ((regparm (2))); - OVERLAPPED *get_overlapped () {return &io_status;} - OVERLAPPED *get_overlapped_buffer () {return &io_status;} - select_record *select_read (select_stuff *); - select_record *select_write (select_stuff *); - select_record *select_except (select_stuff *); -}; - -class fhandler_dev_raw: public fhandler_base -{ - protected: - char *devbuf; - size_t devbufsiz; - size_t devbufstart; - size_t devbufend; - struct status_flags - { - unsigned lastblk_to_read : 1; - public: - status_flags () : lastblk_to_read (0) {} - } status; - - IMPLEMENT_STATUS_FLAG (bool, lastblk_to_read) - - fhandler_dev_raw (); - - public: - ~fhandler_dev_raw (); - - int open (int flags, mode_t mode = 0); - - int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2))); - - int dup (fhandler_base *child); - int ioctl (unsigned int cmd, void *buf); - - void fixup_after_fork (HANDLE); - void fixup_after_exec (); -}; - -class fhandler_dev_floppy: public fhandler_dev_raw -{ - private: - _off64_t drive_size; - unsigned long bytes_per_sector; - struct status_flags - { - unsigned eom_detected : 1; - public: - status_flags () : eom_detected (0) {} - } status; - - IMPLEMENT_STATUS_FLAG (bool, eom_detected) - - inline _off64_t get_current_position (); - int get_drive_info (struct hd_geometry *geo); - - BOOL write_file (const void *buf, DWORD to_write, DWORD *written, int *err); - BOOL read_file (void *buf, DWORD to_read, DWORD *read, int *err); - - public: - fhandler_dev_floppy (); - - int open (int flags, mode_t mode = 0); - int dup (fhandler_base *child); - void __stdcall raw_read (void *ptr, size_t& ulen); - ssize_t __stdcall raw_write (const void *ptr, size_t ulen); - _off64_t lseek (_off64_t offset, int whence); - int ioctl (unsigned int cmd, void *buf); -}; - -class fhandler_dev_tape: public fhandler_dev_raw -{ - HANDLE mt_mtx; - HANDLE mt_evt; - - bool is_rewind_device () { return get_minor () < 128; } - unsigned int driveno () { return (unsigned int) get_minor () & 0x7f; } - void drive_init (); - - inline bool _lock (); - inline int unlock (int ret = 0); - - public: - fhandler_dev_tape (); - - virtual int open (int flags, mode_t mode = 0); - virtual int close (); - - void __stdcall raw_read (void *ptr, size_t& ulen); - ssize_t __stdcall raw_write (const void *ptr, size_t ulen); - - virtual _off64_t lseek (_off64_t offset, int whence); - - virtual int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2))); - - virtual int dup (fhandler_base *child); - virtual void fixup_after_fork (HANDLE parent); - virtual void set_close_on_exec (bool val); - virtual int ioctl (unsigned int cmd, void *buf); -}; - -/* Standard disk file */ - -class fhandler_disk_file: public fhandler_base -{ - int readdir_helper (DIR *, dirent *, DWORD, DWORD, PUNICODE_STRING fname) __attribute__ ((regparm (3))); - - public: - fhandler_disk_file (); - fhandler_disk_file (path_conv &pc); - - int open (int flags, mode_t mode); - int lock (int, struct __flock64 *); - bool isdevice () const { return false; } - int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2))); - int __stdcall fchmod (mode_t mode) __attribute__ ((regparm (1))); - int __stdcall fchown (__uid32_t uid, __gid32_t gid) __attribute__ ((regparm (2))); - int __stdcall facl (int, int, __acl32 *) __attribute__ ((regparm (3))); - ssize_t __stdcall fgetxattr (const char *, void *, size_t) __attribute__ ((regparm (3))); - int __stdcall fsetxattr (const char *, const void *, size_t, int) __attribute__ ((regparm (3))); - int __stdcall fadvise (_off64_t, _off64_t, int) __attribute__ ((regparm (3))); - int __stdcall ftruncate (_off64_t, bool) __attribute__ ((regparm (3))); - int __stdcall link (const char *) __attribute__ ((regparm (2))); - int __stdcall utimens (const struct timespec *) __attribute__ ((regparm (2))); - int __stdcall fstatvfs (struct statvfs *buf) __attribute__ ((regparm (2))); - - HANDLE mmap (caddr_t *addr, size_t len, int prot, int flags, _off64_t off); - int munmap (HANDLE h, caddr_t addr, size_t len); - int msync (HANDLE h, caddr_t addr, size_t len, int flags); - bool fixup_mmap_after_fork (HANDLE h, int prot, int flags, - _off64_t offset, DWORD size, void *address); - int mkdir (mode_t mode); - int rmdir (); - DIR *opendir (int fd) __attribute__ ((regparm (2))); - int readdir (DIR *, dirent *) __attribute__ ((regparm (3))); - _off64_t telldir (DIR *); - void seekdir (DIR *, _off64_t); - void rewinddir (DIR *); - int closedir (DIR *); - - ssize_t __stdcall pread (void *, size_t, _off64_t) __attribute__ ((regparm (3))); - ssize_t __stdcall pwrite (void *, size_t, _off64_t) __attribute__ ((regparm (3))); -}; - -class fhandler_cygdrive: public fhandler_disk_file -{ - enum - { - DRVSZ = sizeof ("x:\\") - }; - int ndrives; - const char *pdrive; - char pdrive_buf[1 + (2 * 26 * DRVSZ)]; - void set_drives (); - public: - fhandler_cygdrive (); - int open (int flags, mode_t mode); - int close (); - DIR *opendir (int fd) __attribute__ ((regparm (2))); - int readdir (DIR *, dirent *) __attribute__ ((regparm (3))); - void rewinddir (DIR *); - int closedir (DIR *); - int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2))); -}; - -class fhandler_serial: public fhandler_base -{ - private: - size_t vmin_; /* from termios */ - unsigned int vtime_; /* from termios */ - pid_t pgrp_; - int rts; /* for Windows 9x purposes only */ - int dtr; /* for Windows 9x purposes only */ - - public: - int overlapped_armed; - OVERLAPPED io_status; - DWORD ev; - - /* Constructor */ - fhandler_serial (); - - int open (int flags, mode_t mode); - int close (); - int init (HANDLE h, DWORD a, mode_t flags); - void overlapped_setup (); - int dup (fhandler_base *child); - void __stdcall raw_read (void *ptr, size_t& ulen); - ssize_t __stdcall raw_write (const void *ptr, size_t ulen); - int tcsendbreak (int); - int tcdrain (); - int tcflow (int); - int ioctl (unsigned int cmd, void *); - int switch_modem_lines (int set, int clr); - int tcsetattr (int a, const struct termios *t); - int tcgetattr (struct termios *t); - _off64_t lseek (_off64_t, int) { return 0; } - int tcflush (int); - bool is_tty () const { return true; } - void fixup_after_fork (HANDLE parent); - void fixup_after_exec (); - - /* We maintain a pgrp so that tcsetpgrp and tcgetpgrp work, but we - don't use it for permissions checking. fhandler_tty_slave does - permission checking on pgrps. */ - virtual int tcgetpgrp () { return pgrp_; } - virtual int tcsetpgrp (const pid_t pid) { pgrp_ = pid; return 0; } - select_record *select_read (select_stuff *); - select_record *select_write (select_stuff *); - select_record *select_except (select_stuff *); - bool is_slow () {return true;} -}; - -#define acquire_output_mutex(ms) \ - __acquire_output_mutex (__PRETTY_FUNCTION__, __LINE__, ms) - -#define release_output_mutex() \ - __release_output_mutex (__PRETTY_FUNCTION__, __LINE__) - -class tty; -class tty_min; -class fhandler_termios: public fhandler_base -{ - protected: - HANDLE output_handle; - virtual void doecho (const void *, DWORD) {}; - virtual int accept_input () {return 1;}; - public: - tty_min *tc; - fhandler_termios () : - fhandler_base () - { - need_fork_fixup (true); - } - HANDLE& get_output_handle () { return output_handle; } - line_edit_status line_edit (const char *rptr, int nread, termios&); - void set_output_handle (HANDLE h) { output_handle = h; } - void tcinit (tty_min *this_tc, bool force = false); - bool is_tty () const { return true; } - int tcgetpgrp (); - int tcsetpgrp (int pid); - bg_check_types bg_check (int sig); - virtual DWORD __acquire_output_mutex (const char *fn, int ln, DWORD ms) {return 1;} - virtual void __release_output_mutex (const char *fn, int ln) {} - void echo_erase (int force = 0); - virtual _off64_t lseek (_off64_t, int); -}; - -enum ansi_intensity -{ - INTENSITY_INVISIBLE, - INTENSITY_DIM, - INTENSITY_NORMAL, - INTENSITY_BOLD -}; - -#define normal 0 -#define gotesc 1 -#define gotsquare 2 -#define gotarg1 3 -#define gotrsquare 4 -#define gotcommand 5 -#define gettitle 6 -#define eattitle 7 -#define gotparen 8 -#define gotrparen 9 -#define MAXARGS 10 - -class dev_console -{ - WORD default_color, underline_color, dim_color; - - /* Used to determine if an input keystroke should be modified with META. */ - int meta_mask; - -/* Output state */ - int state_; - int args_[MAXARGS]; - int nargs_; - unsigned rarg; - bool saw_question_mark; - bool saw_greater_than_sign; - bool vt100_graphics_mode_active; - bool alternate_charset_active; - bool metabit; - - char my_title_buf [TITLESIZE + 1]; - - WORD current_win32_attr; - ansi_intensity intensity; - bool underline, blink, reverse; - WORD fg, bg; - - /* saved cursor coordinates */ - int savex, savey; - - /* saved screen */ - COORD savebufsiz; - PCHAR_INFO savebuf; - - struct - { - short Top, Bottom; - } scroll_region; - struct - { - SHORT winTop; - SHORT winBottom; - COORD dwWinSize; - COORD dwBufferSize; - COORD dwCursorPosition; - WORD wAttributes; - } info; - - COORD dwLastCursorPosition; - COORD dwMousePosition; /* scroll-adjusted coord of mouse event */ - COORD dwLastMousePosition; /* scroll-adjusted coord of previous mouse event */ - DWORD dwLastButtonState; /* (not noting mouse wheel events) */ - int last_button_code; /* transformed mouse report button code */ - int nModifiers; - - bool insert_mode; - int use_mouse; - bool use_focus; - bool raw_win32_keyboard_mode; - - inline UINT get_console_cp (); - DWORD con_to_str (char *d, int dlen, WCHAR w); - DWORD str_to_con (mbtowc_p, const char *, PWCHAR d, const char *s, DWORD sz); - void set_color (HANDLE); - bool fillin_info (HANDLE); - void set_default_attr (); - - friend class fhandler_console; -}; - -/* This is a input and output console handle */ -class fhandler_console: public fhandler_termios -{ - private: - static const unsigned MAX_WRITE_CHARS; - static dev_console *dev_state; - static bool invisible_console; - - /* Used when we encounter a truncated multi-byte sequence. The - lead bytes are stored here and revisited in the next write call. */ - struct { - int len; - unsigned char buf[4]; /* Max len of valid UTF-8 sequence. */ - } trunc_buf; - PWCHAR write_buf; - -/* Output calls */ - void set_default_attr (); - - void clear_screen (int, int, int, int); - void scroll_screen (int, int, int, int, int, int); - void cursor_set (bool, int, int); - void cursor_get (int *, int *); - void cursor_rel (int, int); - inline void write_replacement_char (); - inline bool write_console (PWCHAR, DWORD, DWORD&); - const unsigned char *write_normal (unsigned const char*, unsigned const char *); - void char_command (char); - bool set_raw_win32_keyboard_mode (bool); - int output_tcsetattr (int a, const struct termios *t); - -/* Input calls */ - int igncr_enabled (); - int input_tcsetattr (int a, const struct termios *t); - void set_cursor_maybe (); - static bool create_invisible_console (HWINSTA); - static bool create_invisible_console_workaround (); - - public: - fhandler_console (); - - fhandler_console* is_console () { return this; } - - int open (int flags, mode_t mode = 0); - - void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); - ssize_t __stdcall write (const void *ptr, size_t len); - void doecho (const void *str, DWORD len) { (void) write (str, len); } - int close (); - - int tcflush (int); - int tcsetattr (int a, const struct termios *t); - int tcgetattr (struct termios *t); - - /* Special dup as we must dup two handles */ - int dup (fhandler_base *child); - - int ioctl (unsigned int cmd, void *); - int init (HANDLE, DWORD, mode_t); - bool mouse_aware (MOUSE_EVENT_RECORD& mouse_event); - bool focus_aware () {return dev_state->use_focus;} - - select_record *select_read (select_stuff *); - select_record *select_write (select_stuff *); - select_record *select_except (select_stuff *); - void fixup_after_fork_exec (bool); - void fixup_after_exec () {fixup_after_fork_exec (true);} - void fixup_after_fork (HANDLE) {fixup_after_fork_exec (false);} - void set_close_on_exec (bool val); - void set_input_state (); - void send_winch_maybe (); - static tty_min *get_tty_stuff (int); - bool is_slow () {return true;} - static bool need_invisible (); - static bool has_a () {return !invisible_console;} -}; - -class fhandler_tty_common: public fhandler_termios -{ - public: - fhandler_tty_common () - : fhandler_termios (), output_done_event (NULL), - ioctl_request_event (NULL), ioctl_done_event (NULL), output_mutex (NULL), - input_mutex (NULL), input_available_event (NULL) - { - // nothing to do - } - HANDLE output_done_event; // Raised by master when tty's output buffer - // written. Write status in tty::write_retval. - HANDLE ioctl_request_event; // Raised by slave to perform ioctl() request. - // Ioctl() request in tty::cmd/arg. - HANDLE ioctl_done_event; // Raised by master on ioctl() completion. - // Ioctl() status in tty::ioctl_retval. - HANDLE output_mutex, input_mutex; - HANDLE input_available_event; - - DWORD __acquire_output_mutex (const char *fn, int ln, DWORD ms); - void __release_output_mutex (const char *fn, int ln); - - tty *get_ttyp () { return (tty *) tc; } - - int close (); - _off64_t lseek (_off64_t, int); - void set_close_on_exec (bool val); - select_record *select_read (select_stuff *); - select_record *select_write (select_stuff *); - select_record *select_except (select_stuff *); - bool is_slow () {return true;} -}; - -class fhandler_tty_slave: public fhandler_tty_common -{ - HANDLE inuse; // used to indicate that a tty is in use - public: - /* Constructor */ - fhandler_tty_slave (); - - int open (int flags, mode_t mode = 0); - ssize_t __stdcall write (const void *ptr, size_t len); - void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); - int init (HANDLE, DWORD, mode_t); - - int tcsetattr (int a, const struct termios *t); - int tcgetattr (struct termios *t); - int tcflush (int); - int ioctl (unsigned int cmd, void *); - int close (); - int dup (fhandler_base *child); - void fixup_after_fork (HANDLE parent); - void fixup_after_exec (); - - select_record *select_read (select_stuff *); - int cygserver_attach_tty (HANDLE*, HANDLE*); - int get_unit (); - virtual char const *ttyname () { return pc.dev.name; } -}; - -class fhandler_pty_master: public fhandler_tty_common -{ - int pktmode; // non-zero if pty in a packet mode. -public: - int need_nl; // Next read should start with \n - DWORD dwProcessId; // Owner of master handles - - /* Constructor */ - fhandler_pty_master (); - - int process_slave_output (char *buf, size_t len, int pktmode_on); - void doecho (const void *str, DWORD len); - int accept_input (); - int open (int flags, mode_t mode = 0); - ssize_t __stdcall write (const void *ptr, size_t len); - void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); - int close (); - - int tcsetattr (int a, const struct termios *t); - int tcgetattr (struct termios *t); - int tcflush (int); - int ioctl (unsigned int cmd, void *); - - char *ptsname (); - - HANDLE from_master, to_master; - bool hit_eof (); - bool setup (bool); - int dup (fhandler_base *); - void fixup_after_fork (HANDLE parent); - void fixup_after_exec (); - int tcgetpgrp (); -}; - -class fhandler_tty_master: public fhandler_pty_master -{ - public: - /* Constructor */ - fhandler_console *console; // device handler to perform real i/o. - - fhandler_tty_master (); - int init (); - int init_console (); - void set_winsize (bool); - bool is_slow () {return true;} -}; - -class fhandler_dev_null: public fhandler_base -{ - public: - fhandler_dev_null (); - - select_record *select_read (select_stuff *); - select_record *select_write (select_stuff *); - select_record *select_except (select_stuff *); -}; - -class fhandler_dev_zero: public fhandler_base -{ - public: - fhandler_dev_zero (); - int open (int flags, mode_t mode = 0); - ssize_t __stdcall write (const void *ptr, size_t len); - void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); - _off64_t lseek (_off64_t offset, int whence); - - virtual HANDLE mmap (caddr_t *addr, size_t len, int prot, - int flags, _off64_t off); - virtual int munmap (HANDLE h, caddr_t addr, size_t len); - virtual int msync (HANDLE h, caddr_t addr, size_t len, int flags); - virtual bool fixup_mmap_after_fork (HANDLE h, int prot, int flags, - _off64_t offset, DWORD size, - void *address); -}; - -class fhandler_dev_random: public fhandler_base -{ - protected: - HCRYPTPROV crypt_prov; - long pseudo; - _off64_t dummy_offset; - - bool crypt_gen_random (void *ptr, size_t len); - int pseudo_write (const void *ptr, size_t len); - int pseudo_read (void *ptr, size_t len); - - public: - fhandler_dev_random (); - int open (int flags, mode_t mode = 0); - ssize_t __stdcall write (const void *ptr, size_t len); - void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); - _off64_t lseek (_off64_t offset, int whence); - int close (); - int dup (fhandler_base *child); -}; - -class fhandler_dev_mem: public fhandler_base -{ - protected: - DWORD mem_size; - _off64_t pos; - - public: - fhandler_dev_mem (); - ~fhandler_dev_mem (); - - int open (int flags, mode_t mode = 0); - ssize_t __stdcall write (const void *ptr, size_t ulen); - void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); - _off64_t lseek (_off64_t offset, int whence); - int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2))); - int dup (fhandler_base *child); - - HANDLE mmap (caddr_t *addr, size_t len, int prot, int flags, _off64_t off); - int munmap (HANDLE h, caddr_t addr, size_t len); - int msync (HANDLE h, caddr_t addr, size_t len, int flags); - bool fixup_mmap_after_fork (HANDLE h, int prot, int flags, - _off64_t offset, DWORD size, void *address); -} ; - -class fhandler_dev_clipboard: public fhandler_base -{ - _off64_t pos; - void *membuffer; - size_t msize; - bool eof; - public: - fhandler_dev_clipboard (); - int is_windows () { return 1; } - int open (int flags, mode_t mode = 0); - ssize_t __stdcall write (const void *ptr, size_t len); - void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); - _off64_t lseek (_off64_t offset, int whence); - int close (); - - int dup (fhandler_base *child); - void fixup_after_exec (); -}; - -class fhandler_windows: public fhandler_base -{ - private: - HWND hWnd_; // the window whose messages are to be retrieved by read() call - int method_; // write method (Post or Send) - public: - fhandler_windows (); - int is_windows () { return 1; } - int open (int flags, mode_t mode = 0); - ssize_t __stdcall write (const void *ptr, size_t len); - void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); - int ioctl (unsigned int cmd, void *); - _off64_t lseek (_off64_t, int) { return 0; } - int close () { return 0; } - - void set_close_on_exec (bool val); - void fixup_after_fork (HANDLE parent); - select_record *select_read (select_stuff *); - select_record *select_write (select_stuff *); - select_record *select_except (select_stuff *); - bool is_slow () {return true;} -}; - -class fhandler_dev_dsp: public fhandler_base -{ - public: - class Audio; - class Audio_out; - class Audio_in; - private: - int audioformat_; - int audiofreq_; - int audiobits_; - int audiochannels_; - Audio_out *audio_out_; - Audio_in *audio_in_; - public: - fhandler_dev_dsp (); - - int open (int flags, mode_t mode = 0); - ssize_t __stdcall write (const void *ptr, size_t len); - void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); - int ioctl (unsigned int cmd, void *); - _off64_t lseek (_off64_t, int); - int close (); - int dup (fhandler_base *child); - void fixup_after_fork (HANDLE parent); - void fixup_after_exec (); - private: - void close_audio_in (); - void close_audio_out (bool immediately = false); -}; - -class fhandler_virtual : public fhandler_base -{ - protected: - char *filebuf; - _off64_t filesize; - _off64_t position; - int fileid; // unique within each class - public: - - fhandler_virtual (); - virtual ~fhandler_virtual(); - - virtual int exists(); - DIR *opendir (int fd) __attribute__ ((regparm (2))); - _off64_t telldir (DIR *); - void seekdir (DIR *, _off64_t); - void rewinddir (DIR *); - int closedir (DIR *); - ssize_t __stdcall write (const void *ptr, size_t len); - void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); - _off64_t lseek (_off64_t, int); - int dup (fhandler_base *child); - int open (int flags, mode_t mode = 0); - int close (); - int __stdcall fstat (struct stat *buf) __attribute__ ((regparm (2))); - int __stdcall fstatvfs (struct statvfs *buf) __attribute__ ((regparm (2))); - int __stdcall fchmod (mode_t mode) __attribute__ ((regparm (1))); - int __stdcall fchown (__uid32_t uid, __gid32_t gid) __attribute__ ((regparm (2))); - int __stdcall facl (int, int, __acl32 *) __attribute__ ((regparm (3))); - virtual bool fill_filebuf (); - char *get_filebuf () { return filebuf; } - void fixup_after_exec (); -}; - -class fhandler_proc: public fhandler_virtual -{ - public: - fhandler_proc (); - int exists(); - int readdir (DIR *, dirent *) __attribute__ ((regparm (3))); - static DWORD get_proc_fhandler(const char *path); - - int open (int flags, mode_t mode = 0); - int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2))); - bool fill_filebuf (); -}; - -class fhandler_netdrive: public fhandler_virtual -{ - public: - fhandler_netdrive (); - int exists(); - int readdir (DIR *, dirent *) __attribute__ ((regparm (3))); - void seekdir (DIR *, _off64_t); - void rewinddir (DIR *); - int closedir (DIR *); - int open (int flags, mode_t mode = 0); - int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2))); -}; - -class fhandler_registry: public fhandler_proc -{ - private: - wchar_t *value_name; - DWORD wow64; - int prefix_len; - public: - fhandler_registry (); - void set_name (path_conv &pc); - int exists(); - int readdir (DIR *, dirent *) __attribute__ ((regparm (3))); - _off64_t telldir (DIR *); - void seekdir (DIR *, _off64_t); - void rewinddir (DIR *); - int closedir (DIR *); - - int open (int flags, mode_t mode = 0); - int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2))); - bool fill_filebuf (); - int close (); - int dup (fhandler_base *child); -}; - -class pinfo; -class fhandler_process: public fhandler_proc -{ - pid_t pid; - public: - fhandler_process (); - int exists(); - DIR *opendir (int fd) __attribute__ ((regparm (2))); - int readdir (DIR *, dirent *) __attribute__ ((regparm (3))); - int open (int flags, mode_t mode = 0); - int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2))); - bool fill_filebuf (); -}; - -class fhandler_procnet: public fhandler_proc -{ - pid_t pid; - public: - fhandler_procnet (); - int exists(); - int readdir (DIR *, dirent *) __attribute__ ((regparm (3))); - int open (int flags, mode_t mode = 0); - int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2))); - bool fill_filebuf (); -}; - -struct fhandler_nodevice: public fhandler_base -{ - fhandler_nodevice (); - int open (int flags, mode_t mode = 0); - // int __stdcall fstat (struct __stat64 *buf, path_conv *); -}; - -#define report_tty_counts(fh, call, use_op) \ - termios_printf ("%s %s, %susecount %d",\ - fh->ttyname (), call,\ - use_op, ((fhandler_tty_slave *) fh)->archetype->usecount); - -typedef union -{ - char __base[sizeof (fhandler_base)]; - char __console[sizeof (fhandler_console)]; - char __cygdrive[sizeof (fhandler_cygdrive)]; - char __dev_clipboard[sizeof (fhandler_dev_clipboard)]; - char __dev_dsp[sizeof (fhandler_dev_dsp)]; - char __dev_floppy[sizeof (fhandler_dev_floppy)]; - char __dev_mem[sizeof (fhandler_dev_mem)]; - char __dev_null[sizeof (fhandler_dev_null)]; - char __dev_random[sizeof (fhandler_dev_random)]; - char __dev_raw[sizeof (fhandler_dev_raw)]; - char __dev_tape[sizeof (fhandler_dev_tape)]; - char __dev_zero[sizeof (fhandler_dev_zero)]; - char __disk_file[sizeof (fhandler_disk_file)]; - char __fifo[sizeof (fhandler_fifo)]; - char __mailslot[sizeof (fhandler_mailslot)]; - char __netdrive[sizeof (fhandler_netdrive)]; - char __nodevice[sizeof (fhandler_nodevice)]; - char __pipe[sizeof (fhandler_pipe)]; - char __proc[sizeof (fhandler_proc)]; - char __process[sizeof (fhandler_process)]; - char __pty_master[sizeof (fhandler_pty_master)]; - char __registry[sizeof (fhandler_registry)]; - char __serial[sizeof (fhandler_serial)]; - char __socket[sizeof (fhandler_socket)]; - char __termios[sizeof (fhandler_termios)]; - char __tty_common[sizeof (fhandler_tty_common)]; - char __tty_master[sizeof (fhandler_tty_master)]; - char __tty_slave[sizeof (fhandler_tty_slave)]; - char __virtual[sizeof (fhandler_virtual)]; - char __windows[sizeof (fhandler_windows)]; -} fhandler_union; -#endif /* _FHANDLER_H_ */ diff --git a/winsup/cygwin/fhandler_clipboard.cc b/winsup/cygwin/fhandler_clipboard.cc deleted file mode 100644 index c4f060578..000000000 --- a/winsup/cygwin/fhandler_clipboard.cc +++ /dev/null @@ -1,295 +0,0 @@ -/* fhandler_dev_clipboard: code to access /dev/clipboard - - Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009 - Red Hat, Inc - - Written by Charles Wilson (cwilson@ece.gatech.edu) - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include -#include "cygerrno.h" -#include "path.h" -#include "fhandler.h" - -/* - * Robert Collins: - * FIXME: should we use GetClipboardSequenceNumber to tell if the clipboard has - * changed? How does /dev/clipboard operate under (say) linux? - */ - -static const NO_COPY char *CYGWIN_NATIVE = "CYGWIN_NATIVE_CLIPBOARD"; -/* this is MT safe because windows format id's are atomic */ -static int cygnativeformat; - -fhandler_dev_clipboard::fhandler_dev_clipboard () - : fhandler_base (), pos (0), membuffer (NULL), msize (0), - eof (true) -{ - /* FIXME: check for errors and loop until we can open the clipboard */ - OpenClipboard (NULL); - cygnativeformat = RegisterClipboardFormat (CYGWIN_NATIVE); - CloseClipboard (); -} - -/* - * Special clipboard dup to duplicate input and output - * handles. - */ - -int -fhandler_dev_clipboard::dup (fhandler_base * child) -{ - fhandler_dev_clipboard *fhc = (fhandler_dev_clipboard *) child; - - if (!fhc->open (get_flags (), 0)) - system_printf ("error opening clipboard, %E"); - - fhc->membuffer = membuffer; - fhc->pos = pos; - fhc->msize = msize; - - return 0; -} - -int -fhandler_dev_clipboard::open (int flags, mode_t) -{ - set_flags (flags | O_TEXT); - eof = false; - pos = 0; - if (membuffer) - free (membuffer); - membuffer = NULL; - if (!cygnativeformat) - cygnativeformat = RegisterClipboardFormat (CYGWIN_NATIVE); - nohandle (true); - set_open_status (); - return 1; -} - -static int -set_clipboard (const void *buf, size_t len) -{ - HGLOBAL hmem; - void *clipbuf; - /* Native CYGWIN format */ - if (OpenClipboard (NULL)) - { - hmem = GlobalAlloc (GMEM_MOVEABLE, len + sizeof (size_t)); - if (!hmem) - { - __seterrno (); - CloseClipboard (); - return -1; - } - clipbuf = GlobalLock (hmem); - memcpy ((unsigned char *) clipbuf + sizeof (size_t), buf, len); - *(size_t *) (clipbuf) = len; - GlobalUnlock (hmem); - EmptyClipboard (); - if (!cygnativeformat) - cygnativeformat = RegisterClipboardFormat (CYGWIN_NATIVE); - HANDLE ret = SetClipboardData (cygnativeformat, hmem); - CloseClipboard (); - /* According to MSDN, hmem must not be free'd after transferring the - data to the clipboard via SetClipboardData. */ - /* GlobalFree (hmem); */ - if (!ret) - { - __seterrno (); - return -1; - } - } - - /* CF_TEXT/CF_OEMTEXT for copying to wordpad and the like */ - len = sys_mbstowcs (NULL, 0, (const char *) buf, len); - if (!len) - { - set_errno (EILSEQ); - return -1; - } - if (OpenClipboard (NULL)) - { - hmem = GlobalAlloc (GMEM_MOVEABLE, (len + 1) * sizeof (WCHAR)); - if (!hmem) - { - __seterrno (); - CloseClipboard (); - return -1; - } - clipbuf = GlobalLock (hmem); - sys_mbstowcs ((PWCHAR) clipbuf, len + 1, (const char *) buf); - GlobalUnlock (hmem); - HANDLE ret = SetClipboardData (CF_UNICODETEXT, hmem); - CloseClipboard (); - /* According to MSDN, hmem must not be free'd after transferring the - data to the clipboard via SetClipboardData. */ - /* GlobalFree (hmem); */ - if (!ret) - { - __seterrno (); - return -1; - } - } - return 0; -} - -/* FIXME: arbitrary seeking is not handled */ -ssize_t __stdcall -fhandler_dev_clipboard::write (const void *buf, size_t len) -{ - if (!eof) - { - /* write to our membuffer */ - size_t cursize = msize; - void *tempbuffer = realloc (membuffer, cursize + len); - if (!tempbuffer) - { - debug_printf ("Couldn't realloc() clipboard buffer for write"); - return -1; - } - membuffer = tempbuffer; - msize = cursize + len; - memcpy ((unsigned char *) membuffer + cursize, buf, len); - - /* now pass to windows */ - if (set_clipboard (membuffer, msize)) - { - /* FIXME: membuffer is now out of sync with pos, but msize - is used above */ - return -1; - } - - pos = msize; - - eof = false; - return len; - } - else - { - /* FIXME: return 0 bytes written, file not open */ - return 0; - } -} - -void __stdcall -fhandler_dev_clipboard::read (void *ptr, size_t& len) -{ - HGLOBAL hglb; - size_t ret; - UINT formatlist[2]; - int format; - size_t plen = len; - - len = 0; - if (eof) - return; - if (!OpenClipboard (NULL)) - return; - formatlist[0] = cygnativeformat; - formatlist[1] = CF_UNICODETEXT; - if ((format = GetPriorityClipboardFormat (formatlist, 2)) <= 0) - { - CloseClipboard (); - return; - } - if (!(hglb = GetClipboardData (format))) - { - CloseClipboard (); - return; - } - if (format == cygnativeformat) - { - unsigned char *buf; - - if (!(buf = (unsigned char *) GlobalLock (hglb))) - { - CloseClipboard (); - return; - } - size_t buflen = (*(size_t *) buf); - ret = ((plen > (buflen - pos)) ? (buflen - pos) : plen); - memcpy (ptr, buf + sizeof (size_t)+ pos , ret); - pos += ret; - if (pos + plen - ret >= buflen) - eof = true; - } - else - { - int wret; - PWCHAR buf; - - if (!(buf = (PWCHAR) GlobalLock (hglb))) - { - CloseClipboard (); - return; - } - size_t glen = GlobalSize (hglb) / sizeof (WCHAR) - 1; - /* This loop is necessary because the number of bytes returned by - sys_wcstombs does not indicate the number of wide chars used for - it, so we could potentially drop wide chars. */ - if (glen - pos > plen) - glen = pos + plen; - while ((wret = sys_wcstombs (NULL, 0, buf + pos, glen - pos)) != -1 - && (size_t) wret > plen) - --glen; - ret = sys_wcstombs ((char *) ptr, plen, buf + pos, glen - pos); - pos += ret; - if (pos + plen - ret >= wcslen (buf)) - eof = true; - } - GlobalUnlock (hglb); - CloseClipboard (); - len = ret; -} - -_off64_t -fhandler_dev_clipboard::lseek (_off64_t offset, int whence) -{ - /* On reads we check this at read time, not seek time. - * On writes we use this to decide how to write - empty and write, or open, copy, empty - * and write - */ - pos = offset; - /* treat seek like rewind */ - if (membuffer) - free (membuffer); - msize = 0; - return 0; -} - -int -fhandler_dev_clipboard::close () -{ - if (!hExeced) - { - eof = true; - pos = 0; - if (membuffer) - { - free (membuffer); - membuffer = NULL; - } - msize = 0; - } - return 0; -} - -void -fhandler_dev_clipboard::fixup_after_exec () -{ - if (!close_on_exec ()) - { - eof = false; - pos = msize = 0; - membuffer = NULL; - } -} diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc deleted file mode 100644 index 7a11fd22f..000000000 --- a/winsup/cygwin/fhandler_console.cc +++ /dev/null @@ -1,2316 +0,0 @@ -/* fhandler_console.cc - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2008, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "miscfuncs.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "sigproc.h" -#include "pinfo.h" -#include "shared_info.h" -#include "cygtls.h" -#include "tls_pbuf.h" -#include "registry.h" - -/* Don't make this bigger than NT_MAX_PATH as long as the temporary buffer - is allocated using tmp_pathbuf!!! */ -#define CONVERT_LIMIT NT_MAX_PATH - -/* - * Scroll the screen context. - * x1, y1 - ul corner - * x2, y2 - dr corner - * xn, yn - new ul corner - * Negative values represents current screen dimensions - */ - -#define srTop (dev_state->info.winTop + dev_state->scroll_region.Top) -#define srBottom ((dev_state->scroll_region.Bottom < 0) ? dev_state->info.winBottom : dev_state->info.winTop + dev_state->scroll_region.Bottom) - -#define use_tty ISSTATE (myself, PID_USETTY) - -const char *get_nonascii_key (INPUT_RECORD&, char *); - -const unsigned fhandler_console::MAX_WRITE_CHARS = 16384; - -static console_state NO_COPY *shared_console_info; - -dev_console NO_COPY *fhandler_console::dev_state; - -static void -beep () -{ - reg_key r (HKEY_CURRENT_USER, KEY_ALL_ACCESS, "AppEvents", "Schemes", "Apps", - ".Default", ".Default", ".Current", NULL); - if (r.created ()) - { - char *buf = NULL; - UINT len = GetWindowsDirectory (buf, 0); - buf = (char *) alloca (len += sizeof ("\\media\\ding.wav")); - UINT res = GetWindowsDirectory (buf, len); - if (res && res <= len) - r.set_string ("", strcat (buf, "\\media\\ding.wav")); - } - MessageBeep (MB_OK); -} - -/* Allocate and initialize the shared record for the current console. - Returns a pointer to shared_console_info. */ -tty_min * -fhandler_console::get_tty_stuff (int flags = 0) -{ - if (dev_state) - return &shared_console_info->tty_min_state; - - shared_locations sh_shared_console = SH_SHARED_CONSOLE; - shared_console_info = - (console_state *) open_shared (NULL, 0, cygheap->console_h, - sizeof (*shared_console_info), - sh_shared_console); - dev_state = &shared_console_info->dev_state; - - ProtectHandleINH (cygheap->console_h); - if (!shared_console_info->tty_min_state.ntty) - { - shared_console_info->tty_min_state.setntty (TTY_CONSOLE); - shared_console_info->tty_min_state.setsid (myself->sid); - myself->set_ctty (&shared_console_info->tty_min_state, flags, NULL); - - dev_state->scroll_region.Bottom = -1; - dev_state->dwLastCursorPosition.X = -1; - dev_state->dwLastCursorPosition.Y = -1; - dev_state->dwLastMousePosition.X = -1; - dev_state->dwLastMousePosition.Y = -1; - dev_state->dwLastButtonState = 0; /* none pressed */ - dev_state->last_button_code = 3; /* released */ - dev_state->underline_color = FOREGROUND_GREEN | FOREGROUND_BLUE; - dev_state->dim_color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; - dev_state->meta_mask = LEFT_ALT_PRESSED; - /* Set the mask that determines if an input keystroke is modified by - META. We set this based on the keyboard layout language loaded - for the current thread. The left key always generates - META, but the right key only generates META if we are using - an English keyboard because many "international" keyboards - replace common shell symbols ('[', '{', etc.) with accented - language-specific characters (umlaut, accent grave, etc.). On - these keyboards right (called AltGr) is used to produce the - shell symbols and should not be interpreted as META. */ - if (PRIMARYLANGID (LOWORD (GetKeyboardLayout (0))) == LANG_ENGLISH) - dev_state->meta_mask |= RIGHT_ALT_PRESSED; - dev_state->set_default_attr (); - shared_console_info->tty_min_state.sethwnd ((HWND) INVALID_HANDLE_VALUE); - } - - return &shared_console_info->tty_min_state; -} - -void -set_console_ctty () -{ - fhandler_console::get_tty_stuff (); -} - -/* Return the tty structure associated with a given tty number. If the - tty number is < 0, just return a dummy record. */ -tty_min * -tty_list::get_tty (int n) -{ - static tty_min nada; - if (n == TTY_CONSOLE) - return fhandler_console::get_tty_stuff (); - else if (n >= 0) - return &cygwin_shared->tty.ttys[n]; - else - return &nada; -} - -inline DWORD -dev_console::con_to_str (char *d, int dlen, WCHAR w) -{ - return sys_cp_wcstombs (cygheap->locale.wctomb, cygheap->locale.charset, - d, dlen, &w, 1); -} - -inline UINT -dev_console::get_console_cp () -{ - /* The alternate charset is always 437, just as in the Linux console. */ - return alternate_charset_active ? 437 : 0; -} - -inline DWORD -dev_console::str_to_con (mbtowc_p f_mbtowc, const char *charset, - PWCHAR d, const char *s, DWORD sz) -{ - return sys_cp_mbstowcs (f_mbtowc, charset, d, CONVERT_LIMIT, s, sz); -} - -bool -fhandler_console::set_raw_win32_keyboard_mode (bool new_mode) -{ - bool old_mode = dev_state->raw_win32_keyboard_mode; - dev_state->raw_win32_keyboard_mode = new_mode; - syscall_printf ("raw keyboard mode %sabled", dev_state->raw_win32_keyboard_mode ? "en" : "dis"); - return old_mode; -}; - -void -fhandler_console::set_cursor_maybe () -{ - CONSOLE_SCREEN_BUFFER_INFO now; - - if (!GetConsoleScreenBufferInfo (get_output_handle (), &now)) - return; - - if (dev_state->dwLastCursorPosition.X != now.dwCursorPosition.X || - dev_state->dwLastCursorPosition.Y != now.dwCursorPosition.Y) - { - SetConsoleCursorPosition (get_output_handle (), now.dwCursorPosition); - dev_state->dwLastCursorPosition = now.dwCursorPosition; - } -} - -void -fhandler_console::send_winch_maybe () -{ - SHORT y = dev_state->info.dwWinSize.Y; - SHORT x = dev_state->info.dwWinSize.X; - dev_state->fillin_info (get_output_handle ()); - - if (y != dev_state->info.dwWinSize.Y || x != dev_state->info.dwWinSize.X) - { - extern fhandler_tty_master *tty_master; - dev_state->scroll_region.Top = 0; - dev_state->scroll_region.Bottom = -1; - if (tty_master) - tty_master->set_winsize (true); - else - tc->kill_pgrp (SIGWINCH); - } -} - -/* Check whether a mouse event is to be reported as an escape sequence */ -bool -fhandler_console::mouse_aware (MOUSE_EVENT_RECORD& mouse_event) -{ - if (! dev_state->use_mouse) - return 0; - - /* Adjust mouse position by window scroll buffer offset - and remember adjusted position in state for use by read() */ - CONSOLE_SCREEN_BUFFER_INFO now; - if (GetConsoleScreenBufferInfo (get_output_handle (), &now)) - { - dev_state->dwMousePosition.X = mouse_event.dwMousePosition.X - now.srWindow.Left; - dev_state->dwMousePosition.Y = mouse_event.dwMousePosition.Y - now.srWindow.Top; - } - else - { - /* Cannot adjust position by window scroll buffer offset */ - return 0; - } - - /* Check whether adjusted mouse position can be reported */ - if (dev_state->dwMousePosition.X > 0xFF - ' ' - 1 - || dev_state->dwMousePosition.Y > 0xFF - ' ' - 1) - { - /* Mouse position out of reporting range */ - return 0; - } - - return ((mouse_event.dwEventFlags == 0 || mouse_event.dwEventFlags == DOUBLE_CLICK) - && mouse_event.dwButtonState != dev_state->dwLastButtonState) - || mouse_event.dwEventFlags == MOUSE_WHEELED - || (mouse_event.dwEventFlags == MOUSE_MOVED - && (dev_state->dwMousePosition.X != dev_state->dwLastMousePosition.X - || dev_state->dwMousePosition.Y != dev_state->dwLastMousePosition.Y) - && ((dev_state->use_mouse >= 2 && mouse_event.dwButtonState) - || dev_state->use_mouse >= 3)); -} - -void __stdcall -fhandler_console::read (void *pv, size_t& buflen) -{ - HANDLE h = get_io_handle (); - -#define buf ((char *) pv) - - int ch; - set_input_state (); - - int copied_chars = get_readahead_into_buffer (buf, buflen); - - if (copied_chars) - { - buflen = copied_chars; - return; - } - - HANDLE w4[2]; - DWORD nwait; - char tmp[60]; - - w4[0] = h; - if (&_my_tls != _main_tls) - nwait = 1; - else - { - w4[1] = signal_arrived; - nwait = 2; - } - - termios ti = tc->ti; - for (;;) - { - int bgres; - if ((bgres = bg_check (SIGTTIN)) <= bg_eof) - { - buflen = bgres; - return; - } - - set_cursor_maybe (); /* to make cursor appear on the screen immediately */ - switch (WaitForMultipleObjects (nwait, w4, FALSE, INFINITE)) - { - case WAIT_OBJECT_0: - break; - case WAIT_OBJECT_0 + 1: - goto sig_exit; - default: - goto err; - } - - DWORD nread; - INPUT_RECORD input_rec; - const char *toadd = NULL; - - if (!ReadConsoleInputW (h, &input_rec, 1, &nread)) - { - syscall_printf ("ReadConsoleInput failed, %E"); - goto err; /* seems to be failure */ - } - - /* check the event that occurred */ - switch (input_rec.EventType) - { - case KEY_EVENT: -#define virtual_key_code (input_rec.Event.KeyEvent.wVirtualKeyCode) -#define control_key_state (input_rec.Event.KeyEvent.dwControlKeyState) - - dev_state->nModifiers = 0; - -#ifdef DEBUGGING - /* allow manual switching to/from raw mode via ctrl-alt-scrolllock */ - if (input_rec.Event.KeyEvent.bKeyDown && - virtual_key_code == VK_SCROLL && - ((control_key_state & (LEFT_ALT_PRESSED | LEFT_CTRL_PRESSED)) == (LEFT_ALT_PRESSED | LEFT_CTRL_PRESSED)) - ) - { - set_raw_win32_keyboard_mode (!dev_state->raw_win32_keyboard_mode); - continue; - } -#endif - - if (dev_state->raw_win32_keyboard_mode) - { - __small_sprintf (tmp, "\033{%u;%u;%u;%u;%u;%luK", - input_rec.Event.KeyEvent.bKeyDown, - input_rec.Event.KeyEvent.wRepeatCount, - input_rec.Event.KeyEvent.wVirtualKeyCode, - input_rec.Event.KeyEvent.wVirtualScanCode, - input_rec.Event.KeyEvent.uChar.UnicodeChar, - input_rec.Event.KeyEvent.dwControlKeyState); - toadd = tmp; - nread = strlen (toadd); - break; - } - -#define ich (input_rec.Event.KeyEvent.uChar.AsciiChar) -#define wch (input_rec.Event.KeyEvent.uChar.UnicodeChar) -#define ALT_PRESSED (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED) -#define CTRL_PRESSED (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED) - - /* Ignore key up events, except for left alt events with non-zero character - */ - if (!input_rec.Event.KeyEvent.bKeyDown && - /* - Event for left alt, with a non-zero character, comes from - "alt + numerics" key sequence. - e.g. 0233 => é - */ - !(wch != 0 - // ?? experimentally determined on an XP system - && virtual_key_code == VK_MENU - // left alt -- see http://www.microsoft.com/hwdev/tech/input/Scancode.asp - && input_rec.Event.KeyEvent.wVirtualScanCode == 0x38)) - continue; - - if (control_key_state & SHIFT_PRESSED) - dev_state->nModifiers |= 1; - if (control_key_state & RIGHT_ALT_PRESSED) - dev_state->nModifiers |= 2; - if (control_key_state & CTRL_PRESSED) - dev_state->nModifiers |= 4; - if (control_key_state & LEFT_ALT_PRESSED) - dev_state->nModifiers |= 8; - - /* Send the VERASE character from the terminal settings as backspace keycode. */ - if (input_rec.Event.KeyEvent.wVirtualScanCode == 14) - { - char c = ti.c_cc[VERASE]; - nread = 0; - if (control_key_state & ALT_PRESSED) { - if (dev_state->metabit) - c |= 0x80; - else - tmp[nread++] = '\e'; - } - tmp[nread++] = c; - tmp[nread] = 0; - toadd = tmp; - } - /* Allow Ctrl-Space to emit ^@ */ - else if (input_rec.Event.KeyEvent.wVirtualKeyCode == VK_SPACE - && (control_key_state & CTRL_PRESSED)) - toadd = ""; - else if (wch == 0 - /* arrow/function keys */ - || (input_rec.Event.KeyEvent.dwControlKeyState & ENHANCED_KEY)) - { - toadd = get_nonascii_key (input_rec, tmp); - if (!toadd) - { - dev_state->nModifiers = 0; - continue; - } - nread = strlen (toadd); - } - else - { - nread = dev_state->con_to_str (tmp + 1, 59, wch); - /* Determine if the keystroke is modified by META. The tricky - part is to distinguish whether the right Alt key should be - recognized as Alt, or as AltGr. */ - bool meta = - /* Alt but not AltGr (= left ctrl + right alt)? */ - (control_key_state & ALT_PRESSED) != 0 - && ((control_key_state & CTRL_PRESSED) == 0 - /* but also allow Alt-AltGr: */ - || (control_key_state & ALT_PRESSED) == ALT_PRESSED - || (wch <= 0x1f || wch == 0x7f)); - if (!meta) - { - /* Determine if the character is in the current multibyte - charset. The test is easy. If the multibyte sequence - is > 1 and the first byte is ASCII CAN, the character - has been translated into the ASCII CAN + UTF-8 replacement - sequence. If so, just ignore the keypress. - FIXME: Is there a better solution? */ - if (nread > 1 && tmp[1] == 0x18) - beep (); - else - toadd = tmp + 1; - } - else if (dev_state->metabit) - { - tmp[1] |= 0x80; - toadd = tmp + 1; - } - else - { - tmp[0] = '\033'; - tmp[1] = cyg_tolower (tmp[1]); - toadd = tmp; - nread++; - dev_state->nModifiers &= ~4; - } - } -#undef ich -#undef wch -#undef ALT_PRESSED -#undef CTRL_PRESSED - break; - - case MOUSE_EVENT: - send_winch_maybe (); - { - MOUSE_EVENT_RECORD& mouse_event = input_rec.Event.MouseEvent; - /* As a unique guard for mouse report generation, - call mouse_aware() which is common with select(), so the result - of select() and the actual read() will be consistent on the - issue of whether input (i.e. a mouse escape sequence) will - be available or not */ - if (mouse_aware (mouse_event)) - { - /* Note: Reported mouse position was already retrieved by - mouse_aware() and adjusted by window scroll buffer offset */ - - /* Treat the double-click event like a regular button press */ - if (mouse_event.dwEventFlags == DOUBLE_CLICK) - { - syscall_printf ("mouse: double-click -> click"); - mouse_event.dwEventFlags = 0; - } - - /* This code assumes Windows never reports multiple button - events at the same time. */ - int b = 0; - char sz[32]; - - if (mouse_event.dwEventFlags == MOUSE_WHEELED) - { - if (mouse_event.dwButtonState & 0xFF800000) - { - b = 0x41; - strcpy (sz, "wheel down"); - } - else - { - b = 0x40; - strcpy (sz, "wheel up"); - } - } - else - { - /* Ignore unimportant mouse buttons */ - mouse_event.dwButtonState &= 0x7; - - if (mouse_event.dwEventFlags == MOUSE_MOVED) - { - b = dev_state->last_button_code; - } - else if (mouse_event.dwButtonState < dev_state->dwLastButtonState) - { - b = 3; - strcpy (sz, "btn up"); - } - else if ((mouse_event.dwButtonState & 1) != (dev_state->dwLastButtonState & 1)) - { - b = 0; - strcpy (sz, "btn1 down"); - } - else if ((mouse_event.dwButtonState & 2) != (dev_state->dwLastButtonState & 2)) - { - b = 2; - strcpy (sz, "btn2 down"); - } - else if ((mouse_event.dwButtonState & 4) != (dev_state->dwLastButtonState & 4)) - { - b = 1; - strcpy (sz, "btn3 down"); - } - - dev_state->last_button_code = b; - - if (mouse_event.dwEventFlags == MOUSE_MOVED) - { - b += 32; - strcpy (sz, "move"); - } - else - { - /* Remember the modified button state */ - dev_state->dwLastButtonState = mouse_event.dwButtonState; - } - } - - /* Remember mouse position */ - dev_state->dwLastMousePosition.X = dev_state->dwMousePosition.X; - dev_state->dwLastMousePosition.Y = dev_state->dwMousePosition.Y; - - /* Remember the modifiers */ - dev_state->nModifiers = 0; - if (mouse_event.dwControlKeyState & SHIFT_PRESSED) - dev_state->nModifiers |= 0x4; - if (mouse_event.dwControlKeyState & (RIGHT_ALT_PRESSED|LEFT_ALT_PRESSED)) - dev_state->nModifiers |= 0x8; - if (mouse_event.dwControlKeyState & (RIGHT_CTRL_PRESSED|LEFT_CTRL_PRESSED)) - dev_state->nModifiers |= 0x10; - - /* Indicate the modifiers */ - b |= dev_state->nModifiers; - - /* We can now create the code. */ - sprintf (tmp, "\033[M%c%c%c", b + ' ', dev_state->dwMousePosition.X + ' ' + 1, dev_state->dwMousePosition.Y + ' ' + 1); - syscall_printf ("mouse: %s at (%d,%d)", sz, dev_state->dwMousePosition.X, dev_state->dwMousePosition.Y); - - toadd = tmp; - nread = 6; - } - } - break; - - case FOCUS_EVENT: - if (dev_state->use_focus) { - if (input_rec.Event.FocusEvent.bSetFocus) - sprintf (tmp, "\033[I"); - else - sprintf (tmp, "\033[O"); - - toadd = tmp; - nread = 3; - } - break; - - case WINDOW_BUFFER_SIZE_EVENT: - send_winch_maybe (); - /* fall through */ - default: - continue; - } - - if (toadd) - { - line_edit_status res = line_edit (toadd, nread, ti); - if (res == line_edit_signalled) - goto sig_exit; - else if (res == line_edit_input_done) - break; - } - } - - while (buflen) - if ((ch = get_readahead ()) < 0) - break; - else - { - buf[copied_chars++] = (unsigned char)(ch & 0xff); - buflen--; - } -#undef buf - - buflen = copied_chars; - return; - -err: - __seterrno (); - buflen = (size_t) -1; - return; - -sig_exit: - set_sig_errno (EINTR); - buflen = (size_t) -1; -} - -void -fhandler_console::set_input_state () -{ - if (tc->rstcons ()) - input_tcsetattr (0, &tc->ti); -} - -bool -dev_console::fillin_info (HANDLE h) -{ - bool ret; - CONSOLE_SCREEN_BUFFER_INFO linfo; - - if ((ret = GetConsoleScreenBufferInfo (h, &linfo))) - { - info.winTop = linfo.srWindow.Top; - info.winBottom = linfo.srWindow.Bottom; - info.dwWinSize.Y = 1 + linfo.srWindow.Bottom - linfo.srWindow.Top; - info.dwWinSize.X = 1 + linfo.srWindow.Right - linfo.srWindow.Left; - info.dwBufferSize = linfo.dwSize; - info.dwCursorPosition = linfo.dwCursorPosition; - info.wAttributes = linfo.wAttributes; - } - else - { - memset (&info, 0, sizeof info); - info.dwWinSize.Y = 25; - info.dwWinSize.X = 80; - info.winBottom = 24; - } - - return ret; -} - -void -fhandler_console::scroll_screen (int x1, int y1, int x2, int y2, int xn, int yn) -{ - SMALL_RECT sr1, sr2; - CHAR_INFO fill; - COORD dest; - - dev_state->fillin_info (get_output_handle ()); - sr1.Left = x1 >= 0 ? x1 : dev_state->info.dwWinSize.X - 1; - if (y1 == 0) - sr1.Top = dev_state->info.winTop; - else - sr1.Top = y1 > 0 ? y1 : dev_state->info.winBottom; - sr1.Right = x2 >= 0 ? x2 : dev_state->info.dwWinSize.X - 1; - if (y2 == 0) - sr1.Bottom = dev_state->info.winTop; - else - sr1.Bottom = y2 > 0 ? y2 : dev_state->info.winBottom; - sr2.Top = srTop; - sr2.Left = 0; - sr2.Bottom = srBottom; - sr2.Right = dev_state->info.dwWinSize.X - 1; - if (sr1.Bottom > sr2.Bottom && sr1.Top <= sr2.Bottom) - sr1.Bottom = sr2.Bottom; - dest.X = xn >= 0 ? xn : dev_state->info.dwWinSize.X - 1; - if (yn == 0) - dest.Y = dev_state->info.winTop; - else - dest.Y = yn > 0 ? yn : dev_state->info.winBottom; - fill.Char.AsciiChar = ' '; - fill.Attributes = dev_state->current_win32_attr; - ScrollConsoleScreenBuffer (get_output_handle (), &sr1, &sr2, dest, &fill); - - /* ScrollConsoleScreenBuffer on Windows 95 is buggy - when scroll distance - * is more than half of screen, filling doesn't work as expected */ - - if (sr1.Top == sr1.Bottom) - /* nothing to do */; - else if (dest.Y <= sr1.Top) /* forward scroll */ - clear_screen (0, 1 + dest.Y + sr1.Bottom - sr1.Top, sr2.Right, sr2.Bottom); - else /* reverse scroll */ - clear_screen (0, sr1.Top, sr2.Right, dest.Y - 1); -} - -int -fhandler_console::open (int flags, mode_t) -{ - HANDLE h; - - tcinit (get_tty_stuff (flags)); - - set_io_handle (NULL); - set_output_handle (NULL); - - set_flags ((flags & ~O_TEXT) | O_BINARY); - - /* Open the input handle as handle_ */ - h = CreateFile ("CONIN$", GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, sec_none_cloexec (flags), - OPEN_EXISTING, 0, 0); - - if (h == INVALID_HANDLE_VALUE) - { - __seterrno (); - return 0; - } - set_io_handle (h); - uninterruptible_io (true); // Handled explicitly in read code - - h = CreateFile ("CONOUT$", GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, sec_none_cloexec (flags), - OPEN_EXISTING, 0, 0); - - if (h == INVALID_HANDLE_VALUE) - { - __seterrno (); - return 0; - } - set_output_handle (h); - - if (dev_state->fillin_info (get_output_handle ())) - { - dev_state->current_win32_attr = dev_state->info.wAttributes; - if (!dev_state->default_color) - dev_state->default_color = dev_state->info.wAttributes; - dev_state->set_default_attr (); - } - - tc->rstcons (false); - set_open_status (); - cygheap->manage_console_count ("fhandler_console::open", 1); - - DWORD cflags; - if (GetConsoleMode (get_io_handle (), &cflags)) - SetConsoleMode (get_io_handle (), - ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT | cflags); - - debug_printf ("opened conin$ %p, conout$ %p", get_io_handle (), - get_output_handle ()); - - return 1; -} - -int -fhandler_console::close () -{ - CloseHandle (get_io_handle ()); - CloseHandle (get_output_handle ()); - if (!hExeced) - cygheap->manage_console_count ("fhandler_console::close", -1); - return 0; -} - -/* Special console dup to duplicate input and output handles. */ - -int -fhandler_console::dup (fhandler_base *child) -{ - fhandler_console *fhc = (fhandler_console *) child; - - if (!fhc->open (get_flags () & ~O_NOCTTY, 0)) - system_printf ("error opening console, %E"); - - return 0; -} - -int -fhandler_console::ioctl (unsigned int cmd, void *buf) -{ - switch (cmd) - { - case TIOCGWINSZ: - int st; - - st = dev_state->fillin_info (get_output_handle ()); - if (st) - { - /* *not* the buffer size, the actual screen size... */ - /* based on Left Top Right Bottom of srWindow */ - ((struct winsize *) buf)->ws_row = dev_state->info.dwWinSize.Y; - ((struct winsize *) buf)->ws_col = dev_state->info.dwWinSize.X; - syscall_printf ("WINSZ: (row=%d,col=%d)", - ((struct winsize *) buf)->ws_row, - ((struct winsize *) buf)->ws_col); - return 0; - } - else - { - syscall_printf ("WINSZ failed"); - __seterrno (); - return -1; - } - return 0; - case TIOCSWINSZ: - bg_check (SIGTTOU); - return 0; - case KDGKBMETA: - *(int *) buf = (dev_state->metabit) ? K_METABIT : K_ESCPREFIX; - return 0; - case KDSKBMETA: - if ((int) buf == K_METABIT) - dev_state->metabit = TRUE; - else if ((int) buf == K_ESCPREFIX) - dev_state->metabit = FALSE; - else - { - set_errno (EINVAL); - return -1; - } - return 0; - case TIOCLINUX: - if (*(unsigned char *) buf == 6) - { - *(unsigned char *) buf = (unsigned char) dev_state->nModifiers; - return 0; - } - else - { - set_errno (EINVAL); - return -1; - } - } - - return fhandler_base::ioctl (cmd, buf); -} - -int -fhandler_console::tcflush (int queue) -{ - int res = 0; - if (queue == TCIFLUSH - || queue == TCIOFLUSH) - { - if (!FlushConsoleInputBuffer (get_io_handle ())) - { - __seterrno (); - res = -1; - } - } - return res; -} - -int -fhandler_console::output_tcsetattr (int, struct termios const *t) -{ - /* All the output bits we can ignore */ - - DWORD flags = ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT; - - int res = SetConsoleMode (get_output_handle (), flags) ? 0 : -1; - syscall_printf ("%d = tcsetattr (,%x) (ENABLE FLAGS %x) (lflag %x oflag %x)", - res, t, flags, t->c_lflag, t->c_oflag); - return res; -} - -int -fhandler_console::input_tcsetattr (int, struct termios const *t) -{ - /* Ignore the optional_actions stuff, since all output is emitted - instantly */ - - DWORD oflags; - - if (!GetConsoleMode (get_io_handle (), &oflags)) - oflags = 0; - DWORD flags = 0; - -#if 0 - /* Enable/disable LF -> CRLF conversions */ - rbinary ((t->c_iflag & INLCR) ? false : true); -#endif - - /* There's some disparity between what we need and what's - available. We've got ECHO and ICANON, they've - got ENABLE_ECHO_INPUT and ENABLE_LINE_INPUT. */ - - tc->ti = *t; - - if (t->c_lflag & ECHO) - { - flags |= ENABLE_ECHO_INPUT; - } - if (t->c_lflag & ICANON) - { - flags |= ENABLE_LINE_INPUT; - } - - if (flags & ENABLE_ECHO_INPUT - && !(flags & ENABLE_LINE_INPUT)) - { - /* This is illegal, so turn off the echo here, and fake it - when we read the characters */ - - flags &= ~ENABLE_ECHO_INPUT; - } - - if (t->c_lflag & ISIG) - { - flags |= ENABLE_PROCESSED_INPUT; - } - - if (use_tty) - { - flags = 0; // ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT; - tc->ti.c_iflag = 0; - tc->ti.c_lflag = 0; - } - - flags |= ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT; - - int res; - if (flags == oflags) - res = 0; - else - { - res = SetConsoleMode (get_io_handle (), flags) ? 0 : -1; - if (res < 0) - __seterrno (); - syscall_printf ("%d = tcsetattr (,%x) enable flags %p, c_lflag %p iflag %p", - res, t, flags, t->c_lflag, t->c_iflag); - } - - tc->rstcons (false); - return res; -} - -int -fhandler_console::tcsetattr (int a, struct termios const *t) -{ - int res = output_tcsetattr (a, t); - if (res != 0) - return res; - return input_tcsetattr (a, t); -} - -int -fhandler_console::tcgetattr (struct termios *t) -{ - int res; - *t = tc->ti; - - t->c_cflag |= CS8; - - DWORD flags; - - if (!GetConsoleMode (get_io_handle (), &flags)) - { - __seterrno (); - res = -1; - } - else - { - if (flags & ENABLE_ECHO_INPUT) - t->c_lflag |= ECHO; - - if (flags & ENABLE_LINE_INPUT) - t->c_lflag |= ICANON; - - if (flags & ENABLE_PROCESSED_INPUT) - t->c_lflag |= ISIG; - - /* What about ENABLE_WINDOW_INPUT - and ENABLE_MOUSE_INPUT ? */ - - /* All the output bits we can ignore */ - res = 0; - } - syscall_printf ("%d = tcgetattr (%p) enable flags %p, t->lflag %p, t->iflag %p", - res, t, flags, t->c_lflag, t->c_iflag); - return res; -} - -fhandler_console::fhandler_console () : - fhandler_termios () -{ - trunc_buf.len = 0; -} - -void -dev_console::set_color (HANDLE h) -{ - WORD win_fg = fg; - WORD win_bg = bg; - if (reverse) - { - WORD save_fg = win_fg; - win_fg = (win_bg & BACKGROUND_RED ? FOREGROUND_RED : 0) | - (win_bg & BACKGROUND_GREEN ? FOREGROUND_GREEN : 0) | - (win_bg & BACKGROUND_BLUE ? FOREGROUND_BLUE : 0) | - (win_bg & BACKGROUND_INTENSITY ? FOREGROUND_INTENSITY : 0); - win_bg = (save_fg & FOREGROUND_RED ? BACKGROUND_RED : 0) | - (save_fg & FOREGROUND_GREEN ? BACKGROUND_GREEN : 0) | - (save_fg & FOREGROUND_BLUE ? BACKGROUND_BLUE : 0) | - (save_fg & FOREGROUND_INTENSITY ? BACKGROUND_INTENSITY : 0); - } - - /* apply attributes */ - if (underline) - win_fg = underline_color; - /* emulate blink with bright background */ - if (blink) - win_bg |= BACKGROUND_INTENSITY; - if (intensity == INTENSITY_INVISIBLE) - win_fg = win_bg; - else if (intensity != INTENSITY_BOLD) - /* nothing to do */; - /* apply foreground intensity only in non-reverse mode! */ - else if (reverse) - win_bg |= BACKGROUND_INTENSITY; - else - win_fg |= FOREGROUND_INTENSITY; - - current_win32_attr = win_fg | win_bg; - if (h) - SetConsoleTextAttribute (h, current_win32_attr); -} - -#define FOREGROUND_ATTR_MASK (FOREGROUND_RED | FOREGROUND_GREEN | \ - FOREGROUND_BLUE | FOREGROUND_INTENSITY) -#define BACKGROUND_ATTR_MASK (BACKGROUND_RED | BACKGROUND_GREEN | \ - BACKGROUND_BLUE | BACKGROUND_INTENSITY) -void -dev_console::set_default_attr () -{ - blink = underline = reverse = false; - intensity = INTENSITY_NORMAL; - fg = default_color & FOREGROUND_ATTR_MASK; - bg = default_color & BACKGROUND_ATTR_MASK; - set_color (NULL); -} - -/* - * Clear the screen context from x1/y1 to x2/y2 cell. - * Negative values represents current screen dimensions - */ -void -fhandler_console::clear_screen (int x1, int y1, int x2, int y2) -{ - COORD tlc; - DWORD done; - int num; - - dev_state->fillin_info (get_output_handle ()); - - if (x1 < 0) - x1 = dev_state->info.dwWinSize.X - 1; - if (y1 < 0) - y1 = dev_state->info.winBottom; - if (x2 < 0) - x2 = dev_state->info.dwWinSize.X - 1; - if (y2 < 0) - y2 = dev_state->info.winBottom; - - num = abs (y1 - y2) * dev_state->info.dwBufferSize.X + abs (x1 - x2) + 1; - - if ((y2 * dev_state->info.dwBufferSize.X + x2) > (y1 * dev_state->info.dwBufferSize.X + x1)) - { - tlc.X = x1; - tlc.Y = y1; - } - else - { - tlc.X = x2; - tlc.Y = y2; - } - FillConsoleOutputCharacterA (get_output_handle (), ' ', - num, - tlc, - &done); - FillConsoleOutputAttribute (get_output_handle (), - dev_state->current_win32_attr, - num, - tlc, - &done); -} - -void -fhandler_console::cursor_set (bool rel_to_top, int x, int y) -{ - COORD pos; - - dev_state->fillin_info (get_output_handle ()); - if (y > dev_state->info.winBottom) - y = dev_state->info.winBottom; - else if (y < 0) - y = 0; - else if (rel_to_top) - y += dev_state->info.winTop; - - if (x > dev_state->info.dwWinSize.X) - x = dev_state->info.dwWinSize.X - 1; - else if (x < 0) - x = 0; - - pos.X = x; - pos.Y = y; - SetConsoleCursorPosition (get_output_handle (), pos); -} - -void -fhandler_console::cursor_rel (int x, int y) -{ - dev_state->fillin_info (get_output_handle ()); - x += dev_state->info.dwCursorPosition.X; - y += dev_state->info.dwCursorPosition.Y; - cursor_set (false, x, y); -} - -void -fhandler_console::cursor_get (int *x, int *y) -{ - dev_state->fillin_info (get_output_handle ()); - *y = dev_state->info.dwCursorPosition.Y; - *x = dev_state->info.dwCursorPosition.X; -} - -/* VT100 line drawing graphics mode maps `abcdefghijklmnopqrstuvwxyz{|}~ to - graphical characters */ -static wchar_t __vt100_conv [31] = { - 0x25C6, /* Black Diamond */ - 0x2592, /* Medium Shade */ - 0x2409, /* Symbol for Horizontal Tabulation */ - 0x240C, /* Symbol for Form Feed */ - 0x240D, /* Symbol for Carriage Return */ - 0x240A, /* Symbol for Line Feed */ - 0x00B0, /* Degree Sign */ - 0x00B1, /* Plus-Minus Sign */ - 0x2424, /* Symbol for Newline */ - 0x240B, /* Symbol for Vertical Tabulation */ - 0x2518, /* Box Drawings Light Up And Left */ - 0x2510, /* Box Drawings Light Down And Left */ - 0x250C, /* Box Drawings Light Down And Right */ - 0x2514, /* Box Drawings Light Up And Right */ - 0x253C, /* Box Drawings Light Vertical And Horizontal */ - 0x23BA, /* Horizontal Scan Line-1 */ - 0x23BB, /* Horizontal Scan Line-3 */ - 0x2500, /* Box Drawings Light Horizontal */ - 0x23BC, /* Horizontal Scan Line-7 */ - 0x23BD, /* Horizontal Scan Line-9 */ - 0x251C, /* Box Drawings Light Vertical And Right */ - 0x2524, /* Box Drawings Light Vertical And Left */ - 0x2534, /* Box Drawings Light Up And Horizontal */ - 0x252C, /* Box Drawings Light Down And Horizontal */ - 0x2502, /* Box Drawings Light Vertical */ - 0x2264, /* Less-Than Or Equal To */ - 0x2265, /* Greater-Than Or Equal To */ - 0x03C0, /* Greek Small Letter Pi */ - 0x2260, /* Not Equal To */ - 0x00A3, /* Pound Sign */ - 0x00B7, /* Middle Dot */ -}; - -inline -bool fhandler_console::write_console (PWCHAR buf, DWORD len, DWORD& done) -{ - if (dev_state->vt100_graphics_mode_active) - for (DWORD i = 0; i < len; i ++) - if (buf[i] >= (unsigned char) '`' && buf[i] <= (unsigned char) '~') - buf[i] = __vt100_conv[buf[i] - (unsigned char) '`']; - - while (len > 0) - { - DWORD nbytes = len > MAX_WRITE_CHARS ? MAX_WRITE_CHARS : len; - if (!WriteConsoleW (get_output_handle (), buf, nbytes, &done, 0)) - { - __seterrno (); - return false; - } - len -= done; - buf += done; - } - return true; -} - -#define BAK 1 -#define ESC 2 -#define NOR 0 -#define IGN 4 -#if 1 -#define ERR 5 -#else -#define ERR NOR -#endif -#define DWN 6 -#define BEL 7 -#define TAB 8 /* We should't let the console deal with these */ -#define CR 13 -#define LF 10 -#define SO 14 -#define SI 15 - -static const char base_chars[256] = -{ -/*00 01 02 03 04 05 06 07 */ IGN, ERR, ERR, NOR, NOR, NOR, NOR, BEL, -/*08 09 0A 0B 0C 0D 0E 0F */ BAK, TAB, DWN, ERR, ERR, CR, SO, SI, -/*10 11 12 13 14 15 16 17 */ NOR, NOR, ERR, ERR, ERR, ERR, ERR, ERR, -/*18 19 1A 1B 1C 1D 1E 1F */ NOR, NOR, ERR, ESC, ERR, ERR, ERR, ERR, -/* ! " # $ % & ' */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*( ) * + , - . / */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*0 1 2 3 4 5 6 7 */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*8 9 : ; < = > ? */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*@ A B C D E F G */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*H I J K L M N O */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*P Q R S T U V W */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*X Y Z [ \ ] ^ _ */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*` a b c d e f g */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*h i j k l m n o */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*p q r s t u v w */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*x y z { | } ~ 7F */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*80 81 82 83 84 85 86 87 */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*88 89 8A 8B 8C 8D 8E 8F */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*90 91 92 93 94 95 96 97 */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*98 99 9A 9B 9C 9D 9E 9F */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*A0 A1 A2 A3 A4 A5 A6 A7 */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*A8 A9 AA AB AC AD AE AF */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*B0 B1 B2 B3 B4 B5 B6 B7 */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*B8 B9 BA BB BC BD BE BF */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*C0 C1 C2 C3 C4 C5 C6 C7 */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*C8 C9 CA CB CC CD CE CF */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*D0 D1 D2 D3 D4 D5 D6 D7 */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*D8 D9 DA DB DC DD DE DF */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*E0 E1 E2 E3 E4 E5 E6 E7 */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*E8 E9 EA EB EC ED EE EF */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*F0 F1 F2 F3 F4 F5 F6 F7 */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR, -/*F8 F9 FA FB FC FD FE FF */ NOR, NOR, NOR, NOR, NOR, NOR, NOR, NOR }; - -void -fhandler_console::char_command (char c) -{ - int x, y; - char buf[40]; - - switch (c) - { - case 'm': /* Set Graphics Rendition */ - for (int i = 0; i <= dev_state->nargs_; i++) - switch (dev_state->args_[i]) - { - case 0: /* normal color */ - dev_state->set_default_attr (); - break; - case 1: /* bold */ - dev_state->intensity = INTENSITY_BOLD; - break; - case 2: /* dim */ - dev_state->intensity = INTENSITY_DIM; - break; - case 4: /* underlined */ - dev_state->underline = 1; - break; - case 5: /* blink mode */ - dev_state->blink = true; - break; - case 7: /* reverse */ - dev_state->reverse = true; - break; - case 8: /* invisible */ - dev_state->intensity = INTENSITY_INVISIBLE; - break; - case 10: /* end alternate charset */ - dev_state->alternate_charset_active = false; - break; - case 11: /* start alternate charset */ - dev_state->alternate_charset_active = true; - break; - case 22: - case 28: - dev_state->intensity = INTENSITY_NORMAL; - break; - case 24: - dev_state->underline = false; - break; - case 25: - dev_state->blink = false; - break; - case 27: - dev_state->reverse = false; - break; - case 30: /* BLACK foreground */ - dev_state->fg = 0; - break; - case 31: /* RED foreground */ - dev_state->fg = FOREGROUND_RED; - break; - case 32: /* GREEN foreground */ - dev_state->fg = FOREGROUND_GREEN; - break; - case 33: /* YELLOW foreground */ - dev_state->fg = FOREGROUND_RED | FOREGROUND_GREEN; - break; - case 34: /* BLUE foreground */ - dev_state->fg = FOREGROUND_BLUE; - break; - case 35: /* MAGENTA foreground */ - dev_state->fg = FOREGROUND_RED | FOREGROUND_BLUE; - break; - case 36: /* CYAN foreground */ - dev_state->fg = FOREGROUND_BLUE | FOREGROUND_GREEN; - break; - case 37: /* WHITE foreg */ - dev_state->fg = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED; - break; - case 39: - dev_state->fg = dev_state->default_color & FOREGROUND_ATTR_MASK; - break; - case 40: /* BLACK background */ - dev_state->bg = 0; - break; - case 41: /* RED background */ - dev_state->bg = BACKGROUND_RED; - break; - case 42: /* GREEN background */ - dev_state->bg = BACKGROUND_GREEN; - break; - case 43: /* YELLOW background */ - dev_state->bg = BACKGROUND_RED | BACKGROUND_GREEN; - break; - case 44: /* BLUE background */ - dev_state->bg = BACKGROUND_BLUE; - break; - case 45: /* MAGENTA background */ - dev_state->bg = BACKGROUND_RED | BACKGROUND_BLUE; - break; - case 46: /* CYAN background */ - dev_state->bg = BACKGROUND_BLUE | BACKGROUND_GREEN; - break; - case 47: /* WHITE background */ - dev_state->bg = BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED; - break; - case 49: - dev_state->bg = dev_state->default_color & BACKGROUND_ATTR_MASK; - break; - } - dev_state->set_color (get_output_handle ()); - break; - case 'h': - case 'l': - if (!dev_state->saw_question_mark) - { - switch (dev_state->args_[0]) - { - case 4: /* Insert mode */ - dev_state->insert_mode = (c == 'h') ? true : false; - syscall_printf ("insert mode %sabled", dev_state->insert_mode ? "en" : "dis"); - break; - } - break; - } - switch (dev_state->args_[0]) - { - case 47: /* Save/Restore screen */ - if (c == 'h') /* save */ - { - CONSOLE_SCREEN_BUFFER_INFO now; - COORD cob = { 0, 0 }; - - if (!GetConsoleScreenBufferInfo (get_output_handle (), &now)) - break; - - dev_state->savebufsiz.X = now.srWindow.Right - now.srWindow.Left + 1; - dev_state->savebufsiz.Y = now.srWindow.Bottom - now.srWindow.Top + 1; - - if (dev_state->savebuf) - cfree (dev_state->savebuf); - dev_state->savebuf = (PCHAR_INFO) cmalloc_abort (HEAP_1_BUF, sizeof (CHAR_INFO) * - dev_state->savebufsiz.X * dev_state->savebufsiz.Y); - - ReadConsoleOutputW (get_output_handle (), dev_state->savebuf, - dev_state->savebufsiz, cob, &now.srWindow); - } - else /* restore */ - { - CONSOLE_SCREEN_BUFFER_INFO now; - COORD cob = { 0, 0 }; - - if (!GetConsoleScreenBufferInfo (get_output_handle (), &now)) - break; - - if (!dev_state->savebuf) - break; - - WriteConsoleOutputW (get_output_handle (), dev_state->savebuf, - dev_state->savebufsiz, cob, &now.srWindow); - - cfree (dev_state->savebuf); - dev_state->savebuf = NULL; - dev_state->savebufsiz.X = dev_state->savebufsiz.Y = 0; - } - break; - - case 1000: /* Mouse tracking */ - dev_state->use_mouse = (c == 'h') ? 1 : 0; - syscall_printf ("mouse support set to mode %d", dev_state->use_mouse); - break; - - case 1002: /* Mouse button event tracking */ - dev_state->use_mouse = (c == 'h') ? 2 : 0; - syscall_printf ("mouse support set to mode %d", dev_state->use_mouse); - break; - - case 1003: /* Mouse any event tracking */ - dev_state->use_mouse = (c == 'h') ? 3 : 0; - syscall_printf ("mouse support set to mode %d", dev_state->use_mouse); - break; - - case 1004: /* Focus in/out event reporting */ - dev_state->use_focus = (c == 'h') ? true : false; - syscall_printf ("focus reporting set to %d", dev_state->use_focus); - break; - - case 2000: /* Raw keyboard mode */ - set_raw_win32_keyboard_mode ((c == 'h') ? true : false); - break; - - default: /* Ignore */ - syscall_printf ("unknown h/l command: %d", dev_state->args_[0]); - break; - } - break; - case 'J': - switch (dev_state->args_[0]) - { - case 0: /* Clear to end of screen */ - cursor_get (&x, &y); - clear_screen (x, y, -1, -1); - break; - case 1: /* Clear from beginning of screen to cursor */ - cursor_get (&x, &y); - clear_screen (0, 0, x, y); - break; - case 2: /* Clear screen */ - clear_screen (0, 0, -1, -1); - cursor_set (true, 0,0); - break; - default: - goto bad_escape; - } - break; - - case 'A': - cursor_rel (0, -(dev_state->args_[0] ? dev_state->args_[0] : 1)); - break; - case 'B': - cursor_rel (0, dev_state->args_[0] ? dev_state->args_[0] : 1); - break; - case 'C': - cursor_rel (dev_state->args_[0] ? dev_state->args_[0] : 1, 0); - break; - case 'D': - cursor_rel (-(dev_state->args_[0] ? dev_state->args_[0] : 1),0); - break; - case 'K': - switch (dev_state->args_[0]) - { - case 0: /* Clear to end of line */ - cursor_get (&x, &y); - clear_screen (x, y, -1, y); - break; - case 2: /* Clear line */ - cursor_get (&x, &y); - clear_screen (0, y, -1, y); - break; - case 1: /* Clear from bol to cursor */ - cursor_get (&x, &y); - clear_screen (0, y, x, y); - break; - default: - goto bad_escape; - } - break; - case 'H': - case 'f': - cursor_set (true, (dev_state->args_[1] ? dev_state->args_[1] : 1) - 1, - (dev_state->args_[0] ? dev_state->args_[0] : 1) - 1); - break; - case 'G': /* hpa - position cursor at column n - 1 */ - cursor_get (&x, &y); - cursor_set (false, (dev_state->args_[0] ? dev_state->args_[0] - 1 : 0), y); - break; - case 'd': /* vpa - position cursor at line n */ - cursor_get (&x, &y); - cursor_set (true, x, (dev_state->args_[0] ? dev_state->args_[0] - 1 : 0)); - break; - case 's': /* Save cursor position */ - cursor_get (&dev_state->savex, &dev_state->savey); - dev_state->savey -= dev_state->info.winTop; - break; - case 'u': /* Restore cursor position */ - cursor_set (true, dev_state->savex, dev_state->savey); - break; - case 'I': /* TAB */ - cursor_get (&x, &y); - cursor_set (false, 8 * (x / 8 + 1), y); - break; - case 'L': /* AL - insert blank lines */ - dev_state->args_[0] = dev_state->args_[0] ? dev_state->args_[0] : 1; - cursor_get (&x, &y); - scroll_screen (0, y, -1, -1, 0, y + dev_state->args_[0]); - break; - case 'M': /* DL - delete lines */ - dev_state->args_[0] = dev_state->args_[0] ? dev_state->args_[0] : 1; - cursor_get (&x, &y); - scroll_screen (0, y + dev_state->args_[0], -1, -1, 0, y); - break; - case '@': /* IC - insert chars */ - dev_state->args_[0] = dev_state->args_[0] ? dev_state->args_[0] : 1; - cursor_get (&x, &y); - scroll_screen (x, y, -1, y, x + dev_state->args_[0], y); - break; - case 'P': /* DC - delete chars */ - dev_state->args_[0] = dev_state->args_[0] ? dev_state->args_[0] : 1; - cursor_get (&x, &y); - scroll_screen (x + dev_state->args_[0], y, -1, y, x, y); - break; - case 'S': /* SF - Scroll forward */ - dev_state->args_[0] = dev_state->args_[0] ? dev_state->args_[0] : 1; - scroll_screen (0, dev_state->args_[0], -1, -1, 0, 0); - break; - case 'T': /* SR - Scroll down */ - dev_state->fillin_info (get_output_handle ()); - dev_state->args_[0] = dev_state->args_[0] ? dev_state->args_[0] : 1; - scroll_screen (0, 0, -1, -1, 0, dev_state->info.winTop + dev_state->args_[0]); - break; - case 'X': /* ec - erase chars */ - dev_state->args_[0] = dev_state->args_[0] ? dev_state->args_[0] : 1; - cursor_get (&x, &y); - scroll_screen (x + dev_state->args_[0], y, -1, y, x, y); - scroll_screen (x, y, -1, y, x + dev_state->args_[0], y); - break; - case 'Z': /* Back tab */ - cursor_get (&x, &y); - cursor_set (false, ((8 * (x / 8 + 1)) - 8), y); - break; - case 'b': /* Repeat char #1 #2 times */ - if (dev_state->insert_mode) - { - cursor_get (&x, &y); - scroll_screen (x, y, -1, y, x + dev_state->args_[1], y); - } - while (dev_state->args_[1]--) - WriteFile (get_output_handle (), &dev_state->args_[0], 1, (DWORD *) &x, 0); - break; - case 'c': /* u9 - Terminal enquire string */ - if (dev_state->saw_greater_than_sign) - /* Generate Secondary Device Attribute report, using 67 = ASCII 'C' - to indicate Cygwin (convention used by Rxvt, Urxvt, Screen, Mintty), - and cygwin version for terminal version. */ - __small_sprintf (buf, "\033[>67;%d%02d;0c", CYGWIN_VERSION_DLL_MAJOR, CYGWIN_VERSION_DLL_MINOR); - else - strcpy (buf, "\033[?6c"); - /* The generated report needs to be injected for read-ahead into the - fhandler_console object associated with standard input. - The current call does not work. */ - puts_readahead (buf); - break; - case 'n': - switch (dev_state->args_[0]) - { - case 6: /* u7 - Cursor position request */ - cursor_get (&x, &y); - y -= dev_state->info.winTop; - /* x -= dev_state->info.winLeft; // not available yet */ - __small_sprintf (buf, "\033[%d;%dR", y + 1, x + 1); - puts_readahead (buf); - break; - default: - goto bad_escape; - } - break; - case 'r': /* Set Scroll region */ - dev_state->scroll_region.Top = dev_state->args_[0] ? dev_state->args_[0] - 1 : 0; - dev_state->scroll_region.Bottom = dev_state->args_[1] ? dev_state->args_[1] - 1 : -1; - cursor_set (true, 0, 0); - break; - case 'g': /* TAB set/clear */ - break; - default: -bad_escape: - break; - } -} - -/* This gets called when we found an invalid input character. We just - print a half filled square (UTF 0x2592). We have no chance to figure - out the "meaning" of the input char anyway. */ -inline void -fhandler_console::write_replacement_char () -{ - static const wchar_t replacement_char = 0x2592; /* Half filled square */ - DWORD done; - WriteConsoleW (get_output_handle (), &replacement_char, 1, &done, 0); -} - -const unsigned char * -fhandler_console::write_normal (const unsigned char *src, - const unsigned char *end) -{ - /* Scan forward to see what a char which needs special treatment */ - DWORD done; - DWORD buf_len; - const unsigned char *found = src; - size_t ret; - mbstate_t ps; - UINT cp = dev_state->get_console_cp (); - const char *charset; - mbtowc_p f_mbtowc; - - if (cp) - { - /* The alternate charset is always 437, just as in the Linux console. */ - f_mbtowc = __cp_mbtowc; - charset = "CP437"; - } - else - { - f_mbtowc = cygheap->locale.mbtowc; - charset = cygheap->locale.charset; - } - - /* First check if we have cached lead bytes of a former try to write - a truncated multibyte sequence. If so, process it. */ - if (trunc_buf.len) - { - const unsigned char *nfound; - int cp_len = min (end - src, 4 - trunc_buf.len); - memcpy (trunc_buf.buf + trunc_buf.len, src, cp_len); - memset (&ps, 0, sizeof ps); - switch (ret = f_mbtowc (_REENT, NULL, (const char *) trunc_buf.buf, - trunc_buf.len + cp_len, charset, &ps)) - { - case -2: - /* Still truncated multibyte sequence? Keep in trunc_buf. */ - trunc_buf.len += cp_len; - return end; - case -1: - /* Give up, print replacement chars for trunc_buf... */ - for (int i = 0; i < trunc_buf.len; ++i) - write_replacement_char (); - /* ... mark trunc_buf as unused... */ - trunc_buf.len = 0; - /* ... and proceed. */ - nfound = NULL; - break; - case 0: - nfound = trunc_buf.buf + 1; - break; - default: - nfound = trunc_buf.buf + ret; - break; - } - /* Valid multibyte sequence? Process. */ - if (nfound) - { - buf_len = dev_state->str_to_con (f_mbtowc, charset, write_buf, - (const char *) trunc_buf.buf, - nfound - trunc_buf.buf); - if (!write_console (write_buf, buf_len, done)) - { - debug_printf ("multibyte sequence write failed, handle %p", get_output_handle ()); - return 0; - } - found = src + (nfound - trunc_buf.buf - trunc_buf.len); - trunc_buf.len = 0; - return found; - } - } - - memset (&ps, 0, sizeof ps); - while (found < end - && found - src < CONVERT_LIMIT - && base_chars[*found] == NOR) - { - switch (ret = f_mbtowc (_REENT, NULL, (const char *) found, - end - found, charset, &ps)) - { - case -2: - /* Truncated multibyte sequence. Stick to it until the next write. */ - trunc_buf.len = end - found; - memcpy (trunc_buf.buf, found, trunc_buf.len); - return end; - case -1: - break; - case 0: - found++; - break; - default: - found += ret; - break; - } - if (ret == (size_t) -1) /* Invalid multibyte sequence. */ - break; - } - - /* Print all the base ones out */ - if (found != src) - { - DWORD len = found - src; - buf_len = dev_state->str_to_con (f_mbtowc, charset, write_buf, - (const char *) src, len); - if (!buf_len) - { - debug_printf ("conversion error, handle %p", - get_output_handle ()); - __seterrno (); - return 0; - } - - if (dev_state->insert_mode) - { - int x, y; - cursor_get (&x, &y); - scroll_screen (x, y, -1, y, x + buf_len, y); - } - - if (!write_console (write_buf, buf_len, done)) - { - debug_printf ("write failed, handle %p", get_output_handle ()); - return 0; - } - if (len >= CONVERT_LIMIT) - return found; - } - - if (found < end) - { - int x, y; - switch (base_chars[*found]) - { - case SO: - dev_state->vt100_graphics_mode_active = true; - break; - case SI: - dev_state->vt100_graphics_mode_active = false; - break; - case BEL: - beep (); - break; - case ESC: - dev_state->state_ = gotesc; - break; - case DWN: - cursor_get (&x, &y); - if (y >= srBottom) - { - if (y >= dev_state->info.winBottom && !dev_state->scroll_region.Top) - WriteConsoleW (get_output_handle (), L"\n", 1, &done, 0); - else - { - scroll_screen (0, srTop + 1, -1, srBottom, 0, srTop); - y--; - } - } - cursor_set (false, ((tc->ti.c_oflag & ONLCR) ? 0 : x), y + 1); - break; - case BAK: - cursor_rel (-1, 0); - break; - case IGN: - cursor_rel (1, 0); - break; - case CR: - cursor_get (&x, &y); - cursor_set (false, 0, y); - break; - case ERR: - /* Don't print chars marked as ERR chars, except for a ASCII CAN - sequence which is printed as singlebyte chars from the UTF - Basic Latin and Latin 1 Supplement plains. */ - if (*found == 0x18) - { - write_replacement_char (); - if (found + 1 < end) - { - ret = __utf8_mbtowc (_REENT, NULL, (const char *) found + 1, - end - found - 1, NULL, &ps); - if (ret != (size_t) -1) - while (ret-- > 0) - { - WCHAR w = *(found + 1); - WriteConsoleW (get_output_handle (), &w, 1, &done, 0); - found++; - } - } - } - break; - case TAB: - cursor_get (&x, &y); - cursor_set (false, 8 * (x / 8 + 1), y); - break; - case NOR: - write_replacement_char (); - break; - } - found++; - } - return found; -} - -ssize_t __stdcall -fhandler_console::write (const void *vsrc, size_t len) -{ - /* Run and check for ansi sequences */ - unsigned const char *src = (unsigned char *) vsrc; - unsigned const char *end = src + len; - /* This might look a bit far fetched, but using the TLS path buffer allows - to allocate a big buffer without using the stack too much. Doing it here - in write instead of in write_normal should be faster, too. */ - tmp_pathbuf tp; - write_buf = tp.w_get (); - - debug_printf ("%x, %d", vsrc, len); - - while (src < end) - { - debug_printf ("at %d(%c) state is %d", *src, isprint (*src) ? *src : ' ', - dev_state->state_); - switch (dev_state->state_) - { - case normal: - src = write_normal (src, end); - if (!src) /* write_normal failed */ - return -1; - break; - case gotesc: - if (*src == '[') /* CSI Control Sequence Introducer */ - { - dev_state->state_ = gotsquare; - dev_state->saw_question_mark = false; - dev_state->saw_greater_than_sign = false; - for (dev_state->nargs_ = 0; dev_state->nargs_ < MAXARGS; dev_state->nargs_++) - dev_state->args_[dev_state->nargs_] = 0; - dev_state->nargs_ = 0; - } - else if (*src == ']') /* OSC Operating System Command */ - { - dev_state->rarg = 0; - dev_state->my_title_buf[0] = '\0'; - dev_state->state_ = gotrsquare; - } - else if (*src == '(') /* Designate G0 character set */ - { - dev_state->state_ = gotparen; - } - else if (*src == ')') /* Designate G1 character set */ - { - dev_state->state_ = gotrparen; - } - else if (*src == 'M') /* Reverse Index (scroll down) */ - { - dev_state->fillin_info (get_output_handle ()); - scroll_screen (0, 0, -1, -1, 0, dev_state->info.winTop + 1); - dev_state->state_ = normal; - } - else if (*src == 'c') /* RIS Full Reset */ - { - dev_state->set_default_attr (); - clear_screen (0, 0, -1, -1); - cursor_set (true, 0, 0); - dev_state->state_ = normal; - } - else if (*src == '8') /* DECRC Restore cursor position */ - { - cursor_set (true, dev_state->savex, dev_state->savey); - dev_state->state_ = normal; - } - else if (*src == '7') /* DECSC Save cursor position */ - { - cursor_get (&dev_state->savex, &dev_state->savey); - dev_state->savey -= dev_state->info.winTop; - dev_state->state_ = normal; - } - else if (*src == 'R') /* ? */ - dev_state->state_ = normal; - else - { - dev_state->state_ = normal; - } - src++; - break; - case gotarg1: - if (isdigit (*src)) - { - dev_state->args_[dev_state->nargs_] = dev_state->args_[dev_state->nargs_] * 10 + *src - '0'; - src++; - } - else if (*src == ';') - { - src++; - dev_state->nargs_++; - if (dev_state->nargs_ >= MAXARGS) - dev_state->nargs_--; - } - else - { - dev_state->state_ = gotcommand; - } - break; - case gotcommand: - char_command (*src++); - dev_state->state_ = normal; - break; - case gotrsquare: - if (isdigit (*src)) - dev_state->rarg = dev_state->rarg * 10 + (*src - '0'); - else if (*src == ';' && (dev_state->rarg == 2 || dev_state->rarg == 0)) - dev_state->state_ = gettitle; - else - dev_state->state_ = eattitle; - src++; - break; - case eattitle: - case gettitle: - { - int n = strlen (dev_state->my_title_buf); - if (*src < ' ') - { - if (*src == '\007' && dev_state->state_ == gettitle) - { - if (old_title) - strcpy (old_title, dev_state->my_title_buf); - set_console_title (dev_state->my_title_buf); - } - dev_state->state_ = normal; - } - else if (n < TITLESIZE) - { - dev_state->my_title_buf[n++] = *src; - dev_state->my_title_buf[n] = '\0'; - } - src++; - break; - } - case gotsquare: - if (*src == ';') - { - dev_state->state_ = gotarg1; - dev_state->nargs_++; - src++; - } - else if (isalpha (*src)) - dev_state->state_ = gotcommand; - else if (*src != '@' && !isalpha (*src) && !isdigit (*src)) - { - if (*src == '?') - dev_state->saw_question_mark = true; - else if (*src == '>') - dev_state->saw_greater_than_sign = true; - /* ignore any extra chars between [ and first arg or command */ - src++; - } - else - dev_state->state_ = gotarg1; - break; - case gotparen: - if (*src == '0') - dev_state->vt100_graphics_mode_active = true; - else - dev_state->vt100_graphics_mode_active = false; - dev_state->state_ = normal; - src++; - break; - case gotrparen: - /* This is not strictly needed, ^N/^O can just always be enabled */ - if (*src == '0') - /*dev_state->vt100_graphics_mode_SOSI_enabled = true*/; - else - /*dev_state->vt100_graphics_mode_SOSI_enabled = false*/; - dev_state->state_ = normal; - src++; - break; - } - } - - syscall_printf ("%d = fhandler_console::write (,..%d)", len, len); - - return len; -} - -static struct { - int vk; - const char *val[4]; -} keytable[] NO_COPY = { - /* NORMAL */ /* SHIFT */ /* CTRL */ /* CTRL-SHIFT */ - /* Unmodified and Alt-modified keypad keys comply with linux console - SHIFT, CTRL, CTRL-SHIFT modifiers comply with xterm modifier usage */ - {VK_NUMPAD5, {"\033[G", "\033[1;2G", "\033[1;5G", "\033[1;6G"}}, - {VK_CLEAR, {"\033[G", "\033[1;2G", "\033[1;5G", "\033[1;6G"}}, - {VK_LEFT, {"\033[D", "\033[1;2D", "\033[1;5D", "\033[1;6D"}}, - {VK_RIGHT, {"\033[C", "\033[1;2C", "\033[1;5C", "\033[1;6C"}}, - {VK_UP, {"\033[A", "\033[1;2A", "\033[1;5A", "\033[1;6A"}}, - {VK_DOWN, {"\033[B", "\033[1;2B", "\033[1;5B", "\033[1;6B"}}, - {VK_PRIOR, {"\033[5~", "\033[5;2~", "\033[5;5~", "\033[5;6~"}}, - {VK_NEXT, {"\033[6~", "\033[6;2~", "\033[6;5~", "\033[6;6~"}}, - {VK_HOME, {"\033[1~", "\033[1;2~", "\033[1;5~", "\033[1;6~"}}, - {VK_END, {"\033[4~", "\033[4;2~", "\033[4;5~", "\033[4;6~"}}, - {VK_INSERT, {"\033[2~", "\033[2;2~", "\033[2;5~", "\033[2;6~"}}, - {VK_DELETE, {"\033[3~", "\033[3;2~", "\033[3;5~", "\033[3;6~"}}, - /* F1...F12, SHIFT-F1...SHIFT-F10 comply with linux console - F6...F12, and all modified F-keys comply with rxvt (compatible extension) */ - {VK_F1, {"\033[[A", "\033[23~", "\033[11^", "\033[23^"}}, - {VK_F2, {"\033[[B", "\033[24~", "\033[12^", "\033[24^"}}, - {VK_F3, {"\033[[C", "\033[25~", "\033[13^", "\033[25^"}}, - {VK_F4, {"\033[[D", "\033[26~", "\033[14^", "\033[26^"}}, - {VK_F5, {"\033[[E", "\033[28~", "\033[15^", "\033[28^"}}, - {VK_F6, {"\033[17~", "\033[29~", "\033[17^", "\033[29^"}}, - {VK_F7, {"\033[18~", "\033[31~", "\033[18^", "\033[31^"}}, - {VK_F8, {"\033[19~", "\033[32~", "\033[19^", "\033[32^"}}, - {VK_F9, {"\033[20~", "\033[33~", "\033[20^", "\033[33^"}}, - {VK_F10, {"\033[21~", "\033[34~", "\033[21^", "\033[34^"}}, - {VK_F11, {"\033[23~", "\033[23$", "\033[23^", "\033[23@"}}, - {VK_F12, {"\033[24~", "\033[24$", "\033[24^", "\033[24@"}}, - /* CTRL-6 complies with Windows cmd console but should be fixed */ - {'6', {NULL, NULL, "\036", NULL}}, - /* Table end marker */ - {0} -}; - -const char * -get_nonascii_key (INPUT_RECORD& input_rec, char *tmp) -{ -#define NORMAL 0 -#define SHIFT 1 -#define CONTROL 2 -/*#define CONTROLSHIFT 3*/ - - int modifier_index = NORMAL; - if (input_rec.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED) - modifier_index = SHIFT; - if (input_rec.Event.KeyEvent.dwControlKeyState & - (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) - modifier_index += CONTROL; - - for (int i = 0; keytable[i].vk; i++) - if (input_rec.Event.KeyEvent.wVirtualKeyCode == keytable[i].vk) - { - if ((input_rec.Event.KeyEvent.dwControlKeyState & - (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) - && keytable[i].val[modifier_index] != NULL) - { /* Generic ESC prefixing if Alt is pressed */ - tmp[0] = '\033'; - strcpy (tmp + 1, keytable[i].val[modifier_index]); - return tmp; - } - else - return keytable[i].val[modifier_index]; - } - - if (input_rec.Event.KeyEvent.uChar.AsciiChar) - { - tmp[0] = input_rec.Event.KeyEvent.uChar.AsciiChar; - tmp[1] = '\0'; - return tmp; - } - return NULL; -} - -int -fhandler_console::init (HANDLE f, DWORD a, mode_t bin) -{ - // this->fhandler_termios::init (f, mode, bin); - /* Ensure both input and output console handles are open */ - int flags = 0; - - a &= GENERIC_READ | GENERIC_WRITE; - if (a == GENERIC_READ) - flags = O_RDONLY; - if (a == GENERIC_WRITE) - flags = O_WRONLY; - if (a == (GENERIC_READ | GENERIC_WRITE)) - flags = O_RDWR; - open (flags | O_BINARY); - if (f != INVALID_HANDLE_VALUE) - CloseHandle (f); /* Reopened by open */ - - return !tcsetattr (0, &tc->ti); -} - -int -fhandler_console::igncr_enabled () -{ - return tc->ti.c_iflag & IGNCR; -} - -void -fhandler_console::set_close_on_exec (bool val) -{ - fhandler_base::set_close_on_exec (val); - set_no_inheritance (output_handle, val); -} - -void __stdcall -set_console_title (char *title) -{ - wchar_t buf[TITLESIZE + 1]; - sys_mbstowcs (buf, TITLESIZE + 1, title); - lock_ttys here (15000); - SetConsoleTitleW (buf); - debug_printf ("title '%W'", buf); -} - -void -fhandler_console::fixup_after_fork_exec (bool execing) -{ - HANDLE h = get_handle (); - HANDLE oh = get_output_handle (); - - if ((execing && close_on_exec ()) || open (O_NOCTTY | get_flags (), 0)) - cygheap->manage_console_count ("fhandler_console::fixup_after_fork_exec", -1); - else - { - bool sawerr = false; - if (!get_io_handle ()) - { - system_printf ("error opening input console handle for %s after fork/exec, errno %d, %E", get_name (), get_errno ()); - sawerr = true; - } - if (!get_output_handle ()) - { - system_printf ("error opening output console handle for %s after fork/exec, errno %d, %E", get_name (), get_errno ()); - sawerr = true; - } - - if (!sawerr) - system_printf ("error opening console after fork/exec, errno %d, %E", get_errno ()); - } - - if (!close_on_exec ()) - { - CloseHandle (h); - CloseHandle (oh); - } -} - -bool NO_COPY fhandler_console::invisible_console; - -// #define WINSTA_ACCESS (WINSTA_READATTRIBUTES | STANDARD_RIGHTS_READ | STANDARD_RIGHTS_WRITE | WINSTA_CREATEDESKTOP | WINSTA_EXITWINDOWS) -#define WINSTA_ACCESS WINSTA_ALL_ACCESS - -/* Create a console in an invisible window station. This should work - in all versions of Windows NT except Windows 7 (so far). */ -bool -fhandler_console::create_invisible_console (HWINSTA horig) -{ - HWINSTA h = CreateWindowStationW (NULL, 0, WINSTA_ACCESS, NULL); - termios_printf ("%p = CreateWindowStation(NULL), %E", h); - BOOL b; - if (h) - { - b = SetProcessWindowStation (h); - termios_printf ("SetProcessWindowStation %d, %E", b); - } - b = AllocConsole (); /* will cause flashing if CreateWindowStation - failed */ - if (!h) - SetParent (GetConsoleWindow (), HWND_MESSAGE); - if (horig && h && h != horig && SetProcessWindowStation (horig)) - CloseWindowStation (h); - termios_printf ("%d = AllocConsole (), %E", b); - invisible_console = true; - return b; -} - -/* Ugly workaround for Windows 7. - - First try to just attach to any console which may have started this - app. If that works use this as our "invisible console". - - This will fail if not started from the command prompt. In that case, start - a dummy console application in a hidden state so that we can use its console - as our invisible console. This probably works everywhere but process - creation is slow and to be avoided if possible so the window station method - is vastly preferred. - - FIXME: This is not completely thread-safe since it creates two inheritable - handles which are known only to this function. If another thread starts - a process the new process will inherit these handles. However, since this - function is currently only called at startup and during exec, it shouldn't - be a big deal. */ -bool -fhandler_console::create_invisible_console_workaround () -{ - if (!AttachConsole (-1)) - { - bool taskbar; - DWORD err = GetLastError (); - path_conv helper ("/bin/cygwin-console-helper.exe"); - HANDLE hello = NULL; - HANDLE goodbye = NULL; - /* If err == ERROR_PROC_FOUND then this method won't work. But that's - ok. The window station method should work ok when AttachConsole doesn't - work. - - If the helper doesn't exist or we can't create event handles then we - can't use this method. */ - if (err == ERROR_PROC_NOT_FOUND || !helper.exists () - || !(hello = CreateEvent (&sec_none, true, false, NULL)) - || !(goodbye = CreateEvent (&sec_none, true, false, NULL))) - { - AllocConsole (); /* This is just sanity check code. We should - never actually hit here unless we're running - in an environment which lacks the helper - app. */ - taskbar = true; - } - else - { - STARTUPINFOW si = {}; - PROCESS_INFORMATION pi; - size_t len = helper.get_wide_win32_path_len (); - WCHAR cmd[len + (2 * strlen (" 0xffffffff")) + 1]; - WCHAR title[] = L"invisible cygwin console"; - - helper.get_wide_win32_path (cmd); - __small_swprintf (cmd + len, L" %p %p", hello, goodbye); - - si.cb = sizeof (si); - si.dwFlags = STARTF_USESHOWWINDOW; - si.wShowWindow = SW_HIDE; - si.lpTitle = title; - - /* Create a new hidden process. Use the two event handles as - argv[1] and argv[2]. */ - BOOL x = CreateProcessW (NULL, cmd, &sec_none_nih, &sec_none_nih, true, - CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi); - if (x) - { - CloseHandle (pi.hProcess); /* Don't need */ - CloseHandle (pi.hThread); /* these. */ - } - taskbar = false; - /* Wait for subprocess to indicate that it is live. This may not - actually be needed but it's hard to say since it is possible that - there will be no console for a brief time after the process - returns and there is no easy way to determine if/when this happens - in Windows. So play it safe. */ - if (!x || (WaitForSingleObject (hello, 10000) != WAIT_OBJECT_0) - || !AttachConsole (pi.dwProcessId)) - AllocConsole (); /* Oh well. Watch the flash. */ - } - - if (!taskbar) - /* Setting the owner of the console window to HWND_MESSAGE seems to - hide it from the taskbar. Don't know if this method is faster than - calling ShowWindowAsync but it should guarantee no taskbar presence - for the hidden console. */ - SetParent (GetConsoleWindow (), HWND_MESSAGE); - if (hello) - CloseHandle (hello); - if (goodbye) - { - SetEvent (goodbye); /* Tell helper process it's ok to exit. */ - CloseHandle (goodbye); - } - } - return invisible_console = true; -} - -bool -fhandler_console::need_invisible () -{ - BOOL b = false; - if (GetConsoleCP ()) - invisible_console = false; - else - { - HWINSTA h; - /* The intent here is to allocate an "invisible" console if we have no - controlling tty or to reuse the existing console if we already have - a tty. So, first get the old window station. If there is no controlling - terminal, create a new window station and then set it as the current - window station. The subsequent AllocConsole will then be allocated - invisibly. But, after doing that we have to restore any existing windows - station or, strangely, characters will not be displayed in any windows - drawn on the current screen. We only do this if we have changed to - a new window station and if we had an existing windows station previously. - We also close the previously opened window station even though AllocConsole - is now "using" it. This doesn't seem to cause any problems. - - Things to watch out for if you make changes in this code: - - - Flashing, black consoles showing up when you start, e.g., ssh in - an xterm. - - Non-displaying of characters in rxvt or xemacs if you start a - process using setsid: bash -lc "setsid rxvt". */ - - h = GetProcessWindowStation (); - - USEROBJECTFLAGS oi; - DWORD len; - if (!h - || !GetUserObjectInformationW (h, UOI_FLAGS, &oi, sizeof (oi), &len) - || !(oi.dwFlags & WSF_VISIBLE)) - { - b = true; - debug_printf ("window station is not visible"); - AllocConsole (); - invisible_console = true; - } - else if (wincap.has_broken_alloc_console ()) - b = create_invisible_console_workaround (); - else - b = create_invisible_console (h); - } - - debug_printf ("invisible_console %d", invisible_console); - return b; -} diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc deleted file mode 100644 index b6c67b955..000000000 --- a/winsup/cygwin/fhandler_disk_file.cc +++ /dev/null @@ -1,2287 +0,0 @@ -/* fhandler_disk_file.cc - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "shared_info.h" -#include "pinfo.h" -#include "ntdll.h" -#include "tls_pbuf.h" -#include "nfs.h" -#include "pwdgrp.h" -#include - -#define _COMPILING_NEWLIB -#include - -class __DIR_mounts -{ - int count; - const char *parent_dir; - int parent_dir_len; - UNICODE_STRING mounts[MAX_MOUNTS]; - bool found[MAX_MOUNTS + 2]; - UNICODE_STRING cygdrive; - -#define __DIR_PROC (MAX_MOUNTS) -#define __DIR_CYGDRIVE (MAX_MOUNTS+1) - - __ino64_t eval_ino (int idx) - { - __ino64_t ino = 0; - char fname[parent_dir_len + mounts[idx].Length + 2]; - struct __stat64 st; - - char *c = stpcpy (fname, parent_dir); - if (c[- 1] != '/') - *c++ = '/'; - sys_wcstombs (c, mounts[idx].Length + 1, - mounts[idx].Buffer, mounts[idx].Length / sizeof (WCHAR)); - path_conv pc (fname, PC_SYM_NOFOLLOW | PC_POSIX); - if (!stat_worker (pc, &st)) - ino = st.st_ino; - return ino; - } - -public: - __DIR_mounts (const char *posix_path) - : parent_dir (posix_path) - { - parent_dir_len = strlen (parent_dir); - count = mount_table->get_mounts_here (parent_dir, parent_dir_len, mounts, - &cygdrive); - rewind (); - } - ~__DIR_mounts () - { - for (int i = 0; i < count; ++i) - RtlFreeUnicodeString (&mounts[i]); - RtlFreeUnicodeString (&cygdrive); - } - __ino64_t check_mount (PUNICODE_STRING fname, __ino64_t ino, - bool eval = true) - { - if (parent_dir_len == 1) /* root dir */ - { - if (RtlEqualUnicodeString (fname, &ro_u_proc, FALSE)) - { - found[__DIR_PROC] = true; - return 2; - } - if (fname->Length / sizeof (WCHAR) == mount_table->cygdrive_len - 2 - && RtlEqualUnicodeString (fname, &cygdrive, FALSE)) - { - found[__DIR_CYGDRIVE] = true; - return 2; - } - } - for (int i = 0; i < count; ++i) - if (RtlEqualUnicodeString (fname, &mounts[i], FALSE)) - { - found[i] = true; - return eval ? eval_ino (i) : 1; - } - return ino; - } - __ino64_t check_missing_mount (PUNICODE_STRING retname = NULL) - { - for (int i = 0; i < count; ++i) - if (!found[i]) - { - found[i] = true; - if (retname) - { - *retname = mounts[i]; - return eval_ino (i); - } - return 1; - } - if (parent_dir_len == 1) /* root dir */ - { - if (!found[__DIR_PROC]) - { - found[__DIR_PROC] = true; - if (retname) - RtlInitUnicodeString (retname, L"proc"); - return 2; - } - if (!found[__DIR_CYGDRIVE]) - { - found[__DIR_CYGDRIVE] = true; - if (cygdrive.Length > 0) - { - if (retname) - *retname = cygdrive; - return 2; - } - } - } - return 0; - } - void rewind () { memset (found, 0, sizeof found); } -}; - -inline bool -path_conv::isgood_inode (__ino64_t ino) const -{ - /* We can't trust remote inode numbers of only 32 bit. That means, - all remote inode numbers when running under NT4, as well as remote NT4 - NTFS, as well as shares of Samba version < 3.0. - The known exception are SFU NFS shares, which return the valid 32 bit - inode number from the remote file system unchanged. */ - return hasgood_inode () && (ino > UINT32_MAX || !isremote () || fs_is_nfs ()); -} - -static inline bool -is_volume_mountpoint (POBJECT_ATTRIBUTES attr) -{ - bool ret = false; - IO_STATUS_BLOCK io; - HANDLE reph; - UNICODE_STRING subst; - - if (NT_SUCCESS (NtOpenFile (&reph, READ_CONTROL, attr, &io, - FILE_SHARE_VALID_FLAGS, - FILE_OPEN_FOR_BACKUP_INTENT - | FILE_OPEN_REPARSE_POINT))) - { - PREPARSE_DATA_BUFFER rp = (PREPARSE_DATA_BUFFER) - alloca (MAXIMUM_REPARSE_DATA_BUFFER_SIZE); - if (NT_SUCCESS (NtFsControlFile (reph, NULL, NULL, NULL, - &io, FSCTL_GET_REPARSE_POINT, NULL, 0, - (LPVOID) rp, MAXIMUM_REPARSE_DATA_BUFFER_SIZE)) - && rp->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT - && (RtlInitCountedUnicodeString (&subst, - (WCHAR *)((char *)rp->MountPointReparseBuffer.PathBuffer - + rp->MountPointReparseBuffer.SubstituteNameOffset), - rp->MountPointReparseBuffer.SubstituteNameLength), - RtlEqualUnicodePathPrefix (&subst, &ro_u_volume, TRUE))) - ret = true; - NtClose (reph); - } - return ret; -} - -static inline __ino64_t -get_ino_by_handle (path_conv &pc, HANDLE hdl) -{ - IO_STATUS_BLOCK io; - FILE_INTERNAL_INFORMATION fai; - - if (NT_SUCCESS (NtQueryInformationFile (hdl, &io, &fai, sizeof fai, - FileInternalInformation)) - && pc.isgood_inode (fai.FileId.QuadPart)) - return fai.FileId.QuadPart; - return 0; -} - -unsigned __stdcall -path_conv::ndisk_links (DWORD nNumberOfLinks) -{ - if (!isdir () || isremote ()) - return nNumberOfLinks; - - OBJECT_ATTRIBUTES attr; - IO_STATUS_BLOCK io; - HANDLE fh; - - if (!NT_SUCCESS (NtOpenFile (&fh, SYNCHRONIZE | FILE_LIST_DIRECTORY, - get_object_attr (attr, sec_none_nih), - &io, FILE_SHARE_VALID_FLAGS, - FILE_SYNCHRONOUS_IO_NONALERT - | FILE_OPEN_FOR_BACKUP_INTENT - | FILE_DIRECTORY_FILE))) - return nNumberOfLinks; - - unsigned count = 0; - bool first = true; - PFILE_BOTH_DIRECTORY_INFORMATION fdibuf = (PFILE_BOTH_DIRECTORY_INFORMATION) - alloca (65536); - __DIR_mounts *dir = new __DIR_mounts (normalized_path); - while (NT_SUCCESS (NtQueryDirectoryFile (fh, NULL, NULL, NULL, &io, fdibuf, - 65536, FileBothDirectoryInformation, - FALSE, NULL, first))) - { - if (first) - { - first = false; - /* All directories have . and .. as their first entries. - If . is not present as first entry, we're on a drive's - root direcotry, which doesn't have these entries. */ - if (fdibuf->FileNameLength != 2 || fdibuf->FileName[0] != L'.') - count = 2; - } - for (PFILE_BOTH_DIRECTORY_INFORMATION pfdi = fdibuf; - pfdi; - pfdi = (PFILE_BOTH_DIRECTORY_INFORMATION) - (pfdi->NextEntryOffset ? (PBYTE) pfdi + pfdi->NextEntryOffset - : NULL)) - { - switch (pfdi->FileAttributes - & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_REPARSE_POINT)) - { - case FILE_ATTRIBUTE_DIRECTORY: - /* Just a directory */ - ++count; - break; - case FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_REPARSE_POINT: - /* Volume mount point or symlink to directory */ - { - UNICODE_STRING fname; - - RtlInitCountedUnicodeString (&fname, pfdi->FileName, - pfdi->FileNameLength); - InitializeObjectAttributes (&attr, &fname, - objcaseinsensitive (), fh, NULL); - if (is_volume_mountpoint (&attr)) - ++count; - } - break; - default: - break; - } - UNICODE_STRING fname; - RtlInitCountedUnicodeString (&fname, pfdi->FileName, - pfdi->FileNameLength); - dir->check_mount (&fname, 0, false); - } - } - while (dir->check_missing_mount ()) - ++count; - NtClose (fh); - delete dir; - return count; -} - -/* For files on NFS shares, we request an EA of type NfsV3Attributes. - This returns the content of a struct fattr3 as defined in RFC 1813. - The content is the NFS equivalent of struct stat. so there's not much - to do here except for copying. */ -int __stdcall -fhandler_base::fstat_by_nfs_ea (struct __stat64 *buf) -{ - NTSTATUS status; - IO_STATUS_BLOCK io; - struct { - FILE_FULL_EA_INFORMATION ffei; - char buf[sizeof (NFS_V3_ATTR) + sizeof (fattr3)]; - } ffei_buf; - struct { - FILE_GET_EA_INFORMATION fgei; - char buf[sizeof (NFS_V3_ATTR)]; - } fgei_buf; - - fgei_buf.fgei.NextEntryOffset = 0; - fgei_buf.fgei.EaNameLength = sizeof (NFS_V3_ATTR) - 1; - stpcpy (fgei_buf.fgei.EaName, NFS_V3_ATTR); - status = NtQueryEaFile (get_handle (), &io, - &ffei_buf.ffei, sizeof ffei_buf, TRUE, - &fgei_buf.fgei, sizeof fgei_buf, NULL, TRUE); - if (NT_SUCCESS (status)) - { - fattr3 *nfs_attr = (fattr3 *) (ffei_buf.ffei.EaName - + ffei_buf.ffei.EaNameLength + 1); - buf->st_dev = nfs_attr->fsid; - buf->st_ino = nfs_attr->fileid; - buf->st_mode = (nfs_attr->mode & 0xfff) - | nfs_type_mapping[nfs_attr->type & 7]; - buf->st_nlink = nfs_attr->nlink; - /* FIXME: How to convert UNIX uid/gid to Windows SIDs? */ -#if 0 - buf->st_uid = nfs_attr->uid; - buf->st_gid = nfs_attr->gid; -#else - buf->st_uid = myself->uid; - buf->st_gid = myself->gid; -#endif - buf->st_rdev = makedev (nfs_attr->rdev.specdata1, - nfs_attr->rdev.specdata2); - buf->st_size = nfs_attr->size; - buf->st_blksize = PREFERRED_IO_BLKSIZE; - buf->st_blocks = nfs_attr->used / 512; - buf->st_atim = nfs_attr->atime; - buf->st_mtim = nfs_attr->mtime; - buf->st_ctim = nfs_attr->ctime; - return 0; - } - debug_printf ("%p = NtQueryEaFile(%S)", status, pc.get_nt_native_path ()); - return -1; -} - -int __stdcall -fhandler_base::fstat_by_handle (struct __stat64 *buf) -{ - NTSTATUS status; - IO_STATUS_BLOCK io; - - if (pc.fs_is_nfs ()) - return fstat_by_nfs_ea (buf); - - /* Don't use FileAllInformation info class. It returns a pathname rather - than a filename, so it needs a really big buffer for no good reason - since we don't need the name anyway. So we just call the three info - classes necessary to get all information required by stat(2). */ - - union { - FILE_BASIC_INFORMATION fbi; - FILE_NETWORK_OPEN_INFORMATION fnoi; - } fi; - FILE_STANDARD_INFORMATION fsi; - FILE_INTERNAL_INFORMATION fii; - - if (pc.has_buggy_basic_info ()) - { - status = NtQueryInformationFile (get_handle (), &io, &fi, sizeof fi, - FileNetworkOpenInformation); - /* The timestamps are in the same relative memory location, only - the DOS attributes have to be moved. */ - fi.fbi.FileAttributes = fi.fnoi.FileAttributes; - } - else - status = NtQueryInformationFile (get_handle (), &io, &fi.fbi, sizeof fi.fbi, - FileBasicInformation); - if (!NT_SUCCESS (status)) - { - debug_printf ("%p = NtQueryInformationFile(%S, FileBasicInformation)", - status, pc.get_nt_native_path ()); - return -1; - } - status = NtQueryInformationFile (get_handle (), &io, &fsi, sizeof fsi, - FileStandardInformation); - if (!NT_SUCCESS (status)) - { - debug_printf ("%p = NtQueryInformationFile(%S, FileStandardInformation)", - status, pc.get_nt_native_path ()); - return -1; - } - status = NtQueryInformationFile (get_handle (), &io, &fii, sizeof fii, - FileInternalInformation); - if (!NT_SUCCESS (status)) - { - debug_printf ("%p = NtQueryInformationFile(%S, FileInternalInformation)", - status, pc.get_nt_native_path ()); - return -1; - } - /* If the change time is 0, it's a file system which doesn't - support a change timestamp. In that case use the LastWriteTime - entry, as in other calls to fstat_helper. */ - if (pc.is_rep_symlink ()) - fi.fbi.FileAttributes &= ~FILE_ATTRIBUTE_DIRECTORY; - pc.file_attributes (fi.fbi.FileAttributes); - return fstat_helper (buf, - fi.fbi.ChangeTime.QuadPart ? &fi.fbi.ChangeTime - : &fi.fbi.LastWriteTime, - &fi.fbi.LastAccessTime, - &fi.fbi.LastWriteTime, - &fi.fbi.CreationTime, - get_dev (), - fsi.EndOfFile.QuadPart, - fsi.AllocationSize.QuadPart, - fii.FileId.QuadPart, - fsi.NumberOfLinks, - fi.fbi.FileAttributes); -} - -int __stdcall -fhandler_base::fstat_by_name (struct __stat64 *buf) -{ - NTSTATUS status; - OBJECT_ATTRIBUTES attr; - IO_STATUS_BLOCK io; - UNICODE_STRING dirname; - UNICODE_STRING basename; - HANDLE dir; - struct { - FILE_ID_BOTH_DIR_INFORMATION fdi; - WCHAR buf[NAME_MAX + 1]; - } fdi_buf; - LARGE_INTEGER FileId; - - RtlSplitUnicodePath (pc.get_nt_native_path (), &dirname, &basename); - InitializeObjectAttributes (&attr, &dirname, pc.objcaseinsensitive (), - NULL, NULL); - if (!NT_SUCCESS (status = NtOpenFile (&dir, SYNCHRONIZE | FILE_LIST_DIRECTORY, - &attr, &io, FILE_SHARE_VALID_FLAGS, - FILE_SYNCHRONOUS_IO_NONALERT - | FILE_OPEN_FOR_BACKUP_INTENT - | FILE_DIRECTORY_FILE))) - { - debug_printf ("%p = NtOpenFile(%S)", status, pc.get_nt_native_path ()); - goto too_bad; - } - if (wincap.has_fileid_dirinfo () && !pc.has_buggy_fileid_dirinfo () - && NT_SUCCESS (status = NtQueryDirectoryFile (dir, NULL, NULL, NULL, &io, - &fdi_buf.fdi, sizeof fdi_buf, - FileIdBothDirectoryInformation, - TRUE, &basename, TRUE))) - FileId = fdi_buf.fdi.FileId; - else if (NT_SUCCESS (status = NtQueryDirectoryFile (dir, NULL, NULL, NULL, - &io, &fdi_buf.fdi, - sizeof fdi_buf, - FileBothDirectoryInformation, - TRUE, &basename, TRUE))) - FileId.QuadPart = 0; /* get_ino is called in fstat_helper. */ - if (!NT_SUCCESS (status)) - { - debug_printf ("%p = NtQueryDirectoryFile(%S)", status, - pc.get_nt_native_path ()); - NtClose (dir); - goto too_bad; - } - NtClose (dir); - /* If the change time is 0, it's a file system which doesn't - support a change timestamp. In that case use the LastWriteTime - entry, as in other calls to fstat_helper. */ - if (pc.is_rep_symlink ()) - fdi_buf.fdi.FileAttributes &= ~FILE_ATTRIBUTE_DIRECTORY; - pc.file_attributes (fdi_buf.fdi.FileAttributes); - return fstat_helper (buf, - fdi_buf.fdi.ChangeTime.QuadPart - ? &fdi_buf.fdi.ChangeTime : &fdi_buf.fdi.LastWriteTime, - &fdi_buf.fdi.LastAccessTime, - &fdi_buf.fdi.LastWriteTime, - &fdi_buf.fdi.CreationTime, - pc.fs_serial_number (), - fdi_buf.fdi.EndOfFile.QuadPart, - fdi_buf.fdi.AllocationSize.QuadPart, - FileId.QuadPart, - 1, - fdi_buf.fdi.FileAttributes); - -too_bad: - LARGE_INTEGER ft; - /* Arbitrary value: 2006-12-01 */ - RtlSecondsSince1970ToTime (1164931200L, &ft); - return fstat_helper (buf, - &ft, - &ft, - &ft, - &ft, - 0, - 0ULL, - -1LL, - 0ULL, - 1, - pc.file_attributes ()); -} - -int __stdcall -fhandler_base::fstat_fs (struct __stat64 *buf) -{ - int res = -1; - int oret; - int open_flags = O_RDONLY | O_BINARY; - - if (get_handle ()) - { - if (!nohandle () && !is_fs_special ()) - res = fstat_by_handle (buf); - if (res) - res = fstat_by_name (buf); - return res; - } - query_open (query_read_attributes); - oret = open_fs (open_flags, 0); - if (oret) - { - /* We now have a valid handle, regardless of the "nohandle" state. - Since fhandler_base::open only calls CloseHandle if !nohandle, - we have to set it to false before calling close and restore - the state afterwards. */ - res = fstat_by_handle (buf); - bool no_handle = nohandle (); - nohandle (false); - close_fs (); - nohandle (no_handle); - set_io_handle (NULL); - } - if (res) - res = fstat_by_name (buf); - - return res; -} - -/* The ChangeTime is taken from the NTFS ChangeTime entry, if reading - the file information using NtQueryInformationFile succeeded. If not, - it's faked using the LastWriteTime entry from GetFileInformationByHandle - or FindFirstFile. We're deliberatly not using the creation time anymore - to simplify interaction with native Windows applications which choke on - creation times >= access or write times. - - Note that the dwFileAttributes member of the file information evaluated - in the calling function is used here, not the pc.fileattr member, since - the latter might be old and not reflect the actual state of the file. */ -int __stdcall -fhandler_base::fstat_helper (struct __stat64 *buf, - PLARGE_INTEGER ChangeTime, - PLARGE_INTEGER LastAccessTime, - PLARGE_INTEGER LastWriteTime, - PLARGE_INTEGER CreationTime, - DWORD dwVolumeSerialNumber, - ULONGLONG nFileSize, - LONGLONG nAllocSize, - ULONGLONG nFileIndex, - DWORD nNumberOfLinks, - DWORD dwFileAttributes) -{ - IO_STATUS_BLOCK st; - FILE_COMPRESSION_INFORMATION fci; - - to_timestruc_t ((PFILETIME) LastAccessTime, &buf->st_atim); - to_timestruc_t ((PFILETIME) LastWriteTime, &buf->st_mtim); - to_timestruc_t ((PFILETIME) ChangeTime, &buf->st_ctim); - to_timestruc_t ((PFILETIME) CreationTime, &buf->st_birthtim); - buf->st_dev = dwVolumeSerialNumber; - buf->st_size = (_off64_t) nFileSize; - /* The number of links to a directory includes the - number of subdirectories in the directory, since all - those subdirectories point to it. - This is too slow on remote drives, so we do without it. - Setting the count to 2 confuses `find (1)' command. So - let's try it with `1' as link count. */ -#if 0 - buf->st_nlink = pc.ndisk_links (nNumberOfLinks); -#else - buf->st_nlink = nNumberOfLinks; -#endif - - /* Enforce namehash as inode number on untrusted file systems. */ - if (pc.isgood_inode (nFileIndex)) - buf->st_ino = (__ino64_t) nFileIndex; - else - buf->st_ino = get_ino (); - - buf->st_blksize = PREFERRED_IO_BLKSIZE; - - if (nAllocSize >= 0LL) - /* A successful NtQueryInformationFile returns the allocation size - correctly for compressed and sparse files as well. */ - buf->st_blocks = (nAllocSize + S_BLKSIZE - 1) / S_BLKSIZE; - else if (::has_attribute (dwFileAttributes, FILE_ATTRIBUTE_COMPRESSED - | FILE_ATTRIBUTE_SPARSE_FILE) - && get_handle () && !is_fs_special () - && !NtQueryInformationFile (get_handle (), &st, (PVOID) &fci, - sizeof fci, FileCompressionInformation)) - /* Otherwise we request the actual amount of bytes allocated for - compressed and sparsed files. */ - buf->st_blocks = (fci.CompressedFileSize.QuadPart + S_BLKSIZE - 1) - / S_BLKSIZE; - else - /* Otherwise compute no. of blocks from file size. */ - buf->st_blocks = (buf->st_size + S_BLKSIZE - 1) / S_BLKSIZE; - - buf->st_mode = 0; - /* Using a side effect: get_file_attributes checks for directory. - This is used, to set S_ISVTX, if needed. */ - if (pc.isdir ()) - buf->st_mode = S_IFDIR; - else if (pc.issymlink ()) - { - buf->st_size = pc.get_symlink_length (); - /* symlinks are everything for everyone! */ - buf->st_mode = S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO; - get_file_attribute (get_handle (), pc, NULL, - &buf->st_uid, &buf->st_gid); - goto done; - } - else if (pc.issocket ()) - buf->st_mode = S_IFSOCK; - - if (!get_file_attribute (is_fs_special () && !pc.issocket () - ? NULL : get_handle (), pc, - &buf->st_mode, &buf->st_uid, &buf->st_gid)) - { - /* If read-only attribute is set, modify ntsec return value */ - if (::has_attribute (dwFileAttributes, FILE_ATTRIBUTE_READONLY) - && !pc.isdir () && !pc.issymlink ()) - buf->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH); - - if (buf->st_mode & S_IFMT) - /* nothing */; - else if (!is_fs_special ()) - buf->st_mode |= S_IFREG; - else - { - buf->st_dev = dev (); - buf->st_mode = dev ().mode; - buf->st_size = 0; - } - } - else - { - buf->st_mode |= STD_RBITS; - - if (!::has_attribute (dwFileAttributes, FILE_ATTRIBUTE_READONLY)) - buf->st_mode |= STD_WBITS; - /* | S_IWGRP | S_IWOTH; we don't give write to group etc */ - - if (pc.isdir ()) - buf->st_mode |= S_IFDIR | STD_WBITS | STD_XBITS; - else if (buf->st_mode & S_IFMT) - /* nothing */; - else if (is_fs_special ()) - { - buf->st_dev = dev (); - buf->st_mode = dev ().mode; - buf->st_size = 0; - } - else - { - buf->st_mode |= S_IFREG; - /* Check suffix for executable file. */ - if (pc.exec_state () == dont_know_if_executable) - { - PUNICODE_STRING path = pc.get_nt_native_path (); - - if (RtlEqualUnicodePathSuffix (path, &ro_u_exe, TRUE) - || RtlEqualUnicodePathSuffix (path, &ro_u_lnk, TRUE) - || RtlEqualUnicodePathSuffix (path, &ro_u_com, TRUE)) - pc.set_exec (); - } - /* No known suffix, check file header. This catches binaries and - shebang scripts. */ - if (pc.exec_state () == dont_know_if_executable) - { - OBJECT_ATTRIBUTES attr; - NTSTATUS status; - HANDLE h; - IO_STATUS_BLOCK io; - - /* The NWFS implementation is frighteningly incomplete. When - re-opening a file by handle, the subsequent NtReadFile - returns with the weird status STATUS_FILE_IS_A_DIRECTORY. - We're still using the re-open by handle method for all - other filesystems since it's 8-10% faster than opening - by name. */ - if (pc.fs_is_nwfs ()) - InitializeObjectAttributes (&attr, pc.get_nt_native_path (), - OBJ_CASE_INSENSITIVE, NULL, NULL) - else - InitializeObjectAttributes (&attr, &ro_u_empty, 0, - get_handle (), NULL); - status = NtOpenFile (&h, SYNCHRONIZE | FILE_READ_DATA, - &attr, &io, FILE_SHARE_VALID_FLAGS, - FILE_SYNCHRONOUS_IO_NONALERT); - if (NT_SUCCESS (status)) - { - LARGE_INTEGER off = { QuadPart:0LL }; - char magic[3]; - - status = NtReadFile (h, NULL, NULL, NULL, &io, magic, - 3, &off, NULL); - if (NT_SUCCESS (status) - && has_exec_chars (magic, io.Information)) - { - pc.set_exec (); - buf->st_mode |= STD_XBITS; - } - else - debug_printf ("%p = NtReadFile(%S)", status, - pc.get_nt_native_path ()); - NtClose (h); - } - else - debug_printf ("%p = NtOpenFile(%S)", status, - pc.get_nt_native_path ()); - } - } - if (pc.exec_state () == is_executable) - buf->st_mode |= STD_XBITS; - - /* This fakes the permissions of all files to match the current umask. */ - buf->st_mode &= ~(cygheap->umask); - /* If the FS supports ACLs, we're here because we couldn't even open - the file for READ_CONTROL access. Chances are high that the file's - security descriptor has no ACE for "Everyone", so we should not fake - any access for "others". */ - if (has_acls ()) - buf->st_mode &= ~(S_IROTH | S_IWOTH | S_IXOTH); - } - - done: - syscall_printf ("0 = fstat (, %p) st_atime=%x st_size=%D, st_mode=%p, st_ino=%D, sizeof=%d", - buf, buf->st_atime, buf->st_size, buf->st_mode, - buf->st_ino, sizeof (*buf)); - return 0; -} - -int __stdcall -fhandler_disk_file::fstat (struct __stat64 *buf) -{ - return fstat_fs (buf); -} - -int __stdcall -fhandler_disk_file::fstatvfs (struct statvfs *sfs) -{ - int ret = -1, opened = 0; - NTSTATUS status; - IO_STATUS_BLOCK io; - FILE_FS_FULL_SIZE_INFORMATION full_fsi; - FILE_FS_SIZE_INFORMATION fsi; - HANDLE fh = get_handle (); - - if (!fh) - { - OBJECT_ATTRIBUTES attr; - opened = NT_SUCCESS (NtOpenFile (&fh, READ_CONTROL, - pc.get_object_attr (attr, sec_none_nih), - &io, FILE_SHARE_VALID_FLAGS, - FILE_OPEN_FOR_BACKUP_INTENT)); - if (!opened) - { - /* Can't open file. Try again with parent dir. */ - UNICODE_STRING dirname; - RtlSplitUnicodePath (pc.get_nt_native_path (), &dirname, NULL); - attr.ObjectName = &dirname; - opened = NT_SUCCESS (NtOpenFile (&fh, READ_CONTROL, &attr, &io, - FILE_SHARE_VALID_FLAGS, - FILE_OPEN_FOR_BACKUP_INTENT)); - if (!opened) - goto out; - } - } - - sfs->f_files = ULONG_MAX; - sfs->f_ffree = ULONG_MAX; - sfs->f_favail = ULONG_MAX; - sfs->f_fsid = pc.fs_serial_number (); - sfs->f_flag = pc.fs_flags (); - sfs->f_namemax = pc.fs_name_len (); - /* Get allocation related information. Try to get "full" information - first, which is only available since W2K. If that fails, try to - retrieve normal allocation information. */ - status = NtQueryVolumeInformationFile (fh, &io, &full_fsi, sizeof full_fsi, - FileFsFullSizeInformation); - if (NT_SUCCESS (status)) - { - sfs->f_bsize = full_fsi.BytesPerSector * full_fsi.SectorsPerAllocationUnit; - sfs->f_frsize = sfs->f_bsize; - sfs->f_blocks = full_fsi.TotalAllocationUnits.LowPart; - sfs->f_bfree = full_fsi.ActualAvailableAllocationUnits.LowPart; - sfs->f_bavail = full_fsi.CallerAvailableAllocationUnits.LowPart; - if (sfs->f_bfree > sfs->f_bavail) - { - /* Quotas active. We can't trust TotalAllocationUnits. */ - NTFS_VOLUME_DATA_BUFFER nvdb; - - status = NtFsControlFile (fh, NULL, NULL, NULL, &io, - FSCTL_GET_NTFS_VOLUME_DATA, - NULL, 0, &nvdb, sizeof nvdb); - if (!NT_SUCCESS (status)) - debug_printf ("%p = NtFsControlFile(%S, FSCTL_GET_NTFS_VOLUME_DATA)", - status, pc.get_nt_native_path ()); - else - sfs->f_blocks = nvdb.TotalClusters.QuadPart; - } - ret = 0; - } - else - { - status = NtQueryVolumeInformationFile (fh, &io, &fsi, sizeof fsi, - FileFsSizeInformation); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - goto out; - } - sfs->f_bsize = fsi.BytesPerSector * fsi.SectorsPerAllocationUnit; - sfs->f_frsize = sfs->f_bsize; - sfs->f_blocks = fsi.TotalAllocationUnits.LowPart; - sfs->f_bfree = fsi.AvailableAllocationUnits.LowPart; - sfs->f_bavail = sfs->f_bfree; - ret = 0; - } -out: - if (opened) - NtClose (fh); - syscall_printf ("%d = fstatvfs (%s, %p)", ret, get_name (), sfs); - return ret; -} - -int __stdcall -fhandler_disk_file::fchmod (mode_t mode) -{ - extern int chmod_device (path_conv& pc, mode_t mode); - int res = -1; - int oret = 0; - NTSTATUS status; - IO_STATUS_BLOCK io; - - if (pc.is_fs_special ()) - return chmod_device (pc, mode); - - if (!get_handle ()) - { - query_open (query_write_control); - if (!(oret = open (O_BINARY, 0))) - { - /* Need WRITE_DAC|WRITE_OWNER to write ACLs. */ - if (pc.has_acls ()) - return -1; - /* Otherwise FILE_WRITE_ATTRIBUTES is sufficient. */ - query_open (query_write_attributes); - if (!(oret = open (O_BINARY, 0))) - return -1; - } - } - - if (pc.fs_is_nfs ()) - { - /* chmod on NFS shares works by writing an EA of type NfsV3Attributes. - Only type and mode have to be set. Apparently type isn't checked - for consistency, so it's sufficent to set it to NF3REG all the time. */ - struct { - FILE_FULL_EA_INFORMATION ffei; - char buf[sizeof (NFS_V3_ATTR) + sizeof (fattr3)]; - } ffei_buf; - ffei_buf.ffei.NextEntryOffset = 0; - ffei_buf.ffei.Flags = 0; - ffei_buf.ffei.EaNameLength = sizeof (NFS_V3_ATTR) - 1; - ffei_buf.ffei.EaValueLength = sizeof (fattr3); - strcpy (ffei_buf.ffei.EaName, NFS_V3_ATTR); - fattr3 *nfs_attr = (fattr3 *) (ffei_buf.ffei.EaName - + ffei_buf.ffei.EaNameLength + 1); - memset (nfs_attr, 0, sizeof (fattr3)); - nfs_attr->type = NF3REG; - nfs_attr->mode = mode; - status = NtSetEaFile (get_handle (), &io, - &ffei_buf.ffei, sizeof ffei_buf); - if (!NT_SUCCESS (status)) - __seterrno_from_nt_status (status); - else - res = 0; - goto out; - } - - if (pc.has_acls ()) - { - if (pc.isdir ()) - mode |= S_IFDIR; - if (!set_file_attribute (get_handle (), pc, - ILLEGAL_UID, ILLEGAL_GID, mode)) - res = 0; - } - - /* If the mode has any write bits set, the DOS R/O flag is in the way. */ - if (mode & (S_IWUSR | S_IWGRP | S_IWOTH)) - pc &= (DWORD) ~FILE_ATTRIBUTE_READONLY; - else if (!pc.has_acls ()) /* Never set DOS R/O if security is used. */ - pc |= (DWORD) FILE_ATTRIBUTE_READONLY; - if (S_ISSOCK (mode)) - pc |= (DWORD) FILE_ATTRIBUTE_SYSTEM; - - status = NtSetAttributesFile (get_handle (), pc.file_attributes ()); - /* MVFS needs a good amount of kicking to be convinced that it has to write - back metadata changes and to invalidate the cached metadata information - stored for the given handle. This method to open a second handle to - the file and write the same metadata information twice has been found - experimentally: http://cygwin.com/ml/cygwin/2009-07/msg00533.html */ - if (pc.fs_is_mvfs () && NT_SUCCESS (status) && !oret) - { - OBJECT_ATTRIBUTES attr; - HANDLE fh; - - InitializeObjectAttributes (&attr, &ro_u_empty, 0, get_handle (), NULL); - if (NT_SUCCESS (NtOpenFile (&fh, FILE_WRITE_ATTRIBUTES, &attr, &io, - FILE_SHARE_VALID_FLAGS, - FILE_OPEN_FOR_BACKUP_INTENT))) - { - NtSetAttributesFile (fh, pc.file_attributes ()); - NtClose (fh); - } - } - /* Correct NTFS security attributes have higher priority */ - if (!pc.has_acls ()) - { - if (!NT_SUCCESS (status)) - __seterrno_from_nt_status (status); - else - res = 0; - } - -out: - if (oret) - close_fs (); - - return res; -} - -int __stdcall -fhandler_disk_file::fchown (__uid32_t uid, __gid32_t gid) -{ - int oret = 0; - - if (!pc.has_acls ()) - { - /* fake - if not supported, pretend we're like win95 - where it just works */ - /* FIXME: Could be supported on NFS when user->uid mapping is in place. */ - return 0; - } - - if (!get_handle ()) - { - query_open (query_write_control); - if (!(oret = fhandler_disk_file::open (O_BINARY, 0))) - return -1; - } - - mode_t attrib = 0; - if (pc.isdir ()) - attrib |= S_IFDIR; - __uid32_t old_uid; - int res = get_file_attribute (get_handle (), pc, &attrib, &old_uid, NULL); - if (!res) - { - /* Typical Windows default ACLs can contain permissions for one - group, while being owned by another user/group. The permission - bits returned above are pretty much useless then. Creating a - new ACL with these useless permissions results in a potentially - broken symlink. So what we do here is to set the underlying - permissions of symlinks to a sensible value which allows the - world to read the symlink and only the new owner to change it. */ - if (pc.issymlink ()) - attrib = S_IFLNK | STD_RBITS | STD_WBITS; - res = set_file_attribute (get_handle (), pc, uid, gid, attrib); - /* If you're running a Samba server which has no winbidd running, the - uid<->SID mapping is disfunctional. Even trying to chown to your - own account fails since the account used on the server is the UNIX - account which gets used for the standard user mapping. This is a - default mechanism which doesn't know your real Windows SID. - There are two possible error codes in different Samba releases for - this situation, one of them is unfortunately the not very significant - STATUS_ACCESS_DENIED. Instead of relying on the error codes, we're - using the below very simple heuristic. If set_file_attribute failed, - and the original user account was either already unknown, or one of - the standard UNIX accounts, we're faking success. */ - if (res == -1 && pc.fs_is_samba ()) - { - cygsid sid; - - if (old_uid == ILLEGAL_UID - || (sid.getfrompw (internal_getpwuid (old_uid)) - && EqualPrefixSid (sid, well_known_samba_unix_user_fake_sid))) - { - debug_printf ("Faking chown worked on standalone Samba"); - res = 0; - } - } - } - if (oret) - close_fs (); - - return res; -} - -int _stdcall -fhandler_disk_file::facl (int cmd, int nentries, __aclent32_t *aclbufp) -{ - int res = -1; - int oret = 0; - - if (!pc.has_acls ()) - { -cant_access_acl: - switch (cmd) - { - struct __stat64 st; - - case SETACL: - /* Open for writing required to be able to set ctime - (even though setting the ACL is just pretended). */ - if (!get_handle ()) - oret = open (O_WRONLY | O_BINARY, 0); - res = 0; - break; - case GETACL: - if (!aclbufp) - set_errno (EFAULT); - else if (nentries < MIN_ACL_ENTRIES) - set_errno (ENOSPC); - else - { - if (!get_handle ()) - { - query_open (query_read_attributes); - oret = open (O_BINARY, 0); - } - if ((oret && !fstat_by_handle (&st)) - || !fstat_by_name (&st)) - { - aclbufp[0].a_type = USER_OBJ; - aclbufp[0].a_id = st.st_uid; - aclbufp[0].a_perm = (st.st_mode & S_IRWXU) >> 6; - aclbufp[1].a_type = GROUP_OBJ; - aclbufp[1].a_id = st.st_gid; - aclbufp[1].a_perm = (st.st_mode & S_IRWXG) >> 3; - aclbufp[2].a_type = OTHER_OBJ; - aclbufp[2].a_id = ILLEGAL_GID; - aclbufp[2].a_perm = st.st_mode & S_IRWXO; - aclbufp[3].a_type = CLASS_OBJ; - aclbufp[3].a_id = ILLEGAL_GID; - aclbufp[3].a_perm = S_IRWXU | S_IRWXG | S_IRWXO; - res = MIN_ACL_ENTRIES; - } - } - break; - case GETACLCNT: - res = MIN_ACL_ENTRIES; - break; - default: - set_errno (EINVAL); - break; - } - } - else - { - if (!get_handle ()) - { - query_open (cmd == SETACL ? query_write_control : query_read_control); - if (!(oret = open (O_BINARY, 0))) - { - if (cmd == GETACL || cmd == GETACLCNT) - goto cant_access_acl; - return -1; - } - } - switch (cmd) - { - case SETACL: - if (!aclsort32 (nentries, 0, aclbufp)) - { - bool rw = false; - res = setacl (get_handle (), pc, nentries, aclbufp, rw); - if (rw) - { - IO_STATUS_BLOCK io; - FILE_BASIC_INFORMATION fbi; - fbi.CreationTime.QuadPart - = fbi.LastAccessTime.QuadPart - = fbi.LastWriteTime.QuadPart - = fbi.ChangeTime.QuadPart = 0LL; - fbi.FileAttributes = (pc.file_attributes () - & ~FILE_ATTRIBUTE_READONLY) - ?: FILE_ATTRIBUTE_NORMAL; - NtSetInformationFile (get_handle (), &io, &fbi, sizeof fbi, - FileBasicInformation); - } - } - break; - case GETACL: - if (!aclbufp) - set_errno(EFAULT); - else - res = getacl (get_handle (), pc, nentries, aclbufp); - break; - case GETACLCNT: - res = getacl (get_handle (), pc, 0, NULL); - break; - default: - set_errno (EINVAL); - break; - } - } - - if (oret) - close_fs (); - - return res; -} - -ssize_t -fhandler_disk_file::fgetxattr (const char *name, void *value, size_t size) -{ - if (pc.is_fs_special ()) - { - set_errno (ENOTSUP); - return -1; - } - return read_ea (get_handle (), pc, name, (char *) value, size); -} - -int -fhandler_disk_file::fsetxattr (const char *name, const void *value, size_t size, - int flags) -{ - if (pc.is_fs_special ()) - { - set_errno (ENOTSUP); - return -1; - } - return write_ea (get_handle (), pc, name, (const char *) value, size, flags); -} - -int -fhandler_disk_file::fadvise (_off64_t offset, _off64_t length, int advice) -{ - if (advice < POSIX_FADV_NORMAL || advice > POSIX_FADV_NOREUSE) - { - set_errno (EINVAL); - return -1; - } - - /* Windows only supports advice flags for the whole file. We're using - a simplified test here so that we don't have to ask for the actual - file size. Length == 0 means all bytes starting at offset anyway. - So we only actually follow the advice, if it's given for offset == 0. */ - if (offset != 0) - return 0; - - /* We only support normal and sequential mode for now. Everything which - is not POSIX_FADV_SEQUENTIAL is treated like POSIX_FADV_NORMAL. */ - if (advice != POSIX_FADV_SEQUENTIAL) - advice = POSIX_FADV_NORMAL; - - IO_STATUS_BLOCK io; - FILE_MODE_INFORMATION fmi; - NTSTATUS status = NtQueryInformationFile (get_handle (), &io, - &fmi, sizeof fmi, - FileModeInformation); - if (!NT_SUCCESS (status)) - __seterrno_from_nt_status (status); - else - { - fmi.Mode &= ~FILE_SEQUENTIAL_ONLY; - if (advice == POSIX_FADV_SEQUENTIAL) - fmi.Mode |= FILE_SEQUENTIAL_ONLY; - status = NtSetInformationFile (get_handle (), &io, &fmi, sizeof fmi, - FileModeInformation); - if (NT_SUCCESS (status)) - return 0; - __seterrno_from_nt_status (status); - } - - return -1; -} - -int -fhandler_disk_file::ftruncate (_off64_t length, bool allow_truncate) -{ - int res = -1; - - if (length < 0 || !get_handle ()) - set_errno (EINVAL); - else if (pc.isdir ()) - set_errno (EISDIR); - else if (!(get_access () & GENERIC_WRITE)) - set_errno (EBADF); - else - { - NTSTATUS status; - IO_STATUS_BLOCK io; - FILE_STANDARD_INFORMATION fsi; - FILE_END_OF_FILE_INFORMATION feofi; - - status = NtQueryInformationFile (get_handle (), &io, &fsi, sizeof fsi, - FileStandardInformation); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - return -1; - } - - /* If called through posix_fallocate, silently succeed if length - is less than the file's actual length. */ - if (!allow_truncate && length < fsi.EndOfFile.QuadPart) - return 0; - - feofi.EndOfFile.QuadPart = length; - /* Create sparse files only when called through ftruncate, not when - called through posix_fallocate. */ - if (allow_truncate - && (pc.fs_flags () & FILE_SUPPORTS_SPARSE_FILES) - && length >= fsi.EndOfFile.QuadPart + (128 * 1024)) - { - status = NtFsControlFile (get_handle (), NULL, NULL, NULL, &io, - FSCTL_SET_SPARSE, NULL, 0, NULL, 0); - syscall_printf ("%p = NtFsControlFile(%S, FSCTL_SET_SPARSE)", - status, pc.get_nt_native_path ()); - } - status = NtSetInformationFile (get_handle (), &io, - &feofi, sizeof feofi, - FileEndOfFileInformation); - if (!NT_SUCCESS (status)) - __seterrno_from_nt_status (status); - else - res = 0; - } - return res; -} - -int -fhandler_disk_file::link (const char *newpath) -{ - size_t nlen = strlen (newpath); - path_conv newpc (newpath, PC_SYM_NOFOLLOW | PC_POSIX | PC_NULLEMPTY, stat_suffixes); - if (newpc.error) - { - set_errno (newpc.error); - return -1; - } - - if (newpc.exists ()) - { - syscall_printf ("file '%S' exists?", newpc.get_nt_native_path ()); - set_errno (EEXIST); - return -1; - } - - if (isdirsep (newpath[nlen - 1]) || has_dot_last_component (newpath, false)) - { - set_errno (ENOENT); - return -1; - } - - char new_buf[nlen + 5]; - if (!newpc.error) - { - /* If the original file is a lnk special file (except for sockets), - and if the original file has a .lnk suffix, add one to the hardlink - as well. */ - if (pc.is_lnk_special () && !pc.issocket () - && RtlEqualUnicodePathSuffix (pc.get_nt_native_path (), - &ro_u_lnk, TRUE)) - { - /* Shortcut hack. */ - stpcpy (stpcpy (new_buf, newpath), ".lnk"); - newpath = new_buf; - newpc.check (newpath, PC_SYM_NOFOLLOW); - } - else if (!pc.isdir () - && pc.is_binary () - && RtlEqualUnicodePathSuffix (pc.get_nt_native_path (), - &ro_u_exe, TRUE) - && !RtlEqualUnicodePathSuffix (newpc.get_nt_native_path (), - &ro_u_exe, TRUE)) - { - /* Executable hack. */ - stpcpy (stpcpy (new_buf, newpath), ".exe"); - newpath = new_buf; - newpc.check (newpath, PC_SYM_NOFOLLOW); - } - } - - HANDLE fh; - NTSTATUS status; - OBJECT_ATTRIBUTES attr; - IO_STATUS_BLOCK io; - status = NtOpenFile (&fh, READ_CONTROL, - pc.get_object_attr (attr, sec_none_nih), &io, - FILE_SHARE_VALID_FLAGS, - FILE_OPEN_FOR_BACKUP_INTENT | FILE_OPEN_REPARSE_POINT); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - return -1; - } - PUNICODE_STRING tgt = newpc.get_nt_native_path (); - ULONG size = sizeof (FILE_LINK_INFORMATION) + tgt->Length; - PFILE_LINK_INFORMATION pfli = (PFILE_LINK_INFORMATION) alloca (size); - pfli->ReplaceIfExists = FALSE; - pfli->RootDirectory = NULL; - memcpy (pfli->FileName, tgt->Buffer, pfli->FileNameLength = tgt->Length); - status = NtSetInformationFile (fh, &io, pfli, size, FileLinkInformation); - NtClose (fh); - if (!NT_SUCCESS (status)) - { - if (status == STATUS_INVALID_DEVICE_REQUEST) - { - /* FS doesn't support hard links. Linux returns EPERM. */ - set_errno (EPERM); - return -1; - } - else - { - __seterrno_from_nt_status (status); - return -1; - } - } - return 0; -} - -int -fhandler_disk_file::utimens (const struct timespec *tvp) -{ - return utimens_fs (tvp); -} - -int -fhandler_base::utimens_fs (const struct timespec *tvp) -{ - struct timespec timeofday; - struct timespec tmp[2]; - bool closeit = false; - - if (!get_handle ()) - { - query_open (query_write_attributes); - if (!open_fs (O_BINARY, 0)) - { - /* It's documented in MSDN that FILE_WRITE_ATTRIBUTES is sufficient - to change the timestamps. Unfortunately it's not sufficient for a - remote HPFS which requires GENERIC_WRITE, so we just retry to open - for writing, though this fails for R/O files of course. */ - query_open (no_query); - if (!open_fs (O_WRONLY | O_BINARY, 0)) - { - syscall_printf ("Opening file failed"); - return -1; - } - } - closeit = true; - } - - clock_gettime (CLOCK_REALTIME, &timeofday); - if (!tvp) - tmp[1] = tmp[0] = timeofday; - else - { - if ((tvp[0].tv_nsec < UTIME_NOW || tvp[0].tv_nsec > 999999999L) - || (tvp[1].tv_nsec < UTIME_NOW || tvp[1].tv_nsec > 999999999L)) - { - if (closeit) - close_fs (); - set_errno (EINVAL); - return -1; - } - tmp[0] = (tvp[0].tv_nsec == UTIME_NOW) ? timeofday : tvp[0]; - tmp[1] = (tvp[1].tv_nsec == UTIME_NOW) ? timeofday : tvp[1]; - } - debug_printf ("incoming lastaccess %08x %08x", tmp[0].tv_sec, tmp[0].tv_nsec); - - IO_STATUS_BLOCK io; - FILE_BASIC_INFORMATION fbi; - - fbi.CreationTime.QuadPart = 0LL; - /* UTIME_OMIT is handled in timespec_to_filetime by setting FILETIME to 0. */ - timespec_to_filetime (&tmp[0], (LPFILETIME) &fbi.LastAccessTime); - timespec_to_filetime (&tmp[1], (LPFILETIME) &fbi.LastWriteTime); - fbi.ChangeTime.QuadPart = 0LL; - fbi.FileAttributes = 0; - NTSTATUS status = NtSetInformationFile (get_handle (), &io, &fbi, sizeof fbi, - FileBasicInformation); - /* For this special case for MVFS see the comment in - fhandler_disk_file::fchmod. */ - if (pc.fs_is_mvfs () && NT_SUCCESS (status) && !closeit) - { - OBJECT_ATTRIBUTES attr; - HANDLE fh; - - InitializeObjectAttributes (&attr, &ro_u_empty, 0, get_handle (), NULL); - if (NT_SUCCESS (NtOpenFile (&fh, FILE_WRITE_ATTRIBUTES, &attr, &io, - FILE_SHARE_VALID_FLAGS, - FILE_OPEN_FOR_BACKUP_INTENT))) - { - NtSetInformationFile (fh, &io, &fbi, sizeof fbi, - FileBasicInformation); - NtClose (fh); - } - } - if (closeit) - close_fs (); - /* Opening a directory on a 9x share from a NT machine works(!), but - then NtSetInformationFile fails with STATUS_NOT_SUPPORTED. Oh well... */ - if (!NT_SUCCESS (status) && status != STATUS_NOT_SUPPORTED) - { - __seterrno_from_nt_status (status); - return -1; - } - return 0; -} - -fhandler_disk_file::fhandler_disk_file () : - fhandler_base () -{ -} - -fhandler_disk_file::fhandler_disk_file (path_conv &pc) : - fhandler_base () -{ - set_name (pc); -} - -int -fhandler_disk_file::open (int flags, mode_t mode) -{ - return open_fs (flags, mode); -} - -int -fhandler_base::open_fs (int flags, mode_t mode) -{ - /* Unfortunately NT allows to open directories for writing, but that's - disallowed according to SUSv3. */ - if (pc.isdir () && (flags & O_ACCMODE) != O_RDONLY) - { - set_errno (EISDIR); - return 0; - } - - int res = fhandler_base::open (flags | O_DIROPEN, mode); - if (!res) - goto out; - - /* This is for file systems known for having a buggy CreateFile call - which might return a valid HANDLE without having actually opened - the file. - The only known file system to date is the SUN NFS Solstice Client 3.1 - which returns a valid handle when trying to open a file in a nonexistent - directory. */ - if (pc.has_buggy_open () && !pc.exists ()) - { - debug_printf ("Buggy open detected."); - close_fs (); - set_errno (ENOENT); - return 0; - } - - ino = get_ino_by_handle (pc, get_handle ()); - /* A unique ID is necessary to recognize fhandler entries which are - duplicated by dup(2) or fork(2). */ - AllocateLocallyUniqueId ((PLUID) &unique_id); - -out: - syscall_printf ("%d = fhandler_disk_file::open (%S, %p)", res, - pc.get_nt_native_path (), flags); - return res; -} - -ssize_t __stdcall -fhandler_disk_file::pread (void *buf, size_t count, _off64_t offset) -{ - ssize_t res; - _off64_t curpos = lseek (0, SEEK_CUR); - if (curpos < 0 || lseek (offset, SEEK_SET) < 0) - res = -1; - else - { - size_t tmp_count = count; - read (buf, tmp_count); - if (lseek (curpos, SEEK_SET) >= 0) - res = (ssize_t) tmp_count; - else - res = -1; - } - debug_printf ("%d = pread (%p, %d, %d)\n", res, buf, count, offset); - return res; -} - -ssize_t __stdcall -fhandler_disk_file::pwrite (void *buf, size_t count, _off64_t offset) -{ - int res; - _off64_t curpos = lseek (0, SEEK_CUR); - if (curpos < 0 || lseek (offset, SEEK_SET) < 0) - res = curpos; - else - { - res = (ssize_t) write (buf, count); - if (lseek (curpos, SEEK_SET) < 0) - res = -1; - } - debug_printf ("%d = pwrite (%p, %d, %d)\n", res, buf, count, offset); - return res; -} - -int -fhandler_disk_file::mkdir (mode_t mode) -{ - int res = -1; - SECURITY_ATTRIBUTES sa = sec_none_nih; - NTSTATUS status; - HANDLE dir; - OBJECT_ATTRIBUTES attr; - IO_STATUS_BLOCK io; - PFILE_FULL_EA_INFORMATION p = NULL; - ULONG plen = 0; - - if (pc.fs_is_nfs ()) - { - /* When creating a dir on an NFS share, we have to set the - file mode by writing a NFS fattr3 structure with the - correct mode bits set. */ - plen = sizeof (FILE_FULL_EA_INFORMATION) + sizeof (NFS_V3_ATTR) - + sizeof (fattr3); - p = (PFILE_FULL_EA_INFORMATION) alloca (plen); - p->NextEntryOffset = 0; - p->Flags = 0; - p->EaNameLength = sizeof (NFS_V3_ATTR) - 1; - p->EaValueLength = sizeof (fattr3); - strcpy (p->EaName, NFS_V3_ATTR); - fattr3 *nfs_attr = (fattr3 *) (p->EaName + p->EaNameLength + 1); - memset (nfs_attr, 0, sizeof (fattr3)); - nfs_attr->type = NF3DIR; - nfs_attr->mode = (mode & 07777) & ~cygheap->umask; - } - status = NtCreateFile (&dir, FILE_LIST_DIRECTORY | SYNCHRONIZE, - pc.get_object_attr (attr, sa), &io, NULL, - FILE_ATTRIBUTE_DIRECTORY, FILE_SHARE_VALID_FLAGS, - FILE_CREATE, - FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT - | FILE_OPEN_FOR_BACKUP_INTENT, - p, plen); - if (NT_SUCCESS (status)) - { - if (has_acls ()) - set_file_attribute (dir, pc, ILLEGAL_UID, ILLEGAL_GID, - S_JUSTCREATED | S_IFDIR - | ((mode & 07777) & ~cygheap->umask)); - NtClose (dir); - res = 0; - } - else - __seterrno_from_nt_status (status); - - return res; -} - -int -fhandler_disk_file::rmdir () -{ - extern NTSTATUS unlink_nt (path_conv &pc); - - if (!pc.isdir ()) - { - set_errno (ENOTDIR); - return -1; - } - if (!pc.exists ()) - { - set_errno (ENOENT); - return -1; - } - - NTSTATUS status = unlink_nt (pc); - - /* Check for existence of remote dirs after trying to delete them. - Two reasons: - - Sometimes SMB indicates failure when it really succeeds. - - Removeing a directory on a samba drive doesn't return an error if the - directory can't be removed because it's not empty. */ - if (isremote ()) - { - OBJECT_ATTRIBUTES attr; - FILE_BASIC_INFORMATION fbi; - - if (NT_SUCCESS (NtQueryAttributesFile - (pc.get_object_attr (attr, sec_none_nih), &fbi))) - status = STATUS_DIRECTORY_NOT_EMPTY; - else - status = STATUS_SUCCESS; - } - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - return -1; - } - return 0; -} - -/* This is the minimal number of entries which fit into the readdir cache. - The number of bytes allocated by the cache is determined by this number, - To tune caching, just tweak this number. To get a feeling for the size, - the size of the readdir cache is DIR_NUM_ENTRIES * 624 + 4 bytes. */ - -#define DIR_NUM_ENTRIES 100 /* Cache size 62404 bytes */ - -#define DIR_BUF_SIZE (DIR_NUM_ENTRIES \ - * (sizeof (FILE_ID_BOTH_DIR_INFORMATION) \ - + (NAME_MAX + 1) * sizeof (WCHAR))) - -struct __DIR_cache -{ - char __cache[DIR_BUF_SIZE]; /* W2K needs this buffer 8 byte aligned. */ - ULONG __pos; -}; - -#define d_cachepos(d) (((__DIR_cache *) (d)->__d_dirname)->__pos) -#define d_cache(d) (((__DIR_cache *) (d)->__d_dirname)->__cache) - -#define d_mounts(d) ((__DIR_mounts *) (d)->__d_internal) - -DIR * -fhandler_disk_file::opendir (int fd) -{ - DIR *dir; - DIR *res = NULL; - - if (!pc.isdir ()) - set_errno (ENOTDIR); - else if ((dir = (DIR *) malloc (sizeof (DIR))) == NULL) - set_errno (ENOMEM); - else if ((dir->__d_dirname = (char *) malloc ( sizeof (struct __DIR_cache))) - == NULL) - { - set_errno (ENOMEM); - goto free_dir; - } - else if ((dir->__d_dirent = - (struct dirent *) malloc (sizeof (struct dirent))) == NULL) - { - set_errno (ENOMEM); - goto free_dirname; - } - else - { - cygheap_fdnew cfd; - if (cfd < 0 && fd < 0) - goto free_dirent; - - dir->__d_dirent->__d_version = __DIRENT_VERSION; - dir->__d_cookie = __DIRENT_COOKIE; - dir->__handle = INVALID_HANDLE_VALUE; - dir->__d_position = 0; - dir->__flags = (get_name ()[0] == '/' && get_name ()[1] == '\0') - ? dirent_isroot : 0; - dir->__d_internal = (unsigned) new __DIR_mounts (get_name ()); - d_cachepos (dir) = 0; - - if (!pc.iscygdrive ()) - { - if (fd < 0) - { - /* opendir() case. Initialize with given directory name and - NULL directory handle. */ - OBJECT_ATTRIBUTES attr; - NTSTATUS status; - IO_STATUS_BLOCK io; - - status = NtOpenFile (&get_handle (), - SYNCHRONIZE | FILE_LIST_DIRECTORY, - pc.get_object_attr (attr, sec_none_nih), - &io, FILE_SHARE_VALID_FLAGS, - FILE_SYNCHRONOUS_IO_NONALERT - | FILE_OPEN_FOR_BACKUP_INTENT - | FILE_DIRECTORY_FILE); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - goto free_mounts; - } - } - - /* FileIdBothDirectoryInformation is apparently unsupported on - XP when accessing directories on UDF. When trying to use it - so, NtQueryDirectoryFile returns with STATUS_ACCESS_VIOLATION. - It's not clear if the call isn't also unsupported on other - OS/FS combinations (say, Win2K/CDFS or so). Instead of - testing in readdir for yet another error code, let's use - FileIdBothDirectoryInformation only on filesystems supporting - persistent ACLs, FileBothDirectoryInformation otherwise. - - NFS clients hide dangling symlinks from directory queries, - unless you use the FileNamesInformation info class. - On newer NFS clients (>=Vista) FileIdBothDirectoryInformation - works fine, but only if the NFS share is mounted to a drive - letter. TODO: We don't test that here for now, but it might - be worth to test if there's a speed gain in using - FileIdBothDirectoryInformation, because it doesn't require to - open the file to read the inode number. */ - if (pc.hasgood_inode ()) - { - dir->__flags |= dirent_set_d_ino; - if (pc.fs_is_nfs ()) - dir->__flags |= dirent_nfs_d_ino; - else if (wincap.has_fileid_dirinfo () - && !pc.has_buggy_fileid_dirinfo ()) - dir->__flags |= dirent_get_d_ino; - } - } - if (fd >= 0) - dir->__d_fd = fd; - else - { - /* Filling cfd with `this' (aka storing this in the file - descriptor table should only happen after it's clear that - opendir doesn't fail, otherwise we end up cfree'ing the - fhandler twice, once in opendir() in dir.cc, the second - time on exit. Nasty, nasty... */ - cfd = this; - dir->__d_fd = cfd; - if (pc.iscygdrive ()) - cfd->nohandle (true); - } - set_close_on_exec (true); - dir->__fh = this; - res = dir; - } - - syscall_printf ("%p = opendir (%s)", res, get_name ()); - return res; - -free_mounts: - delete d_mounts (dir); -free_dirent: - free (dir->__d_dirent); -free_dirname: - free (dir->__d_dirname); -free_dir: - free (dir); - return res; -} - -__ino64_t __stdcall -readdir_get_ino (const char *path, bool dot_dot) -{ - char *fname; - struct __stat64 st; - HANDLE hdl; - OBJECT_ATTRIBUTES attr; - IO_STATUS_BLOCK io; - __ino64_t ino = 0; - - if (dot_dot) - { - fname = (char *) alloca (strlen (path) + 4); - char *c = stpcpy (fname, path); - if (c[-1] != '/') - *c++ = '/'; - strcpy (c, ".."); - path = fname; - } - path_conv pc (path, PC_SYM_NOFOLLOW | PC_POSIX | PC_NOWARN); - if (pc.isspecial ()) - { - if (!stat_worker (pc, &st)) - ino = st.st_ino; - } - else if (!pc.hasgood_inode ()) - ino = hash_path_name (0, pc.get_nt_native_path ()); - else if (NT_SUCCESS (NtOpenFile (&hdl, READ_CONTROL, - pc.get_object_attr (attr, sec_none_nih), - &io, FILE_SHARE_VALID_FLAGS, - FILE_OPEN_FOR_BACKUP_INTENT - | (pc.is_rep_symlink () - ? FILE_OPEN_REPARSE_POINT : 0)))) - { - ino = get_ino_by_handle (pc, hdl); - if (!ino) - ino = hash_path_name (0, pc.get_nt_native_path ()); - NtClose (hdl); - } - return ino; -} - -int -fhandler_disk_file::readdir_helper (DIR *dir, dirent *de, DWORD w32_err, - DWORD attr, PUNICODE_STRING fname) -{ - if (w32_err) - { - bool added = false; - if ((de->d_ino = d_mounts (dir)->check_missing_mount (fname))) - added = true; - if (!added) - { - fname->Length = 0; - return geterrno_from_win_error (w32_err); - } - - attr = 0; - dir->__flags &= ~dirent_set_d_ino; - } - - /* Set d_type if type can be determined from file attributes. - FILE_ATTRIBUTE_SYSTEM ommitted to leave DT_UNKNOWN for old symlinks. - For new symlinks, d_type will be reset to DT_UNKNOWN below. */ - if (attr && - !(attr & ( ~FILE_ATTRIBUTE_VALID_FLAGS - | FILE_ATTRIBUTE_SYSTEM - | FILE_ATTRIBUTE_REPARSE_POINT))) - { - if (attr & FILE_ATTRIBUTE_DIRECTORY) - de->d_type = DT_DIR; - else - de->d_type = DT_REG; - } - - /* Check for directory reparse point. These are potential volume mount - points which have another inode than the underlying directory. */ - if ((attr & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_REPARSE_POINT)) - == (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_REPARSE_POINT)) - { - HANDLE reph; - OBJECT_ATTRIBUTES attr; - IO_STATUS_BLOCK io; - - InitializeObjectAttributes (&attr, fname, pc.objcaseinsensitive (), - get_handle (), NULL); - if (is_volume_mountpoint (&attr) - && (NT_SUCCESS (NtOpenFile (&reph, READ_CONTROL, &attr, &io, - FILE_SHARE_VALID_FLAGS, - FILE_OPEN_FOR_BACKUP_INTENT)))) - { - de->d_ino = get_ino_by_handle (pc, reph); - NtClose (reph); - } - } - - /* Check for Windows shortcut. If it's a Cygwin or U/WIN - symlink, drop the .lnk suffix. */ - if ((attr & FILE_ATTRIBUTE_READONLY) && fname->Length > 4 * sizeof (WCHAR)) - { - UNICODE_STRING uname; - - RtlInitCountedUnicodeString (&uname, - fname->Buffer - + fname->Length / sizeof (WCHAR) - 4, - 4 * sizeof (WCHAR)); - if (RtlEqualUnicodeString (&uname, &ro_u_lnk, TRUE)) - { - tmp_pathbuf tp; - UNICODE_STRING fbuf; - - tp.u_get (&fbuf); - RtlCopyUnicodeString (&fbuf, pc.get_nt_native_path ()); - RtlAppendUnicodeToString (&fbuf, L"\\"); - RtlAppendUnicodeStringToString (&fbuf, fname); - fbuf.Buffer += 4; /* Skip leading \??\ */ - fbuf.Length -= 4 * sizeof (WCHAR); - if (fbuf.Buffer[1] != L':') /* UNC path */ - { - *(fbuf.Buffer += 2) = L'\\'; - fbuf.Length -= 2 * sizeof (WCHAR); - } - path_conv fpath (&fbuf, PC_SYM_NOFOLLOW); - if (fpath.issymlink () || fpath.is_fs_special ()) - { - fname->Length -= 4 * sizeof (WCHAR); - de->d_type = DT_UNKNOWN; - } - } - } - - sys_wcstombs (de->d_name, NAME_MAX + 1, fname->Buffer, - fname->Length / sizeof (WCHAR)); - - /* Don't try to optimize relative to dir->__d_position. On several - filesystems it's no safe bet that "." and ".." entries always - come first. */ - if (de->d_name[0] == '.') - { - if (de->d_name[1] == '\0') - dir->__flags |= dirent_saw_dot; - else if (de->d_name[1] == '.' && de->d_name[2] == '\0') - dir->__flags |= dirent_saw_dot_dot; - } - return 0; -} - -int -fhandler_disk_file::readdir (DIR *dir, dirent *de) -{ - int res = 0; - NTSTATUS status = STATUS_SUCCESS; - PFILE_ID_BOTH_DIR_INFORMATION buf = NULL; - PWCHAR FileName; - ULONG FileNameLength; - ULONG FileAttributes = 0; - IO_STATUS_BLOCK io; - UNICODE_STRING fname; - - /* d_cachepos always refers to the next cache entry to use. If it's 0 - we must reload the cache. */ - if (d_cachepos (dir) == 0) - { - if ((dir->__flags & dirent_get_d_ino)) - { - status = NtQueryDirectoryFile (get_handle (), NULL, NULL, NULL, &io, - d_cache (dir), DIR_BUF_SIZE, - FileIdBothDirectoryInformation, - FALSE, NULL, dir->__d_position == 0); - /* FileIdBothDirectoryInformation isn't supported for remote drives - on NT4 and 2K systems, and it's also not supported on 2K at all, - when accessing network drives on any remote OS. There are also - hacked versions of Samba 3.0.x out there (Debian-based it seems), - which return STATUS_NOT_SUPPORTED rather than handling this info - class. We just fall back to using a standard directory query in - this case and note this case using the dirent_get_d_ino flag. */ - if (!NT_SUCCESS (status) && status != STATUS_NO_MORE_FILES - && (status == STATUS_INVALID_LEVEL - || status == STATUS_NOT_SUPPORTED - || status == STATUS_INVALID_PARAMETER - || status == STATUS_INVALID_NETWORK_RESPONSE - || status == STATUS_INVALID_INFO_CLASS)) - dir->__flags &= ~dirent_get_d_ino; - /* Something weird happens on Samba up to version 3.0.21c, which is - fixed in 3.0.22. FileIdBothDirectoryInformation seems to work - nicely, but only up to the 128th entry in the directory. After - reaching this entry, the next call to NtQueryDirectoryFile - (FileIdBothDirectoryInformation) returns STATUS_INVALID_LEVEL. - Why should we care, we can just switch to - FileBothDirectoryInformation, isn't it? Nope! The next call to - NtQueryDirectoryFile(FileBothDirectoryInformation) actually - returns STATUS_NO_MORE_FILES, regardless how many files are left - unread in the directory. This does not happen when using - FileBothDirectoryInformation right from the start, but since - we can't decide whether the server we're talking with has this - bug or not, we end up serving Samba shares always in the slow - mode using FileBothDirectoryInformation. So, what we do here is - to implement the solution suggested by Andrew Tridgell, we just - reread all entries up to dir->d_position using - FileBothDirectoryInformation. - However, We do *not* mark this server as broken and fall back to - using FileBothDirectoryInformation further on. This would slow - down every access to such a server, even for directories under - 128 entries. Also, bigger dirs only suffer from one additional - call per full directory scan, which shouldn't be too big a hit. - This can easily be changed if necessary. */ - if (status == STATUS_INVALID_LEVEL && dir->__d_position) - { - d_cachepos (dir) = 0; - for (int cnt = 0; cnt < dir->__d_position; ++cnt) - { - if (d_cachepos (dir) == 0) - { - status = NtQueryDirectoryFile (get_handle (), NULL, NULL, - NULL, &io, d_cache (dir), - DIR_BUF_SIZE, - FileBothDirectoryInformation, - FALSE, NULL, cnt == 0); - if (!NT_SUCCESS (status)) - goto go_ahead; - } - buf = (PFILE_ID_BOTH_DIR_INFORMATION) (d_cache (dir) - + d_cachepos (dir)); - if (buf->NextEntryOffset == 0) - d_cachepos (dir) = 0; - else - d_cachepos (dir) += buf->NextEntryOffset; - } - goto go_ahead; - } - } - if (!(dir->__flags & dirent_get_d_ino)) - status = NtQueryDirectoryFile (get_handle (), NULL, NULL, NULL, &io, - d_cache (dir), DIR_BUF_SIZE, - (dir->__flags & dirent_nfs_d_ino) - ? FileNamesInformation - : FileBothDirectoryInformation, - FALSE, NULL, dir->__d_position == 0); - } - -go_ahead: - - if (status == STATUS_NO_MORE_FILES) - /*nothing*/; - else if (!NT_SUCCESS (status)) - debug_printf ("NtQueryDirectoryFile failed, status %p, win32 error %lu", - status, RtlNtStatusToDosError (status)); - else - { - buf = (PFILE_ID_BOTH_DIR_INFORMATION) (d_cache (dir) + d_cachepos (dir)); - if (buf->NextEntryOffset == 0) - d_cachepos (dir) = 0; - else - d_cachepos (dir) += buf->NextEntryOffset; - if ((dir->__flags & dirent_get_d_ino)) - { - FileName = buf->FileName; - FileNameLength = buf->FileNameLength; - FileAttributes = buf->FileAttributes; - if ((dir->__flags & dirent_set_d_ino)) - de->d_ino = buf->FileId.QuadPart; - } - else if ((dir->__flags & dirent_nfs_d_ino)) - { - FileName = ((PFILE_NAMES_INFORMATION) buf)->FileName; - FileNameLength = ((PFILE_NAMES_INFORMATION) buf)->FileNameLength; - } - else - { - FileName = ((PFILE_BOTH_DIRECTORY_INFORMATION) buf)->FileName; - FileNameLength = - ((PFILE_BOTH_DIRECTORY_INFORMATION) buf)->FileNameLength; - FileAttributes = - ((PFILE_BOTH_DIRECTORY_INFORMATION) buf)->FileAttributes; - } - RtlInitCountedUnicodeString (&fname, FileName, FileNameLength); - de->d_ino = d_mounts (dir)->check_mount (&fname, de->d_ino); - if (de->d_ino == 0 && (dir->__flags & dirent_set_d_ino)) - { - /* Don't try to optimize relative to dir->__d_position. On several - filesystems it's no safe bet that "." and ".." entries always - come first. */ - if (FileNameLength == sizeof (WCHAR) && FileName[0] == '.') - de->d_ino = get_ino_by_handle (pc, get_handle ()); - else if (FileNameLength == 2 * sizeof (WCHAR) - && FileName[0] == L'.' && FileName[1] == L'.') - { - if (!(dir->__flags & dirent_isroot)) - de->d_ino = readdir_get_ino (get_name (), true); - else - de->d_ino = get_ino_by_handle (pc, get_handle ()); - } - else - { - OBJECT_ATTRIBUTES attr; - HANDLE hdl; - NTSTATUS f_status; - - InitializeObjectAttributes (&attr, &fname, - pc.objcaseinsensitive (), - get_handle (), NULL); - /* FILE_OPEN_REPARSE_POINT on NFS is a no-op, so the normal - NtOpenFile here returns the inode number of the symlink target, - rather than the inode number of the symlink itself. - - Worse, trying to open a symlink without setting the special - "ActOnSymlink" EA triggers a bug in Windows 7 which results - in a timeout of up to 20 seconds, followed by two exceptions - in the NT kernel. - - Since both results are far from desirable, we open symlinks - on NFS so that we get the right inode and a happy W7. - And, since some filesystems choke on the EAs, we don't - use them unconditionally. */ - f_status = (dir->__flags & dirent_nfs_d_ino) - ? NtCreateFile (&hdl, READ_CONTROL, &attr, &io, - NULL, 0, FILE_SHARE_VALID_FLAGS, - FILE_OPEN, FILE_OPEN_FOR_BACKUP_INTENT, - &nfs_aol_ffei, sizeof nfs_aol_ffei) - : NtOpenFile (&hdl, READ_CONTROL, &attr, &io, - FILE_SHARE_VALID_FLAGS, - FILE_OPEN_FOR_BACKUP_INTENT - | FILE_OPEN_REPARSE_POINT); - if (NT_SUCCESS (f_status)) - { - de->d_ino = get_ino_by_handle (pc, hdl); - NtClose (hdl); - } - } - /* Untrusted file system. Don't try to fetch inode number again. */ - if (de->d_ino == 0) - dir->__flags &= ~dirent_set_d_ino; - } - } - - if (!(res = readdir_helper (dir, de, RtlNtStatusToDosError (status), - buf ? FileAttributes : 0, &fname))) - dir->__d_position++; - else if (!(dir->__flags & dirent_saw_dot)) - { - strcpy (de->d_name , "."); - de->d_ino = get_ino_by_handle (pc, get_handle ()); - dir->__d_position++; - dir->__flags |= dirent_saw_dot; - res = 0; - } - else if (!(dir->__flags & dirent_saw_dot_dot)) - { - strcpy (de->d_name , ".."); - if (!(dir->__flags & dirent_isroot)) - de->d_ino = readdir_get_ino (get_name (), true); - else - de->d_ino = get_ino_by_handle (pc, get_handle ()); - dir->__d_position++; - dir->__flags |= dirent_saw_dot_dot; - res = 0; - } - - syscall_printf ("%d = readdir (%p, %p) (L\"%lS\" > \"%ls\")", res, dir, &de, - res ? NULL : &fname, res ? "***" : de->d_name); - return res; -} - -_off64_t -fhandler_disk_file::telldir (DIR *dir) -{ - return dir->__d_position; -} - -void -fhandler_disk_file::seekdir (DIR *dir, _off64_t loc) -{ - rewinddir (dir); - while (loc > dir->__d_position) - if (!::readdir (dir)) - break; -} - -void -fhandler_disk_file::rewinddir (DIR *dir) -{ - d_cachepos (dir) = 0; - if (wincap.has_buggy_restart_scan () && isremote ()) - { - /* This works around a W2K bug. The RestartScan parameter in calls - to NtQueryDirectoryFile on remote shares is ignored, thus - resulting in not being able to rewind on remote shares. By - reopening the directory, we get a fresh new directory pointer. */ - OBJECT_ATTRIBUTES attr; - NTSTATUS status; - IO_STATUS_BLOCK io; - HANDLE new_dir; - - InitializeObjectAttributes (&attr, &ro_u_empty, pc.objcaseinsensitive (), - get_handle (), NULL); - status = NtOpenFile (&new_dir, SYNCHRONIZE | FILE_LIST_DIRECTORY, - &attr, &io, FILE_SHARE_VALID_FLAGS, - FILE_SYNCHRONOUS_IO_NONALERT - | FILE_OPEN_FOR_BACKUP_INTENT - | FILE_DIRECTORY_FILE); - if (!NT_SUCCESS (stat)) - debug_printf ("Unable to reopen dir %s, NT error: %p", - get_name (), status); - else - { - NtClose (get_handle ()); - set_io_handle (new_dir); - } - } - dir->__d_position = 0; - d_mounts (dir)->rewind (); -} - -int -fhandler_disk_file::closedir (DIR *dir) -{ - int res = 0; - NTSTATUS status; - - delete d_mounts (dir); - if (!get_handle ()) - /* ignore */; - else if (get_handle () == INVALID_HANDLE_VALUE) - { - set_errno (EBADF); - res = -1; - } - else if (!NT_SUCCESS (status = NtClose (get_handle ()))) - { - __seterrno_from_nt_status (status); - res = -1; - } - syscall_printf ("%d = closedir (%p, %s)", res, dir, get_name ()); - return res; -} - -fhandler_cygdrive::fhandler_cygdrive () : - fhandler_disk_file (), ndrives (0), pdrive (NULL) -{ -} - -int -fhandler_cygdrive::open (int flags, mode_t mode) -{ - if ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) - { - set_errno (EEXIST); - return 0; - } - if (flags & O_WRONLY) - { - set_errno (EISDIR); - return 0; - } - flags |= O_DIROPEN; - set_flags (flags); - nohandle (true); - return 1; -} - -int -fhandler_cygdrive::close () -{ - return 0; -} - -void -fhandler_cygdrive::set_drives () -{ - pdrive = pdrive_buf; - ndrives = GetLogicalDriveStrings (sizeof pdrive_buf, pdrive_buf) / DRVSZ; -} - -int -fhandler_cygdrive::fstat (struct __stat64 *buf) -{ - fhandler_base::fstat (buf); - buf->st_ino = 2; - buf->st_mode = S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH; - if (!ndrives) - set_drives (); - char flptst[] = "X:"; - int n = ndrives; - for (const char *p = pdrive; p && *p; p = strchr (p, '\0') + 1) - if (is_floppy ((flptst[0] = *p, flptst)) - || GetFileAttributes (p) == INVALID_FILE_ATTRIBUTES) - n--; - buf->st_nlink = n + 2; - return 0; -} - -DIR * -fhandler_cygdrive::opendir (int fd) -{ - DIR *dir; - - dir = fhandler_disk_file::opendir (fd); - if (dir && !ndrives) - set_drives (); - - return dir; -} - -int -fhandler_cygdrive::readdir (DIR *dir, dirent *de) -{ - char flptst[] = "X:"; - - while (true) - { - if (!pdrive || !*pdrive) - { - if (!(dir->__flags & dirent_saw_dot)) - { - de->d_name[0] = '.'; - de->d_name[1] = '\0'; - de->d_ino = 2; - } - return ENMFILE; - } - if (!is_floppy ((flptst[0] = *pdrive, flptst)) - && GetFileAttributes (pdrive) != INVALID_FILE_ATTRIBUTES) - break; - pdrive = strchr (pdrive, '\0') + 1; - } - *de->d_name = cyg_tolower (*pdrive); - de->d_name[1] = '\0'; - user_shared->warned_msdos = true; - de->d_ino = readdir_get_ino (pdrive, false); - dir->__d_position++; - pdrive = strchr (pdrive, '\0') + 1; - syscall_printf ("%p = readdir (%p) (%s)", &de, dir, de->d_name); - return 0; -} - -void -fhandler_cygdrive::rewinddir (DIR *dir) -{ - pdrive = pdrive_buf; - dir->__d_position = 0; -} - -int -fhandler_cygdrive::closedir (DIR *dir) -{ - pdrive = pdrive_buf; - return 0; -} diff --git a/winsup/cygwin/fhandler_dsp.cc b/winsup/cygwin/fhandler_dsp.cc deleted file mode 100644 index 9095ba517..000000000 --- a/winsup/cygwin/fhandler_dsp.cc +++ /dev/null @@ -1,1374 +0,0 @@ -/* Fhandler_dev_dsp: code to emulate OSS sound model /dev/dsp - - Copyright 2001, 2002, 2003, 2004, 2008 Red Hat, Inc - - Written by Andy Younger (andy@snoogie.demon.co.uk) - Extended by Gerd Spalink (Gerd.Spalink@t-online.de) - to support recording from the audio input - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" - -/*------------------------------------------------------------------------ - Simple encapsulation of the win32 audio device. - - Implementation Notes - 1. Audio structures are malloced just before the first read or - write to /dev/dsp. The actual buffer size is determined at that time, - such that one buffer holds about 125ms of audio data. - At the time of this writing, 12 buffers are allocated, - so that up to 1.5 seconds can be buffered within Win32. - The buffer size can be queried with the ioctl SNDCTL_DSP_GETBLKSIZE, - but for this implementation only returns meaningful results if - sampling rate, number of channels and number of bits per sample - are not changed afterwards. - The audio structures are freed when the device is reset or closed, - and they are not passed to exec'ed processes. - The dev_ member is cleared after a fork. This forces the child - to reopen the audio device._ - - 2. Every open call creates a new instance of the handler. After a - successful open, every subsequent open from the same process - to the device fails with EBUSY. - The structures are shared between duped handles, but not with - children. They only inherit the settings from the parent. - */ - -class fhandler_dev_dsp::Audio -{ // This class contains functionality common to Audio_in and Audio_out - public: - Audio (); - ~Audio (); - - class queue; - - bool isvalid (); - void setconvert (int format); - void convert_none (unsigned char *buffer, int size_bytes) { } - void convert_U8_S8 (unsigned char *buffer, int size_bytes); - void convert_S16LE_U16LE (unsigned char *buffer, int size_bytes); - void convert_S16LE_U16BE (unsigned char *buffer, int size_bytes); - void convert_S16LE_S16BE (unsigned char *buffer, int size_bytes); - void fillFormat (WAVEFORMATEX * format, - int rate, int bits, int channels); - unsigned blockSize (int rate, int bits, int channels); - void (fhandler_dev_dsp::Audio::*convert_) - (unsigned char *buffer, int size_bytes); - - enum { MAX_BLOCKS = 12 }; - int bufferIndex_; // offset into pHdr_->lpData - WAVEHDR *pHdr_; // data to be filled by write - WAVEHDR wavehdr_[MAX_BLOCKS]; - char *bigwavebuffer_; // audio samples only - // Member variables below must be locked - queue *Qisr2app_; // blocks passed from wave callback -}; - -class fhandler_dev_dsp::Audio::queue -{ // non-blocking fixed size queues for buffer management - public: - queue (int depth = 4); - ~queue (); - - bool send (WAVEHDR *); // queue an item, returns true if successful - bool recv (WAVEHDR **); // retrieve an item, returns true if successful - void reset (); - int query (); // return number of items queued - inline void lock () { EnterCriticalSection (&lock_); } - inline void unlock () { LeaveCriticalSection (&lock_); } - inline void dellock () { debug_printf ("Deleting Critical Section"); DeleteCriticalSection (&lock_); } - bool isvalid () { return storage_; } - private: - CRITICAL_SECTION lock_; - int head_; - int tail_; - int depth_; - WAVEHDR **storage_; -}; - -static void CALLBACK waveOut_callback (HWAVEOUT hWave, UINT msg, DWORD instance, - DWORD param1, DWORD param2); - -class fhandler_dev_dsp::Audio_out: public Audio -{ - public: - void fork_fixup (HANDLE parent); - bool query (int rate, int bits, int channels); - bool start (); - void stop (bool immediately = false); - bool write (const char *pSampleData, int nBytes); - void buf_info (audio_buf_info *p, int rate, int bits, int channels); - void callback_sampledone (WAVEHDR *pHdr); - bool parsewav (const char *&pData, int &nBytes, - int rate, int bits, int channels); - - private: - void init (unsigned blockSize); - void waitforallsent (); - void waitforspace (); - bool sendcurrent (); - - enum { MAX_BLOCKS = 12 }; - HWAVEOUT dev_; // The wave device - /* Private copies of audiofreq_, audiobits_, audiochannels_, - possibly set from wave file */ - int freq_; - int bits_; - int channels_; -}; - -static void CALLBACK waveIn_callback (HWAVEIN hWave, UINT msg, DWORD instance, - DWORD param1, DWORD param2); - -class fhandler_dev_dsp::Audio_in: public Audio -{ -public: - void fork_fixup (HANDLE parent); - bool query (int rate, int bits, int channels); - bool start (int rate, int bits, int channels); - void stop (); - bool read (char *pSampleData, int &nBytes); - void buf_info (audio_buf_info *p, int rate, int bits, int channels); - void callback_blockfull (WAVEHDR *pHdr); - -private: - bool init (unsigned blockSize); - bool queueblock (WAVEHDR *pHdr); - void waitfordata (); // blocks until we have a good pHdr_ - - HWAVEIN dev_; -}; - -/* -------------------------------------------------------------------- - Implementation */ - -// Simple fixed length FIFO queue implementation for audio buffer management -fhandler_dev_dsp::Audio::queue::queue (int depth) -{ - // allow space for one extra object in the queue - // so we can distinguish full and empty status - depth_ = depth; - storage_ = new WAVEHDR *[depth_ + 1]; -} - -fhandler_dev_dsp::Audio::queue::~queue () -{ - delete[] storage_; -} - -void -fhandler_dev_dsp::Audio::queue::reset () - { - /* When starting, after reset and after fork */ - head_ = tail_ = 0; - debug_printf ("InitializeCriticalSection"); - memset (&lock_, 0, sizeof (lock_)); - InitializeCriticalSection (&lock_); - } - -bool -fhandler_dev_dsp::Audio::queue::send (WAVEHDR *x) -{ - bool res = false; - lock (); - if (query () == depth_) - system_printf ("Queue overflow"); - else - { - storage_[tail_] = x; - if (++tail_ > depth_) - tail_ = 0; - res = true; - } - unlock (); - return res; -} - -bool -fhandler_dev_dsp::Audio::queue::recv (WAVEHDR **x) -{ - bool res = false; - lock (); - if (query () != 0) - { - *x = storage_[head_]; - if (++head_ > depth_) - head_ = 0; - res = true; - } - unlock (); - return res; -} - -int -fhandler_dev_dsp::Audio::queue::query () -{ - int n = tail_ - head_; - if (n < 0) - n += depth_ + 1; - return n; -} - -// Audio class implements functionality need for both read and write -fhandler_dev_dsp::Audio::Audio () -{ - bigwavebuffer_ = NULL; - Qisr2app_ = new queue (MAX_BLOCKS); - convert_ = &fhandler_dev_dsp::Audio::convert_none; -} - -fhandler_dev_dsp::Audio::~Audio () -{ - debug_printf(""); - delete Qisr2app_; - delete[] bigwavebuffer_; -} - -inline bool -fhandler_dev_dsp::Audio::isvalid () -{ - return bigwavebuffer_ && Qisr2app_ && Qisr2app_->isvalid (); -} - -void -fhandler_dev_dsp::Audio::setconvert (int format) -{ - switch (format) - { - case AFMT_S8: - convert_ = &fhandler_dev_dsp::Audio::convert_U8_S8; - debug_printf ("U8_S8"); - break; - case AFMT_U16_LE: - convert_ = &fhandler_dev_dsp::Audio::convert_S16LE_U16LE; - debug_printf ("S16LE_U16LE"); - break; - case AFMT_U16_BE: - convert_ = &fhandler_dev_dsp::Audio::convert_S16LE_U16BE; - debug_printf ("S16LE_U16BE"); - break; - case AFMT_S16_BE: - convert_ = &fhandler_dev_dsp::Audio::convert_S16LE_S16BE; - debug_printf ("S16LE_S16BE"); - break; - default: - convert_ = &fhandler_dev_dsp::Audio::convert_none; - debug_printf ("none"); - } -} - -void -fhandler_dev_dsp::Audio::convert_U8_S8 (unsigned char *buffer, - int size_bytes) -{ - while (size_bytes-- > 0) - { - *buffer ^= (unsigned char)0x80; - buffer++; - } -} - -void -fhandler_dev_dsp::Audio::convert_S16LE_U16BE (unsigned char *buffer, - int size_bytes) -{ - int size_samples = size_bytes / 2; - unsigned char hi, lo; - while (size_samples-- > 0) - { - hi = buffer[0]; - lo = buffer[1]; - *buffer++ = lo; - *buffer++ = hi ^ (unsigned char)0x80; - } -} - -void -fhandler_dev_dsp::Audio::convert_S16LE_U16LE (unsigned char *buffer, - int size_bytes) -{ - int size_samples = size_bytes / 2; - while (size_samples-- > 0) - { - buffer++; - *buffer ^= (unsigned char)0x80; - buffer++; - } -} - -void -fhandler_dev_dsp::Audio::convert_S16LE_S16BE (unsigned char *buffer, - int size_bytes) -{ - int size_samples = size_bytes / 2; - unsigned char hi, lo; - while (size_samples-- > 0) - { - hi = buffer[0]; - lo = buffer[1]; - *buffer++ = lo; - *buffer++ = hi; - } -} - -void -fhandler_dev_dsp::Audio::fillFormat (WAVEFORMATEX * format, - int rate, int bits, int channels) -{ - memset (format, 0, sizeof (*format)); - format->wFormatTag = WAVE_FORMAT_PCM; - format->wBitsPerSample = bits; - format->nChannels = channels; - format->nSamplesPerSec = rate; - format->nAvgBytesPerSec = format->nSamplesPerSec * format->nChannels - * (bits / 8); - format->nBlockAlign = format->nChannels * (bits / 8); -} - -// calculate a good block size -unsigned -fhandler_dev_dsp::Audio::blockSize (int rate, int bits, int channels) -{ - unsigned blockSize; - blockSize = ((bits / 8) * channels * rate) / 8; // approx 125ms per block - // round up to multiple of 64 - blockSize += 0x3f; - blockSize &= ~0x3f; - return blockSize; -} - -//======================================================================= -void -fhandler_dev_dsp::Audio_out::fork_fixup (HANDLE parent) -{ - /* Null dev_. - It will be necessary to reset the queue, open the device - and create a lock when writing */ - debug_printf ("parent=0x%08x", parent); - dev_ = NULL; -} - - -bool -fhandler_dev_dsp::Audio_out::query (int rate, int bits, int channels) -{ - WAVEFORMATEX format; - MMRESULT rc; - - fillFormat (&format, rate, bits, channels); - rc = waveOutOpen (NULL, WAVE_MAPPER, &format, 0L, 0L, WAVE_FORMAT_QUERY); - debug_printf ("%d = waveOutOpen (freq=%d bits=%d channels=%d)", rc, rate, bits, channels); - return (rc == MMSYSERR_NOERROR); -} - -bool -fhandler_dev_dsp::Audio_out::start () -{ - WAVEFORMATEX format; - MMRESULT rc; - unsigned bSize = blockSize (freq_, bits_, channels_); - - if (dev_) - return true; - - /* In case of fork bigwavebuffer may already exist */ - if (!bigwavebuffer_) - bigwavebuffer_ = new char[MAX_BLOCKS * bSize]; - - if (!isvalid ()) - return false; - - fillFormat (&format, freq_, bits_, channels_); - rc = waveOutOpen (&dev_, WAVE_MAPPER, &format, (DWORD) waveOut_callback, - (DWORD) this, CALLBACK_FUNCTION); - if (rc == MMSYSERR_NOERROR) - init (bSize); - - debug_printf ("%d = waveOutOpen (freq=%d bits=%d channels=%d)", rc, freq_, bits_, channels_); - - return (rc == MMSYSERR_NOERROR); -} - -void -fhandler_dev_dsp::Audio_out::stop (bool immediately) -{ - MMRESULT rc; - WAVEHDR *pHdr; - - debug_printf ("dev_=%08x", (int)dev_); - if (dev_) - { - if (!immediately) - { - sendcurrent (); // force out last block whatever size.. - waitforallsent (); // block till finished.. - } - - rc = waveOutReset (dev_); - debug_printf ("%d = waveOutReset ()", rc); - while (Qisr2app_->recv (&pHdr)) - { - rc = waveOutUnprepareHeader (dev_, pHdr, sizeof (WAVEHDR)); - debug_printf ("%d = waveOutUnprepareHeader (0x%08x)", rc, pHdr); - } - - rc = waveOutClose (dev_); - debug_printf ("%d = waveOutClose ()", rc); - - Qisr2app_->dellock (); - } -} - -void -fhandler_dev_dsp::Audio_out::init (unsigned blockSize) -{ - int i; - - // internally queue all of our buffer for later use by write - Qisr2app_->reset (); - for (i = 0; i < MAX_BLOCKS; i++) - { - wavehdr_[i].lpData = &bigwavebuffer_[i * blockSize]; - wavehdr_[i].dwUser = (int) blockSize; - wavehdr_[i].dwFlags = 0; - if (!Qisr2app_->send (&wavehdr_[i])) - { - system_printf ("Internal Error i=%d", i); - break; // should not happen - } - } - pHdr_ = NULL; -} - -bool -fhandler_dev_dsp::Audio_out::write (const char *pSampleData, int nBytes) -{ - while (nBytes != 0) - { // Block if all blocks used until at least one is free - waitforspace (); - - int sizeleft = (int)pHdr_->dwUser - bufferIndex_; - if (nBytes < sizeleft) - { // all data fits into the current block, with some space left - memcpy (&pHdr_->lpData[bufferIndex_], pSampleData, nBytes); - bufferIndex_ += nBytes; - break; - } - else - { // data will fill up the current block - memcpy (&pHdr_->lpData[bufferIndex_], pSampleData, sizeleft); - bufferIndex_ += sizeleft; - sendcurrent (); - pSampleData += sizeleft; - nBytes -= sizeleft; - } - } - return true; -} - -void -fhandler_dev_dsp::Audio_out::buf_info (audio_buf_info *p, - int rate, int bits, int channels) -{ - p->fragstotal = MAX_BLOCKS; - if (this && dev_) - { - /* If the device is running we use the internal values, - possibly set from the wave file. */ - p->fragsize = blockSize (freq_, bits_, channels_); - p->fragments = Qisr2app_->query (); - if (pHdr_ != NULL) - p->bytes = (int)pHdr_->dwUser - bufferIndex_ - + p->fragsize * p->fragments; - else - p->bytes = p->fragsize * p->fragments; - } - else - { - p->fragsize = blockSize (rate, bits, channels); - p->fragments = MAX_BLOCKS; - p->bytes = p->fragsize * p->fragments; - } -} - -/* This is called on an interupt so use locking.. Note Qisr2app_ - is used so we should wrap all references to it in locks. */ -inline void -fhandler_dev_dsp::Audio_out::callback_sampledone (WAVEHDR *pHdr) -{ - Qisr2app_->send (pHdr); -} - -void -fhandler_dev_dsp::Audio_out::waitforspace () -{ - WAVEHDR *pHdr; - MMRESULT rc = WAVERR_STILLPLAYING; - - if (pHdr_ != NULL) - return; - while (!Qisr2app_->recv (&pHdr)) - { - debug_printf ("100ms"); - Sleep (100); - } - if (pHdr->dwFlags) - { - /* Errors are ignored here. They will probbaly cause a failure - in the subsequent PrepareHeader */ - rc = waveOutUnprepareHeader (dev_, pHdr, sizeof (WAVEHDR)); - debug_printf ("%d = waveOutUnprepareHeader (0x%08x)", rc, pHdr); - } - pHdr_ = pHdr; - bufferIndex_ = 0; -} - -void -fhandler_dev_dsp::Audio_out::waitforallsent () -{ - while (Qisr2app_->query () != MAX_BLOCKS) - { - debug_printf ("%d blocks in Qisr2app", Qisr2app_->query ()); - Sleep (100); - } -} - -// send the block described by pHdr_ and bufferIndex_ to wave device -bool -fhandler_dev_dsp::Audio_out::sendcurrent () -{ - WAVEHDR *pHdr = pHdr_; - MMRESULT rc; - debug_printf ("pHdr=0x%08x bytes=%d", pHdr, bufferIndex_); - - if (pHdr_ == NULL) - return false; - pHdr_ = NULL; - - // Sample buffer conversion - (this->*convert_) ((unsigned char *)pHdr->lpData, bufferIndex_); - - // Send internal buffer out to the soundcard - pHdr->dwBufferLength = bufferIndex_; - rc = waveOutPrepareHeader (dev_, pHdr, sizeof (WAVEHDR)); - debug_printf ("%d = waveOutPrepareHeader (0x%08x)", rc, pHdr); - if (rc == MMSYSERR_NOERROR) - { - rc = waveOutWrite (dev_, pHdr, sizeof (WAVEHDR)); - debug_printf ("%d = waveOutWrite (0x%08x)", rc, pHdr); - } - if (rc == MMSYSERR_NOERROR) - return true; - - /* FIXME: Should we return an error instead ?*/ - pHdr->dwFlags = 0; /* avoid calling UnprepareHeader again */ - Qisr2app_->send (pHdr); - return false; -} - -//------------------------------------------------------------------------ -// Call back routine -static void CALLBACK -waveOut_callback (HWAVEOUT hWave, UINT msg, DWORD instance, DWORD param1, - DWORD param2) -{ - if (msg == WOM_DONE) - { - fhandler_dev_dsp::Audio_out *ptr = - (fhandler_dev_dsp::Audio_out *) instance; - ptr->callback_sampledone ((WAVEHDR *) param1); - } -} - -//------------------------------------------------------------------------ -// wav file detection.. -#pragma pack(1) -struct wavchunk -{ - char id[4]; - unsigned int len; -}; -struct wavformat -{ - unsigned short wFormatTag; - unsigned short wChannels; - unsigned int dwSamplesPerSec; - unsigned int dwAvgBytesPerSec; - unsigned short wBlockAlign; - unsigned short wBitsPerSample; -}; -#pragma pack() - -bool -fhandler_dev_dsp::Audio_out::parsewav (const char * &pData, int &nBytes, - int dev_freq, int dev_bits, int dev_channels) -{ - int len; - const char *end = pData + nBytes; - const char *pDat; - int skip = 0; - - /* Start with default values from the device handler */ - freq_ = dev_freq; - bits_ = dev_bits; - channels_ = dev_channels; - setconvert (bits_ == 8 ? AFMT_U8 : AFMT_S16_LE); - - // Check alignment first: A lot of the code below depends on it - if (((int)pData & 0x3) != 0) - return false; - if (!(pData[0] == 'R' && pData[1] == 'I' - && pData[2] == 'F' && pData[3] == 'F')) - return false; - if (!(pData[8] == 'W' && pData[9] == 'A' - && pData[10] == 'V' && pData[11] == 'E')) - return false; - - len = *(int *) &pData[4]; - len -= 12; - pDat = pData + 12; - skip = 12; - while ((len > 0) && (pDat + sizeof (wavchunk) < end)) - { /* We recognize two kinds of wavchunk: - "fmt " for the PCM parameters (only PCM supported here) - "data" for the start of PCM data */ - wavchunk * pChunk = (wavchunk *) pDat; - int blklen = pChunk-> len; - if (pChunk->id[0] == 'f' && pChunk->id[1] == 'm' - && pChunk->id[2] == 't' && pChunk->id[3] == ' ') - { - wavformat *format = (wavformat *) (pChunk + 1); - if ((char *) (format + 1) >= end) - return false; - // We have found the parameter chunk - if (format->wFormatTag == 0x0001) - { // Micr*s*ft PCM; check if parameters work with our device - if (query (format->dwSamplesPerSec, format->wBitsPerSample, - format->wChannels)) - { // return the parameters we found - freq_ = format->dwSamplesPerSec; - bits_ = format->wBitsPerSample; - channels_ = format->wChannels; - } - } - } - else - { - if (pChunk->id[0] == 'd' && pChunk->id[1] == 'a' - && pChunk->id[2] == 't' && pChunk->id[3] == 'a') - { // throw away all the header & not output it to the soundcard. - skip += sizeof (wavchunk); - debug_printf ("Discard %d bytes wave header", skip); - pData += skip; - nBytes -= skip; - setconvert (bits_ == 8 ? AFMT_U8 : AFMT_S16_LE); - return true; - } - } - pDat += blklen + sizeof (wavchunk); - skip += blklen + sizeof (wavchunk); - len -= blklen + sizeof (wavchunk); - } - return false; -} - -/* ======================================================================== - Buffering concept for Audio_in: - On the first read, we queue all blocks of our bigwavebuffer - for reception and start the wave-in device. - We manage queues of pointers to WAVEHDR - When a block has been filled, the callback puts the corresponding - WAVEHDR pointer into a queue. - The function read() blocks (polled, sigh) until at least one good buffer - has arrived, then the data is copied into the buffer provided to read(). - After a buffer has been fully used by read(), it is queued again - to the wave-in device immediately. - The function read() iterates until all data requested has been - received, there is no way to interrupt it */ - -void -fhandler_dev_dsp::Audio_in::fork_fixup (HANDLE parent) -{ - /* Null dev_. - It will be necessary to reset the queue, open the device - and create a lock when reading */ - debug_printf ("parent=0x%08x", parent); - dev_ = NULL; -} - -bool -fhandler_dev_dsp::Audio_in::query (int rate, int bits, int channels) -{ - WAVEFORMATEX format; - MMRESULT rc; - - fillFormat (&format, rate, bits, channels); - rc = waveInOpen (NULL, WAVE_MAPPER, &format, 0L, 0L, WAVE_FORMAT_QUERY); - debug_printf ("%d = waveInOpen (freq=%d bits=%d channels=%d)", rc, rate, bits, channels); - return (rc == MMSYSERR_NOERROR); -} - -bool -fhandler_dev_dsp::Audio_in::start (int rate, int bits, int channels) -{ - WAVEFORMATEX format; - MMRESULT rc; - unsigned bSize = blockSize (rate, bits, channels); - - if (dev_) - return true; - - /* In case of fork bigwavebuffer may already exist */ - if (!bigwavebuffer_) - bigwavebuffer_ = new char[MAX_BLOCKS * bSize]; - - if (!isvalid ()) - return false; - - fillFormat (&format, rate, bits, channels); - rc = waveInOpen (&dev_, WAVE_MAPPER, &format, (DWORD) waveIn_callback, - (DWORD) this, CALLBACK_FUNCTION); - debug_printf ("%d = waveInOpen (rate=%d bits=%d channels=%d)", rc, rate, bits, channels); - - if (rc == MMSYSERR_NOERROR) - { - if (!init (bSize)) - return false; - } - return (rc == MMSYSERR_NOERROR); -} - -void -fhandler_dev_dsp::Audio_in::stop () -{ - MMRESULT rc; - WAVEHDR *pHdr; - - debug_printf ("dev_=%08x", (int)dev_); - if (dev_) - { - /* Note that waveInReset calls our callback for all incomplete buffers. - Since all the win32 wave functions appear to use a common lock, - we must not call into the wave API from the callback. - Otherwise we end up in a deadlock. */ - rc = waveInReset (dev_); - debug_printf ("%d = waveInReset ()", rc); - - while (Qisr2app_->recv (&pHdr)) - { - rc = waveInUnprepareHeader (dev_, pHdr, sizeof (WAVEHDR)); - debug_printf ("%d = waveInUnprepareHeader (0x%08x)", rc, pHdr); - } - - rc = waveInClose (dev_); - debug_printf ("%d = waveInClose ()", rc); - - Qisr2app_->dellock (); - } -} - -bool -fhandler_dev_dsp::Audio_in::queueblock (WAVEHDR *pHdr) -{ - MMRESULT rc; - rc = waveInPrepareHeader (dev_, pHdr, sizeof (WAVEHDR)); - debug_printf ("%d = waveInPrepareHeader (0x%08x)", rc, pHdr); - if (rc == MMSYSERR_NOERROR) - { - rc = waveInAddBuffer (dev_, pHdr, sizeof (WAVEHDR)); - debug_printf ("%d = waveInAddBuffer (0x%08x)", rc, pHdr); - } - if (rc == MMSYSERR_NOERROR) - return true; - - /* FIXME: Should the calling function return an error instead ?*/ - pHdr->dwFlags = 0; /* avoid calling UnprepareHeader again */ - pHdr->dwBytesRecorded = 0; /* no data will have been read */ - Qisr2app_->send (pHdr); - return false; -} - -bool -fhandler_dev_dsp::Audio_in::init (unsigned blockSize) -{ - MMRESULT rc; - int i; - - // try to queue all of our buffer for reception - Qisr2app_->reset (); - for (i = 0; i < MAX_BLOCKS; i++) - { - wavehdr_[i].lpData = &bigwavebuffer_[i * blockSize]; - wavehdr_[i].dwBufferLength = blockSize; - wavehdr_[i].dwFlags = 0; - if (!queueblock (&wavehdr_[i])) - break; - } - pHdr_ = NULL; - rc = waveInStart (dev_); - debug_printf ("%d = waveInStart (), queued=%d", rc, i); - return (rc == MMSYSERR_NOERROR); -} - -bool -fhandler_dev_dsp::Audio_in::read (char *pSampleData, int &nBytes) -{ - int bytes_to_read = nBytes; - nBytes = 0; - debug_printf ("pSampleData=%08x nBytes=%d", pSampleData, bytes_to_read); - while (bytes_to_read != 0) - { // Block till next sound has been read - waitfordata (); - - // Handle gathering our blocks into smaller or larger buffer - int sizeleft = pHdr_->dwBytesRecorded - bufferIndex_; - if (bytes_to_read < sizeleft) - { // The current buffer holds more data than requested - memcpy (pSampleData, &pHdr_->lpData[bufferIndex_], bytes_to_read); - (this->*convert_) ((unsigned char *)pSampleData, bytes_to_read); - nBytes += bytes_to_read; - bufferIndex_ += bytes_to_read; - debug_printf ("got %d", bytes_to_read); - break; // done; use remaining data in next call to read - } - else - { // not enough or exact amount in the current buffer - if (sizeleft) - { // use up what we have - memcpy (pSampleData, &pHdr_->lpData[bufferIndex_], sizeleft); - (this->*convert_) ((unsigned char *)pSampleData, sizeleft); - nBytes += sizeleft; - bytes_to_read -= sizeleft; - pSampleData += sizeleft; - debug_printf ("got %d", sizeleft); - } - queueblock (pHdr_); // re-queue this block to ISR - pHdr_ = NULL; // need to wait for a new block - // if more samples are needed, we need a new block now - } - } - debug_printf ("end nBytes=%d", nBytes); - return true; -} - -void -fhandler_dev_dsp::Audio_in::waitfordata () -{ - WAVEHDR *pHdr; - MMRESULT rc; - - if (pHdr_ != NULL) - return; - while (!Qisr2app_->recv (&pHdr)) - { - debug_printf ("100ms"); - Sleep (100); - } - if (pHdr->dwFlags) /* Zero if queued following error in queueblock */ - { - /* Errors are ignored here. They will probbaly cause a failure - in the subsequent PrepareHeader */ - rc = waveInUnprepareHeader (dev_, pHdr, sizeof (WAVEHDR)); - debug_printf ("%d = waveInUnprepareHeader (0x%08x)", rc, pHdr); - } - pHdr_ = pHdr; - bufferIndex_ = 0; -} - -void -fhandler_dev_dsp::Audio_in::buf_info (audio_buf_info *p, - int rate, int bits, int channels) -{ - p->fragstotal = MAX_BLOCKS; - p->fragsize = blockSize (rate, bits, channels); - if (this && dev_) - { - p->fragments = Qisr2app_->query (); - if (pHdr_ != NULL) - p->bytes = pHdr_->dwBytesRecorded - bufferIndex_ - + p->fragsize * p->fragments; - else - p->bytes = p->fragsize * p->fragments; - } - else - { - p->fragments = 0; - p->bytes = 0; - } -} - -inline void -fhandler_dev_dsp::Audio_in::callback_blockfull (WAVEHDR *pHdr) -{ - Qisr2app_->send (pHdr); -} - -static void CALLBACK -waveIn_callback (HWAVEIN hWave, UINT msg, DWORD instance, DWORD param1, - DWORD param2) -{ - if (msg == WIM_DATA) - { - fhandler_dev_dsp::Audio_in *ptr = - (fhandler_dev_dsp::Audio_in *) instance; - ptr->callback_blockfull ((WAVEHDR *) param1); - } -} - - -/* ------------------------------------------------------------------------ - /dev/dsp handler - ------------------------------------------------------------------------ */ -fhandler_dev_dsp::fhandler_dev_dsp (): - fhandler_base () -{ - debug_printf ("0x%08x", (int)this); - audio_in_ = NULL; - audio_out_ = NULL; -} - -int -fhandler_dev_dsp::open (int flags, mode_t mode) -{ - if (cygheap->fdtab.find_archetype (dev ())) - { - set_errno (EBUSY); - return 0; - } - int err = 0; - UINT num_in = 0, num_out = 0; - set_flags ((flags & ~O_TEXT) | O_BINARY); - // Work out initial sample format & frequency, /dev/dsp defaults - audioformat_ = AFMT_U8; - audiofreq_ = 8000; - audiobits_ = 8; - audiochannels_ = 1; - switch (flags & O_ACCMODE) - { - case O_RDWR: - if ((num_in = waveInGetNumDevs ()) == 0) - err = ENXIO; - /* Fall through */ - case O_WRONLY: - if ((num_out = waveOutGetNumDevs ()) == 0) - err = ENXIO; - break; - case O_RDONLY: - if ((num_in = waveInGetNumDevs ()) == 0) - err = ENXIO; - break; - default: - err = EINVAL; - } - - if (!err) - { - set_open_status (); - need_fork_fixup (true); - nohandle (true); - - // FIXME: Do this better someday - fhandler_dev_dsp *arch = (fhandler_dev_dsp *) cmalloc_abort (HEAP_ARCHETYPES, sizeof (*this)); - archetype = arch; - *((fhandler_dev_dsp **) cygheap->fdtab.add_archetype ()) = arch; - *arch = *this; - archetype->usecount = 1; - } - else - set_errno (err); - - debug_printf ("ACCMODE=0x%08x audio_in=%d audio_out=%d, err=%d", - flags & O_ACCMODE, num_in, num_out, err); - return !err; -} - -#define IS_WRITE() ((get_flags() & O_ACCMODE) != O_RDONLY) -#define IS_READ() ((get_flags() & O_ACCMODE) != O_WRONLY) - -ssize_t __stdcall -fhandler_dev_dsp::write (const void *ptr, size_t len) -{ - debug_printf ("ptr=%08x len=%d", ptr, len); - if ((fhandler_dev_dsp *) archetype != this) - return ((fhandler_dev_dsp *)archetype)->write(ptr, len); - - int len_s = len; - const char *ptr_s = static_cast (ptr); - - if (audio_out_) - /* nothing to do */; - else if (IS_WRITE ()) - { - debug_printf ("Allocating"); - if (!(audio_out_ = new Audio_out)) - return -1; - - /* check for wave file & get parameters & skip header if possible. */ - - if (audio_out_->parsewav (ptr_s, len_s, - audiofreq_, audiobits_, audiochannels_)) - debug_printf ("=> ptr_s=%08x len_s=%d", ptr_s, len_s); - } - else - { - set_errno (EBADF); // device was opened for read? - return -1; - } - - /* Open audio device properly with callbacks. - Private parameters were set in call to parsewav. - This is a no-op when there are successive writes in the same process */ - if (!audio_out_->start ()) - { - set_errno (EIO); - return -1; - } - - audio_out_->write (ptr_s, len_s); - return len; -} - -void __stdcall -fhandler_dev_dsp::read (void *ptr, size_t& len) -{ - debug_printf ("ptr=%08x len=%d", ptr, len); - if ((fhandler_dev_dsp *) archetype != this) - return ((fhandler_dev_dsp *)archetype)->read(ptr, len); - - if (audio_in_) - /* nothing to do */; - else if (IS_READ ()) - { - debug_printf ("Allocating"); - if (!(audio_in_ = new Audio_in)) - { - len = (size_t)-1; - return; - } - audio_in_->setconvert (audioformat_); - } - else - { - len = (size_t)-1; - set_errno (EBADF); // device was opened for write? - return; - } - - /* Open audio device properly with callbacks. - This is a noop when there are successive reads in the same process */ - if (!audio_in_->start (audiofreq_, audiobits_, audiochannels_)) - { - len = (size_t)-1; - set_errno (EIO); - return; - } - - audio_in_->read ((char *)ptr, (int&)len); -} - -_off64_t -fhandler_dev_dsp::lseek (_off64_t offset, int whence) -{ - return 0; -} - -void -fhandler_dev_dsp::close_audio_in () -{ - if (audio_in_) - { - audio_in_->stop (); - delete audio_in_; - audio_in_ = NULL; - } -} - -void -fhandler_dev_dsp::close_audio_out (bool immediately) -{ - if (audio_out_) - { - audio_out_->stop (immediately); - delete audio_out_; - audio_out_ = NULL; - } -} - -int -fhandler_dev_dsp::close () -{ - debug_printf ("audio_in=%08x audio_out=%08x", - (int)audio_in_, (int)audio_out_); - if (!hExeced) - { - if ((fhandler_dev_dsp *) archetype != this) - return ((fhandler_dev_dsp *) archetype)->close (); - - if (--usecount == 0) - { - close_audio_in (); - close_audio_out (exit_state != ES_NOT_EXITING); - } - } - return 0; -} - -int -fhandler_dev_dsp::dup (fhandler_base * child) -{ - debug_printf (""); - child->archetype = archetype; - child->set_flags (get_flags ()); - archetype->usecount++; - return 0; -} - -int -fhandler_dev_dsp::ioctl (unsigned int cmd, void *ptr) -{ - debug_printf ("audio_in=%08x audio_out=%08x", - (int)audio_in_, (int)audio_out_); - if ((fhandler_dev_dsp *) archetype != this) - return ((fhandler_dev_dsp *)archetype)->ioctl(cmd, ptr); - - int *intptr = (int *) ptr; - switch (cmd) - { -#define CASE(a) case a : debug_printf ("/dev/dsp: ioctl %s", #a); - - CASE (SNDCTL_DSP_RESET) - close_audio_in (); - close_audio_out (true); - return 0; - break; - - CASE (SNDCTL_DSP_GETBLKSIZE) - /* This is valid even if audio_X is NULL */ - if (IS_WRITE ()) - { - *intptr = audio_out_->blockSize (audiofreq_, - audiobits_, - audiochannels_); - } - else - { // I am very sure that IS_READ is valid - *intptr = audio_in_->blockSize (audiofreq_, - audiobits_, - audiochannels_); - } - return 0; - - CASE (SNDCTL_DSP_SETFMT) - { - int nBits; - switch (*intptr) - { - case AFMT_QUERY: - *intptr = audioformat_; - return 0; - break; - case AFMT_U16_BE: - case AFMT_U16_LE: - case AFMT_S16_BE: - case AFMT_S16_LE: - nBits = 16; - break; - case AFMT_U8: - case AFMT_S8: - nBits = 8; - break; - default: - nBits = 0; - } - if (nBits && IS_WRITE ()) - { - close_audio_out (); - if (audio_out_->query (audiofreq_, nBits, audiochannels_)) - { - audiobits_ = nBits; - audioformat_ = *intptr; - } - else - { - *intptr = audiobits_; - return -1; - } - } - if (nBits && IS_READ ()) - { - close_audio_in (); - if (audio_in_->query (audiofreq_, nBits, audiochannels_)) - { - audiobits_ = nBits; - audioformat_ = *intptr; - } - else - { - *intptr = audiobits_; - return -1; - } - } - return 0; - } - - CASE (SNDCTL_DSP_SPEED) - if (IS_WRITE ()) - { - close_audio_out (); - if (audio_out_->query (*intptr, audiobits_, audiochannels_)) - audiofreq_ = *intptr; - else - { - *intptr = audiofreq_; - return -1; - } - } - if (IS_READ ()) - { - close_audio_in (); - if (audio_in_->query (*intptr, audiobits_, audiochannels_)) - audiofreq_ = *intptr; - else - { - *intptr = audiofreq_; - return -1; - } - } - return 0; - - CASE (SNDCTL_DSP_STEREO) - { - int nChannels = *intptr + 1; - int res = ioctl (SNDCTL_DSP_CHANNELS, &nChannels); - *intptr = nChannels - 1; - return res; - } - - CASE (SNDCTL_DSP_CHANNELS) - { - int nChannels = *intptr; - - if (IS_WRITE ()) - { - close_audio_out (); - if (audio_out_->query (audiofreq_, audiobits_, nChannels)) - audiochannels_ = nChannels; - else - { - *intptr = audiochannels_; - return -1; - } - } - if (IS_READ ()) - { - close_audio_in (); - if (audio_in_->query (audiofreq_, audiobits_, nChannels)) - audiochannels_ = nChannels; - else - { - *intptr = audiochannels_; - return -1; - } - } - return 0; - } - - CASE (SNDCTL_DSP_GETOSPACE) - { - if (!IS_WRITE ()) - { - set_errno(EBADF); - return -1; - } - audio_buf_info *p = (audio_buf_info *) ptr; - audio_out_->buf_info (p, audiofreq_, audiobits_, audiochannels_); - debug_printf ("ptr=%p frags=%d fragsize=%d bytes=%d", - ptr, p->fragments, p->fragsize, p->bytes); - return 0; - } - - CASE (SNDCTL_DSP_GETISPACE) - { - if (!IS_READ ()) - { - set_errno(EBADF); - return -1; - } - audio_buf_info *p = (audio_buf_info *) ptr; - audio_in_->buf_info (p, audiofreq_, audiobits_, audiochannels_); - debug_printf ("ptr=%p frags=%d fragsize=%d bytes=%d", - ptr, p->fragments, p->fragsize, p->bytes); - return 0; - } - - CASE (SNDCTL_DSP_SETFRAGMENT) - // Fake!! esound & mikmod require this on non PowerPC platforms. - // - return 0; - - CASE (SNDCTL_DSP_GETFMTS) - *intptr = AFMT_S16_LE | AFMT_U8; // only native formats returned here - return 0; - - CASE (SNDCTL_DSP_GETCAPS) - *intptr = DSP_CAP_BATCH | DSP_CAP_DUPLEX; - return 0; - - CASE (SNDCTL_DSP_POST) - CASE (SNDCTL_DSP_SYNC) - // Stop audio out device - close_audio_out (); - // Stop audio in device - close_audio_in (); - return 0; - - default: - debug_printf ("/dev/dsp: ioctl 0x%08x not handled yet! FIXME:", cmd); - break; - -#undef CASE - }; - set_errno (EINVAL); - return -1; -} - -void -fhandler_dev_dsp::fixup_after_fork (HANDLE parent) -{ // called from new child process - debug_printf ("audio_in=%08x audio_out=%08x", - (int)audio_in_, (int)audio_out_); - if (archetype != this) - return ((fhandler_dev_dsp *)archetype)->fixup_after_fork (parent); - - if (audio_in_) - audio_in_ ->fork_fixup (parent); - if (audio_out_) - audio_out_->fork_fixup (parent); -} - -void -fhandler_dev_dsp::fixup_after_exec () -{ - debug_printf ("audio_in=%08x audio_out=%08x, close_on_exec %d", - (int) audio_in_, (int) audio_out_, close_on_exec ()); - if (!close_on_exec ()) - { - if (archetype != this) - return ((fhandler_dev_dsp *) archetype)->fixup_after_exec (); - - audio_in_ = NULL; - audio_out_ = NULL; - } -} diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc deleted file mode 100644 index d24c73143..000000000 --- a/winsup/cygwin/fhandler_fifo.cc +++ /dev/null @@ -1,333 +0,0 @@ -/* fhandler_fifo.cc - See fhandler.h for a description of the fhandler classes. - - Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#include "winsup.h" -#include "miscfuncs.h" - -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "sigproc.h" -#include "cygtls.h" -#include "shared_info.h" - -fhandler_fifo::fhandler_fifo (): - wait_state (fifo_unknown), dummy_client (NULL) -{ - get_overlapped ()->hEvent = NULL; - need_fork_fixup (true); -} - -HANDLE -fhandler_fifo::open_nonserver (const char *npname, unsigned low_flags, - LPSECURITY_ATTRIBUTES sa_buf) -{ - DWORD mode = 0; - if (low_flags == O_RDONLY) - mode = GENERIC_READ; - else if (low_flags == O_WRONLY) - mode = GENERIC_WRITE; - else - mode = GENERIC_READ | GENERIC_WRITE; - while (1) - { - HANDLE h = CreateFile (npname, mode, 0, sa_buf, OPEN_EXISTING, - FILE_FLAG_OVERLAPPED, NULL); - if (h != INVALID_HANDLE_VALUE || GetLastError () != ERROR_PIPE_NOT_CONNECTED) - return h; - if (&_my_tls != _main_tls) - low_priority_sleep (0); - else if (WaitForSingleObject (signal_arrived, 0) == WAIT_OBJECT_0) - { - set_errno (EINTR); - return NULL; - } - } -} - -char * -fhandler_fifo::fifo_name (char *buf) -{ - /* Generate a semi-unique name to associate with this fifo. */ - __small_sprintf (buf, "\\\\.\\pipe\\__cygfifo__%S_%08x_%016X", - &installation_key, get_dev (), get_ino ()); - return buf; -} - -#define FIFO_PIPE_MODE (PIPE_TYPE_BYTE | PIPE_READMODE_BYTE) -#define FIFO_BUF_SIZE 4096 -#define cnp(m, s) CreateNamedPipe(npname, (m), FIFO_PIPE_MODE, \ - PIPE_UNLIMITED_INSTANCES, (s), (s), \ - NMPWAIT_WAIT_FOREVER, sa_buf) - -inline PSECURITY_ATTRIBUTES -sec_user_cloexec (bool cloexec, PSECURITY_ATTRIBUTES sa, PSID sid) -{ - return cloexec ? sec_user_nih (sa, sid) : sec_user (sa, sid); -} - -int -fhandler_fifo::open (int flags, mode_t) -{ - int res = 1; - char npname[MAX_PATH]; - - fifo_name (npname); - unsigned low_flags = flags & O_ACCMODE; - DWORD mode = 0; - if (low_flags == O_WRONLY) - mode = PIPE_ACCESS_OUTBOUND; - else if (low_flags == O_RDONLY || low_flags == O_RDWR) - mode = PIPE_ACCESS_DUPLEX; - else - { - set_errno (EINVAL); - res = 0; - } - - if (res) - { - char char_sa_buf[1024]; - LPSECURITY_ATTRIBUTES sa_buf = - sec_user_cloexec (flags & O_CLOEXEC, (PSECURITY_ATTRIBUTES) char_sa_buf, - cygheap->user.sid()); - bool do_seterrno = true; - - HANDLE h; - bool nonblocking_write = !!((flags & (O_WRONLY | O_NONBLOCK)) == (O_WRONLY | O_NONBLOCK)); - wait_state = fifo_unknown; - if (mode != PIPE_ACCESS_OUTBOUND) - { - h = cnp (mode | FILE_FLAG_OVERLAPPED, FIFO_BUF_SIZE); - wait_state = fifo_wait_for_client; - } - else - { - h = open_nonserver (npname, low_flags, sa_buf); - if (h != INVALID_HANDLE_VALUE) - wait_state = fifo_ok; - else if (nonblocking_write) - { - set_errno (ENXIO); - do_seterrno = false; - } - else if ((h = cnp (PIPE_ACCESS_DUPLEX, 1)) != INVALID_HANDLE_VALUE) - { - if ((dummy_client = open_nonserver (npname, low_flags, sa_buf)) - != INVALID_HANDLE_VALUE) - { - wait_state = fifo_wait_for_server; - ProtectHandle (dummy_client); - } - else - { - DWORD saveerr = GetLastError (); - CloseHandle (h); - h = INVALID_HANDLE_VALUE; - SetLastError (saveerr); - } - } - } - if (h == INVALID_HANDLE_VALUE) - { - if (do_seterrno) - __seterrno (); - res = 0; - } - else if (!setup_overlapped ()) - { - CloseHandle (h); - __seterrno (); - res = 0; - } - else - { - set_io_handle (h); - set_flags (flags); - res = 1; - } - } - - debug_printf ("returning %d, errno %d", res, get_errno ()); - return res; -} - -bool -fhandler_fifo::wait (bool iswrite) -{ - DWORD ninstances; - switch (wait_state) - { - case fifo_wait_for_next_client: - DisconnectNamedPipe (get_handle ()); - if (!GetNamedPipeHandleState (get_handle (), NULL, &ninstances, NULL, NULL, NULL, 0)) - { - __seterrno (); - wait_state = fifo_error; - return false; - } - if (ninstances <= 1) - { - wait_state = fifo_eof; - return false; - } - case fifo_wait_for_client: - { - DWORD dummy_bytes; - while (1) - { - int res = ConnectNamedPipe (get_handle (), get_overlapped ()); - if (GetLastError () != ERROR_NO_DATA && GetLastError () != ERROR_PIPE_CONNECTED) - { - res = wait_overlapped (res, iswrite, &dummy_bytes); - if (!res) - { - if (get_errno () != EINTR) - wait_state = fifo_error; - else if (!_my_tls.call_signal_handler ()) - wait_state = fifo_eintr; - else - continue; - return false; - } - } - wait_state = fifo_ok; - break; - } - } - break; - case fifo_wait_for_server: - char npname[MAX_PATH]; - fifo_name (npname); - char char_sa_buf[1024]; - LPSECURITY_ATTRIBUTES sa_buf; - sa_buf = sec_user_cloexec (close_on_exec (), - (PSECURITY_ATTRIBUTES) char_sa_buf, - cygheap->user.sid()); - while (1) - { - if (WaitNamedPipe (npname, 10)) - /* connected, maybe */; - else if (GetLastError () != ERROR_SEM_TIMEOUT) - { - __seterrno (); - return false; - } - else if (WaitForSingleObject (signal_arrived, 0) != WAIT_OBJECT_0) - continue; - else if (_my_tls.call_signal_handler ()) - continue; - else - { - set_errno (EINTR); - return false; - } - HANDLE h = open_nonserver (npname, get_flags () & O_ACCMODE, sa_buf); - if (h != INVALID_HANDLE_VALUE) - { - ForceCloseHandle (get_handle ()); - ForceCloseHandle (dummy_client); - dummy_client = NULL; - wait_state = fifo_ok; - set_io_handle (h); - break; - } - if (GetLastError () == ERROR_PIPE_LISTENING) - continue; - else - { - __seterrno (); - return false; - } - } - default: - break; - } - return true; -} - -void __stdcall -fhandler_fifo::raw_read (void *in_ptr, size_t& len) -{ - while (wait_state != fifo_eof && wait_state != fifo_error && wait_state != fifo_eintr) - if (!wait (false)) - len = (wait_state == fifo_error || wait_state == fifo_eintr) ? (size_t) -1 : 0; - else - { - size_t prev_len = len; - read_overlapped (in_ptr, len); - if (len) - break; - wait_state = fifo_wait_for_next_client; - len = prev_len; - } - if (wait_state == fifo_eintr) - wait_state = fifo_wait_for_client; - debug_printf ("returning %d, mode %d, %E\n", len, get_errno ()); -} - -ssize_t __stdcall -fhandler_fifo::raw_write (const void *ptr, size_t len) -{ - return wait (true) ? write_overlapped (ptr, len) : -1; -} - -int __stdcall -fhandler_fifo::fstatvfs (struct statvfs *sfs) -{ - fhandler_disk_file fh (pc); - fh.get_device () = FH_FS; - return fh.fstatvfs (sfs); -} - -int -fhandler_fifo::close () -{ - wait_state = fifo_eof; - if (dummy_client) - { - ForceCloseHandle (dummy_client); - dummy_client = NULL; - } - return fhandler_base::close (); -} - -int -fhandler_fifo::dup (fhandler_base *child) -{ - int res = fhandler_base::dup (child); - fhandler_fifo *fifo_child = (fhandler_fifo *) child; - if (res == 0 && dummy_client) - { - bool dres = DuplicateHandle (GetCurrentProcess (), dummy_client, - GetCurrentProcess (), - &fifo_child->dummy_client, 0, - TRUE, DUPLICATE_SAME_ACCESS); - if (!dres) - { - fifo_child->dummy_client = NULL; - child->close (); - __seterrno (); - res = -1; - } - } - return res; -} - -void -fhandler_fifo::set_close_on_exec (bool val) -{ - fhandler_base::set_close_on_exec (val); - if (dummy_client) - set_no_inheritance (dummy_client, val); -} diff --git a/winsup/cygwin/fhandler_floppy.cc b/winsup/cygwin/fhandler_floppy.cc deleted file mode 100644 index 0d906b186..000000000 --- a/winsup/cygwin/fhandler_floppy.cc +++ /dev/null @@ -1,555 +0,0 @@ -/* fhandler_floppy.cc. See fhandler.h for a description of the - fhandler classes. - - Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, - 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include -#include -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "ntdll.h" - -#define IS_EOM(err) ((err) == ERROR_INVALID_PARAMETER \ - || (err) == ERROR_SEEK \ - || (err) == ERROR_SECTOR_NOT_FOUND) - -/**********************************************************************/ -/* fhandler_dev_floppy */ - -fhandler_dev_floppy::fhandler_dev_floppy () - : fhandler_dev_raw (), status () -{ -} - -int -fhandler_dev_floppy::get_drive_info (struct hd_geometry *geo) -{ - char dbuf[256]; - char pbuf[256]; - - DISK_GEOMETRY *di = NULL; - PARTITION_INFORMATION_EX *pix = NULL; - PARTITION_INFORMATION *pi = NULL; - DWORD bytes_read = 0; - - /* Always try using the new EX ioctls first (>= XP). If not available, - fall back to trying the old non-EX ioctls. - Unfortunately the EX ioctls are not implemented in the floppy driver. */ - if (wincap.has_disk_ex_ioctls () && get_major () != DEV_FLOPPY_MAJOR) - { - if (!DeviceIoControl (get_handle (), - IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, - dbuf, 256, &bytes_read, NULL)) - __seterrno (); - else - { - di = &((DISK_GEOMETRY_EX *) dbuf)->Geometry; - if (!DeviceIoControl (get_handle (), - IOCTL_DISK_GET_PARTITION_INFO_EX, NULL, 0, - pbuf, 256, &bytes_read, NULL)) - __seterrno (); - else - pix = (PARTITION_INFORMATION_EX *) pbuf; - } - } - if (!di) - { - if (!DeviceIoControl (get_handle (), - IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, - dbuf, 256, &bytes_read, NULL)) - __seterrno (); - else - { - di = (DISK_GEOMETRY *) dbuf; - if (!DeviceIoControl (get_handle (), - IOCTL_DISK_GET_PARTITION_INFO, NULL, 0, - pbuf, 256, &bytes_read, NULL)) - __seterrno (); - else - pi = (PARTITION_INFORMATION *) pbuf; - } - } - if (!di) - { - /* Up to Win2K, even IOCTL_DISK_GET_DRIVE_GEOMETRY fails when trying - it on CD or DVD drives. In that case fall back to requesting - simple file system information. */ - NTSTATUS status; - IO_STATUS_BLOCK io; - FILE_FS_SIZE_INFORMATION ffsi; - - status = NtQueryVolumeInformationFile (get_handle (), &io, &ffsi, - sizeof ffsi, - FileFsSizeInformation); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - return -1; - } - debug_printf ("fsys geometry: (%D units)*(%u sec)*(%u bps)", - ffsi.TotalAllocationUnits.QuadPart, - ffsi.SectorsPerAllocationUnit, - ffsi.BytesPerSector); - bytes_per_sector = ffsi.BytesPerSector; - drive_size = ffsi.TotalAllocationUnits.QuadPart - * ffsi.SectorsPerAllocationUnit - * ffsi.BytesPerSector; - if (geo) - { - geo->heads = 1; - geo->sectors = ffsi.SectorsPerAllocationUnit; - geo->cylinders = ffsi.TotalAllocationUnits.LowPart; - geo->start = 0; - } - } - else - { - debug_printf ("disk geometry: (%D cyl)*(%u trk)*(%u sec)*(%u bps)", - di->Cylinders.QuadPart, - di->TracksPerCylinder, - di->SectorsPerTrack, - di->BytesPerSector); - bytes_per_sector = di->BytesPerSector; - if (pix) - { - debug_printf ("partition info: offset %D length %D", - pix->StartingOffset.QuadPart, - pix->PartitionLength.QuadPart); - drive_size = pix->PartitionLength.QuadPart; - } - else if (pi) - { - debug_printf ("partition info: offset %D length %D", - pi->StartingOffset.QuadPart, - pi->PartitionLength.QuadPart); - drive_size = pi->PartitionLength.QuadPart; - } - else - { - /* Getting the partition size by using the drive geometry information - looks wrong, but this is a historical necessity. NT4 didn't - maintain partition information for the whole drive (aka - "partition 0"), but returned ERROR_INVALID_HANDLE instead. That - got fixed in W2K. */ - drive_size = di->Cylinders.QuadPart * di->TracksPerCylinder - * di->SectorsPerTrack * di->BytesPerSector; - } - if (geo) - { - geo->heads = di->TracksPerCylinder; - geo->sectors = di->SectorsPerTrack; - geo->cylinders = di->Cylinders.LowPart; - if (pix) - geo->start = pix->StartingOffset.QuadPart >> 9ULL; - else if (pi) - geo->start = pi->StartingOffset.QuadPart >> 9ULL; - else - geo->start = 0; - } - } - debug_printf ("drive size: %D", drive_size); - - return 0; -} - -/* Wrapper functions for ReadFile and WriteFile to simplify error handling. */ -BOOL -fhandler_dev_floppy::read_file (void *buf, DWORD to_read, DWORD *read, int *err) -{ - BOOL ret; - - *err = 0; - if (!(ret = ReadFile (get_handle (), buf, to_read, read, 0))) - *err = GetLastError (); - syscall_printf ("%d (err %d) = ReadFile (%d, %d, to_read %d, read %d, 0)", - ret, *err, get_handle (), buf, to_read, *read); - return ret; -} - -BOOL -fhandler_dev_floppy::write_file (const void *buf, DWORD to_write, - DWORD *written, int *err) -{ - BOOL ret; - - *err = 0; - if (!(ret = WriteFile (get_handle (), buf, to_write, written, 0))) - *err = GetLastError (); - syscall_printf ("%d (err %d) = WriteFile (%d, %d, write %d, written %d, 0)", - ret, *err, get_handle (), buf, to_write, *written); - return ret; -} - -int -fhandler_dev_floppy::open (int flags, mode_t) -{ - /* The correct size of the buffer would be 512 bytes, which is the atomic - size, supported by WinNT. Unfortunately, the performance is worse than - access to file system on same device! Setting buffer size to a - relatively big value increases performance by means. The new ioctl call - with 'rdevio.h' header file supports changing this value. - - As default buffer size, we're using some value which is a multiple of - the typical tar and cpio buffer sizes, Except O_DIRECT is set, in which - case we're not buffering at all. */ - devbufsiz = (flags & O_DIRECT) ? 0L : 61440L; - int ret = fhandler_dev_raw::open (flags); - - if (ret) - { - DWORD bytes_read; - - if (get_drive_info (NULL)) - { - close (); - return 0; - } - /* If we're trying to access a CD/DVD drive, or an entire disk, - make sure we're actually allowed to read *all* of the device. - This is actually documented in the MSDN CreateFile man page. */ - if (get_major () != DEV_FLOPPY_MAJOR - && (get_major () == DEV_CDROM_MAJOR || get_minor () == 0) - && !DeviceIoControl (get_handle (), FSCTL_ALLOW_EXTENDED_DASD_IO, - NULL, 0, NULL, 0, &bytes_read, NULL)) - debug_printf ("DeviceIoControl (FSCTL_ALLOW_EXTENDED_DASD_IO) " - "failed, %E"); - } - - return ret; -} - -int -fhandler_dev_floppy::dup (fhandler_base *child) -{ - int ret = fhandler_dev_raw::dup (child); - - if (!ret) - { - fhandler_dev_floppy *fhc = (fhandler_dev_floppy *) child; - - fhc->drive_size = drive_size; - fhc->bytes_per_sector = bytes_per_sector; - fhc->eom_detected (eom_detected ()); - } - return ret; -} - -inline _off64_t -fhandler_dev_floppy::get_current_position () -{ - LARGE_INTEGER off = { QuadPart: 0LL }; - off.LowPart = SetFilePointer (get_handle (), 0, &off.HighPart, FILE_CURRENT); - return off.QuadPart; -} - -void __stdcall -fhandler_dev_floppy::raw_read (void *ptr, size_t& ulen) -{ - DWORD bytes_read = 0; - DWORD read2; - DWORD bytes_to_read; - int ret; - size_t len = ulen; - char *tgt; - char *p = (char *) ptr; - - /* Checking a previous end of media */ - if (eom_detected () && !lastblk_to_read ()) - { - set_errno (ENOSPC); - goto err; - } - - if (devbuf) - { - while (len > 0) - { - if (devbufstart < devbufend) - { - bytes_to_read = min (len, devbufend - devbufstart); - debug_printf ("read %d bytes from buffer (rest %d)", - bytes_to_read, - devbufend - devbufstart - bytes_to_read); - memcpy (p, devbuf + devbufstart, bytes_to_read); - len -= bytes_to_read; - p += bytes_to_read; - bytes_read += bytes_to_read; - devbufstart += bytes_to_read; - - if (lastblk_to_read ()) - { - lastblk_to_read (false); - break; - } - } - if (len > 0) - { - if (len >= devbufsiz) - { - bytes_to_read = (len / bytes_per_sector) * bytes_per_sector; - tgt = p; - } - else - { - tgt = devbuf; - bytes_to_read = devbufsiz; - } - _off64_t current_position = get_current_position (); - if (current_position + bytes_to_read >= drive_size) - bytes_to_read = drive_size - current_position; - if (!bytes_to_read) - break; - - debug_printf ("read %d bytes from pos %U %s", bytes_to_read, - current_position, - len < devbufsiz ? "into buffer" : "directly"); - if (!read_file (tgt, bytes_to_read, &read2, &ret)) - { - if (!IS_EOM (ret)) - { - __seterrno (); - goto err; - } - - eom_detected (true); - - if (!read2) - { - if (!bytes_read) - { - debug_printf ("return -1, set errno to ENOSPC"); - set_errno (ENOSPC); - goto err; - } - break; - } - lastblk_to_read (true); - } - if (!read2) - break; - if (tgt == devbuf) - { - devbufstart = 0; - devbufend = read2; - } - else - { - len -= read2; - p += read2; - bytes_read += read2; - } - } - } - } - else - { - _off64_t current_position = get_current_position (); - bytes_to_read = len; - if (current_position + bytes_to_read >= drive_size) - bytes_to_read = drive_size - current_position; - debug_printf ("read %d bytes from pos %U directly", bytes_to_read, - current_position); - if (bytes_to_read && !read_file (p, bytes_to_read, &bytes_read, &ret)) - { - if (!IS_EOM (ret)) - { - __seterrno (); - goto err; - } - if (bytes_read) - eom_detected (true); - else - { - debug_printf ("return -1, set errno to ENOSPC"); - set_errno (ENOSPC); - goto err; - } - } - } - - ulen = (size_t) bytes_read; - return; - -err: - ulen = (size_t) -1; -} - -int __stdcall -fhandler_dev_floppy::raw_write (const void *ptr, size_t len) -{ - DWORD bytes_written = 0; - char *p = (char *) ptr; - int ret; - - /* Checking a previous end of media on tape */ - if (eom_detected ()) - { - set_errno (ENOSPC); - return -1; - } - - /* Invalidate buffer. */ - devbufstart = devbufend = 0; - - if (len > 0) - { - if (!write_file (p, len, &bytes_written, &ret)) - { - if (!IS_EOM (ret)) - { - __seterrno (); - return -1; - } - eom_detected (true); - if (!bytes_written) - { - set_errno (ENOSPC); - return -1; - } - } - } - return bytes_written; -} - -_off64_t -fhandler_dev_floppy::lseek (_off64_t offset, int whence) -{ - char buf[bytes_per_sector]; - _off64_t lloffset = offset; - _off64_t current_pos = (_off64_t) -1; - LARGE_INTEGER sector_aligned_offset; - size_t bytes_left; - - if (whence == SEEK_END) - { - lloffset += drive_size; - whence = SEEK_SET; - } - else if (whence == SEEK_CUR) - { - current_pos = get_current_position (); - lloffset += current_pos - (devbufend - devbufstart); - whence = SEEK_SET; - } - - if (whence != SEEK_SET || lloffset < 0 || lloffset > drive_size) - { - set_errno (EINVAL); - return -1; - } - - /* If new position is in buffered range, adjust buffer and return */ - if (devbufstart < devbufend) - { - if (current_pos == (_off64_t) -1) - current_pos = get_current_position (); - if (current_pos - devbufend <= lloffset && lloffset <= current_pos) - { - devbufstart = devbufend - (current_pos - lloffset); - return lloffset; - } - } - - sector_aligned_offset.QuadPart = (lloffset / bytes_per_sector) - * bytes_per_sector; - bytes_left = lloffset - sector_aligned_offset.QuadPart; - - /* Invalidate buffer. */ - devbufstart = devbufend = 0; - - sector_aligned_offset.LowPart = - SetFilePointer (get_handle (), - sector_aligned_offset.LowPart, - §or_aligned_offset.HighPart, - FILE_BEGIN); - if (sector_aligned_offset.LowPart == INVALID_SET_FILE_POINTER - && GetLastError ()) - { - __seterrno (); - return -1; - } - - eom_detected (false); - - if (bytes_left) - { - raw_read (buf, bytes_left); - if (bytes_left == (size_t) -1) - return -1; - } - - return sector_aligned_offset.QuadPart + bytes_left; -} - -int -fhandler_dev_floppy::ioctl (unsigned int cmd, void *buf) -{ - DISK_GEOMETRY di; - DWORD bytes_read; - switch (cmd) - { - case HDIO_GETGEO: - { - debug_printf ("HDIO_GETGEO"); - return get_drive_info ((struct hd_geometry *) buf); - } - case BLKGETSIZE: - case BLKGETSIZE64: - { - debug_printf ("BLKGETSIZE"); - if (cmd == BLKGETSIZE) - *(long *)buf = drive_size >> 9UL; - else - *(_off64_t *)buf = drive_size; - return 0; - } - case BLKRRPART: - { - debug_printf ("BLKRRPART"); - if (!DeviceIoControl (get_handle (), - IOCTL_DISK_UPDATE_DRIVE_SIZE, - NULL, 0, - &di, sizeof (di), - &bytes_read, NULL)) - { - __seterrno (); - return -1; - } - get_drive_info (NULL); - return 0; - } - case BLKSSZGET: - { - debug_printf ("BLKSSZGET"); - *(int *)buf = bytes_per_sector; - return 0; - } - case RDSETBLK: - /* Just check the restriction that blocksize must be a multiple - of the sector size of the underlying volume sector size, - then fall through to fhandler_dev_raw::ioctl. */ - if (((struct rdop *) buf)->rd_parm % bytes_per_sector) - { - SetLastError (ERROR_INVALID_PARAMETER); - __seterrno (); - return -1; - } - /*FALLTHRU*/ - default: - return fhandler_dev_raw::ioctl (cmd, buf); - } -} - diff --git a/winsup/cygwin/fhandler_mailslot.cc b/winsup/cygwin/fhandler_mailslot.cc deleted file mode 100644 index 691c6043b..000000000 --- a/winsup/cygwin/fhandler_mailslot.cc +++ /dev/null @@ -1,190 +0,0 @@ -/* fhandler_mailslot.cc. See fhandler.h for a description of the fhandler classes. - - Copyright 2005, 2007, 2008, 2009, 2010 Red Hat, Inc. - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#include "winsup.h" - -#include "cygerrno.h" -#include "path.h" -#include "fhandler.h" -#include "ntdll.h" -#include "shared_info.h" -#include "tls_pbuf.h" - -/**********************************************************************/ -/* fhandler_mailslot */ - -fhandler_mailslot::fhandler_mailslot () - : fhandler_base () -{ -} - -int __stdcall -fhandler_mailslot::fstat (struct __stat64 *buf) -{ - debug_printf ("here"); - - fhandler_base::fstat (buf); - if (is_auto_device ()) - { - buf->st_mode = S_IFCHR | S_IRUSR | S_IWUSR; - buf->st_uid = geteuid32 (); - buf->st_gid = getegid32 (); - buf->st_nlink = 1; - buf->st_blksize = PREFERRED_IO_BLKSIZE; - time_as_timestruc_t (&buf->st_ctim); - buf->st_atim = buf->st_mtim = buf->st_birthtim = buf->st_ctim; - } - return 0; -} - -POBJECT_ATTRIBUTES -fhandler_mailslot::get_object_attr (OBJECT_ATTRIBUTES &attr, - PUNICODE_STRING path, - int flags) -{ - - RtlCopyUnicodeString (path, pc.get_nt_native_path ()); - RtlAppendUnicodeStringToString (path, &installation_key); - InitializeObjectAttributes (&attr, path, - OBJ_CASE_INSENSITIVE - | (flags & O_CLOEXEC ? 0 : OBJ_INHERIT), - NULL, NULL); - return &attr; -} - -int -fhandler_mailslot::open (int flags, mode_t mode) -{ - int res = 0; - NTSTATUS status; - IO_STATUS_BLOCK io; - OBJECT_ATTRIBUTES attr; - HANDLE x; - LARGE_INTEGER timeout; - tmp_pathbuf tp; - UNICODE_STRING path; - - tp.u_get (&path); - - switch (flags & O_ACCMODE) - { - case O_RDONLY: /* Server */ - timeout.QuadPart = (flags & O_NONBLOCK) ? 0LL : 0x8000000000000000LL; - status = NtCreateMailslotFile (&x, GENERIC_READ | SYNCHRONIZE, - get_object_attr (attr, &path, flags), - &io, FILE_SYNCHRONOUS_IO_NONALERT, - 0, 0, &timeout); - if (!NT_SUCCESS (status)) - { - /* FIXME: It's not possible to open the read side of an existing - mailslot again. You'll get a handle, but using it in ReadFile - returns ERROR_INVALID_PARAMETER. On the other hand, - NtCreateMailslotFile returns with STATUS_OBJECT_NAME_EXISTS if - the mailslot has been created already. - So this is an exclusive open for now. *Duplicating* read side - handles works, though, so it might be an option to duplicate - the handle from the first process to the current process for - opening the mailslot. */ -#if 0 - if (status != STATUS_OBJECT_NAME_COLLISION) - { - __seterrno_from_nt_status (status); - break; - } - status = NtOpenFile (&x, GENERIC_READ | SYNCHRONIZE, - get_object_attr (attr, &path, flags), &io, - FILE_SHARE_VALID_FLAGS, - FILE_SYNCHRONOUS_IO_NONALERT); -#endif - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - break; - } - } - set_io_handle (x); - set_flags (flags, O_BINARY); - res = 1; - set_open_status (); - break; - case O_WRONLY: /* Client */ - /* The client is the DLL exclusively. Don't allow opening from - application code. */ - extern fhandler_mailslot *dev_kmsg; - if (this != dev_kmsg) - { - set_errno (EPERM); /* As on Linux. */ - break; - } - status = NtOpenFile (&x, GENERIC_WRITE | SYNCHRONIZE, - get_object_attr (attr, &path, flags), &io, - FILE_SHARE_VALID_FLAGS, - FILE_SYNCHRONOUS_IO_NONALERT); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - break; - } - set_io_handle (x); - set_flags (flags, O_BINARY); - res = 1; - set_open_status (); - break; - default: - set_errno (EINVAL); - break; - } - return res; -} - -ssize_t __stdcall -fhandler_mailslot::write (const void *ptr, size_t len) -{ - /* Check for 425/426 byte weirdness */ - if (len == 425 || len == 426) - { - char buf[427]; - buf[425] = buf[426] = '\0'; - memcpy (buf, ptr, len); - return raw_write (buf, 427); - } - return raw_write (ptr, len); -} - -int -fhandler_mailslot::ioctl (unsigned int cmd, void *buf) -{ - int res = -1; - NTSTATUS status; - IO_STATUS_BLOCK io; - - switch (cmd) - { - case FIONBIO: - { - FILE_MAILSLOT_SET_INFORMATION fmsi; - fmsi.ReadTimeout.QuadPart = buf ? 0LL : 0x8000000000000000LL; - status = NtSetInformationFile (get_handle (), &io, &fmsi, sizeof fmsi, - FileMailslotSetInformation); - if (!NT_SUCCESS (status)) - { - debug_printf ("NtSetInformationFile (%X): %08x", - fmsi.ReadTimeout.QuadPart, status); - __seterrno_from_nt_status (status); - break; - } - } - /*FALLTHRU*/ - default: - res = fhandler_base::ioctl (cmd, buf); - break; - } - return res; -} diff --git a/winsup/cygwin/fhandler_mem.cc b/winsup/cygwin/fhandler_mem.cc deleted file mode 100644 index b172cc576..000000000 --- a/winsup/cygwin/fhandler_mem.cc +++ /dev/null @@ -1,280 +0,0 @@ -/* fhandler_mem.cc. See fhandler.h for a description of the fhandler classes. - - Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, - 2010 Red Hat, Inc. - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#include "winsup.h" -#include - -#include "cygerrno.h" -#include "path.h" -#include "fhandler.h" -#include "ntdll.h" - -/**********************************************************************/ -/* fhandler_dev_mem */ - -fhandler_dev_mem::fhandler_dev_mem () - : fhandler_base () -{ -} - -fhandler_dev_mem::~fhandler_dev_mem () -{ -} - -int -fhandler_dev_mem::open (int flags, mode_t) -{ - if (!wincap.has_physical_mem_access ()) - { - set_errno (ENOENT); - debug_printf ("%s is accessible under NT4/W2K/XP only", dev ().name); - return 0; - } - - if (dev () == FH_MEM) /* /dev/mem */ - { - NTSTATUS ret; - SYSTEM_BASIC_INFORMATION sbi; - if ((ret = NtQuerySystemInformation (SystemBasicInformation, (PVOID) &sbi, - sizeof sbi, NULL)) != STATUS_SUCCESS) - { - __seterrno_from_nt_status (ret); - debug_printf("NtQuerySystemInformation: ret %d, Dos(ret) %E", ret); - mem_size = 0; - } - else - mem_size = sbi.PhysicalPageSize * sbi.NumberOfPhysicalPages; - debug_printf ("MemSize: %d MB", mem_size >> 20); - } - else if (dev () == FH_KMEM) /* /dev/kmem - Not yet supported */ - { - mem_size = 0; - debug_printf ("KMemSize: %d MB", mem_size >> 20); - } - else if (dev () == FH_PORT) /* /dev/port == First 64K of /dev/mem */ - { - mem_size = 65536; - debug_printf ("PortSize: 64 KB"); - } - else - { - mem_size = 0; - debug_printf ("Illegal minor number!!!"); - } - - /* Check for illegal flags. */ - if (flags & (O_APPEND | O_TRUNC | O_EXCL)) - { - set_errno (EINVAL); - return 0; - } - - OBJECT_ATTRIBUTES attr; - InitializeObjectAttributes (&attr, &ro_u_pmem, - OBJ_CASE_INSENSITIVE - | (flags & O_CLOEXEC ? 0 : OBJ_INHERIT), - NULL, NULL); - - ACCESS_MASK section_access; - if ((flags & O_ACCMODE) == O_RDONLY) - { - set_access (GENERIC_READ); - section_access = SECTION_MAP_READ; - } - else if ((flags & O_ACCMODE) == O_WRONLY) - { - set_access (GENERIC_WRITE); - section_access = SECTION_MAP_READ | SECTION_MAP_WRITE; - } - else - { - set_access (GENERIC_READ | GENERIC_WRITE); - section_access = SECTION_MAP_READ | SECTION_MAP_WRITE; - } - - HANDLE mem; - NTSTATUS ret = NtOpenSection (&mem, section_access, &attr); - if (!NT_SUCCESS (ret)) - { - __seterrno_from_nt_status (ret); - set_io_handle (NULL); - return 0; - } - - set_io_handle (mem); - set_open_status (); - return 1; -} - -ssize_t __stdcall -fhandler_dev_mem::write (const void *ptr, size_t ulen) -{ - if (!ulen || pos >= mem_size) - return 0; - - if (!(get_access () & GENERIC_WRITE)) - { - set_errno (EINVAL); - return -1; - } - - if (pos + ulen > mem_size) - ulen = mem_size - pos; - - PHYSICAL_ADDRESS phys; - NTSTATUS ret; - void *viewmem = NULL; - DWORD len = ulen + getsystempagesize () - 1; - - phys.QuadPart = (ULONGLONG) pos; - if ((ret = NtMapViewOfSection (get_handle (), - INVALID_HANDLE_VALUE, - &viewmem, - 0L, - len, - &phys, - &len, - ViewShare, - 0, - PAGE_READONLY)) != STATUS_SUCCESS) - { - __seterrno_from_nt_status (ret); - return -1; - } - - memcpy ((char *) viewmem + (pos - phys.QuadPart), ptr, ulen); - - if (!NT_SUCCESS (ret = NtUnmapViewOfSection (INVALID_HANDLE_VALUE, viewmem))) - { - __seterrno_from_nt_status (ret); - return -1; - } - - pos += ulen; - return ulen; -} - -void __stdcall -fhandler_dev_mem::read (void *ptr, size_t& ulen) -{ - if (!ulen || pos >= mem_size) - { - ulen = 0; - return; - } - - if (!(get_access () & GENERIC_READ)) - { - set_errno (EINVAL); - ulen = (size_t) -1; - return; - } - - if (pos + ulen > mem_size) - ulen = mem_size - pos; - - PHYSICAL_ADDRESS phys; - NTSTATUS ret; - void *viewmem = NULL; - DWORD len = ulen + getsystempagesize () - 1; - - phys.QuadPart = (ULONGLONG) pos; - if ((ret = NtMapViewOfSection (get_handle (), - INVALID_HANDLE_VALUE, - &viewmem, - 0L, - len, - &phys, - &len, - ViewShare, - 0, - PAGE_READONLY)) != STATUS_SUCCESS) - { - __seterrno_from_nt_status (ret); - ulen = (size_t) -1; - return; - } - - memcpy (ptr, (char *) viewmem + (pos - phys.QuadPart), ulen); - - if (!NT_SUCCESS (ret = NtUnmapViewOfSection (INVALID_HANDLE_VALUE, viewmem))) - { - __seterrno_from_nt_status (ret); - ulen = (size_t) -1; - return; - } - - pos += ulen; -} - -_off64_t -fhandler_dev_mem::lseek (_off64_t offset, int whence) -{ - switch (whence) - { - case SEEK_SET: - pos = offset; - break; - - case SEEK_CUR: - pos += offset; - break; - - case SEEK_END: - pos = mem_size; - pos += offset; - break; - - default: - set_errno (EINVAL); - return ILLEGAL_SEEK; - } - - if (pos > mem_size) - { - set_errno (EINVAL); - return ILLEGAL_SEEK; - } - - return pos; -} - -int -fhandler_dev_mem::fstat (struct __stat64 *buf) -{ - fhandler_base::fstat (buf); - buf->st_blksize = getsystempagesize (); - if (is_auto_device ()) - { - buf->st_mode = S_IFCHR; - if (wincap.has_physical_mem_access ()) - buf->st_mode |= S_IRUSR | S_IWUSR | - S_IRGRP | S_IWGRP | - S_IROTH | S_IWOTH; - } - - return 0; -} - -int -fhandler_dev_mem::dup (fhandler_base *child) -{ - int ret = fhandler_base::dup (child); - - if (! ret) - { - fhandler_dev_mem *fhc = (fhandler_dev_mem *) child; - - fhc->mem_size = mem_size; - fhc->pos = pos; - } - return ret; -} diff --git a/winsup/cygwin/fhandler_netdrive.cc b/winsup/cygwin/fhandler_netdrive.cc deleted file mode 100644 index 3de2278ef..000000000 --- a/winsup/cygwin/fhandler_netdrive.cc +++ /dev/null @@ -1,330 +0,0 @@ -/* fhandler_netdrive.cc: fhandler for // and //MACHINE handling - - Copyright 2005, 2006, 2007, 2008 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "cygthread.h" -#include - -#include - -enum - { - GET_RESOURCE_OPENENUM = 1, - GET_RESOURCE_OPENENUMTOP = 2, - GET_RESOURCE_ENUM = 3 - }; - -struct netdriveinf - { - int what; - int ret; - PVOID in; - PVOID out; - DWORD outsize; - HANDLE sem; - }; - -struct net_hdls - { - HANDLE net; - HANDLE dom; - }; - -static DWORD WINAPI -thread_netdrive (void *arg) -{ - netdriveinf *ndi = (netdriveinf *) arg; - char provider[256], *dummy = NULL; - LPNETRESOURCE nro; - DWORD cnt, size; - struct net_hdls *nh; - - ReleaseSemaphore (ndi->sem, 1, NULL); - switch (ndi->what) - { - case GET_RESOURCE_OPENENUMTOP: - nro = (LPNETRESOURCE) alloca (size = 4096); - nh = (struct net_hdls *) ndi->out; - ndi->ret = WNetGetProviderName (WNNC_NET_LANMAN, provider, - (size = 256, &size)); - if (ndi->ret != NO_ERROR) - break; - memset (nro, 0, sizeof *nro); - nro->dwScope = RESOURCE_GLOBALNET; - nro->dwType = RESOURCETYPE_ANY; - nro->dwDisplayType = RESOURCEDISPLAYTYPE_GROUP; - nro->dwUsage = RESOURCEUSAGE_RESERVED | RESOURCEUSAGE_CONTAINER; - nro->lpRemoteName = provider; - nro->lpProvider = provider; - ndi->ret = WNetOpenEnum (RESOURCE_GLOBALNET, RESOURCETYPE_DISK, - RESOURCEUSAGE_ALL, nro, &nh->net); - if (ndi->ret != NO_ERROR) - break; - while ((ndi->ret = WNetEnumResource (nh->net, (cnt = 1, &cnt), nro, - (size = 4096, &size))) == NO_ERROR) - { - ndi->ret = WNetOpenEnum (RESOURCE_GLOBALNET, RESOURCETYPE_DISK, - RESOURCEUSAGE_ALL, nro, &nh->dom); - if (ndi->ret == NO_ERROR) - break; - } - break; - case GET_RESOURCE_OPENENUM: - nro = (LPNETRESOURCE) alloca (size = 4096); - nh = (struct net_hdls *) ndi->out; - ndi->ret = WNetGetProviderName (WNNC_NET_LANMAN, provider, - (size = 256, &size)); - if (ndi->ret != NO_ERROR) - break; - ((LPNETRESOURCE) ndi->in)->lpProvider = provider; - ndi->ret = WNetGetResourceInformation ((LPNETRESOURCE) ndi->in, - nro, &size, &dummy); - if (ndi->ret != NO_ERROR) - break; - ndi->ret = WNetOpenEnum (RESOURCE_GLOBALNET, RESOURCETYPE_DISK, - RESOURCEUSAGE_ALL, nro, &nh->dom); - break; - case GET_RESOURCE_ENUM: - nh = (struct net_hdls *) ndi->in; - if (!nh->dom) - { - ndi->ret = ERROR_NO_MORE_ITEMS; - break; - } - while ((ndi->ret = WNetEnumResource (nh->dom, (cnt = 1, &cnt), - (LPNETRESOURCE) ndi->out, - &ndi->outsize)) != NO_ERROR - && nh->net) - { - WNetCloseEnum (nh->dom); - nh->dom = NULL; - nro = (LPNETRESOURCE) alloca (size = 4096); - while ((ndi->ret = WNetEnumResource (nh->net, (cnt = 1, &cnt), nro, - (size = 4096, &size))) == NO_ERROR) - { - ndi->ret = WNetOpenEnum (RESOURCE_GLOBALNET, RESOURCETYPE_DISK, - RESOURCEUSAGE_ALL, nro, &nh->dom); - if (ndi->ret == NO_ERROR) - break; - } - if (ndi->ret != NO_ERROR) - break; - } - break; - } - ReleaseSemaphore (ndi->sem, 1, NULL); - return 0; -} - -static DWORD -create_thread_and_wait (int what, PVOID in, PVOID out, DWORD outsize, - const char *name) -{ - netdriveinf ndi = { what, 0, in, out, outsize, - CreateSemaphore (&sec_none_nih, 0, 2, NULL) }; - cygthread *thr = new cygthread (thread_netdrive, 0, &ndi, name); - if (thr->detach (ndi.sem)) - ndi.ret = ERROR_OPERATION_ABORTED; - CloseHandle (ndi.sem); - return ndi.ret; -} - -/* Returns 0 if path doesn't exist, >0 if path is a directory, - -1 if path is a file, -2 if it's a symlink. */ -int -fhandler_netdrive::exists () -{ - char *to; - const char *from; - size_t len = strlen (get_name ()); - if (len == 2) - return 1; - char namebuf[len + 1]; - for (to = namebuf, from = get_name (); *from; to++, from++) - *to = (*from == '/') ? '\\' : *from; - *to = '\0'; - - struct net_hdls nh = { NULL, NULL }; - NETRESOURCE nr = {0}; - nr.dwType = RESOURCETYPE_DISK; - nr.lpRemoteName = namebuf; - DWORD ret = create_thread_and_wait (GET_RESOURCE_OPENENUM, - &nr, &nh, 0, "WNetOpenEnum"); - if (ret != NO_ERROR) - { - if (nh.dom) - WNetCloseEnum (nh.dom); - if (nh.net) - WNetCloseEnum (nh.net); - return 0; - } - return 1; -} - -fhandler_netdrive::fhandler_netdrive (): - fhandler_virtual () -{ -} - -int -fhandler_netdrive::fstat (struct __stat64 *buf) -{ - const char *path = get_name (); - debug_printf ("fstat (%s)", path); - - fhandler_base::fstat (buf); - - buf->st_mode = S_IFDIR | STD_RBITS | STD_XBITS; - buf->st_ino = get_ino (); - - return 0; -} - -int -fhandler_netdrive::readdir (DIR *dir, dirent *de) -{ - NETRESOURCE *nro; - DWORD ret; - int res; - - if (!dir->__d_position) - { - size_t len = strlen (get_name ()); - char *namebuf = NULL; - NETRESOURCE nr = { 0 }; - struct net_hdls *nh; - - if (len != 2) /* // */ - { - const char *from; - char *to; - namebuf = (char *) alloca (len + 1); - for (to = namebuf, from = get_name (); *from; to++, from++) - *to = (*from == '/') ? '\\' : *from; - *to = '\0'; - } - - nr.lpRemoteName = namebuf; - nr.dwType = RESOURCETYPE_DISK; - nh = (struct net_hdls *) ccalloc (HEAP_FHANDLER, 1, sizeof *nh); - ret = create_thread_and_wait (len == 2 ? GET_RESOURCE_OPENENUMTOP - : GET_RESOURCE_OPENENUM, - &nr, nh, 0, "WNetOpenEnum"); - if (ret != NO_ERROR) - { - dir->__handle = INVALID_HANDLE_VALUE; - res = geterrno_from_win_error (ret); - goto out; - } - dir->__handle = (HANDLE) nh; - } - ret = create_thread_and_wait (GET_RESOURCE_ENUM, dir->__handle, - nro = (LPNETRESOURCE) alloca (16384), - 16384, "WnetEnumResource"); - if (ret != NO_ERROR) - res = geterrno_from_win_error (ret); - else - { - dir->__d_position++; - char *bs = strrchr (nro->lpRemoteName, '\\'); - strcpy (de->d_name, bs ? bs + 1 : nro->lpRemoteName); - if (strlen (get_name ()) == 2) - { - strlwr (de->d_name); - de->d_ino = hash_path_name (get_ino (), de->d_name); - } - else - { - de->d_ino = readdir_get_ino (nro->lpRemoteName, false); - /* We can't trust remote inode numbers of only 32 bit. That means, - all remote inode numbers when running under NT4, as well as - remote NT4 NTFS, as well as shares of Samba version < 3.0. */ - if (de->d_ino <= UINT_MAX) - de->d_ino = hash_path_name (0, nro->lpRemoteName); - } - - res = 0; - } -out: - syscall_printf ("%d = readdir (%p, %p)", res, dir, de); - return res; -} - -void -fhandler_netdrive::seekdir (DIR *dir, _off64_t pos) -{ - rewinddir (dir); - if (pos < 0) - return; - while (dir->__d_position < pos) - if (!readdir (dir, dir->__d_dirent)) - break; -} - -void -fhandler_netdrive::rewinddir (DIR *dir) -{ - if (dir->__handle != INVALID_HANDLE_VALUE) - { - struct net_hdls *nh = (struct net_hdls *) dir->__handle; - if (nh->dom) - WNetCloseEnum (nh->dom); - if (nh->net) - WNetCloseEnum (nh->net); - cfree (nh); - } - dir->__handle = INVALID_HANDLE_VALUE; - return fhandler_virtual::rewinddir (dir); -} - -int -fhandler_netdrive::closedir (DIR *dir) -{ - rewinddir (dir); - return fhandler_virtual::closedir (dir); -} - -int -fhandler_netdrive::open (int flags, mode_t mode) -{ - int res = fhandler_virtual::open (flags, mode); - if (!res) - goto out; - - nohandle (true); - - if ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) - { - set_errno (EEXIST); - res = 0; - goto out; - } - else if (flags & O_WRONLY) - { - set_errno (EISDIR); - res = 0; - goto out; - } - - res = 1; - set_flags ((flags & ~O_TEXT) | O_BINARY | O_DIROPEN); - set_open_status (); -out: - syscall_printf ("%d = fhandler_netdrive::open (%p, %d)", res, flags, mode); - return res; -} - diff --git a/winsup/cygwin/fhandler_nodevice.cc b/winsup/cygwin/fhandler_nodevice.cc deleted file mode 100644 index 4ffe2c447..000000000 --- a/winsup/cygwin/fhandler_nodevice.cc +++ /dev/null @@ -1,27 +0,0 @@ -/* fhandler_nodevice.cc. "No such device" handler. - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2008, 2009 - Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "cygerrno.h" -#include "path.h" -#include "fhandler.h" - -int -fhandler_nodevice::open (int, mode_t) -{ - if (!pc.error) - set_errno (ENXIO); - return 0; -} - -fhandler_nodevice::fhandler_nodevice () -{ -} diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc deleted file mode 100644 index bfbf64ddf..000000000 --- a/winsup/cygwin/fhandler_proc.cc +++ /dev/null @@ -1,1223 +0,0 @@ -/* fhandler_proc.cc: fhandler for /proc virtual filesystem - - Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "miscfuncs.h" -#include -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "fhandler_virtual.h" -#include "pinfo.h" -#include "dtable.h" -#include "cygheap.h" -#include "tls_pbuf.h" -#include -#include -#include "ntdll.h" -#include -#include -#include -#include "cpuid.h" - -#define _COMPILING_NEWLIB -#include - -static _off64_t format_proc_loadavg (void *, char *&); -static _off64_t format_proc_meminfo (void *, char *&); -static _off64_t format_proc_stat (void *, char *&); -static _off64_t format_proc_version (void *, char *&); -static _off64_t format_proc_uptime (void *, char *&); -static _off64_t format_proc_cpuinfo (void *, char *&); -static _off64_t format_proc_partitions (void *, char *&); -static _off64_t format_proc_self (void *, char *&); -static _off64_t format_proc_mounts (void *, char *&); - -/* names of objects in /proc */ -static const virt_tab_t proc_tab[] = { - { ".", FH_PROC, virt_directory, NULL }, - { "..", FH_PROC, virt_directory, NULL }, - { "loadavg", FH_PROC, virt_file, format_proc_loadavg }, - { "meminfo", FH_PROC, virt_file, format_proc_meminfo }, - { "registry", FH_REGISTRY, virt_directory, NULL }, - { "stat", FH_PROC, virt_file, format_proc_stat }, - { "version", FH_PROC, virt_file, format_proc_version }, - { "uptime", FH_PROC, virt_file, format_proc_uptime }, - { "cpuinfo", FH_PROC, virt_file, format_proc_cpuinfo }, - { "partitions", FH_PROC, virt_file, format_proc_partitions }, - { "self", FH_PROC, virt_symlink, format_proc_self }, - { "mounts", FH_PROC, virt_symlink, format_proc_mounts }, - { "registry32", FH_REGISTRY, virt_directory, NULL }, - { "registry64", FH_REGISTRY, virt_directory, NULL }, - { "net", FH_PROCNET, virt_directory, NULL }, - { NULL, 0, virt_none, NULL } -}; - -#define PROC_DIR_COUNT 4 - -static const int PROC_LINK_COUNT = (sizeof (proc_tab) / sizeof (virt_tab_t)) - 1; - -/* name of the /proc filesystem */ -const char proc[] = "/proc"; -const int proc_len = sizeof (proc) - 1; - -/* Auxillary function that returns the fhandler associated with the given path - this is where it would be nice to have pattern matching in C - polymorphism - just doesn't cut it. */ -DWORD -fhandler_proc::get_proc_fhandler (const char *path) -{ - debug_printf ("get_proc_fhandler(%s)", path); - path += proc_len; - /* Since this method is called from path_conv::check we can't rely on - it being normalised and therefore the path may have runs of slashes - in it. */ - while (isdirsep (*path)) - path++; - - /* Check if this is the root of the virtual filesystem (i.e. /proc). */ - if (*path == 0) - return FH_PROC; - - for (int i = 0; proc_tab[i].name; i++) - { - if (path_prefix_p (proc_tab[i].name, path, strlen (proc_tab[i].name), - false)) - return proc_tab[i].fhandler; - } - - if (pinfo (atoi (path))) - return FH_PROCESS; - - bool has_subdir = false; - while (*path) - if (isdirsep (*path++)) - { - has_subdir = true; - break; - } - - if (has_subdir) - /* The user is trying to access a non-existent subdirectory of /proc. */ - return FH_BAD; - else - /* Return FH_PROC so that we can return EROFS if the user is trying to - create a file. */ - return FH_PROC; -} - -/* Returns 0 if path doesn't exist, >0 if path is a directory, - -1 if path is a file, -2 if it's a symlink. */ -int -fhandler_proc::exists () -{ - const char *path = get_name (); - debug_printf ("exists (%s)", path); - path += proc_len; - if (*path == 0) - return virt_rootdir; - for (int i = 0; proc_tab[i].name; i++) - if (!strcmp (path + 1, proc_tab[i].name)) - { - fileid = i; - return proc_tab[i].type; - } - return virt_none; -} - -fhandler_proc::fhandler_proc (): - fhandler_virtual () -{ -} - -int -fhandler_proc::fstat (struct __stat64 *buf) -{ - const char *path = get_name (); - debug_printf ("fstat (%s)", path); - - path += proc_len; - fhandler_base::fstat (buf); - - buf->st_mode &= ~_IFMT & NO_W; - - if (!*path) - { - winpids pids ((DWORD) 0); - buf->st_ino = 2; - buf->st_mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH; - buf->st_nlink = PROC_DIR_COUNT + 2 + pids.npids; - return 0; - } - else - { - path++; - for (int i = 0; proc_tab[i].name; i++) - if (!strcmp (path, proc_tab[i].name)) - { - if (proc_tab[i].type == virt_directory) - buf->st_mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH; - else if (proc_tab[i].type == virt_symlink) - buf->st_mode = S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO; - else - { - buf->st_mode &= NO_X; - buf->st_mode |= S_IFREG; - } - return 0; - } - } - set_errno (ENOENT); - return -1; -} - -int -fhandler_proc::readdir (DIR *dir, dirent *de) -{ - int res; - if (dir->__d_position < PROC_LINK_COUNT) - { - strcpy (de->d_name, proc_tab[dir->__d_position++].name); - dir->__flags |= dirent_saw_dot | dirent_saw_dot_dot; - res = 0; - } - else - { - winpids pids ((DWORD) 0); - int found = 0; - res = ENMFILE; - for (unsigned i = 0; i < pids.npids; i++) - if (found++ == dir->__d_position - PROC_LINK_COUNT) - { - __small_sprintf (de->d_name, "%d", pids[i]->pid); - dir->__d_position++; - res = 0; - break; - } - } - - syscall_printf ("%d = readdir (%p, %p) (%s)", res, dir, de, de->d_name); - return res; -} - -int -fhandler_proc::open (int flags, mode_t mode) -{ - int proc_file_no = -1; - - int res = fhandler_virtual::open (flags, mode); - if (!res) - goto out; - - nohandle (true); - - const char *path; - - path = get_name () + proc_len; - - if (!*path) - { - if ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) - { - set_errno (EEXIST); - res = 0; - goto out; - } - else if (flags & O_WRONLY) - { - set_errno (EISDIR); - res = 0; - goto out; - } - else - { - flags |= O_DIROPEN; - goto success; - } - } - - proc_file_no = -1; - for (int i = 0; proc_tab[i].name; i++) - if (path_prefix_p (proc_tab[i].name, path + 1, strlen (proc_tab[i].name), - false)) - { - proc_file_no = i; - if (proc_tab[i].fhandler != FH_PROC) - { - if ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) - { - set_errno (EEXIST); - res = 0; - goto out; - } - else if (flags & O_WRONLY) - { - set_errno (EISDIR); - res = 0; - goto out; - } - else - { - flags |= O_DIROPEN; - goto success; - } - } - } - - if (proc_file_no == -1) - { - if (flags & O_CREAT) - { - set_errno (EROFS); - res = 0; - goto out; - } - else - { - set_errno (ENOENT); - res = 0; - goto out; - } - } - if (flags & O_WRONLY) - { - set_errno (EROFS); - res = 0; - goto out; - } - - fileid = proc_file_no; - if (!fill_filebuf ()) - { - res = 0; - goto out; - } - - if (flags & O_APPEND) - position = filesize; - else - position = 0; - -success: - res = 1; - set_flags ((flags & ~O_TEXT) | O_BINARY); - set_open_status (); -out: - syscall_printf ("%d = fhandler_proc::open (%p, %d)", res, flags, mode); - return res; -} - -bool -fhandler_proc::fill_filebuf () -{ - if (fileid < PROC_LINK_COUNT && proc_tab[fileid].format_func) - { - filesize = proc_tab[fileid].format_func (NULL, filebuf); - return true; - } - return false; -} - -static _off64_t -format_proc_version (void *, char *&destbuf) -{ - struct utsname uts_name; - - uname (&uts_name); - destbuf = (char *) crealloc_abort (destbuf, strlen (uts_name.sysname) - + strlen (uts_name.release) - + strlen (uts_name.version) - + 4); - return __small_sprintf (destbuf, "%s %s %s\n", - uts_name.sysname, uts_name.release, uts_name.version); -} - -static _off64_t -format_proc_loadavg (void *, char *&destbuf) -{ - destbuf = (char *) crealloc_abort (destbuf, 16); - return __small_sprintf (destbuf, "%u.%02u %u.%02u %u.%02u\n", - 0, 0, 0, 0, 0, 0); -} - -static _off64_t -format_proc_meminfo (void *, char *&destbuf) -{ - unsigned long mem_total = 0UL, mem_free = 0UL, swap_total = 0UL, - swap_free = 0UL; - MEMORYSTATUS memory_status; - GlobalMemoryStatus (&memory_status); - mem_total = memory_status.dwTotalPhys; - mem_free = memory_status.dwAvailPhys; - PSYSTEM_PAGEFILE_INFORMATION spi = NULL; - ULONG size = 512; - NTSTATUS ret = STATUS_SUCCESS; - - spi = (PSYSTEM_PAGEFILE_INFORMATION) malloc (size); - if (spi) - { - ret = NtQuerySystemInformation (SystemPagefileInformation, (PVOID) spi, - size, &size); - if (ret == STATUS_INFO_LENGTH_MISMATCH) - { - free (spi); - spi = (PSYSTEM_PAGEFILE_INFORMATION) malloc (size); - if (spi) - ret = NtQuerySystemInformation (SystemPagefileInformation, - (PVOID) spi, size, &size); - } - } - if (!spi || ret || (!ret && GetLastError () == ERROR_PROC_NOT_FOUND)) - { - swap_total = memory_status.dwTotalPageFile - mem_total; - swap_free = memory_status.dwAvailPageFile - mem_total; - } - else - { - PSYSTEM_PAGEFILE_INFORMATION spp = spi; - do - { - swap_total += spp->CurrentSize * getsystempagesize (); - swap_free += (spp->CurrentSize - spp->TotalUsed) - * getsystempagesize (); - } - while (spp->NextEntryOffset - && (spp = (PSYSTEM_PAGEFILE_INFORMATION) - ((char *) spp + spp->NextEntryOffset))); - } - if (spi) - free (spi); - destbuf = (char *) crealloc_abort (destbuf, 512); - return __small_sprintf (destbuf, " total: used: free:\n" - "Mem: %10lu %10lu %10lu\n" - "Swap: %10lu %10lu %10lu\n" - "MemTotal: %10lu kB\n" - "MemFree: %10lu kB\n" - "MemShared: 0 kB\n" - "HighTotal: 0 kB\n" - "HighFree: 0 kB\n" - "LowTotal: %10lu kB\n" - "LowFree: %10lu kB\n" - "SwapTotal: %10lu kB\n" - "SwapFree: %10lu kB\n", - mem_total, mem_total - mem_free, mem_free, - swap_total, swap_total - swap_free, swap_free, - mem_total >> 10, mem_free >> 10, - mem_total >> 10, mem_free >> 10, - swap_total >> 10, swap_free >> 10); -} - -static _off64_t -format_proc_uptime (void *, char *&destbuf) -{ - unsigned long long uptime = 0ULL, idle_time = 0ULL; - NTSTATUS ret; - SYSTEM_TIME_OF_DAY_INFORMATION stodi; - /* Sizeof SYSTEM_PERFORMANCE_INFORMATION on 64 bit systems. It - appears to contain some trailing additional information from - what I can tell after examining the content. - FIXME: It would be nice if this could be verified somehow. */ - const size_t sizeof_spi = sizeof (SYSTEM_PERFORMANCE_INFORMATION) + 16; - PSYSTEM_PERFORMANCE_INFORMATION spi = (PSYSTEM_PERFORMANCE_INFORMATION) - alloca (sizeof_spi); - - if (!system_info.dwNumberOfProcessors) - GetSystemInfo (&system_info); - - ret = NtQuerySystemInformation (SystemTimeOfDayInformation, &stodi, - sizeof stodi, NULL); - if (NT_SUCCESS (ret)) - uptime = (stodi.CurrentTime.QuadPart - stodi.BootTime.QuadPart) / 100000ULL; - else - debug_printf ("NtQuerySystemInformation(SystemTimeOfDayInformation), " - "status %p", ret); - - if (NT_SUCCESS (NtQuerySystemInformation (SystemPerformanceInformation, - spi, sizeof_spi, NULL))) - idle_time = (spi->IdleTime.QuadPart / system_info.dwNumberOfProcessors) - / 100000ULL; - - destbuf = (char *) crealloc_abort (destbuf, 80); - return __small_sprintf (destbuf, "%U.%02u %U.%02u\n", - uptime / 100, long (uptime % 100), - idle_time / 100, long (idle_time % 100)); -} - -static _off64_t -format_proc_stat (void *, char *&destbuf) -{ - unsigned long pages_in = 0UL, pages_out = 0UL, interrupt_count = 0UL, - context_switches = 0UL, swap_in = 0UL, swap_out = 0UL; - time_t boot_time = 0; - NTSTATUS ret; - /* Sizeof SYSTEM_PERFORMANCE_INFORMATION on 64 bit systems. It - appears to contain some trailing additional information from - what I can tell after examining the content. - FIXME: It would be nice if this could be verified somehow. */ - const size_t sizeof_spi = sizeof (SYSTEM_PERFORMANCE_INFORMATION) + 16; - PSYSTEM_PERFORMANCE_INFORMATION spi = (PSYSTEM_PERFORMANCE_INFORMATION) - alloca (sizeof_spi); - SYSTEM_TIME_OF_DAY_INFORMATION stodi; - tmp_pathbuf tp; - - char *buf = tp.c_get (); - char *eobuf = buf; - - if (!system_info.dwNumberOfProcessors) - GetSystemInfo (&system_info); - - SYSTEM_PROCESSOR_TIMES spt[system_info.dwNumberOfProcessors]; - ret = NtQuerySystemInformation (SystemProcessorTimes, (PVOID) spt, - sizeof spt[0] * system_info.dwNumberOfProcessors, NULL); - if (!NT_SUCCESS (ret)) - debug_printf ("NtQuerySystemInformation(SystemProcessorTimes), " - "status %p", ret); - else - { - unsigned long long user_time = 0ULL, kernel_time = 0ULL, idle_time = 0ULL; - for (unsigned long i = 0; i < system_info.dwNumberOfProcessors; i++) - { - kernel_time += (spt[i].KernelTime.QuadPart - spt[i].IdleTime.QuadPart) - * HZ / 10000000ULL; - user_time += spt[i].UserTime.QuadPart * HZ / 10000000ULL; - idle_time += spt[i].IdleTime.QuadPart * HZ / 10000000ULL; - } - - eobuf += __small_sprintf (eobuf, "cpu %U %U %U %U\n", - user_time, 0ULL, kernel_time, idle_time); - user_time = 0ULL, kernel_time = 0ULL, idle_time = 0ULL; - for (unsigned long i = 0; i < system_info.dwNumberOfProcessors; i++) - { - interrupt_count += spt[i].InterruptCount; - kernel_time = (spt[i].KernelTime.QuadPart - spt[i].IdleTime.QuadPart) * HZ / 10000000ULL; - user_time = spt[i].UserTime.QuadPart * HZ / 10000000ULL; - idle_time = spt[i].IdleTime.QuadPart * HZ / 10000000ULL; - eobuf += __small_sprintf (eobuf, "cpu%d %U %U %U %U\n", i, - user_time, 0ULL, kernel_time, idle_time); - } - - ret = NtQuerySystemInformation (SystemPerformanceInformation, - (PVOID) spi, sizeof_spi, NULL); - if (!NT_SUCCESS (ret)) - { - debug_printf ("NtQuerySystemInformation(SystemPerformanceInformation)" - ", status %p", ret); - memset (spi, 0, sizeof_spi); - } - ret = NtQuerySystemInformation (SystemTimeOfDayInformation, - (PVOID) &stodi, - sizeof stodi, NULL); - if (!NT_SUCCESS (ret)) - debug_printf ("NtQuerySystemInformation(SystemTimeOfDayInformation), " - "status %p", ret); - } - if (!NT_SUCCESS (ret)) - return 0; - - pages_in = spi->PagesRead; - pages_out = spi->PagefilePagesWritten + spi->MappedFilePagesWritten; - /* - * Note: there is no distinction made in this structure between pages - * read from the page file and pages read from mapped files, but there - * is such a distinction made when it comes to writing. Goodness knows - * why. The value of swap_in, then, will obviously be wrong but its our - * best guess. - */ - swap_in = spi->PagesRead; - swap_out = spi->PagefilePagesWritten; - context_switches = spi->ContextSwitches; - boot_time = to_time_t ((FILETIME *) &stodi.BootTime.QuadPart); - - eobuf += __small_sprintf (eobuf, "page %u %u\n" - "swap %u %u\n" - "intr %u\n" - "ctxt %u\n" - "btime %u\n", - pages_in, pages_out, - swap_in, swap_out, - interrupt_count, - context_switches, - boot_time); - destbuf = (char *) crealloc_abort (destbuf, eobuf - buf); - memcpy (destbuf, buf, eobuf - buf); - return eobuf - buf; -} - -#define read_value(x,y) \ - do {\ - dwCount = BUFSIZE; \ - if ((dwError = RegQueryValueEx (hKey, x, NULL, &dwType, in_buf.b, &dwCount)), \ - (dwError != ERROR_SUCCESS && dwError != ERROR_MORE_DATA)) \ - { \ - debug_printf ("RegQueryValueEx failed retcode %d", dwError); \ - return 0; \ - } \ - if (dwType != y) \ - { \ - debug_printf ("Value %s had an unexpected type (expected %d, found %d)", y, dwType); \ - return 0; \ - }\ - } while (0) - -#define print(x) \ - do { \ - strcpy (bufptr, x), \ - bufptr += sizeof (x) - 1; \ - } while (0) - -static _off64_t -format_proc_cpuinfo (void *, char *&destbuf) -{ - SYSTEM_INFO siSystemInfo; - HKEY hKey; - DWORD dwError, dwCount, dwType; - DWORD dwOldThreadAffinityMask; - int cpu_number; - const int BUFSIZE = 256; - union - { - BYTE b[BUFSIZE]; - char s[BUFSIZE]; - DWORD d; - unsigned m[13]; - } in_buf; - tmp_pathbuf tp; - - char *buf = tp.c_get (); - char *bufptr = buf; - - GetSystemInfo (&siSystemInfo); - for (cpu_number = 0; ; cpu_number++) - { - if (cpu_number) - print ("\n"); - - __small_sprintf (in_buf.s, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%d", cpu_number); - - if ((dwError = RegOpenKeyEx (HKEY_LOCAL_MACHINE, in_buf.s, 0, KEY_QUERY_VALUE, &hKey)) != ERROR_SUCCESS) - { - if (dwError == ERROR_FILE_NOT_FOUND) - break; - debug_printf ("RegOpenKeyEx failed retcode %d", dwError); - return 0; - } - - dwOldThreadAffinityMask = SetThreadAffinityMask (GetCurrentThread (), 1 << cpu_number); - if (dwOldThreadAffinityMask == 0) - debug_printf ("SetThreadAffinityMask failed %E"); - // I'm not sure whether the thread changes processor immediately - // and I'm not sure whether this function will cause the thread to be rescheduled - low_priority_sleep (0); - - bool has_cpuid = false; - - if (!can_set_flag (0x00040000)) - debug_printf ("386 processor - no cpuid"); - else - { - debug_printf ("486 processor"); - if (can_set_flag (0x00200000)) - { - debug_printf ("processor supports CPUID instruction"); - has_cpuid = true; - } - else - debug_printf ("processor does not support CPUID instruction"); - } - - - if (!has_cpuid) - { - bufptr += __small_sprintf (bufptr, "processor : %d\n", cpu_number); - read_value ("VendorIdentifier", REG_SZ); - bufptr += __small_sprintf (bufptr, "vendor_id : %s\n", in_buf.s); - read_value ("Identifier", REG_SZ); - bufptr += __small_sprintf (bufptr, "identifier : %s\n", in_buf.s); - read_value ("~Mhz", REG_DWORD); - bufptr += __small_sprintf (bufptr, "cpu MHz : %u\n", in_buf.d); - - print ("flags :"); - if (IsProcessorFeaturePresent (PF_3DNOW_INSTRUCTIONS_AVAILABLE)) - print (" 3dnow"); - if (IsProcessorFeaturePresent (PF_COMPARE_EXCHANGE_DOUBLE)) - print (" cx8"); - if (!IsProcessorFeaturePresent (PF_FLOATING_POINT_EMULATED)) - print (" fpu"); - if (IsProcessorFeaturePresent (PF_MMX_INSTRUCTIONS_AVAILABLE)) - print (" mmx"); - if (IsProcessorFeaturePresent (PF_PAE_ENABLED)) - print (" pae"); - if (IsProcessorFeaturePresent (PF_RDTSC_INSTRUCTION_AVAILABLE)) - print (" tsc"); - if (IsProcessorFeaturePresent (PF_XMMI_INSTRUCTIONS_AVAILABLE)) - print (" sse"); - if (IsProcessorFeaturePresent (PF_XMMI64_INSTRUCTIONS_AVAILABLE)) - print (" sse2"); - } - else - { - bufptr += __small_sprintf (bufptr, "processor\t: %d\n", cpu_number); - unsigned maxf, vendor_id[4], unused; - cpuid (&maxf, &vendor_id[0], &vendor_id[2], &vendor_id[1], 0); - maxf &= 0xffff; - vendor_id[3] = 0; - - // vendor identification - bool is_amd = false, is_intel = false; - if (!strcmp ((char*)vendor_id, "AuthenticAMD")) - is_amd = true; - else if (!strcmp ((char*)vendor_id, "GenuineIntel")) - is_intel = true; - - bufptr += __small_sprintf (bufptr, "vendor_id\t: %s\n", - (char *)vendor_id); - read_value ("~Mhz", REG_DWORD); - unsigned cpu_mhz = in_buf.d; - if (maxf >= 1) - { - unsigned features2, features1, extra_info, cpuid_sig; - cpuid (&cpuid_sig, &extra_info, &features2, &features1, 1); - /* unsigned extended_family = (cpuid_sig & 0x0ff00000) >> 20, - extended_model = (cpuid_sig & 0x000f0000) >> 16, - type = (cpuid_sig & 0x00003000) >> 12; */ - unsigned family = (cpuid_sig & 0x00000f00) >> 8, - model = (cpuid_sig & 0x000000f0) >> 4, - stepping = cpuid_sig & 0x0000000f; - /* Not printed on Linux */ - //unsigned brand_id = extra_info & 0x0000000f; - //unsigned cpu_count = (extra_info & 0x00ff0000) >> 16; - unsigned apic_id = (extra_info & 0xff000000) >> 24; - if (family == 15) - family += (cpuid_sig >> 20) & 0xff; - if (family >= 6) - model += ((cpuid_sig >> 16) & 0x0f) << 4; - unsigned maxe = 0; - cpuid (&maxe, &unused, &unused, &unused, 0x80000000); - if (maxe >= 0x80000004) - { - cpuid (&in_buf.m[0], &in_buf.m[1], &in_buf.m[2], - &in_buf.m[3], 0x80000002); - cpuid (&in_buf.m[4], &in_buf.m[5], &in_buf.m[6], - &in_buf.m[7], 0x80000003); - cpuid (&in_buf.m[8], &in_buf.m[9], &in_buf.m[10], - &in_buf.m[11], 0x80000004); - in_buf.m[12] = 0; - } - else - { - // could implement a lookup table here if someone needs it - strcpy (in_buf.s, "unknown"); - } - int cache_size = -1, - tlb_size = -1, - clflush = 64, - cache_alignment = 64; - if (features1 & (1 << 19)) // CLFSH - clflush = ((extra_info >> 8) & 0xff) << 3; - if (is_intel && family == 15) - cache_alignment = clflush * 2; - if (maxe >= 0x80000005) // L1 Cache and TLB Identifiers - { - unsigned data_cache, inst_cache; - cpuid (&unused, &unused, &data_cache, &inst_cache, - 0x80000005); - - cache_size = (inst_cache >> 24) + (data_cache >> 24); - tlb_size = 0; - } - if (maxe >= 0x80000006) // L2 Cache and L2 TLB Identifiers - { - unsigned tlb, l2; - cpuid (&unused, &tlb, &l2, &unused, 0x80000006); - - cache_size = l2 >> 16; - tlb_size = ((tlb >> 16) & 0xfff) + (tlb & 0xfff); - } - bufptr += __small_sprintf (bufptr, "cpu family\t: %d\n" - "model\t\t: %d\n" - "model name\t: %s\n" - "stepping\t: %d\n" - "cpu MHz\t\t: %d\n", - family, - model, - in_buf.s + strspn (in_buf.s, " "), - stepping, - cpu_mhz); - if (cache_size >= 0) - bufptr += __small_sprintf (bufptr, "cache size\t: %d KB\n", - cache_size); - - // Recognize multi-core CPUs - if (is_amd && maxe >= 0x80000008) - { - unsigned core_info; - cpuid (&unused, &unused, &core_info, &unused, 0x80000008); - - int max_cores = 1 + (core_info & 0xff); - if (max_cores > 1) - { - int shift = (core_info >> 12) & 0x0f; - if (!shift) - while ((1 << shift) < max_cores) - ++shift; - int core_id = apic_id & ((1 << shift) - 1); - apic_id >>= shift; - - bufptr += __small_sprintf (bufptr, "physical id\t: %d\n" - "core id\t\t: %d\n" - "cpu cores\t: %d\n", - apic_id, core_id, max_cores); - } - } - // Recognize Intel Hyper-Transport CPUs - else if (is_intel && (features1 & (1 << 28)) && maxf >= 4) - { - /* TODO */ - } - - bufptr += __small_sprintf (bufptr, "fpu\t\t: %s\n" - "fpu_exception\t: %s\n" - "cpuid level\t: %d\n" - "wp\t\t: yes\n", - (features1 & (1 << 0)) ? "yes" : "no", - (features1 & (1 << 0)) ? "yes" : "no", - maxf); - print ("flags\t\t:"); - if (features1 & (1 << 0)) - print (" fpu"); - if (features1 & (1 << 1)) - print (" vme"); - if (features1 & (1 << 2)) - print (" de"); - if (features1 & (1 << 3)) - print (" pse"); - if (features1 & (1 << 4)) - print (" tsc"); - if (features1 & (1 << 5)) - print (" msr"); - if (features1 & (1 << 6)) - print (" pae"); - if (features1 & (1 << 7)) - print (" mce"); - if (features1 & (1 << 8)) - print (" cx8"); - if (features1 & (1 << 9)) - print (" apic"); - if (features1 & (1 << 11)) - print (" sep"); - if (features1 & (1 << 12)) - print (" mtrr"); - if (features1 & (1 << 13)) - print (" pge"); - if (features1 & (1 << 14)) - print (" mca"); - if (features1 & (1 << 15)) - print (" cmov"); - if (features1 & (1 << 16)) - print (" pat"); - if (features1 & (1 << 17)) - print (" pse36"); - if (features1 & (1 << 18)) - print (" pn"); - if (features1 & (1 << 19)) - print (" clflush"); - if (is_intel && features1 & (1 << 21)) - print (" dts"); - if (is_intel && features1 & (1 << 22)) - print (" acpi"); - if (features1 & (1 << 23)) - print (" mmx"); - if (features1 & (1 << 24)) - print (" fxsr"); - if (features1 & (1 << 25)) - print (" sse"); - if (features1 & (1 << 26)) - print (" sse2"); - if (is_intel && (features1 & (1 << 27))) - print (" ss"); - if (features1 & (1 << 28)) - print (" ht"); - if (is_intel) - { - if (features1 & (1 << 29)) - print (" tm"); - if (features1 & (1 << 30)) - print (" ia64"); - if (features1 & (1 << 31)) - print (" pbe"); - } - - if (is_amd && maxe >= 0x80000001) - { - unsigned features; - cpuid (&unused, &unused, &unused, &features, 0x80000001); - - if (features & (1 << 11)) - print (" syscall"); - if (features & (1 << 19)) // Huh? Not in AMD64 specs. - print (" mp"); - if (features & (1 << 20)) - print (" nx"); - if (features & (1 << 22)) - print (" mmxext"); - if (features & (1 << 25)) - print (" fxsr_opt"); - if (features & (1 << 26)) - print (" pdpe1gb"); - if (features & (1 << 27)) - print (" rdtscp"); - if (features & (1 << 29)) - print (" lm"); - if (features & (1 << 30)) // 31th bit is on - print (" 3dnowext"); - if (features & (1 << 31)) // 32th bit (highest) is on - print (" 3dnow"); - } - - if (features2 & (1 << 0)) - print (" pni"); - if (is_intel) - { - if (features2 & (1 << 2)) - print (" dtes64"); - if (features2 & (1 << 3)) - print (" monitor"); - if (features2 & (1 << 4)) - print (" ds_cpl"); - if (features2 & (1 << 5)) - print (" vmx"); - if (features2 & (1 << 6)) - print (" smx"); - if (features2 & (1 << 7)) - print (" est"); - if (features2 & (1 << 8)) - print (" tm2"); - if (features2 & (1 << 9)) - print (" ssse3"); - if (features2 & (1 << 10)) - print (" cid"); - if (features2 & (1 << 12)) - print (" fma"); - } - if (features2 & (1 << 13)) - print (" cx16"); - if (is_intel) - { - if (features2 & (1 << 14)) - print (" xtpr"); - if (features2 & (1 << 15)) - print (" pdcm"); - if (features2 & (1 << 18)) - print (" dca"); - if (features2 & (1 << 19)) - print (" sse4_1"); - if (features2 & (1 << 20)) - print (" sse4_2"); - if (features2 & (1 << 21)) - print (" x2apic"); - if (features2 & (1 << 22)) - print (" movbe"); - if (features2 & (1 << 23)) - print (" popcnt"); - if (features2 & (1 << 25)) - print (" aes"); - if (features2 & (1 << 26)) - print (" xsave"); - if (features2 & (1 << 27)) - print (" osxsave"); - if (features2 & (1 << 28)) - print (" avx"); - } - - if (maxe >= 0x80000001) - { - unsigned features; - cpuid (&unused, &unused, &features, &unused, 0x80000001); - - if (features & (1 << 0)) - print (" lahf_lm"); - if (features & (1 << 1)) - print (" cmp_legacy"); - if (is_amd) - { - if (features & (1 << 2)) - print (" svm"); - if (features & (1 << 3)) - print (" extapic"); - if (features & (1 << 4)) - print (" cr8_legacy"); - if (features & (1 << 5)) - print (" abm"); - if (features & (1 << 6)) - print (" sse4a"); - if (features & (1 << 7)) - print (" misalignsse"); - if (features & (1 << 8)) - print (" 3dnowprefetch"); - if (features & (1 << 9)) - print (" osvw"); - } - if (features & (1 << 10)) - print (" ibs"); - if (is_amd) - { - if (features & (1 << 11)) - print (" sse5"); - if (features & (1 << 12)) - print (" skinit"); - if (features & (1 << 13)) - print (" wdt"); - } - } - - print ("\n"); - - /* TODO: bogomips */ - - if (tlb_size >= 0) - bufptr += __small_sprintf (bufptr, - "TLB size\t: %d 4K pages\n", - tlb_size); - bufptr += __small_sprintf (bufptr, "clflush size\t: %d\n" - "cache_alignment\t: %d\n", - clflush, - cache_alignment); - - if (maxe >= 0x80000008) // Address size - { - unsigned addr_size, phys, virt; - cpuid (&addr_size, &unused, &unused, &unused, 0x80000008); - - phys = addr_size & 0xff; - virt = (addr_size >> 8) & 0xff; - /* Fix an errata on Intel CPUs */ - if (is_intel && family == 15 && model == 3 && stepping == 4) - phys = 36; - bufptr += __small_sprintf (bufptr, "address sizes\t: " - "%u bits physical, " - "%u bits virtual\n", - phys, virt); - } - - if (maxe >= 0x80000007) // advanced power management - { - cpuid (&unused, &unused, &unused, &features2, 0x80000007); - - print ("power management:"); - if (features2 & (1 << 0)) - print (" ts"); - if (features2 & (1 << 1)) - print (" fid"); - if (features2 & (1 << 2)) - print (" vid"); - if (features2 & (1 << 3)) - print (" ttp"); - if (features2 & (1 << 4)) - print (" tm"); - if (features2 & (1 << 5)) - print (" stc"); - if (features2 & (1 << 6)) - print (" 100mhzsteps"); - if (features2 & (1 << 7)) - print (" hwpstate"); - } - } - else - { - bufptr += __small_sprintf (bufptr, "cpu MHz : %d\n" - "fpu : %s\n", - cpu_mhz, - IsProcessorFeaturePresent (PF_FLOATING_POINT_EMULATED) ? "no" : "yes"); - } - } - if (dwOldThreadAffinityMask != 0) - SetThreadAffinityMask (GetCurrentThread (), dwOldThreadAffinityMask); - - RegCloseKey (hKey); - bufptr += __small_sprintf (bufptr, "\n"); - } - - destbuf = (char *) crealloc_abort (destbuf, bufptr - buf); - memcpy (destbuf, buf, bufptr - buf); - return bufptr - buf; -} - -#undef read_value - -static _off64_t -format_proc_partitions (void *, char *&destbuf) -{ - char devname[NAME_MAX + 1]; - OBJECT_ATTRIBUTES attr; - HANDLE dirhdl, devhdl; - IO_STATUS_BLOCK io; - NTSTATUS status; - tmp_pathbuf tp; - - char *buf = tp.c_get (); - char *bufptr = buf; - - /* Open \Device object directory. */ - wchar_t wpath[MAX_PATH] = L"\\Device"; - UNICODE_STRING upath = {14, 16, wpath}; - InitializeObjectAttributes (&attr, &upath, OBJ_CASE_INSENSITIVE, NULL, NULL); - status = NtOpenDirectoryObject (&dirhdl, DIRECTORY_QUERY, &attr); - if (!NT_SUCCESS (status)) - { - debug_printf ("NtOpenDirectoryObject, status %p", status); - return 0; - } - - print ("major minor #blocks name\n\n"); - /* Traverse \Device directory ... */ - PDIRECTORY_BASIC_INFORMATION dbi = (PDIRECTORY_BASIC_INFORMATION) - alloca (640); - BOOLEAN restart = TRUE; - ULONG context = 0; - while (NT_SUCCESS (NtQueryDirectoryObject (dirhdl, dbi, 640, TRUE, restart, - &context, NULL))) - { - restart = FALSE; - sys_wcstombs (devname, NAME_MAX + 1, dbi->ObjectName.Buffer, - dbi->ObjectName.Length / 2); - /* ... and check for a "Harddisk[0-9]*" entry. */ - if (!strncasematch (devname, "Harddisk", 8) - || dbi->ObjectName.Length < 18 - || !isdigit (devname[8])) - continue; - /* Construct path name for partition 0, which is the whole disk, - and try to open. */ - wcscpy (wpath, dbi->ObjectName.Buffer); - wcscpy (wpath + dbi->ObjectName.Length / 2, L"\\Partition0"); - upath.Length = 22 + dbi->ObjectName.Length; - upath.MaximumLength = upath.Length + 2; - InitializeObjectAttributes (&attr, &upath, OBJ_CASE_INSENSITIVE, - dirhdl, NULL); - status = NtOpenFile (&devhdl, READ_CONTROL | FILE_READ_DATA, &attr, &io, - FILE_SHARE_VALID_FLAGS, 0); - if (!NT_SUCCESS (status)) - { - /* Retry with READ_CONTROL only for non-privileged users. This - at least prints the Partition0 info, but it doesn't allow access - to the drive's layout information. It beats me, though, why - a non-privileged user shouldn't get read access to the drive - layout information. */ - status = NtOpenFile (&devhdl, READ_CONTROL, &attr, &io, - FILE_SHARE_VALID_FLAGS, 0); - if (!NT_SUCCESS (status)) - { - debug_printf ("NtOpenFile(%s), status %p", devname, status); - continue; - } - } - - /* Use a buffer since some ioctl buffers aren't fixed size. */ - char buf[256]; - PARTITION_INFORMATION *pi = NULL; - PARTITION_INFORMATION_EX *pix = NULL; - DISK_GEOMETRY *dg = NULL; - DWORD bytes; - unsigned long drive_number = strtoul (devname + 8, NULL, 10); - unsigned long long size; - - if (wincap.has_disk_ex_ioctls () - && DeviceIoControl (devhdl, IOCTL_DISK_GET_PARTITION_INFO_EX, - NULL, 0, buf, 256, &bytes, NULL)) - { - pix = (PARTITION_INFORMATION_EX *) buf; - size = pix->PartitionLength.QuadPart; - } - else if (DeviceIoControl (devhdl, IOCTL_DISK_GET_PARTITION_INFO, - NULL, 0, buf, 256, &bytes, NULL)) - { - pi = (PARTITION_INFORMATION *) buf; - size = pi->PartitionLength.QuadPart; - } - else if (DeviceIoControl (devhdl, IOCTL_DISK_GET_DRIVE_GEOMETRY, - NULL, 0, buf, 256, &bytes, NULL)) - { - dg = (DISK_GEOMETRY *) buf; - size = (unsigned long long) dg->Cylinders.QuadPart - * dg->TracksPerCylinder - * dg->SectorsPerTrack - * dg->BytesPerSector; - } - else - size = 0; - if (!pi && !pix && !dg) - debug_printf ("DeviceIoControl %E"); - else - { - device dev; - dev.parsedisk (drive_number, 0); - bufptr += __small_sprintf (bufptr, "%5d %5d %9U %s\n", - dev.major, dev.minor, - size >> 10, dev.name + 5); - } - size_t buf_size = 8192; - while (true) - { - char buf[buf_size]; - if (DeviceIoControl (devhdl, IOCTL_DISK_GET_DRIVE_LAYOUT, - NULL, 0, (DRIVE_LAYOUT_INFORMATION *) buf, - buf_size, &bytes, NULL)) - /* fall through */; - else if (GetLastError () == ERROR_INSUFFICIENT_BUFFER) - { - buf_size *= 2; - continue; - } - else - { - debug_printf ("DeviceIoControl %E"); - break; - } - DRIVE_LAYOUT_INFORMATION *dli = (DRIVE_LAYOUT_INFORMATION *) buf; - for (unsigned part = 0; part < dli->PartitionCount; part++) - { - if (!dli->PartitionEntry[part].PartitionLength.QuadPart - || !dli->PartitionEntry[part].RecognizedPartition) - continue; - device dev; - dev.parsedisk (drive_number, - dli->PartitionEntry[part].PartitionNumber); - size = dli->PartitionEntry[part].PartitionLength.QuadPart >> 10; - bufptr += __small_sprintf (bufptr, "%5d %5d %9U %s\n", - dev.major, dev.minor, - size, dev.name + 5); - } - break; - } - NtClose (devhdl); - } - NtClose (dirhdl); - - destbuf = (char *) crealloc_abort (destbuf, bufptr - buf); - memcpy (destbuf, buf, bufptr - buf); - return bufptr - buf; -} - -static _off64_t -format_proc_self (void *, char *&destbuf) -{ - destbuf = (char *) crealloc_abort (destbuf, 16); - return __small_sprintf (destbuf, "%d", getpid ()); -} - -static _off64_t -format_proc_mounts (void *, char *&destbuf) -{ - destbuf = (char *) crealloc_abort (destbuf, sizeof ("self/mounts")); - return __small_sprintf (destbuf, "self/mounts"); -} - -#undef print diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc deleted file mode 100644 index fa8aff7c6..000000000 --- a/winsup/cygwin/fhandler_process.cc +++ /dev/null @@ -1,1076 +0,0 @@ -/* fhandler_process.cc: fhandler for /proc/ virtual filesystem - - Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "fhandler_virtual.h" -#include "pinfo.h" -#include "shared_info.h" -#include "dtable.h" -#include "cygheap.h" -#include "ntdll.h" -#include "cygtls.h" -#include "pwdgrp.h" -#include "tls_pbuf.h" -#include -#include -#include - -#define _COMPILING_NEWLIB -#include - -static _off64_t format_process_maps (void *, char *&); -static _off64_t format_process_stat (void *, char *&); -static _off64_t format_process_status (void *, char *&); -static _off64_t format_process_statm (void *, char *&); -static _off64_t format_process_winexename (void *, char *&); -static _off64_t format_process_winpid (void *, char *&); -static _off64_t format_process_exename (void *, char *&); -static _off64_t format_process_root (void *, char *&); -static _off64_t format_process_cwd (void *, char *&); -static _off64_t format_process_cmdline (void *, char *&); -static _off64_t format_process_ppid (void *, char *&); -static _off64_t format_process_uid (void *, char *&); -static _off64_t format_process_pgid (void *, char *&); -static _off64_t format_process_sid (void *, char *&); -static _off64_t format_process_gid (void *, char *&); -static _off64_t format_process_ctty (void *, char *&); -static _off64_t format_process_fd (void *, char *&); -static _off64_t format_process_mounts (void *, char *&); - -static const virt_tab_t process_tab[] = -{ - { ".", FH_PROCESS, virt_directory, NULL }, - { "..", FH_PROCESS, virt_directory, NULL }, - { "ppid", FH_PROCESS, virt_file, format_process_ppid }, - { "winpid", FH_PROCESS, virt_file, format_process_winpid }, - { "winexename", FH_PROCESS, virt_file, format_process_winexename }, - { "status", FH_PROCESS, virt_file, format_process_status }, - { "uid", FH_PROCESS, virt_file, format_process_uid }, - { "gid", FH_PROCESS, virt_file, format_process_gid }, - { "pgid", FH_PROCESS, virt_file, format_process_pgid }, - { "sid", FH_PROCESS, virt_file, format_process_sid }, - { "ctty", FH_PROCESS, virt_file, format_process_ctty }, - { "stat", FH_PROCESS, virt_file, format_process_stat }, - { "statm", FH_PROCESS, virt_file, format_process_statm }, - { "cmdline", FH_PROCESS, virt_file, format_process_cmdline }, - { "maps", FH_PROCESS, virt_file, format_process_maps }, - { "fd", FH_PROCESSFD, virt_directory, format_process_fd }, - { "exename", FH_PROCESS, virt_file, format_process_exename }, - { "root", FH_PROCESS, virt_symlink, format_process_root }, - { "exe", FH_PROCESS, virt_symlink, format_process_exename }, - { "cwd", FH_PROCESS, virt_symlink, format_process_cwd }, - { "mounts", FH_PROCESS, virt_file, format_process_mounts }, - { NULL, 0, virt_none, NULL } -}; - -static const int PROCESS_LINK_COUNT = - (sizeof (process_tab) / sizeof (virt_tab_t)) - 1; - -static int get_process_state (DWORD dwProcessId); -static bool get_mem_values (DWORD dwProcessId, unsigned long *vmsize, - unsigned long *vmrss, unsigned long *vmtext, - unsigned long *vmdata, unsigned long *vmlib, - unsigned long *vmshare); - -/* Returns 0 if path doesn't exist, >0 if path is a directory, - * -1 if path is a file, -2 if path is a symlink, -3 if path is a pipe, - * -4 if path is a socket. - */ -int -fhandler_process::exists () -{ - const char *path = get_name (); - debug_printf ("exists (%s)", path); - path += proc_len + 1; - while (*path != 0 && !isdirsep (*path)) - path++; - if (*path == 0) - return 2; - - for (int i = 0; process_tab[i].name; i++) - { - if (!strcmp (path + 1, process_tab[i].name)) - { - fileid = i; - return process_tab[i].type; - } - if (process_tab[i].type == virt_directory - && !strncmp (path + 1, process_tab[i].name, - strlen (process_tab[i].name)) - && path[1 + strlen (process_tab[i].name)] == '/') - { - fileid = i; - if (fill_filebuf ()) - return virt_symlink; - /* Check for nameless device entries. */ - path = strrchr (path, '/'); - if (path && *++path) - { - if (!strncmp (path, "pipe:[", 6)) - return virt_pipe; - else if (!strncmp (path, "socket:[", 8)) - return virt_socket; - } - } - } - return virt_none; -} - -fhandler_process::fhandler_process (): - fhandler_proc () -{ -} - -int -fhandler_process::fstat (struct __stat64 *buf) -{ - const char *path = get_name (); - int file_type = exists (); - fhandler_base::fstat (buf); - path += proc_len + 1; - pid = atoi (path); - pinfo p (pid); - if (!p) - { - set_errno (ENOENT); - return -1; - } - - buf->st_mode &= ~_IFMT & NO_W; - - switch (file_type) - { - case virt_none: - set_errno (ENOENT); - return -1; - case virt_directory: - case virt_rootdir: - buf->st_ctime = buf->st_mtime = buf->st_birthtime = p->start_time; - buf->st_ctim.tv_nsec = buf->st_mtim.tv_nsec - = buf->st_birthtim.tv_nsec = 0; - time_as_timestruc_t (&buf->st_atim); - buf->st_uid = p->uid; - buf->st_gid = p->gid; - buf->st_mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH; - if (file_type == 1) - buf->st_nlink = 2; - else - buf->st_nlink = 3; - return 0; - case virt_symlink: - buf->st_uid = p->uid; - buf->st_gid = p->gid; - buf->st_mode = S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO; - return 0; - case virt_pipe: - buf->st_uid = p->uid; - buf->st_gid = p->gid; - buf->st_mode = S_IFIFO | S_IRUSR | S_IWUSR; - return 0; - case virt_socket: - buf->st_uid = p->uid; - buf->st_gid = p->gid; - buf->st_mode = S_IFSOCK | S_IRUSR | S_IWUSR; - return 0; - case virt_file: - default: - buf->st_uid = p->uid; - buf->st_gid = p->gid; - buf->st_mode |= S_IFREG | S_IRUSR | S_IRGRP | S_IROTH; - return 0; - } -} - -DIR * -fhandler_process::opendir (int fd) -{ - DIR *dir = fhandler_virtual::opendir (fd); - if (dir && process_tab[fileid].fhandler == FH_PROCESSFD) - fill_filebuf (); - return dir; -} - -int -fhandler_process::readdir (DIR *dir, dirent *de) -{ - int res = ENMFILE; - if (process_tab[fileid].fhandler == FH_PROCESSFD) - { - if (dir->__d_position >= 2 + filesize / sizeof (int)) - goto out; - } - else if (dir->__d_position >= PROCESS_LINK_COUNT) - goto out; - if (process_tab[fileid].fhandler == FH_PROCESSFD && dir->__d_position > 1) - { - int *p = (int *) filebuf; - __small_sprintf (de->d_name, "%d", p[dir->__d_position++ - 2]); - } - else - strcpy (de->d_name, process_tab[dir->__d_position++].name); - dir->__flags |= dirent_saw_dot | dirent_saw_dot_dot; - res = 0; -out: - syscall_printf ("%d = readdir (%p, %p) (%s)", res, dir, de, de->d_name); - return res; -} - -int -fhandler_process::open (int flags, mode_t mode) -{ - int process_file_no = -1; - - int res = fhandler_virtual::open (flags, mode); - if (!res) - goto out; - - nohandle (true); - - const char *path; - path = get_name () + proc_len + 1; - pid = atoi (path); - while (*path != 0 && !isdirsep (*path)) - path++; - - if (*path == 0) - { - if ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) - { - set_errno (EEXIST); - res = 0; - goto out; - } - else if (flags & O_WRONLY) - { - set_errno (EISDIR); - res = 0; - goto out; - } - else - { - flags |= O_DIROPEN; - goto success; - } - } - - process_file_no = -1; - for (int i = 0; process_tab[i].name; i++) - { - if (path_prefix_p (process_tab[i].name, path + 1, - strlen (process_tab[i].name), false)) - process_file_no = i; - } - if (process_file_no == -1) - { - if (flags & O_CREAT) - { - set_errno (EROFS); - res = 0; - goto out; - } - else - { - set_errno (ENOENT); - res = 0; - goto out; - } - } - if (process_tab[process_file_no].fhandler == FH_PROCESSFD) - { - flags |= O_DIROPEN; - goto success; - } - if (flags & O_WRONLY) - { - set_errno (EROFS); - res = 0; - goto out; - } - - fileid = process_file_no; - if (!fill_filebuf ()) - { - res = 0; - goto out; - } - - if (flags & O_APPEND) - position = filesize; - else - position = 0; - -success: - res = 1; - set_flags ((flags & ~O_TEXT) | O_BINARY); - set_open_status (); -out: - syscall_printf ("%d = fhandler_proc::open (%p, %d)", res, flags, mode); - return res; -} - -struct process_fd_t { - const char *path; - _pinfo *p; -}; - -bool -fhandler_process::fill_filebuf () -{ - const char *path; - path = get_name () + proc_len + 1; - if (!pid) - pid = atoi (path); - - pinfo p (pid); - - if (!p) - { - set_errno (ENOENT); - return false; - } - - if (process_tab[fileid].format_func) - { - if (process_tab[fileid].fhandler == FH_PROCESSFD) - { - process_fd_t fd = { path, p }; - filesize = process_tab[fileid].format_func (&fd, filebuf); - } - else - filesize = process_tab[fileid].format_func (p, filebuf); - return !filesize ? false : true; - } - return false; -} - -static _off64_t -format_process_fd (void *data, char *&destbuf) -{ - _pinfo *p = ((process_fd_t *) data)->p; - const char *path = ((process_fd_t *) data)->path; - size_t fs = 0; - char *fdp = strrchr (path, '/'); - - if (!fdp || *++fdp == 'f') /* The "fd" directory itself. */ - { - if (destbuf) - cfree (destbuf); - destbuf = p->fds (fs); - } - else - { - if (destbuf) - cfree (destbuf); - int fd = atoi (fdp); - if (fd < 0 || (fd == 0 && !isdigit (*fdp))) - { - set_errno (ENOENT); - return 0; - } - destbuf = p->fd (fd, fs); - if (!destbuf || !*destbuf) - { - set_errno (ENOENT); - return 0; - } - } - return fs; -} - -static _off64_t -format_process_ppid (void *data, char *&destbuf) -{ - _pinfo *p = (_pinfo *) data; - destbuf = (char *) crealloc_abort (destbuf, 40); - return __small_sprintf (destbuf, "%d\n", p->ppid); -} - -static _off64_t -format_process_uid (void *data, char *&destbuf) -{ - _pinfo *p = (_pinfo *) data; - destbuf = (char *) crealloc_abort (destbuf, 40); - return __small_sprintf (destbuf, "%d\n", p->uid); -} - -static _off64_t -format_process_pgid (void *data, char *&destbuf) -{ - _pinfo *p = (_pinfo *) data; - destbuf = (char *) crealloc_abort (destbuf, 40); - return __small_sprintf (destbuf, "%d\n", p->pgid); -} - -static _off64_t -format_process_sid (void *data, char *&destbuf) -{ - _pinfo *p = (_pinfo *) data; - destbuf = (char *) crealloc_abort (destbuf, 40); - return __small_sprintf (destbuf, "%d\n", p->sid); -} - -static _off64_t -format_process_gid (void *data, char *&destbuf) -{ - _pinfo *p = (_pinfo *) data; - destbuf = (char *) crealloc_abort (destbuf, 40); - return __small_sprintf (destbuf, "%d\n", p->gid); -} - -static _off64_t -format_process_ctty (void *data, char *&destbuf) -{ - _pinfo *p = (_pinfo *) data; - destbuf = (char *) crealloc_abort (destbuf, 40); - return __small_sprintf (destbuf, "%d\n", p->ctty); -} - -static _off64_t -format_process_root (void *data, char *&destbuf) -{ - _pinfo *p = (_pinfo *) data; - size_t fs; - - if (destbuf) - { - cfree (destbuf); - destbuf = NULL; - } - destbuf = p->root (fs); - if (!destbuf || !*destbuf) - { - destbuf = cstrdup (""); - fs = strlen (destbuf) + 1; - } - return fs; -} - -static _off64_t -format_process_cwd (void *data, char *&destbuf) -{ - _pinfo *p = (_pinfo *) data; - size_t fs; - - if (destbuf) - { - cfree (destbuf); - destbuf = NULL; - } - destbuf = p->cwd (fs); - if (!destbuf || !*destbuf) - { - destbuf = cstrdup (""); - fs = strlen (destbuf) + 1; - } - return fs; -} - -static _off64_t -format_process_cmdline (void *data, char *&destbuf) -{ - _pinfo *p = (_pinfo *) data; - size_t fs; - - if (destbuf) - { - cfree (destbuf); - destbuf = NULL; - } - destbuf = p->cmdline (fs); - if (!destbuf || !*destbuf) - { - destbuf = cstrdup (""); - fs = strlen (destbuf) + 1; - } - return fs; -} - -static _off64_t -format_process_exename (void *data, char *&destbuf) -{ - _pinfo *p = (_pinfo *) data; - int len; - tmp_pathbuf tp; - - char *buf = tp.c_get (); - if (p->process_state & PID_EXITED) - stpcpy (buf, ""); - else - { - mount_table->conv_to_posix_path (p->progname, buf, 1); - len = strlen (buf); - if (len > 4) - { - char *s = buf + len - 4; - if (ascii_strcasematch (s, ".exe")) - *s = 0; - } - } - destbuf = (char *) crealloc_abort (destbuf, (len = strlen (buf)) + 1); - stpcpy (destbuf, buf); - return len; -} - -static _off64_t -format_process_winpid (void *data, char *&destbuf) -{ - _pinfo *p = (_pinfo *) data; - destbuf = (char *) crealloc_abort (destbuf, 20); - return __small_sprintf (destbuf, "%d\n", p->dwProcessId); -} - -static _off64_t -format_process_winexename (void *data, char *&destbuf) -{ - _pinfo *p = (_pinfo *) data; - int len = strlen (p->progname); - destbuf = (char *) crealloc_abort (destbuf, len + 2); - strcpy (destbuf, p->progname); - destbuf[len] = '\n'; - return len + 1; -} - -static _off64_t -format_process_maps (void *data, char *&destbuf) -{ - _pinfo *p = (_pinfo *) data; - HANDLE proc = OpenProcess (PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, - FALSE, - p->dwProcessId); - if (!proc) - return 0; - - _off64_t len = 0; - HMODULE *modules; - DWORD needed, i; - DWORD_PTR wset_size; - DWORD_PTR *workingset = NULL; - MODULEINFO info; - - tmp_pathbuf tp; - PWCHAR modname = tp.w_get (); - char *posix_modname = tp.c_get (); - size_t maxsize = 0; - - if (destbuf) - { - cfree (destbuf); - destbuf = NULL; - } - if (!EnumProcessModules (proc, NULL, 0, &needed)) - { - __seterrno (); - len = -1; - goto out; - } - modules = (HMODULE*) alloca (needed); - if (!EnumProcessModules (proc, modules, needed, &needed)) - { - __seterrno (); - len = -1; - goto out; - } - - QueryWorkingSet (proc, (void *) &wset_size, sizeof wset_size); - if (GetLastError () == ERROR_BAD_LENGTH) - { - workingset = (DWORD_PTR *) alloca (sizeof (DWORD_PTR) * ++wset_size); - if (!QueryWorkingSet (proc, (void *) workingset, - sizeof (DWORD_PTR) * wset_size)) - workingset = NULL; - } - for (i = 0; i < needed / sizeof (HMODULE); i++) - if (GetModuleInformation (proc, modules[i], &info, sizeof info) - && GetModuleFileNameExW (proc, modules[i], modname, NT_MAX_PATH)) - { - char access[5]; - strcpy (access, "r--p"); - struct __stat64 st; - if (mount_table->conv_to_posix_path (modname, posix_modname, 0)) - sys_wcstombs (posix_modname, NT_MAX_PATH, modname); - if (stat64 (posix_modname, &st)) - { - st.st_dev = 0; - st.st_ino = 0; - } - size_t newlen = strlen (posix_modname) + 62; - if (len + newlen >= maxsize) - destbuf = (char *) crealloc_abort (destbuf, - maxsize += roundup2 (newlen, 2048)); - if (workingset) - for (unsigned i = 1; i <= wset_size; ++i) - { - DWORD_PTR addr = workingset[i] & 0xfffff000UL; - if ((char *)addr >= info.lpBaseOfDll - && (char *)addr < (char *)info.lpBaseOfDll + info.SizeOfImage) - { - access[0] = (workingset[i] & 0x5) ? 'r' : '-'; - access[1] = (workingset[i] & 0x4) ? 'w' : '-'; - access[2] = (workingset[i] & 0x2) ? 'x' : '-'; - access[3] = (workingset[i] & 0x100) ? 's' : 'p'; - } - } - int written = __small_sprintf (destbuf + len, - "%08lx-%08lx %s %08lx %04x:%04x %U ", - info.lpBaseOfDll, - (unsigned long)info.lpBaseOfDll - + info.SizeOfImage, - access, - info.EntryPoint, - st.st_dev >> 16, - st.st_dev & 0xffff, - st.st_ino); - while (written < 62) - destbuf[len + written++] = ' '; - len += written; - len += __small_sprintf (destbuf + len, "%s\n", posix_modname); - } -out: - CloseHandle (proc); - return len; -} - -static _off64_t -format_process_stat (void *data, char *&destbuf) -{ - _pinfo *p = (_pinfo *) data; - char cmd[NAME_MAX + 1]; - int state = 'R'; - unsigned long fault_count = 0UL, - utime = 0UL, stime = 0UL, - start_time = 0UL, - vmsize = 0UL, vmrss = 0UL, vmmaxrss = 0UL; - int priority = 0; - if (p->process_state & PID_EXITED) - strcpy (cmd, ""); - else - { - char *last_slash = strrchr (p->progname, '\\'); - strcpy (cmd, last_slash ? last_slash + 1 : p->progname); - int len = strlen (cmd); - if (len > 4) - { - char *s = cmd + len - 4; - if (ascii_strcasematch (s, ".exe")) - *s = 0; - } - } - /* - * Note: under Windows, a _process_ is always running - it's only _threads_ - * that get suspended. Therefore the default state is R (runnable). - */ - if (p->process_state & PID_EXITED) - state = 'Z'; - else if (p->process_state & PID_STOPPED) - state = 'T'; - else - state = get_process_state (p->dwProcessId); - start_time = (GetTickCount () / 1000 - time (NULL) + p->start_time) * HZ; - - NTSTATUS ret; - HANDLE hProcess; - VM_COUNTERS vmc; - KERNEL_USER_TIMES put; - PROCESS_BASIC_INFORMATION pbi; - QUOTA_LIMITS ql; - SYSTEM_TIME_OF_DAY_INFORMATION stodi; - SYSTEM_PROCESSOR_TIMES spt; - hProcess = OpenProcess (PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, - FALSE, p->dwProcessId); - if (hProcess != NULL) - { - ret = NtQueryInformationProcess (hProcess, - ProcessVmCounters, - (PVOID) &vmc, - sizeof vmc, NULL); - if (ret == STATUS_SUCCESS) - ret = NtQueryInformationProcess (hProcess, - ProcessTimes, - (PVOID) &put, - sizeof put, NULL); - if (ret == STATUS_SUCCESS) - ret = NtQueryInformationProcess (hProcess, - ProcessBasicInformation, - (PVOID) &pbi, - sizeof pbi, NULL); - if (ret == STATUS_SUCCESS) - ret = NtQueryInformationProcess (hProcess, - ProcessQuotaLimits, - (PVOID) &ql, - sizeof ql, NULL); - CloseHandle (hProcess); - } - else - { - DWORD error = GetLastError (); - __seterrno_from_win_error (error); - debug_printf ("OpenProcess: ret %d", error); - return 0; - } - if (ret == STATUS_SUCCESS) - ret = NtQuerySystemInformation (SystemTimeOfDayInformation, - (PVOID) &stodi, - sizeof stodi, NULL); - if (ret == STATUS_SUCCESS) - ret = NtQuerySystemInformation (SystemProcessorTimes, - (PVOID) &spt, - sizeof spt, NULL); - if (ret != STATUS_SUCCESS) - { - __seterrno_from_nt_status (ret); - debug_printf ("NtQueryInformationProcess: ret %d, Dos(ret) %E", ret); - return 0; - } - fault_count = vmc.PageFaultCount; - utime = put.UserTime.QuadPart * HZ / 10000000ULL; - stime = put.KernelTime.QuadPart * HZ / 10000000ULL; -#if 0 - if (stodi.CurrentTime.QuadPart > put.CreateTime.QuadPart) - start_time = (spt.KernelTime.QuadPart + spt.UserTime.QuadPart - - stodi.CurrentTime.QuadPart + put.CreateTime.QuadPart) * HZ / 10000000ULL; - else - /* - * sometimes stodi.CurrentTime is a bit behind - * Note: some older versions of procps are broken and can't cope - * with process start times > time(NULL). - */ - start_time = (spt.KernelTme.QuadPart + spt.UserTime.QuadPart) * HZ / 10000000ULL; -#endif - priority = pbi.BasePriority; - unsigned page_size = getsystempagesize (); - vmsize = vmc.PagefileUsage; - vmrss = vmc.WorkingSetSize / page_size; - vmmaxrss = ql.MaximumWorkingSetSize / page_size; - - destbuf = (char *) crealloc_abort (destbuf, strlen (cmd) + 320); - return __small_sprintf (destbuf, "%d (%s) %c " - "%d %d %d %d %d " - "%lu %lu %lu %lu %lu %lu %lu " - "%ld %ld %ld %ld %ld %ld " - "%lu %lu " - "%ld " - "%lu", - p->pid, cmd, - state, - p->ppid, p->pgid, p->sid, makedev (FH_TTYS, p->ctty), - -1, 0, fault_count, fault_count, 0, 0, utime, stime, - utime, stime, priority, 0, 0, 0, - start_time, vmsize, - vmrss, vmmaxrss - ); -} - -static _off64_t -format_process_status (void *data, char *&destbuf) -{ - _pinfo *p = (_pinfo *) data; - char cmd[NAME_MAX + 1]; - int state = 'R'; - const char *state_str = "unknown"; - unsigned long vmsize = 0UL, vmrss = 0UL, vmdata = 0UL, vmlib = 0UL, vmtext = 0UL, - vmshare = 0UL; - if (p->process_state & PID_EXITED) - strcpy (cmd, ""); - else - { - char *last_slash = strrchr (p->progname, '\\'); - strcpy (cmd, last_slash ? last_slash + 1 : p->progname); - int len = strlen (cmd); - if (len > 4) - { - char *s = cmd + len - 4; - if (ascii_strcasematch (s, ".exe")) - *s = 0; - } - } - /* - * Note: under Windows, a _process_ is always running - it's only _threads_ - * that get suspended. Therefore the default state is R (runnable). - */ - if (p->process_state & PID_EXITED) - state = 'Z'; - else if (p->process_state & PID_STOPPED) - state = 'T'; - else - state = get_process_state (p->dwProcessId); - switch (state) - { - case 'O': - state_str = "running"; - break; - case 'D': - case 'S': - state_str = "sleeping"; - break; - case 'R': - state_str = "runnable"; - break; - case 'Z': - state_str = "zombie"; - break; - case 'T': - state_str = "stopped"; - break; - } - if (!get_mem_values (p->dwProcessId, &vmsize, &vmrss, &vmtext, &vmdata, - &vmlib, &vmshare)) - return 0; - unsigned page_size = getsystempagesize (); - vmsize *= page_size; vmrss *= page_size; vmdata *= page_size; - vmtext *= page_size; vmlib *= page_size; - // The real uid value for *this* process is stored at cygheap->user.real_uid - // but we can't get at the real uid value for any other process, so - // just fake it as p->uid. Similar for p->gid. - destbuf = (char *) crealloc_abort (destbuf, strlen (cmd) + 320); - return __small_sprintf (destbuf, "Name:\t%s\n" - "State:\t%c (%s)\n" - "Tgid:\t%d\n" - "Pid:\t%d\n" - "PPid:\t%d\n" - "Uid:\t%d %d %d %d\n" - "Gid:\t%d %d %d %d\n" - "VmSize:\t%8d kB\n" - "VmLck:\t%8d kB\n" - "VmRSS:\t%8d kB\n" - "VmData:\t%8d kB\n" - "VmStk:\t%8d kB\n" - "VmExe:\t%8d kB\n" - "VmLib:\t%8d kB\n" - "SigPnd:\t%016x\n" - "SigBlk:\t%016x\n" - "SigIgn:\t%016x\n", - cmd, - state, state_str, - p->pgid, - p->pid, - p->ppid, - p->uid, p->uid, p->uid, p->uid, - p->gid, p->gid, p->gid, p->gid, - vmsize >> 10, 0, vmrss >> 10, vmdata >> 10, 0, - vmtext >> 10, vmlib >> 10, - 0, 0, _my_tls.sigmask - ); -} - -static _off64_t -format_process_statm (void *data, char *&destbuf) -{ - _pinfo *p = (_pinfo *) data; - unsigned long vmsize = 0UL, vmrss = 0UL, vmtext = 0UL, vmdata = 0UL, - vmlib = 0UL, vmshare = 0UL; - if (!get_mem_values (p->dwProcessId, &vmsize, &vmrss, &vmtext, &vmdata, - &vmlib, &vmshare)) - return 0; - destbuf = (char *) crealloc_abort (destbuf, 96); - return __small_sprintf (destbuf, "%ld %ld %ld %ld %ld %ld %ld", - vmsize, vmrss, vmshare, vmtext, vmlib, vmdata, 0); -} - -extern "C" { - FILE *setmntent (const char *, const char *); - struct mntent *getmntent (FILE *); -}; - -static _off64_t -format_process_mounts (void *data, char *&destbuf) -{ - _pinfo *p = (_pinfo *) data; - user_info *u_shared = NULL; - HANDLE u_hdl = NULL; - _off64_t len = 0; - struct mntent *mnt; - - if (p->pid != myself->pid) - { - WCHAR sid_string[UNLEN + 1] = L""; /* Large enough for SID */ - shared_locations sl = SH_JUSTOPEN; - - cygsid p_sid; - - if (!p_sid.getfrompw (internal_getpwuid (p->uid))) - return 0; - p_sid.string (sid_string); - u_shared = (user_info *) open_shared (sid_string, USER_VERSION, u_hdl, - sizeof (user_info), sl, - &sec_none_nih); - if (!u_shared) - return 0; - } - else - u_shared = user_shared; - - /* Store old value of _my_tls.locals here. */ - int iteration = _my_tls.locals.iteration; - unsigned available_drives = _my_tls.locals.available_drives; - /* This reinitializes the above values in _my_tls. */ - setmntent (NULL, NULL); - while ((mnt = getmntent (NULL))) - { - destbuf = (char *) crealloc_abort (destbuf, len - + strlen (mnt->mnt_fsname) - + strlen (mnt->mnt_dir) - + strlen (mnt->mnt_type) - + strlen (mnt->mnt_opts) - + 28); - len += __small_sprintf (destbuf + len, "%s %s %s %s %d %d\n", - mnt->mnt_fsname, mnt->mnt_dir, mnt->mnt_type, - mnt->mnt_opts, mnt->mnt_freq, mnt->mnt_passno); - } - /* Restore old value of _my_tls.locals here. */ - _my_tls.locals.iteration = iteration; - _my_tls.locals.available_drives = available_drives; - - if (u_hdl) /* Only not-NULL if open_shared has been called. */ - { - UnmapViewOfFile (u_shared); - CloseHandle (u_hdl); - } - return len; -} - -static int -get_process_state (DWORD dwProcessId) -{ - /* - * This isn't really heavy magic - just go through the processes' - * threads one by one and return a value accordingly - * Errors are silently ignored. - */ - NTSTATUS ret; - SYSTEM_PROCESSES *sp; - ULONG n = 0x1000; - PULONG p = new ULONG[n]; - int state =' '; - while (STATUS_INFO_LENGTH_MISMATCH == - (ret = NtQuerySystemInformation (SystemProcessesAndThreadsInformation, - (PVOID) p, - n * sizeof *p, NULL))) - delete [] p, p = new ULONG[n *= 2]; - if (ret != STATUS_SUCCESS) - { - debug_printf ("NtQuerySystemInformation: ret %d, Dos(ret) %d", - ret, RtlNtStatusToDosError (ret)); - goto out; - } - state = 'Z'; - sp = (SYSTEM_PROCESSES *) p; - for (;;) - { - if (sp->ProcessId == dwProcessId) - { - SYSTEM_THREADS *st; - if (wincap.has_process_io_counters ()) - /* - * Windows 2000 and XP have an extra member in SYSTEM_PROCESSES - * which means the offset of the first SYSTEM_THREADS entry is - * different on these operating systems compared to NT 4. - */ - st = &sp->Threads[0]; - else - /* - * 136 is the offset of the first SYSTEM_THREADS entry on - * Windows NT 4. - */ - st = (SYSTEM_THREADS *) ((char *) sp + 136); - state = 'S'; - for (unsigned i = 0; i < sp->ThreadCount; i++) - { - if (st->State == StateRunning || - st->State == StateReady) - { - state = 'R'; - goto out; - } - st++; - } - break; - } - if (!sp->NextEntryDelta) - break; - sp = (SYSTEM_PROCESSES *) ((char *) sp + sp->NextEntryDelta); - } -out: - delete [] p; - return state; -} - -static bool -get_mem_values (DWORD dwProcessId, unsigned long *vmsize, unsigned long *vmrss, - unsigned long *vmtext, unsigned long *vmdata, - unsigned long *vmlib, unsigned long *vmshare) -{ - bool res = true; - NTSTATUS ret; - HANDLE hProcess; - VM_COUNTERS vmc; - MEMORY_WORKING_SET_LIST *mwsl; - ULONG n = 0x1000, length; - PULONG p = (PULONG) malloc (sizeof (ULONG) * n); - unsigned page_size = getsystempagesize (); - hProcess = OpenProcess (PROCESS_QUERY_INFORMATION, - FALSE, dwProcessId); - if (hProcess == NULL) - { - DWORD error = GetLastError (); - __seterrno_from_win_error (error); - debug_printf ("OpenProcess: ret %d", error); - return false; - } - while ((ret = NtQueryVirtualMemory (hProcess, 0, - MemoryWorkingSetList, - (PVOID) p, - n * sizeof *p, &length)), - (ret == STATUS_SUCCESS || ret == STATUS_INFO_LENGTH_MISMATCH) && - length >= (n * sizeof (*p))) - p = (PULONG) realloc (p, n *= (2 * sizeof (ULONG))); - - if (ret != STATUS_SUCCESS) - { - debug_printf ("NtQueryVirtualMemory: ret %d, Dos(ret) %d", - ret, RtlNtStatusToDosError (ret)); - res = false; - goto out; - } - mwsl = (MEMORY_WORKING_SET_LIST *) p; - for (unsigned long i = 0; i < mwsl->NumberOfPages; i++) - { - ++*vmrss; - unsigned flags = mwsl->WorkingSetList[i] & 0x0FFF; - if ((flags & (WSLE_PAGE_EXECUTE | WSLE_PAGE_SHAREABLE)) == (WSLE_PAGE_EXECUTE | WSLE_PAGE_SHAREABLE)) - ++*vmlib; - else if (flags & WSLE_PAGE_SHAREABLE) - ++*vmshare; - else if (flags & WSLE_PAGE_EXECUTE) - ++*vmtext; - else - ++*vmdata; - } - ret = NtQueryInformationProcess (hProcess, ProcessVmCounters, (PVOID) &vmc, - sizeof vmc, NULL); - if (ret != STATUS_SUCCESS) - { - debug_printf ("NtQueryInformationProcess: ret %d, Dos(ret) %d", - ret, RtlNtStatusToDosError (ret)); - res = false; - goto out; - } - *vmsize = vmc.PagefileUsage / page_size; -out: - free (p); - CloseHandle (hProcess); - return res; -} diff --git a/winsup/cygwin/fhandler_procnet.cc b/winsup/cygwin/fhandler_procnet.cc deleted file mode 100644 index 3cf29dd6c..000000000 --- a/winsup/cygwin/fhandler_procnet.cc +++ /dev/null @@ -1,297 +0,0 @@ -/* fhandler_procnet.cc: fhandler for /proc/net virtual filesystem - - Copyright 2007, 2008, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#define __INSIDE_CYGWIN_NET__ - -#include "winsup.h" -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "fhandler_virtual.h" -#include "dtable.h" -#include "cygheap.h" - -#include -#define USE_SYS_TYPES_FD_SET -#include -#include -#include -#include - -#define _COMPILING_NEWLIB -#include -#include -#include - -extern "C" int ip_addr_prefix (PIP_ADAPTER_UNICAST_ADDRESS pua, - PIP_ADAPTER_PREFIX pap); -bool get_adapters_addresses (PIP_ADAPTER_ADDRESSES *pa0, ULONG family); - -static _off64_t format_procnet_ifinet6 (void *, char *&); - -static const virt_tab_t procnet_tab[] = -{ - { ".", FH_PROCNET, virt_directory, NULL }, - { "..", FH_PROCNET, virt_directory, NULL }, - { "if_inet6", FH_PROCNET, virt_file, format_procnet_ifinet6 }, - { NULL, 0, virt_none, NULL } -}; - -static const int PROCNET_LINK_COUNT = - (sizeof (procnet_tab) / sizeof (virt_tab_t)) - 1; - -/* Returns 0 if path doesn't exist, >0 if path is a directory, - * -1 if path is a file, -2 if path is a symlink, -3 if path is a pipe, - * -4 if path is a socket. - */ -int -fhandler_procnet::exists () -{ - const char *path = get_name (); - debug_printf ("exists (%s)", path); - path += proc_len + 1; - while (*path != 0 && !isdirsep (*path)) - path++; - if (*path == 0) - return 1; - - for (int i = 0; procnet_tab[i].name; i++) - if (!strcmp (path + 1, procnet_tab[i].name)) - { - if (procnet_tab[i].type == virt_file) - { - if (!wincap.has_gaa_prefixes () - || !get_adapters_addresses (NULL, AF_INET6)) - return virt_none; - } - fileid = i; - return procnet_tab[i].type; - } - return virt_none; -} - -fhandler_procnet::fhandler_procnet (): - fhandler_proc () -{ -} - -int -fhandler_procnet::fstat (struct __stat64 *buf) -{ - fhandler_base::fstat (buf); - buf->st_mode &= ~_IFMT & NO_W; - int file_type = exists (); - switch (file_type) - { - case virt_none: - set_errno (ENOENT); - return -1; - case virt_directory: - case virt_rootdir: - buf->st_mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH; - buf->st_nlink = 2; - return 0; - case virt_file: - default: - buf->st_mode |= S_IFREG | S_IRUSR | S_IRGRP | S_IROTH; - return 0; - } -} - -int -fhandler_procnet::readdir (DIR *dir, dirent *de) -{ - int res = ENMFILE; - if (dir->__d_position >= PROCNET_LINK_COUNT) - goto out; - if (procnet_tab[dir->__d_position].type == virt_file) - { - if (!wincap.has_gaa_prefixes () - || !get_adapters_addresses (NULL, AF_INET6)) - goto out; - } - strcpy (de->d_name, procnet_tab[dir->__d_position++].name); - dir->__flags |= dirent_saw_dot | dirent_saw_dot_dot; - res = 0; -out: - syscall_printf ("%d = readdir (%p, %p) (%s)", res, dir, de, de->d_name); - return res; -} - -int -fhandler_procnet::open (int flags, mode_t mode) -{ - int process_file_no = -1; - - int res = fhandler_virtual::open (flags, mode); - if (!res) - goto out; - - nohandle (true); - - const char *path; - path = get_name () + proc_len + 1; - while (*path != 0 && !isdirsep (*path)) - path++; - - if (*path == 0) - { - if ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) - { - set_errno (EEXIST); - res = 0; - goto out; - } - else if (flags & O_WRONLY) - { - set_errno (EISDIR); - res = 0; - goto out; - } - else - { - flags |= O_DIROPEN; - goto success; - } - } - - process_file_no = -1; - for (int i = 0; procnet_tab[i].name; i++) - { - if (path_prefix_p (procnet_tab[i].name, path + 1, - strlen (procnet_tab[i].name), false)) - process_file_no = i; - } - if (process_file_no == -1) - { - if (flags & O_CREAT) - { - set_errno (EROFS); - res = 0; - goto out; - } - else - { - set_errno (ENOENT); - res = 0; - goto out; - } - } - if (flags & O_WRONLY) - { - set_errno (EROFS); - res = 0; - goto out; - } - - fileid = process_file_no; - if (!fill_filebuf ()) - { - res = 0; - goto out; - } - - if (flags & O_APPEND) - position = filesize; - else - position = 0; - -success: - res = 1; - set_flags ((flags & ~O_TEXT) | O_BINARY); - set_open_status (); -out: - syscall_printf ("%d = fhandler_proc::open (%p, %d)", res, flags, mode); - return res; -} - -bool -fhandler_procnet::fill_filebuf () -{ - if (procnet_tab[fileid].format_func) - { - filesize = procnet_tab[fileid].format_func (NULL, filebuf); - return true; - } - return false; -} - -/* Return the same scope values as Linux. */ -static unsigned int -get_scope (struct in6_addr *addr) -{ - if (IN6_IS_ADDR_LOOPBACK (addr)) - return 0x10; - if (IN6_IS_ADDR_LINKLOCAL (addr)) - return 0x20; - if (IN6_IS_ADDR_SITELOCAL (addr)) - return 0x40; - if (IN6_IS_ADDR_V4COMPAT (addr)) - return 0x80; - return 0x0; -} - -/* Convert DAD state into Linux compatible values. */ -static unsigned int dad_to_flags[] = -{ - 0x02, /* Invalid -> NODAD */ - 0x40, /* Tentative -> TENTATIVE */ - 0xc0, /* Duplicate -> PERMANENT | TENTATIVE */ - 0x20, /* Deprecated -> DEPRECATED */ - 0x80 /* Preferred -> PERMANENT */ -}; - -static _off64_t -format_procnet_ifinet6 (void *, char *&filebuf) -{ - PIP_ADAPTER_ADDRESSES pa0 = NULL, pap; - PIP_ADAPTER_UNICAST_ADDRESS pua; - ULONG alloclen; - - if (!wincap.has_gaa_prefixes ()) - return 0; - _off64_t filesize = 0; - if (!get_adapters_addresses (&pa0, AF_INET6)) - goto out; - alloclen = 0; - for (pap = pa0; pap; pap = pap->Next) - for (pua = pap->FirstUnicastAddress; pua; pua = pua->Next) - alloclen += 100; - if (!alloclen) - goto out; - filebuf = (char *) crealloc (filebuf, alloclen); - if (!filebuf) - goto out; - for (pap = pa0; pap; pap = pap->Next) - for (pua = pap->FirstUnicastAddress; pua; pua = pua->Next) - { - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) - pua->Address.lpSockaddr; - for (int i = 0; i < 8; ++i) - /* __small_sprintf generates upper-case hex. */ - filesize += sprintf (filebuf + filesize, "%04x", - ntohs (sin6->sin6_addr.s6_addr16[i])); - filebuf[filesize++] = ' '; - filesize += sprintf (filebuf + filesize, - "%02lx %02x %02x %02x %s\n", - pap->Ipv6IfIndex, - ip_addr_prefix (pua, pap->FirstPrefix), - get_scope (&((struct sockaddr_in6 *) - pua->Address.lpSockaddr)->sin6_addr), - dad_to_flags [pua->DadState], - pap->AdapterName); - } - -out: - if (pa0) - free (pa0); - return filesize; -} diff --git a/winsup/cygwin/fhandler_random.cc b/winsup/cygwin/fhandler_random.cc deleted file mode 100644 index e5d8a4866..000000000 --- a/winsup/cygwin/fhandler_random.cc +++ /dev/null @@ -1,187 +0,0 @@ -/* fhandler_random.cc: code to access /dev/random and /dev/urandom - - Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2009 - Red Hat, Inc. - - Written by Corinna Vinschen (vinschen@cygnus.com) - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include "cygerrno.h" -#include "path.h" -#include "fhandler.h" - -#define RANDOM 8 -#define URANDOM 9 - -#define PSEUDO_MULTIPLIER (6364136223846793005LL) -#define PSEUDO_SHIFTVAL (21) - -fhandler_dev_random::fhandler_dev_random () - : fhandler_base (), crypt_prov ((HCRYPTPROV) NULL) -{ -} - -int -fhandler_dev_random::open (int flags, mode_t) -{ - set_flags ((flags & ~O_TEXT) | O_BINARY); - nohandle (true); - set_open_status (); - dummy_offset = 0; - return 1; -} - -bool -fhandler_dev_random::crypt_gen_random (void *ptr, size_t len) -{ - if (!crypt_prov - && !CryptAcquireContext (&crypt_prov, NULL, MS_DEF_PROV, PROV_RSA_FULL, - CRYPT_VERIFYCONTEXT | CRYPT_MACHINE_KEYSET) - && !CryptAcquireContext (&crypt_prov, NULL, MS_DEF_PROV, PROV_RSA_FULL, - CRYPT_VERIFYCONTEXT | CRYPT_MACHINE_KEYSET - | CRYPT_NEWKEYSET)) - { - debug_printf ("%E = CryptAquireContext()"); - return false; - } - if (!CryptGenRandom (crypt_prov, len, (BYTE *)ptr)) - { - debug_printf ("%E = CryptGenRandom()"); - return false; - } - return true; -} - -int -fhandler_dev_random::pseudo_write (const void *ptr, size_t len) -{ - /* Use buffer to mess up the pseudo random number generator. */ - for (size_t i = 0; i < len; ++i) - pseudo = (pseudo + ((unsigned char *)ptr)[i]) * PSEUDO_MULTIPLIER + 1; - return len; -} - -ssize_t __stdcall -fhandler_dev_random::write (const void *ptr, size_t len) -{ - if (!len) - return 0; - if (!ptr) - { - set_errno (EINVAL); - return -1; - } - - /* Limit len to a value <= 512 since we don't want to overact. - Copy to local buffer because CryptGenRandom violates const. */ - unsigned char buf[512]; - size_t limited_len = len <= 512 ? len : 512; - memcpy (buf, ptr, limited_len); - - /* Mess up system entropy source. Return error if device is /dev/random. */ - if (!crypt_gen_random (buf, limited_len) && dev () == FH_RANDOM) - { - __seterrno (); - return -1; - } - /* Mess up the pseudo random number generator. */ - pseudo_write (buf, limited_len); - return len; -} - -int -fhandler_dev_random::pseudo_read (void *ptr, size_t len) -{ - /* Use pseudo random number generator as fallback entropy source. - This multiplier was obtained from Knuth, D.E., "The Art of - Computer Programming," Vol 2, Seminumerical Algorithms, Third - Edition, Addison-Wesley, 1998, p. 106 (line 26) & p. 108 */ - for (size_t i = 0; i < len; ++i) - { - pseudo = pseudo * PSEUDO_MULTIPLIER + 1; - ((unsigned char *)ptr)[i] = (pseudo >> PSEUDO_SHIFTVAL) & UCHAR_MAX; - } - return len; -} - -void __stdcall -fhandler_dev_random::read (void *ptr, size_t& len) -{ - if (!len) - return; - - if (!ptr) - { - set_errno (EINVAL); - len = (size_t) -1; - return; - } - - if (crypt_gen_random (ptr, len)) - return; - - /* If device is /dev/urandom, use pseudo number generator as fallback. - Don't do this for /dev/random since it's intended for uses that need - very high quality randomness. */ - if (dev () == FH_URANDOM) - { - len = pseudo_read (ptr, len); - return; - } - - __seterrno (); - len = (size_t) -1; -} - -_off64_t -fhandler_dev_random::lseek (_off64_t off, int whence) -{ - /* As on Linux, fake being able to set an offset. The fact that neither - reading nor writing changes the dummy offset is also the same as on - Linux (tested with kernel 2.6.23). */ - _off64_t new_off; - - switch (whence) - { - case SEEK_SET: - new_off = off; - break; - case SEEK_CUR: - new_off = dummy_offset + off; - break; - default: - set_errno (EINVAL); - return (_off64_t) -1; - } - if (new_off < 0) - { - set_errno (EINVAL); - return (_off64_t) -1; - } - return dummy_offset = new_off; -} - -int -fhandler_dev_random::close () -{ - if (!hExeced && crypt_prov) - while (!CryptReleaseContext (crypt_prov, 0) - && GetLastError () == ERROR_BUSY) - Sleep (10); - return 0; -} - -int -fhandler_dev_random::dup (fhandler_base *child) -{ - fhandler_dev_random *fhr = (fhandler_dev_random *) child; - fhr->crypt_prov = (HCRYPTPROV)NULL; - return 0; -} diff --git a/winsup/cygwin/fhandler_raw.cc b/winsup/cygwin/fhandler_raw.cc deleted file mode 100644 index 5ffe8c1e9..000000000 --- a/winsup/cygwin/fhandler_raw.cc +++ /dev/null @@ -1,201 +0,0 @@ -/* fhandler_raw.cc. See fhandler.h for a description of the fhandler classes. - - Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009 - Red Hat, Inc. - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#include "winsup.h" - -#include -#include -#include "cygerrno.h" -#include "path.h" -#include "fhandler.h" - -/**********************************************************************/ -/* fhandler_dev_raw */ - -fhandler_dev_raw::fhandler_dev_raw () - : fhandler_base (), status () -{ - need_fork_fixup (true); -} - -fhandler_dev_raw::~fhandler_dev_raw () -{ - if (devbufsiz > 1L) - delete [] devbuf; -} - -int __stdcall -fhandler_dev_raw::fstat (struct __stat64 *buf) -{ - debug_printf ("here"); - - fhandler_base::fstat (buf); - if (is_auto_device ()) - { - if (get_major () == DEV_TAPE_MAJOR) - buf->st_mode = S_IFCHR | STD_RBITS | STD_WBITS | S_IWGRP | S_IWOTH; - else - buf->st_mode = S_IFBLK | STD_RBITS | STD_WBITS | S_IWGRP | S_IWOTH; - - buf->st_uid = geteuid32 (); - buf->st_gid = getegid32 (); - buf->st_nlink = 1; - buf->st_blksize = PREFERRED_IO_BLKSIZE; - time_as_timestruc_t (&buf->st_ctim); - buf->st_atim = buf->st_mtim = buf->st_birthtim = buf->st_ctim; - } - return 0; -} - -int -fhandler_dev_raw::open (int flags, mode_t) -{ - /* Check for illegal flags. */ - if (get_major () != DEV_TAPE_MAJOR && (flags & (O_APPEND | O_EXCL))) - { - set_errno (EINVAL); - return 0; - } - - /* Always open a raw device existing and binary. */ - flags &= ~(O_CREAT | O_TRUNC); - flags |= O_BINARY; - - /* Write-only doesn't work well with raw devices */ - if ((flags & O_ACCMODE) == O_WRONLY) - flags = ((flags & ~O_WRONLY) | O_RDWR); - - int res = fhandler_base::open (flags, 0); - if (res && devbufsiz > 1L) - devbuf = new char [devbufsiz]; - - return res; -} - -int -fhandler_dev_raw::dup (fhandler_base *child) -{ - int ret = fhandler_base::dup (child); - - if (!ret) - { - fhandler_dev_raw *fhc = (fhandler_dev_raw *) child; - - fhc->devbufsiz = devbufsiz; - if (devbufsiz > 1L) - fhc->devbuf = new char [devbufsiz]; - fhc->devbufstart = 0; - fhc->devbufend = 0; - fhc->lastblk_to_read (false); - } - return ret; -} - -void -fhandler_dev_raw::fixup_after_fork (HANDLE) -{ - devbufstart = 0; - devbufend = 0; - lastblk_to_read (false); -} - -void -fhandler_dev_raw::fixup_after_exec () -{ - if (!close_on_exec ()) - { - if (devbufsiz > 1L) - devbuf = new char [devbufsiz]; - devbufstart = 0; - devbufend = 0; - lastblk_to_read (false); - } -} - -int -fhandler_dev_raw::ioctl (unsigned int cmd, void *buf) -{ - int ret = NO_ERROR; - - if (cmd == RDIOCDOP) - { - struct rdop *op = (struct rdop *) buf; - - if (!op) - ret = ERROR_INVALID_PARAMETER; - else - switch (op->rd_op) - { - case RDSETBLK: - if (get_major () == DEV_TAPE_MAJOR) - { - struct mtop mop; - - mop.mt_op = MTSETBLK; - mop.mt_count = op->rd_parm; - ret = ioctl (MTIOCTOP, &mop); - } - else if ((devbuf && ((op->rd_parm <= 1 && (devbufend - devbufstart)) - || op->rd_parm < devbufend - devbufstart)) - || (op->rd_parm > 1 && (op->rd_parm % 512)) - || (get_flags () & O_DIRECT)) - /* The conditions for a *valid* parameter are these: - - If there's still data in the current buffer, it must - fit in the new buffer. - - The new size is either 0 or 1, both indicating unbufferd - I/O, or the new buffersize must be a multiple of 512. - - In the O_DIRECT case, the whole request is invalid. */ - ret = ERROR_INVALID_PARAMETER; - else if (!devbuf || op->rd_parm != devbufsiz) - { - char *buf = NULL; - if (op->rd_parm > 1L) - buf = new char [op->rd_parm]; - if (buf && devbufsiz > 1L) - { - memcpy (buf, devbuf + devbufstart, devbufend - devbufstart); - devbufend -= devbufstart; - } - else - devbufend = 0; - - if (devbufsiz > 1L) - delete [] devbuf; - - devbufstart = 0; - devbuf = buf; - devbufsiz = op->rd_parm ?: 1L; - } - break; - default: - break; - } - } - else if (cmd == RDIOCGET) - { - struct rdget *get = (struct rdget *) buf; - - if (!get) - ret = ERROR_INVALID_PARAMETER; - else - get->bufsiz = devbufsiz; - } - else - return fhandler_base::ioctl (cmd, buf); - - if (ret != NO_ERROR) - { - SetLastError (ret); - __seterrno (); - return -1; - } - return 0; -} diff --git a/winsup/cygwin/fhandler_registry.cc b/winsup/cygwin/fhandler_registry.cc deleted file mode 100644 index 9f8e9af97..000000000 --- a/winsup/cygwin/fhandler_registry.cc +++ /dev/null @@ -1,996 +0,0 @@ -/* fhandler_registry.cc: fhandler for /proc/registry virtual filesystem - - Copyright 2002, 2003, 2003, 2004, 2005, 2006, 2007, 2008, 2009, - 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* FIXME: Access permissions are ignored at the moment. */ - -#include "winsup.h" -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" - -#define _COMPILING_NEWLIB -#include - -/* If this bit is set in __d_position then we are enumerating values, - * else sub-keys. keeping track of where we are is horribly messy - * the bottom 16 bits are the absolute position and the top 15 bits - * make up the value index if we are enuerating values. - */ -static const _off_t REG_ENUM_VALUES_MASK = 0x8000000; -static const _off_t REG_POSITION_MASK = 0xffff; - -/* List of root keys in /proc/registry. - * Possibly we should filter out those not relevant to the flavour of Windows - * Cygwin is running on. - */ -static const char *registry_listing[] = -{ - ".", - "..", - "HKEY_CLASSES_ROOT", - "HKEY_CURRENT_CONFIG", - "HKEY_CURRENT_USER", - "HKEY_LOCAL_MACHINE", - "HKEY_USERS", - "HKEY_PERFORMANCE_DATA", // NT/2000/XP - NULL -}; - -static const HKEY registry_keys[] = -{ - (HKEY) INVALID_HANDLE_VALUE, - (HKEY) INVALID_HANDLE_VALUE, - HKEY_CLASSES_ROOT, - HKEY_CURRENT_CONFIG, - HKEY_CURRENT_USER, - HKEY_LOCAL_MACHINE, - HKEY_USERS, - HKEY_PERFORMANCE_DATA -}; - -static const int ROOT_KEY_COUNT = sizeof (registry_keys) / sizeof (HKEY); - -/* These get added to each subdirectory in /proc/registry. - * If we wanted to implement writing, we could maybe add a '.writable' entry or - * suchlike. - */ -static const char *special_dot_files[] = -{ - ".", - "..", - NULL -}; - -static const int SPECIAL_DOT_FILE_COUNT = - (sizeof (special_dot_files) / sizeof (const char *)) - 1; - -/* Value names for HKEY_PERFORMANCE_DATA. - * - * CAUTION: Never call RegQueryValueEx (HKEY_PERFORMANCE_DATA, "Add", ...). - * It WRITES data and may destroy the perfc009.dat file. Same applies to - * name prefixes "Ad" and "A". - */ -static const char * const perf_data_files[] = -{ - "@", - "Costly", - "Global" -}; - -static const int PERF_DATA_FILE_COUNT = - sizeof (perf_data_files) / sizeof (perf_data_files[0]); - -static HKEY open_key (const char *name, REGSAM access, DWORD wow64, bool isValue); - -/* Return true if char must be encoded. - */ -static inline bool -must_encode (wchar_t c) -{ - return (iswdirsep (c) || c == L':' || c == L'%'); -} - -/* Encode special chars in registry key or value name. - * Returns 0: success, -1: error. - */ -static int -encode_regname (char *dst, const wchar_t *src, bool add_val) -{ - int di = 0; - if (!src[0]) - dst[di++] = '@'; // Default value. - else - for (int si = 0; src[si]; si++) - { - wchar_t c = src[si]; - if (must_encode (c) || - (si == 0 && ((c == L'.' - && (!src[1] || (src[1] == L'.' && !src[2]))) - || (c == L'@' && !src[1])))) - { - if (di + 3 >= NAME_MAX + 1) - return -1; - __small_sprintf (dst + di, "%%%02x", c); - di += 3; - } - else - di += sys_wcstombs (dst + di, NAME_MAX + 1 - di, &c, 1); - } - - if (add_val) - { - if (di + 4 >= NAME_MAX + 1) - return -1; - memcpy (dst + di, "%val", 4); - di += 4; - } - - dst[di] = 0; - return 0; -} - -/* Decode special chars in registry key or value name. - * Returns 0: success, 1: "%val" detected, -1: error. - */ -static int -decode_regname (wchar_t *wdst, const char *src, int len = -1) -{ - if (len < 0) - len = strlen (src); - char dst[len + 1]; - int res = 0; - - if (len > 4 && !memcmp (src + len - 4, "%val", 4)) - { - len -= 4; - res = 1; - } - - int di = 0; - if (len == 1 && src[0] == '@') - ; // Default value. - else - for (int si = 0; si < len; si++) - { - char c = src[si]; - if (c == '%') - { - if (si + 2 >= len) - return -1; - char s[] = {src[si+1], src[si+2], '\0'}; - char *p; - c = strtoul (s, &p, 16); - if (!(must_encode ((wchar_t) c) || - (si == 0 && ((c == '.' && (len == 3 || (src[3] == '.' && len == 4))) || - (c == '@' && len == 3))))) - return -1; - dst[di++] = c; - si += 2; - } - else - dst[di++] = c; - } - - dst[di] = 0; - sys_mbstowcs (wdst, NAME_MAX + 1, dst); - return res; -} - - -/* Hash table to limit calls to key_exists (). - */ -class __DIR_hash -{ -public: - __DIR_hash () - { - memset (table, 0, sizeof(table)); - } - - void set (unsigned h) - { - table [(h >> 3) & (HASH_SIZE - 1)] |= (1 << (h & 0x3)); - } - - bool is_set (unsigned h) const - { - return (table [(h >> 3) & (HASH_SIZE - 1)] & (1 << (h & 0x3))) != 0; - } - -private: - enum { HASH_SIZE = 1024 }; - unsigned char table[HASH_SIZE]; -}; - -#define d_hash(d) ((__DIR_hash *) (d)->__d_internal) - - -/* Return true if subkey NAME exists in key PARENT. - */ -static bool -key_exists (HKEY parent, const wchar_t *name, DWORD wow64) -{ - HKEY hKey = (HKEY) INVALID_HANDLE_VALUE; - LONG error = RegOpenKeyExW (parent, name, 0, KEY_READ | wow64, &hKey); - if (error == ERROR_SUCCESS) - RegCloseKey (hKey); - - return (error == ERROR_SUCCESS || error == ERROR_ACCESS_DENIED); -} - -/* Returns 0 if path doesn't exist, >0 if path is a directory, - * <0 if path is a file. - * - * We open the last key but one and then enum it's sub-keys and values to see if the - * final component is there. This gets round the problem of not having security access - * to the final key in the path. - */ -int -fhandler_registry::exists () -{ - int file_type = 0, index = 0, pathlen; - DWORD buf_size = NAME_MAX + 1; - LONG error; - wchar_t buf[buf_size]; - const char *file; - HKEY hKey = (HKEY) INVALID_HANDLE_VALUE; - - const char *path = get_name (); - debug_printf ("exists (%s)", path); - path += proc_len + prefix_len + 1; - if (*path) - path++; - else - { - file_type = 2; - goto out; - } - pathlen = strlen (path); - file = path + pathlen - 1; - if (isdirsep (*file) && pathlen > 1) - file--; - while (!isdirsep (*file)) - file--; - file++; - - if (file == path) - { - for (int i = 0; registry_listing[i]; i++) - if (path_prefix_p (registry_listing[i], path, - strlen (registry_listing[i]), true)) - { - file_type = 1; - break; - } - } - else - { - wchar_t dec_file[NAME_MAX + 1]; - - int val_only = decode_regname (dec_file, file); - if (val_only < 0) - goto out; - - if (!val_only) - hKey = open_key (path, KEY_READ, wow64, false); - if (hKey != (HKEY) INVALID_HANDLE_VALUE || get_errno () == EACCES) - file_type = 1; - else - { - hKey = open_key (path, KEY_READ, wow64, true); - if (hKey == (HKEY) INVALID_HANDLE_VALUE) - return 0; - - if (hKey == HKEY_PERFORMANCE_DATA) - { - /* RegEnumValue () returns garbage for this key. - RegQueryValueEx () returns a PERF_DATA_BLOCK even - if a value does not contain any counter objects. - So allow access to the generic names and to - (blank separated) lists of counter numbers. - Never allow access to "Add", see above comment. */ - for (int i = 0; i < PERF_DATA_FILE_COUNT && file_type == 0; i++) - { - if (strcasematch (perf_data_files[i], file)) - file_type = -1; - } - if (file_type == 0 && !file[strspn (file, " 0123456789")]) - file_type = -1; - goto out; - } - - if (!val_only && dec_file[0]) - { - while (ERROR_SUCCESS == - (error = RegEnumKeyExW (hKey, index++, buf, &buf_size, - NULL, NULL, NULL, NULL)) - || (error == ERROR_MORE_DATA)) - { - if (!wcscasecmp (buf, dec_file)) - { - file_type = 1; - goto out; - } - buf_size = NAME_MAX + 1; - } - if (error != ERROR_NO_MORE_ITEMS) - { - seterrno_from_win_error (__FILE__, __LINE__, error); - goto out; - } - index = 0; - buf_size = NAME_MAX + 1; - } - - while (ERROR_SUCCESS == - (error = RegEnumValueW (hKey, index++, buf, &buf_size, - NULL, NULL, NULL, NULL)) - || (error == ERROR_MORE_DATA)) - { - if (!wcscasecmp (buf, dec_file)) - { - file_type = -1; - goto out; - } - buf_size = NAME_MAX + 1; - } - if (error != ERROR_NO_MORE_ITEMS) - { - seterrno_from_win_error (__FILE__, __LINE__, error); - goto out; - } - } - } -out: - if (hKey != (HKEY) INVALID_HANDLE_VALUE) - RegCloseKey (hKey); - return file_type; -} - -void -fhandler_registry::set_name (path_conv &in_pc) -{ - if (strncasematch (in_pc.normalized_path, "/proc/registry32", 16)) - { - wow64 = KEY_WOW64_32KEY; - prefix_len += 2; - } - else if (strncasematch (in_pc.normalized_path, "/proc/registry64", 16)) - { - wow64 = KEY_WOW64_64KEY; - prefix_len += 2; - } - fhandler_base::set_name (in_pc); -} - -fhandler_registry::fhandler_registry (): -fhandler_proc () -{ - wow64 = 0; - prefix_len = sizeof ("registry") - 1; -} - -int -fhandler_registry::fstat (struct __stat64 *buf) -{ - fhandler_base::fstat (buf); - buf->st_mode &= ~_IFMT & NO_W; - int file_type = exists (); - switch (file_type) - { - case 0: - set_errno (ENOENT); - return -1; - case 1: - buf->st_mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH; - break; - case 2: - buf->st_mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH; - buf->st_nlink = ROOT_KEY_COUNT; - break; - default: - case -1: - buf->st_mode |= S_IFREG; - buf->st_mode &= NO_X; - break; - } - if (file_type != 0 && file_type != 2) - { - HKEY hKey; - const char *path = get_name () + proc_len + prefix_len + 2; - hKey = - open_key (path, STANDARD_RIGHTS_READ | KEY_QUERY_VALUE, wow64, - (file_type < 0) ? true : false); - - if (hKey == HKEY_PERFORMANCE_DATA) - /* RegQueryInfoKey () always returns write time 0, - RegQueryValueEx () does not return required buffer size. */ - ; - else if (hKey != (HKEY) INVALID_HANDLE_VALUE) - { - FILETIME ftLastWriteTime; - DWORD subkey_count; - if (ERROR_SUCCESS == - RegQueryInfoKey (hKey, NULL, NULL, NULL, &subkey_count, NULL, - NULL, NULL, NULL, NULL, NULL, - &ftLastWriteTime)) - { - to_timestruc_t (&ftLastWriteTime, &buf->st_mtim); - buf->st_ctim = buf->st_birthtim = buf->st_mtim; - time_as_timestruc_t (&buf->st_atim); - if (file_type > 0) - buf->st_nlink = subkey_count + 2; - else - { - int pathlen = strlen (path); - const char *value_name = path + pathlen - 1; - if (isdirsep (*value_name) && pathlen > 1) - value_name--; - while (!isdirsep (*value_name)) - value_name--; - value_name++; - wchar_t dec_value_name[NAME_MAX + 1]; - DWORD dwSize = 0; - DWORD type; - if (decode_regname (dec_value_name, value_name) >= 0 - && RegQueryValueExW (hKey, dec_value_name, NULL, &type, - NULL, &dwSize) == ERROR_SUCCESS - && (type == REG_SZ || type == REG_EXPAND_SZ - || type == REG_MULTI_SZ || type == REG_LINK)) - { - PBYTE tmpbuf = (PBYTE) malloc (dwSize); - if (!tmpbuf - || RegQueryValueExW (hKey, dec_value_name, - NULL, NULL, tmpbuf, &dwSize) - != ERROR_SUCCESS) - buf->st_size = dwSize / sizeof (wchar_t); - else - buf->st_size = sys_wcstombs (NULL, 0, - (wchar_t *) tmpbuf, - dwSize / sizeof (wchar_t)); - free (tmpbuf); - } - else - buf->st_size = dwSize; - } - __uid32_t uid; - __gid32_t gid; - if (get_reg_attribute (hKey, &buf->st_mode, &uid, &gid) == 0) - { - buf->st_uid = uid; - buf->st_gid = gid; - buf->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH); - if (file_type > 0) - buf->st_mode |= S_IFDIR; - else - buf->st_mode &= NO_X; - } - } - RegCloseKey (hKey); - } - else - { - /* Here's the problem: If we can't open the key, we don't know - nothing at all about the key/value. It's only clear that - the current user has no read access. At this point it's - rather unlikely that the user has write or execute access - and it's also rather unlikely that the user is the owner. - Therefore it's probably most safe to assume unknown ownership - and no permissions for nobody. */ - buf->st_uid = UNKNOWN_UID; - buf->st_gid = UNKNOWN_GID; - buf->st_mode &= ~0777; - } - } - return 0; -} - -int -fhandler_registry::readdir (DIR *dir, dirent *de) -{ - DWORD buf_size = NAME_MAX + 1; - wchar_t buf[buf_size]; - HANDLE handle; - const char *path = dir->__d_dirname + proc_len + 1 + prefix_len; - LONG error; - int res = ENMFILE; - - dir->__flags |= dirent_saw_dot | dirent_saw_dot_dot; - if (*path == 0) - { - if (dir->__d_position >= ROOT_KEY_COUNT) - goto out; - strcpy (de->d_name, registry_listing[dir->__d_position++]); - res = 0; - goto out; - } - if (dir->__handle == INVALID_HANDLE_VALUE) - { - if (dir->__d_position != 0) - goto out; - handle = open_key (path + 1, KEY_READ, wow64, false); - dir->__handle = handle; - if (dir->__handle == INVALID_HANDLE_VALUE) - goto out; - dir->__d_internal = (unsigned) new __DIR_hash (); - } - if (dir->__d_position < SPECIAL_DOT_FILE_COUNT) - { - strcpy (de->d_name, special_dot_files[dir->__d_position++]); - res = 0; - goto out; - } - if ((HKEY) dir->__handle == HKEY_PERFORMANCE_DATA) - { - /* RegEnumValue () returns garbage for this key, - simulate only a minimal listing of the generic names. */ - if (dir->__d_position >= SPECIAL_DOT_FILE_COUNT + PERF_DATA_FILE_COUNT) - goto out; - strcpy (de->d_name, perf_data_files[dir->__d_position - SPECIAL_DOT_FILE_COUNT]); - dir->__d_position++; - res = 0; - goto out; - } - -retry: - if (dir->__d_position & REG_ENUM_VALUES_MASK) - /* For the moment, the type of key is ignored here. when write access is added, - * maybe add an extension for the type of each value? - */ - error = RegEnumValueW ((HKEY) dir->__handle, - (dir->__d_position & ~REG_ENUM_VALUES_MASK) >> 16, - buf, &buf_size, NULL, NULL, NULL, NULL); - else - error = - RegEnumKeyExW ((HKEY) dir->__handle, dir->__d_position - - SPECIAL_DOT_FILE_COUNT, buf, &buf_size, - NULL, NULL, NULL, NULL); - if (error == ERROR_NO_MORE_ITEMS - && (dir->__d_position & REG_ENUM_VALUES_MASK) == 0) - { - /* If we're finished with sub-keys, start on values under this key. */ - dir->__d_position |= REG_ENUM_VALUES_MASK; - buf_size = NAME_MAX + 1; - goto retry; - } - if (error != ERROR_SUCCESS && error != ERROR_MORE_DATA) - { - RegCloseKey ((HKEY) dir->__handle); - dir->__handle = INVALID_HANDLE_VALUE; - if (error != ERROR_NO_MORE_ITEMS) - seterrno_from_win_error (__FILE__, __LINE__, error); - goto out; - } - - /* We get here if `buf' contains valid data. */ - dir->__d_position++; - if (dir->__d_position & REG_ENUM_VALUES_MASK) - dir->__d_position += 0x10000; - - { - /* Append "%val" if value name is identical to a previous key name. */ - unsigned h = hash_path_name (1, buf); - bool add_val = false; - if (! (dir->__d_position & REG_ENUM_VALUES_MASK)) - d_hash (dir)->set (h); - else if (d_hash (dir)->is_set (h) - && key_exists ((HKEY) dir->__handle, buf, wow64)) - add_val = true; - - if (encode_regname (de->d_name, buf, add_val)) - { - buf_size = NAME_MAX + 1; - goto retry; - } - } - - if (dir->__d_position & REG_ENUM_VALUES_MASK) - de->d_type = DT_REG; - else - de->d_type = DT_DIR; - - res = 0; -out: - syscall_printf ("%d = readdir (%p, %p)", res, dir, de); - return res; -} - -_off64_t -fhandler_registry::telldir (DIR * dir) -{ - return dir->__d_position & REG_POSITION_MASK; -} - -void -fhandler_registry::seekdir (DIR * dir, _off64_t loc) -{ - /* Unfortunately cannot simply set __d_position due to transition from sub-keys to - * values. - */ - rewinddir (dir); - while (loc > (dir->__d_position & REG_POSITION_MASK)) - if (!readdir (dir, dir->__d_dirent)) - break; -} - -void -fhandler_registry::rewinddir (DIR * dir) -{ - if (dir->__handle != INVALID_HANDLE_VALUE) - { - RegCloseKey ((HKEY) dir->__handle); - dir->__handle = INVALID_HANDLE_VALUE; - } - dir->__d_position = 0; - dir->__flags = dirent_saw_dot | dirent_saw_dot_dot; -} - -int -fhandler_registry::closedir (DIR * dir) -{ - int res = 0; - if (dir->__handle != INVALID_HANDLE_VALUE) - { - delete d_hash (dir); - if (RegCloseKey ((HKEY) dir->__handle) != ERROR_SUCCESS) - { - __seterrno (); - res = -1; - } - } - syscall_printf ("%d = closedir (%p)", res, dir); - return 0; -} - -int -fhandler_registry::open (int flags, mode_t mode) -{ - int pathlen; - const char *file; - HKEY handle = (HKEY) INVALID_HANDLE_VALUE; - - int res = fhandler_virtual::open (flags, mode); - if (!res) - goto out; - - const char *path; - path = get_name () + proc_len + 1 + prefix_len; - if (!*path) - { - if ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) - { - set_errno (EEXIST); - res = 0; - goto out; - } - else if (flags & O_WRONLY) - { - set_errno (EISDIR); - res = 0; - goto out; - } - else - { - flags |= O_DIROPEN; - /* Marking as nohandle allows to call dup. */ - nohandle (true); - goto success; - } - } - path++; - pathlen = strlen (path); - file = path + pathlen - 1; - if (isdirsep (*file) && pathlen > 1) - file--; - while (!isdirsep (*file)) - file--; - file++; - - if (file == path) - { - for (int i = 0; registry_listing[i]; i++) - if (path_prefix_p (registry_listing[i], path, - strlen (registry_listing[i]), true)) - { - if ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) - { - set_errno (EEXIST); - res = 0; - goto out; - } - else if (flags & O_WRONLY) - { - set_errno (EISDIR); - res = 0; - goto out; - } - else - { - set_io_handle (registry_keys[i]); - /* Marking as nohandle allows to call dup on pseudo registry - handles. */ - nohandle (true); - flags |= O_DIROPEN; - goto success; - } - } - - if (flags & O_CREAT) - { - set_errno (EROFS); - res = 0; - } - else - { - set_errno (ENOENT); - res = 0; - } - goto out; - } - - if (flags & O_WRONLY) - { - set_errno (EROFS); - res = 0; - } - else - { - wchar_t dec_file[NAME_MAX + 1]; - int val_only = decode_regname (dec_file, file); - if (val_only < 0) - { - set_errno (EINVAL); - res = 0; - goto out; - } - - if (!val_only) - handle = open_key (path, KEY_READ, wow64, false); - if (handle == (HKEY) INVALID_HANDLE_VALUE) - { - if (get_errno () != EACCES) - handle = open_key (path, KEY_READ, wow64, true); - if (handle == (HKEY) INVALID_HANDLE_VALUE) - { - res = 0; - goto out; - } - } - else - flags |= O_DIROPEN; - - set_io_handle (handle); - set_close_on_exec (!!(flags & O_CLOEXEC)); - value_name = cwcsdup (dec_file); - - if (!(flags & O_DIROPEN) && !fill_filebuf ()) - { - RegCloseKey (handle); - res = 0; - goto out; - } - - if (flags & O_APPEND) - position = filesize; - else - position = 0; - } - -success: - res = 1; - set_flags ((flags & ~O_TEXT) | O_BINARY); - set_open_status (); -out: - syscall_printf ("%d = fhandler_registry::open (%p, %d)", res, flags, mode); - return res; -} - -int -fhandler_registry::close () -{ - int res = fhandler_virtual::close (); - if (res != 0) - return res; - HKEY handle = (HKEY) get_handle (); - if (handle != (HKEY) INVALID_HANDLE_VALUE && handle < HKEY_CLASSES_ROOT) - { - if (RegCloseKey (handle) != ERROR_SUCCESS) - { - __seterrno (); - res = -1; - } - } - if (!hExeced && value_name) - { - cfree (value_name); - value_name = NULL; - } - return res; -} - -bool -fhandler_registry::fill_filebuf () -{ - DWORD type, size; - LONG error; - HKEY handle = (HKEY) get_handle (); - size_t bufalloc; - - if (handle != HKEY_PERFORMANCE_DATA) - { - error = RegQueryValueExW (handle, value_name, NULL, &type, NULL, &size); - if (error != ERROR_SUCCESS) - { - if (error != ERROR_FILE_NOT_FOUND) - { - seterrno_from_win_error (__FILE__, __LINE__, error); - return false; - } - goto value_not_found; - } - PBYTE tmpbuf = (PBYTE) cmalloc_abort (HEAP_BUF, size); - error = - RegQueryValueExW (handle, value_name, NULL, NULL, tmpbuf, &size); - if (error != ERROR_SUCCESS) - { - seterrno_from_win_error (__FILE__, __LINE__, error); - return true; - } - if (type == REG_SZ || type == REG_EXPAND_SZ || type == REG_MULTI_SZ - || type == REG_LINK) - bufalloc = sys_wcstombs (NULL, 0, (wchar_t *) tmpbuf, - size / sizeof (wchar_t)); - else - bufalloc = size; - filebuf = (char *) cmalloc_abort (HEAP_BUF, bufalloc); - if (type == REG_SZ || type == REG_EXPAND_SZ || type == REG_MULTI_SZ - || type == REG_LINK) - sys_wcstombs (filebuf, bufalloc, (wchar_t *) tmpbuf, - size / sizeof (wchar_t)); - else - memcpy (filebuf, tmpbuf, bufalloc); - filesize = bufalloc; - } - else - { - bufalloc = 0; - do - { - bufalloc += 16 * 1024; - filebuf = (char *) crealloc_abort (filebuf, bufalloc); - size = bufalloc; - error = RegQueryValueExW (handle, value_name, NULL, &type, - (PBYTE) filebuf, &size); - if (error != ERROR_SUCCESS && error != ERROR_MORE_DATA) - { - seterrno_from_win_error (__FILE__, __LINE__, error); - return false; - } - } - while (error == ERROR_MORE_DATA); - filesize = size; - /* RegQueryValueEx () opens HKEY_PERFORMANCE_DATA. */ - RegCloseKey (handle); - } - return true; -value_not_found: - DWORD buf_size = NAME_MAX + 1; - wchar_t buf[buf_size]; - int index = 0; - while (ERROR_SUCCESS == - (error = RegEnumKeyExW (handle, index++, buf, &buf_size, NULL, NULL, - NULL, NULL)) || (error == ERROR_MORE_DATA)) - { - if (!wcscasecmp (buf, value_name)) - { - set_errno (EISDIR); - return false; - } - buf_size = NAME_MAX + 1; - } - if (error != ERROR_NO_MORE_ITEMS) - { - seterrno_from_win_error (__FILE__, __LINE__, error); - return false; - } - set_errno (ENOENT); - return false; -} - -/* Auxillary member function to open registry keys. */ -static HKEY -open_key (const char *name, REGSAM access, DWORD wow64, bool isValue) -{ - HKEY hKey = (HKEY) INVALID_HANDLE_VALUE; - HKEY hParentKey = (HKEY) INVALID_HANDLE_VALUE; - bool parentOpened = false; - wchar_t component[NAME_MAX + 1]; - - while (*name) - { - const char *anchor = name; - while (*name && !isdirsep (*name)) - name++; - int val_only = decode_regname (component, anchor, name - anchor); - if (val_only < 0) - { - set_errno (EINVAL); - if (parentOpened) - RegCloseKey (hParentKey); - hKey = (HKEY) INVALID_HANDLE_VALUE; - break; - } - if (*name) - name++; - if (*name == 0 && isValue == true) - break; - - if (val_only || !component[0] || hKey == HKEY_PERFORMANCE_DATA) - { - set_errno (ENOENT); - if (parentOpened) - RegCloseKey (hParentKey); - hKey = (HKEY) INVALID_HANDLE_VALUE; - break; - } - - if (hParentKey != (HKEY) INVALID_HANDLE_VALUE) - { - REGSAM effective_access = KEY_READ; - if ((strchr (name, '/') == NULL && isValue == true) || *name == 0) - effective_access = access; - LONG error = RegOpenKeyExW (hParentKey, component, 0, - effective_access | wow64, &hKey); - if (error == ERROR_ACCESS_DENIED) /* Try opening with backup intent */ - error = RegCreateKeyExW (hParentKey, component, 0, NULL, - REG_OPTION_BACKUP_RESTORE, - effective_access | wow64, NULL, - &hKey, NULL); - if (parentOpened) - RegCloseKey (hParentKey); - if (error != ERROR_SUCCESS) - { - hKey = (HKEY) INVALID_HANDLE_VALUE; - seterrno_from_win_error (__FILE__, __LINE__, error); - return hKey; - } - hParentKey = hKey; - parentOpened = true; - } - else - { - for (int i = 0; registry_listing[i]; i++) - if (strncasematch (anchor, registry_listing[i], name - anchor - 1)) - hKey = registry_keys[i]; - if (hKey == (HKEY) INVALID_HANDLE_VALUE) - return hKey; - hParentKey = hKey; - } - } - return hKey; -} - -int -fhandler_registry::dup (fhandler_base *child) -{ - int ret = fhandler_virtual::dup (child); - /* Pseudo registry handles can't be duplicated using DuplicateHandle. - Therefore those fhandlers are marked with the nohandle flag. This - allows fhandler_base::dup to succeed as usual for nohandle fhandlers. - Here we just have to fix up by copying the pseudo handle value. */ - if ((HKEY) get_handle () >= HKEY_CLASSES_ROOT) - child->set_io_handle (get_handle ()); - return ret; -} diff --git a/winsup/cygwin/fhandler_serial.cc b/winsup/cygwin/fhandler_serial.cc deleted file mode 100644 index a076dad1a..000000000 --- a/winsup/cygwin/fhandler_serial.cc +++ /dev/null @@ -1,1127 +0,0 @@ -/* fhandler_serial.cc - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "sigproc.h" -#include "pinfo.h" -#include - -/**********************************************************************/ -/* fhandler_serial */ - -fhandler_serial::fhandler_serial () - : fhandler_base (), vmin_ (0), vtime_ (0), pgrp_ (myself->pgid) -{ - need_fork_fixup (true); -} - -void -fhandler_serial::overlapped_setup () -{ - memset (&io_status, 0, sizeof (io_status)); - io_status.hEvent = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL); - ProtectHandle (io_status.hEvent); - overlapped_armed = 0; -} - -void __stdcall -fhandler_serial::raw_read (void *ptr, size_t& ulen) -{ - int tot; - DWORD n; - HANDLE w4[2]; - size_t minchars = vmin_ ? min (vmin_, ulen) : ulen; - - w4[0] = io_status.hEvent; - w4[1] = signal_arrived; - - debug_printf ("ulen %d, vmin_ %d, vtime_ %d, hEvent %p", ulen, vmin_, vtime_, - io_status.hEvent); - if (!overlapped_armed) - { - SetCommMask (get_handle (), EV_RXCHAR); - ResetEvent (io_status.hEvent); - } - - for (n = 0, tot = 0; ulen; ulen -= n, ptr = (char *) ptr + n) - { - COMSTAT st; - DWORD inq = vmin_ ? minchars : vtime_ ? ulen : 1; - - n = 0; - - if (vtime_) // non-interruptible -- have to use kernel timeouts - overlapped_armed = -1; - - if (!ClearCommError (get_handle (), &ev, &st)) - goto err; - else if (ev) - termios_printf ("error detected %x", ev); - else if (st.cbInQue && !vtime_) - inq = st.cbInQue; - else if (!overlapped_armed) - { - if ((size_t) tot >= minchars) - break; - else if (WaitCommEvent (get_handle (), &ev, &io_status)) - { - debug_printf ("WaitCommEvent succeeded: ev %x", ev); - if (!ev) - continue; - } - else if (GetLastError () != ERROR_IO_PENDING) - goto err; - else - { - overlapped_armed = 1; - switch (WaitForMultipleObjects (2, w4, FALSE, INFINITE)) - { - case WAIT_OBJECT_0: - if (!GetOverlappedResult (get_handle (), &io_status, &n, - FALSE)) - goto err; - debug_printf ("n %d, ev %x", n, ev); - break; - case WAIT_OBJECT_0 + 1: - tot = -1; - PurgeComm (get_handle (), PURGE_RXABORT); - overlapped_armed = 0; - set_sig_errno (EINTR); - goto out; - default: - goto err; - } - } - } - - overlapped_armed = 0; - ResetEvent (io_status.hEvent); - if (inq > ulen) - inq = ulen; - debug_printf ("inq %d", inq); - if (ReadFile (get_handle (), ptr, inq, &n, &io_status)) - /* Got something */; - else if (GetLastError () != ERROR_IO_PENDING) - goto err; - else if (!GetOverlappedResult (get_handle (), &io_status, &n, TRUE)) - goto err; - - tot += n; - debug_printf ("vtime_ %d, vmin_ %d, n %d, tot %d", vtime_, vmin_, n, tot); - if (vtime_ || !vmin_ || !n) - break; - continue; - - err: - debug_printf ("err %E"); - if (GetLastError () != ERROR_OPERATION_ABORTED) - { - PurgeComm (get_handle (), PURGE_RXABORT); - tot = -1; - __seterrno (); - break; - } - - n = 0; - } - -out: - ulen = tot; -} - -/* Cover function to WriteFile to provide Posix interface and semantics - (as much as possible). */ -ssize_t __stdcall -fhandler_serial::raw_write (const void *ptr, size_t len) -{ - DWORD bytes_written; - OVERLAPPED write_status; - - memset (&write_status, 0, sizeof (write_status)); - write_status.hEvent = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL); - ProtectHandle (write_status.hEvent); - - for (;;) - { - if (WriteFile (get_handle (), ptr, len, &bytes_written, &write_status)) - break; - - switch (GetLastError ()) - { - case ERROR_OPERATION_ABORTED: - DWORD ev; - if (!ClearCommError (get_handle (), &ev, NULL)) - goto err; - if (ev) - termios_printf ("error detected %x", ev); - continue; - case ERROR_IO_PENDING: - break; - default: - goto err; - } - - if (!GetOverlappedResult (get_handle (), &write_status, &bytes_written, TRUE)) - goto err; - - break; - } - - ForceCloseHandle (write_status.hEvent); - - return bytes_written; - -err: - __seterrno (); - ForceCloseHandle (write_status.hEvent); - return -1; -} - -int -fhandler_serial::init (HANDLE f, DWORD flags, mode_t bin) -{ - return open (flags, bin & (O_BINARY | O_TEXT)); -} - -int -fhandler_serial::open (int flags, mode_t mode) -{ - int res; - COMMTIMEOUTS to; - extern BOOL reset_com; - - syscall_printf ("fhandler_serial::open (%s, %p, %p)", - get_name (), flags, mode); - - if (!fhandler_base::open (flags, mode)) - return 0; - - res = 1; - - SetCommMask (get_handle (), EV_RXCHAR); - - uninterruptible_io (true); // Handled explicitly in read code - - overlapped_setup (); - - memset (&to, 0, sizeof (to)); - SetCommTimeouts (get_handle (), &to); - - /* Reset serial port to known state of 9600-8-1-no flow control - on open for better behavior under Win 95. - - FIXME: This should only be done when explicitly opening the com - port. It should not be reset if an fd is inherited. - Using __progname in this way, to determine how far along in the - initialization we are, is really a terrible kludge and should - be fixed ASAP. - */ - if (reset_com && __progname) - { - DCB state; - GetCommState (get_handle (), &state); - syscall_printf ("setting initial state on %s (reset_com %d)", - get_name (), reset_com); - state.BaudRate = CBR_9600; - state.ByteSize = 8; - state.StopBits = ONESTOPBIT; - state.Parity = NOPARITY; /* FIXME: correct default? */ - state.fBinary = TRUE; /* binary xfer */ - state.EofChar = 0; /* no end-of-data in binary mode */ - state.fNull = FALSE; /* don't discard nulls in binary mode */ - state.fParity = FALSE; /* ignore parity errors */ - state.fErrorChar = FALSE; - state.fTXContinueOnXoff = TRUE; /* separate TX and RX flow control */ - state.fOutX = FALSE; /* disable transmission flow control */ - state.fInX = FALSE; /* disable reception flow control */ - state.XonChar = 0x11; - state.XoffChar = 0x13; - state.fOutxDsrFlow = FALSE; /* disable DSR flow control */ - state.fRtsControl = RTS_CONTROL_ENABLE; /* ignore lead control except - DTR */ - state.fOutxCtsFlow = FALSE; /* disable output flow control */ - state.fDtrControl = DTR_CONTROL_ENABLE; /* assert DTR */ - state.fDsrSensitivity = FALSE; /* don't assert DSR */ - state.fAbortOnError = TRUE; - if (!SetCommState (get_handle (), &state)) - system_printf ("couldn't set initial state for %s, %E", get_name ()); - } - - SetCommMask (get_handle (), EV_RXCHAR); - set_open_status (); - syscall_printf ("%p = fhandler_serial::open (%s, %p, %p)", - res, get_name (), flags, mode); - return res; -} - -int -fhandler_serial::close () -{ - ForceCloseHandle (io_status.hEvent); - return fhandler_base::close (); -} - -/* tcsendbreak: POSIX 7.2.2.1 */ -/* Break for 250-500 milliseconds if duration == 0 */ -/* Otherwise, units for duration are undefined */ -int -fhandler_serial::tcsendbreak (int duration) -{ - unsigned int sleeptime = 300000; - - if (duration > 0) - sleeptime *= duration; - - if (SetCommBreak (get_handle ()) == 0) - return -1; - - /* FIXME: need to send zero bits during duration */ - usleep (sleeptime); - - if (ClearCommBreak (get_handle ()) == 0) - return -1; - - syscall_printf ("0 = fhandler_serial:tcsendbreak (%d)", duration); - - return 0; -} - -/* tcdrain: POSIX 7.2.2.1 */ -int -fhandler_serial::tcdrain () -{ - if (FlushFileBuffers (get_handle ()) == 0) - return -1; - - return 0; -} - -/* tcflow: POSIX 7.2.2.1 */ -int -fhandler_serial::tcflow (int action) -{ - DWORD win32action = 0; - DCB dcb; - char xchar; - - termios_printf ("action %d", action); - - switch (action) - { - case TCOOFF: - win32action = SETXOFF; - break; - case TCOON: - win32action = SETXON; - break; - case TCION: - case TCIOFF: - if (GetCommState (get_handle (), &dcb) == 0) - return -1; - if (action == TCION) - xchar = (dcb.XonChar ? dcb.XonChar : 0x11); - else - xchar = (dcb.XoffChar ? dcb.XoffChar : 0x13); - if (TransmitCommChar (get_handle (), xchar) == 0) - return -1; - return 0; - break; - default: - return -1; - break; - } - - if (EscapeCommFunction (get_handle (), win32action) == 0) - return -1; - - return 0; -} - - -/* switch_modem_lines: set or clear RTS and/or DTR */ -int -fhandler_serial::switch_modem_lines (int set, int clr) -{ - int res = 0; - - if (set & TIOCM_RTS) - { - if (EscapeCommFunction (get_handle (), SETRTS)) - rts = TIOCM_RTS; - else - { - __seterrno (); - res = -1; - } - } - else if (clr & TIOCM_RTS) - { - if (EscapeCommFunction (get_handle (), CLRRTS)) - rts = 0; - else - { - __seterrno (); - res = -1; - } - } - if (set & TIOCM_DTR) - { - if (EscapeCommFunction (get_handle (), SETDTR)) - rts = TIOCM_DTR; - else - { - __seterrno (); - res = -1; - } - } - else if (clr & TIOCM_DTR) - { - if (EscapeCommFunction (get_handle (), CLRDTR)) - rts = 0; - else - { - __seterrno (); - res = -1; - } - } - - return res; -} - -/* ioctl: */ -int -fhandler_serial::ioctl (unsigned int cmd, void *buffer) -{ - int res = 0; - -# define ibuffer ((int) buffer) -# define ipbuffer (*(int *) buffer) - - DWORD ev; - COMSTAT st; - if (!ClearCommError (get_handle (), &ev, &st)) - { - __seterrno (); - res = -1; - } - else - switch (cmd) - { - case TCFLSH: - res = tcflush (ibuffer); - break; - case TIOCMGET: - DWORD modem_lines; - if (!GetCommModemStatus (get_handle (), &modem_lines)) - { - __seterrno (); - res = -1; - } - else - { - ipbuffer = 0; - if (modem_lines & MS_CTS_ON) - ipbuffer |= TIOCM_CTS; - if (modem_lines & MS_DSR_ON) - ipbuffer |= TIOCM_DSR; - if (modem_lines & MS_RING_ON) - ipbuffer |= TIOCM_RI; - if (modem_lines & MS_RLSD_ON) - ipbuffer |= TIOCM_CD; - - DWORD cb; - DWORD mcr; - if (!DeviceIoControl (get_handle (), IOCTL_SERIAL_GET_DTRRTS, - NULL, 0, &mcr, 4, &cb, 0) || cb != 4) - ipbuffer |= rts | dtr; - else - { - if (mcr & 2) - ipbuffer |= TIOCM_RTS; - if (mcr & 1) - ipbuffer |= TIOCM_DTR; - } - } - break; - case TIOCMSET: - if (switch_modem_lines (ipbuffer, ~ipbuffer)) - res = -1; - break; - case TIOCMBIS: - if (switch_modem_lines (ipbuffer, 0)) - res = -1; - break; - case TIOCMBIC: - if (switch_modem_lines (0, ipbuffer)) - res = -1; - break; - case TIOCCBRK: - if (ClearCommBreak (get_handle ()) == 0) - { - __seterrno (); - res = -1; - } - break; - case TIOCSBRK: - if (SetCommBreak (get_handle ()) == 0) - { - __seterrno (); - res = -1; - } - break; - case TIOCINQ: - if (ev & CE_FRAME || ev & CE_IOE || ev & CE_OVERRUN || ev & CE_RXOVER - || ev & CE_RXPARITY) - { - set_errno (EINVAL); /* FIXME: Use correct errno */ - res = -1; - } - else - ipbuffer = st.cbInQue; - break; - case TIOCGWINSZ: - ((struct winsize *) buffer)->ws_row = 0; - ((struct winsize *) buffer)->ws_col = 0; - break; - default: - set_errno (ENOSYS); - res = -1; - break; - } - - termios_printf ("%d = ioctl (%p, %p)", res, cmd, buffer); -# undef ibuffer -# undef ipbuffer - return res; -} - -/* tcflush: POSIX 7.2.2.1 */ -int -fhandler_serial::tcflush (int queue) -{ - DWORD flags; - - switch (queue) - { - case TCOFLUSH: - flags = PURGE_TXABORT | PURGE_TXCLEAR; - break; - case TCIFLUSH: - flags = PURGE_RXABORT | PURGE_RXCLEAR; - break; - case TCIOFLUSH: - flags = PURGE_TXABORT | PURGE_TXCLEAR | PURGE_RXABORT | PURGE_RXCLEAR; - break; - default: - termios_printf ("Invalid tcflush queue %d", queue); - set_errno (EINVAL); - return -1; - } - - if (!PurgeComm (get_handle (), flags)) - { - __seterrno (); - return -1; - } - - return 0; -} - -/* tcsetattr: POSIX 7.2.1.1 */ -int -fhandler_serial::tcsetattr (int action, const struct termios *t) -{ - /* Possible actions: - TCSANOW: immediately change attributes. - TCSADRAIN: flush output, then change attributes. - TCSAFLUSH: flush output and discard input, then change attributes. - */ - - bool dropDTR = false; - COMMTIMEOUTS to; - DCB ostate, state; - unsigned int ovtime = vtime_, ovmin = vmin_; - int tmpDtr, tmpRts, res; - res = tmpDtr = tmpRts = 0; - - termios_printf ("action %d", action); - if ((action == TCSADRAIN) || (action == TCSAFLUSH)) - { - FlushFileBuffers (get_handle ()); - termios_printf ("flushed file buffers"); - } - if (action == TCSAFLUSH) - PurgeComm (get_handle (), (PURGE_RXABORT | PURGE_RXCLEAR)); - - /* get default/last comm state */ - if (!GetCommState (get_handle (), &ostate)) - return -1; - - state = ostate; - - /* -------------- Set baud rate ------------------ */ - /* FIXME: WIN32 also has 14400, 56000, 128000, and 256000. - Unix also has 230400. */ - - switch (t->c_ospeed) - { - case B0: - /* Drop DTR - but leave DCB-resident bitrate as-is since - 0 is an invalid bitrate in Win32 */ - dropDTR = true; - break; - case B110: - state.BaudRate = CBR_110; - break; - case B300: - state.BaudRate = CBR_300; - break; - case B600: - state.BaudRate = CBR_600; - break; - case B1200: - state.BaudRate = CBR_1200; - break; - case B2400: - state.BaudRate = CBR_2400; - break; - case B4800: - state.BaudRate = CBR_4800; - break; - case B9600: - state.BaudRate = CBR_9600; - break; - case B19200: - state.BaudRate = CBR_19200; - break; - case B38400: - state.BaudRate = CBR_38400; - break; - case B57600: - state.BaudRate = CBR_57600; - break; - case B115200: - state.BaudRate = CBR_115200; - break; - case B128000: - state.BaudRate = CBR_128000; - break; - case B230400: - state.BaudRate = 230400 /* CBR_230400 - not defined */; - break; - case B256000: - state.BaudRate = CBR_256000; - break; - case B460800: - state.BaudRate = 460800 /* CBR_460800 - not defined */; - break; - case B500000: - state.BaudRate = 500000 /* CBR_500000 - not defined */; - break; - case B576000: - state.BaudRate = 576000 /* CBR_576000 - not defined */; - break; - case B921600: - state.BaudRate = 921600 /* CBR_921600 - not defined */; - break; - case B1000000: - state.BaudRate = 1000000 /* CBR_1000000 - not defined */; - break; - case B1152000: - state.BaudRate = 1152000 /* CBR_1152000 - not defined */; - break; - case B1500000: - state.BaudRate = 1500000 /* CBR_1500000 - not defined */; - break; - case B2000000: - state.BaudRate = 2000000 /* CBR_2000000 - not defined */; - break; - case B2500000: - state.BaudRate = 2500000 /* CBR_2500000 - not defined */; - break; - case B3000000: - state.BaudRate = 3000000 /* CBR_3000000 - not defined */; - break; - default: - /* Unsupported baud rate! */ - termios_printf ("Invalid t->c_ospeed %d", t->c_ospeed); - set_errno (EINVAL); - return -1; - } - - /* -------------- Set byte size ------------------ */ - - switch (t->c_cflag & CSIZE) - { - case CS5: - state.ByteSize = 5; - break; - case CS6: - state.ByteSize = 6; - break; - case CS7: - state.ByteSize = 7; - break; - case CS8: - state.ByteSize = 8; - break; - default: - /* Unsupported byte size! */ - termios_printf ("Invalid t->c_cflag byte size %d", - t->c_cflag & CSIZE); - set_errno (EINVAL); - return -1; - } - - /* -------------- Set stop bits ------------------ */ - - if (t->c_cflag & CSTOPB) - state.StopBits = TWOSTOPBITS; - else - state.StopBits = ONESTOPBIT; - - /* -------------- Set parity ------------------ */ - - if (t->c_cflag & PARENB) - state.Parity = (t->c_cflag & PARODD) ? ODDPARITY : EVENPARITY; - else - state.Parity = NOPARITY; - - state.fBinary = TRUE; /* Binary transfer */ - state.EofChar = 0; /* No end-of-data in binary mode */ - state.fNull = FALSE; /* Don't discard nulls in binary mode */ - - /* -------------- Parity errors ------------------ */ - /* fParity combines the function of INPCK and NOT IGNPAR */ - - if ((t->c_iflag & INPCK) && !(t->c_iflag & IGNPAR)) - state.fParity = TRUE; /* detect parity errors */ - else - state.fParity = FALSE; /* ignore parity errors */ - - /* Only present in Win32, Unix has no equivalent */ - state.fErrorChar = FALSE; - state.ErrorChar = 0; - - /* -------------- Set software flow control ------------------ */ - /* Set fTXContinueOnXoff to FALSE. This prevents the triggering of a - premature XON when the remote device interprets a received character - as XON (same as IXANY on the remote side). Otherwise, a TRUE - value separates the TX and RX functions. */ - - state.fTXContinueOnXoff = TRUE; /* separate TX and RX flow control */ - - /* Transmission flow control */ - if (t->c_iflag & IXON) - state.fOutX = TRUE; /* enable */ - else - state.fOutX = FALSE; /* disable */ - - /* Reception flow control */ - if (t->c_iflag & IXOFF) - state.fInX = TRUE; /* enable */ - else - state.fInX = FALSE; /* disable */ - - /* XoffLim and XonLim are left at default values */ - - state.XonChar = (t->c_cc[VSTART] ? t->c_cc[VSTART] : 0x11); - state.XoffChar = (t->c_cc[VSTOP] ? t->c_cc[VSTOP] : 0x13); - - /* -------------- Set hardware flow control ------------------ */ - - /* Disable DSR flow control */ - state.fOutxDsrFlow = FALSE; - - /* Some old flavors of Unix automatically enabled hardware flow - control when software flow control was not enabled. Since newer - Unices tend to require explicit setting of hardware flow-control, - this is what we do. */ - - /* RTS/CTS flow control */ - if (t->c_cflag & CRTSCTS) - { /* enable */ - state.fOutxCtsFlow = TRUE; - state.fRtsControl = RTS_CONTROL_HANDSHAKE; - } - else - { /* disable */ - state.fRtsControl = RTS_CONTROL_ENABLE; - state.fOutxCtsFlow = FALSE; - tmpRts = TIOCM_RTS; - } - - if (t->c_cflag & CRTSXOFF) - state.fRtsControl = RTS_CONTROL_HANDSHAKE; - - /* -------------- DTR ------------------ */ - /* Assert DTR on device open */ - - state.fDtrControl = DTR_CONTROL_ENABLE; - - /* -------------- DSR ------------------ */ - /* Assert DSR at the device? */ - - if (t->c_cflag & CLOCAL) - state.fDsrSensitivity = FALSE; /* no */ - else - state.fDsrSensitivity = TRUE; /* yes */ - - /* -------------- Error handling ------------------ */ - /* Since read/write operations terminate upon error, we - will use ClearCommError() to resume. */ - - state.fAbortOnError = TRUE; - - if ((memcmp (&ostate, &state, sizeof (state)) != 0) - && !SetCommState (get_handle (), &state)) - { - /* SetCommState() failed, usually due to invalid DCB param. - Keep track of this so we can set errno to EINVAL later - and return failure */ - termios_printf ("SetCommState() failed, %E"); - __seterrno (); - res = -1; - } - - rbinary ((t->c_iflag & IGNCR) ? false : true); - wbinary ((t->c_oflag & ONLCR) ? false : true); - - if (dropDTR) - { - EscapeCommFunction (get_handle (), CLRDTR); - tmpDtr = 0; - } - else - { - /* FIXME: Sometimes when CLRDTR is set, setting - state.fDtrControl = DTR_CONTROL_ENABLE will fail. This - is a problem since a program might want to change some - parameters while DTR is still down. */ - - EscapeCommFunction (get_handle (), SETDTR); - tmpDtr = TIOCM_DTR; - } - - rts = tmpRts; - dtr = tmpDtr; - - /* The following documentation on was taken from "Linux Serial Programming - HOWTO". It explains how MIN (t->c_cc[VMIN] || vmin_) and TIME - (t->c_cc[VTIME] || vtime_) is to be used. - - In non-canonical input processing mode, input is not assembled into - lines and input processing (erase, kill, delete, etc.) does not - occur. Two parameters control the behavior of this mode: c_cc[VTIME] - sets the character timer, and c_cc[VMIN] sets the minimum number of - characters to receive before satisfying the read. - - If MIN > 0 and TIME = 0, MIN sets the number of characters to receive - before the read is satisfied. As TIME is zero, the timer is not used. - - If MIN = 0 and TIME > 0, TIME serves as a timeout value. The read will - be satisfied if a single character is read, or TIME is exceeded (t = - TIME *0.1 s). If TIME is exceeded, no character will be returned. - - If MIN > 0 and TIME > 0, TIME serves as an inter-character timer. The - read will be satisfied if MIN characters are received, or the time - between two characters exceeds TIME. The timer is restarted every time - a character is received and only becomes active after the first - character has been received. - - If MIN = 0 and TIME = 0, read will be satisfied immediately. The - number of characters currently available, or the number of characters - requested will be returned. According to Antonino (see contributions), - you could issue a fcntl(fd, F_SETFL, FNDELAY); before reading to get - the same result. - */ - - if (t->c_lflag & ICANON) - { - vmin_ = 0; - vtime_ = 0; - } - else - { - vtime_ = t->c_cc[VTIME] * 100; - vmin_ = t->c_cc[VMIN]; - } - - debug_printf ("vtime %d, vmin %d", vtime_, vmin_); - - if (ovmin != vmin_ || ovtime != vtime_) - { - memset (&to, 0, sizeof (to)); - - if ((vmin_ > 0) && (vtime_ == 0)) - { - /* Returns immediately with whatever is in buffer on a ReadFile(); - or blocks if nothing found. We will keep calling ReadFile(); until - vmin_ characters are read */ - to.ReadIntervalTimeout = to.ReadTotalTimeoutMultiplier = MAXDWORD; - to.ReadTotalTimeoutConstant = MAXDWORD - 1; - } - else if ((vmin_ == 0) && (vtime_ > 0)) - { - /* set timeoout constant appropriately and we will only try to - read one character in ReadFile() */ - to.ReadTotalTimeoutConstant = vtime_; - to.ReadIntervalTimeout = to.ReadTotalTimeoutMultiplier = MAXDWORD; - } - else if ((vmin_ > 0) && (vtime_ > 0)) - { - /* time applies to the interval time for this case */ - to.ReadIntervalTimeout = vtime_; - } - else if ((vmin_ == 0) && (vtime_ == 0)) - { - /* returns immediately with whatever is in buffer as per - Time-Outs docs in Win32 SDK API docs */ - to.ReadIntervalTimeout = MAXDWORD; - } - - debug_printf ("ReadTotalTimeoutConstant %d, ReadIntervalTimeout %d, ReadTotalTimeoutMultiplier %d", - to.ReadTotalTimeoutConstant, to.ReadIntervalTimeout, to.ReadTotalTimeoutMultiplier); - - if (!SetCommTimeouts(get_handle (), &to)) - { - /* SetCommTimeouts() failed. Keep track of this so we - can set errno to EINVAL later and return failure */ - termios_printf ("SetCommTimeouts() failed, %E"); - __seterrno (); - res = -1; - } - } - - return res; -} - -/* tcgetattr: POSIX 7.2.1.1 */ -int -fhandler_serial::tcgetattr (struct termios *t) -{ - DCB state; - - /* Get current Win32 comm state */ - if (GetCommState (get_handle (), &state) == 0) - return -1; - - /* for safety */ - memset (t, 0, sizeof (*t)); - - t->c_cflag = 0; - /* -------------- Baud rate ------------------ */ - switch (state.BaudRate) - { - case CBR_110: - t->c_ospeed = t->c_ispeed = B110; - break; - case CBR_300: - t->c_ospeed = t->c_ispeed = B300; - break; - case CBR_600: - t->c_ospeed = t->c_ispeed = B600; - break; - case CBR_1200: - t->c_ospeed = t->c_ispeed = B1200; - break; - case CBR_2400: - t->c_ospeed = t->c_ispeed = B2400; - break; - case CBR_4800: - t->c_ospeed = t->c_ispeed = B4800; - break; - case CBR_9600: - t->c_ospeed = t->c_ispeed = B9600; - break; - case CBR_19200: - t->c_ospeed = t->c_ispeed = B19200; - break; - case CBR_38400: - t->c_ospeed = t->c_ispeed = B38400; - break; - case CBR_57600: - t->c_ospeed = t->c_ispeed = B57600; - break; - case CBR_115200: - t->c_ospeed = t->c_ispeed = B115200; - break; - case CBR_128000: - t->c_ospeed = t->c_ispeed = B128000; - break; - case 230400: /* CBR_230400 - not defined */ - t->c_ospeed = t->c_ispeed = B230400; - break; - case CBR_256000: - t->c_ospeed = t->c_ispeed = B256000; - break; - case 460800: /* CBR_460000 - not defined */ - t->c_ospeed = t->c_ispeed = B460800; - break; - case 500000: /* CBR_500000 - not defined */ - t->c_ospeed = t->c_ispeed = B500000; - break; - case 576000: /* CBR_576000 - not defined */ - t->c_ospeed = t->c_ispeed = B576000; - break; - case 921600: /* CBR_921600 - not defined */ - t->c_ospeed = t->c_ispeed = B921600; - break; - case 1000000: /* CBR_1000000 - not defined */ - t->c_ospeed = t->c_ispeed = B1000000; - break; - case 1152000: /* CBR_1152000 - not defined */ - t->c_ospeed = t->c_ispeed = B1152000; - break; - case 1500000: /* CBR_1500000 - not defined */ - t->c_ospeed = t->c_ispeed = B1500000; - break; - case 2000000: /* CBR_2000000 - not defined */ - t->c_ospeed = t->c_ispeed = B2000000; - break; - case 2500000: /* CBR_2500000 - not defined */ - t->c_ospeed = t->c_ispeed = B2500000; - break; - case 3000000: /* CBR_3000000 - not defined */ - t->c_ospeed = t->c_ispeed = B3000000; - break; - default: - /* Unsupported baud rate! */ - termios_printf ("Invalid baud rate %d", state.BaudRate); - set_errno (EINVAL); - return -1; - } - - /* -------------- Byte size ------------------ */ - - switch (state.ByteSize) - { - case 5: - t->c_cflag |= CS5; - break; - case 6: - t->c_cflag |= CS6; - break; - case 7: - t->c_cflag |= CS7; - break; - case 8: - t->c_cflag |= CS8; - break; - default: - /* Unsupported byte size! */ - termios_printf ("Invalid byte size %d", state.ByteSize); - set_errno (EINVAL); - return -1; - } - - /* -------------- Stop bits ------------------ */ - - if (state.StopBits == TWOSTOPBITS) - t->c_cflag |= CSTOPB; - - /* -------------- Parity ------------------ */ - - if (state.Parity == ODDPARITY) - t->c_cflag |= (PARENB | PARODD); - if (state.Parity == EVENPARITY) - t->c_cflag |= PARENB; - - /* -------------- Parity errors ------------------ */ - - /* fParity combines the function of INPCK and NOT IGNPAR */ - if (state.fParity) - t->c_iflag |= INPCK; - else - t->c_iflag |= IGNPAR; /* not necessarily! */ - - /* -------------- Software flow control ------------------ */ - - /* transmission flow control */ - if (state.fOutX) - t->c_iflag |= IXON; - - /* reception flow control */ - if (state.fInX) - t->c_iflag |= IXOFF; - - t->c_cc[VSTART] = (state.XonChar ? state.XonChar : 0x11); - t->c_cc[VSTOP] = (state.XoffChar ? state.XoffChar : 0x13); - - /* -------------- Hardware flow control ------------------ */ - /* Some old flavors of Unix automatically enabled hardware flow - control when software flow control was not enabled. Since newer - Unices tend to require explicit setting of hardware flow-control, - this is what we do. */ - - /* Input flow-control */ - if ((state.fRtsControl == RTS_CONTROL_HANDSHAKE) && state.fOutxCtsFlow) - t->c_cflag |= CRTSCTS; - if (state.fRtsControl == RTS_CONTROL_HANDSHAKE) - t->c_cflag |= CRTSXOFF; - - /* -------------- CLOCAL --------------- */ - /* DSR is only lead toggled only by CLOCAL. Check it to see if - CLOCAL was called. */ - /* FIXME: If tcsetattr() hasn't been called previously, this may - give a false CLOCAL. */ - - if (!state.fDsrSensitivity) - t->c_cflag |= CLOCAL; - - /* FIXME: need to handle IGNCR */ -#if 0 - if (!rbinary ()) - t->c_iflag |= IGNCR; -#endif - - if (!wbinary ()) - t->c_oflag |= ONLCR; - - t->c_cc[VTIME] = vtime_ / 100; - t->c_cc[VMIN] = vmin_; - - debug_printf ("vmin_ %d, vtime_ %d", vmin_, vtime_); - - return 0; -} - -void -fhandler_serial::fixup_after_fork (HANDLE parent) -{ - if (close_on_exec ()) - fhandler_base::fixup_after_fork (parent); - overlapped_setup (); - debug_printf ("io_status.hEvent %p", io_status.hEvent); -} - -void -fhandler_serial::fixup_after_exec () -{ - if (!close_on_exec ()) - overlapped_setup (); - debug_printf ("io_status.hEvent %p, close_on_exec %d", io_status.hEvent, close_on_exec ()); -} - -int -fhandler_serial::dup (fhandler_base *child) -{ - fhandler_serial *fhc = (fhandler_serial *) child; - fhc->overlapped_setup (); - fhc->vmin_ = vmin_; - fhc->vtime_ = vtime_; - return fhandler_base::dup (child); -} diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc deleted file mode 100644 index 6f6ab31d2..000000000 --- a/winsup/cygwin/fhandler_socket.cc +++ /dev/null @@ -1,2100 +0,0 @@ -/* fhandler_socket.cc. See fhandler.h for a description of the fhandler classes. - - Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, - 2009, 2010 Red Hat, Inc. - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -/* #define DEBUG_NEST_ON 1 */ - -#define __INSIDE_CYGWIN_NET__ - -#include "winsup.h" -#include -#include - -#include -#define USE_SYS_TYPES_FD_SET -#include -#include -#include -#include "cygerrno.h" -#include "security.h" -#include "cygwin/version.h" -#include "perprocess.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "shared_info.h" -#include "sigproc.h" -#include "wininfo.h" -#include -#include -#include "cygtls.h" -#include "cygwin/in6.h" -#include "ntdll.h" - -#define ASYNC_MASK (FD_READ|FD_WRITE|FD_OOB|FD_ACCEPT|FD_CONNECT) -#define EVENT_MASK (FD_READ|FD_WRITE|FD_OOB|FD_ACCEPT|FD_CONNECT|FD_CLOSE) - -extern bool fdsock (cygheap_fdmanip& fd, const device *, SOCKET soc); -extern "C" { -int sscanf (const char *, const char *, ...); -} /* End of "C" section */ - -fhandler_dev_random* entropy_source; - -static inline mode_t -adjust_socket_file_mode (mode_t mode) -{ - /* Kludge: Don't allow to remove read bit on socket files for - user/group/other, if the accompanying write bit is set. It would - be nice to have exact permissions on a socket file, but it's - necessary that somebody able to access the socket can always read - the contents of the socket file to avoid spurious "permission - denied" messages. */ - return mode | ((mode & (S_IWUSR | S_IWGRP | S_IWOTH)) << 1); -} - -/* cygwin internal: map sockaddr into internet domain address */ -static int -get_inet_addr (const struct sockaddr *in, int inlen, - struct sockaddr_storage *out, int *outlen, - int *type = NULL, int *secret = NULL) -{ - int secret_buf [4]; - int* secret_ptr = (secret ? : secret_buf); - - if (in->sa_family == AF_INET || in->sa_family == AF_INET6) - { - memcpy (out, in, inlen); - *outlen = inlen; - return 1; - } - else if (in->sa_family == AF_LOCAL) - { - NTSTATUS status; - HANDLE fh; - OBJECT_ATTRIBUTES attr; - IO_STATUS_BLOCK io; - - path_conv pc (in->sa_data, PC_SYM_FOLLOW); - if (pc.error) - { - set_errno (pc.error); - return 0; - } - if (!pc.exists ()) - { - set_errno (ENOENT); - return 0; - } - if (!pc.issocket ()) - { - set_errno (EBADF); - return 0; - } - status = NtOpenFile (&fh, GENERIC_READ | SYNCHRONIZE, - pc.get_object_attr (attr, sec_none_nih), &io, - FILE_SHARE_VALID_FLAGS, - FILE_SYNCHRONOUS_IO_NONALERT - | FILE_OPEN_FOR_BACKUP_INTENT); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - return 0; - } - int ret = 0; - char buf[128]; - memset (buf, 0, sizeof buf); - status = NtReadFile (fh, NULL, NULL, NULL, &io, buf, 128, NULL, NULL); - NtClose (fh); - if (NT_SUCCESS (status)) - { - struct sockaddr_in sin; - char ctype; - sin.sin_family = AF_INET; - sscanf (buf + strlen (SOCKET_COOKIE), "%hu %c %08x-%08x-%08x-%08x", - &sin.sin_port, - &ctype, - secret_ptr, secret_ptr + 1, secret_ptr + 2, secret_ptr + 3); - sin.sin_port = htons (sin.sin_port); - sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK); - memcpy (out, &sin, sizeof sin); - *outlen = sizeof sin; - if (type) - *type = (ctype == 's' ? SOCK_STREAM : - ctype == 'd' ? SOCK_DGRAM - : 0); - ret = 1; - } - else - __seterrno_from_nt_status (status); - return ret; - } - else - { - set_errno (EAFNOSUPPORT); - return 0; - } -} - -/**********************************************************************/ -/* fhandler_socket */ - -fhandler_socket::fhandler_socket () : - fhandler_base (), - wsock_events (NULL), - wsock_mtx (NULL), - wsock_evt (NULL), - prot_info_ptr (NULL), - sun_path (NULL), - peer_sun_path (NULL), - status () -{ - need_fork_fixup (true); -} - -fhandler_socket::~fhandler_socket () -{ - if (prot_info_ptr) - cfree (prot_info_ptr); - if (sun_path) - cfree (sun_path); - if (peer_sun_path) - cfree (peer_sun_path); -} - -char * -fhandler_socket::get_proc_fd_name (char *buf) -{ - __small_sprintf (buf, "socket:[%d]", get_socket ()); - return buf; -} - -int -fhandler_socket::open (int flags, mode_t mode) -{ - set_errno (ENXIO); - return 0; -} - -void -fhandler_socket::af_local_set_sockpair_cred () -{ - sec_pid = sec_peer_pid = getpid (); - sec_uid = sec_peer_uid = geteuid32 (); - sec_gid = sec_peer_gid = getegid32 (); -} - -void -fhandler_socket::af_local_setblocking (bool &async, bool &nonblocking) -{ - async = async_io (); - nonblocking = is_nonblocking (); - if (async) - { - WSAAsyncSelect (get_socket (), winmsg, 0, 0); - WSAEventSelect (get_socket (), wsock_evt, EVENT_MASK); - } - set_nonblocking (false); - async_io (false); -} - -void -fhandler_socket::af_local_unsetblocking (bool async, bool nonblocking) -{ - if (nonblocking) - set_nonblocking (true); - if (async) - { - WSAAsyncSelect (get_socket (), winmsg, WM_ASYNCIO, ASYNC_MASK); - async_io (true); - } -} - -bool -fhandler_socket::af_local_recv_secret () -{ - int out[4] = { 0, 0, 0, 0 }; - int rest = sizeof out; - char *ptr = (char *) out; - while (rest > 0) - { - int ret = recvfrom (ptr, rest, 0, NULL, NULL); - if (ret <= 0) - break; - rest -= ret; - ptr += ret; - } - if (rest == 0) - { - debug_printf ("Received af_local secret: %08x-%08x-%08x-%08x", - out[0], out[1], out[2], out[3]); - if (out[0] != connect_secret[0] || out[1] != connect_secret[1] - || out[2] != connect_secret[2] || out[3] != connect_secret[3]) - { - debug_printf ("Receiving af_local secret mismatch"); - return false; - } - } - else - debug_printf ("Receiving af_local secret failed"); - return rest == 0; -} - -bool -fhandler_socket::af_local_send_secret () -{ - int rest = sizeof connect_secret; - char *ptr = (char *) connect_secret; - while (rest > 0) - { - int ret = sendto (ptr, rest, 0, NULL, 0); - if (ret <= 0) - break; - rest -= ret; - ptr += ret; - } - debug_printf ("Sending af_local secret %s", rest == 0 ? "succeeded" - : "failed"); - return rest == 0; -} - -bool -fhandler_socket::af_local_recv_cred () -{ - struct ucred out = { (pid_t) 0, (__uid32_t) -1, (__gid32_t) -1 }; - int rest = sizeof out; - char *ptr = (char *) &out; - while (rest > 0) - { - int ret = recvfrom (ptr, rest, 0, NULL, NULL); - if (ret <= 0) - break; - rest -= ret; - ptr += ret; - } - if (rest == 0) - { - debug_printf ("Received eid credentials: pid: %d, uid: %d, gid: %d", - out.pid, out.uid, out.gid); - sec_peer_pid = out.pid; - sec_peer_uid = out.uid; - sec_peer_gid = out.gid; - } - else - debug_printf ("Receiving eid credentials failed"); - return rest == 0; -} - -bool -fhandler_socket::af_local_send_cred () -{ - struct ucred in = { sec_pid, sec_uid, sec_gid }; - int rest = sizeof in; - char *ptr = (char *) ∈ - while (rest > 0) - { - int ret = sendto (ptr, rest, 0, NULL, 0); - if (ret <= 0) - break; - rest -= ret; - ptr += ret; - } - if (rest == 0) - debug_printf ("Sending eid credentials succeeded"); - else - debug_printf ("Sending eid credentials failed"); - return rest == 0; -} - -int -fhandler_socket::af_local_connect () -{ - /* This keeps the test out of select. */ - if (get_addr_family () != AF_LOCAL || get_socket_type () != SOCK_STREAM) - return 0; - - debug_printf ("af_local_connect called"); - bool orig_async_io, orig_is_nonblocking; - af_local_setblocking (orig_async_io, orig_is_nonblocking); - if (!af_local_send_secret () || !af_local_recv_secret () - || !af_local_send_cred () || !af_local_recv_cred ()) - { - debug_printf ("accept from unauthorized server"); - ::shutdown (get_socket (), SD_BOTH); - WSASetLastError (WSAECONNREFUSED); - return -1; - } - af_local_unsetblocking (orig_async_io, orig_is_nonblocking); - return 0; -} - -int -fhandler_socket::af_local_accept () -{ - debug_printf ("af_local_accept called"); - bool orig_async_io, orig_is_nonblocking; - af_local_setblocking (orig_async_io, orig_is_nonblocking); - if (!af_local_recv_secret () || !af_local_send_secret () - || !af_local_recv_cred () || !af_local_send_cred ()) - { - debug_printf ("connect from unauthorized client"); - ::shutdown (get_socket (), SD_BOTH); - ::closesocket (get_socket ()); - WSASetLastError (WSAECONNABORTED); - return -1; - } - af_local_unsetblocking (orig_async_io, orig_is_nonblocking); - return 0; -} - -void -fhandler_socket::af_local_set_cred () -{ - sec_pid = getpid (); - sec_uid = geteuid32 (); - sec_gid = getegid32 (); - sec_peer_pid = (pid_t) 0; - sec_peer_uid = (__uid32_t) -1; - sec_peer_gid = (__gid32_t) -1; -} - -void -fhandler_socket::af_local_copy (fhandler_socket *sock) -{ - sock->connect_secret[0] = connect_secret[0]; - sock->connect_secret[1] = connect_secret[1]; - sock->connect_secret[2] = connect_secret[2]; - sock->connect_secret[3] = connect_secret[3]; - sock->sec_pid = sec_pid; - sock->sec_uid = sec_uid; - sock->sec_gid = sec_gid; - sock->sec_peer_pid = sec_peer_pid; - sock->sec_peer_uid = sec_peer_uid; - sock->sec_peer_gid = sec_peer_gid; -} - -void -fhandler_socket::af_local_set_secret (char *buf) -{ - if (!entropy_source) - { - void *buf = malloc (sizeof (fhandler_dev_random)); - entropy_source = new (buf) fhandler_dev_random (); - entropy_source->dev () = *urandom_dev; - } - if (entropy_source && - !entropy_source->open (O_RDONLY)) - { - delete entropy_source; - entropy_source = NULL; - } - if (entropy_source) - { - size_t len = sizeof (connect_secret); - entropy_source->read (connect_secret, len); - if (len != sizeof (connect_secret)) - bzero ((char*) connect_secret, sizeof (connect_secret)); - } - __small_sprintf (buf, "%08x-%08x-%08x-%08x", - connect_secret [0], connect_secret [1], - connect_secret [2], connect_secret [3]); -} - -/* Maximum number of concurrently opened sockets from all Cygwin processes - per session. Note that shared sockets (through dup/fork/exec) are - counted as one socket. */ -#define NUM_SOCKS (32768 / sizeof (wsa_event)) - -#define LOCK_EVENTS WaitForSingleObject (wsock_mtx, INFINITE) -#define UNLOCK_EVENTS ReleaseMutex (wsock_mtx) - -static wsa_event wsa_events[NUM_SOCKS] __attribute__((section (".cygwin_dll_common"), shared)); - -static LONG socket_serial_number __attribute__((section (".cygwin_dll_common"), shared)); - -static HANDLE wsa_slot_mtx; - -static PWCHAR -sock_shared_name (PWCHAR buf, LONG num) -{ - __small_swprintf (buf, L"socket.%d", num); - return buf; -} - -static wsa_event * -search_wsa_event_slot (LONG new_serial_number) -{ - WCHAR name[32], searchname[32]; - UNICODE_STRING uname; - OBJECT_ATTRIBUTES attr; - NTSTATUS status; - - if (!wsa_slot_mtx) - { - RtlInitUnicodeString (&uname, sock_shared_name (name, 0)); - InitializeObjectAttributes (&attr, &uname, OBJ_INHERIT | OBJ_OPENIF, - get_session_parent_dir (), - everyone_sd (CYG_MUTANT_ACCESS)); - status = NtCreateMutant (&wsa_slot_mtx, CYG_MUTANT_ACCESS, &attr, FALSE); - if (!NT_SUCCESS (status)) - api_fatal ("Couldn't create/open shared socket mutex %S, %p", - &uname, status); - } - switch (WaitForSingleObject (wsa_slot_mtx, INFINITE)) - { - case WAIT_OBJECT_0: - case WAIT_ABANDONED: - break; - default: - api_fatal ("WFSO failed for shared socket mutex, %E"); - break; - } - unsigned int slot = new_serial_number % NUM_SOCKS; - while (wsa_events[slot].serial_number) - { - HANDLE searchmtx; - RtlInitUnicodeString (&uname, sock_shared_name (searchname, - wsa_events[slot].serial_number)); - InitializeObjectAttributes (&attr, &uname, 0, get_session_parent_dir (), - NULL); - status = NtOpenMutant (&searchmtx, READ_CONTROL, &attr); - if (!NT_SUCCESS (status)) - break; - /* Mutex still exists, attached socket is active, try next slot. */ - NtClose (searchmtx); - slot = (slot + 1) % NUM_SOCKS; - if (slot == (new_serial_number % NUM_SOCKS)) - { - /* Did the whole array once. Too bad. */ - debug_printf ("No free socket slot"); - ReleaseMutex (wsa_slot_mtx); - return NULL; - } - } - memset (&wsa_events[slot], 0, sizeof (wsa_event)); - wsa_events[slot].serial_number = new_serial_number; - ReleaseMutex (wsa_slot_mtx); - return wsa_events + slot; -} - -bool -fhandler_socket::init_events () -{ - LONG new_serial_number; - WCHAR name[32]; - UNICODE_STRING uname; - OBJECT_ATTRIBUTES attr; - NTSTATUS status; - - do - { - new_serial_number = - InterlockedIncrement (&socket_serial_number); - if (!new_serial_number) /* 0 is reserved for global mutex */ - InterlockedIncrement (&socket_serial_number); - RtlInitUnicodeString (&uname, sock_shared_name (name, new_serial_number)); - InitializeObjectAttributes (&attr, &uname, OBJ_INHERIT | OBJ_OPENIF, - get_session_parent_dir (), - everyone_sd (CYG_MUTANT_ACCESS)); - status = NtCreateMutant (&wsock_mtx, CYG_MUTANT_ACCESS, &attr, FALSE); - if (!NT_SUCCESS (status)) - { - debug_printf ("NtCreateMutant(%S), %p", &uname, status); - set_errno (ENOBUFS); - return false; - } - if (status == STATUS_OBJECT_NAME_EXISTS) - NtClose (wsock_mtx); - } - while (status == STATUS_OBJECT_NAME_EXISTS); - if ((wsock_evt = CreateEvent (&sec_all, TRUE, FALSE, NULL)) - == WSA_INVALID_EVENT) - { - debug_printf ("CreateEvent, %E"); - set_errno (ENOBUFS); - NtClose (wsock_mtx); - return false; - } - if (WSAEventSelect (get_socket (), wsock_evt, EVENT_MASK) == SOCKET_ERROR) - { - debug_printf ("WSAEventSelect, %E"); - set_winsock_errno (); - NtClose (wsock_evt); - NtClose (wsock_mtx); - return false; - } - wsock_events = search_wsa_event_slot (new_serial_number); - /* sock type not yet set here. */ - if (pc.dev == FH_UDP || pc.dev == FH_DGRAM) - wsock_events->events = FD_WRITE; - return true; -} - -int -fhandler_socket::evaluate_events (const long event_mask, long &events, - bool erase) -{ - int ret = 0; - long events_now = 0; - - WSANETWORKEVENTS evts = { 0 }; - if (!(WSAEnumNetworkEvents (get_socket (), wsock_evt, &evts))) - { - if (evts.lNetworkEvents) - { - LOCK_EVENTS; - wsock_events->events |= evts.lNetworkEvents; - events_now = (wsock_events->events & event_mask); - if (evts.lNetworkEvents & FD_CONNECT) - wsock_events->connect_errorcode = evts.iErrorCode[FD_CONNECT_BIT]; - UNLOCK_EVENTS; - if ((evts.lNetworkEvents & FD_OOB) && wsock_events->owner) - kill (wsock_events->owner, SIGURG); - } - } - - LOCK_EVENTS; - if ((events = events_now) != 0 - || (events = (wsock_events->events & event_mask)) != 0) - { - if (events & FD_CONNECT) - { - int wsa_err = 0; - if ((wsa_err = wsock_events->connect_errorcode) != 0) - { - WSASetLastError (wsa_err); - ret = SOCKET_ERROR; - } - else - wsock_events->events |= FD_WRITE; - wsock_events->events &= ~FD_CONNECT; - wsock_events->connect_errorcode = 0; - } - if (erase) - wsock_events->events &= ~(events & ~(FD_WRITE | FD_CLOSE)); - } - UNLOCK_EVENTS; - - return ret; -} - -int -fhandler_socket::wait_for_events (const long event_mask, bool dontwait) -{ - if (async_io ()) - return 0; - - int ret; - long events; - - while (!(ret = evaluate_events (event_mask, events, true)) && !events) - { - if (is_nonblocking () || dontwait) - { - WSASetLastError (WSAEWOULDBLOCK); - return SOCKET_ERROR; - } - - WSAEVENT ev[2] = { wsock_evt, signal_arrived }; - switch (WSAWaitForMultipleEvents (2, ev, FALSE, 50, FALSE)) - { - case WSA_WAIT_TIMEOUT: - case WSA_WAIT_EVENT_0: - break; - - case WSA_WAIT_EVENT_0 + 1: - if (_my_tls.call_signal_handler ()) - { - sig_dispatch_pending (); - break; - } - WSASetLastError (WSAEINTR); - return SOCKET_ERROR; - - default: - WSASetLastError (WSAEFAULT); - return SOCKET_ERROR; - } - } - - return ret; -} - -void -fhandler_socket::release_events () -{ - NtClose (wsock_evt); - NtClose (wsock_mtx); -} - -/* Called from net.cc:fdsock() if a freshly created socket is not - inheritable. In that case we use fixup_before_fork_exec. See - the comment in fdsock() for a description of the problem. */ -void -fhandler_socket::init_fixup_before () -{ - prot_info_ptr = (LPWSAPROTOCOL_INFOW) - cmalloc_abort (HEAP_BUF, sizeof (WSAPROTOCOL_INFOW)); - cygheap->fdtab.inc_need_fixup_before (); -} - -int -fhandler_socket::fixup_before_fork_exec (DWORD win_pid) -{ - SOCKET ret = WSADuplicateSocketW (get_socket (), win_pid, prot_info_ptr); - if (ret) - set_winsock_errno (); - else - debug_printf ("WSADuplicateSocket succeeded (%lx)", prot_info_ptr->dwProviderReserved); - return (int) ret; -} - -void -fhandler_socket::fixup_after_fork (HANDLE parent) -{ - fork_fixup (parent, wsock_mtx, "wsock_mtx"); - fork_fixup (parent, wsock_evt, "wsock_evt"); - - if (!need_fixup_before ()) - { - fhandler_base::fixup_after_fork (parent); - return; - } - - SOCKET new_sock = WSASocketW (FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, - FROM_PROTOCOL_INFO, prot_info_ptr, 0, - WSA_FLAG_OVERLAPPED); - if (new_sock == INVALID_SOCKET) - { - set_winsock_errno (); - set_io_handle ((HANDLE) INVALID_SOCKET); - } - else - { - /* Even though the original socket was not inheritable, the duplicated - socket is potentially inheritable again. */ - SetHandleInformation ((HANDLE) new_sock, HANDLE_FLAG_INHERIT, 0); - set_io_handle ((HANDLE) new_sock); - debug_printf ("WSASocket succeeded (%lx)", new_sock); - } -} - -void -fhandler_socket::fixup_after_exec () -{ - if (need_fixup_before () && !close_on_exec ()) - fixup_after_fork (NULL); -} - -int -fhandler_socket::dup (fhandler_base *child) -{ - debug_printf ("here"); - fhandler_socket *fhs = (fhandler_socket *) child; - - if (!DuplicateHandle (GetCurrentProcess (), wsock_mtx, - GetCurrentProcess (), &fhs->wsock_mtx, - 0, TRUE, DUPLICATE_SAME_ACCESS)) - { - __seterrno (); - return -1; - } - if (!DuplicateHandle (GetCurrentProcess (), wsock_evt, - GetCurrentProcess (), &fhs->wsock_evt, - 0, TRUE, DUPLICATE_SAME_ACCESS)) - { - __seterrno (); - NtClose (fhs->wsock_mtx); - return -1; - } - fhs->wsock_events = wsock_events; - - fhs->rmem (rmem ()); - fhs->wmem (wmem ()); - fhs->addr_family = addr_family; - fhs->set_socket_type (get_socket_type ()); - if (get_addr_family () == AF_LOCAL) - { - fhs->set_sun_path (get_sun_path ()); - fhs->set_peer_sun_path (get_peer_sun_path ()); - if (get_socket_type () == SOCK_STREAM) - { - fhs->sec_pid = sec_pid; - fhs->sec_uid = sec_uid; - fhs->sec_gid = sec_gid; - fhs->sec_peer_pid = sec_peer_pid; - fhs->sec_peer_uid = sec_peer_uid; - fhs->sec_peer_gid = sec_peer_gid; - } - } - fhs->connect_state (connect_state ()); - - if (!need_fixup_before ()) - { - int ret = fhandler_base::dup (child); - if (ret) - { - NtClose (fhs->wsock_evt); - NtClose (fhs->wsock_mtx); - } - return ret; - } - - cygheap->user.deimpersonate (); - fhs->init_fixup_before (); - fhs->set_io_handle (get_io_handle ()); - if (!fhs->fixup_before_fork_exec (GetCurrentProcessId ())) - { - cygheap->user.reimpersonate (); - fhs->fixup_after_fork (GetCurrentProcess ()); - if (fhs->get_io_handle() != (HANDLE) INVALID_SOCKET) - return 0; - } - cygheap->user.reimpersonate (); - cygheap->fdtab.dec_need_fixup_before (); - NtClose (fhs->wsock_evt); - NtClose (fhs->wsock_mtx); - return -1; -} - -int __stdcall -fhandler_socket::fstat (struct __stat64 *buf) -{ - int res; - if (get_device () == FH_UNIX) - { - res = fhandler_base::fstat_fs (buf); - if (!res) - { - buf->st_mode = (buf->st_mode & ~S_IFMT) | S_IFSOCK; - buf->st_size = 0; - } - } - else - { - res = fhandler_base::fstat (buf); - if (!res) - { - buf->st_dev = 0; - buf->st_ino = (__ino64_t) ((DWORD) get_handle ()); - buf->st_mode = S_IFSOCK | S_IRWXU | S_IRWXG | S_IRWXO; - buf->st_size = 0; - } - } - return res; -} - -int __stdcall -fhandler_socket::fstatvfs (struct statvfs *sfs) -{ - if (get_device () == FH_UNIX) - { - fhandler_disk_file fh (pc); - fh.get_device () = FH_FS; - return fh.fstatvfs (sfs); - } - set_errno (EBADF); - return -1; -} - -int -fhandler_socket::fchmod (mode_t mode) -{ - if (get_device () == FH_UNIX) - { - fhandler_disk_file fh (pc); - fh.get_device () = FH_FS; - int ret = fh.fchmod (S_IFSOCK | adjust_socket_file_mode (mode)); - return ret; - } - set_errno (EBADF); - return -1; -} - -int -fhandler_socket::fchown (__uid32_t uid, __gid32_t gid) -{ - if (get_device () == FH_UNIX) - { - fhandler_disk_file fh (pc); - return fh.fchown (uid, gid); - } - set_errno (EBADF); - return -1; -} - -int -fhandler_socket::facl (int cmd, int nentries, __aclent32_t *aclbufp) -{ - if (get_device () == FH_UNIX) - { - fhandler_disk_file fh (pc); - return fh.facl (cmd, nentries, aclbufp); - } - set_errno (EBADF); - return -1; -} - -int -fhandler_socket::link (const char *newpath) -{ - if (get_device () == FH_UNIX) - { - fhandler_disk_file fh (pc); - return fh.link (newpath); - } - return fhandler_base::link (newpath); -} - -static inline bool -address_in_use (const struct sockaddr *addr) -{ - switch (addr->sa_family) - { - case AF_INET: - { - PMIB_TCPTABLE tab; - PMIB_TCPROW entry; - DWORD size = 0, i; - struct sockaddr_in *in = (struct sockaddr_in *) addr; - - if (GetTcpTable (NULL, &size, FALSE) == ERROR_INSUFFICIENT_BUFFER) - { - tab = (PMIB_TCPTABLE) alloca (size += 16 * sizeof (PMIB_TCPROW)); - if (!GetTcpTable (tab, &size, FALSE)) - for (i = tab->dwNumEntries, entry = tab->table; i > 0; - --i, ++entry) - if (entry->dwLocalAddr == in->sin_addr.s_addr - && entry->dwLocalPort == in->sin_port - && entry->dwState >= MIB_TCP_STATE_LISTEN - && entry->dwState <= MIB_TCP_STATE_LAST_ACK) - return true; - } - } - break; - case AF_INET6: - { - /* This test works on XP SP2 and above which should cover almost - all IPv6 users... */ - PMIB_TCP6TABLE_OWNER_PID tab; - PMIB_TCP6ROW_OWNER_PID entry; - DWORD size = 0, i; - struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) addr; - - if (GetExtendedTcpTable (NULL, &size, FALSE, AF_INET6, - TCP_TABLE_OWNER_PID_ALL, 0) - == ERROR_INSUFFICIENT_BUFFER) - { - tab = (PMIB_TCP6TABLE_OWNER_PID) - alloca (size += 16 * sizeof (PMIB_TCP6ROW_OWNER_PID)); - if (!GetExtendedTcpTable (tab, &size, FALSE, AF_INET6, - TCP_TABLE_OWNER_PID_ALL, 0)) - for (i = tab->dwNumEntries, entry = tab->table; i > 0; - --i, ++entry) - if (IN6_ARE_ADDR_EQUAL (entry->ucLocalAddr, - in6->sin6_addr.s6_addr) - /* FIXME: Is testing for the scope required. too?!? */ - && entry->dwLocalPort == in6->sin6_port - && entry->dwState >= MIB_TCP_STATE_LISTEN - && entry->dwState <= MIB_TCP_STATE_LAST_ACK) - return true; - } - } - break; - default: - break; - } - return false; -} - -int -fhandler_socket::bind (const struct sockaddr *name, int namelen) -{ - int res = -1; - - if (name->sa_family == AF_LOCAL) - { -#define un_addr ((struct sockaddr_un *) name) - struct sockaddr_in sin; - int len = sizeof sin; - - if (strlen (un_addr->sun_path) >= UNIX_PATH_LEN) - { - set_errno (ENAMETOOLONG); - goto out; - } - sin.sin_family = AF_INET; - sin.sin_port = 0; - sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK); - if (::bind (get_socket (), (sockaddr *) &sin, len)) - { - syscall_printf ("AF_LOCAL: bind failed"); - set_winsock_errno (); - goto out; - } - if (::getsockname (get_socket (), (sockaddr *) &sin, &len)) - { - syscall_printf ("AF_LOCAL: getsockname failed"); - set_winsock_errno (); - goto out; - } - - sin.sin_port = ntohs (sin.sin_port); - debug_printf ("AF_LOCAL: socket bound to port %u", sin.sin_port); - - path_conv pc (un_addr->sun_path, PC_SYM_FOLLOW); - if (pc.error) - { - set_errno (pc.error); - goto out; - } - if (pc.exists ()) - { - set_errno (EADDRINUSE); - goto out; - } - mode_t mode = adjust_socket_file_mode ((S_IRWXU | S_IRWXG | S_IRWXO) - & ~cygheap->umask); - DWORD fattr = FILE_ATTRIBUTE_SYSTEM; - if (!(mode & (S_IWUSR | S_IWGRP | S_IWOTH))) - fattr |= FILE_ATTRIBUTE_READONLY; - SECURITY_ATTRIBUTES sa = sec_none_nih; - NTSTATUS status; - HANDLE fh; - OBJECT_ATTRIBUTES attr; - IO_STATUS_BLOCK io; - - status = NtCreateFile (&fh, DELETE | FILE_GENERIC_WRITE, - pc.get_object_attr (attr, sa), &io, NULL, fattr, - FILE_SHARE_VALID_FLAGS, FILE_CREATE, - FILE_NON_DIRECTORY_FILE - | FILE_SYNCHRONOUS_IO_NONALERT - | FILE_OPEN_FOR_BACKUP_INTENT, - NULL, 0); - if (!NT_SUCCESS (status)) - { - if (io.Information == FILE_EXISTS) - set_errno (EADDRINUSE); - else - __seterrno_from_nt_status (status); - } - else - { - if (pc.has_acls ()) - set_file_attribute (fh, pc, ILLEGAL_UID, ILLEGAL_GID, - S_JUSTCREATED | mode); - char buf[sizeof (SOCKET_COOKIE) + 80]; - __small_sprintf (buf, "%s%u %c ", SOCKET_COOKIE, sin.sin_port, - get_socket_type () == SOCK_STREAM ? 's' - : get_socket_type () == SOCK_DGRAM ? 'd' : '-'); - af_local_set_secret (strchr (buf, '\0')); - DWORD blen = strlen (buf) + 1; - status = NtWriteFile (fh, NULL, NULL, NULL, &io, buf, blen, NULL, 0); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - FILE_DISPOSITION_INFORMATION fdi = { TRUE }; - status = NtSetInformationFile (fh, &io, &fdi, sizeof fdi, - FileDispositionInformation); - if (!NT_SUCCESS (status)) - debug_printf ("Setting delete dispostion failed, status = %p", - status); - } - else - { - set_sun_path (un_addr->sun_path); - res = 0; - } - NtClose (fh); - } -#undef un_addr - } - else - { - /* If the application didn't explicitely call setsockopt (SO_REUSEADDR), - enforce exclusive local address use using the SO_EXCLUSIVEADDRUSE - socket option, to emulate POSIX socket behaviour more closely. - - KB 870562: Note that this option is only available since NT4 SP4. - Also note that a bug in Win2K SP1-3 and XP up to SP1 only enables - this option for users in the local administrators group. */ - if (wincap.has_exclusiveaddruse ()) - { - if (!saw_reuseaddr ()) - { - int on = 1; - int ret = ::setsockopt (get_socket (), SOL_SOCKET, - ~(SO_REUSEADDR), - (const char *) &on, sizeof on); - debug_printf ("%d = setsockopt (SO_EXCLUSIVEADDRUSE), %E", ret); - } - else if (!wincap.has_enhanced_socket_security ()) - { - debug_printf ("SO_REUSEADDR set"); - /* There's a bug in SO_REUSEADDR handling in WinSock. - Per standards, we must not be able to reuse a complete - duplicate of a local TCP address (same IP, same port), - even if SO_REUSEADDR has been set. That's unfortunately - possible in WinSock. - - So we're testing here if the local address is already in - use and don't bind, if so. This only works for OSes with - IP Helper support and is, of course, still prone to races. - - However, we don't have to do this on systems supporting - "enhanced socket security" (2K3 and later). On these - systems the default binding behaviour is exactly as you'd - expect for SO_REUSEADDR, while setting SO_REUSEADDR re-enables - the wrong behaviour. So all we have to do on these newer - systems is never to set SO_REUSEADDR but only to note that - it has been set for the above SO_EXCLUSIVEADDRUSE setting. - See setsockopt() in net.cc. */ - if (get_socket_type () == SOCK_STREAM - && wincap.has_ip_helper_lib () - && address_in_use (name)) - { - debug_printf ("Local address in use, don't bind"); - set_errno (EADDRINUSE); - goto out; - } - } - } - if (::bind (get_socket (), name, namelen)) - set_winsock_errno (); - else - res = 0; - } - -out: - return res; -} - -int -fhandler_socket::connect (const struct sockaddr *name, int namelen) -{ - int res = -1; - bool in_progress = false; - struct sockaddr_storage sst; - DWORD err; - int type; - - if (!get_inet_addr (name, namelen, &sst, &namelen, &type, connect_secret)) - return -1; - - if (get_addr_family () == AF_LOCAL && get_socket_type () != type) - { - WSASetLastError (WSAEPROTOTYPE); - set_winsock_errno (); - return -1; - } - - res = ::connect (get_socket (), (struct sockaddr *) &sst, namelen); - if (!is_nonblocking () - && res == SOCKET_ERROR - && WSAGetLastError () == WSAEWOULDBLOCK) - res = wait_for_events (FD_CONNECT | FD_CLOSE, false); - - if (!res) - err = 0; - else - { - err = WSAGetLastError (); - /* Special handling for connect to return the correct error code - when called on a non-blocking socket. */ - if (is_nonblocking ()) - { - if (err == WSAEWOULDBLOCK || err == WSAEALREADY) - in_progress = true; - - if (err == WSAEWOULDBLOCK) - WSASetLastError (err = WSAEINPROGRESS); - } - if (err == WSAEINVAL) - WSASetLastError (err = WSAEISCONN); - set_winsock_errno (); - } - - if (get_addr_family () == AF_LOCAL && (!res || in_progress)) - set_peer_sun_path (name->sa_data); - - if (get_addr_family () == AF_LOCAL && get_socket_type () == SOCK_STREAM) - { - af_local_set_cred (); /* Don't move into af_local_connect since - af_local_connect is called from select, - possibly running under another identity. */ - if (!res && af_local_connect ()) - { - set_winsock_errno (); - return -1; - } - } - - if (err == WSAEINPROGRESS || err == WSAEALREADY) - connect_state (connect_pending); - else if (err) - connect_state (connect_failed); - else - connect_state (connected); - - return res; -} - -int -fhandler_socket::listen (int backlog) -{ - int res = ::listen (get_socket (), backlog); - if (res && WSAGetLastError () == WSAEINVAL) - { - /* It's perfectly valid to call listen on an unbound INET socket. - In this case the socket is automatically bound to an unused - port number, listening on all interfaces. On Winsock, listen - fails with WSAEINVAL when it's called on an unbound socket. - So we have to bind manually here to have POSIX semantics. */ - if (get_addr_family () == AF_INET) - { - struct sockaddr_in sin; - sin.sin_family = AF_INET; - sin.sin_port = 0; - sin.sin_addr.s_addr = INADDR_ANY; - if (!::bind (get_socket (), (struct sockaddr *) &sin, sizeof sin)) - res = ::listen (get_socket (), backlog); - } - else if (get_addr_family () == AF_INET6) - { - struct sockaddr_in6 sin6 = - { - sin6_family: AF_INET6, - sin6_port: 0, - sin6_flowinfo: 0, - sin6_addr: {{IN6ADDR_ANY_INIT}}, - sin6_scope_id: 0 - }; - if (!::bind (get_socket (), (struct sockaddr *) &sin6, sizeof sin6)) - res = ::listen (get_socket (), backlog); - } - } - if (!res) - { - if (get_addr_family () == AF_LOCAL && get_socket_type () == SOCK_STREAM) - af_local_set_cred (); - connect_state (connected); - listener (true); - } - else - set_winsock_errno (); - return res; -} - -int -fhandler_socket::accept4 (struct sockaddr *peer, int *len, int flags) -{ - /* Allows NULL peer and len parameters. */ - struct sockaddr_storage lpeer; - int llen = sizeof (struct sockaddr_storage); - - int res = 0; - while (!(res = wait_for_events (FD_ACCEPT | FD_CLOSE, false)) - && (res = ::accept (get_socket (), (struct sockaddr *) &lpeer, &llen)) - == SOCKET_ERROR - && WSAGetLastError () == WSAEWOULDBLOCK) - ; - if (res == (int) INVALID_SOCKET) - set_winsock_errno (); - else - { - cygheap_fdnew res_fd; - if (res_fd >= 0 && fdsock (res_fd, &dev (), res)) - { - fhandler_socket *sock = (fhandler_socket *) res_fd; - sock->set_addr_family (get_addr_family ()); - sock->set_socket_type (get_socket_type ()); - sock->async_io (false); /* fdsock switches async mode off. */ - if (get_addr_family () == AF_LOCAL) - { - sock->set_sun_path (get_sun_path ()); - sock->set_peer_sun_path (get_peer_sun_path ()); - if (get_socket_type () == SOCK_STREAM) - { - /* Don't forget to copy credentials from accepting - socket to accepted socket and start transaction - on accepted socket! */ - af_local_copy (sock); - res = sock->af_local_accept (); - if (res == -1) - { - res_fd.release (); - set_winsock_errno (); - goto out; - } - } - } - sock->set_nonblocking (flags & SOCK_NONBLOCK); - if (flags & SOCK_CLOEXEC) - sock->set_close_on_exec (true); - /* No locking necessary at this point. */ - sock->wsock_events->events = wsock_events->events | FD_WRITE; - sock->wsock_events->owner = wsock_events->owner; - sock->connect_state (connected); - res = res_fd; - if (peer) - { - if (get_addr_family () == AF_LOCAL) - { - /* FIXME: Right now we have no way to determine the - bound socket name of the peer's socket. For now - we just fake an unbound socket on the other side. */ - static struct sockaddr_un un = { AF_LOCAL, "" }; - memcpy (peer, &un, min (*len, (int) sizeof (un.sun_family))); - *len = (int) sizeof (un.sun_family); - } - else - { - memcpy (peer, &lpeer, min (*len, llen)); - *len = llen; - } - } - } - else - { - closesocket (res); - res = -1; - } - } - -out: - debug_printf ("res %d", res); - return res; -} - -int -fhandler_socket::getsockname (struct sockaddr *name, int *namelen) -{ - int res = -1; - - if (get_addr_family () == AF_LOCAL) - { - struct sockaddr_un sun; - sun.sun_family = AF_LOCAL; - sun.sun_path[0] = '\0'; - if (get_sun_path ()) - strncat (sun.sun_path, get_sun_path (), UNIX_PATH_LEN - 1); - memcpy (name, &sun, min (*namelen, (int) SUN_LEN (&sun) + 1)); - *namelen = (int) SUN_LEN (&sun) + (get_sun_path () ? 1 : 0); - res = 0; - } - else - { - /* Always use a local big enough buffer and truncate later as necessary - per POSIX. WinSock unfortunaltey only returns WSAEFAULT if the buffer - is too small. */ - struct sockaddr_storage sock; - int len = sizeof sock; - res = ::getsockname (get_socket (), (struct sockaddr *) &sock, &len); - if (!res) - { - memcpy (name, &sock, min (*namelen, len)); - *namelen = len; - } - else - { - if (WSAGetLastError () == WSAEINVAL) - { - /* Winsock returns WSAEINVAL if the socket is locally - unbound. Per SUSv3 this is not an error condition. - We're faking a valid return value here by creating the - same content in the sockaddr structure as on Linux. */ - memset (&sock, 0, sizeof sock); - sock.ss_family = get_addr_family (); - switch (get_addr_family ()) - { - case AF_INET: - res = 0; - len = (int) sizeof (struct sockaddr_in); - break; - case AF_INET6: - res = 0; - len = (int) sizeof (struct sockaddr_in6); - break; - default: - WSASetLastError (WSAEOPNOTSUPP); - break; - } - if (!res) - { - memcpy (name, &sock, min (*namelen, len)); - *namelen = len; - } - } - if (res) - set_winsock_errno (); - } - } - - return res; -} - -int -fhandler_socket::getpeername (struct sockaddr *name, int *namelen) -{ - /* Always use a local big enough buffer and truncate later as necessary - per POSIX. WinSock unfortunately only returns WSAEFAULT if the buffer - is too small. */ - struct sockaddr_storage sock; - int len = sizeof sock; - int res = ::getpeername (get_socket (), (struct sockaddr *) &sock, &len); - if (res) - set_winsock_errno (); - else if (get_addr_family () == AF_LOCAL) - { - struct sockaddr_un sun; - memset (&sun, 0, sizeof sun); - sun.sun_family = AF_LOCAL; - sun.sun_path[0] = '\0'; - if (get_peer_sun_path ()) - strncat (sun.sun_path, get_peer_sun_path (), UNIX_PATH_LEN - 1); - memcpy (name, &sun, min (*namelen, (int) SUN_LEN (&sun) + 1)); - *namelen = (int) SUN_LEN (&sun) + (get_peer_sun_path () ? 1 : 0); - } - else - { - memcpy (name, &sock, min (*namelen, len)); - *namelen = len; - } - - return res; -} - -int -fhandler_socket::readv (const struct iovec *const iov, const int iovcnt, - ssize_t tot) -{ - struct msghdr msg = - { - msg_name: NULL, - msg_namelen: 0, - msg_iov: (struct iovec *) iov, // const_cast - msg_iovlen: iovcnt, - msg_control: NULL, - msg_controllen: 0, - msg_flags: 0 - }; - - return recvmsg (&msg, 0); -} - -extern "C" { -#define WSAID_WSARECVMSG \ - {0xf689d7c8,0x6f1f,0x436b,{0x8a,0x53,0xe5,0x4f,0xe3,0x51,0xc3,0x22}}; -typedef int (WSAAPI *LPFN_WSARECVMSG)(SOCKET,LPWSAMSG,LPDWORD,LPWSAOVERLAPPED, - LPWSAOVERLAPPED_COMPLETION_ROUTINE); -int WSAAPI WSASendMsg(SOCKET,LPWSAMSG,DWORD,LPDWORD, LPWSAOVERLAPPED, - LPWSAOVERLAPPED_COMPLETION_ROUTINE); -}; - -/* There's no DLL which exports the symbol WSARecvMsg. One has to call - WSAIoctl as below to fetch the function pointer. Why on earth did the - MS developers decide not to export a normal symbol for these extension - functions? */ -inline int -get_ext_funcptr (SOCKET sock, void *funcptr) -{ - DWORD bret; - const GUID guid = WSAID_WSARECVMSG; - return WSAIoctl (sock, SIO_GET_EXTENSION_FUNCTION_POINTER, - (void *) &guid, sizeof (GUID), funcptr, sizeof (void *), - &bret, NULL, NULL); -} - -inline ssize_t -fhandler_socket::recv_internal (LPWSAMSG wsamsg) -{ - ssize_t res = 0; - DWORD ret = 0, wret; - int evt_mask = FD_READ | ((wsamsg->dwFlags & MSG_OOB) ? FD_OOB : 0); - LPWSABUF &wsabuf = wsamsg->lpBuffers; - ULONG &wsacnt = wsamsg->dwBufferCount; - bool use_recvmsg = false; - static NO_COPY LPFN_WSARECVMSG WSARecvMsg; - - bool waitall = !!(wsamsg->dwFlags & MSG_WAITALL); - bool dontwait = !!(wsamsg->dwFlags & MSG_DONTWAIT); - wsamsg->dwFlags &= (MSG_OOB | MSG_PEEK | MSG_DONTROUTE); - if (wsamsg->Control.len > 0) - { - if (!WSARecvMsg - && get_ext_funcptr (get_socket (), &WSARecvMsg) == SOCKET_ERROR) - { - set_winsock_errno (); - return SOCKET_ERROR; - } - use_recvmsg = true; - } - if (waitall) - { - if (get_socket_type () != SOCK_STREAM) - { - WSASetLastError (WSAEOPNOTSUPP); - set_winsock_errno (); - return SOCKET_ERROR; - } - if (is_nonblocking () || (wsamsg->dwFlags & (MSG_OOB | MSG_PEEK))) - waitall = false; - } - - /* Note: Don't call WSARecvFrom(MSG_PEEK) without actually having data - waiting in the buffers, otherwise the event handling gets messed up - for some reason. */ - while (!(res = wait_for_events (evt_mask | FD_CLOSE, dontwait)) - || saw_shutdown_read ()) - { - if (use_recvmsg) - res = WSARecvMsg (get_socket (), wsamsg, &wret, NULL, NULL); - /* This is working around a really weird problem in WinSock. - - Assume you create a socket, fork the process (thus duplicating - the socket), connect the socket in the child, then call recv - on the original socket handle in the parent process. - In this scenario, calls to WinSock's recvfrom and WSARecvFrom - in the parent will fail with WSAEINVAL, regardless whether both - address parameters, name and namelen, are NULL or point to valid - storage. However, calls to recv and WSARecv succeed as expected. - Per MSDN, WSAEINVAL in the context of recv means "The socket has not - been bound". It is as if the recvfrom functions test if the socket - is bound locally, but in the parent process, WinSock doesn't know - about that and fails, while the same test is omitted in the recv - functions. - - This also covers another weird case: Winsock returns WSAEFAULT if - namelen is a valid pointer while name is NULL. Both parameters are - ignored for TCP sockets, so this only occurs when using UDP socket. */ - else if (!wsamsg->name || get_socket_type () == SOCK_STREAM) - res = WSARecv (get_socket (), wsabuf, wsacnt, &wret, &wsamsg->dwFlags, - NULL, NULL); - else - res = WSARecvFrom (get_socket (), wsabuf, wsacnt, &wret, - &wsamsg->dwFlags, wsamsg->name, &wsamsg->namelen, - NULL, NULL); - if (!res) - { - ret += wret; - if (!waitall) - break; - while (wret && wsacnt) - { - if (wsabuf->len > wret) - { - wsabuf->len -= wret; - wsabuf->buf += wret; - wret = 0; - } - else - { - wret -= wsabuf->len; - ++wsabuf; - --wsacnt; - } - } - if (!wret) - break; - } - else if (WSAGetLastError () != WSAEWOULDBLOCK) - break; - } - - if (res) - { - /* According to SUSv3, errno isn't set in that case and no error - condition is returned. */ - if (WSAGetLastError () == WSAEMSGSIZE) - return ret + wret; - - if (!ret) - { - /* ESHUTDOWN isn't defined for recv in SUSv3. Simply EOF is returned - in this case. */ - if (WSAGetLastError () == WSAESHUTDOWN) - return 0; - - set_winsock_errno (); - return SOCKET_ERROR; - } - } - - return ret; -} - -ssize_t -fhandler_socket::recvfrom (void *ptr, size_t len, int flags, - struct sockaddr *from, int *fromlen) -{ - WSABUF wsabuf = { len, (char *) ptr }; - WSAMSG wsamsg = { from, from && fromlen ? *fromlen : 0, - &wsabuf, 1, - { 0, NULL}, - flags }; - ssize_t ret = recv_internal (&wsamsg); - if (fromlen) - *fromlen = wsamsg.namelen; - return ret; -} - -ssize_t -fhandler_socket::recvmsg (struct msghdr *msg, int flags) -{ - /* TODO: Descriptor passing on AF_LOCAL sockets. */ - - /* Disappointing but true: Even if WSARecvMsg is supported, it's only - supported for datagram and raw sockets. */ - if (!wincap.has_recvmsg () || get_socket_type () == SOCK_STREAM - || get_addr_family () == AF_LOCAL) - { - msg->msg_controllen = 0; - if (!CYGWIN_VERSION_CHECK_FOR_USING_ANCIENT_MSGHDR) - msg->msg_flags = 0; - } - - WSABUF wsabuf[msg->msg_iovlen]; - WSABUF *wsaptr = wsabuf + msg->msg_iovlen; - const struct iovec *iovptr = msg->msg_iov + msg->msg_iovlen; - while (--wsaptr >= wsabuf) - { - wsaptr->len = (--iovptr)->iov_len; - wsaptr->buf = (char *) iovptr->iov_base; - } - WSAMSG wsamsg = { (struct sockaddr *) msg->msg_name, msg->msg_namelen, - wsabuf, msg->msg_iovlen, - { msg->msg_controllen, (char *) msg->msg_control }, - flags }; - ssize_t ret = recv_internal (&wsamsg); - if (ret >= 0) - { - msg->msg_namelen = wsamsg.namelen; - msg->msg_controllen = wsamsg.Control.len; - if (!CYGWIN_VERSION_CHECK_FOR_USING_ANCIENT_MSGHDR) - msg->msg_flags = wsamsg.dwFlags; - } - return ret; -} - -int -fhandler_socket::writev (const struct iovec *const iov, const int iovcnt, - ssize_t tot) -{ - struct msghdr msg = - { - msg_name: NULL, - msg_namelen: 0, - msg_iov: (struct iovec *) iov, // const_cast - msg_iovlen: iovcnt, - msg_control: NULL, - msg_controllen: 0, - msg_flags: 0 - }; - - return sendmsg (&msg, 0); -} - -inline ssize_t -fhandler_socket::send_internal (struct _WSAMSG *wsamsg, int flags) -{ - int res = 0; - DWORD ret = 0, err = 0, sum = 0, off = 0; - WSABUF buf; - bool use_sendmsg = false; - bool dontwait = !!(flags & MSG_DONTWAIT); - bool nosignal = !(flags & MSG_NOSIGNAL); - - flags &= (MSG_OOB | MSG_DONTROUTE); - if (wsamsg->Control.len > 0) - use_sendmsg = true; - for (DWORD i = 0; i < wsamsg->dwBufferCount; - off >= wsamsg->lpBuffers[i].len && (++i, off = 0)) - { - /* CV 2009-12-02: Don't split datagram messages. */ - /* FIXME: Look for a way to split a message into the least number of - pieces to minimize the number of WsaSendTo calls. */ - if (get_socket_type () == SOCK_STREAM) - { - buf.buf = wsamsg->lpBuffers[i].buf + off; - buf.len = wsamsg->lpBuffers[i].len - off; - /* See net.cc:fdsock() and MSDN KB 823764 */ - if (buf.len >= (unsigned) wmem ()) - buf.len = (unsigned) wmem (); - } - - do - { - if (use_sendmsg) - res = WSASendMsg (get_socket (), wsamsg, flags, &ret, NULL, NULL); - else if (get_socket_type () == SOCK_STREAM) - res = WSASendTo (get_socket (), &buf, 1, &ret, flags, - wsamsg->name, wsamsg->namelen, NULL, NULL); - else - res = WSASendTo (get_socket (), wsamsg->lpBuffers, - wsamsg->dwBufferCount, &ret, flags, - wsamsg->name, wsamsg->namelen, NULL, NULL); - if (res && (err = WSAGetLastError ()) == WSAEWOULDBLOCK) - { - LOCK_EVENTS; - wsock_events->events &= ~FD_WRITE; - UNLOCK_EVENTS; - } - } - while (res && err == WSAEWOULDBLOCK - && !(res = wait_for_events (FD_WRITE | FD_CLOSE, dontwait))); - - if (!res) - { - off += ret; - sum += ret; - if (get_socket_type () != SOCK_STREAM) - break; - } - else if (is_nonblocking () || err != WSAEWOULDBLOCK) - break; - } - - if (sum) - res = sum; - else if (res == SOCKET_ERROR) - { - set_winsock_errno (); - - /* Special handling for EPIPE and SIGPIPE. - - EPIPE is generated if the local end has been shut down on a connection - oriented socket. In this case the process will also receive a SIGPIPE - unless MSG_NOSIGNAL is set. */ - if (get_errno () == ESHUTDOWN && get_socket_type () == SOCK_STREAM) - { - set_errno (EPIPE); - if (!nosignal) - raise (SIGPIPE); - } - } - - return res; -} - -ssize_t -fhandler_socket::sendto (const void *ptr, size_t len, int flags, - const struct sockaddr *to, int tolen) -{ - struct sockaddr_storage sst; - - if (to && !get_inet_addr (to, tolen, &sst, &tolen)) - return SOCKET_ERROR; - - WSABUF wsabuf = { len, (char *) ptr }; - WSAMSG wsamsg = { to ? (struct sockaddr *) &sst : NULL, tolen, - &wsabuf, 1, - { 0, NULL}, - 0 }; - return send_internal (&wsamsg, flags); -} - -int -fhandler_socket::sendmsg (const struct msghdr *msg, int flags) -{ - /* TODO: Descriptor passing on AF_LOCAL sockets. */ - - WSABUF wsabuf[msg->msg_iovlen]; - WSABUF *wsaptr = wsabuf; - const struct iovec *iovptr = msg->msg_iov; - for (int i = 0; i < msg->msg_iovlen; ++i) - { - wsaptr->len = iovptr->iov_len; - (wsaptr++)->buf = (char *) (iovptr++)->iov_base; - } - WSAMSG wsamsg = { (struct sockaddr *) msg->msg_name, msg->msg_namelen, - wsabuf, msg->msg_iovlen, - /* Disappointing but true: Even if WSASendMsg is - supported, it's only supported for datagram and - raw sockets. */ - { !wincap.has_sendmsg () - || get_socket_type () == SOCK_STREAM - || get_addr_family () == AF_LOCAL - ? 0 : msg->msg_controllen, (char *) msg->msg_control }, - 0 }; - return send_internal (&wsamsg, flags); -} - -int -fhandler_socket::shutdown (int how) -{ - int res = ::shutdown (get_socket (), how); - - if (res) - set_winsock_errno (); - else - switch (how) - { - case SHUT_RD: - saw_shutdown_read (true); - break; - case SHUT_WR: - saw_shutdown_write (true); - break; - case SHUT_RDWR: - saw_shutdown_read (true); - saw_shutdown_write (true); - break; - } - return res; -} - -int -fhandler_socket::close () -{ - int res = 0; - /* TODO: CV - 2008-04-16. Lingering disabled. The original problem - could be no longer reproduced on NT4, XP, 2K8. Any return of a - spurious "Connection reset by peer" *could* be caused by disabling - the linger code here... */ -#if 0 - /* HACK to allow a graceful shutdown even if shutdown() hasn't been - called by the application. Note that this isn't the ultimate - solution but it helps in many cases. */ - struct linger linger; - linger.l_onoff = 1; - linger.l_linger = 240; /* secs. default 2MSL value according to MSDN. */ - setsockopt (get_socket (), SOL_SOCKET, SO_LINGER, - (const char *)&linger, sizeof linger); -#endif - release_events (); - while ((res = closesocket (get_socket ())) != 0) - { - if (WSAGetLastError () != WSAEWOULDBLOCK) - { - set_winsock_errno (); - res = -1; - break; - } - if (WaitForSingleObject (signal_arrived, 10) == WAIT_OBJECT_0) - { - set_errno (EINTR); - res = -1; - break; - } - WSASetLastError (0); - } - - debug_printf ("%d = fhandler_socket::close()", res); - return res; -} - -/* Definitions of old ifreq stuff used prior to Cygwin 1.7.0. */ -#define OLD_SIOCGIFFLAGS _IOW('s', 101, struct __old_ifreq) -#define OLD_SIOCGIFADDR _IOW('s', 102, struct __old_ifreq) -#define OLD_SIOCGIFBRDADDR _IOW('s', 103, struct __old_ifreq) -#define OLD_SIOCGIFNETMASK _IOW('s', 104, struct __old_ifreq) -#define OLD_SIOCGIFHWADDR _IOW('s', 105, struct __old_ifreq) -#define OLD_SIOCGIFMETRIC _IOW('s', 106, struct __old_ifreq) -#define OLD_SIOCGIFMTU _IOW('s', 107, struct __old_ifreq) -#define OLD_SIOCGIFINDEX _IOW('s', 108, struct __old_ifreq) - -#define CONV_OLD_TO_NEW_SIO(old) (((old)&0xff00ffff)|(((long)sizeof(struct ifreq)&IOCPARM_MASK)<<16)) - -struct __old_ifreq { -#define __OLD_IFNAMSIZ 16 - union { - char ifrn_name[__OLD_IFNAMSIZ]; /* if name, e.g. "en0" */ - } ifr_ifrn; - - union { - struct sockaddr ifru_addr; - struct sockaddr ifru_broadaddr; - struct sockaddr ifru_netmask; - struct sockaddr ifru_hwaddr; - short ifru_flags; - int ifru_metric; - int ifru_mtu; - int ifru_ifindex; - } ifr_ifru; -}; - -int -fhandler_socket::ioctl (unsigned int cmd, void *p) -{ - extern int get_ifconf (struct ifconf *ifc, int what); /* net.cc */ - int res; - struct ifconf ifc, *ifcp; - struct ifreq *ifrp; - - switch (cmd) - { - case SIOCGIFCONF: - ifcp = (struct ifconf *) p; - if (!ifcp) - { - set_errno (EINVAL); - return -1; - } - if (CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ) - { - ifc.ifc_len = ifcp->ifc_len / sizeof (struct __old_ifreq) - * sizeof (struct ifreq); - ifc.ifc_buf = (caddr_t) alloca (ifc.ifc_len); - } - else - { - ifc.ifc_len = ifcp->ifc_len; - ifc.ifc_buf = ifcp->ifc_buf; - } - res = get_ifconf (&ifc, cmd); - if (res) - debug_printf ("error in get_ifconf"); - if (CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ) - { - struct __old_ifreq *ifr = (struct __old_ifreq *) ifcp->ifc_buf; - for (ifrp = ifc.ifc_req; - (caddr_t) ifrp < ifc.ifc_buf + ifc.ifc_len; - ++ifrp, ++ifr) - { - memcpy (&ifr->ifr_ifrn, &ifrp->ifr_ifrn, sizeof ifr->ifr_ifrn); - ifr->ifr_name[__OLD_IFNAMSIZ - 1] = '\0'; - memcpy (&ifr->ifr_ifru, &ifrp->ifr_ifru, sizeof ifr->ifr_ifru); - } - ifcp->ifc_len = ifc.ifc_len / sizeof (struct ifreq) - * sizeof (struct __old_ifreq); - } - else - ifcp->ifc_len = ifc.ifc_len; - break; - case OLD_SIOCGIFFLAGS: - case OLD_SIOCGIFADDR: - case OLD_SIOCGIFBRDADDR: - case OLD_SIOCGIFNETMASK: - case OLD_SIOCGIFHWADDR: - case OLD_SIOCGIFMETRIC: - case OLD_SIOCGIFMTU: - case OLD_SIOCGIFINDEX: - cmd = CONV_OLD_TO_NEW_SIO (cmd); - /*FALLTHRU*/ - case SIOCGIFFLAGS: - case SIOCGIFBRDADDR: - case SIOCGIFNETMASK: - case SIOCGIFADDR: - case SIOCGIFHWADDR: - case SIOCGIFMETRIC: - case SIOCGIFMTU: - case SIOCGIFINDEX: - case SIOCGIFFRNDLYNAM: - case SIOCGIFDSTADDR: - { - if (!p) - { - debug_printf ("ifr == NULL"); - set_errno (EINVAL); - return -1; - } - - if (cmd > SIOCGIFINDEX && CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ) - { - debug_printf ("cmd not supported on this platform"); - set_errno (EINVAL); - return -1; - } - ifc.ifc_len = 64 * sizeof (struct ifreq); - ifc.ifc_buf = (caddr_t) alloca (ifc.ifc_len); - if (cmd == SIOCGIFFRNDLYNAM) - { - struct ifreq_frndlyname *iff = (struct ifreq_frndlyname *) - alloca (64 * sizeof (struct ifreq_frndlyname)); - for (int i = 0; i < 64; ++i) - ifc.ifc_req[i].ifr_frndlyname = &iff[i]; - } - - res = get_ifconf (&ifc, cmd); - if (res) - { - debug_printf ("error in get_ifconf"); - break; - } - - if (CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ) - { - struct __old_ifreq *ifr = (struct __old_ifreq *) p; - debug_printf (" name: %s", ifr->ifr_name); - for (ifrp = ifc.ifc_req; - (caddr_t) ifrp < ifc.ifc_buf + ifc.ifc_len; - ++ifrp) - { - debug_printf ("testname: %s", ifrp->ifr_name); - if (! strcmp (ifrp->ifr_name, ifr->ifr_name)) - { - memcpy (&ifr->ifr_ifru, &ifrp->ifr_ifru, - sizeof ifr->ifr_ifru); - break; - } - } - } - else - { - struct ifreq *ifr = (struct ifreq *) p; - debug_printf (" name: %s", ifr->ifr_name); - for (ifrp = ifc.ifc_req; - (caddr_t) ifrp < ifc.ifc_buf + ifc.ifc_len; - ++ifrp) - { - debug_printf ("testname: %s", ifrp->ifr_name); - if (! strcmp (ifrp->ifr_name, ifr->ifr_name)) - { - if (cmd == SIOCGIFFRNDLYNAM) - /* The application has to care for the space. */ - memcpy (ifr->ifr_frndlyname, ifrp->ifr_frndlyname, - sizeof (struct ifreq_frndlyname)); - else - memcpy (&ifr->ifr_ifru, &ifrp->ifr_ifru, - sizeof ifr->ifr_ifru); - break; - } - } - } - if ((caddr_t) ifrp >= ifc.ifc_buf + ifc.ifc_len) - { - set_errno (EINVAL); - return -1; - } - break; - } - case FIOASYNC: - res = WSAAsyncSelect (get_socket (), winmsg, WM_ASYNCIO, - *(int *) p ? ASYNC_MASK : 0); - syscall_printf ("Async I/O on socket %s", - *(int *) p ? "started" : "cancelled"); - async_io (*(int *) p != 0); - /* If async_io is switched off, revert the event handling. */ - if (*(int *) p == 0) - WSAEventSelect (get_socket (), wsock_evt, EVENT_MASK); - break; - case FIONREAD: - res = ioctlsocket (get_socket (), FIONREAD, (unsigned long *) p); - if (res == SOCKET_ERROR) - set_winsock_errno (); - break; - default: - /* Sockets are always non-blocking internally. So we just note the - state here. */ - if (cmd == FIONBIO) - { - syscall_printf ("socket is now %sblocking", - *(int *) p ? "non" : ""); - set_nonblocking (*(int *) p); - res = 0; - } - else - res = ioctlsocket (get_socket (), cmd, (unsigned long *) p); - break; - } - syscall_printf ("%d = ioctl_socket (%x, %x)", res, cmd, p); - return res; -} - -int -fhandler_socket::fcntl (int cmd, void *arg) -{ - int res = 0; - int request, current; - - switch (cmd) - { - case F_SETOWN: - { - pid_t pid = (pid_t) arg; - LOCK_EVENTS; - wsock_events->owner = pid; - UNLOCK_EVENTS; - debug_printf ("owner set to %d", pid); - } - break; - case F_GETOWN: - res = wsock_events->owner; - break; - case F_SETFL: - { - /* Carefully test for the O_NONBLOCK or deprecated OLD_O_NDELAY flag. - Set only the flag that has been passed in. If both are set, just - record O_NONBLOCK. */ - int new_flags = (int) arg & O_NONBLOCK_MASK; - if ((new_flags & OLD_O_NDELAY) && (new_flags & O_NONBLOCK)) - new_flags = O_NONBLOCK; - current = get_flags () & O_NONBLOCK_MASK; - request = new_flags ? 1 : 0; - if (!!current != !!new_flags && (res = ioctl (FIONBIO, &request))) - break; - set_flags ((get_flags () & ~O_NONBLOCK_MASK) | new_flags); - break; - } - default: - res = fhandler_base::fcntl (cmd, arg); - break; - } - return res; -} - -void -fhandler_socket::set_close_on_exec (bool val) -{ - set_no_inheritance (wsock_mtx, val); - set_no_inheritance (wsock_evt, val); - if (need_fixup_before ()) - { - close_on_exec (val); - debug_printf ("set close_on_exec for %s to %d", get_name (), val); - } - else - fhandler_base::set_close_on_exec (val); -} - -void -fhandler_socket::set_sun_path (const char *path) -{ - sun_path = path ? cstrdup (path) : NULL; -} - -void -fhandler_socket::set_peer_sun_path (const char *path) -{ - peer_sun_path = path ? cstrdup (path) : NULL; -} - -int -fhandler_socket::getpeereid (pid_t *pid, __uid32_t *euid, __gid32_t *egid) -{ - if (get_addr_family () != AF_LOCAL || get_socket_type () != SOCK_STREAM) - { - set_errno (EINVAL); - return -1; - } - if (connect_state () != connected) - { - set_errno (ENOTCONN); - return -1; - } - if (sec_peer_pid == (pid_t) 0) - { - set_errno (ENOTCONN); /* Usually when calling getpeereid on - accepting (instead of accepted) socket. */ - return -1; - } - - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - if (pid) - *pid = sec_peer_pid; - if (euid) - *euid = sec_peer_uid; - if (egid) - *egid = sec_peer_gid; - return 0; -} diff --git a/winsup/cygwin/fhandler_tape.cc b/winsup/cygwin/fhandler_tape.cc deleted file mode 100644 index ff7e84aab..000000000 --- a/winsup/cygwin/fhandler_tape.cc +++ /dev/null @@ -1,1485 +0,0 @@ -/* fhandler_tape.cc. See fhandler.h for a description of the fhandler - classes. - - Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "cygtls.h" -#include -#include -#include -#include -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "shared_info.h" -#include "sigproc.h" - -/* Media changes and bus resets are sometimes reported and the function - hasn't been executed. We repeat all functions which return with one - of these error codes. */ -#define TAPE_FUNC(func) while ((lasterr = (func)) == ERROR_MEDIA_CHANGED) \ - { \ - initialize (drive, false); \ - part (partition)->initialize (0); \ - } - -#define IS_BOT(err) ((err) == ERROR_BEGINNING_OF_MEDIA) - -#define IS_EOF(err) ((err) == ERROR_FILEMARK_DETECTED \ - || (err) == ERROR_SETMARK_DETECTED) - -#define IS_SM(err) ((err) == ERROR_SETMARK_DETECTED) - -#define IS_EOD(err) ((err) == ERROR_END_OF_MEDIA \ - || (err) == ERROR_EOM_OVERFLOW \ - || (err) == ERROR_NO_DATA_DETECTED) - -#define IS_EOM(err) ((err) == ERROR_END_OF_MEDIA \ - || (err) == ERROR_EOM_OVERFLOW) - -/**********************************************************************/ -/* mtinfo_part */ - -void -mtinfo_part::initialize (long nblock) -{ - block = nblock; - if (block == 0) - file = fblock = 0; - else - file = fblock = -1; - smark = false; - emark = no_eof; -} - -/**********************************************************************/ -/* mtinfo_drive */ - -void -mtinfo_drive::initialize (int num, bool first_time) -{ - drive = num; - partition = 0; - block = -1; - lock = unlocked; - if (first_time) - { - buffer_writes (true); - async_writes (false); - two_fm (false); - fast_eom (false); - auto_lock (false); - sysv (false); - nowait (false); - } - for (int i = 0; i < MAX_PARTITION_NUM; ++i) - part (i)->initialize (); -} - -int -mtinfo_drive::get_dp (HANDLE mt) -{ - DWORD len = sizeof _dp; - TAPE_FUNC (GetTapeParameters (mt, GET_TAPE_DRIVE_INFORMATION, &len, &_dp)); - return error ("get_dp"); -} - -int -mtinfo_drive::get_mp (HANDLE mt) -{ - DWORD len = sizeof _mp; - TAPE_FUNC (GetTapeParameters (mt, GET_TAPE_MEDIA_INFORMATION, &len, &_mp)); - return error ("get_mp"); -} - -int -mtinfo_drive::open (HANDLE mt) -{ - get_dp (mt); - get_mp (mt); - get_pos (mt); - if (partition < MAX_PARTITION_NUM && part (partition)->block != block) - part (partition)->initialize (block); - /* The following rewind in position 0 solves a problem which appears - * in case of multi volume archives (at least on NT4): The last ReadFile - * on the previous medium returns ERROR_NO_DATA_DETECTED. After media - * change, all subsequent ReadFile calls return ERROR_NO_DATA_DETECTED, - * too. The call to set_pos apparently reset some internal flags. - * FIXME: Is that really true or based on a misinterpretation? */ - if (!block) - { - debug_printf ("rewind in position 0"); - set_pos (mt, TAPE_REWIND, 0, false); - } - return error ("open"); -} - -int -mtinfo_drive::close (HANDLE mt, bool rewind) -{ - lasterr = 0; - if (GetTapeStatus (mt) == ERROR_NO_MEDIA_IN_DRIVE) - dirty = clean; - if (dirty >= has_written) - { - /* If an async write is still pending, wait for completion. */ - if (dirty == async_write_pending) - lasterr = async_wait (mt, NULL); - if (!lasterr) - { - /* if last operation was writing, write a filemark */ - debug_printf ("writing filemark"); - write_marks (mt, TAPE_FILEMARKS, two_fm () ? 2 : 1); - if (two_fm () && !lasterr && !rewind) /* Backspace over 2nd fmark. */ - { - set_pos (mt, TAPE_SPACE_FILEMARKS, -1, false); - if (!lasterr) - part (partition)->fblock = 0; /* That's obvious, isn't it? */ - } - } - } - else if (dirty == has_read && !rewind) - { - if (sysv ()) - { - /* Under SYSV semantics, the tape is moved past the next file mark - after read. */ - if (part (partition)->emark == no_eof) - set_pos (mt, TAPE_SPACE_FILEMARKS, 1, false); - else if (part (partition)->emark == eof_hit) - part (partition)->emark = eof; - } - else - { - /* Under BSD semantics, we must check if the filemark has been - inadvertendly crossed. If so cross the filemark backwards - and position the tape right before EOF. */ - if (part (partition)->emark == eof_hit) - set_pos (mt, TAPE_SPACE_FILEMARKS, -1, false); - } - } - if (rewind) - { - debug_printf ("rewinding"); - set_pos (mt, TAPE_REWIND, 0, false); - } - if (auto_lock () && lock == auto_locked) - prepare (mt, TAPE_UNLOCK); - dirty = clean; - return error ("close"); -} - -int -mtinfo_drive::read (HANDLE mt, HANDLE mt_evt, void *ptr, size_t &ulen) -{ - BOOL ret; - DWORD bytes_read = 0; - - if (GetTapeStatus (mt) == ERROR_NO_MEDIA_IN_DRIVE) - return lasterr = ERROR_NO_MEDIA_IN_DRIVE; - if (lasterr == ERROR_BUS_RESET) - { - ulen = 0; - goto out; - } - /* If an async write is still pending, wait for completion. */ - if (dirty == async_write_pending) - lasterr = async_wait (mt, NULL); - dirty = clean; - if (part (partition)->emark == eof_hit) - { - part (partition)->emark = eof; - lasterr = ulen = 0; - goto out; - } - else if (part (partition)->emark == eod_hit) - { - part (partition)->emark = eod; - lasterr = ulen = 0; - goto out; - } - else if (part (partition)->emark == eod) - { - lasterr = ERROR_NO_DATA_DETECTED; - ulen = (size_t) -1; - goto out; - } - else if (part (partition)->emark == eom_hit) - { - part (partition)->emark = eom; - lasterr = ulen = 0; - goto out; - } - else if (part (partition)->emark == eom) - { - lasterr = ERROR_END_OF_MEDIA; - ulen = (size_t) -1; - goto out; - } - part (partition)->smark = false; - if (auto_lock () && lock < auto_locked) - prepare (mt, TAPE_LOCK, true); - ov.Offset = ov.OffsetHigh = 0; - ov.hEvent = mt_evt; - ret = ReadFile (mt, ptr, ulen, &bytes_read, &ov); - lasterr = ret ? 0 : GetLastError (); - if (lasterr == ERROR_IO_PENDING) - lasterr = async_wait (mt, &bytes_read); - ulen = (size_t) bytes_read; - if (bytes_read > 0) - { - long blocks_read = mp ()->BlockSize == 0 - ? 1 : howmany (bytes_read, mp ()->BlockSize); - block += blocks_read; - part (partition)->block += blocks_read; - if (part (partition)->fblock >= 0) - part (partition)->fblock += blocks_read; - } - if (IS_EOF (lasterr)) - { - block++; - part (partition)->block++; - if (part (partition)->file >= 0) - part (partition)->file++; - part (partition)->fblock = 0; - part (partition)->smark = IS_SM (lasterr); - part (partition)->emark = bytes_read > 0 ? eof_hit : eof; - lasterr = 0; - } - else if (IS_EOD (lasterr)) - { - if (part (partition)->emark == eof) - part (partition)->emark = IS_EOM (lasterr) ? eom : eod; - else - { - part (partition)->emark = IS_EOM (lasterr) ? eom_hit : eod_hit; - lasterr = 0; - } - } - else - { - part (partition)->emark = no_eof; - /* This happens if the buffer is too small when in variable block - size mode. Linux returns ENOMEM here. We're doing the same. */ - if (lasterr == ERROR_MORE_DATA) - lasterr = ERROR_NOT_ENOUGH_MEMORY; - } - if (!lasterr) - dirty = has_read; -out: - return error ("read"); -} - -int -mtinfo_drive::async_wait (HANDLE mt, DWORD *bytes_written) -{ - DWORD written; - - bool ret = GetOverlappedResult (mt, &ov, &written, TRUE); - if (bytes_written) - *bytes_written = written; - return ret ? 0 : GetLastError (); -} - -int -mtinfo_drive::write (HANDLE mt, HANDLE mt_evt, const void *ptr, size_t &len) -{ - BOOL ret; - DWORD bytes_written = 0; - int async_err = 0; - - if (GetTapeStatus (mt) == ERROR_NO_MEDIA_IN_DRIVE) - return lasterr = ERROR_NO_MEDIA_IN_DRIVE; - if (lasterr == ERROR_BUS_RESET) - { - len = 0; - return error ("write"); - } - if (dirty == async_write_pending) - async_err = async_wait (mt, &bytes_written); - dirty = clean; - part (partition)->smark = false; - if (auto_lock () && lock < auto_locked) - prepare (mt, TAPE_LOCK, true); - ov.Offset = ov.OffsetHigh = 0; - ov.hEvent = mt_evt; - ret = WriteFile (mt, ptr, len, &bytes_written, &ov); - lasterr = ret ? 0: GetLastError (); - if (lasterr == ERROR_IO_PENDING) - { - if (async_writes () && mp ()->BlockSize == 0) - dirty = async_write_pending; - else - /* Wait for completion if a non-async write. */ - lasterr = async_wait (mt, &bytes_written); - } - len = (size_t) bytes_written; - if (bytes_written > 0) - { - long blocks_written = mp ()->BlockSize == 0 - ? 1 : howmany (bytes_written, mp ()->BlockSize); - block += blocks_written; - part (partition)->block += blocks_written; - if (part (partition)->fblock >= 0) - part (partition)->fblock += blocks_written; - } - if (!lasterr && async_err) - lasterr = async_err; - if (lasterr == ERROR_EOM_OVERFLOW) - part (partition)->emark = eom; - else if (lasterr == ERROR_END_OF_MEDIA) - ; // FIXME?: part (partition)->emark = eom_hit; - else - { - part (partition)->emark = no_eof; - if (!lasterr) - dirty = has_written; - else if (lasterr == ERROR_IO_PENDING) - dirty = async_write_pending; - } - return error ("write"); -} - -int -mtinfo_drive::get_pos (HANDLE mt, long *ppartition, long *pblock) -{ - DWORD p, low, high; - - TAPE_FUNC (GetTapePosition (mt, TAPE_LOGICAL_POSITION, &p, &low, &high)); - if (lasterr == ERROR_INVALID_FUNCTION) - TAPE_FUNC (GetTapePosition (mt, TAPE_ABSOLUTE_POSITION, &p, &low, &high)); - if (!lasterr) - { - if (p > 0) - partition = (long) p - 1; - block = (long) low; - if (ppartition) - *ppartition= partition; - if (pblock) - *pblock = block; - } - else - { - partition = 0; - block = -1; - } - return error ("get_pos"); -} - -int -mtinfo_drive::_set_pos (HANDLE mt, int mode, long count, int partition, - BOOL dont_wait) -{ - /* If an async write is still pending, wait for completion. */ - if (dirty == async_write_pending) - lasterr = async_wait (mt, NULL); - dirty = clean; - TAPE_FUNC (SetTapePosition (mt, mode, partition, count, count < 0 ? -1 : 0, - dont_wait)); - return lasterr; -} - -int -mtinfo_drive::set_pos (HANDLE mt, int mode, long count, - bool sfm_func) -{ - int err = 0; - long undone = count; - BOOL dont_wait = FALSE; - - switch (mode) - { - case TAPE_SPACE_RELATIVE_BLOCKS: - case TAPE_SPACE_FILEMARKS: - case TAPE_SPACE_SETMARKS: - if (!count) - { - lasterr = 0; - goto out; - } - break; - case TAPE_ABSOLUTE_BLOCK: - case TAPE_LOGICAL_BLOCK: - case TAPE_REWIND: - dont_wait = nowait () ? TRUE : FALSE; - break; - } - if (mode == TAPE_SPACE_FILEMARKS) - { - while (!err && undone > 0) - if (!(err = _set_pos (mt, mode, 1, 0, FALSE)) || IS_SM (err)) - --undone; - while (!err && undone < 0) - if (!(err = _set_pos (mt, mode, -1, 0, FALSE)) || IS_SM (err)) - ++undone; - } - else - err = _set_pos (mt, mode, count, 0, dont_wait); - switch (mode) - { - case TAPE_ABSOLUTE_BLOCK: - case TAPE_LOGICAL_BLOCK: - get_pos (mt); - part (partition)->initialize (block); - break; - case TAPE_REWIND: - if (!err) - { - block = 0; - part (partition)->initialize (0); - } - else - { - get_pos (mt); - part (partition)->initialize (block); - } - break; - case TAPE_SPACE_END_OF_DATA: - get_pos (mt); - part (partition)->initialize (block); - part (partition)->emark = IS_EOM (err) ? eom : eod; - break; - case TAPE_SPACE_FILEMARKS: - if (!err || IS_SM (err)) - { - get_pos (mt); - part (partition)->block = block; - if (count > 0) - { - if (part (partition)->file >= 0) - part (partition)->file += count - undone; - part (partition)->fblock = 0; - part (partition)->smark = IS_SM (err); - } - else - { - if (part (partition)->file >= 0) - part (partition)->file += count - undone; - part (partition)->fblock = -1; - part (partition)->smark = false; - } - if (sfm_func) - err = set_pos (mt, mode, count > 0 ? -1 : 1, false); - else - part (partition)->emark = count > 0 ? eof : no_eof; - } - else if (IS_EOD (err)) - { - get_pos (mt); - part (partition)->block = block; - if (part (partition)->file >= 0) - part (partition)->file += count - undone; - part (partition)->fblock = -1; - part (partition)->smark = false; - part (partition)->emark = IS_EOM (err) ? eom : eod; - } - else if (IS_BOT (err)) - { - block = 0; - part (partition)->initialize (0); - } - else - { - get_pos (mt); - part (partition)->initialize (block); - } - break; - case TAPE_SPACE_RELATIVE_BLOCKS: - if (!err) - { - block += count; - part (partition)->block += count; - if (part (partition)->fblock >= 0) - part (partition)->fblock += count; - part (partition)->smark = false; - part (partition)->emark = no_eof; - } - else if (IS_EOF (err)) - { - get_pos (mt); - part (partition)->block = block; - if (part (partition)->file >= 0) - part (partition)->file += count > 0 ? 1 : -1; - part (partition)->fblock = count > 0 ? 0 : -1; - part (partition)->smark = (count > 0 && IS_SM (err)); - part (partition)->emark = count > 0 ? eof : no_eof; - } - else if (IS_EOD (err)) - { - get_pos (mt); - part (partition)->fblock = block - part (partition)->block; - part (partition)->block = block; - part (partition)->smark = false; - part (partition)->emark = IS_EOM (err) ? eom : eod; - } - else if (IS_BOT (err)) - { - block = 0; - part (partition)->initialize (0); - } - break; - case TAPE_SPACE_SETMARKS: - get_pos (mt); - part (partition)->block = block; - if (!err) - { - part (partition)->file = -1; - part (partition)->fblock = -1; - part (partition)->smark = true; - } - break; - } - lasterr = err; -out: - return error ("set_pos"); -} - -int -mtinfo_drive::create_partitions (HANDLE mt, long count) -{ - if (dp ()->MaximumPartitionCount <= 1) - return ERROR_INVALID_PARAMETER; - if (set_pos (mt, TAPE_REWIND, 0, false)) - goto out; - partition = 0; - part (partition)->initialize (0); - debug_printf ("Format tape with %s partition(s)", count <= 0 ? "one" : "two"); - if (get_feature (TAPE_DRIVE_INITIATOR)) - { - if (count <= 0) - TAPE_FUNC (CreateTapePartition (mt, TAPE_INITIATOR_PARTITIONS, - count <= 0 ? 0 : 2, (DWORD) count)); - } - else if (get_feature (TAPE_DRIVE_FIXED)) - { - /* This is supposed to work for Tandberg SLR drivers up to version - 1.6 which missed to set the TAPE_DRIVE_INITIATOR flag. According - to Tandberg, CreateTapePartition(TAPE_FIXED_PARTITIONS) apparently - does not ignore the dwCount parameter. Go figure! */ - TAPE_FUNC (CreateTapePartition (mt, TAPE_FIXED_PARTITIONS, - count <= 0 ? 0 : 2, (DWORD) count)); - } - else - lasterr = ERROR_INVALID_PARAMETER; -out: - return error ("partition"); -} - -int -mtinfo_drive::set_partition (HANDLE mt, long count) -{ - if (count < 0 || (unsigned long) count >= MAX_PARTITION_NUM) - lasterr = ERROR_INVALID_PARAMETER; - else if ((DWORD) count >= dp ()->MaximumPartitionCount) - lasterr = ERROR_IO_DEVICE; - else - { - int part_block = part (count)->block >= 0 ? part (count)->block : 0; - int err = _set_pos (mt, TAPE_LOGICAL_BLOCK, part_block, count + 1, FALSE); - if (err) - { - int sav_block = block; - int sav_partition = partition; - get_pos (mt); - if (sav_partition != partition) - { - if (partition < MAX_PARTITION_NUM - && part (partition)->block != block) - part (partition)->initialize (block); - } - else if (sav_block != block && partition < MAX_PARTITION_NUM) - part (partition)->initialize (block); - lasterr = err; - } - else - { - partition = count; - if (part (partition)->block == -1) - part (partition)->initialize (0); - } - } - return error ("set_partition"); -} - -int -mtinfo_drive::write_marks (HANDLE mt, int marktype, DWORD count) -{ - /* If an async write is still pending, wait for completion. */ - if (dirty == async_write_pending) - { - lasterr = async_wait (mt, NULL); - dirty = has_written; - } - if (marktype != TAPE_SETMARKS) - dirty = clean; - if (marktype == TAPE_FILEMARKS - && !get_feature (TAPE_DRIVE_WRITE_FILEMARKS)) - { - if (get_feature (TAPE_DRIVE_WRITE_LONG_FMKS)) - marktype = TAPE_LONG_FILEMARKS; - else - marktype = TAPE_SHORT_FILEMARKS; - } - TAPE_FUNC (WriteTapemark (mt, marktype, count, FALSE)); - int err = lasterr; - if (!err) - { - block += count; - part (partition)->block += count; - if (part (partition)->file >= 0) - part (partition)->file += count; - part (partition)->fblock = 0; - part (partition)->emark = eof; - part (partition)->smark = (marktype == TAPE_SETMARKS); - } - else - { - int sav_block = block; - int sav_partition = partition; - get_pos (mt); - if (sav_partition != partition) - { - if (partition < MAX_PARTITION_NUM - && part (partition)->block != block) - part (partition)->initialize (block); - } - else if (sav_block != block && partition < MAX_PARTITION_NUM) - part (partition)->initialize (block); - lasterr = err; - } - return error ("write_marks"); -} - -int -mtinfo_drive::erase (HANDLE mt, int mode) -{ - switch (mode) - { - case TAPE_ERASE_SHORT: - if (!get_feature (TAPE_DRIVE_ERASE_SHORT)) - mode = TAPE_ERASE_LONG; - break; - case TAPE_ERASE_LONG: - if (!get_feature (TAPE_DRIVE_ERASE_LONG)) - mode = TAPE_ERASE_SHORT; - break; - } - TAPE_FUNC (EraseTape (mt, mode, nowait () ? TRUE : FALSE)); - part (partition)->initialize (0); - return error ("erase"); -} - -int -mtinfo_drive::prepare (HANDLE mt, int action, bool is_auto) -{ - BOOL dont_wait = FALSE; - - /* If an async write is still pending, wait for completion. */ - if (dirty == async_write_pending) - lasterr = async_wait (mt, NULL); - dirty = clean; - if (action == TAPE_UNLOAD || action == TAPE_LOAD || action == TAPE_TENSION) - dont_wait = nowait () ? TRUE : FALSE; - TAPE_FUNC (PrepareTape (mt, action, dont_wait)); - /* Reset buffer after all successful preparations but lock and unlock. */ - switch (action) - { - case TAPE_FORMAT: - case TAPE_UNLOAD: - case TAPE_LOAD: - initialize (drive, false); - break; - case TAPE_TENSION: - part (partition)->initialize (0); - break; - case TAPE_LOCK: - lock = lasterr ? lock_error : is_auto ? auto_locked : locked; - break; - case TAPE_UNLOCK: - lock = lasterr ? lock_error : unlocked; - break; - } - return error ("prepare"); -} - -int -mtinfo_drive::set_compression (HANDLE mt, long count) -{ - if (!get_feature (TAPE_DRIVE_SET_COMPRESSION)) - return ERROR_INVALID_PARAMETER; - TAPE_SET_DRIVE_PARAMETERS sdp = - { - dp ()->ECC, - count ? TRUE : FALSE, - dp ()->DataPadding, - dp ()->ReportSetmarks, - dp ()->EOTWarningZoneSize - }; - TAPE_FUNC (SetTapeParameters (mt, SET_TAPE_DRIVE_INFORMATION, &sdp)); - int err = lasterr; - if (!err) - dp ()->Compression = sdp.Compression; - else - get_dp (mt); - lasterr = err; - return error ("set_compression"); -} - -int -mtinfo_drive::set_blocksize (HANDLE mt, long count) -{ - TAPE_SET_MEDIA_PARAMETERS smp = {count}; - TAPE_FUNC (SetTapeParameters (mt, SET_TAPE_MEDIA_INFORMATION, &smp)); - return error ("set_blocksize"); -} - -int -mtinfo_drive::get_status (HANDLE mt, struct mtget *get) -{ - int notape = 0; - DWORD tstat; - - if (!get) - return ERROR_INVALID_PARAMETER; - - if ((tstat = GetTapeStatus (mt)) == ERROR_NO_MEDIA_IN_DRIVE) - notape = 1; - - memset (get, 0, sizeof *get); - - get->mt_type = MT_ISUNKNOWN; - - if (!notape && get_feature (TAPE_DRIVE_SET_BLOCK_SIZE)) - get->mt_dsreg = (mp ()->BlockSize << MT_ST_BLKSIZE_SHIFT) - & MT_ST_BLKSIZE_MASK; - else - get->mt_dsreg = (dp ()->DefaultBlockSize << MT_ST_BLKSIZE_SHIFT) - & MT_ST_BLKSIZE_MASK; - - if (wincap.has_ioctl_storage_get_media_types_ex ()) - { - DWORD size = sizeof (GET_MEDIA_TYPES) + 10 * sizeof (DEVICE_MEDIA_INFO); - void *buf = alloca (size); - if (DeviceIoControl (mt, IOCTL_STORAGE_GET_MEDIA_TYPES_EX, - NULL, 0, buf, size, &size, NULL) - || GetLastError () == ERROR_MORE_DATA) - { - PGET_MEDIA_TYPES gmt = (PGET_MEDIA_TYPES) buf; - for (DWORD i = 0; i < gmt->MediaInfoCount; ++i) - { - PDEVICE_MEDIA_INFO dmi = &gmt->MediaInfo[i]; - get->mt_type = dmi->DeviceSpecific.TapeInfo.MediaType; -#define TINFO DeviceSpecific.TapeInfo - if (dmi->TINFO.MediaCharacteristics & MEDIA_CURRENTLY_MOUNTED) - { - get->mt_type = dmi->DeviceSpecific.TapeInfo.MediaType; - if (dmi->TINFO.BusType == BusTypeScsi) - get->mt_dsreg |= - (dmi->TINFO.BusSpecificData.ScsiInformation.DensityCode - << MT_ST_DENSITY_SHIFT) - & MT_ST_DENSITY_MASK; - break; - } -#undef TINFO - } - } - } - - if (!notape) - { - get->mt_resid = partition; - get->mt_fileno = part (partition)->file; - get->mt_blkno = part (partition)->fblock; - - if (get->mt_blkno != 0) - /* nothing to do */; - else if (get->mt_fileno == 0) - get->mt_gstat |= GMT_BOT (-1); - else - get->mt_gstat |= GMT_EOF (-1); - if (part (partition)->emark >= eod_hit) - get->mt_gstat |= GMT_EOD (-1); - if (part (partition)->emark >= eom_hit) - get->mt_gstat |= GMT_EOT (-1); - - if (part (partition)->smark) - get->mt_gstat |= GMT_SM (-1); - - get->mt_gstat |= GMT_ONLINE (-1); - - if (mp ()->WriteProtected) - get->mt_gstat |= GMT_WR_PROT (-1); - - get->mt_capacity = get_ll (mp ()->Capacity); - get->mt_remaining = get_ll (mp ()->Remaining); - } - - if (notape) - get->mt_gstat |= GMT_DR_OPEN (-1); - - if (buffer_writes ()) - get->mt_gstat |= GMT_IM_REP_EN (-1); /* TODO: Async writes */ - - if (tstat == ERROR_DEVICE_REQUIRES_CLEANING) - get->mt_gstat |= GMT_CLN (-1); - - /* Cygwin specials: */ - if (dp ()->ReportSetmarks) - get->mt_gstat |= GMT_REP_SM (-1); - if (dp ()->DataPadding) - get->mt_gstat |= GMT_PADDING (-1); - if (dp ()->ECC) - get->mt_gstat |= GMT_HW_ECC (-1); - if (dp ()->Compression) - get->mt_gstat |= GMT_HW_COMP (-1); - if (two_fm ()) - get->mt_gstat |= GMT_TWO_FM (-1); - if (fast_eom ()) - get->mt_gstat |= GMT_FAST_MTEOM (-1); - if (auto_lock ()) - get->mt_gstat |= GMT_AUTO_LOCK (-1); - if (sysv ()) - get->mt_gstat |= GMT_SYSV (-1); - if (nowait ()) - get->mt_gstat |= GMT_NOWAIT (-1); - if (async_writes ()) - get->mt_gstat |= GMT_ASYNC (-1); - - get->mt_erreg = 0; /* FIXME: No softerr counting */ - - get->mt_minblksize = dp ()->MinimumBlockSize; - get->mt_maxblksize = dp ()->MaximumBlockSize; - get->mt_defblksize = dp ()->DefaultBlockSize; - get->mt_featureslow = dp ()->FeaturesLow; - get->mt_featureshigh = dp ()->FeaturesHigh; - get->mt_eotwarningzonesize = dp ()->EOTWarningZoneSize; - - return 0; -} - -int -mtinfo_drive::set_options (HANDLE mt, long options) -{ - long what = (options & MT_ST_OPTIONS); - bool call_setparams = false; - bool set; - TAPE_SET_DRIVE_PARAMETERS sdp = - { - dp ()->ECC, - dp ()->Compression, - dp ()->DataPadding, - dp ()->ReportSetmarks, - dp ()->EOTWarningZoneSize - }; - - lasterr = 0; - switch (what) - { - case 0: - if (options == 0 || options == 1) - { - buffer_writes ((options == 1)); - } - break; - case MT_ST_BOOLEANS: - buffer_writes (!!(options & MT_ST_BUFFER_WRITES)); - async_writes (!!(options & MT_ST_ASYNC_WRITES)); - two_fm (!!(options & MT_ST_TWO_FM)); - fast_eom (!!(options & MT_ST_FAST_MTEOM)); - auto_lock (!!(options & MT_ST_AUTO_LOCK)); - sysv (!!(options & MT_ST_SYSV)); - nowait (!!(options & MT_ST_NOWAIT)); - if (get_feature (TAPE_DRIVE_SET_ECC)) - sdp.ECC = !!(options & MT_ST_ECC); - if (get_feature (TAPE_DRIVE_SET_PADDING)) - sdp.DataPadding = !!(options & MT_ST_PADDING); - if (get_feature (TAPE_DRIVE_SET_REPORT_SMKS)) - sdp.ReportSetmarks = !!(options & MT_ST_REPORT_SM); - if (sdp.ECC != dp ()->ECC || sdp.DataPadding != dp ()->DataPadding - || sdp.ReportSetmarks != dp ()->ReportSetmarks) - call_setparams = true; - break; - case MT_ST_SETBOOLEANS: - case MT_ST_CLEARBOOLEANS: - set = (what == MT_ST_SETBOOLEANS); - if (options & MT_ST_BUFFER_WRITES) - buffer_writes (set); - if (options & MT_ST_ASYNC_WRITES) - async_writes (set); - if (options & MT_ST_TWO_FM) - two_fm (set); - if (options & MT_ST_FAST_MTEOM) - fast_eom (set); - if (options & MT_ST_AUTO_LOCK) - auto_lock (set); - if (options & MT_ST_SYSV) - sysv (set); - if (options & MT_ST_NOWAIT) - nowait (set); - if (options & MT_ST_ECC) - sdp.ECC = set; - if (options & MT_ST_PADDING) - sdp.DataPadding = set; - if (options & MT_ST_REPORT_SM) - sdp.ReportSetmarks = set; - if (sdp.ECC != dp ()->ECC || sdp.DataPadding != dp ()->DataPadding - || sdp.ReportSetmarks != dp ()->ReportSetmarks) - call_setparams = true; - break; - case MT_ST_EOT_WZ_SIZE: - if (get_feature (TAPE_DRIVE_SET_EOT_WZ_SIZE)) - { - sdp.EOTWarningZoneSize = (options & ~MT_ST_OPTIONS); - if (sdp.EOTWarningZoneSize != dp ()->EOTWarningZoneSize) - call_setparams = true; - } - break; - } - if (call_setparams) - { - TAPE_FUNC (SetTapeParameters (mt, SET_TAPE_DRIVE_INFORMATION, &sdp)); - int err = lasterr; - if (!err) - { - dp ()->ECC = sdp.ECC; - dp ()->DataPadding = sdp.DataPadding; - dp ()->ReportSetmarks = sdp.ReportSetmarks; - } - else - get_dp (mt); - lasterr = err; - } - return error ("set_options"); -} - -int -mtinfo_drive::ioctl (HANDLE mt, unsigned int cmd, void *buf) -{ - myfault efault; - if (efault.faulted ()) - return ERROR_NOACCESS; - if (cmd == MTIOCTOP) - { - struct mtop *op = (struct mtop *) buf; - if (lasterr == ERROR_BUS_RESET) - { - /* If a bus reset occurs, block further access to this device - until the user rewinds, unloads or in any other way tries - to maintain a well-known tape position. */ - if (op->mt_op != MTREW && op->mt_op != MTOFFL - && op->mt_op != MTRETEN && op->mt_op != MTERASE - && op->mt_op != MTSEEK && op->mt_op != MTEOM) - return ERROR_BUS_RESET; - /* Try to maintain last lock state after bus reset. */ - if (lock >= auto_locked && PrepareTape (mt, TAPE_LOCK, FALSE)) - { - debug_printf ("Couldn't relock drive after bus reset."); - lock = unlocked; - } - } - switch (op->mt_op) - { - case MTRESET: - break; - case MTFSF: - set_pos (mt, TAPE_SPACE_FILEMARKS, op->mt_count, false); - break; - case MTBSF: - set_pos (mt, TAPE_SPACE_FILEMARKS, -op->mt_count, false); - break; - case MTFSR: - set_pos (mt, TAPE_SPACE_RELATIVE_BLOCKS, op->mt_count, false); - break; - case MTBSR: - set_pos (mt, TAPE_SPACE_RELATIVE_BLOCKS, -op->mt_count, false); - break; - case MTWEOF: - write_marks (mt, TAPE_FILEMARKS, op->mt_count); - break; - case MTREW: - set_pos (mt, TAPE_REWIND, 0, false); - break; - case MTOFFL: - case MTUNLOAD: - prepare (mt, TAPE_UNLOAD); - break; - case MTNOP: - lasterr = 0; - break; - case MTRETEN: - if (!get_feature (TAPE_DRIVE_TENSION)) - lasterr = ERROR_INVALID_PARAMETER; - else if (!set_pos (mt, TAPE_REWIND, 0, false)) - prepare (mt, TAPE_TENSION); - break; - case MTBSFM: - set_pos (mt, TAPE_SPACE_FILEMARKS, -op->mt_count, true); - break; - case MTFSFM: - set_pos (mt, TAPE_SPACE_FILEMARKS, op->mt_count, true); - break; - case MTEOM: - if (fast_eom () && get_feature (TAPE_DRIVE_END_OF_DATA)) - set_pos (mt, TAPE_SPACE_END_OF_DATA, 0, false); - else - set_pos (mt, TAPE_SPACE_FILEMARKS, 32767, false); - break; - case MTERASE: - erase (mt, TAPE_ERASE_LONG); - break; - case MTRAS1: - case MTRAS2: - case MTRAS3: - lasterr = ERROR_INVALID_PARAMETER; - break; - case MTSETBLK: - if (!get_feature (TAPE_DRIVE_SET_BLOCK_SIZE)) - { - lasterr = ERROR_INVALID_PARAMETER; - break; - } - if ((DWORD) op->mt_count == mp ()->BlockSize) - { - /* Nothing has changed. */ - lasterr = 0; - break; - } - if ((op->mt_count == 0 && !get_feature (TAPE_DRIVE_VARIABLE_BLOCK)) - || (op->mt_count > 0 - && ((DWORD) op->mt_count < dp ()->MinimumBlockSize - || (DWORD) op->mt_count > dp ()->MaximumBlockSize))) - { - lasterr = ERROR_INVALID_PARAMETER; - break; - } - if (set_blocksize (mt, op->mt_count) - && lasterr == ERROR_INVALID_FUNCTION) - lasterr = ERROR_INVALID_BLOCK_LENGTH; - break; - case MTSEEK: - if (get_feature (TAPE_DRIVE_LOGICAL_BLK)) - set_pos (mt, TAPE_LOGICAL_BLOCK, op->mt_count, false); - else if (!get_pos (mt)) - set_pos (mt, TAPE_SPACE_RELATIVE_BLOCKS, - op->mt_count - block, false); - break; - case MTTELL: - if (!get_pos (mt)) - op->mt_count = block; - break; - case MTFSS: - set_pos (mt, TAPE_SPACE_SETMARKS, op->mt_count, false); - break; - case MTBSS: - set_pos (mt, TAPE_SPACE_SETMARKS, -op->mt_count, false); - break; - case MTWSM: - write_marks (mt, TAPE_SETMARKS, op->mt_count); - break; - case MTLOCK: - prepare (mt, TAPE_LOCK); - break; - case MTUNLOCK: - prepare (mt, TAPE_UNLOCK); - break; - case MTLOAD: - prepare (mt, TAPE_LOAD); - break; - case MTCOMPRESSION: - set_compression (mt, op->mt_count); - break; - case MTSETPART: - set_partition (mt, op->mt_count); - break; - case MTMKPART: - create_partitions (mt, op->mt_count); - break; - case MTSETDRVBUFFER: - set_options (mt, op->mt_count); - break; - case MTSETDENSITY: - default: - lasterr = ERROR_INVALID_PARAMETER; - break; - } - } - else if (cmd == MTIOCGET) - get_status (mt, (struct mtget *) buf); - else if (cmd == MTIOCPOS && !get_pos (mt)) - ((struct mtpos *) buf)->mt_blkno = block; - - return lasterr; -} - -/**********************************************************************/ -/* mtinfo */ - -void -mtinfo::initialize () -{ - for (unsigned i = 0; i < MAX_DRIVE_NUM; ++i) - drive (i)->initialize (i, true); -} - -/**********************************************************************/ -/* fhandler_dev_tape */ - -#define mt (cygwin_shared->mt) - -#define lock(err_ret_val) if (!_lock ()) return err_ret_val; - -inline bool -fhandler_dev_tape::_lock () -{ - HANDLE obj[2] = { mt_mtx, signal_arrived }; - BOOL ret = WaitForMultipleObjects (2, obj, FALSE, INFINITE) == WAIT_OBJECT_0; - if (!ret) - { - debug_printf ("signal_arrived"); \ - set_errno (EINTR); - } - return ret; -} - -inline int -fhandler_dev_tape::unlock (int ret) -{ - ReleaseMutex (mt_mtx); - return ret; -} - -fhandler_dev_tape::fhandler_dev_tape () - : fhandler_dev_raw () -{ - debug_printf ("unit: %d", dev ().minor); -} - -int -fhandler_dev_tape::open (int flags, mode_t) -{ - int ret; - - if (driveno () >= MAX_DRIVE_NUM) - { - set_errno (ENOENT); - return 0; - } - if (!(mt_mtx = CreateMutex (&sec_all, !!(flags & O_CLOEXEC), NULL))) - { - __seterrno (); - return 0; - } - - /* The O_SYNC flag is not supported by the tape driver. Use the - MT_ST_BUFFER_WRITES and MT_ST_ASYNC_WRITES flags in the drive - settings instead. In turn, the MT_ST_BUFFER_WRITES is translated - into O_SYNC, which controls the FILE_WRITE_THROUGH flag in the - NtCreateFile call in fhandler_base::open. */ - flags &= ~O_SYNC; - if (!mt.drive (driveno ())->buffer_writes ()) - flags |= O_SYNC; - - ret = fhandler_dev_raw::open (flags); - if (ret) - { - mt.drive (driveno ())->open (get_handle ()); - - /* In append mode, seek to beginning of next filemark */ - if (flags & O_APPEND) - mt.drive (driveno ())->set_pos (get_handle (), - TAPE_SPACE_FILEMARKS, 1, true); - - if (!(flags & O_DIRECT)) - { - devbufsiz = mt.drive (driveno ())->dp ()->MaximumBlockSize; - devbuf = new char [devbufsiz]; - } - devbufstart = devbufend = 0; - } - else - ReleaseMutex (mt_mtx); - return ret; -} - -int -fhandler_dev_tape::close () -{ - int ret = 0; - int cret = 0; - - if (!hExeced) - { - lock (-1); - ret = mt.drive (driveno ())->close (get_handle (), is_rewind_device ()); - if (ret) - __seterrno_from_win_error (ret); - cret = fhandler_dev_raw::close (); - unlock (0); - } - if (mt_evt) - CloseHandle (mt_evt); - CloseHandle (mt_mtx); - return ret ? -1 : cret; -} - -void __stdcall -fhandler_dev_tape::raw_read (void *ptr, size_t &ulen) -{ - char *buf = (char *) ptr; - size_t len = ulen; - size_t block_size; - size_t bytes_to_read; - size_t bytes_read = 0; - int ret = 0; - - if (lastblk_to_read ()) - { - lastblk_to_read (false); - ulen = 0; - return; - } - if (!_lock ()) - { - ulen = (size_t) -1; - return; - } - block_size = mt.drive (driveno ())->mp ()->BlockSize; - if (devbuf) - { - if (devbufend > devbufstart) - { - bytes_to_read = min (len, devbufend - devbufstart); - debug_printf ("read %d bytes from buffer (rest %d)", - bytes_to_read, devbufend - devbufstart - bytes_to_read); - memcpy (buf, devbuf + devbufstart, bytes_to_read); - len -= bytes_to_read; - bytes_read += bytes_to_read; - buf += bytes_to_read; - devbufstart += bytes_to_read; - if (devbufstart == devbufend) - devbufstart = devbufend = 0; - /* If a switch to variable block_size occured, just return the buffer - remains until the buffer is empty, then proceed with usual variable - block size handling (one block per read call). */ - if (!block_size) - len = 0; - } - if (len > 0) - { - if (!mt_evt && !(mt_evt = CreateEvent (&sec_none, TRUE, FALSE, NULL))) - debug_printf ("Creating event failed, %E"); - size_t block_fit = !block_size ? len : rounddown(len, block_size); - if (block_fit) - { - debug_printf ("read %d bytes from tape (rest %d)", - block_fit, len - block_fit); - ret = mt.drive (driveno ())->read (get_handle (), mt_evt, buf, - block_fit); - if (ret) - __seterrno_from_win_error (ret); - else if (block_fit) - { - len -= block_fit; - bytes_read += block_fit; - buf += block_fit; - /* Only one block in each read call, please. */ - if (!block_size) - len = 0; - } - else { - len = 0; - if (bytes_read) - lastblk_to_read (true); - } - } - if (!ret && len > 0) - { - debug_printf ("read %d bytes from tape (one block)", block_size); - ret = mt.drive (driveno ())->read (get_handle (), mt_evt, devbuf, - block_size); - if (ret) - __seterrno_from_win_error (ret); - else if (block_size) - { - devbufstart = len; - devbufend = block_size; - bytes_read += len; - memcpy (buf, devbuf, len); - } - else if (bytes_read) - lastblk_to_read (true); - } - } - } - else - { - if (!mt_evt && !(mt_evt = CreateEvent (&sec_none, TRUE, FALSE, NULL))) - debug_printf ("Creating event failed, %E"); - bytes_read = ulen; - ret = mt.drive (driveno ())->read (get_handle (), mt_evt, ptr, - bytes_read); - } - ulen = (ret ? (size_t) -1 : bytes_read); - unlock (); -} - -ssize_t __stdcall -fhandler_dev_tape::raw_write (const void *ptr, size_t len) -{ - lock (-1); - if (!mt_evt && !(mt_evt = CreateEvent (&sec_none, TRUE, FALSE, NULL))) - debug_printf ("Creating event failed, %E"); - int ret = mt.drive (driveno ())->write (get_handle (), mt_evt, ptr, len); - if (ret) - __seterrno_from_win_error (ret); - return unlock (ret ? -1 : (int) len); -} - -_off64_t -fhandler_dev_tape::lseek (_off64_t offset, int whence) -{ - struct mtop op; - struct mtpos pos; - DWORD block_size; - _off64_t ret = ILLEGAL_SEEK; - - lock (ILLEGAL_SEEK); - - debug_printf ("lseek (%s, %d, %d)", get_name (), offset, whence); - - block_size = mt.drive (driveno ())->mp ()->BlockSize; - if (block_size == 0) - { - set_errno (EIO); - goto out; - } - - if (ioctl (MTIOCPOS, &pos)) - goto out; - - switch (whence) - { - case SEEK_END: - op.mt_op = MTFSF; - op.mt_count = 1; - if (ioctl (MTIOCTOP, &op)) - goto out; - break; - case SEEK_SET: - if (whence == SEEK_SET && offset < 0) - { - set_errno (EINVAL); - goto out; - } - break; - case SEEK_CUR: - break; - default: - set_errno (EINVAL); - goto out; - } - - op.mt_op = MTFSR; - op.mt_count = offset / block_size - - (whence == SEEK_SET ? pos.mt_blkno : 0); - - if (op.mt_count < 0) - { - op.mt_op = MTBSR; - op.mt_count = -op.mt_count; - } - - if (ioctl (MTIOCTOP, &op) || ioctl (MTIOCPOS, &pos)) - goto out; - - ret = pos.mt_blkno * block_size; - -out: - return unlock (ret); -} - -int -fhandler_dev_tape::fstat (struct __stat64 *buf) -{ - int ret; - - if (driveno () >= MAX_DRIVE_NUM) - { - set_errno (ENOENT); - return -1; - } - if (!(ret = fhandler_base::fstat (buf))) - buf->st_blocks = 0; - return ret; -} - -int -fhandler_dev_tape::dup (fhandler_base *child) -{ - lock (-1); - fhandler_dev_tape *fh = (fhandler_dev_tape *) child; - if (!DuplicateHandle (GetCurrentProcess (), mt_mtx, - GetCurrentProcess (), &fh->mt_mtx, - 0, TRUE, DUPLICATE_SAME_ACCESS)) - { - debug_printf ("dup(%s) failed, mutex handle %x, %E", - get_name (), mt_mtx); - __seterrno (); - return unlock (-1); - } - fh->mt_evt = NULL; - if (mt_evt && - !DuplicateHandle (GetCurrentProcess (), mt_evt, - GetCurrentProcess (), &fh->mt_evt, - 0, TRUE, DUPLICATE_SAME_ACCESS)) - { - debug_printf ("dup(%s) failed, event handle %x, %E", - get_name (), mt_evt); - __seterrno (); - return unlock (-1); - } - return unlock (fhandler_dev_raw::dup (child)); -} - -void -fhandler_dev_tape::fixup_after_fork (HANDLE parent) -{ - fhandler_dev_raw::fixup_after_fork (parent); - fork_fixup (parent, mt_mtx, "mt_mtx"); - if (mt_evt) - fork_fixup (parent, mt_evt, "mt_evt"); -} - -void -fhandler_dev_tape::set_close_on_exec (bool val) -{ - fhandler_dev_raw::set_close_on_exec (val); - set_no_inheritance (mt_mtx, val); - if (mt_evt) - set_no_inheritance (mt_evt, val); -} - -int -fhandler_dev_tape::ioctl (unsigned int cmd, void *buf) -{ - int ret = 0; - lock (-1); - if (cmd == MTIOCTOP || cmd == MTIOCGET || cmd == MTIOCPOS) - { - ret = mt.drive (driveno ())->ioctl (get_handle (), cmd, buf); - if (ret) - __seterrno_from_win_error (ret); - return unlock (ret ? -1 : 0); - } - return unlock (fhandler_dev_raw::ioctl (cmd, buf)); -} diff --git a/winsup/cygwin/fhandler_termios.cc b/winsup/cygwin/fhandler_termios.cc deleted file mode 100644 index b5d9f2ef3..000000000 --- a/winsup/cygwin/fhandler_termios.cc +++ /dev/null @@ -1,369 +0,0 @@ -/* fhandler_termios.cc - - Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009 - Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include "cygerrno.h" -#include "path.h" -#include "fhandler.h" -#include "sigproc.h" -#include "pinfo.h" -#include "tty.h" -#include "cygtls.h" - -/* Common functions shared by tty/console */ - -void -fhandler_termios::tcinit (tty_min *this_tc, bool force) -{ - /* Initial termios values */ - - tc = this_tc; - - if (force || !tc->initialized ()) - { - tc->ti.c_iflag = BRKINT | ICRNL | IXON; - tc->ti.c_oflag = OPOST | ONLCR; - tc->ti.c_cflag = B38400 | CS8 | CREAD; - tc->ti.c_lflag = ISIG | ICANON | ECHO | IEXTEN; - - tc->ti.c_cc[VDISCARD] = CFLUSH; - tc->ti.c_cc[VEOL] = CEOL; - tc->ti.c_cc[VEOL2] = CEOL2; - tc->ti.c_cc[VEOF] = CEOF; - tc->ti.c_cc[VERASE] = CERASE; - tc->ti.c_cc[VINTR] = CINTR; - tc->ti.c_cc[VKILL] = CKILL; - tc->ti.c_cc[VLNEXT] = CLNEXT; - tc->ti.c_cc[VMIN] = 1; - tc->ti.c_cc[VQUIT] = CQUIT; - tc->ti.c_cc[VREPRINT] = CRPRNT; - tc->ti.c_cc[VSTART] = CSTART; - tc->ti.c_cc[VSTOP] = CSTOP; - tc->ti.c_cc[VSUSP] = CSUSP; - tc->ti.c_cc[VSWTC] = CSWTCH; - tc->ti.c_cc[VTIME] = 0; - tc->ti.c_cc[VWERASE] = CWERASE; - - tc->ti.c_ispeed = tc->ti.c_ospeed = B38400; - tc->pgid = myself->pgid; - tc->initialized (true); - } -} - -int -fhandler_termios::tcsetpgrp (const pid_t pgid) -{ - termios_printf ("tty %d pgid %d, sid %d, tsid %d", tc->ntty, pgid, - myself->sid, tc->getsid ()); - if (myself->sid != tc->getsid ()) - { - set_errno (EPERM); - return -1; - } - int res; - while (1) - { - res = bg_check (-SIGTTOU); - - switch (res) - { - case bg_ok: - tc->setpgid (pgid); - init_console_handler (tc->gethwnd ()); - res = 0; - break; - case bg_signalled: - if (_my_tls.call_signal_handler ()) - continue; - set_errno (EINTR); - /* fall through intentionally */ - default: - res = -1; - break; - } - break; - } - return res; -} - -int -fhandler_termios::tcgetpgrp () -{ - if (myself->ctty != -1 && myself->ctty == tc->ntty) - return tc->pgid; - set_errno (ENOTTY); - return -1; -} - -int -fhandler_pty_master::tcgetpgrp () -{ - return myself->ctty != -1 && myself->ctty == tc->ntty ? tc->pgid : 0; -} - -void -tty_min::kill_pgrp (int sig) -{ - int killself = 0; - winpids pids ((DWORD) PID_MAP_RW); - siginfo_t si = {0}; - si.si_signo = sig; - si.si_code = SI_KERNEL; - for (unsigned i = 0; i < pids.npids; i++) - { - _pinfo *p = pids[i]; - if (!p->exists () || p->ctty != ntty || p->pgid != pgid) - continue; - if (p == myself) - killself++; - else - sig_send (p, si); - } - if (killself) - sig_send (myself, si); -} - -bg_check_types -fhandler_termios::bg_check (int sig) -{ - if (!myself->pgid || tc->getpgid () == myself->pgid || - myself->ctty != tc->ntty || - ((sig == SIGTTOU) && !(tc->ti.c_lflag & TOSTOP))) - return bg_ok; - - if (sig < 0) - sig = -sig; - - termios_printf ("bg I/O pgid %d, tpgid %d, %s, ntty tty%d", myself->pgid, tc->getpgid (), - myctty (), tc->ntty); - - if (tc->getsid () == 0) - { - /* The pty has been closed by the master. Return an EOF - indication. FIXME: There is nothing to stop somebody - from reallocating this pty. I think this is the case - which is handled by unlockpt on a Unix system. */ - termios_printf ("closed by master"); - return bg_eof; - } - - /* If the process group is no more or if process is ignoring or blocks 'sig', - return with error */ - int pgid_gone = !pid_exists (myself->pgid); - int sigs_ignored = - ((void *) global_sigs[sig].sa_handler == (void *) SIG_IGN) || - (_main_tls->sigmask & SIGTOMASK (sig)); - - if (pgid_gone) - goto setEIO; - else if (!sigs_ignored) - /* nothing */; - else if (sig == SIGTTOU) - return bg_ok; /* Just allow the output */ - else - goto setEIO; /* This is an output error */ - - /* Don't raise a SIGTT* signal if we have already been interrupted - by another signal. */ - if (WaitForSingleObject (signal_arrived, 0) != WAIT_OBJECT_0) - { - siginfo_t si = {0}; - si.si_signo = sig; - si.si_code = SI_KERNEL; - kill_pgrp (myself->pgid, si); - } - return bg_signalled; - -setEIO: - set_errno (EIO); - return bg_error; -} - -#define set_input_done(x) input_done = input_done || (x) - -inline void -fhandler_termios::echo_erase (int force) -{ - if (force || tc->ti.c_lflag & ECHO) - doecho ("\b \b", 3); -} - -line_edit_status -fhandler_termios::line_edit (const char *rptr, int nread, termios& ti) -{ - line_edit_status ret = line_edit_ok; - char c; - int input_done = 0; - bool sawsig = false; - int iscanon = ti.c_lflag & ICANON; - - while (nread-- > 0) - { - c = *rptr++; - - termios_printf ("char %c", c); - - /* Check for special chars */ - - if (c == '\r') - { - if (ti.c_iflag & IGNCR) - continue; - if (ti.c_iflag & ICRNL) - { - c = '\n'; - set_input_done (iscanon); - } - } - else if (c == '\n') - { - if (ti.c_iflag & INLCR) - c = '\r'; - else - set_input_done (iscanon); - } - - if (ti.c_iflag & ISTRIP) - c &= 0x7f; - if (ti.c_lflag & ISIG) - { - int sig; - if (CCEQ (ti.c_cc[VINTR], c)) - sig = SIGINT; - else if (CCEQ (ti.c_cc[VQUIT], c)) - sig = SIGQUIT; - else if (CCEQ (ti.c_cc[VSUSP], c)) - sig = SIGTSTP; - else - goto not_a_sig; - - termios_printf ("got interrupt %d, sending signal %d", c, sig); - eat_readahead (-1); - tc->kill_pgrp (sig); - ti.c_lflag &= ~FLUSHO; - sawsig = true; - goto restart_output; - } - not_a_sig: - if (ti.c_iflag & IXON) - { - if (CCEQ (ti.c_cc[VSTOP], c)) - { - if (!tc->output_stopped) - { - tc->output_stopped = 1; - acquire_output_mutex (INFINITE); - } - continue; - } - else if (CCEQ (ti.c_cc[VSTART], c)) - { - restart_output: - tc->output_stopped = 0; - release_output_mutex (); - continue; - } - else if ((ti.c_iflag & IXANY) && tc->output_stopped) - goto restart_output; - } - if (iscanon && ti.c_lflag & IEXTEN && CCEQ (ti.c_cc[VDISCARD], c)) - { - ti.c_lflag ^= FLUSHO; - continue; - } - if (!iscanon) - /* nothing */; - else if (CCEQ (ti.c_cc[VERASE], c)) - { - if (eat_readahead (1)) - echo_erase (); - continue; - } - else if (CCEQ (ti.c_cc[VWERASE], c)) - { - int ch; - do - if (!eat_readahead (1)) - break; - else - echo_erase (); - while ((ch = peek_readahead (1)) >= 0 && !isspace (ch)); - continue; - } - else if (CCEQ (ti.c_cc[VKILL], c)) - { - int nchars = eat_readahead (-1); - if (ti.c_lflag & ECHO) - while (nchars--) - echo_erase (1); - continue; - } - else if (CCEQ (ti.c_cc[VREPRINT], c)) - { - if (ti.c_lflag & ECHO) - { - doecho ("\n\r", 2); - doecho (rabuf, ralen); - } - continue; - } - else if (CCEQ (ti.c_cc[VEOF], c)) - { - termios_printf ("EOF"); - accept_input (); - ret = line_edit_input_done; - continue; - } - else if (CCEQ (ti.c_cc[VEOL], c) || - CCEQ (ti.c_cc[VEOL2], c) || - c == '\n') - { - set_input_done (1); - termios_printf ("EOL"); - } - - if (ti.c_iflag & IUCLC && isupper (c)) - c = cyg_tolower (c); - - put_readahead (c); - if (ti.c_lflag & ECHO) - doecho (&c, 1); - if (!iscanon || input_done) - { - int status = accept_input (); - if (status != 1) - { - ret = status ? line_edit_error : line_edit_pipe_full; - eat_readahead (1); - break; - } - ret = line_edit_input_done; - input_done = 0; - } - } - - if (!iscanon && ralen > 0) - ret = line_edit_input_done; - - if (sawsig) - ret = line_edit_signalled; - - return ret; -} - -_off64_t -fhandler_termios::lseek (_off64_t, int) -{ - set_errno (ESPIPE); - return -1; -} diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc deleted file mode 100644 index 4e4dc5338..000000000 --- a/winsup/cygwin/fhandler_tty.cc +++ /dev/null @@ -1,1484 +0,0 @@ -/* fhandler_tty.cc - - Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "sigproc.h" -#include "pinfo.h" -#include "cygheap.h" -#include "shared_info.h" -#include "cygserver.h" -#include "cygthread.h" -#include "child_info.h" - -/* tty master stuff */ - -fhandler_tty_master NO_COPY *tty_master; - -static DWORD WINAPI process_input (void *); // Input queue thread -static DWORD WINAPI process_output (void *); // Output queue thread -static DWORD WINAPI process_ioctl (void *); // Ioctl requests thread - -fhandler_tty_master::fhandler_tty_master () - : fhandler_pty_master (), console (NULL) -{ -} - -int -fhandler_tty_slave::get_unit () -{ - return dev () == FH_TTY ? myself->ctty : dev ().minor; -} - -void -fhandler_tty_master::set_winsize (bool sendSIGWINCH) -{ - winsize w; - console->ioctl (TIOCGWINSZ, &w); - get_ttyp ()->winsize = w; - if (sendSIGWINCH) - tc->kill_pgrp (SIGWINCH); -} - -int -fhandler_tty_master::init () -{ - termios_printf ("Creating master for tty%d", get_unit ()); - - if (init_console ()) - { - termios_printf ("can't create fhandler"); - return -1; - } - - if (!setup (false)) - return 1; - - set_winsize (false); - - set_close_on_exec (true); - - cygthread *h; - h = new cygthread (process_input, 0, cygself, "ttyin"); - h->SetThreadPriority (THREAD_PRIORITY_HIGHEST); - h->zap_h (); - - h = new cygthread (process_ioctl, 0, cygself, "ttyioctl"); - h->SetThreadPriority (THREAD_PRIORITY_HIGHEST); - h->zap_h (); - - h = new cygthread (process_output, 0, cygself, "ttyout"); - h->SetThreadPriority (THREAD_PRIORITY_HIGHEST); - h->zap_h (); - - return 0; -} - -#ifdef DEBUGGING -static class mutex_stack -{ -public: - const char *fn; - int ln; - const char *tname; -} ostack[100]; - -static int osi; -#endif /*DEBUGGING*/ - -DWORD -fhandler_tty_common::__acquire_output_mutex (const char *fn, int ln, - DWORD ms) -{ - if (strace.active ()) - strace.prntf (_STRACE_TERMIOS, fn, "(%d): tty output_mutex: waiting %d ms", ln, ms); - DWORD res = WaitForSingleObject (output_mutex, ms); - if (res == WAIT_OBJECT_0) - { -#ifndef DEBUGGING - if (strace.active ()) - strace.prntf (_STRACE_TERMIOS, fn, "(%d): tty output_mutex: acquired", ln, res); -#else - ostack[osi].fn = fn; - ostack[osi].ln = ln; - ostack[osi].tname = cygthread::name (); - termios_printf ("acquired for %s:%d, osi %d", fn, ln, osi); - osi++; -#endif - } - return res; -} - -void -fhandler_tty_common::__release_output_mutex (const char *fn, int ln) -{ - if (ReleaseMutex (output_mutex)) - { -#ifndef DEBUGGING - if (strace.active ()) - strace.prntf (_STRACE_TERMIOS, fn, "(%d): tty output_mutex released", ln); -#else - if (osi > 0) - osi--; - termios_printf ("released at %s:%d, osi %d", fn, ln, osi); - termios_printf (" for %s:%d (%s)", ostack[osi].fn, ostack[osi].ln, ostack[osi].tname); - ostack[osi].ln = -ln; -#endif - } -#ifdef DEBUGGING - else if (osi > 0) - { - system_printf ("couldn't release output mutex but we seem to own it, %E"); - try_to_debug (); - } -#endif -} - -/* Process tty input. */ - -void -fhandler_pty_master::doecho (const void *str, DWORD len) -{ - acquire_output_mutex (INFINITE); - if (!WriteFile (to_master, str, len, &len, NULL)) - termios_printf ("Write to %p failed, %E", to_master); -// WaitForSingleObject (output_done_event, INFINITE); - release_output_mutex (); -} - -int -fhandler_pty_master::accept_input () -{ - DWORD bytes_left; - int ret = 1; - - WaitForSingleObject (input_mutex, INFINITE); - - bytes_left = eat_readahead (-1); - - if (!bytes_left) - { - termios_printf ("sending EOF to slave"); - get_ttyp ()->read_retval = 0; - } - else - { - char *p = rabuf; - DWORD rc; - DWORD written = 0; - - termios_printf ("about to write %d chars to slave", bytes_left); - rc = WriteFile (get_output_handle (), p, bytes_left, &written, NULL); - if (!rc) - { - debug_printf ("error writing to pipe %E"); - get_ttyp ()->read_retval = -1; - ret = -1; - } - else - { - get_ttyp ()->read_retval = 1; - p += written; - bytes_left -= written; - if (bytes_left > 0) - { - debug_printf ("to_slave pipe is full"); - puts_readahead (p, bytes_left); - ret = 0; - } - } - } - - SetEvent (input_available_event); - ReleaseMutex (input_mutex); - return ret; -} - -static DWORD WINAPI -process_input (void *) -{ - char rawbuf[INP_BUFFER_SIZE]; - - while (1) - { - size_t nraw = INP_BUFFER_SIZE; - tty_master->console->read ((void *) rawbuf, nraw); - if (tty_master->line_edit (rawbuf, nraw, tty_master->get_ttyp ()->ti) - == line_edit_signalled) - tty_master->console->eat_readahead (-1); - } -} - -bool -fhandler_pty_master::hit_eof () -{ - if (get_ttyp ()->was_opened && !get_ttyp ()->slave_alive ()) - { - /* We have the only remaining open handle to this pty, and - the slave pty has been opened at least once. We treat - this as EOF. */ - termios_printf ("all other handles closed"); - return 1; - } - return 0; -} - -/* Process tty output requests */ - -int -fhandler_pty_master::process_slave_output (char *buf, size_t len, int pktmode_on) -{ - size_t rlen; - char outbuf[OUT_BUFFER_SIZE + 1]; - DWORD n; - int column = 0; - int rc = 0; - - if (len == 0) - goto out; - - if (need_nl) - { - /* We need to return a left over \n character, resulting from - \r\n conversion. Note that we already checked for FLUSHO and - output_stopped at the time that we read the character, so we - don't check again here. */ - if (buf) - buf[0] = '\n'; - need_nl = 0; - rc = 1; - goto out; - } - - - for (;;) - { - /* Set RLEN to the number of bytes to read from the pipe. */ - rlen = len; - if (get_ttyp ()->ti.c_oflag & OPOST && get_ttyp ()->ti.c_oflag & ONLCR) - { - /* We are going to expand \n to \r\n, so don't read more than - half of the number of bytes requested. */ - rlen /= 2; - if (rlen == 0) - rlen = 1; - } - if (rlen > sizeof outbuf) - rlen = sizeof outbuf; - - HANDLE handle = get_io_handle (); - - n = 0; // get_readahead_into_buffer (outbuf, len); - if (!n) - { - /* Doing a busy wait like this is quite inefficient, but nothing - else seems to work completely. Windows should provide some sort - of overlapped I/O for pipes, or something, but it doesn't. */ - while (1) - { - if (!PeekNamedPipe (handle, NULL, 0, NULL, &n, NULL)) - goto err; - if (n > 0) - break; - if (hit_eof ()) - goto out; - /* DISCARD (FLUSHO) and tcflush can finish here. */ - if (n == 0 && (get_ttyp ()->ti.c_lflag & FLUSHO || !buf)) - goto out; - if (n == 0 && is_nonblocking ()) - { - set_errno (EAGAIN); - rc = -1; - break; - } - - Sleep (10); - } - - if (ReadFile (handle, outbuf, rlen, &n, NULL) == FALSE) - goto err; - } - - termios_printf ("bytes read %u", n); - get_ttyp ()->write_error = 0; - if (output_done_event != NULL) - SetEvent (output_done_event); - - if (get_ttyp ()->ti.c_lflag & FLUSHO || !buf) - continue; - - char *optr; - optr = buf; - if (pktmode_on) - *optr++ = TIOCPKT_DATA; - - if (!(get_ttyp ()->ti.c_oflag & OPOST)) // post-process output - { - memcpy (optr, outbuf, n); - optr += n; - } - else // raw output mode - { - char *iptr = outbuf; - - while (n--) - { - switch (*iptr) - { - case '\r': - if ((get_ttyp ()->ti.c_oflag & ONOCR) && column == 0) - { - iptr++; - continue; - } - if (get_ttyp ()->ti.c_oflag & OCRNL) - *iptr = '\n'; - else - column = 0; - break; - case '\n': - if (get_ttyp ()->ti.c_oflag & ONLCR) - { - *optr++ = '\r'; - column = 0; - } - if (get_ttyp ()->ti.c_oflag & ONLRET) - column = 0; - break; - default: - column++; - break; - } - - /* Don't store data past the end of the user's buffer. This - can happen if the user requests a read of 1 byte when - doing \r\n expansion. */ - if (optr - buf >= (int) len) - { - if (*iptr != '\n' || n != 0) - system_printf ("internal error: %d unexpected characters", n); - need_nl = 1; - break; - } - - *optr++ = *iptr++; - } - } - rc = optr - buf; - break; - - err: - if (GetLastError () == ERROR_BROKEN_PIPE) - rc = 0; - else - { - __seterrno (); - rc = -1; - } - break; - } - -out: - termios_printf ("returning %d", rc); - return rc; -} - -static DWORD WINAPI -process_output (void *) -{ - char buf[OUT_BUFFER_SIZE * 2]; - - for (;;) - { - int n = tty_master->process_slave_output (buf, OUT_BUFFER_SIZE, 0); - if (n <= 0) - { - if (n < 0) - termios_printf ("ReadFile %E"); - ExitThread (0); - } - n = tty_master->console->write ((void *) buf, (size_t) n); - tty_master->get_ttyp ()->write_error = n == -1 ? get_errno () : 0; - } -} - - -/* Process tty ioctl requests */ - -static DWORD WINAPI -process_ioctl (void *) -{ - while (1) - { - WaitForSingleObject (tty_master->ioctl_request_event, INFINITE); - termios_printf ("ioctl() request"); - tty *ttyp = tty_master->get_ttyp (); - ttyp->ioctl_retval = - tty_master->console->ioctl (ttyp->cmd, - (ttyp->cmd == KDSKBMETA) - ? (void *) ttyp->arg.value - : (void *) &ttyp->arg); - SetEvent (tty_master->ioctl_done_event); - } -} - -/**********************************************************************/ -/* Tty slave stuff */ - -fhandler_tty_slave::fhandler_tty_slave () - : fhandler_tty_common (), inuse (NULL) -{ - uninterruptible_io (true); -} - -/* FIXME: This function needs to close handles when it has - a failing condition. */ -int -fhandler_tty_slave::open (int flags, mode_t) -{ - if (get_device () == FH_TTY) - dev().tty_to_real_device (); - fhandler_tty_slave *arch = (fhandler_tty_slave *) cygheap->fdtab.find_archetype (pc.dev); - if (arch) - { - *this = *(fhandler_tty_slave *) arch; - termios_printf ("copied fhandler_tty_slave archetype"); - set_flags ((flags & ~O_TEXT) | O_BINARY); - cygheap->manage_console_count ("fhandler_tty_slave::open", 1); - goto out; - } - - tcinit (cygwin_shared->tty[get_unit ()]); - - cygwin_shared->tty.attach (get_unit ()); - - set_flags ((flags & ~O_TEXT) | O_BINARY); - /* Create synchronisation events */ - char buf[MAX_PATH]; - - /* output_done_event may or may not exist. It will exist if the tty - was opened by fhandler_tty_master::init, normally called at - startup if use_tty is non-zero. It will not exist if this is a - pty opened by fhandler_pty_master::open. In the former case, tty - output is handled by a separate thread which controls output. */ - shared_name (buf, OUTPUT_DONE_EVENT, get_unit ()); - output_done_event = OpenEvent (EVENT_ALL_ACCESS, TRUE, buf); - - if (!(output_mutex = get_ttyp ()->open_output_mutex ())) - { - termios_printf ("open output mutex failed, %E"); - __seterrno (); - return 0; - } - if (!(input_mutex = get_ttyp ()->open_input_mutex ())) - { - termios_printf ("open input mutex failed, %E"); - __seterrno (); - return 0; - } - shared_name (buf, INPUT_AVAILABLE_EVENT, get_unit ()); - if (!(input_available_event = OpenEvent (EVENT_ALL_ACCESS, TRUE, buf))) - { - termios_printf ("open input event failed, %E"); - __seterrno (); - return 0; - } - - /* The ioctl events may or may not exist. See output_done_event, - above. */ - shared_name (buf, IOCTL_REQUEST_EVENT, get_unit ()); - ioctl_request_event = OpenEvent (EVENT_ALL_ACCESS, TRUE, buf); - shared_name (buf, IOCTL_DONE_EVENT, get_unit ()); - ioctl_done_event = OpenEvent (EVENT_ALL_ACCESS, TRUE, buf); - - /* FIXME: Needs a method to eliminate tty races */ - { - acquire_output_mutex (500); - inuse = get_ttyp ()->create_inuse (TTY_SLAVE_ALIVE); - get_ttyp ()->was_opened = true; - release_output_mutex (); - } - - if (!get_ttyp ()->from_master || !get_ttyp ()->to_master) - { - termios_printf ("tty handles have been closed"); - set_errno (EACCES); - return 0; - } - - HANDLE from_master_local; - HANDLE to_master_local; - from_master_local = to_master_local = NULL; - - if (cygserver_running == CYGSERVER_UNAVAIL - || !cygserver_attach_tty (&from_master_local, &to_master_local)) - { - if (get_ttyp ()->master_pid < 0) - { - set_errno (EAGAIN); - termios_printf ("*** master is closed"); - return 0; - } - pinfo p (get_ttyp ()->master_pid); - if (!p) - { - set_errno (EAGAIN); - termios_printf ("*** couldn't find tty master"); - return 0; - } - termios_printf ("cannot dup handles via server. using old method."); - HANDLE tty_owner = OpenProcess (PROCESS_DUP_HANDLE, FALSE, - p->dwProcessId); - if (tty_owner == NULL) - { - termios_printf ("can't open tty (%d) handle process %d", - get_unit (), get_ttyp ()->master_pid); - __seterrno (); - return 0; - } - - if (!DuplicateHandle (tty_owner, get_ttyp ()->from_master, - GetCurrentProcess (), &from_master_local, 0, TRUE, - DUPLICATE_SAME_ACCESS)) - { - termios_printf ("can't duplicate input from %u/%p, %E", - get_ttyp ()->master_pid, get_ttyp ()->from_master); - __seterrno (); - return 0; - } - - VerifyHandle (from_master_local); - if (!DuplicateHandle (tty_owner, get_ttyp ()->to_master, - GetCurrentProcess (), &to_master_local, 0, TRUE, - DUPLICATE_SAME_ACCESS)) - { - termios_printf ("can't duplicate output, %E"); - __seterrno (); - return 0; - } - VerifyHandle (to_master_local); - CloseHandle (tty_owner); - } - - termios_printf ("duplicated from_master %p->%p from tty_owner", - get_ttyp ()->from_master, from_master_local); - termios_printf ("duplicated to_master %p->%p from tty_owner", - get_ttyp ()->to_master, to_master_local); - - set_io_handle (from_master_local); - set_output_handle (to_master_local); - set_close_on_exec (!!(flags & O_CLOEXEC)); - - set_open_status (); - if (cygheap->manage_console_count ("fhandler_tty_slave::open", 1) == 1 - && !output_done_event) - fhandler_console::need_invisible (); - - // FIXME: Do this better someday - arch = (fhandler_tty_slave *) cmalloc_abort (HEAP_ARCHETYPES, sizeof (*this)); - *((fhandler_tty_slave **) cygheap->fdtab.add_archetype ()) = arch; - archetype = arch; - *arch = *this; - -out: - usecount = 0; - arch->usecount++; - report_tty_counts (this, "opened", ""); - myself->set_ctty (get_ttyp (), flags, arch); - - return 1; -} - -int -fhandler_tty_slave::close () -{ - /* This used to always call fhandler_tty_common::close when hExeced but that - caused multiple closes of the handles associated with this tty. Since - close_all_files is not called until after the cygwin process has synced - or before a non-cygwin process has exited, it should be safe to just - close this normally. cgf 2006-05-20 */ - cygheap->manage_console_count ("fhandler_tty_slave::close", -1); - - archetype->usecount--; - report_tty_counts (this, "closed", ""); - - if (archetype->usecount) - { -#ifdef DEBUGGING - if (archetype->usecount < 0) - system_printf ("error: usecount %d", archetype->usecount); -#endif - termios_printf ("just returning because archetype usecount is != 0"); - return 0; - } - - termios_printf ("closing last open %s handle", ttyname ()); - if (inuse && !CloseHandle (inuse)) - termios_printf ("CloseHandle (inuse), %E"); - return fhandler_tty_common::close (); -} - -int -fhandler_tty_slave::cygserver_attach_tty (LPHANDLE from_master_ptr, - LPHANDLE to_master_ptr) -{ - if (!from_master_ptr || !to_master_ptr) - return 0; - - client_request_attach_tty req ((DWORD) get_ttyp ()->master_pid, - (HANDLE) get_ttyp ()->from_master, - (HANDLE) get_ttyp ()->to_master); - - if (req.make_request () == -1 || req.error_code ()) - return 0; - - *from_master_ptr = req.from_master (); - *to_master_ptr = req.to_master (); - - return 1; -} - -int -fhandler_tty_slave::init (HANDLE, DWORD a, mode_t) -{ - int flags = 0; - - a &= GENERIC_READ | GENERIC_WRITE; - if (a == GENERIC_READ) - flags = O_RDONLY; - if (a == GENERIC_WRITE) - flags = O_WRONLY; - if (a == (GENERIC_READ | GENERIC_WRITE)) - flags = O_RDWR; - - return open (flags); -} - -ssize_t __stdcall -fhandler_tty_slave::write (const void *ptr, size_t len) -{ - DWORD n, towrite = len; - - termios_printf ("tty%d, write(%x, %d)", get_unit (), ptr, len); - - acquire_output_mutex (INFINITE); - - while (len) - { - n = min (OUT_BUFFER_SIZE, len); - char *buf = (char *)ptr; - ptr = (char *) ptr + n; - len -= n; - - /* Previous write may have set write_error to != 0. Check it here. - This is less than optimal, but the alternative slows down tty - writes enormously. */ - if (get_ttyp ()->write_error) - { - set_errno (get_ttyp ()->write_error); - towrite = (DWORD) -1; - break; - } - - if (WriteFile (get_output_handle (), buf, n, &n, NULL) == FALSE) - { - DWORD err = GetLastError (); - termios_printf ("WriteFile failed, %E"); - switch (err) - { - case ERROR_NO_DATA: - err = ERROR_IO_DEVICE; - default: - __seterrno_from_win_error (err); - } - raise (SIGHUP); /* FIXME: Should this be SIGTTOU? */ - towrite = (DWORD) -1; - break; - } - - if (output_done_event != NULL) - { - DWORD rc; - DWORD x = n * 1000; - rc = WaitForSingleObject (output_done_event, x); - termios_printf ("waited %d ms for output_done_event, WFSO %d", x, rc); - } - } - release_output_mutex (); - return towrite; -} - -void __stdcall -fhandler_tty_slave::read (void *ptr, size_t& len) -{ - int totalread = 0; - int vmin = 0; - int vtime = 0; /* Initialized to prevent -Wuninitialized warning */ - size_t readlen; - DWORD bytes_in_pipe; - char buf[INP_BUFFER_SIZE]; - char peek_buf[INP_BUFFER_SIZE]; - DWORD time_to_wait; - DWORD rc; - HANDLE w4[2]; - - termios_printf ("read(%x, %d) handle %p", ptr, len, get_handle ()); - - if (!ptr) /* Indicating tcflush(). */ - time_to_wait = 0; - else if ((get_ttyp ()->ti.c_lflag & ICANON)) - time_to_wait = INFINITE; - else - { - vmin = get_ttyp ()->ti.c_cc[VMIN]; - if (vmin > INP_BUFFER_SIZE) - vmin = INP_BUFFER_SIZE; - vtime = get_ttyp ()->ti.c_cc[VTIME]; - if (vmin < 0) - vmin = 0; - if (vtime < 0) - vtime = 0; - if (!vmin && !vtime) - time_to_wait = 0; - else - time_to_wait = !vtime ? INFINITE : 100 * vtime; - } - - w4[0] = signal_arrived; - w4[1] = input_available_event; - - DWORD waiter = time_to_wait; - while (len) - { - rc = WaitForMultipleObjects (2, w4, FALSE, waiter); - - if (rc == WAIT_TIMEOUT) - { - termios_printf ("wait timed out, waiter %u", waiter); - break; - } - - if (rc == WAIT_FAILED) - { - termios_printf ("wait for input event failed, %E"); - break; - } - - if (rc == WAIT_OBJECT_0) - { - /* if we've received signal after successfully reading some data, - just return all data successfully read */ - if (totalread > 0) - break; - set_sig_errno (EINTR); - len = (size_t) -1; - return; - } - - rc = WaitForSingleObject (input_mutex, 1000); - if (rc == WAIT_FAILED) - { - termios_printf ("wait for input mutex failed, %E"); - break; - } - else if (rc == WAIT_TIMEOUT) - { - termios_printf ("failed to acquire input mutex after input event arrived"); - break; - } - if (!PeekNamedPipe (get_handle (), peek_buf, sizeof (peek_buf), &bytes_in_pipe, NULL, NULL)) - { - termios_printf ("PeekNamedPipe failed, %E"); - raise (SIGHUP); - bytes_in_pipe = 0; - } - - /* On first peek determine no. of bytes to flush. */ - if (!ptr && len == UINT_MAX) - len = (size_t) bytes_in_pipe; - - if (ptr && !bytes_in_pipe && !vmin && !time_to_wait) - { - ReleaseMutex (input_mutex); - len = (size_t) bytes_in_pipe; - return; - } - - readlen = min (bytes_in_pipe, min (len, sizeof (buf))); - - if (ptr && vmin && readlen > (unsigned) vmin) - readlen = vmin; - - DWORD n = 0; - if (readlen) - { - termios_printf ("reading %d bytes (vtime %d)", readlen, vtime); - if (ReadFile (get_handle (), buf, readlen, &n, NULL) == FALSE) - { - termios_printf ("read failed, %E"); - raise (SIGHUP); - } - /* MSDN states that 5th prameter can be used to determine total - number of bytes in pipe, but for some reason this number doesn't - change after successful read. So we have to peek into the pipe - again to see if input is still available */ - if (!PeekNamedPipe (get_handle (), peek_buf, 1, &bytes_in_pipe, NULL, NULL)) - { - termios_printf ("PeekNamedPipe failed, %E"); - raise (SIGHUP); - bytes_in_pipe = 0; - } - if (n) - { - len -= n; - totalread += n; - if (ptr) - { - memcpy (ptr, buf, n); - ptr = (char *) ptr + n; - } - } - } - - if (!bytes_in_pipe) - ResetEvent (input_available_event); - - ReleaseMutex (input_mutex); - - if (!ptr) - { - if (!bytes_in_pipe) - break; - continue; - } - - if (get_ttyp ()->read_retval < 0) // read error - { - set_errno (-get_ttyp ()->read_retval); - totalread = -1; - break; - } - if (get_ttyp ()->read_retval == 0) //EOF - { - termios_printf ("saw EOF"); - break; - } - if (get_ttyp ()->ti.c_lflag & ICANON || is_nonblocking ()) - break; - if (vmin && totalread >= vmin) - break; - - /* vmin == 0 && vtime == 0: - * we've already read all input, if any, so return immediately - * vmin == 0 && vtime > 0: - * we've waited for input 10*vtime ms in WFSO(input_available_event), - * no matter whether any input arrived, we shouldn't wait any longer, - * so return immediately - * vmin > 0 && vtime == 0: - * here, totalread < vmin, so continue waiting until more data - * arrive - * vmin > 0 && vtime > 0: - * similar to the previous here, totalread < vmin, and timer - * hadn't expired -- WFSO(input_available_event) != WAIT_TIMEOUT, - * so "restart timer" and wait until more data arrive - */ - - if (vmin == 0) - break; - - if (n) - waiter = time_to_wait; - } - termios_printf ("%d=read(%x, %d)", totalread, ptr, len); - len = (size_t) totalread; -} - -int -fhandler_tty_slave::dup (fhandler_base *child) -{ - fhandler_tty_slave *arch = (fhandler_tty_slave *) archetype; - *(fhandler_tty_slave *) child = *arch; - child->set_flags (get_flags ()); - child->usecount = 0; - arch->usecount++; - cygheap->manage_console_count ("fhandler_tty_slave::dup", 1); - report_tty_counts (child, "duped", ""); - return 0; -} - -int -fhandler_pty_master::dup (fhandler_base *child) -{ - fhandler_tty_master *arch = (fhandler_tty_master *) archetype; - *(fhandler_tty_master *) child = *arch; - child->set_flags (get_flags ()); - child->usecount = 0; - arch->usecount++; - report_tty_counts (child, "duped master", ""); - return 0; -} - -int -fhandler_tty_slave::tcgetattr (struct termios *t) -{ - *t = get_ttyp ()->ti; - return 0; -} - -int -fhandler_tty_slave::tcsetattr (int, const struct termios *t) -{ - acquire_output_mutex (INFINITE); - get_ttyp ()->ti = *t; - release_output_mutex (); - return 0; -} - -int -fhandler_tty_slave::tcflush (int queue) -{ - int ret = 0; - - termios_printf ("tcflush(%d) handle %p", queue, get_handle ()); - - if (queue == TCIFLUSH || queue == TCIOFLUSH) - { - size_t len = UINT_MAX; - read (NULL, len); - ret = ((int) len) >= 0 ? 0 : -1; - } - if (queue == TCOFLUSH || queue == TCIOFLUSH) - { - /* do nothing for now. */ - } - - termios_printf ("%d=tcflush(%d)", ret, queue); - return ret; -} - -int -fhandler_tty_slave::ioctl (unsigned int cmd, void *arg) -{ - termios_printf ("ioctl (%x)", cmd); - - if (myself->pgid && get_ttyp ()->getpgid () != myself->pgid - && myself->ctty == get_unit () && (get_ttyp ()->ti.c_lflag & TOSTOP)) - { - /* background process */ - termios_printf ("bg ioctl pgid %d, tpgid %d, %s", myself->pgid, - get_ttyp ()->getpgid (), myctty ()); - raise (SIGTTOU); - } - - int retval; - switch (cmd) - { - case TIOCGWINSZ: - case TIOCSWINSZ: - case TIOCLINUX: - case KDGKBMETA: - case KDSKBMETA: - break; - case FIONBIO: - set_nonblocking (*(int *) arg); - retval = 0; - goto out; - default: - set_errno (EINVAL); - return -1; - } - - acquire_output_mutex (INFINITE); - - get_ttyp ()->cmd = cmd; - get_ttyp ()->ioctl_retval = 0; - int val; - switch (cmd) - { - case TIOCGWINSZ: - get_ttyp ()->arg.winsize = get_ttyp ()->winsize; - if (ioctl_request_event) - SetEvent (ioctl_request_event); - *(struct winsize *) arg = get_ttyp ()->arg.winsize; - if (ioctl_done_event) - WaitForSingleObject (ioctl_done_event, INFINITE); - get_ttyp ()->winsize = get_ttyp ()->arg.winsize; - break; - case TIOCSWINSZ: - if (get_ttyp ()->winsize.ws_row != ((struct winsize *) arg)->ws_row - || get_ttyp ()->winsize.ws_col != ((struct winsize *) arg)->ws_col) - { - get_ttyp ()->arg.winsize = *(struct winsize *) arg; - if (ioctl_request_event) - { - get_ttyp ()->ioctl_retval = -EINVAL; - SetEvent (ioctl_request_event); - } - else - { - get_ttyp ()->winsize = *(struct winsize *) arg; - killsys (-get_ttyp ()->getpgid (), SIGWINCH); - } - if (ioctl_done_event) - WaitForSingleObject (ioctl_done_event, INFINITE); - } - break; - case TIOCLINUX: - val = *(unsigned char *) arg; - if (val != 6 || !ioctl_request_event || !ioctl_done_event) - get_ttyp ()->ioctl_retval = -EINVAL; - else - { - get_ttyp ()->arg.value = val; - SetEvent (ioctl_request_event); - WaitForSingleObject (ioctl_done_event, INFINITE); - *(unsigned char *) arg = (unsigned char) (get_ttyp ()->arg.value); - } - break; - case KDGKBMETA: - if (ioctl_request_event) - { - SetEvent (ioctl_request_event); - if (ioctl_done_event) - WaitForSingleObject (ioctl_done_event, INFINITE); - *(int *) arg = get_ttyp ()->arg.value; - } - else - get_ttyp ()->ioctl_retval = -EINVAL; - break; - case KDSKBMETA: - if (ioctl_request_event) - { - get_ttyp ()->arg.value = (int) arg; - SetEvent (ioctl_request_event); - if (ioctl_done_event) - WaitForSingleObject (ioctl_done_event, INFINITE); - } - else - get_ttyp ()->ioctl_retval = -EINVAL; - break; - } - - release_output_mutex (); - retval = get_ttyp ()->ioctl_retval; - if (retval < 0) - { - set_errno (-retval); - retval = -1; - } - -out: - termios_printf ("%d = ioctl (%x)", retval, cmd); - return retval; -} - -/******************************************************* - fhandler_pty_master -*/ -fhandler_pty_master::fhandler_pty_master () - : fhandler_tty_common (), pktmode (0), need_nl (0), dwProcessId (0) -{ -} - -int -fhandler_pty_master::open (int flags, mode_t) -{ - int ntty; - ntty = cygwin_shared->tty.allocate (false); - if (ntty < 0) - return 0; - - dev().devn = FHDEV (DEV_TTYM_MAJOR, ntty); - if (!setup (true)) - { - lock_ttys::release (); - return 0; - } - lock_ttys::release (); - set_flags ((flags & ~O_TEXT) | O_BINARY); - set_open_status (); - // - // FIXME: Do this better someday - fhandler_pty_master *arch = (fhandler_tty_master *) cmalloc_abort (HEAP_ARCHETYPES, sizeof (*this)); - *((fhandler_pty_master **) cygheap->fdtab.add_archetype ()) = arch; - archetype = arch; - *arch = *this; - arch->dwProcessId = GetCurrentProcessId (); - - usecount = 0; - arch->usecount++; - char buf[sizeof ("opened pty master for ttyNNNNNNNNNNN")]; - __small_sprintf (buf, "opened pty master for tty%d", get_unit ()); - report_tty_counts (this, buf, ""); - return 1; -} - -_off64_t -fhandler_tty_common::lseek (_off64_t, int) -{ - set_errno (ESPIPE); - return -1; -} - -int -fhandler_tty_common::close () -{ - termios_printf ("tty%d <%p,%p> closing", get_unit (), get_handle (), get_output_handle ()); - if (output_done_event && !CloseHandle (output_done_event)) - termios_printf ("CloseHandle (output_done_event), %E"); - if (ioctl_done_event && !CloseHandle (ioctl_done_event)) - termios_printf ("CloseHandle (ioctl_done_event), %E"); - if (ioctl_request_event && !CloseHandle (ioctl_request_event)) - termios_printf ("CloseHandle (ioctl_request_event), %E"); - if (!ForceCloseHandle (input_mutex)) - termios_printf ("CloseHandle (input_mutex<%p>), %E", input_mutex); - if (!ForceCloseHandle (output_mutex)) - termios_printf ("CloseHandle (output_mutex<%p>), %E", output_mutex); - if (!ForceCloseHandle1 (get_handle (), from_pty)) - termios_printf ("CloseHandle (get_handle ()<%p>), %E", get_handle ()); - if (!ForceCloseHandle1 (get_output_handle (), to_pty)) - termios_printf ("CloseHandle (get_output_handle ()<%p>), %E", get_output_handle ()); - - if (!ForceCloseHandle (input_available_event)) - termios_printf ("CloseHandle (input_available_event<%p>), %E", input_available_event); - - return 0; -} - -int -fhandler_pty_master::close () -{ -#if 0 - while (accept_input () > 0) - continue; -#endif - archetype->usecount--; - report_tty_counts (this, "closing master", ""); - - if (archetype->usecount) - { -#ifdef DEBUGGING - if (archetype->usecount < 0) - system_printf ("error: usecount %d", archetype->usecount); -#endif - termios_printf ("just returning because archetype usecount is != 0"); - return 0; - } - - fhandler_tty_master *arch = (fhandler_tty_master *) archetype; - termios_printf ("closing from_master(%p)/to_master(%p) since we own them(%d)", - arch->from_master, arch->to_master, arch->dwProcessId); - if (cygwin_finished_initializing) - { - if (!ForceCloseHandle (arch->from_master)) - termios_printf ("error closing from_master %p, %E", arch->from_master); - if (!ForceCloseHandle (arch->to_master)) - termios_printf ("error closing from_master %p, %E", arch->to_master); - } - fhandler_tty_common::close (); - - if (hExeced || get_ttyp ()->master_pid != myself->pid) - termios_printf ("not clearing: %d, master_pid %d", hExeced, get_ttyp ()->master_pid); - else - get_ttyp ()->set_master_closed (); - - return 0; -} - -ssize_t __stdcall -fhandler_pty_master::write (const void *ptr, size_t len) -{ - int i; - char *p = (char *) ptr; - termios ti = tc->ti; - - for (i = 0; i < (int) len; i++) - { - line_edit_status status = line_edit (p++, 1, ti); - if (status > line_edit_signalled) - { - if (status != line_edit_pipe_full) - i = -1; - break; - } - } - return i; -} - -void __stdcall -fhandler_pty_master::read (void *ptr, size_t& len) -{ - len = (size_t) process_slave_output ((char *) ptr, len, pktmode); -} - -int -fhandler_pty_master::tcgetattr (struct termios *t) -{ - *t = cygwin_shared->tty[get_unit ()]->ti; - return 0; -} - -int -fhandler_pty_master::tcsetattr (int, const struct termios *t) -{ - cygwin_shared->tty[get_unit ()]->ti = *t; - return 0; -} - -int -fhandler_pty_master::tcflush (int queue) -{ - int ret = 0; - - termios_printf ("tcflush(%d) handle %p", queue, get_handle ()); - - if (queue == TCIFLUSH || queue == TCIOFLUSH) - ret = process_slave_output (NULL, OUT_BUFFER_SIZE, 0); - else if (queue == TCIFLUSH || queue == TCIOFLUSH) - { - /* do nothing for now. */ - } - - termios_printf ("%d=tcflush(%d)", ret, queue); - return ret; -} - -int -fhandler_pty_master::ioctl (unsigned int cmd, void *arg) -{ - switch (cmd) - { - case TIOCPKT: - pktmode = *(int *) arg; - break; - case TIOCGWINSZ: - *(struct winsize *) arg = get_ttyp ()->winsize; - break; - case TIOCSWINSZ: - if (get_ttyp ()->winsize.ws_row != ((struct winsize *) arg)->ws_row - || get_ttyp ()->winsize.ws_col != ((struct winsize *) arg)->ws_col) - { - get_ttyp ()->winsize = *(struct winsize *) arg; - killsys (-get_ttyp ()->getpgid (), SIGWINCH); - } - break; - case FIONBIO: - set_nonblocking (*(int *) arg); - break; - default: - set_errno (EINVAL); - return -1; - } - return 0; -} - -char * -fhandler_pty_master::ptsname () -{ - static char buf[TTY_NAME_MAX]; - - __small_sprintf (buf, "/dev/tty%d", get_unit ()); - return buf; -} - -void -fhandler_tty_common::set_close_on_exec (bool val) -{ - // Cygwin processes will handle this specially on exec. - close_on_exec (val); -} - -void -fhandler_tty_slave::fixup_after_fork (HANDLE parent) -{ - // fork_fixup (parent, inuse, "inuse"); - // fhandler_tty_common::fixup_after_fork (parent); - report_tty_counts (this, "inherited", ""); -} - -void -fhandler_tty_slave::fixup_after_exec () -{ - if (!close_on_exec ()) - fixup_after_fork (NULL); -} - -int -fhandler_tty_master::init_console () -{ - console = (fhandler_console *) build_fh_dev (*console_dev, "/dev/ttym"); - if (console == NULL) - return -1; - - console->init (INVALID_HANDLE_VALUE, GENERIC_READ | GENERIC_WRITE, O_BINARY); - cygheap->manage_console_count ("fhandler_tty_master::init_console", -1, true); - console->uninterruptible_io (true); - return 0; -} - -#define close_maybe(h) \ - do { \ - if (h && h != INVALID_HANDLE_VALUE) \ - CloseHandle (h); \ - } while (0) - -bool -fhandler_pty_master::setup (bool ispty) -{ - int res; - tty& t = *cygwin_shared->tty[get_unit ()]; - - tcinit (&t, true); /* Set termios information. Force initialization. */ - - const char *errstr = NULL; - DWORD pipe_mode = PIPE_NOWAIT; - - /* Create communication pipes */ - - char pipename[sizeof("ttyNNNN-from-master")]; - __small_sprintf (pipename, "tty%d-from-master", get_unit ()); - res = fhandler_pipe::create_selectable (&sec_none_nih, from_master, - get_output_handle (), 128 * 1024, - pipename); - if (res) - { - errstr = "input pipe"; - goto err; - } - /* Only ptys should create inheritable handles by default. ttys are - parcelled out on an as-needed basis and handle inheritance differently. */ - if (ispty && !SetHandleInformation (get_output_handle (), HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) - { - errstr = "inheritable get_output_handle ()"; - goto err; - } - - if (!SetNamedPipeHandleState (get_output_handle (), &pipe_mode, NULL, NULL)) - termios_printf ("can't set output_handle(%p) to non-blocking mode", - get_output_handle ()); - - __small_sprintf (pipename, "tty%d-to-master", get_unit ()); - res = fhandler_pipe::create_selectable (&sec_none_nih, get_io_handle (), - to_master, 128 * 1024, pipename); - if (res) - { - errstr = "output pipe"; - goto err; - } - /* Only ptys should create inheritable handles by default. ttys are - parcelled out on an as-needed basis and handle inheritance differently. */ - if (ispty && !SetHandleInformation (get_io_handle (), HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) - { - errstr = "inheritable get_io_handle ()"; - goto err; - } - - need_nl = 0; - - /* We do not allow others to open us (for handle duplication) - but rely on cygheap->inherited_ctty for descendant processes. - In the future the cygserver may allow access by others. */ - - if (cygserver_running == CYGSERVER_UNKNOWN) - cygserver_init (); - - /* Create synchronisation events */ - - if (!ispty) - { - if (!(output_done_event = t.get_event (errstr = OUTPUT_DONE_EVENT))) - goto err; - if (!(ioctl_done_event = t.get_event (errstr = IOCTL_DONE_EVENT))) - goto err; - if (!(ioctl_request_event = t.get_event (errstr = IOCTL_REQUEST_EVENT))) - goto err; - } - - if (!(input_available_event = t.get_event (errstr = INPUT_AVAILABLE_EVENT, TRUE))) - goto err; - - char buf[MAX_PATH]; - errstr = shared_name (buf, OUTPUT_MUTEX, t.ntty); - if (!(output_mutex = CreateMutex (&sec_all, FALSE, buf))) - goto err; - - errstr = shared_name (buf, INPUT_MUTEX, t.ntty); - if (!(input_mutex = CreateMutex (&sec_all, FALSE, buf))) - goto err; - - t.from_master = from_master; - t.to_master = to_master; - // /* screws up tty master */ ProtectHandle1INH (output_mutex, output_mutex); - // /* screws up tty master */ ProtectHandle1INH (input_mutex, input_mutex); - t.winsize.ws_col = 80; - t.winsize.ws_row = 25; - t.master_pid = myself->pid; - - termios_printf ("tty%d opened - from_slave %p, to_slave %p", t.ntty, - get_io_handle (), get_output_handle ()); - return true; - -err: - __seterrno (); - close_maybe (get_io_handle ()); - close_maybe (get_output_handle ()); - close_maybe (output_done_event); - close_maybe (ioctl_done_event); - close_maybe (ioctl_request_event); - close_maybe (input_available_event); - close_maybe (output_mutex); - close_maybe (input_mutex); - close_maybe (from_master); - close_maybe (to_master); - termios_printf ("tty%d open failed - failed to create %s", errstr); - return false; -} - -void -fhandler_pty_master::fixup_after_fork (HANDLE parent) -{ - DWORD wpid = GetCurrentProcessId (); - fhandler_tty_master *arch = (fhandler_tty_master *) archetype; - if (arch->dwProcessId != wpid) - { - tty& t = *get_ttyp (); - if (!DuplicateHandle (parent, arch->from_master, GetCurrentProcess (), - &arch->from_master, 0, false, DUPLICATE_SAME_ACCESS)) - system_printf ("couldn't duplicate from_parent(%p), %E", arch->from_master); - if (!DuplicateHandle (parent, arch->to_master, GetCurrentProcess (), - &arch->to_master, 0, false, DUPLICATE_SAME_ACCESS)) - system_printf ("couldn't duplicate to_parent(%p), %E", arch->from_master); - if (myself->pid == t.master_pid) - { - t.from_master = arch->from_master; - t.to_master = arch->to_master; - } - arch->dwProcessId = wpid; - } - from_master = arch->from_master; - to_master = arch->to_master; - report_tty_counts (this, "inherited master", ""); -} - -void -fhandler_pty_master::fixup_after_exec () -{ - if (!close_on_exec ()) - fixup_after_fork (spawn_info->parent); - else - from_master = to_master = NULL; -} diff --git a/winsup/cygwin/fhandler_virtual.cc b/winsup/cygwin/fhandler_virtual.cc deleted file mode 100644 index c47d2ccdd..000000000 --- a/winsup/cygwin/fhandler_virtual.cc +++ /dev/null @@ -1,277 +0,0 @@ -/* fhandler_virtual.cc: base fhandler class for virtual filesystems - - Copyright 2002, 2003, 2004, 2005, 2007, 2008, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include "cygerrno.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" - -#include - -fhandler_virtual::fhandler_virtual (): - fhandler_base (), filebuf (NULL), fileid (-1) -{ -} - -fhandler_virtual::~fhandler_virtual () -{ - if (filebuf) - { - cfree (filebuf); - filebuf = NULL; - } -} - -void -fhandler_virtual::fixup_after_exec () -{ -} - -DIR * -fhandler_virtual::opendir (int fd) -{ - DIR *dir; - DIR *res = NULL; - size_t len; - - if (exists () <= 0) - set_errno (ENOTDIR); - else if ((len = strlen (get_name ())) > PATH_MAX - 3) - set_errno (ENAMETOOLONG); - else if ((dir = (DIR *) malloc (sizeof (DIR))) == NULL) - set_errno (ENOMEM); - else if ((dir->__d_dirname = (char *) malloc (len + 3)) == NULL) - { - free (dir); - set_errno (ENOMEM); - } - else if ((dir->__d_dirent = - (struct dirent *) malloc (sizeof (struct dirent))) == NULL) - { - free (dir); - set_errno (ENOMEM); - } - else - { - strcpy (dir->__d_dirname, get_name ()); - dir->__d_dirent->__d_version = __DIRENT_VERSION; - dir->__d_cookie = __DIRENT_COOKIE; - dir->__handle = INVALID_HANDLE_VALUE; - dir->__d_position = 0; - dir->__flags = 0; - - if (fd >= 0) - { - dir->__d_fd = fd; - res = dir; - dir->__fh = this; - res = dir; - } - else - { - cygheap_fdnew cfd; - if (cfd >= 0) - { - cfd = this; - cfd->nohandle (true); - dir->__d_fd = cfd; - dir->__fh = this; - res = dir; - } - } - close_on_exec (true); - } - - syscall_printf ("%p = opendir (%s)", res, get_name ()); - return res; -} - -_off64_t fhandler_virtual::telldir (DIR * dir) -{ - return dir->__d_position; -} - -void -fhandler_virtual::seekdir (DIR * dir, _off64_t loc) -{ - dir->__flags |= dirent_saw_dot | dirent_saw_dot_dot; - dir->__d_position = loc; -} - -void -fhandler_virtual::rewinddir (DIR * dir) -{ - dir->__d_position = 0; - dir->__flags |= dirent_saw_dot | dirent_saw_dot_dot; -} - -int -fhandler_virtual::closedir (DIR * dir) -{ - return 0; -} - -_off64_t -fhandler_virtual::lseek (_off64_t offset, int whence) -{ - /* - * On Linux, when you lseek within a /proc file, - * the contents of the file are updated. - */ - if (!fill_filebuf ()) - return (_off64_t) -1; - switch (whence) - { - case SEEK_SET: - position = offset; - break; - case SEEK_CUR: - position += offset; - break; - case SEEK_END: - position = filesize + offset; - break; - default: - set_errno (EINVAL); - return (_off64_t) -1; - } - return position; -} - -int -fhandler_virtual::dup (fhandler_base * child) -{ - int ret = fhandler_base::dup (child); - - if (!ret) - { - fhandler_virtual *fhproc_child = (fhandler_virtual *) child; - fhproc_child->filebuf = (char *) cmalloc_abort (HEAP_BUF, filesize); - fhproc_child->filesize = filesize; - fhproc_child->position = position; - memcpy (fhproc_child->filebuf, filebuf, filesize); - fhproc_child->set_flags (get_flags ()); - } - return ret; -} - -int -fhandler_virtual::close () -{ - if (!hExeced) - { - if (filebuf) - { - cfree (filebuf); - filebuf = NULL; - } - } - return 0; -} - -void __stdcall -fhandler_virtual::read (void *ptr, size_t& len) -{ - if (len == 0) - return; - if (openflags & O_DIROPEN) - { - set_errno (EISDIR); - len = (size_t) -1; - return; - } - if (!filebuf) - { - len = (size_t) 0; - return; - } - if ((ssize_t) len > filesize - position) - len = (size_t) (filesize - position); - if ((ssize_t) len < 0) - len = 0; - else - memcpy (ptr, filebuf + position, len); - position += len; -} - -ssize_t __stdcall -fhandler_virtual::write (const void *ptr, size_t len) -{ - set_errno (EACCES); - return -1; -} - -/* low-level open for all proc files */ -int -fhandler_virtual::open (int flags, mode_t mode) -{ - rbinary (true); - wbinary (true); - - set_flags ((flags & ~O_TEXT) | O_BINARY); - - return 1; -} - -int -fhandler_virtual::exists () -{ - return 0; -} - -bool -fhandler_virtual::fill_filebuf () -{ - return true; -} - -int -fhandler_virtual::fchmod (mode_t mode) -{ - /* Same as on Linux. */ - set_errno (EPERM); - return -1; -} - -int -fhandler_virtual::fchown (__uid32_t uid, __gid32_t gid) -{ - /* Same as on Linux. */ - set_errno (EPERM); - return -1; -} - -int -fhandler_virtual::facl (int cmd, int nentries, __aclent32_t *aclbufp) -{ - int res = fhandler_base::facl (cmd, nentries, aclbufp); - if (res >= 0 && cmd == GETACL) - { - aclbufp[0].a_perm = (S_IRUSR | (pc.isdir () ? S_IXUSR : 0)) >> 6; - aclbufp[1].a_perm = (S_IRGRP | (pc.isdir () ? S_IXGRP : 0)) >> 3; - aclbufp[2].a_perm = S_IROTH | (pc.isdir () ? S_IXOTH : 0); - } - return res; -} - -int __stdcall -fhandler_virtual::fstatvfs (struct statvfs *sfs) -{ - /* Virtual file system. Just return an empty buffer with a few values - set to something useful. Just as on Linux. */ - memset (sfs, 0, sizeof (*sfs)); - sfs->f_bsize = sfs->f_frsize = 4096; - sfs->f_namemax = NAME_MAX; - return 0; -} diff --git a/winsup/cygwin/fhandler_virtual.h b/winsup/cygwin/fhandler_virtual.h deleted file mode 100644 index de914eacd..000000000 --- a/winsup/cygwin/fhandler_virtual.h +++ /dev/null @@ -1,27 +0,0 @@ -/* fhandler_virtual.h: Header for virtual fhandlers - - Copyright 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -enum virtual_ftype_t { - virt_socket = -4, - virt_pipe = -3, - virt_symlink = -2, - virt_file = -1, - virt_none = 0, - virt_directory = 1, - virt_rootdir = 2 -}; - -struct virt_tab_t { - const char *name; - __dev32_t fhandler; - virtual_ftype_t type; - _off64_t (*format_func)(void *data, char *&); -}; - diff --git a/winsup/cygwin/fhandler_windows.cc b/winsup/cygwin/fhandler_windows.cc deleted file mode 100644 index 7475b89bb..000000000 --- a/winsup/cygwin/fhandler_windows.cc +++ /dev/null @@ -1,144 +0,0 @@ -/* fhandler_windows.cc: code to access windows message queues. - - Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2009 - Red Hat, Inc. - - Written by Sergey S. Okhapkin (sos@prospect.com.ru). - Feedback and testing by Andy Piper (andyp@parallax.co.uk). - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include "cygerrno.h" -#include "path.h" -#include "fhandler.h" - -/* -The following unix-style calls are supported: - - open ("/dev/windows", flags, mode=0) - - create a unix fd for message queue. - O_NONBLOCK flag controls the read() call behavior. - - read (fd, buf, len) - - return next message from queue. buf must point to MSG - structure, len must be >= sizeof (MSG). If read is set to - non-blocking and the queue is empty, read call returns -1 - immediately with errno set to EAGAIN, otherwise it blocks - untill the message will be received. - - write (fd, buf, len) - - send a message pointed by buf. len argument ignored. - - ioctl (fd, command, *param) - - control read()/write() behavior. - ioctl (fd, WINDOWS_POST, NULL): write() will PostMessage(); - ioctl (fd, WINDOWS_SEND, NULL): write() will SendMessage(); - ioctl (fd, WINDOWS_HWND, &hWnd): read() messages for - hWnd window. - - select () call marks read fd when any message posted to queue. -*/ - -fhandler_windows::fhandler_windows () - : fhandler_base (), hWnd_ (NULL), method_ (WINDOWS_POST) -{ -} - -int -fhandler_windows::open (int flags, mode_t) -{ - set_flags ((flags & ~O_TEXT) | O_BINARY); - close_on_exec (true); - set_open_status (); - return 1; -} - -ssize_t __stdcall -fhandler_windows::write (const void *buf, size_t) -{ - MSG *ptr = (MSG *) buf; - - if (method_ == WINDOWS_POST) - { - if (!PostMessage (ptr->hwnd, ptr->message, ptr->wParam, ptr->lParam)) - { - __seterrno (); - return -1; - } - else - return sizeof (MSG); - } - else - return SendMessage (ptr->hwnd, ptr->message, ptr->wParam, ptr->lParam); -} - -void __stdcall -fhandler_windows::read (void *buf, size_t& len) -{ - MSG *ptr = (MSG *) buf; - - if (len < sizeof (MSG)) - { - set_errno (EINVAL); - len = (size_t) -1; - return; - } - - len = (size_t) GetMessage (ptr, hWnd_, 0, 0); - - if ((ssize_t) len == -1) - __seterrno (); -} - -int -fhandler_windows::ioctl (unsigned int cmd, void *val) -{ - switch (cmd) - { - case WINDOWS_POST: - case WINDOWS_SEND: - method_ = cmd; - break; - case WINDOWS_HWND: - if (val == NULL) - { - set_errno (EINVAL); - return -1; - } - hWnd_ = * ((HWND *) val); - break; - default: - set_errno (EINVAL); - return -1; - } - return 0; -} - -void -fhandler_windows::set_close_on_exec (bool val) -{ - if (get_handle ()) - fhandler_base::set_close_on_exec (val); - else - fhandler_base::close_on_exec (val); - void *h = hWnd_; - if (h) - set_no_inheritance (h, val); -} - -void -fhandler_windows::fixup_after_fork (HANDLE parent) -{ - if (get_handle ()) - fhandler_base::fixup_after_fork (parent); - void *h = hWnd_; - if (h) - fork_fixup (parent, h, "hWnd_"); -} diff --git a/winsup/cygwin/fhandler_zero.cc b/winsup/cygwin/fhandler_zero.cc deleted file mode 100644 index a27c0f6ec..000000000 --- a/winsup/cygwin/fhandler_zero.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* fhandler_dev_zero.cc: code to access /dev/zero - - Copyright 2000, 2001, 2002, 2003, 2004, 2005 Red Hat, Inc. - - Written by DJ Delorie (dj@cygnus.com) - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "security.h" -#include "cygerrno.h" -#include "path.h" -#include "fhandler.h" - -fhandler_dev_zero::fhandler_dev_zero () - : fhandler_base () -{ -} - -int -fhandler_dev_zero::open (int flags, mode_t) -{ - set_flags ((flags & ~O_TEXT) | O_BINARY); - nohandle (true); - set_open_status (); - return 1; -} - -ssize_t __stdcall -fhandler_dev_zero::write (const void *, size_t len) -{ - if (get_device () == FH_FULL) - { - set_errno (ENOSPC); - return -1; - } - return len; -} - -void __stdcall -fhandler_dev_zero::read (void *ptr, size_t& len) -{ - memset (ptr, 0, len); -} - -_off64_t -fhandler_dev_zero::lseek (_off64_t, int) -{ - return 0; -} diff --git a/winsup/cygwin/flock.cc b/winsup/cygwin/flock.cc deleted file mode 100644 index e31add840..000000000 --- a/winsup/cygwin/flock.cc +++ /dev/null @@ -1,1534 +0,0 @@ -/* flock.cc. NT specific implementation of advisory file locking. - - Copyright 2003, 2008, 2009 Red Hat, Inc. - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -/* The basic mechanism as well as the datastructures used in the below - implementation are taken from the FreeBSD repository on 2008-03-18. - The essential code of the lf_XXX functions has been taken from the - module src/sys/kern/kern_lockf.c. It has been adapted to use NT - global namespace subdirs and event objects for synchronization - purposes. - - So, the following copyright applies to most of the code in the lf_XXX - functions. - - * Copyright (c) 1982, 1986, 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Scooter Morris at Genentech 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. - * 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. - * - * @(#)ufs_lockf.c 8.3 (Berkeley) 1/6/94 -*/ - -/* - * The flock() function is based upon source taken from the Red Hat - * implementation used in their imap-2002d SRPM. - * - * $RH: flock.c,v 1.2 2000/08/23 17:07:00 nalin Exp $ - */ - -/* The lockf function is based upon FreeBSD sources with the following - * copyright. - */ -/* - * Copyright (c) 1997 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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. - */ - -#include "winsup.h" -#include -#include -#include -#include -#include "cygerrno.h" -#include "security.h" -#include "shared_info.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "pinfo.h" -#include "sigproc.h" -#include "cygtls.h" -#include "tls_pbuf.h" -#include "ntdll.h" -#include -#include - -#define F_WAIT 0x10 /* Wait until lock is granted */ -#define F_FLOCK 0x20 /* Use flock(2) semantics for lock */ -#define F_POSIX 0x40 /* Use POSIX semantics for lock */ - -#ifndef OFF_MAX -#define OFF_MAX LLONG_MAX -#endif - -static NO_COPY muto lockf_guard; - -#define INODE_LIST_LOCK() (lockf_guard.init ("lockf_guard")->acquire ()) -#define INODE_LIST_UNLOCK() (lockf_guard.release ()) - -#define LOCK_OBJ_NAME_LEN 64 - -#define FLOCK_INODE_DIR_ACCESS (DIRECTORY_QUERY \ - | DIRECTORY_TRAVERSE \ - | DIRECTORY_CREATE_OBJECT \ - | READ_CONTROL) - -#define FLOCK_EVENT_ACCESS (EVENT_QUERY_STATE \ - | SYNCHRONIZE \ - | READ_CONTROL) - -/* This function takes the own process security descriptor DACL and adds - SYNCHRONIZE permissions for everyone. This allows all processes - to wait for this process to die when blocking in a F_SETLKW on a lock - which is hold by this process. */ -static void -allow_others_to_sync () -{ - static NO_COPY bool done; - - if (done) - return; - - NTSTATUS status; - PACL dacl; - LPVOID ace; - ULONG len; - - /* Get this process DACL. We use a temporary path buffer in TLS space - to avoid having to alloc 64K from the stack. */ - tmp_pathbuf tp; - PSECURITY_DESCRIPTOR sd = (PSECURITY_DESCRIPTOR) tp.w_get (); - status = NtQuerySecurityObject (NtCurrentProcess (), - DACL_SECURITY_INFORMATION, sd, - NT_MAX_PATH * sizeof (WCHAR), &len); - if (!NT_SUCCESS (status)) - { - debug_printf ("NtQuerySecurityObject: %p", status); - return; - } - /* Create a valid dacl pointer and set it's size to be as big as - there's room in the temporary buffer. Note that the descriptor - is in self-relative format. */ - dacl = (PACL) ((char *) sd + (uintptr_t) sd->Dacl); - dacl->AclSize = NT_MAX_PATH * sizeof (WCHAR) - ((char *) dacl - (char *) sd); - /* Allow everyone to SYNCHRONIZE with this process. */ - if (!AddAccessAllowedAce (dacl, ACL_REVISION, SYNCHRONIZE, - well_known_world_sid)) - { - debug_printf ("AddAccessAllowedAce: %lu", GetLastError ()); - return; - } - /* Set the size of the DACL correctly. */ - if (!FindFirstFreeAce (dacl, &ace)) - { - debug_printf ("FindFirstFreeAce: %lu", GetLastError ()); - return; - } - dacl->AclSize = (char *) ace - (char *) dacl; - /* Write the DACL back. */ - status = NtSetSecurityObject (NtCurrentProcess (), DACL_SECURITY_INFORMATION, sd); - if (!NT_SUCCESS (status)) - { - debug_printf ("NtSetSecurityObject: %p", status); - return; - } - done = true; -} - -/* Get the handle count of an object. */ -static ULONG -get_obj_handle_count (HANDLE h) -{ - OBJECT_BASIC_INFORMATION obi; - NTSTATUS status; - ULONG hdl_cnt = 0; - - status = NtQueryObject (h, ObjectBasicInformation, &obi, sizeof obi, NULL); - if (!NT_SUCCESS (status)) - debug_printf ("NtQueryObject: %p\n", status); - else - hdl_cnt = obi.HandleCount; - return hdl_cnt; -} - -/* Per lock class. */ -class lockf_t -{ - public: - short lf_flags; /* Semantics: F_POSIX, F_FLOCK, F_WAIT */ - short lf_type; /* Lock type: F_RDLCK, F_WRLCK */ - _off64_t lf_start; /* Byte # of the start of the lock */ - _off64_t lf_end; /* Byte # of the end of the lock (-1=EOF) */ - long long lf_id; /* Cygwin PID for POSIX locks, a unique id per - file table entry for BSD flock locks. */ - DWORD lf_wid; /* Win PID of the resource holding the lock */ - class lockf_t **lf_head; /* Back pointer to the head of the lockf_t list */ - class inode_t *lf_inode; /* Back pointer to the inode_t */ - class lockf_t *lf_next; /* Pointer to the next lock on this inode_t */ - HANDLE lf_obj; /* Handle to the lock event object. */ - - lockf_t () - : lf_flags (0), lf_type (0), lf_start (0), lf_end (0), lf_id (0), - lf_wid (0), lf_head (NULL), lf_inode (NULL), - lf_next (NULL), lf_obj (NULL) - {} - lockf_t (class inode_t *node, class lockf_t **head, short flags, short type, - _off64_t start, _off64_t end, long long id, DWORD wid) - : lf_flags (flags), lf_type (type), lf_start (start), lf_end (end), - lf_id (id), lf_wid (wid), lf_head (head), lf_inode (node), - lf_next (NULL), lf_obj (NULL) - {} - ~lockf_t (); - - /* Used to create all locks list in a given TLS buffer. */ - void *operator new (size_t size, void *p) - { return p; } - /* Used to store own lock list in the cygheap. */ - void *operator new (size_t size) - { return cmalloc (HEAP_FHANDLER, sizeof (lockf_t)); } - /* Never call on node->i_all_lf! */ - void operator delete (void *p) - { cfree (p); } - - void create_lock_obj (); - bool open_lock_obj (); - void del_lock_obj (HANDLE fhdl, bool signal = false); -}; - -/* Per inode_t class */ -class inode_t -{ - friend class lockf_t; - - public: - LIST_ENTRY (inode_t) i_next; - lockf_t *i_lockf; /* List of locks of this process. */ - lockf_t *i_all_lf; /* Temp list of all locks for this file. */ - - __dev32_t i_dev; /* Device ID */ - __ino64_t i_ino; /* inode number */ - - private: - HANDLE i_dir; - HANDLE i_mtx; - unsigned long i_wait; /* Number of blocked threads waiting for - a blocking lock. */ - - public: - inode_t (__dev32_t dev, __ino64_t ino); - ~inode_t (); - - void *operator new (size_t size) - { return cmalloc (HEAP_FHANDLER, sizeof (inode_t)); } - void operator delete (void *p) - { cfree (p); } - - static inode_t *get (__dev32_t dev, __ino64_t ino, bool create_if_missing); - - void LOCK () { WaitForSingleObject (i_mtx, INFINITE); } - void UNLOCK () { ReleaseMutex (i_mtx); } - - void wait () { ++i_wait; } - void unwait () { if (i_wait > 0) --i_wait; } - bool waiting () { return i_wait > 0; } - - lockf_t *get_all_locks_list (); - - bool del_my_locks (long long id, HANDLE fhdl); -}; - -inode_t::~inode_t () -{ - lockf_t *lock, *n_lock; - for (lock = i_lockf; lock && (n_lock = lock->lf_next, 1); lock = n_lock) - delete lock; - NtClose (i_mtx); - NtClose (i_dir); -} - -bool -inode_t::del_my_locks (long long id, HANDLE fhdl) -{ - lockf_t *lock, *n_lock; - lockf_t **prev = &i_lockf; - int lc = 0; - for (lock = *prev; lock && (n_lock = lock->lf_next, 1); lock = n_lock) - { - if (lock->lf_flags & F_POSIX) - { - /* Delete all POSIX locks. */ - *prev = n_lock; - ++lc; - delete lock; - } - else if (id && lock->lf_id == id) - { - int cnt = 0; - cygheap_fdenum cfd (true); - while (cfd.next () >= 0) - if (cfd->get_unique_id () == lock->lf_id && ++cnt > 1) - break; - /* Delete BSD flock lock when no other fd in this process references - it anymore. */ - if (cnt <= 1) - { - *prev = n_lock; - lock->del_lock_obj (fhdl); - delete lock; - } - } - else - prev = &lock->lf_next; - } - return i_lockf == NULL; -} - -/* Used to delete the locks on a file hold by this process. Called from - close(2) and fixup_after_fork, as well as from fixup_after_exec in - case the close_on_exec flag is set. The whole inode is deleted as - soon as no lock exists on it anymore. */ -void -fhandler_base::del_my_locks (del_lock_called_from from) -{ - INODE_LIST_LOCK (); - inode_t *node = inode_t::get (get_dev (), get_ino (), false); - if (node) - { - /* When we're called from fixup_after_exec, the fhandler is a - close-on-exec fhandler. In this case our io handle is already - invalid. We can't use it to test for the object reference count. - However, that shouldn't be necessary for the following reason. - After exec, there are no threads in the current process waiting for - the lock. So, either we're the only process accessing the file table - entry and there are no threads which require signalling, or we have - a parent process still accessing the file object and signalling the - lock event would be premature. */ - bool no_locks_left = - node->del_my_locks (from == after_fork ? 0 : get_unique_id (), - from == after_exec ? NULL : get_handle ()); - if (no_locks_left) - { - LIST_REMOVE (node, i_next); - node->UNLOCK (); - delete node; - } - else - node->UNLOCK (); - } - INODE_LIST_UNLOCK (); -} - -/* Called in an execed child. The exec'ed process must allow SYNCHRONIZE - access to everyone if at least one inode exists. - The lock owner's Windows PID changed and all POSIX lock event objects - have to be relabeled so that waiting processes know which process to - wait on. If the node has been abandoned due to close_on_exec on the - referencing fhandlers, remove the inode entirely. */ -void -fixup_lockf_after_exec () -{ - inode_t *node, *next_node; - - INODE_LIST_LOCK (); - if (LIST_FIRST (&cygheap->inode_list)) - allow_others_to_sync (); - LIST_FOREACH_SAFE (node, &cygheap->inode_list, i_next, next_node) - { - int cnt = 0; - cygheap_fdenum cfd (true); - while (cfd.next () >= 0) - if (cfd->get_dev () == node->i_dev - && cfd->get_ino () == node->i_ino - && ++cnt > 1) - break; - if (cnt == 0) - { - LIST_REMOVE (node, i_next); - delete node; - } - else - { - node->LOCK (); - for (lockf_t *lock = node->i_lockf; lock; lock = lock->lf_next) - if (lock->lf_flags & F_POSIX) - { - lock->del_lock_obj (NULL); - lock->lf_wid = myself->dwProcessId; - lock->create_lock_obj (); - } - node->UNLOCK (); - } - } - INODE_LIST_UNLOCK (); -} - -/* static method to return a pointer to the inode_t structure for a specific - file. The file is specified by the device and inode_t number. If inode_t - doesn't exist, create it. */ -inode_t * -inode_t::get (__dev32_t dev, __ino64_t ino, bool create_if_missing) -{ - inode_t *node; - - INODE_LIST_LOCK (); - LIST_FOREACH (node, &cygheap->inode_list, i_next) - if (node->i_dev == dev && node->i_ino == ino) - break; - if (!node && create_if_missing) - { - node = new inode_t (dev, ino); - if (node) - LIST_INSERT_HEAD (&cygheap->inode_list, node, i_next); - } - if (node) - node->LOCK (); - INODE_LIST_UNLOCK (); - return node; -} - -inode_t::inode_t (__dev32_t dev, __ino64_t ino) -: i_lockf (NULL), i_all_lf (NULL), i_dev (dev), i_ino (ino), i_wait (0L) -{ - HANDLE parent_dir; - WCHAR name[48]; - UNICODE_STRING uname; - OBJECT_ATTRIBUTES attr; - NTSTATUS status; - - parent_dir = get_shared_parent_dir (); - /* Create a subdir which is named after the device and inode_t numbers - of the given file, in hex notation. */ - int len = __small_swprintf (name, L"flock-%08x-%016X", dev, ino); - RtlInitCountedUnicodeString (&uname, name, len * sizeof (WCHAR)); - InitializeObjectAttributes (&attr, &uname, OBJ_INHERIT | OBJ_OPENIF, - parent_dir, everyone_sd (FLOCK_INODE_DIR_ACCESS)); - status = NtCreateDirectoryObject (&i_dir, FLOCK_INODE_DIR_ACCESS, &attr); - if (!NT_SUCCESS (status)) - api_fatal ("NtCreateDirectoryObject(inode): %p", status); - /* Create a mutex object in the file specific dir, which is used for - access synchronization on the dir and its objects. */ - InitializeObjectAttributes (&attr, &ro_u_mtx, OBJ_INHERIT | OBJ_OPENIF, i_dir, - everyone_sd (CYG_MUTANT_ACCESS)); - status = NtCreateMutant (&i_mtx, CYG_MUTANT_ACCESS, &attr, FALSE); - if (!NT_SUCCESS (status)) - api_fatal ("NtCreateMutant(inode): %p", status); -} - -/* Enumerate all lock event objects for this file and create a lockf_t - list in the i_all_lf member. This list is searched in lf_getblock - for locks which potentially block our lock request. */ - -/* Number of lockf_t structs which fit in the temporary buffer. */ -#define MAX_LOCKF_CNT ((intptr_t)((NT_MAX_PATH * sizeof (WCHAR)) \ - / sizeof (lockf_t))) - -lockf_t * -inode_t::get_all_locks_list () -{ - struct fdbi - { - DIRECTORY_BASIC_INFORMATION dbi; - WCHAR buf[2][NAME_MAX + 1]; - } f; - ULONG context; - NTSTATUS status; - lockf_t *lock = i_all_lf; - - for (BOOLEAN restart = TRUE; - NT_SUCCESS (status = NtQueryDirectoryObject (i_dir, &f, sizeof f, TRUE, - restart, &context, NULL)); - restart = FALSE) - { - if (f.dbi.ObjectName.Length != LOCK_OBJ_NAME_LEN * sizeof (WCHAR)) - continue; - wchar_t *wc = f.dbi.ObjectName.Buffer, *endptr; - /* "%02x-%01x-%016X-%016X-%016X-%08x", - lf_flags, lf_type, lf_start, lf_end, lf_id, lf_wid */ - wc[LOCK_OBJ_NAME_LEN] = L'\0'; - short flags = wcstol (wc, &endptr, 16); - if ((flags & ~(F_FLOCK | F_POSIX)) != 0 - || ((flags & (F_FLOCK | F_POSIX)) == (F_FLOCK | F_POSIX))) - continue; - short type = wcstol (endptr + 1, &endptr, 16); - if ((type != F_RDLCK && type != F_WRLCK) || !endptr || *endptr != L'-') - continue; - _off64_t start = (_off64_t) wcstoull (endptr + 1, &endptr, 16); - if (start < 0 || !endptr || *endptr != L'-') - continue; - _off64_t end = (_off64_t) wcstoull (endptr + 1, &endptr, 16); - if (end < -1LL || (end > 0 && end < start) || !endptr || *endptr != L'-') - continue; - long long id = wcstoll (endptr + 1, &endptr, 16); - if (!endptr || *endptr != L'-' - || ((flags & F_POSIX) && (id < 1 || id > ULONG_MAX))) - continue; - DWORD wid = wcstoul (endptr + 1, &endptr, 16); - if (endptr && *endptr != L'\0') - continue; - if (lock - i_all_lf >= MAX_LOCKF_CNT) - { - system_printf ("Warning, can't handle more than %d locks per file.", - MAX_LOCKF_CNT); - break; - } - if (lock > i_all_lf) - lock[-1].lf_next = lock; - new (lock++) lockf_t (this, &i_all_lf, flags, type, start, end, id, wid); - } - /* If no lock has been found, return NULL. */ - if (lock == i_all_lf) - return NULL; - return i_all_lf; -} - -/* Create the lock event object in the file's subdir in the NT global - namespace. The name is constructed from the lock properties which - identify it uniquely, all values in hex. See the __small_swprintf - call right at the start. */ -void -lockf_t::create_lock_obj () -{ - WCHAR name[LOCK_OBJ_NAME_LEN + 1]; - UNICODE_STRING uname; - OBJECT_ATTRIBUTES attr; - NTSTATUS status; - - __small_swprintf (name, L"%02x-%01x-%016X-%016X-%016X-%08x", - lf_flags & (F_POSIX | F_FLOCK), lf_type, lf_start, - lf_end, lf_id, lf_wid); - RtlInitCountedUnicodeString (&uname, name, - LOCK_OBJ_NAME_LEN * sizeof (WCHAR)); - InitializeObjectAttributes (&attr, &uname, OBJ_INHERIT, lf_inode->i_dir, - everyone_sd (FLOCK_EVENT_ACCESS)); - status = NtCreateEvent (&lf_obj, CYG_EVENT_ACCESS, &attr, - NotificationEvent, FALSE); - if (!NT_SUCCESS (status)) - api_fatal ("NtCreateEvent(lock): %p", status); -} - -/* Open a lock event object for SYNCHRONIZE access (to wait for it). */ -bool -lockf_t::open_lock_obj () -{ - WCHAR name[LOCK_OBJ_NAME_LEN + 1]; - UNICODE_STRING uname; - OBJECT_ATTRIBUTES attr; - NTSTATUS status; - - __small_swprintf (name, L"%02x-%01x-%016X-%016X-%016X-%08x", - lf_flags & (F_POSIX | F_FLOCK), lf_type, lf_start, - lf_end, lf_id, lf_wid); - RtlInitCountedUnicodeString (&uname, name, - LOCK_OBJ_NAME_LEN * sizeof (WCHAR)); - InitializeObjectAttributes (&attr, &uname, 0, lf_inode->i_dir, NULL); - status = NtOpenEvent (&lf_obj, FLOCK_EVENT_ACCESS, &attr); - if (!NT_SUCCESS (status)) - { - SetLastError (RtlNtStatusToDosError (status)); - lf_obj = NULL; /* Paranoia... */ - } - return lf_obj != NULL; -} - -/* Close a lock event handle. The important thing here is to signal it - before closing the handle. This way all threads waiting for this - lock can wake up. */ -void -lockf_t::del_lock_obj (HANDLE fhdl, bool signal) -{ - if (lf_obj) - { - /* Only signal the event if it's either a POSIX lock, or, in case of - BSD flock locks, if it's an explicit unlock or if the calling fhandler - holds the last reference to the file table entry. The file table - entry in UNIX terms is equivalent to the FILE_OBJECT in Windows NT - terms. It's what the handle/descriptor references when calling - CreateFile/open. Calling DuplicateHandle/dup only creates a new - handle/descriptor to the same FILE_OBJECT/file table entry. */ - if ((lf_flags & F_POSIX) || signal - || (fhdl && get_obj_handle_count (fhdl) <= 1)) - SetEvent (lf_obj); - NtClose (lf_obj); - lf_obj = NULL; - } -} - -lockf_t::~lockf_t () -{ - del_lock_obj (NULL); -} - -/* - * This variable controls the maximum number of processes that will - * be checked in doing deadlock detection. - */ -#ifndef __CYGWIN__ -#define MAXDEPTH 50 -static int maxlockdepth = MAXDEPTH; -#endif - -#define NOLOCKF (struct lockf_t *)0 -#define SELF 0x1 -#define OTHERS 0x2 -static int lf_clearlock (lockf_t *, lockf_t **, HANDLE); -static int lf_findoverlap (lockf_t *, lockf_t *, int, lockf_t ***, lockf_t **); -static lockf_t *lf_getblock (lockf_t *, inode_t *node); -static int lf_getlock (lockf_t *, inode_t *, struct __flock64 *); -static int lf_setlock (lockf_t *, inode_t *, lockf_t **, HANDLE); -static void lf_split (lockf_t *, lockf_t *, lockf_t **); -static void lf_wakelock (lockf_t *, HANDLE); - -int -fhandler_disk_file::lock (int a_op, struct __flock64 *fl) -{ - _off64_t start, end, oadd; - lockf_t *n; - int error = 0; - - short a_flags = fl->l_type & (F_POSIX | F_FLOCK); - short type = fl->l_type & (F_RDLCK | F_WRLCK | F_UNLCK); - - if (!a_flags) - a_flags = F_POSIX; /* default */ - if (a_op == F_SETLKW) - { - a_op = F_SETLK; - a_flags |= F_WAIT; - } - if (a_op == F_SETLK) - switch (type) - { - case F_UNLCK: - a_op = F_UNLCK; - break; - case F_RDLCK: - /* flock semantics don't specify a requirement that the file has - been opened with a specific open mode, in contrast to POSIX locks - which require that a file is opened for reading to place a read - lock and opened for writing to place a write lock. */ - if ((a_flags & F_POSIX) && !(get_access () & GENERIC_READ)) - { - set_errno (EBADF); - return -1; - } - break; - case F_WRLCK: - /* See above comment. */ - if ((a_flags & F_POSIX) && !(get_access () & GENERIC_WRITE)) - { - set_errno (EBADF); - return -1; - } - break; - default: - set_errno (EINVAL); - return -1; - } - - /* - * Convert the flock structure into a start and end. - */ - switch (fl->l_whence) - { - case SEEK_SET: - start = fl->l_start; - break; - - case SEEK_CUR: - if ((start = lseek (0, SEEK_CUR)) == ILLEGAL_SEEK) - return -1; - break; - - case SEEK_END: - { - NTSTATUS status; - IO_STATUS_BLOCK io; - FILE_STANDARD_INFORMATION fsi; - - status = NtQueryInformationFile (get_handle (), &io, &fsi, sizeof fsi, - FileStandardInformation); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - return -1; - } - if (fl->l_start > 0 && fsi.EndOfFile.QuadPart > OFF_MAX - fl->l_start) - { - set_errno (EOVERFLOW); - return -1; - } - start = fsi.EndOfFile.QuadPart + fl->l_start; - } - break; - - default: - return (EINVAL); - } - if (start < 0) - { - set_errno (EINVAL); - return -1; - } - if (fl->l_len < 0) - { - if (start == 0) - { - set_errno (EINVAL); - return -1; - } - end = start - 1; - start += fl->l_len; - if (start < 0) - { - set_errno (EINVAL); - return -1; - } - } - else if (fl->l_len == 0) - end = -1; - else - { - oadd = fl->l_len - 1; - if (oadd > OFF_MAX - start) - { - set_errno (EOVERFLOW); - return -1; - } - end = start + oadd; - } - - inode_t *node = inode_t::get (get_dev (), get_ino (), true); - if (!node) - { - set_errno (ENOLCK); - return -1; - } - need_fork_fixup (true); - - /* Unlock the fd table which has been locked in fcntl_worker/lock_worker, - otherwise a blocking F_SETLKW never wakes up on a signal. */ - cygheap->fdtab.unlock (); - - lockf_t **head = &node->i_lockf; - -#if 0 - /* - * Avoid the common case of unlocking when inode_t has no locks. - * - * This shortcut is invalid for Cygwin because the above inode_t::get - * call returns with an empty lock list if this process has no locks - * on the file yet. - */ - if (*head == NULL) - { - if (a_op != F_SETLK) - { - node->UNLOCK (); - fl->l_type = F_UNLCK; - return 0; - } - } -#endif - /* - * Allocate a spare structure in case we have to split. - */ - lockf_t *clean = NULL; - if (a_op == F_SETLK || a_op == F_UNLCK) - { - clean = new lockf_t (); - if (!clean) - { - node->UNLOCK (); - set_errno (ENOLCK); - return -1; - } - } - /* - * Create the lockf_t structure - */ - lockf_t *lock = new lockf_t (node, head, a_flags, type, start, end, - (a_flags & F_FLOCK) ? get_unique_id () - : getpid (), - myself->dwProcessId); - if (!lock) - { - node->UNLOCK (); - set_errno (ENOLCK); - return -1; - } - - switch (a_op) - { - case F_SETLK: - error = lf_setlock (lock, node, &clean, get_handle ()); - break; - - case F_UNLCK: - error = lf_clearlock (lock, &clean, get_handle ()); - lock->lf_next = clean; - clean = lock; - break; - - case F_GETLK: - error = lf_getlock (lock, node, fl); - lock->lf_next = clean; - clean = lock; - break; - - default: - lock->lf_next = clean; - clean = lock; - error = EINVAL; - break; - } - for (lock = clean; lock != NULL; ) - { - n = lock->lf_next; - lock->del_lock_obj (get_handle (), a_op == F_UNLCK); - delete lock; - lock = n; - } - if (node->i_lockf == NULL && !node->waiting ()) - { - INODE_LIST_LOCK (); - LIST_REMOVE (node, i_next); - node->UNLOCK (); - delete node; - INODE_LIST_UNLOCK (); - } - else - node->UNLOCK (); - if (error) - { - set_errno (error); - return -1; - } - return 0; -} - -/* - * Set a byte-range lock. - */ -static int -lf_setlock (lockf_t *lock, inode_t *node, lockf_t **clean, HANDLE fhdl) -{ - lockf_t *block; - lockf_t **head = lock->lf_head; - lockf_t **prev, *overlap; - int ovcase, priority, old_prio, needtolink; - tmp_pathbuf tp; - - /* - * Set the priority - */ - priority = old_prio = GetThreadPriority (GetCurrentThread ()); - if (lock->lf_type == F_WRLCK && priority <= THREAD_PRIORITY_ABOVE_NORMAL) - priority = THREAD_PRIORITY_HIGHEST; - /* - * Scan lock list for this file looking for locks that would block us. - */ - /* Create temporary space for the all locks list. */ - node->i_all_lf = (lockf_t *) tp.w_get (); - while ((block = lf_getblock(lock, node))) - { - DWORD ret; - HANDLE obj = block->lf_obj; - block->lf_obj = NULL; - - /* - * Free the structure and return if nonblocking. - */ - if ((lock->lf_flags & F_WAIT) == 0) - { - lock->lf_next = *clean; - *clean = lock; - if (obj) - NtClose (obj); - return EAGAIN; - } - /* - * We are blocked. Since flock style locks cover - * the whole file, there is no chance for deadlock. - * For byte-range locks we must check for deadlock. - * - * Deadlock detection is done by looking through the - * wait channels to see if there are any cycles that - * involve us. MAXDEPTH is set just to make sure we - * do not go off into neverland. - */ - /* FIXME: We check the handle count of all the lock event objects - this process holds. If it's > 1, another process is - waiting for one of our locks. This method isn't overly - intelligent. If it turns out to be too dumb, we might - have to remove it or to find another method. */ - for (lockf_t *lk = node->i_lockf; lk; lk = lk->lf_next) - if ((lk->lf_flags & F_POSIX) && get_obj_handle_count (lk->lf_obj) > 1) - { - if (obj) - NtClose (obj); - return EDEADLK; - } - - /* - * For flock type locks, we must first remove - * any shared locks that we hold before we sleep - * waiting for an exclusive lock. - */ - if ((lock->lf_flags & F_FLOCK) && lock->lf_type == F_WRLCK) - { - lock->lf_type = F_UNLCK; - (void) lf_clearlock (lock, clean, fhdl); - lock->lf_type = F_WRLCK; - } - - /* - * Add our lock to the blocked list and sleep until we're free. - * Remember who blocked us (for deadlock detection). - */ - /* Cygwin: No locked list. See deadlock recognition above. */ - - /* Wait for the blocking object and its holding process. */ - if (!obj) - { - /* We can't synchronize on the lock event object. - Treat this as a deadlock-like situation for now. */ - system_printf ("Can't sync with lock object hold by " - "Win32 pid %lu: %E", block->lf_wid); - return EDEADLK; - } - SetThreadPriority (GetCurrentThread (), priority); - if (lock->lf_flags & F_POSIX) - { - HANDLE proc = OpenProcess (SYNCHRONIZE, FALSE, block->lf_wid); - if (!proc) - { - /* If we can't synchronize on the process holding the lock, - we will never recognize when the lock has been abandoned. - Treat this as a deadlock-like situation for now. */ - system_printf ("Can't sync with process holding a lock " - "(Win32 pid %lu): %E", block->lf_wid); - NtClose (obj); - return EDEADLK; - } - HANDLE w4[3] = { obj, proc, signal_arrived }; - node->wait (); - node->UNLOCK (); - ret = WaitForMultipleObjects (3, w4, FALSE, INFINITE); - CloseHandle (proc); - } - else - { - HANDLE w4[2] = { obj, signal_arrived }; - node->wait (); - node->UNLOCK (); - /* Unfortunately, since BSD flock locks are not attached to a - specific process, we can't recognize an abandoned lock by - sync'ing with a process. We have to find out if we're the only - process left accessing this event object. */ - do - { - ret = WaitForMultipleObjects (2, w4, FALSE, 100L); - } - while (ret == WAIT_TIMEOUT && get_obj_handle_count (obj) > 1); - /* There's a good chance that the above loop is left with - ret == WAIT_TIMEOUT if another process closes the file handle - associated with this lock. This is for all practical purposes - equivalent to a signalled lock object. */ - if (ret == WAIT_TIMEOUT) - ret = WAIT_OBJECT_0; - } - node->LOCK (); - node->unwait (); - NtClose (obj); - SetThreadPriority (GetCurrentThread (), old_prio); - switch (ret) - { - case WAIT_OBJECT_0: - /* The lock object has been set to signalled. */ - break; - case WAIT_OBJECT_0 + 1: - /* For POSIX locks, the process holding the lock has exited. */ - if (lock->lf_flags & F_POSIX) - break; - /*FALLTHRU*/ - case WAIT_OBJECT_0 + 2: - /* A signal came in. */ - _my_tls.call_signal_handler (); - return EINTR; - default: - system_printf ("Shouldn't happen! ret = %lu, error: %lu\n", - ret, GetLastError ()); - return geterrno_from_win_error (); - } - } - allow_others_to_sync (); - /* - * No blocks!! Add the lock. Note that we will - * downgrade or upgrade any overlapping locks this - * process already owns. - * - * Handle any locks that overlap. - */ - prev = head; - block = *head; - needtolink = 1; - for (;;) - { - ovcase = lf_findoverlap (block, lock, SELF, &prev, &overlap); - if (ovcase) - block = overlap->lf_next; - /* - * Six cases: - * 0) no overlap - * 1) overlap == lock - * 2) overlap contains lock - * 3) lock contains overlap - * 4) overlap starts before lock - * 5) overlap ends after lock - */ - switch (ovcase) - { - case 0: /* no overlap */ - if (needtolink) - { - *prev = lock; - lock->lf_next = overlap; - lock->create_lock_obj (); - } - break; - - case 1: /* overlap == lock */ - /* - * If downgrading lock, others may be - * able to acquire it. - * Cygwin: Always wake lock. - */ - lf_wakelock (overlap, fhdl); - overlap->lf_type = lock->lf_type; - overlap->create_lock_obj (); - lock->lf_next = *clean; - *clean = lock; - break; - - case 2: /* overlap contains lock */ - /* - * Check for common starting point and different types. - */ - if (overlap->lf_type == lock->lf_type) - { - lock->lf_next = *clean; - *clean = lock; - break; - } - if (overlap->lf_start == lock->lf_start) - { - *prev = lock; - lock->lf_next = overlap; - overlap->lf_start = lock->lf_end + 1; - } - else - lf_split (overlap, lock, clean); - lf_wakelock (overlap, fhdl); - overlap->create_lock_obj (); - lock->create_lock_obj (); - if (lock->lf_next && !lock->lf_next->lf_obj) - lock->lf_next->create_lock_obj (); - break; - - case 3: /* lock contains overlap */ - /* - * If downgrading lock, others may be able to - * acquire it, otherwise take the list. - * Cygwin: Always wake old lock and create new lock. - */ - lf_wakelock (overlap, fhdl); - /* - * Add the new lock if necessary and delete the overlap. - */ - if (needtolink) - { - *prev = lock; - lock->lf_next = overlap->lf_next; - prev = &lock->lf_next; - lock->create_lock_obj (); - needtolink = 0; - } - else - *prev = overlap->lf_next; - overlap->lf_next = *clean; - *clean = overlap; - continue; - - case 4: /* overlap starts before lock */ - /* - * Add lock after overlap on the list. - */ - lock->lf_next = overlap->lf_next; - overlap->lf_next = lock; - overlap->lf_end = lock->lf_start - 1; - prev = &lock->lf_next; - lf_wakelock (overlap, fhdl); - overlap->create_lock_obj (); - lock->create_lock_obj (); - needtolink = 0; - continue; - - case 5: /* overlap ends after lock */ - /* - * Add the new lock before overlap. - */ - if (needtolink) { - *prev = lock; - lock->lf_next = overlap; - } - overlap->lf_start = lock->lf_end + 1; - lf_wakelock (overlap, fhdl); - lock->create_lock_obj (); - overlap->create_lock_obj (); - break; - } - break; - } - return 0; -} - -/* - * Remove a byte-range lock on an inode_t. - * - * Generally, find the lock (or an overlap to that lock) - * and remove it (or shrink it), then wakeup anyone we can. - */ -static int -lf_clearlock (lockf_t *unlock, lockf_t **clean, HANDLE fhdl) -{ - lockf_t **head = unlock->lf_head; - lockf_t *lf = *head; - lockf_t *overlap, **prev; - int ovcase; - - if (lf == NOLOCKF) - return 0; - prev = head; - while ((ovcase = lf_findoverlap (lf, unlock, SELF, &prev, &overlap))) - { - /* - * Wakeup the list of locks to be retried. - */ - lf_wakelock (overlap, fhdl); - - switch (ovcase) - { - case 1: /* overlap == lock */ - *prev = overlap->lf_next; - overlap->lf_next = *clean; - *clean = overlap; - break; - - case 2: /* overlap contains lock: split it */ - if (overlap->lf_start == unlock->lf_start) - { - overlap->lf_start = unlock->lf_end + 1; - overlap->create_lock_obj (); - break; - } - lf_split (overlap, unlock, clean); - overlap->lf_next = unlock->lf_next; - overlap->create_lock_obj (); - if (overlap->lf_next && !overlap->lf_next->lf_obj) - overlap->lf_next->create_lock_obj (); - break; - - case 3: /* lock contains overlap */ - *prev = overlap->lf_next; - lf = overlap->lf_next; - overlap->lf_next = *clean; - *clean = overlap; - continue; - - case 4: /* overlap starts before lock */ - overlap->lf_end = unlock->lf_start - 1; - prev = &overlap->lf_next; - lf = overlap->lf_next; - overlap->create_lock_obj (); - continue; - - case 5: /* overlap ends after lock */ - overlap->lf_start = unlock->lf_end + 1; - overlap->create_lock_obj (); - break; - } - break; - } - return 0; -} - -/* - * Check whether there is a blocking lock, - * and if so return its process identifier. - */ -static int -lf_getlock (lockf_t *lock, inode_t *node, struct __flock64 *fl) -{ - lockf_t *block; - tmp_pathbuf tp; - - /* Create temporary space for the all locks list. */ - node->i_all_lf = (lockf_t *) tp.w_get (); - if ((block = lf_getblock (lock, node))) - { - if (block->lf_obj) - NtClose (block->lf_obj); - fl->l_type = block->lf_type; - fl->l_whence = SEEK_SET; - fl->l_start = block->lf_start; - if (block->lf_end == -1) - fl->l_len = 0; - else - fl->l_len = block->lf_end - block->lf_start + 1; - if (block->lf_flags & F_POSIX) - fl->l_pid = (pid_t) block->lf_id; - else - fl->l_pid = -1; - } - else - fl->l_type = F_UNLCK; - return 0; -} - -/* - * Walk the list of locks for an inode_t and - * return the first blocking lock. - */ -static lockf_t * -lf_getblock (lockf_t *lock, inode_t *node) -{ - lockf_t **prev, *overlap; - lockf_t *lf = node->get_all_locks_list (); - int ovcase; - NTSTATUS status; - EVENT_BASIC_INFORMATION ebi; - - prev = lock->lf_head; - while ((ovcase = lf_findoverlap (lf, lock, OTHERS, &prev, &overlap))) - { - /* - * We've found an overlap, see if it blocks us - */ - if ((lock->lf_type == F_WRLCK || overlap->lf_type == F_WRLCK)) - { - /* Open the event object for synchronization. */ - if (!overlap->open_lock_obj () || (overlap->lf_flags & F_POSIX)) - return overlap; - /* In case of BSD flock locks, check if the event object is - signalled. If so, the overlap doesn't actually exist anymore. - There are just a few open handles left. */ - status = NtQueryEvent (overlap->lf_obj, EventBasicInformation, - &ebi, sizeof ebi, NULL); - if (!NT_SUCCESS (status) || ebi.SignalState == 0) - return overlap; - NtClose (overlap->lf_obj); - overlap->lf_obj = NULL; - } - /* - * Nope, point to the next one on the list and - * see if it blocks us - */ - lf = overlap->lf_next; - } - return NOLOCKF; -} - -/* - * Walk the list of locks for an inode_t to - * find an overlapping lock (if any). - * - * NOTE: this returns only the FIRST overlapping lock. There - * may be more than one. - */ -static int -lf_findoverlap (lockf_t *lf, lockf_t *lock, int type, lockf_t ***prev, - lockf_t **overlap) -{ - _off64_t start, end; - - *overlap = lf; - if (lf == NOLOCKF) - return 0; - - start = lock->lf_start; - end = lock->lf_end; - while (lf != NOLOCKF) - { - if (((type & SELF) && lf->lf_id != lock->lf_id) - || ((type & OTHERS) && lf->lf_id == lock->lf_id) - /* As on Linux: POSIX locks and BSD flock locks don't interact. */ - || (lf->lf_flags & (F_POSIX | F_FLOCK)) - != (lock->lf_flags & (F_POSIX | F_FLOCK))) - { - *prev = &lf->lf_next; - *overlap = lf = lf->lf_next; - continue; - } - /* - * OK, check for overlap - * - * Six cases: - * 0) no overlap - * 1) overlap == lock - * 2) overlap contains lock - * 3) lock contains overlap - * 4) overlap starts before lock - * 5) overlap ends after lock - */ - if ((lf->lf_end != -1 && start > lf->lf_end) || - (end != -1 && lf->lf_start > end)) - { - /* Case 0 */ - if ((type & SELF) && end != -1 && lf->lf_start > end) - return 0; - *prev = &lf->lf_next; - *overlap = lf = lf->lf_next; - continue; - } - if ((lf->lf_start == start) && (lf->lf_end == end)) - { - /* Case 1 */ - return 1; - } - if ((lf->lf_start <= start) && (end != -1) && - ((lf->lf_end >= end) || (lf->lf_end == -1))) - { - /* Case 2 */ - return 2; - } - if (start <= lf->lf_start && (end == -1 || - (lf->lf_end != -1 && end >= lf->lf_end))) - { - /* Case 3 */ - return 3; - } - if ((lf->lf_start < start) && - ((lf->lf_end >= start) || (lf->lf_end == -1))) - { - /* Case 4 */ - return 4; - } - if ((lf->lf_start > start) && (end != -1) && - ((lf->lf_end > end) || (lf->lf_end == -1))) - { - /* Case 5 */ - return 5; - } - api_fatal ("lf_findoverlap: default\n"); - } - return 0; -} - -/* - * Split a lock and a contained region into - * two or three locks as necessary. - */ -static void -lf_split (lockf_t *lock1, lockf_t *lock2, lockf_t **split) -{ - lockf_t *splitlock; - - /* - * Check to see if spliting into only two pieces. - */ - if (lock1->lf_start == lock2->lf_start) - { - lock1->lf_start = lock2->lf_end + 1; - lock2->lf_next = lock1; - return; - } - if (lock1->lf_end == lock2->lf_end) - { - lock1->lf_end = lock2->lf_start - 1; - lock2->lf_next = lock1->lf_next; - lock1->lf_next = lock2; - return; - } - /* - * Make a new lock consisting of the last part of - * the encompassing lock. We use the preallocated - * splitlock so we don't have to block. - */ - splitlock = *split; - assert (splitlock != NULL); - *split = splitlock->lf_next; - memcpy (splitlock, lock1, sizeof *splitlock); - /* We have to unset the obj HANDLE here which has been copied by the - above memcpy, so that the calling function recognizes the new object. - See post-lf_split handling in lf_setlock and lf_clearlock. */ - splitlock->lf_obj = NULL; - splitlock->lf_start = lock2->lf_end + 1; - lock1->lf_end = lock2->lf_start - 1; - /* - * OK, now link it in - */ - splitlock->lf_next = lock1->lf_next; - lock2->lf_next = splitlock; - lock1->lf_next = lock2; -} - -/* - * Wakeup a blocklist - * Cygwin: Just signal the lock which gets removed. This unblocks - * all threads waiting for this lock. - */ -static void -lf_wakelock (lockf_t *listhead, HANDLE fhdl) -{ - listhead->del_lock_obj (fhdl, true); -} - -extern "C" int -flock (int fd, int operation) -{ - int res = -1; - int cmd; - struct __flock64 fl = { 0, SEEK_SET, 0, 0, 0 }; - - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - cygheap_fdget cfd (fd, true); - if (cfd < 0) - goto done; - - cmd = (operation & LOCK_NB) ? F_SETLK : F_SETLKW; - switch (operation & (~LOCK_NB)) - { - case LOCK_EX: - fl.l_type = F_WRLCK | F_FLOCK; - break; - case LOCK_SH: - fl.l_type = F_RDLCK | F_FLOCK; - break; - case LOCK_UN: - fl.l_type = F_UNLCK | F_FLOCK; - break; - default: - set_errno (EINVAL); - goto done; - } - res = cfd->lock (cmd, &fl); - if ((res == -1) && ((get_errno () == EAGAIN) || (get_errno () == EACCES))) - set_errno (EWOULDBLOCK); -done: - syscall_printf ("%d = flock (%d, %d)", res, fd, operation); - return res; -} - -extern "C" int -lockf (int filedes, int function, _off64_t size) -{ - int res = -1; - int cmd; - struct __flock64 fl; - - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - cygheap_fdget cfd (filedes, true); - if (cfd < 0) - goto done; - - fl.l_start = 0; - fl.l_len = size; - fl.l_whence = SEEK_CUR; - - switch (function) - { - case F_ULOCK: - cmd = F_SETLK; - fl.l_type = F_UNLCK; - break; - case F_LOCK: - cmd = F_SETLKW; - fl.l_type = F_WRLCK; - break; - case F_TLOCK: - cmd = F_SETLK; - fl.l_type = F_WRLCK; - break; - case F_TEST: - fl.l_type = F_WRLCK; - if (cfd->lock (F_GETLK, &fl) == -1) - goto done; - if (fl.l_type == F_UNLCK || fl.l_pid == getpid ()) - res = 0; - else - errno = EAGAIN; - goto done; - /* NOTREACHED */ - default: - errno = EINVAL; - goto done; - /* NOTREACHED */ - } - res = cfd->lock (cmd, &fl); -done: - syscall_printf ("%d = lockf (%d, %d, %D)", res, filedes, function, size); - return res; -} diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc deleted file mode 100644 index f0a427a63..000000000 --- a/winsup/cygwin/fork.cc +++ /dev/null @@ -1,784 +0,0 @@ -/* fork.cc - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006, - 2007, 2008, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include -#include "cygerrno.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "sigproc.h" -#include "pinfo.h" -#include "cygheap.h" -#include "child_info.h" -#include "cygtls.h" -#include "tls_pbuf.h" -#include "dll_init.h" -#include "cygmalloc.h" - -#define NPIDS_HELD 4 - -/* Timeout to wait for child to start, parent to init child, etc. */ -/* FIXME: Once things stabilize, bump up to a few minutes. */ -#define FORK_WAIT_TIMEOUT (300 * 1000) /* 300 seconds */ - -class frok -{ - bool load_dlls; - child_info_fork ch; - const char *error; - int child_pid; - int this_errno; - int __stdcall parent (volatile char * volatile here); - int __stdcall child (volatile char * volatile here); - friend int fork (); -}; - -class lock_signals -{ - bool worked; -public: - lock_signals () - { - worked = sig_send (NULL, __SIGHOLD) == 0; - } - operator int () const - { - return worked; - } - void dont_bother () - { - worked = false; - } - ~lock_signals () - { - if (worked) - sig_send (NULL, __SIGNOHOLD); - } -}; - -class lock_pthread -{ - bool bother; -public: - lock_pthread (): bother (1) - { - pthread::atforkprepare (); - } - void dont_bother () - { - bother = false; - } - ~lock_pthread () - { - if (bother) - pthread::atforkparent (); - } -}; - -class hold_everything -{ -public: /* DELETEME*/ - bool& ischild; - /* Note the order of the locks below. It is important, - to avoid races, that the lock order be preserved. - - pthread is first because it serves as a master lock - against other forks being attempted while this one is active. - - signals is next to stop signal processing for the duration - of the fork. - - process is last. If it is put before signals, then a deadlock - could be introduced if the process attempts to exit due to a signal. */ - lock_pthread pthread; - lock_signals signals; - lock_process process; - -public: - hold_everything (bool& x): ischild (x) {} - operator int () const {return signals;} - - ~hold_everything() - { - if (ischild) - { - pthread.dont_bother (); - process.dont_bother (); - signals.dont_bother (); - } - } - -}; - -static void -resume_child (HANDLE forker_finished) -{ - SetEvent (forker_finished); - debug_printf ("signalled child"); - return; -} - -/* Notify parent that it is time for the next step. */ -static void __stdcall -sync_with_parent (const char *s, bool hang_self) -{ - debug_printf ("signalling parent: %s", s); - fork_info->ready (false); - if (hang_self) - { - HANDLE h = fork_info->forker_finished; - /* Wait for the parent to fill in our stack and heap. - Don't wait forever here. If our parent dies we don't want to clog - the system. If the wait fails, we really can't continue so exit. */ - DWORD psync_rc = WaitForSingleObject (h, FORK_WAIT_TIMEOUT); - debug_printf ("awake"); - switch (psync_rc) - { - case WAIT_TIMEOUT: - api_fatal ("WFSO timed out %s", s); - break; - case WAIT_FAILED: - if (GetLastError () == ERROR_INVALID_HANDLE && - WaitForSingleObject (fork_info->forker_finished, 1) != WAIT_FAILED) - break; - api_fatal ("WFSO failed %s, fork_finished %p, %E", s, - fork_info->forker_finished); - break; - default: - debug_printf ("no problems"); - break; - } - } -} - -int __stdcall -frok::child (volatile char * volatile here) -{ - HANDLE& hParent = ch.parent; - extern void fixup_lockf_after_fork (); - extern void fixup_hooks_after_fork (); - extern void fixup_timers_after_fork (); - debug_printf ("child is running. pid %d, ppid %d, stack here %p", - myself->pid, myself->ppid, __builtin_frame_address (0)); - - sync_with_parent ("after longjmp", true); - sigproc_printf ("hParent %p, load_dlls %d", hParent, load_dlls); - - /* If we've played with the stack, stacksize != 0. That means that - fork() was invoked from other than the main thread. Make sure that - the threadinfo information is properly set up. */ - if (fork_info->stacksize) - { - _main_tls = &_my_tls; - _main_tls->init_thread (NULL, NULL); - _main_tls->local_clib = *_impure_ptr; - _impure_ptr = &_main_tls->local_clib; - } - - set_cygwin_privileges (hProcToken); - clear_procimptoken (); - cygheap->user.reimpersonate (); - -#ifdef DEBUGGING - if (GetEnvironmentVariableA ("FORKDEBUG", NULL, 0)) - try_to_debug (); - char buf[80]; - /* This is useful for debugging fork problems. Use gdb to attach to - the pid reported here. */ - if (GetEnvironmentVariableA ("CYGWIN_FORK_SLEEP", buf, sizeof (buf))) - { - small_printf ("Sleeping %d after fork, pid %u\n", atoi (buf), GetCurrentProcessId ()); - Sleep (atoi (buf)); - } -#endif - - MALLOC_CHECK; - - /* Incredible but true: If we use sockets and SYSV IPC shared memory, - there's a good chance that a duplicated socket in the child occupies - memory which is needed to duplicate shared memory from the parent - process, if the shared memory hasn't been duplicated already. - The same goes very likely for "normal" mmap shared memory, too, but - with SYSV IPC it was the first time observed. So, *never* fixup - fdtab before fixing up shared memory. */ - if (fixup_shms_after_fork ()) - api_fatal ("recreate_shm areas after fork failed"); - - MALLOC_CHECK; - - /* If we haven't dynamically loaded any dlls, just signal - the parent. Otherwise, load all the dlls, tell the parent - that we're done, and wait for the parent to fill in the. - loaded dlls' data/bss. */ - if (!load_dlls) - { - cygheap->fdtab.fixup_after_fork (hParent); - sync_with_parent ("performed fork fixup", false); - } - else - { - dlls.load_after_fork (hParent); - cygheap->fdtab.fixup_after_fork (hParent); - sync_with_parent ("loaded dlls", true); - } - - init_console_handler (myself->ctty >= 0); - ForceCloseHandle1 (fork_info->forker_finished, forker_finished); - - pthread::atforkchild (); - fixup_timers_after_fork (); - cygbench ("fork-child"); - ld_preload (); - fixup_hooks_after_fork (); - _my_tls.fixup_after_fork (); - wait_for_sigthread (); - cygwin_finished_initializing = true; - return 0; -} - -#define NO_SLOW_PID_REUSE -#ifndef NO_SLOW_PID_REUSE -static void -slow_pid_reuse (HANDLE h) -{ - static NO_COPY HANDLE last_fork_procs[NPIDS_HELD]; - static NO_COPY unsigned nfork_procs; - - if (nfork_procs >= (sizeof (last_fork_procs) / sizeof (last_fork_procs [0]))) - nfork_procs = 0; - /* Keep a list of handles to child processes sitting around to prevent - Windows from reusing the same pid n times in a row. Having the same pids - close in succesion confuses bash. Keeping a handle open will stop - windows from reusing the same pid. */ - if (last_fork_procs[nfork_procs]) - ForceCloseHandle1 (last_fork_procs[nfork_procs], fork_stupidity); - if (DuplicateHandle (GetCurrentProcess (), h, - GetCurrentProcess (), &last_fork_procs[nfork_procs], - 0, FALSE, DUPLICATE_SAME_ACCESS)) - ProtectHandle1 (last_fork_procs[nfork_procs], fork_stupidity); - else - { - last_fork_procs[nfork_procs] = NULL; - system_printf ("couldn't create last_fork_proc, %E"); - } - nfork_procs++; -} -#endif - -int __stdcall -frok::parent (volatile char * volatile stack_here) -{ - HANDLE forker_finished; - DWORD rc; - child_pid = -1; - error = NULL; - this_errno = 0; - bool fix_impersonation = false; - pinfo child; - static char errbuf[256]; - - int c_flags = GetPriorityClass (GetCurrentProcess ()); - debug_printf ("priority class %d", c_flags); - - /* If we don't have a console, then don't create a console for the - child either. */ - HANDLE console_handle = CreateFile ("CONOUT$", GENERIC_WRITE, - FILE_SHARE_WRITE, &sec_none_nih, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, - NULL); - - if (console_handle != INVALID_HANDLE_VALUE) - CloseHandle (console_handle); - else - c_flags |= DETACHED_PROCESS; - - /* Some file types (currently only sockets) need extra effort in the - parent after CreateProcess and before copying the datastructures - to the child. So we have to start the child in suspend state, - unfortunately, to avoid a race condition. */ - if (cygheap->fdtab.need_fixup_before ()) - c_flags |= CREATE_SUSPENDED; - - /* Remember if we need to load dynamically linked dlls. - We do this here so that this information will be available - in the parent and, when the stack is copied, in the child. */ - load_dlls = dlls.reload_on_fork && dlls.loaded_dlls; - - forker_finished = CreateEvent (&sec_all, FALSE, FALSE, NULL); - if (forker_finished == NULL) - { - this_errno = geterrno_from_win_error (); - error = "unable to allocate forker_finished event"; - return -1; - } - - ProtectHandleINH (forker_finished); - - ch.forker_finished = forker_finished; - - ch.stackbottom = _tlsbase; - ch.stacktop = (void *) stack_here; - ch.stacksize = (char *) ch.stackbottom - (char *) stack_here; - debug_printf ("stack - bottom %p, top %p, size %d", - ch.stackbottom, ch.stacktop, ch.stacksize); - - PROCESS_INFORMATION pi; - STARTUPINFOW si; - - memset (&si, 0, sizeof (si)); - si.cb = sizeof si; - - si.lpReserved2 = (LPBYTE) &ch; - si.cbReserved2 = sizeof (ch); - - /* FIXME: myself->progname should be converted to WCHAR. */ - tmp_pathbuf tp; - PWCHAR progname = tp.w_get (); - sys_mbstowcs (progname, NT_MAX_PATH, myself->progname); - - syscall_printf ("CreateProcess (%W, %W, 0, 0, 1, %p, 0, 0, %p, %p)", - progname, progname, c_flags, &si, &pi); - bool locked = __malloc_lock (); - time_t start_time = time (NULL); - - /* Remove impersonation */ - cygheap->user.deimpersonate (); - fix_impersonation = true; - - while (1) - { - rc = CreateProcessW (progname, /* image to run */ - progname, /* what we send in arg0 */ - &sec_none_nih, - &sec_none_nih, - TRUE, /* inherit handles from parent */ - c_flags, - NULL, /* environment filled in later */ - 0, /* use current drive/directory */ - &si, - &pi); - - if (!rc) - { - this_errno = geterrno_from_win_error (); - error = "CreateProcessW failed"; - memset (&pi, 0, sizeof (pi)); - goto cleanup; - } - - if (cygheap->fdtab.need_fixup_before ()) - { - cygheap->fdtab.fixup_before_fork (pi.dwProcessId); - ResumeThread (pi.hThread); - } - - CloseHandle (pi.hThread); - - /* Protect the handle but name it similarly to the way it will - be called in subproc handling. */ - ProtectHandle1 (pi.hProcess, childhProc); - - strace.write_childpid (ch, pi.dwProcessId); - - /* Wait for subproc to initialize itself. */ - if (!ch.sync (pi.dwProcessId, pi.hProcess, FORK_WAIT_TIMEOUT)) - { - DWORD exit_code = ch.proc_retry (pi.hProcess); - if (!exit_code) - continue; - this_errno = EAGAIN; - /* Not thread safe, but do we care? */ - __small_sprintf (errbuf, "died waiting for longjmp before initialization, " - "retry %d, exit code %p", ch.retry, exit_code); - error = errbuf; - goto cleanup; - } - break; - } - - /* Restore impersonation */ - cygheap->user.reimpersonate (); - fix_impersonation = false; - - child_pid = cygwin_pid (pi.dwProcessId); - child.init (child_pid, 1, NULL); - - if (!child) - { - this_errno = get_errno () == ENOMEM ? ENOMEM : EAGAIN; -#ifdef DEBUGGING - error = "pinfo failed"; -#else - syscall_printf ("pinfo failed"); -#endif - goto cleanup; - } - - child->start_time = start_time; /* Register child's starting time. */ - child->nice = myself->nice; - - /* Initialize things that are done later in dll_crt0_1 that aren't done - for the forkee. */ - strcpy (child->progname, myself->progname); - - /* Fill in fields in the child's process table entry. */ - child->dwProcessId = pi.dwProcessId; - child.hProcess = pi.hProcess; - - /* Hopefully, this will succeed. The alternative to doing things this - way is to reserve space prior to calling CreateProcess and then fill - it in afterwards. This requires more bookkeeping than I like, though, - so we'll just do it the easy way. So, terminate any child process if - we can't actually record the pid in the internal table. */ - if (!child.remember (false)) - { - TerminateProcess (pi.hProcess, 1); - this_errno = EAGAIN; -#ifdef DEBUGGING0 - error = "child.remember failed"; -#endif - goto cleanup; - } - -#ifndef NO_SLOW_PID_REUSE - slow_pid_reuse (pi.hProcess); -#endif - - /* CHILD IS STOPPED */ - debug_printf ("child is alive (but stopped)"); - - /* Initialize, in order: stack, dll data, dll bss. - data, bss, heap were done earlier (in dcrt0.cc) - Note: variables marked as NO_COPY will not be copied since they are - placed in a protected segment. */ - - MALLOC_CHECK; - const void *impure_beg; - const void *impure_end; - const char *impure; - if (&_my_tls == _main_tls) - impure_beg = impure_end = impure = NULL; - else - { - impure = "impure"; - impure_beg = _impure_ptr; - impure_end = _impure_ptr + 1; - } - rc = child_copy (pi.hProcess, true, - "stack", stack_here, ch.stackbottom, - impure, impure_beg, impure_end, - NULL); - - __malloc_unlock (); - locked = false; - MALLOC_CHECK; - if (!rc) - { - this_errno = get_errno (); - DWORD exit_code; - if (!GetExitCodeProcess (pi.hProcess, &exit_code)) - exit_code = 0xdeadbeef; - __small_sprintf (errbuf, "pid %u, exitval %p", pi.dwProcessId, exit_code); - error = errbuf; - goto cleanup; - } - - /* Now fill data/bss of any DLLs that were linked into the program. */ - for (dll *d = dlls.istart (DLL_LINK); d; d = dlls.inext ()) - { - debug_printf ("copying data/bss of a linked dll"); - if (!child_copy (pi.hProcess, true, - "linked dll data", d->p.data_start, d->p.data_end, - "linked dll bss", d->p.bss_start, d->p.bss_end, - NULL)) - { - this_errno = get_errno (); -#ifdef DEBUGGING - DWORD exit_code; - if (!GetExitCodeProcess (pi.hProcess, &exit_code)) - exit_code = 0xdeadbeef; - __small_sprintf (errbuf, "pid %u, exitval %p", pi.dwProcessId, exit_code); - error = errbuf; -#endif - goto cleanup; - } - } - - /* Start thread, and then wait for it to reload dlls. */ - resume_child (forker_finished); - if (!ch.sync (child->pid, pi.hProcess, FORK_WAIT_TIMEOUT)) - { - this_errno = EAGAIN; - error = "died waiting for dll loading"; - goto cleanup; - } - - /* If DLLs were loaded in the parent, then the child has reloaded all - of them and is now waiting to have all of the individual data and - bss sections filled in. */ - if (load_dlls) - { - /* CHILD IS STOPPED */ - /* write memory of reloaded dlls */ - for (dll *d = dlls.istart (DLL_LOAD); d; d = dlls.inext ()) - { - debug_printf ("copying data/bss for a loaded dll"); - if (!child_copy (pi.hProcess, true, - "loaded dll data", d->p.data_start, d->p.data_end, - "loaded dll bss", d->p.bss_start, d->p.bss_end, - NULL)) - { - this_errno = get_errno (); -#ifdef DEBUGGING - error = "copying data/bss for a loaded dll"; -#endif - goto cleanup; - } - } - /* Start the child up again. */ - resume_child (forker_finished); - } - - ForceCloseHandle (forker_finished); - forker_finished = NULL; - - return child_pid; - -/* Common cleanup code for failure cases */ -cleanup: - if (fix_impersonation) - cygheap->user.reimpersonate (); - if (locked) - __malloc_unlock (); - - /* Remember to de-allocate the fd table. */ - if (pi.hProcess && !child.hProcess) - ForceCloseHandle1 (pi.hProcess, childhProc); - if (forker_finished) - ForceCloseHandle (forker_finished); - debug_printf ("returning -1"); - return -1; -} - -extern "C" int -fork () -{ - frok grouped; - - debug_printf ("entering"); - grouped.load_dlls = 0; - - int res; - bool ischild = false; - - myself->set_has_pgid_children (); - - if (grouped.ch.parent == NULL) - return -1; - if (grouped.ch.subproc_ready == NULL) - { - system_printf ("unable to allocate subproc_ready event, %E"); - return -1; - } - - { - hold_everything held_everything (ischild); - /* This tmp_pathbuf constructor is required here because the below setjmp - magic will otherwise not restore the original buffer count values in - the thread-local storage. A process forking too deeply will run into - the problem to be out of temporary TLS path buffers. */ - tmp_pathbuf tp; - - if (!held_everything) - { - if (exit_state) - Sleep (INFINITE); - set_errno (EAGAIN); - return -1; - } - - ischild = !!setjmp (grouped.ch.jmp); - - volatile char * volatile esp; - __asm__ volatile ("movl %%esp,%0": "=r" (esp)); - - if (!ischild) - res = grouped.parent (esp); - else - { - res = grouped.child (esp); - ischild = true; /* might have been reset by fork mem copy */ - } - } - - MALLOC_CHECK; - if (ischild || res > 0) - /* everything is ok */; - else - { - if (!grouped.error) - syscall_printf ("fork failed - child pid %d, errno %d", grouped.child_pid, grouped.this_errno); - else - { - char buf[strlen (grouped.error) + sizeof ("child %d - , errno 4294967295 ")]; - strcpy (buf, "child %d - "); - strcat (buf, grouped.error); - strcat (buf, ", errno %d"); - system_printf (buf, grouped.child_pid, grouped.this_errno); - } - - set_errno (grouped.this_errno); - } - syscall_printf ("%d = fork()", res); - return res; -} -#ifdef DEBUGGING -void -fork_init () -{ -} -#endif /*DEBUGGING*/ - -#ifdef NEWVFORK -/* Dummy function to force second assignment below to actually be - carried out */ -static vfork_save * -get_vfork_val () -{ - return vfork_storage.val (); -} -#endif - -extern "C" int -vfork () -{ -#ifndef NEWVFORK - debug_printf ("stub called"); - return fork (); -#else - vfork_save *vf = get_vfork_val (); - char **esp, **pp; - - if (vf == NULL) - vf = vfork_storage.create (); - else if (vf->pid) - return fork (); - - // FIXME the tls stuff could introduce a signal race if a child process - // exits quickly. - if (!setjmp (vf->j)) - { - vf->pid = -1; - __asm__ volatile ("movl %%esp,%0": "=r" (vf->vfork_esp):); - __asm__ volatile ("movl %%ebp,%0": "=r" (vf->vfork_ebp):); - for (pp = (char **) vf->frame, esp = vf->vfork_esp; - esp <= vf->vfork_ebp + 2; pp++, esp++) - *pp = *esp; - vf->ctty = myself->ctty; - vf->sid = myself->sid; - vf->pgid = myself->pgid; - cygheap->ctty_on_hold = cygheap->ctty; - vf->console_count = cygheap->console_count; - debug_printf ("cygheap->ctty_on_hold %p, cygheap->console_count %d", cygheap->ctty_on_hold, cygheap->console_count); - int res = cygheap->fdtab.vfork_child_dup () ? 0 : -1; - debug_printf ("%d = vfork()", res); - _my_tls.call_signal_handler (); // FIXME: racy - vf->tls = _my_tls; - return res; - } - - vf = get_vfork_val (); - - for (pp = (char **) vf->frame, esp = vf->vfork_esp; - esp <= vf->vfork_ebp + 2; pp++, esp++) - *esp = *pp; - - cygheap->fdtab.vfork_parent_restore (); - - myself->ctty = vf->ctty; - myself->sid = vf->sid; - myself->pgid = vf->pgid; - termios_printf ("cygheap->ctty %p, cygheap->ctty_on_hold %p", cygheap->ctty, cygheap->ctty_on_hold); - cygheap->console_count = vf->console_count; - - if (vf->pid < 0) - { - int exitval = vf->exitval; - vf->pid = 0; - if ((vf->pid = fork ()) == 0) - exit (exitval); - } - - int pid = vf->pid; - vf->pid = 0; - debug_printf ("exiting vfork, pid %d", pid); - sig_dispatch_pending (); - - _my_tls.call_signal_handler (); // FIXME: racy - _my_tls = vf->tls; - return pid; -#endif -} - -/* Copy memory from one process to another. */ - -bool -child_copy (HANDLE hp, bool write, ...) -{ - va_list args; - va_start (args, write); - static const char *huh[] = {"read", "write"}; - - char *what; - while ((what = va_arg (args, char *))) - { - char *low = va_arg (args, char *); - char *high = va_arg (args, char *); - DWORD todo = wincap.chunksize () ?: high - low; - char *here; - - for (here = low; here < high; here += todo) - { - DWORD done = 0; - if (here + todo > high) - todo = high - here; - int res; - if (write) - res = WriteProcessMemory (hp, here, here, todo, &done); - else - res = ReadProcessMemory (hp, here, here, todo, &done); - debug_printf ("%s - hp %p low %p, high %p, res %d", what, hp, low, high, res); - if (!res || todo != done) - { - if (!res) - __seterrno (); - /* If this happens then there is a bug in our fork - implementation somewhere. */ - system_printf ("%s %s copy failed, %p..%p, done %d, windows pid %u, %E", - what, huh[write], low, high, done, myself->dwProcessId); - goto err; - } - } - } - - va_end (args); - debug_printf ("done"); - return true; - - err: - va_end (args); - TerminateProcess (hp, 1); - set_errno (EAGAIN); - return false; -} diff --git a/winsup/cygwin/gcrt0.c b/winsup/cygwin/gcrt0.c deleted file mode 100644 index 19a941676..000000000 --- a/winsup/cygwin/gcrt0.c +++ /dev/null @@ -1,41 +0,0 @@ -/* gcrt0.c - - Copyright 1998, 1999, 2000, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include -#include - -extern u_char etext asm ("etext"); -extern u_char eprol asm ("__eprol"); -extern void _mcleanup (void); -extern void monstartup (u_long, u_long); - -void _monstartup (void) __attribute__((__constructor__)); - -/* startup initialization for -pg support */ - -void -_monstartup (void) -{ - static int called; - - /* Guard against multiple calls that may happen if DLLs are linked - with profile option set as well. Addede side benefit is that it - makes profiling backward compatible (GCC used to emit a call to - _monstartup when compiling main with profiling enabled). */ - if (called++) - return; - - monstartup ((u_long) &eprol, (u_long) &etext); - atexit (&_mcleanup); -} - -asm (".text"); -asm ("__eprol:"); - diff --git a/winsup/cygwin/gendef b/winsup/cygwin/gendef deleted file mode 100755 index 9c17010b4..000000000 --- a/winsup/cygwin/gendef +++ /dev/null @@ -1,464 +0,0 @@ -#!/usr/bin/perl -# Copyright 2003, 2004, 2005, 2006, 2008 Red Hat, Inc. -# -# This file is part of Cygwin. -# -# This software is a copyrighted work licensed under the terms of the -# Cygwin license. Please consult the file "CYGWIN_LICENSE" for -# details. -# -use strict; -sub cleanup(@); - -my $in = shift; -my $tls_offsets = shift; -my $out = shift; -my $sigfe = shift; - -$main::first = 0; -if (!defined($in) || !defined($out) || !defined($sigfe)) { - die "usage: $0 deffile.in cygtls.h deffile.def sigfe.s\n"; -} - -require $tls_offsets; - -open(IN, $in) or die "$0: couldn't open \"$in\" - $!\n"; -my @top = (); -while () { - push(@top, cleanup $_); - last if /^\s*exports\s*$/i; -} -my $libline = cleanup scalar(); -my @in = cleanup ; -close(IN); - -my %sigfe = (); -my @data = (); -my @nosigfuncs = (); -my @text = (); -for (@in) { - chomp; - s/\sDATA$//o and do { - push @data, $_; - next; - }; - if (/=/o) { - if (s/\s+NOSIGFE\s*$//) { - # nothing - } elsif (s/ SIGFE(_MAYBE)?$//) { - my $func = (split(' '))[2]; - my $maybe = lc $1 . '_'; - $sigfe{$func} = '_sigfe' . $maybe . $func; - } - } else { - my ($func, $sigfe) = m%^\s*(\S+)(?:\s+((?:NO)?SIGFE(?:_MAYBE)?))?$%o; - if (defined($sigfe) && $sigfe =~ /^NO/o) { - $_ = $func; - } else { - $sigfe ||= 'sigfe'; - $_ = '_' . lc($sigfe) . '_' . $func; - $sigfe{$func} = $_; - $_ = $func . ' = ' . $_; - } - } - s/(\S)\s+(\S)/$1 $2/go; - s/(\S)\s+$/$1/o; - s/^\s+(\S)/$1/o; - push @text, $_; -} - -for (@text) { - my ($alias, $func) = /^(\S+) = (\S+)\s*$/o; - $_ = $alias . ' = ' . $sigfe{$func} - if defined($func) && $sigfe{$func}; -} - -open(OUT, '>', $out) or die "$0: couldn't open \"$out\" - $!\n"; -push @top, (map {$_ . " DATA\n"} @data), (map {$_ . "\n"} @text); -print OUT @top; -close OUT; - -open(SIGFE, '>', $sigfe) or die "$0: couldn't open sigfe file \"$sigfe\" - $!\n"; - -for my $k (sort keys %sigfe) { - print SIGFE fefunc($k, $sigfe{$k}); -} -close SIGFE; - -sub fefunc { - my $func = '_' . shift; - my $fe = '_' . shift; - my $sigfe_func = ($fe =~ /^(.*)$func/)[0]; - my $extra; - my $res = < than tls - jge 0f # yep. we don't have a tls. - subl \$$tls::initialized,%ebx # where we will be looking - movl $tls::initialized(%ebx),%eax - cmpl \$0xc763173f,%eax # initialized? - je 1f -0: popl %edx - popl %ebx - ret - -__sigfe: - pushl %ebx - pushl %edx - movl %fs:4,%ebx # location of bottom of stack -1: movl \$1,%eax # potential lock value - lock xchgl %eax,$tls::stacklock(%ebx) # see if we can grab it - movl %eax,$tls::spinning(%ebx) # flag if we are waiting for lock - testl %eax,%eax # it will be zero - jz 2f # if so - xorl %eax,%eax # nope. It was not zero - call _low_priority_sleep # should be a short-time thing, so - jmp 1b # sleep and loop -2: movl \$4,%eax # have the lock, now increment the - xadd %eax,$tls::stackptr(%ebx) # stack pointer and get pointer - leal __sigbe,%edx # new place to return to - xchgl %edx,12(%esp) # exchange with real return value - movl %edx,(%eax) # store real return value on alt stack - incl $tls::incyg(%ebx) - decl $tls::stacklock(%ebx) # remove lock - popl %edx # restore saved value - popl %ebx - ret - - .global __sigbe -__sigbe: # return here after cygwin syscall - pushl %edx - pushl %ebx - pushl %eax # don't clobber -1: movl %fs:4,%ebx # address of bottom of tls - movl \$1,%eax # potential lock value - lock xchgl %eax,$tls::stacklock(%ebx) # see if we can grab it - movl %eax,$tls::spinning(%ebx) # flag if we are waiting for lock - testl %eax,%eax # it will be zero - jz 2f # if so - xorl %eax,%eax # nope. not zero - call _low_priority_sleep # sleep - jmp 1b # and loop -2: movl \$-4,%eax # now decrement aux stack - xadd %eax,$tls::stackptr(%ebx) # and get pointer - xorl %edx,%edx - xchgl %edx,-4(%eax) # get return address from signal stack - xchgl %edx,8(%esp) # restore edx/real return address - decl $tls::incyg(%ebx) - decl $tls::stacklock(%ebx) # release lock - popl %eax - popl %ebx - ret - - .global _sigreturn -_sigreturn: - movl %fs:4,%ebx - incl $tls::incyg(%ebx) - addl \$12,%esp # remove arguments - call _set_process_mask\@4 - -1: movl \$1,%eax # potential lock value - lock xchgl %eax,$tls::stacklock(%ebx) # see if we can grab it - movl %eax,$tls::spinning(%ebx) # flag if we are waiting for lock - testl %eax,%eax # it will be zero - jz 2f # if so - xorl %eax,%eax # nope. not zero - call _low_priority_sleep # sleep - jmp 1b # and loop -2: popl %edx # saved errno - testl %edx,%edx # Is it < 0 - jl 3f # yup. ignore it - movl $tls::errno_addr(%ebx),%eax - movl %edx,(%eax) -3: movl \$-4,%eax # now decrement aux stack - xadd %eax,$tls::stackptr(%ebx) # and get pointer - xorl %ebp,%ebp - xchgl %ebp,-4(%eax) # get return address from signal stack - xchgl %ebp,28(%esp) # store real return address - decl $tls::incyg(%ebx) - decl $tls::stacklock(%ebx) # unlock - - popl %eax - popl %ebx - popl %ecx - popl %edx - popl %edi - popl %esi - popf - ret - - .global _sigdelayed -_sigdelayed: - pushl %ebp - movl %esp,%ebp - pushf - pushl %esi - pushl %edi - pushl %edx - pushl %ecx - pushl %ebx - pushl %eax - movl %fs:4,%ebx - incl $tls::incyg(%ebx) - pushl $tls::saved_errno(%ebx) # saved errno - call _set_process_mask_delta - pushl %eax - - # fill out handler arguments - xorl %eax,%eax # ucontext_t (currently not set) - pushl %eax - leal $tls::infodata(%ebx),%eax - pushl %eax # siginfo - pushl $tls::sig(%ebx) # signal number - - call _reset_signal_arrived\@0 - pushl \$_sigreturn # where to return - pushl $tls::func(%ebx) # signal func - cmpl \$0,$tls::threadkill(%ebx)#pthread_kill signal? - jnz 4f # yes. callee clears signal number - movl \$0,$tls::sig(%ebx) # zero the signal number as a - # flag to the signal handler thread - # that it is ok to set up sigsave -4: decl $tls::incyg(%ebx) - ret - - .global __ZN7_cygtls3popEv -__ZN7_cygtls3popEv: -1: pushl %ebx - pushl %edx # FIXME: needed? - movl %eax,%ebx - movl \$-4,%edx - xadd %edx,$tls::pstackptr(%ebx) - xorl %eax,%eax - xchgl %eax,-4(%edx) - popl %edx # FIXME: needed? - popl %ebx - ret - - .global __ZN7_cygtls4lockEv -__ZN7_cygtls4lockEv: - pushl %ebx - movl %eax,%ebx -1: movl \$1,%eax - lock xchgl %eax,$tls::pstacklock(%ebx) - testl %eax,%eax - jz 2f - xorl %eax,%eax - call _low_priority_sleep - jmp 1b -2: popl %ebx - ret - - .global __ZN7_cygtls6unlockEv -__ZN7_cygtls6unlockEv: - decl $tls::pstacklock(%eax) - ret - - .global __ZN7_cygtls6lockedEv -__ZN7_cygtls6lockedEv: - movl $tls::pstacklock(%eax),%eax - ret - - .extern __ZN7_cygtls19call_signal_handlerEv -stabilize_sig_stack: - movl %fs:4,%ebx - incl $tls::incyg(%ebx) -1: movl \$1,%eax - lock xchgl %eax,$tls::stacklock(%ebx) - movl %eax,$tls::spinning(%ebx) # flag if we are waiting for lock - testl %eax,%eax - jz 2f - xorl %eax,%eax - call _low_priority_sleep - jmp 1b -2: cmpl \$0,$tls::sig(%ebx) - jz 3f - decl $tls::stacklock(%ebx) # unlock - movl \$-$tls::sizeof__cygtls,%eax # point to beginning - addl %ebx,%eax # of tls block - call __ZN7_cygtls19call_signal_handlerEv - jmp 1b -3: decl $tls::incyg(%ebx) - ret -EOF - } - return $res; -} - -sub longjmp { - return <) { - if (/%storage_here/) { - $storage_ix = @lines; - } elsif (/^"([^"]+)",\s*(.*)$/o) { - push(@patterns, [$1, $2]); - next; - } - if (@patterns) { - for my $f (sort devsort @patterns) { - my $x = $f->[0]; - my $rest = $f->[1]; - my ($dev, $devrest) = ($x =~ /([^%]+)(%.*)?$/o); - push(@lines, generate($dev, $devrest, $rest, [])); - } - @patterns = (); - } - push(@lines, $_); -} - -close INPUT; -# @storage = sort devsort @storage; -chop $storage[$#storage]; -chop $storage[$#storage]; -$storage[$#storage] .= "\n"; -splice(@lines, $storage_ix, 1, - "static const device dev_storage[] =\n", "{\n", - @storage, "};\n\n", - sort {$a cmp $b} values %pointers); -open(SHILKA, '>', $shilka); -print SHILKA @lines; -close SHILKA; - -chdir '/tmp'; -system qw'shilka -length -strip -no-definitions', $shilka; -if ($? == -1) { - die "$0: shilka command missing? - $!\n"; -} else { - exit $? if $?; -} -chdir $cwd; -unlink $shilka; -open(C, $c) or die "$0: couldn't open $c - $!\n"; -@lines = ; -close C; -unlink $c; -splice(@lines, 0, 3); -my $ign_until_brace = 0; -for (my $i = 0; $i < @lines; $i++) { - $_ = $lines[$i]; - $ign_until_brace = 1 if /(?:KR_reset|KR_output_statistics).*\)\s*$/o; - if ($ign_until_brace || /(?:#\s*line|(?:KR_reset|KR_output_statistics).*;)/) { - $ign_until_brace = 0 if $ign_until_brace && /}/o; - splice(@lines, $i, 1); - redo; - }; -} -open(OUTPUT, '>', $output) or do {{ - if (chmod(0664, $output)) { - open(OUTPUT, '>', $output); - last; - } - die "$0: couldn't open $output - $!\n"; -}}; -print OUTPUT @lines; -close OUTPUT; - -sub generate { - my $dev = shift; - my $devrest = shift; - my $rest = shift; - my $vars = shift; - my $res; - my @lines = (); - if ($devrest) { - my ($a, $low, $high, $fmt, $b) = ($devrest =~ /%([\({])([^-]+)-([^\)}]+)[\)}](.)(.*)/o); - my ($middle, $devrest0) = ($b =~ /^([^%]*)(%.*)?$/); - $fmt = "%$fmt"; - my $vars_ix = @{$vars}; - for my $f ($low .. $high) { - $vars->[$vars_ix] = $f; - $#{$vars} = $vars_ix; - my $dev0 = $dev . sprintf($fmt, $f) . $middle; - push(@lines, generate($dev0, $devrest0, $rest, $vars)); - } - } else { - my $fh = $dev; - $fh =~ s%/%_%og; - my $shilka_id = $fh; - my $storage_str = $fh . '_storage'; - $fh =~ s/^_dev_/FH_/o; - $fh = uc $fh; - $shilka_id =~ s/^_dev_//o; - $storage_str =~ s/^_dev/dev/o; - my $storage_loc = "dev_storage + " . @storage; - @lines = ('"' . $dev . '"' . " = $shilka_id {return $storage_loc;}\n"); - $rest = "$fh, $rest" if $rest =~ /^"/o; - $rest = fixup($rest, $vars); - if ($rest =~ /^(.*), ([a-z_]*_dev)/) { - $pointers{$2} ||= "const device *$2 = $storage_loc;\n"; - $rest = $1; - } - push(@storage, " {\"$dev\", " . $rest . "},\n"); - } - return @lines; -} - -sub fixup { - my $rest = shift; - my $vars = shift; - 0 while $rest =~ s/{([^}]*)}/evalit($1, $vars)/eg; - return $rest; -} - -sub evalit { - my $what = shift; - my $vars = shift; - $what =~ s/\$(\d+)/'$vars->[$1-1]'/g; - my $res = eval $what; - return $res; -} - -sub devsort { - my $a0 = $a->[0]; - my $b0 = $b->[0]; - $a0 =~ s/(\D)(\d+)/"$1" . sprintf "%05d", $2/e; - $b0 =~ s/(\D)(\d+)/"$1" . sprintf "%05d", $2/e; - return $a0 cmp $b0; -} diff --git a/winsup/cygwin/gentls_offsets b/winsup/cygwin/gentls_offsets deleted file mode 100755 index 2c96487d4..000000000 --- a/winsup/cygwin/gentls_offsets +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/perl -s -# Copyright 2003, 2004, 2005 Red Hat, Inc. -# -# This file is part of Cygwin. -# -# This software is a copyrighted work licensed under the terms of the -# Cygwin license. Please consult the file "CYGWIN_LICENSE" for -# details. -# -my $tls = shift; -my $tls_out = shift; -open(TLS, $tls) or die "$0: couldn't open tls file \"$tls\" - $!\n"; -my $struct = ''; -my @fields = (); -my $def = ''; -$tls = join('', ); -$tls =~ s/\n[^\n]*gentls_offsets[^\n]*\n(.+)\Z/$1/os; -my $pre = $`; -substr($tls, 0, length($pre)) = ''; -$pre =~ s/\n#ifndef _[^\n]+\n/\n/os; -$pre .= "\n//*/"; -$tls =~ s%/\*\s*gentls_offsets.*?/\*\s*gentls_offsets\s*\*/%%ogs; -foreach ($tls =~ /^.*\n/mg) { - /^}|\s*(?:typedef|const)/o and do { - $def .= $_ ; - next; - }; - $def .= $_ if $struct; - if (!s/;.*$//o) { - if (!$struct && /^\s*(?:struct|class)\s*([a-z_0-9]+)/o) { - $def .= $_; - $struct = $1 - } - next; - } - s/(?:\[[^\]]*\]|struct|class)//o; - s/^\s+\S+\s+//o; - s/[\*\s()]+//go; - for my $f (split(/,/)) { - push(@fields, $f); - } -} -close TLS; -open(TMP, '>', "/tmp/$$.cc") or die "$0: couldn't open temporary index file \"/tmp/$$.c\" - $!\n"; -print TMP < -#include -#include -#include -$pre -$def -int -main(int argc, char **argv) -{ - $struct *foo; -# define foo_beg ((char *) foo) -# define offset(f) ((int) (((char *) &(foo->f)) - foo_beg) - CYGTLS_PADSIZE) -# define poffset(f) (((char *) &(foo->f)) - ((char *) foo)) -EOF - print TMP 'puts ("//;# autogenerated: Do not edit.\n");', "\n\n"; - print TMP "printf (\"//; \$tls::sizeof_$struct = %d;\\n\", sizeof($struct\));\n"; - for my $f (@fields) { - print TMP ' printf ("//; $tls::', $f, ' = %d;\n", ', "offset($f));\n"; - print TMP ' printf ("//; $tls::p', $f, ' = %d;\n", ', "poffset($f));\n"; - } - print TMP ' puts ("//; __DATA__\n");', "\n"; - for my $f (@fields) { - print TMP ' printf ("#define tls_', $f, ' (%d)\n", ', "offset($f));\n"; - print TMP ' printf ("#define tls_p', $f, ' (%d)\n", ', "poffset($f));\n"; - } - - print TMP <', $tls_out) or die "$0: couldn't open tls index file \"$tls_out\" - $!\n"; -open(OFFS, "/tmp/$$.a.out|") or die "$0: couldn't run \"/tmp/$$.a.out\" - $!\n"; -print TLS_OUT ; -close OFFS; -close TLS_OUT; -unlink "/tmp/$$.cc", "/tmp/$$.a.out"; -exit(0); diff --git a/winsup/cygwin/glob.cc b/winsup/cygwin/glob.cc deleted file mode 100644 index 6bb97c19a..000000000 --- a/winsup/cygwin/glob.cc +++ /dev/null @@ -1,978 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Guido van Rossum. - * - * 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. - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93"; -#endif /* LIBC_SCCS and not lint */ -#ifdef __CYGWIN -__FBSDID("$FreeBSD: /repoman/r/ncvs/src/lib/libc/gen/glob.c,v 1.25 2006/06/05 18:22:13 delphij Exp $"); -#endif - -/* - * glob(3) -- a superset of the one defined in POSIX 1003.2. - * - * The [!...] convention to negate a range is supported (SysV, Posix, ksh). - * - * Optional extra services, controlled by flags not defined by POSIX: - * - * GLOB_QUOTE: - * Escaping convention: \ inhibits any special meaning the following - * character might have (except \ at end of string is retained). - * GLOB_MAGCHAR: - * Set in gl_flags if pattern contained a globbing character. - * GLOB_NOMAGIC: - * Same as GLOB_NOCHECK, but it will only append pattern if it did - * not contain any magic characters. [Used in csh style globbing] - * GLOB_ALTDIRFUNC: - * Use alternately specified directory access functions. - * GLOB_TILDE: - * expand ~user/foo to the /home/dir/of/user/foo - * GLOB_BRACE: - * expand {1,2}{a,b} to 1a 1b 2a 2b - * gl_matchc: - * Number of matches in the current invocation of glob. - */ - -/* - * Some notes on multibyte character support: - * 1. Patterns with illegal byte sequences match nothing - even if - * GLOB_NOCHECK is specified. - * 2. Illegal byte sequences in filenames are handled by treating them as - * single-byte characters with a value of the first byte of the sequence - * cast to wchar_t. - * 3. State-dependent encodings are not currently supported. - */ - -#include "winsup.h" - - -#include -#include -#include -#include -#include -#include -#include - -//#include "collate.h" - -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" - -#include "cygheap.h" -#include "perprocess.h" -#include "cygwin/version.h" - -#ifndef ARG_MAX -#define ARG_MAX 32000 /* See CreateProcess */ -#endif - -#undef MAXPATHLEN -#define MAXPATHLEN 16384 - -#define DOLLAR '$' -#define DOT '.' -#define EOS '\0' -#define LBRACKET '[' -#define NOT '!' -#define QUESTION '?' -#define QUOTE '\\' -#define RANGE '-' -#define RBRACKET ']' -#define SEP '/' -#define STAR '*' -#define TILDE '~' -#define UNDERSCORE '_' -#define LBRACE '{' -#define RBRACE '}' -#define SLASH '/' -#define COMMA ',' - -#ifndef DEBUG - -#define M_QUOTE 0x8000000000ULL -#define M_PROTECT 0x4000000000ULL -#define M_MASK 0xffffffffffULL -#define M_CHAR 0x00ffffffffULL - -typedef uint_fast64_t Char; - -#else - -#define M_QUOTE 0x80 -#define M_PROTECT 0x40 -#define M_MASK 0xff -#define M_CHAR 0x7f - -typedef char Char; - -#endif - - -#define CHAR(c) ((Char)((c)&M_CHAR)) -#define META(c) ((Char)((c)|M_QUOTE)) -#define M_ALL META('*') -#define M_END META(']') -#define M_NOT META('!') -#define M_ONE META('?') -#define M_RNG META('-') -#define M_SET META('[') -#define ismeta(c) (((c)&M_QUOTE) != 0) - - -static int compare(const void *, const void *); -static int g_Ctoc(const Char *, char *, size_t); -static int g_lstat(Char *, struct __stat64 *, glob_t *); -static DIR *g_opendir(Char *, glob_t *); -static Char *g_strchr(Char *, wchar_t); -#ifdef notdef -static Char *g_strcat(Char *, const Char *); -#endif -static int g_stat(Char *, struct __stat64 *, glob_t *); -static int glob0(const Char *, glob_t *, size_t *); -static int glob1(Char *, glob_t *, size_t *); -static int glob2(Char *, Char *, Char *, Char *, glob_t *, size_t *); -static int glob3(Char *, Char *, Char *, Char *, Char *, glob_t *, size_t *); -static int globextend(const Char *, glob_t *, size_t *); -static const Char * - globtilde(const Char *, Char *, size_t, glob_t *); -static int globexp1(const Char *, glob_t *, size_t *); -static int globexp2(const Char *, const Char *, glob_t *, int *, size_t *); -static int match(Char *, Char *, Char *); -#ifdef DEBUG -static void qprintf(const char *, Char *); -#endif - -int -glob(const char *pattern, int flags, int (*errfunc)(const char *, int), glob_t *pglob) -{ - const char *patnext; - size_t limit; - Char *bufnext, *bufend, patbuf[MAXPATHLEN], prot; - mbstate_t mbs; - wchar_t wc; - size_t clen; - - patnext = pattern; - if (!(flags & GLOB_APPEND)) { - pglob->gl_pathc = 0; - pglob->gl_pathv = NULL; - if (!(flags & GLOB_DOOFFS)) - pglob->gl_offs = 0; - } - if (flags & GLOB_LIMIT) { - limit = pglob->gl_matchc; - if (limit == 0) - limit = ARG_MAX; - } else - limit = 0; - pglob->gl_flags = flags & ~GLOB_MAGCHAR; - pglob->gl_errfunc = errfunc; - pglob->gl_matchc = 0; - - bufnext = patbuf; - bufend = bufnext + MAXPATHLEN - 1; - if (flags & GLOB_NOESCAPE) { - memset(&mbs, 0, sizeof(mbs)); - while (bufend - bufnext >= MB_CUR_MAX) { - clen = mbrtowc(&wc, patnext, MB_LEN_MAX, &mbs); - if (clen == (size_t)-1 || clen == (size_t)-2) - return (GLOB_NOMATCH); - else if (clen == 0) - break; - *bufnext++ = wc; - patnext += clen; - } - } else { - /* Protect the quoted characters. */ - memset(&mbs, 0, sizeof(mbs)); - while (bufend - bufnext >= MB_CUR_MAX) { - if (*patnext == QUOTE) { - if (*++patnext == EOS) { - *bufnext++ = QUOTE | M_PROTECT; - continue; - } - prot = M_PROTECT; - } else - prot = 0; - clen = mbrtowc(&wc, patnext, MB_LEN_MAX, &mbs); - if (clen == (size_t)-1 || clen == (size_t)-2) - return (GLOB_NOMATCH); - else if (clen == 0) - break; - *bufnext++ = wc | prot; - patnext += clen; - } - } - *bufnext = EOS; - - if (flags & GLOB_BRACE) - return globexp1(patbuf, pglob, &limit); - else - return glob0(patbuf, pglob, &limit); -} - -/* - * Expand recursively a glob {} pattern. When there is no more expansion - * invoke the standard globbing routine to glob the rest of the magic - * characters - */ -static int -globexp1(const Char *pattern, glob_t *pglob, size_t *limit) -{ - const Char* ptr = pattern; - int rv; - - /* Protect a single {}, for find(1), like csh */ - if (pattern[0] == LBRACE && pattern[1] == RBRACE && pattern[2] == EOS) - return glob0(pattern, pglob, limit); - - while ((ptr = (const Char *) g_strchr((Char *) ptr, LBRACE)) != NULL) - if (!globexp2(ptr, pattern, pglob, &rv, limit)) - return rv; - - return glob0(pattern, pglob, limit); -} - - -/* - * Recursive brace globbing helper. Tries to expand a single brace. - * If it succeeds then it invokes globexp1 with the new pattern. - * If it fails then it tries to glob the rest of the pattern and returns. - */ -static int -globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, int *rv, size_t *limit) -{ - int i; - Char *lm, *ls; - const Char *pe, *pm, *pm1, *pl; - Char patbuf[MAXPATHLEN]; - - /* copy part up to the brace */ - for (lm = patbuf, pm = pattern; pm != ptr; *lm++ = *pm++) - continue; - *lm = EOS; - ls = lm; - - /* Find the balanced brace */ - for (i = 0, pe = ++ptr; *pe; pe++) - if (*pe == LBRACKET) { - /* Ignore everything between [] */ - for (pm = pe++; *pe != RBRACKET && *pe != EOS; pe++) - continue; - if (*pe == EOS) { - /* - * We could not find a matching RBRACKET. - * Ignore and just look for RBRACE - */ - pe = pm; - } - } - else if (*pe == LBRACE) - i++; - else if (*pe == RBRACE) { - if (i == 0) - break; - i--; - } - - /* Non matching braces; just glob the pattern */ - if (i != 0 || *pe == EOS) { - *rv = glob0(patbuf, pglob, limit); - return 0; - } - - for (i = 0, pl = pm = ptr; pm <= pe; pm++) - switch (*pm) { - case LBRACKET: - /* Ignore everything between [] */ - for (pm1 = pm++; *pm != RBRACKET && *pm != EOS; pm++) - continue; - if (*pm == EOS) { - /* - * We could not find a matching RBRACKET. - * Ignore and just look for RBRACE - */ - pm = pm1; - } - break; - - case LBRACE: - i++; - break; - - case RBRACE: - if (i) { - i--; - break; - } - /* FALLTHROUGH */ - case COMMA: - if (i && *pm == COMMA) - break; - else { - /* Append the current string */ - for (lm = ls; (pl < pm); *lm++ = *pl++) - continue; - /* - * Append the rest of the pattern after the - * closing brace - */ - for (pl = pe + 1; (*lm++ = *pl++) != EOS;) - continue; - - /* Expand the current pattern */ -#ifdef DEBUG - qprintf("globexp2:", patbuf); -#endif - *rv = globexp1(patbuf, pglob, limit); - - /* move after the comma, to the next string */ - pl = pm + 1; - } - break; - - default: - break; - } - *rv = 0; - return 0; -} - - - -/* - * expand tilde from the passwd file. - */ -static const Char * -globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob) -{ - struct passwd *pwd; - char *h; - const Char *p; - Char *b, *eb; - - if (*pattern != TILDE || !(pglob->gl_flags & GLOB_TILDE)) - return pattern; - - /* - * Copy up to the end of the string or / - */ - eb = &patbuf[patbuf_len - 1]; - for (p = pattern + 1, h = (char *) patbuf; - h < (char *)eb && *p && *p != SLASH; *h++ = *p++) - continue; - - *h = EOS; - - if (((char *) patbuf)[0] == EOS) { - /* - * handle a plain ~ or ~/ by expanding $HOME first (iff - * we're not running setuid or setgid) and then trying - * the password file - */ - if (cygheap->user.issetuid() != 0 || - (h = getenv("HOME")) == NULL) { - if (((h = getlogin()) != NULL && - (pwd = getpwnam(h)) != NULL) || - (pwd = getpwuid32(getuid32())) != NULL) - h = pwd->pw_dir; - else - return pattern; - } - } - else { - /* - * Expand a ~user - */ - if ((pwd = getpwnam((char*) patbuf)) == NULL) - return pattern; - else - h = pwd->pw_dir; - } - - /* Copy the home directory */ - for (b = patbuf; b < eb && *h; *b++ = *h++) - continue; - - /* Append the rest of the pattern */ - while (b < eb && (*b++ = *p++) != EOS) - continue; - *b = EOS; - - return patbuf; -} - - -/* - * The main glob() routine: compiles the pattern (optionally processing - * quotes), calls glob1() to do the real pattern matching, and finally - * sorts the list (unless unsorted operation is requested). Returns 0 - * if things went well, nonzero if errors occurred. - */ -static int -glob0(const Char *pattern, glob_t *pglob, size_t *limit) -{ - const Char *qpatnext; - int err; - size_t oldpathc; - Char c, *bufnext, patbuf[MAXPATHLEN]; - - qpatnext = globtilde(pattern, patbuf, MAXPATHLEN, pglob); - oldpathc = pglob->gl_pathc; - bufnext = patbuf; - - /* We don't need to check for buffer overflow any more. */ - while ((c = *qpatnext++) != EOS) { - switch (c) { - case LBRACKET: - c = *qpatnext; - if (c == NOT) - ++qpatnext; - if (*qpatnext == EOS || - g_strchr((Char *) qpatnext+1, RBRACKET) == NULL) { - *bufnext++ = LBRACKET; - if (c == NOT) - --qpatnext; - break; - } - *bufnext++ = M_SET; - if (c == NOT) - *bufnext++ = M_NOT; - c = *qpatnext++; - do { - *bufnext++ = CHAR(c); - if (*qpatnext == RANGE && - (c = qpatnext[1]) != RBRACKET) { - *bufnext++ = M_RNG; - *bufnext++ = CHAR(c); - qpatnext += 2; - } - } while ((c = *qpatnext++) != RBRACKET); - pglob->gl_flags |= GLOB_MAGCHAR; - *bufnext++ = M_END; - break; - case QUESTION: - pglob->gl_flags |= GLOB_MAGCHAR; - *bufnext++ = M_ONE; - break; - case STAR: - pglob->gl_flags |= GLOB_MAGCHAR; - /* collapse adjacent stars to one, - * to avoid exponential behavior - */ - if (bufnext == patbuf || bufnext[-1] != M_ALL) - *bufnext++ = M_ALL; - break; - default: - *bufnext++ = CHAR(c); - break; - } - } - *bufnext = EOS; -#ifdef DEBUG - qprintf("glob0:", patbuf); -#endif - - if ((err = glob1(patbuf, pglob, limit)) != 0) - return(err); - - /* - * If there was no match we are going to append the pattern - * if GLOB_NOCHECK was specified or if GLOB_NOMAGIC was specified - * and the pattern did not contain any magic characters - * GLOB_NOMAGIC is there just for compatibility with csh. - */ - if (pglob->gl_pathc == oldpathc) { - if (((pglob->gl_flags & GLOB_NOCHECK) || - ((pglob->gl_flags & GLOB_NOMAGIC) && - !(pglob->gl_flags & GLOB_MAGCHAR)))) - return(globextend(pattern, pglob, limit)); - else - return(GLOB_NOMATCH); - } - if (!(pglob->gl_flags & GLOB_NOSORT)) - qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc, - pglob->gl_pathc - oldpathc, sizeof(char *), compare); - return(0); -} - -static int -compare(const void *p, const void *q) -{ - return(strcmp(*(char **)p, *(char **)q)); -} - -static int -glob1(Char *pattern, glob_t *pglob, size_t *limit) -{ - Char pathbuf[MAXPATHLEN]; - - /* A null pathname is invalid -- POSIX 1003.1 sect. 2.4. */ - if (*pattern == EOS) - return(0); - return(glob2(pathbuf, pathbuf, pathbuf + MAXPATHLEN - 1, - pattern, pglob, limit)); -} - -/* - * The functions glob2 and glob3 are mutually recursive; there is one level - * of recursion for each segment in the pattern that contains one or more - * meta characters. - */ -static int -glob2(Char *pathbuf, Char *pathend, Char *pathend_last, Char *pattern, - glob_t *pglob, size_t *limit) -{ - struct __stat64 sb; - Char *p, *q; - int anymeta; - - /* - * Loop over pattern segments until end of pattern or until - * segment with meta character found. - */ - for (anymeta = 0;;) { - if (*pattern == EOS) { /* End of pattern? */ - *pathend = EOS; - if (g_lstat(pathbuf, &sb, pglob)) - return(0); - - if (((pglob->gl_flags & GLOB_MARK) && - pathend[-1] != SEP) && (S_ISDIR(sb.st_mode) - || (S_ISLNK(sb.st_mode) && - (g_stat(pathbuf, &sb, pglob) == 0) && - S_ISDIR(sb.st_mode)))) { - if (pathend + 1 > pathend_last) - return (GLOB_ABORTED); - *pathend++ = SEP; - *pathend = EOS; - } - ++pglob->gl_matchc; - return(globextend(pathbuf, pglob, limit)); - } - - /* Find end of next segment, copy tentatively to pathend. */ - q = pathend; - p = pattern; - while (*p != EOS && *p != SEP) { - if (ismeta(*p)) - anymeta = 1; - if (q + 1 > pathend_last) - return (GLOB_ABORTED); - *q++ = *p++; - } - - if (!anymeta) { /* No expansion, do next segment. */ - pathend = q; - pattern = p; - while (*pattern == SEP) { - if (pathend + 1 > pathend_last) - return (GLOB_ABORTED); - *pathend++ = *pattern++; - } - } else /* Need expansion, recurse. */ - return(glob3(pathbuf, pathend, pathend_last, pattern, p, - pglob, limit)); - } - /* NOTREACHED */ -} - -static int -glob3(Char *pathbuf, Char *pathend, Char *pathend_last, - Char *pattern, Char *restpattern, - glob_t *pglob, size_t *limit) -{ - struct dirent *dp; - DIR *dirp; - int err; - char buf[MAXPATHLEN]; - - /* - * The readdirfunc declaration can't be prototyped, because it is - * assigned, below, to two functions which are prototyped in glob.h - * and dirent.h as taking pointers to differently typed opaque - * structures. - */ - struct dirent *(*readdirfunc)(void *); - - if (pathend > pathend_last) - return (GLOB_ABORTED); - *pathend = EOS; - errno = 0; - - if ((dirp = g_opendir(pathbuf, pglob)) == NULL) { - /* TODO: don't call for ENOENT or ENOTDIR? */ - if (pglob->gl_errfunc) { - if (g_Ctoc(pathbuf, buf, sizeof(buf))) - return (GLOB_ABORTED); - if (pglob->gl_errfunc(buf, errno) || - pglob->gl_flags & GLOB_ERR) - return (GLOB_ABORTED); - } - return((pglob->gl_flags & GLOB_ERR) ? GLOB_ABORTED : 0); - } - - err = 0; - - /* Search directory for matching names. */ - if (pglob->gl_flags & GLOB_ALTDIRFUNC) - readdirfunc = pglob->gl_readdir; - else - readdirfunc = (dirent*(*)(void*)) readdir; - while ((dp = (*readdirfunc)(dirp))) { - char *sc; - Char *dc; - wchar_t wc; - size_t clen; - mbstate_t mbs; - - /* Initial DOT must be matched literally. */ - if (dp->d_name[0] == DOT && *pattern != DOT) - continue; - memset(&mbs, 0, sizeof(mbs)); - dc = pathend; - sc = dp->d_name; - while (dc < pathend_last) { - clen = mbrtowc(&wc, sc, MB_LEN_MAX, &mbs); - if (clen == (size_t)-1 || clen == (size_t)-2) { - wc = *sc; - clen = 1; - memset(&mbs, 0, sizeof(mbs)); - } - if ((*dc++ = wc) == EOS) - break; - sc += clen; - } - if (!match(pathend, pattern, restpattern)) { - *pathend = EOS; - continue; - } - err = glob2(pathbuf, --dc, pathend_last, restpattern, - pglob, limit); - if (err) - break; - } - - if (pglob->gl_flags & GLOB_ALTDIRFUNC) - (*pglob->gl_closedir)(dirp); - else - closedir(dirp); - return(err); -} - - -/* - * Extend the gl_pathv member of a glob_t structure to accomodate a new item, - * add the new item, and update gl_pathc. - * - * This assumes the BSD realloc, which only copies the block when its size - * crosses a power-of-two boundary; for v7 realloc, this would cause quadratic - * behavior. - * - * Return 0 if new item added, error code if memory couldn't be allocated. - * - * Invariant of the glob_t structure: - * Either gl_pathc is zero and gl_pathv is NULL; or gl_pathc > 0 and - * gl_pathv points to (gl_offs + gl_pathc + 1) items. - */ -static int -globextend(const Char *path, glob_t *pglob, size_t *limit) -{ - char **pathv; - size_t i, newsize, len; - char *copy; - const Char *p; - - if (*limit && pglob->gl_pathc > *limit) { - errno = 0; - return (GLOB_NOSPACE); - } - - newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs); - pathv = pglob->gl_pathv ? - (char **) realloc((char *)pglob->gl_pathv, newsize) : - (char **) malloc(newsize); - if (pathv == NULL) { - if (pglob->gl_pathv) { - free(pglob->gl_pathv); - pglob->gl_pathv = NULL; - } - return(GLOB_NOSPACE); - } - - if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) { - /* first time around -- clear initial gl_offs items */ - pathv += pglob->gl_offs; - for (i = pglob->gl_offs + 1; --i > 0; ) - *--pathv = NULL; - } - pglob->gl_pathv = pathv; - - for (p = path; *p++;) - continue; - len = MB_CUR_MAX * (size_t)(p - path); /* XXX overallocation */ - if ((copy = (char *) malloc(len)) != NULL) { - if (g_Ctoc(path, copy, len)) { - free(copy); - return (GLOB_NOSPACE); - } - pathv[pglob->gl_offs + pglob->gl_pathc++] = copy; - } - pathv[pglob->gl_offs + pglob->gl_pathc] = NULL; - return(copy == NULL ? GLOB_NOSPACE : 0); -} - -/* - * pattern matching function for filenames. Each occurrence of the * - * pattern causes a recursion level. - */ -static int -match(Char *name, Char *pat, Char *patend) -{ - int ok, negate_range; - Char c, k; - - while (pat < patend) { - c = *pat++; - switch (c & M_MASK) { - case M_ALL: - if (pat == patend) - return(1); - do - if (match(name, pat, patend)) - return(1); - while (*name++ != EOS); - return(0); - case M_ONE: - if (*name++ == EOS) - return(0); - break; - case M_SET: - ok = 0; - if ((k = *name++) == EOS) - return(0); - if ((negate_range = ((*pat & M_MASK) == M_NOT)) != EOS) - ++pat; - if (ignore_case_with_glob) - { - while (((c = *pat++) & M_MASK) != M_END) - if ((*pat & M_MASK) == M_RNG) { - if (tolower(c) <= tolower(k) && tolower(k) <= tolower(pat[1])) - ok = 1; - pat += 2; - } else if (tolower(c) == tolower(k)) - ok = 1; - } - else - { - while (((c = *pat++) & M_MASK) != M_END) - if ((*pat & M_MASK) == M_RNG) { - if (c <= k && k <= pat[1]) - ok = 1; - pat += 2; - } else if (c == k) - ok = 1; - } - if (ok == negate_range) - return(0); - break; - default: - if (ignore_case_with_glob) - { - if (tolower(*name) != tolower(c)) - return(0); - ++name; - } - else - { - if (*name++ != c) - return(0); - } - break; - } - } - return(*name == EOS); -} - -/* Free allocated data belonging to a glob_t structure. */ -void -globfree(glob_t *pglob) -{ - size_t i; - char **pp; - - if (pglob->gl_pathv != NULL) { - pp = pglob->gl_pathv + pglob->gl_offs; - for (i = pglob->gl_pathc; i--; ++pp) - if (*pp) - free(*pp); - free(pglob->gl_pathv); - pglob->gl_pathv = NULL; - } -} - -static DIR * -g_opendir(Char *str, glob_t *pglob) -{ - char buf[MAXPATHLEN]; - - if (!*str) - strcpy(buf, "."); - else { - if (g_Ctoc(str, buf, sizeof(buf))) - return (NULL); - } - - if (pglob->gl_flags & GLOB_ALTDIRFUNC) - return (DIR *) ((*pglob->gl_opendir)((const char *) buf)); - - return(opendir(buf)); -} - -static void -stat32_to_stat64 (struct __stat32 *src, struct __stat64 *dst) -{ - dst->st_dev = src->st_dev; - dst->st_ino = src->st_ino; - dst->st_mode = src->st_mode; - dst->st_nlink = src->st_nlink; - dst->st_uid = src->st_uid; - dst->st_gid = src->st_gid; - dst->st_rdev = src->st_rdev; - dst->st_size = src->st_size; - dst->st_atim = src->st_atim; - dst->st_mtim = src->st_mtim; - dst->st_ctim = src->st_ctim; - dst->st_birthtim = src->st_mtim; - dst->st_blksize = src->st_blksize; - dst->st_blocks = src->st_blocks; -} - -static int -g_lstat(Char *fn, struct __stat64 *sb, glob_t *pglob) -{ - char buf[MAXPATHLEN]; - - if (g_Ctoc(fn, buf, sizeof(buf))) { - errno = ENAMETOOLONG; - return (-1); - } - if (pglob->gl_flags & GLOB_ALTDIRFUNC) { - struct __stat32 lsb; - int ret; - - if (CYGWIN_VERSION_CHECK_FOR_USING_BIG_TYPES) - ret = (*pglob->gl_lstat)(buf, sb); - else if (!(ret = (*pglob->gl_lstat)(buf, - (struct __stat64 *)&lsb))) - stat32_to_stat64 (&lsb, sb); - return ret; - } - return(lstat64(buf, sb)); -} - -static int -g_stat(Char *fn, struct __stat64 *sb, glob_t *pglob) -{ - char buf[MAXPATHLEN]; - - if (g_Ctoc(fn, buf, sizeof(buf))) { - errno = ENAMETOOLONG; - return (-1); - } - if (pglob->gl_flags & GLOB_ALTDIRFUNC) { - struct __stat32 lsb; - int ret; - - if (CYGWIN_VERSION_CHECK_FOR_USING_BIG_TYPES) - ret = (*pglob->gl_stat)(buf, sb); - else if (!(ret = (*pglob->gl_stat)(buf, - (struct __stat64 *)&lsb))) - stat32_to_stat64 (&lsb, sb); - return ret; - } - return(stat64(buf, sb)); -} - -static Char * -g_strchr(Char *str, wchar_t ch) -{ - - do { - if (*str == ch) - return (str); - } while (*str++); - return (NULL); -} - -static int -g_Ctoc(const Char *str, char *buf, size_t len) -{ - mbstate_t mbs; - size_t clen; - - memset(&mbs, 0, sizeof(mbs)); - while (len >= (size_t) MB_CUR_MAX) { - clen = wcrtomb(buf, *str, &mbs); - if (clen == (size_t)-1) - return (1); - if (*str == L'\0') - return (0); - str++; - buf += clen; - len -= clen; - } - return (1); -} - -#ifdef DEBUG -static void -qprintf(const char *str, Char *s) -{ - Char *p; - - (void)printf("%s:\n", str); - for (p = s; *p; p++) - (void)printf("%c", CHAR(*p)); - (void)printf("\n"); - for (p = s; *p; p++) - (void)printf("%c", *p & M_PROTECT ? '"' : ' '); - (void)printf("\n"); - for (p = s; *p; p++) - (void)printf("%c", ismeta(*p) ? '_' : ' '); - (void)printf("\n"); -} -#endif diff --git a/winsup/cygwin/glob_pattern_p.cc b/winsup/cygwin/glob_pattern_p.cc deleted file mode 100644 index e8f42519b..000000000 --- a/winsup/cygwin/glob_pattern_p.cc +++ /dev/null @@ -1,28 +0,0 @@ -/* glob_pattern_p.c - - int glob_pattern_p (__const char *__pattern, int __quote) - - Return nonzero if PATTERN contains any metacharacters. - Metacharacters can be quoted with backslashes if QUOTE is nonzero. - - This function is not part of the interface specified by POSIX.2 - but several programs want to use it. */ - -#include - -extern "C" { - -int glob_pattern_p (const char *pattern, int quote) -{ - const char *quote_chars = "\\?*[]"; - if (!quote) - quote_chars++; - while ((pattern = strpbrk (pattern, quote_chars)) != NULL) - if (*pattern == '\\') - pattern++; - else - return true; - return false; -} - -} /* extern "C" */ diff --git a/winsup/cygwin/globals.cc b/winsup/cygwin/globals.cc deleted file mode 100644 index 5934a72b7..000000000 --- a/winsup/cygwin/globals.cc +++ /dev/null @@ -1,162 +0,0 @@ -/* globals.cc - Define global variables here. - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#define _GLOBALS_H 1 -#include "winsup.h" -#include "cygtls.h" -#include "perprocess.h" -#include "cygprops.h" -#include "thread.h" -#include -#include - -HANDLE NO_COPY hMainThread; -HANDLE NO_COPY hProcToken; -HANDLE NO_COPY hProcImpToken; -HMODULE NO_COPY cygwin_hmodule; -HANDLE hExeced; -int NO_COPY sigExeced; - -/* program exit the program */ - -enum exit_states - { - ES_NOT_EXITING = 0, - ES_PROCESS_LOCKED, - ES_EVENTS_TERMINATE, - ES_THREADTERM, - ES_SIGNAL, - ES_CLOSEALL, - ES_HUP_PGRP, - ES_HUP_SID, - ES_EXEC_EXIT, - ES_TITLE, - ES_TTY_TERMINATE, - ES_FINAL - }; - -exit_states NO_COPY exit_state; - -SYSTEM_INFO system_info; - -/* Set in init.cc. Used to check if Cygwin DLL is dynamically loaded. */ -int NO_COPY dynamically_loaded; - -bool display_title; -bool strip_title_path; -bool allow_glob = true; -bool NO_COPY in_forkee; - -int __argc_safe; -int __argc; -char **__argv; -#ifdef NEWVFORK -vfork_save NO_COPY *main_vfork; -#endif - -_cygtls NO_COPY *_main_tls /* !globals.h */; - -bool NO_COPY cygwin_finished_initializing; - -bool NO_COPY _cygwin_testing; - -char NO_COPY almost_null[1]; - -char *old_title; - -/* Define globally used, but readonly variables using the _RDATA attribute. */ -#define _RDATA __attribute__ ((section(".rdata"))) - -/* Heavily-used const UNICODE_STRINGs are defined here once. The idea is a - speed improvement by not having to initialize a UNICODE_STRING every time - we make a string comparison. The strings are not defined as const, - because the respective NT functions are not taking const arguments - and doing so here results in lots of extra casts for no good reason. - Rather, the strings are placed in the R/O section .rdata, so we get - a SEGV if some code erroneously tries to overwrite these strings. */ -#define _ROU(_s) \ - { Length: sizeof (_s) - sizeof (WCHAR), \ - MaximumLength: sizeof (_s), \ - Buffer: (PWSTR) (_s) } -UNICODE_STRING _RDATA ro_u_empty = _ROU (L""); -UNICODE_STRING _RDATA ro_u_lnk = _ROU (L".lnk"); -UNICODE_STRING _RDATA ro_u_exe = _ROU (L".exe"); -UNICODE_STRING _RDATA ro_u_dll = _ROU (L".dll"); -UNICODE_STRING _RDATA ro_u_com = _ROU (L".com"); -UNICODE_STRING _RDATA ro_u_scr = _ROU (L".scr"); -UNICODE_STRING _RDATA ro_u_sys = _ROU (L".sys"); -UNICODE_STRING _RDATA ro_u_proc = _ROU (L"proc"); -UNICODE_STRING _RDATA ro_u_pmem = _ROU (L"\\device\\physicalmemory"); -UNICODE_STRING _RDATA ro_u_natp = _ROU (L"\\??\\"); -UNICODE_STRING _RDATA ro_u_uncp = _ROU (L"\\??\\UNC\\"); -UNICODE_STRING _RDATA ro_u_mtx = _ROU (L"mtx"); -UNICODE_STRING _RDATA ro_u_csc = _ROU (L"CSC-CACHE"); -UNICODE_STRING _RDATA ro_u_fat = _ROU (L"FAT"); -UNICODE_STRING _RDATA ro_u_mvfs = _ROU (L"MVFS"); -UNICODE_STRING _RDATA ro_u_nfs = _ROU (L"NFS"); -UNICODE_STRING _RDATA ro_u_ntfs = _ROU (L"NTFS"); -UNICODE_STRING _RDATA ro_u_sunwnfs = _ROU (L"SUNWNFS"); -UNICODE_STRING _RDATA ro_u_udf = _ROU (L"UDF"); -UNICODE_STRING _RDATA ro_u_unixfs = _ROU (L"UNIXFS"); -UNICODE_STRING _RDATA ro_u_nwfs = _ROU (L"NWFS"); -UNICODE_STRING _RDATA ro_u_volume = _ROU (L"\\??\\Volume{"); -#undef _ROU - -/* Cygwin properties are meant to be readonly data placed in the DLL, but - which can be changed by external tools to make adjustments to the - behaviour of a DLL based on the binary of the DLL itself. This is - different from $CYGWIN since it only affects that very DLL, not all - DLLs which have access to the $CYGWIN environment variable. */ -cygwin_props_t _RDATA cygwin_props = -{ - CYGWIN_PROPS_MAGIC, - sizeof (cygwin_props_t), - 0 -}; - -#undef _RDATA - -extern "C" -{ - /* This is an exported copy of environ which can be used by DLLs - which use cygwin.dll. */ - char **__cygwin_environ; - char ***main_environ = &__cygwin_environ; - /* __progname used in getopt error message */ - char *__progname; - static MTinterface _mtinterf; - struct per_process __cygwin_user_data = - {/* initial_sp */ 0, /* magic_biscuit */ 0, - /* dll_major */ CYGWIN_VERSION_DLL_MAJOR, - /* dll_major */ CYGWIN_VERSION_DLL_MINOR, - /* impure_ptr_ptr */ NULL, /* envptr */ NULL, - /* malloc */ malloc, /* free */ free, - /* realloc */ realloc, - /* fmode_ptr */ NULL, /* main */ NULL, /* ctors */ NULL, - /* dtors */ NULL, /* data_start */ NULL, /* data_end */ NULL, - /* bss_start */ NULL, /* bss_end */ NULL, - /* calloc */ calloc, - /* premain */ {NULL, NULL, NULL, NULL}, - /* run_ctors_p */ 0, - /* unused */ {0, 0, 0, 0, 0, 0, 0}, - /* cxx_malloc */ &default_cygwin_cxx_malloc, - /* hmodule */ NULL, - /* api_major */ CYGWIN_VERSION_API_MAJOR, - /* api_minor */ CYGWIN_VERSION_API_MINOR, - /* unused2 */ {0, 0, 0, 0, 0, 0}, - /* threadinterface */ &_mtinterf, - /* impure_ptr */ _GLOBAL_REENT, - }; - bool ignore_case_with_glob; - int _check_for_executable = true; -}; - -int NO_COPY __api_fatal_exit_val = 1; diff --git a/winsup/cygwin/gmon.c b/winsup/cygwin/gmon.c deleted file mode 100644 index 981b41042..000000000 --- a/winsup/cygwin/gmon.c +++ /dev/null @@ -1,282 +0,0 @@ -/*- - * Copyright (c) 1983, 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - */ - -#if !defined(lint) && defined(LIBC_SCCS) -static char rcsid[] = "$OpenBSD: gmon.c,v 1.8 1997/07/23 21:11:27 kstailey Exp $"; -#endif - -#include -#include -#include -#include - -#include -#include - -/* XXX needed? */ -//extern char *minbrk __asm ("minbrk"); - -struct gmonparam _gmonparam = { GMON_PROF_OFF }; - -static int s_scale; -/* see profil(2) where this is describe (incorrectly) */ -#define SCALE_1_TO_1 0x10000L - -#define ERR(s) write(2, s, sizeof(s)) - -void moncontrol __P((int)); - -static void * -fake_sbrk(int size) -{ - void *rv = malloc(size); - if (rv) - return rv; - else - return (void *) -1; -} - -void -monstartup(lowpc, highpc) - u_long lowpc; - u_long highpc; -{ - register int o; - char *cp; - struct gmonparam *p = &_gmonparam; - - /* - * round lowpc and highpc to multiples of the density we're using - * so the rest of the scaling (here and in gprof) stays in ints. - */ - p->lowpc = ROUNDDOWN(lowpc, HISTFRACTION * sizeof(HISTCOUNTER)); - p->highpc = ROUNDUP(highpc, HISTFRACTION * sizeof(HISTCOUNTER)); - p->textsize = p->highpc - p->lowpc; - p->kcountsize = p->textsize / HISTFRACTION; - p->hashfraction = HASHFRACTION; - p->fromssize = p->textsize / p->hashfraction; - p->tolimit = p->textsize * ARCDENSITY / 100; - if (p->tolimit < MINARCS) - p->tolimit = MINARCS; - else if (p->tolimit > MAXARCS) - p->tolimit = MAXARCS; - p->tossize = p->tolimit * sizeof(struct tostruct); - - cp = fake_sbrk(p->kcountsize + p->fromssize + p->tossize); - if (cp == (char *)-1) { - ERR("monstartup: out of memory\n"); - return; - } -#ifdef notdef - bzero(cp, p->kcountsize + p->fromssize + p->tossize); -#endif - p->tos = (struct tostruct *)cp; - cp += p->tossize; - p->kcount = (u_short *)cp; - cp += p->kcountsize; - p->froms = (u_short *)cp; - - /* XXX minbrk needed? */ - //minbrk = fake_sbrk(0); - p->tos[0].link = 0; - - o = p->highpc - p->lowpc; - if (p->kcountsize < o) { -#ifndef notdef - s_scale = ((float)p->kcountsize / o ) * SCALE_1_TO_1; -#else /* avoid floating point */ - int quot = o / p->kcountsize; - - if (quot >= 0x10000) - s_scale = 1; - else if (quot >= 0x100) - s_scale = 0x10000 / quot; - else if (o >= 0x800000) - s_scale = 0x1000000 / (o / (p->kcountsize >> 8)); - else - s_scale = 0x1000000 / ((o << 8) / p->kcountsize); -#endif - } else - s_scale = SCALE_1_TO_1; - - moncontrol(1); -} - -void -_mcleanup() -{ - int fd; - int hz; - int fromindex; - int endfrom; - u_long frompc; - int toindex; - struct rawarc rawarc; - struct gmonparam *p = &_gmonparam; - struct gmonhdr gmonhdr, *hdr; - char *proffile; -#ifdef DEBUG - int log, len; - char dbuf[200]; -#endif - - if (p->state == GMON_PROF_ERROR) - ERR("_mcleanup: tos overflow\n"); - - hz = PROF_HZ; - moncontrol(0); - -#ifdef nope - if ((profdir = getenv("PROFDIR")) != NULL) { - extern char *__progname; - char *s, *t, *limit; - pid_t pid; - long divisor; - - /* If PROFDIR contains a null value, no profiling - output is produced */ - if (*profdir == '\0') { - return; - } - - limit = buf + sizeof buf - 1 - 10 - 1 - - strlen(__progname) - 1; - t = buf; - s = profdir; - while((*t = *s) != '\0' && t < limit) { - t++; - s++; - } - *t++ = '/'; - - /* - * Copy and convert pid from a pid_t to a string. For - * best performance, divisor should be initialized to - * the largest power of 10 less than PID_MAX. - */ - pid = getpid(); - divisor=10000; - while (divisor > pid) divisor /= 10; /* skip leading zeros */ - do { - *t++ = (pid/divisor) + '0'; - pid %= divisor; - } while (divisor /= 10); - *t++ = '.'; - - s = __progname; - while ((*t++ = *s++) != '\0') - ; - - proffile = buf; - } else { - proffile = "gmon.out"; - } -#else - { - char gmon_out[] = "gmon.out"; - proffile = gmon_out; - } -#endif - - fd = open(proffile , O_CREAT|O_TRUNC|O_WRONLY|O_BINARY, 0666); - if (fd < 0) { - perror( proffile ); - return; - } -#ifdef DEBUG - log = open("gmon.log", O_CREAT|O_TRUNC|O_WRONLY, 0664); - if (log < 0) { - perror("mcount: gmon.log"); - return; - } - len = sprintf(dbuf, "[mcleanup1] kcount 0x%x ssiz %d\n", - p->kcount, p->kcountsize); - write(log, dbuf, len); -#endif - hdr = (struct gmonhdr *)&gmonhdr; - hdr->lpc = p->lowpc; - hdr->hpc = p->highpc; - hdr->ncnt = p->kcountsize + sizeof(gmonhdr); - hdr->version = GMONVERSION; - hdr->profrate = hz; - write(fd, (char *)hdr, sizeof *hdr); - write(fd, p->kcount, p->kcountsize); - endfrom = p->fromssize / sizeof(*p->froms); - for (fromindex = 0; fromindex < endfrom; fromindex++) { - if (p->froms[fromindex] == 0) - continue; - - frompc = p->lowpc; - frompc += fromindex * p->hashfraction * sizeof(*p->froms); - for (toindex = p->froms[fromindex]; toindex != 0; - toindex = p->tos[toindex].link) { -#ifdef DEBUG - len = sprintf(dbuf, - "[mcleanup2] frompc 0x%x selfpc 0x%x count %d\n" , - frompc, p->tos[toindex].selfpc, - p->tos[toindex].count); - write(log, dbuf, len); -#endif - rawarc.raw_frompc = frompc; - rawarc.raw_selfpc = p->tos[toindex].selfpc; - rawarc.raw_count = p->tos[toindex].count; - write(fd, &rawarc, sizeof rawarc); - } - } - close(fd); -} - -/* - * Control profiling - * profiling is what mcount checks to see if - * all the data structures are ready. - */ -void -moncontrol(mode) - int mode; -{ - struct gmonparam *p = &_gmonparam; - - if (mode) { - /* start */ - profil((char *)p->kcount, p->kcountsize, p->lowpc, - s_scale); - p->state = GMON_PROF_ON; - } else { - /* stop */ - profil((char *)0, 0, 0, 0); - p->state = GMON_PROF_OFF; - } -} - - diff --git a/winsup/cygwin/gmon.h b/winsup/cygwin/gmon.h deleted file mode 100644 index be016791e..000000000 --- a/winsup/cygwin/gmon.h +++ /dev/null @@ -1,166 +0,0 @@ -/* $OpenBSD: gmon.h,v 1.3 1996/04/21 22:31:46 deraadt Exp $ */ -/* $NetBSD: gmon.h,v 1.5 1996/04/09 20:55:30 cgd Exp $ */ - -/*- - * Copyright (c) 1982, 1986, 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - * - * @(#)gmon.h 8.2 (Berkeley) 1/4/94 - */ - -#ifndef _SYS_GMON_H_ -#define _SYS_GMON_H_ - -#ifndef __P -#define __P(x) x -#endif - -#include - -/* - * Structure prepended to gmon.out profiling data file. - */ -struct gmonhdr { - u_long lpc; /* base pc address of sample buffer */ - u_long hpc; /* max pc address of sampled buffer */ - int ncnt; /* size of sample buffer (plus this header) */ - int version; /* version number */ - int profrate; /* profiling clock rate */ - int spare[3]; /* reserved */ -}; -#define GMONVERSION 0x00051879 - -/* - * histogram counters are unsigned shorts (according to the kernel). - */ -#define HISTCOUNTER unsigned short - -/* - * fraction of text space to allocate for histogram counters here, 1/2 - */ -#define HISTFRACTION 2 - -/* - * Fraction of text space to allocate for from hash buckets. - * The value of HASHFRACTION is based on the minimum number of bytes - * of separation between two subroutine call points in the object code. - * Given MIN_SUBR_SEPARATION bytes of separation the value of - * HASHFRACTION is calculated as: - * - * HASHFRACTION = MIN_SUBR_SEPARATION / (2 * sizeof(short) - 1); - * - * For example, on the VAX, the shortest two call sequence is: - * - * calls $0,(r0) - * calls $0,(r0) - * - * which is separated by only three bytes, thus HASHFRACTION is - * calculated as: - * - * HASHFRACTION = 3 / (2 * 2 - 1) = 1 - * - * Note that the division above rounds down, thus if MIN_SUBR_FRACTION - * is less than three, this algorithm will not work! - * - * In practice, however, call instructions are rarely at a minimal - * distance. Hence, we will define HASHFRACTION to be 2 across all - * architectures. This saves a reasonable amount of space for - * profiling data structures without (in practice) sacrificing - * any granularity. - */ -#define HASHFRACTION 2 - -/* - * percent of text space to allocate for tostructs with a minimum. - */ -#define ARCDENSITY 2 -#define MINARCS 50 -#define MAXARCS ((1 << (8 * sizeof(HISTCOUNTER))) - 2) - -struct tostruct { - u_long selfpc; - long count; - u_short link; - u_short pad; -}; - -/* - * a raw arc, with pointers to the calling site and - * the called site and a count. - */ -struct rawarc { - u_long raw_frompc; - u_long raw_selfpc; - long raw_count; -}; - -/* - * general rounding functions. - */ -#define ROUNDDOWN(x,y) (((x)/(y))*(y)) -#define ROUNDUP(x,y) ((((x)+(y)-1)/(y))*(y)) - -/* - * The profiling data structures are housed in this structure. - */ -struct gmonparam { - int state; - u_short *kcount; - u_long kcountsize; - u_short *froms; - u_long fromssize; - struct tostruct *tos; - u_long tossize; - long tolimit; - u_long lowpc; - u_long highpc; - u_long textsize; - u_long hashfraction; -}; -extern struct gmonparam _gmonparam; - -/* - * Possible states of profiling. - */ -#define GMON_PROF_ON 0 -#define GMON_PROF_BUSY 1 -#define GMON_PROF_ERROR 2 -#define GMON_PROF_OFF 3 - -/* - * Sysctl definitions for extracting profiling information from the kernel. - */ -#define GPROF_STATE 0 /* int: profiling enabling variable */ -#define GPROF_COUNT 1 /* struct: profile tick count buffer */ -#define GPROF_FROMS 2 /* struct: from location hash bucket */ -#define GPROF_TOS 3 /* struct: destination/count structure */ -#define GPROF_GMONPARAM 4 /* struct: profiling parameters (see above) */ -#endif /* !_SYS_GMONH_ */ diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc deleted file mode 100644 index 970e62627..000000000 --- a/winsup/cygwin/grp.cc +++ /dev/null @@ -1,499 +0,0 @@ -/* grp.cc - - Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009 Red Hat, Inc. - - Original stubs by Jason Molenda of Cygnus Support, crash@cygnus.com - First implementation by Gunther Ebert, gunther.ebert@ixos-leipzig.de - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include "cygerrno.h" -#include "pinfo.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "pwdgrp.h" - -static __group32 *group_buf; -static pwdgrp gr (group_buf); -static char * NO_COPY null_ptr; - -bool -pwdgrp::parse_group () -{ -# define grp (*group_buf)[curr_lines] - grp.gr_name = next_str (':'); - if (!*grp.gr_name) - return false; - - grp.gr_passwd = next_str (':'); - - if (!next_num (grp.gr_gid)) - return false; - - int n; - char *dp = raw_ptr (); - for (n = 0; *next_str (','); n++) - continue; - - grp.gr_mem = &null_ptr; - if (n) - { - char **namearray = (char **) calloc (n + 1, sizeof (char *)); - if (namearray) - { - for (int i = 0; i < n; i++, dp = strchr (dp, '\0') + 1) - namearray[i] = dp; - grp.gr_mem = namearray; - } - } - - return true; -# undef grp -} - -/* Cygwin internal */ -/* Read in /etc/group and save contents in the group cache */ -/* This sets group_in_memory_p to 1 so functions in this file can - tell that /etc/group has been read in */ -void -pwdgrp::read_group () -{ - for (int i = 0; i < gr.curr_lines; i++) - if ((*group_buf)[i].gr_mem != &null_ptr) - free ((*group_buf)[i].gr_mem); - - load (L"\\etc\\group"); - - /* Complete /etc/group in memory if needed */ - if (!internal_getgrgid (myself->gid)) - { - static char linebuf [200]; - char group_name [UNLEN + 1] = "mkgroup"; - char strbuf[128] = ""; - struct __group32 *gr; - - cygheap->user.groups.pgsid.string (strbuf); - if ((gr = internal_getgrsid (cygheap->user.groups.pgsid))) - snprintf (group_name, sizeof (group_name), - "passwd/group_GID_clash(%lu/%lu)", myself->gid, gr->gr_gid); - if (myself->uid == UNKNOWN_UID) - strcpy (group_name, "mkpasswd"); /* Feedback... */ - snprintf (linebuf, sizeof (linebuf), "%s:%s:%lu:%s", - group_name, strbuf, myself->gid, cygheap->user.name ()); - debug_printf ("Completing /etc/group: %s", linebuf); - add_line (linebuf); - } - static char NO_COPY pretty_ls[] = "????????::-1:"; - add_line (pretty_ls); -} - -muto NO_COPY pwdgrp::pglock; - -pwdgrp::pwdgrp (passwd *&pbuf) : - pwdgrp_buf_elem_size (sizeof (*pbuf)), passwd_buf (&pbuf) -{ - read = &pwdgrp::read_passwd; - parse = &pwdgrp::parse_passwd; - pglock.init ("pglock"); -} - -pwdgrp::pwdgrp (__group32 *&gbuf) : - pwdgrp_buf_elem_size (sizeof (*gbuf)), group_buf (&gbuf) -{ - read = &pwdgrp::read_group; - parse = &pwdgrp::parse_group; - pglock.init ("pglock"); -} - -struct __group32 * -internal_getgrsid (cygpsid &sid) -{ - char sid_string[128]; - - gr.refresh (false); - - if (sid.string (sid_string)) - for (int i = 0; i < gr.curr_lines; i++) - if (!strcmp (sid_string, group_buf[i].gr_passwd)) - return group_buf + i; - return NULL; -} - -struct __group32 * -internal_getgrgid (__gid32_t gid, bool check) -{ - gr.refresh (check); - - for (int i = 0; i < gr.curr_lines; i++) - if (group_buf[i].gr_gid == gid) - return group_buf + i; - return NULL; -} - -struct __group32 * -internal_getgrnam (const char *name, bool check) -{ - gr.refresh (check); - - for (int i = 0; i < gr.curr_lines; i++) - if (strcasematch (group_buf[i].gr_name, name)) - return group_buf + i; - - /* Didn't find requested group */ - return NULL; -} - -static struct __group16 * -grp32togrp16 (struct __group16 *gp16, struct __group32 *gp32) -{ - if (!gp16 || !gp32) - return NULL; - - /* Copying the pointers is actually unnecessary. Just having the correct - return type is important. */ - gp16->gr_name = gp32->gr_name; - gp16->gr_passwd = gp32->gr_passwd; - gp16->gr_gid = (__gid16_t) gp32->gr_gid; /* Not loss-free */ - gp16->gr_mem = gp32->gr_mem; - - return gp16; -} - -extern "C" int -getgrgid_r (__gid32_t gid, struct __group32 *grp, char *buffer, size_t bufsize, - struct __group32 **result) -{ - *result = NULL; - - if (!grp || !buffer) - return ERANGE; - - struct __group32 *tempgr = internal_getgrgid (gid, true); - pthread_testcancel (); - if (!tempgr) - return 0; - - /* check needed buffer size. */ - int i; - size_t needsize = strlen (tempgr->gr_name) + strlen (tempgr->gr_passwd) - + 2 + sizeof (char *); - for (i = 0; tempgr->gr_mem[i]; ++i) - needsize += strlen (tempgr->gr_mem[i]) + 1 + sizeof (char *); - if (needsize > bufsize) - return ERANGE; - - /* make a copy of tempgr */ - *result = grp; - grp->gr_gid = tempgr->gr_gid; - buffer = stpcpy (grp->gr_name = buffer, tempgr->gr_name); - buffer = stpcpy (grp->gr_passwd = buffer + 1, tempgr->gr_passwd); - grp->gr_mem = (char **) (buffer + 1); - buffer = (char *) grp->gr_mem + (i + 1) * sizeof (char *); - for (i = 0; tempgr->gr_mem[i]; ++i) - buffer = stpcpy (grp->gr_mem[i] = buffer, tempgr->gr_mem[i]) + 1; - grp->gr_mem[i] = NULL; - return 0; -} - -extern "C" struct __group32 * -getgrgid32 (__gid32_t gid) -{ - return internal_getgrgid (gid, true); -} - -extern "C" struct __group16 * -getgrgid (__gid16_t gid) -{ - static struct __group16 g16; /* FIXME: thread-safe? */ - - return grp32togrp16 (&g16, getgrgid32 (gid16togid32 (gid))); -} - -extern "C" int -getgrnam_r (const char *nam, struct __group32 *grp, char *buffer, - size_t bufsize, struct __group32 **result) -{ - *result = NULL; - - if (!grp || !buffer) - return ERANGE; - - struct __group32 *tempgr = internal_getgrnam (nam, true); - pthread_testcancel (); - if (!tempgr) - return 0; - - /* check needed buffer size. */ - int i; - size_t needsize = strlen (tempgr->gr_name) + strlen (tempgr->gr_passwd) - + 2 + sizeof (char *); - for (i = 0; tempgr->gr_mem[i]; ++i) - needsize += strlen (tempgr->gr_mem[i]) + 1 + sizeof (char *); - if (needsize > bufsize) - return ERANGE; - - /* make a copy of tempgr */ - *result = grp; - grp->gr_gid = tempgr->gr_gid; - buffer = stpcpy (grp->gr_name = buffer, tempgr->gr_name); - buffer = stpcpy (grp->gr_passwd = buffer + 1, tempgr->gr_passwd); - grp->gr_mem = (char **) (buffer + 1); - buffer = (char *) grp->gr_mem + (i + 1) * sizeof (char *); - for (i = 0; tempgr->gr_mem[i]; ++i) - buffer = stpcpy (grp->gr_mem[i] = buffer, tempgr->gr_mem[i]) + 1; - grp->gr_mem[i] = NULL; - return 0; -} - -extern "C" struct __group32 * -getgrnam32 (const char *name) -{ - return internal_getgrnam (name, true); -} - -extern "C" struct __group16 * -getgrnam (const char *name) -{ - static struct __group16 g16; /* FIXME: thread-safe? */ - - return grp32togrp16 (&g16, getgrnam32 (name)); -} - -extern "C" void -endgrent () -{ - _my_tls.locals.grp_pos = 0; -} - -extern "C" struct __group32 * -getgrent32 () -{ - if (_my_tls.locals.grp_pos == 0) - gr.refresh (true); - if (_my_tls.locals.grp_pos < gr.curr_lines) - return group_buf + _my_tls.locals.grp_pos++; - - return NULL; -} - -extern "C" struct __group16 * -getgrent () -{ - static struct __group16 g16; /* FIXME: thread-safe? */ - - return grp32togrp16 (&g16, getgrent32 ()); -} - -extern "C" void -setgrent () -{ - _my_tls.locals.grp_pos = 0; -} - -/* Internal function. ONLY USE THIS INTERNALLY, NEVER `getgrent'!!! */ -struct __group32 * -internal_getgrent (int pos) -{ - gr.refresh (false); - - if (pos < gr.curr_lines) - return group_buf + pos; - return NULL; -} - -int -internal_getgroups (int gidsetsize, __gid32_t *grouplist, cygpsid * srchsid) -{ - HANDLE hToken = NULL; - DWORD size; - int cnt = 0; - struct __group32 *gr; - - if (!srchsid && cygheap->user.groups.issetgroups ()) - { - cygsid sid; - for (int gidx = 0; (gr = internal_getgrent (gidx)); ++gidx) - if (sid.getfromgr (gr)) - for (int pg = 0; pg < cygheap->user.groups.sgsids.count (); ++pg) - if (sid == cygheap->user.groups.sgsids.sids[pg] - && sid != well_known_world_sid) - { - if (cnt < gidsetsize) - grouplist[cnt] = gr->gr_gid; - ++cnt; - if (gidsetsize && cnt > gidsetsize) - goto error; - break; - } - return cnt; - } - - - /* If impersonated, use impersonation token. */ - if (cygheap->user.issetuid ()) - hToken = cygheap->user.primary_token (); - else - hToken = hProcToken; - - if (GetTokenInformation (hToken, TokenGroups, NULL, 0, &size) - || GetLastError () == ERROR_INSUFFICIENT_BUFFER) - { - PTOKEN_GROUPS groups = (PTOKEN_GROUPS) alloca (size); - - if (GetTokenInformation (hToken, TokenGroups, groups, size, &size)) - { - cygsid sid; - - if (srchsid) - { - for (DWORD pg = 0; pg < groups->GroupCount; ++pg) - if ((cnt = (*srchsid == groups->Groups[pg].Sid))) - break; - } - else - for (int gidx = 0; (gr = internal_getgrent (gidx)); ++gidx) - if (sid.getfromgr (gr)) - for (DWORD pg = 0; pg < groups->GroupCount; ++pg) - if (sid == groups->Groups[pg].Sid - && (groups->Groups[pg].Attributes - & (SE_GROUP_ENABLED | SE_GROUP_INTEGRITY_ENABLED)) - && sid != well_known_world_sid) - { - if (cnt < gidsetsize) - grouplist[cnt] = gr->gr_gid; - ++cnt; - if (gidsetsize && cnt > gidsetsize) - goto error; - break; - } - } - } - else - debug_printf ("%d = GetTokenInformation(NULL) %E", size); - return cnt; - -error: - set_errno (EINVAL); - return -1; -} - -extern "C" int -getgroups32 (int gidsetsize, __gid32_t *grouplist) -{ - return internal_getgroups (gidsetsize, grouplist); -} - -extern "C" int -getgroups (int gidsetsize, __gid16_t *grouplist) -{ - __gid32_t *grouplist32 = NULL; - - if (gidsetsize < 0) - { - set_errno (EINVAL); - return -1; - } - if (gidsetsize > 0 && grouplist) - grouplist32 = (__gid32_t *) alloca (gidsetsize * sizeof (__gid32_t)); - - int ret = internal_getgroups (gidsetsize, grouplist32); - - if (gidsetsize > 0 && grouplist) - for (int i = 0; i < ret; ++ i) - grouplist[i] = grouplist32[i]; - - return ret; -} - -extern "C" int -initgroups32 (const char *name, __gid32_t gid) -{ - int ret = -1; - - cygheap->user.deimpersonate (); - struct passwd *pw = internal_getpwnam (name); - struct __group32 *gr = internal_getgrgid (gid); - cygsid usersid, grpsid; - if (!usersid.getfrompw (pw) || !grpsid.getfromgr (gr)) - set_errno (EINVAL); - else - { - cygsidlist tmp_gsids (cygsidlist_auto, 12); - if (get_server_groups (tmp_gsids, usersid, pw)) - { - tmp_gsids += grpsid; - cygsidlist new_gsids (cygsidlist_alloc, tmp_gsids.count ()); - for (int i = 0; i < tmp_gsids.count (); i++) - new_gsids.sids[i] = tmp_gsids.sids[i]; - new_gsids.count (tmp_gsids.count ()); - cygheap->user.groups.update_supp (new_gsids); - ret = 0; - } - } - cygheap->user.reimpersonate (); - syscall_printf ( "%d = initgroups (%s, %u)", ret, name, gid); - return ret; -} - -extern "C" int -initgroups (const char *name, __gid16_t gid) -{ - return initgroups32 (name, gid16togid32(gid)); -} - -/* setgroups32: standards? */ -extern "C" int -setgroups32 (int ngroups, const __gid32_t *grouplist) -{ - syscall_printf ("setgroups32 (%d)", ngroups); - if (ngroups < 0 || (ngroups > 0 && !grouplist)) - { - set_errno (EINVAL); - return -1; - } - - cygsidlist gsids (cygsidlist_alloc, ngroups); - struct __group32 *gr; - - if (ngroups && !gsids.sids) - return -1; - - for (int gidx = 0; gidx < ngroups; ++gidx) - { - if ((gr = internal_getgrgid (grouplist[gidx])) - && gsids.addfromgr (gr)) - continue; - debug_printf ("No sid found for gid %d", grouplist[gidx]); - gsids.free_sids (); - set_errno (EINVAL); - return -1; - } - cygheap->user.groups.update_supp (gsids); - return 0; -} - -extern "C" int -setgroups (int ngroups, const __gid16_t *grouplist) -{ - __gid32_t *grouplist32 = NULL; - - if (ngroups > 0 && grouplist) - { - grouplist32 = (__gid32_t *) alloca (ngroups * sizeof (__gid32_t)); - if (grouplist32 == NULL) - return -1; - for (int i = 0; i < ngroups; i++) - grouplist32[i] = grouplist[i]; - } - return setgroups32 (ngroups, grouplist32); -} diff --git a/winsup/cygwin/heap.cc b/winsup/cygwin/heap.cc deleted file mode 100644 index be4946d25..000000000 --- a/winsup/cygwin/heap.cc +++ /dev/null @@ -1,175 +0,0 @@ -/* heap.cc: Cygwin heap manager. - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "cygerrno.h" -#include "shared_info.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "child_info.h" - -#define assert(x) - -static unsigned page_const; - -#define MINHEAP_SIZE (4 * 1024 * 1024) - -/* Initialize the heap at process start up. */ -void -heap_init () -{ - const DWORD alloctype = MEM_RESERVE; - /* If we're the forkee, we must allocate the heap at exactly the same place - as our parent. If not, we don't care where it ends up. */ - - page_const = system_info.dwPageSize; - if (!cygheap->user_heap.base) - { - cygheap->user_heap.chunk = cygwin_shared->heap_chunk_size (); - /* For some obscure reason Vista and 2003 sometimes reserve space after - calls to CreateProcess overlapping the spot where the heap has been - allocated. This apparently spoils fork. The behaviour looks quite - arbitrary. Experiments on Vista show a memory size of 0x37e000 or - 0x1fd000 overlapping the usual heap by at most 0x1ed000. So what - we do here is to allocate the heap with an extra slop of (by default) - 0x400000 and set the appropriate pointers to the start of the heap - area + slop. A forking child then creates its heap at the new start - address and without the slop factor. Since this is not entirely - foolproof we add a registry setting "heap_slop_in_mb" so the slop - factor can be influenced by the user if the need arises. */ - cygheap->user_heap.slop = cygwin_shared->heap_slop_size (); - while (cygheap->user_heap.chunk >= MINHEAP_SIZE) - { - /* Initialize page mask and default heap size. Preallocate a heap - * to assure contiguous memory. */ - cygheap->user_heap.base = - VirtualAlloc (NULL, cygheap->user_heap.chunk - + cygheap->user_heap.slop, - alloctype, PAGE_NOACCESS); - if (cygheap->user_heap.base) - break; - cygheap->user_heap.chunk -= 1 * 1024 * 1024; - } - if (cygheap->user_heap.base == NULL) - api_fatal ("unable to allocate heap, heap_chunk_size %p, slop %p, %E", - cygheap->user_heap.chunk, cygheap->user_heap.slop); - cygheap->user_heap.base = (void *) ((char *) cygheap->user_heap.base - + cygheap->user_heap.slop); - cygheap->user_heap.ptr = cygheap->user_heap.top = cygheap->user_heap.base; - cygheap->user_heap.max = (char *) cygheap->user_heap.base - + cygheap->user_heap.chunk; - } - else - { - DWORD chunk = cygheap->user_heap.chunk; /* allocation chunk */ - /* total size commited in parent */ - DWORD allocsize = (char *) cygheap->user_heap.top - - (char *) cygheap->user_heap.base; - - /* Loop until we've managed to reserve an adequate amount of memory. */ - char *p; - DWORD reserve_size = chunk * ((allocsize + (chunk - 1)) / chunk); - while (1) - { - p = (char *) VirtualAlloc (cygheap->user_heap.base, reserve_size, - alloctype, PAGE_READWRITE); - if (p) - break; - if ((reserve_size -= page_const) < allocsize) - break; - } - if (!p && in_forkee && !fork_info->handle_failure (GetLastError ())) - api_fatal ("couldn't allocate heap, %E, base %p, top %p, " - "reserve_size %d, allocsize %d, page_const %d", - cygheap->user_heap.base, cygheap->user_heap.top, - reserve_size, allocsize, page_const); - if (p != cygheap->user_heap.base) - api_fatal ("heap allocated at wrong address %p (mapped) != %p (expected)", p, cygheap->user_heap.base); - if (allocsize && !VirtualAlloc (cygheap->user_heap.base, allocsize, MEM_COMMIT, PAGE_READWRITE)) - api_fatal ("MEM_COMMIT failed, %E"); - } - - debug_printf ("heap base %p, heap top %p", cygheap->user_heap.base, - cygheap->user_heap.top); - page_const--; - // malloc_init (); -} - -#define pround(n) (((size_t)(n) + page_const) & ~page_const) - -/* FIXME: This function no longer handles "split heaps". */ - -extern "C" void * -sbrk (int n) -{ - char *newtop, *newbrk; - unsigned commitbytes, newbrksize; - - if (n == 0) - return cygheap->user_heap.ptr; /* Just wanted to find current cygheap->user_heap.ptr address */ - - newbrk = (char *) cygheap->user_heap.ptr + n; /* Where new cygheap->user_heap.ptr will be */ - newtop = (char *) pround (newbrk); /* Actual top of allocated memory - - on page boundary */ - - if (newtop == cygheap->user_heap.top) - goto good; - - if (n < 0) - { /* Freeing memory */ - assert (newtop < cygheap->user_heap.top); - n = (char *) cygheap->user_heap.top - newtop; - if (VirtualFree (newtop, n, MEM_DECOMMIT)) /* Give it back to OS */ - goto good; /* Didn't take */ - else - goto err; - } - - assert (newtop > cygheap->user_heap.top); - - /* Find the number of bytes to commit, rounded up to the nearest page. */ - commitbytes = pround (newtop - (char *) cygheap->user_heap.top); - - /* Need to grab more pages from the OS. If this fails it may be because - we have used up previously reserved memory. Or, we're just plumb out - of memory. Only attempt to commit memory that we know we've previously - reserved. */ - if (newtop <= cygheap->user_heap.max) - { - if (VirtualAlloc (cygheap->user_heap.top, commitbytes, MEM_COMMIT, PAGE_READWRITE) != NULL) - goto good; - } - - /* Couldn't allocate memory. Maybe we can reserve some more. - Reserve either the maximum of the standard cygwin_shared->heap_chunk_size () - or the requested amount. Then attempt to actually allocate it. */ - if ((newbrksize = cygheap->user_heap.chunk) < commitbytes) - newbrksize = commitbytes; - - if ((VirtualAlloc (cygheap->user_heap.top, newbrksize, MEM_RESERVE, PAGE_NOACCESS) - || VirtualAlloc (cygheap->user_heap.top, newbrksize = commitbytes, MEM_RESERVE, PAGE_NOACCESS)) - && VirtualAlloc (cygheap->user_heap.top, commitbytes, MEM_COMMIT, PAGE_READWRITE) != NULL) - { - cygheap->user_heap.max = (char *) cygheap->user_heap.max + pround (newbrksize); - goto good; - } - -err: - set_errno (ENOMEM); - return (void *) -1; - -good: - void *oldbrk = cygheap->user_heap.ptr; - cygheap->user_heap.ptr = newbrk; - cygheap->user_heap.top = newtop; - return oldbrk; -} diff --git a/winsup/cygwin/heap.h b/winsup/cygwin/heap.h deleted file mode 100644 index b497dd3a4..000000000 --- a/winsup/cygwin/heap.h +++ /dev/null @@ -1,20 +0,0 @@ -/* heap.h: Cygwin heap manager definitions. - - Copyright 2000, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "perprocess.h" - -/* Heap management. */ -void heap_init (); -void malloc_init (); - -#define inheap(s) \ - (cygheap->user_heap.ptr && s \ - && ((char *) (s) >= (char *) cygheap->user_heap.base) \ - && ((char *) (s) <= (char *) cygheap->user_heap.top)) diff --git a/winsup/cygwin/hires.h b/winsup/cygwin/hires.h deleted file mode 100644 index e91df0690..000000000 --- a/winsup/cygwin/hires.h +++ /dev/null @@ -1,54 +0,0 @@ -/* hires.h: Definitions for hires clock calculations - - Copyright 2002, 2003, 2004, 2005, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef __HIRES_H__ -#define __HIRES_H__ - -#include - -/* Largest delay in ms for sleep and alarm calls. - Allow actual delay to exceed requested delay by 10 s. - Express as multiple of 1000 (i.e. seconds) + max resolution - The tv_sec argument in timeval structures cannot exceed - HIRES_DELAY_MAX / 1000 - 1, so that adding fractional part - and rounding won't exceed HIRES_DELAY_MAX */ -#define HIRES_DELAY_MAX ((((UINT_MAX - 10000) / 1000) * 1000) + 10) - -class hires_base -{ - protected: - int inited; -}; - -class hires_us : hires_base -{ - LARGE_INTEGER primed_ft; - LARGE_INTEGER primed_pc; - double freq; - void prime (); - public: - LONGLONG usecs (bool justdelta); -}; - -class hires_ms : hires_base -{ - LONGLONG initime_ns; - void prime (); - public: - LONGLONG nsecs (); - LONGLONG usecs () {return nsecs () / 10LL;} - LONGLONG msecs () {return nsecs () / 10000LL;} - UINT dmsecs () { return timeGetTime (); } - UINT resolution (); - LONGLONG uptime () {return (nsecs () - initime_ns) / 10000LL;} -}; - -extern hires_ms gtod; -#endif /*__HIRES_H__*/ diff --git a/winsup/cygwin/hookapi.cc b/winsup/cygwin/hookapi.cc deleted file mode 100644 index 7a13ee047..000000000 --- a/winsup/cygwin/hookapi.cc +++ /dev/null @@ -1,304 +0,0 @@ -/* hookapi.cc - - Copyright 2005, 2006, 2007, 2008 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include "ntdll.h" -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" - -#define rva(coerce, base, addr) (coerce) ((char *) (base) + (addr)) -#define rvacyg(coerce, addr) rva (coerce, cygwin_hmodule, addr) - -struct function_hook -{ - const char *name; // Function name, e.g. "DirectDrawCreateEx". - const void *hookfn; // Address of your function. - void *origfn; // Stored by HookAPICalls, the address of the original function. -}; - -/* Given an HMODULE, returns a pointer to the PE header */ -static PIMAGE_NT_HEADERS -PEHeaderFromHModule (HMODULE hModule) -{ - PIMAGE_NT_HEADERS pNTHeader; - - if (PIMAGE_DOS_HEADER(hModule) ->e_magic != IMAGE_DOS_SIGNATURE) - pNTHeader = NULL; - else - { - pNTHeader = PIMAGE_NT_HEADERS (PBYTE (hModule) - + PIMAGE_DOS_HEADER (hModule) ->e_lfanew); - if (pNTHeader->Signature != IMAGE_NT_SIGNATURE) - pNTHeader = NULL; - } - - return pNTHeader; -} - -static long -rvadelta (PIMAGE_NT_HEADERS pnt, DWORD import_rva) -{ - PIMAGE_SECTION_HEADER section = (PIMAGE_SECTION_HEADER) (pnt + 1); - for (int i = 0; i < pnt->FileHeader.NumberOfSections; i++) - if (section[i].VirtualAddress <= import_rva - && (section[i].VirtualAddress + section[i].Misc.VirtualSize) > import_rva) - // if (ascii_strncasematch ((char *) section[i].Name, ".idata", IMAGE_SIZEOF_SHORT_NAME)) - return section[i].VirtualAddress - section[i].PointerToRawData; - return -1; -} - -static void * -putmem (PIMAGE_THUNK_DATA pi, const void *hookfn) -{ - DWORD ofl; - if (!VirtualProtect (pi, sizeof (PVOID), PAGE_READWRITE, &ofl) ) - return NULL; - - void *origfn = (void *) pi->u1.Function; - pi->u1.Function = (DWORD) hookfn; - - VirtualProtect (pi, sizeof (PVOID), ofl, &ofl); - return origfn; -} - -/* Builds stubs for and redirects the IAT for one DLL (pImportDesc) */ - -static bool -RedirectIAT (function_hook& fh, PIMAGE_IMPORT_DESCRIPTOR pImportDesc, - HMODULE hm) -{ - // If no import names table, we can't redirect this, so bail - if (pImportDesc->OriginalFirstThunk == 0) - return false; - - /* import address table */ - PIMAGE_THUNK_DATA pt = rva (PIMAGE_THUNK_DATA, hm, pImportDesc->FirstThunk); - /* import names table */ - PIMAGE_THUNK_DATA pn = rva (PIMAGE_THUNK_DATA, hm, pImportDesc->OriginalFirstThunk); - - /* Scan through the IAT, completing the stubs and redirecting the IAT - entries to point to the stubs. */ - for (PIMAGE_THUNK_DATA pi = pt; pn->u1.Ordinal; pi++, pn++) - { - if (IMAGE_SNAP_BY_ORDINAL (pn->u1.Ordinal) ) - continue; - - /* import by name */ - PIMAGE_IMPORT_BY_NAME pimp = rva (PIMAGE_IMPORT_BY_NAME, hm, pn->u1.AddressOfData); - - if (strcmp (fh.name, (char *) pimp->Name) == 0) - { - fh.origfn = putmem (pi, fh.hookfn); - if (!fh.origfn) - return false; - hook_chain *hc; - for (hc = &cygheap->hooks; hc->next; hc = hc->next) - continue; - hc->next = (hook_chain *) cmalloc_abort (HEAP_1_HOOK, sizeof (hook_chain)); - hc->next->loc = (void **) pi; - hc->next->func = fh.hookfn; - hc->next->next = NULL; - break; - } - } - - return true; -} - -static void -get_export (function_hook& fh) -{ - PIMAGE_DOS_HEADER pdh = (PIMAGE_DOS_HEADER) cygwin_hmodule; - if (pdh->e_magic != IMAGE_DOS_SIGNATURE) - return; - PIMAGE_NT_HEADERS pnt = (PIMAGE_NT_HEADERS) ((char *) pdh + pdh->e_lfanew); - if (pnt->Signature != IMAGE_NT_SIGNATURE || pnt->FileHeader.SizeOfOptionalHeader == 0) - return; - PIMAGE_EXPORT_DIRECTORY pexp = - rvacyg (PIMAGE_EXPORT_DIRECTORY, - pnt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress); - if (!pexp) - return; - - PDWORD pfuncs = rvacyg (PDWORD, pexp->AddressOfFunctions); - PDWORD pnames = rvacyg (PDWORD, pexp->AddressOfNames); - for (DWORD i = 0; i < pexp->NumberOfNames; i++) - if (strcmp (fh.name, rvacyg (char *, pnames[i])) == 0) - { - fh.origfn = rvacyg (void *, pfuncs[i]); - break; - } -} - -static const char * -makename (const char *name, char *&buf, int& i, int inc) -{ - i += inc; - static const char *testers[] = {"NOTUSED", "64", "32"}; - if (i < 0 || i >= (int) (sizeof (testers) / sizeof (testers[0]))) - return NULL; - if (i) - { - __small_sprintf (buf, "_%s%s", name, testers[i]); - name = buf; - } - return name; -} - -/* Find first missing dll in a given executable. - FIXME: This is not foolproof since it doesn't look for dlls in the - same directory as the given executable, like Windows. Instead it - searches for dlls in the context of the current executable. */ -const char * -find_first_notloaded_dll (path_conv& pc) -{ - const char *res = "?"; - HANDLE hc = NULL; - HMODULE hm = NULL; - OBJECT_ATTRIBUTES attr; - IO_STATUS_BLOCK io; - HANDLE h; - NTSTATUS status; - - status = NtOpenFile (&h, SYNCHRONIZE | GENERIC_READ, - pc.get_object_attr (attr, sec_none_nih), - &io, FILE_SHARE_READ | FILE_SHARE_WRITE, - FILE_SYNCHRONOUS_IO_NONALERT - | FILE_OPEN_FOR_BACKUP_INTENT - | FILE_NON_DIRECTORY_FILE); - if (!NT_SUCCESS (status)) - goto out; - - hc = CreateFileMapping (h, &sec_none_nih, PAGE_READONLY, 0, 0, NULL); - NtClose (h); - if (!hc) - goto out; - hm = (HMODULE) MapViewOfFile(hc, FILE_MAP_READ, 0, 0, 0); - CloseHandle (hc); - - PIMAGE_NT_HEADERS pExeNTHdr; - pExeNTHdr = PEHeaderFromHModule (hm); - - if (pExeNTHdr) - { - DWORD importRVA; - importRVA = pExeNTHdr->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress; - if (importRVA) - { - long delta = rvadelta (pExeNTHdr, importRVA); - - // Convert imports RVA to a usable pointer - PIMAGE_IMPORT_DESCRIPTOR pdfirst; - pdfirst = rva (PIMAGE_IMPORT_DESCRIPTOR, hm, importRVA - delta); - - // Iterate through each import descriptor, and redirect if appropriate - for (PIMAGE_IMPORT_DESCRIPTOR pd = pdfirst; pd->FirstThunk; pd++) - { - const char *lib = rva (PSTR, hm, pd->Name - delta); - if (!LoadLibraryEx (lib, NULL, DONT_RESOLVE_DLL_REFERENCES - | LOAD_LIBRARY_AS_DATAFILE)) - { - static char buf[NT_MAX_PATH]; - res = strcpy (buf, lib); - } - } - } - } - -out: - if (hm) - UnmapViewOfFile (hm); - - return res; -} - -// Top level routine to find the EXE's imports and redirect them -void * -hook_or_detect_cygwin (const char *name, const void *fn, WORD& subsys) -{ - HMODULE hm = fn ? GetModuleHandle (NULL) : (HMODULE) name; - PIMAGE_NT_HEADERS pExeNTHdr = PEHeaderFromHModule (hm); - - if (!pExeNTHdr) - return false; - - subsys = pExeNTHdr->OptionalHeader.Subsystem; - - DWORD importRVA = pExeNTHdr->OptionalHeader.DataDirectory - [IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress; - if (!importRVA) - return false; - - long delta = fn ? 0 : rvadelta (pExeNTHdr, importRVA); - if (delta < 0) - return false; - - // Convert imports RVA to a usable pointer - PIMAGE_IMPORT_DESCRIPTOR pdfirst = rva (PIMAGE_IMPORT_DESCRIPTOR, hm, importRVA - delta); - - function_hook fh; - fh.origfn = NULL; - fh.hookfn = fn; - char *buf = (char *) alloca (strlen (name) + sizeof ("_64")); - int i; - // Iterate through each import descriptor, and redirect if appropriate - for (PIMAGE_IMPORT_DESCRIPTOR pd = pdfirst; pd->FirstThunk; pd++) - { - if (!ascii_strcasematch (rva (PSTR, hm, pd->Name - delta), "cygwin1.dll")) - continue; - if (!fn) - return (void *) "found it"; // just checking if executable used cygwin1.dll - i = -1; - while (!fh.origfn && (fh.name = makename (name, buf, i, 1))) - RedirectIAT (fh, pd, hm); - if (fh.origfn) - break; - } - - while (!fh.origfn && (fh.name = makename (name, buf, i, -1))) - get_export (fh); - - return fh.origfn; -} - -void -ld_preload () -{ - char *p = getenv ("LD_PRELOAD"); - if (!p) - return; - char *s = (char *) alloca (strlen (p) + 1); - strcpy (s, p); - char *here = NULL; - for (p = strtok_r (s, ":\t\n", &here); p; p = strtok_r (NULL, ":\t\n", &here)) - { - path_conv lib (p); - WCHAR libname[lib.get_wide_win32_path_len () + 1]; - if (!LoadLibraryW (lib.get_wide_win32_path (libname))) - { - __seterrno (); - api_fatal ("error while loading shared libraries: %s: " - "cannot open shared object file: %s", p, - strerror (get_errno ())); - } - } -} - -void -fixup_hooks_after_fork () -{ - for (hook_chain *hc = &cygheap->hooks; (hc = hc->next); ) - putmem ((PIMAGE_THUNK_DATA) hc->loc, hc->func); -} diff --git a/winsup/cygwin/how-autoload-works.txt b/winsup/cygwin/how-autoload-works.txt deleted file mode 100644 index 8cff52900..000000000 --- a/winsup/cygwin/how-autoload-works.txt +++ /dev/null @@ -1,66 +0,0 @@ -Copyright 2002 Red Hat Inc., Egor Duda - -How does function autoloading work? - -Cygwin has the ability to handle win32 functions which are present on -some platforms and not present on others via autoload mechanism. It's -essentially a lazy binding of symbols. It works as following. For -(almost) every function from OS API which cygwin uses, a stub is created -in file autoload.cc. Each reference to the such function from win32 API -in cygwin dll source code is actually pointing to this stub. - -When the function, say GetConsoleWindow(), is called for the first time, -the control is passed to its stub. The stub tries to load the -appropriate system dll via LoadModule() and get the actual function -address via GetProcAddress(). If this operation succeeds, the stub is -"patched" to pass control to actual address of GetConsoleWindow() in -appropriate system dll, so that next time we won't have to load dll and -perform address lookup in it again. From this point on, the call to the -function is performed as if the dll/function were linked statically. - -If LoadModule() or GetProcAddress() fail, (and on nt4 the latter indeed -fails because GetConsoleWindow() is not available in kernel32.dll), then -the application, depending on what kind of stub is created in -autoload.cc, will either: - -1) Exit with fatal error. - -2) Or return a predefined value indicating an error; and set the windows -error code to 127 (ERROR_PROC_NOT_FOUND). - -Almost all w32api functions are linked into the cygwin dll in this -manner, dynamically, at runtime. - -The costs: -1) A tiny overhead in the initial call to a function call as each call -is performed, indirectly, via a stub. For the first lookup of a symbol -of an unloaded dll, there is also some overhead in loading the dll for -the first time. The dll is only loaded by the first call to a symbol -in the dll. After the first call to a function, subsequent calls are -as fast as a normal, statically loaded function. - -The benefits: -1) Speedup at startup time. Applications only load those dlls which are -actually needed. For example, if application never uses socket -functions, winsock dlls are never loaded. - -2) Greatly simplify wincap system -- we don't need to have a separate -capability for every win32 function which may or may not be present on -particular win32 platform. - -3) Allows a single cygwin1.dll for all win32 platforms. - -If you're changing in cygwin1.dll source code and if you use some -function that was not used there before, you should add a stub so it -will be autoloaded. To do so, add one of the LoadDllfunc* macros to -autoload.cc. All macros eventually resolve to the following form: - -LoadDLLfuncEx2 (function name, parameter block length, dll name, - non-fatality flag , value to return if function not available) - -Parameter block length is a sum of sizes (in bytes) of parameters which are -being passed to the function. If non-fatality flag is set to 0, then failure -to load dll and find a function will cause fatal error. If non fatality flag -is set to 1, then call to the function will return default value. -You can also use shorter versions -- LoadDLLfuncEx and LoadDLLfunc, if the -defaults they provide suit your needs. diff --git a/winsup/cygwin/how-cygheap-works.txt b/winsup/cygwin/how-cygheap-works.txt deleted file mode 100644 index b60f88808..000000000 --- a/winsup/cygwin/how-cygheap-works.txt +++ /dev/null @@ -1,120 +0,0 @@ -Copyright 2001 Red Hat Inc., Christopher Faylor - -Cygwin has recently adopted something called the "cygwin heap". This is -an internal heap that is inherited by forked/execed children. It -consists of process specific information that should be inherited. So -things like the file descriptor table, the current working directory, -and the chroot value live there. - -The cygheap is also used to pass argv information to a child process. -There is a problem here, though. If you allocate space for argv on the -heap and then exec a process the child process (1) will happily use the -space in the heap. But what happens when that process execs another -process (2)? The space used by child process (1) still is being used in -child process (2) but it is basically just a memory leak. - -To rectify this problem, memory used by child process 1 is tagged in -such a way that child process 2 will know to delete it. This is in -cygheap_fixup_in_child. - -The cygheap memory allocation functions are adapted from memory -allocators developed by DJ Delorie. They are similar to early BSD -malloc and are intended to be relatively lightweight and relatively -fast. - -How is the cygheap propagated to the child? - -Well, it depends if you are running on Windows 9x or Windows NT. - -On NT and 9x, just before CreateProcess is about to be called in -fork or exec, a shared memory region is prepared for copying of the -cygwin heap. This is in cygheap_setup_for_child. The handle to this -shared memory region is passed to the new process in the 'child_info' -structure. - -If there are no handles that need "fixing up" prior to starting another -process, cygheap_setup_for_child will also copy the contents of the -cygwin heap to the shared memory region. - -If there are any handles that need "fixing up" prior to invoking -another process (i.e., sockets) then the creation of the shared -memory region and copying of the current cygwin heap is a two -step process. - -First the shared memory region is created and the process is started -in a "CREATE_SUSPENDED" state, inheriting the handle. After the -process is created, the fixup_before_*() functions are called. These -set information in the heap and duplicate handles in the child, essentially -ensuring that the child's fd table is correct. - -(Note that it is vital that the cygwin heap should not grow during this -process. Currently, there is no guard against this happening so this -operation is not thread safe.) - -Meanwhile, back in fork_parent, the function -cygheap_setup_for_child_cleanup is called. In the simple "one step" -case above, all that happens is that the shared memory is ummapped and -the handle referring to it is closed. - -In the two step process, the cygheap is now copied to the shared memory -region, complete with new fdtab info (the child process will see the -updated information as soon as it starts). Then the memory is unmapped, -the handle is closed, and upon return the child process is started. - -It is in the child process that the difference between Windows 9x and -Windows NT becomes evident. - -Under Windows NT, the operation is simple. The shared memory handle is -used to map the information that the parent has set up into the cygheap -location in the child. This means that the child has a copy of the -cygwin heap existing in "shared memory" but the only process with a view -to this "shared memory" is the child. - -Under Windows 9x, due to address limitations, we can't just map the -shared memory region into the cygheap position. So, instead, the memory -is mapped whereever Windows wants to put it, a new heap region is -allocated at the same place as in the parent, the contents of the shared -memory is *copied* to the new heap, and the shared memory is unmapped. -Simple, huh? - -Why do we go to these contortions? Previous versions (<1.3.3) of cygwin -used to block when creating a child so that the child could copy the -parent's cygheap. The problem with this was that when a cygwin process -invoked a non-cygwin child, it would block forever waiting for the child -to let it know that it was done copying the heap. That caused -understandable complaints from people who wanted to run non-cygwin -applications "in the background". - -In Cygwin 1.3.3 (and presumably beyond) the location of the cygwin heap -has been fixed to be at the end of the cygwin1.dll address space. -Previously, we let the "OS" choose where to allocate the cygwin heap in -the initial cygwin process and attempted to use this same location in -subsequent cygwin processes started from this parent. - -The reason for putting cygheap at a fixed, known location is that we -need to put this information at a fixed location since it incorporates -pointers to entities within itself. So, when a process forks or execs, -the memory referred to by the pointers has to exist at the same place in -both the parent or the child. - -(It "might be nice" to used something like Microsoft's "based pointers" -for the cygheap. Unfortunately gcc does not support that feature, as of -this writing.) - -The reason for choosing a fixed, arbitrary location is to accommodate -Windows XP, although there were sporadic complaints of cygwin heap -failures in other pathological situations with both NT and 9x. In -Windows XP, Microsoft made the allocation of memory less deterministic. -This is certainly their right. Cygwin was previously relying on -undocumented and "iffy" behavior before. So, now we always allocate -space immediately after the dll in the theory that there is not going -to be anything else living there. - -Recent (2001-09-20) cygwin email threads have indicated that we're not -exactly on completely firm ground now, though. We are assuming that -there is sufficient space after the cygwin DLL for the allocation of the -cygwin heap. Unfortunately the ld option '--enable-auto-image-base' -has a tendency to allocate DLLs immediately after cygwin1.dll. This -causes the dreaded "Couldn't reserve space for cygwin's heap" message. - -Solutions for this behavior are currently in the musing state. diff --git a/winsup/cygwin/how-cygtls-works.txt b/winsup/cygwin/how-cygtls-works.txt deleted file mode 100644 index 69363f1fb..000000000 --- a/winsup/cygwin/how-cygtls-works.txt +++ /dev/null @@ -1,75 +0,0 @@ -Copyright 2005 Red Hat Inc., Max Kaehn - -All cygwin threads have separate context in an object of class _cygtls. The -storage for this object is kept on the stack in the bottom CYGTLS_PADSIZE -bytes. Each thread references the storage via the Thread Environment Block -(aka Thread Information Block), which Windows maintains for each user thread -in the system, with the address in the FS segment register. The memory -is laid out as in the NT_TIB structure from : - -typedef struct _NT_TIB { - struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList; - PVOID StackBase; - PVOID StackLimit; - PVOID SubSystemTib; - _ANONYMOUS_UNION union { - PVOID FiberData; - DWORD Version; - } DUMMYUNIONNAME; - PVOID ArbitraryUserPointer; - struct _NT_TIB *Self; -} NT_TIB,*PNT_TIB; - -Cygwin sees it like this: - -extern exception_list *_except_list asm ("%fs:0"); // exceptions.cc -extern char *_tlsbase __asm__ ("%fs:4"); // cygtls.h -extern char *_tlstop __asm__ ("%fs:8"); // cygtls.h - -And accesses cygtls like this: - -#define _my_tls (((_cygtls *) _tlsbase)[-1]) // cygtls.h - - -Initialization always goes through _cygtls::init_thread(). It works -in the following ways: - -* In the main thread, _dll_crt0() provides CYGTLS_PADSIZE bytes on the stack - and passes them to initialize_main_tls(), which calls _cygtls::init_thread(). - It then calls dll_crt0_1(), which terminates with cygwin_exit() rather than - by returning, so the storage never goes out of scope. - - If you load cygwin1.dll dynamically from a non-cygwin application, it is - vital that the bottom CYGTLS_PADSIZE bytes of the stack are not in use - before you call cygwin_dll_init(). See winsup/testsuite/cygload for - more information. - -* Threads other than the main thread receive DLL_THREAD_ATTACH messages - to dll_entry() (in init.cc). - - dll_entry() calls munge_threadfunc(), which grabs the function pointer - for the thread from the stack frame and substitutes threadfunc_fe(), - - which then passes the original function pointer to _cygtls::call(), - - which then allocates CYGTLS_PADSIZE bytes on the stack and hands them - to call2(), - - which allocates an exception_list object on the stack and hands it to - init_exceptions() (in exceptions.cc), which attaches it to the end of - the list of exception handlers, changing _except_list (aka - tib->ExceptionList), then passes the cygtls storage to init_thread(). - call2() calls ExitThread() instead of returning, so the storage never - goes out of scope. - -Note that the padding isn't necessarily going to be just where the _cygtls -structure lives; it just makes sure there's enough room on the stack when the -CYGTLS_PADSIZE bytes down from there are overwritten. - - -Debugging - -You can examine the segment registers in gdb via "info w32 selector $fs" -(which is using GetThreadSelectorEntry()) to get results like this: - - Selector $fs - 0x03b: base=0x7ffdd000 limit=0x00000fff 32-bit Data (Read/Write, Exp-up) - Priviledge level = 3. Byte granular. - -"x/3x 0x7ffdd000" will give you _except_list, _tlsbase, and _tlstop. diff --git a/winsup/cygwin/how-fhandlers-work.txt b/winsup/cygwin/how-fhandlers-work.txt deleted file mode 100644 index cef46fedc..000000000 --- a/winsup/cygwin/how-fhandlers-work.txt +++ /dev/null @@ -1,75 +0,0 @@ -Copyright 2001 Red Hat Inc., Robert Collins - -fhandlers are the core mechanism by which cygwin provides a file descripter (fd) -interface to things such as a random number generated, winsock sockets, raw disk -devices, the clipboard, the console and so on. Under unix access to all such -devices is via a combination of IOCTL's and open/close/read/write calls. Some -special functions do exist - such as bind () and listen () for sockets, but -these consistently operate on fd's. Under Win32 there are disparate interfaces -that have little in common with each other. See for example Direct Sound and -the Clipboard. - -The fhandler class provides all open,read,write,close, ioctl and fork()/exec() -functionality for the fd interface. The base class operates on win32 backed -files. The various derived classes utilise win32 primitives to provide their -specific functionality. - -When a file is opened - not necesarily via open() a fd is assigned to it. The fd -includes a pointer to the actual fhandler that operates this specific file. All -file-oriented system calls then operate off this basic structure. - -For example, lets examine lseek (). - -extern "C" off_t -_lseek (int fd, off_t pos, int dir) -{ - off_t res; - sigframe thisframe (mainthread); - - if (dir != SEEK_SET && dir != SEEK_CUR && dir != SEEK_END) - { - set_errno (EINVAL); - res = -1; - } - else if (cygheap->fdtab.not_open (fd)) - { - set_errno (EBADF); - res = -1; - } - else - { - res = cygheap->fdtab[fd]->lseek (pos, dir); - } - syscall_printf ("%d = lseek (%d, %d, %d)", res, fd, pos, dir); - - return res; -} - -The sigframe thisframe (mainthread); is signal related - see -"how_signals_work.txt". - -The if, else if, else tests (in order) -* the validity of the dir parameter, -* is the fd being passed actually open? (cannot seek on a closed fd) -* call the lseek virtual function in the associated fhandler. - -So as you can see, there is no code that attempts to understand the nature of -the fhandler. - -fhandlers that make cross-function-call use of win32 objects that are not -inheritable cross-process need to implement fixup-after-fork and recreate those -objects. HANDLES can be inherited, but memory mapped regions (for example) -cannot. - -For an example step-by-step to create a new fhandler, see -../doc/fhandler-tut.txt - -Note: In most case, it is safe to assume that using new/delete (or -malloc/free) in an fhandler is dangerous and to be avoided. The reason -for this is that memory allocated to fhandlers is copied between execed -processes in the cygwin heap. Memory allocated in new/delete is only -copied to forked processes. So use cmalloc/cfree. - -Obviously it is possible to use new/delete in some situations but if you're -seeing strange core dumps with usages like cat < /my/newfhandler then the -above may well be the culprit. diff --git a/winsup/cygwin/how-signals-work.txt b/winsup/cygwin/how-signals-work.txt deleted file mode 100644 index 4d94c79dc..000000000 --- a/winsup/cygwin/how-signals-work.txt +++ /dev/null @@ -1,158 +0,0 @@ -Copyright 2001, 2002, 2003, 2004 Red Hat Inc., Christopher Faylor - -[note that the following discussion is still incomplete] - -How do signals work? - -On process startup, cygwin starts a secondary thread which deals with -signals. This thread contains a loop which blocks waiting for -information to arrive on a pipe whose handle (sendsig) is currently -stored in _pinfo (this may change). - -Communication on the sendsig pipe is via the 'sigpacket' structure. -This structure is filled out by the sig_send function with information -about the signal being sent, such as (as of this writing) the signal -number, the originating pid, the originating thread, and the address of -the mask to use (this may change). - -Any cygwin function which calls a win32 api function is wrapped by the -assembly functions "_sigfe" and "_sigbe". These functions maintain a -cygwin "signal stack" which is used by the signal thread to control -handling of signal interrupts. Cygwin functions which need to be -wrapped by these functions (the majority) are labelled by the SIGFE -option in the file cygwin.din. - -The cygwin.din function is translated into a standard cygwin.def file by -the perl script "gendef". This function notices exported cygwin -functions which are labelled as SIGFE and generates a front end assembly -file "sigfe.s" which contains the wrapper glue necessary for every -function to call sigfe prior to actually dispatching to the real cygwin -function. This generated file contains low-level signal related -functions: _sigfe, _sigbe, sigdelayed, sigreturn, longjmp, and setjmp. - -The signal stack maintained by sigfe/sigbe and friends is a secondary -shadow stack. Addresses from this stack are swapped into the "real" -stack as needed to control program flow. The intent is that executing -cygwin functions will still see the same stack layout as if they had -been called directly and will be able to retrieve arguments from the -stack but will always return to the _sigbe routine so that any signal -handlers will be properly called. - -Upon receipt of a "non-special" (see below) signal, the function -sigpacket::process is called. This function determines what action, if -any, to take on the signal. Possible actions are: Ignore the signal -(e.g., SIGUSR1), terminate the program (SIGKILL, SIGTERM), stop the -program (SIGSTOP, SIGTSTP, etc.), wake up a sigwait or sigwaitinfo in a -targetted thread, or call a signal handler (possibly in a thread). If -no thread information has been sent to sigpacket::process, it determines -the correct thread to use based on various heuristics, as per UNIX. As -per linux, the only time a handler is called in a thread is when there -is some kind of fault like SIGSEGV, SIGILL, etc. Signals sent via the -UNIX kill() function are normally sent to the main thread. Ditto -signals sent as the result of pressing tty keys, like CTRL-C. - -Signals which stop a process are handled by a special internal handler: -sig_handle_tty_stop. Some signals (e.g., SIGKILL, SIGSTOP) are -uncatchable, as on UNIX. - -If the signal has an associated signal handler, then the setup_handler -function is eventually called. It is passed the signal, the address of -the handler, a standard UNIX sigaction structure, and a pointer to the -thread's "_cygtls" information. The meat of signal processing is in -setup_handler. - -setup_handler has a "simple" task. It tries to stop the appropriate -thread and either redirect its execution to the signal handler function, -flag that a signal has been received (sigwait) or both (sigpause). - -To accomplish its task, setup_handler first inspects the target thread's -local storage (_cygtls) structure. This structure contains information -on any not-yet-handled signals that may have been set up by a previous -call to setup_handler but not yet dispatched in the target thread. If this -structure seems to be "active", then setup_handler returns, notifying it's -parent via a false value. Otherwise processing continues. - -(For pending signals, the theory is that the signal handler thread will -be forced to be rerun by having some strategic cygwin function call -sig_send with a __SIGFLUSH argument. This causes the signal handler to -rescan the signal array looking for pending signals.) - -After determining that it's ok to send a signal, setup_handler will lock -the cygtls stack to ensure that it has complete access. It will then -inspect the thread's 'incyg' boolean. If this is true, the thread is -currently executing a cygwin function. If it is false, the thread is -unlocked and it is assumed that the thread is executing "user" code. -The actions taken by setup_handler differ based on whether the program -is executing a cygwin routine or not. - -If the program is executing a cygwin routine, then the -interrupt_on_return function is called which causes the address of the -'sigdelayed' function to be pushed onto the thread's signal stack, and -the signal's mask and handler to be saved in the tls structure. After -performing these operations, the 'signal_arrived' event is signalled, as -well as any thread-specific wait event. - -Since the sigdelayed function was saved on the thread's signal stack, -when the cygwin function returns, it will eventually return to the -sigdelayed "front end". The sigdelayed function will save a lot of -state on the stack and set the signal mask as appropriate for POSIX. -It uses information from the _cygtls structure which has been filled in -by interrupt_setup, as called by setup_handler. sigdelayed pushes a -"call" to the function "sigreturn" on the thread's signal stack. This -will be the return address eventually seen by the signal handler. After -setting up the return value, modifying the signal mask, and saving other -information on the stack, sigreturn clears the signal number in the -_cygtls structure so that setup_handler can use it and jumps to the -signal handler function. And, so a UNIX signal handler function is -emulated. - -The signal handler function operates as normal for UNIX but, upon -return, it does not go directly back to the return address of the -original cygwin function. Instead it returns to the previously -mentioned 'sigreturn' assembly language function. - -sigreturn resets the process mask to its state prior to calling the -signal handler. It checks to see if a cygwin routine has set a special -"restore this errno on returning from a signal" value and sets errno to -this, if so. It pops the signal stack, places the new return address on -the real stack, restores all of the register values that were in effect -when sigdelayed was called, and then returns. - -Ok. That is more or less how cygwin interrupts a process which is -executing a cygwin function. We are almost ready to talk about how -cygwin interrupts user code but there is one more thing to talk about: -SA_RESTART. - -UNIX allows some blocking functions to be interrupted by a signal -handler and then return to blocking. In cygwin, so far, only -read/readv() and the wait* functions operate in this fashion. To -accommodate this behavior, a function notices when a signal comes in and -then calls the _cygtls function 'call_signal_handler_now'. -'call_signal_handler_now' emulates the behavior of both sigdelayed and -sigreturn. It sets the appropriate masks and calls the handler, -returning true to the caller if SA_RESTART is active. If SA_RESTART is -active, the function will loop. Otherwise it will typically return -1 -and set the errno to EINTR. - -Phew. So, now we turn to the case where cygwin needs to interrupt the -program when it is not executing a cygwin function. In this scenario, -we rely on the win32 "SuspendThread" function. Cygwin will suspend the -thread using this function and then inspect the location at which the -thread is executing using the win32 "GetThreadContext" call. In theory, -the program should not be executing in a win32 api since attempts to -suspend a process executing a win32 call can cause disastrous results, -especially on Win9x. - -If the process is executing in an unsafe location then setup_handler -will (quickly!) return false as in the case above. Otherwise, the -current location of the thread is pushed on the thread's signal stack -and the thread is redirected to the sigdelayed function via the win32 -"SetThreadContext" call. Then the thread is restarted using the win32 -"ResumeThread" call and things proceed as per the sigdelayed discussion -above. - -This leads us to the sig_send function. This is the "client side" part -of the signal manipulation process. sig_send is the low-level function -called by a high level process like kill() or pthread_kill(). - -** More to come ** diff --git a/winsup/cygwin/how-spawn-works.txt b/winsup/cygwin/how-spawn-works.txt deleted file mode 100644 index e865ebf3e..000000000 --- a/winsup/cygwin/how-spawn-works.txt +++ /dev/null @@ -1,33 +0,0 @@ -(THIS DESCRIPTION IS OUT-OF-DATE) -Spawn.cc in cygwin handles spawn, vfork and exec calls. It does this via -a mode parameter that determines its behaviour with respect to the -child. - -Of particular interest is the exec behaviour. - -In general spawn_guts (where the action happens) does the following: -* Finds the actual program being run (which may include path searching). -* Determines the type (.exe, shell script, perl etc) and for non binary -programs finds the correct interpreter. -* Creates a commandline (based on the type and the user parameters). -* Guesses at whether the binary that will be invoked is a cygwin program -or not (if (real_path.iscygexec ())) and uses that information to copy -the argv table, or to translate it for win32 program usage. -* passes a handle to the parent to the child (note: this handle should -have it's rights restricted the daemon is merged). -* Start the process. -* if the mode is _P_OVERLAY (we are doing an exec) -wait for the child to -a) if it's a cygwin process, signal us via an event. -b) if it's a win32 process, exit. -c) exit. - -If a) occurs, we 'reparent' the child which makes it look to the current -process's parent in the pid and process group chains. -b) is where the cygwin process hangs around as a 'stub' presenting it's -pid as the win32 process's pid, to allow cygwin tools to kill the win32 -process. -once a-c has occured, execution resumes. -* If the mode is _P_OVERLAY, this process exits, otherwise it's -behaviour depends on the mode parameter. See the last block of -spawn_guts. diff --git a/winsup/cygwin/how-startup-shutdown-works.txt b/winsup/cygwin/how-startup-shutdown-works.txt deleted file mode 100755 index 578deeb30..000000000 --- a/winsup/cygwin/how-startup-shutdown-works.txt +++ /dev/null @@ -1,165 +0,0 @@ -Copyright 2010 Red Hat Inc., contributed by Dave Korn. - - - How the C runtime handles startup and termination. - -------------------------------------------------- - -This file documents the processes involved in starting up and shutting down -a Cygwin executable. The responsibility is divided between code that is -statically linked into each Cygwin-based DLL or executable as part of the -C runtime, and code in the Cygwin DLL itself that co-operates with it. The -runtime library code lives in the winsup/cygwin/lib directory, and a little -of it is in winsup/cygwin/include/cygwin/cygwin_dll.h - - - - Process overall startup sequence. - ================================= - -Overall process startup (and indeed termination) is under the control of the -underlying Windows OS. The details of the Win32 CreateProcess API and the -underlying NT Native API ZwCreateProcess calls are far more complex (and -unknown, since proprietary) than we need go into here; the important details -are that the process address space is first created, then an initial thread -is spawned that performs DLL initialisation, calling the DllMain functions of -all statically-linked DLLs in load order. This thread is also serialised under -the Windows OS global loader lock, and DllMain functions are very limited in -what they can do as a consequence; to help deal with this, cygwin wraps the -user's DllMain function and defers calling it until runtime. Once the DLLs -have been initialised, the initial thread then performs C runtime setup and -calls into the executable's main() function. - - - Entry sequence for Cygwin-based DLLs. - ===================================== - -In the compiler's LINK_SPEC, a -e option sets the entry point (what Windows -regards as DllMain) to __cygwin_dll_entry@12. This is defined in -include/cygwin/cygwin_dll.h. The user's DllMain function, if any, is called -from within this function - directly in the case of thread attach/detach -notifications and process detach, but indirectly at process attach time via -cygwin_attach_dll in lib/cygwin_attach_dll.c, which calls the CRT common code -_cygwin_crt0_common and then hands off to the Cygwin DLL at dll_dllcrt0. The -CRT common code doesn't call the user DllMain at once; it caches a pointer to -it in the 'main' member of the DLL's per_process struct. - - - __cygwin_dll_entry@12 -> cygwin_attach_dll -> (_cygwin_crt0_common) - -> dll_dllcrt0 -> (DllMain?maybe?) - -dll_dllcrt0 is in dll_init.cc sets up exception handler, ensures cygwin DLL is -at least partially initialised, allocates a new entry for the DLL chain, and -either calls the 'main' function (via dll::init) before returning to the OS -loader, or defers doing so until dll_crt0_1 runs dlls.dll_list::init() during -the application's startup sequence, depending on whether Cygwin DLL was fully -initialised yet or not. In general statically linked DLLs will defer, while -dlopen'd DLLs will run at once. The Cygwin DLL runs the dependent DLL's ctors -immediately prior to making the call, whether immediate or deferred. - - - Entry sequence for Cygwin-based executables. - ============================================ - -The entry point is the windows standard entrypoint, WinMainCRTStartup, aliased -to mainCRTStartup, defined in crt0.c. It aligns the stack, sets the x87 fpu -cw, and hands off to cygwin_crt0 in lib/cygwin_crt0.c, which calls the CRT -common init code in _cygwin_crt0_common and heads off into the DLL, never to -return from _dll_crt0. - - mainCRTStartup -> cygwin_crt0 -> (_cygwin_crt0_common) -> _dll_crt0 - -> dll_crt0_1 -> (n*DllMain?maybe?) -> main -> (__main) -> cygwin_exit - -This is a wrapper that does some fork-related stack sorting out then hands off -to dll_crt0_1, which completes all Cygwin DLL initialisation, runs any -deferred DllMain calls, and jumps into the application, returning via the -termination routines. - - - Post-entry construction. - ======================== - -The compiler automatically inserts a hidden call to __main at the start of the -user's main() function. During startup, DLL constructors are run in dll:init() -immediately prior to calling that DLL's DllMain function (not in a forkee, -though; once is enough). In __main, all statically-loaded DLL ctors are now -complete, so we queue an atexit call to dll_global_dtors, then run the -application's ctors and queue an atexit call to do_global_dtors. - - - - Process overall termination sequence. - ===================================== - -The program termination sequence can begin in one of the following ways: - -- by returning from main() -- by calling exit(), _Exit() or _exit() -- by calling abort() - (this can be implicit, such as when an unhandled C++ exception is thrown, - or when an SEH exception is raised and not trapped, or an unhandled signal - terminates the program). - - - Unload sequence for Cygwin-based DLLS. - ====================================== - - _cygwin_dll_entry@12 -> (DllMain) -> cygwin_detach_dll -> dll_list::detach - -> (remove_dll_atexit) -> (dll::run_dtors) - -When a DLL is unloaded, whether as a result of dlclose() calling FreeLibrary(), -or when then entire process is terminating, the OS arranges to call the DLL's -DllMain function with a DLL_PROCESS_DETACH notification. As during the entry -sequence, this is also wrapped by _cygwin_dll_entry(), although there is in -this case no need to defer calling the user's DllMain hook; it is called at -once. If no error is indicated, the dll is then detached from Cygwin's -internal tracking list, and any atexit functions it has registered are run and -cancelled from the atexit list. Finally any static destructors are run. - - - Exit sequence for Cygwin-based executables. - ============================================ - -This diagram illustrates the code paths, listed above, by which the main -executable can terminate: - - +-------------->-- exception handling --->----------------------------+ - | | - +-------------->--------- abort --------->--- stdio cleanup ----------+ - | | - +-------------->-- direct or via _Exit -->-------------------+ | - | | | - +-------------->----------+ | | - | V stdio cleanup, V V - main -> dll_crt0_1 -> cygwin_exit -> exit -> atexit funcs -> _exit -> do_exit - -> pinfo::exit -> ExitProcess -> END. - -Returning from main() transfers control back to dll_crt0_1(), which passes the -return value to cygwin_exit(); this is the same as calling exit(), which is -an export name alias for cygwin_exit() anyway. cygwin_exit() calls the real -exit() function in newlib, which runs the atexit functions and shuts down -stdio before exiting via _exit(), which immediately passes the exit status -through to do_exit(). If exiting via abort(), stdio is cleaned up, but no -atexit functions are run. - -All the termination sequences end up in do_exit(), which takes care of POSIXy -stuff like process group and child signalling, tty disconnection, etc. This -finally passes control to pinfo::exit(), which takes care of indicating the -correct overall exit status and then gives control to the OS process shutdown -routine, ExitProcess(). - -During ExitProcess(), all the statically-linked DLLs in the application are -terminated, by calling their DllMain functions with the DLL_PROCESS_DETACH -notification. - - - Static object destruction. - ========================== - -Static object destruction for any statically-linked DLLs, or any dlopen()ed -DLLs that have still not been dlclose()d by termination time, is handled in -dll_global_dtors(). As the description above makes clear, this relies on the -atexit functions being run, and so only takes place during a graceful exit, -and not in the case of termination via _exit(), _Exit(), abort() or through an -unhandled signal or exception. The destructors are run before stdio has been -terminated, and in reverse of DLL load order. - diff --git a/winsup/cygwin/how-to-debug-cygwin.txt b/winsup/cygwin/how-to-debug-cygwin.txt deleted file mode 100644 index fcf53a27f..000000000 --- a/winsup/cygwin/how-to-debug-cygwin.txt +++ /dev/null @@ -1,128 +0,0 @@ -Copyright 2001, 2002, 2005 Red Hat Inc., Egor Duda - -So, your favorite program has crashed? And did you say something about -'stackdump'? Or it just prints its output from left to right and -upside-down? Well, you can file an angry bug report and wait until some -of the core developers try to reproduce your problem, try to find what's -the matter with your program and cygwin and fix the bug, if any. But -you can do something better than that. You can debug the problem -yourself, and even if you can't fix it, your analysis may be very -helpful. Here's the (incomplete) howto on cygwin debugging. - -1. First things first - - The first thing you'll need to do is to build cygwin1.dll and your - crashed application from sources. To debug them you'll need debug - information, which is normally stripped from executables. You probably - also want to build a version of the dll with more debugging capabilities - by reconfiguring your build directory, specifying the --enable-debugging - option to configure. - -2. Creating a known-working cygwin debugging environment - - - create a separate directory, say, c:\cygdeb, and put known-working - cygwin1.dll and gdb.exe in it. - - create a wrapper c:\cygdeb\debug_wrapper.cmd: - -========= debug_wrapper.cmd ========= -rem setting CYGWIN_TESTING environment variable makes cygwin application -rem not to interfere with other already running cygwin applications. -set CYGWIN_TESTING=1 -c:\cygdeb\gdb.exe -nw %1 %2 -=================================== - -3. Using cygwin's JIT debugging facility - - add 'error_start=c:\cygdeb\debug_wrapper.cmd' to CYGWIN environment - variable. When some application encounters critical error, cygwin will stop - it and execute debug_wrapper.cmd, which will run gdb and make it to attach to - the crashed application. - -4. Strace - - You can run your program under 'strace' utility, described if user's manual. - If you know where the problem approximately is, you can add a bunch of - additional debug_printf()s in the source code and see what they print in - strace log. There's one common problem with this method, that some bugs - may mysteriously disappear once the program is run under strace. Then the - bug is likely a race condition. strace has two useful options to deal with - such situation: -b enables buffering of output and reduces additional - timeouts introduced by strace, and -m option allows you to mask certain - classes of *_printf() functions, reducing timeouts even more. - - Note that strace does not use the cygwin DLL and so any process that it - starts does not inherit a cygwin environment. It is equivalent to starting - a program from the command prompt. - -5. Problems at early startup - - Sometimes, something crashes at the very early stages of application - initialization, when JIT debugging facility is not yet active. Ok, there's - another environment variable that may help. Create program_wrapper.cmd: - -========= program_wrapper.cmd ========= -rem setting CYGWIN_SLEEP environment variable makes cygwin application -rem to sleep for x milliseconds at startup -set CYGWIN_SLEEP=20000 -c:\some\path\bad_program.exe some parameters -=================================== - - Now, run program_wrapper.cmd. It should print running program pid. - After starting program_wrapper.cmd you've got 20 seconds to open another - window, cd to c:\cygdeb in it, run gdb there and in gdb prompt type - - (gdb) attach - - where is the pid that program_wrapper.cmd have printed. - After that you can normally step through the code in cygwin1.dll and - bad_program.exe - -6. More problems at early startup - - You can also set a CYGWIN_DEBUG variable to force the debugger to pop up - only when a certain program is run: - -set CYGWIN_DEBUG=cat.exe:gdb.exe - - This will force gdb.exe to start when the program name contains the string - "cat.exe". The ':gdb.exe' isn't really needed, since it is the default. - It is just there to show how you can specify a program to run when the - program starts. You can optionally set a breakpoint on "break_here" - once the debugger pops up and then you can single step through the - initialization process. - - Note that it bears repeating that both of the above options are *only* - available when configuring cygwin with --enable-debugging. - -7. Heap corruption - - If your program crashes at malloc() or free() or when it references some - malloc()'ed memory, it looks like heap corruption. You can configure and - build special version of cygwin1.dll which includes heap sanity checking. - To do it, just add --enable-malloc-debugging option to configure. Be warned, - however, that this version of dll is _very_ slow (10-100 times slower than - normal), so use it only when absolutely necessary. - -8. Program dies when running under strace - - If your program crashes when you run it using strace but runs ok (or has a - different problem) otherwise, then there may be a problem in one of the - strace *_printf statements. Usually this is caused by a change in arguments - resulting in a %s being used with something other than a pointer to a - string. - - To debug this scenario, do something like this: - - bash$ gdb -nw yourapp.exe - (gdb) dll cygwin1 - (gdb) l dll_crt0_1 - (gdb) b <> - (gdb) run - (gdb) set strace._active=1 - (gdb) continue - - The program will then run in "strace mode", calling each strace *_printf, - just like it does when run under the strace program. Eventually, the - program will crash, probably in small_printf. At that point, a 'bt' - command should show you the offending call to strace_printf with the - improper format string. diff --git a/winsup/cygwin/how-vfork-works.txt b/winsup/cygwin/how-vfork-works.txt deleted file mode 100644 index 59fe5f52e..000000000 --- a/winsup/cygwin/how-vfork-works.txt +++ /dev/null @@ -1,36 +0,0 @@ -(THIS DESCRIPTION IS OUT-OF-DATE) - -How does vfork work? - -When a program calls vfork, cygwin attempts to short circuit its -normal, expensive fork mechanism. - -Vfork is mainly smoke and mirrors. A call to vfork contines to execute -in the current process but first it returns a pid of 0 so that process -will execute code intended for the child in a UNIX system. Before -returning the zero, vfork makes a copy of the current fd table so that -closing an fd in the "child" will not affect the "parent". - -Some of this info is stored in a per-thread structure but vfork is not -really thread-safe since it also stores the fd "backup" table in the -global fd table. - -The process continues to execute until it hits some type of exec call. -The exec call is essentially translated into a spawn NO_WAIT call and -the new process is started via this mechanism. After execing, the -"child" process no longer should exist, so the spawn code longjmps back -to the original vfork call. The previously opened fds are closed and -the parent's fd table is restored. vfork() then returns the pid of the -just-spawned process. - -Meanwhile, the just-spawned child notices that it has been spawned as -the result of a vfork and closes the extra file handles. - -This all relies on the fact that the child in a vfork call can affect -just about everything in the parent except for the parent's fds. -The assumption is that a vfork is always just used as a method for -starting a program. - -The assumption is also that all of this is much faster than the -slow method that cygwin uses to implement fork(). - diff --git a/winsup/cygwin/include/a.out.h b/winsup/cygwin/include/a.out.h deleted file mode 100644 index 500e14f3f..000000000 --- a/winsup/cygwin/include/a.out.h +++ /dev/null @@ -1,431 +0,0 @@ -/* a.out.h - - Copyright 1997, 1998, 1999, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _A_OUT_H_ -#define _A_OUT_H_ - -#ifdef __cplusplus -extern "C" { -#endif -#define COFF_IMAGE_WITH_PE -#define COFF_LONG_SECTION_NAMES - -/*** coff information for Intel 386/486. */ - - -/********************** FILE HEADER **********************/ - -struct external_filehdr { - short f_magic; /* magic number */ - short f_nscns; /* number of sections */ - unsigned long f_timdat; /* time & date stamp */ - unsigned long f_symptr; /* file pointer to symtab */ - unsigned long f_nsyms; /* number of symtab entries */ - short f_opthdr; /* sizeof(optional hdr) */ - short f_flags; /* flags */ -}; - -/* Bits for f_flags: - * F_RELFLG relocation info stripped from file - * F_EXEC file is executable (no unresolved external references) - * F_LNNO line numbers stripped from file - * F_LSYMS local symbols stripped from file - * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax) - */ - -#define F_RELFLG (0x0001) -#define F_EXEC (0x0002) -#define F_LNNO (0x0004) -#define F_LSYMS (0x0008) - - - -#define I386MAGIC 0x14c -#define I386PTXMAGIC 0x154 -#define I386AIXMAGIC 0x175 - -/* This is Lynx's all-platform magic number for executables. */ - -#define LYNXCOFFMAGIC 0415 - -#define I386BADMAG(x) (((x).f_magic != I386MAGIC) \ - && (x).f_magic != I386AIXMAGIC \ - && (x).f_magic != I386PTXMAGIC \ - && (x).f_magic != LYNXCOFFMAGIC) - -#define FILHDR struct external_filehdr -#define FILHSZ 20 - - -/********************** AOUT "OPTIONAL HEADER"= - **********************/ - - -typedef struct -{ - unsigned short magic; /* type of file */ - unsigned short vstamp; /* version stamp */ - unsigned long tsize; /* text size in bytes, padded to FW bdry*/ - unsigned long dsize; /* initialized data " " */ - unsigned long bsize; /* uninitialized data " " */ - unsigned long entry; /* entry pt. */ - unsigned long text_start; /* base of text used for this file */ - unsigned long data_start; /* base of data used for this file= - */ -} -AOUTHDR; - -#define AOUTSZ 28 -#define AOUTHDRSZ 28 - -#define OMAGIC 0404 /* object files, eg as output */ -#define ZMAGIC 0413 /* demand load format, eg normal ld output */ -#define STMAGIC 0401 /* target shlib */ -#define SHMAGIC 0443 /* host shlib */ - - -/* define some NT default values */ -/* #define NT_IMAGE_BASE 0x400000 moved to internal.h */ -#define NT_SECTION_ALIGNMENT 0x1000 -#define NT_FILE_ALIGNMENT 0x200 -#define NT_DEF_RESERVE 0x100000 -#define NT_DEF_COMMIT 0x1000 - -/********************** SECTION HEADER **********************/ - - -struct external_scnhdr { - char s_name[8]; /* section name */ - unsigned long s_paddr; /* physical address, offset - of last addr in scn */ - unsigned long s_vaddr; /* virtual address */ - unsigned long s_size; /* section size */ - unsigned long s_scnptr; /* file ptr to raw data for section */ - unsigned long s_relptr; /* file ptr to relocation */ - unsigned long s_lnnoptr; /* file ptr to line numbers */ - unsigned short s_nreloc; /* number of relocation entries */ - unsigned short s_nlnno; /* number of line number entries*/ - unsigned long s_flags; /* flags */ -}; - -#define SCNHDR struct external_scnhdr -#define SCNHSZ 40 - -/* - * names of "special" sections - */ -#define _TEXT ".text" -#define _DATA ".data" -#define _BSS ".bss" -#define _COMMENT ".comment" -#define _LIB ".lib" - -/********************** LINE NUMBERS **********************/ - -/* 1 line number entry for every "breakpointable" source line in a section. - * Line numbers are grouped on a per function basis; first entry in a function - * grouping will have l_lnno = 0 and in place of physical address will be the - * symbol table index of the function name. - */ -struct external_lineno { - union { - unsigned long l_symndx; /* function name symbol index, iff l_lnno 0 */ - unsigned long l_paddr; /* (physical) address of line number */ - } l_addr; - unsigned short l_lnno; /* line number */ -}; - -#define LINENO struct external_lineno -#define LINESZ 6 - -/********************** SYMBOLS **********************/ - -#define E_SYMNMLEN 8 /* # characters in a symbol name */ -#define E_FILNMLEN 14 /* # characters in a file name */ -#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ - -struct external_syment -{ - union { - char e_name[E_SYMNMLEN]; - struct { - unsigned long e_zeroes; - unsigned long e_offset; - } e; - } e; - unsigned long e_value; - unsigned short e_scnum; - unsigned short e_type; - char e_sclass[1]; - char e_numaux[1]; -}; - -#define N_BTMASK (0xf) -#define N_TMASK (0x30) -#define N_BTSHFT (4) -#define N_TSHIFT (2) - -union external_auxent { - struct { - unsigned long x_tagndx; /* str, un, or enum tag indx */ - union { - struct { - unsigned short x_lnno; /* declaration line number */ - unsigned short x_size; /* str/union/array size */ - } x_lnsz; - unsigned long x_fsize; /* size of function */ - } x_misc; - union { - struct { /* if ISFCN, tag, or .bb */ - unsigned long x_lnnoptr;/* ptr to fcn line # */ - unsigned long x_endndx; /* entry ndx past block end */ - } x_fcn; - struct { /* if ISARY, up to 4 dimen. */ - char x_dimen[E_DIMNUM][2]; - } x_ary; - } x_fcnary; - unsigned short x_tvndx; /* tv index */ - } x_sym; - - union { - char x_fname[E_FILNMLEN]; - struct { - unsigned long x_zeroes; - unsigned long x_offset; - } x_n; - } x_file; - - struct { - unsigned long x_scnlen; /* section length */ - unsigned short x_nreloc; /* # relocation entries */ - unsigned short x_nlinno; /* # line numbers */ - unsigned long x_checksum; /* section COMDAT checksum */ - unsigned short x_associated;/* COMDAT associated section index */ - char x_comdat[1]; /* COMDAT selection number */ - } x_scn; - - struct { - unsigned long x_tvfill; /* tv fill value */ - unsigned short x_tvlen; /* length of .tv */ - char x_tvran[2][2]; /* tv range */ - } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ - -}; - -#define SYMENT struct external_syment -#define SYMESZ 18 -#define AUXENT union external_auxent -#define AUXESZ 18 - -#define _ETEXT "etext" - -/********************** RELOCATION DIRECTIVES **********************/ - -struct external_reloc { - char r_vaddr[4]; - char r_symndx[4]; - char r_type[2]; -}; - -#define RELOC struct external_reloc -#define RELSZ 10 - -/* end of coff/i386.h */ - -/* PE COFF header information */ - -#ifndef _PE_H -#define _PE_H - -/* NT specific file attributes */ -#define IMAGE_FILE_RELOCS_STRIPPED 0x0001 -#define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002 -#define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004 -#define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008 -#define IMAGE_FILE_BYTES_REVERSED_LO 0x0080 -#define IMAGE_FILE_32BIT_MACHINE 0x0100 -#define IMAGE_FILE_DEBUG_STRIPPED 0x0200 -#define IMAGE_FILE_SYSTEM 0x1000 -#define IMAGE_FILE_DLL 0x2000 -#define IMAGE_FILE_BYTES_REVERSED_HI 0x8000 - -/* additional flags to be set for section headers to allow the NT loader to - read and write to the section data (to replace the addresses of data in - dlls for one thing); also to execute the section in .text's case= - */ -#define IMAGE_SCN_MEM_DISCARDABLE 0x02000000 -#define IMAGE_SCN_MEM_EXECUTE 0x20000000 -#define IMAGE_SCN_MEM_READ 0x40000000 -#define IMAGE_SCN_MEM_WRITE 0x80000000 - -/* - * Section characteristics added for ppc-nt - */ - -#define IMAGE_SCN_TYPE_NO_PAD 0x00000008 /* Reserved. */ - -#define IMAGE_SCN_CNT_CODE 0x00000020 /* Section contains code. */ -#define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040 /* Section contains initialized data. */ -#define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080 /* Section contains uninitialized data. */ - -#define IMAGE_SCN_LNK_OTHER 0x00000100 /* Reserved. */ -#define IMAGE_SCN_LNK_INFO 0x00000200 /* Section contains comments or some other type of information. */ -#define IMAGE_SCN_LNK_REMOVE 0x00000800 /* Section contents will not become part of image. */ -#define IMAGE_SCN_LNK_COMDAT 0x00001000 /* Section contents comdat. */ - -#define IMAGE_SCN_MEM_FARDATA 0x00008000 - -#define IMAGE_SCN_MEM_PURGEABLE 0x00020000 -#define IMAGE_SCN_MEM_16BIT 0x00020000 -#define IMAGE_SCN_MEM_LOCKED 0x00040000 -#define IMAGE_SCN_MEM_PRELOAD 0x00080000 - -#define IMAGE_SCN_ALIGN_1BYTES 0x00100000 -#define IMAGE_SCN_ALIGN_2BYTES 0x00200000 -#define IMAGE_SCN_ALIGN_4BYTES 0x00300000 -#define IMAGE_SCN_ALIGN_8BYTES 0x00400000 -#define IMAGE_SCN_ALIGN_16BYTES 0x00500000 /* Default alignment if no others are specified. */ -#define IMAGE_SCN_ALIGN_32BYTES 0x00600000 -#define IMAGE_SCN_ALIGN_64BYTES 0x00700000 - - -#define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000 /* Section contains extended relocations. */ -#define IMAGE_SCN_MEM_NOT_CACHED 0x04000000 /* Section is not cachable. */ -#define IMAGE_SCN_MEM_NOT_PAGED 0x08000000 /* Section is not pageable. */ -#define IMAGE_SCN_MEM_SHARED 0x10000000 /* Section is shareable. */ - -/* COMDAT selection codes. */ - -#define IMAGE_COMDAT_SELECT_NODUPLICATES (1) /* Warn if duplicates. */ -#define IMAGE_COMDAT_SELECT_ANY (2) /* No warning. */ -#define IMAGE_COMDAT_SELECT_SAME_SIZE (3) /* Warn if different size. */ -#define IMAGE_COMDAT_SELECT_EXACT_MATCH (4) /* Warn if different. */ -#define IMAGE_COMDAT_SELECT_ASSOCIATIVE (5) /* Base on other section. */ - -/* Magic values that are true for all dos/nt implementations */ -#define DOSMAGIC 0x5a4d -#define NT_SIGNATURE 0x00004550 - -/* NT allows long filenames, we want to accommodate this. This may break - some of the bfd functions */ -#undef FILNMLEN -#define FILNMLEN 18 /* # characters in a file name */ - - -#ifdef COFF_IMAGE_WITH_PE -/* The filehdr is only weired in images */ - -#undef FILHDR -struct external_PE_filehdr -{ - /* DOS header fields */ - unsigned short e_magic; /* Magic number, 0x5a4d */ - unsigned short e_cblp; /* Bytes on last page of file, 0x90 */ - unsigned short e_cp; /* Pages in file, 0x3 */ - unsigned short e_crlc; /* Relocations, 0x0 */ - unsigned short e_cparhdr; /* Size of header in paragraphs, 0x4 */ - unsigned short e_minalloc; /* Minimum extra paragraphs needed, 0x0 */ - unsigned short e_maxalloc; /* Maximum extra paragraphs needed, 0xFFFF */ - unsigned short e_ss; /* Initial (relative) SS value, 0x0 */ - unsigned short e_sp; /* Initial SP value, 0xb8 */ - unsigned short e_csum; /* Checksum, 0x0 */ - unsigned short e_ip; /* Initial IP value, 0x0 */ - unsigned short e_cs; /* Initial (relative) CS value, 0x0 */ - unsigned short e_lfarlc; /* File address of relocation table, 0x40 */ - unsigned short e_ovno; /* Overlay number, 0x0 */ - char e_res[4][2]; /* Reserved words, all 0x0 */ - unsigned short e_oemid; /* OEM identifier (for e_oeminfo), 0x0 */ - unsigned short e_oeminfo; /* OEM information; e_oemid specific, 0x0 */ - char e_res2[10][2]; /* Reserved words, all 0x0 */ - unsigned long e_lfanew; /* File address of new exe header, 0x80 */ - char dos_message[16][4]; /* other stuff, always follow DOS header */ - unsigned int nt_signature; /* required NT signature, 0x4550 */ - - /* From standard header */ - - unsigned short f_magic; /* magic number */ - unsigned short f_nscns; /* number of sections */ - unsigned long f_timdat; /* time & date stamp */ - unsigned long f_symptr; /* file pointer to symtab */ - unsigned long f_nsyms; /* number of symtab entries */ - unsigned short f_opthdr; /* sizeof(optional hdr) */ - unsigned short f_flags; /* flags */ -}; - - -#define FILHDR struct external_PE_filehdr -#undef FILHSZ -#define FILHSZ 152 - -#endif - -typedef struct -{ - unsigned short magic; /* type of file */ - unsigned short vstamp; /* version stamp */ - unsigned long tsize; /* text size in bytes, padded to FW bdry*/ - unsigned long dsize; /* initialized data " " */ - unsigned long bsize; /* uninitialized data " " */ - unsigned long entry; /* entry pt. */ - unsigned long text_start; /* base of text used for this file */ - unsigned long data_start; /* base of all data used for this file */ - - /* NT extra fields; see internal.h for descriptions */ - unsigned long ImageBase; - unsigned long SectionAlignment; - unsigned long FileAlignment; - unsigned short MajorOperatingSystemVersion; - unsigned short MinorOperatingSystemVersion; - unsigned short MajorImageVersion; - unsigned short MinorImageVersion; - unsigned short MajorSubsystemVersion; - unsigned short MinorSubsystemVersion; - char Reserved1[4]; - unsigned long SizeOfImage; - unsigned long SizeOfHeaders; - unsigned long CheckSum; - unsigned short Subsystem; - unsigned short DllCharacteristics; - unsigned long SizeOfStackReserve; - unsigned long SizeOfStackCommit; - unsigned long SizeOfHeapReserve; - unsigned long SizeOfHeapCommit; - unsigned long LoaderFlags; - unsigned long NumberOfRvaAndSizes; - /* IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; */ - char DataDirectory[16][2][4]; /* 16 entries, 2 elements/entry, 4 chars */ - -} PEAOUTHDR; - - -#undef AOUTSZ -#define AOUTSZ (AOUTHDRSZ + 196) - -#undef E_FILNMLEN -#define E_FILNMLEN 18 /* # characters in a file name */ -#endif - -/* end of coff/pe.h */ - -#define DT_NON (0) /* no derived type */ -#define DT_PTR (1) /* pointer */ -#define DT_FCN (2) /* function */ -#define DT_ARY (3) /* array */ - -#define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT)) -#define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT)) -#define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT)) - -#ifdef __cplusplus -} -#endif - -#endif /* _A_OUT_H_ */ - diff --git a/winsup/cygwin/include/arpa/ftp.h b/winsup/cygwin/include/arpa/ftp.h deleted file mode 100644 index 7d39a3e7a..000000000 --- a/winsup/cygwin/include/arpa/ftp.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 1983, 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - * - * @(#)ftp.h 8.1 (Berkeley) 6/2/93 - */ - -#ifndef _ARPA_FTP_H -#define _ARPA_FTP_H - -/* Definitions for FTP; see RFC-765. */ - -/* - * Reply codes. - */ -#define PRELIM 1 /* positive preliminary */ -#define COMPLETE 2 /* positive completion */ -#define CONTINUE 3 /* positive intermediate */ -#define TRANSIENT 4 /* transient negative completion */ -#define ERROR 5 /* permanent negative completion */ - -/* - * Type codes - */ -#define TYPE_A 1 /* ASCII */ -#define TYPE_E 2 /* EBCDIC */ -#define TYPE_I 3 /* image */ -#define TYPE_L 4 /* local byte size */ - -#ifdef FTP_NAMES -char *typenames[] = {"0", "ASCII", "EBCDIC", "Image", "Local" }; -#endif - -/* - * Form codes - */ -#define FORM_N 1 /* non-print */ -#define FORM_T 2 /* telnet format effectors */ -#define FORM_C 3 /* carriage control (ASA) */ -#ifdef FTP_NAMES -char *formnames[] = {"0", "Nonprint", "Telnet", "Carriage-control" }; -#endif - -/* - * Structure codes - */ -#define STRU_F 1 /* file (no record structure) */ -#define STRU_R 2 /* record structure */ -#define STRU_P 3 /* page structure */ -#ifdef FTP_NAMES -char *strunames[] = {"0", "File", "Record", "Page" }; -#endif - -/* - * Mode types - */ -#define MODE_S 1 /* stream */ -#define MODE_B 2 /* block */ -#define MODE_C 3 /* compressed */ -#ifdef FTP_NAMES -char *modenames[] = {"0", "Stream", "Block", "Compressed" }; -#endif - -/* - * Record Tokens - */ -#define REC_ESC '\377' /* Record-mode Escape */ -#define REC_EOR '\001' /* Record-mode End-of-Record */ -#define REC_EOF '\002' /* Record-mode End-of-File */ - -/* - * Block Header - */ -#define BLK_EOR 0x80 /* Block is End-of-Record */ -#define BLK_EOF 0x40 /* Block is End-of-File */ -#define BLK_ERRORS 0x20 /* Block is suspected of containing errors */ -#define BLK_RESTART 0x10 /* Block is Restart Marker */ - -#define BLK_BYTECOUNT 2 /* Bytes in this block */ - -#endif /* !_ARPA_FTP_H */ diff --git a/winsup/cygwin/include/arpa/inet.h b/winsup/cygwin/include/arpa/inet.h deleted file mode 100644 index d6b19fce7..000000000 --- a/winsup/cygwin/include/arpa/inet.h +++ /dev/null @@ -1,37 +0,0 @@ -/* arpa/inet.h - - Copyright 1997, 1998, 2001, 2002, 2003 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _ARPA_INET_H -#define _ARPA_INET_H - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -#ifndef __INSIDE_CYGWIN_NET__ -in_addr_t inet_addr (const char *); -int inet_aton (const char *, struct in_addr *); -in_addr_t inet_lnaof (struct in_addr); -struct in_addr inet_makeaddr (unsigned long , unsigned long); -in_addr_t inet_netof (struct in_addr); -in_addr_t inet_network (const char *); -char *inet_ntoa (struct in_addr); -int inet_pton (int, const char *, void *); -const char *inet_ntop (int, const void *, char *, socklen_t); -#endif - -#ifdef __cplusplus -}; -#endif - -#endif /* _ARPA_INET_H */ diff --git a/winsup/cygwin/include/arpa/nameser.h b/winsup/cygwin/include/arpa/nameser.h deleted file mode 100755 index 3980933f5..000000000 --- a/winsup/cygwin/include/arpa/nameser.h +++ /dev/null @@ -1,563 +0,0 @@ -/* - * Copyright (c) 1983, 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - */ - -/* - * Copyright (c) 1996-1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -/* - * $Id$ - */ - -#ifndef _ARPA_NAMESER_H_ -#define _ARPA_NAMESER_H_ - -#ifdef __CYGWIN__ -#define BSD 199903 /* Used inside the .h file */ -#endif - -#define BIND_4_COMPAT - -#include -#if (!defined(BSD)) || (BSD < 199306) -# include -#else -# include -#endif -#include - -/* - * Revision information. This is the release date in YYYYMMDD format. - * It can change every day so the right thing to do with it is use it - * in preprocessor commands such as "#if (__NAMESER > 19931104)". Do not - * compare for equality; rather, use it to determine whether your libbind.a - * contains a new enough lib/nameser/ to support the feature you need. - */ - -#define __NAMESER 19991006 /* New interface version stamp. */ - -/* - * Define constants based on RFC 883, RFC 1034, RFC 1035 - */ -#define NS_PACKETSZ 512 /* maximum packet size */ -#define NS_MAXDNAME 1025 /* maximum domain name */ -#define NS_MAXCDNAME 255 /* maximum compressed domain name */ -#define NS_MAXLABEL 63 /* maximum length of domain label */ -#define NS_HFIXEDSZ 12 /* #/bytes of fixed data in header */ -#define NS_QFIXEDSZ 4 /* #/bytes of fixed data in query */ -#define NS_RRFIXEDSZ 10 /* #/bytes of fixed data in r record */ -#define NS_INT32SZ 4 /* #/bytes of data in a u_int32_t */ -#define NS_INT16SZ 2 /* #/bytes of data in a u_int16_t */ -#define NS_INT8SZ 1 /* #/bytes of data in a u_int8_t */ -#define NS_INADDRSZ 4 /* IPv4 T_A */ -#define NS_IN6ADDRSZ 16 /* IPv6 T_AAAA */ -#define NS_CMPRSFLGS 0xc0 /* Flag bits indicating name compression. */ -#define NS_DEFAULTPORT 53 /* For both TCP and UDP. */ - -/* - * These can be expanded with synonyms, just keep ns_parse.c:ns_parserecord() - * in synch with it. - */ -typedef enum __ns_sect { - ns_s_qd = 0, /* Query: Question. */ - ns_s_zn = 0, /* Update: Zone. */ - ns_s_an = 1, /* Query: Answer. */ - ns_s_pr = 1, /* Update: Prerequisites. */ - ns_s_ns = 2, /* Query: Name servers. */ - ns_s_ud = 2, /* Update: Update. */ - ns_s_ar = 3, /* Query|Update: Additional records. */ - ns_s_max = 4 -} ns_sect; - -/* - * This is a message handle. It is caller allocated and has no dynamic data. - * This structure is intended to be opaque to all but ns_parse.c, thus the - * leading _'s on the member names. Use the accessor functions, not the _'s. - */ -typedef struct __ns_msg { - const u_char *_msg, *_eom; - u_int16_t _id, _flags, _counts[ns_s_max]; - const u_char *_sections[ns_s_max]; - ns_sect _sect; - int _rrnum; - const u_char *_msg_ptr; -} ns_msg; - -/* Private data structure - do not use from outside library. */ -struct _ns_flagdata { int mask, shift; }; -extern struct _ns_flagdata _ns_flagdata[]; - -/* Accessor macros - this is part of the public interface. */ - -#define ns_msg_id(handle) ((handle)._id + 0) -#define ns_msg_base(handle) ((handle)._msg + 0) -#define ns_msg_end(handle) ((handle)._eom + 0) -#define ns_msg_size(handle) ((handle)._eom - (handle)._msg) -#define ns_msg_count(handle, section) ((handle)._counts[section] + 0) - -/* - * This is a parsed record. It is caller allocated and has no dynamic data. - */ -typedef struct __ns_rr { - char name[NS_MAXDNAME]; - u_int16_t type; - u_int16_t rr_class; - u_int32_t ttl; - u_int16_t rdlength; - const u_char * rdata; -} ns_rr; - -/* Accessor macros - this is part of the public interface. */ -#define ns_rr_name(rr) (((rr).name[0] != '\0') ? (rr).name : ".") -#define ns_rr_type(rr) ((ns_type)((rr).type + 0)) -#define ns_rr_class(rr) ((ns_class)((rr).rr_class + 0)) -#define ns_rr_ttl(rr) ((rr).ttl + 0) -#define ns_rr_rdlen(rr) ((rr).rdlength + 0) -#define ns_rr_rdata(rr) ((rr).rdata + 0) - -/* - * These don't have to be in the same order as in the packet flags word, - * and they can even overlap in some cases, but they will need to be kept - * in synch with ns_parse.c:ns_flagdata[]. - */ -typedef enum __ns_flag { - ns_f_qr, /* Question/Response. */ - ns_f_opcode, /* Operation code. */ - ns_f_aa, /* Authoritative Answer. */ - ns_f_tc, /* Truncation occurred. */ - ns_f_rd, /* Recursion Desired. */ - ns_f_ra, /* Recursion Available. */ - ns_f_z, /* MBZ. */ - ns_f_ad, /* Authentic Data (DNSSEC). */ - ns_f_cd, /* Checking Disabled (DNSSEC). */ - ns_f_rcode, /* Response code. */ - ns_f_max -} ns_flag; - -/* - * Currently defined opcodes. - */ -typedef enum __ns_opcode { - ns_o_query = 0, /* Standard query. */ - ns_o_iquery = 1, /* Inverse query (deprecated/unsupported). */ - ns_o_status = 2, /* Name server status query (unsupported). */ - /* Opcode 3 is undefined/reserved. */ - ns_o_notify = 4, /* Zone change notification. */ - ns_o_update = 5, /* Zone update message. */ - ns_o_max = 6 -} ns_opcode; - -/* - * Currently defined response codes. - */ -typedef enum __ns_rcode { - ns_r_noerror = 0, /* No error occurred. */ - ns_r_formerr = 1, /* Format error. */ - ns_r_servfail = 2, /* Server failure. */ - ns_r_nxdomain = 3, /* Name error. */ - ns_r_notimpl = 4, /* Unimplemented. */ - ns_r_refused = 5, /* Operation refused. */ - /* these are for BIND_UPDATE */ - ns_r_yxdomain = 6, /* Name exists */ - ns_r_yxrrset = 7, /* RRset exists */ - ns_r_nxrrset = 8, /* RRset does not exist */ - ns_r_notauth = 9, /* Not authoritative for zone */ - ns_r_notzone = 10, /* Zone of record different from zone section */ - ns_r_max = 11, - /* The following are TSIG extended errors */ - ns_r_badsig = 16, - ns_r_badkey = 17, - ns_r_badtime = 18 -} ns_rcode; - -/* BIND_UPDATE */ -typedef enum __ns_update_operation { - ns_uop_delete = 0, - ns_uop_add = 1, - ns_uop_max = 2 -} ns_update_operation; - -/* - * This structure is used for TSIG authenticated messages - */ -struct ns_tsig_key { - char name[NS_MAXDNAME], alg[NS_MAXDNAME]; - unsigned char *data; - int len; -}; -typedef struct ns_tsig_key ns_tsig_key; - -/* - * This structure is used for TSIG authenticated TCP messages - */ -struct ns_tcp_tsig_state { - int counter; - struct dst_key *key; - void *ctx; - unsigned char sig[NS_PACKETSZ]; - int siglen; -}; -typedef struct ns_tcp_tsig_state ns_tcp_tsig_state; - -#define NS_TSIG_FUDGE 300 -#define NS_TSIG_TCP_COUNT 100 -#define NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT" - -#define NS_TSIG_ERROR_NO_TSIG -10 -#define NS_TSIG_ERROR_NO_SPACE -11 -#define NS_TSIG_ERROR_FORMERR -12 - -/* - * Currently defined type values for resources and queries. - */ -typedef enum __ns_type { - ns_t_invalid = 0, /* Cookie. */ - ns_t_a = 1, /* Host address. */ - ns_t_ns = 2, /* Authoritative server. */ - ns_t_md = 3, /* Mail destination. */ - ns_t_mf = 4, /* Mail forwarder. */ - ns_t_cname = 5, /* Canonical name. */ - ns_t_soa = 6, /* Start of authority zone. */ - ns_t_mb = 7, /* Mailbox domain name. */ - ns_t_mg = 8, /* Mail group member. */ - ns_t_mr = 9, /* Mail rename name. */ - ns_t_null = 10, /* Null resource record. */ - ns_t_wks = 11, /* Well known service. */ - ns_t_ptr = 12, /* Domain name pointer. */ - ns_t_hinfo = 13, /* Host information. */ - ns_t_minfo = 14, /* Mailbox information. */ - ns_t_mx = 15, /* Mail routing information. */ - ns_t_txt = 16, /* Text strings. */ - ns_t_rp = 17, /* Responsible person. */ - ns_t_afsdb = 18, /* AFS cell database. */ - ns_t_x25 = 19, /* X_25 calling address. */ - ns_t_isdn = 20, /* ISDN calling address. */ - ns_t_rt = 21, /* Router. */ - ns_t_nsap = 22, /* NSAP address. */ - ns_t_nsap_ptr = 23, /* Reverse NSAP lookup (deprecated). */ - ns_t_sig = 24, /* Security signature. */ - ns_t_key = 25, /* Security key. */ - ns_t_px = 26, /* X.400 mail mapping. */ - ns_t_gpos = 27, /* Geographical position (withdrawn). */ - ns_t_aaaa = 28, /* Ip6 Address. */ - ns_t_loc = 29, /* Location Information. */ - ns_t_nxt = 30, /* Next domain (security). */ - ns_t_eid = 31, /* Endpoint identifier. */ - ns_t_nimloc = 32, /* Nimrod Locator. */ - ns_t_srv = 33, /* Server Selection. */ - ns_t_atma = 34, /* ATM Address */ - ns_t_naptr = 35, /* Naming Authority PoinTeR */ - ns_t_kx = 36, /* Key Exchange */ - ns_t_cert = 37, /* Certification record */ - ns_t_a6 = 38, /* IPv6 address (deprecates AAAA) */ - ns_t_dname = 39, /* Non-terminal DNAME (for IPv6) */ - ns_t_sink = 40, /* Kitchen sink (experimentatl) */ - ns_t_opt = 41, /* EDNS0 option (meta-RR) */ - ns_t_tkey = 249, /* Transaction key */ - ns_t_tsig = 250, /* Transaction signature. */ - ns_t_ixfr = 251, /* Incremental zone transfer. */ - ns_t_axfr = 252, /* Transfer zone of authority. */ - ns_t_mailb = 253, /* Transfer mailbox records. */ - ns_t_maila = 254, /* Transfer mail agent records. */ - ns_t_any = 255, /* Wildcard match. */ - ns_t_zxfr = 256, /* BIND-specific, nonstandard. */ - ns_t_max = 65536 -} ns_type; - -/* Exclusively a QTYPE? (not also an RTYPE) */ -#define ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || \ - (t) == ns_t_mailb || (t) == ns_t_maila) -/* Some kind of meta-RR? (not a QTYPE, but also not an RTYPE) */ -#define ns_t_mrr_p(t) ((t) == ns_t_tsig || (t) == ns_t_opt) -/* Exclusively an RTYPE? (not also a QTYPE or a meta-RR) */ -#define ns_t_rr_p(t) (!ns_t_qt_p(t) && !ns_t_mrr_p(t)) -#define ns_t_udp_p(t) ((t) != ns_t_axfr && (t) != ns_t_zxfr) -#define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || \ - (t) == ns_t_zxfr) - -/* - * Values for class field - */ -typedef enum __ns_class { - ns_c_invalid = 0, /* Cookie. */ - ns_c_in = 1, /* Internet. */ - ns_c_2 = 2, /* unallocated/unsupported. */ - ns_c_chaos = 3, /* MIT Chaos-net. */ - ns_c_hs = 4, /* MIT Hesiod. */ - /* Query class values which do not appear in resource records */ - ns_c_none = 254, /* for prereq. sections in update requests */ - ns_c_any = 255, /* Wildcard match. */ - ns_c_max = 65536 -} ns_class; - -/* DNSSEC constants. */ - -typedef enum __ns_key_types { - ns_kt_rsa = 1, /* key type RSA/MD5 */ - ns_kt_dh = 2, /* Diffie Hellman */ - ns_kt_dsa = 3, /* Digital Signature Standard (MANDATORY) */ - ns_kt_private = 254 /* Private key type starts with OID */ -} ns_key_types; - -typedef enum __ns_cert_types { - cert_t_pkix = 1, /* PKIX (X.509v3) */ - cert_t_spki = 2, /* SPKI */ - cert_t_pgp = 3, /* PGP */ - cert_t_url = 253, /* URL private type */ - cert_t_oid = 254 /* OID private type */ -} ns_cert_types; - -/* Flags field of the KEY RR rdata. */ -#define NS_KEY_TYPEMASK 0xC000 /* Mask for "type" bits */ -#define NS_KEY_TYPE_AUTH_CONF 0x0000 /* Key usable for both */ -#define NS_KEY_TYPE_CONF_ONLY 0x8000 /* Key usable for confidentiality */ -#define NS_KEY_TYPE_AUTH_ONLY 0x4000 /* Key usable for authentication */ -#define NS_KEY_TYPE_NO_KEY 0xC000 /* No key usable for either; no key */ -/* The type bits can also be interpreted independently, as single bits: */ -#define NS_KEY_NO_AUTH 0x8000 /* Key unusable for authentication */ -#define NS_KEY_NO_CONF 0x4000 /* Key unusable for confidentiality */ -#define NS_KEY_RESERVED2 0x2000 /* Security is *mandatory* if bit=0 */ -#define NS_KEY_EXTENDED_FLAGS 0x1000 /* reserved - must be zero */ -#define NS_KEY_RESERVED4 0x0800 /* reserved - must be zero */ -#define NS_KEY_RESERVED5 0x0400 /* reserved - must be zero */ -#define NS_KEY_NAME_TYPE 0x0300 /* these bits determine the type */ -#define NS_KEY_NAME_USER 0x0000 /* key is assoc. with user */ -#define NS_KEY_NAME_ENTITY 0x0200 /* key is assoc. with entity eg host */ -#define NS_KEY_NAME_ZONE 0x0100 /* key is zone key */ -#define NS_KEY_NAME_RESERVED 0x0300 /* reserved meaning */ -#define NS_KEY_RESERVED8 0x0080 /* reserved - must be zero */ -#define NS_KEY_RESERVED9 0x0040 /* reserved - must be zero */ -#define NS_KEY_RESERVED10 0x0020 /* reserved - must be zero */ -#define NS_KEY_RESERVED11 0x0010 /* reserved - must be zero */ -#define NS_KEY_SIGNATORYMASK 0x000F /* key can sign RR's of same name */ -#define NS_KEY_RESERVED_BITMASK ( NS_KEY_RESERVED2 | \ - NS_KEY_RESERVED4 | \ - NS_KEY_RESERVED5 | \ - NS_KEY_RESERVED8 | \ - NS_KEY_RESERVED9 | \ - NS_KEY_RESERVED10 | \ - NS_KEY_RESERVED11 ) -#define NS_KEY_RESERVED_BITMASK2 0xFFFF /* no bits defined here */ - -/* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */ -#define NS_ALG_MD5RSA 1 /* MD5 with RSA */ -#define NS_ALG_DH 2 /* Diffie Hellman KEY */ -#define NS_ALG_DSA 3 /* DSA KEY */ -#define NS_ALG_DSS NS_ALG_DSA -#define NS_ALG_EXPIRE_ONLY 253 /* No alg, no security */ -#define NS_ALG_PRIVATE_OID 254 /* Key begins with OID giving alg */ - -/* Protocol values */ -/* value 0 is reserved */ -#define NS_KEY_PROT_TLS 1 -#define NS_KEY_PROT_EMAIL 2 -#define NS_KEY_PROT_DNSSEC 3 -#define NS_KEY_PROT_IPSEC 4 -#define NS_KEY_PROT_ANY 255 - -/* Signatures */ -#define NS_MD5RSA_MIN_BITS 512 /* Size of a mod or exp in bits */ -#define NS_MD5RSA_MAX_BITS 2552 - /* Total of binary mod and exp */ -#define NS_MD5RSA_MAX_BYTES ((NS_MD5RSA_MAX_BITS+7/8)*2+3) - /* Max length of text sig block */ -#define NS_MD5RSA_MAX_BASE64 (((NS_MD5RSA_MAX_BYTES+2)/3)*4) -#define NS_MD5RSA_MIN_SIZE ((NS_MD5RSA_MIN_BITS+7)/8) -#define NS_MD5RSA_MAX_SIZE ((NS_MD5RSA_MAX_BITS+7)/8) - -#define NS_DSA_SIG_SIZE 41 -#define NS_DSA_MIN_SIZE 213 -#define NS_DSA_MAX_BYTES 405 - -/* Offsets into SIG record rdata to find various values */ -#define NS_SIG_TYPE 0 /* Type flags */ -#define NS_SIG_ALG 2 /* Algorithm */ -#define NS_SIG_LABELS 3 /* How many labels in name */ -#define NS_SIG_OTTL 4 /* Original TTL */ -#define NS_SIG_EXPIR 8 /* Expiration time */ -#define NS_SIG_SIGNED 12 /* Signature time */ -#define NS_SIG_FOOT 16 /* Key footprint */ -#define NS_SIG_SIGNER 18 /* Domain name of who signed it */ - -/* How RR types are represented as bit-flags in NXT records */ -#define NS_NXT_BITS 8 -#define NS_NXT_BIT_SET( n,p) (p[(n)/NS_NXT_BITS] |= (0x80>>((n)%NS_NXT_BITS))) -#define NS_NXT_BIT_CLEAR(n,p) (p[(n)/NS_NXT_BITS] &= ~(0x80>>((n)%NS_NXT_BITS))) -#define NS_NXT_BIT_ISSET(n,p) (p[(n)/NS_NXT_BITS] & (0x80>>((n)%NS_NXT_BITS))) -#define NS_NXT_MAX 127 - -/* - * Inline versions of get/put short/long. Pointer is advanced. - */ -#define NS_GET16(s, cp) do { \ - register const u_char *t_cp = (const u_char *)(cp); \ - (s) = ((u_int16_t)t_cp[0] << 8) \ - | ((u_int16_t)t_cp[1]) \ - ; \ - (cp) += NS_INT16SZ; \ -} while (0) - -#define NS_GET32(l, cp) do { \ - register const u_char *t_cp = (const u_char *)(cp); \ - (l) = ((u_int32_t)t_cp[0] << 24) \ - | ((u_int32_t)t_cp[1] << 16) \ - | ((u_int32_t)t_cp[2] << 8) \ - | ((u_int32_t)t_cp[3]) \ - ; \ - (cp) += NS_INT32SZ; \ -} while (0) - -#define NS_PUT16(s, cp) do { \ - register u_int16_t t_s = (u_int16_t)(s); \ - register u_char *t_cp = (u_char *)(cp); \ - *t_cp++ = t_s >> 8; \ - *t_cp = t_s; \ - (cp) += NS_INT16SZ; \ -} while (0) - -#define NS_PUT32(l, cp) do { \ - register u_int32_t t_l = (u_int32_t)(l); \ - register u_char *t_cp = (u_char *)(cp); \ - *t_cp++ = t_l >> 24; \ - *t_cp++ = t_l >> 16; \ - *t_cp++ = t_l >> 8; \ - *t_cp = t_l; \ - (cp) += NS_INT32SZ; \ -} while (0) - -/* - * ANSI C identifier hiding for bind's lib/nameser. - */ -#define ns_msg_getflag __ns_msg_getflag -#define ns_get16 __ns_get16 -#define ns_get32 __ns_get32 -#define ns_put16 __ns_put16 -#define ns_put32 __ns_put32 -#define ns_initparse __ns_initparse -#define ns_skiprr __ns_skiprr -#define ns_parserr __ns_parserr -#define ns_sprintrr __ns_sprintrr -#define ns_sprintrrf __ns_sprintrrf -#define ns_format_ttl __ns_format_ttl -#define ns_parse_ttl __ns_parse_ttl -#define ns_datetosecs __ns_datetosecs -#define ns_name_ntol __ns_name_ntol -#define ns_name_ntop __ns_name_ntop -#define ns_name_pton __ns_name_pton -#define ns_name_unpack __ns_name_unpack -#define ns_name_pack __ns_name_pack -#define ns_name_compress __ns_name_compress -#define ns_name_uncompress __ns_name_uncompress -#define ns_name_skip __ns_name_skip -#define ns_name_rollback __ns_name_rollback -#define ns_sign __ns_sign -#define ns_sign_tcp __ns_sign_tcp -#define ns_sign_tcp_init __ns_sign_tcp_init -#define ns_find_tsig __ns_find_tsig -#define ns_verify __ns_verify -#define ns_verify_tcp __ns_verify_tcp -#define ns_verify_tcp_init __ns_verify_tcp_init -#define ns_samedomain __ns_samedomain -#define ns_subdomain __ns_subdomain -#define ns_makecanon __ns_makecanon -#define ns_samename __ns_samename - -__BEGIN_DECLS -int ns_msg_getflag __P((ns_msg, int)); -u_int ns_get16 __P((const u_char *)); -u_long ns_get32 __P((const u_char *)); -void ns_put16 __P((u_int, u_char *)); -void ns_put32 __P((u_long, u_char *)); -int ns_initparse __P((const u_char *, int, ns_msg *)); -int ns_skiprr __P((const u_char *, const u_char *, ns_sect, int)); -int ns_parserr __P((ns_msg *, ns_sect, int, ns_rr *)); -int ns_sprintrr __P((const ns_msg *, const ns_rr *, - const char *, const char *, char *, size_t)); -int ns_sprintrrf __P((const u_char *, size_t, const char *, - ns_class, ns_type, u_long, const u_char *, - size_t, const char *, const char *, - char *, size_t)); -int ns_format_ttl __P((u_long, char *, size_t)); -int ns_parse_ttl __P((const char *, u_long *)); -u_int32_t ns_datetosecs __P((const char *cp, int *errp)); -int ns_name_ntol __P((const u_char *, u_char *, size_t)); -int ns_name_ntop __P((const u_char *, char *, size_t)); -int ns_name_pton __P((const char *, u_char *, size_t)); -int ns_name_unpack __P((const u_char *, const u_char *, - const u_char *, u_char *, size_t)); -int ns_name_pack __P((const u_char *, u_char *, int, - const u_char **, const u_char **)); -int ns_name_uncompress __P((const u_char *, const u_char *, - const u_char *, char *, size_t)); -int ns_name_compress __P((const char *, u_char *, size_t, - const u_char **, const u_char **)); -int ns_name_skip __P((const u_char **, const u_char *)); -void ns_name_rollback __P((const u_char *, const u_char **, - const u_char **)); -int ns_sign __P((u_char *, int *, int, int, void *, - const u_char *, int, u_char *, int *, time_t)); -int ns_sign_tcp __P((u_char *, int *, int, int, - ns_tcp_tsig_state *, int)); -int ns_sign_tcp_init __P((void *, const u_char *, int, - ns_tcp_tsig_state *)); -u_char *ns_find_tsig __P((u_char *, u_char *)); -int ns_verify __P((u_char *, int *, void *, - const u_char *, int, u_char *, int *, - time_t *, int)); -int ns_verify_tcp __P((u_char *, int *, ns_tcp_tsig_state *, int)); -int ns_verify_tcp_init __P((void *, const u_char *, int, - ns_tcp_tsig_state *)); -int ns_samedomain __P((const char *, const char *)); -int ns_subdomain __P((const char *, const char *)); -int ns_makecanon __P((const char *, char *, size_t)); -int ns_samename __P((const char *, const char *)); -__END_DECLS - -#ifdef BIND_4_COMPAT -#include -#endif - -#endif /* !_ARPA_NAMESER_H_ */ diff --git a/winsup/cygwin/include/arpa/nameser_compat.h b/winsup/cygwin/include/arpa/nameser_compat.h deleted file mode 100755 index a75f9bc13..000000000 --- a/winsup/cygwin/include/arpa/nameser_compat.h +++ /dev/null @@ -1,231 +0,0 @@ -/* Copyright (c) 1983, 1989 - * The Regents of the University of California. All rights reserved. - * - * 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. - */ - -/* - * from nameser.h 8.1 (Berkeley) 6/2/93 - * $Id$ - */ - -#ifndef _ARPA_NAMESER_COMPAT_ -#define _ARPA_NAMESER_COMPAT_ - -#define __BIND 19950621 /* (DEAD) interface version stamp. */ - -#ifndef BYTE_ORDER -#if (BSD >= 199103) -# include -#else -#ifdef linux -# include -#else -#define LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */ -#define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */ -#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/ - -#if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \ - defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \ - defined(__alpha__) || defined(__alpha) || \ - (defined(__Lynx__) && defined(__x86__)) -#define BYTE_ORDER LITTLE_ENDIAN -#endif - -#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \ - defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \ - defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\ - defined(apollo) || defined(__convex__) || defined(_CRAY) || \ - defined(__hppa) || defined(__hp9000) || \ - defined(__hp9000s300) || defined(__hp9000s700) || \ - defined(__hp3000s900) || defined(MPE) || \ - defined (BIT_ZERO_ON_LEFT) || defined(m68k) || \ - (defined(__Lynx__) && \ - (defined(__68k__) || defined(__sparc__) || defined(__powerpc__))) -#define BYTE_ORDER BIG_ENDIAN -#endif -#endif /* linux */ -#endif /* BSD */ -#endif /* BYTE_ORDER */ - -#if !defined(BYTE_ORDER) || \ - (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN && \ - BYTE_ORDER != PDP_ENDIAN) - /* you must determine what the correct bit order is for - * your compiler - the next line is an intentional error - * which will force your compiles to bomb until you fix - * the above macros. - */ - error "Undefined or invalid BYTE_ORDER"; -#endif - -/* - * Structure for query header. The order of the fields is machine- and - * compiler-dependent, depending on the byte/bit order and the layout - * of bit fields. We use bit fields only in int variables, as this - * is all ANSI requires. This requires a somewhat confusing rearrangement. - */ - -typedef struct { - unsigned id :16; /* query identification number */ -#if BYTE_ORDER == BIG_ENDIAN - /* fields in third byte */ - unsigned qr: 1; /* response flag */ - unsigned opcode: 4; /* purpose of message */ - unsigned aa: 1; /* authoritive answer */ - unsigned tc: 1; /* truncated message */ - unsigned rd: 1; /* recursion desired */ - /* fields in fourth byte */ - unsigned ra: 1; /* recursion available */ - unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ - unsigned ad: 1; /* authentic data from named */ - unsigned cd: 1; /* checking disabled by resolver */ - unsigned rcode :4; /* response code */ -#endif -#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN - /* fields in third byte */ - unsigned rd :1; /* recursion desired */ - unsigned tc :1; /* truncated message */ - unsigned aa :1; /* authoritive answer */ - unsigned opcode :4; /* purpose of message */ - unsigned qr :1; /* response flag */ - /* fields in fourth byte */ - unsigned rcode :4; /* response code */ - unsigned cd: 1; /* checking disabled by resolver */ - unsigned ad: 1; /* authentic data from named */ - unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ - unsigned ra :1; /* recursion available */ -#endif - /* remaining bytes */ - unsigned qdcount :16; /* number of question entries */ - unsigned ancount :16; /* number of answer entries */ - unsigned nscount :16; /* number of authority entries */ - unsigned arcount :16; /* number of resource entries */ -} HEADER; - -#define PACKETSZ NS_PACKETSZ -#define MAXDNAME NS_MAXDNAME -#define MAXCDNAME NS_MAXCDNAME -#define MAXLABEL NS_MAXLABEL -#define HFIXEDSZ NS_HFIXEDSZ -#define QFIXEDSZ NS_QFIXEDSZ -#define RRFIXEDSZ NS_RRFIXEDSZ -#define INT32SZ NS_INT32SZ -#define INT16SZ NS_INT16SZ -#define INADDRSZ NS_INADDRSZ -#define IN6ADDRSZ NS_IN6ADDRSZ -#define INDIR_MASK NS_CMPRSFLGS -#define NAMESERVER_PORT NS_DEFAULTPORT - -#define S_ZONE ns_s_zn -#define S_PREREQ ns_s_pr -#define S_UPDATE ns_s_ud -#define S_ADDT ns_s_ar - -#define QUERY ns_o_query -#define IQUERY ns_o_iquery -#define STATUS ns_o_status -#define NS_NOTIFY_OP ns_o_notify -#define NS_UPDATE_OP ns_o_update - -#define NOERROR ns_r_noerror -#define FORMERR ns_r_formerr -#define SERVFAIL ns_r_servfail -#define NXDOMAIN ns_r_nxdomain -#define NOTIMP ns_r_notimpl -#define REFUSED ns_r_refused -#define YXDOMAIN ns_r_yxdomain -#define YXRRSET ns_r_yxrrset -#define NXRRSET ns_r_nxrrset -#define NOTAUTH ns_r_notauth -#define NOTZONE ns_r_notzone -/*#define BADSIG ns_r_badsig*/ -/*#define BADKEY ns_r_badkey*/ -/*#define BADTIME ns_r_badtime*/ - - -#define DELETE ns_uop_delete -#define ADD ns_uop_add - -#define T_A ns_t_a -#define T_NS ns_t_ns -#define T_MD ns_t_md -#define T_MF ns_t_mf -#define T_CNAME ns_t_cname -#define T_SOA ns_t_soa -#define T_MB ns_t_mb -#define T_MG ns_t_mg -#define T_MR ns_t_mr -#define T_NULL ns_t_null -#define T_WKS ns_t_wks -#define T_PTR ns_t_ptr -#define T_HINFO ns_t_hinfo -#define T_MINFO ns_t_minfo -#define T_MX ns_t_mx -#define T_TXT ns_t_txt -#define T_RP ns_t_rp -#define T_AFSDB ns_t_afsdb -#define T_X25 ns_t_x25 -#define T_ISDN ns_t_isdn -#define T_RT ns_t_rt -#define T_NSAP ns_t_nsap -#define T_NSAP_PTR ns_t_nsap_ptr -#define T_SIG ns_t_sig -#define T_KEY ns_t_key -#define T_PX ns_t_px -#define T_GPOS ns_t_gpos -#define T_AAAA ns_t_aaaa -#define T_LOC ns_t_loc -#define T_NXT ns_t_nxt -#define T_EID ns_t_eid -#define T_NIMLOC ns_t_nimloc -#define T_SRV ns_t_srv -#define T_ATMA ns_t_atma -#define T_NAPTR ns_t_naptr -#define T_A6 ns_t_a6 -#define T_TSIG ns_t_tsig -#define T_IXFR ns_t_ixfr -#define T_AXFR ns_t_axfr -#define T_MAILB ns_t_mailb -#define T_MAILA ns_t_maila -#define T_ANY ns_t_any - -#define C_IN ns_c_in -#define C_CHAOS ns_c_chaos -#define C_HS ns_c_hs -/* BIND_UPDATE */ -#define C_NONE ns_c_none -#define C_ANY ns_c_any - -#define GETSHORT NS_GET16 -#define GETLONG NS_GET32 -#define PUTSHORT NS_PUT16 -#define PUTLONG NS_PUT32 - -#endif /* _ARPA_NAMESER_COMPAT_ */ diff --git a/winsup/cygwin/include/arpa/telnet.h b/winsup/cygwin/include/arpa/telnet.h deleted file mode 100644 index 50874765c..000000000 --- a/winsup/cygwin/include/arpa/telnet.h +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - * - * @(#)telnet.h 8.2 (Berkeley) 12/15/93 - */ - -#ifndef _ARPA_TELNET_H -#define _ARPA_TELNET_H - -/* - * Definitions for the TELNET protocol. - */ -#define IAC 255 /* interpret as command: */ -#define DONT 254 /* you are not to use option */ -#define DO 253 /* please, you use option */ -#define WONT 252 /* I won't use option */ -#define WILL 251 /* I will use option */ -#define SB 250 /* interpret as subnegotiation */ -#define GA 249 /* you may reverse the line */ -#define EL 248 /* erase the current line */ -#define EC 247 /* erase the current character */ -#define AYT 246 /* are you there */ -#define AO 245 /* abort output--but let prog finish */ -#define IP 244 /* interrupt process--permanently */ -#define BREAK 243 /* break */ -#define DM 242 /* data mark--for connect. cleaning */ -#define NOP 241 /* nop */ -#define SE 240 /* end sub negotiation */ -#define EOR 239 /* end of record (transparent mode) */ -#define ABORT 238 /* Abort process */ -#define SUSP 237 /* Suspend process */ -#define xEOF 236 /* End of file: EOF is already used... */ - -#define SYNCH 242 /* for telfunc calls */ - -#ifdef TELCMDS -char *telcmds[] = { - "EOF", "SUSP", "ABORT", "EOR", - "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", - "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0, -}; -#else -extern char *telcmds[]; -#endif - -#define TELCMD_FIRST xEOF -#define TELCMD_LAST IAC -#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \ - (unsigned int)(x) >= TELCMD_FIRST) -#define TELCMD(x) telcmds[(x)-TELCMD_FIRST] - -/* telnet options */ -#define TELOPT_BINARY 0 /* 8-bit data path */ -#define TELOPT_ECHO 1 /* echo */ -#define TELOPT_RCP 2 /* prepare to reconnect */ -#define TELOPT_SGA 3 /* suppress go ahead */ -#define TELOPT_NAMS 4 /* approximate message size */ -#define TELOPT_STATUS 5 /* give status */ -#define TELOPT_TM 6 /* timing mark */ -#define TELOPT_RCTE 7 /* remote controlled transmission and echo */ -#define TELOPT_NAOL 8 /* negotiate about output line width */ -#define TELOPT_NAOP 9 /* negotiate about output page size */ -#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */ -#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */ -#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */ -#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */ -#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */ -#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */ -#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */ -#define TELOPT_XASCII 17 /* extended ascic character set */ -#define TELOPT_LOGOUT 18 /* force logout */ -#define TELOPT_BM 19 /* byte macro */ -#define TELOPT_DET 20 /* data entry terminal */ -#define TELOPT_SUPDUP 21 /* supdup protocol */ -#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */ -#define TELOPT_SNDLOC 23 /* send location */ -#define TELOPT_TTYPE 24 /* terminal type */ -#define TELOPT_EOR 25 /* end or record */ -#define TELOPT_TUID 26 /* TACACS user identification */ -#define TELOPT_OUTMRK 27 /* output marking */ -#define TELOPT_TTYLOC 28 /* terminal location number */ -#define TELOPT_3270REGIME 29 /* 3270 regime */ -#define TELOPT_X3PAD 30 /* X.3 PAD */ -#define TELOPT_NAWS 31 /* window size */ -#define TELOPT_TSPEED 32 /* terminal speed */ -#define TELOPT_LFLOW 33 /* remote flow control */ -#define TELOPT_LINEMODE 34 /* Linemode option */ -#define TELOPT_XDISPLOC 35 /* X Display Location */ -#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */ -#define TELOPT_AUTHENTICATION 37/* Authenticate */ -#define TELOPT_ENCRYPT 38 /* Encryption option */ -#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */ -#define TELOPT_EXOPL 255 /* extended-options-list */ -#define TELOPT_ENVIRON TELOPT_OLD_ENVIRON - -#define NTELOPTS (1+TELOPT_NEW_ENVIRON) -#ifdef TELOPTS -char *telopts[NTELOPTS+1] = { - "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", - "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP", - "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS", - "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO", - "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT", - "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD", - "TACACS UID", "OUTPUT MARKING", "TTYLOC", - "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW", - "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION", - "ENCRYPT", "NEW-ENVIRON", - 0, -}; -#define TELOPT_FIRST TELOPT_BINARY -#define TELOPT_LAST TELOPT_NEW_ENVIRON -#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST) -#define TELOPT(x) telopts[(x)-TELOPT_FIRST] -#endif - -/* sub-option qualifiers */ -#define TELQUAL_IS 0 /* option is... */ -#define TELQUAL_SEND 1 /* send option */ -#define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */ -#define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */ -#define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */ - -#define LFLOW_OFF 0 /* Disable remote flow control */ -#define LFLOW_ON 1 /* Enable remote flow control */ -#define LFLOW_RESTART_ANY 2 /* Restart output on any char */ -#define LFLOW_RESTART_XON 3 /* Restart output only on XON */ - -/* - * LINEMODE suboptions - */ - -#define LM_MODE 1 -#define LM_FORWARDMASK 2 -#define LM_SLC 3 - -#define MODE_EDIT 0x01 -#define MODE_TRAPSIG 0x02 -#define MODE_ACK 0x04 -#define MODE_SOFT_TAB 0x08 -#define MODE_LIT_ECHO 0x10 - -#define MODE_MASK 0x1f - -/* Not part of protocol, but needed to simplify things... */ -#define MODE_FLOW 0x0100 -#define MODE_ECHO 0x0200 -#define MODE_INBIN 0x0400 -#define MODE_OUTBIN 0x0800 -#define MODE_FORCE 0x1000 - -#define SLC_SYNCH 1 -#define SLC_BRK 2 -#define SLC_IP 3 -#define SLC_AO 4 -#define SLC_AYT 5 -#define SLC_EOR 6 -#define SLC_ABORT 7 -#define SLC_EOF 8 -#define SLC_SUSP 9 -#define SLC_EC 10 -#define SLC_EL 11 -#define SLC_EW 12 -#define SLC_RP 13 -#define SLC_LNEXT 14 -#define SLC_XON 15 -#define SLC_XOFF 16 -#define SLC_FORW1 17 -#define SLC_FORW2 18 - -#define NSLC 18 - -/* - * For backwards compatability, we define SLC_NAMES to be the - * list of names if SLC_NAMES is not defined. - */ -#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \ - "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \ - "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0, -#ifdef SLC_NAMES -char *slc_names[] = { - SLC_NAMELIST -}; -#else -extern char *slc_names[]; -#define SLC_NAMES SLC_NAMELIST -#endif - -#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC) -#define SLC_NAME(x) slc_names[x] - -#define SLC_NOSUPPORT 0 -#define SLC_CANTCHANGE 1 -#define SLC_VARIABLE 2 -#define SLC_DEFAULT 3 -#define SLC_LEVELBITS 0x03 - -#define SLC_FUNC 0 -#define SLC_FLAGS 1 -#define SLC_VALUE 2 - -#define SLC_ACK 0x80 -#define SLC_FLUSHIN 0x40 -#define SLC_FLUSHOUT 0x20 - -#define OLD_ENV_VAR 1 -#define OLD_ENV_VALUE 0 -#define NEW_ENV_VAR 0 -#define NEW_ENV_VALUE 1 -#define ENV_ESC 2 -#define ENV_USERVAR 3 - -#define ENV_VALUE 0 -#define ENV_VAR 1 - -/* - * AUTHENTICATION suboptions - */ - -/* - * Who is authenticating who ... - */ -#define AUTH_WHO_CLIENT 0 /* Client authenticating server */ -#define AUTH_WHO_SERVER 1 /* Server authenticating client */ -#define AUTH_WHO_MASK 1 - -/* - * amount of authentication done - */ -#define AUTH_HOW_ONE_WAY 0 -#define AUTH_HOW_MUTUAL 2 -#define AUTH_HOW_MASK 2 - -#define AUTHTYPE_NULL 0 -#define AUTHTYPE_KERBEROS_V4 1 -#define AUTHTYPE_KERBEROS_V5 2 -#define AUTHTYPE_SPX 3 -#define AUTHTYPE_MINK 4 -#define AUTHTYPE_CNT 5 - -#define AUTHTYPE_TEST 99 - -#ifdef AUTH_NAMES -char *authtype_names[] = { - "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0, -}; -#else -extern char *authtype_names[]; -#endif - -#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT) -#define AUTHTYPE_NAME(x) authtype_names[x] - -/* - * ENCRYPTion suboptions - */ -#define ENCRYPT_IS 0 /* I pick encryption type ... */ -#define ENCRYPT_SUPPORT 1 /* I support encryption types ... */ -#define ENCRYPT_REPLY 2 /* Initial setup response */ -#define ENCRYPT_START 3 /* Am starting to send encrypted */ -#define ENCRYPT_END 4 /* Am ending encrypted */ -#define ENCRYPT_REQSTART 5 /* Request you start encrypting */ -#define ENCRYPT_REQEND 6 /* Request you send encrypting */ -#define ENCRYPT_ENC_KEYID 7 -#define ENCRYPT_DEC_KEYID 8 -#define ENCRYPT_CNT 9 - -#define ENCTYPE_ANY 0 -#define ENCTYPE_DES_CFB64 1 -#define ENCTYPE_DES_OFB64 2 -#define ENCTYPE_CNT 3 - -#ifdef ENCRYPT_NAMES -char *encrypt_names[] = { - "IS", "SUPPORT", "REPLY", "START", "END", - "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID", - 0, -}; -char *enctype_names[] = { - "ANY", "DES_CFB64", "DES_OFB64", 0, -}; -#else -extern char *encrypt_names[]; -extern char *enctype_names[]; -#endif - - -#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT) -#define ENCRYPT_NAME(x) encrypt_names[x] - -#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT) -#define ENCTYPE_NAME(x) enctype_names[x] -#endif /* _ARPA_TELNET_H */ diff --git a/winsup/cygwin/include/asm/byteorder.h b/winsup/cygwin/include/asm/byteorder.h deleted file mode 100644 index 3727c5421..000000000 --- a/winsup/cygwin/include/asm/byteorder.h +++ /dev/null @@ -1,95 +0,0 @@ -/* asm/byteorder.h - - Copyright 1996, 1998, 2001, 2006, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _I386_BYTEORDER_H -#define _I386_BYTEORDER_H - -#include <_ansi.h> -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef __LITTLE_ENDIAN -#define __LITTLE_ENDIAN 1234 -#endif - -#ifndef __LITTLE_ENDIAN_BITFIELD -#define __LITTLE_ENDIAN_BITFIELD -#endif - -extern uint32_t ntohl(uint32_t); -extern uint16_t ntohs(uint16_t); -extern uint32_t htonl(uint32_t); -extern uint16_t htons(uint16_t); - -_ELIDABLE_INLINE uint32_t __ntohl(uint32_t); -_ELIDABLE_INLINE uint16_t __ntohs(uint16_t); - -_ELIDABLE_INLINE uint32_t -__ntohl(uint32_t x) -{ - __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */ - "rorl $16,%0\n\t" /* swap words */ - "xchgb %b0,%h0" /* swap higher bytes */ - :"=q" (x) - : "0" (x)); - return x; -} - -#define __constant_ntohl(x) \ - ((uint32_t)((((uint32_t)(x) & 0x000000ffU) << 24) | \ - (((uint32_t)(x) & 0x0000ff00U) << 8) | \ - (((uint32_t)(x) & 0x00ff0000U) >> 8) | \ - (((uint32_t)(x) & 0xff000000U) >> 24))) - -_ELIDABLE_INLINE uint16_t -__ntohs(uint16_t x) -{ - __asm__("xchgb %b0,%h0" /* swap bytes */ - : "=q" (x) - : "0" (x)); - return x; -} - -#define __constant_ntohs(x) \ - ((uint16_t)((((uint16_t)(x) & 0x00ff) << 8) | \ - (((uint16_t)(x) & 0xff00) >> 8))) \ - -#define __htonl(x) __ntohl(x) -#define __htons(x) __ntohs(x) -#define __constant_htonl(x) __constant_ntohl(x) -#define __constant_htons(x) __constant_ntohs(x) - -#if defined (__OPTIMIZE__) && !defined (__NO_INLINE__) -# define ntohl(x) \ -(__builtin_constant_p((long)(x)) ? \ - __constant_ntohl((x)) : \ - __ntohl((x))) -# define ntohs(x) \ -(__builtin_constant_p((short)(x)) ? \ - __constant_ntohs((x)) : \ - __ntohs((x))) -# define htonl(x) \ -(__builtin_constant_p((long)(x)) ? \ - __constant_htonl((x)) : \ - __htonl((x))) -# define htons(x) \ -(__builtin_constant_p((short)(x)) ? \ - __constant_htons((x)) : \ - __htons((x))) -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/winsup/cygwin/include/asm/socket.h b/winsup/cygwin/include/asm/socket.h deleted file mode 100644 index e4cec1fd6..000000000 --- a/winsup/cygwin/include/asm/socket.h +++ /dev/null @@ -1,76 +0,0 @@ -/* asm/socket.h - - Copyright 1996, 1997, 1998, 2001, 2005, 2007 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _ASM_SOCKET_H -#define _ASM_SOCKET_H - -#include - -#define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */ -#define IOC_VOID 0x20000000 /* no parameters */ -#define IOC_OUT 0x40000000 /* copy out parameters */ -#define IOC_IN 0x80000000 /* copy in parameters */ - -#define _IO(x,y) (IOC_VOID|(x<<8)|y) -#define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y) -#define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y) - -#define SIOCATMARK _IOR('s', 7, u_long) /* at oob mark? */ -#define FIONREAD _IOR('f', 127, u_long) /* get # bytes to read */ -#define FIONBIO 0x8004667e /* To be compatible with termiost version */ -#define REAL_FIONBIO _IOW('f', 126, u_long) /* set/clear non-blocking i/o */ -#define FIOASYNC _IOW('f', 125, u_long) /* set/clear async i/o */ -#define SIOCSHIWAT _IOW('s', 0, u_long) /* set high watermark */ -#define SIOCGHIWAT _IOR('s', 1, u_long) /* get high watermark */ -#define SIOCSLOWAT _IOW('s', 2, u_long) /* set low watermark */ -#define SIOCGLOWAT _IOR('s', 3, u_long) /* get low watermark */ - -/* Needed for if queries */ -#define SIOCGIFCONF _IOW('s', 100, struct ifconf) /* get if list */ -#define SIOCGIFFLAGS _IOW('s', 101, struct ifreq) /* Get if flags */ -#define SIOCGIFADDR _IOW('s', 102, struct ifreq) /* Get if addr */ -#define SIOCGIFBRDADDR _IOW('s', 103, struct ifreq) /* Get if broadcastaddr */ -#define SIOCGIFNETMASK _IOW('s', 104, struct ifreq) /* Get if netmask */ -#define SIOCGIFHWADDR _IOW('s', 105, struct ifreq) /* Get hw addr */ -#define SIOCGIFMETRIC _IOW('s', 106, struct ifreq) /* get metric */ -#define SIOCGIFMTU _IOW('s', 107, struct ifreq) /* get MTU size */ -#define SIOCGIFINDEX _IOW('s', 108, struct ifreq) /* get if index */ -#define SIOGIFINDEX SIOCGIFINDEX /* backward compatibility w/ Linux typo. */ -#define SIOCGIFFRNDLYNAM _IOW('s', 109, struct ifreq) /* get friendly if name */ -#define SIOCGIFDSTADDR _IOW('s', 110, struct ifreq) /* Get if dstaddr */ - -#define SOL_SOCKET 0xffff /* options for socket level */ - -#define SO_DEBUG 0x0001 /* turn on debugging info recording */ -#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ -#define SO_REUSEADDR 0x0004 /* allow local address reuse */ -#define SO_KEEPALIVE 0x0008 /* keep connections alive */ -#define SO_DONTROUTE 0x0010 /* just use interface addresses */ -#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ -#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ -#define SO_LINGER 0x0080 /* linger on close if data present */ -#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ -#define SO_DONTLINGER (u_int)(~SO_LINGER) -#define SO_PEERCRED 0x0200 /* same as getpeereid */ - -/* - * Additional options. - */ -#define SO_SNDBUF 0x1001 /* send buffer size */ -#define SO_RCVBUF 0x1002 /* receive buffer size */ -#define SO_SNDLOWAT 0x1003 /* send low-water mark */ -#define SO_RCVLOWAT 0x1004 /* receive low-water mark */ -#define SO_SNDTIMEO 0x1005 /* send timeout */ -#define SO_RCVTIMEO 0x1006 /* receive timeout */ -#define SO_ERROR 0x1007 /* get error status and clear */ -#define SO_TYPE 0x1008 /* get socket type */ - -#endif /* _ASM_SOCKET_H */ - diff --git a/winsup/cygwin/include/asm/types.h b/winsup/cygwin/include/asm/types.h deleted file mode 100644 index 2653fd674..000000000 --- a/winsup/cygwin/include/asm/types.h +++ /dev/null @@ -1,23 +0,0 @@ -/* asm/types.h - - Copyright 1998, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _ASM_TYPES_H -#define _ASM_TYPES_H - -typedef __signed__ char __s8; -typedef unsigned char __u8; - -typedef __signed__ short __s16; -typedef unsigned short __u16; - -typedef __signed__ int __s32; -typedef unsigned int __u32; - -#endif /* _ASM_TYPES_H */ diff --git a/winsup/cygwin/include/attr/xattr.h b/winsup/cygwin/include/attr/xattr.h deleted file mode 100644 index 421e6871d..000000000 --- a/winsup/cygwin/include/attr/xattr.h +++ /dev/null @@ -1,46 +0,0 @@ -/* attr/xattr.h - - Copyright 2008 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _ATTR_XATTR_H -#define _ATTR_XATTR_H - -#include "_ansi.h" -#if 0 -/* Per man pages you have to include explicitely before - including . That's how it works on Linux, too. */ -#include -#endif -#include - -#define XATTR_CREATE 1 -#define XATTR_REPLACE 2 - -#ifndef ENOATTR -#define ENOATTR ENODATA -#endif - -_BEGIN_STD_C - -ssize_t _EXFUN(getxattr,(const char *, const char *, void *, size_t )); -ssize_t _EXFUN(lgetxattr,(const char *, const char *, void *, size_t )); -ssize_t _EXFUN(fgetxattr,(int , const char *, void *, size_t )); -ssize_t _EXFUN(listxattr,(const char *, char *, size_t )); -ssize_t _EXFUN(llistxattr,(const char *, char *, size_t )); -ssize_t _EXFUN(flistxattr,(int , char *, size_t )); -int _EXFUN(setxattr,(const char *, const char *, const void *, size_t , int )); -int _EXFUN(lsetxattr,(const char *, const char *, const void *, size_t , int )); -int _EXFUN(fsetxattr,(int , const char *, const void *, size_t , int )); -int _EXFUN(removexattr,(const char *, const char *)); -int _EXFUN(lremovexattr,(const char *, const char *)); -int _EXFUN(fremovexattr,(int , const char *)); - -_END_STD_C - -#endif /* _ATTR_XATTR_H */ diff --git a/winsup/cygwin/include/bits/wordsize.h b/winsup/cygwin/include/bits/wordsize.h deleted file mode 100644 index 38e14f85f..000000000 --- a/winsup/cygwin/include/bits/wordsize.h +++ /dev/null @@ -1,6 +0,0 @@ -/* wordsize.h - Linux compatibility */ - -#ifndef _WORDSIZE_H -#define _WORDSIZE_H 1 -#define __WORDSIZE 32 -#endif /*_WORDSIZE_H*/ diff --git a/winsup/cygwin/include/byteswap.h b/winsup/cygwin/include/byteswap.h deleted file mode 100644 index cd5a726d4..000000000 --- a/winsup/cygwin/include/byteswap.h +++ /dev/null @@ -1,39 +0,0 @@ -/* byteswap.h - -Copyright 2005 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _BYTESWAP_H -#define _BYTESWAP_H - -#ifdef __cplusplus -extern "C" { -#endif - -static __inline unsigned short -bswap_16 (unsigned short __x) -{ - return (__x >> 8) | (__x << 8); -} - -static __inline unsigned int -bswap_32 (unsigned int __x) -{ - return (bswap_16 (__x & 0xffff) << 16) | (bswap_16 (__x >> 16)); -} - -static __inline unsigned long long -bswap_64 (unsigned long long __x) -{ - return (((unsigned long long) bswap_32 (__x & 0xffffffffull)) << 32) | (bswap_32 (__x >> 32)); -} - -#ifdef __cplusplus -} -#endif -#endif /* _BYTESWAP_H */ diff --git a/winsup/cygwin/include/cygwin/_types.h b/winsup/cygwin/include/cygwin/_types.h deleted file mode 100644 index b96267622..000000000 --- a/winsup/cygwin/include/cygwin/_types.h +++ /dev/null @@ -1,16 +0,0 @@ -/* cygwin/_types.h - - Copyright 2004 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGWIN__TYPES_H -#define _CYGWIN__TYPES_H - -typedef void *_flock_t; - -#endif /* _CYGWIN__TYPES_H */ diff --git a/winsup/cygwin/include/cygwin/acl.h b/winsup/cygwin/include/cygwin/acl.h deleted file mode 100644 index 3ea5f91e5..000000000 --- a/winsup/cygwin/include/cygwin/acl.h +++ /dev/null @@ -1,98 +0,0 @@ -/* cygwin/acl.h header file for Cygwin. - - Copyright 1999, 2000, 2001, 2002 Red Hat, Inc. - Written by C. Vinschen. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGWIN_ACL_H -#ifdef __cplusplus -extern "C" { -#endif -#define _CYGWIN_ACL_H - -#include <_ansi.h> - -#include -#include - -/* Values for `cmd' in calls to acl(2) and facl(2) */ -#define SETACL (0x0) -#define GETACL (0x1) -#define GETACLCNT (0x2) - -#define MIN_ACL_ENTRIES (4) // minimal acl entries from GETACLCNT -#define MAX_ACL_ENTRIES (256) // max entries of each type - -// Return values of aclcheck(3) in case of error */ -#define GRP_ERROR (0x1) -#define USER_ERROR (0x2) -#define CLASS_ERROR (0x3) -#define OTHER_ERROR (0x4) -#define DUPLICATE_ERROR (0x5) -#define ENTRY_ERROR (0x6) -#define MISS_ERROR (0x7) // which = -1 -#define MEM_ERROR (0x8) // which = -1 - -// Values for entry type of struct acl -#define USER_OBJ (0x0001) // owner -#define USER (0x0002) // additional user -#define GROUP_OBJ (0x0004) // owning group -#define GROUP (0x0008) // additional group -#define CLASS_OBJ (0x0010) // mask entry -#define OTHER_OBJ (0x0020) // others -#define ACL_DEFAULT (0x1000) // default flag -#define DEF_USER_OBJ (ACL_DEFAULT|USER_OBJ) // default owner -#define DEF_USER (ACL_DEFAULT|USER) // default additional user -#define DEF_GROUP_OBJ (ACL_DEFAULT|GROUP_OBJ) // default owning group -#define DEF_GROUP (ACL_DEFAULT|GROUP) // default additional group -#define DEF_CLASS_OBJ (ACL_DEFAULT|CLASS_OBJ) // default mask entry -#define DEF_OTHER_OBJ (ACL_DEFAULT|OTHER_OBJ) // default others -// Values with equivalent meanings -#define USER_OWNER USER_OBJ -#define GROUP_OWNER GROUP_OBJ -#define MASK CLASS_OBJ -#define OTHER OTHER_OBJ - -#ifdef __INSIDE_CYGWIN__ -typedef struct __acl16 { - int a_type; - __uid16_t a_id; - mode_t a_perm; -} __aclent16_t; - -typedef struct __acl32 { - int a_type; - __uid32_t a_id; - mode_t a_perm; -} __aclent32_t; -#else -typedef struct acl { - int a_type; /* entry type */ - uid_t a_id; /* UID | GID */ - mode_t a_perm; /* permissions */ -} aclent_t; -#endif - -#ifndef __INSIDE_CYGWIN__ -int _EXFUN(acl,(const char *path, int cmd, int nentries, aclent_t *aclbufp)); -int _EXFUN(lacl,(const char *path, int cmd, int nentries, aclent_t *aclbufp)); -int _EXFUN(facl,(int fd, int cmd, int nentries, aclent_t *aclbufp)); -int _EXFUN(aclcheck,(aclent_t *aclbufp, int nentries, int *which)); -int _EXFUN(aclsort,(int nentries, int calclass, aclent_t *aclbufp)); -int _EXFUN(acltomode,(aclent_t *aclbufp, int nentries, mode_t *modep)); -int _EXFUN(aclfrommode,(aclent_t *aclbufp, int nentries, mode_t *modep)); -int _EXFUN(acltopbits,(aclent_t *aclbufp, int nentries, mode_t *pbitsp)); -int _EXFUN(aclfrompbits,(aclent_t *aclbufp, int nentries, mode_t *pbitsp)); -char *_EXFUN(acltotext,(aclent_t *aclbufp, int aclcnt)); -aclent_t *_EXFUN(aclfromtext,(char *acltextp, int *aclcnt)); -#endif - -#ifdef __cplusplus -} -#endif -#endif /* _CYGWIN_ACL_H */ diff --git a/winsup/cygwin/include/cygwin/config.h b/winsup/cygwin/include/cygwin/config.h deleted file mode 100644 index 4404a9473..000000000 --- a/winsup/cygwin/include/cygwin/config.h +++ /dev/null @@ -1,75 +0,0 @@ -/* cygwin/config.h header file for Cygwin. - - This wraps Cygwin configuration setting which were in newlib's - sys/config.h before. This way we can manaage our configuration - setting without bothering newlib. - - Copyright 2003, 2007, 2008, 2009 Red Hat, Inc. - Written by C. Vinschen. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGWIN_CONFIG_H -#ifdef __cplusplus -extern "C" { -#endif -#define _CYGWIN_CONFIG_H - -#define __DYNAMIC_REENT__ - -/* The following provides an inline version of __getreent() for newlib, - which will be used throughout the library whereever there is a _r - version of a function that takes _REENT. This saves the overhead - of a function call for what amounts to a simple computation. - - The definition below is essentially equivalent to the one in cygtls.h - (&_my_tls.local_clib) however it uses a fixed precomputed - offset rather than dereferencing a field of a structure. - - Including tlsoffets.h here in order to get this constant offset - tls_local_clib is a bit of a hack, but the alternative would require - dragging the entire definition of struct _cygtls (a large and complex - Cygwin internal data structure) into newlib. The machinery to - compute these offsets already exists for the sake of gendef so - we might as well just use it here. */ - -#ifdef _COMPILING_NEWLIB -#include "../tlsoffsets.h" -extern char *_tlsbase __asm__ ("%fs:4"); -#define __getreent() (struct _reent *)(_tlsbase + tls_local_clib) -#endif /* _COMPILING_NEWLIB */ - -#define __FILENAME_MAX__ 4096 /* Keep in sync with PATH_MAX in limits.h. */ -#define _READ_WRITE_RETURN_TYPE _ssize_t -#define __LARGE64_FILES 1 -#define __CYGWIN_USE_BIG_TYPES__ 1 -#ifdef __CYGWIN_USE_BIG_TYPES__ -/* __USE_INTERNAL_STAT64 is needed when building newlib for Cygwin. - It must be set when __CYGWIN_USE_BIG_TYPES__ is set. In this case - newlib will call the 64 bit stat calls internally. Otherwise the - struct stat used in newlib is not matching the struct stat used in - Cygwin. */ -#define __USE_INTERNAL_STAT64 1 -#endif -#if defined(__INSIDE_CYGWIN__) || defined(_COMPILING_NEWLIB) -#define __EXPORT __declspec(dllexport) -#define __IMPORT -#else -#define __EXPORT -#define __IMPORT __declspec(dllimport) -#endif - -#ifndef __WCHAR_MAX__ -#define __WCHAR_MAX__ 0xffffu -#endif - -#define DEFAULT_LOCALE "C.UTF-8" - -#ifdef __cplusplus -} -#endif -#endif /* _CYGWIN_CONFIG_H */ diff --git a/winsup/cygwin/include/cygwin/core_dump.h b/winsup/cygwin/include/cygwin/core_dump.h deleted file mode 100644 index b1943937b..000000000 --- a/winsup/cygwin/include/cygwin/core_dump.h +++ /dev/null @@ -1,73 +0,0 @@ -/* core_dump.h - - Copyright 1999, 2000, 2001 Red Hat, Inc. - - Written by Egor Duda - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGWIN_CORE_DUMP_H -#define _CYGWIN_CORE_DUMP_H - -#include - -#define NOTE_INFO_PROCESS 1 -#define NOTE_INFO_THREAD 2 -#define NOTE_INFO_MODULE 3 - -struct win32_core_process_info -{ - DWORD pid; - int signal; - int command_line_size; - char command_line[1]; -} -#ifdef __GNUC__ - __attribute__ ((packed)) -#endif -; - -struct win32_core_thread_info -{ - DWORD tid; - BOOL is_active_thread; - CONTEXT thread_context; -} -#ifdef __GNUC__ - __attribute__ ((packed)) -#endif -; - -struct win32_core_module_info -{ - void* base_address; - int module_name_size; - char module_name[1]; -} -#ifdef __GNUC__ - __attribute__ ((packed)) -#endif -; - -struct win32_pstatus -{ - unsigned long data_type; - union - { - struct win32_core_process_info process_info; - struct win32_core_thread_info thread_info; - struct win32_core_module_info module_info; - } data ; -} -#ifdef __GNUC__ - __attribute__ ((packed)) -#endif -; - -typedef struct win32_pstatus win32_pstatus_t ; - -#endif /* _CYGWIN_CORE_DUMP_H */ diff --git a/winsup/cygwin/include/cygwin/cygwin_dll.h b/winsup/cygwin/include/cygwin/cygwin_dll.h deleted file mode 100644 index 7b1f1b883..000000000 --- a/winsup/cygwin/include/cygwin/cygwin_dll.h +++ /dev/null @@ -1,96 +0,0 @@ -/* cygwin_dll.h - - Copyright 1998, 1999, 2000, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef __CYGWIN_CYGWIN_DLL_H__ -#define __CYGWIN_CYGWIN_DLL_H__ - -#include - -#ifdef __cplusplus -#define CDECL_BEGIN extern "C" { -#define CDECL_END } -#else -#define CDECL_BEGIN -#define CDECL_END -#endif - -#define DECLARE_CYGWIN_DLL(Entry) \ - \ -CDECL_BEGIN \ - int WINAPI Entry (HINSTANCE h, DWORD reason, void *ptr); \ - typedef int (*mainfunc) (int, char **, char **); \ - extern int cygwin_attach_dll (HMODULE, mainfunc); \ - extern void cygwin_detach_dll (DWORD); \ -CDECL_END \ - \ -static HINSTANCE storedHandle; \ -static DWORD storedReason; \ -static void* storedPtr; \ -int __dynamically_loaded; \ - \ -static int __dllMain (int a, char **b, char **c) \ -{ \ - return Entry (storedHandle, storedReason, storedPtr); \ -} \ - \ -static DWORD dll_index; \ - \ -int WINAPI _cygwin_dll_entry (HINSTANCE h, DWORD reason, void *ptr) \ -{ \ - int ret; \ - ret = 1; \ - \ - switch (reason) \ - { \ - case DLL_PROCESS_ATTACH: \ - { \ - storedHandle = h; \ - storedReason = reason; \ - storedPtr = ptr; \ - __dynamically_loaded = (ptr == NULL); \ - dll_index = cygwin_attach_dll (h, &__dllMain); \ - if (dll_index == (DWORD) -1) \ - ret = 0; \ - } \ - break; \ - \ - case DLL_PROCESS_DETACH: \ - { \ - ret = Entry (h, reason, ptr); \ - if (ret) \ - { \ - cygwin_detach_dll (dll_index); \ - dll_index = (DWORD) -1; \ - } \ - } \ - break; \ - \ - case DLL_THREAD_ATTACH: \ - { \ - ret = Entry (h, reason, ptr); \ - } \ - break; \ - \ - case DLL_THREAD_DETACH: \ - { \ - ret = Entry (h, reason, ptr); \ - } \ - break; \ - } \ - return ret; \ -} \ - \ -/* OBSOLETE: This is only provided for source level compatibility. */ \ -int WINAPI _cygwin_noncygwin_dll_entry (HINSTANCE h, DWORD reason, void *ptr) \ -{ \ - return _cygwin_dll_entry (h, reason, ptr); \ -} \ - -#endif /* __CYGWIN_CYGWIN_DLL_H__ */ diff --git a/winsup/cygwin/include/cygwin/fs.h b/winsup/cygwin/include/cygwin/fs.h deleted file mode 100644 index eb8c7e3d1..000000000 --- a/winsup/cygwin/include/cygwin/fs.h +++ /dev/null @@ -1,20 +0,0 @@ -/* cygwin/fs.h - - Copyright 2002, 2003 Red Hat Inc. - Written by Chris January - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGWIN_FS_H_ -#define _CYGWIN_FS_H_ - -#define BLKRRPART 0x0000125f -#define BLKGETSIZE 0x00001260 -#define BLKSSZGET 0x00001268 -#define BLKGETSIZE64 0x00041268 - -#endif diff --git a/winsup/cygwin/include/cygwin/grp.h b/winsup/cygwin/include/cygwin/grp.h deleted file mode 100644 index 7dcae637d..000000000 --- a/winsup/cygwin/include/cygwin/grp.h +++ /dev/null @@ -1,48 +0,0 @@ -/* cygwin/grp.h - - Copyright 2002 Red Hat Inc. - Written by Corinna Vinschen - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGWIN_GRP_H_ -#define _CYGWIN_GRP_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __INSIDE_CYGWIN__ -struct __group16 -{ - char *gr_name; - char *gr_passwd; - __gid16_t gr_gid; - char **gr_mem; -}; - -struct __group32 -{ - char *gr_name; - char *gr_passwd; - __gid32_t gr_gid; - char **gr_mem; -}; - -struct __group32 * getgrgid32 (__gid32_t gid); -struct __group32 * getgrnam32 (const char *name); -__gid32_t getgid32 (); -__gid32_t getegid32 (); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _CYGWIN_GRP_H_ */ diff --git a/winsup/cygwin/include/cygwin/hdreg.h b/winsup/cygwin/include/cygwin/hdreg.h deleted file mode 100644 index dc8157838..000000000 --- a/winsup/cygwin/include/cygwin/hdreg.h +++ /dev/null @@ -1,24 +0,0 @@ -/* cygwin/hdreg.h - - Copyright 2002 Red Hat Inc. - Written by Chris January - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGWIN_HDREG_H_ -#define _CYGWIN_HDREG_H_ - -struct hd_geometry { - unsigned char heads; - unsigned char sectors; - unsigned short cylinders; - unsigned long start; -}; - -#define HDIO_GETGEO 0x301 - -#endif diff --git a/winsup/cygwin/include/cygwin/icmp.h b/winsup/cygwin/include/cygwin/icmp.h deleted file mode 100644 index 7e7aedccd..000000000 --- a/winsup/cygwin/include/cygwin/icmp.h +++ /dev/null @@ -1 +0,0 @@ -/* icmp.h */ diff --git a/winsup/cygwin/include/cygwin/if.h b/winsup/cygwin/include/cygwin/if.h deleted file mode 100644 index 8f76e836e..000000000 --- a/winsup/cygwin/include/cygwin/if.h +++ /dev/null @@ -1,123 +0,0 @@ -/* cygwin/if.h - - Copyright 1996, 2001, 2007 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGWIN_IF_H_ -#define _CYGWIN_IF_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include -#include - -/* Standard interface flags. */ -#define IFF_UP 0x1 /* interface is up */ -#define IFF_BROADCAST 0x2 /* broadcast address valid */ -#define IFF_LOOPBACK 0x8 /* is a loopback net */ -#define IFF_POINTOPOINT 0x10 /* is a point-to-point interface */ -#define IFF_NOTRAILERS 0x20 /* avoid use of trailers */ -#define IFF_RUNNING 0x40 /* resources allocated */ -#define IFF_NOARP 0x80 /* no ARP protocol */ -#define IFF_PROMISC 0x100 /* receive all packets */ -#define IFF_MULTICAST 0x1000 /* Supports multicast */ -#define IFF_LOWER_UP 0x10000 /* driver signals L1 up */ -#define IFF_DORMANT 0x20000 /* driver signals dormant */ - -struct if_nameindex { - unsigned if_index; - char *if_name; -}; - -/* This is the structure expected by ioctl when the application requests - the friendly adapter name (>= XP SP1). ifru_data should point to such - a structure when ioctl is called with SIOCGIFFRNDLYNAM. */ -#define IFRF_FRIENDLYNAMESIZ 260 - -struct ifreq_frndlyname { - int ifrf_len; - char ifrf_friendlyname[IFRF_FRIENDLYNAMESIZ]; -}; - -/* - * Interface request structure used for socket - * ioctl's. All interface ioctl's must have parameter - * definitions which begin with ifr_name. The - * remainder may be interface specific. - */ -#define IFNAMSIZ 44 -#define IF_NAMESIZE IFNAMSIZ -#define IFHWADDRLEN 6 - -struct ifreq { - union { - char ifrn_name[IFNAMSIZ]; /* Unique Windows Adapter name (A GUID) */ - } ifr_ifrn; - - union { - struct sockaddr ifru_addr; - struct sockaddr ifru_broadaddr; - struct sockaddr ifru_dstaddr; - struct sockaddr ifru_netmask; - struct sockaddr ifru_hwaddr; - int ifru_flags; - int ifru_metric; - int ifru_mtu; - int ifru_ifindex; - /* The space must be preallocated by the application. */ - void *ifru_data; - /* Pad to sizeof sockaddr_in6 for further extensions. */ - char __ifru_pad[28]; - } ifr_ifru; -}; - -#define ifr_name ifr_ifrn.ifrn_name /* interface name */ -#define ifr_addr ifr_ifru.ifru_addr /* address */ -#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ -#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* destination address */ -#define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */ -#define ifr_flags ifr_ifru.ifru_flags /* flags */ -#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ -#define ifr_metric ifr_ifru.ifru_metric /* metric */ -#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ -#define ifr_ifindex ifr_ifru.ifru_ifindex /* interface index */ -#define ifr_data ifr_ifru.ifru_data /* for use by interface */ -#define ifr_frndlyname ifr_ifru.ifru_data /* Windows friendly if name */ - -/* - * Structure used in SIOCGIFCONF request. - * Used to retrieve interface configuration - * for machine (useful for programs which - * must know all networks accessible). - */ - -struct ifconf -{ - int ifc_len; /* size of buffer */ - union - { - caddr_t ifcu_buf; - struct ifreq *ifcu_req; - } ifc_ifcu; -}; - -#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ -#define ifc_req ifc_ifcu.ifcu_req /* array of structures */ - -extern unsigned if_nametoindex (const char *); -extern char *if_indextoname (unsigned, char *); -extern struct if_nameindex *if_nameindex (void); -extern void if_freenameindex (struct if_nameindex *); - -#ifdef __cplusplus -}; -#endif /* __cplusplus */ - -#endif /* _CYGWIN_IF_H_ */ diff --git a/winsup/cygwin/include/cygwin/in.h b/winsup/cygwin/include/cygwin/in.h deleted file mode 100644 index 30ac623a8..000000000 --- a/winsup/cygwin/include/cygwin/in.h +++ /dev/null @@ -1,263 +0,0 @@ -/* - * INET An implementation of the TCP/IP protocol suite for the LINUX - * operating system. INET is implemented using the BSD Socket - * interface as the means of communication with the user level. - * - * Definitions of the Internet Protocol. - * - * Version: @(#)in.h 1.0.1 04/21/93 - * - * Authors: Original taken from the GNU Project file. - * Fred N. van Kempen, - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - */ -#ifndef _CYGWIN_IN_H -#define _CYGWIN_IN_H - -#include - -typedef uint16_t in_port_t; -typedef uint32_t in_addr_t; - -/* Standard well-defined IP protocols. If you ever add one here, don't - forget to define it below. */ -enum -{ - IPPROTO_IP = 0, /* Dummy protocol for TCP */ - IPPROTO_HOPOPTS = 0, /* IPv6 Hop-by-Hop options */ - IPPROTO_ICMP = 1, /* Internet Control Message Protocol */ - IPPROTO_IGMP = 2, /* Internet Gateway Management Protocol */ - IPPROTO_IPIP = 4, /* IPIP tunnels (older KA9Q tunnels use 94) */ - IPPROTO_TCP = 6, /* Transmission Control Protocol */ - IPPROTO_EGP = 8, /* Exterior Gateway Protocol */ - IPPROTO_PUP = 12, /* PUP protocol */ - IPPROTO_UDP = 17, /* User Datagram Protocol */ - IPPROTO_IDP = 22, /* XNS IDP protocol */ - IPPROTO_IPV6 = 41, /* IPv6 header */ - IPPROTO_ROUTING = 43, /* IPv6 Routing header */ - IPPROTO_FRAGMENT = 44, /* IPv6 fragmentation header */ - IPPROTO_ESP = 50, /* encapsulating security payload */ - IPPROTO_AH = 51, /* authentication header */ - IPPROTO_ICMPV6 = 58, /* ICMPv6 */ - IPPROTO_NONE = 59, /* IPv6 no next header */ - IPPROTO_DSTOPTS = 60, /* IPv6 Destination options */ - IPPROTO_RAW = 255, /* Raw IP packets */ - IPPROTO_MAX -}; - -/* Define IPPROTO_xxx values to accomodate SUSv3 */ -#define IPPROTO_IP IPPROTO_IP -#define IPPROTO_HOPOPTS IPPROTO_HOPOPTS -#define IPPROTO_ICMP IPPROTO_ICMP -#define IPPROTO_IGMP IPPROTO_IGMP -#define IPPROTO_IPIP IPPROTO_IPIP -#define IPPROTO_TCP IPPROTO_TCP -#define IPPROTO_EGP IPPROTO_EGP -#define IPPROTO_PUP IPPROTO_PUP -#define IPPROTO_UDP IPPROTO_UDP -#define IPPROTO_IDP IPPROTO_IDP -#define IPPROTO_RAW IPPROTO_RAW -#define IPPROTO_IPV6 IPPROTO_IPV6 -#define IPPROTO_ROUTING IPPROTO_ROUTING -#define IPPROTO_FRAGMENT IPPROTO_FRAGMENT -#define IPPROTO_ESP IPPROTO_ESP -#define IPPROTO_AH IPPROTO_AH -#define IPPROTO_ICMPV6 IPPROTO_ICMPV6 -#define IPPROTO_NONE IPPROTO_NONE -#define IPPROTO_DSTOPTS IPPROTO_DSTOPTS - -/* Standard well-known ports. *//* from winsup/include/netinet/in.h */ -enum -{ - IPPORT_ECHO = 7, /* Echo service. */ - IPPORT_DISCARD = 9, /* Discard transmissions service. */ - IPPORT_SYSTAT = 11, /* System status service. */ - IPPORT_DAYTIME = 13, /* Time of day service. */ - IPPORT_NETSTAT = 15, /* Network status service. */ - IPPORT_FTP = 21, /* File Transfer Protocol. */ - IPPORT_TELNET = 23, /* Telnet protocol. */ - IPPORT_SMTP = 25, /* Simple Mail Transfer Protocol. */ - IPPORT_TIMESERVER = 37, /* Timeserver service. */ - IPPORT_NAMESERVER = 42, /* Domain Name Service. */ - IPPORT_WHOIS = 43, /* Internet Whois service. */ - IPPORT_MTP = 57, - - IPPORT_TFTP = 69, /* Trivial File Transfer Protocol. */ - IPPORT_RJE = 77, - IPPORT_FINGER = 79, /* Finger service. */ - IPPORT_TTYLINK = 87, - IPPORT_SUPDUP = 95, /* SUPDUP protocol. */ - - - IPPORT_EXECSERVER = 512, /* execd service. */ - IPPORT_LOGINSERVER = 513, /* rlogind service. */ - IPPORT_CMDSERVER = 514, - IPPORT_EFSSERVER = 520, - - /* UDP ports. */ - IPPORT_BIFFUDP = 512, - IPPORT_WHOSERVER = 513, - IPPORT_ROUTESERVER = 520, - - /* Ports less than this value are reserved for privileged processes. */ - IPPORT_RESERVED = 1024, - - /* Ports greater this value are reserved for (non-privileged) servers. */ - IPPORT_USERRESERVED = 5000 -}; - -/* Internet address. */ -struct in_addr -{ - in_addr_t s_addr; -}; - -/* Request struct for IPv4 multicast socket ops */ - -struct ip_mreq -{ - struct in_addr imr_multiaddr; /* IP multicast address of group */ - struct in_addr imr_interface; /* local IP address of interface */ -}; - -struct ip_mreq_source -{ - struct in_addr imr_multiaddr; - struct in_addr imr_sourceaddr; - struct in_addr imr_interface; -}; - -struct ip_msfilter -{ - struct in_addr imsf_multiaddr; - struct in_addr imsf_interface; - uint32_t imsf_fmode; - uint32_t imsf_numsrc; - struct in_addr imsf_slist[1]; -}; - -#define IP_MSFILTER_SIZE(numsrc) (sizeof (struct ip_msfilter) \ - - sizeof (struct in_addr) \ - + (numsrc) * sizeof (struct in_addr)) - -struct in_pktinfo -{ - struct in_addr ipi_addr; - uint32_t ipi_ifindex; -}; - -/* Request struct for IP agnostic multicast socket ops */ - -struct group_req -{ - uint32_t gr_interface; - struct sockaddr_storage gr_group; -}; - -struct group_source_req -{ - uint32_t gsr_interface; - struct sockaddr_storage gsr_group; - struct sockaddr_storage gsr_source; -}; - -struct group_filter -{ - uint32_t gf_interface; - struct sockaddr_storage gf_group; - uint32_t gf_fmode; - uint32_t gf_numsrc; - struct sockaddr_storage gf_slist[1]; -}; - -#define GROUP_FILTER_SIZE(numsrc) (sizeof (struct group_filter) \ - - sizeof (struct sockaddr_storage) \ - + (numsrc) * sizeof (struct sockaddr_storage)) - -/* Structure describing an Internet (IP) socket address. */ -#define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */ -struct sockaddr_in -{ - sa_family_t sin_family; /* Address family */ - in_port_t sin_port; /* Port number */ - struct in_addr sin_addr; /* Internet address */ - - /* Pad to size of `struct sockaddr'. */ - unsigned char __pad[__SOCK_SIZE__ - sizeof(short int) - - sizeof(unsigned short int) - sizeof(struct in_addr)]; -}; -#define sin_zero __pad /* for BSD UNIX comp. -FvK */ - -/* - * Definitions of the bits in an Internet address integer. - * On subnets, host and network parts are found according - * to the subnet mask, not these masks. - */ -#define IN_CLASSA(a) ((((in_addr_t) (a)) & 0x80000000) == 0) -#define IN_CLASSA_NET 0xff000000 -#define IN_CLASSA_NSHIFT 24 -#define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET) -#define IN_CLASSA_MAX 128 - -#define IN_CLASSB(a) ((((in_addr_t) (a)) & 0xc0000000) == 0x80000000) -#define IN_CLASSB_NET 0xffff0000 -#define IN_CLASSB_NSHIFT 16 -#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET) -#define IN_CLASSB_MAX 65536 - -#define IN_CLASSC(a) ((((in_addr_t) (a)) & 0xe0000000) == 0xc0000000) -#define IN_CLASSC_NET 0xffffff00 -#define IN_CLASSC_NSHIFT 8 -#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET) - -#define IN_CLASSD(a) ((((in_addr_t) (a)) & 0xf0000000) == 0xe0000000) -#define IN_MULTICAST(a) IN_CLASSD(a) -#define IN_MULTICAST_NET 0xF0000000 - -#define IN_EXPERIMENTAL(a) ((((in_addr_t) (a)) & 0xe0000000) == 0xe0000000) -#define IN_BADCLASS(a) ((((in_addr_t) (a)) & 0xf0000000) == 0xf0000000) - -/* Address to accept any incoming messages. */ -#define INADDR_ANY ((in_addr_t) 0x00000000) - -/* Address to send to all hosts. */ -#define INADDR_BROADCAST ((in_addr_t) 0xffffffff) - -/* Address indicating an error return. */ -#define INADDR_NONE 0xffffffff - -/* Network number for local host loopback. */ -#define IN_LOOPBACKNET 127 - -/* Address to loopback in software to local host. */ -#define INADDR_LOOPBACK 0x7f000001 /* 127.0.0.1 */ -#define IN_LOOPBACK(a) ((((in_addr_t) (a)) & 0xff000000) == 0x7f000000) - -/* Defines for Multicast INADDR */ -#define INADDR_UNSPEC_GROUP 0xe0000000 /* 224.0.0.0 */ -#define INADDR_ALLHOSTS_GROUP 0xe0000001 /* 224.0.0.1 */ -#define INADDR_ALLRTRS_GROUP 0xe0000002 /* 224.0.0.2 */ -#define INADDR_MAX_LOCAL_GROUP 0xe00000ff /* 224.0.0.255 */ - -#define INET_ADDRSTRLEN 16 - -/* contains the htonl type stuff.. */ - -#include - -/* Some random defines to make it easier in the kernel.. */ -#ifdef __KERNEL__ - -#define LOOPBACK(x) (((x) & htonl(0xff000000)) == htonl(0x7f000000)) -#define MULTICAST(x) (((x) & htonl(0xf0000000)) == htonl(0xe0000000)) - -#endif - -#ifdef AF_INET6 -#include -#endif -#endif /* _CYGWIN_IN_H */ diff --git a/winsup/cygwin/include/cygwin/in6.h b/winsup/cygwin/include/cygwin/in6.h deleted file mode 100644 index bdb812c99..000000000 --- a/winsup/cygwin/include/cygwin/in6.h +++ /dev/null @@ -1,119 +0,0 @@ -/* cygwin/in6.h - - Copyright 2006, 2007 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* NOTE: This file is NOT for direct inclusion. Use netinet/in.h. */ - -#ifndef _CYGWIN_IN6_H -#define _CYGWIN_IN6_H - -#define INET6_ADDRSTRLEN 46 - -#define IN6_ARE_ADDR_EQUAL(a, b) \ - (((const uint32_t *)(a))[0] == ((const uint32_t *)(b))[0] \ - && ((const uint32_t *)(a))[1] == ((const uint32_t *)(b))[1] \ - && ((const uint32_t *)(a))[2] == ((const uint32_t *)(b))[2] \ - && ((const uint32_t *)(a))[3] == ((const uint32_t *)(b))[3]) - -#define IN6_IS_ADDR_UNSPECIFIED(addr) \ - (((const uint32_t *)(addr))[0] == 0 \ - && ((const uint32_t *)(addr))[1] == 0 \ - && ((const uint32_t *)(addr))[2] == 0 \ - && ((const uint32_t *)(addr))[3] == 0) - -#define IN6_IS_ADDR_LOOPBACK(addr) \ - (((const uint32_t *)(addr))[0] == 0 \ - && ((const uint32_t *)(addr))[1] == 0 \ - && ((const uint32_t *)(addr))[2] == 0 \ - && ((const uint32_t *)(addr))[3] == htonl (1)) - -#define IN6_IS_ADDR_MULTICAST(addr) (((const uint8_t *) (addr))[0] == 0xff) - -#define IN6_IS_ADDR_LINKLOCAL(addr) \ - ((((const uint16_t *)(addr))[0] & htons (0xffc0)) == htons (0xfe80)) - -#define IN6_IS_ADDR_SITELOCAL(addr) \ - ((((const uint16_t *)(addr))[0] & htons (0xffc0)) == htons (0xfec0)) - -#define IN6_IS_ADDR_V4MAPPED(addr) \ - (((const uint32_t *)(addr))[0] == 0 \ - && ((const uint32_t *)(addr))[1] == 0 \ - && ((const uint32_t *)(addr))[2] == htonl (0xffff)) - -#define IN6_IS_ADDR_V4COMPAT(addr) \ - (((const uint32_t *)(addr))[0] == 0 \ - && ((const uint32_t *)(addr))[1] == 0 \ - && ((const uint32_t *)(addr))[2] == 0 \ - && ntohl (((const uint32_t *)(addr))[3]) > 1) - -#define IN6_IS_ADDR_MC_NODELOCAL(addr) \ - (IN6_IS_ADDR_MULTICAST(addr) \ - && (((const uint8_t *)(addr))[1] & 0xf) == 0x1) - -#define IN6_IS_ADDR_MC_LINKLOCAL(addr) \ - (IN6_IS_ADDR_MULTICAST (addr) \ - && (((const uint8_t *)(addr))[1] & 0xf) == 0x2) - -#define IN6_IS_ADDR_MC_SITELOCAL(addr) \ - (IN6_IS_ADDR_MULTICAST(addr) \ - && (((const uint8_t *)(addr))[1] & 0xf) == 0x5) - -#define IN6_IS_ADDR_MC_ORGLOCAL(addr) \ - (IN6_IS_ADDR_MULTICAST(addr) \ - && (((const uint8_t *)(addr))[1] & 0xf) == 0x8) - -#define IN6_IS_ADDR_MC_GLOBAL(addr) \ - (IN6_IS_ADDR_MULTICAST(addr) \ - && (((const uint8_t *)(addr))[1] & 0xf) == 0xe) - -struct in6_addr -{ - union - { - uint8_t __s6_addr[16]; - uint16_t __s6_addr16[8]; - uint32_t __s6_addr32[4]; - } __u6; -#define s6_addr __u6.__s6_addr -#define s6_addr16 __u6.__s6_addr16 -#define s6_addr32 __u6.__s6_addr32 -}; - -struct ipv6_mreq -{ - struct in6_addr ipv6mr_multiaddr; - uint32_t ipv6mr_interface; -}; - -struct in6_pktinfo -{ - struct in6_addr ipi6_addr; - uint32_t ipi6_ifindex; -}; - -#if defined (__INSIDE_CYGWIN__) && !defined (_CYGWIN_IN_H) -typedef uint16_t in_port_t; -#endif - -struct sockaddr_in6 -{ - sa_family_t sin6_family; /* AF_INET6 */ - in_port_t sin6_port; /* Port number. */ - uint32_t sin6_flowinfo; /* Traffic class and flow inf. */ - struct in6_addr sin6_addr; /* IPv6 address. */ - uint32_t sin6_scope_id; /* Set of interfaces for a scope. */ -}; - -#define IN6ADDR_ANY_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } -#define IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } - -extern const struct in6_addr in6addr_any; -extern const struct in6_addr in6addr_loopback; - -#endif /* _CYGWIN_IN6_H */ diff --git a/winsup/cygwin/include/cygwin/in_systm.h b/winsup/cygwin/include/cygwin/in_systm.h deleted file mode 100644 index 1a2c1b2e7..000000000 --- a/winsup/cygwin/include/cygwin/in_systm.h +++ /dev/null @@ -1,34 +0,0 @@ -/* System specific type definitions for networking code. - * - * Version: @(#)in_systm.h 1.0.0 06/07/00 - * - * Authors: Original taken from the GNU Project file. - * Fred N. van Kempen, - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - */ -#ifndef _CYGWIN_IN_SYSTM_H -#define _CYGWIN_IN_SYSTM_H - -#include -#include - -__BEGIN_DECLS - -/* - * Network order versions of various data types. Unfortunately, BSD - * assumes specific sizes for shorts (16 bit) and longs (32 bit) which - * don't hold in general. As a consequence, the network order versions - * may not reflect the actual size of the native data types. - */ - -typedef u_int16_t n_short; /* short as received from the net */ -typedef u_int32_t n_long; /* long as received from the net */ -typedef u_int32_t n_time; /* ms since 00:00 GMT, byte rev */ - -__END_DECLS - -#endif /* _CYGWIN_IN_SYSTM_H */ diff --git a/winsup/cygwin/include/cygwin/ipc.h b/winsup/cygwin/include/cygwin/ipc.h deleted file mode 100644 index 783778822..000000000 --- a/winsup/cygwin/include/cygwin/ipc.h +++ /dev/null @@ -1,71 +0,0 @@ -/* sys/ipc.h - - Copyright 2001, 2002 Red Hat Inc. - Written by Robert Collins - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGWIN_IPC_H -#define _CYGWIN_IPC_H - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -struct ipc_perm -{ - uid_t uid; /* Owner's user ID. */ - gid_t gid; /* Owner's group ID. */ - uid_t cuid; /* Creator's user ID. */ - gid_t cgid; /* Creator's group ID. */ - mode_t mode; /* Read/write permission. */ - key_t key; - unsigned short seq; -}; - -/* Mode bits: - */ -#define IPC_CREAT 0x0200 /* Create entry if key does not exist. */ -#define IPC_EXCL 0x0400 /* Fail if key exists. */ -#define IPC_NOWAIT 0x0800 /* Error if request must wait. */ -#ifdef _KERNEL -#define IPC_KEY_IS_SHMID 0x1000 /* Used in shmget when called from shmat. */ -#endif - -/* Keys: - */ -#define IPC_PRIVATE ((key_t) 0) /* Private key. */ - -/* Control commands: - */ -#define IPC_RMID 0x1000 /* Remove identifier. */ -#define IPC_SET 0x1001 /* Set options. */ -#define IPC_STAT 0x1002 /* Get options. */ -#ifdef _KERNEL -#define IPC_INFO 0x1003 /* For ipcs(8). */ -#endif - -#ifdef _KERNEL -#define IPCID_TO_IX(id) ((id) & 0xffff) -#define IPCID_TO_SEQ(id) (((id) >> 16) & 0xffff) -#define IXSEQ_TO_IPCID(ix,perm) (((perm.seq) << 16) | (ix & 0xffff)) - -#define IPC_R 000400 /* read permission */ -#define IPC_W 000200 /* write/alter permission */ -#define IPC_M 010000 /* permission to change control info */ -#endif - -key_t ftok (const char *path, int id); - -#ifdef __cplusplus -} -#endif - -#endif /* _CYGWIN_IPC_H */ diff --git a/winsup/cygwin/include/cygwin/kd.h b/winsup/cygwin/include/cygwin/kd.h deleted file mode 100644 index b4ec7c523..000000000 --- a/winsup/cygwin/include/cygwin/kd.h +++ /dev/null @@ -1,20 +0,0 @@ -/* cygwin/kd.h - - Copyright 2006 Red Hat Inc. - Written by Kazuhiro Fujieda - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGWIN_KD_H_ -#define _CYGWIN_KD_H_ - -#define KDGKBMETA 0x4b62 -#define KDSKBMETA 0x4b63 -#define K_METABIT 0x03 -#define K_ESCPREFIX 0x04 - -#endif /* _CYGWIN_KD_H_ */ diff --git a/winsup/cygwin/include/cygwin/msg.h b/winsup/cygwin/include/cygwin/msg.h deleted file mode 100644 index 8679786dd..000000000 --- a/winsup/cygwin/include/cygwin/msg.h +++ /dev/null @@ -1,102 +0,0 @@ -/* sys/msg.h - - Copyright 2002 Red Hat Inc. - Written by Conrad Scott - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGWIN_MSG_H -#define _CYGWIN_MSG_H - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* Message operation flags: - */ -#define MSG_NOERROR 0x01 /* No error if big message. */ - -#ifdef _KERNEL -/* Command definitions for the semctl () function: - */ -#define MSG_STAT 0x2000 /* For ipcs(8) */ -#define MSG_INFO 0x2001 /* For ipcs(8) */ -#endif /* _KERNEL */ - -/* Used for the number of messages in the message queue. - */ -typedef unsigned long msgqnum_t; - -/* Used for the number of bytes allowed in a message queue. - */ -typedef unsigned long msglen_t; - -struct msqid_ds -{ - struct ipc_perm msg_perm; /* Operation permission structure. */ - msglen_t msg_cbytes; /* Number of bytes currently on queue. */ - msgqnum_t msg_qnum; /* Number of messages currently on queue. */ - msglen_t msg_qbytes; /* Maximum number of bytes allowed on queue. */ - pid_t msg_lspid; /* Process ID of last msgsnd (). */ - pid_t msg_lrpid; /* Process ID of last msgrcv (). */ - timestruc_t msg_stim; /* Time of last msgsnd (). */ - timestruc_t msg_rtim; /* Time of last msgrcv (). */ - timestruc_t msg_ctim; /* Time of last change. */ -#ifdef _KERNEL - struct msg *msg_first; - struct msg *msg_last; -#else - long msg_spare4[2]; -#endif /* _KERNEL */ -}; - -#define msg_stime msg_stim.tv_sec -#define msg_rtime msg_rtim.tv_sec -#define msg_ctime msg_ctim.tv_sec - -#ifdef _KERNEL -/* Buffer type for msgctl (IPC_INFO, ...) as used by ipcs(8). - */ -struct msginfo -{ - long msgmax; /* Maximum number of bytes per - message. */ - long msgmnb; /* Maximum number of bytes on any one - message queue. */ - long msgmni; /* Maximum number of message queues, - system wide. */ - long msgtql; /* Maximum number of messages, system - wide. */ - long msgssz; /* Size of a message segment, must be - small power of 2 greater than 4. */ - long msgseg; /* Number of message segments */ - long msg_spare[2]; -}; - -/* Buffer type for msgctl (MSG_INFO, ...) as used by ipcs(8). - */ -struct msg_info -{ - long msg_ids; /* Number of allocated queues. */ - long msg_num; /* Number of messages, system wide. */ - long msg_tot; /* Size in bytes of messages, system wide. */ -}; -#endif /* _KERNEL */ - -int msgctl (int msqid, int cmd, struct msqid_ds *buf); -int msgget (key_t key, int msgflg); -ssize_t msgrcv (int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg); -int msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg); - -#ifdef __cplusplus -} -#endif - -#endif /* _CYGWIN_MSG_H */ diff --git a/winsup/cygwin/include/cygwin/mtio.h b/winsup/cygwin/include/cygwin/mtio.h deleted file mode 100644 index 04d5df451..000000000 --- a/winsup/cygwin/include/cygwin/mtio.h +++ /dev/null @@ -1,313 +0,0 @@ -/* cygwin/mtio.h - - Copyright 1999, 2001, 2004 Red Hat, Inc. - - Written by Corinna Vinschen - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* cygwin/mtio.h header file for Cygwin. - - by C. Vinschen. */ - -#ifndef _CYGWIN_MTIO_H -#define _CYGWIN_MTIO_H - -#include -#include - -#ifndef DEFTAPE -#define DEFTAPE "/dev/tape" -#endif - -/* - * Structures and definitions for mag tape io control commands - */ - -/* structure for MTIOCTOP - mag tape op command */ -struct mtop { - short mt_op; /* operations defined below */ - int mt_count; /* how many of them */ -}; - -/* Magnetic Tape operations [Not all operations supported by all drivers]: */ -#define MTRESET 0 /* reset drive in case of problems */ -#define MTFSF 1 /* forward space over FileMark, - * position at first record of next file - */ -#define MTBSF 2 /* backward space FileMark (position before FM) */ -#define MTFSR 3 /* forward space record */ -#define MTBSR 4 /* backward space record */ -#define MTWEOF 5 /* write an end-of-file record (mark) */ -#define MTREW 6 /* rewind */ -#define MTOFFL 7 /* rewind and put the drive offline (eject?) */ -#define MTNOP 8 /* no op, set status only (read with MTIOCGET) */ -#define MTRETEN 9 /* retension tape */ -#define MTBSFM 10 /* +backward space FileMark, position at FM */ -#define MTFSFM 11 /* +forward space FileMark, position at FM */ -#define MTEOM 12 /* goto end of recorded media (for appending files). - * MTEOM positions after the last FM, ready for - * appending another file. - */ -#define MTERASE 13 /* erase tape -- be careful! */ - -#define MTRAS1 14 /* run self test 1 (nondestructive) */ -#define MTRAS2 15 /* run self test 2 (destructive) */ -#define MTRAS3 16 /* reserved for self test 3 */ - -#define MTSETBLK 20 /* set block length (SCSI) */ -#define MTSETDENSITY 21 /* set tape density (SCSI) */ -#define MTSEEK 22 /* seek to block (Tandberg, etc.) */ -#define MTTELL 23 /* tell block (Tandberg, etc.) */ -#define MTSETDRVBUFFER 24 /* set the drive buffering according to SCSI-2 */ - /* ordinary buffered operation with code 1 */ -#define MTFSS 25 /* space forward over setmarks */ -#define MTBSS 26 /* space backward over setmarks */ -#define MTWSM 27 /* write setmarks */ - -#define MTLOCK 28 /* lock the drive door */ -#define MTUNLOCK 29 /* unlock the drive door */ -#define MTLOAD 30 /* execute the SCSI load command */ -#define MTUNLOAD 31 /* execute the SCSI unload command */ -#define MTCOMPRESSION 32/* control compression with SCSI mode page 15 */ -#define MTSETPART 33 /* Change the active tape partition */ -#define MTMKPART 34 /* Format the tape with one or two partitions */ - -/* structure for MTIOCGET - mag tape get status command */ - -struct mtget { - long mt_type; /* type of magtape device */ - long mt_resid; /* residual count: (not sure) - * number of bytes ignored, or - * number of files not skipped, or - * number of records not skipped. - * Cygwin: remaining KB until 1.5.7. - * active partition since 1.5.8 - * (same as on GNU-Linux). - */ - /* the following registers are device dependent */ - long mt_dsreg; /* status register, Contains blocksize and - density code. See MT_ST_xxx macros below */ - long mt_gstat; /* generic (device independent) status */ - long mt_erreg; /* error register */ - /* The next two fields are not always used */ - long mt_fileno; /* number of current file on tape */ - long mt_blkno; /* current block number */ - /* The next are Windows NT specific */ - long long mt_capacity; /* Tape capacity in bytes */ - long long mt_remaining; /* Remaining bytes */ - int mt_minblksize; - int mt_maxblksize; - int mt_defblksize; - unsigned long mt_featureslow; - unsigned long mt_featureshigh; - unsigned long mt_eotwarningzonesize; -}; - -/* structure for MTIOCPOS - mag tape get position command */ - -struct mtpos { - long mt_blkno; /* current block number */ -}; - - -/* mag tape io control commands */ -#define MTIOCTOP _IOW('m', 1, struct mtop) /* do a mag tape op */ -#define MTIOCGET _IOR('m', 2, struct mtget) /* get tape status */ -#define MTIOCPOS _IOR('m', 3, struct mtpos) /* get tape position */ - -/* Generic Mag Tape (device independent) status macros for examining - * mt_gstat -- HP-UX compatible. - * There is room for more generic status bits here, but I don't - * know which of them are reserved. At least three or so should - * be added to make this really useful. - */ -#define GMT_EOF(x) ((x) & 0x80000000) -#define GMT_BOT(x) ((x) & 0x40000000) -#define GMT_EOT(x) ((x) & 0x20000000) -#define GMT_SM(x) ((x) & 0x10000000) /* DDS setmark */ -#define GMT_EOD(x) ((x) & 0x08000000) /* DDS EOD */ -#define GMT_WR_PROT(x) ((x) & 0x04000000) -#define GMT_REP_SM(x) ((x) & 0x02000000) /* Cygwin: rep. setmarks */ -#define GMT_ONLINE(x) ((x) & 0x01000000) -#define GMT_D_6250(x) ((x) & 0x00800000) -#define GMT_D_1600(x) ((x) & 0x00400000) -#define GMT_D_800(x) ((x) & 0x00200000) -#define GMT_PADDING(x) ((x) & 0x00100000) /* Cygwin: data padding */ -#define GMT_HW_ECC(x) ((x) & 0x00080000) /* Cygwin: HW error corr. */ -#define GMT_DR_OPEN(x) ((x) & 0x00040000) /* door open (no tape) */ -#define GMT_HW_COMP(x) ((x) & 0x00020000) /* Cygwin: HW compression */ -#define GMT_IM_REP_EN(x) ((x) & 0x00010000) /* immediate report mode */ -#define GMT_CLN(x) ((x) & 0x00008000) /* cleaning requested */ -/* 15 generic status bits unused */ -/* Cygwin only: The below settings are also used by the GNU-Linux SCSI tape - driver but they aren't usually reported here. Unfortunately, there's no - other official method to retrieve the values of these settings and - reporting them here apparently doesn't hurt. */ -#define GMT_TWO_FM(x) ((x) & 0x00000080) /* two fm after write */ -#define GMT_FAST_MTEOM(x) ((x) & 0x00000040) /* fast seek to eom */ -#define GMT_AUTO_LOCK(x) ((x) & 0x00000020) /* auto door lock on r/w */ -#define GMT_SYSV(x) ((x) & 0x00000010) /* SYSV read semantics */ -#define GMT_NOWAIT(x) ((x) & 0x00000008) /* don't wait for positioning commands */ -#define GMT_ASYNC(x) ((x) & 0x00000004) /* asynchronous writes */ - - -/* SCSI-tape specific definitions */ -/* Bitfield shifts in the status mt_dsreg */ -#define MT_ST_BLKSIZE_SHIFT 0 -#define MT_ST_BLKSIZE_MASK 0xffffff -#define MT_ST_DENSITY_SHIFT 24 -#define MT_ST_DENSITY_MASK 0xff000000 - -#define MT_ST_SOFTERR_SHIFT 0 -#define MT_ST_SOFTERR_MASK 0xffff - -/* Bitfields for the MTSETDRVBUFFER ioctl. */ -#define MT_ST_OPTIONS 0xf0000000 -#define MT_ST_BOOLEANS 0x10000000 -#define MT_ST_SETBOOLEANS 0x30000000 -#define MT_ST_CLEARBOOLEANS 0x40000000 -#define MT_ST_WRITE_THRESHOLD 0x20000000 /* Not supported */ -#define MT_ST_DEF_OPTIONS 0x60000000 /* Not supported */ -#define MT_ST_EOT_WZ_SIZE 0xf0000000 /* Cygwin only */ - -#define MT_ST_BUFFER_WRITES 0x00000001 -#define MT_ST_ASYNC_WRITES 0x00000002 -#define MT_ST_READ_AHEAD 0x00000004 /* Not supported */ -#define MT_ST_DEBUGGING 0x00000008 /* Not supported */ -#define MT_ST_TWO_FM 0x00000010 -#define MT_ST_FAST_MTEOM 0x00000020 -#define MT_ST_AUTO_LOCK 0x00000040 -#define MT_ST_DEF_WRITES 0x00000080 /* Not supported */ -#define MT_ST_CAN_BSR 0x00000100 /* Not supported */ -#define MT_ST_NO_BLKLIMS 0x00000200 /* Not supported */ -#define MT_ST_CAN_PARTITIONS 0x00000400 /* Not supported */ -#define MT_ST_SCSI2LOGICAL 0x00000800 /* Not supported */ -#define MT_ST_SYSV 0x00001000 -#define MT_ST_NOWAIT 0x00002000 -#define MT_ST_ECC 0x00010000 /* Cygwin only */ -#define MT_ST_PADDING 0x00020000 /* Cygwin only */ -#define MT_ST_REPORT_SM 0x00040000 /* Cygwin only */ - -/* - * Constants for mt_type. Not all of these are supported, - * and these are not all of the ones that are supported. - * - * Only used when not colliding with Windows codes (see below) - */ -#define MT_ISUNKNOWN 0x01 -#define MT_ISQIC02 0x02 /* Generic QIC-02 tape streamer */ -#define MT_ISWT5150 0x03 /* Wangtek 5150EQ, QIC-150, QIC-02 */ -#define MT_ISARCHIVE_5945L2 0x04 /* Archive 5945L-2, QIC-24, QIC-02? */ -#define MT_ISCMSJ500 0x05 /* CMS Jumbo 500 (QIC-02?) */ -#define MT_ISTDC3610 0x06 /* Tandberg 6310, QIC-24 */ -#define MT_ISARCHIVE_VP60I 0x07 /* Archive VP60i, QIC-02 */ -#define MT_ISARCHIVE_2150L 0x08 /* Archive Viper 2150L */ -#define MT_ISARCHIVE_2060L 0x09 /* Archive Viper 2060L */ -#define MT_ISARCHIVESC499 0x0A /* Archive SC-499 QIC-36 controller */ -#define MT_ISQIC02_ALL_FEATURES 0x0F /* Generic QIC-02 with all features */ -#define MT_ISWT5099EEN24 0x11 /* Wangtek 5099-een24, 60MB, QIC-24 */ -#define MT_ISTEAC_MT2ST 0x12 /* Teac MT-2ST 155mb drive, Teac DC-1 card (Wangtek type) */ -#define MT_ISEVEREX_FT40A 0x32 /* Everex FT40A (QIC-40) */ -#define MT_ISDDS1 0x51 /* DDS device without partitions */ -#define MT_ISDDS2 0x52 /* DDS device with partitions */ -#define MT_ISSCSI1 0x71 /* Generic ANSI SCSI-1 tape unit */ -#define MT_ISSCSI2 0x72 /* Generic ANSI SCSI-2 tape unit */ - -/* More constants for mt_type. These are the codes used by Windows >= 5.1 */ -#define MT_ISDDS_4mm 0x20 -#define MT_ISMiniQic 0x21 -#define MT_ISTravan 0x22 -#define MT_ISQIC 0x23 -#define MT_ISMP_8mm 0x24 -#define MT_ISAME_8mm 0x25 -#define MT_ISAIT1_8mm 0x26 -#define MT_ISDLT 0x27 -#define MT_ISNCTP 0x28 -#define MT_ISIBM_3480 0x29 -#define MT_ISIBM_3490E 0x2a -#define MT_ISIBM_Magstar_3590 0x2b -#define MT_ISIBM_Magstar_MP 0x2c -#define MT_ISSTK_DATA_D3 0x2d -#define MT_ISSONY_DTF 0x2e -#define MT_ISDV_6mm 0x2f -#define MT_ISDMI 0x30 -#define MT_ISSONY_D2 0x31 -#define MT_ISCLEANER_CARTRIDGE 0x32 -#define MT_ISAVATAR_F2 0x4f -#define MT_ISMP2_8mm 0x50 -#define MT_ISDST_S 0x51 -#define MT_ISDST_M 0x52 -#define MT_ISDST_L 0x53 -#define MT_ISVXATape_1 0x54 -#define MT_ISVXATape_2 0x55 -#define MT_ISSTK_9840 0x56 -#define MT_ISLTO_Ultrium 0x57 -#define MT_ISLTO_Accelis 0x58 -#define MT_ISAIT_8mm 0x5a -#define MT_ISADR_1 0x5b -#define MT_ISADR_2 0x5c -#define MT_ISSTK_9940 0x5d - -struct mt_tape_info { - long t_type; /* device type id (mt_type) */ - char *t_name; /* descriptive name */ -}; - -#define MT_TAPE_INFO { \ - {MT_ISUNKNOWN, "Unknown type of tape device"}, \ - {MT_ISQIC02, "Generic QIC-02 tape streamer"}, \ - {MT_ISWT5150, "Wangtek 5150, QIC-150"}, \ - {MT_ISARCHIVE_5945L2, "Archive 5945L-2"}, \ - {MT_ISCMSJ500, "CMS Jumbo 500"}, \ - {MT_ISTDC3610, "Tandberg TDC 3610, QIC-24"}, \ - {MT_ISARCHIVE_VP60I, "Archive VP60i, QIC-02"}, \ - {MT_ISARCHIVE_2150L, "Archive Viper 2150L"}, \ - {MT_ISARCHIVE_2060L, "Archive Viper 2060L"}, \ - {MT_ISARCHIVESC499, "Archive SC-499 QIC-36 controller"}, \ - {MT_ISQIC02_ALL_FEATURES, "Generic QIC-02 tape, all features"}, \ - {MT_ISWT5099EEN24, "Wangtek 5099-een24, 60MB"}, \ - {MT_ISTEAC_MT2ST, "Teac MT-2ST 155mb data cassette drive"}, \ - {MT_ISDDS_4mm, "DDS"}, \ - {MT_ISMiniQic, "MiniQic"}, \ - {MT_ISTravan, "Travan tape"}, \ - {MT_ISQIC, "QIC tape"}, \ - {MT_ISMP_8mm, "8mm Exabyte metal particle tape"}, \ - {MT_ISAME_8mm, "8mm Exabyte advanced metal evap tape"}, \ - {MT_ISAIT1_8mm, "8mm Sony AIT1 tape"}, \ - {MT_ISDLT, "DLT compact tape)"}, \ - {MT_ISNCTP, "Philips NCTP tape"}, \ - {MT_ISIBM_3480, "IBM 3480 tape"}, \ - {MT_ISIBM_3490E, "IBM 3490E tape"}, \ - {MT_ISIBM_Magstar_3590, "IBM Magstar 3590 tape"}, \ - {MT_ISIBM_Magstar_MP, "IBM Magstar MP tape"}, \ - {MT_ISSTK_DATA_D3, "STK data D3 tape"}, \ - {MT_ISSONY_DTF, "Sony DTF tape"}, \ - {MT_ISDV_6mm, "6mm digital video tape"}, \ - {MT_ISDMI, "Exabyte DMI tape"}, \ - {MT_ISSONY_D2, "Sony D2S or D2L tape"}, \ - {MT_ISCLEANER_CARTRIDGE, "Cleaner (all drive types that support cleaners)"}, \ - {MT_ISAVATAR_F2, "Avatar 2"}, \ - {MT_ISMP2_8mm, "8mm Hitachi tape"}, \ - {MT_ISDST_S, "Ampex DST small tape"}, \ - {MT_ISDST_M, "Ampex DST medium tape"}, \ - {MT_ISDST_L, "Ampex DST large tape"}, \ - {MT_ISVXATape_1, "Ecrix 8mm tape"}, \ - {MT_ISVXATape_2, "Ecrix 8mm tape"}, \ - {MT_ISSTK_9840, "STK 9840"}, \ - {MT_ISLTO_Ultrium, "LTO Ultrium (IBM, HP, Seagate)"}, \ - {MT_ISLTO_Accelis, "LTO Accelis (IBM, HP, Seagate)"}, \ - {MT_ISAIT_8mm, "AIT tape (AIT2 or higher)"}, \ - {MT_ISADR_1, "OnStream ADR1"}, \ - {MT_ISADR_2, "OnStream ADR2"}, \ - {MT_ISSTK_9940, "STK 9940"}, \ - {MT_ISSCSI1, "Generic SCSI-1 tape"}, \ - {MT_ISSCSI2, "Generic SCSI-2 tape"}, \ - {0, NULL} \ -} - -#endif /* _CYGWIN_MTIO_H */ diff --git a/winsup/cygwin/include/cygwin/rdevio.h b/winsup/cygwin/include/cygwin/rdevio.h deleted file mode 100644 index 73059ac09..000000000 --- a/winsup/cygwin/include/cygwin/rdevio.h +++ /dev/null @@ -1,42 +0,0 @@ -/* cygwin/rdevio.h - - Copyright 1999, 2001 Red Hat, Inc. - - Written by Corinna Vinschen - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* - * cygwin/rdevio.h header file for Cygwin. - * - * Written by C. Vinschen. - */ - -#ifndef _CYGWIN_RDEVIO_H -#define _CYGWIN_RDEVIO_H - -/* structure for RDIOCDOP - raw device operation */ -struct rdop { - short rd_op; - unsigned long rd_parm; -}; - -/* Raw device operations */ -#define RDSETBLK 1 /* set buffer for driver */ - -/* structure for RDIOCGET - get raw device */ -struct rdget { - unsigned long bufsiz; -}; - -/* - * ioctl commands -*/ -#define RDIOCDOP _IOW('r', 128, struct rdop) -#define RDIOCGET _IOR('r', 129, struct rdget) - -#endif /* _CYGWIN_RDEVIO_H */ diff --git a/winsup/cygwin/include/cygwin/sem.h b/winsup/cygwin/include/cygwin/sem.h deleted file mode 100644 index af7a42f36..000000000 --- a/winsup/cygwin/include/cygwin/sem.h +++ /dev/null @@ -1,128 +0,0 @@ -/* sys/sem.h - - Copyright 2002 Red Hat Inc. - Written by Conrad Scott - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGWIN_SEM_H -#define _CYGWIN_SEM_H - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* Semaphore operation flags: - */ -#define SEM_UNDO 010000 /* Set up adjust on exit entry. */ - -/* Command definitions for the semctl () function: - */ -#define GETNCNT 0x3000 /* Get semncnt. */ -#define GETPID 0x3001 /* Get sempid. */ -#define GETVAL 0x3002 /* Get semval. */ -#define GETALL 0x3003 /* Get all cases of semval. */ -#define GETZCNT 0x3004 /* Get semzcnt. */ -#define SETVAL 0x3005 /* Set semval. */ -#define SETALL 0x3006 /* Set all cases of semval. */ - -#ifdef _KERNEL -#define SEM_STAT 0x3010 /* For ipcs(8). */ -#define SEM_INFO 0x3011 /* For ipcs(8). */ -#endif /* _KERNEL */ - -struct semid_ds -{ - struct ipc_perm sem_perm; /* Operation permission structure. */ - unsigned short sem_nsems; /* Number of semaphores in set. */ - timestruc_t sem_otim; /* Last semop () time. */ - timestruc_t sem_ctim; /* Last time changed by semctl (). */ -#ifdef _KERNEL - struct sem *sem_base; /* pointer to first semaphore in set */ - long sem_spare4[1]; -#else - long sem_spare4[2]; -#endif /* _KERNEL */ -}; - -#define sem_otime sem_otim.tv_sec -#define sem_ctime sem_ctim.tv_sec - -struct sembuf -{ - unsigned short sem_num; /* Semaphore number. */ - short sem_op; /* Semaphore operation. */ - short sem_flg; /* Operation flags. */ -}; - -#ifdef _KERNEL -/* Buffer type for semctl (IPC_INFO, ...) as used by ipcs(8). - */ -struct seminfo -{ - long semmni; /* Maximum number of unique semaphore - sets, system wide. */ - long semmns; /* Maximum number of semaphores, - system wide. */ - long semmsl; /* Maximum number of semaphores per - semaphore set. */ - long semopm; /* Maximum number of operations per - semop call. */ - long semmnu; /* Maximum number of undo structures, - system wide. */ - long semume; /* Maximum number of undo entries per - undo structure. */ - long semvmx; /* Maximum semaphore value. */ - long semaem; /* Maximum adjust-on-exit value. */ - long semmap; /* # of entries in semaphore map */ - long semusz; /* size in bytes of undo structure */ - long sem_spare[2]; -}; - -/* Buffer type for semctl (SEM_INFO, ...) as used by ipcs(8). - */ -struct sem_info -{ - long sem_ids; /* Number of allocated semaphore sets. */ - long sem_num; /* Number of allocated semaphores. */ -}; - -/* Permission flags */ -#define SEM_A IPC_W /* alter permission */ -#define SEM_R IPC_R /* read permission */ - -/* Internally used mode bits. */ -#define SEM_ALLOC 01000 /* semaphore is allocated */ - -#endif /* _KERNEL */ - -#ifdef _KERNEL -/* According to SUSv3, "the fourth argument [to semctl()] is optional and - depends upon the operation requested. If required, it is of type - union semun, which the application shall explicitly declare:" */ -union semun { - int val; /* value for SETVAL */ - struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */ - unsigned short *array; /* array for GETALL, SETALL */ -}; -/* Therefore this union is only declared here if building internal code. - _KERNEL must not be defined in exernal applications! Declare union - semun explicitely as required by SUSv3, please. */ -#endif /* _KERNEL */ - -int semctl (int semid, int semnum, int cmd, ...); -int semget (key_t key, int nsems, int semflg); -int semop (int semid, struct sembuf *sops, size_t nsops); - -#ifdef __cplusplus -} -#endif - -#endif /* _CYGWIN_SEM_H */ diff --git a/winsup/cygwin/include/cygwin/shm.h b/winsup/cygwin/include/cygwin/shm.h deleted file mode 100644 index 2c882012c..000000000 --- a/winsup/cygwin/include/cygwin/shm.h +++ /dev/null @@ -1,106 +0,0 @@ -/* sys/shm.h - - Copyright 2001, 2002 Red Hat Inc. - Written by Robert Collins - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGWIN_SHM_H -#define _CYGWIN_SHM_H - -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* Segment low boundary address multiple. - * - * 64 Kb was hardcoded for x86. MS states this may change so the constant - * expression is replaced by a function call returning the correct value. */ -#define SHMLBA (cygwin_internal (CW_GET_SHMLBA)) - -/* Shared memory operation flags: - */ -#define SHM_RDONLY 0x01 /* Attach read-only (else read-write). */ -#define SHM_RND 0x02 /* Round attach address to SHMLBA. */ - -#ifdef _KERNEL -/* Command definitions for the semctl () function: - */ -#define SHM_STAT 0x4000 /* For ipcs(8) */ -#define SHM_INFO 0x4001 /* For ipcs(8) */ -#endif /* _KERNEL */ - -/* Unsigned integer used for the number of current attaches. - */ -typedef unsigned int shmatt_t; - -struct shmid_ds -{ - struct ipc_perm shm_perm; /* Operation permission structure. */ - size_t shm_segsz; /* Size of segment in bytes. */ - pid_t shm_lpid; /* Process ID of last operation. */ - pid_t shm_cpid; /* Process ID of creator. */ - shmatt_t shm_nattch;/* Number of current attaches. */ - timestruc_t shm_atim; /* Time of last shmat (). */ - timestruc_t shm_dtim; /* Time of last shmdt (). */ - timestruc_t shm_ctim; /* Time of last change by shmctl (). */ -#ifdef _KERNEL - struct shm_handle *shm_internal; - long shm_spare4[1]; -#else - long shm_spare4[2]; -#endif /* _KERNEL */ -}; - -#define shm_atime shm_atim.tv_sec -#define shm_dtime shm_dtim.tv_sec -#define shm_ctime shm_ctim.tv_sec - -#ifdef _KERNEL -/* Buffer type for shmctl (IPC_INFO, ...) as used by ipcs(8). - */ -struct shminfo -{ - long shmmax; /* Maximum size in bytes of a shared - memory segment. */ - long shmmin; /* Minimum size in bytes of a shared - memory segment. */ - long shmmni; /* Maximum number of shared memory - segments, system wide. */ - long shmseg; /* Maximum number of shared memory - segments attached per process. */ - long shmall; /* Maximum number of bytes of shared - memory, system wide. */ - long shm_spare[4]; -}; - -/* Buffer type for shmctl (SHM_INFO, ...) as used by ipcs(8). - */ -struct shm_info -{ -#define shm_ids used_ids - long used_ids; /* Number of allocated segments. */ - long shm_tot; /* Size in bytes of allocated segments. */ - long shm_atts; /* Number of attached segments, system - wide. */ -}; -#endif /* _KERNEL */ - -void *shmat (int shmid, const void *shmaddr, int shmflg); -int shmctl (int shmid, int cmd, struct shmid_ds *buf); -int shmdt (const void *shmaddr); -int shmget (key_t key, size_t size, int shmflg); - -#ifdef __cplusplus -} -#endif - -#endif /* _CYGWIN_SHM_H */ diff --git a/winsup/cygwin/include/cygwin/signal.h b/winsup/cygwin/include/cygwin/signal.h deleted file mode 100644 index a3cc90b22..000000000 --- a/winsup/cygwin/include/cygwin/signal.h +++ /dev/null @@ -1,281 +0,0 @@ -/* signal.h - - Copyright 2004, 2005, 2006 Red Hat, Inc. - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#ifndef _CYGWIN_SIGNAL_H -#define _CYGWIN_SIGNAL_H - -#ifdef __cplusplus -extern "C" { -#endif -struct _fpstate -{ - unsigned long cw; - unsigned long sw; - unsigned long tag; - unsigned long ipoff; - unsigned long cssel; - unsigned long dataoff; - unsigned long datasel; - unsigned char _st[80]; - unsigned long nxst; -}; - -struct ucontext -{ - unsigned long cr2; - unsigned long dr0; - unsigned long dr1; - unsigned long dr2; - unsigned long dr3; - unsigned long dr6; - unsigned long dr7; - struct _fpstate fpstate; - unsigned long gs; - unsigned long fs; - unsigned long es; - unsigned long ds; - unsigned long edi; - unsigned long esi; - unsigned long ebx; - unsigned long edx; - unsigned long ecx; - unsigned long eax; - unsigned long ebp; - unsigned long eip; - unsigned long cs; - unsigned long eflags; - unsigned long esp; - unsigned long ss; - unsigned char _internal; - unsigned long oldmask; -}; - -#define __COPY_CONTEXT_SIZE ((unsigned) &((struct ucontext *) 0)->_internal) - -typedef union sigval -{ - int sival_int; /* integer signal value */ - void *sival_ptr; /* pointer signal value */ -} sigval_t; - -typedef struct sigevent -{ - sigval_t sigev_value; /* signal value */ - int sigev_signo; /* signal number */ - int sigev_notify; /* notification type */ - void (*sigev_notify_function) (sigval_t); /* notification function */ - pthread_attr_t *sigev_notify_attributes; /* notification attributes */ -} sigevent_t; - -#pragma pack(push,4) -struct _sigcommune -{ - __uint32_t _si_code; - void *_si_read_handle; - void *_si_write_handle; - void *_si_process_handle; - __extension__ union - { - int _si_fd; - void *_si_pipe_fhandler; - char *_si_str; - }; -}; - -typedef struct -{ - int si_signo; /* signal number */ - int si_code; /* signal code */ - pid_t si_pid; /* sender's pid */ - uid_t si_uid; /* sender's uid */ - int si_errno; /* errno associated with signal */ - - __extension__ union - { - __uint32_t __pad[32]; /* plan for future growth */ - struct _sigcommune _si_commune; /* cygwin ipc */ - __extension__ union - { - /* timers */ - struct - { - union - { - struct - { - timer_t si_tid; /* timer id */ - unsigned int si_overrun; /* overrun count */ - }; - sigval_t si_sigval; /* signal value */ - sigval_t si_value; /* signal value */ - }; - }; - }; - - /* SIGCHLD */ - __extension__ struct - { - int si_status; /* exit code */ - clock_t si_utime; /* user time */ - clock_t si_stime; /* system time */ - }; - - /* core dumping signals */ - void *si_addr; /* faulting address */ - }; -} siginfo_t; -#pragma pack(pop) - -enum -{ - SI_USER = 0, /* sent by kill, raise, pthread_kill */ - SI_ASYNCIO = 2, /* sent by AIO completion (currently - unimplemented) */ - SI_MESGQ, /* sent by real time mesq state change - (currently unimplemented) */ - SI_TIMER, /* sent by timer expiration */ - SI_QUEUE, /* sent by sigqueue (currently - unimplemented) */ - SI_KERNEL, /* sent by system */ - - ILL_ILLOPC, /* illegal opcode */ - ILL_ILLOPN, /* illegal operand */ - ILL_ILLADR, /* illegal addressing mode */ - ILL_ILLTRP, /* illegal trap*/ - ILL_PRVOPC, /* privileged opcode */ - ILL_PRVREG, /* privileged register */ - ILL_COPROC, /* coprocessor error */ - ILL_BADSTK, /* internal stack error */ - - FPE_INTDIV, /* integer divide by zero */ - FPE_INTOVF, /* integer overflow */ - FPE_FLTDIV, /* floating point divide by zero */ - FPE_FLTOVF, /* floating point overflow */ - FPE_FLTUND, /* floating point underflow */ - FPE_FLTRES, /* floating point inexact result */ - FPE_FLTINV, /* floating point invalid operation */ - FPE_FLTSUB, /* subscript out of range */ - - SEGV_MAPERR, /* address not mapped to object */ - SEGV_ACCERR, /* invalid permissions for mapped object */ - - BUS_ADRALN, /* invalid address alignment. */ - BUS_ADRERR, /* non-existant physical address. */ - BUS_OBJERR, /* object specific hardware error. */ - - CLD_EXITED, /* child has exited */ - CLD_KILLED, /* child was killed */ - CLD_DUMPED, /* child terminated abnormally */ - CLD_TRAPPED, /* traced child has trapped */ - CLD_STOPPED, /* child has stopped */ - CLD_CONTINUED /* stopped child has continued */ -}; - -enum -{ - SIGEV_SIGNAL = 0, /* a queued signal, with an application - defined value, is generated when the - event of interest occurs */ - SIGEV_NONE, /* no asynchronous notification is - delivered when the event of interest - occurs */ - SIGEV_THREAD /* a notification function is called to - perform notification */ -}; - -typedef void (*_sig_func_ptr)(int); - -struct sigaction -{ - __extension__ union - { - _sig_func_ptr sa_handler; /* SIG_DFL, SIG_IGN, or pointer to a function */ - void (*sa_sigaction) ( int, siginfo_t *, void * ); - }; - sigset_t sa_mask; - int sa_flags; -}; - -#define SA_NOCLDSTOP 1 /* Do not generate SIGCHLD when children - stop */ -#define SA_SIGINFO 2 /* Invoke the signal catching function - with three arguments instead of one - */ -#define SA_RESTART 0x10000000 /* Restart syscall on signal return */ -#define SA_NODEFER 0x40000000 /* Don't automatically block the signal - when its handler is being executed */ -#define SA_RESETHAND 0x80000000 /* Reset to SIG_DFL on entry to handler */ -#define SA_ONESHOT SA_RESETHAND /* Historical linux name */ -#define SA_NOMASK SA_NODEFER /* Historical linux name */ - -/* Used internally by cygwin. Included here to group everything in one place. - Do not use. */ -#define _SA_INTERNAL_MASK 0xf000 /* bits in this range are internal */ - -#define SIGHUP 1 /* hangup */ -#define SIGINT 2 /* interrupt */ -#define SIGQUIT 3 /* quit */ -#define SIGILL 4 /* illegal instruction (not reset when caught) */ -#define SIGTRAP 5 /* trace trap (not reset when caught) */ -#define SIGABRT 6 /* used by abort */ -#define SIGEMT 7 /* EMT instruction */ -#define SIGFPE 8 /* floating point exception */ -#define SIGKILL 9 /* kill (cannot be caught or ignored) */ -#define SIGBUS 10 /* bus error */ -#define SIGSEGV 11 /* segmentation violation */ -#define SIGSYS 12 /* bad argument to system call */ -#define SIGPIPE 13 /* write on a pipe with no one to read it */ -#define SIGALRM 14 /* alarm clock */ -#define SIGTERM 15 /* software termination signal from kill */ -#define SIGURG 16 /* urgent condition on IO channel */ -#define SIGSTOP 17 /* sendable stop signal not from tty */ -#define SIGTSTP 18 /* stop signal from tty */ -#define SIGCONT 19 /* continue a stopped process */ -#define SIGCHLD 20 /* to parent on child stop or exit */ -#define SIGCLD 20 /* System V name for SIGCHLD */ -#define SIGTTIN 21 /* to readers pgrp upon background tty read */ -#define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ -#define SIGIO 23 /* input/output possible signal */ -#define SIGPOLL SIGIO /* System V name for SIGIO */ -#define SIGXCPU 24 /* exceeded CPU time limit */ -#define SIGXFSZ 25 /* exceeded file size limit */ -#define SIGVTALRM 26 /* virtual time alarm */ -#define SIGPROF 27 /* profiling time alarm */ -#define SIGWINCH 28 /* window changed */ -#define SIGLOST 29 /* resource lost (eg, record-lock lost) */ -#define SIGUSR1 30 /* user defined signal 1 */ -#define SIGUSR2 31 /* user defined signal 2 */ - -/* Real-Time signals per SUSv3. RT_SIGMAX is defined as 8 in limits.h */ -#define SIGRTMIN 32 -#define SIGRTMAX ((SIGRTMIN) + 0) -#define NSIG 33 /* signal 0 implied */ - -#define SIG_HOLD ((_sig_func_ptr)2) /* Signal in signal mask */ - -int sigwait (const sigset_t *, int *); -int sigwaitinfo (const sigset_t *, siginfo_t *); -int sighold (int); -int sigignore (int); -int sigrelse (int); -_sig_func_ptr sigset (int, _sig_func_ptr); - -int sigqueue(pid_t, int, const union sigval); -int siginterrupt (int, int); -#ifdef __INSIDE_CYGWIN__ -extern const char *sys_sigabbrev[]; -#else -extern const char __declspec(dllimport) *sys_sigabbrev[]; -#endif - -#ifdef __cplusplus -} -#endif -#endif /*_CYGWIN_SIGNAL_H*/ diff --git a/winsup/cygwin/include/cygwin/socket.h b/winsup/cygwin/include/cygwin/socket.h deleted file mode 100644 index 0f099241a..000000000 --- a/winsup/cygwin/include/cygwin/socket.h +++ /dev/null @@ -1,306 +0,0 @@ -/* cygwin/socket.h - - Copyright 1999, 2000, 2001, 2005, 2006, 2007, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGWIN_SOCKET_H -#define _CYGWIN_SOCKET_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include - -/* Not unsigned for backward compatibility. Keep #define for backward - compatibility. */ -#ifndef socklen_t -typedef int socklen_t; -#define socklen_t socklen_t -#endif - -typedef uint16_t sa_family_t; - -struct sockaddr { - sa_family_t sa_family; /* address family, AF_xxx */ - char sa_data[14]; /* 14 bytes of protocol address */ -}; - -/* Definition of sockaddr_storage according to SUSv3. */ -#define _SS_MAXSIZE 128 /* Maximum size. */ -#define _SS_ALIGNSIZE (sizeof (int64_t))/* Desired alignment. */ -#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof (sa_family_t)) -#define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (sa_family_t) \ - + _SS_PAD1SIZE + _SS_ALIGNSIZE)) - -struct sockaddr_storage { - sa_family_t ss_family; - char _ss_pad1[_SS_PAD1SIZE]; - int64_t __ss_align; - char _ss_pad2[_SS_PAD2SIZE]; -}; - -#include /* arch-dependent defines */ -#include /* the SIOCxxx I/O controls */ -#include /* iovec support */ -#include - -struct ucred { - pid_t pid; - __uid32_t uid; - __gid32_t gid; -}; - -struct linger { - unsigned short l_onoff; /* Linger active */ - unsigned short l_linger; /* How long to linger for */ -}; - -struct msghdr -{ - void * msg_name; /* Socket name */ - socklen_t msg_namelen; /* Length of name */ - struct iovec * msg_iov; /* Data blocks */ - int msg_iovlen; /* Number of blocks */ - void * msg_control; /* Ancillary data */ - socklen_t msg_controllen; /* Ancillary data buffer length */ - int msg_flags; /* Received flags on recvmsg */ -}; - -struct cmsghdr -{ - socklen_t cmsg_len; /* Length of cmsghdr + data */ - int cmsg_level; /* Protocol */ - int cmsg_type; /* Protocol type */ -}; - -#define CMSG_ALIGN(len) \ - (((len) + __alignof__ (struct cmsghdr) - 1) \ - & ~(__alignof__ (struct cmsghdr) - 1)) -#define CMSG_LEN(len) \ - (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len)) -#define CMSG_SPACE(len) \ - (CMSG_ALIGN (sizeof (struct cmsghdr)) + CMSG_ALIGN(len)) -#define CMSG_FIRSTHDR(mhdr) \ - ({ \ - struct msghdr *_m = (struct msghdr *) mhdr; \ - (unsigned) (_m)->msg_controllen >= sizeof (struct cmsghdr) \ - ? (struct cmsghdr *) (_m)->msg_control \ - : (struct cmsghdr *) NULL; \ - }) -#define CMSG_NXTHDR(mhdr,cmsg) \ - ({ \ - struct msghdr *_m = (struct msghdr *) mhdr; \ - struct cmsghdr *_c = (struct cmsghdr *) cmsg; \ - ((char *) _c + CMSG_SPACE (_c->cmsg_len) \ - > (char *) _m->msg_control + _m->msg_controllen) \ - ? (struct cmsghdr *) NULL \ - : (struct cmsghdr *) ((char *) _c + CMSG_ALIGN (_c->cmsg_len)); \ - }) -#define CMSG_DATA(cmsg) \ - ((unsigned char *) ((struct cmsghdr *)(cmsg) + 1)) - -/* "Socket"-level control message types: */ -#define SCM_RIGHTS 0x01 /* access rights (array of int) */ - -#ifdef __INSIDE_CYGWIN__ -/* Definition of struct msghdr up to release 1.5.18 */ -struct OLD_msghdr -{ - void * msg_name; /* Socket name */ - int msg_namelen; /* Length of name */ - struct iovec * msg_iov; /* Data blocks */ - int msg_iovlen; /* Number of blocks */ - void * msg_accrights; /* Per protocol magic */ - /* (eg BSD descriptor passing) */ - int msg_accrightslen; /* Length of rights list */ -}; -#endif - -/* Socket types. */ -#define SOCK_STREAM 1 /* stream (connection) socket */ -#define SOCK_DGRAM 2 /* datagram (conn.less) socket */ -#define SOCK_RAW 3 /* raw socket */ -#define SOCK_RDM 4 /* reliably-delivered message */ -#define SOCK_SEQPACKET 5 /* sequential packet socket */ - -/* GNU extension flags. Or them to the type parameter in calls to - socket(2) to mark socket as nonblocking and/or close-on-exec. */ -#define SOCK_NONBLOCK 0x01000000 -#define SOCK_CLOEXEC 0x02000000 -#ifdef __INSIDE_CYGWIN__ -#define _SOCK_FLAG_MASK 0xff000000 /* Bits left for more extensions */ -#endif - -/* Supported address families. */ -/* - * Address families. - */ -#define AF_UNSPEC 0 /* unspecified */ -#define AF_UNIX 1 /* local to host (pipes, portals) */ -#define AF_LOCAL 1 /* POSIX name for AF_UNIX */ -#define AF_INET 2 /* internetwork: UDP, TCP, etc. */ -#define AF_IMPLINK 3 /* arpanet imp addresses */ -#define AF_PUP 4 /* pup protocols: e.g. BSP */ -#define AF_CHAOS 5 /* mit CHAOS protocols */ -#define AF_NS 6 /* XEROX NS protocols */ -#define AF_ISO 7 /* ISO protocols */ -#define AF_OSI AF_ISO /* OSI is ISO */ -#define AF_ECMA 8 /* european computer manufacturers */ -#define AF_DATAKIT 9 /* datakit protocols */ -#define AF_CCITT 10 /* CCITT protocols, X.25 etc */ -#define AF_SNA 11 /* IBM SNA */ -#define AF_DECnet 12 /* DECnet */ -#define AF_DLI 13 /* Direct data link interface */ -#define AF_LAT 14 /* LAT */ -#define AF_HYLINK 15 /* NSC Hyperchannel */ -#define AF_APPLETALK 16 /* AppleTalk */ -#define AF_NETBIOS 17 /* NetBios-style addresses */ -#define AF_INET6 23 /* IP version 6 */ - -#define AF_MAX 32 -/* - * Protocol families, same as address families for now. - */ -#define PF_UNSPEC AF_UNSPEC -#define PF_UNIX AF_UNIX -#define PF_LOCAL AF_LOCAL -#define PF_INET AF_INET -#define PF_IMPLINK AF_IMPLINK -#define PF_PUP AF_PUP -#define PF_CHAOS AF_CHAOS -#define PF_NS AF_NS -#define PF_ISO AF_ISO -#define PF_OSI AF_OSI -#define PF_ECMA AF_ECMA -#define PF_DATAKIT AF_DATAKIT -#define PF_CCITT AF_CCITT -#define PF_SNA AF_SNA -#define PF_DECnet AF_DECnet -#define PF_DLI AF_DLI -#define PF_LAT AF_LAT -#define PF_HYLINK AF_HYLINK -#define PF_APPLETALK AF_APPLETALK -#define PF_NETBIOS AF_NETBIOS -#define PF_INET6 AF_INET6 - -#define PF_MAX AF_MAX - -/* Maximum queue length specificable by listen. */ -#define SOMAXCONN 0x7fffffff - -/* Flags we can use with send/ and recv. */ -#define MSG_OOB 0x1 /* process out-of-band data */ -#define MSG_PEEK 0x2 /* peek at incoming message */ -#define MSG_DONTROUTE 0x4 /* send without using routing tables */ -#define MSG_WAITALL 0x8 /* wait for all requested bytes */ -#define MSG_DONTWAIT 0x10 /* selective non-blocking operation */ -#define MSG_NOSIGNAL 0x20 /* Don't raise SIGPIPE */ -#define MSG_TRUNC 0x0100 /* Normal data truncated */ -#define MSG_CTRUNC 0x0200 /* Control data truncated */ - -/* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */ -#define SOL_IP 0 -#define SOL_IPV6 41 -#define SOL_IPX 256 -#define SOL_AX25 257 -#define SOL_ATALK 258 -#define SOL_NETROM 259 -#define SOL_TCP 6 -#define SOL_UDP 17 - -/* IP options */ -#ifndef IPTOS_LOWDELAY -#define IPTOS_LOWDELAY 0x10 -#define IPTOS_THROUGHPUT 0x08 -#define IPTOS_RELIABILITY 0x04 -#endif - -/* These need to appear somewhere around here */ -#define IP_DEFAULT_MULTICAST_TTL 1 -#define IP_DEFAULT_MULTICAST_LOOP 1 -#define IP_MAX_MEMBERSHIPS 20 - -/* IP options for use with getsockopt/setsockopt */ -#define IP_OPTIONS 1 -#define IP_HDRINCL 2 -#define IP_TOS 3 -#define IP_TTL 4 -#define IP_MULTICAST_IF 9 -#define IP_MULTICAST_TTL 10 -#define IP_MULTICAST_LOOP 11 -#define IP_ADD_MEMBERSHIP 12 -#define IP_DROP_MEMBERSHIP 13 -#define IP_DONTFRAGMENT 14 -#define IP_ADD_SOURCE_MEMBERSHIP 15 -#define IP_DROP_SOURCE_MEMBERSHIP 16 -#define IP_BLOCK_SOURCE 17 -#define IP_UNBLOCK_SOURCE 18 -#define IP_PKTINFO 19 - -/* IPv6 options for use with getsockopt/setsockopt */ -#define IPV6_HOPOPTS 1 -#define IPV6_UNICAST_HOPS 4 -#define IPV6_MULTICAST_IF 9 -#define IPV6_MULTICAST_HOPS 10 -#define IPV6_MULTICAST_LOOP 11 -#define IPV6_ADD_MEMBERSHIP 12 -#define IPV6_DROP_MEMBERSHIP 13 -#define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP -#define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP -#define IPV6_DONTFRAG 14 -#define IPV6_PKTINFO 19 -#define IPV6_HOPLIMIT 21 -#define IPV6_CHECKSUM 26 -#define IPV6_V6ONLY 27 -#define IPV6_RTHDR 32 -#define IPV6_RECVRTHDR 38 - -/* IP agnostic options for use with getsockopt/setsockopt */ -#define MCAST_JOIN_GROUP 41 -#define MCAST_LEAVE_GROUP 42 -#define MCAST_BLOCK_SOURCE 43 -#define MCAST_UNBLOCK_SOURCE 44 -#define MCAST_JOIN_SOURCE_GROUP 45 -#define MCAST_LEAVE_SOURCE_GROUP 46 - -#define MCAST_EXCLUDE 0 -#define MCAST_INCLUDE 1 - -/* Old WinSock1 values, needed internally */ -#ifdef __INSIDE_CYGWIN__ -#define _WS1_IP_OPTIONS 1 -#define _WS1_IP_MULTICAST_IF 2 -#define _WS1_IP_MULTICAST_TTL 3 -#define _WS1_IP_MULTICAST_LOOP 4 -#define _WS1_IP_ADD_MEMBERSHIP 5 -#define _WS1_IP_DROP_MEMBERSHIP 6 -#define _WS1_IP_TTL 7 -#define _WS1_IP_TOS 8 -#define _WS1_IP_DONTFRAGMENT 9 -#endif - -/* IPX options */ -#define IPX_TYPE 1 - -/* TCP options - this way around because someone left a set in the c library includes */ -#ifndef TCP_NODELAY -#define TCP_NODELAY 0x0001 -#define TCP_MAXSEG 2 -#endif - -/* The various priorities. */ -#define SOPRI_INTERACTIVE 0 -#define SOPRI_NORMAL 1 -#define SOPRI_BACKGROUND 2 - -#ifdef __cplusplus -}; -#endif /* __cplusplus */ - -#endif /* _CYGWIN_SOCKET_H */ diff --git a/winsup/cygwin/include/cygwin/sockios.h b/winsup/cygwin/include/cygwin/sockios.h deleted file mode 100644 index 2e756954e..000000000 --- a/winsup/cygwin/include/cygwin/sockios.h +++ /dev/null @@ -1 +0,0 @@ -/* sockios.h */ diff --git a/winsup/cygwin/include/cygwin/stat.h b/winsup/cygwin/include/cygwin/stat.h deleted file mode 100644 index 49b81fc2d..000000000 --- a/winsup/cygwin/include/cygwin/stat.h +++ /dev/null @@ -1,102 +0,0 @@ -/* cygwin/stat.h - - Copyright 2002, 2007 Red Hat Inc. - Written by Corinna Vinschen - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGWIN_STAT_H -#define _CYGWIN_STAT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined (__INSIDE_CYGWIN__) || defined (_COMPILING_NEWLIB) -struct __stat32 -{ - __dev16_t st_dev; - __ino32_t st_ino; - mode_t st_mode; - nlink_t st_nlink; - __uid16_t st_uid; - __gid16_t st_gid; - __dev16_t st_rdev; - _off_t st_size; - timestruc_t st_atim; - timestruc_t st_mtim; - timestruc_t st_ctim; - blksize_t st_blksize; - __blkcnt32_t st_blocks; - long st_spare4[2]; -}; - -struct __stat64 -{ - __dev32_t st_dev; - __ino64_t st_ino; - mode_t st_mode; - nlink_t st_nlink; - __uid32_t st_uid; - __gid32_t st_gid; - __dev32_t st_rdev; - _off64_t st_size; - timestruc_t st_atim; - timestruc_t st_mtim; - timestruc_t st_ctim; - blksize_t st_blksize; - __blkcnt64_t st_blocks; - timestruc_t st_birthtim; -}; - -extern int fstat64 (int fd, struct __stat64 *buf); -extern int stat64 (const char *file_name, struct __stat64 *buf); -extern int lstat64 (const char *file_name, struct __stat64 *buf); - -#endif - -struct stat -{ - dev_t st_dev; - ino_t st_ino; - mode_t st_mode; - nlink_t st_nlink; - uid_t st_uid; - gid_t st_gid; - dev_t st_rdev; - off_t st_size; - timestruc_t st_atim; - timestruc_t st_mtim; - timestruc_t st_ctim; - blksize_t st_blksize; - blkcnt_t st_blocks; -#ifdef __CYGWIN_USE_BIG_TYPES__ - timestruc_t st_birthtim; -#else - long st_spare4[2]; -#endif -}; - -#define st_atime st_atim.tv_sec -#define st_mtime st_mtim.tv_sec -#define st_ctime st_ctim.tv_sec -#ifdef __CYGWIN_USE_BIG_TYPES__ -#define st_birthtime st_birthtim.tv_sec -#endif - -/* POSIX IPC objects are not implemented as distinct file types, so the - below macros have to return 0. The expression is supposed to catch - illegal usage with non-stat parameters. */ -#define S_TYPEISMQ(buf) ((void)(buf)->st_mode,0) -#define S_TYPEISSEM(buf) ((void)(buf)->st_mode,0) -#define S_TYPEISSHM(buf) ((void)(buf)->st_mode,0) - -#ifdef __cplusplus -} -#endif - -#endif /* _CYGWIN_STAT_H */ diff --git a/winsup/cygwin/include/cygwin/stdlib.h b/winsup/cygwin/include/cygwin/stdlib.h deleted file mode 100644 index edf00a073..000000000 --- a/winsup/cygwin/include/cygwin/stdlib.h +++ /dev/null @@ -1,78 +0,0 @@ -/* stdlib.h - - Copyright 2005, 2006, 2007, 2008, 2009 Red Hat Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGWIN_STDLIB_H -#define _CYGWIN_STDLIB_H - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -const char *getprogname (void); -void setprogname (const char *); - -#ifndef __STRICT_ANSI__ -char *realpath (const char *, char *); -char *canonicalize_file_name (const char *); -int unsetenv (const char *); -char *initstate (unsigned seed, char *state, size_t size); -long random (void); -char *setstate (const char *state); -void srandom (unsigned); -char *ptsname (int); -int grantpt (int); -int unlockpt (int); -#endif /*__STRICT_ANSI__*/ - -int posix_openpt (int); -int posix_memalign (void **, size_t, size_t); - -#ifdef _COMPILING_NEWLIB -#define unsetenv UNUSED_unsetenv -#define _unsetenv_r UNUSED__unsetenv_r -#endif - -extern _PTR memalign _PARAMS ((size_t, size_t)); -extern _PTR valloc _PARAMS ((size_t)); - -#undef _malloc_r -#define _malloc_r(r, s) malloc (s) -#undef _free_r -#define _free_r(r, p) free (p) -#undef _realloc_r -#define _realloc_r(r, p, s) realloc (p, s) -#undef _calloc_r -#define _calloc_r(r, s1, s2) calloc (s1, s2); -#undef _memalign_r -#define _memalign_r(r, s1, s2) memalign (s1, s2); -#undef _mallinfo_r -#define _mallinfo_r(r) mallinfo () -#undef _malloc_stats_r -#define _malloc_stats_r(r) malloc_stats () -#undef _mallopt_r -#define _mallopt_r(i1, i2) mallopt (i1, i2) -#undef _malloc_usable_size_r -#define _malloc_usable_size_r(r, p) malloc_usable_size (p) -#undef _valloc_r -#define _valloc_r(r, s) valloc (s) -#undef _pvalloc_r -#define _pvalloc_r(r, s) pvalloc (s) -#undef _malloc_trim_r -#define _malloc_trim_r(r, s) malloc_trim (s) -#undef _mstats_r -#define _mstats_r(r, p) mstats (p) - -#ifdef __cplusplus -} -#endif -#endif /*_CYGWIN_STDLIB_H*/ diff --git a/winsup/cygwin/include/cygwin/sys_time.h b/winsup/cygwin/include/cygwin/sys_time.h deleted file mode 100644 index 1cbd8ae59..000000000 --- a/winsup/cygwin/include/cygwin/sys_time.h +++ /dev/null @@ -1,27 +0,0 @@ -/* sys_time.h - - Copyright 2005 Red Hat Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGWIN_SYS_TIME_H -#define _CYGWIN_SYS_TIME_H -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -int futimes (int, const struct timeval *); -int lutimes (const char *, const struct timeval *); - - -#ifdef __cplusplus -} -#endif -#endif /*_CYGWIN_SYS_TIME_H*/ diff --git a/winsup/cygwin/include/cygwin/sysproto.h b/winsup/cygwin/include/cygwin/sysproto.h deleted file mode 100644 index cea8a023b..000000000 --- a/winsup/cygwin/include/cygwin/sysproto.h +++ /dev/null @@ -1,94 +0,0 @@ -/* cygwin/sysproto.h - - Copyright 2003 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* cygwin/sysproto.h header file for Cygwin. */ - -#ifndef _CYGWIN_SYSPROTO_H -#define _CYGWIN_SYSPROTO_H -#define _SYS_SYSPROTO_H_ /* Keep it, used by BSD files */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -struct msgctl_args { - int msqid; - int cmd; - struct msqid_ds *buf; -}; - -struct msgget_args { - key_t key; - int msgflg; -}; - -struct msgrcv_args { - int msqid; - void *msgp; - size_t msgsz; - long msgtyp; - int msgflg; -}; - -struct msgsnd_args { - int msqid; - const void *msgp; - size_t msgsz; - int msgflg; -}; - -struct semctl_args { - int semid; - int semnum; - int cmd; - union semun *arg; -}; - -struct semget_args { - key_t key; - int nsems; - int semflg; -}; - -struct semop_args { - int semid; - struct sembuf *sops; - size_t nsops; -}; - -struct shmat_args { - int shmid; - const void *shmaddr; - int shmflg; -}; - -struct shmctl_args { - int shmid; - int cmd; - struct shmid_ds *buf; -}; - -struct shmdt_args { - const void *shmaddr; -}; - -struct shmget_args { - key_t key; - size_t size; - int shmflg; -}; - -#ifdef __cplusplus -} -#endif - -#endif /* _CYGWIN_SYSPROTO_H */ diff --git a/winsup/cygwin/include/cygwin/time.h b/winsup/cygwin/include/cygwin/time.h deleted file mode 100644 index d1b7670bc..000000000 --- a/winsup/cygwin/include/cygwin/time.h +++ /dev/null @@ -1,40 +0,0 @@ -/* time.h - - Copyright 2005, 2007 Red Hat Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGWIN_TIME_H -#define _CYGWIN_TIME_H -#ifdef __cplusplus -extern "C" -{ -#endif - -/* Not defined in main time.h */ -int __cdecl clock_setres (clockid_t, struct timespec *); - -/* GNU extensions. */ -time_t __cdecl timelocal (struct tm *); -time_t __cdecl timegm (struct tm *); - -#define TIMER_RELTIME 0 /* For compatibility with HP/UX, Solaris, others? */ - -#ifndef __STRICT_ANSI__ - -extern int daylight __asm__ ("__daylight"); - -#ifndef __timezonefunc__ -extern long timezone __asm__ ("__timezone"); -#endif - -#endif /*__STRICT_ANSI__*/ - -#ifdef __cplusplus -} -#endif -#endif /*_CYGWIN_TIME_H*/ diff --git a/winsup/cygwin/include/cygwin/types.h b/winsup/cygwin/include/cygwin/types.h deleted file mode 100644 index f92421116..000000000 --- a/winsup/cygwin/include/cygwin/types.h +++ /dev/null @@ -1,252 +0,0 @@ -/* types.h - - Copyright 2001, 2002, 2003, 2005 Red Hat Inc. - Written by Robert Collins - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#ifndef _CYGWIN_TYPES_H -#define _CYGWIN_TYPES_H - -#include -#include -#include - -#ifndef __timespec_t_defined -#define __timespec_t_defined -typedef struct timespec timespec_t; -#endif /*__timespec_t_defined*/ - -#ifndef __timestruc_t_defined -#define __timestruc_t_defined -typedef struct timespec timestruc_t; -#endif /*__timestruc_t_defined*/ - -#ifndef __off_t_defined -#define __off_t_defined -#ifdef __CYGWIN_USE_BIG_TYPES__ -typedef _off64_t off_t; -#else -typedef _off_t off_t; -#endif -#endif /*__off_t_defined*/ - -typedef __loff_t loff_t; - -#ifndef __dev_t_defined -#define __dev_t_defined -typedef short __dev16_t; -typedef unsigned long __dev32_t; -#ifdef __CYGWIN_USE_BIG_TYPES__ -typedef __dev32_t dev_t; -#else -typedef __dev16_t dev_t; -#endif -#endif /*__dev_t_defined*/ - -#ifndef __blksize_t_defined -#define __blksize_t_defined -typedef long blksize_t; -#endif /*__blksize_t_defined*/ - -#ifndef __blkcnt_t_defined -#define __blkcnt_t_defined -typedef long __blkcnt32_t; -typedef long long __blkcnt64_t; -#ifdef __CYGWIN_USE_BIG_TYPES__ -typedef __blkcnt64_t blkcnt_t; -#else -typedef __blkcnt32_t blkcnt_t; -#endif -#endif /*__blkcnt_t_defined*/ - -#ifndef __fsblkcnt_t_defined -#define __fsblkcnt_t_defined -typedef unsigned long fsblkcnt_t; -#endif /* __fsblkcnt_t_defined */ - -#ifndef __fsfilcnt_t_defined -#define __fsfilcnt_t_defined -typedef unsigned long fsfilcnt_t; -#endif /* __fsfilcnt_t_defined */ - -#ifndef __uid_t_defined -#define __uid_t_defined -typedef unsigned short __uid16_t; -typedef unsigned long __uid32_t; -#ifdef __CYGWIN_USE_BIG_TYPES__ -typedef __uid32_t uid_t; -#else -typedef __uid16_t uid_t; -#endif -#endif /*__uid_t_defined*/ - -#ifndef __gid_t_defined -#define __gid_t_defined -typedef unsigned short __gid16_t; -typedef unsigned long __gid32_t; -#ifdef __CYGWIN_USE_BIG_TYPES__ -typedef __gid32_t gid_t; -#else -typedef __gid16_t gid_t; -#endif -#endif /*__gid_t_defined*/ - -#ifndef __ino_t_defined -#define __ino_t_defined -typedef unsigned long __ino32_t; -typedef unsigned long long __ino64_t; -#ifdef __CYGWIN_USE_BIG_TYPES__ -typedef __ino64_t ino_t; -#else -typedef __ino32_t ino_t; -#endif -#endif /*__ino_t_defined*/ - -/* Generic ID type, must match at least pid_t, uid_t and gid_t in size. */ -#ifndef __id_t_defined -#define __id_t_defined -typedef unsigned long id_t; -#endif /* __id_t_defined */ - -#if defined (__INSIDE_CYGWIN__) -struct __flock32 { - short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */ - short l_whence; /* flag to choose starting offset */ - _off_t l_start; /* relative offset, in bytes */ - _off_t l_len; /* length, in bytes; 0 means lock to EOF */ - short l_pid; /* returned with F_GETLK */ - short l_xxx; /* reserved for future use */ -}; - -struct __flock64 { - short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */ - short l_whence; /* flag to choose starting offset */ - _off64_t l_start; /* relative offset, in bytes */ - _off64_t l_len; /* length, in bytes; 0 means lock to EOF */ - pid_t l_pid; /* returned with F_GETLK */ -}; -#endif - -struct flock { - short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */ - short l_whence; /* flag to choose starting offset */ - off_t l_start; /* relative offset, in bytes */ - off_t l_len; /* length, in bytes; 0 means lock to EOF */ -#ifdef __CYGWIN_USE_BIG_TYPES__ - pid_t l_pid; /* returned with F_GETLK */ -#else - short l_pid; /* returned with F_GETLK */ - short l_xxx; /* reserved for future use */ -#endif -}; - -#ifndef __key_t_defined -#define __key_t_defined -typedef long long key_t; -#endif /* __key_t_defined */ - -#ifndef __BIT_TYPES_DEFINED -#define __BIT_TYPES_DEFINED__ 1 - -#ifndef __vm_offset_t_defined -#define __vm_offset_t_defined -typedef unsigned long vm_offset_t; -#endif /*__vm_offset_t_defined*/ - -#ifndef __vm_size_t_defined -#define __vm_size_t_defined -typedef unsigned long vm_size_t; -#endif /*__vm_size_t_defined*/ - -#ifndef __vm_object_t_defined -#define __vm_object_t_defined -typedef void *vm_object_t; -#endif /* __vm_object_t_defined */ - -#ifndef __u_int8_t_defined -#define __u_int8_t_defined -typedef unsigned char u_int8_t; -#endif -#ifndef __u_int16_t_defined -#define __u_int16_t_defined -typedef __uint16_t u_int16_t; -#endif -#ifndef __u_int32_t_defined -#define __u_int32_t_defined -typedef __uint32_t u_int32_t; -#endif -#ifndef __u_int64_t_defined -#define __u_int64_t_defined -typedef __uint64_t u_int64_t; -#endif - -#ifndef __register_t_defined -#define __register_t_defined -typedef __int32_t register_t; -#endif - -#ifndef __addr_t_defined -#define __addr_t_defined -typedef char *addr_t; -#endif - -#ifndef __mode_t_defined -#define __mode_t_defined -typedef unsigned mode_t; -#endif -#endif /*__BIT_TYPES_DEFINED*/ - -#if !defined(__INSIDE_CYGWIN__) || !defined(__cplusplus) - -typedef struct __pthread_t {char __dummy;} *pthread_t; -typedef struct __pthread_mutex_t {char __dummy;} *pthread_mutex_t; - -typedef struct __pthread_key_t {char __dummy;} *pthread_key_t; -typedef struct __pthread_attr_t {char __dummy;} *pthread_attr_t; -typedef struct __pthread_mutexattr_t {char __dummy;} *pthread_mutexattr_t; -typedef struct __pthread_condattr_t {char __dummy;} *pthread_condattr_t; -typedef struct __pthread_cond_t {char __dummy;} *pthread_cond_t; - - /* These variables are not user alterable. This means you!. */ -typedef struct -{ - pthread_mutex_t mutex; - int state; -} -pthread_once_t; -typedef struct __pthread_rwlock_t {char __dummy;} *pthread_rwlock_t; -typedef struct __pthread_rwlockattr_t {char __dummy;} *pthread_rwlockattr_t; - -#else - -/* pthreads types */ - -typedef class pthread *pthread_t; -typedef class pthread_mutex *pthread_mutex_t; -typedef class pthread_key *pthread_key_t; -typedef class pthread_attr *pthread_attr_t; -typedef class pthread_mutexattr *pthread_mutexattr_t; -typedef class pthread_condattr *pthread_condattr_t; -typedef class pthread_cond *pthread_cond_t; -typedef class pthread_once pthread_once_t; -typedef class pthread_rwlock *pthread_rwlock_t; -typedef class pthread_rwlockattr *pthread_rwlockattr_t; - -/* semaphores types */ -typedef class semaphore *sem_t; -#endif /* __INSIDE_CYGWIN__ */ -#endif /* _CYGWIN_TYPES_H */ - -#ifdef __cplusplus -} -#endif diff --git a/winsup/cygwin/include/cygwin/utmp.h b/winsup/cygwin/include/cygwin/utmp.h deleted file mode 100644 index 56a137ffe..000000000 --- a/winsup/cygwin/include/cygwin/utmp.h +++ /dev/null @@ -1,40 +0,0 @@ -/* cygwin/utmp.h - - Copyright 2004 Red Hat, Inc. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#ifndef CYGWIN_UTMP_H -#define CYGWIN_UTMP_H - -#include -#include -#include - -#define WTMP_FILE _PATH_WTMP - -#ifdef __cplusplus -extern "C" { -#endif - -#define UT_LINESIZE 16 -#define UT_NAMESIZE 16 -#define UT_HOSTSIZE 256 -#define UT_IDLEN 2 - -#define RUN_LVL 1 -#define BOOT_TIME 2 -#define NEW_TIME 3 -#define OLD_TIME 4 - -#define INIT_PROCESS 5 -#define LOGIN_PROCESS 6 -#define USER_PROCESS 7 -#define DEAD_PROCESS 8 - -#ifdef __cplusplus -} -#endif -#endif /* CYGWIN_UTMP_H */ diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h deleted file mode 100644 index 44d660430..000000000 --- a/winsup/cygwin/include/cygwin/version.h +++ /dev/null @@ -1,453 +0,0 @@ -/* version.h -- Cygwin version numbers and accompanying documentation. - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* Cygwin versioning is relatively complicated because of its status - as a shared library. Let's start with how versioning used to be done. - - Historical versioning in Cygwin 16.0 to 19.5: - - In the olden days of Cygwin, we had a dll major and minor version - and a registry version. The major number started at 16 because the - "b15" GNU-Win32 release of the compiler tools was out when this - scheme was started. We incremented the DLL name frequently (for - every official release) and towards the end of this period every - release used a different shared memory area to prevent DLLs from - interfering with each other (embedding a build timestamp into the - name of the shared memory area). This turned out to be a Bad Idea - (tm) because people needed to mingle separate releases and have - them work together more than we thought they would. This was - especially problematic when tty info needed to be retained when an - old Cygwin executable executed a newer one. - - In the old scheme, we incremented the major number whenever a - change to the dll invalidated existing executables. This can - happen for a number of reasons, including when functions are - removed from the export list of the dll. The minor number was - incremented when a change was made that we wanted to record, but - that didn't invalidate existing executables. Both numbers were - recorded in the executable and in the dll. - - In October 1998 (starting with Cygwin 19.6), we started a new method - of Cygwin versioning: */ - - /* The DLL major and minor numbers correspond to the "version of - the Cygwin shared library". This version is used to track important - changes to the DLL and is mainly informative in nature. */ - -#define CYGWIN_VERSION_DLL_MAJOR 1007 -#define CYGWIN_VERSION_DLL_MINOR 2 - - /* Major numbers before CYGWIN_VERSION_DLL_EPOCH are - incompatible. */ - -#define CYGWIN_VERSION_DLL_EPOCH 19 - - /* CYGWIN_VERSION_DLL_COMBINED gives us a single number - representing the combined DLL major and minor numbers. */ - - /* WATCH OUT FOR OCTAL! Don't use, say, "00020" for 0.20 */ - -#define CYGWIN_VERSION_DLL_MAKE_COMBINED(maj, min) (((maj) * 1000) + min) -#define CYGWIN_VERSION_DLL_COMBINED \ - CYGWIN_VERSION_DLL_MAKE_COMBINED (CYGWIN_VERSION_DLL_MAJOR, CYGWIN_VERSION_DLL_MINOR) - - /* Every version of cygwin <= this uses an old, incorrect method - to determine signal masks. */ - -#define CYGWIN_VERSION_USER_API_VERSION_COMBINED \ - CYGWIN_VERSION_DLL_MAKE_COMBINED (user_data->api_major, user_data->api_minor) - - /* API versions <= this had a termios structure whose members were - too small to accomodate modern settings. */ -#define CYGWIN_VERSION_DLL_OLD_TERMIOS 5 -#define CYGWIN_VERSION_DLL_IS_OLD_TERMIOS \ - (CYGWIN_VERSION_USER_API_VERSION_COMBINED <= CYGWIN_VERSION_DLL_OLD_TERMIOS) - -#define CYGWIN_VERSION_DLL_MALLOC_ENV 28 - /* Old APIs had getc/putc macros that conflict with new CR/LF - handling in the stdio buffers */ -#define CYGWIN_VERSION_OLD_STDIO_CRLF_HANDLING \ - (CYGWIN_VERSION_USER_API_VERSION_COMBINED <= 20) - -#define CYGWIN_VERSION_CHECK_FOR_S_IEXEC \ - (CYGWIN_VERSION_USER_API_VERSION_COMBINED >= 36) - -#define CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK \ - (CYGWIN_VERSION_USER_API_VERSION_COMBINED <= 28) - -#define CYGWIN_VERSION_CHECK_FOR_USING_BIG_TYPES \ - (CYGWIN_VERSION_USER_API_VERSION_COMBINED >= 79) - -#define CYGWIN_VERSION_CHECK_FOR_USING_ANCIENT_MSGHDR \ - (CYGWIN_VERSION_USER_API_VERSION_COMBINED <= 138) - -#define CYGWIN_VERSION_CHECK_FOR_USING_WINSOCK1_VALUES \ - (CYGWIN_VERSION_USER_API_VERSION_COMBINED <= 138) - -#define CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ \ - (CYGWIN_VERSION_USER_API_VERSION_COMBINED <= 161) - -#define CYGWIN_VERSION_CHECK_FOR_OLD_CTYPE \ - (CYGWIN_VERSION_USER_API_VERSION_COMBINED <= 209) - -#define CYGWIN_VERSION_CYGWIN_CONV 181 - - /* API_MAJOR 0.0: Initial version. API_MINOR changes: - 1: Export cygwin32_ calls as cygwin_ as well. - 2: Export j1, jn, y1, yn. - 3: Export dll_noncygwin_dllcrt0. - 4: New socket ioctls, revamped ifconf support. - 5: Thread support/exports. - 6: Change in termios handling. - 7: Export scandir and alphasort. - 8: Export _ctype_, _sys_errlist, _sys_nerr. - 9: Mount-related changes, new cygwin_umount export. - Raw device support (tape, floppies). - 10: Fast math routine support added. - 11: Export seekdir, telldir. - 12: Export pthread_join, pthread_detach. - 13: Export math funcs gamma and friends, also _j0, _j1, etc. - 14: Export snprintf and vnsprintf. - 15: Export glob - 16: Export cygwin_stackdump - 17: Export fast math stuff - 18: Stop exporting _strace_wm - 19: Export fchown, lchown, lacl - 20: regsub, inet_network - 21: incompatible change to stdio cr/lf and buffering - 22: Export cygwin_logon_user, cygwin_set_impersonation_token. - geteuid, getegid return effective uid/gid. - getuid, getgid return real uid/gid. - seteuid, setegid set only effective uid/gid. - setuid, setgid set effective and real uid/gid. - 23: Export new dll_crt0 interface and cygwin_user_data for use - with crt0 startup code. - 24: Export poll and _poll. - 25: Export getmode and _getmode. - 26: CW_GET_CYGDRIVE_PREFIXES addition to external.cc - 27: CW_GETPINFO_FULL addition to external.cc - 28: Accidentally bumped by cgf - 29: Export hstrerror - 30: CW_GET_CYGDRIVE_INFO addition to external.cc - 31: Export inet_aton - 32: Export getrlimit/setrlimit - 33: Export setlogmask - 34: Separated out mount table - 35: Export drand48, erand48, jrand48, lcong48, lrand48, - mrand48, nrand48, seed48, and srand48. - 36: Added _cygwin_S_IEXEC, et al - 37: [f]pathconv support _PC_POSIX_PERMISSIONS and _PC_POSIX_SECURITY - 38: vscanf, vscanf_r, and random pthread functions - 39: asctime_r, ctime_r, gmtime_r, localtime_r - 40: fchdir - 41: __signgam - 42: sys_errlist, sys_nerr - 43: sigsetjmp, siglongjmp fixed - 44: Export dirfd - 45: perprocess change, gamma_r, gammaf_r, lgamma_r, lgammaf_r - 46: Remove cygwin_getshared - 47: Report EOTWarningZoneSize in struct mtget. - 48: Export "posix" regex functions - 49: Export setutent, endutent, utmpname, getutent, getutid, getutline. - 50: Export fnmatch. - 51: Export recvmsg, sendmsg. - 52: Export strptime - 53: Export strlcat, strlcpy. - 54: Export __fpclassifyd, __fpclassifyf, __signbitd, __signbitf. - 55: Export fcloseall, fcloseall_r. - 56: Make ntsec on by default. - 57: Export setgroups. - 58: Export memalign, valloc, malloc_trim, malloc_usable_size, mallopt, - malloc_stats - 59: getsid - 60: MSG_NOSIGNAL - 61: Export getc_unlocked, getchar_unlocked, putc_unlocked, - putchar_unlocked - 62: Erroneously bumped - 63: Export pututline - 64: Export fseeko, ftello - 65: Export siginterrupt - 66: Export nl_langinfo - 67: Export pthread_getsequence_np - 68: Export netdb stuff - 69: Export strtof - 70: Export asprintf, _asprintf_r, vasprintf, _vasprintf_r - 71: Export strerror_r - 72: Export nanosleep - 73: Export setreuid32, setreuid, setregid32, setregid - 74: Export _strtold a64l hcreate hcreate_r hdestroy hdestroy_r hsearch - hsearch_r isblank iswalnum iswalpha iswblank iswcntrl iswctype - iswdigit iswgraph iswlower iswprint iswpunct iswspace iswupper - iswxdigit l64a mbrlen mbrtowc mbsinit mbsrtowcs mempcpy - on_exit setbuffer setlinebuf strndup strnlen tdelete tdestroy - tfind towctrans towlower towupper tsearch twalk wcrtomb wcscat - wcschr wcscpy wcscspn wcslcat wcslcpy wcsncat wcsncmp wcsncpy - wcspbrk wcsrchr wcsrtombs wcsspn wcsstr wctob wctob wctrans - wctype wmemchr wmemcmp wmemcpy wmemmove wmemset - 75: Export exp2 exp2f fdim fdimf fma fmaf fmax fmaxf fmin fminf lrint - lrintf lround lroundf nearbyint nearbyintf remquo remquof - round roundf scalbln scalblnf sincos sincosf tgamma tgammaf - truncf - 76: mallinfo - 77: thread-safe exit/at_exit - 78: Use stat and fstat rather than _stat, and _fstat. - Export btowc and trunc. - 79: Export acl32 aclcheck32 aclfrommode32 aclfrompbits32 aclfromtext32 - aclsort32 acltomode32 acltopbits32 acltotext32 facl32 - fgetpos64 fopen64 freopen64 fseeko64 fsetpos64 ftello64 - _open64 _lseek64 _fstat64 _stat64 mknod32 - 80: Export pthread_rwlock stuff - 81: CW_CHECK_NTSEC addition to external.cc - 82: Export wcscoll wcswidth wcwidth - 83: Export gethostid - 84: Pty open allocates invisible console. 64 bit interface - 85: Export new 32/64 functions from API 0.79 only with leading - underscore. No problems with backward compatibility since no - official release has been made so far. This change removes - exported symbols like fopen64, which might confuse configure. - 86: Export ftok - 87: Export vsyslog - 88: Export _getreent - 89: Export __mempcpy - 90: Export _fopen64 - 91: Export argz_add argz_add_sep argz_append argz_count argz_create - argz_create_sep argz_delete argz_extract argz_insert - argz_next argz_replace argz_stringify envz_add envz_entry - envz_get envz_merge envz_remove envz_strip - 92: Export getusershell, setusershell, endusershell - 93: Export daemon, forkpty, openpty, iruserok, ruserok, login_tty, - openpty, forkpty, revoke, logwtmp, updwtmp - 94: Export getopt, getopt_long, optarg, opterr, optind, optopt, - optreset, __check_rhosts_file, __rcmd_errstr. - 95: Export shmat, shmctl, shmdt, shmget. - 96: CW_GET_ERRNO_FROM_WINERROR addition to external.cc - 97: Export sem_open, sem_close, sem_timedwait, sem_getvalue. - 98: Export _tmpfile64. - 99: CW_GET_POSIX_SECURITY_ATTRIBUTE addition to external.cc. - 100: CW_GET_SHMLBA addition to external.cc. - 101: Export err, errx, verr, verrx, warn, warnx, vwarn, vwarnx. - 102: CW_GET_UID_FROM_SID and CW_GET_GID_FROM_SID addition to external.cc. - 103: Export getprogname, setprogname. - 104: Export msgctl, msgget, msgrcv, msgsnd, semctl, semget, semop. - 105: Export sigwait. - 106: Export flock. - 107: Export fcntl64. - 108: Remove unused (hopefully) reent_data export. - 109: Oh well. Someone uses reent_data. - 110: Export clock_gettime, sigwaitinfo, timer_create, timer_delete, - timer_settime - 111: Export sigqueue, sighold. - 112: Redefine some mtget fields. - 113: Again redefine some mtget fields. Use mt_fileno and mt_blkno as - on Linux. - 114: Export rand_r, ttyname_r. - 115: Export flockfile, ftrylockfile, funlockfile, getgrgid_r, getgrnam_r, - getlogin_r. - 116: Export atoll. - 117: Export utmpx functions, Return utmp * from pututent. - 118: Export getpriority, setpriority. - 119: Export fdatasync. - 120: Export basename, dirname. - 122: Export statvfs, fstatvfs. - 123: Export utmpxname. - 124: Add MAP_AUTOGROW flag to mmap. - 125: LD_PRELOAD/CW_HOOK available. - 126: Export lsearch, lfind, timer_gettime. - 127: Export sigrelese. - 128: Export pselect. - 129: Export mkdtemp. - 130: Export strtoimax, strtoumax, llabs, imaxabs, lldiv, imaxdiv. - 131: Export inet_ntop, inet_pton. - 132: Add GLOB_LIMIT flag to glob. - 133: Export __getline, __getdelim. - 134: Export getline, getdelim. - 135: Export pread, pwrite - 136: Add TIOCMBIS/TIOCMBIC ioctl codes. - 137: fts_children, fts_close, fts_get_clientptr, fts_get_stream, - fts_open, fts_read, fts_set, fts_set_clientptr, ftw, nftw. - 138: Export readdir_r. - 139: Start using POSIX definition of struct msghdr and WinSock2 - IPPROTO_IP values. - 140: Export mlock, munlock. - 141: Export futimes, lutimes. - 142: Export memmem - 143: Export clock_getres, clock_setres - 144: Export timelocal, timegm. - 145: Add MAP_NORESERVE flag to mmap. - 146: Change SI_USER definition. FIXME: Need to develop compatibility - macro for this? - 147: Eliminate problematic d_ino from dirent structure. unsetenv now - returns int, as per linux. - 148: Add open(2) flags O_SYNC, O_RSYNC, O_DSYNC and O_DIRECT. - 149: Add open(2) flag O_NOFOLLOW. - 150: Export getsubopt. - 151: Export __opendir_with_d_ino - 152: Revert to having d_ino in dirent unconditionally. - 153: Export updwtmpx, Implement CW_SETUP_WINENV. - 154: Export sigset, sigignore. - 155: Export __isinff, __isinfd, __isnanf, __isnand. - 156: Export __srbuf_r, __swget_r. - 157: Export gai_strerror, getaddrinfo, getnameinfo, freeaddrinfo, - in6addr_any, in6addr_loopback. - 158: Export bindresvport, bindresvport_sa, iruserok_sa, rcmd_af, - rresvport_af. - 159: Export posix_openpt. - 160: Export posix_fadvise, posix_fallocate. - 161: Export resolver functions. - 162: New struct ifreq. Export if_nametoindex, if_indextoname, - if_nameindex, if_freenameindex. - 163: Export posix_madvise, posix_memalign. - 164: Export shm_open, shm_unlink. - 165: Export mq_close, mq_getattr, mq_notify, mq_open, mq_receive, - mq_send, mq_setattr, mq_timedreceive, mq_timedsend, mq_unlink. - 166: Export sem_unlink. - 167: Add st_birthtim to struct stat. - 168: Export asnprintf, dprintf, _Exit, vasnprintf, vdprintf. - 169: Export confstr. - 170: Export insque, remque. - 171: Export exp10, exp10f, pow10, pow10f, strcasestr, funopen, - fopencookie. - 172: Export getifaddrs, freeifaddrs. - 173: Export __assert_func. - 174: Export stpcpy, stpncpy. - 175: Export fdopendir. - 176: Export wcstol, wcstoll, wcstoul, wcstoull, wcsxfrm. - 177: Export sys_sigabbrev - 178: Export wcpcpy, wcpncpy. - 179: Export _f_llrint, _f_llrintf, _f_llrintl, _f_lrint, _f_lrintf, - _f_lrintl, _f_rint, _f_rintf, _f_rintl, llrint, llrintf, llrintl, - rintl, lrintl, and redirect exports of lrint, lrintf, rint, rintf. - 180: Export getxattr, lgetxattr, fgetxattr, listxattr, llistxattr, - flistxattr, setxattr, lsetxattr, fsetxattr, removexattr, - lremovexattr, fremovexattr. - 181: Export cygwin_conv_path, cygwin_create_path, cygwin_conv_path_list. - 182: Export lockf. - FIXME: Removed 12 year old and entirely wrong wprintf function at - this point. We need a working implementation soon. - 183: Export open_memstream, fmemopen. - 184: Export openat, faccessat, fchmodat, fchownat, fstatat, futimesat, - linkat, mkdirat, mkfifoat, mknodat, readlinkat, renameat, symlinkat, - unlinkat. - 185: Export futimens, utimensat. - 186: Remove ancient V8 regexp functions. Also eliminate old crt0 interface - which provided its own user_data structure. - 187: Export cfmakeraw. - 188: Export CW_SET_PRIV_KEY. - 189: Implement dirent.d_type. - 190: Export fgetwc, fgetws, fputwc, fputws, fwide, getwc, getwchar, - putwc, putwchar, ungetwc. - 191: Export glob_pattern_p - 192: CW_SETERRNO added - 193: Export wcstok. - 194: fcntl.h flags O_DIRECTORY, O_EXEC and O_SEARCH added. - 195: Export wcstod, wcstof. - 196: Export wcsnlen. - 197: Export wcstoimax, wcstoumax. - 198: Export reallocf. - 199: Export open_wmemstream. - 200: Export mbsnrtowcs, wcsnrtombs. - 201: Export wprintf, fwprintf, swprintf, vwprintf, vfwprintf, vswprintf. - 202: Export gethostbyname2. - 203: Export wcsftime. - 204: recv/send flag MSG_DONTWAIT added. - 205: Export wscanf, fwscanf, swscanf, vwscanf, vfwscanf, vswscanf. - 206: Export wcscasecmp, wcsncasecmp. - 207: Export wcsdup. - 208: Export log2, log2f. - 209: Export wordexp, wordfree. - 210: New ctype layout using variable ctype pointer. Export __ctype_ptr__. - 211: Export fpurge, mkstemps. - 212: Add and export libstdc++ malloc wrappers. - 213: Export canonicalize_file_name, eaccess, euidaccess. - 214: Export execvpe, fexecve. - 215: CW_EXIT_PROCESS added. - 216: CW_SET_EXTERNAL_TOKEN added. - 217: CW_GET_INSTKEY added. - 218: Export get_nprocs, get_nprocs_conf, get_phys_pages, get_avphys_pages. - 219: Export dup3, pipe2, O_CLOEXEC, F_DUPFD_CLOEXEC. - 220: Export accept4, SOCK_CLOEXEC, SOCK_NONBLOCK. - 221: Export strfmon. - 222: CW_INT_SETLOCALE added. - */ - - /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */ - -#define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 222 - - /* There is also a compatibity version number associated with the - shared memory regions. It is incremented when incompatible - changes are made to the shared memory region *or* to any named - shared mutexes, semaphores, etc. The arbitrary starting - version was 0 (cygwin release 98r2). - Bump to 4 since this hasn't been rigorously updated in a - while. */ - -#define CYGWIN_VERSION_SHARED_DATA 5 - - /* An identifier used in the names used to create shared objects. - The full names include the CYGWIN_VERSION_SHARED_DATA version - as well as this identifier. */ - -#define CYGWIN_VERSION_DLL_IDENTIFIER "cygwin1" - - /* The Cygwin mount table interface in the Win32 registry also - has a version number associated with it in case that is - changed in a non-backwards compatible fashion. Increment this - version number whenever incompatible changes in mount table - registry usage are made. - - 1: Original number version. - 2: New mount registry layout, system-wide mount accessibility. - 3: The mount table is not in the registry anymore, but in /etc/fstab. - */ - -#define CYGWIN_VERSION_MOUNT_REGISTRY 3 - - /* Identifiers used in the Win32 registry. */ - -#define CYGWIN_INFO_CYGWIN_REGISTRY_NAME "Cygwin" -#define CYGWIN_INFO_PROGRAM_OPTIONS_NAME "Program Options" -#define CYGWIN_INFO_INSTALLATIONS_NAME "Installations" - - /* The default cygdrive prefix. */ - -#define CYGWIN_INFO_CYGDRIVE_DEFAULT_PREFIX "/cygdrive" - - /* In addition to the above version number strings, the build - process adds some strings that may be useful in - debugging/identifying a particular Cygwin DLL: - - The mkvers.sh script at the top level produces a .cc file - which initializes a cygwin_version structure based on the - above version information and creates a string table for - grepping via "fgrep '%%%' cygwinwhatever.dll" if you are - using GNU grep. Otherwise you may want to do a - "strings cygwinwhatever.dll | fgrep '%%%'" instead. - - This will produce output such as: - - %%% Cygwin dll_identifier: cygwin - %%% Cygwin api_major: 0 - %%% Cygwin api_minor: 0 - %%% Cygwin dll_major: 19 - %%% Cygwin dll_minor: 6 - %%% Cygwin shared_data: 1 - %%% Cygwin registry: b15 - %%% Cygwin build date: Wed Oct 14 16:26:51 EDT 1998 - %%% Cygwin shared id: cygwinS1 - - This information can also be obtained through a call to - cygwin_internal (CW_GETVERSIONINFO). - */ - -#define CYGWIN_VERSION_MAGIC(a, b) ((unsigned) ((((unsigned short) a) << 16) | (unsigned short) b)) -#define CYGWIN_VERSION_MAGIC_VERSION(a) ((unsigned) ((unsigned)a & 0xffff)) diff --git a/winsup/cygwin/include/cygwin/wait.h b/winsup/cygwin/include/cygwin/wait.h deleted file mode 100644 index bed81b779..000000000 --- a/winsup/cygwin/include/cygwin/wait.h +++ /dev/null @@ -1,37 +0,0 @@ -/* cygwin/wait.h - - Copyright 2006, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGWIN_WAIT_H -#define _CYGWIN_WAIT_H - -#define WNOHANG 1 -#define WUNTRACED 2 -#define WCONTINUED 8 -#define __W_CONTINUED 0xffff - -/* A status looks like: - <2 bytes info> <2 bytes code> - - == 0, child has exited, info is the exit value - == 1..7e, child has exited, info is the signal number. - == 7f, child has stopped, info was the signal number. - == 80, there was a core dump. -*/ - -#define WIFEXITED(w) (((w) & 0xff) == 0) -#define WIFSIGNALED(w) (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f)) -#define WIFSTOPPED(w) (((w) & 0xff) == 0x7f) -#define WIFCONTINUED(w) (((w) & 0xffff) == __W_CONTINUED) -#define WEXITSTATUS(w) (((w) >> 8) & 0xff) -#define WTERMSIG(w) ((w) & 0x7f) -#define WSTOPSIG WEXITSTATUS -#define WCOREDUMP(w) (WIFSIGNALED(w) && (w & 0x80)) - -#endif /* _CYGWIN_WAIT_H */ diff --git a/winsup/cygwin/include/dlfcn.h b/winsup/cygwin/include/dlfcn.h deleted file mode 100644 index 2cf88e2d3..000000000 --- a/winsup/cygwin/include/dlfcn.h +++ /dev/null @@ -1,42 +0,0 @@ -/* dlfcn.h - - Copyright 1998, 1999, 2000, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _DLFCN_H -#define _DLFCN_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* declarations used for dynamic linking support routines */ -extern void *dlopen (const char *, int); -extern void *dlsym (void *, const char *); -extern int dlclose (void *); -extern char *dlerror (void); - -/* specific to CYGWIN */ -#define FORK_RELOAD 1 -#define FORK_NO_RELOAD 0 - -extern void dlfork (int); - -/* following doesn't exist in Win32 API .... */ -#define RTLD_DEFAULT NULL - -/* valid values for mode argument to dlopen */ -#define RTLD_LAZY 1 /* lazy function call binding */ -#define RTLD_NOW 2 /* immediate function call binding */ -#define RTLD_GLOBAL 4 /* symbols in this dlopen'ed obj are visible to other dlopen'ed objs */ - -#ifdef __cplusplus -} -#endif - -#endif /* _DLFCN_H */ diff --git a/winsup/cygwin/include/elf.h b/winsup/cygwin/include/elf.h deleted file mode 100644 index 0981dedce..000000000 --- a/winsup/cygwin/include/elf.h +++ /dev/null @@ -1,25 +0,0 @@ -/* elf.h - - Copyright 2005 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _ELF_H_ -#define _ELF_H_ - -#ifdef __cplusplus -extern "C" { -#endif -#include -#include -#include -#include -#ifdef __cplusplus -} -#endif - -#endif /*_ELF_H_*/ diff --git a/winsup/cygwin/include/endian.h b/winsup/cygwin/include/endian.h deleted file mode 100644 index c8b89d432..000000000 --- a/winsup/cygwin/include/endian.h +++ /dev/null @@ -1,40 +0,0 @@ -/* endian.h - - Copyright 2005 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _ENDIAN_H_ -#define _ENDIAN_H_ - -#include - -#ifndef __BIG_ENDIAN -#define __BIG_ENDIAN 4321 -#endif -#ifndef __LITTLE_ENDIAN -#define __LITTLE_ENDIAN 1234 -#endif - -#ifndef __BYTE_ORDER -# define __BYTE_ORDER __LITTLE_ENDIAN -#endif - -/*#ifdef __USE_BSD*/ -# define LITTLE_ENDIAN __LITTLE_ENDIAN -# define BIG_ENDIAN __BIG_ENDIAN -# define PDP_ENDIAN __PDP_ENDIAN -# define BYTE_ORDER __BYTE_ORDER -/*#endif*/ - -#if __BYTE_ORDER == __LITTLE_ENDIAN -# define __LONG_LONG_PAIR(HI, LO) LO, HI -#elif __BYTE_ORDER == __BIG_ENDIAN -# define __LONG_LONG_PAIR(HI, LO) HI, LO -#endif -#endif /*_ENDIAN_H_*/ - diff --git a/winsup/cygwin/include/err.h b/winsup/cygwin/include/err.h deleted file mode 100644 index d1002c527..000000000 --- a/winsup/cygwin/include/err.h +++ /dev/null @@ -1,33 +0,0 @@ -/* err.h - - Copyright 2003 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _ERR_H -#define _ERR_H - -#include -#include - -__BEGIN_DECLS - -extern void warn (const char *fmt, ...); -extern void warnx (const char *fmt, ...); - -extern void err (int eval, const char *fmt, ...); -extern void errx (int eval, const char *fmt, ...); - -extern void vwarn (const char *fmt, va_list ap); -extern void vwarnx (const char *fmt, va_list ap); - -extern void verr (int eval, const char *fmt, va_list ap); -extern void verrx (int eval, const char *fmt, va_list ap); - -__END_DECLS - -#endif /* _ERR_H */ diff --git a/winsup/cygwin/include/exceptions.h b/winsup/cygwin/include/exceptions.h deleted file mode 100644 index 39d3d8f17..000000000 --- a/winsup/cygwin/include/exceptions.h +++ /dev/null @@ -1,115 +0,0 @@ -/* exceptions.h - - Copyright 1996, 1997, 1998, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _EXCEPTIONS_H -#define _EXCEPTIONS_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* Documentation on the innards of exception handling (i.e. from the - perspective of a compiler implementor) apparently doesn't exist. Sigh. - However, the following came from Onno Hovers - -The first pointer to the chain of handlers is in the thread environment block -at FS:[0]. This chain has the following format: - -typedef struct __EXCEPTION_FRAME -{ - struct __EXCEPTION_FRAME *Prev; /-* pointer to the previous frame *-/ - PEXCEPTION_HANDLER Handler; /-* handler function *-/ -} - -You register an exception handler in your compiler with this simple ASM -sequence: - PUSH _MyExceptionHandler - PUSH FS:[0] - MOV FS:[0],ESP -An exception frame MUST be on the stack! The frame may have more fields and -both Visual C++ and Borland C++ use more fields for themselves. - -When an exception occurs the system calls all handlers starting with the -handler at FS:0, and then the previous etc. until one handler returns -ExceptionContinueExecution, which is 0. If a handler does not want to handle -the exception it should just return ExceptionContinueSearch, which is 1. - -The handler has the following parameters: -ehandler ( - PEXCEPTION_RECORD erecord, - PEXCEPTION_FRAME myframe, - PCONTEXT context, /-* context before and after *-/ - PVOID dispatch) /-* something *-/ - -When a handler wants to handle the exception, it has some alternatives: - --one is to do do something about the exception condition, like emulating -an invalid instruction, mapping memory where there was a page fault, etc. -If the handler wants to have the context of the thread that causes the -exception changed, it should make that change in the context passed to the -handler. - --the second alternative is to call all exception handlers again, indicating -that you want them to clean up. This way all the __finally blocks get -executed. After doing that you change the context passed to the handler so -the code starts executing in the except block. For this purpose you could -call RtlUnwind. This (undocumented) function calls all exception handlers -up to but not including the exception frame passed to it. If NULL is passed -as exception frame RtlUnwind calls all exception handlers and then exits the -process. The parameters to RtlUnwind are: - -RtlUnwind ( - PEXCEPTION_FRAME endframe, - PVOID unusedEip, - PEXCEPTION_RECORD erecord, - DWORD returnEax) - -You should set unusedEip to the address where RtlUnwind should return like -this: - PUSH 0 - PUSH OFFSET ReturnUnwind - PUSH 0 - PUSH 0 - CALL RtlUnwind -ReturnUnwind: - ..... - -If no EXCEPTION_RECORD is passed, RtlUnwind makes a default exception -record. In any case, the ExceptionFlags part of this record has the -EH_UNWINDING (=2), flag set. (and EH_EXIT_UNWIND (=4), when NULL is passed as the end -frame.). - -The handler for a exception as well as a for unwinds may be executed in the -thread causing the exception, but may also be executed in another (special -exception) thread. So it is not wise to make any assumptions about that! - -As an alternative you may consider the SetUnhandledExceptionFilter API -to install your own exception filter. This one is documented. -*/ - -/* The January 1994 MSJ has an article entitled "Clearer, More Comprehensive - Error Processing with Win32 Structured Exception Handling". It goes into - a teensy bit of detail of the innards of exception handling (i.e. what we - have to do). */ - -typedef int (exception_handler) (EXCEPTION_RECORD *, struct _exception_list *, - CONTEXT *, void *); - -typedef struct _exception_list -{ - struct _exception_list *prev; - exception_handler *handler; -} exception_list; - -#ifdef __cplusplus -}; -#endif /* __cplusplus */ - -#endif /* _EXCEPTIONS_H */ diff --git a/winsup/cygwin/include/fcntl.h b/winsup/cygwin/include/fcntl.h deleted file mode 100644 index 1aff1b74b..000000000 --- a/winsup/cygwin/include/fcntl.h +++ /dev/null @@ -1,51 +0,0 @@ -/* fcntl.h - - Copyright 1996, 1998, 2001, 2005, 2006, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _FCNTL_H -#define _FCNTL_H - -#include -#define O_NDELAY _FNDELAY - -/* sys/fcntl defines values up to 0x40000 (O_NOINHERIT). */ -#define _FDIRECT 0x80000 -#define _FNOFOLLOW 0x100000 -#define _FDIRECTORY 0x200000 -#define _FEXECSRCH 0x400000 - -/* POSIX-1.2008 requires this flag and allows to set it to 0 if its - functionality is not required. */ -#define O_TTY_INIT 0 - -#define O_DIRECT _FDIRECT -#define O_NOFOLLOW _FNOFOLLOW -#define O_DSYNC _FSYNC -#define O_RSYNC _FSYNC -#define O_DIRECTORY _FDIRECTORY -#define O_EXEC _FEXECSRCH -#define O_SEARCH _FEXECSRCH - -#define POSIX_FADV_NORMAL 0 -#define POSIX_FADV_SEQUENTIAL 1 -#define POSIX_FADV_RANDOM 2 -#define POSIX_FADV_WILLNEED 3 -#define POSIX_FADV_DONTNEED 4 -#define POSIX_FADV_NOREUSE 5 - -#ifdef __cplusplus -extern "C" { -#endif -extern int posix_fadvise _PARAMS ((int, off_t, off_t, int)); -extern int posix_fallocate _PARAMS ((int, off_t, off_t)); -#ifdef __cplusplus -} -#endif - -#endif /* _FCNTL_H */ diff --git a/winsup/cygwin/include/features.h b/winsup/cygwin/include/features.h deleted file mode 100644 index 4b0b5f945..000000000 --- a/winsup/cygwin/include/features.h +++ /dev/null @@ -1,35 +0,0 @@ -/* features.h - - Copyright 2001, 2002, 2003, 2004 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _FEATURES_H -#define _FEATURES_H - -#include -#include - -/* Various options should be defined here, but the framework to do this - is not laid down so far. Especially notable are the following defines, - which can be used by the application to switch on or off various - datatypes and function prototypes: - - _BSD_SOURCE to include pure BSD functions which are not defined - under POSIX. - - _POSIX_SOURCE if the application requests a POSIX compatible system. - - _XOPEN_SOURCE if X/Open functions and datatypes are requested. This - option includes _POSIX_SOURCE. - - _GNU_SOURCE to turn on GNU extensions which might collide with defines - used in application or library headers. This option - includes _BSD_SOURCE, _XOPEN_SOURCE and _POSIX_SOURCE. -*/ - -#endif /* _FEATURES_H */ diff --git a/winsup/cygwin/include/fnmatch.h b/winsup/cygwin/include/fnmatch.h deleted file mode 100644 index e4500abe2..000000000 --- a/winsup/cygwin/include/fnmatch.h +++ /dev/null @@ -1,63 +0,0 @@ -/* $OpenBSD: fnmatch.h,v 1.5 2000/03/24 17:13:23 millert Exp $ */ -/* $NetBSD: fnmatch.h,v 1.5 1994/10/26 00:55:53 cgd Exp $ */ - -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - * - * @(#)fnmatch.h 8.1 (Berkeley) 6/2/93 - */ - -#ifndef _FNMATCH_H_ -#define _FNMATCH_H_ - -#define FNM_NOMATCH 1 /* Match failed. */ -#define FNM_NOSYS 2 /* Function not supported (unused). */ - -#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ -#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ -#define FNM_PERIOD 0x04 /* Period must be matched by period. */ -#ifndef _POSIX_SOURCE -#define FNM_LEADING_DIR 0x08 /* Ignore / after Imatch. */ -#define FNM_CASEFOLD 0x10 /* Case insensitive search. */ -#define FNM_IGNORECASE FNM_CASEFOLD -#define FNM_FILE_NAME FNM_PATHNAME -#endif - -#include - -__BEGIN_DECLS -int fnmatch __P((const char *, const char *, int)); -__END_DECLS - -#endif /* !_FNMATCH_H_ */ - - diff --git a/winsup/cygwin/include/fts.h b/winsup/cygwin/include/fts.h deleted file mode 100644 index ac3209920..000000000 --- a/winsup/cygwin/include/fts.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - * - * @(#)fts.h 8.3 (Berkeley) 8/14/94 - * $FreeBSD: /repoman/r/ncvs/src/include/fts.h,v 1.11 2005/01/07 00:06:20 pjd Exp $ - */ - -#ifndef _FTS_H_ -#define _FTS_H_ - -typedef struct { - struct _ftsent *fts_cur; /* current node */ - struct _ftsent *fts_child; /* linked list of children */ - struct _ftsent **fts_array; /* sort array */ - __dev32_t fts_dev; /* starting device # */ - char *fts_path; /* path for this descent */ - int fts_rfd; /* fd for root */ - int fts_pathlen; /* sizeof(path) */ - int fts_nitems; /* elements in the sort array */ - int (*fts_compar) /* compare function */ - (const struct _ftsent * const *, const struct _ftsent * const *); - -#define FTS_COMFOLLOW 0x001 /* follow command line symlinks */ -#define FTS_LOGICAL 0x002 /* logical walk */ -#define FTS_NOCHDIR 0x004 /* don't change directories */ -#define FTS_NOSTAT 0x008 /* don't get stat info */ -#define FTS_PHYSICAL 0x010 /* physical walk */ -#define FTS_SEEDOT 0x020 /* return dot and dot-dot */ -#define FTS_XDEV 0x040 /* don't cross devices */ -#ifndef __CYGWIN__ -#define FTS_WHITEOUT 0x080 /* return whiteout information */ -#endif -#define FTS_OPTIONMASK 0x0ff /* valid user option mask */ - -#define FTS_NAMEONLY 0x100 /* (private) child names only */ -#define FTS_STOP 0x200 /* (private) unrecoverable error */ - int fts_options; /* fts_open options, global flags */ - void *fts_clientptr; /* thunk for sort function */ -} FTS; - -typedef struct _ftsent { - struct _ftsent *fts_cycle; /* cycle node */ - struct _ftsent *fts_parent; /* parent directory */ - struct _ftsent *fts_link; /* next file in directory */ - union { - struct { - long __fts_number; /* local numeric value */ - void *__fts_pointer; /* local address value */ - } __struct_ftsent; - int64_t __fts_bignum; - } __union_ftsent; -#define fts_number __union_ftsent.__struct_ftsent.__fts_number -#define fts_pointer __union_ftsent.__struct_ftsent.__fts_pointer -#define fts_bignum __union_ftsent.__fts_bignum - char *fts_accpath; /* access path */ - char *fts_path; /* root path */ - int fts_errno; /* errno for this node */ - int fts_symfd; /* fd for symlink */ - u_short fts_pathlen; /* strlen(fts_path) */ - u_short fts_namelen; /* strlen(fts_name) */ - - __ino64_t fts_ino; /* inode */ - __dev32_t fts_dev; /* device */ - nlink_t fts_nlink; /* link count */ - -#define FTS_ROOTPARENTLEVEL -1 -#define FTS_ROOTLEVEL 0 - short fts_level; /* depth (-1 to N) */ - -#define FTS_D 1 /* preorder directory */ -#define FTS_DC 2 /* directory that causes cycles */ -#define FTS_DEFAULT 3 /* none of the above */ -#define FTS_DNR 4 /* unreadable directory */ -#define FTS_DOT 5 /* dot or dot-dot */ -#define FTS_DP 6 /* postorder directory */ -#define FTS_ERR 7 /* error; errno is set */ -#define FTS_F 8 /* regular file */ -#define FTS_INIT 9 /* initialized only */ -#define FTS_NS 10 /* stat(2) failed */ -#define FTS_NSOK 11 /* no stat(2) requested */ -#define FTS_SL 12 /* symbolic link */ -#define FTS_SLNONE 13 /* symbolic link without target */ -#define FTS_W 14 /* whiteout object */ - u_short fts_info; /* user flags for FTSENT structure */ - -#define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ -#define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ -#define FTS_ISW 0x04 /* this is a whiteout object */ - u_short fts_flags; /* private flags for FTSENT structure */ - -#define FTS_AGAIN 1 /* read node again */ -#define FTS_FOLLOW 2 /* follow symbolic link */ -#define FTS_NOINSTR 3 /* no instructions */ -#define FTS_SKIP 4 /* discard node */ - u_short fts_instr; /* fts_set() instructions */ - -#ifdef __INSIDE_CYGWIN__ - struct __stat64 *fts_statp; /* stat(2) information */ -#elif defined (__CYGWIN__) && !defined (__CYGWIN_USE_BIG_TYPES__) - #error "fts requires __CYGWIN_USE_BIG_TYPES__" -#else - struct stat *fts_statp; /* stat(2) information */ -#endif - char *fts_name; /* file name */ - FTS *fts_fts; /* back pointer to main FTS */ -} FTSENT; - -#include - -__BEGIN_DECLS -FTSENT *fts_children(FTS *, int); -int fts_close(FTS *); -void *fts_get_clientptr(FTS *); -#define fts_get_clientptr(fts) ((fts)->fts_clientptr) -FTS *fts_get_stream(FTSENT *); -#define fts_get_stream(ftsent) ((ftsent)->fts_fts) -FTS *fts_open(char * const *, int, - int (*)(const FTSENT * const *, const FTSENT * const *)); -FTSENT *fts_read(FTS *); -int fts_set(FTS *, FTSENT *, int); -void fts_set_clientptr(FTS *, void *); -__END_DECLS - -#endif /* !_FTS_H_ */ diff --git a/winsup/cygwin/include/ftw.h b/winsup/cygwin/include/ftw.h deleted file mode 100644 index 501081e73..000000000 --- a/winsup/cygwin/include/ftw.h +++ /dev/null @@ -1,71 +0,0 @@ -/* $OpenBSD: ftw.h,v 1.1 2003/07/21 21:13:18 millert Exp $ */ - -/* - * Copyright (c) 2003 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Sponsored in part by the Defense Advanced Research Projects - * Agency (DARPA) and Air Force Research Laboratory, Air Force - * Materiel Command, USAF, under agreement number F39502-99-1-0512. - * - * $FreeBSD: /repoman/r/ncvs/src/include/ftw.h,v 1.2 2004/08/24 13:00:54 tjr Exp $ - */ - -#ifndef _FTW_H -#define _FTW_H - -#include -#include -#include - -/* - * Valid flags for the 3rd argument to the function that is passed as the - * second argument to ftw(3) and nftw(3). Say it three times fast! - */ -#define FTW_F 0 /* File. */ -#define FTW_D 1 /* Directory. */ -#define FTW_DNR 2 /* Directory without read permission. */ -#define FTW_DP 3 /* Directory with subdirectories visited. */ -#define FTW_NS 4 /* Unknown type; stat() failed. */ -#define FTW_SL 5 /* Symbolic link. */ -#define FTW_SLN 6 /* Sym link that names a nonexistent file. */ - -/* - * Flags for use as the 4th argument to nftw(3). These may be ORed together. - */ -#define FTW_PHYS 0x01 /* Physical walk, don't follow sym links. */ -#define FTW_MOUNT 0x02 /* The walk does not cross a mount point. */ -#define FTW_DEPTH 0x04 /* Subdirs visited before the dir itself. */ -#define FTW_CHDIR 0x08 /* Change to a directory before reading it. */ - -struct FTW { - int base; - int level; -}; - -__BEGIN_DECLS -#ifdef __INSIDE_CYGWIN__ -int ftw(const char *, int (*)(const char *, const struct __stat64 *, int), int); -int nftw(const char *, int (*)(const char *, const struct __stat64 *, int, - struct FTW *), int, int); -#elif defined (__CYGWIN__) && !defined (__CYGWIN_USE_BIG_TYPES__) - #error "ftw requires __CYGWIN_USE_BIG_TYPES__" -#else -int ftw(const char *, int (*)(const char *, const struct stat *, int), int); -int nftw(const char *, int (*)(const char *, const struct stat *, int, - struct FTW *), int, int); -#endif -__END_DECLS - -#endif /* !_FTW_H */ diff --git a/winsup/cygwin/include/getopt.h b/winsup/cygwin/include/getopt.h deleted file mode 100644 index 0c1c8c92a..000000000 --- a/winsup/cygwin/include/getopt.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 1987, 1993, 1994, 1996 - * The Regents of the University of California. All rights reserved. - * - * 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. - */ - -#ifdef _COMPILING_NEWLIB -#include_next "getopt.h" -#else -#ifndef __GETOPT_H__ -#define __GETOPT_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef __INSIDE_CYGWIN__ -extern int __declspec(dllimport) opterr; /* if error message should be printed */ -extern int __declspec(dllimport) optind; /* index into parent argv vector */ -extern int __declspec(dllimport) optopt; /* character checked for validity */ -extern int __declspec(dllimport) optreset; /* reset getopt */ -extern char __declspec(dllimport) *optarg; /* argument associated with option */ -#endif - -int getopt (int, char * const *, const char *); - -#ifdef __cplusplus -} -#endif - -#endif /* __GETOPT_H__ */ - -#ifndef __UNISTD_GETOPT__ -#ifndef __GETOPT_LONG_H__ -#define __GETOPT_LONG_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -struct option { - const char *name; - int has_arg; - int *flag; - int val; -}; - -int getopt_long (int, char *const *, const char *, const struct option *, int *); -int getopt_long_only (int, char *const *, const char *, const struct option *, int *); - -#ifndef HAVE_DECL_GETOPT -#define HAVE_DECL_GETOPT 1 -#endif - -#define no_argument 0 -#define required_argument 1 -#define optional_argument 2 - -#ifdef __cplusplus -} -#endif - -#endif /* __GETOPT_LONG_H__ */ -#endif /* __UNISTD_GETOPT__ */ -#endif /*_INSIDE_NEWLIB*/ diff --git a/winsup/cygwin/include/glob.h b/winsup/cygwin/include/glob.h deleted file mode 100644 index 93f2d7e94..000000000 --- a/winsup/cygwin/include/glob.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Guido van Rossum. - * - * 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. - * - * @(#)glob.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD: /repoman/r/ncvs/src/include/glob.h,v 1.10 2006/05/22 05:57:39 ache Exp $ - */ - -#ifndef _GLOB_H_ -#define _GLOB_H_ - -#include -#include -#include - -typedef struct { - size_t gl_pathc; /* Count of total paths so far. */ - size_t gl_matchc; /* Count of paths matching pattern. */ - size_t gl_offs; /* Reserved at beginning of gl_pathv. */ - int gl_flags; /* Copy of flags parameter to glob. */ - char **gl_pathv; /* List of paths matching pattern. */ - /* Copy of errfunc parameter to glob. */ - int (*gl_errfunc) __P((const char *, int)); - - /* - * Alternate filesystem access methods for glob; replacement - * versions of closedir(3), readdir(3), opendir(3), stat(2) - * and lstat(2). - */ - void (*gl_closedir)(void *); - struct dirent *(*gl_readdir)(void *); - void *(*gl_opendir)(const char *); -#if defined (__INSIDE_CYGWIN__) - int (*gl_lstat) __P((const char *, struct __stat64 *)); - int (*gl_stat) __P((const char *, struct __stat64 *)); -#else - - int (*gl_lstat) __P((const char *, struct stat *)); - int (*gl_stat) __P((const char *, struct stat *)); -#endif -} glob_t; - -/* Believed to have been introduced in 1003.2-1992 */ -#define GLOB_APPEND 0x0001 /* Append to output from previous call. */ -#define GLOB_DOOFFS 0x0002 /* Use gl_offs. */ -#define GLOB_ERR 0x0004 /* Return on error. */ -#define GLOB_MARK 0x0008 /* Append / to matching directories. */ -#define GLOB_NOCHECK 0x0010 /* Return pattern itself if nothing matches. */ -#define GLOB_NOSORT 0x0020 /* Don't sort. */ -#define GLOB_NOESCAPE 0x2000 /* Disable backslash escaping. */ - -/* Error values returned by glob(3) */ -#define GLOB_NOSPACE (-1) /* Malloc call failed. */ -#define GLOB_ABORTED (-2) /* Unignored error. */ -#define GLOB_NOMATCH (-3) /* No match and GLOB_NOCHECK was not set. */ -#define GLOB_NOSYS (-4) /* Obsolete: source comptability only. */ - -#ifndef _POSIX_SOURCE -#define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */ -#define GLOB_BRACE 0x0080 /* Expand braces ala csh. */ -#define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */ -#define GLOB_NOMAGIC 0x0200 /* GLOB_NOCHECK without magic chars (csh). */ -#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */ -#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */ -#define GLOB_LIMIT 0x1000 /* limit number of returned paths */ - -/* source compatibility, these are the old names */ -#define GLOB_MAXPATH GLOB_LIMIT -#define GLOB_ABEND GLOB_ABORTED -#endif /* __BSD_VISIBLE */ - -__BEGIN_DECLS - -#undef DLLEXPORT -#ifdef __INSIDE_CYGWIN__ -# define DLLEXPORT -#else -# define DLLEXPORT __declspec(dllimport) -#endif - -int DLLEXPORT glob (const char *, int, int (*)(const char *, int), glob_t *); -void DLLEXPORT globfree (glob_t *); -int DLLEXPORT glob_pattern_p (const char *, int); -__END_DECLS - -#endif /* !_GLOB_H_ */ diff --git a/winsup/cygwin/include/icmp.h b/winsup/cygwin/include/icmp.h deleted file mode 100644 index 7e7aedccd..000000000 --- a/winsup/cygwin/include/icmp.h +++ /dev/null @@ -1 +0,0 @@ -/* icmp.h */ diff --git a/winsup/cygwin/include/ifaddrs.h b/winsup/cygwin/include/ifaddrs.h deleted file mode 100644 index f6c28e798..000000000 --- a/winsup/cygwin/include/ifaddrs.h +++ /dev/null @@ -1,57 +0,0 @@ -/* $OpenBSD: ifaddrs.h,v 1.4 2004/01/22 21:48:02 espie Exp $ */ - -/* - * Copyright (c) 1995, 1999 - * Berkeley Software Design, Inc. All rights reserved. - * - * 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. - * - * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``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 Berkeley Software Design, Inc. 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. - * - * BSDI ifaddrs.h,v 2.5 2000/02/23 14:51:59 dab Exp - */ - -#ifndef _IFADDRS_H_ -#define _IFADDRS_H_ - -struct ifaddrs { - struct ifaddrs *ifa_next; - char *ifa_name; - unsigned int ifa_flags; - struct sockaddr *ifa_addr; - struct sockaddr *ifa_netmask; - struct sockaddr *ifa_dstaddr; - void *ifa_data; -}; - -/* - * This may have been defined in . Note that if is - * to be included it must be included before this header file. - */ -/* CV 2007-06-20: Not a problem on Cygwin right now. */ -#ifndef ifa_broadaddr -#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */ -#endif - -#include - -__BEGIN_DECLS -extern int getifaddrs(struct ifaddrs **); -extern void freeifaddrs(struct ifaddrs *); -__END_DECLS - -#endif diff --git a/winsup/cygwin/include/inttypes.h b/winsup/cygwin/include/inttypes.h deleted file mode 100644 index ff34678ed..000000000 --- a/winsup/cygwin/include/inttypes.h +++ /dev/null @@ -1,246 +0,0 @@ -/* inttypes.h - fixed size integer types - - Copyright 2003, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _INTTYPES_H -#define _INTTYPES_H - -#include -#define __need_wchar_t -#include - -/* fprintf() macros for signed integers */ - -#define PRId8 "d" -#define PRId16 "d" -#define PRId32 "d" -#define PRId64 "lld" - -#define PRIdLEAST8 "d" -#define PRIdLEAST16 "d" -#define PRIdLEAST32 "d" -#define PRIdLEAST64 "lld" - -#define PRIdFAST8 "d" -#define PRIdFAST16 "d" -#define PRIdFAST32 "d" -#define PRIdFAST64 "lld" - -#define PRIdMAX "lld" -#define PRIdPTR "ld" - -#define PRIi8 "i" -#define PRIi16 "i" -#define PRIi32 "i" -#define PRIi64 "lli" - -#define PRIiLEAST8 "i" -#define PRIiLEAST16 "i" -#define PRIiLEAST32 "i" -#define PRIiLEAST64 "lli" - -#define PRIiFAST8 "i" -#define PRIiFAST16 "i" -#define PRIiFAST32 "i" -#define PRIiFAST64 "lli" - -#define PRIiMAX "lli" -#define PRIiPTR "li" - -/* fprintf() macros for unsigned integers */ - -#define PRIo8 "o" -#define PRIo16 "o" -#define PRIo32 "o" -#define PRIo64 "llo" - -#define PRIoLEAST8 "o" -#define PRIoLEAST16 "o" -#define PRIoLEAST32 "o" -#define PRIoLEAST64 "llo" - -#define PRIoFAST8 "o" -#define PRIoFAST16 "o" -#define PRIoFAST32 "o" -#define PRIoFAST64 "llo" - -#define PRIoMAX "llo" -#define PRIoPTR "lo" - -#define PRIu8 "u" -#define PRIu16 "u" -#define PRIu32 "u" -#define PRIu64 "llu" - -#define PRIuLEAST8 "u" -#define PRIuLEAST16 "u" -#define PRIuLEAST32 "u" -#define PRIuLEAST64 "llu" - -#define PRIuFAST8 "u" -#define PRIuFAST16 "u" -#define PRIuFAST32 "u" -#define PRIuFAST64 "llu" - -#define PRIuMAX "llu" -#define PRIuPTR "lu" - -#define PRIx8 "x" -#define PRIx16 "x" -#define PRIx32 "x" -#define PRIx64 "llx" - -#define PRIxLEAST8 "x" -#define PRIxLEAST16 "x" -#define PRIxLEAST32 "x" -#define PRIxLEAST64 "llx" - -#define PRIxFAST8 "x" -#define PRIxFAST16 "x" -#define PRIxFAST32 "x" -#define PRIxFAST64 "llx" - -#define PRIxMAX "llx" -#define PRIxPTR "lx" - -#define PRIX8 "X" -#define PRIX16 "X" -#define PRIX32 "X" -#define PRIX64 "llX" - -#define PRIXLEAST8 "X" -#define PRIXLEAST16 "X" -#define PRIXLEAST32 "X" -#define PRIXLEAST64 "llX" - -#define PRIXFAST8 "X" -#define PRIXFAST16 "X" -#define PRIXFAST32 "X" -#define PRIXFAST64 "llX" - -#define PRIXMAX "llX" -#define PRIXPTR "lX" - -/* fscanf() macros for signed integers */ - -#define SCNd8 "hhd" -#define SCNd16 "hd" -#define SCNd32 "d" -#define SCNd64 "lld" - -#define SCNdLEAST8 "hhd" -#define SCNdLEAST16 "hd" -#define SCNdLEAST32 "d" -#define SCNdLEAST64 "lld" - -#define SCNdFAST8 "hhd" -#define SCNdFAST16 "d" -#define SCNdFAST32 "d" -#define SCNdFAST64 "lld" - -#define SCNdMAX "lld" -#define SCNdPTR "ld" - -#define SCNi8 "hhi" -#define SCNi16 "hi" -#define SCNi32 "i" -#define SCNi64 "lli" - -#define SCNiLEAST8 "hhi" -#define SCNiLEAST16 "hi" -#define SCNiLEAST32 "i" -#define SCNiLEAST64 "lli" - -#define SCNiFAST8 "hhi" -#define SCNiFAST16 "i" -#define SCNiFAST32 "i" -#define SCNiFAST64 "lli" - -#define SCNiMAX "lli" -#define SCNiPTR "li" - -/* fscanf() macros for unsigned integers */ - -#define SCNo8 "hho" -#define SCNo16 "ho" -#define SCNo32 "o" -#define SCNo64 "llo" - -#define SCNoLEAST8 "hho" -#define SCNoLEAST16 "ho" -#define SCNoLEAST32 "o" -#define SCNoLEAST64 "llo" - -#define SCNoFAST8 "hho" -#define SCNoFAST16 "o" -#define SCNoFAST32 "o" -#define SCNoFAST64 "llo" - -#define SCNoMAX "llo" -#define SCNoPTR "lo" - -#define SCNu8 "hhu" -#define SCNu16 "hu" -#define SCNu32 "u" -#define SCNu64 "llu" - -#define SCNuLEAST8 "hhu" -#define SCNuLEAST16 "hu" -#define SCNuLEAST32 "u" -#define SCNuLEAST64 "llu" - -#define SCNuFAST8 "hhu" -#define SCNuFAST16 "u" -#define SCNuFAST32 "u" -#define SCNuFAST64 "llu" - -#define SCNuMAX "llu" -#define SCNuPTR "lu" - -#define SCNx8 "hhx" -#define SCNx16 "hx" -#define SCNx32 "x" -#define SCNx64 "llx" - -#define SCNxLEAST8 "hhx" -#define SCNxLEAST16 "hx" -#define SCNxLEAST32 "x" -#define SCNxLEAST64 "llx" - -#define SCNxFAST8 "hhx" -#define SCNxFAST16 "x" -#define SCNxFAST32 "x" -#define SCNxFAST64 "llx" - -#define SCNxMAX "llx" -#define SCNxPTR "lx" - -#ifdef __cplusplus -extern "C" { -#endif - -#include <_ansi.h> - -typedef struct { - intmax_t quot; - intmax_t rem; -} imaxdiv_t; - -intmax_t _EXFUN(imaxabs, (intmax_t)); -imaxdiv_t _EXFUN(imaxdiv, (intmax_t, intmax_t)); -intmax_t _EXFUN(strtoimax, (const char *, char **, int)); -uintmax_t _EXFUN(strtoumax, (const char *, char **, int)); -intmax_t _EXFUN(wcstoimax, (const wchar_t *, wchar_t **, int)); -uintmax_t _EXFUN(wcstoumax, (const wchar_t *, wchar_t **, int)); - -#ifdef __cplusplus -} -#endif - -#endif /* _INTTYPES_H */ diff --git a/winsup/cygwin/include/io.h b/winsup/cygwin/include/io.h deleted file mode 100644 index de9f39e0a..000000000 --- a/winsup/cygwin/include/io.h +++ /dev/null @@ -1,29 +0,0 @@ -/* io.h - - Copyright 1999, 2000, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _IO_H_ -#define _IO_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * Function to return a Win32 HANDLE from a fd. - */ -extern long get_osfhandle(int); -extern int setmode (int __fd, int __mode); -int access(const char *__path, int __amode); - -#ifdef __cplusplus -}; -#endif /* __cplusplus */ - -#endif /* _IO_H_ */ diff --git a/winsup/cygwin/include/lastlog.h b/winsup/cygwin/include/lastlog.h deleted file mode 100644 index 9db86206d..000000000 --- a/winsup/cygwin/include/lastlog.h +++ /dev/null @@ -1,22 +0,0 @@ -/* lastlog.h - - Copyright 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _LASTLOG_H -#define _LASTLOG_H - -#include - -struct lastlog { - long ll_time; - char ll_line[UT_LINESIZE]; - char ll_host[UT_HOSTSIZE]; -}; - -#endif diff --git a/winsup/cygwin/include/libgen.h b/winsup/cygwin/include/libgen.h deleted file mode 100644 index f5c24a8cc..000000000 --- a/winsup/cygwin/include/libgen.h +++ /dev/null @@ -1,23 +0,0 @@ -/* libgen.h - - Copyright 2005 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _LIBGEN_H -#define _LIBGEN_H - -#include - -__BEGIN_DECLS - -extern char *basename (char *path); -extern char *dirname (char *path); - -__END_DECLS - -#endif /* _LIBGEN_H */ diff --git a/winsup/cygwin/include/limits.h b/winsup/cygwin/include/limits.h deleted file mode 100644 index f3bdece68..000000000 --- a/winsup/cygwin/include/limits.h +++ /dev/null @@ -1,491 +0,0 @@ -/* limits.h - - Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _LIMITS_H___ - -#include - -#ifndef _MACH_MACHLIMITS_H_ - -/* _MACH_MACHLIMITS_H_ is used on OSF/1. */ -#define _LIMITS_H___ -#define _MACH_MACHLIMITS_H_ - - -/* Numerical limits */ - -/* Number of bits in a `char'. */ -#undef CHAR_BIT -#define CHAR_BIT 8 - -/* Maximum length of a multibyte character. */ -#ifndef MB_LEN_MAX -/* TODO: This is newlib's max value. We should probably rather define our - own _mbtowc_r and _wctomb_r functions which are only codepage dependent. */ -#define MB_LEN_MAX 8 -#endif - -/* Minimum and maximum values a `signed char' can hold. */ -#undef SCHAR_MIN -#define SCHAR_MIN (-128) -#undef SCHAR_MAX -#define SCHAR_MAX 127 - -/* Maximum value an `unsigned char' can hold. (Minimum is 0). */ -#undef UCHAR_MAX -#define UCHAR_MAX 255 - -/* Minimum and maximum values a `char' can hold. */ -#ifdef __CHAR_UNSIGNED__ -#undef CHAR_MIN -#define CHAR_MIN 0 -#undef CHAR_MAX -#define CHAR_MAX 255 -#else -#undef CHAR_MIN -#define CHAR_MIN (-128) -#undef CHAR_MAX -#define CHAR_MAX 127 -#endif - -/* Minimum and maximum values a `signed short int' can hold. */ -#undef SHRT_MIN -#define SHRT_MIN (-32768) -#undef SHRT_MAX -#define SHRT_MAX 32767 - -/* Maximum value an `unsigned short int' can hold. (Minimum is 0). */ -#undef USHRT_MAX -#define USHRT_MAX 65535 - -/* Minimum and maximum values a `signed int' can hold. */ -#ifndef __INT_MAX__ -#define __INT_MAX__ 2147483647 -#endif -#undef INT_MIN -#define INT_MIN (-INT_MAX-1) -#undef INT_MAX -#define INT_MAX __INT_MAX__ - -/* Maximum value an `unsigned int' can hold. (Minimum is 0). */ -#undef UINT_MAX -#define UINT_MAX (INT_MAX * 2U + 1) - -/* Minimum and maximum values a `signed long int' can hold. - (Same as `int'). */ -#ifndef __LONG_MAX__ -#ifndef __alpha__ -#define __LONG_MAX__ 2147483647L -#else -#define __LONG_MAX__ 9223372036854775807L -# endif /* __alpha__ */ -#endif -#undef LONG_MIN -#define LONG_MIN (-LONG_MAX-1) -#undef LONG_MAX -#define LONG_MAX __LONG_MAX__ - -/* Maximum value an `unsigned long int' can hold. (Minimum is 0). */ -#undef ULONG_MAX -#define ULONG_MAX (LONG_MAX * 2UL + 1) - -/* Minimum and maximum values a `signed long long int' can hold. */ -#ifndef __LONG_LONG_MAX__ -#define __LONG_LONG_MAX__ 9223372036854775807LL -#endif - -#if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined (__STRICT_ANSI__) -#undef LONG_LONG_MIN -#define LONG_LONG_MIN (-LONG_LONG_MAX-1) -#undef LONG_LONG_MAX -#define LONG_LONG_MAX __LONG_LONG_MAX__ - -/* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */ -#undef ULONG_LONG_MAX -#define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1) -#endif - -/* Minimum and maximum values a `signed long long int' can hold. */ -#undef LLONG_MIN -#define LLONG_MIN (-LLONG_MAX-1) -#undef LLONG_MAX -#define LLONG_MAX __LONG_LONG_MAX__ - -/* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */ -#undef ULLONG_MAX -#define ULLONG_MAX (LLONG_MAX * 2ULL + 1) - -/* Maximum size of ssize_t */ -#undef SSIZE_MAX -#define SSIZE_MAX (__LONG_MAX__) - - -/* Runtime Invariant Values */ - -/* Please note that symbolic names shall be ommited, on specific - implementations where the corresponding value is equal to or greater - than the stated minimum, but is unspecified. This indetermination - might depend on the amount of available memory space on a specific - instance of a specific implementation. The actual value supported by - a specific instance shall be provided by the sysconf() function. */ - -/* Maximum number of I/O operations in a single list I/O call supported by - the implementation. Not yet implemented. */ -#undef AIO_LISTIO_MAX -/* #define AIO_LISTIO_MAX >= _POSIX_AIO_LISTIO_MAX */ - -/* Maximum number of outstanding asynchronous I/O operations supported by - the implementation. Not yet implemented. */ -#undef AIO_MAX -/* #define AIO_MAX >= _POSIX_AIO_MAX */ - -/* The maximum amount by which a process can decrease its asynchronous I/O - priority level from its own scheduling priority. */ -#undef AIO_PRIO_DELTA_MAX -/* #define AIO_PRIO_DELTA_MAX >= 0 */ - -/* Maximum number of bytes in arguments and environment passed in an exec - call. 32000 is the safe value used for Windows processes when called - from Cygwin processes. */ -#undef ARG_MAX -#define ARG_MAX 32000 - -/* Maximum number of functions that may be registered with atexit(). */ -#undef ATEXIT_MAX -#define ATEXIT_MAX 32 - -/* Maximum number of simultaneous processes per real user ID. */ -#undef CHILD_MAX -#define CHILD_MAX 256 - -/* Maximum number of timer expiration overruns. Not yet implemented. */ -#undef DELAYTIMER_MAX -/* #define DELAYTIMER_MAX >= _POSIX_DELAYTIMER_MAX */ - -/* Maximum length of a host name. */ -#undef HOST_NAME_MAX -#define HOST_NAME_MAX 255 - -/* Maximum number of iovcnt in a writev (an arbitrary number) */ -#undef IOV_MAX -#define IOV_MAX 1024 - -/* Maximum number of characters in a login name. */ -#undef LOGIN_NAME_MAX -#define LOGIN_NAME_MAX 256 /* equal to UNLEN defined in w32api/lmcons.h */ - -/* The maximum number of open message queue descriptors a process may hold. */ -#undef MQ_OPEN_MAX -#define MQ_OPEN_MAX OPEN_MAX - -/* The maximum number of message priorities supported by the implementation. */ -#undef MQ_PRIO_MAX -#define MQ_PRIO_MAX INT_MAX - -/* # of open files per process. Actually it can be more since Cygwin - grows the dtable as necessary. We define a reasonable limit here - which is returned by getdtablesize(), sysconf(_SC_OPEN_MAX) and - getrlimit(RLIMIT_NOFILE). */ -#undef OPEN_MAX -#define OPEN_MAX 256 - -/* Size in bytes of a page. */ -#undef PAGESIZE -#undef PAGE_SIZE -#define PAGESIZE 65536 -#define PAGE_SIZE PAGESIZE - -/* Maximum number of attempts made to destroy a thread's thread-specific - data values on thread exit. */ -/* FIXME: I really don't understand this value. Why should multiple - attempts be necessary to destroy thread-specific data?!? Anyway, the - current value here is 1, taken originally from our pthread.h file, - where it was mistakenly defined first. Unfortunately this value is - lower than the POSIX defined minimum value, which is 4. */ -#undef PTHREAD_DESTRUCTOR_ITERATIONS -#define PTHREAD_DESTRUCTOR_ITERATIONS 1 - -/* Maximum number of data keys that can be created by a process. */ -/* Tls has 64 items for pre win2000 - and we don't want to use them all :] */ -#undef PTHREAD_KEYS_MAX -#define PTHREAD_KEYS_MAX 32 - -/* Minimum size in bytes of thread stack storage. */ -/* Actually the minimum stack size is somewhat of a split personality. - The size parameter in a CreateThread call is the size of the initially - commited stack size, which can be specified as low as 4K. However, the - default *reserved* stack size is 1 Meg, unless the .def file specifies - another STACKSIZE value. And even if you specify a stack size below 64K, - the allocation granularity is in the way. You can never squeeze multiple - threads in the same allocation granularity slot. Oh well. */ -#undef PTHREAD_STACK_MIN -#define PTHREAD_STACK_MIN 65536 - -/* Maximum number of threads that can be created per process. */ -/* Windows allows any arbitrary number of threads per process. */ -#undef PTHREAD_THREADS_MAX -/* #define PTHREAD_THREADS_MAX unspecified */ - -/* Maximum number of realtime signals reserved for application use. */ -/* FIXME: We only support one realtime signal but _POSIX_RTSIG_MAX is 8. */ -#undef RTSIG_MAX -#define RTSIG_MAX 1 - -/* Maximum number of semaphores that a process may have. */ -/* Windows allows any arbitrary number of semaphores per process. */ -#undef SEM_NSEMS_MAX -/* #define SEM_NSEMS_MAX unspecified */ - -/* The maximum value a semaphore may have. */ -#undef SEM_VALUE_MAX -#define SEM_VALUE_MAX 1147483648 - -/* Maximum number of queued signals that a process may send and have pending - at the receiver(s) at any time. */ -#undef SIGQUEUE_MAX -#define SIGQUEUE_MAX 32 - -/* The maximum number of replenishment operations that may be simultaneously - pending for a particular sporadic server scheduler. Not implemented. */ -#undef SS_REPL_MAX -/* #define SS_REPL_MAX >= _POSIX_SS_REPL_MAX */ - -/* Number of streams that one process can have open at one time. */ -#undef STREAM_MAX -#define STREAM_MAX 20 - -/* Maximum number of nested symbolic links. */ -#undef SYMLOOP_MAX -#define SYMLOOP_MAX 10 - -/* Maximum number of timer expiration overruns. */ -#undef TIMER_MAX -#define TIMER_MAX 32 - -/* Maximum length of the trace event name. Not implemented. */ -#undef TRACE_EVENT_NAME_MAX -/* #define TRACE_EVENT_NAME_MAX >= _POSIX_TRACE_EVENT_NAME_MAX */ - -/* Maximum length of the trace generation version string or of the trace - stream name. Not implemented. */ -#undef TRACE_NAME_MAX -/* #define TRACE_NAME_MAX >= _POSIX_TRACE_NAME_MAX */ - -/* Maximum number of trace streams that may simultaneously exist in the - system. Not implemented. */ -#undef TRACE_SYS_MAX -/* #define TRACE_SYS_MAX >= _POSIX_TRACE_SYS_MAX */ - -/* Maximum number of user trace event type identifiers that may simultaneously - exist in a traced process, including the predefined user trace event - POSIX_TRACE_UNNAMED_USER_EVENT. Not implemented. */ -#undef TRACE_USER_EVENT_MAX -/* #define TRACE_USER_EVENT_MAX >= _POSIX_TRACE_USER_EVENT_MAX */ - -/* Maximum number of characters in a tty name. */ -#undef TTY_NAME_MAX -#define TTY_NAME_MAX 32 - -/* Maximum number of bytes supported for the name of a timezone (not of the TZ variable). Not implemented. */ -#undef TZNAME_MAX -/* #define TZNAME_MAX >= _POSIX_TZNAME_MAX */ - - -/* Pathname Variable Values */ - -/* Minimum bits needed to represent the maximum size of a regular file. */ -#undef FILESIZEBITS -#define FILESIZEBITS 64 - -/* Maximum number of hardlinks to a file. */ -#undef LINK_MAX -#define LINK_MAX 1024 - -/* Maximum number of bytes in a terminal canonical input line. */ -#undef MAX_CANON -#define MAX_CANON 255 - -/* Minimum number of bytes available in a terminal input queue. */ -#undef MAX_INPUT -#define MAX_INPUT 255 - -/* Maximum length of a path component. */ -#undef NAME_MAX -#define NAME_MAX 255 - -/* Maximum length of a path given to API functions including trailing NUL. - Deliberately set to the same default value as on Linux. Internal paths - may be longer. */ -/* Keep in sync with __PATHNAME_MAX__ in cygwin/config.h */ -#undef PATH_MAX -#define PATH_MAX 4096 - -/* # of bytes in a pipe buf. This is the max # of bytes which can be - written to a pipe in one atomic operation. */ -#undef PIPE_BUF -#define PIPE_BUF 4096 - -/* Minimum number of bytes of storage actually allocated for any portion - of a file. Not implemented. */ -#undef POSIX_ALLOC_SIZE_MIN -/* #define POSIX_ALLOC_SIZE_MIN unspecifed */ - -/* Recommended increment for file transfer sizes between the - {POSIX_REC_MIN_XFER_SIZE} and {POSIX_REC_MAX_XFER_SIZE} values. - Not implemented. */ -#undef POSIX_REC_INCR_XFER_SIZE -/* #define POSIX_REC_INCR_XFER_SIZE unspecifed */ - -/* Maximum recommended file transfer size. Not implemented. */ -#undef POSIX_REC_MAX_XFER_SIZE -/* #define POSIX_REC_MAX_XFER_SIZE unspecifed */ - -/* Minimum recommended file transfer size. Not implemented. */ -#undef POSIX_REC_MIN_XFER_SIZE -/* #define POSIX_REC_MIN_XFER_SIZE unspecifed */ - -/* Recommended file transfer buffer alignment. Not implemented. */ -#undef POSIX_REC_XFER_ALIGN -/* #define POSIX_REC_XFER_ALIGN unspecifed */ - -/* Maximum number of bytes in a symbolic link. */ -#undef SYMLINK_MAX -#define SYMLINK_MAX (PATH_MAX - 1) - - -/* Runtime Increasable Values */ - -/* Maximum obase values allowed by the bc utility. */ -#undef BC_BASE_MAX -#define BC_BASE_MAX 99 - -/* Maximum number of elements permitted in an array by the bc utility. */ -#undef BC_DIM_MAX -#define BC_DIM_MAX 2048 - -/* Maximum scale value allowed by the bc utility. */ -#undef BC_SCALE_MAX -#define BC_SCALE_MAX 99 - -/* Maximum length of a string constant accepted by the bc utility. */ -#undef BC_STRING_MAX -#define BC_STRING_MAX 1000 - -/* Maximum number of bytes in a character class name. Not implemented. */ -#undef CHARCLASS_NAME_MAX -/* #define CHARCLASS_NAME_MAX >= _POSIX2_CHARCLASS_NAME_MAX */ - -/* Maximum number of weights that can be assigned to an entry of the - LC_COLLATE order keyword in the locale definition file. */ -/* FIXME: We don't support this at all right now, so this value is - misleading at best. It's also lower than _POSIX2_COLL_WEIGHTS_MAX - which is not good. So, for now we deliberately not define it even - though it was defined in the former syslimits.h file. */ -#undef COLL_WEIGHTS_MAX -/* #define COLL_WEIGHTS_MAX >= _POSIX2_COLL_WEIGHTS_MAX */ - -/* Maximum number of expressions that can be nested within parentheses - by the expr utility. */ -#undef EXPR_NEST_MAX -#define EXPR_NEST_MAX 32 - -/* Maximum bytes of a text utility's input line */ -#undef LINE_MAX -#define LINE_MAX 2048 - -/* Max num groups for a user, value taken from NT documentation */ -/* Must match NGROUPS */ -#undef NGROUPS_MAX -#define NGROUPS_MAX 1024 - -/* Maximum number of repeated occurrences of a regular expression when - using the interval notation \{m,n\} */ -#undef RE_DUP_MAX -#define RE_DUP_MAX 255 - - -/* POSIX values */ -/* These should never vary from one system type to another */ -/* They represent the minimum values that POSIX systems must support. - POSIX-conforming apps must not require larger values. */ - -/* Maximum Values */ - -#define _POSIX_CLOCKRES_MIN 20000000 - -/* Minimum Values */ - -#define _POSIX_AIO_LISTIO_MAX 2 -#define _POSIX_AIO_MAX 1 -#define _POSIX_ARG_MAX 4096 -#define _POSIX_CHILD_MAX 25 -#define _POSIX_DELAYTIMER_MAX 32 -#define _POSIX_HOST_NAME_MAX 255 -#define _POSIX_LINK_MAX 8 -#define _POSIX_LOGIN_NAME_MAX 9 -#define _POSIX_MAX_CANON 255 -#define _POSIX_MAX_INPUT 255 -#define _POSIX_MQ_OPEN_MAX 8 -#define _POSIX_MQ_PRIO_MAX 32 -#define _POSIX_NAME_MAX 14 -#define _POSIX_NGROUPS_MAX 8 -#define _POSIX_OPEN_MAX 20 -#define _POSIX_PATH_MAX 256 -#define _POSIX_PIPE_BUF 512 -#define _POSIX_RE_DUP_MAX 255 -#define _POSIX_RTSIG_MAX 8 -#define _POSIX_SEM_NSEMS_MAX 256 -#define _POSIX_SEM_VALUE_MAX 32767 -#define _POSIX_SIGQUEUE_MAX 32 -#define _POSIX_SSIZE_MAX 32767 -#define _POSIX_STREAM_MAX 8 -#define _POSIX_SS_REPL_MAX 4 -#define _POSIX_SYMLINK_MAX 255 -#define _POSIX_SYMLOOP_MAX 8 -#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 -#define _POSIX_THREAD_KEYS_MAX 128 -#define _POSIX_THREAD_THREADS_MAX 64 -#define _POSIX_TIMER_MAX 32 -#define _POSIX_TRACE_EVENT_NAME_MAX 30 -#define _POSIX_TRACE_NAME_MAX 8 -#define _POSIX_TRACE_SYS_MAX 8 -#define _POSIX_TRACE_USER_EVENT_MAX 32 -#define _POSIX_TTY_NAME_MAX 9 -#define _POSIX_TZNAME_MAX 6 - -#define _POSIX2_BC_BASE_MAX 99 -#define _POSIX2_BC_DIM_MAX 2048 -#define _POSIX2_BC_SCALE_MAX 99 -#define _POSIX2_BC_STRING_MAX 1000 -#define _POSIX2_COLL_WEIGHTS_MAX 2 -#define _POSIX2_EXPR_NEST_MAX 32 -#define _POSIX2_LINE_MAX 2048 -#define _POSIX2_RE_DUP_MAX 255 - -#define _XOPEN_IOV_MAX 16 -#define _XOPEN_NAME_MAX 255 -#define _XOPEN_PATH_MAX 1024 - -/* Other Invariant Values */ - -#define NL_ARGMAX 9 -#define NL_LANGMAX 14 -#define NL_MSGMAX 32767 -#define NL_NMAX INT_MAX -#define NL_SETMAX 255 -#define NL_TEXTMAX _POSIX2_LINE_MAX - -/* Default process priority. */ -#undef NZERO -#define NZERO 20 - -#endif /* _MACH_MACHLIMITS_H_ */ -#endif /* _LIMITS_H___ */ diff --git a/winsup/cygwin/include/machine/stdlib.h b/winsup/cygwin/include/machine/stdlib.h deleted file mode 100644 index 2d1539e2c..000000000 --- a/winsup/cygwin/include/machine/stdlib.h +++ /dev/null @@ -1,22 +0,0 @@ -/* machine/stdlib.h - - Copyright 2005 Red Hat, Inc. - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#ifndef _MACHSTDLIB_H_ -#define _MACHSTDLIB_H_ -#ifdef __cplusplus -extern "C" { -#endif - -char *mkdtemp (char *); - -#ifdef __cplusplus -} -#endif -#endif /* _MACHSTDLIB_H_ */ diff --git a/winsup/cygwin/include/mapi.h b/winsup/cygwin/include/mapi.h deleted file mode 100644 index e2d47e264..000000000 --- a/winsup/cygwin/include/mapi.h +++ /dev/null @@ -1,102 +0,0 @@ -/* mapi.h - - Copyright 1997, 1998, 1999, 2000, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _MAPI_H -#define _MAPI_H - -/* Currently this doesn't include all the definitions. It does cover - the parts of Simple MAPI required to send mail. */ - -#ifdef __cplusplus -extern "C" -{ -#endif - - /* FIXME: should this be elsewhere? */ -typedef unsigned long FLAGS; - - /* FIXME: should this be elsewhere? */ -#define SUCCESS_SUCCESS 0 - - /* FIXME: should this be elsewhere? */ -typedef unsigned long LHANDLE, FAR *LPLHANDLE; - - -#define MAPI_E_AMBIGUOUS_RECIPIENT 0x15 -#define MAPI_E_ATTACHMENT_NOT_FOUND 0xb -#define MAPI_E_ATTACHMENT_OPEN_FAILURE 0xc -#define MAPI_E_BAD_RECIPTYPE 0xf -#define MAPI_E_FAILURE 0x2 -#define MAPI_E_INSUFFICIENT_MEMORY 0x5 -#define MAPI_E_INVALID_RECIPS 0x19 -#define MAPI_E_LOGIN_FAILURE 0x3 -#define MAPI_E_TEXT_TOO_LARGE 0x12 -#define MAPI_E_TOO_MANY_FILES 0x9 -#define MAPI_E_TOO_MANY_RECIPIENTS 0xa -#define MAPI_E_UNKNOWN_RECIPIENT 0xe -#define MAPI_E_USER_ABORT 0x1 -#define MAPI_E_TEXT_TOO_LARGE 0x12 -#define MAPI_DIALOG 0x8 -#define MAPI_NEW_SESSION 0x2 -#define MAPI_LOGON_UI 0x1 -#define MAPI_RECEIPT_REQUESTED 0x2 -#define MAPI_SENT 0x4 -#define MAPI_UNREAD 0x1 -#define MAPI_OLE 0x1 -#define MAPI_OLE_STATIC 0x2 - -#define MAPI_ORIG 0 -#define MAPI_TO 1 -#define MAPI_CC 2 -#define MAPI_BCC 3 - -typedef struct -{ - ULONG ulReserved; - ULONG flFlags; - ULONG nPosition; - LPTSTR lpszPathName; - LPTSTR lpszFileName; - LPVOID lpFileType; -} MapiFileDesc, FAR *lpMapiFileDesc; - -typedef struct -{ - ULONG ulReserved; - ULONG ulRecipClass; - LPTSTR lpszName; - LPTSTR lpszAddress; - ULONG ulEIDSize; - LPVOID lpEntryID; -} MapiRecipDesc, FAR *lpMapiRecipDesc; - -typedef struct -{ - ULONG ulReserved; - LPTSTR lpszSubject; - LPTSTR lpszNoteText; - LPTSTR lpszMessageType; - LPTSTR lpszDateReceived; - LPTSTR lpszConversationID; - FLAGS flFlags; - lpMapiRecipDesc lpOriginator; - ULONG nRecipCount; - lpMapiRecipDesc lpRecips; - ULONG nFileCount; - lpMapiFileDesc lpFiles; -} MapiMessage, FAR *lpMapiMessage; - -ULONG FAR PASCAL MAPISendMail (LHANDLE, ULONG, lpMapiMessage, FLAGS, ULONG); - -#ifdef __cplusplus -} -#endif - -#endif /* _MAPI_H */ diff --git a/winsup/cygwin/include/memory.h b/winsup/cygwin/include/memory.h deleted file mode 100644 index 2e16766b9..000000000 --- a/winsup/cygwin/include/memory.h +++ /dev/null @@ -1,17 +0,0 @@ -/* memory.h - - Copyright 1998, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _MEMORY_H -#define _MEMORY_H - -/* This allows more things to compile. */ -#include - -#endif /* _MEMORY_H */ diff --git a/winsup/cygwin/include/mntent.h b/winsup/cygwin/include/mntent.h deleted file mode 100644 index 8ad270ba0..000000000 --- a/winsup/cygwin/include/mntent.h +++ /dev/null @@ -1,54 +0,0 @@ -/* mntent.h - - Copyright 1996, 1998, 1999, 2000, 2001, 2006, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _MNTENT_H -#define _MNTENT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -struct mntent -{ - char *mnt_fsname; - char *mnt_dir; - char *mnt_type; - char *mnt_opts; - int mnt_freq; - int mnt_passno; -}; - -#ifndef _NOMNTENT_FUNCS -#include -FILE *setmntent (const char *__filep, const char *__type); -struct mntent *getmntent (FILE *__filep); -int endmntent (FILE *__filep); -#endif - -/* The following two defines are deprecated. Use the equivalent - names from paths.h instead. */ -#ifndef MNTTAB -#define MNTTAB _PATH_MNTTAB -#endif -/* This next file does exist, but the implementation of these - functions does not actually use it. - However, applications need the define to pass to setmntent(). -*/ -#ifndef MOUNTED -#define MOUNTED _PATH_MOUNTED -#endif - -#ifdef __cplusplus -}; -#endif - -#endif /* _MNTENT_H */ diff --git a/winsup/cygwin/include/monetary.h b/winsup/cygwin/include/monetary.h deleted file mode 100644 index 8b525e961..000000000 --- a/winsup/cygwin/include/monetary.h +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * Copyright (c) 2001 Alexey Zelkin - * All rights reserved. - * - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - * $FreeBSD$ - */ - -#ifndef _MONETARY_H_ -#define _MONETARY_H_ - -#include -#include - -__BEGIN_DECLS -ssize_t strfmon(char * __restrict, size_t, const char * __restrict, ...); -__END_DECLS - -#endif /* !_MONETARY_H_ */ diff --git a/winsup/cygwin/include/mqueue.h b/winsup/cygwin/include/mqueue.h deleted file mode 100644 index 59c32dbe4..000000000 --- a/winsup/cygwin/include/mqueue.h +++ /dev/null @@ -1,45 +0,0 @@ -/* mqueue.h: POSIX message queue interface - - Copyright 2007 Red Hat, Inc. - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#include -#include -#include -#include - -#ifndef _MQUEUE_H -#define _MQUEUE_H - -__BEGIN_DECLS - -typedef intptr_t mqd_t; - -struct mq_attr { - long mq_flags; /* Message queue flags */ - long mq_maxmsg; /* Max number of messages in queue */ - long mq_msgsize; /* Max message size */ - long mq_curmsgs; /* Current number of messages in queue */ -}; - -int mq_close (mqd_t); -int mq_getattr (mqd_t, struct mq_attr *); -int mq_notify (mqd_t, const struct sigevent *); -mqd_t mq_open (const char *, int, ...); -ssize_t mq_receive (mqd_t, char *, size_t, unsigned int *); -int mq_send (mqd_t, const char *, size_t, unsigned int); -int mq_setattr (mqd_t, const struct mq_attr *, struct mq_attr *); -ssize_t mq_timedreceive (mqd_t, char *, size_t, unsigned int *, - const struct timespec *); -int mq_timedsend (mqd_t, const char *, size_t, unsigned int, - const struct timespec *); -int mq_unlink (const char *name); - -__END_DECLS - -#endif /* _MQUEUE_H */ diff --git a/winsup/cygwin/include/net/if.h b/winsup/cygwin/include/net/if.h deleted file mode 100644 index aff3b88e9..000000000 --- a/winsup/cygwin/include/net/if.h +++ /dev/null @@ -1,16 +0,0 @@ -/* net/if.h - - Copyright 1998, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _NET_IF_H -#define _NET_IF_H - -#include - -#endif /* _NET_IF_H */ diff --git a/winsup/cygwin/include/netdb.h b/winsup/cygwin/include/netdb.h deleted file mode 100644 index 1a6d241f6..000000000 --- a/winsup/cygwin/include/netdb.h +++ /dev/null @@ -1,236 +0,0 @@ -/* Original linux netdb.h merged with winsock.h types */ - -/*- - * Copyright (c) 1980, 1983, 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - * - * @(#)netdb.h 8.1 (Berkeley) 6/2/93 - * netdb.h,v 1.1.1.1 1995/02/18 05:34:07 hjl Exp - * - - * Portions Copyright (c) 1993 by Digital Equipment Corporation. - * - * Permission to use, copy, modify and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies, and that - * the name of Digital Equipment Corporation not be used in advertising or - * publicity pertaining to distribution of the document or software without - * specific, written prior permission. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT - * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - * - - * --Copyright-- - */ - -#ifndef _NETDB_H_ -#define _NETDB_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#ifndef __INSIDE_CYGWIN_NET__ -#include -#endif - -/* - * Structures returned by network data base library. All addresses are - * supplied in host order, and returned in network order (suitable for - * use in system calls). - */ - - /* Different from the linux versions - note the shorts.. */ -struct hostent { - const char *h_name; /* official name of host */ - char **h_aliases; /* alias list */ - short h_addrtype; /* host address type */ - short h_length; /* length of address */ - char **h_addr_list; /* list of addresses from name server */ -#define h_addr h_addr_list[0] /* address, for backward compatiblity */ -}; - -/* - * Assumption here is that a network number - * fits in an unsigned long -- probably a poor one. - */ - -struct netent { - char *n_name; /* official name of net */ - char **n_aliases; /* alias list */ - short n_addrtype; /* net address type */ - uint32_t n_net; /* network # */ -}; - -struct servent { - char *s_name; /* official service name */ - char **s_aliases; /* alias list */ - short s_port; /* port # */ - char *s_proto; /* protocol to use */ -}; - -struct protoent -{ - char *p_name; /* official protocol name */ - char **p_aliases; /* alias list */ - short p_proto; /* protocol # */ -}; - -struct rpcent { - char *r_name; /* name of server for this rpc program */ - char **r_aliases; /* alias list */ - int r_number; /* rpc program number */ -}; - -struct addrinfo { - int ai_flags; /* input flags */ - int ai_family; /* address family of socket */ - int ai_socktype; /* socket type */ - int ai_protocol; /* ai_protocol */ - socklen_t ai_addrlen; /* length of socket address */ - char *ai_canonname; /* canonical name of service location */ - struct sockaddr *ai_addr; /* socket address of socket */ - struct addrinfo *ai_next; /* pointer to next in list */ -}; - -/* - * Error return codes from gethostbyname() and gethostbyaddr() - * (left in extern int h_errno). - */ - -#ifdef __INSIDE_CYGWIN_NET__ -extern int h_errno; -#else -extern __declspec(dllimport) int h_errno; -#endif - -#define NETDB_INTERNAL -1 /* see errno */ -#define NETDB_SUCCESS 0 /* no problem */ -#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ -#define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */ -#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ -#define NO_DATA 4 /* Valid name, no data record of requested type */ -#define NO_ADDRESS NO_DATA /* no address, look for MX record */ - -#define AI_PASSIVE 1 -#define AI_CANONNAME 2 -#define AI_NUMERICHOST 4 -#define AI_NUMERICSERV 8 -#define AI_ALL 256 -#define AI_ADDRCONFIG 1024 /* Only available on Vista. Unchangable default - on older systems. */ -#define AI_V4MAPPED 2048 - -#define NI_NOFQDN 1 -#define NI_NUMERICHOST 2 -#define NI_NAMEREQD 4 -#define NI_NUMERICSERV 8 -#define NI_DGRAM 16 - -#define NI_MAXHOST 1025 -#define NI_MAXSERV 32 - -#define EAI_ADDRFAMILY 1 -#define EAI_AGAIN 2 -#define EAI_BADFLAGS 3 -#define EAI_FAIL 4 -#define EAI_FAMILY 5 -#define EAI_MEMORY 6 -#define EAI_NODATA 7 -#define EAI_NONAME 8 -#define EAI_SERVICE 9 -#define EAI_SOCKTYPE 10 -#define EAI_SYSTEM 11 -#define EAI_BADHINTS 12 -#define EAI_PROTOCOL 13 -#define EAI_OVERFLOW 14 - -#ifndef __INSIDE_CYGWIN_NET__ -void endhostent (void); -void endnetent (void); -void endprotoent (void); -void endservent (void); -void endrpcent (void); -struct hostent *gethostbyaddr (const char *, int, int); -struct hostent *gethostbyname (const char *); -struct hostent *gethostent (void); -struct netent *getnetbyaddr (long, int); /* u_long? */ -struct netent *getnetbyname (const char *); -struct netent *getnetent (void); -struct protoent *getprotobyname (const char *); -struct protoent *getprotobynumber (int); -struct protoent *getprotoent (void); -struct servent *getservbyname (const char *, const char *); -struct servent *getservbyport (int, const char *); -struct servent *getservent (void); -struct rpcent *getrpcent (void); -struct rpcent *getrpcbyname (const char *); -struct rpcent *getrpcbynumber (int); -const char *hstrerror (int); -void herror (const char *); -void sethostent (int); -void setnetent (int); -void setprotoent (int); -void setservent (int); -void setrpcent (int); -void freeaddrinfo (struct addrinfo *); -const char *gai_strerror (int); -int getaddrinfo (const char *, const char *, - const struct addrinfo *, struct addrinfo **); -int getnameinfo (const struct sockaddr *, socklen_t, char *, - socklen_t, char *, socklen_t, int); - -int rcmd (char **, uint16_t, const char *, const char *, - const char *, int *); -int rcmd_af (char **, uint16_t, const char *, const char *, - const char *, int *, int); -int rexec (char **, uint16_t rport, char *, char *, char *, int *); -int rresvport (int *); -int rresvport_af (int *, int); -int iruserok (unsigned long, int, const char *, const char *); -int iruserok_sa (const void *, int, int, const char *, - const char *); -int ruserok (const char *, int, const char *, const char *); -#endif - -#ifdef __cplusplus -}; -#endif - -#endif /* !_NETDB_H_ */ - diff --git a/winsup/cygwin/include/netinet/in.h b/winsup/cygwin/include/netinet/in.h deleted file mode 100644 index 027ac2cd1..000000000 --- a/winsup/cygwin/include/netinet/in.h +++ /dev/null @@ -1,28 +0,0 @@ -/* netinet/in.h - - Copyright 1998, 2001, 2006 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _NETINET_IN_H -#define _NETINET_IN_H - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -extern int bindresvport (int, struct sockaddr_in *); -extern int bindresvport_sa (int, struct sockaddr *); - -#ifdef __cplusplus -}; -#endif - -#endif /* _NETINET_IN_H */ diff --git a/winsup/cygwin/include/netinet/in_systm.h b/winsup/cygwin/include/netinet/in_systm.h deleted file mode 100644 index 17b5feb8d..000000000 --- a/winsup/cygwin/include/netinet/in_systm.h +++ /dev/null @@ -1,16 +0,0 @@ -/* netinet/in_systm.h - - Copyright 2000, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _NETINET_IN_SYSTM_H -#define _NETINET_IN_SYSTM_H - -#include - -#endif /* _NETINET_IN_SYSTM_H */ diff --git a/winsup/cygwin/include/netinet/ip.h b/winsup/cygwin/include/netinet/ip.h deleted file mode 100644 index 653f6db9d..000000000 --- a/winsup/cygwin/include/netinet/ip.h +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (c) 1982, 1986, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - * - * @(#)ip.h 8.2 (Berkeley) 6/1/94 - * $FreeBSD: src/sys/netinet/ip.h,v 1.17 1999/12/22 19:13:20 shin Exp $ - */ - -#ifndef _NETINET_IP_H -#define _NETINET_IP_H - -#include -#include - -/* Added by Wu Yongwei */ -#ifndef LITTLE_ENDIAN -#define LITTLE_ENDIAN 1234 -#define BIG_ENDIAN 4321 -#endif -#ifndef BYTE_ORDER -#define BYTE_ORDER LITTLE_ENDIAN -#endif - -/* - * Definitions for internet protocol version 4. - * Per RFC 791, September 1981. - */ -#define IPVERSION 4 - -/* - * Structure of an internet header, naked of options. - */ -struct ip { -#ifdef _IP_VHL - u_char ip_vhl; /* version << 4 | header length >> 2 */ -#else -#if BYTE_ORDER == LITTLE_ENDIAN - u_int ip_hl:4, /* header length */ - ip_v:4; /* version */ -#endif -#if BYTE_ORDER == BIG_ENDIAN - u_int ip_v:4, /* version */ - ip_hl:4; /* header length */ -#endif -#endif /* not _IP_VHL */ - u_char ip_tos; /* type of service */ - u_short ip_len; /* total length */ - u_short ip_id; /* identification */ - u_short ip_off; /* fragment offset field */ -#define IP_RF 0x8000 /* reserved fragment flag */ -#define IP_DF 0x4000 /* dont fragment flag */ -#define IP_MF 0x2000 /* more fragments flag */ -#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ - u_char ip_ttl; /* time to live */ - u_char ip_p; /* protocol */ - u_short ip_sum; /* checksum */ - struct in_addr ip_src,ip_dst; /* source and dest address */ -}; - -#ifdef _IP_VHL -#define IP_MAKE_VHL(v, hl) ((v) << 4 | (hl)) -#define IP_VHL_HL(vhl) ((vhl) & 0x0f) -#define IP_VHL_V(vhl) ((vhl) >> 4) -#define IP_VHL_BORING 0x45 -#endif - -#define IP_MAXPACKET 65535 /* maximum packet size */ - -/* - * Definitions for IP type of service (ip_tos) - */ -#ifndef IPTOS_LOWDELAY -#define IPTOS_LOWDELAY 0x10 -#define IPTOS_THROUGHPUT 0x08 -#define IPTOS_RELIABILITY 0x04 -#endif -#define IPTOS_MINCOST 0x02 -/* ECN bits proposed by Sally Floyd */ -#define IPTOS_CE 0x01 /* congestion experienced */ -#define IPTOS_ECT 0x02 /* ECN-capable transport */ - - -/* - * Definitions for IP precedence (also in ip_tos) (hopefully unused) - */ -#define IPTOS_PREC_NETCONTROL 0xe0 -#define IPTOS_PREC_INTERNETCONTROL 0xc0 -#define IPTOS_PREC_CRITIC_ECP 0xa0 -#define IPTOS_PREC_FLASHOVERRIDE 0x80 -#define IPTOS_PREC_FLASH 0x60 -#define IPTOS_PREC_IMMEDIATE 0x40 -#define IPTOS_PREC_PRIORITY 0x20 -#define IPTOS_PREC_ROUTINE 0x00 - -/* - * Definitions for options. - */ -#define IPOPT_COPIED(o) ((o)&0x80) -#define IPOPT_CLASS(o) ((o)&0x60) -#define IPOPT_NUMBER(o) ((o)&0x1f) - -#define IPOPT_CONTROL 0x00 -#define IPOPT_RESERVED1 0x20 -#define IPOPT_DEBMEAS 0x40 -#define IPOPT_RESERVED2 0x60 - -#define IPOPT_EOL 0 /* end of option list */ -#define IPOPT_NOP 1 /* no operation */ - -#define IPOPT_RR 7 /* record packet route */ -#define IPOPT_TS 68 /* timestamp */ -#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ -#define IPOPT_LSRR 131 /* loose source route */ -#define IPOPT_SATID 136 /* satnet id */ -#define IPOPT_SSRR 137 /* strict source route */ -#define IPOPT_RA 148 /* router alert */ - -/* - * Offsets to fields in options other than EOL and NOP. - */ -#define IPOPT_OPTVAL 0 /* option ID */ -#define IPOPT_OLEN 1 /* option length */ -#define IPOPT_OFFSET 2 /* offset within option */ -#define IPOPT_MINOFF 4 /* min value of above */ - -/* - * Time stamp option structure. - */ -struct ip_timestamp { - u_char ipt_code; /* IPOPT_TS */ - u_char ipt_len; /* size of structure (variable) */ - u_char ipt_ptr; /* index of current entry */ -#if BYTE_ORDER == LITTLE_ENDIAN - u_int ipt_flg:4, /* flags, see below */ - ipt_oflw:4; /* overflow counter */ -#endif -#if BYTE_ORDER == BIG_ENDIAN - u_int ipt_oflw:4, /* overflow counter */ - ipt_flg:4; /* flags, see below */ -#endif - union ipt_timestamp { - n_long ipt_time[1]; - struct ipt_ta { - struct in_addr ipt_addr; - n_long ipt_time; - } ipt_ta[1]; - } ipt_timestamp; -}; - -/* flag bits for ipt_flg */ -#define IPOPT_TS_TSONLY 0 /* timestamps only */ -#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ -#define IPOPT_TS_PRESPEC 3 /* specified modules only */ - -/* bits for security (not byte swapped) */ -#define IPOPT_SECUR_UNCLASS 0x0000 -#define IPOPT_SECUR_CONFID 0xf135 -#define IPOPT_SECUR_EFTO 0x789a -#define IPOPT_SECUR_MMMM 0xbc4d -#define IPOPT_SECUR_RESTR 0xaf13 -#define IPOPT_SECUR_SECRET 0xd788 -#define IPOPT_SECUR_TOPSECRET 0x6bc5 - -/* - * Internet implementation parameters. - */ -#define MAXTTL 255 /* maximum time to live (seconds) */ -#define IPDEFTTL 64 /* default ttl, from RFC 1340 */ -#define IPFRAGTTL 60 /* time to live for frags, slowhz */ -#define IPTTLDEC 1 /* subtracted when forwarding */ - -#define IP_MSS 576 /* default maximum segment size */ - -#endif diff --git a/winsup/cygwin/include/netinet/ip_icmp.h b/winsup/cygwin/include/netinet/ip_icmp.h deleted file mode 100644 index 6a1be053c..000000000 --- a/winsup/cygwin/include/netinet/ip_icmp.h +++ /dev/null @@ -1,16 +0,0 @@ -/* netinet/ip_icmp.h - - Copyright 1998, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _NETINET_IP_ICMP_H -#define _NETINET_IP_ICMP_H - -#include - -#endif /* _NETINET_IP_ICMP_H */ diff --git a/winsup/cygwin/include/netinet/tcp.h b/winsup/cygwin/include/netinet/tcp.h deleted file mode 100644 index 305527d0e..000000000 --- a/winsup/cygwin/include/netinet/tcp.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 1982, 1986, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - * - * @(#)tcp.h 8.1 (Berkeley) 6/10/93 - * $FreeBSD: src/sys/netinet/tcp.h,v 1.13 2000/01/09 19:17:25 shin Exp $ - */ - -#ifndef _NETINET_TCP_H -#define _NETINET_TCP_H - -/* Added by Wu Yongwei */ -#ifndef LITTLE_ENDIAN -#define LITTLE_ENDIAN 1234 -#define BIG_ENDIAN 4321 -#endif -#ifndef BYTE_ORDER -#define BYTE_ORDER LITTLE_ENDIAN -#endif - -typedef u_int32_t tcp_seq; -typedef u_int32_t tcp_cc; /* connection count per rfc1644 */ - -#define tcp6_seq tcp_seq /* for KAME src sync over BSD*'s */ -#define tcp6hdr tcphdr /* for KAME src sync over BSD*'s */ - -/* - * TCP header. - * Per RFC 793, September, 1981. - */ -struct tcphdr { - u_short th_sport; /* source port */ - u_short th_dport; /* destination port */ - tcp_seq th_seq; /* sequence number */ - tcp_seq th_ack; /* acknowledgement number */ -#if BYTE_ORDER == LITTLE_ENDIAN - u_int th_x2:4, /* (unused) */ - th_off:4; /* data offset */ -#endif -#if BYTE_ORDER == BIG_ENDIAN - u_int th_off:4, /* data offset */ - th_x2:4; /* (unused) */ -#endif - u_char th_flags; -#define TH_FIN 0x01 -#define TH_SYN 0x02 -#define TH_RST 0x04 -#define TH_PUSH 0x08 -#define TH_ACK 0x10 -#define TH_URG 0x20 -#define TH_FLAGS (TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG) - - u_short th_win; /* window */ - u_short th_sum; /* checksum */ - u_short th_urp; /* urgent pointer */ -}; - -#define TCPOPT_EOL 0 -#define TCPOPT_NOP 1 -#define TCPOPT_MAXSEG 2 -#define TCPOLEN_MAXSEG 4 -#define TCPOPT_WINDOW 3 -#define TCPOLEN_WINDOW 3 -#define TCPOPT_SACK_PERMITTED 4 /* Experimental */ -#define TCPOLEN_SACK_PERMITTED 2 -#define TCPOPT_SACK 5 /* Experimental */ -#define TCPOPT_TIMESTAMP 8 -#define TCPOLEN_TIMESTAMP 10 -#define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */ -#define TCPOPT_TSTAMP_HDR \ - (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP) - -#define TCPOPT_CC 11 /* CC options: RFC-1644 */ -#define TCPOPT_CCNEW 12 -#define TCPOPT_CCECHO 13 -#define TCPOLEN_CC 6 -#define TCPOLEN_CC_APPA (TCPOLEN_CC+2) -#define TCPOPT_CC_HDR(ccopt) \ - (TCPOPT_NOP<<24|TCPOPT_NOP<<16|(ccopt)<<8|TCPOLEN_CC) - -/* - * Default maximum segment size for TCP. - * With an IP MSS of 576, this is 536, - * but 512 is probably more convenient. - * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)). - */ -#define TCP_MSS 512 - -/* - * Default maximum segment size for TCP6. - * With an IP6 MSS of 1280, this is 1220, - * but 1024 is probably more convenient. (xxx kazu in doubt) - * This should be defined as MIN(1024, IP6_MSS - sizeof (struct tcpip6hdr)) - */ -#define TCP6_MSS 1024 - -#define TCP_MAXWIN 65535 /* largest value for (unscaled) window */ -#define TTCP_CLIENT_SND_WND 4096 /* dflt send window for T/TCP client */ - -#define TCP_MAX_WINSHIFT 14 /* maximum window shift */ - -#define TCP_MAXHLEN (0xf<<2) /* max length of header in bytes */ -#define TCP_MAXOLEN (TCP_MAXHLEN - sizeof(struct tcphdr)) - /* max space left for options */ - -/* - * User-settable options (used with setsockopt). - */ -#ifndef TCP_NODELAY -#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ -#define TCP_MAXSEG 0x02 /* set maximum segment size */ -#endif -#define TCP_NOPUSH 0x04 /* don't push last block of write */ -#define TCP_NOOPT 0x08 /* don't use TCP options */ - -#endif diff --git a/winsup/cygwin/include/netinet/udp.h b/winsup/cygwin/include/netinet/udp.h deleted file mode 100644 index 61932720b..000000000 --- a/winsup/cygwin/include/netinet/udp.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1982, 1986, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - * - * @(#)udp.h 8.1 (Berkeley) 6/10/93 - * $FreeBSD: src/sys/netinet/udp.h,v 1.7 1999/08/28 00:49:34 peter Exp $ - */ - -#ifndef _NETINET_UDP_H -#define _NETINET_UDP_H - -/* - * Udp protocol header. - * Per RFC 768, September, 1981. - */ -struct udphdr { - u_short uh_sport; /* source port */ - u_short uh_dport; /* destination port */ - u_short uh_ulen; /* udp length */ - u_short uh_sum; /* udp checksum */ -}; - -#endif diff --git a/winsup/cygwin/include/paths.h b/winsup/cygwin/include/paths.h deleted file mode 100644 index 8194f415b..000000000 --- a/winsup/cygwin/include/paths.h +++ /dev/null @@ -1,32 +0,0 @@ -/* paths.h - - Copyright 2001, 2002, 2003, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _PATHS_H_ -#define _PATHS_H_ - -#define _PATH_BSHELL "/bin/sh" -#define _PATH_CSHELL "/bin/csh" -#define _PATH_DEFPATH "/bin" -#define _PATH_DEV "/dev/" -#define _PATH_DEVNULL "/dev/null" -#define _PATH_LASTLOG "/var/log/lastlog" -#define _PATH_MAN "/usr/share/man" -#define _PATH_MEM "/dev/mem" -#define _PATH_MNTTAB "/etc/fstab" -#define _PATH_MOUNTED "/etc/mtab" -#define _PATH_STDPATH "/bin:/usr/sbin:/sbin" -#define _PATH_TMP "/tmp/" -#define _PATH_TTY "/dev/tty" -#define _PATH_UTMP "/var/run/utmp" -#define _PATH_VARRUN "/var/run/" -#define _PATH_VI "/bin/vi" -#define _PATH_WTMP "/var/log/wtmp" - -#endif /* _PATHS_H_ */ diff --git a/winsup/cygwin/include/poll.h b/winsup/cygwin/include/poll.h deleted file mode 100644 index a836b2af4..000000000 --- a/winsup/cygwin/include/poll.h +++ /dev/null @@ -1,11 +0,0 @@ -/* poll.h - - Copyright 2000, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include diff --git a/winsup/cygwin/include/pthread.h b/winsup/cygwin/include/pthread.h deleted file mode 100644 index 73759ddc0..000000000 --- a/winsup/cygwin/include/pthread.h +++ /dev/null @@ -1,202 +0,0 @@ -/* pthread.h: POSIX pthread interface - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2006, - 2007 Red Hat, Inc. - - Written by Marco Fuykschot - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#include -#include -#include - -#ifndef _PTHREAD_H -#define _PTHREAD_H - -#ifdef __cplusplus -extern "C" -{ -#endif - - -/* Defines. (These are correctly defined here as per - http://www.opengroup.org/onlinepubs/7908799/xsh/pthread.h.html */ - -/* FIXME: this should allocate a new cond variable, and return the value that - would normally be written to the passed parameter of pthread_cond_init(lvalue, NULL); */ -/* #define PTHREAD_COND_INITIALIZER 0 */ - -/* the default : joinable */ - -#define PTHREAD_CANCEL_ASYNCHRONOUS 1 -/* defaults are enable, deferred */ -#define PTHREAD_CANCEL_ENABLE 0 -#define PTHREAD_CANCEL_DEFERRED 0 -#define PTHREAD_CANCEL_DISABLE 1 -#define PTHREAD_CANCELED ((void *)-1) -/* this should be a value that can never be a valid address */ -#define PTHREAD_COND_INITIALIZER (pthread_cond_t)21 -#define PTHREAD_CREATE_DETACHED 1 -/* the default : joinable */ -#define PTHREAD_CREATE_JOINABLE 0 -#define PTHREAD_EXPLICIT_SCHED 1 -#define PTHREAD_INHERIT_SCHED 0 -#define PTHREAD_MUTEX_RECURSIVE 0 -#define PTHREAD_MUTEX_ERRORCHECK 1 -#define PTHREAD_MUTEX_NORMAL 2 -#define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL -/* this should be too low to ever be a valid address */ -#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP (pthread_mutex_t)18 -#define PTHREAD_NORMAL_MUTEX_INITIALIZER_NP (pthread_mutex_t)19 -#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP (pthread_mutex_t)20 -#define PTHREAD_MUTEX_INITIALIZER PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP -#define PTHREAD_ONCE_INIT { PTHREAD_MUTEX_INITIALIZER, 0 } -#if defined(_POSIX_THREAD_PRIO_INHERIT) && _POSIX_THREAD_PRIO_INHERIT >= 0 -#define PTHREAD_PRIO_NONE 0 -#define PTHREAD_PRIO_INHERIT 1 -#define PTHREAD_PRIO_PROTECT 2 -#endif -#define PTHREAD_PROCESS_SHARED 1 -#define PTHREAD_PROCESS_PRIVATE 0 -#define PTHREAD_RWLOCK_INITIALIZER (pthread_rwlock_t)22 -/* process is the default */ -#define PTHREAD_SCOPE_PROCESS 0 -#define PTHREAD_SCOPE_SYSTEM 1 - - -/* Attributes */ -int pthread_attr_destroy (pthread_attr_t *); -int pthread_attr_getdetachstate (const pthread_attr_t *, int *); -int pthread_attr_getinheritsched (const pthread_attr_t *, int *); -int pthread_attr_getschedparam (const pthread_attr_t *, struct sched_param *); -int pthread_attr_getschedpolicy (const pthread_attr_t *, int *); -int pthread_attr_getscope (const pthread_attr_t *, int *); -int pthread_attr_init (pthread_attr_t *); -int pthread_attr_setdetachstate (pthread_attr_t *, int); -int pthread_attr_setinheritsched (pthread_attr_t *, int); -int pthread_attr_setschedparam (pthread_attr_t *, const struct sched_param *); -int pthread_attr_setschedpolicy (pthread_attr_t *, int); -int pthread_attr_setscope (pthread_attr_t *, int); - -#ifdef _POSIX_THREAD_ATTR_STACKADDR -/* These functions may be implementable via some low level trickery. For now they are - * Not supported or implemented. The prototypes are here so if someone greps the - * source they will see these comments - */ -int pthread_attr_getstackaddr (const pthread_attr_t *, void **); -int pthread_attr_setstackaddr (pthread_attr_t *, void *); -#endif - -#ifdef _POSIX_THREAD_ATTR_STACKSIZE -int pthread_attr_getstacksize (const pthread_attr_t *, size_t *); -int pthread_attr_setstacksize (pthread_attr_t *, size_t); -#endif - -int pthread_cancel (pthread_t); -/* Macros for cleanup_push and pop; - * The function definitions are -void pthread_cleanup_push (void (*routine)(void*), void *arg); -void pthread_cleanup_pop (int execute); -*/ -typedef void (*__cleanup_routine_type) (void *); -typedef struct _pthread_cleanup_handler -{ - __cleanup_routine_type function; - void *arg; - struct _pthread_cleanup_handler *next; -} __pthread_cleanup_handler; - -void _pthread_cleanup_push (__pthread_cleanup_handler *handler); -void _pthread_cleanup_pop (int execute); - -#define pthread_cleanup_push(_fn, _arg) { __pthread_cleanup_handler __cleanup_handler = \ - { _fn, _arg, NULL }; \ - _pthread_cleanup_push( &__cleanup_handler ); -#define pthread_cleanup_pop(_execute) _pthread_cleanup_pop( _execute ); } - -/* Condition variables */ -int pthread_cond_broadcast (pthread_cond_t *); -int pthread_cond_destroy (pthread_cond_t *); -int pthread_cond_init (pthread_cond_t *, const pthread_condattr_t *); -int pthread_cond_signal (pthread_cond_t *); -int pthread_cond_timedwait (pthread_cond_t *, - pthread_mutex_t *, const struct timespec *); -int pthread_cond_wait (pthread_cond_t *, pthread_mutex_t *); -int pthread_condattr_destroy (pthread_condattr_t *); -int pthread_condattr_getpshared (const pthread_condattr_t *, int *); -int pthread_condattr_init (pthread_condattr_t *); -int pthread_condattr_setpshared (pthread_condattr_t *, int); - -int pthread_create (pthread_t *, const pthread_attr_t *, - void *(*)(void *), void *); -int pthread_detach (pthread_t); -int pthread_equal (pthread_t, pthread_t); -void pthread_exit (void *); -int pthread_getschedparam (pthread_t, int *, struct sched_param *); -void *pthread_getspecific (pthread_key_t); -int pthread_join (pthread_t, void **); -int pthread_key_create (pthread_key_t *, void (*)(void *)); -int pthread_key_delete (pthread_key_t); - -/* Mutex's */ -int pthread_mutex_destroy (pthread_mutex_t *); -int pthread_mutex_getprioceiling (const pthread_mutex_t *, int *); -int pthread_mutex_init (pthread_mutex_t *, const pthread_mutexattr_t *); -int pthread_mutex_lock (pthread_mutex_t *); -int pthread_mutex_setprioceiling (pthread_mutex_t *, int, int *); -int pthread_mutex_trylock (pthread_mutex_t *); -int pthread_mutex_unlock (pthread_mutex_t *); -int pthread_mutexattr_destroy (pthread_mutexattr_t *); -int pthread_mutexattr_getprioceiling (const pthread_mutexattr_t *, int *); -int pthread_mutexattr_getprotocol (const pthread_mutexattr_t *, int *); -int pthread_mutexattr_getpshared (const pthread_mutexattr_t *, int *); -int pthread_mutexattr_gettype (const pthread_mutexattr_t *, int *); -int pthread_mutexattr_init (pthread_mutexattr_t *); -int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *, int); -int pthread_mutexattr_setprotocol (pthread_mutexattr_t *, int); -int pthread_mutexattr_setpshared (pthread_mutexattr_t *, int); -int pthread_mutexattr_settype (pthread_mutexattr_t *, int); - -/* RW Locks */ -int pthread_rwlock_destroy (pthread_rwlock_t *rwlock); -int pthread_rwlock_init (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr); -int pthread_rwlock_rdlock (pthread_rwlock_t *rwlock); -int pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock); -int pthread_rwlock_wrlock (pthread_rwlock_t *rwlock); -int pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock); -int pthread_rwlock_unlock (pthread_rwlock_t *rwlock); -int pthread_rwlockattr_init (pthread_rwlockattr_t *rwlockattr); -int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t *attr, - int *pshared); -int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *attr, int pshared); -int pthread_rwlockattr_destroy (pthread_rwlockattr_t *rwlockattr); - -int pthread_once (pthread_once_t *, void (*)(void)); - -/* Concurrency levels - X/Open interface */ -int pthread_getconcurrency (void); -int pthread_setconcurrency (int); - - -pthread_t pthread_self (void); -int pthread_setcancelstate (int, int *); -int pthread_setcanceltype (int, int *); -int pthread_setschedparam (pthread_t, int, const struct sched_param *); -int pthread_setspecific (pthread_key_t, const void *); -void pthread_testcancel (void); - -/* Non posix calls */ - -int pthread_suspend (pthread_t); -int pthread_continue (pthread_t); - -#ifdef __cplusplus -} -#endif - -#endif /* _PTHREAD_H */ diff --git a/winsup/cygwin/include/pty.h b/winsup/cygwin/include/pty.h deleted file mode 100644 index 7b92a2b4d..000000000 --- a/winsup/cygwin/include/pty.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef __PTY_H__ -#define __PTY_H__ - -#include <_ansi.h> -#include - -#ifdef __cplusplus -extern "C" { -#endif - -int _EXFUN(openpty ,(int *, int *, char *, const struct termios *, - const struct winsize *)); -int _EXFUN(forkpty ,(int *, char *, const struct termios *, - const struct winsize *)); - -#ifdef __cplusplus -} -#endif - -#endif /* __PTY_H__ */ diff --git a/winsup/cygwin/include/regex.h b/winsup/cygwin/include/regex.h deleted file mode 100644 index d7c673c19..000000000 --- a/winsup/cygwin/include/regex.h +++ /dev/null @@ -1,130 +0,0 @@ -/*- - * Copyright (c) 1992 Henry Spencer. - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer of the University of Toronto. - * - * 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. - * 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. - * - * @(#)regex.h 8.2 (Berkeley) 1/3/94 - * $FreeBSD$ - */ - -#ifndef _REGEX_H_ -#define _REGEX_H_ - -#include -#include - -/* types */ -#ifdef __CYGWIN__ -typedef _off_t regoff_t; - -#define __need_size_t -#include -#else /* !__CYGWIN__ */ -typedef __off_t regoff_t; - -#ifndef _SIZE_T_DECLARED -typedef __size_t size_t; -#define _SIZE_T_DECLARED -#endif -#endif /* !__CYGWIN__ */ - -typedef struct { - int re_magic; - size_t re_nsub; /* number of parenthesized subexpressions */ -#ifdef __CYGWIN__ - const char *re_endp; /* end pointer for REG_PEND */ -#else - __const char *re_endp; /* end pointer for REG_PEND */ -#endif - struct re_guts *re_g; /* none of your business :-) */ -} regex_t; - -typedef struct { - regoff_t rm_so; /* start of match */ - regoff_t rm_eo; /* end of match */ -} regmatch_t; - -/* regcomp() flags */ -#define REG_BASIC 0000 -#define REG_EXTENDED 0001 -#define REG_ICASE 0002 -#define REG_NOSUB 0004 -#define REG_NEWLINE 0010 -#define REG_NOSPEC 0020 -#define REG_PEND 0040 -#define REG_DUMP 0200 - -/* regerror() flags */ -#define REG_ENOSYS (-1) -#ifdef __CYGWIN__ -#define REG_NOERROR 0 /* GNU extension */ -#endif -#define REG_NOMATCH 1 -#define REG_BADPAT 2 -#define REG_ECOLLATE 3 -#define REG_ECTYPE 4 -#define REG_EESCAPE 5 -#define REG_ESUBREG 6 -#define REG_EBRACK 7 -#define REG_EPAREN 8 -#define REG_EBRACE 9 -#define REG_BADBR 10 -#define REG_ERANGE 11 -#define REG_ESPACE 12 -#define REG_BADRPT 13 -#define REG_EMPTY 14 -#define REG_ASSERT 15 -#define REG_INVARG 16 -#define REG_ILLSEQ 17 -#define REG_ATOI 255 /* convert name to number (!) */ -#define REG_ITOA 0400 /* convert number to name (!) */ - -/* regexec() flags */ -#define REG_NOTBOL 00001 -#define REG_NOTEOL 00002 -#define REG_STARTEND 00004 -#define REG_TRACE 00400 /* tracing of execution */ -#define REG_LARGE 01000 /* force large representation */ -#define REG_BACKR 02000 /* force use of backref code */ - -__BEGIN_DECLS -int regcomp(regex_t * __restrict, const char * __restrict, int); -size_t regerror(int, const regex_t * __restrict, char * __restrict, size_t); -/* - * XXX forth parameter should be `regmatch_t [__restrict]', but isn't because - * of a bug in GCC 3.2 (when -std=c99 is specified) which perceives this as a - * syntax error. - */ -int regexec(const regex_t * __restrict, const char * __restrict, size_t, - regmatch_t * __restrict, int); -void regfree(regex_t *); -__END_DECLS - -#endif /* !_REGEX_H_ */ diff --git a/winsup/cygwin/include/resolv.h b/winsup/cygwin/include/resolv.h deleted file mode 100755 index 49967c85a..000000000 --- a/winsup/cygwin/include/resolv.h +++ /dev/null @@ -1,461 +0,0 @@ -/* - * Copyright (c) 1983, 1987, 1989 - * The Regents of the University of California. All rights reserved. - * - * 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. - */ - -/* - * Portions Copyright (c) 1996-1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -/* - * @(#)resolv.h 8.1 (Berkeley) 6/2/93 - * $Id$ - */ - -#ifndef _RESOLV_H_ -#define _RESOLV_H_ - -#include -#if !defined(__CYGWIN__) && ((!defined(BSD)) || (BSD < 199306)) -# include -#else -# include -#endif -#include -#include -#include -#include -#include - -/* - * Revision information. This is the release date in YYYYMMDD format. - * It can change every day so the right thing to do with it is use it - * in preprocessor commands such as "#if (__RES > 19931104)". Do not - * compare for equality; rather, use it to determine whether your resolver - * is new enough to contain a certain feature. - */ - -#define __RES 19991006 - -/* - * This used to be defined in res_query.c, now it's in herror.c. - * [XXX no it's not. It's in irs/irs_data.c] - * It was - * never extern'd by any *.h file before it was placed here. For thread - * aware programs, the last h_errno value set is stored in res->h_errno. - * - * XXX: There doesn't seem to be a good reason for exposing RES_SET_H_ERRNO - * (and __h_errno_set) to the public via . - * XXX: __h_errno_set is really part of IRS, not part of the resolver. - * If somebody wants to build and use a resolver that doesn't use IRS, - * what do they do? Perhaps something like - * #ifdef WANT_IRS - * # define RES_SET_H_ERRNO(r,x) __h_errno_set(r,x) - * #else - * # define RES_SET_H_ERRNO(r,x) (h_errno = (r)->res_h_errno = (x)) - * #endif - */ - -#define RES_SET_H_ERRNO(r,x) __h_errno_set(r,x) -struct __res_state; /* forward */ -__BEGIN_DECLS -void __h_errno_set(struct __res_state *res, int err); -__END_DECLS - -/* - * Resolver configuration file. - * Normally not present, but may contain the address of the - * inital name server(s) to query and the domain search list. - */ - -#ifndef _PATH_RESCONF -#define _PATH_RESCONF "/etc/resolv.conf" -#endif - -typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error } - res_sendhookact; - -typedef res_sendhookact (*res_send_qhook)__P((struct sockaddr * const *ns, - const u_char **query, - int *querylen, - u_char *ans, - int anssiz, - int *resplen)); - -typedef res_sendhookact (*res_send_rhook)__P((const struct sockaddr *ns, - const u_char *query, - int querylen, - u_char *ans, - int anssiz, - int *resplen)); - -struct res_sym { - int number; /* Identifying number, like T_MX */ - const char * name; /* Its symbolic name, like "MX" */ - const char * humanname; /* Its fun name, like "mail exchanger" */ -}; - -/* - * Global defines and variables for resolver stub. - */ -#define MAXNS 3 /* max # name servers we'll track */ -#define MAXDFLSRCH 3 /* # default domain levels to try */ -#define MAXDNSRCH 6 /* max # domains in search path */ -#define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */ - -#define RES_TIMEOUT 5 /* min. seconds between retries */ -#define MAXRESOLVSORT 10 /* number of net to sort on */ -#define RES_MAXNDOTS 15 /* should reflect bit field size */ -#define RES_MAXRETRANS 30 /* only for resolv.conf/RES_OPTIONS */ -#define RES_MAXRETRY 5 /* only for resolv.conf/RES_OPTIONS */ -#define RES_DFLRETRY 2 /* Default #/tries. */ -#define RES_MAXTIME 65535 /* Infinity, in milliseconds. */ - -struct __res_state_ext; - -struct __res_state { - int retrans; /* retransmition time interval */ - int retry; /* number of times to retransmit */ - u_long options; /* option flags - see below. */ - int nscount; /* number of name servers */ - struct sockaddr_in - nsaddr_list[MAXNS]; /* address of name server */ -#define nsaddr nsaddr_list[0] /* for backward compatibility */ - u_short id; /* current message id */ - char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */ - char defdname[256]; /* default domain (deprecated) */ - u_long pfcode; /* RES_PRF_ flags - see below. */ - unsigned ndots:4; /* threshold for initial abs. query */ - unsigned nsort:4; /* number of elements in sort_list[] */ - char unused[3]; - struct { - struct in_addr addr; - u_int32_t mask; - } sort_list[MAXRESOLVSORT]; - res_send_qhook qhook; /* query hook */ - res_send_rhook rhook; /* response hook */ - int res_h_errno; /* last one set for this context */ - int _vcsock; /* PRIVATE: for res_send VC i/o */ - u_int _flags; /* PRIVATE: see below */ - union { - /* On an 32-bit arch this means 512b total. */ - char pad[72 - 3*sizeof (int) - 2*sizeof (void *)]; - struct { - u_int16_t nscount; - u_int16_t nstimes[MAXNS]; /* ms. */ - int nssocks[MAXNS]; - struct __res_state_ext *ext; /* extention for IPv6 */ - } _ext; - } _u; -}; - -typedef struct __res_state *res_state; - -union res_sockaddr_union { - struct sockaddr_in sin; -#ifdef IN6ADDR_ANY_INIT - struct sockaddr_in6 sin6; -#endif -#ifdef ISC_ALIGN64 - int64_t __align; /* 64bit alignment */ -#else - int32_t __align; /* 32bit alignment */ -#endif - char __space[128]; /* max size */ -}; - -/* - * Resolver flags (used to be discrete per-module statics ints). - */ -#define RES_F_VC 0x00000001 /* socket is TCP */ -#define RES_F_CONN 0x00000002 /* socket is connected */ -#define RES_F_EDNS0ERR 0x00000004 /* EDNS0 caused errors */ - -/* res_findzonecut() options */ -#define RES_EXHAUSTIVE 0x00000001 /* always do all queries */ - -/* - * Resolver options (keep these in synch with res_debug.c, please) - */ -#define RES_INIT 0x00000001 /* address initialized */ -#define RES_DEBUG 0x00000002 /* print debug messages */ -#define RES_AAONLY 0x00000004 /* authoritative answers only (!IMPL)*/ -#define RES_USEVC 0x00000008 /* use virtual circuit */ -#define RES_PRIMARY 0x00000010 /* query primary server only (!IMPL) */ -#define RES_IGNTC 0x00000020 /* ignore trucation errors */ -#define RES_RECURSE 0x00000040 /* recursion desired */ -#define RES_DEFNAMES 0x00000080 /* use default domain name */ -#define RES_STAYOPEN 0x00000100 /* Keep TCP socket open */ -#define RES_DNSRCH 0x00000200 /* search up local domain tree */ -#define RES_INSECURE1 0x00000400 /* type 1 security disabled */ -#define RES_INSECURE2 0x00000800 /* type 2 security disabled */ -#define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */ -#define RES_USE_INET6 0x00002000 /* use/map IPv6 in gethostbyname() */ -#define RES_ROTATE 0x00004000 /* rotate ns list after each query */ -#define RES_NOCHECKNAME 0x00008000 /* do not check names for sanity. */ -#define RES_KEEPTSIG 0x00010000 /* do not strip TSIG records */ -#define RES_BLAST 0x00020000 /* blast all recursive servers */ -#define RES_NO_NIBBLE 0x00040000 /* disable IPv6 nibble mode reverse */ -#define RES_NO_BITSTRING 0x00080000 /* disable IPv6 bit string mode reverse */ -/* KAME extensions: use higher bit to avoid conflict with ISC use */ -#define RES_USE_DNAME 0x10000000 /* use DNAME */ -#define RES_USE_A6 0x20000000 /* use A6 */ -#define RES_USE_EDNS0 0x40000000 /* use EDNS0 if configured */ - -#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH) - -/* - * Resolver "pfcode" values. Used by dig. - */ -#define RES_PRF_STATS 0x00000001 -#define RES_PRF_UPDATE 0x00000002 -#define RES_PRF_CLASS 0x00000004 -#define RES_PRF_CMD 0x00000008 -#define RES_PRF_QUES 0x00000010 -#define RES_PRF_ANS 0x00000020 -#define RES_PRF_AUTH 0x00000040 -#define RES_PRF_ADD 0x00000080 -#define RES_PRF_HEAD1 0x00000100 -#define RES_PRF_HEAD2 0x00000200 -#define RES_PRF_TTLID 0x00000400 -#define RES_PRF_HEADX 0x00000800 -#define RES_PRF_QUERY 0x00001000 -#define RES_PRF_REPLY 0x00002000 -#define RES_PRF_INIT 0x00004000 -/* 0x00008000 */ - -/* Things involving an internal (static) resolver context. */ -#if defined(_REENTRANT) || defined(__CYGWIN__) -__BEGIN_DECLS -extern struct __res_state *__res_state(void); -__END_DECLS -#define _res (*__res_state()) -#else -#ifndef __BIND_NOSTATIC -extern struct __res_state _res; -#endif -#endif - -#ifndef __BIND_NOSTATIC -#define fp_nquery __fp_nquery -#define fp_query __fp_query -#define hostalias __hostalias -#define p_query __p_query -#define res_close __res_close -#define res_init __res_init -#define res_isourserver __res_isourserver -#define res_mkquery __res_mkquery -#define res_query __res_query -#define res_querydomain __res_querydomain -#define res_search __res_search -#define res_send __res_send -#define res_sendsigned __res_sendsigned - -__BEGIN_DECLS -void fp_nquery __P((const u_char *, int, FILE *)); -void fp_query __P((const u_char *, FILE *)); -const char * hostalias __P((const char *)); -void p_query __P((const u_char *)); -void res_close __P((void)); -int res_init __P((void)); -int res_isourserver __P((const struct sockaddr_in *)); -int res_mkquery __P((int, const char *, int, int, const u_char *, - int, const u_char *, u_char *, int)); -int res_query __P((const char *, int, int, u_char *, int)); -int res_querydomain __P((const char *, const char *, int, int, - u_char *, int)); -int res_search __P((const char *, int, int, u_char *, int)); -int res_send __P((const u_char *, int, u_char *, int)); -int res_sendsigned __P((const u_char *, int, ns_tsig_key *, - u_char *, int)); -__END_DECLS -#endif - -#if !defined(SHARED_LIBBIND) || defined(LIB) -/* - * If libbind is a shared object (well, DLL anyway) - * these externs break the linker when resolv.h is - * included by a lib client (like named) - * Make them go away if a client is including this - * - */ -extern const struct res_sym __p_key_syms[]; -extern const struct res_sym __p_cert_syms[]; -extern const struct res_sym __p_class_syms[]; -extern const struct res_sym __p_type_syms[]; -extern const struct res_sym __p_rcode_syms[]; -#endif /* SHARED_LIBBIND */ - -#define b64_ntop __b64_ntop -#define b64_pton __b64_pton -#define dn_comp __dn_comp -#define dn_count_labels __dn_count_labels -#define dn_expand __dn_expand -#define dn_skipname __dn_skipname -#define fp_resstat __fp_resstat -#define loc_aton __loc_aton -#define loc_ntoa __loc_ntoa -#define p_cdname __p_cdname -#define p_cdnname __p_cdnname -#define p_class __p_class -#define p_fqname __p_fqname -#define p_fqnname __p_fqnname -#define p_option __p_option -#define p_secstodate __p_secstodate -#define p_section __p_section -#define p_time __p_time -#define p_type __p_type -#define p_rcode __p_rcode -#define putlong __putlong -#define putshort __putshort -#define res_dnok __res_dnok -#define res_findzonecut __res_findzonecut -#define res_hnok __res_hnok -#define res_hostalias __res_hostalias -#define res_mailok __res_mailok -#define res_nameinquery __res_nameinquery -#define res_nclose __res_nclose -#define res_ninit __res_ninit -#define res_nmkquery __res_nmkquery -#define res_pquery __res_pquery -#define res_nquery __res_nquery -#define res_nquerydomain __res_nquerydomain -#define res_nsearch __res_nsearch -#define res_nsend __res_nsend -#define res_nsendsigned __res_nsendsigned -#define res_nisourserver __res_nisourserver -#define res_ownok __res_ownok -#define res_queriesmatch __res_queriesmatch -#define res_randomid __res_randomid -#define sym_ntop __sym_ntop -#define sym_ntos __sym_ntos -#define sym_ston __sym_ston -#define res_nopt __res_nopt -#define res_ndestroy __res_ndestroy -#define res_nametoclass __res_nametoclass -#define res_nametotype __res_nametotype -#define res_setservers __res_setservers -#define res_getservers __res_getservers -__BEGIN_DECLS -int res_hnok __P((const char *)); -int res_ownok __P((const char *)); -int res_mailok __P((const char *)); -int res_dnok __P((const char *)); -int sym_ston __P((const struct res_sym *, const char *, int *)); -const char * sym_ntos __P((const struct res_sym *, int, int *)); -const char * sym_ntop __P((const struct res_sym *, int, int *)); -int b64_ntop __P((u_char const *, size_t, char *, size_t)); -int b64_pton __P((char const *, u_char *, size_t)); -int loc_aton __P((const char *ascii, u_char *binary)); -const char * loc_ntoa __P((const u_char *binary, char *ascii)); -int dn_skipname __P((const u_char *, const u_char *)); -void putlong __P((u_int32_t, u_char *)); -void putshort __P((u_int16_t, u_char *)); -const char * p_class __P((int)); -const char * p_time __P((u_int32_t)); -const char * p_type __P((int)); -const char * p_rcode __P((int)); -const u_char * p_cdnname __P((const u_char *, const u_char *, int, FILE *)); -const u_char * p_cdname __P((const u_char *, const u_char *, FILE *)); -const u_char * p_fqnname __P((const u_char *cp, const u_char *msg, - int, char *, int)); -const u_char * p_fqname __P((const u_char *, const u_char *, FILE *)); -const char * p_option __P((u_long option)); -char * p_secstodate __P((u_long)); -int dn_count_labels __P((const char *)); -int dn_comp __P((const char *, u_char *, int, - u_char **, u_char **)); -int dn_expand __P((const u_char *, const u_char *, const u_char *, - char *, int)); -u_int res_randomid __P((void)); -int res_nameinquery __P((const char *, int, int, - const u_char *, const u_char *)); -int res_queriesmatch __P((const u_char *, const u_char *, - const u_char *, const u_char *)); -const char * p_section __P((int section, int opcode)); -/* Things involving a resolver context. */ -int res_ninit __P((res_state)); -int res_nisourserver __P((const res_state, - const struct sockaddr_in *)); -void fp_resstat __P((const res_state, FILE *)); -void res_pquery __P((const res_state, const u_char *, int, FILE *)); -const char * res_hostalias __P((const res_state, const char *, - char *, size_t)); -int res_nquery __P((res_state, - const char *, int, int, u_char *, int)); -int res_nsearch __P((res_state, const char *, int, - int, u_char *, int)); -int res_nquerydomain __P((res_state, - const char *, const char *, int, int, - u_char *, int)); -int res_nmkquery __P((res_state, - int, const char *, int, int, const u_char *, - int, const u_char *, u_char *, int)); -int res_nsend __P((res_state, const u_char *, int, u_char *, int)); -int res_nsendsigned __P((res_state, const u_char *, int, - ns_tsig_key *, u_char *, int)); -int res_findzonecut __P((res_state, const char *, ns_class, int, - char *, size_t, struct in_addr *, int)); -void res_nclose __P((res_state)); -int res_nopt __P((res_state, int, u_char *, int, int)); -void res_send_setqhook __P((res_send_qhook hook)); -void res_send_setrhook __P((res_send_rhook hook)); -int __res_vinit __P((res_state, int)); -void res_destroyservicelist __P((void)); -const char * res_servicename __P((u_int16_t port, const char *proto)); -const char * res_protocolname __P((int num)); -void res_destroyprotolist __P((void)); -void res_buildprotolist __P((void)); -const char * res_get_nibblesuffix __P((res_state)); -const char * res_get_bitstringsuffix __P((res_state)); -void res_ndestroy __P((res_state)); -u_int16_t res_nametoclass __P((const char *buf, int *success)); -u_int16_t res_nametotype __P((const char *buf, int *success)); -void res_setservers __P((res_state, - const union res_sockaddr_union *, int)); -int res_getservers __P((res_state, - union res_sockaddr_union *, int)); -__END_DECLS - -#endif /* !_RESOLV_H_ */ diff --git a/winsup/cygwin/include/sched.h b/winsup/cygwin/include/sched.h deleted file mode 100644 index f97b8ebf4..000000000 --- a/winsup/cygwin/include/sched.h +++ /dev/null @@ -1,64 +0,0 @@ -/* sched.h: scheduler interface for Cygwin - - Copyright 2001 Red Hat, Inc. - - Written by Robert Collins - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -/* Written from the opengroup specifications */ - -#ifndef _SCHED_H -#define _SCHED_H -#include - -/* we return -1 and set errno on failure */ -#define SCHED_FIFO 1 -#define SCHED_RR 2 -#define SCHED_OTHER 3 - -struct sched_param -{ - int sched_priority; -}; - -#ifdef __cplusplus -extern "C" { -#endif - -/* max priority for policy */ -int sched_get_priority_max (int); -/* min priority for policy */ -int sched_get_priority_min (int); -/* get sched params for process */ -int sched_getparam (pid_t, struct sched_param *); -/* get the scheduler for pid */ -int sched_getscheduler (pid_t); -/* get the time quantum for pid */ -int sched_rr_get_interval (pid_t, struct timespec *); -/* set the scheduling parameters */ -int sched_setparam (pid_t, const struct sched_param *); -/* set the scheduler */ -int sched_setscheduler (pid_t, int, const struct sched_param *); -/* yield the cpu */ -int sched_yield (void); - -#if defined(__INSIDE_CYGWIN__) -/* These are private helper functions used to calculate scheduler settings and - * validate parameters */ - -/* check parameters for validity */ -int valid_sched_parameters(const struct sched_param *); -/* set a single thread's priority */ -int sched_set_thread_priority(HANDLE thread, int priority); - -#endif /* INSIDE_CYGWIN */ - -#ifdef __cplusplus -} -#endif -#endif /* _SCHED_H */ diff --git a/winsup/cygwin/include/search.h b/winsup/cygwin/include/search.h deleted file mode 100644 index f532eae55..000000000 --- a/winsup/cygwin/include/search.h +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * Written by J.T. Conklin - * Public domain. - * - * $NetBSD: search.h,v 1.12 1999/02/22 10:34:28 christos Exp $ - * $FreeBSD: src/include/search.h,v 1.10 2002/10/16 14:29:23 robert Exp $ - */ - -#ifndef _SEARCH_H_ -#define _SEARCH_H_ - -#include -#include - -typedef struct entry -{ - char *key; - void *data; -} ENTRY; - -typedef enum -{ - FIND, ENTER -} ACTION; - -typedef enum -{ - preorder, - postorder, - endorder, - leaf -} VISIT; - -#ifdef _SEARCH_PRIVATE -typedef struct node -{ - char *key; - struct node *llink, *rlink; -} node_t; -#endif - -struct hsearch_data -{ - struct internal_head *htable; - size_t htablesize; -}; - -struct qelem -{ - struct qelem *q_forw; - struct qelem *q_back; -}; - -__BEGIN_DECLS -int hcreate (size_t); -void hdestroy (void); -ENTRY *hsearch (ENTRY, ACTION); -int hcreate_r (size_t, struct hsearch_data *); -void hdestroy_r (struct hsearch_data *); -int hsearch_r (ENTRY, ACTION, ENTRY **, struct hsearch_data *); -void *tdelete (const void * __restrict, void ** __restrict, - int (*) (const void *, const void *)); -void tdestroy (void *, void (*)(void *)); -void *tfind (const void *, void **, - int (*) (const void *, const void *)); -void *tsearch (const void *, void **, int (*) (const void *, const void *)); -void twalk (const void *, void (*) (const void *, VISIT, int)); -void *lfind (const void *, const void *, size_t *, size_t, - int (*) (const void *, const void *)); -void *lsearch (const void *, void *, size_t *, size_t, - int (*) (const void *, const void *)); -void insque (void *, void *); -void remque (void *); -__END_DECLS - -#endif /* !_SEARCH_H_ */ diff --git a/winsup/cygwin/include/semaphore.h b/winsup/cygwin/include/semaphore.h deleted file mode 100644 index b16d13751..000000000 --- a/winsup/cygwin/include/semaphore.h +++ /dev/null @@ -1,45 +0,0 @@ -/* semaphore.h: POSIX semaphore interface - - Copyright 2001, 2003, 2007 Red Hat, Inc. - - Written by Robert Collins - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#include - -#ifndef _SEMAPHORE_H -#define _SEMAPHORE_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -#ifndef __INSIDE_CYGWIN__ - typedef struct __sem_t {char __dummy;} *sem_t; -#endif - -#define SEM_FAILED ((sem_t *) 0) - -/* Semaphores */ - int sem_init (sem_t *sem, int pshared, unsigned int value); - int sem_destroy (sem_t *sem); - sem_t *sem_open (const char *name, int oflag, ...); - int sem_close (sem_t *sem); - int sem_unlink (const char *name); - int sem_wait (sem_t *sem); - int sem_trywait (sem_t *sem); - int sem_timedwait (sem_t *sem, const struct timespec *abstime); - int sem_post (sem_t *sem); - int sem_getvalue (sem_t *sem, int *sval); - -#ifdef __cplusplus -} -#endif - -#endif /* _SEMAPHORE_H */ diff --git a/winsup/cygwin/include/stdint.h b/winsup/cygwin/include/stdint.h deleted file mode 100644 index 12f16e220..000000000 --- a/winsup/cygwin/include/stdint.h +++ /dev/null @@ -1,182 +0,0 @@ -/* stdint.h - integer types - - Copyright 2003, 2006, 2007 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _STDINT_H -#define _STDINT_H - -/* Exact-width integer types */ - -#ifndef __int8_t_defined -#define __int8_t_defined -typedef signed char int8_t; -typedef short int16_t; -typedef int int32_t; -typedef long long int64_t; -#endif - -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -#ifndef __uint32_t_defined -#define __uint32_t_defined -typedef unsigned int uint32_t; -#endif -typedef unsigned long long uint64_t; - -/* Minimum-width integer types */ - -typedef signed char int_least8_t; -typedef short int_least16_t; -typedef int int_least32_t; -typedef long long int_least64_t; - -typedef unsigned char uint_least8_t; -typedef unsigned short uint_least16_t; -typedef unsigned int uint_least32_t; -typedef unsigned long long uint_least64_t; - -/* Fastest minimum-width integer types */ - -typedef signed char int_fast8_t; -typedef int int_fast16_t; -typedef int int_fast32_t; -typedef long long int_fast64_t; - -typedef unsigned char uint_fast8_t; -typedef unsigned int uint_fast16_t; -typedef unsigned int uint_fast32_t; -typedef unsigned long long uint_fast64_t; - -/* Integer types capable of holding object pointers */ - -#ifndef __intptr_t_defined -#define __intptr_t_defined -typedef int intptr_t; -#endif -typedef unsigned int uintptr_t; - -/* Greatest-width integer types */ - -typedef long long intmax_t; -typedef unsigned long long uintmax_t; - -/* Limits of exact-width integer types */ - -#define INT8_MIN (-128) -#define INT16_MIN (-32768) -#define INT32_MIN (-2147483647 - 1) -#define INT64_MIN (-9223372036854775807LL - 1LL) - -#define INT8_MAX (127) -#define INT16_MAX (32767) -#define INT32_MAX (2147483647) -#define INT64_MAX (9223372036854775807LL) - -#define UINT8_MAX (255) -#define UINT16_MAX (65535) -#define UINT32_MAX (4294967295U) -#define UINT64_MAX (18446744073709551615ULL) - -/* Limits of minimum-width integer types */ - -#define INT_LEAST8_MIN (-128) -#define INT_LEAST16_MIN (-32768) -#define INT_LEAST32_MIN (-2147483647 - 1) -#define INT_LEAST64_MIN (-9223372036854775807LL - 1LL) - -#define INT_LEAST8_MAX (127) -#define INT_LEAST16_MAX (32767) -#define INT_LEAST32_MAX (2147483647) -#define INT_LEAST64_MAX (9223372036854775807LL) - -#define UINT_LEAST8_MAX (255) -#define UINT_LEAST16_MAX (65535) -#define UINT_LEAST32_MAX (4294967295U) -#define UINT_LEAST64_MAX (18446744073709551615ULL) - -/* Limits of fastest minimum-width integer types */ - -#define INT_FAST8_MIN (-128) -#define INT_FAST16_MIN (-2147483647 - 1) -#define INT_FAST32_MIN (-2147483647 - 1) -#define INT_FAST64_MIN (-9223372036854775807LL - 1LL) - -#define INT_FAST8_MAX (127) -#define INT_FAST16_MAX (2147483647) -#define INT_FAST32_MAX (2147483647) -#define INT_FAST64_MAX (9223372036854775807LL) - -#define UINT_FAST8_MAX (255) -#define UINT_FAST16_MAX (4294967295U) -#define UINT_FAST32_MAX (4294967295U) -#define UINT_FAST64_MAX (18446744073709551615ULL) - -/* Limits of integer types capable of holding object pointers */ - -#define INTPTR_MIN (-2147483647 - 1) -#define INTPTR_MAX (2147483647) -#define UINTPTR_MAX (4294967295U) - -/* Limits of greatest-width integer types */ - -#define INTMAX_MIN (-9223372036854775807LL - 1LL) -#define INTMAX_MAX (9223372036854775807LL) -#define UINTMAX_MAX (18446744073709551615ULL) - -/* Limits of other integer types */ - -#ifndef PTRDIFF_MIN -#define PTRDIFF_MIN (-2147483647 - 1) -#define PTRDIFF_MAX (2147483647) -#endif - -#ifndef SIG_ATOMIC_MIN -#define SIG_ATOMIC_MIN (-2147483647 - 1) -#endif -#ifndef SIG_ATOMIC_MAX -#define SIG_ATOMIC_MAX (2147483647) -#endif - -#ifndef SIZE_MAX -#define SIZE_MAX (4294967295U) -#endif - -#ifndef WCHAR_MIN -#ifdef __WCHAR_MIN__ -#define WCHAR_MIN __WCHAR_MIN__ -#define WCHAR_MAX __WCHAR_MAX__ -#else -#define WCHAR_MIN (0) -#define WCHAR_MAX (65535) -#endif -#endif - -#ifndef WINT_MIN -#define WINT_MIN 0U -#define WINT_MAX (4294967295U) -#endif - -/* Macros for minimum-width integer constant expressions */ - -#define INT8_C(x) x -#define INT16_C(x) x -#define INT32_C(x) x -#define INT64_C(x) x ## LL - -#define UINT8_C(x) x -#define UINT16_C(x) x -#define UINT32_C(x) x ## U -#define UINT64_C(x) x ## ULL - -/* Macros for greatest-width integer constant expressions */ - -#define INTMAX_C(x) x ## LL -#define UINTMAX_C(x) x ## ULL - -#endif /* _STDINT_H */ diff --git a/winsup/cygwin/include/strings.h b/winsup/cygwin/include/strings.h deleted file mode 100644 index a443ee51f..000000000 --- a/winsup/cygwin/include/strings.h +++ /dev/null @@ -1,37 +0,0 @@ -/* strings.h - - Copyright 2007 Red Hat, Inc. - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#ifndef _STRINGS_H_ -#define _STRINGS_H_ - -/* newlib's string.h already declares these functions. */ -#ifndef _STRING_H_ - -#include "_ansi.h" - -#define __need_size_t -#include - -_BEGIN_STD_C - -int _EXFUN(bcmp,(const void *, const void *, size_t)); -void _EXFUN(bcopy,(const void *, void *, size_t)); -void _EXFUN(bzero,(void *, size_t)); -int _EXFUN(ffs,(int)); -char *_EXFUN(index,(const char *, int)); -char *_EXFUN(rindex,(const char *, int)); -int _EXFUN(strcasecmp,(const char *, const char *)); -int _EXFUN(strncasecmp,(const char *, const char *, size_t)); - -_END_STD_C - -#endif /* _STRING_H_ */ - -#endif /* _STRINGS_H_ */ diff --git a/winsup/cygwin/include/sys/acl.h b/winsup/cygwin/include/sys/acl.h deleted file mode 100644 index 89c38bc0f..000000000 --- a/winsup/cygwin/include/sys/acl.h +++ /dev/null @@ -1,17 +0,0 @@ -/* sys/acl.h header file for Cygwin. - - Copyright 1999, 2000, 2001 Red Hat, Inc. - Written by C. Vinschen. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SYS_ACL_H -#define _SYS_ACL_H - -#include - -#endif /* _SYS_ACL_H */ diff --git a/winsup/cygwin/include/sys/copying.dj b/winsup/cygwin/include/sys/copying.dj deleted file mode 100644 index a05f4bc81..000000000 --- a/winsup/cygwin/include/sys/copying.dj +++ /dev/null @@ -1,41 +0,0 @@ -This is the file "copying.dj". It does not apply to any sources -copyrighted by UCB Berkeley or the Free Software Foundation. - - Copyright Information for sources and executables that are marked - Copyright (C) DJ Delorie - 24 Kirsten Ave - Rochester NH 03867-2954 - -This document is Copyright (C) DJ Delorie and may be distributed -verbatim, but changing it is not allowed. - -Source code copyright DJ Delorie is distributed under the terms of the -GNU General Public Licence, with the following exceptions: - -* Any existing copyright or authorship information in any given source -file must remain intact. If you modify a source file, a notice to that -effect must be added to the authorship information in the source file. - -* binaries provided in djgpp may be distributed without sources ONLY if -the recipient is given sufficient information to obtain a copy of djgpp -themselves. This primarily applies to go32.exe, emu387, stub.exe, and -the graphics drivers. - -* modified versions of the binaries provided in djgpp must be -distributed under the terms of the GPL. - -* objects and libraries linked into an application may be distributed -without sources. - ------ - -Changes to source code copyright BSD or FSF are copyright DJ Delorie, but -fall under the terms of the original copyright. - -A copy of the file "COPYING" is included with this document. If you did not -receive a copy of "COPYING", you may obtain one from whence this document -was obtained, or by writing: - Free Software Foundation - 675 Mass Ave - Cambridge, MA 02139 - USA diff --git a/winsup/cygwin/include/sys/cygwin.h b/winsup/cygwin/include/sys/cygwin.h deleted file mode 100644 index 6c04dc8e1..000000000 --- a/winsup/cygwin/include/sys/cygwin.h +++ /dev/null @@ -1,341 +0,0 @@ -/* sys/cygwin.h - - Copyright 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SYS_CYGWIN_H -#define _SYS_CYGWIN_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define _CYGWIN_SIGNAL_STRING "cYgSiGw00f" - -#if 0 /* ENTIRELY DEPRECATED INTERFACES. */ -extern pid_t cygwin32_winpid_to_pid (int); -extern void cygwin32_win32_to_posix_path_list (const char *, char *); -extern int cygwin32_win32_to_posix_path_list_buf_size (const char *); -extern void cygwin32_posix_to_win32_path_list (const char *, char *); -extern int cygwin32_posix_to_win32_path_list_buf_size (const char *); -extern int cygwin32_conv_to_win32_path (const char *, char *); -extern int cygwin32_conv_to_full_win32_path (const char *, char *); -extern void cygwin32_conv_to_posix_path (const char *, char *); -extern void cygwin32_conv_to_full_posix_path (const char *, char *); -extern int cygwin32_posix_path_list_p (const char *); -extern void cygwin32_split_path (const char *, char *, char *); -extern int cygwin32_attach_handle_to_fd (char *, int, HANDLE, mode_t, DWORD); -#endif - -/* DEPRECATED INTERFACES. These are restricted to MAX_PATH length. - Don't use in modern applications. */ -extern int cygwin_win32_to_posix_path_list (const char *, char *) - __attribute__ ((deprecated)); -extern int cygwin_win32_to_posix_path_list_buf_size (const char *) - __attribute__ ((deprecated)); -extern int cygwin_posix_to_win32_path_list (const char *, char *) - __attribute__ ((deprecated)); -extern int cygwin_posix_to_win32_path_list_buf_size (const char *) - __attribute__ ((deprecated)); -extern int cygwin_conv_to_win32_path (const char *, char *) - __attribute__ ((deprecated)); -extern int cygwin_conv_to_full_win32_path (const char *, char *) - __attribute__ ((deprecated)); -extern int cygwin_conv_to_posix_path (const char *, char *) - __attribute__ ((deprecated)); -extern int cygwin_conv_to_full_posix_path (const char *, char *) - __attribute__ ((deprecated)); - -/* Use these interfaces in favor of the above. */ - -/* Possible 'what' values in calls to cygwin_conv_path/cygwin_create_path. */ -enum -{ - CCP_POSIX_TO_WIN_A = 0, /* from is char*, to is char* */ - CCP_POSIX_TO_WIN_W, /* from is char*, to is wchar_t* */ - CCP_WIN_A_TO_POSIX, /* from is char*, to is char* */ - CCP_WIN_W_TO_POSIX, /* from is wchar_t*, to is char* */ - - /* Or these values to the above as needed. */ - CCP_ABSOLUTE = 0, /* Request absolute path (default). */ - CCP_RELATIVE = 0x100 /* Request to keep path relative. */ -}; -typedef unsigned int cygwin_conv_path_t; - -/* If size is 0, cygwin_conv_path returns the required buffer size in bytes. - Otherwise, it returns 0 on success, or -1 on error and errno is set to - one of the below values: - - EINVAL what has an invalid value. - EFAULT from or to point into nirvana. - ENAMETOOLONG the resulting path is longer than 32K, or, in case - of what == CCP_POSIX_TO_WIN_A, longer than MAX_PATH. - ENOSPC size is less than required for the conversion. -*/ -extern ssize_t cygwin_conv_path (cygwin_conv_path_t what, const void *from, - void *to, size_t size); -/* Same, but handles path lists separated by colon or semicolon. */ -extern ssize_t cygwin_conv_path_list (cygwin_conv_path_t what, const void *from, - void *to, size_t size); -/* Allocate a buffer for the conversion result using malloc(3), and return - a pointer to it. Returns NULL if something goes wrong with errno set - to one of the above values, or to ENOMEM if malloc fails. */ -extern void *cygwin_create_path (cygwin_conv_path_t what, const void *from); - -extern pid_t cygwin_winpid_to_pid (int); -extern int cygwin_posix_path_list_p (const char *); -extern void cygwin_split_path (const char *, char *, char *); - -struct __cygwin_perfile -{ - const char *name; - unsigned flags; -}; - -/* External interface stuff */ - -/* Always add at the bottom. Do not add new values in the middle. */ -typedef enum - { - CW_LOCK_PINFO, - CW_UNLOCK_PINFO, - CW_GETTHREADNAME, - CW_GETPINFO, - CW_SETPINFO, - CW_SETTHREADNAME, - CW_GETVERSIONINFO, - CW_READ_V1_MOUNT_TABLES, - CW_USER_DATA, - CW_PERFILE, - CW_GET_CYGDRIVE_PREFIXES, - CW_GETPINFO_FULL, - CW_INIT_EXCEPTIONS, - CW_GET_CYGDRIVE_INFO, - CW_SET_CYGWIN_REGISTRY_NAME, - CW_GET_CYGWIN_REGISTRY_NAME, - CW_STRACE_TOGGLE, - CW_STRACE_ACTIVE, - CW_CYGWIN_PID_TO_WINPID, - CW_EXTRACT_DOMAIN_AND_USER, - CW_CMDLINE, - CW_CHECK_NTSEC, - CW_GET_ERRNO_FROM_WINERROR, - CW_GET_POSIX_SECURITY_ATTRIBUTE, - CW_GET_SHMLBA, - CW_GET_UID_FROM_SID, - CW_GET_GID_FROM_SID, - CW_GET_BINMODE, - CW_HOOK, - CW_ARGV, - CW_ENVP, - CW_DEBUG_SELF, - CW_SYNC_WINENV, - CW_CYGTLS_PADSIZE, - CW_SET_DOS_FILE_WARNING, - CW_SET_PRIV_KEY, - CW_SETERRNO, - CW_EXIT_PROCESS, - CW_SET_EXTERNAL_TOKEN, - CW_GET_INSTKEY, - CW_INT_SETLOCALE - } cygwin_getinfo_types; - -/* Token type for CW_SET_EXTERNAL_TOKEN */ -enum -{ - CW_TOKEN_IMPERSONATION = 0, - CW_TOKEN_RESTRICTED = 1 -}; - -#define CW_NEXTPID 0x80000000 /* or with pid to get next one */ -unsigned long cygwin_internal (cygwin_getinfo_types, ...); - -/* Flags associated with process_state */ -enum -{ - PID_IN_USE = 0x00001, /* Entry in use. */ - PID_UNUSED = 0x00002, /* Available. */ - PID_STOPPED = 0x00004, /* Waiting for SIGCONT. */ - PID_TTYIN = 0x00008, /* Waiting for terminal input. */ - PID_TTYOU = 0x00010, /* Waiting for terminal output. */ - PID_ORPHANED = 0x00020, /* Member of an orphaned process group. */ - PID_ACTIVE = 0x00040, /* Pid accepts signals. */ - PID_CYGPARENT = 0x00080, /* Set if parent was a cygwin app. */ - PID_MAP_RW = 0x00100, /* Flag to open map rw. */ - PID_MYSELF = 0x00200, /* Flag that pid is me. */ - PID_NOCLDSTOP = 0x00400, /* Set if no SIGCHLD signal on stop. */ - PID_INITIALIZING = 0x00800, /* Set until ready to receive signals. */ - PID_USETTY = 0x01000, /* Setting this enables or disables cygwin's - tty support. This is inherited by - all execed or forked processes. */ - PID_ALLPIDS = 0x02000, /* used by pinfo scanner */ - PID_EXECED = 0x04000, /* redirect to original pid info block */ - PID_NOREDIR = 0x08000, /* don't redirect if execed */ - PID_EXITED = 0x80000000 /* Free entry. */ -}; - -#ifdef WINVER - -/* This lives in the app and is initialized before jumping into the DLL. - It should only contain stuff which the user's process needs to see, or - which is needed before the user pointer is initialized, or is needed to - carry inheritance information from parent to child. Note that it cannot - be used to carry inheritance information across exec! - - Remember, this structure is linked into the application's executable. - Changes to this can invalidate existing executables, so we go to extra - lengths to avoid having to do it. - - When adding/deleting members, remember to adjust {public,internal}_reserved. - The size of the class shouldn't change [unless you really are prepared to - invalidate all existing executables]. The program does a check (using - SIZEOF_PER_PROCESS) to make sure you remember to make the adjustment. -*/ - -#ifdef __cplusplus -class MTinterface; -#endif - -struct per_process_cxx_malloc; - -struct per_process -{ - char *initial_sp; - - /* The offset of these 3 values can never change. */ - /* magic_biscuit is the size of this class and should never change. */ - unsigned long magic_biscuit; - unsigned long dll_major; - unsigned long dll_minor; - - struct _reent **impure_ptr_ptr; - char ***envptr; - - /* Used to point to the memory machine we should use. Usually these - point back into the dll, but they can be overridden by the user. */ - void *(*malloc)(size_t); - void (*free)(void *); - void *(*realloc)(void *, size_t); - - int *fmode_ptr; - - int (*main)(int, char **, char **); - void (**ctors)(void); - void (**dtors)(void); - - /* For fork */ - void *data_start; - void *data_end; - void *bss_start; - void *bss_end; - - void *(*calloc)(size_t, size_t); - /* For future expansion of values set by the app. */ - void (*premain[4]) (int, char **, struct per_process *); - - /* The rest are *internal* to cygwin.dll. - Those that are here because we want the child to inherit the value from - the parent (which happens when bss is copied) are marked as such. */ - - /* non-zero of ctors have been run. Inherited from parent. */ - int run_ctors_p; - - DWORD unused[7]; - - /* Pointers to real operator new/delete functions for forwarding. */ - struct per_process_cxx_malloc *cxx_malloc; - - HMODULE hmodule; - - DWORD api_major; /* API version that this program was */ - DWORD api_minor; /* linked with */ - /* For future expansion, so apps won't have to be relinked if we - add an item. */ - DWORD unused2[6]; - -#if defined (__INSIDE_CYGWIN__) && defined (__cplusplus) - MTinterface *threadinterface; -#else - void *threadinterface; -#endif - struct _reent *impure_ptr; -}; -#define per_process_overwrite ((unsigned) &(((struct per_process *) NULL)->threadinterface)) - -extern void cygwin_premain0 (int argc, char **argv, struct per_process *); -extern void cygwin_premain1 (int argc, char **argv, struct per_process *); -extern void cygwin_premain2 (int argc, char **argv, struct per_process *); -extern void cygwin_premain3 (int argc, char **argv, struct per_process *); - -#ifdef _PATH_PASSWD -extern HANDLE cygwin_logon_user (const struct passwd *, const char *); -#endif -extern void cygwin_set_impersonation_token (const HANDLE); - -/* included if is included */ -extern int cygwin_attach_handle_to_fd (char *, int, HANDLE, mode_t, DWORD); - -#ifdef __CYGWIN__ -#include - -#define TTY_CONSOLE 0x40000000 - -#define EXTERNAL_PINFO_VERSION_16_BIT 0 -#define EXTERNAL_PINFO_VERSION_32_BIT 1 -#define EXTERNAL_PINFO_VERSION_32_LP 2 -#define EXTERNAL_PINFO_VERSION EXTERNAL_PINFO_VERSION_32_LP - -#ifndef _SYS_TYPES_H -typedef unsigned short __uid16_t; -typedef unsigned short __gid16_t; -typedef unsigned long __uid32_t; -typedef unsigned long __gid32_t; -#endif - -struct external_pinfo - { - pid_t pid; - pid_t ppid; - DWORD exitcode; - DWORD dwProcessId, dwSpawnedProcessId; - __uid16_t uid; - __gid16_t gid; - pid_t pgid; - pid_t sid; - int ctty; - mode_t umask; - - long start_time; - struct rusage rusage_self; - struct rusage rusage_children; - - char progname[MAX_PATH]; - - DWORD strace_mask; - DWORD version; - - DWORD process_state; - - /* Only available if version >= EXTERNAL_PINFO_VERSION_32_BIT */ - __uid32_t uid32; - __gid32_t gid32; - - /* Only available if version >= EXTERNAL_PINFO_VERSION_32_LP */ - char *progname_long; -}; -#endif /*__CYGWIN__*/ -#endif /*WINVER*/ - -#ifdef __cplusplus -}; -#endif -#endif /* _SYS_CYGWIN_H */ diff --git a/winsup/cygwin/include/sys/dirent.h b/winsup/cygwin/include/sys/dirent.h deleted file mode 100644 index 451c802bc..000000000 --- a/winsup/cygwin/include/sys/dirent.h +++ /dev/null @@ -1,111 +0,0 @@ -/* Posix dirent.h for WIN32. - - Copyright 2001, 2002, 2003, 2005, 2006, 2007 Red Hat, Inc. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -/* Including this file should not require any Windows headers. */ - -#ifndef _SYS_DIRENT_H -#define _SYS_DIRENT_H - -#include -#include - -#define __DIRENT_VERSION 2 - -#pragma pack(push,4) -#if defined(__INSIDE_CYGWIN__) || defined (__CYGWIN_USE_BIG_TYPES__) -#define _DIRENT_HAVE_D_TYPE -struct dirent -{ - long __d_version; /* Used internally */ - __ino64_t d_ino; - unsigned char d_type; - unsigned char __d_unused1[3]; - __uint32_t __d_internal1; - char d_name[NAME_MAX + 1]; -}; -#else -struct dirent -{ - long d_version; - long d_reserved[2]; - long d_fd; - ino_t d_ino; - char d_name[NAME_MAX + 1]; -}; -#endif -#pragma pack(pop) - -#define __DIRENT_COOKIE 0xdede4242 - -#pragma pack(push,4) -typedef struct __DIR -{ - /* This is first to set alignment in non _COMPILING_NEWLIB case. */ - unsigned long __d_cookie; - struct dirent *__d_dirent; - char *__d_dirname; /* directory name with trailing '*' */ - _off_t __d_position; /* used by telldir/seekdir */ - int __d_fd; - unsigned __d_internal; - void *__handle; - void *__fh; - unsigned __flags; -} DIR; -#pragma pack(pop) - -DIR *opendir (const char *); -DIR *fdopendir (int); -struct dirent *readdir (DIR *); -int readdir_r (DIR *, struct dirent *, struct dirent **); -void rewinddir (DIR *); -int closedir (DIR *); - -int dirfd (DIR *); - -#ifndef _POSIX_SOURCE -#ifndef __INSIDE_CYGWIN__ -off_t telldir (DIR *); -void seekdir (DIR *, off_t loc); -#endif - -int scandir (const char *__dir, - struct dirent ***__namelist, - int (*select) (const struct dirent *), - int (*compar) (const struct dirent **, const struct dirent **)); - -int alphasort (const struct dirent **__a, const struct dirent **__b); -#ifdef _DIRENT_HAVE_D_TYPE -/* File types for `d_type'. */ -enum -{ - DT_UNKNOWN = 0, -# define DT_UNKNOWN DT_UNKNOWN - DT_FIFO = 1, -# define DT_FIFO DT_FIFO - DT_CHR = 2, -# define DT_CHR DT_CHR - DT_DIR = 4, -# define DT_DIR DT_DIR - DT_BLK = 6, -# define DT_BLK DT_BLK - DT_REG = 8, -# define DT_REG DT_REG - DT_LNK = 10, -# define DT_LNK DT_LNK - DT_SOCK = 12, -# define DT_SOCK DT_SOCK - DT_WHT = 14 -# define DT_WHT DT_WHT -}; - -/* Convert between stat structure types and directory types. */ -# define IFTODT(mode) (((mode) & 0170000) >> 12) -# define DTTOIF(dirtype) ((dirtype) << 12) -#endif /* _DIRENT_HAVE_D_TYPE */ -#endif /* _POSIX_SOURCE */ -#endif /*_SYS_DIRENT_H*/ diff --git a/winsup/cygwin/include/sys/elf32.h b/winsup/cygwin/include/sys/elf32.h deleted file mode 100644 index 5dfe9c8b0..000000000 --- a/winsup/cygwin/include/sys/elf32.h +++ /dev/null @@ -1,156 +0,0 @@ -/*- - * Copyright (c) 1996-1998 John D. Polstra. - * All rights reserved. - * - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - * $FreeBSD: src/sys/sys/elf32.h,v 1.8 2002/05/30 08:32:18 dfr Exp $ - */ - -#ifndef _SYS_ELF32_H_ -#define _SYS_ELF32_H_ 1 - -#include - -/* - * ELF definitions common to all 32-bit architectures. - */ - -typedef u_int32_t Elf32_Addr; -typedef u_int16_t Elf32_Half; -typedef u_int32_t Elf32_Off; -typedef int32_t Elf32_Sword; -typedef u_int32_t Elf32_Word; -typedef u_int32_t Elf32_Size; -typedef Elf32_Off Elf32_Hashelt; - -/* - * ELF header. - */ - -typedef struct { - unsigned char e_ident[EI_NIDENT]; /* File identification. */ - Elf32_Half e_type; /* File type. */ - Elf32_Half e_machine; /* Machine architecture. */ - Elf32_Word e_version; /* ELF format version. */ - Elf32_Addr e_entry; /* Entry point. */ - Elf32_Off e_phoff; /* Program header file offset. */ - Elf32_Off e_shoff; /* Section header file offset. */ - Elf32_Word e_flags; /* Architecture-specific flags. */ - Elf32_Half e_ehsize; /* Size of ELF header in bytes. */ - Elf32_Half e_phentsize; /* Size of program header entry. */ - Elf32_Half e_phnum; /* Number of program header entries. */ - Elf32_Half e_shentsize; /* Size of section header entry. */ - Elf32_Half e_shnum; /* Number of section header entries. */ - Elf32_Half e_shstrndx; /* Section name strings section. */ -} Elf32_Ehdr; - -/* - * Section header. - */ - -typedef struct { - Elf32_Word sh_name; /* Section name (index into the - section header string table). */ - Elf32_Word sh_type; /* Section type. */ - Elf32_Word sh_flags; /* Section flags. */ - Elf32_Addr sh_addr; /* Address in memory image. */ - Elf32_Off sh_offset; /* Offset in file. */ - Elf32_Size sh_size; /* Size in bytes. */ - Elf32_Word sh_link; /* Index of a related section. */ - Elf32_Word sh_info; /* Depends on section type. */ - Elf32_Size sh_addralign; /* Alignment in bytes. */ - Elf32_Size sh_entsize; /* Size of each entry in section. */ -} Elf32_Shdr; - -/* - * Program header. - */ - -typedef struct { - Elf32_Word p_type; /* Entry type. */ - Elf32_Off p_offset; /* File offset of contents. */ - Elf32_Addr p_vaddr; /* Virtual address in memory image. */ - Elf32_Addr p_paddr; /* Physical address (not used). */ - Elf32_Size p_filesz; /* Size of contents in file. */ - Elf32_Size p_memsz; /* Size of contents in memory. */ - Elf32_Word p_flags; /* Access permission flags. */ - Elf32_Size p_align; /* Alignment in memory and file. */ -} Elf32_Phdr; - -/* - * Dynamic structure. The ".dynamic" section contains an array of them. - */ - -typedef struct { - Elf32_Sword d_tag; /* Entry type. */ - union { - Elf32_Size d_val; /* Integer value. */ - Elf32_Addr d_ptr; /* Address value. */ - } d_un; -} Elf32_Dyn; - -/* - * Relocation entries. - */ - -/* Relocations that don't need an addend field. */ -typedef struct { - Elf32_Addr r_offset; /* Location to be relocated. */ - Elf32_Word r_info; /* Relocation type and symbol index. */ -} Elf32_Rel; - -/* Relocations that need an addend field. */ -typedef struct { - Elf32_Addr r_offset; /* Location to be relocated. */ - Elf32_Word r_info; /* Relocation type and symbol index. */ - Elf32_Sword r_addend; /* Addend. */ -} Elf32_Rela; - -/* Macros for accessing the fields of r_info. */ -#define ELF32_R_SYM(info) ((info) >> 8) -#define ELF32_R_TYPE(info) ((unsigned char)(info)) - -/* Macro for constructing r_info from field values. */ -#define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type)) - -/* - * Symbol table entries. - */ - -typedef struct { - Elf32_Word st_name; /* String table index of name. */ - Elf32_Addr st_value; /* Symbol value. */ - Elf32_Size st_size; /* Size of associated object. */ - unsigned char st_info; /* Type and binding information. */ - unsigned char st_other; /* Reserved (not used). */ - Elf32_Half st_shndx; /* Section index of symbol. */ -} Elf32_Sym; - -/* Macros for accessing the fields of st_info. */ -#define ELF32_ST_BIND(info) ((info) >> 4) -#define ELF32_ST_TYPE(info) ((info) & 0xf) - -/* Macro for constructing st_info from field values. */ -#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) - -#endif /* !_SYS_ELF32_H_ */ diff --git a/winsup/cygwin/include/sys/elf64.h b/winsup/cygwin/include/sys/elf64.h deleted file mode 100644 index 48556be5f..000000000 --- a/winsup/cygwin/include/sys/elf64.h +++ /dev/null @@ -1,172 +0,0 @@ -/*- - * Copyright (c) 1996-1998 John D. Polstra. - * All rights reserved. - * - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - * $FreeBSD: src/sys/sys/elf64.h,v 1.10 2002/05/30 08:32:18 dfr Exp $ - */ - -#ifndef _SYS_ELF64_H_ -#define _SYS_ELF64_H_ 1 - -#include - -/* - * ELF definitions common to all 64-bit architectures. - */ - -typedef uint64_t Elf64_Addr; -typedef uint16_t Elf64_Half; -typedef uint32_t Elf64_Word; -typedef int32_t Elf64_Sword; -typedef uint64_t Elf64_Xword; -typedef int64_t Elf64_Sxword; -typedef uint64_t Elf64_Off; -typedef uint16_t Elf64_Section; -typedef Elf64_Half Elf64_Versym; -typedef uint16_t Elf64_Quarter; - -/* - * Types of dynamic symbol hash table bucket and chain elements. - * - * This is inconsistent among 64 bit architectures, so a machine dependent - * typedef is required. - */ - -#ifdef __alpha__ -typedef Elf64_Off Elf64_Hashelt; -#else -typedef Elf64_Half Elf64_Hashelt; -#endif - -/* - * ELF header. - */ - -typedef struct { - unsigned char e_ident[EI_NIDENT]; /* File identification. */ - Elf64_Half e_type; /* File type. */ - Elf64_Half e_machine; /* Machine architecture. */ - Elf64_Word e_version; /* ELF format version. */ - Elf64_Addr e_entry; /* Entry point. */ - Elf64_Off e_phoff; /* Program header file offset. */ - Elf64_Off e_shoff; /* Section header file offset. */ - Elf64_Word e_flags; /* Architecture-specific flags. */ - Elf64_Half e_ehsize; /* Size of ELF header in bytes. */ - Elf64_Half e_phentsize; /* Size of program header entry. */ - Elf64_Half e_phnum; /* Number of program header entries. */ - Elf64_Half e_shentsize; /* Size of section header entry. */ - Elf64_Half e_shnum; /* Number of section header entries. */ - Elf64_Half e_shstrndx; /* Section name strings section. */ -} Elf64_Ehdr; - -/* - * Section header. - */ - -typedef struct { - Elf64_Word sh_name; /* Section name (index into the - section header string table). */ - Elf64_Word sh_type; /* Section type. */ - Elf64_Xword sh_flags; /* Section flags. */ - Elf64_Addr sh_addr; /* Address in memory image. */ - Elf64_Off sh_offset; /* Offset in file. */ - Elf64_Xword sh_size; /* Size in bytes. */ - Elf64_Word sh_link; /* Index of a related section. */ - Elf64_Word sh_info; /* Depends on section type. */ - Elf64_Xword sh_addralign; /* Alignment in bytes. */ - Elf64_Xword sh_entsize; /* Size of each entry in section. */ -} Elf64_Shdr; - -/* - * Program header. - */ - -typedef struct { - Elf64_Word p_type; /* Entry type. */ - Elf64_Word p_flags; /* Access permission flags. */ - Elf64_Off p_offset; /* File offset of contents. */ - Elf64_Addr p_vaddr; /* Virtual address in memory image. */ - Elf64_Addr p_paddr; /* Physical address (not used). */ - Elf64_Xword p_filesz; /* Size of contents in file. */ - Elf64_Xword p_memsz; /* Size of contents in memory. */ - Elf64_Xword p_align; /* Alignment in memory and file. */ -} Elf64_Phdr; - -/* - * Dynamic structure. The ".dynamic" section contains an array of them. - */ - -typedef struct { - Elf64_Sxword d_tag; /* Entry type. */ - union { - Elf64_Xword d_val; /* Integer value. */ - Elf64_Addr d_ptr; /* Address value. */ - } d_un; -} Elf64_Dyn; - -/* - * Relocation entries. - */ - -/* Relocations that don't need an addend field. */ -typedef struct { - Elf64_Addr r_offset; /* Location to be relocated. */ - Elf64_Xword r_info; /* Relocation type and symbol index. */ -} Elf64_Rel; - -/* Relocations that need an addend field. */ -typedef struct { - Elf64_Addr r_offset; /* Location to be relocated. */ - Elf64_Xword r_info; /* Relocation type and symbol index. */ - Elf64_Sxword r_addend; /* Addend. */ -} Elf64_Rela; - -/* Macros for accessing the fields of r_info. */ -#define ELF64_R_SYM(info) ((info) >> 32) -#define ELF64_R_TYPE(info) ((unsigned char)(info)) - -/* Macro for constructing r_info from field values. */ -#define ELF64_R_INFO(sym, type) (((sym) << 32) + (unsigned char)(type)) - -/* - * Symbol table entries. - */ - -typedef struct { - Elf64_Word st_name; /* String table index of name. */ - unsigned char st_info; /* Type and binding information. */ - unsigned char st_other; /* Reserved (not used). */ - Elf64_Section st_shndx; /* Section index of symbol. */ - Elf64_Addr st_value; /* Symbol value. */ - Elf64_Xword st_size; /* Size of associated object. */ -} Elf64_Sym; - -/* Macros for accessing the fields of st_info. */ -#define ELF64_ST_BIND(info) ((info) >> 4) -#define ELF64_ST_TYPE(info) ((info) & 0xf) - -/* Macro for constructing st_info from field values. */ -#define ELF64_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) - -#endif /* !_SYS_ELF64_H_ */ diff --git a/winsup/cygwin/include/sys/elf_common.h b/winsup/cygwin/include/sys/elf_common.h deleted file mode 100644 index b864f0464..000000000 --- a/winsup/cygwin/include/sys/elf_common.h +++ /dev/null @@ -1,299 +0,0 @@ -/*- - * Copyright (c) 1998 John D. Polstra. - * All rights reserved. - * - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - * $FreeBSD: src/sys/sys/elf_common.h,v 1.15 2004/05/05 02:38:54 marcel Exp $ - */ - -#ifndef _SYS_ELF_COMMON_H_ -#define _SYS_ELF_COMMON_H_ 1 - -/* - * ELF definitions that are independent of architecture or word size. - */ - -/* - * Note header. The ".note" section contains an array of notes. Each - * begins with this header, aligned to a word boundary. Immediately - * following the note header is n_namesz bytes of name, padded to the - * next word boundary. Then comes n_descsz bytes of descriptor, again - * padded to a word boundary. The values of n_namesz and n_descsz do - * not include the padding. - */ - -typedef struct { - u_int32_t n_namesz; /* Length of name. */ - u_int32_t n_descsz; /* Length of descriptor. */ - u_int32_t n_type; /* Type of this note. */ -} Elf_Note; - -/* Indexes into the e_ident array. Keep synced with - http://www.sco.com/developer/gabi/ch4.eheader.html */ -#define EI_MAG0 0 /* Magic number, byte 0. */ -#define EI_MAG1 1 /* Magic number, byte 1. */ -#define EI_MAG2 2 /* Magic number, byte 2. */ -#define EI_MAG3 3 /* Magic number, byte 3. */ -#define EI_CLASS 4 /* Class of machine. */ -#define EI_DATA 5 /* Data format. */ -#define EI_VERSION 6 /* ELF format version. */ -#define EI_OSABI 7 /* Operating system / ABI identification */ -#define EI_ABIVERSION 8 /* ABI version */ -#define OLD_EI_BRAND 8 /* Start of architecture identification. */ -#define EI_PAD 9 /* Start of padding (per SVR4 ABI). */ -#define EI_NIDENT 16 /* Size of e_ident array. */ - -/* Values for the magic number bytes. */ -#define ELFMAG0 0x7f -#define ELFMAG1 'E' -#define ELFMAG2 'L' -#define ELFMAG3 'F' -#define ELFMAG "\177ELF" /* magic string */ -#define SELFMAG 4 /* magic string size */ - -/* Values for e_ident[EI_VERSION] and e_version. */ -#define EV_NONE 0 -#define EV_CURRENT 1 - -/* Values for e_ident[EI_CLASS]. */ -#define ELFCLASSNONE 0 /* Unknown class. */ -#define ELFCLASS32 1 /* 32-bit architecture. */ -#define ELFCLASS64 2 /* 64-bit architecture. */ - -/* Values for e_ident[EI_DATA]. */ -#define ELFDATANONE 0 /* Unknown data format. */ -#define ELFDATA2LSB 1 /* 2's complement little-endian. */ -#define ELFDATA2MSB 2 /* 2's complement big-endian. */ - -/* Values for e_ident[EI_OSABI]. */ -#define ELFOSABI_SYSV 0 /* UNIX System V ABI */ -#define ELFOSABI_NONE ELFOSABI_SYSV /* symbol used in old spec */ -#define ELFOSABI_HPUX 1 /* HP-UX operating system */ -#define ELFOSABI_NETBSD 2 /* NetBSD */ -#define ELFOSABI_LINUX 3 /* GNU/Linux */ -#define ELFOSABI_HURD 4 /* GNU/Hurd */ -#define ELFOSABI_86OPEN 5 /* 86Open common IA32 ABI */ -#define ELFOSABI_SOLARIS 6 /* Solaris */ -#define ELFOSABI_MONTEREY 7 /* Monterey */ -#define ELFOSABI_IRIX 8 /* IRIX */ -#define ELFOSABI_FREEBSD 9 /* FreeBSD */ -#define ELFOSABI_TRU64 10 /* TRU64 UNIX */ -#define ELFOSABI_MODESTO 11 /* Novell Modesto */ -#define ELFOSABI_OPENBSD 12 /* OpenBSD */ -#define ELFOSABI_ARM 97 /* ARM */ -#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ - -/* e_ident */ -#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \ - (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \ - (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \ - (ehdr).e_ident[EI_MAG3] == ELFMAG3) - -/* Values for e_type. */ -#define ET_NONE 0 /* Unknown type. */ -#define ET_REL 1 /* Relocatable. */ -#define ET_EXEC 2 /* Executable. */ -#define ET_DYN 3 /* Shared object. */ -#define ET_CORE 4 /* Core file. */ - -/* Values for e_machine. */ -#define EM_NONE 0 /* Unknown machine. */ -#define EM_M32 1 /* AT&T WE32100. */ -#define EM_SPARC 2 /* Sun SPARC. */ -#define EM_386 3 /* Intel i386. */ -#define EM_68K 4 /* Motorola 68000. */ -#define EM_88K 5 /* Motorola 88000. */ -#define EM_486 6 /* Intel i486. */ -#define EM_860 7 /* Intel i860. */ -#define EM_MIPS 8 /* MIPS R3000 Big-Endian only */ - -/* Extensions. This list is not complete. */ -#define EM_S370 9 /* IBM System/370 */ -#define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */ /* Depreciated */ -#define EM_PARISC 15 /* HPPA */ -#define EM_SPARC32PLUS 18 /* SPARC v8plus */ -#define EM_PPC 20 /* PowerPC 32-bit */ -#define EM_PPC64 21 /* PowerPC 64-bit */ -#define EM_ARM 40 /* ARM */ -#define EM_SPARCV9 43 /* SPARC v9 64-bit */ -#define EM_IA_64 50 /* Intel IA-64 Processor */ -#define EM_X86_64 62 /* Advanced Micro Devices x86-64 */ -#define EM_ALPHA 0x9026 /* Alpha (written in the absence of an ABI */ - -/* Special section indexes. */ -#define SHN_UNDEF 0 /* Undefined, missing, irrelevant. */ -#define SHN_LORESERVE 0xff00 /* First of reserved range. */ -#define SHN_LOPROC 0xff00 /* First processor-specific. */ -#define SHN_HIPROC 0xff1f /* Last processor-specific. */ -#define SHN_ABS 0xfff1 /* Absolute values. */ -#define SHN_COMMON 0xfff2 /* Common data. */ -#define SHN_HIRESERVE 0xffff /* Last of reserved range. */ - -/* sh_type */ -#define SHT_NULL 0 /* inactive */ -#define SHT_PROGBITS 1 /* program defined information */ -#define SHT_SYMTAB 2 /* symbol table section */ -#define SHT_STRTAB 3 /* string table section */ -#define SHT_RELA 4 /* relocation section with addends */ -#define SHT_HASH 5 /* symbol hash table section */ -#define SHT_DYNAMIC 6 /* dynamic section */ -#define SHT_NOTE 7 /* note section */ -#define SHT_NOBITS 8 /* no space section */ -#define SHT_REL 9 /* relocation section - no addends */ -#define SHT_SHLIB 10 /* reserved - purpose unknown */ -#define SHT_DYNSYM 11 /* dynamic symbol table section */ -#define SHT_NUM 12 /* number of section types */ -#define SHT_LOOS 0x60000000 /* First of OS specific semantics */ -#define SHT_HIOS 0x6fffffff /* Last of OS specific semantics */ -#define SHT_LOPROC 0x70000000 /* reserved range for processor */ -#define SHT_HIPROC 0x7fffffff /* specific section header types */ -#define SHT_LOUSER 0x80000000 /* reserved range for application */ -#define SHT_HIUSER 0xffffffff /* specific indexes */ - -/* Flags for sh_flags. */ -#define SHF_WRITE 0x1 /* Section contains writable data. */ -#define SHF_ALLOC 0x2 /* Section occupies memory. */ -#define SHF_EXECINSTR 0x4 /* Section contains instructions. */ -#define SHF_TLS 0x400 /* Section contains TLS data. */ -#define SHF_MASKPROC 0xf0000000 /* Reserved for processor-specific. */ - -/* Values for p_type. */ -#define PT_NULL 0 /* Unused entry. */ -#define PT_LOAD 1 /* Loadable segment. */ -#define PT_DYNAMIC 2 /* Dynamic linking information segment. */ -#define PT_INTERP 3 /* Pathname of interpreter. */ -#define PT_NOTE 4 /* Auxiliary information. */ -#define PT_SHLIB 5 /* Reserved (not used). */ -#define PT_PHDR 6 /* Location of program header itself. */ -#define PT_TLS 7 /* Thread local storage segment */ - -#define PT_COUNT 8 /* Number of defined p_type values. */ - -#define PT_LOOS 0x60000000 /* OS-specific */ -#define PT_HIOS 0x6fffffff /* OS-specific */ -#define PT_LOPROC 0x70000000 /* First processor-specific type. */ -#define PT_HIPROC 0x7fffffff /* Last processor-specific type. */ - -/* Values for p_flags. */ -#define PF_X 0x1 /* Executable. */ -#define PF_W 0x2 /* Writable. */ -#define PF_R 0x4 /* Readable. */ - -/* Values for d_tag. */ -#define DT_NULL 0 /* Terminating entry. */ -#define DT_NEEDED 1 /* String table offset of a needed shared - library. */ -#define DT_PLTRELSZ 2 /* Total size in bytes of PLT relocations. */ -#define DT_PLTGOT 3 /* Processor-dependent address. */ -#define DT_HASH 4 /* Address of symbol hash table. */ -#define DT_STRTAB 5 /* Address of string table. */ -#define DT_SYMTAB 6 /* Address of symbol table. */ -#define DT_RELA 7 /* Address of ElfNN_Rela relocations. */ -#define DT_RELASZ 8 /* Total size of ElfNN_Rela relocations. */ -#define DT_RELAENT 9 /* Size of each ElfNN_Rela relocation entry. */ -#define DT_STRSZ 10 /* Size of string table. */ -#define DT_SYMENT 11 /* Size of each symbol table entry. */ -#define DT_INIT 12 /* Address of initialization function. */ -#define DT_FINI 13 /* Address of finalization function. */ -#define DT_SONAME 14 /* String table offset of shared object - name. */ -#define DT_RPATH 15 /* String table offset of library path. [sup] */ -#define DT_SYMBOLIC 16 /* Indicates "symbolic" linking. [sup] */ -#define DT_REL 17 /* Address of ElfNN_Rel relocations. */ -#define DT_RELSZ 18 /* Total size of ElfNN_Rel relocations. */ -#define DT_RELENT 19 /* Size of each ElfNN_Rel relocation. */ -#define DT_PLTREL 20 /* Type of relocation used for PLT. */ -#define DT_DEBUG 21 /* Reserved (not used). */ -#define DT_TEXTREL 22 /* Indicates there may be relocations in - non-writable segments. [sup] */ -#define DT_JMPREL 23 /* Address of PLT relocations. */ -#define DT_BIND_NOW 24 /* [sup] */ -#define DT_INIT_ARRAY 25 /* Address of the array of pointers to - initialization functions */ -#define DT_FINI_ARRAY 26 /* Address of the array of pointers to - termination functions */ -#define DT_INIT_ARRAYSZ 27 /* Size in bytes of the array of - initialization functions. */ -#define DT_FINI_ARRAYSZ 28 /* Size in bytes of the array of - terminationfunctions. */ -#define DT_RUNPATH 29 /* String table offset of a null-terminated - library search path string. */ -#define DT_FLAGS 30 /* Object specific flag values. */ -#define DT_ENCODING 32 /* Values greater than or equal to DT_ENCODING - and less than DT_LOOS follow the rules for - the interpretation of the d_un union - as follows: even == 'd_ptr', even == 'd_val' - or none */ -#define DT_PREINIT_ARRAY 32 /* Address of the array of pointers to - pre-initialization functions. */ -#define DT_PREINIT_ARRAYSZ 33 /* Size in bytes of the array of - pre-initialization functions. */ - -#define DT_COUNT 33 /* Number of defined d_tag values. */ - -#define DT_LOOS 0x6000000d /* First OS-specific */ -#define DT_HIOS 0x6fff0000 /* Last OS-specific */ -#define DT_LOPROC 0x70000000 /* First processor-specific type. */ -#define DT_HIPROC 0x7fffffff /* Last processor-specific type. */ - -/* Values for DT_FLAGS */ -#define DF_ORIGIN 0x0001 /* Indicates that the object being loaded may - make reference to the $ORIGIN substitution - string */ -#define DF_SYMBOLIC 0x0002 /* Indicates "symbolic" linking. */ -#define DF_TEXTREL 0x0004 /* Indicates there may be relocations in - non-writable segments. */ -#define DF_BIND_NOW 0x0008 /* Indicates that the dynamic linker should - process all relocations for the object - containing this entry before transferring - control to the program. */ -#define DF_STATIC_TLS 0x0010 /* Indicates that the shared object or - executable contains code using a static - thread-local storage scheme. */ - -/* Values for n_type. Used in core files. */ -#define NT_PRSTATUS 1 /* Process status. */ -#define NT_FPREGSET 2 /* Floating point registers. */ -#define NT_PRPSINFO 3 /* Process state info. */ - -/* Symbol Binding - ELFNN_ST_BIND - st_info */ -#define STB_LOCAL 0 /* Local symbol */ -#define STB_GLOBAL 1 /* Global symbol */ -#define STB_WEAK 2 /* like global - lower precedence */ -#define STB_LOPROC 13 /* reserved range for processor */ -#define STB_HIPROC 15 /* specific symbol bindings */ - -/* Symbol type - ELFNN_ST_TYPE - st_info */ -#define STT_NOTYPE 0 /* Unspecified type. */ -#define STT_OBJECT 1 /* Data object. */ -#define STT_FUNC 2 /* Function. */ -#define STT_SECTION 3 /* Section. */ -#define STT_FILE 4 /* Source file. */ -#define STT_TLS 6 /* TLS object. */ -#define STT_LOPROC 13 /* reserved range for processor */ -#define STT_HIPROC 15 /* specific symbol types */ - -/* Special symbol table indexes. */ -#define STN_UNDEF 0 /* Undefined symbol index. */ - -#endif /* !_SYS_ELF_COMMON_H_ */ diff --git a/winsup/cygwin/include/sys/elf_generic.h b/winsup/cygwin/include/sys/elf_generic.h deleted file mode 100644 index dbe9f1e83..000000000 --- a/winsup/cygwin/include/sys/elf_generic.h +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * Copyright (c) 1998 John D. Polstra. - * All rights reserved. - * - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - * $FreeBSD: src/sys/sys/elf_generic.h,v 1.6 2002/07/20 02:56:11 peter Exp $ - */ - -#ifndef _SYS_ELF_GENERIC_H_ -#define _SYS_ELF_GENERIC_H_ 1 - -#include - -/* - * Definitions of generic ELF names which relieve applications from - * needing to know the word size. - */ - -#ifndef __ELF_WORD_SIZE -# define __ELF_WORD_SIZE 32 -#endif - -#if __ELF_WORD_SIZE != 32 && __ELF_WORD_SIZE != 64 -#error "__ELF_WORD_SIZE must be defined as 32 or 64" -#endif - -#define ELF_CLASS __CONCAT(ELFCLASS,__ELF_WORD_SIZE) - -#if BYTE_ORDER == LITTLE_ENDIAN -#define ELF_DATA ELFDATA2LSB -#elif BYTE_ORDER == BIG_ENDIAN -#define ELF_DATA ELFDATA2MSB -#else -#error "Unknown byte order" -#endif - -#if __ELF_WORD_SIZE == 32 -#define __elfN(x) elf32_##x -#define __ElfN(x) Elf32_##x -#define __ELFN(x) ELF32_##x -#else -#define __elfN(x) elf364_##x -#define __ElfN(x) Elf364_##x -#define __ELFN(x) ELF364_##x -#endif -#define __ElfType(x) typedef __ElfN(x) Elf_##x - -#define FOO -__ElfType(Addr); -__ElfType(Half); -__ElfType(Off); -__ElfType(Sword); -__ElfType(Word); -__ElfType(Size); -__ElfType(Hashelt); -__ElfType(Ehdr); -__ElfType(Shdr); -__ElfType(Phdr); -__ElfType(Dyn); -__ElfType(Rel); -__ElfType(Rela); -__ElfType(Sym); - -#define ELF_R_SYM __ELFN(R_SYM) -#define ELF_R_TYPE __ELFN(R_TYPE) -#define ELF_R_INFO __ELFN(R_INFO) -#define ELF_ST_BIND __ELFN(ST_BIND) -#define ELF_ST_TYPE __ELFN(ST_TYPE) -#define ELF_ST_INFO __ELFN(ST_INFO) - -#endif /* !_SYS_ELF_GENERIC_H_ */ diff --git a/winsup/cygwin/include/sys/file.h b/winsup/cygwin/include/sys/file.h deleted file mode 100644 index af07df4cf..000000000 --- a/winsup/cygwin/include/sys/file.h +++ /dev/null @@ -1,54 +0,0 @@ -/* This is file FILE.H */ -/* -** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 -** -** This file is distributed under the terms listed in the document -** "copying.dj", available from DJ Delorie at the address above. -** A copy of "copying.dj" should accompany this file; if not, a copy -** should be available from where this file was obtained. This file -** may not be distributed without a verbatim copy of "copying.dj". -** -** This file is distributed WITHOUT ANY WARRANTY; without even the implied -** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -*/ -/* - * 2003-11-27 Nicholas Wourms : - * - * Include sys/cdefs.h. Add function prototype for flock(). - * Add some comments from BSD's header for further clarity. - * (L_SET, L_CURR, L_INCR, L_XTND): Redefine as the macros - * SEEK_SET, SEEK_CUR, SEEK_CUR, & SEEK_END respectively. - * (LOCK_SH,LOCK_EX,LOCK_NB,LOCK_UN): New macros for flock(). -*/ -#ifndef _FILE_H_ -#define _FILE_H_ - -#include -#include - -/* Whence values for lseek(); renamed by POSIX 1003.1 */ -#define L_SET SEEK_SET -#define L_CURR SEEK_CUR -#define L_INCR SEEK_CUR -#define L_XTND SEEK_END - -/* Operations for flock() function */ -#define LOCK_SH 1 /* Shared lock. */ -#define LOCK_EX 2 /* Exclusive lock. */ -#define LOCK_NB 4 /* Don't block when locking. */ -#define LOCK_UN 8 /* Unlock. */ - -/* Operations for access function */ -#define F_OK 0 /* does file exist */ -#define X_OK 1 /* is it executable or searchable by caller */ -#define W_OK 2 /* is it writable by caller */ -#define R_OK 4 /* is it readable by caller */ - -/* Apply or remove an advisory lock on the file fd refers to. */ -__BEGIN_DECLS - -int _EXFUN(flock, (int, int)); - -__END_DECLS - -#endif diff --git a/winsup/cygwin/include/sys/ioctl.h b/winsup/cygwin/include/sys/ioctl.h deleted file mode 100644 index 1aa5acaf9..000000000 --- a/winsup/cygwin/include/sys/ioctl.h +++ /dev/null @@ -1,69 +0,0 @@ -/* sys/ioctl.h - - Copyright 1998, 2001, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* sys/ioctl.h */ - -#ifndef _SYS_IOCTL_H -#define _SYS_IOCTL_H - -#include -#include - -__BEGIN_DECLS - -/* /dev/windows ioctls */ - -#define WINDOWS_POST 0 /* Set write() behavior to PostMessage() */ -#define WINDOWS_SEND 1 /* Set write() behavior to SendMessage() */ -#define WINDOWS_HWND 2 /* Set hWnd for read() calls */ - -/* Some standard linux defines */ - -#define _IOC_NRBITS 8 -#define _IOC_TYPEBITS 8 -#define _IOC_SIZEBITS 14 -#define _IOC_DIRBITS 2 - -#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) -#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) -#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) -#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) - -#define _IOC_NRSHIFT 0 -#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) -#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) -#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) - -#define _IOC_NONE 0U -#define _IOC_WRITE 1U -#define _IOC_READ 2U - -#define _IOC(dir,type,nr,size) \ - (((dir) << _IOC_DIRSHIFT) | \ - + ((type) << _IOC_TYPESHIFT) | \ - + ((nr) << _IOC_NRSHIFT) | \ - + ((size) << _IOC_SIZESHIFT)) - -#define _LINUX_IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) -#define _LINUX_IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) -#define _LINUX_IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) -#define _LINUX_IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size)) - -#ifdef __USE_LINUX_IOCTL_DEFS -# define _IO _LINUX_IO -# define _IOR _LINUX_IOR -# define _IOW _LINUX_IOW -# define _IOWR _LINUX_IOWR -#endif /*__USE_LINUX_IOCTL_DEFS */ - -int __cdecl ioctl (int __fd, int __cmd, ...); - -__END_DECLS -#endif diff --git a/winsup/cygwin/include/sys/ipc.h b/winsup/cygwin/include/sys/ipc.h deleted file mode 100644 index e615bd7c2..000000000 --- a/winsup/cygwin/include/sys/ipc.h +++ /dev/null @@ -1,18 +0,0 @@ -/* sys/ipc.h - - Copyright 2003 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* sys/ipc.h header file for Cygwin. */ - -#ifndef _SYS_IPC_H -#define _SYS_IPC_H - -#include - -#endif /* _SYS_IPC_H */ diff --git a/winsup/cygwin/include/sys/kd.h b/winsup/cygwin/include/sys/kd.h deleted file mode 100644 index 5900efdd7..000000000 --- a/winsup/cygwin/include/sys/kd.h +++ /dev/null @@ -1,20 +0,0 @@ -/* sys/kd.h - - Copyright 2006 Red Hat, Inc. - - Written by Kazuhiro Fujieda - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* sys/kd.h header file for Cygwin. */ - -#ifndef _SYS_KD_H -#define _SYS_KD_H - -#include - -#endif /* _SYS_KD_H */ diff --git a/winsup/cygwin/include/sys/lock.h b/winsup/cygwin/include/sys/lock.h deleted file mode 100644 index abed82716..000000000 --- a/winsup/cygwin/include/sys/lock.h +++ /dev/null @@ -1,54 +0,0 @@ -/* sys/lock.h - - Copyright 2004 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SYS_LOCK_H_ -#define _SYS_LOCK_H_ - -typedef void *_LOCK_T; -#define _LOCK_RECURSIVE_T _LOCK_T - -/* - * This must match cygwins PTHREAD_XXX_MUTEX_INITIALIZER_NP which are - * defined in - */ -#define _LOCK_T_RECURSIVE_INITIALIZER ((_LOCK_T)18) -#define _LOCK_T_INITIALIZER ((_LOCK_T)19) - -#define __LOCK_INIT(CLASS,NAME) \ - CLASS _LOCK_T NAME = _LOCK_T_INITIALIZER; -#define __LOCK_INIT_RECURSIVE(CLASS,NAME) \ - CLASS _LOCK_T NAME = _LOCK_T_RECURSIVE_INITIALIZER; - -#define __lock_init(__lock) __cygwin_lock_init(&__lock) -#define __lock_init_recursive(__lock) __cygwin_lock_init_recursive(&__lock) -#define __lock_close(__lock) __cygwin_lock_fini(&__lock) -#define __lock_close_recursive(__lock) __cygwin_lock_fini(&__lock) -#define __lock_acquire(__lock) __cygwin_lock_lock(&__lock) -#define __lock_acquire_recursive(__lock) __cygwin_lock_lock(&__lock) -#define __lock_try_acquire(lock) __cygwin_lock_trylock(&__lock) -#define __lock_try_acquire_recursive(lock) __cygwin_lock_trylock(&__lock) -#define __lock_release(__lock) __cygwin_lock_unlock(&__lock) -#define __lock_release_recursive(__lock) __cygwin_lock_unlock(&__lock) - -#ifdef __cplusplus -extern "C" -{ -#endif -void __cygwin_lock_init(_LOCK_T *); -void __cygwin_lock_init_recursive(_LOCK_T *); -void __cygwin_lock_fini(_LOCK_T *); -void __cygwin_lock_lock(_LOCK_T *); -int __cygwin_lock_trylock(_LOCK_T *); -void __cygwin_lock_unlock(_LOCK_T *); -#ifdef __cplusplus -} -#endif - -#endif diff --git a/winsup/cygwin/include/sys/mman.h b/winsup/cygwin/include/sys/mman.h deleted file mode 100644 index 234de8074..000000000 --- a/winsup/cygwin/include/sys/mman.h +++ /dev/null @@ -1,77 +0,0 @@ -/* sys/mman.h - - Copyright 1996, 1997, 1998, 2000, 2001, 2003, 2005, 2007 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SYS_MMAN_H_ -#define _SYS_MMAN_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include -#include - -#define PROT_NONE 0 -#define PROT_READ 1 -#define PROT_WRITE 2 -#define PROT_EXEC 4 - -#define MAP_FILE 0 -#define MAP_SHARED 1 -#define MAP_PRIVATE 2 -#define MAP_TYPE 0xF -#define MAP_FIXED 0x10 -#define MAP_ANONYMOUS 0x20 -#define MAP_ANON MAP_ANONYMOUS -/* Non-standard flag */ -#define MAP_NORESERVE 0x4000 /* Don't reserve swap space for this mapping. - Page protection must be set explicitely - to access page. Only supported for anonymous - private mappings. */ -#define MAP_AUTOGROW 0x8000 /* Grow underlying object to mapping size. - File must be opened for writing. */ - -#define MAP_FAILED ((void *)-1) - -/* - * Flags for msync. - */ -#define MS_ASYNC 1 -#define MS_SYNC 2 -#define MS_INVALIDATE 4 - -/* - * Flags for posix_madvise. - */ -#define POSIX_MADV_NORMAL 0 -#define POSIX_MADV_SEQUENTIAL 1 -#define POSIX_MADV_RANDOM 2 -#define POSIX_MADV_WILLNEED 3 -#define POSIX_MADV_DONTNEED 4 - -#ifndef __INSIDE_CYGWIN__ -extern void *mmap (void *__addr, size_t __len, int __prot, int __flags, int __fd, off_t __off); -#endif -extern int munmap (void *__addr, size_t __len); -extern int mprotect (void *__addr, size_t __len, int __prot); -extern int msync (void *__addr, size_t __len, int __flags); -extern int mlock (const void *__addr, size_t __len); -extern int munlock (const void *__addr, size_t __len); - -extern int posix_madvise (void *__addr, size_t __len, int __advice); - -extern int shm_open (const char *__name, int __oflag, mode_t __mode); -extern int shm_unlink (const char *__name); - -#ifdef __cplusplus -}; -#endif /* __cplusplus */ - -#endif /* _SYS_MMAN_H_ */ diff --git a/winsup/cygwin/include/sys/mount.h b/winsup/cygwin/include/sys/mount.h deleted file mode 100644 index f6e6ac64d..000000000 --- a/winsup/cygwin/include/sys/mount.h +++ /dev/null @@ -1,50 +0,0 @@ -/* sys/mount.h - - Copyright 1998, 1999, 2000, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SYS_MOUNT_H -#define _SYS_MOUNT_H - -#ifdef __cplusplus -extern "C" { -#endif - -enum -{ - MOUNT_SYMLINK = 0x00001, /* "mount point" is a symlink */ - MOUNT_BINARY = 0x00002, /* "binary" format read/writes */ - MOUNT_SYSTEM = 0x00008, /* mount point came from system table */ - MOUNT_EXEC = 0x00010, /* Any file in the mounted directory - gets 'x' bit */ - MOUNT_CYGDRIVE = 0x00020, /* mount point refers to cygdrive - device mount */ - MOUNT_CYGWIN_EXEC = 0x00040, /* file or directory is or contains a - cygwin executable */ - MOUNT_MIXED = 0x00080, /* reads are text, writes are binary - not yet implemented */ - MOUNT_NOTEXEC = 0x00100, /* don't check files for executable magic */ - MOUNT_DEVFS = 0x00200, /* /device "filesystem" */ - MOUNT_PROC = 0x00400, /* /proc "filesystem" */ - MOUNT_RO = 0x01000, /* read-only "filesystem" */ - MOUNT_NOACL = 0x02000, /* support reading/writing ACLs */ - MOUNT_NOPOSIX = 0x04000, /* Case insensitve path handling */ - MOUNT_OVERRIDE = 0x08000, /* Allow overriding of root */ - MOUNT_IMMUTABLE = 0x10000, /* Mount point can't be changed */ - MOUNT_AUTOMATIC = 0x20000 /* Mount point was added automatically */ -}; - -int mount (const char *, const char *, unsigned __flags); -int umount (const char *); -int cygwin_umount (const char *__path, unsigned __flags); - -#ifdef __cplusplus -}; -#endif - -#endif /* _SYS_MOUNT_H */ diff --git a/winsup/cygwin/include/sys/msg.h b/winsup/cygwin/include/sys/msg.h deleted file mode 100644 index a554ab4f8..000000000 --- a/winsup/cygwin/include/sys/msg.h +++ /dev/null @@ -1,18 +0,0 @@ -/* sys/msg.h - - Copyright 2003 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* sys/msg.h header file for Cygwin. */ - -#ifndef _SYS_MSG_H -#define _SYS_MSG_H - -#include - -#endif /* _SYS_MSG_H */ diff --git a/winsup/cygwin/include/sys/mtio.h b/winsup/cygwin/include/sys/mtio.h deleted file mode 100644 index 84812bdc9..000000000 --- a/winsup/cygwin/include/sys/mtio.h +++ /dev/null @@ -1,18 +0,0 @@ -/* sys/mtio.h - - Copyright 1999, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* sys/mtio.h header file for Cygwin. */ - -#ifndef _SYS_MTIO_H -#define _SYS_MTIO_H - -#include - -#endif /* _SYS_MTIO_H */ diff --git a/winsup/cygwin/include/sys/param.h b/winsup/cygwin/include/sys/param.h deleted file mode 100644 index c84ea5a04..000000000 --- a/winsup/cygwin/include/sys/param.h +++ /dev/null @@ -1,80 +0,0 @@ -/* sys/param.h - - Copyright 2001, 2003, 2007 Red Hat, Inc. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#ifndef _SYS_PARAM_H -#define _SYS_PARAM_H - -#include -/* Linux includes limits.h, but this is not universally done. */ -#include - -/* Max number of open files. The Posix version is OPEN_MAX. */ -/* Number of fds is virtually unlimited in cygwin, but we must provide - some reasonable value for Posix conformance */ -#define NOFILE 8192 - -/* Max number of groups; must keep in sync with NGROUPS_MAX in limits.h */ -#define NGROUPS 1024 - -/* Ticks/second for system calls such as times() */ -/* FIXME: is this the appropriate value? */ -#define HZ 1000 - -/* Max hostname size that can be dealt with */ -/* FIXME: is this the appropriate value? */ -#define MAXHOSTNAMELEN 64 - -/* The Posix version is PATH_MAX. MAXPATHLEN is the BSD variant. */ -#define MAXPATHLEN PATH_MAX - -/* This is the number of bytes per block given in the st_blocks stat member. - It should be in sync with S_BLKSIZE in sys/stat.h. S_BLKSIZE is the - BSD variant of this constant. */ -#define DEV_BSIZE 1024 - -#if 0 /* defined in endian.h */ -/* Some autoconf'd packages check for endianness. When cross-building we - can't run programs on the target. Fortunately, autoconf supports the - definition of byte order in sys/param.h (that's us!). - The values here are the same as used in gdb/defs.h (are the more - appropriate values?). */ -#define BIG_ENDIAN 4321 -#define LITTLE_ENDIAN 1234 - -/* All known win32 systems are little endian. */ -#define BYTE_ORDER LITTLE_ENDIAN -#endif - -#ifndef NULL -#define NULL 0L -#endif - -#ifndef NBBY -#define NBBY 8 -#endif - -/* Bit map related macros. */ -#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) -#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) -#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) -#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) - -/* Macros for counting and rounding. */ -#ifndef howmany -#define howmany(x, y) (((x)+((y)-1))/(y)) -#endif -#define rounddown(x, y) (((x)/(y))*(y)) -#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */ -#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */ -#define powerof2(x) ((((x)-1)&(x))==0) - -/* Macros for min/max. */ -#define MIN(a,b) (((a)<(b))?(a):(b)) -#define MAX(a,b) (((a)>(b))?(a):(b)) - -#endif diff --git a/winsup/cygwin/include/sys/poll.h b/winsup/cygwin/include/sys/poll.h deleted file mode 100644 index 7fd1c6eb0..000000000 --- a/winsup/cygwin/include/sys/poll.h +++ /dev/null @@ -1,45 +0,0 @@ -/* sys/poll.h - - Copyright 2000, 2001, 2006 Red Hat, Inc. - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#ifndef _SYS_POLL_H -#define _SYS_POLL_H - -#include - -__BEGIN_DECLS - -#define POLLIN 1 /* Set if data to read. */ -#define POLLPRI 2 /* Set if urgent data to read. */ -#define POLLOUT 4 /* Set if writing data wouldn't block. */ -#define POLLERR 8 /* An error occured. */ -#define POLLHUP 16 /* Shutdown or close happened. */ -#define POLLNVAL 32 /* Invalid file descriptor. */ - -#define NPOLLFILE 64 /* Number of canonical fd's in one call to poll(). */ - -/* The following values are defined by XPG4. */ -#define POLLRDNORM POLLIN -#define POLLRDBAND POLLPRI -#define POLLWRNORM POLLOUT -#define POLLWRBAND POLLOUT - -struct pollfd { - int fd; - short events; - short revents; -}; - -typedef unsigned int nfds_t; - -extern int poll __P ((struct pollfd *fds, nfds_t nfds, int timeout)); - -__END_DECLS - -#endif /* _SYS_POLL_H */ diff --git a/winsup/cygwin/include/sys/procfs.h b/winsup/cygwin/include/sys/procfs.h deleted file mode 100644 index 78485f678..000000000 --- a/winsup/cygwin/include/sys/procfs.h +++ /dev/null @@ -1,18 +0,0 @@ -/* sys/procfs.h - - Copyright 2000, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* sys/procfs.h header file for Cygwin. */ - -#ifndef _SYS_PROCFS_H -#define _SYS_PROCFS_H - -#include - -#endif /* _SYS_PROCFS_H */ diff --git a/winsup/cygwin/include/sys/queue.h b/winsup/cygwin/include/sys/queue.h deleted file mode 100644 index a62d82a2e..000000000 --- a/winsup/cygwin/include/sys/queue.h +++ /dev/null @@ -1,512 +0,0 @@ -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - * - * @(#)queue.h 8.5 (Berkeley) 8/20/94 - * $FreeBSD: /repoman/r/ncvs/src/sys/sys/queue.h,v 1.56 2003/08/14 14:49:26 kan Exp $ - */ - -#ifndef _SYS_QUEUE_H_ -#define _SYS_QUEUE_H_ - -#include - -/* - * This file defines four types of data structures: singly-linked lists, - * singly-linked tail queues, lists and tail queues. - * - * A singly-linked list is headed by a single forward pointer. The elements - * are singly linked for minimum space and pointer manipulation overhead at - * the expense of O(n) removal for arbitrary elements. New elements can be - * added to the list after an existing element or at the head of the list. - * Elements being removed from the head of the list should use the explicit - * macro for this purpose for optimum efficiency. A singly-linked list may - * only be traversed in the forward direction. Singly-linked lists are ideal - * for applications with large datasets and few or no removals or for - * implementing a LIFO queue. - * - * A singly-linked tail queue is headed by a pair of pointers, one to the - * head of the list and the other to the tail of the list. The elements are - * singly linked for minimum space and pointer manipulation overhead at the - * expense of O(n) removal for arbitrary elements. New elements can be added - * to the list after an existing element, at the head of the list, or at the - * end of the list. Elements being removed from the head of the tail queue - * should use the explicit macro for this purpose for optimum efficiency. - * A singly-linked tail queue may only be traversed in the forward direction. - * Singly-linked tail queues are ideal for applications with large datasets - * and few or no removals or for implementing a FIFO queue. - * - * A list is headed by a single forward pointer (or an array of forward - * pointers for a hash table header). The elements are doubly linked - * so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before - * or after an existing element or at the head of the list. A list - * may only be traversed in the forward direction. - * - * A tail queue is headed by a pair of pointers, one to the head of the - * list and the other to the tail of the list. The elements are doubly - * linked so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before or - * after an existing element, at the head of the list, or at the end of - * the list. A tail queue may be traversed in either direction. - * - * For details on the use of these macros, see the queue(3) manual page. - * - * - * SLIST LIST STAILQ TAILQ - * _HEAD + + + + - * _HEAD_INITIALIZER + + + + - * _ENTRY + + + + - * _INIT + + + + - * _EMPTY + + + + - * _FIRST + + + + - * _NEXT + + + + - * _PREV - - - + - * _LAST - - + + - * _FOREACH + + + + - * _FOREACH_SAFE + + + + - * _FOREACH_REVERSE - - - + - * _FOREACH_REVERSE_SAFE - - - + - * _INSERT_HEAD + + + + - * _INSERT_BEFORE - + - + - * _INSERT_AFTER + + + + - * _INSERT_TAIL - - + + - * _CONCAT - - + + - * _REMOVE_HEAD + - + - - * _REMOVE + + + + - * - */ -#define QUEUE_MACRO_DEBUG 0 -#if QUEUE_MACRO_DEBUG -/* Store the last 2 places the queue element or head was altered */ -struct qm_trace { - char * lastfile; - int lastline; - char * prevfile; - int prevline; -}; - -#define TRACEBUF struct qm_trace trace; -#define TRASHIT(x) do {(x) = (void *)-1;} while (0) - -#define QMD_TRACE_HEAD(head) do { \ - (head)->trace.prevline = (head)->trace.lastline; \ - (head)->trace.prevfile = (head)->trace.lastfile; \ - (head)->trace.lastline = __LINE__; \ - (head)->trace.lastfile = __FILE__; \ -} while (0) - -#define QMD_TRACE_ELEM(elem) do { \ - (elem)->trace.prevline = (elem)->trace.lastline; \ - (elem)->trace.prevfile = (elem)->trace.lastfile; \ - (elem)->trace.lastline = __LINE__; \ - (elem)->trace.lastfile = __FILE__; \ -} while (0) - -#else -#define QMD_TRACE_ELEM(elem) -#define QMD_TRACE_HEAD(head) -#define TRACEBUF -#define TRASHIT(x) -#endif /* QUEUE_MACRO_DEBUG */ - -/* - * Singly-linked List declarations. - */ -#define SLIST_HEAD(name, type) \ -struct name { \ - struct type *slh_first; /* first element */ \ -} - -#define SLIST_HEAD_INITIALIZER(head) \ - { NULL } - -#undef SLIST_ENTRY -#define SLIST_ENTRY(type) \ -struct { \ - struct type *sle_next; /* next element */ \ -} - -/* - * Singly-linked List functions. - */ -#define SLIST_EMPTY(head) ((head)->slh_first == NULL) - -#define SLIST_FIRST(head) ((head)->slh_first) - -#define SLIST_FOREACH(var, head, field) \ - for ((var) = SLIST_FIRST((head)); \ - (var); \ - (var) = SLIST_NEXT((var), field)) - -#define SLIST_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) = SLIST_FIRST((head)); \ - (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \ - for ((varp) = &SLIST_FIRST((head)); \ - ((var) = *(varp)) != NULL; \ - (varp) = &SLIST_NEXT((var), field)) - -#define SLIST_INIT(head) do { \ - SLIST_FIRST((head)) = NULL; \ -} while (0) - -#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ - SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \ - SLIST_NEXT((slistelm), field) = (elm); \ -} while (0) - -#define SLIST_INSERT_HEAD(head, elm, field) do { \ - SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \ - SLIST_FIRST((head)) = (elm); \ -} while (0) - -#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) - -#define SLIST_REMOVE(head, elm, type, field) do { \ - if (SLIST_FIRST((head)) == (elm)) { \ - SLIST_REMOVE_HEAD((head), field); \ - } \ - else { \ - struct type *curelm = SLIST_FIRST((head)); \ - while (SLIST_NEXT(curelm, field) != (elm)) \ - curelm = SLIST_NEXT(curelm, field); \ - SLIST_NEXT(curelm, field) = \ - SLIST_NEXT(SLIST_NEXT(curelm, field), field); \ - } \ -} while (0) - -#define SLIST_REMOVE_HEAD(head, field) do { \ - SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \ -} while (0) - -/* - * Singly-linked Tail queue declarations. - */ -#define STAILQ_HEAD(name, type) \ -struct name { \ - struct type *stqh_first;/* first element */ \ - struct type **stqh_last;/* addr of last next element */ \ -} - -#define STAILQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).stqh_first } - -#define STAILQ_ENTRY(type) \ -struct { \ - struct type *stqe_next; /* next element */ \ -} - -/* - * Singly-linked Tail queue functions. - */ -#define STAILQ_CONCAT(head1, head2) do { \ - if (!STAILQ_EMPTY((head2))) { \ - *(head1)->stqh_last = (head2)->stqh_first; \ - (head1)->stqh_last = (head2)->stqh_last; \ - STAILQ_INIT((head2)); \ - } \ -} while (0) - -#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL) - -#define STAILQ_FIRST(head) ((head)->stqh_first) - -#define STAILQ_FOREACH(var, head, field) \ - for((var) = STAILQ_FIRST((head)); \ - (var); \ - (var) = STAILQ_NEXT((var), field)) - - -#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) = STAILQ_FIRST((head)); \ - (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define STAILQ_INIT(head) do { \ - STAILQ_FIRST((head)) = NULL; \ - (head)->stqh_last = &STAILQ_FIRST((head)); \ -} while (0) - -#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \ - if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\ - (head)->stqh_last = &STAILQ_NEXT((elm), field); \ - STAILQ_NEXT((tqelm), field) = (elm); \ -} while (0) - -#define STAILQ_INSERT_HEAD(head, elm, field) do { \ - if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \ - (head)->stqh_last = &STAILQ_NEXT((elm), field); \ - STAILQ_FIRST((head)) = (elm); \ -} while (0) - -#define STAILQ_INSERT_TAIL(head, elm, field) do { \ - STAILQ_NEXT((elm), field) = NULL; \ - *(head)->stqh_last = (elm); \ - (head)->stqh_last = &STAILQ_NEXT((elm), field); \ -} while (0) - -#define STAILQ_LAST(head, type, field) \ - (STAILQ_EMPTY((head)) ? \ - NULL : \ - ((struct type *) \ - ((char *)((head)->stqh_last) - __offsetof(struct type, field)))) - -#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) - -#define STAILQ_REMOVE(head, elm, type, field) do { \ - if (STAILQ_FIRST((head)) == (elm)) { \ - STAILQ_REMOVE_HEAD((head), field); \ - } \ - else { \ - struct type *curelm = STAILQ_FIRST((head)); \ - while (STAILQ_NEXT(curelm, field) != (elm)) \ - curelm = STAILQ_NEXT(curelm, field); \ - if ((STAILQ_NEXT(curelm, field) = \ - STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\ - (head)->stqh_last = &STAILQ_NEXT((curelm), field);\ - } \ -} while (0) - -#define STAILQ_REMOVE_HEAD(head, field) do { \ - if ((STAILQ_FIRST((head)) = \ - STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \ - (head)->stqh_last = &STAILQ_FIRST((head)); \ -} while (0) - -#define STAILQ_REMOVE_HEAD_UNTIL(head, elm, field) do { \ - if ((STAILQ_FIRST((head)) = STAILQ_NEXT((elm), field)) == NULL) \ - (head)->stqh_last = &STAILQ_FIRST((head)); \ -} while (0) - -/* - * List declarations. - */ -#define LIST_HEAD(name, type) \ -struct name { \ - struct type *lh_first; /* first element */ \ -} - -#define LIST_HEAD_INITIALIZER(head) \ - { NULL } - -#define LIST_ENTRY(type) \ -struct { \ - struct type *le_next; /* next element */ \ - struct type **le_prev; /* address of previous next element */ \ -} - -/* - * List functions. - */ - -#define LIST_EMPTY(head) ((head)->lh_first == NULL) - -#define LIST_FIRST(head) ((head)->lh_first) - -#define LIST_FOREACH(var, head, field) \ - for ((var) = LIST_FIRST((head)); \ - (var); \ - (var) = LIST_NEXT((var), field)) - -#define LIST_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) = LIST_FIRST((head)); \ - (var) && ((tvar) = LIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define LIST_INIT(head) do { \ - LIST_FIRST((head)) = NULL; \ -} while (0) - -#define LIST_INSERT_AFTER(listelm, elm, field) do { \ - if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\ - LIST_NEXT((listelm), field)->field.le_prev = \ - &LIST_NEXT((elm), field); \ - LIST_NEXT((listelm), field) = (elm); \ - (elm)->field.le_prev = &LIST_NEXT((listelm), field); \ -} while (0) - -#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ - (elm)->field.le_prev = (listelm)->field.le_prev; \ - LIST_NEXT((elm), field) = (listelm); \ - *(listelm)->field.le_prev = (elm); \ - (listelm)->field.le_prev = &LIST_NEXT((elm), field); \ -} while (0) - -#define LIST_INSERT_HEAD(head, elm, field) do { \ - if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \ - LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\ - LIST_FIRST((head)) = (elm); \ - (elm)->field.le_prev = &LIST_FIRST((head)); \ -} while (0) - -#define LIST_NEXT(elm, field) ((elm)->field.le_next) - -#define LIST_REMOVE(elm, field) do { \ - if (LIST_NEXT((elm), field) != NULL) \ - LIST_NEXT((elm), field)->field.le_prev = \ - (elm)->field.le_prev; \ - *(elm)->field.le_prev = LIST_NEXT((elm), field); \ -} while (0) - -/* - * Tail queue declarations. - */ -#define TAILQ_HEAD(name, type) \ -struct name { \ - struct type *tqh_first; /* first element */ \ - struct type **tqh_last; /* addr of last next element */ \ - TRACEBUF \ -} - -#define TAILQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).tqh_first } - -#define TAILQ_ENTRY(type) \ -struct { \ - struct type *tqe_next; /* next element */ \ - struct type **tqe_prev; /* address of previous next element */ \ - TRACEBUF \ -} - -/* - * Tail queue functions. - */ -#define TAILQ_CONCAT(head1, head2, field) do { \ - if (!TAILQ_EMPTY(head2)) { \ - *(head1)->tqh_last = (head2)->tqh_first; \ - (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ - (head1)->tqh_last = (head2)->tqh_last; \ - TAILQ_INIT((head2)); \ - QMD_TRACE_HEAD(head); \ - QMD_TRACE_HEAD(head2); \ - } \ -} while (0) - -#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) - -#define TAILQ_FIRST(head) ((head)->tqh_first) - -#define TAILQ_FOREACH(var, head, field) \ - for ((var) = TAILQ_FIRST((head)); \ - (var); \ - (var) = TAILQ_NEXT((var), field)) - -#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) = TAILQ_FIRST((head)); \ - (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ - for ((var) = TAILQ_LAST((head), headname); \ - (var); \ - (var) = TAILQ_PREV((var), headname, field)) - -#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \ - for ((var) = TAILQ_LAST((head), headname); \ - (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ - (var) = (tvar)) - -#define TAILQ_INIT(head) do { \ - TAILQ_FIRST((head)) = NULL; \ - (head)->tqh_last = &TAILQ_FIRST((head)); \ - QMD_TRACE_HEAD(head); \ -} while (0) - -#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ - if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\ - TAILQ_NEXT((elm), field)->field.tqe_prev = \ - &TAILQ_NEXT((elm), field); \ - else { \ - (head)->tqh_last = &TAILQ_NEXT((elm), field); \ - QMD_TRACE_HEAD(head); \ - } \ - TAILQ_NEXT((listelm), field) = (elm); \ - (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \ - QMD_TRACE_ELEM(&(elm)->field); \ - QMD_TRACE_ELEM(&listelm->field); \ -} while (0) - -#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ - (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ - TAILQ_NEXT((elm), field) = (listelm); \ - *(listelm)->field.tqe_prev = (elm); \ - (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \ - QMD_TRACE_ELEM(&(elm)->field); \ - QMD_TRACE_ELEM(&listelm->field); \ -} while (0) - -#define TAILQ_INSERT_HEAD(head, elm, field) do { \ - if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \ - TAILQ_FIRST((head))->field.tqe_prev = \ - &TAILQ_NEXT((elm), field); \ - else \ - (head)->tqh_last = &TAILQ_NEXT((elm), field); \ - TAILQ_FIRST((head)) = (elm); \ - (elm)->field.tqe_prev = &TAILQ_FIRST((head)); \ - QMD_TRACE_HEAD(head); \ - QMD_TRACE_ELEM(&(elm)->field); \ -} while (0) - -#define TAILQ_INSERT_TAIL(head, elm, field) do { \ - TAILQ_NEXT((elm), field) = NULL; \ - (elm)->field.tqe_prev = (head)->tqh_last; \ - *(head)->tqh_last = (elm); \ - (head)->tqh_last = &TAILQ_NEXT((elm), field); \ - QMD_TRACE_HEAD(head); \ - QMD_TRACE_ELEM(&(elm)->field); \ -} while (0) - -#define TAILQ_LAST(head, headname) \ - (*(((struct headname *)((head)->tqh_last))->tqh_last)) - -#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) - -#define TAILQ_PREV(elm, headname, field) \ - (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) - -#define TAILQ_REMOVE(head, elm, field) do { \ - if ((TAILQ_NEXT((elm), field)) != NULL) \ - TAILQ_NEXT((elm), field)->field.tqe_prev = \ - (elm)->field.tqe_prev; \ - else { \ - (head)->tqh_last = (elm)->field.tqe_prev; \ - QMD_TRACE_HEAD(head); \ - } \ - *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \ - TRASHIT((elm)->field.tqe_next); \ - TRASHIT((elm)->field.tqe_prev); \ - QMD_TRACE_ELEM(&(elm)->field); \ -} while (0) - -#endif /* !_SYS_QUEUE_H_ */ diff --git a/winsup/cygwin/include/sys/resource.h b/winsup/cygwin/include/sys/resource.h deleted file mode 100644 index d2de569cd..000000000 --- a/winsup/cygwin/include/sys/resource.h +++ /dev/null @@ -1,84 +0,0 @@ -/* sys/resource.h - - Copyright 1997, 1998, 2000, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SYS_RESOURCE_H_ -#define _SYS_RESOURCE_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Used for get/setpriority */ -#define PRIO_PROCESS 0 -#define PRIO_PGRP 1 -#define PRIO_USER 2 - -#define RLIMIT_CPU 0 /* CPU time in seconds */ -#define RLIMIT_FSIZE 1 /* Maximum filesize */ -#define RLIMIT_DATA 2 /* max data size */ -#define RLIMIT_STACK 3 /* max stack size */ -#define RLIMIT_CORE 4 /* max core file size */ -#define RLIMIT_NOFILE 5 /* max number of open files */ -#define RLIMIT_OFILE RLIMIT_NOFILE /* BSD name */ -#define RLIMIT_AS 6 /* address space (virt. memory) limit */ - -#define RLIMIT_NLIMITS 7 /* upper bound of RLIMIT_* defines */ -#define RLIM_NLIMITS RLIMIT_NLIMITS - -#define RLIM_INFINITY (0xffffffffUL) -#define RLIM_SAVED_MAX RLIM_INFINITY -#define RLIM_SAVED_CUR RLIM_INFINITY - -typedef unsigned long rlim_t; - -struct rlimit { - rlim_t rlim_cur; - rlim_t rlim_max; -}; - -#define RUSAGE_SELF 0 /* calling process */ -#define RUSAGE_CHILDREN -1 /* terminated child processes */ - -struct rusage { - struct timeval ru_utime; /* user time used */ - struct timeval ru_stime; /* system time used */ - long ru_maxrss; - long ru_ixrss; /* XXX: 0 */ - long ru_idrss; /* XXX: sum of rm_asrss */ - long ru_isrss; /* XXX: 0 */ - long ru_minflt; /* any page faults not requiring I/O */ - long ru_majflt; /* any page faults requiring I/O */ - long ru_nswap; /* swaps */ - long ru_inblock; /* block input operations */ - long ru_oublock; /* block output operations */ - long ru_msgsnd; /* messages sent */ - long ru_msgrcv; /* messages received */ - long ru_nsignals; /* signals received */ - long ru_nvcsw; /* voluntary context switches */ - long ru_nivcsw; /* involuntary " */ -#define ru_last ru_nivcsw -}; - -int getrlimit (int __resource, struct rlimit *__rlp); -int setrlimit (int __resource, const struct rlimit *__rlp); - -int getrusage (int __who, struct rusage *__rusage); - -int getpriority (int which, id_t who); -int setpriority (int which, id_t who, int value); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/winsup/cygwin/include/sys/sched.h b/winsup/cygwin/include/sys/sched.h deleted file mode 100644 index 8a03ccd88..000000000 --- a/winsup/cygwin/include/sys/sched.h +++ /dev/null @@ -1,16 +0,0 @@ -/* sys/sched.h: stub to the scheduler interface for Cygwin - - The purpose of this file is to override newlib's sched.h. The definitions - in newlib's sched.h are coliding with the definitions in Cygwin's sched.h. - - Copyright 2009 Red Hat, Inc. - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#ifndef _SCHED_H -#include -#endif /* _SCHED_H */ diff --git a/winsup/cygwin/include/sys/select.h b/winsup/cygwin/include/sys/select.h deleted file mode 100644 index 45aef1e18..000000000 --- a/winsup/cygwin/include/sys/select.h +++ /dev/null @@ -1,41 +0,0 @@ -/* select.h - Copyright 1998, 1999, 2000, 2001, 2009 Red Hat, Inc. - - Written by Geoffrey Noer - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SYS_SELECT_H -#define _SYS_SELECT_H - -#if !defined (_POSIX_SOURCE) && !defined (__INSIDE_CYGWIN_NET__) && !defined (__USE_W32_SOCKETS) - -#include - -/* Get fd_set, and macros like FD_SET */ -#include - -/* Get definition of timeval. */ -#include -#include - -/* Get definition of sigset_t. */ -#include - -__BEGIN_DECLS - -int select __P ((int __n, fd_set *__readfds, fd_set *__writefds, - fd_set *__exceptfds, struct timeval *__timeout)); -int pselect __P ((int __n, fd_set *__readfds, fd_set *__writefds, - fd_set *__exceptfds, const struct timespec *__timeout, - const sigset_t *__set)); - -__END_DECLS - -#endif /* !_POSIX_SOURCE, !__INSIDE_CYGWIN_NET__ */ - -#endif /* sys/select.h */ diff --git a/winsup/cygwin/include/sys/sem.h b/winsup/cygwin/include/sys/sem.h deleted file mode 100644 index f7bdb595c..000000000 --- a/winsup/cygwin/include/sys/sem.h +++ /dev/null @@ -1,18 +0,0 @@ -/* sys/sem.h - - Copyright 2003 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* sys/sem.h header file for Cygwin. */ - -#ifndef _SYS_SEM_H -#define _SYS_SEM_H - -#include - -#endif /* _SYS_SEM_H */ diff --git a/winsup/cygwin/include/sys/shm.h b/winsup/cygwin/include/sys/shm.h deleted file mode 100644 index 2f0c38084..000000000 --- a/winsup/cygwin/include/sys/shm.h +++ /dev/null @@ -1,18 +0,0 @@ -/* sys/shm.h - - Copyright 2003 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* sys/shm.h header file for Cygwin. */ - -#ifndef _SYS_SHM_H -#define _SYS_SHM_H - -#include - -#endif /* _SYS_SHM_H */ diff --git a/winsup/cygwin/include/sys/smallprint.h b/winsup/cygwin/include/sys/smallprint.h deleted file mode 100644 index 9593d4d10..000000000 --- a/winsup/cygwin/include/sys/smallprint.h +++ /dev/null @@ -1,27 +0,0 @@ -/* sys/smallprint.h - - Copyright 1998, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SYS_SMALLPRINT_H -#define _SYS_SMALLPRINT_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -int __small_sprintf (char *__dst, const char *__fmt, ...); -int __small_vsprintf (char *__dst, const char *__fmt, va_list __ap); - -#ifdef __cplusplus -}; -#endif - -#endif /* _SYS_SMALLPRINT_H */ diff --git a/winsup/cygwin/include/sys/socket.h b/winsup/cygwin/include/sys/socket.h deleted file mode 100644 index 7eaa9e477..000000000 --- a/winsup/cygwin/include/sys/socket.h +++ /dev/null @@ -1,60 +0,0 @@ -/* sys/socket.h - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2005, 2006, - 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SYS_SOCKET_H -#define _SYS_SOCKET_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* SUS symbolic values for the second parm to shutdown(2) */ -#define SHUT_RD 0 /* == Win32 SD_RECEIVE */ -#define SHUT_WR 1 /* == Win32 SD_SEND */ -#define SHUT_RDWR 2 /* == Win32 SD_BOTH */ - -#ifndef __INSIDE_CYGWIN_NET__ - int accept (int, struct sockaddr *__peer, socklen_t *); - int accept4 (int, struct sockaddr *__peer, socklen_t *, int flags); - int bind (int, const struct sockaddr *__my_addr, socklen_t __addrlen); - int connect (int, const struct sockaddr *, socklen_t); - int getpeername (int, struct sockaddr *__peer, socklen_t *); - int getsockname (int, struct sockaddr *__addr, socklen_t *); - int listen (int, int __n); - ssize_t recv (int, void *__buff, size_t __len, int __flags); - ssize_t recvfrom (int, void *__buff, size_t __len, int __flags, - struct sockaddr *__from, socklen_t *__fromlen); - ssize_t recvmsg(int s, struct msghdr *msg, int flags); - ssize_t send (int, const void *__buff, size_t __len, int __flags); - ssize_t sendmsg(int s, const struct msghdr *msg, int flags); - ssize_t sendto (int, const void *, size_t __len, int __flags, - const struct sockaddr *__to, socklen_t __tolen); - int setsockopt (int __s, int __level, int __optname, const void *optval, - socklen_t __optlen); - int getsockopt (int __s, int __level, int __optname, void *__optval, - socklen_t *__optlen); - int shutdown (int, int); - int socket (int __family, int __type, int __protocol); - int socketpair (int __domain, int __type, int __protocol, int *__socket_vec); - - struct servent *getservbyname (const char *__name, const char *__proto); -#endif - -#ifdef __cplusplus -}; -#endif - -#endif /* _SYS_SOCKET_H */ diff --git a/winsup/cygwin/include/sys/soundcard.h b/winsup/cygwin/include/sys/soundcard.h deleted file mode 100644 index 79341c547..000000000 --- a/winsup/cygwin/include/sys/soundcard.h +++ /dev/null @@ -1,1287 +0,0 @@ -#ifndef SOUNDCARD_H -#define SOUNDCARD_H -/* - * Copyright by Hannu Savolainen 1993-1997 - * - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - */ - - -/* - * OSS interface version. With versions earlier than 3.6 this value is - * an integer with value less than 361. In versions 3.6 and later - * it's a six digit hexadecimal value. For example value - * of 0x030600 represents OSS version 3.6.0. - * Use ioctl(fd, OSS_GETVERSION, &int) to get the version number of - * the currently active driver. - */ -#define SOUND_VERSION 0x030802 -#define OPEN_SOUND_SYSTEM - -/* In Linux we need to be prepared for cross compiling */ -//#include - -/* - * Supported card ID numbers (Should be somewhere else?) - */ - -#define SNDCARD_ADLIB 1 -#define SNDCARD_SB 2 -#define SNDCARD_PAS 3 -#define SNDCARD_GUS 4 -#define SNDCARD_MPU401 5 -#define SNDCARD_SB16 6 -#define SNDCARD_SB16MIDI 7 -#define SNDCARD_UART6850 8 -#define SNDCARD_GUS16 9 -#define SNDCARD_MSS 10 -#define SNDCARD_PSS 11 -#define SNDCARD_SSCAPE 12 -#define SNDCARD_PSS_MPU 13 -#define SNDCARD_PSS_MSS 14 -#define SNDCARD_SSCAPE_MSS 15 -#define SNDCARD_TRXPRO 16 -#define SNDCARD_TRXPRO_SB 17 -#define SNDCARD_TRXPRO_MPU 18 -#define SNDCARD_MAD16 19 -#define SNDCARD_MAD16_MPU 20 -#define SNDCARD_CS4232 21 -#define SNDCARD_CS4232_MPU 22 -#define SNDCARD_MAUI 23 -#define SNDCARD_PSEUDO_MSS 24 -#define SNDCARD_GUSPNP 25 -#define SNDCARD_UART401 26 -/* Sound card numbers 27 to N are reserved. Don't add more numbers here. */ - -/*********************************** - * IOCTL Commands for /dev/sequencer - */ - -#ifndef _SIOWR -#if defined(_IOWR) && (defined(_AIX) || (!defined(sun) && !defined(sparc) && !defined(__sparc__) && !defined(__INCioctlh) && !defined(__Lynx__))) -/* Use already defined ioctl defines if they exist (except with Sun or Sparc) */ -#define SIOCPARM_MASK IOCPARM_MASK -#define SIOC_VOID IOC_VOID -#define SIOC_OUT IOC_OUT -#define SIOC_IN IOC_IN -#define SIOC_INOUT IOC_INOUT -#define _SIOC_SIZE _IOC_SIZE -#define _SIOC_DIR _IOC_DIR -#define _SIOC_NONE _IOC_NONE -#define _SIOC_READ _IOC_READ -#define _SIOC_WRITE _IOC_WRITE -#define _SIO _IO -#define _SIOR _IOR -#define _SIOW _IOW -#define _SIOWR _IOWR -#else - -/* Ioctl's have the command encoded in the lower word, - * and the size of any in or out parameters in the upper - * word. The high 2 bits of the upper word are used - * to encode the in/out status of the parameter; for now - * we restrict parameters to at most 8191 bytes. - */ -/* #define SIOCTYPE (0xff<<8) */ -#define SIOCPARM_MASK 0x1fff /* parameters must be < 8192 bytes */ -#define SIOC_VOID 0x00000000 /* no parameters */ -#define SIOC_OUT 0x20000000 /* copy out parameters */ -#define SIOC_IN 0x40000000 /* copy in parameters */ -#define SIOC_INOUT (SIOC_IN|SIOC_OUT) -/* the 0x20000000 is so we can distinguish new ioctl's from old */ -#define _SIO(x,y) ((int)(SIOC_VOID|(x<<8)|y)) -#define _SIOR(x,y,t) ((int)(SIOC_OUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y)) -#define _SIOW(x,y,t) ((int)(SIOC_IN|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y)) -/* this should be _SIORW, but stdio got there first */ -#define _SIOWR(x,y,t) ((int)(SIOC_INOUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y)) -#define _SIOC_SIZE(x) ((x>>16)&SIOCPARM_MASK) -#define _SIOC_DIR(x) (x & 0xf0000000) -#define _SIOC_NONE SIOC_VOID -#define _SIOC_READ SIOC_OUT -#define _SIOC_WRITE SIOC_IN -# endif /* _IOWR */ -#endif /* !_SIOWR */ - -#define SNDCTL_SEQ_RESET _SIO ('Q', 0) -#define SNDCTL_SEQ_SYNC _SIO ('Q', 1) -#define SNDCTL_SYNTH_INFO _SIOWR('Q', 2, struct synth_info) -#define SNDCTL_SEQ_CTRLRATE _SIOWR('Q', 3, int) /* Set/get timer resolution (HZ) */ -#define SNDCTL_SEQ_GETOUTCOUNT _SIOR ('Q', 4, int) -#define SNDCTL_SEQ_GETINCOUNT _SIOR ('Q', 5, int) -#define SNDCTL_SEQ_PERCMODE _SIOW ('Q', 6, int) -#define SNDCTL_FM_LOAD_INSTR _SIOW ('Q', 7, struct sbi_instrument) /* Obsolete. Don't use!!!!!! */ -#define SNDCTL_SEQ_TESTMIDI _SIOW ('Q', 8, int) -#define SNDCTL_SEQ_RESETSAMPLES _SIOW ('Q', 9, int) -#define SNDCTL_SEQ_NRSYNTHS _SIOR ('Q',10, int) -#define SNDCTL_SEQ_NRMIDIS _SIOR ('Q',11, int) -#define SNDCTL_MIDI_INFO _SIOWR('Q',12, struct midi_info) -#define SNDCTL_SEQ_THRESHOLD _SIOW ('Q',13, int) -#define SNDCTL_SYNTH_MEMAVL _SIOWR('Q',14, int) /* in=dev#, out=memsize */ -#define SNDCTL_FM_4OP_ENABLE _SIOW ('Q',15, int) /* in=dev# */ -#define SNDCTL_SEQ_PANIC _SIO ('Q',17) -#define SNDCTL_SEQ_OUTOFBAND _SIOW ('Q',18, struct seq_event_rec) -#define SNDCTL_SEQ_GETTIME _SIOR ('Q',19, int) -#define SNDCTL_SYNTH_ID _SIOWR('Q',20, struct synth_info) -#define SNDCTL_SYNTH_CONTROL _SIOWR('Q',21, struct synth_control) -#define SNDCTL_SYNTH_REMOVESAMPLE _SIOWR('Q',22, struct remove_sample) - -typedef struct synth_control -{ - int devno; /* Synthesizer # */ - char data[4000]; /* Device spesific command/data record */ -}synth_control; - -typedef struct remove_sample -{ - int devno; /* Synthesizer # */ - int bankno; /* MIDI bank # (0=General MIDI) */ - int instrno; /* MIDI instrument number */ -} remove_sample; - -typedef struct seq_event_rec { - unsigned char arr[8]; -} seq_event_rec; - -#define SNDCTL_TMR_TIMEBASE _SIOWR('T', 1, int) -#define SNDCTL_TMR_START _SIO ('T', 2) -#define SNDCTL_TMR_STOP _SIO ('T', 3) -#define SNDCTL_TMR_CONTINUE _SIO ('T', 4) -#define SNDCTL_TMR_TEMPO _SIOWR('T', 5, int) -#define SNDCTL_TMR_SOURCE _SIOWR('T', 6, int) -# define TMR_INTERNAL 0x00000001 -# define TMR_EXTERNAL 0x00000002 -# define TMR_MODE_MIDI 0x00000010 -# define TMR_MODE_FSK 0x00000020 -# define TMR_MODE_CLS 0x00000040 -# define TMR_MODE_SMPTE 0x00000080 -#define SNDCTL_TMR_METRONOME _SIOW ('T', 7, int) -#define SNDCTL_TMR_SELECT _SIOW ('T', 8, int) - -/* - * Some big endian/little endian handling macros - */ - -#if defined(_AIX) || defined(AIX) || defined(sparc) || defined(__sparc__) || defined(HPPA) || defined(PPC) -/* Big endian machines */ -# define _PATCHKEY(id) (0xfd00|id) -# define AFMT_S16_NE AFMT_S16_BE -#else -# define _PATCHKEY(id) ((id<<8)|0xfd) -# define AFMT_S16_NE AFMT_S16_LE -#endif - -/* - * Sample loading mechanism for internal synthesizers (/dev/sequencer) - * The following patch_info structure has been designed to support - * Gravis UltraSound. It tries to be universal format for uploading - * sample based patches but is probably too limited. - * - * (PBD) As Hannu guessed, the GUS structure is too limited for - * the WaveFront, but this is the right place for a constant definition. - */ - -struct patch_info { - unsigned short key; /* Use WAVE_PATCH here */ -#define WAVE_PATCH _PATCHKEY(0x04) -#define GUS_PATCH WAVE_PATCH -#define WAVEFRONT_PATCH _PATCHKEY(0x06) - - short device_no; /* Synthesizer number */ - short instr_no; /* Midi pgm# */ - - unsigned int mode; -/* - * The least significant byte has the same format than the GUS .PAT - * files - */ -#define WAVE_16_BITS 0x01 /* bit 0 = 8 or 16 bit wave data. */ -#define WAVE_UNSIGNED 0x02 /* bit 1 = Signed - Unsigned data. */ -#define WAVE_LOOPING 0x04 /* bit 2 = looping enabled-1. */ -#define WAVE_BIDIR_LOOP 0x08 /* bit 3 = Set is bidirectional looping. */ -#define WAVE_LOOP_BACK 0x10 /* bit 4 = Set is looping backward. */ -#define WAVE_SUSTAIN_ON 0x20 /* bit 5 = Turn sustaining on. (Env. pts. 3)*/ -#define WAVE_ENVELOPES 0x40 /* bit 6 = Enable envelopes - 1 */ -#define WAVE_FAST_RELEASE 0x80 /* bit 7 = Shut off immediately after note off */ - /* (use the env_rate/env_offs fields). */ -/* Linux specific bits */ -#define WAVE_VIBRATO 0x00010000 /* The vibrato info is valid */ -#define WAVE_TREMOLO 0x00020000 /* The tremolo info is valid */ -#define WAVE_SCALE 0x00040000 /* The scaling info is valid */ -#define WAVE_FRACTIONS 0x00080000 /* Fraction information is valid */ -/* Reserved bits */ -#define WAVE_ROM 0x40000000 /* For future use */ -#define WAVE_MULAW 0x20000000 /* For future use */ -/* Other bits must be zeroed */ - - int len; /* Size of the wave data in bytes */ - int loop_start, loop_end; /* Byte offsets from the beginning */ - -/* - * The base_freq and base_note fields are used when computing the - * playback speed for a note. The base_note defines the tone frequency - * which is heard if the sample is played using the base_freq as the - * playback speed. - * - * The low_note and high_note fields define the minimum and maximum note - * frequencies for which this sample is valid. It is possible to define - * more than one samples for an instrument number at the same time. The - * low_note and high_note fields are used to select the most suitable one. - * - * The fields base_note, high_note and low_note should contain - * the note frequency multiplied by 1000. For example value for the - * middle A is 440*1000. - */ - - unsigned int base_freq; - unsigned int base_note; - unsigned int high_note; - unsigned int low_note; - int panning; /* -128=left, 127=right */ - int detuning; - -/* New fields introduced in version 1.99.5 */ - - /* Envelope. Enabled by mode bit WAVE_ENVELOPES */ - unsigned char env_rate[ 6 ]; /* GUS HW ramping rate */ - unsigned char env_offset[ 6 ]; /* 255 == 100% */ - - /* - * The tremolo, vibrato and scale info are not supported yet. - * Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or - * WAVE_SCALE - */ - - unsigned char tremolo_sweep; - unsigned char tremolo_rate; - unsigned char tremolo_depth; - - unsigned char vibrato_sweep; - unsigned char vibrato_rate; - unsigned char vibrato_depth; - - int scale_frequency; - unsigned int scale_factor; /* from 0 to 2048 or 0 to 2 */ - - int volume; - int fractions; - int reserved1; - int spare[2]; - char data[1]; /* The waveform data starts here */ - }; - -struct sysex_info { - short key; /* Use SYSEX_PATCH or MAUI_PATCH here */ -#define SYSEX_PATCH _PATCHKEY(0x05) -#define MAUI_PATCH _PATCHKEY(0x06) - short device_no; /* Synthesizer number */ - int len; /* Size of the sysex data in bytes */ - unsigned char data[1]; /* Sysex data starts here */ - }; - -/* - * /dev/sequencer input events. - * - * The data written to the /dev/sequencer is a stream of events. Events - * are records of 4 or 8 bytes. The first byte defines the size. - * Any number of events can be written with a write call. There - * is a set of macros for sending these events. Use these macros if you - * want to maximize portability of your program. - * - * Events SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO. Are also input events. - * (All input events are currently 4 bytes long. Be prepared to support - * 8 byte events also. If you receive any event having first byte >= 128, - * it's a 8 byte event. - * - * The events are documented at the end of this file. - * - * Normal events (4 bytes) - * There is also a 8 byte version of most of the 4 byte events. The - * 8 byte one is recommended. - */ -#define SEQ_NOTEOFF 0 -#define SEQ_FMNOTEOFF SEQ_NOTEOFF /* Just old name */ -#define SEQ_NOTEON 1 -#define SEQ_FMNOTEON SEQ_NOTEON -#define SEQ_WAIT TMR_WAIT_ABS -#define SEQ_PGMCHANGE 3 -#define SEQ_FMPGMCHANGE SEQ_PGMCHANGE -#define SEQ_SYNCTIMER TMR_START -#define SEQ_MIDIPUTC 5 -#define SEQ_DRUMON 6 /*** OBSOLETE ***/ -#define SEQ_DRUMOFF 7 /*** OBSOLETE ***/ -#define SEQ_ECHO TMR_ECHO /* For synching programs with output */ -#define SEQ_AFTERTOUCH 9 -#define SEQ_CONTROLLER 10 - -/******************************************* - * Midi controller numbers - ******************************************* - * Controllers 0 to 31 (0x00 to 0x1f) and - * 32 to 63 (0x20 to 0x3f) are continuous - * controllers. - * In the MIDI 1.0 these controllers are sent using - * two messages. Controller numbers 0 to 31 are used - * to send the MSB and the controller numbers 32 to 63 - * are for the LSB. Note that just 7 bits are used in MIDI bytes. - */ - -#define CTL_BANK_SELECT 0x00 -#define CTL_MODWHEEL 0x01 -#define CTL_BREATH 0x02 -/* undefined 0x03 */ -#define CTL_FOOT 0x04 -#define CTL_PORTAMENTO_TIME 0x05 -#define CTL_DATA_ENTRY 0x06 -#define CTL_MAIN_VOLUME 0x07 -#define CTL_BALANCE 0x08 -/* undefined 0x09 */ -#define CTL_PAN 0x0a -#define CTL_EXPRESSION 0x0b -/* undefined 0x0c */ -/* undefined 0x0d */ -/* undefined 0x0e */ -/* undefined 0x0f */ -#define CTL_GENERAL_PURPOSE1 0x10 -#define CTL_GENERAL_PURPOSE2 0x11 -#define CTL_GENERAL_PURPOSE3 0x12 -#define CTL_GENERAL_PURPOSE4 0x13 -/* undefined 0x14 - 0x1f */ - -/* undefined 0x20 */ -/* The controller numbers 0x21 to 0x3f are reserved for the */ -/* least significant bytes of the controllers 0x00 to 0x1f. */ -/* These controllers are not recognised by the driver. */ - -/* Controllers 64 to 69 (0x40 to 0x45) are on/off switches. */ -/* 0=OFF and 127=ON (intermediate values are possible) */ -#define CTL_DAMPER_PEDAL 0x40 -#define CTL_SUSTAIN 0x40 /* Alias */ -#define CTL_HOLD 0x40 /* Alias */ -#define CTL_PORTAMENTO 0x41 -#define CTL_SOSTENUTO 0x42 -#define CTL_SOFT_PEDAL 0x43 -/* undefined 0x44 */ -#define CTL_HOLD2 0x45 -/* undefined 0x46 - 0x4f */ - -#define CTL_GENERAL_PURPOSE5 0x50 -#define CTL_GENERAL_PURPOSE6 0x51 -#define CTL_GENERAL_PURPOSE7 0x52 -#define CTL_GENERAL_PURPOSE8 0x53 -/* undefined 0x54 - 0x5a */ -#define CTL_EXT_EFF_DEPTH 0x5b -#define CTL_TREMOLO_DEPTH 0x5c -#define CTL_CHORUS_DEPTH 0x5d -#define CTL_DETUNE_DEPTH 0x5e -#define CTL_CELESTE_DEPTH 0x5e /* Alias for the above one */ -#define CTL_PHASER_DEPTH 0x5f -#define CTL_DATA_INCREMENT 0x60 -#define CTL_DATA_DECREMENT 0x61 -#define CTL_NONREG_PARM_NUM_LSB 0x62 -#define CTL_NONREG_PARM_NUM_MSB 0x63 -#define CTL_REGIST_PARM_NUM_LSB 0x64 -#define CTL_REGIST_PARM_NUM_MSB 0x65 -/* undefined 0x66 - 0x78 */ -/* reserved 0x79 - 0x7f */ - -/* Pseudo controllers (not midi compatible) */ -#define CTRL_PITCH_BENDER 255 -#define CTRL_PITCH_BENDER_RANGE 254 -#define CTRL_EXPRESSION 253 /* Obsolete */ -#define CTRL_MAIN_VOLUME 252 /* Obsolete */ -#define SEQ_BALANCE 11 -#define SEQ_VOLMODE 12 - -/* - * Volume mode decides how volumes are used - */ - -#define VOL_METHOD_ADAGIO 1 -#define VOL_METHOD_LINEAR 2 - -/* - * Note! SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO are used also as - * input events. - */ - -/* - * Event codes 0xf0 to 0xfc are reserved for future extensions. - */ - -#define SEQ_FULLSIZE 0xfd /* Long events */ -/* - * SEQ_FULLSIZE events are used for loading patches/samples to the - * synthesizer devices. These events are passed directly to the driver - * of the associated synthesizer device. There is no limit to the size - * of the extended events. These events are not queued but executed - * immediately when the write() is called (execution can take several - * seconds of time). - * - * When a SEQ_FULLSIZE message is written to the device, it must - * be written using exactly one write() call. Other events cannot - * be mixed to the same write. - * - * For FM synths (YM3812/OPL3) use struct sbi_instrument and write it to the - * /dev/sequencer. Don't write other data together with the instrument structure - * Set the key field of the structure to FM_PATCH. The device field is used to - * route the patch to the corresponding device. - * - * For wave table use struct patch_info. Initialize the key field - * to WAVE_PATCH. - */ -#define SEQ_PRIVATE 0xfe /* Low level HW dependent events (8 bytes) */ -#define SEQ_EXTENDED 0xff /* Extended events (8 bytes) OBSOLETE */ - -/* - * Record for FM patches - */ - -typedef unsigned char sbi_instr_data[32]; - -struct sbi_instrument { - unsigned short key; /* FM_PATCH or OPL3_PATCH */ -#define FM_PATCH _PATCHKEY(0x01) -#define OPL3_PATCH _PATCHKEY(0x03) - short device; /* Synth# (0-4) */ - int channel; /* Program# to be initialized */ - sbi_instr_data operators; /* Register settings for operator cells (.SBI format) */ - }; - -struct synth_info { /* Read only */ - char name[30]; - int device; /* 0-N. INITIALIZE BEFORE CALLING */ - int synth_type; -#define SYNTH_TYPE_FM 0 -#define SYNTH_TYPE_SAMPLE 1 -#define SYNTH_TYPE_MIDI 2 /* Midi interface */ - - int synth_subtype; -#define FM_TYPE_ADLIB 0x00 -#define FM_TYPE_OPL3 0x01 -#define MIDI_TYPE_MPU401 0x401 - -#define SAMPLE_TYPE_BASIC 0x10 -#define SAMPLE_TYPE_GUS SAMPLE_TYPE_BASIC -#define SAMPLE_TYPE_WAVEFRONT 0x11 - - int perc_mode; /* No longer supported */ - int nr_voices; - int nr_drums; /* Obsolete field */ - int instr_bank_size; - unsigned int capabilities; -#define SYNTH_CAP_PERCMODE 0x00000001 /* No longer used */ -#define SYNTH_CAP_OPL3 0x00000002 /* Set if OPL3 supported */ -#define SYNTH_CAP_INPUT 0x00000004 /* Input (MIDI) device */ - int dummies[19]; /* Reserve space */ - }; - -struct sound_timer_info { - char name[32]; - int caps; - }; - -#define MIDI_CAP_MPU401 1 /* MPU-401 intelligent mode */ - -struct midi_info { - char name[30]; - int device; /* 0-N. INITIALIZE BEFORE CALLING */ - unsigned int capabilities; /* To be defined later */ - int dev_type; - int dummies[18]; /* Reserve space */ - }; - -/******************************************** - * ioctl commands for the /dev/midi## - */ -typedef struct { - unsigned char cmd; - char nr_args, nr_returns; - unsigned char data[30]; - } mpu_command_rec; - -#define SNDCTL_MIDI_PRETIME _SIOWR('m', 0, int) -#define SNDCTL_MIDI_MPUMODE _SIOWR('m', 1, int) -#define SNDCTL_MIDI_MPUCMD _SIOWR('m', 2, mpu_command_rec) - -/******************************************** - * IOCTL commands for /dev/dsp and /dev/audio - */ - -#define SNDCTL_DSP_RESET _SIO ('P', 0) -#define SNDCTL_DSP_SYNC _SIO ('P', 1) -#define SNDCTL_DSP_SPEED _SIOWR('P', 2, int) -#define SNDCTL_DSP_STEREO _SIOWR('P', 3, int) -#define SNDCTL_DSP_GETBLKSIZE _SIOWR('P', 4, int) -#define SNDCTL_DSP_SAMPLESIZE SNDCTL_DSP_SETFMT -#define SNDCTL_DSP_CHANNELS _SIOWR('P', 6, int) -#define SOUND_PCM_WRITE_CHANNELS SNDCTL_DSP_CHANNELS -#define SOUND_PCM_WRITE_FILTER _SIOWR('P', 7, int) -#define SNDCTL_DSP_POST _SIO ('P', 8) -#define SNDCTL_DSP_SUBDIVIDE _SIOWR('P', 9, int) -#define SNDCTL_DSP_SETFRAGMENT _SIOWR('P',10, int) - -/* Audio data formats (Note! U8=8 and S16_LE=16 for compatibility) */ -#define SNDCTL_DSP_GETFMTS _SIOR ('P',11, int) /* Returns a mask */ -#define SNDCTL_DSP_SETFMT _SIOWR('P',5, int) /* Selects ONE fmt*/ -# define AFMT_QUERY 0x00000000 /* Return current fmt */ -# define AFMT_MU_LAW 0x00000001 -# define AFMT_A_LAW 0x00000002 -# define AFMT_IMA_ADPCM 0x00000004 -# define AFMT_U8 0x00000008 -# define AFMT_S16_LE 0x00000010 /* Little endian signed 16*/ -# define AFMT_S16_BE 0x00000020 /* Big endian signed 16 */ -# define AFMT_S8 0x00000040 -# define AFMT_U16_LE 0x00000080 /* Little endian U16 */ -# define AFMT_U16_BE 0x00000100 /* Big endian U16 */ -# define AFMT_MPEG 0x00000200 /* MPEG (2) audio */ -# define AFMT_AC3 0x00000400 /* Dolby Digital AC3 */ - -/* - * Buffer status queries. - */ -typedef struct audio_buf_info { - int fragments; /* # of available fragments (partially usend ones not counted) */ - int fragstotal; /* Total # of fragments allocated */ - int fragsize; /* Size of a fragment in bytes */ - - int bytes; /* Available space in bytes (includes partially used fragments) */ - /* Note! 'bytes' could be more than fragments*fragsize */ - } audio_buf_info; - -#define SNDCTL_DSP_GETOSPACE _SIOR ('P',12, audio_buf_info) -#define SNDCTL_DSP_GETISPACE _SIOR ('P',13, audio_buf_info) -#define SNDCTL_DSP_NONBLOCK _SIO ('P',14) -#define SNDCTL_DSP_GETCAPS _SIOR ('P',15, int) -# define DSP_CAP_REVISION 0x000000ff /* Bits for revision level (0 to 255) */ -# define DSP_CAP_DUPLEX 0x00000100 /* Full duplex record/playback */ -# define DSP_CAP_REALTIME 0x00000200 /* Real time capability */ -# define DSP_CAP_BATCH 0x00000400 /* Device has some kind of */ - /* internal buffers which may */ - /* cause some delays and */ - /* decrease precision of timing */ -# define DSP_CAP_COPROC 0x00000800 /* Has a coprocessor */ - /* Sometimes it's a DSP */ - /* but usually not */ -# define DSP_CAP_TRIGGER 0x00001000 /* Supports SETTRIGGER */ -# define DSP_CAP_MMAP 0x00002000 /* Supports mmap() */ -# define DSP_CAP_MULTI 0x00004000 /* support multiple open */ -# define DSP_CAP_BIND 0x00008000 /* channel binding to front/rear/cneter/lfe */ - - -#define SNDCTL_DSP_GETTRIGGER _SIOR ('P',16, int) -#define SNDCTL_DSP_SETTRIGGER _SIOW ('P',16, int) -# define PCM_ENABLE_INPUT 0x00000001 -# define PCM_ENABLE_OUTPUT 0x00000002 - -typedef struct count_info { - int bytes; /* Total # of bytes processed */ - int blocks; /* # of fragment transitions since last time */ - int ptr; /* Current DMA pointer value */ - } count_info; - -#define SNDCTL_DSP_GETIPTR _SIOR ('P',17, count_info) -#define SNDCTL_DSP_GETOPTR _SIOR ('P',18, count_info) - -typedef struct buffmem_desc { - unsigned *buffer; - int size; - } buffmem_desc; -#define SNDCTL_DSP_MAPINBUF _SIOR ('P', 19, buffmem_desc) -#define SNDCTL_DSP_MAPOUTBUF _SIOR ('P', 20, buffmem_desc) -#define SNDCTL_DSP_SETSYNCRO _SIO ('P', 21) -#define SNDCTL_DSP_SETDUPLEX _SIO ('P', 22) -#define SNDCTL_DSP_GETODELAY _SIOR ('P', 23, int) - -#define SNDCTL_DSP_GETCHANNELMASK _SIOWR('P', 64, int) -#define SNDCTL_DSP_BIND_CHANNEL _SIOWR('P', 65, int) -# define DSP_BIND_QUERY 0x00000000 -# define DSP_BIND_FRONT 0x00000001 -# define DSP_BIND_SURR 0x00000002 -# define DSP_BIND_CENTER_LFE 0x00000004 -# define DSP_BIND_HANDSET 0x00000008 -# define DSP_BIND_MIC 0x00000010 -# define DSP_BIND_MODEM1 0x00000020 -# define DSP_BIND_MODEM2 0x00000040 -# define DSP_BIND_I2S 0x00000080 -# define DSP_BIND_SPDIF 0x00000100 - -/* - * Application's profile defines the way how playback underrun situations should be handled. - * - * APF_NORMAL (the default) and APF_NETWORK make the driver to cleanup the - * playback buffer whenever an underrun occurs. This consumes some time - * prevents looping the existing buffer. - * APF_CPUINTENS is intended to be set by CPU intensive applications which - * are likely to run out of time occasionally. In this mode the buffer cleanup is - * disabled which saves CPU time but also let's the previous buffer content to - * be played during the "pause" after the underrun. - */ -#define SNDCTL_DSP_PROFILE _SIOW ('P', 23, int) -#define APF_NORMAL 0 /* Normal applications */ -#define APF_NETWORK 1 /* Underruns probably caused by an "external" delay */ -#define APF_CPUINTENS 2 /* Underruns probably caused by "overheating" the CPU */ - -#define SOUND_PCM_READ_RATE _SIOR ('P', 2, int) -#define SOUND_PCM_READ_CHANNELS _SIOR ('P', 6, int) -#define SOUND_PCM_READ_BITS _SIOR ('P', 5, int) -#define SOUND_PCM_READ_FILTER _SIOR ('P', 7, int) - -/* Some alias names */ -#define SOUND_PCM_WRITE_BITS SNDCTL_DSP_SETFMT -#define SOUND_PCM_WRITE_RATE SNDCTL_DSP_SPEED -#define SOUND_PCM_POST SNDCTL_DSP_POST -#define SOUND_PCM_RESET SNDCTL_DSP_RESET -#define SOUND_PCM_SYNC SNDCTL_DSP_SYNC -#define SOUND_PCM_SUBDIVIDE SNDCTL_DSP_SUBDIVIDE -#define SOUND_PCM_SETFRAGMENT SNDCTL_DSP_SETFRAGMENT -#define SOUND_PCM_GETFMTS SNDCTL_DSP_GETFMTS -#define SOUND_PCM_SETFMT SNDCTL_DSP_SETFMT -#define SOUND_PCM_GETOSPACE SNDCTL_DSP_GETOSPACE -#define SOUND_PCM_GETISPACE SNDCTL_DSP_GETISPACE -#define SOUND_PCM_NONBLOCK SNDCTL_DSP_NONBLOCK -#define SOUND_PCM_GETCAPS SNDCTL_DSP_GETCAPS -#define SOUND_PCM_GETTRIGGER SNDCTL_DSP_GETTRIGGER -#define SOUND_PCM_SETTRIGGER SNDCTL_DSP_SETTRIGGER -#define SOUND_PCM_SETSYNCRO SNDCTL_DSP_SETSYNCRO -#define SOUND_PCM_GETIPTR SNDCTL_DSP_GETIPTR -#define SOUND_PCM_GETOPTR SNDCTL_DSP_GETOPTR -#define SOUND_PCM_MAPINBUF SNDCTL_DSP_MAPINBUF -#define SOUND_PCM_MAPOUTBUF SNDCTL_DSP_MAPOUTBUF - -/* - * ioctl calls to be used in communication with coprocessors and - * DSP chips. - */ - -typedef struct copr_buffer { - int command; /* Set to 0 if not used */ - int flags; -#define CPF_NONE 0x0000 -#define CPF_FIRST 0x0001 /* First block */ -#define CPF_LAST 0x0002 /* Last block */ - int len; - int offs; /* If required by the device (0 if not used) */ - - unsigned char data[4000]; /* NOTE! 4000 is not 4k */ - } copr_buffer; - -typedef struct copr_debug_buf { - int command; /* Used internally. Set to 0 */ - int parm1; - int parm2; - int flags; - int len; /* Length of data in bytes */ - } copr_debug_buf; - -typedef struct copr_msg { - int len; - unsigned char data[4000]; - } copr_msg; - -#define SNDCTL_COPR_RESET _SIO ('C', 0) -#define SNDCTL_COPR_LOAD _SIOWR('C', 1, copr_buffer) -#define SNDCTL_COPR_RDATA _SIOWR('C', 2, copr_debug_buf) -#define SNDCTL_COPR_RCODE _SIOWR('C', 3, copr_debug_buf) -#define SNDCTL_COPR_WDATA _SIOW ('C', 4, copr_debug_buf) -#define SNDCTL_COPR_WCODE _SIOW ('C', 5, copr_debug_buf) -#define SNDCTL_COPR_RUN _SIOWR('C', 6, copr_debug_buf) -#define SNDCTL_COPR_HALT _SIOWR('C', 7, copr_debug_buf) -#define SNDCTL_COPR_SENDMSG _SIOWR('C', 8, copr_msg) -#define SNDCTL_COPR_RCVMSG _SIOR ('C', 9, copr_msg) - -/********************************************* - * IOCTL commands for /dev/mixer - */ - -/* - * Mixer devices - * - * There can be up to 20 different analog mixer channels. The - * SOUND_MIXER_NRDEVICES gives the currently supported maximum. - * The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells - * the devices supported by the particular mixer. - */ - -#define SOUND_MIXER_NRDEVICES 25 -#define SOUND_MIXER_VOLUME 0 -#define SOUND_MIXER_BASS 1 -#define SOUND_MIXER_TREBLE 2 -#define SOUND_MIXER_SYNTH 3 -#define SOUND_MIXER_PCM 4 -#define SOUND_MIXER_SPEAKER 5 -#define SOUND_MIXER_LINE 6 -#define SOUND_MIXER_MIC 7 -#define SOUND_MIXER_CD 8 -#define SOUND_MIXER_IMIX 9 /* Recording monitor */ -#define SOUND_MIXER_ALTPCM 10 -#define SOUND_MIXER_RECLEV 11 /* Recording level */ -#define SOUND_MIXER_IGAIN 12 /* Input gain */ -#define SOUND_MIXER_OGAIN 13 /* Output gain */ -/* - * The AD1848 codec and compatibles have three line level inputs - * (line, aux1 and aux2). Since each card manufacturer have assigned - * different meanings to these inputs, it's inpractical to assign - * specific meanings (line, cd, synth etc.) to them. - */ -#define SOUND_MIXER_LINE1 14 /* Input source 1 (aux1) */ -#define SOUND_MIXER_LINE2 15 /* Input source 2 (aux2) */ -#define SOUND_MIXER_LINE3 16 /* Input source 3 (line) */ -#define SOUND_MIXER_DIGITAL1 17 /* Digital (input) 1 */ -#define SOUND_MIXER_DIGITAL2 18 /* Digital (input) 2 */ -#define SOUND_MIXER_DIGITAL3 19 /* Digital (input) 3 */ -#define SOUND_MIXER_PHONEIN 20 /* Phone input */ -#define SOUND_MIXER_PHONEOUT 21 /* Phone output */ -#define SOUND_MIXER_VIDEO 22 /* Video/TV (audio) in */ -#define SOUND_MIXER_RADIO 23 /* Radio in */ -#define SOUND_MIXER_MONITOR 24 /* Monitor (usually mic) volume */ - -/* Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX) */ -/* Not counted to SOUND_MIXER_NRDEVICES, but use the same number space */ -#define SOUND_ONOFF_MIN 28 -#define SOUND_ONOFF_MAX 30 - -/* Note! Number 31 cannot be used since the sign bit is reserved */ -#define SOUND_MIXER_NONE 31 - -/* - * The following unsupported macros are no longer functional. - * Use SOUND_MIXER_PRIVATE# macros in future. - */ -#define SOUND_MIXER_ENHANCE SOUND_MIXER_NONE -#define SOUND_MIXER_MUTE SOUND_MIXER_NONE -#define SOUND_MIXER_LOUD SOUND_MIXER_NONE - - -#define SOUND_DEVICE_LABELS {"Vol ", "Bass ", "Trebl", "Synth", "Pcm ", "Spkr ", "Line ", \ - "Mic ", "CD ", "Mix ", "Pcm2 ", "Rec ", "IGain", "OGain", \ - "Line1", "Line2", "Line3", "Digital1", "Digital2", "Digital3", \ - "PhoneIn", "PhoneOut", "Video", "Radio", "Monitor"} - -#define SOUND_DEVICE_NAMES {"vol", "bass", "treble", "synth", "pcm", "speaker", "line", \ - "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \ - "line1", "line2", "line3", "dig1", "dig2", "dig3", \ - "phin", "phout", "video", "radio", "monitor"} - -/* Device bitmask identifiers */ - -#define SOUND_MIXER_RECSRC 0xff /* Arg contains a bit for each recording source */ -#define SOUND_MIXER_DEVMASK 0xfe /* Arg contains a bit for each supported device */ -#define SOUND_MIXER_RECMASK 0xfd /* Arg contains a bit for each supported recording source */ -#define SOUND_MIXER_CAPS 0xfc -# define SOUND_CAP_EXCL_INPUT 0x00000001 /* Only one recording source at a time */ -#define SOUND_MIXER_STEREODEVS 0xfb /* Mixer channels supporting stereo */ -#define SOUND_MIXER_OUTSRC 0xfa /* Arg contains a bit for each input source to output */ -#define SOUND_MIXER_OUTMASK 0xf9 /* Arg contains a bit for each supported input source to output */ - -/* Device mask bits */ - -#define SOUND_MASK_VOLUME (1 << SOUND_MIXER_VOLUME) -#define SOUND_MASK_BASS (1 << SOUND_MIXER_BASS) -#define SOUND_MASK_TREBLE (1 << SOUND_MIXER_TREBLE) -#define SOUND_MASK_SYNTH (1 << SOUND_MIXER_SYNTH) -#define SOUND_MASK_PCM (1 << SOUND_MIXER_PCM) -#define SOUND_MASK_SPEAKER (1 << SOUND_MIXER_SPEAKER) -#define SOUND_MASK_LINE (1 << SOUND_MIXER_LINE) -#define SOUND_MASK_MIC (1 << SOUND_MIXER_MIC) -#define SOUND_MASK_CD (1 << SOUND_MIXER_CD) -#define SOUND_MASK_IMIX (1 << SOUND_MIXER_IMIX) -#define SOUND_MASK_ALTPCM (1 << SOUND_MIXER_ALTPCM) -#define SOUND_MASK_RECLEV (1 << SOUND_MIXER_RECLEV) -#define SOUND_MASK_IGAIN (1 << SOUND_MIXER_IGAIN) -#define SOUND_MASK_OGAIN (1 << SOUND_MIXER_OGAIN) -#define SOUND_MASK_LINE1 (1 << SOUND_MIXER_LINE1) -#define SOUND_MASK_LINE2 (1 << SOUND_MIXER_LINE2) -#define SOUND_MASK_LINE3 (1 << SOUND_MIXER_LINE3) -#define SOUND_MASK_DIGITAL1 (1 << SOUND_MIXER_DIGITAL1) -#define SOUND_MASK_DIGITAL2 (1 << SOUND_MIXER_DIGITAL2) -#define SOUND_MASK_DIGITAL3 (1 << SOUND_MIXER_DIGITAL3) -#define SOUND_MASK_PHONEIN (1 << SOUND_MIXER_PHONEIN) -#define SOUND_MASK_PHONEOUT (1 << SOUND_MIXER_PHONEOUT) -#define SOUND_MASK_RADIO (1 << SOUND_MIXER_RADIO) -#define SOUND_MASK_VIDEO (1 << SOUND_MIXER_VIDEO) -#define SOUND_MASK_MONITOR (1 << SOUND_MIXER_MONITOR) - -/* Obsolete macros */ -#define SOUND_MASK_MUTE (1 << SOUND_MIXER_MUTE) -#define SOUND_MASK_ENHANCE (1 << SOUND_MIXER_ENHANCE) -#define SOUND_MASK_LOUD (1 << SOUND_MIXER_LOUD) - -#define MIXER_READ(dev) _SIOR('M', dev, int) -#define SOUND_MIXER_READ_VOLUME MIXER_READ(SOUND_MIXER_VOLUME) -#define SOUND_MIXER_READ_BASS MIXER_READ(SOUND_MIXER_BASS) -#define SOUND_MIXER_READ_TREBLE MIXER_READ(SOUND_MIXER_TREBLE) -#define SOUND_MIXER_READ_SYNTH MIXER_READ(SOUND_MIXER_SYNTH) -#define SOUND_MIXER_READ_PCM MIXER_READ(SOUND_MIXER_PCM) -#define SOUND_MIXER_READ_SPEAKER MIXER_READ(SOUND_MIXER_SPEAKER) -#define SOUND_MIXER_READ_LINE MIXER_READ(SOUND_MIXER_LINE) -#define SOUND_MIXER_READ_MIC MIXER_READ(SOUND_MIXER_MIC) -#define SOUND_MIXER_READ_CD MIXER_READ(SOUND_MIXER_CD) -#define SOUND_MIXER_READ_IMIX MIXER_READ(SOUND_MIXER_IMIX) -#define SOUND_MIXER_READ_ALTPCM MIXER_READ(SOUND_MIXER_ALTPCM) -#define SOUND_MIXER_READ_RECLEV MIXER_READ(SOUND_MIXER_RECLEV) -#define SOUND_MIXER_READ_IGAIN MIXER_READ(SOUND_MIXER_IGAIN) -#define SOUND_MIXER_READ_OGAIN MIXER_READ(SOUND_MIXER_OGAIN) -#define SOUND_MIXER_READ_LINE1 MIXER_READ(SOUND_MIXER_LINE1) -#define SOUND_MIXER_READ_LINE2 MIXER_READ(SOUND_MIXER_LINE2) -#define SOUND_MIXER_READ_LINE3 MIXER_READ(SOUND_MIXER_LINE3) - -/* Obsolete macros */ -#define SOUND_MIXER_READ_MUTE MIXER_READ(SOUND_MIXER_MUTE) -#define SOUND_MIXER_READ_ENHANCE MIXER_READ(SOUND_MIXER_ENHANCE) -#define SOUND_MIXER_READ_LOUD MIXER_READ(SOUND_MIXER_LOUD) - -#define SOUND_MIXER_READ_RECSRC MIXER_READ(SOUND_MIXER_RECSRC) -#define SOUND_MIXER_READ_DEVMASK MIXER_READ(SOUND_MIXER_DEVMASK) -#define SOUND_MIXER_READ_RECMASK MIXER_READ(SOUND_MIXER_RECMASK) -#define SOUND_MIXER_READ_STEREODEVS MIXER_READ(SOUND_MIXER_STEREODEVS) -#define SOUND_MIXER_READ_CAPS MIXER_READ(SOUND_MIXER_CAPS) - -#define MIXER_WRITE(dev) _SIOWR('M', dev, int) -#define SOUND_MIXER_WRITE_VOLUME MIXER_WRITE(SOUND_MIXER_VOLUME) -#define SOUND_MIXER_WRITE_BASS MIXER_WRITE(SOUND_MIXER_BASS) -#define SOUND_MIXER_WRITE_TREBLE MIXER_WRITE(SOUND_MIXER_TREBLE) -#define SOUND_MIXER_WRITE_SYNTH MIXER_WRITE(SOUND_MIXER_SYNTH) -#define SOUND_MIXER_WRITE_PCM MIXER_WRITE(SOUND_MIXER_PCM) -#define SOUND_MIXER_WRITE_SPEAKER MIXER_WRITE(SOUND_MIXER_SPEAKER) -#define SOUND_MIXER_WRITE_LINE MIXER_WRITE(SOUND_MIXER_LINE) -#define SOUND_MIXER_WRITE_MIC MIXER_WRITE(SOUND_MIXER_MIC) -#define SOUND_MIXER_WRITE_CD MIXER_WRITE(SOUND_MIXER_CD) -#define SOUND_MIXER_WRITE_IMIX MIXER_WRITE(SOUND_MIXER_IMIX) -#define SOUND_MIXER_WRITE_ALTPCM MIXER_WRITE(SOUND_MIXER_ALTPCM) -#define SOUND_MIXER_WRITE_RECLEV MIXER_WRITE(SOUND_MIXER_RECLEV) -#define SOUND_MIXER_WRITE_IGAIN MIXER_WRITE(SOUND_MIXER_IGAIN) -#define SOUND_MIXER_WRITE_OGAIN MIXER_WRITE(SOUND_MIXER_OGAIN) -#define SOUND_MIXER_WRITE_LINE1 MIXER_WRITE(SOUND_MIXER_LINE1) -#define SOUND_MIXER_WRITE_LINE2 MIXER_WRITE(SOUND_MIXER_LINE2) -#define SOUND_MIXER_WRITE_LINE3 MIXER_WRITE(SOUND_MIXER_LINE3) - -/* Obsolete macros */ -#define SOUND_MIXER_WRITE_MUTE MIXER_WRITE(SOUND_MIXER_MUTE) -#define SOUND_MIXER_WRITE_ENHANCE MIXER_WRITE(SOUND_MIXER_ENHANCE) -#define SOUND_MIXER_WRITE_LOUD MIXER_WRITE(SOUND_MIXER_LOUD) - -#define SOUND_MIXER_WRITE_RECSRC MIXER_WRITE(SOUND_MIXER_RECSRC) - -typedef struct mixer_info -{ - char id[16]; - char name[32]; - int modify_counter; - int fillers[10]; -} mixer_info; - -typedef struct _old_mixer_info /* Obsolete */ -{ - char id[16]; - char name[32]; -} _old_mixer_info; - -#define SOUND_MIXER_INFO _SIOR ('M', 101, mixer_info) -#define SOUND_OLD_MIXER_INFO _SIOR ('M', 101, _old_mixer_info) - -/* - * A mechanism for accessing "proprietary" mixer features. This method - * permits passing 128 bytes of arbitrary data between a mixer application - * and the mixer driver. Interpretation of the record is defined by - * the particular mixer driver. - */ -typedef unsigned char mixer_record[128]; - -#define SOUND_MIXER_ACCESS _SIOWR('M', 102, mixer_record) - -/* - * Two ioctls for special souncard function - */ -#define SOUND_MIXER_AGC _SIOWR('M', 103, int) -#define SOUND_MIXER_3DSE _SIOWR('M', 104, int) - -/* - * The SOUND_MIXER_PRIVATE# commands can be redefined by low level drivers. - * These features can be used when accessing device specific features. - */ -#define SOUND_MIXER_PRIVATE1 _SIOWR('M', 111, int) -#define SOUND_MIXER_PRIVATE2 _SIOWR('M', 112, int) -#define SOUND_MIXER_PRIVATE3 _SIOWR('M', 113, int) -#define SOUND_MIXER_PRIVATE4 _SIOWR('M', 114, int) -#define SOUND_MIXER_PRIVATE5 _SIOWR('M', 115, int) - -/* - * SOUND_MIXER_GETLEVELS and SOUND_MIXER_SETLEVELS calls can be used - * for querying current mixer settings from the driver and for loading - * default volume settings _prior_ activating the mixer (loading - * doesn't affect current state of the mixer hardware). These calls - * are for internal use only. - */ - -typedef struct mixer_vol_table { - int num; /* Index to volume table */ - char name[32]; - int levels[32]; -} mixer_vol_table; - -#define SOUND_MIXER_GETLEVELS _SIOWR('M', 116, mixer_vol_table) -#define SOUND_MIXER_SETLEVELS _SIOWR('M', 117, mixer_vol_table) - -/* - * An ioctl for identifying the driver version. It will return value - * of the SOUND_VERSION macro used when compiling the driver. - * This call was introduced in OSS version 3.6 and it will not work - * with earlier versions (returns EINVAL). - */ -#define OSS_GETVERSION _SIOR ('M', 118, int) - -/* - * Level 2 event types for /dev/sequencer - */ - -/* - * The 4 most significant bits of byte 0 specify the class of - * the event: - * - * 0x8X = system level events, - * 0x9X = device/port specific events, event[1] = device/port, - * The last 4 bits give the subtype: - * 0x02 = Channel event (event[3] = chn). - * 0x01 = note event (event[4] = note). - * (0x01 is not used alone but always with bit 0x02). - * event[2] = MIDI message code (0x80=note off etc.) - * - */ - -#define EV_SEQ_LOCAL 0x80 -#define EV_TIMING 0x81 -#define EV_CHN_COMMON 0x92 -#define EV_CHN_VOICE 0x93 -#define EV_SYSEX 0x94 -/* - * Event types 200 to 220 are reserved for application use. - * These numbers will not be used by the driver. - */ - -/* - * Events for event type EV_CHN_VOICE - */ - -#define MIDI_NOTEOFF 0x80 -#define MIDI_NOTEON 0x90 -#define MIDI_KEY_PRESSURE 0xA0 - -/* - * Events for event type EV_CHN_COMMON - */ - -#define MIDI_CTL_CHANGE 0xB0 -#define MIDI_PGM_CHANGE 0xC0 -#define MIDI_CHN_PRESSURE 0xD0 -#define MIDI_PITCH_BEND 0xE0 - -#define MIDI_SYSTEM_PREFIX 0xF0 - -/* - * Timer event types - */ -#define TMR_WAIT_REL 1 /* Time relative to the prev time */ -#define TMR_WAIT_ABS 2 /* Absolute time since TMR_START */ -#define TMR_STOP 3 -#define TMR_START 4 -#define TMR_CONTINUE 5 -#define TMR_TEMPO 6 -#define TMR_ECHO 8 -#define TMR_CLOCK 9 /* MIDI clock */ -#define TMR_SPP 10 /* Song position pointer */ -#define TMR_TIMESIG 11 /* Time signature */ - -/* - * Local event types - */ -#define LOCL_STARTAUDIO 1 - -#if (!defined(__KERNEL__) && !defined(KERNEL) && !defined(INKERNEL) && !defined(_KERNEL)) || defined(USE_SEQ_MACROS) -/* - * Some convenience macros to simplify programming of the - * /dev/sequencer interface - * - * These macros define the API which should be used when possible. - */ -#define SEQ_DECLAREBUF() SEQ_USE_EXTBUF() - -void seqbuf_dump(void); /* This function must be provided by programs */ - -extern int OSS_init(int seqfd, int buflen); -extern void OSS_seqbuf_dump(int fd, unsigned char *buf, int buflen); -extern void OSS_seq_advbuf(int len, int fd, unsigned char *buf, int buflen); -extern void OSS_seq_needbuf(int len, int fd, unsigned char *buf, int buflen); -extern void OSS_patch_caching(int dev, int chn, int patch, - int fd, unsigned char *buf, int buflen); -extern void OSS_drum_caching(int dev, int chn, int patch, - int fd, unsigned char *buf, int buflen); -extern void OSS_write_patch(int fd, unsigned char *buf, int len); -extern int OSS_write_patch2(int fd, unsigned char *buf, int len); - -#define SEQ_PM_DEFINES int __foo_bar___ -#ifdef OSSLIB -# define SEQ_USE_EXTBUF() \ - extern unsigned char *_seqbuf; \ - extern int _seqbuflen;extern int _seqbufptr -# define SEQ_DEFINEBUF(len) SEQ_USE_EXTBUF();static int _requested_seqbuflen=len -# define _SEQ_ADVBUF(len) OSS_seq_advbuf(len, seqfd, _seqbuf, _seqbuflen) -# define _SEQ_NEEDBUF(len) OSS_seq_needbuf(len, seqfd, _seqbuf, _seqbuflen) -# define SEQ_DUMPBUF() OSS_seqbuf_dump(seqfd, _seqbuf, _seqbuflen) - -# define SEQ_LOAD_GMINSTR(dev, instr) \ - OSS_patch_caching(dev, -1, instr, seqfd, _seqbuf, _seqbuflen) -# define SEQ_LOAD_GMDRUM(dev, drum) \ - OSS_drum_caching(dev, -1, drum, seqfd, _seqbuf, _seqbuflen) -#else /* !OSSLIB */ - -# define SEQ_LOAD_GMINSTR(dev, instr) -# define SEQ_LOAD_GMDRUM(dev, drum) - -# define SEQ_USE_EXTBUF() \ - extern unsigned char _seqbuf[]; \ - extern int _seqbuflen;extern int _seqbufptr - -#ifndef USE_SIMPLE_MACROS -/* Sample seqbuf_dump() implementation: - * - * SEQ_DEFINEBUF (2048); -- Defines a buffer for 2048 bytes - * - * int seqfd; -- The file descriptor for /dev/sequencer. - * - * void - * seqbuf_dump () - * { - * if (_seqbufptr) - * if (write (seqfd, _seqbuf, _seqbufptr) == -1) - * { - * perror ("write /dev/sequencer"); - * exit (-1); - * } - * _seqbufptr = 0; - * } - */ - -#define SEQ_DEFINEBUF(len) unsigned char _seqbuf[len]; int _seqbuflen = len;int _seqbufptr = 0 -#define _SEQ_NEEDBUF(len) if ((_seqbufptr+(len)) > _seqbuflen) seqbuf_dump() -#define _SEQ_ADVBUF(len) _seqbufptr += len -#define SEQ_DUMPBUF seqbuf_dump -#else -/* - * This variation of the sequencer macros is used just to format one event - * using fixed buffer. - * - * The program using the macro library must define the following macros before - * using this library. - * - * #define _seqbuf name of the buffer (unsigned char[]) - * #define _SEQ_ADVBUF(len) If the applic needs to know the exact - * size of the event, this macro can be used. - * Otherwise this must be defined as empty. - * #define _seqbufptr Define the name of index variable or 0 if - * not required. - */ -#define _SEQ_NEEDBUF(len) /* empty */ -#endif -#endif /* !OSSLIB */ - -#define SEQ_VOLUME_MODE(dev, mode) {_SEQ_NEEDBUF(8);\ - _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ - _seqbuf[_seqbufptr+1] = SEQ_VOLMODE;\ - _seqbuf[_seqbufptr+2] = (dev);\ - _seqbuf[_seqbufptr+3] = (mode);\ - _seqbuf[_seqbufptr+4] = 0;\ - _seqbuf[_seqbufptr+5] = 0;\ - _seqbuf[_seqbufptr+6] = 0;\ - _seqbuf[_seqbufptr+7] = 0;\ - _SEQ_ADVBUF(8);} - -/* - * Midi voice messages - */ - -#define _CHN_VOICE(dev, event, chn, note, parm) \ - {_SEQ_NEEDBUF(8);\ - _seqbuf[_seqbufptr] = EV_CHN_VOICE;\ - _seqbuf[_seqbufptr+1] = (dev);\ - _seqbuf[_seqbufptr+2] = (event);\ - _seqbuf[_seqbufptr+3] = (chn);\ - _seqbuf[_seqbufptr+4] = (note);\ - _seqbuf[_seqbufptr+5] = (parm);\ - _seqbuf[_seqbufptr+6] = (0);\ - _seqbuf[_seqbufptr+7] = 0;\ - _SEQ_ADVBUF(8);} - -#define SEQ_START_NOTE(dev, chn, note, vol) \ - _CHN_VOICE(dev, MIDI_NOTEON, chn, note, vol) - -#define SEQ_STOP_NOTE(dev, chn, note, vol) \ - _CHN_VOICE(dev, MIDI_NOTEOFF, chn, note, vol) - -#define SEQ_KEY_PRESSURE(dev, chn, note, pressure) \ - _CHN_VOICE(dev, MIDI_KEY_PRESSURE, chn, note, pressure) - -/* - * Midi channel messages - */ - -#define _CHN_COMMON(dev, event, chn, p1, p2, w14) \ - {_SEQ_NEEDBUF(8);\ - _seqbuf[_seqbufptr] = EV_CHN_COMMON;\ - _seqbuf[_seqbufptr+1] = (dev);\ - _seqbuf[_seqbufptr+2] = (event);\ - _seqbuf[_seqbufptr+3] = (chn);\ - _seqbuf[_seqbufptr+4] = (p1);\ - _seqbuf[_seqbufptr+5] = (p2);\ - *(short *)&_seqbuf[_seqbufptr+6] = (w14);\ - _SEQ_ADVBUF(8);} -/* - * SEQ_SYSEX permits sending of sysex messages. (It may look that it permits - * sending any MIDI bytes but it's absolutely not possible. Trying to do - * so _will_ cause problems with MPU401 intelligent mode). - * - * Sysex messages are sent in blocks of 1 to 6 bytes. Longer messages must be - * sent by calling SEQ_SYSEX() several times (there must be no other events - * between them). First sysex fragment must have 0xf0 in the first byte - * and the last byte (buf[len-1] of the last fragment must be 0xf7. No byte - * between these sysex start and end markers cannot be larger than 0x7f. Also - * lengths of each fragments (except the last one) must be 6. - * - * Breaking the above rules may work with some MIDI ports but is likely to - * cause fatal problems with some other devices (such as MPU401). - */ -#define SEQ_SYSEX(dev, buf, len) \ - {int ii, ll=(len); \ - unsigned char *bufp=buf;\ - if (ll>6)ll=6;\ - _SEQ_NEEDBUF(8);\ - _seqbuf[_seqbufptr] = EV_SYSEX;\ - _seqbuf[_seqbufptr+1] = (dev);\ - for(ii=0;ii>8)&0xff);\ - _seqbuf[_seqbufptr+7] = 0;\ - _SEQ_ADVBUF(8);} -/* - * The following 5 macros are incorrectly implemented and obsolete. - * Use SEQ_BENDER and SEQ_CONTROL (with proper controller) instead. - */ -#define SEQ_PITCHBEND(dev, voice, value) SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER, value) -#define SEQ_BENDER_RANGE(dev, voice, value) SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER_RANGE, value) -#define SEQ_EXPRESSION(dev, voice, value) SEQ_CONTROL(dev, voice, CTL_EXPRESSION, value*128) -#define SEQ_MAIN_VOLUME(dev, voice, value) SEQ_CONTROL(dev, voice, CTL_MAIN_VOLUME, (value*16383)/100) -#define SEQ_PANNING(dev, voice, pos) SEQ_CONTROL(dev, voice, CTL_PAN, (pos+128) / 2) - -/* - * Timing and syncronization macros - */ - -#define _TIMER_EVENT(ev, parm) {_SEQ_NEEDBUF(8);\ - _seqbuf[_seqbufptr+0] = EV_TIMING; \ - _seqbuf[_seqbufptr+1] = (ev); \ - _seqbuf[_seqbufptr+2] = 0;\ - _seqbuf[_seqbufptr+3] = 0;\ - *(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \ - _SEQ_ADVBUF(8);} - -#define SEQ_START_TIMER() _TIMER_EVENT(TMR_START, 0) -#define SEQ_STOP_TIMER() _TIMER_EVENT(TMR_STOP, 0) -#define SEQ_CONTINUE_TIMER() _TIMER_EVENT(TMR_CONTINUE, 0) -#define SEQ_WAIT_TIME(ticks) _TIMER_EVENT(TMR_WAIT_ABS, ticks) -#define SEQ_DELTA_TIME(ticks) _TIMER_EVENT(TMR_WAIT_REL, ticks) -#define SEQ_ECHO_BACK(key) _TIMER_EVENT(TMR_ECHO, key) -#define SEQ_SET_TEMPO(value) _TIMER_EVENT(TMR_TEMPO, value) -#define SEQ_SONGPOS(pos) _TIMER_EVENT(TMR_SPP, pos) -#define SEQ_TIME_SIGNATURE(sig) _TIMER_EVENT(TMR_TIMESIG, sig) - -/* - * Local control events - */ - -#define _LOCAL_EVENT(ev, parm) {_SEQ_NEEDBUF(8);\ - _seqbuf[_seqbufptr+0] = EV_SEQ_LOCAL; \ - _seqbuf[_seqbufptr+1] = (ev); \ - _seqbuf[_seqbufptr+2] = 0;\ - _seqbuf[_seqbufptr+3] = 0;\ - *(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \ - _SEQ_ADVBUF(8);} - -#define SEQ_PLAYAUDIO(devmask) _LOCAL_EVENT(LOCL_STARTAUDIO, devmask) -/* - * Events for the level 1 interface only - */ - -#define SEQ_MIDIOUT(device, byte) {_SEQ_NEEDBUF(4);\ - _seqbuf[_seqbufptr] = SEQ_MIDIPUTC;\ - _seqbuf[_seqbufptr+1] = (byte);\ - _seqbuf[_seqbufptr+2] = (device);\ - _seqbuf[_seqbufptr+3] = 0;\ - _SEQ_ADVBUF(4);} - -/* - * Patch loading. - */ -#ifdef OSSLIB -# define SEQ_WRPATCH(patchx, len) \ - OSS_write_patch(seqfd, (char*)(patchx), len) -# define SEQ_WRPATCH2(patchx, len) \ - OSS_write_patch2(seqfd, (char*)(patchx), len) -#else -# define SEQ_WRPATCH(patchx, len) \ - {if (_seqbufptr) SEQ_DUMPBUF();\ - if (write(seqfd, (char*)(patchx), len)==-1) \ - perror("Write patch: /dev/sequencer");} -# define SEQ_WRPATCH2(patchx, len) \ - (SEQ_DUMPBUF(), write(seqfd, (char*)(patchx), len)) -#endif - -#endif -#endif diff --git a/winsup/cygwin/include/sys/statfs.h b/winsup/cygwin/include/sys/statfs.h deleted file mode 100644 index 51ad3c6b1..000000000 --- a/winsup/cygwin/include/sys/statfs.h +++ /dev/null @@ -1,11 +0,0 @@ -/* sys/statfs.h - - Copyright 2002 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include diff --git a/winsup/cygwin/include/sys/statvfs.h b/winsup/cygwin/include/sys/statvfs.h deleted file mode 100644 index aa86674af..000000000 --- a/winsup/cygwin/include/sys/statvfs.h +++ /dev/null @@ -1,44 +0,0 @@ -/* sys/statvfs.h - - Copyright 2005 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SYS_STATVFS_H_ -#define _SYS_STATVFS_H_ - -#include - -#define ST_RDONLY 0x80000 /* equals FILE_READ_ONLY_VOLUME */ -#define ST_NOSUID 0 /* Looking for that bit should always fail. */ - -struct statvfs { - unsigned long f_bsize; /* file system block size */ - unsigned long f_frsize; /* fragment size */ - fsblkcnt_t f_blocks; /* size of fs in f_frsize units */ - fsblkcnt_t f_bfree; /* free blocks in fs */ - fsblkcnt_t f_bavail; /* free blocks avail to non-superuser */ - fsfilcnt_t f_files; /* total file nodes in file system */ - fsfilcnt_t f_ffree; /* free file nodes in fs */ - fsfilcnt_t f_favail; /* avail file nodes in fs */ - unsigned long f_fsid; /* file system id */ - unsigned long f_flag; /* mount flags */ - unsigned long f_namemax; /* maximum length of filenames */ -}; - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -int statvfs (const char *__path, struct statvfs *__buf); -int fstatvfs (int __fd, struct statvfs *__buf); - -#ifdef __cplusplus -}; -#endif /* __cplusplus */ - -#endif /*_SYS_STATVFS_H_*/ diff --git a/winsup/cygwin/include/sys/stdio.h b/winsup/cygwin/include/sys/stdio.h deleted file mode 100644 index 7aa46a000..000000000 --- a/winsup/cygwin/include/sys/stdio.h +++ /dev/null @@ -1,44 +0,0 @@ -/* sys/stdio.h - - Copyright 2004, 2005 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SYS_STDIO_H_ -#define _SYS_STDIO_H_ - -#include -#include - -/* These definitions should be kept in sync with those in the newlib - header of the same name (newlib/libc/include/sys/stdio.h). */ - -#if !defined(__SINGLE_THREAD__) -# if !defined(_flockfile) -# define _flockfile(fp) ({ if (!((fp)->_flags & __SSTR)) \ - __cygwin_lock_lock ((_LOCK_T *)&(fp)->_lock); }) -# endif -# if !defined(_ftrylockfile) -# define _ftrylockfile(fp) (((fp)->_flags & __SSTR) ? 0 : \ - __cygwin_lock_trylock ((_LOCK_T *)&(fp)->_lock)) -# endif -# if !defined(_funlockfile) -# define _funlockfile(fp) ({ if (!((fp)->_flags & __SSTR)) \ - __cygwin_lock_unlock ((_LOCK_T *)&(fp)->_lock); }) -# endif -#endif - -__BEGIN_DECLS - -#ifdef _GNU_SOURCE -ssize_t _EXFUN(getline, (char **, size_t *, FILE *)); -ssize_t _EXFUN(getdelim, (char **, size_t *, int, FILE *)); -#endif /* _GNU_SOURCE */ - -__END_DECLS - -#endif diff --git a/winsup/cygwin/include/sys/strace.h b/winsup/cygwin/include/sys/strace.h deleted file mode 100644 index 4685e5f36..000000000 --- a/winsup/cygwin/include/sys/strace.h +++ /dev/null @@ -1,156 +0,0 @@ -/* sys/strace.h - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* This file contains routines for tracing system calls and other internal - phenomenon. - - When tracing system calls, try to use the same style throughout: - - result = syscall (arg1, arg2, arg3) [optional extra stuff] - - If a system call can block (eg: read, write, wait), print another message - before hanging so the user will know why the program has stopped. - - Note: __seterrno will also print a trace message. Have that printed - *first*. This will make it easy to always know what __seterrno is - refering to. For the same reason, try not to have __seterrno messages - printed alone. -*/ - -#ifndef _SYS_STRACE_H -#define _SYS_STRACE_H - -#include - -#ifdef __cplusplus - -class child_info; -class strace -{ - int vsprntf (char *buf, const char *func, const char *infmt, va_list ap); - void write (unsigned category, const char *buf, int count); - unsigned char _active; -public: - strace (); - int microseconds (); - int version; - int lmicrosec; - bool execing; - void hello () __attribute__ ((regparm (1))); - void prntf (unsigned, const char *func, const char *, ...) /*__attribute__ ((regparm(3)))*/; - void vprntf (unsigned, const char *func, const char *, va_list ap) /*__attribute__ ((regparm(3)))*/; - void wm (int message, int word, int lon) __attribute__ ((regparm(3))); - void write_childpid (child_info&, unsigned long) __attribute__ ((regparm (2))); - bool attached () const {return _active == 3;} - bool active () const {return _active & 1;} - unsigned char& active_val () {return _active;} -}; - -extern strace strace; - -#endif /* __cplusplus */ - -#define _STRACE_INTERFACE_ACTIVATE_ADDR -1 -#define _STRACE_INTERFACE_ACTIVATE_ADDR1 -2 -#define _STRACE_CHILD_PID -3 - -/* Bitmasks of tracing messages to print. */ - -#define _STRACE_ALL 0x00001 // so behaviour of strace=1 is unchanged -#define _STRACE_FLUSH 0x00002 // flush output buffer after every message -#define _STRACE_INHERIT 0x00004 // children inherit mask from parent -#define _STRACE_UHOH 0x00008 // unusual or weird phenomenon -#define _STRACE_SYSCALL 0x00010 // system calls -#define _STRACE_STARTUP 0x00020 // argc/envp printout at startup -#define _STRACE_DEBUG 0x00040 // info to help debugging -#define _STRACE_PARANOID 0x00080 // paranoid info -#define _STRACE_TERMIOS 0x00100 // info for debugging termios stuff -#define _STRACE_SELECT 0x00200 // info on ugly select internals -#define _STRACE_WM 0x00400 // trace windows messages (enable _strace_wm) -#define _STRACE_SIGP 0x00800 // trace signal and process handling -#define _STRACE_MINIMAL 0x01000 // very minimal strace output -#define _STRACE_EXITDUMP 0x04000 // dump strace cache on exit -#define _STRACE_SYSTEM 0x08000 // cache strace messages -#define _STRACE_NOMUTEX 0x10000 // don't use mutex for synchronization -#define _STRACE_MALLOC 0x20000 // trace malloc calls -#define _STRACE_THREAD 0x40000 // thread-locking calls -#define _STRACE_NOTALL 0x80000 // don't include if _STRACE_ALL - -#ifdef __cplusplus -extern "C" { -#endif - -void small_printf (const char *, ...); -void strace_printf (unsigned, const char *func, const char *, ...); - -#ifdef __cplusplus -} -#endif - -#ifdef __cplusplus - -#ifdef NOSTRACE -#define define_strace(c, f) -#define define_strace1(c, f) -#else -#ifdef NEW_MACRO_VARARGS -/* Output message to strace log */ - -#define define_strace0(c,...) \ - do { \ - if ((c & _STRACE_SYSTEM) || strace.active ()) \ - strace.prntf (c, __PRETTY_FUNCTION__, __VA_ARGS__); \ - } \ - while (0) - -#define define_strace(c, ...) define_strace0 (_STRACE_ ## c, __VA_ARGS__) -#define define_strace1(c, ...) define_strace0 ((_STRACE_ ## c | _STRACE_NOTALL), __VA_ARGS__) - -#define debug_printf(...) define_strace (DEBUG, __VA_ARGS__) -#define paranoid_printf(...) define_strace1 (PARANOID, __VA_ARGS__) -#define select_printf(...) define_strace (SELECT, __VA_ARGS__) -#define sigproc_printf(...) define_strace (SIGP, __VA_ARGS__) -#define syscall_printf(...) define_strace (SYSCALL, __VA_ARGS__) -#define system_printf(...) define_strace (SYSTEM, __VA_ARGS__) -#define termios_printf(...) define_strace (TERMIOS, __VA_ARGS__) -#define wm_printf(...) define_strace (WM, __VA_ARGS__) -#define minimal_printf(...) define_strace1 (MINIMAL, __VA_ARGS__) -#define malloc_printf(...) define_strace1 (MALLOC, __VA_ARGS__) -#define thread_printf(...) define_strace1 (THREAD, __VA_ARGS__) -#else -#define strace_printf_wrap(what, fmt, args...) \ - ((void) ({\ - if ((_STRACE_ ## what & _STRACE_SYSTEM) || strace.active ()) \ - strace.prntf(_STRACE_ ## what, __PRETTY_FUNCTION__, fmt, ## args); \ - 0; \ - })) -#define strace_printf_wrap1(what, fmt, args...) \ - ((void) ({\ - if ((_STRACE_ ## what & _STRACE_SYSTEM) || strace.active ()) \ - strace.prntf((_STRACE_ ## what) | _STRACE_NOTALL, __PRETTY_FUNCTION__, fmt, ## args); \ - 0; \ - })) - -#define debug_printf(fmt, args...) strace_printf_wrap(DEBUG, fmt , ## args) -#define paranoid_printf(fmt, args...) strace_printf_wrap1(PARANOID, fmt , ## args) -#define select_printf(fmt, args...) strace_printf_wrap(SELECT, fmt , ## args) -#define sigproc_printf(fmt, args...) strace_printf_wrap(SIGP, fmt , ## args) -#define syscall_printf(fmt, args...) strace_printf_wrap(SYSCALL, fmt , ## args) -#define system_printf(fmt, args...) strace_printf_wrap(SYSTEM, fmt , ## args) -#define termios_printf(fmt, args...) strace_printf_wrap(TERMIOS, fmt , ## args) -#define wm_printf(fmt, args...) strace_printf_wrap(WM, fmt , ## args) -#define minimal_printf(fmt, args...) strace_printf_wrap1(MINIMAL, fmt , ## args) -#define malloc_printf(fmt, args...) strace_printf_wrap1(MALLOC, fmt , ## args) -#define thread_printf(fmt, args...) strace_printf_wrap1(THREAD, fmt , ## args) -#endif /*NEW_MACRO_VARARGS*/ -#endif /*NOSTRACE*/ -#endif /* __cplusplus */ -#endif /* _SYS_STRACE_H */ diff --git a/winsup/cygwin/include/sys/sysinfo.h b/winsup/cygwin/include/sys/sysinfo.h deleted file mode 100644 index 1e24c860a..000000000 --- a/winsup/cygwin/include/sys/sysinfo.h +++ /dev/null @@ -1,27 +0,0 @@ -/* sys/sysinfo.h - - Copyright 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* sys/sysinfo.h header file for Cygwin. */ - -#ifndef _SYS_SYSINFO_H -#define _SYS_SYSINFO_H - -#include - -__BEGIN_DECLS - -extern int get_nprocs_conf (void); -extern int get_nprocs (void); -extern long get_phys_pages (void); -extern long get_avphys_pages (void); - -__END_DECLS - -#endif /* _SYS_SYSINFO_H */ diff --git a/winsup/cygwin/include/sys/syslimits.h b/winsup/cygwin/include/sys/syslimits.h deleted file mode 100644 index b501de81e..000000000 --- a/winsup/cygwin/include/sys/syslimits.h +++ /dev/null @@ -1,20 +0,0 @@ -/* sys/syslimits.h - - Copyright 2006 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SYS_SYSLIMITS_H -#define _SYS_SYSLIMITS_H - -#ifdef _COMPILING_NEWLIB -# include -#else -# error "Do not include sys/syslimits.h from applications directly." -#endif - -#endif /*_SYS_SYSLIMITS_H */ diff --git a/winsup/cygwin/include/sys/syslog.h b/winsup/cygwin/include/sys/syslog.h deleted file mode 100644 index d7279d3be..000000000 --- a/winsup/cygwin/include/sys/syslog.h +++ /dev/null @@ -1,143 +0,0 @@ -/* sys/syslog.h - - Copyright 1996, 1998, 2001, 2005 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SYS_LOG_H -#define _SYS_LOG_H - -#include -#include - -#define _PATH_LOG "/dev/log" -#define _PATH_KLOG "/dev/kmsg" - -#define LOG_EMERG 0 -#define LOG_ALERT 1 -#define LOG_CRIT 2 -#define LOG_ERR 3 -#define LOG_WARNING 4 -#define LOG_NOTICE 5 -#define LOG_INFO 6 -#define LOG_DEBUG 7 - -#define LOG_PRIMASK 0x07 - -#define LOG_PRI(p) ((p) & LOG_PRIMASK) -#define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri)) - -#define LOG_KERN (0<<3) -#define LOG_USER (1<<3) -#define LOG_MAIL (2<<3) -#define LOG_DAEMON (3<<3) -#define LOG_AUTH (4<<3) -#define LOG_SYSLOG (5<<3) -#define LOG_LPR (6<<3) -#define LOG_NEWS (7<<3) -#define LOG_UUCP (8<<3) -#define LOG_CRON (9<<3) -#define LOG_AUTHPRIV (10<<3) -#define LOG_FTP (11<<3) - -/* Codes through 15 are reserved for system use */ -#define LOG_LOCAL0 (16<<3) -#define LOG_LOCAL1 (17<<3) -#define LOG_LOCAL2 (18<<3) -#define LOG_LOCAL3 (19<<3) -#define LOG_LOCAL4 (20<<3) -#define LOG_LOCAL5 (21<<3) -#define LOG_LOCAL6 (22<<3) -#define LOG_LOCAL7 (23<<3) - -#define LOG_NFACILITIES 24 -#define LOG_FACMASK 0x03f8 -#define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) - -#ifdef SYSLOG_NAMES - -#define INTERNAL_NOPRI 0x10 /* Maps to "none" */ -#define INTERNAL_MARK LOG_MAKEPRI(LOG_NFACILITIES, 0) /* Maps to "mark" */ - -typedef struct _code { - char *c_name; - int c_val; -} CODE; - -CODE prioritynames[] = { - { "alert", LOG_ALERT }, - { "crit", LOG_CRIT }, - { "debug", LOG_DEBUG }, - { "emerg", LOG_EMERG }, - { "err", LOG_ERR }, - { "error", LOG_ERR }, /* Deprecated */ - { "info", LOG_INFO }, - { "none", INTERNAL_NOPRI }, - { "notice", LOG_NOTICE }, - { "panic", LOG_EMERG }, /* Deprecated */ - { "warn", LOG_WARNING }, /* Deprecated */ - { "warning", LOG_WARNING }, - { NULL, -1 } -}; - -CODE facilitynames[] = { - { "auth", LOG_AUTH }, - { "authpriv", LOG_AUTHPRIV }, - { "cron", LOG_CRON }, - { "daemon", LOG_DAEMON }, - { "ftp", LOG_FTP }, - { "kern", LOG_KERN }, - { "lpr", LOG_LPR }, - { "mail", LOG_MAIL }, - { "mark", INTERNAL_MARK }, - { "news", LOG_NEWS }, - { "security", LOG_AUTH }, /* Deprecated */ - { "syslog", LOG_SYSLOG }, - { "user", LOG_USER }, - { "uucp", LOG_UUCP }, - { "local0", LOG_LOCAL0 }, - { "local1", LOG_LOCAL1 }, - { "local2", LOG_LOCAL2 }, - { "local3", LOG_LOCAL3 }, - { "local4", LOG_LOCAL4 }, - { "local5", LOG_LOCAL5 }, - { "local6", LOG_LOCAL6 }, - { "local7", LOG_LOCAL7 }, - { NULL, -1 } -}; - -#endif /* SYSLOG_NAMES */ - -#define LOG_MASK(pri) (1 << (pri)) -#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) - -/* - * Option flags for openlog. - * - * LOG_ODELAY no longer does anything. - * LOG_NDELAY is the inverse of what it used to be. - */ -#define LOG_PID 0x01 /* log the pid with each message */ -#define LOG_CONS 0x02 /* log on the console if errors in sending */ -#define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */ -#define LOG_NDELAY 0x08 /* don't delay open */ -#define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */ -#define LOG_PERROR 0x20 /* log to stderr as well */ - -__BEGIN_DECLS - - -void closelog (void); -void openlog (const char *, int, int); -int setlogmask (int); -void syslog (int, const char *, ...); -void vsyslog (int, const char *, va_list ap); - -__END_DECLS - - -#endif /* _SYS_LOG_H */ diff --git a/winsup/cygwin/include/sys/sysmacros.h b/winsup/cygwin/include/sys/sysmacros.h deleted file mode 100644 index 2c9c69923..000000000 --- a/winsup/cygwin/include/sys/sysmacros.h +++ /dev/null @@ -1,24 +0,0 @@ -/* sys/sysmacros.h - - Copyright 1998, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SYS_SYSMACROS_H -#define _SYS_SYSMACROS_H - -#ifdef __CYGWIN_USE_BIG_TYPES__ -#define major(dev) ((int)(((dev) >> 16) & 0xffff)) -#define minor(dev) ((int)((dev) & 0xffff)) -#define makedev(major, minor) (((major) << 16) | ((minor) & 0xffff)) -#else -#define major(dev) ((int)(((dev) >> 8) & 0xff)) -#define minor(dev) ((int)((dev) & 0xff)) -#define makedev(major, minor) (((major) << 8) | ((minor) & 0xff)) -#endif - -#endif /* _SYS_SYSMACROS_H */ diff --git a/winsup/cygwin/include/sys/sysproto.h b/winsup/cygwin/include/sys/sysproto.h deleted file mode 100644 index 488782b89..000000000 --- a/winsup/cygwin/include/sys/sysproto.h +++ /dev/null @@ -1,18 +0,0 @@ -/* sys/sysproto.h - - Copyright 2003 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* sys/sysproto.h header file for Cygwin. */ - -#ifndef _SYS_SYSPROTO_H -#define _SYS_SYSPROTO_H - -#include - -#endif /* _SYS_SYSPROTO_H */ diff --git a/winsup/cygwin/include/sys/termio.h b/winsup/cygwin/include/sys/termio.h deleted file mode 100644 index 87f2eb461..000000000 --- a/winsup/cygwin/include/sys/termio.h +++ /dev/null @@ -1,12 +0,0 @@ -/* sys/termio.h - - Copyright 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include - diff --git a/winsup/cygwin/include/sys/termios.h b/winsup/cygwin/include/sys/termios.h deleted file mode 100644 index c81d820ac..000000000 --- a/winsup/cygwin/include/sys/termios.h +++ /dev/null @@ -1,352 +0,0 @@ -/* sys/termios.h - - Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, - 2007 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* sys/termios.h */ - -#ifndef _SYS_TERMIOS_H -#define _SYS_TERMIOS_H - -#define TIOCMGET 0x5415 -#define TIOCMBIS 0x5416 -#define TIOCMBIC 0x5417 -#define TIOCMSET 0x5418 -#define TIOCINQ 0x541B - -/* TIOCINQ is utilized instead of FIONREAD which has been -accupied for other purposes under CYGWIN. -Other UNIX ioctl requests has been omited because -effects of their work one can achive by standard -POSIX commands */ - -#define TIOCSBRK 0x5427 -#define TIOCCBRK 0x5428 - -#define TIOCM_DTR 0x002 -#define TIOCM_RTS 0x004 -#define TIOCM_CTS 0x020 -#define TIOCM_CAR 0x040 -#define TIOCM_RNG 0x080 -#define TIOCM_DSR 0x100 -#define TIOCM_CD TIOCM_CAR -#define TIOCM_RI TIOCM_RNG - -#define TCOOFF 0 -#define TCOON 1 -#define TCIOFF 2 -#define TCION 3 - -#define TCGETA 5 -#define TCSETA 6 -#define TCSETAW 7 -#define TCSETAF 8 - -#define TCIFLUSH 0 -#define TCOFLUSH 1 -#define TCIOFLUSH 2 -#define TCFLSH 3 - -#define TCSAFLUSH 1 -#define TCSANOW 2 -#define TCSADRAIN 3 -#define TCSADFLUSH 4 - -#define TIOCPKT 6 - -#define TIOCPKT_DATA 0 -#define TIOCPKT_FLUSHREAD 1 -#define TIOCPKT_FLUSHWRITE 2 -#define TIOCPKT_STOP 4 -#define TIOCPKT_START 8 -#define TIOCPKT_NOSTOP 16 -#define TIOCPKT_DOSTOP 32 - -#define FIONBIO 0x8004667e /* To be compatible with socket version */ - -#define CTRL(ch) ((ch)&0x1F) - -#define CNUL 0 -#define CDEL 0x0007f -#define CESC '\\' -#define CINTR CTRL('C') -#define CQUIT 0x0001c -#define CERASE CDEL -#define CKILL CTRL('U') -#define CEOT CTRL('D') -#define CEOL 0 -#define CEOL2 0 -#define CEOF CTRL('D') -#define CSTART CTRL('Q') -#define CSTOP CTRL('S') -#define CSWTCH 0x0001a -#define NSWTCH 0 -#define CSUSP CTRL('Z') -#define CDSUSP CTRL('Y') -#define CRPRNT CTRL('R') -#define CFLUSH CTRL('O') -#define CWERASE CTRL('W') -#define CLNEXT CTRL('V') - -/* iflag bits */ -#define IGNBRK 0x00001 -#define BRKINT 0x00002 -#define IGNPAR 0x00004 -#define IMAXBEL 0x00008 -#define INPCK 0x00010 -#define ISTRIP 0x00020 -#define INLCR 0x00040 -#define IGNCR 0x00080 -#define ICRNL 0x00100 -#define IXON 0x00400 -#define IXOFF 0x01000 -#define IUCLC 0x04000 -#define IXANY 0x08000 -#define PARMRK 0x10000 - -/* oflag bits */ - -#define OPOST 0x00001 -#define OLCUC 0x00002 -#define OCRNL 0x00004 -#define ONLCR 0x00008 -#define ONOCR 0x00010 -#define ONLRET 0x00020 -#define OFILL 0x00040 -#define CRDLY 0x00180 -#define CR0 0x00000 -#define CR1 0x00080 -#define CR2 0x00100 -#define CR3 0x00180 -#define NLDLY 0x00200 -#define NL0 0x00000 -#define NL1 0x00200 -#define BSDLY 0x00400 -#define BS0 0x00000 -#define BS1 0x00400 -#define TABDLY 0x01800 -#define TAB0 0x00000 -#define TAB1 0x00800 -#define TAB2 0x01000 -#define TAB3 0x01800 -#define XTABS 0x01800 -#define VTDLY 0x02000 -#define VT0 0x00000 -#define VT1 0x02000 -#define FFDLY 0x04000 -#define FF0 0x00000 -#define FF1 0x04000 -#define OFDEL 0x08000 - -/* cflag bits */ - -/* Baud rate values. These must fit in speed_t, which is unsigned - char. See also the extended baud rates below. These baud rates - set an additional bit. */ -#define CBAUD 0x0100f -#define B0 0x00000 -#define B50 0x00001 -#define B75 0x00002 -#define B110 0x00003 -#define B134 0x00004 -#define B150 0x00005 -#define B200 0x00006 -#define B300 0x00007 -#define B600 0x00008 -#define B1200 0x00009 -#define B1800 0x0000a -#define B2400 0x0000b -#define B4800 0x0000c -#define B9600 0x0000d -#define B19200 0x0000e -#define B38400 0x0000f - -#define CSIZE 0x00030 -#define CS5 0x00000 -#define CS6 0x00010 -#define CS7 0x00020 -#define CS8 0x00030 -#define CSTOPB 0x00040 -#define CREAD 0x00080 -#define PARENB 0x00100 -#define PARODD 0x00200 -#define HUPCL 0x00400 -#define CLOCAL 0x00800 - -/* Extended baud rates above 37K. */ -#define CBAUDEX 0x0100f -#define B57600 0x01001 -#define B115200 0x01002 -#define B128000 0x01003 -#define B230400 0x01004 -#define B256000 0x01005 -#define B460800 0x01006 -#define B500000 0x01007 -#define B576000 0x01008 -#define B921600 0x01009 -#define B1000000 0x0100a -#define B1152000 0x0100b -#define B1500000 0x0100c -#define B2000000 0x0100d -#define B2500000 0x0100e -#define B3000000 0x0100f - -#define CRTSXOFF 0x04000 -#define CRTSCTS 0x08000 - -/* lflag bits */ -#define ISIG 0x0001 -#define ICANON 0x0002 -#define ECHO 0x0004 -#define ECHOE 0x0008 -#define ECHOK 0x0010 -#define ECHONL 0x0020 -#define NOFLSH 0x0040 -#define TOSTOP 0x0080 -#define IEXTEN 0x0100 -#define FLUSHO 0x0200 -#define ECHOKE 0x0400 -#define ECHOCTL 0x0800 - -#define VDISCARD 1 -#define VEOL 2 -#define VEOL2 3 -#define VEOF 4 -#define VERASE 5 -#define VINTR 6 -#define VKILL 7 -#define VLNEXT 8 -#define VMIN 9 -#define VQUIT 10 -#define VREPRINT 11 -#define VSTART 12 -#define VSTOP 13 -#define VSUSP 14 -#define VSWTC 15 -#define VTIME 16 -#define VWERASE 17 - -#define NCCS 18 - -/* Compare a character C to a value VAL from the `c_cc' array in a - `struct termios'. If VAL is _POSIX_VDISABLE, no character can match it. */ -#define CCEQ(val, c) ((c) == (val) && (val) != _POSIX_VDISABLE) - -typedef unsigned char cc_t; -typedef unsigned int tcflag_t; -typedef unsigned int speed_t; -typedef unsigned short otcflag_t; -typedef unsigned char ospeed_t; - -struct __oldtermios -{ - otcflag_t c_iflag; - otcflag_t c_oflag; - otcflag_t c_cflag; - otcflag_t c_lflag; - char c_line; - cc_t c_cc[NCCS]; - ospeed_t c_ispeed; - ospeed_t c_ospeed; -}; - -struct termios -{ - tcflag_t c_iflag; - tcflag_t c_oflag; - tcflag_t c_cflag; - tcflag_t c_lflag; - char c_line; - cc_t c_cc[NCCS]; - speed_t c_ispeed; - speed_t c_ospeed; -}; - -#ifdef CYGWIN_VERSION_DLL_IS_OLD_TERMIOS -#ifdef __GNUC__ -# define __tonew_termios(ti) \ - ({ \ - struct termios *__newti; \ - \ - if (!CYGWIN_VERSION_DLL_IS_OLD_TERMIOS) \ - __newti = (struct termios *) ti; \ - else \ - { \ - __newti = (struct termios *) alloca(sizeof(struct termios)); \ - __newti->c_iflag = ((struct __oldtermios *)ti)->c_iflag; \ - __newti->c_oflag = ((struct __oldtermios *)ti)->c_oflag; \ - __newti->c_cflag = ((struct __oldtermios *)ti)->c_cflag; \ - __newti->c_lflag = ((struct __oldtermios *)ti)->c_lflag; \ - __newti->c_line = ((struct __oldtermios *)ti)->c_line; \ - __newti->c_ispeed = ((struct __oldtermios *)ti)->c_ispeed; \ - __newti->c_ospeed = ((struct __oldtermios *)ti)->c_ospeed; \ - memcpy (__newti->c_cc, ((struct __oldtermios *)ti)->c_cc, sizeof(__newti->c_cc)); \ - } \ - __newti; \ - }) - -# define __makenew_termios(ti) \ - (CYGWIN_VERSION_DLL_IS_OLD_TERMIOS ? \ - (struct termios *) alloca (sizeof (struct termios)) : (ti)) - -# define __toapp_termios(toti, fromti) \ - ({ \ - if (!CYGWIN_VERSION_DLL_IS_OLD_TERMIOS) \ - toti = fromti; \ - else \ - { \ - ((struct __oldtermios *)toti)->c_iflag = fromti->c_iflag; \ - ((struct __oldtermios *)toti)->c_oflag = fromti->c_oflag; \ - ((struct __oldtermios *)toti)->c_cflag = fromti->c_cflag; \ - ((struct __oldtermios *)toti)->c_lflag = fromti->c_lflag; \ - ((struct __oldtermios *)toti)->c_line = fromti->c_line; \ - ((struct __oldtermios *)toti)->c_ispeed = fromti->c_ispeed; \ - ((struct __oldtermios *)toti)->c_ospeed = fromti->c_ospeed; \ - memcpy (((struct __oldtermios*)toti)->c_cc, fromti->c_cc, sizeof(fromti->c_cc)); \ - } \ - toti; \ - }) -#endif /*__GNUC__*/ -#endif - -#define termio termios - -#define cfgetospeed(tp) ((tp)->c_ospeed) -#define cfgetispeed(tp) ((tp)->c_ispeed) - -#ifdef __cplusplus -extern "C" { -#endif - -int tcgetattr (int, struct termios *); -int tcsetattr (int, int, const struct termios *); -int tcsendbreak (int, int); -int tcdrain (int); -int tcflush (int, int); -int tcflow (int, int); -void cfmakeraw (struct termios *); -int cfsetispeed (struct termios *, speed_t); -int cfsetospeed (struct termios *, speed_t); - -#ifdef __cplusplus -} -#endif - -/* Extra stuff to make porting stuff easier. */ -struct winsize -{ - unsigned short ws_row, ws_col; - unsigned short ws_xpixel, ws_ypixel; -}; - -#define TIOCGWINSZ (('T' << 8) | 1) -#define TIOCSWINSZ (('T' << 8) | 2) -#define TIOCLINUX (('T' << 8) | 3) - -#endif /* _SYS_TERMIOS_H */ diff --git a/winsup/cygwin/include/sys/ttychars.h b/winsup/cygwin/include/sys/ttychars.h deleted file mode 100644 index 2d313646f..000000000 --- a/winsup/cygwin/include/sys/ttychars.h +++ /dev/null @@ -1 +0,0 @@ -/* ttychars.h */ diff --git a/winsup/cygwin/include/sys/uio.h b/winsup/cygwin/include/sys/uio.h deleted file mode 100644 index e28f14e7e..000000000 --- a/winsup/cygwin/include/sys/uio.h +++ /dev/null @@ -1,38 +0,0 @@ -/* sys/uio.h - - Copyright 1996, 2000, 2001, 2002 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _UIO_H_ -#define _UIO_H_ - -/* For size_t */ -#include -/* For ssize_t */ -#include - -#include - -__BEGIN_DECLS - -/* - * Define the uio buffers used for writev, readv. - */ - -struct iovec -{ - void *iov_base; - size_t iov_len; -}; - -extern ssize_t readv __P ((int filedes, const struct iovec *vector, int count)); -extern ssize_t writev __P ((int filedes, const struct iovec *vector, int count)); - -__END_DECLS - -#endif /* _UIO_H_ */ diff --git a/winsup/cygwin/include/sys/un.h b/winsup/cygwin/include/sys/un.h deleted file mode 100644 index 7dbbc88b8..000000000 --- a/winsup/cygwin/include/sys/un.h +++ /dev/null @@ -1,29 +0,0 @@ -/* sys/un.h - - Copyright 1999, 2001, 2005, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SYS_UN_H -#define _SYS_UN_H - -#include /* for strlen */ -#include - -/* POSIX requires only at least 100 bytes */ -#define UNIX_PATH_LEN 108 - -struct sockaddr_un { - sa_family_t sun_family; /* address family AF_LOCAL/AF_UNIX */ - char sun_path[UNIX_PATH_LEN]; /* 108 bytes of socket address */ -}; - -/* Evaluates the actual length of `sockaddr_un' structure. */ -#define SUN_LEN(p) ((size_t)(((struct sockaddr_un *) NULL)->sun_path) \ - + strlen ((p)->sun_path)) - -#endif diff --git a/winsup/cygwin/include/sys/utime.h b/winsup/cygwin/include/sys/utime.h deleted file mode 100644 index 8a9ec15b0..000000000 --- a/winsup/cygwin/include/sys/utime.h +++ /dev/null @@ -1,30 +0,0 @@ -/* sys/utime.h - - Copyright 2001 Red Hat, Inc. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#ifndef _SYS_UTIME_H -#define _SYS_UTIME_H - -#ifdef __cplusplus -extern "C" { -#endif -#include <_ansi.h> -#include - -struct utimbuf -{ - time_t actime; - time_t modtime; -}; - -int _EXFUN(utime, (const char *__path, const struct utimbuf *__buf)); - -#ifdef __cplusplus -}; -#endif - -#endif /* _SYS_UTIME_H */ diff --git a/winsup/cygwin/include/sys/utmp.h b/winsup/cygwin/include/sys/utmp.h deleted file mode 100644 index 8a63b348b..000000000 --- a/winsup/cygwin/include/sys/utmp.h +++ /dev/null @@ -1,54 +0,0 @@ -/* sys/utmp.h - - Copyright 2001, 2003, 2004, 2005, 2008 Red Hat, Inc. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#ifndef UTMP_H -#define UTMP_H - -#include - -#define UTMP_FILE _PATH_UTMP - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef ut_name -#define ut_name ut_user -#endif - - -struct utmp -{ - short ut_type; - pid_t ut_pid; - char ut_line[UT_LINESIZE]; - char ut_id[UT_IDLEN]; - time_t ut_time; - char ut_user[UT_NAMESIZE]; - char ut_host[UT_HOSTSIZE]; - long ut_addr; -}; - -extern struct utmp *getutent (void); -extern struct utmp *getutid (const struct utmp *); -extern struct utmp *getutline (const struct utmp *); -extern struct utmp *pututline (const struct utmp *); -extern void endutent (void); -extern void setutent (void); -extern void utmpname (const char *); - -void login (const struct utmp *); -int logout (const char *); -int login_tty (int); -void updwtmp (const char *, const struct utmp *); -void logwtmp (const char *, const char *, const char *); - -#ifdef __cplusplus -} -#endif -#endif /* UTMP_H */ diff --git a/winsup/cygwin/include/sys/utsname.h b/winsup/cygwin/include/sys/utsname.h deleted file mode 100644 index bb770c0f1..000000000 --- a/winsup/cygwin/include/sys/utsname.h +++ /dev/null @@ -1,33 +0,0 @@ -/* sys/utsname.h - - Copyright 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SYS_UTSNAME_H -#define _SYS_UTSNAME_H - -#ifdef __cplusplus -extern "C" { -#endif - -struct utsname -{ - char sysname[20]; - char nodename[20]; - char release[20]; - char version[20]; - char machine[20]; -}; - -int uname (struct utsname *); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/winsup/cygwin/include/sys/vfs.h b/winsup/cygwin/include/sys/vfs.h deleted file mode 100644 index 57b6f9232..000000000 --- a/winsup/cygwin/include/sys/vfs.h +++ /dev/null @@ -1,38 +0,0 @@ -/* sys/vfs.h - - Copyright 1997, 1998, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SYS_VFS_H_ -#define _SYS_VFS_H_ - -struct statfs { - long f_type; /* type of filesystem */ - long f_bsize; /* optimal transfer block size */ - long f_blocks; /* total data blocks in file system */ - long f_bfree; /* free blocks in fs */ - long f_bavail; /* free blocks avail to non-superuser */ - long f_files; /* total file nodes in file system */ - long f_ffree; /* free file nodes in fs */ - long f_fsid; /* file system id */ - long f_namelen; /* maximum length of filenames */ - long f_spare[6]; /* spare for later */ -}; - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -int statfs (const char *__path, struct statfs *__buf); -int fstatfs (int __fd, struct statfs *__buf); - -#ifdef __cplusplus -}; -#endif /* __cplusplus */ - -#endif /*_SYS_VFS_H_*/ diff --git a/winsup/cygwin/include/sys/wait.h b/winsup/cygwin/include/sys/wait.h deleted file mode 100644 index 04bbae7f5..000000000 --- a/winsup/cygwin/include/sys/wait.h +++ /dev/null @@ -1,55 +0,0 @@ -/* sys/wait.h - - Copyright 1997, 1998, 2001, 2002, 2003, 2004, 2006 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SYS_WAIT_H -#define _SYS_WAIT_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -pid_t wait (int *); -pid_t waitpid (pid_t, int *, int); -pid_t wait3 (int *__status, int __options, struct rusage *__rusage); -pid_t wait4 (pid_t __pid, int *__status, int __options, struct rusage *__rusage); - -union wait - { - int w_status; - struct - { - unsigned int __w_termsig:7; /* Terminating signal. */ - unsigned int __w_coredump:1; /* Set if dumped core. */ - unsigned int __w_retcode:8; /* Return code if exited normally. */ - unsigned int:16; - } __wait_terminated; - struct - { - unsigned int __w_stopval:8; /* W_STOPPED if stopped. */ - unsigned int __w_stopsig:8; /* Stopping signal. */ - unsigned int:16; - } __wait_stopped; - }; - -#define w_termsig __wait_terminated.__w_termsig -#define w_coredump __wait_terminated.__w_coredump -#define w_retcode __wait_terminated.__w_retcode -#define w_stopsig __wait_stopped.__w_stopsig -#define w_stopval __wait_stopped.__w_stopval - -#ifdef __cplusplus -}; -#endif - -#endif diff --git a/winsup/cygwin/include/sysexits.h b/winsup/cygwin/include/sysexits.h deleted file mode 100644 index eba0b92dd..000000000 --- a/winsup/cygwin/include/sysexits.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - * - * @(#)sysexits.h 8.1 (Berkeley) 6/2/93 - */ - -#ifndef _SYSEXITS_H_ -#define _SYSEXITS_H_ - -/* - * 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. - */ - -#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 */ - -#define EX__MAX 78 /* maximum listed value */ - -#endif /* !_SYSEXITS_H_ */ diff --git a/winsup/cygwin/include/syslog.h b/winsup/cygwin/include/syslog.h deleted file mode 100644 index 5721ca5e4..000000000 --- a/winsup/cygwin/include/syslog.h +++ /dev/null @@ -1,16 +0,0 @@ -/* syslog.h - - Copyright 1996, 1998, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SYSLOG_H -#define _SYSLOG_H - -#include - -#endif /* _SYSLOG_H */ diff --git a/winsup/cygwin/include/termio.h b/winsup/cygwin/include/termio.h deleted file mode 100644 index ba7b3b10b..000000000 --- a/winsup/cygwin/include/termio.h +++ /dev/null @@ -1,16 +0,0 @@ -/* termio.h - - Copyright 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _TERMIO_H -#define _TERMIO_H - -#include - -#endif diff --git a/winsup/cygwin/include/tzfile.h b/winsup/cygwin/include/tzfile.h deleted file mode 100644 index 5586380a8..000000000 --- a/winsup/cygwin/include/tzfile.h +++ /dev/null @@ -1,51 +0,0 @@ -/* tzfile.h - - Copyright 2001, 2002, 2003 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _TZFILE_H -#define _TZFILE_H - -#define SECSPERMIN 60 -#define MINSPERHOUR 60 -#define HOURSPERDAY 24 -#define DAYSPERWEEK 7 -#define DAYSPERNYEAR 365 -#define DAYSPERLYEAR 366 -#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) -#define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY) -#define MONSPERYEAR 12 - -#define TM_SUNDAY 0 -#define TM_MONDAY 1 -#define TM_TUESDAY 2 -#define TM_WEDNESDAY 3 -#define TM_THURSDAY 4 -#define TM_FRIDAY 5 -#define TM_SATURDAY 6 - -#define TM_JANUARY 0 -#define TM_FEBRUARY 1 -#define TM_MARCH 2 -#define TM_APRIL 3 -#define TM_MAY 4 -#define TM_JUNE 5 -#define TM_JULY 6 -#define TM_AUGUST 7 -#define TM_SEPTEMBER 8 -#define TM_OCTOBER 9 -#define TM_NOVEMBER 10 -#define TM_DECEMBER 11 - -#define TM_YEAR_BASE 1900 - -#define EPOCH_YEAR 1970 -#define EPOCH_WDAY TM_THURSDAY - -#define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0) -#endif diff --git a/winsup/cygwin/include/utmpx.h b/winsup/cygwin/include/utmpx.h deleted file mode 100644 index 2239a6353..000000000 --- a/winsup/cygwin/include/utmpx.h +++ /dev/null @@ -1,55 +0,0 @@ -/* utmpx.h - - Copyright 2004 Red Hat, Inc. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#ifndef UTMPX_H -#define UTMPX_H - -#include -#include - -#define UTMPX_FILE _PATH_UTMP - -#ifdef __cplusplus -extern "C" { -#endif - -/* Must be kept in sync with struct utmp as defined in sys/utmp.h! */ -struct utmpx -{ - short ut_type; - pid_t ut_pid; - char ut_line[UT_LINESIZE]; - char ut_id[UT_IDLEN]; - time_t ut_time; - char ut_user[UT_NAMESIZE]; - char ut_host[UT_HOSTSIZE]; - long ut_addr; - struct timeval ut_tv; -}; - -#ifndef ut_name -#define ut_name ut_user -#endif - -#ifndef ut_xtime -#define ut_xtime ut_tv.tv_sec -#endif - -extern void endutxent (void); -extern struct utmpx *getutxent (void); -extern struct utmpx *getutxid (const struct utmpx *id); -extern struct utmpx *getutxline (const struct utmpx *line); -extern struct utmpx *pututxline (const struct utmpx *utmpx); -extern void setutxent (void); -extern void utmpxname (const char *file); -extern void updwtmpx (const char *file, const struct utmpx *utmpx); - -#ifdef __cplusplus -} -#endif -#endif /* UTMPX_H */ diff --git a/winsup/cygwin/include/wait.h b/winsup/cygwin/include/wait.h deleted file mode 100644 index f0f1281e2..000000000 --- a/winsup/cygwin/include/wait.h +++ /dev/null @@ -1,16 +0,0 @@ -/* wait.h - - Copyright 2008 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _WAIT_H -#define _WAIT_H - -#include - -#endif /* _WAIT_H */ diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc deleted file mode 100644 index 9bf49f2a3..000000000 --- a/winsup/cygwin/init.cc +++ /dev/null @@ -1,158 +0,0 @@ -/* init.cc - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "cygtls.h" -#include "ntdll.h" -#include "shared_info.h" - -static DWORD _my_oldfunc; - -static char NO_COPY *search_for = (char *) cygthread::stub; -unsigned threadfunc_ix[8] __attribute__((section (".cygwin_dll_common"), shared)); -extern cygthread *hwait_sig; - -#define OLDFUNC_OFFSET -1 - -static void WINAPI -threadfunc_fe (VOID *arg) -{ - (void)__builtin_return_address(1); - asm volatile ("andl $-16,%%esp" ::: "%esp"); - _cygtls::call ((DWORD (*) (void *, void *)) TlsGetValue (_my_oldfunc), arg); -} - -/* If possible, redirect the thread entry point to a cygwin routine which - adds tls stuff to the stack. */ -static void -munge_threadfunc () -{ - int i; - char **ebp = (char **) __builtin_frame_address (0); - if (!threadfunc_ix[0]) - { - char **peb; - char **top = (char **) _tlsbase; - for (peb = ebp, i = 0; peb < top && i < 7; peb++) - if (*peb == search_for) - threadfunc_ix[i++] = peb - ebp; - if (0 && !threadfunc_ix[0]) - { - try_to_debug (); - return; - } - } - - if (threadfunc_ix[0]) - { - char *threadfunc = ebp[threadfunc_ix[0]]; - if (!search_for || threadfunc == search_for) - { - search_for = NULL; - for (i = 0; threadfunc_ix[i]; i++) - ebp[threadfunc_ix[i]] = (char *) threadfunc_fe; - TlsSetValue (_my_oldfunc, threadfunc); - } - } -} - -inline static void -respawn_wow64_process () -{ - NTSTATUS ret; - PROCESS_BASIC_INFORMATION pbi; - HANDLE parent; - - ULONG wow64 = TRUE; /* Opt on the safe side. */ - - /* Unfortunately there's no simpler way to retrieve the - parent process in NT, as far as I know. Hints welcome. */ - ret = NtQueryInformationProcess (NtCurrentProcess (), - ProcessBasicInformation, - &pbi, sizeof pbi, NULL); - if (NT_SUCCESS (ret) - && (parent = OpenProcess (PROCESS_QUERY_INFORMATION, - FALSE, - pbi.InheritedFromUniqueProcessId))) - { - NtQueryInformationProcess (parent, ProcessWow64Information, - &wow64, sizeof wow64, NULL); - CloseHandle (parent); - } - - /* The parent is a real 64 bit process? Respawn! */ - if (!wow64) - { - PROCESS_INFORMATION pi; - STARTUPINFOW si; - DWORD ret = 0; - - GetStartupInfoW (&si); - if (!CreateProcessW (NULL, GetCommandLineW (), NULL, NULL, TRUE, - CREATE_DEFAULT_ERROR_MODE - | GetPriorityClass (GetCurrentProcess ()), - NULL, NULL, &si, &pi)) - api_fatal ("Failed to create process <%s>, %E", GetCommandLineA ()); - CloseHandle (pi.hThread); - if (WaitForSingleObject (pi.hProcess, INFINITE) == WAIT_FAILED) - api_fatal ("Waiting for process %d failed, %E", pi.dwProcessId); - GetExitCodeProcess (pi.hProcess, &ret); - CloseHandle (pi.hProcess); - ExitProcess (ret); - } -} - -extern void __stdcall dll_crt0_0 (); - -extern "C" BOOL WINAPI -dll_entry (HANDLE h, DWORD reason, void *static_load) -{ - BOOL wow64_test_stack_marker; - - switch (reason) - { - case DLL_PROCESS_ATTACH: - wincap.init (); - init_console_handler (false); - - cygwin_hmodule = (HMODULE) h; - dynamically_loaded = (static_load == NULL); - - /* Is the stack at an unusual address? That is, an address which - is in the usual space occupied by the process image, but below - the auto load address of DLLs? - Check if we're running in WOW64 on a 64 bit machine *and* are - spawned by a genuine 64 bit process. If so, respawn. */ - if (wincap.is_wow64 () - && &wow64_test_stack_marker >= (PBOOL) 0x400000 - && &wow64_test_stack_marker <= (PBOOL) 0x10000000) - respawn_wow64_process (); - - dll_crt0_0 (); - _my_oldfunc = TlsAlloc (); - break; - case DLL_PROCESS_DETACH: - if (dynamically_loaded) - shared_destroy (); - break; - case DLL_THREAD_ATTACH: - if (hwait_sig) - munge_threadfunc (); - break; - case DLL_THREAD_DETACH: - if (hwait_sig && (void *) &_my_tls > (void *) &wow64_test_stack_marker - && _my_tls.isinitialized ()) - _my_tls.remove (0); - break; - } - - return TRUE; -} diff --git a/winsup/cygwin/ioctl.cc b/winsup/cygwin/ioctl.cc deleted file mode 100644 index ffcdbded4..000000000 --- a/winsup/cygwin/ioctl.cc +++ /dev/null @@ -1,63 +0,0 @@ -/* ioctl.cc: ioctl routines. - - Copyright 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2006, 2008, 2009 - Red Hat, Inc. - - Written by Doug Evans of Cygnus Support - dje@cygnus.com - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "cygerrno.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" - -extern "C" int -ioctl (int fd, int cmd, ...) -{ - - cygheap_fdget cfd (fd); - if (cfd < 0) - return -1; - - /* check for optional mode argument */ - va_list ap; - va_start (ap, cmd); - char *argp = va_arg (ap, char *); - va_end (ap); - - debug_printf ("fd %d, cmd %x", fd, cmd); - int res; - /* FIXME: This stinks. There are collisions between cmd types - depending on whether fd is associated with a pty master or not. - Something to fix for Cygwin2. CGF 2006-06-04 */ - if (cfd->is_tty () && cfd->get_major () != DEV_TTYM_MAJOR) - switch (cmd) - { - case TCGETA: - res = tcgetattr (fd, (struct termios *) argp); - goto out; - case TCSETA: - res = tcsetattr (fd, TCSANOW, (struct termios *) argp); - goto out; - case TCSETAW: - res = tcsetattr (fd, TCSADRAIN, (struct termios *) argp); - goto out; - case TCSETAF: - res = tcsetattr (fd, TCSAFLUSH, (struct termios *) argp); - goto out; - } - - res = cfd->ioctl (cmd, argp); - -out: - debug_printf ("returning %d", res); - return res; -} diff --git a/winsup/cygwin/ipc.cc b/winsup/cygwin/ipc.cc deleted file mode 100644 index b9f09cbde..000000000 --- a/winsup/cygwin/ipc.cc +++ /dev/null @@ -1,91 +0,0 @@ -/* ipc.cc: Single unix specification IPC interface for Cygwin - - Copyright 2001, 2002, 2003 Red Hat, Inc. - - Originally written by Robert Collins - Updated to 64 bit key_t by Charles Wilson - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#include "winsup.h" -#include - -/* Notes: we return a valid key even if id's low order 8 bits are 0. */ -extern "C" key_t -ftok (const char *path, int id) -{ - struct __stat64 statbuf; - key_t tmp; - if (stat64 (path, &statbuf)) - { - /* stat set the appropriate errno for us */ - return (key_t) -1; - } - - /* Since __CYGWIN_USE_BIG_TYPES__, - dev_t is 32bits for cygwin - ino_t is 64bits for cygwin - and we need 8 bits for the id. - thus key_t needs 104 bits total -- but we only have 64 (long long) - We will have to alias; leaving open the possibility that the same - key will be returned for multiple files. This possibility exists - also on Linux; the question is, how to minimize this possibility. - - How to solve? Well, based on C. Vinschen's research, the nFileIndex* - words vary as follows, on a partition with > 110,000 files - nFileIndexHigh: 564 values between 0x00010000 -- 0xffff0000 - nFileIndexLow : 103812 values between 0x00000000 -- 0x0003ffff - R. Collins suggests that these may represent a tree path, - and that it would require ~2.9M files to force the tree depth - to increase and reveal more bit usage. - - Implementation details: dev_t is 32bits, but is formed by - device(32bits) << 16 | unit(32bits) - But device is ACTUALLY == status & FH_DEVMASK, where FH_DEVMASK - is 0x00000fff --> 12 bits - - As it happens, the maximum number of devices is actually - FH_NDEV, not FH_DEVMASK, where FH_NDEV is currently 0x0000001d. - However, FH_NDEV grows as new device types are added. So - currently the device number needs 5 bits, but later? Let's - take a cue from Linux, and use the lower 8 bits (instead of the - lower 12 or 16) for the device (major?) number. - - Similarly, while 'units' is an int (32bits), it is unclear - how many of these are significant. For most devices, it seems that - 'units' is equivalent to 'minor'. For FH_TAPE, it's obvious that - only 8 bits are important. However, for FH_SOCKET...it might be - as high as 16 significant bits. - - Let's assume that we only need 8 bits from device (major) and - only 8 bits from unit (minor). (On linux, only 8 bits of minor - are used, and none from major). - ---> so, we only need 0x00ff00ff (16 bits) of dev_t - - ---> we MUST have all 8 bits of id. - - ---> So, we only have 64 - 8 - 16 = 40 bits for ino_t. But, we - need 0xffff0000 for nFileIndexHigh and 0x0003ffff for nFileIndexLow - minimum, or 16 + 18 = 34 bits. Lucky us - we have 6 more bits - to distribute. - - For lack of a better idea, we'll allocate 2 of the extra bits to - nFileIndexHigh and 4 to nFileIndexLow. */ - - /* get 8 bits from dev_t (major), put into 0xff00000000000000L */ - tmp = (((key_t) statbuf.st_dev) & 0x0000000000ff0000LL) << 40; - /* get 8 bits from dev_t (minor), put into 0x00ff000000000000L */ - tmp |= (((key_t) statbuf.st_dev) & 0x00000000000000ffLL) << 48; - /* get upper 16+2 bits from nFileInfoHigh, put into 0x0000ffffc0000000L - shift down first, then mask, to avoid sign extension on rightshift */ - tmp |= (((key_t) statbuf.st_ino) & 0xffffc00000000000LL) >> 16; - /* get lower 18+4 bits from nFileInfoLow, put into 0x000000003fffff00L */ - tmp |= (((key_t) statbuf.st_ino) & 0x00000000003fffffLL) << 8; - /* use all 8 bits of id, and put into 0x00000000000000ffL */ - tmp |= (id & 0x00ff); - return tmp; -} diff --git a/winsup/cygwin/kernel32.cc b/winsup/cygwin/kernel32.cc deleted file mode 100644 index 6af0ddb2e..000000000 --- a/winsup/cygwin/kernel32.cc +++ /dev/null @@ -1,439 +0,0 @@ -/* kernel32.cc: Win32 replacement functions. - - Copyright 2008 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "shared_info.h" -#include "ntdll.h" -#include - -/* Implement CreateEvent/OpenEvent so that named objects are always created in - Cygwin shared object namespace. */ - -HANDLE WINAPI -CreateEventW (LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, - BOOL bInitialState, LPCWSTR lpName) -{ - HANDLE evt; - UNICODE_STRING uname; - OBJECT_ATTRIBUTES attr; - NTSTATUS status; - ULONG flags = 0; - - if (lpEventAttributes && lpEventAttributes->bInheritHandle) - flags |= OBJ_INHERIT; - if (lpName) - { - RtlInitUnicodeString (&uname, lpName); - flags |= OBJ_OPENIF | OBJ_CASE_INSENSITIVE; - } - InitializeObjectAttributes (&attr, lpName ? &uname : NULL, flags, - lpName ? get_shared_parent_dir () : NULL, - lpEventAttributes - ? lpEventAttributes->lpSecurityDescriptor : NULL); - status = NtCreateEvent (&evt, CYG_EVENT_ACCESS, &attr, - bManualReset ? NotificationEvent - : SynchronizationEvent, - bInitialState); - if (!NT_SUCCESS (status)) - { - SetLastError (RtlNtStatusToDosError (status)); - return NULL; - } - SetLastError (status == STATUS_OBJECT_NAME_EXISTS - ? ERROR_ALREADY_EXISTS : ERROR_SUCCESS); - return evt; -} - -HANDLE WINAPI -CreateEventA (LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, - BOOL bInitialState, LPCSTR lpName) -{ - WCHAR name[MAX_PATH]; - - if (lpName && !sys_mbstowcs (name, MAX_PATH, lpName)) - { - SetLastError (ERROR_FILENAME_EXCED_RANGE); - return NULL; - } - return CreateEventW (lpEventAttributes, bManualReset, bInitialState, - lpName ? name : NULL); -} - -HANDLE WINAPI -OpenEventW (DWORD dwDesiredAccess, BOOL bInheritHandle, LPCWSTR lpName) -{ - HANDLE evt; - UNICODE_STRING uname; - OBJECT_ATTRIBUTES attr; - NTSTATUS status; - ULONG flags = 0; - - if (bInheritHandle) - flags |= OBJ_INHERIT; - if (lpName) - { - RtlInitUnicodeString (&uname, lpName); - flags |= OBJ_CASE_INSENSITIVE; - } - InitializeObjectAttributes (&attr, lpName ? &uname : NULL, flags, - lpName ? get_shared_parent_dir () : NULL, - NULL); - status = NtOpenEvent (&evt, dwDesiredAccess, &attr); - if (!NT_SUCCESS (status)) - { - SetLastError (RtlNtStatusToDosError (status)); - return NULL; - } - return evt; -} - -HANDLE WINAPI -OpenEventA (DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpName) -{ - WCHAR name[MAX_PATH]; - - if (lpName && !sys_mbstowcs (name, MAX_PATH, lpName)) - { - SetLastError (ERROR_FILENAME_EXCED_RANGE); - return NULL; - } - return OpenEventW (dwDesiredAccess, bInheritHandle, lpName ? name : NULL); -} - -/* Implement CreateMutex/OpenMutex so that named objects are always created in - Cygwin shared object namespace. */ - -HANDLE WINAPI -CreateMutexW (LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner, - LPCWSTR lpName) -{ - HANDLE mtx; - UNICODE_STRING uname; - OBJECT_ATTRIBUTES attr; - NTSTATUS status; - ULONG flags = 0; - - if (lpMutexAttributes && lpMutexAttributes->bInheritHandle) - flags |= OBJ_INHERIT; - if (lpName) - { - RtlInitUnicodeString (&uname, lpName); - flags |= OBJ_OPENIF | OBJ_CASE_INSENSITIVE; - } - InitializeObjectAttributes (&attr, lpName ? &uname : NULL, flags, - lpName ? get_shared_parent_dir () : NULL, - lpMutexAttributes - ? lpMutexAttributes->lpSecurityDescriptor : NULL); - status = NtCreateMutant (&mtx, CYG_MUTANT_ACCESS, &attr, bInitialOwner); - if (!NT_SUCCESS (status)) - { - SetLastError (RtlNtStatusToDosError (status)); - return NULL; - } - SetLastError (status == STATUS_OBJECT_NAME_EXISTS - ? ERROR_ALREADY_EXISTS : ERROR_SUCCESS); - return mtx; -} - -HANDLE WINAPI -CreateMutexA (LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner, - LPCSTR lpName) -{ - WCHAR name[MAX_PATH]; - - if (lpName && !sys_mbstowcs (name, MAX_PATH, lpName)) - { - SetLastError (ERROR_FILENAME_EXCED_RANGE); - return NULL; - } - return CreateMutexW (lpMutexAttributes, bInitialOwner, lpName ? name : NULL); -} - -HANDLE WINAPI -OpenMutexW (DWORD dwDesiredAccess, BOOL bInheritHandle, LPCWSTR lpName) -{ - HANDLE mtx; - UNICODE_STRING uname; - OBJECT_ATTRIBUTES attr; - NTSTATUS status; - ULONG flags = 0; - - if (bInheritHandle) - flags |= OBJ_INHERIT; - if (lpName) - { - RtlInitUnicodeString (&uname, lpName); - flags |= OBJ_CASE_INSENSITIVE; - } - InitializeObjectAttributes (&attr, lpName ? &uname : NULL, flags, - lpName ? get_shared_parent_dir () : NULL, - NULL); - status = NtOpenMutant (&mtx, dwDesiredAccess, &attr); - if (!NT_SUCCESS (status)) - { - SetLastError (RtlNtStatusToDosError (status)); - return NULL; - } - return mtx; -} - -HANDLE WINAPI -OpenMutexA (DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpName) -{ - WCHAR name[MAX_PATH]; - - if (lpName && !sys_mbstowcs (name, MAX_PATH, lpName)) - { - SetLastError (ERROR_FILENAME_EXCED_RANGE); - return NULL; - } - return OpenMutexW (dwDesiredAccess, bInheritHandle, lpName ? name : NULL); -} - -/* Implement CreateSemaphore/OpenSemaphore so that named objects are always - created in Cygwin shared object namespace. */ - -HANDLE WINAPI -CreateSemaphoreW (LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, - LONG lInitialCount, LONG lMaximumCount, LPCWSTR lpName) -{ - HANDLE sem; - UNICODE_STRING uname; - OBJECT_ATTRIBUTES attr; - NTSTATUS status; - ULONG flags = 0; - - if (lpSemaphoreAttributes && lpSemaphoreAttributes->bInheritHandle) - flags |= OBJ_INHERIT; - if (lpName) - { - RtlInitUnicodeString (&uname, lpName); - flags |= OBJ_OPENIF | OBJ_CASE_INSENSITIVE; - } - InitializeObjectAttributes (&attr, lpName ? &uname : NULL, flags, - lpName ? get_shared_parent_dir () : NULL, - lpSemaphoreAttributes - ? lpSemaphoreAttributes->lpSecurityDescriptor - : NULL); - status = NtCreateSemaphore (&sem, CYG_SEMAPHORE_ACCESS, &attr, - lInitialCount, lMaximumCount); - if (!NT_SUCCESS (status)) - { - SetLastError (RtlNtStatusToDosError (status)); - return NULL; - } - SetLastError (status == STATUS_OBJECT_NAME_EXISTS - ? ERROR_ALREADY_EXISTS : ERROR_SUCCESS); - return sem; -} - -HANDLE WINAPI -CreateSemaphoreA (LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, - LONG lInitialCount, LONG lMaximumCount, LPCSTR lpName) -{ - WCHAR name[MAX_PATH]; - - if (lpName && !sys_mbstowcs (name, MAX_PATH, lpName)) - { - SetLastError (ERROR_FILENAME_EXCED_RANGE); - return NULL; - } - return CreateSemaphoreW (lpSemaphoreAttributes, lInitialCount, lMaximumCount, - lpName ? name : NULL); -} - -HANDLE WINAPI -OpenSemaphoreW (DWORD dwDesiredAccess, BOOL bInheritHandle, LPCWSTR lpName) -{ - HANDLE sem; - UNICODE_STRING uname; - OBJECT_ATTRIBUTES attr; - NTSTATUS status; - ULONG flags = 0; - - if (bInheritHandle) - flags |= OBJ_INHERIT; - if (lpName) - { - RtlInitUnicodeString (&uname, lpName); - flags |= OBJ_CASE_INSENSITIVE; - } - InitializeObjectAttributes (&attr, lpName ? &uname : NULL, flags, - lpName ? get_shared_parent_dir () : NULL, - NULL); - status = NtOpenSemaphore (&sem, dwDesiredAccess, &attr); - if (!NT_SUCCESS (status)) - { - SetLastError (RtlNtStatusToDosError (status)); - return NULL; - } - return sem; -} - -HANDLE WINAPI -OpenSemaphoreA (DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpName) -{ - WCHAR name[MAX_PATH]; - - if (lpName && !sys_mbstowcs (name, MAX_PATH, lpName)) - { - SetLastError (ERROR_FILENAME_EXCED_RANGE); - return NULL; - } - return OpenSemaphoreW (dwDesiredAccess, bInheritHandle, lpName ? name : NULL); -} - -/* Implement CreateFileMapping/OpenFileMapping so that named objects are always - created in Cygwin shared object namespace. */ - -HANDLE WINAPI -CreateFileMappingW (HANDLE hFile, LPSECURITY_ATTRIBUTES lpAttributes, - DWORD flProtect, DWORD dwMaximumSizeHigh, - DWORD dwMaximumSizeLow, LPCWSTR lpName) -{ - HANDLE sect; - UNICODE_STRING uname; - OBJECT_ATTRIBUTES attr; - NTSTATUS status; - ULONG flags = 0; - ACCESS_MASK access = READ_CONTROL | SECTION_QUERY | SECTION_MAP_READ; - ULONG prot = flProtect & (PAGE_NOACCESS | PAGE_READONLY | PAGE_READWRITE - | PAGE_WRITECOPY | PAGE_EXECUTE - | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE - | PAGE_EXECUTE_WRITECOPY); - ULONG attribs = flProtect & (SEC_BASED | SEC_NO_CHANGE | SEC_IMAGE | SEC_VLM - | SEC_RESERVE | SEC_COMMIT | SEC_NOCACHE); - LARGE_INTEGER size = {{ LowPart : dwMaximumSizeLow, - HighPart : dwMaximumSizeHigh }}; - PLARGE_INTEGER psize = size.QuadPart ? &size : NULL; - - if (prot & (PAGE_READWRITE | PAGE_WRITECOPY - | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY)) - access |= SECTION_MAP_WRITE; - if (prot & (PAGE_EXECUTE | PAGE_EXECUTE_READ - | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY)) - access |= SECTION_MAP_EXECUTE; - if (lpAttributes && lpAttributes->bInheritHandle) - flags |= OBJ_INHERIT; - if (lpName) - { - RtlInitUnicodeString (&uname, lpName); - flags |= OBJ_OPENIF | OBJ_CASE_INSENSITIVE; - } - InitializeObjectAttributes (&attr, lpName ? &uname : NULL, flags, - lpName ? get_shared_parent_dir () : NULL, - lpAttributes - ? lpAttributes->lpSecurityDescriptor - : NULL); - if (!(attribs & (SEC_RESERVE | SEC_COMMIT))) - attribs |= SEC_COMMIT; - if (hFile == INVALID_HANDLE_VALUE) - hFile = NULL; - status = NtCreateSection (§, access, &attr, psize, prot, attribs, hFile); - if (!NT_SUCCESS (status)) - { - SetLastError (RtlNtStatusToDosError (status)); - return NULL; - } - SetLastError (status == STATUS_OBJECT_NAME_EXISTS - ? ERROR_ALREADY_EXISTS : ERROR_SUCCESS); - return sect; -} - -HANDLE WINAPI -CreateFileMappingA (HANDLE hFile, LPSECURITY_ATTRIBUTES lpAttributes, - DWORD flProtect, DWORD dwMaximumSizeHigh, - DWORD dwMaximumSizeLow, LPCSTR lpName) -{ - WCHAR name[MAX_PATH]; - - if (lpName && !sys_mbstowcs (name, MAX_PATH, lpName)) - { - SetLastError (ERROR_FILENAME_EXCED_RANGE); - return NULL; - } - return CreateFileMappingW (hFile, lpAttributes, flProtect, dwMaximumSizeHigh, - dwMaximumSizeLow, lpName ? name : NULL); -} - -HANDLE WINAPI -OpenFileMappingW (DWORD dwDesiredAccess, BOOL bInheritHandle, LPCWSTR lpName) -{ - HANDLE sect; - UNICODE_STRING uname; - OBJECT_ATTRIBUTES attr; - NTSTATUS status; - ULONG flags = 0; - - if (bInheritHandle) - flags |= OBJ_INHERIT; - if (lpName) - { - RtlInitUnicodeString (&uname, lpName); - flags |= OBJ_CASE_INSENSITIVE; - } - InitializeObjectAttributes (&attr, lpName ? &uname : NULL, flags, - lpName ? get_shared_parent_dir () : NULL, - NULL); - status = NtOpenSection (§, dwDesiredAccess, &attr); - if (!NT_SUCCESS (status)) - { - SetLastError (RtlNtStatusToDosError (status)); - return NULL; - } - return sect; -} - -HANDLE WINAPI -OpenFileMappingA (DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpName) -{ - WCHAR name[MAX_PATH]; - - if (lpName && !sys_mbstowcs (name, MAX_PATH, lpName)) - { - SetLastError (ERROR_FILENAME_EXCED_RANGE); - return NULL; - } - return OpenFileMappingW (dwDesiredAccess, bInheritHandle, lpName ? name : NULL); -} - -/* When Terminal Services are installed, the GetWindowsDirectory function - does not return the system installation dir, but a user specific directory - instead. That's not what we have in mind when calling GetWindowsDirectory - from within Cygwin. So we're calling GetSystemWindowsDirectory from here, - except on NT4 where we use the method as described in KB186498. */ - -#define SYSTEM32 (sizeof ("\\System32") - 1) - -UINT WINAPI -GetWindowsDirectoryW (LPWSTR buf, UINT size) -{ - if (wincap.has_terminal_services ()) - return GetSystemWindowsDirectoryW (buf, size); - /* NT4 */ - WCHAR name [size + SYSTEM32]; - UINT ret = GetSystemDirectoryW (name, size + SYSTEM32); - if (ret < size + SYSTEM32) - { - name[ret - SYSTEM32] = L'\0'; - wcscpy (buf, name); - } - return ret - SYSTEM32; -} - -UINT WINAPI -GetWindowsDirectoryA (LPSTR buf, UINT size) -{ - WCHAR name[MAX_PATH]; - UINT ret = GetWindowsDirectoryW (name, min (size, MAX_PATH)); - if (ret < size) - sys_wcstombs (buf, size, name); - return ret; -} diff --git a/winsup/cygwin/lc_msg.h b/winsup/cygwin/lc_msg.h deleted file mode 100644 index a579e0b21..000000000 --- a/winsup/cygwin/lc_msg.h +++ /dev/null @@ -1,277 +0,0 @@ -/* This struct of LC_MESSAGES data has been generated by fetching locale - data from a Linux system using glibc-2.10.2-1.i686 on 2010-02-09. */ - -struct lc_msg_t -{ - const char *locale; - const wchar_t *yesexpr; - const wchar_t *noexpr; - const wchar_t *yesstr; - const wchar_t *nostr; -}; - -static struct lc_msg_t lc_msg[] = -{ - { "aa_DJ", L"^[oOyY].*", L"^[mnMN].*", L"", L"" }, - { "aa_ER", L"^[yY].*", L"^[mnMN].*", L"", L"" }, - { "aa_ER@saaho", L"^[yY].*", L"^[mnMN].*", L"", L"" }, - { "aa_ET", L"^[yY].*", L"^[mnMN].*", L"", L"" }, - { "af_ZA", L"^[jJyY]", L"^[nN]", L"", L"" }, - { "am_ET", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "an_ES", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "ar_AE", L"^[\x0646yY].*", L"^[\x0644nN].*", L"\x0646\x0639\x0645", L"\x0644\x0627" }, - { "ar_BH", L"^[\x0646yY].*", L"^[\x0644nN].*", L"\x0646\x0639\x0645", L"\x0644\x0627" }, - { "ar_DZ", L"^[\x0646yY].*", L"^[\x0644nN].*", L"\x0646\x0639\x0645", L"\x0644\x0627" }, - { "ar_EG", L"^[\x0646yY].*", L"^[\x0644nN].*", L"\x0646\x0639\x0645", L"\x0644\x0627" }, - { "ar_IN", L"^[\x0646yY].*", L"^[\x0644nN].*", L"\x0646\x0639\x0645", L"\x0644\x0627" }, - { "ar_IQ", L"^[\x0646yY].*", L"^[\x0644nN].*", L"\x0646\x0639\x0645", L"\x0644\x0627" }, - { "ar_JO", L"^[\x0646yY].*", L"^[\x0644nN].*", L"\x0646\x0639\x0645", L"\x0644\x0627" }, - { "ar_KW", L"^[\x0646yY].*", L"^[\x0644nN].*", L"\x0646\x0639\x0645", L"\x0644\x0627" }, - { "ar_LB", L"^[\x0646yY].*", L"^[\x0644nN].*", L"\x0646\x0639\x0645", L"\x0644\x0627" }, - { "ar_LY", L"^[\x0646yY].*", L"^[\x0644nN].*", L"\x0646\x0639\x0645", L"\x0644\x0627" }, - { "ar_MA", L"^[\x0646yY].*", L"^[\x0644nN].*", L"\x0646\x0639\x0645", L"\x0644\x0627" }, - { "ar_OM", L"^[\x0646yY].*", L"^[\x0644nN].*", L"\x0646\x0639\x0645", L"\x0644\x0627" }, - { "ar_QA", L"^[\x0646yY].*", L"^[\x0644nN].*", L"\x0646\x0639\x0645", L"\x0644\x0627" }, - { "ar_SA", L"^[\x0646yY].*", L"^[\x0644nN].*", L"\x0646\x0639\x0645", L"\x0644\x0627" }, - { "ar_SD", L"^[\x0646yY].*", L"^[\x0644nN].*", L"\x0646\x0639\x0645", L"\x0644\x0627" }, - { "ar_SY", L"^[\x0646yY].*", L"^[\x0644nN].*", L"\x0646\x0639\x0645", L"\x0644\x0627" }, - { "ar_TN", L"^[\x0646yY].*", L"^[\x0644nN].*", L"\x0646\x0639\x0645", L"\x0644\x0627" }, - { "ar_YE", L"^[\x0646yY].*", L"^[\x0644nN].*", L"\x0646\x0639\x0645", L"\x0644\x0627" }, - { "ast_ES", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "be_BY", L"^[\x0422\x0442Yy].*", L"^[\x041d\x043dNn].*", L"", L"" }, - { "be_BY@latin", L"^[TtYy].*", L"^[Nn].*", L"", L"" }, - { "ber_DZ", L"^[Bb].*", L"^[YyNn].*", L"b\x0259li", L"yox" }, - { "ber_MA", L"^[Bb].*", L"^[YyNn].*", L"b\x0259li", L"yox" }, - { "bg_BG", L"^[+1\x0414\x0434\x0044\x0064YyOo].*", L"^[-0\x041d\x043dNnKk].*", L"", L"" }, - { "bn_BD", L"^[\x09b9\x09cd\x09af\x09be\x0981yY]", L"^[\x09a8\x09benN]", L"\x09b9\x09cd\x09af\x09be\x0981", L"\x09a8\x09be" }, - { "bn_IN", L"^[\x09b9\x09cd\x09af\x09be\x0981yY]", L"^[\x09a8\x09benN]", L"\x09b9\x09cd\x09af\x09be\x0981", L"\x09a8\x09be" }, - { "bo_CN", L"^[\x0f68Yy].*", L"^[\x0f58Nn].*", L"\x0f68\x0f72\x0f53", L"\x0f58\x0f7a\x0f53" }, - { "bo_IN", L"^[\x0f68Yy].*", L"^[\x0f58Nn].*", L"\x0f68\x0f72\x0f53", L"\x0f58\x0f7a\x0f53" }, - { "br_FR", L"^[oOyY].*", L"^[nN].*", L"", L"" }, - { "br_FR@euro", L"^[oOyY].*", L"^[nN].*", L"", L"" }, - { "bs_BA", L"^[dDyY]*.", L"^[nN]*.", L"", L"" }, - { "byn_ER", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "ca_AD", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "ca_ES", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "ca_ES@euro", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "ca_FR", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "ca_IT", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "crh_UA", L"^[Ee].*", L"^[YyNn].*", L"ebet", L"yoq" }, - { "cs_CZ", L"^[aAyY].*", L"^[nN].*", L"ano", L"ne" }, - { "csb_PL", L"^[JjTtYy].*", L"^[nN].*", L"", L"" }, - { "cy_GB", L"^[iItTyY].*", L"^[nN].*", L"ie", L"na" }, - { "da_DK", L"^[1JjYy].*", L"^[0Nn].*", L"", L"" }, - { "de_AT", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "de_AT@euro", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "de_BE", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "de_BE@euro", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "de_CH", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "de_DE", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "de_DE@euro", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "de_LU", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "de_LU@euro", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "dz_BT", L"^[\x0f68Yy].*", L"^[\x0f58Nn].*", L"\x0f68\x0f72\x0f53", L"\x0f58\x0f7a\x0f53" }, - { "el_CY", L"^[\x03bd\x039dyY].*", L"^[\x03bf\x039fnN].*", L"", L"" }, - { "el_GR", L"^[\x03bd\x039dyY].*", L"^[\x03bf\x039fnN].*", L"", L"" }, - { "en_AG", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "en_AU", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "en_BW", L"^[yY]", L"^[nN]", L"", L"" }, - { "en_CA", L"^[yYoO].*", L"^[nN].*", L"", L"" }, - { "en_DK", L"^[1JjsSyYoO].*", L"^[0nN].*", L"", L"" }, - { "en_GB", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "en_HK", L"^[yY]", L"^[nN]", L"Yes", L"No" }, - { "en_IE", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "en_IE@euro", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "en_IN", L"^[yY]", L"^[nN]", L"Yes", L"No" }, - { "en_NG", L"^[yY]", L"^[nN]", L"", L"" }, - { "en_NZ", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "en_PH", L"^[yY]", L"^[nN]", L"Yes", L"No" }, - { "en_SG", L"^[yY]", L"^[nN]", L"Yes", L"No" }, - { "en_US", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "en_ZA", L"^[yY]", L"^[nN]", L"", L"" }, - { "en_ZW", L"^[yY]", L"^[nN]", L"", L"" }, - { "es_AR", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "es_BO", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "es_CL", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "es_CO", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "es_CR", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "es_DO", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "es_EC", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "es_ES", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "es_ES@euro", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "es_GT", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "es_HN", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "es_MX", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "es_NI", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "es_PA", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "es_PE", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "es_PR", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "es_PY", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "es_SV", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "es_US", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "es_UY", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "es_VE", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "et_EE", L"^[JjYy].*", L"^[EeNn].*", L"", L"" }, - { "eu_ES", L"^[bBsSyY].*", L"^[eEnN].*", L"", L"" }, - { "eu_ES@euro", L"^[bBsSyY].*", L"^[eEnN].*", L"", L"" }, - { "fa_IR", L"^[yY\x0622\x0628Hf].*", L"^[nN\x062e\x0646ok].*", L"", L"" }, - { "fi_FI", L"^[KkJjYy].*", L"^[NnEe].*", L"", L"" }, - { "fi_FI@euro", L"^[KkJjYy].*", L"^[NnEe].*", L"", L"" }, - { "fil_PH", L"[oOyY].*", L"[hHnN].*", L"oo", L"hindi" }, - { "fo_FO", L"^[JjYy].*", L"^[Nn].*", L"", L"" }, - { "fr_BE", L"^[oOjJyY1].*", L"^[nN0].*", L"", L"" }, - { "fr_BE@euro", L"^[oOjJyY1].*", L"^[nN0].*", L"", L"" }, - { "fr_CA", L"^[oOyY].*", L"^[nN].*", L"", L"" }, - { "fr_CH", L"^[OojJsSyY].*", L"^[nN].*", L"", L"" }, - { "fr_FR", L"^[oOyY].*", L"^[nN].*", L"", L"" }, - { "fr_FR@euro", L"^[oOyY].*", L"^[nN].*", L"", L"" }, - { "fr_LU", L"^[oOyY].*", L"^[nN].*", L"", L"" }, - { "fr_LU@euro", L"^[oOyY].*", L"^[nN].*", L"", L"" }, - { "fur_IT", L"^[sSjJoOyY].*", L"^[nN].*", L"", L"" }, - { "fy_DE", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "fy_NL", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "ga_IE", L"^[tTyY].*", L"^[nN].*", L"", L"" }, - { "ga_IE@euro", L"^[tTyY].*", L"^[nN].*", L"", L"" }, - { "gd_GB", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "gez_ER", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "gez_ER@abegede", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "gez_ET", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "gez_ET@abegede", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "gl_ES", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "gl_ES@euro", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "gu_IN", L"^[yY\x0ab9]", L"^[nN\x0aa8]", L"", L"" }, - { "gv_GB", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "ha_NG", L"^[TtiIYy].*", L"^[bBaAnN].*", L"Toh", L"Babu" }, - { "he_IL", L"^[Yy\x05db].*", L"^[Nn\x05dc].*", L"", L"" }, - { "hi_IN", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "hne_IN", L"^[\x0939\x0935yY]", L"^[\x0928\x0907nN]", L"\x0939\x0935", L"\x0928\x0907" }, - { "hr_HR", L"^[dDyY].*", L"^[nN].*", L"", L"" }, - { "hsb_DE", L"^[hHyY].*", L"^[nN].*", L"haj", L"n\x011b" }, - { "ht_HT", L"^[ooyy].*", L"^[nn].*", L"", L"" }, - { "hu_HU", L"^[IiYy].*", L"^[nN].*", L"", L"" }, - { "hy_AM", L"^[yYsS\x0561\x0531]", L"^[nN\x0578\x0548]", L"\x0561\x0575\x0578", L"\x0578\x0579" }, - { "id_ID", L"^[yY].*", L"^[tTnN].*", L"", L"" }, - { "ig_NG", L"^[EeIiYy].*", L"^[0MmNn].*", L"Ee", L"Mba" }, - { "ik_CA", L"[yYiIaA].*", L"[nNqQ].*", L"aa", L"qa\x00f1\x0061\x0061" }, - { "is_IS", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "it_CH", L"^[sSjJoOyY].*", L"^[nN].*", L"", L"" }, - { "it_IT", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "it_IT@euro", L"^[sSyY].*", L"^[nN].*", L"", L"" }, - { "iu_CA", L"[yYsS].*", L"[nN].*", L"", L"" }, - { "iw_IL", L"^[Yy\x05db].*", L"^[Nn\x05dc].*", L"", L"" }, - { "ja_JP", L"^([yY\xff59\xff39]|\x306f\x3044|\x30cf\x30a4)", L"^([nN\xff4e\xff2e]|\x3044\x3044\x3048|\x30a4\x30a4\x30a8)", L"\x306f\x3044", L"\x3044\x3044\x3048" }, - { "ka_GE", L"^[1yYkKxX\x10ee].*", L"^[0nNaA\x10d0].*", L"", L"" }, - { "kk_KZ", L"^[\x0418\x0438Yy].*", L"^[\x0416\x0436Nn].*", L"", L"" }, - { "kl_GL", L"^[JjYyAa].*", L"^[Nn].*", L"", L"" }, - { "km_KH", L"^[yY]([eE][sS])?", L"^[nN][oO]?", L"yes:YES:y:Y", L"no:NO:n:N" }, - { "kn_IN", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "ko_KR", L"^[yY\xc608]", L"^[nN\xc544]", L"", L"\xc544\xb2c8\xc624" }, - { "ks_IN", L"^[\x0622yY].*", L"^[\x0646nN].*", L"\x0622", L"\x0646\x0639" }, - { "ks_IN@devanagari", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "ku_TR", L"^[eEdDyY].*", L"^[nN].*", L"er\x00ea", L"n\x00e2" }, - { "kw_GB", L"^[eEyY].*", L"^[nN].*", L"", L"" }, - { "ky_KG", L"^[\x041e\x043eYy].*", L"^[\x0416\x0436Nn].*", L"\x041e\x043e\x0431\x0430", L"\x0416\x043e\x043a" }, - { "lg_UG", L"^[yY]", L"^[nN]", L"", L"" }, - { "li_BE", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "li_NL", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "lo_LA", L"^[yY\x0ea1]", L"^[nN\x0e9a]", L"\x0ec1\x0ea1\x0ec8\x0e99", L"\x0e9a\x0ecd\x0ec8\x0ec1\x0ea1\x0ec8\x0e99" }, - { "lt_LT", L"^[TtYy].*", L"^[Nn].*", L"", L"" }, - { "lv_LV", L"^[JjYy].*", L"^[Nn].*", L"", L"" }, - { "mai_IN", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "mg_MG", L"^[eEyY].*", L"^[tTnN].*", L"", L"" }, - { "mi_NZ", L"^[1yY\x0101\x0100\x00e4\x00c4\x0061\x0041].*", L"^[0nNkK].*", L"\x0101\x0065", L"k\x0101ore" }, - { "mk_MK", L"^[\x0414\x0434\x0044\x0064Yy1].*", L"^[\x041d\x043dNn0].*", L"\x0434\x0430", L"\x043d\x0435" }, - { "ml_IN", L"^[\x0d05\x0d24\x0d46yY]", L"^[\x0d05\x0d32\x0d4d\x0d32nN]", L"\x0d05\x0d24\x0d46", L"\x0d05\x0d32\x0d4d\x0d32" }, - { "mn_MN", L"^[\x0442\x0422yY].*", L"^[\x04af\x04aenN].*", L"", L"" }, - { "mr_IN", L"^(Yes|[yY])", L"^(No|[nN])", L"", L"" }, - { "ms_MY", L"^[yY]", L"^[tT]", L"Ya", L"Tidak" }, - { "mt_MT", L"^(Yes|[yY])", L"^(No|[nN])", L"", L"" }, - { "nan_TW@latin", L"^[sS].*", L"^[mM].*", L"S\x012b", L"M\x0304-S\x012b" }, - { "nb_NO", L"^[JjYy].*", L"^[Nn].*", L"", L"" }, - { "nds_DE", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "nds_NL", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "ne_NP", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "nl_AW", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "nl_BE", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "nl_BE@euro", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "nl_NL", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "nl_NL@euro", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "nn_NO", L"^[JjYy].*", L"^[Nn].*", L"", L"" }, - { "no_NO", L"^[JjYy].*", L"^[Nn].*", L"", L"" }, - { "nr_ZA", L"^[yY]", L"^[nN]", L"", L"" }, - { "nso_ZA", L"^[yYeE]", L"^[nNaA]", L"", L"" }, - { "oc_FR", L"^[oOsSyY].*", L"^[nN].*", L"", L"" }, - { "om_ET", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "om_KE", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "or_IN", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "pa_IN", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "pa_PK", L"^[yY\x0647\x0628\x0066].*", L"^[nN\x0646o].*", L"\x0628\x0644\x0643\x0644", L"\x0646\x0647\x064a\x06ba" }, - { "pap_AN", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "pl_PL", L"^[TtYy].*", L"^[nN].*", L"", L"" }, - { "pt_BR", L"^[SsyY].*", L"^[nN].*", L"", L"" }, - { "pt_PT", L"^[SsyY].*", L"^[nN].*", L"", L"" }, - { "pt_PT@euro", L"^[SsyY].*", L"^[nN].*", L"", L"" }, - { "ro_RO", L"^[DdYy].*", L"^[nN].*", L"", L"" }, - { "ru_RU", L"^[\x0414\x0434Yy].*", L"^[\x041d\x043dNn].*", L"", L"" }, - { "ru_UA", L"^[\x0414\x0434Yy].*", L"^[\x041d\x043dNn].*", L"", L"" }, - { "rw_RW", L"^[yY]", L"^[nNoO]", L"", L"" }, - { "sa_IN", L"^[aAyY].*", L"^[nN].*", L"", L"" }, - { "sc_IT", L"^[sSjJoOyY].*", L"^[nN].*", L"", L"" }, - { "sd_IN", L"^[\x0646yY].*", L"^[\x0644nN].*", L"\x0646\x0639\x0645", L"\x0644\x0627" }, - { "sd_IN@devanagari", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "se_NO", L"^[JjYy].*", L"^[Ii].*", L"", L"" }, - { "shs_CA", L"^[yYoO].*", L"^[nN].*", L"", L"" }, - { "si_LK", L"^[\x0d94Yy]", L"^[\x0db1Nn]", L"\x0d94\x0dc0\x0dca", L"\x0db1\x0dd0\x0dad" }, - { "sid_ET", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "sk_SK", L"^[aA\x00e1\x00c1yY].*", L"^[nN].*", L"\x00e1no", L"nie" }, - { "sl_SI", L"^[YyJj].*", L"^[Nn].*", L"", L"" }, - { "so_DJ", L"^[oOyY].*", L"^[nN].*", L"", L"" }, - { "so_ET", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "so_KE", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "so_SO", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "sq_AL", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "sr_CS", L"^[\x0414\x0434\x0044\x0064Yy]", L"^[\x041d\x043dNn]", L"", L"" }, - { "sr_CS@latin", L"^[dDyY]", L"^[nN]", L"", L"" }, - { "sr_ME", L"^[\x0414\x0434\x0044\x0064Yy]", L"^[\x041d\x043dNn]", L"", L"" }, - { "sr_ME@latin", L"^[dDyY]", L"^[nN]", L"", L"" }, - { "sr_RS", L"^[\x0414\x0434\x0044\x0064Yy]", L"^[\x041d\x043dNn]", L"", L"" }, - { "sr_RS@latin", L"^[dDyY]", L"^[nN]", L"", L"" }, - { "sr_SP", L"^[\x0414\x0434\x0044\x0064Yy]", L"^[\x041d\x043dNn]", L"", L"" }, - { "sr_SP@latin", L"^[dDyY]", L"^[nN]", L"", L"" }, - { "ss_ZA", L"^[yY]", L"^[nNaA]", L"", L"" }, - { "st_ZA", L"^[yY]", L"^[nN]", L"", L"" }, - { "sv_FI", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "sv_FI@euro", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "sv_SE", L"^[jJyY].*", L"^[nN].*", L"", L"" }, - { "ta_IN", L"^[\x0b86\x0bae\x0bcdyY]", L"^[\x0b87\x0bb2\x0bcd\x0bb2\x0bc8nN]", L"\x0b86\x0bae\x0bcd", L"\x0b87\x0bb2\x0bcd\x0bb2\x0bc8" }, - { "te_IN", L"^[yY\x0c05].*", L"^[nN\x0c15].*", L"\x0c05\x0c35\x0c28\x0c41", L"\x0c15\x0c3e\x0c26\x0c41" }, - { "tg_TJ", L"^[\x04b2\x04b3\x0425\x0445\x0414\x0434Yy].*", L"^[\x041d\x043dNn].*", L"\x0434\x0430", L"\x043d\x0435\x0442" }, - { "th_TH", L"^[yY\x0e0a]", L"^[nN\x0e21]", L"\x0e43\x0e0a\x0e48", L"\x0e44\x0e21\x0e48\x0e43\x0e0a\x0e48" }, - { "ti_ER", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "ti_ET", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "tig_ER", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "tk_TM", L"^[hH].*", L"^[\x00fd\x00ddnN].*", L"hawa", L"\x00fdok" }, - { "tl_PH", L"^[yY].*", L"^[nN].*", L"", L"" }, - { "tn_ZA", L"^[yYeE]", L"^[nN]", L"", L"" }, - { "tr_CY", L"^[yYeE]", L"^[nNhH]", L"evet", L"hay\x0131r" }, - { "tr_TR", L"^[yYeE]", L"^[nNhH]", L"evet", L"hay\x0131r" }, - { "ts_ZA", L"^[yY]", L"^[nN]", L"", L"" }, - { "ug_CN", L"^[1JjsSyYoO].*", L"^[0nN].*", L"yes", L"no" }, - { "uk_UA", L"^([Yy+]|[\x0422\x0442][\x0410\x0430][\x041a\x043a]?)$", L"^([Nn-]|[\x041d\x043d][\x0406\x0456])$", L"\x0442\x0430\x043a", L"\x043d\x0456" }, - { "ur_PK", L"^[yY\x0647\x0628\x0066].*", L"^[nN\x0646o].*", L"\x0628\x0644\x0643\x0644", L"\x0646\x0647\x064a\x06ba" }, - { "uz_UZ", L"^[yY\x0647\x0628\x0066].*", L"^[nN\x0646o].*", L"\x0628\x0644\x0643\x0644", L"\x0646\x0647\x064a\x06ba" }, - { "uz_UZ@cyrillic", L"^[\x04b2\x04b3Yy].*", L"^[\x0419\x0439Nn].*", L"\x04b2\x0430", L"\x0419\x045e\x049b" }, - { "ve_ZA", L"^[yYeE]", L"^[nNhH]", L"", L"" }, - { "vi_VN", L"^[1yYcC].*", L"^[0nNkK].*", L"C\x00f3", L"Kh\x00f4ng" }, - { "wa_BE", L"^[oOyYaAwW].*", L"^[nN].*", L"Oyi", L"Neni" }, - { "wa_BE@euro", L"^[oOyYaAwW].*", L"^[nN].*", L"Oyi", L"Neni" }, - { "wo_SN", L"^[wWyY].*", L"^[dDnN].*", L"", L"" }, - { "xh_ZA", L"^[yYeE]", L"^[nNhH]", L"", L"" }, - { "yi_US", L"^[Yy\x05d9].*", L"^[Nn\x05e0\x05e7].*", L"\x05d9\x05d0\x05b8", L"\x05e7\x05f2\x05df" }, - { "yo_NG", L"^[EeyY].*", L"^[rROoKkNn].*", L"B\x1eb9\x0301\x1eb9\x0300 ni", L"B\x1eb9\x0301\x1eb9\x0300 k\x1ecd\x0301" }, - { "zh_CN", L"^[yY\x662f]", L"^[nN\x4e0d\x5426]", L"", L"" }, - { "zh_HK", L"^[yY\x662f]", L"^[nN\x4e0d\x5426]", L"", L"" }, - { "zh_SG", L"^[yY]", L"^[nN]", L"Yes", L"No" }, - { "zh_TW", L"^[yY\x662f]", L"^[nN\x4e0d\x5426]", L"", L"" }, - { "zu_ZA", L"^[yY]", L"^[nNcC]", L"", L"" }, -}; diff --git a/winsup/cygwin/lib/_cygwin_crt0_common.cc b/winsup/cygwin/lib/_cygwin_crt0_common.cc deleted file mode 100644 index 173f85268..000000000 --- a/winsup/cygwin/lib/_cygwin_crt0_common.cc +++ /dev/null @@ -1,156 +0,0 @@ -/* _cygwin_crt0_common.cc: common crt0 function for cygwin crt0's. - - Copyright 2000, 2001, 2002, 2003, 2004, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "crt0.h" -#include "cygwin-cxx.h" - -/* Weaken these declarations so the references don't pull in C++ dependencies - unnecessarily. */ -#define WEAK __attribute__ ((weak)) - -/* Use asm names to bypass the --wrap that is being applied to redirect all other - references to these operators toward the redirectors in the Cygwin DLL; this - way we can record what definitions were visible at final link time but still - send all calls to the redirectors. */ -extern WEAK void *operator new(std::size_t sz) throw (std::bad_alloc) - __asm__ ("___real__Znwj"); -extern WEAK void *operator new[](std::size_t sz) throw (std::bad_alloc) - __asm__ ("___real__Znaj"); -extern WEAK void operator delete(void *p) throw() - __asm__ ("___real__ZdlPv "); -extern WEAK void operator delete[](void *p) throw() - __asm__ ("___real__ZdaPv"); -extern WEAK void *operator new(std::size_t sz, const std::nothrow_t &nt) throw() - __asm__ ("___real__ZnwjRKSt9nothrow_t"); -extern WEAK void *operator new[](std::size_t sz, const std::nothrow_t &nt) throw() - __asm__ ("___real__ZnajRKSt9nothrow_t"); -extern WEAK void operator delete(void *p, const std::nothrow_t &nt) throw() - __asm__ ("___real__ZdlPvRKSt9nothrow_t"); -extern WEAK void operator delete[](void *p, const std::nothrow_t &nt) throw() - __asm__ ("___real__ZdaPvRKSt9nothrow_t"); - -/* Avoid an info message from linker when linking applications. */ -extern __declspec(dllimport) struct _reent *_impure_ptr; - -/* Initialised in _cygwin_dll_entry. */ -extern int __dynamically_loaded; - -#undef environ - -extern "C" -{ -char **environ; -int cygwin_attach_dll (HMODULE, MainFunc); -int cygwin_attach_noncygwin_dll (HMODULE, MainFunc); -int main (int, char **, char **); -int _fmode; -void _pei386_runtime_relocator (); - -struct per_process_cxx_malloc __cygwin_cxx_malloc = -{ - &(operator new), &(operator new[]), - &(operator delete), &(operator delete[]), - &(operator new), &(operator new[]), - &(operator delete), &(operator delete[]) -}; - -/* Set up pointers to various pieces so the dll can then use them, - and then jump to the dll. */ - -int __stdcall -_cygwin_crt0_common (MainFunc f, per_process *u) -{ - per_process *newu = (per_process *) cygwin_internal (CW_USER_DATA); - bool uwasnull; - - /* u is non-NULL if we are in a DLL, and NULL in the main exe. - newu is the Cygwin DLL's internal per_process and never NULL. */ - if (u != NULL) - uwasnull = false; /* Caller allocated space for per_process structure. */ - else - { - u = newu; /* Using DLL built-in per_process. */ - uwasnull = true; /* Remember for later. */ - } - - /* The version numbers are the main source of compatibility checking. - As a backup to them, we use the size of the per_process struct. */ - u->magic_biscuit = sizeof (per_process); - - /* cygwin.dll version number in effect at the time the app was created. */ - u->dll_major = CYGWIN_VERSION_DLL_MAJOR; - u->dll_minor = CYGWIN_VERSION_DLL_MINOR; - u->api_major = CYGWIN_VERSION_API_MAJOR; - u->api_minor = CYGWIN_VERSION_API_MINOR; - - u->ctors = &__CTOR_LIST__; - u->dtors = &__DTOR_LIST__; - u->envptr = &environ; - if (uwasnull) - _impure_ptr = u->impure_ptr; /* Use field initialized in newer DLLs. */ - else - u->impure_ptr_ptr = &_impure_ptr; /* Older DLLs need this. */ - - u->main = f; - - /* These functions are executed prior to main. They are just stubs unless the - user overrides them. */ - u->premain[0] = cygwin_premain0; - u->premain[1] = cygwin_premain1; - u->premain[2] = cygwin_premain2; - u->premain[3] = cygwin_premain3; - u->fmode_ptr = &_fmode; - - /* This is used to record what the initial sp was. The value is needed - when copying the parent's stack to the child during a fork. */ - u->initial_sp = (char *) __builtin_frame_address (1); - - /* Remember whatever the user linked his application with - or - point to entries in the dll. */ - u->malloc = &malloc; - u->free = &free; - u->realloc = &realloc; - u->calloc = &calloc; - - /* Likewise for the C++ memory operators, if any, but not if we - were dlopen()'d, as we might get dlclose()'d and that would - leave stale function pointers behind. */ - if (newu && newu->cxx_malloc && !__dynamically_loaded) - { - /* Inherit what we don't override. */ -#define CONDITIONALLY_OVERRIDE(MEMBER) \ - if (!__cygwin_cxx_malloc.MEMBER) \ - __cygwin_cxx_malloc.MEMBER = newu->cxx_malloc->MEMBER; - CONDITIONALLY_OVERRIDE(oper_new); - CONDITIONALLY_OVERRIDE(oper_new__); - CONDITIONALLY_OVERRIDE(oper_delete); - CONDITIONALLY_OVERRIDE(oper_delete__); - CONDITIONALLY_OVERRIDE(oper_new_nt); - CONDITIONALLY_OVERRIDE(oper_new___nt); - CONDITIONALLY_OVERRIDE(oper_delete_nt); - CONDITIONALLY_OVERRIDE(oper_delete___nt); - /* Now update the resulting set into the global redirectors. */ - *newu->cxx_malloc = __cygwin_cxx_malloc; - } - - /* Setup the module handle so fork can get the path name. */ - u->hmodule = GetModuleHandle (0); - - /* variables for fork */ - u->data_start = &_data_start__; - u->data_end = &_data_end__; - u->bss_start = &_bss_start__; - u->bss_end = &_bss_end__; - - _pei386_runtime_relocator (); - return 1; -} -} /* "C" */ diff --git a/winsup/cygwin/lib/crt0.h b/winsup/cygwin/lib/crt0.h deleted file mode 100644 index 461ea9b2e..000000000 --- a/winsup/cygwin/lib/crt0.h +++ /dev/null @@ -1,23 +0,0 @@ -/* crt0.h: header file for crt0. - - Copyright 2000, 2001, 2008 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -struct per_process; -typedef int (*MainFunc) (int argc, char *argv[], char **env); -int __stdcall _cygwin_crt0_common (MainFunc, struct per_process *); -int dll_dllcrt0 (HMODULE, struct per_process *); - -#ifdef __cplusplus -} -#endif diff --git a/winsup/cygwin/lib/cygwin_attach_dll.c b/winsup/cygwin/lib/cygwin_attach_dll.c deleted file mode 100644 index 49bb9256d..000000000 --- a/winsup/cygwin/lib/cygwin_attach_dll.c +++ /dev/null @@ -1,27 +0,0 @@ -/* attach_dll.cc: crt0 for attaching cygwin DLL from a non-cygwin app. - - Copyright 2000, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#undef __INSIDE_CYGWIN__ -#include -#include /* Needed since call to sys/time.h via sys/cygwin.h - complains otherwise */ -#include -#include "crt0.h" - -/* for a loaded dll */ -int -cygwin_attach_dll (HMODULE h, MainFunc f) -{ - static struct per_process u; - (void) _cygwin_crt0_common (f, &u); - - /* jump into the dll. */ - return dll_dllcrt0 (h, &u); -} diff --git a/winsup/cygwin/lib/cygwin_crt0.c b/winsup/cygwin/lib/cygwin_crt0.c deleted file mode 100644 index a3aa07773..000000000 --- a/winsup/cygwin/lib/cygwin_crt0.c +++ /dev/null @@ -1,23 +0,0 @@ -/* cygwin_crt0.cc: crt0 for cygwin - - Copyright 2000, 2001, 2008, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#undef __INSIDE_CYGWIN__ -#include "crt0.h" - -extern void __stdcall _dll_crt0 () - __declspec (dllimport) __attribute ((noreturn)); - -/* for main module */ -void -cygwin_crt0 (MainFunc f) -{ - _cygwin_crt0_common (f, NULL); - _dll_crt0 (); /* Jump into the dll, never to return */ -} diff --git a/winsup/cygwin/lib/dll_entry.c b/winsup/cygwin/lib/dll_entry.c deleted file mode 100644 index 781f6a3ea..000000000 --- a/winsup/cygwin/lib/dll_entry.c +++ /dev/null @@ -1,17 +0,0 @@ -/* dll_entry.cc: Provide the default user DLL linker entry point. - - Copyright 1998, 2000, 2001 Red Hat, Inc. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* Here we simply instantiate the DECLARE_CYGWIN_DLL to define the - linker entry point, __cygwin_dll_entry@12, which in turn calls - _DllMain@12 to do user-specific initialization, if any. There is a - default DllMain stub in the library if there is no user supplied - one. */ - -#include "cygwin/cygwin_dll.h" - -DECLARE_CYGWIN_DLL (DllMain); diff --git a/winsup/cygwin/lib/dll_main.cc b/winsup/cygwin/lib/dll_main.cc deleted file mode 100644 index 7f977f689..000000000 --- a/winsup/cygwin/lib/dll_main.cc +++ /dev/null @@ -1,38 +0,0 @@ -/* dll_main.cc: Provide the DllMain stub that the user can override. - - Copyright 1998, 2000, 2001, 2009 Red Hat, Inc. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - - -#define WIN32_LEAN_AND_MEAN -#include - -extern "C" -BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, - LPVOID reserved /* Not used. */); - -BOOL APIENTRY -DllMain ( - HINSTANCE hInst /* Library instance handle. */ , - DWORD reason /* Reason this function is being called. */ , - LPVOID reserved /* Not used. */) -{ - switch (reason) - { - case DLL_PROCESS_ATTACH: - break; - - case DLL_PROCESS_DETACH: - break; - - case DLL_THREAD_ATTACH: - break; - - case DLL_THREAD_DETACH: - break; - } - return TRUE; -} diff --git a/winsup/cygwin/lib/libcmain.c b/winsup/cygwin/lib/libcmain.c deleted file mode 100644 index d1faba1b3..000000000 --- a/winsup/cygwin/lib/libcmain.c +++ /dev/null @@ -1,43 +0,0 @@ -/* libcmain.c - - Copyright 1996, 1997, 1998, 2000, 2001, 2006, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include - -#define SP " \t\n" - -/* Allow apps which don't have a main to work, as long as they define WinMain */ -int -main () -{ - HMODULE x = GetModuleHandle (0); - char *s = GetCommandLine (); - STARTUPINFO si; - char *nexts; - - s += strspn (s, SP); - - if (*s != '"') - nexts = strpbrk (s, SP); - else - while ((nexts = strchr (s + 1, '"')) != NULL && nexts[-1] == '\\') - s = nexts; - - if (!nexts) - nexts = strchr (s, '\0'); - else - nexts += strspn (nexts + 1, SP); - - GetStartupInfo (&si); - - return WinMain (x, 0, nexts, - ((si.dwFlags & STARTF_USESHOWWINDOW) != 0 - ? si.wShowWindow - : SW_SHOWNORMAL)); -} diff --git a/winsup/cygwin/lib/premain0.c b/winsup/cygwin/lib/premain0.c deleted file mode 100644 index b77e02e8e..000000000 --- a/winsup/cygwin/lib/premain0.c +++ /dev/null @@ -1,14 +0,0 @@ -/* premain0.c - - Copyright 2000 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -void -cygwin_premain0(int argc, char **argv) -{ -} diff --git a/winsup/cygwin/lib/premain1.c b/winsup/cygwin/lib/premain1.c deleted file mode 100644 index 99aeac916..000000000 --- a/winsup/cygwin/lib/premain1.c +++ /dev/null @@ -1,14 +0,0 @@ -/* premain1.c - - Copyright 2000 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -void -cygwin_premain1(int argc, char **argv) -{ -} diff --git a/winsup/cygwin/lib/premain2.c b/winsup/cygwin/lib/premain2.c deleted file mode 100644 index a89e76ec3..000000000 --- a/winsup/cygwin/lib/premain2.c +++ /dev/null @@ -1,14 +0,0 @@ -/* premain2.c - - Copyright 2000 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -void -cygwin_premain2(int argc, char **argv) -{ -} diff --git a/winsup/cygwin/lib/premain3.c b/winsup/cygwin/lib/premain3.c deleted file mode 100644 index c5b99b918..000000000 --- a/winsup/cygwin/lib/premain3.c +++ /dev/null @@ -1,14 +0,0 @@ -/* premain3.c - - Copyright 2000 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -void -cygwin_premain3(int argc, char **argv) -{ -} diff --git a/winsup/cygwin/lib/pseudo-reloc.c b/winsup/cygwin/lib/pseudo-reloc.c deleted file mode 100644 index 77f041114..000000000 --- a/winsup/cygwin/lib/pseudo-reloc.c +++ /dev/null @@ -1,367 +0,0 @@ -/* pseudo-reloc.c - - Contributed by Egor Duda - Modified by addition of runtime_pseudo_reloc version 2 - by Kai Tietz - - THIS SOFTWARE IS NOT COPYRIGHTED - - This source code is offered for use in the public domain. You may - use, modify or distribute it freely. - - This code is distributed in the hope that it will be useful but - WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY - DISCLAMED. This includes but is not limited to warrenties of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -*/ - -#include -#include -#include -#include -#include - -#if defined(__CYGWIN__) -#include -#include -#include -/* copied from winsup.h */ -# define NO_COPY __attribute__((nocommon)) __attribute__((section(".data_cygwin_nocopy"))) -/* custom status code: */ -#define STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION ((NTSTATUS) 0xe0000269) -#define SHORT_MSG_BUF_SZ 128 -#else -# define NO_COPY -#endif - -#ifdef __GNUC__ -#define ATTRIBUTE_NORETURN __attribute__ ((noreturn)) -#else -#define ATTRIBUTE_NORETURN -#endif - -#ifndef __MINGW_LSYMBOL -#define __MINGW_LSYMBOL(sym) sym -#endif - -extern char __RUNTIME_PSEUDO_RELOC_LIST__; -extern char __RUNTIME_PSEUDO_RELOC_LIST_END__; -extern char __MINGW_LSYMBOL(_image_base__); - -void _pei386_runtime_relocator (void); - -/* v1 relocation is basically: - * *(base + .target) += .addend - * where (base + .target) is always assumed to point - * to a DWORD (4 bytes). - */ -typedef struct { - DWORD addend; - DWORD target; -} runtime_pseudo_reloc_item_v1; - -/* v2 relocation is more complex. In effect, it is - * *(base + .target) += *(base + .sym) - (base + .sym) - * with care taken in both reading, sign extension, and writing - * because .flags may indicate that (base + .target) may point - * to a BYTE, WORD, DWORD, or QWORD (w64). - */ -typedef struct { - DWORD sym; - DWORD target; - DWORD flags; -} runtime_pseudo_reloc_item_v2; - -typedef struct { - DWORD magic1; - DWORD magic2; - DWORD version; -} runtime_pseudo_reloc_v2; - -static void ATTRIBUTE_NORETURN -__report_error (const char *msg, ...) -{ -#ifdef __CYGWIN__ - /* This function is used to print short error messages - * to stderr, which may occur during DLL initialization - * while fixing up 'pseudo' relocations. This early, we - * may not be able to use cygwin stdio functions, so we - * use the win32 WriteFile api. This should work with both - * normal win32 console IO handles, redirected ones, and - * cygwin ptys. - */ - char buf[SHORT_MSG_BUF_SZ]; - wchar_t module[MAX_PATH]; - char * posix_module = NULL; - static const char UNKNOWN_MODULE[] = ": "; - static const size_t UNKNOWN_MODULE_LEN = sizeof (UNKNOWN_MODULE) - 1; - static const char CYGWIN_FAILURE_MSG[] = "Cygwin runtime failure: "; - static const size_t CYGWIN_FAILURE_MSG_LEN = sizeof (CYGWIN_FAILURE_MSG) - 1; - DWORD len; - DWORD done; - va_list args; - HANDLE errh = GetStdHandle (STD_ERROR_HANDLE); - ssize_t modulelen = GetModuleFileNameW (NULL, module, sizeof (module)); - - if (errh == INVALID_HANDLE_VALUE) - cygwin_internal (CW_EXIT_PROCESS, - STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION, - 1); - - if (modulelen > 0) - posix_module = cygwin_create_path (CCP_WIN_W_TO_POSIX, module); - - va_start (args, msg); - len = (DWORD) vsnprintf (buf, SHORT_MSG_BUF_SZ, msg, args); - va_end (args); - buf[SHORT_MSG_BUF_SZ-1] = '\0'; /* paranoia */ - - if (posix_module) - { - WriteFile (errh, (PCVOID)CYGWIN_FAILURE_MSG, - CYGWIN_FAILURE_MSG_LEN, &done, NULL); - WriteFile (errh, (PCVOID)posix_module, - strlen(posix_module), &done, NULL); - WriteFile (errh, (PCVOID)": ", 2, &done, NULL); - WriteFile (errh, (PCVOID)buf, len, &done, NULL); - free (posix_module); - } - else - { - WriteFile (errh, (PCVOID)CYGWIN_FAILURE_MSG, - CYGWIN_FAILURE_MSG_LEN, &done, NULL); - WriteFile (errh, (PCVOID)UNKNOWN_MODULE, - UNKNOWN_MODULE_LEN, &done, NULL); - WriteFile (errh, (PCVOID)buf, len, &done, NULL); - } - WriteFile (errh, (PCVOID)"\n", 1, &done, NULL); - - cygwin_internal (CW_EXIT_PROCESS, - STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION, - 1); - /* not reached, but silences noreturn warning */ - abort (); -#else - va_list argp; - va_start (argp, msg); -# ifdef __MINGW64_VERSION_MAJOR - fprintf (stderr, "Mingw-w64 runtime failure:\n"); -# else - fprintf (stderr, "Mingw runtime failure:\n"); -# endif - vfprintf (stderr, msg, argp); - va_end (argp); - abort (); -#endif -} - -/* This function temporarily marks the page containing addr - * writable, before copying len bytes from *src to *addr, and - * then restores the original protection settings to the page. - * - * Using this function eliminates the requirement with older - * pseudo-reloc implementations, that sections containing - * pseudo-relocs (such as .text and .rdata) be permanently - * marked writable. This older behavior sabotaged any memory - * savings achieved by shared libraries on win32 -- and was - * slower, too. However, on cygwin as of binutils 2.20 the - * .text section is still marked writable, and the .rdata section - * is folded into the (writable) .data when --enable-auto-import. - */ -static void -__write_memory (void *addr, const void *src, size_t len) -{ - MEMORY_BASIC_INFORMATION b; - DWORD oldprot; - - if (!len) - return; - - if (!VirtualQuery (addr, &b, sizeof(b))) - { - __report_error (" VirtualQuery failed for %d bytes at address %p", - (int) sizeof(b), addr); - } - - /* Temporarily allow write access to read-only protected memory. */ - if (b.Protect != PAGE_EXECUTE_READWRITE && b.Protect != PAGE_READWRITE) - VirtualProtect (b.BaseAddress, b.RegionSize, PAGE_EXECUTE_READWRITE, - &oldprot); - /* write the data. */ - memcpy (addr, src, len); - /* Restore original protection. */ - if (b.Protect != PAGE_EXECUTE_READWRITE && b.Protect != PAGE_READWRITE) - VirtualProtect (b.BaseAddress, b.RegionSize, oldprot, &oldprot); -} - -#define RP_VERSION_V1 0 -#define RP_VERSION_V2 1 - -static void -do_pseudo_reloc (void * start, void * end, void * base) -{ - ptrdiff_t addr_imp, reldata; - ptrdiff_t reloc_target = (ptrdiff_t) ((char *)end - (char*)start); - runtime_pseudo_reloc_v2 *v2_hdr = (runtime_pseudo_reloc_v2 *) start; - runtime_pseudo_reloc_item_v2 *r; - - /* A valid relocation list will contain at least one entry, and - * one v1 data structure (the smallest one) requires two DWORDs. - * So, if the relocation list is smaller than 8 bytes, bail. - */ - if (reloc_target < 8) - return; - - /* Check if this is the old pseudo relocation version. */ - /* There are two kinds of v1 relocation lists: - * 1) With a (v2-style) version header. In this case, the - * first entry in the list is a 3-DWORD structure, with - * value: - * { 0, 0, RP_VERSION_V1 } - * In this case, we skip to the next entry in the list, - * knowing that all elements after the head item can - * be cast to runtime_pseudo_reloc_item_v1. - * 2) Without a (v2-style) version header. In this case, the - * first element in the list IS an actual v1 relocation - * record, which is two DWORDs. Because there will never - * be a case where a v1 relocation record has both - * addend == 0 and target == 0, this case will not be - * confused with the prior one. - * All current binutils, when generating a v1 relocation list, - * use the second (e.g. original) form -- that is, without the - * v2-style version header. - */ - if (reloc_target >= 12 - && v2_hdr->magic1 == 0 && v2_hdr->magic2 == 0 - && v2_hdr->version == RP_VERSION_V1) - { - /* We have a list header item indicating that the rest - * of the list contains v1 entries. Move the pointer to - * the first true v1 relocation record. By definition, - * that v1 element will not have both addend == 0 and - * target == 0 (and thus, when interpreted as a - * runtime_pseudo_reloc_v2, it will not have both - * magic1 == 0 and magic2 == 0). - */ - v2_hdr++; - } - - if (v2_hdr->magic1 != 0 || v2_hdr->magic2 != 0) - { - /************************* - * Handle v1 relocations * - *************************/ - runtime_pseudo_reloc_item_v1 * o; - for (o = (runtime_pseudo_reloc_item_v1 *) v2_hdr; - o < (runtime_pseudo_reloc_item_v1 *)end; - o++) - { - DWORD newval; - reloc_target = (ptrdiff_t) base + o->target; - newval = (*((DWORD*) reloc_target)) + o->addend; - __write_memory ((void *) reloc_target, &newval, sizeof(DWORD)); - } - return; - } - - /* If we got this far, then we have relocations of version 2 or newer */ - - /* Check if this is a known version. */ - if (v2_hdr->version != RP_VERSION_V2) - { - __report_error (" Unknown pseudo relocation protocol version %d.\n", - (int) v2_hdr->version); - return; - } - - /************************* - * Handle v2 relocations * - *************************/ - - /* Walk over header. */ - r = (runtime_pseudo_reloc_item_v2 *) &v2_hdr[1]; - - for (; r < (runtime_pseudo_reloc_item_v2 *) end; r++) - { - /* location where new address will be written */ - reloc_target = (ptrdiff_t) base + r->target; - - /* get sym pointer. It points either to the iat entry - * of the referenced element, or to the stub function. - */ - addr_imp = (ptrdiff_t) base + r->sym; - addr_imp = *((ptrdiff_t *) addr_imp); - - /* read existing relocation value from image, casting to the - * bitsize indicated by the 8 LSBs of flags. If the value is - * negative, manually sign-extend to ptrdiff_t width. Raise an - * error if the bitsize indicated by the 8 LSBs of flags is not - * supported. - */ - switch ((r->flags & 0xff)) - { - case 8: - reldata = (ptrdiff_t) (*((unsigned char *)reloc_target)); - if ((reldata & 0x80) != 0) - reldata |= ~((ptrdiff_t) 0xff); - break; - case 16: - reldata = (ptrdiff_t) (*((unsigned short *)reloc_target)); - if ((reldata & 0x8000) != 0) - reldata |= ~((ptrdiff_t) 0xffff); - break; - case 32: - reldata = (ptrdiff_t) (*((unsigned int *)reloc_target)); -#ifdef _WIN64 - if ((reldata & 0x80000000) != 0) - reldata |= ~((ptrdiff_t) 0xffffffff); -#endif - break; -#ifdef _WIN64 - case 64: - reldata = (ptrdiff_t) (*((unsigned long long *)reloc_target)); - break; -#endif - default: - reldata=0; - __report_error (" Unknown pseudo relocation bit size %d.\n", - (int) (r->flags & 0xff)); - break; - } - - /* Adjust the relocation value */ - reldata -= ((ptrdiff_t) base + r->sym); - reldata += addr_imp; - - /* Write the new relocation value back to *reloc_target */ - switch ((r->flags & 0xff)) - { - case 8: - __write_memory ((void *) reloc_target, &reldata, 1); - break; - case 16: - __write_memory ((void *) reloc_target, &reldata, 2); - break; - case 32: - __write_memory ((void *) reloc_target, &reldata, 4); - break; -#ifdef _WIN64 - case 64: - __write_memory ((void *) reloc_target, &reldata, 8); - break; -#endif - } - } -} - -void -_pei386_runtime_relocator (void) -{ - static NO_COPY int was_init = 0; - if (was_init) - return; - ++was_init; - do_pseudo_reloc (&__RUNTIME_PSEUDO_RELOC_LIST__, - &__RUNTIME_PSEUDO_RELOC_LIST_END__, - &__MINGW_LSYMBOL(_image_base__)); -} diff --git a/winsup/cygwin/libc/bsdlib.cc b/winsup/cygwin/libc/bsdlib.cc deleted file mode 100644 index 116b246f0..000000000 --- a/winsup/cygwin/libc/bsdlib.cc +++ /dev/null @@ -1,301 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - * - * 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. - * - * CV 2003-09-10: Cygwin specific changes applied. Code simplified just - * for Cygwin alone. - */ - -#include "winsup.h" -#include -#include -#include -#include -#include -#include -#include "cygtls.h" - -extern "C" int -daemon (int nochdir, int noclose) -{ - int fd; - - switch (fork ()) - { - case -1: - return -1; - case 0: - break; - default: - /* This sleep avoids a race condition which kills the - child process if parent is started by a NT/W2K service. - FIXME: Is that still true? */ - Sleep (1000L); - _exit (0); - } - if (setsid () == -1) - return -1; - if (!nochdir) - chdir ("/"); - if (!noclose && (fd = open (_PATH_DEVNULL, O_RDWR, 0)) >= 0) - { - dup2 (fd, STDIN_FILENO); - dup2 (fd, STDOUT_FILENO); - dup2 (fd, STDERR_FILENO); - if (fd > 2) - close (fd); - } - return 0; -} - -extern "C" int -login_tty (int fd) -{ - char *fdname; - int newfd; - - if (setsid () == -1) - return -1; - if ((fdname = ttyname (fd))) - { - if (fd != STDIN_FILENO) - close (STDIN_FILENO); - if (fd != STDOUT_FILENO) - close (STDOUT_FILENO); - if (fd != STDERR_FILENO) - close (STDERR_FILENO); - newfd = open (fdname, O_RDWR); - close (newfd); - } - dup2 (fd, STDIN_FILENO); - dup2 (fd, STDOUT_FILENO); - dup2 (fd, STDERR_FILENO); - if (fd > 2) - close (fd); - return 0; -} - -extern "C" int -openpty (int *amaster, int *aslave, char *name, const struct termios *termp, - const struct winsize *winp) -{ - int master, slave; - char pts[TTY_NAME_MAX]; - - if ((master = open ("/dev/ptmx", O_RDWR | O_NOCTTY)) >= 0) - { - grantpt (master); - unlockpt (master); - strcpy (pts, ptsname (master)); - revoke (pts); - if ((slave = open (pts, O_RDWR | O_NOCTTY)) >= 0) - { - if (amaster) - *amaster = master; - if (aslave) - *aslave = slave; - if (name) - strcpy (name, pts); - if (termp) - tcsetattr (slave, TCSAFLUSH, termp); - if (winp) - ioctl (slave, TIOCSWINSZ, (char *) winp); - return 0; - } - close (master); - } - set_errno (ENOENT); - return -1; -} - -extern "C" int -forkpty (int *amaster, char *name, const struct termios *termp, - const struct winsize *winp) -{ - int master, slave, pid; - - if (openpty (&master, &slave, name, termp, winp) == -1) - return -1; - switch (pid = fork ()) - { - case -1: - return -1; - case 0: - close (master); - login_tty (slave); - return 0; - } - if (amaster) - *amaster = master; - close (slave); - return pid; -} - -extern "C" char *__progname; - -static void -_vwarnx (const char *fmt, va_list ap) -{ - fprintf (stderr, "%s: ", __progname); - vfprintf (stderr, fmt, ap); -} - -extern "C" void -vwarn (const char *fmt, va_list ap) -{ - _vwarnx (fmt, ap); - fprintf (stderr, ": %s", strerror (get_errno ())); - fputc ('\n', stderr); -} - -extern "C" void -vwarnx (const char *fmt, va_list ap) -{ - _vwarnx (fmt, ap); - fputc ('\n', stderr); -} - -extern "C" void -warn (const char *fmt, ...) -{ - va_list ap; - va_start (ap, fmt); - vwarn (fmt, ap); - va_end (ap); -} - -extern "C" void -warnx (const char *fmt, ...) -{ - va_list ap; - va_start (ap, fmt); - vwarnx (fmt, ap); - va_end (ap); -} - -extern "C" void -verr (int eval, const char *fmt, va_list ap) -{ - vwarn (fmt, ap); - exit (eval); -} - -extern "C" void -verrx (int eval, const char *fmt, va_list ap) -{ - vwarnx (fmt, ap); - exit (eval); -} - -extern "C" void -err (int eval, const char *fmt, ...) -{ - va_list ap; - va_start (ap, fmt); - vwarn (fmt, ap); - va_end (ap); - exit (eval); -} - -extern "C" void -errx (int eval, const char *fmt, ...) -{ - va_list ap; - va_start (ap, fmt); - vwarnx (fmt, ap); - va_end (ap); - exit (eval); -} - -extern "C" const char * -getprogname (void) -{ - return __progname; -} - -extern "C" void -setprogname (const char *newprogname) -{ - myfault efault; - if (!efault.faulted (EFAULT)) - { - /* Per BSD man page, setprogname keeps a pointer to the last - path component of the argument. It does *not* copy the - argument before. */ - __progname = strrchr (newprogname, '/'); - if (__progname) - ++__progname; - else - __progname = (char *)newprogname; - } -} - -extern "C" void -logwtmp (const char *line, const char *user, const char *host) -{ - struct utmp ut; - memset (&ut, 0, sizeof ut); - ut.ut_type = USER_PROCESS; - ut.ut_pid = getpid (); - if (line) - strncpy (ut.ut_line, line, sizeof ut.ut_line); - time (&ut.ut_time); - if (user) - strncpy (ut.ut_user, user, sizeof ut.ut_user); - if (host) - strncpy (ut.ut_host, host, sizeof ut.ut_host); - updwtmp (_PATH_WTMP, &ut); -} - -extern "C" void -login (const struct utmp *ut) -{ - pututline (ut); - endutent (); - updwtmp (_PATH_WTMP, ut); -} - -extern "C" int -logout (const char *line) -{ - struct utmp ut_buf, *ut; - - memset (&ut_buf, 0, sizeof ut_buf); - strncpy (ut_buf.ut_line, line, sizeof ut_buf.ut_line); - setutent (); - ut = getutline (&ut_buf); - - if (ut) - { - ut->ut_type = DEAD_PROCESS; - memset (ut->ut_user, 0, sizeof ut->ut_user); - memset (ut->ut_host, 0, sizeof ut->ut_host); - time (&ut->ut_time); - debug_printf ("set logout time for %s", line); - pututline (ut); - endutent (); - return 1; - } - return 0; -} diff --git a/winsup/cygwin/libc/fnmatch.c b/winsup/cygwin/libc/fnmatch.c deleted file mode 100644 index 295f4c413..000000000 --- a/winsup/cygwin/libc/fnmatch.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Copyright (c) 1989, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Guido van Rossum. - * - * 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. - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94"; -#endif /* LIBC_SCCS and not lint */ -#include -#if 0 -__FBSDID("$FreeBSD: src/lib/libc/gen/fnmatch.c,v 1.18 2007/01/09 00:27:53 imp Exp $"); -#endif - -/* - * Function fnmatch() as specified in POSIX 1003.2-1992, section B.6. - * Compares a filename or pathname to a pattern. - */ - -/* - * Some notes on multibyte character support: - * 1. Patterns with illegal byte sequences match nothing. - * 2. Illegal byte sequences in the "string" argument are handled by treating - * them as single-byte characters with a value of the first byte of the - * sequence cast to wchar_t. - * 3. Multibyte conversion state objects (mbstate_t) are passed around and - * used for most, but not all, conversions. Further work will be required - * to support state-dependent encodings. - */ - -#include -#include -#include -#include -#include - -#include "../posix/collate.h" - -#define EOS '\0' - -#define RANGE_MATCH 1 -#define RANGE_NOMATCH 0 -#define RANGE_ERROR (-1) - -static int rangematch(const char *, wchar_t, int, char **, mbstate_t *); -static int fnmatch1(const char *, const char *, int, mbstate_t, mbstate_t); - -int -fnmatch(pattern, string, flags) - const char *pattern, *string; - int flags; -{ - static const mbstate_t initial; - - return (fnmatch1(pattern, string, flags, initial, initial)); -} - -static int -fnmatch1(pattern, string, flags, patmbs, strmbs) - const char *pattern, *string; - int flags; - mbstate_t patmbs, strmbs; -{ - const char *stringstart; - char *newp; - char c; - wchar_t pc, sc; - size_t pclen, sclen; - - for (stringstart = string;;) { - pclen = mbrtowc(&pc, pattern, MB_LEN_MAX, &patmbs); - if (pclen == (size_t)-1 || pclen == (size_t)-2) - return (FNM_NOMATCH); - pattern += pclen; - sclen = mbrtowc(&sc, string, MB_LEN_MAX, &strmbs); - if (sclen == (size_t)-1 || sclen == (size_t)-2) { - sc = (unsigned char)*string; - sclen = 1; - memset(&strmbs, 0, sizeof(strmbs)); - } - switch (pc) { - case EOS: - if ((flags & FNM_LEADING_DIR) && sc == '/') - return (0); - return (sc == EOS ? 0 : FNM_NOMATCH); - case '?': - if (sc == EOS) - return (FNM_NOMATCH); - if (sc == '/' && (flags & FNM_PATHNAME)) - return (FNM_NOMATCH); - if (sc == '.' && (flags & FNM_PERIOD) && - (string == stringstart || - ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) - return (FNM_NOMATCH); - string += sclen; - break; - case '*': - c = *pattern; - /* Collapse multiple stars. */ - while (c == '*') - c = *++pattern; - - if (sc == '.' && (flags & FNM_PERIOD) && - (string == stringstart || - ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) - return (FNM_NOMATCH); - - /* Optimize for pattern with * at end or before /. */ - if (c == EOS) - if (flags & FNM_PATHNAME) - return ((flags & FNM_LEADING_DIR) || - strchr(string, '/') == NULL ? - 0 : FNM_NOMATCH); - else - return (0); - else if (c == '/' && flags & FNM_PATHNAME) { - if ((string = strchr(string, '/')) == NULL) - return (FNM_NOMATCH); - break; - } - - /* General case, use recursion. */ - while (sc != EOS) { - if (!fnmatch1(pattern, string, - flags & ~FNM_PERIOD, patmbs, strmbs)) - return (0); - sclen = mbrtowc(&sc, string, MB_LEN_MAX, - &strmbs); - if (sclen == (size_t)-1 || - sclen == (size_t)-2) { - sc = (unsigned char)*string; - sclen = 1; - memset(&strmbs, 0, sizeof(strmbs)); - } - if (sc == '/' && flags & FNM_PATHNAME) - break; - string += sclen; - } - return (FNM_NOMATCH); - case '[': - if (sc == EOS) - return (FNM_NOMATCH); - if (sc == '/' && (flags & FNM_PATHNAME)) - return (FNM_NOMATCH); - if (sc == '.' && (flags & FNM_PERIOD) && - (string == stringstart || - ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) - return (FNM_NOMATCH); - - switch (rangematch(pattern, sc, flags, &newp, - &patmbs)) { - case RANGE_ERROR: - goto norm; - case RANGE_MATCH: - pattern = newp; - break; - case RANGE_NOMATCH: - return (FNM_NOMATCH); - } - string += sclen; - break; - case '\\': - if (!(flags & FNM_NOESCAPE)) { - pclen = mbrtowc(&pc, pattern, MB_LEN_MAX, - &patmbs); - if (pclen == (size_t)-1 || pclen == (size_t)-2) - return (FNM_NOMATCH); - if (pclen == 0) - pc = '\\'; - pattern += pclen; - } - /* FALLTHROUGH */ - default: - norm: - if (pc == sc) - ; - else if ((flags & FNM_CASEFOLD) && - (towlower(pc) == towlower(sc))) - ; - else - return (FNM_NOMATCH); - string += sclen; - break; - } - } - /* NOTREACHED */ -} - -static int -rangematch(pattern, test, flags, newp, patmbs) - const char *pattern; - wchar_t test; - int flags; - char **newp; - mbstate_t *patmbs; -{ - int negate, ok; - wchar_t c, c2; - size_t pclen; - const char *origpat; - - /* - * A bracket expression starting with an unquoted circumflex - * character produces unspecified results (IEEE 1003.2-1992, - * 3.13.2). This implementation treats it like '!', for - * consistency with the regular expression syntax. - * J.T. Conklin (conklin@ngai.kaleida.com) - */ - if ( (negate = (*pattern == '!' || *pattern == '^')) ) - ++pattern; - - if (flags & FNM_CASEFOLD) - test = towlower(test); - - /* - * A right bracket shall lose its special meaning and represent - * itself in a bracket expression if it occurs first in the list. - * -- POSIX.2 2.8.3.2 - */ - ok = 0; - origpat = pattern; - for (;;) { - if (*pattern == ']' && pattern > origpat) { - pattern++; - break; - } else if (*pattern == '\0') { - return (RANGE_ERROR); - } else if (*pattern == '/' && (flags & FNM_PATHNAME)) { - return (RANGE_NOMATCH); - } else if (*pattern == '\\' && !(flags & FNM_NOESCAPE)) - pattern++; - pclen = mbrtowc(&c, pattern, MB_LEN_MAX, patmbs); - if (pclen == (size_t)-1 || pclen == (size_t)-2) - return (RANGE_NOMATCH); - pattern += pclen; - - if (flags & FNM_CASEFOLD) - c = towlower(c); - - if (*pattern == '-' && *(pattern + 1) != EOS && - *(pattern + 1) != ']') { - if (*++pattern == '\\' && !(flags & FNM_NOESCAPE)) - if (*pattern != EOS) - pattern++; - pclen = mbrtowc(&c2, pattern, MB_LEN_MAX, patmbs); - if (pclen == (size_t)-1 || pclen == (size_t)-2) - return (RANGE_NOMATCH); - pattern += pclen; - if (c2 == EOS) - return (RANGE_ERROR); - - if (flags & FNM_CASEFOLD) - c2 = towlower(c2); - - if (__collate_load_error ? - c <= test && test <= c2 : - __collate_range_cmp(c, test) <= 0 - && __collate_range_cmp(test, c2) <= 0 - ) - ok = 1; - } else if (c == test) - ok = 1; - } - - *newp = (char *)pattern; - return (ok == negate ? RANGE_NOMATCH : RANGE_MATCH); -} diff --git a/winsup/cygwin/libc/fts.c b/winsup/cygwin/libc/fts.c deleted file mode 100644 index 028884389..000000000 --- a/winsup/cygwin/libc/fts.c +++ /dev/null @@ -1,1249 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * 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. - * 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. - * - * $OpenBSD: fts.c,v 1.22 1999/10/03 19:22:22 millert Exp $ - */ - -#if 0 -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; -#endif /* LIBC_SCCS and not lint */ -#endif -#ifdef __CYGWIN__ -#include "winsup.h" -#include -#define __FBSDID(x) -#define _open open -#define _close close -#endif -#include -__FBSDID("$FreeBSD: /repoman/r/ncvs/src/lib/libc/gen/fts.c,v 1.27 2004/06/08 06:23:23 das Exp $"); - -#ifndef __CYGWIN__ -#include "namespace.h" -#endif -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#ifndef __CYGWIN__ -#include "un-namespace.h" -#endif - -static FTSENT *fts_alloc(FTS *, const char *, int); -static FTSENT *fts_build(FTS *, int); -static void fts_lfree(FTSENT *); -static void fts_load(FTS *, FTSENT *); -static size_t fts_maxarglen(char * const *); -static void fts_padjust(FTS *, FTSENT *); -static int fts_palloc(FTS *, size_t); -static FTSENT *fts_sort(FTS *, FTSENT *, int); -static u_short fts_stat(FTS *, FTSENT *, int); -static int fts_safe_changedir(FTS *, FTSENT *, int, const char *); -static int fts_ufslinks(FTS *, const FTSENT *); - -#define ISDOT(a) (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2]))) - -#define CLR(opt) (sp->fts_options &= ~(opt)) -#define ISSET(opt) (sp->fts_options & (opt)) -#define SET(opt) (sp->fts_options |= (opt)) - -#define FCHDIR(sp, fd) (!ISSET(FTS_NOCHDIR) && fchdir(fd)) - -/* fts_build flags */ -#define BCHILD 1 /* fts_children */ -#define BNAMES 2 /* fts_children, names only */ -#define BREAD 3 /* fts_read */ - -/* - * Internal representation of an FTS, including extra implementation - * details. The FTS returned from fts_open points to this structure's - * ftsp_fts member (and can be cast to an _fts_private as required) - */ -struct _fts_private { - FTS ftsp_fts; - struct statfs ftsp_statfs; - __dev32_t ftsp_dev; - int ftsp_linksreliable; -}; - -/* - * The "FTS_NOSTAT" option can avoid a lot of calls to stat(2) if it - * knows that a directory could not possibly have subdirectories. This - * is decided by looking at the link count: a subdirectory would - * increment its parent's link count by virtue of its own ".." entry. - * This assumption only holds for UFS-like filesystems that implement - * links and directories this way, so we must punt for others. - */ - -#ifndef __CYGWIN__ -static const char *ufslike_filesystems[] = { - "ufs", - "nfs", - "nfs4", - "ext2fs", - 0 -}; -#endif - -FTS * -fts_open(argv, options, compar) - char * const *argv; - int options; - int (*compar)(const FTSENT * const *, const FTSENT * const *); -{ - struct _fts_private *priv; - FTS *sp; - FTSENT *p, *root; - int nitems; - FTSENT *parent, *tmp; - int len; - - /* Options check. */ - if (options & ~FTS_OPTIONMASK) { - errno = EINVAL; - return (NULL); - } - - /* Allocate/initialize the stream. */ - if ((priv = malloc(sizeof(*priv))) == NULL) - return (NULL); - memset(priv, 0, sizeof(*priv)); - sp = &priv->ftsp_fts; - sp->fts_compar = compar; - sp->fts_options = options; - - /* Shush, GCC. */ - tmp = NULL; - - /* Logical walks turn on NOCHDIR; symbolic links are too hard. */ - if (ISSET(FTS_LOGICAL)) - SET(FTS_NOCHDIR); - - /* - * Start out with 1K of path space, and enough, in any case, - * to hold the user's paths. - */ - if (fts_palloc(sp, MAX(fts_maxarglen(argv), MAXPATHLEN))) - goto mem1; - - /* Allocate/initialize root's parent. */ - if ((parent = fts_alloc(sp, "", 0)) == NULL) - goto mem2; - parent->fts_level = FTS_ROOTPARENTLEVEL; - - /* Allocate/initialize root(s). */ - for (root = NULL, nitems = 0; *argv != NULL; ++argv, ++nitems) { - /* Don't allow zero-length paths. */ - if ((len = strlen(*argv)) == 0) { - errno = ENOENT; - goto mem3; - } - - p = fts_alloc(sp, *argv, len); - p->fts_level = FTS_ROOTLEVEL; - p->fts_parent = parent; - p->fts_accpath = p->fts_name; - p->fts_info = fts_stat(sp, p, ISSET(FTS_COMFOLLOW)); - - /* Command-line "." and ".." are real directories. */ - if (p->fts_info == FTS_DOT) - p->fts_info = FTS_D; - - /* - * If comparison routine supplied, traverse in sorted - * order; otherwise traverse in the order specified. - */ - if (compar) { - p->fts_link = root; - root = p; - } else { - p->fts_link = NULL; - if (root == NULL) - tmp = root = p; - else { - tmp->fts_link = p; - tmp = p; - } - } - } - if (compar && nitems > 1) - root = fts_sort(sp, root, nitems); - - /* - * Allocate a dummy pointer and make fts_read think that we've just - * finished the node before the root(s); set p->fts_info to FTS_INIT - * so that everything about the "current" node is ignored. - */ - if ((sp->fts_cur = fts_alloc(sp, "", 0)) == NULL) - goto mem3; - sp->fts_cur->fts_link = root; - sp->fts_cur->fts_info = FTS_INIT; - - /* - * If using chdir(2), grab a file descriptor pointing to dot to ensure - * that we can get back here; this could be avoided for some paths, - * but almost certainly not worth the effort. Slashes, symbolic links, - * and ".." are all fairly nasty problems. Note, if we can't get the - * descriptor we run anyway, just more slowly. - */ - if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = _open(".", O_RDONLY, 0)) < 0) - SET(FTS_NOCHDIR); - - return (sp); - -mem3: fts_lfree(root); - free(parent); -mem2: free(sp->fts_path); -mem1: free(sp); - return (NULL); -} - -static void -fts_load(sp, p) - FTS *sp; - FTSENT *p; -{ - int len; - char *cp; - - /* - * Load the stream structure for the next traversal. Since we don't - * actually enter the directory until after the preorder visit, set - * the fts_accpath field specially so the chdir gets done to the right - * place and the user can access the first node. From fts_open it's - * known that the path will fit. - */ - len = p->fts_pathlen = p->fts_namelen; - memmove(sp->fts_path, p->fts_name, len + 1); - if ((cp = strrchr(p->fts_name, '/')) && (cp != p->fts_name || cp[1])) { - len = strlen(++cp); - memmove(p->fts_name, cp, len + 1); - p->fts_namelen = len; - } - p->fts_accpath = p->fts_path = sp->fts_path; - sp->fts_dev = p->fts_dev; -} - -int -fts_close(sp) - FTS *sp; -{ - FTSENT *freep, *p; - int saved_errno; - - /* - * This still works if we haven't read anything -- the dummy structure - * points to the root list, so we step through to the end of the root - * list which has a valid parent pointer. - */ - if (sp->fts_cur) { - for (p = sp->fts_cur; p->fts_level >= FTS_ROOTLEVEL;) { - freep = p; - p = p->fts_link != NULL ? p->fts_link : p->fts_parent; - free(freep); - } - free(p); - } - - /* Free up child linked list, sort array, path buffer. */ - if (sp->fts_child) - fts_lfree(sp->fts_child); - if (sp->fts_array) - free(sp->fts_array); - free(sp->fts_path); - - /* Return to original directory, save errno if necessary. */ - if (!ISSET(FTS_NOCHDIR)) { - saved_errno = fchdir(sp->fts_rfd) ? errno : 0; - (void)_close(sp->fts_rfd); - - /* Set errno and return. */ - if (saved_errno != 0) { - /* Free up the stream pointer. */ - free(sp); - errno = saved_errno; - return (-1); - } - } - - /* Free up the stream pointer. */ - free(sp); - return (0); -} - -/* - * Special case of "/" at the end of the path so that slashes aren't - * appended which would cause paths to be written as "....//foo". - */ -#define NAPPEND(p) \ - (p->fts_path[p->fts_pathlen - 1] == '/' \ - ? p->fts_pathlen - 1 : p->fts_pathlen) - -FTSENT * -fts_read(sp) - FTS *sp; -{ - FTSENT *p, *tmp; - int instr; - char *t; - int saved_errno; - - /* If finished or unrecoverable error, return NULL. */ - if (sp->fts_cur == NULL || ISSET(FTS_STOP)) - return (NULL); - - /* Set current node pointer. */ - p = sp->fts_cur; - - /* Save and zero out user instructions. */ - instr = p->fts_instr; - p->fts_instr = FTS_NOINSTR; - - /* Any type of file may be re-visited; re-stat and re-turn. */ - if (instr == FTS_AGAIN) { - p->fts_info = fts_stat(sp, p, 0); - return (p); - } - - /* - * Following a symlink -- SLNONE test allows application to see - * SLNONE and recover. If indirecting through a symlink, have - * keep a pointer to current location. If unable to get that - * pointer, follow fails. - */ - if (instr == FTS_FOLLOW && - (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) { - p->fts_info = fts_stat(sp, p, 1); - if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { - if ((p->fts_symfd = _open(".", O_RDONLY, 0)) < 0) { - p->fts_errno = errno; - p->fts_info = FTS_ERR; - } else - p->fts_flags |= FTS_SYMFOLLOW; - } - return (p); - } - - /* Directory in pre-order. */ - if (p->fts_info == FTS_D) { - /* If skipped or crossed mount point, do post-order visit. */ - if (instr == FTS_SKIP || - (ISSET(FTS_XDEV) && p->fts_dev != sp->fts_dev)) { - if (p->fts_flags & FTS_SYMFOLLOW) - (void)_close(p->fts_symfd); - if (sp->fts_child) { - fts_lfree(sp->fts_child); - sp->fts_child = NULL; - } - p->fts_info = FTS_DP; - return (p); - } - - /* Rebuild if only read the names and now traversing. */ - if (sp->fts_child != NULL && ISSET(FTS_NAMEONLY)) { - CLR(FTS_NAMEONLY); - fts_lfree(sp->fts_child); - sp->fts_child = NULL; - } - - /* - * Cd to the subdirectory. - * - * If have already read and now fail to chdir, whack the list - * to make the names come out right, and set the parent errno - * so the application will eventually get an error condition. - * Set the FTS_DONTCHDIR flag so that when we logically change - * directories back to the parent we don't do a chdir. - * - * If haven't read do so. If the read fails, fts_build sets - * FTS_STOP or the fts_info field of the node. - */ - if (sp->fts_child != NULL) { - if (fts_safe_changedir(sp, p, -1, p->fts_accpath)) { - p->fts_errno = errno; - p->fts_flags |= FTS_DONTCHDIR; - for (p = sp->fts_child; p != NULL; - p = p->fts_link) - p->fts_accpath = - p->fts_parent->fts_accpath; - } - } else if ((sp->fts_child = fts_build(sp, BREAD)) == NULL) { - if (ISSET(FTS_STOP)) - return (NULL); - return (p); - } - p = sp->fts_child; - sp->fts_child = NULL; - goto name; - } - - /* Move to the next node on this level. */ -next: tmp = p; - if ((p = p->fts_link) != NULL) { - free(tmp); - - /* - * If reached the top, return to the original directory (or - * the root of the tree), and load the paths for the next root. - */ - if (p->fts_level == FTS_ROOTLEVEL) { - if (FCHDIR(sp, sp->fts_rfd)) { - SET(FTS_STOP); - return (NULL); - } - fts_load(sp, p); - return (sp->fts_cur = p); - } - - /* - * User may have called fts_set on the node. If skipped, - * ignore. If followed, get a file descriptor so we can - * get back if necessary. - */ - if (p->fts_instr == FTS_SKIP) - goto next; - if (p->fts_instr == FTS_FOLLOW) { - p->fts_info = fts_stat(sp, p, 1); - if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { - if ((p->fts_symfd = - _open(".", O_RDONLY, 0)) < 0) { - p->fts_errno = errno; - p->fts_info = FTS_ERR; - } else - p->fts_flags |= FTS_SYMFOLLOW; - } - p->fts_instr = FTS_NOINSTR; - } - -name: t = sp->fts_path + NAPPEND(p->fts_parent); - *t++ = '/'; - memmove(t, p->fts_name, p->fts_namelen + 1); - return (sp->fts_cur = p); - } - - /* Move up to the parent node. */ - p = tmp->fts_parent; - free(tmp); - - if (p->fts_level == FTS_ROOTPARENTLEVEL) { - /* - * Done; free everything up and set errno to 0 so the user - * can distinguish between error and EOF. - */ - free(p); - errno = 0; - return (sp->fts_cur = NULL); - } - - /* NUL terminate the pathname. */ - sp->fts_path[p->fts_pathlen] = '\0'; - - /* - * Return to the parent directory. If at a root node or came through - * a symlink, go back through the file descriptor. Otherwise, cd up - * one directory. - */ - if (p->fts_level == FTS_ROOTLEVEL) { - if (FCHDIR(sp, sp->fts_rfd)) { - SET(FTS_STOP); - return (NULL); - } - } else if (p->fts_flags & FTS_SYMFOLLOW) { - if (FCHDIR(sp, p->fts_symfd)) { - saved_errno = errno; - (void)_close(p->fts_symfd); - errno = saved_errno; - SET(FTS_STOP); - return (NULL); - } - (void)_close(p->fts_symfd); - } else if (!(p->fts_flags & FTS_DONTCHDIR) && - fts_safe_changedir(sp, p->fts_parent, -1, "..")) { - SET(FTS_STOP); - return (NULL); - } - p->fts_info = p->fts_errno ? FTS_ERR : FTS_DP; - return (sp->fts_cur = p); -} - -/* - * Fts_set takes the stream as an argument although it's not used in this - * implementation; it would be necessary if anyone wanted to add global - * semantics to fts using fts_set. An error return is allowed for similar - * reasons. - */ -/* ARGSUSED */ -int -fts_set(sp, p, instr) - FTS *sp; - FTSENT *p; - int instr; -{ - if (instr != 0 && instr != FTS_AGAIN && instr != FTS_FOLLOW && - instr != FTS_NOINSTR && instr != FTS_SKIP) { - errno = EINVAL; - return (1); - } - p->fts_instr = instr; - return (0); -} - -FTSENT * -fts_children(sp, instr) - FTS *sp; - int instr; -{ - FTSENT *p; - int fd; - - if (instr != 0 && instr != FTS_NAMEONLY) { - errno = EINVAL; - return (NULL); - } - - /* Set current node pointer. */ - p = sp->fts_cur; - - /* - * Errno set to 0 so user can distinguish empty directory from - * an error. - */ - errno = 0; - - /* Fatal errors stop here. */ - if (ISSET(FTS_STOP)) - return (NULL); - - /* Return logical hierarchy of user's arguments. */ - if (p->fts_info == FTS_INIT) - return (p->fts_link); - - /* - * If not a directory being visited in pre-order, stop here. Could - * allow FTS_DNR, assuming the user has fixed the problem, but the - * same effect is available with FTS_AGAIN. - */ - if (p->fts_info != FTS_D /* && p->fts_info != FTS_DNR */) - return (NULL); - - /* Free up any previous child list. */ - if (sp->fts_child != NULL) - fts_lfree(sp->fts_child); - - if (instr == FTS_NAMEONLY) { - SET(FTS_NAMEONLY); - instr = BNAMES; - } else - instr = BCHILD; - - /* - * If using chdir on a relative path and called BEFORE fts_read does - * its chdir to the root of a traversal, we can lose -- we need to - * chdir into the subdirectory, and we don't know where the current - * directory is, so we can't get back so that the upcoming chdir by - * fts_read will work. - */ - if (p->fts_level != FTS_ROOTLEVEL || p->fts_accpath[0] == '/' || - ISSET(FTS_NOCHDIR)) - return (sp->fts_child = fts_build(sp, instr)); - - if ((fd = _open(".", O_RDONLY, 0)) < 0) - return (NULL); - sp->fts_child = fts_build(sp, instr); - if (fchdir(fd)) - return (NULL); - (void)_close(fd); - return (sp->fts_child); -} - -#ifndef fts_get_clientptr -#error "fts_get_clientptr not defined" -#endif - -void * -(fts_get_clientptr)(FTS *sp) -{ - - return (fts_get_clientptr(sp)); -} - -#ifndef fts_get_stream -#error "fts_get_stream not defined" -#endif - -FTS * -(fts_get_stream)(FTSENT *p) -{ - return (fts_get_stream(p)); -} - -void -fts_set_clientptr(FTS *sp, void *clientptr) -{ - - sp->fts_clientptr = clientptr; -} - -/* - * This is the tricky part -- do not casually change *anything* in here. The - * idea is to build the linked list of entries that are used by fts_children - * and fts_read. There are lots of special cases. - * - * The real slowdown in walking the tree is the stat calls. If FTS_NOSTAT is - * set and it's a physical walk (so that symbolic links can't be directories), - * we can do things quickly. First, if it's a 4.4BSD file system, the type - * of the file is in the directory entry. Otherwise, we assume that the number - * of subdirectories in a node is equal to the number of links to the parent. - * The former skips all stat calls. The latter skips stat calls in any leaf - * directories and for any files after the subdirectories in the directory have - * been found, cutting the stat calls by about 2/3. - */ -static FTSENT * -fts_build(sp, type) - FTS *sp; - int type; -{ - struct dirent *dp; - FTSENT *p, *head; - int nitems; - FTSENT *cur, *tail; - DIR *dirp; - void *oldaddr; - size_t dnamlen; - int cderrno, descend, len, level, maxlen, nlinks, /*oflag,*/ saved_errno, - nostat, doadjust; - char *cp; - - /* Set current node pointer. */ - cur = sp->fts_cur; - - /* - * Open the directory for reading. If this fails, we're done. - * If being called from fts_read, set the fts_info field. - */ -#ifdef FTS_WHITEOUT - if (ISSET(FTS_WHITEOUT)) - oflag = DTF_NODUP | DTF_REWIND; - else - oflag = DTF_HIDEW | DTF_NODUP | DTF_REWIND; -#else -#define __opendir2(path, flag) opendir(path) -#endif - if ((dirp = __opendir2(cur->fts_accpath, oflag)) == NULL) { - if (type == BREAD) { - cur->fts_info = FTS_DNR; - cur->fts_errno = errno; - } - return (NULL); - } - - /* - * Nlinks is the number of possible entries of type directory in the - * directory if we're cheating on stat calls, 0 if we're not doing - * any stat calls at all, -1 if we're doing stats on everything. - */ - if (type == BNAMES) { - nlinks = 0; - /* Be quiet about nostat, GCC. */ - nostat = 0; - } else if (ISSET(FTS_NOSTAT) && ISSET(FTS_PHYSICAL)) { - if (fts_ufslinks(sp, cur)) - nlinks = cur->fts_nlink - (ISSET(FTS_SEEDOT) ? 0 : 2); - else - nlinks = -1; - nostat = 1; - } else { - nlinks = -1; - nostat = 0; - } - -#ifdef notdef - (void)printf("nlinks == %d (cur: %d)\n", nlinks, cur->fts_nlink); - (void)printf("NOSTAT %d PHYSICAL %d SEEDOT %d\n", - ISSET(FTS_NOSTAT), ISSET(FTS_PHYSICAL), ISSET(FTS_SEEDOT)); -#endif - /* - * If we're going to need to stat anything or we want to descend - * and stay in the directory, chdir. If this fails we keep going, - * but set a flag so we don't chdir after the post-order visit. - * We won't be able to stat anything, but we can still return the - * names themselves. Note, that since fts_read won't be able to - * chdir into the directory, it will have to return different path - * names than before, i.e. "a/b" instead of "b". Since the node - * has already been visited in pre-order, have to wait until the - * post-order visit to return the error. There is a special case - * here, if there was nothing to stat then it's not an error to - * not be able to stat. This is all fairly nasty. If a program - * needed sorted entries or stat information, they had better be - * checking FTS_NS on the returned nodes. - */ - cderrno = 0; - if (nlinks || type == BREAD) { - if (fts_safe_changedir(sp, cur, dirfd(dirp), NULL)) { - if (nlinks && type == BREAD) - cur->fts_errno = errno; - cur->fts_flags |= FTS_DONTCHDIR; - descend = 0; - cderrno = errno; - } else - descend = 1; - } else - descend = 0; - - /* - * Figure out the max file name length that can be stored in the - * current path -- the inner loop allocates more path as necessary. - * We really wouldn't have to do the maxlen calculations here, we - * could do them in fts_read before returning the path, but it's a - * lot easier here since the length is part of the dirent structure. - * - * If not changing directories set a pointer so that can just append - * each new name into the path. - */ - len = NAPPEND(cur); - if (ISSET(FTS_NOCHDIR)) { - cp = sp->fts_path + len; - *cp++ = '/'; - } else { - /* GCC, you're too verbose. */ - cp = NULL; - } - len++; - maxlen = sp->fts_pathlen - len; - - level = cur->fts_level + 1; - - /* Read the directory, attaching each entry to the `link' pointer. */ - doadjust = 0; - for (head = tail = NULL, nitems = 0; dirp && (dp = readdir(dirp));) { -#ifdef __CYGWIN__ - dnamlen = strlen (dp->d_name); -#else - dnamlen = dp->d_namlen; -#endif - if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name)) - continue; - - if ((p = fts_alloc(sp, dp->d_name, (int)dnamlen)) == NULL) - goto mem1; - if (dnamlen >= maxlen) { /* include space for NUL */ - oldaddr = sp->fts_path; - if (fts_palloc(sp, dnamlen + len + 1)) { - /* - * No more memory for path or structures. Save - * errno, free up the current structure and the - * structures already allocated. - */ -mem1: saved_errno = errno; - if (p) - free(p); - fts_lfree(head); - (void)closedir(dirp); - cur->fts_info = FTS_ERR; - SET(FTS_STOP); - errno = saved_errno; - return (NULL); - } - /* Did realloc() change the pointer? */ - if (oldaddr != sp->fts_path) { - doadjust = 1; - if (ISSET(FTS_NOCHDIR)) - cp = sp->fts_path + len; - } - maxlen = sp->fts_pathlen - len; - } - - if (len + dnamlen >= USHRT_MAX) { - /* - * In an FTSENT, fts_pathlen is a u_short so it is - * possible to wraparound here. If we do, free up - * the current structure and the structures already - * allocated, then error out with ENAMETOOLONG. - */ - free(p); - fts_lfree(head); - (void)closedir(dirp); - cur->fts_info = FTS_ERR; - SET(FTS_STOP); - errno = ENAMETOOLONG; - return (NULL); - } - p->fts_level = level; - p->fts_parent = sp->fts_cur; - p->fts_pathlen = len + dnamlen; - -#ifdef FTS_WHITEOUT - if (dp->d_type == DT_WHT) - p->fts_flags |= FTS_ISW; -#endif - - if (cderrno) { - if (nlinks) { - p->fts_info = FTS_NS; - p->fts_errno = cderrno; - } else - p->fts_info = FTS_NSOK; - p->fts_accpath = cur->fts_accpath; - } else if (nlinks == 0 -#if defined(DT_DIR) - || (nostat && - dp->d_type != DT_DIR && dp->d_type != DT_UNKNOWN) -#endif - ) { - p->fts_accpath = - ISSET(FTS_NOCHDIR) ? p->fts_path : p->fts_name; - p->fts_info = FTS_NSOK; - } else { - /* Build a file name for fts_stat to stat. */ - if (ISSET(FTS_NOCHDIR)) { - p->fts_accpath = p->fts_path; - memmove(cp, p->fts_name, p->fts_namelen + 1); - } else - p->fts_accpath = p->fts_name; - /* Stat it. */ - p->fts_info = fts_stat(sp, p, 0); - - /* Decrement link count if applicable. */ - if (nlinks > 0 && (p->fts_info == FTS_D || - p->fts_info == FTS_DC || p->fts_info == FTS_DOT)) - --nlinks; - } - - /* We walk in directory order so "ls -f" doesn't get upset. */ - p->fts_link = NULL; - if (head == NULL) - head = tail = p; - else { - tail->fts_link = p; - tail = p; - } - ++nitems; - } - if (dirp) - (void)closedir(dirp); - - /* - * If realloc() changed the address of the path, adjust the - * addresses for the rest of the tree and the dir list. - */ - if (doadjust) - fts_padjust(sp, head); - - /* - * If not changing directories, reset the path back to original - * state. - */ - if (ISSET(FTS_NOCHDIR)) { - if (len == sp->fts_pathlen || nitems == 0) - --cp; - *cp = '\0'; - } - - /* - * If descended after called from fts_children or after called from - * fts_read and nothing found, get back. At the root level we use - * the saved fd; if one of fts_open()'s arguments is a relative path - * to an empty directory, we wind up here with no other way back. If - * can't get back, we're done. - */ - if (descend && (type == BCHILD || !nitems) && - (cur->fts_level == FTS_ROOTLEVEL ? - FCHDIR(sp, sp->fts_rfd) : - fts_safe_changedir(sp, cur->fts_parent, -1, ".."))) { - cur->fts_info = FTS_ERR; - SET(FTS_STOP); - return (NULL); - } - - /* If didn't find anything, return NULL. */ - if (!nitems) { - if (type == BREAD) - cur->fts_info = FTS_DP; - return (NULL); - } - - /* Sort the entries. */ - if (sp->fts_compar && nitems > 1) - head = fts_sort(sp, head, nitems); - return (head); -} - -static u_short -fts_stat(sp, p, follow) - FTS *sp; - FTSENT *p; - int follow; -{ - FTSENT *t; - __dev32_t dev; - __ino64_t ino; - struct __stat64 *sbp, sb; - int saved_errno; - - /* If user needs stat info, stat buffer already allocated. */ - sbp = ISSET(FTS_NOSTAT) ? &sb : p->fts_statp; - -#ifdef FTS_WHITEOUT - /* Check for whiteout. */ - if (p->fts_flags & FTS_ISW) { - if (sbp != &sb) { - memset(sbp, '\0', sizeof(*sbp)); - sbp->st_mode = S_IFWHT; - } - return (FTS_W); - } -#endif - - /* - * If doing a logical walk, or application requested FTS_FOLLOW, do - * a stat(2). If that fails, check for a non-existent symlink. If - * fail, set the errno from the stat call. - */ - if (ISSET(FTS_LOGICAL) || follow) { - if (stat64(p->fts_accpath, sbp)) { - saved_errno = errno; - if (!lstat64(p->fts_accpath, sbp)) { - errno = 0; - return (FTS_SLNONE); - } - p->fts_errno = saved_errno; - goto err; - } - } else if (lstat64(p->fts_accpath, sbp)) { - p->fts_errno = errno; -err: memset(sbp, 0, sizeof(struct __stat64)); - return (FTS_NS); - } - - if (S_ISDIR(sbp->st_mode)) { - /* - * Set the device/inode. Used to find cycles and check for - * crossing mount points. Also remember the link count, used - * in fts_build to limit the number of stat calls. It is - * understood that these fields are only referenced if fts_info - * is set to FTS_D. - */ - dev = p->fts_dev = sbp->st_dev; - ino = p->fts_ino = sbp->st_ino; - p->fts_nlink = sbp->st_nlink; - - if (ISDOT(p->fts_name)) - return (FTS_DOT); - - /* - * Cycle detection is done by brute force when the directory - * is first encountered. If the tree gets deep enough or the - * number of symbolic links to directories is high enough, - * something faster might be worthwhile. - */ - for (t = p->fts_parent; - t->fts_level >= FTS_ROOTLEVEL; t = t->fts_parent) - if (ino == t->fts_ino && dev == t->fts_dev) { - p->fts_cycle = t; - return (FTS_DC); - } - return (FTS_D); - } - if (S_ISLNK(sbp->st_mode)) - return (FTS_SL); - if (S_ISREG(sbp->st_mode)) - return (FTS_F); - return (FTS_DEFAULT); -} - -/* - * The comparison function takes pointers to pointers to FTSENT structures. - * Qsort wants a comparison function that takes pointers to void. - * (Both with appropriate levels of const-poisoning, of course!) - * Use a trampoline function to deal with the difference. - */ -static int -fts_compar(const void *a, const void *b) -{ - FTS *parent; - - parent = (*(const FTSENT * const *)a)->fts_fts; - return (*parent->fts_compar)(a, b); -} - -static FTSENT * -fts_sort(sp, head, nitems) - FTS *sp; - FTSENT *head; - int nitems; -{ - FTSENT **ap, *p; - - /* - * Construct an array of pointers to the structures and call qsort(3). - * Reassemble the array in the order returned by qsort. If unable to - * sort for memory reasons, return the directory entries in their - * current order. Allocate enough space for the current needs plus - * 40 so don't realloc one entry at a time. - */ - if (nitems > sp->fts_nitems) { - sp->fts_nitems = nitems + 40; - if ((sp->fts_array = reallocf(sp->fts_array, - sp->fts_nitems * sizeof(FTSENT *))) == NULL) { - sp->fts_nitems = 0; - return (head); - } - } - for (ap = sp->fts_array, p = head; p; p = p->fts_link) - *ap++ = p; - qsort(sp->fts_array, nitems, sizeof(FTSENT *), fts_compar); - for (head = *(ap = sp->fts_array); --nitems; ++ap) - ap[0]->fts_link = ap[1]; - ap[0]->fts_link = NULL; - return (head); -} - -static FTSENT * -fts_alloc(sp, name, namelen) - FTS *sp; - const char *name; - int namelen; -{ - FTSENT *p; - size_t len; - - struct ftsent_withstat { - FTSENT ent; - struct __stat64 statbuf; - }; - - /* - * The file name is a variable length array and no stat structure is - * necessary if the user has set the nostat bit. Allocate the FTSENT - * structure, the file name and the stat structure in one chunk, but - * be careful that the stat structure is reasonably aligned. - */ - if (ISSET(FTS_NOSTAT)) - len = sizeof(FTSENT) + namelen + 1; - else - len = sizeof(struct ftsent_withstat) + namelen + 1; - - if ((p = malloc(len)) == NULL) - return (NULL); - - if (ISSET(FTS_NOSTAT)) { - p->fts_name = (char *)(p + 1); - p->fts_statp = NULL; - } else { - p->fts_name = (char *)((struct ftsent_withstat *)p + 1); - p->fts_statp = &((struct ftsent_withstat *)p)->statbuf; - } - - /* Copy the name and guarantee NUL termination. */ - memcpy(p->fts_name, name, namelen); - p->fts_name[namelen] = '\0'; - p->fts_namelen = namelen; - p->fts_path = sp->fts_path; - p->fts_errno = 0; - p->fts_flags = 0; - p->fts_instr = FTS_NOINSTR; - p->fts_number = 0; - p->fts_pointer = NULL; - p->fts_fts = sp; - return (p); -} - -static void -fts_lfree(head) - FTSENT *head; -{ - FTSENT *p; - - /* Free a linked list of structures. */ - while ((p = head)) { - head = head->fts_link; - free(p); - } -} - -/* - * Allow essentially unlimited paths; find, rm, ls should all work on any tree. - * Most systems will allow creation of paths much longer than MAXPATHLEN, even - * though the kernel won't resolve them. Add the size (not just what's needed) - * plus 256 bytes so don't realloc the path 2 bytes at a time. - */ -static int -fts_palloc(sp, more) - FTS *sp; - size_t more; -{ - - sp->fts_pathlen += more + 256; - /* - * Check for possible wraparound. In an FTS, fts_pathlen is - * a signed int but in an FTSENT it is an unsigned short. - * We limit fts_pathlen to USHRT_MAX to be safe in both cases. - */ - if (sp->fts_pathlen < 0 || sp->fts_pathlen >= USHRT_MAX) { - if (sp->fts_path) - free(sp->fts_path); - sp->fts_path = NULL; - errno = ENAMETOOLONG; - return (1); - } - sp->fts_path = reallocf(sp->fts_path, sp->fts_pathlen); - return (sp->fts_path == NULL); -} - -/* - * When the path is realloc'd, have to fix all of the pointers in structures - * already returned. - */ -static void -fts_padjust(sp, head) - FTS *sp; - FTSENT *head; -{ - FTSENT *p; - char *addr = sp->fts_path; - -#define ADJUST(p) do { \ - if ((p)->fts_accpath != (p)->fts_name) { \ - (p)->fts_accpath = \ - (char *)addr + ((p)->fts_accpath - (p)->fts_path); \ - } \ - (p)->fts_path = addr; \ -} while (0) - /* Adjust the current set of children. */ - for (p = sp->fts_child; p; p = p->fts_link) - ADJUST(p); - - /* Adjust the rest of the tree, including the current level. */ - for (p = head; p->fts_level >= FTS_ROOTLEVEL;) { - ADJUST(p); - p = p->fts_link ? p->fts_link : p->fts_parent; - } -} - -static size_t -fts_maxarglen(argv) - char * const *argv; -{ - size_t len, max; - - for (max = 0; *argv; ++argv) - if ((len = strlen(*argv)) > max) - max = len; - return (max + 1); -} - -/* - * Change to dir specified by fd or p->fts_accpath without getting - * tricked by someone changing the world out from underneath us. - * Assumes p->fts_dev and p->fts_ino are filled in. - */ -static int -fts_safe_changedir(sp, p, fd, path) - FTS *sp; - FTSENT *p; - int fd; - const char *path; -{ - int ret, oerrno, newfd; - struct __stat64 sb; - - newfd = fd; - if (ISSET(FTS_NOCHDIR)) - return (0); - if (fd < 0 && (newfd = _open(path, O_RDONLY, 0)) < 0) - return (-1); - if (fstat64(newfd, &sb)) { - ret = -1; - goto bail; - } - if (p->fts_dev != sb.st_dev || p->fts_ino != sb.st_ino) { - errno = ENOENT; /* disinformation */ - ret = -1; - goto bail; - } - ret = fchdir(newfd); -bail: - oerrno = errno; - if (fd < 0) - (void)_close(newfd); - errno = oerrno; - return (ret); -} - -/* - * Check if the filesystem for "ent" has UFS-style links. - */ -static int -fts_ufslinks(FTS *sp, const FTSENT *ent) -{ - struct _fts_private *priv; -#ifndef __CYGWIN__ - const char **cpp; -#endif - - priv = (struct _fts_private *)sp; - /* - * If this node's device is different from the previous, grab - * the filesystem information, and decide on the reliability - * of the link information from this filesystem for stat(2) - * avoidance. - */ - if (priv->ftsp_dev != ent->fts_dev) { - if (statfs(ent->fts_path, &priv->ftsp_statfs) != -1) { - priv->ftsp_dev = ent->fts_dev; -#ifdef __CYGWIN__ - /* The link count is reliable in Cygwin's directory - stat structures, unless the link count is 1. - This indicates a filesystem on which Cygwin - refuses to count the directory links for speed. */ - priv->ftsp_linksreliable = (ent->fts_nlink == 1) - ? 0 : 1; -#else - priv->ftsp_linksreliable = 0; - for (cpp = ufslike_filesystems; *cpp; cpp++) { - if (strcmp(priv->ftsp_statfs.f_fstypename, - *cpp) == 0) { - priv->ftsp_linksreliable = 1; - break; - } - } -#endif - } else { - priv->ftsp_linksreliable = 0; - } - } - return (priv->ftsp_linksreliable); -} diff --git a/winsup/cygwin/libc/ftw.c b/winsup/cygwin/libc/ftw.c deleted file mode 100644 index 9863e1621..000000000 --- a/winsup/cygwin/libc/ftw.c +++ /dev/null @@ -1,107 +0,0 @@ -/* $OpenBSD: ftw.c,v 1.4 2004/07/07 16:05:23 millert Exp $ */ - -/* - * Copyright (c) 2003, 2004 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Sponsored in part by the Defense Advanced Research Projects - * Agency (DARPA) and Air Force Research Laboratory, Air Force - * Materiel Command, USAF, under agreement number F39502-99-1-0512. - */ - -#if 0 -#if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$OpenBSD: ftw.c,v 1.4 2004/07/07 16:05:23 millert Exp $"; -#endif /* LIBC_SCCS and not lint */ -#endif - -#ifdef __CYGWIN__ -#include "winsup.h" -#endif -#include -#if 0 -__FBSDID("$FreeBSD: /repoman/r/ncvs/src/lib/libc/gen/ftw.c,v 1.4 2004/08/24 13:00:55 tjr Exp $"); -#endif -#include -#include -#include -#include -#include -#include - -int -ftw(const char *path, int (*fn)(const char *, const struct __stat64 *, int), - int nfds) -{ - char * const paths[2] = { (char *)path, NULL }; - FTSENT *cur; - FTS *ftsp; - int error = 0, fnflag, sverrno; - -#if 0 - /* GLibc allows nfds < 1 and treats it as nfds == 1. Since nfds is - not used in this OpenBSD version anyway, just ignore it for - Linux compatibility. */ - /* XXX - nfds is currently unused */ - if (nfds < 1 || nfds > OPEN_MAX) { - errno = EINVAL; - return (-1); - } -#endif - - ftsp = fts_open(paths, FTS_LOGICAL | FTS_COMFOLLOW | FTS_NOCHDIR, NULL); - if (ftsp == NULL) - return (-1); - while ((cur = fts_read(ftsp)) != NULL) { - switch (cur->fts_info) { - case FTS_D: - fnflag = FTW_D; - break; - case FTS_DNR: - fnflag = FTW_DNR; - break; - case FTS_DP: - /* we only visit in preorder */ - continue; - case FTS_F: - case FTS_DEFAULT: - fnflag = FTW_F; - break; - case FTS_NS: - case FTS_NSOK: - case FTS_SLNONE: - fnflag = FTW_NS; - break; - case FTS_SL: - fnflag = FTW_SL; - break; - case FTS_DC: - errno = ELOOP; - /* FALLTHROUGH */ - default: - error = -1; - goto done; - } - error = fn(cur->fts_path, cur->fts_statp, fnflag); - if (error != 0) - break; - } -done: - sverrno = errno; - if (fts_close(ftsp) != 0 && error == 0) - error = -1; - else - errno = sverrno; - return (error); -} diff --git a/winsup/cygwin/libc/getopt.c b/winsup/cygwin/libc/getopt.c deleted file mode 100644 index bc35f96d4..000000000 --- a/winsup/cygwin/libc/getopt.c +++ /dev/null @@ -1,535 +0,0 @@ -/* $OpenBSD: getopt_long.c,v 1.23 2007/10/31 12:34:57 chl Exp $ */ -/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */ - -/* - * Copyright (c) 2002 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Sponsored in part by the Defense Advanced Research Projects - * Agency (DARPA) and Air Force Research Laboratory, Air Force - * Materiel Command, USAF, under agreement number F39502-99-1-0512. - */ -/*- - * Copyright (c) 2000 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dieter Baron and Thomas Klausner. - * - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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. - */ - -#include -#include -#include -#include -#define __INSIDE_CYGWIN__ -#include - -#define REPLACE_GETOPT /* use this getopt as the system getopt(3) */ - -#ifdef REPLACE_GETOPT -int opterr = 1; /* if error message should be printed */ -int optind = 1; /* index into parent argv vector */ -int optopt = '?'; /* character checked for validity */ -int optreset; /* reset getopt */ -char *optarg; /* argument associated with option */ -#endif - -#define PRINT_ERROR ((opterr) && (*options != ':')) - -#define FLAG_PERMUTE 0x01 /* permute non-options to the end of argv */ -#define FLAG_ALLARGS 0x02 /* treat non-options as args to option "-1" */ -#define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */ - -/* return values */ -#define BADCH (int)'?' -#define BADARG ((*options == ':') ? (int)':' : (int)'?') -#define INORDER (int)1 - -#ifdef __CYGWIN__ -static char EMSG[] = ""; -#else -#define EMSG "" -#endif - -static int getopt_internal(int, char * const *, const char *, - const struct option *, int *, int); -static int parse_long_options(char * const *, const char *, - const struct option *, int *, int); -static int gcd(int, int); -static void permute_args(int, int, int, char * const *); - -static char *place = EMSG; /* option letter processing */ - -/* XXX: set optreset to 1 rather than these two */ -static int nonopt_start = -1; /* first non option argument (for permute) */ -static int nonopt_end = -1; /* first option after non options (for permute) */ - -/* Error messages */ -static const char recargchar[] = "option requires an argument -- %c"; -static const char recargstring[] = "option requires an argument -- %s"; -static const char ambig[] = "ambiguous option -- %.*s"; -static const char noarg[] = "option doesn't take an argument -- %.*s"; -static const char illoptchar[] = "unknown option -- %c"; -static const char illoptstring[] = "unknown option -- %s"; - -/* - * Compute the greatest common divisor of a and b. - */ -static int -gcd(int a, int b) -{ - int c; - - c = a % b; - while (c != 0) { - a = b; - b = c; - c = a % b; - } - - return (b); -} - -/* - * Exchange the block from nonopt_start to nonopt_end with the block - * from nonopt_end to opt_end (keeping the same order of arguments - * in each block). - */ -static void -permute_args(int panonopt_start, int panonopt_end, int opt_end, - char * const *nargv) -{ - int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos; - char *swap; - - /* - * compute lengths of blocks and number and size of cycles - */ - nnonopts = panonopt_end - panonopt_start; - nopts = opt_end - panonopt_end; - ncycle = gcd(nnonopts, nopts); - cyclelen = (opt_end - panonopt_start) / ncycle; - - for (i = 0; i < ncycle; i++) { - cstart = panonopt_end+i; - pos = cstart; - for (j = 0; j < cyclelen; j++) { - if (pos >= panonopt_end) - pos -= nnonopts; - else - pos += nopts; - swap = nargv[pos]; - /* LINTED const cast */ - ((char **) nargv)[pos] = nargv[cstart]; - /* LINTED const cast */ - ((char **)nargv)[cstart] = swap; - } - } -} - -/* - * parse_long_options -- - * Parse long options in argc/argv argument vector. - * Returns -1 if short_too is set and the option does not match long_options. - */ -static int -parse_long_options(char * const *nargv, const char *options, - const struct option *long_options, int *idx, int short_too) -{ - char *current_argv, *has_equal; - size_t current_argv_len; - int i, ambiguous, match; - -#define IDENTICAL_INTERPRETATION(_x, _y) \ - (long_options[(_x)].has_arg == long_options[(_y)].has_arg && \ - long_options[(_x)].flag == long_options[(_y)].flag && \ - long_options[(_x)].val == long_options[(_y)].val) - - current_argv = place; - match = -1; - ambiguous = 0; - - optind++; - - if ((has_equal = strchr(current_argv, '=')) != NULL) { - /* argument found (--option=arg) */ - current_argv_len = has_equal - current_argv; - has_equal++; - } else - current_argv_len = strlen(current_argv); - - for (i = 0; long_options[i].name; i++) { - /* find matching long option */ - if (strncmp(current_argv, long_options[i].name, - current_argv_len)) - continue; - - if (strlen(long_options[i].name) == current_argv_len) { - /* exact match */ - match = i; - ambiguous = 0; - break; - } - /* - * If this is a known short option, don't allow - * a partial match of a single character. - */ - if (short_too && current_argv_len == 1) - continue; - - if (match == -1) /* partial match */ - match = i; - else if (!IDENTICAL_INTERPRETATION(i, match)) - ambiguous = 1; - } - if (ambiguous) { - /* ambiguous abbreviation */ - if (PRINT_ERROR) - warnx(ambig, (int)current_argv_len, - current_argv); - optopt = 0; - return (BADCH); - } - if (match != -1) { /* option found */ - if (long_options[match].has_arg == no_argument - && has_equal) { - if (PRINT_ERROR) - warnx(noarg, (int)current_argv_len, - current_argv); - /* - * XXX: GNU sets optopt to val regardless of flag - */ - if (long_options[match].flag == NULL) - optopt = long_options[match].val; - else - optopt = 0; - return (BADARG); - } - if (long_options[match].has_arg == required_argument || - long_options[match].has_arg == optional_argument) { - if (has_equal) - optarg = has_equal; - else if (long_options[match].has_arg == - required_argument) { - /* - * optional argument doesn't use next nargv - */ - optarg = nargv[optind++]; - } - } - if ((long_options[match].has_arg == required_argument) - && (optarg == NULL)) { - /* - * Missing argument; leading ':' indicates no error - * should be generated. - */ - if (PRINT_ERROR) - warnx(recargstring, - current_argv); - /* - * XXX: GNU sets optopt to val regardless of flag - */ - if (long_options[match].flag == NULL) - optopt = long_options[match].val; - else - optopt = 0; - --optind; - return (BADARG); - } - } else { /* unknown option */ - if (short_too) { - --optind; - return (-1); - } - if (PRINT_ERROR) - warnx(illoptstring, current_argv); - optopt = 0; - return (BADCH); - } - if (idx) - *idx = match; - if (long_options[match].flag) { - *long_options[match].flag = long_options[match].val; - return (0); - } else - return (long_options[match].val); -#undef IDENTICAL_INTERPRETATION -} - -/* - * getopt_internal -- - * Parse argc/argv argument vector. Called by user level routines. - */ -static int -getopt_internal(int nargc, char * const *nargv, const char *options, - const struct option *long_options, int *idx, int flags) -{ - char *oli; /* option letter list index */ - int optchar, short_too; - static int posixly_correct = -1; - - if (options == NULL) - return (-1); - - /* - * XXX Some GNU programs (like cvs) set optind to 0 instead of - * XXX using optreset. Work around this braindamage. - */ - if (optind == 0) - optind = optreset = 1; - - /* - * Disable GNU extensions if POSIXLY_CORRECT is set or options - * string begins with a '+'. - * - * CV, 2009-12-14: Check POSIXLY_CORRECT anew if optind == 0 or - * optreset != 0 for GNU compatibility. - */ - if (posixly_correct == -1 || optreset != 0) - posixly_correct = (getenv("POSIXLY_CORRECT") != NULL); - if (*options == '-') - flags |= FLAG_ALLARGS; - else if (posixly_correct || *options == '+') - flags &= ~FLAG_PERMUTE; - if (*options == '+' || *options == '-') - options++; - - optarg = NULL; - if (optreset) - nonopt_start = nonopt_end = -1; -start: - if (optreset || !*place) { /* update scanning pointer */ - optreset = 0; - if (optind >= nargc) { /* end of argument vector */ - place = EMSG; - if (nonopt_end != -1) { - /* do permutation, if we have to */ - permute_args(nonopt_start, nonopt_end, - optind, nargv); - optind -= nonopt_end - nonopt_start; - } - else if (nonopt_start != -1) { - /* - * If we skipped non-options, set optind - * to the first of them. - */ - optind = nonopt_start; - } - nonopt_start = nonopt_end = -1; - return (-1); - } - if (*(place = nargv[optind]) != '-' || - (place[1] == '\0' && strchr(options, '-') == NULL)) { - place = EMSG; /* found non-option */ - if (flags & FLAG_ALLARGS) { - /* - * GNU extension: - * return non-option as argument to option 1 - */ - optarg = nargv[optind++]; - return (INORDER); - } - if (!(flags & FLAG_PERMUTE)) { - /* - * If no permutation wanted, stop parsing - * at first non-option. - */ - return (-1); - } - /* do permutation */ - if (nonopt_start == -1) - nonopt_start = optind; - else if (nonopt_end != -1) { - permute_args(nonopt_start, nonopt_end, - optind, nargv); - nonopt_start = optind - - (nonopt_end - nonopt_start); - nonopt_end = -1; - } - optind++; - /* process next argument */ - goto start; - } - if (nonopt_start != -1 && nonopt_end == -1) - nonopt_end = optind; - - /* - * If we have "-" do nothing, if "--" we are done. - */ - if (place[1] != '\0' && *++place == '-' && place[1] == '\0') { - optind++; - place = EMSG; - /* - * We found an option (--), so if we skipped - * non-options, we have to permute. - */ - if (nonopt_end != -1) { - permute_args(nonopt_start, nonopt_end, - optind, nargv); - optind -= nonopt_end - nonopt_start; - } - nonopt_start = nonopt_end = -1; - return (-1); - } - } - - /* - * Check long options if: - * 1) we were passed some - * 2) the arg is not just "-" - * 3) either the arg starts with -- we are getopt_long_only() - */ - if (long_options != NULL && place != nargv[optind] && - (*place == '-' || (flags & FLAG_LONGONLY))) { - short_too = 0; - if (*place == '-') - place++; /* --foo long option */ - else if (*place != ':' && strchr(options, *place) != NULL) - short_too = 1; /* could be short option too */ - - optchar = parse_long_options(nargv, options, long_options, - idx, short_too); - if (optchar != -1) { - place = EMSG; - return (optchar); - } - } - - if ((optchar = (int)*place++) == (int)':' || - (optchar == (int)'-' && *place != '\0') || - (oli = strchr(options, optchar)) == NULL) { - /* - * If the user specified "-" and '-' isn't listed in - * options, return -1 (non-option) as per POSIX. - * Otherwise, it is an unknown option character (or ':'). - */ - if (optchar == (int)'-' && *place == '\0') - return (-1); - if (!*place) - ++optind; - if (PRINT_ERROR) - warnx(illoptchar, optchar); - optopt = optchar; - return (BADCH); - } - if (long_options != NULL && optchar == 'W' && oli[1] == ';') { - /* -W long-option */ - if (*place) /* no space */ - /* NOTHING */; - else if (++optind >= nargc) { /* no arg */ - place = EMSG; - if (PRINT_ERROR) - warnx(recargchar, optchar); - optopt = optchar; - return (BADARG); - } else /* white space */ - place = nargv[optind]; - optchar = parse_long_options(nargv, options, long_options, - idx, 0); - place = EMSG; - return (optchar); - } - if (*++oli != ':') { /* doesn't take argument */ - if (!*place) - ++optind; - } else { /* takes (optional) argument */ - optarg = NULL; - if (*place) /* no white space */ - optarg = place; - else if (oli[1] != ':') { /* arg not optional */ - if (++optind >= nargc) { /* no arg */ - place = EMSG; - if (PRINT_ERROR) - warnx(recargchar, optchar); - optopt = optchar; - return (BADARG); - } else - optarg = nargv[optind]; - } - place = EMSG; - ++optind; - } - /* dump back option letter */ - return (optchar); -} - -#ifdef REPLACE_GETOPT -/* - * getopt -- - * Parse argc/argv argument vector. - * - * [eventually this will replace the BSD getopt] - */ -int -getopt(int nargc, char * const *nargv, const char *options) -{ - - /* - * We don't pass FLAG_PERMUTE to getopt_internal() since - * the BSD getopt(3) (unlike GNU) has never done this. - * - * Furthermore, since many privileged programs call getopt() - * before dropping privileges it makes sense to keep things - * as simple (and bug-free) as possible. - */ - return (getopt_internal(nargc, nargv, options, NULL, NULL, 0)); -} -#endif /* REPLACE_GETOPT */ - -/* - * getopt_long -- - * Parse argc/argv argument vector. - */ -int -getopt_long(int nargc, char * const *nargv, const char *options, - const struct option *long_options, int *idx) -{ - - return (getopt_internal(nargc, nargv, options, long_options, idx, - FLAG_PERMUTE)); -} - -/* - * getopt_long_only -- - * Parse argc/argv argument vector. - */ -int -getopt_long_only(int nargc, char * const *nargv, const char *options, - const struct option *long_options, int *idx) -{ - - return (getopt_internal(nargc, nargv, options, long_options, idx, - FLAG_PERMUTE|FLAG_LONGONLY)); -} diff --git a/winsup/cygwin/libc/inet_addr.c b/winsup/cygwin/libc/inet_addr.c deleted file mode 100644 index d80705257..000000000 --- a/winsup/cygwin/libc/inet_addr.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (c) 1983, 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - * 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. - */ - -/* - * Portions Copyright (c) 1993 by Digital Equipment Corporation. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies, and that - * the name of Digital Equipment Corporation not be used in advertising or - * publicity pertaining to distribution of the document or software without - * specific, written prior permission. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT - * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Portions Copyright (c) 1996-1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static const char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93"; -static const char rcsid[] = "$Id$"; -#endif /* LIBC_SCCS and not lint */ -#include -#ifndef __CYGWIN__ -__FBSDID("$FreeBSD$"); -#else -#define __INSIDE_CYGWIN__ -#define __INSIDE_CYGWIN_NET__ -#endif - -#ifndef __CYGWIN__ -#include "port_before.h" -#endif - -#include -#include - -#include -#include - -#include - -#ifndef __CYGWIN__ -#include "port_after.h" -#endif - -/* - * Check whether "cp" is a valid ascii representation - * of an Internet address and convert to a binary address. - * Returns 1 if the address is valid, 0 if not. - * This replaces inet_addr, the return value from which - * cannot distinguish between failure and a local broadcast address. - */ -extern int -cygwin_inet_aton(const char *cp, struct in_addr *addr) { - u_long val; - int base, n; - char c; - u_int8_t parts[4]; - u_int8_t *pp = parts; - int digit; - - c = *cp; - for (;;) { - /* - * Collect number up to ``.''. - * Values are specified as for C: - * 0x=hex, 0=octal, isdigit=decimal. - */ - if (!isdigit((unsigned char)c)) - return (0); - val = 0; base = 10; digit = 0; - if (c == '0') { - c = *++cp; - if (c == 'x' || c == 'X') - base = 16, c = *++cp; - else { - base = 8; - digit = 1 ; - } - } - for (;;) { - if (isascii(c) && isdigit((unsigned char)c)) { - if (base == 8 && (c == '8' || c == '9')) - return (0); - val = (val * base) + (c - '0'); - c = *++cp; - digit = 1; - } else if (base == 16 && isascii(c) && - isxdigit((unsigned char)c)) { - val = (val << 4) | - (c + 10 - (islower((unsigned char)c) ? 'a' : 'A')); - c = *++cp; - digit = 1; - } else - break; - } - if (c == '.') { - /* - * Internet format: - * a.b.c.d - * a.b.c (with c treated as 16 bits) - * a.b (with b treated as 24 bits) - */ - if (pp >= parts + 3 || val > 0xffU) - return (0); - *pp++ = val; - c = *++cp; - } else - break; - } - /* - * Check for trailing characters. - */ - if (c != '\0' && (!isascii(c) || !isspace((unsigned char)c))) - return (0); - /* - * Did we get a valid digit? - */ - if (!digit) - return (0); - /* - * Concoct the address according to - * the number of parts specified. - */ - n = pp - parts + 1; - switch (n) { - case 1: /* a -- 32 bits */ - break; - - case 2: /* a.b -- 8.24 bits */ - if (val > 0xffffffU) - return (0); - val |= parts[0] << 24; - break; - - case 3: /* a.b.c -- 8.8.16 bits */ - if (val > 0xffffU) - return (0); - val |= (parts[0] << 24) | (parts[1] << 16); - break; - - case 4: /* a.b.c.d -- 8.8.8.8 bits */ - if (val > 0xffU) - return (0); - val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); - break; - } - if (addr != NULL) - addr->s_addr = htonl(val); - return (1); -} - -/* - * Ascii internet address interpretation routine. - * The value returned is in network order. - */ -in_addr_t /* XXX should be struct in_addr :( */ -cygwin_inet_addr(const char *cp) { - struct in_addr val; - - if (cygwin_inet_aton(cp, &val)) - return (val.s_addr); - return (INADDR_NONE); -} - -#ifndef __CYGWIN__ -/* - * Weak aliases for applications that use certain private entry points, - * and fail to include . - */ -#undef inet_addr -__weak_reference(__inet_addr, inet_addr); -#undef inet_aton -__weak_reference(__inet_aton, inet_aton); -#endif diff --git a/winsup/cygwin/libc/inet_network.c b/winsup/cygwin/libc/inet_network.c deleted file mode 100644 index 52286f453..000000000 --- a/winsup/cygwin/libc/inet_network.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static const char sccsid[] = "@(#)inet_network.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ -#include -#ifndef __CYGWIN__ -__FBSDID("$FreeBSD$"); -#else -#define __INSIDE_CYGWIN__ -#define __INSIDE_CYGWIN_NET__ -#endif - -#ifndef __CYGWIN__ -#include "port_before.h" -#endif - -#include -#include -#include -#include - -#ifndef __CYGWIN__ -#include "port_after.h" -#endif - -/* - * Internet network address interpretation routine. - * The library routines call this routine to interpret - * network numbers. - */ -in_addr_t -cygwin_inet_network(cp) - const char *cp; -{ - in_addr_t val, base, n; - char c; - in_addr_t parts[4], *pp = parts; - int i, digit; - -again: - val = 0; base = 10; digit = 0; - if (*cp == '0') - digit = 1, base = 8, cp++; - if (*cp == 'x' || *cp == 'X') - base = 16, cp++; - while ((c = *cp) != 0) { - if (isdigit((unsigned char)c)) { - if (base == 8U && (c == '8' || c == '9')) - return (INADDR_NONE); - val = (val * base) + (c - '0'); - cp++; - digit = 1; - continue; - } - if (base == 16U && isxdigit((unsigned char)c)) { - val = (val << 4) + - (c + 10 - (islower((unsigned char)c) ? 'a' : 'A')); - cp++; - digit = 1; - continue; - } - break; - } - if (!digit) - return (INADDR_NONE); - if (*cp == '.') { - if (pp >= parts + 4 || val > 0xffU) - return (INADDR_NONE); - *pp++ = val, cp++; - goto again; - } - if (*cp && !isspace(*cp&0xff)) - return (INADDR_NONE); - *pp++ = val; - n = pp - parts; - if (n > 4U) - return (INADDR_NONE); - for (val = 0, i = 0; i < n; i++) { - val <<= 8; - val |= parts[i] & 0xff; - } - return (val); -} - -#ifndef __CYGWIN__ -/* - * Weak aliases for applications that use certain private entry points, - * and fail to include . - */ -#undef inet_network -__weak_reference(__inet_network, inet_network); -#endif diff --git a/winsup/cygwin/libc/minires-os-if.c b/winsup/cygwin/libc/minires-os-if.c deleted file mode 100644 index 3715c0847..000000000 --- a/winsup/cygwin/libc/minires-os-if.c +++ /dev/null @@ -1,567 +0,0 @@ -/* minires-os-if.c. Stub synchronous resolver for Cygwin. - - Copyright 2006, 2007, 2008, 2009 Red Hat, Inc. - - Written by Pierre A. Humblet - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "minires.h" - -#ifdef __CYGWIN__ -/*********************************************************************** - * - Windows interface code - -***********************************************************************/ - -/* Conflict between Windows definitions and others */ -#undef ERROR -#undef NOERROR -#undef DELETE - -#include -#include -#include - -/*********************************************************************** - * write_record: Translates a Windows DNS record into a compressed record - ***********************************************************************/ - -#define PUTDOMAIN(d,p)\ - {int res = dn_comp(d, p, EndPtr - p, dnptrs, lastdnptr); p += res < 0 ? strlen(d) : res; } - -static u_char * write_record(unsigned char * ptr, PDNS_RECORD rr, unsigned char * EndPtr, - unsigned char ** dnptrs, unsigned char ** lastdnptr, int debug) -{ - u_char * rd_length_ptr; - - PUTDOMAIN(rr->pName, ptr); - - if (ptr + 4 > EndPtr) - ptr += 4; - else { - PUTSHORT(rr->wType, ptr); - PUTSHORT(ns_c_in, ptr); - } - if ((rr->Flags.DW & 0x3) == DnsSectionQuestion) - return ptr; - - if (ptr + 4 > EndPtr) - ptr += 4; - else { - PUTLONG(rr->dwTtl, ptr); - } - rd_length_ptr = ptr; - ptr += 2; /* Placeholder for RDLENGTH */ - - /* The default case uses an undocumented feature of the Windows - resolver for types greater than 16. - The DNS_RECORD Data contains the record in wire format. */ - - switch(rr->wType) { - case DNS_TYPE_A: - { - u_char * aptr = (u_char *) & rr->Data.A.IpAddress; - if (ptr + 4 <= EndPtr) { - ptr[0] = aptr[0]; - ptr[1] = aptr[1]; - ptr[2] = aptr[2]; - ptr[3] = aptr[3]; - } - ptr += 4; - break; - } - case DNS_TYPE_NS: - case DNS_TYPE_MD: - case DNS_TYPE_MF: - case DNS_TYPE_CNAME: - case DNS_TYPE_MB: - case DNS_TYPE_MG: - case DNS_TYPE_MR: - case DNS_TYPE_PTR: - PUTDOMAIN(rr->Data.PTR.pNameHost, ptr); - break; - case DNS_TYPE_SOA: - PUTDOMAIN(rr->Data.SOA.pNamePrimaryServer, ptr); - PUTDOMAIN(rr->Data.SOA.pNameAdministrator, ptr); - if (ptr + 20 > EndPtr) - ptr += 20; - else { - PUTLONG(rr->Data.SOA.dwSerialNo, ptr); - PUTLONG(rr->Data.SOA.dwRefresh, ptr); - PUTLONG(rr->Data.SOA.dwRetry, ptr); - PUTLONG(rr->Data.SOA.dwExpire, ptr); - PUTLONG(rr->Data.SOA.dwDefaultTtl, ptr); - } - break; - case DNS_TYPE_NULL: - if (ptr + rr->Data.Null.dwByteCount <= EndPtr) - memcpy(ptr, rr->Data.Null.Data, rr->Data.Null.dwByteCount); - ptr += rr->Data.Null.dwByteCount; - if (rr->Data.Null.dwByteCount == rr->wDataLength - sizeof(DNS_NULL_DATA) + 1) - DPRINTF(debug, "Null byte count has an unexpected value\n"); - break; - case DNS_TYPE_WKS: - if (ptr + rr->wDataLength - sizeof(DNS_WKS_DATA) + 1 + 5 > EndPtr) - ptr += rr->wDataLength - sizeof(DNS_WKS_DATA) + 1 + 5; - else { - PUTLONG(rr->Data.WKS.IpAddress, ptr); - *ptr++ = rr->Data.WKS.chProtocol; - memcpy(ptr, rr->Data.WKS.BitMask, rr->wDataLength - sizeof(DNS_WKS_DATA) + 1); - ptr += rr->wDataLength - sizeof(DNS_WKS_DATA) + 1; - } - break; - case DNS_TYPE_MINFO: - case DNS_TYPE_RP: - PUTDOMAIN(rr->Data.MINFO.pNameMailbox, ptr); - PUTDOMAIN(rr->Data.MINFO.pNameErrorsMailbox, ptr); - break; - case DNS_TYPE_MX: - case DNS_TYPE_AFSDB: - case DNS_TYPE_RT: - if (ptr + 2 > EndPtr) - ptr += 2; - else - PUTSHORT(rr->Data.MX.wPreference, ptr); - PUTDOMAIN(rr->Data.MX.pNameExchange, ptr); - break; - case DNS_TYPE_HINFO: - case DNS_TYPE_ISDN: - case DNS_TYPE_TEXT: - case DNS_TYPE_X25: - { - unsigned int i, len; - for (i = 0; i < rr->Data.TXT.dwStringCount; i++) { - len = strlen(rr->Data.TXT.pStringArray[i]) & 0xFF; - if (ptr + len + 1 > EndPtr) - ptr += len + 1; - else { - *ptr++ = len; - memcpy(ptr, rr->Data.TXT.pStringArray[i], len); - ptr += len; - } - } - break; - } - case DNS_TYPE_SRV: - if (ptr + 6 > EndPtr) - ptr += 6; - else { - PUTSHORT(rr->Data.SRV.wPriority, ptr); - PUTSHORT(rr->Data.SRV.wWeight, ptr); - PUTSHORT(rr->Data.SRV.wPort, ptr); - } - PUTDOMAIN(rr->Data.SRV.pNameTarget, ptr); - break; - default: - { - unsigned int len = rr->wDataLength; - DPRINTF(debug, "No structure for wType %d\n", rr->wType); - if (ptr + len <= EndPtr) - memcpy(ptr, (char *) &rr->Data, len); - ptr += len; - break; - } - } - if (rd_length_ptr + 2 <= EndPtr) - PUTSHORT(ptr - rd_length_ptr - 2, rd_length_ptr); - return ptr; -} - -/*********************************************************************** - * - cygwin_query: implements res_nquery by calling DnsQuery - - ***********************************************************************/ -static int cygwin_query(res_state statp, const char * DomName, int Class, int Type, - unsigned char * AnsPtr, int AnsLength) -{ - DNS_STATUS res; - PDNS_RECORD pQueryResultsSet, rr; - int section, len, counts[4] = {0, 0, 0, 0}, debug = statp->options & RES_DEBUG; - unsigned char * dnptrs[256], * ptr; - - dnptrs[0] = AnsPtr; - dnptrs[1] = NULL; - - if (Class != ns_c_in) { - errno = ENOSYS; - statp->res_h_errno = NETDB_INTERNAL; - return -1; - } - - res = DnsQuery_A(DomName, Type, DNS_QUERY_TREAT_AS_FQDN, - NULL, &pQueryResultsSet, NULL); -#if 0 -#define NETDB_INTERNAL -1 /* see errno */ -#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ -#define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */ -#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ -#define NO_DATA 4 /* Valid name, no data record of requested type */ -#endif - - DPRINTF(debug, "DnsQuery: %lu (Windows)\n", res); - if (res) { - switch (res) { - case ERROR_INVALID_NAME: - errno = EINVAL; - statp->res_h_errno = NETDB_INTERNAL;; - break; - case ERROR_TIMEOUT: - statp->res_h_errno = TRY_AGAIN; - break; - case DNS_ERROR_RCODE_NAME_ERROR: - statp->res_h_errno = HOST_NOT_FOUND; - break; - case DNS_ERROR_RCODE_SERVER_FAILURE: - statp->res_h_errno = TRY_AGAIN; - break; - case DNS_ERROR_NO_DNS_SERVERS: - case DNS_ERROR_RCODE_FORMAT_ERROR: - case DNS_ERROR_RCODE_NOT_IMPLEMENTED: - case DNS_ERROR_RCODE_REFUSED: - statp->res_h_errno = NO_RECOVERY; - break; - case DNS_INFO_NO_RECORDS: /* May be returned even if the host doesn't exist */ - statp->res_h_errno = NO_DATA; - break; - default: - DPRINTF(debug, "Unknown code %lu for %s %d\n", res, DomName, Type); - statp->res_h_errno = NO_RECOVERY; - break; - } - len = -1; - goto done; - } - - ptr = AnsPtr + HFIXEDSZ; /* Skip header */ - - rr = pQueryResultsSet; - section = 0; - while (rr) { - if (!counts[0] && (rr->Flags.DW & 0x3)) { - /* No question. Adopt the first name as the name in the question */ - if ((len = dn_comp(rr->pName, ptr, AnsLength - 4, - dnptrs, &dnptrs[DIM(dnptrs) - 1])) < 0) { - ptr = NULL; - break; - } - ptr += len; - PUTSHORT(Type, ptr); - PUTSHORT(ns_c_in, ptr); - counts[0] = 1; - } - - DPRINTF(debug, "%s Section %d Type %u Windows Record Length %u\n", - rr->pName, rr->Flags.DW & 0x3, rr->wType, rr->wDataLength); - - /* Check the records are in correct section order */ - if ((rr->Flags.DW & 0x3) < section) { - DPRINTF(debug, "Unexpected section order %s %d\n", DomName, Type); - continue; - } - section = rr->Flags.DW & 0x3; - - ptr = write_record(ptr, rr, AnsPtr + AnsLength, dnptrs, - &dnptrs[DIM(dnptrs) - 1], debug); - - counts[section]++; - rr = rr->pNext; - } - - DnsRecordListFree(pQueryResultsSet, DnsFreeRecordList); - - len = ptr - AnsPtr; -done: - ptr = AnsPtr; - PUTSHORT(0, ptr); /* Id */ - PUTSHORT((QR << 8) + RA + RD, ptr); - for (section = 0; section < DIM(counts); section++) { - PUTSHORT(counts[section], ptr); - } - return len; -} - -/*********************************************************************** - * - get_registry_items: returns dns items from the registry - - kHey: Handle to registry key - KeyValue: key value to read - what: 0 addresses ; 1 search list - -***********************************************************************/ -static void get_registry_dns_items(HKEY hKey, LPCTSTR KeyValue, - res_state statp, int what) -{ - DWORD size = 0; - LONG res; - LPBYTE list; - int debug = statp->options & RES_DEBUG; - - res = RegQueryValueEx( hKey, KeyValue, NULL, NULL, NULL, &size); - DPRINTF(debug, "value %s, error %lu (Windows), size %lu\n", - KeyValue, res, size); - if ((res == ERROR_SUCCESS) && (size > 1)) { - if (!(list = (LPBYTE) alloca(size))) { - DPRINTF(debug, "alloca: %s\n", strerror(errno)); - } - else if ((res = RegQueryValueEx( hKey, KeyValue, NULL, NULL, list, - &size )) != ERROR_SUCCESS) { - DPRINTF(debug, "RegQueryValueEx: error %lu (Windows)\n", res); - } - else if (what == 0) { /* Get the addresses */ - BYTE *ap, *srch; - int numAddresses = 0; - for (ap = list; ap < list + size && *ap; ap = srch) { - /* The separation character can be 0, ' ', or ','. */ - for (srch = ap; *srch && (isdigit(*srch) || *srch == '.' ); srch++); - *srch++ = 0; - if (numAddresses < DIM(statp->nsaddr_list)) { - DPRINTF(debug, "server \"%s\"\n", ap); - statp->nsaddr_list[numAddresses].sin_addr.s_addr = cygwin_inet_addr((char *) ap); - if ( statp->nsaddr_list[numAddresses].sin_addr.s_addr != 0 ) - numAddresses++; - } - else - DPRINTF(debug, "no space for server \"%s\"\n", ap); - } - statp->nscount = numAddresses; - } - else /* Parse the search line */ - minires_get_search((char *) list, statp); - } - return; -} - -/*********************************************************************** - * - get_registry_dns: - - Read the registry to get dns server addresses in Network Byte Order, - and set statp->nscount (for NT <= 4.0) - Read the registry SearchList - -***********************************************************************/ - -static void get_registry_dns(res_state statp) -{ - HKEY hKey; - DWORD res; - const char *keyName = "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters"; - - DPRINTF(statp->options & RES_DEBUG, "key %s\n", keyName); - if ((res = RegOpenKeyEx( HKEY_LOCAL_MACHINE, keyName, 0, - KEY_QUERY_VALUE | KEY_READ, &hKey)) != ERROR_SUCCESS) { - DPRINTF(statp->options & RES_DEBUG, "RegOpenKeyEx: error %lu (Windows)\n", res); - return; - } - - if (statp->nscount == 0) - get_registry_dns_items(hKey, "NameServer", statp, 0); - if (statp->nscount == 0) - get_registry_dns_items(hKey, "DhcpNameServer", statp, 0); - if (statp->dnsrch[0] == NULL) - get_registry_dns_items(hKey, "SearchList", statp, 1); - - RegCloseKey(hKey); - - return; -} - -/*********************************************************************** - * - get_dns_info: Get the search list or the domain name - and the dns server addresses in Network Byte Order - Set statp->os_query if DnsQuery is available. - -***********************************************************************/ -void get_dns_info(res_state statp) -{ -#if MAX_HOSTNAME_LEN > MAXHOSTNAMELEN -#define MAX_HOSTNAME_SIZE (MAX_HOSTNAME_LEN + 1) -#else -#define MAX_HOSTNAME_SIZE (MAXHOSTNAMELEN + 1) -#endif -#if MAX_HOSTNAME_SIZE > 256 /* sizeof(defdname) */ -#error stap->defdname too short -#endif - - int res, debug = statp->options & RES_DEBUG; - - ULONG ulOutBufLen = 0; - DWORD dwRetVal; - IP_ADDR_STRING * pIPAddr; - FIXED_INFO * pFixedInfo; - int numAddresses = 0; - - if (statp->use_os - && ((dwRetVal = DnsQuery_A(NULL, 0, 0, NULL, NULL, NULL)) != ERROR_PROC_NOT_FOUND)) - { - DPRINTF(debug, "using dnsapi.dll %d\n", dwRetVal); - statp->os_query = (typeof(statp->os_query)) cygwin_query; - /* We just need the search list. Avoid loading iphlpapi. */ - statp->nscount = -1; - } - - if (statp->nscount != 0) - goto use_registry; - - /* First call to get the buffer length we need */ - dwRetVal = GetNetworkParams((FIXED_INFO *) 0, &ulOutBufLen); - if (dwRetVal != ERROR_BUFFER_OVERFLOW) { - DPRINTF(debug, "GetNetworkParams: error %lu (Windows)\n", dwRetVal); - goto use_registry; - } - if ((pFixedInfo = (FIXED_INFO *) alloca(ulOutBufLen)) == 0) { - DPRINTF(debug, "alloca: %s\n", strerror(errno)); - goto use_registry; - } - if ((dwRetVal = GetNetworkParams(pFixedInfo, & ulOutBufLen))) { - DPRINTF(debug, "GetNetworkParams: error %lu (Windows)\n", dwRetVal); - goto use_registry; - } - - DPRINTF(debug, "GetNetworkParams: OK\n"); - /* Record server addresses, up to array size */ - for (pIPAddr = &(pFixedInfo->DnsServerList), numAddresses = 0; - pIPAddr; - pIPAddr = pIPAddr->Next) { - if (numAddresses < DIM(statp->nsaddr_list)) { - DPRINTF(debug, "server \"%s\"\n", pIPAddr->IpAddress.String); - statp->nsaddr_list[numAddresses].sin_addr.s_addr = cygwin_inet_addr(pIPAddr->IpAddress.String); - if (statp->nsaddr_list[numAddresses].sin_addr.s_addr != 0) { - numAddresses++; - statp->nscount++; - } - } - else - DPRINTF(debug, "no space for server \"%s\"\n", pIPAddr->IpAddress.String); - } - - use_registry: - get_registry_dns(statp); - - if (!statp->dnsrch[0]) { - statp->defdname[sizeof(statp->defdname) - 1] = 0; - if (!(res = getdomainname(statp->defdname, sizeof(statp->defdname)))) { - if (statp->defdname[0] && !statp->defdname[sizeof(statp->defdname) - 1]) - statp->dnsrch[0] = statp->defdname; - } - DPRINTF(debug, "getdomainname \"%s\"\n", - (res)? strerror(errno) : statp->defdname); - } -} - -#else -/*********************************************************************** - * - Default interface code - -***********************************************************************/ - -void get_dns_info(res_state statp) -{ - return; -} - -#endif - - - -#if 0 -#define DNS_ERROR_RCODE_FORMAT_ERROR 9001L -#define DNS_ERROR_RCODE_SERVER_FAILURE 9002L -#define DNS_ERROR_RCODE_NAME_ERROR 9003L -#define DNS_ERROR_RCODE_NOT_IMPLEMENTED 9004L -#define DNS_ERROR_RCODE_REFUSED 9005L -#define DNS_ERROR_RCODE_YXDOMAIN 9006L -#define DNS_ERROR_RCODE_YXRRSET 9007L -#define DNS_ERROR_RCODE_NXRRSET 9008L -#define DNS_ERROR_RCODE_NOTAUTH 9009L -#define DNS_ERROR_RCODE_NOTZONE 9010L -#define DNS_ERROR_RCODE_BADSIG 9016L -#define DNS_ERROR_RCODE_BADKEY 9017L -#define DNS_ERROR_RCODE_BADTIME 9018L -#define DNS_INFO_NO_RECORDS 9501L -#define DNS_ERROR_BAD_PACKET 9502L -#define DNS_ERROR_NO_PACKET 9503L -#define DNS_ERROR_RCODE 9504L -#define DNS_ERROR_UNSECURE_PACKET 9505L -#define DNS_ERROR_INVALID_TYPE 9551L -#define DNS_ERROR_INVALID_IP_ADDRESS 9552L -#define DNS_ERROR_INVALID_PROPERTY 9553L -#define DNS_ERROR_TRY_AGAIN_LATER 9554L -#define DNS_ERROR_NOT_UNIQUE 9555L -#define DNS_ERROR_NON_RFC_NAME 9556L -#define DNS_STATUS_FQDN 9557L -#define DNS_STATUS_DOTTED_NAME 9558L -#define DNS_STATUS_SINGLE_PART_NAME 9559L -#define DNS_ERROR_INVALID_NAME_CHAR 9560L -#define DNS_ERROR_NUMERIC_NAME 9561L -#define DNS_ERROR_NOT_LALOWED_ON_ROOT_SERVER 9562L -#define DNS_ERROR_NOT_ALLOWED_UNDER_DELEGATION 9563L -#define DNS_ERROR_CANNOT_FIND_ROOT_HINTS 9564L -#define DNS_ERROR_INCONSISTENT_ROOT_HINTS 9565L -#define DNS_ERROR_ZONE_DOES_NOT_EXIST 9601L -#define DNS_ERROR_NO_ZONE_INFO 9602L -#define DNS_ERROR_INVALID_ZONE_OPERATION 9603L -#define DNS_ERROR_ZONE_CONFIGURATION_ERROR 9604L -#define DNS_ERROR_ZONE_HAS_NO_SOA_RECORD 9605L -#define DNS_ERROR_ZONE_HAS_NO_NS_RECORDS 9606L -#define DNS_ERROR_ZONE_LOCKED 9607L -#define DNS_ERROR_ZONE_CREATION_FAILED 9608L -#define DNS_ERROR_ZONE_ALREADY_EXISTS 9609L -#define DNS_ERROR_AUTOZONE_ALREADY_EXISTS 9610L -#define DNS_ERROR_INVALID_ZONE_TYPE 9611L -#define DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP 9612L -#define DNS_ERROR_ZONE_NOT_SECONDARY 9613L -#define DNS_ERROR_NEED_SECONDARY_ADDRESSES 9614L -#define DNS_ERROR_WINS_INIT_FAILED 9615L -#define DNS_ERROR_NEED_WINS_SERVERS 9616L -#define DNS_ERROR_NBSTAT_INIT_FAILED 9617L -#define DNS_ERROR_SOA_DELETE_INVALID 9618L -#define DNS_ERROR_FORWARDER_ALREADY_EXISTS 9619L -#define DNS_ERROR_ZONE_REQUIRES_MASTER_IP 9620L -#define DNS_ERROR_ZONE_IS_SHUTDOWN 9621L -#define DNS_ERROR_PRIMARY_REQUIRES_DATAFILE 9651L -#define DNS_ERROR_INVALID_DATAFILE_NAME 9652L -#define DNS_ERROR_DATAFILE_OPEN_FAILURE 9653L -#define DNS_ERROR_FILE_WRITEBACK_FAILED 9654L -#define DNS_ERROR_DATAFILE_PARSING 9655L -#define DNS_ERROR_RECORD_DOES_NOT_EXIST 9701L -#define DNS_ERROR_RECORD_FORMAT 9702L -#define DNS_ERROR_NODE_CREATION_FAILED 9703L -#define DNS_ERROR_UNKNOWN_RECORD_TYPE 9704L -#define DNS_ERROR_RECORD_TIMED_OUT 9705L -#define DNS_ERROR_NAME_NOT_IN_ZONE 9706L -#define DNS_ERROR_CNAME_LOOP 9707L -#define DNS_ERROR_NODE_IS_CNAME 9708L -#define DNS_ERROR_CNAME_COLLISION 9709L -#define DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT 9710L -#define DNS_ERROR_RECORD_ALREADY_EXISTS 9711L -#define DNS_ERROR_SECONDARY_DATA 9712L -#define DNS_ERROR_NO_CREATE_CACHE_DATA 9713L -#define DNS_ERROR_NAME_DOES_NOT_EXIST 9714L -#define DNS_WARNING_PTR_CREATE_FAILED 9715L -#define DNS_WARNING_DOMAIN_UNDELETED 9716L -#define DNS_ERROR_DS_UNAVAILABLE 9717L -#define DNS_ERROR_DS_ZONE_ALREADY_EXISTS 9718L -#define DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE 9719L -#define DNS_INFO_AXFR_COMPLETE 9751L -#define DNS_ERROR_AXFR 9752L -#define DNS_INFO_ADDED_LOCAL_WINS 9753L -#define DNS_STATUS_CONTINUE_NEEDED 9801L -#define DNS_ERROR_NO_TCPIP 9851L -#define DNS_ERROR_NO_DNS_SERVERS 9852L -#define DNS_ERROR_DP_DOES_NOT_EXIST 9901L -#define DNS_ERROR_DP_ALREADY_EXISTS 9902L -#define DNS_ERROR_DP_NOT_ENLISTED 9903L -#define DNS_ERROR_DP_ALREADY_ENLISTED 9904L -#define DNS_ERROR_DP_NOT_AVAILABLE 9905L -#endif diff --git a/winsup/cygwin/libc/minires.c b/winsup/cygwin/libc/minires.c deleted file mode 100644 index c401e7c60..000000000 --- a/winsup/cygwin/libc/minires.c +++ /dev/null @@ -1,995 +0,0 @@ -/* minires.c. Stub synchronous resolver for Cygwin. - - Copyright 2006, 2008, 2009 Red Hat, Inc. - - Written by Pierre A. Humblet - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "minires.h" - -/*********************************************************************** - -Utilities - -***********************************************************************/ -/*********************************************************************** - -dprintf -***********************************************************************/ -void minires_dprintf(const char * format, ...) -{ - va_list args; - - va_start(args, format); - fprintf(stderr, "Minires: "); - vfprintf(stderr, format, args); - va_end(args); -} - -/*********************************************************************** - -scanline -Put pointers in list[] to the beginning of each space or comma delimited -word in "in", and put the lengths in sizes[] (counting the final 0). -Return the number of words found -***********************************************************************/ -static int scanline(char * in, char **list, int * sizes, int maxnum) -{ - int i; - char * startp; - for (i = 0; i < maxnum; i++) { - while((*in) && (isspace((unsigned char)*in) || *in == ',')) in++; - if (*in == 0) - break; - startp = in++; - while((*in) && !isspace((unsigned char)*in) && *in != ',') in++; - list[i] = startp; - sizes[i] = in - startp + 1; - if (*in) - *in++ = 0; - } - return i; -} - -/*********************************************************************** - -Read the search string. - -***********************************************************************/ -void minires_get_search(char * string, res_state statp) -{ - char * words[MAXDNSRCH+1], * ptr; - int sizes[MAXDNSRCH+1]; - int i, j, debug = statp->options & RES_DEBUG; - - i = scanline(string, words, sizes, MAXDNSRCH+1); - ptr = statp->defdname; - for (j = 0; j < i; j++) { - if (j < MAXDNSRCH - && ptr + sizes[j] < &statp->defdname[DIM(statp->defdname)]) { - statp->dnsrch[j] = strcpy(ptr, words[j]); - statp->dnsrch[j+1] = NULL; - ptr += sizes[j]; - DPRINTF(debug, "search \"%s\"\n", words[j]); - } - else - DPRINTF(debug, "no space for \"%s\"\n", words[j]); - } -} - -/*********************************************************************** - -Read options - - -***********************************************************************/ -static void get_options(res_state statp, int i, char **words) -{ - char *ptr; - int value; - - while (i-- > 0) { - if (!strcasecmp("debug", words[i])) { - statp->options |= RES_DEBUG; - DPRINTF(statp->options & RES_DEBUG, "%s: 1\n", words[i]); - continue; - } - if (!strcasecmp("inet6", words[i])) { - statp->options |= RES_USE_INET6; - DPRINTF(statp->options & RES_DEBUG, "%s: 1\n", words[i]); - continue; - } - if (!strcasecmp("osquery", words[i])) { - statp->use_os = 1; - DPRINTF(statp->options & RES_DEBUG, "%s: 1\n", words[i]); - continue; - } - - if ((ptr = strchr(words[i], ':'))) { - *ptr++ = 0; - value = atoi(ptr); - /* Not supported - if (!strcasecmp("ndots", words[i])) { - statp->ndots = value; - continue; - } - */ - if (!strcasecmp("retry", words[i]) - || !strcasecmp("attempts", words[i])) { - if (value < 1) - value = 1; - else if (value > RES_MAXRETRY) - value = RES_MAXRETRY; - statp->retry = value; - DPRINTF(statp->options & RES_DEBUG, "%s: %d\n", words[i], value); - continue; - } - if (!strcasecmp("retrans", words[i]) - || !strcasecmp("timeout", words[i])) { - if (value < 1) - value = 1; - else if (value > RES_MAXRETRANS) - value = RES_MAXRETRANS; - statp->retrans = value; - DPRINTF(statp->options & RES_DEBUG, "%s: %d\n", words[i], value); - continue; - } - } - DPRINTF(statp->options & RES_DEBUG, "unknown option: \"%s\"\n", words[i]); - } -} - -/*********************************************************************** - -Read the resolv.conf file. -We only look for nameserver, domain, search and options - -***********************************************************************/ -#if MAXNS > MAXDNSRCH + 1 -#define MAXSIZE MAXNS -#else -#define MAXSIZE MAXDNSRCH + 1 /* Make unused one visible */ -#endif -static void get_resolv(res_state statp) -{ - FILE * fd; - char *words[MAXSIZE + 1], line[4096], *ptr; - int sizes[DIM(words)]; - int i, j, ns = 0, have_search, have_address, debug = statp->options & RES_DEBUG; - - fd = fopen(_PATH_RESCONF, "r"); - DPRINTF(debug, _PATH_RESCONF ": %s\n", fd?"OK":strerror(errno)); - if (fd == NULL) - return; - - statp->use_os = 0; /* Do not use os_query, except if allowed by "options" */ - have_search = (statp->dnsrch[0] != NULL); - have_address = (statp->nscount != 0); - - while ( fgets(line, sizeof(line), fd) != 0) { - DPRINTF(debug, "resolv.conf %s", line); - if ((i = scanline(line, words, sizes, DIM(words))) > 0) { - if (!have_address - && !strncasecmp("nameserver", words[0], sizes[0])) { - for ( j = 1; j < i ; j++) { - unsigned int address; - address = cygwin_inet_addr(words[j]); - if (address == -1) { - DPRINTF(debug, "invalid server \"%s\"\n", words[j]); - } - else if (ns >= MAXNS) { - DPRINTF(debug, "no space for server \"%s\"\n", words[j]); - } - else { - statp->nsaddr_list[ns++].sin_addr.s_addr = address; - statp->nscount++; - DPRINTF(debug, "server \"%s\"\n", words[j]); - } - } - } - else if (!have_search - && (!strncasecmp("search", words[0], sizes[0]) - || !strncasecmp("domain", words[0], sizes[0]))) { - ptr = statp->defdname; - for (j = 0; j + 1 < i; j++) { - if (j < MAXDNSRCH - && ptr + sizes[j + 1] < &statp->defdname[DIM(statp->defdname)]) { - statp->dnsrch[j] = strcpy(ptr, words[j+1]); - statp->dnsrch[j+1] = 0; - ptr += sizes[j+1]; - DPRINTF(debug, "domain|search \"%s\"\n", statp->dnsrch[j]); - } - else { - DPRINTF(debug, "no space for \"%s\"\n", words[j+1]); - } - } - } - /* Options line */ - else if (!strncasecmp("options", words[0], sizes[0])) - get_options(statp, i - 1, &words[1]); - } - } - fclose(fd); - return; -} - -/****************************************************************************/ -/* - open_sock() - Create a datagram socket and call bind. - -****************************************************************************/ - -static int open_sock(struct sockaddr_in *CliAddr, int debug) -{ - int fd; - - DPRINTF(debug, "opening UDP socket\n"); - - /* Create a datagram socket */ - if ((fd = cygwin_socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { - DPRINTF(debug, "socket(UDP): %s\n", strerror(errno)); - return -1; - } - /* Set non-blocking */ - if (fcntl64(fd, F_SETFL, O_NONBLOCK) < 0) { - DPRINTF(debug, "fcntl: %s\n", strerror(errno)); - return -1; - } - /* Set close on exec flag */ - if (fcntl64(fd, F_SETFD, 1) == -1) { - DPRINTF(debug, "fcntl: %s\n", strerror(errno)); - return -1; - } - - CliAddr->sin_family = AF_INET; - CliAddr->sin_addr.s_addr = htonl(INADDR_ANY); - CliAddr->sin_port = htons(0); - bzero(CliAddr->sin_zero, sizeof(CliAddr->sin_zero)); - /* Get a port */ - if (cygwin_bind(fd, (struct sockaddr *) CliAddr, sizeof(*CliAddr)) < 0) { - DPRINTF(debug, "bind: %s\n", strerror(errno)); - return -1; - } - return fd; -} - -/***************************************************************** - * - __res_state() - Undocumented but public. Accessed through _res - - *****************************************************************/ -static struct __res_state res; -struct __res_state *__res_state(void) -{ - return & res; -} - -/***************************************************************** - * - res_init() - - *****************************************************************/ -int res_ninit(res_state statp) -{ - int i; - - statp->res_h_errno = NETDB_SUCCESS; - /* Only debug may be set before calling init */ - statp->options &= RES_DEBUG; - statp->options |= RES_INIT | RES_DEFAULT; - statp->nscount = 0; - statp->os_query = NULL; - statp->retrans = RES_TIMEOUT; /* timeout in seconds */ - statp->retry = RES_MAXRETRY; /* max number of retries */ - statp->use_os = 1; /* use os_query if available and allowed by get_resolv */ - statp->mypid = -1; - statp->sockfd = -1; - /* Use the pid and the ppid for random seed, from the point of view of an outsider. - Mix the upper and lower bits as they are not used equally */ - i = getpid(); - statp->id = (ushort) (getppid() ^ (i << 8) ^ (i >> 8)); - for (i = 0; i < DIM(statp->dnsrch); i++) statp->dnsrch[i] = 0; - - /* resolv.conf (dns servers & search list)*/ - get_resolv(statp); - /* Get dns servers and search list from an os-specific routine, set os_query */ - get_dns_info(statp); - - if (statp->nscount == 0 && !statp->os_query) { - errno = ENONET; - statp->res_h_errno = NETDB_INTERNAL; - DPRINTF(statp->options & RES_DEBUG, "no dns server found\n"); - return -1; - } - for (i = 0; i < statp->nscount; i++) { - statp->nsaddr_list[i].sin_family = AF_INET; - statp->nsaddr_list[i].sin_port = htons(NAMESERVER_PORT); - bzero(statp->nsaddr_list[i].sin_zero, sizeof(statp->nsaddr_list[i].sin_zero)); - } - return 0; -} - -int res_init() -{ - int r = res_ninit(& res); - h_errno = res.res_h_errno; - return r; -} - -/***************************************************************** - * - res_close() - - *****************************************************************/ -void res_nclose(res_state statp) -{ - int res; - if (statp->sockfd != -1) { - res = close(statp->sockfd); - DPRINTF(statp->options & RES_DEBUG, "close sockfd %d: %s\n", - statp->sockfd, (res == 0)?"OK":strerror(errno)); - statp->sockfd = -1; - } -} - -void res_close() -{ - res_nclose(& res); -} - -/***************************************************************** - * - get_tcp_buf() - - *****************************************************************/ -static int get_tcp_buf(int fd, unsigned char *buf, int size, int debug) -{ - int res; - while (size > 0) { - if ((res = read(fd, buf, size)) < 0) { - DPRINTF(debug, "read: %s\n", strerror(errno)); - return -1; - } - DPRINTF(debug, "read %d out of %d\n", res, size); - size -= res; - buf += res; - } - return 0; -} - -/***************************************************************** - * - get_tcp() - - *****************************************************************/ -static int get_tcp(struct sockaddr_in *CliAddr, - const unsigned char * MsgPtr, int MsgLength, - unsigned char * AnsPtr, int AnsLength, int debug) -{ - int fd, res = -1; - unsigned short ans_length; - union {short len; u_char buf[sizeof(short)];} len_buf; - - DPRINTF(debug, "retrying with TCP\n"); - - /* Create a tcp socket */ - if ((fd = cygwin_socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { - DPRINTF(debug, "socket(TCP): %s\n", strerror(errno)); - return -1; - } - - if (cygwin_connect(fd, (struct sockaddr *) CliAddr, sizeof(* CliAddr)) < 0) { - DPRINTF(debug, "connect: %s\n", strerror(errno)); - goto done; - } - - /* Send the length then the message */ - len_buf.len = htons(MsgLength); - if (write(fd, len_buf.buf, sizeof(len_buf)) != sizeof(len_buf) - || write(fd, MsgPtr, MsgLength) != MsgLength) { - DPRINTF(debug, "write: %s\n", strerror(errno)); - goto done; - } - - /* Read the answer length */ - if (get_tcp_buf(fd, len_buf.buf, sizeof(len_buf), debug)) - goto done; - ans_length = ntohs(len_buf.len); - - /* Read the answer */ - if (get_tcp_buf(fd, AnsPtr, MIN(ans_length, AnsLength), debug)) - goto done; - res = ans_length; - - done: - close (fd); - return res; -} - -/***************************************************************** - ** - res_send - Assumes that the message is a query starting with a short id. - Handles retransmissions until that id is received. - -*****************************************************************/ -int res_nsend( res_state statp, const unsigned char * MsgPtr, - int MsgLength, unsigned char * AnsPtr, int AnsLength) -{ - /* Current server, shared by all tasks */ - volatile static unsigned int SServ = 0XFFFFFFFF; - int tcp; - const int debug = statp->options & RES_DEBUG; - - fd_set fdset_read; - int rslt, addrLen, transNum, wServ; - struct sockaddr_in mySockAddr, dnsSockAddr; - struct timeval timeOut; - - statp->res_h_errno = NETDB_SUCCESS; - if (((statp->options & RES_INIT) == 0) && (res_ninit(statp) != 0)) - return -1; - - /* Close the socket if it had been opened before a fork. - Reuse of pid's cannot hurt */ - if ((statp->sockfd != -1) && (statp->mypid != getpid())) { - res_nclose(statp); - } - - /* Open a socket for this process */ - if (statp->sockfd == -1) { - /* Create a non-blocking, close on exec socket and bind it (to any port) */ - statp->sockfd = open_sock(& mySockAddr, debug); - if (statp->sockfd < 0 ) { - statp->res_h_errno = NETDB_INTERNAL; - return -1; - } - statp->mypid = getpid(); - if (SServ == 0XFFFFFFFF) /* Pseudo random */ - SServ = statp->id % statp->nscount; - } - - transNum = 0; - while ( transNum++ < statp->retry) { - if ((wServ = SServ + 1) >= statp->nscount) - wServ = 0; - SServ = wServ; - - /* There exists attacks on DNS where many wrong answers with guessed id's and - spoofed source address and port are generated at about the time when the - program is tricked into resolving a name. - This routine runs through the retry loop for each incorrect answer. - It is thus extremely likely that such attacks will cause a TRY_AGAIN return, - probably causing the calling program to retry after a delay. - - Note that valid late or duplicate answers to a previous questions also cause - a retry, although this is minimized by flushing the socket before sending the - new question. - */ - - /* Flush duplicate or late answers */ - while ((rslt = cygwin_recvfrom( statp->sockfd, AnsPtr, AnsLength, 0, NULL, NULL)) >= 0) { - DPRINTF(debug, "Flushed %d bytes\n", rslt); - } - DPRINTF(debug && (errno != EWOULDBLOCK), - "Unexpected errno for flushing recvfrom: %s", strerror(errno)); - - /* Send the message */ - rslt = cygwin_sendto(statp->sockfd, MsgPtr, MsgLength, 0, - (struct sockaddr *) &statp->nsaddr_list[wServ], - sizeof(struct sockaddr_in)); - DPRINTF(debug, "sendto: server %08x sockfd %d %s\n", - statp->nsaddr_list[wServ].sin_addr.s_addr, - statp->sockfd, (rslt == MsgLength)?"OK":strerror(errno)); - if (rslt != MsgLength) { - statp->res_h_errno = NETDB_INTERNAL; - return -1; - }; - /* - Wait for a reply with select() - */ - FD_ZERO(&fdset_read); - FD_SET (statp->sockfd, &fdset_read ); - timeOut.tv_sec = statp->retrans; - timeOut.tv_usec = 0; - rslt = cygwin_select(statp->sockfd + 1, &fdset_read, NULL, NULL, &timeOut); - if ( rslt == 0 ) { /* Timeout */ - DPRINTF(statp->options & RES_DEBUG, "timeout for server %08x\n", - statp->nsaddr_list[wServ].sin_addr.s_addr); - continue; - } - else if ((rslt != 1) || (FD_ISSET(statp->sockfd, &fdset_read) == 0)) { - DPRINTF(debug, "select: %s\n", strerror(errno)); - statp->res_h_errno = NETDB_INTERNAL; - return -1; - } - - addrLen = sizeof(dnsSockAddr); - rslt = cygwin_recvfrom(statp->sockfd, AnsPtr, AnsLength, 0, - (struct sockaddr *) & dnsSockAddr, & addrLen); - if (rslt <= 0) { - DPRINTF(debug, "recvfrom: %s\n", strerror(errno)); - statp->res_h_errno = NETDB_INTERNAL; - return -1; - } - DPRINTF(debug, "recvfrom: %d bytes from %08x\n", rslt, dnsSockAddr.sin_addr.s_addr); - /* - Prepare to retry with tcp - */ - for (tcp = 0; tcp < 2; tcp++) { - /* Check if this is the expected message from the expected server */ - if ((memcmp(& dnsSockAddr, & statp->nsaddr_list[wServ], - (char *) & dnsSockAddr.sin_zero[0] - (char *) & dnsSockAddr) == 0) - && (rslt >= HFIXEDSZ) - && (*MsgPtr == *AnsPtr) /* Ids match */ - && (*(MsgPtr + 1) == *(AnsPtr + 1)) - && ((AnsPtr[2] & QR) != 0) - && (AnsPtr[4] == 0) - /* We check the question if present. - Some servers don't return it on error, in particular - when the name in the question is not valid. */ - && (((AnsPtr[5] == 0) - && ((AnsPtr[3] & ERR_MASK) != NOERROR)) - || ((AnsPtr[5] == 1) - && (rslt >= MsgLength) - && (memcmp(MsgPtr + HFIXEDSZ, AnsPtr + HFIXEDSZ, MsgLength - HFIXEDSZ) == 0)))) { - if ((AnsPtr[3] & ERR_MASK) == NOERROR) { - if ((AnsPtr[2] & TC) && (tcp == 0) && !(statp->options & RES_IGNTC)) { - /* Truncated. Try TCP */ - rslt = get_tcp(&statp->nsaddr_list[wServ], MsgPtr, MsgLength, - AnsPtr, AnsLength, statp->options & RES_DEBUG); - continue /* Tcp loop */; - } - else if ((AnsPtr[6] | AnsPtr[7])!= 0) - return rslt; - else - statp->res_h_errno = NO_DATA; - } -#if 0 - NETDB_INTERNAL -1 /* see errno */ - NETDB_SUCCESS 0 /* no problem */ - HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ - TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */ - Also seen returned by some servers when the name is too long - NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ - NO_DATA 4 /* Valid name, no data record of requested type */ -#endif - else { - switch (AnsPtr[3] & ERR_MASK) { - /* return HOST_NOT_FOUND even for non-authoritative answers */ - case NXDOMAIN: - case FORMERR: - statp->res_h_errno = HOST_NOT_FOUND; - break; - case SERVFAIL: - statp->res_h_errno = TRY_AGAIN; - break; - default: - statp->res_h_errno = NO_RECOVERY; - } - } - return -1; - } - else { - DPRINTF(debug, "unexpected answer\n"); - break; - } - } /* TCP */ - } - DPRINTF(debug, "too many retries\n"); - statp->res_h_errno = TRY_AGAIN; - return -1; -} - -int res_send( const unsigned char * MsgPtr, int MsgLength, - unsigned char * AnsPtr, int AnsLength) -{ - int r = res_nsend(& res, MsgPtr, MsgLength, AnsPtr, AnsLength); - h_errno = res.res_h_errno; - return r; -} - -/***************************************************************** - * - res_mkquery - - Return: packet size - -1 name format is incorrect -*****************************************************************/ -int res_nmkquery (res_state statp, - int op, const char * dnameptr, int qclass, int qtype, - const unsigned char * dataptr, int datalen, - const unsigned char * newrr, unsigned char * buf, int buflen) -{ - int i, len; - const char * ptr; - unsigned int id4; - - if (op == QUERY) { - /* Write the name and verify buffer length */ - len = dn_comp(dnameptr, buf + HFIXEDSZ, buflen - HFIXEDSZ - QFIXEDSZ, NULL, NULL); - if (len < 0) { - DPRINTF(statp->options & RES_DEBUG, - "\"%s\" invalid or buffer too short\n", dnameptr); - statp->res_h_errno = NETDB_INTERNAL; - return -1; - } - - /* Fill the header */ - PUTSHORT(statp->id, buf); - PUTSHORT(RD, buf); - PUTSHORT(1, buf); /* Number of questions */ - for (i = 0; i < 3; i++) - PUTSHORT(0, buf); /* Number of answers */ - - /* Write qtype and qclass */ - buf += len; - PUTSHORT(qtype, buf); - PUTSHORT(qclass, buf); - - /* Update id. The current query adds entropy to the next query id */ - for (id4 = qtype, i = 0, ptr = dnameptr; *ptr; ptr++, i += 3) - id4 ^= *ptr << (i & 0xF); - i = 1 + statp->id % 15; /* Between 1 and 16 */ - /* id dependent rotation, also brings MSW to LSW */ - id4 = (id4 << i) ^ (id4 >> (16 - i)) ^ (id4 >> (32 - i)); - if ((short) id4) - statp->id ^= (short) id4; - else - statp->id++; /* Force change */ - - return len + (HFIXEDSZ + QFIXEDSZ); /* packet size */ - } - else { /* Not implemented */ - errno = ENOSYS; - statp->res_h_errno = NETDB_INTERNAL; - return -1; - } -} - -int res_mkquery (int op, const char * dnameptr, int qclass, int qtype, - const unsigned char * dataptr, int datalen, - const unsigned char * newrr, unsigned char * buf, int buflen) -{ - int r = res_nmkquery (& res, op, dnameptr, qclass, qtype, - dataptr, datalen, newrr, buf, buflen); - h_errno = res.res_h_errno; - return r; - -} - -/***************************************************************** - * res_query() - *****************************************************************/ - -int res_nquery( res_state statp, const char * DomName, int Class, int Type, - unsigned char * AnsPtr, int AnsLength) -{ - u_char packet[PACKETSZ]; - int len; - - DPRINTF(statp->options & RES_DEBUG, "query \"%s\" type %d\n", DomName, Type); - statp->res_h_errno = NETDB_SUCCESS; - - /* If a hook exists to a native implementation, use it */ - if (statp->os_query) - return ((os_query_t *) statp->os_query)(statp, DomName, Class, Type, AnsPtr, AnsLength); - - if ((len = res_nmkquery (statp, QUERY, DomName, Class, Type, - 0, 0, 0, packet, PACKETSZ)) < 0) - return -1; - return res_nsend( statp, packet, len, AnsPtr, AnsLength); -} - -int res_query( const char * DomName, int Class, int Type, unsigned char * AnsPtr, int AnsLength) -{ - int r = res_nquery(& res, DomName, Class, Type, AnsPtr, AnsLength); - h_errno = res.res_h_errno; - return r; -} - -/***************************************************************** - * res_querydomain() - *****************************************************************/ -int res_nquerydomain( res_state statp, const char * Name, const char * DomName, - int Class, int Type, unsigned char * AnsPtr, int AnsLength) -{ - char fqdn[MAXDNAME], *ptr; - int nlen; - - if (!DomName) - ptr = (char *) Name; - else if ((nlen = strlen(Name)) >= sizeof(fqdn) - 1) - goto error; - else { - strcpy(fqdn, Name); - ptr = &fqdn[nlen]; - if (nlen && *(ptr - 1) != '.') - *(ptr++ - 1) = '.'; - fqdn[sizeof(fqdn) - 1] = 0; - strncpy(ptr, DomName, sizeof(fqdn) - (ptr - fqdn)); - if (fqdn[sizeof(fqdn) - 1]) - goto error; - ptr = fqdn; - } - return res_nquery(statp, ptr, Class, Type, AnsPtr, AnsLength); - - error: - DPRINTF(statp->options & RES_DEBUG, "querydomain: name too long\n"); - errno = EINVAL; - statp->res_h_errno = NETDB_INTERNAL;; - return -1; -} - -int res_querydomain( const char * Name, const char * DomName, int Class, - int Type, unsigned char * AnsPtr, int AnsLength) -{ - int r = res_nquerydomain(& res, Name, DomName, Class, Type, AnsPtr, - AnsLength); - h_errno = res.res_h_errno; - return r; -} - -/***************************************************************** - * - res_search() - - *****************************************************************/ - -int res_nsearch( res_state statp, const char * DomName, int Class, int Type, - unsigned char * AnsPtr, int AnsLength) -{ - int len, stat, i; - char fullDomName[MAXDNAME], *ptr, *sptr; - - DPRINTF(statp->options & RES_DEBUG, "search \"%s\" type %d\n", DomName, Type); - - if (((statp->options & RES_INIT) == 0) && (res_ninit(statp) != 0)) - return -1; - - stat = res_nquery( statp, DomName, Class, Type, AnsPtr, AnsLength); - - /* Check if will skip search */ - if (statp->res_h_errno != HOST_NOT_FOUND /* Success or hard failure */ - || ((ptr = strrchr(DomName, '.')) && (!*(ptr+1))) /* Final dot */ - || (((statp->options & RES_DNSRCH) == 0) /* Or no search */ - && ((ptr != NULL) /* And some dot */ - || ((statp->options & RES_DEFNAMES) == 0)))/* or no def domain */ - || (!(sptr = statp->dnsrch[0]))) - return stat; - - len = strlen(DomName); - if (len >= MAXDNAME - 1) /* Space for next dot */ - goto error; - strcpy(fullDomName, DomName); - fullDomName[len++] = '.'; - fullDomName[MAXDNAME - 1] = 0; /* Overflow indicator */ - i = 0; - do { - strncpy(fullDomName + len, sptr, MAXDNAME - len); - if (fullDomName[MAXDNAME - 1]) - goto error; - stat = res_nquery(statp, fullDomName, Class, Type, AnsPtr, AnsLength); - } while ((sptr = statp->dnsrch[++i]) != NULL - && statp->res_h_errno == HOST_NOT_FOUND - && (statp->options & RES_DNSRCH) != 0); - - /* Return last stat */ - return stat; - - error: - DPRINTF(statp->options & RES_DEBUG, "name too long during search\n"); - errno = EINVAL; - statp->res_h_errno = NETDB_INTERNAL; - return -1; -} - -int res_search( const char * DomName, int Class, int Type, - unsigned char * AnsPtr, int AnsLength) -{ - int r = res_nsearch(& res, DomName, Class, Type, AnsPtr, AnsLength); - h_errno = res.res_h_errno; - return r; -} - -/***************************************************************** - * dn_expand - *****************************************************************/ - -int dn_expand(const unsigned char *msg, const unsigned char *eomorig, - const unsigned char *comp_dn, char *exp_dn, int length) -{ - unsigned int len, complen = 0; - const unsigned char *comp_dn_orig = comp_dn; -/* char * exp_start = exp_dn; */ - - errno = EINVAL; - if (comp_dn >= eomorig) - goto expand_fail; - if ((len = *comp_dn++) == 0) /* Weird case */ - exp_dn++; - else do { - if (len <= MAXLABEL) { - if ((length -= (len + 1)) >= 0 /* Need space for final . */ - && comp_dn + len <= eomorig) { - do { *exp_dn++ = *comp_dn++; } while (--len != 0); - *exp_dn++ = '.'; - } - else - goto expand_fail; - } - else if (len >= (128+64)) { - if (!complen) /* Still in the original field? */ - complen = (comp_dn - comp_dn_orig) + 1; - comp_dn = msg + (((len & ~(128+64)) << 8) + *comp_dn); - if (comp_dn >= eomorig) - goto expand_fail; - } - else - goto expand_fail; - } while ((len = *comp_dn++) != 0); - /* Replace last . with a 0 */ - *(--exp_dn) = 0; - if (!complen) - complen = comp_dn - comp_dn_orig; -/* fprintf(stderr, "dn_expand %s\n", exp_start); */ - return complen; - -expand_fail: -/* fprintf(stderr, "dn_expand fails\n"); */ - return -1; -} - -/***************************************************************** - * - dn_comp - - Return -1 in case of overflow, but still fill buffer correctly. - We do not check the alphabet of the host names - nor the length of the compressed name and we - preserve the letter cases. - - *****************************************************************/ -int dn_comp(const char * exp_dn, u_char * comp_dn, int length, - u_char ** dnptrs, u_char ** lastdnptr) -{ - u_char *cptr = comp_dn, *dptr, *lptr, *rptr; - unsigned int i, len; - u_char * const eptr = comp_dn + length - 1; /* Last valid */ - - errno = EINVAL; - - if (*exp_dn == '.' && !*(exp_dn + 1)) - exp_dn++; - while (1) { - if (*exp_dn == '.' || cptr > eptr) - return -1; - if (*exp_dn == 0) { - *cptr++ = 0; - break; - } - /* Try to compress */ - if (dnptrs) { - for (i = 1; dnptrs[i]; i++) { - dptr = dnptrs[i]; - if (dptr >= comp_dn) /* Handle name.name */ - continue; - rptr = (u_char *) exp_dn; - len = *dptr++; - while (1) { - do { - if (*dptr++ != *rptr++) - goto next_dn; - } while (--len); - len = *dptr++; - if (len == 0) { /* last label */ - if (!*rptr || (*rptr == '.' && !*(rptr + 1))) { /* Full match */ - len = (dnptrs[i] - dnptrs[0]) | 0xC000; - /* Write pointer */ - *cptr++ = len >> 8; - if (cptr > eptr) - return -1; - *cptr++ = len; - goto done; - } - goto next_dn; - } - if (*rptr++ != '.') - goto next_dn; - if (len >= 128 + 64) { - dptr = dnptrs[0] + ((len - 128 - 64) << 8) + *dptr; - len = *dptr++; - } - } - next_dn: ; - } - /* Record label if asked and if space is available and if not too far off */ - if (lastdnptr && (lastdnptr != &dnptrs[i]) && (cptr - dnptrs[0]) < 0xC000) { - dnptrs[i] = cptr; - dnptrs[i+1] = NULL; - } - } - /* Write label */ - lptr = cptr++; /* Length byte */ - rptr = (u_char *) exp_dn; - do { - if (cptr <= eptr) - *cptr++ = *rptr; - } while ((*++rptr != '.') && (*rptr != 0)); - len = rptr - (u_char *) exp_dn; - if (len > MAXLABEL) - return -1; - *lptr = len; - exp_dn = (char *) rptr; - if (*exp_dn != 0) - exp_dn++; /* Skip over . */ - } - done: - return cptr - comp_dn; -} - -/***************************************************************** - * dn_skipname - - Measures the compressed domain name length and returns it. - *****************************************************************/ -int dn_skipname(const unsigned char *comp_dn, const unsigned char *eom) -{ - int len; - const unsigned char *comp_dn_orig = comp_dn; - - do { - len = *comp_dn++; - if (len >= (128 + 64)) { - comp_dn++; - break; - } - if (len > MAXLABEL || - (comp_dn += len) > eom) - return -1; - } while (len != 0); - - return comp_dn - comp_dn_orig; -} - -/***************************************************************** - * dn_length1 For internal use - - Return length of uncompressesed name incl final 0. - *****************************************************************/ - -int dn_length1(const unsigned char *msg, const unsigned char *eomorig, - const unsigned char *comp_dn) -{ - unsigned int len, length = 0; - - errno = EINVAL; - if (comp_dn >= eomorig) - goto expand_fail; - else while ((len = *comp_dn++) != 0) { - if (len <= MAXLABEL) { - if ((comp_dn += len) <= eomorig) - length += len + 1; - else - goto expand_fail; - } - else if (len >= (128+64)) { - comp_dn = msg + (((len & ~(128+64)) << 8) + *comp_dn); - if (comp_dn >= eomorig) - goto expand_fail; - } - else - goto expand_fail; - } - return length; - -expand_fail: - return -1; -} diff --git a/winsup/cygwin/libc/minires.h b/winsup/cygwin/libc/minires.h deleted file mode 100644 index cda0b4c51..000000000 --- a/winsup/cygwin/libc/minires.h +++ /dev/null @@ -1,68 +0,0 @@ -/* minires.h. Stub synchronous resolver for Cygwin. - - Copyright 2006 Red Hat, Inc. - - Written by Pierre A. Humblet - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#define __INSIDE_CYGWIN_NET__ - -#include "winsup.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -extern in_addr_t cygwin_inet_addr (const char *); -extern int cygwin_socket (int, int, int); -extern int cygwin_bind (int, const struct sockaddr *, socklen_t); -extern int cygwin_connect (int, const struct sockaddr *, socklen_t); -extern int cygwin_select (int, fd_set *, fd_set *, fd_set *, struct timeval *); -extern int cygwin_sendto (int, const void *, size_t, int, - const struct sockaddr *, socklen_t); -extern int cygwin_recvfrom (int, void *, size_t, int, struct sockaddr *, - socklen_t *); - -/* Number of elements is an array */ -#define DIM(x) (sizeof(x) / sizeof(*(x))) - -/* Definitions to parse the messages */ -#define RD (1<<8) /* Offset in a short */ -#define RA (1<<7) -#define QR (1<<7) /* Offsets in a char */ -#define TC (1<<1) -#define ERR_MASK 0xF - -/* Type for os specific res_lookup */ -typedef int (os_query_t) (res_state, const char *, int, int, u_char *, int); - -/* Special use of state elements */ -#define sockfd _vcsock -#define mypid _flags -#define os_query qhook -#define use_os pfcode - -#define DPRINTF(cond, format...) if (cond) minires_dprintf(format) - -/* Utility functions */ -void minires_dprintf(const char * format, ...); -void minires_get_search(char * string, res_state statp); -void get_dns_info(res_state statp); diff --git a/winsup/cygwin/libc/nftw.c b/winsup/cygwin/libc/nftw.c deleted file mode 100644 index bb1c92381..000000000 --- a/winsup/cygwin/libc/nftw.c +++ /dev/null @@ -1,126 +0,0 @@ -/* $OpenBSD: nftw.c,v 1.4 2004/07/07 16:05:23 millert Exp $ */ - -/* - * Copyright (c) 2003, 2004 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Sponsored in part by the Defense Advanced Research Projects - * Agency (DARPA) and Air Force Research Laboratory, Air Force - * Materiel Command, USAF, under agreement number F39502-99-1-0512. - */ - -#if 0 -#if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$OpenBSD: nftw.c,v 1.4 2004/07/07 16:05:23 millert Exp $"; -#endif /* LIBC_SCCS and not lint */ -#endif - -#ifdef __CYGWIN__ -#include "winsup.h" -#endif -#include -#if 0 -__FBSDID("$FreeBSD: /repoman/r/ncvs/src/lib/libc/gen/nftw.c,v 1.1.2.1 2004/08/29 06:10:53 tjr Exp $"); -#endif -#include -#include -#include -#include -#include -#include - -int -nftw(const char *path, int (*fn)(const char *, const struct __stat64 *, int, - struct FTW *), int nfds, int ftwflags) -{ - char * const paths[2] = { (char *)path, NULL }; - struct FTW ftw; - FTSENT *cur; - FTS *ftsp; - int error = 0, ftsflags, fnflag, postorder, sverrno; - -#if 0 - /* GLibc allows nfds < 1 and treats it as nfds == 1. Since nfds is - not used in this OpenBSD version anyway, just ignore it for - Linux compatibility. */ - /* XXX - nfds is currently unused */ - if (nfds < 1 || nfds > OPEN_MAX) { - errno = EINVAL; - return (-1); - } -#endif - - ftsflags = FTS_COMFOLLOW; - if (!(ftwflags & FTW_CHDIR)) - ftsflags |= FTS_NOCHDIR; - if (ftwflags & FTW_MOUNT) - ftsflags |= FTS_XDEV; - if (ftwflags & FTW_PHYS) - ftsflags |= FTS_PHYSICAL; - else - ftsflags |= FTS_LOGICAL; - postorder = (ftwflags & FTW_DEPTH) != 0; - ftsp = fts_open(paths, ftsflags, NULL); - if (ftsp == NULL) - return (-1); - while ((cur = fts_read(ftsp)) != NULL) { - switch (cur->fts_info) { - case FTS_D: - if (postorder) - continue; - fnflag = FTW_D; - break; - case FTS_DNR: - fnflag = FTW_DNR; - break; - case FTS_DP: - if (!postorder) - continue; - fnflag = FTW_DP; - break; - case FTS_F: - case FTS_DEFAULT: - fnflag = FTW_F; - break; - case FTS_NS: - case FTS_NSOK: - fnflag = FTW_NS; - break; - case FTS_SL: - fnflag = FTW_SL; - break; - case FTS_SLNONE: - fnflag = FTW_SLN; - break; - case FTS_DC: - errno = ELOOP; - /* FALLTHROUGH */ - default: - error = -1; - goto done; - } - ftw.base = cur->fts_pathlen - cur->fts_namelen; - ftw.level = cur->fts_level; - error = fn(cur->fts_path, cur->fts_statp, fnflag, &ftw); - if (error != 0) - break; - } -done: - sverrno = errno; - if (fts_close(ftsp) != 0 && error == 0) - error = -1; - else - errno = sverrno; - return (error); -} diff --git a/winsup/cygwin/libc/rcmd.cc b/winsup/cygwin/libc/rcmd.cc deleted file mode 100644 index 225ac325b..000000000 --- a/winsup/cygwin/libc/rcmd.cc +++ /dev/null @@ -1,778 +0,0 @@ -/* - * Copyright (c) 1983, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * 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. - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94"; -#endif /* LIBC_SCCS and not lint */ -#include -#ifndef __CYGWIN__ -__FBSDID("$FreeBSD$"); -#else -#define __INSIDE_CYGWIN_NET__ -#include "winsup.h" -#endif - -#ifndef __CYGWIN__ -#include "namespace.h" -#endif -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef __CYGWIN__ -#include -#endif -#ifdef YP -#include -#include -#endif -#ifndef __CYGWIN__ -#include -#include "un-namespace.h" -#endif - -#ifndef __CYGWIN__ -extern int innetgr( const char *, const char *, const char *, const char * ); - -#define max(a, b) ((a > b) ? a : b) -#else -#include "wininet.h" -#include "cygwin/in6.h" - -#ifndef _PATH_HEQUIV -# define _PATH_HEQUIV "/etc/hosts.equiv" -#endif - -#define innetgr(a,b,c,d) (0) - -extern int rcmdsh(char **, int, const char *, const char *, const char *, - const char *); - -extern "C" { - int cygwin_accept (int, struct sockaddr *, socklen_t *); - int cygwin_bindresvport_sa (int, struct sockaddr *); - int cygwin_connect (int, const struct sockaddr *, socklen_t); - void cygwin_freeaddrinfo (struct addrinfo *); - const char * cygwin_gai_strerror (int); - int cygwin_getaddrinfo (const char *, const char *, const struct addrinfo *, - struct addrinfo **); - int cygwin_getnameinfo (const struct sockaddr *, socklen_t, char *, size_t, - char *, size_t, int); - struct servent *cygwin_getservbyname (const char *, const char *); - int cygwin_listen (int, int); - int cygwin_rresvport_af(int *alport, int family); - int cygwin_select (int, fd_set *, fd_set *, fd_set *, struct timeval *); - int cygwin_socket (int, int, int); - int seteuid32 (__uid32_t); -} -#endif - -#ifndef __CYGWIN__ -static int __ivaliduser(FILE *, u_int32_t, const char *, const char *); -static int __ivaliduser_af(FILE *,const void *, const char *, const char *, - int, int); -#endif -static int __ivaliduser_sa(FILE *, const struct sockaddr *, socklen_t, - const char *, const char *); -static int __icheckhost(const struct sockaddr *, socklen_t, const char *); - -char paddr[NI_MAXHOST]; - -extern "C" int -cygwin_rcmd_af(char **ahost, in_port_t rport, const char *locuser, - const char *remuser, const char *cmd, int *fd2p, int af) -{ - struct addrinfo hints, *res, *ai; - struct sockaddr_storage from; - fd_set reads; - sigset_t oldmask, newmask; - pid_t pid; - int s, aport, lport, timo, error; - char c;//, *p; - int refused, nres; - char num[8]; - static char canonnamebuf[INTERNET_MAX_HOST_NAME_LENGTH + 1]; /* is it proper here? */ -#ifndef __CYGWIN__ - /* call rcmdsh() with specified remote shell if appropriate. */ - if (!issetugid() && (p = getenv("RSH"))) { - struct servent *sp = cygwin_getservbyname("shell", "tcp"); - - if (sp && sp->s_port == rport) - return (rcmdsh(ahost, rport, locuser, remuser, - cmd, p)); - } - - /* use rsh(1) if non-root and remote port is shell. */ - if (geteuid()) { - struct servent *sp = cygwin_getservbyname("shell", "tcp"); - - if (sp && sp->s_port == rport) - return (rcmdsh(ahost, rport, locuser, remuser, - cmd, NULL)); - } -#endif - pid = getpid(); - - memset(&hints, 0, sizeof(hints)); - hints.ai_flags = AI_CANONNAME; - hints.ai_family = af; - hints.ai_socktype = SOCK_STREAM; - hints.ai_protocol = 0; - (void)snprintf(num, sizeof(num), "%d", ntohs(rport)); - error = cygwin_getaddrinfo(*ahost, num, &hints, &res); - if (error) { - fprintf(stderr, "rcmd: getaddrinfo: %s\n", - cygwin_gai_strerror(error)); - if (error == EAI_SYSTEM) - fprintf(stderr, "rcmd: getaddrinfo: %s\n", - strerror(errno)); - return (-1); - } - - if (res->ai_canonname - && strlen(res->ai_canonname) + 1 < sizeof(canonnamebuf)) { - strncpy(canonnamebuf, res->ai_canonname, sizeof(canonnamebuf)); - *ahost = canonnamebuf; - } - nres = 0; - for (ai = res; ai; ai = ai->ai_next) - nres++; - ai = res; - refused = 0; - sigemptyset(&newmask); - sigaddset(&newmask, SIGURG); - sigprocmask(SIG_BLOCK, (const sigset_t *)&newmask, &oldmask); - for (timo = 1, lport = IPPORT_RESERVED - 1;;) { - s = cygwin_rresvport_af(&lport, ai->ai_family); - if (s < 0) { - if (errno != EAGAIN && ai->ai_next) { - ai = ai->ai_next; - continue; - } - if (errno == EAGAIN) - (void)fprintf(stderr, - "rcmd: socket: All ports in use\n"); - else - (void)fprintf(stderr, "rcmd: socket: %s\n", - strerror(errno)); - cygwin_freeaddrinfo(res); - sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, - NULL); - return (-1); - } - fcntl64(s, F_SETOWN, pid); - if (cygwin_connect(s, ai->ai_addr, ai->ai_addrlen) >= 0) - break; - (void)close(s); - if (errno == EADDRINUSE) { - lport--; - continue; - } - if (errno == ECONNREFUSED) - refused = 1; - if (ai->ai_next == NULL && (!refused || timo > 16)) { - (void)fprintf(stderr, "%s: %s\n", - *ahost, strerror(errno)); - cygwin_freeaddrinfo(res); - sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, - NULL); - return (-1); - } - if (nres > 1) { - int oerrno = errno; - - cygwin_getnameinfo(ai->ai_addr, ai->ai_addrlen, paddr, - sizeof(paddr), NULL, 0, NI_NUMERICHOST); - (void)fprintf(stderr, "connect to address %s: ", - paddr); - errno = oerrno; - perror(0); - } - if ((ai = ai->ai_next) == NULL) { - /* refused && timo <= 16 */ - struct timespec time_to_sleep, time_remaining; - - time_to_sleep.tv_sec = timo; - time_to_sleep.tv_nsec = 0; - (void)nanosleep(&time_to_sleep, &time_remaining); - timo *= 2; - ai = res; - refused = 0; - } - if (nres > 1) { - cygwin_getnameinfo(ai->ai_addr, ai->ai_addrlen, paddr, - sizeof(paddr), NULL, 0, NI_NUMERICHOST); - fprintf(stderr, "Trying %s...\n", paddr); - } - } - lport--; - if (fd2p == 0) { - write(s, "", 1); - lport = 0; - } else { - int s2 = cygwin_rresvport_af(&lport, ai->ai_family), s3; - socklen_t len = ai->ai_addrlen; - int nfds; - - if (s2 < 0) - goto bad; - cygwin_listen(s2, 1); - (void)snprintf(num, sizeof(num), "%d", lport); - if (write(s, num, strlen(num)+1) != (int)strlen(num)+1) { - (void)fprintf(stderr, - "rcmd: write (setting up stderr): %s\n", - strerror(errno)); - (void)close(s2); - goto bad; - } - nfds = max(s, s2)+1; - if(nfds > FD_SETSIZE) { - fprintf(stderr, "rcmd: too many files\n"); - (void)close(s2); - goto bad; - } -again: - FD_ZERO(&reads); - FD_SET(s, &reads); - FD_SET(s2, &reads); - errno = 0; - if (cygwin_select(nfds, &reads, 0, 0, 0) < 1 || !FD_ISSET(s2, &reads)){ - if (errno != 0) - (void)fprintf(stderr, - "rcmd: select (setting up stderr): %s\n", - strerror(errno)); - else - (void)fprintf(stderr, - "select: protocol failure in circuit setup\n"); - (void)close(s2); - goto bad; - } - s3 = cygwin_accept(s2, (struct sockaddr *)&from, &len); - switch (from.ss_family) { - case AF_INET: - aport = ntohs(((struct sockaddr_in *)&from)->sin_port); - break; -#ifdef INET6 - case AF_INET6: - aport = ntohs(((struct sockaddr_in6 *)&from)->sin6_port); - break; -#endif - default: - aport = 0; /* error */ - break; - } - /* - * XXX careful for ftp bounce attacks. If discovered, shut them - * down and check for the real auxiliary channel to connect. - */ - if (aport == 20) { - close(s3); - goto again; - } - (void)close(s2); - if (s3 < 0) { - (void)fprintf(stderr, - "rcmd: accept: %s\n", strerror(errno)); - lport = 0; - goto bad; - } - *fd2p = s3; - if (aport >= IPPORT_RESERVED || aport < IPPORT_RESERVED / 2) { - (void)fprintf(stderr, - "socket: protocol failure in circuit setup.\n"); - goto bad2; - } - } - (void)write(s, locuser, strlen(locuser)+1); - (void)write(s, remuser, strlen(remuser)+1); - (void)write(s, cmd, strlen(cmd)+1); - if (read(s, &c, 1) != 1) { - (void)fprintf(stderr, - "rcmd: %s: %s\n", *ahost, strerror(errno)); - goto bad2; - } - if (c != 0) { - while (read(s, &c, 1) == 1) { - (void)write(STDERR_FILENO, &c, 1); - if (c == '\n') - break; - } - goto bad2; - } - sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL); - cygwin_freeaddrinfo(res); - return (s); -bad2: - if (lport) - (void)close(*fd2p); -bad: - (void)close(s); - sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL); - cygwin_freeaddrinfo(res); - return (-1); -} - -extern "C" int -cygwin_rcmd(char **ahost, in_port_t rport, const char *locuser, - const char *remuser, const char *cmd, int *fd2p) -{ - return cygwin_rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, - AF_INET); -} - -extern "C" int -cygwin_rresvport_af(int *alport, int family) -{ - int s; - struct sockaddr_storage ss; - u_short *sport; - - memset(&ss, 0, sizeof(ss)); - ss.ss_family = family; - switch (family) { - case AF_INET: - sport = &((struct sockaddr_in *)&ss)->sin_port; - ((struct sockaddr_in *)&ss)->sin_addr.s_addr = INADDR_ANY; - break; -#ifdef INET6 - case AF_INET6: - sport = &((struct sockaddr_in6 *)&ss)->sin6_port; - ((struct sockaddr_in6 *)&ss)->sin6_addr = in6addr_any; - break; -#endif - default: - errno = EAFNOSUPPORT; - return -1; - } - - s = cygwin_socket(ss.ss_family, SOCK_STREAM, 0); - if (s < 0) - return (-1); -#if 0 /* compat_exact_traditional_rresvport_semantics */ - sin.sin_port = htons((u_short)*alport); - if (_bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0) - return (s); - if (errno != EADDRINUSE) { - (void)_close(s); - return (-1); - } -#endif - *sport = 0; - if (cygwin_bindresvport_sa(s, (struct sockaddr *)&ss) == -1) { - (void)close(s); - return (-1); - } - *alport = (int)ntohs(*sport); - return (s); -} - -extern "C" int -cygwin_rresvport(int *port) -{ - return cygwin_rresvport_af(port, AF_INET); -} - -int __check_rhosts_file = 1; -char *__rcmd_errstr; - -/* - * AF independent extension of iruserok. - * - * Returns 0 if ok, -1 if not ok. - */ -extern "C" int -iruserok_sa(const void *ra, int rlen, int superuser, const char *ruser, - const char *luser) -{ - const char *cp; - struct __stat64 sbuf; - struct passwd *pwd; - FILE *hostf; - uid_t uid; - int first; - char pbuf[MAXPATHLEN]; - const struct sockaddr *raddr; - struct sockaddr_storage ss; - - /* avoid alignment issue */ - if (rlen > (int) sizeof(ss)) - return(-1); - memcpy(&ss, ra, rlen); - raddr = (struct sockaddr *)&ss; - - first = 1; - hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "rt"); -again: - if (hostf) { - if (__ivaliduser_sa(hostf, raddr, rlen, luser, ruser) == 0) { - (void)fclose(hostf); - return (0); - } - (void)fclose(hostf); - } - if (first == 1 && (__check_rhosts_file || superuser)) { - first = 0; - if ((pwd = getpwnam(luser)) == NULL) - return (-1); - (void)strcpy(pbuf, pwd->pw_dir); - (void)strcat(pbuf, "/.rhosts"); - - /* - * Change effective uid while opening .rhosts. If root and - * reading an NFS mounted file system, can't read files that - * are protected read/write owner only. - */ - uid = geteuid32(); - (void)seteuid32(pwd->pw_uid); - hostf = fopen(pbuf, "rt"); - (void)seteuid32(uid); - - if (hostf == NULL) - return (-1); - /* - * If not a regular file, or is owned by someone other than - * user or root or if writeable by anyone but the owner, quit. - */ - cp = NULL; - if (lstat64(pbuf, &sbuf) < 0) - cp = ".rhosts lstat failed"; - else if (!S_ISREG(sbuf.st_mode)) - cp = ".rhosts not regular file"; - else if (fstat64(fileno(hostf), &sbuf) < 0) - cp = ".rhosts fstat failed"; - else if (sbuf.st_uid && sbuf.st_uid != pwd->pw_uid) - cp = "bad .rhosts owner"; - else if (sbuf.st_mode & (S_IWGRP|S_IWOTH)) - cp = ".rhosts writeable by other than owner"; - /* If there were any problems, quit. */ - if (cp) { - __rcmd_errstr = (char *) cp; - (void)fclose(hostf); - return (-1); - } - goto again; - } - return (-1); -} - -/* - * New .rhosts strategy: We are passed an ip address. We spin through - * hosts.equiv and .rhosts looking for a match. When the .rhosts only - * has ip addresses, we don't have to trust a nameserver. When it - * contains hostnames, we spin through the list of addresses the nameserver - * gives us and look for a match. - * - * Returns 0 if ok, -1 if not ok. - */ -extern "C" int -iruserok(unsigned long raddr, int superuser, const char *ruser, - const char *luser) -{ - struct sockaddr_in sin; - - memset(&sin, 0, sizeof(sin)); - sin.sin_family = AF_INET; - memcpy(&sin.sin_addr, &raddr, sizeof(sin.sin_addr)); - return iruserok_sa((struct sockaddr *)&sin, sizeof(struct sockaddr_in), - superuser, ruser, luser); -} - -extern "C" int -ruserok(const char *rhost, int superuser, const char *ruser, const char *luser) -{ - struct addrinfo hints, *res, *r; - int error; - - memset(&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_DGRAM; /*dummy*/ - error = cygwin_getaddrinfo(rhost, "0", &hints, &res); - if (error) - return (-1); - - for (r = res; r; r = r->ai_next) { - if (iruserok_sa(r->ai_addr, r->ai_addrlen, superuser, ruser, - luser) == 0) { - cygwin_freeaddrinfo(res); - return (0); - } - } - cygwin_freeaddrinfo(res); - return (-1); -} - -#ifndef __CYGWIN__ -/* - * XXX - * Don't make static, used by lpd(8). - * - * Returns 0 if ok, -1 if not ok. - */ -static int -__ivaliduser(FILE *hostf, u_int32_t raddr, const char *luser, const char *ruser) -{ - struct sockaddr_in sin; - - memset(&sin, 0, sizeof(sin)); - sin.sin_family = AF_INET; - memcpy(&sin.sin_addr, &raddr, sizeof(sin.sin_addr)); - return __ivaliduser_sa(hostf, (struct sockaddr *)&sin, - sizeof(struct sockaddr_in), luser, ruser); -} - -/* - * Returns 0 if ok, -1 if not ok. - * - * XXX obsolete API. - */ -static int -__ivaliduser_af(FILE *hostf, const void *raddr, const char *luser, - const char *ruser, int af, int len) -{ - struct sockaddr *sa = NULL; - struct sockaddr_in *sin = NULL; -#ifdef INET6 - struct sockaddr_in6 *sin6 = NULL; -#endif - struct sockaddr_storage ss; - int salen = 0; - - memset(&ss, 0, sizeof(ss)); - switch (af) { - case AF_INET: - if (len != sizeof(sin->sin_addr)) - return -1; - sin = (struct sockaddr_in *)&ss; - sin->sin_family = AF_INET; - salen = sizeof(struct sockaddr_in); - memcpy(&sin->sin_addr, raddr, sizeof(sin->sin_addr)); - break; -#ifdef INET6 - case AF_INET6: - if (len != sizeof(sin6->sin6_addr)) - return -1; - /* you will lose scope info */ - sin6 = (struct sockaddr_in6 *)&ss; - sin6->sin6_family = AF_INET6; - salen = sizeof(struct sockaddr_in6); - memcpy(&sin6->sin6_addr, raddr, sizeof(sin6->sin6_addr)); - break; -#endif - default: - return -1; - } - - sa = (struct sockaddr *)&ss; - return __ivaliduser_sa(hostf, sa, salen, luser, ruser); -} -#endif - -static int -__ivaliduser_sa(FILE *hostf, const struct sockaddr *raddr, socklen_t salen, - const char *luser, const char *ruser) -{ - char *user, *p; - int ch; - char buf[MAXHOSTNAMELEN + 128]; /* host + login */ - char hname[MAXHOSTNAMELEN]; - /* Presumed guilty until proven innocent. */ - int userok = 0, hostok = 0; -#ifdef YP - char *ypdomain; - - if (yp_get_default_domain(&ypdomain)) - ypdomain = NULL; -#else -#define ypdomain NULL -#endif - /* We need to get the damn hostname back for netgroup matching. */ - if (cygwin_getnameinfo(raddr, salen, hname, sizeof(hname), NULL, 0, - NI_NAMEREQD) != 0) - hname[0] = '\0'; - - while (fgets(buf, sizeof(buf), hostf)) { - p = buf; - /* Skip lines that are too long. */ - if (strchr(p, '\n') == NULL) { - while ((ch = getc(hostf)) != '\n' && ch != EOF); - continue; - } - if (*p == '\n' || *p == '#') { - /* comment... */ - continue; - } - while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0') { - *p = isupper((unsigned char)*p) ? tolower((unsigned char)*p) : *p; - p++; - } - if (*p == ' ' || *p == '\t') { - *p++ = '\0'; - while (*p == ' ' || *p == '\t') - p++; - user = p; - while (*p != '\n' && *p != ' ' && - *p != '\t' && *p != '\0') - p++; - } else - user = p; - *p = '\0'; - /* - * Do +/- and +@/-@ checking. This looks really nasty, - * but it matches SunOS's behavior so far as I can tell. - */ - switch(buf[0]) { - case '+': - if (!buf[1]) { /* '+' matches all hosts */ - hostok = 1; - break; - } - if (buf[1] == '@') /* match a host by netgroup */ - hostok = hname[0] != '\0' && - innetgr(&buf[2], hname, NULL, ypdomain); - else /* match a host by addr */ - hostok = __icheckhost(raddr, salen, - (char *)&buf[1]); - break; - case '-': /* reject '-' hosts and all their users */ - if (buf[1] == '@') { - if (hname[0] == '\0' || - innetgr(&buf[2], hname, NULL, ypdomain)) - return(-1); - } else { - if (__icheckhost(raddr, salen, - (char *)&buf[1])) - return(-1); - } - break; - default: /* if no '+' or '-', do a simple match */ - hostok = __icheckhost(raddr, salen, buf); - break; - } - switch(*user) { - case '+': - if (!*(user+1)) { /* '+' matches all users */ - userok = 1; - break; - } - if (*(user+1) == '@') /* match a user by netgroup */ - userok = innetgr(user+2, NULL, ruser, ypdomain); - else /* match a user by direct specification */ - userok = !(strcmp(ruser, user+1)); - break; - case '-': /* if we matched a hostname, */ - if (hostok) { /* check for user field rejections */ - if (!*(user+1)) - return(-1); - if (*(user+1) == '@') { - if (innetgr(user+2, NULL, - ruser, ypdomain)) - return(-1); - } else { - if (!strcmp(ruser, user+1)) - return(-1); - } - } - break; - default: /* no rejections: try to match the user */ - if (hostok) - userok = !(strcmp(ruser,*user ? user : luser)); - break; - } - if (hostok && userok) - return(0); - } - return (-1); -} - -/* - * Returns "true" if match, 0 if no match. - */ -static int -__icheckhost(const struct sockaddr *raddr, socklen_t salen, const char *lhost) -{ - struct sockaddr_in sin; - struct sockaddr_in6 *sin6; - struct addrinfo hints, *res, *r; - int error; - char h1[NI_MAXHOST], h2[NI_MAXHOST]; - - if (raddr->sa_family == AF_INET6) { - sin6 = (struct sockaddr_in6 *)raddr; - if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { - memset(&sin, 0, sizeof(sin)); - sin.sin_family = AF_INET; - memcpy(&sin.sin_addr, &sin6->sin6_addr.s6_addr[12], - sizeof(sin.sin_addr)); - raddr = (struct sockaddr *)&sin; - salen = sizeof(struct sockaddr_in); - } - } - - h1[0] = '\0'; - if (cygwin_getnameinfo(raddr, salen, h1, sizeof(h1), NULL, 0, - NI_NUMERICHOST) != 0) - return (0); - - /* Resolve laddr into sockaddr */ - memset(&hints, 0, sizeof(hints)); - hints.ai_family = raddr->sa_family; - hints.ai_socktype = SOCK_DGRAM; /*XXX dummy*/ - res = NULL; - error = cygwin_getaddrinfo(lhost, "0", &hints, &res); - if (error) - return (0); - - for (r = res; r ; r = r->ai_next) { - h2[0] = '\0'; - if (cygwin_getnameinfo(r->ai_addr, r->ai_addrlen, h2, sizeof(h2), - NULL, 0, NI_NUMERICHOST) != 0) - continue; - if (strcmp(h1, h2) == 0) { - cygwin_freeaddrinfo(res); - return (1); - } - } - - /* No match. */ - cygwin_freeaddrinfo(res); - return (0); -} diff --git a/winsup/cygwin/libc/rexec.cc b/winsup/cygwin/libc/rexec.cc deleted file mode 100644 index 1ee25ed53..000000000 --- a/winsup/cygwin/libc/rexec.cc +++ /dev/null @@ -1,412 +0,0 @@ -/* - * Copyright (c) 1980, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - * 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. - * - * $FreeBSD$ - */ - -/* CV 2006-07-04: Tweaked for inclusion into Cygwin. */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rexec.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#ifdef __CYGWIN__ -#include "winsup.h" -#include "sigproc.h" -#include "cygtls.h" -#include -#endif - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -extern "C" { - int cygwin_accept (int, struct sockaddr *, socklen_t *); - int cygwin_connect (int, const struct sockaddr *, socklen_t); - int cygwin_getsockname (int, struct sockaddr *, socklen_t *); - void cygwin_herror (const char *); - int cygwin_listen (int, int); - int cygwin_socket (int, int, int); -} - -/* - * Options and other state info. - */ -struct macel { - char mac_name[9]; /* macro name */ - char *mac_start; /* start of macro in macbuf */ - char *mac_end; /* end of macro in macbuf */ -}; - -int macnum; /* number of defined macros */ -struct macel macros[16]; -char macbuf[4096]; - -static FILE *cfile; - -#define DEFAULT 1 -#define LOGIN 2 -#define PASSWD 3 -#define ACCOUNT 4 -#define MACDEF 5 -#define ID 10 -#define MACH 11 - -static char tokval[100]; - -static struct toktab { - const char *tokstr; - int tval; -} toktab[]= { - { "default", DEFAULT }, - { "login", LOGIN }, - { "password", PASSWD }, - { "passwd", PASSWD }, - { "account", ACCOUNT }, - { "machine", MACH }, - { "macdef", MACDEF }, - { NULL, 0 } -}; - -static int -token() -{ - char *cp; - int c; - struct toktab *t; - - if (feof(cfile) || ferror(cfile)) - return (0); - while ((c = getc(cfile)) != EOF && - (c == '\n' || c == '\t' || c == ' ' || c == ',')) - continue; - if (c == EOF) - return (0); - cp = tokval; - if (c == '"') { - while ((c = getc(cfile)) != EOF && c != '"') { - if (c == '\\') - c = getc(cfile); - *cp++ = c; - } - } else { - *cp++ = c; - while ((c = getc(cfile)) != EOF - && c != '\n' && c != '\t' && c != ' ' && c != ',') { - if (c == '\\') - c = getc(cfile); - *cp++ = c; - } - } - *cp = 0; - if (tokval[0] == 0) - return (0); - for (t = toktab; t->tokstr; t++) - if (!strcmp(t->tokstr, tokval)) - return (t->tval); - return (ID); -} - -static int -ruserpass(const char *host, char **aname, char **apass, char **aacct) -{ - const char *hdir; - char buf[BUFSIZ], *tmp; - char myname[INTERNET_MAX_HOST_NAME_LENGTH + 1]; - const char *mydomain; - int t, i, c, usedefault = 0; - struct __stat64 stb; - - hdir = getenv("HOME"); - if (hdir == NULL) - hdir = "."; - if (strlen(hdir) + 8 > sizeof(buf)) - return (0); - (void) sprintf(buf, "%s/.netrc", hdir); - cfile = fopen(buf, "r"); - if (cfile == NULL) { - if (errno != ENOENT) - warn("%s", buf); - return (0); - } - if (cygwin_gethostname(myname, sizeof(myname)) < 0) - myname[0] = '\0'; - if ((mydomain = strchr(myname, '.')) == NULL) - mydomain = ""; -next: - while ((t = token())) switch(t) { - - case DEFAULT: - usedefault = 1; - /* FALL THROUGH */ - - case MACH: - if (!usedefault) { - if (token() != ID) - continue; - /* - * Allow match either for user's input host name - * or official hostname. Also allow match of - * incompletely-specified host in local domain. - */ - if (strcasecmp(host, tokval) == 0) - goto match; - if ((tmp = strchr(host, '.')) != NULL && - strcasecmp(tmp, mydomain) == 0 && - strncasecmp(host, tokval, tmp - host) == 0 && - tokval[tmp - host] == '\0') - goto match; - continue; - } - match: - while ((t = token()) && t != MACH && t != DEFAULT) switch(t) { - - case LOGIN: - if (token()) { - if (*aname == 0) { - *aname = (char *) malloc((unsigned) strlen(tokval) + 1); - (void) strcpy(*aname, tokval); - } else { - if (strcmp(*aname, tokval)) - goto next; - } - } - break; - case PASSWD: - if ((*aname == 0 || strcmp(*aname, "anonymous")) && - fstat64(fileno(cfile), &stb) >= 0 && - (stb.st_mode & 077) != 0) { - warnx("Error: .netrc file is readable by others."); - warnx("Remove password or make file unreadable by others."); - goto bad; - } - if (token() && *apass == 0) { - *apass = (char *) malloc((unsigned) strlen(tokval) + 1); - (void) strcpy(*apass, tokval); - } - break; - case ACCOUNT: - if (fstat64(fileno(cfile), &stb) >= 0 - && (stb.st_mode & 077) != 0) { - warnx("Error: .netrc file is readable by others."); - warnx("Remove account or make file unreadable by others."); - goto bad; - } - if (token() && aacct && *aacct == 0) { - *aacct = (char *) malloc((unsigned) strlen(tokval) + 1); - (void) strcpy(*aacct, tokval); - } - break; - case MACDEF: - while ((c=getc(cfile)) != EOF && - (c == ' ' || c == '\t')) - ; - if (c == EOF || c == '\n') { - printf("Missing macdef name argument.\n"); - goto bad; - } - if (macnum == 16) { - printf("Limit of 16 macros have already been defined\n"); - goto bad; - } - tmp = macros[macnum].mac_name; - *tmp++ = c; - for (i=0; i < 8 && (c=getc(cfile)) != EOF && - !isspace(c); ++i) { - *tmp++ = c; - } - if (c == EOF) { - printf("Macro definition missing null line terminator.\n"); - goto bad; - } - *tmp = '\0'; - if (c != '\n') { - while ((c=getc(cfile)) != EOF && c != '\n'); - } - if (c == EOF) { - printf("Macro definition missing null line terminator.\n"); - goto bad; - } - if (macnum == 0) { - macros[macnum].mac_start = macbuf; - } - else { - macros[macnum].mac_start = macros[macnum-1].mac_end + 1; - } - tmp = macros[macnum].mac_start; - while (tmp != macbuf + 4096) { - if ((c=getc(cfile)) == EOF) { - printf("Macro definition missing null line terminator.\n"); - goto bad; - } - *tmp = c; - if (*tmp == '\n') { - if (*(tmp-1) == '\0') { - macros[macnum++].mac_end = tmp - 1; - break; - } - *tmp = '\0'; - } - tmp++; - } - if (tmp == macbuf + 4096) { - printf("4K macro buffer exceeded\n"); - goto bad; - } - break; - default: - warnx("Unknown .netrc keyword %s", tokval); - break; - } - goto done; - } -done: - (void) fclose(cfile); - return (0); -bad: - (void) fclose(cfile); - return (-1); -} - -extern "C" int -cygwin_rexec (char **ahost, unsigned short rport, char *name, char *pass, - char *cmd, int *fd2p) -{ - struct sockaddr_in sin, sin2, from; - struct hostent *hp; - u_short port = 0; - int s, timo = 1, s3; - char c; - char ahostbuf[INTERNET_MAX_HOST_NAME_LENGTH + 1]; - - sig_dispatch_pending (); - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - hp = cygwin_gethostbyname(*ahost); - if (hp == 0) { - cygwin_herror(*ahost); - return (-1); - } - *ahost = strcpy (ahostbuf, hp->h_name); - ruserpass(hp->h_name, &name, &pass, NULL); - if (!name) - name = getlogin (); - if (!pass) - pass = almost_null; -retry: - s = cygwin_socket(AF_INET, SOCK_STREAM, 0); - if (s < 0) { - perror("rexec: socket"); - return (-1); - } - sin.sin_family = hp->h_addrtype; - sin.sin_port = rport; - bcopy(hp->h_addr, (caddr_t)&sin.sin_addr, hp->h_length); - if (cygwin_connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) { - if (errno == ECONNREFUSED && timo <= 16) { - (void) close(s); - sleep(timo); - timo *= 2; - goto retry; - } - perror(hp->h_name); - return (-1); - } - if (fd2p == 0) { - (void) write(s, "", 1); - } else { - char num[8]; - int s2, sin2len; - - s2 = cygwin_socket(AF_INET, SOCK_STREAM, 0); - if (s2 < 0) { - (void) close(s); - return (-1); - } - cygwin_listen(s2, 1); - sin2len = sizeof (sin2); - if (cygwin_getsockname(s2, (struct sockaddr *)&sin2, &sin2len) < 0 || - sin2len != sizeof (sin2)) { - perror("getsockname"); - (void) close(s2); - goto bad; - } - port = ntohs((u_short)sin2.sin_port); - (void) sprintf(num, "%u", port); - (void) write(s, num, strlen(num)+1); - { int len = sizeof (from); - s3 = cygwin_accept(s2, (struct sockaddr *)&from, &len); - close(s2); - if (s3 < 0) { - perror("accept"); - port = 0; - goto bad; - } - } - *fd2p = s3; - } - (void) write(s, name, strlen(name) + 1); - /* should public key encypt the password here */ - (void) write(s, pass, strlen(pass) + 1); - (void) write(s, cmd, strlen(cmd) + 1); - if (read(s, &c, 1) != 1) { - perror(*ahost); - goto bad; - } - if (c != 0) { - while (read(s, &c, 1) == 1) { - (void) write(2, &c, 1); - if (c == '\n') - break; - } - goto bad; - } - return (s); -bad: - if (port) - (void) close(*fd2p); - (void) close(s); - return (-1); -} diff --git a/winsup/cygwin/libc/strfmon.c b/winsup/cygwin/libc/strfmon.c deleted file mode 100644 index 79f8ab461..000000000 --- a/winsup/cygwin/libc/strfmon.c +++ /dev/null @@ -1,622 +0,0 @@ -/*- - * Copyright (c) 2001 Alexey Zelkin - * All rights reserved. - * - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - */ - -#include -#if 0 -__FBSDID("$FreeBSD: src/lib/libc/stdlib/strfmon.c,v 1.19 2008/04/24 07:49:00 ru Exp $"); -#endif - -#include "winsup.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* internal flags */ -#define NEED_GROUPING 0x01 /* print digits grouped (default) */ -#define SIGN_POSN_USED 0x02 /* '+' or '(' usage flag */ -#define LOCALE_POSN 0x04 /* use locale defined +/- (default) */ -#define PARENTH_POSN 0x08 /* enclose negative amount in () */ -#define SUPRESS_CURR_SYMBOL 0x10 /* supress the currency from output */ -#define LEFT_JUSTIFY 0x20 /* left justify */ -#define USE_INTL_CURRENCY 0x40 /* use international currency symbol */ -#define IS_NEGATIVE 0x80 /* is argument value negative ? */ - -/* internal macros */ -#define PRINT(CH) do { \ - if (dst >= s + maxsize) \ - goto e2big_error; \ - *dst++ = CH; \ -} while (0) - -#define PRINTS(STR) do { \ - char *tmps = STR; \ - while (*tmps != '\0') \ - PRINT(*tmps++); \ -} while (0) - -#define GET_NUMBER(VAR) do { \ - VAR = 0; \ - while (isdigit((unsigned char)*fmt)) { \ - if (VAR > INT_MAX / 10) \ - goto e2big_error; \ - VAR *= 10; \ - VAR += *fmt - '0'; \ - if (VAR < 0) \ - goto e2big_error; \ - fmt++; \ - } \ -} while (0) - -#define GRPCPY(howmany) do { \ - int i = howmany; \ - while (i-- > 0) { \ - avalue_size--; \ - *--bufend = *(avalue+avalue_size+padded); \ - } \ -} while (0) - -#define GRPSEP do { \ - *--bufend = thousands_sep; \ - groups++; \ -} while (0) - -static void __setup_vars(int, char *, char *, char *, char **); -static int __calc_left_pad(int, char *); -static char *__format_grouped_double(double, int *, int, int, int); - -ssize_t -strfmon(char * __restrict s, size_t maxsize, const char * __restrict format, - ...) -{ - va_list ap; - char *dst; /* output destination pointer */ - const char *fmt; /* current format poistion pointer */ - struct lconv *lc; /* pointer to lconv structure */ - char *asciivalue; /* formatted double pointer */ - - int flags; /* formatting options */ - int pad_char; /* padding character */ - int pad_size; /* pad size */ - int width; /* field width */ - int left_prec; /* left precision */ - int right_prec; /* right precision */ - double value; /* just value */ - char space_char = ' '; /* space after currency */ - - char cs_precedes, /* values gathered from struct lconv */ - sep_by_space, - sign_posn, - *signstr, - *currency_symbol; - - char *tmpptr; /* temporary vars */ - int sverrno; - - va_start(ap, format); - - lc = localeconv(); - dst = s; - fmt = format; - asciivalue = NULL; - currency_symbol = NULL; - pad_size = 0; - - while (*fmt) { - /* pass nonformating characters AS IS */ - if (*fmt != '%') - goto literal; - - /* '%' found ! */ - - /* "%%" mean just '%' */ - if (*(fmt+1) == '%') { - fmt++; - literal: - PRINT(*fmt++); - continue; - } - - /* set up initial values */ - flags = (NEED_GROUPING|LOCALE_POSN); - pad_char = ' '; /* padding character is "space" */ - left_prec = -1; /* no left precision specified */ - right_prec = -1; /* no right precision specified */ - width = -1; /* no width specified */ - value = 0; /* we have no value to print now */ - - /* Flags */ - while (1) { - switch (*++fmt) { - case '=': /* fill character */ - pad_char = *++fmt; - if (pad_char == '\0') - goto format_error; - continue; - case '^': /* not group currency */ - flags &= ~(NEED_GROUPING); - continue; - case '+': /* use locale defined signs */ - if (flags & SIGN_POSN_USED) - goto format_error; - flags |= (SIGN_POSN_USED|LOCALE_POSN); - continue; - case '(': /* enclose negatives with () */ - if (flags & SIGN_POSN_USED) - goto format_error; - flags |= (SIGN_POSN_USED|PARENTH_POSN); - continue; - case '!': /* suppress currency symbol */ - flags |= SUPRESS_CURR_SYMBOL; - continue; - case '-': /* alignment (left) */ - flags |= LEFT_JUSTIFY; - continue; - default: - break; - } - break; - } - - /* field Width */ - if (isdigit((unsigned char)*fmt)) { - GET_NUMBER(width); - /* Do we have enough space to put number with - * required width ? - */ - if ((unsigned int)width >= maxsize - (dst - s)) - goto e2big_error; - } - - /* Left precision */ - if (*fmt == '#') { - if (!isdigit((unsigned char)*++fmt)) - goto format_error; - GET_NUMBER(left_prec); - if ((unsigned int)left_prec >= maxsize - (dst - s)) - goto e2big_error; - } - - /* Right precision */ - if (*fmt == '.') { - if (!isdigit((unsigned char)*++fmt)) - goto format_error; - GET_NUMBER(right_prec); - if ((unsigned int)right_prec >= maxsize - (dst - s) - - left_prec) - goto e2big_error; - } - - /* Conversion Characters */ - switch (*fmt++) { - case 'i': /* use internaltion currency format */ - flags |= USE_INTL_CURRENCY; - break; - case 'n': /* use national currency format */ - flags &= ~(USE_INTL_CURRENCY); - break; - default: /* required character is missing or - premature EOS */ - goto format_error; - } - - if (currency_symbol != NULL) - free(currency_symbol); - if (flags & USE_INTL_CURRENCY) { - currency_symbol = strdup(lc->int_curr_symbol); - if (currency_symbol != NULL) { - space_char = *(currency_symbol+3); - *(currency_symbol+3) = '\0'; - } - } else - currency_symbol = strdup(lc->currency_symbol); - - if (currency_symbol == NULL) - goto end_error; /* ENOMEM. */ - - /* value itself */ - value = va_arg(ap, double); - - /* detect sign */ - if (value < 0) { - flags |= IS_NEGATIVE; - value = -value; - } - - /* fill left_prec with amount of padding chars */ - if (left_prec >= 0) { - pad_size = __calc_left_pad((flags ^ IS_NEGATIVE), - currency_symbol) - - __calc_left_pad(flags, currency_symbol); - if (pad_size < 0) - pad_size = 0; - } - - if (asciivalue != NULL) - free(asciivalue); - asciivalue = __format_grouped_double(value, &flags, - left_prec, right_prec, pad_char); - if (asciivalue == NULL) - goto end_error; /* errno already set */ - /* to ENOMEM by malloc() */ - - /* set some variables for later use */ - __setup_vars(flags, &cs_precedes, &sep_by_space, - &sign_posn, &signstr); - - /* - * Description of some LC_MONETARY's values: - * - * p_cs_precedes & n_cs_precedes - * - * = 1 - $currency_symbol precedes the value - * for a monetary quantity with a non-negative value - * = 0 - symbol succeeds the value - * - * p_sep_by_space & n_sep_by_space - * - * = 0 - no space separates $currency_symbol - * from the value for a monetary quantity with a - * non-negative value - * = 1 - space separates the symbol from the value - * = 2 - space separates the symbol and the sign string, - * if adjacent. - * - * p_sign_posn & n_sign_posn - * - * = 0 - parentheses enclose the quantity and the - * $currency_symbol - * = 1 - the sign string precedes the quantity and the - * $currency_symbol - * = 2 - the sign string succeeds the quantity and the - * $currency_symbol - * = 3 - the sign string precedes the $currency_symbol - * = 4 - the sign string succeeds the $currency_symbol - * - */ - - tmpptr = dst; - - while (pad_size-- > 0) - PRINT(' '); - - if (sign_posn == 0 && (flags & IS_NEGATIVE)) - PRINT('('); - - if (cs_precedes == 1) { - if (sign_posn == 1 || sign_posn == 3) { - PRINTS(signstr); - if (sep_by_space == 2) /* XXX: ? */ - PRINT(' '); - } - - if (!(flags & SUPRESS_CURR_SYMBOL)) { - PRINTS(currency_symbol); - - if (sign_posn == 4) { - if (sep_by_space == 2) - PRINT(space_char); - PRINTS(signstr); - if (sep_by_space == 1) - PRINT(' '); - } else if (sep_by_space == 1) - PRINT(space_char); - } - } else if (sign_posn == 1) - PRINTS(signstr); - - PRINTS(asciivalue); - - if (cs_precedes == 0) { - if (sign_posn == 3) { - if (sep_by_space == 1) - PRINT(' '); - PRINTS(signstr); - } - - if (!(flags & SUPRESS_CURR_SYMBOL)) { - if ((sign_posn == 3 && sep_by_space == 2) - || (sep_by_space == 1 - && (sign_posn == 0 - || sign_posn == 1 - || sign_posn == 2 - || sign_posn == 4))) - PRINT(space_char); - PRINTS(currency_symbol); /* XXX: len */ - if (sign_posn == 4) { - if (sep_by_space == 2) - PRINT(' '); - PRINTS(signstr); - } - } - } - - if (sign_posn == 2) { - if (sep_by_space == 2) - PRINT(' '); - PRINTS(signstr); - } - - if (sign_posn == 0 && (flags & IS_NEGATIVE)) - PRINT(')'); - - if (dst - tmpptr < width) { - if (flags & LEFT_JUSTIFY) { - while (dst - tmpptr < width) - PRINT(' '); - } else { - pad_size = dst-tmpptr; - memmove(tmpptr + width-pad_size, tmpptr, - pad_size); - memset(tmpptr, ' ', width-pad_size); - dst += width-pad_size; - } - } - } - - PRINT('\0'); - va_end(ap); - free(asciivalue); - free(currency_symbol); - return (dst - s - 1); /* return size of put data except trailing '\0' */ - -e2big_error: - errno = E2BIG; - goto end_error; - -format_error: - errno = EINVAL; - -end_error: - sverrno = errno; - if (asciivalue != NULL) - free(asciivalue); - if (currency_symbol != NULL) - free(currency_symbol); - errno = sverrno; - va_end(ap); - return (-1); -} - -static void -__setup_vars(int flags, char *cs_precedes, char *sep_by_space, - char *sign_posn, char **signstr) { - - struct lconv *lc = localeconv(); - static char negative[] = "-"; - - if ((flags & IS_NEGATIVE) && (flags & USE_INTL_CURRENCY)) { - *cs_precedes = lc->int_n_cs_precedes; - *sep_by_space = lc->int_n_sep_by_space; - *sign_posn = (flags & PARENTH_POSN) ? 0 : lc->int_n_sign_posn; - *signstr = (*lc->negative_sign == '\0') ? negative - : lc->negative_sign; - } else if (flags & USE_INTL_CURRENCY) { - *cs_precedes = lc->int_p_cs_precedes; - *sep_by_space = lc->int_p_sep_by_space; - *sign_posn = (flags & PARENTH_POSN) ? 0 : lc->int_p_sign_posn; - *signstr = lc->positive_sign; - } else if (flags & IS_NEGATIVE) { - *cs_precedes = lc->n_cs_precedes; - *sep_by_space = lc->n_sep_by_space; - *sign_posn = (flags & PARENTH_POSN) ? 0 : lc->n_sign_posn; - *signstr = (*lc->negative_sign == '\0') ? negative - : lc->negative_sign; - } else { - *cs_precedes = lc->p_cs_precedes; - *sep_by_space = lc->p_sep_by_space; - *sign_posn = (flags & PARENTH_POSN) ? 0 : lc->p_sign_posn; - *signstr = lc->positive_sign; - } - - /* Set defult values for unspecified information. */ - if (*cs_precedes != 0) - *cs_precedes = 1; - if (*sep_by_space == CHAR_MAX) - *sep_by_space = 0; - if (*sign_posn == CHAR_MAX) - *sign_posn = 0; -} - -static int -__calc_left_pad(int flags, char *cur_symb) { - - char cs_precedes, sep_by_space, sign_posn, *signstr; - int left_chars = 0; - - __setup_vars(flags, &cs_precedes, &sep_by_space, &sign_posn, &signstr); - - if (cs_precedes != 0) { - left_chars += strlen(cur_symb); - if (sep_by_space != 0) - left_chars++; - } - - switch (sign_posn) { - case 1: - left_chars += strlen(signstr); - break; - case 3: - case 4: - if (cs_precedes != 0) - left_chars += strlen(signstr); - } - return (left_chars); -} - -static int -get_groups(int size, char *grouping) { - - int chars = 0; - - if (*grouping == CHAR_MAX || *grouping <= 0) /* no grouping ? */ - return (0); - - while (size > (int)*grouping) { - chars++; - size -= (int)*grouping++; - /* no more grouping ? */ - if (*grouping == CHAR_MAX) - break; - /* rest grouping with same value ? */ - if (*grouping == 0) { - chars += (size - 1) / *(grouping - 1); - break; - } - } - return (chars); -} - -/* convert double to ASCII */ -static char * -__format_grouped_double(double value, int *flags, - int left_prec, int right_prec, int pad_char) { - - char *rslt; - char *avalue; - int avalue_size; - char fmt[32]; - - size_t bufsize; - char *bufend; - - int padded; - - struct lconv *lc = localeconv(); - char *grouping; - char decimal_point; - char thousands_sep; - - int groups = 0; - - grouping = lc->mon_grouping; - decimal_point = *lc->mon_decimal_point; - if (decimal_point == '\0') - decimal_point = *lc->decimal_point; - thousands_sep = *lc->mon_thousands_sep; - if (thousands_sep == '\0') - thousands_sep = *lc->thousands_sep; - - /* fill left_prec with default value */ - if (left_prec == -1) - left_prec = 0; - - /* fill right_prec with default value */ - if (right_prec == -1) { - if (*flags & USE_INTL_CURRENCY) - right_prec = lc->int_frac_digits; - else - right_prec = lc->frac_digits; - - if (right_prec == CHAR_MAX) /* POSIX locale ? */ - right_prec = 2; - } - - if (*flags & NEED_GROUPING) - left_prec += get_groups(left_prec, grouping); - - /* convert to string */ - snprintf(fmt, sizeof(fmt), "%%%d.%df", left_prec + right_prec + 1, - right_prec); - avalue_size = asprintf(&avalue, fmt, value); - if (avalue_size < 0) - return (NULL); - - /* make sure that we've enough space for result string */ - bufsize = strlen(avalue)*2+1; - rslt = calloc(1, bufsize); - if (rslt == NULL) { - free(avalue); - return (NULL); - } - bufend = rslt + bufsize - 1; /* reserve space for trailing '\0' */ - - /* skip spaces at beggining */ - padded = 0; - while (avalue[padded] == ' ') { - padded++; - avalue_size--; - } - - if (right_prec > 0) { - bufend -= right_prec; - memcpy(bufend, avalue + avalue_size+padded-right_prec, - right_prec); - *--bufend = decimal_point; - avalue_size -= (right_prec + 1); - } - - if ((*flags & NEED_GROUPING) && - thousands_sep != '\0' && /* XXX: need investigation */ - *grouping != CHAR_MAX && - *grouping > 0) { - while (avalue_size > (int)*grouping) { - GRPCPY(*grouping); - GRPSEP; - grouping++; - - /* no more grouping ? */ - if (*grouping == CHAR_MAX) - break; - - /* rest grouping with same value ? */ - if (*grouping == 0) { - grouping--; - while (avalue_size > *grouping) { - GRPCPY(*grouping); - GRPSEP; - } - } - } - if (avalue_size != 0) - GRPCPY(avalue_size); - padded -= groups; - - } else { - bufend -= avalue_size; - memcpy(bufend, avalue+padded, avalue_size); - if (right_prec == 0) - padded--; /* decrease assumed $decimal_point */ - } - - /* do padding with pad_char */ - if (padded > 0) { - bufend -= padded; - memset(bufend, pad_char, padded); - } - - bufsize = bufsize - (bufend - rslt) + 1; - memmove(rslt, bufend, bufsize); - free(avalue); - return (rslt); -} diff --git a/winsup/cygwin/libc/strptime.cc b/winsup/cygwin/libc/strptime.cc deleted file mode 100644 index e96de5917..000000000 --- a/winsup/cygwin/libc/strptime.cc +++ /dev/null @@ -1,388 +0,0 @@ -/* $NetBSD: strptime.c,v 1.28 2008/04/28 20:23:01 martin Exp $ */ - -/*- - * Copyright (c) 1997, 1998, 2005, 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code was contributed to The NetBSD Foundation by Klaus Klein. - * Heavily optimised by David Laight - * - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: strptime.c,v 1.28 2008/04/28 20:23:01 martin Exp $"); -#endif - -#ifdef __CYGWIN__ -#include "winsup.h" -#else -#include "namespace.h" -#include -#endif -#include -#include -#include -#include -#include -#include "../locale/timelocal.h" - -#ifdef __weak_alias -__weak_alias(strptime,_strptime) -#endif - -#define _ctloc(x) (_CurrentTimeLocale->x) - -/* - * We do not implement alternate representations. However, we always - * check whether a given modifier is allowed for a certain conversion. - */ -#define ALT_E 0x01 -#define ALT_O 0x02 -#define LEGAL_ALT(x) { if (alt_format & ~(x)) return NULL; } - -static const char gmt[4] = { "GMT" }; - -static const u_char *conv_num(const unsigned char *, int *, uint, uint); -static const u_char *find_string(const u_char *, int *, const char * const *, - const char * const *, int); - - -char * -strptime(const char *buf, const char *fmt, struct tm *tm) -{ - unsigned char c; - const unsigned char *bp; - int alt_format, i, split_year = 0; - const char *new_fmt; - - bp = (const u_char *)buf; - struct lc_time_T *_CurrentTimeLocale = __get_current_time_locale (); - - while (bp != NULL && (c = *fmt++) != '\0') { - /* Clear `alternate' modifier prior to new conversion. */ - alt_format = 0; - i = 0; - - /* Eat up white-space. */ - if (isspace(c)) { - while (isspace(*bp)) - bp++; - continue; - } - - if (c != '%') - goto literal; - - -again: switch (c = *fmt++) { - case '%': /* "%%" is converted to "%". */ -literal: - if (c != *bp++) - return NULL; - LEGAL_ALT(0); - continue; - - /* - * "Alternative" modifiers. Just set the appropriate flag - * and start over again. - */ - case 'E': /* "%E?" alternative conversion modifier. */ - LEGAL_ALT(0); - alt_format |= ALT_E; - goto again; - - case 'O': /* "%O?" alternative conversion modifier. */ - LEGAL_ALT(0); - alt_format |= ALT_O; - goto again; - - /* - * "Complex" conversion rules, implemented through recursion. - */ - case 'c': /* Date and time, using the locale's format. */ - new_fmt = _ctloc(c_fmt); - goto recurse; - - case 'D': /* The date as "%m/%d/%y". */ - new_fmt = "%m/%d/%y"; - LEGAL_ALT(0); - goto recurse; - - case 'F': /* The date as "%Y-%m-%d". */ - new_fmt = "%Y-%m-%d"; - LEGAL_ALT(0); - goto recurse; - - case 'R': /* The time as "%H:%M". */ - new_fmt = "%H:%M"; - LEGAL_ALT(0); - goto recurse; - - case 'r': /* The time in 12-hour clock representation. */ - new_fmt =_ctloc(ampm_fmt); - LEGAL_ALT(0); - goto recurse; - - case 'T': /* The time as "%H:%M:%S". */ - new_fmt = "%H:%M:%S"; - LEGAL_ALT(0); - goto recurse; - - case 'X': /* The time, using the locale's format. */ - new_fmt =_ctloc(X_fmt); - goto recurse; - - case 'x': /* The date, using the locale's format. */ - new_fmt =_ctloc(x_fmt); - recurse: - bp = (const u_char *)strptime((const char *)bp, - new_fmt, tm); - LEGAL_ALT(ALT_E); - continue; - - /* - * "Elementary" conversion rules. - */ - case 'A': /* The day of week, using the locale's form. */ - case 'a': - bp = find_string(bp, &tm->tm_wday, _ctloc(weekday), - _ctloc(wday), 7); - LEGAL_ALT(0); - continue; - - case 'B': /* The month, using the locale's form. */ - case 'b': - case 'h': - bp = find_string(bp, &tm->tm_mon, _ctloc(month), - _ctloc(mon), 12); - LEGAL_ALT(0); - continue; - - case 'C': /* The century number. */ - i = 20; - bp = conv_num(bp, &i, 0, 99); - - i = i * 100 - TM_YEAR_BASE; - if (split_year) - i += tm->tm_year % 100; - split_year = 1; - tm->tm_year = i; - LEGAL_ALT(ALT_E); - continue; - - case 'd': /* The day of month. */ - case 'e': - bp = conv_num(bp, &tm->tm_mday, 1, 31); - LEGAL_ALT(ALT_O); - continue; - - case 'k': /* The hour (24-hour clock representation). */ - LEGAL_ALT(0); - /* FALLTHROUGH */ - case 'H': - bp = conv_num(bp, &tm->tm_hour, 0, 23); - LEGAL_ALT(ALT_O); - continue; - - case 'l': /* The hour (12-hour clock representation). */ - LEGAL_ALT(0); - /* FALLTHROUGH */ - case 'I': - bp = conv_num(bp, &tm->tm_hour, 1, 12); - if (tm->tm_hour == 12) - tm->tm_hour = 0; - LEGAL_ALT(ALT_O); - continue; - - case 'j': /* The day of year. */ - i = 1; - bp = conv_num(bp, &i, 1, 366); - tm->tm_yday = i - 1; - LEGAL_ALT(0); - continue; - - case 'M': /* The minute. */ - bp = conv_num(bp, &tm->tm_min, 0, 59); - LEGAL_ALT(ALT_O); - continue; - - case 'm': /* The month. */ - i = 1; - bp = conv_num(bp, &i, 1, 12); - tm->tm_mon = i - 1; - LEGAL_ALT(ALT_O); - continue; - - case 'p': /* The locale's equivalent of AM/PM. */ - bp = find_string(bp, &i, _ctloc(am_pm), NULL, 2); - if (tm->tm_hour > 11) - return NULL; - tm->tm_hour += i * 12; - LEGAL_ALT(0); - continue; - - case 'S': /* The seconds. */ - bp = conv_num(bp, &tm->tm_sec, 0, 61); - LEGAL_ALT(ALT_O); - continue; - - case 'U': /* The week of year, beginning on sunday. */ - case 'W': /* The week of year, beginning on monday. */ - /* - * XXX This is bogus, as we can not assume any valid - * information present in the tm structure at this - * point to calculate a real value, so just check the - * range for now. - */ - bp = conv_num(bp, &i, 0, 53); - LEGAL_ALT(ALT_O); - continue; - - case 'w': /* The day of week, beginning on sunday. */ - bp = conv_num(bp, &tm->tm_wday, 0, 6); - LEGAL_ALT(ALT_O); - continue; - - case 'Y': /* The year. */ - i = TM_YEAR_BASE; /* just for data sanity... */ - bp = conv_num(bp, &i, 0, 9999); - tm->tm_year = i - TM_YEAR_BASE; - LEGAL_ALT(ALT_E); - continue; - - case 'y': /* The year within 100 years of the epoch. */ - /* LEGAL_ALT(ALT_E | ALT_O); */ - bp = conv_num(bp, &i, 0, 99); - - if (split_year) - /* preserve century */ - i += (tm->tm_year / 100) * 100; - else { - split_year = 1; - if (i <= 68) - i = i + 2000 - TM_YEAR_BASE; - else - i = i + 1900 - TM_YEAR_BASE; - } - tm->tm_year = i; - continue; - - case 'Z': - tzset(); - if (strncmp((const char *)bp, gmt, 3) == 0) { - tm->tm_isdst = 0; -#ifdef TM_GMTOFF - tm->TM_GMTOFF = 0; -#endif -#ifdef TM_ZONE - tm->TM_ZONE = gmt; -#endif - bp += 3; - } else { - const unsigned char *ep; - - ep = find_string(bp, &i, - (const char * const *)tzname, - NULL, 2); - if (ep != NULL) { - tm->tm_isdst = i; -#ifdef TM_GMTOFF - tm->TM_GMTOFF = -(timezone); -#endif -#ifdef TM_ZONE - tm->TM_ZONE = tzname[i]; -#endif - } - bp = ep; - } - continue; - - /* - * Miscellaneous conversions. - */ - case 'n': /* Any kind of white-space. */ - case 't': - while (isspace(*bp)) - bp++; - LEGAL_ALT(0); - continue; - - - default: /* Unknown/unsupported conversion. */ - return NULL; - } - } - - return (char *) bp; -} - - -static const u_char * -conv_num(const unsigned char *buf, int *dest, uint llim, uint ulim) -{ - uint result = 0; - unsigned char ch; - - /* The limit also determines the number of valid digits. */ - uint rulim = ulim; - - ch = *buf; - if (ch < '0' || ch > '9') - return NULL; - - do { - result *= 10; - result += ch - '0'; - rulim /= 10; - ch = *++buf; - } while ((result * 10 <= ulim) && rulim && ch >= '0' && ch <= '9'); - - if (result < llim || result > ulim) - return NULL; - - *dest = result; - return buf; -} - -static const u_char * -find_string(const u_char *bp, int *tgt, const char * const *n1, - const char * const *n2, int c) -{ - int i; - unsigned int len; - - /* check full name - then abbreviated ones */ - for (; n1 != NULL; n1 = n2, n2 = NULL) { - for (i = 0; i < c; i++, n1++) { - len = strlen(*n1); - if (strncasecmp(*n1, (const char *)bp, len) == 0) { - *tgt = i; - return bp + len; - } - } - } - - /* Nothing matched */ - return NULL; -} diff --git a/winsup/cygwin/libc/xsique.cc b/winsup/cygwin/libc/xsique.cc deleted file mode 100644 index 9e2f76e74..000000000 --- a/winsup/cygwin/libc/xsique.cc +++ /dev/null @@ -1,48 +0,0 @@ -/* xsique.cc. XSI insque and remque functions. - - Copyright 2007 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include - -extern "C" void -insque (void *velement, void *vpred) -{ - if (!velement) - return; - - struct qelem *element = (struct qelem *) velement; - struct qelem *pred = (struct qelem *) vpred; - struct qelem *succ; - - if (pred) - { - if ((succ = element->q_forw = pred->q_forw)) - succ->q_back = element; - pred->q_forw = element; - } - else - element->q_forw = NULL; - element->q_back = pred; -} - -extern "C" void -remque (void *velement) -{ - if (!velement) - return; - - struct qelem *pred = ((struct qelem *) velement)->q_back; - struct qelem *succ = ((struct qelem *) velement)->q_forw; - - if (succ) - succ->q_back = pred; - if (pred) - pred->q_forw = succ; -} - diff --git a/winsup/cygwin/libstdcxx_wrapper.cc b/winsup/cygwin/libstdcxx_wrapper.cc deleted file mode 100755 index a6492f243..000000000 --- a/winsup/cygwin/libstdcxx_wrapper.cc +++ /dev/null @@ -1,90 +0,0 @@ -/* libstdcxx_wrapper.cc - - Copyright 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - - -/* We provide these stubs to call into a user's - provided ONDEE replacement if there is one - otherwise - it must fall back to the standard libstdc++ version. */ - -#include "winsup.h" -#include "cygwin-cxx.h" -#include "perprocess.h" - -/* We are declaring asm names for the functions we define here, as we want - to define the wrappers in this file. GCC links everything with wrappers - around the standard C++ memory management operators; these are the wrappers, - but we want the compiler to know they are the malloc operators and not have - it think they're just any old function matching 'extern "C" _wrap_*'. */ - -extern void *operator new(std::size_t sz) throw (std::bad_alloc) - __asm__ ("___wrap__Znwj"); -extern void *operator new[](std::size_t sz) throw (std::bad_alloc) - __asm__ ("___wrap__Znaj"); -extern void operator delete(void *p) throw() - __asm__ ("___wrap__ZdlPv"); -extern void operator delete[](void *p) throw() - __asm__ ("___wrap__ZdaPv"); -extern void *operator new(std::size_t sz, const std::nothrow_t &nt) throw() - __asm__ ("___wrap__ZnwjRKSt9nothrow_t"); -extern void *operator new[](std::size_t sz, const std::nothrow_t &nt) throw() - __asm__ ("___wrap__ZnajRKSt9nothrow_t"); -extern void operator delete(void *p, const std::nothrow_t &nt) throw() - __asm__ ("___wrap__ZdlPvRKSt9nothrow_t"); -extern void operator delete[](void *p, const std::nothrow_t &nt) throw() - __asm__ ("___wrap__ZdaPvRKSt9nothrow_t"); - -extern void * -operator new(std::size_t sz) throw (std::bad_alloc) -{ - return (*user_data->cxx_malloc->oper_new) (sz); -} - -extern void * -operator new[](std::size_t sz) throw (std::bad_alloc) -{ - return (*user_data->cxx_malloc->oper_new__) (sz); -} - -extern void -operator delete(void *p) throw() -{ - (*user_data->cxx_malloc->oper_delete) (p); -} - -extern void -operator delete[](void *p) throw() -{ - (*user_data->cxx_malloc->oper_delete__) (p); -} - -extern void * -operator new(std::size_t sz, const std::nothrow_t &nt) throw() -{ - return (*user_data->cxx_malloc->oper_new_nt) (sz, nt); -} - -extern void * -operator new[](std::size_t sz, const std::nothrow_t &nt) throw() -{ - return (*user_data->cxx_malloc->oper_new___nt) (sz, nt); -} - -extern void -operator delete(void *p, const std::nothrow_t &nt) throw() -{ - (*user_data->cxx_malloc->oper_delete_nt) (p, nt); -} - -extern void -operator delete[](void *p, const std::nothrow_t &nt) throw() -{ - (*user_data->cxx_malloc->oper_delete___nt) (p, nt); -} - diff --git a/winsup/cygwin/localtime.cc b/winsup/cygwin/localtime.cc deleted file mode 100644 index c6615bd2a..000000000 --- a/winsup/cygwin/localtime.cc +++ /dev/null @@ -1,2198 +0,0 @@ -/* -** This file is in the public domain, so clarified as of -** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). -*/ -/* Temporarily merged private.h and tzfile.h for ease of management - DJ */ - -#include "winsup.h" -#include "cygerrno.h" -#include "sync.h" -#define STD_INSPIRED -#define lint - -#define USG_COMPAT - -#ifndef lint -#ifndef NOID -static char elsieid[] = "@(#)localtime.c 7.66"; -#endif /* !defined NOID */ -#endif /* !defined lint */ - -/* -** Leap second handling from Bradley White (bww@k.gp.cs.cmu.edu). -** POSIX-style TZ environment variable handling from Guy Harris -** (guy@auspex.com). -*/ - -/*LINTLIBRARY*/ - -#ifndef PRIVATE_H - -#define PRIVATE_H - -/* -** This file is in the public domain, so clarified as of -** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). -*/ - -/* -** This header is for use ONLY with the time conversion code. -** There is no guarantee that it will remain unchanged, -** or that it will remain at all. -** Do NOT copy it to any system include directory. -** Thank you! -*/ - -/* -** ID -*/ - -#ifndef lint -#ifndef NOID -static char privatehid[] = "@(#)private.h 7.48"; -#endif /* !defined NOID */ -#endif /* !defined lint */ - -/* -** Defaults for preprocessor symbols. -** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'. -*/ - -#ifndef HAVE_ADJTIME -#define HAVE_ADJTIME 1 -#endif /* !defined HAVE_ADJTIME */ - -#ifndef HAVE_GETTEXT -#define HAVE_GETTEXT 0 -#endif /* !defined HAVE_GETTEXT */ - -#ifndef HAVE_SETTIMEOFDAY -#define HAVE_SETTIMEOFDAY 3 -#endif /* !defined HAVE_SETTIMEOFDAY */ - -#ifndef HAVE_STRERROR -#define HAVE_STRERROR 0 -#endif /* !defined HAVE_STRERROR */ - -#ifndef HAVE_SYMLINK -#define HAVE_SYMLINK 1 -#endif /* !defined HAVE_SYMLINK */ - -#ifndef HAVE_UNISTD_H -#define HAVE_UNISTD_H 1 -#endif /* !defined HAVE_UNISTD_H */ - -#ifndef HAVE_UTMPX_H -#define HAVE_UTMPX_H 0 -#endif /* !defined HAVE_UTMPX_H */ - -#ifndef LOCALE_HOME -#define LOCALE_HOME "/usr/lib/locale" -#endif /* !defined LOCALE_HOME */ - -/* -** Nested includes -*/ - -#include "stdio.h" -#include "limits.h" /* for CHAR_BIT */ -#include "stdlib.h" - -#if HAVE_GETTEXT - 0 -#endif /* HAVE_GETTEXT - 0 */ - -#if HAVE_UNISTD_H - 0 -#include "unistd.h" /* for F_OK and R_OK */ -#endif /* HAVE_UNISTD_H - 0 */ - -#if !(HAVE_UNISTD_H - 0) -#ifndef F_OK -#define F_OK 0 -#endif /* !defined F_OK */ -#ifndef R_OK -#define R_OK 4 -#endif /* !defined R_OK */ -#endif /* !(HAVE_UNISTD_H - 0) */ - -/* Unlike 's isdigit, this also works if c < 0 | c > UCHAR_MAX. */ -#define is_digit(c) ((unsigned)(c) - '0' <= 9) - -/* -** Workarounds for compilers/systems. -*/ - -/* -** SunOS 4.1.1 cc lacks const. -*/ - -#ifndef const -#ifndef __STDC__ -#define const -#endif /* !defined __STDC__ */ -#endif /* !defined const */ - -/* -** SunOS 4.1.1 cc lacks prototypes. -*/ - -#ifndef P -#ifdef __STDC__ -#define P(x) x -#endif /* defined __STDC__ */ -#ifndef __STDC__ -#define P(x) () -#endif /* !defined __STDC__ */ -#endif /* !defined P */ - -/* -** SunOS 4.1.1 headers lack EXIT_SUCCESS. -*/ - -#ifndef EXIT_SUCCESS -#define EXIT_SUCCESS 0 -#endif /* !defined EXIT_SUCCESS */ - -/* -** SunOS 4.1.1 headers lack EXIT_FAILURE. -*/ - -#ifndef EXIT_FAILURE -#define EXIT_FAILURE 1 -#endif /* !defined EXIT_FAILURE */ - -/* -** SunOS 4.1.1 headers lack FILENAME_MAX. -*/ - -#ifndef FILENAME_MAX - -#ifndef MAXPATHLEN -#ifdef unix -#endif /* defined unix */ -#endif /* !defined MAXPATHLEN */ - -#ifdef MAXPATHLEN -#define FILENAME_MAX MAXPATHLEN -#endif /* defined MAXPATHLEN */ -#ifndef MAXPATHLEN -#define FILENAME_MAX 1024 /* Pure guesswork */ -#endif /* !defined MAXPATHLEN */ - -#endif /* !defined FILENAME_MAX */ - -/* -** SunOS 4.1.1 libraries lack remove. -*/ - -#ifndef remove -extern int unlink P((const char * filename)); -#define remove unlink -#endif /* !defined remove */ - -/* -** Finally, some convenience items. -*/ - -#ifndef TYPE_BIT -#define TYPE_BIT(type) (sizeof (type) * CHAR_BIT) -#endif /* !defined TYPE_BIT */ - -#ifndef TYPE_SIGNED -#define TYPE_SIGNED(type) (((type) -1) < 0) -#endif /* !defined TYPE_SIGNED */ - -#ifndef INT_STRLEN_MAXIMUM -/* -** 302 / 1000 is log10(2.0) rounded up. -** Subtract one for the sign bit if the type is signed; -** add one for integer division truncation; -** add one more for a minus sign if the type is signed. -*/ -#define INT_STRLEN_MAXIMUM(type) \ - ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type)) -#endif /* !defined INT_STRLEN_MAXIMUM */ - -/* -** INITIALIZE(x) -*/ - -#ifndef GNUC_or_lint -#ifdef lint -#define GNUC_or_lint -#endif /* defined lint */ -#ifndef lint -#ifdef __GNUC__ -#define GNUC_or_lint -#endif /* defined __GNUC__ */ -#endif /* !defined lint */ -#endif /* !defined GNUC_or_lint */ - -#ifndef INITIALIZE -#ifdef GNUC_or_lint -#define INITIALIZE(x) ((x) = 0) -#endif /* defined GNUC_or_lint */ -#ifndef GNUC_or_lint -#define INITIALIZE(x) -#endif /* !defined GNUC_or_lint */ -#endif /* !defined INITIALIZE */ - -/* -** For the benefit of GNU folk... -** `_(MSGID)' uses the current locale's message library string for MSGID. -** The default is to use gettext if available, and use MSGID otherwise. -*/ - -#ifndef _ -#if HAVE_GETTEXT - 0 -#define _(msgid) gettext(msgid) -#else /* !(HAVE_GETTEXT - 0) */ -#define _(msgid) msgid -#endif /* !(HAVE_GETTEXT - 0) */ -#endif /* !defined _ */ - -#ifndef TZ_DOMAIN -#define TZ_DOMAIN "tz" -#endif /* !defined TZ_DOMAIN */ - -/* -** UNIX was a registered trademark of UNIX System Laboratories in 1993. -*/ - -#endif /* !defined PRIVATE_H */ - -#ifndef TZFILE_H - -#define TZFILE_H - -/* -** This file is in the public domain, so clarified as of -** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). -*/ - -/* -** This header is for use ONLY with the time conversion code. -** There is no guarantee that it will remain unchanged, -** or that it will remain at all. -** Do NOT copy it to any system include directory. -** Thank you! -*/ - -/* -** ID -*/ - -#ifndef lint -#ifndef NOID -static char tzfilehid[] = "@(#)tzfile.h 7.14"; -#endif /* !defined NOID */ -#endif /* !defined lint */ - -/* -** Information about time zone files. -*/ - -#ifndef TZDIR -#define TZDIR "/usr/share/zoneinfo" /* Time zone object file directory */ -#endif /* !defined TZDIR */ - -#ifndef TZDEFAULT -#define TZDEFAULT "localtime" -#endif /* !defined TZDEFAULT */ - -#ifndef TZDEFRULES -#define TZDEFRULES "posixrules" -#endif /* !defined TZDEFRULES */ - -/* -** Each file begins with. . . -*/ - -#define TZ_MAGIC "TZif" - -struct tzhead { - char tzh_magic[4]; /* TZ_MAGIC */ - char tzh_reserved[16]; /* reserved for future use */ - char tzh_ttisgmtcnt[4]; /* coded number of trans. time flags */ - char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ - char tzh_leapcnt[4]; /* coded number of leap seconds */ - char tzh_timecnt[4]; /* coded number of transition times */ - char tzh_typecnt[4]; /* coded number of local time types */ - char tzh_charcnt[4]; /* coded number of abbr. chars */ -}; - -/* -** . . .followed by. . . -** -** tzh_timecnt (char [4])s coded transition times a la time(2) -** tzh_timecnt (unsigned char)s types of local time starting at above -** tzh_typecnt repetitions of -** one (char [4]) coded UTC offset in seconds -** one (unsigned char) used to set tm_isdst -** one (unsigned char) that's an abbreviation list index -** tzh_charcnt (char)s '\0'-terminated zone abbreviations -** tzh_leapcnt repetitions of -** one (char [4]) coded leap second transition times -** one (char [4]) total correction after above -** tzh_ttisstdcnt (char)s indexed by type; if true, transition -** time is standard time, if false, -** transition time is wall clock time -** if absent, transition times are -** assumed to be wall clock time -** tzh_ttisgmtcnt (char)s indexed by type; if true, transition -** time is UTC, if false, -** transition time is local time -** if absent, transition times are -** assumed to be local time -*/ - -/* -** In the current implementation, "tzset()" refuses to deal with files that -** exceed any of the limits below. -*/ - -#ifndef TZ_MAX_TIMES -/* -** The TZ_MAX_TIMES value below is enough to handle a bit more than a -** year's worth of solar time (corrected daily to the nearest second) or -** 138 years of Pacific Presidential Election time -** (where there are three time zone transitions every fourth year). -*/ -#define TZ_MAX_TIMES 370 -#endif /* !defined TZ_MAX_TIMES */ - -#ifndef TZ_MAX_TYPES -#ifndef NOSOLAR -#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ -#endif /* !defined NOSOLAR */ -#ifdef NOSOLAR -/* -** Must be at least 14 for Europe/Riga as of Jan 12 1995, -** as noted by Earl Chew . -*/ -#define TZ_MAX_TYPES 20 /* Maximum number of local time types */ -#endif /* !defined NOSOLAR */ -#endif /* !defined TZ_MAX_TYPES */ - -#ifndef TZ_MAX_CHARS -#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ - /* (limited by what unsigned chars can hold) */ -#endif /* !defined TZ_MAX_CHARS */ - -#ifndef TZ_MAX_LEAPS -#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ -#endif /* !defined TZ_MAX_LEAPS */ - -#define SECSPERMIN 60 -#define MINSPERHOUR 60 -#define HOURSPERDAY 24 -#define DAYSPERWEEK 7 -#define DAYSPERNYEAR 365 -#define DAYSPERLYEAR 366 -#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) -#define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY) -#define MONSPERYEAR 12 - -#define TM_SUNDAY 0 -#define TM_MONDAY 1 -#define TM_TUESDAY 2 -#define TM_WEDNESDAY 3 -#define TM_THURSDAY 4 -#define TM_FRIDAY 5 -#define TM_SATURDAY 6 - -#define TM_JANUARY 0 -#define TM_FEBRUARY 1 -#define TM_MARCH 2 -#define TM_APRIL 3 -#define TM_MAY 4 -#define TM_JUNE 5 -#define TM_JULY 6 -#define TM_AUGUST 7 -#define TM_SEPTEMBER 8 -#define TM_OCTOBER 9 -#define TM_NOVEMBER 10 -#define TM_DECEMBER 11 - -#define TM_YEAR_BASE 1900 - -#define EPOCH_YEAR 1970 -#define EPOCH_WDAY TM_THURSDAY - -/* -** Accurate only for the past couple of centuries; -** that will probably do. -*/ - -#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) - -#ifndef USG - -/* -** Use of the underscored variants may cause problems if you move your code to -** certain System-V-based systems; for maximum portability, use the -** underscore-free variants. The underscored variants are provided for -** backward compatibility only; they may disappear from future versions of -** this file. -*/ - -#define SECS_PER_MIN SECSPERMIN -#define MINS_PER_HOUR MINSPERHOUR -#define HOURS_PER_DAY HOURSPERDAY -#define DAYS_PER_WEEK DAYSPERWEEK -#define DAYS_PER_NYEAR DAYSPERNYEAR -#define DAYS_PER_LYEAR DAYSPERLYEAR -#define SECS_PER_HOUR SECSPERHOUR -#define SECS_PER_DAY SECSPERDAY -#define MONS_PER_YEAR MONSPERYEAR - -#endif /* !defined USG */ - -#endif /* !defined TZFILE_H */ - -#include "fcntl.h" - -/* -** SunOS 4.1.1 headers lack O_BINARY. -*/ - -#ifdef O_BINARY -#define OPEN_MODE (O_RDONLY | O_BINARY) -#endif /* defined O_BINARY */ -#ifndef O_BINARY -#define OPEN_MODE O_RDONLY -#endif /* !defined O_BINARY */ - -#ifndef WILDABBR -/* -** Someone might make incorrect use of a time zone abbreviation: -** 1. They might reference tzname[0] before calling tzset (explicitly -** or implicitly). -** 2. They might reference tzname[1] before calling tzset (explicitly -** or implicitly). -** 3. They might reference tzname[1] after setting to a time zone -** in which Daylight Saving Time is never observed. -** 4. They might reference tzname[0] after setting to a time zone -** in which Standard Time is never observed. -** 5. They might reference tm.TM_ZONE after calling offtime. -** What's best to do in the above cases is open to debate; -** for now, we just set things up so that in any of the five cases -** WILDABBR is used. Another possibility: initialize tzname[0] to the -** string "tzname[0] used before set", and similarly for the other cases. -** And another: initialize tzname[0] to "ERA", with an explanation in the -** manual page of what this "time zone abbreviation" means (doing this so -** that tzname[0] has the "normal" length of three characters). -*/ -#define WILDABBR " " -#endif /* !defined WILDABBR */ - -static char wildabbr[] NO_COPY = WILDABBR; - -static char gmt[] NO_COPY = "GMT"; - -struct ttinfo { /* time type information */ - long tt_gmtoff; /* UTC offset in seconds */ - int tt_isdst; /* used to set tm_isdst */ - int tt_abbrind; /* abbreviation list index */ - int tt_ttisstd; /* true if transition is std time */ - int tt_ttisgmt; /* true if transition is UTC */ -}; - -struct lsinfo { /* leap second information */ - time_t ls_trans; /* transition time */ - long ls_corr; /* correction to apply */ -}; - -#define BIGGEST(a, b) (((a) > (b)) ? (a) : (b)) - -#ifdef TZNAME_MAX -#define MY_TZNAME_MAX TZNAME_MAX -#endif /* defined TZNAME_MAX */ -#ifndef TZNAME_MAX -#define MY_TZNAME_MAX 255 -#endif /* !defined TZNAME_MAX */ - -struct state { - int leapcnt; - int timecnt; - int typecnt; - int charcnt; - time_t ats[TZ_MAX_TIMES]; - unsigned char types[TZ_MAX_TIMES]; - struct ttinfo ttis[TZ_MAX_TYPES]; - char chars[BIGGEST(BIGGEST(TZ_MAX_CHARS + 1, sizeof gmt), - (2 * (MY_TZNAME_MAX + 1)))]; - struct lsinfo lsis[TZ_MAX_LEAPS]; -}; - -struct rule { - int r_type; /* type of rule--see below */ - int r_day; /* day number of rule */ - int r_week; /* week number of rule */ - int r_mon; /* month number of rule */ - long r_time; /* transition time of rule */ -}; - -#define JULIAN_DAY 0 /* Jn - Julian day */ -#define DAY_OF_YEAR 1 /* n - day of year */ -#define MONTH_NTH_DAY_OF_WEEK 2 /* Mm.n.d - month, week, day of week */ - -/* -** Prototypes for static functions. -*/ - -static long detzcode P((const char * codep)); -static const char * getzname P((const char * strp)); -static const char * getnum P((const char * strp, int * nump, int min, - int max)); -static const char * getsecs P((const char * strp, long * secsp)); -static const char * getoffset P((const char * strp, long * offsetp)); -static const char * getrule P((const char * strp, struct rule * rulep)); -static void gmtload P((struct state * sp)); -static void gmtsub P((const time_t * timep, long offset, - struct tm * tmp)); -static void localsub P((const time_t * timep, long offset, - struct tm * tmp)); -static int increment_overflow P((int * number, int delta)); -static int normalize_overflow P((int * tensptr, int * unitsptr, - int base)); -static void settzname P((void)); -static time_t time1 P((struct tm * tmp, - void(*funcp) P((const time_t *, - long, struct tm *)), - long offset)); -static time_t time2 P((struct tm *tmp, - void(*funcp) P((const time_t *, - long, struct tm*)), - long offset, int * okayp)); -static time_t time2sub P((struct tm *tmp, - void(*funcp) P((const time_t *, - long, struct tm*)), - long offset, int * okayp, int do_norm_secs)); -static void timesub P((const time_t * timep, long offset, - const struct state * sp, struct tm * tmp)); -static int tmcomp P((const struct tm * atmp, - const struct tm * btmp)); -static time_t transtime P((time_t janfirst, int year, - const struct rule * rulep, long offset)); -static int tzload P((const char * name, struct state * sp)); -static int tzparse P((const char * name, struct state * sp, - int lastditch)); - -#ifdef ALL_STATE -static struct state * lclptr; -static struct state * gmtptr; -#endif /* defined ALL_STATE */ - -#ifndef ALL_STATE -static struct state lclmem; -static struct state gmtmem; -#define lclptr (&lclmem) -#define gmtptr (&gmtmem) -#endif /* State Farm */ - -#ifndef TZ_STRLEN_MAX -#define TZ_STRLEN_MAX 255 -#endif /* !defined TZ_STRLEN_MAX */ - -static char lcl_TZname[TZ_STRLEN_MAX + 1]; -static int lcl_is_set; -static int gmt_is_set; - -#define tzname _tzname -#undef _tzname - -char * tzname[2] = { - wildabbr, - wildabbr -}; - -/* -** Section 4.12.3 of X3.159-1989 requires that -** Except for the strftime function, these functions [asctime, -** ctime, gmtime, localtime] return values in one of two static -** objects: a broken-down time structure and an array of char. -** Thanks to Paul Eggert (eggert@twinsun.com) for noting this. -*/ - -static struct tm tm; - - -/* These variables are initialized by tzset. The macro versions are - defined in time.h, and indirect through the __imp_ pointers. */ - -#define timezone _timezone -#define daylight _daylight -#undef _timezone -#undef _daylight - -#ifdef USG_COMPAT -long timezone; /* was time_t but POSIX requires long. */ -int daylight; -#endif /* defined USG_COMPAT */ - -#ifdef ALTZONE -time_t altzone; -#endif /* defined ALTZONE */ - -static long -detzcode(const char *codep) -{ - register long result; - register int i; - - result = (codep[0] & 0x80) ? ~0L : 0L; - for (i = 0; i < 4; ++i) - result = (result << 8) | (codep[i] & 0xff); - return result; -} - -static void -settzname P((void)) -{ - register struct state * const sp = lclptr; - register int i; - - tzname[0] = wildabbr; - tzname[1] = wildabbr; -#ifdef USG_COMPAT - daylight = 0; - timezone = 0; -#endif /* defined USG_COMPAT */ -#ifdef ALTZONE - altzone = 0; -#endif /* defined ALTZONE */ -#ifdef ALL_STATE - if (sp == NULL) { - tzname[0] = tzname[1] = gmt; - return; - } -#endif /* defined ALL_STATE */ - for (i = 0; i < sp->typecnt; ++i) { - register const struct ttinfo * const ttisp = &sp->ttis[i]; - - tzname[ttisp->tt_isdst] = - &sp->chars[ttisp->tt_abbrind]; -#ifdef USG_COMPAT - if (ttisp->tt_isdst) - daylight = 1; - if (i == 0 || !ttisp->tt_isdst) - timezone = -(ttisp->tt_gmtoff); -#endif /* defined USG_COMPAT */ -#ifdef ALTZONE - if (i == 0 || ttisp->tt_isdst) - altzone = -(ttisp->tt_gmtoff); -#endif /* defined ALTZONE */ - } - /* - ** And to get the latest zone names into tzname. . . - */ - for (i = 0; i < sp->timecnt; ++i) { - register const struct ttinfo * const ttisp = - &sp->ttis[ - sp->types[i]]; - - tzname[ttisp->tt_isdst] = - &sp->chars[ttisp->tt_abbrind]; - } -} - -#include "tz_posixrules.h" - -static int -tzload(const char *name, struct state *sp) -{ - register const char * p; - register int i; - register int fid; - save_errno save; - - if (name == NULL && (name = TZDEFAULT) == NULL) - return -1; - { - register int doaccess; - /* - ** Section 4.9.1 of the C standard says that - ** "FILENAME_MAX expands to an integral constant expression - ** that is the size needed for an array of char large enough - ** to hold the longest file name string that the implementation - ** guarantees can be opened." - */ - char fullname[FILENAME_MAX + 1]; - - if (name[0] == ':') - ++name; - doaccess = name[0] == '/'; - if (!doaccess) { - if ((p = TZDIR) == NULL) - return -1; - if ((strlen(p) + strlen(name) + 1) >= sizeof fullname) - return -1; - strcpy(fullname, p); - strcat(fullname, "/"); - strcat(fullname, name); - /* - ** Set doaccess if '.' (as in "../") shows up in name. - */ - if (strchr(name, '.') != NULL) - doaccess = true; - name = fullname; - } -#if 0 - if (doaccess && access(name, R_OK) != 0) - return -1; -#endif - if ((fid = open(name, OPEN_MODE)) == -1) - { - const char *base = strrchr(name, '/'); - if (base) - base++; - else - base = name; - if (strcmp(base, "posixrules")) - return -1; - - /* We've got a built-in copy of posixrules just in case */ - fid = -2; - } - } - { - struct tzhead * tzhp; - union { - struct tzhead tzhead; - char buf[sizeof *sp + sizeof *tzhp]; - } u; - int ttisstdcnt; - int ttisgmtcnt; - - if (fid == -2) - { - memcpy(u.buf, _posixrules_data, sizeof (_posixrules_data)); - i = sizeof (_posixrules_data); - } - else - { - i = read(fid, u.buf, sizeof u.buf); - if (close(fid) != 0) - return -1; - } - ttisstdcnt = (int) detzcode(u.tzhead.tzh_ttisgmtcnt); - ttisgmtcnt = (int) detzcode(u.tzhead.tzh_ttisstdcnt); - sp->leapcnt = (int) detzcode(u.tzhead.tzh_leapcnt); - sp->timecnt = (int) detzcode(u.tzhead.tzh_timecnt); - sp->typecnt = (int) detzcode(u.tzhead.tzh_typecnt); - sp->charcnt = (int) detzcode(u.tzhead.tzh_charcnt); - p = u.tzhead.tzh_charcnt + sizeof u.tzhead.tzh_charcnt; - if (sp->leapcnt < 0 || sp->leapcnt > TZ_MAX_LEAPS || - sp->typecnt <= 0 || sp->typecnt > TZ_MAX_TYPES || - sp->timecnt < 0 || sp->timecnt > TZ_MAX_TIMES || - sp->charcnt < 0 || sp->charcnt > TZ_MAX_CHARS || - (ttisstdcnt != sp->typecnt && ttisstdcnt != 0) || - (ttisgmtcnt != sp->typecnt && ttisgmtcnt != 0)) - return -1; - if (i - (p - u.buf) < sp->timecnt * 4 + /* ats */ - sp->timecnt + /* types */ - sp->typecnt * (4 + 2) + /* ttinfos */ - sp->charcnt + /* chars */ - sp->leapcnt * (4 + 4) + /* lsinfos */ - ttisstdcnt + /* ttisstds */ - ttisgmtcnt) /* ttisgmts */ - return -1; - for (i = 0; i < sp->timecnt; ++i) { - sp->ats[i] = detzcode(p); - p += 4; - } - for (i = 0; i < sp->timecnt; ++i) { - sp->types[i] = (unsigned char) *p++; - if (sp->types[i] >= sp->typecnt) - return -1; - } - for (i = 0; i < sp->typecnt; ++i) { - register struct ttinfo * ttisp; - - ttisp = &sp->ttis[i]; - ttisp->tt_gmtoff = detzcode(p); - p += 4; - ttisp->tt_isdst = (unsigned char) *p++; - if (ttisp->tt_isdst != 0 && ttisp->tt_isdst != 1) - return -1; - ttisp->tt_abbrind = (unsigned char) *p++; - if (ttisp->tt_abbrind < 0 || - ttisp->tt_abbrind > sp->charcnt) - return -1; - } - for (i = 0; i < sp->charcnt; ++i) - sp->chars[i] = *p++; - sp->chars[i] = '\0'; /* ensure '\0' at end */ - for (i = 0; i < sp->leapcnt; ++i) { - register struct lsinfo * lsisp; - - lsisp = &sp->lsis[i]; - lsisp->ls_trans = detzcode(p); - p += 4; - lsisp->ls_corr = detzcode(p); - p += 4; - } - for (i = 0; i < sp->typecnt; ++i) { - register struct ttinfo * ttisp; - - ttisp = &sp->ttis[i]; - if (ttisstdcnt == 0) - ttisp->tt_ttisstd = false; - else { - ttisp->tt_ttisstd = *p++; - if (ttisp->tt_ttisstd != true && - ttisp->tt_ttisstd != false) - return -1; - } - } - for (i = 0; i < sp->typecnt; ++i) { - register struct ttinfo * ttisp; - - ttisp = &sp->ttis[i]; - if (ttisgmtcnt == 0) - ttisp->tt_ttisgmt = false; - else { - ttisp->tt_ttisgmt = *p++; - if (ttisp->tt_ttisgmt != true && - ttisp->tt_ttisgmt != false) - return -1; - } - } - } - __gettzinfo ()->__tzrule[0].offset - = -sp->ttis[1].tt_gmtoff; - __gettzinfo ()->__tzrule[1].offset - = -sp->ttis[0].tt_gmtoff; - return 0; -} - -static const int mon_lengths[2][MONSPERYEAR] = { - { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, - { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } -}; - -static const int year_lengths[2] = { - DAYSPERNYEAR, DAYSPERLYEAR -}; - -/* -** Given a pointer into a time zone string, scan until a character that is not -** a valid character in a zone name is found. Return a pointer to that -** character. -*/ - -static const char * -getzname(const char *strp) -{ - register char c; - - while ((c = *strp) != '\0' && !is_digit(c) && c != ',' && c != '-' && - c != '+') - ++strp; - return strp; -} - -/* -** Given a pointer into a time zone string, extract a number from that string. -** Check that the number is within a specified range; if it is not, return -** NULL. -** Otherwise, return a pointer to the first character not part of the number. -*/ - -static const char * -getnum(const char *strp, int *nump, const int min, const int max) -{ - register char c; - register int num; - - if (strp == NULL || !is_digit(c = *strp)) - return NULL; - num = 0; - do { - num = num * 10 + (c - '0'); - if (num > max) - return NULL; /* illegal value */ - c = *++strp; - } while (is_digit(c)); - if (num < min) - return NULL; /* illegal value */ - *nump = num; - return strp; -} - -/* -** Given a pointer into a time zone string, extract a number of seconds, -** in hh[:mm[:ss]] form, from the string. -** If any error occurs, return NULL. -** Otherwise, return a pointer to the first character not part of the number -** of seconds. -*/ - -static const char * -getsecs(const char *strp, long *secsp) -{ - int num; - - /* - ** `HOURSPERDAY * DAYSPERWEEK - 1' allows quasi-Posix rules like - ** "M10.4.6/26", which does not conform to Posix, - ** but which specifies the equivalent of - ** ``02:00 on the first Sunday on or after 23 Oct''. - */ - strp = getnum(strp, &num, 0, HOURSPERDAY * DAYSPERWEEK - 1); - if (strp == NULL) - return NULL; - *secsp = num * (long) SECSPERHOUR; - if (*strp == ':') { - ++strp; - strp = getnum(strp, &num, 0, MINSPERHOUR - 1); - if (strp == NULL) - return NULL; - *secsp += num * SECSPERMIN; - if (*strp == ':') { - ++strp; - /* `SECSPERMIN' allows for leap seconds. */ - strp = getnum(strp, &num, 0, SECSPERMIN); - if (strp == NULL) - return NULL; - *secsp += num; - } - } - return strp; -} - -/* -** Given a pointer into a time zone string, extract an offset, in -** [+-]hh[:mm[:ss]] form, from the string. -** If any error occurs, return NULL. -** Otherwise, return a pointer to the first character not part of the time. -*/ - -static const char * -getoffset(const char *strp, long *offsetp) -{ - register int neg = 0; - - if (*strp == '-') { - neg = 1; - ++strp; - } else if (*strp == '+') - ++strp; - strp = getsecs(strp, offsetp); - if (strp == NULL) - return NULL; /* illegal time */ - if (neg) - *offsetp = -*offsetp; - return strp; -} - -/* -** Given a pointer into a time zone string, extract a rule in the form -** date[/time]. See POSIX section 8 for the format of "date" and "time". -** If a valid rule is not found, return NULL. -** Otherwise, return a pointer to the first character not part of the rule. -*/ - -static const char * -getrule(const char *strp, struct rule *rulep) -{ - if (*strp == 'J') { - /* - ** Julian day. - */ - rulep->r_type = JULIAN_DAY; - ++strp; - strp = getnum(strp, &rulep->r_day, 1, DAYSPERNYEAR); - } else if (*strp == 'M') { - /* - ** Month, week, day. - */ - rulep->r_type = MONTH_NTH_DAY_OF_WEEK; - ++strp; - strp = getnum(strp, &rulep->r_mon, 1, MONSPERYEAR); - if (strp == NULL) - return NULL; - if (*strp++ != '.') - return NULL; - strp = getnum(strp, &rulep->r_week, 1, 5); - if (strp == NULL) - return NULL; - if (*strp++ != '.') - return NULL; - strp = getnum(strp, &rulep->r_day, 0, DAYSPERWEEK - 1); - } else if (is_digit(*strp)) { - /* - ** Day of year. - */ - rulep->r_type = DAY_OF_YEAR; - strp = getnum(strp, &rulep->r_day, 0, DAYSPERLYEAR - 1); - } else return NULL; /* invalid format */ - if (strp == NULL) - return NULL; - if (*strp == '/') { - /* - ** Time specified. - */ - ++strp; - strp = getsecs(strp, &rulep->r_time); - } else rulep->r_time = 2 * SECSPERHOUR; /* default = 2:00:00 */ - return strp; -} - -/* -** Given the Epoch-relative time of January 1, 00:00:00 UTC, in a year, the -** year, a rule, and the offset from UTC at the time that rule takes effect, -** calculate the Epoch-relative time that rule takes effect. -*/ - -static time_t -transtime(const time_t janfirst, const int year, const struct rule *rulep, - long offset) -{ - register int leapyear; - register time_t value; - register int i; - int d, m1, yy0, yy1, yy2, dow; - - INITIALIZE(value); - leapyear = isleap(year); - switch (rulep->r_type) { - - case JULIAN_DAY: - /* - ** Jn - Julian day, 1 == January 1, 60 == March 1 even in leap - ** years. - ** In non-leap years, or if the day number is 59 or less, just - ** add SECSPERDAY times the day number-1 to the time of - ** January 1, midnight, to get the day. - */ - value = janfirst + (rulep->r_day - 1) * SECSPERDAY; - if (leapyear && rulep->r_day >= 60) - value += SECSPERDAY; - break; - - case DAY_OF_YEAR: - /* - ** n - day of year. - ** Just add SECSPERDAY times the day number to the time of - ** January 1, midnight, to get the day. - */ - value = janfirst + rulep->r_day * SECSPERDAY; - break; - - case MONTH_NTH_DAY_OF_WEEK: - /* - ** Mm.n.d - nth "dth day" of month m. - */ - value = janfirst; - for (i = 0; i < rulep->r_mon - 1; ++i) - value += mon_lengths[leapyear][i] * SECSPERDAY; - - /* - ** Use Zeller's Congruence to get day-of-week of first day of - ** month. - */ - m1 = (rulep->r_mon + 9) % 12 + 1; - yy0 = (rulep->r_mon <= 2) ? (year - 1) : year; - yy1 = yy0 / 100; - yy2 = yy0 % 100; - dow = ((26 * m1 - 2) / 10 + - 1 + yy2 + yy2 / 4 + yy1 / 4 - 2 * yy1) % 7; - if (dow < 0) - dow += DAYSPERWEEK; - - /* - ** "dow" is the day-of-week of the first day of the month. Get - ** the day-of-month (zero-origin) of the first "dow" day of the - ** month. - */ - d = rulep->r_day - dow; - if (d < 0) - d += DAYSPERWEEK; - for (i = 1; i < rulep->r_week; ++i) { - if (d + DAYSPERWEEK >= - mon_lengths[leapyear][rulep->r_mon - 1]) - break; - d += DAYSPERWEEK; - } - - /* - ** "d" is the day-of-month (zero-origin) of the day we want. - */ - value += d * SECSPERDAY; - break; - } - - /* - ** "value" is the Epoch-relative time of 00:00:00 UTC on the day in - ** question. To get the Epoch-relative time of the specified local - ** time on that day, add the transition time and the current offset - ** from UTC. - */ - return value + rulep->r_time + offset; -} - -/* -** Given a POSIX section 8-style TZ string, fill in the rule tables as -** appropriate. -*/ - -static int -tzparse(const char *name, struct state *sp, const int lastditch) -{ - const char * stdname; - const char * dstname; - size_t stdlen; - size_t dstlen; - long stdoffset; - long dstoffset; - register time_t * atp; - register unsigned char * typep; - register char * cp; - register int load_result; - - INITIALIZE(dstname); - stdname = name; - if (lastditch) { - stdlen = strlen(name); /* length of standard zone name */ - name += stdlen; - if (stdlen >= sizeof sp->chars) - stdlen = (sizeof sp->chars) - 1; - stdoffset = 0; - } else { - name = getzname(name); - stdlen = name - stdname; - if (stdlen < 3) - return -1; - if (*name == '\0') - return -1; - name = getoffset(name, &stdoffset); - if (name == NULL) - return -1; - } - load_result = tzload(TZDEFRULES, sp); - if (load_result != 0) - sp->leapcnt = 0; /* so, we're off a little */ - if (*name != '\0') { - dstname = name; - name = getzname(name); - dstlen = name - dstname; /* length of DST zone name */ - if (dstlen < 3) - return -1; - if (*name != '\0' && *name != ',' && *name != ';') { - name = getoffset(name, &dstoffset); - if (name == NULL) - return -1; - } else dstoffset = stdoffset - SECSPERHOUR; - if (*name == ',' || *name == ';') { - struct rule start; - struct rule end; - register int year; - register time_t janfirst; - time_t starttime; - time_t endtime; - - ++name; - if ((name = getrule(name, &start)) == NULL) - return -1; - if (*name++ != ',') - return -1; - if ((name = getrule(name, &end)) == NULL) - return -1; - if (*name != '\0') - return -1; - sp->typecnt = 2; /* standard time and DST */ - /* - ** Two transitions per year, from EPOCH_YEAR to 2037. - */ - sp->timecnt = 2 * (2037 - EPOCH_YEAR + 1); - if (sp->timecnt > TZ_MAX_TIMES) - return -1; - sp->ttis[0].tt_gmtoff = -dstoffset; - sp->ttis[0].tt_isdst = 1; - sp->ttis[0].tt_abbrind = stdlen + 1; - sp->ttis[1].tt_gmtoff = -stdoffset; - sp->ttis[1].tt_isdst = 0; - sp->ttis[1].tt_abbrind = 0; - atp = sp->ats; - typep = sp->types; - janfirst = 0; - for (year = EPOCH_YEAR; year <= 2037; ++year) { - starttime = transtime(janfirst, year, &start, - stdoffset); - endtime = transtime(janfirst, year, &end, - dstoffset); - if (starttime > endtime) { - *atp++ = endtime; - *typep++ = 1; /* DST ends */ - *atp++ = starttime; - *typep++ = 0; /* DST begins */ - } else { - *atp++ = starttime; - *typep++ = 0; /* DST begins */ - *atp++ = endtime; - *typep++ = 1; /* DST ends */ - } - janfirst += year_lengths[isleap(year)] * - SECSPERDAY; - } - __gettzinfo ()->__tzrule[0].offset - = -sp->ttis[1].tt_gmtoff; - __gettzinfo ()->__tzrule[1].offset - = -sp->ttis[0].tt_gmtoff; - } else { - register long theirstdoffset; - register long theirdstoffset; - register long theiroffset; - register int isdst; - register int i; - register int j; - - if (*name != '\0') - return -1; - if (load_result != 0) - return -1; - /* - ** Initial values of theirstdoffset and theirdstoffset. - */ - theirstdoffset = 0; - for (i = 0; i < sp->timecnt; ++i) { - j = sp->types[i]; - if (!sp->ttis[j].tt_isdst) { - theirstdoffset = - -sp->ttis[j].tt_gmtoff; - break; - } - } - theirdstoffset = 0; - for (i = 0; i < sp->timecnt; ++i) { - j = sp->types[i]; - if (sp->ttis[j].tt_isdst) { - theirdstoffset = - -sp->ttis[j].tt_gmtoff; - break; - } - } - /* - ** Initially we're assumed to be in standard time. - */ - isdst = false; - theiroffset = theirstdoffset; - /* - ** Now juggle transition times and types - ** tracking offsets as you do. - */ - for (i = 0; i < sp->timecnt; ++i) { - j = sp->types[i]; - sp->types[i] = sp->ttis[j].tt_isdst; - if (sp->ttis[j].tt_ttisgmt) { - /* No adjustment to transition time */ - } else { - /* - ** If summer time is in effect, and the - ** transition time was not specified as - ** standard time, add the summer time - ** offset to the transition time; - ** otherwise, add the standard time - ** offset to the transition time. - */ - /* - ** Transitions from DST to DDST - ** will effectively disappear since - ** POSIX provides for only one DST - ** offset. - */ - if (isdst && !sp->ttis[j].tt_ttisstd) { - sp->ats[i] += dstoffset - - theirdstoffset; - } else { - sp->ats[i] += stdoffset - - theirstdoffset; - } - } - theiroffset = -sp->ttis[j].tt_gmtoff; - if (sp->ttis[j].tt_isdst) - theirdstoffset = theiroffset; - else theirstdoffset = theiroffset; - } - /* - ** Finally, fill in ttis. - ** ttisstd and ttisgmt need not be handled. - */ - sp->ttis[0].tt_gmtoff = -stdoffset; - sp->ttis[0].tt_isdst = false; - sp->ttis[0].tt_abbrind = 0; - sp->ttis[1].tt_gmtoff = -dstoffset; - sp->ttis[1].tt_isdst = true; - sp->ttis[1].tt_abbrind = stdlen + 1; - sp->typecnt = 2; - __gettzinfo ()->__tzrule[0].offset - = -sp->ttis[0].tt_gmtoff; - __gettzinfo ()->__tzrule[1].offset - = -sp->ttis[1].tt_gmtoff; - } - } else { - dstlen = 0; - sp->typecnt = 1; /* only standard time */ - sp->timecnt = 0; - sp->ttis[0].tt_gmtoff = -stdoffset; - sp->ttis[0].tt_isdst = 0; - sp->ttis[0].tt_abbrind = 0; - __gettzinfo ()->__tzrule[0].offset = -sp->ttis[0].tt_gmtoff; - __gettzinfo ()->__tzrule[1].offset = -sp->ttis[0].tt_gmtoff; - } - sp->charcnt = stdlen + 1; - if (dstlen != 0) - sp->charcnt += dstlen + 1; - if ((size_t) sp->charcnt > sizeof sp->chars) - return -1; - cp = sp->chars; - strncpy(cp, stdname, stdlen); - cp += stdlen; - *cp++ = '\0'; - if (dstlen != 0) { - strncpy(cp, dstname, dstlen); - *(cp + dstlen) = '\0'; - } - return 0; -} - -static void -gmtload(struct state *sp) -{ - if (tzload(gmt, sp) != 0) - tzparse(gmt, sp, true); -} - -#ifndef STD_INSPIRED -/* -** A non-static declaration of tzsetwall in a system header file -** may cause a warning about this upcoming static declaration... -*/ -static -#endif /* !defined STD_INSPIRED */ -void -tzsetwall P((void)) -{ - if (lcl_is_set < 0) - return; - lcl_is_set = -1; - -#ifdef ALL_STATE - if (lclptr == NULL) { - lclptr = (struct state *) malloc(sizeof *lclptr); - if (lclptr == NULL) { - settzname(); /* all we can do */ - return; - } - } -#endif /* defined ALL_STATE */ -#if defined (_WIN32) || defined (__CYGWIN__) -#define is_upper(c) ((unsigned)(c) - 'A' <= 26) - { - TIME_ZONE_INFORMATION tz; - char buf[BUFSIZ]; - char *cp, *dst; - wchar_t *src; - div_t d; - GetTimeZoneInformation(&tz); - dst = cp = buf; - for (src = tz.StandardName; *src; src++) - if (is_upper(*src)) *dst++ = *src; - if ((dst - cp) < 3) - { - /* In non-english Windows, converted tz.StandardName - may not contain a valid standard timezone name. */ - strcpy(cp, wildabbr); - cp += strlen(wildabbr); - } - else - cp = dst; - d = div(tz.Bias+tz.StandardBias, 60); - sprintf(cp, "%d", d.quot); - if (d.rem) - sprintf(cp=strchr(cp, 0), ":%d", abs(d.rem)); - if(tz.StandardDate.wMonth) { - cp = strchr(cp, 0); - dst = cp; - for (src = tz.DaylightName; *src; src++) - if (is_upper(*src)) *dst++ = *src; - if ((dst - cp) < 3) - { - /* In non-english Windows, converted tz.DaylightName - may not contain a valid daylight timezone name. */ - strcpy(cp, wildabbr); - cp += strlen(wildabbr); - } - else - cp = dst; - d = div(tz.Bias+tz.DaylightBias, 60); - sprintf(cp, "%d", d.quot); - if (d.rem) - sprintf(cp=strchr(cp, 0), ":%d", abs(d.rem)); - cp = strchr(cp, 0); - sprintf(cp=strchr(cp, 0), ",M%d.%d.%d/%d", - tz.DaylightDate.wMonth, - tz.DaylightDate.wDay, - tz.DaylightDate.wDayOfWeek, - tz.DaylightDate.wHour); - if (tz.DaylightDate.wMinute || tz.DaylightDate.wSecond) - sprintf(cp=strchr(cp, 0), ":%d", tz.DaylightDate.wMinute); - if (tz.DaylightDate.wSecond) - sprintf(cp=strchr(cp, 0), ":%d", tz.DaylightDate.wSecond); - cp = strchr(cp, 0); - sprintf(cp=strchr(cp, 0), ",M%d.%d.%d/%d", - tz.StandardDate.wMonth, - tz.StandardDate.wDay, - tz.StandardDate.wDayOfWeek, - tz.StandardDate.wHour); - if (tz.StandardDate.wMinute || tz.StandardDate.wSecond) - sprintf(cp=strchr(cp, 0), ":%d", tz.StandardDate.wMinute); - if (tz.StandardDate.wSecond) - sprintf(cp=strchr(cp, 0), ":%d", tz.StandardDate.wSecond); - } - /* printf("TZ deduced as `%s'\n", buf); */ - if (tzparse(buf, lclptr, false) == 0) { - settzname(); - lcl_is_set = 1; - strlcpy(lcl_TZname, buf, sizeof (lcl_TZname)); -#if 0 - /* Huh? POSIX doesn't mention anywhere that tzset should - set $TZ. That's not right. */ - setenv("TZ", lcl_TZname, 1); -#endif - return; - } - } -#endif - if (tzload((char *) NULL, lclptr) != 0) - gmtload(lclptr); - settzname(); -} - -static NO_COPY muto tzset_guard; - -extern "C" void -tzset P((void)) -{ - tzset_guard.init ("tzset_guard")->acquire (); - const char * name = getenv("TZ"); - - if (name == NULL) { - if (!lcl_is_set) - tzsetwall(); - goto out; - } - - if (lcl_is_set > 0 && strcmp(lcl_TZname, name) == 0) - goto out; - lcl_is_set = (strlen(name) < sizeof (lcl_TZname)); - if (lcl_is_set) - strcpy(lcl_TZname, name); - -#ifdef ALL_STATE - if (lclptr == NULL) { - lclptr = (struct state *) malloc(sizeof *lclptr); - if (lclptr == NULL) { - settzname(); /* all we can do */ - goto out; - } - } -#endif /* defined ALL_STATE */ - if (*name == '\0') { - /* - ** User wants it fast rather than right. - */ - lclptr->leapcnt = 0; /* so, we're off a little */ - lclptr->timecnt = 0; - lclptr->ttis[0].tt_gmtoff = 0; - lclptr->ttis[0].tt_abbrind = 0; - strcpy(lclptr->chars, gmt); - } else if (tzload(name, lclptr) != 0) { - if (name[0] == ':' || tzparse(name, lclptr, false) != 0) - gmtload(lclptr); - } - settzname(); -out: - tzset_guard.release (); -} - -/* -** The easy way to behave "as if no library function calls" localtime -** is to not call it--so we drop its guts into "localsub", which can be -** freely called. (And no, the PANS doesn't require the above behavior-- -** but it *is* desirable.) -** -** The unused offset argument is for the benefit of mktime variants. -*/ - -/*ARGSUSED*/ -static void -localsub (const time_t * const timep, - const long offset, - struct tm * const tmp) -{ - register struct state * sp; - register const struct ttinfo * ttisp; - register int i; - const time_t t = *timep; - - sp = lclptr; -#ifdef ALL_STATE - if (sp == NULL) { - gmtsub(timep, offset, tmp); - return; - } -#endif /* defined ALL_STATE */ - if (sp->timecnt == 0 || t < sp->ats[0]) { - i = 0; - while (sp->ttis[i].tt_isdst) - if (++i >= sp->typecnt) { - i = 0; - break; - } - } else { - for (i = 1; i < sp->timecnt; ++i) - if (t < sp->ats[i]) - break; - i = sp->types[i - 1]; - } - ttisp = &sp->ttis[i]; - /* - ** To get (wrong) behavior that's compatible with System V Release 2.0 - ** you'd replace the statement below with - ** t += ttisp->tt_gmtoff; - ** timesub(&t, 0L, sp, tmp); - */ - timesub(&t, ttisp->tt_gmtoff, sp, tmp); - tmp->tm_isdst = ttisp->tt_isdst; - tzname[tmp->tm_isdst] = &sp->chars[ttisp->tt_abbrind]; -#ifdef TM_ZONE - tmp->TM_ZONE = &sp->chars[ttisp->tt_abbrind]; -#endif /* defined TM_ZONE */ -} - -extern "C" struct tm * -localtime(const time_t *timep) -{ - tzset(); - localsub(timep, 0L, &tm); - return &tm; -} - -/* - * Re-entrant version of localtime - */ -extern "C" struct tm * -localtime_r(const time_t *timep, struct tm *tm) -{ - tzset(); - localsub(timep, 0L, tm); - return tm; -} - -/* -** gmtsub is to gmtime as localsub is to localtime. -*/ - -static void -gmtsub(const time_t *timep, const long offset, struct tm *tmp) -{ - if (!gmt_is_set) { - gmt_is_set = true; -#ifdef ALL_STATE - gmtptr = (struct state *) malloc(sizeof *gmtptr); - if (gmtptr != NULL) -#endif /* defined ALL_STATE */ - gmtload(gmtptr); - } - timesub(timep, offset, gmtptr, tmp); -#ifdef TM_ZONE - /* - ** Could get fancy here and deliver something such as - ** "UTC+xxxx" or "UTC-xxxx" if offset is non-zero, - ** but this is no time for a treasure hunt. - */ - if (offset != 0) - tmp->TM_ZONE = wildabbr; - else { -#ifdef ALL_STATE - if (gmtptr == NULL) - tmp->TM_ZONE = gmt; - else tmp->TM_ZONE = gmtptr->chars; -#endif /* defined ALL_STATE */ -#ifndef ALL_STATE - tmp->TM_ZONE = gmtptr->chars; -#endif /* State Farm */ - } -#endif /* defined TM_ZONE */ -} - -extern "C" struct tm * -gmtime(const time_t *timep) -{ - gmtsub(timep, 0L, &tm); - return &tm; -} - -/* - * Re-entrant version of gmtime - */ -extern "C" struct tm * -gmtime_r(const time_t *timep, struct tm *tm) -{ - gmtsub(timep, 0L, tm); - return tm; -} - -#ifdef STD_INSPIRED - -extern "C" struct tm * -offtime(const time_t *timep, const long offset) -{ - gmtsub(timep, offset, &tm); - return &tm; -} - -#endif /* defined STD_INSPIRED */ - -static void -timesub(const time_t *timep, const long offset, const struct state *sp, - struct tm *tmp) -{ - register const struct lsinfo * lp; - register long days; - register long rem; - register int y; - register int yleap; - register const int * ip; - register long corr; - register int hit; - register int i; - - corr = 0; - hit = 0; -#ifdef ALL_STATE - i = (sp == NULL) ? 0 : sp->leapcnt; -#endif /* defined ALL_STATE */ -#ifndef ALL_STATE - i = sp->leapcnt; -#endif /* State Farm */ - while (--i >= 0) { - lp = &sp->lsis[i]; - if (*timep >= lp->ls_trans) { - if (*timep == lp->ls_trans) { - hit = ((i == 0 && lp->ls_corr > 0) || - lp->ls_corr > sp->lsis[i - 1].ls_corr); - if (hit) - while (i > 0 && - sp->lsis[i].ls_trans == - sp->lsis[i - 1].ls_trans + 1 && - sp->lsis[i].ls_corr == - sp->lsis[i - 1].ls_corr + 1) { - ++hit; - --i; - } - } - corr = lp->ls_corr; - break; - } - } - days = *timep / SECSPERDAY; - rem = *timep % SECSPERDAY; -#ifdef mc68k - if (*timep == 0x80000000) { - /* - ** A 3B1 muffs the division on the most negative number. - */ - days = -24855; - rem = -11648; - } -#endif /* defined mc68k */ - rem += (offset - corr); - while (rem < 0) { - rem += SECSPERDAY; - --days; - } - while (rem >= SECSPERDAY) { - rem -= SECSPERDAY; - ++days; - } - tmp->tm_hour = (int) (rem / SECSPERHOUR); - rem = rem % SECSPERHOUR; - tmp->tm_min = (int) (rem / SECSPERMIN); - /* - ** A positive leap second requires a special - ** representation. This uses "... ??:59:60" et seq. - */ - tmp->tm_sec = (int) (rem % SECSPERMIN) + hit; - tmp->tm_wday = (int) ((EPOCH_WDAY + days) % DAYSPERWEEK); - if (tmp->tm_wday < 0) - tmp->tm_wday += DAYSPERWEEK; - y = EPOCH_YEAR; -#define LEAPS_THRU_END_OF(y) ((y) / 4 - (y) / 100 + (y) / 400) - while (days < 0 || days >= (long) year_lengths[yleap = isleap(y)]) { - register int newy; - - newy = y + days / DAYSPERNYEAR; - if (days < 0) - --newy; - days -= (newy - y) * DAYSPERNYEAR + - LEAPS_THRU_END_OF(newy - 1) - - LEAPS_THRU_END_OF(y - 1); - y = newy; - } - tmp->tm_year = y - TM_YEAR_BASE; - tmp->tm_yday = (int) days; - ip = mon_lengths[yleap]; - for (tmp->tm_mon = 0; days >= (long) ip[tmp->tm_mon]; ++(tmp->tm_mon)) - days = days - (long) ip[tmp->tm_mon]; - tmp->tm_mday = (int) (days + 1); - tmp->tm_isdst = 0; -#ifdef TM_GMTOFF - tmp->TM_GMTOFF = offset; -#endif /* defined TM_GMTOFF */ -} - -extern "C" char * -ctime(const time_t *timep) -{ -/* -** Section 4.12.3.2 of X3.159-1989 requires that -** The ctime function converts the calendar time pointed to by timer -** to local time in the form of a string. It is equivalent to -** asctime(localtime(timer)) -*/ - return asctime(localtime(timep)); -} - -extern "C" char * -ctime_r(const time_t *timep, char *buf) -{ - struct tm tm; - - return asctime_r(localtime_r(timep, &tm), buf); -} - -/* -** Adapted from code provided by Robert Elz, who writes: -** The "best" way to do mktime I think is based on an idea of Bob -** Kridle's (so its said...) from a long time ago. -** [kridle@xinet.com as of 1996-01-16.] -** It does a binary search of the time_t space. Since time_t's are -** just 32 bits, its a max of 32 iterations (even at 64 bits it -** would still be very reasonable). -*/ - -#ifndef WRONG -#define WRONG (-1) -#endif /* !defined WRONG */ - -/* -** Simplified normalize logic courtesy Paul Eggert (eggert@twinsun.com). -*/ - -/* Mark as noinline to prevent a compiler warning. */ -static int __attribute__((noinline)) -increment_overflow(int *number, int delta) -{ - int number0; - - number0 = *number; - *number += delta; - return (*number < number0) != (delta < 0); -} - -static int -normalize_overflow(int *tensptr, int *unitsptr, const int base) -{ - register int tensdelta; - - tensdelta = (*unitsptr >= 0) ? - (*unitsptr / base) : - (-1 - (-1 - *unitsptr) / base); - *unitsptr -= tensdelta * base; - return increment_overflow(tensptr, tensdelta); -} - -static int -tmcomp(register const struct tm *atmp, register const struct tm *btmp) -{ - register int result; - - if ((result = (atmp->tm_year - btmp->tm_year)) == 0 && - (result = (atmp->tm_mon - btmp->tm_mon)) == 0 && - (result = (atmp->tm_mday - btmp->tm_mday)) == 0 && - (result = (atmp->tm_hour - btmp->tm_hour)) == 0 && - (result = (atmp->tm_min - btmp->tm_min)) == 0) - result = atmp->tm_sec - btmp->tm_sec; - return result; -} - -static time_t -time2sub(struct tm *tmp, void (*funcp) P((const time_t*, long, struct tm*)), - const long offset, int *okayp, const int do_norm_secs) -{ - register const struct state * sp; - register int dir; - register int bits; - register int i, j ; - register int saved_seconds; - time_t newt; - time_t t; - struct tm yourtm, mytm; - - *okayp = false; - yourtm = *tmp; - if (do_norm_secs) { - if (normalize_overflow(&yourtm.tm_min, &yourtm.tm_sec, - SECSPERMIN)) - return WRONG; - } - if (normalize_overflow(&yourtm.tm_hour, &yourtm.tm_min, MINSPERHOUR)) - return WRONG; - if (normalize_overflow(&yourtm.tm_mday, &yourtm.tm_hour, HOURSPERDAY)) - return WRONG; - if (normalize_overflow(&yourtm.tm_year, &yourtm.tm_mon, MONSPERYEAR)) - return WRONG; - /* - ** Turn yourtm.tm_year into an actual year number for now. - ** It is converted back to an offset from TM_YEAR_BASE later. - */ - if (increment_overflow(&yourtm.tm_year, TM_YEAR_BASE)) - return WRONG; - while (yourtm.tm_mday <= 0) { - if (increment_overflow(&yourtm.tm_year, -1)) - return WRONG; - i = yourtm.tm_year + (1 < yourtm.tm_mon); - yourtm.tm_mday += year_lengths[isleap(i)]; - } - while (yourtm.tm_mday > DAYSPERLYEAR) { - i = yourtm.tm_year + (1 < yourtm.tm_mon); - yourtm.tm_mday -= year_lengths[isleap(i)]; - if (increment_overflow(&yourtm.tm_year, 1)) - return WRONG; - } - for ( ; ; ) { - i = mon_lengths[isleap(yourtm.tm_year)][yourtm.tm_mon]; - if (yourtm.tm_mday <= i) - break; - yourtm.tm_mday -= i; - if (++yourtm.tm_mon >= MONSPERYEAR) { - yourtm.tm_mon = 0; - if (increment_overflow(&yourtm.tm_year, 1)) - return WRONG; - } - } - if (increment_overflow(&yourtm.tm_year, -TM_YEAR_BASE)) - return WRONG; - if (yourtm.tm_year + TM_YEAR_BASE < EPOCH_YEAR) { - /* - ** We can't set tm_sec to 0, because that might push the - ** time below the minimum representable time. - ** Set tm_sec to 59 instead. - ** This assumes that the minimum representable time is - ** not in the same minute that a leap second was deleted from, - ** which is a safer assumption than using 58 would be. - */ - if (increment_overflow(&yourtm.tm_sec, 1 - SECSPERMIN)) - return WRONG; - saved_seconds = yourtm.tm_sec; - yourtm.tm_sec = SECSPERMIN - 1; - } else { - saved_seconds = yourtm.tm_sec; - yourtm.tm_sec = 0; - } - /* - ** Divide the search space in half - ** (this works whether time_t is signed or unsigned). - */ - bits = TYPE_BIT(time_t) - 1; - /* - ** If time_t is signed, then 0 is just above the median, - ** assuming two's complement arithmetic. - ** If time_t is unsigned, then (1 << bits) is just above the median. - */ - t = TYPE_SIGNED(time_t) ? 0 : (((time_t) 1) << bits); - for ( ; ; ) { - (*funcp)(&t, offset, &mytm); - dir = tmcomp(&mytm, &yourtm); - if (dir != 0) { - if (bits-- < 0) - return WRONG; - if (bits < 0) - --t; /* may be needed if new t is minimal */ - else if (dir > 0) - t -= ((time_t) 1) << bits; - else t += ((time_t) 1) << bits; - continue; - } - if (yourtm.tm_isdst < 0 || mytm.tm_isdst == yourtm.tm_isdst) - break; - /* - ** Right time, wrong type. - ** Hunt for right time, right type. - ** It's okay to guess wrong since the guess - ** gets checked. - */ - /* - ** The (void *) casts are the benefit of SunOS 3.3 on Sun 2's. - */ - sp = (const struct state *) - (((void *) funcp == (void *) localsub) ? - lclptr : gmtptr); -#ifdef ALL_STATE - if (sp == NULL) - return WRONG; -#endif /* defined ALL_STATE */ - for (i = sp->typecnt - 1; i >= 0; --i) { - if (sp->ttis[i].tt_isdst != yourtm.tm_isdst) - continue; - for (j = sp->typecnt - 1; j >= 0; --j) { - if (sp->ttis[j].tt_isdst == yourtm.tm_isdst) - continue; - newt = t + sp->ttis[j].tt_gmtoff - - sp->ttis[i].tt_gmtoff; - (*funcp)(&newt, offset, &mytm); - if (tmcomp(&mytm, &yourtm) != 0) - continue; - if (mytm.tm_isdst != yourtm.tm_isdst) - continue; - /* - ** We have a match. - */ - t = newt; - goto label; - } - } - return WRONG; - } -label: - newt = t + saved_seconds; - if ((newt < t) != (saved_seconds < 0)) - return WRONG; - t = newt; - (*funcp)(&t, offset, tmp); - *okayp = true; - return t; -} - -static time_t -time2(struct tm *tmp, void (*funcp) P((const time_t*, long, struct tm*)), - const long offset, int *okayp) -{ - time_t t; - - /* - ** First try without normalization of seconds - ** (in case tm_sec contains a value associated with a leap second). - ** If that fails, try with normalization of seconds. - */ - t = time2sub(tmp, funcp, offset, okayp, false); - if (*okayp) - return t; - t = time2sub(tmp, funcp, offset, okayp, true); - if (*okayp) - return t; - /* Workaround for the spring forward gap problem which results in - the autoconf mktime usability test failing. - What we do here is this: The gap has 3600 seconds. If we - subtract 3600 from the tm_sec value and get a valid result, - then we can simply add 3600 to the return value and are done. - If the result is still not valid, the problem is not the - spring forward gap and we can give up. */ - struct tm tmp2 = *tmp; - tmp2.tm_sec -= 3600; - t = time2sub(&tmp2, funcp, offset, okayp, true); - if (*okayp) - { - if (t + 3600 < 0) /* Sanity check */ - return WRONG; - return t + 3600; - } - return t; -} - -static time_t -time1(struct tm *tmp, void (*funcp) P((const time_t *, long, struct tm *)), - const long offset) -{ - register time_t t; - register const struct state * sp; - register int samei, otheri; - int okay; - - if (tmp->tm_isdst > 1) - tmp->tm_isdst = 1; - t = time2(tmp, funcp, offset, &okay); -#ifdef PCTS - /* - ** PCTS code courtesy Grant Sullivan (grant@osf.org). - */ - if (okay) - return t; - if (tmp->tm_isdst < 0) - tmp->tm_isdst = 0; /* reset to std and try again */ -#endif /* defined PCTS */ -#ifndef PCTS - if (okay || tmp->tm_isdst < 0) - return t; -#endif /* !defined PCTS */ - /* - ** We're supposed to assume that somebody took a time of one type - ** and did some math on it that yielded a "struct tm" that's bad. - ** We try to divine the type they started from and adjust to the - ** type they need. - */ - /* - ** The (void *) casts are the benefit of SunOS 3.3 on Sun 2's. - */ - sp = (const struct state *) (((void *) funcp == (void *) localsub) ? - lclptr : gmtptr); -#ifdef ALL_STATE - if (sp == NULL) - return WRONG; -#endif /* defined ALL_STATE */ - for (samei = sp->typecnt - 1; samei >= 0; --samei) { - if (sp->ttis[samei].tt_isdst != tmp->tm_isdst) - continue; - for (otheri = sp->typecnt - 1; otheri >= 0; --otheri) { - if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst) - continue; - tmp->tm_sec += sp->ttis[otheri].tt_gmtoff - - sp->ttis[samei].tt_gmtoff; - tmp->tm_isdst = !tmp->tm_isdst; - t = time2(tmp, funcp, offset, &okay); - if (okay) - return t; - tmp->tm_sec -= sp->ttis[otheri].tt_gmtoff - - sp->ttis[samei].tt_gmtoff; - tmp->tm_isdst = !tmp->tm_isdst; - } - } - return WRONG; -} - -extern "C" time_t -mktime(struct tm *tmp) -{ - tzset(); - return time1(tmp, localsub, 0L); -} - -#ifdef STD_INSPIRED - -extern "C" time_t -timelocal(struct tm *tmp) -{ - tmp->tm_isdst = -1; /* in case it wasn't initialized */ - return mktime(tmp); -} - -extern "C" time_t -timegm(struct tm *tmp) -{ - tmp->tm_isdst = 0; - return time1(tmp, gmtsub, 0L); -} - -extern "C" time_t -timeoff(struct tm *tmp, const long offset) -{ - tmp->tm_isdst = 0; - return time1(tmp, gmtsub, offset); -} - -#endif /* defined STD_INSPIRED */ - -#ifdef CMUCS - -/* -** The following is supplied for compatibility with -** previous versions of the CMUCS runtime library. -*/ - -extern "C" long -gtime(struct tm *tmp) -{ - const time_t t = mktime(tmp); - - if (t == WRONG) - return -1; - return t; -} - -#endif /* defined CMUCS */ - -/* -** XXX--is the below the right way to conditionalize?? -*/ - -#ifdef STD_INSPIRED - -/* -** IEEE Std 1003.1-1988 (POSIX) legislates that 536457599 -** shall correspond to "Wed Dec 31 23:59:59 UTC 1986", which -** is not the case if we are accounting for leap seconds. -** So, we provide the following conversion routines for use -** when exchanging timestamps with POSIX conforming systems. -*/ - -static long -leapcorr(time_t *timep) -{ - register struct state * sp; - register struct lsinfo * lp; - register int i; - - sp = lclptr; - i = sp->leapcnt; - while (--i >= 0) { - lp = &sp->lsis[i]; - if (*timep >= lp->ls_trans) - return lp->ls_corr; - } - return 0; -} - -extern "C" time_t -time2posix(time_t t) -{ - tzset(); - return t - leapcorr(&t); -} - -extern "C" time_t -posix2time(time_t t) -{ - time_t x; - time_t y; - - tzset(); - /* - ** For a positive leap second hit, the result - ** is not unique. For a negative leap second - ** hit, the corresponding time doesn't exist, - ** so we return an adjacent second. - */ - x = t + leapcorr(&t); - y = x - leapcorr(&x); - if (y < t) { - do { - x++; - y = x - leapcorr(&x); - } while (y < t); - if (t != y) - return x - 1; - } else if (y > t) { - do { - --x; - y = x - leapcorr(&x); - } while (y > t); - if (t != y) - return x + 1; - } - return x; -} - -#endif /* defined STD_INSPIRED */ diff --git a/winsup/cygwin/lsearch.cc b/winsup/cygwin/lsearch.cc deleted file mode 100644 index 9e2d93b77..000000000 --- a/winsup/cygwin/lsearch.cc +++ /dev/null @@ -1,51 +0,0 @@ -/* Initial implementation: - Copyright (c) 2002 Robert Drehmel - All rights reserved. - - As long as the above copyright statement and this notice remain - unchanged, you can do what ever you want with this file. */ - -#include /* for uint8_t */ -#include /* for memcpy () prototype */ - -static void *lwork (const void *, const void *, size_t *, size_t, - int (*) (const void *, const void *), int); - -extern "C" void * -lsearch (const void *key, void *base, size_t *nelp, size_t width, - int (*compar) (const void *, const void *)) -{ - return lwork (key, base, nelp, width, compar, 1); -} - -extern "C" void * -lfind (const void *key, const void *base, size_t *nelp, size_t width, - int (*compar) (const void *, const void *)) -{ - return lwork (key, base, nelp, width, compar, 0); -} - -static void * -lwork (const void *key, const void *base, size_t *nelp, size_t width, - int (*compar) (const void *, const void *), int addelem) -{ - uint8_t *ep, *endp; - - /* Cast to an integer value first to avoid the warning for removing - 'const' via a cast. */ - ep = (uint8_t *) (uintptr_t)base; - for (endp = (uint8_t *) (ep + width * *nelp); ep < endp; ep += width) - if (compar (key, ep) == 0) - return ep; - - /* lfind () shall return when the key was not found. */ - if (!addelem) - return NULL; - - /* lsearch () adds the key to the end of the table and increments - the number of elements. */ - memcpy (endp, key, width); - ++*nelp; - - return endp; -} diff --git a/winsup/cygwin/malloc.cc b/winsup/cygwin/malloc.cc deleted file mode 100644 index f9c3d557a..000000000 --- a/winsup/cygwin/malloc.cc +++ /dev/null @@ -1,5064 +0,0 @@ -/* - This is a version (aka dlmalloc) of malloc/free/realloc written by - Doug Lea and released to the public domain, as explained at - http://creativecommons.org/licenses/publicdomain. Send questions, - comments, complaints, performance data, etc to dl@cs.oswego.edu - -* Version 2.8.3 Thu Sep 22 11:16:15 2005 Doug Lea (dl at gee) - - Note: There may be an updated version of this malloc obtainable at - ftp://gee.cs.oswego.edu/pub/misc/malloc.c - Check before installing! - -* Quickstart - - This library is all in one file to simplify the most common usage: - ftp it, compile it (-O3), and link it into another program. All of - the compile-time options default to reasonable values for use on - most platforms. You might later want to step through various - compile-time and dynamic tuning options. - - For convenience, an include file for code using this malloc is at: - ftp://gee.cs.oswego.edu/pub/misc/malloc-2.8.3.h - You don't really need this .h file unless you call functions not - defined in your system include files. The .h file contains only the - excerpts from this file needed for using this malloc on ANSI C/C++ - systems, so long as you haven't changed compile-time options about - naming and tuning parameters. If you do, then you can create your - own malloc.h that does include all settings by cutting at the point - indicated below. Note that you may already by default be using a C - library containing a malloc that is based on some version of this - malloc (for example in linux). You might still want to use the one - in this file to customize settings or to avoid overheads associated - with library versions. - -* Vital statistics: - - Supported pointer/size_t representation: 4 or 8 bytes - size_t MUST be an unsigned type of the same width as - pointers. (If you are using an ancient system that declares - size_t as a signed type, or need it to be a different width - than pointers, you can use a previous release of this malloc - (e.g. 2.7.2) supporting these.) - - Alignment: 8 bytes (default) - This suffices for nearly all current machines and C compilers. - However, you can define MALLOC_ALIGNMENT to be wider than this - if necessary (up to 128bytes), at the expense of using more space. - - Minimum overhead per allocated chunk: 4 or 8 bytes (if 4byte sizes) - 8 or 16 bytes (if 8byte sizes) - Each malloced chunk has a hidden word of overhead holding size - and status information, and additional cross-check word - if FOOTERS is defined. - - Minimum allocated size: 4-byte ptrs: 16 bytes (including overhead) - 8-byte ptrs: 32 bytes (including overhead) - - Even a request for zero bytes (i.e., malloc(0)) returns a - pointer to something of the minimum allocatable size. - The maximum overhead wastage (i.e., number of extra bytes - allocated than were requested in malloc) is less than or equal - to the minimum size, except for requests >= mmap_threshold that - are serviced via mmap(), where the worst case wastage is about - 32 bytes plus the remainder from a system page (the minimal - mmap unit); typically 4096 or 8192 bytes. - - Security: static-safe; optionally more or less - The "security" of malloc refers to the ability of malicious - code to accentuate the effects of errors (for example, freeing - space that is not currently malloc'ed or overwriting past the - ends of chunks) in code that calls malloc. This malloc - guarantees not to modify any memory locations below the base of - heap, i.e., static variables, even in the presence of usage - errors. The routines additionally detect most improper frees - and reallocs. All this holds as long as the static bookkeeping - for malloc itself is not corrupted by some other means. This - is only one aspect of security -- these checks do not, and - cannot, detect all possible programming errors. - - If FOOTERS is defined nonzero, then each allocated chunk - carries an additional check word to verify that it was malloced - from its space. These check words are the same within each - execution of a program using malloc, but differ across - executions, so externally crafted fake chunks cannot be - freed. This improves security by rejecting frees/reallocs that - could corrupt heap memory, in addition to the checks preventing - writes to statics that are always on. This may further improve - security at the expense of time and space overhead. (Note that - FOOTERS may also be worth using with MSPACES.) - - By default detected errors cause the program to abort (calling - "abort()"). You can override this to instead proceed past - errors by defining PROCEED_ON_ERROR. In this case, a bad free - has no effect, and a malloc that encounters a bad address - caused by user overwrites will ignore the bad address by - dropping pointers and indices to all known memory. This may - be appropriate for programs that should continue if at all - possible in the face of programming errors, although they may - run out of memory because dropped memory is never reclaimed. - - If you don't like either of these options, you can define - CORRUPTION_ERROR_ACTION and USAGE_ERROR_ACTION to do anything - else. And if if you are sure that your program using malloc has - no errors or vulnerabilities, you can define INSECURE to 1, - which might (or might not) provide a small performance improvement. - - Thread-safety: NOT thread-safe unless USE_LOCKS defined - When USE_LOCKS is defined, each public call to malloc, free, - etc is surrounded with either a pthread mutex or a win32 - spinlock (depending on WIN32). This is not especially fast, and - can be a major bottleneck. It is designed only to provide - minimal protection in concurrent environments, and to provide a - basis for extensions. If you are using malloc in a concurrent - program, consider instead using ptmalloc, which is derived from - a version of this malloc. (See http://www.malloc.de). - - System requirements: Any combination of MORECORE and/or MMAP/MUNMAP - This malloc can use unix sbrk or any emulation (invoked using - the CALL_MORECORE macro) and/or mmap/munmap or any emulation - (invoked using CALL_MMAP/CALL_MUNMAP) to get and release system - memory. On most unix systems, it tends to work best if both - MORECORE and MMAP are enabled. On Win32, it uses emulations - based on VirtualAlloc. It also uses common C library functions - like memset. - - Compliance: I believe it is compliant with the Single Unix Specification - (See http://www.unix.org). Also SVID/XPG, ANSI C, and probably - others as well. - -* Overview of algorithms - - This is not the fastest, most space-conserving, most portable, or - most tunable malloc ever written. However it is among the fastest - while also being among the most space-conserving, portable and - tunable. Consistent balance across these factors results in a good - general-purpose allocator for malloc-intensive programs. - - In most ways, this malloc is a best-fit allocator. Generally, it - chooses the best-fitting existing chunk for a request, with ties - broken in approximately least-recently-used order. (This strategy - normally maintains low fragmentation.) However, for requests less - than 256bytes, it deviates from best-fit when there is not an - exactly fitting available chunk by preferring to use space adjacent - to that used for the previous small request, as well as by breaking - ties in approximately most-recently-used order. (These enhance - locality of series of small allocations.) And for very large requests - (>= 256Kb by default), it relies on system memory mapping - facilities, if supported. (This helps avoid carrying around and - possibly fragmenting memory used only for large chunks.) - - All operations (except malloc_stats and mallinfo) have execution - times that are bounded by a constant factor of the number of bits in - a size_t, not counting any clearing in calloc or copying in realloc, - or actions surrounding MORECORE and MMAP that have times - proportional to the number of non-contiguous regions returned by - system allocation routines, which is often just 1. - - The implementation is not very modular and seriously overuses - macros. Perhaps someday all C compilers will do as good a job - inlining modular code as can now be done by brute-force expansion, - but now, enough of them seem not to. - - Some compilers issue a lot of warnings about code that is - dead/unreachable only on some platforms, and also about intentional - uses of negation on unsigned types. All known cases of each can be - ignored. - - For a longer but out of date high-level description, see - http://gee.cs.oswego.edu/dl/html/malloc.html - -* MSPACES - If MSPACES is defined, then in addition to malloc, free, etc., - this file also defines mspace_malloc, mspace_free, etc. These - are versions of malloc routines that take an "mspace" argument - obtained using create_mspace, to control all internal bookkeeping. - If ONLY_MSPACES is defined, only these versions are compiled. - So if you would like to use this allocator for only some allocations, - and your system malloc for others, you can compile with - ONLY_MSPACES and then do something like... - static mspace mymspace = create_mspace(0,0); // for example - #define mymalloc(bytes) mspace_malloc(mymspace, bytes) - - (Note: If you only need one instance of an mspace, you can instead - use "USE_DL_PREFIX" to relabel the global malloc.) - - You can similarly create thread-local allocators by storing - mspaces as thread-locals. For example: - static __thread mspace tlms = 0; - void* tlmalloc(size_t bytes) { - if (tlms == 0) tlms = create_mspace(0, 0); - return mspace_malloc(tlms, bytes); - } - void tlfree(void* mem) { mspace_free(tlms, mem); } - - Unless FOOTERS is defined, each mspace is completely independent. - You cannot allocate from one and free to another (although - conformance is only weakly checked, so usage errors are not always - caught). If FOOTERS is defined, then each chunk carries around a tag - indicating its originating mspace, and frees are directed to their - originating spaces. - - ------------------------- Compile-time options --------------------------- - -Be careful in setting #define values for numerical constants of type -size_t. On some systems, literal values are not automatically extended -to size_t precision unless they are explicitly casted. - -WIN32 default: defined if _WIN32 defined - Defining WIN32 sets up defaults for MS environment and compilers. - Otherwise defaults are for unix. - -MALLOC_ALIGNMENT default: (size_t)8 - Controls the minimum alignment for malloc'ed chunks. It must be a - power of two and at least 8, even on machines for which smaller - alignments would suffice. It may be defined as larger than this - though. Note however that code and data structures are optimized for - the case of 8-byte alignment. - -MSPACES default: 0 (false) - If true, compile in support for independent allocation spaces. - This is only supported if HAVE_MMAP is true. - -ONLY_MSPACES default: 0 (false) - If true, only compile in mspace versions, not regular versions. - -USE_LOCKS default: 0 (false) - Causes each call to each public routine to be surrounded with - pthread or WIN32 mutex lock/unlock. (If set true, this can be - overridden on a per-mspace basis for mspace versions.) - -FOOTERS default: 0 - If true, provide extra checking and dispatching by placing - information in the footers of allocated chunks. This adds - space and time overhead. - -INSECURE default: 0 - If true, omit checks for usage errors and heap space overwrites. - -USE_DL_PREFIX default: NOT defined - Causes compiler to prefix all public routines with the string 'dl'. - This can be useful when you only want to use this malloc in one part - of a program, using your regular system malloc elsewhere. - -ABORT default: defined as abort() - Defines how to abort on failed checks. On most systems, a failed - check cannot die with an "assert" or even print an informative - message, because the underlying print routines in turn call malloc, - which will fail again. Generally, the best policy is to simply call - abort(). It's not very useful to do more than this because many - errors due to overwriting will show up as address faults (null, odd - addresses etc) rather than malloc-triggered checks, so will also - abort. Also, most compilers know that abort() does not return, so - can better optimize code conditionally calling it. - -PROCEED_ON_ERROR default: defined as 0 (false) - Controls whether detected bad addresses cause them to bypassed - rather than aborting. If set, detected bad arguments to free and - realloc are ignored. And all bookkeeping information is zeroed out - upon a detected overwrite of freed heap space, thus losing the - ability to ever return it from malloc again, but enabling the - application to proceed. If PROCEED_ON_ERROR is defined, the - static variable malloc_corruption_error_count is compiled in - and can be examined to see if errors have occurred. This option - generates slower code than the default abort policy. - -DEBUG default: NOT defined - The DEBUG setting is mainly intended for people trying to modify - this code or diagnose problems when porting to new platforms. - However, it may also be able to better isolate user errors than just - using runtime checks. The assertions in the check routines spell - out in more detail the assumptions and invariants underlying the - algorithms. The checking is fairly extensive, and will slow down - execution noticeably. Calling malloc_stats or mallinfo with DEBUG - set will attempt to check every non-mmapped allocated and free chunk - in the course of computing the summaries. - -ABORT_ON_ASSERT_FAILURE default: defined as 1 (true) - Debugging assertion failures can be nearly impossible if your - version of the assert macro causes malloc to be called, which will - lead to a cascade of further failures, blowing the runtime stack. - ABORT_ON_ASSERT_FAILURE cause assertions failures to call abort(), - which will usually make debugging easier. - -MALLOC_FAILURE_ACTION default: sets errno to ENOMEM, or no-op on win32 - The action to take before "return 0" when malloc fails to be able to - return memory because there is none available. - -HAVE_MORECORE default: 1 (true) unless win32 or ONLY_MSPACES - True if this system supports sbrk or an emulation of it. - -MORECORE default: sbrk - The name of the sbrk-style system routine to call to obtain more - memory. See below for guidance on writing custom MORECORE - functions. The type of the argument to sbrk/MORECORE varies across - systems. It cannot be size_t, because it supports negative - arguments, so it is normally the signed type of the same width as - size_t (sometimes declared as "intptr_t"). It doesn't much matter - though. Internally, we only call it with arguments less than half - the max value of a size_t, which should work across all reasonable - possibilities, although sometimes generating compiler warnings. See - near the end of this file for guidelines for creating a custom - version of MORECORE. - -MORECORE_CONTIGUOUS default: 1 (true) - If true, take advantage of fact that consecutive calls to MORECORE - with positive arguments always return contiguous increasing - addresses. This is true of unix sbrk. It does not hurt too much to - set it true anyway, since malloc copes with non-contiguities. - Setting it false when definitely non-contiguous saves time - and possibly wasted space it would take to discover this though. - -MORECORE_CANNOT_TRIM default: NOT defined - True if MORECORE cannot release space back to the system when given - negative arguments. This is generally necessary only if you are - using a hand-crafted MORECORE function that cannot handle negative - arguments. - -HAVE_MMAP default: 1 (true) - True if this system supports mmap or an emulation of it. If so, and - HAVE_MORECORE is not true, MMAP is used for all system - allocation. If set and HAVE_MORECORE is true as well, MMAP is - primarily used to directly allocate very large blocks. It is also - used as a backup strategy in cases where MORECORE fails to provide - space from system. Note: A single call to MUNMAP is assumed to be - able to unmap memory that may have be allocated using multiple calls - to MMAP, so long as they are adjacent. - -HAVE_MREMAP default: 1 on linux, else 0 - If true realloc() uses mremap() to re-allocate large blocks and - extend or shrink allocation spaces. - -MMAP_CLEARS default: 1 on unix - True if mmap clears memory so calloc doesn't need to. This is true - for standard unix mmap using /dev/zero. - -USE_BUILTIN_FFS default: 0 (i.e., not used) - Causes malloc to use the builtin ffs() function to compute indices. - Some compilers may recognize and intrinsify ffs to be faster than the - supplied C version. Also, the case of x86 using gcc is special-cased - to an asm instruction, so is already as fast as it can be, and so - this setting has no effect. (On most x86s, the asm version is only - slightly faster than the C version.) - -malloc_getpagesize default: derive from system includes, or 4096. - The system page size. To the extent possible, this malloc manages - memory from the system in page-size units. This may be (and - usually is) a function rather than a constant. This is ignored - if WIN32, where page size is determined using getSystemInfo during - initialization. - -USE_DEV_RANDOM default: 0 (i.e., not used) - Causes malloc to use /dev/random to initialize secure magic seed for - stamping footers. Otherwise, the current time is used. - -NO_MALLINFO default: 0 - If defined, don't compile "mallinfo". This can be a simple way - of dealing with mismatches between system declarations and - those in this file. - -MALLINFO_FIELD_TYPE default: size_t - The type of the fields in the mallinfo struct. This was originally - defined as "int" in SVID etc, but is more usefully defined as - size_t. The value is used only if HAVE_USR_INCLUDE_MALLOC_H is not set - -REALLOC_ZERO_BYTES_FREES default: not defined - This should be set if a call to realloc with zero bytes should - be the same as a call to free. Some people think it should. Otherwise, - since this malloc returns a unique pointer for malloc(0), so does - realloc(p, 0). - -LACKS_UNISTD_H, LACKS_FCNTL_H, LACKS_SYS_PARAM_H, LACKS_SYS_MMAN_H -LACKS_STRINGS_H, LACKS_STRING_H, LACKS_SYS_TYPES_H, LACKS_ERRNO_H -LACKS_STDLIB_H default: NOT defined unless on WIN32 - Define these if your system does not have these header files. - You might need to manually insert some of the declarations they provide. - -DEFAULT_GRANULARITY default: page size if MORECORE_CONTIGUOUS, - system_info.dwAllocationGranularity in WIN32, - otherwise 64K. - Also settable using mallopt(M_GRANULARITY, x) - The unit for allocating and deallocating memory from the system. On - most systems with contiguous MORECORE, there is no reason to - make this more than a page. However, systems with MMAP tend to - either require or encourage larger granularities. You can increase - this value to prevent system allocation functions to be called so - often, especially if they are slow. The value must be at least one - page and must be a power of two. Setting to 0 causes initialization - to either page size or win32 region size. (Note: In previous - versions of malloc, the equivalent of this option was called - "TOP_PAD") - -DEFAULT_TRIM_THRESHOLD default: 2MB - Also settable using mallopt(M_TRIM_THRESHOLD, x) - The maximum amount of unused top-most memory to keep before - releasing via malloc_trim in free(). Automatic trimming is mainly - useful in long-lived programs using contiguous MORECORE. Because - trimming via sbrk can be slow on some systems, and can sometimes be - wasteful (in cases where programs immediately afterward allocate - more large chunks) the value should be high enough so that your - overall system performance would improve by releasing this much - memory. As a rough guide, you might set to a value close to the - average size of a process (program) running on your system. - Releasing this much memory would allow such a process to run in - memory. Generally, it is worth tuning trim thresholds when a - program undergoes phases where several large chunks are allocated - and released in ways that can reuse each other's storage, perhaps - mixed with phases where there are no such chunks at all. The trim - value must be greater than page size to have any useful effect. To - disable trimming completely, you can set to MAX_SIZE_T. Note that the trick - some people use of mallocing a huge space and then freeing it at - program startup, in an attempt to reserve system memory, doesn't - have the intended effect under automatic trimming, since that memory - will immediately be returned to the system. - -DEFAULT_MMAP_THRESHOLD default: 256K - Also settable using mallopt(M_MMAP_THRESHOLD, x) - The request size threshold for using MMAP to directly service a - request. Requests of at least this size that cannot be allocated - using already-existing space will be serviced via mmap. (If enough - normal freed space already exists it is used instead.) Using mmap - segregates relatively large chunks of memory so that they can be - individually obtained and released from the host system. A request - serviced through mmap is never reused by any other request (at least - not directly; the system may just so happen to remap successive - requests to the same locations). Segregating space in this way has - the benefits that: Mmapped space can always be individually released - back to the system, which helps keep the system level memory demands - of a long-lived program low. Also, mapped memory doesn't become - `locked' between other chunks, as can happen with normally allocated - chunks, which means that even trimming via malloc_trim would not - release them. However, it has the disadvantage that the space - cannot be reclaimed, consolidated, and then used to service later - requests, as happens with normal chunks. The advantages of mmap - nearly always outweigh disadvantages for "large" chunks, but the - value of "large" may vary across systems. The default is an - empirically derived value that works well in most systems. You can - disable mmap by setting to MAX_SIZE_T. - -*/ - -#ifndef WIN32 -#ifdef _WIN32 -#define WIN32 1 -#endif /* _WIN32 */ -#endif /* WIN32 */ -#ifdef WIN32 -#define WIN32_LEAN_AND_MEAN -#include -#define HAVE_MMAP 1 -#define HAVE_MORECORE 0 -#define LACKS_UNISTD_H -#define LACKS_SYS_PARAM_H -#define LACKS_SYS_MMAN_H -#define LACKS_STRING_H -#define LACKS_STRINGS_H -#define LACKS_SYS_TYPES_H -#define LACKS_ERRNO_H -#define MALLOC_FAILURE_ACTION -#define MMAP_CLEARS 0 /* WINCE and some others apparently don't clear */ -#endif /* WIN32 */ - -#if defined(DARWIN) || defined(_DARWIN) -/* Mac OSX docs advise not to use sbrk; it seems better to use mmap */ -#ifndef HAVE_MORECORE -#define HAVE_MORECORE 0 -#define HAVE_MMAP 1 -#endif /* HAVE_MORECORE */ -#endif /* DARWIN */ - -#ifndef LACKS_SYS_TYPES_H -#include /* For size_t */ -#endif /* LACKS_SYS_TYPES_H */ -#ifdef __CYGWIN__ -#include "cygmalloc.h" -#endif /* __CYGWIN__ */ - -/* The maximum possible size_t value has all bits set */ -#define MAX_SIZE_T (~(size_t)0) - -#ifndef ONLY_MSPACES -#define ONLY_MSPACES 0 -#endif /* ONLY_MSPACES */ -#ifndef MSPACES -#if ONLY_MSPACES -#define MSPACES 1 -#else /* ONLY_MSPACES */ -#define MSPACES 0 -#endif /* ONLY_MSPACES */ -#endif /* MSPACES */ -#ifndef MALLOC_ALIGNMENT -#define MALLOC_ALIGNMENT ((size_t)8U) -#endif /* MALLOC_ALIGNMENT */ -#ifndef FOOTERS -#define FOOTERS 0 -#endif /* FOOTERS */ -#ifndef ABORT -#define ABORT abort() -#endif /* ABORT */ -#ifndef ABORT_ON_ASSERT_FAILURE -#define ABORT_ON_ASSERT_FAILURE 1 -#endif /* ABORT_ON_ASSERT_FAILURE */ -#ifndef PROCEED_ON_ERROR -#define PROCEED_ON_ERROR 0 -#endif /* PROCEED_ON_ERROR */ -#ifndef USE_LOCKS -#define USE_LOCKS 0 -#endif /* USE_LOCKS */ -#ifndef INSECURE -#define INSECURE 0 -#endif /* INSECURE */ -#ifndef HAVE_MMAP -#define HAVE_MMAP 1 -#endif /* HAVE_MMAP */ -#ifndef MMAP_CLEARS -#define MMAP_CLEARS 1 -#endif /* MMAP_CLEARS */ -#ifndef HAVE_MREMAP -#ifdef linux -#define HAVE_MREMAP 1 -#else /* linux */ -#define HAVE_MREMAP 0 -#endif /* linux */ -#endif /* HAVE_MREMAP */ -#ifndef MALLOC_FAILURE_ACTION -#define MALLOC_FAILURE_ACTION errno = ENOMEM; -#endif /* MALLOC_FAILURE_ACTION */ -#ifndef HAVE_MORECORE -#if ONLY_MSPACES -#define HAVE_MORECORE 0 -#else /* ONLY_MSPACES */ -#define HAVE_MORECORE 1 -#endif /* ONLY_MSPACES */ -#endif /* HAVE_MORECORE */ -#if !HAVE_MORECORE -#define MORECORE_CONTIGUOUS 0 -#else /* !HAVE_MORECORE */ -#ifndef MORECORE -#define MORECORE sbrk -#endif /* MORECORE */ -#ifndef MORECORE_CONTIGUOUS -#define MORECORE_CONTIGUOUS 1 -#endif /* MORECORE_CONTIGUOUS */ -#endif /* HAVE_MORECORE */ -#ifndef DEFAULT_GRANULARITY -#if MORECORE_CONTIGUOUS -#define DEFAULT_GRANULARITY (0) /* 0 means to compute in init_mparams */ -#else /* MORECORE_CONTIGUOUS */ -#define DEFAULT_GRANULARITY ((size_t)64U * (size_t)1024U) -#endif /* MORECORE_CONTIGUOUS */ -#endif /* DEFAULT_GRANULARITY */ -#ifndef DEFAULT_TRIM_THRESHOLD -#ifndef MORECORE_CANNOT_TRIM -#define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U) -#else /* MORECORE_CANNOT_TRIM */ -#define DEFAULT_TRIM_THRESHOLD MAX_SIZE_T -#endif /* MORECORE_CANNOT_TRIM */ -#endif /* DEFAULT_TRIM_THRESHOLD */ -#ifndef DEFAULT_MMAP_THRESHOLD -#if HAVE_MMAP -#define DEFAULT_MMAP_THRESHOLD ((size_t)256U * (size_t)1024U) -#else /* HAVE_MMAP */ -#define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T -#endif /* HAVE_MMAP */ -#endif /* DEFAULT_MMAP_THRESHOLD */ -#ifndef USE_BUILTIN_FFS -#define USE_BUILTIN_FFS 0 -#endif /* USE_BUILTIN_FFS */ -#ifndef USE_DEV_RANDOM -#define USE_DEV_RANDOM 0 -#endif /* USE_DEV_RANDOM */ -#ifndef NO_MALLINFO -#define NO_MALLINFO 0 -#endif /* NO_MALLINFO */ -#ifndef MALLINFO_FIELD_TYPE -#define MALLINFO_FIELD_TYPE size_t -#endif /* MALLINFO_FIELD_TYPE */ - -/* - mallopt tuning options. SVID/XPG defines four standard parameter - numbers for mallopt, normally defined in malloc.h. None of these - are used in this malloc, so setting them has no effect. But this - malloc does support the following options. -*/ - -#define M_TRIM_THRESHOLD (-1) -#define M_GRANULARITY (-2) -#define M_MMAP_THRESHOLD (-3) - -/* ------------------------ Mallinfo declarations ------------------------ */ - -#if !NO_MALLINFO -/* - This version of malloc supports the standard SVID/XPG mallinfo - routine that returns a struct containing usage properties and - statistics. It should work on any system that has a - /usr/include/malloc.h defining struct mallinfo. The main - declaration needed is the mallinfo struct that is returned (by-copy) - by mallinfo(). The malloinfo struct contains a bunch of fields that - are not even meaningful in this version of malloc. These fields are - are instead filled by mallinfo() with other numbers that might be of - interest. - - HAVE_USR_INCLUDE_MALLOC_H should be set if you have a - /usr/include/malloc.h file that includes a declaration of struct - mallinfo. If so, it is included; else a compliant version is - declared below. These must be precisely the same for mallinfo() to - work. The original SVID version of this struct, defined on most - systems with mallinfo, declares all fields as ints. But some others - define as unsigned long. If your system defines the fields using a - type of different width than listed here, you MUST #include your - system version and #define HAVE_USR_INCLUDE_MALLOC_H. -*/ - -/* #define HAVE_USR_INCLUDE_MALLOC_H */ - -#ifdef HAVE_USR_INCLUDE_MALLOC_H -#include "/usr/include/malloc.h" -#else /* HAVE_USR_INCLUDE_MALLOC_H */ - -struct mallinfo { - MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */ - MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */ - MALLINFO_FIELD_TYPE smblks; /* always 0 */ - MALLINFO_FIELD_TYPE hblks; /* always 0 */ - MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */ - MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */ - MALLINFO_FIELD_TYPE fsmblks; /* always 0 */ - MALLINFO_FIELD_TYPE uordblks; /* total allocated space */ - MALLINFO_FIELD_TYPE fordblks; /* total free space */ - MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */ -}; - -#endif /* HAVE_USR_INCLUDE_MALLOC_H */ -#endif /* NO_MALLINFO */ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#if !ONLY_MSPACES - -/* ------------------- Declarations of public routines ------------------- */ - -#ifndef USE_DL_PREFIX -#define dlcalloc calloc -#define dlfree free -#define dlmalloc malloc -#define dlmemalign memalign -#define dlrealloc realloc -#define dlvalloc valloc -#define dlpvalloc pvalloc -#define dlmallinfo mallinfo -#define dlmallopt mallopt -#define dlmalloc_trim malloc_trim -#define dlmalloc_stats malloc_stats -#define dlmalloc_usable_size malloc_usable_size -#define dlmalloc_footprint malloc_footprint -#define dlmalloc_max_footprint malloc_max_footprint -#define dlindependent_calloc independent_calloc -#define dlindependent_comalloc independent_comalloc -#endif /* USE_DL_PREFIX */ - - -/* - malloc(size_t n) - Returns a pointer to a newly allocated chunk of at least n bytes, or - null if no space is available, in which case errno is set to ENOMEM - on ANSI C systems. - - If n is zero, malloc returns a minimum-sized chunk. (The minimum - size is 16 bytes on most 32bit systems, and 32 bytes on 64bit - systems.) Note that size_t is an unsigned type, so calls with - arguments that would be negative if signed are interpreted as - requests for huge amounts of space, which will often fail. The - maximum supported value of n differs across systems, but is in all - cases less than the maximum representable value of a size_t. -*/ -void* dlmalloc(size_t); - -/* - free(void* p) - Releases the chunk of memory pointed to by p, that had been previously - allocated using malloc or a related routine such as realloc. - It has no effect if p is null. If p was not malloced or already - freed, free(p) will by default cause the current program to abort. -*/ -void dlfree(void*); - -/* - calloc(size_t n_elements, size_t element_size); - Returns a pointer to n_elements * element_size bytes, with all locations - set to zero. -*/ -void* dlcalloc(size_t, size_t); - -/* - realloc(void* p, size_t n) - Returns a pointer to a chunk of size n that contains the same data - as does chunk p up to the minimum of (n, p's size) bytes, or null - if no space is available. - - The returned pointer may or may not be the same as p. The algorithm - prefers extending p in most cases when possible, otherwise it - employs the equivalent of a malloc-copy-free sequence. - - If p is null, realloc is equivalent to malloc. - - If space is not available, realloc returns null, errno is set (if on - ANSI) and p is NOT freed. - - if n is for fewer bytes than already held by p, the newly unused - space is lopped off and freed if possible. realloc with a size - argument of zero (re)allocates a minimum-sized chunk. - - The old unix realloc convention of allowing the last-free'd chunk - to be used as an argument to realloc is not supported. -*/ - -void* dlrealloc(void*, size_t); - -/* - memalign(size_t alignment, size_t n); - Returns a pointer to a newly allocated chunk of n bytes, aligned - in accord with the alignment argument. - - The alignment argument should be a power of two. If the argument is - not a power of two, the nearest greater power is used. - 8-byte alignment is guaranteed by normal malloc calls, so don't - bother calling memalign with an argument of 8 or less. - - Overreliance on memalign is a sure way to fragment space. -*/ -void* dlmemalign(size_t, size_t); - -/* - valloc(size_t n); - Equivalent to memalign(pagesize, n), where pagesize is the page - size of the system. If the pagesize is unknown, 4096 is used. -*/ -void* dlvalloc(size_t); - -/* - mallopt(int parameter_number, int parameter_value) - Sets tunable parameters The format is to provide a - (parameter-number, parameter-value) pair. mallopt then sets the - corresponding parameter to the argument value if it can (i.e., so - long as the value is meaningful), and returns 1 if successful else - 0. SVID/XPG/ANSI defines four standard param numbers for mallopt, - normally defined in malloc.h. None of these are use in this malloc, - so setting them has no effect. But this malloc also supports other - options in mallopt. See below for details. Briefly, supported - parameters are as follows (listed defaults are for "typical" - configurations). - - Symbol param # default allowed param values - M_TRIM_THRESHOLD -1 2*1024*1024 any (MAX_SIZE_T disables) - M_GRANULARITY -2 page size any power of 2 >= page size - M_MMAP_THRESHOLD -3 256*1024 any (or 0 if no MMAP support) -*/ -int dlmallopt(int, int); - -/* - malloc_footprint(); - Returns the number of bytes obtained from the system. The total - number of bytes allocated by malloc, realloc etc., is less than this - value. Unlike mallinfo, this function returns only a precomputed - result, so can be called frequently to monitor memory consumption. - Even if locks are otherwise defined, this function does not use them, - so results might not be up to date. -*/ -size_t dlmalloc_footprint(void); - -/* - malloc_max_footprint(); - Returns the maximum number of bytes obtained from the system. This - value will be greater than current footprint if deallocated space - has been reclaimed by the system. The peak number of bytes allocated - by malloc, realloc etc., is less than this value. Unlike mallinfo, - this function returns only a precomputed result, so can be called - frequently to monitor memory consumption. Even if locks are - otherwise defined, this function does not use them, so results might - not be up to date. -*/ -size_t dlmalloc_max_footprint(void); - -#if !NO_MALLINFO -/* - mallinfo() - Returns (by copy) a struct containing various summary statistics: - - arena: current total non-mmapped bytes allocated from system - ordblks: the number of free chunks - smblks: always zero. - hblks: current number of mmapped regions - hblkhd: total bytes held in mmapped regions - usmblks: the maximum total allocated space. This will be greater - than current total if trimming has occurred. - fsmblks: always zero - uordblks: current total allocated space (normal or mmapped) - fordblks: total free space - keepcost: the maximum number of bytes that could ideally be released - back to system via malloc_trim. ("ideally" means that - it ignores page restrictions etc.) - - Because these fields are ints, but internal bookkeeping may - be kept as longs, the reported values may wrap around zero and - thus be inaccurate. -*/ -struct mallinfo dlmallinfo(void); -#endif /* NO_MALLINFO */ - -/* - independent_calloc(size_t n_elements, size_t element_size, void* chunks[]); - - independent_calloc is similar to calloc, but instead of returning a - single cleared space, it returns an array of pointers to n_elements - independent elements that can hold contents of size elem_size, each - of which starts out cleared, and can be independently freed, - realloc'ed etc. The elements are guaranteed to be adjacently - allocated (this is not guaranteed to occur with multiple callocs or - mallocs), which may also improve cache locality in some - applications. - - The "chunks" argument is optional (i.e., may be null, which is - probably the most typical usage). If it is null, the returned array - is itself dynamically allocated and should also be freed when it is - no longer needed. Otherwise, the chunks array must be of at least - n_elements in length. It is filled in with the pointers to the - chunks. - - In either case, independent_calloc returns this pointer array, or - null if the allocation failed. If n_elements is zero and "chunks" - is null, it returns a chunk representing an array with zero elements - (which should be freed if not wanted). - - Each element must be individually freed when it is no longer - needed. If you'd like to instead be able to free all at once, you - should instead use regular calloc and assign pointers into this - space to represent elements. (In this case though, you cannot - independently free elements.) - - independent_calloc simplifies and speeds up implementations of many - kinds of pools. It may also be useful when constructing large data - structures that initially have a fixed number of fixed-sized nodes, - but the number is not known at compile time, and some of the nodes - may later need to be freed. For example: - - struct Node { int item; struct Node* next; }; - - struct Node* build_list() { - struct Node** pool; - int n = read_number_of_nodes_needed(); - if (n <= 0) return 0; - pool = (struct Node**)(independent_calloc(n, sizeof(struct Node), 0); - if (pool == 0) die(); - // organize into a linked list... - struct Node* first = pool[0]; - for (i = 0; i < n-1; ++i) - pool[i]->next = pool[i+1]; - free(pool); // Can now free the array (or not, if it is needed later) - return first; - } -*/ -void** dlindependent_calloc(size_t, size_t, void**); - -/* - independent_comalloc(size_t n_elements, size_t sizes[], void* chunks[]); - - independent_comalloc allocates, all at once, a set of n_elements - chunks with sizes indicated in the "sizes" array. It returns - an array of pointers to these elements, each of which can be - independently freed, realloc'ed etc. The elements are guaranteed to - be adjacently allocated (this is not guaranteed to occur with - multiple callocs or mallocs), which may also improve cache locality - in some applications. - - The "chunks" argument is optional (i.e., may be null). If it is null - the returned array is itself dynamically allocated and should also - be freed when it is no longer needed. Otherwise, the chunks array - must be of at least n_elements in length. It is filled in with the - pointers to the chunks. - - In either case, independent_comalloc returns this pointer array, or - null if the allocation failed. If n_elements is zero and chunks is - null, it returns a chunk representing an array with zero elements - (which should be freed if not wanted). - - Each element must be individually freed when it is no longer - needed. If you'd like to instead be able to free all at once, you - should instead use a single regular malloc, and assign pointers at - particular offsets in the aggregate space. (In this case though, you - cannot independently free elements.) - - independent_comallac differs from independent_calloc in that each - element may have a different size, and also that it does not - automatically clear elements. - - independent_comalloc can be used to speed up allocation in cases - where several structs or objects must always be allocated at the - same time. For example: - - struct Head { ... } - struct Foot { ... } - - void send_message(char* msg) { - int msglen = strlen(msg); - size_t sizes[3] = { sizeof(struct Head), msglen, sizeof(struct Foot) }; - void* chunks[3]; - if (independent_comalloc(3, sizes, chunks) == 0) - die(); - struct Head* head = (struct Head*)(chunks[0]); - char* body = (char*)(chunks[1]); - struct Foot* foot = (struct Foot*)(chunks[2]); - // ... - } - - In general though, independent_comalloc is worth using only for - larger values of n_elements. For small values, you probably won't - detect enough difference from series of malloc calls to bother. - - Overuse of independent_comalloc can increase overall memory usage, - since it cannot reuse existing noncontiguous small chunks that - might be available for some of the elements. -*/ -void** dlindependent_comalloc(size_t, size_t*, void**); - - -/* - pvalloc(size_t n); - Equivalent to valloc(minimum-page-that-holds(n)), that is, - round up n to nearest pagesize. - */ -void* dlpvalloc(size_t); - -/* - malloc_trim(size_t pad); - - If possible, gives memory back to the system (via negative arguments - to sbrk) if there is unused memory at the `high' end of the malloc - pool or in unused MMAP segments. You can call this after freeing - large blocks of memory to potentially reduce the system-level memory - requirements of a program. However, it cannot guarantee to reduce - memory. Under some allocation patterns, some large free blocks of - memory will be locked between two used chunks, so they cannot be - given back to the system. - - The `pad' argument to malloc_trim represents the amount of free - trailing space to leave untrimmed. If this argument is zero, only - the minimum amount of memory to maintain internal data structures - will be left. Non-zero arguments can be supplied to maintain enough - trailing space to service future expected allocations without having - to re-obtain memory from the system. - - Malloc_trim returns 1 if it actually released any memory, else 0. -*/ -int dlmalloc_trim(size_t); - -/* - malloc_usable_size(void* p); - - Returns the number of bytes you can actually use in - an allocated chunk, which may be more than you requested (although - often not) due to alignment and minimum size constraints. - You can use this many bytes without worrying about - overwriting other allocated objects. This is not a particularly great - programming practice. malloc_usable_size can be more useful in - debugging and assertions, for example: - - p = malloc(n); - assert(malloc_usable_size(p) >= 256); -*/ -size_t dlmalloc_usable_size(void*); - -/* - malloc_stats(); - Prints on stderr the amount of space obtained from the system (both - via sbrk and mmap), the maximum amount (which may be more than - current if malloc_trim and/or munmap got called), and the current - number of bytes allocated via malloc (or realloc, etc) but not yet - freed. Note that this is the number of bytes allocated, not the - number requested. It will be larger than the number requested - because of alignment and bookkeeping overhead. Because it includes - alignment wastage as being in use, this figure may be greater than - zero even when no user-level chunks are allocated. - - The reported current and maximum system memory can be inaccurate if - a program makes other calls to system memory allocation functions - (normally sbrk) outside of malloc. - - malloc_stats prints only the most commonly interesting statistics. - More information can be obtained by calling mallinfo. -*/ -void dlmalloc_stats(void); - -#endif /* ONLY_MSPACES */ - -#if MSPACES - -/* - mspace is an opaque type representing an independent - region of space that supports mspace_malloc, etc. -*/ -typedef void* mspace; - -/* - create_mspace creates and returns a new independent space with the - given initial capacity, or, if 0, the default granularity size. It - returns null if there is no system memory available to create the - space. If argument locked is non-zero, the space uses a separate - lock to control access. The capacity of the space will grow - dynamically as needed to service mspace_malloc requests. You can - control the sizes of incremental increases of this space by - compiling with a different DEFAULT_GRANULARITY or dynamically - setting with mallopt(M_GRANULARITY, value). -*/ -mspace create_mspace(size_t capacity, int locked); - -/* - destroy_mspace destroys the given space, and attempts to return all - of its memory back to the system, returning the total number of - bytes freed. After destruction, the results of access to all memory - used by the space become undefined. -*/ -size_t destroy_mspace(mspace msp); - -/* - create_mspace_with_base uses the memory supplied as the initial base - of a new mspace. Part (less than 128*sizeof(size_t) bytes) of this - space is used for bookkeeping, so the capacity must be at least this - large. (Otherwise 0 is returned.) When this initial space is - exhausted, additional memory will be obtained from the system. - Destroying this space will deallocate all additionally allocated - space (if possible) but not the initial base. -*/ -mspace create_mspace_with_base(void* base, size_t capacity, int locked); - -/* - mspace_malloc behaves as malloc, but operates within - the given space. -*/ -void* mspace_malloc(mspace msp, size_t bytes); - -/* - mspace_free behaves as free, but operates within - the given space. - - If compiled with FOOTERS==1, mspace_free is not actually needed. - free may be called instead of mspace_free because freed chunks from - any space are handled by their originating spaces. -*/ -void mspace_free(mspace msp, void* mem); - -/* - mspace_realloc behaves as realloc, but operates within - the given space. - - If compiled with FOOTERS==1, mspace_realloc is not actually - needed. realloc may be called instead of mspace_realloc because - realloced chunks from any space are handled by their originating - spaces. -*/ -void* mspace_realloc(mspace msp, void* mem, size_t newsize); - -/* - mspace_calloc behaves as calloc, but operates within - the given space. -*/ -void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size); - -/* - mspace_memalign behaves as memalign, but operates within - the given space. -*/ -void* mspace_memalign(mspace msp, size_t alignment, size_t bytes); - -/* - mspace_independent_calloc behaves as independent_calloc, but - operates within the given space. -*/ -void** mspace_independent_calloc(mspace msp, size_t n_elements, - size_t elem_size, void* chunks[]); - -/* - mspace_independent_comalloc behaves as independent_comalloc, but - operates within the given space. -*/ -void** mspace_independent_comalloc(mspace msp, size_t n_elements, - size_t sizes[], void* chunks[]); - -/* - mspace_footprint() returns the number of bytes obtained from the - system for this space. -*/ -size_t mspace_footprint(mspace msp); - -/* - mspace_max_footprint() returns the peak number of bytes obtained from the - system for this space. -*/ -size_t mspace_max_footprint(mspace msp); - - -#if !NO_MALLINFO -/* - mspace_mallinfo behaves as mallinfo, but reports properties of - the given space. -*/ -struct mallinfo mspace_mallinfo(mspace msp); -#endif /* NO_MALLINFO */ - -/* - mspace_malloc_stats behaves as malloc_stats, but reports - properties of the given space. -*/ -void mspace_malloc_stats(mspace msp); - -/* - mspace_trim behaves as malloc_trim, but - operates within the given space. -*/ -int mspace_trim(mspace msp, size_t pad); - -/* - An alias for mallopt. -*/ -int mspace_mallopt(int, int); - -#endif /* MSPACES */ - -#ifdef __cplusplus -}; /* end of extern "C" */ -#endif /* __cplusplus */ - -/* - ======================================================================== - To make a fully customizable malloc.h header file, cut everything - above this line, put into file malloc.h, edit to suit, and #include it - on the next line, as well as in programs that use this malloc. - ======================================================================== -*/ - -/* #include "malloc.h" */ - -/*------------------------------ internal #includes ---------------------- */ - -#ifdef WIN32 -#pragma warning( disable : 4146 ) /* no "unsigned" warnings */ -#endif /* WIN32 */ - -#include /* for printing in malloc_stats */ - -#ifndef LACKS_ERRNO_H -#include /* for MALLOC_FAILURE_ACTION */ -#endif /* LACKS_ERRNO_H */ -#if FOOTERS -#include /* for magic initialization */ -#endif /* FOOTERS */ -#ifndef LACKS_STDLIB_H -#include /* for abort() */ -#endif /* LACKS_STDLIB_H */ -#ifdef DEBUG -#if ABORT_ON_ASSERT_FAILURE -#define assert(x) if(!(x)) ABORT -#else /* ABORT_ON_ASSERT_FAILURE */ -#include -#endif /* ABORT_ON_ASSERT_FAILURE */ -#else /* DEBUG */ -#define assert(x) -#endif /* DEBUG */ -#ifndef LACKS_STRING_H -#include /* for memset etc */ -#endif /* LACKS_STRING_H */ -#if USE_BUILTIN_FFS -#ifndef LACKS_STRINGS_H -#include /* for ffs */ -#endif /* LACKS_STRINGS_H */ -#endif /* USE_BUILTIN_FFS */ -#if HAVE_MMAP -#ifndef LACKS_SYS_MMAN_H -#include /* for mmap */ -#endif /* LACKS_SYS_MMAN_H */ -#ifndef LACKS_FCNTL_H -#include -#endif /* LACKS_FCNTL_H */ -#endif /* HAVE_MMAP */ -#if HAVE_MORECORE -#ifndef LACKS_UNISTD_H -#include /* for sbrk */ -#else /* LACKS_UNISTD_H */ -#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) -extern void* sbrk(ptrdiff_t); -#endif /* FreeBSD etc */ -#endif /* LACKS_UNISTD_H */ -#endif /* HAVE_MMAP */ - -#ifndef WIN32 -#ifndef malloc_getpagesize -# ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */ -# ifndef _SC_PAGE_SIZE -# define _SC_PAGE_SIZE _SC_PAGESIZE -# endif -# endif -# ifdef _SC_PAGE_SIZE -# define malloc_getpagesize sysconf(_SC_PAGE_SIZE) -# else -# if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE) - extern size_t getpagesize(); -# define malloc_getpagesize getpagesize() -# else -# ifdef WIN32 /* use supplied emulation of getpagesize */ -# define malloc_getpagesize getpagesize() -# else -# ifndef LACKS_SYS_PARAM_H -# include -# endif -# ifdef EXEC_PAGESIZE -# define malloc_getpagesize EXEC_PAGESIZE -# else -# ifdef NBPG -# ifndef CLSIZE -# define malloc_getpagesize NBPG -# else -# define malloc_getpagesize (NBPG * CLSIZE) -# endif -# else -# ifdef NBPC -# define malloc_getpagesize NBPC -# else -# ifdef PAGESIZE -# define malloc_getpagesize PAGESIZE -# else /* just guess */ -# define malloc_getpagesize ((size_t)4096U) -# endif -# endif -# endif -# endif -# endif -# endif -# endif -#endif -#endif - -/* ------------------- size_t and alignment properties -------------------- */ - -/* The byte and bit size of a size_t */ -#define SIZE_T_SIZE (sizeof(size_t)) -#define SIZE_T_BITSIZE (sizeof(size_t) << 3) - -/* Some constants coerced to size_t */ -/* Annoying but necessary to avoid errors on some plaftorms */ -#define SIZE_T_ZERO ((size_t)0) -#define SIZE_T_ONE ((size_t)1) -#define SIZE_T_TWO ((size_t)2) -#define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1) -#define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2) -#define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES) -#define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U) - -/* The bit mask value corresponding to MALLOC_ALIGNMENT */ -#define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE) - -/* True if address a has acceptable alignment */ -#define is_aligned(A) (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0) - -/* the number of bytes to offset an address to align it */ -#define align_offset(A)\ - ((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\ - ((MALLOC_ALIGNMENT - ((size_t)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK)) - -/* -------------------------- MMAP preliminaries ------------------------- */ - -/* - If HAVE_MORECORE or HAVE_MMAP are false, we just define calls and - checks to fail so compiler optimizer can delete code rather than - using so many "#if"s. -*/ - - -/* MORECORE and MMAP must return MFAIL on failure */ -#define MFAIL ((void*)(MAX_SIZE_T)) -#define CMFAIL ((char*)(MFAIL)) /* defined for convenience */ - -#if !HAVE_MMAP -#define IS_MMAPPED_BIT (SIZE_T_ZERO) -#define USE_MMAP_BIT (SIZE_T_ZERO) -#define CALL_MMAP(s) MFAIL -#define CALL_MUNMAP(a, s) (-1) -#define DIRECT_MMAP(s) MFAIL - -#else /* HAVE_MMAP */ -#define IS_MMAPPED_BIT (SIZE_T_ONE) -#define USE_MMAP_BIT (SIZE_T_ONE) - -#ifndef WIN32 -#define CALL_MUNMAP(a, s) munmap((a), (s)) -#define MMAP_PROT (PROT_READ|PROT_WRITE) -#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) -#define MAP_ANONYMOUS MAP_ANON -#endif /* MAP_ANON */ -#ifdef MAP_ANONYMOUS -#define MMAP_FLAGS (MAP_PRIVATE|MAP_ANONYMOUS) -#define CALL_MMAP(s) mmap(0, (s), MMAP_PROT, MMAP_FLAGS, -1, 0) -#else /* MAP_ANONYMOUS */ -/* - Nearly all versions of mmap support MAP_ANONYMOUS, so the following - is unlikely to be needed, but is supplied just in case. -*/ -#define MMAP_FLAGS (MAP_PRIVATE) -static int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */ -#define CALL_MMAP(s) ((dev_zero_fd < 0) ? \ - (dev_zero_fd = open("/dev/zero", O_RDWR), \ - mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) : \ - mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) -#endif /* MAP_ANONYMOUS */ - -#define DIRECT_MMAP(s) CALL_MMAP(s) -#else /* WIN32 */ - -/* Win32 MMAP via VirtualAlloc */ -static void* win32mmap(size_t size) { - void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); - return (ptr != 0)? ptr: MFAIL; -} - -/* For direct MMAP, use MEM_TOP_DOWN to minimize interference */ -static void* win32direct_mmap(size_t size) { - void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, - PAGE_READWRITE); - return (ptr != 0)? ptr: MFAIL; -} - -/* This function supports releasing coalesed segments */ -static int win32munmap(void* ptr, size_t size) { - MEMORY_BASIC_INFORMATION minfo; - char* cptr = ptr; - while (size) { - if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0) - return -1; - if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr || - minfo.State != MEM_COMMIT || minfo.RegionSize > size) - return -1; - if (VirtualFree(cptr, 0, MEM_RELEASE) == 0) - return -1; - cptr += minfo.RegionSize; - size -= minfo.RegionSize; - } - return 0; -} - -#define CALL_MMAP(s) win32mmap(s) -#define CALL_MUNMAP(a, s) win32munmap((a), (s)) -#define DIRECT_MMAP(s) win32direct_mmap(s) -#endif /* WIN32 */ -#endif /* HAVE_MMAP */ - -#if HAVE_MMAP && HAVE_MREMAP -#define CALL_MREMAP(addr, osz, nsz, mv) mremap((addr), (osz), (nsz), (mv)) -#else /* HAVE_MMAP && HAVE_MREMAP */ -#define CALL_MREMAP(addr, osz, nsz, mv) MFAIL -#endif /* HAVE_MMAP && HAVE_MREMAP */ - -#if HAVE_MORECORE -#define CALL_MORECORE(S) MORECORE(S) -#else /* HAVE_MORECORE */ -#define CALL_MORECORE(S) MFAIL -#endif /* HAVE_MORECORE */ - -/* mstate bit set if continguous morecore disabled or failed */ -#define USE_NONCONTIGUOUS_BIT (4U) - -/* segment bit set in create_mspace_with_base */ -#define EXTERN_BIT (8U) - - -/* --------------------------- Lock preliminaries ------------------------ */ - -#if USE_LOCKS - -/* - When locks are defined, there are up to two global locks: - - * If HAVE_MORECORE, morecore_mutex protects sequences of calls to - MORECORE. In many cases sys_alloc requires two calls, that should - not be interleaved with calls by other threads. This does not - protect against direct calls to MORECORE by other threads not - using this lock, so there is still code to cope the best we can on - interference. - - * magic_init_mutex ensures that mparams.magic and other - unique mparams values are initialized only once. -*/ - -#ifndef WIN32 -/* By default use posix locks */ -#include -#define MLOCK_T pthread_mutex_t -#define INITIAL_LOCK(l) pthread_mutex_init(l, NULL) -#define ACQUIRE_LOCK(l) pthread_mutex_lock(l) -#define RELEASE_LOCK(l) pthread_mutex_unlock(l) - -#if HAVE_MORECORE -static MLOCK_T morecore_mutex = PTHREAD_MUTEX_INITIALIZER; -#endif /* HAVE_MORECORE */ - -static MLOCK_T magic_init_mutex = PTHREAD_MUTEX_INITIALIZER; - -#else /* WIN32 */ -/* - Because lock-protected regions have bounded times, and there - are no recursive lock calls, we can use simple spinlocks. -*/ - -#define MLOCK_T long -static int win32_acquire_lock (MLOCK_T *sl) { - for (;;) { -#ifdef InterlockedCompareExchangePointer - if (!InterlockedCompareExchange(sl, 1, 0)) - return 0; -#else /* Use older void* version */ - if (!InterlockedCompareExchange((void**)sl, (void*)1, (void*)0)) - return 0; -#endif /* InterlockedCompareExchangePointer */ - Sleep (0); - } -} - -static void win32_release_lock (MLOCK_T *sl) { - InterlockedExchange (sl, 0); -} - -#define INITIAL_LOCK(l) *(l)=0 -#define ACQUIRE_LOCK(l) win32_acquire_lock(l) -#define RELEASE_LOCK(l) win32_release_lock(l) -#if HAVE_MORECORE -static MLOCK_T morecore_mutex; -#endif /* HAVE_MORECORE */ -static MLOCK_T magic_init_mutex; -#endif /* WIN32 */ - -#define USE_LOCK_BIT (2U) -#else /* USE_LOCKS */ -#define USE_LOCK_BIT (0U) -#define INITIAL_LOCK(l) -#endif /* USE_LOCKS */ - -#if USE_LOCKS && HAVE_MORECORE -#define ACQUIRE_MORECORE_LOCK() ACQUIRE_LOCK(&morecore_mutex); -#define RELEASE_MORECORE_LOCK() RELEASE_LOCK(&morecore_mutex); -#else /* USE_LOCKS && HAVE_MORECORE */ -#define ACQUIRE_MORECORE_LOCK() -#define RELEASE_MORECORE_LOCK() -#endif /* USE_LOCKS && HAVE_MORECORE */ - -#if USE_LOCKS -#define ACQUIRE_MAGIC_INIT_LOCK() ACQUIRE_LOCK(&magic_init_mutex); -#define RELEASE_MAGIC_INIT_LOCK() RELEASE_LOCK(&magic_init_mutex); -#else /* USE_LOCKS */ -#define ACQUIRE_MAGIC_INIT_LOCK() -#define RELEASE_MAGIC_INIT_LOCK() -#endif /* USE_LOCKS */ - - -/* ----------------------- Chunk representations ------------------------ */ - -/* - (The following includes lightly edited explanations by Colin Plumb.) - - The malloc_chunk declaration below is misleading (but accurate and - necessary). It declares a "view" into memory allowing access to - necessary fields at known offsets from a given base. - - Chunks of memory are maintained using a `boundary tag' method as - originally described by Knuth. (See the paper by Paul Wilson - ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps for a survey of such - techniques.) Sizes of free chunks are stored both in the front of - each chunk and at the end. This makes consolidating fragmented - chunks into bigger chunks fast. The head fields also hold bits - representing whether chunks are free or in use. - - Here are some pictures to make it clearer. They are "exploded" to - show that the state of a chunk can be thought of as extending from - the high 31 bits of the head field of its header through the - prev_foot and PINUSE_BIT bit of the following chunk header. - - A chunk that's in use looks like: - - chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of previous chunk (if P = 1) | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |P| - | Size of this chunk 1| +-+ - mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | | - +- -+ - | | - +- -+ - | : - +- size - sizeof(size_t) available payload bytes -+ - : | - chunk-> +- -+ - | | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |1| - | Size of next chunk (may or may not be in use) | +-+ - mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - And if it's free, it looks like this: - - chunk-> +- -+ - | User payload (must be in use, or we would have merged!) | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |P| - | Size of this chunk 0| +-+ - mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Next pointer | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Prev pointer | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | : - +- size - sizeof(struct chunk) unused bytes -+ - : | - chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of this chunk | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0| - | Size of next chunk (must be in use, or we would have merged)| +-+ - mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | : - +- User payload -+ - : | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - |0| - +-+ - Note that since we always merge adjacent free chunks, the chunks - adjacent to a free chunk must be in use. - - Given a pointer to a chunk (which can be derived trivially from the - payload pointer) we can, in O(1) time, find out whether the adjacent - chunks are free, and if so, unlink them from the lists that they - are on and merge them with the current chunk. - - Chunks always begin on even word boundaries, so the mem portion - (which is returned to the user) is also on an even word boundary, and - thus at least double-word aligned. - - The P (PINUSE_BIT) bit, stored in the unused low-order bit of the - chunk size (which is always a multiple of two words), is an in-use - bit for the *previous* chunk. If that bit is *clear*, then the - word before the current chunk size contains the previous chunk - size, and can be used to find the front of the previous chunk. - The very first chunk allocated always has this bit set, preventing - access to non-existent (or non-owned) memory. If pinuse is set for - any given chunk, then you CANNOT determine the size of the - previous chunk, and might even get a memory addressing fault when - trying to do so. - - The C (CINUSE_BIT) bit, stored in the unused second-lowest bit of - the chunk size redundantly records whether the current chunk is - inuse. This redundancy enables usage checks within free and realloc, - and reduces indirection when freeing and consolidating chunks. - - Each freshly allocated chunk must have both cinuse and pinuse set. - That is, each allocated chunk borders either a previously allocated - and still in-use chunk, or the base of its memory arena. This is - ensured by making all allocations from the the `lowest' part of any - found chunk. Further, no free chunk physically borders another one, - so each free chunk is known to be preceded and followed by either - inuse chunks or the ends of memory. - - Note that the `foot' of the current chunk is actually represented - as the prev_foot of the NEXT chunk. This makes it easier to - deal with alignments etc but can be very confusing when trying - to extend or adapt this code. - - The exceptions to all this are - - 1. The special chunk `top' is the top-most available chunk (i.e., - the one bordering the end of available memory). It is treated - specially. Top is never included in any bin, is used only if - no other chunk is available, and is released back to the - system if it is very large (see M_TRIM_THRESHOLD). In effect, - the top chunk is treated as larger (and thus less well - fitting) than any other available chunk. The top chunk - doesn't update its trailing size field since there is no next - contiguous chunk that would have to index off it. However, - space is still allocated for it (TOP_FOOT_SIZE) to enable - separation or merging when space is extended. - - 3. Chunks allocated via mmap, which have the lowest-order bit - (IS_MMAPPED_BIT) set in their prev_foot fields, and do not set - PINUSE_BIT in their head fields. Because they are allocated - one-by-one, each must carry its own prev_foot field, which is - also used to hold the offset this chunk has within its mmapped - region, which is needed to preserve alignment. Each mmapped - chunk is trailed by the first two fields of a fake next-chunk - for sake of usage checks. - -*/ - -struct malloc_chunk { - size_t prev_foot; /* Size of previous chunk (if free). */ - size_t head; /* Size and inuse bits. */ - struct malloc_chunk* fd; /* double links -- used only if free. */ - struct malloc_chunk* bk; -}; - -typedef struct malloc_chunk mchunk; -typedef struct malloc_chunk* mchunkptr; -typedef struct malloc_chunk* sbinptr; /* The type of bins of chunks */ -typedef unsigned int bindex_t; /* Described below */ -typedef unsigned int binmap_t; /* Described below */ -typedef unsigned int flag_t; /* The type of various bit flag sets */ - -/* ------------------- Chunks sizes and alignments ----------------------- */ - -#define MCHUNK_SIZE (sizeof(mchunk)) - -#if FOOTERS -#define CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) -#else /* FOOTERS */ -#define CHUNK_OVERHEAD (SIZE_T_SIZE) -#endif /* FOOTERS */ - -/* MMapped chunks need a second word of overhead ... */ -#define MMAP_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) -/* ... and additional padding for fake next-chunk at foot */ -#define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES) - -/* The smallest size we can malloc is an aligned minimal chunk */ -#define MIN_CHUNK_SIZE\ - ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) - -/* conversion from malloc headers to user pointers, and back */ -#define chunk2mem(p) ((void*)((char*)(p) + TWO_SIZE_T_SIZES)) -#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - TWO_SIZE_T_SIZES)) -/* chunk associated with aligned address A */ -#define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A))) - -/* Bounds on request (not chunk) sizes. */ -#define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2) -#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE) - -/* pad request bytes into a usable size */ -#define pad_request(req) \ - (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) - -/* pad request, checking for minimum (but not maximum) */ -#define request2size(req) \ - (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req)) - - -/* ------------------ Operations on head and foot fields ----------------- */ - -/* - The head field of a chunk is or'ed with PINUSE_BIT when previous - adjacent chunk in use, and or'ed with CINUSE_BIT if this chunk is in - use. If the chunk was obtained with mmap, the prev_foot field has - IS_MMAPPED_BIT set, otherwise holding the offset of the base of the - mmapped region to the base of the chunk. -*/ - -#define PINUSE_BIT (SIZE_T_ONE) -#define CINUSE_BIT (SIZE_T_TWO) -#define INUSE_BITS (PINUSE_BIT|CINUSE_BIT) - -/* Head value for fenceposts */ -#define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE) - -/* extraction of fields from head words */ -#define cinuse(p) ((p)->head & CINUSE_BIT) -#define pinuse(p) ((p)->head & PINUSE_BIT) -#define chunksize(p) ((p)->head & ~(INUSE_BITS)) - -#define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT) -#define clear_cinuse(p) ((p)->head &= ~CINUSE_BIT) - -/* Treat space at ptr +/- offset as a chunk */ -#define chunk_plus_offset(p, s) ((mchunkptr)(((char*)(p)) + (s))) -#define chunk_minus_offset(p, s) ((mchunkptr)(((char*)(p)) - (s))) - -/* Ptr to next or previous physical malloc_chunk. */ -#define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->head & ~INUSE_BITS))) -#define prev_chunk(p) ((mchunkptr)( ((char*)(p)) - ((p)->prev_foot) )) - -/* extract next chunk's pinuse bit */ -#define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT) - -/* Get/set size at footer */ -#define get_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot) -#define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s)) - -/* Set size, pinuse bit, and foot */ -#define set_size_and_pinuse_of_free_chunk(p, s)\ - ((p)->head = (s|PINUSE_BIT), set_foot(p, s)) - -/* Set size, pinuse bit, foot, and clear next pinuse */ -#define set_free_with_pinuse(p, s, n)\ - (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s)) - -#define is_mmapped(p)\ - (!((p)->head & PINUSE_BIT) && ((p)->prev_foot & IS_MMAPPED_BIT)) - -/* Get the internal overhead associated with chunk p */ -#define overhead_for(p)\ - (is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD) - -/* Return true if malloced space is not necessarily cleared */ -#if MMAP_CLEARS -#define calloc_must_clear(p) (!is_mmapped(p)) -#else /* MMAP_CLEARS */ -#define calloc_must_clear(p) (1) -#endif /* MMAP_CLEARS */ - -/* ---------------------- Overlaid data structures ----------------------- */ - -/* - When chunks are not in use, they are treated as nodes of either - lists or trees. - - "Small" chunks are stored in circular doubly-linked lists, and look - like this: - - chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of previous chunk | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - `head:' | Size of chunk, in bytes |P| - mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Forward pointer to next chunk in list | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Back pointer to previous chunk in list | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Unused space (may be 0 bytes long) . - . . - . | -nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - `foot:' | Size of chunk, in bytes | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - Larger chunks are kept in a form of bitwise digital trees (aka - tries) keyed on chunksizes. Because malloc_tree_chunks are only for - free chunks greater than 256 bytes, their size doesn't impose any - constraints on user chunk sizes. Each node looks like: - - chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of previous chunk | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - `head:' | Size of chunk, in bytes |P| - mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Forward pointer to next chunk of same size | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Back pointer to previous chunk of same size | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Pointer to left child (child[0]) | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Pointer to right child (child[1]) | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Pointer to parent | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | bin index of this chunk | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Unused space . - . | -nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - `foot:' | Size of chunk, in bytes | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - Each tree holding treenodes is a tree of unique chunk sizes. Chunks - of the same size are arranged in a circularly-linked list, with only - the oldest chunk (the next to be used, in our FIFO ordering) - actually in the tree. (Tree members are distinguished by a non-null - parent pointer.) If a chunk with the same size an an existing node - is inserted, it is linked off the existing node using pointers that - work in the same way as fd/bk pointers of small chunks. - - Each tree contains a power of 2 sized range of chunk sizes (the - smallest is 0x100 <= x < 0x180), which is is divided in half at each - tree level, with the chunks in the smaller half of the range (0x100 - <= x < 0x140 for the top nose) in the left subtree and the larger - half (0x140 <= x < 0x180) in the right subtree. This is, of course, - done by inspecting individual bits. - - Using these rules, each node's left subtree contains all smaller - sizes than its right subtree. However, the node at the root of each - subtree has no particular ordering relationship to either. (The - dividing line between the subtree sizes is based on trie relation.) - If we remove the last chunk of a given size from the interior of the - tree, we need to replace it with a leaf node. The tree ordering - rules permit a node to be replaced by any leaf below it. - - The smallest chunk in a tree (a common operation in a best-fit - allocator) can be found by walking a path to the leftmost leaf in - the tree. Unlike a usual binary tree, where we follow left child - pointers until we reach a null, here we follow the right child - pointer any time the left one is null, until we reach a leaf with - both child pointers null. The smallest chunk in the tree will be - somewhere along that path. - - The worst case number of steps to add, find, or remove a node is - bounded by the number of bits differentiating chunks within - bins. Under current bin calculations, this ranges from 6 up to 21 - (for 32 bit sizes) or up to 53 (for 64 bit sizes). The typical case - is of course much better. -*/ - -struct malloc_tree_chunk { - /* The first four fields must be compatible with malloc_chunk */ - size_t prev_foot; - size_t head; - struct malloc_tree_chunk* fd; - struct malloc_tree_chunk* bk; - - struct malloc_tree_chunk* child[2]; - struct malloc_tree_chunk* parent; - bindex_t index; -}; - -typedef struct malloc_tree_chunk tchunk; -typedef struct malloc_tree_chunk* tchunkptr; -typedef struct malloc_tree_chunk* tbinptr; /* The type of bins of trees */ - -/* A little helper macro for trees */ -#define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1]) - -/* ----------------------------- Segments -------------------------------- */ - -/* - Each malloc space may include non-contiguous segments, held in a - list headed by an embedded malloc_segment record representing the - top-most space. Segments also include flags holding properties of - the space. Large chunks that are directly allocated by mmap are not - included in this list. They are instead independently created and - destroyed without otherwise keeping track of them. - - Segment management mainly comes into play for spaces allocated by - MMAP. Any call to MMAP might or might not return memory that is - adjacent to an existing segment. MORECORE normally contiguously - extends the current space, so this space is almost always adjacent, - which is simpler and faster to deal with. (This is why MORECORE is - used preferentially to MMAP when both are available -- see - sys_alloc.) When allocating using MMAP, we don't use any of the - hinting mechanisms (inconsistently) supported in various - implementations of unix mmap, or distinguish reserving from - committing memory. Instead, we just ask for space, and exploit - contiguity when we get it. It is probably possible to do - better than this on some systems, but no general scheme seems - to be significantly better. - - Management entails a simpler variant of the consolidation scheme - used for chunks to reduce fragmentation -- new adjacent memory is - normally prepended or appended to an existing segment. However, - there are limitations compared to chunk consolidation that mostly - reflect the fact that segment processing is relatively infrequent - (occurring only when getting memory from system) and that we - don't expect to have huge numbers of segments: - - * Segments are not indexed, so traversal requires linear scans. (It - would be possible to index these, but is not worth the extra - overhead and complexity for most programs on most platforms.) - * New segments are only appended to old ones when holding top-most - memory; if they cannot be prepended to others, they are held in - different segments. - - Except for the top-most segment of an mstate, each segment record - is kept at the tail of its segment. Segments are added by pushing - segment records onto the list headed by &mstate.seg for the - containing mstate. - - Segment flags control allocation/merge/deallocation policies: - * If EXTERN_BIT set, then we did not allocate this segment, - and so should not try to deallocate or merge with others. - (This currently holds only for the initial segment passed - into create_mspace_with_base.) - * If IS_MMAPPED_BIT set, the segment may be merged with - other surrounding mmapped segments and trimmed/de-allocated - using munmap. - * If neither bit is set, then the segment was obtained using - MORECORE so can be merged with surrounding MORECORE'd segments - and deallocated/trimmed using MORECORE with negative arguments. -*/ - -struct malloc_segment { - char* base; /* base address */ - size_t size; /* allocated size */ - struct malloc_segment* next; /* ptr to next segment */ - flag_t sflags; /* mmap and extern flag */ -}; - -#define is_mmapped_segment(S) ((S)->sflags & IS_MMAPPED_BIT) -#define is_extern_segment(S) ((S)->sflags & EXTERN_BIT) - -typedef struct malloc_segment msegment; -typedef struct malloc_segment* msegmentptr; - -/* ---------------------------- malloc_state ----------------------------- */ - -/* - A malloc_state holds all of the bookkeeping for a space. - The main fields are: - - Top - The topmost chunk of the currently active segment. Its size is - cached in topsize. The actual size of topmost space is - topsize+TOP_FOOT_SIZE, which includes space reserved for adding - fenceposts and segment records if necessary when getting more - space from the system. The size at which to autotrim top is - cached from mparams in trim_check, except that it is disabled if - an autotrim fails. - - Designated victim (dv) - This is the preferred chunk for servicing small requests that - don't have exact fits. It is normally the chunk split off most - recently to service another small request. Its size is cached in - dvsize. The link fields of this chunk are not maintained since it - is not kept in a bin. - - SmallBins - An array of bin headers for free chunks. These bins hold chunks - with sizes less than MIN_LARGE_SIZE bytes. Each bin contains - chunks of all the same size, spaced 8 bytes apart. To simplify - use in double-linked lists, each bin header acts as a malloc_chunk - pointing to the real first node, if it exists (else pointing to - itself). This avoids special-casing for headers. But to avoid - waste, we allocate only the fd/bk pointers of bins, and then use - repositioning tricks to treat these as the fields of a chunk. - - TreeBins - Treebins are pointers to the roots of trees holding a range of - sizes. There are 2 equally spaced treebins for each power of two - from TREE_SHIFT to TREE_SHIFT+16. The last bin holds anything - larger. - - Bin maps - There is one bit map for small bins ("smallmap") and one for - treebins ("treemap). Each bin sets its bit when non-empty, and - clears the bit when empty. Bit operations are then used to avoid - bin-by-bin searching -- nearly all "search" is done without ever - looking at bins that won't be selected. The bit maps - conservatively use 32 bits per map word, even if on 64bit system. - For a good description of some of the bit-based techniques used - here, see Henry S. Warren Jr's book "Hacker's Delight" (and - supplement at http://hackersdelight.org/). Many of these are - intended to reduce the branchiness of paths through malloc etc, as - well as to reduce the number of memory locations read or written. - - Segments - A list of segments headed by an embedded malloc_segment record - representing the initial space. - - Address check support - The least_addr field is the least address ever obtained from - MORECORE or MMAP. Attempted frees and reallocs of any address less - than this are trapped (unless INSECURE is defined). - - Magic tag - A cross-check field that should always hold same value as mparams.magic. - - Flags - Bits recording whether to use MMAP, locks, or contiguous MORECORE - - Statistics - Each space keeps track of current and maximum system memory - obtained via MORECORE or MMAP. - - Locking - If USE_LOCKS is defined, the "mutex" lock is acquired and released - around every public call using this mspace. -*/ - -/* Bin types, widths and sizes */ -#define NSMALLBINS (32U) -#define NTREEBINS (32U) -#define SMALLBIN_SHIFT (3U) -#define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT) -#define TREEBIN_SHIFT (8U) -#define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT) -#define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE) -#define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD) - -struct malloc_state { - binmap_t smallmap; - binmap_t treemap; - size_t dvsize; - size_t topsize; - char* least_addr; - mchunkptr dv; - mchunkptr top; - size_t trim_check; - size_t magic; - mchunkptr smallbins[(NSMALLBINS+1)*2]; - tbinptr treebins[NTREEBINS]; - size_t footprint; - size_t max_footprint; - flag_t mflags; -#if USE_LOCKS - MLOCK_T mutex; /* locate lock among fields that rarely change */ -#endif /* USE_LOCKS */ - msegment seg; -}; - -typedef struct malloc_state* mstate; - -/* ------------- Global malloc_state and malloc_params ------------------- */ - -/* - malloc_params holds global properties, including those that can be - dynamically set using mallopt. There is a single instance, mparams, - initialized in init_mparams. -*/ - -struct malloc_params { - size_t magic; - size_t page_size; - size_t granularity; - size_t mmap_threshold; - size_t trim_threshold; - flag_t default_mflags; -}; - -static struct malloc_params mparams; - -/* The global malloc_state used for all non-"mspace" calls */ -static struct malloc_state _gm_; -#define gm (&_gm_) -#define is_global(M) ((M) == &_gm_) -#define is_initialized(M) ((M)->top != 0) - -/* -------------------------- system alloc setup ------------------------- */ - -/* Operations on mflags */ - -#define use_lock(M) ((M)->mflags & USE_LOCK_BIT) -#define enable_lock(M) ((M)->mflags |= USE_LOCK_BIT) -#define disable_lock(M) ((M)->mflags &= ~USE_LOCK_BIT) - -#define use_mmap(M) ((M)->mflags & USE_MMAP_BIT) -#define enable_mmap(M) ((M)->mflags |= USE_MMAP_BIT) -#define disable_mmap(M) ((M)->mflags &= ~USE_MMAP_BIT) - -#define use_noncontiguous(M) ((M)->mflags & USE_NONCONTIGUOUS_BIT) -#define disable_contiguous(M) ((M)->mflags |= USE_NONCONTIGUOUS_BIT) - -#define set_lock(M,L)\ - ((M)->mflags = (L)?\ - ((M)->mflags | USE_LOCK_BIT) :\ - ((M)->mflags & ~USE_LOCK_BIT)) - -/* page-align a size */ -#define page_align(S)\ - (((S) + (mparams.page_size)) & ~(mparams.page_size - SIZE_T_ONE)) - -/* granularity-align a size */ -#define granularity_align(S)\ - (((S) + (mparams.granularity)) & ~(mparams.granularity - SIZE_T_ONE)) - -#define is_page_aligned(S)\ - (((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0) -#define is_granularity_aligned(S)\ - (((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0) - -/* True if segment S holds address A */ -#define segment_holds(S, A)\ - ((char*)(A) >= S->base && (char*)(A) < S->base + S->size) - -/* Return segment holding given address */ -static msegmentptr segment_holding(mstate m, char* addr) { - msegmentptr sp = &m->seg; - for (;;) { - if (addr >= sp->base && addr < sp->base + sp->size) - return sp; - if ((sp = sp->next) == 0) - return 0; - } -} - -/* Return true if segment contains a segment link */ -static int has_segment_link(mstate m, msegmentptr ss) { - msegmentptr sp = &m->seg; - for (;;) { - if ((char*)sp >= ss->base && (char*)sp < ss->base + ss->size) - return 1; - if ((sp = sp->next) == 0) - return 0; - } -} - -#ifndef MORECORE_CANNOT_TRIM -#define should_trim(M,s) ((s) > (M)->trim_check) -#else /* MORECORE_CANNOT_TRIM */ -#define should_trim(M,s) (0) -#endif /* MORECORE_CANNOT_TRIM */ - -/* - TOP_FOOT_SIZE is padding at the end of a segment, including space - that may be needed to place segment records and fenceposts when new - noncontiguous segments are added. -*/ -#define TOP_FOOT_SIZE\ - (align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE) - - -/* ------------------------------- Hooks -------------------------------- */ - -/* - PREACTION should be defined to return 0 on success, and nonzero on - failure. If you are not using locking, you can redefine these to do - anything you like. -*/ - -#if USE_LOCKS - -/* Ensure locks are initialized */ -#define GLOBALLY_INITIALIZE() (mparams.page_size == 0 && init_mparams()) - -#define PREACTION(M) ((GLOBALLY_INITIALIZE() || use_lock(M))? ACQUIRE_LOCK(&(M)->mutex) : 0) -#define POSTACTION(M) { if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); } -#else /* USE_LOCKS */ - -#ifndef PREACTION -#define PREACTION(M) (0) -#endif /* PREACTION */ - -#ifndef POSTACTION -#define POSTACTION(M) -#endif /* POSTACTION */ - -#endif /* USE_LOCKS */ - -/* - CORRUPTION_ERROR_ACTION is triggered upon detected bad addresses. - USAGE_ERROR_ACTION is triggered on detected bad frees and - reallocs. The argument p is an address that might have triggered the - fault. It is ignored by the two predefined actions, but might be - useful in custom actions that try to help diagnose errors. -*/ - -#if PROCEED_ON_ERROR - -/* A count of the number of corruption errors causing resets */ -int malloc_corruption_error_count; - -/* default corruption action */ -static void reset_on_error(mstate m); - -#define CORRUPTION_ERROR_ACTION(m) reset_on_error(m) -#define USAGE_ERROR_ACTION(m, p) - -#else /* PROCEED_ON_ERROR */ - -#ifndef CORRUPTION_ERROR_ACTION -#define CORRUPTION_ERROR_ACTION(m) ABORT -#endif /* CORRUPTION_ERROR_ACTION */ - -#ifndef USAGE_ERROR_ACTION -#define USAGE_ERROR_ACTION(m,p) ABORT -#endif /* USAGE_ERROR_ACTION */ - -#endif /* PROCEED_ON_ERROR */ - -/* -------------------------- Debugging setup ---------------------------- */ - -#if ! DEBUG - -#define check_free_chunk(M,P) -#define check_inuse_chunk(M,P) -#define check_malloced_chunk(M,P,N) -#define check_mmapped_chunk(M,P) -#define check_malloc_state(M) -#define check_top_chunk(M,P) - -#else /* DEBUG */ -#define check_free_chunk(M,P) do_check_free_chunk(M,P) -#define check_inuse_chunk(M,P) do_check_inuse_chunk(M,P) -#define check_top_chunk(M,P) do_check_top_chunk(M,P) -#define check_malloced_chunk(M,P,N) do_check_malloced_chunk(M,P,N) -#define check_mmapped_chunk(M,P) do_check_mmapped_chunk(M,P) -#define check_malloc_state(M) do_check_malloc_state(M) - -static void do_check_any_chunk(mstate m, mchunkptr p); -static void do_check_top_chunk(mstate m, mchunkptr p); -static void do_check_mmapped_chunk(mstate m, mchunkptr p); -static void do_check_inuse_chunk(mstate m, mchunkptr p); -static void do_check_free_chunk(mstate m, mchunkptr p); -static void do_check_malloced_chunk(mstate m, void* mem, size_t s); -static void do_check_tree(mstate m, tchunkptr t); -static void do_check_treebin(mstate m, bindex_t i); -static void do_check_smallbin(mstate m, bindex_t i); -static void do_check_malloc_state(mstate m); -static int bin_find(mstate m, mchunkptr x); -static size_t traverse_and_check(mstate m); -#endif /* DEBUG */ - -/* ---------------------------- Indexing Bins ---------------------------- */ - -#define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS) -#define small_index(s) ((s) >> SMALLBIN_SHIFT) -#define small_index2size(i) ((i) << SMALLBIN_SHIFT) -#define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE)) - -/* addressing by index. See above about smallbin repositioning */ -#define smallbin_at(M, i) ((sbinptr)((char*)&((M)->smallbins[(i)<<1]))) -#define treebin_at(M,i) (&((M)->treebins[i])) - -/* assign tree index for size S to variable I */ -#if defined(__GNUC__) && defined(i386) -#define compute_tree_index(S, I)\ -{\ - size_t X = S >> TREEBIN_SHIFT;\ - if (X == 0)\ - I = 0;\ - else if (X > 0xFFFF)\ - I = NTREEBINS-1;\ - else {\ - unsigned int K;\ - __asm__("bsrl %1,%0\n\t" : "=r" (K) : "rm" (X));\ - I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ - }\ -} -#else /* GNUC */ -#define compute_tree_index(S, I)\ -{\ - size_t X = S >> TREEBIN_SHIFT;\ - if (X == 0)\ - I = 0;\ - else if (X > 0xFFFF)\ - I = NTREEBINS-1;\ - else {\ - unsigned int Y = (unsigned int)X;\ - unsigned int N = ((Y - 0x100) >> 16) & 8;\ - unsigned int K = (((Y <<= N) - 0x1000) >> 16) & 4;\ - N += K;\ - N += K = (((Y <<= K) - 0x4000) >> 16) & 2;\ - K = 14 - N + ((Y <<= K) >> 15);\ - I = (K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1));\ - }\ -} -#endif /* GNUC */ - -/* Bit representing maximum resolved size in a treebin at i */ -#define bit_for_tree_index(i) \ - (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2) - -/* Shift placing maximum resolved bit in a treebin at i as sign bit */ -#define leftshift_for_tree_index(i) \ - ((i == NTREEBINS-1)? 0 : \ - ((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2))) - -/* The size of the smallest chunk held in bin with index i */ -#define minsize_for_tree_index(i) \ - ((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \ - (((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1))) - - -/* ------------------------ Operations on bin maps ----------------------- */ - -/* bit corresponding to given index */ -#define idx2bit(i) ((binmap_t)(1) << (i)) - -/* Mark/Clear bits with given index */ -#define mark_smallmap(M,i) ((M)->smallmap |= idx2bit(i)) -#define clear_smallmap(M,i) ((M)->smallmap &= ~idx2bit(i)) -#define smallmap_is_marked(M,i) ((M)->smallmap & idx2bit(i)) - -#define mark_treemap(M,i) ((M)->treemap |= idx2bit(i)) -#define clear_treemap(M,i) ((M)->treemap &= ~idx2bit(i)) -#define treemap_is_marked(M,i) ((M)->treemap & idx2bit(i)) - -/* index corresponding to given bit */ - -#if defined(__GNUC__) && defined(i386) -#define compute_bit2idx(X, I)\ -{\ - unsigned int J;\ - __asm__("bsfl %1,%0\n\t" : "=r" (J) : "rm" (X));\ - I = (bindex_t)J;\ -} - -#else /* GNUC */ -#if USE_BUILTIN_FFS -#define compute_bit2idx(X, I) I = ffs(X)-1 - -#else /* USE_BUILTIN_FFS */ -#define compute_bit2idx(X, I)\ -{\ - unsigned int Y = X - 1;\ - unsigned int K = Y >> (16-4) & 16;\ - unsigned int N = K; Y >>= K;\ - N += K = Y >> (8-3) & 8; Y >>= K;\ - N += K = Y >> (4-2) & 4; Y >>= K;\ - N += K = Y >> (2-1) & 2; Y >>= K;\ - N += K = Y >> (1-0) & 1; Y >>= K;\ - I = (bindex_t)(N + Y);\ -} -#endif /* USE_BUILTIN_FFS */ -#endif /* GNUC */ - -/* isolate the least set bit of a bitmap */ -#define least_bit(x) ((x) & -(x)) - -/* mask with all bits to left of least bit of x on */ -#define left_bits(x) ((x<<1) | -(x<<1)) - -/* mask with all bits to left of or equal to least bit of x on */ -#define same_or_left_bits(x) ((x) | -(x)) - - -/* ----------------------- Runtime Check Support ------------------------- */ - -/* - For security, the main invariant is that malloc/free/etc never - writes to a static address other than malloc_state, unless static - malloc_state itself has been corrupted, which cannot occur via - malloc (because of these checks). In essence this means that we - believe all pointers, sizes, maps etc held in malloc_state, but - check all of those linked or offsetted from other embedded data - structures. These checks are interspersed with main code in a way - that tends to minimize their run-time cost. - - When FOOTERS is defined, in addition to range checking, we also - verify footer fields of inuse chunks, which can be used guarantee - that the mstate controlling malloc/free is intact. This is a - streamlined version of the approach described by William Robertson - et al in "Run-time Detection of Heap-based Overflows" LISA'03 - http://www.usenix.org/events/lisa03/tech/robertson.html The footer - of an inuse chunk holds the xor of its mstate and a random seed, - that is checked upon calls to free() and realloc(). This is - (probablistically) unguessable from outside the program, but can be - computed by any code successfully malloc'ing any chunk, so does not - itself provide protection against code that has already broken - security through some other means. Unlike Robertson et al, we - always dynamically check addresses of all offset chunks (previous, - next, etc). This turns out to be cheaper than relying on hashes. -*/ - -#if !INSECURE -/* Check if address a is at least as high as any from MORECORE or MMAP */ -#define ok_address(M, a) ((char*)(a) >= (M)->least_addr) -/* Check if address of next chunk n is higher than base chunk p */ -#define ok_next(p, n) ((char*)(p) < (char*)(n)) -/* Check if p has its cinuse bit on */ -#define ok_cinuse(p) cinuse(p) -/* Check if p has its pinuse bit on */ -#define ok_pinuse(p) pinuse(p) - -#else /* !INSECURE */ -#define ok_address(M, a) (1) -#define ok_next(b, n) (1) -#define ok_cinuse(p) (1) -#define ok_pinuse(p) (1) -#endif /* !INSECURE */ - -#if (FOOTERS && !INSECURE) -/* Check if (alleged) mstate m has expected magic field */ -#define ok_magic(M) ((M)->magic == mparams.magic) -#else /* (FOOTERS && !INSECURE) */ -#define ok_magic(M) (1) -#endif /* (FOOTERS && !INSECURE) */ - - -/* In gcc, use __builtin_expect to minimize impact of checks */ -#if !INSECURE -#if defined(__GNUC__) && __GNUC__ >= 3 -#define RTCHECK(e) __builtin_expect(e, 1) -#else /* GNUC */ -#define RTCHECK(e) (e) -#endif /* GNUC */ -#else /* !INSECURE */ -#define RTCHECK(e) (1) -#endif /* !INSECURE */ - -/* macros to set up inuse chunks with or without footers */ - -#if !FOOTERS - -#define mark_inuse_foot(M,p,s) - -/* Set cinuse bit and pinuse bit of next chunk */ -#define set_inuse(M,p,s)\ - ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ - ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) - -/* Set cinuse and pinuse of this chunk and pinuse of next chunk */ -#define set_inuse_and_pinuse(M,p,s)\ - ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ - ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) - -/* Set size, cinuse and pinuse bit of this chunk */ -#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ - ((p)->head = (s|PINUSE_BIT|CINUSE_BIT)) - -#else /* FOOTERS */ - -/* Set foot of inuse chunk to be xor of mstate and seed */ -#define mark_inuse_foot(M,p,s)\ - (((mchunkptr)((char*)(p) + (s)))->prev_foot = ((size_t)(M) ^ mparams.magic)) - -#define get_mstate_for(p)\ - ((mstate)(((mchunkptr)((char*)(p) +\ - (chunksize(p))))->prev_foot ^ mparams.magic)) - -#define set_inuse(M,p,s)\ - ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ - (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT), \ - mark_inuse_foot(M,p,s)) - -#define set_inuse_and_pinuse(M,p,s)\ - ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ - (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT),\ - mark_inuse_foot(M,p,s)) - -#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ - ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ - mark_inuse_foot(M, p, s)) - -#endif /* !FOOTERS */ - -/* ---------------------------- setting mparams -------------------------- */ - -/* Initialize mparams */ -static int init_mparams(void) { - if (mparams.page_size == 0) { - size_t s; - - mparams.mmap_threshold = DEFAULT_MMAP_THRESHOLD; - mparams.trim_threshold = DEFAULT_TRIM_THRESHOLD; -#if MORECORE_CONTIGUOUS - mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT; -#else /* MORECORE_CONTIGUOUS */ - mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT|USE_NONCONTIGUOUS_BIT; -#endif /* MORECORE_CONTIGUOUS */ - -#if (FOOTERS && !INSECURE) - { -#if USE_DEV_RANDOM - int fd; - unsigned char buf[sizeof(size_t)]; - /* Try to use /dev/urandom, else fall back on using time */ - if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 && - read(fd, buf, sizeof(buf)) == sizeof(buf)) { - s = *((size_t *) buf); - close(fd); - } - else -#endif /* USE_DEV_RANDOM */ - s = (size_t)(time(0) ^ (size_t)0x55555555U); - - s |= (size_t)8U; /* ensure nonzero */ - s &= ~(size_t)7U; /* improve chances of fault for bad values */ - - } -#else /* (FOOTERS && !INSECURE) */ - s = (size_t)0x58585858U; -#endif /* (FOOTERS && !INSECURE) */ - ACQUIRE_MAGIC_INIT_LOCK(); - if (mparams.magic == 0) { - mparams.magic = s; - /* Set up lock for main malloc area */ - INITIAL_LOCK(&gm->mutex); - gm->mflags = mparams.default_mflags; - } - RELEASE_MAGIC_INIT_LOCK(); - -#ifndef WIN32 - mparams.page_size = malloc_getpagesize; - mparams.granularity = ((DEFAULT_GRANULARITY != 0)? - DEFAULT_GRANULARITY : mparams.page_size); -#else /* WIN32 */ - { - SYSTEM_INFO system_info; - GetSystemInfo(&system_info); - mparams.page_size = system_info.dwPageSize; - mparams.granularity = system_info.dwAllocationGranularity; - } -#endif /* WIN32 */ - - /* Sanity-check configuration: - size_t must be unsigned and as wide as pointer type. - ints must be at least 4 bytes. - alignment must be at least 8. - Alignment, min chunk size, and page size must all be powers of 2. - */ - if ((sizeof(size_t) != sizeof(char*)) || - (MAX_SIZE_T < MIN_CHUNK_SIZE) || - (sizeof(int) < 4) || - (MALLOC_ALIGNMENT < (size_t)8U) || - ((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT-SIZE_T_ONE)) != 0) || - ((MCHUNK_SIZE & (MCHUNK_SIZE-SIZE_T_ONE)) != 0) || - ((mparams.granularity & (mparams.granularity-SIZE_T_ONE)) != 0) || - ((mparams.page_size & (mparams.page_size-SIZE_T_ONE)) != 0)) - ABORT; - } - return 0; -} - -/* support for mallopt */ -static int change_mparam(int param_number, int value) { - size_t val = (size_t)value; - init_mparams(); - switch(param_number) { - case M_TRIM_THRESHOLD: - mparams.trim_threshold = val; - return 1; - case M_GRANULARITY: - if (val >= mparams.page_size && ((val & (val-1)) == 0)) { - mparams.granularity = val; - return 1; - } - else - return 0; - case M_MMAP_THRESHOLD: - mparams.mmap_threshold = val; - return 1; - default: - return 0; - } -} - -#if DEBUG -/* ------------------------- Debugging Support --------------------------- */ - -/* Check properties of any chunk, whether free, inuse, mmapped etc */ -static void do_check_any_chunk(mstate m, mchunkptr p) { - assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); - assert(ok_address(m, p)); -} - -/* Check properties of top chunk */ -static void do_check_top_chunk(mstate m, mchunkptr p) { - msegmentptr sp = segment_holding(m, (char*)p); - size_t sz = chunksize(p); - assert(sp != 0); - assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); - assert(ok_address(m, p)); - assert(sz == m->topsize); - assert(sz > 0); - assert(sz == ((sp->base + sp->size) - (char*)p) - TOP_FOOT_SIZE); - assert(pinuse(p)); - assert(!next_pinuse(p)); -} - -/* Check properties of (inuse) mmapped chunks */ -static void do_check_mmapped_chunk(mstate m, mchunkptr p) { - size_t sz = chunksize(p); - size_t len = (sz + (p->prev_foot & ~IS_MMAPPED_BIT) + MMAP_FOOT_PAD); - assert(is_mmapped(p)); - assert(use_mmap(m)); - assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); - assert(ok_address(m, p)); - assert(!is_small(sz)); - assert((len & (mparams.page_size-SIZE_T_ONE)) == 0); - assert(chunk_plus_offset(p, sz)->head == FENCEPOST_HEAD); - assert(chunk_plus_offset(p, sz+SIZE_T_SIZE)->head == 0); -} - -/* Check properties of inuse chunks */ -static void do_check_inuse_chunk(mstate m, mchunkptr p) { - do_check_any_chunk(m, p); - assert(cinuse(p)); - assert(next_pinuse(p)); - /* If not pinuse and not mmapped, previous chunk has OK offset */ - assert(is_mmapped(p) || pinuse(p) || next_chunk(prev_chunk(p)) == p); - if (is_mmapped(p)) - do_check_mmapped_chunk(m, p); -} - -/* Check properties of free chunks */ -static void do_check_free_chunk(mstate m, mchunkptr p) { - size_t sz = p->head & ~(PINUSE_BIT|CINUSE_BIT); - mchunkptr next = chunk_plus_offset(p, sz); - do_check_any_chunk(m, p); - assert(!cinuse(p)); - assert(!next_pinuse(p)); - assert (!is_mmapped(p)); - if (p != m->dv && p != m->top) { - if (sz >= MIN_CHUNK_SIZE) { - assert((sz & CHUNK_ALIGN_MASK) == 0); - assert(is_aligned(chunk2mem(p))); - assert(next->prev_foot == sz); - assert(pinuse(p)); - assert (next == m->top || cinuse(next)); - assert(p->fd->bk == p); - assert(p->bk->fd == p); - } - else /* markers are always of size SIZE_T_SIZE */ - assert(sz == SIZE_T_SIZE); - } -} - -/* Check properties of malloced chunks at the point they are malloced */ -static void do_check_malloced_chunk(mstate m, void* mem, size_t s) { - if (mem != 0) { - mchunkptr p = mem2chunk(mem); - size_t sz = p->head & ~(PINUSE_BIT|CINUSE_BIT); - do_check_inuse_chunk(m, p); - assert((sz & CHUNK_ALIGN_MASK) == 0); - assert(sz >= MIN_CHUNK_SIZE); - assert(sz >= s); - /* unless mmapped, size is less than MIN_CHUNK_SIZE more than request */ - assert(is_mmapped(p) || sz < (s + MIN_CHUNK_SIZE)); - } -} - -/* Check a tree and its subtrees. */ -static void do_check_tree(mstate m, tchunkptr t) { - tchunkptr head = 0; - tchunkptr u = t; - bindex_t tindex = t->index; - size_t tsize = chunksize(t); - bindex_t idx; - compute_tree_index(tsize, idx); - assert(tindex == idx); - assert(tsize >= MIN_LARGE_SIZE); - assert(tsize >= minsize_for_tree_index(idx)); - assert((idx == NTREEBINS-1) || (tsize < minsize_for_tree_index((idx+1)))); - - do { /* traverse through chain of same-sized nodes */ - do_check_any_chunk(m, ((mchunkptr)u)); - assert(u->index == tindex); - assert(chunksize(u) == tsize); - assert(!cinuse(u)); - assert(!next_pinuse(u)); - assert(u->fd->bk == u); - assert(u->bk->fd == u); - if (u->parent == 0) { - assert(u->child[0] == 0); - assert(u->child[1] == 0); - } - else { - assert(head == 0); /* only one node on chain has parent */ - head = u; - assert(u->parent != u); - assert (u->parent->child[0] == u || - u->parent->child[1] == u || - *((tbinptr*)(u->parent)) == u); - if (u->child[0] != 0) { - assert(u->child[0]->parent == u); - assert(u->child[0] != u); - do_check_tree(m, u->child[0]); - } - if (u->child[1] != 0) { - assert(u->child[1]->parent == u); - assert(u->child[1] != u); - do_check_tree(m, u->child[1]); - } - if (u->child[0] != 0 && u->child[1] != 0) { - assert(chunksize(u->child[0]) < chunksize(u->child[1])); - } - } - u = u->fd; - } while (u != t); - assert(head != 0); -} - -/* Check all the chunks in a treebin. */ -static void do_check_treebin(mstate m, bindex_t i) { - tbinptr* tb = treebin_at(m, i); - tchunkptr t = *tb; - int empty = (m->treemap & (1U << i)) == 0; - if (t == 0) - assert(empty); - if (!empty) - do_check_tree(m, t); -} - -/* Check all the chunks in a smallbin. */ -static void do_check_smallbin(mstate m, bindex_t i) { - sbinptr b = smallbin_at(m, i); - mchunkptr p = b->bk; - unsigned int empty = (m->smallmap & (1U << i)) == 0; - if (p == b) - assert(empty); - if (!empty) { - for (; p != b; p = p->bk) { - size_t size = chunksize(p); - mchunkptr q; - /* each chunk claims to be free */ - do_check_free_chunk(m, p); - /* chunk belongs in bin */ - assert(small_index(size) == i); - assert(p->bk == b || chunksize(p->bk) == chunksize(p)); - /* chunk is followed by an inuse chunk */ - q = next_chunk(p); - if (q->head != FENCEPOST_HEAD) - do_check_inuse_chunk(m, q); - } - } -} - -/* Find x in a bin. Used in other check functions. */ -static int bin_find(mstate m, mchunkptr x) { - size_t size = chunksize(x); - if (is_small(size)) { - bindex_t sidx = small_index(size); - sbinptr b = smallbin_at(m, sidx); - if (smallmap_is_marked(m, sidx)) { - mchunkptr p = b; - do { - if (p == x) - return 1; - } while ((p = p->fd) != b); - } - } - else { - bindex_t tidx; - compute_tree_index(size, tidx); - if (treemap_is_marked(m, tidx)) { - tchunkptr t = *treebin_at(m, tidx); - size_t sizebits = size << leftshift_for_tree_index(tidx); - while (t != 0 && chunksize(t) != size) { - t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; - sizebits <<= 1; - } - if (t != 0) { - tchunkptr u = t; - do { - if (u == (tchunkptr)x) - return 1; - } while ((u = u->fd) != t); - } - } - } - return 0; -} - -/* Traverse each chunk and check it; return total */ -static size_t traverse_and_check(mstate m) { - size_t sum = 0; - if (is_initialized(m)) { - msegmentptr s = &m->seg; - sum += m->topsize + TOP_FOOT_SIZE; - while (s != 0) { - mchunkptr q = align_as_chunk(s->base); - mchunkptr lastq = 0; - assert(pinuse(q)); - while (segment_holds(s, q) && - q != m->top && q->head != FENCEPOST_HEAD) { - sum += chunksize(q); - if (cinuse(q)) { - assert(!bin_find(m, q)); - do_check_inuse_chunk(m, q); - } - else { - assert(q == m->dv || bin_find(m, q)); - assert(lastq == 0 || cinuse(lastq)); /* Not 2 consecutive free */ - do_check_free_chunk(m, q); - } - lastq = q; - q = next_chunk(q); - } - s = s->next; - } - } - return sum; -} - -/* Check all properties of malloc_state. */ -static void do_check_malloc_state(mstate m) { - bindex_t i; - size_t total; - /* check bins */ - for (i = 0; i < NSMALLBINS; ++i) - do_check_smallbin(m, i); - for (i = 0; i < NTREEBINS; ++i) - do_check_treebin(m, i); - - if (m->dvsize != 0) { /* check dv chunk */ - do_check_any_chunk(m, m->dv); - assert(m->dvsize == chunksize(m->dv)); - assert(m->dvsize >= MIN_CHUNK_SIZE); - assert(bin_find(m, m->dv) == 0); - } - - if (m->top != 0) { /* check top chunk */ - do_check_top_chunk(m, m->top); - assert(m->topsize == chunksize(m->top)); - assert(m->topsize > 0); - assert(bin_find(m, m->top) == 0); - } - - total = traverse_and_check(m); - assert(total <= m->footprint); - assert(m->footprint <= m->max_footprint); -} -#endif /* DEBUG */ - -/* ----------------------------- statistics ------------------------------ */ - -#if !NO_MALLINFO -static struct mallinfo internal_mallinfo(mstate m) { - struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - if (!PREACTION(m)) { - check_malloc_state(m); - if (is_initialized(m)) { - size_t nfree = SIZE_T_ONE; /* top always free */ - size_t mfree = m->topsize + TOP_FOOT_SIZE; - size_t sum = mfree; - msegmentptr s = &m->seg; - while (s != 0) { - mchunkptr q = align_as_chunk(s->base); - while (segment_holds(s, q) && - q != m->top && q->head != FENCEPOST_HEAD) { - size_t sz = chunksize(q); - sum += sz; - if (!cinuse(q)) { - mfree += sz; - ++nfree; - } - q = next_chunk(q); - } - s = s->next; - } - - nm.arena = sum; - nm.ordblks = nfree; - nm.hblkhd = m->footprint - sum; - nm.usmblks = m->max_footprint; - nm.uordblks = m->footprint - mfree; - nm.fordblks = mfree; - nm.keepcost = m->topsize; - } - - POSTACTION(m); - } - return nm; -} -#endif /* !NO_MALLINFO */ - -static void internal_malloc_stats(mstate m) { - if (!PREACTION(m)) { - size_t maxfp = 0; - size_t fp = 0; - size_t used = 0; - check_malloc_state(m); - if (is_initialized(m)) { - msegmentptr s = &m->seg; - maxfp = m->max_footprint; - fp = m->footprint; - used = fp - (m->topsize + TOP_FOOT_SIZE); - - while (s != 0) { - mchunkptr q = align_as_chunk(s->base); - while (segment_holds(s, q) && - q != m->top && q->head != FENCEPOST_HEAD) { - if (!cinuse(q)) - used -= chunksize(q); - q = next_chunk(q); - } - s = s->next; - } - } - - fprintf(stderr, "max system bytes = %10lu\n", (unsigned long)(maxfp)); - fprintf(stderr, "system bytes = %10lu\n", (unsigned long)(fp)); - fprintf(stderr, "in use bytes = %10lu\n", (unsigned long)(used)); - - POSTACTION(m); - } -} - -/* ----------------------- Operations on smallbins ----------------------- */ - -/* - Various forms of linking and unlinking are defined as macros. Even - the ones for trees, which are very long but have very short typical - paths. This is ugly but reduces reliance on inlining support of - compilers. -*/ - -/* Link a free chunk into a smallbin */ -#define insert_small_chunk(M, P, S) {\ - bindex_t I = small_index(S);\ - mchunkptr B = smallbin_at(M, I);\ - mchunkptr F = B;\ - assert(S >= MIN_CHUNK_SIZE);\ - if (!smallmap_is_marked(M, I))\ - mark_smallmap(M, I);\ - else if (RTCHECK(ok_address(M, B->fd)))\ - F = B->fd;\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - B->fd = P;\ - F->bk = P;\ - P->fd = F;\ - P->bk = B;\ -} - -/* Unlink a chunk from a smallbin */ -#define unlink_small_chunk(M, P, S) {\ - mchunkptr F = P->fd;\ - mchunkptr B = P->bk;\ - bindex_t I = small_index(S);\ - assert(P != B);\ - assert(P != F);\ - assert(chunksize(P) == small_index2size(I));\ - if (F == B)\ - clear_smallmap(M, I);\ - else if (RTCHECK((F == smallbin_at(M,I) || ok_address(M, F)) &&\ - (B == smallbin_at(M,I) || ok_address(M, B)))) {\ - F->bk = B;\ - B->fd = F;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ -} - -/* Unlink the first chunk from a smallbin */ -#define unlink_first_small_chunk(M, B, P, I) {\ - mchunkptr F = P->fd;\ - assert(P != B);\ - assert(P != F);\ - assert(chunksize(P) == small_index2size(I));\ - if (B == F)\ - clear_smallmap(M, I);\ - else if (RTCHECK(ok_address(M, F))) {\ - B->fd = F;\ - F->bk = B;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ -} - -/* Replace dv node, binning the old one */ -/* Used only when dvsize known to be small */ -#define replace_dv(M, P, S) {\ - size_t DVS = M->dvsize;\ - if (DVS != 0) {\ - mchunkptr DV = M->dv;\ - assert(is_small(DVS));\ - insert_small_chunk(M, DV, DVS);\ - }\ - M->dvsize = S;\ - M->dv = P;\ -} - -/* ------------------------- Operations on trees ------------------------- */ - -/* Insert chunk into tree */ -#define insert_large_chunk(M, X, S) {\ - tbinptr* H;\ - bindex_t I;\ - compute_tree_index(S, I);\ - H = treebin_at(M, I);\ - X->index = I;\ - X->child[0] = X->child[1] = 0;\ - if (!treemap_is_marked(M, I)) {\ - mark_treemap(M, I);\ - *H = X;\ - X->parent = (tchunkptr)H;\ - X->fd = X->bk = X;\ - }\ - else {\ - tchunkptr T = *H;\ - size_t K = S << leftshift_for_tree_index(I);\ - for (;;) {\ - if (chunksize(T) != S) {\ - tchunkptr* C = &(T->child[(K >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]);\ - K <<= 1;\ - if (*C != 0)\ - T = *C;\ - else if (RTCHECK(ok_address(M, C))) {\ - *C = X;\ - X->parent = T;\ - X->fd = X->bk = X;\ - break;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - break;\ - }\ - }\ - else {\ - tchunkptr F = T->fd;\ - if (RTCHECK(ok_address(M, T) && ok_address(M, F))) {\ - T->fd = F->bk = X;\ - X->fd = F;\ - X->bk = T;\ - X->parent = 0;\ - break;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - break;\ - }\ - }\ - }\ - }\ -} - -/* - Unlink steps: - - 1. If x is a chained node, unlink it from its same-sized fd/bk links - and choose its bk node as its replacement. - 2. If x was the last node of its size, but not a leaf node, it must - be replaced with a leaf node (not merely one with an open left or - right), to make sure that lefts and rights of descendents - correspond properly to bit masks. We use the rightmost descendent - of x. We could use any other leaf, but this is easy to locate and - tends to counteract removal of leftmosts elsewhere, and so keeps - paths shorter than minimally guaranteed. This doesn't loop much - because on average a node in a tree is near the bottom. - 3. If x is the base of a chain (i.e., has parent links) relink - x's parent and children to x's replacement (or null if none). -*/ - -#define unlink_large_chunk(M, X) {\ - tchunkptr XP = X->parent;\ - tchunkptr R;\ - if (X->bk != X) {\ - tchunkptr F = X->fd;\ - R = X->bk;\ - if (RTCHECK(ok_address(M, F))) {\ - F->bk = R;\ - R->fd = F;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - }\ - else {\ - tchunkptr* RP;\ - if (((R = *(RP = &(X->child[1]))) != 0) ||\ - ((R = *(RP = &(X->child[0]))) != 0)) {\ - tchunkptr* CP;\ - while ((*(CP = &(R->child[1])) != 0) ||\ - (*(CP = &(R->child[0])) != 0)) {\ - R = *(RP = CP);\ - }\ - if (RTCHECK(ok_address(M, RP)))\ - *RP = 0;\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - }\ - }\ - if (XP != 0) {\ - tbinptr* H = treebin_at(M, X->index);\ - if (X == *H) {\ - if ((*H = R) == 0) \ - clear_treemap(M, X->index);\ - }\ - else if (RTCHECK(ok_address(M, XP))) {\ - if (XP->child[0] == X) \ - XP->child[0] = R;\ - else \ - XP->child[1] = R;\ - }\ - else\ - CORRUPTION_ERROR_ACTION(M);\ - if (R != 0) {\ - if (RTCHECK(ok_address(M, R))) {\ - tchunkptr C0, C1;\ - R->parent = XP;\ - if ((C0 = X->child[0]) != 0) {\ - if (RTCHECK(ok_address(M, C0))) {\ - R->child[0] = C0;\ - C0->parent = R;\ - }\ - else\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - if ((C1 = X->child[1]) != 0) {\ - if (RTCHECK(ok_address(M, C1))) {\ - R->child[1] = C1;\ - C1->parent = R;\ - }\ - else\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - }\ - else\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - }\ -} - -/* Relays to large vs small bin operations */ - -#define insert_chunk(M, P, S)\ - if (is_small(S)) insert_small_chunk(M, P, S)\ - else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); } - -#define unlink_chunk(M, P, S)\ - if (is_small(S)) unlink_small_chunk(M, P, S)\ - else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); } - - -/* Relays to internal calls to malloc/free from realloc, memalign etc */ - -#if ONLY_MSPACES -#define internal_malloc(m, b) mspace_malloc(m, b) -#define internal_free(m, mem) mspace_free(m,mem); -#else /* ONLY_MSPACES */ -#if MSPACES -#define internal_malloc(m, b)\ - (m == gm)? dlmalloc(b) : mspace_malloc(m, b) -#define internal_free(m, mem)\ - if (m == gm) dlfree(mem); else mspace_free(m,mem); -#else /* MSPACES */ -#define internal_malloc(m, b) dlmalloc(b) -#define internal_free(m, mem) dlfree(mem) -#endif /* MSPACES */ -#endif /* ONLY_MSPACES */ - -/* ----------------------- Direct-mmapping chunks ----------------------- */ - -/* - Directly mmapped chunks are set up with an offset to the start of - the mmapped region stored in the prev_foot field of the chunk. This - allows reconstruction of the required argument to MUNMAP when freed, - and also allows adjustment of the returned chunk to meet alignment - requirements (especially in memalign). There is also enough space - allocated to hold a fake next chunk of size SIZE_T_SIZE to maintain - the PINUSE bit so frees can be checked. -*/ - -/* Malloc using mmap */ -static void* mmap_alloc(mstate m, size_t nb) { - size_t mmsize = granularity_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); - if (mmsize > nb) { /* Check for wrap around 0 */ - char* mm = (char*)(DIRECT_MMAP(mmsize)); - if (mm != CMFAIL) { - size_t offset = align_offset(chunk2mem(mm)); - size_t psize = mmsize - offset - MMAP_FOOT_PAD; - mchunkptr p = (mchunkptr)(mm + offset); - p->prev_foot = offset | IS_MMAPPED_BIT; - (p)->head = (psize|CINUSE_BIT); - mark_inuse_foot(m, p, psize); - chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD; - chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0; - - if (mm < m->least_addr) - m->least_addr = mm; - if ((m->footprint += mmsize) > m->max_footprint) - m->max_footprint = m->footprint; - assert(is_aligned(chunk2mem(p))); - check_mmapped_chunk(m, p); - return chunk2mem(p); - } - } - return 0; -} - -/* Realloc using mmap */ -static mchunkptr mmap_resize(mstate m, mchunkptr oldp, size_t nb) { - size_t oldsize = chunksize(oldp); - if (is_small(nb)) /* Can't shrink mmap regions below small size */ - return 0; - /* Keep old chunk if big enough but not too big */ - if (oldsize >= nb + SIZE_T_SIZE && - (oldsize - nb) <= (mparams.granularity << 1)) - return oldp; - else { - size_t offset = oldp->prev_foot & ~IS_MMAPPED_BIT; - size_t oldmmsize = oldsize + offset + MMAP_FOOT_PAD; - size_t newmmsize = granularity_align(nb + SIX_SIZE_T_SIZES + - CHUNK_ALIGN_MASK); - char* cp = (char*)CALL_MREMAP((char*)oldp - offset, - oldmmsize, newmmsize, 1); - if (cp != CMFAIL) { - mchunkptr newp = (mchunkptr)(cp + offset); - size_t psize = newmmsize - offset - MMAP_FOOT_PAD; - newp->head = (psize|CINUSE_BIT); - mark_inuse_foot(m, newp, psize); - chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD; - chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0; - - if (cp < m->least_addr) - m->least_addr = cp; - if ((m->footprint += newmmsize - oldmmsize) > m->max_footprint) - m->max_footprint = m->footprint; - check_mmapped_chunk(m, newp); - return newp; - } - } - return 0; -} - -/* -------------------------- mspace management -------------------------- */ - -/* Initialize top chunk and its size */ -static void init_top(mstate m, mchunkptr p, size_t psize) { - /* Ensure alignment */ - size_t offset = align_offset(chunk2mem(p)); - p = (mchunkptr)((char*)p + offset); - psize -= offset; - - m->top = p; - m->topsize = psize; - p->head = psize | PINUSE_BIT; - /* set size of fake trailing chunk holding overhead space only once */ - chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE; - m->trim_check = mparams.trim_threshold; /* reset on each update */ -} - -/* Initialize bins for a new mstate that is otherwise zeroed out */ -static void init_bins(mstate m) { - /* Establish circular links for smallbins */ - bindex_t i; - for (i = 0; i < NSMALLBINS; ++i) { - sbinptr bin = smallbin_at(m,i); - bin->fd = bin->bk = bin; - } -} - -#if PROCEED_ON_ERROR - -/* default corruption action */ -static void reset_on_error(mstate m) { - int i; - ++malloc_corruption_error_count; - /* Reinitialize fields to forget about all memory */ - m->smallbins = m->treebins = 0; - m->dvsize = m->topsize = 0; - m->seg.base = 0; - m->seg.size = 0; - m->seg.next = 0; - m->top = m->dv = 0; - for (i = 0; i < NTREEBINS; ++i) - *treebin_at(m, i) = 0; - init_bins(m); -} -#endif /* PROCEED_ON_ERROR */ - -/* Allocate chunk and prepend remainder with chunk in successor base. */ -static void* prepend_alloc(mstate m, char* newbase, char* oldbase, - size_t nb) { - mchunkptr p = align_as_chunk(newbase); - mchunkptr oldfirst = align_as_chunk(oldbase); - size_t psize = (char*)oldfirst - (char*)p; - mchunkptr q = chunk_plus_offset(p, nb); - size_t qsize = psize - nb; - set_size_and_pinuse_of_inuse_chunk(m, p, nb); - - assert((char*)oldfirst > (char*)q); - assert(pinuse(oldfirst)); - assert(qsize >= MIN_CHUNK_SIZE); - - /* consolidate remainder with first chunk of old base */ - if (oldfirst == m->top) { - size_t tsize = m->topsize += qsize; - m->top = q; - q->head = tsize | PINUSE_BIT; - check_top_chunk(m, q); - } - else if (oldfirst == m->dv) { - size_t dsize = m->dvsize += qsize; - m->dv = q; - set_size_and_pinuse_of_free_chunk(q, dsize); - } - else { - if (!cinuse(oldfirst)) { - size_t nsize = chunksize(oldfirst); - unlink_chunk(m, oldfirst, nsize); - oldfirst = chunk_plus_offset(oldfirst, nsize); - qsize += nsize; - } - set_free_with_pinuse(q, qsize, oldfirst); - insert_chunk(m, q, qsize); - check_free_chunk(m, q); - } - - check_malloced_chunk(m, chunk2mem(p), nb); - return chunk2mem(p); -} - - -/* Add a segment to hold a new noncontiguous region */ -static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) { - /* Determine locations and sizes of segment, fenceposts, old top */ - char* old_top = (char*)m->top; - msegmentptr oldsp = segment_holding(m, old_top); - char* old_end = oldsp->base + oldsp->size; - size_t ssize = pad_request(sizeof(struct malloc_segment)); - char* rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); - size_t offset = align_offset(chunk2mem(rawsp)); - char* asp = rawsp + offset; - char* csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp; - mchunkptr sp = (mchunkptr)csp; - msegmentptr ss = (msegmentptr)(chunk2mem(sp)); - mchunkptr tnext = chunk_plus_offset(sp, ssize); - mchunkptr p = tnext; - int nfences = 0; - - /* reset top to new space */ - init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); - - /* Set up segment record */ - assert(is_aligned(ss)); - set_size_and_pinuse_of_inuse_chunk(m, sp, ssize); - *ss = m->seg; /* Push current record */ - m->seg.base = tbase; - m->seg.size = tsize; - m->seg.sflags = mmapped; - m->seg.next = ss; - - /* Insert trailing fenceposts */ - for (;;) { - mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE); - p->head = FENCEPOST_HEAD; - ++nfences; - if ((char*)(&(nextp->head)) < old_end) - p = nextp; - else - break; - } - assert(nfences >= 2); - - /* Insert the rest of old top into a bin as an ordinary free chunk */ - if (csp != old_top) { - mchunkptr q = (mchunkptr)old_top; - size_t psize = csp - old_top; - mchunkptr tn = chunk_plus_offset(q, psize); - set_free_with_pinuse(q, psize, tn); - insert_chunk(m, q, psize); - } - - check_top_chunk(m, m->top); -} - -/* -------------------------- System allocation -------------------------- */ - -/* Get memory from system using MORECORE or MMAP */ -static void* sys_alloc(mstate m, size_t nb) { - char* tbase = CMFAIL; - size_t tsize = 0; - flag_t mmap_flag = 0; - - init_mparams(); - - /* Directly map large chunks */ - if (use_mmap(m) && nb >= mparams.mmap_threshold) { - void* mem = mmap_alloc(m, nb); - if (mem != 0) - return mem; - } - - /* - Try getting memory in any of three ways (in most-preferred to - least-preferred order): - 1. A call to MORECORE that can normally contiguously extend memory. - (disabled if not MORECORE_CONTIGUOUS or not HAVE_MORECORE or - or main space is mmapped or a previous contiguous call failed) - 2. A call to MMAP new space (disabled if not HAVE_MMAP). - Note that under the default settings, if MORECORE is unable to - fulfill a request, and HAVE_MMAP is true, then mmap is - used as a noncontiguous system allocator. This is a useful backup - strategy for systems with holes in address spaces -- in this case - sbrk cannot contiguously expand the heap, but mmap may be able to - find space. - 3. A call to MORECORE that cannot usually contiguously extend memory. - (disabled if not HAVE_MORECORE) - */ - - if (MORECORE_CONTIGUOUS && !use_noncontiguous(m)) { - char* br = CMFAIL; - msegmentptr ss = (m->top == 0)? 0 : segment_holding(m, (char*)m->top); - size_t asize = 0; - ACQUIRE_MORECORE_LOCK(); - - if (ss == 0) { /* First time through or recovery */ - char* base = (char*)CALL_MORECORE(0); - if (base != CMFAIL) { - asize = granularity_align(nb + TOP_FOOT_SIZE + SIZE_T_ONE); - /* Adjust to end on a page boundary */ - if (!is_page_aligned(base)) - asize += (page_align((size_t)base) - (size_t)base); - /* Can't call MORECORE if size is negative when treated as signed */ - if (asize < HALF_MAX_SIZE_T && - (br = (char*)(CALL_MORECORE(asize))) == base) { - tbase = base; - tsize = asize; - } - } - } - else { - /* Subtract out existing available top space from MORECORE request. */ - asize = granularity_align(nb - m->topsize + TOP_FOOT_SIZE + SIZE_T_ONE); - /* Use mem here only if it did continuously extend old space */ - if (asize < HALF_MAX_SIZE_T && - (br = (char*)(CALL_MORECORE(asize))) == ss->base+ss->size) { - tbase = br; - tsize = asize; - } - } - - if (tbase == CMFAIL) { /* Cope with partial failure */ - if (br != CMFAIL) { /* Try to use/extend the space we did get */ - if (asize < HALF_MAX_SIZE_T && - asize < nb + TOP_FOOT_SIZE + SIZE_T_ONE) { - size_t esize = granularity_align(nb + TOP_FOOT_SIZE + SIZE_T_ONE - asize); - if (esize < HALF_MAX_SIZE_T) { - char* end = (char*)CALL_MORECORE(esize); - if (end != CMFAIL) - asize += esize; - else { /* Can't use; try to release */ - CALL_MORECORE(-asize); - br = CMFAIL; - } - } - } - } - if (br != CMFAIL) { /* Use the space we did get */ - tbase = br; - tsize = asize; - } - else - disable_contiguous(m); /* Don't try contiguous path in the future */ - } - - RELEASE_MORECORE_LOCK(); - } - - if (HAVE_MMAP && tbase == CMFAIL) { /* Try MMAP */ - size_t req = nb + TOP_FOOT_SIZE + SIZE_T_ONE; - size_t rsize = granularity_align(req); - if (rsize > nb) { /* Fail if wraps around zero */ - char* mp = (char*)(CALL_MMAP(rsize)); - if (mp != CMFAIL) { - tbase = mp; - tsize = rsize; - mmap_flag = IS_MMAPPED_BIT; - } - } - } - - if (HAVE_MORECORE && tbase == CMFAIL) { /* Try noncontiguous MORECORE */ - size_t asize = granularity_align(nb + TOP_FOOT_SIZE + SIZE_T_ONE); - if (asize < HALF_MAX_SIZE_T) { - char* br = CMFAIL; - char* end = CMFAIL; - ACQUIRE_MORECORE_LOCK(); - br = (char*)(CALL_MORECORE(asize)); - end = (char*)(CALL_MORECORE(0)); - RELEASE_MORECORE_LOCK(); - if (br != CMFAIL && end != CMFAIL && br < end) { - size_t ssize = end - br; - if (ssize > nb + TOP_FOOT_SIZE) { - tbase = br; - tsize = ssize; - } - } - } - } - - if (tbase != CMFAIL) { - - if ((m->footprint += tsize) > m->max_footprint) - m->max_footprint = m->footprint; - - if (!is_initialized(m)) { /* first-time initialization */ - m->seg.base = m->least_addr = tbase; - m->seg.size = tsize; - m->seg.sflags = mmap_flag; - m->magic = mparams.magic; - init_bins(m); - if (is_global(m)) - init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); - else { - /* Offset top by embedded malloc_state */ - mchunkptr mn = next_chunk(mem2chunk(m)); - init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) -TOP_FOOT_SIZE); - } - } - - else { - /* Try to merge with an existing segment */ - msegmentptr sp = &m->seg; - while (sp != 0 && tbase != sp->base + sp->size) - sp = sp->next; - if (sp != 0 && - !is_extern_segment(sp) && - (sp->sflags & IS_MMAPPED_BIT) == mmap_flag && - segment_holds(sp, m->top)) { /* append */ - sp->size += tsize; - init_top(m, m->top, m->topsize + tsize); - } - else { - if (tbase < m->least_addr) - m->least_addr = tbase; - sp = &m->seg; - while (sp != 0 && sp->base != tbase + tsize) - sp = sp->next; - if (sp != 0 && - !is_extern_segment(sp) && - (sp->sflags & IS_MMAPPED_BIT) == mmap_flag) { - char* oldbase = sp->base; - sp->base = tbase; - sp->size += tsize; - return prepend_alloc(m, tbase, oldbase, nb); - } - else - add_segment(m, tbase, tsize, mmap_flag); - } - } - - if (nb < m->topsize) { /* Allocate from new or extended top space */ - size_t rsize = m->topsize -= nb; - mchunkptr p = m->top; - mchunkptr r = m->top = chunk_plus_offset(p, nb); - r->head = rsize | PINUSE_BIT; - set_size_and_pinuse_of_inuse_chunk(m, p, nb); - check_top_chunk(m, m->top); - check_malloced_chunk(m, chunk2mem(p), nb); - return chunk2mem(p); - } - } - - MALLOC_FAILURE_ACTION; - return 0; -} - -/* ----------------------- system deallocation -------------------------- */ - -/* Unmap and unlink any mmapped segments that don't contain used chunks */ -static size_t release_unused_segments(mstate m) { - size_t released = 0; - msegmentptr pred = &m->seg; - msegmentptr sp = pred->next; - while (sp != 0) { - char* base = sp->base; - size_t size = sp->size; - msegmentptr next = sp->next; - if (is_mmapped_segment(sp) && !is_extern_segment(sp)) { - mchunkptr p = align_as_chunk(base); - size_t psize = chunksize(p); - /* Can unmap if first chunk holds entire segment and not pinned */ - if (!cinuse(p) && (char*)p + psize >= base + size - TOP_FOOT_SIZE) { - tchunkptr tp = (tchunkptr)p; - assert(segment_holds(sp, (char*)sp)); - if (p == m->dv) { - m->dv = 0; - m->dvsize = 0; - } - else { - unlink_large_chunk(m, tp); - } - if (CALL_MUNMAP(base, size) == 0) { - released += size; - m->footprint -= size; - /* unlink obsoleted record */ - sp = pred; - sp->next = next; - } - else { /* back out if cannot unmap */ - insert_large_chunk(m, tp, psize); - } - } - } - pred = sp; - sp = next; - } - return released; -} - -static int sys_trim(mstate m, size_t pad) { - size_t released = 0; - if (pad < MAX_REQUEST && is_initialized(m)) { - pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ - - if (m->topsize > pad) { - /* Shrink top space in granularity-size units, keeping at least one */ - size_t unit = mparams.granularity; - size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - - SIZE_T_ONE) * unit; - msegmentptr sp = segment_holding(m, (char*)m->top); - - if (!is_extern_segment(sp)) { - if (is_mmapped_segment(sp)) { - if (HAVE_MMAP && - sp->size >= extra && - !has_segment_link(m, sp)) { /* can't shrink if pinned */ - size_t newsize = sp->size - extra; - /* Prefer mremap, fall back to munmap */ - if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) || - (CALL_MUNMAP(sp->base + newsize, extra) == 0)) { - released = extra; - } - } - } - else if (HAVE_MORECORE) { - if (extra >= HALF_MAX_SIZE_T) /* Avoid wrapping negative */ - extra = (HALF_MAX_SIZE_T) + SIZE_T_ONE - unit; - ACQUIRE_MORECORE_LOCK(); - { - /* Make sure end of memory is where we last set it. */ - char* old_br = (char*)(CALL_MORECORE(0)); - if (old_br == sp->base + sp->size) { - char* rel_br = (char*)(CALL_MORECORE(-extra)); - char* new_br = (char*)(CALL_MORECORE(0)); - if (rel_br != CMFAIL && new_br < old_br) - released = old_br - new_br; - } - } - RELEASE_MORECORE_LOCK(); - } - } - - if (released != 0) { - sp->size -= released; - m->footprint -= released; - init_top(m, m->top, m->topsize - released); - check_top_chunk(m, m->top); - } - } - - /* Unmap any unused mmapped segments */ - if (HAVE_MMAP) - released += release_unused_segments(m); - - /* On failure, disable autotrim to avoid repeated failed future calls */ - if (released == 0) - m->trim_check = MAX_SIZE_T; - } - - return (released != 0)? 1 : 0; -} - -/* ---------------------------- malloc support --------------------------- */ - -/* allocate a large request from the best fitting chunk in a treebin */ -static void* tmalloc_large(mstate m, size_t nb) { - tchunkptr v = 0; - size_t rsize = -nb; /* Unsigned negation */ - tchunkptr t; - bindex_t idx; - compute_tree_index(nb, idx); - - if ((t = *treebin_at(m, idx)) != 0) { - /* Traverse tree for this bin looking for node with size == nb */ - size_t sizebits = nb << leftshift_for_tree_index(idx); - tchunkptr rst = 0; /* The deepest untaken right subtree */ - for (;;) { - tchunkptr rt; - size_t trem = chunksize(t) - nb; - if (trem < rsize) { - v = t; - if ((rsize = trem) == 0) - break; - } - rt = t->child[1]; - t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; - if (rt != 0 && rt != t) - rst = rt; - if (t == 0) { - t = rst; /* set t to least subtree holding sizes > nb */ - break; - } - sizebits <<= 1; - } - } - - if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ - binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap; - if (leftbits != 0) { - bindex_t i; - binmap_t leastbit = least_bit(leftbits); - compute_bit2idx(leastbit, i); - t = *treebin_at(m, i); - } - } - - while (t != 0) { /* find smallest of tree or subtree */ - size_t trem = chunksize(t) - nb; - if (trem < rsize) { - rsize = trem; - v = t; - } - t = leftmost_child(t); - } - - /* If dv is a better fit, return 0 so malloc will use it */ - if (v != 0 && rsize < (size_t)(m->dvsize - nb)) { - if (RTCHECK(ok_address(m, v))) { /* split */ - mchunkptr r = chunk_plus_offset(v, nb); - assert(chunksize(v) == rsize + nb); - if (RTCHECK(ok_next(v, r))) { - unlink_large_chunk(m, v); - if (rsize < MIN_CHUNK_SIZE) - set_inuse_and_pinuse(m, v, (rsize + nb)); - else { - set_size_and_pinuse_of_inuse_chunk(m, v, nb); - set_size_and_pinuse_of_free_chunk(r, rsize); - insert_chunk(m, r, rsize); - } - return chunk2mem(v); - } - } - CORRUPTION_ERROR_ACTION(m); - } - return 0; -} - -/* allocate a small request from the best fitting chunk in a treebin */ -static void* tmalloc_small(mstate m, size_t nb) { - tchunkptr t, v; - size_t rsize; - bindex_t i; - binmap_t leastbit = least_bit(m->treemap); - compute_bit2idx(leastbit, i); - - v = t = *treebin_at(m, i); - rsize = chunksize(t) - nb; - - while ((t = leftmost_child(t)) != 0) { - size_t trem = chunksize(t) - nb; - if (trem < rsize) { - rsize = trem; - v = t; - } - } - - if (RTCHECK(ok_address(m, v))) { - mchunkptr r = chunk_plus_offset(v, nb); - assert(chunksize(v) == rsize + nb); - if (RTCHECK(ok_next(v, r))) { - unlink_large_chunk(m, v); - if (rsize < MIN_CHUNK_SIZE) - set_inuse_and_pinuse(m, v, (rsize + nb)); - else { - set_size_and_pinuse_of_inuse_chunk(m, v, nb); - set_size_and_pinuse_of_free_chunk(r, rsize); - replace_dv(m, r, rsize); - } - return chunk2mem(v); - } - } - - CORRUPTION_ERROR_ACTION(m); - return 0; -} - -/* --------------------------- realloc support --------------------------- */ - -static void* internal_realloc(mstate m, void* oldmem, size_t bytes) { - if (bytes >= MAX_REQUEST) { - MALLOC_FAILURE_ACTION; - return 0; - } - if (!PREACTION(m)) { - mchunkptr oldp = mem2chunk(oldmem); - size_t oldsize = chunksize(oldp); - mchunkptr next = chunk_plus_offset(oldp, oldsize); - mchunkptr newp = 0; - void* extra = 0; - - /* Try to either shrink or extend into top. Else malloc-copy-free */ - - if (RTCHECK(ok_address(m, oldp) && ok_cinuse(oldp) && - ok_next(oldp, next) && ok_pinuse(next))) { - size_t nb = request2size(bytes); - if (is_mmapped(oldp)) - newp = mmap_resize(m, oldp, nb); - else if (oldsize >= nb) { /* already big enough */ - size_t rsize = oldsize - nb; - newp = oldp; - if (rsize >= MIN_CHUNK_SIZE) { - mchunkptr remainder = chunk_plus_offset(newp, nb); - set_inuse(m, newp, nb); - set_inuse(m, remainder, rsize); - extra = chunk2mem(remainder); - } - } - else if (next == m->top && oldsize + m->topsize > nb) { - /* Expand into top */ - size_t newsize = oldsize + m->topsize; - size_t newtopsize = newsize - nb; - mchunkptr newtop = chunk_plus_offset(oldp, nb); - set_inuse(m, oldp, nb); - newtop->head = newtopsize |PINUSE_BIT; - m->top = newtop; - m->topsize = newtopsize; - newp = oldp; - } - } - else { - USAGE_ERROR_ACTION(m, oldmem); - POSTACTION(m); - return 0; - } - - POSTACTION(m); - - if (newp != 0) { - if (extra != 0) { - internal_free(m, extra); - } - check_inuse_chunk(m, newp); - return chunk2mem(newp); - } - else { - void* newmem = internal_malloc(m, bytes); - if (newmem != 0) { - size_t oc = oldsize - overhead_for(oldp); - memcpy(newmem, oldmem, (oc < bytes)? oc : bytes); - internal_free(m, oldmem); - } - return newmem; - } - } - return 0; -} - -/* --------------------------- memalign support -------------------------- */ - -static void* internal_memalign(mstate m, size_t alignment, size_t bytes) { - if (alignment <= MALLOC_ALIGNMENT) /* Can just use malloc */ - return internal_malloc(m, bytes); - if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */ - alignment = MIN_CHUNK_SIZE; - if ((alignment & (alignment-SIZE_T_ONE)) != 0) {/* Ensure a power of 2 */ - size_t a = MALLOC_ALIGNMENT << 1; - while (a < alignment) a <<= 1; - alignment = a; - } - - if (bytes >= MAX_REQUEST - alignment) { - if (m != 0) { /* Test isn't needed but avoids compiler warning */ - MALLOC_FAILURE_ACTION; - } - } - else { - size_t nb = request2size(bytes); - size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD; - char* mem = (char*)internal_malloc(m, req); - if (mem != 0) { - void* leader = 0; - void* trailer = 0; - mchunkptr p = mem2chunk(mem); - - if (PREACTION(m)) return 0; - if ((((size_t)(mem)) % alignment) != 0) { /* misaligned */ - /* - Find an aligned spot inside chunk. Since we need to give - back leading space in a chunk of at least MIN_CHUNK_SIZE, if - the first calculation places us at a spot with less than - MIN_CHUNK_SIZE leader, we can move to the next aligned spot. - We've allocated enough total room so that this is always - possible. - */ - char* br = (char*)mem2chunk((size_t)(((size_t)(mem + - alignment - - SIZE_T_ONE)) & - -alignment)); - char* pos = ((size_t)(br - (char*)(p)) >= MIN_CHUNK_SIZE)? - br : br+alignment; - mchunkptr newp = (mchunkptr)pos; - size_t leadsize = pos - (char*)(p); - size_t newsize = chunksize(p) - leadsize; - - if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */ - newp->prev_foot = p->prev_foot + leadsize; - newp->head = (newsize|CINUSE_BIT); - } - else { /* Otherwise, give back leader, use the rest */ - set_inuse(m, newp, newsize); - set_inuse(m, p, leadsize); - leader = chunk2mem(p); - } - p = newp; - } - - /* Give back spare room at the end */ - if (!is_mmapped(p)) { - size_t size = chunksize(p); - if (size > nb + MIN_CHUNK_SIZE) { - size_t remainder_size = size - nb; - mchunkptr remainder = chunk_plus_offset(p, nb); - set_inuse(m, p, nb); - set_inuse(m, remainder, remainder_size); - trailer = chunk2mem(remainder); - } - } - - assert (chunksize(p) >= nb); - assert((((size_t)(chunk2mem(p))) % alignment) == 0); - check_inuse_chunk(m, p); - POSTACTION(m); - if (leader != 0) { - internal_free(m, leader); - } - if (trailer != 0) { - internal_free(m, trailer); - } - return chunk2mem(p); - } - } - return 0; -} - -/* ------------------------ comalloc/coalloc support --------------------- */ - -static void** ialloc(mstate m, - size_t n_elements, - size_t* sizes, - int opts, - void* chunks[]) { - /* - This provides common support for independent_X routines, handling - all of the combinations that can result. - - The opts arg has: - bit 0 set if all elements are same size (using sizes[0]) - bit 1 set if elements should be zeroed - */ - - size_t element_size; /* chunksize of each element, if all same */ - size_t contents_size; /* total size of elements */ - size_t array_size; /* request size of pointer array */ - void* mem; /* malloced aggregate space */ - mchunkptr p; /* corresponding chunk */ - size_t remainder_size; /* remaining bytes while splitting */ - void** marray; /* either "chunks" or malloced ptr array */ - mchunkptr array_chunk; /* chunk for malloced ptr array */ - flag_t was_enabled; /* to disable mmap */ - size_t size; - size_t i; - - /* compute array length, if needed */ - if (chunks != 0) { - if (n_elements == 0) - return chunks; /* nothing to do */ - marray = chunks; - array_size = 0; - } - else { - /* if empty req, must still return chunk representing empty array */ - if (n_elements == 0) - return (void**)internal_malloc(m, 0); - marray = 0; - array_size = request2size(n_elements * (sizeof(void*))); - } - - /* compute total element size */ - if (opts & 0x1) { /* all-same-size */ - element_size = request2size(*sizes); - contents_size = n_elements * element_size; - } - else { /* add up all the sizes */ - element_size = 0; - contents_size = 0; - for (i = 0; i != n_elements; ++i) - contents_size += request2size(sizes[i]); - } - - size = contents_size + array_size; - - /* - Allocate the aggregate chunk. First disable direct-mmapping so - malloc won't use it, since we would not be able to later - free/realloc space internal to a segregated mmap region. - */ - was_enabled = use_mmap(m); - disable_mmap(m); - mem = internal_malloc(m, size - CHUNK_OVERHEAD); - if (was_enabled) - enable_mmap(m); - if (mem == 0) - return 0; - - if (PREACTION(m)) return 0; - p = mem2chunk(mem); - remainder_size = chunksize(p); - - assert(!is_mmapped(p)); - - if (opts & 0x2) { /* optionally clear the elements */ - memset((size_t*)mem, 0, remainder_size - SIZE_T_SIZE - array_size); - } - - /* If not provided, allocate the pointer array as final part of chunk */ - if (marray == 0) { - size_t array_chunk_size; - array_chunk = chunk_plus_offset(p, contents_size); - array_chunk_size = remainder_size - contents_size; - marray = (void**) (chunk2mem(array_chunk)); - set_size_and_pinuse_of_inuse_chunk(m, array_chunk, array_chunk_size); - remainder_size = contents_size; - } - - /* split out elements */ - for (i = 0; ; ++i) { - marray[i] = chunk2mem(p); - if (i != n_elements-1) { - if (element_size != 0) - size = element_size; - else - size = request2size(sizes[i]); - remainder_size -= size; - set_size_and_pinuse_of_inuse_chunk(m, p, size); - p = chunk_plus_offset(p, size); - } - else { /* the final element absorbs any overallocation slop */ - set_size_and_pinuse_of_inuse_chunk(m, p, remainder_size); - break; - } - } - -#if DEBUG - if (marray != chunks) { - /* final element must have exactly exhausted chunk */ - if (element_size != 0) { - assert(remainder_size == element_size); - } - else { - assert(remainder_size == request2size(sizes[i])); - } - check_inuse_chunk(m, mem2chunk(marray)); - } - for (i = 0; i != n_elements; ++i) - check_inuse_chunk(m, mem2chunk(marray[i])); - -#endif /* DEBUG */ - - POSTACTION(m); - return marray; -} - - -/* -------------------------- public routines ---------------------------- */ - -#if !ONLY_MSPACES - -void* dlmalloc(size_t bytes) { - /* - Basic algorithm: - If a small request (< 256 bytes minus per-chunk overhead): - 1. If one exists, use a remainderless chunk in associated smallbin. - (Remainderless means that there are too few excess bytes to - represent as a chunk.) - 2. If it is big enough, use the dv chunk, which is normally the - chunk adjacent to the one used for the most recent small request. - 3. If one exists, split the smallest available chunk in a bin, - saving remainder in dv. - 4. If it is big enough, use the top chunk. - 5. If available, get memory from system and use it - Otherwise, for a large request: - 1. Find the smallest available binned chunk that fits, and use it - if it is better fitting than dv chunk, splitting if necessary. - 2. If better fitting than any binned chunk, use the dv chunk. - 3. If it is big enough, use the top chunk. - 4. If request size >= mmap threshold, try to directly mmap this chunk. - 5. If available, get memory from system and use it - - The ugly goto's here ensure that postaction occurs along all paths. - */ - - if (!PREACTION(gm)) { - void* mem; - size_t nb; - if (bytes <= MAX_SMALL_REQUEST) { - bindex_t idx; - binmap_t smallbits; - nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); - idx = small_index(nb); - smallbits = gm->smallmap >> idx; - - if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ - mchunkptr b, p; - idx += ~smallbits & 1; /* Uses next bin if idx empty */ - b = smallbin_at(gm, idx); - p = b->fd; - assert(chunksize(p) == small_index2size(idx)); - unlink_first_small_chunk(gm, b, p, idx); - set_inuse_and_pinuse(gm, p, small_index2size(idx)); - mem = chunk2mem(p); - check_malloced_chunk(gm, mem, nb); - goto postaction; - } - - else if (nb > gm->dvsize) { - if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ - mchunkptr b, p, r; - size_t rsize; - bindex_t i; - binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); - binmap_t leastbit = least_bit(leftbits); - compute_bit2idx(leastbit, i); - b = smallbin_at(gm, i); - p = b->fd; - assert(chunksize(p) == small_index2size(i)); - unlink_first_small_chunk(gm, b, p, i); - rsize = small_index2size(i) - nb; - /* Fit here cannot be remainderless if 4byte sizes */ - if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) - set_inuse_and_pinuse(gm, p, small_index2size(i)); - else { - set_size_and_pinuse_of_inuse_chunk(gm, p, nb); - r = chunk_plus_offset(p, nb); - set_size_and_pinuse_of_free_chunk(r, rsize); - replace_dv(gm, r, rsize); - } - mem = chunk2mem(p); - check_malloced_chunk(gm, mem, nb); - goto postaction; - } - - else if (gm->treemap != 0 && (mem = tmalloc_small(gm, nb)) != 0) { - check_malloced_chunk(gm, mem, nb); - goto postaction; - } - } - } - else if (bytes >= MAX_REQUEST) - nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ - else { - nb = pad_request(bytes); - if (gm->treemap != 0 && (mem = tmalloc_large(gm, nb)) != 0) { - check_malloced_chunk(gm, mem, nb); - goto postaction; - } - } - - if (nb <= gm->dvsize) { - size_t rsize = gm->dvsize - nb; - mchunkptr p = gm->dv; - if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ - mchunkptr r = gm->dv = chunk_plus_offset(p, nb); - gm->dvsize = rsize; - set_size_and_pinuse_of_free_chunk(r, rsize); - set_size_and_pinuse_of_inuse_chunk(gm, p, nb); - } - else { /* exhaust dv */ - size_t dvs = gm->dvsize; - gm->dvsize = 0; - gm->dv = 0; - set_inuse_and_pinuse(gm, p, dvs); - } - mem = chunk2mem(p); - check_malloced_chunk(gm, mem, nb); - goto postaction; - } - - else if (nb < gm->topsize) { /* Split top */ - size_t rsize = gm->topsize -= nb; - mchunkptr p = gm->top; - mchunkptr r = gm->top = chunk_plus_offset(p, nb); - r->head = rsize | PINUSE_BIT; - set_size_and_pinuse_of_inuse_chunk(gm, p, nb); - mem = chunk2mem(p); - check_top_chunk(gm, gm->top); - check_malloced_chunk(gm, mem, nb); - goto postaction; - } - - mem = sys_alloc(gm, nb); - - postaction: - POSTACTION(gm); - return mem; - } - - return 0; -} - -void dlfree(void* mem) { - /* - Consolidate freed chunks with preceeding or succeeding bordering - free chunks, if they exist, and then place in a bin. Intermixed - with special cases for top, dv, mmapped chunks, and usage errors. - */ - - if (mem != 0) { - mchunkptr p = mem2chunk(mem); -#if FOOTERS - mstate fm = get_mstate_for(p); - if (!ok_magic(fm)) { - USAGE_ERROR_ACTION(fm, p); - return; - } -#else /* FOOTERS */ -#define fm gm -#endif /* FOOTERS */ - if (!PREACTION(fm)) { - check_inuse_chunk(fm, p); - if (RTCHECK(ok_address(fm, p) && ok_cinuse(p))) { - size_t psize = chunksize(p); - mchunkptr next = chunk_plus_offset(p, psize); - if (!pinuse(p)) { - size_t prevsize = p->prev_foot; - if ((prevsize & IS_MMAPPED_BIT) != 0) { - prevsize &= ~IS_MMAPPED_BIT; - psize += prevsize + MMAP_FOOT_PAD; - if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) - fm->footprint -= psize; - goto postaction; - } - else { - mchunkptr prev = chunk_minus_offset(p, prevsize); - psize += prevsize; - p = prev; - if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ - if (p != fm->dv) { - unlink_chunk(fm, p, prevsize); - } - else if ((next->head & INUSE_BITS) == INUSE_BITS) { - fm->dvsize = psize; - set_free_with_pinuse(p, psize, next); - goto postaction; - } - } - else - goto erroraction; - } - } - - if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { - if (!cinuse(next)) { /* consolidate forward */ - if (next == fm->top) { - size_t tsize = fm->topsize += psize; - fm->top = p; - p->head = tsize | PINUSE_BIT; - if (p == fm->dv) { - fm->dv = 0; - fm->dvsize = 0; - } - if (should_trim(fm, tsize)) - sys_trim(fm, 0); - goto postaction; - } - else if (next == fm->dv) { - size_t dsize = fm->dvsize += psize; - fm->dv = p; - set_size_and_pinuse_of_free_chunk(p, dsize); - goto postaction; - } - else { - size_t nsize = chunksize(next); - psize += nsize; - unlink_chunk(fm, next, nsize); - set_size_and_pinuse_of_free_chunk(p, psize); - if (p == fm->dv) { - fm->dvsize = psize; - goto postaction; - } - } - } - else - set_free_with_pinuse(p, psize, next); - insert_chunk(fm, p, psize); - check_free_chunk(fm, p); - goto postaction; - } - } - erroraction: - USAGE_ERROR_ACTION(fm, p); - postaction: - POSTACTION(fm); - } - } -#if !FOOTERS -#undef fm -#endif /* FOOTERS */ -} - -void* dlcalloc(size_t n_elements, size_t elem_size) { - void* mem; - size_t req = 0; - if (n_elements != 0) { - req = n_elements * elem_size; - if (((n_elements | elem_size) & ~(size_t)0xffff) && - (req / n_elements != elem_size)) - req = MAX_SIZE_T; /* force downstream failure on overflow */ - } - mem = dlmalloc(req); - if (mem != 0 && calloc_must_clear(mem2chunk(mem))) - memset(mem, 0, req); - return mem; -} - -void* dlrealloc(void* oldmem, size_t bytes) { - if (oldmem == 0) - return dlmalloc(bytes); -#ifdef REALLOC_ZERO_BYTES_FREES - if (bytes == 0) { - dlfree(oldmem); - return 0; - } -#endif /* REALLOC_ZERO_BYTES_FREES */ - else { -#if ! FOOTERS - mstate m = gm; -#else /* FOOTERS */ - mstate m = get_mstate_for(mem2chunk(oldmem)); - if (!ok_magic(m)) { - USAGE_ERROR_ACTION(m, oldmem); - return 0; - } -#endif /* FOOTERS */ - return internal_realloc(m, oldmem, bytes); - } -} - -void* dlmemalign(size_t alignment, size_t bytes) { - return internal_memalign(gm, alignment, bytes); -} - -void** dlindependent_calloc(size_t n_elements, size_t elem_size, - void* chunks[]) { - size_t sz = elem_size; /* serves as 1-element array */ - return ialloc(gm, n_elements, &sz, 3, chunks); -} - -void** dlindependent_comalloc(size_t n_elements, size_t sizes[], - void* chunks[]) { - return ialloc(gm, n_elements, sizes, 0, chunks); -} - -void* dlvalloc(size_t bytes) { - size_t pagesz; - init_mparams(); - pagesz = mparams.page_size; - return dlmemalign(pagesz, bytes); -} - -void* dlpvalloc(size_t bytes) { - size_t pagesz; - init_mparams(); - pagesz = mparams.page_size; - return dlmemalign(pagesz, (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE)); -} - -int dlmalloc_trim(size_t pad) { - int result = 0; - if (!PREACTION(gm)) { - result = sys_trim(gm, pad); - POSTACTION(gm); - } - return result; -} - -size_t dlmalloc_footprint(void) { - return gm->footprint; -} - -size_t dlmalloc_max_footprint(void) { - return gm->max_footprint; -} - -#if !NO_MALLINFO -struct mallinfo dlmallinfo(void) { - return internal_mallinfo(gm); -} -#endif /* NO_MALLINFO */ - -void dlmalloc_stats() { - internal_malloc_stats(gm); -} - -size_t dlmalloc_usable_size(void* mem) { - if (mem != 0) { - mchunkptr p = mem2chunk(mem); - if (cinuse(p)) - return chunksize(p) - overhead_for(p); - } - return 0; -} - -int dlmallopt(int param_number, int value) { - return change_mparam(param_number, value); -} - -#endif /* !ONLY_MSPACES */ - -/* ----------------------------- user mspaces ---------------------------- */ - -#if MSPACES - -static mstate init_user_mstate(char* tbase, size_t tsize) { - size_t msize = pad_request(sizeof(struct malloc_state)); - mchunkptr mn; - mchunkptr msp = align_as_chunk(tbase); - mstate m = (mstate)(chunk2mem(msp)); - memset(m, 0, msize); - INITIAL_LOCK(&m->mutex); - msp->head = (msize|PINUSE_BIT|CINUSE_BIT); - m->seg.base = m->least_addr = tbase; - m->seg.size = m->footprint = m->max_footprint = tsize; - m->magic = mparams.magic; - m->mflags = mparams.default_mflags; - disable_contiguous(m); - init_bins(m); - mn = next_chunk(mem2chunk(m)); - init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) - TOP_FOOT_SIZE); - check_top_chunk(m, m->top); - return m; -} - -mspace create_mspace(size_t capacity, int locked) { - mstate m = 0; - size_t msize = pad_request(sizeof(struct malloc_state)); - init_mparams(); /* Ensure pagesize etc initialized */ - - if (capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { - size_t rs = ((capacity == 0)? mparams.granularity : - (capacity + TOP_FOOT_SIZE + msize)); - size_t tsize = granularity_align(rs); - char* tbase = (char*)(CALL_MMAP(tsize)); - if (tbase != CMFAIL) { - m = init_user_mstate(tbase, tsize); - m->seg.sflags = IS_MMAPPED_BIT; - set_lock(m, locked); - } - } - return (mspace)m; -} - -mspace create_mspace_with_base(void* base, size_t capacity, int locked) { - mstate m = 0; - size_t msize = pad_request(sizeof(struct malloc_state)); - init_mparams(); /* Ensure pagesize etc initialized */ - - if (capacity > msize + TOP_FOOT_SIZE && - capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { - m = init_user_mstate((char*)base, capacity); - m->seg.sflags = EXTERN_BIT; - set_lock(m, locked); - } - return (mspace)m; -} - -size_t destroy_mspace(mspace msp) { - size_t freed = 0; - mstate ms = (mstate)msp; - if (ok_magic(ms)) { - msegmentptr sp = &ms->seg; - while (sp != 0) { - char* base = sp->base; - size_t size = sp->size; - flag_t flag = sp->sflags; - sp = sp->next; - if ((flag & IS_MMAPPED_BIT) && !(flag & EXTERN_BIT) && - CALL_MUNMAP(base, size) == 0) - freed += size; - } - } - else { - USAGE_ERROR_ACTION(ms,ms); - } - return freed; -} - -/* - mspace versions of routines are near-clones of the global - versions. This is not so nice but better than the alternatives. -*/ - - -void* mspace_malloc(mspace msp, size_t bytes) { - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; - } - if (!PREACTION(ms)) { - void* mem; - size_t nb; - if (bytes <= MAX_SMALL_REQUEST) { - bindex_t idx; - binmap_t smallbits; - nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); - idx = small_index(nb); - smallbits = ms->smallmap >> idx; - - if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ - mchunkptr b, p; - idx += ~smallbits & 1; /* Uses next bin if idx empty */ - b = smallbin_at(ms, idx); - p = b->fd; - assert(chunksize(p) == small_index2size(idx)); - unlink_first_small_chunk(ms, b, p, idx); - set_inuse_and_pinuse(ms, p, small_index2size(idx)); - mem = chunk2mem(p); - check_malloced_chunk(ms, mem, nb); - goto postaction; - } - - else if (nb > ms->dvsize) { - if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ - mchunkptr b, p, r; - size_t rsize; - bindex_t i; - binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); - binmap_t leastbit = least_bit(leftbits); - compute_bit2idx(leastbit, i); - b = smallbin_at(ms, i); - p = b->fd; - assert(chunksize(p) == small_index2size(i)); - unlink_first_small_chunk(ms, b, p, i); - rsize = small_index2size(i) - nb; - /* Fit here cannot be remainderless if 4byte sizes */ - if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) - set_inuse_and_pinuse(ms, p, small_index2size(i)); - else { - set_size_and_pinuse_of_inuse_chunk(ms, p, nb); - r = chunk_plus_offset(p, nb); - set_size_and_pinuse_of_free_chunk(r, rsize); - replace_dv(ms, r, rsize); - } - mem = chunk2mem(p); - check_malloced_chunk(ms, mem, nb); - goto postaction; - } - - else if (ms->treemap != 0 && (mem = tmalloc_small(ms, nb)) != 0) { - check_malloced_chunk(ms, mem, nb); - goto postaction; - } - } - } - else if (bytes >= MAX_REQUEST) - nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ - else { - nb = pad_request(bytes); - if (ms->treemap != 0 && (mem = tmalloc_large(ms, nb)) != 0) { - check_malloced_chunk(ms, mem, nb); - goto postaction; - } - } - - if (nb <= ms->dvsize) { - size_t rsize = ms->dvsize - nb; - mchunkptr p = ms->dv; - if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ - mchunkptr r = ms->dv = chunk_plus_offset(p, nb); - ms->dvsize = rsize; - set_size_and_pinuse_of_free_chunk(r, rsize); - set_size_and_pinuse_of_inuse_chunk(ms, p, nb); - } - else { /* exhaust dv */ - size_t dvs = ms->dvsize; - ms->dvsize = 0; - ms->dv = 0; - set_inuse_and_pinuse(ms, p, dvs); - } - mem = chunk2mem(p); - check_malloced_chunk(ms, mem, nb); - goto postaction; - } - - else if (nb < ms->topsize) { /* Split top */ - size_t rsize = ms->topsize -= nb; - mchunkptr p = ms->top; - mchunkptr r = ms->top = chunk_plus_offset(p, nb); - r->head = rsize | PINUSE_BIT; - set_size_and_pinuse_of_inuse_chunk(ms, p, nb); - mem = chunk2mem(p); - check_top_chunk(ms, ms->top); - check_malloced_chunk(ms, mem, nb); - goto postaction; - } - - mem = sys_alloc(ms, nb); - - postaction: - POSTACTION(ms); - return mem; - } - - return 0; -} - -void mspace_free(mspace msp, void* mem) { - if (mem != 0) { - mchunkptr p = mem2chunk(mem); -#if FOOTERS - mstate fm = get_mstate_for(p); -#else /* FOOTERS */ - mstate fm = (mstate)msp; -#endif /* FOOTERS */ - if (!ok_magic(fm)) { - USAGE_ERROR_ACTION(fm, p); - return; - } - if (!PREACTION(fm)) { - check_inuse_chunk(fm, p); - if (RTCHECK(ok_address(fm, p) && ok_cinuse(p))) { - size_t psize = chunksize(p); - mchunkptr next = chunk_plus_offset(p, psize); - if (!pinuse(p)) { - size_t prevsize = p->prev_foot; - if ((prevsize & IS_MMAPPED_BIT) != 0) { - prevsize &= ~IS_MMAPPED_BIT; - psize += prevsize + MMAP_FOOT_PAD; - if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) - fm->footprint -= psize; - goto postaction; - } - else { - mchunkptr prev = chunk_minus_offset(p, prevsize); - psize += prevsize; - p = prev; - if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ - if (p != fm->dv) { - unlink_chunk(fm, p, prevsize); - } - else if ((next->head & INUSE_BITS) == INUSE_BITS) { - fm->dvsize = psize; - set_free_with_pinuse(p, psize, next); - goto postaction; - } - } - else - goto erroraction; - } - } - - if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { - if (!cinuse(next)) { /* consolidate forward */ - if (next == fm->top) { - size_t tsize = fm->topsize += psize; - fm->top = p; - p->head = tsize | PINUSE_BIT; - if (p == fm->dv) { - fm->dv = 0; - fm->dvsize = 0; - } - if (should_trim(fm, tsize)) - sys_trim(fm, 0); - goto postaction; - } - else if (next == fm->dv) { - size_t dsize = fm->dvsize += psize; - fm->dv = p; - set_size_and_pinuse_of_free_chunk(p, dsize); - goto postaction; - } - else { - size_t nsize = chunksize(next); - psize += nsize; - unlink_chunk(fm, next, nsize); - set_size_and_pinuse_of_free_chunk(p, psize); - if (p == fm->dv) { - fm->dvsize = psize; - goto postaction; - } - } - } - else - set_free_with_pinuse(p, psize, next); - insert_chunk(fm, p, psize); - check_free_chunk(fm, p); - goto postaction; - } - } - erroraction: - USAGE_ERROR_ACTION(fm, p); - postaction: - POSTACTION(fm); - } - } -} - -void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size) { - void* mem; - size_t req = 0; - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; - } - if (n_elements != 0) { - req = n_elements * elem_size; - if (((n_elements | elem_size) & ~(size_t)0xffff) && - (req / n_elements != elem_size)) - req = MAX_SIZE_T; /* force downstream failure on overflow */ - } - mem = internal_malloc(ms, req); - if (mem != 0 && calloc_must_clear(mem2chunk(mem))) - memset(mem, 0, req); - return mem; -} - -void* mspace_realloc(mspace msp, void* oldmem, size_t bytes) { - if (oldmem == 0) - return mspace_malloc(msp, bytes); -#ifdef REALLOC_ZERO_BYTES_FREES - if (bytes == 0) { - mspace_free(msp, oldmem); - return 0; - } -#endif /* REALLOC_ZERO_BYTES_FREES */ - else { -#if FOOTERS - mchunkptr p = mem2chunk(oldmem); - mstate ms = get_mstate_for(p); -#else /* FOOTERS */ - mstate ms = (mstate)msp; -#endif /* FOOTERS */ - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; - } - return internal_realloc(ms, oldmem, bytes); - } -} - -void* mspace_memalign(mspace msp, size_t alignment, size_t bytes) { - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; - } - return internal_memalign(ms, alignment, bytes); -} - -void** mspace_independent_calloc(mspace msp, size_t n_elements, - size_t elem_size, void* chunks[]) { - size_t sz = elem_size; /* serves as 1-element array */ - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; - } - return ialloc(ms, n_elements, &sz, 3, chunks); -} - -void** mspace_independent_comalloc(mspace msp, size_t n_elements, - size_t sizes[], void* chunks[]) { - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; - } - return ialloc(ms, n_elements, sizes, 0, chunks); -} - -int mspace_trim(mspace msp, size_t pad) { - int result = 0; - mstate ms = (mstate)msp; - if (ok_magic(ms)) { - if (!PREACTION(ms)) { - result = sys_trim(ms, pad); - POSTACTION(ms); - } - } - else { - USAGE_ERROR_ACTION(ms,ms); - } - return result; -} - -void mspace_malloc_stats(mspace msp) { - mstate ms = (mstate)msp; - if (ok_magic(ms)) { - internal_malloc_stats(ms); - } - else { - USAGE_ERROR_ACTION(ms,ms); - } -} - -size_t mspace_footprint(mspace msp) { - size_t result; - mstate ms = (mstate)msp; - if (ok_magic(ms)) { - result = ms->footprint; - } - USAGE_ERROR_ACTION(ms,ms); - return result; -} - - -size_t mspace_max_footprint(mspace msp) { - size_t result; - mstate ms = (mstate)msp; - if (ok_magic(ms)) { - result = ms->max_footprint; - } - USAGE_ERROR_ACTION(ms,ms); - return result; -} - - -#if !NO_MALLINFO -struct mallinfo mspace_mallinfo(mspace msp) { - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - } - return internal_mallinfo(ms); -} -#endif /* NO_MALLINFO */ - -int mspace_mallopt(int param_number, int value) { - return change_mparam(param_number, value); -} - -#endif /* MSPACES */ - -/* -------------------- Alternative MORECORE functions ------------------- */ - -/* - Guidelines for creating a custom version of MORECORE: - - * For best performance, MORECORE should allocate in multiples of pagesize. - * MORECORE may allocate more memory than requested. (Or even less, - but this will usually result in a malloc failure.) - * MORECORE must not allocate memory when given argument zero, but - instead return one past the end address of memory from previous - nonzero call. - * For best performance, consecutive calls to MORECORE with positive - arguments should return increasing addresses, indicating that - space has been contiguously extended. - * Even though consecutive calls to MORECORE need not return contiguous - addresses, it must be OK for malloc'ed chunks to span multiple - regions in those cases where they do happen to be contiguous. - * MORECORE need not handle negative arguments -- it may instead - just return MFAIL when given negative arguments. - Negative arguments are always multiples of pagesize. MORECORE - must not misinterpret negative args as large positive unsigned - args. You can suppress all such calls from even occurring by defining - MORECORE_CANNOT_TRIM, - - As an example alternative MORECORE, here is a custom allocator - kindly contributed for pre-OSX macOS. It uses virtually but not - necessarily physically contiguous non-paged memory (locked in, - present and won't get swapped out). You can use it by uncommenting - this section, adding some #includes, and setting up the appropriate - defines above: - - #define MORECORE osMoreCore - - There is also a shutdown routine that should somehow be called for - cleanup upon program exit. - - #define MAX_POOL_ENTRIES 100 - #define MINIMUM_MORECORE_SIZE (64 * 1024U) - static int next_os_pool; - void *our_os_pools[MAX_POOL_ENTRIES]; - - void *osMoreCore(int size) - { - void *ptr = 0; - static void *sbrk_top = 0; - - if (size > 0) - { - if (size < MINIMUM_MORECORE_SIZE) - size = MINIMUM_MORECORE_SIZE; - if (CurrentExecutionLevel() == kTaskLevel) - ptr = PoolAllocateResident(size + RM_PAGE_SIZE, 0); - if (ptr == 0) - { - return (void *) MFAIL; - } - // save ptrs so they can be freed during cleanup - our_os_pools[next_os_pool] = ptr; - next_os_pool++; - ptr = (void *) ((((size_t) ptr) + RM_PAGE_MASK) & ~RM_PAGE_MASK); - sbrk_top = (char *) ptr + size; - return ptr; - } - else if (size < 0) - { - // we don't currently support shrink behavior - return (void *) MFAIL; - } - else - { - return sbrk_top; - } - } - - // cleanup any allocated memory pools - // called as last thing before shutting down driver - - void osCleanupMem(void) - { - void **ptr; - - for (ptr = our_os_pools; ptr < &our_os_pools[MAX_POOL_ENTRIES]; ptr++) - if (*ptr) - { - PoolDeallocate(*ptr); - *ptr = 0; - } - } - -*/ - - -/* ----------------------------------------------------------------------- -History: - V2.8.3 Thu Sep 22 11:16:32 2005 Doug Lea (dl at gee) - * Add max_footprint functions - * Ensure all appropriate literals are size_t - * Fix conditional compilation problem for some #define settings - * Avoid concatenating segments with the one provided - in create_mspace_with_base - * Rename some variables to avoid compiler shadowing warnings - * Use explicit lock initialization. - * Better handling of sbrk interference. - * Simplify and fix segment insertion, trimming and mspace_destroy - * Reinstate REALLOC_ZERO_BYTES_FREES option from 2.7.x - * Thanks especially to Dennis Flanagan for help on these. - - V2.8.2 Sun Jun 12 16:01:10 2005 Doug Lea (dl at gee) - * Fix memalign brace error. - - V2.8.1 Wed Jun 8 16:11:46 2005 Doug Lea (dl at gee) - * Fix improper #endif nesting in C++ - * Add explicit casts needed for C++ - - V2.8.0 Mon May 30 14:09:02 2005 Doug Lea (dl at gee) - * Use trees for large bins - * Support mspaces - * Use segments to unify sbrk-based and mmap-based system allocation, - removing need for emulation on most platforms without sbrk. - * Default safety checks - * Optional footer checks. Thanks to William Robertson for the idea. - * Internal code refactoring - * Incorporate suggestions and platform-specific changes. - Thanks to Dennis Flanagan, Colin Plumb, Niall Douglas, - Aaron Bachmann, Emery Berger, and others. - * Speed up non-fastbin processing enough to remove fastbins. - * Remove useless cfree() to avoid conflicts with other apps. - * Remove internal memcpy, memset. Compilers handle builtins better. - * Remove some options that no one ever used and rename others. - - V2.7.2 Sat Aug 17 09:07:30 2002 Doug Lea (dl at gee) - * Fix malloc_state bitmap array misdeclaration - - V2.7.1 Thu Jul 25 10:58:03 2002 Doug Lea (dl at gee) - * Allow tuning of FIRST_SORTED_BIN_SIZE - * Use PTR_UINT as type for all ptr->int casts. Thanks to John Belmonte. - * Better detection and support for non-contiguousness of MORECORE. - Thanks to Andreas Mueller, Conal Walsh, and Wolfram Gloger - * Bypass most of malloc if no frees. Thanks To Emery Berger. - * Fix freeing of old top non-contiguous chunk im sysmalloc. - * Raised default trim and map thresholds to 256K. - * Fix mmap-related #defines. Thanks to Lubos Lunak. - * Fix copy macros; added LACKS_FCNTL_H. Thanks to Neal Walfield. - * Branch-free bin calculation - * Default trim and mmap thresholds now 256K. - - V2.7.0 Sun Mar 11 14:14:06 2001 Doug Lea (dl at gee) - * Introduce independent_comalloc and independent_calloc. - Thanks to Michael Pachos for motivation and help. - * Make optional .h file available - * Allow > 2GB requests on 32bit systems. - * new WIN32 sbrk, mmap, munmap, lock code from . - Thanks also to Andreas Mueller , - and Anonymous. - * Allow override of MALLOC_ALIGNMENT (Thanks to Ruud Waij for - helping test this.) - * memalign: check alignment arg - * realloc: don't try to shift chunks backwards, since this - leads to more fragmentation in some programs and doesn't - seem to help in any others. - * Collect all cases in malloc requiring system memory into sysmalloc - * Use mmap as backup to sbrk - * Place all internal state in malloc_state - * Introduce fastbins (although similar to 2.5.1) - * Many minor tunings and cosmetic improvements - * Introduce USE_PUBLIC_MALLOC_WRAPPERS, USE_MALLOC_LOCK - * Introduce MALLOC_FAILURE_ACTION, MORECORE_CONTIGUOUS - Thanks to Tony E. Bennett and others. - * Include errno.h to support default failure action. - - V2.6.6 Sun Dec 5 07:42:19 1999 Doug Lea (dl at gee) - * return null for negative arguments - * Added Several WIN32 cleanups from Martin C. Fong - * Add 'LACKS_SYS_PARAM_H' for those systems without 'sys/param.h' - (e.g. WIN32 platforms) - * Cleanup header file inclusion for WIN32 platforms - * Cleanup code to avoid Microsoft Visual C++ compiler complaints - * Add 'USE_DL_PREFIX' to quickly allow co-existence with existing - memory allocation routines - * Set 'malloc_getpagesize' for WIN32 platforms (needs more work) - * Use 'assert' rather than 'ASSERT' in WIN32 code to conform to - usage of 'assert' in non-WIN32 code - * Improve WIN32 'sbrk()' emulation's 'findRegion()' routine to - avoid infinite loop - * Always call 'fREe()' rather than 'free()' - - V2.6.5 Wed Jun 17 15:57:31 1998 Doug Lea (dl at gee) - * Fixed ordering problem with boundary-stamping - - V2.6.3 Sun May 19 08:17:58 1996 Doug Lea (dl at gee) - * Added pvalloc, as recommended by H.J. Liu - * Added 64bit pointer support mainly from Wolfram Gloger - * Added anonymously donated WIN32 sbrk emulation - * Malloc, calloc, getpagesize: add optimizations from Raymond Nijssen - * malloc_extend_top: fix mask error that caused wastage after - foreign sbrks - * Add linux mremap support code from HJ Liu - - V2.6.2 Tue Dec 5 06:52:55 1995 Doug Lea (dl at gee) - * Integrated most documentation with the code. - * Add support for mmap, with help from - Wolfram Gloger (Gloger@lrz.uni-muenchen.de). - * Use last_remainder in more cases. - * Pack bins using idea from colin@nyx10.cs.du.edu - * Use ordered bins instead of best-fit threshhold - * Eliminate block-local decls to simplify tracing and debugging. - * Support another case of realloc via move into top - * Fix error occuring when initial sbrk_base not word-aligned. - * Rely on page size for units instead of SBRK_UNIT to - avoid surprises about sbrk alignment conventions. - * Add mallinfo, mallopt. Thanks to Raymond Nijssen - (raymond@es.ele.tue.nl) for the suggestion. - * Add `pad' argument to malloc_trim and top_pad mallopt parameter. - * More precautions for cases where other routines call sbrk, - courtesy of Wolfram Gloger (Gloger@lrz.uni-muenchen.de). - * Added macros etc., allowing use in linux libc from - H.J. Lu (hjl@gnu.ai.mit.edu) - * Inverted this history list - - V2.6.1 Sat Dec 2 14:10:57 1995 Doug Lea (dl at gee) - * Re-tuned and fixed to behave more nicely with V2.6.0 changes. - * Removed all preallocation code since under current scheme - the work required to undo bad preallocations exceeds - the work saved in good cases for most test programs. - * No longer use return list or unconsolidated bins since - no scheme using them consistently outperforms those that don't - given above changes. - * Use best fit for very large chunks to prevent some worst-cases. - * Added some support for debugging - - V2.6.0 Sat Nov 4 07:05:23 1995 Doug Lea (dl at gee) - * Removed footers when chunks are in use. Thanks to - Paul Wilson (wilson@cs.texas.edu) for the suggestion. - - V2.5.4 Wed Nov 1 07:54:51 1995 Doug Lea (dl at gee) - * Added malloc_trim, with help from Wolfram Gloger - (wmglo@Dent.MED.Uni-Muenchen.DE). - - V2.5.3 Tue Apr 26 10:16:01 1994 Doug Lea (dl at g) - - V2.5.2 Tue Apr 5 16:20:40 1994 Doug Lea (dl at g) - * realloc: try to expand in both directions - * malloc: swap order of clean-bin strategy; - * realloc: only conditionally expand backwards - * Try not to scavenge used bins - * Use bin counts as a guide to preallocation - * Occasionally bin return list chunks in first scan - * Add a few optimizations from colin@nyx10.cs.du.edu - - V2.5.1 Sat Aug 14 15:40:43 1993 Doug Lea (dl at g) - * faster bin computation & slightly different binning - * merged all consolidations to one part of malloc proper - (eliminating old malloc_find_space & malloc_clean_bin) - * Scan 2 returns chunks (not just 1) - * Propagate failure in realloc if malloc returns 0 - * Add stuff to allow compilation on non-ANSI compilers - from kpv@research.att.com - - V2.5 Sat Aug 7 07:41:59 1993 Doug Lea (dl at g.oswego.edu) - * removed potential for odd address access in prev_chunk - * removed dependency on getpagesize.h - * misc cosmetics and a bit more internal documentation - * anticosmetics: mangled names in macros to evade debugger strangeness - * tested on sparc, hp-700, dec-mips, rs6000 - with gcc & native cc (hp, dec only) allowing - Detlefs & Zorn comparison study (in SIGPLAN Notices.) - - Trial version Fri Aug 28 13:14:29 1992 Doug Lea (dl at g.oswego.edu) - * Based loosely on libg++-1.2X malloc. (It retains some of the overall - structure of old version, but most details differ.) - -*/ diff --git a/winsup/cygwin/malloc_wrapper.cc b/winsup/cygwin/malloc_wrapper.cc deleted file mode 100644 index 86b74d564..000000000 --- a/winsup/cygwin/malloc_wrapper.cc +++ /dev/null @@ -1,305 +0,0 @@ -/* malloc_wrapper.cc - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007 Red Hat, Inc. - - Originally written by Steve Chamberlain of Cygnus Support - sac@cygnus.com - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "perprocess.h" -#include "cygmalloc.h" -#ifndef MALLOC_DEBUG -#include -#endif -extern "C" struct mallinfo dlmallinfo (); - -/* we provide these stubs to call into a user's - provided malloc if there is one - otherwise - functions we provide - like strdup will cause - problems if malloced on our heap and free'd on theirs. -*/ - -static int export_malloc_called; -static int use_internal_malloc = 1; - -/* These routines are used by the application if it - doesn't provide its own malloc. */ - -extern "C" void -free (void *p) -{ - malloc_printf ("(%p), called by %p", p, __builtin_return_address (0)); - if (!use_internal_malloc) - user_data->free (p); - else - { - __malloc_lock (); - dlfree (p); - __malloc_unlock (); - } -} - -extern "C" void * -malloc (size_t size) -{ - void *res; - export_malloc_called = 1; - if (!use_internal_malloc) - res = user_data->malloc (size); - else - { - __malloc_lock (); - res = dlmalloc (size); - __malloc_unlock (); - } - malloc_printf ("(%d) = %x, called by %p", size, res, __builtin_return_address (0)); - return res; -} - -extern "C" void * -realloc (void *p, size_t size) -{ - void *res; - if (!use_internal_malloc) - res = user_data->realloc (p, size); - else - { - __malloc_lock (); - res = dlrealloc (p, size); - __malloc_unlock (); - } - malloc_printf ("(%x, %d) = %x, called by %x", p, size, res, __builtin_return_address (0)); - return res; -} - -/* BSD extension: Same as realloc, just if it fails to allocate new memory, - it frees the incoming pointer. */ -extern "C" void * -reallocf (void *p, size_t size) -{ - void *res = realloc (p, size); - if (!res && p) - free (p); - return res; -} - -extern "C" void * -calloc (size_t nmemb, size_t size) -{ - void *res; - if (!use_internal_malloc) - res = user_data->calloc (nmemb, size); - else - { - __malloc_lock (); - res = dlcalloc (nmemb, size); - __malloc_unlock (); - } - malloc_printf ("(%d, %d) = %x, called by %x", nmemb, size, res, __builtin_return_address (0)); - return res; -} - -extern "C" int -posix_memalign (void **memptr, size_t alignment, size_t bytes) -{ - save_errno save; - - void *res; - if (!use_internal_malloc) - return ENOSYS; - if ((alignment & (alignment - 1)) != 0) - return EINVAL; - __malloc_lock (); - res = dlmemalign (alignment, bytes); - __malloc_unlock (); - if (!res) - return ENOMEM; - if (memptr) - *memptr = res; - return 0; -} - -extern "C" void * -memalign (size_t alignment, size_t bytes) -{ - void *res; - if (!use_internal_malloc) - { - set_errno (ENOSYS); - res = NULL; - } - else - { - __malloc_lock (); - res = dlmemalign (alignment, bytes); - __malloc_unlock (); - } - - return res; -} - -extern "C" void * -valloc (size_t bytes) -{ - void *res; - if (!use_internal_malloc) - { - set_errno (ENOSYS); - res = NULL; - } - else - { - __malloc_lock (); - res = dlvalloc (bytes); - __malloc_unlock (); - } - - return res; -} - -extern "C" size_t -malloc_usable_size (void *p) -{ - size_t res; - if (!use_internal_malloc) - { - set_errno (ENOSYS); - res = 0; - } - else - { - __malloc_lock (); - res = dlmalloc_usable_size (p); - __malloc_unlock (); - } - - return res; -} - -extern "C" int -malloc_trim (size_t pad) -{ - size_t res; - if (!use_internal_malloc) - { - set_errno (ENOSYS); - res = 0; - } - else - { - __malloc_lock (); - res = dlmalloc_trim (pad); - __malloc_unlock (); - } - - return res; -} - -extern "C" int -mallopt (int p, int v) -{ - int res; - if (!use_internal_malloc) - { - set_errno (ENOSYS); - res = 0; - } - else - { - __malloc_lock (); - res = dlmallopt (p, v); - __malloc_unlock (); - } - - return res; -} - -extern "C" void -malloc_stats () -{ - if (!use_internal_malloc) - set_errno (ENOSYS); - else - { - __malloc_lock (); - dlmalloc_stats (); - __malloc_unlock (); - } -} - -extern "C" struct mallinfo -mallinfo () -{ - struct mallinfo m; - if (!use_internal_malloc) - set_errno (ENOSYS); - else - { - __malloc_lock (); - m = dlmallinfo (); - __malloc_unlock (); - } - - return m; -} - -extern "C" char * -strdup (const char *s) -{ - char *p; - size_t len = strlen (s) + 1; - if ((p = (char *) malloc (len)) != NULL) - memcpy (p, s, len); - return p; -} - -/* We use a critical section to lock access to the malloc data - structures. This permits malloc to be called from different - threads. Note that it does not make malloc reentrant, and it does - not permit a signal handler to call malloc. The malloc code in - newlib will call __malloc_lock and __malloc_unlock at appropriate - times. */ - -muto NO_COPY mallock; - -void -malloc_init () -{ - mallock.init ("mallock"); - -#ifndef MALLOC_DEBUG - /* Check if malloc is provided by application. If so, redirect all - calls to malloc/free/realloc to application provided. This may - happen if some other dll calls cygwin's malloc, but main code provides - its own malloc */ - if (!in_forkee) - { - user_data->free (user_data->malloc (16)); - if (export_malloc_called) - malloc_printf ("using internal malloc"); - else - { - use_internal_malloc = 0; - malloc_printf ("using external malloc"); - } - } -#endif -} - -extern "C" void -__set_ENOMEM () -{ - set_errno (ENOMEM); -} diff --git a/winsup/cygwin/mcount.c b/winsup/cygwin/mcount.c deleted file mode 100644 index 4f69864b3..000000000 --- a/winsup/cygwin/mcount.c +++ /dev/null @@ -1,172 +0,0 @@ -/*- - * Copyright (c) 1983, 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - */ - -#if !defined(lint) && !defined(_KERNEL) && defined(LIBC_SCCS) -static char rcsid[] = "$OpenBSD: mcount.c,v 1.6 1997/07/23 21:11:27 kstailey Exp $"; -#endif - -#include -#include - -/* - * mcount is called on entry to each function compiled with the profiling - * switch set. _mcount(), which is declared in a machine-dependent way - * with _MCOUNT_DECL, does the actual work and is either inlined into a - * C routine or called by an assembly stub. In any case, this magic is - * taken care of by the MCOUNT definition in . - * - * _mcount updates data structures that represent traversals of the - * program's call graph edges. frompc and selfpc are the return - * address and function address that represents the given call graph edge. - * - * Note: the original BSD code used the same variable (frompcindex) for - * both frompcindex and frompc. Any reasonable, modern compiler will - * perform this optimization. - */ -//_MCOUNT_DECL __P((u_long frompc, u_long selfpc)); -_MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */ - register u_long frompc, selfpc; -{ - register u_short *frompcindex; - register struct tostruct *top, *prevtop; - register struct gmonparam *p; - register long toindex; - - p = &_gmonparam; - /* - * check that we are profiling - * and that we aren't recursively invoked. - */ - if (p->state != GMON_PROF_ON) - return; - p->state = GMON_PROF_BUSY; - /* - * check that frompcindex is a reasonable pc value. - * for example: signal catchers get called from the stack, - * not from text space. too bad. - */ - frompc -= p->lowpc; - if (frompc > p->textsize) - goto done; - -#if (HASHFRACTION & (HASHFRACTION - 1)) == 0 - if (p->hashfraction == HASHFRACTION) - frompcindex = - &p->froms[frompc / (HASHFRACTION * sizeof(*p->froms))]; - else -#endif - frompcindex = - &p->froms[frompc / (p->hashfraction * sizeof(*p->froms))]; - toindex = *frompcindex; - if (toindex == 0) { - /* - * first time traversing this arc - */ - toindex = ++p->tos[0].link; - if (toindex >= p->tolimit) - /* halt further profiling */ - goto overflow; - - *frompcindex = toindex; - top = &p->tos[toindex]; - top->selfpc = selfpc; - top->count = 1; - top->link = 0; - goto done; - } - top = &p->tos[toindex]; - if (top->selfpc == selfpc) { - /* - * arc at front of chain; usual case. - */ - top->count++; - goto done; - } - /* - * have to go looking down chain for it. - * top points to what we are looking at, - * prevtop points to previous top. - * we know it is not at the head of the chain. - */ - for (; /* goto done */; ) { - if (top->link == 0) { - /* - * top is end of the chain and none of the chain - * had top->selfpc == selfpc. - * so we allocate a new tostruct - * and link it to the head of the chain. - */ - toindex = ++p->tos[0].link; - if (toindex >= p->tolimit) - goto overflow; - - top = &p->tos[toindex]; - top->selfpc = selfpc; - top->count = 1; - top->link = *frompcindex; - *frompcindex = toindex; - goto done; - } - /* - * otherwise, check the next arc on the chain. - */ - prevtop = top; - top = &p->tos[top->link]; - if (top->selfpc == selfpc) { - /* - * there it is. - * increment its count - * move it to the head of the chain. - */ - top->count++; - toindex = prevtop->link; - prevtop->link = top->link; - top->link = *frompcindex; - *frompcindex = toindex; - goto done; - } - } -done: - p->state = GMON_PROF_ON; - return; -overflow: - p->state = GMON_PROF_ERROR; - return; -} - -/* - * Actual definition of mcount function. Defined in , - * which is included by - */ -MCOUNT - diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc deleted file mode 100644 index 29b8159ad..000000000 --- a/winsup/cygwin/miscfuncs.cc +++ /dev/null @@ -1,414 +0,0 @@ -/* miscfuncs.cc: misc funcs that don't belong anywhere else - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "miscfuncs.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "cygtls.h" -#include "ntdll.h" - -long tls_ix = -1; - -const char case_folded_lower[] NO_COPY = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, '!', '"', '#', '$', '%', '&', 39, '(', ')', '*', '+', ',', '-', '.', '/', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', - '@', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '[', 92, ']', '^', '_', - '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', 127, - 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, - 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, - 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, - 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, - 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, - 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, - 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, - 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 -}; - -const char case_folded_upper[] NO_COPY = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, '!', '"', '#', '$', '%', '&', 39, '(', ')', '*', '+', ',', '-', '.', '/', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', - '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', 92, ']', '^', '_', - '`', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~', 127, - 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, - 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, - 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, - 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, - 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, - 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, - 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, - 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 -}; - -const char isalpha_array[] NO_COPY = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, -0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0, 0, 0, 0, 0, - 0,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, -0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -extern "C" int __stdcall -cygwin_wcscasecmp (const wchar_t *ws, const wchar_t *wt) -{ - UNICODE_STRING us, ut; - - RtlInitUnicodeString (&us, ws); - RtlInitUnicodeString (&ut, wt); - return RtlCompareUnicodeString (&us, &ut, TRUE); -} - -extern "C" int __stdcall -cygwin_wcsncasecmp (const wchar_t *ws, const wchar_t *wt, size_t n) -{ - UNICODE_STRING us, ut; - size_t ls = 0, lt = 0; - - while (ws[ls] && ls < n) - ++ls; - RtlInitCountedUnicodeString (&us, ws, ls * sizeof (WCHAR)); - while (wt[lt] && lt < n) - ++lt; - RtlInitCountedUnicodeString (&ut, wt, lt * sizeof (WCHAR)); - return RtlCompareUnicodeString (&us, &ut, TRUE); -} - -extern "C" int __stdcall -cygwin_strcasecmp (const char *cs, const char *ct) -{ - UNICODE_STRING us, ut; - ULONG len; - - len = (strlen (cs) + 1) * sizeof (WCHAR); - RtlInitEmptyUnicodeString (&us, (PWCHAR) alloca (len), len); - us.Length = sys_mbstowcs (us.Buffer, us.MaximumLength, cs) * sizeof (WCHAR); - len = (strlen (ct) + 1) * sizeof (WCHAR); - RtlInitEmptyUnicodeString (&ut, (PWCHAR) alloca (len), len); - ut.Length = sys_mbstowcs (ut.Buffer, ut.MaximumLength, ct) * sizeof (WCHAR); - return RtlCompareUnicodeString (&us, &ut, TRUE); -} - -extern "C" int __stdcall -cygwin_strncasecmp (const char *cs, const char *ct, size_t n) -{ - UNICODE_STRING us, ut; - ULONG len; - size_t ls = 0, lt = 0; - - while (cs[ls] && ls < n) - ++ls; - len = (ls + 1) * sizeof (WCHAR); - RtlInitEmptyUnicodeString (&us, (PWCHAR) alloca (len), len); - us.Length = sys_mbstowcs (us.Buffer, ls + 1, cs, ls) * sizeof (WCHAR); - while (ct[lt] && lt < n) - ++lt; - len = (lt + 1) * sizeof (WCHAR); - RtlInitEmptyUnicodeString (&ut, (PWCHAR) alloca (len), len); - ut.Length = sys_mbstowcs (ut.Buffer, lt + 1, ct, lt) * sizeof (WCHAR); - return RtlCompareUnicodeString (&us, &ut, TRUE); -} - -extern "C" char * __stdcall -cygwin_strlwr (char *string) -{ - UNICODE_STRING us; - size_t len = (strlen (string) + 1) * sizeof (WCHAR); - - us.MaximumLength = len; us.Buffer = (PWCHAR) alloca (len); - us.Length = sys_mbstowcs (us.Buffer, len, string) * sizeof (WCHAR) - - sizeof (WCHAR); - RtlDowncaseUnicodeString (&us, &us, FALSE); - sys_wcstombs (string, len / sizeof (WCHAR), us.Buffer); - return string; -} - -extern "C" char * __stdcall -cygwin_strupr (char *string) -{ - UNICODE_STRING us; - size_t len = (strlen (string) + 1) * sizeof (WCHAR); - - us.MaximumLength = len; us.Buffer = (PWCHAR) alloca (len); - us.Length = sys_mbstowcs (us.Buffer, len, string) * sizeof (WCHAR) - - sizeof (WCHAR); - RtlUpcaseUnicodeString (&us, &us, FALSE); - sys_wcstombs (string, len / sizeof (WCHAR), us.Buffer); - return string; -} - -int __stdcall -check_invalid_virtual_addr (const void *s, unsigned sz) -{ - MEMORY_BASIC_INFORMATION mbuf; - const void *end; - - for (end = (char *) s + sz; s < end; - s = (char *) mbuf.BaseAddress + mbuf.RegionSize) - if (!VirtualQuery (s, &mbuf, sizeof mbuf)) - return EINVAL; - return 0; -} - -static char __attribute__ ((noinline)) -dummytest (volatile char *p) -{ - return *p; -} - -ssize_t -check_iovec (const struct iovec *iov, int iovcnt, bool forwrite) -{ - if (iovcnt <= 0 || iovcnt > IOV_MAX) - { - set_errno (EINVAL); - return -1; - } - - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - size_t tot = 0; - - while (iovcnt != 0) - { - if (iov->iov_len > SSIZE_MAX || (tot += iov->iov_len) > SSIZE_MAX) - { - set_errno (EINVAL); - return -1; - } - - volatile char *p = ((char *) iov->iov_base) + iov->iov_len - 1; - if (!iov->iov_len) - /* nothing to do */; - else if (!forwrite) - *p = dummytest (p); - else - dummytest (p); - - iov++; - iovcnt--; - } - - assert (tot <= SSIZE_MAX); - - return (ssize_t) tot; -} - -extern "C" int -low_priority_sleep (DWORD secs) -{ - HANDLE thisthread = GetCurrentThread (); - int curr_prio = GetThreadPriority (thisthread); - bool staylow; - if (secs != INFINITE) - staylow = false; - else - { - secs = 0; - staylow = true; - } - - if (!secs) - { - for (int i = 0; i < 3; i++) - SwitchToThread (); - } - else - { - int new_prio; - if (GetCurrentThreadId () == cygthread::main_thread_id) - new_prio = THREAD_PRIORITY_LOWEST; - else - new_prio = GetThreadPriority (hMainThread); - - if (curr_prio != new_prio) - /* Force any threads in normal priority to be scheduled */ - SetThreadPriority (thisthread, new_prio); - Sleep (secs); - - if (!staylow && curr_prio != new_prio) - SetThreadPriority (thisthread, curr_prio); - } - - return curr_prio; -} - -/* Get a default value for the nice factor. When changing these values, - have a look into the below function nice_to_winprio. The values must - match the layout of the static "priority" array. */ -int -winprio_to_nice (DWORD prio) -{ - switch (prio) - { - case REALTIME_PRIORITY_CLASS: - return -20; - case HIGH_PRIORITY_CLASS: - return -16; - case ABOVE_NORMAL_PRIORITY_CLASS: - return -8; - case NORMAL_PRIORITY_CLASS: - return 0; - case BELOW_NORMAL_PRIORITY_CLASS: - return 8; - case IDLE_PRIORITY_CLASS: - return 16; - } - return 0; -} - -/* Get a Win32 priority matching the incoming nice factor. The incoming - nice is limited to the interval [-NZERO,NZERO-1]. */ -DWORD -nice_to_winprio (int &nice) -{ - static const DWORD priority[] NO_COPY = - { - REALTIME_PRIORITY_CLASS, /* 0 */ - HIGH_PRIORITY_CLASS, /* 1 */ - HIGH_PRIORITY_CLASS, - HIGH_PRIORITY_CLASS, - HIGH_PRIORITY_CLASS, - HIGH_PRIORITY_CLASS, - HIGH_PRIORITY_CLASS, - HIGH_PRIORITY_CLASS, /* 7 */ - ABOVE_NORMAL_PRIORITY_CLASS, /* 8 */ - ABOVE_NORMAL_PRIORITY_CLASS, - ABOVE_NORMAL_PRIORITY_CLASS, - ABOVE_NORMAL_PRIORITY_CLASS, - ABOVE_NORMAL_PRIORITY_CLASS, - ABOVE_NORMAL_PRIORITY_CLASS, - ABOVE_NORMAL_PRIORITY_CLASS, - ABOVE_NORMAL_PRIORITY_CLASS, /* 15 */ - NORMAL_PRIORITY_CLASS, /* 16 */ - NORMAL_PRIORITY_CLASS, - NORMAL_PRIORITY_CLASS, - NORMAL_PRIORITY_CLASS, - NORMAL_PRIORITY_CLASS, - NORMAL_PRIORITY_CLASS, - NORMAL_PRIORITY_CLASS, - NORMAL_PRIORITY_CLASS, /* 23 */ - BELOW_NORMAL_PRIORITY_CLASS, /* 24 */ - BELOW_NORMAL_PRIORITY_CLASS, - BELOW_NORMAL_PRIORITY_CLASS, - BELOW_NORMAL_PRIORITY_CLASS, - BELOW_NORMAL_PRIORITY_CLASS, - BELOW_NORMAL_PRIORITY_CLASS, - BELOW_NORMAL_PRIORITY_CLASS, - BELOW_NORMAL_PRIORITY_CLASS, /* 31 */ - IDLE_PRIORITY_CLASS, /* 32 */ - IDLE_PRIORITY_CLASS, - IDLE_PRIORITY_CLASS, - IDLE_PRIORITY_CLASS, - IDLE_PRIORITY_CLASS, - IDLE_PRIORITY_CLASS, - IDLE_PRIORITY_CLASS, - IDLE_PRIORITY_CLASS /* 39 */ - }; - if (nice < -NZERO) - nice = -NZERO; - else if (nice > NZERO - 1) - nice = NZERO - 1; - DWORD prio = priority[nice + NZERO]; - if (!wincap.has_extended_priority_class () - && (prio == BELOW_NORMAL_PRIORITY_CLASS - || prio == ABOVE_NORMAL_PRIORITY_CLASS)) - prio = NORMAL_PRIORITY_CLASS; - return prio; -} - -#undef CreatePipe -bool -create_pipe (PHANDLE hr,PHANDLE hw, LPSECURITY_ATTRIBUTES sa, DWORD n) -{ - for (int i = 0; i < 10; i++) - if (CreatePipe (hr, hw, sa, n)) - return true; - else if (GetLastError () == ERROR_PIPE_BUSY && i < 9) - Sleep (10); - else - break; - return false; -} - -/* backslashify: Convert all forward slashes in src path to back slashes - in dst path. Add a trailing slash to dst when trailing_slash_p arg - is set to 1. */ - -void -backslashify (const char *src, char *dst, bool trailing_slash_p) -{ - const char *start = src; - - while (*src) - { - if (*src == '/') - *dst++ = '\\'; - else - *dst++ = *src; - ++src; - } - if (trailing_slash_p - && src > start - && !isdirsep (src[-1])) - *dst++ = '\\'; - *dst++ = 0; -} - -/* slashify: Convert all back slashes in src path to forward slashes - in dst path. Add a trailing slash to dst when trailing_slash_p arg - is set to 1. */ - -void -slashify (const char *src, char *dst, bool trailing_slash_p) -{ - const char *start = src; - - while (*src) - { - if (*src == '\\') - *dst++ = '/'; - else - *dst++ = *src; - ++src; - } - if (trailing_slash_p - && src > start - && !isdirsep (src[-1])) - *dst++ = '/'; - *dst++ = 0; -} diff --git a/winsup/cygwin/miscfuncs.h b/winsup/cygwin/miscfuncs.h deleted file mode 100644 index 489f8b745..000000000 --- a/winsup/cygwin/miscfuncs.h +++ /dev/null @@ -1,42 +0,0 @@ -/* miscfuncs.h: main Cygwin header file. - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _MISCFUNCS_H -#define _MISCFUNCS_H -int winprio_to_nice (DWORD) __attribute__ ((regparm (1))); -DWORD nice_to_winprio (int &) __attribute__ ((regparm (1))); - -bool __stdcall create_pipe (PHANDLE, PHANDLE, LPSECURITY_ATTRIBUTES, DWORD) - __attribute__ ((regparm (3))); -#define CreatePipe create_pipe - -extern "C" int low_priority_sleep (DWORD) __attribute__ ((regparm (1))); -#define SLEEP_0_STAY_LOW INFINITE - -void backslashify (const char *, char *, bool); -void slashify (const char *, char *, bool); -#define isslash(c) ((c) == '/') - -extern void transform_chars (PWCHAR, PWCHAR); -inline void -transform_chars (PUNICODE_STRING upath, USHORT start_idx) -{ - transform_chars (upath->Buffer + start_idx, - upath->Buffer + upath->Length / sizeof (WCHAR) - 1); -} - -/* Memory checking */ -int __stdcall check_invalid_virtual_addr (const void *s, unsigned sz) __attribute__ ((regparm(2))); - -ssize_t check_iovec (const struct iovec *, int, bool) __attribute__ ((regparm(3))); -#define check_iovec_for_read(a, b) check_iovec ((a), (b), false) -#define check_iovec_for_write(a, b) check_iovec ((a), (b), true) -#endif /*_MISCFUNCS_H*/ diff --git a/winsup/cygwin/mkglobals_h b/winsup/cygwin/mkglobals_h deleted file mode 100755 index 1e409e01f..000000000 --- a/winsup/cygwin/mkglobals_h +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/perl -my @argv = @ARGV; -$_ = join('', <>); -s/\n[^\n]*!globals.h[^\n]*\n/\n/sog; -s%/\*.*?\*/%%sog; -s/(enum\s.*?{.*?})/munge($1)/soge; -s/^(\s*)([a-zA-Z_])/$1extern $2/mog; -s/extern (extern|enum)/$1/sog; -s/\n\s*extern static[^\n]*\n/\n/sog; -s/\s+=.*?;/;/sog; -s/^\n+//sog; -s/#include "winsup\.h"\n//so; -s/-NL-/\n/sog; -s/-EQ-/=/sog; -s/\s+\n/\n/sog; -s/\n{2,}/\n/sog; -print < 1); - -my ($ar, $as, $nm, $objcopy, %replace); -GetOptions('ar=s'=>\$ar, 'as=s'=>\$as,'nm=s'=>\$nm, 'objcopy=s'=>\$objcopy, 'replace=s'=>\%replace); - -# Args:: -# 1) import lib to create -# 2) input dll -# 3...) extra objects to add - -$_ = File::Spec->rel2abs($_) for @ARGV; - -my $libdll = shift; -my $inpdll = shift; - -open my $nm_fd, '-|', $nm, '-Apg', '--defined-only', $inpdll; -my %text = (); -my %import = (); -my %symfile = (); -while (<$nm_fd>) { - chomp; - my ($fn, $type, $sym) = /^$inpdll:(.*?):\S+\s+(\S)\s+(\S+)$/o; - next unless $fn; - $text{$fn} = $sym if $type eq 'T'; - $import{$fn} = $sym if $type eq 'I'; - $symfile{$sym} = $fn; -} -close $nm_fd or exit 1; - -for my $sym (keys %replace) { - my $fn; - my $_sym = '_' . $sym; - if (!defined($fn = $symfile{$_sym})) { - $fn = "$sym.o"; - $text{$fn} = $_sym; - } - my $imp_sym = '__imp__' . $replace{$sym}; - $import{$fn} = $imp_sym; -} - -for my $f (keys %text) { - my $imp_sym = delete $import{$f}; - my $glob_sym = $text{$f}; - if (!defined $imp_sym) { - delete $text{$f}; - } elsif ($imp_sym eq '__imp__') { - $text{$f} = 0; - } else { - $text{$f} = 1; - open my $as_fd, '|-', $as, '-o', "$dir/t-$f", "-"; - print $as_fd <\@exclude, 'library=s'=>\@library, 'ar=s'=>\$ar, 'x!'=>\$x); - -die "$0: must specify --ar\n" unless defined $ar; -my $lib = shift or die "$0: missing lib argument\nusage: $0 lib [map-file]\n"; -$lib = Cwd::abs_path($lib); - -my %excludes = map {($_, 1)} @exclude; -my $libraries = join('|', map {quotemeta} @library); - -my %sources = (); -while (<>) { - my ($source, $file, $absfile); - if (m%^($libraries)\(([^)]*)\)%o) { - $source = $1; - $absfile = $file = $2; - } elsif (/^LOAD\s+(.*\.o)$/o) { - $source = '.'; - $file = $1; - $absfile = Cwd::abs_path($file); - } else { - next; - } - push @{$sources{$source}}, $absfile unless $excludes{$file} || $excludes{$source}; -} - -my $here = getcwd(); -my $dir = tempdir(CLEANUP=>1); -chdir $dir; -my @files = (); -for (sort keys %sources) { - if ($_ eq '.') { - xsystem '/bin/cp', '-a', @{$sources{$_}}, '.'; - } else { - xsystem $ar, 'x', $_, @{$sources{$_}}, '.'; - } - push @files, map {basename($_)} @{$sources{$_}}; -} - -unlink $lib; -xsystem $ar, 'crs', $lib, sort @files; -exit 0; - -sub xsystem(@) { - print join(' ', 'x', @_), "\n" if $x; - system(@_) == 0 or die "$0: @_[0] $_[1] $_[2]... exited with non-zero status\n"; -} diff --git a/winsup/cygwin/mktemp.cc b/winsup/cygwin/mktemp.cc deleted file mode 100644 index b8a1381c4..000000000 --- a/winsup/cygwin/mktemp.cc +++ /dev/null @@ -1,183 +0,0 @@ -/* mktemp.cc: mktemp functions - -This file is adapted for Cygwin from FreeBSD and newlib. - -See the copyright at the bottom of this file. */ - -#include "winsup.h" -#include "cygerrno.h" -#include -#include -#include - -static int _gettemp(char *, int *, int, size_t); -static uint32_t arc4random (); - -static const char padchar[] = -"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - -extern "C" int -mkstemp(char *path) -{ - int fd; - return _gettemp(path, &fd, 0, 0) ? fd : -1; -} - -extern "C" char * -mkdtemp(char *path) -{ - return _gettemp(path, NULL, 1, 0) ? path : NULL; -} - -extern "C" int -mkstemps(char *path, int len) -{ - int fd; - return _gettemp(path, &fd, 0, len) ? fd : -1; -} - -extern "C" char * -mktemp(char *path) -{ - return _gettemp(path, NULL, 0, 0) ? path : (char *) NULL; -} - -static int -_gettemp(char *path, int *doopen, int domkdir, size_t suffixlen) -{ - char *start, *trv, *suffp; - char *pad; - - if (doopen && domkdir) - { - set_errno (EINVAL); - return 0; - } - - trv = strchr (path, '\0'); - if ((size_t) (trv - path) < suffixlen) - { - set_errno (EINVAL); - return 0; - } - trv -= suffixlen; - suffp = trv--; - - /* Fill space with random characters */ - while (trv >= path && *trv == 'X') - { - uint32_t rand = arc4random () % (sizeof (padchar) - 1); - *trv-- = padchar[rand]; - } - if (suffp - trv < 6) - { - set_errno (EINVAL); - return 0; - } - start = trv + 1; - - /* - * check the target directory. - */ - struct __stat64 sbuf; - if (doopen != NULL || domkdir) - { - for (; trv > path; trv--) - { - if (*trv == '/') - { - *trv = '\0'; - int rval = stat64 (path, &sbuf); - *trv = '/'; - if (rval != 0) - return 0; - if (!S_ISDIR (sbuf.st_mode)) - { - set_errno (ENOTDIR); - return 0; - } - break; - } - } - } - - for (;;) - { - if (doopen) - { - if ((*doopen = open (path, O_CREAT | O_EXCL | O_RDWR | O_BINARY, - S_IRUSR | S_IWUSR)) >= 0) - return 1; - if (errno != EEXIST) - return 0; - } - else if (domkdir) - { - if (mkdir (path, 0700) == 0) - return 1; - if (errno != EEXIST) - return 0; - } - else if (lstat64 (path, &sbuf)) - return errno == ENOENT; - - /* If we have a collision, cycle through the space of filenames */ - for (trv = start;;) - { - if (*trv == '\0' || trv == suffp) - return 0; - pad = strchr (padchar, *trv); - if (pad == NULL || *++pad == '\0') - *trv++ = padchar[0]; - else - { - *trv++ = *pad; - break; - } - } - } - /*NOTREACHED*/ -} - -static uint32_t -arc4random () -{ - union - { - uint32_t rand; - char buf[sizeof (int) / 8]; - } r; - int fd = open ("/dev/urandom", O_RDONLY); - read (fd, r.buf, 4); - close (fd); - return r.rand; -} - -/* -* Copyright (c) 1987, 1993 -* The Regents of the University of California. All rights reserved. -* -* 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. -* 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. -*/ diff --git a/winsup/cygwin/mkvers.sh b/winsup/cygwin/mkvers.sh deleted file mode 100755 index 665f35868..000000000 --- a/winsup/cygwin/mkvers.sh +++ /dev/null @@ -1,177 +0,0 @@ -#!/bin/sh -# mkvers.sh - Make version information for cygwin DLL -# -# Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc. -# -# This file is part of Cygwin. -# -# This software is a copyrighted work licensed under the terms of the -# Cygwin license. Please consult the file "CYGWIN_LICENSE" for -# details. - -exec 9> version.cc - -# -# Arg 1 is the name of the version include file -# -incfile="$1" -rcfile="$2" -windres="$3" - -[ -r $incfile ] || { - echo "**** Couldn't open file '$incfile'. Aborting." -} - -# -# Load the current date so we can work on individual fields -# -build_date=`date` -set -$- $build_date -# -# Translate the month into a number -# -case "$2" in - Jan) m=01 ;; - Feb) m=02 ;; - Mar) m=03 ;; - Apr) m=04 ;; - May) m=05 ;; - Jun) m=06 ;; - Jul) m=07 ;; - Aug) m=08 ;; - Sep) m=09 ;; - Oct) m=10 ;; - Nov) m=11 ;; - Dec) m=12 ;; -esac - -if [ "$3" -lt 10 ]; then - d=0$3 -else - d=$3 -fi -hhmm="`echo $4 | sed 's/:..$//'`" -# -# Set date into YYYY-MM-DD HH:MM:SS format -# -builddate="${6-$5}-$m-$d $hhmm" - -set -$- '' - -# -# Output the initial part of version.cc -# -cat <&9 -#include "config.h" -#include "cygwin_version.h" - -#define strval(x) #x -#define str(x) strval(x) -#define shared_data_version str(CYGWIN_VERSION_SHARED_DATA) - -const char *cygwin_version_strings = - "BEGIN_CYGWIN_VERSION_INFO\n" -EOF - -# -# Split version file into dir and filename components -# -dir=`dirname $incfile` -fn=`basename $incfile` - -# -# Look in the include file CVS directory for a CVS Tag file. This file, -# if it exists, will contain the name of the sticky tag associated with -# the current build. Save that for output later. -# -cvs_tag="`sed -e '/dontuse/d' -e 's%^.\(.*\)%\1%' $dir/CVS/Tag 2>/dev/null`" - -wv_cvs_tag="$cvs_tag" -[ -n "$cvs_tag" ] && cvs_tag=" CVS tag"' -'"$cvs_tag" - -# -# Look in the source directory containing the include/cygwin/version.h -# and set dir accordingly. -dir=`echo $dir | sed -e 's%/include/cygwin.*$%%' -e 's%include/cygwin.*$%.%'` - -# Look in $dir for a a ".snapshot-date" file. If one is found then this -# information will be saved for output to the DLL. -# -if [ -r "$dir/.snapshot-date" ]; then - read snapshotdate < "$dir/.snapshot-date" - snapshot="snapshot date -$snapshotdate" -fi - -# -# Scan the version.h file for strings that begin with CYGWIN_INFO or -# CYGWIN_VERSION. Perform crude parsing on the lines to get the values -# associated with these values and then pipe it into a while loop which -# outputs these values in C palatable format for inclusion in the DLL -# with a '%% ' identifier that will introduce "interesting" strings. -# These strings are strictly for use by a user to scan the DLL for -# interesting information. -# -(sed -n -e 's%#define CYGWIN_INFO_\([A-Z_]*\)[ ][ ]*\([a-zA-Z0-9"][^/]*\).*%_\1\ -\2%p' -e 's%#define CYGWIN_VERSION_\([A-Z_]*\)[ ][ ]*\([a-zA-Z0-9"][^/]*\).*%_\1\ -\2%p' $incfile | sed -e 's/["\\]//g' -e '/^_/y/ABCDEFGHIJKLMNOPQRSTUVWXYZ_/abcdefghijklmnopqrstuvwxyz /'; -echo ' build date'; echo $build_date; [ -n "$cvs_tag" ] && echo "$cvs_tag";\ -[ -n "$snapshot" ] && echo "$snapshot" -) | while read var; do - read val -cat <&9 - -trap "rm -f /tmp/mkvers.$$" 0 1 2 15 - -if [ -n "$snapshotdate" ]; then - usedate="`echo $snapshotdate | sed 's/-\\(..:..[^-]*\\).*$/ \1SNP/'`" -else - usedate="$builddate" -fi - -# -# Finally, output the shared ID and set up the cygwin_version structure -# for use by Cygwin itself. -# -cat <&9 -#ifdef DEBUGGING - "%%% Cygwin shared id: " CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "-$builddate\n" -#else - "%%% Cygwin shared id: " CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "\n" -#endif - "END_CYGWIN_VERSION_INFO\n\0"; -cygwin_version_info cygwin_version = -{ - CYGWIN_VERSION_API_MAJOR, CYGWIN_VERSION_API_MINOR, - CYGWIN_VERSION_DLL_MAJOR, CYGWIN_VERSION_DLL_MINOR, - CYGWIN_VERSION_SHARED_DATA, - CYGWIN_VERSION_MOUNT_REGISTRY, - "$usedate", -#ifdef DEBUGGING - CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "-$builddate" -#else - CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version -#endif -}; -EOF - -# -# Generate winver.o using cygwin/version.h information. -# Turn the cygwin major number from some large number to something like 1.1.0. -# -eval `sed -n 's/^.*dll \(m[ai][jn]or\): \([0-9]*\)[^0-9]*$/\1=\2/p' /tmp/mkvers.$$` -cygverhigh=`expr $major / 1000` -cygverlow=`expr $major % 1000` -cygwin_ver="$cygverhigh.$cygverlow.$minor" -if [ -n "$cvs_tag" ]; then - cvs_tag="`echo $wv_cvs_tag | sed -e 's/-branch.*//'`" - cygwin_ver="$cygwin_ver-$cvs_tag" -fi - -echo "Version $cygwin_ver" -set -$- $builddate -$windres --include-dir $dir/../w32api/include --include-dir $dir/include --define CYGWIN_BUILD_DATE="$1" --define CYGWIN_BUILD_TIME="$2" --define CYGWIN_VERSION='"'"$cygwin_ver"'"' $rcfile winver.o diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc deleted file mode 100644 index 710df06e8..000000000 --- a/winsup/cygwin/mmap.cc +++ /dev/null @@ -1,1835 +0,0 @@ -/* mmap.cc - - Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "miscfuncs.h" -#include -#include -#include -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "ntdll.h" -#include - -/* __PROT_ATTACH indicates an anonymous mapping which is supposed to be - attached to a file mapping for pages beyond the file's EOF. The idea - is to support mappings longer than the file, without the file growing - to mapping length (POSIX semantics). */ -#define __PROT_ATTACH 0x8000000 -/* Filler pages are the pages from the last file backed page to the next - 64K boundary. These pages are created as anonymous pages, but with - the same page protection as the file's pages, since POSIX applications - expect to be able to access this part the same way as the file pages. */ -#define __PROT_FILLER 0x4000000 - -/* Stick with 4K pages for bookkeeping, otherwise we just get confused - when trying to do file mappings with trailing filler pages correctly. */ -#define PAGE_CNT(bytes) howmany((bytes),getsystempagesize()) - -#define PGBITS (sizeof (DWORD)*8) -#define MAPSIZE(pages) howmany ((pages), PGBITS) - -#define MAP_SET(n) (page_map[(n)/PGBITS] |= (1L << ((n) % PGBITS))) -#define MAP_CLR(n) (page_map[(n)/PGBITS] &= ~(1L << ((n) % PGBITS))) -#define MAP_ISSET(n) (page_map[(n)/PGBITS] & (1L << ((n) % PGBITS))) - -/* Used for anonymous mappings. */ -static fhandler_dev_zero fh_anonymous; - -/* Used for thread synchronization while accessing mmap bookkeeping lists. */ -static NO_COPY muto mmap_guard; -#define LIST_LOCK() (mmap_guard.init ("mmap_guard")->acquire ()) -#define LIST_UNLOCK() (mmap_guard.release ()) - -/* Small helpers to avoid having lots of flag bit tests in the code. */ -static inline bool -priv (int flags) -{ - return (flags & MAP_PRIVATE) == MAP_PRIVATE; -} - -static inline bool -fixed (int flags) -{ - return (flags & MAP_FIXED) == MAP_FIXED; -} - -static inline bool -anonymous (int flags) -{ - return (flags & MAP_ANONYMOUS) == MAP_ANONYMOUS; -} - -static inline bool -noreserve (int flags) -{ - return (flags & MAP_NORESERVE) == MAP_NORESERVE; -} - -static inline bool -autogrow (int flags) -{ - return (flags & MAP_AUTOGROW) == MAP_AUTOGROW; -} - -static inline bool -attached (int prot) -{ - return (prot & __PROT_ATTACH) == __PROT_ATTACH; -} - -static inline bool -filler (int prot) -{ - return (prot & __PROT_FILLER) == __PROT_FILLER; -} - -static inline DWORD -gen_create_protect (DWORD openflags, int flags) -{ - DWORD ret = PAGE_READONLY; - - if (priv (flags)) - ret = PAGE_WRITECOPY; - else if (openflags & GENERIC_WRITE) - ret = PAGE_READWRITE; - - if (openflags & GENERIC_EXECUTE) - ret <<= 4; - - return ret; -} - -/* Generate Windows protection flags from mmap prot and flag values. */ -static inline DWORD -gen_protect (int prot, int flags) -{ - DWORD ret = PAGE_NOACCESS; - - /* Attached pages are only reserved, but the protection must be a - valid value, so we just return PAGE_READWRITE. */ - if (attached (prot)) - return PAGE_EXECUTE_READWRITE; - - if (prot & PROT_WRITE) - ret = (priv (flags) && (!anonymous (flags) || filler (prot))) - ? PAGE_WRITECOPY : PAGE_READWRITE; - else if (prot & PROT_READ) - ret = PAGE_READONLY; - - if (prot & PROT_EXEC) - ret <<= 4; - - return ret; -} - -static HANDLE -CreateMapping (HANDLE fhdl, size_t len, _off64_t off, DWORD openflags, - int prot, int flags) -{ - HANDLE h; - NTSTATUS ret; - - LARGE_INTEGER sectionsize = { QuadPart: len }; - ULONG protect = gen_create_protect (openflags, flags); - ULONG attributes = attached (prot) ? SEC_RESERVE : SEC_COMMIT; - - OBJECT_ATTRIBUTES oa; - InitializeObjectAttributes (&oa, NULL, OBJ_INHERIT, NULL, - sec_none.lpSecurityDescriptor); - - if (fhdl == INVALID_HANDLE_VALUE) - { - /* Standard anonymous mapping needs non-zero len. */ - ret = NtCreateSection (&h, SECTION_ALL_ACCESS, &oa, - §ionsize, protect, attributes, NULL); - } - else if (autogrow (flags)) - { - /* Auto-grow only works if the protection is PAGE_READWRITE. So, - first we call NtCreateSection with PAGE_READWRITE, then, if the - requested protection is different, we close the mapping and - reopen it again with the correct protection, if auto-grow worked. */ - sectionsize.QuadPart += off; - ret = NtCreateSection (&h, SECTION_ALL_ACCESS, &oa, - §ionsize, PAGE_READWRITE, attributes, fhdl); - if (NT_SUCCESS (ret) && protect != PAGE_READWRITE) - { - NtClose (h); - ret = NtCreateSection (&h, SECTION_ALL_ACCESS, &oa, - §ionsize, protect, attributes, fhdl); - } - } - else - { - /* Zero len creates mapping for whole file and allows - AT_EXTENDABLE_FILE mapping, if we ever use it... */ - sectionsize.QuadPart = 0; - ret = NtCreateSection (&h, SECTION_ALL_ACCESS, &oa, - §ionsize, protect, attributes, fhdl); - } - if (!NT_SUCCESS (ret)) - { - h = NULL; - SetLastError (RtlNtStatusToDosError (ret)); - } - return h; -} - -static void * -MapView (HANDLE h, void *addr, size_t len, DWORD openflags, - int prot, int flags, _off64_t off) -{ - NTSTATUS ret; - LARGE_INTEGER offset = { QuadPart:off }; - DWORD protect = gen_create_protect (openflags, flags); - void *base = addr; - ULONG commitsize = attached (prot) ? 0 : len; - ULONG viewsize = len; - ULONG alloc_type = (base && !wincap.is_wow64 () ? AT_ROUND_TO_PAGE : 0) - | MEM_TOP_DOWN; - - /* Try mapping using the given address first, even if it's NULL. - If it failed, and addr was not NULL and flags is not MAP_FIXED, - try again with NULL address. - - Note: Retrying the mapping might be unnecessary, now that mmap64 checks - for a valid memory area first. */ - ret = NtMapViewOfSection (h, NtCurrentProcess (), &base, 0, commitsize, - &offset, &viewsize, ViewShare, alloc_type, protect); - if (!NT_SUCCESS (ret) && addr && !fixed (flags)) - { - base = NULL; - ret = NtMapViewOfSection (h, NtCurrentProcess (), &base, 0, commitsize, - &offset, &viewsize, ViewShare, 0, protect); - } - if (!NT_SUCCESS (ret)) - { - base = NULL; - SetLastError (RtlNtStatusToDosError (ret)); - } - debug_printf ("%p (status %p) = NtMapViewOfSection (h:%x, addr:%x, len:%u," - " off:%X, protect:%x, type:%x)", - base, ret, h, addr, len, off, protect, 0); - return base; -} - -/* Class structure used to keep a record of all current mmap areas - in a process. Needed for bookkeeping all mmaps in a process and - for duplicating all mmaps after fork() since mmaps are not propagated - to child processes by Windows. All information must be duplicated - by hand, see fixup_mmaps_after_fork(). - - The class structure: - - One member of class map per process, global variable mmapped_areas. - Contains a singly-linked list of type class mmap_list. Each mmap_list - entry represents all mapping to a file, keyed by file descriptor and - file name hash. - Each list entry contains a singly-linked list of type class mmap_record. - Each mmap_record represents exactly one mapping. For each mapping, there's - an additional so called `page_map'. It's an array of bits, one bit - per mapped memory page. The bit is set if the page is accessible, - unset otherwise. */ - -class mmap_record -{ - public: - LIST_ENTRY (mmap_record) mr_next; - - private: - int fd; - HANDLE mapping_hdl; - DWORD openflags; - int prot; - int flags; - _off64_t offset; - DWORD len; - caddr_t base_address; - DWORD *page_map; - device dev; - - public: - mmap_record (int nfd, HANDLE h, DWORD of, int p, int f, _off64_t o, DWORD l, - caddr_t b) : - fd (nfd), - mapping_hdl (h), - openflags (of), - prot (p), - flags (f), - offset (o), - len (l), - base_address (b), - page_map (NULL) - { - dev.devn = 0; - if (fd >= 0 && !cygheap->fdtab.not_open (fd)) - dev = cygheap->fdtab[fd]->dev (); - else if (fd == -1) - dev.parse (FH_ZERO); - } - - int get_fd () const { return fd; } - HANDLE get_handle () const { return mapping_hdl; } - device& get_device () { return dev; } - int get_prot () const { return prot; } - int get_openflags () const { return openflags; } - int get_flags () const { return flags; } - bool priv () const { return ::priv (flags); } - bool fixed () const { return ::fixed (flags); } - bool anonymous () const { return ::anonymous (flags); } - bool noreserve () const { return ::noreserve (flags); } - bool autogrow () const { return ::autogrow (flags); } - bool attached () const { return ::attached (prot); } - bool filler () const { return ::filler (prot); } - _off64_t get_offset () const { return offset; } - DWORD get_len () const { return len; } - caddr_t get_address () const { return base_address; } - - bool alloc_page_map (); - void free_page_map () { if (page_map) cfree (page_map); } - - DWORD find_unused_pages (DWORD pages) const; - bool match (caddr_t addr, DWORD len, caddr_t &m_addr, DWORD &m_len); - _off64_t map_pages (_off64_t off, DWORD len); - bool map_pages (caddr_t addr, DWORD len); - bool unmap_pages (caddr_t addr, DWORD len); - int access (caddr_t address); - - fhandler_base *alloc_fh (); - void free_fh (fhandler_base *fh); - - DWORD gen_create_protect () const - { return ::gen_create_protect (get_openflags (), get_flags ()); } - DWORD gen_protect () const - { return ::gen_protect (get_prot (), get_flags ()); } - bool compatible_flags (int fl) const; -}; - -class mmap_list -{ - public: - LIST_ENTRY (mmap_list) ml_next; - LIST_HEAD (, mmap_record) recs; - - private: - int fd; - __ino64_t hash; - - public: - int get_fd () const { return fd; } - __ino64_t get_hash () const { return hash; } - - bool anonymous () const { return fd == -1; } - void set (int nfd, struct __stat64 *st); - mmap_record *add_record (mmap_record r); - bool del_record (mmap_record *rec); - caddr_t try_map (void *addr, size_t len, int flags, _off64_t off); -}; - -class mmap_areas -{ - public: - LIST_HEAD (, mmap_list) lists; - - mmap_list *get_list_by_fd (int fd, struct __stat64 *st); - mmap_list *add_list (int fd, struct __stat64 *st); - void del_list (mmap_list *ml); -}; - -/* This is the global map structure pointer. */ -static mmap_areas mmapped_areas; - -bool -mmap_record::compatible_flags (int fl) const -{ -#define MAP_COMPATMASK (MAP_TYPE | MAP_NORESERVE) - return (get_flags () & MAP_COMPATMASK) == (fl & MAP_COMPATMASK); -} - -DWORD -mmap_record::find_unused_pages (DWORD pages) const -{ - DWORD mapped_pages = PAGE_CNT (get_len ()); - DWORD start; - - if (pages > mapped_pages) - return (DWORD)-1; - for (start = 0; start <= mapped_pages - pages; ++start) - if (!MAP_ISSET (start)) - { - DWORD cnt; - for (cnt = 0; cnt < pages; ++cnt) - if (MAP_ISSET (start + cnt)) - break; - if (cnt >= pages) - return start; - } - return (DWORD)-1; -} - -bool -mmap_record::match (caddr_t addr, DWORD len, caddr_t &m_addr, DWORD &m_len) -{ - caddr_t low = (addr >= get_address ()) ? addr : get_address (); - caddr_t high = get_address (); - if (filler ()) - high += get_len (); - else - high += (PAGE_CNT (get_len ()) * getsystempagesize ()); - high = (addr + len < high) ? addr + len : high; - if (low < high) - { - m_addr = low; - m_len = high - low; - return true; - } - return false; -} - -bool -mmap_record::alloc_page_map () -{ - /* Allocate one bit per page */ - if (!(page_map = (DWORD *) ccalloc (HEAP_MMAP, - MAPSIZE (PAGE_CNT (get_len ())), - sizeof (DWORD)))) - return false; - - DWORD start_protect = gen_create_protect (); - DWORD real_protect = gen_protect (); - if (real_protect != start_protect && !noreserve () - && !VirtualProtect (get_address (), get_len (), - real_protect, &start_protect)) - system_printf ("Warning: VirtualProtect (addr: %p, len: 0x%x, " - "new_prot: 0x%x, old_prot: 0x%x), %E", - get_address (), get_len (), - real_protect, start_protect); - DWORD len = PAGE_CNT (get_len ()); - while (len-- > 0) - MAP_SET (len); - return true; -} - -_off64_t -mmap_record::map_pages (_off64_t off, DWORD len) -{ - /* Used ONLY if this mapping matches into the chunk of another already - performed mapping in a special case of MAP_ANON|MAP_PRIVATE. - - Otherwise it's job is now done by alloc_page_map(). */ - DWORD old_prot; - debug_printf ("map_pages (fd=%d, off=%D, len=%u)", get_fd (), off, len); - len = PAGE_CNT (len); - - if ((off = find_unused_pages (len)) == (DWORD)-1) - return 0L; - if (!noreserve () - && !VirtualProtect (get_address () + off * getsystempagesize (), - len * getsystempagesize (), gen_protect (), - &old_prot)) - { - __seterrno (); - return (_off64_t)-1; - } - - while (len-- > 0) - MAP_SET (off + len); - return off * getsystempagesize (); -} - -bool -mmap_record::map_pages (caddr_t addr, DWORD len) -{ - debug_printf ("map_pages (addr=%x, len=%u)", addr, len); - DWORD old_prot; - DWORD off = addr - get_address (); - off /= getsystempagesize (); - len = PAGE_CNT (len); - /* First check if the area is unused right now. */ - for (DWORD l = 0; l < len; ++l) - if (MAP_ISSET (off + l)) - { - set_errno (EINVAL); - return false; - } - if (!noreserve () - && !VirtualProtect (get_address () + off * getsystempagesize (), - len * getsystempagesize (), gen_protect (), - &old_prot)) - { - __seterrno (); - return false; - } - for (; len-- > 0; ++off) - MAP_SET (off); - return true; -} - -bool -mmap_record::unmap_pages (caddr_t addr, DWORD len) -{ - DWORD old_prot; - DWORD off = addr - get_address (); - if (noreserve () - && !VirtualFree (get_address () + off, len, MEM_DECOMMIT)) - debug_printf ("VirtualFree in unmap_pages () failed, %E"); - else if (!VirtualProtect (get_address () + off, len, PAGE_NOACCESS, - &old_prot)) - debug_printf ("VirtualProtect in unmap_pages () failed, %E"); - - off /= getsystempagesize (); - len = PAGE_CNT (len); - for (; len-- > 0; ++off) - MAP_CLR (off); - /* Return TRUE if all pages are free'd which may result in unmapping - the whole chunk. */ - for (len = MAPSIZE (PAGE_CNT (get_len ())); len > 0; ) - if (page_map[--len]) - return false; - return true; -} - -int -mmap_record::access (caddr_t address) -{ - if (address < get_address () || address >= get_address () + get_len ()) - return 0; - DWORD off = (address - get_address ()) / getsystempagesize (); - return MAP_ISSET (off); -} - -fhandler_base * -mmap_record::alloc_fh () -{ - if (anonymous ()) - { - fh_anonymous.set_io_handle (INVALID_HANDLE_VALUE); - fh_anonymous.set_access (GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE); - return &fh_anonymous; - } - - /* The file descriptor could have been closed or, even - worse, could have been reused for another file before - the call to fork(). This requires creating a fhandler - of the correct type to be sure to call the method of the - correct class. */ - fhandler_base *fh = build_fh_dev (get_device ()); - fh->set_access (get_openflags ()); - return fh; -} - -void -mmap_record::free_fh (fhandler_base *fh) -{ - if (!anonymous ()) - delete fh; -} - -mmap_record * -mmap_list::add_record (mmap_record r) -{ - mmap_record *rec = (mmap_record *) cmalloc (HEAP_MMAP, sizeof (mmap_record)); - if (!rec) - return NULL; - *rec = r; - if (!rec->alloc_page_map ()) - { - cfree (rec); - return NULL; - } - LIST_INSERT_HEAD (&recs, rec, mr_next); - return rec; -} - -void -mmap_list::set (int nfd, struct __stat64 *st) -{ - fd = nfd; - if (!anonymous ()) - { - /* The fd isn't sufficient since it could already be the fd of another - file. So we use the inode number as evaluated by fstat to identify - the file. */ - hash = st ? st->st_ino : (__ino64_t) 0; - } - LIST_INIT (&recs); -} - -bool -mmap_list::del_record (mmap_record *rec) -{ - rec->free_page_map (); - LIST_REMOVE (rec, mr_next); - cfree (rec); - /* Return true if the list is empty which allows the caller to remove - this list from the list of lists. */ - return !LIST_FIRST(&recs); -} - -caddr_t -mmap_list::try_map (void *addr, size_t len, int flags, _off64_t off) -{ - mmap_record *rec; - - if (off == 0 && !fixed (flags)) - { - /* If MAP_FIXED isn't given, check if this mapping matches into the - chunk of another already performed mapping. */ - DWORD plen = PAGE_CNT (len); - LIST_FOREACH (rec, &recs, mr_next) - if (rec->find_unused_pages (plen) != (DWORD) -1) - break; - if (rec && rec->compatible_flags (flags)) - { - if ((off = rec->map_pages (off, len)) == (_off64_t) -1) - return (caddr_t) MAP_FAILED; - return (caddr_t) rec->get_address () + off; - } - } - else if (fixed (flags)) - { - /* If MAP_FIXED is given, test if the requested area is in an - unmapped part of an still active mapping. This can happen - if a memory region is unmapped and remapped with MAP_FIXED. */ - caddr_t u_addr; - DWORD u_len; - - LIST_FOREACH (rec, &recs, mr_next) - if (rec->match ((caddr_t) addr, len, u_addr, u_len)) - break; - if (rec) - { - if (u_addr > (caddr_t) addr || u_addr + len < (caddr_t) addr + len - || !rec->compatible_flags (flags)) - { - /* Partial match only, or access mode doesn't match. */ - /* FIXME: Handle partial mappings gracefully if adjacent - memory is available. */ - set_errno (EINVAL); - return (caddr_t) MAP_FAILED; - } - if (!rec->map_pages ((caddr_t) addr, len)) - return (caddr_t) MAP_FAILED; - return (caddr_t) addr; - } - } - return NULL; -} - -mmap_list * -mmap_areas::get_list_by_fd (int fd, struct __stat64 *st) -{ - mmap_list *ml; - LIST_FOREACH (ml, &lists, ml_next) - { - if (fd == -1 && ml->anonymous ()) - return ml; - /* The fd isn't sufficient since it could already be the fd of another - file. So we use the inode number as evaluated by fstat to identify - the file. */ - if (fd != -1 && st && ml->get_hash () == st->st_ino) - return ml; - } - return 0; -} - -mmap_list * -mmap_areas::add_list (int fd, struct __stat64 *st) -{ - mmap_list *ml = (mmap_list *) cmalloc (HEAP_MMAP, sizeof (mmap_list)); - if (!ml) - return NULL; - ml->set (fd, st); - LIST_INSERT_HEAD (&lists, ml, ml_next); - return ml; -} - -void -mmap_areas::del_list (mmap_list *ml) -{ - LIST_REMOVE (ml, ml_next); - cfree (ml); -} - -/* This function is called from exception_handler when a segmentation - violation has occurred. It should also be called from all Cygwin - functions that want to support passing noreserve mmap page addresses - to Windows system calls. In that case, it should be called only after - a system call indicates that the application buffer passed had an - invalid virtual address to avoid any performance impact in non-noreserve - cases. - - Check if the address range is all within noreserve mmap regions. If so, - call VirtualAlloc to commit the pages and return MMAP_NORESERVE_COMMITED - on success. If the page has __PROT_ATTACH (SUSv3 memory protection - extension), or if VirutalAlloc fails, return MMAP_RAISE_SIGBUS. - Otherwise, return MMAP_NONE if the address range is not covered by an - attached or noreserve map. - - On MAP_NORESERVE_COMMITED, the exeception handler should return 0 to - allow the application to retry the memory access, or the calling Cygwin - function should retry the Windows system call. */ -mmap_region_status -mmap_is_attached_or_noreserve (void *addr, size_t len) -{ - mmap_region_status ret = MMAP_NONE; - - LIST_LOCK (); - mmap_list *map_list = mmapped_areas.get_list_by_fd (-1, NULL); - - size_t pagesize = getpagesize (); - caddr_t start_addr = (caddr_t) rounddown ((uintptr_t) addr, pagesize); - len += ((caddr_t) addr - start_addr); - len = roundup2 (len, pagesize); - - if (map_list == NULL) - goto out; - - mmap_record *rec; - caddr_t u_addr; - DWORD u_len; - - LIST_FOREACH (rec, &map_list->recs, mr_next) - { - if (!rec->match (start_addr, len, u_addr, u_len)) - continue; - if (rec->attached ()) - { - ret = MMAP_RAISE_SIGBUS; - break; - } - if (!rec->noreserve ()) - break; - - size_t commit_len = u_len - (start_addr - u_addr); - if (commit_len > len) - commit_len = len; - - if (!VirtualAlloc (start_addr, commit_len, MEM_COMMIT, - rec->gen_protect ())) - { - ret = MMAP_RAISE_SIGBUS; - break; - } - - start_addr += commit_len; - len -= commit_len; - if (!len) - { - ret = MMAP_NORESERVE_COMMITED; - break; - } - } -out: - LIST_UNLOCK (); - return ret; -} - -static caddr_t -mmap_worker (mmap_list *map_list, fhandler_base *fh, caddr_t base, size_t len, - int prot, int flags, int fd, _off64_t off, struct __stat64 *st) -{ - HANDLE h = fh->mmap (&base, len, prot, flags, off); - if (h == INVALID_HANDLE_VALUE) - return NULL; - if (!map_list - && !(map_list = mmapped_areas.get_list_by_fd (fd, st)) - && !(map_list = mmapped_areas.add_list (fd, st))) - { - fh->munmap (h, base, len); - return NULL; - } - mmap_record mmap_rec (fd, h, fh->get_access (), prot, flags, off, len, base); - mmap_record *rec = map_list->add_record (mmap_rec); - if (!rec) - { - fh->munmap (h, base, len); - return NULL; - } - return base; -} - -extern "C" void * -mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off) -{ - syscall_printf ("addr %x, len %u, prot %x, flags %x, fd %d, off %D", - addr, len, prot, flags, fd, off); - - caddr_t ret = (caddr_t) MAP_FAILED; - fhandler_base *fh = NULL; - fhandler_disk_file *fh_disk_file = NULL; /* Used for reopening a disk file - when necessary. */ - mmap_list *map_list = NULL; - size_t orig_len = 0; - caddr_t base = NULL; - struct __stat64 st; - - DWORD pagesize = getpagesize (); - - fh_anonymous.set_io_handle (INVALID_HANDLE_VALUE); - fh_anonymous.set_access (GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE); - - /* EINVAL error conditions. */ - if (off % pagesize - || ((prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC))) - || ((flags & MAP_TYPE) != MAP_SHARED - && (flags & MAP_TYPE) != MAP_PRIVATE) - || (fixed (flags) && ((uintptr_t) addr % pagesize)) - || !len) - { - set_errno (EINVAL); - goto out; - } - - if (!anonymous (flags) && fd != -1) - { - /* Ensure that fd is open */ - cygheap_fdget cfd (fd); - if (cfd < 0) - goto out; - - fh = cfd; - - /* mmap /dev/zero is like MAP_ANONYMOUS. */ - if (fh->get_device () == FH_ZERO) - flags |= MAP_ANONYMOUS; - } - - if (anonymous (flags) || fd == -1) - { - fh = &fh_anonymous; - fd = -1; - flags |= MAP_ANONYMOUS; - /* Anonymous mappings are always forced to pagesize length with - no offset. */ - len = roundup2 (len, pagesize); - off = 0; - } - else if (fh->get_device () == FH_FS) - { - /* EACCES error conditions according to SUSv3. File must be opened - for reading, regardless of the requested protection, and file must - be opened for writing when PROT_WRITE together with MAP_SHARED - is requested. */ - if (!(fh->get_access () & GENERIC_READ) - || (!(fh->get_access () & GENERIC_WRITE) - && (prot & PROT_WRITE) && !priv (flags))) - { - set_errno (EACCES); - goto out; - } - - /* You can't create mappings with PAGE_EXECUTE protection if - the file isn't explicitely opened with EXECUTE access. */ - OBJECT_ATTRIBUTES attr; - NTSTATUS status; - HANDLE h; - IO_STATUS_BLOCK io; - - InitializeObjectAttributes (&attr, &ro_u_empty, fh->pc.objcaseinsensitive (), - fh->get_handle (), NULL); - status = NtOpenFile (&h, - fh->get_access () | GENERIC_EXECUTE | SYNCHRONIZE, - &attr, &io, FILE_SHARE_VALID_FLAGS, - FILE_SYNCHRONOUS_IO_NONALERT - | FILE_OPEN_FOR_BACKUP_INTENT); - if (NT_SUCCESS (status)) - { - fh_disk_file = new (ccalloc (HEAP_FHANDLER, 1, sizeof *fh_disk_file)) - fhandler_disk_file; - fh_disk_file->set_name (fh->pc); - fh_disk_file->set_io_handle (h); - fh_disk_file->set_access (fh->get_access () | GENERIC_EXECUTE); - fh = fh_disk_file; - } - else if (prot & PROT_EXEC) - { - /* TODO: To be or not to be... I'm opting for refusing this - mmap request rather than faking it, but that might break - some non-portable code. */ - set_errno (EACCES); - goto out; - } - - if (fh->fstat_by_handle (&st)) - { - __seterrno (); - goto out; - } - _off64_t fsiz = st.st_size; - - /* Don't allow file mappings beginning beyond EOF since Windows can't - handle that POSIX like, unless MAP_AUTOGROW flag is set, which - mimics Windows behaviour. */ - if (off >= fsiz && !autogrow (flags)) - { - /* Instead, it seems suitable to return an anonymous mapping of - the given size instead. Mapped addresses beyond EOF aren't - written back to the file anyway, so the handling is identical - to other pages beyond EOF. */ - fh = &fh_anonymous; - len = roundup2 (len, pagesize); - prot = PROT_READ | PROT_WRITE | __PROT_ATTACH; - flags &= MAP_FIXED; - flags |= MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE; - fd = -1; - off = 0; - goto go_ahead; - } - fsiz -= off; - /* We're creating the pages beyond EOF as reserved, anonymous pages. - Note that this isn't done in WOW64 environments since apparently - WOW64 does not support the AT_ROUND_TO_PAGE flag which is required - to get this right. Too bad. */ - if (!wincap.is_wow64 () - && ((len > fsiz && !autogrow (flags)) - || roundup2 (len, getsystempagesize ()) - < roundup2 (len, pagesize))) - orig_len = len; - if (len > fsiz) - { - if (autogrow (flags)) - { - /* Allow mapping beyond EOF if MAP_AUTOGROW flag is set. - Check if file has been opened for writing, otherwise - MAP_AUTOGROW is invalid. */ - if (!(fh->get_access () & GENERIC_WRITE)) - { - set_errno (EINVAL); - goto out; - } - } - else - /* Otherwise, don't map beyond EOF, since Windows would change - the file to the new length, in contrast to POSIX. */ - len = fsiz; - } - - /* If the requested offset + len is <= file size, drop MAP_AUTOGROW. - This simplifes fhandler::mmap's job. */ - if (autogrow (flags) && (off + len) <= fsiz) - flags &= ~MAP_AUTOGROW; - } - -go_ahead: - - /* MAP_NORESERVE is only supported on private anonymous mappings. - Remove that bit from flags so that later code doesn't have to - test all bits. */ - if (noreserve (flags) && (!anonymous (flags) || !priv (flags))) - flags &= ~MAP_NORESERVE; - - LIST_LOCK (); - map_list = mmapped_areas.get_list_by_fd (fd, &st); - - /* Test if an existing anonymous mapping can be recycled. */ - if (map_list && anonymous (flags)) - { - caddr_t tried = map_list->try_map (addr, len, flags, off); - /* try_map returns NULL if no map matched, otherwise it returns - a valid address, or MAP_FAILED in case of a fatal error. */ - if (tried) - { - ret = tried; - goto out_with_unlock; - } - } - - if (orig_len) - { - /* If the requested length is bigger than the file size, we try to - allocate an area of the full size first. This area is immediately - deallocated and the address we got is used as base address for the - subsequent real mappings. This ensures that we have enough space - for the whole thing. */ - orig_len = roundup2 (orig_len, pagesize); - PVOID newaddr = VirtualAlloc (addr, orig_len, MEM_TOP_DOWN | MEM_RESERVE, - PAGE_READWRITE); - if (!newaddr) - { - /* If addr is not NULL, but MAP_FIXED isn't given, allow the OS - to choose. */ - if (addr && !fixed (flags)) - newaddr = VirtualAlloc (NULL, orig_len, MEM_TOP_DOWN | MEM_RESERVE, - PAGE_READWRITE); - if (!newaddr) - { - __seterrno (); - goto out_with_unlock; - } - } - if (!VirtualFree (newaddr, 0, MEM_RELEASE)) - { - __seterrno (); - goto out_with_unlock; - } - addr = newaddr; - } - - base = mmap_worker (map_list, fh, (caddr_t) addr, len, prot, flags, fd, off, - &st); - if (!base) - goto out_with_unlock; - - if (orig_len) - { - /* If the requested length is bigger than the file size, the - remainder is created as anonymous mapping. Actually two - mappings are created, first the remainder from the file end to - the next 64K boundary as accessible pages with the same - protection as the file's pages, then as much pages as necessary - to accomodate the requested length, but as reserved pages which - raise a SIGBUS when trying to access them. AT_ROUND_TO_PAGE - and page protection on shared pages is only supported by 32 bit NT, - so don't even try on WOW64. This is accomplished by not setting - orig_len on WOW64 above. */ -#if 0 - orig_len = roundup2 (orig_len, pagesize); -#endif - len = roundup2 (len, getsystempagesize ()); - if (orig_len - len) - { - orig_len -= len; - size_t valid_page_len = orig_len % pagesize; - size_t sigbus_page_len = orig_len - valid_page_len; - - caddr_t at_base = base + len; - if (valid_page_len) - { - prot |= __PROT_FILLER; - flags &= MAP_SHARED | MAP_PRIVATE; - flags |= MAP_ANONYMOUS | MAP_FIXED; - at_base = mmap_worker (NULL, &fh_anonymous, at_base, - valid_page_len, prot, flags, -1, 0, NULL); - if (!at_base) - { - fh->munmap (fh->get_handle (), base, len); - set_errno (ENOMEM); - goto out_with_unlock; - } - at_base += valid_page_len; - } - if (sigbus_page_len) - { - prot = PROT_READ | PROT_WRITE | __PROT_ATTACH; - flags = MAP_ANONYMOUS | MAP_NORESERVE | MAP_FIXED; - at_base = mmap_worker (NULL, &fh_anonymous, at_base, - sigbus_page_len, prot, flags, -1, 0, NULL); - if (!at_base) - debug_printf ("Warning: Mapping beyond EOF failed, %E"); - } - } - } - - ret = base; - -out_with_unlock: - LIST_UNLOCK (); - -out: - - if (fh_disk_file) - { - NtClose (fh_disk_file->get_handle ()); - delete fh; - } - - syscall_printf ("%p = mmap() ", ret); - return ret; -} - -extern "C" void * -mmap (void *addr, size_t len, int prot, int flags, int fd, _off_t off) -{ - return mmap64 (addr, len, prot, flags, fd, (_off64_t)off); -} - -/* munmap () removes all mmapped pages between addr and addr+len. */ - -extern "C" int -munmap (void *addr, size_t len) -{ - syscall_printf ("munmap (addr %x, len %u)", addr, len); - - /* Error conditions according to SUSv3 */ - if (!addr || !len || check_invalid_virtual_addr (addr, len)) - { - set_errno (EINVAL); - return -1; - } - size_t pagesize = getpagesize (); - if (((uintptr_t) addr % pagesize) || !len) - { - set_errno (EINVAL); - return -1; - } - len = roundup2 (len, pagesize); - - LIST_LOCK (); - - /* Iterate through the map, unmap pages between addr and addr+len - in all maps. */ - mmap_list *map_list, *next_map_list; - LIST_FOREACH_SAFE (map_list, &mmapped_areas.lists, ml_next, next_map_list) - { - mmap_record *rec, *next_rec; - caddr_t u_addr; - DWORD u_len; - - LIST_FOREACH_SAFE (rec, &map_list->recs, mr_next, next_rec) - { - if (!rec->match ((caddr_t) addr, len, u_addr, u_len)) - continue; - if (rec->unmap_pages (u_addr, u_len)) - { - /* The whole record has been unmapped, so we now actually - unmap it from the system in full length... */ - fhandler_base *fh = rec->alloc_fh (); - fh->munmap (rec->get_handle (), - rec->get_address (), - rec->get_len ()); - rec->free_fh (fh); - - /* ...and delete the record. */ - if (map_list->del_record (rec)) - { - /* Yay, the last record has been removed from the list, - we can remove the list now, too. */ - mmapped_areas.del_list (map_list); - break; - } - } - } - } - - LIST_UNLOCK (); - syscall_printf ("0 = munmap(): %x", addr); - return 0; -} - -/* Sync file with memory. Ignore flags for now. */ - -extern "C" int -msync (void *addr, size_t len, int flags) -{ - int ret = -1; - mmap_list *map_list; - - syscall_printf ("msync (addr: %p, len %u, flags %x)", addr, len, flags); - - LIST_LOCK (); - - if (((uintptr_t) addr % getpagesize ()) - || (flags & ~(MS_ASYNC | MS_SYNC | MS_INVALIDATE)) - || ((flags & (MS_ASYNC | MS_SYNC)) == (MS_ASYNC | MS_SYNC))) - { - set_errno (EINVAL); - goto out; - } -#if 0 /* If I only knew why I did that... */ - len = roundup2 (len, getpagesize ()); -#endif - - /* Iterate through the map, looking for the mmapped area. - Error if not found. */ - LIST_FOREACH (map_list, &mmapped_areas.lists, ml_next) - { - mmap_record *rec; - LIST_FOREACH (rec, &map_list->recs, mr_next) - { - if (rec->access ((caddr_t) addr)) - { - /* Check whole area given by len. */ - for (DWORD i = getpagesize (); i < len; i += getpagesize ()) - if (!rec->access ((caddr_t) addr + i)) - { - set_errno (ENOMEM); - goto out; - } - fhandler_base *fh = rec->alloc_fh (); - ret = fh->msync (rec->get_handle (), (caddr_t) addr, len, flags); - rec->free_fh (fh); - goto out; - } - } - } - - /* No matching mapping exists. */ - set_errno (ENOMEM); - -out: - LIST_UNLOCK (); - syscall_printf ("%d = msync()", ret); - return ret; -} - -/* Set memory protection */ - -extern "C" int -mprotect (void *addr, size_t len, int prot) -{ - bool in_mapped = false; - bool ret = false; - DWORD old_prot; - DWORD new_prot = 0; - - syscall_printf ("mprotect (addr: %p, len %u, prot %x)", addr, len, prot); - - /* See comment in mmap64 for a description. */ - size_t pagesize = getpagesize (); - if ((uintptr_t) addr % pagesize) - { - set_errno (EINVAL); - goto out; - } - len = roundup2 (len, pagesize); - - LIST_LOCK (); - - /* Iterate through the map, protect pages between addr and addr+len - in all maps. */ - mmap_list *map_list; - LIST_FOREACH (map_list, &mmapped_areas.lists, ml_next) - { - mmap_record *rec; - caddr_t u_addr; - DWORD u_len; - - LIST_FOREACH (rec, &map_list->recs, mr_next) - { - if (!rec->match ((caddr_t) addr, len, u_addr, u_len)) - continue; - in_mapped = true; - if (rec->attached ()) - continue; - new_prot = gen_protect (prot, rec->get_flags ()); - if (rec->noreserve ()) - { - if (new_prot == PAGE_NOACCESS) - ret = VirtualFree (u_addr, u_len, MEM_DECOMMIT); - else - ret = !!VirtualAlloc (u_addr, u_len, MEM_COMMIT, new_prot); - } - else - ret = VirtualProtect (u_addr, u_len, new_prot, &old_prot); - if (!ret) - { - __seterrno (); - break; - } - } - } - - LIST_UNLOCK (); - - if (!in_mapped) - { - int flags = 0; - MEMORY_BASIC_INFORMATION mbi; - - ret = VirtualQuery (addr, &mbi, sizeof mbi); - if (ret) - { - /* If write protection is requested, check if the page was - originally protected writecopy. In this case call VirtualProtect - requesting PAGE_WRITECOPY, otherwise the VirtualProtect will fail - on NT version >= 5.0 */ - if (prot & PROT_WRITE) - { - if (mbi.AllocationProtect == PAGE_WRITECOPY - || mbi.AllocationProtect == PAGE_EXECUTE_WRITECOPY) - flags = MAP_PRIVATE; - } - new_prot = gen_protect (prot, flags); - if (new_prot != PAGE_NOACCESS && mbi.State == MEM_RESERVE) - ret = VirtualAlloc (addr, len, MEM_COMMIT, new_prot); - else - ret = VirtualProtect (addr, len, new_prot, &old_prot); - } - if (!ret) - __seterrno (); - } - -out: - - syscall_printf ("%d = mprotect ()", ret ? 0 : -1); - return ret ? 0 : -1; -} - -extern "C" int -mlock (const void *addr, size_t len) -{ - int ret = -1; - - /* Instead of using VirtualLock, which does not guarantee that the pages - aren't swapped out when the process is inactive, we're using - ZwLockVirtualMemory with the LOCK_VM_IN_RAM flag to do what mlock on - POSIX systems does. On NT, this requires SeLockMemoryPrivilege, - which is given only to SYSTEM by default. */ - - push_thread_privilege (SE_LOCK_MEMORY_PRIVILEGE, true); - - /* Align address and length values to page size. */ - size_t pagesize = getpagesize (); - PVOID base = (PVOID) rounddown((uintptr_t) addr, pagesize); - ULONG size = roundup2 (((uintptr_t) addr - (uintptr_t) base) + len, pagesize); - NTSTATUS status = 0; - do - { - status = NtLockVirtualMemory (NtCurrentProcess (), &base, &size, - LOCK_VM_IN_RAM); - if (status == STATUS_WORKING_SET_QUOTA) - { - /* The working set is too small, try to increase it so that the - requested locking region fits in. Unfortunately I don't know - any function which would return the currently locked pages of - a process (no go with NtQueryVirtualMemory). - - So, except for the border cases, what we do here is something - really embarrassing. We raise the working set by 64K at a time - and retry, until either we fail to raise the working set size - further, or until NtLockVirtualMemory returns successfully (or - with another error). */ - ULONG min, max; - if (!GetProcessWorkingSetSize (GetCurrentProcess (), &min, &max)) - { - set_errno (ENOMEM); - break; - } - if (min < size) - min = size + pagesize; - else if (size < pagesize) - min += size; - else - min += pagesize; - if (max < min) - max = min; - if (!SetProcessWorkingSetSize (GetCurrentProcess (), min, max)) - { - set_errno (ENOMEM); - break; - } - } - else if (!NT_SUCCESS (status)) - __seterrno_from_nt_status (status); - else - ret = 0; - } - while (status == STATUS_WORKING_SET_QUOTA); - - pop_thread_privilege (); - - return ret; -} - -extern "C" int -munlock (const void *addr, size_t len) -{ - int ret = -1; - - push_thread_privilege (SE_LOCK_MEMORY_PRIVILEGE, true); - - /* Align address and length values to page size. */ - size_t pagesize = getpagesize (); - PVOID base = (PVOID) rounddown((uintptr_t) addr, pagesize); - ULONG size = roundup2 (((uintptr_t) addr - (uintptr_t) base) + len, pagesize); - NTSTATUS status = NtUnlockVirtualMemory (NtCurrentProcess (), &base, &size, - LOCK_VM_IN_RAM); - if (!NT_SUCCESS (status)) - __seterrno_from_nt_status (status); - else - ret = 0; - - pop_thread_privilege (); - - return ret; -} - -extern "C" int -posix_madvise (void *addr, size_t len, int advice) -{ - /* Check parameters. */ - if (advice < POSIX_MADV_NORMAL || advice > POSIX_MADV_DONTNEED - || !len) - return EINVAL; - - /* Check requested memory area. */ - MEMORY_BASIC_INFORMATION m; - char *p = (char *) addr; - char *endp = p + len; - while (p < endp) - { - if (!VirtualQuery (p, &m, sizeof m) || m.State == MEM_FREE) - return ENOMEM; - p = (char *) m.BaseAddress + m.RegionSize; - } - - /* Eventually do nothing. */ - return 0; -} - -/* - * Base implementation: - * - * `mmap' returns ENODEV as documented in SUSv2. - * In contrast to the global function implementation, the member function - * `mmap' has to return the mapped base address in `addr' and the handle to - * the mapping object as return value. In case of failure, the fhandler - * mmap has to close that handle by itself and return INVALID_HANDLE_VALUE. - * - * `munmap' and `msync' get the handle to the mapping object as first parameter - * additionally. -*/ -HANDLE -fhandler_base::mmap (caddr_t *addr, size_t len, int prot, - int flags, _off64_t off) -{ - set_errno (ENODEV); - return INVALID_HANDLE_VALUE; -} - -int -fhandler_base::munmap (HANDLE h, caddr_t addr, size_t len) -{ - set_errno (ENODEV); - return -1; -} - -int -fhandler_base::msync (HANDLE h, caddr_t addr, size_t len, int flags) -{ - set_errno (ENODEV); - return -1; -} - -bool -fhandler_base::fixup_mmap_after_fork (HANDLE h, int prot, int flags, - _off64_t offset, DWORD size, - void *address) -{ - set_errno (ENODEV); - return -1; -} - -/* Implementation for anonymous maps. Using fhandler_dev_zero looks - quite the natural way. */ -HANDLE -fhandler_dev_zero::mmap (caddr_t *addr, size_t len, int prot, - int flags, _off64_t off) -{ - HANDLE h; - void *base; - - if (priv (flags) && !filler (prot)) - { - /* Private anonymous maps are now implemented using VirtualAlloc. - This has two advantages: - - - VirtualAlloc has a smaller footprint than a copy-on-write - anonymous map. - - - It supports decommitting using VirtualFree, in contrast to - section maps. This allows minimum footprint private maps, - when using the (non-POSIX, yay-Linux) MAP_NORESERVE flag. - */ - DWORD protect = gen_protect (prot, flags); - DWORD alloc_type = MEM_TOP_DOWN | MEM_RESERVE - | (noreserve (flags) ? 0 : MEM_COMMIT); - base = VirtualAlloc (*addr, len, alloc_type, protect); - if (!base && addr && !fixed (flags)) - base = VirtualAlloc (NULL, len, alloc_type, protect); - if (!base || (fixed (flags) && base != *addr)) - { - if (!base) - __seterrno (); - else - { - VirtualFree (base, 0, MEM_RELEASE); - set_errno (EINVAL); - debug_printf ("VirtualAlloc: address shift with MAP_FIXED given"); - } - return INVALID_HANDLE_VALUE; - } - h = (HANDLE) 1; /* Fake handle to indicate success. */ - } - else - { - h = CreateMapping (get_handle (), len, off, get_access (), prot, flags); - if (!h) - { - __seterrno (); - debug_printf ("CreateMapping failed with %E"); - return INVALID_HANDLE_VALUE; - } - - base = MapView (h, *addr, len, get_access(), prot, flags, off); - if (!base || (fixed (flags) && base != *addr)) - { - if (!base) - __seterrno (); - else - { - NtUnmapViewOfSection (NtCurrentProcess (), base); - set_errno (EINVAL); - debug_printf ("MapView: address shift with MAP_FIXED given"); - } - NtClose (h); - return INVALID_HANDLE_VALUE; - } - } - *addr = (caddr_t) base; - return h; -} - -int -fhandler_dev_zero::munmap (HANDLE h, caddr_t addr, size_t len) -{ - if (h == (HANDLE) 1) /* See fhandler_dev_zero::mmap. */ - VirtualFree (addr, 0, MEM_RELEASE); - else - { - NtUnmapViewOfSection (NtCurrentProcess (), addr); - NtClose (h); - } - return 0; -} - -int -fhandler_dev_zero::msync (HANDLE h, caddr_t addr, size_t len, int flags) -{ - return 0; -} - -bool -fhandler_dev_zero::fixup_mmap_after_fork (HANDLE h, int prot, int flags, - _off64_t offset, DWORD size, - void *address) -{ - /* Re-create the map */ - void *base; - if (priv (flags) && !filler (prot)) - { - DWORD alloc_type = MEM_RESERVE | (noreserve (flags) ? 0 : MEM_COMMIT); - /* Always allocate R/W so that ReadProcessMemory doesn't fail - due to a non-writable target address. The protection is - set to the correct one anyway in the fixup loop. */ - base = VirtualAlloc (address, size, alloc_type, PAGE_READWRITE); - } - else - base = MapView (h, address, size, get_access (), prot, flags, offset); - if (base != address) - { - MEMORY_BASIC_INFORMATION m; - VirtualQuery (address, &m, sizeof (m)); - system_printf ("requested %p != %p mem alloc base %p, state %p, " - "size %d, %E", address, base, m.AllocationBase, m.State, - m.RegionSize); - } - return base == address; -} - -/* Implementation for disk files and anonymous mappings. */ -HANDLE -fhandler_disk_file::mmap (caddr_t *addr, size_t len, int prot, - int flags, _off64_t off) -{ - HANDLE h = CreateMapping (get_handle (), len, off, get_access (), - prot, flags); - if (!h) - { - __seterrno (); - debug_printf ("CreateMapping failed with %E"); - return INVALID_HANDLE_VALUE; - } - - void *base = MapView (h, *addr, len, get_access (), prot, flags, off); - if (!base || (fixed (flags) && base != *addr)) - { - if (!base) - __seterrno (); - else - { - NtUnmapViewOfSection (NtCurrentProcess (), base); - set_errno (EINVAL); - debug_printf ("MapView: address shift with MAP_FIXED given"); - } - NtClose (h); - return INVALID_HANDLE_VALUE; - } - - *addr = (caddr_t) base; - return h; -} - -int -fhandler_disk_file::munmap (HANDLE h, caddr_t addr, size_t len) -{ - NtUnmapViewOfSection (NtCurrentProcess (), addr); - NtClose (h); - return 0; -} - -int -fhandler_disk_file::msync (HANDLE h, caddr_t addr, size_t len, int flags) -{ - if (FlushViewOfFile (addr, len) == 0) - { - __seterrno (); - return -1; - } - return 0; -} - -bool -fhandler_disk_file::fixup_mmap_after_fork (HANDLE h, int prot, int flags, - _off64_t offset, DWORD size, - void *address) -{ - /* Re-create the map */ - void *base = MapView (h, address, size, get_access (), prot, flags, offset); - if (base != address) - { - MEMORY_BASIC_INFORMATION m; - VirtualQuery (address, &m, sizeof (m)); - system_printf ("requested %p != %p mem alloc base %p, state %p, " - "size %d, %E", address, base, m.AllocationBase, m.State, - m.RegionSize); - } - return base == address; -} - -HANDLE -fhandler_dev_mem::mmap (caddr_t *addr, size_t len, int prot, - int flags, _off64_t off) -{ - if (off >= mem_size - || (DWORD) len >= mem_size - || off + len >= mem_size) - { - set_errno (EINVAL); - debug_printf ("-1 = mmap(): illegal parameter, set EINVAL"); - return INVALID_HANDLE_VALUE; - } - - OBJECT_ATTRIBUTES attr; - InitializeObjectAttributes (&attr, &ro_u_pmem, - OBJ_CASE_INSENSITIVE | OBJ_INHERIT, - NULL, NULL); - - /* Section access is bit-wise ored, while on the Win32 level access - is only one of the values. It's not quite clear if the section - access has to be defined this way, or if SECTION_ALL_ACCESS would - be sufficient but this worked fine so far, so why change? */ - ACCESS_MASK section_access; - if (prot & PROT_WRITE) - section_access = SECTION_MAP_READ | SECTION_MAP_WRITE; - else - section_access = SECTION_MAP_READ; - - HANDLE h; - NTSTATUS ret = NtOpenSection (&h, section_access, &attr); - if (!NT_SUCCESS (ret)) - { - __seterrno_from_nt_status (ret); - debug_printf ("-1 = mmap(): NtOpenSection failed with %E"); - return INVALID_HANDLE_VALUE; - } - - void *base = MapView (h, *addr, len, get_access (), prot, - flags | MAP_ANONYMOUS, off); - if (!base || (fixed (flags) && base != *addr)) - { - if (!base) - __seterrno (); - else - { - NtUnmapViewOfSection (NtCurrentProcess (), base); - set_errno (EINVAL); - debug_printf ("MapView: address shift with MAP_FIXED given"); - } - NtClose (h); - return INVALID_HANDLE_VALUE; - } - - *addr = (caddr_t) base; - return h; -} - -int -fhandler_dev_mem::munmap (HANDLE h, caddr_t addr, size_t len) -{ - NTSTATUS ret; - if (!NT_SUCCESS (ret = NtUnmapViewOfSection (NtCurrentProcess (), addr))) - { - __seterrno_from_nt_status (ret); - return -1; - } - NtClose (h); - return 0; -} - -int -fhandler_dev_mem::msync (HANDLE h, caddr_t addr, size_t len, int flags) -{ - return 0; -} - -bool -fhandler_dev_mem::fixup_mmap_after_fork (HANDLE h, int prot, int flags, - _off64_t offset, DWORD size, - void *address) -{ - void *base = MapView (h, address, size, get_access (), prot, - flags | MAP_ANONYMOUS, offset); - if (base != address) - { - MEMORY_BASIC_INFORMATION m; - VirtualQuery (address, &m, sizeof (m)); - system_printf ("requested %p != %p mem alloc base %p, state %p, " - "size %d, %E", address, base, m.AllocationBase, m.State, - m.RegionSize); - } - return base == address; -} - -/* Call to re-create all the file mappings in a forked child. Called from - the child in initialization. At this point we are passed a valid - mmapped_areas map, and all the HANDLE's are valid for the child, but - none of the mapped areas are in our address space. We need to iterate - through the map, doing the MapViewOfFile calls. */ - -int __stdcall -fixup_mmaps_after_fork (HANDLE parent) -{ - /* Iterate through the map */ - mmap_list *map_list; - LIST_FOREACH (map_list, &mmapped_areas.lists, ml_next) - { - mmap_record *rec; - LIST_FOREACH (rec, &map_list->recs, mr_next) - { - debug_printf ("fd %d, h 0x%x, address %p, len 0x%x, prot: 0x%x, " - "flags: 0x%x, offset %X", - rec->get_fd (), rec->get_handle (), rec->get_address (), - rec->get_len (), rec->get_prot (), rec->get_flags (), - rec->get_offset ()); - - fhandler_base *fh = rec->alloc_fh (); - bool ret = fh->fixup_mmap_after_fork (rec->get_handle (), - rec->get_prot (), - rec->get_flags () | MAP_FIXED, - rec->get_offset (), - rec->get_len (), - rec->get_address ()); - rec->free_fh (fh); - - if (!ret) - { - if (rec->attached ()) - { - system_printf ("Warning: Fixup mapping beyond EOF failed"); - continue; - } - return -1; - } - - MEMORY_BASIC_INFORMATION mbi; - DWORD old_prot; - - for (char *address = rec->get_address (); - address < rec->get_address () + rec->get_len (); - address += mbi.RegionSize) - { - if (!VirtualQueryEx (parent, address, &mbi, sizeof mbi)) - { - system_printf ("VirtualQueryEx failed for MAP_PRIVATE " - "address %p, %E", address); - return -1; - } - /* Just skip reserved pages. */ - if (mbi.State == MEM_RESERVE) - continue; - /* Copy-on-write pages must be copied to the child to circumvent - a strange notion how copy-on-write is supposed to work. */ - if (rec->priv ()) - { - if (rec->noreserve () - && !VirtualAlloc (address, mbi.RegionSize, - MEM_COMMIT, PAGE_READWRITE)) - { - system_printf ("VirtualAlloc failed for MAP_PRIVATE " - "address %p, %E", address); - return -1; - } - if (mbi.Protect == PAGE_NOACCESS - && !VirtualProtectEx (parent, address, mbi.RegionSize, - PAGE_READONLY, &old_prot)) - { - system_printf ("VirtualProtectEx failed for MAP_PRIVATE " - "address %p, %E", address); - return -1; - } - else if ((mbi.AllocationProtect == PAGE_WRITECOPY - || mbi.AllocationProtect == PAGE_EXECUTE_WRITECOPY) - && (mbi.Protect == PAGE_READWRITE - || mbi.Protect == PAGE_EXECUTE_READWRITE)) - /* A WRITECOPY page which has been written to is set to - READWRITE, but that's an incompatible protection to - set the page to. Convert the protection to WRITECOPY - so that the below VirtualProtect doesn't fail. */ - mbi.Protect <<= 1; - - if (!ReadProcessMemory (parent, address, address, - mbi.RegionSize, NULL)) - { - system_printf ("ReadProcessMemory failed for MAP_PRIVATE " - "address %p, %E", address); - return -1; - } - if (mbi.Protect == PAGE_NOACCESS - && !VirtualProtectEx (parent, address, mbi.RegionSize, - PAGE_NOACCESS, &old_prot)) - { - system_printf ("WARNING: VirtualProtectEx to return to " - "PAGE_NOACCESS state in parent failed for " - "MAP_PRIVATE address %p, %E", address); - return -1; - } - } - /* Set child page protection to parent protection */ - if (!VirtualProtect (address, mbi.RegionSize, - mbi.Protect, &old_prot)) - { - MEMORY_BASIC_INFORMATION m; - VirtualQuery (address, &m, sizeof m); - system_printf ("VirtualProtect failed for " - "address %p, " - "parentstate: 0x%x, " - "state: 0x%x, " - "parentprot: 0x%x, " - "prot: 0x%x, %E", - address, mbi.State, m.State, - mbi.Protect, m.Protect); - return -1; - } - } - } - } - - debug_printf ("succeeded"); - return 0; -} diff --git a/winsup/cygwin/mmap_helper.h b/winsup/cygwin/mmap_helper.h deleted file mode 100644 index 23a03ff60..000000000 --- a/winsup/cygwin/mmap_helper.h +++ /dev/null @@ -1,91 +0,0 @@ -/* mmap_helper.h - - Copyright 2006 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _MMAP_HELPER_H -#define _MMAP_HELPER_H -#define _MMIOWRAP(__ptr, __len, __func) \ -({ \ - BOOL __res; \ - for (int __i = 0; __i < 2; __i++) \ - { \ - __res = __func; \ - if (__res || __i > 0) \ - break; \ - DWORD __errcode = GetLastError (); \ - if (__errcode != ERROR_NOACCESS) \ - break; \ - switch (mmap_is_attached_or_noreserve (__ptr, __len)) \ - { \ - case MMAP_NORESERVE_COMMITED: \ - continue; \ - case MMAP_RAISE_SIGBUS: \ - raise(SIGBUS); \ - default: \ - break; \ - } \ - break; \ - } \ - __res; \ -}) - -#define _MMSOCKWRAP(__ptr, __count, __func) \ -({ \ - int __res; \ - for (int __i = 0; __i < 2; __i++) \ - { \ - __res = __func; \ - if (!__res || __i > 0) \ - break; \ - DWORD __errcode = WSAGetLastError (); \ - if (__errcode != WSAEFAULT) \ - break; \ - for (unsigned __j = 0; __j < __count; __j++) \ - switch (mmap_is_attached_or_noreserve (__ptr[__j].buf, __ptr[__j].len)) \ - { \ - case MMAP_NORESERVE_COMMITED: \ - goto keeptrying; \ - case MMAP_RAISE_SIGBUS: \ - raise(SIGBUS); \ - default: \ - break; \ - } \ - break; \ - keeptrying: \ - continue; \ - } \ - __res; \ -}) - -extern inline BOOL -mmReadFile (HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, - LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped) -{ - return _MMIOWRAP (lpBuffer, nNumberOfBytesToRead, - (ReadFile (hFile, lpBuffer, nNumberOfBytesToRead, - lpNumberOfBytesRead, lpOverlapped))); -} - -#ifdef _WINSOCK_H -extern inline int -mmWSARecvFrom (SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, - LPDWORD lpNumberOfBytesRecvd, LPDWORD lpFlags, - struct sockaddr* lpFrom, - LPINT lpFromlen, LPWSAOVERLAPPED lpOverlapped, - LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) -{ - return _MMSOCKWRAP (lpBuffers, dwBufferCount, - (mmWSARecvFrom(s, lpBuffers, dwBufferCount, - lpNumberOfBytesRecvd, lpFlags, lpFrom, - lpFromlen, lpOverlapped, - lpCompletionRoutine))); -} -#endif /*_WINSOCK_H*/ - -#endif /*_MMAP_HELPER_H*/ diff --git a/winsup/cygwin/mount.cc b/winsup/cygwin/mount.cc deleted file mode 100644 index e8d181125..000000000 --- a/winsup/cygwin/mount.cc +++ /dev/null @@ -1,1678 +0,0 @@ -/* mount.cc: mount handling. - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "miscfuncs.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "shared_info.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "cygtls.h" -#include "tls_pbuf.h" -#include -#include -#include -#include - -/* Determine if path prefix matches current cygdrive */ -#define iscygdrive(path) \ - (path_prefix_p (mount_table->cygdrive, (path), mount_table->cygdrive_len, false)) - -#define iscygdrive_device(path) \ - (isalpha (path[mount_table->cygdrive_len]) && \ - (path[mount_table->cygdrive_len + 1] == '/' || \ - !path[mount_table->cygdrive_len + 1])) - -#define isproc(path) \ - (path_prefix_p (proc, (path), proc_len, false)) - -bool NO_COPY mount_info::got_usr_bin; -bool NO_COPY mount_info::got_usr_lib; -int NO_COPY mount_info::root_idx = -1; - -/* is_unc_share: Return non-zero if PATH begins with //server/share - or with one of the native prefixes //./ or //?/ - This function is only used to test for valid input strings. - The later normalization drops the native prefixes. */ - -static inline bool __stdcall -is_native_path (const char *path) -{ - return isdirsep (path[0]) - && (isdirsep (path[1]) || path[1] == '?') - && (path[2] == '?' || path[2] == '.') - && isdirsep (path[3]) - && isalpha (path[4]); -} - -static inline bool __stdcall -is_unc_share (const char *path) -{ - const char *p; - return (isdirsep (path[0]) - && isdirsep (path[1]) - && isalnum (path[2]) - && ((p = strpbrk (path + 3, "\\/")) != NULL) - && isalnum (p[1])); -} - -/* Return true if src_path is a valid, internally supported device name. - In that case, win32_path gets the corresponding NT device name and - dev is appropriately filled with device information. */ - -static bool -win32_device_name (const char *src_path, char *win32_path, device& dev) -{ - dev.parse (src_path); - if (dev == FH_FS || dev == FH_DEV) - return false; - strcpy (win32_path, dev.native); - return true; -} - -/* Beginning with Samba 3.0.28a, Samba allows to get version information using - the ExtendedInfo member returned by a FileFsObjectIdInformation request. - We just store the samba_version information for now. Older versions than - 3.2 are still guessed at by testing the file system flags. */ -#define SAMBA_EXTENDED_INFO_MAGIC 0x536d4261 /* "SmBa" */ -#define SAMBA_EXTENDED_INFO_VERSION_STRING_LENGTH 28 -#pragma pack(push,4) -struct smb_extended_info { - DWORD samba_magic; /* Always SAMBA_EXTENDED_INFO_MAGIC */ - DWORD samba_version; /* Major/Minor/Release/Revision */ - DWORD samba_subversion; /* Prerelease/RC/Vendor patch */ - LARGE_INTEGER samba_gitcommitdate; - char samba_version_string[SAMBA_EXTENDED_INFO_VERSION_STRING_LENGTH]; -}; -#pragma pack(pop) - -bool -fs_info::update (PUNICODE_STRING upath, HANDLE in_vol) -{ - NTSTATUS status = STATUS_OBJECT_NAME_NOT_FOUND; - HANDLE vol; - OBJECT_ATTRIBUTES attr; - IO_STATUS_BLOCK io; - bool no_media = false; - FILE_FS_DEVICE_INFORMATION ffdi; - FILE_FS_OBJECTID_INFORMATION ffoi; - struct { - FILE_FS_ATTRIBUTE_INFORMATION ffai; - WCHAR buf[NAME_MAX + 1]; - } ffai_buf; - struct { - FILE_FS_VOLUME_INFORMATION ffvi; - WCHAR buf[NAME_MAX + 1]; - } ffvi_buf; - UNICODE_STRING fsname; - - clear (); - if (in_vol) - vol = in_vol; - else - { - ULONG access = READ_CONTROL; - /* Always caseinsensitive. We really just need access to the drive. */ - InitializeObjectAttributes (&attr, upath, OBJ_CASE_INSENSITIVE, NULL, - NULL); - /* Note: Don't use the FILE_OPEN_REPARSE_POINT flag here. The reason - is that symlink_info::check relies on being able to open a handle - to the target of a volume mount point. */ - status = NtOpenFile (&vol, access, &attr, &io, FILE_SHARE_VALID_FLAGS, - FILE_OPEN_FOR_BACKUP_INTENT); - /* At least one filesystem (HGFS, VMware shared folders) doesn't like - to be opened with access set to just READ_CONTROL. */ - if (status == STATUS_INVALID_PARAMETER) - { - access |= FILE_READ_DATA; - status = NtOpenFile (&vol, access, &attr, &io, FILE_SHARE_VALID_FLAGS, - FILE_OPEN_FOR_BACKUP_INTENT); - } - while (!NT_SUCCESS (status) - && (attr.ObjectName->Length > 7 * sizeof (WCHAR) - || status == STATUS_NO_MEDIA_IN_DEVICE)) - { - UNICODE_STRING dir; - RtlSplitUnicodePath (attr.ObjectName, &dir, NULL); - attr.ObjectName = &dir; - if (status == STATUS_NO_MEDIA_IN_DEVICE) - { - no_media = true; - dir.Length = 6 * sizeof (WCHAR); - } - else if (dir.Length > 7 * sizeof (WCHAR)) - dir.Length -= sizeof (WCHAR); - status = NtOpenFile (&vol, access, &attr, &io, FILE_SHARE_VALID_FLAGS, - FILE_OPEN_FOR_BACKUP_INTENT); - } - if (!NT_SUCCESS (status)) - { - debug_printf ("Cannot access path %S, status %08lx", - attr.ObjectName, status); - NtClose (vol); - return false; - } - } - - status = NtQueryVolumeInformationFile (vol, &io, &ffvi_buf.ffvi, - sizeof ffvi_buf, - FileFsVolumeInformation); - sernum = NT_SUCCESS (status) ? ffvi_buf.ffvi.VolumeSerialNumber : 0; - status = NtQueryVolumeInformationFile (vol, &io, &ffdi, sizeof ffdi, - FileFsDeviceInformation); - if (!NT_SUCCESS (status)) - ffdi.DeviceType = ffdi.Characteristics = 0; - - if ((ffdi.Characteristics & FILE_REMOTE_DEVICE) - || (!ffdi.DeviceType - && RtlEqualUnicodePathPrefix (attr.ObjectName, &ro_u_uncp, TRUE))) - is_remote_drive (true); - - if (!no_media) - status = NtQueryVolumeInformationFile (vol, &io, &ffai_buf.ffai, - sizeof ffai_buf, - FileFsAttributeInformation); - if (no_media || !NT_SUCCESS (status)) - { - debug_printf ("Cannot get volume attributes (%S), %08lx", - attr.ObjectName, status); - if (!in_vol) - NtClose (vol); - return false; - } - flags (ffai_buf.ffai.FileSystemAttributes); - name_len (ffai_buf.ffai.MaximumComponentNameLength); - RtlInitCountedUnicodeString (&fsname, ffai_buf.ffai.FileSystemName, - ffai_buf.ffai.FileSystemNameLength); - if (is_remote_drive ()) - { -/* Should be reevaluated for each new OS. Right now this mask is valid up - to Vista. The important point here is to test only flags indicating - capabilities and to ignore flags indicating a specific state of this - volume. At present these flags to ignore are FILE_VOLUME_IS_COMPRESSED - and FILE_READ_ONLY_VOLUME. */ -#define GETVOLINFO_VALID_MASK (0x003701ffUL) -#define TEST_GVI(f,m) (((f) & GETVOLINFO_VALID_MASK) == (m)) - -/* Volume quotas are potentially supported since Samba 3.0, object ids and - the unicode on disk flag since Samba 3.2. */ -#define SAMBA_IGNORE (FILE_VOLUME_QUOTAS \ - | FILE_SUPPORTS_OBJECT_IDS \ - | FILE_UNICODE_ON_DISK) -#define FS_IS_SAMBA TEST_GVI(flags () & ~SAMBA_IGNORE, \ - FILE_CASE_SENSITIVE_SEARCH \ - | FILE_CASE_PRESERVED_NAMES \ - | FILE_PERSISTENT_ACLS) -/* Netapp DataOnTap. TODO: Find out if that's the only flag combination. */ -#define FS_IS_NETAPP_DATAONTAP TEST_GVI(flags (), \ - FILE_CASE_SENSITIVE_SEARCH \ - | FILE_CASE_PRESERVED_NAMES \ - | FILE_UNICODE_ON_DISK \ - | FILE_PERSISTENT_ACLS \ - | FILE_NAMED_STREAMS) -/* These are the minimal flags supported by NTFS since NT4. Every filesystem - not supporting these flags is not a native NTFS. We subsume them under - the filesystem type "cifs". */ -#define MINIMAL_WIN_NTFS_FLAGS (FILE_CASE_SENSITIVE_SEARCH \ - | FILE_CASE_PRESERVED_NAMES \ - | FILE_UNICODE_ON_DISK \ - | FILE_PERSISTENT_ACLS \ - | FILE_FILE_COMPRESSION) -#define FS_IS_WINDOWS_NTFS TEST_GVI(flags () & MINIMAL_WIN_NTFS_FLAGS, \ - MINIMAL_WIN_NTFS_FLAGS) - /* This always fails on NT4. */ - status = NtQueryVolumeInformationFile (vol, &io, &ffoi, sizeof ffoi, - FileFsObjectIdInformation); - if (NT_SUCCESS (status)) - { - smb_extended_info *extended_info = (smb_extended_info *) - &ffoi.ExtendedInfo; - if (extended_info->samba_magic == SAMBA_EXTENDED_INFO_MAGIC) - { - is_samba (true); - samba_version (extended_info->samba_version); - } - } - /* First check the remote filesystems faking to be NTFS. */ - if (!got_fs () && RtlEqualUnicodeString (&fsname, &ro_u_ntfs, FALSE) - /* Test for Samba on NT4 or for older Samba releases not supporting - extended info. */ - && !is_samba (FS_IS_SAMBA) - /* Netapp inode info is unusable. */ - && !is_netapp (FS_IS_NETAPP_DATAONTAP)) - /* Any other remote FS faking to be NTFS. */ - is_cifs (!FS_IS_WINDOWS_NTFS); - /* Then check remote filesystems honest about their name. */ - if (!got_fs () - /* Microsoft NFS needs distinct access methods for metadata. */ - && !is_nfs (RtlEqualUnicodeString (&fsname, &ro_u_nfs, FALSE)) - /* MVFS == Rational ClearCase remote filesystem. Has a couple of - drawbacks, like not supporting DOS attributes other than R/O - and stuff like that. */ - && !is_mvfs (RtlEqualUnicodePathPrefix (&fsname, &ro_u_mvfs, FALSE)) - /* Known remote file system which can't handle calls to - NtQueryDirectoryFile(FileIdBothDirectoryInformation) */ - && !is_unixfs (RtlEqualUnicodeString (&fsname, &ro_u_unixfs, FALSE))) - /* Known remote file system with buggy open calls. Further - explanation in fhandler.cc (fhandler_disk_file::open). */ - { - is_sunwnfs (RtlEqualUnicodeString (&fsname, &ro_u_sunwnfs, FALSE)); - has_buggy_open (is_sunwnfs ()); - } - /* Not only UNIXFS is known to choke on FileIdBothDirectoryInformation. - Some other CIFS servers have problems with this call as well. - Know example: EMC NS-702. We just don't use that info class on - any remote CIFS. */ - if (got_fs ()) - has_buggy_fileid_dirinfo (is_cifs () || is_unixfs ()); - } - if (!got_fs () - && !is_ntfs (RtlEqualUnicodeString (&fsname, &ro_u_ntfs, FALSE)) - && !is_fat (RtlEqualUnicodePathPrefix (&fsname, &ro_u_fat, TRUE)) - && !is_csc_cache (RtlEqualUnicodeString (&fsname, &ro_u_csc, FALSE)) - && !is_nwfs (RtlEqualUnicodeString (&fsname, &ro_u_nwfs, FALSE)) - && is_cdrom (ffdi.DeviceType == FILE_DEVICE_CD_ROM)) - is_udf (RtlEqualUnicodeString (&fsname, &ro_u_udf, FALSE)); - if (!got_fs ()) - { - /* The filesystem name is only used in fillout_mntent and only if - the filesystem isn't one of the well-known filesystems anyway. */ - sys_wcstombs (fsn, sizeof fsn, ffai_buf.ffai.FileSystemName, - ffai_buf.ffai.FileSystemNameLength / sizeof (WCHAR)); - strlwr (fsn); - } - has_acls (flags () & FS_PERSISTENT_ACLS); - /* Netapp inode numbers are fly-by-night. */ - hasgood_inode ((has_acls () && !is_netapp ()) || is_nfs ()); - /* NWFS is known to have a broken FileBasicInformation info class. It - can't be used to fetch information, only to set information. Therefore, - for NWFS we have to fallback to the FileNetworkOpenInformation info - class. Unfortunately we can't use FileNetworkOpenInformation all the - time since that fails on other filesystems like NFS. */ - has_buggy_basic_info (is_nwfs ()); - /* Case sensitivity is supported if FILE_CASE_SENSITIVE_SEARCH is set, - except on Samba which handles Windows clients case insensitive. - - NFS doesn't set the FILE_CASE_SENSITIVE_SEARCH flag but is case - sensitive. - - UDF on NT 5.x is broken (at least) in terms of case sensitivity. - The UDF driver reports the FILE_CASE_SENSITIVE_SEARCH capability - but: - - Opening the root directory for query seems to work at first, - but the filenames in the directory listing are mutilated. - - When trying to open a file or directory case sensitive, the file - appears to be non-existant. */ - caseinsensitive (((!(flags () & FILE_CASE_SENSITIVE_SEARCH) || is_samba ()) - && !is_nfs ()) - || (is_udf () && wincap.has_broken_udf ())); - - if (!in_vol) - NtClose (vol); - return true; -} - -inline void -mount_info::create_root_entry (const PWCHAR root) -{ - /* Create a default root dir derived from the location of the Cygwin DLL. - The entry is immutable, unless the "override" option is given in /etc/fstab. */ - char native_root[PATH_MAX]; - sys_wcstombs (native_root, PATH_MAX, root); - mount_table->add_item (native_root, "/", - MOUNT_SYSTEM | MOUNT_BINARY | MOUNT_IMMUTABLE | MOUNT_AUTOMATIC); - /* Create a default cygdrive entry. Note that this is a user entry. - This allows to override it with mount, unless the sysadmin created - a cygdrive entry in /etc/fstab. */ - cygdrive_flags = MOUNT_BINARY | MOUNT_NOPOSIX | MOUNT_CYGDRIVE; - strcpy (cygdrive, CYGWIN_INFO_CYGDRIVE_DEFAULT_PREFIX "/"); - cygdrive_len = strlen (cygdrive); -} - -/* init: Initialize the mount table. */ - -void -mount_info::init () -{ - nmounts = 0; - PWCHAR pathend; - WCHAR path[PATH_MAX]; - - pathend = wcpcpy (path, installation_root); - create_root_entry (path); - pathend = wcpcpy (pathend, L"\\etc\\fstab"); - - from_fstab (false, path, pathend); - from_fstab (true, path, pathend); - - if (!got_usr_bin || !got_usr_lib) - { - char native[PATH_MAX]; - assert (root_idx != -1); - char *p = stpcpy (native, mount[root_idx].native_path); - if (!got_usr_bin) - { - stpcpy (p, "\\bin"); - mount_table->add_item (native, "/usr/bin", - MOUNT_SYSTEM | MOUNT_BINARY | MOUNT_AUTOMATIC); - } - if (!got_usr_lib) - { - stpcpy (p, "\\lib"); - mount_table->add_item (native, "/usr/lib", - MOUNT_SYSTEM | MOUNT_BINARY | MOUNT_AUTOMATIC); - } - } -} - -static void -set_flags (unsigned *flags, unsigned val) -{ - *flags = val; - if (!(*flags & PATH_BINARY)) - { - *flags |= PATH_TEXT; - debug_printf ("flags: text (%p)", *flags & (PATH_TEXT | PATH_BINARY)); - } - else - { - *flags |= PATH_BINARY; - debug_printf ("flags: binary (%p)", *flags & (PATH_TEXT | PATH_BINARY)); - } -} - -int -mount_item::build_win32 (char *dst, const char *src, unsigned *outflags, unsigned chroot_pathlen) -{ - int n, err = 0; - const char *real_native_path; - int real_posix_pathlen; - set_flags (outflags, (unsigned) flags); - if (!cygheap->root.exists () || posix_pathlen != 1 || posix_path[0] != '/') - { - n = native_pathlen; - real_native_path = native_path; - real_posix_pathlen = chroot_pathlen ?: posix_pathlen; - } - else - { - n = cygheap->root.native_length (); - real_native_path = cygheap->root.native_path (); - real_posix_pathlen = posix_pathlen; - } - memcpy (dst, real_native_path, n + 1); - const char *p = src + real_posix_pathlen; - if (*p == '/') - /* nothing */; - else if ((isdrive (dst) && !dst[2]) || *p) - dst[n++] = '\\'; - if ((n + strlen (p)) >= NT_MAX_PATH) - err = ENAMETOOLONG; - else - backslashify (p, dst + n, 0); - return err; -} - -/* conv_to_win32_path: Ensure src_path is a pure Win32 path and store - the result in win32_path. - - If win32_path != NULL, the relative path, if possible to keep, is - stored in win32_path. If the relative path isn't possible to keep, - the full path is stored. - - If full_win32_path != NULL, the full path is stored there. - - The result is zero for success, or an errno value. - - {,full_}win32_path must have sufficient space (i.e. NT_MAX_PATH bytes). */ - -int -mount_info::conv_to_win32_path (const char *src_path, char *dst, device& dev, - unsigned *flags) -{ - bool chroot_ok = !cygheap->root.exists (); - while (sys_mount_table_counter < cygwin_shared->sys_mount_table_counter) - { - int current = cygwin_shared->sys_mount_table_counter; - init (); - sys_mount_table_counter = current; - } - MALLOC_CHECK; - - dev.devn = FH_FS; - - *flags = 0; - debug_printf ("conv_to_win32_path (%s)", src_path); - - int i, rc; - mount_item *mi = NULL; /* initialized to avoid compiler warning */ - - /* The path is already normalized, without ../../ stuff, we need to have this - so that we can move from one mounted directory to another with relative - stuff. - - eg mounting c:/foo /foo - d:/bar /bar - - cd /bar - ls ../foo - - should look in c:/foo, not d:/foo. - - converting normalizex UNIX path to a DOS-style path, looking up the - appropriate drive in the mount table. */ - - /* See if this is a cygwin "device" */ - if (win32_device_name (src_path, dst, dev)) - { - *flags = MOUNT_BINARY; /* FIXME: Is this a sensible default for devices? */ - rc = 0; - goto out_no_chroot_check; - } - - MALLOC_CHECK; - /* If the path is on a network drive or a //./ resp.//?/ path prefix, - bypass the mount table. If it's // or //MACHINE, use the netdrive - device. */ - if (src_path[1] == '/') - { - if (!strchr (src_path + 2, '/')) - { - dev = *netdrive_dev; - set_flags (flags, PATH_BINARY); - } - else - { - /* For UNC paths, use the cygdrive prefix flags as default setting. - This is more natural since UNC paths, just like cygdrive paths, - are rather (warning, poetic description ahead) windows into the - native Win32 world. This also gives the user an elegant way to - change the settings for those paths in a central place. */ - set_flags (flags, (unsigned) cygdrive_flags); - } - backslashify (src_path, dst, 0); - /* Go through chroot check */ - goto out; - } - if (isproc (src_path)) - { - dev = *proc_dev; - dev.devn = fhandler_proc::get_proc_fhandler (src_path); - if (dev.devn == FH_BAD) - return ENOENT; - set_flags (flags, PATH_BINARY); - strcpy (dst, src_path); - goto out; - } - /* Check if the cygdrive prefix was specified. If so, just strip - off the prefix and transform it into an MS-DOS path. */ - else if (iscygdrive (src_path)) - { - int n = mount_table->cygdrive_len - 1; - int unit; - - if (!src_path[n]) - { - unit = 0; - dst[0] = '\0'; - if (mount_table->cygdrive_len > 1) - dev = *cygdrive_dev; - } - else if (cygdrive_win32_path (src_path, dst, unit)) - { - set_flags (flags, (unsigned) cygdrive_flags); - goto out; - } - else if (mount_table->cygdrive_len > 1) - return ENOENT; - } - - int chroot_pathlen; - chroot_pathlen = 0; - /* Check the mount table for prefix matches. */ - for (i = 0; i < nmounts; i++) - { - const char *path; - int len; - - mi = mount + posix_sorted[i]; - if (!cygheap->root.exists () - || (mi->posix_pathlen == 1 && mi->posix_path[0] == '/')) - { - path = mi->posix_path; - len = mi->posix_pathlen; - } - else if (cygheap->root.posix_ok (mi->posix_path)) - { - path = cygheap->root.unchroot (mi->posix_path); - chroot_pathlen = len = strlen (path); - } - else - { - chroot_pathlen = 0; - continue; - } - - if (path_prefix_p (path, src_path, len, mi->flags & MOUNT_NOPOSIX)) - break; - } - - if (i < nmounts) - { - int err = mi->build_win32 (dst, src_path, flags, chroot_pathlen); - if (err) - return err; - chroot_ok = true; - } - else - { - int offset = 0; - if (src_path[1] != '/' && src_path[1] != ':') - offset = cygheap->cwd.get_drive (dst); - backslashify (src_path, dst + offset, 0); - } - out: - MALLOC_CHECK; - if (chroot_ok || cygheap->root.ischroot_native (dst)) - rc = 0; - else - { - debug_printf ("attempt to access outside of chroot '%s - %s'", - cygheap->root.posix_path (), cygheap->root.native_path ()); - rc = ENOENT; - } - - out_no_chroot_check: - debug_printf ("src_path %s, dst %s, flags %p, rc %d", src_path, dst, *flags, rc); - return rc; -} - -int -mount_info::get_mounts_here (const char *parent_dir, int parent_dir_len, - PUNICODE_STRING mount_points, - PUNICODE_STRING cygd) -{ - int n_mounts = 0; - - for (int i = 0; i < nmounts; i++) - { - mount_item *mi = mount + posix_sorted[i]; - char *last_slash = strrchr (mi->posix_path, '/'); - if (!last_slash) - continue; - if (last_slash == mi->posix_path) - { - if (parent_dir_len == 1 && mi->posix_pathlen > 1) - RtlCreateUnicodeStringFromAsciiz (&mount_points[n_mounts++], - last_slash + 1); - } - else if (parent_dir_len == last_slash - mi->posix_path - && strncasematch (parent_dir, mi->posix_path, parent_dir_len)) - RtlCreateUnicodeStringFromAsciiz (&mount_points[n_mounts++], - last_slash + 1); - } - RtlCreateUnicodeStringFromAsciiz (cygd, cygdrive + 1); - if (cygd->Length) - cygd->Length -= 2; // Strip trailing slash - return n_mounts; -} - -/* cygdrive_posix_path: Build POSIX path used as the - mount point for cygdrives created when there is no other way to - obtain a POSIX path from a Win32 one. */ - -void -mount_info::cygdrive_posix_path (const char *src, char *dst, int trailing_slash_p) -{ - int len = cygdrive_len; - - memcpy (dst, cygdrive, len + 1); - - /* Now finish the path off with the drive letter to be used. - The cygdrive prefix always ends with a trailing slash so - the drive letter is added after the path. */ - dst[len++] = cyg_tolower (src[0]); - if (!src[2] || (isdirsep (src[2]) && !src[3])) - dst[len++] = '\000'; - else - { - int n; - dst[len++] = '/'; - if (isdirsep (src[2])) - n = 3; - else - n = 2; - strcpy (dst + len, src + n); - } - slashify (dst, dst, trailing_slash_p); -} - -int -mount_info::cygdrive_win32_path (const char *src, char *dst, int& unit) -{ - int res; - const char *p = src + cygdrive_len; - if (!isalpha (*p) || (!isdirsep (p[1]) && p[1])) - { - unit = -1; /* FIXME: should be zero, maybe? */ - dst[0] = '\0'; - res = 0; - } - else - { - /* drive letter must always be uppercase for casesensitive native NT. */ - dst[0] = cyg_toupper (*p); - dst[1] = ':'; - strcpy (dst + 2, p + 1); - backslashify (dst, dst, !dst[2]); - unit = dst[0]; - res = 1; - } - debug_printf ("src '%s', dst '%s'", src, dst); - return res; -} - -/* conv_to_posix_path: Ensure src_path is a POSIX path. - - The result is zero for success, or an errno value. - posix_path must have sufficient space (i.e. NT_MAX_PATH bytes). - If keep_rel_p is non-zero, relative paths stay that way. */ - -/* TODO: Change conv_to_posix_path to work with native paths. */ - -/* src_path is a wide Win32 path. */ -int -mount_info::conv_to_posix_path (PWCHAR src_path, char *posix_path, - int keep_rel_p) -{ - bool changed = false; - if (!wcsncmp (src_path, L"\\\\?\\", 4)) - { - src_path += 4; - if (src_path[1] != L':') /* native UNC path */ - { - *(src_path += 2) = L'\\'; - changed = true; - } - } - tmp_pathbuf tp; - char *buf = tp.c_get (); - sys_wcstombs (buf, NT_MAX_PATH, src_path); - int ret = conv_to_posix_path (buf, posix_path, keep_rel_p); - if (changed) - src_path[0] = L'C'; - return ret; -} - -int -mount_info::conv_to_posix_path (const char *src_path, char *posix_path, - int keep_rel_p) -{ - int src_path_len = strlen (src_path); - int relative_path_p = !isabspath (src_path); - int trailing_slash_p; - - if (src_path_len <= 1) - trailing_slash_p = 0; - else - { - const char *lastchar = src_path + src_path_len - 1; - trailing_slash_p = isdirsep (*lastchar) && lastchar[-1] != ':'; - } - - debug_printf ("conv_to_posix_path (%s, %s, %s)", src_path, - keep_rel_p ? "keep-rel" : "no-keep-rel", - trailing_slash_p ? "add-slash" : "no-add-slash"); - MALLOC_CHECK; - - if (src_path_len >= NT_MAX_PATH) - { - debug_printf ("ENAMETOOLONG"); - return ENAMETOOLONG; - } - - /* FIXME: For now, if the path is relative and it's supposed to stay - that way, skip mount table processing. */ - - if (keep_rel_p && relative_path_p) - { - slashify (src_path, posix_path, 0); - debug_printf ("%s = conv_to_posix_path (%s)", posix_path, src_path); - return 0; - } - - tmp_pathbuf tp; - char *pathbuf = tp.c_get (); - char *tail; - int rc = normalize_win32_path (src_path, pathbuf, tail); - if (rc != 0) - { - debug_printf ("%d = conv_to_posix_path (%s)", rc, src_path); - return rc; - } - - int pathbuflen = tail - pathbuf; - for (int i = 0; i < nmounts; ++i) - { - mount_item &mi = mount[native_sorted[i]]; - if (!path_prefix_p (mi.native_path, pathbuf, mi.native_pathlen, - mi.flags & MOUNT_NOPOSIX)) - continue; - - if (cygheap->root.exists () && !cygheap->root.posix_ok (mi.posix_path)) - continue; - - /* SRC_PATH is in the mount table. */ - int nextchar; - const char *p = pathbuf + mi.native_pathlen; - - if (!*p || !p[1]) - nextchar = 0; - else if (isdirsep (*p)) - nextchar = -1; - else - nextchar = 1; - - int addslash = nextchar > 0 ? 1 : 0; - if ((mi.posix_pathlen + (pathbuflen - mi.native_pathlen) + addslash) >= NT_MAX_PATH) - return ENAMETOOLONG; - strcpy (posix_path, mi.posix_path); - if (addslash) - strcat (posix_path, "/"); - if (nextchar) - slashify (p, - posix_path + addslash + (mi.posix_pathlen == 1 ? 0 : mi.posix_pathlen), - trailing_slash_p); - - if (cygheap->root.exists ()) - { - const char *p = cygheap->root.unchroot (posix_path); - memmove (posix_path, p, strlen (p) + 1); - } - goto out; - } - - if (!cygheap->root.exists ()) - /* nothing */; - else if (!cygheap->root.ischroot_native (pathbuf)) - return ENOENT; - else - { - const char *p = pathbuf + cygheap->root.native_length (); - if (*p) - slashify (p, posix_path, trailing_slash_p); - else - { - posix_path[0] = '/'; - posix_path[1] = '\0'; - } - goto out; - } - - /* Not in the database. This should [theoretically] only happen if either - the path begins with //, or / isn't mounted, or the path has a drive - letter not covered by the mount table. If it's a relative path then the - caller must want an absolute path (otherwise we would have returned - above). So we always return an absolute path at this point. */ - if (isdrive (pathbuf)) - cygdrive_posix_path (pathbuf, posix_path, trailing_slash_p); - else - { - /* The use of src_path and not pathbuf here is intentional. - We couldn't translate the path, so just ensure no \'s are present. */ - slashify (src_path, posix_path, trailing_slash_p); - } - -out: - debug_printf ("%s = conv_to_posix_path (%s)", posix_path, src_path); - MALLOC_CHECK; - return 0; -} - -/* Return flags associated with a mount point given the win32 path. */ - -unsigned -mount_info::set_flags_from_win32_path (const char *p) -{ - for (int i = 0; i < nmounts; i++) - { - mount_item &mi = mount[native_sorted[i]]; - if (path_prefix_p (mi.native_path, p, mi.native_pathlen, - mi.flags & MOUNT_NOPOSIX)) - return mi.flags; - } - return PATH_BINARY; -} - -inline char * -skip_ws (char *in) -{ - while (*in == ' ' || *in == '\t') - ++in; - return in; -} - -inline char * -find_ws (char *in) -{ - while (*in && *in != ' ' && *in != '\t') - ++in; - return in; -} - -inline char * -conv_fstab_spaces (char *field) -{ - register char *sp = field; - while ((sp = strstr (sp, "\\040")) != NULL) - { - *sp++ = ' '; - memmove (sp, sp + 3, strlen (sp + 3) + 1); - } - return field; -} - -struct opt -{ - const char *name; - unsigned val; - bool clear; -} oopts[] = -{ - {"acl", MOUNT_NOACL, 1}, - {"auto", 0, 0}, - {"binary", MOUNT_BINARY, 0}, - {"cygexec", MOUNT_CYGWIN_EXEC, 0}, - {"exec", MOUNT_EXEC, 0}, - {"noacl", MOUNT_NOACL, 0}, - {"nosuid", 0, 0}, - {"notexec", MOUNT_NOTEXEC, 0}, - {"nouser", MOUNT_SYSTEM, 0}, - {"override", MOUNT_OVERRIDE, 0}, - {"posix=0", MOUNT_NOPOSIX, 0}, - {"posix=1", MOUNT_NOPOSIX, 1}, - {"text", MOUNT_BINARY, 1}, - {"user", MOUNT_SYSTEM, 1} -}; - -static bool -read_flags (char *options, unsigned &flags) -{ - while (*options) - { - char *p = strchr (options, ','); - if (p) - *p++ = '\0'; - else - p = strchr (options, '\0'); - - for (opt *o = oopts; - o < (oopts + (sizeof (oopts) / sizeof (oopts[0]))); - o++) - if (strcmp (options, o->name) == 0) - { - if (o->clear) - flags &= ~o->val; - else - flags |= o->val; - goto gotit; - } - system_printf ("invalid fstab option - '%s'", options); - return false; - - gotit: - options = p; - } - return true; -} - -bool -mount_info::from_fstab_line (char *line, bool user) -{ - char *native_path, *posix_path, *fs_type; - - /* First field: Native path. */ - char *c = skip_ws (line); - if (!*c || *c == '#') - return true; - char *cend = find_ws (c); - *cend = '\0'; - native_path = conv_fstab_spaces (c); - /* Always convert drive letter to uppercase for case sensitivity. */ - if (isdrive (native_path)) - native_path[0] = cyg_toupper (native_path[0]); - /* Second field: POSIX path. */ - c = skip_ws (cend + 1); - if (!*c) - return true; - cend = find_ws (c); - *cend = '\0'; - posix_path = conv_fstab_spaces (c); - /* Third field: FS type. */ - c = skip_ws (cend + 1); - if (!*c) - return true; - cend = find_ws (c); - *cend = '\0'; - fs_type = c; - /* Forth field: Flags. */ - c = skip_ws (cend + 1); - if (!*c) - return true; - cend = find_ws (c); - *cend = '\0'; - unsigned mount_flags = MOUNT_SYSTEM | MOUNT_BINARY; - if (!strcmp (fs_type, "cygdrive")) - mount_flags |= MOUNT_NOPOSIX; - if (!read_flags (c, mount_flags)) - return true; - if (user) - mount_flags &= ~MOUNT_SYSTEM; - if (!strcmp (fs_type, "cygdrive")) - { - cygdrive_flags = mount_flags | MOUNT_CYGDRIVE; - slashify (posix_path, cygdrive, 1); - cygdrive_len = strlen (cygdrive); - } - else - { - int res = mount_table->add_item (native_path, posix_path, mount_flags); - if (res && get_errno () == EMFILE) - return false; - } - return true; -} - -bool -mount_info::from_fstab (bool user, WCHAR fstab[], PWCHAR fstab_end) -{ - UNICODE_STRING upath; - OBJECT_ATTRIBUTES attr; - IO_STATUS_BLOCK io; - NTSTATUS status; - HANDLE fh; - - if (user) - { - PWCHAR username; - sys_mbstowcs (username = wcpcpy (fstab_end, L".d\\"), - NT_MAX_PATH - (fstab_end - fstab), - cygheap->user.name ()); - /* Make sure special chars in the username are converted according to - the rules. */ - transform_chars (username, username + wcslen (username) - 1); - } - RtlInitUnicodeString (&upath, fstab); - InitializeObjectAttributes (&attr, &upath, OBJ_CASE_INSENSITIVE, NULL, NULL); - debug_printf ("Try to read mounts from %W", fstab); - status = NtOpenFile (&fh, SYNCHRONIZE | FILE_READ_DATA, &attr, &io, - FILE_SHARE_VALID_FLAGS, - FILE_SYNCHRONOUS_IO_NONALERT - | FILE_OPEN_FOR_BACKUP_INTENT); - if (!NT_SUCCESS (status)) - { - debug_printf ("NtOpenFile(%S) failed, %p", &upath, status); - return false; - } - - char buf[NT_MAX_PATH]; - char *got = buf; - DWORD len = 0; - unsigned line = 1; - /* Using buffer size - 2 leaves space to append two \0. */ - while (NT_SUCCESS (NtReadFile (fh, NULL, NULL, NULL, &io, got, - (sizeof (buf) - 2) - (got - buf), NULL, NULL))) - { - char *end; - - len = io.Information; - /* Set end marker. */ - got[len] = got[len + 1] = '\0'; - /* Set len to the absolute len of bytes in buf. */ - len += got - buf; - /* Reset got to start reading at the start of the buffer again. */ - got = buf; -retry: - bool got_nl = false; - while (got < buf + len && (end = strchr (got, '\n'))) - { - got_nl = true; - end[end[-1] == '\r' ? -1 : 0] = '\0'; - if (!from_fstab_line (got, user)) - goto done; - got = end + 1; - ++line; - } - if (len < (sizeof (buf) - 2)) - break; - /* Check if the buffer contained at least one \n. If not, the - line length is > 32K. We don't take such long lines. Print - a debug message and skip this line entirely. */ - if (!got_nl) - { - system_printf ("%W: Line %d too long, skipping...", fstab, line); - while (NT_SUCCESS (NtReadFile (fh, NULL, NULL, NULL, &io, buf, - (sizeof (buf) - 2), NULL, NULL))) - { - len = io.Information; - buf[len] = buf[len + 1] = '\0'; - got = strchr (buf, '\n'); - if (got) - { - ++got; - ++line; - goto retry; - } - } - got = buf; - break; - } - /* We have to read once more. Move remaining bytes to the start of - the buffer and reposition got so that it points to the end of - the remaining bytes. */ - len = buf + len - got; - memmove (buf, got, len); - got = buf + len; - buf[len] = buf[len + 1] = '\0'; - } - /* Catch a last line without trailing \n. */ - if (got > buf) - from_fstab_line (got, user); -done: - NtClose (fh); - return true; -} - -/* write_cygdrive_info: Store default prefix and flags - to use when creating cygdrives to the special user shared mem - location used to store cygdrive information. */ - -int -mount_info::write_cygdrive_info (const char *cygdrive_prefix, unsigned flags) -{ - /* Verify cygdrive prefix starts with a forward slash and if there's - another character, it's not a slash. */ - if ((cygdrive_prefix == NULL) || (*cygdrive_prefix == 0) || - (!isslash (cygdrive_prefix[0])) || - ((cygdrive_prefix[1] != '\0') && (isslash (cygdrive_prefix[1])))) - { - set_errno (EINVAL); - return -1; - } - /* Don't allow overriding of a system cygdrive prefix. */ - if (cygdrive_flags & MOUNT_SYSTEM) - { - set_errno (EPERM); - return -1; - } - - slashify (cygdrive_prefix, cygdrive, 1); - cygdrive_flags = flags & ~MOUNT_SYSTEM; - cygdrive_len = strlen (cygdrive); - - return 0; -} - -int -mount_info::get_cygdrive_info (char *user, char *system, char *user_flags, - char *system_flags) -{ - if (user) - *user = '\0'; - if (system) - *system = '\0'; - if (user_flags) - *user_flags = '\0'; - if (system_flags) - *system_flags = '\0'; - - char *path = (cygdrive_flags & MOUNT_SYSTEM) ? system : user; - char *flags = (cygdrive_flags & MOUNT_SYSTEM) ? system_flags : user_flags; - - if (path) - { - strcpy (path, cygdrive); - /* Strip trailing slash for backward compatibility. */ - if (cygdrive_len > 2) - path[cygdrive_len - 1] = '\0'; - } - if (flags) - strcpy (flags, (cygdrive_flags & MOUNT_BINARY) ? "binmode" : "textmode"); - return 0; -} - -static mount_item *mounts_for_sort; - -/* sort_by_posix_name: qsort callback to sort the mount entries. Sort - user mounts ahead of system mounts to the same POSIX path. */ -/* FIXME: should the user should be able to choose whether to - prefer user or system mounts??? */ -static int -sort_by_posix_name (const void *a, const void *b) -{ - mount_item *ap = mounts_for_sort + (*((int*) a)); - mount_item *bp = mounts_for_sort + (*((int*) b)); - - /* Base weighting on longest posix path first so that the most - obvious path will be chosen. */ - size_t alen = strlen (ap->posix_path); - size_t blen = strlen (bp->posix_path); - - int res = blen - alen; - - if (res) - return res; /* Path lengths differed */ - - /* The two paths were the same length, so just determine normal - lexical sorted order. */ - res = strcmp (ap->posix_path, bp->posix_path); - - if (res == 0) - { - /* need to select between user and system mount to same POSIX path */ - if (!(bp->flags & MOUNT_SYSTEM)) /* user mount */ - return 1; - else - return -1; - } - - return res; -} - -/* sort_by_native_name: qsort callback to sort the mount entries. Sort - user mounts ahead of system mounts to the same POSIX path. */ -/* FIXME: should the user should be able to choose whether to - prefer user or system mounts??? */ -static int -sort_by_native_name (const void *a, const void *b) -{ - mount_item *ap = mounts_for_sort + (*((int*) a)); - mount_item *bp = mounts_for_sort + (*((int*) b)); - - /* Base weighting on longest win32 path first so that the most - obvious path will be chosen. */ - size_t alen = strlen (ap->native_path); - size_t blen = strlen (bp->native_path); - - int res = blen - alen; - - if (res) - return res; /* Path lengths differed */ - - /* The two paths were the same length, so just determine normal - lexical sorted order. */ - res = strcmp (ap->native_path, bp->native_path); - - if (res == 0) - { - /* need to select between user and system mount to same POSIX path */ - if (!(bp->flags & MOUNT_SYSTEM)) /* user mount */ - return 1; - else - return -1; - } - - return res; -} - -void -mount_info::sort () -{ - for (int i = 0; i < nmounts; i++) - native_sorted[i] = posix_sorted[i] = i; - /* Sort them into reverse length order, otherwise we won't - be able to look for /foo in /. */ - mounts_for_sort = mount; /* ouch. */ - qsort (posix_sorted, nmounts, sizeof (posix_sorted[0]), sort_by_posix_name); - qsort (native_sorted, nmounts, sizeof (native_sorted[0]), sort_by_native_name); -} - -/* Add an entry to the mount table. - Returns 0 on success, -1 on failure and errno is set. - - This is where all argument validation is done. It may not make sense to - do this when called internally, but it's cleaner to keep it all here. */ - -int -mount_info::add_item (const char *native, const char *posix, - unsigned mountflags) -{ - tmp_pathbuf tp; - char *nativetmp = tp.c_get (); - /* FIXME: The POSIX path is stored as value name right now, which is - restricted to 256 bytes. */ - char posixtmp[CYG_MAX_PATH]; - char *nativetail, *posixtail, error[] = "error"; - int nativeerr, posixerr; - - /* Something's wrong if either path is NULL or empty, or if it's - not a UNC or absolute path. */ - - if (native == NULL || !isabspath (native) || - !(is_native_path (native) || is_unc_share (native) || isdrive (native))) - nativeerr = EINVAL; - else - nativeerr = normalize_win32_path (native, nativetmp, nativetail); - - if (posix == NULL || !isabspath (posix) || - is_unc_share (posix) || isdrive (posix)) - posixerr = EINVAL; - else - posixerr = normalize_posix_path (posix, posixtmp, posixtail); - - debug_printf ("%s[%s], %s[%s], %p", - native, nativeerr ? error : nativetmp, - posix, posixerr ? error : posixtmp, mountflags); - - if (nativeerr || posixerr) - { - set_errno (nativeerr?:posixerr); - return -1; - } - - /* Make sure both paths do not end in /. */ - if (nativetail > nativetmp + 1 && nativetail[-1] == '\\') - nativetail[-1] = '\0'; - if (posixtail > posixtmp + 1 && posixtail[-1] == '/') - posixtail[-1] = '\0'; - - /* Write over an existing mount item with the same POSIX path if - it exists and is from the same registry area. */ - int i; - for (i = 0; i < nmounts; i++) - { - if (!strcmp (mount[i].posix_path, posixtmp)) - { - /* Don't allow overriding of a system mount with a user mount. */ - if ((mount[i].flags & MOUNT_SYSTEM) && !(mountflags & MOUNT_SYSTEM)) - { - set_errno (EPERM); - return -1; - } - if ((mount[i].flags & MOUNT_SYSTEM) != (mountflags & MOUNT_SYSTEM)) - continue; - else if (!(mount[i].flags & MOUNT_IMMUTABLE)) - break; - else if (mountflags & MOUNT_OVERRIDE) - { - mountflags |= MOUNT_IMMUTABLE; - break; - } - else - { - set_errno (EPERM); - return -1; - } - } - } - - if (i == nmounts && nmounts == MAX_MOUNTS) - { - set_errno (EMFILE); - return -1; - } - - if (i == nmounts) - nmounts++; - - if (strcmp (posixtmp, "/usr/bin") == 0) - got_usr_bin = true; - - if (strcmp (posixtmp, "/usr/lib") == 0) - got_usr_lib = true; - - if (posixtmp[0] == '/' && posixtmp[1] == '\0' && !(mountflags & MOUNT_CYGDRIVE)) - root_idx = i; - - mount[i].init (nativetmp, posixtmp, mountflags); - sort (); - - return 0; -} - -/* Delete a mount table entry where path is either a Win32 or POSIX - path. Since the mount table is really just a table of aliases, - deleting / is ok (although running without a slash mount is - strongly discouraged because some programs may run erratically - without one). If MOUNT_SYSTEM is set in flags, remove from system - registry, otherwise remove the user registry mount. -*/ - -int -mount_info::del_item (const char *path, unsigned flags) -{ - tmp_pathbuf tp; - char *pathtmp = tp.c_get (); - int posix_path_p = false; - - /* Something's wrong if path is NULL or empty. */ - if (path == NULL || *path == 0 || !isabspath (path)) - { - set_errno (EINVAL); - return -1; - } - - if (is_unc_share (path) || strpbrk (path, ":\\")) - backslashify (path, pathtmp, 0); - else - { - slashify (path, pathtmp, 0); - posix_path_p = true; - } - nofinalslash (pathtmp, pathtmp); - - for (int i = 0; i < nmounts; i++) - { - int ent = native_sorted[i]; /* in the same order as getmntent() */ - if (((posix_path_p) - ? !strcmp (mount[ent].posix_path, pathtmp) - : strcasematch (mount[ent].native_path, pathtmp))) - { - /* Don't allow removal of a system mount. */ - if (mount[ent].flags & MOUNT_SYSTEM) - { - set_errno (EPERM); - return -1; - } - nmounts--; /* One less mount table entry */ - /* Fill in the hole if not at the end of the table */ - if (ent < nmounts) - memmove (mount + ent, mount + ent + 1, - sizeof (mount[ent]) * (nmounts - ent)); - sort (); /* Resort the table */ - return 0; - } - } - set_errno (EINVAL); - return -1; -} - -/************************* mount_item class ****************************/ - -static mntent * -fillout_mntent (const char *native_path, const char *posix_path, unsigned flags) -{ - struct mntent& ret=_my_tls.locals.mntbuf; - bool append_bs = false; - - /* Remove drivenum from list if we see a x: style path */ - if (strlen (native_path) == 2 && native_path[1] == ':') - { - int drivenum = cyg_tolower (native_path[0]) - 'a'; - if (drivenum >= 0 && drivenum <= 31) - _my_tls.locals.available_drives &= ~(1 << drivenum); - append_bs = true; - } - - /* Pass back pointers to mount_table strings reserved for use by - getmntent rather than pointers to strings in the internal mount - table because the mount table might change, causing weird effects - from the getmntent user's point of view. */ - - ret.mnt_fsname = _my_tls.locals.mnt_fsname; - strcpy (_my_tls.locals.mnt_dir, posix_path); - ret.mnt_dir = _my_tls.locals.mnt_dir; - - /* Try to give a filesystem type that matches what a Linux application might - expect. Naturally, this is a moving target, but we can make some - reasonable guesses for popular types. */ - - fs_info mntinfo; - tmp_pathbuf tp; - UNICODE_STRING unat; - tp.u_get (&unat); - get_nt_native_path (native_path, unat); - if (append_bs) - RtlAppendUnicodeToString (&unat, L"\\"); - mntinfo.update (&unat, NULL); - - /* Order must be identical to mount.h, enum fs_info_type. */ - const char *fs_names[] = { - "none", - "vfat", - "ntfs", - "smbfs", - "nfs", - "netapp", - "iso9660", - "udf", - "csc-cache", - "sunwnfs", - "unixfs", - "mvfs", - "cifs", - "nwfs" - }; - - if (mntinfo.what_fs () > 0 && mntinfo.what_fs () < max_fs_type) - strcpy (_my_tls.locals.mnt_type, fs_names[mntinfo.what_fs ()]); - else - strcpy (_my_tls.locals.mnt_type, mntinfo.fsname ()); - - ret.mnt_type = _my_tls.locals.mnt_type; - - slashify (native_path, _my_tls.locals.mnt_fsname, false); - - /* mnt_opts is a string that details mount params such as - binary or textmode, or exec. We don't print - `silent' here; it's a magic internal thing. */ - - if (!(flags & MOUNT_BINARY)) - strcpy (_my_tls.locals.mnt_opts, (char *) "text"); - else - strcpy (_my_tls.locals.mnt_opts, (char *) "binary"); - - if (flags & MOUNT_CYGWIN_EXEC) - strcat (_my_tls.locals.mnt_opts, (char *) ",cygexec"); - else if (flags & MOUNT_EXEC) - strcat (_my_tls.locals.mnt_opts, (char *) ",exec"); - else if (flags & MOUNT_NOTEXEC) - strcat (_my_tls.locals.mnt_opts, (char *) ",notexec"); - - if (flags & MOUNT_NOACL) - strcat (_my_tls.locals.mnt_opts, (char *) ",noacl"); - - if (flags & MOUNT_NOPOSIX) - strcat (_my_tls.locals.mnt_opts, (char *) ",posix=0"); - - if (!(flags & MOUNT_SYSTEM)) /* user mount */ - strcat (_my_tls.locals.mnt_opts, (char *) ",user"); - - if (flags & MOUNT_CYGDRIVE) /* cygdrive */ - strcat (_my_tls.locals.mnt_opts, (char *) ",noumount"); - - if (flags & (MOUNT_AUTOMATIC | MOUNT_CYGDRIVE)) - strcat (_my_tls.locals.mnt_opts, (char *) ",auto"); - - ret.mnt_opts = _my_tls.locals.mnt_opts; - - ret.mnt_freq = 1; - ret.mnt_passno = 1; - return &ret; -} - -struct mntent * -mount_item::getmntent () -{ - return fillout_mntent (native_path, posix_path, flags); -} - -static struct mntent * -cygdrive_getmntent () -{ - char native_path[4]; - char posix_path[CYG_MAX_PATH]; - DWORD mask = 1, drive = 'a'; - struct mntent *ret = NULL; - - while (_my_tls.locals.available_drives) - { - for (/* nothing */; drive <= 'z'; mask <<= 1, drive++) - if (_my_tls.locals.available_drives & mask) - break; - - __small_sprintf (native_path, "%c:\\", cyg_toupper (drive)); - if (GetFileAttributes (native_path) == INVALID_FILE_ATTRIBUTES) - { - _my_tls.locals.available_drives &= ~mask; - continue; - } - native_path[2] = '\0'; - __small_sprintf (posix_path, "%s%c", mount_table->cygdrive, drive); - ret = fillout_mntent (native_path, posix_path, mount_table->cygdrive_flags); - break; - } - - return ret; -} - -struct mntent * -mount_info::getmntent (int x) -{ - if (x < 0 || x >= nmounts) - return cygdrive_getmntent (); - - return mount[native_sorted[x]].getmntent (); -} - -/* Fill in the fields of a mount table entry. */ - -void -mount_item::init (const char *native, const char *posix, unsigned mountflags) -{ - strcpy ((char *) native_path, native); - strcpy ((char *) posix_path, posix); - - native_pathlen = strlen (native_path); - posix_pathlen = strlen (posix_path); - - flags = mountflags; -} - -/********************** Mount System Calls **************************/ - -/* Mount table system calls. - Note that these are exported to the application. */ - -/* mount: Add a mount to the mount table in memory and to the registry - that will cause paths under win32_path to be translated to paths - under posix_path. */ - -extern "C" int -mount (const char *win32_path, const char *posix_path, unsigned flags) -{ - /* FIXME: Should we disallow setting MOUNT_SYSTEM in flags since it - isn't really supported except from fstab? */ - int res = -1; - - myfault efault; - if (efault.faulted (EFAULT)) - /* errno set */; - else if (!*posix_path) - set_errno (EINVAL); - else if (strpbrk (posix_path, "\\:")) - set_errno (EINVAL); - else if (flags & MOUNT_CYGDRIVE) /* normal mount */ - { - /* When flags include MOUNT_CYGDRIVE, take this to mean that - we actually want to change the cygdrive prefix and flags - without actually mounting anything. */ - res = mount_table->write_cygdrive_info (posix_path, flags); - win32_path = NULL; - } - else if (!*win32_path) - set_errno (EINVAL); - else - res = mount_table->add_item (win32_path, posix_path, flags); - - syscall_printf ("%d = mount (%s, %s, %p)", res, win32_path, posix_path, flags); - return res; -} - -/* umount: The standard umount call only has a path parameter. Since - it is not possible for this call to specify whether to remove the - mount from the user or global mount registry table, assume the user - table. */ - -extern "C" int -umount (const char *path) -{ - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - if (!*path) - { - set_errno (EINVAL); - return -1; - } - return cygwin_umount (path, 0); -} - -/* cygwin_umount: This is like umount but takes an additional flags - parameter that specifies whether to umount from the user or system-wide - registry area. */ - -extern "C" int -cygwin_umount (const char *path, unsigned flags) -{ - int res = -1; - - if (!(flags & MOUNT_CYGDRIVE)) - res = mount_table->del_item (path, flags & ~MOUNT_SYSTEM); - - syscall_printf ("%d = cygwin_umount (%s, %d)", res, path, flags); - return res; -} - -bool -is_floppy (const char *dos) -{ - char dev[256]; - if (!QueryDosDevice (dos, dev, 256)) - return false; - return ascii_strncasematch (dev, "\\Device\\Floppy", 14); -} - -extern "C" FILE * -setmntent (const char *filep, const char *) -{ - _my_tls.locals.iteration = 0; - _my_tls.locals.available_drives = GetLogicalDrives (); - /* Filter floppy drives on A: and B: */ - if ((_my_tls.locals.available_drives & 1) && is_floppy ("A:")) - _my_tls.locals.available_drives &= ~1; - if ((_my_tls.locals.available_drives & 2) && is_floppy ("B:")) - _my_tls.locals.available_drives &= ~2; - return (FILE *) filep; -} - -extern "C" struct mntent * -getmntent (FILE *) -{ - return mount_table->getmntent (_my_tls.locals.iteration++); -} - -extern "C" int -endmntent (FILE *) -{ - return 1; -} diff --git a/winsup/cygwin/mount.h b/winsup/cygwin/mount.h deleted file mode 100644 index 95a158ad7..000000000 --- a/winsup/cygwin/mount.h +++ /dev/null @@ -1,189 +0,0 @@ -/* mount.h: mount definitions. - - Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _MOUNT_H -#define _MOUNT_H - -enum fs_info_type -{ - none = 0, - fat, - ntfs, - samba, - nfs, - netapp, - cdrom, - udf, - csc_cache, - sunwnfs, - unixfs, - mvfs, - cifs, - nwfs, - /* Always last. */ - max_fs_type -}; - -#define IMPLEMENT_FS_FLAG(func, flag) \ - bool func (bool val) { if (val) status.fs_type = flag; return val; } \ - bool func () const { return status.fs_type == flag; } - -class fs_info -{ - struct status_flags - { - ULONG flags; /* Volume flags */ - ULONG samba_version; /* Samba version if available */ - ULONG name_len; /* MaximumComponentNameLength */ - fs_info_type fs_type; /* Filesystem type */ - unsigned is_remote_drive : 1; - unsigned has_acls : 1; - unsigned hasgood_inode : 1; - unsigned caseinsensitive : 1; - unsigned has_buggy_open : 1; - unsigned has_buggy_fileid_dirinfo : 1; - unsigned has_buggy_basic_info : 1; - } status; - ULONG sernum; /* Volume Serial Number */ - char fsn[80]; /* Windows filesystem name */ - unsigned long got_fs () const { return status.fs_type != none; } - - public: - void clear () - { - memset (&status, 0 , sizeof status); - sernum = 0UL; - fsn[0] = '\0'; - } - fs_info () { clear (); } - - IMPLEMENT_STATUS_FLAG (ULONG, flags) - IMPLEMENT_STATUS_FLAG (ULONG, samba_version) - IMPLEMENT_STATUS_FLAG (ULONG, name_len) - IMPLEMENT_STATUS_FLAG (bool, is_remote_drive) - IMPLEMENT_STATUS_FLAG (bool, has_acls) - IMPLEMENT_STATUS_FLAG (bool, hasgood_inode) - IMPLEMENT_STATUS_FLAG (bool, caseinsensitive) - IMPLEMENT_STATUS_FLAG (bool, has_buggy_open) - IMPLEMENT_STATUS_FLAG (bool, has_buggy_fileid_dirinfo) - IMPLEMENT_STATUS_FLAG (bool, has_buggy_basic_info) - IMPLEMENT_FS_FLAG (is_fat, fat) - IMPLEMENT_FS_FLAG (is_ntfs, ntfs) - IMPLEMENT_FS_FLAG (is_samba, samba) - IMPLEMENT_FS_FLAG (is_nfs, nfs) - IMPLEMENT_FS_FLAG (is_netapp, netapp) - IMPLEMENT_FS_FLAG (is_cdrom, cdrom) - IMPLEMENT_FS_FLAG (is_udf, udf) - IMPLEMENT_FS_FLAG (is_csc_cache, csc_cache) - IMPLEMENT_FS_FLAG (is_sunwnfs, sunwnfs) - IMPLEMENT_FS_FLAG (is_unixfs, unixfs) - IMPLEMENT_FS_FLAG (is_mvfs, mvfs) - IMPLEMENT_FS_FLAG (is_cifs, cifs) - IMPLEMENT_FS_FLAG (is_nwfs, nwfs) - fs_info_type what_fs () const { return status.fs_type; } - - ULONG serial_number () const { return sernum; } - - const char *fsname () const { return fsn[0] ? fsn : "unknown"; } - - bool update (PUNICODE_STRING, HANDLE) __attribute__ ((regparm (3))); -}; - -/* Mount table entry */ - -class mount_item -{ - public: - /* FIXME: Nasty static allocation. Need to have a heap in the shared - area [with the user being able to configure at runtime the max size]. */ - /* Win32-style mounted partition source ("C:\foo\bar"). - native_path[0] == 0 for unused entries. */ - char native_path[CYG_MAX_PATH]; - int native_pathlen; - - /* POSIX-style mount point ("/foo/bar") */ - char posix_path[CYG_MAX_PATH]; - int posix_pathlen; - - unsigned flags; - - void init (const char *dev, const char *path, unsigned flags); - - struct mntent *getmntent (); - int build_win32 (char *, const char *, unsigned *, unsigned); -}; - -/* Warning: Decreasing this value will cause cygwin.dll to ignore existing - higher numbered registry entries. Don't change this number willy-nilly. - What we need is to have a more dynamic allocation scheme, but the current - scheme should be satisfactory for a long while yet. */ -#define MAX_MOUNTS 30 - -class reg_key; -struct device; - -/* NOTE: Do not make gratuitous changes to the names or organization of the - below class. The layout is checksummed to determine compatibility between - different cygwin versions. */ -class mount_info -{ - public: - DWORD sys_mount_table_counter; - int nmounts; - mount_item mount[MAX_MOUNTS]; - - static bool got_usr_bin; - static bool got_usr_lib; - static int root_idx; - - /* cygdrive_prefix is used as the root of the path automatically - prepended to a path when the path has no associated mount. - cygdrive_flags are the default flags for the cygdrives. */ - char cygdrive[CYG_MAX_PATH]; - size_t cygdrive_len; - unsigned cygdrive_flags; - private: - int posix_sorted[MAX_MOUNTS]; - int native_sorted[MAX_MOUNTS]; - - public: - void init (); - int add_item (const char *dev, const char *path, unsigned flags); - int del_item (const char *path, unsigned flags); - - unsigned set_flags_from_win32_path (const char *path); - int conv_to_win32_path (const char *src_path, char *dst, device&, - unsigned *flags = NULL); - int conv_to_posix_path (PWCHAR src_path, char *posix_path, - int keep_rel_p); - int conv_to_posix_path (const char *src_path, char *posix_path, - int keep_rel_p); - struct mntent *getmntent (int x); - - int write_cygdrive_info (const char *cygdrive_prefix, unsigned flags); - int get_cygdrive_info (char *user, char *system, char* user_flags, - char* system_flags); - void cygdrive_posix_path (const char *src, char *dst, int trailing_slash_p); - int get_mounts_here (const char *parent_dir, int, - PUNICODE_STRING mount_points, - PUNICODE_STRING cygd); - - private: - void sort (); - void mount_slash (); - void create_root_entry (const PWCHAR root); - - bool from_fstab_line (char *line, bool user); - bool from_fstab (bool user, WCHAR [], PWCHAR); - - int cygdrive_win32_path (const char *src, char *dst, int& unit); -}; -#endif diff --git a/winsup/cygwin/msg.cc b/winsup/cygwin/msg.cc deleted file mode 100644 index 2f44c86c7..000000000 --- a/winsup/cygwin/msg.cc +++ /dev/null @@ -1,183 +0,0 @@ -/* msg.cc: XSI IPC interface for Cygwin. - - Copyright 2003, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include - -#include "sigproc.h" -#include "cygtls.h" - -#include "cygserver_msg.h" - -/* - * client_request_msg Constructors - */ - -client_request_msg::client_request_msg (int msqid, - int cmd, - struct msqid_ds *buf) - : client_request (CYGSERVER_REQUEST_MSG, &_parameters, sizeof (_parameters)) -{ - _parameters.in.msgop = MSGOP_msgctl; - ipc_set_proc_info (_parameters.in.ipcblk); - - _parameters.in.ctlargs.msqid = msqid; - _parameters.in.ctlargs.cmd = cmd; - _parameters.in.ctlargs.buf = buf; - - msglen (sizeof (_parameters.in)); -} - -client_request_msg::client_request_msg (key_t key, - int msgflg) - : client_request (CYGSERVER_REQUEST_MSG, &_parameters, sizeof (_parameters)) -{ - _parameters.in.msgop = MSGOP_msgget; - ipc_set_proc_info (_parameters.in.ipcblk); - - _parameters.in.getargs.key = key; - _parameters.in.getargs.msgflg = msgflg; - - msglen (sizeof (_parameters.in)); -} - -client_request_msg::client_request_msg (int msqid, - void *msgp, - size_t msgsz, - long msgtyp, - int msgflg) - : client_request (CYGSERVER_REQUEST_MSG, &_parameters, sizeof (_parameters)) -{ - _parameters.in.msgop = MSGOP_msgrcv; - ipc_set_proc_info (_parameters.in.ipcblk); - - _parameters.in.rcvargs.msqid = msqid; - _parameters.in.rcvargs.msgp = msgp; - _parameters.in.rcvargs.msgsz = msgsz; - _parameters.in.rcvargs.msgtyp = msgtyp; - _parameters.in.rcvargs.msgflg = msgflg; - - msglen (sizeof (_parameters.in)); -} - -client_request_msg::client_request_msg (int msqid, - const void *msgp, - size_t msgsz, - int msgflg) - : client_request (CYGSERVER_REQUEST_MSG, &_parameters, sizeof (_parameters)) -{ - _parameters.in.msgop = MSGOP_msgsnd; - ipc_set_proc_info (_parameters.in.ipcblk); - - _parameters.in.sndargs.msqid = msqid; - _parameters.in.sndargs.msgp = msgp; - _parameters.in.sndargs.msgsz = msgsz; - _parameters.in.sndargs.msgflg = msgflg; - - msglen (sizeof (_parameters.in)); -} - -/* - * XSI message queue API. These are exported by the DLL. - */ - -extern "C" int -msgctl (int msqid, int cmd, struct msqid_ds *buf) -{ - syscall_printf ("msgctl (msqid = %d, cmd = 0x%x, buf = %p)", - msqid, cmd, buf); - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - switch (cmd) - { - case IPC_STAT: - break; - case IPC_SET: - break; - case IPC_RMID: - break; - case IPC_INFO: - break; - case MSG_INFO: - break; - default: - syscall_printf ("-1 [%d] = msgctl ()", EINVAL); - set_errno (EINVAL); - return -1; - } - client_request_msg request (msqid, cmd, buf); - if (request.make_request () == -1 || request.retval () == -1) - { - syscall_printf ("-1 [%d] = msgctl ()", request.error_code ()); - set_errno (request.error_code ()); - if (request.error_code () == ENOSYS) - raise (SIGSYS); - return -1; - } - return request.retval (); -} - -extern "C" int -msgget (key_t key, int msgflg) -{ - syscall_printf ("msgget (key = %U, msgflg = 0x%x)", key, msgflg); - client_request_msg request (key, msgflg); - if (request.make_request () == -1 || request.retval () == -1) - { - syscall_printf ("-1 [%d] = msgget ()", request.error_code ()); - set_errno (request.error_code ()); - if (request.error_code () == ENOSYS) - raise (SIGSYS); - return -1; - } - return request.retval (); -} - -extern "C" ssize_t -msgrcv (int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) -{ - syscall_printf ("msgrcv (msqid = %d, msgp = %p, msgsz = %d, " - "msgtyp = %d, msgflg = 0x%x)", - msqid, msgp, msgsz, msgtyp, msgflg); - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - client_request_msg request (msqid, msgp, msgsz, msgtyp, msgflg); - if (request.make_request () == -1 || request.rcvval () == -1) - { - syscall_printf ("-1 [%d] = msgrcv ()", request.error_code ()); - set_errno (request.error_code ()); - if (request.error_code () == ENOSYS) - raise (SIGSYS); - return -1; - } - return request.rcvval (); -} - -extern "C" int -msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg) -{ - syscall_printf ("msgsnd (msqid = %d, msgp = %p, msgsz = %d, msgflg = 0x%x)", - msqid, msgp, msgsz, msgflg); - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - client_request_msg request (msqid, msgp, msgsz, msgflg); - if (request.make_request () == -1 || request.retval () == -1) - { - syscall_printf ("-1 [%d] = msgsnd ()", request.error_code ()); - set_errno (request.error_code ()); - if (request.error_code () == ENOSYS) - raise (SIGSYS); - return -1; - } - return request.retval (); -} diff --git a/winsup/cygwin/mtinfo.h b/winsup/cygwin/mtinfo.h deleted file mode 100644 index cccaed8b7..000000000 --- a/winsup/cygwin/mtinfo.h +++ /dev/null @@ -1,137 +0,0 @@ -/* mtinfo.h: Defininitions for the Cygwin tape driver class. - - Copyright 2004, 2005, 2006, 2008 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* Maximum number of supported partitions per drive. */ -#define MAX_PARTITION_NUM 64 -/* Maximum number of supported drives. */ -#define MAX_DRIVE_NUM 8 - -/* Values for bookkeeping of the tape position relative to filemarks - and eod/eom. */ -enum eom_val -{ - no_eof, - eof_hit, - eof, - eod_hit, - eod, - eom_hit, - eom -}; - -enum dirty_state -{ - clean, - has_read, - has_written, - async_write_pending -}; - -enum lock_state -{ - unlocked, - lock_error, - auto_locked, - locked -}; - -/* Partition specific information */ -class mtinfo_part -{ -public: - long block; /* logical block no */ - long file; /* current file no */ - long fblock; /* relative block no */ - bool smark; /* At setmark? */ - eom_val emark; /* "end-of"-mark */ - - void initialize (long nblock = -1); -}; - -class mtinfo_drive -{ - int drive; - int lasterr; - long partition; - long block; - dirty_state dirty; - lock_state lock; - TAPE_GET_DRIVE_PARAMETERS _dp; - TAPE_GET_MEDIA_PARAMETERS _mp; - OVERLAPPED ov; - struct status_flags - { - unsigned buffer_writes : 1; - unsigned async_writes : 1; - unsigned two_fm : 1; - unsigned fast_eom : 1; - unsigned auto_lock : 1; - unsigned sysv : 1; - unsigned nowait : 1; - } status; - mtinfo_part _part[MAX_PARTITION_NUM]; - - inline int error (const char *str) - { - if (lasterr) - debug_printf ("%s: Win32 error %d", str, lasterr); - return lasterr; - } - inline bool get_feature (DWORD parm) - { - return ((parm & TAPE_DRIVE_HIGH_FEATURES) - ? ((_dp.FeaturesHigh & parm) != 0) - : ((_dp.FeaturesLow & parm) != 0)); - } - int get_pos (HANDLE mt, long *ppartition = NULL, long *pblock = NULL); - int _set_pos (HANDLE mt, int mode, long count, int partition, BOOL dont_wait); - int create_partitions (HANDLE mt, long count); - int set_partition (HANDLE mt, long count); - int write_marks (HANDLE mt, int marktype, DWORD count); - int erase (HANDLE mt, int mode); - int prepare (HANDLE mt, int action, bool is_auto = false); - int set_compression (HANDLE mt, long count); - int set_blocksize (HANDLE mt, long count); - int get_status (HANDLE mt, struct mtget *get); - int set_options (HANDLE mt, long options); - int async_wait (HANDLE mt, DWORD *bytes_written); - -public: - void initialize (int num, bool first_time); - int get_dp (HANDLE mt); - int get_mp (HANDLE mt); - int open (HANDLE mt); - int close (HANDLE mt, bool rewind); - int read (HANDLE mt, HANDLE mt_evt, void *ptr, size_t &ulen); - int write (HANDLE mt, HANDLE mt_evt, const void *ptr, size_t &len); - int ioctl (HANDLE mt, unsigned int cmd, void *buf); - int set_pos (HANDLE mt, int mode, long count, bool sfm_func); - - IMPLEMENT_STATUS_FLAG (bool, buffer_writes) - IMPLEMENT_STATUS_FLAG (bool, async_writes) - IMPLEMENT_STATUS_FLAG (bool, two_fm) - IMPLEMENT_STATUS_FLAG (bool, fast_eom) - IMPLEMENT_STATUS_FLAG (bool, auto_lock) - IMPLEMENT_STATUS_FLAG (bool, sysv) - IMPLEMENT_STATUS_FLAG (bool, nowait) - - PTAPE_GET_DRIVE_PARAMETERS dp () { return &_dp; } - PTAPE_GET_MEDIA_PARAMETERS mp () { return &_mp; } - mtinfo_part *part (int num) { return &_part[num]; } -}; - -class mtinfo -{ - mtinfo_drive _drive[MAX_DRIVE_NUM]; - -public: - void initialize (); - mtinfo_drive *drive (int num) { return &_drive[num]; } -}; diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc deleted file mode 100644 index ac83d4e53..000000000 --- a/winsup/cygwin/net.cc +++ /dev/null @@ -1,4713 +0,0 @@ -/* net.cc: network-related routines. - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* #define DEBUG_NEST_ON 1 */ - -#define __INSIDE_CYGWIN_NET__ - -#include "winsup.h" - -/* unfortunately defined in windows header file but used in - cygwin header files too */ -#undef NOERROR -#undef DELETE - -#include "miscfuncs.h" -#include -#include - -#include -#define gethostname cygwin_gethostname -#include -#undef gethostname -#include -#include -#define USE_SYS_TYPES_FD_SET -#include -#include -#include -#include "cygerrno.h" -#include "security.h" -#include "cygwin/version.h" -#include "shared_info.h" -#include "perprocess.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "sigproc.h" -#include "registry.h" -#include "cygtls.h" -#include "cygwin/in6.h" -#include "ifaddrs.h" -#include "tls_pbuf.h" -#define _CYGWIN_IN_H -#include - -extern "C" -{ - int h_errno; - - int __stdcall rcmd (char **ahost, unsigned short inport, char *locuser, - char *remuser, char *cmd, SOCKET * fd2p); - int sscanf (const char *, const char *, ...); - int cygwin_inet_aton(const char *, struct in_addr *); - const char *cygwin_inet_ntop (int, const void *, char *, socklen_t); - int dn_length1(const unsigned char *, const unsigned char *, - const unsigned char *); -} /* End of "C" section */ - -const struct in6_addr in6addr_any = {{IN6ADDR_ANY_INIT}}; -const struct in6_addr in6addr_loopback = {{IN6ADDR_LOOPBACK_INIT}}; - -static fhandler_socket * -get (const int fd) -{ - cygheap_fdget cfd (fd); - - if (cfd < 0) - return 0; - - fhandler_socket *const fh = cfd->is_socket (); - - if (!fh) - set_errno (ENOTSOCK); - - return fh; -} - -/* exported as inet_ntoa: BSD 4.3 */ -extern "C" char * -cygwin_inet_ntoa (struct in_addr in) -{ - char buf[20]; - const char *res = cygwin_inet_ntop (AF_INET, &in, buf, sizeof buf); - - if (_my_tls.locals.ntoa_buf) - { - free (_my_tls.locals.ntoa_buf); - _my_tls.locals.ntoa_buf = NULL; - } - if (res) - _my_tls.locals.ntoa_buf = strdup (res); - return _my_tls.locals.ntoa_buf; -} - -/* inet_netof is in the standard BSD sockets library. It is useless - for modern networks, since it assumes network values which are no - longer meaningful, but some existing code calls it. */ - -extern "C" unsigned long -inet_netof (struct in_addr in) -{ - unsigned long i, res; - - i = ntohl (in.s_addr); - if (IN_CLASSA (i)) - res = (i & IN_CLASSA_NET) >> IN_CLASSA_NSHIFT; - else if (IN_CLASSB (i)) - res = (i & IN_CLASSB_NET) >> IN_CLASSB_NSHIFT; - else - res = (i & IN_CLASSC_NET) >> IN_CLASSC_NSHIFT; - - return res; -} - -/* inet_makeaddr is in the standard BSD sockets library. It is - useless for modern networks, since it assumes network values which - are no longer meaningful, but some existing code calls it. */ - -extern "C" struct in_addr -inet_makeaddr (int net, int lna) -{ - unsigned long i; - struct in_addr in; - - if (net < IN_CLASSA_MAX) - i = (net << IN_CLASSA_NSHIFT) | (lna & IN_CLASSA_HOST); - else if (net < IN_CLASSB_MAX) - i = (net << IN_CLASSB_NSHIFT) | (lna & IN_CLASSB_HOST); - else if (net < 0x1000000) - i = (net << IN_CLASSC_NSHIFT) | (lna & IN_CLASSC_HOST); - else - i = net | lna; - - in.s_addr = htonl (i); - - - return in; -} - -struct tl -{ - int w; - const char *s; - int e; -}; - -static NO_COPY struct tl errmap[] = { - {WSAEINTR, "WSAEINTR", EINTR}, - {WSAEWOULDBLOCK, "WSAEWOULDBLOCK", EWOULDBLOCK}, - {WSAEINPROGRESS, "WSAEINPROGRESS", EINPROGRESS}, - {WSAEALREADY, "WSAEALREADY", EALREADY}, - {WSAENOTSOCK, "WSAENOTSOCK", ENOTSOCK}, - {WSAEDESTADDRREQ, "WSAEDESTADDRREQ", EDESTADDRREQ}, - {WSAEMSGSIZE, "WSAEMSGSIZE", EMSGSIZE}, - {WSAEPROTOTYPE, "WSAEPROTOTYPE", EPROTOTYPE}, - {WSAENOPROTOOPT, "WSAENOPROTOOPT", ENOPROTOOPT}, - {WSAEPROTONOSUPPORT, "WSAEPROTONOSUPPORT", EPROTONOSUPPORT}, - {WSAESOCKTNOSUPPORT, "WSAESOCKTNOSUPPORT", ESOCKTNOSUPPORT}, - {WSAEOPNOTSUPP, "WSAEOPNOTSUPP", EOPNOTSUPP}, - {WSAEPFNOSUPPORT, "WSAEPFNOSUPPORT", EPFNOSUPPORT}, - {WSAEAFNOSUPPORT, "WSAEAFNOSUPPORT", EAFNOSUPPORT}, - {WSAEADDRINUSE, "WSAEADDRINUSE", EADDRINUSE}, - {WSAEADDRNOTAVAIL, "WSAEADDRNOTAVAIL", EADDRNOTAVAIL}, - {WSAENETDOWN, "WSAENETDOWN", ENETDOWN}, - {WSAENETUNREACH, "WSAENETUNREACH", ENETUNREACH}, - {WSAENETRESET, "WSAENETRESET", ENETRESET}, - {WSAECONNABORTED, "WSAECONNABORTED", ECONNABORTED}, - {WSAECONNRESET, "WSAECONNRESET", ECONNRESET}, - {WSAENOBUFS, "WSAENOBUFS", ENOBUFS}, - {WSAEISCONN, "WSAEISCONN", EISCONN}, - {WSAENOTCONN, "WSAENOTCONN", ENOTCONN}, - {WSAESHUTDOWN, "WSAESHUTDOWN", ESHUTDOWN}, - {WSAETOOMANYREFS, "WSAETOOMANYREFS", ETOOMANYREFS}, - {WSAETIMEDOUT, "WSAETIMEDOUT", ETIMEDOUT}, - {WSAECONNREFUSED, "WSAECONNREFUSED", ECONNREFUSED}, - {WSAELOOP, "WSAELOOP", ELOOP}, - {WSAENAMETOOLONG, "WSAENAMETOOLONG", ENAMETOOLONG}, - {WSAEHOSTDOWN, "WSAEHOSTDOWN", EHOSTDOWN}, - {WSAEHOSTUNREACH, "WSAEHOSTUNREACH", EHOSTUNREACH}, - {WSAENOTEMPTY, "WSAENOTEMPTY", ENOTEMPTY}, - {WSAEPROCLIM, "WSAEPROCLIM", EPROCLIM}, - {WSAEUSERS, "WSAEUSERS", EUSERS}, - {WSAEDQUOT, "WSAEDQUOT", EDQUOT}, - {WSAESTALE, "WSAESTALE", ESTALE}, - {WSAEREMOTE, "WSAEREMOTE", EREMOTE}, - {WSAEINVAL, "WSAEINVAL", EINVAL}, - {WSAEFAULT, "WSAEFAULT", EFAULT}, - {0, "NOERROR", 0}, - {0, NULL, 0} -}; - -static int -find_winsock_errno (int why) -{ - for (int i = 0; errmap[i].s != NULL; ++i) - if (why == errmap[i].w) - return errmap[i].e; - - return EPERM; -} - -void -__set_winsock_errno (const char *fn, int ln) -{ - DWORD werr = WSAGetLastError (); - int err = find_winsock_errno (werr); - - set_errno (err); - syscall_printf ("%s:%d - winsock error %d -> errno %d", fn, ln, werr, err); -} - -/* - * Since the member `s' isn't used for debug output we can use it - * for the error text returned by herror and hstrerror. - */ -static NO_COPY struct tl host_errmap[] = { - {WSAHOST_NOT_FOUND, "Unknown host", HOST_NOT_FOUND}, - {WSATRY_AGAIN, "Host name lookup failure", TRY_AGAIN}, - {WSANO_RECOVERY, "Unknown server error", NO_RECOVERY}, - {WSANO_DATA, "No address associated with name", NO_DATA}, - {0, NULL, 0} -}; - -static void -set_host_errno () -{ - int i; - - int why = WSAGetLastError (); - - for (i = 0; host_errmap[i].w != 0; ++i) - if (why == host_errmap[i].w) - break; - - if (host_errmap[i].w != 0) - h_errno = host_errmap[i].e; - else - h_errno = NETDB_INTERNAL; -} - -inline int -DWORD_round (int n) -{ - return sizeof (DWORD) * (((n + sizeof (DWORD) - 1)) / sizeof (DWORD)); -} - -inline int -strlen_round (const char *s) -{ - if (!s) - return 0; - return DWORD_round (strlen (s) + 1); -} - -#pragma pack(push,2) -struct pservent -{ - char *s_name; - char **s_aliases; - short s_port; - char *s_proto; -}; -#pragma pack(pop) - -static const char *entnames[] = {"host", "proto", "serv"}; - -static unionent * -realloc_ent (unionent *&dst, int sz) -{ - /* Allocate the storage needed. Allocate a rounded size to attempt to force - reuse of this buffer so that a poorly-written caller will not be using - a freed buffer. */ - unsigned rsz = 256 * ((sz + 255) / 256); - unionent * ptr; - if ((ptr = (unionent *) realloc (dst, rsz))) - dst = ptr; - return ptr; -} - -static inline hostent * -realloc_ent (int sz, hostent *) -{ - return (hostent *) realloc_ent (_my_tls.locals.hostent_buf, sz); -} - -/* Generic "dup a {host,proto,serv}ent structure" function. - This is complicated because we need to be able to free the - structure at any point and we can't rely on the pointer contents - being untouched by callers. So, we allocate a chunk of memory - large enough to hold the structure and all of the stuff it points - to then we copy the source into this new block of memory. - The 'unionent' struct is a union of all of the currently used - *ent structure. */ - -#ifdef DEBUGGING -static void * -#else -static inline void * -#endif -dup_ent (unionent *&dst, unionent *src, unionent::struct_type type) -{ - if (dst) - debug_printf ("old %sent structure \"%s\" %p\n", entnames[type], - dst->name, dst); - - if (!src) - { - set_winsock_errno (); - return NULL; - } - - debug_printf ("duping %sent \"%s\", %p", entnames[type], src->name, src); - - /* Find the size of the raw structure minus any character strings, etc. */ - int sz, struct_sz; - switch (type) - { - case unionent::t_protoent: - struct_sz = sizeof (protoent); - break; - case unionent::t_servent: - struct_sz = sizeof (servent); - break; - case unionent::t_hostent: - struct_sz = sizeof (hostent); - break; - default: - api_fatal ("called with invalid value %d", type); - break; - } - - /* Every *ent begins with a name. Calculate its length. */ - int namelen = strlen_round (src->name); - sz = struct_sz + namelen; - - char **av; - /* The next field in every *ent is an argv list of "something". - Calculate the number of components and how much space the - character strings will take. */ - int list_len = 0; - for (av = src->list; av && *av; av++) - { - list_len++; - sz += sizeof (char **) + strlen_round (*av); - } - - /* NULL terminate if there actually was a list */ - if (av) - { - sz += sizeof (char **); - list_len++; - } - - /* Do servent/hostent specific processing */ - int protolen = 0; - int addr_list_len = 0; - if (type == unionent::t_servent) - { - if (src->s_proto) - sz += (protolen = strlen_round (src->s_proto)); - } - else if (type == unionent::t_hostent) - { - /* Calculate the length and storage used for h_addr_list */ - for (av = src->h_addr_list; av && *av; av++) - { - addr_list_len++; - sz += sizeof (char **) + DWORD_round (src->h_len); - } - if (av) - { - sz += sizeof (char **); - addr_list_len++; - } - } - - /* Allocate the storage needed. */ - if (realloc_ent (dst, sz)) - { - memset (dst, 0, sz); - /* This field is common to all *ent structures but named differently - in each, of course. */ - dst->port_proto_addrtype = src->port_proto_addrtype; - - char *dp = ((char *) dst) + struct_sz; - if (namelen) - { - /* Copy the name field to dst, using space just beyond the end of - the dst structure. */ - strcpy (dst->name = dp, src->name); - dp += namelen; - } - - /* Copy the 'list' type to dst, using space beyond end of structure - + storage for name. */ - if (src->list) - { - char **dav = dst->list = (char **) dp; - dp += sizeof (char **) * list_len; - for (av = src->list; av && *av; av++) - { - int len = strlen (*av) + 1; - memcpy (*dav++ = dp, *av, len); - dp += DWORD_round (len); - } - } - - /* Do servent/protoent/hostent specific processing. */ - if (type == unionent::t_protoent) - debug_printf ("protoent %s %x %x", dst->name, dst->list, dst->port_proto_addrtype); - else if (type == unionent::t_servent) - { - if (src->s_proto) - { - strcpy (dst->s_proto = dp, src->s_proto); - dp += protolen; - } - } - else if (type == unionent::t_hostent) - { - /* Transfer h_len and duplicate contents of h_addr_list, using - memory after 'list' allocation. */ - dst->h_len = src->h_len; - char **dav = dst->h_addr_list = (char **) dp; - dp += sizeof (char **) * addr_list_len; - for (av = src->h_addr_list; av && *av; av++) - { - memcpy (*dav++ = dp, *av, src->h_len); - dp += DWORD_round (src->h_len); - } - } - /* Sanity check that we did our bookkeeping correctly. */ - assert ((dp - (char *) dst) == sz); - } - debug_printf ("duped %sent \"%s\", %p", entnames[type], dst ? dst->name : "", dst); - return dst; -} - -static inline hostent * -dup_ent (hostent *src) -{ - return (hostent *) dup_ent (_my_tls.locals.hostent_buf, (unionent *) src, unionent::t_hostent); -} - -static inline protoent * -dup_ent (protoent *src) -{ - return (protoent *) dup_ent (_my_tls.locals.protoent_buf, (unionent *) src, unionent::t_protoent); -} - -static inline servent * -dup_ent (servent *src) -{ - return (servent *) dup_ent (_my_tls.locals.servent_buf, (unionent *) src, unionent::t_servent); -} - -/* exported as getprotobyname: standards? */ -extern "C" struct protoent * -cygwin_getprotobyname (const char *p) -{ - myfault efault; - if (efault.faulted (EFAULT)) - return NULL; - return dup_ent (getprotobyname (p)); -} - -/* exported as getprotobynumber: standards? */ -extern "C" struct protoent * -cygwin_getprotobynumber (int number) -{ - return dup_ent (getprotobynumber (number)); -} - -bool -fdsock (cygheap_fdmanip& fd, const device *dev, SOCKET soc) -{ - int size; - - fd = build_fh_dev (*dev); - if (!fd.isopen ()) - return false; - fd->set_io_handle ((HANDLE) soc); - if (!((fhandler_socket *) fd)->init_events ()) - return false; - fd->set_flags (O_RDWR | O_BINARY); - fd->uninterruptible_io (true); - debug_printf ("fd %d, name '%s', soc %p", (int) fd, dev->name, soc); - - /* Usually sockets are inheritable IFS objects. Unfortunately some virus - scanners or other network-oriented software replace normal sockets - with their own kind, which is running through a filter driver. - - The result is that these new sockets are not normal kernel objects - anymore. They are typically not marked as inheritable, nor are they - IFS handles, as normal OS sockets are. They are in fact not inheritable - to child processes, and subsequent socket calls in the child process - will fail with error 10038, WSAENOTSOCK. And worse, while DuplicateHandle - on these sockets mostly works in the process which created the socket, - DuplicateHandle does quite often not work anymore in a child process. - It does not help to mark them inheritable via SetHandleInformation. - - The only way to make these sockets usable in child processes is to - duplicate them via WSADuplicateSocket/WSASocket calls. This requires - to start the child process in SUSPENDED state so we only do this on - affected systems. If we recognize a non-inheritable socket, or if - the XP1_IFS_HANDLES flag is not set in a call to WSADuplicateSocket, - we switch to inheritance/dup via WSADuplicateSocket/WSASocket for - that socket. */ - DWORD flags; -#if 0 - /* Disable checking for IFS handle for now. In theory, checking the fact - that the socket handle is not inheritable should be sufficient. */ - WSAPROTOCOL_INFOW wpi; -#endif - if (!GetHandleInformation ((HANDLE) soc, &flags) - || !(flags & HANDLE_FLAG_INHERIT)) -#if 0 - || WSADuplicateSocketW (soc, GetCurrentProcessId (), &wpi) - /* dwProviderReserved contains the actual SOCKET value of the duplicated - socket. Close it or suffer a handle leak. Worse, one socket for each - connection remains in CLOSE_WAIT state. */ - || (closesocket ((SOCKET) wpi.dwProviderReserved), FALSE) - || !(wpi.dwServiceFlags1 & XP1_IFS_HANDLES)) -#endif - ((fhandler_socket *) fd)->init_fixup_before (); - - /* Raise default buffer sizes (instead of WinSock default 8K). - - 64K appear to have the best size/performance ratio for a default - value. Tested with ssh/scp on Vista over Gigabit LAN. - - NOTE. If the SO_RCVBUF size exceeds 65535(*), and if the socket is - connected to a remote machine, then calling WSADuplicateSocket on - fork/exec fails with WinSock error 10022, WSAEINVAL. Fortunately - we don't use WSADuplicateSocket anymore, rather we just utilize - handle inheritance. An explanation for this weird behaviour would - be nice, though. - - (*) Maximum normal TCP window size. Coincidence? */ - ((fhandler_socket *) fd)->rmem () = 65535; - ((fhandler_socket *) fd)->wmem () = 65535; - if (::setsockopt (soc, SOL_SOCKET, SO_RCVBUF, - (char *) &((fhandler_socket *) fd)->rmem (), sizeof (int))) - { - debug_printf ("setsockopt(SO_RCVBUF) failed, %lu", WSAGetLastError ()); - if (::getsockopt (soc, SOL_SOCKET, SO_RCVBUF, - (char *) &((fhandler_socket *) fd)->rmem (), - (size = sizeof (int), &size))) - system_printf ("getsockopt(SO_RCVBUF) failed, %lu", WSAGetLastError ()); - } - if (::setsockopt (soc, SOL_SOCKET, SO_SNDBUF, - (char *) &((fhandler_socket *) fd)->wmem (), sizeof (int))) - { - debug_printf ("setsockopt(SO_SNDBUF) failed, %lu", WSAGetLastError ()); - if (::getsockopt (soc, SOL_SOCKET, SO_SNDBUF, - (char *) &((fhandler_socket *) fd)->wmem (), - (size = sizeof (int), &size))) - system_printf ("getsockopt(SO_SNDBUF) failed, %lu", WSAGetLastError ()); - } - - return true; -} - -/* exported as socket: standards? */ -extern "C" int -cygwin_socket (int af, int type, int protocol) -{ - int res = -1; - SOCKET soc = 0; - - int flags = type & _SOCK_FLAG_MASK; - type &= ~_SOCK_FLAG_MASK; - - debug_printf ("socket (%d, %d (flags %p), %d)", af, type, flags, protocol); - - if ((flags & ~(SOCK_NONBLOCK | SOCK_CLOEXEC)) != 0) - { - set_errno (EINVAL); - goto done; - } - - soc = socket (af == AF_LOCAL ? AF_INET : af, type, - af == AF_LOCAL ? 0 : protocol); - - if (soc == INVALID_SOCKET) - { - set_winsock_errno (); - goto done; - } - - const device *dev; - - if (af == AF_LOCAL) - dev = type == SOCK_STREAM ? stream_dev : dgram_dev; - else - dev = type == SOCK_STREAM ? tcp_dev : udp_dev; - - { - cygheap_fdnew fd; - if (fd < 0 || !fdsock (fd, dev, soc)) - closesocket (soc); - else - { - ((fhandler_socket *) fd)->set_addr_family (af); - ((fhandler_socket *) fd)->set_socket_type (type); - if (flags & SOCK_NONBLOCK) - ((fhandler_socket *) fd)->set_nonblocking (true); - if (flags & SOCK_CLOEXEC) - ((fhandler_socket *) fd)->set_close_on_exec (true); - res = fd; - } - } - -done: - syscall_printf ("%d = socket (%d, %d (flags %p), %d)", - res, af, type, flags, protocol); - return res; -} - -/* exported as sendto: standards? */ -extern "C" int -cygwin_sendto (int fd, const void *buf, size_t len, int flags, - const struct sockaddr *to, socklen_t tolen) -{ - int res; - - fhandler_socket *fh = get (fd); - - myfault efault; - if (efault.faulted (EFAULT) || !fh) - res = -1; - else - res = fh->sendto (buf, len, flags, to, tolen); - - syscall_printf ("%d = sendto (%d, %p, %d, %x, %p, %d)", - res, fd, buf, len, flags, to, tolen); - - return res; -} - -/* exported as recvfrom: standards? */ -extern "C" int -cygwin_recvfrom (int fd, void *buf, size_t len, int flags, - struct sockaddr *from, socklen_t *fromlen) -{ - int res; - - fhandler_socket *fh = get (fd); - - myfault efault; - if (efault.faulted (EFAULT) || !fh) - res = -1; - else if ((res = len) != 0) - res = fh->recvfrom (buf, len, flags, from, fromlen); - - syscall_printf ("%d = recvfrom (%d, %p, %d, %x, %p, %p)", - res, fd, buf, len, flags, from, fromlen); - - return res; -} - -static int -convert_ws1_ip_optname (int optname) -{ - static int ws2_optname[] = - { - 0, - IP_OPTIONS, - IP_MULTICAST_IF, - IP_MULTICAST_TTL, - IP_MULTICAST_LOOP, - IP_ADD_MEMBERSHIP, - IP_DROP_MEMBERSHIP, - IP_TTL, - IP_TOS, - IP_DONTFRAGMENT - }; - return (optname < 1 || optname > _WS1_IP_DONTFRAGMENT) - ? optname - : ws2_optname[optname]; -} - -/* exported as setsockopt: standards? */ -extern "C" int -cygwin_setsockopt (int fd, int level, int optname, const void *optval, - socklen_t optlen) -{ - int res; - fhandler_socket *fh = get (fd); - - myfault efault; - if (efault.faulted (EFAULT) || !fh) - res = -1; - else - { - /* Old applications still use the old Winsock1 IPPROTO_IP values. */ - if (level == IPPROTO_IP && CYGWIN_VERSION_CHECK_FOR_USING_WINSOCK1_VALUES) - optname = convert_ws1_ip_optname (optname); - - /* On systems supporting "enhanced socket security (2K3 and later), - the default behaviour of stream socket binding is equivalent to the - POSIX behaviour with SO_REUSEADDR. Setting SO_REUSEADDR would only - result in wrong behaviour. See also fhandler_socket::bind(). */ - if (level == SOL_SOCKET && optname == SO_REUSEADDR - && wincap.has_enhanced_socket_security () - && fh->get_socket_type () == SOCK_STREAM) - res = 0; - else - res = setsockopt (fh->get_socket (), level, optname, - (const char *) optval, optlen); - - if (optlen == 4) - syscall_printf ("setsockopt optval=%x", *(long *) optval); - - if (res) - { - /* KB 248611: - - Windows 2000 and above don't support setting the IP_TOS field - with setsockopt. Additionally, TOS was always (also under 9x - and NT) only implemented for UDP and ICMP, never for TCP. - - The difference is that beginning with Windows 2000 the - setsockopt call returns WinSock error 10022, WSAEINVAL when - trying to set the IP_TOS field, instead of just ignoring the - call. This is *not* explained in KB 248611, but only in KB - 258978. - - Either case, the official workaround is to add a new registry - DWORD value HKLM/System/CurrentControlSet/Services/Tcpip/... - ... Parameters/DisableUserTOSSetting, set to 0, and reboot. - - Sidenote: The reasoning for dropping ToS in Win2K is that ToS - per RFC 1349 is incompatible with DiffServ per RFC 2474/2475. - - We just ignore the return value of setting IP_TOS under Windows - 2000 and above entirely. */ - if (level == IPPROTO_IP && optname == IP_TOS - && WSAGetLastError () == WSAEINVAL - && wincap.has_disabled_user_tos_setting ()) - { - debug_printf ("Faked IP_TOS success"); - res = 0; - } - else - set_winsock_errno (); - } - else if (level == SOL_SOCKET) - switch (optname) - { - case SO_REUSEADDR: - fh->saw_reuseaddr (*(int *) optval); - break; - case SO_RCVBUF: - fh->rmem (*(int *) optval); - break; - case SO_SNDBUF: - fh->wmem (*(int *) optval); - break; - default: - break; - } - } - - syscall_printf ("%d = setsockopt (%d, %d, %x, %p, %d)", - res, fd, level, optname, optval, optlen); - return res; -} - -/* exported as getsockopt: standards? */ -extern "C" int -cygwin_getsockopt (int fd, int level, int optname, void *optval, - socklen_t *optlen) -{ - int res; - fhandler_socket *fh = get (fd); - - myfault efault; - if (efault.faulted (EFAULT) || !fh) - res = -1; - else if (optname == SO_PEERCRED) - { - struct ucred *cred = (struct ucred *) optval; - res = fh->getpeereid (&cred->pid, &cred->uid, &cred->gid); - } - else - { - /* Old applications still use the old Winsock1 IPPROTO_IP values. */ - if (level == IPPROTO_IP && CYGWIN_VERSION_CHECK_FOR_USING_WINSOCK1_VALUES) - optname = convert_ws1_ip_optname (optname); - res = getsockopt (fh->get_socket (), level, optname, (char *) optval, - (int *) optlen); - - if (optname == SO_ERROR) - { - int *e = (int *) optval; - - debug_printf ("WinSock SO_ERROR = %d", *e); - *e = find_winsock_errno (*e); - } - - if (res) - set_winsock_errno (); - } - - syscall_printf ("%d = getsockopt (%d, %d, 0x%x, %p, %p)", - res, fd, level, optname, optval, optlen); - return res; -} - -extern "C" int -getpeereid (int fd, __uid32_t *euid, __gid32_t *egid) -{ - sig_dispatch_pending (); - fhandler_socket *fh = get (fd); - if (fh) - return fh->getpeereid (NULL, euid, egid); - return -1; -} - -/* exported as connect: standards? */ -extern "C" int -cygwin_connect (int fd, const struct sockaddr *name, socklen_t namelen) -{ - int res; - sig_dispatch_pending (); - - fhandler_socket *fh = get (fd); - - myfault efault; - if (efault.faulted (EFAULT) || !fh) - res = -1; - else - res = fh->connect (name, namelen); - - syscall_printf ("%d = connect (%d, %p, %d)", res, fd, name, namelen); - - return res; -} - -/* exported as getservbyname: standards? */ -extern "C" struct servent * -cygwin_getservbyname (const char *name, const char *proto) -{ - sig_dispatch_pending (); - myfault efault; - if (efault.faulted (EFAULT)) - return NULL; - - servent *res = dup_ent (getservbyname (name, proto)); - syscall_printf ("%p = getservbyname (%s, %s)", res, name, proto); - return res; -} - -/* exported as getservbyport: standards? */ -extern "C" struct servent * -cygwin_getservbyport (int port, const char *proto) -{ - sig_dispatch_pending (); - myfault efault; - if (efault.faulted (EFAULT)) - return NULL; - - servent *res = dup_ent (getservbyport (port, proto)); - syscall_printf ("%p = getservbyport (%d, %s)", res, port, proto); - return res; -} - -extern "C" int -cygwin_gethostname (char *name, size_t len) -{ - sig_dispatch_pending (); - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - if (gethostname (name, len)) - { - DWORD local_len = len; - - if (!GetComputerNameA (name, &local_len)) - { - set_winsock_errno (); - return -1; - } - } - debug_printf ("name %s", name); - return 0; -} - -/* exported as gethostbyname: standards? */ -extern "C" struct hostent * -cygwin_gethostbyname (const char *name) -{ - sig_dispatch_pending (); - myfault efault; - if (efault.faulted (EFAULT)) - return NULL; - - unsigned char tmp_addr[4]; - struct hostent tmp, *h; - char *tmp_aliases[1] = {0}; - char *tmp_addr_list[2] = {0,0}; - unsigned int a, b, c, d; - char dummy; - - if (sscanf (name, "%u.%u.%u.%u%c", &a, &b, &c, &d, &dummy) != 4 - || a >= 256 || b >= 256 || c >= 256 || d >= 256) - h = gethostbyname (name); - else - { - /* In case you don't have DNS, at least x.x.x.x still works */ - memset (&tmp, 0, sizeof (tmp)); - tmp_addr[0] = a; - tmp_addr[1] = b; - tmp_addr[2] = c; - tmp_addr[3] = d; - tmp_addr_list[0] = (char *) tmp_addr; - tmp.h_name = name; - tmp.h_aliases = tmp_aliases; - tmp.h_addrtype = 2; - tmp.h_length = 4; - tmp.h_addr_list = tmp_addr_list; - h = &tmp; - } - - hostent *res = dup_ent (h); - if (res) - debug_printf ("h_name %s", res->h_name); - else - { - debug_printf ("dup_ent returned NULL for name %s, h %p", name, h); - set_host_errno (); - } - return res; -} - -/* exported as gethostbyaddr: standards? */ -extern "C" struct hostent * -cygwin_gethostbyaddr (const char *addr, int len, int type) -{ - sig_dispatch_pending (); - myfault efault; - if (efault.faulted (EFAULT)) - return NULL; - - hostent *res = dup_ent (gethostbyaddr (addr, len, type)); - if (res) - debug_printf ("h_name %s", res->h_name); - else - set_host_errno (); - return res; -} - -static void -memcpy4to6 (char *dst, const u_char *src) -{ - const unsigned int h[] = {0, 0, htonl (0xFFFF)}; - memcpy (dst, h, 12); - memcpy (dst + 12, src, NS_INADDRSZ); -} - -static hostent * -gethostby_helper (const char *name, const int af, const int type, - const int addrsize_in, const int addrsize_out) -{ - /* Get the data from the name server */ - const int maxcount = 3; - int old_errno, ancount = 0, anlen = 1024, msgsize = 0; - u_char *ptr, *msg = NULL; - int sz; - hostent *ret; - char *string_ptr; - - while ((anlen > msgsize) && (ancount++ < maxcount)) - { - msgsize = anlen; - ptr = (u_char *) realloc (msg, msgsize); - if (ptr == NULL ) - { - old_errno = errno; - free (msg); - set_errno (old_errno); - h_errno = NETDB_INTERNAL; - return NULL; - } - msg = ptr; - anlen = res_search (name, ns_c_in, type, msg, msgsize); - } - - if (ancount >= maxcount) - { - free (msg); - h_errno = NO_RECOVERY; - return NULL; - } - if (anlen < 0) /* errno and h_errno are set */ - { - old_errno = errno; - free (msg); - set_errno (old_errno); - return NULL; - } - u_char *eomsg = msg + anlen - 1; - - - /* We scan the answer records to determine the required memory size. - They can be corrupted and we don't fully trust that the message - follows the standard exactly. glibc applies some checks that - we emulate. - The answers are copied in the hostent structure in a second scan. - To simplify the second scan we store information as follows: - - "class" is replaced by the compressed name size - - the first 16 bits of the "ttl" store the expanded name size + 1 - - the last 16 bits of the "ttl" store the offset to the next valid record. - Note that "type" is rewritten in host byte order. */ - - class record { - public: - unsigned type: 16; // type - unsigned complen: 16; // class or compressed length - unsigned namelen1: 16; // expanded length (with final 0) - unsigned next_o: 16; // offset to next valid - unsigned size: 16; // data size - u_char data[]; // data - record * next () { return (record *) (((char *) this) + next_o); } - void set_next ( record * nxt) { next_o = ((char *) nxt) - ((char *) this); } - u_char * name () { return (u_char *) (((char *) this) - complen); } - }; - - record * anptr = NULL, * prevptr = NULL, * curptr; - int i, alias_count = 0, string_size = 0, address_count = 0; - int namelen1 = 0, address_len = 0, antype, anclass, ansize; - unsigned complen; - - /* Get the count of answers */ - ancount = ntohs (((HEADER *) msg)->ancount); - - /* Skip the question, it was verified by res_send */ - ptr = msg + sizeof (HEADER); - if ((complen = dn_skipname (ptr, eomsg)) < 0) - goto corrupted; - /* Point to the beginning of the answer section */ - ptr += complen + NS_QFIXEDSZ; - - /* Scan the answer records to determine the sizes */ - for (i = 0; i < ancount; i++, ptr = curptr->data + ansize) - { - if ((complen = dn_skipname (ptr, eomsg)) < 0) - goto corrupted; - - curptr = (record *) (ptr + complen); - antype = ntohs (curptr->type); - anclass = ntohs (curptr->complen); - ansize = ntohs (curptr->size); - /* Class must be internet */ - if (anclass != ns_c_in) - continue; - - curptr->complen = complen; - if ((namelen1 = dn_length1 (msg, eomsg, curptr-> name())) <= 0) - goto corrupted; - - if (antype == ns_t_cname) - { - alias_count++; - string_size += namelen1; - } - else if (antype == type) - { - ansize = ntohs (curptr->size); - if (ansize != addrsize_in) - continue; - if (address_count == 0) - { - address_len = namelen1; - string_size += namelen1; - } - else if (address_len != namelen1) - continue; - address_count++; - } - /* Update the records */ - curptr->type = antype; /* Host byte order */ - curptr->namelen1 = namelen1; - if (! anptr) - anptr = prevptr = curptr; - else - { - prevptr->set_next (curptr); - prevptr = curptr; - } - } - - /* If there is no address, quit */ - if (address_count == 0) - { - free (msg); - h_errno = NO_DATA; - return NULL; - } - - /* Determine the total size */ - sz = DWORD_round (sizeof(hostent)) - + sizeof (char *) * (alias_count + address_count + 2) - + string_size - + address_count * addrsize_out; - - ret = realloc_ent (sz, (hostent *) NULL); - if (! ret) - { - old_errno = errno; - free (msg); - set_errno (old_errno); - h_errno = NETDB_INTERNAL; - return NULL; - } - - ret->h_addrtype = af; - ret->h_length = addrsize_out; - ret->h_aliases = (char **) (((char *) ret) + DWORD_round (sizeof(hostent))); - ret->h_addr_list = ret->h_aliases + alias_count + 1; - string_ptr = (char *) (ret->h_addr_list + address_count + 1); - - /* Rescan the answers */ - ancount = alias_count + address_count; /* Valid records */ - alias_count = address_count = 0; - - for (i = 0, curptr = anptr; i < ancount; i++, curptr = curptr->next ()) - { - antype = curptr->type; - if (antype == ns_t_cname) - { - complen = dn_expand (msg, eomsg, curptr->name (), string_ptr, string_size); -#ifdef DEBUGGING - if (complen != curptr->complen) - goto debugging; -#endif - ret->h_aliases[alias_count++] = string_ptr; - namelen1 = curptr->namelen1; - string_ptr += namelen1; - string_size -= namelen1; - continue; - } - if (antype == type) - { - if (address_count == 0) - { - complen = dn_expand (msg, eomsg, curptr->name(), string_ptr, string_size); -#ifdef DEBUGGING - if (complen != curptr->complen) - goto debugging; -#endif - ret->h_name = string_ptr; - namelen1 = curptr->namelen1; - string_ptr += namelen1; - string_size -= namelen1; - } - ret->h_addr_list[address_count++] = string_ptr; - if (addrsize_in != addrsize_out) - memcpy4to6 (string_ptr, curptr->data); - else - memcpy (string_ptr, curptr->data, addrsize_in); - string_ptr += addrsize_out; - string_size -= addrsize_out; - continue; - } -#ifdef DEBUGGING - /* Should not get here */ - goto debugging; -#endif - } -#ifdef DEBUGGING - if (string_size < 0) - goto debugging; -#endif - - free (msg); - - ret->h_aliases[alias_count] = NULL; - ret->h_addr_list[address_count] = NULL; - - return ret; - - corrupted: - free (msg); - /* Hopefully message corruption errors are temporary. - Should it be NO_RECOVERY ? */ - h_errno = TRY_AGAIN; - return NULL; - - -#ifdef DEBUGGING - debugging: - system_printf ("Please debug."); - free (msg); - free (ret); - h_errno = NO_RECOVERY; - return NULL; -#endif -} - -/* gethostbyname2: standards? */ -extern "C" struct hostent * -gethostbyname2 (const char *name, int af) -{ - sig_dispatch_pending (); - myfault efault; - if (efault.faulted (EFAULT)) - return NULL; - - if (!(_res.options & RES_INIT)) - res_init(); - bool v4to6 = _res.options & RES_USE_INET6; - - int type, addrsize_in, addrsize_out; - switch (af) - { - case AF_INET: - addrsize_in = NS_INADDRSZ; - addrsize_out = (v4to6) ? NS_IN6ADDRSZ : NS_INADDRSZ; - type = ns_t_a; - break; - case AF_INET6: - addrsize_in = addrsize_out = NS_IN6ADDRSZ; - type = ns_t_aaaa; - break; - default: - set_errno (EAFNOSUPPORT); - h_errno = NETDB_INTERNAL; - return NULL; - } - - return gethostby_helper (name, af, type, addrsize_in, addrsize_out); -} - -/* exported as accept: standards? */ -extern "C" int -cygwin_accept (int fd, struct sockaddr *peer, socklen_t *len) -{ - int res; - sig_dispatch_pending (); - - fhandler_socket *fh = get (fd); - - myfault efault; - if (efault.faulted (EFAULT) || !fh) - res = -1; - else - res = fh->accept4 (peer, len, fh->is_nonblocking () ? SOCK_NONBLOCK : 0); - - syscall_printf ("%d = accept (%d, %p, %p)", res, fd, peer, len); - return res; -} - -extern "C" int -accept4 (int fd, struct sockaddr *peer, socklen_t *len, int flags) -{ - int res; - sig_dispatch_pending (); - - fhandler_socket *fh = get (fd); - - myfault efault; - if (efault.faulted (EFAULT) || !fh) - res = -1; - else if ((flags & ~(SOCK_NONBLOCK | SOCK_CLOEXEC)) != 0) - { - set_errno (EINVAL); - res = -1; - } - else - res = fh->accept4 (peer, len, flags); - - syscall_printf ("%d = accept4 (%d, %p, %p, %p)", res, fd, peer, len, flags); - return res; -} - -/* exported as bind: standards? */ -extern "C" int -cygwin_bind (int fd, const struct sockaddr *my_addr, socklen_t addrlen) -{ - int res; - sig_dispatch_pending (); - fhandler_socket *fh = get (fd); - - myfault efault; - if (efault.faulted (EFAULT) || !fh) - res = -1; - else - res = fh->bind (my_addr, addrlen); - - syscall_printf ("%d = bind (%d, %p, %d)", res, fd, my_addr, addrlen); - return res; -} - -/* exported as getsockname: standards? */ -extern "C" int -cygwin_getsockname (int fd, struct sockaddr *addr, socklen_t *namelen) -{ - int res; - sig_dispatch_pending (); - - fhandler_socket *fh = get (fd); - - myfault efault; - if (efault.faulted (EFAULT) || !fh) - res = -1; - else - res = fh->getsockname (addr, namelen); - - syscall_printf ("%d = getsockname (%d, %p, %p)", res, fd, addr, namelen); - return res; -} - -/* exported as listen: standards? */ -extern "C" int -cygwin_listen (int fd, int backlog) -{ - int res; - sig_dispatch_pending (); - fhandler_socket *fh = get (fd); - - if (!fh) - res = -1; - else - res = fh->listen (backlog); - - syscall_printf ("%d = listen (%d, %d)", res, fd, backlog); - return res; -} - -/* exported as shutdown: standards? */ -extern "C" int -cygwin_shutdown (int fd, int how) -{ - int res; - sig_dispatch_pending (); - - fhandler_socket *fh = get (fd); - - if (!fh) - res = -1; - else - res = fh->shutdown (how); - - syscall_printf ("%d = shutdown (%d, %d)", res, fd, how); - return res; -} - -/* exported as hstrerror: BSD 4.3 */ -extern "C" const char * -cygwin_hstrerror (int err) -{ - int i; - - for (i = 0; host_errmap[i].e != 0; ++i) - if (err == host_errmap[i].e) - break; - - return host_errmap[i].s; -} - -/* exported as herror: BSD 4.3 */ -extern "C" void -cygwin_herror (const char *s) -{ - myfault efault; - if (efault.faulted ()) - return; - if (cygheap->fdtab.not_open (2)) - return; - - if (s) - { - write (2, s, strlen (s)); - write (2, ": ", 2); - } - - const char *h_errstr = cygwin_hstrerror (h_errno); - - if (!h_errstr) - switch (h_errno) - { - case NETDB_INTERNAL: - h_errstr = "Resolver internal error"; - break; - case NETDB_SUCCESS: - h_errstr = "Resolver error 0 (no error)"; - break; - default: - h_errstr = "Unknown resolver error"; - break; - } - write (2, h_errstr, strlen (h_errstr)); - write (2, "\n", 1); -} - -/* exported as getpeername: standards? */ -extern "C" int -cygwin_getpeername (int fd, struct sockaddr *name, socklen_t *len) -{ - int res; - sig_dispatch_pending (); - - fhandler_socket *fh = get (fd); - - myfault efault; - if (efault.faulted (EFAULT) || !fh) - res = -1; - else - res = fh->getpeername (name, len); - - syscall_printf ("%d = getpeername (%d) %d", res, fd, (fh ? fh->get_socket () : -1)); - return res; -} - -/* exported as recv: standards? */ -extern "C" int -cygwin_recv (int fd, void *buf, size_t len, int flags) -{ - return cygwin_recvfrom (fd, buf, len, flags, NULL, NULL); -} - -/* exported as send: standards? */ -extern "C" int -cygwin_send (int fd, const void *buf, size_t len, int flags) -{ - return cygwin_sendto (fd, buf, len, flags, NULL, 0); -} - -/* getdomainname: standards? */ -extern "C" int -getdomainname (char *domain, size_t len) -{ - sig_dispatch_pending (); - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - PFIXED_INFO info = NULL; - ULONG size = 0; - - if (GetNetworkParams(info, &size) == ERROR_BUFFER_OVERFLOW - && (info = (PFIXED_INFO) alloca(size)) - && GetNetworkParams(info, &size) == ERROR_SUCCESS) - { - strncpy(domain, info->DomainName, len); - return 0; - } - - /* This is only used by NT4. - The registry names are language independent. */ - reg_key r (HKEY_LOCAL_MACHINE, KEY_READ, - "SYSTEM", "CurrentControlSet", "Services", - "Tcpip", "Parameters", NULL); - - if (!r.error ()) - { - int res1, res2 = 0; /* Suppress compiler warning */ - res1 = r.get_string ("Domain", domain, len, ""); - if (res1 != ERROR_SUCCESS || !domain[0]) - res2 = r.get_string ("DhcpDomain", domain, len, ""); - if (res1 == ERROR_SUCCESS || res2 == ERROR_SUCCESS) - return 0; - } - __seterrno (); - return -1; -} - -/* Fill out an ifconf struct. */ - -/* Vista/Longhorn: unicast address has additional OnLinkPrefixLength member. */ -typedef struct _IP_ADAPTER_UNICAST_ADDRESS_LH { - _ANONYMOUS_UNION union { - ULONGLONG Alignment; - _ANONYMOUS_UNION struct { - ULONG Length; - DWORD Flags; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; - struct _IP_ADAPTER_UNICAST_ADDRESS_VISTA *Next; - SOCKET_ADDRESS Address; - IP_PREFIX_ORIGIN PrefixOrigin; - IP_SUFFIX_ORIGIN SuffixOrigin; - IP_DAD_STATE DadState; - ULONG ValidLifetime; - ULONG PreferredLifetime; - ULONG LeaseLifetime; - unsigned char OnLinkPrefixLength; -} IP_ADAPTER_UNICAST_ADDRESS_LH, *PIP_ADAPTER_UNICAST_ADDRESS_LH; - -/* Vista/Longhorn: IP_ADAPTER_ADDRESSES has a lot more info. We pick only - what we need for now. */ -typedef struct _IP_ADAPTER_ADDRESSES_LH { - _ANONYMOUS_UNION union { - ULONGLONG Alignment; - _ANONYMOUS_STRUCT struct { - ULONG Length; - DWORD IfIndex; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; - struct _IP_ADAPTER_ADDRESSES* Next; - PCHAR AdapterName; - PIP_ADAPTER_UNICAST_ADDRESS FirstUnicastAddress; - PIP_ADAPTER_ANYCAST_ADDRESS FirstAnycastAddress; - PIP_ADAPTER_MULTICAST_ADDRESS FirstMulticastAddress; - PIP_ADAPTER_DNS_SERVER_ADDRESS FirstDnsServerAddress; - PWCHAR DnsSuffix; - PWCHAR Description; - PWCHAR FriendlyName; - BYTE PhysicalAddress[MAX_ADAPTER_ADDRESS_LENGTH]; - DWORD PhysicalAddressLength; - DWORD Flags; - DWORD Mtu; - DWORD IfType; - IF_OPER_STATUS OperStatus; - DWORD Ipv6IfIndex; - DWORD ZoneIndices[16]; - PIP_ADAPTER_PREFIX FirstPrefix; - - ULONG64 TransmitLinkSpeed; - ULONG64 ReceiveLinkSpeed; - PVOID FirstWinsServerAddress; - PVOID FirstGatewayAddress; - ULONG Ipv4Metric; - ULONG Ipv6Metric; -} IP_ADAPTER_ADDRESSES_LH,*PIP_ADAPTER_ADDRESSES_LH; - -/* We can't include ws2tcpip.h. */ - -#define SIO_GET_INTERFACE_LIST _IOR('t', 127, u_long) - -struct sockaddr_in6_old { - short sin6_family; - u_short sin6_port; - u_long sin6_flowinfo; - struct in6_addr sin6_addr; -}; - -typedef union sockaddr_gen{ - struct sockaddr Address; - struct sockaddr_in AddressIn; - struct sockaddr_in6_old AddressIn6; -} sockaddr_gen; - -typedef struct _INTERFACE_INFO { - u_long iiFlags; - sockaddr_gen iiAddress; - sockaddr_gen iiBroadcastAddress; - sockaddr_gen iiNetmask; -} INTERFACE_INFO, *LPINTERFACE_INFO; - -#ifndef IN_LOOPBACK -#define IN_LOOPBACK(a) ((((long int) (a)) & 0xff000000) == 0x7f000000) -#endif - -static int in6_are_prefix_equal (struct in6_addr *, struct in6_addr *, int); - -static int in_are_prefix_equal (struct in_addr *p1, struct in_addr *p2, int len) -{ - if (0 > len || len > 32) - return 0; - uint32_t pfxmask = 0xffffffff << (32 - len); - return (ntohl (p1->s_addr) & pfxmask) == (ntohl (p2->s_addr) & pfxmask); -} - -extern "C" int -ip_addr_prefix (PIP_ADAPTER_UNICAST_ADDRESS pua, PIP_ADAPTER_PREFIX pap) -{ - if (wincap.has_gaa_on_link_prefix ()) - return (int) ((PIP_ADAPTER_UNICAST_ADDRESS_LH) pua)->OnLinkPrefixLength; - switch (pua->Address.lpSockaddr->sa_family) - { - case AF_INET: - /* Prior to Vista, the loopback prefix is not available. */ - if (IN_LOOPBACK (ntohl (((struct sockaddr_in *) - pua->Address.lpSockaddr)->sin_addr.s_addr))) - return 8; - for ( ; pap; pap = pap->Next) - if (in_are_prefix_equal ( - &((struct sockaddr_in *) pua->Address.lpSockaddr)->sin_addr, - &((struct sockaddr_in *) pap->Address.lpSockaddr)->sin_addr, - pap->PrefixLength)) - return pap->PrefixLength; - break; - case AF_INET6: - /* Prior to Vista, the loopback prefix is not available. */ - if (IN6_IS_ADDR_LOOPBACK (&((struct sockaddr_in6 *) - pua->Address.lpSockaddr)->sin6_addr)) - return 128; - for ( ; pap; pap = pap->Next) - if (in6_are_prefix_equal ( - &((struct sockaddr_in6 *) pua->Address.lpSockaddr)->sin6_addr, - &((struct sockaddr_in6 *) pap->Address.lpSockaddr)->sin6_addr, - pap->PrefixLength)) - return pap->PrefixLength; - break; - default: - break; - } - return 0; -} - -#ifndef GAA_FLAG_INCLUDE_ALL_INTERFACES -#define GAA_FLAG_INCLUDE_ALL_INTERFACES 0x0100 -#endif - -bool -get_adapters_addresses (PIP_ADAPTER_ADDRESSES *pa_ret, ULONG family) -{ - DWORD ret, size = 0; - PIP_ADAPTER_ADDRESSES pa0 = NULL; - - if (!pa_ret) - return ERROR_BUFFER_OVERFLOW - == GetAdaptersAddresses (family, GAA_FLAG_INCLUDE_PREFIX - | GAA_FLAG_INCLUDE_ALL_INTERFACES, - NULL, NULL, &size); - do - { - ret = GetAdaptersAddresses (family, GAA_FLAG_INCLUDE_PREFIX - | GAA_FLAG_INCLUDE_ALL_INTERFACES, - NULL, pa0, &size); - if (ret == ERROR_BUFFER_OVERFLOW - && !(pa0 = (PIP_ADAPTER_ADDRESSES) realloc (pa0, size))) - break; - } - while (ret == ERROR_BUFFER_OVERFLOW); - if (ret != ERROR_SUCCESS) - { - if (pa0) - free (pa0); - *pa_ret = NULL; - return false; - } - *pa_ret = pa0; - return true; -} - -#define WS_IFF_UP 1 -#define WS_IFF_BROADCAST 2 -#define WS_IFF_LOOPBACK 4 -#define WS_IFF_POINTTOPOINT 8 -#define WS_IFF_MULTICAST 16 - -static inline short -convert_ifr_flags (u_long ws_flags) -{ - return (ws_flags & (WS_IFF_UP | WS_IFF_BROADCAST)) - | ((ws_flags & (WS_IFF_LOOPBACK | WS_IFF_POINTTOPOINT)) << 1) - | ((ws_flags & WS_IFF_MULTICAST) << 8); -} - -static u_long -get_routedst (DWORD if_index) -{ - PMIB_IPFORWARDTABLE pift; - ULONG size = 0; - if (GetIpForwardTable (NULL, &size, FALSE) == ERROR_INSUFFICIENT_BUFFER - && (pift = (PMIB_IPFORWARDTABLE) alloca (size)) - && GetIpForwardTable (pift, &size, FALSE) == NO_ERROR) - for (DWORD i = 0; i < pift->dwNumEntries; ++i) - { - if (pift->table[i].dwForwardIfIndex == if_index - && pift->table[i].dwForwardMask == INADDR_BROADCAST) - return pift->table[i].dwForwardDest; - } - return INADDR_ANY; -} - -struct ifall { - struct ifaddrs ifa_ifa; - char ifa_name[IFNAMSIZ]; - struct sockaddr_storage ifa_addr; - struct sockaddr_storage ifa_brddstaddr; - struct sockaddr_storage ifa_netmask; - struct sockaddr ifa_hwaddr; - int ifa_metric; - int ifa_mtu; - int ifa_ifindex; - struct ifreq_frndlyname ifa_frndlyname; -}; - -static unsigned int -get_flags (PIP_ADAPTER_ADDRESSES pap) -{ - unsigned int flags = IFF_UP; - if (pap->IfType == IF_TYPE_SOFTWARE_LOOPBACK) - flags |= IFF_LOOPBACK; - else if (pap->IfType == IF_TYPE_PPP) - flags |= IFF_POINTOPOINT; - if (!(pap->Flags & IP_ADAPTER_NO_MULTICAST)) - flags |= IFF_MULTICAST; - if (pap->OperStatus == IfOperStatusUp - || pap->OperStatus == IfOperStatusUnknown) - flags |= IFF_RUNNING; - if (pap->OperStatus != IfOperStatusLowerLayerDown) - flags |= IFF_LOWER_UP; - if (pap->OperStatus == IfOperStatusDormant) - flags |= IFF_DORMANT; - return flags; -} - -static ULONG -get_ipv4fromreg_ipcnt (const char *name) -{ - HKEY key; - LONG ret; - char regkey[256], *c; - ULONG ifs = 1; - DWORD dhcp, size; - - c = stpcpy (regkey, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\" - "Parameters\\Interfaces\\"); - stpcpy (c, name); - if ((ret = RegOpenKeyEx (HKEY_LOCAL_MACHINE, regkey, 0, KEY_READ, - &key)) != ERROR_SUCCESS) - { - debug_printf ("RegOpenKeyEx(%s), win32 error %ld", ret); - return 0; - } - /* If DHCP is used, we have only one address. */ - if ((ret = RegQueryValueEx (key, "EnableDHCP", NULL, NULL, (PBYTE) &dhcp, - (size = sizeof dhcp, &size))) == ERROR_SUCCESS - && dhcp == 0 - && (ret = RegQueryValueEx (key, "IPAddress", NULL, NULL, NULL, - &size)) == ERROR_SUCCESS) - { - char *ipa = (char *) alloca (size); - RegQueryValueEx (key, "IPAddress", NULL, NULL, (PBYTE) ipa, &size); - for (ifs = 0, c = ipa; *c; c += strlen (c) + 1) - ifs++; - } - RegCloseKey (key); - return ifs; -} - -static void -get_ipv4fromreg (struct ifall *ifp, const char *name, DWORD idx) -{ - HKEY key; - LONG ret; - char regkey[256], *c; - DWORD ifs; - DWORD dhcp, size; - - c = stpcpy (regkey, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\" - "Parameters\\Interfaces\\"); - stpcpy (c, name); - if ((ret = RegOpenKeyEx (HKEY_LOCAL_MACHINE, regkey, 0, KEY_READ, &key)) - != ERROR_SUCCESS) - { - debug_printf ("RegOpenKeyEx(%s), win32 error %ld", ret); - return; - } - /* If DHCP is used, we have only one address. */ - if ((ret = RegQueryValueEx (key, "EnableDHCP", NULL, NULL, (PBYTE) &dhcp, - (size = sizeof dhcp, &size))) == ERROR_SUCCESS) - { -#define addr ((struct sockaddr_in *) &ifp->ifa_addr) -#define mask ((struct sockaddr_in *) &ifp->ifa_netmask) -#define brdc ((struct sockaddr_in *) &ifp->ifa_brddstaddr) - if (dhcp) - { - if ((ret = RegQueryValueEx (key, "DhcpIPAddress", NULL, NULL, - (PBYTE) regkey, (size = 256, &size))) - == ERROR_SUCCESS) - cygwin_inet_aton (regkey, &addr->sin_addr); - if ((ret = RegQueryValueEx (key, "DhcpSubnetMask", NULL, NULL, - (PBYTE) regkey, (size = 256, &size))) - == ERROR_SUCCESS) - cygwin_inet_aton (regkey, &mask->sin_addr); - } - else - { - if ((ret = RegQueryValueEx (key, "IPAddress", NULL, NULL, NULL, - &size)) == ERROR_SUCCESS) - { - char *ipa = (char *) alloca (size); - RegQueryValueEx (key, "IPAddress", NULL, NULL, (PBYTE) ipa, &size); - for (ifs = 0, c = ipa; *c && ifs < idx; c += strlen (c) + 1) - ifs++; - if (*c) - cygwin_inet_aton (c, &addr->sin_addr); - } - if ((ret = RegQueryValueEx (key, "SubnetMask", NULL, NULL, NULL, - &size)) == ERROR_SUCCESS) - { - char *ipa = (char *) alloca (size); - RegQueryValueEx (key, "SubnetMask", NULL, NULL, (PBYTE) ipa, &size); - for (ifs = 0, c = ipa; *c && ifs < idx; c += strlen (c) + 1) - ifs++; - if (*c) - cygwin_inet_aton (c, &mask->sin_addr); - } - } - if (ifp->ifa_ifa.ifa_flags & IFF_BROADCAST) - brdc->sin_addr.s_addr = (addr->sin_addr.s_addr - & mask->sin_addr.s_addr) - | ~mask->sin_addr.s_addr; -#undef addr -#undef mask -#undef brdc - } - RegCloseKey (key); -} - -static void -get_friendlyname (struct ifall *ifp, PIP_ADAPTER_ADDRESSES pap) -{ - struct ifreq_frndlyname *iff = (struct ifreq_frndlyname *) - &ifp->ifa_frndlyname; - iff->ifrf_len = sys_wcstombs (iff->ifrf_friendlyname, - IFRF_FRIENDLYNAMESIZ, - pap->FriendlyName); -} - -static void -get_hwaddr (struct ifall *ifp, PIP_ADAPTER_ADDRESSES pap) -{ - for (UINT i = 0; i < IFHWADDRLEN; ++i) - if (i >= pap->PhysicalAddressLength) - ifp->ifa_hwaddr.sa_data[i] = '\0'; - else - ifp->ifa_hwaddr.sa_data[i] = pap->PhysicalAddress[i]; -} -/* - * Get network interfaces XP SP1 and above. - * Use IP Helper function GetAdaptersAddresses. - */ -static struct ifall * -get_xp_ifs (ULONG family) -{ - PIP_ADAPTER_ADDRESSES pa0 = NULL, pap; - PIP_ADAPTER_UNICAST_ADDRESS pua; - int cnt = 0; - struct ifall *ifret = NULL, *ifp; - struct sockaddr_in *if_sin; - struct sockaddr_in6 *if_sin6; - - if (!get_adapters_addresses (&pa0, family)) - goto done; - - for (pap = pa0; pap; pap = pap->Next) - if (!pap->FirstUnicastAddress) - { - /* FirstUnicastAddress is NULL for interfaces which are disconnected. - Fetch number of configured IPv4 addresses from registry and - store in an unused member of the adapter addresses structure. */ - pap->Ipv6IfIndex = get_ipv4fromreg_ipcnt (pap->AdapterName); - cnt += pap->Ipv6IfIndex; - } - else for (pua = pap->FirstUnicastAddress; pua; pua = pua->Next) - ++cnt; - - if (!(ifret = (struct ifall *) calloc (cnt, sizeof (struct ifall)))) - goto done; - ifp = ifret; - - for (pap = pa0; pap; pap = pap->Next) - { - DWORD idx = 0; - if (!pap->FirstUnicastAddress) - for (idx = 0; idx < pap->Ipv6IfIndex; ++idx) - { - /* Next in chain */ - ifp->ifa_ifa.ifa_next = (struct ifaddrs *) &ifp[1].ifa_ifa; - /* Interface name */ - if (idx) - __small_sprintf (ifp->ifa_name, "%s:%u", pap->AdapterName, idx); - else - strcpy (ifp->ifa_name, pap->AdapterName); - ifp->ifa_ifa.ifa_name = ifp->ifa_name; - /* Flags */ - ifp->ifa_ifa.ifa_flags = get_flags (pap); - if (pap->IfType != IF_TYPE_PPP) - ifp->ifa_ifa.ifa_flags |= IFF_BROADCAST; - /* Address */ - ifp->ifa_addr.ss_family = AF_INET; - ifp->ifa_ifa.ifa_addr = (struct sockaddr *) &ifp->ifa_addr; - /* Broadcast/Destination address */ - ifp->ifa_brddstaddr.ss_family = AF_INET; - ifp->ifa_ifa.ifa_dstaddr = NULL; - /* Netmask */ - ifp->ifa_netmask.ss_family = AF_INET; - ifp->ifa_ifa.ifa_netmask = (struct sockaddr *) &ifp->ifa_netmask; - /* Try to fetch real IPv4 address information from registry. */ - get_ipv4fromreg (ifp, pap->AdapterName, idx); - /* Hardware address */ - get_hwaddr (ifp, pap); - /* Metric */ - ifp->ifa_metric = 1; - /* MTU */ - ifp->ifa_mtu = pap->Mtu; - /* Interface index */ - ifp->ifa_ifindex = pap->IfIndex; - /* Friendly name */ - get_friendlyname (ifp, pap); - ++ifp; - } - else - for (idx = 0, pua = pap->FirstUnicastAddress; pua; - ++idx, pua = pua->Next) - { - struct sockaddr *sa = (struct sockaddr *) pua->Address.lpSockaddr; -# define sin ((struct sockaddr_in *) sa) -# define sin6 ((struct sockaddr_in6 *) sa) - size_t sa_size = (sa->sa_family == AF_INET6 - ? sizeof *sin6 : sizeof *sin); - /* Next in chain */ - ifp->ifa_ifa.ifa_next = (struct ifaddrs *) &ifp[1].ifa_ifa; - /* Interface name */ - if (idx && sa->sa_family == AF_INET) - __small_sprintf (ifp->ifa_name, "%s:%u", pap->AdapterName, idx); - else - strcpy (ifp->ifa_name, pap->AdapterName); - ifp->ifa_ifa.ifa_name = ifp->ifa_name; - /* Flags */ - ifp->ifa_ifa.ifa_flags = get_flags (pap); - if (sa->sa_family == AF_INET - && pap->IfType != IF_TYPE_SOFTWARE_LOOPBACK - && pap->IfType != IF_TYPE_PPP) - ifp->ifa_ifa.ifa_flags |= IFF_BROADCAST; - if (sa->sa_family == AF_INET) - { - ULONG hwaddr[2], hwlen = 6; - if (SendARP (sin->sin_addr.s_addr, 0, hwaddr, &hwlen)) - ifp->ifa_ifa.ifa_flags |= IFF_NOARP; - } - /* Address */ - memcpy (&ifp->ifa_addr, sa, sa_size); - ifp->ifa_ifa.ifa_addr = (struct sockaddr *) &ifp->ifa_addr; - /* Netmask */ - int prefix = ip_addr_prefix (pua, pap->FirstPrefix); - switch (sa->sa_family) - { - case AF_INET: - if_sin = (struct sockaddr_in *) &ifp->ifa_netmask; - if_sin->sin_addr.s_addr = htonl (UINT32_MAX << (32 - prefix)); - if_sin->sin_family = AF_INET; - break; - case AF_INET6: - if_sin6 = (struct sockaddr_in6 *) &ifp->ifa_netmask; - for (cnt = 0; cnt < 4 && prefix; ++cnt, prefix -= 32) - if_sin6->sin6_addr.s6_addr32[cnt] = UINT32_MAX; - if (prefix < 32) - if_sin6->sin6_addr.s6_addr32[cnt] <<= 32 - prefix; - break; - } - ifp->ifa_ifa.ifa_netmask = (struct sockaddr *) &ifp->ifa_netmask; - if (pap->IfType == IF_TYPE_PPP) - { - /* Destination address */ - if (sa->sa_family == AF_INET) - { - if_sin = (struct sockaddr_in *) &ifp->ifa_brddstaddr; - if_sin->sin_addr.s_addr = get_routedst (pap->IfIndex); - if_sin->sin_family = AF_INET; - } - else - /* FIXME: No official way to get the dstaddr for ipv6? */ - memcpy (&ifp->ifa_addr, sa, sa_size); - ifp->ifa_ifa.ifa_dstaddr = (struct sockaddr *) - &ifp->ifa_brddstaddr; - } - else - { - /* Broadcast address */ - if (sa->sa_family == AF_INET) - { - if_sin = (struct sockaddr_in *) &ifp->ifa_brddstaddr; - uint32_t mask = - ((struct sockaddr_in *) &ifp->ifa_netmask)->sin_addr.s_addr; - if_sin->sin_addr.s_addr = (sin->sin_addr.s_addr & mask) - | ~mask; - if_sin->sin_family = AF_INET; - ifp->ifa_ifa.ifa_broadaddr = (struct sockaddr *) - &ifp->ifa_brddstaddr; - } - else /* No IPv6 broadcast */ - ifp->ifa_ifa.ifa_broadaddr = NULL; - } - /* Hardware address */ - get_hwaddr (ifp, pap); - /* Metric */ - if (wincap.has_gaa_on_link_prefix ()) - ifp->ifa_metric = (sa->sa_family == AF_INET - ? ((PIP_ADAPTER_ADDRESSES_LH) pap)->Ipv4Metric - : ((PIP_ADAPTER_ADDRESSES_LH) pap)->Ipv6Metric); - else - ifp->ifa_metric = 1; - /* MTU */ - ifp->ifa_mtu = pap->Mtu; - /* Interface index */ - ifp->ifa_ifindex = pap->IfIndex; - /* Friendly name */ - get_friendlyname (ifp, pap); - ++ifp; -# undef sin -# undef sin6 - } - } - /* Since every entry is set to the next entry, the last entry points to an - invalid next entry now. Fix it retroactively. */ - if (ifp > ifret) - ifp[-1].ifa_ifa.ifa_next = NULL; - -done: - if (pa0) - free (pa0); - return ifret; -} - -/* - * Get network interfaces NTSP4, W2K, XP w/o service packs. - * Use IP Helper Library - */ -static struct ifall * -get_2k_ifs () -{ - int ethId = 0, pppId = 0, slpId = 0, tokId = 0; - - DWORD ip_cnt; - DWORD siz_ip_table = 0; - PMIB_IPADDRTABLE ipt; - PMIB_IFROW ifrow; - struct ifall *ifret = NULL, *ifp = NULL; - struct sockaddr_in *if_sin; - - struct ifcount_t - { - DWORD ifIndex; - size_t count; - unsigned int enumerated; // for eth0:1 - unsigned int classId; // for eth0, tok0 ... - - }; - ifcount_t *iflist, *ifEntry; - - if (GetIpAddrTable (NULL, &siz_ip_table, TRUE) == ERROR_INSUFFICIENT_BUFFER - && (ifrow = (PMIB_IFROW) alloca (sizeof (MIB_IFROW))) - && (ipt = (PMIB_IPADDRTABLE) alloca (siz_ip_table)) - && !GetIpAddrTable (ipt, &siz_ip_table, TRUE)) - { - if (!(ifret = (struct ifall *) calloc (ipt->dwNumEntries, sizeof (struct ifall)))) - goto done; - ifp = ifret; - - iflist = - (ifcount_t *) alloca (sizeof (ifcount_t) * (ipt->dwNumEntries + 1)); - memset (iflist, 0, sizeof (ifcount_t) * (ipt->dwNumEntries + 1)); - for (ip_cnt = 0; ip_cnt < ipt->dwNumEntries; ++ip_cnt) - { - ifEntry = iflist; - /* search for matching entry (and stop at first free entry) */ - while (ifEntry->count != 0) - { - if (ifEntry->ifIndex == ipt->table[ip_cnt].dwIndex) - break; - ifEntry++; - } - if (ifEntry->count == 0) - { - ifEntry->count = 1; - ifEntry->ifIndex = ipt->table[ip_cnt].dwIndex; - } - else - { - ifEntry->count++; - } - } - /* reset the last element. This is just the stopper for the loop. */ - iflist[ipt->dwNumEntries].count = 0; - - /* Iterate over all configured IP-addresses */ - for (ip_cnt = 0; ip_cnt < ipt->dwNumEntries; ++ip_cnt) - { - memset (ifrow, 0, sizeof (MIB_IFROW)); - ifrow->dwIndex = ipt->table[ip_cnt].dwIndex; - if (GetIfEntry (ifrow) != NO_ERROR) - continue; - - ifcount_t *ifEntry = iflist; - - /* search for matching entry (and stop at first free entry) */ - while (ifEntry->count != 0) - { - if (ifEntry->ifIndex == ipt->table[ip_cnt].dwIndex) - break; - ifEntry++; - } - - /* Next in chain */ - ifp->ifa_ifa.ifa_next = (struct ifaddrs *) &ifp[1].ifa_ifa; - /* Interface name */ - if (ifrow->dwType == IF_TYPE_SOFTWARE_LOOPBACK) - strcpy (ifp->ifa_name, "lo"); - else - { - const char *name = ""; - switch (ifrow->dwType) - { - case IF_TYPE_ISO88025_TOKENRING: - name = "tok"; - if (ifEntry->enumerated == 0) - ifEntry->classId = tokId++; - break; - case IF_TYPE_ETHERNET_CSMACD: - name = "eth"; - if (ifEntry->enumerated == 0) - ifEntry->classId = ethId++; - break; - case IF_TYPE_PPP: - name = "ppp"; - if (ifEntry->enumerated == 0) - ifEntry->classId = pppId++; - break; - case IF_TYPE_SLIP: - name = "slp"; - if (ifEntry->enumerated == 0) - ifEntry->classId = slpId++; - break; - default: - continue; - } - __small_sprintf (ifp->ifa_name, - ifEntry->enumerated ? "%s%u:%u" : "%s%u", - name, ifEntry->classId, ifEntry->enumerated); - ifEntry->enumerated++; - } - ifp->ifa_ifa.ifa_name = ifp->ifa_name; - /* Flags */ - if (ifrow->dwType == IF_TYPE_SOFTWARE_LOOPBACK) - ifp->ifa_ifa.ifa_flags |= IFF_LOOPBACK; - else if (ifrow->dwType == IF_TYPE_PPP - || ifrow->dwType == IF_TYPE_SLIP) - ifp->ifa_ifa.ifa_flags |= IFF_POINTOPOINT | IFF_NOARP; - else - ifp->ifa_ifa.ifa_flags |= IFF_BROADCAST; - if (ifrow->dwAdminStatus == IF_ADMIN_STATUS_UP) - { - ifp->ifa_ifa.ifa_flags |= IFF_UP | IFF_LOWER_UP; - /* Bug in NT4's IP Helper lib. The dwOperStatus has just - two values, 0 or 1, non operational, operational. */ - if (ifrow->dwOperStatus >= (wincap.has_broken_if_oper_status () - ? 1 : IF_OPER_STATUS_CONNECTED)) - ifp->ifa_ifa.ifa_flags |= IFF_RUNNING; - } - /* Address */ - if_sin = (struct sockaddr_in *) &ifp->ifa_addr; - if_sin->sin_addr.s_addr = ipt->table[ip_cnt].dwAddr; - if_sin->sin_family = AF_INET; - ifp->ifa_ifa.ifa_addr = (struct sockaddr *) &ifp->ifa_addr; - /* Netmask */ - if_sin = (struct sockaddr_in *) &ifp->ifa_netmask; - if_sin->sin_addr.s_addr = ipt->table[ip_cnt].dwMask; - if_sin->sin_family = AF_INET; - ifp->ifa_ifa.ifa_netmask = (struct sockaddr *) &ifp->ifa_netmask; - if_sin = (struct sockaddr_in *) &ifp->ifa_brddstaddr; - if (ifrow->dwType == IF_TYPE_PPP - || ifrow->dwType == IF_TYPE_SLIP) - { - /* Destination address */ - if_sin->sin_addr.s_addr = - get_routedst (ipt->table[ip_cnt].dwIndex); - ifp->ifa_ifa.ifa_dstaddr = (struct sockaddr *) - &ifp->ifa_brddstaddr; - } - else - { - /* Broadcast address */ -#if 0 - /* Unfortunately, the field returns only crap. */ - if_sin->sin_addr.s_addr = ipt->table[ip_cnt].dwBCastAddr; -#else - uint32_t mask = ipt->table[ip_cnt].dwMask; - if_sin->sin_addr.s_addr = (ipt->table[ip_cnt].dwAddr & mask) | ~mask; -#endif - ifp->ifa_ifa.ifa_broadaddr = (struct sockaddr *) - &ifp->ifa_brddstaddr; - } - if_sin->sin_family = AF_INET; - /* Hardware address */ - for (UINT i = 0; i < IFHWADDRLEN; ++i) - if (i >= ifrow->dwPhysAddrLen) - ifp->ifa_hwaddr.sa_data[i] = '\0'; - else - ifp->ifa_hwaddr.sa_data[i] = ifrow->bPhysAddr[i]; - /* Metric */ - ifp->ifa_metric = 1; - /* MTU */ - ifp->ifa_mtu = ifrow->dwMtu; - /* Interface index */ - ifp->ifa_ifindex = ifrow->dwIndex; - /* Friendly name */ - struct ifreq_frndlyname *iff = (struct ifreq_frndlyname *) - &ifp->ifa_frndlyname; - iff->ifrf_len = sys_wcstombs (iff->ifrf_friendlyname, - IFRF_FRIENDLYNAMESIZ, - ifrow->wszName); - ++ifp; - } - } - /* Since every entry is set to the next entry, the last entry points to an - invalid next entry now. Fix it retroactively. */ - if (ifp > ifret) - ifp[-1].ifa_ifa.ifa_next = NULL; - -done: - return ifret; -} - -/* - * Get network interfaces Windows NT < SP4: - * Look at the Bind value in - * HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Linkage\ - * This is a REG_MULTI_SZ with strings of the form: - * \Device\, where netcard is the name of the net device. - * Then look under: - * HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\\ - * Parameters\Tcpip - * at the IPAddress, Subnetmask and DefaultGateway values for the - * required values. - * Also fake "lo" since there's no representation in the registry. - */ -static struct ifall * -get_nt_ifs () -{ - HKEY key; - LONG ret; - struct ifall *ifret = NULL, *ifp; - unsigned long lip, lnp; - struct sockaddr_in *sin = NULL; - DWORD size; - int cnt = 0, idx; - char *binding = NULL; - - if ((ret = RegOpenKeyEx (HKEY_LOCAL_MACHINE, - "SYSTEM\\" - "CurrentControlSet\\" - "Services\\" - "Tcpip\\" "Linkage", - 0, KEY_READ, &key)) == ERROR_SUCCESS) - { - if ((ret = RegQueryValueEx (key, "Bind", NULL, NULL, - NULL, &size)) == ERROR_SUCCESS) - { - binding = (char *) alloca (size); - if ((ret = RegQueryValueEx (key, "Bind", NULL, NULL, - (unsigned char *) binding, - &size)) != ERROR_SUCCESS) - binding = NULL; - } - RegCloseKey (key); - } - - if (!binding) - { - __seterrno_from_win_error (ret); - return NULL; - } - - char *bp, eth[2] = "/"; - char cardkey[256], ipaddress[256], netmask[256]; - - for (bp = binding; *bp; bp += strlen (bp) + 1) - { - bp += strlen ("\\Device\\"); - strcpy (cardkey, "SYSTEM\\CurrentControlSet\\Services\\"); - strcat (cardkey, bp); - strcat (cardkey, "\\Parameters\\Tcpip"); - - if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, cardkey, - 0, KEY_READ, &key) != ERROR_SUCCESS) - continue; - - if (RegQueryValueEx (key, "IPAddress", - NULL, NULL, - (unsigned char *) ipaddress, - (size = 256, &size)) == ERROR_SUCCESS - && RegQueryValueEx (key, "SubnetMask", - NULL, NULL, - (unsigned char *) netmask, - (size = 256, &size)) == ERROR_SUCCESS) - ++cnt; - RegCloseKey (key); - } - ++cnt; /* loopback */ - if (!(ifret = (struct ifall *) malloc (cnt * sizeof (struct ifall)))) - return NULL; - /* Set up lo interface first */ - idx = 0; - ifp = ifret + idx; - memset (ifp, 0, sizeof *ifp); - /* Next in chain */ - ifp->ifa_ifa.ifa_next = (struct ifaddrs *) &ifp[1].ifa_ifa; - /* Interface name */ - strcpy (ifp->ifa_name, "lo"); - ifp->ifa_ifa.ifa_name = ifp->ifa_name; - /* Flags */ - ifp->ifa_ifa.ifa_flags = IFF_UP | IFF_LOWER_UP | IFF_RUNNING | IFF_LOOPBACK; - /* Address */ - sin = (struct sockaddr_in *) &ifp->ifa_addr; - sin->sin_addr.s_addr = htonl (INADDR_LOOPBACK); - sin->sin_family = AF_INET; - ifp->ifa_ifa.ifa_addr = (struct sockaddr *) &ifp->ifa_addr; - /* Netmask */ - sin = (struct sockaddr_in *) &ifp->ifa_netmask; - sin->sin_addr.s_addr = htonl (IN_CLASSA_NET); - sin->sin_family = AF_INET; - ifp->ifa_ifa.ifa_netmask = (struct sockaddr *) &ifp->ifa_netmask; - /* Broadcast address */ - sin = (struct sockaddr_in *) &ifp->ifa_brddstaddr; - sin->sin_addr.s_addr = htonl (INADDR_LOOPBACK | IN_CLASSA_HOST); - sin->sin_family = AF_INET; - ifp->ifa_ifa.ifa_broadaddr = (struct sockaddr *) &ifp->ifa_brddstaddr; - /* Hardware address */ - ; // Nothing to do... */ - /* Metric */ - ifp->ifa_metric = 1; - /* MTU */ - ifp->ifa_mtu = 1520; /* Default value for MS TCP Loopback interface. */ - /* Interface index */ - ifp->ifa_ifindex = -1; - /* Friendly name */ - struct ifreq_frndlyname *iff = (struct ifreq_frndlyname *) - &ifp->ifa_frndlyname; - strcpy (iff->ifrf_friendlyname, "Default loopback"); - iff->ifrf_len = 16; - - for (bp = binding; *bp; bp += strlen (bp) + 1) - { - bp += strlen ("\\Device\\"); - strcpy (cardkey, "SYSTEM\\CurrentControlSet\\Services\\"); - strcat (cardkey, bp); - strcat (cardkey, "\\Parameters\\Tcpip"); - - if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, cardkey, - 0, KEY_READ, &key) != ERROR_SUCCESS) - continue; - - if (RegQueryValueEx (key, "IPAddress", - NULL, NULL, - (unsigned char *) ipaddress, - (size = 256, &size)) == ERROR_SUCCESS - && RegQueryValueEx (key, "SubnetMask", - NULL, NULL, - (unsigned char *) netmask, - (size = 256, &size)) == ERROR_SUCCESS) - { - char *ip, *np; - char dhcpaddress[256], dhcpnetmask[256]; - bool ppp = false; - - for (ip = ipaddress, np = netmask; - *ip && *np; - ip += strlen (ip) + 1, np += strlen (np) + 1) - { - bool dhcp = false; - if (cygwin_inet_addr (ip) == 0L - && RegQueryValueEx (key, "DhcpIPAddress", - NULL, NULL, - (unsigned char *) dhcpaddress, - (size = 256, &size)) - == ERROR_SUCCESS - && RegQueryValueEx (key, "DhcpSubnetMask", - NULL, NULL, - (unsigned char *) dhcpnetmask, - (size = 256, &size)) - == ERROR_SUCCESS) - dhcp = true; - if (++idx == cnt - && !(ifp = (struct ifall *) - realloc (ifret, ++cnt * sizeof (struct ifall)))) - { - free (ifret); - return NULL; - } - ifp = ifret + idx; - memset (ifp, 0, sizeof *ifp); - /* Next in chain */ - ifp->ifa_ifa.ifa_next = (struct ifaddrs *) &ifp[1].ifa_ifa; - /* Interface name */ - if (!strncmp (bp, "NdisWan", 7)) - { - strcpy (ifp->ifa_name, "ppp"); - strcat (ifp->ifa_name, bp + 7); - ppp = true; - } - else - { - ++*eth; - strcpy (ifp->ifa_name, "eth"); - strcat (ifp->ifa_name, eth); - } - ifp->ifa_ifa.ifa_name = ifp->ifa_name; - /* Flags */ - ifp->ifa_ifa.ifa_flags = IFF_UP | IFF_LOWER_UP | IFF_RUNNING; - if (ppp) - ifp->ifa_ifa.ifa_flags |= IFF_POINTOPOINT | IFF_NOARP; - else - ifp->ifa_ifa.ifa_flags |= IFF_BROADCAST; - /* Address */ - sin = (struct sockaddr_in *) &ifp->ifa_addr; - sin->sin_addr.s_addr = cygwin_inet_addr (dhcp ? dhcpaddress : ip); - sin->sin_family = AF_INET; - ifp->ifa_ifa.ifa_addr = (struct sockaddr *) &ifp->ifa_addr; - /* Netmask */ - sin = (struct sockaddr_in *) &ifp->ifa_netmask; - sin->sin_addr.s_addr = cygwin_inet_addr (dhcp ? dhcpnetmask : np); - sin->sin_family = AF_INET; - ifp->ifa_ifa.ifa_netmask = (struct sockaddr *) &ifp->ifa_netmask; - if (ppp) - { - /* Destination address */ - sin = (struct sockaddr_in *) &ifp->ifa_brddstaddr; - sin->sin_addr.s_addr = - cygwin_inet_addr (dhcp ? dhcpaddress : ip); - sin->sin_family = AF_INET; - ifp->ifa_ifa.ifa_dstaddr = (struct sockaddr *) - &ifp->ifa_brddstaddr; - } - else - { - /* Broadcast address */ - lip = cygwin_inet_addr (dhcp ? dhcpaddress : ip); - lnp = cygwin_inet_addr (dhcp ? dhcpnetmask : np); - sin = (struct sockaddr_in *) &ifp->ifa_brddstaddr; - sin->sin_addr.s_addr = (lip & lnp) | ~lnp; - sin->sin_family = AF_INET; - ifp->ifa_ifa.ifa_broadaddr = (struct sockaddr *) - &ifp->ifa_brddstaddr; - } - /* Hardware address */ - ; // Nothing to do... */ - /* Metric */ - ifp->ifa_metric = 1; - /* MTU */ - ifp->ifa_mtu = 1500; - /* Interface index */ - ifp->ifa_ifindex = -1; - /* Friendly name */ - struct ifreq_frndlyname *iff = (struct ifreq_frndlyname *) - &ifp->ifa_frndlyname; - strcpy (iff->ifrf_friendlyname, bp); - iff->ifrf_len = strlen (iff->ifrf_friendlyname); - } - } - RegCloseKey (key); - } - /* Since every entry is set to the next entry, the last entry points to an - invalid next entry now. Fix it retroactively. */ - if (ifp > ifret) - ifp->ifa_ifa.ifa_next = NULL; - return ifret; -} - -extern "C" int -getifaddrs (struct ifaddrs **ifap) -{ - if (!ifap) - { - set_errno (EINVAL); - return -1; - } - struct ifall *ifp; - if (wincap.has_gaa_prefixes () && !CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ) - ifp = get_xp_ifs (AF_UNSPEC); - else if (wincap.has_ip_helper_lib ()) - ifp = get_2k_ifs (); - else - ifp = get_nt_ifs (); - *ifap = &ifp->ifa_ifa; - return ifp ? 0 : -1; -} - -extern "C" void -freeifaddrs (struct ifaddrs *ifp) -{ - if (ifp) - free (ifp); -} - -int -get_ifconf (struct ifconf *ifc, int what) -{ - sig_dispatch_pending (); - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - /* Ensure we have space for at least one struct ifreqs, fail if not. */ - if (ifc->ifc_len < (int) sizeof (struct ifreq)) - { - set_errno (EINVAL); - return -1; - } - - struct ifall *ifret, *ifp; - if (wincap.has_gaa_prefixes () && !CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ) - ifret = get_xp_ifs (AF_INET); - else if (wincap.has_ip_helper_lib ()) - ifret = get_2k_ifs (); - else - ifret = get_nt_ifs (); - if (!ifret) - return -1; - - struct sockaddr_in *sin; - struct ifreq *ifr = ifc->ifc_req; - int cnt = 0; - for (ifp = ifret; ifp; ifp = (struct ifall *) ifp->ifa_ifa.ifa_next) - { - ++cnt; - strcpy (ifr->ifr_name, ifp->ifa_name); - switch (what) - { - case SIOCGIFFLAGS: - ifr->ifr_flags = ifp->ifa_ifa.ifa_flags; - break; - case SIOCGIFCONF: - case SIOCGIFADDR: - sin = (struct sockaddr_in *) &ifr->ifr_addr; - memcpy (sin, &ifp->ifa_addr, sizeof *sin); - break; - case SIOCGIFNETMASK: - sin = (struct sockaddr_in *) &ifr->ifr_netmask; - memcpy (sin, &ifp->ifa_netmask, sizeof *sin); - break; - case SIOCGIFDSTADDR: - sin = (struct sockaddr_in *) &ifr->ifr_dstaddr; - if (ifp->ifa_ifa.ifa_flags & IFF_POINTOPOINT) - memcpy (sin, &ifp->ifa_brddstaddr, sizeof *sin); - else /* Return addr as on Linux. */ - memcpy (sin, &ifp->ifa_addr, sizeof *sin); - break; - case SIOCGIFBRDADDR: - sin = (struct sockaddr_in *) &ifr->ifr_broadaddr; - if (!(ifp->ifa_ifa.ifa_flags & IFF_POINTOPOINT)) - memcpy (sin, &ifp->ifa_brddstaddr, sizeof *sin); - else - { - sin->sin_addr.s_addr = INADDR_ANY; - sin->sin_family = AF_INET; - sin->sin_port = 0; - } - break; - case SIOCGIFHWADDR: - memcpy (&ifr->ifr_hwaddr, &ifp->ifa_hwaddr, sizeof ifr->ifr_hwaddr); - break; - case SIOCGIFMETRIC: - ifr->ifr_metric = ifp->ifa_metric; - break; - case SIOCGIFMTU: - ifr->ifr_mtu = ifp->ifa_mtu; - break; - case SIOCGIFINDEX: - ifr->ifr_ifindex = ifp->ifa_ifindex; - break; - case SIOCGIFFRNDLYNAM: - memcpy (ifr->ifr_frndlyname, &ifp->ifa_frndlyname, - sizeof (struct ifreq_frndlyname)); - } - if ((caddr_t) ++ifr > - ifc->ifc_buf + ifc->ifc_len - sizeof (struct ifreq)) - break; - } - /* Set the correct length */ - ifc->ifc_len = cnt * sizeof (struct ifreq); - free (ifret); - return 0; -} - -extern "C" unsigned -if_nametoindex (const char *name) -{ - PIP_ADAPTER_ADDRESSES pa0 = NULL, pap; - unsigned index = 0; - - myfault efault; - if (efault.faulted (EFAULT)) - return 0; - - if (wincap.has_gaa_prefixes () - && get_adapters_addresses (&pa0, AF_UNSPEC)) - { - char lname[IF_NAMESIZE], *c; - - lname[0] = '\0'; - strncat (lname, name, IF_NAMESIZE - 1); - if (lname[0] == '{' && (c = strchr (lname, ':'))) - *c = '\0'; - for (pap = pa0; pap; pap = pap->Next) - if (strcasematch (lname, pap->AdapterName)) - { - index = pap->Ipv6IfIndex ?: pap->IfIndex; - break; - } - free (pa0); - } - return index; -} - -extern "C" char * -if_indextoname (unsigned ifindex, char *ifname) -{ - PIP_ADAPTER_ADDRESSES pa0 = NULL, pap; - char *name = NULL; - - myfault efault; - if (efault.faulted (EFAULT)) - return NULL; - - if (wincap.has_gaa_prefixes () - && get_adapters_addresses (&pa0, AF_UNSPEC)) - { - for (pap = pa0; pap; pap = pap->Next) - if (ifindex == (pap->Ipv6IfIndex ?: pap->IfIndex)) - { - /* Unfortunately the pre-Vista IPv6 stack has a distinct loopback - device with the same Ipv6IfIndex as the IfIndex of the IPv4 - loopback device, but with a different adapter name. - For consistency with /proc/net/if_inet6, try to find the - IPv6 loopback device and use that adapter name instead. - We identify the loopback device by its IfIndex of 1. */ - if (pap->IfIndex == 1 && pap->Ipv6IfIndex == 0) - for (PIP_ADAPTER_ADDRESSES pap2 = pa0; pap2; pap2 = pap2->Next) - if (pap2->Ipv6IfIndex == 1) - { - pap = pap2; - break; - } - name = strcpy (ifname, pap->AdapterName); - break; - } - free (pa0); - } - else - set_errno (ENXIO); - return name; -} - -extern "C" struct if_nameindex * -if_nameindex (void) -{ - PIP_ADAPTER_ADDRESSES pa0 = NULL, pap; - struct if_nameindex *iflist = NULL; - char (*ifnamelist)[IF_NAMESIZE]; - - myfault efault; - if (efault.faulted (EFAULT)) - return NULL; - - if (wincap.has_gaa_prefixes () - && get_adapters_addresses (&pa0, AF_UNSPEC)) - { - int cnt = 0; - for (pap = pa0; pap; pap = pap->Next) - ++cnt; - iflist = (struct if_nameindex *) - malloc ((cnt + 1) * sizeof (struct if_nameindex) - + cnt * IF_NAMESIZE); - if (!iflist) - set_errno (ENOBUFS); - else - { - ifnamelist = (char (*)[IF_NAMESIZE]) (iflist + cnt + 1); - for (pap = pa0, cnt = 0; pap; pap = pap->Next) - { - for (int i = 0; i < cnt; ++i) - if (iflist[i].if_index == (pap->Ipv6IfIndex ?: pap->IfIndex)) - goto outer_loop; - iflist[cnt].if_index = pap->Ipv6IfIndex ?: pap->IfIndex; - strcpy (iflist[cnt].if_name = ifnamelist[cnt], pap->AdapterName); - /* See comment in if_indextoname. */ - if (pap->IfIndex == 1 && pap->Ipv6IfIndex == 0) - for (PIP_ADAPTER_ADDRESSES pap2 = pa0; pap2; pap2 = pap2->Next) - if (pap2->Ipv6IfIndex == 1) - { - strcpy (ifnamelist[cnt], pap2->AdapterName); - break; - } - ++cnt; - outer_loop: - ; - } - iflist[cnt].if_index = 0; - iflist[cnt].if_name = NULL; - } - free (pa0); - } - else - set_errno (ENXIO); - return iflist; -} - -extern "C" void -if_freenameindex (struct if_nameindex *ptr) -{ - myfault efault; - if (efault.faulted (EFAULT)) - return; - free (ptr); -} - -#define PORT_LOW (IPPORT_EFSSERVER + 1) -#define PORT_HIGH (IPPORT_RESERVED - 1) -#define NUM_PORTS (PORT_HIGH - PORT_LOW + 1) - -extern "C" int -cygwin_bindresvport_sa (int fd, struct sockaddr *sa) -{ - struct sockaddr_storage sst; - struct sockaddr_in *sin = NULL; - struct sockaddr_in6 *sin6 = NULL; - in_port_t port; - socklen_t salen; - int ret; - - sig_dispatch_pending (); - - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - fhandler_socket *fh = get (fd); - if (!fh) - return -1; - - if (!sa) - { - sa = (struct sockaddr *) &sst; - memset (&sst, 0, sizeof sst); - sa->sa_family = fh->get_addr_family (); - } - - switch (sa->sa_family) - { - case AF_INET: - salen = sizeof (struct sockaddr_in); - sin = (struct sockaddr_in *) sa; - port = sin->sin_port; - break; - case AF_INET6: - salen = sizeof (struct sockaddr_in6); - sin6 = (struct sockaddr_in6 *) sa; - port = sin6->sin6_port; - break; - default: - set_errno (EPFNOSUPPORT); - return -1; - } - - /* If a non-zero port number is given, try this first. If that succeeds, - or if the error message is serious, return. */ - if (port) - { - ret = fh->bind (sa, salen); - if (!ret || (get_errno () != EADDRINUSE && get_errno () != EINVAL)) - return ret; - } - - LONG myport; - - for (int i = 0; i < NUM_PORTS; i++) - { - while ((myport = InterlockedExchange (&cygwin_shared->last_used_bindresvport, -1)) == -1) - low_priority_sleep (0); - if (myport == 0 || --myport < PORT_LOW) - myport = PORT_HIGH; - InterlockedExchange (&cygwin_shared->last_used_bindresvport, myport); - - if (sa->sa_family == AF_INET6) - sin6->sin6_port = htons (myport); - else - sin->sin_port = htons (myport); - if (!(ret = fh->bind (sa, salen))) - break; - if (get_errno () != EADDRINUSE && get_errno () != EINVAL) - break; - } - - return ret; -} - -extern "C" int -cygwin_bindresvport (int fd, struct sockaddr_in *sin) -{ - return cygwin_bindresvport_sa (fd, (struct sockaddr *) sin); -} - -/* socketpair: standards? */ -/* Win32 supports AF_INET only, so ignore domain and protocol arguments */ -extern "C" int -socketpair (int family, int type, int protocol, int *sb) -{ - int res = -1; - SOCKET insock, outsock, newsock; - struct sockaddr_in sock_in, sock_out; - int len; - - sig_dispatch_pending (); - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - int flags = type & _SOCK_FLAG_MASK; - type &= ~_SOCK_FLAG_MASK; - - if (family != AF_LOCAL && family != AF_INET) - { - set_errno (EAFNOSUPPORT); - goto done; - } - if (type != SOCK_STREAM && type != SOCK_DGRAM) - { - set_errno (EPROTOTYPE); - goto done; - } - if ((flags & ~(SOCK_NONBLOCK | SOCK_CLOEXEC)) != 0) - { - set_errno (EINVAL); - goto done; - } - if ((family == AF_LOCAL && protocol != PF_UNSPEC && protocol != PF_LOCAL) - || (family == AF_INET && protocol != PF_UNSPEC && protocol != PF_INET)) - { - set_errno (EPROTONOSUPPORT); - goto done; - } - - /* create the first socket */ - newsock = socket (AF_INET, type, 0); - if (newsock == INVALID_SOCKET) - { - debug_printf ("first socket call failed"); - set_winsock_errno (); - goto done; - } - - /* bind the socket to any unused port */ - sock_in.sin_family = AF_INET; - sock_in.sin_port = 0; - sock_in.sin_addr.s_addr = INADDR_ANY; - if (bind (newsock, (struct sockaddr *) &sock_in, sizeof (sock_in)) < 0) - { - debug_printf ("bind failed"); - set_winsock_errno (); - closesocket (newsock); - goto done; - } - len = sizeof (sock_in); - if (getsockname (newsock, (struct sockaddr *) &sock_in, &len) < 0) - { - debug_printf ("getsockname error"); - set_winsock_errno (); - closesocket (newsock); - goto done; - } - - /* For stream sockets, create a listener */ - if (type == SOCK_STREAM) - listen (newsock, 2); - - /* create a connecting socket */ - outsock = socket (AF_INET, type, 0); - if (outsock == INVALID_SOCKET) - { - debug_printf ("second socket call failed"); - set_winsock_errno (); - closesocket (newsock); - goto done; - } - - /* For datagram sockets, bind the 2nd socket to an unused address, too */ - if (type == SOCK_DGRAM) - { - sock_out.sin_family = AF_INET; - sock_out.sin_port = 0; - sock_out.sin_addr.s_addr = htonl (INADDR_LOOPBACK); - if (bind (outsock, (struct sockaddr *) &sock_out, sizeof (sock_out)) < 0) - { - debug_printf ("bind failed"); - set_winsock_errno (); - closesocket (newsock); - closesocket (outsock); - goto done; - } - len = sizeof (sock_out); - if (getsockname (outsock, (struct sockaddr *) &sock_out, &len) < 0) - { - debug_printf ("getsockname error"); - set_winsock_errno (); - closesocket (newsock); - closesocket (outsock); - goto done; - } - } - - /* Force IP address to loopback */ - sock_in.sin_addr.s_addr = htonl (INADDR_LOOPBACK); - if (type == SOCK_DGRAM) - sock_out.sin_addr.s_addr = htonl (INADDR_LOOPBACK); - - /* Do a connect */ - if (connect (outsock, (struct sockaddr *) &sock_in, sizeof (sock_in)) < 0) - { - debug_printf ("connect error"); - set_winsock_errno (); - closesocket (newsock); - closesocket (outsock); - goto done; - } - - if (type == SOCK_STREAM) - { - /* For stream sockets, accept the connection and close the listener */ - len = sizeof (sock_in); - insock = accept (newsock, (struct sockaddr *) &sock_in, &len); - if (insock == INVALID_SOCKET) - { - debug_printf ("accept error"); - set_winsock_errno (); - closesocket (newsock); - closesocket (outsock); - goto done; - } - closesocket (newsock); - } - else - { - /* For datagram sockets, connect the 2nd socket */ - if (connect (newsock, (struct sockaddr *) &sock_out, - sizeof (sock_out)) < 0) - { - debug_printf ("connect error"); - set_winsock_errno (); - closesocket (newsock); - closesocket (outsock); - goto done; - } - insock = newsock; - } - - { - cygheap_fdnew sb0; - const device *dev; - - if (family == AF_INET) - dev = (type == SOCK_STREAM ? tcp_dev : udp_dev); - else - dev = (type == SOCK_STREAM ? stream_dev : dgram_dev); - - if (sb0 >= 0 && fdsock (sb0, dev, insock)) - { - ((fhandler_socket *) sb0)->set_addr_family (family); - ((fhandler_socket *) sb0)->set_socket_type (type); - ((fhandler_socket *) sb0)->connect_state (connected); - if (flags & SOCK_NONBLOCK) - ((fhandler_socket *) sb0)->set_nonblocking (true); - if (flags & SOCK_CLOEXEC) - ((fhandler_socket *) sb0)->set_close_on_exec (true); - if (family == AF_LOCAL && type == SOCK_STREAM) - ((fhandler_socket *) sb0)->af_local_set_sockpair_cred (); - - cygheap_fdnew sb1 (sb0, false); - - if (sb1 >= 0 && fdsock (sb1, dev, outsock)) - { - ((fhandler_socket *) sb1)->set_addr_family (family); - ((fhandler_socket *) sb1)->set_socket_type (type); - ((fhandler_socket *) sb1)->connect_state (connected); - if (flags & SOCK_NONBLOCK) - ((fhandler_socket *) sb1)->set_nonblocking (true); - if (flags & SOCK_CLOEXEC) - ((fhandler_socket *) sb1)->set_close_on_exec (true); - if (family == AF_LOCAL && type == SOCK_STREAM) - ((fhandler_socket *) sb1)->af_local_set_sockpair_cred (); - - sb[0] = sb0; - sb[1] = sb1; - res = 0; - } - } - - if (res == -1) - { - closesocket (insock); - closesocket (outsock); - } - } - -done: - syscall_printf ("%d = socketpair (...)", res); - return res; -} - -/* sethostent: standards? */ -extern "C" void -sethostent (int) -{ -} - -/* endhostent: standards? */ -extern "C" void -endhostent (void) -{ -} - -/* exported as recvmsg: standards? */ -extern "C" int -cygwin_recvmsg (int fd, struct msghdr *msg, int flags) -{ - int res; - - fhandler_socket *fh = get (fd); - - myfault efault; - if (efault.faulted (EFAULT) || !fh) - res = -1; - else - { - res = check_iovec_for_read (msg->msg_iov, msg->msg_iovlen); - if (res > 0) - res = fh->recvmsg (msg, flags); - } - - syscall_printf ("%d = recvmsg (%d, %p, %x)", res, fd, msg, flags); - return res; -} - -/* exported as sendmsg: standards? */ -extern "C" int -cygwin_sendmsg (int fd, const struct msghdr *msg, int flags) -{ - int res; - - fhandler_socket *fh = get (fd); - - myfault efault; - if (efault.faulted (EFAULT) || !fh) - res = -1; - else - { - res = check_iovec_for_write (msg->msg_iov, msg->msg_iovlen); - if (res >= 0) - res = fh->sendmsg (msg, flags); - } - - syscall_printf ("%d = sendmsg (%d, %p, %x)", res, fd, msg, flags); - return res; -} - -/* This is from the BIND 4.9.4 release, modified to compile by itself */ - -/* Copyright (c) 1996 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -/* int - * inet_pton4(src, dst) - * like inet_aton() but without all the hexadecimal and shorthand. - * return: - * 1 if `src' is a valid dotted quad, else 0. - * notice: - * does not touch `dst' unless it's returning 1. - * author: - * Paul Vixie, 1996. - */ -static int -inet_pton4 (const char *src, u_char *dst) -{ - static const char digits[] = "0123456789"; - int saw_digit, octets, ch; - u_char tmp[INADDRSZ], *tp; - - saw_digit = 0; - octets = 0; - *(tp = tmp) = 0; - while ((ch = *src++) != '\0') - { - const char *pch; - - if ((pch = strchr(digits, ch)) != NULL) - { - u_int ret = *tp * 10 + (pch - digits); - - if (ret > 255) - return (0); - *tp = ret; - if (! saw_digit) - { - if (++octets > 4) - return (0); - saw_digit = 1; - } - } - else if (ch == '.' && saw_digit) - { - if (octets == 4) - return (0); - *++tp = 0; - saw_digit = 0; - } - else - return (0); - } - if (octets < 4) - return (0); - - memcpy(dst, tmp, INADDRSZ); - return (1); -} - -/* int - * inet_pton6(src, dst) - * convert presentation level address to network order binary form. - * return: - * 1 if `src' is a valid [RFC1884 2.2] address, else 0. - * notice: - * (1) does not touch `dst' unless it's returning 1. - * (2) :: in a full address is silently ignored. - * credit: - * inspired by Mark Andrews. - * author: - * Paul Vixie, 1996. - */ -static int -inet_pton6 (const char *src, u_char *dst) -{ - static const char xdigits_l[] = "0123456789abcdef", - xdigits_u[] = "0123456789ABCDEF"; - u_char tmp[IN6ADDRSZ], *tp, *endp, *colonp; - const char *xdigits, *curtok; - int ch, saw_xdigit; - u_int val; - - memset((tp = tmp), 0, IN6ADDRSZ); - endp = tp + IN6ADDRSZ; - colonp = NULL; - /* Leading :: requires some special handling. */ - if (*src == ':') - if (*++src != ':') - return (0); - curtok = src; - saw_xdigit = 0; - val = 0; - while ((ch = *src++) != '\0') - { - const char *pch; - - if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) - pch = strchr((xdigits = xdigits_u), ch); - if (pch != NULL) - { - val <<= 4; - val |= (pch - xdigits); - if (val > 0xffff) - return (0); - saw_xdigit = 1; - continue; - } - if (ch == ':') - { - curtok = src; - if (!saw_xdigit) - { - if (colonp) - return (0); - colonp = tp; - continue; - } - if (tp + INT16SZ > endp) - return (0); - *tp++ = (u_char) (val >> 8) & 0xff; - *tp++ = (u_char) val & 0xff; - saw_xdigit = 0; - val = 0; - continue; - } - if (ch == '.' && ((tp + INADDRSZ) <= endp) && inet_pton4(curtok, tp) > 0) - { - tp += INADDRSZ; - saw_xdigit = 0; - break; /* '\0' was seen by inet_pton4(). */ - } - return (0); - } - if (saw_xdigit) - { - if (tp + INT16SZ > endp) - return (0); - *tp++ = (u_char) (val >> 8) & 0xff; - *tp++ = (u_char) val & 0xff; - } - if (colonp != NULL) - { - /* - * Since some memmove()'s erroneously fail to handle - * overlapping regions, we'll do the shift by hand. - */ - const int n = tp - colonp; - int i; - - for (i = 1; i <= n; i++) - { - endp[- i] = colonp[n - i]; - colonp[n - i] = 0; - } - tp = endp; - } - if (tp != endp) - return (0); - - memcpy(dst, tmp, IN6ADDRSZ); - return (1); -} - -/* int - * inet_pton(af, src, dst) - * convert from presentation format (which usually means ASCII printable) - * to network format (which is usually some kind of binary format). - * return: - * 1 if the address was valid for the specified address family - * 0 if the address wasn't valid (`dst' is untouched in this case) - * -1 if some other error occurred (`dst' is untouched in this case, too) - * author: - * Paul Vixie, 1996. - */ -extern "C" int -cygwin_inet_pton (int af, const char *src, void *dst) -{ - switch (af) - { - case AF_INET: - return (inet_pton4(src, (u_char *) dst)); - case AF_INET6: - return (inet_pton6(src, (u_char *) dst)); - default: - errno = EAFNOSUPPORT; - return (-1); - } - /* NOTREACHED */ -} - -/* const char * - * inet_ntop4(src, dst, size) - * format an IPv4 address, more or less like inet_ntoa() - * return: - * `dst' (as a const) - * notes: - * (1) uses no statics - * (2) takes a u_char* not an in_addr as input - * author: - * Paul Vixie, 1996. - */ -static const char * -inet_ntop4 (const u_char *src, char *dst, size_t size) -{ - static const char fmt[] = "%u.%u.%u.%u"; - char tmp[sizeof "255.255.255.255"]; - - __small_sprintf(tmp, fmt, src[0], src[1], src[2], src[3]); - if (strlen(tmp) > size) - { - errno = ENOSPC; - return (NULL); - } - strcpy(dst, tmp); - return (dst); -} - -/* const char * - * inet_ntop6(src, dst, size) - * convert IPv6 binary address into presentation (printable) format - * author: - * Paul Vixie, 1996. - */ -static const char * -inet_ntop6 (const u_char *src, char *dst, size_t size) -{ - /* - * Note that int32_t and int16_t need only be "at least" large enough - * to contain a value of the specified size. On some systems, like - * Crays, there is no such thing as an integer variable with 16 bits. - * Keep this in mind if you think this function should have been coded - * to use pointer overlays. All the world's not a VAX. - */ - char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp; - struct { int base, len; } best, cur; - u_int words[IN6ADDRSZ / INT16SZ]; - int i; - - /* - * Preprocess: - * Copy the input (bytewise) array into a wordwise array. - * Find the longest run of 0x00's in src[] for :: shorthanding. - */ - memset(words, 0, sizeof words); - for (i = 0; i < IN6ADDRSZ; i++) - words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3)); - best.base = -1; - cur.base = -1; - for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) - { - if (words[i] == 0) - { - if (cur.base == -1) - cur.base = i, cur.len = 1; - else - cur.len++; - } - else - { - if (cur.base != -1) - { - if (best.base == -1 || cur.len > best.len) - best = cur; - cur.base = -1; - } - } - } - if (cur.base != -1) - { - if (best.base == -1 || cur.len > best.len) - best = cur; - } - if (best.base != -1 && best.len < 2) - best.base = -1; - - /* - * Format the result. - */ - tp = tmp; - for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) - { - /* Are we inside the best run of 0x00's? */ - if (best.base != -1 && i >= best.base && i < (best.base + best.len)) - { - if (i == best.base) - *tp++ = ':'; - continue; - } - /* Are we following an initial run of 0x00s or any real hex? */ - if (i != 0) - *tp++ = ':'; - /* Is this address an encapsulated IPv4? */ - if (i == 6 && best.base == 0 && - (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) - { - if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp))) - return (NULL); - tp += strlen(tp); - break; - } - __small_sprintf(tp, "%x", words[i]); - while (*tp) - { - if (isupper (*tp)) - *tp = _tolower (*tp); - ++tp; - } - } - /* Was it a trailing run of 0x00's? */ - if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ)) - *tp++ = ':'; - *tp++ = '\0'; - - /* - * Check for overflow, copy, and we're done. - */ - if ((size_t) (tp - tmp) > size) - { - errno = ENOSPC; - return (NULL); - } - strcpy(dst, tmp); - return (dst); -} - -/* char * - * inet_ntop(af, src, dst, size) - * convert a network format address to presentation format. - * return: - * pointer to presentation format address (`dst'), or NULL (see errno). - * author: - * Paul Vixie, 1996. - */ -extern "C" const char * -cygwin_inet_ntop (int af, const void *src, char *dst, socklen_t size) -{ - switch (af) - { - case AF_INET: - return (inet_ntop4((const u_char *) src, dst, size)); - case AF_INET6: - return (inet_ntop6((const u_char *) src, dst, size)); - default: - errno = EAFNOSUPPORT; - return (NULL); - } - /* NOTREACHED */ -} - -/* W. Richard STEVENS libgai implementation, slightly tweaked for inclusion - into Cygwin as pure IPv4 replacement. Please note that the code is - kept intact as much as possible. Especially the IPv6 and AF_UNIX code - is kept in, even though we can support neither of them. Please don't - activate them, they won't work correctly. */ - -#define IPv4 -#undef IPv6 -#undef UNIXdomain - -#undef HAVE_SOCKADDR_SA_LEN -#define gethostbyname2(host,family) cygwin_gethostbyname((host)) - -#define AI_CLONE 0x8000 /* Avoid collision with AI_ values in netdb.h */ - -/* - * Create and fill in an addrinfo{}. - */ - -/* include ga_aistruct1 */ -static int -ga_aistruct (struct addrinfo ***paipnext, const struct addrinfo *hintsp, - const void *addr, int family) -{ - struct addrinfo *ai; - - if ((ai = (struct addrinfo *) calloc (1, sizeof (struct addrinfo))) == NULL) - return (EAI_MEMORY); - ai->ai_next = NULL; - ai->ai_canonname = NULL; - **paipnext = ai; - *paipnext = &ai->ai_next; - - if ((ai->ai_socktype = hintsp->ai_socktype) == 0) - ai->ai_flags |= AI_CLONE; - - ai->ai_protocol = hintsp->ai_protocol; -/* end ga_aistruct1 */ - -/* include ga_aistruct2 */ - switch ((ai->ai_family = family)) - { -#ifdef IPv4 - case AF_INET: - { - struct sockaddr_in *sinptr; - - /* 4allocate sockaddr_in{} and fill in all but port */ - if ((sinptr = (struct sockaddr_in *) - calloc (1, sizeof (struct sockaddr_in))) == NULL) - return (EAI_MEMORY); -#ifdef HAVE_SOCKADDR_SA_LEN - sinptr->sin_len = sizeof (struct sockaddr_in); -#endif - sinptr->sin_family = AF_INET; - memcpy (&sinptr->sin_addr, addr, sizeof (struct in_addr)); - ai->ai_addr = (struct sockaddr *) sinptr; - ai->ai_addrlen = sizeof (struct sockaddr_in); - break; - } -#endif /* IPV4 */ -#ifdef IPv6 - case AF_INET6: - { - struct sockaddr_in6 *sin6ptr; - - /* 4allocate sockaddr_in6{} and fill in all but port */ - if ((sin6ptr = calloc (1, sizeof (struct sockaddr_in6))) == NULL) - return (EAI_MEMORY); -#ifdef HAVE_SOCKADDR_SA_LEN - sin6ptr->sin6_len = sizeof (struct sockaddr_in6); -#endif - sin6ptr->sin6_family = AF_INET6; - memcpy (&sin6ptr->sin6_addr, addr, sizeof (struct in6_addr)); - ai->ai_addr = (struct sockaddr *) sin6ptr; - ai->ai_addrlen = sizeof (struct sockaddr_in6); - break; - } -#endif /* IPV6 */ -#ifdef UNIXdomain - case AF_LOCAL: - { - struct sockaddr_un *unp; - - /* 4allocate sockaddr_un{} and fill in */ -/* *INDENT-OFF* */ - if (strlen(addr) >= sizeof(unp->sun_path)) - return(EAI_SERVICE); - if ( (unp = calloc(1, sizeof(struct sockaddr_un))) == NULL) - return(EAI_MEMORY); -/* *INDENT-ON* */ - unp->sun_family = AF_LOCAL; - strcpy (unp->sun_path, addr); -#ifdef HAVE_SOCKADDR_SA_LEN - unp->sun_len = SUN_LEN (unp); -#endif - ai->ai_addr = (struct sockaddr *) unp; - ai->ai_addrlen = sizeof (struct sockaddr_un); - if (hintsp->ai_flags & AI_PASSIVE) - unlink (unp->sun_path); /* OK if this fails */ - break; - } -#endif /* UNIXDOMAIN */ - } - return (0); -} - -/* end ga_aistruct2 */ - -/* - * Clone a new addrinfo structure from an existing one. - */ - -/* include ga_clone */ - -/* Cygwin specific: The ga_clone function is split up to allow an easy - duplication of addrinfo structs. This is used to duplicate the - structures from Winsock, so that we have the allocation of the structs - returned to the application under control. This is especially helpful - for the AI_V4MAPPED case prior to Vista. */ -static struct addrinfo * -ga_dup (struct addrinfo *ai, bool v4mapped) -{ - struct addrinfo *nai; - - if ((nai = (struct addrinfo *) calloc (1, sizeof (struct addrinfo))) == NULL) - return (NULL); - - nai->ai_flags = 0; /* make sure AI_CLONE is off */ - nai->ai_family = v4mapped ? AF_INET6 : ai->ai_family; - nai->ai_socktype = ai->ai_socktype; - nai->ai_protocol = ai->ai_protocol; - nai->ai_canonname = NULL; - if (!(ai->ai_flags & AI_CLONE) && ai->ai_canonname - && !(nai->ai_canonname = strdup (ai->ai_canonname))) - { - free (nai); - return NULL; - } - nai->ai_addrlen = v4mapped ? sizeof (struct sockaddr_in6) : ai->ai_addrlen; - if ((nai->ai_addr = (struct sockaddr *) malloc (v4mapped - ? sizeof (struct sockaddr_in6) - : ai->ai_addrlen)) == NULL) - { - if (nai->ai_canonname) - free (nai->ai_canonname); - free (nai); - return NULL; - } - if (v4mapped) - { - struct sockaddr_in6 *in = (struct sockaddr_in6 *) nai->ai_addr; - in->sin6_family = AF_INET6; - in->sin6_port = ((struct sockaddr_in *) ai->ai_addr)->sin_port; - in->sin6_flowinfo = 0; - in->sin6_addr.s6_addr32[0] = 0; - in->sin6_addr.s6_addr32[1] = 0; - in->sin6_addr.s6_addr32[2] = htonl (0xffff); - in->sin6_addr.s6_addr32[3] = ((struct sockaddr_in *) ai->ai_addr)->sin_addr.s_addr; - in->sin6_scope_id = 0; - } - else - memcpy (nai->ai_addr, ai->ai_addr, ai->ai_addrlen); - - return nai; -} - -static struct addrinfo * -ga_clone (struct addrinfo *ai) -{ - struct addrinfo *nai; - - if ((nai = ga_dup (ai, false))) - { - nai->ai_next = ai->ai_next; - ai->ai_next = nai; - } - return nai; -} - -static struct addrinfo * -ga_duplist (struct addrinfo *ai, bool v4mapped) -{ - void ipv4_freeaddrinfo (struct addrinfo *aihead); - struct addrinfo *tmp, *nai = NULL, *nai0 = NULL; - - for (; ai; ai = ai->ai_next, nai = tmp) - { - if (!(tmp = ga_dup (ai, v4mapped))) - goto bad; - if (!nai0) - nai0 = tmp; - if (nai) - nai->ai_next = tmp; - } - return nai0; - -bad: - ipv4_freeaddrinfo (nai0); - return NULL; -} - -/* end ga_clone */ - -/* - * Basic error checking of flags, family, socket type, and protocol. - */ - -/* include ga_echeck */ -static int -ga_echeck (const char *hostname, const char *servname, - int flags, int family, int socktype, int protocol) -{ -#if 0 - if (flags & ~(AI_PASSIVE | AI_CANONNAME)) - return (EAI_BADFLAGS); /* unknown flag bits */ -#endif - if (hostname == NULL || hostname[0] == '\0') - { - if (servname == NULL || servname[0] == '\0') - return (EAI_NONAME); /* host or service must be specified */ - } - - switch (family) - { - case AF_UNSPEC: - break; -#ifdef IPv4 - case AF_INET: - if (socktype != 0 && - (socktype != SOCK_STREAM && - socktype != SOCK_DGRAM && socktype != SOCK_RAW)) - return (EAI_SOCKTYPE); /* invalid socket type */ - break; -#endif -#ifdef IPv6 - case AF_INET6: - if (socktype != 0 && - (socktype != SOCK_STREAM && - socktype != SOCK_DGRAM && socktype != SOCK_RAW)) - return (EAI_SOCKTYPE); /* invalid socket type */ - break; -#endif -#ifdef UNIXdomain - case AF_LOCAL: - if (socktype != 0 && - (socktype != SOCK_STREAM && socktype != SOCK_DGRAM)) - return (EAI_SOCKTYPE); /* invalid socket type */ - break; -#endif - default: - return (EAI_FAMILY); /* unknown protocol family */ - } - return (0); -} - -/* end ga_echeck */ - -struct search { - const char *host; /* hostname or address string */ - int family; /* AF_xxx */ -}; - -/* - * Set up the search[] array with the hostnames and address families - * that we are to look up. - */ - -/* include ga_nsearch1 */ -static int -ga_nsearch (const char *hostname, const struct addrinfo *hintsp, - struct search *search) -{ - int nsearch = 0; - - if (hostname == NULL || hostname[0] == '\0') - { - if (hintsp->ai_flags & AI_PASSIVE) - { - /* 4no hostname and AI_PASSIVE: implies wildcard bind */ - switch (hintsp->ai_family) - { -#ifdef IPv4 - case AF_INET: - search[nsearch].host = "0.0.0.0"; - search[nsearch].family = AF_INET; - nsearch++; - break; -#endif -#ifdef IPv6 - case AF_INET6: - search[nsearch].host = "0::0"; - search[nsearch].family = AF_INET6; - nsearch++; - break; -#endif - case AF_UNSPEC: -#ifdef IPv6 - search[nsearch].host = "0::0"; /* IPv6 first, then IPv4 */ - search[nsearch].family = AF_INET6; - nsearch++; -#endif -#ifdef IPv4 - search[nsearch].host = "0.0.0.0"; - search[nsearch].family = AF_INET; - nsearch++; -#endif - break; - } -/* end ga_nsearch1 */ -/* include ga_nsearch2 */ - } - else - { - /* 4no host and not AI_PASSIVE: connect to local host */ - switch (hintsp->ai_family) - { -#ifdef IPv4 - case AF_INET: - search[nsearch].host = "localhost"; /* 127.0.0.1 */ - search[nsearch].family = AF_INET; - nsearch++; - break; -#endif -#ifdef IPv6 - case AF_INET6: - search[nsearch].host = "0::1"; - search[nsearch].family = AF_INET6; - nsearch++; - break; -#endif - case AF_UNSPEC: -#ifdef IPv6 - search[nsearch].host = "0::1"; /* IPv6 first, then IPv4 */ - search[nsearch].family = AF_INET6; - nsearch++; -#endif -#ifdef IPv4 - search[nsearch].host = "localhost"; - search[nsearch].family = AF_INET; - nsearch++; -#endif - break; - } - } -/* end ga_nsearch2 */ -/* include ga_nsearch3 */ - } - else - { /* host is specified */ - switch (hintsp->ai_family) - { -#ifdef IPv4 - case AF_INET: - search[nsearch].host = hostname; - search[nsearch].family = AF_INET; - nsearch++; - break; -#endif -#ifdef IPv6 - case AF_INET6: - search[nsearch].host = hostname; - search[nsearch].family = AF_INET6; - nsearch++; - break; -#endif - case AF_UNSPEC: -#ifdef IPv6 - search[nsearch].host = hostname; - search[nsearch].family = AF_INET6; /* IPv6 first */ - nsearch++; -#endif -#ifdef IPv4 - search[nsearch].host = hostname; - search[nsearch].family = AF_INET; /* then IPv4 */ - nsearch++; -#endif - break; - } - } - if (nsearch < 1 || nsearch > 2) - return -1; - return (nsearch); -} - -/* end ga_nsearch3 */ - -/* - * Go through all the addrinfo structures, checking for a match of the - * socket type and filling in the socket type, and then the port number - * in the corresponding socket address structures. - * - * The AI_CLONE flag works as follows. Consider a multihomed host with - * two IP addresses and no socket type specified by the caller. After - * the "host" search there are two addrinfo structures, one per IP address. - * Assuming a service supported by both TCP and UDP (say the daytime - * service) we need to return *four* addrinfo structures: - * IP#1, SOCK_STREAM, TCP port, - * IP#1, SOCK_DGRAM, UDP port, - * IP#2, SOCK_STREAM, TCP port, - * IP#2, SOCK_DGRAM, UDP port. - * To do this, when the "host" loop creates an addrinfo structure, if the - * caller has not specified a socket type (hintsp->ai_socktype == 0), the - * AI_CLONE flag is set. When the following function finds an entry like - * this it is handled as follows: If the entry's ai_socktype is still 0, - * this is the first use of the structure, and the ai_socktype field is set. - * But, if the entry's ai_socktype is nonzero, then we clone a new addrinfo - * structure and set it's ai_socktype to the new value. Although we only - * need two socket types today (SOCK_STREAM and SOCK_DGRAM) this algorithm - * will handle any number. Also notice that Posix.1g requires all socket - * types to be nonzero. - */ - -/* include ga_port */ -static int -ga_port (struct addrinfo *aihead, int port, int socktype) - /* port must be in network byte order */ -{ - int nfound = 0; - struct addrinfo *ai; - - for (ai = aihead; ai != NULL; ai = ai->ai_next) - { - if (ai->ai_flags & AI_CLONE) - { - if (ai->ai_socktype != 0) - { - if ((ai = ga_clone (ai)) == NULL) - return (-1); /* memory allocation error */ - /* ai points to newly cloned entry, which is what we want */ - } - } - else if (ai->ai_socktype != socktype) - continue; /* ignore if mismatch on socket type */ - - ai->ai_socktype = socktype; - - switch (ai->ai_family) - { -#ifdef IPv4 - case AF_INET: - ((struct sockaddr_in *) ai->ai_addr)->sin_port = port; - nfound++; - break; -#endif -#ifdef IPv6 - case AF_INET6: - ((struct sockaddr_in6 *) ai->ai_addr)->sin6_port = port; - nfound++; - break; -#endif - } - } - return (nfound); -} - -/* end ga_port */ - -/* - * This function handles the service string. - */ - -/* include ga_serv */ -static int -ga_serv (struct addrinfo *aihead, const struct addrinfo *hintsp, - const char *serv) -{ - int port, rc, nfound; - struct servent *sptr; - - nfound = 0; - if (isdigit (serv[0])) - { /* check for port number string first */ - port = htons (atoi (serv)); - if (hintsp->ai_socktype) - { - /* 4caller specifies socket type */ - if ((rc = ga_port (aihead, port, hintsp->ai_socktype)) < 0) - return (EAI_MEMORY); - nfound += rc; - } - else - { - /* 4caller does not specify socket type */ - if ((rc = ga_port (aihead, port, SOCK_STREAM)) < 0) - return (EAI_MEMORY); - nfound += rc; - if ((rc = ga_port (aihead, port, SOCK_DGRAM)) < 0) - return (EAI_MEMORY); - nfound += rc; - } - } - else - { - /* 4try service name, TCP then UDP */ - if (hintsp->ai_socktype == 0 || hintsp->ai_socktype == SOCK_STREAM) - { - if ((sptr = cygwin_getservbyname (serv, "tcp")) != NULL) - { - if ((rc = ga_port (aihead, sptr->s_port, SOCK_STREAM)) < 0) - return (EAI_MEMORY); - nfound += rc; - } - } - if (hintsp->ai_socktype == 0 || hintsp->ai_socktype == SOCK_DGRAM) - { - if ((sptr = cygwin_getservbyname (serv, "udp")) != NULL) - { - if ((rc = ga_port (aihead, sptr->s_port, SOCK_DGRAM)) < 0) - return (EAI_MEMORY); - nfound += rc; - } - } - } - - if (nfound == 0) - { - if (hintsp->ai_socktype == 0) - return (EAI_NONAME); /* all calls to getservbyname() failed */ - else - return (EAI_SERVICE); /* service not supported for socket type */ - } - return (0); -} - -/* end ga_serv */ - -#ifdef UNIXdomain -/* include ga_unix */ -static int -ga_unix (const char *path, struct addrinfo *hintsp, struct addrinfo **result) -{ - int rc; - struct addrinfo *aihead, **aipnext; - - aihead = NULL; - aipnext = &aihead; - - if (hintsp->ai_family != AF_UNSPEC && hintsp->ai_family != AF_LOCAL) - return (EAI_ADDRFAMILY); - - if (hintsp->ai_socktype == 0) - { - /* 4no socket type specified: return stream then dgram */ - hintsp->ai_socktype = SOCK_STREAM; - if ((rc = ga_aistruct (&aipnext, hintsp, path, AF_LOCAL)) != 0) - return (rc); - hintsp->ai_socktype = SOCK_DGRAM; - } - - if ((rc = ga_aistruct (&aipnext, hintsp, path, AF_LOCAL)) != 0) - return (rc); - - if (hintsp->ai_flags & AI_CANONNAME) - { - struct utsname myname; - - if (uname (&myname) < 0) - return (EAI_SYSTEM); - if ((aihead->ai_canonname = strdup (myname.nodename)) == NULL) - return (EAI_MEMORY); - } - - *result = aihead; /* pointer to first structure in linked list */ - return (0); -} - -/* end ga_unix */ -#endif /* UNIXdomain */ - -/* include gn_ipv46 */ -static int -gn_ipv46 (char *host, size_t hostlen, char *serv, size_t servlen, - void *aptr, size_t alen, int family, int port, int flags) -{ - char *ptr; - struct hostent *hptr; - struct servent *sptr; - - if (host && hostlen > 0) - { - if (flags & NI_NUMERICHOST) - { - if (cygwin_inet_ntop (family, aptr, host, hostlen) == NULL) - return (1); - } - else - { - hptr = cygwin_gethostbyaddr ((const char *) aptr, alen, family); - if (hptr != NULL && hptr->h_name != NULL) - { - if (flags & NI_NOFQDN) - { - if ((ptr = strchr (hptr->h_name, '.')) != NULL) - *ptr = 0; /* overwrite first dot */ - } - //snprintf (host, hostlen, "%s", hptr->h_name); - *host = '\0'; - strncat (host, hptr->h_name, hostlen - 1); - } - else - { - if (flags & NI_NAMEREQD) - return (1); - if (cygwin_inet_ntop (family, aptr, host, hostlen) == NULL) - return (1); - } - } - } - - if (serv && servlen > 0) - { - if (flags & NI_NUMERICSERV) - { - //snprintf (serv, servlen, "%d", ntohs (port)); - char buf[32]; - __small_sprintf (buf, "%d", ntohs (port)); - *serv = '\0'; - strncat (serv, buf, servlen - 1); - } - else - { - sptr = cygwin_getservbyport (port, (flags & NI_DGRAM) ? "udp" : NULL); - if (sptr != NULL && sptr->s_name != NULL) - { - //snprintf (serv, servlen, "%s", sptr->s_name); - *serv = '\0'; - strncat (serv, sptr->s_name, servlen - 1); - } - else - { - //snprintf (serv, servlen, "%d", ntohs (port)); - char buf[32]; - __small_sprintf (buf, "%d", ntohs (port)); - *serv = '\0'; - strncat (serv, buf, servlen - 1); - } - } - } - return (0); -} - -/* end gn_ipv46 */ - -/* include freeaddrinfo */ -void -ipv4_freeaddrinfo (struct addrinfo *aihead) -{ - struct addrinfo *ai, *ainext; - - for (ai = aihead; ai != NULL; ai = ainext) - { - if (ai->ai_addr != NULL) - free (ai->ai_addr); /* socket address structure */ - - if (ai->ai_canonname != NULL) - free (ai->ai_canonname); - - ainext = ai->ai_next; /* can't fetch ai_next after free() */ - free (ai); /* the addrinfo{} itself */ - } -} - -/* end freeaddrinfo */ - -/* include ga1 */ - -int -ipv4_getaddrinfo (const char *hostname, const char *servname, - const struct addrinfo *hintsp, struct addrinfo **result) -{ - int rc, error, nsearch; - char **ap, *canon; - struct hostent *hptr; - struct search search[3], *sptr; - struct addrinfo hints, *aihead, **aipnext; - - /* - * If we encounter an error we want to free() any dynamic memory - * that we've allocated. This is our hack to simplify the code. - */ -#define error(e) { error = (e); goto bad; } - - aihead = NULL; /* initialize automatic variables */ - aipnext = &aihead; - canon = NULL; - - if (hintsp == NULL) - { - bzero (&hints, sizeof (hints)); - hints.ai_family = AF_UNSPEC; - } - else - hints = *hintsp; /* struct copy */ - - /* 4first some basic error checking */ - if ((rc = ga_echeck (hostname, servname, hints.ai_flags, hints.ai_family, - hints.ai_socktype, hints.ai_protocol)) != 0) - error (rc); - -#ifdef UNIXdomain - /* 4special case Unix domain first */ - if (hostname != NULL && - (strcmp (hostname, "/local") == 0 || strcmp (hostname, "/unix") == 0) && - (servname != NULL && servname[0] == '/')) - return (ga_unix (servname, &hints, result)); -#endif -/* end ga1 */ - -/* include ga3 */ - /* 4remainder of function for IPv4/IPv6 */ - nsearch = ga_nsearch (hostname, &hints, &search[0]); - if (nsearch == -1) - error (EAI_FAMILY); - for (sptr = &search[0]; sptr < &search[nsearch]; sptr++) - { -#ifdef IPv4 - /* 4check for an IPv4 dotted-decimal string */ - if (isdigit (sptr->host[0])) - { - struct in_addr inaddr; - - if (inet_pton4 (sptr->host, (u_char *) &inaddr) == 1) - { - if (hints.ai_family != AF_UNSPEC && hints.ai_family != AF_INET) - error (EAI_ADDRFAMILY); - if (sptr->family != AF_INET) - continue; /* ignore */ - rc = ga_aistruct (&aipnext, &hints, &inaddr, AF_INET); - if (rc != 0) - error (rc); - continue; - } - } -#endif - -#ifdef IPv6 - /* 4check for an IPv6 hex string */ - if ((isxdigit (sptr->host[0]) || sptr->host[0] == ':') && - (strchr (sptr->host, ':') != NULL)) - { - struct in6_addr in6addr; - - if (inet_pton6 (sptr->host, &in6addr) == 1) - { - if (hints.ai_family != AF_UNSPEC && hints.ai_family != AF_INET6) - error (EAI_ADDRFAMILY); - if (sptr->family != AF_INET6) - continue; /* ignore */ - rc = ga_aistruct (&aipnext, &hints, &in6addr, AF_INET6); - if (rc != 0) - error (rc); - continue; - } - } -#endif -/* end ga3 */ -/* include ga4 */ -#ifdef IPv6 - /* 4remainder of for() to look up hostname */ - if ((_res.options & RES_INIT) == 0) - res_init (); /* need this to set _res.options */ -#endif - - if (nsearch == 2) - { -#ifdef IPv6 - _res.options &= ~RES_USE_INET6; -#endif - hptr = gethostbyname2 (sptr->host, sptr->family); - } - else - { -#ifdef IPv6 - if (sptr->family == AF_INET6) - _res.options |= RES_USE_INET6; - else - _res.options &= ~RES_USE_INET6; -#endif - hptr = gethostbyname (sptr->host); - } - if (hptr == NULL) - { - if (nsearch == 2) - continue; /* failure OK if multiple searches */ - - switch (h_errno) - { - case HOST_NOT_FOUND: - error (EAI_NONAME); - case TRY_AGAIN: - error (EAI_AGAIN); - case NO_RECOVERY: - error (EAI_FAIL); - case NO_DATA: - error (EAI_NODATA); - default: - error (EAI_NONAME); - } - } - - /* 4check for address family mismatch if one specified */ - if (hints.ai_family != AF_UNSPEC && hints.ai_family != hptr->h_addrtype) - error (EAI_ADDRFAMILY); - - /* 4save canonical name first time */ - if (hostname != NULL && hostname[0] != '\0' && - (hints.ai_flags & AI_CANONNAME) && canon == NULL) - { - if ((canon = strdup (hptr->h_name)) == NULL) - error (EAI_MEMORY); - } - - /* 4create one addrinfo{} for each returned address */ - for (ap = hptr->h_addr_list; *ap != NULL; ap++) - { - rc = ga_aistruct (&aipnext, &hints, *ap, hptr->h_addrtype); - if (rc != 0) - error (rc); - } - } - if (aihead == NULL) - error (EAI_NONAME); /* nothing found */ -/* end ga4 */ - -/* include ga5 */ - /* 4return canonical name */ - if (hostname != NULL && hostname[0] != '\0' && - hints.ai_flags & AI_CANONNAME) - { - if (canon != NULL) - aihead->ai_canonname = canon; /* strdup'ed earlier */ - else - { - if ((aihead->ai_canonname = strdup (search[0].host)) == NULL) - error (EAI_MEMORY); - } - } - - /* 4now process the service name */ - if (servname != NULL && servname[0] != '\0') - { - if ((rc = ga_serv (aihead, &hints, servname)) != 0) - error (rc); - } - - *result = aihead; /* pointer to first structure in linked list */ - return (0); - -bad: - ipv4_freeaddrinfo (aihead); /* free any alloc'ed memory */ - return (error); -} - -/* end ga5 */ - -/* include getnameinfo */ -int -ipv4_getnameinfo (const struct sockaddr *sa, socklen_t salen, - char *host, size_t hostlen, - char *serv, size_t servlen, int flags) -{ - - switch (sa->sa_family) - { -#ifdef IPv4 - case AF_INET: - { - struct sockaddr_in *sain = (struct sockaddr_in *) sa; - - return (gn_ipv46 (host, hostlen, serv, servlen, - &sain->sin_addr, sizeof (struct in_addr), - AF_INET, sain->sin_port, flags)); - } -#endif - -#ifdef IPv6 - case AF_INET6: - { - struct sockaddr_in6 *sain = (struct sockaddr_in6 *) sa; - - return (gn_ipv46 (host, hostlen, serv, servlen, - &sain->sin6_addr, sizeof (struct in6_addr), - AF_INET6, sain->sin6_port, flags)); - } -#endif - -#ifdef UNIXdomain - case AF_LOCAL: - { - struct sockaddr_un *un = (struct sockaddr_un *) sa; - - if (hostlen > 0) - snprintf (host, hostlen, "%s", "/local"); - if (servlen > 0) - snprintf (serv, servlen, "%s", un->sun_path); - return (0); - } -#endif - - default: - return (EAI_FAMILY); - } -} - -/* end getnameinfo */ - -/* Start of cygwin specific wrappers around the gai functions. */ - -struct gai_errmap_t -{ - int w32_errval; - const char *errtxt; -}; - -static gai_errmap_t gai_errmap[] = -{ - {0, "Success"}, - {0, "Address family for hostname not supported"}, - {WSATRY_AGAIN, "Temporary failure in name resolution"}, - {WSAEINVAL, "Invalid value for ai_flags"}, - {WSANO_RECOVERY, "Non-recoverable failure in name resolution"}, - {WSAEAFNOSUPPORT, "ai_family not supported"}, - {WSA_NOT_ENOUGH_MEMORY, "Memory allocation failure"}, - {WSANO_DATA, "No address associated with hostname"}, - {WSAHOST_NOT_FOUND, "hostname nor servname provided, or not known"}, - {WSATYPE_NOT_FOUND, "servname not supported for ai_socktype"}, - {WSAESOCKTNOSUPPORT, "ai_socktype not supported"}, - {0, "System error returned in errno"}, - {0, "Invalid value for hints"}, - {0, "Resolved protocol is unknown"}, - {WSAEFAULT, "An argument buffer overflowed"} -}; - -extern "C" const char * -cygwin_gai_strerror (int err) -{ - if (err >= 0 && err < (int) (sizeof gai_errmap / sizeof *gai_errmap)) - return gai_errmap[err].errtxt; - return "Unknown error"; -} - -static int -w32_to_gai_err (int w32_err) -{ - if (w32_err >= WSABASEERR) - for (unsigned i = 0; i < sizeof gai_errmap / sizeof *gai_errmap; ++i) - if (gai_errmap[i].w32_errval == w32_err) - return i; - return w32_err; -} - -/* We can't use autoload here because we don't know where the functions - are loaded from. On Win2K, the functions are available in the - ipv6 technology preview lib called wship6.dll, in XP and above they - are implemented in ws2_32.dll. For older systems we use the ipv4-only - version above. */ - -static void (WINAPI *freeaddrinfo)(const struct addrinfo *); -static int (WINAPI *getaddrinfo)(const char *, const char *, - const struct addrinfo *, - struct addrinfo **); -static int (WINAPI *getnameinfo)(const struct sockaddr *, socklen_t, - char *, size_t, char *, size_t, int); -static bool -get_ipv6_funcs (HMODULE lib) -{ - return ((freeaddrinfo = (void (WINAPI *)(const struct addrinfo *)) - GetProcAddress (lib, "freeaddrinfo")) - && (getaddrinfo = (int (WINAPI *)(const char *, const char *, - const struct addrinfo *, - struct addrinfo **)) - GetProcAddress (lib, "getaddrinfo")) - && (getnameinfo = (int (WINAPI *)(const struct sockaddr *, - socklen_t, char *, size_t, - char *, size_t, int)) - GetProcAddress (lib, "getnameinfo"))); -} - -static NO_COPY muto load_ipv6_guard; -static NO_COPY bool ipv6_inited = false; -#define load_ipv6() if (!ipv6_inited) load_ipv6_funcs (); - -static void -load_ipv6_funcs () -{ - tmp_pathbuf tp; - PWCHAR lib_name = tp.w_get (); - size_t len; - HMODULE lib; - - load_ipv6_guard.init ("klog_guard")->acquire (); - if (ipv6_inited) - goto out; - WSAGetLastError (); /* Kludge. Enforce WSAStartup call. */ - if (GetSystemDirectoryW (lib_name, NT_MAX_PATH)) - { - len = wcslen (lib_name); - wcpcpy (lib_name + len, L"\\ws2_32.dll"); - if ((lib = LoadLibraryW (lib_name))) - { - if (get_ipv6_funcs (lib)) - goto out; - FreeLibrary (lib); - } - wcpcpy (lib_name + len, L"\\wship6.dll"); - if ((lib = LoadLibraryW (lib_name))) - { - if (get_ipv6_funcs (lib)) - goto out; - FreeLibrary (lib); - } - freeaddrinfo = NULL; - getaddrinfo = NULL; - getnameinfo = NULL; - } -out: - ipv6_inited = true; - load_ipv6_guard.release (); -} - -extern "C" void -cygwin_freeaddrinfo (struct addrinfo *addr) -{ - myfault efault; - if (efault.faulted (EFAULT)) - return; - ipv4_freeaddrinfo (addr); -} - -extern "C" int -cygwin_getaddrinfo (const char *hostname, const char *servname, - const struct addrinfo *hints, struct addrinfo **res) -{ - myfault efault; - if (efault.faulted (EFAULT)) - return EAI_SYSTEM; - /* Both subsequent getaddrinfo implementations let all possible values - in ai_flags slip through and just ignore unknowen values. So we have - to check manually here. */ - if (hints && (hints->ai_flags - & ~(AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_ALL - | AI_NUMERICSERV | AI_ADDRCONFIG | AI_V4MAPPED))) - return EAI_BADFLAGS; - /* AI_NUMERICSERV is not supported in our replacement getaddrinfo, nor - is it supported by Winsock prior to Vista. We just check the servname - parameter by ourselves here. */ - if (hints && (hints->ai_flags & AI_NUMERICSERV)) - { - char *p; - if (servname && *servname && (strtoul (servname, &p, 10), *p)) - return EAI_NONAME; - } - load_ipv6 (); - if (!getaddrinfo) - return ipv4_getaddrinfo (hostname, servname, hints, res); - - struct addrinfo nhints, *dupres; - - /* AI_ADDRCONFIG is not supported prior to Vista. Rather it's - the default and only possible setting. - On Vista, the default behaviour is as if AI_ADDRCONFIG is set, - apparently for performance reasons. To get the POSIX default - behaviour, the AI_ALL flag has to be set. */ - if (wincap.supports_all_posix_ai_flags () - && hints && hints->ai_family == PF_UNSPEC) - { - nhints = *hints; - hints = &nhints; - nhints.ai_flags |= AI_ALL; - } - int ret = w32_to_gai_err (getaddrinfo (hostname, servname, hints, res)); - /* Always copy over to self-allocated memory. */ - if (!ret) - { - dupres = ga_duplist (*res, false); - freeaddrinfo (*res); - *res = dupres; - if (!dupres) - return EAI_MEMORY; - } - /* AI_V4MAPPED and AI_ALL are not supported prior to Vista. So, what - we do here is to emulate AI_V4MAPPED. If no IPv6 addresses are - returned, or the AI_ALL flag is set, we try with AF_INET again, and - convert the returned IPv4 addresses into v4-in-v6 entries. This - is done in ga_dup if the v4mapped flag is set. */ - if (!wincap.supports_all_posix_ai_flags () - && hints - && hints->ai_family == AF_INET6 - && (hints->ai_flags & AI_V4MAPPED) - && (ret == EAI_NODATA || ret == EAI_NONAME - || (hints->ai_flags & AI_ALL))) - { - struct addrinfo *v4res; - nhints = *hints; - nhints.ai_family = AF_INET; - int ret2 = w32_to_gai_err (getaddrinfo (hostname, servname, - &nhints, &v4res)); - if (!ret2) - { - dupres = ga_duplist (v4res, true); - freeaddrinfo (v4res); - if (!dupres) - { - if (!ret) - ipv4_freeaddrinfo (*res); - return EAI_MEMORY; - } - /* If a list of v6 addresses exists, append the v4-in-v6 address - list. Otherwise just return the v4-in-v6 address list. */ - if (!ret) - { - struct addrinfo *ptr; - for (ptr = *res; ptr->ai_next; ptr = ptr->ai_next) - ; - ptr->ai_next = dupres; - } - else - *res = dupres; - ret = 0; - } - } - return ret; -} - -extern "C" int -cygwin_getnameinfo (const struct sockaddr *sa, socklen_t salen, - char *host, size_t hostlen, char *serv, - size_t servlen, int flags) -{ - myfault efault; - if (efault.faulted (EFAULT)) - return EAI_SYSTEM; - load_ipv6 (); - if (!getnameinfo) - return ipv4_getnameinfo (sa, salen, host, hostlen, serv, servlen, flags); - - /* When the incoming port number does not resolve to a well-known service, - Winsock's getnameinfo up to Windows 2003 returns with error WSANO_DATA - instead of setting `serv' to the numeric port number string, as required - by RFC 3493. This is fixed on Vista and later. To avoid the error on - systems up to Windows 2003, we check if the port number resolves - to a well-known service. If not, we set the NI_NUMERICSERV flag. */ - if (!wincap.supports_all_posix_ai_flags ()) - { - int port = 0; - - switch (sa->sa_family) - { - case AF_INET: - port = ((struct sockaddr_in *) sa)->sin_port; - break; - case AF_INET6: - port = ((struct sockaddr_in6 *) sa)->sin6_port; - break; - } - if (!port || !getservbyport (port, flags & NI_DGRAM ? "udp" : "tcp")) - flags |= NI_NUMERICSERV; - } - int ret = w32_to_gai_err (getnameinfo (sa, salen, host, hostlen, serv, - servlen, flags)); - if (ret) - set_winsock_errno (); - return ret; -} - -/* The below function in6_are_prefix_equal has been taken from OpenBSD's - src/sys/netinet6/in6.c. */ - -/* - * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. - * All rights reserved. - * - * 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. Neither the name of the project 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 PROJECT 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 PROJECT 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. - */ - -/* - * Copyright (c) 1982, 1986, 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. 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. - * - * @(#)in.c 8.2 (Berkeley) 11/15/93 - */ - -static int -in6_are_prefix_equal (struct in6_addr *p1, struct in6_addr *p2, int len) -{ - int bytelen, bitlen; - - /* sanity check */ - if (0 > len || len > 128) - return 0; - - bytelen = len / 8; - bitlen = len % 8; - - if (memcmp (&p1->s6_addr, &p2->s6_addr, bytelen)) - return 0; - /* len == 128 is ok because bitlen == 0 then */ - if (bitlen != 0 && - p1->s6_addr[bytelen] >> (8 - bitlen) != - p2->s6_addr[bytelen] >> (8 - bitlen)) - return 0; - - return 1; -} - -/* These functions are stick to the end of this file so that the - optimization in asm/byteorder.h can be used even here in net.cc. */ - -#undef htonl -#undef ntohl -#undef htons -#undef ntohs - -/* htonl: standards? */ -extern "C" uint32_t -htonl (uint32_t x) -{ - return __htonl (x); -} - -/* ntohl: standards? */ -extern "C" uint32_t -ntohl (uint32_t x) -{ - return __ntohl (x); -} - -/* htons: standards? */ -extern "C" uint16_t -htons (uint16_t x) -{ - return __htons (x); -} - -/* ntohs: standards? */ -extern "C" uint16_t -ntohs (uint16_t x) -{ - return __ntohs (x); -} diff --git a/winsup/cygwin/netdb.cc b/winsup/cygwin/netdb.cc deleted file mode 100644 index bf03d1f56..000000000 --- a/winsup/cygwin/netdb.cc +++ /dev/null @@ -1,408 +0,0 @@ -/* netdb.cc: network database related routines. - - Copyright 2002, 2003, 2007 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include - -/* Locate and open a system network database file. relative_path - should be one of the following values: - "protocol" - "services" - "networks" - "hosts" - - It is the callers responsibility to close the file. */ -static FILE * -open_system_file (const char *relative_path) -{ - /* system dir path is never longer. */ - char win32_name[MAX_PATH]; - - if (!GetSystemDirectory (win32_name, MAX_PATH)) - return NULL; - strcat (win32_name, "\\drivers\\etc\\"); - strcat (win32_name, relative_path); - debug_printf ("netdb file to open %s", win32_name); - FILE *result = fopen (win32_name, "rt"); - debug_printf ("handle to netdb file %p", result); - return result; -} - -inline static FILE * -open_protocol_file () -{ - return open_system_file ("protocol"); -} - -/* Wrapper for open_system_file(), fixing the constant name -"services". Returns the open file. */ -inline static FILE * -open_services_file () -{ - return open_system_file ("services"); -} - -/* Read an entire line up till the next \n character. Memory for the -line is dynamically allocated, and the caller must call free() to -deallocate it. When the end of file is reached, NULL is returned. */ -static char * -get_entire_line (FILE *fd) -{ - static const int BUFF_SIZE = 1024; - struct line_fragment - { - char buffer[BUFF_SIZE]; - line_fragment *next; - }; - - line_fragment *fragment_list_head = NULL; - line_fragment *fragment = NULL; - int fragment_count = 0; - char *result; - - do - { - line_fragment *new_fragment = (line_fragment *) malloc (sizeof (line_fragment)); - paranoid_printf ("line fragment allocated %p", new_fragment); - if (!fragment_list_head) - fragment_list_head = new_fragment; - if (fragment) - fragment->next = new_fragment; - fragment = new_fragment; - fragment->next = NULL; - *fragment->buffer = '\0'; - result = fgets (fragment->buffer, BUFF_SIZE, fd); - ++fragment_count; - } - while (result && !strchr (fragment->buffer, '\n')); - - if (*fragment_list_head->buffer != '\0') - { - char *concatenated_line = (char *) calloc (fragment_count * BUFF_SIZE , sizeof (char)); - paranoid_printf ("concatenated line allocated %p", concatenated_line); - *concatenated_line = '\0'; - fragment = fragment_list_head; - while (fragment != NULL) - { - line_fragment *previous = fragment; - strcat (concatenated_line, fragment->buffer); - fragment = fragment->next; - free (previous); - } - return concatenated_line; - } - else - { - fragment = fragment_list_head; - while (fragment != NULL) - { - line_fragment *previous = fragment; - fragment = fragment->next; - free (previous); - } - return NULL; - } -} - -/* Characters representing whitespace. Used by parse_* routines to -delimit tokens. */ -static const NO_COPY char *SPACE = " \t\n\r\f"; - -/* Parse a list aliases from a network database file. Returns a -char** structure terminated by a NULL. */ -static void -parse_alias_list (char ***aliases, char **lasts) -{ - struct alias_t - { - char *alias_name; - alias_t *next; - }; - alias_t *alias_list_head = NULL, *alias_list_tail = NULL; - char *alias; - int alias_count = 0; - alias = strtok_r (NULL, SPACE, lasts); - - while (alias) - { - ++alias_count; - alias_t *new_alias = (alias_t *) malloc (sizeof (alias_t)); - paranoid_printf ("new alias alloc %p", new_alias); - if (!alias_list_head) - alias_list_head = new_alias; - if (alias_list_tail) - alias_list_tail->next = new_alias; - new_alias->next = NULL; - new_alias->alias_name = alias; - alias_list_tail = new_alias; - alias = strtok_r (NULL, SPACE, lasts); - } - - *aliases = (char**) calloc (alias_count + 1, sizeof (char *)); - paranoid_printf ("aliases alloc %p", *aliases); - - char **current_entry = *aliases; - while (alias_list_head) - { - alias_t *previous = alias_list_head; - *current_entry = strdup (alias_list_head->alias_name); - paranoid_printf ("*current entry strdup %p", *current_entry); - alias_list_head = alias_list_head->next; - free (previous); - ++current_entry; - } - - *current_entry = NULL; -} - -/* Read the next line from svc_file, and parse it into the structure -pointed to by sep. sep can point to stack or static data, but it's -members will be overwritten with pointers to dynamically allocated -heap data accommodating parsed data. It is the responsibility of the -caller to free up the allocated structures. The function returns true -to indicate that a line was successfully read and parsed. False is -used to indicate that no more lines can be read and parsed. This -should also interpreted as end of file. */ -static bool -parse_services_line (FILE *svc_file, struct servent *sep) -{ - char *line; - while ((line = get_entire_line (svc_file))) - { - char *name, *port, *protocol, *lasts; - - line[strcspn (line, "#")] = '\0'; // truncate at comment marker. - name = strtok_r (line, SPACE, &lasts); - if (!name) - { - free (line); - continue; - } - port = strtok_r (NULL, SPACE, &lasts); - protocol = strchr (port, '/'); - *protocol++ = '\0'; - sep->s_name = strdup (name); - paranoid_printf ("sep->s_name strdup %p", sep->s_name); - sep->s_port = atoi (port); - sep->s_proto = strdup (protocol); - paranoid_printf ("sep->s_proto strdup %p", sep->s_proto); - /* parse_alias_list relies on side effects. Read the comments - for that function.*/ - parse_alias_list (& sep->s_aliases, &lasts); - free (line); - return true; - } - return false; -} - -static FILE *svc_file = NULL; -static long int svc_read_pos = 0; -static struct servent current_servent; - -/* Steps through a struct servent, and frees all of the internal -structures.*/ -static void -free_servent (struct servent *sep) -{ - free (sep->s_name); - free (sep->s_proto); - char ** current = sep->s_aliases; - while (current && *current) - { - free (*current); - ++current; - } - free (sep->s_aliases); - sep->s_name = NULL; - sep->s_port = 0; - sep->s_proto = NULL; - sep->s_aliases = NULL; -} - -extern "C" void -cygwin_setservent (int stay_open) -{ - if (svc_file) - fclose (svc_file); - if (stay_open) - svc_file = open_services_file (); - free_servent (¤t_servent); - svc_read_pos = 0; - syscall_printf ("setservent (%d)", stay_open); -} - -extern "C" struct servent * -cygwin_getservent (void) -{ - FILE *fd; - if (svc_file) - fd = svc_file; - else - { - fd = open_services_file (); - if (!fd) - { - syscall_printf ("%p = getservent()", NULL); - return NULL; - } - fseek (fd, svc_read_pos, SEEK_SET); - } - free_servent (¤t_servent); - bool found = parse_services_line (fd, ¤t_servent); - if (!svc_file) - { - svc_read_pos = ftell (fd); - fclose (fd); - } - struct servent *result; - if (found) - result = ¤t_servent; - else - result = NULL; - syscall_printf ("%p = getservent()", result); - return result; -} - -extern "C" void -cygwin_endservent (void) -{ - if (svc_file) - { - fclose (svc_file); - svc_file = NULL; - } - free_servent (¤t_servent); - svc_read_pos = 0; - syscall_printf ("endservent ()"); -} - -/* Read the next line from proto_file, and parse it into the structure -pointed to by pep. pep can point to stack or static data, but it's -members will be overwritten with pointers to dynamically allocated -heap data accommodating parsed data. It is the responsibility of the -caller to free up the allocated structures. The function returns true -to indicate that a line was successfully read and parsed. False is -used to indicate that no more lines can be read and parsed. This -should also interpreted as end of file. */ -static bool -parse_protocol_line (FILE *proto_file, struct protoent *pep) -{ - char *line; - while ((line = get_entire_line (proto_file))) - { - char *name, *protocol, *lasts; - - line[strcspn (line, "#")] = '\0'; // truncate at comment marker. - name = strtok_r (line, SPACE, &lasts); - if (!name) - { - free (line); - continue; - } - protocol = strtok_r (NULL, SPACE, &lasts); - pep->p_name = strdup (name); - paranoid_printf ("pep->p_name strdup %p", pep->p_name); - pep->p_proto = atoi (protocol); - /* parse_alias_list relies on side effects. Read the comments - for that function.*/ - parse_alias_list (& pep->p_aliases, &lasts); - free (line); - return true; - } - return false; -} - -static FILE *proto_file = NULL; -static long int proto_read_pos = 0; -static struct protoent current_protoent; - -/* Steps through a struct protoent, and frees all the internal -structures. */ -static void -free_protoent (struct protoent *pep) -{ - free (pep->p_name); - char ** current = pep->p_aliases; - while (current && *current) - { - free (*current); - ++current; - } - free (pep->p_aliases); - pep->p_name = NULL; - pep->p_proto = 0; - pep->p_aliases = NULL; -} - -extern "C" void -cygwin_setprotoent (int stay_open) -{ - if (proto_file) - fclose (proto_file); - - if (stay_open) - proto_file = open_protocol_file (); - - free_protoent (¤t_protoent); - proto_read_pos = 0; - syscall_printf ("setprotoent (%d)", stay_open); -} - -extern "C" struct protoent * -cygwin_getprotoent (void) -{ - FILE *fd; - - if (proto_file) - fd = proto_file; - else - { - fd = open_protocol_file (); - if (!fd) - { - syscall_printf ("%p = getprotoent()", NULL); - return NULL; - } - fseek (fd, proto_read_pos, SEEK_SET); - } - free_protoent (¤t_protoent); - - bool found = parse_protocol_line (fd, ¤t_protoent); - if (!proto_file) - { - proto_read_pos = ftell (fd); - fclose (fd); - } - - struct protoent *result; - if (found) - result = ¤t_protoent; - else - result = NULL; - - syscall_printf ("%p = getprotoent()", result); - return result; -} - -extern "C" void -cygwin_endprotoent (void) -{ - if (proto_file) - { - fclose (proto_file); - proto_file = NULL; - } - - free_protoent (¤t_protoent); - proto_read_pos = 0; - syscall_printf ("endprotoent ()"); -} diff --git a/winsup/cygwin/nfs.cc b/winsup/cygwin/nfs.cc deleted file mode 100644 index 46face17e..000000000 --- a/winsup/cygwin/nfs.cc +++ /dev/null @@ -1,18 +0,0 @@ -/* nfs.cc - - Copyright 2008 Red Hat, Inc. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "sys/fcntl.h" -#include "nfs.h" - -struct nfs_aol_ffei_t nfs_aol_ffei = { 0, 0, sizeof (NFS_ACT_ON_LINK) - 1, 0, - NFS_ACT_ON_LINK }; - -uint32_t nfs_type_mapping[] = { 0, S_IFREG, S_IFDIR, S_IFBLK, - S_IFCHR, S_IFLNK, S_IFSOCK, S_IFIFO }; - diff --git a/winsup/cygwin/nfs.h b/winsup/cygwin/nfs.h deleted file mode 100644 index 657126f78..000000000 --- a/winsup/cygwin/nfs.h +++ /dev/null @@ -1,55 +0,0 @@ -/* nfs.h - - Copyright 2008 Red Hat, Inc. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#define NFS_ACT_ON_LINK "NfsActOnLink" -#define NFS_SYML_TARGET "NfsSymlinkTargetName" -#define NFS_V3_ATTR "NfsV3Attributes" - -/* NFS datastructures per RFC 1813, as returned by SFU NFS. */ - -enum ftype3 { - NF3REG = 1, - NF3DIR = 2, - NF3BLK = 3, - NF3CHR = 4, - NF3LNK = 5, - NF3SOCK = 6, - NF3FIFO = 7 -}; - -struct fattr3 { - uint32_t type; - uint32_t mode; - uint32_t nlink; - uint32_t uid; - uint32_t gid; - uint32_t filler1; - uint64_t size; - uint64_t used; - struct - { - uint32_t specdata1; - uint32_t specdata2; - } rdev; - uint64_t fsid; - uint64_t fileid; - timestruc_t atime; - timestruc_t mtime; - timestruc_t ctime; -}; - -struct nfs_aol_ffei_t { - ULONG NextEntryOffset; - UCHAR Flags; - UCHAR EaNameLength; - USHORT EaValueLength; - CHAR EaName[sizeof (NFS_ACT_ON_LINK)]; -}; -extern struct nfs_aol_ffei_t nfs_aol_ffei; - -extern uint32_t nfs_type_mapping[]; diff --git a/winsup/cygwin/nlsfuncs.cc b/winsup/cygwin/nlsfuncs.cc deleted file mode 100644 index 8444768b6..000000000 --- a/winsup/cygwin/nlsfuncs.cc +++ /dev/null @@ -1,1201 +0,0 @@ -/* nlsfuncs.cc: NLS helper functions - - Copyright 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include -#include -#include -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "tls_pbuf.h" -/* Internal headers from newlib */ -#include "../locale/timelocal.h" -#include "../locale/lnumeric.h" -#include "../locale/lmonetary.h" -#include "../locale/lmessages.h" -#include "lc_msg.h" - -#define _LC(x) &lc_##x##_ptr,lc_##x##_end-lc_##x##_ptr - -#define getlocaleinfo(category,type) \ - __getlocaleinfo(lcid,(type),_LC(category),f_wctomb,charset) -#define eval_datetimefmt(type,force) \ - __eval_datetimefmt(lcid,(type),(force),&lc_time_ptr,\ - lc_time_end-lc_time_ptr,f_wctomb, charset) - -#define has_modifier(x) ((x)[0] && !strcmp (modifier, (x))) - -/* Vista and later. Not defined in w32api yet. */ -extern "C" { -WINBASEAPI LCID WINAPI LocaleNameToLCID (LPCWSTR, DWORD); -}; - -static char last_locale[ENCODING_LEN + 1]; -static LCID last_lcid; - -/* Fetch LCID from POSIX locale specifier. - Return values: - - -1: Invalid locale - 0: C or POSIX - >0: LCID -*/ -static LCID -__get_lcid_from_locale (const char *name) -{ - char locale[ENCODING_LEN + 1]; - char *c; - LCID lcid; - - /* Speed up reusing the same locale as before, for instance in LC_ALL case. */ - if (!strcmp (name, last_locale)) - { - debug_printf ("LCID=0x%04x", last_lcid); - return last_lcid; - } - stpcpy (last_locale, name); - stpcpy (locale, name); - /* Store modifier for later use. */ - const char *modifier = strchr (last_locale, '@') ? : ""; - /* Drop charset and modifier */ - c = strchr (locale, '.'); - if (!c) - c = strchr (locale, '@'); - if (c) - *c = '\0'; - /* "POSIX" already converted to "C" in loadlocale. */ - if (!strcmp (locale, "C")) - return last_lcid = 0; - c = strchr (locale, '_'); - if (!c) - return last_lcid = (LCID) -1; - if (wincap.has_localenames ()) - { - wchar_t wlocale[ENCODING_LEN + 1]; - - /* Convert to RFC 4646 syntax which is the standard for the locale names - replacing LCIDs starting with Vista. */ - *c = '-'; - mbstowcs (wlocale, locale, ENCODING_LEN + 1); - lcid = LocaleNameToLCID (wlocale, 0); - if (lcid == 0) - { - /* Unfortunately there are a couple of locales for which no form - without a Script part per RFC 4646 exists. - Linux also supports no_NO which is equivalent to nb_NO. */ - struct { - const char *loc; - const wchar_t *wloc; - } sc_only_locale[] = { - { "az-AZ" , L"az-Latn-AZ" }, - { "bs-BA" , L"bs-Latn-BA" }, - { "ha-NG" , L"ha-Latn-NG" }, - { "iu-CA" , L"iu-Latn-CA" }, - { "mn-CN" , L"mn-Mong-CN" }, - { "no-NO" , L"nb-NO" }, - { "sr-BA" , L"sr-Cyrl-BA" }, - { "sr-CS" , L"sr-Cyrl-CS" }, - { "sr-ME" , L"sr-Cyrl-ME" }, - { "sr-RS" , L"sr-Cyrl-RS" }, - { "tg-TJ" , L"tg-Cyrl-TJ" }, - { "tzm-DZ", L"tzm-Latn-DZ" }, - { "uz-UZ" , L"uz-Latn-UZ" }, - { NULL , NULL } - }; - for (int i = 0; sc_only_locale[i].loc - && sc_only_locale[i].loc[0] <= locale[0]; ++i) - if (!strcmp (locale, sc_only_locale[i].loc)) - { - lcid = LocaleNameToLCID (sc_only_locale[i].wloc, 0); - if (!strncmp (locale, "sr-", 3)) - { - /* Vista/2K8 is missing sr-ME and sr-RS. It has only the - deprecated sr-CS. So we map ME and RS to CS here. */ - if (lcid == 0) - lcid = LocaleNameToLCID (L"sr-Cyrl-CS", 0); - /* "@latin" modifier for the sr_XY locales changes - collation behaviour so lcid should accommodate that - by being set to the Latin sublang. */ - if (lcid != 0 && has_modifier ("@latin")) - lcid = MAKELANGID (lcid & 0x3ff, (lcid >> 10) - 1); - } - else if (!strncmp (locale, "uz-", 3)) - { - /* Equivalent for "@cyrillic" modifier in uz_UZ locale */ - if (lcid != 0 && has_modifier ("@cyrillic")) - lcid = MAKELANGID (lcid & 0x3ff, (lcid >> 10) + 1); - } - break; - } - } - last_lcid = lcid ?: (LCID) -1; - debug_printf ("LCID=0x%04x", last_lcid); - return last_lcid; - } - /* Pre-Vista we have to loop through the LCID values and see if they - match language and TERRITORY. */ - *c++ = '\0'; - /* locale now points to the language, c points to the TERRITORY */ - const char *language = locale; - const char *territory = c; - LCID lang, sublang; - char iso[10]; - - /* In theory the lang part takes 10 bits (0x3ff), but up to Windows 2003 R2 - the highest lang value is 0x81. */ - for (lang = 1; lang <= 0x81; ++lang) - if (GetLocaleInfo (lang, LOCALE_SISO639LANGNAME, iso, 10) - && !strcmp (language, iso)) - break; - if (lang > 0x81) - lcid = 0; - else if (!territory) - lcid = lang; - else - { - /* In theory the sublang part takes 7 bits (0x3f), but up to - Windows 2003 R2 the highest sublang value is 0x14. */ - for (sublang = 1; sublang <= 0x14; ++sublang) - { - lcid = (sublang << 10) | lang; - if (GetLocaleInfo (lcid, LOCALE_SISO3166CTRYNAME, iso, 10) - && !strcmp (territory, iso)) - break; - } - if (sublang > 0x14) - lcid = 0; - } - if (lcid == 0 && territory) - { - /* Unfortunately there are four language LCID number areas representing - multiple languages. Fortunately only two of them already existed - pre-Vista. The concealed languages have to be tested explicitly, - since they are not catched by the above loops. - This also enables the serbian ISO 3166 territory codes which have - been changed post 2003, and maps them to the old wrong (SP was never - a valid ISO 3166 code) territory code sr_SP which fortunately has the - same LCID as the newer sr_CS. - Linux also supports no_NO which is equivalent to nb_NO. */ - struct { - const char *loc; - LCID lcid; - } ambiguous_locale[] = { - { "bs_BA", MAKELANGID (LANG_BOSNIAN, 0x05) }, - { "nn_NO", MAKELANGID (LANG_NORWEGIAN, SUBLANG_NORWEGIAN_NYNORSK) }, - { "no_NO", MAKELANGID (LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL) }, - { "sr_BA", MAKELANGID (LANG_BOSNIAN, - SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC) }, - { "sr_CS", MAKELANGID (LANG_SERBIAN, SUBLANG_SERBIAN_CYRILLIC) }, - { "sr_ME", MAKELANGID (LANG_SERBIAN, SUBLANG_SERBIAN_CYRILLIC) }, - { "sr_RS", MAKELANGID (LANG_SERBIAN, SUBLANG_SERBIAN_CYRILLIC) }, - { "sr_SP", MAKELANGID (LANG_SERBIAN, SUBLANG_SERBIAN_CYRILLIC) }, - { NULL, 0 }, - }; - *--c = '_'; - for (int i = 0; ambiguous_locale[i].loc - && ambiguous_locale[i].loc[0] <= locale[0]; ++i) - if (!strcmp (locale, ambiguous_locale[i].loc) - && GetLocaleInfo (ambiguous_locale[i].lcid, LOCALE_SISO639LANGNAME, - iso, 10)) - { - lcid = ambiguous_locale[i].lcid; - /* "@latin" modifier for the sr_XY locales changes collation - behaviour so lcid should accommodate that by being set to - the Latin sublang. */ - if (!strncmp (locale, "sr_", 3) && has_modifier ("@latin")) - lcid = MAKELANGID (lcid & 0x3ff, (lcid >> 10) - 1); - break; - } - } - else if (lcid == 0x0443) /* uz_UZ (Uzbek/Uzbekistan) */ - { - /* Equivalent for "@cyrillic" modifier in uz_UZ locale */ - if (lcid != 0 && has_modifier ("@cyrillic")) - lcid = MAKELANGID (lcid & 0x3ff, (lcid >> 10) + 1); - } - last_lcid = lcid ?: (LCID) -1; - debug_printf ("LCID=0x%04x", last_lcid); - return last_lcid; -} - -/* Never returns -1. Just skips invalid chars instead. Only if return_invalid - is set, s==NULL returns -1 since then it's used to recognize invalid strings - in the used charset. */ -static size_t -lc_wcstombs (wctomb_p f_wctomb, const char *charset, - char *s, const wchar_t *pwcs, size_t n, - bool return_invalid = false) -{ - char *ptr = s; - size_t max = n; - char buf[8]; - size_t i, bytes, num_to_copy; - mbstate_t state; - - memset (&state, 0, sizeof state); - if (s == NULL) - { - size_t num_bytes = 0; - while (*pwcs != 0) - { - bytes = f_wctomb (_REENT, buf, *pwcs++, charset, &state); - if (bytes != (size_t) -1) - num_bytes += bytes; - else if (return_invalid) - return (size_t) -1; - } - return num_bytes; - } - while (n > 0) - { - bytes = f_wctomb (_REENT, buf, *pwcs, charset, &state); - if (bytes == (size_t) -1) - { - memset (&state, 0, sizeof state); - ++pwcs; - continue; - } - num_to_copy = (n > bytes ? bytes : n); - for (i = 0; i < num_to_copy; ++i) - *ptr++ = buf[i]; - - if (*pwcs == 0x00) - return ptr - s - (n >= bytes); - ++pwcs; - n -= num_to_copy; - } - return max; -} - -/* Never returns -1. Invalid sequences are translated to replacement - wide-chars. */ -static size_t -lc_mbstowcs (mbtowc_p f_mbtowc, const char *charset, - wchar_t *pwcs, const char *s, size_t n) -{ - size_t ret = 0; - char *t = (char *) s; - size_t bytes; - mbstate_t state; - - memset (&state, 0, sizeof state); - if (!pwcs) - n = 1; - while (n > 0) - { - bytes = f_mbtowc (_REENT, pwcs, t, 6 /* fake, always enough */, - charset, &state); - if (bytes == (size_t) -1) - { - state.__count = 0; - bytes = 1; - if (pwcs) - *pwcs = L' '; - } - else if (bytes == 0) - break; - t += bytes; - ++ret; - if (pwcs) - { - ++pwcs; - --n; - } - } - return ret; -} - -static char * -__getlocaleinfo (LCID lcid, LCTYPE type, char **ptr, size_t size, - wctomb_p f_wctomb, const char *charset) -{ - wchar_t wbuf[80]; - size_t num; - char *ret; - - GetLocaleInfoW (lcid, type, wbuf, 80); - num = lc_wcstombs (f_wctomb, charset, ret = *ptr, wbuf, size); - *ptr += num + 1; - return ret; -} - -static UINT -getlocaleint (LCID lcid, LCTYPE type) -{ - UINT val; - return GetLocaleInfoW (lcid, type | LOCALE_RETURN_NUMBER, (PWCHAR) &val, - sizeof val) ? val : 0; -} - -static char * -__eval_datetimefmt (LCID lcid, LCTYPE type, int force, char **ptr, - size_t size, wctomb_p f_wctomb, const char *charset) -{ - wchar_t buf[80]; - wchar_t fc; - size_t num; - mbstate_t mb; - size_t idx; - const char *day_str = "edaA"; - const char *mon_str = "mmbB"; - const char *year_str = "yyyY"; - const char *hour12_str = "lI"; - const char *hour24_str = "kH"; - const char *t_str; - char *ret = *ptr; - char *p = *ptr; - - GetLocaleInfoW (lcid, type, buf, 80); - memset (&mb, 0, sizeof mb); - for (wchar_t *fmt = buf; *fmt; ++fmt) - switch (fc = *fmt) - { - case L'\'': - if (fmt[1] == L'\'') - *p++ = '\''; - else - while (fmt[1] && *++fmt != L'\'') - { - num = f_wctomb (_REENT, p, *fmt, charset, &mb); - if (num == (size_t) -1) - memset (&mb, 0, sizeof mb); - else - p += num; - } - break; - case L'd': - case L'M': - case L'y': - t_str = (fc == L'd' ? day_str : fc == L'M' ? mon_str : year_str); - if (fc == L'y') - force = 0; - for (idx = 1; fmt[1] == fc; ++idx, ++fmt); - if (--idx > 3) - idx = 3; - if (force && idx == 3) - idx = 2; - *p++ = '%'; - *p++ = t_str[idx]; - break; - case L'g': - break; - case L'h': - case L'H': - t_str = (fc == L'h' || force ? hour12_str : hour24_str); - idx = 0; - if (fmt[1] == fc) - { - ++fmt; - idx = 1; - } - *p++ = '%'; - *p++ = t_str[idx]; - break; - case L'm': - case L's': - case L't': - if (fmt[1] == fc) - ++fmt; - *p++ = '%'; - *p++ = (fc == L'm' ? 'M' : fc == L's' ? 'S' : 'p'); - break; - case L'\t': - case L'\n': - case L'%': - *p++ = '%'; - *p++ = (char) fc; - break; - default: - num = f_wctomb (_REENT, p, *fmt, charset, &mb); - if (num == (size_t) -1) - memset (&mb, 0, sizeof mb); - else - p += num; - break; - } - *p++ = '\0'; - *ptr = p; - return ret; -} - -/* Convert Windows grouping format into POSIX grouping format. */ -static char * -conv_grouping (LCID lcid, LCTYPE type, char **lc_ptr) -{ - char buf[10]; /* Per MSDN max size of LOCALE_SGROUPING element incl. NUL */ - bool repeat = false; - char *ptr = *lc_ptr; - char *ret = ptr; - - GetLocaleInfoA (lcid, type, buf, 10); - /* Convert Windows grouping format into POSIX grouping format. */ - for (char *c = buf; *c; ++c) - { - if (*c < '0' || *c > '9') - continue; - char val = *c - '0'; - if (!val) - { - repeat = true; - break; - } - *ptr++ = val; - } - if (!repeat) - *ptr++ = CHAR_MAX; - *ptr++ = '\0'; - *lc_ptr = ptr; - return ret; -} - -/* Called from newlib's setlocale() via __time_load_locale() if category - is LC_TIME. Returns LC_TIME values fetched from Windows locale data - in the structure pointed to by _time_locale. This is subsequently - accessed by functions like nl_langinfo, strftime, strptime. */ -extern "C" int -__set_lc_time_from_win (const char *name, struct lc_time_T *_time_locale, - char **lc_time_buf, wctomb_p f_wctomb, - const char *charset) -{ - LCID lcid = __get_lcid_from_locale (name); - if (!lcid || lcid == (LCID) -1) - return lcid; - - char *new_lc_time_buf = (char *) malloc (4096); - const char *lc_time_end = new_lc_time_buf + 4096; - - if (!new_lc_time_buf) - return -1; - char *lc_time_ptr = new_lc_time_buf; - /* mon */ - for (int i = 0; i < 12; ++i) - _time_locale->mon[i] = getlocaleinfo (time, LOCALE_SABBREVMONTHNAME1 + i); - /* month and alt_month */ - for (int i = 0; i < 12; ++i) - _time_locale->month[i] = _time_locale->alt_month[i] - = getlocaleinfo (time, LOCALE_SMONTHNAME1 + i); - /* wday */ - _time_locale->wday[0] = getlocaleinfo (time, LOCALE_SABBREVDAYNAME7); - for (int i = 0; i < 6; ++i) - _time_locale->wday[i + 1] = getlocaleinfo (time, - LOCALE_SABBREVDAYNAME1 + i); - /* weekday */ - _time_locale->weekday[0] = getlocaleinfo (time, LOCALE_SDAYNAME7); - for (int i = 0; i < 6; ++i) - _time_locale->weekday[i + 1] = getlocaleinfo (time, LOCALE_SDAYNAME1 + i); - /* X_fmt */ - _time_locale->X_fmt = eval_datetimefmt (LOCALE_STIMEFORMAT, 0); - /* x_fmt */ - _time_locale->x_fmt = eval_datetimefmt (LOCALE_SSHORTDATE, 0); - /* c_fmt */ - _time_locale->c_fmt = eval_datetimefmt (LOCALE_SLONGDATE, 1); - --lc_time_ptr; - *lc_time_ptr++ = ' '; - eval_datetimefmt (LOCALE_STIMEFORMAT, 0); - /* AM/PM */ - _time_locale->am_pm[0] = getlocaleinfo (time, LOCALE_S1159); - _time_locale->am_pm[1] = getlocaleinfo (time, LOCALE_S2359); - /* date_fmt */ - _time_locale->date_fmt = eval_datetimefmt (LOCALE_SLONGDATE, 1); - --lc_time_ptr; - *lc_time_ptr++ = ' '; - eval_datetimefmt (LOCALE_STIMEFORMAT, 0); - --lc_time_ptr; - lc_time_ptr = stpcpy (lc_time_ptr, " %Z") + 1; - /* md */ - { - wchar_t buf[80]; - GetLocaleInfoW (lcid, LOCALE_IDATE, buf, 80); - lc_time_ptr = stpcpy (lc_time_ptr, *buf == L'1' ? "dm" : "md") + 1; - } - /* ampm_fmt */ - _time_locale->ampm_fmt = eval_datetimefmt (LOCALE_STIMEFORMAT, 1); - - char *tmp = (char *) realloc (new_lc_time_buf, lc_time_ptr - new_lc_time_buf); - if (!tmp) - { - free (new_lc_time_buf); - return -1; - } - if (*lc_time_buf) - free (*lc_time_buf); - *lc_time_buf = tmp; - return 1; -} - -/* Called from newlib's setlocale() via __numeric_load_locale() if category - is LC_NUMERIC. Returns LC_NUMERIC values fetched from Windows locale data - in the structure pointed to by _numeric_locale. This is subsequently - accessed by functions like nl_langinfo, localeconv, printf, etc. */ -extern "C" int -__set_lc_numeric_from_win (const char *name, - struct lc_numeric_T *_numeric_locale, - char **lc_numeric_buf, wctomb_p f_wctomb, - const char *charset) -{ - LCID lcid = __get_lcid_from_locale (name); - if (!lcid || lcid == (LCID) -1) - return lcid; - - char *new_lc_numeric_buf = (char *) malloc (48); - const char *lc_numeric_end = new_lc_numeric_buf + 48; - - if (!new_lc_numeric_buf) - return -1; - char *lc_numeric_ptr = new_lc_numeric_buf; - /* decimal_point */ - _numeric_locale->decimal_point = getlocaleinfo (numeric, - LOCALE_SDECIMAL); - /* thousands_sep */ - _numeric_locale->thousands_sep = getlocaleinfo (numeric, - LOCALE_STHOUSAND); - /* grouping */ - _numeric_locale->grouping = conv_grouping (lcid, LOCALE_SGROUPING, - &lc_numeric_ptr); - - char *tmp = (char *) realloc (new_lc_numeric_buf, - lc_numeric_ptr - new_lc_numeric_buf); - if (!tmp) - { - free (new_lc_numeric_buf); - return -1; - } - if (*lc_numeric_buf) - free (*lc_numeric_buf); - *lc_numeric_buf = tmp; - return 1; -} - -/* Called from newlib's setlocale() via __monetary_load_locale() if category - is LC_MONETARY. Returns LC_MONETARY values fetched from Windows locale data - in the structure pointed to by _monetary_locale. This is subsequently - accessed by functions like nl_langinfo, localeconv, printf, etc. */ -extern "C" int -__set_lc_monetary_from_win (const char *name, - struct lc_monetary_T *_monetary_locale, - char **lc_monetary_buf, wctomb_p f_wctomb, - const char *charset) -{ - LCID lcid = __get_lcid_from_locale (name); - if (!lcid || lcid == (LCID) -1) - return lcid; - - char *new_lc_monetary_buf = (char *) malloc (256); - const char *lc_monetary_end = new_lc_monetary_buf + 256; - - if (!new_lc_monetary_buf) - return -1; - char *lc_monetary_ptr = new_lc_monetary_buf; - /* int_curr_symbol */ - _monetary_locale->int_curr_symbol = getlocaleinfo (monetary, - LOCALE_SINTLSYMBOL); - /* No spacing char means space. */ - if (!_monetary_locale->int_curr_symbol[3]) - { - lc_monetary_ptr[-1] = ' '; - *lc_monetary_ptr++ = '\0'; - } - /* currency_symbol */ - { - /* As on Linux: If the currency_symbol can't be represented in the - given charset, use int_curr_symbol. */ - wchar_t wbuf[14]; - GetLocaleInfoW (lcid, LOCALE_SCURRENCY, wbuf, 14); - if (lc_wcstombs (f_wctomb, charset, NULL, wbuf, 0, true) == (size_t) -1) - { - _monetary_locale->currency_symbol = lc_monetary_ptr; - lc_monetary_ptr = stpncpy (lc_monetary_ptr, - _monetary_locale->int_curr_symbol, 3); - *lc_monetary_ptr++ = '\0'; - } - else - _monetary_locale->currency_symbol = getlocaleinfo (monetary, - LOCALE_SCURRENCY); - } - /* mon_decimal_point */ - _monetary_locale->mon_decimal_point = getlocaleinfo (monetary, - LOCALE_SMONDECIMALSEP); - /* mon_thousands_sep */ - _monetary_locale->mon_thousands_sep = getlocaleinfo (monetary, - LOCALE_SMONTHOUSANDSEP); - /* mon_grouping */ - _monetary_locale->mon_grouping = conv_grouping (lcid, LOCALE_SMONGROUPING, - &lc_monetary_ptr); - /* positive_sign */ - _monetary_locale->positive_sign = getlocaleinfo (monetary, - LOCALE_SPOSITIVESIGN); - /* negative_sign */ - _monetary_locale->negative_sign = getlocaleinfo (monetary, - LOCALE_SNEGATIVESIGN); - /* int_frac_digits */ - *lc_monetary_ptr = (char) getlocaleint (lcid, LOCALE_IINTLCURRDIGITS); - _monetary_locale->int_frac_digits = lc_monetary_ptr++; - /* frac_digits */ - *lc_monetary_ptr = (char) getlocaleint (lcid, LOCALE_ICURRDIGITS); - _monetary_locale->frac_digits = lc_monetary_ptr++; - /* p_cs_precedes */ - *lc_monetary_ptr = (char) getlocaleint (lcid, LOCALE_IPOSSYMPRECEDES); - _monetary_locale->p_cs_precedes = lc_monetary_ptr++; - /* p_sep_by_space */ - *lc_monetary_ptr = (char) getlocaleint (lcid, LOCALE_IPOSSEPBYSPACE); - _monetary_locale->p_sep_by_space = lc_monetary_ptr++; - /* n_cs_precedes */ - *lc_monetary_ptr = (char) getlocaleint (lcid, LOCALE_INEGSYMPRECEDES); - _monetary_locale->n_cs_precedes = lc_monetary_ptr++; - /* n_sep_by_space */ - *lc_monetary_ptr = (char) getlocaleint (lcid, LOCALE_INEGSEPBYSPACE); - _monetary_locale->n_sep_by_space = lc_monetary_ptr++; - /* p_sign_posn */ - *lc_monetary_ptr = (char) getlocaleint (lcid, LOCALE_IPOSSIGNPOSN); - _monetary_locale->p_sign_posn = lc_monetary_ptr++; - /* p_sign_posn */ - *lc_monetary_ptr = (char) getlocaleint (lcid, LOCALE_INEGSIGNPOSN); - _monetary_locale->n_sign_posn = lc_monetary_ptr++; - - char *tmp = (char *) realloc (new_lc_monetary_buf, - lc_monetary_ptr - new_lc_monetary_buf); - if (!tmp) - { - free (new_lc_monetary_buf); - return -1; - } - if (*lc_monetary_buf) - free (*lc_monetary_buf); - *lc_monetary_buf = tmp; - return 1; -} - -static int -locale_cmp (const void *a, const void *b) -{ - struct lc_msg_t *la = (struct lc_msg_t *) a; - struct lc_msg_t *lb = (struct lc_msg_t *) b; - return strcmp (la->locale, lb->locale); -} - -extern "C" int -__set_lc_messages_from_win (const char *name, - struct lc_messages_T *_messages_locale, - char **lc_messages_buf, - wctomb_p f_wctomb, const char *charset) -{ - LCID lcid = __get_lcid_from_locale (name); - if (!lcid || lcid == (LCID) -1) - return lcid; - - char locale[ENCODING_LEN + 1]; - char *c, *c2; - - strcpy (locale, name); - /* Removes the charset from the locale and attach the modifer to the - language_TERRITORY part. */ - c = strchr (locale, '.'); - if (c) - { - *c = '\0'; - c2 = strchr (c + 1, '@'); - /* Ignore @cjknarrow modifier since it's a very personal thing between - Cygwin and newlib... */ - if (c2 && strcmp (c2, "@cjknarrow")) - memmove (c, c2, strlen (c2) + 1); - } - /* Now search in the alphabetically order lc_msg array for the - locale. */ - lc_msg_t locale_key = { locale, NULL, NULL, NULL, NULL }; - lc_msg_t *res = (lc_msg_t *) bsearch ((void *) &locale_key, (void *) lc_msg, - sizeof lc_msg / sizeof *lc_msg, - sizeof *lc_msg, locale_cmp); - if (!res) - return 0; - - /* Evaluate string length in target charset. Characters invalid in the - target charset are simply ignored, as on Linux. */ - size_t len = 0; - len += lc_wcstombs (f_wctomb, charset, NULL, res->yesexpr, 0) + 1; - len += lc_wcstombs (f_wctomb, charset, NULL, res->noexpr, 0) + 1; - len += lc_wcstombs (f_wctomb, charset, NULL, res->yesstr, 0) + 1; - len += lc_wcstombs (f_wctomb, charset, NULL, res->nostr, 0) + 1; - /* Allocate. */ - char *new_lc_messages_buf = (char *) malloc (len); - const char *lc_messages_end = new_lc_messages_buf + len; - - if (!new_lc_messages_buf) - return -1; - /* Copy over. */ - c = new_lc_messages_buf; - _messages_locale->yesexpr = (const char *) c; - len = lc_wcstombs (f_wctomb, charset, c, res->yesexpr, lc_messages_end - c); - _messages_locale->noexpr = (const char *) (c += len + 1); - len = lc_wcstombs (f_wctomb, charset, c, res->noexpr, lc_messages_end - c); - _messages_locale->yesstr = (const char *) (c += len + 1); - len = lc_wcstombs (f_wctomb, charset, c, res->yesstr, lc_messages_end - c); - _messages_locale->nostr = (const char *) (c += len + 1); - lc_wcstombs (f_wctomb, charset, c, res->nostr, lc_messages_end - c); - /* Aftermath. */ - if (*lc_messages_buf) - free (*lc_messages_buf); - *lc_messages_buf = new_lc_messages_buf; - return 1; -} - -LCID collate_lcid = 0; -static mbtowc_p collate_mbtowc = __ascii_mbtowc; -char collate_charset[ENCODING_LEN + 1] = "ASCII"; - -/* Called from newlib's setlocale() if category is LC_COLLATE. Stores - LC_COLLATE locale information. This is subsequently accessed by the - below functions strcoll, strxfrm, wcscoll, wcsxfrm. */ -extern "C" int -__collate_load_locale (const char *name, mbtowc_p f_mbtowc, const char *charset) -{ - LCID lcid = __get_lcid_from_locale (name); - if (lcid == (LCID) -1) - return -1; - collate_lcid = lcid; - collate_mbtowc = f_mbtowc; - stpcpy (collate_charset, charset); - return 0; -} - -/* We use the Windows functions for locale-specific string comparison and - transformation. The advantage is that we don't need any files with - collation information. */ -extern "C" int -wcscoll (const wchar_t *ws1, const wchar_t *ws2) -{ - int ret; - - if (!collate_lcid) - return wcscmp (ws1, ws2); - ret = CompareStringW (collate_lcid, 0, ws1, -1, ws2, -1); - if (!ret) - set_errno (EINVAL); - return ret - CSTR_EQUAL; -} - -extern "C" int -strcoll (const char *s1, const char *s2) -{ - size_t n1, n2; - wchar_t *ws1, *ws2; - tmp_pathbuf tp; - int ret; - - if (!collate_lcid) - return strcmp (s1, s2); - /* The ANSI version of CompareString uses the default charset of the lcid, - so we must use the Unicode version. */ - n1 = lc_mbstowcs (collate_mbtowc, collate_charset, NULL, s1, 0) + 1; - ws1 = (n1 > NT_MAX_PATH ? (wchar_t *) malloc (n1 * sizeof (wchar_t)) - : tp.w_get ()); - lc_mbstowcs (collate_mbtowc, collate_charset, ws1, s1, n1); - n2 = lc_mbstowcs (collate_mbtowc, collate_charset, NULL, s2, 0) + 1; - ws2 = (n2 > NT_MAX_PATH ? (wchar_t *) malloc (n2 * sizeof (wchar_t)) - : tp.w_get ()); - lc_mbstowcs (collate_mbtowc, collate_charset, ws2, s2, n2); - ret = CompareStringW (collate_lcid, 0, ws1, -1, ws2, -1); - if (n1 > NT_MAX_PATH) - free (ws1); - if (n2 > NT_MAX_PATH) - free (ws2); - if (!ret) - set_errno (EINVAL); - return ret - CSTR_EQUAL; -} - -extern "C" size_t -wcsxfrm (wchar_t *ws1, const wchar_t *ws2, size_t wsn) -{ - size_t ret; - - if (!collate_lcid) - return wcslcpy (ws1, ws2, wsn); - ret = LCMapStringW (collate_lcid, LCMAP_SORTKEY | LCMAP_BYTEREV, - ws2, -1, ws1, wsn * sizeof (wchar_t)); - /* LCMapStringW returns byte count including the terminating NUL character, - wcsxfrm is supposed to return length in wchar_t excluding the NUL. - Since the array is only single byte NUL-terminated we must make sure - the result is wchar_t-NUL terminated. */ - if (ret) - { - ret = (ret + 1) / sizeof (wchar_t); - if (ret >= wsn) - return wsn; - ws1[ret] = L'\0'; - return ret; - } - if (GetLastError () != ERROR_INSUFFICIENT_BUFFER) - set_errno (EINVAL); - return wsn; -} - -extern "C" size_t -strxfrm (char *s1, const char *s2, size_t sn) -{ - size_t ret; - size_t n2; - wchar_t *ws2; - tmp_pathbuf tp; - - if (!collate_lcid) - return strlcpy (s1, s2, sn); - /* The ANSI version of LCMapString uses the default charset of the lcid, - so we must use the Unicode version. */ - n2 = lc_mbstowcs (collate_mbtowc, collate_charset, NULL, s2, 0) + 1; - ws2 = (n2 > NT_MAX_PATH ? (wchar_t *) malloc (n2 * sizeof (wchar_t)) - : tp.w_get ()); - lc_mbstowcs (collate_mbtowc, collate_charset, ws2, s2, n2); - /* The sort key is a NUL-terminated byte string. */ - ret = LCMapStringW (collate_lcid, LCMAP_SORTKEY, ws2, -1, (PWCHAR) s1, sn); - if (n2 > NT_MAX_PATH) - free (ws2); - if (ret == 0) - { - if (GetLastError () != ERROR_INSUFFICIENT_BUFFER) - set_errno (EINVAL); - return sn; - } - /* LCMapStringW returns byte count including the terminating NUL character. - strxfrm is supposed to return length excluding the NUL. */ - return ret - 1; -} - -/* Fetch default ANSI codepage from locale info and generate a setlocale - compatible character set code. Called from newlib's setlocale(), if the - charset isn't given explicitely in the POSIX compatible locale specifier. */ -extern "C" void -__set_charset_from_locale (const char *locale, char *charset) -{ - UINT cp; - LCID lcid = __get_lcid_from_locale (locale); - wchar_t wbuf[9]; - - /* "C" locale, or invalid locale? */ - if (lcid == 0 || lcid == (LCID) -1) - cp = 20127; - else if (!GetLocaleInfoW (lcid, - LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER, - (PWCHAR) &cp, sizeof cp)) - cp = 0; - /* Translate codepage and lcid to a charset closely aligned with the default - charsets defined in Glibc. */ - const char *cs; - const char *modifier = strchr (locale, '@') ?: ""; - switch (cp) - { - case 20127: - cs = "ASCII"; - break; - case 874: - cs = "CP874"; - break; - case 932: - cs = "EUCJP"; - break; - case 936: - cs = "GBK"; - break; - case 949: - cs = "EUCKR"; - break; - case 950: - cs = "BIG5"; - break; - case 1250: - if (lcid == 0x081a /* sr_CS (Serbian Language/Former - Serbia and Montenegro) */ - || lcid == 0x181a /* sr_BA (Serbian Language/Bosnia - and Herzegovina) */ - || lcid == 0x241a /* sr_RS (Serbian Language/Serbia) */ - || lcid == 0x2c1a /* sr_ME (Serbian Language/Montenegro)*/ - || lcid == 0x0442) /* tk_TM (Turkmen/Turkmenistan) */ - cs = "UTF-8"; - else if (lcid == 0x041c) /* sq_AL (Albanian/Albania) */ - cs = "ISO-8859-1"; - else - cs = "ISO-8859-2"; - break; - case 1251: - if (lcid == 0x0c1a /* sr_CS (Serbian Language/Former - Serbia and Montenegro) */ - || lcid == 0x1c1a /* sr_BA (Serbian Language/Bosnia - and Herzegovina) */ - || lcid == 0x281a /* sr_RS (Serbian Language/Serbia) */ - || lcid == 0x301a /* sr_ME (Serbian Language/Montenegro)*/ - || lcid == 0x0440 /* ky_KG (Kyrgyz/Kyrgyzstan) */ - || lcid == 0x0843 /* uz_UZ (Uzbek/Uzbekistan) */ - /* tt_RU (Tatar/Russia), - IQTElif alphabet */ - || (lcid == 0x0444 && has_modifier ("@iqtelif")) - || lcid == 0x0450) /* mn_MN (Mongolian/Mongolia) */ - cs = "UTF-8"; - else if (lcid == 0x0423) /* be_BY (Belarusian/Belarus) */ - cs = has_modifier ("@latin") ? "UTF-8" : "CP1251"; - else if (lcid == 0x0402) /* bg_BG (Bulgarian/Bulgaria) */ - cs = "CP1251"; - else if (lcid == 0x0422) /* uk_UA (Ukrainian/Ukraine) */ - cs = "KOI8-U"; - else - cs = "ISO-8859-5"; - break; - case 1252: - if (lcid == 0x0452) /* cy_GB (Welsh/Great Britain) */ - cs = "ISO-8859-14"; - else if (lcid == 0x4009 /* en_IN (English/India) */ - || lcid == 0x0464 /* fil_PH (Filipino/Philippines) */ - || lcid == 0x0462 /* fy_NL (Frisian/Netherlands) */ - || lcid == 0x0468 /* ha_NG (Hausa/Nigeria) */ - || lcid == 0x0470 /* ig_NG (Igbo/Nigeria) */ - || lcid == 0x046c /* nso_ZA (Northern Sotho/South Africa) */ - || lcid == 0x0487 /* rw_RW (Kinyarwanda/Rwanda) */ - || lcid == 0x043b /* se_NO (Northern Saami/Norway) */ - || lcid == 0x0432 /* tn_ZA (Tswana/South Africa) */ - || lcid == 0x0488 /* wo_SN (Wolof/Senegal) */ - || lcid == 0x046a /* yo_NG (Yoruba/Nigeria) */ - || lcid == 0x085d) /* iu_CA (Inuktitut/Canada) */ - cs = "UTF-8"; - else if (lcid == 0x042e) /* hsb_DE (Upper Sorbian/Germany) */ - cs = "ISO-8859-2"; - else if (lcid == 0x0491 /* gd_GB (Scots Gaelic/Great Britain) */ - || (has_modifier ("@euro") - && GetLocaleInfoW (lcid, LOCALE_SINTLSYMBOL, wbuf, 9) - && !wcsncmp (wbuf, L"EUR", 3))) - cs = "ISO-8859-15"; - else - cs = "ISO-8859-1"; - break; - case 1253: - cs = "ISO-8859-7"; - break; - case 1254: - if (lcid == 0x042c) /* az_AZ (Azeri/Azerbaijan) */ - cs = "UTF-8"; - else if (lcid == 0x0443) /* uz_UZ (Uzbek/Uzbekistan) */ - cs = "ISO-8859-1"; - else - cs = "ISO-8859-9"; - break; - case 1255: - cs = "ISO-8859-8"; - break; - case 1256: - if (lcid == 0x0429 /* fa_IR (Persian/Iran) */ - || lcid == 0x0480 /* ug_CN (Uyghur/China) */ - || lcid == 0x0420) /* ur_PK (Urdu/Pakistan) */ - cs = "UTF-8"; - else - cs = "ISO-8859-6"; - break; - case 1257: - if (lcid == 0x0425) /* et_EE (Estonian/Estonia) */ - cs = "ISO-8859-15"; - else - cs = "ISO-8859-13"; - break; - case 1258: - default: - if (lcid == 0x0481) /* mi_NZ (Maori/New Zealand) */ - cs = "ISO-8859-13"; - else if (lcid == 0x043a) /* mt_MT (Maltese/Malta) */ - cs = "ISO-8859-3"; - else if (lcid == 0x0437) /* ka_GE (Georgian/Georgia) */ - cs = "GEORGIAN-PS"; - else if (lcid == 0x043f) /* kk_KZ (Kazakh/Kazakhstan) */ - cs = "PT154"; - else - cs = "UTF-8"; - break; - } - stpcpy (charset, cs); -} - -/* This function is called from newlib's loadlocale if the locale identifier - was invalid, one way or the other. It looks for the file - - /usr/share/locale/locale.alias - - which is part of the gettext package, and if it finds the locale alias - in that file, it replaces the locale with the correct locale string from - that file. - - If successful, it returns a pointer to new_locale, NULL otherwise.*/ -extern "C" char * -__set_locale_from_locale_alias (const char *locale, char *new_locale) -{ - wchar_t wlocale[ENCODING_LEN + 1]; - wchar_t walias[ENCODING_LEN + 1]; -#define LOCALE_ALIAS_LINE_LEN 255 - char alias_buf[LOCALE_ALIAS_LINE_LEN + 1], *c; - wchar_t *wc; - const char *alias, *replace; - char *ret = NULL; - - FILE *fp = fopen ("/usr/share/locale/locale.alias", "rt"); - if (!fp) - return NULL; - /* The incoming locale is given in the application charset, or in - the Cygwin internal charset. We try both. */ - if (mbstowcs (wlocale, locale, ENCODING_LEN + 1) == (size_t) -1) - sys_mbstowcs (wlocale, ENCODING_LEN + 1, locale); - wlocale[ENCODING_LEN] = L'\0'; - /* Ignore @cjknarrow modifier since it's a very personal thing between - Cygwin and newlib... */ - if ((wc = wcschr (wlocale, L'@')) && !wcscmp (wc + 1, L"cjknarrow")) - *wc = L'\0'; - while (fgets (alias_buf, LOCALE_ALIAS_LINE_LEN + 1, fp)) - { - alias_buf[LOCALE_ALIAS_LINE_LEN] = '\0'; - c = strrchr (alias_buf, '\n'); - if (c) - *c = '\0'; - c = alias_buf; - c += strspn (c, " \t"); - if (!*c || *c == '#') - continue; - alias = c; - c += strcspn (c, " \t"); - *c++ = '\0'; - c += strspn (c, " \t"); - if (*c == '#') - continue; - replace = c; - c += strcspn (c, " \t"); - *c++ = '\0'; - if (strlen (replace) > ENCODING_LEN) - continue; - /* The file is latin1 encoded */ - lc_mbstowcs (__iso_mbtowc, "ISO-8859-1", walias, alias, ENCODING_LEN + 1); - walias[ENCODING_LEN] = L'\0'; - if (!wcscmp (wlocale, walias)) - { - ret = strcpy (new_locale, replace); - break; - } - } - fclose (fp); - return ret; -} - -static char * -check_codepage (char *ret) -{ - if (!wincap.has_always_all_codepages ()) - { - /* Prior to Windows Vista, many codepages are not installed by - default, or can be deinstalled. The following codepages require - that the respective conversion tables are installed into the OS. - So we check if they are installed and if not, setlocale should - fail. */ - CPINFO cpi; - UINT cp = 0; - if (__mbtowc == __sjis_mbtowc) - cp = 932; - else if (__mbtowc == __eucjp_mbtowc) - cp = 20932; - else if (__mbtowc == __gbk_mbtowc) - cp = 936; - else if (__mbtowc == __kr_mbtowc) - cp = 949; - else if (__mbtowc == __big5_mbtowc) - cp = 950; - if (cp && !GetCPInfo (cp, &cpi) - && GetLastError () == ERROR_INVALID_PARAMETER) - return NULL; - } - return ret; -} - -/* Can be called via cygwin_internal (CW_INTERNAL_SETLOCALE) for application - which really (think they) know what they are doing. */ -extern "C" void -internal_setlocale () -{ - /* Each setlocale from the environment potentially changes the - multibyte representation of the CWD. Therefore we have to - reevaluate the CWD's posix path and store in the new charset. - Same for the PATH environment variable. */ - /* FIXME: Other buffered paths might be affected as well. */ - /* FIXME: It could be necessary to convert the entire environment, - not just PATH. */ - tmp_pathbuf tp; - char *path; - wchar_t *w_path = NULL, *w_cwd; - - /* Don't do anything if the charset hasn't actually changed. */ - if (strcmp (cygheap->locale.charset, __locale_charset ()) == 0) - return; - - debug_printf ("Cygwin charset changed from %s to %s", - cygheap->locale.charset, __locale_charset ()); - /* Fetch PATH and CWD and convert to wchar_t in previous charset. */ - path = getenv ("PATH"); - if (path && *path) /* $PATH can be potentially unset. */ - { - w_path = tp.w_get (); - sys_mbstowcs (w_path, 32768, path); - } - w_cwd = tp.w_get (); - cwdstuff::cwd_lock.acquire (); - sys_mbstowcs (w_cwd, 32768, cygheap->cwd.get_posix ()); - /* Set charset for internal conversion functions. */ - if (*__locale_charset () == 'A'/*SCII*/) - { - cygheap->locale.mbtowc = __utf8_mbtowc; - cygheap->locale.wctomb = __utf8_wctomb; - } - else - { - cygheap->locale.mbtowc = __mbtowc; - cygheap->locale.wctomb = __wctomb; - } - strcpy (cygheap->locale.charset, __locale_charset ()); - /* Restore CWD and PATH in new charset. */ - cygheap->cwd.reset_posix (w_cwd); - cwdstuff::cwd_lock.release (); - if (w_path) - { - char *c_path = tp.c_get (); - sys_wcstombs (c_path, 32768, w_path); - setenv ("PATH", c_path, 1); - } -} - -/* Called from dll_crt0_1, before fetching the command line from Windows. - Set the internal charset according to the environment locale settings. - Check if a required codepage is available, and only switch internal - charset if so. - Make sure to reset the application locale to "C" per POSIX. */ -void -initial_setlocale () -{ - char *ret = _setlocale_r (_REENT, LC_CTYPE, ""); - if (ret && check_codepage (ret)) - internal_setlocale (); -} - -/* Like newlib's setlocale, but additionally check if the charset needs - OS support and the required codepage is actually installed. If codepage - is not available, revert to previous locale and return NULL. For details - about codepage availability, see the comment in check_codepage() above. */ -extern "C" char * -setlocale (int category, const char *locale) -{ - char old[(LC_MESSAGES + 1) * (ENCODING_LEN + 1/*"/"*/ + 1)]; - if (locale && !wincap.has_always_all_codepages ()) - stpcpy (old, _setlocale_r (_REENT, category, NULL)); - char *ret = _setlocale_r (_REENT, category, locale); - if (ret && locale && !(ret = check_codepage (ret))) - _setlocale_r (_REENT, category, old); - return ret; -} diff --git a/winsup/cygwin/ntdll.h b/winsup/cygwin/ntdll.h deleted file mode 100644 index 465d52782..000000000 --- a/winsup/cygwin/ntdll.h +++ /dev/null @@ -1,1096 +0,0 @@ -/* ntdll.h. Contains ntdll specific stuff not defined elsewhere. - - Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, - 2009, 2010 Red Hat, Inc. - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#define STATUS_NOT_ALL_ASSIGNED ((NTSTATUS) 0x00000106) -#define STATUS_OBJECT_NAME_EXISTS ((NTSTATUS) 0x40000000) -#define STATUS_BUFFER_OVERFLOW ((NTSTATUS) 0x80000005) -#define STATUS_NO_MORE_FILES ((NTSTATUS) 0x80000006) -#ifndef STATUS_INVALID_INFO_CLASS -/* Some w32api header file defines this so we need to conditionalize this - define to avoid warnings. */ -#define STATUS_INVALID_INFO_CLASS ((NTSTATUS) 0xc0000003) -#endif -#define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS) 0xc0000004) -#define STATUS_INVALID_PARAMETER ((NTSTATUS) 0xc000000d) -#define STATUS_NO_SUCH_FILE ((NTSTATUS) 0xc000000f) -#define STATUS_INVALID_DEVICE_REQUEST ((NTSTATUS) 0xc0000010) -#define STATUS_END_OF_FILE ((NTSTATUS) 0xc0000011) -#define STATUS_NO_MEDIA_IN_DEVICE ((NTSTATUS) 0xc0000013) -#define STATUS_ACCESS_DENIED ((NTSTATUS) 0xc0000022) -#define STATUS_BUFFER_TOO_SMALL ((NTSTATUS) 0xc0000023) -#define STATUS_OBJECT_NAME_INVALID ((NTSTATUS) 0xc0000033) -#define STATUS_OBJECT_NAME_NOT_FOUND ((NTSTATUS) 0xc0000034) -#define STATUS_OBJECT_PATH_NOT_FOUND ((NTSTATUS) 0xc000003A) -#define STATUS_SHARING_VIOLATION ((NTSTATUS) 0xc0000043) -#define STATUS_EAS_NOT_SUPPORTED ((NTSTATUS) 0xc000004f) -#define STATUS_EA_TOO_LARGE ((NTSTATUS) 0xc0000050) -#define STATUS_NONEXISTENT_EA_ENTRY ((NTSTATUS) 0xc0000051) -#define STATUS_NO_EAS_ON_FILE ((NTSTATUS) 0xc0000052) -#define STATUS_LOCK_NOT_GRANTED ((NTSTATUS) 0xc0000055) -#define STATUS_DELETE_PENDING ((NTSTATUS) 0xc0000056) -#define STATUS_DISK_FULL ((NTSTATUS) 0xc000007f) -#define STATUS_WORKING_SET_QUOTA ((NTSTATUS) 0xc00000a1) -#define STATUS_NOT_SUPPORTED ((NTSTATUS) 0xc00000bb) -#define STATUS_INVALID_NETWORK_RESPONSE ((NTSTATUS) 0xc00000c3) -#define STATUS_DIRECTORY_NOT_EMPTY ((NTSTATUS) 0xc0000101) -#define STATUS_CANNOT_DELETE ((NTSTATUS) 0xc0000121) -#define STATUS_INVALID_LEVEL ((NTSTATUS) 0xc0000148) -#define STATUS_DLL_NOT_FOUND ((NTSTATUS) 0xc0000135) -#define STATUS_ENTRYPOINT_NOT_FOUND ((NTSTATUS) 0xc0000139) -#define STATUS_BAD_DLL_ENTRYPOINT ((NTSTATUS) 0xc0000251) -#define STATUS_ILLEGAL_DLL_RELOCATION ((NTSTATUS) 0xc0000269) -/* custom status code: */ -#define STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION ((NTSTATUS) 0xe0000269) - -#define PDI_MODULES 0x01 -#define PDI_HEAPS 0x04 -#define LDRP_IMAGE_DLL 0x00000004 -#define WSLE_PAGE_READONLY 0x001 -#define WSLE_PAGE_EXECUTE 0x002 -#define WSLE_PAGE_EXECUTE_READ 0x003 -#define WSLE_PAGE_READWRITE 0x004 -#define WSLE_PAGE_WRITECOPY 0x005 -#define WSLE_PAGE_EXECUTE_READWRITE 0x006 -#define WSLE_PAGE_EXECUTE_WRITECOPY 0x007 -#define WSLE_PAGE_SHARE_COUNT_MASK 0x0E0 -#define WSLE_PAGE_SHAREABLE 0x100 - -#define FILE_SUPERSEDED 0 -#define FILE_OPENED 1 -#define FILE_CREATED 2 -#define FILE_OVERWRITTEN 3 -#define FILE_EXISTS 4 -#define FILE_DOES_NOT_EXIST 5 - -#define FILE_WRITE_TO_END_OF_FILE (-1LL) -#define FILE_USE_FILE_POINTER_POSITION (-2LL) - -/* Device Characteristics. */ -#define FILE_REMOVABLE_MEDIA 0x00000001 -#define FILE_READ_ONLY_DEVICE 0x00000002 -#define FILE_FLOPPY_DISKETTE 0x00000004 -#define FILE_WRITE_ONCE_MEDIA 0x00000008 -#define FILE_REMOTE_DEVICE 0x00000010 -#define FILE_DEVICE_IS_MOUNTED 0x00000020 -#define FILE_VIRTUAL_VOLUME 0x00000040 -#define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080 -#define FILE_DEVICE_SECURE_OPEN 0x00000100 - -/* Transaction access rights. */ -#define TRANSACTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x3F) - -typedef enum _FILE_INFORMATION_CLASS -{ - FileDirectoryInformation = 1, - FileFullDirectoryInformation, // 2 - FileBothDirectoryInformation, // 3 - FileBasicInformation, // 4 wdm - FileStandardInformation, // 5 wdm - FileInternalInformation, // 6 - FileEaInformation, // 7 - FileAccessInformation, // 8 - FileNameInformation, // 9 - FileRenameInformation, // 10 - FileLinkInformation, // 11 - FileNamesInformation, // 12 - FileDispositionInformation, // 13 - FilePositionInformation, // 14 wdm - FileFullEaInformation, // 15 - FileModeInformation, // 16 - FileAlignmentInformation, // 17 - FileAllInformation, // 18 - FileAllocationInformation, // 19 - FileEndOfFileInformation, // 20 wdm - FileAlternateNameInformation, // 21 - FileStreamInformation, // 22 - FilePipeInformation, // 23 - FilePipeLocalInformation, // 24 - FilePipeRemoteInformation, // 25 - FileMailslotQueryInformation, // 26 - FileMailslotSetInformation, // 27 - FileCompressionInformation, // 28 - FileObjectIdInformation, // 29 - FileCompletionInformation, // 30 - FileMoveClusterInformation, // 31 - FileQuotaInformation, // 32 - FileReparsePointInformation, // 33 - FileNetworkOpenInformation, // 34 - FileAttributeTagInformation, // 35 - FileTrackingInformation, // 36 - FileIdBothDirectoryInformation, // 37 - FileIdFullDirectoryInformation, // 38 - FileValidDataLengthInformation, // 39 - FileShortNameInformation, // 40 - FileMaximumInformation -} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS; - -typedef struct _FILE_NAMES_INFORMATION -{ - ULONG NextEntryOffset; - ULONG FileIndex; - ULONG FileNameLength; - WCHAR FileName[1]; -} FILE_NAMES_INFORMATION, *PFILE_NAMES_INFORMATION; - -typedef struct _FILE_DIRECTORY_INFORMATION { - ULONG NextEntryOffset; - ULONG FileIndex; - LARGE_INTEGER CreationTime; - LARGE_INTEGER LastAccessTime; - LARGE_INTEGER LastWriteTime; - LARGE_INTEGER ChangeTime; - LARGE_INTEGER EndOfFile; - LARGE_INTEGER AllocationSize; - ULONG FileAttributes; - ULONG FileNameLength; - WCHAR FileName[1]; -} FILE_DIRECTORY_INFORMATION, *PFILE_DIRECTORY_INFORMATION; - -typedef struct _FILE_BOTH_DIRECTORY_INFORMATION -{ - ULONG NextEntryOffset; - ULONG FileIndex; - LARGE_INTEGER CreationTime; - LARGE_INTEGER LastAccessTime; - LARGE_INTEGER LastWriteTime; - LARGE_INTEGER ChangeTime; - LARGE_INTEGER EndOfFile; - LARGE_INTEGER AllocationSize; - ULONG FileAttributes; - ULONG FileNameLength; - ULONG EaSize; - CCHAR ShortNameLength; - WCHAR ShortName[12]; - WCHAR FileName[1]; -} FILE_BOTH_DIRECTORY_INFORMATION, *PFILE_BOTH_DIRECTORY_INFORMATION; - -typedef struct _FILE_ID_BOTH_DIR_INFORMATION -{ - ULONG NextEntryOffset; - ULONG FileIndex; - LARGE_INTEGER CreationTime; - LARGE_INTEGER LastAccessTime; - LARGE_INTEGER LastWriteTime; - LARGE_INTEGER ChangeTime; - LARGE_INTEGER EndOfFile; - LARGE_INTEGER AllocationSize; - ULONG FileAttributes; - ULONG FileNameLength; - ULONG EaSize; - CCHAR ShortNameLength; - WCHAR ShortName[12]; - LARGE_INTEGER FileId; - WCHAR FileName[1]; -} FILE_ID_BOTH_DIR_INFORMATION, *PFILE_ID_BOTH_DIR_INFORMATION; - - -#define AT_EXTENDABLE_FILE 0x00002000 -#define AT_ROUND_TO_PAGE 0x40000000 - -#define LOCK_VM_IN_WSL 1 -#define LOCK_VM_IN_RAM 2 - -#define DIRECTORY_QUERY 1 -#define DIRECTORY_TRAVERSE 2 -#define DIRECTORY_CREATE_OBJECT 4 -#define DIRECTORY_CREATE_SUBDIRECTORY 8 -#define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|0x0f) - -#define EVENT_QUERY_STATE 1 -#define SEMAPHORE_QUERY_STATE 1 - -/* Specific ACCESS_MASKSs for objects created in Cygwin. */ -#define CYG_SHARED_DIR_ACCESS (DIRECTORY_QUERY \ - | DIRECTORY_TRAVERSE \ - | DIRECTORY_CREATE_SUBDIRECTORY \ - | DIRECTORY_CREATE_OBJECT \ - | READ_CONTROL) - -#define CYG_MUTANT_ACCESS (MUTANT_QUERY_STATE \ - | SYNCHRONIZE \ - | READ_CONTROL) - -#define CYG_EVENT_ACCESS (EVENT_QUERY_STATE \ - | EVENT_MODIFY_STATE \ - | SYNCHRONIZE \ - | READ_CONTROL) - -#define CYG_SEMAPHORE_ACCESS (SEMAPHORE_QUERY_STATE \ - | SEMAPHORE_MODIFY_STATE \ - | SYNCHRONIZE \ - | READ_CONTROL) - -typedef ULONG KAFFINITY; - -typedef enum _SYSTEM_INFORMATION_CLASS -{ - SystemBasicInformation = 0, - SystemPerformanceInformation = 2, - SystemTimeOfDayInformation = 3, - SystemProcessesAndThreadsInformation = 5, - SystemProcessorTimes = 8, - SystemPagefileInformation = 18, - /* There are a lot more of these... */ -} SYSTEM_INFORMATION_CLASS; - -typedef struct _SYSTEM_BASIC_INFORMATION -{ - ULONG Unknown; - ULONG MaximumIncrement; - ULONG PhysicalPageSize; - ULONG NumberOfPhysicalPages; - ULONG LowestPhysicalPage; - ULONG HighestPhysicalPage; - ULONG AllocationGranularity; - ULONG LowestUserAddress; - ULONG HighestUserAddress; - ULONG ActiveProcessors; - UCHAR NumberProcessors; -} SYSTEM_BASIC_INFORMATION, *PSYSTEM_BASIC_INFORMATION; - -typedef struct _SYSTEM_PAGEFILE_INFORMATION -{ - ULONG NextEntryOffset; - ULONG CurrentSize; - ULONG TotalUsed; - ULONG PeakUsed; - UNICODE_STRING FileName; -} SYSTEM_PAGEFILE_INFORMATION, *PSYSTEM_PAGEFILE_INFORMATION; - -typedef struct __attribute__ ((aligned (8))) _SYSTEM_PROCESSOR_TIMES -{ - LARGE_INTEGER IdleTime; - LARGE_INTEGER KernelTime; - LARGE_INTEGER UserTime; - LARGE_INTEGER DpcTime; - LARGE_INTEGER InterruptTime; - ULONG InterruptCount; -} SYSTEM_PROCESSOR_TIMES, *PSYSTEM_PROCESSOR_TIMES; - -typedef LONG KPRIORITY; -typedef struct _VM_COUNTERS -{ - ULONG PeakVirtualSize; - ULONG VirtualSize; - ULONG PageFaultCount; - ULONG PeakWorkingSetSize; - ULONG WorkingSetSize; - ULONG QuotaPeakPagedPoolUsage; - ULONG QuotaPagedPoolUsage; - ULONG QuotaPeakNonPagedPoolUsage; - ULONG QuotaNonPagedPoolUsage; - ULONG PagefileUsage; - ULONG PeakPagefileUsage; -} VM_COUNTERS, *PVM_COUNTERS; - -typedef struct _CLIENT_ID -{ - HANDLE UniqueProcess; - HANDLE UniqueThread; -} CLIENT_ID, *PCLIENT_ID; - -typedef enum -{ - StateInitialized, - StateReady, - StateRunning, - StateStandby, - StateTerminated, - StateWait, - StateTransition, - StateUnknown, -} THREAD_STATE; - -typedef enum -{ - Executive, - FreePage, - PageIn, - PoolAllocation, - DelayExecution, - Suspended, - UserRequest, - WrExecutive, - WrFreePage, - WrPageIn, - WrPoolAllocation, - WrDelayExecution, - WrSuspended, - WrUserRequest, - WrEventPair, - WrQueue, - WrLpcReceive, - WrLpcReply, - WrVirtualMemory, - WrPageOut, - WrRendezvous, - Spare2, - Spare3, - Spare4, - Spare5, - Spare6, - WrKernel, - MaximumWaitReason -} KWAIT_REASON; - -typedef struct _SYSTEM_THREADS -{ - LARGE_INTEGER KernelTime; - LARGE_INTEGER UserTime; - LARGE_INTEGER CreateTime; - ULONG WaitTime; - PVOID StartAddress; - CLIENT_ID ClientId; - KPRIORITY Priority; - KPRIORITY BasePriority; - ULONG ContextSwitchCount; - THREAD_STATE State; - KWAIT_REASON WaitReason; - DWORD Reserved; -} SYSTEM_THREADS, *PSYSTEM_THREADS; - -typedef struct _SYSTEM_PROCESSES -{ - ULONG NextEntryDelta; - ULONG ThreadCount; - ULONG Reserved1[6]; - LARGE_INTEGER CreateTime; - LARGE_INTEGER UserTime; - LARGE_INTEGER KernelTime; - UNICODE_STRING ProcessName; - KPRIORITY BasePriority; - ULONG ProcessId; - ULONG InheritedFromProcessId; - ULONG HandleCount; - ULONG Reserved2[2]; - VM_COUNTERS VmCounters; - IO_COUNTERS IoCounters; - SYSTEM_THREADS Threads[1]; -} SYSTEM_PROCESSES, *PSYSTEM_PROCESSES; - -typedef struct _IO_STATUS_BLOCK -{ - NTSTATUS Status; - ULONG Information; -} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; - -typedef struct _SYSTEM_PERFORMANCE_INFORMATION -{ - LARGE_INTEGER IdleTime; - LARGE_INTEGER ReadTransferCount; - LARGE_INTEGER WriteTransferCount; - LARGE_INTEGER OtherTransferCount; - ULONG ReadOperationCount; - ULONG WriteOperationCount; - ULONG OtherOperationCount; - ULONG AvailablePages; - ULONG TotalCommittedPages; - ULONG TotalCommitLimit; - ULONG PeakCommitment; - ULONG PageFaults; - ULONG WriteCopyFaults; - ULONG TransitionFaults; - ULONG Reserved1; - ULONG DemandZeroFaults; - ULONG PagesRead; - ULONG PageReadIos; - ULONG Reserved2[2]; - ULONG PagefilePagesWritten; - ULONG PagefilePageWriteIos; - ULONG MappedFilePagesWritten; - ULONG MappedFilePageWriteIos; - ULONG PagedPoolUsage; - ULONG NonPagedPoolUsage; - ULONG PagedPoolAllocs; - ULONG PagedPoolFrees; - ULONG NonPagedPoolAllocs; - ULONG NonPagedPoolFrees; - ULONG TotalFreeSystemPtes; - ULONG SystemCodePage; - ULONG TotalSystemDriverPages; - ULONG TotalSystemCodePages; - ULONG SmallNonPagedLookasideListAllocateHits; - ULONG SmallPagedLookasideListAllocateHits; - ULONG Reserved3; - ULONG MmSystemCachePage; - ULONG PagedPoolPage; - ULONG SystemDriverPage; - ULONG FastReadNoWait; - ULONG FastReadWait; - ULONG FastReadResourceMiss; - ULONG FastReadNotPossible; - ULONG FastMdlReadNoWait; - ULONG FastMdlReadWait; - ULONG FastMdlReadResourceMiss; - ULONG FastMdlReadNotPossible; - ULONG MapDataNoWait; - ULONG MapDataWait; - ULONG MapDataNoWaitMiss; - ULONG MapDataWaitMiss; - ULONG PinMappedDataCount; - ULONG PinReadNoWait; - ULONG PinReadWait; - ULONG PinReadNoWaitMiss; - ULONG PinReadWaitMiss; - ULONG CopyReadNoWait; - ULONG CopyReadWait; - ULONG CopyReadNoWaitMiss; - ULONG CopyReadWaitMiss; - ULONG MdlReadNoWait; - ULONG MdlReadWait; - ULONG MdlReadNoWaitMiss; - ULONG MdlReadWaitMiss; - ULONG ReadAheadIos; - ULONG LazyWriteIos; - ULONG LazyWritePages; - ULONG DataFlushes; - ULONG DataPages; - ULONG ContextSwitches; - ULONG FirstLevelTbFills; - ULONG SecondLevelTbFills; - ULONG SystemCalls; -} SYSTEM_PERFORMANCE_INFORMATION, *PSYSTEM_PERFORMANCE_INFORMATION; - -typedef struct __attribute__ ((aligned(8))) _SYSTEM_TIME_OF_DAY_INFORMATION -{ - LARGE_INTEGER BootTime; - LARGE_INTEGER CurrentTime; - LARGE_INTEGER TimeZoneBias; - ULONG CurrentTimeZoneId; -} SYSTEM_TIME_OF_DAY_INFORMATION, *PSYSTEM_TIME_OF_DAY_INFORMATION; - -typedef enum _PROCESSINFOCLASS -{ - ProcessBasicInformation = 0, - ProcessQuotaLimits = 1, - ProcessVmCounters = 3, - ProcessTimes = 4, - ProcessSessionInformation = 24, - ProcessWow64Information = 26 -} PROCESSINFOCLASS; - -typedef struct _DEBUG_BUFFER -{ - HANDLE SectionHandle; - PVOID SectionBase; - PVOID RemoteSectionBase; - ULONG SectionBaseDelta; - HANDLE EventPairHandle; - ULONG Unknown[2]; - HANDLE RemoteThreadHandle; - ULONG InfoClassMask; - ULONG SizeOfInfo; - ULONG AllocatedSize; - ULONG SectionSize; - PVOID ModuleInformation; - PVOID BackTraceInformation; - PVOID HeapInformation; - PVOID LockInformation; - PVOID Reserved[9]; -} DEBUG_BUFFER, *PDEBUG_BUFFER; - -typedef struct _DEBUG_HEAP_INFORMATION -{ - ULONG Base; - ULONG Flags; - USHORT Granularity; - USHORT Unknown; - ULONG Allocated; - ULONG Committed; - ULONG TagCount; - ULONG BlockCount; - ULONG Reserved[7]; - PVOID Tags; - PVOID Blocks; -} DEBUG_HEAP_INFORMATION, *PDEBUG_HEAP_INFORMATION; - -typedef struct _DEBUG_MODULE_INFORMATION -{ - ULONG Reserved[2]; - ULONG Base; - ULONG Size; - ULONG Flags; - USHORT Index; - USHORT Unknown; - USHORT LoadCount; - USHORT ModuleNameOffset; - CHAR ImageName[256]; -} DEBUG_MODULE_INFORMATION, *PDEBUG_MODULE_INFORMATION; - -typedef struct _KERNEL_USER_TIMES -{ - LARGE_INTEGER CreateTime; - LARGE_INTEGER ExitTime; - LARGE_INTEGER KernelTime; - LARGE_INTEGER UserTime; -} KERNEL_USER_TIMES, *PKERNEL_USER_TIMES; - -typedef struct _RTL_USER_PROCESS_PARAMETERS -{ - ULONG AllocationSize; - ULONG Size; - ULONG Flags; - ULONG DebugFlags; - HANDLE hConsole; - ULONG ProcessGroup; - HANDLE hStdInput; - HANDLE hStdOutput; - HANDLE hStdError; - UNICODE_STRING CurrentDirectoryName; - HANDLE CurrentDirectoryHandle; - UNICODE_STRING DllPath; - UNICODE_STRING ImagePathName; - UNICODE_STRING CommandLine; - PWSTR Environment; - ULONG dwX; - ULONG dwY; - ULONG dwXSize; - ULONG dwYSize; - ULONG dwXCountChars; - ULONG dwYCountChars; - ULONG dwFillAttribute; - ULONG dwFlags; - ULONG wShowWindow; - UNICODE_STRING WindowTitle; - UNICODE_STRING DesktopInfo; - UNICODE_STRING ShellInfo; - UNICODE_STRING RuntimeInfo; -} RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS; - -typedef struct _PEB -{ - BYTE Reserved1[2]; - BYTE BeingDebugged; - BYTE Reserved2[9]; - PVOID LoaderData; - PRTL_USER_PROCESS_PARAMETERS ProcessParameters; - BYTE Reserved3[448]; - ULONG SessionId; -} PEB, *PPEB; - -/* Simplifed definition, just to get the PEB pointer. */ -typedef struct _TEB -{ - PVOID dummy[12]; - PPEB Peb; - /* A lot more follows... */ -} TEB, *PTEB; - -typedef struct _PROCESS_BASIC_INFORMATION -{ - NTSTATUS ExitStatus; - PPEB PebBaseAddress; - KAFFINITY AffinityMask; - KPRIORITY BasePriority; - ULONG UniqueProcessId; - ULONG InheritedFromUniqueProcessId; -} PROCESS_BASIC_INFORMATION, *PPROCESS_BASIC_INFORMATION; - -typedef struct _PROCESS_SESSION_INFORMATION -{ - ULONG SessionId; -} PROCESS_SESSION_INFORMATION, *PPROCESS_SESSION_INFORMATION; - -typedef enum _MEMORY_INFORMATION_CLASS -{ - MemoryBasicInformation, - MemoryWorkingSetList, - MemorySectionName, - MemoryBasicVlmInformation -} MEMORY_INFORMATION_CLASS; - -typedef struct _MEMORY_WORKING_SET_LIST -{ - ULONG NumberOfPages; - ULONG WorkingSetList[1]; -} MEMORY_WORKING_SET_LIST, *PMEMORY_WORKING_SET_LIST; - -typedef struct _FILE_BASIC_INFORMATION { - LARGE_INTEGER CreationTime; - LARGE_INTEGER LastAccessTime; - LARGE_INTEGER LastWriteTime; - LARGE_INTEGER ChangeTime; - ULONG FileAttributes; -} FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION; - -typedef struct _FILE_STANDARD_INFORMATION { - LARGE_INTEGER AllocationSize; - LARGE_INTEGER EndOfFile; - ULONG NumberOfLinks; - BOOLEAN DeletePending; - BOOLEAN Directory; -} FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION; - -typedef struct _FILE_NETWORK_OPEN_INFORMATION { - LARGE_INTEGER CreationTime; - LARGE_INTEGER LastAccessTime; - LARGE_INTEGER LastWriteTime; - LARGE_INTEGER ChangeTime; - LARGE_INTEGER AllocationSize; - LARGE_INTEGER EndOfFile; - ULONG FileAttributes; -} FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION; - -typedef struct _FILE_INTERNAL_INFORMATION { - LARGE_INTEGER FileId; -} FILE_INTERNAL_INFORMATION, *PFILE_INTERNAL_INFORMATION; - -typedef struct _FILE_EA_INFORMATION { - ULONG EaSize; -} FILE_EA_INFORMATION, *PFILE_EA_INFORMATION; - -typedef struct _FILE_ACCESS_INFORMATION { - ACCESS_MASK AccessFlags; -} FILE_ACCESS_INFORMATION, *PFILE_ACCESS_INFORMATION; - -typedef struct _FILE_DISPOSITION_INFORMATION { - BOOLEAN DeleteFile; -} FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION; - -typedef struct _FILE_POSITION_INFORMATION { - LARGE_INTEGER CurrentByteOffset; -} FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION; - -typedef struct _FILE_END_OF_FILE_INFORMATION { - LARGE_INTEGER EndOfFile; -} FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION; - -typedef struct _FILE_MODE_INFORMATION { - ULONG Mode; -} FILE_MODE_INFORMATION, *PFILE_MODE_INFORMATION; - -typedef struct _FILE_ALIGNMENT_INFORMATION { - ULONG AlignmentRequirement; -} FILE_ALIGNMENT_INFORMATION; - -typedef struct _FILE_NAME_INFORMATION { - ULONG FileNameLength; - WCHAR FileName[1]; -} FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION; - -typedef struct _FILE_LINK_INFORMATION { - BOOLEAN ReplaceIfExists; - HANDLE RootDirectory; - ULONG FileNameLength; - WCHAR FileName[1]; -} FILE_LINK_INFORMATION, *PFILE_LINK_INFORMATION; - -typedef struct _FILE_RENAME_INFORMATION { - BOOLEAN ReplaceIfExists; - HANDLE RootDirectory; - ULONG FileNameLength; - WCHAR FileName[1]; -} FILE_RENAME_INFORMATION, *PFILE_RENAME_INFORMATION; - -typedef struct _FILE_ALL_INFORMATION { - FILE_BASIC_INFORMATION BasicInformation; - FILE_STANDARD_INFORMATION StandardInformation; - FILE_INTERNAL_INFORMATION InternalInformation; - FILE_EA_INFORMATION EaInformation; - FILE_ACCESS_INFORMATION AccessInformation; - FILE_POSITION_INFORMATION PositionInformation; - FILE_MODE_INFORMATION ModeInformation; - FILE_ALIGNMENT_INFORMATION AlignmentInformation; - FILE_NAME_INFORMATION NameInformation; -} FILE_ALL_INFORMATION, *PFILE_ALL_INFORMATION; - -typedef struct _FILE_PIPE_LOCAL_INFORMATION -{ - ULONG NamedPipeType; - ULONG NamedPipeConfiguration; - ULONG MaximumInstances; - ULONG CurrentInstances; - ULONG InboundQuota; - ULONG ReadDataAvailable; - ULONG OutboundQuota; - ULONG WriteQuotaAvailable; - ULONG NamedPipeState; - ULONG NamedPipeEnd; -} FILE_PIPE_LOCAL_INFORMATION, *PFILE_PIPE_LOCAL_INFORMATION; - -typedef struct _FILE_COMPRESSION_INFORMATION -{ - LARGE_INTEGER CompressedFileSize; - USHORT CompressionFormat; - UCHAR CompressionUnitShift; - UCHAR ChunkShift; - UCHAR ClusterShift; - UCHAR Reserved[3]; -} FILE_COMPRESSION_INFORMATION, *PFILE_COMPRESSION_INFORMATION; - -typedef struct _FILE_FS_DEVICE_INFORMATION -{ - ULONG DeviceType; - ULONG Characteristics; -} FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION; - -typedef struct _FILE_FS_ATTRIBUTE_INFORMATION -{ - ULONG FileSystemAttributes; - ULONG MaximumComponentNameLength; - ULONG FileSystemNameLength; - WCHAR FileSystemName[1]; -} FILE_FS_ATTRIBUTE_INFORMATION, *PFILE_FS_ATTRIBUTE_INFORMATION; - -typedef struct _FILE_FS_VOLUME_INFORMATION -{ - LARGE_INTEGER VolumeCreationTime; - ULONG VolumeSerialNumber; - ULONG VolumeLabelLength; - BOOLEAN SupportsObjects; - WCHAR VolumeLabel[1]; -} FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION; - -typedef struct _FILE_FS_SIZE_INFORMATION -{ - LARGE_INTEGER TotalAllocationUnits; - LARGE_INTEGER AvailableAllocationUnits; - ULONG SectorsPerAllocationUnit; - ULONG BytesPerSector; -} FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION; - -typedef struct _FILE_FS_FULL_SIZE_INFORMATION -{ - LARGE_INTEGER TotalAllocationUnits; - LARGE_INTEGER CallerAvailableAllocationUnits; - LARGE_INTEGER ActualAvailableAllocationUnits; - ULONG SectorsPerAllocationUnit; - ULONG BytesPerSector; -} FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION; - -typedef struct _FILE_FS_OBJECTID_INFORMATION { - UCHAR ObjectId[16]; - UCHAR ExtendedInfo[48]; -} FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION; - -typedef enum _FSINFOCLASS { - FileFsVolumeInformation = 1, - FileFsLabelInformation, - FileFsSizeInformation, - FileFsDeviceInformation, - FileFsAttributeInformation, - FileFsControlInformation, - FileFsFullSizeInformation, - FileFsObjectIdInformation, - FileFsDriverPathInformation, - FileFsMaximumInformation -} FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS; - -typedef enum _OBJECT_INFORMATION_CLASS -{ - ObjectBasicInformation = 0, - ObjectNameInformation = 1, - ObjectHandleInformation = 4 - // and many more -} OBJECT_INFORMATION_CLASS; - -typedef struct _OBJECT_BASIC_INFORMATION -{ - ULONG Attributes; - ACCESS_MASK GrantedAccess; - ULONG HandleCount; - ULONG PointerCount; - ULONG PagedPoolUsage; - ULONG NonPagedPoolUsage; - ULONG Reserved[3]; - ULONG NameInformationLength; - ULONG TypeInformationLength; - ULONG SecurityDescriptorLength; - LARGE_INTEGER CreateTime; -} OBJECT_BASIC_INFORMATION, *POBJECT_BASIC_INFORMATION; - -typedef struct _OBJECT_NAME_INFORMATION -{ - UNICODE_STRING Name; -} OBJECT_NAME_INFORMATION; - -typedef struct _DIRECTORY_BASIC_INFORMATION -{ - UNICODE_STRING ObjectName; - UNICODE_STRING ObjectTypeName; -} DIRECTORY_BASIC_INFORMATION, *PDIRECTORY_BASIC_INFORMATION; - -typedef struct _FILE_GET_EA_INFORMATION -{ - ULONG NextEntryOffset; - UCHAR EaNameLength; - CHAR EaName[1]; -} FILE_GET_EA_INFORMATION, *PFILE_GET_EA_INFORMATION; - -typedef struct _FILE_FULL_EA_INFORMATION -{ - ULONG NextEntryOffset; - UCHAR Flags; - UCHAR EaNameLength; - USHORT EaValueLength; - CHAR EaName[1]; -} FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION; - -typedef struct _FILE_MAILSLOT_SET_INFORMATION -{ - LARGE_INTEGER ReadTimeout; -} FILE_MAILSLOT_SET_INFORMATION, *PFILE_MAILSLOT_SET_INFORMATION; - -typedef VOID NTAPI (*PIO_APC_ROUTINE)(PVOID, PIO_STATUS_BLOCK, ULONG); - -typedef enum _EVENT_TYPE -{ - NotificationEvent = 0, - SynchronizationEvent -} EVENT_TYPE, *PEVENT_TYPE; - -typedef struct _EVENT_BASIC_INFORMATION -{ - EVENT_TYPE EventType; - LONG SignalState; -} EVENT_BASIC_INFORMATION, *PEVENT_BASIC_INFORMATION; - -typedef enum _EVENT_INFORMATION_CLASS -{ - EventBasicInformation = 0 -} EVENT_INFORMATION_CLASS, *PEVENT_INFORMATION_CLASS; - -/* Function declarations for ntdll.dll. These don't appear in any - standard Win32 header. */ - -#define NtCurrentProcess() ((HANDLE) 0xffffffff) -#define NtCurrentThread() ((HANDLE) 0xfffffffe) - -extern "C" -{ - NTSTATUS NTAPI NtAdjustPrivilegesToken (HANDLE, BOOLEAN, PTOKEN_PRIVILEGES, - ULONG, PTOKEN_PRIVILEGES, PULONG); - NTSTATUS NTAPI NtClose (HANDLE); - NTSTATUS NTAPI NtCommitTransaction (HANDLE, BOOLEAN); - NTSTATUS NTAPI NtCreateDirectoryObject (PHANDLE, ACCESS_MASK, - POBJECT_ATTRIBUTES); - NTSTATUS NTAPI NtCreateEvent (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, - EVENT_TYPE, BOOLEAN); - NTSTATUS NTAPI NtCreateFile (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, - PIO_STATUS_BLOCK, PLARGE_INTEGER, ULONG, ULONG, - ULONG, ULONG, PVOID, ULONG); - NTSTATUS NTAPI NtCreateMailslotFile(PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, - PIO_STATUS_BLOCK, ULONG, ULONG, ULONG, - PLARGE_INTEGER); - NTSTATUS NTAPI NtCreateMutant (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, - BOOLEAN); - NTSTATUS NTAPI NtCreateSection (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, - PLARGE_INTEGER, ULONG, ULONG, HANDLE); - NTSTATUS NTAPI NtCreateSemaphore (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, - LONG, LONG); - NTSTATUS NTAPI NtCreateToken (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, - TOKEN_TYPE, PLUID, PLARGE_INTEGER, PTOKEN_USER, - PTOKEN_GROUPS, PTOKEN_PRIVILEGES, PTOKEN_OWNER, - PTOKEN_PRIMARY_GROUP, PTOKEN_DEFAULT_DACL, - PTOKEN_SOURCE); - NTSTATUS NTAPI NtCreateTransaction (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, - LPGUID, HANDLE, ULONG, ULONG, ULONG, - PLARGE_INTEGER, PUNICODE_STRING); - NTSTATUS NTAPI NtFsControlFile (HANDLE, HANDLE, PIO_APC_ROUTINE, PVOID, - PIO_STATUS_BLOCK, ULONG, PVOID, ULONG, - PVOID, ULONG); - NTSTATUS NTAPI NtLockVirtualMemory (HANDLE, PVOID *, ULONG *, ULONG); - NTSTATUS NTAPI NtMapViewOfSection (HANDLE, HANDLE, PVOID *, ULONG, ULONG, - PLARGE_INTEGER, PULONG, SECTION_INHERIT, - ULONG, ULONG); - NTSTATUS NTAPI NtNotifyChangeDirectoryFile (HANDLE, HANDLE, PIO_APC_ROUTINE, - PVOID, PIO_STATUS_BLOCK, - PFILE_NOTIFY_INFORMATION, ULONG, - ULONG, BOOLEAN); - NTSTATUS NTAPI NtOpenDirectoryObject (PHANDLE, ACCESS_MASK, - POBJECT_ATTRIBUTES); - NTSTATUS NTAPI NtOpenEvent (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES); - NTSTATUS NTAPI NtOpenFile (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, - PIO_STATUS_BLOCK, ULONG, ULONG); - NTSTATUS NTAPI NtOpenMutant (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES); - NTSTATUS NTAPI NtOpenSection (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES); - NTSTATUS NTAPI NtOpenSemaphore (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES); - /* WARNING! Don't rely on the timestamp information returned by - NtQueryAttributesFile. Only the DOS file attribute info is reliable. */ - NTSTATUS NTAPI NtQueryAttributesFile (POBJECT_ATTRIBUTES, - PFILE_BASIC_INFORMATION); - NTSTATUS NTAPI NtQueryDirectoryFile(HANDLE, HANDLE, PVOID, PVOID, - PIO_STATUS_BLOCK, PVOID, ULONG, - FILE_INFORMATION_CLASS, BOOLEAN, - PUNICODE_STRING, BOOLEAN); - NTSTATUS NTAPI NtQueryDirectoryObject (HANDLE, PVOID, ULONG, BOOLEAN, - BOOLEAN, PULONG, PULONG); - NTSTATUS NTAPI NtQueryEaFile (HANDLE, PIO_STATUS_BLOCK, PVOID, ULONG, - BOOLEAN, PVOID, ULONG, PULONG, BOOLEAN); - NTSTATUS NTAPI NtQueryEvent (HANDLE, EVENT_INFORMATION_CLASS, PVOID, ULONG, - PULONG); - NTSTATUS NTAPI NtQueryFullAttributesFile (POBJECT_ATTRIBUTES, - PFILE_NETWORK_OPEN_INFORMATION); - NTSTATUS NTAPI NtQueryInformationFile (HANDLE, PIO_STATUS_BLOCK, PVOID, - ULONG, FILE_INFORMATION_CLASS); - NTSTATUS NTAPI NtQueryInformationProcess (HANDLE, PROCESSINFOCLASS, - PVOID, ULONG, PULONG); - NTSTATUS NTAPI NtQueryObject (HANDLE, OBJECT_INFORMATION_CLASS, VOID *, - ULONG, ULONG *); - NTSTATUS NTAPI NtQuerySystemInformation (SYSTEM_INFORMATION_CLASS, - PVOID, ULONG, PULONG); - NTSTATUS NTAPI NtQuerySecurityObject (HANDLE, SECURITY_INFORMATION, - PSECURITY_DESCRIPTOR, ULONG, PULONG); - NTSTATUS NTAPI NtQueryVirtualMemory (HANDLE, PVOID, MEMORY_INFORMATION_CLASS, - PVOID, ULONG, PULONG); - NTSTATUS NTAPI NtQueryVolumeInformationFile (HANDLE, IO_STATUS_BLOCK *, - VOID *, ULONG, - FS_INFORMATION_CLASS); - NTSTATUS NTAPI NtReadFile (HANDLE, HANDLE, PIO_APC_ROUTINE, PVOID, - PIO_STATUS_BLOCK, PVOID, ULONG, PLARGE_INTEGER, - PULONG); - NTSTATUS NTAPI NtRollbackTransaction (HANDLE, BOOLEAN); - NTSTATUS NTAPI NtSetEaFile (HANDLE, PIO_STATUS_BLOCK, PVOID, ULONG); - NTSTATUS NTAPI NtSetInformationFile (HANDLE, PIO_STATUS_BLOCK, PVOID, ULONG, - FILE_INFORMATION_CLASS); - NTSTATUS NTAPI NtSetSecurityObject (HANDLE, SECURITY_INFORMATION, - PSECURITY_DESCRIPTOR); - NTSTATUS NTAPI NtUnlockVirtualMemory (HANDLE, PVOID *, ULONG *, ULONG); - NTSTATUS NTAPI NtUnmapViewOfSection (HANDLE, PVOID); - NTSTATUS NTAPI NtWriteFile (HANDLE, HANDLE, PIO_APC_ROUTINE, PVOID, - PIO_STATUS_BLOCK, PVOID, ULONG, PLARGE_INTEGER, - PULONG); - NTSTATUS NTAPI RtlAppendUnicodeToString (PUNICODE_STRING, PCWSTR); - NTSTATUS NTAPI RtlAppendUnicodeStringToString (PUNICODE_STRING, - PUNICODE_STRING); - VOID NTAPI RtlAcquirePebLock (); - NTSTATUS NTAPI RtlAnsiStringToUnicodeString (PUNICODE_STRING, PANSI_STRING, - BOOLEAN); - LONG NTAPI RtlCompareUnicodeString (PUNICODE_STRING, PUNICODE_STRING, - BOOLEAN); - NTSTATUS NTAPI RtlConvertSidToUnicodeString (PUNICODE_STRING, PSID, BOOLEAN); - VOID NTAPI RtlCopyUnicodeString (PUNICODE_STRING, PUNICODE_STRING); - BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz (PUNICODE_STRING, PCSTR); - NTSTATUS NTAPI RtlDowncaseUnicodeString (PUNICODE_STRING, PUNICODE_STRING, - BOOLEAN); - BOOLEAN NTAPI RtlEqualUnicodeString (PUNICODE_STRING, PUNICODE_STRING, - BOOLEAN); - VOID NTAPI RtlFreeAnsiString (PANSI_STRING); - VOID NTAPI RtlFreeOemString (POEM_STRING); - VOID NTAPI RtlFreeUnicodeString (PUNICODE_STRING); - HANDLE NTAPI RtlGetCurrentTransaction (); - VOID NTAPI RtlInitEmptyUnicodeString (PUNICODE_STRING, PCWSTR, USHORT); - VOID NTAPI RtlInitUnicodeString (PUNICODE_STRING, PCWSTR); - NTSTATUS NTAPI RtlIntegerToUnicodeString (ULONG, ULONG, PUNICODE_STRING); - ULONG NTAPI RtlIsDosDeviceName_U (PCWSTR); - ULONG NTAPI RtlNtStatusToDosError (NTSTATUS); - NTSTATUS NTAPI RtlOemStringToUnicodeString (PUNICODE_STRING, POEM_STRING, - BOOLEAN); - BOOLEAN NTAPI RtlPrefixUnicodeString (PUNICODE_STRING, PUNICODE_STRING, - BOOLEAN); - VOID NTAPI RtlReleasePebLock (); - VOID NTAPI RtlSecondsSince1970ToTime (ULONG, PLARGE_INTEGER); - BOOLEAN NTAPI RtlSetCurrentTransaction (HANDLE); - NTSTATUS NTAPI RtlUnicodeStringToAnsiString (PANSI_STRING, PUNICODE_STRING, - BOOLEAN); - NTSTATUS NTAPI RtlUnicodeStringToOemString (PANSI_STRING, PUNICODE_STRING, - BOOLEAN); - WCHAR NTAPI RtlUpcaseUnicodeChar (WCHAR); - NTSTATUS NTAPI RtlUpcaseUnicodeString (PUNICODE_STRING, PUNICODE_STRING, - BOOLEAN); - - /* A few Rtl functions are either actually macros, or they just don't - exist even though they would be a big help. We implement them here, - partly as inline functions. */ - - /* RtlInitEmptyUnicodeString is defined as a macro in wdm.h, but that file - is missing entirely in w32api. */ - inline - VOID NTAPI RtlInitEmptyUnicodeString(PUNICODE_STRING dest, PCWSTR buf, - USHORT len) - { - dest->Length = 0; - dest->MaximumLength = len; - dest->Buffer = (PWSTR) buf; - } - /* Like RtlInitEmptyUnicodeString, but initialize Length to len, too. - This is for instance useful when creating a UNICODE_STRING from an - NtQueryInformationFile info buffer, where the length of the filename - is known, but you can't rely on the string being 0-terminated. - If you know it's 0-terminated, just use RtlInitUnicodeString(). */ - inline - VOID NTAPI RtlInitCountedUnicodeString (PUNICODE_STRING dest, PCWSTR buf, - USHORT len) - { - dest->Length = dest->MaximumLength = len; - dest->Buffer = (PWSTR) buf; - } - /* Split path into dirname and basename part. This function does not - copy anything! It just initializes the dirname and basename - UNICODE_STRINGs so that their Buffer members point to the right spot - into path's Buffer, and the Length (and MaximumLength) members are set - to match the dirname part and the basename part. - Note that dirname's Length is set so that it also includes the trailing - backslash. If you don't need it, just subtract sizeof(WCHAR) from - dirname.Length. */ - inline - VOID NTAPI RtlSplitUnicodePath (PUNICODE_STRING path, PUNICODE_STRING dirname, - PUNICODE_STRING basename) - { - USHORT len = path->Length / sizeof (WCHAR); - while (len > 0 && path->Buffer[--len] != L'\\') - ; - ++len; - if (dirname) - RtlInitCountedUnicodeString (dirname, path->Buffer, len * sizeof (WCHAR)); - if (basename) - RtlInitCountedUnicodeString (basename, &path->Buffer[len], - path->Length - len * sizeof (WCHAR)); - } - /* Check if prefix is a prefix of path. */ - inline - BOOLEAN NTAPI RtlEqualUnicodePathPrefix (PUNICODE_STRING path, - PUNICODE_STRING prefix, - BOOLEAN caseinsensitive) - { - UNICODE_STRING p; - - RtlInitCountedUnicodeString (&p, path->Buffer, - prefix->Length < path->Length - ? prefix->Length : path->Length); - return RtlEqualUnicodeString (&p, prefix, caseinsensitive); - } - /* Check if sufffix is a sufffix of path. */ - inline - BOOL NTAPI RtlEqualUnicodePathSuffix (PUNICODE_STRING path, - PUNICODE_STRING suffix, - BOOLEAN caseinsensitive) - { - UNICODE_STRING p; - - if (suffix->Length < path->Length) - RtlInitCountedUnicodeString (&p, (PWCHAR) ((PBYTE) path->Buffer - + path->Length - suffix->Length), - suffix->Length); - else - RtlInitCountedUnicodeString (&p, path->Buffer, path->Length); - return RtlEqualUnicodeString (&p, suffix, caseinsensitive); - } - /* Implemented in strfuncs.cc. Create a Hex UNICODE_STRING from a given - 64 bit integer value. If append is TRUE, append the hex string, - otherwise overwrite dest. Returns either STATUS_SUCCESS, or - STATUS_BUFFER_OVERFLOW, if the unicode buffer is too small (hasn't - room for 16 WCHARs). */ - NTSTATUS NTAPI RtlInt64ToHexUnicodeString (ULONGLONG value, - PUNICODE_STRING dest, - BOOLEAN append); - /* Set file attributes. Don't change file times. */ - inline - NTSTATUS NTAPI NtSetAttributesFile (HANDLE h, ULONG attr) - { - IO_STATUS_BLOCK io; - FILE_BASIC_INFORMATION fbi; - fbi.CreationTime.QuadPart = fbi.LastAccessTime.QuadPart = - fbi.LastWriteTime.QuadPart = fbi.ChangeTime.QuadPart = 0LL; - fbi.FileAttributes = attr ?: FILE_ATTRIBUTE_NORMAL; - return NtSetInformationFile(h, &io, &fbi, sizeof fbi, FileBasicInformation); - } -} diff --git a/winsup/cygwin/ntea.cc b/winsup/cygwin/ntea.cc deleted file mode 100644 index 25ba6db1f..000000000 --- a/winsup/cygwin/ntea.cc +++ /dev/null @@ -1,514 +0,0 @@ -/* ntea.cc: code for manipulating Extended Attributes - - Copyright 1997, 1998, 2000, 2001, 2006, 2008, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "cygtls.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "ntdll.h" -#include -#include - -#define MAX_EA_NAME_LEN 256 -#define MAX_EA_VALUE_LEN 65536 - -/* At least one maximum sized entry fits. */ -#define EA_BUFSIZ (sizeof (FILE_FULL_EA_INFORMATION) + MAX_EA_NAME_LEN \ - + MAX_EA_VALUE_LEN) - -#define NEXT_FEA(p) ((PFILE_FULL_EA_INFORMATION) (p->NextEntryOffset \ - ? (char *) p + p->NextEntryOffset : NULL)) - -ssize_t __stdcall -read_ea (HANDLE hdl, path_conv &pc, const char *name, char *value, size_t size) -{ - OBJECT_ATTRIBUTES attr; - NTSTATUS status; - IO_STATUS_BLOCK io; - ssize_t ret = -1; - HANDLE h = hdl; - ULONG glen = 0; - PFILE_GET_EA_INFORMATION gea = NULL; - PFILE_FULL_EA_INFORMATION fea; - /* We have to store the latest EaName to compare with the next one, since - ZwQueryEaFile has a bug when accessing files on a remote share. It - returns the last EA entry of the file infinitely. Even utilizing the - optional EaIndex only helps marginally. If you use that, the last - EA in the file is returned twice. */ - char lastname[MAX_EA_NAME_LEN]; - - myfault efault; - if (efault.faulted (EFAULT)) - goto out; - - pc.get_object_attr (attr, sec_none_nih); - - debug_printf ("read_ea (%S, %s, %p, %lu)", - attr.ObjectName, name, value, size); - - /* Early open if handle is NULL. This allows to return error codes like - ENOENT before we actually check for the correctness of the EA name and - stuff like that. */ - if (!hdl) - { - status = NtOpenFile (&h, READ_CONTROL | FILE_READ_EA, &attr, &io, - FILE_SHARE_VALID_FLAGS, FILE_OPEN_FOR_BACKUP_INTENT); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - goto out; - } - hdl = NULL; - } - - fea = (PFILE_FULL_EA_INFORMATION) alloca (EA_BUFSIZ); - - if (name) - { - size_t nlen; - - /* For compatibility with Linux, we only allow user xattrs and - return EOPNOTSUPP otherwise. */ - if (ascii_strncasematch (name, "user.", 5)) - name += 5; - else - { - set_errno (EOPNOTSUPP); - goto out; - } - - if ((nlen = strlen (name)) >= MAX_EA_NAME_LEN) - { - set_errno (EINVAL); - return -1; - } - glen = sizeof (FILE_GET_EA_INFORMATION) + nlen; - gea = (PFILE_GET_EA_INFORMATION) alloca (glen); - - gea->NextEntryOffset = 0; - gea->EaNameLength = nlen; - strcpy (gea->EaName, name); - } - - while (true) - { - if (h) - { - status = NtQueryEaFile (h, &io, fea, EA_BUFSIZ, TRUE, gea, glen, - NULL, TRUE); - if (status != STATUS_ACCESS_DENIED || !hdl) - break; - } - status = NtOpenFile (&h, READ_CONTROL | FILE_READ_EA, &attr, &io, - FILE_SHARE_VALID_FLAGS, FILE_OPEN_FOR_BACKUP_INTENT); - if (!NT_SUCCESS (status)) - break; - hdl = NULL; - } - if (!NT_SUCCESS (status)) - { - if (status == STATUS_NO_EAS_ON_FILE) - ret = 0; - else if (status == STATUS_NONEXISTENT_EA_ENTRY) - /* Actually this error code is either never generated, or it was only - generated in some old and long forgotton NT version. See below. */ - set_errno (ENOATTR); - else - __seterrno_from_nt_status (status); - goto out; - } - if (name) - { - /* Another weird behaviour of ZwQueryEaFile. If you ask for a - specific EA which is not present in the file's EA list, you don't - get a useful error code like STATUS_NONEXISTENT_EA_ENTRY. Rather - ZwQueryEaFile returns success with the entry's EaValueLength - set to 0. */ - if (!fea->EaValueLength) - { - set_errno (ENOATTR); - goto out; - } - if (size > 0) - { - if (size < fea->EaValueLength) - { - set_errno (ERANGE); - goto out; - } - memcpy (value, fea->EaName + fea->EaNameLength + 1, - fea->EaValueLength); - } - ret = fea->EaValueLength; - } - else - { - ret = 0; - do - { - fea->EaNameLength += 5; /* "user." */ - if (size > 0) - { - if ((size_t) ret + fea->EaNameLength + 1 > size) - { - set_errno (ERANGE); - goto out; - } - /* For compatibility with Linux, we always prepend "user." to - the attribute name, so effectively we only support user - attributes from a application point of view. */ - char tmpbuf[MAX_EA_NAME_LEN * 2]; - char *tp = stpcpy (tmpbuf, "user."); - stpcpy (tp, fea->EaName); - /* NTFS stores all EA names in uppercase unfortunately. To keep - compatibility with ext/xfs EA namespaces and accompanying - tools, which expect the namespaces to be lower case, we return - EA names in lowercase if the file is on a native NTFS. */ - if (pc.fs_is_ntfs ()) - strlwr (tp); - tp = stpcpy (value, tmpbuf) + 1; - ret += tp - value; - value = tp; - } - else - ret += fea->EaNameLength + 1; - strcpy (lastname, fea->EaName); - status = NtQueryEaFile (h, &io, fea, EA_BUFSIZ, TRUE, NULL, 0, - NULL, FALSE); - } - while (NT_SUCCESS (status) && strcmp (lastname, fea->EaName) != 0); - } - -out: - if (!hdl) - CloseHandle (h); - debug_printf ("%d = read_ea (%S, %s, %p, %lu)", - ret, attr.ObjectName, name, value, size); - return ret; -} - -int __stdcall -write_ea (HANDLE hdl, path_conv &pc, const char *name, const char *value, - size_t size, int flags) -{ - OBJECT_ATTRIBUTES attr; - NTSTATUS status; - IO_STATUS_BLOCK io; - int ret = -1; - HANDLE h = hdl; - PFILE_FULL_EA_INFORMATION fea; - ULONG flen; - size_t nlen; - - myfault efault; - if (efault.faulted (EFAULT)) - goto out; - - pc.get_object_attr (attr, sec_none_nih); - - debug_printf ("write_ea (%S, %s, %p, %lu, %d)", - attr.ObjectName, name, value, size, flags); - - /* Early open if handle is NULL. This allows to return error codes like - ENOENT before we actually check for the correctness of the EA name and - stuff like that. */ - if (!hdl) - { - status = NtOpenFile (&h, READ_CONTROL | FILE_WRITE_EA, &attr, &io, - FILE_SHARE_VALID_FLAGS, FILE_OPEN_FOR_BACKUP_INTENT); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - goto out; - } - hdl = NULL; - } - - /* For compatibility with Linux, we only allow user xattrs and - return EOPNOTSUPP otherwise. */ - if (!ascii_strncasematch (name, "user.", 5)) - { - set_errno (EOPNOTSUPP); - goto out; - } - - /* removexattr is supposed to fail with ENOATTR if the requested EA is not - available. This is equivalent to the XATTR_REPLACE flag for setxattr. */ - if (!value) - flags = XATTR_REPLACE; - - if (flags) - { - if (flags != XATTR_CREATE && flags != XATTR_REPLACE) - { - set_errno (EINVAL); - goto out; - } - ssize_t rret = read_ea (hdl, pc, name, NULL, 0); - if (flags == XATTR_CREATE && rret > 0) - { - set_errno (EEXIST); - goto out; - } - if (flags == XATTR_REPLACE && rret < 0) - goto out; - } - - /* Skip "user." prefix. */ - name += 5; - - if ((nlen = strlen (name)) >= MAX_EA_NAME_LEN) - { - set_errno (EINVAL); - goto out; - } - flen = sizeof (FILE_FULL_EA_INFORMATION) + nlen + 1 + size; - fea = (PFILE_FULL_EA_INFORMATION) alloca (flen); - fea->NextEntryOffset = 0; - fea->Flags = 0; - fea->EaNameLength = nlen; - fea->EaValueLength = size; - strcpy (fea->EaName, name); - if (value) - memcpy (fea->EaName + fea->EaNameLength + 1, value, size); - - while (true) - { - if (h) - { - status = NtSetEaFile (h, &io, fea, flen); - if (status != STATUS_ACCESS_DENIED || !hdl) - break; - } - status = NtOpenFile (&h, READ_CONTROL | FILE_WRITE_EA, &attr, &io, - FILE_SHARE_VALID_FLAGS, FILE_OPEN_FOR_BACKUP_INTENT); - if (!NT_SUCCESS (status)) - break; - hdl = NULL; - } - if (!NT_SUCCESS (status)) - { - /* STATUS_EA_TOO_LARGE has a matching Win32 error ERROR_EA_TABLE_FULL. - Too bad RtlNtStatusToDosError does not translate STATUS_EA_TOO_LARGE - to ERROR_EA_TABLE_FULL, but to ERROR_EA_LIST_INCONSISTENT. This - error code is also returned for STATUS_EA_LIST_INCONSISTENT, which - means the incoming EA list is... inconsistent. For obvious reasons - we translate ERROR_EA_LIST_INCONSISTENT to EINVAL, so we have to - handle STATUS_EA_TOO_LARGE explicitely here, to get the correct - mapping to ENOSPC. */ - if (status == STATUS_EA_TOO_LARGE) - set_errno (ENOSPC); - else - __seterrno_from_nt_status (status); - } - else - ret = 0; - -out: - if (!hdl) - CloseHandle (h); - debug_printf ("%d = write_ea (%S, %s, %p, %lu, %d)", - ret, attr.ObjectName, name, value, size, flags); - return ret; -} - -static ssize_t __stdcall -getxattr_worker (path_conv &pc, const char *name, void *value, size_t size) -{ - int res = -1; - - if (pc.error) - { - debug_printf ("got %d error from path_conv", pc.error); - set_errno (pc.error); - } - else if (pc.exists ()) - { - fhandler_base *fh; - - if (!(fh = build_fh_pc (pc))) - return -1; - - res = fh->fgetxattr (name, value, size); - delete fh; - } - else - set_errno (ENOENT); - return res; -} - -extern "C" ssize_t -getxattr (const char *path, const char *name, void *value, size_t size) -{ - if (!name) - { - set_errno (EINVAL); - return -1; - } - path_conv pc (path, PC_SYM_FOLLOW | PC_POSIX, stat_suffixes); - return getxattr_worker (pc, name, value, size); -} - -extern "C" ssize_t -lgetxattr (const char *path, const char *name, void *value, size_t size) -{ - if (!name) - { - set_errno (EINVAL); - return -1; - } - path_conv pc (path, PC_SYM_NOFOLLOW | PC_POSIX, stat_suffixes); - return getxattr_worker (pc, name, value, size); -} - -extern "C" ssize_t -fgetxattr (int fd, const char *name, void *value, size_t size) -{ - int res; - - if (!name) - { - set_errno (EINVAL); - return -1; - } - cygheap_fdget cfd (fd); - if (cfd < 0) - res = -1; - else - res = cfd->fgetxattr (name, value, size); - return res; -} - -extern "C" ssize_t -listxattr (const char *path, char *list, size_t size) -{ - path_conv pc (path, PC_SYM_FOLLOW | PC_POSIX, stat_suffixes); - return getxattr_worker (pc, NULL, list, size); -} - -extern "C" ssize_t -llistxattr (const char *path, char *list, size_t size) -{ - path_conv pc (path, PC_SYM_NOFOLLOW | PC_POSIX, stat_suffixes); - return getxattr_worker (pc, NULL, list, size); -} - -extern "C" ssize_t -flistxattr (int fd, char *list, size_t size) -{ - int res; - - cygheap_fdget cfd (fd); - if (cfd < 0) - res = -1; - else - res = cfd->fgetxattr (NULL, list, size); - return res; -} - -static int __stdcall -setxattr_worker (path_conv &pc, const char *name, const void *value, - size_t size, int flags) -{ - int res = -1; - - if (pc.error) - { - debug_printf ("got %d error from path_conv", pc.error); - set_errno (pc.error); - } - else if (pc.exists ()) - { - fhandler_base *fh; - - if (!(fh = build_fh_pc (pc))) - return -1; - - res = fh->fsetxattr (name, value, size, flags); - delete fh; - } - else - set_errno (ENOENT); - return res; -} - -extern "C" int -setxattr (const char *path, const char *name, const void *value, size_t size, - int flags) -{ - if (!size) - { - set_errno (EINVAL); - return -1; - } - path_conv pc (path, PC_SYM_NOFOLLOW | PC_POSIX, stat_suffixes); - return setxattr_worker (pc, name, value, size, flags); -} - -extern "C" int -lsetxattr (const char *path, const char *name, const void *value, size_t size, - int flags) -{ - if (!size) - { - set_errno (EINVAL); - return -1; - } - path_conv pc (path, PC_SYM_NOFOLLOW | PC_POSIX, stat_suffixes); - return setxattr_worker (pc, name, value, size, flags); -} - -extern "C" int -fsetxattr (int fd, const char *name, const void *value, size_t size, int flags) -{ - int res; - - if (!size) - { - set_errno (EINVAL); - return -1; - } - cygheap_fdget cfd (fd); - if (cfd < 0) - res = -1; - else - res = cfd->fsetxattr (name, value, size, flags); - return res; -} - -extern "C" int -removexattr (const char *path, const char *name) -{ - path_conv pc (path, PC_SYM_FOLLOW | PC_POSIX, stat_suffixes); - return setxattr_worker (pc, name, NULL, 0, 0); -} - -extern "C" int -lremovexattr (const char *path, const char *name) -{ - path_conv pc (path, PC_SYM_NOFOLLOW | PC_POSIX, stat_suffixes); - return setxattr_worker (pc, name, NULL, 0, 0); -} - -extern "C" int -fremovexattr (int fd, const char *name) -{ - int res; - - cygheap_fdget cfd (fd); - if (cfd < 0) - res = -1; - else - res = cfd->fsetxattr (name, NULL, 0, 0); - return res; -} diff --git a/winsup/cygwin/passwd.cc b/winsup/cygwin/passwd.cc deleted file mode 100644 index 8c51c22a0..000000000 --- a/winsup/cygwin/passwd.cc +++ /dev/null @@ -1,294 +0,0 @@ -/* passwd.cc: getpwnam () and friends - - Copyright 1996, 1997, 1998, 2001, 2002, 2003, 2007, 2008, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "pinfo.h" -#include "cygheap.h" -#include "pwdgrp.h" -#include "shared_info.h" - -/* Read /etc/passwd only once for better performance. This is done - on the first call that needs information from it. */ - -passwd *passwd_buf; -static pwdgrp pr (passwd_buf); - -/* Parse /etc/passwd line into passwd structure. */ -bool -pwdgrp::parse_passwd () -{ -# define res (*passwd_buf)[curr_lines] - res.pw_name = next_str (':'); - res.pw_passwd = next_str (':'); - if (!next_num (res.pw_uid)) - return false; - if (!next_num (res.pw_gid)) - return false; - res.pw_comment = NULL; - res.pw_gecos = next_str (':'); - res.pw_dir = next_str (':'); - res.pw_shell = next_str (':'); - return true; -# undef res -} - -/* Read in /etc/passwd and save contents in the password cache. - This sets pr to loaded or emulated so functions in this file can - tell that /etc/passwd has been read in or will be emulated. */ -void -pwdgrp::read_passwd () -{ - load (L"\\etc\\passwd"); - - char strbuf[128] = ""; - bool searchentry = true; - struct passwd *pw; - /* must be static */ - static char NO_COPY pretty_ls[] = "????????:*:-1:-1:"; - - add_line (pretty_ls); - cygsid tu = cygheap->user.sid (); - tu.string (strbuf); - if (!user_shared->cb || myself->uid == ILLEGAL_UID) - searchentry = !internal_getpwsid (tu); - if (searchentry - && (!(pw = internal_getpwnam (cygheap->user.name ())) - || !user_shared->cb - || (myself->uid != ILLEGAL_UID - && myself->uid != (__uid32_t) pw->pw_uid - && !internal_getpwuid (myself->uid)))) - { - static char linebuf[1024]; // must be static and - // should not be NO_COPY - snprintf (linebuf, sizeof (linebuf), "%s:*:%lu:%lu:,%s:%s:/bin/sh", - cygheap->user.name (), - (!user_shared->cb || myself->uid == ILLEGAL_UID) - ? UNKNOWN_UID : myself->uid, - !user_shared->cb ? UNKNOWN_GID : myself->gid, - strbuf, getenv ("HOME") ?: ""); - debug_printf ("Completing /etc/passwd: %s", linebuf); - add_line (linebuf); - } -} - -struct passwd * -internal_getpwsid (cygpsid &sid) -{ - struct passwd *pw; - char *ptr1, *ptr2, *endptr; - char sid_string[128] = {0,','}; - - pr.refresh (false); - - if (sid.string (sid_string + 2)) - { - endptr = strchr (sid_string + 2, 0) - 1; - for (int i = 0; i < pr.curr_lines; i++) - if ((pw = passwd_buf + i)->pw_dir > pw->pw_gecos + 8) - for (ptr1 = endptr, ptr2 = pw->pw_dir - 2; - *ptr1 == *ptr2; ptr2--) - if (!*--ptr1) - return pw; - } - return NULL; -} - -struct passwd * -internal_getpwuid (__uid32_t uid, bool check) -{ - pr.refresh (check); - - for (int i = 0; i < pr.curr_lines; i++) - if (uid == (__uid32_t) passwd_buf[i].pw_uid) - return passwd_buf + i; - return NULL; -} - -struct passwd * -internal_getpwnam (const char *name, bool check) -{ - pr.refresh (check); - - for (int i = 0; i < pr.curr_lines; i++) - /* on Windows NT user names are case-insensitive */ - if (strcasematch (name, passwd_buf[i].pw_name)) - return passwd_buf + i; - return NULL; -} - - -extern "C" struct passwd * -getpwuid32 (__uid32_t uid) -{ - struct passwd *temppw = internal_getpwuid (uid, true); - pthread_testcancel (); - return temppw; -} - -extern "C" struct passwd * -getpwuid (__uid16_t uid) -{ - return getpwuid32 (uid16touid32 (uid)); -} - -extern "C" int -getpwuid_r32 (__uid32_t uid, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result) -{ - *result = NULL; - - if (!pwd || !buffer) - return ERANGE; - - struct passwd *temppw = internal_getpwuid (uid, true); - pthread_testcancel (); - if (!temppw) - return 0; - - /* check needed buffer size. */ - size_t needsize = strlen (temppw->pw_name) + strlen (temppw->pw_passwd) - + strlen (temppw->pw_gecos) + strlen (temppw->pw_dir) - + strlen (temppw->pw_shell) + 5; - if (needsize > bufsize) - return ERANGE; - - /* make a copy of temppw */ - *result = pwd; - pwd->pw_uid = temppw->pw_uid; - pwd->pw_gid = temppw->pw_gid; - buffer = stpcpy (pwd->pw_name = buffer, temppw->pw_name); - buffer = stpcpy (pwd->pw_passwd = buffer + 1, temppw->pw_passwd); - buffer = stpcpy (pwd->pw_gecos = buffer + 1, temppw->pw_gecos); - buffer = stpcpy (pwd->pw_dir = buffer + 1, temppw->pw_dir); - stpcpy (pwd->pw_shell = buffer + 1, temppw->pw_shell); - pwd->pw_comment = NULL; - return 0; -} - -extern "C" int -getpwuid_r (__uid16_t uid, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result) -{ - return getpwuid_r32 (uid16touid32 (uid), pwd, buffer, bufsize, result); -} - -extern "C" struct passwd * -getpwnam (const char *name) -{ - struct passwd *temppw = internal_getpwnam (name, true); - pthread_testcancel (); - return temppw; -} - - -/* the max size buffer we can expect to - * use is returned via sysconf with _SC_GETPW_R_SIZE_MAX. - * This may need updating! - Rob Collins April 2001. - */ -extern "C" int -getpwnam_r (const char *nam, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result) -{ - *result = NULL; - - if (!pwd || !buffer || !nam) - return ERANGE; - - struct passwd *temppw = internal_getpwnam (nam, true); - pthread_testcancel (); - - if (!temppw) - return 0; - - /* check needed buffer size. */ - size_t needsize = strlen (temppw->pw_name) + strlen (temppw->pw_passwd) - + strlen (temppw->pw_gecos) + strlen (temppw->pw_dir) - + strlen (temppw->pw_shell) + 5; - if (needsize > bufsize) - return ERANGE; - - /* make a copy of temppw */ - *result = pwd; - pwd->pw_uid = temppw->pw_uid; - pwd->pw_gid = temppw->pw_gid; - buffer = stpcpy (pwd->pw_name = buffer, temppw->pw_name); - buffer = stpcpy (pwd->pw_passwd = buffer + 1, temppw->pw_passwd); - buffer = stpcpy (pwd->pw_gecos = buffer + 1, temppw->pw_gecos); - buffer = stpcpy (pwd->pw_dir = buffer + 1, temppw->pw_dir); - stpcpy (pwd->pw_shell = buffer + 1, temppw->pw_shell); - pwd->pw_comment = NULL; - return 0; -} - -extern "C" struct passwd * -getpwent (void) -{ - if (_my_tls.locals.pw_pos == 0) - pr.refresh (true); - if (_my_tls.locals.pw_pos < pr.curr_lines) - return passwd_buf + _my_tls.locals.pw_pos++; - - return NULL; -} - -extern "C" struct passwd * -getpwduid (__uid16_t) -{ - return NULL; -} - -extern "C" void -setpwent (void) -{ - _my_tls.locals.pw_pos = 0; -} - -extern "C" void -endpwent (void) -{ - _my_tls.locals.pw_pos = 0; -} - -extern "C" int -setpassent () -{ - return 0; -} - -extern "C" char * -getpass (const char * prompt) -{ - char *pass = _my_tls.locals.pass; - struct termios ti, newti; - - cygheap_fdget fhstdin (0); - - if (fhstdin < 0) - pass[0] = '\0'; - else - { - fhstdin->tcgetattr (&ti); - newti = ti; - newti.c_lflag &= ~ECHO; - fhstdin->tcsetattr (TCSANOW, &newti); - fputs (prompt, stderr); - fgets (pass, _PASSWORD_LEN, stdin); - fprintf (stderr, "\n"); - for (int i=0; pass[i]; i++) - if (pass[i] == '\r' || pass[i] == '\n') - pass[i] = '\0'; - fhstdin->tcsetattr (TCSANOW, &ti); - } - return pass; -} diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc deleted file mode 100644 index 82c96c7e6..000000000 --- a/winsup/cygwin/path.cc +++ /dev/null @@ -1,3613 +0,0 @@ -/* path.cc: path support. - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - - /* This module's job is to - - convert between POSIX and Win32 style filenames, - - support the `mount' functionality, - - support symlinks for files and directories - - Pathnames are handled as follows: - - - A \ or : in a path denotes a pure windows spec. - - Paths beginning with // (or \\) are not translated (i.e. looked - up in the mount table) and are assumed to be UNC path names. - - The goal in the above set of rules is to allow both POSIX and Win32 - flavors of pathnames without either interfering. The rules are - intended to be as close to a superset of both as possible. - - Note that you can have more than one path to a file. The mount - table is always prefered when translating Win32 paths to POSIX - paths. Win32 paths in mount table entries may be UNC paths or - standard Win32 paths starting with : - - Text vs Binary issues are not considered here in path style - decisions, although the appropriate flags are retrieved and - stored in various structures. - - Removing mounted filesystem support would simplify things greatly, - but having it gives us a mechanism of treating disk that lives on a - UNIX machine as having UNIX semantics [it allows one to edit a text - file on that disk and not have cr's magically appear and perhaps - break apps running on UNIX boxes]. It also useful to be able to - layout a hierarchy without changing the underlying directories. - - The semantics of mounting file systems is not intended to precisely - follow normal UNIX systems. - - Each DOS drive is defined to have a current directory. Supporting - this would complicate things so for now things are defined so that - c: means c:\. - */ - -#include "winsup.h" -#include "miscfuncs.h" -#include -#include -#include -#include -#include -#include -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "shared_info.h" -#include "cygtls.h" -#include "tls_pbuf.h" -#include "environ.h" -#include "nfs.h" -#include -#include -#include -#include - -bool dos_file_warning = true; - -suffix_info stat_suffixes[] = -{ - suffix_info ("", 1), - suffix_info (".exe", 1), - suffix_info (NULL) -}; - -struct symlink_info -{ - char contents[SYMLINK_MAX + 1]; - char *ext_here; - int extn; - unsigned pflags; - DWORD fileattr; - int issymlink; - bool ext_tacked_on; - int error; - bool isdevice; - _major_t major; - _minor_t minor; - _mode_t mode; - int check (char *path, const suffix_info *suffixes, unsigned opt, - fs_info &fs); - int set (char *path); - bool parse_device (const char *); - int check_sysfile (HANDLE h); - int check_shortcut (HANDLE h); - int check_reparse_point (HANDLE h); - int check_nfs_symlink (HANDLE h); - int posixify (char *srcbuf); - bool set_error (int); -}; - -muto NO_COPY cwdstuff::cwd_lock; - -static const GUID GUID_shortcut - = { 0x00021401L, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46}}; - -enum { - WSH_FLAG_IDLIST = 0x01, /* Contains an ITEMIDLIST. */ - WSH_FLAG_FILE = 0x02, /* Contains a file locator element. */ - WSH_FLAG_DESC = 0x04, /* Contains a description. */ - WSH_FLAG_RELPATH = 0x08, /* Contains a relative path. */ - WSH_FLAG_WD = 0x10, /* Contains a working dir. */ - WSH_FLAG_CMDLINE = 0x20, /* Contains command line args. */ - WSH_FLAG_ICON = 0x40 /* Contains a custom icon. */ -}; - -struct win_shortcut_hdr - { - DWORD size; /* Header size in bytes. Must contain 0x4c. */ - GUID magic; /* GUID of shortcut files. */ - DWORD flags; /* Content flags. See above. */ - - /* The next fields from attr to icon_no are always set to 0 in Cygwin - and U/Win shortcuts. */ - DWORD attr; /* Target file attributes. */ - FILETIME ctime; /* These filetime items are never touched by the */ - FILETIME mtime; /* system, apparently. Values don't matter. */ - FILETIME atime; - DWORD filesize; /* Target filesize. */ - DWORD icon_no; /* Icon number. */ - - DWORD run; /* Values defined in winuser.h. Use SW_NORMAL. */ - DWORD hotkey; /* Hotkey value. Set to 0. */ - DWORD dummy[2]; /* Future extension probably. Always 0. */ - }; - -/* Return non-zero if PATH1 is a prefix of PATH2. - Both are assumed to be of the same path style and / vs \ usage. - Neither may be "". - LEN1 = strlen (PATH1). It's passed because often it's already known. - - Examples: - /foo/ is a prefix of /foo <-- may seem odd, but desired - /foo is a prefix of /foo/ - / is a prefix of /foo/bar - / is not a prefix of foo/bar - foo/ is a prefix foo/bar - /foo is not a prefix of /foobar -*/ - -int -path_prefix_p (const char *path1, const char *path2, int len1, - bool caseinsensitive) -{ - /* Handle case where PATH1 has trailing '/' and when it doesn't. */ - if (len1 > 0 && isdirsep (path1[len1 - 1])) - len1--; - - if (len1 == 0) - return isdirsep (path2[0]) && !isdirsep (path2[1]); - - if (isdirsep (path2[len1]) || path2[len1] == 0 || path1[len1 - 1] == ':') - return caseinsensitive ? strncasematch (path1, path2, len1) - : !strncmp (path1, path2, len1); - - return 0; -} - -/* Return non-zero if paths match in first len chars. - Check is dependent of the case sensitivity setting. */ -int -pathnmatch (const char *path1, const char *path2, int len, bool caseinsensitive) -{ - return caseinsensitive - ? strncasematch (path1, path2, len) : !strncmp (path1, path2, len); -} - -/* Return non-zero if paths match. Check is dependent of the case - sensitivity setting. */ -int -pathmatch (const char *path1, const char *path2, bool caseinsensitive) -{ - return caseinsensitive - ? strcasematch (path1, path2) : !strcmp (path1, path2); -} - -/* TODO: This function is used in mkdir and rmdir to generate correct - error messages in case of paths ending in /. or /.. components. - Right now, normalize_posix_path will just normalize - those components away, which changes the semantics. */ -bool -has_dot_last_component (const char *dir, bool test_dot_dot) -{ - /* SUSv3: . and .. are not allowed as last components in various system - calls. Don't test for backslash path separator since that's a Win32 - path following Win32 rules. */ - const char *last_comp = strchr (dir, '\0'); - - if (last_comp == dir) - return false; /* Empty string. Probably shouldn't happen here? */ - - /* Detect run of trailing slashes */ - while (last_comp > dir && *--last_comp == '/') - continue; - - /* Detect just a run of slashes or a path that does not end with a slash. */ - if (*last_comp != '.') - return false; - - /* We know we have a trailing dot here. Check that it really is a standalone "." - path component by checking that it is at the beginning of the string or is - preceded by a "/" */ - if (last_comp == dir || *--last_comp == '/') - return true; - - /* If we're not checking for '..' we're done. Ditto if we're now pointing to - a non-dot. */ - if (!test_dot_dot || *last_comp != '.') - return false; /* either not testing for .. or this was not '..' */ - - /* Repeat previous test for standalone or path component. */ - return last_comp == dir || last_comp[-1] == '/'; -} - -/* Normalize a POSIX path. - All duplicate /'s, except for 2 leading /'s, are deleted. - The result is 0 for success, or an errno error value. */ - -int -normalize_posix_path (const char *src, char *dst, char *&tail) -{ - const char *in_src = src; - char *dst_start = dst; - syscall_printf ("src %s", src); - - if ((isdrive (src) && isdirsep (src[2])) || *src == '\\') - goto win32_path; - - tail = dst; - if (!isslash (src[0])) - { - if (!cygheap->cwd.get (dst)) - return get_errno (); - tail = strchr (tail, '\0'); - if (isslash (dst[0]) && isslash (dst[1])) - ++dst_start; - if (*src == '.') - { - if (tail == dst_start + 1 && *dst_start == '/') - tail--; - goto sawdot; - } - if (tail > dst && !isslash (tail[-1])) - *tail++ = '/'; - } - /* Two leading /'s? If so, preserve them. */ - else if (isslash (src[1]) && !isslash (src[2])) - { - *tail++ = *src++; - ++dst_start; - } - - while (*src) - { - if (*src == '\\') - goto win32_path; - /* Strip runs of /'s. */ - if (!isslash (*src)) - *tail++ = *src++; - else - { - while (*++src) - { - if (isslash (*src)) - continue; - - if (*src != '.') - break; - - sawdot: - if (src[1] != '.') - { - if (!src[1]) - { - *tail++ = '/'; - goto done; - } - if (!isslash (src[1])) - break; - } - else if (src[2] && !isslash (src[2])) - break; - else - { - while (tail > dst_start && !isslash (*--tail)) - continue; - src++; - } - } - - *tail++ = '/'; - } - if ((tail - dst) >= NT_MAX_PATH) - { - debug_printf ("ENAMETOOLONG = normalize_posix_path (%s)", src); - return ENAMETOOLONG; - } - } - -done: - *tail = '\0'; - - debug_printf ("%s = normalize_posix_path (%s)", dst, in_src); - return 0; - -win32_path: - int err = normalize_win32_path (in_src, dst, tail); - if (!err) - for (char *p = dst; (p = strchr (p, '\\')); p++) - *p = '/'; - return err ?: -1; -} - -inline void -path_conv::add_ext_from_sym (symlink_info &sym) -{ - if (sym.ext_here && *sym.ext_here) - { - known_suffix = path + sym.extn; - if (sym.ext_tacked_on) - strcpy ((char *) known_suffix, sym.ext_here); - } -} - -static void __stdcall mkrelpath (char *dst, bool caseinsensitive) - __attribute__ ((regparm (2))); - -static void __stdcall -mkrelpath (char *path, bool caseinsensitive) -{ - tmp_pathbuf tp; - char *cwd_win32 = tp.c_get (); - if (!cygheap->cwd.get (cwd_win32, 0)) - return; - - unsigned cwdlen = strlen (cwd_win32); - if (!path_prefix_p (cwd_win32, path, cwdlen, caseinsensitive)) - return; - - size_t n = strlen (path); - if (n < cwdlen) - return; - - char *tail = path; - if (n == cwdlen) - tail += cwdlen; - else - tail += isdirsep (cwd_win32[cwdlen - 1]) ? cwdlen : cwdlen + 1; - - memmove (path, tail, strlen (tail) + 1); - if (!*path) - strcpy (path, "."); -} - -void -path_conv::set_normalized_path (const char *path_copy) -{ - if (path_copy) - { - size_t n = strlen (path_copy) + 1; - char *p = (char *) cmalloc_abort (HEAP_STR, n); - normalized_path = (const char *) memcpy (p, path_copy, n); - } -} - -static inline void -str2uni_cat (UNICODE_STRING &tgt, const char *srcstr) -{ - int len = sys_mbstowcs (tgt.Buffer + tgt.Length / sizeof (WCHAR), - (tgt.MaximumLength - tgt.Length) / sizeof (WCHAR), - srcstr); - if (len) - tgt.Length += (len - 1) * sizeof (WCHAR); -} - -PUNICODE_STRING -get_nt_native_path (const char *path, UNICODE_STRING& upath) -{ - upath.Length = 0; - if (path[0] == '/') /* special path w/o NT path representation. */ - str2uni_cat (upath, path); - else if (path[0] != '\\') /* X:\... or relative path. */ - { - if (path[1] == ':') /* X:\... */ - { - RtlAppendUnicodeStringToString (&upath, &ro_u_natp); - str2uni_cat (upath, path); - /* The drive letter must be upper case. */ - upath.Buffer[4] = towupper (upath.Buffer[4]); - } - else - str2uni_cat (upath, path); - transform_chars (&upath, 7); - } - else if (path[1] != '\\') /* \Device\... */ - str2uni_cat (upath, path); - else if ((path[2] != '.' && path[2] != '?') - || path[3] != '\\') /* \\server\share\... */ - { - RtlAppendUnicodeStringToString (&upath, &ro_u_uncp); - str2uni_cat (upath, path + 2); - transform_chars (&upath, 8); - } - else /* \\.\device or \\?\foo */ - { - RtlAppendUnicodeStringToString (&upath, &ro_u_natp); - str2uni_cat (upath, path + 4); - } - return &upath; -} - -PUNICODE_STRING -path_conv::get_nt_native_path () -{ - if (!wide_path) - { - uni_path.Length = 0; - uni_path.MaximumLength = (strlen (path) + 10) * sizeof (WCHAR); - wide_path = (PWCHAR) cmalloc_abort (HEAP_STR, uni_path.MaximumLength); - uni_path.Buffer = wide_path; - ::get_nt_native_path (path, uni_path); - } - return &uni_path; -} - -POBJECT_ATTRIBUTES -path_conv::get_object_attr (OBJECT_ATTRIBUTES &attr, SECURITY_ATTRIBUTES &sa) -{ - if (!get_nt_native_path ()) - return NULL; - InitializeObjectAttributes (&attr, &uni_path, - objcaseinsensitive () - | (sa.bInheritHandle ? OBJ_INHERIT : 0), - NULL, sa.lpSecurityDescriptor); - return &attr; -} - -PWCHAR -path_conv::get_wide_win32_path (PWCHAR wc) -{ - get_nt_native_path (); - if (!wide_path) - return NULL; - wcpcpy (wc, wide_path); - if (wc[1] == L'?') - wc[1] = L'\\'; - return wc; -} - -void -warn_msdos (const char *src) -{ - if (user_shared->warned_msdos || !dos_file_warning || !cygwin_finished_initializing) - return; - tmp_pathbuf tp; - char *posix_path = tp.c_get (); - small_printf ("cygwin warning:\n"); - if (cygwin_conv_path (CCP_WIN_A_TO_POSIX | CCP_RELATIVE, src, - posix_path, NT_MAX_PATH)) - small_printf (" MS-DOS style path detected: %s\n POSIX equivalent preferred.\n", - src); - else - small_printf (" MS-DOS style path detected: %s\n Preferred POSIX equivalent is: %s\n", - src, posix_path); - small_printf (" CYGWIN environment variable option \"nodosfilewarning\" turns off this warning.\n" - " Consult the user's guide for more details about POSIX paths:\n" - " http://cygwin.com/cygwin-ug-net/using.html#using-pathnames\n"); - user_shared->warned_msdos = true; -} - -static DWORD -getfileattr (const char *path, bool caseinsensitive) /* path has to be always absolute. */ -{ - tmp_pathbuf tp; - UNICODE_STRING upath; - OBJECT_ATTRIBUTES attr; - FILE_BASIC_INFORMATION fbi; - NTSTATUS status; - IO_STATUS_BLOCK io; - - tp.u_get (&upath); - InitializeObjectAttributes (&attr, &upath, - caseinsensitive ? OBJ_CASE_INSENSITIVE : 0, - NULL, NULL); - get_nt_native_path (path, upath); - - status = NtQueryAttributesFile (&attr, &fbi); - if (NT_SUCCESS (status)) - return fbi.FileAttributes; - - if (status != STATUS_OBJECT_NAME_NOT_FOUND - && status != STATUS_NO_SUCH_FILE) /* File not found on 9x share */ - { - /* File exists but access denied. Try to get attribute through - directory query. */ - UNICODE_STRING dirname, basename; - HANDLE dir; - FILE_BOTH_DIRECTORY_INFORMATION fdi; - - RtlSplitUnicodePath (&upath, &dirname, &basename); - InitializeObjectAttributes (&attr, &dirname, - caseinsensitive ? OBJ_CASE_INSENSITIVE : 0, - NULL, NULL); - status = NtOpenFile (&dir, SYNCHRONIZE | FILE_LIST_DIRECTORY, - &attr, &io, FILE_SHARE_VALID_FLAGS, - FILE_SYNCHRONOUS_IO_NONALERT - | FILE_OPEN_FOR_BACKUP_INTENT - | FILE_DIRECTORY_FILE); - if (NT_SUCCESS (status)) - { - status = NtQueryDirectoryFile (dir, NULL, NULL, 0, &io, - &fdi, sizeof fdi, - FileBothDirectoryInformation, - TRUE, &basename, TRUE); - NtClose (dir); - if (NT_SUCCESS (status) || status == STATUS_BUFFER_OVERFLOW) - return fdi.FileAttributes; - } - } - SetLastError (RtlNtStatusToDosError (status)); - return INVALID_FILE_ATTRIBUTES; -} - -/* Convert an arbitrary path SRC to a pure Win32 path, suitable for - passing to Win32 API routines. - - If an error occurs, `error' is set to the errno value. - Otherwise it is set to 0. - - follow_mode values: - SYMLINK_FOLLOW - convert to PATH symlink points to - SYMLINK_NOFOLLOW - convert to PATH of symlink itself - SYMLINK_IGNORE - do not check PATH for symlinks - SYMLINK_CONTENTS - just return symlink contents -*/ - -/* TODO: This implementation is only preliminary. For internal - purposes it's necessary to have a path_conv::check function which - takes a UNICODE_STRING src path, otherwise we waste a lot of time - for converting back and forth. The below implementation does - realy nothing but converting to char *, until path_conv handles - wide-char paths directly. */ -void -path_conv::check (const UNICODE_STRING *src, unsigned opt, - const suffix_info *suffixes) -{ - tmp_pathbuf tp; - char *path = tp.c_get (); - - user_shared->warned_msdos = true; - sys_wcstombs (path, NT_MAX_PATH, src->Buffer, src->Length / sizeof (WCHAR)); - path_conv::check (path, opt, suffixes); -} - -void -path_conv::check (const char *src, unsigned opt, - const suffix_info *suffixes) -{ - /* The tmp_buf array is used when expanding symlinks. It is NT_MAX_PATH * 2 - in length so that we can hold the expanded symlink plus a trailer. */ - tmp_pathbuf tp; - char *path_copy = tp.c_get (); - char *pathbuf = tp.c_get (); - char *tmp_buf = tp.t_get (); - char *THIS_path = tp.c_get (); - symlink_info sym; - bool need_directory = 0; - bool saw_symlinks = 0; - bool add_ext = false; - bool is_relpath; - char *tail, *path_end; - -#if 0 - static path_conv last_path_conv; - static char last_src[CYG_MAX_PATH]; - - if (*last_src && strcmp (last_src, src) == 0) - { - *this = last_path_conv; - return; - } -#endif - - myfault efault; - if (efault.faulted ()) - { - error = EFAULT; - return; - } - int loop = 0; - path_flags = 0; - known_suffix = NULL; - fileattr = INVALID_FILE_ATTRIBUTES; - caseinsensitive = OBJ_CASE_INSENSITIVE; - if (wide_path) - cfree (wide_path); - wide_path = NULL; - if (path) - { - cfree (modifiable_path ()); - path = NULL; - } - memset (&dev, 0, sizeof (dev)); - fs.clear (); - if (normalized_path) - { - cfree ((void *) normalized_path); - normalized_path = NULL; - } - int component = 0; // Number of translated components - - if (!(opt & PC_NULLEMPTY)) - error = 0; - else if (!*src) - { - error = ENOENT; - return; - } - - bool is_msdos = false; - /* This loop handles symlink expansion. */ - for (;;) - { - MALLOC_CHECK; - assert (src); - - is_relpath = !isabspath (src); - error = normalize_posix_path (src, path_copy, tail); - if (error > 0) - return; - if (error < 0) - { - if (component == 0) - is_msdos = true; - error = 0; - } - - /* Detect if the user was looking for a directory. We have to strip the - trailing slash initially while trying to add extensions but take it - into account during processing */ - if (tail > path_copy + 2 && isslash (tail[-1])) - { - need_directory = 1; - *--tail = '\0'; - } - path_end = tail; - - /* Scan path_copy from right to left looking either for a symlink - or an actual existing file. If an existing file is found, just - return. If a symlink is found, exit the for loop. - Also: be careful to preserve the errno returned from - symlink.check as the caller may need it. */ - /* FIXME: Do we have to worry about multiple \'s here? */ - component = 0; // Number of translated components - sym.contents[0] = '\0'; - - int symlen = 0; - - for (unsigned pflags_or = opt & PC_NO_ACCESS_CHECK; ; pflags_or = 0) - { - const suffix_info *suff; - char *full_path; - - /* Don't allow symlink.check to set anything in the path_conv - class if we're working on an inner component of the path */ - if (component) - { - suff = NULL; - sym.pflags = 0; - full_path = pathbuf; - } - else - { - suff = suffixes; - sym.pflags = path_flags; - full_path = THIS_path; - } - - /* Convert to native path spec sans symbolic link info. */ - error = mount_table->conv_to_win32_path (path_copy, full_path, dev, - &sym.pflags); - - if (error) - return; - - sym.pflags |= pflags_or; - - if (dev.major == DEV_CYGDRIVE_MAJOR) - { - if (!component) - fileattr = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_READONLY; - else - { - fileattr = getfileattr (THIS_path, - sym.pflags & MOUNT_NOPOSIX); - dev.devn = FH_FS; - } - goto out; - } - else if (dev == FH_DEV) - { - dev.devn = FH_FS; -#if 0 - fileattr = getfileattr (THIS_path, sym.pflags & MOUNT_NOPOSIX); - if (!component && fileattr == INVALID_FILE_ATTRIBUTES) - { - fileattr = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_READONLY; - goto out; - } -#endif - } - else if (isvirtual_dev (dev.devn)) - { - /* FIXME: Calling build_fhandler here is not the right way to handle this. */ - fhandler_virtual *fh = (fhandler_virtual *) build_fh_dev (dev, path_copy); - int file_type = fh->exists (); - if (file_type == -2) - { - fh->fill_filebuf (); - symlen = sym.set (fh->get_filebuf ()); - } - delete fh; - switch (file_type) - { - case 1: - case 2: - if (component == 0) - fileattr = FILE_ATTRIBUTE_DIRECTORY; - break; - case -1: - if (component == 0) - fileattr = 0; - break; - case -2: /* /proc/self or /proc//symlinks */ - goto is_virtual_symlink; - case -3: /* /proc//fd/pipe:[] */ - if (component == 0) - { - fileattr = 0; - dev.parse (FH_PIPE); - } - break; - case -4: /* /proc//fd/socket:[] */ - if (component == 0) - { - fileattr = 0; - dev.parse (FH_TCP); - } - break; - default: - if (component == 0) - fileattr = INVALID_FILE_ATTRIBUTES; - goto virtual_component_retry; - } - if (component == 0 || dev.devn != FH_NETDRIVE) - path_flags |= PATH_RO; - goto out; - } - /* devn should not be a device. If it is, then stop parsing now. */ - else if (dev.devn != FH_FS) - { - fileattr = 0; - path_flags = sym.pflags; - if (component) - { - error = ENOTDIR; - return; - } - goto out; /* Found a device. Stop parsing. */ - } - - /* If path is only a drivename, Windows interprets it as the - current working directory on this drive instead of the root - dir which is what we want. So we need the trailing backslash - in this case. */ - if (full_path[0] && full_path[1] == ':' && full_path[2] == '\0') - { - full_path[2] = '\\'; - full_path[3] = '\0'; - } - - symlen = sym.check (full_path, suff, opt, fs); - -is_virtual_symlink: - - if (sym.isdevice) - { - dev.parse (sym.major, sym.minor); - dev.setfs (1); - dev.mode = sym.mode; - fileattr = sym.fileattr; - goto out; - } - - if (sym.pflags & PATH_SOCKET) - { - if (component) - { - error = ENOTDIR; - return; - } - fileattr = sym.fileattr; - dev.parse (FH_UNIX); - dev.setfs (1); - goto out; - } - - if (!component) - { - fileattr = sym.fileattr; - path_flags = sym.pflags; - /* If the OS is caseinsensitive or the FS is caseinsensitive, - don't handle path casesensitive. */ - if (cygwin_shared->obcaseinsensitive || fs.caseinsensitive ()) - path_flags |= PATH_NOPOSIX; - /* If the incoming path was given in DOS notation, always treat - it as caseinsensitive,noacl path. */ - else if (is_msdos) - path_flags |= PATH_NOPOSIX | PATH_NOACL; - caseinsensitive = (path_flags & PATH_NOPOSIX) - ? OBJ_CASE_INSENSITIVE : 0; - } - - /* If symlink.check found an existing non-symlink file, then - it sets the appropriate flag. It also sets any suffix found - into `ext_here'. */ - if (!sym.issymlink && sym.fileattr != INVALID_FILE_ATTRIBUTES) - { - error = sym.error; - if (component == 0) - add_ext = true; - else if (!(sym.fileattr & FILE_ATTRIBUTE_DIRECTORY)) - { - error = ENOTDIR; - goto out; - } - goto out; // file found - } - /* Found a symlink if symlen > 0. If component == 0, then the - src path itself was a symlink. If !follow_mode then - we're done. Otherwise we have to insert the path found - into the full path that we are building and perform all of - these operations again on the newly derived path. */ - else if (symlen > 0) - { - saw_symlinks = 1; - if (component == 0 && !need_directory && !(opt & PC_SYM_FOLLOW)) - { - set_symlink (symlen); // last component of path is a symlink. - if (opt & PC_SYM_CONTENTS) - { - strcpy (THIS_path, sym.contents); - goto out; - } - add_ext = true; - goto out; - } - else - break; - } - else if (sym.error && sym.error != ENOENT) - { - error = sym.error; - goto out; - } - /* No existing file found. */ - -virtual_component_retry: - /* Find the new "tail" of the path, e.g. in '/for/bar/baz', - /baz is the tail. */ - if (tail != path_end) - *tail = '/'; - while (--tail > path_copy + 1 && *tail != '/') {} - /* Exit loop if there is no tail or we are at the - beginning of a UNC path */ - if (tail <= path_copy + 1) - goto out; // all done - - /* Haven't found an existing pathname component yet. - Pinch off the tail and try again. */ - *tail = '\0'; - component++; - } - - /* Arrive here if above loop detected a symlink. */ - if (++loop > SYMLOOP_MAX) - { - error = ELOOP; // Eep. - return; - } - - MALLOC_CHECK; - - - /* Place the link content, possibly with head and/or tail, in tmp_buf */ - - char *headptr; - if (isabspath (sym.contents)) - headptr = tmp_buf; /* absolute path */ - else - { - /* Copy the first part of the path (with ending /) and point to the end. */ - char *prevtail = tail; - while (--prevtail > path_copy && *prevtail != '/') {} - int headlen = prevtail - path_copy + 1;; - memcpy (tmp_buf, path_copy, headlen); - headptr = &tmp_buf[headlen]; - } - - /* Make sure there is enough space */ - if (headptr + symlen >= tmp_buf + (2 * NT_MAX_PATH)) - { - too_long: - error = ENAMETOOLONG; - set_path ("::ENAMETOOLONG::"); - return; - } - - /* Copy the symlink contents to the end of tmp_buf. - Convert slashes. */ - for (char *p = sym.contents; *p; p++) - *headptr++ = *p == '\\' ? '/' : *p; - *headptr = '\0'; - - /* Copy any tail component (with the 0) */ - if (tail++ < path_end) - { - /* Add a slash if needed. There is space. */ - if (*(headptr - 1) != '/') - *headptr++ = '/'; - int taillen = path_end - tail + 1; - if (headptr + taillen > tmp_buf + (2 * NT_MAX_PATH)) - goto too_long; - memcpy (headptr, tail, taillen); - } - - /* Evaluate everything all over again. */ - src = tmp_buf; - } - - if (!(opt & PC_SYM_CONTENTS)) - add_ext = true; - -out: - set_path (THIS_path); - if (add_ext) - add_ext_from_sym (sym); - if (dev.devn == FH_NETDRIVE && component) - { - /* This case indicates a non-existant resp. a non-retrievable - share. This happens for instance if the share is a printer. - In this case the path must not be treated like a FH_NETDRIVE, - but like a FH_FS instead, so the usual open call for files - is used on it. */ - dev.parse (FH_FS); - } - else if (isvirtual_dev (dev.devn) && fileattr == INVALID_FILE_ATTRIBUTES) - { - error = ENOENT; - return; - } - else if (!need_directory || error) - /* nothing to do */; - else if (fileattr == INVALID_FILE_ATTRIBUTES) - strcat (modifiable_path (), "\\"); /* Reattach trailing dirsep in native path. */ - else if (fileattr & FILE_ATTRIBUTE_DIRECTORY) - path_flags &= ~PATH_SYMLINK; - else - { - debug_printf ("%s is a non-directory", path); - error = ENOTDIR; - return; - } - - if (dev.isfs ()) - { - if (strncmp (path, "\\\\.\\", 4)) - { - if (!tail || tail == path) - /* nothing */; - else if (tail[-1] != '\\') - *tail = '\0'; - else - { - error = ENOENT; - return; - } - } - - /* FS has been checked already for existing files. */ - if (exists () || fs.update (get_nt_native_path (), NULL)) - { - /* Incoming DOS paths are treated like DOS paths in native - Windows applications. No ACLs, just default settings. */ - if (is_msdos) - fs.has_acls (false); - debug_printf ("this->path(%s), has_acls(%d)", path, fs.has_acls ()); - /* CV: We could use this->has_acls() but I want to make sure that - we don't forget that the PATH_NOACL flag must be taken into - account here. */ - if (!(path_flags & PATH_NOACL) && fs.has_acls ()) - set_exec (0); /* We really don't know if this is executable or not here - but set it to not executable since it will be figured out - later by anything which cares about this. */ - } - if (exec_state () != dont_know_if_executable) - /* ok */; - else if (isdir ()) - set_exec (1); - else if (issymlink () || issocket ()) - set_exec (0); - } - - if (opt & PC_NOFULL) - { - if (is_relpath) - { - mkrelpath (this->modifiable_path (), !!caseinsensitive); - /* Invalidate wide_path so that wide relpath can be created - in later calls to get_nt_native_path or get_wide_win32_path. */ - if (wide_path) - cfree (wide_path); - wide_path = NULL; - } - if (need_directory) - { - size_t n = strlen (this->path); - /* Do not add trailing \ to UNC device names like \\.\a: */ - if (this->path[n - 1] != '\\' && - (strncmp (this->path, "\\\\.\\", 4) != 0)) - { - this->modifiable_path ()[n] = '\\'; - this->modifiable_path ()[n + 1] = '\0'; - } - } - } - - if (saw_symlinks) - set_has_symlinks (); - - if ((opt & PC_POSIX)) - { - if (tail < path_end && tail > path_copy + 1) - *tail = '/'; - set_normalized_path (path_copy); - if (is_msdos && !(opt & PC_NOWARN)) - warn_msdos (src); - } - -#if 0 - if (!error) - { - last_path_conv = *this; - strcpy (last_src, src); - } -#endif -} - -path_conv::~path_conv () -{ - if (normalized_path) - { - cfree ((void *) normalized_path); - normalized_path = NULL; - } - if (path) - { - cfree (modifiable_path ()); - path = NULL; - } - if (wide_path) - { - cfree (wide_path); - wide_path = NULL; - } -} - -bool -path_conv::is_binary () -{ - tmp_pathbuf tp; - PWCHAR bintest = tp.w_get (); - DWORD bin; - - return GetBinaryTypeW (get_wide_win32_path (bintest), &bin) - && (bin == SCS_32BIT_BINARY || bin == SCS_64BIT_BINARY); -} - -/* Normalize a Win32 path. - /'s are converted to \'s in the process. - All duplicate \'s, except for 2 leading \'s, are deleted. - - The result is 0 for success, or an errno error value. - FIXME: A lot of this should be mergeable with the POSIX critter. */ -int -normalize_win32_path (const char *src, char *dst, char *&tail) -{ - const char *src_start = src; - bool beg_src_slash = isdirsep (src[0]); - - tail = dst; - /* Skip long path name prefixes in Win32 or NT syntax. */ - if (beg_src_slash && (src[1] == '?' || isdirsep (src[1])) - && src[2] == '?' && isdirsep (src[3])) - { - src += 4; - if (src[1] != ':') /* native UNC path */ - src += 2; /* Fortunately the first char is not copied... */ - else - beg_src_slash = false; - } - if (beg_src_slash && isdirsep (src[1])) - { - if (isdirsep (src[2])) - { - /* More than two slashes are just folded into one. */ - src += 2; - while (isdirsep (src[1])) - ++src; - } - else - { - /* Two slashes start a network or device path. */ - *tail++ = '\\'; - src++; - if (src[1] == '.' && isdirsep (src[2])) - { - *tail++ = '\\'; - *tail++ = '.'; - src += 2; - } - } - } - if (tail == dst) - { - if (isdrive (src)) - /* Always convert drive letter to uppercase for case sensitivity. */ - *tail++ = cyg_toupper (*src++); - else if (*src != '/') - { - if (beg_src_slash) - tail += cygheap->cwd.get_drive (dst); - else if (!cygheap->cwd.get (dst, 0)) - return get_errno (); - else - { - tail = strchr (tail, '\0'); - if (tail[-1] != '\\') - *tail++ = '\\'; - } - } - } - - while (*src) - { - /* Strip duplicate /'s. */ - if (isdirsep (src[0]) && isdirsep (src[1])) - src++; - /* Ignore "./". */ - else if (src[0] == '.' && isdirsep (src[1]) - && (src == src_start || isdirsep (src[-1]))) - src += 2; - - /* Backup if "..". */ - else if (src[0] == '.' && src[1] == '.' - /* dst must be greater than dst_start */ - && tail[-1] == '\\') - { - if (!isdirsep (src[2]) && src[2] != '\0') - *tail++ = *src++; - else - { - /* Back up over /, but not if it's the first one. */ - if (tail > dst + 1) - tail--; - /* Now back up to the next /. */ - while (tail > dst + 1 && tail[-1] != '\\' && tail[-2] != ':') - tail--; - src += 2; - if (isdirsep (*src)) - src++; - } - } - /* Otherwise, add char to result. */ - else - { - if (*src == '/') - *tail++ = '\\'; - else - *tail++ = *src; - src++; - } - if ((tail - dst) >= NT_MAX_PATH) - return ENAMETOOLONG; - } - if (tail > dst + 1 && tail[-1] == '.' && tail[-2] == '\\') - tail--; - *tail = '\0'; - debug_printf ("%s = normalize_win32_path (%s)", dst, src_start); - return 0; -} - -/* Various utilities. */ - -/* nofinalslash: Remove trailing / and \ from SRC (except for the - first one). It is ok for src == dst. */ - -void __stdcall -nofinalslash (const char *src, char *dst) -{ - int len = strlen (src); - if (src != dst) - memcpy (dst, src, len + 1); - while (len > 1 && isdirsep (dst[--len])) - dst[len] = '\0'; -} - -/* conv_path_list: Convert a list of path names to/from Win32/POSIX. */ - -static int -conv_path_list (const char *src, char *dst, size_t size, int to_posix) -{ - tmp_pathbuf tp; - char src_delim, dst_delim; - cygwin_conv_path_t conv_fn; - size_t len; - - if (to_posix) - { - src_delim = ';'; - dst_delim = ':'; - conv_fn = CCP_WIN_A_TO_POSIX | CCP_RELATIVE; - } - else - { - src_delim = ':'; - dst_delim = ';'; - conv_fn = CCP_POSIX_TO_WIN_A | CCP_RELATIVE; - } - - char *srcbuf; - len = strlen (src) + 1; - if (len <= NT_MAX_PATH * sizeof (WCHAR)) - srcbuf = (char *) tp.w_get (); - else - srcbuf = (char *) alloca (len); - - int err = 0; - char *d = dst - 1; - bool saw_empty = false; - do - { - char *s = strccpy (srcbuf, &src, src_delim); - size_t len = s - srcbuf; - if (len >= NT_MAX_PATH) - { - err = ENAMETOOLONG; - break; - } - if (len) - { - ++d; - err = cygwin_conv_path (conv_fn, srcbuf, d, size - (d - dst)); - } - else if (!to_posix) - { - ++d; - err = cygwin_conv_path (conv_fn, ".", d, size - (d - dst)); - } - else - { - if (to_posix == ENV_CVT) - saw_empty = true; - continue; - } - if (err) - break; - d = strchr (d, '\0'); - *d = dst_delim; - } - while (*src++); - - if (saw_empty) - err = EIDRM; - - if (d < dst) - d++; - *d = '\0'; - return err; -} - -/********************** Symbolic Link Support **************************/ - -/* Create a symlink from FROMPATH to TOPATH. */ - -/* If TRUE create symlinks as Windows shortcuts, if false create symlinks - as normal files with magic number and system bit set. */ -bool allow_winsymlinks = false; - -extern "C" int -symlink (const char *oldpath, const char *newpath) -{ - return symlink_worker (oldpath, newpath, allow_winsymlinks, false); -} - -int -symlink_worker (const char *oldpath, const char *newpath, bool use_winsym, - bool isdevice) -{ - int res = -1; - size_t len; - path_conv win32_newpath, win32_oldpath; - char *buf, *cp; - SECURITY_ATTRIBUTES sa = sec_none_nih; - OBJECT_ATTRIBUTES attr; - IO_STATUS_BLOCK io; - NTSTATUS status; - HANDLE fh; - tmp_pathbuf tp; - unsigned check_opt; - bool mk_winsym = use_winsym; - bool has_trailing_dirsep = false; - - /* POSIX says that empty 'newpath' is invalid input while empty - 'oldpath' is valid -- it's symlink resolver job to verify if - symlink contents point to existing filesystem object */ - myfault efault; - if (efault.faulted (EFAULT)) - goto done; - if (!*oldpath || !*newpath) - { - set_errno (ENOENT); - goto done; - } - - if (strlen (oldpath) > SYMLINK_MAX) - { - set_errno (ENAMETOOLONG); - goto done; - } - - /* Trailing dirsep is a no-no. */ - len = strlen (newpath); - has_trailing_dirsep = isdirsep (newpath[len - 1]); - if (has_trailing_dirsep) - { - newpath = strdup (newpath); - ((char *) newpath)[len - 1] = '\0'; - } - - check_opt = PC_SYM_NOFOLLOW | PC_POSIX | (isdevice ? PC_NOWARN : 0); - /* We need the normalized full path below. */ - win32_newpath.check (newpath, check_opt, stat_suffixes); - /* MVFS doesn't handle the SYSTEM DOS attribute, but it handles the R/O - attribute. Therefore we create symlinks on MVFS always as shortcuts. */ - mk_winsym |= win32_newpath.fs_is_mvfs (); - - if (mk_winsym && !win32_newpath.exists () - && (isdevice || !win32_newpath.fs_is_nfs ())) - { - char *newplnk = tp.c_get (); - stpcpy (stpcpy (newplnk, newpath), ".lnk"); - win32_newpath.check (newplnk, check_opt); - } - - if (win32_newpath.error) - { - set_errno (win32_newpath.error); - goto done; - } - - syscall_printf ("symlink (%s, %S)", oldpath, - win32_newpath.get_nt_native_path ()); - - if ((!isdevice && win32_newpath.exists ()) - || win32_newpath.is_auto_device ()) - { - set_errno (EEXIST); - goto done; - } - if (has_trailing_dirsep && !win32_newpath.exists ()) - { - set_errno (ENOENT); - goto done; - } - - if (!isdevice && win32_newpath.fs_is_nfs ()) - { - /* On NFS, create symlinks by calling NtCreateFile with an EA of type - NfsSymlinkTargetName containing ... the symlink target name. */ - PFILE_FULL_EA_INFORMATION pffei = (PFILE_FULL_EA_INFORMATION) tp.w_get (); - pffei->NextEntryOffset = 0; - pffei->Flags = 0; - pffei->EaNameLength = sizeof (NFS_SYML_TARGET) - 1; - char *EaValue = stpcpy (pffei->EaName, NFS_SYML_TARGET) + 1; - pffei->EaValueLength = sizeof (WCHAR) * - (sys_mbstowcs ((PWCHAR) EaValue, NT_MAX_PATH, oldpath) - 1); - status = NtCreateFile (&fh, FILE_WRITE_DATA | FILE_WRITE_EA | SYNCHRONIZE, - win32_newpath.get_object_attr (attr, sa), - &io, NULL, FILE_ATTRIBUTE_SYSTEM, - FILE_SHARE_VALID_FLAGS, FILE_CREATE, - FILE_SYNCHRONOUS_IO_NONALERT - | FILE_OPEN_FOR_BACKUP_INTENT, - pffei, NT_MAX_PATH * sizeof (WCHAR)); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - goto done; - } - NtClose (fh); - res = 0; - goto done; - } - - if (mk_winsym) - { - ITEMIDLIST *pidl = NULL; - size_t full_len = 0; - unsigned short oldpath_len, desc_len, relpath_len, pidl_len = 0; - char desc[MAX_PATH + 1], *relpath; - - if (!isdevice) - { - /* First create an IDLIST to learn how big our shortcut is - going to be. */ - IShellFolder *psl; - - /* The symlink target is relative to the directory in which - the symlink gets created, not relative to the cwd. Therefore - we have to mangle the path quite a bit before calling path_conv. */ - if (isabspath (oldpath)) - win32_oldpath.check (oldpath, - PC_SYM_NOFOLLOW, - stat_suffixes); - else - { - len = strrchr (win32_newpath.normalized_path, '/') - - win32_newpath.normalized_path + 1; - char *absoldpath = tp.t_get (); - stpcpy (stpncpy (absoldpath, win32_newpath.normalized_path, len), - oldpath); - win32_oldpath.check (absoldpath, PC_SYM_NOFOLLOW, stat_suffixes); - } - if (SUCCEEDED (SHGetDesktopFolder (&psl))) - { - WCHAR wc_path[win32_oldpath.get_wide_win32_path_len () + 1]; - win32_oldpath.get_wide_win32_path (wc_path); - /* Amazing but true: Even though the ParseDisplayName method - takes a wide char path name, it does not understand the - Win32 prefix for long pathnames! So we have to tack off - the prefix and convert the path to the "normal" syntax - for ParseDisplayName. */ - WCHAR *wc = wc_path + 4; - if (wc[1] != L':') /* native UNC path */ - *(wc += 2) = L'\\'; - HRESULT res; - if (SUCCEEDED (res = psl->ParseDisplayName (NULL, NULL, wc, NULL, - &pidl, NULL))) - { - ITEMIDLIST *p; - - for (p = pidl; p->mkid.cb > 0; - p = (ITEMIDLIST *)((char *) p + p->mkid.cb)) - ; - pidl_len = (char *) p - (char *) pidl + 2; - } - psl->Release (); - } - } - /* Compute size of shortcut file. */ - full_len = sizeof (win_shortcut_hdr); - if (pidl_len) - full_len += sizeof (unsigned short) + pidl_len; - oldpath_len = strlen (oldpath); - /* Unfortunately the length of the description is restricted to a - length of MAX_PATH up to NT4, and to a length of 2000 bytes - since W2K. We don't want to add considerations for the different - lengths and even 2000 bytes is not enough for long path names. - So what we do here is to set the description to the POSIX path - only if the path is not longer than MAX_PATH characters. We - append the full path name after the regular shortcut data - (see below), which works fine with Windows Explorer as well - as older Cygwin versions (as long as the whole file isn't bigger - than 8K). The description field is only used for backward - compatibility to older Cygwin versions and those versions are - not capable of handling long path names anyway. */ - desc_len = stpcpy (desc, oldpath_len > MAX_PATH - ? "[path too long]" : oldpath) - desc; - full_len += sizeof (unsigned short) + desc_len; - /* Devices get the oldpath string unchanged as relative path. */ - if (isdevice) - { - relpath_len = oldpath_len; - stpcpy (relpath = tp.c_get (), oldpath); - } - else - { - relpath_len = strlen (win32_oldpath.get_win32 ()); - stpcpy (relpath = tp.c_get (), win32_oldpath.get_win32 ()); - } - full_len += sizeof (unsigned short) + relpath_len; - full_len += sizeof (unsigned short) + oldpath_len; - /* 1 byte more for trailing 0 written by stpcpy. */ - if (full_len < NT_MAX_PATH * sizeof (WCHAR)) - buf = (char *) tp.w_get (); - else - buf = (char *) alloca (full_len + 1); - - /* Create shortcut header */ - win_shortcut_hdr *shortcut_header = (win_shortcut_hdr *) buf; - memset (shortcut_header, 0, sizeof *shortcut_header); - shortcut_header->size = sizeof *shortcut_header; - shortcut_header->magic = GUID_shortcut; - shortcut_header->flags = (WSH_FLAG_DESC | WSH_FLAG_RELPATH); - if (pidl) - shortcut_header->flags |= WSH_FLAG_IDLIST; - shortcut_header->run = SW_NORMAL; - cp = buf + sizeof (win_shortcut_hdr); - - /* Create IDLIST */ - if (pidl) - { - *(unsigned short *)cp = pidl_len; - memcpy (cp += 2, pidl, pidl_len); - cp += pidl_len; - CoTaskMemFree (pidl); - } - - /* Create description */ - *(unsigned short *)cp = desc_len; - cp = stpcpy (cp += 2, desc); - - /* Create relpath */ - *(unsigned short *)cp = relpath_len; - cp = stpcpy (cp += 2, relpath); - - /* Append the POSIX path after the regular shortcut data for - the long path support. */ - unsigned short *plen = (unsigned short *) cp; - cp += 2; - *(PWCHAR) cp = 0xfeff; /* BOM */ - cp += 2; - *plen = sys_mbstowcs ((PWCHAR) cp, NT_MAX_PATH, oldpath) * sizeof (WCHAR); - cp += *plen; - } - else - { - /* Default technique creating a symlink. */ - buf = (char *) tp.w_get (); - cp = stpcpy (buf, SYMLINK_COOKIE); - *(PWCHAR) cp = 0xfeff; /* BOM */ - cp += 2; - /* Note that the terminating nul is written. */ - cp += sys_mbstowcs ((PWCHAR) cp, NT_MAX_PATH, oldpath) * sizeof (WCHAR); - } - - if (isdevice && win32_newpath.exists ()) - { - status = NtOpenFile (&fh, FILE_WRITE_ATTRIBUTES, - win32_newpath.get_object_attr (attr, sa), - &io, 0, FILE_OPEN_FOR_BACKUP_INTENT); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - goto done; - } - status = NtSetAttributesFile (fh, FILE_ATTRIBUTE_NORMAL); - NtClose (fh); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - goto done; - } - } - status = NtCreateFile (&fh, DELETE | FILE_GENERIC_WRITE, - win32_newpath.get_object_attr (attr, sa), - &io, NULL, FILE_ATTRIBUTE_NORMAL, - FILE_SHARE_VALID_FLAGS, - isdevice ? FILE_OVERWRITE_IF : FILE_CREATE, - FILE_SYNCHRONOUS_IO_NONALERT - | FILE_NON_DIRECTORY_FILE - | FILE_OPEN_FOR_BACKUP_INTENT, - NULL, 0); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - goto done; - } - if (win32_newpath.has_acls ()) - set_file_attribute (fh, win32_newpath, ILLEGAL_UID, ILLEGAL_GID, - (io.Information == FILE_CREATED ? S_JUSTCREATED : 0) - | S_IFLNK | STD_RBITS | STD_WBITS); - status = NtWriteFile (fh, NULL, NULL, NULL, &io, buf, cp - buf, NULL, NULL); - if (NT_SUCCESS (status) && io.Information == (ULONG) (cp - buf)) - { - status = NtSetAttributesFile (fh, mk_winsym ? FILE_ATTRIBUTE_READONLY - : FILE_ATTRIBUTE_SYSTEM); - if (!NT_SUCCESS (status)) - debug_printf ("Setting attributes failed, status = %p", status); - res = 0; - } - else - { - __seterrno_from_nt_status (status); - FILE_DISPOSITION_INFORMATION fdi = { TRUE }; - status = NtSetInformationFile (fh, &io, &fdi, sizeof fdi, - FileDispositionInformation); - if (!NT_SUCCESS (status)) - debug_printf ("Setting delete dispostion failed, status = %p", status); - } - NtClose (fh); - -done: - syscall_printf ("%d = symlink_worker (%s, %s, %d, %d)", res, oldpath, - newpath, mk_winsym, isdevice); - if (has_trailing_dirsep) - free ((void *) newpath); - return res; -} - -static bool -cmp_shortcut_header (win_shortcut_hdr *file_header) -{ - /* A Cygwin or U/Win shortcut only contains a description and a relpath. - Cygwin shortcuts also might contain an ITEMIDLIST. The run type is - always set to SW_NORMAL. */ - return file_header->size == sizeof (win_shortcut_hdr) - && !memcmp (&file_header->magic, &GUID_shortcut, sizeof GUID_shortcut) - && (file_header->flags & ~WSH_FLAG_IDLIST) - == (WSH_FLAG_DESC | WSH_FLAG_RELPATH) - && file_header->run == SW_NORMAL; -} - -int -symlink_info::check_shortcut (HANDLE in_h) -{ - tmp_pathbuf tp; - win_shortcut_hdr *file_header; - char *buf, *cp; - unsigned short len; - int res = 0; - UNICODE_STRING same = { 0, 0, (PWCHAR) L"" }; - OBJECT_ATTRIBUTES attr; - NTSTATUS status; - HANDLE h; - IO_STATUS_BLOCK io; - FILE_STANDARD_INFORMATION fsi; - - InitializeObjectAttributes (&attr, &same, 0, in_h, NULL); - status = NtOpenFile (&h, FILE_READ_DATA | SYNCHRONIZE, - &attr, &io, FILE_SHARE_VALID_FLAGS, - FILE_OPEN_FOR_BACKUP_INTENT - | FILE_SYNCHRONOUS_IO_NONALERT); - if (!NT_SUCCESS (status)) - return 0; - status = NtQueryInformationFile (h, &io, &fsi, sizeof fsi, - FileStandardInformation); - if (!NT_SUCCESS (status)) - { - set_error (EIO); - goto out; - } - if (fsi.EndOfFile.QuadPart <= sizeof (win_shortcut_hdr) - || fsi.EndOfFile.QuadPart > 4 * 65536) - goto out; - if (fsi.EndOfFile.LowPart < NT_MAX_PATH * sizeof (WCHAR)) - buf = (char *) tp.w_get (); - else - buf = (char *) alloca (fsi.EndOfFile.LowPart + 1); - if (!NT_SUCCESS (NtReadFile (h, NULL, NULL, NULL, - &io, buf, fsi.EndOfFile.LowPart, NULL, NULL))) - { - set_error (EIO); - goto out; - } - file_header = (win_shortcut_hdr *) buf; - if (io.Information != fsi.EndOfFile.LowPart - || !cmp_shortcut_header (file_header)) - goto out; - cp = buf + sizeof (win_shortcut_hdr); - if (file_header->flags & WSH_FLAG_IDLIST) /* Skip ITEMIDLIST */ - cp += *(unsigned short *) cp + 2; - if (!(len = *(unsigned short *) cp)) - goto out; - cp += 2; - /* Check if this is a device file - these start with the sequence :\\ */ - if (strncmp (cp, ":\\", 2) == 0) - res = strlen (strcpy (contents, cp)); /* Don't mess with device files */ - else - { - /* Has appended full path? If so, use it instead of description. */ - unsigned short relpath_len = *(unsigned short *) (cp + len); - if (cp + len + 2 + relpath_len < buf + fsi.EndOfFile.LowPart) - { - cp += len + 2 + relpath_len; - len = *(unsigned short *) cp; - cp += 2; - } - if (*(PWCHAR) cp == 0xfeff) /* BOM */ - { - char *tmpbuf = tp.c_get (); - if (sys_wcstombs (tmpbuf, NT_MAX_PATH, (PWCHAR) (cp + 2)) - > SYMLINK_MAX + 1) - goto out; - res = posixify (tmpbuf); - } - else if (len > SYMLINK_MAX) - goto out; - else - { - cp[len] = '\0'; - res = posixify (cp); - } - } - if (res) /* It's a symlink. */ - pflags = PATH_SYMLINK | PATH_LNK; - -out: - NtClose (h); - return res; -} - -int -symlink_info::check_sysfile (HANDLE in_h) -{ - tmp_pathbuf tp; - char cookie_buf[sizeof (SYMLINK_COOKIE) - 1]; - char *srcbuf = tp.c_get (); - int res = 0; - UNICODE_STRING same = { 0, 0, (PWCHAR) L"" }; - OBJECT_ATTRIBUTES attr; - NTSTATUS status; - HANDLE h; - IO_STATUS_BLOCK io; - bool interix_symlink = false; - - InitializeObjectAttributes (&attr, &same, 0, in_h, NULL); - status = NtOpenFile (&h, FILE_READ_DATA | SYNCHRONIZE, - &attr, &io, FILE_SHARE_VALID_FLAGS, - FILE_OPEN_FOR_BACKUP_INTENT - | FILE_SYNCHRONOUS_IO_NONALERT); - if (!NT_SUCCESS (status)) - ; - else if (!NT_SUCCESS (status = NtReadFile (h, NULL, NULL, NULL, &io, - cookie_buf, sizeof (cookie_buf), - NULL, NULL))) - { - debug_printf ("ReadFile1 failed"); - if (status != STATUS_END_OF_FILE) - set_error (EIO); - } - else if (io.Information == sizeof (cookie_buf) - && memcmp (cookie_buf, SYMLINK_COOKIE, sizeof (cookie_buf)) == 0) - { - /* It's a symlink. */ - pflags = PATH_SYMLINK; - } - else if (io.Information == sizeof (cookie_buf) - && memcmp (cookie_buf, SOCKET_COOKIE, sizeof (cookie_buf)) == 0) - pflags |= PATH_SOCKET; - else if (io.Information >= sizeof (INTERIX_SYMLINK_COOKIE) - && memcmp (cookie_buf, INTERIX_SYMLINK_COOKIE, - sizeof (INTERIX_SYMLINK_COOKIE) - 1) == 0) - { - /* It's an Interix symlink. */ - pflags = PATH_SYMLINK; - interix_symlink = true; - /* Interix symlink cookies are shorter than Cygwin symlink cookies, so - in case of an Interix symlink cooky we have read too far into the - file. Set file pointer back to the position right after the cookie. */ - FILE_POSITION_INFORMATION fpi; - fpi.CurrentByteOffset.QuadPart = sizeof (INTERIX_SYMLINK_COOKIE) - 1; - NtSetInformationFile (h, &io, &fpi, sizeof fpi, FilePositionInformation); - } - if (pflags == PATH_SYMLINK) - { - status = NtReadFile (h, NULL, NULL, NULL, &io, srcbuf, - NT_MAX_PATH, NULL, NULL); - if (!NT_SUCCESS (status)) - { - debug_printf ("ReadFile2 failed"); - if (status != STATUS_END_OF_FILE) - set_error (EIO); - } - else if (*(PWCHAR) srcbuf == 0xfeff /* BOM */ - || interix_symlink) - { - /* Add trailing 0 to Interix symlink target. Skip BOM in Cygwin - symlinks. */ - if (interix_symlink) - ((PWCHAR) srcbuf)[io.Information / sizeof (WCHAR)] = L'\0'; - else - srcbuf += 2; - char *tmpbuf = tp.c_get (); - if (sys_wcstombs (tmpbuf, NT_MAX_PATH, (PWCHAR) srcbuf) - > SYMLINK_MAX + 1) - debug_printf ("symlink string too long"); - else - res = posixify (tmpbuf); - } - else if (io.Information > SYMLINK_MAX + 1) - debug_printf ("symlink string too long"); - else - res = posixify (srcbuf); - } - NtClose (h); - return res; -} - -int -symlink_info::check_reparse_point (HANDLE h) -{ - tmp_pathbuf tp; - NTSTATUS status; - IO_STATUS_BLOCK io; - PREPARSE_DATA_BUFFER rp = (PREPARSE_DATA_BUFFER) tp.c_get (); - UNICODE_STRING subst; - char srcbuf[SYMLINK_MAX + 7]; - - status = NtFsControlFile (h, NULL, NULL, NULL, &io, FSCTL_GET_REPARSE_POINT, - NULL, 0, (LPVOID) rp, - MAXIMUM_REPARSE_DATA_BUFFER_SIZE); - if (!NT_SUCCESS (status)) - { - debug_printf ("NtFsControlFile(FSCTL_GET_REPARSE_POINT) failed, %p", - status); - set_error (EIO); - return 0; - } - if (rp->ReparseTag == IO_REPARSE_TAG_SYMLINK) - RtlInitCountedUnicodeString (&subst, - (WCHAR *)((char *)rp->SymbolicLinkReparseBuffer.PathBuffer - + rp->SymbolicLinkReparseBuffer.SubstituteNameOffset), - rp->SymbolicLinkReparseBuffer.SubstituteNameLength); - else if (rp->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) - { - RtlInitCountedUnicodeString (&subst, - (WCHAR *)((char *)rp->MountPointReparseBuffer.PathBuffer - + rp->MountPointReparseBuffer.SubstituteNameOffset), - rp->MountPointReparseBuffer.SubstituteNameLength); - if (RtlEqualUnicodePathPrefix (&subst, &ro_u_volume, TRUE)) - { - /* Volume mount point. Not treated as symlink. The return - value of -1 is a hint for the caller to treat this as a - volume mount point. */ - return -1; - } - } - else - { - /* Maybe it's a reparse point, but it's certainly not one we - recognize. Drop the REPARSE file attribute so we don't even - try to use the flag for some special handling. It's just some - arbitrary file or directory for us. */ - fileattr &= ~FILE_ATTRIBUTE_REPARSE_POINT; - return 0; - } - sys_wcstombs (srcbuf, SYMLINK_MAX + 7, subst.Buffer, - subst.Length / sizeof (WCHAR)); - pflags = PATH_SYMLINK | PATH_REP; - fileattr &= ~FILE_ATTRIBUTE_DIRECTORY; - return posixify (srcbuf); -} - -int -symlink_info::check_nfs_symlink (HANDLE h) -{ - tmp_pathbuf tp; - NTSTATUS status; - OBJECT_ATTRIBUTES attr; - IO_STATUS_BLOCK io; - struct { - FILE_GET_EA_INFORMATION fgei; - char buf[sizeof (NFS_SYML_TARGET)]; - } fgei_buf; - PFILE_FULL_EA_INFORMATION pffei; - int res = 0; - - InitializeObjectAttributes (&attr, &ro_u_empty, 0, h, NULL); - status = NtOpenFile (&h, FILE_READ_EA, &attr, &io, FILE_SHARE_VALID_FLAGS, - FILE_OPEN_REPARSE_POINT | FILE_OPEN_FOR_BACKUP_INTENT); - if (!NT_SUCCESS (status)) - return 0; - /* To find out if the file is a symlink and to get the symlink target, - try to fetch the NfsSymlinkTargetName EA. */ - fgei_buf.fgei.NextEntryOffset = 0; - fgei_buf.fgei.EaNameLength = sizeof (NFS_SYML_TARGET) - 1; - stpcpy (fgei_buf.fgei.EaName, NFS_SYML_TARGET); - pffei = (PFILE_FULL_EA_INFORMATION) tp.w_get (); - status = NtQueryEaFile (h, &io, pffei, NT_MAX_PATH * sizeof (WCHAR), TRUE, - &fgei_buf.fgei, sizeof fgei_buf, NULL, TRUE); - NtClose (h); - if (NT_SUCCESS (status) && pffei->EaValueLength > 0) - { - PWCHAR spath = (PWCHAR) - (pffei->EaName + pffei->EaNameLength + 1); - res = sys_wcstombs (contents, SYMLINK_MAX + 1, - spath, pffei->EaValueLength); - pflags = PATH_SYMLINK; - } - return res; -} - -int -symlink_info::posixify (char *srcbuf) -{ - /* The definition for a path in a native symlink is a bit weird. The Flags - value seem to contain 0 for absolute paths (stored as NT native path) - and 1 for relative paths. Relative paths are paths not starting with a - drive letter. These are not converted to NT native, but stored as - given. A path starting with a single backslash is relative to the - current drive thus a "relative" value (Flags == 1). - Funny enough it's possible to store paths with slashes instead of - backslashes, but they are evaluated incorrectly by subsequent Windows - calls like CreateFile (ERROR_INVALID_NAME). So, what we do here is to - take paths starting with slashes at face value, evaluating them as - Cygwin specific POSIX paths. - A path starting with two slashes(!) or backslashes is converted into an - NT UNC path. Unfortunately, in contrast to POSIX rules, paths starting - with three or more (back)slashes are also converted into UNC paths, - just incorrectly sticking to one redundant leading backslashe. We go - along with this behaviour to avoid scenarios in which native tools access - other files than Cygwin. - The above rules are used exactly the same way on Cygwin specific symlinks - (sysfiles and shortcuts) to eliminate non-POSIX paths in the output. */ - - /* Eliminate native NT prefixes. */ - if (srcbuf[0] == '\\' && !strncmp (srcbuf + 1, "??\\", 3)) - { - srcbuf += 4; - if (srcbuf[1] != ':') /* native UNC path */ - *(srcbuf += 2) = '\\'; - } - if (isdrive (srcbuf)) - mount_table->conv_to_posix_path (srcbuf, contents, 0); - else if (srcbuf[0] == '\\') - { - if (srcbuf[1] == '\\') /* UNC path */ - slashify (srcbuf, contents, 0); - else /* Paths starting with \ are current drive relative. */ - { - char cvtbuf[SYMLINK_MAX + 1]; - - stpcpy (cvtbuf + cygheap->cwd.get_drive (cvtbuf), srcbuf); - mount_table->conv_to_posix_path (cvtbuf, contents, 0); - } - } - else /* Everything else is taken as is. */ - slashify (srcbuf, contents, 0); - return strlen (contents); -} - -enum -{ - SCAN_BEG, - SCAN_LNK, - SCAN_HASLNK, - SCAN_JUSTCHECK, - SCAN_JUSTCHECKTHIS, /* Never try to append a suffix. */ - SCAN_APPENDLNK, - SCAN_EXTRALNK, - SCAN_DONE, -}; - -class suffix_scan -{ - const suffix_info *suffixes, *suffixes_start; - int nextstate; - char *eopath; -public: - const char *path; - char *has (const char *, const suffix_info *); - int next (); - int lnk_match () {return nextstate >= SCAN_APPENDLNK;} -}; - -char * -suffix_scan::has (const char *in_path, const suffix_info *in_suffixes) -{ - nextstate = SCAN_BEG; - suffixes = suffixes_start = in_suffixes; - - const char *fname = strrchr (in_path, '\\'); - fname = fname ? fname + 1 : in_path; - char *ext_here = strrchr (fname, '.'); - path = in_path; - eopath = strchr (path, '\0'); - - if (!ext_here) - goto noext; - - if (suffixes) - { - /* Check if the extension matches a known extension */ - for (const suffix_info *ex = in_suffixes; ex->name != NULL; ex++) - if (ascii_strcasematch (ext_here, ex->name)) - { - nextstate = SCAN_JUSTCHECK; - suffixes = NULL; /* Has an extension so don't scan for one. */ - goto done; - } - } - - /* Didn't match. Use last resort -- .lnk. */ - if (ascii_strcasematch (ext_here, ".lnk")) - { - nextstate = SCAN_HASLNK; - suffixes = NULL; - } - - noext: - ext_here = eopath; - - done: - /* Avoid attaching suffixes if the resulting filename would be invalid. */ - if (eopath - fname > NAME_MAX - 4) - { - nextstate = SCAN_JUSTCHECKTHIS; - suffixes = NULL; - } - return ext_here; -} - -int -suffix_scan::next () -{ - for (;;) - { - if (!suffixes) - switch (nextstate) - { - case SCAN_BEG: - suffixes = suffixes_start; - if (!suffixes) - { - nextstate = SCAN_LNK; - return 1; - } - nextstate = SCAN_EXTRALNK; - /* fall through to suffix checking below */ - break; - case SCAN_HASLNK: - nextstate = SCAN_APPENDLNK; /* Skip SCAN_BEG */ - return 1; - case SCAN_EXTRALNK: - nextstate = SCAN_DONE; - *eopath = '\0'; - return 0; - case SCAN_JUSTCHECK: - nextstate = SCAN_LNK; - return 1; - case SCAN_JUSTCHECKTHIS: - nextstate = SCAN_DONE; - return 1; - case SCAN_LNK: - case SCAN_APPENDLNK: - strcat (eopath, ".lnk"); - nextstate = SCAN_DONE; - return 1; - default: - *eopath = '\0'; - return 0; - } - - while (suffixes && suffixes->name) - if (nextstate == SCAN_EXTRALNK && !suffixes->addon) - suffixes++; - else - { - strcpy (eopath, suffixes->name); - if (nextstate == SCAN_EXTRALNK) - strcat (eopath, ".lnk"); - suffixes++; - return 1; - } - suffixes = NULL; - } -} - -bool -symlink_info::set_error (int in_errno) -{ - bool res; - if (!(pflags & PATH_NO_ACCESS_CHECK) || in_errno == ENAMETOOLONG || in_errno == EIO) - { - error = in_errno; - res = true; - } - else if (in_errno == ENOENT) - res = true; - else - { - fileattr = FILE_ATTRIBUTE_NORMAL; - res = false; - } - return res; -} - -bool -symlink_info::parse_device (const char *contents) -{ - char *endptr; - _major_t mymajor; - _major_t myminor; - _mode_t mymode; - - mymajor = strtol (contents += 2, &endptr, 16); - if (endptr == contents) - return isdevice = false; - - contents = endptr; - myminor = strtol (++contents, &endptr, 16); - if (endptr == contents) - return isdevice = false; - - contents = endptr; - mymode = strtol (++contents, &endptr, 16); - if (endptr == contents) - return isdevice = false; - - if ((mymode & S_IFMT) == S_IFIFO) - { - mymajor = _major (FH_FIFO); - myminor = _minor (FH_FIFO); - } - - major = mymajor; - minor = myminor; - mode = mymode; - return isdevice = true; -} - -/* Check if PATH is a symlink. PATH must be a valid Win32 path name. - - If PATH is a symlink, put the value of the symlink--the file to - which it points--into BUF. The value stored in BUF is not - necessarily null terminated. BUFLEN is the length of BUF; only up - to BUFLEN characters will be stored in BUF. BUF may be NULL, in - which case nothing will be stored. - - Set *SYML if PATH is a symlink. - - Set *EXEC if PATH appears to be executable. This is an efficiency - hack because we sometimes have to open the file anyhow. *EXEC will - not be set for every executable file. - - Return -1 on error, 0 if PATH is not a symlink, or the length - stored into BUF if PATH is a symlink. */ - -int -symlink_info::check (char *path, const suffix_info *suffixes, unsigned opt, - fs_info &fs) -{ - HANDLE h = NULL; - int res = 0; - suffix_scan suffix; - contents[0] = '\0'; - - issymlink = true; - isdevice = false; - ext_here = suffix.has (path, suffixes); - extn = ext_here - path; - major = 0; - minor = 0; - mode = 0; - pflags &= ~(PATH_SYMLINK | PATH_LNK | PATH_REP); - ULONG ci_flag = cygwin_shared->obcaseinsensitive || (pflags & PATH_NOPOSIX) - ? OBJ_CASE_INSENSITIVE : 0; - - /* TODO: Temporarily do all char->UNICODE conversion here. This should - already be slightly faster than using Ascii functions. */ - tmp_pathbuf tp; - UNICODE_STRING upath; - OBJECT_ATTRIBUTES attr; - tp.u_get (&upath); - InitializeObjectAttributes (&attr, &upath, ci_flag, NULL, NULL); - - PVOID eabuf = &nfs_aol_ffei; - ULONG easize = sizeof nfs_aol_ffei; - - while (suffix.next ()) - { - FILE_BASIC_INFORMATION fbi; - NTSTATUS status; - IO_STATUS_BLOCK io; - bool no_ea = false; - bool fs_update_called = false; - - error = 0; - get_nt_native_path (suffix.path, upath); - if (h) - { - NtClose (h); - h = NULL; - } - /* The EA given to NtCreateFile allows to get a handle to a symlink on - an NFS share, rather than getting a handle to the target of the - symlink (which would spoil the task of this method quite a bit). - Fortunately it's ignored on most other file systems so we don't have - to special case NFS too much. */ - status = NtCreateFile (&h, - READ_CONTROL | FILE_READ_ATTRIBUTES, - &attr, &io, NULL, 0, FILE_SHARE_VALID_FLAGS, - FILE_OPEN, - FILE_OPEN_REPARSE_POINT - | FILE_OPEN_FOR_BACKUP_INTENT, - eabuf, easize); - debug_printf ("%p = NtCreateFile (%S)", status, &upath); - /* No right to access EAs or EAs not supported? */ - if (!NT_SUCCESS (status) - && (status == STATUS_ACCESS_DENIED - || status == STATUS_EAS_NOT_SUPPORTED - || status == STATUS_NOT_SUPPORTED - || status == STATUS_INVALID_NETWORK_RESPONSE - /* Or a bug in Samba 3.2.x (x <= 7) when accessing a share's - root dir which has EAs enabled? */ - || status == STATUS_INVALID_PARAMETER)) - { - no_ea = true; - /* If EAs are not supported, there's no sense to check them again - with suffixes attached. So we set eabuf/easize to 0 here once. */ - if (status == STATUS_EAS_NOT_SUPPORTED - || status == STATUS_NOT_SUPPORTED) - { - eabuf = NULL; - easize = 0; - } - status = NtOpenFile (&h, READ_CONTROL | FILE_READ_ATTRIBUTES, - &attr, &io, FILE_SHARE_VALID_FLAGS, - FILE_OPEN_REPARSE_POINT - | FILE_OPEN_FOR_BACKUP_INTENT); - debug_printf ("%p = NtOpenFile (no-EA, %S)", status, &upath); - } - if (status == STATUS_OBJECT_NAME_NOT_FOUND && ci_flag == 0 - && wincap.has_broken_udf ()) - { - /* On NT 5.x UDF is broken (at least) in terms of case sensitivity. - When trying to open a file case sensitive, the file appears to be - non-existant. Another bug is described in fs_info::update. */ - attr.Attributes = OBJ_CASE_INSENSITIVE; - status = NtOpenFile (&h, READ_CONTROL | FILE_READ_ATTRIBUTES, - &attr, &io, FILE_SHARE_VALID_FLAGS, - FILE_OPEN_REPARSE_POINT - | FILE_OPEN_FOR_BACKUP_INTENT); - debug_printf ("%p = NtOpenFile (broken-UDF, %S)", status, &upath); - attr.Attributes = 0; - if (NT_SUCCESS (status)) - { - fs.update (&upath, h); - if (fs.is_udf ()) - fs_update_called = true; - else - { - NtClose (h); - status = STATUS_OBJECT_NAME_NOT_FOUND; - } - } - } - - if (NT_SUCCESS (status) - /* Check file system while we're having the file open anyway. - This speeds up path_conv noticably (~10%). */ - && (fs_update_called || fs.update (&upath, h)) - && NT_SUCCESS (status = fs.has_buggy_basic_info () - ? NtQueryAttributesFile (&attr, &fbi) - : NtQueryInformationFile (h, &io, &fbi, sizeof fbi, - FileBasicInformation))) - fileattr = fbi.FileAttributes; - else - { - debug_printf ("%p = NtQueryInformationFile (%S)", status, &upath); - h = NULL; - fileattr = INVALID_FILE_ATTRIBUTES; - - /* One of the inner path components is invalid, or the path contains - invalid characters. Bail out with ENOENT. - - Note that additional STATUS_OBJECT_PATH_INVALID and - STATUS_OBJECT_PATH_SYNTAX_BAD status codes exist. The first one - is seemingly not generated by NtQueryInformationFile, the latter - is only generated if the path is no absolute path within the - NT name space, which should not happen and would point to an - error in get_nt_native_path. Both status codes are deliberately - not tested here unless proved necessary. */ - if (status == STATUS_OBJECT_PATH_NOT_FOUND - || status == STATUS_OBJECT_NAME_INVALID - || status == STATUS_NO_MEDIA_IN_DEVICE) - { - set_error (ENOENT); - goto file_not_symlink; - } - if (status != STATUS_OBJECT_NAME_NOT_FOUND - && status != STATUS_NO_SUCH_FILE) /* ENOENT on NFS or 9x share */ - { - /* The file exists, but the user can't access it for one reason - or the other. To get the file attributes we try to access the - information by opening the parent directory and getting the - file attributes using a matching NtQueryDirectoryFile call. */ - UNICODE_STRING dirname, basename; - OBJECT_ATTRIBUTES dattr; - HANDLE dir; - struct { - FILE_BOTH_DIRECTORY_INFORMATION fdi; - WCHAR dummy_buf[NAME_MAX + 1]; - } fdi_buf; - - RtlSplitUnicodePath (&upath, &dirname, &basename); - InitializeObjectAttributes (&dattr, &dirname, ci_flag, - NULL, NULL); - status = NtOpenFile (&dir, SYNCHRONIZE | FILE_LIST_DIRECTORY, - &dattr, &io, FILE_SHARE_VALID_FLAGS, - FILE_SYNCHRONOUS_IO_NONALERT - | FILE_OPEN_FOR_BACKUP_INTENT - | FILE_DIRECTORY_FILE); - if (!NT_SUCCESS (status)) - { - debug_printf ("%p = NtOpenFile(%S)", status, &dirname); - /* There's a special case if the file is itself the root - of a drive which is not accessible by the current user. - This case is only recognized by the length of the - basename part. If it's 0, the incoming file is the - root of a drive. So we at least know it's a directory. */ - fileattr = basename.Length ? 0 : FILE_ATTRIBUTE_DIRECTORY; - } - else - { - status = NtQueryDirectoryFile (dir, NULL, NULL, NULL, &io, - &fdi_buf, sizeof fdi_buf, - FileBothDirectoryInformation, - TRUE, &basename, TRUE); - /* Take the opportunity to check file system while we're - having the handle to the parent dir. */ - fs.update (&upath, h); - NtClose (dir); - if (!NT_SUCCESS (status)) - { - debug_printf ("%p = NtQueryDirectoryFile(%S)", - status, &dirname); - if (status == STATUS_NO_SUCH_FILE) - { - /* This can happen when trying to access files - which match DOS device names on SMB shares. - NtOpenFile failed with STATUS_ACCESS_DENIED, - but the NtQueryDirectoryFile tells us the - file doesn't exist. We're suspicious in this - case and retry with the next suffix instead of - just giving up. */ - set_error (ENOENT); - continue; - } - fileattr = 0; - } - else - fileattr = fdi_buf.fdi.FileAttributes; - } - ext_tacked_on = !!*ext_here; - goto file_not_symlink; - } - set_error (ENOENT); - continue; - } - - ext_tacked_on = !!*ext_here; - - res = -1; - - /* Windows shortcuts are potentially treated as symlinks. Valid Cygwin - & U/WIN shortcuts are R/O, but definitely not directories. */ - if ((fileattr & (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_DIRECTORY)) - == FILE_ATTRIBUTE_READONLY && suffix.lnk_match ()) - { - res = check_shortcut (h); - if (!res) - { - /* If searching for `foo' and then finding a `foo.lnk' which is - no shortcut, return the same as if file not found. */ - if (ext_tacked_on) - { - fileattr = INVALID_FILE_ATTRIBUTES; - set_error (ENOENT); - continue; - } - } - else if (contents[0] != ':' || contents[1] != '\\' - || !parse_device (contents)) - break; - } - - /* If searching for `foo' and then finding a `foo.lnk' which is - no shortcut, return the same as if file not found. */ - else if (suffix.lnk_match () && ext_tacked_on) - { - fileattr = INVALID_FILE_ATTRIBUTES; - set_error (ENOENT); - continue; - } - - /* Reparse points are potentially symlinks. This check must be - performed before checking the SYSTEM attribute for sysfile - symlinks, since reparse points can have this flag set, too. - For instance, Vista starts to create a couple of reparse points - with SYSTEM and HIDDEN flags set. */ - else if (fileattr & FILE_ATTRIBUTE_REPARSE_POINT) - { - res = check_reparse_point (h); - if (res == -1) - { - /* Volume mount point. The filesystem information for the top - level directory should be for the volume top level directory - itself, rather than for the reparse point itself. So we - fetch the filesystem information again, but with a NULL - handle. This does what we want because fs_info::update opens - the handle without FILE_OPEN_REPARSE_POINT. */ - fs.update (&upath, NULL); - } - else if (res) - break; - } - - /* This is the old Cygwin method creating symlinks. A symlink will - have the `system' file attribute. Only files can be symlinks - (which can be symlinks to directories). */ - else if ((fileattr & (FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_DIRECTORY)) - == FILE_ATTRIBUTE_SYSTEM) - { - res = check_sysfile (h); - if (res) - break; - } - - /* If the file could be opened with FILE_READ_EA, and if it's on a - NFS share, check if it's a symlink. Only files can be symlinks - (which can be symlinks to directories). */ - else if (fs.is_nfs () && !no_ea && !(fileattr & FILE_ATTRIBUTE_DIRECTORY)) - { - res = check_nfs_symlink (h); - if (res) - break; - } - - /* Normal file. */ - file_not_symlink: - issymlink = false; - syscall_printf ("%s", isdevice ? "is a device" : "not a symlink"); - res = 0; - break; - } - - if (h) - NtClose (h); - - syscall_printf ("%d = symlink.check (%s, %p) (%p)", - res, suffix.path, contents, pflags); - return res; -} - -/* "path" is the path in a virtual symlink. Set a symlink_info struct from - that and proceed with further path checking afterwards. */ -int -symlink_info::set (char *path) -{ - strcpy (contents, path); - pflags = PATH_SYMLINK; - fileattr = FILE_ATTRIBUTE_NORMAL; - error = 0; - issymlink = true; - isdevice = false; - ext_tacked_on = false; - ext_here = NULL; - extn = major = minor = mode = 0; - return strlen (path); -} - -/* readlink system call */ - -extern "C" ssize_t -readlink (const char *path, char *buf, size_t buflen) -{ - if (buflen < 0) - { - set_errno (ENAMETOOLONG); - return -1; - } - - path_conv pathbuf (path, PC_SYM_CONTENTS, stat_suffixes); - - if (pathbuf.error) - { - set_errno (pathbuf.error); - syscall_printf ("-1 = readlink (%s, %p, %d)", path, buf, buflen); - return -1; - } - - if (!pathbuf.exists ()) - { - set_errno (ENOENT); - return -1; - } - - if (!pathbuf.issymlink ()) - { - if (pathbuf.exists ()) - set_errno (EINVAL); - return -1; - } - - ssize_t len = min (buflen, strlen (pathbuf.get_win32 ())); - memcpy (buf, pathbuf.get_win32 (), len); - - /* errno set by symlink.check if error */ - return len; -} - -/* Some programs rely on st_dev/st_ino being unique for each file. - Hash the path name and hope for the best. The hash arg is not - always initialized to zero since readdir needs to compute the - dirent ino_t based on a combination of the hash of the directory - done during the opendir call and the hash or the filename within - the directory. FIXME: Not bullet-proof. */ -/* Cygwin internal */ -__ino64_t __stdcall -hash_path_name (__ino64_t hash, PUNICODE_STRING name) -{ - if (name->Length == 0) - return hash; - - /* Build up hash. Name is already normalized */ - USHORT len = name->Length / sizeof (WCHAR); - for (USHORT idx = 0; idx < len; ++idx) - hash = RtlUpcaseUnicodeChar (name->Buffer[idx]) - + (hash << 6) + (hash << 16) - hash; - return hash; -} - -__ino64_t __stdcall -hash_path_name (__ino64_t hash, PCWSTR name) -{ - UNICODE_STRING uname; - RtlInitUnicodeString (&uname, name); - return hash_path_name (hash, &uname); -} - -__ino64_t __stdcall -hash_path_name (__ino64_t hash, const char *name) -{ - UNICODE_STRING uname; - RtlCreateUnicodeStringFromAsciiz (&uname, name); - __ino64_t ret = hash_path_name (hash, &uname); - RtlFreeUnicodeString (&uname); - return ret; -} - -extern "C" char * -getcwd (char *buf, size_t ulen) -{ - char* res = NULL; - myfault efault; - if (efault.faulted (EFAULT)) - /* errno set */; - else if (ulen == 0 && buf) - set_errno (EINVAL); - else - res = cygheap->cwd.get (buf, 1, 1, ulen); - return res; -} - -/* getwd: Legacy. */ -extern "C" char * -getwd (char *buf) -{ - return getcwd (buf, PATH_MAX + 1); /*Per SuSv3!*/ -} - -/* chdir: POSIX 5.2.1.1 */ -extern "C" int -chdir (const char *in_dir) -{ - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - if (!*in_dir) - { - set_errno (ENOENT); - return -1; - } - - syscall_printf ("dir '%s'", in_dir); - - /* Convert path. First argument ensures that we don't check for NULL/empty/invalid - again. */ - path_conv path (PC_NONULLEMPTY, in_dir, PC_SYM_FOLLOW | PC_POSIX); - if (path.error) - { - set_errno (path.error); - syscall_printf ("-1 = chdir (%s)", in_dir); - return -1; - } - - int res = -1; - bool doit = false; - const char *posix_cwd = NULL; - int devn = path.get_devn (); - if (!path.exists ()) - set_errno (ENOENT); - else if (!path.isdir ()) - set_errno (ENOTDIR); - else if (!isvirtual_dev (devn)) - { - /* The sequence chdir("xx"); chdir(".."); must be a noop if xx - is not a symlink. This is exploited by find.exe. - The posix_cwd is just path.normalized_path. - In other cases we let cwd.set obtain the Posix path through - the mount table. */ - if (!isdrive(path.normalized_path)) - posix_cwd = path.normalized_path; - res = 0; - doit = true; - } - else - { - posix_cwd = path.normalized_path; - res = 0; - } - - if (!res) - res = cygheap->cwd.set (path.get_nt_native_path (), posix_cwd, doit); - - /* Note that we're accessing cwd.posix without a lock here. I didn't think - it was worth locking just for strace. */ - syscall_printf ("%d = chdir() cygheap->cwd.posix '%s' native '%S'", res, - cygheap->cwd.get_posix (), path.get_nt_native_path ()); - MALLOC_CHECK; - return res; -} - -extern "C" int -fchdir (int fd) -{ - int res; - cygheap_fdget cfd (fd); - if (cfd >= 0) - res = chdir (cfd->get_name ()); - else - res = -1; - - syscall_printf ("%d = fchdir (%d)", res, fd); - return res; -} - -/******************** Exported Path Routines *********************/ - -/* Cover functions to the path conversion routines. - These are exported to the world as cygwin_foo by cygwin.din. */ - -#define return_with_errno(x) \ - do {\ - int err = (x);\ - if (!err)\ - return 0;\ - set_errno (err);\ - return -1;\ - } while (0) - -extern "C" ssize_t -cygwin_conv_path (cygwin_conv_path_t what, const void *from, void *to, - size_t size) -{ - tmp_pathbuf tp; - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - path_conv p; - size_t lsiz = 0; - char *buf = NULL; - int error = 0; - bool relative = !!(what & CCP_RELATIVE); - what &= ~CCP_RELATIVE; - - switch (what) - { - case CCP_POSIX_TO_WIN_A: - { - p.check ((const char *) from, - PC_POSIX | PC_SYM_FOLLOW | PC_NO_ACCESS_CHECK | PC_NOWARN - | (relative ? PC_NOFULL : 0)); - if (p.error) - return_with_errno (p.error); - PUNICODE_STRING up = p.get_nt_native_path (); - buf = tp.c_get (); - sys_wcstombs (buf, NT_MAX_PATH, up->Buffer, up->Length / sizeof (WCHAR)); - /* Convert native path to standard DOS path. */ - if (!strncmp (buf, "\\??\\", 4)) - { - buf += 4; - if (buf[1] != ':') /* native UNC path */ - *(buf += 2) = '\\'; - } - lsiz = strlen (buf) + 1; - /* TODO: Incoming "." is a special case which leads to a trailing - backslash ".\\" in the Win32 path. That's a result of the - conversion in normalize_posix_path. This should not occur - so the below code is just a band-aid. */ - if (!strcmp ((const char *) from, ".") && relative - && !strcmp (buf, ".\\")) - { - --lsiz; - buf[lsiz - 1] = '\0'; - } - } - break; - case CCP_POSIX_TO_WIN_W: - p.check ((const char *) from, PC_POSIX | PC_SYM_FOLLOW - | PC_NO_ACCESS_CHECK | PC_NOWARN - | (relative ? PC_NOFULL : 0)); - if (p.error) - return_with_errno (p.error); - /* Relative Windows paths are always restricted to MAX_PATH chars. */ - if (relative && !isabspath (p.get_win32 ()) - && sys_mbstowcs (NULL, 0, p.get_win32 ()) > MAX_PATH) - { - /* Recreate as absolute path. */ - p.check ((const char *) from, PC_POSIX | PC_SYM_FOLLOW - | PC_NO_ACCESS_CHECK | PC_NOWARN); - if (p.error) - return_with_errno (p.error); - } - lsiz = p.get_wide_win32_path_len () + 1; - /* TODO: Same ".\\" band-aid as in CCP_POSIX_TO_WIN_A case. */ - if (!strcmp ((const char *) from, ".") && relative - && !wcscmp (p.get_nt_native_path ()->Buffer, L".\\")) - { - --lsiz; - p.get_nt_native_path ()->Length -= sizeof (WCHAR); - p.get_nt_native_path ()->Buffer[lsiz - 1] = L'\0'; - } - lsiz *= sizeof (WCHAR); - break; - case CCP_WIN_A_TO_POSIX: - buf = tp.c_get (); - error = mount_table->conv_to_posix_path ((const char *) from, buf, - relative); - if (error) - return_with_errno (error); - lsiz = strlen (buf) + 1; - break; - case CCP_WIN_W_TO_POSIX: - buf = tp.c_get (); - error = mount_table->conv_to_posix_path ((const PWCHAR) from, buf, - relative); - if (error) - return_with_errno (error); - lsiz = strlen (buf) + 1; - break; - default: - set_errno (EINVAL); - return -1; - } - if (!size) - return lsiz; - if (size < lsiz) - { - set_errno (ENOSPC); - return -1; - } - switch (what) - { - case CCP_POSIX_TO_WIN_A: - case CCP_WIN_A_TO_POSIX: - case CCP_WIN_W_TO_POSIX: - strcpy ((char *) to, buf); - break; - case CCP_POSIX_TO_WIN_W: - p.get_wide_win32_path ((PWCHAR) to); - break; - } - return 0; -} - -extern "C" void * -cygwin_create_path (cygwin_conv_path_t what, const void *from) -{ - void *to; - ssize_t size = cygwin_conv_path (what, from, NULL, 0); - if (size <= 0) - return NULL; - if (!(to = malloc (size))) - return NULL; - if (cygwin_conv_path (what, from, to, size) == -1) - return NULL; - return to; -} - - -extern "C" int -cygwin_conv_to_win32_path (const char *path, char *win32_path) -{ - return cygwin_conv_path (CCP_POSIX_TO_WIN_A | CCP_RELATIVE, path, win32_path, - MAX_PATH); -} - -extern "C" int -cygwin_conv_to_full_win32_path (const char *path, char *win32_path) -{ - return cygwin_conv_path (CCP_POSIX_TO_WIN_A | CCP_ABSOLUTE, path, win32_path, - MAX_PATH); -} - -/* This is exported to the world as cygwin_foo by cygwin.din. */ - -extern "C" int -cygwin_conv_to_posix_path (const char *path, char *posix_path) -{ - return cygwin_conv_path (CCP_WIN_A_TO_POSIX | CCP_RELATIVE, path, posix_path, - MAX_PATH); -} - -extern "C" int -cygwin_conv_to_full_posix_path (const char *path, char *posix_path) -{ - return cygwin_conv_path (CCP_WIN_A_TO_POSIX | CCP_ABSOLUTE, path, posix_path, - MAX_PATH); -} - -/* The realpath function is required by POSIX:2008. */ - -extern "C" char * -realpath (const char *path, char *resolved) -{ - /* Make sure the right errno is returned if path is NULL. */ - if (!path) - { - set_errno (EINVAL); - return NULL; - } - - /* Guard reading from a potentially invalid path and writing to a - potentially invalid resolved. */ - tmp_pathbuf tp; - myfault efault; - if (efault.faulted (EFAULT)) - return NULL; - - char *tpath; - if (isdrive (path)) - { - tpath = tp.c_get (); - mount_table->cygdrive_posix_path (path, tpath, 0); - } - else - tpath = (char *) path; - - path_conv real_path (tpath, PC_SYM_FOLLOW | PC_POSIX, stat_suffixes); - - - /* POSIX 2008 requires malloc'ing if resolved is NULL, and states - that using non-NULL resolved is asking for portability - problems. */ - - if (!real_path.error && real_path.exists ()) - { - if (!resolved) - { - resolved = (char *) malloc (strlen (real_path.normalized_path) + 1); - if (!resolved) - return NULL; - } - strcpy (resolved, real_path.normalized_path); - return resolved; - } - - /* FIXME: on error, Linux puts the name of the path - component which could not be resolved into RESOLVED, but POSIX - does not require this. */ - if (resolved) - resolved[0] = '\0'; - set_errno (real_path.error ?: ENOENT); - return NULL; -} - -/* Linux provides this extension. Since the only portable use of - realpath requires a NULL second argument, we might as well have a - one-argument wrapper. */ -extern "C" char * -canonicalize_file_name (const char *path) -{ - return realpath (path, NULL); -} - -/* Return non-zero if path is a POSIX path list. - This is exported to the world as cygwin_foo by cygwin.din. - -DOCTOOL-START - - Rather than use a mode to say what the "proper" path list - format is, we allow any, and give apps the tools they need to - convert between the two. If a ';' is present in the path list it's - a Win32 path list. Otherwise, if the first path begins with - [letter]: (in which case it can be the only element since if it - wasn't a ';' would be present) it's a Win32 path list. Otherwise, - it's a POSIX path list. - -DOCTOOL-END - */ - -extern "C" int -cygwin_posix_path_list_p (const char *path) -{ - int posix_p = !(strchr (path, ';') || isdrive (path)); - return posix_p; -} - -/* These are used for apps that need to convert env vars like PATH back and - forth. The conversion is a two step process. First, an upper bound on the - size of the buffer needed is computed. Then the conversion is done. This - allows the caller to use alloca if it wants. */ - -static int -conv_path_list_buf_size (const char *path_list, bool to_posix) -{ - int i, num_elms, max_mount_path_len, size; - const char *p; - - path_conv pc(".", PC_POSIX); - /* The theory is that an upper bound is - current_size + (num_elms * max_mount_path_len) */ - /* FIXME: This method is questionable in the long run. */ - - unsigned nrel; - char delim = to_posix ? ';' : ':'; - for (p = path_list, num_elms = nrel = 0; p; num_elms++) - { - if (!isabspath (p)) - nrel++; - p = strchr (++p, delim); - } - - /* 7: strlen ("//c") + slop, a conservative initial value */ - for (max_mount_path_len = sizeof ("/cygdrive/X"), i = 0; - i < mount_table->nmounts; i++) - { - int mount_len = (to_posix - ? mount_table->mount[i].posix_pathlen - : mount_table->mount[i].native_pathlen); - if (max_mount_path_len < mount_len) - max_mount_path_len = mount_len; - } - - /* 100: slop */ - size = strlen (path_list) - + (num_elms * max_mount_path_len) - + (nrel * strlen (to_posix ? pc.normalized_path : pc.get_win32 ())) - + 100; - - return size; -} - - -extern "C" int -cygwin_win32_to_posix_path_list_buf_size (const char *path_list) -{ - return conv_path_list_buf_size (path_list, true); -} - -extern "C" int -cygwin_posix_to_win32_path_list_buf_size (const char *path_list) -{ - return conv_path_list_buf_size (path_list, false); -} - -extern "C" ssize_t -env_PATH_to_posix (const void *win32, void *posix, size_t size) -{ - return_with_errno (conv_path_list ((const char *) win32, (char *) posix, - size, ENV_CVT)); -} - -extern "C" int -cygwin_win32_to_posix_path_list (const char *win32, char *posix) -{ - return_with_errno (conv_path_list (win32, posix, MAX_PATH, 1)); -} - -extern "C" int -cygwin_posix_to_win32_path_list (const char *posix, char *win32) -{ - return_with_errno (conv_path_list (posix, win32, MAX_PATH, 0)); -} - -extern "C" ssize_t -cygwin_conv_path_list (cygwin_conv_path_t what, const void *from, void *to, - size_t size) -{ - /* FIXME: Path lists are (so far) always retaining relative paths. */ - what &= ~CCP_RELATIVE; - switch (what) - { - case CCP_WIN_W_TO_POSIX: - case CCP_POSIX_TO_WIN_W: - /*FIXME*/ - api_fatal ("wide char path lists not yet supported"); - break; - case CCP_WIN_A_TO_POSIX: - case CCP_POSIX_TO_WIN_A: - if (size == 0) - return conv_path_list_buf_size ((const char *) from, - what == CCP_WIN_A_TO_POSIX); - return_with_errno (conv_path_list ((const char *) from, (char *) to, - size, what == CCP_WIN_A_TO_POSIX)); - break; - default: - break; - } - set_errno (EINVAL); - return -1; -} - -/* cygwin_split_path: Split a path into directory and file name parts. - Buffers DIR and FILE are assumed to be big enough. - - Examples (path -> `dir' / `file'): - / -> `/' / `' - "" -> `.' / `' - . -> `.' / `.' (FIXME: should this be `.' / `'?) - .. -> `.' / `..' (FIXME: should this be `..' / `'?) - foo -> `.' / `foo' - foo/bar -> `foo' / `bar' - foo/bar/ -> `foo' / `bar' - /foo -> `/' / `foo' - /foo/bar -> `/foo' / `bar' - c: -> `c:/' / `' - c:/ -> `c:/' / `' - c:foo -> `c:/' / `foo' - c:/foo -> `c:/' / `foo' - */ - -extern "C" void -cygwin_split_path (const char *path, char *dir, char *file) -{ - int dir_started_p = 0; - - /* Deal with drives. - Remember that c:foo <==> c:/foo. */ - if (isdrive (path)) - { - *dir++ = *path++; - *dir++ = *path++; - *dir++ = '/'; - if (!*path) - { - *dir = 0; - *file = 0; - return; - } - if (isdirsep (*path)) - ++path; - dir_started_p = 1; - } - - /* Determine if there are trailing slashes and "delete" them if present. - We pretend as if they don't exist. */ - const char *end = path + strlen (path); - /* path + 1: keep leading slash. */ - while (end > path + 1 && isdirsep (end[-1])) - --end; - - /* At this point, END points to one beyond the last character - (with trailing slashes "deleted"). */ - - /* Point LAST_SLASH at the last slash (duh...). */ - const char *last_slash; - for (last_slash = end - 1; last_slash >= path; --last_slash) - if (isdirsep (*last_slash)) - break; - - if (last_slash == path) - { - *dir++ = '/'; - *dir = 0; - } - else if (last_slash > path) - { - memcpy (dir, path, last_slash - path); - dir[last_slash - path] = 0; - } - else - { - if (dir_started_p) - ; /* nothing to do */ - else - *dir++ = '.'; - *dir = 0; - } - - memcpy (file, last_slash + 1, end - last_slash - 1); - file[end - last_slash - 1] = 0; -} - -/*****************************************************************************/ - -static inline PRTL_USER_PROCESS_PARAMETERS -get_user_proc_parms () -{ - return NtCurrentTeb ()->Peb->ProcessParameters; -} - -/* Initialize cygcwd 'muto' for serializing access to cwd info. */ -void -cwdstuff::init () -{ - cwd_lock.init ("cwd_lock"); - /* Initially re-open the cwd to allow POSIX semantics. */ - set (NULL, NULL, true); -} - -/* Chdir and fill out the elements of a cwdstuff struct. */ -int -cwdstuff::set (PUNICODE_STRING nat_cwd, const char *posix_cwd, bool doit) -{ - int res = 0; - UNICODE_STRING upath; - size_t len = 0; - - cwd_lock.acquire (); - - if (nat_cwd) - { - upath = *nat_cwd; - if (upath.Buffer[0] == L'/') /* Virtual path. Never use in PEB. */ - doit = false; - else - { - len = upath.Length / sizeof (WCHAR) - 4; - if (RtlEqualUnicodePathPrefix (&upath, &ro_u_uncp, TRUE)) - len -= 2; - } - } - - if (doit) - { - /* We utilize the user parameter block. The directory is - stored manually there. Why the hassle? - - - SetCurrentDirectory fails for directories with strict - permissions even for processes with the SE_BACKUP_NAME - privilege enabled. The reason is apparently that - SetCurrentDirectory calls NtOpenFile without the - FILE_OPEN_FOR_BACKUP_INTENT flag set. - - - Unlinking a cwd fails because SetCurrentDirectory seems to - open directories so that deleting the directory is disallowed. - The below code opens with *all* sharing flags set. */ - HANDLE h; - NTSTATUS status; - IO_STATUS_BLOCK io; - OBJECT_ATTRIBUTES attr; - PHANDLE phdl; - - RtlAcquirePebLock (); - phdl = &get_user_proc_parms ()->CurrentDirectoryHandle; - if (!nat_cwd) /* On init, just reopen CWD with desired access flags. */ - RtlInitUnicodeString (&upath, L""); - /* This is for Win32 apps only. No case sensitivity here... */ - InitializeObjectAttributes (&attr, &upath, - OBJ_CASE_INSENSITIVE | OBJ_INHERIT, - nat_cwd ? NULL : *phdl, NULL); - status = NtOpenFile (&h, SYNCHRONIZE | FILE_TRAVERSE, &attr, &io, - FILE_SHARE_VALID_FLAGS, - FILE_DIRECTORY_FILE - | FILE_SYNCHRONOUS_IO_NONALERT - | FILE_OPEN_FOR_BACKUP_INTENT); - if (!NT_SUCCESS (status)) - { - RtlReleasePebLock (); - __seterrno_from_nt_status (status); - res = -1; - goto out; - } - /* Workaround a problem in Vista/Longhorn which fails in subsequent - calls to CreateFile with ERROR_INVALID_HANDLE if the handle in - CurrentDirectoryHandle changes without calling SetCurrentDirectory, - and the filename given to CreateFile is a relative path. It looks - like Vista stores a copy of the CWD handle in some other undocumented - place. The NtClose/DuplicateHandle reuses the original handle for - the copy of the new handle and the next CreateFile works. - Note that this is not thread-safe (yet?) */ - NtClose (*phdl); - if (DuplicateHandle (GetCurrentProcess (), h, GetCurrentProcess (), phdl, - 0, TRUE, DUPLICATE_SAME_ACCESS)) - NtClose (h); - else - *phdl = h; - dir = *phdl; - - /* No need to set path on init. */ - if (nat_cwd - /* TODO: - Check the length of the new CWD. Windows can only handle - CWDs of up to MAX_PATH length, including a trailing backslash. - If the path is longer, it's not an error condition for Cygwin, - so we don't fail. Windows on the other hand has a problem now. - For now, we just don't store the path in the PEB and proceed as - usual. */ - && len <= MAX_PATH - (nat_cwd->Buffer[len - 1] == L'\\' ? 1 : 2)) - { - /* Convert to a Win32 path. */ - upath.Buffer += upath.Length / sizeof (WCHAR) - len; - if (upath.Buffer[1] == L'\\') /* UNC path */ - upath.Buffer[0] = L'\\'; - upath.Length = len * sizeof (WCHAR); - /* Append backslash if necessary. */ - if (upath.Buffer[len - 1] != L'\\') - { - upath.Buffer[len] = L'\\'; - upath.Length += sizeof (WCHAR); - } - RtlCopyUnicodeString (&get_user_proc_parms ()->CurrentDirectoryName, - &upath); - } - - RtlReleasePebLock (); - } - - if (nat_cwd || !win32.Buffer) - { - /* If there is no win32 path */ - if (!nat_cwd) - { - PUNICODE_STRING pdir; - - RtlAcquirePebLock (); - pdir = &get_user_proc_parms ()->CurrentDirectoryName; - RtlInitEmptyUnicodeString (&win32, - (PWCHAR) crealloc_abort (win32.Buffer, - pdir->Length + 2), - pdir->Length + 2); - RtlCopyUnicodeString (&win32, pdir); - RtlReleasePebLock (); - - PWSTR eoBuffer = win32.Buffer + (win32.Length / sizeof (WCHAR)); - /* Remove trailing slash if one exists. FIXME: Is there a better way to - do this? */ - if ((eoBuffer - win32.Buffer) > 3 && eoBuffer[-1] == L'\\') - win32.Length -= sizeof (WCHAR); - - posix_cwd = NULL; - } - else - { - bool unc = false; - - if (upath.Buffer[0] == L'/') /* Virtual path, don't mangle. */ - ; - else if (!doit) - { - /* Convert to a Win32 path. */ - upath.Buffer += upath.Length / sizeof (WCHAR) - len; - if (upath.Buffer[1] == L'\\') /* UNC path */ - unc = true; - upath.Length = len * sizeof (WCHAR); - } - else - { - PWSTR eoBuffer = upath.Buffer + (upath.Length / sizeof (WCHAR)); - /* Remove trailing slash if one exists. FIXME: Is there a better way to - do this? */ - if ((eoBuffer - upath.Buffer) > 3 && eoBuffer[-1] == L'\\') - upath.Length -= sizeof (WCHAR); - } - RtlInitEmptyUnicodeString (&win32, - (PWCHAR) crealloc_abort (win32.Buffer, - upath.Length + 2), - upath.Length + 2); - RtlCopyUnicodeString (&win32, &upath); - if (unc) - win32.Buffer[0] = L'\\'; - } - /* Make sure it's NUL-terminated. */ - win32.Buffer[win32.Length / sizeof (WCHAR)] = L'\0'; - if (!doit) /* Virtual path */ - drive_length = 0; - else if (win32.Buffer[1] == L':') /* X: */ - drive_length = 2; - else if (win32.Buffer[1] == L'\\') /* UNC path */ - { - PWCHAR ptr = wcschr (win32.Buffer + 2, L'\\'); - if (ptr) - ptr = wcschr (ptr + 1, L'\\'); - if (ptr) - drive_length = ptr - win32.Buffer; - else - drive_length = win32.Length / sizeof (WCHAR); - } - else /* Shouldn't happen */ - drive_length = 0; - - tmp_pathbuf tp; - if (!posix_cwd) - { - posix_cwd = (const char *) tp.c_get (); - mount_table->conv_to_posix_path (win32.Buffer, (char *) posix_cwd, 0); - } - posix = (char *) crealloc_abort (posix, strlen (posix_cwd) + 1); - stpcpy (posix, posix_cwd); - } - -out: - cwd_lock.release (); - return res; -} - -/* Store incoming wchar_t path as current posix cwd. This is called from - setlocale so that the cwd is always stored in the right charset. */ -void -cwdstuff::reset_posix (wchar_t *w_cwd) -{ - size_t len = sys_wcstombs (NULL, (size_t) -1, w_cwd); - posix = (char *) crealloc_abort (posix, len + 1); - sys_wcstombs (posix, len + 1, w_cwd); -} - -char * -cwdstuff::get (char *buf, int need_posix, int with_chroot, unsigned ulen) -{ - MALLOC_CHECK; - - tmp_pathbuf tp; - if (ulen) - /* nothing */; - else if (buf == NULL) - ulen = (unsigned) -1; - else - { - set_errno (EINVAL); - goto out; - } - - cwd_lock.acquire (); - - char *tocopy; - if (!need_posix) - { - tocopy = tp.c_get (); - sys_wcstombs (tocopy, NT_MAX_PATH, win32.Buffer, - win32.Length / sizeof (WCHAR)); - } - else - tocopy = posix; - - debug_printf ("posix %s", posix); - if (strlen (tocopy) >= ulen) - { - set_errno (ERANGE); - buf = NULL; - } - else - { - if (!buf) - buf = (char *) malloc (strlen (tocopy) + 1); - strcpy (buf, tocopy); - if (!buf[0]) /* Should only happen when chroot */ - strcpy (buf, "/"); - } - - cwd_lock.release (); - -out: - syscall_printf ("(%s) = cwdstuff::get (%p, %d, %d, %d), errno %d", - buf, buf, ulen, need_posix, with_chroot, errno); - MALLOC_CHECK; - return buf; -} - -int etc::curr_ix = 0; -/* Note that the first elements of the below arrays are unused */ -bool etc::change_possible[MAX_ETC_FILES + 1]; -OBJECT_ATTRIBUTES etc::fn[MAX_ETC_FILES + 1]; -LARGE_INTEGER etc::last_modified[MAX_ETC_FILES + 1]; - -int -etc::init (int n, POBJECT_ATTRIBUTES attr) -{ - if (n > 0) - /* ok */; - else if (++curr_ix <= MAX_ETC_FILES) - n = curr_ix; - else - api_fatal ("internal error"); - - fn[n] = *attr; - change_possible[n] = false; - test_file_change (n); - paranoid_printf ("fn[%d] %S, curr_ix %d", n, fn[n].ObjectName, curr_ix); - return n; -} - -bool -etc::test_file_change (int n) -{ - NTSTATUS status; - FILE_NETWORK_OPEN_INFORMATION fnoi; - bool res; - - status = NtQueryFullAttributesFile (&fn[n], &fnoi); - if (!NT_SUCCESS (status)) - { - res = true; - memset (last_modified + n, 0, sizeof (last_modified[n])); - debug_printf ("NtQueryFullAttributesFile (%S) failed, %p", - fn[n].ObjectName, status); - } - else - { - res = CompareFileTime ((FILETIME *) &fnoi.LastWriteTime, - (FILETIME *) last_modified + n) > 0; - last_modified[n].QuadPart = fnoi.LastWriteTime.QuadPart; - } - - paranoid_printf ("fn[%d] %S res %d", n, fn[n].ObjectName, res); - return res; -} - -bool -etc::dir_changed (int n) -{ - if (!change_possible[n]) - { - static HANDLE changed_h NO_COPY; - NTSTATUS status; - IO_STATUS_BLOCK io; - - if (!changed_h) - { - OBJECT_ATTRIBUTES attr; - - path_conv dir ("/etc"); - status = NtOpenFile (&changed_h, SYNCHRONIZE | FILE_LIST_DIRECTORY, - dir.get_object_attr (attr, sec_none_nih), &io, - FILE_SHARE_VALID_FLAGS, FILE_DIRECTORY_FILE); - if (!NT_SUCCESS (status)) - { -#ifdef DEBUGGING - system_printf ("NtOpenFile (%S) failed, %p", - dir.get_nt_native_path (), status); -#endif - changed_h = INVALID_HANDLE_VALUE; - } - else - { - status = NtNotifyChangeDirectoryFile (changed_h, NULL, NULL, - NULL, &io, NULL, 0, - FILE_NOTIFY_CHANGE_LAST_WRITE - | FILE_NOTIFY_CHANGE_FILE_NAME, - FALSE); - if (!NT_SUCCESS (status)) - { -#ifdef DEBUGGING - system_printf ("NtNotifyChangeDirectoryFile (1) failed, %p", - status); -#endif - NtClose (changed_h); - changed_h = INVALID_HANDLE_VALUE; - } - } - memset (change_possible, true, sizeof (change_possible)); - } - - if (changed_h == INVALID_HANDLE_VALUE) - change_possible[n] = true; - else if (WaitForSingleObject (changed_h, 0) == WAIT_OBJECT_0) - { - status = NtNotifyChangeDirectoryFile (changed_h, NULL, NULL, - NULL, &io, NULL, 0, - FILE_NOTIFY_CHANGE_LAST_WRITE - | FILE_NOTIFY_CHANGE_FILE_NAME, - FALSE); - if (!NT_SUCCESS (status)) - { -#ifdef DEBUGGING - system_printf ("NtNotifyChangeDirectoryFile (2) failed, %p", - status); -#endif - NtClose (changed_h); - changed_h = INVALID_HANDLE_VALUE; - } - memset (change_possible, true, sizeof change_possible); - } - } - - paranoid_printf ("fn[%d] %S change_possible %d", - n, fn[n].ObjectName, change_possible[n]); - return change_possible[n]; -} - -bool -etc::file_changed (int n) -{ - bool res = false; - if (dir_changed (n) && test_file_change (n)) - res = true; - change_possible[n] = false; /* Change is no longer possible */ - paranoid_printf ("fn[%d] %S res %d", n, fn[n].ObjectName, res); - return res; -} - -/* No need to be reentrant or thread-safe according to SUSv3. - / and \\ are treated equally. Leading drive specifiers are - kept intact as far as it makes sense. Everything else is - POSIX compatible. */ -extern "C" char * -basename (char *path) -{ - static char buf[4]; - char *c, *d, *bs = path; - - if (!path || !*path) - return strcpy (buf, "."); - if (isalpha (path[0]) && path[1] == ':') - bs += 2; - else if (strspn (path, "/\\") > 1) - ++bs; - c = strrchr (bs, '/'); - if ((d = strrchr (c ?: bs, '\\')) > c) - c = d; - if (c) - { - /* Trailing (back)slashes are eliminated. */ - while (c && c > bs && c[1] == '\0') - { - *c = '\0'; - c = strrchr (bs, '/'); - if ((d = strrchr (c ?: bs, '\\')) > c) - c = d; - } - if (c && (c > bs || c[1])) - return c + 1; - } - else if (!bs[0]) - { - stpncpy (buf, path, bs - path); - stpcpy (buf + (bs - path), "."); - return buf; - } - return path; -} - -/* No need to be reentrant or thread-safe according to SUSv3. - / and \\ are treated equally. Leading drive specifiers and - leading double (back)slashes are kept intact as far as it - makes sense. Everything else is POSIX compatible. */ -extern "C" char * -dirname (char *path) -{ - static char buf[4]; - char *c, *d, *bs = path; - - if (!path || !*path) - return strcpy (buf, "."); - if (isalpha (path[0]) && path[1] == ':') - bs += 2; - else if (strspn (path, "/\\") > 1) - ++bs; - c = strrchr (bs, '/'); - if ((d = strrchr (c ?: bs, '\\')) > c) - c = d; - if (c) - { - /* Trailing (back)slashes are eliminated. */ - while (c && c > bs && c[1] == '\0') - { - *c = '\0'; - c = strrchr (bs, '/'); - if ((d = strrchr (c ?: bs, '\\')) > c) - c = d; - } - if (!c) - strcpy (bs, "."); - else if (c > bs) - { - /* More trailing (back)slashes are eliminated. */ - while (c > bs && (*c == '/' || *c == '\\')) - *c-- = '\0'; - } - else - c[1] = '\0'; - } - else - { - stpncpy (buf, path, bs - path); - stpcpy (buf + (bs - path), "."); - return buf; - } - return path; -} diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h deleted file mode 100644 index 2f583e9e7..000000000 --- a/winsup/cygwin/path.h +++ /dev/null @@ -1,323 +0,0 @@ -/* path.h: path data structures - - Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "devices.h" -#include "mount.h" -#include "cygheap_malloc.h" - -#include -#include - -#define isproc_dev(devn) \ - (devn == FH_PROC || devn == FH_REGISTRY || devn == FH_PROCESS || \ - devn == FH_PROCNET) - -#define isvirtual_dev(devn) \ - (isproc_dev (devn) || devn == FH_CYGDRIVE || devn == FH_NETDRIVE) - -inline bool -has_attribute (DWORD attributes, DWORD attribs_to_test) -{ - return attributes != INVALID_FILE_ATTRIBUTES - && (attributes & attribs_to_test); -} - -enum executable_states -{ - is_executable, - dont_care_if_executable, - not_executable = dont_care_if_executable, - dont_know_if_executable -}; - -struct suffix_info -{ - const char *name; - int addon; - suffix_info (const char *s, int addit = 0): name (s), addon (addit) {} -}; - -extern suffix_info stat_suffixes[]; - -enum pathconv_arg -{ - PC_SYM_FOLLOW = 0x0001, - PC_SYM_NOFOLLOW = 0x0002, - PC_SYM_CONTENTS = 0x0008, - PC_NOFULL = 0x0010, - PC_NULLEMPTY = 0x0020, - PC_CHECK_EA = 0x0040, - PC_POSIX = 0x0080, - PC_NOWARN = 0x0100, - PC_NO_ACCESS_CHECK = 0x00800000 -}; - -#define PC_NONULLEMPTY -1 - -#include "sys/mount.h" - -enum path_types -{ - PATH_NOTHING = 0, - PATH_SYMLINK = MOUNT_SYMLINK, - PATH_BINARY = MOUNT_BINARY, - PATH_EXEC = MOUNT_EXEC, - PATH_NOTEXEC = MOUNT_NOTEXEC, - PATH_CYGWIN_EXEC = MOUNT_CYGWIN_EXEC, - PATH_RO = MOUNT_RO, - PATH_NOACL = MOUNT_NOACL, - PATH_NOPOSIX = MOUNT_NOPOSIX, - PATH_ALL_EXEC = (PATH_CYGWIN_EXEC | PATH_EXEC), - PATH_NO_ACCESS_CHECK = PC_NO_ACCESS_CHECK, - PATH_LNK = 0x01000000, - PATH_TEXT = 0x02000000, - PATH_REP = 0x04000000, - PATH_HAS_SYMLINKS = 0x10000000, - PATH_SOCKET = 0x40000000 -}; - -class symlink_info; - -class path_conv -{ - DWORD fileattr; - ULONG caseinsensitive; - fs_info fs; - PWCHAR wide_path; - UNICODE_STRING uni_path; - void add_ext_from_sym (symlink_info&); - DWORD symlink_length; - const char *path; - public: - unsigned path_flags; - const char *known_suffix; - const char *normalized_path; - int error; - device dev; - - bool isremote () const {return fs.is_remote_drive ();} - ULONG objcaseinsensitive () const {return caseinsensitive;} - bool has_acls () const {return !(path_flags & PATH_NOACL) && fs.has_acls (); } - bool hasgood_inode () const {return fs.hasgood_inode (); } - bool isgood_inode (__ino64_t ino) const; - int has_symlinks () const {return path_flags & PATH_HAS_SYMLINKS;} - int has_buggy_open () const {return fs.has_buggy_open ();} - int has_buggy_fileid_dirinfo () const {return fs.has_buggy_fileid_dirinfo ();} - int has_buggy_basic_info () const {return fs.has_buggy_basic_info ();} - int binmode () const - { - if (path_flags & PATH_BINARY) - return O_BINARY; - if (path_flags & PATH_TEXT) - return O_TEXT; - return 0; - } - int issymlink () const {return path_flags & PATH_SYMLINK;} - int is_lnk_symlink () const {return path_flags & PATH_LNK;} - int is_rep_symlink () const {return path_flags & PATH_REP;} - int isdevice () const {return dev.devn && dev.devn != FH_FS && dev.devn != FH_FIFO;} - int isfifo () const {return dev == FH_FIFO;} - int isspecial () const {return dev.devn && dev.devn != FH_FS;} - int iscygdrive () const {return dev.devn == FH_CYGDRIVE;} - int is_auto_device () const {return isdevice () && !is_fs_special ();} - int is_fs_device () const {return isdevice () && is_fs_special ();} - int is_fs_special () const {return dev.is_fs_special ();} - int is_lnk_special () const {return is_fs_device () || isfifo () || is_lnk_symlink ();} - int issocket () const {return dev.devn == FH_UNIX;} - int iscygexec () const {return path_flags & PATH_CYGWIN_EXEC;} - void set_cygexec (bool isset) - { - if (isset) - path_flags |= PATH_CYGWIN_EXEC; - else - path_flags &= ~PATH_CYGWIN_EXEC; - } - bool isro () const {return !!(path_flags & PATH_RO);} - bool exists () const {return fileattr != INVALID_FILE_ATTRIBUTES;} - bool has_attribute (DWORD x) const {return exists () && (fileattr & x);} - int isdir () const {return has_attribute (FILE_ATTRIBUTE_DIRECTORY);} - executable_states exec_state () - { - extern int _check_for_executable; - if (path_flags & PATH_ALL_EXEC) - return is_executable; - if (path_flags & PATH_NOTEXEC) - return not_executable; - if (!_check_for_executable) - return dont_care_if_executable; - return dont_know_if_executable; - } - - void set_symlink (DWORD n) {path_flags |= PATH_SYMLINK; symlink_length = n;} - void set_has_symlinks () {path_flags |= PATH_HAS_SYMLINKS;} - void set_exec (int x = 1) {path_flags |= x ? PATH_EXEC : PATH_NOTEXEC;} - - void check (const UNICODE_STRING *upath, unsigned opt = PC_SYM_FOLLOW, - const suffix_info *suffixes = NULL) __attribute__ ((regparm(3))); - void check (const char *src, unsigned opt = PC_SYM_FOLLOW, - const suffix_info *suffixes = NULL) __attribute__ ((regparm(3))); - - path_conv (const device& in_dev) - : fileattr (INVALID_FILE_ATTRIBUTES), wide_path (NULL), path (NULL), - path_flags (0), known_suffix (NULL), normalized_path (NULL), error (0), - dev (in_dev) - { - set_path (in_dev.native); - } - - path_conv (int, const char *src, unsigned opt = PC_SYM_FOLLOW, - const suffix_info *suffixes = NULL) - : wide_path (NULL), path (NULL), normalized_path (NULL) - { - check (src, opt, suffixes); - } - - path_conv (const UNICODE_STRING *src, unsigned opt = PC_SYM_FOLLOW, - const suffix_info *suffixes = NULL) - : wide_path (NULL), path (NULL), normalized_path (NULL) - { - check (src, opt | PC_NULLEMPTY, suffixes); - } - - path_conv (const char *src, unsigned opt = PC_SYM_FOLLOW, - const suffix_info *suffixes = NULL) - : wide_path (NULL), path (NULL), normalized_path (NULL) - { - check (src, opt | PC_NULLEMPTY, suffixes); - } - - path_conv () - : fileattr (INVALID_FILE_ATTRIBUTES), wide_path (NULL), path (NULL), - path_flags (0), known_suffix (NULL), normalized_path (NULL), error (0) - {} - - ~path_conv (); - inline const char *get_win32 () { return path; } - PUNICODE_STRING get_nt_native_path (); - POBJECT_ATTRIBUTES get_object_attr (OBJECT_ATTRIBUTES &attr, - SECURITY_ATTRIBUTES &sa); - inline size_t get_wide_win32_path_len () - { - get_nt_native_path (); - return uni_path.Length / sizeof (WCHAR); - } - - PWCHAR get_wide_win32_path (PWCHAR wc); - operator DWORD &() {return fileattr;} - operator int () {return fileattr; } - path_conv &operator =(path_conv& pc) - { - memcpy (this, &pc, sizeof pc); - path = cstrdup (pc.path); - set_normalized_path (pc.normalized_path); - wide_path = NULL; - return *this; - } - DWORD get_devn () const {return dev.devn;} - short get_unitn () const {return dev.minor;} - DWORD file_attributes () const {return fileattr;} - void file_attributes (DWORD new_attr) {fileattr = new_attr;} - DWORD fs_flags () {return fs.flags ();} - DWORD fs_name_len () {return fs.name_len ();} - bool fs_is_fat () const {return fs.is_fat ();} - bool fs_is_ntfs () const {return fs.is_ntfs ();} - bool fs_is_samba () const {return fs.is_samba ();} - bool fs_is_nfs () const {return fs.is_nfs ();} - bool fs_is_netapp () const {return fs.is_netapp ();} - bool fs_is_cdrom () const {return fs.is_cdrom ();} - bool fs_is_mvfs () const {return fs.is_mvfs ();} - bool fs_is_cifs () const {return fs.is_cifs ();} - bool fs_is_nwfs () const {return fs.is_nwfs ();} - ULONG fs_serial_number () const {return fs.serial_number ();} - inline const char *set_path (const char *p) - { - if (path) - cfree (modifiable_path ()); - char *new_path = (char *) cmalloc_abort (HEAP_STR, strlen (p) + 7); - strcpy (new_path, p); - return path = new_path; - } - bool is_binary (); - - unsigned __stdcall ndisk_links (DWORD); - void set_normalized_path (const char *) __attribute__ ((regparm (2))); - DWORD get_symlink_length () { return symlink_length; }; - private: - char *modifiable_path () {return (char *) path;} -}; - -/* Symlink marker */ -#define SYMLINK_COOKIE "!" - -/* Socket marker */ -#define SOCKET_COOKIE "!" - -/* Interix symlink marker */ -#define INTERIX_SYMLINK_COOKIE "IntxLNK\1" - -int __stdcall slash_unc_prefix_p (const char *path) __attribute__ ((regparm(1))); - -enum fe_types -{ - FE_NADA = 0, /* Nothing special */ - FE_NNF = 1, /* Return NULL if not found */ - FE_NATIVE = 2, /* Return native path in path_conv struct */ - FE_CWD = 4, /* Search CWD for program */ - FE_DLL = 8 /* Search for DLLs, not executables. */ -}; -const char *__stdcall find_exec (const char *name, path_conv& buf, - const char *winenv = "PATH=", - unsigned opt = FE_NADA, - const char **known_suffix = NULL) - __attribute__ ((regparm(3))); - -/* Common macros for checking for invalid path names */ -#define isdrive(s) (isalpha (*(s)) && (s)[1] == ':') -#define iswdrive(s) (iswalpha (*(s)) && (s)[1] == L':') - -static inline bool -has_exec_chars (const char *buf, int len) -{ - return len >= 2 && - ((buf[0] == '#' && buf[1] == '!') || - (buf[0] == ':' && buf[1] == '\n') || - (buf[0] == 'M' && buf[1] == 'Z')); -} - -int pathmatch (const char *path1, const char *path2, bool caseinsensitive) __attribute__ ((regparm (3))); -int pathnmatch (const char *path1, const char *path2, int len, bool caseinsensitive) __attribute__ ((regparm (3))); -bool has_dot_last_component (const char *dir, bool test_dot_dot) __attribute__ ((regparm (2))); - -int path_prefix_p (const char *path1, const char *path2, int len1, - bool caseinsensitive) __attribute__ ((regparm (3))); - -bool is_floppy (const char *); -int normalize_win32_path (const char *, char *, char *&); -int normalize_posix_path (const char *, char *, char *&); -PUNICODE_STRING get_nt_native_path (const char *, UNICODE_STRING&); - -/* FIXME: Move to own include file eventually */ - -#define MAX_ETC_FILES 2 -class etc -{ - friend class dtable; - static int curr_ix; - static HANDLE changed_h; - static bool change_possible[MAX_ETC_FILES + 1]; - static OBJECT_ATTRIBUTES fn[MAX_ETC_FILES + 1]; - static LARGE_INTEGER last_modified[MAX_ETC_FILES + 1]; - static bool dir_changed (int); - static int init (int, POBJECT_ATTRIBUTES); - static bool file_changed (int); - static bool test_file_change (int); - friend class pwdgrp; -}; diff --git a/winsup/cygwin/path.sgml b/winsup/cygwin/path.sgml deleted file mode 100644 index 26c3ea34e..000000000 --- a/winsup/cygwin/path.sgml +++ /dev/null @@ -1,178 +0,0 @@ - -cygwin_conv_path - - -extern "C" ssize_t -cygwin_conv_path -cygwin_conv_path_t what -const void * from -void * to -size_t size - - -Use this function to convert POSIX paths in -from to Win32 paths in to -or, vice versa, Win32 paths in from to POSIX paths -in to. what -defines the direction of this conversion and can be any of the below -values. - - - CCP_POSIX_TO_WIN_A /* from is char *posix, to is char *win32 */ - CCP_POSIX_TO_WIN_W, /* from is char *posix, to is wchar_t *win32 */ - CCP_WIN_A_TO_POSIX, /* from is char *win32, to is char *posix */ - CCP_WIN_W_TO_POSIX, /* from is wchar_t *win32, to is char *posix */ - - -You can additionally or the following values to -what, to define whether you want the resulting -path in to to be absolute or if you want to keep -relative paths in relative notation. Creating absolute paths is the -default. - - - CCP_ABSOLUTE = 0, /* Request absolute path (default). */ - CCP_RELATIVE = 0x100 /* Request to keep path relative. */ - - -size is the size of the buffer pointed to -by to in bytes. If size -is 0, cygwin_conv_path just returns the required -buffer size in bytes. Otherwise, it returns 0 on success, or -1 on -error and errno is set to one of the below values. - - - EINVAL what has an invalid value. - EFAULT from or to point into nirvana. - ENAMETOOLONG the resulting path is longer than 32K, or, in case - of what == CCP_POSIX_TO_WIN_A, longer than MAX_PATH. - ENOSPC size is less than required for the conversion. - - - -Example use of cygwin_conv_path - - - -/* Conversion from incoming Win32 path given as wchar_t *win32 to POSIX path. - If incoming path is a relative path, stick to it. First ask how big - the output buffer has to be and allocate space dynamically. */ -ssize_t size; -char *posix; -size = cygwin_conv_path (CCP_WIN_W_TO_POSIX | CCP_RELATIVE, win32, NULL, 0); -if (size < 0) - perror ("cygwin_conv_path"); -else - { - posix = (char *) malloc (size); - if (cygwin_conv_path (CCP_WIN_W_TO_POSIX | CCP_RELATIVE, win32, - posix, size)) - perror ("cygwin_conv_path"); - } -]]> - - - - - - -cygwin_conv_path_list - - -extern "C" ssize_t -cygwin_conv_path_list -cygwin_conv_path_t what -const void * from -void * to -size_t size - - -This is the same as cygwin_conv_path, but the -input is treated as a path list in $PATH or %PATH% notation. -If what is CCP_POSIX_TO_WIN_A or -CCP_POSIX_TO_WIN_W, given a POSIX $PATH-style string (i.e. /foo:/bar) -convert it to the equivalent Win32 %PATH%-style string (i.e. d:\;e:\bar). -If what is CCP_WIN_A_TO_POSIX or -CCP_WIN_W_TO_POSIX, given a Win32 %PATH%-style string (i.e. d:\;e:\bar) -convert it to the equivalent POSIX $PATH-style string (i.e. /foo:/bar). -size is the size of the buffer pointed to by -to in bytes. - -See also cygwin_conv_path - - - - -cygwin_create_path - - -extern "C" void * -cygwin_create_path -cygwin_conv_path_t what -const void * from - - -This is equivalent to the cygwin_conv_path, except -that cygwin_create_path does not take a buffer pointer -for the result of the conversion as input. Rather it allocates the buffer -itself using malloc(3) and returns a pointer to this -buffer. In case of error it returns NULL and sets errno to one of the -values defined for cygwin_conv_path. Additionally -errno can be set to the below value. - - - ENOMEM Insufficient memory was available. - - -When you don't need the returned buffer anymore, use -free(3) to deallocate it. - -See also cygwin_conv_path - - - - -cygwin_posix_path_list_p - - -extern "C" int -cygwin_posix_path_list_p -const char *path - - -This function tells you if the supplied -path is a POSIX-style path (i.e. posix names, -forward slashes, colon delimiters) or a Win32-style path (drive -letters, reverse slashes, semicolon delimiters. The return value is -true if the path is a POSIX path. Note that "_p" means "predicate", a -lisp term meaning that the function tells you something about the -parameter. - - - - -cygwin_split_path - - -extern "C" void -cygwin_split_path - -const char * path -char * dir -char * file - - -Split a path into the directory and the file portions. Both -dir and file are -expected to point to buffers of sufficient size. - - -Example use of cygwin_split_path - -char dir[200], file[100]; -cygwin_split_path("c:/foo/bar.c", dir, file); -printf("dir=%s, file=%s\n", dir, file); - - - diff --git a/winsup/cygwin/perprocess.h b/winsup/cygwin/perprocess.h deleted file mode 100644 index c0a555983..000000000 --- a/winsup/cygwin/perprocess.h +++ /dev/null @@ -1,28 +0,0 @@ -/* per_process.h: main Cygwin header file. - - Copyright 2000, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Pointer into application's static data */ -extern struct per_process __cygwin_user_data; -#define user_data (&__cygwin_user_data) - -/* We use the following to test that sizeof hasn't changed. When adding - or deleting members, insert fillers or use the reserved entries. - Do not change this value. */ -#define SIZEOF_PER_PROCESS (42 * 4) - -#ifdef __cplusplus -} -#endif diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc deleted file mode 100644 index f772b42a8..000000000 --- a/winsup/cygwin/pinfo.cc +++ /dev/null @@ -1,1281 +0,0 @@ -/* pinfo.cc: process table support - - Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "miscfuncs.h" -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "sigproc.h" -#include "pinfo.h" -#include "perprocess.h" -#include "environ.h" -#include -#include "ntdll.h" -#include "shared_info.h" -#include "cygheap.h" -#include "cygmalloc.h" -#include "cygtls.h" -#include "tls_pbuf.h" -#include "child_info.h" - -class pinfo_basic: public _pinfo -{ -public: - pinfo_basic(); -}; - -pinfo_basic::pinfo_basic() -{ - pid = dwProcessId = GetCurrentProcessId (); - GetModuleFileName (NULL, progname, sizeof (progname)); -} - -pinfo_basic myself_initial NO_COPY; - -pinfo NO_COPY myself (static_cast<_pinfo *> (&myself_initial)); // Avoid myself != NULL checks - -bool is_toplevel_proc; - -/* Setup the pinfo structure for this process. There may already be a - _pinfo for this "pid" if h != NULL. */ - -void -pinfo::thisproc (HANDLE h) -{ - procinfo = NULL; - - if (!h) - cygheap->pid = cygwin_pid (myself_initial.pid); - - init (cygheap->pid, PID_IN_USE, h ?: INVALID_HANDLE_VALUE); - procinfo->process_state |= PID_IN_USE; - procinfo->dwProcessId = myself_initial.pid; - strcpy (procinfo->progname, myself_initial.progname); - strace.hello (); - debug_printf ("myself->dwProcessId %u", procinfo->dwProcessId); - if (h) - { - /* here if execed */ - static pinfo NO_COPY myself_identity; - myself_identity.init (cygwin_pid (procinfo->dwProcessId), PID_EXECED, NULL); - procinfo->exec_sendsig = NULL; - procinfo->exec_dwProcessId = 0; - } - else if (!child_proc_info) /* child_proc_info is only set when this process - was started by another cygwin process */ - procinfo->start_time = time (NULL); /* Register our starting time. */ - else if (cygheap->pid_handle) - { - ForceCloseHandle (cygheap->pid_handle); - cygheap->pid_handle = NULL; - } -} - -/* Initialize the process table entry for the current task. - This is not called for forked tasks, only execed ones. */ -void __stdcall -pinfo_init (char **envp, int envc) -{ - if (envp) - { - environ_init (envp, envc); - /* spawn has already set up a pid structure for us so we'll use that */ - myself->process_state |= PID_CYGPARENT; - } - else - { - /* Invent our own pid. */ - - myself.thisproc (NULL); - myself->ppid = 1; - myself->pgid = myself->sid = myself->pid; - myself->ctty = -1; - myself->uid = ILLEGAL_UID; - myself->gid = UNKNOWN_GID; - environ_init (NULL, 0); /* call after myself has been set up */ - myself->nice = winprio_to_nice (GetPriorityClass (GetCurrentProcess ())); - debug_printf ("Set nice to %d", myself->nice); - } - - debug_printf ("pid %d, pgid %d", myself->pid, myself->pgid); -} - -static DWORD -status_exit (DWORD x) -{ - const char *find_first_notloaded_dll (path_conv &); - switch (x) - { - case STATUS_DLL_NOT_FOUND: - { - char posix_prog[NT_MAX_PATH]; - path_conv pc (myself->progname, PC_NOWARN); - mount_table->conv_to_posix_path (pc.get_win32 (), posix_prog, 1); - small_printf ("%s: error while loading shared libraries: %s: cannot open shared object file: No such file or directory\n", - posix_prog, find_first_notloaded_dll (pc)); - x = 127; - } - break; - case STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION: /* custom error value */ - /* We've already printed the error message in pseudo-reloc.c */ - x = 127; - break; - default: - x = 127; - } - return x; -} - -# define self (*this) -void -pinfo::set_exit_code (DWORD x) -{ - if (x >= 0xc0000000UL) - x = status_exit (x); - self->exitcode = EXITCODE_SET | (sigExeced ?: (x & 0xff) << 8); -} - -void -pinfo::maybe_set_exit_code_from_windows () -{ - DWORD x = 0xdeadbeef; - DWORD oexitcode = self->exitcode; - - if (hProcess && !(self->exitcode & EXITCODE_SET)) - { - WaitForSingleObject (hProcess, INFINITE); /* just to be safe, in case - process hasn't quite exited - after closing pipe */ - GetExitCodeProcess (hProcess, &x); - set_exit_code (x); - } - sigproc_printf ("pid %d, exit value - old %p, windows %p, cygwin %p", - self->pid, oexitcode, x, self->exitcode); -} - -void -pinfo::exit (DWORD n) -{ - minimal_printf ("winpid %d, exit %d", GetCurrentProcessId (), n); - lock_process until_exit (); - cygthread::terminate (); - - if (n != EXITCODE_NOSET) - self->exitcode = EXITCODE_SET | n;/* We're really exiting. Record the UNIX exit code. */ - else - { - exit_state = ES_EXEC_EXIT; - maybe_set_exit_code_from_windows (); - } - - sigproc_terminate (ES_FINAL); - - /* FIXME: There is a potential race between an execed process and its - parent here. I hated to add a mutex just for that, though. */ - struct rusage r; - fill_rusage (&r, GetCurrentProcess ()); - add_rusage (&self->rusage_self, &r); - int exitcode = self->exitcode & 0xffff; - if (!self->cygstarted) - exitcode = ((exitcode & 0xff) << 8) | ((exitcode >> 8) & 0xff); - sigproc_printf ("Calling ExitProcess n %p, exitcode %p", n, exitcode); - ExitProcess (exitcode); -} -# undef self - -void -pinfo::init (pid_t n, DWORD flag, HANDLE h0) -{ - shared_locations shloc; - h = NULL; - if (myself && !(flag & PID_EXECED) - && (n == myself->pid || (DWORD) n == myself->dwProcessId)) - { - procinfo = myself; - destroy = 0; - return; - } - - void *mapaddr; - int createit = flag & (PID_IN_USE | PID_EXECED); - DWORD access = FILE_MAP_READ - | (flag & (PID_IN_USE | PID_EXECED | PID_MAP_RW) - ? FILE_MAP_WRITE : 0); - if (!h0) - shloc = (flag & (PID_IN_USE | PID_EXECED)) ? SH_JUSTCREATE : SH_JUSTOPEN; - else - { - shloc = SH_MYSELF; - if (h0 == INVALID_HANDLE_VALUE) - h0 = NULL; - } - - procinfo = NULL; - PSECURITY_ATTRIBUTES sa_buf = (PSECURITY_ATTRIBUTES) alloca (1024); - PSECURITY_ATTRIBUTES sec_attribs = sec_user_nih (sa_buf, cygheap->user.sid(), - well_known_world_sid, - FILE_MAP_READ); - - for (int i = 0; i < 20; i++) - { - DWORD mapsize; - if (flag & PID_EXECED) - mapsize = PINFO_REDIR_SIZE; - else - mapsize = sizeof (_pinfo); - - procinfo = (_pinfo *) open_shared (L"cygpid", n, h0, mapsize, shloc, - sec_attribs, access); - if (!h0) - { - if (createit) - __seterrno (); - return; - } - - if (!procinfo) - { - if (exit_state) - return; - - switch (GetLastError ()) - { - case ERROR_INVALID_HANDLE: - api_fatal ("MapViewOfFileEx h0 %p, i %d failed, %E", h0, i); - case ERROR_INVALID_ADDRESS: - mapaddr = NULL; - } - debug_printf ("MapViewOfFileEx h0 %p, i %d failed, %E", h0, i); - low_priority_sleep (0); - continue; - } - - bool created = shloc != SH_JUSTOPEN; - - if ((procinfo->process_state & PID_INITIALIZING) && (flag & PID_NOREDIR) - && cygwin_pid (procinfo->dwProcessId) != procinfo->pid) - { - set_errno (ESRCH); - break; - } - - if (procinfo->process_state & PID_EXECED) - { - assert (i == 0); - pid_t realpid = procinfo->pid; - debug_printf ("execed process windows pid %d, cygwin pid %d", n, realpid); - if (realpid == n) - api_fatal ("retrieval of execed process info for pid %d failed due to recursion.", n); - - n = realpid; - CloseHandle (h0); - h0 = NULL; - goto loop; - } - - /* In certain pathological cases, it is possible for the shared memory - region to exist for a while after a process has exited. This should - only be a brief occurrence, so rather than introduce some kind of - locking mechanism, just loop. */ - if (!created && createit && (procinfo->process_state & PID_EXITED)) - { - debug_printf ("looping because pid %d, procinfo->pid %d, " - "procinfo->dwProcessid %u has PID_EXITED set", - n, procinfo->pid, procinfo->dwProcessId); - goto loop; - } - - if (!created) - /* nothing */; - else if (!(flag & PID_EXECED)) - procinfo->pid = n; - else - { - procinfo->process_state |= PID_IN_USE | PID_EXECED; - procinfo->pid = myself->pid; - } - - h = h0; /* Success! */ - break; - - loop: - release (); - if (h0) - low_priority_sleep (0); - } - - if (h) - { - destroy = 1; - ProtectHandle1 (h, pinfo_shared_handle); - } - else - { - h = h0; - release (); - } -} - -void -pinfo::set_acl() -{ - PACL acl_buf = (PACL) alloca (1024); - SECURITY_DESCRIPTOR sd; - NTSTATUS status; - - sec_acl (acl_buf, true, true, cygheap->user.sid (), - well_known_world_sid, FILE_MAP_READ); - if (!InitializeSecurityDescriptor (&sd, SECURITY_DESCRIPTOR_REVISION)) - debug_printf ("InitializeSecurityDescriptor %E"); - else if (!SetSecurityDescriptorDacl (&sd, TRUE, acl_buf, FALSE)) - debug_printf ("SetSecurityDescriptorDacl %E"); - else if ((status = NtSetSecurityObject (h, DACL_SECURITY_INFORMATION, &sd))) - debug_printf ("NtSetSecurityObject %lx", status); -} - -const char * -_pinfo::_ctty (char *buf) -{ - if (ctty == TTY_CONSOLE) - strcpy (buf, "ctty /dev/console"); - else if (ctty < 0) - strcpy (buf, "no ctty"); - else - __small_sprintf (buf, "ctty /dev/tty%d", ctty); - return buf; -} - -void -_pinfo::set_ctty (tty_min *tc, int flags, fhandler_tty_slave *arch) -{ - debug_printf ("old %s", __ctty ()); - if ((ctty < 0 || ctty == tc->ntty) && !(flags & O_NOCTTY)) - { - ctty = tc->ntty; - lock_ttys here; - syscall_printf ("attaching %s sid %d, pid %d, pgid %d, tty->pgid %d, tty->sid %d", - __ctty (), sid, pid, pgid, tc->getpgid (), tc->getsid ()); - - pinfo p (tc->getsid ()); - if (sid == pid && (!p || p->pid == pid || !p->exists ())) - { -#ifdef DEBUGGING - debug_printf ("resetting %s sid. Was %d, now %d. pgid was %d, now %d.", - __ctty (), tc->getsid (), sid, tc->getpgid (), pgid); -#else - paranoid_printf ("resetting %s sid. Was %d, now %d. pgid was %d, now %d.", - __ctty (), tc->getsid (), sid, tc->getpgid (), pgid); -#endif - /* We are the session leader */ - tc->setsid (sid); - tc->setpgid (pgid); - } - else - sid = tc->getsid (); - if (tc->getpgid () == 0) -{debug_printf ("setting pgid to %d", pgid); - tc->setpgid (pgid); -} - if (cygheap->ctty != arch) - { - debug_printf ("cygheap->ctty %p, arch %p", cygheap->ctty, arch); - if (!cygheap->ctty) - syscall_printf ("ctty NULL"); - else - { - syscall_printf ("ctty %p, usecount %d", cygheap->ctty, - cygheap->ctty->usecount); - cygheap->ctty->close (); - } - cygheap->ctty = arch; - if (arch) - { - arch->usecount++; - /* guard ctty arch */ - cygheap->manage_console_count ("_pinfo::set_ctty", 1); - report_tty_counts (cygheap->ctty, "ctty", ""); - } - } - } -} - -/* Test to determine if a process really exists and is processing signals. - */ -bool __stdcall -_pinfo::exists () -{ - return this && !(process_state & PID_EXITED); -} - -bool -_pinfo::alive () -{ - HANDLE h = OpenProcess (PROCESS_QUERY_INFORMATION, false, dwProcessId); - if (h) - CloseHandle (h); - return !!h; -} - -DWORD WINAPI -commune_process (void *arg) -{ - siginfo_t& si = *((siginfo_t *) arg); - tmp_pathbuf tp; - char *path = tp.c_get (); - DWORD nr; - HANDLE& tothem = si._si_commune._si_write_handle; - HANDLE process_sync = - OpenSemaphore (SYNCHRONIZE, false, shared_name (path, "commune", si.si_pid)); - if (process_sync) // FIXME: this test shouldn't be necessary - ProtectHandle (process_sync); - - lock_process now (); - if (si._si_commune._si_code & PICOM_EXTRASTR) - si._si_commune._si_str = (char *) (&si + 1); - - switch (si._si_commune._si_code) - { - case PICOM_CMDLINE: - { - sigproc_printf ("processing PICOM_CMDLINE"); - unsigned n = 0; - const char *argv[__argc_safe + 1]; - - for (int i = 0; i < __argc_safe; i++) - { - if (IsBadStringPtr (__argv[i], INT32_MAX)) - argv[i] = ""; - else - argv[i] = __argv[i]; - n += strlen (argv[i]) + 1; - } - argv[__argc_safe] = NULL; - if (!WriteFile (tothem, &n, sizeof n, &nr, NULL)) - { - /*__seterrno ();*/ // this is run from the signal thread, so don't set errno - sigproc_printf ("WriteFile sizeof argv failed, %E"); - } - else - for (const char **a = argv; *a; a++) - if (!WriteFile (tothem, *a, strlen (*a) + 1, &nr, NULL)) - { - sigproc_printf ("WriteFile arg %d failed, %E", a - argv); - break; - } - break; - } - case PICOM_CWD: - { - sigproc_printf ("processing PICOM_CWD"); - unsigned int n = strlen (cygheap->cwd.get (path, 1, 1, NT_MAX_PATH)) + 1; - if (!WriteFile (tothem, &n, sizeof n, &nr, NULL)) - sigproc_printf ("WriteFile sizeof cwd failed, %E"); - else if (!WriteFile (tothem, path, n, &nr, NULL)) - sigproc_printf ("WriteFile cwd failed, %E"); - break; - } - case PICOM_ROOT: - { - sigproc_printf ("processing PICOM_ROOT"); - unsigned n; - if (cygheap->root.exists ()) - n = strlen (strcpy (path, cygheap->root.posix_path ())) + 1; - else - n = strlen (strcpy (path, "/")) + 1; - if (!WriteFile (tothem, &n, sizeof n, &nr, NULL)) - sigproc_printf ("WriteFile sizeof root failed, %E"); - else if (!WriteFile (tothem, path, n, &nr, NULL)) - sigproc_printf ("WriteFile root failed, %E"); - break; - } - case PICOM_FDS: - { - sigproc_printf ("processing PICOM_FDS"); - unsigned int n = 0; - int fd; - cygheap_fdenum cfd; - while ((fd = cfd.next ()) >= 0) - n += sizeof (int); - cfd.rewind (); - if (!WriteFile (tothem, &n, sizeof n, &nr, NULL)) - sigproc_printf ("WriteFile sizeof fds failed, %E"); - else - while ((fd = cfd.next ()) >= 0) - if (!WriteFile (tothem, &fd, sizeof fd, &nr, NULL)) - { - sigproc_printf ("WriteFile fd %d failed, %E", fd); - break; - } - break; - } - case PICOM_PIPE_FHANDLER: - { - sigproc_printf ("processing PICOM_FDS"); - HANDLE hdl = si._si_commune._si_pipe_fhandler; - unsigned int n = 0; - cygheap_fdenum cfd; - while (cfd.next () >= 0) - if (cfd->get_handle () == hdl) - { - fhandler_pipe *fh = cfd; - n = sizeof *fh; - if (!WriteFile (tothem, &n, sizeof n, &nr, NULL)) - sigproc_printf ("WriteFile sizeof hdl failed, %E"); - else if (!WriteFile (tothem, fh, n, &nr, NULL)) - sigproc_printf ("WriteFile hdl failed, %E"); - break; - } - if (!n && !WriteFile (tothem, &n, sizeof n, &nr, NULL)) - sigproc_printf ("WriteFile sizeof hdl failed, %E"); - break; - } - case PICOM_FD: - { - sigproc_printf ("processing PICOM_FD"); - int fd = si._si_commune._si_fd; - unsigned int n = 0; - cygheap_fdget cfd (fd); - if (cfd < 0) - n = strlen (strcpy (path, "")) + 1; - else - n = strlen (cfd->get_proc_fd_name (path)) + 1; - if (!WriteFile (tothem, &n, sizeof n, &nr, NULL)) - sigproc_printf ("WriteFile sizeof fd failed, %E"); - else if (!WriteFile (tothem, path, n, &nr, NULL)) - sigproc_printf ("WriteFile fd failed, %E"); - break; - } - } - if (process_sync) - { - DWORD res = WaitForSingleObject (process_sync, 5000); - if (res != WAIT_OBJECT_0) - sigproc_printf ("WFSO failed - %d, %E", res); - else - sigproc_printf ("synchronized with pid %d", si.si_pid); - ForceCloseHandle (process_sync); - } - CloseHandle (tothem); - _my_tls._ctinfo->auto_release (); - return 0; -} - -commune_result -_pinfo::commune_request (__uint32_t code, ...) -{ - DWORD nr; - commune_result res; - va_list args; - siginfo_t si = {0}; - HANDLE& hp = si._si_commune._si_process_handle; - HANDLE& fromthem = si._si_commune._si_read_handle; - HANDLE request_sync = NULL; - bool locked = false; - - res.s = NULL; - res.n = 0; - - if (!this || !pid) - { - set_errno (ESRCH); - goto err; - } - - va_start (args, code); - si._si_commune._si_code = code; - switch (code) - { - case PICOM_PIPE_FHANDLER: - si._si_commune._si_pipe_fhandler = va_arg (args, HANDLE); - break; - - case PICOM_FD: - si._si_commune._si_fd = va_arg (args, int); - break; - - break; - } - va_end (args); - - locked = true; - char name_buf[MAX_PATH]; - request_sync = CreateSemaphore (&sec_none_nih, 0, LONG_MAX, - shared_name (name_buf, "commune", myself->pid)); - if (!request_sync) - goto err; - ProtectHandle (request_sync); - - si.si_signo = __SIGCOMMUNE; - if (sig_send (this, si)) - { - ForceCloseHandle (request_sync); /* don't signal semaphore since there was apparently no receiving process */ - request_sync = NULL; - goto err; - } - - size_t n; - switch (code) - { - case PICOM_CMDLINE: - case PICOM_CWD: - case PICOM_ROOT: - case PICOM_FDS: - case PICOM_FD: - case PICOM_PIPE_FHANDLER: - if (!ReadFile (fromthem, &n, sizeof n, &nr, NULL) || nr != sizeof n) - { - __seterrno (); - goto err; - } - if (!n) - res.s = NULL; - else - { - res.s = (char *) cmalloc_abort (HEAP_COMMUNE, n); - char *p; - for (p = res.s; n && ReadFile (fromthem, p, n, &nr, NULL); p += nr, n -= nr) - continue; - if (n) - { - __seterrno (); - goto err; - } - res.n = p - res.s; - } - break; - } - goto out; - -err: - memset (&res, 0, sizeof (res)); - -out: - if (request_sync) - { - LONG res; - ReleaseSemaphore (request_sync, 1, &res); - ForceCloseHandle (request_sync); - } - if (hp) - CloseHandle (hp); - if (fromthem) - CloseHandle (fromthem); - return res; -} - -fhandler_pipe * -_pinfo::pipe_fhandler (HANDLE hdl, size_t &n) -{ - if (!this || !pid) - return NULL; - if (pid == myself->pid) - return NULL; - commune_result cr = commune_request (PICOM_PIPE_FHANDLER, hdl); - n = cr.n; - return (fhandler_pipe *) cr.s; -} - -char * -_pinfo::fd (int fd, size_t &n) -{ - char *s; - if (!this || !pid) - return NULL; - if (pid != myself->pid) - { - commune_result cr = commune_request (PICOM_FD, fd); - s = cr.s; - n = cr.n; - } - else - { - cygheap_fdget cfd (fd); - if (cfd < 0) - s = cstrdup (""); - else - s = cfd->get_proc_fd_name ((char *) cmalloc_abort (HEAP_COMMUNE, NT_MAX_PATH)); - n = strlen (s) + 1; - } - return s; -} - -char * -_pinfo::fds (size_t &n) -{ - char *s; - if (!this || !pid) - return NULL; - if (pid != myself->pid) - { - commune_result cr = commune_request (PICOM_FDS); - s = cr.s; - n = cr.n; - } - else - { - n = 0; - int fd; - cygheap_fdenum cfd (true); - while ((fd = cfd.next ()) >= 0) - n += sizeof (int); - cfd.rewind (); - s = (char *) cmalloc_abort (HEAP_COMMUNE, n); - int *p = (int *) s; - while ((fd = cfd.next ()) >= 0 && (char *) p - s < (int) n) - *p++ = fd; - } - return s; -} - -char * -_pinfo::root (size_t& n) -{ - char *s; - if (!this || !pid) - return NULL; - if (pid != myself->pid) - { - commune_result cr = commune_request (PICOM_ROOT); - s = cr.s; - n = cr.n; - } - else - { - if (cygheap->root.exists ()) - s = cstrdup (cygheap->root.posix_path ()); - else - s = cstrdup ("/"); - n = strlen (s) + 1; - } - return s; -} - -char * -_pinfo::cwd (size_t& n) -{ - char *s; - if (!this || !pid) - return NULL; - if (pid != myself->pid) - { - commune_result cr = commune_request (PICOM_CWD); - s = cr.s; - n = cr.n; - } - else - { - s = (char *) cmalloc_abort (HEAP_COMMUNE, NT_MAX_PATH); - cygheap->cwd.get (s, 1, 1, NT_MAX_PATH); - n = strlen (s) + 1; - } - return s; -} - -char * -_pinfo::cmdline (size_t& n) -{ - char *s; - if (!this || !pid) - return NULL; - if (pid != myself->pid) - { - commune_result cr = commune_request (PICOM_CMDLINE); - s = cr.s; - n = cr.n; - } - else - { - n = 0; - for (char **a = __argv; *a; a++) - n += strlen (*a) + 1; - char *p; - p = s = (char *) cmalloc_abort (HEAP_COMMUNE, n); - for (char **a = __argv; *a; a++) - { - strcpy (p, *a); - p = strchr (p, '\0') + 1; - } - } - return s; -} - -/* This is the workhorse which waits for the write end of the pipe - created during new process creation. If the pipe is closed or a zero - is received on the pipe, it is assumed that the cygwin pid has exited. - Otherwise, various "signals" can be sent to the parent to inform the - parent to perform a certain action. */ -static DWORD WINAPI -proc_waiter (void *arg) -{ - pinfo vchild = *(pinfo *) arg; - ((pinfo *) arg)->waiter_ready = true; - - siginfo_t si = {0}; - si.si_signo = SIGCHLD; - si.si_code = CLD_EXITED; - si.si_pid = vchild->pid; -#if 0 // FIXME: This is tricky to get right - si.si_utime = pchildren[rc]->rusage_self.ru_utime; - si.si_stime = pchildren[rc].rusage_self.ru_stime; -#endif - pid_t pid = vchild->pid; - - for (;;) - { - DWORD nb; - char buf = '\0'; - - if (!ReadFile (vchild.rd_proc_pipe, &buf, 1, &nb, NULL) - && GetLastError () != ERROR_BROKEN_PIPE) - { - system_printf ("error on read of child wait pipe %p, %E", vchild.rd_proc_pipe); - break; - } - - si.si_uid = vchild->uid; - - switch (buf) - { - case __ALERT_ALIVE: - continue; - case 0: - /* Child exited. Do some cleanup and signal myself. */ - CloseHandle (vchild.rd_proc_pipe); - vchild.rd_proc_pipe = NULL; - vchild.maybe_set_exit_code_from_windows (); - if (WIFEXITED (vchild->exitcode)) - si.si_code = CLD_EXITED; - else if (WCOREDUMP (vchild->exitcode)) - si.si_code = CLD_DUMPED; - else - si.si_code = CLD_KILLED; - si.si_status = vchild->exitcode; - vchild->process_state = PID_EXITED; - /* This should always be last. Do not use vchild-> beyond this point */ - break; - case SIGTTIN: - case SIGTTOU: - case SIGTSTP: - case SIGSTOP: - if (ISSTATE (myself, PID_NOCLDSTOP)) // FIXME: No need for this flag to be in _pinfo any longer - continue; - /* Child stopped. Signal myself. */ - si.si_code = CLD_STOPPED; - break; - case SIGCONT: - continue; - default: - system_printf ("unknown value %d on proc pipe", buf); - continue; - } - - /* Special case: If the "child process" that died is us, then we're - execing. Just call proc_subproc directly and then exit this loop. - We're done here. */ - if (hExeced) - { - /* execing. no signals available now. */ - proc_subproc (PROC_CLEARWAIT, 0); - break; - } - - /* Send a SIGCHLD to myself. We do this here, rather than in proc_subproc - to avoid the proc_subproc lock since the signal thread will eventually - be calling proc_subproc and could unnecessarily block. */ - sig_send (myself_nowait, si); - - /* If we're just stopped or got a continue signal, keep looping. - Otherwise, return this thread to the pool. */ - if (buf != '\0') - sigproc_printf ("looping"); - else - break; - } - - sigproc_printf ("exiting wait thread for pid %d", pid); - vchild.wait_thread = NULL; - _my_tls._ctinfo->auto_release (); /* automatically return the cygthread to the cygthread pool */ - return 0; -} - -HANDLE -_pinfo::dup_proc_pipe (HANDLE hProcess) -{ - DWORD flags = DUPLICATE_SAME_ACCESS; - HANDLE orig_wr_proc_pipe = wr_proc_pipe; - /* Can't set DUPLICATE_CLOSE_SOURCE for exec case because we could be - execing a non-cygwin process and we need to set the exit value before the - parent sees it. */ - if (this != myself || is_toplevel_proc) - flags |= DUPLICATE_CLOSE_SOURCE; - bool res = DuplicateHandle (GetCurrentProcess (), wr_proc_pipe, - hProcess, &wr_proc_pipe, 0, FALSE, flags); - if (!res && WaitForSingleObject (hProcess, 0) != WAIT_OBJECT_0) - { - wr_proc_pipe = orig_wr_proc_pipe; - system_printf ("DuplicateHandle failed, pid %d, hProcess %p, wr_proc_pipe %p, %E", - pid, hProcess, wr_proc_pipe); - } - else - { - wr_proc_pipe_owner = dwProcessId; - sigproc_printf ("duped wr_proc_pipe %p for pid %d(%u)", wr_proc_pipe, - pid, dwProcessId); - } - return orig_wr_proc_pipe; -} - -/* function to set up the process pipe and kick off proc_waiter */ -int -pinfo::wait () -{ - /* FIXME: execed processes should be able to wait for pids that were started - by the process which execed them. */ - if (!CreatePipe (&rd_proc_pipe, &((*this)->wr_proc_pipe), &sec_none_nih, 16)) - { - system_printf ("Couldn't create pipe tracker for pid %d, %E", - (*this)->pid); - return 0; - } - - if (!(*this)->dup_proc_pipe (hProcess)) - { - system_printf ("Couldn't duplicate pipe topid %d(%p), %E", (*this)->pid, hProcess); - return 0; - } - - preserve (); /* Preserve the shared memory associated with the pinfo */ - - waiter_ready = false; - /* Fire up a new thread to track the subprocess */ - cygthread *h = new cygthread (proc_waiter, 0, this, "proc_waiter"); - if (!h) - sigproc_printf ("tracking thread creation failed for pid %d", (*this)->pid); - else - { - wait_thread = h; - sigproc_printf ("created tracking thread for pid %d, winpid %p, rd_pipe %p", - (*this)->pid, (*this)->dwProcessId, rd_proc_pipe); - } - - return 1; -} - -void -_pinfo::sync_proc_pipe () -{ - if (wr_proc_pipe && wr_proc_pipe != INVALID_HANDLE_VALUE) - while (wr_proc_pipe_owner != GetCurrentProcessId ()) - low_priority_sleep (0); -} - -/* function to send a "signal" to the parent when something interesting happens - in the child. */ -bool -_pinfo::alert_parent (char sig) -{ - DWORD nb = 0; - - /* Send something to our parent. If the parent has gone away, close the pipe. - Don't send if this is an exec stub. - - FIXME: Is there a race here if we run this while another thread is attempting - to exec()? */ - if (wr_proc_pipe == INVALID_HANDLE_VALUE || !myself->wr_proc_pipe || hExeced) - /* no parent */; - else - { - sync_proc_pipe (); - if (WriteFile (wr_proc_pipe, &sig, 1, &nb, NULL)) - /* all is well */; - else if (GetLastError () != ERROR_BROKEN_PIPE) - debug_printf ("sending %d notification to parent failed, %E", sig); - else - { - ppid = 1; - HANDLE closeit = wr_proc_pipe; - wr_proc_pipe = INVALID_HANDLE_VALUE; - CloseHandle (closeit); - } - } - return (bool) nb; -} - -void -pinfo::release () -{ - if (procinfo) - { - void *unmap_procinfo = procinfo; - procinfo = NULL; - UnmapViewOfFile (unmap_procinfo); - } - if (h) - { - HANDLE close_h = h; - h = NULL; - ForceCloseHandle1 (close_h, pinfo_shared_handle); - } -} - -/* DOCTOOL-START - - - cygwin_winpid_to_pid - - - extern "C" pid_t - cygwin_winpid_to_pid - - int winpid - - - Given a windows pid, converts to the corresponding Cygwin -pid, if any. Returns -1 if windows pid does not correspond to -a cygwin pid. - - Example use of cygwin_winpid_to_pid - - extern "C" cygwin_winpid_to_pid (int winpid); - pid_t mypid; - mypid = cygwin_winpid_to_pid (windows_pid); - - - - - DOCTOOL-END */ - -extern "C" pid_t -cygwin_winpid_to_pid (int winpid) -{ - pinfo p (cygwin_pid (winpid)); - if (p) - return p->pid; - - set_errno (ESRCH); - return (pid_t) -1; -} - - -#define slop_pidlist 200 -#define size_pidlist(i) (sizeof (pidlist[0]) * ((i) + 1)) -#define size_pinfolist(i) (sizeof (pinfolist[0]) * ((i) + 1)) -class _onreturn -{ - HANDLE *h; -public: - ~_onreturn () - { - if (h && *h) - { - CloseHandle (*h); - *h = NULL; - h = NULL; - } - } - void no_close_p_handle () {h = NULL;} - _onreturn (HANDLE& _h): h (&_h) {} -}; - -inline void -winpids::add (DWORD& nelem, bool winpid, DWORD pid) -{ - pid_t cygpid = cygwin_pid (pid); - - if (nelem >= npidlist) - { - npidlist += slop_pidlist; - pidlist = (DWORD *) realloc (pidlist, size_pidlist (npidlist + 1)); - pinfolist = (pinfo *) realloc (pinfolist, size_pinfolist (npidlist + 1)); - } - - pinfo& p = pinfolist[nelem]; - - /* Open a the process to prevent a subsequent exit from invalidating the - shared memory region. */ - p.hProcess = OpenProcess (PROCESS_QUERY_INFORMATION, false, pid); - _onreturn onreturn (p.hProcess); - - /* If we couldn't open the process then we don't have rights to it and should - make a copy of the shared memory area if it exists (it may not). - */ - bool perform_copy; - if (!p.hProcess) - perform_copy = true; - else - perform_copy = make_copy; - - p.init (cygpid, PID_NOREDIR | pinfo_access, NULL); - - /* If we're just looking for winpids then don't do any special cygwin "stuff* */ - if (winpid) - goto out; - - /* !p means that we couldn't find shared memory for this pid. Probably means - that it isn't a cygwin process. */ - if (!p) - { - if (!pinfo_access) - return; - p.init (cygpid, PID_NOREDIR, NULL); - if (!p) - return; - } - - /* Scan list of previously recorded pids to make sure that this pid hasn't - shown up before. This can happen when a process execs. */ - for (unsigned i = 0; i < nelem; i++) - if (pinfolist[i]->pid == p->pid) - { - if ((_pinfo *) p != (_pinfo *) myself) - p.release (); - return; - } - -out: - /* Exit here. - - If p is "false" then, eventually any opened process handle will be closed and - the function will exit without adding anything to the pid list. - - If p is "true" then we've discovered a cygwin process. - - Handle "myself" differently. Don't copy it and close/zero the handle we - just opened to it. - If not performing a copy, then keep the process handle open for the duration - of the life of the procinfo region to potential races when a new process uses - this pid. - Otherwise, malloc some memory for a copy of the shared memory. - - If the malloc failed, then "oh well". Just keep the shared memory around - and eventually close the handle when the winpids goes out of scope. - - If malloc succeeds, copy the procinfo we just grabbed into the new region, - release the shared memory and allow the handle to be closed when this - function returns. - - Oh, and add the pid to the list and bump the number of elements. */ - - if (p) - { - if (p == (_pinfo *) myself) - /* handle specially. Close the handle but (eventually) don't - deallocate procinfo in release call */; - else if (!perform_copy) - onreturn.no_close_p_handle (); /* Don't close the handle until release */ - else - { - _pinfo *pnew = (_pinfo *) malloc (sizeof (*p.procinfo)); - if (!pnew) - onreturn.no_close_p_handle (); - else - { - *pnew = *p.procinfo; - if ((_pinfo *) p != (_pinfo *) myself) - p.release (); - p.procinfo = pnew; - p.destroy = false; - } - } - } - if (p || winpid) - pidlist[nelem++] = pid; -} - -DWORD -winpids::enum_processes (bool winpid) -{ - static DWORD szprocs; - static SYSTEM_PROCESSES *procs; - - DWORD nelem = 0; - if (!szprocs) - procs = (SYSTEM_PROCESSES *) malloc (sizeof (*procs) + (szprocs = 200 * sizeof (*procs))); - - NTSTATUS res; - for (;;) - { - res = NtQuerySystemInformation (SystemProcessesAndThreadsInformation, - procs, szprocs, NULL); - if (res == 0) - break; - - if (res == STATUS_INFO_LENGTH_MISMATCH) - procs = (SYSTEM_PROCESSES *) realloc (procs, szprocs += 200 * sizeof (*procs)); - else - { - system_printf ("error %p reading system process information", res); - return 0; - } - } - - SYSTEM_PROCESSES *px = procs; - for (;;) - { - if (px->ProcessId) - add (nelem, winpid, px->ProcessId); - if (!px->NextEntryDelta) - break; - px = (SYSTEM_PROCESSES *) ((char *) px + px->NextEntryDelta); - } - - return nelem; -} - -void -winpids::set (bool winpid) -{ - __malloc_lock (); - npids = enum_processes (winpid); - if (pidlist) - pidlist[npids] = 0; - __malloc_unlock (); -} - -DWORD -winpids::enum_init (bool winpid) -{ - return enum_processes (winpid); -} - -void -winpids::release () -{ - _pinfo *p; - for (unsigned i = 0; i < npids; i++) - if (pinfolist[i] == (_pinfo *) myself) - continue; - else if (pinfolist[i].hProcess) - { - if (pinfolist[i]) - pinfolist[i].release (); - CloseHandle (pinfolist[i].hProcess); - } - else if ((p = pinfolist[i])) - { - pinfolist[i].procinfo = NULL; - free (p); - } -} - -winpids::~winpids () -{ - if (npidlist) - { - release (); - free (pidlist); - free (pinfolist); - } -} diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h deleted file mode 100644 index 8a30b8dcf..000000000 --- a/winsup/cygwin/pinfo.h +++ /dev/null @@ -1,240 +0,0 @@ -/* pinfo.h: process table info - - Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _PINFO_H -#define _PINFO_H -#include -#include "thread.h" - -struct commune_result -{ - char *s; - int n; - HANDLE handles[2]; -}; - -enum picom -{ - PICOM_EXTRASTR = 0x80000000, - PICOM_CMDLINE = 1, - PICOM_CWD = 2, - PICOM_ROOT = 3, - PICOM_FDS = 4, - PICOM_FD = 5, - PICOM_PIPE_FHANDLER = 6 -}; - -#define EXITCODE_SET 0x8000000 -#define EXITCODE_NOSET 0x4000000 -#define EXITCODE_RETRY 0x2000000 -#define EXITCODE_OK 0x1000000 - -class fhandler_pipe; - -class _pinfo -{ -public: - /* Cygwin pid */ - pid_t pid; - - /* Various flags indicating the state of the process. See PID_ - constants in . */ - DWORD process_state; - - DWORD exitcode; /* set when process exits */ - -#define PINFO_REDIR_SIZE ((char *) &myself.procinfo->exitcode - (char *) myself.procinfo) - - /* > 0 if started by a cygwin process */ - DWORD cygstarted; - - /* Parent process id. */ - pid_t ppid; - - /* dwProcessId contains the processid used for sending signals. It - will be reset in a child process when it is capable of receiving - signals. */ - DWORD dwProcessId; - - /* Used to spawn a child for fork(), among other things. */ - char progname[NT_MAX_PATH]; - - /* User information. - The information is derived from the GetUserName system call, - with the name looked up in /etc/passwd and assigned a default value - if not found. This data resides in the shared data area (allowing - tasks to store whatever they want here) so it's for informational - purposes only. */ - __uid32_t uid; /* User ID */ - __gid32_t gid; /* Group ID */ - pid_t pgid; /* Process group ID */ - pid_t sid; /* Session ID */ - int ctty; /* Control tty */ - bool has_pgid_children;/* True if we've forked or spawned children with our GID. */ - - /* Resources used by process. */ - long start_time; - struct rusage rusage_self; - struct rusage rusage_children; - int nice; - - /* Non-zero if process was stopped by a signal. */ - char stopsig; - - inline void set_has_pgid_children () - { - if (pgid == pid) - has_pgid_children = 1; - } - - inline void set_has_pgid_children (bool val) {has_pgid_children = val;} - - commune_result commune_request (__uint32_t, ...); - bool alive (); - fhandler_pipe *pipe_fhandler (HANDLE, size_t &); - char *fd (int fd, size_t &); - char *fds (size_t &); - char *root (size_t &); - char *cwd (size_t &); - char *cmdline (size_t &); - void set_ctty (class tty_min *, int, class fhandler_tty_slave *); - HANDLE dup_proc_pipe (HANDLE) __attribute__ ((regparm(2))); - void sync_proc_pipe (); - bool alert_parent (char); - int __stdcall kill (siginfo_t&) __attribute__ ((regparm (2))); - bool __stdcall exists () __attribute__ ((regparm (1))); - const char *_ctty (char *); - - /* signals */ - HANDLE sendsig; - HANDLE exec_sendsig; - DWORD exec_dwProcessId; -public: - HANDLE wr_proc_pipe; - DWORD wr_proc_pipe_owner; - friend class pinfo; -}; - -DWORD WINAPI commune_process (void *); - -enum parent_alerter -{ - __ALERT_REPARENT = 111, // arbitrary non-signal value - __ALERT_ALIVE = 112 -}; - -class pinfo -{ - HANDLE h; - _pinfo *procinfo; - bool destroy; -public: - HANDLE rd_proc_pipe; - HANDLE hProcess; - bool waiter_ready; - class cygthread *wait_thread; - void init (pid_t, DWORD, HANDLE) __attribute__ ((regparm(3))); - pinfo () {} - pinfo (_pinfo *x): procinfo (x), hProcess (NULL) {} - pinfo (pid_t n) : rd_proc_pipe (NULL), hProcess (NULL) {init (n, 0, NULL);} - pinfo (pid_t n, DWORD flag) : rd_proc_pipe (NULL), hProcess (NULL), waiter_ready (0), wait_thread (NULL) {init (n, flag, NULL);} - void thisproc (HANDLE) __attribute__ ((regparm (2))); - void release (); - int wait () __attribute__ ((regparm (1))); - ~pinfo () - { - if (destroy && procinfo) - release (); - } - void exit (DWORD n) __attribute__ ((noreturn, regparm(2))); - void maybe_set_exit_code_from_windows () __attribute__ ((regparm(1))); - void set_exit_code (DWORD n) __attribute__ ((regparm(2))); - _pinfo *operator -> () const {return procinfo;} - int operator == (pinfo *x) const {return x->procinfo == procinfo;} - int operator == (pinfo &x) const {return x.procinfo == procinfo;} - int operator == (_pinfo *x) const {return x == procinfo;} - int operator == (void *x) const {return procinfo == x;} - int operator == (int x) const {return (int) procinfo == (int) x;} - int operator == (char *x) const {return (char *) procinfo == x;} - _pinfo *operator * () const {return procinfo;} - operator _pinfo * () const {return procinfo;} - // operator bool () const {return (int) h;} - void preserve () { destroy = false; } -#ifndef _SIGPROC_H - int remember () {system_printf ("remember is not here"); return 0;} -#else - int remember (bool detach) - { - int res = proc_subproc (detach ? PROC_DETACHED_CHILD : PROC_ADDCHILD, - (DWORD) this); - destroy = res ? false : true; - return res; - } -#endif - HANDLE shared_handle () {return h;} - void set_acl (); - friend class _pinfo; - friend class winpids; -}; - -#define ISSTATE(p, f) (!!((p)->process_state & f)) -#define NOTSTATE(p, f) (!((p)->process_state & f)) - -class winpids -{ - bool make_copy; - DWORD npidlist; - DWORD *pidlist; - pinfo *pinfolist; - DWORD pinfo_access; // access type for pinfo open - DWORD enum_processes (bool winpid); - DWORD enum_init (bool winpid); - void add (DWORD& nelem, bool, DWORD pid); -public: - DWORD npids; - inline void reset () { release (); npids = 0;} - void set (bool winpid); - winpids (): make_copy (true) {} - winpids (int): make_copy (false), npidlist (0), pidlist (NULL), - pinfolist (NULL), pinfo_access (0), npids (0) {} - winpids (DWORD acc): make_copy (false), npidlist (0), pidlist (NULL), - pinfolist (NULL), pinfo_access (acc), npids (0) - { - set (0); - } - inline DWORD& winpid (int i) const {return pidlist[i];} - inline _pinfo *operator [] (int i) const {return (_pinfo *) pinfolist[i];} - ~winpids (); - void release (); -}; - -extern __inline pid_t -cygwin_pid (pid_t pid) -{ - return pid; -} - -void __stdcall pinfo_init (char **, int); -extern pinfo myself; - -#define _P_VFORK 0 -#define _P_SYSTEM 512 - -#define __ctty() _ctty ((char *) alloca (sizeof ("ctty /dev/tty") + 20)) -#define myctty() myself->__ctty () - -/* For mmaps across fork(). */ -int __stdcall fixup_mmaps_after_fork (HANDLE parent); -/* for shm areas across fork (). */ -int __stdcall fixup_shms_after_fork (); - -void __stdcall fill_rusage (struct rusage *, HANDLE); -void __stdcall add_rusage (struct rusage *, struct rusage *); -#endif /*_PINFO_H*/ diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc deleted file mode 100644 index 5194856bc..000000000 --- a/winsup/cygwin/pipe.cc +++ /dev/null @@ -1,414 +0,0 @@ -/* pipe.cc: pipe for Cygwin. - - Copyright 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010 Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* FIXME: Should this really be fhandler_pipe.cc? */ - -#include "winsup.h" -#include -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "pinfo.h" -#include "shared_info.h" - -fhandler_pipe::fhandler_pipe () - : fhandler_base (), popen_pid (0), overlapped (NULL) -{ - need_fork_fixup (true); - uninterruptible_io (true); -} - -int -fhandler_pipe::init (HANDLE f, DWORD a, mode_t mode) -{ - /* FIXME: Have to clean this up someday - FIXME: Do we have to check for both !get_win32_name() and - !*get_win32_name()? */ - if ((!get_win32_name () || !*get_win32_name ()) && get_name ()) - { - char *d; - const char *s; - char *hold_normalized_name = (char *) alloca (strlen (get_name ()) + 1); - for (s = get_name (), d = hold_normalized_name; *s; s++, d++) - if (*s == '/') - *d = '\\'; - else - *d = *s; - *d = '\0'; - set_name (hold_normalized_name); - } - - bool opened_properly = a & FILE_CREATE_PIPE_INSTANCE; - a &= ~FILE_CREATE_PIPE_INSTANCE; - fhandler_base::init (f, a, mode); - close_on_exec (mode & O_CLOEXEC); - setup_overlapped (opened_properly); - return 1; -} - -extern "C" int sscanf (const char *, const char *, ...); - -int -fhandler_pipe::open (int flags, mode_t mode) -{ - HANDLE proc, pipe_hdl, nio_hdl = NULL; - fhandler_pipe *fh = NULL; - size_t size; - int pid, rwflags = (flags & O_ACCMODE); - bool inh; - - sscanf (get_name (), "/proc/%d/fd/pipe:[%d]", &pid, (int *) &pipe_hdl); - if (pid == myself->pid) - { - cygheap_fdenum cfd (true); - while (cfd.next () >= 0) - { - if (cfd->get_handle () != pipe_hdl) - continue; - if ((rwflags == O_RDONLY && !(cfd->get_access () & GENERIC_READ)) - || (rwflags == O_WRONLY && !(cfd->get_access () & GENERIC_WRITE))) - { - set_errno (EACCES); - return 0; - } - if (!cfd->dup (this)) - return 1; - return 0; - } - set_errno (ENOENT); - return 0; - } - - pinfo p (pid); - if (!p) - { - set_errno (ESRCH); - return 0; - } - if (!(proc = OpenProcess (PROCESS_DUP_HANDLE, false, p->dwProcessId))) - { - __seterrno (); - return 0; - } - if (!(fh = p->pipe_fhandler (pipe_hdl, size)) || !size) - { - set_errno (ENOENT); - goto out; - } - /* Too bad, but Windows only allows the same access mode when dup'ing - the pipe. */ - if ((rwflags == O_RDONLY && !(fh->get_access () & GENERIC_READ)) - || (rwflags == O_WRONLY && !(fh->get_access () & GENERIC_WRITE))) - { - set_errno (EACCES); - goto out; - } - inh = !(flags & O_CLOEXEC); - if (!DuplicateHandle (proc, pipe_hdl, GetCurrentProcess (), &nio_hdl, - 0, inh, DUPLICATE_SAME_ACCESS)) - { - __seterrno (); - goto out; - } - init (nio_hdl, fh->get_access (), mode & O_TEXT ?: O_BINARY); - uninterruptible_io (fh->uninterruptible_io ()); - cfree (fh); - CloseHandle (proc); - return 1; -out: - if (nio_hdl) - CloseHandle (nio_hdl); - if (fh) - free (fh); - if (proc) - CloseHandle (proc); - return 0; -} - -_off64_t -fhandler_pipe::lseek (_off64_t offset, int whence) -{ - debug_printf ("(%d, %d)", offset, whence); - set_errno (ESPIPE); - return -1; -} - -int -fhandler_pipe::fadvise (_off64_t offset, _off64_t length, int advice) -{ - set_errno (ESPIPE); - return -1; -} - -int -fhandler_pipe::ftruncate (_off64_t length, bool allow_truncate) -{ - set_errno (allow_truncate ? EINVAL : ESPIPE); - return -1; -} - -char * -fhandler_pipe::get_proc_fd_name (char *buf) -{ - __small_sprintf (buf, "pipe:[%d]", get_handle ()); - return buf; -} - -void -fhandler_pipe::raw_read (void *in_ptr, size_t& in_len) -{ - return read_overlapped (in_ptr, in_len); -} - -int -fhandler_pipe::raw_write (const void *ptr, size_t len) -{ - return write_overlapped (ptr, len); -} - -int -fhandler_pipe::dup (fhandler_base *child) -{ - fhandler_pipe *ftp = (fhandler_pipe *) child; - ftp->set_popen_pid (0); - - int res; - if (get_handle () && fhandler_base::dup (child)) - res = -1; - else - res = 0; - - debug_printf ("res %d", res); - return res; -} - -#define PIPE_INTRO "\\\\.\\pipe\\cygwin-" - -/* Create a pipe, and return handles to the read and write ends, - just like CreatePipe, but ensure that the write end permits - FILE_READ_ATTRIBUTES access, on later versions of win32 where - this is supported. This access is needed by NtQueryInformationFile, - which is used to implement select and nonblocking writes. - Note that the return value is either 0 or GetLastError, - unlike CreatePipe, which returns a bool for success or failure. */ -int -fhandler_pipe::create_selectable (LPSECURITY_ATTRIBUTES sa_ptr, HANDLE& r, - HANDLE& w, DWORD psize, const char *name) -{ - /* Default to error. */ - r = w = INVALID_HANDLE_VALUE; - - /* Ensure that there is enough pipe buffer space for atomic writes. */ - if (psize < PIPE_BUF) - psize = PIPE_BUF; - - char pipename[MAX_PATH]; - const size_t len = __small_sprintf (pipename, PIPE_INTRO "%S-", - &installation_key); - - /* FIXME: Eventually make ttys work with overlapped I/O. */ - DWORD overlapped = name ? 0 : FILE_FLAG_OVERLAPPED; - - /* Retry CreateNamedPipe as long as the pipe name is in use. - Retrying will probably never be necessary, but we want - to be as robust as possible. */ - DWORD err; - do - { - static volatile ULONG pipe_unique_id; - if (!name) - __small_sprintf (pipename + len, "pipe-%p-%p", myself->pid, - InterlockedIncrement ((LONG *) &pipe_unique_id)); - else - strcpy (pipename + len, name); - - debug_printf ("CreateNamedPipe: name %s, size %lu", pipename, psize); - - err = 0; - /* Use CreateNamedPipe instead of CreatePipe, because the latter - returns a write handle that does not permit FILE_READ_ATTRIBUTES - access, on versions of win32 earlier than WinXP SP2. - CreatePipe also stupidly creates a full duplex pipe, which is - a waste, since only a single direction is actually used. - It's important to only allow a single instance, to ensure that - the pipe was not created earlier by some other process, even if - the pid has been reused. We avoid FILE_FLAG_FIRST_PIPE_INSTANCE - because that is only available for Win2k SP2 and WinXP. */ - r = CreateNamedPipe (pipename, PIPE_ACCESS_INBOUND | overlapped, - PIPE_TYPE_BYTE | PIPE_READMODE_BYTE, 1, psize, - psize, NMPWAIT_USE_DEFAULT_WAIT, sa_ptr); - - /* Win 95 seems to return NULL instead of INVALID_HANDLE_VALUE */ - if (r != INVALID_HANDLE_VALUE) - { - debug_printf ("pipe read handle %p", r); - break; - } - - err = GetLastError (); - switch (err) - { - case ERROR_PIPE_BUSY: - /* The pipe is already open with compatible parameters. - Pick a new name and retry. */ - debug_printf ("pipe busy", name ? ", retrying" : ""); - break; - case ERROR_ACCESS_DENIED: - /* The pipe is already open with incompatible parameters. - Pick a new name and retry. */ - debug_printf ("pipe access denied%s", name ? ", retrying" : ""); - break; - default: - { - err = GetLastError (); - debug_printf ("CreatePipe failed, %E"); - return err; - } - } - } - while (!name); - - if (err) - return err; - - debug_printf ("CreateFile: name %s", pipename); - - /* Open the named pipe for writing. - Be sure to permit FILE_READ_ATTRIBUTES access. */ - w = CreateFile (pipename, GENERIC_WRITE | FILE_READ_ATTRIBUTES, 0, sa_ptr, - OPEN_EXISTING, overlapped, 0); - - if (!w || w == INVALID_HANDLE_VALUE) - { - /* Failure. */ - DWORD err = GetLastError (); - debug_printf ("CreateFile failed, %E"); - CloseHandle (r); - return err; - } - - debug_printf ("pipe write handle %p", w); - - /* Success. */ - return 0; -} - -int -fhandler_pipe::create (fhandler_pipe *fhs[2], unsigned psize, int mode) -{ - HANDLE r, w; - SECURITY_ATTRIBUTES *sa = sec_none_cloexec (mode); - int res; - - int ret = create_selectable (sa, r, w, psize); - if (ret) - { - __seterrno_from_win_error (ret); - res = -1; - } - else - { - fhs[0] = (fhandler_pipe *) build_fh_dev (*piper_dev); - fhs[1] = (fhandler_pipe *) build_fh_dev (*pipew_dev); - - mode |= mode & O_TEXT ?: O_BINARY; - fhs[0]->init (r, FILE_CREATE_PIPE_INSTANCE | GENERIC_READ, mode); - fhs[1]->init (w, FILE_CREATE_PIPE_INSTANCE | GENERIC_WRITE, mode); - res = 0; - } - - syscall_printf ("%d = pipe ([%p, %p], %d, %p)", res, fhs[0], fhs[1], psize, mode); - return res; -} - -int -fhandler_pipe::ioctl (unsigned int cmd, void *p) -{ - int n; - - switch (cmd) - { - case FIONREAD: - if (get_device () == FH_PIPEW) - { - set_errno (EINVAL); - return -1; - } - if (!PeekNamedPipe (get_handle (), NULL, 0, NULL, (DWORD *) &n, NULL)) - { - __seterrno (); - return -1; - } - break; - default: - return fhandler_base::ioctl (cmd, p); - break; - } - *(int *) p = n; - return 0; -} - -int __stdcall -fhandler_pipe::fstatvfs (struct statvfs *sfs) -{ - set_errno (EBADF); - return -1; -} - -#define DEFAULT_PIPEBUFSIZE 65536 - -extern "C" int -pipe (int filedes[2]) -{ - fhandler_pipe *fhs[2]; - int res = fhandler_pipe::create (fhs, DEFAULT_PIPEBUFSIZE, O_BINARY); - if (res == 0) - { - cygheap_fdnew fdin; - cygheap_fdnew fdout (fdin, false); - fdin = fhs[0]; - fdout = fhs[1]; - filedes[0] = fdin; - filedes[1] = fdout; - } - - return res; -} - -extern "C" int -_pipe (int filedes[2], unsigned int psize, int mode) -{ - fhandler_pipe *fhs[2]; - int res = fhandler_pipe::create (fhs, psize, mode); - /* This type of pipe is not interruptible so set the appropriate flag. */ - if (!res) - { - cygheap_fdnew fdin; - cygheap_fdnew fdout (fdin, false); - fhs[0]->uninterruptible_io (true); - fdin = fhs[0]; - fdout = fhs[1]; - filedes[0] = fdin; - filedes[1] = fdout; - } - - return res; -} - -extern "C" int -pipe2 (int filedes[2], int mode) -{ - return _pipe (filedes, DEFAULT_PIPEBUFSIZE, mode); -} diff --git a/winsup/cygwin/poll.cc b/winsup/cygwin/poll.cc deleted file mode 100644 index b7f452ddb..000000000 --- a/winsup/cygwin/poll.cc +++ /dev/null @@ -1,122 +0,0 @@ -/* poll.cc. Implements poll(2) via usage of select(2) call. - - Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 - Red Hat, Inc. - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#define __INSIDE_CYGWIN_NET__ - -#define FD_SETSIZE 16384 // lots of fds -#include "winsup.h" -#include -#include -#define USE_SYS_TYPES_FD_SET -#include "cygerrno.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" - -extern "C" int -poll (struct pollfd *fds, nfds_t nfds, int timeout) -{ - int max_fd = 0; - fd_set *read_fds, *write_fds, *except_fds; - struct timeval tv = { timeout / 1000, (timeout % 1000) * 1000 }; - - for (unsigned int i = 0; i < nfds; ++i) - if (fds[i].fd > max_fd) - max_fd = fds[i].fd; - - size_t fds_size = howmany (max_fd + 1, NFDBITS) * sizeof (fd_mask); - - read_fds = (fd_set *) alloca (fds_size); - write_fds = (fd_set *) alloca (fds_size); - except_fds = (fd_set *) alloca (fds_size); - - if (!read_fds || !write_fds || !except_fds) - { - set_errno (EINVAL); /* According to SUSv3. */ - return -1; - } - - memset (read_fds, 0, fds_size); - memset (write_fds, 0, fds_size); - memset (except_fds, 0, fds_size); - - int invalid_fds = 0; - for (unsigned int i = 0; i < nfds; ++i) - { - fds[i].revents = 0; - if (!cygheap->fdtab.not_open (fds[i].fd)) - { - if (fds[i].events & POLLIN) - FD_SET(fds[i].fd, read_fds); - if (fds[i].events & POLLOUT) - FD_SET(fds[i].fd, write_fds); - if (fds[i].events & POLLPRI) - FD_SET(fds[i].fd, except_fds); - } - else if (fds[i].fd >= 0) - { - ++invalid_fds; - fds[i].revents = POLLNVAL; - } - } - - if (invalid_fds) - return invalid_fds; - - int ret = cygwin_select (max_fd + 1, read_fds, write_fds, except_fds, - timeout < 0 ? NULL : &tv); - if (ret <= 0) - return ret; - - /* Set revents fields and count fds with non-zero revents fields for - return value. */ - ret = 0; - for (unsigned int i = 0; i < nfds; ++i) - { - if (fds[i].fd >= 0) - { - if (cygheap->fdtab.not_open (fds[i].fd)) - fds[i].revents = POLLHUP; - else - { - fhandler_socket *sock; - - if (FD_ISSET(fds[i].fd, read_fds)) - /* This should be sufficient for sockets, too. Using - MSG_PEEK, as before, can be considered dangerous at - best. Quote from W. Richard Stevens: "The presence - of an error can be considered either normal data or - an error (POLLERR). In either case, a subsequent read - will return -1 with errno set to the appropriate value." - So it looks like there's actually no good reason to - return POLLERR. */ - fds[i].revents |= POLLIN; - /* Handle failed connect. */ - if (FD_ISSET(fds[i].fd, write_fds) - && (sock = cygheap->fdtab[fds[i].fd]->is_socket ()) - && sock->connect_state () == connect_failed) - fds[i].revents |= (POLLIN | POLLERR); - else - { - if (FD_ISSET(fds[i].fd, write_fds)) - fds[i].revents |= POLLOUT; - if (FD_ISSET(fds[i].fd, except_fds)) - fds[i].revents |= POLLPRI; - } - } - if (fds[i].revents) - ++ret; - } - } - - return ret; -} diff --git a/winsup/cygwin/posix.sgml b/winsup/cygwin/posix.sgml deleted file mode 100644 index c7e16ef12..000000000 --- a/winsup/cygwin/posix.sgml +++ /dev/null @@ -1,1424 +0,0 @@ -System interfaces compatible with the Single Unix Specification, Version 4: - -Note that the core of the Single Unix Specification, Version 4 is -also IEEE Std 1003.1-2008 (POSIX.1-2008). - - - FD_CLR - FD_ISSET - FD_SET - FD_ZERO - _Exit - _exit - _longjmp - _setjmp - _tolower - _toupper - a64l - abort - abs - accept - access - acos - acosf - acosh - acoshf - alarm - alphasort - asctime - asctime_r - asin - asinf - asinh - asinhf - atan - atan2 - atan2f - atanf - atanh - atanhf - atexit - atof - atoff - atoi - atol - atoll - basename - bind - bsearch - btowc - cabs - cabsf - calloc - catclose (available in external "catgets" library) - catgets (available in external "catgets" library) - catopen (available in external "catgets" library) - cbrt - cbrtf - ceil - ceilf - cfgetispeed - cfgetospeed - cfsetispeed - cfsetospeed - chdir - chmod - chown - chroot (see chapter "Implementation Notes") - clearerr - clock - clock_getres (see chapter "Implementation Notes") - clock_gettime (see chapter "Implementation Notes") - clock_setres (see chapter "Implementation Notes") - close - closedir - closelog - confstr - connect - copysign - copysignf - cos - cosf - cosh - coshf - creat - crypt (available in external "crypt" library) - ctermid - ctime - ctime_r - daylight - dbm_clearerr (available in external "libgdbm" library) - dbm_close (available in external "libgdbm" library) - dbm_delete (available in external "libgdbm" library) - dbm_error (available in external "libgdbm" library) - dbm_fetch (available in external "libgdbm" library) - dbm_firstkey (available in external "libgdbm" library) - dbm_nextkey (available in external "libgdbm" library) - dbm_open (available in external "libgdbm" library) - dbm_store (available in external "libgdbm" library) - difftime - dirfd - dirname - div - dlclose - dlerror - dlopen - dlsym - dprintf - drand48 - dup - dup2 - encrypt (available in external "crypt" library) - endgrent - endhostent - endprotoent - endpwent - endservent - endutxent - environ - erand48 - erf - erfc - erfcf - erff - errno - execl - execle - execlp - execv - execve - execvp - exit - exp - exp2 - exp2f - expf - expm1 - expm1f - fabs - fabsf - faccessat - fchdir - fchmod - fchmodat - fchown - fchownat - fclose - fcntl - fdatasync - fdim - fdimf - fdopen - fdopendir - feof - ferror - fexecve - fflush - ffs - fgetc - fgetpos - fgets - fgetwc - fgetws - fileno - flockfile - floor - floorf - fma - fmaf - fmax - fmaxf - fmemopen - fmin - fminf - fmod - fmodf - fnmatch - fopen - fork - fpathconf - fpclassify (see chapter "Implementation Notes") - fprintf - fputc - fputs - fputwc - fputws - fread - free - freeaddrinfo - freopen - frexp - frexpf - fscanf - fseek - fseeko - fsetpos - fstat - fstatat - fstatvfs - fsync - ftell - ftello - ftok - ftruncate - ftrylockfile - ftw - funlockfile - futimens - futimes - fwide - fwprintf - fwrite - fwscanf - gai_strerror - getaddrinfo - getc - getc_unlocked - getchar - getchar_unlocked - getcwd - getdelim - getdomainname - getegid - getenv - geteuid - getgid - getgrent - getgrgid - getgrgid_r - getgrnam - getgrnam_r - getgroups - gethostid - gethostname - getitimer (see chapter "Implementation Notes") - getline - getlogin - getlogin_r - getnameinfo - getopt - getpeername - getpgid - getpgrp - getpid - getppid - getpriority - getprotobyname - getprotobynumber - getprotoent - getpwent - getpwnam - getpwnam_r - getpwuid - getpwuid_r - getrlimit - getrusage - gets - getservbyname - getservbyport - getservent - getsid - getsockname - getsockopt - getsubopt - gettimeofday - getuid - getutxent - getutxid - getutxline - getwc - getwchar - glob - globfree - gmtime - gmtime_r - grantpt - hcreate - hdestroy - hsearch - hstrerror - htonl - htons - hypot - hypotf - iconv (available in external "libiconv" library) - iconv_close (available in external "libiconv" library) - iconv_open (available in external "libiconv" library) - if_freenameindex - if_indextoname - if_nameindex - if_nametoindex - ilogb - ilogbf - imaxabs - imaxdiv - inet_addr - inet_ntoa - inet_ntop - inet_pton - initstate - insque - ioctl - isalnum - isalpha - isascii - isatty - isblank - iscntrl - isdigit - isfinite (see chapter "Implementation Notes") - isgraph - isgreater (see chapter "Implementation Notes") - isgreaterequal (see chapter "Implementation Notes") - isinf (see chapter "Implementation Notes") - isless - islessequal (see chapter "Implementation Notes") - islessgreater (see chapter "Implementation Notes") - islower - isnan (see chapter "Implementation Notes") - isnormal (see chapter "Implementation Notes") - isprint - ispunct - isspace - isunordered (see chapter "Implementation Notes") - isupper - iswalnum - iswalpha - iswblank - iswcntrl - iswctype - iswdigit - iswgraph - iswlower - iswprint - iswpunct - iswspace - iswupper - iswxdigit - isxdigit - j0 - j1 - jn - jrand48 - kill - killpg - l64a - labs - lchown - lcong48 - ldexp - ldexpf - ldiv - lfind - lgamma - lgammaf - link - linkat - listen - llabs - lldiv - llrint - llrintf - llrintl - localeconv - localtime - localtime_r - lockf - log - log10 - log10f - log1p - log1pf - log2 - log2f - logb - logbf - logf - longjmp - lrand48 - lrint - lrintf - lrintl - lround - lroundf - lsearch - lseek - lstat - malloc - mblen - mbrlen - mbrtowc - mbsinit - mbsnrtowcs - mbsrtowcs - mbstowcs - mbtowc - memccpy - memchr - memcmp - memcpy - memmove - memset - mkdir - mkdirat - mkdtemp - mkfifo - mkfifoat - mknod - mknodat - mkstemp - mktime - mlock - mmap - modf - modff - mprotect - mq_close - mq_getattr - mq_notify - mq_open - mq_receive - mq_send - mq_setattr - mq_timedreceive - mq_timedsend - mq_unlink - mrand48 - msgctl (see chapter "Implementation Notes") - msgget (see chapter "Implementation Notes") - msgrcv (see chapter "Implementation Notes") - msgsnd (see chapter "Implementation Notes") - msync - munlock - munmap - nan - nanf - nanosleep - nearbyint - nearbyintf - nextafter - nextafterf - nftw - nice - nl_langinfo - nrand48 - ntohl - ntohs - open - open_memstream - open_wmemstream - openat - opendir - openlog - optarg - opterr - optind - optopt - pathconf - pause - pclose - perror - pipe - poll - popen - posix_fadvise - posix_fallocate - posix_madvise - posix_memalign - posix_openpt - pow - powf - pread - printf - pselect - pthread_atfork - pthread_attr_destroy - pthread_attr_getdetachstate - pthread_attr_getinheritsched - pthread_attr_getschedparam - pthread_attr_getschedpolicy - pthread_attr_getscope - pthread_attr_getstacksize - pthread_attr_init - pthread_attr_setdetachstate - pthread_attr_setinheritsched - pthread_attr_setschedparam - pthread_attr_setschedpolicy - pthread_attr_setscope - pthread_attr_setstacksize - pthread_cancel - pthread_cond_broadcast - pthread_cond_destroy - pthread_cond_init - pthread_cond_signal - pthread_cond_timedwait - pthread_cond_wait - pthread_condattr_destroy - pthread_condattr_getpshared - pthread_condattr_init - pthread_condattr_setpshared - pthread_create - pthread_detach - pthread_equal - pthread_exit - pthread_getconcurrency - pthread_getschedparam - pthread_getspecific - pthread_join - pthread_key_create - pthread_key_delete - pthread_kill - pthread_mutex_destroy - pthread_mutex_getprioceiling - pthread_mutex_init - pthread_mutex_lock - pthread_mutex_setprioceiling - pthread_mutex_trylock - pthread_mutex_unlock - pthread_mutexattr_destroy - pthread_mutexattr_getprioceiling - pthread_mutexattr_getprotocol - pthread_mutexattr_getpshared - pthread_mutexattr_gettype - pthread_mutexattr_init - pthread_mutexattr_setprioceiling - pthread_mutexattr_setprotocol - pthread_mutexattr_setpshared - pthread_mutexattr_settype - pthread_once - pthread_rwlock_destroy - pthread_rwlock_init - pthread_rwlock_rdlock - pthread_rwlock_tryrdlock - pthread_rwlock_trywrlock - pthread_rwlock_unlock - pthread_rwlock_wrlock - pthread_rwlockattr_destroy - pthread_rwlockattr_getpshared - pthread_rwlockattr_init - pthread_rwlockattr_setpshared - pthread_self - pthread_setcancelstate - pthread_setcanceltype - pthread_setconcurrency - pthread_setschedparam - pthread_setspecific - pthread_sigmask - pthread_testcancel - ptsname - putc - putc_unlocked - putchar - putchar_unlocked - putenv - puts - pututxline - putwc - putwchar - pwrite - qsort - raise - rand - rand_r - random - read - readdir - readdir_r - readlink - readlinkat - readv - realloc - realpath - recv - recvfrom - recvmsg - regcomp - regerror - regexec - regfree - remainder - remainderf - remove - remque - remquo - remquof - rename - renameat - rewind - rewinddir - rint - rintf - rintl - rmdir - round - roundf - scalbln - scalblnf - scalbn - scalbnf - scandir - scanf - sched_get_priority_max - sched_get_priority_min - sched_getparam - sched_getscheduler - sched_rr_get_interval - sched_setparam - sched_setscheduler - sched_yield - seed48 - seekdir - select - sem_close - sem_destroy - sem_getvalue - sem_init - sem_open - sem_post - sem_timedwait - sem_trywait - sem_unlink - sem_wait - semctl (see chapter "Implementation Notes") - semget (see chapter "Implementation Notes") - semop (see chapter "Implementation Notes") - send - sendmsg - sendto - setbuf - setegid - setenv - seteuid - setgid - setgrent - sethostent - setitimer (see chapter "Implementation Notes") - setjmp - setkey (available in external "crypt" library) - setlocale - setlogmask - setpgid - setpgrp - setpriority - setprotoent - setpwent - setregid - setreuid - setrlimit - setservent - setsid - setsockopt - setstate - setuid - setutxent - setvbuf - shm_open - shm_unlink - shmat (see chapter "Implementation Notes") - shmctl (see chapter "Implementation Notes") - shmdt (see chapter "Implementation Notes") - shmget (see chapter "Implementation Notes") - shutdown - sigaction - sigaddset - sigdelset - sigemptyset - sigfillset - sighold - sigignore - siginterrupt - sigismember - siglongjmp - signal - signbit (see chapter "Implementation Notes") - signgam - sigpause - sigpending - sigprocmask - sigqueue - sigrelse - sigset - sigsetjmp - sigsuspend - sigwait - sigwaitinfo - sin - sinf - sinh - sinhf - sleep - snprintf - socket - socketpair - sprintf - sqrt - sqrtf - srand - srand48 - srandom - sscanf - stat - statvfs - stderr - stdin - stdout - stpcpy - stpncpy - strcasecmp - strcat - strchr - strcmp - strcoll - strcpy - strcspn - strdup - strerror - strerror_r - strfmon - strftime - strlen - strncasecmp - strncat - strncmp - strncpy - strndup - strnlen - strpbrk - strptime - strrchr - strsignal - strspn - strstr - strtod - strtof - strtoimax - strtok - strtok_r - strtol - strtoll - strtoul - strtoull - strtoumax - strxfrm - swab - swprintf - swscanf - symlink - symlinkat - sync - sysconf - syslog - system - tan - tanf - tanh - tanhf - tcdrain - tcflow - tcflush - tcgetattr - tcgetpgrp - tcsendbreak - tcsetattr - tcsetpgrp - tdelete - telldir - tempnam - tfind - tgamma - tgammaf - time - timer_create - timer_delete - timer_gettime - timer_settime - times - timezone - tmpfile - tmpnam - toascii - tolower - toupper - towctrans - towlower - towupper - trunc - truncate - truncf - tsearch - ttyname - ttyname_r - twalk - tzname - tzset - umask - uname - ungetc - ungetwc - unlink - unlinkat - unlockpt - unsetenv - utime - utimensat - utimes - va_arg - va_copy - va_end - va_start - vdprintf - vfprintf - vfscanf - vfwprintf - vfwscanf - vprintf - vscanf - vsnprintf - vsprintf - vsscanf - vswprintf - vswscanf - vwprintf - vwscanf - wait - waitpid - wcpcpy - wcpncpy - wcrtomb - wcscasecmp - wcscat - wcschr - wcscmp - wcscoll - wcscpy - wcscspn - wcsdup - wcsftime - wcslen - wcsncasecmp - wcsncat - wcsncmp - wcsncpy - wcsnlen - wcsnrtombs - wcspbrk - wcsrchr - wcsrtombs - wcsspn - wcsstr - wcstod - wcstof - wcstoimax - wcstok - wcstol - wcstoll - wcstombs - wcstoul - wcstoull - wcstoumax - wcswidth - wcsxfrm - wctob - wctomb - wctrans - wctype - wcwidth - wmemchr - wmemcmp - wmemcpy - wmemmove - wmemset - wordexp - wordfree - wprintf - write - writev - wscanf - y0 - y1 - yn - - - - -System interfaces compatible with BSD functions: - - - bindresvport - bindresvport_sa - cfmakeraw - daemon - dn_comp - dn_expand - dn_skipname - drem - eaccess - endusershell - err - errx - finite - finitef - fiprintf - flock - forkpty - fpurge - freeifaddrs - fstatfs - fts_children - fts_close - fts_get_clientptr - fts_get_stream - fts_open - fts_read - fts_set - fts_set_clientptr - funopen - gamma - gamma_r - gammaf - gammaf_r - getdtablesize - getifaddrs - getpagesize - getpeereid - getprogname - getusershell - herror - inet_aton - inet_makeaddr - inet_netof - inet_network - initgroups - iruserok - iruserok_sa - login - login_tty - logout - logwtmp - mkstemps - openpty - rcmd - rcmd_af - reallocf - res_close - res_init - res_mkquery - res_nclose - res_ninit - res_nmkquery - res_nquery - res_nquerydomain - res_nsearch - res_nsend - res_query - res_querydomain - res_search - res_send - revoke - rexec - rresvport - rresvport_af - ruserok - sbrk - setbuffer - setgroups - setlinebuf - setpassent - setprogname - settimeofday - setusershell - statfs - strcasestr - strlcat - strlcpy - strsep - updwtmp - valloc - verr - verrx - vhangup (see chapter "Implementation Notes") - vsyslog - vwarn - vwarnx - wait3 - wait4 - warn - warnx - wcslcat - wcslcpy - - - - -System interfaces compatible with GNU or Linux extensions: - - - accept4 - argz_add - argz_add_sep - argz_append - argz_count - argz_create - argz_create_sep - argz_delete - argz_extract - argz_insert - argz_next - argz_replace - argz_stringify - asnprintf - asprintf - asprintf_r - canonicalize_file_name - dremf - dup3 - envz_add - envz_entry - envz_get - envz_merge - envz_remove - envz_strip - euidaccess - execvpe - exp10 - exp10f - fcloseall - fcloseall_r - fgetxattr - flistxattr - fopencookie - fremovexattr - fsetxattr - get_avphys_pages - get_phys_pages - get_nprocs - get_nprocs_conf - getopt_long - getopt_long_only - getxattr - lgetxattr - listxattr - llistxattr - lremovexattr - lsetxattr - memmem - mempcpy - pipe2 - pow10 - pow10f - removexattr - setxattr - tdestroy - timegm - timelocal - updwtmpx - utmpxname - vasnprintf - vasprintf - vasprintf_r - - - - -System interfaces compatible with Solaris or SunOS functions: - - - acl - aclcheck - aclfrommode - aclfrompbits - aclfromtext - aclsort - acltomode - acltopbits - acltotext - endmntent - facl - futimesat - getmntent - memalign - setmntent - - - - -Other UNIX system interfaces, deprecated or not in POSIX.1-2008: - - - bcmp (POSIX.1-2001, SUSv3) - bcopy (SUSv3) - bzero (SUSv3) - cuserid (POSIX.1-1988, SUSv2) - ecvt (SUSv3) - endutent (XPG2) - fcvt (SUSv3) - ftime (SUSv3) - gcvt (SUSv3) - gethostbyaddr (SUSv3) - gethostbyname (SUSv3) - gethostbyname2 (first defined in BIND 4.9.4) - getpass (SUSv2) - getutent (XPG2) - getutid (XPG2) - getutline (XPG2) - getw (SVID) - getwd (SUSv3) - h_errno (SUSv3) - index (SUSv3) - mallinfo (SVID) - mallopt (SVID) - mktemp (SUSv3) - on_exit (SunOS) - pthread_continue (XPG2) - pthread_getsequence_np (Tru64) - pthread_suspend (XPG2) - pututline (XPG2) - putw (SVID) - rindex (SUSv3) - scalb (SUSv3) - setutent (XPG2) - sys_errlist (BSD) - sys_nerr (BSD) - ttyslot (SUSv2) - ualarm (SUSv3) - usleep (SUSv3) - utmpname (XPG2) - vfork (SUSv3) (see chapter "Implementation Notes") - - - - -NOT implemented system interfaces from the Single Unix Specification, Volume 4: - - - acoshl - acosl - aio_cancel - aio_error - aio_fsync - aio_read - aio_return - aio_suspend - aio_write - asinhl - asinl - atan2l - atanhl - atanl - bsd_signal - cabsl - cacos - cacosf - cacosh - cacoshf - cacoshl - cacosl - carg - cargf - cargl - casin - casinf - casinh - casinhf - casinhl - casinl - catan - catanf - catanh - catanhf - catanhl - catanl - cbrtl - ccos - ccosf - ccosh - ccoshf - ccoshl - ccosl - ceill - cexp - cexpf - cexpl - cimag - cimagf - cimagl - clock_getcpuclockid - clog - clogf - clogl - conj - conjf - conjl - copysignl - coshl - cosl - cpow - cpowf - cpowl - cproj - cprojf - cprojl - creal - crealf - creall - csin - csinf - csinh - csinhf - csinhl - csinl - csqrt - csqrtf - csqrtl - ctan - ctanf - ctanh - ctanhf - ctanhl - ctanl - duplocale - endnetent - erfcl - erfl - exp2l - expl - expm1l - fabsl - fattach - fdiml - feclearexcept - fegetenv - fegetexceptflag - fegetround - feholdexcept - feraiseexcept - fesetenv - fesetexceptflag - fesetround - fetestexcept - feupdateenv - floorl - fmal - fmaxl - fminl - fmodl - fmtmsg - freelocale - frexpl - getdate - getdate_err - gethostent - getmsg - getnetbyaddr - getnetbyname - getnetent - getpmsg - hypotl - ilogbl - initstate - isalnum_l - isalpha_l - isastream - isblank_l - iscntrl_l - isdigit_l - isgraph_l - islower_l - isprint_l - ispunct_l - isspace_l - isupper_l - iswalnum_l - iswalpha_l - iswblank_l - iswcntrl_l - iswdigit_l - iswgraph_l - iswlower_l - iswprint_l - iswpunct_l - iswspace_l - iswupper_l - iswxdigit_l - isxdigit_l - ldexpl - lgammal - lio_listio - llround - llroundf - llroundl - log10l - log1pl - log2l - logbl - logl - lroundl - mlockall - modfl - munlockall - nanl - nearbyintl - newlocale - nextafterl - nexttowardl - posix_mem_offset - posix_spawn[...] - posix_trace[...] - posix_typed_[...] - powl - psiginfo - psignal - pthread_attr_getguardsize - pthread_attr_getstack - pthread_attr_getstackaddr - pthread_attr_setguardsize - pthread_attr_setstack - pthread_attr_setstackaddr - pthread_barrier[...] - pthread_condattr_getclock - pthread_condattr_setclock - pthread_getcpuclockid - pthread_mutexattr_getrobust - pthread_mutexattr_setrobust - pthread_mutex_consistent - pthread_mutex_timedlock - pthread_rwlock_timedrdlock - pthread_rwlock_timedwrlock - pthread_setschedprio - pthread_spin_[...] - putmsg - reminderl - remquol - roundl - scalblnl - scalbnl - setcontext - setnetent - sigaltstack - sigtimedwait - sinhl - sinl - sockatmark - sqrtl - strcasecmp_l - strcoll_l - strfmon_l - strncasecmp_l - strtold - strxfrm_l - swabcontext - tanhl - tanl - tcgetsid - tgammal - timer_getoverrun - tolower_l - toupper_l - towctrans_l - truncl - ulimit - uselocale - waitid - wcscasecmp_l - wcsncasecmp_l - wcstold - wcsxfrm_l - wctrans_l - wctype_l - - - - -Implementation Notes - -chroot only emulates a chroot function call -by keeping track of the current root and accomodating this in the file -related function calls. A real chroot functionality is not supported by -Windows however. - -clock_getres, clock_gettime -and clock_setres only support CLOCK_REALTIME for -now. - -BSD file locks created via flock are not -propagated to the parent process and sibling processes. The locks are -only valid in the creating process and subsequently started child processes -shaing the same file descriptor. - -fpclassify, isfinite, -isgreater, isgreaterequal, -isinf, isless, -islessequal, islessgreater, -isnan, isnormal, -isunordered, and signbit -only support float and double arguments, not long double arguments. - -getitimer and setitimer -only support ITIMER_REAL for now. - -link will copy the file if it can't implement -a true hardlink. This is true at least for FAT and FAT32 filesystems. -NTFS supports hardlinks. - -lseek only works properly on binary -files. - -setuid is only safe against reverting the user -switch after a call to one of the exec(2) functions took place. Windows -doesn't support a non-revertable user switch within the context of Win32 -processes. - -vfork just calls fork. - -vhangup always returns -1 and sets errno to -ENOSYS. - -The XSI IPC functions semctl, -semget, semop, -shmat, shmctl, -shmdt, shmget, -msgctl, msgget, -msgrcv and msgsnd are only -available when cygserver is running. - - diff --git a/winsup/cygwin/posix_ipc.cc b/winsup/cygwin/posix_ipc.cc deleted file mode 100644 index 3b0ae7802..000000000 --- a/winsup/cygwin/posix_ipc.cc +++ /dev/null @@ -1,1074 +0,0 @@ -/* posix_ipc.cc: POSIX IPC API for Cygwin. - - Copyright 2007, 2008, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "thread.h" -#include "path.h" -#include "cygtls.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "sigproc.h" -#include "ntdll.h" -#include -#include -#include -#include -#include -#include - -/* The prefix_len is the length of the path prefix ncluding trailing "/" - (or "/sem." for semaphores) as well as the trailing NUL. */ -static struct -{ - const char *prefix; - const size_t prefix_len; - const char *description; -} ipc_names[] = { - { "/dev/shm", 10, "POSIX shared memory object" }, - { "/dev/mqueue", 13, "POSIX message queue" }, - { "/dev/shm", 14, "POSIX semaphore" } -}; - -enum ipc_type_t -{ - shmem, - mqueue, - semaphore -}; - -static bool -check_path (char *res_name, ipc_type_t type, const char *name, size_t len) -{ - /* Note that we require the existance of the appropriate /dev subdirectories - for POSIX IPC object support, similar to Linux (which supports the - directories, but doesn't require to mount them). We don't create - these directory here, that's the task of the installer. But we check - for existance and give ample warning. */ - path_conv path (ipc_names[type].prefix, PC_SYM_NOFOLLOW); - if (path.error || !path.exists () || !path.isdir ()) - { - small_printf ( - "Warning: '%s' does not exists or is not a directory.\n\n" - "%ss require the existance of this directory.\n" - "Create the directory '%s' and set the permissions to 01777.\n" - "For instance on the command line: mkdir -m 01777 %s\n", - ipc_names[type].prefix, ipc_names[type].description, - ipc_names[type].prefix, ipc_names[type].prefix); - set_errno (EINVAL); - return false; - } - /* Name must not be empty, or just be a single slash, or start with more - than one slash. Same for backslash. - Apart from handling backslash like slash, the naming rules are identical - to Linux, including the names and requirements for subdirectories, if - the name contains further slashes. */ - if (!name || (strchr ("/\\", name[0]) - && (!name[1] || strchr ("/\\", name[1])))) - { - debug_printf ("Invalid %s name '%s'", ipc_names[type].description, name); - set_errno (EINVAL); - return false; - } - /* Skip leading (back-)slash. */ - if (strchr ("/\\", name[0])) - ++name; - if (len > PATH_MAX - ipc_names[type].prefix_len) - { - debug_printf ("%s name '%s' too long", ipc_names[type].description, name); - set_errno (ENAMETOOLONG); - return false; - } - __small_sprintf (res_name, "%s/%s%s", ipc_names[type].prefix, - type == semaphore ? "sem." : "", - name); - return true; -} - -static int -ipc_mutex_init (HANDLE *pmtx, const char *name) -{ - char buf[MAX_PATH]; - SECURITY_ATTRIBUTES sa = sec_none; - - __small_sprintf (buf, "mqueue/mtx_%s", name); - sa.lpSecurityDescriptor = everyone_sd (CYG_MUTANT_ACCESS); - *pmtx = CreateMutex (&sa, FALSE, buf); - if (!*pmtx) - debug_printf ("CreateMutex: %E"); - return *pmtx ? 0 : geterrno_from_win_error (); -} - -static int -ipc_mutex_lock (HANDLE mtx) -{ - HANDLE h[2] = { mtx, signal_arrived }; - - switch (WaitForMultipleObjects (2, h, FALSE, INFINITE)) - { - case WAIT_OBJECT_0: - case WAIT_ABANDONED_0: - return 0; - case WAIT_OBJECT_0 + 1: - set_errno (EINTR); - return 1; - default: - break; - } - return geterrno_from_win_error (); -} - -static inline int -ipc_mutex_unlock (HANDLE mtx) -{ - return ReleaseMutex (mtx) ? 0 : geterrno_from_win_error (); -} - -static inline int -ipc_mutex_close (HANDLE mtx) -{ - return CloseHandle (mtx) ? 0 : geterrno_from_win_error (); -} - -static int -ipc_cond_init (HANDLE *pevt, const char *name) -{ - char buf[MAX_PATH]; - SECURITY_ATTRIBUTES sa = sec_none; - - __small_sprintf (buf, "mqueue/evt_%s", name); - sa.lpSecurityDescriptor = everyone_sd (CYG_EVENT_ACCESS); - *pevt = CreateEvent (&sa, TRUE, FALSE, buf); - if (!*pevt) - debug_printf ("CreateEvent: %E"); - return *pevt ? 0 : geterrno_from_win_error (); -} - -static int -ipc_cond_timedwait (HANDLE evt, HANDLE mtx, const struct timespec *abstime) -{ - struct timeval tv; - DWORD timeout; - HANDLE h[2] = { mtx, evt }; - - if (!abstime) - timeout = INFINITE; - else if (abstime->tv_sec < 0 - || abstime->tv_nsec < 0 - || abstime->tv_nsec > 999999999) - return EINVAL; - else - { - gettimeofday (&tv, NULL); - /* Check for immediate timeout. */ - if (tv.tv_sec > abstime->tv_sec - || (tv.tv_sec == abstime->tv_sec - && tv.tv_usec > abstime->tv_nsec / 1000)) - return ETIMEDOUT; - timeout = (abstime->tv_sec - tv.tv_sec) * 1000; - timeout += (abstime->tv_nsec / 1000 - tv.tv_usec) / 1000; - } - if (ipc_mutex_unlock (mtx)) - return -1; - switch (WaitForMultipleObjects (2, h, TRUE, timeout)) - { - case WAIT_OBJECT_0: - case WAIT_ABANDONED_0: - ResetEvent (evt); - return 0; - case WAIT_TIMEOUT: - ipc_mutex_lock (mtx); - return ETIMEDOUT; - default: - break; - } - return geterrno_from_win_error (); -} - -static inline int -ipc_cond_signal (HANDLE evt) -{ - return SetEvent (evt) ? 0 : geterrno_from_win_error (); -} - -static inline int -ipc_cond_close (HANDLE evt) -{ - return CloseHandle (evt) ? 0 : geterrno_from_win_error (); -} - -class ipc_flock -{ - struct __flock64 fl; - -public: - ipc_flock () { memset (&fl, 0, sizeof fl); } - - int lock (int fd, size_t size) - { - fl.l_type = F_WRLCK; - fl.l_whence = SEEK_SET; - fl.l_start = 0; - fl.l_len = size; - return fcntl64 (fd, F_SETLKW, &fl); - } - int unlock (int fd) - { - if (!fl.l_len) - return 0; - fl.l_type = F_UNLCK; - return fcntl64 (fd, F_SETLKW, &fl); - } -}; - -/* POSIX shared memory object implementation. */ - -extern "C" int -shm_open (const char *name, int oflag, mode_t mode) -{ - size_t len = strlen (name); - char shmname[ipc_names[shmem].prefix_len + len]; - - if (!check_path (shmname, shmem, name, len)) - return -1; - - /* Check for valid flags. */ - if (((oflag & O_ACCMODE) != O_RDONLY && (oflag & O_ACCMODE) != O_RDWR) - || (oflag & ~(O_ACCMODE | O_CREAT | O_EXCL | O_TRUNC))) - { - debug_printf ("Invalid oflag 0%o", oflag); - set_errno (EINVAL); - return -1; - } - - return open (shmname, oflag | O_CLOEXEC, mode & 0777); -} - -extern "C" int -shm_unlink (const char *name) -{ - size_t len = strlen (name); - char shmname[ipc_names[shmem].prefix_len + len]; - - if (!check_path (shmname, shmem, name, len)) - return -1; - - return unlink (shmname); -} - -/* The POSIX message queue implementation is based on W. Richard STEVENS - implementation, just tweaked for Cygwin. The main change is - the usage of Windows mutexes and events instead of using the pthread - synchronization objects. The pathname is massaged so that the - files are created under /dev/mqueue. mq_timedsend and mq_timedreceive - are implemented additionally. */ - -struct mq_hdr -{ - struct mq_attr mqh_attr; /* the queue's attributes */ - long mqh_head; /* index of first message */ - long mqh_free; /* index of first free message */ - long mqh_nwait; /* #threads blocked in mq_receive() */ - pid_t mqh_pid; /* nonzero PID if mqh_event set */ - char mqh_uname[36]; /* unique name used to identify synchronization - objects connected to this queue */ - struct sigevent mqh_event; /* for mq_notify() */ -}; - -struct msg_hdr -{ - long msg_next; /* index of next on linked list */ - ssize_t msg_len; /* actual length */ - unsigned int msg_prio; /* priority */ -}; - -struct mq_info -{ - struct mq_hdr *mqi_hdr; /* start of mmap'ed region */ - unsigned long mqi_magic; /* magic number if open */ - int mqi_flags; /* flags for this process */ - HANDLE mqi_lock; /* mutex lock */ - HANDLE mqi_wait; /* and condition variable */ -}; - -#define MQI_MAGIC 0x98765432UL - -#define MSGSIZE(i) roundup((i), sizeof(long)) - -#define MAX_TRIES 10 /* for waiting for initialization */ - -struct mq_attr defattr = { 0, 10, 8192, 0 }; /* Linux defaults. */ - -extern "C" _off64_t lseek64 (int, _off64_t, int); -extern "C" void *mmap64 (void *, size_t, int, int, int, _off64_t); - -extern "C" mqd_t -mq_open (const char *name, int oflag, ...) -{ - int i, fd = -1, nonblock, created; - long msgsize, index; - _off64_t filesize = 0; - va_list ap; - mode_t mode; - int8_t *mptr; - struct __stat64 statbuff; - struct mq_hdr *mqhdr; - struct msg_hdr *msghdr; - struct mq_attr *attr; - struct mq_info *mqinfo; - LUID luid; - - size_t len = strlen (name); - char mqname[ipc_names[mqueue].prefix_len + len]; - - if (!check_path (mqname, mqueue, name, len)) - return (mqd_t) -1; - - myfault efault; - if (efault.faulted (EFAULT)) - return (mqd_t) -1; - - oflag &= (O_CREAT | O_EXCL | O_NONBLOCK); - created = 0; - nonblock = oflag & O_NONBLOCK; - oflag &= ~O_NONBLOCK; - mptr = (int8_t *) MAP_FAILED; - mqinfo = NULL; - -again: - if (oflag & O_CREAT) - { - va_start (ap, oflag); /* init ap to final named argument */ - mode = va_arg (ap, mode_t) & ~S_IXUSR; - attr = va_arg (ap, struct mq_attr *); - va_end (ap); - - /* Open and specify O_EXCL and user-execute */ - fd = open (mqname, oflag | O_EXCL | O_RDWR | O_CLOEXEC, mode | S_IXUSR); - if (fd < 0) - { - if (errno == EEXIST && (oflag & O_EXCL) == 0) - goto exists; /* already exists, OK */ - return (mqd_t) -1; - } - created = 1; - /* First one to create the file initializes it */ - if (attr == NULL) - attr = &defattr; - else if (attr->mq_maxmsg <= 0 || attr->mq_msgsize <= 0) - { - set_errno (EINVAL); - goto err; - } - /* Calculate and set the file size */ - msgsize = MSGSIZE (attr->mq_msgsize); - filesize = sizeof (struct mq_hdr) - + (attr->mq_maxmsg * (sizeof (struct msg_hdr) + msgsize)); - if (lseek64 (fd, filesize - 1, SEEK_SET) == -1) - goto err; - if (write (fd, "", 1) == -1) - goto err; - - /* Memory map the file */ - mptr = (int8_t *) mmap64 (NULL, (size_t) filesize, PROT_READ | PROT_WRITE, - MAP_SHARED, fd, 0); - if (mptr == (int8_t *) MAP_FAILED) - goto err; - - /* Allocate one mq_info{} for the queue */ - if (!(mqinfo = (struct mq_info *) malloc (sizeof (struct mq_info)))) - goto err; - mqinfo->mqi_hdr = mqhdr = (struct mq_hdr *) mptr; - mqinfo->mqi_magic = MQI_MAGIC; - mqinfo->mqi_flags = nonblock; - - /* Initialize header at beginning of file */ - /* Create free list with all messages on it */ - mqhdr->mqh_attr.mq_flags = 0; - mqhdr->mqh_attr.mq_maxmsg = attr->mq_maxmsg; - mqhdr->mqh_attr.mq_msgsize = attr->mq_msgsize; - mqhdr->mqh_attr.mq_curmsgs = 0; - mqhdr->mqh_nwait = 0; - mqhdr->mqh_pid = 0; - if (!AllocateLocallyUniqueId (&luid)) - { - __seterrno (); - goto err; - } - __small_sprintf (mqhdr->mqh_uname, "%016X%08x%08x", - hash_path_name (0,mqname), - luid.HighPart, luid.LowPart); - mqhdr->mqh_head = 0; - index = sizeof (struct mq_hdr); - mqhdr->mqh_free = index; - for (i = 0; i < attr->mq_maxmsg - 1; i++) - { - msghdr = (struct msg_hdr *) &mptr[index]; - index += sizeof (struct msg_hdr) + msgsize; - msghdr->msg_next = index; - } - msghdr = (struct msg_hdr *) &mptr[index]; - msghdr->msg_next = 0; /* end of free list */ - - /* Initialize mutex & condition variable */ - i = ipc_mutex_init (&mqinfo->mqi_lock, mqhdr->mqh_uname); - if (i != 0) - goto pthreaderr; - - i = ipc_cond_init (&mqinfo->mqi_wait, mqhdr->mqh_uname); - if (i != 0) - goto pthreaderr; - - /* Initialization complete, turn off user-execute bit */ - if (fchmod (fd, mode) == -1) - goto err; - close (fd); - return ((mqd_t) mqinfo); - } - -exists: - /* Open the file then memory map */ - if ((fd = open (mqname, O_RDWR | O_CLOEXEC)) < 0) - { - if (errno == ENOENT && (oflag & O_CREAT)) - goto again; - goto err; - } - /* Make certain initialization is complete */ - for (i = 0; i < MAX_TRIES; i++) - { - if (stat64 (mqname, &statbuff) == -1) - { - if (errno == ENOENT && (oflag & O_CREAT)) - { - close (fd); - fd = -1; - goto again; - } - goto err; - } - if ((statbuff.st_mode & S_IXUSR) == 0) - break; - sleep (1); - } - if (i == MAX_TRIES) - { - set_errno (ETIMEDOUT); - goto err; - } - - filesize = statbuff.st_size; - mptr = (int8_t *) mmap64 (NULL, (size_t) filesize, PROT_READ | PROT_WRITE, - MAP_SHARED, fd, 0); - if (mptr == (int8_t *) MAP_FAILED) - goto err; - close (fd); - fd = -1; - - /* Allocate one mq_info{} for each open */ - if (!(mqinfo = (struct mq_info *) malloc (sizeof (struct mq_info)))) - goto err; - mqinfo->mqi_hdr = mqhdr = (struct mq_hdr *) mptr; - mqinfo->mqi_magic = MQI_MAGIC; - mqinfo->mqi_flags = nonblock; - - /* Initialize mutex & condition variable */ - i = ipc_mutex_init (&mqinfo->mqi_lock, mqhdr->mqh_uname); - if (i != 0) - goto pthreaderr; - - i = ipc_cond_init (&mqinfo->mqi_wait, mqhdr->mqh_uname); - if (i != 0) - goto pthreaderr; - - return (mqd_t) mqinfo; - -pthreaderr: - errno = i; -err: - /* Don't let following function calls change errno */ - save_errno save; - - if (created) - unlink (mqname); - if (mptr != (int8_t *) MAP_FAILED) - munmap((void *) mptr, (size_t) filesize); - if (mqinfo) - free (mqinfo); - if (fd >= 0) - close (fd); - return (mqd_t) -1; -} - -extern "C" int -mq_getattr (mqd_t mqd, struct mq_attr *mqstat) -{ - int n; - struct mq_hdr *mqhdr; - struct mq_attr *attr; - struct mq_info *mqinfo; - - myfault efault; - if (efault.faulted (EBADF)) - return -1; - - mqinfo = (struct mq_info *) mqd; - if (mqinfo->mqi_magic != MQI_MAGIC) - { - set_errno (EBADF); - return -1; - } - mqhdr = mqinfo->mqi_hdr; - attr = &mqhdr->mqh_attr; - if ((n = ipc_mutex_lock (mqinfo->mqi_lock)) != 0) - { - errno = n; - return -1; - } - mqstat->mq_flags = mqinfo->mqi_flags; /* per-open */ - mqstat->mq_maxmsg = attr->mq_maxmsg; /* remaining three per-queue */ - mqstat->mq_msgsize = attr->mq_msgsize; - mqstat->mq_curmsgs = attr->mq_curmsgs; - - ipc_mutex_unlock (mqinfo->mqi_lock); - return 0; -} - -extern "C" int -mq_setattr (mqd_t mqd, const struct mq_attr *mqstat, struct mq_attr *omqstat) -{ - int n; - struct mq_hdr *mqhdr; - struct mq_attr *attr; - struct mq_info *mqinfo; - - myfault efault; - if (efault.faulted (EBADF)) - return -1; - - mqinfo = (struct mq_info *) mqd; - if (mqinfo->mqi_magic != MQI_MAGIC) - { - set_errno (EBADF); - return -1; - } - mqhdr = mqinfo->mqi_hdr; - attr = &mqhdr->mqh_attr; - if ((n = ipc_mutex_lock (mqinfo->mqi_lock)) != 0) - { - errno = n; - return -1; - } - - if (omqstat != NULL) - { - omqstat->mq_flags = mqinfo->mqi_flags; /* previous attributes */ - omqstat->mq_maxmsg = attr->mq_maxmsg; - omqstat->mq_msgsize = attr->mq_msgsize; - omqstat->mq_curmsgs = attr->mq_curmsgs; /* and current status */ - } - - if (mqstat->mq_flags & O_NONBLOCK) - mqinfo->mqi_flags |= O_NONBLOCK; - else - mqinfo->mqi_flags &= ~O_NONBLOCK; - - ipc_mutex_unlock (mqinfo->mqi_lock); - return 0; -} - -extern "C" int -mq_notify (mqd_t mqd, const struct sigevent *notification) -{ - int n; - pid_t pid; - struct mq_hdr *mqhdr; - struct mq_info *mqinfo; - - myfault efault; - if (efault.faulted (EBADF)) - return -1; - - mqinfo = (struct mq_info *) mqd; - if (mqinfo->mqi_magic != MQI_MAGIC) - { - set_errno (EBADF); - return -1; - } - mqhdr = mqinfo->mqi_hdr; - if ((n = ipc_mutex_lock (mqinfo->mqi_lock)) != 0) - { - errno = n; - return -1; - } - - pid = getpid (); - if (!notification) - { - if (mqhdr->mqh_pid == pid) - mqhdr->mqh_pid = 0; /* unregister calling process */ - } - else - { - if (mqhdr->mqh_pid != 0) - { - if (kill (mqhdr->mqh_pid, 0) != -1 || errno != ESRCH) - { - set_errno (EBUSY); - ipc_mutex_unlock (mqinfo->mqi_lock); - return -1; - } - } - mqhdr->mqh_pid = pid; - mqhdr->mqh_event = *notification; - } - ipc_mutex_unlock (mqinfo->mqi_lock); - return 0; -} - -static int -_mq_send (mqd_t mqd, const char *ptr, size_t len, unsigned int prio, - const struct timespec *abstime) -{ - int n; - long index, freeindex; - int8_t *mptr; - struct sigevent *sigev; - struct mq_hdr *mqhdr; - struct mq_attr *attr; - struct msg_hdr *msghdr, *nmsghdr, *pmsghdr; - struct mq_info *mqinfo; - - myfault efault; - if (efault.faulted (EBADF)) - return -1; - - mqinfo = (struct mq_info *) mqd; - if (mqinfo->mqi_magic != MQI_MAGIC) - { - set_errno (EBADF); - return -1; - } - if (prio > MQ_PRIO_MAX) - { - set_errno (EINVAL); - return -1; - } - - mqhdr = mqinfo->mqi_hdr; /* struct pointer */ - mptr = (int8_t *) mqhdr; /* byte pointer */ - attr = &mqhdr->mqh_attr; - if ((n = ipc_mutex_lock (mqinfo->mqi_lock)) != 0) - { - errno = n; - return -1; - } - - if (len > (size_t) attr->mq_msgsize) - { - set_errno (EMSGSIZE); - goto err; - } - if (attr->mq_curmsgs == 0) - { - if (mqhdr->mqh_pid != 0 && mqhdr->mqh_nwait == 0) - { - sigev = &mqhdr->mqh_event; - if (sigev->sigev_notify == SIGEV_SIGNAL) - sigqueue (mqhdr->mqh_pid, sigev->sigev_signo, sigev->sigev_value); - mqhdr->mqh_pid = 0; /* unregister */ - } - } - else if (attr->mq_curmsgs >= attr->mq_maxmsg) - { - /* Queue is full */ - if (mqinfo->mqi_flags & O_NONBLOCK) - { - set_errno (EAGAIN); - goto err; - } - /* Wait for room for one message on the queue */ - while (attr->mq_curmsgs >= attr->mq_maxmsg) - ipc_cond_timedwait (mqinfo->mqi_wait, mqinfo->mqi_lock, abstime); - } - - /* nmsghdr will point to new message */ - if ((freeindex = mqhdr->mqh_free) == 0) - api_fatal ("mq_send: curmsgs = %ld; free = 0", attr->mq_curmsgs); - - nmsghdr = (struct msg_hdr *) &mptr[freeindex]; - nmsghdr->msg_prio = prio; - nmsghdr->msg_len = len; - memcpy (nmsghdr + 1, ptr, len); /* copy message from caller */ - mqhdr->mqh_free = nmsghdr->msg_next; /* new freelist head */ - - /* Find right place for message in linked list */ - index = mqhdr->mqh_head; - pmsghdr = (struct msg_hdr *) &(mqhdr->mqh_head); - while (index) - { - msghdr = (struct msg_hdr *) &mptr[index]; - if (prio > msghdr->msg_prio) - { - nmsghdr->msg_next = index; - pmsghdr->msg_next = freeindex; - break; - } - index = msghdr->msg_next; - pmsghdr = msghdr; - } - if (index == 0) - { - /* Queue was empty or new goes at end of list */ - pmsghdr->msg_next = freeindex; - nmsghdr->msg_next = 0; - } - /* Wake up anyone blocked in mq_receive waiting for a message */ - if (attr->mq_curmsgs == 0) - ipc_cond_signal (mqinfo->mqi_wait); - attr->mq_curmsgs++; - - ipc_mutex_unlock (mqinfo->mqi_lock); - return 0; - -err: - ipc_mutex_unlock (mqinfo->mqi_lock); - return -1; -} - -extern "C" int -mq_send (mqd_t mqd, const char *ptr, size_t len, unsigned int prio) -{ - return _mq_send (mqd, ptr, len, prio, NULL); -} - -extern "C" int -mq_timedsend (mqd_t mqd, const char *ptr, size_t len, unsigned int prio, - const struct timespec *abstime) -{ - return _mq_send (mqd, ptr, len, prio, abstime); -} - -static ssize_t -_mq_receive (mqd_t mqd, char *ptr, size_t maxlen, unsigned int *priop, - const struct timespec *abstime) -{ - int n; - long index; - int8_t *mptr; - ssize_t len; - struct mq_hdr *mqhdr; - struct mq_attr *attr; - struct msg_hdr *msghdr; - struct mq_info *mqinfo; - - myfault efault; - if (efault.faulted (EBADF)) - return -1; - - mqinfo = (struct mq_info *) mqd; - if (mqinfo->mqi_magic != MQI_MAGIC) - { - set_errno (EBADF); - return -1; - } - mqhdr = mqinfo->mqi_hdr; /* struct pointer */ - mptr = (int8_t *) mqhdr; /* byte pointer */ - attr = &mqhdr->mqh_attr; - if ((n = ipc_mutex_lock (mqinfo->mqi_lock)) != 0) - { - errno = n; - return -1; - } - - if (maxlen < (size_t) attr->mq_msgsize) - { - set_errno (EMSGSIZE); - goto err; - } - if (attr->mq_curmsgs == 0) /* queue is empty */ - { - if (mqinfo->mqi_flags & O_NONBLOCK) - { - set_errno (EAGAIN); - goto err; - } - /* Wait for a message to be placed onto queue */ - mqhdr->mqh_nwait++; - while (attr->mq_curmsgs == 0) - ipc_cond_timedwait (mqinfo->mqi_wait, mqinfo->mqi_lock, abstime); - mqhdr->mqh_nwait--; - } - - if ((index = mqhdr->mqh_head) == 0) - api_fatal ("mq_receive: curmsgs = %ld; head = 0", attr->mq_curmsgs); - - msghdr = (struct msg_hdr *) &mptr[index]; - mqhdr->mqh_head = msghdr->msg_next; /* new head of list */ - len = msghdr->msg_len; - memcpy(ptr, msghdr + 1, len); /* copy the message itself */ - if (priop != NULL) - *priop = msghdr->msg_prio; - - /* Just-read message goes to front of free list */ - msghdr->msg_next = mqhdr->mqh_free; - mqhdr->mqh_free = index; - - /* Wake up anyone blocked in mq_send waiting for room */ - if (attr->mq_curmsgs == attr->mq_maxmsg) - ipc_cond_signal (mqinfo->mqi_wait); - attr->mq_curmsgs--; - - ipc_mutex_unlock (mqinfo->mqi_lock); - return len; - -err: - ipc_mutex_unlock (mqinfo->mqi_lock); - return -1; -} - -extern "C" ssize_t -mq_receive (mqd_t mqd, char *ptr, size_t maxlen, unsigned int *priop) -{ - return _mq_receive (mqd, ptr, maxlen, priop, NULL); -} - -extern "C" ssize_t -mq_timedreceive (mqd_t mqd, char *ptr, size_t maxlen, unsigned int *priop, - const struct timespec *abstime) -{ - return _mq_receive (mqd, ptr, maxlen, priop, abstime); -} - -extern "C" int -mq_close (mqd_t mqd) -{ - long msgsize, filesize; - struct mq_hdr *mqhdr; - struct mq_attr *attr; - struct mq_info *mqinfo; - - myfault efault; - if (efault.faulted (EBADF)) - return -1; - - mqinfo = (struct mq_info *) mqd; - if (mqinfo->mqi_magic != MQI_MAGIC) - { - set_errno (EBADF); - return -1; - } - mqhdr = mqinfo->mqi_hdr; - attr = &mqhdr->mqh_attr; - - if (mq_notify (mqd, NULL)) /* unregister calling process */ - return -1; - - msgsize = MSGSIZE (attr->mq_msgsize); - filesize = sizeof (struct mq_hdr) - + (attr->mq_maxmsg * (sizeof (struct msg_hdr) + msgsize)); - if (munmap (mqinfo->mqi_hdr, filesize) == -1) - return -1; - - mqinfo->mqi_magic = 0; /* just in case */ - ipc_cond_close (mqinfo->mqi_wait); - ipc_mutex_close (mqinfo->mqi_lock); - free (mqinfo); - return 0; -} - -extern "C" int -mq_unlink (const char *name) -{ - size_t len = strlen (name); - char mqname[ipc_names[mqueue].prefix_len + len]; - - if (!check_path (mqname, mqueue, name, len)) - return -1; - if (unlink (mqname) == -1) - return -1; - return 0; -} - -/* POSIX named semaphore implementation. Loosely based on Richard W. STEPHENS - implementation as far as sem_open is concerned, but under the hood using - the already existing semaphore class in thread.cc. Using a file backed - solution allows to implement kernel persistent named semaphores. */ - -struct sem_finfo -{ - unsigned int value; - unsigned long long hash; - LUID luid; -}; - -extern "C" sem_t * -sem_open (const char *name, int oflag, ...) -{ - int i, fd = -1, created; - va_list ap; - mode_t mode = 0; - unsigned int value = 0; - struct __stat64 statbuff; - sem_t *sem = SEM_FAILED; - sem_finfo sf; - bool wasopen = false; - ipc_flock file; - - size_t len = strlen (name); - char semname[ipc_names[semaphore].prefix_len + len]; - - if (!check_path (semname, semaphore, name, len)) - return SEM_FAILED; - - myfault efault; - if (efault.faulted (EFAULT)) - return SEM_FAILED; - - created = 0; - oflag &= (O_CREAT | O_EXCL); - -again: - if (oflag & O_CREAT) - { - va_start (ap, oflag); /* init ap to final named argument */ - mode = va_arg (ap, mode_t) & ~S_IXUSR; - value = va_arg (ap, unsigned int); - va_end (ap); - - /* Open and specify O_EXCL and user-execute */ - fd = open (semname, oflag | O_EXCL | O_RDWR | O_CLOEXEC, mode | S_IXUSR); - if (fd < 0) - { - if (errno == EEXIST && (oflag & O_EXCL) == 0) - goto exists; /* already exists, OK */ - return SEM_FAILED; - } - created = 1; - /* First one to create the file initializes it. */ - if (!AllocateLocallyUniqueId (&sf.luid)) - { - __seterrno (); - goto err; - } - sf.value = value; - sf.hash = hash_path_name (0, semname); - if (write (fd, &sf, sizeof sf) != sizeof sf) - goto err; - sem = semaphore::open (sf.hash, sf.luid, fd, oflag, mode, value, wasopen); - if (sem == SEM_FAILED) - goto err; - /* Initialization complete, turn off user-execute bit */ - if (fchmod (fd, mode) == -1) - goto err; - /* Don't close (fd); */ - return sem; - } - -exists: - /* Open the file and fetch the semaphore name. */ - if ((fd = open (semname, O_RDWR | O_CLOEXEC)) < 0) - { - if (errno == ENOENT && (oflag & O_CREAT)) - goto again; - goto err; - } - /* Make certain initialization is complete */ - for (i = 0; i < MAX_TRIES; i++) - { - if (stat64 (semname, &statbuff) == -1) - { - if (errno == ENOENT && (oflag & O_CREAT)) - { - close (fd); - fd = -1; - goto again; - } - goto err; - } - if ((statbuff.st_mode & S_IXUSR) == 0) - break; - sleep (1); - } - if (i == MAX_TRIES) - { - set_errno (ETIMEDOUT); - goto err; - } - if (file.lock (fd, sizeof sf)) - goto err; - if (read (fd, &sf, sizeof sf) != sizeof sf) - goto err; - sem = semaphore::open (sf.hash, sf.luid, fd, oflag, mode, sf.value, wasopen); - file.unlock (fd); - if (sem == SEM_FAILED) - goto err; - /* If wasopen is set, the semaphore was already opened and we already have - an open file descriptor pointing to the file. This means, we have to - close the file descriptor created in this call. It won't be stored - anywhere anyway. */ - if (wasopen) - close (fd); - return sem; - -err: - /* Don't let following function calls change errno */ - save_errno save; - - file.unlock (fd); - if (created) - unlink (semname); - if (sem != SEM_FAILED) - semaphore::close (sem); - if (fd >= 0) - close (fd); - return SEM_FAILED; -} - -int -_sem_close (sem_t *sem, bool do_close) -{ - sem_finfo sf; - int fd, ret = -1; - ipc_flock file; - - if (semaphore::getinternal (sem, &fd, &sf.hash, &sf.luid, &sf.value) == -1) - return -1; - if (!file.lock (fd, sizeof sf) - && lseek64 (fd, 0LL, SEEK_SET) != (_off64_t) -1 - && write (fd, &sf, sizeof sf) == sizeof sf) - ret = do_close ? semaphore::close (sem) : 0; - - /* Don't let following function calls change errno */ - save_errno save; - file.unlock (fd); - close (fd); - - return ret; -} - -extern "C" int -sem_close (sem_t *sem) -{ - return _sem_close (sem, true); -} - -extern "C" int -sem_unlink (const char *name) -{ - size_t len = strlen (name); - char semname[ipc_names[semaphore].prefix_len + len]; - - if (!check_path (semname, semaphore, name, len)) - return -1; - if (unlink (semname) == -1) - return -1; - return 0; -} diff --git a/winsup/cygwin/profil.c b/winsup/cygwin/profil.c deleted file mode 100644 index a4f64ae2c..000000000 --- a/winsup/cygwin/profil.c +++ /dev/null @@ -1,173 +0,0 @@ -/* profil.c -- win32 profil.c equivalent - - Copyright 1998, 1999, 2000, 2001, 2003, 2009 Red Hat, Inc. - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#include -#include -#include - -#include - -#define SLEEPTIME (1000 / PROF_HZ) - -/* global profinfo for profil() call */ -static struct profinfo prof; - -/* Get the pc for thread THR */ - -static u_long -get_thrpc (HANDLE thr) -{ - CONTEXT ctx; - u_long pc; - int res; - - res = SuspendThread (thr); - if (res == -1) - return (u_long) - 1; - ctx.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER; - pc = (u_long) - 1; - if (GetThreadContext (thr, &ctx)) - pc = ctx.Eip; - ResumeThread (thr); - return pc; -} - -/* Display cell of profile buffer */ -#if 0 -static void -print_prof (struct profinfo *p) -{ - printf ("profthr %x\ttarget thr %x\n", p->profthr, p->targthr); - printf ("pc: %x - %x\n", p->lowpc, p->highpc); - printf ("scale: %x\n", p->scale); - return; -} -#endif - -/* Everytime we wake up use the main thread pc to hash into the cell in the - profile buffer ARG. */ - -static DWORD CALLBACK -profthr_func (LPVOID arg) -{ - struct profinfo *p = (struct profinfo *) arg; - u_long pc, idx; - - SetThreadPriority(p->profthr, THREAD_PRIORITY_TIME_CRITICAL); - - for (;;) - { - pc = (u_long) get_thrpc (p->targthr); - if (pc >= p->lowpc && pc < p->highpc) - { - idx = PROFIDX (pc, p->lowpc, p->scale); - p->counter[idx]++; - } -#if 0 - print_prof (p); -#endif - Sleep (SLEEPTIME); - } - return 0; -} - -/* Stop profiling to the profiling buffer pointed to by P. */ - -static int -profile_off (struct profinfo *p) -{ - if (p->profthr) - { - TerminateThread (p->profthr, 0); - CloseHandle (p->profthr); - } - if (p->targthr) - CloseHandle (p->targthr); - return 0; -} - -/* Create a timer thread and pass it a pointer P to the profiling buffer. */ - -static int -profile_on (struct profinfo *p) -{ - DWORD thrid; - - /* get handle for this thread */ - if (!DuplicateHandle (GetCurrentProcess (), GetCurrentThread (), - GetCurrentProcess (), &p->targthr, 0, FALSE, - DUPLICATE_SAME_ACCESS)) - { - errno = ESRCH; - return -1; - } - - p->profthr = CreateThread (0, 0, profthr_func, (void *) p, 0, &thrid); - if (!p->profthr) - { - CloseHandle (p->targthr); - p->targthr = 0; - errno = EAGAIN; - return -1; - } - return 0; -} - -/* - * start or stop profiling - * - * profiling goes into the SAMPLES buffer of size SIZE (which is treated - * as an array of u_shorts of size size/2) - * - * each bin represents a range of pc addresses from OFFSET. The number - * of pc addresses in a bin depends on SCALE. (A scale of 65536 maps - * each bin to two addresses, A scale of 32768 maps each bin to 4 addresses, - * a scale of 1 maps each bin to 128k addreses). Scale may be 1 - 65536, - * or zero to turn off profiling - */ -int -profile_ctl (struct profinfo * p, char *samples, size_t size, - u_long offset, u_int scale) -{ - u_long maxbin; - - if (scale > 65536) - { - errno = EINVAL; - return -1; - } - - profile_off (p); - if (scale) - { - memset (samples, 0, size); - memset (p, 0, sizeof *p); - maxbin = size >> 1; - prof.counter = (u_short *) samples; - prof.lowpc = offset; - prof.highpc = PROFADDR (maxbin, offset, scale); - prof.scale = scale; - - return profile_on (p); - } - return 0; -} - -/* Equivalent to unix profil() - Every SLEEPTIME interval, the user's program counter (PC) is examined: - offset is subtracted and the result is multiplied by scale. - The word pointed to by this address is incremented. Buf is unused. */ - -int -profil (char *samples, size_t size, u_long offset, u_int scale) -{ - return profile_ctl (&prof, samples, size, offset, scale); -} - diff --git a/winsup/cygwin/profil.h b/winsup/cygwin/profil.h deleted file mode 100644 index 7ec4dfa09..000000000 --- a/winsup/cygwin/profil.h +++ /dev/null @@ -1,44 +0,0 @@ -/* profil.h: gprof profiling header file - - Copyright 1998, 1999, 2000, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* profiling frequency. (No larger than 1000) */ -#define PROF_HZ 100 - -/* convert an addr to an index */ -#define PROFIDX(pc, base, scale) \ - ({ \ - size_t i = (pc - base) / 2; \ - if (sizeof (unsigned long long int) > sizeof (size_t)) \ - i = (unsigned long long int) i * scale / 65536; \ - else \ - i = i / 65536 * scale + i % 65536 * scale / 65536; \ - i; \ - }) - -/* convert an index into an address */ -#define PROFADDR(idx, base, scale) \ - ((base) + ((((unsigned long long)(idx) << 16) / (scale)) << 1)) - -/* convert a bin size into a scale */ -#define PROFSCALE(range, bins) (((bins) << 16) / ((range) >> 1)) - -typedef void *_WINHANDLE; - -struct profinfo { - _WINHANDLE targthr; /* thread to profile */ - _WINHANDLE profthr; /* profiling thread */ - u_short *counter; /* profiling counters */ - u_long lowpc, highpc; /* range to be profiled */ - u_int scale; /* scale value of bins */ -}; - -int profile_ctl(struct profinfo *, char *, size_t, u_long, u_int); -int profil(char *, size_t, u_long, u_int); - diff --git a/winsup/cygwin/pseudo-reloc.cc b/winsup/cygwin/pseudo-reloc.cc deleted file mode 100644 index 77f041114..000000000 --- a/winsup/cygwin/pseudo-reloc.cc +++ /dev/null @@ -1,367 +0,0 @@ -/* pseudo-reloc.c - - Contributed by Egor Duda - Modified by addition of runtime_pseudo_reloc version 2 - by Kai Tietz - - THIS SOFTWARE IS NOT COPYRIGHTED - - This source code is offered for use in the public domain. You may - use, modify or distribute it freely. - - This code is distributed in the hope that it will be useful but - WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY - DISCLAMED. This includes but is not limited to warrenties of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -*/ - -#include -#include -#include -#include -#include - -#if defined(__CYGWIN__) -#include -#include -#include -/* copied from winsup.h */ -# define NO_COPY __attribute__((nocommon)) __attribute__((section(".data_cygwin_nocopy"))) -/* custom status code: */ -#define STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION ((NTSTATUS) 0xe0000269) -#define SHORT_MSG_BUF_SZ 128 -#else -# define NO_COPY -#endif - -#ifdef __GNUC__ -#define ATTRIBUTE_NORETURN __attribute__ ((noreturn)) -#else -#define ATTRIBUTE_NORETURN -#endif - -#ifndef __MINGW_LSYMBOL -#define __MINGW_LSYMBOL(sym) sym -#endif - -extern char __RUNTIME_PSEUDO_RELOC_LIST__; -extern char __RUNTIME_PSEUDO_RELOC_LIST_END__; -extern char __MINGW_LSYMBOL(_image_base__); - -void _pei386_runtime_relocator (void); - -/* v1 relocation is basically: - * *(base + .target) += .addend - * where (base + .target) is always assumed to point - * to a DWORD (4 bytes). - */ -typedef struct { - DWORD addend; - DWORD target; -} runtime_pseudo_reloc_item_v1; - -/* v2 relocation is more complex. In effect, it is - * *(base + .target) += *(base + .sym) - (base + .sym) - * with care taken in both reading, sign extension, and writing - * because .flags may indicate that (base + .target) may point - * to a BYTE, WORD, DWORD, or QWORD (w64). - */ -typedef struct { - DWORD sym; - DWORD target; - DWORD flags; -} runtime_pseudo_reloc_item_v2; - -typedef struct { - DWORD magic1; - DWORD magic2; - DWORD version; -} runtime_pseudo_reloc_v2; - -static void ATTRIBUTE_NORETURN -__report_error (const char *msg, ...) -{ -#ifdef __CYGWIN__ - /* This function is used to print short error messages - * to stderr, which may occur during DLL initialization - * while fixing up 'pseudo' relocations. This early, we - * may not be able to use cygwin stdio functions, so we - * use the win32 WriteFile api. This should work with both - * normal win32 console IO handles, redirected ones, and - * cygwin ptys. - */ - char buf[SHORT_MSG_BUF_SZ]; - wchar_t module[MAX_PATH]; - char * posix_module = NULL; - static const char UNKNOWN_MODULE[] = ": "; - static const size_t UNKNOWN_MODULE_LEN = sizeof (UNKNOWN_MODULE) - 1; - static const char CYGWIN_FAILURE_MSG[] = "Cygwin runtime failure: "; - static const size_t CYGWIN_FAILURE_MSG_LEN = sizeof (CYGWIN_FAILURE_MSG) - 1; - DWORD len; - DWORD done; - va_list args; - HANDLE errh = GetStdHandle (STD_ERROR_HANDLE); - ssize_t modulelen = GetModuleFileNameW (NULL, module, sizeof (module)); - - if (errh == INVALID_HANDLE_VALUE) - cygwin_internal (CW_EXIT_PROCESS, - STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION, - 1); - - if (modulelen > 0) - posix_module = cygwin_create_path (CCP_WIN_W_TO_POSIX, module); - - va_start (args, msg); - len = (DWORD) vsnprintf (buf, SHORT_MSG_BUF_SZ, msg, args); - va_end (args); - buf[SHORT_MSG_BUF_SZ-1] = '\0'; /* paranoia */ - - if (posix_module) - { - WriteFile (errh, (PCVOID)CYGWIN_FAILURE_MSG, - CYGWIN_FAILURE_MSG_LEN, &done, NULL); - WriteFile (errh, (PCVOID)posix_module, - strlen(posix_module), &done, NULL); - WriteFile (errh, (PCVOID)": ", 2, &done, NULL); - WriteFile (errh, (PCVOID)buf, len, &done, NULL); - free (posix_module); - } - else - { - WriteFile (errh, (PCVOID)CYGWIN_FAILURE_MSG, - CYGWIN_FAILURE_MSG_LEN, &done, NULL); - WriteFile (errh, (PCVOID)UNKNOWN_MODULE, - UNKNOWN_MODULE_LEN, &done, NULL); - WriteFile (errh, (PCVOID)buf, len, &done, NULL); - } - WriteFile (errh, (PCVOID)"\n", 1, &done, NULL); - - cygwin_internal (CW_EXIT_PROCESS, - STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION, - 1); - /* not reached, but silences noreturn warning */ - abort (); -#else - va_list argp; - va_start (argp, msg); -# ifdef __MINGW64_VERSION_MAJOR - fprintf (stderr, "Mingw-w64 runtime failure:\n"); -# else - fprintf (stderr, "Mingw runtime failure:\n"); -# endif - vfprintf (stderr, msg, argp); - va_end (argp); - abort (); -#endif -} - -/* This function temporarily marks the page containing addr - * writable, before copying len bytes from *src to *addr, and - * then restores the original protection settings to the page. - * - * Using this function eliminates the requirement with older - * pseudo-reloc implementations, that sections containing - * pseudo-relocs (such as .text and .rdata) be permanently - * marked writable. This older behavior sabotaged any memory - * savings achieved by shared libraries on win32 -- and was - * slower, too. However, on cygwin as of binutils 2.20 the - * .text section is still marked writable, and the .rdata section - * is folded into the (writable) .data when --enable-auto-import. - */ -static void -__write_memory (void *addr, const void *src, size_t len) -{ - MEMORY_BASIC_INFORMATION b; - DWORD oldprot; - - if (!len) - return; - - if (!VirtualQuery (addr, &b, sizeof(b))) - { - __report_error (" VirtualQuery failed for %d bytes at address %p", - (int) sizeof(b), addr); - } - - /* Temporarily allow write access to read-only protected memory. */ - if (b.Protect != PAGE_EXECUTE_READWRITE && b.Protect != PAGE_READWRITE) - VirtualProtect (b.BaseAddress, b.RegionSize, PAGE_EXECUTE_READWRITE, - &oldprot); - /* write the data. */ - memcpy (addr, src, len); - /* Restore original protection. */ - if (b.Protect != PAGE_EXECUTE_READWRITE && b.Protect != PAGE_READWRITE) - VirtualProtect (b.BaseAddress, b.RegionSize, oldprot, &oldprot); -} - -#define RP_VERSION_V1 0 -#define RP_VERSION_V2 1 - -static void -do_pseudo_reloc (void * start, void * end, void * base) -{ - ptrdiff_t addr_imp, reldata; - ptrdiff_t reloc_target = (ptrdiff_t) ((char *)end - (char*)start); - runtime_pseudo_reloc_v2 *v2_hdr = (runtime_pseudo_reloc_v2 *) start; - runtime_pseudo_reloc_item_v2 *r; - - /* A valid relocation list will contain at least one entry, and - * one v1 data structure (the smallest one) requires two DWORDs. - * So, if the relocation list is smaller than 8 bytes, bail. - */ - if (reloc_target < 8) - return; - - /* Check if this is the old pseudo relocation version. */ - /* There are two kinds of v1 relocation lists: - * 1) With a (v2-style) version header. In this case, the - * first entry in the list is a 3-DWORD structure, with - * value: - * { 0, 0, RP_VERSION_V1 } - * In this case, we skip to the next entry in the list, - * knowing that all elements after the head item can - * be cast to runtime_pseudo_reloc_item_v1. - * 2) Without a (v2-style) version header. In this case, the - * first element in the list IS an actual v1 relocation - * record, which is two DWORDs. Because there will never - * be a case where a v1 relocation record has both - * addend == 0 and target == 0, this case will not be - * confused with the prior one. - * All current binutils, when generating a v1 relocation list, - * use the second (e.g. original) form -- that is, without the - * v2-style version header. - */ - if (reloc_target >= 12 - && v2_hdr->magic1 == 0 && v2_hdr->magic2 == 0 - && v2_hdr->version == RP_VERSION_V1) - { - /* We have a list header item indicating that the rest - * of the list contains v1 entries. Move the pointer to - * the first true v1 relocation record. By definition, - * that v1 element will not have both addend == 0 and - * target == 0 (and thus, when interpreted as a - * runtime_pseudo_reloc_v2, it will not have both - * magic1 == 0 and magic2 == 0). - */ - v2_hdr++; - } - - if (v2_hdr->magic1 != 0 || v2_hdr->magic2 != 0) - { - /************************* - * Handle v1 relocations * - *************************/ - runtime_pseudo_reloc_item_v1 * o; - for (o = (runtime_pseudo_reloc_item_v1 *) v2_hdr; - o < (runtime_pseudo_reloc_item_v1 *)end; - o++) - { - DWORD newval; - reloc_target = (ptrdiff_t) base + o->target; - newval = (*((DWORD*) reloc_target)) + o->addend; - __write_memory ((void *) reloc_target, &newval, sizeof(DWORD)); - } - return; - } - - /* If we got this far, then we have relocations of version 2 or newer */ - - /* Check if this is a known version. */ - if (v2_hdr->version != RP_VERSION_V2) - { - __report_error (" Unknown pseudo relocation protocol version %d.\n", - (int) v2_hdr->version); - return; - } - - /************************* - * Handle v2 relocations * - *************************/ - - /* Walk over header. */ - r = (runtime_pseudo_reloc_item_v2 *) &v2_hdr[1]; - - for (; r < (runtime_pseudo_reloc_item_v2 *) end; r++) - { - /* location where new address will be written */ - reloc_target = (ptrdiff_t) base + r->target; - - /* get sym pointer. It points either to the iat entry - * of the referenced element, or to the stub function. - */ - addr_imp = (ptrdiff_t) base + r->sym; - addr_imp = *((ptrdiff_t *) addr_imp); - - /* read existing relocation value from image, casting to the - * bitsize indicated by the 8 LSBs of flags. If the value is - * negative, manually sign-extend to ptrdiff_t width. Raise an - * error if the bitsize indicated by the 8 LSBs of flags is not - * supported. - */ - switch ((r->flags & 0xff)) - { - case 8: - reldata = (ptrdiff_t) (*((unsigned char *)reloc_target)); - if ((reldata & 0x80) != 0) - reldata |= ~((ptrdiff_t) 0xff); - break; - case 16: - reldata = (ptrdiff_t) (*((unsigned short *)reloc_target)); - if ((reldata & 0x8000) != 0) - reldata |= ~((ptrdiff_t) 0xffff); - break; - case 32: - reldata = (ptrdiff_t) (*((unsigned int *)reloc_target)); -#ifdef _WIN64 - if ((reldata & 0x80000000) != 0) - reldata |= ~((ptrdiff_t) 0xffffffff); -#endif - break; -#ifdef _WIN64 - case 64: - reldata = (ptrdiff_t) (*((unsigned long long *)reloc_target)); - break; -#endif - default: - reldata=0; - __report_error (" Unknown pseudo relocation bit size %d.\n", - (int) (r->flags & 0xff)); - break; - } - - /* Adjust the relocation value */ - reldata -= ((ptrdiff_t) base + r->sym); - reldata += addr_imp; - - /* Write the new relocation value back to *reloc_target */ - switch ((r->flags & 0xff)) - { - case 8: - __write_memory ((void *) reloc_target, &reldata, 1); - break; - case 16: - __write_memory ((void *) reloc_target, &reldata, 2); - break; - case 32: - __write_memory ((void *) reloc_target, &reldata, 4); - break; -#ifdef _WIN64 - case 64: - __write_memory ((void *) reloc_target, &reldata, 8); - break; -#endif - } - } -} - -void -_pei386_runtime_relocator (void) -{ - static NO_COPY int was_init = 0; - if (was_init) - return; - ++was_init; - do_pseudo_reloc (&__RUNTIME_PSEUDO_RELOC_LIST__, - &__RUNTIME_PSEUDO_RELOC_LIST_END__, - &__MINGW_LSYMBOL(_image_base__)); -} diff --git a/winsup/cygwin/pthread.cc b/winsup/cygwin/pthread.cc deleted file mode 100644 index 18f2aea5d..000000000 --- a/winsup/cygwin/pthread.cc +++ /dev/null @@ -1,189 +0,0 @@ -/* pthread.cc: posix pthread interface for Cygwin - - Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2007 Red Hat, Inc. - - Originally written by Marco Fuykschot - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#include "winsup.h" -#include "thread.h" - -extern "C" -{ -/* ThreadCreation */ -int -pthread_create (pthread_t *thread, const pthread_attr_t *attr, - void *(*start_routine) (void *), void *arg) -{ - return pthread::create (thread, attr, start_routine, arg); -} - -int -pthread_once (pthread_once_t * once_control, void (*init_routine) (void)) -{ - return pthread::once (once_control, init_routine); -} - -int -pthread_atfork (void (*prepare)(void), void (*parent)(void), void (*child)(void)) -{ - return pthread::atfork (prepare, parent, child); -} - -/* Thread Exit */ -void -pthread_exit (void *value_ptr) -{ - return pthread::self ()->exit (value_ptr); -} - -int -pthread_join (pthread_t thread, void **return_val) -{ - return pthread::join (&thread, (void **) return_val); -} - -int -pthread_detach (pthread_t thread) -{ - return pthread::detach (&thread); -} - - -/* This isn't a posix call... should we keep it? */ -int -pthread_suspend (pthread_t thread) -{ - return pthread::suspend (&thread); -} - -/* same */ -int -pthread_continue (pthread_t thread) -{ - return pthread::resume (&thread); -} - -unsigned long -pthread_getsequence_np (pthread_t * thread) -{ - if (!pthread::is_good_object (thread)) - return EINVAL; - return (*thread)->getsequence_np (); -} - -/* ID */ - -pthread_t pthread_self () -{ - return pthread::self (); -} - -/* Mutexes */ -int -pthread_mutex_init (pthread_mutex_t * mutex, const pthread_mutexattr_t * attr) -{ - return pthread_mutex::init (mutex, attr, NULL); -} - -/* Synchronisation */ -int -pthread_cond_init (pthread_cond_t * cond, const pthread_condattr_t * attr) -{ - return pthread_cond::init (cond, attr); -} - -/* RW Locks */ -int -pthread_rwlock_init (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) -{ - return pthread_rwlock::init (rwlock, attr); -} - -/* Cancelability */ - -int -pthread_cancel (pthread_t thread) -{ - return pthread::cancel (thread); -} - -int -pthread_setcancelstate (int state, int *oldstate) -{ - return pthread::self ()->setcancelstate (state, oldstate); -} - -int -pthread_setcanceltype (int type, int *oldtype) -{ - return pthread::self ()->setcanceltype (type, oldtype); -} - -void -pthread_testcancel () -{ - pthread::self ()->testcancel (); -} - -void -_pthread_cleanup_push (__pthread_cleanup_handler *handler) -{ - pthread::self ()->push_cleanup_handler (handler); -} - -void -_pthread_cleanup_pop (int execute) -{ - pthread::self ()->pop_cleanup_handler (execute); -} - -/* Semaphores */ -int -sem_init (sem_t * sem, int pshared, unsigned int value) -{ - return semaphore::init (sem, pshared, value); -} - -int -sem_destroy (sem_t * sem) -{ - return semaphore::destroy (sem); -} - -int -sem_wait (sem_t * sem) -{ - return semaphore::wait (sem); -} - -int -sem_trywait (sem_t * sem) -{ - return semaphore::trywait (sem); -} - -int -sem_timedwait (sem_t * sem, const struct timespec *abstime) -{ - return semaphore::timedwait (sem, abstime); -} - -int -sem_post (sem_t * sem) -{ - return semaphore::post (sem); -} - -int -sem_getvalue (sem_t * sem, int *sval) -{ - return semaphore::getvalue (sem, sval); -} - -} diff --git a/winsup/cygwin/pwdgrp.h b/winsup/cygwin/pwdgrp.h deleted file mode 100644 index 00ef2e87a..000000000 --- a/winsup/cygwin/pwdgrp.h +++ /dev/null @@ -1,84 +0,0 @@ -/* pwdgrp.h - - Copyright 2001, 2002, 2003 Red Hat inc. - - Stuff common to pwd and grp handling. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* These functions are needed to allow searching and walking through - the passwd and group lists */ -extern struct passwd *internal_getpwsid (cygpsid &); -extern struct passwd *internal_getpwnam (const char *, bool = FALSE); -extern struct passwd *internal_getpwuid (__uid32_t, bool = FALSE); -extern struct __group32 *internal_getgrsid (cygpsid &); -extern struct __group32 *internal_getgrgid (__gid32_t gid, bool = FALSE); -extern struct __group32 *internal_getgrnam (const char *, bool = FALSE); -extern struct __group32 *internal_getgrent (int); -int internal_getgroups (int, __gid32_t *, cygpsid * = NULL); - -#include "sync.h" -#include "cygtls.h" -class pwdgrp -{ - unsigned pwdgrp_buf_elem_size; - union - { - passwd **passwd_buf; - __group32 **group_buf; - void **pwdgrp_buf; - }; - void (pwdgrp::*read) (); - bool (pwdgrp::*parse) (); - int etc_ix; - UNICODE_STRING upath; - PWCHAR path; - char *buf, *lptr; - int max_lines; - bool initialized; - static muto pglock; - - bool parse_passwd (); - bool parse_group (); - void read_passwd (); - void read_group (); - char *add_line (char *); - char *raw_ptr () const {return lptr;} - char *next_str (char); - bool next_num (unsigned long&); - bool next_num (unsigned int& i) - { - unsigned long x; - bool res = next_num (x); - i = (unsigned int) x; - return res; - } - inline bool next_num (int& i) - { - unsigned long x; - bool res = next_num (x); - i = (int) x; - return res; - } - -public: - int curr_lines; - - void load (const wchar_t *); - inline void refresh (bool check) - { - if (!check && initialized) - return; - if (pglock.acquire () == 1 && - (!initialized || (check && etc::file_changed (etc_ix)))) - (this->*read) (); - pglock.release (); - } - - pwdgrp (passwd *&pbuf); - pwdgrp (__group32 *&gbuf); -}; diff --git a/winsup/cygwin/random.cc b/winsup/cygwin/random.cc deleted file mode 100644 index fe1ac08fd..000000000 --- a/winsup/cygwin/random.cc +++ /dev/null @@ -1,504 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - * 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. - */ - -extern "C" { -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)random.c 8.2 (Berkeley) 5/19/95"; -#endif /* LIBC_SCCS and not lint */ -#include -__FBSDID("$FreeBSD: src/lib/libc/stdlib/random.c,v 1.25 2007/01/09 00:28:10 imp Exp $"); - -#include /* for srandomdev() */ -#include /* for srandomdev() */ -#include -#include -#include /* for srandomdev() */ - -/* - * random.c: - * - * An improved random number generation package. In addition to the standard - * rand()/srand() like interface, this package also has a special state info - * interface. The initstate() routine is called with a seed, an array of - * bytes, and a count of how many bytes are being passed in; this array is - * then initialized to contain information for random number generation with - * that much state information. Good sizes for the amount of state - * information are 32, 64, 128, and 256 bytes. The state can be switched by - * calling the setstate() routine with the same array as was initiallized - * with initstate(). By default, the package runs with 128 bytes of state - * information and generates far better random numbers than a linear - * congruential generator. If the amount of state information is less than - * 32 bytes, a simple linear congruential R.N.G. is used. - * - * Internally, the state information is treated as an array of uint32_t's; the - * zeroeth element of the array is the type of R.N.G. being used (small - * integer); the remainder of the array is the state information for the - * R.N.G. Thus, 32 bytes of state information will give 7 ints worth of - * state information, which will allow a degree seven polynomial. (Note: - * the zeroeth word of state information also has some other information - * stored in it -- see setstate() for details). - * - * The random number generation technique is a linear feedback shift register - * approach, employing trinomials (since there are fewer terms to sum up that - * way). In this approach, the least significant bit of all the numbers in - * the state table will act as a linear feedback shift register, and will - * have period 2^deg - 1 (where deg is the degree of the polynomial being - * used, assuming that the polynomial is irreducible and primitive). The - * higher order bits will have longer periods, since their values are also - * influenced by pseudo-random carries out of the lower bits. The total - * period of the generator is approximately deg*(2**deg - 1); thus doubling - * the amount of state information has a vast influence on the period of the - * generator. Note: the deg*(2**deg - 1) is an approximation only good for - * large deg, when the period of the shift is the dominant factor. - * With deg equal to seven, the period is actually much longer than the - * 7*(2**7 - 1) predicted by this formula. - * - * Modified 28 December 1994 by Jacob S. Rosenberg. - * The following changes have been made: - * All references to the type u_int have been changed to unsigned long. - * All references to type int have been changed to type long. Other - * cleanups have been made as well. A warning for both initstate and - * setstate has been inserted to the effect that on Sparc platforms - * the 'arg_state' variable must be forced to begin on word boundaries. - * This can be easily done by casting a long integer array to char *. - * The overall logic has been left STRICTLY alone. This software was - * tested on both a VAX and Sun SpacsStation with exactly the same - * results. The new version and the original give IDENTICAL results. - * The new version is somewhat faster than the original. As the - * documentation says: "By default, the package runs with 128 bytes of - * state information and generates far better random numbers than a linear - * congruential generator. If the amount of state information is less than - * 32 bytes, a simple linear congruential R.N.G. is used." For a buffer of - * 128 bytes, this new version runs about 19 percent faster and for a 16 - * byte buffer it is about 5 percent faster. - */ - -/* - * For each of the currently supported random number generators, we have a - * break value on the amount of state information (you need at least this - * many bytes of state info to support this random number generator), a degree - * for the polynomial (actually a trinomial) that the R.N.G. is based on, and - * the separation between the two lower order coefficients of the trinomial. - */ -#define TYPE_0 0 /* linear congruential */ -#define BREAK_0 8 -#define DEG_0 0 -#define SEP_0 0 - -#define TYPE_1 1 /* x**7 + x**3 + 1 */ -#define BREAK_1 32 -#define DEG_1 7 -#define SEP_1 3 - -#define TYPE_2 2 /* x**15 + x + 1 */ -#define BREAK_2 64 -#define DEG_2 15 -#define SEP_2 1 - -#define TYPE_3 3 /* x**31 + x**3 + 1 */ -#define BREAK_3 128 -#define DEG_3 31 -#define SEP_3 3 - -#define TYPE_4 4 /* x**63 + x + 1 */ -#define BREAK_4 256 -#define DEG_4 63 -#define SEP_4 1 - -/* - * Array versions of the above information to make code run faster -- - * relies on fact that TYPE_i == i. - */ -#define MAX_TYPES 5 /* max number of types above */ - -#ifdef USE_WEAK_SEEDING -#define NSHUFF 0 -#else /* !USE_WEAK_SEEDING */ -#define NSHUFF 50 /* to drop some "seed -> 1st value" linearity */ -#endif /* !USE_WEAK_SEEDING */ - -static const int degrees[MAX_TYPES] = { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 }; -static const int seps [MAX_TYPES] = { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 }; - -/* - * Initially, everything is set up as if from: - * - * initstate(1, randtbl, 128); - * - * Note that this initialization takes advantage of the fact that srandom() - * advances the front and rear pointers 10*rand_deg times, and hence the - * rear pointer which starts at 0 will also end up at zero; thus the zeroeth - * element of the state information, which contains info about the current - * position of the rear pointer is just - * - * MAX_TYPES * (rptr - state) + TYPE_3 == TYPE_3. - */ - -static uint32_t randtbl[DEG_3 + 1] = { - TYPE_3, -#ifdef USE_WEAK_SEEDING -/* Historic implementation compatibility */ -/* The random sequences do not vary much with the seed */ - 0x9a319039, 0x32d9c024, 0x9b663182, 0x5da1f342, 0xde3b81e0, 0xdf0a6fb5, - 0xf103bc02, 0x48f340fb, 0x7449e56b, 0xbeb1dbb0, 0xab5c5918, 0x946554fd, - 0x8c2e680f, 0xeb3d799f, 0xb11ee0b7, 0x2d436b86, 0xda672e2a, 0x1588ca88, - 0xe369735d, 0x904f35f7, 0xd7158fd6, 0x6fa6f051, 0x616e6b96, 0xac94efdc, - 0x36413f93, 0xc622c298, 0xf5a42ab8, 0x8a88d77b, 0xf5ad9d0e, 0x8999220b, - 0x27fb47b9, -#else /* !USE_WEAK_SEEDING */ - 0x991539b1, 0x16a5bce3, 0x6774a4cd, 0x3e01511e, 0x4e508aaa, 0x61048c05, - 0xf5500617, 0x846b7115, 0x6a19892c, 0x896a97af, 0xdb48f936, 0x14898454, - 0x37ffd106, 0xb58bff9c, 0x59e17104, 0xcf918a49, 0x09378c83, 0x52c7a471, - 0x8d293ea9, 0x1f4fc301, 0xc3db71be, 0x39b44e1c, 0xf8a44ef9, 0x4c8b80b1, - 0x19edc328, 0x87bf4bdd, 0xc9b240e5, 0xe9ee4b1b, 0x4382aee7, 0x535b6b41, - 0xf3bec5da -#endif /* !USE_WEAK_SEEDING */ -}; - -/* - * fptr and rptr are two pointers into the state info, a front and a rear - * pointer. These two pointers are always rand_sep places aparts, as they - * cycle cyclically through the state information. (Yes, this does mean we - * could get away with just one pointer, but the code for random() is more - * efficient this way). The pointers are left positioned as they would be - * from the call - * - * initstate(1, randtbl, 128); - * - * (The position of the rear pointer, rptr, is really 0 (as explained above - * in the initialization of randtbl) because the state table pointer is set - * to point to randtbl[1] (as explained below). - */ -static uint32_t *fptr = &randtbl[SEP_3 + 1]; -static uint32_t *rptr = &randtbl[1]; - -/* - * The following things are the pointer to the state information table, the - * type of the current generator, the degree of the current polynomial being - * used, and the separation between the two pointers. Note that for efficiency - * of random(), we remember the first location of the state information, not - * the zeroeth. Hence it is valid to access state[-1], which is used to - * store the type of the R.N.G. Also, we remember the last location, since - * this is more efficient than indexing every time to find the address of - * the last element to see if the front and rear pointers have wrapped. - */ -static uint32_t *state = &randtbl[1]; -static int rand_type = TYPE_3; -static int rand_deg = DEG_3; -static int rand_sep = SEP_3; -static uint32_t *end_ptr = &randtbl[DEG_3 + 1]; - -static inline uint32_t good_rand (int32_t x) -{ -#ifdef USE_WEAK_SEEDING -/* - * Historic implementation compatibility. - * The random sequences do not vary much with the seed, - * even with overflowing. - */ - return (1103515245 * x + 12345); -#else /* !USE_WEAK_SEEDING */ -/* - * Compute x = (7^5 * x) mod (2^31 - 1) - * wihout overflowing 31 bits: - * (2^31 - 1) = 127773 * (7^5) + 2836 - * From "Random number generators: good ones are hard to find", - * Park and Miller, Communications of the ACM, vol. 31, no. 10, - * October 1988, p. 1195. - */ - int32_t hi, lo; - - /* Can't be initialized with 0, so use another value. */ - if (x == 0) - x = 123459876; - hi = x / 127773; - lo = x % 127773; - x = 16807 * lo - 2836 * hi; - if (x < 0) - x += 0x7fffffff; - return (x); -#endif /* !USE_WEAK_SEEDING */ -} - -/* - * srandom: - * - * Initialize the random number generator based on the given seed. If the - * type is the trivial no-state-information type, just remember the seed. - * Otherwise, initializes state[] based on the given "seed" via a linear - * congruential generator. Then, the pointers are set to known locations - * that are exactly rand_sep places apart. Lastly, it cycles the state - * information a given number of times to get rid of any initial dependencies - * introduced by the L.C.R.N.G. Note that the initialization of randtbl[] - * for default usage relies on values produced by this routine. - */ -void -srandom(unsigned x) -{ - int i, lim; - - state[0] = (uint32_t)x; - if (rand_type == TYPE_0) - lim = NSHUFF; - else { - for (i = 1; i < rand_deg; i++) - state[i] = good_rand(state[i - 1]); - fptr = &state[rand_sep]; - rptr = &state[0]; - lim = 10 * rand_deg; - } - for (i = 0; i < lim; i++) - (void)random(); -} - -/* Avoid a compiler warning when we really want to get at the junk in - an uninitialized variable. */ -static unsigned long -dummy (unsigned volatile long *x) -{ - return *x; -} - -/* - * srandomdev: - * - * Many programs choose the seed value in a totally predictable manner. - * This often causes problems. We seed the generator using the much more - * secure random(4) interface. Note that this particular seeding - * procedure can generate states which are impossible to reproduce by - * calling srandom() with any value, since the succeeding terms in the - * state buffer are no longer derived from the LC algorithm applied to - * a fixed seed. - */ -void -srandomdev() -{ - int fd, done; - size_t len; - - if (rand_type == TYPE_0) - len = sizeof state[0]; - else - len = rand_deg * sizeof state[0]; - - done = 0; - fd = open("/dev/random", O_RDONLY, 0); - if (fd >= 0) { - if (read(fd, (void *) state, len) == (ssize_t) len) - done = 1; - close(fd); - } - - if (!done) { - struct timeval tv; - unsigned long junk; - - gettimeofday(&tv, NULL); - srandom((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec ^ dummy(&junk)); - return; - } - - if (rand_type != TYPE_0) { - fptr = &state[rand_sep]; - rptr = &state[0]; - } -} - -/* - * initstate: - * - * Initialize the state information in the given array of n bytes for future - * random number generation. Based on the number of bytes we are given, and - * the break values for the different R.N.G.'s, we choose the best (largest) - * one we can and set things up for it. srandom() is then called to - * initialize the state information. - * - * Note that on return from srandom(), we set state[-1] to be the type - * multiplexed with the current value of the rear pointer; this is so - * successive calls to initstate() won't lose this information and will be - * able to restart with setstate(). - * - * Note: the first thing we do is save the current state, if any, just like - * setstate() so that it doesn't matter when initstate is called. - * - * Returns a pointer to the old state. - * - * Note: The Sparc platform requires that arg_state begin on an int - * word boundary; otherwise a bus error will occur. Even so, lint will - * complain about mis-alignment, but you should disregard these messages. - */ -char * -initstate(unsigned seed, /* seed for R.N.G. */ - char *arg_state, /* pointer to state array */ - size_t n) /* # bytes of state info */ -{ - char *ostate = (char *)(&state[-1]); - uint32_t *int_arg_state = (uint32_t *)arg_state; - - if (rand_type == TYPE_0) - state[-1] = rand_type; - else - state[-1] = MAX_TYPES * (rptr - state) + rand_type; - if (n < BREAK_0) { - (void)fprintf(stderr, - "random: not enough state (%lu bytes); ignored.\n", - (unsigned long) n); - return(0); - } - if (n < BREAK_1) { - rand_type = TYPE_0; - rand_deg = DEG_0; - rand_sep = SEP_0; - } else if (n < BREAK_2) { - rand_type = TYPE_1; - rand_deg = DEG_1; - rand_sep = SEP_1; - } else if (n < BREAK_3) { - rand_type = TYPE_2; - rand_deg = DEG_2; - rand_sep = SEP_2; - } else if (n < BREAK_4) { - rand_type = TYPE_3; - rand_deg = DEG_3; - rand_sep = SEP_3; - } else { - rand_type = TYPE_4; - rand_deg = DEG_4; - rand_sep = SEP_4; - } - state = int_arg_state + 1; /* first location */ - end_ptr = &state[rand_deg]; /* must set end_ptr before srandom */ - srandom(seed); - if (rand_type == TYPE_0) - int_arg_state[0] = rand_type; - else - int_arg_state[0] = MAX_TYPES * (rptr - state) + rand_type; - return(ostate); -} - -/* - * setstate: - * - * Restore the state from the given state array. - * - * Note: it is important that we also remember the locations of the pointers - * in the current state information, and restore the locations of the pointers - * from the old state information. This is done by multiplexing the pointer - * location into the zeroeth word of the state information. - * - * Note that due to the order in which things are done, it is OK to call - * setstate() with the same state as the current state. - * - * Returns a pointer to the old state information. - * - * Note: The Sparc platform requires that arg_state begin on an int - * word boundary; otherwise a bus error will occur. Even so, lint will - * complain about mis-alignment, but you should disregard these messages. - */ -char * -setstate(const char *arg_state /* pointer to state array */) -{ - uint32_t *new_state = (uint32_t *)arg_state; - uint32_t type = new_state[0] % MAX_TYPES; - uint32_t rear = new_state[0] / MAX_TYPES; - char *ostate = (char *)(&state[-1]); - - if (rand_type == TYPE_0) - state[-1] = rand_type; - else - state[-1] = MAX_TYPES * (rptr - state) + rand_type; - switch(type) { - case TYPE_0: - case TYPE_1: - case TYPE_2: - case TYPE_3: - case TYPE_4: - rand_type = type; - rand_deg = degrees[type]; - rand_sep = seps[type]; - break; - default: - (void)fprintf(stderr, - "random: state info corrupted; not changed.\n"); - } - state = new_state + 1; - if (rand_type != TYPE_0) { - rptr = &state[rear]; - fptr = &state[(rear + rand_sep) % rand_deg]; - } - end_ptr = &state[rand_deg]; /* set end_ptr too */ - return(ostate); -} - -/* - * random: - * - * If we are using the trivial TYPE_0 R.N.G., just do the old linear - * congruential bit. Otherwise, we do our fancy trinomial stuff, which is - * the same in all the other cases due to all the global variables that have - * been set up. The basic operation is to add the number at the rear pointer - * into the one at the front pointer. Then both pointers are advanced to - * the next location cyclically in the table. The value returned is the sum - * generated, reduced to 31 bits by throwing away the "least random" low bit. - * - * Note: the code takes advantage of the fact that both the front and - * rear pointers can't wrap on the same call by not testing the rear - * pointer if the front one has wrapped. - * - * Returns a 31-bit random number. - */ -long -random() -{ - uint32_t i; - uint32_t *f, *r; - - if (rand_type == TYPE_0) { - i = state[0]; - state[0] = i = (good_rand(i)) & 0x7fffffff; - } else { - /* - * Use local variables rather than static variables for speed. - */ - f = fptr; r = rptr; - *f += *r; - i = (*f >> 1) & 0x7fffffff; /* chucking least random bit */ - if (++f >= end_ptr) { - f = state; - ++r; - } - else if (++r >= end_ptr) { - r = state; - } - - fptr = f; rptr = r; - } - return((long)i); -} -} diff --git a/winsup/cygwin/regex/COPYRIGHT b/winsup/cygwin/regex/COPYRIGHT deleted file mode 100644 index dc823b124..000000000 --- a/winsup/cygwin/regex/COPYRIGHT +++ /dev/null @@ -1,52 +0,0 @@ -Copyright 1992, 1993, 1994 Henry Spencer. All rights reserved. -This software is not subject to any license of the American Telephone -and Telegraph Company or of the Regents of the University of California. - -Permission is granted to anyone to use this software for any purpose on -any computer system, and to alter it and redistribute it, subject -to the following restrictions: - -1. The author is not responsible for the consequences of use of this - software, no matter how awful, even if they arise from flaws in it. - -2. The origin of this software must not be misrepresented, either by - explicit claim or by omission. Since few users ever read sources, - credits must appear in the documentation. - -3. Altered versions must be plainly marked as such, and must not be - misrepresented as being the original software. Since few users - ever read sources, credits must appear in the documentation. - -4. This notice may not be removed or altered. - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -/*- - * Copyright (c) 1994 - * The Regents of the University of California. All rights reserved. - * - * 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. - * 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. - * - * @(#)COPYRIGHT 8.1 (Berkeley) 3/16/94 - */ diff --git a/winsup/cygwin/regex/cname.h b/winsup/cygwin/regex/cname.h deleted file mode 100644 index 4ad1ea93b..000000000 --- a/winsup/cygwin/regex/cname.h +++ /dev/null @@ -1,138 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 1994 Henry Spencer. - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * 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. - * 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. - * - * @(#)cname.h 8.3 (Berkeley) 3/20/94 - * $FreeBSD: src/lib/libc/regex/cname.h,v 1.4 2007/01/09 00:28:04 imp Exp $ - */ - -/* character-name table */ -static struct cname { - const char *name; - char code; -} cnames[] = { - {"NUL", '\0'}, - {"SOH", '\001'}, - {"STX", '\002'}, - {"ETX", '\003'}, - {"EOT", '\004'}, - {"ENQ", '\005'}, - {"ACK", '\006'}, - {"BEL", '\007'}, - {"alert", '\007'}, - {"BS", '\010'}, - {"backspace", '\b'}, - {"HT", '\011'}, - {"tab", '\t'}, - {"LF", '\012'}, - {"newline", '\n'}, - {"VT", '\013'}, - {"vertical-tab", '\v'}, - {"FF", '\014'}, - {"form-feed", '\f'}, - {"CR", '\015'}, - {"carriage-return", '\r'}, - {"SO", '\016'}, - {"SI", '\017'}, - {"DLE", '\020'}, - {"DC1", '\021'}, - {"DC2", '\022'}, - {"DC3", '\023'}, - {"DC4", '\024'}, - {"NAK", '\025'}, - {"SYN", '\026'}, - {"ETB", '\027'}, - {"CAN", '\030'}, - {"EM", '\031'}, - {"SUB", '\032'}, - {"ESC", '\033'}, - {"IS4", '\034'}, - {"FS", '\034'}, - {"IS3", '\035'}, - {"GS", '\035'}, - {"IS2", '\036'}, - {"RS", '\036'}, - {"IS1", '\037'}, - {"US", '\037'}, - {"space", ' '}, - {"exclamation-mark", '!'}, - {"quotation-mark", '"'}, - {"number-sign", '#'}, - {"dollar-sign", '$'}, - {"percent-sign", '%'}, - {"ampersand", '&'}, - {"apostrophe", '\''}, - {"left-parenthesis", '('}, - {"right-parenthesis", ')'}, - {"asterisk", '*'}, - {"plus-sign", '+'}, - {"comma", ','}, - {"hyphen", '-'}, - {"hyphen-minus", '-'}, - {"period", '.'}, - {"full-stop", '.'}, - {"slash", '/'}, - {"solidus", '/'}, - {"zero", '0'}, - {"one", '1'}, - {"two", '2'}, - {"three", '3'}, - {"four", '4'}, - {"five", '5'}, - {"six", '6'}, - {"seven", '7'}, - {"eight", '8'}, - {"nine", '9'}, - {"colon", ':'}, - {"semicolon", ';'}, - {"less-than-sign", '<'}, - {"equals-sign", '='}, - {"greater-than-sign", '>'}, - {"question-mark", '?'}, - {"commercial-at", '@'}, - {"left-square-bracket", '['}, - {"backslash", '\\'}, - {"reverse-solidus", '\\'}, - {"right-square-bracket",']'}, - {"circumflex", '^'}, - {"circumflex-accent", '^'}, - {"underscore", '_'}, - {"low-line", '_'}, - {"grave-accent", '`'}, - {"left-brace", '{'}, - {"left-curly-bracket", '{'}, - {"vertical-line", '|'}, - {"right-brace", '}'}, - {"right-curly-bracket", '}'}, - {"tilde", '~'}, - {"DEL", '\177'}, - {NULL, 0} -}; diff --git a/winsup/cygwin/regex/engine.c b/winsup/cygwin/regex/engine.c deleted file mode 100644 index 4afaf8d9a..000000000 --- a/winsup/cygwin/regex/engine.c +++ /dev/null @@ -1,1197 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 1994 Henry Spencer. - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * 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. - * 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. - * - * @(#)engine.c 8.5 (Berkeley) 3/20/94 - */ - -#include -__FBSDID("$FreeBSD: src/lib/libc/regex/engine.c,v 1.23 2009/09/16 06:32:23 dds Exp $"); - -/* - * The matching engine and friends. This file is #included by regexec.c - * after suitable #defines of a variety of macros used herein, so that - * different state representations can be used without duplicating masses - * of code. - */ - -#ifdef SNAMES -#define matcher smatcher -#define fast sfast -#define slow sslow -#define dissect sdissect -#define backref sbackref -#define step sstep -#define print sprint -#define at sat -#define match smat -#endif -#ifdef LNAMES -#define matcher lmatcher -#define fast lfast -#define slow lslow -#define dissect ldissect -#define backref lbackref -#define step lstep -#define print lprint -#define at lat -#define match lmat -#endif -#ifdef MNAMES -#define matcher mmatcher -#define fast mfast -#define slow mslow -#define dissect mdissect -#define backref mbackref -#define step mstep -#define print mprint -#define at mat -#define match mmat -#endif - -/* another structure passed up and down to avoid zillions of parameters */ -struct match { - struct re_guts *g; - int eflags; - regmatch_t *pmatch; /* [nsub+1] (0 element unused) */ - const char *offp; /* offsets work from here */ - const char *beginp; /* start of string -- virtual NUL precedes */ - const char *endp; /* end of string -- virtual NUL here */ - const char *coldp; /* can be no match starting before here */ - const char **lastpos; /* [nplus+1] */ - STATEVARS; - states st; /* current states */ - states fresh; /* states for a fresh start */ - states tmp; /* temporary */ - states empty; /* empty set of states */ - mbstate_t mbs; /* multibyte conversion state */ -}; - -/* ========= begin header generated by ./mkh ========= */ -#ifdef __cplusplus -extern "C" { -#endif - -/* === engine.c === */ -static int matcher(struct re_guts *g, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags); -static const char *dissect(struct match *m, const char *start, const char *stop, sopno startst, sopno stopst); -static const char *backref(struct match *m, const char *start, const char *stop, sopno startst, sopno stopst, sopno lev, int); -static const char *fast(struct match *m, const char *start, const char *stop, sopno startst, sopno stopst); -static const char *slow(struct match *m, const char *start, const char *stop, sopno startst, sopno stopst); -static states step(struct re_guts *g, sopno start, sopno stop, states bef, wint_t ch, states aft); -#define MAX_RECURSION 100 -#define BOL (OUT-1) -#define EOL (BOL-1) -#define BOLEOL (BOL-2) -#define NOTHING (BOL-3) -#define BOW (BOL-4) -#define EOW (BOL-5) -#define BADCHAR (BOL-6) -/* When using wint_t, which is defined as unsigned int on BSD, - as well as on Cygwin or Linux, the NONCHAR test is broken without - the below cast. I'm wondering how this is supposed to work at all... */ -#define NONCHAR(c) ((int)(c) <= OUT) -#ifdef REDEBUG -static void print(struct match *m, const char *caption, states st, int ch, FILE *d); -#endif -#ifdef REDEBUG -static void at(struct match *m, const char *title, const char *start, const char *stop, sopno startst, sopno stopst); -#endif -#ifdef REDEBUG -static const char *pchar(int ch); -#endif - -#ifdef __cplusplus -} -#endif -/* ========= end header generated by ./mkh ========= */ - -#ifdef REDEBUG -#define SP(t, s, c) print(m, t, s, c, stdout) -#define AT(t, p1, p2, s1, s2) at(m, t, p1, p2, s1, s2) -#define NOTE(str) { if (m->eflags®_TRACE) printf("=%s\n", (str)); } -#else -#define SP(t, s, c) /* nothing */ -#define AT(t, p1, p2, s1, s2) /* nothing */ -#define NOTE(s) /* nothing */ -#endif - -/* - - matcher - the actual matching engine - == static int matcher(struct re_guts *g, const char *string, \ - == size_t nmatch, regmatch_t pmatch[], int eflags); - */ -static int /* 0 success, REG_NOMATCH failure */ -matcher(struct re_guts *g, - const char *string, - size_t nmatch, - regmatch_t pmatch[], - int eflags) -{ - const char *endp; - int i; - struct match mv; - struct match *m = &mv; - const char *dp; - const sopno gf = g->firststate+1; /* +1 for OEND */ - const sopno gl = g->laststate; - const char *start; - const char *stop; - /* Boyer-Moore algorithms variables */ - const char *pp; - int cj, mj; - const char *mustfirst; - const char *mustlast; - int *matchjump; - int *charjump; - - /* simplify the situation where possible */ - if (g->cflags®_NOSUB) - nmatch = 0; - if (eflags®_STARTEND) { - start = string + pmatch[0].rm_so; - stop = string + pmatch[0].rm_eo; - } else { - start = string; - stop = start + strlen(start); - } - if (stop < start) - return(REG_INVARG); - - /* prescreening; this does wonders for this rather slow code */ - if (g->must != NULL) { - if (g->charjump != NULL && g->matchjump != NULL) { - mustfirst = g->must; - mustlast = g->must + g->mlen - 1; - charjump = g->charjump; - matchjump = g->matchjump; - pp = mustlast; - for (dp = start+g->mlen-1; dp < stop;) { - /* Fast skip non-matches */ - while (dp < stop && charjump[(int)*dp]) - dp += charjump[(int)*dp]; - - if (dp >= stop) - break; - - /* Greedy matcher */ - /* We depend on not being used for - * for strings of length 1 - */ - while (*--dp == *--pp && pp != mustfirst); - - if (*dp == *pp) - break; - - /* Jump to next possible match */ - mj = matchjump[pp - mustfirst]; - cj = charjump[(int)*dp]; - dp += (cj < mj ? mj : cj); - pp = mustlast; - } - if (pp != mustfirst) - return(REG_NOMATCH); - } else { - for (dp = start; dp < stop; dp++) - if (*dp == g->must[0] && - stop - dp >= g->mlen && - memcmp(dp, g->must, (size_t)g->mlen) == 0) - break; - if (dp == stop) /* we didn't find g->must */ - return(REG_NOMATCH); - } - } - - /* match struct setup */ - m->g = g; - m->eflags = eflags; - m->pmatch = NULL; - m->lastpos = NULL; - m->offp = string; - m->beginp = start; - m->endp = stop; - STATESETUP(m, 4); - SETUP(m->st); - SETUP(m->fresh); - SETUP(m->tmp); - SETUP(m->empty); - CLEAR(m->empty); - ZAPSTATE(&m->mbs); - - /* Adjust start according to moffset, to speed things up */ -#ifndef MNAMES - /* The code evaluating moffset doesn't seem to work right - in the multibyte case. */ - if (g->moffset > -1) - start = ((dp - g->moffset) < start) ? start : dp - g->moffset; -#endif - SP("mloop", m->st, *start); - - /* this loop does only one repetition except for backrefs */ - for (;;) { - endp = fast(m, start, stop, gf, gl); - if (endp == NULL) { /* a miss */ - if (m->pmatch != NULL) - free((char *)m->pmatch); - if (m->lastpos != NULL) - free((char *)m->lastpos); - STATETEARDOWN(m); - return(REG_NOMATCH); - } - if (nmatch == 0 && !g->backrefs) - break; /* no further info needed */ - - /* where? */ - assert(m->coldp != NULL); - for (;;) { - NOTE("finding start"); - endp = slow(m, m->coldp, stop, gf, gl); - if (endp != NULL) - break; - assert(m->coldp < m->endp); - m->coldp += XMBRTOWC(NULL, m->coldp, - m->endp - m->coldp, &m->mbs, 0); - } - if (nmatch == 1 && !g->backrefs) - break; /* no further info needed */ - - /* oh my, he wants the subexpressions... */ - if (m->pmatch == NULL) - m->pmatch = (regmatch_t *)malloc((m->g->nsub + 1) * - sizeof(regmatch_t)); - if (m->pmatch == NULL) { - STATETEARDOWN(m); - return(REG_ESPACE); - } - for (i = 1; i <= m->g->nsub; i++) - m->pmatch[i].rm_so = m->pmatch[i].rm_eo = -1; - if (!g->backrefs && !(m->eflags®_BACKR)) { - NOTE("dissecting"); - dp = dissect(m, m->coldp, endp, gf, gl); - } else { - if (g->nplus > 0 && m->lastpos == NULL) - m->lastpos = malloc((g->nplus+1) * - sizeof(const char *)); - if (g->nplus > 0 && m->lastpos == NULL) { - free(m->pmatch); - STATETEARDOWN(m); - return(REG_ESPACE); - } - NOTE("backref dissect"); - dp = backref(m, m->coldp, endp, gf, gl, (sopno)0, 0); - } - if (dp != NULL) - break; - - /* uh-oh... we couldn't find a subexpression-level match */ - assert(g->backrefs); /* must be back references doing it */ - assert(g->nplus == 0 || m->lastpos != NULL); - for (;;) { - if (dp != NULL || endp <= m->coldp) - break; /* defeat */ - NOTE("backoff"); - endp = slow(m, m->coldp, endp-1, gf, gl); - if (endp == NULL) - break; /* defeat */ - /* try it on a shorter possibility */ -#ifndef NDEBUG - for (i = 1; i <= m->g->nsub; i++) { - assert(m->pmatch[i].rm_so == -1); - assert(m->pmatch[i].rm_eo == -1); - } -#endif - NOTE("backoff dissect"); - dp = backref(m, m->coldp, endp, gf, gl, (sopno)0, 0); - } - assert(dp == NULL || dp == endp); - if (dp != NULL) /* found a shorter one */ - break; - - /* despite initial appearances, there is no match here */ - NOTE("false alarm"); - /* recycle starting later */ - start = m->coldp + XMBRTOWC(NULL, m->coldp, - stop - m->coldp, &m->mbs, 0); - assert(start <= stop); - } - - /* fill in the details if requested */ - if (nmatch > 0) { - pmatch[0].rm_so = m->coldp - m->offp; - pmatch[0].rm_eo = endp - m->offp; - } - if (nmatch > 1) { - assert(m->pmatch != NULL); - for (i = 1; i < nmatch; i++) - if (i <= m->g->nsub) - pmatch[i] = m->pmatch[i]; - else { - pmatch[i].rm_so = -1; - pmatch[i].rm_eo = -1; - } - } - - if (m->pmatch != NULL) - free((char *)m->pmatch); - if (m->lastpos != NULL) - free((char *)m->lastpos); - STATETEARDOWN(m); - return(0); -} - -/* - - dissect - figure out what matched what, no back references - == static const char *dissect(struct match *m, const char *start, \ - == const char *stop, sopno startst, sopno stopst); - */ -static const char * /* == stop (success) always */ -dissect(struct match *m, - const char *start, - const char *stop, - sopno startst, - sopno stopst) -{ - int i; - sopno ss; /* start sop of current subRE */ - sopno es; /* end sop of current subRE */ - const char *sp; /* start of string matched by it */ - const char *stp; /* string matched by it cannot pass here */ - const char *rest; /* start of rest of string */ - const char *tail; /* string unmatched by rest of RE */ - sopno ssub; /* start sop of subsubRE */ - sopno esub; /* end sop of subsubRE */ - const char *ssp; /* start of string matched by subsubRE */ - const char *sep; /* end of string matched by subsubRE */ - const char *oldssp; /* previous ssp */ - const char *dp; - - AT("diss", start, stop, startst, stopst); - sp = start; - for (ss = startst; ss < stopst; ss = es) { - /* identify end of subRE */ - es = ss; - switch (OP(m->g->strip[es])) { - case OPLUS_: - case OQUEST_: - es += OPND(m->g->strip[es]); - break; - case OCH_: - while (OP(m->g->strip[es]) != O_CH) - es += OPND(m->g->strip[es]); - break; - } - es++; - - /* figure out what it matched */ - switch (OP(m->g->strip[ss])) { - case OEND: - assert(nope); - break; - case OCHAR: - sp += XMBRTOWC(NULL, sp, stop - start, &m->mbs, 0); - break; - case OBOL: - case OEOL: - case OBOW: - case OEOW: - break; - case OANY: - case OANYOF: - sp += XMBRTOWC(NULL, sp, stop - start, &m->mbs, 0); - break; - case OBACK_: - case O_BACK: - assert(nope); - break; - /* cases where length of match is hard to find */ - case OQUEST_: - stp = stop; - for (;;) { - /* how long could this one be? */ - rest = slow(m, sp, stp, ss, es); - assert(rest != NULL); /* it did match */ - /* could the rest match the rest? */ - tail = slow(m, rest, stop, es, stopst); - if (tail == stop) - break; /* yes! */ - /* no -- try a shorter match for this one */ - stp = rest - 1; - assert(stp >= sp); /* it did work */ - } - ssub = ss + 1; - esub = es - 1; - /* did innards match? */ - if (slow(m, sp, rest, ssub, esub) != NULL) { - dp = dissect(m, sp, rest, ssub, esub); - assert(dp == rest); - } else /* no */ - assert(sp == rest); - sp = rest; - break; - case OPLUS_: - stp = stop; - for (;;) { - /* how long could this one be? */ - rest = slow(m, sp, stp, ss, es); - assert(rest != NULL); /* it did match */ - /* could the rest match the rest? */ - tail = slow(m, rest, stop, es, stopst); - if (tail == stop) - break; /* yes! */ - /* no -- try a shorter match for this one */ - stp = rest - 1; - assert(stp >= sp); /* it did work */ - } - ssub = ss + 1; - esub = es - 1; - ssp = sp; - oldssp = ssp; - for (;;) { /* find last match of innards */ - sep = slow(m, ssp, rest, ssub, esub); - if (sep == NULL || sep == ssp) - break; /* failed or matched null */ - oldssp = ssp; /* on to next try */ - ssp = sep; - } - if (sep == NULL) { - /* last successful match */ - sep = ssp; - ssp = oldssp; - } - assert(sep == rest); /* must exhaust substring */ - assert(slow(m, ssp, sep, ssub, esub) == rest); - dp = dissect(m, ssp, sep, ssub, esub); - assert(dp == sep); - sp = rest; - break; - case OCH_: - stp = stop; - for (;;) { - /* how long could this one be? */ - rest = slow(m, sp, stp, ss, es); - assert(rest != NULL); /* it did match */ - /* could the rest match the rest? */ - tail = slow(m, rest, stop, es, stopst); - if (tail == stop) - break; /* yes! */ - /* no -- try a shorter match for this one */ - stp = rest - 1; - assert(stp >= sp); /* it did work */ - } - ssub = ss + 1; - esub = ss + OPND(m->g->strip[ss]) - 1; - assert(OP(m->g->strip[esub]) == OOR1); - for (;;) { /* find first matching branch */ - if (slow(m, sp, rest, ssub, esub) == rest) - break; /* it matched all of it */ - /* that one missed, try next one */ - assert(OP(m->g->strip[esub]) == OOR1); - esub++; - assert(OP(m->g->strip[esub]) == OOR2); - ssub = esub + 1; - esub += OPND(m->g->strip[esub]); - if (OP(m->g->strip[esub]) == OOR2) - esub--; - else - assert(OP(m->g->strip[esub]) == O_CH); - } - dp = dissect(m, sp, rest, ssub, esub); - assert(dp == rest); - sp = rest; - break; - case O_PLUS: - case O_QUEST: - case OOR1: - case OOR2: - case O_CH: - assert(nope); - break; - case OLPAREN: - i = OPND(m->g->strip[ss]); - assert(0 < i && i <= m->g->nsub); - m->pmatch[i].rm_so = sp - m->offp; - break; - case ORPAREN: - i = OPND(m->g->strip[ss]); - assert(0 < i && i <= m->g->nsub); - m->pmatch[i].rm_eo = sp - m->offp; - break; - default: /* uh oh */ - assert(nope); - break; - } - } - - assert(sp == stop); - return(sp); -} - -/* - - backref - figure out what matched what, figuring in back references - == static const char *backref(struct match *m, const char *start, \ - == const char *stop, sopno startst, sopno stopst, sopno lev); - */ -static const char * /* == stop (success) or NULL (failure) */ -backref(struct match *m, - const char *start, - const char *stop, - sopno startst, - sopno stopst, - sopno lev, /* PLUS nesting level */ - int rec) -{ - int i; - sopno ss; /* start sop of current subRE */ - const char *sp; /* start of string matched by it */ - sopno ssub; /* start sop of subsubRE */ - sopno esub; /* end sop of subsubRE */ - const char *ssp; /* start of string matched by subsubRE */ - const char *dp; - size_t len; - int hard; - sop s; - regoff_t offsave; - cset *cs; - wint_t wc; - - AT("back", start, stop, startst, stopst); - sp = start; - - /* get as far as we can with easy stuff */ - hard = 0; - for (ss = startst; !hard && ss < stopst; ss++) - switch (OP(s = m->g->strip[ss])) { - case OCHAR: - if (sp == stop) - return(NULL); - sp += XMBRTOWC(&wc, sp, stop - sp, &m->mbs, BADCHAR); - if (wc != OPND(s)) - return(NULL); - break; - case OANY: - if (sp == stop) - return(NULL); - sp += XMBRTOWC(&wc, sp, stop - sp, &m->mbs, BADCHAR); - if (wc == BADCHAR) - return (NULL); - break; - case OANYOF: - if (sp == stop) - return (NULL); - cs = &m->g->sets[OPND(s)]; - sp += XMBRTOWC(&wc, sp, stop - sp, &m->mbs, BADCHAR); - if (wc == BADCHAR || !CHIN(cs, wc)) - return(NULL); - break; - case OBOL: - if ( (sp == m->beginp && !(m->eflags®_NOTBOL)) || - (sp < m->endp && *(sp-1) == '\n' && - (m->g->cflags®_NEWLINE)) ) - { /* yes */ } - else - return(NULL); - break; - case OEOL: - if ( (sp == m->endp && !(m->eflags®_NOTEOL)) || - (sp < m->endp && *sp == '\n' && - (m->g->cflags®_NEWLINE)) ) - { /* yes */ } - else - return(NULL); - break; - case OBOW: - if (( (sp == m->beginp && !(m->eflags®_NOTBOL)) || - (sp < m->endp && *(sp-1) == '\n' && - (m->g->cflags®_NEWLINE)) || - (sp > m->beginp && - !ISWORD(*(sp-1))) ) && - (sp < m->endp && ISWORD(*sp)) ) - { /* yes */ } - else - return(NULL); - break; - case OEOW: - if (( (sp == m->endp && !(m->eflags®_NOTEOL)) || - (sp < m->endp && *sp == '\n' && - (m->g->cflags®_NEWLINE)) || - (sp < m->endp && !ISWORD(*sp)) ) && - (sp > m->beginp && ISWORD(*(sp-1))) ) - { /* yes */ } - else - return(NULL); - break; - case O_QUEST: - break; - case OOR1: /* matches null but needs to skip */ - ss++; - s = m->g->strip[ss]; - do { - assert(OP(s) == OOR2); - ss += OPND(s); - } while (OP(s = m->g->strip[ss]) != O_CH); - /* note that the ss++ gets us past the O_CH */ - break; - default: /* have to make a choice */ - hard = 1; - break; - } - if (!hard) { /* that was it! */ - if (sp != stop) - return(NULL); - return(sp); - } - ss--; /* adjust for the for's final increment */ - - /* the hard stuff */ - AT("hard", sp, stop, ss, stopst); - s = m->g->strip[ss]; - switch (OP(s)) { - case OBACK_: /* the vilest depths */ - i = OPND(s); - assert(0 < i && i <= m->g->nsub); - if (m->pmatch[i].rm_eo == -1) - return(NULL); - assert(m->pmatch[i].rm_so != -1); - len = m->pmatch[i].rm_eo - m->pmatch[i].rm_so; - if (len == 0 && rec++ > MAX_RECURSION) - return(NULL); - assert(stop - m->beginp >= len); - if (sp > stop - len) - return(NULL); /* not enough left to match */ - ssp = m->offp + m->pmatch[i].rm_so; - if (memcmp(sp, ssp, len) != 0) - return(NULL); - while (m->g->strip[ss] != SOP(O_BACK, i)) - ss++; - return(backref(m, sp+len, stop, ss+1, stopst, lev, rec)); - break; - case OQUEST_: /* to null or not */ - dp = backref(m, sp, stop, ss+1, stopst, lev, rec); - if (dp != NULL) - return(dp); /* not */ - return(backref(m, sp, stop, ss+OPND(s)+1, stopst, lev, rec)); - break; - case OPLUS_: - assert(m->lastpos != NULL); - assert(lev+1 <= m->g->nplus); - m->lastpos[lev+1] = sp; - return(backref(m, sp, stop, ss+1, stopst, lev+1, rec)); - break; - case O_PLUS: - if (sp == m->lastpos[lev]) /* last pass matched null */ - return(backref(m, sp, stop, ss+1, stopst, lev-1, rec)); - /* try another pass */ - m->lastpos[lev] = sp; - dp = backref(m, sp, stop, ss-OPND(s)+1, stopst, lev, rec); - if (dp == NULL) - return(backref(m, sp, stop, ss+1, stopst, lev-1, rec)); - else - return(dp); - break; - case OCH_: /* find the right one, if any */ - ssub = ss + 1; - esub = ss + OPND(s) - 1; - assert(OP(m->g->strip[esub]) == OOR1); - for (;;) { /* find first matching branch */ - dp = backref(m, sp, stop, ssub, esub, lev, rec); - if (dp != NULL) - return(dp); - /* that one missed, try next one */ - if (OP(m->g->strip[esub]) == O_CH) - return(NULL); /* there is none */ - esub++; - assert(OP(m->g->strip[esub]) == OOR2); - ssub = esub + 1; - esub += OPND(m->g->strip[esub]); - if (OP(m->g->strip[esub]) == OOR2) - esub--; - else - assert(OP(m->g->strip[esub]) == O_CH); - } - break; - case OLPAREN: /* must undo assignment if rest fails */ - i = OPND(s); - assert(0 < i && i <= m->g->nsub); - offsave = m->pmatch[i].rm_so; - m->pmatch[i].rm_so = sp - m->offp; - dp = backref(m, sp, stop, ss+1, stopst, lev, rec); - if (dp != NULL) - return(dp); - m->pmatch[i].rm_so = offsave; - return(NULL); - break; - case ORPAREN: /* must undo assignment if rest fails */ - i = OPND(s); - assert(0 < i && i <= m->g->nsub); - offsave = m->pmatch[i].rm_eo; - m->pmatch[i].rm_eo = sp - m->offp; - dp = backref(m, sp, stop, ss+1, stopst, lev, rec); - if (dp != NULL) - return(dp); - m->pmatch[i].rm_eo = offsave; - return(NULL); - break; - default: /* uh oh */ - assert(nope); - break; - } - - /* "can't happen" */ - assert(nope); - /* NOTREACHED */ - return "shut up gcc"; -} - -/* - - fast - step through the string at top speed - == static const char *fast(struct match *m, const char *start, \ - == const char *stop, sopno startst, sopno stopst); - */ -static const char * /* where tentative match ended, or NULL */ -fast( struct match *m, - const char *start, - const char *stop, - sopno startst, - sopno stopst) -{ - states st = m->st; - states fresh = m->fresh; - states tmp = m->tmp; - const char *p = start; - wint_t c; - wint_t lastc; /* previous c */ - wint_t flagch; - int i; - const char *coldp; /* last p after which no match was underway */ - size_t clen; - - CLEAR(st); - SET1(st, startst); - SP("fast", st, *p); - st = step(m->g, startst, stopst, st, NOTHING, st); - ASSIGN(fresh, st); - SP("start", st, *p); - coldp = NULL; - if (start == m->beginp) - c = OUT; - else { - /* - * XXX Wrong if the previous character was multi-byte. - * Newline never is (in encodings supported by FreeBSD), - * so this only breaks the ISWORD tests below. - */ - c = (uch)*(start - 1); - } - for (;;) { - /* next character */ - lastc = c; - if (p == m->endp) { - clen = 0; - c = OUT; - } else - clen = XMBRTOWC(&c, p, m->endp - p, &m->mbs, BADCHAR); - if (EQ(st, fresh)) - coldp = p; - - /* is there an EOL and/or BOL between lastc and c? */ - flagch = '\0'; - i = 0; - if ( (lastc == '\n' && m->g->cflags®_NEWLINE) || - (lastc == OUT && !(m->eflags®_NOTBOL)) ) { - flagch = BOL; - i = m->g->nbol; - } - if ( (c == '\n' && m->g->cflags®_NEWLINE) || - (c == OUT && !(m->eflags®_NOTEOL)) ) { - flagch = (flagch == BOL) ? BOLEOL : EOL; - i += m->g->neol; - } - if (i != 0) { - for (; i > 0; i--) - st = step(m->g, startst, stopst, st, flagch, st); - SP("boleol", st, c); - } - - /* how about a word boundary? */ - if ( (flagch == BOL || (lastc != OUT && !ISWORD(lastc))) && - (c != OUT && ISWORD(c)) ) { - flagch = BOW; - } - if ( (lastc != OUT && ISWORD(lastc)) && - (flagch == EOL || (c != OUT && !ISWORD(c))) ) { - flagch = EOW; - } - if (flagch == BOW || flagch == EOW) { - st = step(m->g, startst, stopst, st, flagch, st); - SP("boweow", st, c); - } - - /* are we done? */ - if (ISSET(st, stopst) || p == stop || clen > stop - p) - break; /* NOTE BREAK OUT */ - - /* no, we must deal with this character */ - ASSIGN(tmp, st); - ASSIGN(st, fresh); - assert(c != OUT); - st = step(m->g, startst, stopst, tmp, c, st); - SP("aft", st, c); - assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st)); - p += clen; - } - - assert(coldp != NULL); - m->coldp = coldp; - if (ISSET(st, stopst)) - return(p+XMBRTOWC(NULL, p, stop - p, &m->mbs, 0)); - else - return(NULL); -} - -/* - - slow - step through the string more deliberately - == static const char *slow(struct match *m, const char *start, \ - == const char *stop, sopno startst, sopno stopst); - */ -static const char * /* where it ended */ -slow( struct match *m, - const char *start, - const char *stop, - sopno startst, - sopno stopst) -{ - states st = m->st; - states empty = m->empty; - states tmp = m->tmp; - const char *p = start; - wint_t c; - wint_t lastc; /* previous c */ - wint_t flagch; - int i; - const char *matchp; /* last p at which a match ended */ - size_t clen; - - AT("slow", start, stop, startst, stopst); - CLEAR(st); - SET1(st, startst); - SP("sstart", st, *p); - st = step(m->g, startst, stopst, st, NOTHING, st); - matchp = NULL; - if (start == m->beginp) - c = OUT; - else { - /* - * XXX Wrong if the previous character was multi-byte. - * Newline never is (in encodings supported by FreeBSD), - * so this only breaks the ISWORD tests below. - */ - c = (uch)*(start - 1); - } - for (;;) { - /* next character */ - lastc = c; - if (p == m->endp) { - c = OUT; - clen = 0; - } else - clen = XMBRTOWC(&c, p, m->endp - p, &m->mbs, BADCHAR); - - /* is there an EOL and/or BOL between lastc and c? */ - flagch = '\0'; - i = 0; - if ( (lastc == '\n' && m->g->cflags®_NEWLINE) || - (lastc == OUT && !(m->eflags®_NOTBOL)) ) { - flagch = BOL; - i = m->g->nbol; - } - if ( (c == '\n' && m->g->cflags®_NEWLINE) || - (c == OUT && !(m->eflags®_NOTEOL)) ) { - flagch = (flagch == BOL) ? BOLEOL : EOL; - i += m->g->neol; - } - if (i != 0) { - for (; i > 0; i--) - st = step(m->g, startst, stopst, st, flagch, st); - SP("sboleol", st, c); - } - - /* how about a word boundary? */ - if ( (flagch == BOL || (lastc != OUT && !ISWORD(lastc))) && - (c != OUT && ISWORD(c)) ) { - flagch = BOW; - } - if ( (lastc != OUT && ISWORD(lastc)) && - (flagch == EOL || (c != OUT && !ISWORD(c))) ) { - flagch = EOW; - } - if (flagch == BOW || flagch == EOW) { - st = step(m->g, startst, stopst, st, flagch, st); - SP("sboweow", st, c); - } - - /* are we done? */ - if (ISSET(st, stopst)) - matchp = p; - if (EQ(st, empty) || p == stop || clen > stop - p) - break; /* NOTE BREAK OUT */ - - /* no, we must deal with this character */ - ASSIGN(tmp, st); - ASSIGN(st, empty); - assert(c != OUT); - st = step(m->g, startst, stopst, tmp, c, st); - SP("saft", st, c); - assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st)); - p += clen; - } - - return(matchp); -} - - -/* - - step - map set of states reachable before char to set reachable after - == static states step(struct re_guts *g, sopno start, sopno stop, \ - == states bef, int ch, states aft); - == #define BOL (OUT-1) - == #define EOL (BOL-1) - == #define BOLEOL (BOL-2) - == #define NOTHING (BOL-3) - == #define BOW (BOL-4) - == #define EOW (BOL-5) - == #define BADCHAR (BOL-6) - == #define NONCHAR(c) ((c) <= OUT) - */ -static states -step(struct re_guts *g, - sopno start, /* start state within strip */ - sopno stop, /* state after stop state within strip */ - states bef, /* states reachable before */ - wint_t ch, /* character or NONCHAR code */ - states aft) /* states already known reachable after */ -{ - cset *cs; - sop s; - sopno pc; - onestate here; /* note, macros know this name */ - sopno look; - int i; - - for (pc = start, INIT(here, pc); pc != stop; pc++, INC(here)) { - s = g->strip[pc]; - switch (OP(s)) { - case OEND: - assert(pc == stop-1); - break; - case OCHAR: - /* only characters can match */ - assert(!NONCHAR(ch) || ch != OPND(s)); - if (ch == OPND(s)) - FWD(aft, bef, 1); - break; - case OBOL: - if (ch == BOL || ch == BOLEOL) - FWD(aft, bef, 1); - break; - case OEOL: - if (ch == EOL || ch == BOLEOL) - FWD(aft, bef, 1); - break; - case OBOW: - if (ch == BOW) - FWD(aft, bef, 1); - break; - case OEOW: - if (ch == EOW) - FWD(aft, bef, 1); - break; - case OANY: - if (!NONCHAR(ch)) - FWD(aft, bef, 1); - break; - case OANYOF: - cs = &g->sets[OPND(s)]; - if (!NONCHAR(ch) && CHIN(cs, ch)) - FWD(aft, bef, 1); - break; - case OBACK_: /* ignored here */ - case O_BACK: - FWD(aft, aft, 1); - break; - case OPLUS_: /* forward, this is just an empty */ - FWD(aft, aft, 1); - break; - case O_PLUS: /* both forward and back */ - FWD(aft, aft, 1); - i = ISSETBACK(aft, OPND(s)); - BACK(aft, aft, OPND(s)); - if (!i && ISSETBACK(aft, OPND(s))) { - /* oho, must reconsider loop body */ - pc -= OPND(s) + 1; - INIT(here, pc); - } - break; - case OQUEST_: /* two branches, both forward */ - FWD(aft, aft, 1); - FWD(aft, aft, OPND(s)); - break; - case O_QUEST: /* just an empty */ - FWD(aft, aft, 1); - break; - case OLPAREN: /* not significant here */ - case ORPAREN: - FWD(aft, aft, 1); - break; - case OCH_: /* mark the first two branches */ - FWD(aft, aft, 1); - assert(OP(g->strip[pc+OPND(s)]) == OOR2); - FWD(aft, aft, OPND(s)); - break; - case OOR1: /* done a branch, find the O_CH */ - if (ISSTATEIN(aft, here)) { - for (look = 1; - OP(s = g->strip[pc+look]) != O_CH; - look += OPND(s)) - assert(OP(s) == OOR2); - FWD(aft, aft, look + 1); - } - break; - case OOR2: /* propagate OCH_'s marking */ - FWD(aft, aft, 1); - if (OP(g->strip[pc+OPND(s)]) != O_CH) { - assert(OP(g->strip[pc+OPND(s)]) == OOR2); - FWD(aft, aft, OPND(s)); - } - break; - case O_CH: /* just empty */ - FWD(aft, aft, 1); - break; - default: /* ooooops... */ - assert(nope); - break; - } - } - - return(aft); -} - -#ifdef REDEBUG -/* - - print - print a set of states - == #ifdef REDEBUG - == static void print(struct match *m, const char *caption, states st, \ - == int ch, FILE *d); - == #endif - */ -static void -print(struct match *m, - const char *caption, - states st, - int ch, - FILE *d) -{ - struct re_guts *g = m->g; - int i; - int first = 1; - - if (!(m->eflags®_TRACE)) - return; - - fprintf(d, "%s", caption); - if (ch != '\0') - fprintf(d, " %s", pchar(ch)); - for (i = 0; i < g->nstates; i++) - if (ISSET(st, i)) { - fprintf(d, "%s%d", (first) ? "\t" : ", ", i); - first = 0; - } - fprintf(d, "\n"); -} - -/* - - at - print current situation - == #ifdef REDEBUG - == static void at(struct match *m, const char *title, const char *start, \ - == const char *stop, sopno startst, sopno stopst); - == #endif - */ -static void -at( struct match *m, - const char *title, - const char *start, - const char *stop, - sopno startst, - sopno stopst) -{ - if (!(m->eflags®_TRACE)) - return; - - printf("%s %s-", title, pchar(*start)); - printf("%s ", pchar(*stop)); - printf("%ld-%ld\n", (long)startst, (long)stopst); -} - -#ifndef PCHARDONE -#define PCHARDONE /* never again */ -/* - - pchar - make a character printable - == #ifdef REDEBUG - == static const char *pchar(int ch); - == #endif - * - * Is this identical to regchar() over in debug.c? Well, yes. But a - * duplicate here avoids having a debugging-capable regexec.o tied to - * a matching debug.o, and this is convenient. It all disappears in - * the non-debug compilation anyway, so it doesn't matter much. - */ -static const char * /* -> representation */ -pchar(int ch) -{ - static char pbuf[10]; - - if (isprint((uch)ch) || ch == ' ') - sprintf(pbuf, "%c", ch); - else - sprintf(pbuf, "\\%o", ch); - return(pbuf); -} -#endif -#endif - -#undef matcher -#undef fast -#undef slow -#undef dissect -#undef backref -#undef step -#undef print -#undef at -#undef match diff --git a/winsup/cygwin/regex/regcomp.c b/winsup/cygwin/regex/regcomp.c deleted file mode 100644 index 5aee63948..000000000 --- a/winsup/cygwin/regex/regcomp.c +++ /dev/null @@ -1,1885 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 1994 Henry Spencer. - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * 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. - * 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. - * - * @(#)regcomp.c 8.5 (Berkeley) 3/20/94 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)regcomp.c 8.5 (Berkeley) 3/20/94"; -#endif /* LIBC_SCCS and not lint */ -#include -__FBSDID("$FreeBSD: src/lib/libc/regex/regcomp.c,v 1.36 2007/06/11 03:05:54 delphij Exp $"); - -#ifdef __CYGWIN__ -#include "winsup.h" -#endif -#include -#include -#include -#include -#include -#include -#include -#ifndef __CYGWIN__ -#include -#endif -#include -#include - -#ifndef __CYGWIN__ -#include "collate.h" -#endif - -#include "utils.h" -#include "regex2.h" - -#include "cname.h" - -#ifdef __CYGWIN__ -/* Don't pull in windows headers just for LCID. */ -typedef unsigned long LCID; -/* These are defined in nlsfuncs.cc. */ -extern LCID collate_lcid; -extern char collate_charset[]; -#endif - -/* - * parse structure, passed up and down to avoid global variables and - * other clumsinesses - */ -struct parse { - char *next; /* next character in RE */ - char *end; /* end of string (-> NUL normally) */ - int error; /* has an error been seen? */ - sop *strip; /* malloced strip */ - sopno ssize; /* malloced strip size (allocated) */ - sopno slen; /* malloced strip length (used) */ - int ncsalloc; /* number of csets allocated */ - struct re_guts *g; -# define NPAREN 10 /* we need to remember () 1-9 for back refs */ - sopno pbegin[NPAREN]; /* -> ( ([0] unused) */ - sopno pend[NPAREN]; /* -> ) ([0] unused) */ -}; - -/* ========= begin header generated by ./mkh ========= */ -#ifdef __cplusplus -extern "C" { -#endif - -/* === regcomp.c === */ -#ifdef __CYGWIN__ /* Defined below `int stop'. Our gcc chokes on that. */ -static void p_ere(struct parse *p, int stop); -#else -static void p_ere(struct parse *p, wint_t stop); -#endif -static void p_ere_exp(struct parse *p); -static void p_str(struct parse *p); -#ifdef __CYGWIN__ /* Defined below `int end1/end2'. Our gcc chokes on that. */ -static void p_bre(struct parse *p, int end1, int end2); -#else -static void p_bre(struct parse *p, wint_t end1, wint_t end2); -#endif -static int p_simp_re(struct parse *p, int starordinary); -static int p_count(struct parse *p); -static void p_bracket(struct parse *p); -static void p_b_term(struct parse *p, cset *cs); -static void p_b_cclass(struct parse *p, cset *cs); -static void p_b_eclass(struct parse *p, cset *cs); -static wint_t p_b_symbol(struct parse *p); -static wint_t p_b_coll_elem(struct parse *p, wint_t endc); -static wint_t othercase(wint_t ch); -static void bothcases(struct parse *p, wint_t ch); -static void ordinary(struct parse *p, wint_t ch); -static void nonnewline(struct parse *p); -static void repeat(struct parse *p, sopno start, int from, int to); -static int seterr(struct parse *p, int e); -static cset *allocset(struct parse *p); -static void freeset(struct parse *p, cset *cs); -static void CHadd(struct parse *p, cset *cs, wint_t ch); -static void CHaddrange(struct parse *p, cset *cs, wint_t min, wint_t max); -static void CHaddtype(struct parse *p, cset *cs, wctype_t wct); -static wint_t singleton(cset *cs); -static sopno dupl(struct parse *p, sopno start, sopno finish); -static void doemit(struct parse *p, sop op, size_t opnd); -static void doinsert(struct parse *p, sop op, size_t opnd, sopno pos); -static void dofwd(struct parse *p, sopno pos, sop value); -static void enlarge(struct parse *p, sopno size); -static void stripsnug(struct parse *p, struct re_guts *g); -static void findmust(struct parse *p, struct re_guts *g); -static int altoffset(sop *scan, int offset); -static void computejumps(struct parse *p, struct re_guts *g); -static void computematchjumps(struct parse *p, struct re_guts *g); -static sopno pluscount(struct parse *p, struct re_guts *g); -static wint_t wgetnext(struct parse *p); -static size_t xwcrtomb (char *s, wint_t wc, mbstate_t *ps); - -#ifdef __cplusplus -} -#endif -/* ========= end header generated by ./mkh ========= */ - -static char nuls[10]; /* place to point scanner in event of error */ - -/* - * macros for use with parse structure - * BEWARE: these know that the parse structure is named `p' !!! - */ -#define PEEK() (*p->next) -#define PEEK2() (*(p->next+1)) -#define MORE() (p->next < p->end) -#define MORE2() (p->next+1 < p->end) -#define SEE(c) (MORE() && PEEK() == (c)) -#define SEETWO(a, b) (MORE() && MORE2() && PEEK() == (a) && PEEK2() == (b)) -#define EAT(c) ((SEE(c)) ? (NEXT(), 1) : 0) -#define EATTWO(a, b) ((SEETWO(a, b)) ? (NEXT2(), 1) : 0) -#define NEXT() (p->next++) -#define NEXT2() (p->next += 2) -#define NEXTn(n) (p->next += (n)) -#define GETNEXT() (*p->next++) -#define WGETNEXT() wgetnext(p) -#define SETERROR(e) seterr(p, (e)) -#define REQUIRE(co, e) ((co) || SETERROR(e)) -#define MUSTSEE(c, e) (REQUIRE(MORE() && PEEK() == (c), e)) -#define MUSTEAT(c, e) (REQUIRE(MORE() && GETNEXT() == (c), e)) -#define MUSTNOTSEE(c, e) (REQUIRE(!MORE() || PEEK() != (c), e)) -#define EMIT(op, sopnd) doemit(p, (sop)(op), (size_t)(sopnd)) -#define INSERT(op, pos) doinsert(p, (sop)(op), HERE()-(pos)+1, pos) -#define AHEAD(pos) dofwd(p, pos, HERE()-(pos)) -#define ASTERN(sop, pos) EMIT(sop, HERE()-pos) -#define HERE() (p->slen) -#define THERE() (p->slen - 1) -#define THERETHERE() (p->slen - 2) -#define DROP(n) (p->slen -= (n)) - -#ifndef NDEBUG -static int never = 0; /* for use in asserts; shuts lint up */ -#else -#define never 0 /* some s have bugs too */ -#endif - -/* Macro used by computejump()/computematchjump() */ -#define MIN(a,b) ((a)<(b)?(a):(b)) - -/* - - regcomp - interface for parser and compilation - = extern int regcomp(regex_t *, const char *, int); - = #define REG_BASIC 0000 - = #define REG_EXTENDED 0001 - = #define REG_ICASE 0002 - = #define REG_NOSUB 0004 - = #define REG_NEWLINE 0010 - = #define REG_NOSPEC 0020 - = #define REG_PEND 0040 - = #define REG_DUMP 0200 - */ -int /* 0 success, otherwise REG_something */ -regcomp(regex_t * __restrict preg, - const char * __restrict pattern, - int cflags) -{ - struct parse pa; - struct re_guts *g; - struct parse *p = &pa; - int i; - size_t len; -#ifdef REDEBUG -# define GOODFLAGS(f) (f) -#else -# define GOODFLAGS(f) ((f)&~REG_DUMP) -#endif - - cflags = GOODFLAGS(cflags); - if ((cflags®_EXTENDED) && (cflags®_NOSPEC)) - return(REG_INVARG); - - if (cflags®_PEND) { - if (preg->re_endp < pattern) - return(REG_INVARG); - len = preg->re_endp - pattern; - } else - len = strlen((char *)pattern); - - /* do the mallocs early so failure handling is easy */ - g = (struct re_guts *)malloc(sizeof(struct re_guts)); - if (g == NULL) - return(REG_ESPACE); - p->ssize = len/(size_t)2*(size_t)3 + (size_t)1; /* ugh */ - p->strip = (sop *)malloc(p->ssize * sizeof(sop)); - p->slen = 0; - if (p->strip == NULL) { - free((char *)g); - return(REG_ESPACE); - } - - /* set things up */ - p->g = g; - p->next = (char *)pattern; /* convenience; we do not modify it */ - p->end = p->next + len; - p->error = 0; - p->ncsalloc = 0; - for (i = 0; i < NPAREN; i++) { - p->pbegin[i] = 0; - p->pend[i] = 0; - } - g->sets = NULL; - g->ncsets = 0; - g->cflags = cflags; - g->iflags = 0; - g->nbol = 0; - g->neol = 0; - g->must = NULL; - g->moffset = -1; - g->charjump = NULL; - g->matchjump = NULL; - g->mlen = 0; - g->nsub = 0; - g->backrefs = 0; - - /* do it */ - EMIT(OEND, 0); - g->firststate = THERE(); - if (cflags®_EXTENDED) - p_ere(p, OUT); - else if (cflags®_NOSPEC) - p_str(p); - else - p_bre(p, OUT, OUT); - EMIT(OEND, 0); - g->laststate = THERE(); - - /* tidy up loose ends and fill things in */ - stripsnug(p, g); - findmust(p, g); - /* only use Boyer-Moore algorithm if the pattern is bigger - * than three characters - */ - if(g->mlen > 3) { - computejumps(p, g); - computematchjumps(p, g); - if(g->matchjump == NULL && g->charjump != NULL) { - free(g->charjump); - g->charjump = NULL; - } - } - g->nplus = pluscount(p, g); - g->magic = MAGIC2; - preg->re_nsub = g->nsub; - preg->re_g = g; - preg->re_magic = MAGIC1; -#ifndef REDEBUG - /* not debugging, so can't rely on the assert() in regexec() */ - if (g->iflags&BAD) - SETERROR(REG_ASSERT); -#endif - - /* win or lose, we're done */ - if (p->error != 0) /* lose */ - regfree(preg); - return(p->error); -} - -/* - - p_ere - ERE parser top level, concatenation and alternation - == static void p_ere(struct parse *p, int stop); - */ -static void -p_ere(struct parse *p, - int stop) /* character this ERE should end at */ -{ - char c; - sopno prevback = 0; - sopno prevfwd = 0; - sopno conc; - int first = 1; /* is this the first alternative? */ - - for (;;) { - /* do a bunch of concatenated expressions */ - conc = HERE(); - while (MORE() && (c = PEEK()) != '|' && c != stop) - p_ere_exp(p); - (void)REQUIRE(HERE() != conc, REG_EMPTY); /* require nonempty */ - - if (!EAT('|')) - break; /* NOTE BREAK OUT */ - - if (first) { - INSERT(OCH_, conc); /* offset is wrong */ - prevfwd = conc; - prevback = conc; - first = 0; - } - ASTERN(OOR1, prevback); - prevback = THERE(); - AHEAD(prevfwd); /* fix previous offset */ - prevfwd = HERE(); - EMIT(OOR2, 0); /* offset is very wrong */ - } - - if (!first) { /* tail-end fixups */ - AHEAD(prevfwd); - ASTERN(O_CH, prevback); - } - - assert(!MORE() || SEE(stop)); -} - -/* - - p_ere_exp - parse one subERE, an atom possibly followed by a repetition op - == static void p_ere_exp(struct parse *p); - */ -static void -p_ere_exp(struct parse *p) -{ - char c; - wint_t wc; - sopno pos; - int count; - int count2; - sopno subno; - int wascaret = 0; - - assert(MORE()); /* caller should have ensured this */ - c = GETNEXT(); - - pos = HERE(); - switch (c) { - case '(': - (void)REQUIRE(MORE(), REG_EPAREN); - p->g->nsub++; - subno = p->g->nsub; - if (subno < NPAREN) - p->pbegin[subno] = HERE(); - EMIT(OLPAREN, subno); - if (!SEE(')')) - p_ere(p, ')'); - if (subno < NPAREN) { - p->pend[subno] = HERE(); - assert(p->pend[subno] != 0); - } - EMIT(ORPAREN, subno); - (void)MUSTEAT(')', REG_EPAREN); - break; -#ifndef POSIX_MISTAKE - case ')': /* happens only if no current unmatched ( */ - /* - * You may ask, why the ifndef? Because I didn't notice - * this until slightly too late for 1003.2, and none of the - * other 1003.2 regular-expression reviewers noticed it at - * all. So an unmatched ) is legal POSIX, at least until - * we can get it fixed. - */ - SETERROR(REG_EPAREN); - break; -#endif - case '^': - EMIT(OBOL, 0); - p->g->iflags |= USEBOL; - p->g->nbol++; - wascaret = 1; - break; - case '$': - EMIT(OEOL, 0); - p->g->iflags |= USEEOL; - p->g->neol++; - break; - case '|': - SETERROR(REG_EMPTY); - break; - case '*': - case '+': - case '?': - SETERROR(REG_BADRPT); - break; - case '.': - if (p->g->cflags®_NEWLINE) - nonnewline(p); - else - EMIT(OANY, 0); - break; - case '[': - p_bracket(p); - break; - case '\\': - (void)REQUIRE(MORE(), REG_EESCAPE); - wc = WGETNEXT(); -#ifdef __CYGWIN__ - /* \< and \> are the GNU equivalents to [[:<:]] and [[:>:]] */ - switch (wc) - { - case L'<': - EMIT(OBOW, 0); - break; - case L'>': - EMIT(OEOW, 0); - break; - default: - ordinary(p, wc); - break; - } -#else - ordinary(p, wc); -#endif - break; - case '{': /* okay as ordinary except if digit follows */ - (void)REQUIRE(!MORE() || !isdigit((uch)PEEK()), REG_BADRPT); - /* FALLTHROUGH */ - default: - p->next--; - wc = WGETNEXT(); - ordinary(p, wc); - break; - } - - if (!MORE()) - return; - c = PEEK(); - /* we call { a repetition if followed by a digit */ - if (!( c == '*' || c == '+' || c == '?' || - (c == '{' && MORE2() && isdigit((uch)PEEK2())) )) - return; /* no repetition, we're done */ - NEXT(); - - (void)REQUIRE(!wascaret, REG_BADRPT); - switch (c) { - case '*': /* implemented as +? */ - /* this case does not require the (y|) trick, noKLUDGE */ - INSERT(OPLUS_, pos); - ASTERN(O_PLUS, pos); - INSERT(OQUEST_, pos); - ASTERN(O_QUEST, pos); - break; - case '+': - INSERT(OPLUS_, pos); - ASTERN(O_PLUS, pos); - break; - case '?': - /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */ - INSERT(OCH_, pos); /* offset slightly wrong */ - ASTERN(OOR1, pos); /* this one's right */ - AHEAD(pos); /* fix the OCH_ */ - EMIT(OOR2, 0); /* offset very wrong... */ - AHEAD(THERE()); /* ...so fix it */ - ASTERN(O_CH, THERETHERE()); - break; - case '{': - count = p_count(p); - if (EAT(',')) { - if (isdigit((uch)PEEK())) { - count2 = p_count(p); - (void)REQUIRE(count <= count2, REG_BADBR); - } else /* single number with comma */ - count2 = INFINITY; - } else /* just a single number */ - count2 = count; - repeat(p, pos, count, count2); - if (!EAT('}')) { /* error heuristics */ - while (MORE() && PEEK() != '}') - NEXT(); - (void)REQUIRE(MORE(), REG_EBRACE); - SETERROR(REG_BADBR); - } - break; - } - - if (!MORE()) - return; - c = PEEK(); - if (!( c == '*' || c == '+' || c == '?' || - (c == '{' && MORE2() && isdigit((uch)PEEK2())) ) ) - return; - SETERROR(REG_BADRPT); -} - -/* - - p_str - string (no metacharacters) "parser" - == static void p_str(struct parse *p); - */ -static void -p_str(struct parse *p) -{ - (void)REQUIRE(MORE(), REG_EMPTY); - while (MORE()) - ordinary(p, WGETNEXT()); -} - -/* - - p_bre - BRE parser top level, anchoring and concatenation - == static void p_bre(struct parse *p, int end1, \ - == int end2); - * Giving end1 as OUT essentially eliminates the end1/end2 check. - * - * This implementation is a bit of a kludge, in that a trailing $ is first - * taken as an ordinary character and then revised to be an anchor. - * The amount of lookahead needed to avoid this kludge is excessive. - */ -static void -p_bre(struct parse *p, - int end1, /* first terminating character */ - int end2) /* second terminating character */ -{ - sopno start = HERE(); - int first = 1; /* first subexpression? */ - int wasdollar = 0; - - if (EAT('^')) { - EMIT(OBOL, 0); - p->g->iflags |= USEBOL; - p->g->nbol++; - } - while (MORE() && !SEETWO(end1, end2)) { - wasdollar = p_simp_re(p, first); - first = 0; - } - if (wasdollar) { /* oops, that was a trailing anchor */ - DROP(1); - EMIT(OEOL, 0); - p->g->iflags |= USEEOL; - p->g->neol++; - } - - (void)REQUIRE(HERE() != start, REG_EMPTY); /* require nonempty */ -} - -/* - - p_simp_re - parse a simple RE, an atom possibly followed by a repetition - == static int p_simp_re(struct parse *p, int starordinary); - */ -static int /* was the simple RE an unbackslashed $? */ -p_simp_re(struct parse *p, - int starordinary) /* is a leading * an ordinary character? */ -{ - int c; - int count; - int count2; - sopno pos; - int i; - wint_t wc; - sopno subno; -# define BACKSL (1<g->cflags®_NEWLINE) - nonnewline(p); - else - EMIT(OANY, 0); - break; - case '[': - p_bracket(p); - break; -#ifdef __CYGWIN__ - case BACKSL|'<': - /* \< is the GNU equivalents to [[:<:]] */ - EMIT(OBOW, 0); - break; - case BACKSL|'>': - /* \> is the GNU equivalents to [[:>:]] */ - EMIT(OEOW, 0); - break; -#endif - case BACKSL|'{': - SETERROR(REG_BADRPT); - break; - case BACKSL|'(': - p->g->nsub++; - subno = p->g->nsub; - if (subno < NPAREN) - p->pbegin[subno] = HERE(); - EMIT(OLPAREN, subno); - /* the MORE here is an error heuristic */ - if (MORE() && !SEETWO('\\', ')')) - p_bre(p, '\\', ')'); - if (subno < NPAREN) { - p->pend[subno] = HERE(); - assert(p->pend[subno] != 0); - } - EMIT(ORPAREN, subno); - (void)REQUIRE(EATTWO('\\', ')'), REG_EPAREN); - break; - case BACKSL|')': /* should not get here -- must be user */ - case BACKSL|'}': - SETERROR(REG_EPAREN); - break; - case BACKSL|'1': - case BACKSL|'2': - case BACKSL|'3': - case BACKSL|'4': - case BACKSL|'5': - case BACKSL|'6': - case BACKSL|'7': - case BACKSL|'8': - case BACKSL|'9': - i = (c&~BACKSL) - '0'; - assert(i < NPAREN); - if (p->pend[i] != 0) { - assert(i <= p->g->nsub); - EMIT(OBACK_, i); - assert(p->pbegin[i] != 0); - assert(OP(p->strip[p->pbegin[i]]) == OLPAREN); - assert(OP(p->strip[p->pend[i]]) == ORPAREN); - (void) dupl(p, p->pbegin[i]+1, p->pend[i]); - EMIT(O_BACK, i); - } else - SETERROR(REG_ESUBREG); - p->g->backrefs = 1; - break; - case '*': - (void)REQUIRE(starordinary, REG_BADRPT); - /* FALLTHROUGH */ - default: - p->next--; - wc = WGETNEXT(); - ordinary(p, wc); - break; - } - - if (EAT('*')) { /* implemented as +? */ - /* this case does not require the (y|) trick, noKLUDGE */ - INSERT(OPLUS_, pos); - ASTERN(O_PLUS, pos); - INSERT(OQUEST_, pos); - ASTERN(O_QUEST, pos); - } else if (EATTWO('\\', '{')) { - count = p_count(p); - if (EAT(',')) { - if (MORE() && isdigit((uch)PEEK())) { - count2 = p_count(p); - (void)REQUIRE(count <= count2, REG_BADBR); - } else /* single number with comma */ - count2 = INFINITY; - } else /* just a single number */ - count2 = count; - repeat(p, pos, count, count2); - if (!EATTWO('\\', '}')) { /* error heuristics */ - while (MORE() && !SEETWO('\\', '}')) - NEXT(); - (void)REQUIRE(MORE(), REG_EBRACE); - SETERROR(REG_BADBR); - } - } else if (c == '$') /* $ (but not \$) ends it */ - return(1); - - return(0); -} - -/* - - p_count - parse a repetition count - == static int p_count(struct parse *p); - */ -static int /* the value */ -p_count(struct parse *p) -{ - int count = 0; - int ndigits = 0; - - while (MORE() && isdigit((uch)PEEK()) && count <= DUPMAX) { - count = count*10 + (GETNEXT() - '0'); - ndigits++; - } - - (void)REQUIRE(ndigits > 0 && count <= DUPMAX, REG_BADBR); - return(count); -} - -/* - - p_bracket - parse a bracketed character list - == static void p_bracket(struct parse *p); - */ -static void -p_bracket(struct parse *p) -{ - cset *cs; - wint_t ch; - - /* Dept of Truly Sickening Special-Case Kludges */ - if (p->next + 5 < p->end && strncmp(p->next, "[:<:]]", 6) == 0) { - EMIT(OBOW, 0); - NEXTn(6); - return; - } - if (p->next + 5 < p->end && strncmp(p->next, "[:>:]]", 6) == 0) { - EMIT(OEOW, 0); - NEXTn(6); - return; - } - - if ((cs = allocset(p)) == NULL) - return; - - if (p->g->cflags®_ICASE) - cs->icase = 1; - if (EAT('^')) - cs->invert = 1; - if (EAT(']')) - CHadd(p, cs, ']'); - else if (EAT('-')) - CHadd(p, cs, '-'); - while (MORE() && PEEK() != ']' && !SEETWO('-', ']')) - p_b_term(p, cs); - if (EAT('-')) - CHadd(p, cs, '-'); - (void)MUSTEAT(']', REG_EBRACK); - - if (p->error != 0) /* don't mess things up further */ - return; - - if (cs->invert && p->g->cflags®_NEWLINE) - cs->bmp['\n' >> 3] |= 1 << ('\n' & 7); - - if ((ch = singleton(cs)) != OUT /* optimize singleton sets */ - && cs->invert == 0) { /* But not in invert case. */ - ordinary(p, ch); - freeset(p, cs); - } else - EMIT(OANYOF, (int)(cs - p->g->sets)); -} - -#ifdef __CYGWIN__ -/* This function is usually part of FreeBSD's libc. */ -int -__collate_range_cmp(int c1, int c2) -{ - char s1[2] = { c1, '\0' }; - char s2[2] = { c2, '\0' }; - return strcoll (s1, s2); -} -#endif - -/* - - p_b_term - parse one term of a bracketed character list - == static void p_b_term(struct parse *p, cset *cs); - */ -static void -p_b_term(struct parse *p, cset *cs) -{ - char c; - wint_t start, finish; - wint_t i; - - /* classify what we've got */ - switch ((MORE()) ? PEEK() : '\0') { - case '[': - c = (MORE2()) ? PEEK2() : '\0'; - break; - case '-': - SETERROR(REG_ERANGE); - return; /* NOTE RETURN */ - break; - default: - c = '\0'; - break; - } - - switch (c) { - case ':': /* character class */ - NEXT2(); - (void)REQUIRE(MORE(), REG_EBRACK); - c = PEEK(); - (void)REQUIRE(c != '-' && c != ']', REG_ECTYPE); - p_b_cclass(p, cs); - (void)REQUIRE(MORE(), REG_EBRACK); - (void)REQUIRE(EATTWO(':', ']'), REG_ECTYPE); - break; - case '=': /* equivalence class */ - NEXT2(); - (void)REQUIRE(MORE(), REG_EBRACK); - c = PEEK(); - (void)REQUIRE(c != '-' && c != ']', REG_ECOLLATE); - p_b_eclass(p, cs); - (void)REQUIRE(MORE(), REG_EBRACK); - (void)REQUIRE(EATTWO('=', ']'), REG_ECOLLATE); - break; - default: /* symbol, ordinary character, or range */ - start = p_b_symbol(p); - if (SEE('-') && MORE2() && PEEK2() != ']') { - /* range */ - NEXT(); - if (EAT('-')) - finish = '-'; - else - finish = p_b_symbol(p); - } else if (SEE('-') && !MORE2()) { - SETERROR(REG_EBRACK); - return; - } else - finish = start; - if (start == finish) - CHadd(p, cs, start); - else { -#ifdef __CYGWIN__ - if (!collate_lcid) { -#else - if (__collate_load_error) { -#endif - (void)REQUIRE((uch)start <= (uch)finish, REG_ERANGE); - CHaddrange(p, cs, start, finish); - } else { - (void)REQUIRE(__collate_range_cmp(start, finish) <= 0, REG_ERANGE); - for (i = 0; i <= UCHAR_MAX; i++) { - if ( __collate_range_cmp(start, i) <= 0 - && __collate_range_cmp(i, finish) <= 0 - ) - CHadd(p, cs, i); - } - } - } - break; - } -} - -/* - - p_b_cclass - parse a character-class name and deal with it - == static void p_b_cclass(struct parse *p, cset *cs); - */ -static void -p_b_cclass(struct parse *p, cset *cs) -{ - char *sp = p->next; - size_t len; - wctype_t wct; - char clname[16]; - - while (MORE() && isalpha((uch)PEEK())) - NEXT(); - len = p->next - sp; - if (len >= sizeof(clname) - 1) { - SETERROR(REG_ECTYPE); - return; - } - memcpy(clname, sp, len); - clname[len] = '\0'; - if ((wct = wctype(clname)) == 0) { - SETERROR(REG_ECTYPE); - return; - } - CHaddtype(p, cs, wct); -} - -/* - - p_b_eclass - parse an equivalence-class name and deal with it - == static void p_b_eclass(struct parse *p, cset *cs); - * - * This implementation is incomplete. xxx - */ -static void -p_b_eclass(struct parse *p, cset *cs) -{ - wint_t c; - - c = p_b_coll_elem(p, '='); - CHadd(p, cs, c); -} - -/* - - p_b_symbol - parse a character or [..]ed multicharacter collating symbol - == static char p_b_symbol(struct parse *p); - */ -static wint_t /* value of symbol */ -p_b_symbol(struct parse *p) -{ - wint_t value; - - (void)REQUIRE(MORE(), REG_EBRACK); - if (!EATTWO('[', '.')) - return(WGETNEXT()); - - /* collating symbol */ - value = p_b_coll_elem(p, '.'); - (void)REQUIRE(EATTWO('.', ']'), REG_ECOLLATE); - return(value); -} - -/* - - p_b_coll_elem - parse a collating-element name and look it up - == static char p_b_coll_elem(struct parse *p, int endc); - */ -static wint_t /* value of collating element */ -p_b_coll_elem(struct parse *p, - wint_t endc) /* name ended by endc,']' */ -{ - char *sp = p->next; - struct cname *cp; - int len; - mbstate_t mbs; - wchar_t wc; - size_t clen; - - while (MORE() && !SEETWO(endc, ']')) - NEXT(); - if (!MORE()) { - SETERROR(REG_EBRACK); - return(0); - } - len = p->next - sp; - for (cp = cnames; cp->name != NULL; cp++) - if (strncmp(cp->name, sp, len) == 0 && cp->name[len] == '\0') - return(cp->code); /* known name */ - memset(&mbs, 0, sizeof(mbs)); - if ((clen = mbrtowc(&wc, sp, len, &mbs)) == len) - return (wc); /* single character */ - else if (clen == (size_t)-1 || clen == (size_t)-2) - SETERROR(REG_ILLSEQ); - else - SETERROR(REG_ECOLLATE); /* neither */ - return(0); -} - -/* - - othercase - return the case counterpart of an alphabetic - == static char othercase(int ch); - */ -static wint_t /* if no counterpart, return ch */ -othercase(wint_t ch) -{ - assert(iswalpha(ch)); - if (iswupper(ch)) - return(towlower(ch)); - else if (iswlower(ch)) - return(towupper(ch)); - else /* peculiar, but could happen */ - return(ch); -} - -/* - - bothcases - emit a dualcase version of a two-case character - == static void bothcases(struct parse *p, int ch); - * - * Boy, is this implementation ever a kludge... - */ -static void -bothcases(struct parse *p, wint_t ch) -{ - char *oldnext = p->next; - char *oldend = p->end; - char bracket[3 + MB_LEN_MAX]; - size_t n; - mbstate_t mbs; - - assert(othercase(ch) != ch); /* p_bracket() would recurse */ - p->next = bracket; - memset(&mbs, 0, sizeof(mbs)); - n = xwcrtomb(bracket, ch, &mbs); - assert(n != (size_t)-1); - bracket[n] = ']'; - bracket[n + 1] = '\0'; - p->end = bracket+n+1; - p_bracket(p); - assert(p->next == p->end); - p->next = oldnext; - p->end = oldend; -} - -/* - - ordinary - emit an ordinary character - == static void ordinary(struct parse *p, int ch); - */ -static void -ordinary(struct parse *p, wint_t ch) -{ - cset *cs; - - if ((p->g->cflags®_ICASE) && iswalpha(ch) && othercase(ch) != ch) - bothcases(p, ch); - else if ((ch & OPDMASK) == ch) - EMIT(OCHAR, ch); - else { - /* - * Kludge: character is too big to fit into an OCHAR operand. - * Emit a singleton set. - */ - if ((cs = allocset(p)) == NULL) - return; - CHadd(p, cs, ch); - EMIT(OANYOF, (int)(cs - p->g->sets)); - } -} - -/* - - nonnewline - emit REG_NEWLINE version of OANY - == static void nonnewline(struct parse *p); - * - * Boy, is this implementation ever a kludge... - */ -static void -nonnewline(struct parse *p) -{ - char *oldnext = p->next; - char *oldend = p->end; - char bracket[4]; - - p->next = bracket; - p->end = bracket+3; - bracket[0] = '^'; - bracket[1] = '\n'; - bracket[2] = ']'; - bracket[3] = '\0'; - p_bracket(p); - assert(p->next == bracket+3); - p->next = oldnext; - p->end = oldend; -} - -/* - - repeat - generate code for a bounded repetition, recursively if needed - == static void repeat(struct parse *p, sopno start, int from, int to); - */ -static void -repeat(struct parse *p, - sopno start, /* operand from here to end of strip */ - int from, /* repeated from this number */ - int to) /* to this number of times (maybe INFINITY) */ -{ - sopno finish = HERE(); -# define N 2 -# define INF 3 -# define REP(f, t) ((f)*8 + (t)) -# define MAP(n) (((n) <= 1) ? (n) : ((n) == INFINITY) ? INF : N) - sopno copy; - - if (p->error != 0) /* head off possible runaway recursion */ - return; - - assert(from <= to); - - switch (REP(MAP(from), MAP(to))) { - case REP(0, 0): /* must be user doing this */ - DROP(finish-start); /* drop the operand */ - break; - case REP(0, 1): /* as x{1,1}? */ - case REP(0, N): /* as x{1,n}? */ - case REP(0, INF): /* as x{1,}? */ - /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */ - INSERT(OCH_, start); /* offset is wrong... */ - repeat(p, start+1, 1, to); - ASTERN(OOR1, start); - AHEAD(start); /* ... fix it */ - EMIT(OOR2, 0); - AHEAD(THERE()); - ASTERN(O_CH, THERETHERE()); - break; - case REP(1, 1): /* trivial case */ - /* done */ - break; - case REP(1, N): /* as x?x{1,n-1} */ - /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */ - INSERT(OCH_, start); - ASTERN(OOR1, start); - AHEAD(start); - EMIT(OOR2, 0); /* offset very wrong... */ - AHEAD(THERE()); /* ...so fix it */ - ASTERN(O_CH, THERETHERE()); - copy = dupl(p, start+1, finish+1); - assert(copy == finish+4); - repeat(p, copy, 1, to-1); - break; - case REP(1, INF): /* as x+ */ - INSERT(OPLUS_, start); - ASTERN(O_PLUS, start); - break; - case REP(N, N): /* as xx{m-1,n-1} */ - copy = dupl(p, start, finish); - repeat(p, copy, from-1, to-1); - break; - case REP(N, INF): /* as xx{n-1,INF} */ - copy = dupl(p, start, finish); - repeat(p, copy, from-1, to); - break; - default: /* "can't happen" */ - SETERROR(REG_ASSERT); /* just in case */ - break; - } -} - -/* - - wgetnext - helper function for WGETNEXT() macro. Gets the next wide - - character from the parse struct, signals a REG_ILLSEQ error if the - - character can't be converted. Returns the number of bytes consumed. - */ -static wint_t -wgetnext(struct parse *p) -{ - mbstate_t mbs; - wchar_t wc; - wint_t ret; - size_t n; - - memset(&mbs, 0, sizeof(mbs)); - n = mbrtowc(&wc, p->next, p->end - p->next, &mbs); - if (n == (size_t)-1 || n == (size_t)-2) { - SETERROR(REG_ILLSEQ); - return (0); - } - ret = wc; - if (n == 0) - n = 1; - else if (sizeof (wchar_t) == 2 && wc >= 0xd800 && wc <= 0xdbff) { - /* UTF-16 surrogate pair. Fetch second half and - compute UTF-32 value */ - size_t n2 = mbrtowc(&wc, p->next + n, - p->end - p->next - n, &mbs); - if (n2 == 0 || n2 == (size_t)-1 || n2 == (size_t)-2) { - SETERROR(REG_ILLSEQ); - return (0); - } - ret = (((ret & 0x3ff) << 10) | (wc & 0x3ff)) - + 0x10000; - n += n2; - } - p->next += n; - return (ret); -} - -static size_t -xwcrtomb (char *s, wint_t wc, mbstate_t *ps) -{ - if (sizeof (wchar_t) == 2 && wc >= 0x10000) - { - /* UTF-16 wcrtomb can't handle these values directly. The rest of the - code isn't surrogate pair aware, so we handle this here. Convert - value to UTF-16 surrogate and call wcsrtombs to convert the "string" - to the correct multibyte representation, if any. */ - wchar_t ws[2]; - const wchar_t *wsp = ws; - - wc -= 0x10000; - ws[0] = 0xd800 | (wc >> 10); - ws[1] = 0xdc00 | (wc & 0x3ff); - return wcsnrtombs (s, &wsp, 2, MB_CUR_MAX, ps); - } - return wcrtomb (s, wc, ps); -} - - -/* - - seterr - set an error condition - == static int seterr(struct parse *p, int e); - */ -static int /* useless but makes type checking happy */ -seterr(struct parse *p, int e) -{ - if (p->error == 0) /* keep earliest error condition */ - p->error = e; - p->next = nuls; /* try to bring things to a halt */ - p->end = nuls; - return(0); /* make the return value well-defined */ -} - -/* - - allocset - allocate a set of characters for [] - == static cset *allocset(struct parse *p); - */ -static cset * -allocset(struct parse *p) -{ - cset *cs, *ncs; - - ncs = realloc(p->g->sets, (p->g->ncsets + 1) * sizeof(*ncs)); - if (ncs == NULL) { - SETERROR(REG_ESPACE); - return (NULL); - } - p->g->sets = ncs; - cs = &p->g->sets[p->g->ncsets++]; - memset(cs, 0, sizeof(*cs)); - - return(cs); -} - -/* - - freeset - free a now-unused set - == static void freeset(struct parse *p, cset *cs); - */ -static void -freeset(struct parse *p, cset *cs) -{ - cset *top = &p->g->sets[p->g->ncsets]; - - free(cs->wides); - free(cs->ranges); - free(cs->types); - memset(cs, 0, sizeof(*cs)); - if (cs == top-1) /* recover only the easy case */ - p->g->ncsets--; -} - -/* - - singleton - Determine whether a set contains only one character, - - returning it if so, otherwise returning OUT. - */ -static wint_t -singleton(cset *cs) -{ - wint_t i, s, n; - - for (i = n = 0; i < NC; i++) - if (CHIN(cs, i)) { - n++; - s = i; - } - if (n == 1 && cs->nwides == 0) - return (s); - if (n == 0 && cs->nwides == 1 && cs->nranges == 0 && cs->ntypes == 0 && - cs->icase == 0) - return (cs->wides[0]); - /* Don't bother handling the other cases. */ - return (OUT); -} - -/* - - CHadd - add character to character set. - */ -static void -CHadd(struct parse *p, cset *cs, wint_t ch) -{ - wint_t nch, *newwides; - assert(ch >= 0); - if (ch < NC) - cs->bmp[ch >> 3] |= 1 << (ch & 7); - else { - newwides = realloc(cs->wides, (cs->nwides + 1) * - sizeof(*cs->wides)); - if (newwides == NULL) { - SETERROR(REG_ESPACE); - return; - } - cs->wides = newwides; - cs->wides[cs->nwides++] = ch; - } - if (cs->icase) { - if ((nch = towlower(ch)) < NC) - cs->bmp[nch >> 3] |= 1 << (nch & 7); - if ((nch = towupper(ch)) < NC) - cs->bmp[nch >> 3] |= 1 << (nch & 7); - } -} - -/* - - CHaddrange - add all characters in the range [min,max] to a character set. - */ -static void -CHaddrange(struct parse *p, cset *cs, wint_t min, wint_t max) -{ - crange *newranges; - - for (; min < NC && min <= max; min++) - CHadd(p, cs, min); - if (min >= max) - return; - newranges = realloc(cs->ranges, (cs->nranges + 1) * - sizeof(*cs->ranges)); - if (newranges == NULL) { - SETERROR(REG_ESPACE); - return; - } - cs->ranges = newranges; - cs->ranges[cs->nranges].min = min; - cs->ranges[cs->nranges].min = max; - cs->nranges++; -} - -/* - - CHaddtype - add all characters of a certain type to a character set. - */ -static void -CHaddtype(struct parse *p, cset *cs, wctype_t wct) -{ - wint_t i; - wctype_t *newtypes; - - for (i = 0; i < NC; i++) - if (iswctype(i, wct)) - CHadd(p, cs, i); - newtypes = realloc(cs->types, (cs->ntypes + 1) * - sizeof(*cs->types)); - if (newtypes == NULL) { - SETERROR(REG_ESPACE); - return; - } - cs->types = newtypes; - cs->types[cs->ntypes++] = wct; -} - -/* - - dupl - emit a duplicate of a bunch of sops - == static sopno dupl(struct parse *p, sopno start, sopno finish); - */ -static sopno /* start of duplicate */ -dupl(struct parse *p, - sopno start, /* from here */ - sopno finish) /* to this less one */ -{ - sopno ret = HERE(); - sopno len = finish - start; - - assert(finish >= start); - if (len == 0) - return(ret); - enlarge(p, p->ssize + len); /* this many unexpected additions */ - assert(p->ssize >= p->slen + len); - (void) memcpy((char *)(p->strip + p->slen), - (char *)(p->strip + start), (size_t)len*sizeof(sop)); - p->slen += len; - return(ret); -} - -/* - - doemit - emit a strip operator - == static void doemit(struct parse *p, sop op, size_t opnd); - * - * It might seem better to implement this as a macro with a function as - * hard-case backup, but it's just too big and messy unless there are - * some changes to the data structures. Maybe later. - */ -static void -doemit(struct parse *p, sop op, size_t opnd) -{ - /* avoid making error situations worse */ - if (p->error != 0) - return; - - /* deal with oversize operands ("can't happen", more or less) */ - assert(opnd < 1<slen >= p->ssize) - enlarge(p, (p->ssize+1) / 2 * 3); /* +50% */ - assert(p->slen < p->ssize); - - /* finally, it's all reduced to the easy case */ - p->strip[p->slen++] = SOP(op, opnd); -} - -/* - - doinsert - insert a sop into the strip - == static void doinsert(struct parse *p, sop op, size_t opnd, sopno pos); - */ -static void -doinsert(struct parse *p, sop op, size_t opnd, sopno pos) -{ - sopno sn; - sop s; - int i; - - /* avoid making error situations worse */ - if (p->error != 0) - return; - - sn = HERE(); - EMIT(op, opnd); /* do checks, ensure space */ - assert(HERE() == sn+1); - s = p->strip[sn]; - - /* adjust paren pointers */ - assert(pos > 0); - for (i = 1; i < NPAREN; i++) { - if (p->pbegin[i] >= pos) { - p->pbegin[i]++; - } - if (p->pend[i] >= pos) { - p->pend[i]++; - } - } - - memmove((char *)&p->strip[pos+1], (char *)&p->strip[pos], - (HERE()-pos-1)*sizeof(sop)); - p->strip[pos] = s; -} - -/* - - dofwd - complete a forward reference - == static void dofwd(struct parse *p, sopno pos, sop value); - */ -static void -dofwd(struct parse *p, sopno pos, sop value) -{ - /* avoid making error situations worse */ - if (p->error != 0) - return; - - assert(value < 1<strip[pos] = OP(p->strip[pos]) | value; -} - -/* - - enlarge - enlarge the strip - == static void enlarge(struct parse *p, sopno size); - */ -static void -enlarge(struct parse *p, sopno size) -{ - sop *sp; - - if (p->ssize >= size) - return; - - sp = (sop *)realloc(p->strip, size*sizeof(sop)); - if (sp == NULL) { - SETERROR(REG_ESPACE); - return; - } - p->strip = sp; - p->ssize = size; -} - -/* - - stripsnug - compact the strip - == static void stripsnug(struct parse *p, struct re_guts *g); - */ -static void -stripsnug(struct parse *p, struct re_guts *g) -{ - g->nstates = p->slen; - g->strip = (sop *)realloc((char *)p->strip, p->slen * sizeof(sop)); - if (g->strip == NULL) { - SETERROR(REG_ESPACE); - g->strip = p->strip; - } -} - -/* - - findmust - fill in must and mlen with longest mandatory literal string - == static void findmust(struct parse *p, struct re_guts *g); - * - * This algorithm could do fancy things like analyzing the operands of | - * for common subsequences. Someday. This code is simple and finds most - * of the interesting cases. - * - * Note that must and mlen got initialized during setup. - */ -static void -findmust(struct parse *p, struct re_guts *g) -{ - sop *scan; - sop *start; - sop *newstart; - sopno newlen; - sop s; - char *cp; - int offset; - char buf[MB_LEN_MAX]; - size_t clen; - mbstate_t mbs; - - /* avoid making error situations worse */ - if (p->error != 0) - return; - - /* - * It's not generally safe to do a ``char'' substring search on - * multibyte character strings, but it's safe for at least - * UTF-8 (see RFC 3629). - */ - if (MB_CUR_MAX > 1 && -#ifdef __CYGWIN__ - strcmp(__locale_charset (), "UTF-8") != 0) -#else - strcmp(_CurrentRuneLocale->__encoding, "UTF-8") != 0) -#endif - return; - - /* find the longest OCHAR sequence in strip */ - newlen = 0; - offset = 0; - g->moffset = 0; - scan = g->strip + 1; - do { - s = *scan++; - switch (OP(s)) { - case OCHAR: /* sequence member */ - if (newlen == 0) { /* new sequence */ - memset(&mbs, 0, sizeof(mbs)); - newstart = scan - 1; - } - clen = xwcrtomb(buf, OPND(s), &mbs); - if (clen == (size_t)-1) - goto toohard; - newlen += clen; - break; - case OPLUS_: /* things that don't break one */ - case OLPAREN: - case ORPAREN: - break; - case OQUEST_: /* things that must be skipped */ - case OCH_: - offset = altoffset(scan, offset); - scan--; - do { - scan += OPND(s); - s = *scan; - /* assert() interferes w debug printouts */ - if (OP(s) != O_QUEST && OP(s) != O_CH && - OP(s) != OOR2) { - g->iflags |= BAD; - return; - } - } while (OP(s) != O_QUEST && OP(s) != O_CH); - /* FALLTHROUGH */ - case OBOW: /* things that break a sequence */ - case OEOW: - case OBOL: - case OEOL: - case O_QUEST: - case O_CH: - case OEND: - if (newlen > g->mlen) { /* ends one */ - start = newstart; - g->mlen = newlen; - if (offset > -1) { - g->moffset += offset; - offset = newlen; - } else - g->moffset = offset; - } else { - if (offset > -1) - offset += newlen; - } - newlen = 0; - break; - case OANY: - if (newlen > g->mlen) { /* ends one */ - start = newstart; - g->mlen = newlen; - if (offset > -1) { - g->moffset += offset; - offset = newlen; - } else - g->moffset = offset; - } else { - if (offset > -1) - offset += newlen; - } - if (offset > -1) - offset++; - newlen = 0; - break; - case OANYOF: /* may or may not invalidate offset */ - /* First, everything as OANY */ - if (newlen > g->mlen) { /* ends one */ - start = newstart; - g->mlen = newlen; - if (offset > -1) { - g->moffset += offset; - offset = newlen; - } else - g->moffset = offset; - } else { - if (offset > -1) - offset += newlen; - } - if (offset > -1) - offset++; - newlen = 0; - break; - toohard: - default: - /* Anything here makes it impossible or too hard - * to calculate the offset -- so we give up; - * save the last known good offset, in case the - * must sequence doesn't occur later. - */ - if (newlen > g->mlen) { /* ends one */ - start = newstart; - g->mlen = newlen; - if (offset > -1) - g->moffset += offset; - else - g->moffset = offset; - } - offset = -1; - newlen = 0; - break; - } - } while (OP(s) != OEND); - - if (g->mlen == 0) { /* there isn't one */ - g->moffset = -1; - return; - } - - /* turn it into a character string */ - g->must = malloc((size_t)g->mlen + 1); - if (g->must == NULL) { /* argh; just forget it */ - g->mlen = 0; - g->moffset = -1; - return; - } - cp = g->must; - scan = start; - memset(&mbs, 0, sizeof(mbs)); - while (cp < g->must + g->mlen) { - while (OP(s = *scan++) != OCHAR) - continue; - clen = xwcrtomb(cp, OPND(s), &mbs); - assert(clen != (size_t)-1); - cp += clen; - } - assert(cp == g->must + g->mlen); - *cp++ = '\0'; /* just on general principles */ -} - -/* - - altoffset - choose biggest offset among multiple choices - == static int altoffset(sop *scan, int offset); - * - * Compute, recursively if necessary, the largest offset among multiple - * re paths. - */ -static int -altoffset(sop *scan, int offset) -{ - int largest; - int try; - sop s; - - /* If we gave up already on offsets, return */ - if (offset == -1) - return -1; - - largest = 0; - try = 0; - s = *scan++; - while (OP(s) != O_QUEST && OP(s) != O_CH) { - switch (OP(s)) { - case OOR1: - if (try > largest) - largest = try; - try = 0; - break; - case OQUEST_: - case OCH_: - try = altoffset(scan, try); - if (try == -1) - return -1; - scan--; - do { - scan += OPND(s); - s = *scan; - if (OP(s) != O_QUEST && OP(s) != O_CH && - OP(s) != OOR2) - return -1; - } while (OP(s) != O_QUEST && OP(s) != O_CH); - /* We must skip to the next position, or we'll - * leave altoffset() too early. - */ - scan++; - break; - case OANYOF: - case OCHAR: - case OANY: - try++; - case OBOW: - case OEOW: - case OLPAREN: - case ORPAREN: - case OOR2: - break; - default: - try = -1; - break; - } - if (try == -1) - return -1; - s = *scan++; - } - - if (try > largest) - largest = try; - - return largest+offset; -} - -/* - - computejumps - compute char jumps for BM scan - == static void computejumps(struct parse *p, struct re_guts *g); - * - * This algorithm assumes g->must exists and is has size greater than - * zero. It's based on the algorithm found on Computer Algorithms by - * Sara Baase. - * - * A char jump is the number of characters one needs to jump based on - * the value of the character from the text that was mismatched. - */ -static void -computejumps(struct parse *p, struct re_guts *g) -{ - int ch; - int mindex; - - /* Avoid making errors worse */ - if (p->error != 0) - return; - - g->charjump = (int*) malloc((NC + 1) * sizeof(int)); - if (g->charjump == NULL) /* Not a fatal error */ - return; - /* Adjust for signed chars, if necessary */ - g->charjump = &g->charjump[-(CHAR_MIN)]; - - /* If the character does not exist in the pattern, the jump - * is equal to the number of characters in the pattern. - */ - for (ch = CHAR_MIN; ch < (CHAR_MAX + 1); ch++) - g->charjump[ch] = g->mlen; - - /* If the character does exist, compute the jump that would - * take us to the last character in the pattern equal to it - * (notice that we match right to left, so that last character - * is the first one that would be matched). - */ - for (mindex = 0; mindex < g->mlen; mindex++) - g->charjump[(int)g->must[mindex]] = g->mlen - mindex - 1; -} - -/* - - computematchjumps - compute match jumps for BM scan - == static void computematchjumps(struct parse *p, struct re_guts *g); - * - * This algorithm assumes g->must exists and is has size greater than - * zero. It's based on the algorithm found on Computer Algorithms by - * Sara Baase. - * - * A match jump is the number of characters one needs to advance based - * on the already-matched suffix. - * Notice that all values here are minus (g->mlen-1), because of the way - * the search algorithm works. - */ -static void -computematchjumps(struct parse *p, struct re_guts *g) -{ - int mindex; /* General "must" iterator */ - int suffix; /* Keeps track of matching suffix */ - int ssuffix; /* Keeps track of suffixes' suffix */ - int* pmatches; /* pmatches[k] points to the next i - * such that i+1...mlen is a substring - * of k+1...k+mlen-i-1 - */ - - /* Avoid making errors worse */ - if (p->error != 0) - return; - - pmatches = (int*) malloc(g->mlen * sizeof(unsigned int)); - if (pmatches == NULL) { - g->matchjump = NULL; - return; - } - - g->matchjump = (int*) malloc(g->mlen * sizeof(unsigned int)); - if (g->matchjump == NULL) /* Not a fatal error */ - return; - - /* Set maximum possible jump for each character in the pattern */ - for (mindex = 0; mindex < g->mlen; mindex++) - g->matchjump[mindex] = 2*g->mlen - mindex - 1; - - /* Compute pmatches[] */ - for (mindex = g->mlen - 1, suffix = g->mlen; mindex >= 0; - mindex--, suffix--) { - pmatches[mindex] = suffix; - - /* If a mismatch is found, interrupting the substring, - * compute the matchjump for that position. If no - * mismatch is found, then a text substring mismatched - * against the suffix will also mismatch against the - * substring. - */ - while (suffix < g->mlen - && g->must[mindex] != g->must[suffix]) { - g->matchjump[suffix] = MIN(g->matchjump[suffix], - g->mlen - mindex - 1); - suffix = pmatches[suffix]; - } - } - - /* Compute the matchjump up to the last substring found to jump - * to the beginning of the largest must pattern prefix matching - * it's own suffix. - */ - for (mindex = 0; mindex <= suffix; mindex++) - g->matchjump[mindex] = MIN(g->matchjump[mindex], - g->mlen + suffix - mindex); - - ssuffix = pmatches[suffix]; - while (suffix < g->mlen) { - while (suffix <= ssuffix && suffix < g->mlen) { - g->matchjump[suffix] = MIN(g->matchjump[suffix], - g->mlen + ssuffix - suffix); - suffix++; - } - if (suffix < g->mlen) - ssuffix = pmatches[ssuffix]; - } - - free(pmatches); -} - -/* - - pluscount - count + nesting - == static sopno pluscount(struct parse *p, struct re_guts *g); - */ -static sopno /* nesting depth */ -pluscount(struct parse *p, struct re_guts *g) -{ - sop *scan; - sop s; - sopno plusnest = 0; - sopno maxnest = 0; - - if (p->error != 0) - return(0); /* there may not be an OEND */ - - scan = g->strip + 1; - do { - s = *scan++; - switch (OP(s)) { - case OPLUS_: - plusnest++; - break; - case O_PLUS: - if (plusnest > maxnest) - maxnest = plusnest; - plusnest--; - break; - } - } while (OP(s) != OEND); - if (plusnest != 0) - g->iflags |= BAD; - return(maxnest); -} diff --git a/winsup/cygwin/regex/regerror.c b/winsup/cygwin/regex/regerror.c deleted file mode 100644 index 1bba3e4a6..000000000 --- a/winsup/cygwin/regex/regerror.c +++ /dev/null @@ -1,190 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 1994 Henry Spencer. - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * 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. - * 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. - * - * @(#)regerror.c 8.4 (Berkeley) 3/20/94 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)regerror.c 8.4 (Berkeley) 3/20/94"; -#endif /* LIBC_SCCS and not lint */ -#include -__FBSDID("$FreeBSD: src/lib/libc/regex/regerror.c,v 1.11 2007/06/11 03:05:54 delphij Exp $"); - -#include -#include -#include -#include -#include -#include - -#include "utils.h" - -/* ========= begin header generated by ./mkh ========= */ -#ifdef __cplusplus -extern "C" { -#endif - -/* === regerror.c === */ -static char *regatoi(const regex_t *preg, char *localbuf); - -#ifdef __cplusplus -} -#endif -/* ========= end header generated by ./mkh ========= */ -/* - = #define REG_NOMATCH 1 - = #define REG_BADPAT 2 - = #define REG_ECOLLATE 3 - = #define REG_ECTYPE 4 - = #define REG_EESCAPE 5 - = #define REG_ESUBREG 6 - = #define REG_EBRACK 7 - = #define REG_EPAREN 8 - = #define REG_EBRACE 9 - = #define REG_BADBR 10 - = #define REG_ERANGE 11 - = #define REG_ESPACE 12 - = #define REG_BADRPT 13 - = #define REG_EMPTY 14 - = #define REG_ASSERT 15 - = #define REG_INVARG 16 - = #define REG_ILLSEQ 17 - = #define REG_ATOI 255 // convert name to number (!) - = #define REG_ITOA 0400 // convert number to name (!) - */ -static struct rerr { - int code; -#ifdef __CYGWIN__ /* Avoid whining compiler */ - const char *name; - const char *explain; -#else - char *name; - char *explain; -#endif -} rerrs[] = { - {REG_NOMATCH, "REG_NOMATCH", "regexec() failed to match"}, - {REG_BADPAT, "REG_BADPAT", "invalid regular expression"}, - {REG_ECOLLATE, "REG_ECOLLATE", "invalid collating element"}, - {REG_ECTYPE, "REG_ECTYPE", "invalid character class"}, - {REG_EESCAPE, "REG_EESCAPE", "trailing backslash (\\)"}, - {REG_ESUBREG, "REG_ESUBREG", "invalid backreference number"}, - {REG_EBRACK, "REG_EBRACK", "brackets ([ ]) not balanced"}, - {REG_EPAREN, "REG_EPAREN", "parentheses not balanced"}, - {REG_EBRACE, "REG_EBRACE", "braces not balanced"}, - {REG_BADBR, "REG_BADBR", "invalid repetition count(s)"}, - {REG_ERANGE, "REG_ERANGE", "invalid character range"}, - {REG_ESPACE, "REG_ESPACE", "out of memory"}, - {REG_BADRPT, "REG_BADRPT", "repetition-operator operand invalid"}, - {REG_EMPTY, "REG_EMPTY", "empty (sub)expression"}, - {REG_ASSERT, "REG_ASSERT", "\"can't happen\" -- you found a bug"}, - {REG_INVARG, "REG_INVARG", "invalid argument to regex routine"}, - {REG_ILLSEQ, "REG_ILLSEQ", "illegal byte sequence"}, - {0, "", "*** unknown regexp error code ***"} -}; - -/* - - regerror - the interface to error numbers - = extern size_t regerror(int, const regex_t *, char *, size_t); - */ -/* ARGSUSED */ -size_t -regerror(int errcode, - const regex_t * __restrict preg, - char * __restrict errbuf, - size_t errbuf_size) -{ - struct rerr *r; - size_t len; - int target = errcode &~ REG_ITOA; -#ifdef __CYGWIN__ /* Avoid whining compiler */ - const char *s; -#else - char *s; -#endif - char convbuf[50]; - - if (errcode == REG_ATOI) - s = regatoi(preg, convbuf); - else { - for (r = rerrs; r->code != 0; r++) - if (r->code == target) - break; - - if (errcode®_ITOA) { - if (r->code != 0) - (void) strcpy(convbuf, r->name); - else - sprintf(convbuf, "REG_0x%x", target); - assert(strlen(convbuf) < sizeof(convbuf)); - s = convbuf; - } else - s = r->explain; - } - - len = strlen(s) + 1; - if (errbuf_size > 0) { - if (errbuf_size > len) - (void) strcpy(errbuf, s); - else { - (void) strncpy(errbuf, s, errbuf_size-1); - errbuf[errbuf_size-1] = '\0'; - } - } - - return(len); -} - -/* - - regatoi - internal routine to implement REG_ATOI - == static char *regatoi(const regex_t *preg, char *localbuf); - */ -static char * -regatoi(const regex_t *preg, char *localbuf) -{ - struct rerr *r; - - for (r = rerrs; r->code != 0; r++) - if (strcmp(r->name, preg->re_endp) == 0) - break; - if (r->code == 0) -#ifdef __CYGWIN__ /* Avoid whining compiler */ - { - static char null[] = "0"; - return null; - } -#else - return("0"); -#endif - - sprintf(localbuf, "%d", r->code); - return(localbuf); -} diff --git a/winsup/cygwin/regex/regex.3 b/winsup/cygwin/regex/regex.3 deleted file mode 100644 index f848d66c3..000000000 --- a/winsup/cygwin/regex/regex.3 +++ /dev/null @@ -1,727 +0,0 @@ -.\" Copyright (c) 1992, 1993, 1994 Henry Spencer. -.\" Copyright (c) 1992, 1993, 1994 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Henry Spencer. -.\" -.\" 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. -.\" 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. -.\" -.\" @(#)regex.3 8.4 (Berkeley) 3/20/94 -.\" $FreeBSD: src/lib/libc/regex/regex.3,v 1.21 2007/01/09 00:28:04 imp Exp $ -.\" -.Dd August 17, 2005 -.Dt REGEX 3 -.Os -.Sh NAME -.Nm regcomp , -.Nm regexec , -.Nm regerror , -.Nm regfree -.Nd regular-expression library -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In regex.h -.Ft int -.Fo regcomp -.Fa "regex_t * restrict preg" "const char * restrict pattern" "int cflags" -.Fc -.Ft int -.Fo regexec -.Fa "const regex_t * restrict preg" "const char * restrict string" -.Fa "size_t nmatch" "regmatch_t pmatch[restrict]" "int eflags" -.Fc -.Ft size_t -.Fo regerror -.Fa "int errcode" "const regex_t * restrict preg" -.Fa "char * restrict errbuf" "size_t errbuf_size" -.Fc -.Ft void -.Fn regfree "regex_t *preg" -.Sh DESCRIPTION -These routines implement -.St -p1003.2 -regular expressions -.Pq Do RE Dc Ns s ; -see -.Xr re_format 7 . -The -.Fn regcomp -function -compiles an RE written as a string into an internal form, -.Fn regexec -matches that internal form against a string and reports results, -.Fn regerror -transforms error codes from either into human-readable messages, -and -.Fn regfree -frees any dynamically-allocated storage used by the internal form -of an RE. -.Pp -The header -.In regex.h -declares two structure types, -.Ft regex_t -and -.Ft regmatch_t , -the former for compiled internal forms and the latter for match reporting. -It also declares the four functions, -a type -.Ft regoff_t , -and a number of constants with names starting with -.Dq Dv REG_ . -.Pp -The -.Fn regcomp -function -compiles the regular expression contained in the -.Fa pattern -string, -subject to the flags in -.Fa cflags , -and places the results in the -.Ft regex_t -structure pointed to by -.Fa preg . -The -.Fa cflags -argument -is the bitwise OR of zero or more of the following flags: -.Bl -tag -width REG_EXTENDED -.It Dv REG_EXTENDED -Compile modern -.Pq Dq extended -REs, -rather than the obsolete -.Pq Dq basic -REs that -are the default. -.It Dv REG_BASIC -This is a synonym for 0, -provided as a counterpart to -.Dv REG_EXTENDED -to improve readability. -.It Dv REG_NOSPEC -Compile with recognition of all special characters turned off. -All characters are thus considered ordinary, -so the -.Dq RE -is a literal string. -This is an extension, -compatible with but not specified by -.St -p1003.2 , -and should be used with -caution in software intended to be portable to other systems. -.Dv REG_EXTENDED -and -.Dv REG_NOSPEC -may not be used -in the same call to -.Fn regcomp . -.It Dv REG_ICASE -Compile for matching that ignores upper/lower case distinctions. -See -.Xr re_format 7 . -.It Dv REG_NOSUB -Compile for matching that need only report success or failure, -not what was matched. -.It Dv REG_NEWLINE -Compile for newline-sensitive matching. -By default, newline is a completely ordinary character with no special -meaning in either REs or strings. -With this flag, -.Ql [^ -bracket expressions and -.Ql .\& -never match newline, -a -.Ql ^\& -anchor matches the null string after any newline in the string -in addition to its normal function, -and the -.Ql $\& -anchor matches the null string before any newline in the -string in addition to its normal function. -.It Dv REG_PEND -The regular expression ends, -not at the first NUL, -but just before the character pointed to by the -.Va re_endp -member of the structure pointed to by -.Fa preg . -The -.Va re_endp -member is of type -.Ft "const char *" . -This flag permits inclusion of NULs in the RE; -they are considered ordinary characters. -This is an extension, -compatible with but not specified by -.St -p1003.2 , -and should be used with -caution in software intended to be portable to other systems. -.El -.Pp -When successful, -.Fn regcomp -returns 0 and fills in the structure pointed to by -.Fa preg . -One member of that structure -(other than -.Va re_endp ) -is publicized: -.Va re_nsub , -of type -.Ft size_t , -contains the number of parenthesized subexpressions within the RE -(except that the value of this member is undefined if the -.Dv REG_NOSUB -flag was used). -If -.Fn regcomp -fails, it returns a non-zero error code; -see -.Sx DIAGNOSTICS . -.Pp -The -.Fn regexec -function -matches the compiled RE pointed to by -.Fa preg -against the -.Fa string , -subject to the flags in -.Fa eflags , -and reports results using -.Fa nmatch , -.Fa pmatch , -and the returned value. -The RE must have been compiled by a previous invocation of -.Fn regcomp . -The compiled form is not altered during execution of -.Fn regexec , -so a single compiled RE can be used simultaneously by multiple threads. -.Pp -By default, -the NUL-terminated string pointed to by -.Fa string -is considered to be the text of an entire line, minus any terminating -newline. -The -.Fa eflags -argument is the bitwise OR of zero or more of the following flags: -.Bl -tag -width REG_STARTEND -.It Dv REG_NOTBOL -The first character of -the string -is not the beginning of a line, so the -.Ql ^\& -anchor should not match before it. -This does not affect the behavior of newlines under -.Dv REG_NEWLINE . -.It Dv REG_NOTEOL -The NUL terminating -the string -does not end a line, so the -.Ql $\& -anchor should not match before it. -This does not affect the behavior of newlines under -.Dv REG_NEWLINE . -.It Dv REG_STARTEND -The string is considered to start at -.Fa string -+ -.Fa pmatch Ns [0]. Ns Va rm_so -and to have a terminating NUL located at -.Fa string -+ -.Fa pmatch Ns [0]. Ns Va rm_eo -(there need not actually be a NUL at that location), -regardless of the value of -.Fa nmatch . -See below for the definition of -.Fa pmatch -and -.Fa nmatch . -This is an extension, -compatible with but not specified by -.St -p1003.2 , -and should be used with -caution in software intended to be portable to other systems. -Note that a non-zero -.Va rm_so -does not imply -.Dv REG_NOTBOL ; -.Dv REG_STARTEND -affects only the location of the string, -not how it is matched. -.El -.Pp -See -.Xr re_format 7 -for a discussion of what is matched in situations where an RE or a -portion thereof could match any of several substrings of -.Fa string . -.Pp -Normally, -.Fn regexec -returns 0 for success and the non-zero code -.Dv REG_NOMATCH -for failure. -Other non-zero error codes may be returned in exceptional situations; -see -.Sx DIAGNOSTICS . -.Pp -If -.Dv REG_NOSUB -was specified in the compilation of the RE, -or if -.Fa nmatch -is 0, -.Fn regexec -ignores the -.Fa pmatch -argument (but see below for the case where -.Dv REG_STARTEND -is specified). -Otherwise, -.Fa pmatch -points to an array of -.Fa nmatch -structures of type -.Ft regmatch_t . -Such a structure has at least the members -.Va rm_so -and -.Va rm_eo , -both of type -.Ft regoff_t -(a signed arithmetic type at least as large as an -.Ft off_t -and a -.Ft ssize_t ) , -containing respectively the offset of the first character of a substring -and the offset of the first character after the end of the substring. -Offsets are measured from the beginning of the -.Fa string -argument given to -.Fn regexec . -An empty substring is denoted by equal offsets, -both indicating the character following the empty substring. -.Pp -The 0th member of the -.Fa pmatch -array is filled in to indicate what substring of -.Fa string -was matched by the entire RE. -Remaining members report what substring was matched by parenthesized -subexpressions within the RE; -member -.Va i -reports subexpression -.Va i , -with subexpressions counted (starting at 1) by the order of their opening -parentheses in the RE, left to right. -Unused entries in the array (corresponding either to subexpressions that -did not participate in the match at all, or to subexpressions that do not -exist in the RE (that is, -.Va i -> -.Fa preg Ns -> Ns Va re_nsub ) ) -have both -.Va rm_so -and -.Va rm_eo -set to -1. -If a subexpression participated in the match several times, -the reported substring is the last one it matched. -(Note, as an example in particular, that when the RE -.Ql "(b*)+" -matches -.Ql bbb , -the parenthesized subexpression matches each of the three -.So Li b Sc Ns s -and then -an infinite number of empty strings following the last -.Ql b , -so the reported substring is one of the empties.) -.Pp -If -.Dv REG_STARTEND -is specified, -.Fa pmatch -must point to at least one -.Ft regmatch_t -(even if -.Fa nmatch -is 0 or -.Dv REG_NOSUB -was specified), -to hold the input offsets for -.Dv REG_STARTEND . -Use for output is still entirely controlled by -.Fa nmatch ; -if -.Fa nmatch -is 0 or -.Dv REG_NOSUB -was specified, -the value of -.Fa pmatch Ns [0] -will not be changed by a successful -.Fn regexec . -.Pp -The -.Fn regerror -function -maps a non-zero -.Fa errcode -from either -.Fn regcomp -or -.Fn regexec -to a human-readable, printable message. -If -.Fa preg -is -.No non\- Ns Dv NULL , -the error code should have arisen from use of -the -.Ft regex_t -pointed to by -.Fa preg , -and if the error code came from -.Fn regcomp , -it should have been the result from the most recent -.Fn regcomp -using that -.Ft regex_t . -The -.Fn ( regerror -may be able to supply a more detailed message using information -from the -.Ft regex_t . ) -The -.Fn regerror -function -places the NUL-terminated message into the buffer pointed to by -.Fa errbuf , -limiting the length (including the NUL) to at most -.Fa errbuf_size -bytes. -If the whole message will not fit, -as much of it as will fit before the terminating NUL is supplied. -In any case, -the returned value is the size of buffer needed to hold the whole -message (including terminating NUL). -If -.Fa errbuf_size -is 0, -.Fa errbuf -is ignored but the return value is still correct. -.Pp -If the -.Fa errcode -given to -.Fn regerror -is first ORed with -.Dv REG_ITOA , -the -.Dq message -that results is the printable name of the error code, -e.g.\& -.Dq Dv REG_NOMATCH , -rather than an explanation thereof. -If -.Fa errcode -is -.Dv REG_ATOI , -then -.Fa preg -shall be -.No non\- Ns Dv NULL -and the -.Va re_endp -member of the structure it points to -must point to the printable name of an error code; -in this case, the result in -.Fa errbuf -is the decimal digits of -the numeric value of the error code -(0 if the name is not recognized). -.Dv REG_ITOA -and -.Dv REG_ATOI -are intended primarily as debugging facilities; -they are extensions, -compatible with but not specified by -.St -p1003.2 , -and should be used with -caution in software intended to be portable to other systems. -Be warned also that they are considered experimental and changes are possible. -.Pp -The -.Fn regfree -function -frees any dynamically-allocated storage associated with the compiled RE -pointed to by -.Fa preg . -The remaining -.Ft regex_t -is no longer a valid compiled RE -and the effect of supplying it to -.Fn regexec -or -.Fn regerror -is undefined. -.Pp -None of these functions references global variables except for tables -of constants; -all are safe for use from multiple threads if the arguments are safe. -.Sh IMPLEMENTATION CHOICES -There are a number of decisions that -.St -p1003.2 -leaves up to the implementor, -either by explicitly saying -.Dq undefined -or by virtue of them being -forbidden by the RE grammar. -This implementation treats them as follows. -.Pp -See -.Xr re_format 7 -for a discussion of the definition of case-independent matching. -.Pp -There is no particular limit on the length of REs, -except insofar as memory is limited. -Memory usage is approximately linear in RE size, and largely insensitive -to RE complexity, except for bounded repetitions. -See -.Sx BUGS -for one short RE using them -that will run almost any system out of memory. -.Pp -A backslashed character other than one specifically given a magic meaning -by -.St -p1003.2 -(such magic meanings occur only in obsolete -.Bq Dq basic -REs) -is taken as an ordinary character. -.Pp -Any unmatched -.Ql [\& -is a -.Dv REG_EBRACK -error. -.Pp -Equivalence classes cannot begin or end bracket-expression ranges. -The endpoint of one range cannot begin another. -.Pp -.Dv RE_DUP_MAX , -the limit on repetition counts in bounded repetitions, is 255. -.Pp -A repetition operator -.Ql ( ?\& , -.Ql *\& , -.Ql +\& , -or bounds) -cannot follow another -repetition operator. -A repetition operator cannot begin an expression or subexpression -or follow -.Ql ^\& -or -.Ql |\& . -.Pp -.Ql |\& -cannot appear first or last in a (sub)expression or after another -.Ql |\& , -i.e., an operand of -.Ql |\& -cannot be an empty subexpression. -An empty parenthesized subexpression, -.Ql "()" , -is legal and matches an -empty (sub)string. -An empty string is not a legal RE. -.Pp -A -.Ql {\& -followed by a digit is considered the beginning of bounds for a -bounded repetition, which must then follow the syntax for bounds. -A -.Ql {\& -.Em not -followed by a digit is considered an ordinary character. -.Pp -.Ql ^\& -and -.Ql $\& -beginning and ending subexpressions in obsolete -.Pq Dq basic -REs are anchors, not ordinary characters. -.Sh DIAGNOSTICS -Non-zero error codes from -.Fn regcomp -and -.Fn regexec -include the following: -.Pp -.Bl -tag -width REG_ECOLLATE -compact -.It Dv REG_NOMATCH -The -.Fn regexec -function -failed to match -.It Dv REG_BADPAT -invalid regular expression -.It Dv REG_ECOLLATE -invalid collating element -.It Dv REG_ECTYPE -invalid character class -.It Dv REG_EESCAPE -.Ql \e -applied to unescapable character -.It Dv REG_ESUBREG -invalid backreference number -.It Dv REG_EBRACK -brackets -.Ql "[ ]" -not balanced -.It Dv REG_EPAREN -parentheses -.Ql "( )" -not balanced -.It Dv REG_EBRACE -braces -.Ql "{ }" -not balanced -.It Dv REG_BADBR -invalid repetition count(s) in -.Ql "{ }" -.It Dv REG_ERANGE -invalid character range in -.Ql "[ ]" -.It Dv REG_ESPACE -ran out of memory -.It Dv REG_BADRPT -.Ql ?\& , -.Ql *\& , -or -.Ql +\& -operand invalid -.It Dv REG_EMPTY -empty (sub)expression -.It Dv REG_ASSERT -cannot happen - you found a bug -.It Dv REG_INVARG -invalid argument, e.g.\& negative-length string -.It Dv REG_ILLSEQ -illegal byte sequence (bad multibyte character) -.El -.Sh SEE ALSO -.Xr grep 1 , -.Xr re_format 7 -.Pp -.St -p1003.2 , -sections 2.8 (Regular Expression Notation) -and -B.5 (C Binding for Regular Expression Matching). -.Sh HISTORY -Originally written by -.An Henry Spencer . -Altered for inclusion in the -.Bx 4.4 -distribution. -.Sh BUGS -This is an alpha release with known defects. -Please report problems. -.Pp -The back-reference code is subtle and doubts linger about its correctness -in complex cases. -.Pp -The -.Fn regexec -function -performance is poor. -This will improve with later releases. -The -.Fa nmatch -argument -exceeding 0 is expensive; -.Fa nmatch -exceeding 1 is worse. -The -.Fn regexec -function -is largely insensitive to RE complexity -.Em except -that back -references are massively expensive. -RE length does matter; in particular, there is a strong speed bonus -for keeping RE length under about 30 characters, -with most special characters counting roughly double. -.Pp -The -.Fn regcomp -function -implements bounded repetitions by macro expansion, -which is costly in time and space if counts are large -or bounded repetitions are nested. -An RE like, say, -.Ql "((((a{1,100}){1,100}){1,100}){1,100}){1,100}" -will (eventually) run almost any existing machine out of swap space. -.Pp -There are suspected problems with response to obscure error conditions. -Notably, -certain kinds of internal overflow, -produced only by truly enormous REs or by multiply nested bounded repetitions, -are probably not handled well. -.Pp -Due to a mistake in -.St -p1003.2 , -things like -.Ql "a)b" -are legal REs because -.Ql )\& -is -a special character only in the presence of a previous unmatched -.Ql (\& . -This cannot be fixed until the spec is fixed. -.Pp -The standard's definition of back references is vague. -For example, does -.Ql "a\e(\e(b\e)*\e2\e)*d" -match -.Ql "abbbd" ? -Until the standard is clarified, -behavior in such cases should not be relied on. -.Pp -The implementation of word-boundary matching is a bit of a kludge, -and bugs may lurk in combinations of word-boundary matching and anchoring. -.Pp -Word-boundary matching does not work properly in multibyte locales. diff --git a/winsup/cygwin/regex/regex.7 b/winsup/cygwin/regex/regex.7 deleted file mode 100644 index 79fecc197..000000000 --- a/winsup/cygwin/regex/regex.7 +++ /dev/null @@ -1,480 +0,0 @@ -.\" Copyright (c) 1992, 1993, 1994 Henry Spencer. -.\" Copyright (c) 1992, 1993, 1994 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Henry Spencer. -.\" -.\" 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. -.\" 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. -.\" -.\" @(#)re_format.7 8.3 (Berkeley) 3/20/94 -.\" $FreeBSD: src/lib/libc/regex/re_format.7,v 1.12 2008/09/05 17:41:20 keramida Exp $ -.\" -.Dd March 20, 1994 -.Dt RE_FORMAT 7 -.Os -.Sh NAME -.Nm re_format -.Nd POSIX 1003.2 regular expressions -.Sh DESCRIPTION -Regular expressions -.Pq Dq RE Ns s , -as defined in -.St -p1003.2 , -come in two forms: -modern REs (roughly those of -.Xr egrep 1 ; -1003.2 calls these -.Dq extended -REs) -and obsolete REs (roughly those of -.Xr ed 1 ; -1003.2 -.Dq basic -REs). -Obsolete REs mostly exist for backward compatibility in some old programs; -they will be discussed at the end. -.St -p1003.2 -leaves some aspects of RE syntax and semantics open; -`\(dd' marks decisions on these aspects that -may not be fully portable to other -.St -p1003.2 -implementations. -.Pp -A (modern) RE is one\(dd or more non-empty\(dd -.Em branches , -separated by -.Ql \&| . -It matches anything that matches one of the branches. -.Pp -A branch is one\(dd or more -.Em pieces , -concatenated. -It matches a match for the first, followed by a match for the second, etc. -.Pp -A piece is an -.Em atom -possibly followed -by a single\(dd -.Ql \&* , -.Ql \&+ , -.Ql \&? , -or -.Em bound . -An atom followed by -.Ql \&* -matches a sequence of 0 or more matches of the atom. -An atom followed by -.Ql \&+ -matches a sequence of 1 or more matches of the atom. -An atom followed by -.Ql ?\& -matches a sequence of 0 or 1 matches of the atom. -.Pp -A -.Em bound -is -.Ql \&{ -followed by an unsigned decimal integer, -possibly followed by -.Ql \&, -possibly followed by another unsigned decimal integer, -always followed by -.Ql \&} . -The integers must lie between 0 and -.Dv RE_DUP_MAX -(255\(dd) inclusive, -and if there are two of them, the first may not exceed the second. -An atom followed by a bound containing one integer -.Em i -and no comma matches -a sequence of exactly -.Em i -matches of the atom. -An atom followed by a bound -containing one integer -.Em i -and a comma matches -a sequence of -.Em i -or more matches of the atom. -An atom followed by a bound -containing two integers -.Em i -and -.Em j -matches -a sequence of -.Em i -through -.Em j -(inclusive) matches of the atom. -.Pp -An atom is a regular expression enclosed in -.Ql () -(matching a match for the -regular expression), -an empty set of -.Ql () -(matching the null string)\(dd, -a -.Em bracket expression -(see below), -.Ql .\& -(matching any single character), -.Ql \&^ -(matching the null string at the beginning of a line), -.Ql \&$ -(matching the null string at the end of a line), a -.Ql \e -followed by one of the characters -.Ql ^.[$()|*+?{\e -(matching that character taken as an ordinary character), -a -.Ql \e -followed by any other character\(dd -(matching that character taken as an ordinary character, -as if the -.Ql \e -had not been present\(dd), -or a single character with no other significance (matching that character). -A -.Ql \&{ -followed by a character other than a digit is an ordinary -character, not the beginning of a bound\(dd. -It is illegal to end an RE with -.Ql \e . -.Pp -A -.Em bracket expression -is a list of characters enclosed in -.Ql [] . -It normally matches any single character from the list (but see below). -If the list begins with -.Ql \&^ , -it matches any single character -(but see below) -.Em not -from the rest of the list. -If two characters in the list are separated by -.Ql \&- , -this is shorthand -for the full -.Em range -of characters between those two (inclusive) in the -collating sequence, -.No e.g. Ql [0-9] -in ASCII matches any decimal digit. -It is illegal\(dd for two ranges to share an -endpoint, -.No e.g. Ql a-c-e . -Ranges are very collating-sequence-dependent, -and portable programs should avoid relying on them. -.Pp -To include a literal -.Ql \&] -in the list, make it the first character -(following a possible -.Ql \&^ ) . -To include a literal -.Ql \&- , -make it the first or last character, -or the second endpoint of a range. -To use a literal -.Ql \&- -as the first endpoint of a range, -enclose it in -.Ql [.\& -and -.Ql .]\& -to make it a collating element (see below). -With the exception of these and some combinations using -.Ql \&[ -(see next paragraphs), all other special characters, including -.Ql \e , -lose their special significance within a bracket expression. -.Pp -Within a bracket expression, a collating element (a character, -a multi-character sequence that collates as if it were a single character, -or a collating-sequence name for either) -enclosed in -.Ql [.\& -and -.Ql .]\& -stands for the -sequence of characters of that collating element. -The sequence is a single element of the bracket expression's list. -A bracket expression containing a multi-character collating element -can thus match more than one character, -e.g.\& if the collating sequence includes a -.Ql ch -collating element, -then the RE -.Ql [[.ch.]]*c -matches the first five characters -of -.Ql chchcc . -.Pp -Within a bracket expression, a collating element enclosed in -.Ql [= -and -.Ql =] -is an equivalence class, standing for the sequences of characters -of all collating elements equivalent to that one, including itself. -(If there are no other equivalent collating elements, -the treatment is as if the enclosing delimiters were -.Ql [.\& -and -.Ql .] . ) -For example, if -.Ql x -and -.Ql y -are the members of an equivalence class, -then -.Ql [[=x=]] , -.Ql [[=y=]] , -and -.Ql [xy] -are all synonymous. -An equivalence class may not\(dd be an endpoint -of a range. -.Pp -Within a bracket expression, the name of a -.Em character class -enclosed in -.Ql [: -and -.Ql :] -stands for the list of all characters belonging to that -class. -Standard character class names are: -.Pp -.Bl -column "alnum" "digit" "xdigit" -offset indent -.It Em "alnum digit punct" -.It Em "alpha graph space" -.It Em "blank lower upper" -.It Em "cntrl print xdigit" -.El -.Pp -These stand for the character classes defined in -.Xr ctype 3 . -A locale may provide others. -A character class may not be used as an endpoint of a range. -.Pp -A bracketed expression like -.Ql [[:class:]] -can be used to match a single character that belongs to a character -class. -The reverse, matching any character that does not belong to a specific -class, the negation operator of bracket expressions may be used: -.Ql [^[:class:]] . -.Pp -There are two special cases\(dd of bracket expressions: -the bracket expressions -.Ql [[:<:]] -and -.Ql [[:>:]] -match the null string at the beginning and end of a word respectively. -A word is defined as a sequence of word characters -which is neither preceded nor followed by -word characters. -A word character is an -.Em alnum -character (as defined by -.Xr ctype 3 ) -or an underscore. -This is an extension, -compatible with but not specified by -.St -p1003.2 , -and should be used with -caution in software intended to be portable to other systems. -.Pp -In the event that an RE could match more than one substring of a given -string, -the RE matches the one starting earliest in the string. -If the RE could match more than one substring starting at that point, -it matches the longest. -Subexpressions also match the longest possible substrings, subject to -the constraint that the whole match be as long as possible, -with subexpressions starting earlier in the RE taking priority over -ones starting later. -Note that higher-level subexpressions thus take priority over -their lower-level component subexpressions. -.Pp -Match lengths are measured in characters, not collating elements. -A null string is considered longer than no match at all. -For example, -.Ql bb* -matches the three middle characters of -.Ql abbbc , -.Ql (wee|week)(knights|nights) -matches all ten characters of -.Ql weeknights , -when -.Ql (.*).*\& -is matched against -.Ql abc -the parenthesized subexpression -matches all three characters, and -when -.Ql (a*)* -is matched against -.Ql bc -both the whole RE and the parenthesized -subexpression match the null string. -.Pp -If case-independent matching is specified, -the effect is much as if all case distinctions had vanished from the -alphabet. -When an alphabetic that exists in multiple cases appears as an -ordinary character outside a bracket expression, it is effectively -transformed into a bracket expression containing both cases, -.No e.g. Ql x -becomes -.Ql [xX] . -When it appears inside a bracket expression, all case counterparts -of it are added to the bracket expression, so that (e.g.) -.Ql [x] -becomes -.Ql [xX] -and -.Ql [^x] -becomes -.Ql [^xX] . -.Pp -No particular limit is imposed on the length of REs\(dd. -Programs intended to be portable should not employ REs longer -than 256 bytes, -as an implementation can refuse to accept such REs and remain -POSIX-compliant. -.Pp -Obsolete -.Pq Dq basic -regular expressions differ in several respects. -.Ql \&| -is an ordinary character and there is no equivalent -for its functionality. -.Ql \&+ -and -.Ql ?\& -are ordinary characters, and their functionality -can be expressed using bounds -.No ( Ql {1,} -or -.Ql {0,1} -respectively). -Also note that -.Ql x+ -in modern REs is equivalent to -.Ql xx* . -The delimiters for bounds are -.Ql \e{ -and -.Ql \e} , -with -.Ql \&{ -and -.Ql \&} -by themselves ordinary characters. -The parentheses for nested subexpressions are -.Ql \e( -and -.Ql \e) , -with -.Ql \&( -and -.Ql \&) -by themselves ordinary characters. -.Ql \&^ -is an ordinary character except at the beginning of the -RE or\(dd the beginning of a parenthesized subexpression, -.Ql \&$ -is an ordinary character except at the end of the -RE or\(dd the end of a parenthesized subexpression, -and -.Ql \&* -is an ordinary character if it appears at the beginning of the -RE or the beginning of a parenthesized subexpression -(after a possible leading -.Ql \&^ ) . -Finally, there is one new type of atom, a -.Em back reference : -.Ql \e -followed by a non-zero decimal digit -.Em d -matches the same sequence of characters -matched by the -.Em d Ns th -parenthesized subexpression -(numbering subexpressions by the positions of their opening parentheses, -left to right), -so that (e.g.) -.Ql \e([bc]\e)\e1 -matches -.Ql bb -or -.Ql cc -but not -.Ql bc . -.Sh SEE ALSO -.Xr regex 3 -.Rs -.%T Regular Expression Notation -.%R IEEE Std -.%N 1003.2 -.%P section 2.8 -.Re -.Sh BUGS -Having two kinds of REs is a botch. -.Pp -The current -.St -p1003.2 -spec says that -.Ql \&) -is an ordinary character in -the absence of an unmatched -.Ql \&( ; -this was an unintentional result of a wording error, -and change is likely. -Avoid relying on it. -.Pp -Back references are a dreadful botch, -posing major problems for efficient implementations. -They are also somewhat vaguely defined -(does -.Ql a\e(\e(b\e)*\e2\e)*d -match -.Ql abbbd ? ) . -Avoid using them. -.Pp -.St -p1003.2 -specification of case-independent matching is vague. -The -.Dq one case implies all cases -definition given above -is current consensus among implementors as to the right interpretation. -.Pp -The syntax for word boundaries is incredibly ugly. diff --git a/winsup/cygwin/regex/regex2.h b/winsup/cygwin/regex/regex2.h deleted file mode 100644 index 53f687bf6..000000000 --- a/winsup/cygwin/regex/regex2.h +++ /dev/null @@ -1,196 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 1994 Henry Spencer. - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * 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. - * 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. - * - * @(#)regex2.h 8.4 (Berkeley) 3/20/94 - * $FreeBSD: src/lib/libc/regex/regex2.h,v 1.11 2007/01/09 00:28:04 imp Exp $ - */ - -/* - * First, the stuff that ends up in the outside-world include file - = typedef off_t regoff_t; - = typedef struct { - = int re_magic; - = size_t re_nsub; // number of parenthesized subexpressions - = const char *re_endp; // end pointer for REG_PEND - = struct re_guts *re_g; // none of your business :-) - = } regex_t; - = typedef struct { - = regoff_t rm_so; // start of match - = regoff_t rm_eo; // end of match - = } regmatch_t; - */ -/* - * internals of regex_t - */ -#define MAGIC1 ((('r'^0200)<<8) | 'e') - -/* - * The internal representation is a *strip*, a sequence of - * operators ending with an endmarker. (Some terminology etc. is a - * historical relic of earlier versions which used multiple strips.) - * Certain oddities in the representation are there to permit running - * the machinery backwards; in particular, any deviation from sequential - * flow must be marked at both its source and its destination. Some - * fine points: - * - * - OPLUS_ and O_PLUS are *inside* the loop they create. - * - OQUEST_ and O_QUEST are *outside* the bypass they create. - * - OCH_ and O_CH are *outside* the multi-way branch they create, while - * OOR1 and OOR2 are respectively the end and the beginning of one of - * the branches. Note that there is an implicit OOR2 following OCH_ - * and an implicit OOR1 preceding O_CH. - * - * In state representations, an operator's bit is on to signify a state - * immediately *preceding* "execution" of that operator. - */ -typedef unsigned long sop; /* strip operator */ -typedef long sopno; -#define OPRMASK 0xf8000000L -#define OPDMASK 0x07ffffffL -#define OPSHIFT ((unsigned)27) -#define OP(n) ((n)&OPRMASK) -#define OPND(n) ((n)&OPDMASK) -#define SOP(op, opnd) ((op)|(opnd)) -/* operators meaning operand */ -/* (back, fwd are offsets) */ -#define OEND (1L<= 0); - if (ch < NC) - return (((cs->bmp[ch >> 3] & (1 << (ch & 7))) != 0) ^ - cs->invert); - for (i = 0; i < cs->nwides; i++) - if (ch == cs->wides[i]) - return (!cs->invert); - for (i = 0; i < cs->nranges; i++) - if (cs->ranges[i].min <= ch && ch <= cs->ranges[i].max) - return (!cs->invert); - for (i = 0; i < cs->ntypes; i++) - if (iswctype(ch, cs->types[i])) - return (!cs->invert); - return (cs->invert); -} - -static __inline int -CHIN(cset *cs, wint_t ch) -{ - - assert(ch >= 0); - if (ch < NC) - return (((cs->bmp[ch >> 3] & (1 << (ch & 7))) != 0) ^ - cs->invert); - else if (cs->icase) { - if (cs->invert) - return (CHIN1(cs, ch) && CHIN1(cs, towlower(ch)) && - CHIN1(cs, towupper(ch))); - else - return (CHIN1(cs, ch) || CHIN1(cs, towlower(ch)) || - CHIN1(cs, towupper(ch))); - } else - return (CHIN1(cs, ch)); -} - -/* - * main compiled-expression structure - */ -struct re_guts { - int magic; -# define MAGIC2 ((('R'^0200)<<8)|'E') - sop *strip; /* malloced area for strip */ - int ncsets; /* number of csets in use */ - cset *sets; /* -> cset [ncsets] */ - int cflags; /* copy of regcomp() cflags argument */ - sopno nstates; /* = number of sops */ - sopno firststate; /* the initial OEND (normally 0) */ - sopno laststate; /* the final OEND */ - int iflags; /* internal flags */ -# define USEBOL 01 /* used ^ */ -# define USEEOL 02 /* used $ */ -# define BAD 04 /* something wrong */ - int nbol; /* number of ^ used */ - int neol; /* number of $ used */ - char *must; /* match must contain this string */ - int moffset; /* latest point at which must may be located */ - int *charjump; /* Boyer-Moore char jump table */ - int *matchjump; /* Boyer-Moore match jump table */ - int mlen; /* length of must */ - size_t nsub; /* copy of re_nsub */ - int backrefs; /* does it use back references? */ - sopno nplus; /* how deep does it nest +s? */ -}; - -/* misc utilities */ -#define OUT (CHAR_MIN - 1) /* a non-character value */ -#define ISWORD(c) (iswalnum((wint_t)(c)) || (c) == '_') diff --git a/winsup/cygwin/regex/regexec.c b/winsup/cygwin/regex/regexec.c deleted file mode 100644 index ad12ada41..000000000 --- a/winsup/cygwin/regex/regexec.c +++ /dev/null @@ -1,256 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 1994 Henry Spencer. - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * 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. - * 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. - * - * @(#)regexec.c 8.3 (Berkeley) 3/20/94 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)regexec.c 8.3 (Berkeley) 3/20/94"; -#endif /* LIBC_SCCS and not lint */ -#include -__FBSDID("$FreeBSD: src/lib/libc/regex/regexec.c,v 1.8 2007/06/11 03:05:54 delphij Exp $"); - -/* - * the outer shell of regexec() - * - * This file includes engine.c three times, after muchos fiddling with the - * macros that code uses. This lets the same code operate on two different - * representations for state sets and characters. - */ -#ifdef __CYGWIN__ -#include "winsup.h" -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "utils.h" -#include "regex2.h" - -#ifdef __CYGWIN__ -#define __unused __attribute__ ((unused)) -#endif - -static int nope __unused = 0; /* for use in asserts; shuts lint up */ - -static __inline size_t -xmbrtowc(wint_t *wi, const char *s, size_t n, mbstate_t *mbs, wint_t dummy) -{ - size_t nr; - wchar_t wc; - - nr = mbrtowc(&wc, s, n, mbs); - if (wi != NULL) - *wi = wc; - if (nr == 0) - return (1); - else if (nr == (size_t)-1 || nr == (size_t)-2) { - memset(mbs, 0, sizeof(*mbs)); - if (wi != NULL) - *wi = dummy; - return (1); - } else { - if (sizeof (wchar_t) == 2 && wc >= 0xd800 && wc <= 0xdbff) { - /* UTF-16 surrogate pair. Fetch second half and - compute UTF-32 value */ - size_t n2 = mbrtowc(&wc, s + nr, n - nr, mbs); - if (n2 == 0 || n2 == (size_t)-1 || n2 == (size_t)-2) { - memset(mbs, 0, sizeof(*mbs)); - if (wi != NULL) - *wi = dummy; - return (1); - } - if (wi != NULL) - *wi = (((*wi & 0x3ff) << 10) | (wc & 0x3ff)) - + 0x10000; - nr += n2; - } - return (nr); - } -} - -static __inline size_t -xmbrtowc_dummy(wint_t *wi, - const char *s, - size_t n __unused, - mbstate_t *mbs __unused, - wint_t dummy __unused) -{ - - if (wi != NULL) - *wi = (unsigned char)*s; - return (1); -} - -/* macros for manipulating states, small version */ -#define states long -#define states1 states /* for later use in regexec() decision */ -#define CLEAR(v) ((v) = 0) -#define SET0(v, n) ((v) &= ~((unsigned long)1 << (n))) -#define SET1(v, n) ((v) |= (unsigned long)1 << (n)) -#define ISSET(v, n) (((v) & ((unsigned long)1 << (n))) != 0) -#define ASSIGN(d, s) ((d) = (s)) -#define EQ(a, b) ((a) == (b)) -#define STATEVARS long dummy /* dummy version */ -#define STATESETUP(m, n) /* nothing */ -#define STATETEARDOWN(m) /* nothing */ -#define SETUP(v) ((v) = 0) -#define onestate long -#define INIT(o, n) ((o) = (unsigned long)1 << (n)) -#define INC(o) ((o) <<= 1) -#define ISSTATEIN(v, o) (((v) & (o)) != 0) -/* some abbreviations; note that some of these know variable names! */ -/* do "if I'm here, I can also be there" etc without branches */ -#define FWD(dst, src, n) ((dst) |= ((unsigned long)(src)&(here)) << (n)) -#define BACK(dst, src, n) ((dst) |= ((unsigned long)(src)&(here)) >> (n)) -#define ISSETBACK(v, n) (((v) & ((unsigned long)here >> (n))) != 0) -/* no multibyte support */ -#define XMBRTOWC xmbrtowc_dummy -#define ZAPSTATE(mbs) ((void)(mbs)) -/* function names */ -#define SNAMES /* engine.c looks after details */ - -#include "engine.c" - -/* now undo things */ -#undef states -#undef CLEAR -#undef SET0 -#undef SET1 -#undef ISSET -#undef ASSIGN -#undef EQ -#undef STATEVARS -#undef STATESETUP -#undef STATETEARDOWN -#undef SETUP -#undef onestate -#undef INIT -#undef INC -#undef ISSTATEIN -#undef FWD -#undef BACK -#undef ISSETBACK -#undef SNAMES -#undef XMBRTOWC -#undef ZAPSTATE - -/* macros for manipulating states, large version */ -#define states char * -#define CLEAR(v) memset(v, 0, m->g->nstates) -#define SET0(v, n) ((v)[n] = 0) -#define SET1(v, n) ((v)[n] = 1) -#define ISSET(v, n) ((v)[n]) -#define ASSIGN(d, s) memcpy(d, s, m->g->nstates) -#define EQ(a, b) (memcmp(a, b, m->g->nstates) == 0) -#define STATEVARS long vn; char *space -#define STATESETUP(m, nv) { (m)->space = malloc((nv)*(m)->g->nstates); \ - if ((m)->space == NULL) return(REG_ESPACE); \ - (m)->vn = 0; } -#define STATETEARDOWN(m) { free((m)->space); } -#define SETUP(v) ((v) = &m->space[m->vn++ * m->g->nstates]) -#define onestate long -#define INIT(o, n) ((o) = (n)) -#define INC(o) ((o)++) -#define ISSTATEIN(v, o) ((v)[o]) -/* some abbreviations; note that some of these know variable names! */ -/* do "if I'm here, I can also be there" etc without branches */ -#define FWD(dst, src, n) ((dst)[here+(n)] |= (src)[here]) -#define BACK(dst, src, n) ((dst)[here-(n)] |= (src)[here]) -#define ISSETBACK(v, n) ((v)[here - (n)]) -/* no multibyte support */ -#define XMBRTOWC xmbrtowc_dummy -#define ZAPSTATE(mbs) ((void)(mbs)) -/* function names */ -#define LNAMES /* flag */ - -#include "engine.c" - -/* multibyte character & large states version */ -#undef LNAMES -#undef XMBRTOWC -#undef ZAPSTATE -#define XMBRTOWC xmbrtowc -#define ZAPSTATE(mbs) memset((mbs), 0, sizeof(*(mbs))) -#define MNAMES - -#include "engine.c" - -/* - - regexec - interface for matching - = extern int regexec(const regex_t *, const char *, size_t, \ - = regmatch_t [], int); - = #define REG_NOTBOL 00001 - = #define REG_NOTEOL 00002 - = #define REG_STARTEND 00004 - = #define REG_TRACE 00400 // tracing of execution - = #define REG_LARGE 01000 // force large representation - = #define REG_BACKR 02000 // force use of backref code - * - * We put this here so we can exploit knowledge of the state representation - * when choosing which matcher to call. Also, by this point the matchers - * have been prototyped. - */ -int /* 0 success, REG_NOMATCH failure */ -regexec(const regex_t * __restrict preg, - const char * __restrict string, - size_t nmatch, - regmatch_t pmatch[__restrict], - int eflags) -{ - struct re_guts *g = preg->re_g; -#ifdef REDEBUG -# define GOODFLAGS(f) (f) -#else -# define GOODFLAGS(f) ((f)&(REG_NOTBOL|REG_NOTEOL|REG_STARTEND)) -#endif - - if (preg->re_magic != MAGIC1 || g->magic != MAGIC2) - return(REG_BADPAT); - assert(!(g->iflags&BAD)); - if (g->iflags&BAD) /* backstop for no-debug case */ - return(REG_BADPAT); - eflags = GOODFLAGS(eflags); - - if (MB_CUR_MAX > 1) - return(mmatcher(g, (char *)string, nmatch, pmatch, eflags)); - else if (g->nstates <= CHAR_BIT*sizeof(states1) && !(eflags®_LARGE)) - return(smatcher(g, (char *)string, nmatch, pmatch, eflags)); - else - return(lmatcher(g, (char *)string, nmatch, pmatch, eflags)); -} diff --git a/winsup/cygwin/regex/regfree.c b/winsup/cygwin/regex/regfree.c deleted file mode 100644 index aa795fa78..000000000 --- a/winsup/cygwin/regex/regfree.c +++ /dev/null @@ -1,89 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 1994 Henry Spencer. - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * 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. - * 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. - * - * @(#)regfree.c 8.3 (Berkeley) 3/20/94 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)regfree.c 8.3 (Berkeley) 3/20/94"; -#endif /* LIBC_SCCS and not lint */ -#include -__FBSDID("$FreeBSD: src/lib/libc/regex/regfree.c,v 1.8 2007/06/11 03:05:54 delphij Exp $"); - -#include -#include -#include -#include -#include -#include -#include - -#include "utils.h" -#include "regex2.h" - -/* - - regfree - free everything - = extern void regfree(regex_t *); - */ -void -regfree(regex_t *preg) -{ - struct re_guts *g; - int i; - - if (preg->re_magic != MAGIC1) /* oops */ - return; /* nice to complain, but hard */ - - g = preg->re_g; - if (g == NULL || g->magic != MAGIC2) /* oops again */ - return; - preg->re_magic = 0; /* mark it invalid */ - g->magic = 0; /* mark it invalid */ - - if (g->strip != NULL) - free((char *)g->strip); - if (g->sets != NULL) { - for (i = 0; i < g->ncsets; i++) { - free(g->sets[i].ranges); - free(g->sets[i].wides); - free(g->sets[i].types); - } - free((char *)g->sets); - } - if (g->must != NULL) - free(g->must); - if (g->charjump != NULL) - free(&g->charjump[CHAR_MIN]); - if (g->matchjump != NULL) - free(g->matchjump); - free((char *)g); -} diff --git a/winsup/cygwin/regex/utils.h b/winsup/cygwin/regex/utils.h deleted file mode 100644 index 2a2ed9694..000000000 --- a/winsup/cygwin/regex/utils.h +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 1994 Henry Spencer. - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * 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. - * 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. - * - * @(#)utils.h 8.3 (Berkeley) 3/20/94 - * $FreeBSD: src/lib/libc/regex/utils.h,v 1.3 2007/01/09 00:28:04 imp Exp $ - */ - -/* utility definitions */ -#define DUPMAX _POSIX2_RE_DUP_MAX /* xxx is this right? */ -#define INFINITY (DUPMAX + 1) -#define NC (CHAR_MAX - CHAR_MIN + 1) -typedef unsigned char uch; - -/* switch off assertions (if not already off) if no REDEBUG */ -#ifndef REDEBUG -#ifndef NDEBUG -#define NDEBUG /* no assertions please */ -#endif -#endif -#include - -/* for old systems with bcopy() but no memmove() */ -#ifdef USEBCOPY -#define memmove(d, s, c) bcopy(s, d, c) -#endif diff --git a/winsup/cygwin/registry.cc b/winsup/cygwin/registry.cc deleted file mode 100644 index c71ff7902..000000000 --- a/winsup/cygwin/registry.cc +++ /dev/null @@ -1,313 +0,0 @@ -/* registry.cc: registry interface - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "registry.h" -#include "cygerrno.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "tls_pbuf.h" -#include - -reg_key::reg_key (HKEY top, REGSAM access, ...): _disposition (0) -{ - va_list av; - va_start (av, access); - build_reg (top, access, av); - va_end (av); -} - -/* Opens a key under the appropriate Cygwin key. - Do not use HKCU per MS KB 199190 */ - -reg_key::reg_key (bool isHKLM, REGSAM access, ...): _disposition (0) -{ - va_list av; - HKEY top; - - if (isHKLM) - top = HKEY_LOCAL_MACHINE; - else - { - char name[128]; - const char *names[2] = {cygheap->user.get_windows_id (name), ".DEFAULT"}; - for (int i = 0; i < 2; i++) - { - key_is_invalid = RegOpenKeyEx (HKEY_USERS, names[i], 0, access, &top); - if (key_is_invalid == ERROR_SUCCESS) - goto OK; - debug_printf ("HKU\\%s failed, Win32 error %ld", names[i], key_is_invalid); - } - return; - } -OK: - new (this) reg_key (top, access, "SOFTWARE", - CYGWIN_INFO_CYGWIN_REGISTRY_NAME, NULL); - if (top != HKEY_LOCAL_MACHINE) - RegCloseKey (top); - if (key_is_invalid) - return; - - top = key; - va_start (av, access); - build_reg (top, access, av); - va_end (av); - if (top != key) - RegCloseKey (top); -} - -void -reg_key::build_reg (HKEY top, REGSAM access, va_list av) -{ - char *name; - HKEY r = top; - key_is_invalid = 0; - - /* FIXME: Most of the time a valid mount area should exist. Perhaps - we should just try an open of the correct key first and only resort - to this method in the unlikely situation that it's the first time - the current mount areas are being used. */ - - while ((name = va_arg (av, char *)) != NULL) - { - int res = RegCreateKeyExA (r, - name, - 0, - NULL, - REG_OPTION_NON_VOLATILE, - access, - &sec_none_nih, - &key, - &_disposition); - if (r != top) - RegCloseKey (r); - r = key; - if (res != ERROR_SUCCESS) - { - key_is_invalid = res; - debug_printf ("failed to create key %s in the registry", name); - break; - } - } -} - -/* Given the current registry key, return the specific int value - requested. Return def on failure. */ - -int -reg_key::get_int (const char *name, int def) -{ - DWORD type; - DWORD dst; - DWORD size = sizeof (dst); - - if (key_is_invalid) - return def; - - LONG res = RegQueryValueExA (key, name, 0, &type, (LPBYTE) &dst, &size); - - if (type != REG_DWORD || res != ERROR_SUCCESS) - return def; - - return dst; -} - -int -reg_key::get_int (const PWCHAR name, int def) -{ - DWORD type; - DWORD dst; - DWORD size = sizeof (dst); - - if (key_is_invalid) - return def; - - LONG res = RegQueryValueExW (key, name, 0, &type, (LPBYTE) &dst, &size); - - if (type != REG_DWORD || res != ERROR_SUCCESS) - return def; - - return dst; -} - -/* Given the current registry key, set a specific int value. */ - -int -reg_key::set_int (const char *name, int val) -{ - DWORD value = val; - if (key_is_invalid) - return key_is_invalid; - - return (int) RegSetValueExA (key, name, 0, REG_DWORD, - (const BYTE *) &value, sizeof (value)); -} - -int -reg_key::set_int (const PWCHAR name, int val) -{ - DWORD value = val; - if (key_is_invalid) - return key_is_invalid; - - return (int) RegSetValueExW (key, name, 0, REG_DWORD, - (const BYTE *) &value, sizeof (value)); -} - -/* Given the current registry key, return the specific string value - requested. Return zero on success, non-zero on failure. */ - -int -reg_key::get_string (const char *name, char *dst, size_t max, const char *def) -{ - DWORD size = max; - DWORD type; - LONG res; - - if (key_is_invalid) - res = key_is_invalid; - else - res = RegQueryValueExA (key, name, 0, &type, (LPBYTE) dst, &size); - - if ((def != 0) && ((type != REG_SZ) || (res != ERROR_SUCCESS))) - strcpy (dst, def); - return (int) res; -} - -int -reg_key::get_string (const PWCHAR name, PWCHAR dst, size_t max, const PWCHAR def) -{ - DWORD size = max; - DWORD type; - LONG res; - - if (key_is_invalid) - res = key_is_invalid; - else - res = RegQueryValueExW (key, name, 0, &type, (LPBYTE) dst, &size); - - if ((def != 0) && ((type != REG_SZ) || (res != ERROR_SUCCESS))) - wcscpy (dst, def); - return (int) res; -} - -/* Given the current registry key, set a specific string value. */ - -int -reg_key::set_string (const char *name, const char *src) -{ - if (key_is_invalid) - return key_is_invalid; - return (int) RegSetValueExA (key, name, 0, REG_SZ, (const BYTE*) src, - strlen (src) + 1); -} - -int -reg_key::set_string (const PWCHAR name, const PWCHAR src) -{ - if (key_is_invalid) - return key_is_invalid; - return (int) RegSetValueExW (key, name, 0, REG_SZ, (const BYTE*) src, - (wcslen (src) + 1) * sizeof (WCHAR)); -} - -/* Return the handle to key. */ - -HKEY -reg_key::get_key () -{ - return key; -} - -/* Delete subkey of current key. Returns the error code from the - RegDeleteKeyA invocation. */ - -int -reg_key::kill (const char *name) -{ - if (key_is_invalid) - return key_is_invalid; - return RegDeleteKeyA (key, name); -} - -/* Delete the value specified by name of current key. Returns the error code - from the RegDeleteValueA invocation. */ - -int -reg_key::killvalue (const char *name) -{ - if (key_is_invalid) - return key_is_invalid; - return RegDeleteValueA (key, name); -} - -reg_key::~reg_key () -{ - if (!key_is_invalid) - RegCloseKey (key); - key_is_invalid = 1; -} - -PWCHAR -get_registry_hive_path (const PWCHAR name, PWCHAR path) -{ - WCHAR key[256], *kend; - HKEY hkey; - - if (!name || !path) - return NULL; - kend = wcpcpy (key, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\"); - wcpcpy (kend, name); - if (!RegOpenKeyExW (HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hkey)) - { - tmp_pathbuf tp; - PWCHAR buf = tp.w_get (); - DWORD type, siz; - - path[0] = L'\0'; - if (!RegQueryValueExW (hkey, L"ProfileImagePath", 0, &type, - (BYTE *)buf, (siz = NT_MAX_PATH, &siz))) - ExpandEnvironmentStringsW (buf, path, NT_MAX_PATH); - RegCloseKey (hkey); - if (path[0]) - return path; - } - debug_printf ("HKLM\\%W not found", key); - return NULL; -} - -void -load_registry_hive (const PWCHAR name) -{ - tmp_pathbuf tp; - PWCHAR path = tp.w_get (); - HKEY hkey; - LONG ret; - - if (!name) - return; - /* Check if user hive is already loaded. */ - if (!RegOpenKeyExW (HKEY_USERS, name, 0, KEY_READ, &hkey)) - { - debug_printf ("User registry hive for %W already exists", name); - RegCloseKey (hkey); - return; - } - if (get_registry_hive_path (name, path)) - { - wcscat (path, L"\\NTUSER.DAT"); - if ((ret = RegLoadKeyW (HKEY_USERS, name, path)) != ERROR_SUCCESS) - debug_printf ("Loading user registry hive for %W failed: %d", name, ret); - } -} - diff --git a/winsup/cygwin/registry.h b/winsup/cygwin/registry.h deleted file mode 100644 index b14c3afb5..000000000 --- a/winsup/cygwin/registry.h +++ /dev/null @@ -1,51 +0,0 @@ -/* registry.h: shared info for cygwin - - Copyright 2000, 2001, 2004, 2006, 2008 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -class reg_key -{ -private: - - HKEY key; - LONG key_is_invalid; - DWORD _disposition; - -public: - - reg_key (HKEY toplev, REGSAM access, ...); - reg_key (bool isHKLM, REGSAM access, ...); - - void *operator new (size_t, void *p) {return p;} - void build_reg (HKEY key, REGSAM access, va_list av); - - int error () {return key == (HKEY) INVALID_HANDLE_VALUE;} - - int kill (const char *child); - int killvalue (const char *name); - - HKEY get_key (); - - int get_int (const char *, int); - int get_int (const PWCHAR, int); - int get_string (const char *, char *, size_t, const char *); - int get_string (const PWCHAR, PWCHAR, size_t, const PWCHAR); - - int set_int (const char *, int); - int set_int (const PWCHAR, int); - int set_string (const char *, const char *); - int set_string (const PWCHAR, const PWCHAR); - - bool created () const {return _disposition & REG_CREATED_NEW_KEY;} - - ~reg_key (); -}; - -/* Evaluates path to the directory of the local user registry hive */ -PWCHAR __stdcall get_registry_hive_path (const PWCHAR name, PWCHAR path); -void __stdcall load_registry_hive (const PWCHAR name); diff --git a/winsup/cygwin/resource.cc b/winsup/cygwin/resource.cc deleted file mode 100644 index 6da9c6814..000000000 --- a/winsup/cygwin/resource.cc +++ /dev/null @@ -1,196 +0,0 @@ -/* resource.cc: getrusage () and friends. - - Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2009 Red Hat, Inc. - - Written by Steve Chamberlain (sac@cygnus.com), Doug Evans (dje@cygnus.com), - Geoffrey Noer (noer@cygnus.com) of Cygnus Support. - Rewritten by Sergey S. Okhapkin (sos@prospect.com.ru) - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include "pinfo.h" -#include "psapi.h" -#include "cygtls.h" -#include "path.h" -#include "fhandler.h" -#include "pinfo.h" -#include "dtable.h" - -/* add timeval values */ -static void -add_timeval (struct timeval *tv1, struct timeval *tv2) -{ - tv1->tv_sec += tv2->tv_sec; - tv1->tv_usec += tv2->tv_usec; - if (tv1->tv_usec >= 1000000) - { - tv1->tv_usec -= 1000000; - tv1->tv_sec++; - } -} - -/* add rusage values of r2 to r1 */ -void __stdcall -add_rusage (struct rusage *r1, struct rusage *r2) -{ - add_timeval (&r1->ru_utime, &r2->ru_utime); - add_timeval (&r1->ru_stime, &r2->ru_stime); - r1->ru_maxrss += r2->ru_maxrss; - r1->ru_ixrss += r2->ru_ixrss; - r1->ru_idrss += r2->ru_idrss; - r1->ru_isrss += r2->ru_isrss; - r1->ru_minflt += r2->ru_minflt; - r1->ru_majflt += r2->ru_majflt; - r1->ru_nswap += r2->ru_nswap; - r1->ru_inblock += r2->ru_inblock; - r1->ru_oublock += r2->ru_oublock; - r1->ru_msgsnd += r2->ru_msgsnd; - r1->ru_msgrcv += r2->ru_msgrcv; - r1->ru_nsignals += r2->ru_nsignals; - r1->ru_nvcsw += r2->ru_nvcsw; - r1->ru_nivcsw += r2->ru_nivcsw; -} - -/* FIXME: what about other fields? */ -void __stdcall -fill_rusage (struct rusage *r, HANDLE h) -{ - FILETIME creation_time = {0,0}; - FILETIME exit_time = {0,0}; - FILETIME kernel_time = {0,0}; - FILETIME user_time = {0,0}; - - struct timeval tv; - - memset (r, 0, sizeof (*r)); - GetProcessTimes (h, &creation_time, &exit_time, &kernel_time, &user_time); - totimeval (&tv, &kernel_time, 0, 0); - add_timeval (&r->ru_stime, &tv); - totimeval (&tv, &user_time, 0, 0); - add_timeval (&r->ru_utime, &tv); - - PROCESS_MEMORY_COUNTERS pmc; - - memset (&pmc, 0, sizeof (pmc)); - if (GetProcessMemoryInfo (h, &pmc, sizeof (pmc))) - { - r->ru_maxrss += (long) (pmc.WorkingSetSize /1024); - r->ru_majflt += pmc.PageFaultCount; - } -} - -extern "C" int -getrusage (int intwho, struct rusage *rusage_in) -{ - int res = 0; - struct rusage r; - - if (intwho == RUSAGE_SELF) - { - memset (&r, 0, sizeof (r)); - fill_rusage (&r, GetCurrentProcess ()); - *rusage_in = r; - } - else if (intwho == RUSAGE_CHILDREN) - *rusage_in = myself->rusage_children; - else - { - set_errno (EINVAL); - res = -1; - } - - syscall_printf ("%d = getrusage (%d, %p)", res, intwho, rusage_in); - return res; -} - -unsigned long rlim_core = RLIM_INFINITY; - -extern "C" int -getrlimit (int resource, struct rlimit *rlp) -{ - MEMORY_BASIC_INFORMATION m; - - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - rlp->rlim_cur = RLIM_INFINITY; - rlp->rlim_max = RLIM_INFINITY; - - switch (resource) - { - case RLIMIT_CPU: - case RLIMIT_FSIZE: - case RLIMIT_DATA: - break; - case RLIMIT_STACK: - if (!VirtualQuery ((LPCVOID) &m, &m, sizeof m)) - debug_printf ("couldn't get stack info, returning def.values. %E"); - else - { - rlp->rlim_cur = (DWORD) &m - (DWORD) m.AllocationBase; - rlp->rlim_max = (DWORD) m.BaseAddress + m.RegionSize - - (DWORD) m.AllocationBase; - } - break; - case RLIMIT_NOFILE: - rlp->rlim_cur = getdtablesize (); - if (rlp->rlim_cur < OPEN_MAX) - rlp->rlim_cur = OPEN_MAX; - rlp->rlim_max = OPEN_MAX_MAX; - break; - case RLIMIT_CORE: - rlp->rlim_cur = rlim_core; - break; - case RLIMIT_AS: - rlp->rlim_cur = 0x80000000UL; - rlp->rlim_max = 0x80000000UL; - break; - default: - set_errno (EINVAL); - return -1; - } - return 0; -} - -extern "C" int -setrlimit (int resource, const struct rlimit *rlp) -{ - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - struct rlimit oldlimits; - - // Check if the request is to actually change the resource settings. - // If it does not result in a change, take no action and do not - // fail. - if (getrlimit (resource, &oldlimits) < 0) - return -1; - - if (oldlimits.rlim_cur == rlp->rlim_cur && - oldlimits.rlim_max == rlp->rlim_max) - // No change in resource requirements, succeed immediately - return 0; - - switch (resource) - { - case RLIMIT_CORE: - rlim_core = rlp->rlim_cur; - break; - case RLIMIT_NOFILE: - if (rlp->rlim_cur != RLIM_INFINITY) - return setdtablesize (rlp->rlim_cur); - break; - default: - set_errno (EINVAL); - return -1; - } - return 0; -} diff --git a/winsup/cygwin/scandir.cc b/winsup/cygwin/scandir.cc deleted file mode 100644 index 84b6538a4..000000000 --- a/winsup/cygwin/scandir.cc +++ /dev/null @@ -1,93 +0,0 @@ -/* scandir.cc - - Copyright 1998, 1999, 2000, 2001 Red Hat, Inc. - - Written by Corinna Vinschen - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#include "winsup.h" -#include -#include -#include "cygerrno.h" - -extern "C" int -alphasort (const struct dirent **a, const struct dirent **b) -{ - return strcoll ((*a)->d_name, (*b)->d_name); -} - -extern "C" int -scandir (const char *dir, - struct dirent ***namelist, - int (*select) (const struct dirent *), - int (*compar) (const struct dirent **, const struct dirent **)) -{ - DIR *dirp; - struct dirent *ent, *etmp, **nl = NULL, **ntmp; - int count = 0; - int allocated = 0; - int err = 0; - - if (!(dirp = opendir (dir))) - return -1; - - if (!compar) - compar = alphasort; - - while ((ent = readdir (dirp))) - { - if (!select || select (ent)) - { - if (count == allocated) - { - - if (allocated == 0) - allocated = 10; - else - allocated *= 2; - - ntmp = (struct dirent **) realloc (nl, allocated * sizeof *nl); - if (!ntmp) - { - err = ENOMEM; - break; - } - nl = ntmp; - } - - if (!(etmp = (struct dirent *) malloc (sizeof *ent))) - { - err = ENOMEM; - break; - } - *etmp = *ent; - nl[count++] = etmp; - } - } - - if (err != 0) - { - closedir (dirp); - if (nl) - { - while (count > 0) - free (nl[--count]); - free (nl); - } - /* Ignore errors from closedir() and what not else. */ - set_errno (err); - return -1; - } - - closedir (dirp); - - qsort (nl, count, sizeof *nl, (int (*)(const void *, const void *)) compar); - if (namelist) - *namelist = nl; - return count; -} diff --git a/winsup/cygwin/sched.cc b/winsup/cygwin/sched.cc deleted file mode 100644 index 08f96833b..000000000 --- a/winsup/cygwin/sched.cc +++ /dev/null @@ -1,489 +0,0 @@ -/* sched.cc: scheduler interface for Cygwin - - Copyright 2001, 2002, 2006, 2007 Red Hat, Inc. - - Written by Robert Collins - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#ifdef HAVE_CONFIG_H -#endif - -#include "winsup.h" -#include "miscfuncs.h" -#include "cygerrno.h" -#include "pinfo.h" -/* for getpid */ -#include -#include "registry.h" - -extern "C" HWND WINAPI GetForegroundWindow(); - -/* Win32 priority to UNIX priority Mapping. - For now, I'm just following the spec: any range of priorities is ok. - There are probably many many issues with this... - - We don't want process's going realtime. Well, they probably could, but the issues - with avoiding the priority values 17-22 and 27-30 (not supported before win2k) - make that inefficient. - However to complicate things most unixes use lower is better priorities. - - So we map -14 to 15, and 15 to 1 via (16- ((n+16) >> 1)) - we then map 1 to 15 to various process class and thread priority combinations - - Then we need to look at the threads vi process priority. As win95 98 and NT 4 - Don't support opening threads cross-process (unless a thread HANDLE is passed around) - for now, we'll just use the priority class. - - The code and logic are present to calculate the priority for thread - , if a thread handle can be obtained. Alternatively, if the symbols wouldn't be - resolved until they are used - we could support this on windows 2000 and ME now, and just fall back to the - class only on pre win2000 machines. - - Lastly, because we can't assume that the pid we're given are Windows pids, we can't - alter non-cygwin started programs. -*/ - -extern "C" -{ - -/* max priority for policy */ -int -sched_get_priority_max (int policy) -{ - if (policy < 1 || policy > 3) - { - set_errno (EINVAL); - return -1; - } - return -14; -} - -/* min priority for policy */ -int -sched_get_priority_min (int policy) -{ - if (policy < 1 || policy > 3) - { - set_errno (EINVAL); - return -1; - } - return 15; -} - -/* Check a scheduler parameter struct for valid settings */ -int -valid_sched_parameters (const struct sched_param *param) -{ - if (param->sched_priority < -14 || param->sched_priority > 15) - { - return 0; - } - return -1; - -} - -/* get sched params for process - - Note, I'm never returning EPERM, - Always ESRCH. This is by design (If cygwin ever looks at paranoid security - Walking the pid values is a known hole in some os's) -*/ -int -sched_getparam (pid_t pid, struct sched_param *param) -{ - pid_t localpid; - int winpri; - if (!param || pid < 0) - { - set_errno (EINVAL); - return -1; - } - - localpid = pid ? pid : getpid (); - - DWORD Class; - int ThreadPriority; - HANDLE process; - pinfo p (localpid); - - /* get the class */ - - if (!p) - { - set_errno (ESRCH); - return -1; - } - process = OpenProcess (PROCESS_QUERY_INFORMATION, FALSE, p->dwProcessId); - if (!process) - { - set_errno (ESRCH); - return -1; - } - Class = GetPriorityClass (process); - CloseHandle (process); - if (!Class) - { - set_errno (ESRCH); - return -1; - } - ThreadPriority = THREAD_PRIORITY_NORMAL; - - /* calculate the unix priority. - - FIXME: windows 2000 supports ABOVE_NORMAL and BELOW_NORMAL class's - So this logic just defaults those class factors to NORMAL in the calculations */ - - switch (Class) - { - case IDLE_PRIORITY_CLASS: - switch (ThreadPriority) - { - case THREAD_PRIORITY_IDLE: - winpri = 1; - break; - case THREAD_PRIORITY_LOWEST: - winpri = 2; - break; - case THREAD_PRIORITY_BELOW_NORMAL: - winpri = 3; - break; - case THREAD_PRIORITY_NORMAL: - winpri = 4; - break; - case THREAD_PRIORITY_ABOVE_NORMAL: - winpri = 5; - break; - case THREAD_PRIORITY_HIGHEST: - default: - winpri = 6; - break; - } - break; - case HIGH_PRIORITY_CLASS: - switch (ThreadPriority) - { - case THREAD_PRIORITY_IDLE: - winpri = 1; - break; - case THREAD_PRIORITY_LOWEST: - winpri = 11; - break; - case THREAD_PRIORITY_BELOW_NORMAL: - winpri = 12; - break; - case THREAD_PRIORITY_NORMAL: - winpri = 13; - break; - case THREAD_PRIORITY_ABOVE_NORMAL: - winpri = 14; - break; - case THREAD_PRIORITY_HIGHEST: - default: - winpri = 15; - break; - } - break; - case NORMAL_PRIORITY_CLASS: - default: - switch (ThreadPriority) - { - case THREAD_PRIORITY_IDLE: - winpri = 1; - break; - case THREAD_PRIORITY_LOWEST: - winpri = 7; - break; - case THREAD_PRIORITY_BELOW_NORMAL: - winpri = 8; - break; - case THREAD_PRIORITY_NORMAL: - winpri = 9; - break; - case THREAD_PRIORITY_ABOVE_NORMAL: - winpri = 10; - break; - case THREAD_PRIORITY_HIGHEST: - default: - winpri = 11; - break; - } - break; - } - - /* reverse out winpri = (16- ((unixpri+16) >> 1)) */ - /* - winpri-16 = - (unixpri +16 ) >> 1 - - -(winpri-16) = unixpri +16 >> 1 - (-(winpri-16)) << 1 = unixpri+16 - ((-(winpri - 16)) << 1) - 16 = unixpri - */ - - param->sched_priority = ((-(winpri - 16)) << 1) - 16; - - return 0; -} - -/* get the scheduler for pid - - All process's on WIN32 run with SCHED_FIFO. - So we just give an answer. - (WIN32 uses a multi queue FIFO). -*/ -int -sched_getscheduler (pid_t pid) -{ - if (pid < 0) - return ESRCH; - else - return SCHED_FIFO; -} - -/* get the time quantum for pid - - Implemented only for NT systems, it fails and sets errno to ESRCH - for non-NT systems. -*/ -int -sched_rr_get_interval (pid_t pid, struct timespec *interval) -{ - static const char quantable[2][2][3] = - {{{12, 24, 36}, { 6, 12, 18}}, - {{36, 36, 36}, {18, 18, 18}}}; - /* FIXME: Clocktickinterval can be 15 ms for multi-processor system. */ - static const int clocktickinterval = 10; - static const int quantapertick = 3; - - HWND forwin; - DWORD forprocid; - int vfindex, slindex, qindex, prisep; - long nsec; - - forwin = GetForegroundWindow (); - if (!forwin) - GetWindowThreadProcessId (forwin, &forprocid); - else - forprocid = 0; - - reg_key reg (HKEY_LOCAL_MACHINE, KEY_READ, "SYSTEM", "CurrentControlSet", - "Control", "PriorityControl", NULL); - if (reg.error ()) - { - set_errno (ESRCH); - return -1; - } - prisep = reg.get_int ("Win32PrioritySeparation", 2); - pinfo pi (pid ? pid : myself->pid); - if (!pi) - { - set_errno (ESRCH); - return -1; - } - - if (pi->dwProcessId == forprocid) - { - qindex = prisep & 3; - qindex = qindex == 3 ? 2 : qindex; - } - else - qindex = 0; - vfindex = ((prisep >> 2) & 3) % 3; - if (vfindex == 0) - vfindex = wincap.is_server () || (prisep & 3) == 0 ? 1 : 0; - else - vfindex -= 1; - slindex = ((prisep >> 4) & 3) % 3; - if (slindex == 0) - slindex = wincap.is_server () ? 1 : 0; - else - slindex -= 1; - - nsec = quantable[vfindex][slindex][qindex] / quantapertick - * clocktickinterval * 1000000; - interval->tv_sec = nsec / 1000000000; - interval->tv_nsec = nsec % 1000000000; - - return 0; -} - -/* set the scheduling parameters */ -int -sched_setparam (pid_t pid, const struct sched_param *param) -{ - pid_t localpid; - int winpri; - DWORD Class; - int ThreadPriority; - HANDLE process; - - if (!param || pid < 0) - { - set_errno (EINVAL); - return -1; - } - - if (!valid_sched_parameters (param)) - { - set_errno (EINVAL); - return -1; - } - - /* winpri = (16- ((unixpri+16) >> 1)) */ - winpri = 16 - ((param->sched_priority + 16) >> 1); - - /* calculate our desired priority class and thread priority */ - - if (winpri < 7) - Class = IDLE_PRIORITY_CLASS; - else if (winpri > 10) - Class = HIGH_PRIORITY_CLASS; - else - Class = NORMAL_PRIORITY_CLASS; - - switch (Class) - { - case IDLE_PRIORITY_CLASS: - switch (winpri) - { - case 1: - ThreadPriority = THREAD_PRIORITY_IDLE; - break; - case 2: - ThreadPriority = THREAD_PRIORITY_LOWEST; - break; - case 3: - ThreadPriority = THREAD_PRIORITY_BELOW_NORMAL; - break; - case 4: - ThreadPriority = THREAD_PRIORITY_NORMAL; - break; - case 5: - ThreadPriority = THREAD_PRIORITY_ABOVE_NORMAL; - break; - case 6: - ThreadPriority = THREAD_PRIORITY_HIGHEST; - break; - } - break; - case NORMAL_PRIORITY_CLASS: - switch (winpri) - { - case 7: - ThreadPriority = THREAD_PRIORITY_LOWEST; - break; - case 8: - ThreadPriority = THREAD_PRIORITY_BELOW_NORMAL; - break; - case 9: - ThreadPriority = THREAD_PRIORITY_NORMAL; - break; - case 10: - ThreadPriority = THREAD_PRIORITY_ABOVE_NORMAL; - break; - case 11: - ThreadPriority = THREAD_PRIORITY_HIGHEST; - break; - } - break; - case HIGH_PRIORITY_CLASS: - switch (winpri) - { - case 12: - ThreadPriority = THREAD_PRIORITY_BELOW_NORMAL; - break; - case 13: - ThreadPriority = THREAD_PRIORITY_NORMAL; - break; - case 14: - ThreadPriority = THREAD_PRIORITY_ABOVE_NORMAL; - break; - case 15: - ThreadPriority = THREAD_PRIORITY_HIGHEST; - break; - } - break; - } - - localpid = pid ? pid : getpid (); - - pinfo p (localpid); - - /* set the class */ - - if (!p) - { - set_errno (1); //ESRCH); - return -1; - } - process = - OpenProcess (PROCESS_SET_INFORMATION, FALSE, (DWORD) p->dwProcessId); - if (!process) - { - set_errno (2); //ESRCH); - return -1; - } - if (!SetPriorityClass (process, Class)) - { - CloseHandle (process); - set_errno (EPERM); - return -1; - } - CloseHandle (process); - - return 0; -} - -/* we map -14 to 15, and 15 to 1 via (16- ((n+16) >> 1)). This lines up with the allowed - * valueswe return elsewhere in the sched* functions. We then map in groups of three to - * allowed thread priority's. The reason for dropping accuracy while still returning - * a wide range of values is to allow more flexible code in the future. - */ -int -sched_set_thread_priority (HANDLE thread, int priority) -{ - int real_pri; - real_pri = 16 - ((priority + 16) >> 1); - if (real_pri <1 || real_pri > 15) - return EINVAL; - - if (real_pri < 4) - real_pri = THREAD_PRIORITY_LOWEST; - else if (real_pri < 7) - real_pri = THREAD_PRIORITY_BELOW_NORMAL; - else if (real_pri < 10) - real_pri = THREAD_PRIORITY_NORMAL; - else if (real_pri < 13) - real_pri = THREAD_PRIORITY_ABOVE_NORMAL; - else - real_pri = THREAD_PRIORITY_HIGHEST; - - if (!SetThreadPriority (thread, real_pri)) - /* invalid handle, no access are the only expected errors. */ - return EPERM; - return 0; -} - -/* set the scheduler */ -int -sched_setscheduler (pid_t pid, int policy, - const struct sched_param *param) -{ - /* on win32, you can't change the scheduler. Doh! */ - set_errno (ENOSYS); - return -1; -} - -/* yield the cpu */ -int -sched_yield () -{ - low_priority_sleep (0); - return 0; -} -} diff --git a/winsup/cygwin/sec_acl.cc b/winsup/cygwin/sec_acl.cc deleted file mode 100644 index 156320407..000000000 --- a/winsup/cygwin/sec_acl.cc +++ /dev/null @@ -1,985 +0,0 @@ -/* sec_acl.cc: Sun compatible ACL functions. - - Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, - 2009, 2010 Red Hat, Inc. - - Written by Corinna Vinschen - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "pwdgrp.h" - -static int -searchace (__aclent32_t *aclp, int nentries, int type, __uid32_t id = ILLEGAL_UID) -{ - int i; - - for (i = 0; i < nentries; ++i) - if ((aclp[i].a_type == type && (id == ILLEGAL_UID || aclp[i].a_id == id)) - || !aclp[i].a_type) - return i; - return -1; -} - -int -setacl (HANDLE handle, path_conv &pc, int nentries, __aclent32_t *aclbufp, - bool &writable) -{ - security_descriptor sd_ret; - - if (get_file_sd (handle, pc, sd_ret)) - return -1; - - BOOL dummy; - - /* Get owner SID. */ - PSID owner_sid; - if (!GetSecurityDescriptorOwner (sd_ret, &owner_sid, &dummy)) - { - __seterrno (); - return -1; - } - cygsid owner (owner_sid); - - /* Get group SID. */ - PSID group_sid; - if (!GetSecurityDescriptorGroup (sd_ret, &group_sid, &dummy)) - { - __seterrno (); - return -1; - } - cygsid group (group_sid); - - /* Initialize local security descriptor. */ - SECURITY_DESCRIPTOR sd; - if (!InitializeSecurityDescriptor (&sd, SECURITY_DESCRIPTOR_REVISION)) - { - __seterrno (); - return -1; - } - if (!SetSecurityDescriptorOwner (&sd, owner, FALSE)) - { - __seterrno (); - return -1; - } - if (!SetSecurityDescriptorGroup (&sd, group, FALSE)) - { - __seterrno (); - return -1; - } - - /* Fill access control list. */ - PACL acl = (PACL) alloca (3072); - size_t acl_len = sizeof (ACL); - int ace_off = 0; - - cygsid sid; - struct passwd *pw; - struct __group32 *gr; - int pos; - - if (!InitializeAcl (acl, 3072, ACL_REVISION)) - { - __seterrno (); - return -1; - } - - writable = false; - - for (int i = 0; i < nentries; ++i) - { - DWORD allow; - /* Owner has more standard rights set. */ - if ((aclbufp[i].a_type & ~ACL_DEFAULT) == USER_OBJ) - allow = STANDARD_RIGHTS_ALL - | (pc.fs_is_samba () - ? 0 : (FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES)); - else - allow = STANDARD_RIGHTS_READ - | (pc.fs_is_samba () ? 0 : FILE_READ_ATTRIBUTES); - if (aclbufp[i].a_perm & S_IROTH) - allow |= FILE_GENERIC_READ; - if (aclbufp[i].a_perm & S_IWOTH) - { - allow |= FILE_GENERIC_WRITE; - writable = true; - } - if (aclbufp[i].a_perm & S_IXOTH) - allow |= FILE_GENERIC_EXECUTE & ~FILE_READ_ATTRIBUTES; - if ((aclbufp[i].a_perm & (S_IWOTH | S_IXOTH)) == (S_IWOTH | S_IXOTH)) - allow |= FILE_DELETE_CHILD; - /* Set inherit property. */ - DWORD inheritance = (aclbufp[i].a_type & ACL_DEFAULT) - ? (CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE - | INHERIT_ONLY_ACE) - : NO_INHERITANCE; - /* - * If a specific acl contains a corresponding default entry with - * identical permissions, only one Windows ACE with proper - * inheritance bits is created. - */ - if (!(aclbufp[i].a_type & ACL_DEFAULT) - && aclbufp[i].a_type & (USER|GROUP|OTHER_OBJ) - && (pos = searchace (aclbufp + i + 1, nentries - i - 1, - aclbufp[i].a_type | ACL_DEFAULT, - (aclbufp[i].a_type & (USER|GROUP)) - ? aclbufp[i].a_id : ILLEGAL_UID)) >= 0 - && aclbufp[i].a_perm == aclbufp[i + 1 + pos].a_perm) - { - inheritance = CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE; - /* This invalidates the corresponding default entry. */ - aclbufp[i + 1 + pos].a_type = USER|GROUP|ACL_DEFAULT; - } - switch (aclbufp[i].a_type) - { - case USER_OBJ: - if (!add_access_allowed_ace (acl, ace_off++, allow, - owner, acl_len, inheritance)) - return -1; - break; - case DEF_USER_OBJ: - if (!add_access_allowed_ace (acl, ace_off++, allow, - well_known_creator_owner_sid, acl_len, inheritance)) - return -1; - break; - case USER: - case DEF_USER: - if (!(pw = internal_getpwuid (aclbufp[i].a_id)) - || !sid.getfrompw (pw)) - { - set_errno (EINVAL); - return -1; - } - if (!add_access_allowed_ace (acl, ace_off++, allow, - sid, acl_len, inheritance)) - return -1; - break; - case GROUP_OBJ: - if (!add_access_allowed_ace (acl, ace_off++, allow, - group, acl_len, inheritance)) - return -1; - break; - case DEF_GROUP_OBJ: - if (!add_access_allowed_ace (acl, ace_off++, allow, - well_known_creator_group_sid, acl_len, inheritance)) - return -1; - break; - case GROUP: - case DEF_GROUP: - if (!(gr = internal_getgrgid (aclbufp[i].a_id)) - || !sid.getfromgr (gr)) - { - set_errno (EINVAL); - return -1; - } - if (!add_access_allowed_ace (acl, ace_off++, allow, - sid, acl_len, inheritance)) - return -1; - break; - case OTHER_OBJ: - case DEF_OTHER_OBJ: - if (!add_access_allowed_ace (acl, ace_off++, allow, - well_known_world_sid, - acl_len, inheritance)) - return -1; - break; - } - } - /* Set AclSize to computed value. */ - acl->AclSize = acl_len; - debug_printf ("ACL-Size: %d", acl_len); - /* Create DACL for local security descriptor. */ - if (!SetSecurityDescriptorDacl (&sd, TRUE, acl, FALSE)) - { - __seterrno (); - return -1; - } - /* Make self relative security descriptor in sd_ret. */ - DWORD sd_size = 0; - MakeSelfRelativeSD (&sd, sd_ret, &sd_size); - if (sd_size <= 0) - { - __seterrno (); - return -1; - } - if (!sd_ret.realloc (sd_size)) - { - set_errno (ENOMEM); - return -1; - } - if (!MakeSelfRelativeSD (&sd, sd_ret, &sd_size)) - { - __seterrno (); - return -1; - } - debug_printf ("Created SD-Size: %d", sd_ret.size ()); - return set_file_sd (handle, pc, sd_ret, false); -} - -/* Temporary access denied bits */ -#define DENY_R 040000 -#define DENY_W 020000 -#define DENY_X 010000 - -static void -getace (__aclent32_t &acl, int type, int id, DWORD win_ace_mask, - DWORD win_ace_type) -{ - acl.a_type = type; - acl.a_id = id; - - if ((win_ace_mask & FILE_READ_BITS) && !(acl.a_perm & (S_IROTH | DENY_R))) - { - if (win_ace_type == ACCESS_ALLOWED_ACE_TYPE) - acl.a_perm |= S_IROTH; - else if (win_ace_type == ACCESS_DENIED_ACE_TYPE) - acl.a_perm |= DENY_R; - } - - if ((win_ace_mask & FILE_WRITE_BITS) && !(acl.a_perm & (S_IWOTH | DENY_W))) - { - if (win_ace_type == ACCESS_ALLOWED_ACE_TYPE) - acl.a_perm |= S_IWOTH; - else if (win_ace_type == ACCESS_DENIED_ACE_TYPE) - acl.a_perm |= DENY_W; - } - - if ((win_ace_mask & FILE_EXEC_BITS) && !(acl.a_perm & (S_IXOTH | DENY_X))) - { - if (win_ace_type == ACCESS_ALLOWED_ACE_TYPE) - acl.a_perm |= S_IXOTH; - else if (win_ace_type == ACCESS_DENIED_ACE_TYPE) - acl.a_perm |= DENY_X; - } -} - -int -getacl (HANDLE handle, path_conv &pc, int nentries, __aclent32_t *aclbufp) -{ - security_descriptor sd; - - if (get_file_sd (handle, pc, sd)) - return -1; - - cygpsid owner_sid; - cygpsid group_sid; - BOOL dummy; - __uid32_t uid; - __gid32_t gid; - - if (!GetSecurityDescriptorOwner (sd, (PSID *) &owner_sid, &dummy)) - { - debug_printf ("GetSecurityDescriptorOwner %E"); - __seterrno (); - return -1; - } - uid = owner_sid.get_uid (); - - if (!GetSecurityDescriptorGroup (sd, (PSID *) &group_sid, &dummy)) - { - debug_printf ("GetSecurityDescriptorGroup %E"); - __seterrno (); - return -1; - } - gid = group_sid.get_gid (); - - __aclent32_t lacl[MAX_ACL_ENTRIES]; - memset (&lacl, 0, MAX_ACL_ENTRIES * sizeof (__aclent32_t)); - lacl[0].a_type = USER_OBJ; - lacl[0].a_id = uid; - lacl[1].a_type = GROUP_OBJ; - lacl[1].a_id = gid; - lacl[2].a_type = OTHER_OBJ; - lacl[2].a_id = ILLEGAL_GID; - lacl[3].a_type = CLASS_OBJ; - lacl[3].a_id = ILLEGAL_GID; - lacl[3].a_perm = S_IROTH | S_IWOTH | S_IXOTH; - - PACL acl; - BOOL acl_exists; - - if (!GetSecurityDescriptorDacl (sd, &acl_exists, &acl, &dummy)) - { - __seterrno (); - debug_printf ("GetSecurityDescriptorDacl %E"); - return -1; - } - - int pos, i, types_def = 0; - - if (!acl_exists || !acl) - for (pos = 0; pos < 3; ++pos) /* Don't change CLASS_OBJ entry */ - lacl[pos].a_perm = S_IROTH | S_IWOTH | S_IXOTH; - else - { - for (i = 0; i < acl->AceCount; ++i) - { - ACCESS_ALLOWED_ACE *ace; - - if (!GetAce (acl, i, (PVOID *) &ace)) - continue; - - cygpsid ace_sid ((PSID) &ace->SidStart); - int id; - int type = 0; - - if (ace_sid == well_known_world_sid) - { - type = OTHER_OBJ; - id = ILLEGAL_GID; - } - else if (ace_sid == group_sid) - { - type = GROUP_OBJ; - id = gid; - } - else if (ace_sid == owner_sid) - { - type = USER_OBJ; - id = uid; - } - else if (ace_sid == well_known_creator_group_sid) - { - type = GROUP_OBJ | ACL_DEFAULT; - id = ILLEGAL_GID; - } - else if (ace_sid == well_known_creator_owner_sid) - { - type = USER_OBJ | ACL_DEFAULT; - id = ILLEGAL_GID; - } - else - id = ace_sid.get_id (true, &type); - - if (!type) - continue; - if (!(ace->Header.AceFlags & INHERIT_ONLY_ACE || type & ACL_DEFAULT)) - { - if ((pos = searchace (lacl, MAX_ACL_ENTRIES, type, id)) >= 0) - getace (lacl[pos], type, id, ace->Mask, ace->Header.AceType); - } - if ((ace->Header.AceFlags - & (CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE)) - && pc.isdir ()) - { - if (type == USER_OBJ) - type = USER; - else if (type == GROUP_OBJ) - type = GROUP; - type |= ACL_DEFAULT; - types_def |= type; - if ((pos = searchace (lacl, MAX_ACL_ENTRIES, type, id)) >= 0) - getace (lacl[pos], type, id, ace->Mask, ace->Header.AceType); - } - } - /* Include DEF_CLASS_OBJ if any default ace exists */ - if ((types_def & (USER|GROUP)) - && ((pos = searchace (lacl, MAX_ACL_ENTRIES, DEF_CLASS_OBJ)) >= 0)) - { - lacl[pos].a_type = DEF_CLASS_OBJ; - lacl[pos].a_id = ILLEGAL_GID; - lacl[pos].a_perm = S_IRWXU | S_IRWXG | S_IRWXO; - } - } - if ((pos = searchace (lacl, MAX_ACL_ENTRIES, 0)) < 0) - pos = MAX_ACL_ENTRIES; - if (aclbufp) { - if (owner_sid == group_sid) - lacl[0].a_perm = lacl[1].a_perm; - if (pos > nentries) - { - set_errno (ENOSPC); - return -1; - } - memcpy (aclbufp, lacl, pos * sizeof (__aclent32_t)); - for (i = 0; i < pos; ++i) - aclbufp[i].a_perm &= ~(DENY_R | DENY_W | DENY_X); - aclsort32 (pos, 0, aclbufp); - } - syscall_printf ("%d = getacl (%S)", pos, pc.get_nt_native_path ()); - return pos; -} - -static int -acl_worker (const char *path, int cmd, int nentries, __aclent32_t *aclbufp, - unsigned fmode) -{ - int res = -1; - fhandler_base *fh = build_fh_name (path, fmode, stat_suffixes); - if (fh->error ()) - { - debug_printf ("got %d error from build_fh_name", fh->error ()); - set_errno (fh->error ()); - } - else if (!fh->exists ()) - set_errno (ENOENT); - else - res = fh->facl (cmd, nentries, aclbufp); - - delete fh; - syscall_printf ("%d = acl (%s)", res, path); - return res; -} - -extern "C" int -acl32 (const char *path, int cmd, int nentries, __aclent32_t *aclbufp) -{ - return acl_worker (path, cmd, nentries, aclbufp, PC_SYM_FOLLOW); -} - -extern "C" int -lacl32 (const char *path, int cmd, int nentries, __aclent32_t *aclbufp) -{ - return acl_worker (path, cmd, nentries, aclbufp, PC_SYM_NOFOLLOW); -} - -extern "C" int -facl32 (int fd, int cmd, int nentries, __aclent32_t *aclbufp) -{ - cygheap_fdget cfd (fd); - if (cfd < 0) - { - syscall_printf ("-1 = facl (%d)", fd); - return -1; - } - int res = cfd->facl (cmd, nentries, aclbufp); - syscall_printf ("%d = facl (%s) )", res, cfd->get_name ()); - return res; -} - -extern "C" int -aclcheck32 (__aclent32_t *aclbufp, int nentries, int *which) -{ - bool has_user_obj = false; - bool has_group_obj = false; - bool has_other_obj = false; - bool has_class_obj = false; - bool has_ug_objs = false; - bool has_def_user_obj = false; - bool has_def_group_obj = false; - bool has_def_other_obj = false; - bool has_def_class_obj = false; - bool has_def_ug_objs = false; - int pos2; - - for (int pos = 0; pos < nentries; ++pos) - switch (aclbufp[pos].a_type) - { - case USER_OBJ: - if (has_user_obj) - { - if (which) - *which = pos; - return USER_ERROR; - } - has_user_obj = true; - break; - case GROUP_OBJ: - if (has_group_obj) - { - if (which) - *which = pos; - return GRP_ERROR; - } - has_group_obj = true; - break; - case OTHER_OBJ: - if (has_other_obj) - { - if (which) - *which = pos; - return OTHER_ERROR; - } - has_other_obj = true; - break; - case CLASS_OBJ: - if (has_class_obj) - { - if (which) - *which = pos; - return CLASS_ERROR; - } - has_class_obj = true; - break; - case USER: - case GROUP: - if ((pos2 = searchace (aclbufp + pos + 1, nentries - pos - 1, - aclbufp[pos].a_type, aclbufp[pos].a_id)) >= 0) - { - if (which) - *which = pos2; - return DUPLICATE_ERROR; - } - has_ug_objs = true; - break; - case DEF_USER_OBJ: - if (has_def_user_obj) - { - if (which) - *which = pos; - return USER_ERROR; - } - has_def_user_obj = true; - break; - case DEF_GROUP_OBJ: - if (has_def_group_obj) - { - if (which) - *which = pos; - return GRP_ERROR; - } - has_def_group_obj = true; - break; - case DEF_OTHER_OBJ: - if (has_def_other_obj) - { - if (which) - *which = pos; - return OTHER_ERROR; - } - has_def_other_obj = true; - break; - case DEF_CLASS_OBJ: - if (has_def_class_obj) - { - if (which) - *which = pos; - return CLASS_ERROR; - } - has_def_class_obj = true; - break; - case DEF_USER: - case DEF_GROUP: - if ((pos2 = searchace (aclbufp + pos + 1, nentries - pos - 1, - aclbufp[pos].a_type, aclbufp[pos].a_id)) >= 0) - { - if (which) - *which = pos2; - return DUPLICATE_ERROR; - } - has_def_ug_objs = true; - break; - default: - return ENTRY_ERROR; - } - if (!has_user_obj - || !has_group_obj - || !has_other_obj -#if 0 - /* These checks are not ok yet since CLASS_OBJ isn't fully implemented. */ - || (has_ug_objs && !has_class_obj) - || (has_def_ug_objs && !has_def_class_obj) -#endif - ) - { - if (which) - *which = -1; - return MISS_ERROR; - } - return 0; -} - -static int -acecmp (const void *a1, const void *a2) -{ -#define ace(i) ((const __aclent32_t *) a##i) - int ret = ace (1)->a_type - ace (2)->a_type; - if (!ret) - ret = ace (1)->a_id - ace (2)->a_id; - return ret; -#undef ace -} - -extern "C" int -aclsort32 (int nentries, int, __aclent32_t *aclbufp) -{ - if (aclcheck32 (aclbufp, nentries, NULL)) - return -1; - if (!aclbufp || nentries < 1) - { - set_errno (EINVAL); - return -1; - } - qsort ((void *) aclbufp, nentries, sizeof (__aclent32_t), acecmp); - return 0; -} - -extern "C" int -acltomode32 (__aclent32_t *aclbufp, int nentries, mode_t *modep) -{ - int pos; - - if (!aclbufp || nentries < 1 || !modep) - { - set_errno (EINVAL); - return -1; - } - *modep = 0; - if ((pos = searchace (aclbufp, nentries, USER_OBJ)) < 0 - || !aclbufp[pos].a_type) - { - set_errno (EINVAL); - return -1; - } - *modep |= (aclbufp[pos].a_perm & S_IRWXO) << 6; - if ((pos = searchace (aclbufp, nentries, GROUP_OBJ)) < 0 - || !aclbufp[pos].a_type) - { - set_errno (EINVAL); - return -1; - } - *modep |= (aclbufp[pos].a_perm & S_IRWXO) << 3; - int cpos; - if ((cpos = searchace (aclbufp, nentries, CLASS_OBJ)) >= 0 - && aclbufp[cpos].a_type == CLASS_OBJ) - *modep |= ((aclbufp[pos].a_perm & S_IRWXO) & aclbufp[cpos].a_perm) << 3; - if ((pos = searchace (aclbufp, nentries, OTHER_OBJ)) < 0 - || !aclbufp[pos].a_type) - { - set_errno (EINVAL); - return -1; - } - *modep |= aclbufp[pos].a_perm & S_IRWXO; - return 0; -} - -extern "C" int -aclfrommode32 (__aclent32_t *aclbufp, int nentries, mode_t *modep) -{ - int pos; - - if (!aclbufp || nentries < 1 || !modep) - { - set_errno (EINVAL); - return -1; - } - if ((pos = searchace (aclbufp, nentries, USER_OBJ)) < 0 - || !aclbufp[pos].a_type) - { - set_errno (EINVAL); - return -1; - } - aclbufp[pos].a_perm = (*modep & S_IRWXU) >> 6; - if ((pos = searchace (aclbufp, nentries, GROUP_OBJ)) < 0 - || !aclbufp[pos].a_type) - { - set_errno (EINVAL); - return -1; - } - aclbufp[pos].a_perm = (*modep & S_IRWXG) >> 3; - if ((pos = searchace (aclbufp, nentries, CLASS_OBJ)) >= 0 - && aclbufp[pos].a_type == CLASS_OBJ) - aclbufp[pos].a_perm = (*modep & S_IRWXG) >> 3; - if ((pos = searchace (aclbufp, nentries, OTHER_OBJ)) < 0 - || !aclbufp[pos].a_type) - { - set_errno (EINVAL); - return -1; - } - aclbufp[pos].a_perm = (*modep & S_IRWXO); - return 0; -} - -extern "C" int -acltopbits32 (__aclent32_t *aclbufp, int nentries, mode_t *pbitsp) -{ - return acltomode32 (aclbufp, nentries, pbitsp); -} - -extern "C" int -aclfrompbits32 (__aclent32_t *aclbufp, int nentries, mode_t *pbitsp) -{ - return aclfrommode32 (aclbufp, nentries, pbitsp); -} - -static char * -permtostr (mode_t perm) -{ - static char pbuf[4]; - - pbuf[0] = (perm & S_IROTH) ? 'r' : '-'; - pbuf[1] = (perm & S_IWOTH) ? 'w' : '-'; - pbuf[2] = (perm & S_IXOTH) ? 'x' : '-'; - pbuf[3] = '\0'; - return pbuf; -} - -extern "C" char * -acltotext32 (__aclent32_t *aclbufp, int aclcnt) -{ - if (!aclbufp || aclcnt < 1 || aclcnt > MAX_ACL_ENTRIES - || aclcheck32 (aclbufp, aclcnt, NULL)) - { - set_errno (EINVAL); - return NULL; - } - char buf[32000]; - buf[0] = '\0'; - bool first = true; - - for (int pos = 0; pos < aclcnt; ++pos) - { - if (!first) - strcat (buf, ","); - first = false; - if (aclbufp[pos].a_type & ACL_DEFAULT) - strcat (buf, "default"); - switch (aclbufp[pos].a_type & ~ACL_DEFAULT) - { - case USER_OBJ: - __small_sprintf (buf + strlen (buf), "user::%s", - permtostr (aclbufp[pos].a_perm)); - break; - case USER: - __small_sprintf (buf + strlen (buf), "user:%d:%s", - aclbufp[pos].a_id, permtostr (aclbufp[pos].a_perm)); - break; - case GROUP_OBJ: - __small_sprintf (buf + strlen (buf), "group::%s", - permtostr (aclbufp[pos].a_perm)); - break; - case GROUP: - __small_sprintf (buf + strlen (buf), "group:%d:%s", - aclbufp[pos].a_id, permtostr (aclbufp[pos].a_perm)); - break; - case CLASS_OBJ: - __small_sprintf (buf + strlen (buf), "mask::%s", - permtostr (aclbufp[pos].a_perm)); - break; - case OTHER_OBJ: - __small_sprintf (buf + strlen (buf), "other::%s", - permtostr (aclbufp[pos].a_perm)); - break; - default: - set_errno (EINVAL); - return NULL; - } - } - return strdup (buf); -} - -static mode_t -permfromstr (char *perm) -{ - mode_t mode = 0; - - if (strlen (perm) != 3) - return 01000; - if (perm[0] == 'r') - mode |= S_IROTH; - else if (perm[0] != '-') - return 01000; - if (perm[1] == 'w') - mode |= S_IWOTH; - else if (perm[1] != '-') - return 01000; - if (perm[2] == 'x') - mode |= S_IXOTH; - else if (perm[2] != '-') - return 01000; - return mode; -} - -extern "C" __aclent32_t * -aclfromtext32 (char *acltextp, int *) -{ - if (!acltextp) - { - set_errno (EINVAL); - return NULL; - } - char buf[strlen (acltextp) + 1]; - __aclent32_t lacl[MAX_ACL_ENTRIES]; - memset (lacl, 0, sizeof lacl); - int pos = 0; - strcpy (buf, acltextp); - char *lasts; - for (char *c = strtok_r (buf, ",", &lasts); - c; - c = strtok_r (NULL, ",", &lasts)) - { - if (!strncmp (c, "default", 7)) - { - lacl[pos].a_type |= ACL_DEFAULT; - c += 7; - } - if (!strncmp (c, "user:", 5)) - { - if (c[5] == ':') - lacl[pos].a_type |= USER_OBJ; - else - { - lacl[pos].a_type |= USER; - c += 5; - if (isalpha (*c)) - { - struct passwd *pw = internal_getpwnam (c); - if (!pw) - { - set_errno (EINVAL); - return NULL; - } - lacl[pos].a_id = pw->pw_uid; - c = strechr (c, ':'); - } - else if (isdigit (*c)) - lacl[pos].a_id = strtol (c, &c, 10); - if (*c != ':') - { - set_errno (EINVAL); - return NULL; - } - } - } - else if (!strncmp (c, "group:", 6)) - { - if (c[5] == ':') - lacl[pos].a_type |= GROUP_OBJ; - else - { - lacl[pos].a_type |= GROUP; - c += 5; - if (isalpha (*c)) - { - struct __group32 *gr = internal_getgrnam (c); - if (!gr) - { - set_errno (EINVAL); - return NULL; - } - lacl[pos].a_id = gr->gr_gid; - c = strechr (c, ':'); - } - else if (isdigit (*c)) - lacl[pos].a_id = strtol (c, &c, 10); - if (*c != ':') - { - set_errno (EINVAL); - return NULL; - } - } - } - else if (!strncmp (c, "mask:", 5)) - { - if (c[5] == ':') - lacl[pos].a_type |= CLASS_OBJ; - else - { - set_errno (EINVAL); - return NULL; - } - } - else if (!strncmp (c, "other:", 6)) - { - if (c[5] == ':') - lacl[pos].a_type |= OTHER_OBJ; - else - { - set_errno (EINVAL); - return NULL; - } - } - if ((lacl[pos].a_perm = permfromstr (c)) == 01000) - { - set_errno (EINVAL); - return NULL; - } - ++pos; - } - __aclent32_t *aclp = (__aclent32_t *) malloc (pos * sizeof (__aclent32_t)); - if (aclp) - memcpy (aclp, lacl, pos * sizeof (__aclent32_t)); - return aclp; -} - -/* __aclent16_t and __aclent32_t have same size and same member offsets */ -static __aclent32_t * -acl16to32 (__aclent16_t *aclbufp, int nentries) -{ - __aclent32_t *aclbufp32 = (__aclent32_t *) aclbufp; - if (aclbufp32) - for (int i = 0; i < nentries; i++) - aclbufp32[i].a_id &= USHRT_MAX; - return aclbufp32; -} - -extern "C" int -acl (const char *path, int cmd, int nentries, __aclent16_t *aclbufp) -{ - return acl32 (path, cmd, nentries, acl16to32 (aclbufp, nentries)); -} - -extern "C" int -facl (int fd, int cmd, int nentries, __aclent16_t *aclbufp) -{ - return facl32 (fd, cmd, nentries, acl16to32 (aclbufp, nentries)); -} - -extern "C" int -lacl (const char *path, int cmd, int nentries, __aclent16_t *aclbufp) -{ - return lacl32 (path, cmd, nentries, acl16to32 (aclbufp, nentries)); -} - -extern "C" int -aclcheck (__aclent16_t *aclbufp, int nentries, int *which) -{ - return aclcheck32 (acl16to32 (aclbufp, nentries), nentries, which); -} - -extern "C" int -aclsort (int nentries, int i, __aclent16_t *aclbufp) -{ - return aclsort32 (nentries, i, acl16to32 (aclbufp, nentries)); -} - - -extern "C" int -acltomode (__aclent16_t *aclbufp, int nentries, mode_t *modep) -{ - return acltomode32 (acl16to32 (aclbufp, nentries), nentries, modep); -} - -extern "C" int -aclfrommode (__aclent16_t *aclbufp, int nentries, mode_t *modep) -{ - return aclfrommode32 ((__aclent32_t *)aclbufp, nentries, modep); -} - -extern "C" int -acltopbits (__aclent16_t *aclbufp, int nentries, mode_t *pbitsp) -{ - return acltopbits32 (acl16to32 (aclbufp, nentries), nentries, pbitsp); -} - -extern "C" int -aclfrompbits (__aclent16_t *aclbufp, int nentries, mode_t *pbitsp) -{ - return aclfrompbits32 ((__aclent32_t *)aclbufp, nentries, pbitsp); -} - -extern "C" char * -acltotext (__aclent16_t *aclbufp, int aclcnt) -{ - return acltotext32 (acl16to32 (aclbufp, aclcnt), aclcnt); -} - -extern "C" __aclent16_t * -aclfromtext (char *acltextp, int * aclcnt) -{ - return (__aclent16_t *) aclfromtext32 (acltextp, aclcnt); -} diff --git a/winsup/cygwin/sec_auth.cc b/winsup/cygwin/sec_auth.cc deleted file mode 100644 index 940483b4a..000000000 --- a/winsup/cygwin/sec_auth.cc +++ /dev/null @@ -1,1240 +0,0 @@ -/* sec_auth.cc: NT authentication functions - - Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include -#include -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "ntdll.h" -#include "tls_pbuf.h" -#include -#include -#include "pwdgrp.h" -#include "cyglsa.h" -#include "cygserver_setpwd.h" -#include - -/* Starting with Windows Vista, the token returned by system functions - is a restricted token. The full admin token is linked to it and can - be fetched with GetTokenInformation. This function returns the original - token on pre-Vista, and the elevated token on Vista++ if it's available, - the original token otherwise. The token handle is also made inheritable - since that's necessary anyway. */ -static HANDLE -get_full_privileged_inheritable_token (HANDLE token) -{ - if (wincap.has_mandatory_integrity_control ()) - { - TOKEN_LINKED_TOKEN linked; - DWORD size; - - /* When fetching the linked token without TCB privs, then the linked - token is not a primary token, only an impersonation token, which is - not suitable for CreateProcessAsUser. Converting it to a primary - token using DuplicateTokenEx does NOT work for the linked token in - this case. So we have to switch on TCB privs to get a primary token. - This is generally performed in the calling functions. */ - if (GetTokenInformation (token, TokenLinkedToken, - (PVOID) &linked, sizeof linked, &size)) - { - debug_printf ("Linked Token: %p", linked.LinkedToken); - if (linked.LinkedToken) - { - TOKEN_TYPE type; - - /* At this point we don't know if the user actually had TCB - privileges. Check if the linked token is a primary token. - If not, just return the original token. */ - if (GetTokenInformation (token, TokenType, (PVOID) &type, - sizeof type, &size) - && type != TokenPrimary) - debug_printf ("Linked Token is not a primary token!"); - else - { - CloseHandle (token); - token = linked.LinkedToken; - } - } - } - } - if (!SetHandleInformation (token, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) - { - __seterrno (); - CloseHandle (token); - token = NULL; - } - return token; -} - -void -set_imp_token (HANDLE token, int type) -{ - debug_printf ("set_imp_token (%d, %d)", token, type); - cygheap->user.external_token = (token == INVALID_HANDLE_VALUE - ? NO_IMPERSONATION : token); - cygheap->user.ext_token_is_restricted = (type == CW_TOKEN_RESTRICTED); -} - -extern "C" void -cygwin_set_impersonation_token (const HANDLE hToken) -{ - set_imp_token (hToken, CW_TOKEN_IMPERSONATION); -} - -void -extract_nt_dom_user (const struct passwd *pw, PWCHAR domain, PWCHAR user) -{ - - cygsid psid; - DWORD ulen = UNLEN + 1; - DWORD dlen = MAX_DOMAIN_NAME_LEN + 1; - SID_NAME_USE use; - - debug_printf ("pw_gecos %x (%s)", pw->pw_gecos, pw->pw_gecos); - - if (psid.getfrompw (pw) - && LookupAccountSidW (NULL, psid, user, &ulen, domain, &dlen, &use)) - return; - - char *d, *u, *c; - domain[0] = L'\0'; - sys_mbstowcs (user, UNLEN + 1, pw->pw_name); - if ((d = strstr (pw->pw_gecos, "U-")) != NULL && - (d == pw->pw_gecos || d[-1] == ',')) - { - c = strechr (d + 2, ','); - if ((u = strechr (d + 2, '\\')) >= c) - u = d + 1; - else if (u - d <= MAX_DOMAIN_NAME_LEN + 2) - sys_mbstowcs (domain, MAX_DOMAIN_NAME_LEN + 1, d + 2, u - d - 1); - if (c - u <= UNLEN + 1) - sys_mbstowcs (user, UNLEN + 1, u + 1, c - u); - } -} - -extern "C" HANDLE -cygwin_logon_user (const struct passwd *pw, const char *password) -{ - if (!pw || !password) - { - set_errno (EINVAL); - return INVALID_HANDLE_VALUE; - } - - WCHAR nt_domain[MAX_DOMAIN_NAME_LEN + 1]; - WCHAR nt_user[UNLEN + 1]; - PWCHAR passwd; - HANDLE hToken; - tmp_pathbuf tp; - - extract_nt_dom_user (pw, nt_domain, nt_user); - debug_printf ("LogonUserW (%W, %W, ...)", nt_user, nt_domain); - sys_mbstowcs (passwd = tp.w_get (), NT_MAX_PATH, password); - /* CV 2005-06-08: LogonUser should run under the primary process token, - otherwise it returns with ERROR_ACCESS_DENIED. */ - cygheap->user.deimpersonate (); - if (!LogonUserW (nt_user, *nt_domain ? nt_domain : NULL, passwd, - LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, - &hToken)) - { - __seterrno (); - hToken = INVALID_HANDLE_VALUE; - } - else - { - /* See the comment in get_full_privileged_inheritable_token for a - description why we enable TCB privileges here. */ - push_self_privilege (SE_TCB_PRIVILEGE, true); - hToken = get_full_privileged_inheritable_token (hToken); - pop_self_privilege (); - if (!hToken) - hToken = INVALID_HANDLE_VALUE; - } - cygheap->user.reimpersonate (); - debug_printf ("%d = logon_user(%s,...)", hToken, pw->pw_name); - return hToken; -} - -static void -str2lsa (LSA_STRING &tgt, const char *srcstr) -{ - tgt.Length = strlen (srcstr); - tgt.MaximumLength = tgt.Length + 1; - tgt.Buffer = (PCHAR) srcstr; -} - -static void -str2buf2lsa (LSA_STRING &tgt, char *buf, const char *srcstr) -{ - tgt.Length = strlen (srcstr); - tgt.MaximumLength = tgt.Length + 1; - tgt.Buffer = (PCHAR) buf; - memcpy (buf, srcstr, tgt.MaximumLength); -} - -HANDLE -open_local_policy (ACCESS_MASK access) -{ - LSA_OBJECT_ATTRIBUTES oa = { 0, 0, 0, 0, 0, 0 }; - HANDLE lsa = INVALID_HANDLE_VALUE; - - NTSTATUS ret = LsaOpenPolicy (NULL, &oa, access, &lsa); - if (ret != STATUS_SUCCESS) - { - __seterrno_from_win_error (LsaNtStatusToWinError (ret)); - /* Some versions of Windows set the lsa handle to NULL when - LsaOpenPolicy fails. */ - lsa = INVALID_HANDLE_VALUE; - } - return lsa; -} - -static void -close_local_policy (LSA_HANDLE &lsa) -{ - if (lsa != INVALID_HANDLE_VALUE) - LsaClose (lsa); - lsa = INVALID_HANDLE_VALUE; -} - -bool -get_logon_server (PWCHAR domain, WCHAR *server, bool rediscovery) -{ - DWORD dret; - PDOMAIN_CONTROLLER_INFOW pci; - WCHAR *buf; - DWORD size = MAX_COMPUTERNAME_LENGTH + 1; - - /* Empty domain is interpreted as local system */ - if ((GetComputerNameW (server + 2, &size)) && - (!wcscasecmp (domain, server + 2) || !domain[0])) - { - server[0] = server[1] = L'\\'; - return true; - } - - /* Try to get any available domain controller for this domain */ - dret = DsGetDcNameW (NULL, domain, NULL, NULL, - rediscovery ? DS_FORCE_REDISCOVERY : 0, &pci); - if (dret == ERROR_SUCCESS) - { - wcscpy (server, pci->DomainControllerName); - NetApiBufferFree (pci); - debug_printf ("DC: rediscovery: %d, server: %W", rediscovery, server); - return true; - } - else if (dret == ERROR_PROC_NOT_FOUND) - { - /* NT4 w/o DSClient */ - if (rediscovery) - dret = NetGetAnyDCName (NULL, domain, (LPBYTE *) &buf); - else - dret = NetGetDCName (NULL, domain, (LPBYTE *) &buf); - if (dret == NERR_Success) - { - wcscpy (server, buf); - NetApiBufferFree (buf); - debug_printf ("NT: rediscovery: %d, server: %W", rediscovery, server); - return true; - } - } - __seterrno_from_win_error (dret); - return false; -} - -static bool -get_user_groups (WCHAR *logonserver, cygsidlist &grp_list, - PWCHAR user, PWCHAR domain) -{ - WCHAR dgroup[MAX_DOMAIN_NAME_LEN + GNLEN + 2]; - LPGROUP_USERS_INFO_0 buf; - DWORD cnt, tot, len; - NET_API_STATUS ret; - - /* Look only on logonserver */ - ret = NetUserGetGroups (logonserver, user, 0, (LPBYTE *) &buf, - MAX_PREFERRED_LENGTH, &cnt, &tot); - if (ret) - { - __seterrno_from_win_error (ret); - /* It's no error when the user name can't be found. */ - return ret == NERR_UserNotFound; - } - - len = wcslen (domain); - wcscpy (dgroup, domain); - dgroup[len++] = L'\\'; - - for (DWORD i = 0; i < cnt; ++i) - { - cygsid gsid; - DWORD glen = MAX_SID_LEN; - WCHAR dom[MAX_DOMAIN_NAME_LEN + 1]; - DWORD dlen = sizeof (dom); - SID_NAME_USE use = SidTypeInvalid; - - wcscpy (dgroup + len, buf[i].grui0_name); - if (!LookupAccountNameW (NULL, dgroup, gsid, &glen, dom, &dlen, &use)) - debug_printf ("LookupAccountName(%W), %E", dgroup); - else if (legal_sid_type (use)) - grp_list += gsid; - else - debug_printf ("Global group %W invalid. Use: %d", dgroup, use); - } - - NetApiBufferFree (buf); - return true; -} - -static bool -get_user_local_groups (PWCHAR logonserver, PWCHAR domain, - cygsidlist &grp_list, PWCHAR user) -{ - LPLOCALGROUP_INFO_0 buf; - DWORD cnt, tot; - NET_API_STATUS ret; - - ret = NetUserGetLocalGroups (logonserver, user, 0, LG_INCLUDE_INDIRECT, - (LPBYTE *) &buf, MAX_PREFERRED_LENGTH, - &cnt, &tot); - if (ret) - { - __seterrno_from_win_error (ret); - return false; - } - - WCHAR domlocal_grp[MAX_DOMAIN_NAME_LEN + GNLEN + 2]; - WCHAR builtin_grp[2 * GNLEN + 2]; - PWCHAR dg_ptr, bg_ptr = NULL; - SID_NAME_USE use; - - dg_ptr = wcpcpy (domlocal_grp, domain); - *dg_ptr++ = L'\\'; - - for (DWORD i = 0; i < cnt; ++i) - { - cygsid gsid; - DWORD glen = MAX_SID_LEN; - WCHAR dom[MAX_DOMAIN_NAME_LEN + 1]; - DWORD domlen = MAX_DOMAIN_NAME_LEN + 1; - - use = SidTypeInvalid; - wcscpy (dg_ptr, buf[i].lgrpi0_name); - if (LookupAccountNameW (NULL, domlocal_grp, gsid, &glen, - dom, &domlen, &use)) - { - if (!legal_sid_type (use)) - debug_printf ("Rejecting local %W. use: %d", dg_ptr, use); - else - grp_list += gsid; - } - else if (GetLastError () == ERROR_NONE_MAPPED) - { - /* Check if it's a builtin group. */ - if (!bg_ptr) - { - /* Retrieve name of builtin group from system since it's - localized. */ - glen = 2 * GNLEN + 2; - if (!LookupAccountSidW (NULL, well_known_builtin_sid, - builtin_grp, &glen, domain, &domlen, &use)) - debug_printf ("LookupAccountSid(BUILTIN), %E"); - else - { - bg_ptr = builtin_grp + wcslen (builtin_grp); - bg_ptr = wcpcpy (builtin_grp, L"\\"); - } - } - if (bg_ptr) - { - wcscpy (bg_ptr, dg_ptr); - glen = MAX_SID_LEN; - domlen = MAX_DOMAIN_NAME_LEN + 1; - if (LookupAccountNameW (NULL, builtin_grp, gsid, &glen, - dom, &domlen, &use)) - { - if (!legal_sid_type (use)) - debug_printf ("Rejecting local %W. use: %d", dg_ptr, use); - else - grp_list *= gsid; - } - else - debug_printf ("LookupAccountName(%W), %E", builtin_grp); - } - } - else - debug_printf ("LookupAccountName(%W), %E", domlocal_grp); - } - NetApiBufferFree (buf); - return true; -} - -static bool -sid_in_token_groups (PTOKEN_GROUPS grps, cygpsid sid) -{ - if (!grps) - return false; - for (DWORD i = 0; i < grps->GroupCount; ++i) - if (sid == grps->Groups[i].Sid) - return true; - return false; -} - -static void -get_unix_group_sidlist (struct passwd *pw, cygsidlist &grp_list) -{ - struct __group32 *gr; - cygsid gsid; - - for (int gidx = 0; (gr = internal_getgrent (gidx)); ++gidx) - { - if (gr->gr_gid == (__gid32_t) pw->pw_gid) - goto found; - else if (gr->gr_mem) - for (int gi = 0; gr->gr_mem[gi]; ++gi) - if (strcasematch (pw->pw_name, gr->gr_mem[gi])) - goto found; - continue; - found: - if (gsid.getfromgr (gr)) - grp_list += gsid; - - } -} - -static void -get_token_group_sidlist (cygsidlist &grp_list, PTOKEN_GROUPS my_grps, - LUID auth_luid, int &auth_pos) -{ - auth_pos = -1; - if (my_grps) - { - grp_list += well_known_local_sid; - if (sid_in_token_groups (my_grps, well_known_dialup_sid)) - grp_list *= well_known_dialup_sid; - if (sid_in_token_groups (my_grps, well_known_network_sid)) - grp_list *= well_known_network_sid; - if (sid_in_token_groups (my_grps, well_known_batch_sid)) - grp_list *= well_known_batch_sid; - grp_list *= well_known_interactive_sid; - if (sid_in_token_groups (my_grps, well_known_service_sid)) - grp_list *= well_known_service_sid; - if (sid_in_token_groups (my_grps, well_known_this_org_sid)) - grp_list *= well_known_this_org_sid; - grp_list *= well_known_users_sid; - } - else - { - grp_list += well_known_local_sid; - grp_list *= well_known_interactive_sid; - grp_list *= well_known_users_sid; - } - if (get_ll (auth_luid) != 999LL) /* != SYSTEM_LUID */ - { - for (DWORD i = 0; i < my_grps->GroupCount; ++i) - if (my_grps->Groups[i].Attributes & SE_GROUP_LOGON_ID) - { - grp_list += my_grps->Groups[i].Sid; - auth_pos = grp_list.count () - 1; - break; - } - } -} - -bool -get_server_groups (cygsidlist &grp_list, PSID usersid, struct passwd *pw) -{ - WCHAR user[UNLEN + 1]; - WCHAR domain[MAX_DOMAIN_NAME_LEN + 1]; - WCHAR server[INTERNET_MAX_HOST_NAME_LENGTH + 3]; - DWORD ulen = UNLEN + 1; - DWORD dlen = MAX_DOMAIN_NAME_LEN + 1; - SID_NAME_USE use; - - if (well_known_system_sid == usersid) - { - grp_list *= well_known_admins_sid; - get_unix_group_sidlist (pw, grp_list); - return true; - } - - grp_list *= well_known_world_sid; - grp_list *= well_known_authenticated_users_sid; - - if (!LookupAccountSidW (NULL, usersid, user, &ulen, domain, &dlen, &use)) - { - __seterrno (); - return false; - } - if (get_logon_server (domain, server, false) - && !get_user_groups (server, grp_list, user, domain) - && get_logon_server (domain, server, true)) - get_user_groups (server, grp_list, user, domain); - get_user_local_groups (server, domain, grp_list, user); - get_unix_group_sidlist (pw, grp_list); - return true; -} - -static bool -get_initgroups_sidlist (cygsidlist &grp_list, - PSID usersid, PSID pgrpsid, struct passwd *pw, - PTOKEN_GROUPS my_grps, LUID auth_luid, int &auth_pos) -{ - grp_list *= well_known_world_sid; - grp_list *= well_known_authenticated_users_sid; - if (well_known_system_sid == usersid) - auth_pos = -1; - else - get_token_group_sidlist (grp_list, my_grps, auth_luid, auth_pos); - if (!get_server_groups (grp_list, usersid, pw)) - return false; - - /* special_pgrp true if pgrpsid is not in normal groups */ - grp_list += pgrpsid; - return true; -} - -static void -get_setgroups_sidlist (cygsidlist &tmp_list, PSID usersid, struct passwd *pw, - PTOKEN_GROUPS my_grps, user_groups &groups, - LUID auth_luid, int &auth_pos) -{ - tmp_list *= well_known_world_sid; - tmp_list *= well_known_authenticated_users_sid; - get_token_group_sidlist (tmp_list, my_grps, auth_luid, auth_pos); - get_server_groups (tmp_list, usersid, pw); - for (int gidx = 0; gidx < groups.sgsids.count (); gidx++) - tmp_list += groups.sgsids.sids[gidx]; - tmp_list += groups.pgsid; -} - -static ULONG sys_privs[] = { - SE_CREATE_TOKEN_PRIVILEGE, - SE_ASSIGNPRIMARYTOKEN_PRIVILEGE, - SE_LOCK_MEMORY_PRIVILEGE, - SE_INCREASE_QUOTA_PRIVILEGE, - SE_TCB_PRIVILEGE, - SE_SECURITY_PRIVILEGE, - SE_TAKE_OWNERSHIP_PRIVILEGE, - SE_LOAD_DRIVER_PRIVILEGE, - SE_SYSTEM_PROFILE_PRIVILEGE, /* Vista ONLY */ - SE_SYSTEMTIME_PRIVILEGE, - SE_PROF_SINGLE_PROCESS_PRIVILEGE, - SE_INC_BASE_PRIORITY_PRIVILEGE, - SE_CREATE_PAGEFILE_PRIVILEGE, - SE_CREATE_PERMANENT_PRIVILEGE, - SE_BACKUP_PRIVILEGE, - SE_RESTORE_PRIVILEGE, - SE_SHUTDOWN_PRIVILEGE, - SE_DEBUG_PRIVILEGE, - SE_AUDIT_PRIVILEGE, - SE_SYSTEM_ENVIRONMENT_PRIVILEGE, - SE_CHANGE_NOTIFY_PRIVILEGE, - SE_UNDOCK_PRIVILEGE, - SE_MANAGE_VOLUME_PRIVILEGE, - SE_IMPERSONATE_PRIVILEGE, - SE_CREATE_GLOBAL_PRIVILEGE, - SE_INCREASE_WORKING_SET_PRIVILEGE, - SE_TIME_ZONE_PRIVILEGE, - SE_CREATE_SYMBOLIC_LINK_PRIVILEGE -}; - -#define SYSTEM_PRIVILEGES_COUNT (sizeof sys_privs / sizeof *sys_privs) - -static PTOKEN_PRIVILEGES -get_system_priv_list (size_t &size) -{ - ULONG max_idx = 0; - while (max_idx < SYSTEM_PRIVILEGES_COUNT - && sys_privs[max_idx] != wincap.max_sys_priv ()) - ++max_idx; - if (max_idx >= SYSTEM_PRIVILEGES_COUNT) - api_fatal ("Coding error: wincap privilege %u doesn't exist in sys_privs", - wincap.max_sys_priv ()); - size = sizeof (ULONG) + (max_idx + 1) * sizeof (LUID_AND_ATTRIBUTES); - PTOKEN_PRIVILEGES privs = (PTOKEN_PRIVILEGES) malloc (size); - if (!privs) - { - debug_printf ("malloc (system_privs) failed."); - return NULL; - } - privs->PrivilegeCount = 0; - for (ULONG i = 0; i <= max_idx; ++i) - { - privs->Privileges[privs->PrivilegeCount].Luid.HighPart = 0L; - privs->Privileges[privs->PrivilegeCount].Luid.LowPart = sys_privs[i]; - privs->Privileges[privs->PrivilegeCount].Attributes = - SE_PRIVILEGE_ENABLED | SE_PRIVILEGE_ENABLED_BY_DEFAULT; - ++privs->PrivilegeCount; - } - return privs; -} - -static PTOKEN_PRIVILEGES -get_priv_list (LSA_HANDLE lsa, cygsid &usersid, cygsidlist &grp_list, - size_t &size) -{ - PLSA_UNICODE_STRING privstrs; - ULONG cnt; - PTOKEN_PRIVILEGES privs = NULL; - NTSTATUS ret; - - if (usersid == well_known_system_sid) - return get_system_priv_list (size); - - for (int grp = -1; grp < grp_list.count (); ++grp) - { - if (grp == -1) - { - if ((ret = LsaEnumerateAccountRights (lsa, usersid, &privstrs, - &cnt)) != STATUS_SUCCESS) - continue; - } - else if ((ret = LsaEnumerateAccountRights (lsa, grp_list.sids[grp], - &privstrs, &cnt)) - != STATUS_SUCCESS) - continue; - for (ULONG i = 0; i < cnt; ++i) - { - LUID priv; - PTOKEN_PRIVILEGES tmp; - DWORD tmp_count; - - if (!privilege_luid (privstrs[i].Buffer, &priv)) - continue; - - if (privs) - { - DWORD pcnt = privs->PrivilegeCount; - LUID_AND_ATTRIBUTES *p = privs->Privileges; - for (; pcnt > 0; --pcnt, ++p) - if (priv.HighPart == p->Luid.HighPart - && priv.LowPart == p->Luid.LowPart) - goto next_account_right; - } - - tmp_count = privs ? privs->PrivilegeCount : 0; - size = sizeof (DWORD) - + (tmp_count + 1) * sizeof (LUID_AND_ATTRIBUTES); - tmp = (PTOKEN_PRIVILEGES) realloc (privs, size); - if (!tmp) - { - if (privs) - free (privs); - LsaFreeMemory (privstrs); - debug_printf ("realloc (privs) failed."); - return NULL; - } - tmp->PrivilegeCount = tmp_count; - privs = tmp; - privs->Privileges[privs->PrivilegeCount].Luid = priv; - privs->Privileges[privs->PrivilegeCount].Attributes = - SE_PRIVILEGE_ENABLED | SE_PRIVILEGE_ENABLED_BY_DEFAULT; - ++privs->PrivilegeCount; - - next_account_right: - ; - } - LsaFreeMemory (privstrs); - } - return privs; -} - -/* Accept a token if - - the requested usersid matches the TokenUser and - - if setgroups has been called: - the token groups that are listed in /etc/group match the union of - the requested primary and supplementary groups in gsids. - - else the (unknown) implicitly requested supplementary groups and those - in the token are the groups associated with the usersid. We assume - they match and verify only the primary groups. - The requested primary group must appear in the token. - The primary group in the token is a group associated with the usersid, - except if the token is internal and the group is in the token SD - (see create_token). In that latter case that group must match the - requested primary group. */ -bool -verify_token (HANDLE token, cygsid &usersid, user_groups &groups, bool *pintern) -{ - DWORD size; - bool intern = false; - - if (pintern) - { - TOKEN_SOURCE ts; - if (!GetTokenInformation (token, TokenSource, - &ts, sizeof ts, &size)) - debug_printf ("GetTokenInformation(), %E"); - else - *pintern = intern = !memcmp (ts.SourceName, "Cygwin.1", 8); - } - /* Verify usersid */ - cygsid tok_usersid = NO_SID; - if (!GetTokenInformation (token, TokenUser, - &tok_usersid, sizeof tok_usersid, &size)) - debug_printf ("GetTokenInformation(), %E"); - if (usersid != tok_usersid) - return false; - - /* For an internal token, if setgroups was not called and if the sd group - is not well_known_null_sid, it must match pgrpsid */ - if (intern && !groups.issetgroups ()) - { - const DWORD sd_buf_siz = MAX_SID_LEN + sizeof (SECURITY_DESCRIPTOR); - PSECURITY_DESCRIPTOR sd_buf = (PSECURITY_DESCRIPTOR) alloca (sd_buf_siz); - cygpsid gsid (NO_SID); - if (!GetKernelObjectSecurity (token, GROUP_SECURITY_INFORMATION, - sd_buf, sd_buf_siz, &size)) - debug_printf ("GetKernelObjectSecurity(), %E"); - else if (!GetSecurityDescriptorGroup (sd_buf, (PSID *) &gsid, - (BOOL *) &size)) - debug_printf ("GetSecurityDescriptorGroup(), %E"); - if (well_known_null_sid != gsid) - return gsid == groups.pgsid; - } - - PTOKEN_GROUPS my_grps; - bool sawpg = false, ret = false; - - if (!GetTokenInformation (token, TokenGroups, NULL, 0, &size) && - GetLastError () != ERROR_INSUFFICIENT_BUFFER) - debug_printf ("GetTokenInformation(token, TokenGroups), %E"); - else if (!(my_grps = (PTOKEN_GROUPS) alloca (size))) - debug_printf ("alloca (my_grps) failed."); - else if (!GetTokenInformation (token, TokenGroups, my_grps, size, &size)) - debug_printf ("GetTokenInformation(my_token, TokenGroups), %E"); - else - { - if (groups.issetgroups ()) /* setgroups was called */ - { - cygsid gsid; - struct __group32 *gr; - bool saw[groups.sgsids.count ()]; - memset (saw, 0, sizeof(saw)); - - /* token groups found in /etc/group match the user.gsids ? */ - for (int gidx = 0; (gr = internal_getgrent (gidx)); ++gidx) - if (gsid.getfromgr (gr) && sid_in_token_groups (my_grps, gsid)) - { - int pos = groups.sgsids.position (gsid); - if (pos >= 0) - saw[pos] = true; - else if (groups.pgsid == gsid) - sawpg = true; -#if 0 - /* With this `else', verify_token returns false if we find - groups in the token, which are not in the group list set - with setgroups(). That's rather dangerous. What we're - really interested in is that all groups in the setgroups() - list are in the token. A token created through ADVAPI - should be allowed to contain more groups than requested - through setgroups(), esecially since Vista and the - addition of integrity groups. So we disable this statement - for now. */ - else if (gsid != well_known_world_sid - && gsid != usersid) - goto done; -#endif - } - /* user.sgsids groups must be in the token, except for builtin groups. - These can be different on domain member machines compared to - domain controllers, so these builtin groups may be validly missing - from a token created through password or lsaauth logon. */ - for (int gidx = 0; gidx < groups.sgsids.count (); gidx++) - if (!saw[gidx] - && !groups.sgsids.sids[gidx].is_well_known_sid () - && !sid_in_token_groups (my_grps, groups.sgsids.sids[gidx])) - goto done; - } - /* The primary group must be in the token */ - ret = sawpg - || sid_in_token_groups (my_grps, groups.pgsid) - || groups.pgsid == usersid; - } -done: - return ret; -} - -HANDLE -create_token (cygsid &usersid, user_groups &new_groups, struct passwd *pw) -{ - NTSTATUS ret; - LSA_HANDLE lsa = INVALID_HANDLE_VALUE; - - cygsidlist tmp_gsids (cygsidlist_auto, 12); - - SECURITY_QUALITY_OF_SERVICE sqos = - { sizeof sqos, SecurityImpersonation, SECURITY_STATIC_TRACKING, FALSE }; - OBJECT_ATTRIBUTES oa = { sizeof oa, 0, 0, 0, 0, &sqos }; - LUID auth_luid = SYSTEM_LUID; - LARGE_INTEGER exp = { QuadPart:INT64_MAX }; - - TOKEN_USER user; - PTOKEN_GROUPS new_tok_gsids = NULL; - PTOKEN_PRIVILEGES privs = NULL; - TOKEN_OWNER owner; - TOKEN_PRIMARY_GROUP pgrp; - TOKEN_DEFAULT_DACL dacl = {}; - TOKEN_SOURCE source; - TOKEN_STATISTICS stats; - memcpy (source.SourceName, "Cygwin.1", 8); - source.SourceIdentifier.HighPart = 0; - source.SourceIdentifier.LowPart = 0x0101; - - HANDLE token = INVALID_HANDLE_VALUE; - HANDLE primary_token = INVALID_HANDLE_VALUE; - - PTOKEN_GROUPS my_tok_gsids = NULL; - DWORD size; - size_t psize = 0; - - /* SE_CREATE_TOKEN_NAME privilege needed to call NtCreateToken. */ - push_self_privilege (SE_CREATE_TOKEN_PRIVILEGE, true); - - /* Open policy object. */ - if ((lsa = open_local_policy (POLICY_EXECUTE)) == INVALID_HANDLE_VALUE) - goto out; - - /* User, owner, primary group. */ - user.User.Sid = usersid; - user.User.Attributes = 0; - owner.Owner = usersid; - - /* Retrieve authentication id and group list from own process. */ - if (hProcToken) - { - /* Switching user context to SYSTEM doesn't inherit the authentication - id of the user account running current process. */ - if (usersid == well_known_system_sid) - /* nothing to do */; - else if (!GetTokenInformation (hProcToken, TokenStatistics, - &stats, sizeof stats, &size)) - debug_printf - ("GetTokenInformation(hProcToken, TokenStatistics), %E"); - else - auth_luid = stats.AuthenticationId; - - /* Retrieving current processes group list to be able to inherit - some important well known group sids. */ - if (!GetTokenInformation (hProcToken, TokenGroups, NULL, 0, &size) - && GetLastError () != ERROR_INSUFFICIENT_BUFFER) - debug_printf ("GetTokenInformation(hProcToken, TokenGroups), %E"); - else if (!(my_tok_gsids = (PTOKEN_GROUPS) malloc (size))) - debug_printf ("malloc (my_tok_gsids) failed."); - else if (!GetTokenInformation (hProcToken, TokenGroups, my_tok_gsids, - size, &size)) - { - debug_printf ("GetTokenInformation(hProcToken, TokenGroups), %E"); - free (my_tok_gsids); - my_tok_gsids = NULL; - } - } - - /* Create list of groups, the user is member in. */ - int auth_pos; - if (new_groups.issetgroups ()) - get_setgroups_sidlist (tmp_gsids, usersid, pw, my_tok_gsids, new_groups, - auth_luid, auth_pos); - else if (!get_initgroups_sidlist (tmp_gsids, usersid, new_groups.pgsid, pw, - my_tok_gsids, auth_luid, auth_pos)) - goto out; - - /* Primary group. */ - pgrp.PrimaryGroup = new_groups.pgsid; - - /* Create a TOKEN_GROUPS list from the above retrieved list of sids. */ - new_tok_gsids = (PTOKEN_GROUPS) - alloca (sizeof (DWORD) + (tmp_gsids.count () + 1) - * sizeof (SID_AND_ATTRIBUTES)); - new_tok_gsids->GroupCount = tmp_gsids.count (); - for (DWORD i = 0; i < new_tok_gsids->GroupCount; ++i) - { - new_tok_gsids->Groups[i].Sid = tmp_gsids.sids[i]; - new_tok_gsids->Groups[i].Attributes = SE_GROUP_MANDATORY - | SE_GROUP_ENABLED_BY_DEFAULT - | SE_GROUP_ENABLED; - } - if (auth_pos >= 0) - new_tok_gsids->Groups[auth_pos].Attributes |= SE_GROUP_LOGON_ID; - - /* On systems supporting Mandatory Integrity Control, add a MIC SID. */ - if (wincap.has_mandatory_integrity_control ()) - { - new_tok_gsids->Groups[new_tok_gsids->GroupCount].Attributes = - SE_GROUP_INTEGRITY | SE_GROUP_INTEGRITY_ENABLED; - if (usersid == well_known_system_sid) - new_tok_gsids->Groups[new_tok_gsids->GroupCount++].Sid - = mandatory_system_integrity_sid; - else if (tmp_gsids.contains (well_known_admins_sid)) - new_tok_gsids->Groups[new_tok_gsids->GroupCount++].Sid - = mandatory_high_integrity_sid; - else - new_tok_gsids->Groups[new_tok_gsids->GroupCount++].Sid - = mandatory_medium_integrity_sid; - } - - /* Retrieve list of privileges of that user. */ - if (!(privs = get_priv_list (lsa, usersid, tmp_gsids, psize))) - goto out; - - /* Let's be heroic... */ - ret = NtCreateToken (&token, TOKEN_ALL_ACCESS, &oa, TokenImpersonation, - &auth_luid, &exp, &user, new_tok_gsids, privs, &owner, - &pgrp, &dacl, &source); - if (ret) - __seterrno_from_nt_status (ret); - else - { - /* Convert to primary token. */ - if (!DuplicateTokenEx (token, MAXIMUM_ALLOWED, &sec_none, - SecurityImpersonation, TokenPrimary, - &primary_token)) - { - __seterrno (); - debug_printf ("DuplicateTokenEx %E"); - } - } - -out: - pop_self_privilege (); - if (token != INVALID_HANDLE_VALUE) - CloseHandle (token); - if (privs) - free (privs); - if (my_tok_gsids) - free (my_tok_gsids); - close_local_policy (lsa); - - debug_printf ("%p = create_token ()", primary_token); - return primary_token; -} - -HANDLE -lsaauth (cygsid &usersid, user_groups &new_groups, struct passwd *pw) -{ - cygsidlist tmp_gsids (cygsidlist_auto, 12); - cygpsid pgrpsid; - LSA_STRING name; - HANDLE lsa_hdl = NULL, lsa = INVALID_HANDLE_VALUE; - LSA_OPERATIONAL_MODE sec_mode; - NTSTATUS ret, ret2; - ULONG package_id, size; - LUID auth_luid = SYSTEM_LUID; - struct { - LSA_STRING str; - CHAR buf[16]; - } origin; - DWORD ulen = UNLEN + 1; - DWORD dlen = MAX_DOMAIN_NAME_LEN + 1; - SID_NAME_USE use; - cyglsa_t *authinf = NULL; - ULONG authinf_size; - TOKEN_SOURCE ts; - PCYG_TOKEN_GROUPS gsids = NULL; - PTOKEN_PRIVILEGES privs = NULL; - PACL dacl = NULL; - PVOID profile = NULL; - LUID luid; - QUOTA_LIMITS quota; - size_t psize = 0, gsize = 0, dsize = 0; - OFFSET offset, sids_offset; - int tmpidx, non_well_known_cnt; - - HANDLE user_token = NULL; - - push_self_privilege (SE_TCB_PRIVILEGE, true); - - /* Register as logon process. */ - str2lsa (name, "Cygwin"); - SetLastError (0); - ret = LsaRegisterLogonProcess (&name, &lsa_hdl, &sec_mode); - if (ret != STATUS_SUCCESS) - { - debug_printf ("LsaRegisterLogonProcess: %p", ret); - __seterrno_from_win_error (LsaNtStatusToWinError (ret)); - goto out; - } - else if (GetLastError () == ERROR_PROC_NOT_FOUND) - { - debug_printf ("Couldn't load Secur32.dll"); - goto out; - } - /* Get handle to our own LSA package. */ - str2lsa (name, CYG_LSA_PKGNAME); - ret = LsaLookupAuthenticationPackage (lsa_hdl, &name, &package_id); - if (ret != STATUS_SUCCESS) - { - debug_printf ("LsaLookupAuthenticationPackage: %p", ret); - __seterrno_from_win_error (LsaNtStatusToWinError (ret)); - goto out; - } - - /* Open policy object. */ - if ((lsa = open_local_policy (POLICY_EXECUTE)) == INVALID_HANDLE_VALUE) - goto out; - - /* Create origin. */ - str2buf2lsa (origin.str, origin.buf, "Cygwin"); - /* Create token source. */ - memcpy (ts.SourceName, "Cygwin.1", 8); - ts.SourceIdentifier.HighPart = 0; - ts.SourceIdentifier.LowPart = 0x0103; - - /* Create list of groups, the user is member in. */ - int auth_pos; - if (new_groups.issetgroups ()) - get_setgroups_sidlist (tmp_gsids, usersid, pw, NULL, new_groups, auth_luid, - auth_pos); - else if (!get_initgroups_sidlist (tmp_gsids, usersid, new_groups.pgsid, pw, - NULL, auth_luid, auth_pos)) - goto out; - /* The logon SID entry is not generated automatically on Windows 2000 - and earlier for some reason. So add fake logon sid here, which is - filled with logon id values in the authentication package. */ - if (wincap.needs_logon_sid_in_sid_list ()) - tmp_gsids += fake_logon_sid; - - tmp_gsids.debug_print ("tmp_gsids"); - - /* Evaluate size of TOKEN_GROUPS list */ - non_well_known_cnt = tmp_gsids.non_well_known_count (); - gsize = sizeof (DWORD) + non_well_known_cnt * sizeof (SID_AND_ATTRIBUTES); - tmpidx = -1; - for (int i = 0; i < non_well_known_cnt; ++i) - if ((tmpidx = tmp_gsids.next_non_well_known_sid (tmpidx)) >= 0) - gsize += GetLengthSid (tmp_gsids.sids[tmpidx]); - - /* Retrieve list of privileges of that user. */ - if (!(privs = get_priv_list (lsa, usersid, tmp_gsids, psize))) - goto out; - - /* Create DefaultDacl. */ - dsize = sizeof (ACL) + 3 * sizeof (ACCESS_ALLOWED_ACE) - + GetLengthSid (usersid) - + GetLengthSid (well_known_admins_sid) - + GetLengthSid (well_known_system_sid); - dacl = (PACL) alloca (dsize); - if (!InitializeAcl (dacl, dsize, ACL_REVISION)) - goto out; - if (!AddAccessAllowedAce (dacl, ACL_REVISION, GENERIC_ALL, usersid)) - goto out; - if (!AddAccessAllowedAce (dacl, ACL_REVISION, GENERIC_ALL, - well_known_admins_sid)) - goto out; - if (!AddAccessAllowedAce (dacl, ACL_REVISION, GENERIC_ALL, - well_known_system_sid)) - goto out; - - /* Evaluate authinf size and allocate authinf. */ - authinf_size = (authinf->data - (PBYTE) authinf); - authinf_size += GetLengthSid (usersid); /* User SID */ - authinf_size += gsize; /* Groups + Group SIDs */ - /* When trying to define the admins group as primary group on Vista, - LsaLogonUser fails with error STATUS_INVALID_OWNER. As workaround - we define "Local" as primary group here. Seteuid32 sets the primary - group to the group set in /etc/passwd anyway. */ - if (new_groups.pgsid == well_known_admins_sid) - pgrpsid = well_known_local_sid; - else - pgrpsid = new_groups.pgsid; - - authinf_size += GetLengthSid (pgrpsid); /* Primary Group SID */ - - authinf_size += psize; /* Privileges */ - authinf_size += 0; /* Owner SID */ - authinf_size += dsize; /* Default DACL */ - - authinf = (cyglsa_t *) alloca (authinf_size); - authinf->inf_size = authinf_size - ((PBYTE) &authinf->inf - (PBYTE) authinf); - - authinf->magic = CYG_LSA_MAGIC; - - if (!LookupAccountSidW (NULL, usersid, authinf->username, &ulen, - authinf->domain, &dlen, &use)) - { - __seterrno (); - goto out; - } - - /* Store stuff in authinf with offset relative to start of "inf" member, - instead of using pointers. */ - offset = authinf->data - (PBYTE) &authinf->inf; - - authinf->inf.ExpirationTime.LowPart = 0xffffffffL; - authinf->inf.ExpirationTime.HighPart = 0x7fffffffL; - /* User SID */ - authinf->inf.User.User.Sid = offset; - authinf->inf.User.User.Attributes = 0; - CopySid (GetLengthSid (usersid), (PSID) ((PBYTE) &authinf->inf + offset), - usersid); - offset += GetLengthSid (usersid); - /* Groups */ - authinf->inf.Groups = offset; - gsids = (PCYG_TOKEN_GROUPS) ((PBYTE) &authinf->inf + offset); - sids_offset = offset + sizeof (ULONG) + non_well_known_cnt - * sizeof (SID_AND_ATTRIBUTES); - gsids->GroupCount = non_well_known_cnt; - /* Group SIDs */ - tmpidx = -1; - for (int i = 0; i < non_well_known_cnt; ++i) - { - if ((tmpidx = tmp_gsids.next_non_well_known_sid (tmpidx)) < 0) - break; - gsids->Groups[i].Sid = sids_offset; - gsids->Groups[i].Attributes = SE_GROUP_MANDATORY - | SE_GROUP_ENABLED_BY_DEFAULT - | SE_GROUP_ENABLED; - /* Mark logon SID as logon SID :) */ - if (wincap.needs_logon_sid_in_sid_list () - && tmp_gsids.sids[tmpidx] == fake_logon_sid) - gsids->Groups[i].Attributes += SE_GROUP_LOGON_ID; - CopySid (GetLengthSid (tmp_gsids.sids[tmpidx]), - (PSID) ((PBYTE) &authinf->inf + sids_offset), - tmp_gsids.sids[tmpidx]); - sids_offset += GetLengthSid (tmp_gsids.sids[tmpidx]); - } - offset += gsize; - /* Primary Group SID */ - authinf->inf.PrimaryGroup.PrimaryGroup = offset; - CopySid (GetLengthSid (pgrpsid), (PSID) ((PBYTE) &authinf->inf + offset), - pgrpsid); - offset += GetLengthSid (pgrpsid); - /* Privileges */ - authinf->inf.Privileges = offset; - memcpy ((PBYTE) &authinf->inf + offset, privs, psize); - offset += psize; - /* Owner */ - authinf->inf.Owner.Owner = 0; - /* Default DACL */ - authinf->inf.DefaultDacl.DefaultDacl = offset; - memcpy ((PBYTE) &authinf->inf + offset, dacl, dsize); - - authinf->checksum = CYG_LSA_MAGIC; - PDWORD csp; - PDWORD csp_end; - csp = (PDWORD) &authinf->username; - csp_end = (PDWORD) ((PBYTE) authinf + authinf_size); - while (csp < csp_end) - authinf->checksum += *csp++; - - /* Try to logon... */ - ret = LsaLogonUser (lsa_hdl, (PLSA_STRING) &origin, Interactive, package_id, - authinf, authinf_size, NULL, &ts, &profile, &size, &luid, - &user_token, "a, &ret2); - if (ret != STATUS_SUCCESS) - { - debug_printf ("LsaLogonUser: %p", ret); - __seterrno_from_win_error (LsaNtStatusToWinError (ret)); - goto out; - } - if (profile) - { -#ifdef JUST_ANOTHER_NONWORKING_SOLUTION - /* See ../lsaauth/cyglsa.c. */ - cygprf_t *prf = (cygprf_t *) profile; - if (prf->magic_pre == MAGIC_PRE && prf->magic_post == MAGIC_POST - && prf->token) - { - CloseHandle (user_token); - user_token = prf->token; - system_printf ("Got token through profile: %p", user_token); - } -#endif /* JUST_ANOTHER_NONWORKING_SOLUTION */ - LsaFreeReturnBuffer (profile); - } - user_token = get_full_privileged_inheritable_token (user_token); - -out: - if (privs) - free (privs); - close_local_policy (lsa); - if (lsa_hdl) - LsaDeregisterLogonProcess (lsa_hdl); - pop_self_privilege (); - - debug_printf ("%p = lsaauth ()", user_token); - return user_token; -} - -#define SFU_LSA_KEY_SUFFIX L"_microsoft_sfu_utility" - -HANDLE -lsaprivkeyauth (struct passwd *pw) -{ - NTSTATUS status; - HANDLE lsa = INVALID_HANDLE_VALUE; - HANDLE token = NULL; - WCHAR sid[256]; - WCHAR domain[MAX_DOMAIN_NAME_LEN + 1]; - WCHAR user[UNLEN + 1]; - WCHAR key_name[MAX_DOMAIN_NAME_LEN + UNLEN + wcslen (SFU_LSA_KEY_SUFFIX) + 2]; - UNICODE_STRING key; - PUNICODE_STRING data; - cygsid psid; - - push_self_privilege (SE_TCB_PRIVILEGE, true); - - /* Open policy object. */ - if ((lsa = open_local_policy (POLICY_GET_PRIVATE_INFORMATION)) - == INVALID_HANDLE_VALUE) - goto out; - - /* Needed for Interix key and LogonUser. */ - extract_nt_dom_user (pw, domain, user); - - /* First test for a Cygwin entry. */ - if (psid.getfrompw (pw) && psid.string (sid)) - { - wcpcpy (wcpcpy (key_name, CYGWIN_LSA_KEY_PREFIX), sid); - RtlInitUnicodeString (&key, key_name); - status = LsaRetrievePrivateData (lsa, &key, &data); - if (!NT_SUCCESS (status)) - { - /* No Cygwin key, try Interix key. */ - if (!*domain) - goto out; - __small_swprintf (key_name, L"%W_%W%W", - domain, user, SFU_LSA_KEY_SUFFIX); - RtlInitUnicodeString (&key, key_name); - status = LsaRetrievePrivateData (lsa, &key, &data); - if (!NT_SUCCESS (status)) - goto out; - } - } - - /* The key is not 0-terminated. */ - PWCHAR passwd; - passwd = (PWCHAR) alloca (data->Length + sizeof (WCHAR)); - *wcpncpy (passwd, data->Buffer, data->Length / sizeof (WCHAR)) = L'\0'; - LsaFreeMemory (data); - debug_printf ("Try logon for %W\\%W", domain, user); - if (!LogonUserW (user, domain, passwd, LOGON32_LOGON_INTERACTIVE, - LOGON32_PROVIDER_DEFAULT, &token)) - { - __seterrno (); - token = NULL; - } - else - token = get_full_privileged_inheritable_token (token); - -out: - close_local_policy (lsa); - pop_self_privilege (); - return token; -} diff --git a/winsup/cygwin/sec_helper.cc b/winsup/cygwin/sec_helper.cc deleted file mode 100644 index dc7b89fba..000000000 --- a/winsup/cygwin/sec_helper.cc +++ /dev/null @@ -1,581 +0,0 @@ -/* sec_helper.cc: NT security helper functions - - Copyright 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009, - 2010 Red Hat, Inc. - - Written by Corinna Vinschen - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "pinfo.h" -#include "cygheap.h" -#include "pwdgrp.h" -#include "ntdll.h" - -/* General purpose security attribute objects for global use. */ -SECURITY_ATTRIBUTES NO_COPY sec_none; -SECURITY_ATTRIBUTES NO_COPY sec_none_nih; -SECURITY_ATTRIBUTES NO_COPY sec_all; -SECURITY_ATTRIBUTES NO_COPY sec_all_nih; - -MKSID (well_known_null_sid, "S-1-0-0", - SECURITY_NULL_SID_AUTHORITY, 1, SECURITY_NULL_RID); -MKSID (well_known_world_sid, "S-1-1-0", - SECURITY_WORLD_SID_AUTHORITY, 1, SECURITY_WORLD_RID); -MKSID (well_known_local_sid, "S-1-2-0", - SECURITY_LOCAL_SID_AUTHORITY, 1, SECURITY_LOCAL_RID); -MKSID (well_known_creator_owner_sid, "S-1-3-0", - SECURITY_CREATOR_SID_AUTHORITY, 1, SECURITY_CREATOR_OWNER_RID); -MKSID (well_known_creator_group_sid, "S-1-3-1", - SECURITY_CREATOR_SID_AUTHORITY, 1, SECURITY_CREATOR_GROUP_RID); -MKSID (well_known_dialup_sid, "S-1-5-1", - SECURITY_NT_AUTHORITY, 1, SECURITY_DIALUP_RID); -MKSID (well_known_network_sid, "S-1-5-2", - SECURITY_NT_AUTHORITY, 1, SECURITY_NETWORK_RID); -MKSID (well_known_batch_sid, "S-1-5-3", - SECURITY_NT_AUTHORITY, 1, SECURITY_BATCH_RID); -MKSID (well_known_interactive_sid, "S-1-5-4", - SECURITY_NT_AUTHORITY, 1, SECURITY_INTERACTIVE_RID); -MKSID (well_known_service_sid, "S-1-5-6", - SECURITY_NT_AUTHORITY, 1, SECURITY_SERVICE_RID); -MKSID (well_known_authenticated_users_sid, "S-1-5-11", - SECURITY_NT_AUTHORITY, 1, SECURITY_AUTHENTICATED_USER_RID); -MKSID (well_known_this_org_sid, "S-1-5-15", - SECURITY_NT_AUTHORITY, 1, 15); -MKSID (well_known_system_sid, "S-1-5-18", - SECURITY_NT_AUTHORITY, 1, SECURITY_LOCAL_SYSTEM_RID); -MKSID (well_known_builtin_sid, "S-1-5-32", - SECURITY_NT_AUTHORITY, 1, SECURITY_BUILTIN_DOMAIN_RID); -MKSID (well_known_admins_sid, "S-1-5-32-544", - SECURITY_NT_AUTHORITY, 2, SECURITY_BUILTIN_DOMAIN_RID, - DOMAIN_ALIAS_RID_ADMINS); -MKSID (well_known_users_sid, "S-1-5-32-545", - SECURITY_NT_AUTHORITY, 2, SECURITY_BUILTIN_DOMAIN_RID, - DOMAIN_ALIAS_RID_USERS); -MKSID (fake_logon_sid, "S-1-5-5-0-0", - SECURITY_NT_AUTHORITY, 3, SECURITY_LOGON_IDS_RID, 0, 0); -MKSID (mandatory_medium_integrity_sid, "S-1-16-8192", - SECURITY_MANDATORY_LABEL_AUTHORITY, 1, SECURITY_MANDATORY_MEDIUM_RID); -MKSID (mandatory_high_integrity_sid, "S-1-16-12288", - SECURITY_MANDATORY_LABEL_AUTHORITY, 1, SECURITY_MANDATORY_HIGH_RID); -MKSID (mandatory_system_integrity_sid, "S-1-16-16384", - SECURITY_MANDATORY_LABEL_AUTHORITY, 1, SECURITY_MANDATORY_SYSTEM_RID); -/* UNIX accounts on a Samba server have the SID prefix "S-1-22-1" */ -#define SECURITY_SAMBA_UNIX_AUTHORITY {0,0,0,0,0,22} -MKSID (well_known_samba_unix_user_fake_sid, "S-1-22-1-0", - SECURITY_SAMBA_UNIX_AUTHORITY, 2, 1, 0); - -bool -cygpsid::operator== (const char *nsidstr) const -{ - cygsid nsid (nsidstr); - return psid == nsid; -} - -__uid32_t -cygpsid::get_id (BOOL search_grp, int *type) -{ - /* First try to get SID from group, then passwd */ - __uid32_t id = ILLEGAL_UID; - - if (search_grp) - { - struct __group32 *gr; - if (cygheap->user.groups.pgsid == psid) - id = myself->gid; - else if ((gr = internal_getgrsid (*this))) - id = gr->gr_gid; - if (id != ILLEGAL_UID) - { - if (type) - *type = GROUP; - return id; - } - } - if (!search_grp || type) - { - struct passwd *pw; - if (*this == cygheap->user.sid ()) - id = myself->uid; - else if ((pw = internal_getpwsid (*this))) - id = pw->pw_uid; - if (id != ILLEGAL_UID && type) - *type = USER; - } - return id; -} - -PWCHAR -cygpsid::string (PWCHAR nsidstr) const -{ - UNICODE_STRING sid; - - if (!psid || !nsidstr) - return NULL; - RtlInitEmptyUnicodeString (&sid, nsidstr, 256); - RtlConvertSidToUnicodeString (&sid, psid, FALSE); - return nsidstr; -} - -char * -cygpsid::string (char *nsidstr) const -{ - char *t; - DWORD i; - - if (!psid || !nsidstr) - return NULL; - strcpy (nsidstr, "S-1-"); - t = nsidstr + sizeof ("S-1-") - 1; - t += __small_sprintf (t, "%u", GetSidIdentifierAuthority (psid)->Value[5]); - for (i = 0; i < *GetSidSubAuthorityCount (psid); ++i) - t += __small_sprintf (t, "-%lu", *GetSidSubAuthority (psid, i)); - return nsidstr; -} - -PSID -cygsid::get_sid (DWORD s, DWORD cnt, DWORD *r, bool well_known) -{ - DWORD i; - SID_IDENTIFIER_AUTHORITY sid_auth = {{0,0,0,0,0,0}}; - - if (s > 255 || cnt < 1 || cnt > 8) - { - psid = NO_SID; - return NULL; - } - sid_auth.Value[5] = s; - set (); - InitializeSid (psid, &sid_auth, cnt); - for (i = 0; i < cnt; ++i) - memcpy ((char *) psid + 8 + sizeof (DWORD) * i, &r[i], sizeof (DWORD)); - well_known_sid = well_known; - return psid; -} - -const PSID -cygsid::getfromstr (const char *nsidstr, bool well_known) -{ - char *lasts; - DWORD s, cnt = 0; - DWORD r[8]; - - if (nsidstr && !strncmp (nsidstr, "S-1-", 4)) - { - s = strtoul (nsidstr + 4, &lasts, 10); - while (cnt < 8 && *lasts == '-') - r[cnt++] = strtoul (lasts + 1, &lasts, 10); - if (!*lasts) - return get_sid (s, cnt, r, well_known); - } - return psid = NO_SID; -} - -BOOL -cygsid::getfrompw (const struct passwd *pw) -{ - char *sp = (pw && pw->pw_gecos) ? strrchr (pw->pw_gecos, ',') : NULL; - return (*this = sp ? sp + 1 : sp) != NULL; -} - -BOOL -cygsid::getfromgr (const struct __group32 *gr) -{ - char *sp = (gr && gr->gr_passwd) ? gr->gr_passwd : NULL; - return (*this = sp) != NULL; -} - -cygsid * -cygsidlist::alloc_sids (int n) -{ - if (n > 0) - return (cygsid *) cmalloc (HEAP_STR, n * sizeof (cygsid)); - else - return NULL; -} - -void -cygsidlist::free_sids () -{ - if (sids) - cfree (sids); - sids = NULL; - cnt = maxcnt = 0; - type = cygsidlist_empty; -} - -BOOL -cygsidlist::add (const PSID nsi, bool well_known) -{ - if (contains (nsi)) - return TRUE; - if (cnt >= maxcnt) - { - cygsid *tmp = new cygsid [2 * maxcnt]; - if (!tmp) - return FALSE; - maxcnt *= 2; - for (int i = 0; i < cnt; ++i) - tmp[i] = sids[i]; - delete [] sids; - sids = tmp; - } - if (well_known) - sids[cnt++] *= nsi; - else - sids[cnt++] = nsi; - return TRUE; -} - -bool -get_sids_info (cygpsid owner_sid, cygpsid group_sid, __uid32_t * uidret, __gid32_t * gidret) -{ - struct passwd *pw; - struct __group32 *gr = NULL; - bool ret = false; - - owner_sid.debug_print ("get_sids_info: owner SID ="); - group_sid.debug_print ("get_sids_info: group SID ="); - - if (group_sid == cygheap->user.groups.pgsid) - *gidret = myself->gid; - else if ((gr = internal_getgrsid (group_sid))) - *gidret = gr->gr_gid; - else - *gidret = ILLEGAL_GID; - - if (owner_sid == cygheap->user.sid ()) - { - *uidret = myself->uid; - if (*gidret == myself->gid) - ret = true; - else - ret = (internal_getgroups (0, NULL, &group_sid) > 0); - } - else if ((pw = internal_getpwsid (owner_sid))) - { - *uidret = pw->pw_uid; - if (gr || (*gidret != ILLEGAL_GID - && (gr = internal_getgrgid (*gidret)))) - for (int idx = 0; gr->gr_mem[idx]; ++idx) - if ((ret = strcasematch (pw->pw_name, gr->gr_mem[idx]))) - break; - } - else - *uidret = ILLEGAL_UID; - - return ret; -} - -PSECURITY_DESCRIPTOR -security_descriptor::malloc (size_t nsize) -{ - free (); - if ((psd = (PSECURITY_DESCRIPTOR) ::malloc (nsize))) - sd_size = nsize; - return psd; -} - -PSECURITY_DESCRIPTOR -security_descriptor::realloc (size_t nsize) -{ - PSECURITY_DESCRIPTOR tmp; - - /* Can't re-use buffer allocated by GetSecurityInfo. */ - if (psd && !sd_size) - free (); - if (!(tmp = (PSECURITY_DESCRIPTOR) ::realloc (psd, nsize))) - return NULL; - sd_size = nsize; - return psd = tmp; -} - -void -security_descriptor::free () -{ - if (psd) - { - if (!sd_size) - LocalFree (psd); - else - ::free (psd); - } - psd = NULL; - sd_size = 0; -} - -#undef TEXT -#define TEXT(q) L##q - -/* Index must match the correspoding foo_PRIVILEGE value, see security.h. */ -static const wchar_t *cygpriv[] = -{ - L"", - L"", - SE_CREATE_TOKEN_NAME, - SE_ASSIGNPRIMARYTOKEN_NAME, - SE_LOCK_MEMORY_NAME, - SE_INCREASE_QUOTA_NAME, - SE_MACHINE_ACCOUNT_NAME, - SE_TCB_NAME, - SE_SECURITY_NAME, - SE_TAKE_OWNERSHIP_NAME, - SE_LOAD_DRIVER_NAME, - SE_SYSTEM_PROFILE_NAME, - SE_SYSTEMTIME_NAME, - SE_PROF_SINGLE_PROCESS_NAME, - SE_INC_BASE_PRIORITY_NAME, - SE_CREATE_PAGEFILE_NAME, - SE_CREATE_PERMANENT_NAME, - SE_BACKUP_NAME, - SE_RESTORE_NAME, - SE_SHUTDOWN_NAME, - SE_DEBUG_NAME, - SE_AUDIT_NAME, - SE_SYSTEM_ENVIRONMENT_NAME, - SE_CHANGE_NOTIFY_NAME, - SE_REMOTE_SHUTDOWN_NAME, - SE_UNDOCK_NAME, - SE_SYNC_AGENT_NAME, - SE_ENABLE_DELEGATION_NAME, - SE_MANAGE_VOLUME_NAME, - SE_IMPERSONATE_NAME, - SE_CREATE_GLOBAL_NAME, - SE_TRUSTED_CREDMAN_ACCESS_NAME, - SE_RELABEL_NAME, - SE_INCREASE_WORKING_SET_NAME, - SE_TIME_ZONE_NAME, - SE_CREATE_SYMBOLIC_LINK_NAME -}; - -bool -privilege_luid (const PWCHAR pname, LUID *luid) -{ - ULONG idx; - for (idx = SE_CREATE_TOKEN_PRIVILEGE; - idx <= SE_MAX_WELL_KNOWN_PRIVILEGE; - ++idx) - if (!wcscmp (cygpriv[idx], pname)) - { - luid->HighPart = 0; - luid->LowPart = idx; - return true; - } - return false; -} - -static const wchar_t * -privilege_name (const LUID &priv_luid) -{ - if (priv_luid.HighPart || priv_luid.LowPart < SE_CREATE_TOKEN_PRIVILEGE - || priv_luid.LowPart > SE_MAX_WELL_KNOWN_PRIVILEGE) - return L""; - return cygpriv[priv_luid.LowPart]; -} - -int -set_privilege (HANDLE token, DWORD privilege, bool enable) -{ - int ret = -1; - TOKEN_PRIVILEGES new_priv, orig_priv; - ULONG size; - NTSTATUS status; - - new_priv.PrivilegeCount = 1; - new_priv.Privileges[0].Luid.HighPart = 0L; - new_priv.Privileges[0].Luid.LowPart = privilege; - new_priv.Privileges[0].Attributes = enable ? SE_PRIVILEGE_ENABLED : 0; - - status = NtAdjustPrivilegesToken (token, FALSE, &new_priv, sizeof orig_priv, - &orig_priv, &size); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - goto out; - } - - /* If orig_priv.PrivilegeCount is 0, the privilege hasn't been changed. */ - if (!orig_priv.PrivilegeCount) - ret = enable ? 1 : 0; - else - ret = (orig_priv.Privileges[0].Attributes & SE_PRIVILEGE_ENABLED) ? 1 : 0; - -out: - if (ret < 0) - debug_printf ("%d = set_privilege ((token %x) %W, %d)\n", ret, token, - privilege_name (new_priv.Privileges[0].Luid), enable); - return ret; -} - -/* This is called very early in process initialization. The code must - not depend on anything. */ -void -set_cygwin_privileges (HANDLE token) -{ - set_privilege (token, SE_RESTORE_PRIVILEGE, true); - set_privilege (token, SE_BACKUP_PRIVILEGE, true); - if (wincap.has_create_global_privilege ()) - set_privilege (token, SE_CREATE_GLOBAL_PRIVILEGE, true); -} - -/* Function to return a common SECURITY_DESCRIPTOR that - allows all access. */ - - -SECURITY_DESCRIPTOR *__stdcall -get_null_sd () -{ - static NO_COPY SECURITY_DESCRIPTOR sd; - static NO_COPY SECURITY_DESCRIPTOR *null_sdp; - - if (!null_sdp) - { - InitializeSecurityDescriptor (&sd, SECURITY_DESCRIPTOR_REVISION); - SetSecurityDescriptorDacl (&sd, TRUE, 0, FALSE); - null_sdp = &sd; - } - return null_sdp; -} - -/* Initialize global security attributes. - Called from dcrt0.cc (_dll_crt0). */ - -void -init_global_security () -{ - sec_none.nLength = sec_none_nih.nLength = - sec_all.nLength = sec_all_nih.nLength = sizeof (SECURITY_ATTRIBUTES); - sec_none.bInheritHandle = sec_all.bInheritHandle = TRUE; - sec_none_nih.bInheritHandle = sec_all_nih.bInheritHandle = FALSE; - sec_none.lpSecurityDescriptor = sec_none_nih.lpSecurityDescriptor = NULL; - sec_all.lpSecurityDescriptor = sec_all_nih.lpSecurityDescriptor = - get_null_sd (); -} - -bool -sec_acl (PACL acl, bool original, bool admins, PSID sid1, PSID sid2, DWORD access2) -{ - size_t acl_len = MAX_DACL_LEN(5); - LPVOID pAce; - cygpsid psid; - -#ifdef DEBUGGING - if ((unsigned long) acl % 4) - api_fatal ("Incorrectly aligned incoming ACL buffer!"); -#endif - if (!InitializeAcl (acl, acl_len, ACL_REVISION)) - { - debug_printf ("InitializeAcl %E"); - return false; - } - if (sid1) - if (!AddAccessAllowedAce (acl, ACL_REVISION, - GENERIC_ALL, sid1)) - debug_printf ("AddAccessAllowedAce(sid1) %E"); - if (original && (psid = cygheap->user.saved_sid ()) - && psid != sid1 && psid != well_known_system_sid) - if (!AddAccessAllowedAce (acl, ACL_REVISION, - GENERIC_ALL, psid)) - debug_printf ("AddAccessAllowedAce(original) %E"); - if (sid2) - if (!AddAccessAllowedAce (acl, ACL_REVISION, - access2, sid2)) - debug_printf ("AddAccessAllowedAce(sid2) %E"); - if (admins) - if (!AddAccessAllowedAce (acl, ACL_REVISION, - GENERIC_ALL, well_known_admins_sid)) - debug_printf ("AddAccessAllowedAce(admin) %E"); - if (!AddAccessAllowedAce (acl, ACL_REVISION, - GENERIC_ALL, well_known_system_sid)) - debug_printf ("AddAccessAllowedAce(system) %E"); - FindFirstFreeAce (acl, &pAce); - if (pAce) - acl->AclSize = (char *) pAce - (char *) acl; - else - debug_printf ("FindFirstFreeAce %E"); - - return true; -} - -PSECURITY_ATTRIBUTES __stdcall -__sec_user (PVOID sa_buf, PSID sid1, PSID sid2, DWORD access2, BOOL inherit) -{ - PSECURITY_ATTRIBUTES psa = (PSECURITY_ATTRIBUTES) sa_buf; - PSECURITY_DESCRIPTOR psd = (PSECURITY_DESCRIPTOR) - ((char *) sa_buf + sizeof (*psa)); - PACL acl = (PACL) ((char *) sa_buf + sizeof (*psa) + sizeof (*psd)); - -#ifdef DEBUGGING - if ((unsigned long) sa_buf % 4) - api_fatal ("Incorrectly aligned incoming SA buffer!"); -#endif - if (!sec_acl (acl, true, true, sid1, sid2, access2)) - return inherit ? &sec_none : &sec_none_nih; - - if (!InitializeSecurityDescriptor (psd, SECURITY_DESCRIPTOR_REVISION)) - debug_printf ("InitializeSecurityDescriptor %E"); - -/* - * Setting the owner lets the created security attribute not work - * on NT4 SP3 Server. Don't know why, but the function still does - * what it should do also if the owner isn't set. -*/ -#if 0 - if (!SetSecurityDescriptorOwner (psd, sid, FALSE)) - debug_printf ("SetSecurityDescriptorOwner %E"); -#endif - - if (!SetSecurityDescriptorDacl (psd, TRUE, acl, FALSE)) - debug_printf ("SetSecurityDescriptorDacl %E"); - - psa->nLength = sizeof (SECURITY_ATTRIBUTES); - psa->lpSecurityDescriptor = psd; - psa->bInheritHandle = inherit; - return psa; -} - -/* Helper function to create an event security descriptor which only allows - specific access to everyone. Only the creating process has all access - rights. */ - -PSECURITY_DESCRIPTOR -_everyone_sd (void *buf, ACCESS_MASK access) -{ - PSECURITY_DESCRIPTOR psd = (PSECURITY_DESCRIPTOR) buf; - - if (psd) - { - InitializeSecurityDescriptor (psd, SECURITY_DESCRIPTOR_REVISION); - PACL dacl = (PACL) (psd + 1); - InitializeAcl (dacl, MAX_DACL_LEN (1), ACL_REVISION); - if (!AddAccessAllowedAce (dacl, ACL_REVISION, access, - well_known_world_sid)) - { - debug_printf ("AddAccessAllowedAce: %lu", GetLastError ()); - return NULL; - } - LPVOID ace; - if (!FindFirstFreeAce (dacl, &ace)) - { - debug_printf ("FindFirstFreeAce: %lu", GetLastError ()); - return NULL; - } - dacl->AclSize = (char *) ace - (char *) dacl; - SetSecurityDescriptorDacl (psd, TRUE, dacl, FALSE); - } - return psd; -} - diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc deleted file mode 100644 index a8a251297..000000000 --- a/winsup/cygwin/security.cc +++ /dev/null @@ -1,860 +0,0 @@ -/* security.cc: NT file access control functions - - Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009 Red Hat, Inc. - - Originaly written by Gunther Ebert, gunther.ebert@ixos-leipzig.de - Completely rewritten by Corinna Vinschen - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "pinfo.h" -#include "cygheap.h" -#include "ntdll.h" -#include "pwdgrp.h" -#include - -#define ALL_SECURITY_INFORMATION (DACL_SECURITY_INFORMATION \ - | GROUP_SECURITY_INFORMATION \ - | OWNER_SECURITY_INFORMATION) - -LONG -get_file_sd (HANDLE fh, path_conv &pc, security_descriptor &sd) -{ - DWORD error = ERROR_SUCCESS; - int retry = 0; - int res = -1; - - for (; retry < 2; ++retry) - { - if (fh) - { - /* Amazing but true. If you want to know if an ACE is inherited - from the parent object, you can't use the NtQuerySecurityObject - function. In the DACL returned by this functions, the - INHERITED_ACE flag is never set. Only by calling GetSecurityInfo - you get this information. Oh well. */ - PSECURITY_DESCRIPTOR psd; - error = GetSecurityInfo (fh, SE_FILE_OBJECT, ALL_SECURITY_INFORMATION, - NULL, NULL, NULL, NULL, &psd); - if (error == ERROR_SUCCESS) - { - sd = psd; - res = 0; - break; - } - } - if (!retry) - { - OBJECT_ATTRIBUTES attr; - IO_STATUS_BLOCK io; - NTSTATUS status; - - status = NtOpenFile (&fh, READ_CONTROL, - pc.get_object_attr (attr, sec_none_nih), - &io, FILE_SHARE_VALID_FLAGS, - FILE_OPEN_FOR_BACKUP_INTENT); - if (!NT_SUCCESS (status)) - { - fh = NULL; - error = RtlNtStatusToDosError (status); - break; - } - } - } - if (retry && fh) - NtClose (fh); - if (error != ERROR_SUCCESS) - __seterrno_from_win_error (error); - return res; -} - -LONG -set_file_sd (HANDLE fh, path_conv &pc, security_descriptor &sd, bool is_chown) -{ - NTSTATUS status = STATUS_SUCCESS; - int retry = 0; - int res = -1; - - for (; retry < 2; ++retry) - { - if (fh) - { - status = NtSetSecurityObject (fh, - is_chown ? ALL_SECURITY_INFORMATION - : DACL_SECURITY_INFORMATION, - sd); - if (NT_SUCCESS (status)) - { - res = 0; - break; - } - } - if (!retry) - { - OBJECT_ATTRIBUTES attr; - IO_STATUS_BLOCK io; - status = NtOpenFile (&fh, (is_chown ? WRITE_OWNER : 0) | WRITE_DAC, - pc.get_object_attr (attr, sec_none_nih), - &io, FILE_SHARE_VALID_FLAGS, - FILE_OPEN_FOR_BACKUP_INTENT); - if (!NT_SUCCESS (status)) - { - fh = NULL; - break; - } - } - } - if (retry && fh) - NtClose (fh); - if (!NT_SUCCESS (status)) - __seterrno_from_nt_status (status); - return res; -} - -static void -get_attribute_from_acl (mode_t *attribute, PACL acl, PSID owner_sid, - PSID group_sid, bool grp_member) -{ - ACCESS_ALLOWED_ACE *ace; - int allow = 0; - int deny = 0; - int *flags, *anti; - - for (DWORD i = 0; i < acl->AceCount; ++i) - { - if (!GetAce (acl, i, (PVOID *) &ace)) - continue; - if (ace->Header.AceFlags & INHERIT_ONLY_ACE) - continue; - switch (ace->Header.AceType) - { - case ACCESS_ALLOWED_ACE_TYPE: - flags = &allow; - anti = &deny; - break; - case ACCESS_DENIED_ACE_TYPE: - flags = &deny; - anti = &allow; - break; - default: - continue; - } - - cygpsid ace_sid ((PSID) &ace->SidStart); - if (ace_sid == well_known_world_sid) - { - if (ace->Mask & FILE_READ_BITS) - *flags |= ((!(*anti & S_IROTH)) ? S_IROTH : 0) - | ((!(*anti & S_IRGRP)) ? S_IRGRP : 0) - | ((!(*anti & S_IRUSR)) ? S_IRUSR : 0); - if (ace->Mask & FILE_WRITE_BITS) - *flags |= ((!(*anti & S_IWOTH)) ? S_IWOTH : 0) - | ((!(*anti & S_IWGRP)) ? S_IWGRP : 0) - | ((!(*anti & S_IWUSR)) ? S_IWUSR : 0); - if (ace->Mask & FILE_EXEC_BITS) - *flags |= ((!(*anti & S_IXOTH)) ? S_IXOTH : 0) - | ((!(*anti & S_IXGRP)) ? S_IXGRP : 0) - | ((!(*anti & S_IXUSR)) ? S_IXUSR : 0); - if ((S_ISDIR (*attribute)) && - (ace->Mask & (FILE_WRITE_DATA | FILE_EXECUTE | FILE_DELETE_CHILD)) - == (FILE_WRITE_DATA | FILE_EXECUTE)) - *flags |= S_ISVTX; - } - else if (ace_sid == well_known_null_sid) - { - /* Read SUID, SGID and VTX bits from NULL ACE. */ - if (ace->Mask & FILE_READ_DATA) - *flags |= S_ISVTX; - if (ace->Mask & FILE_WRITE_DATA) - *flags |= S_ISGID; - if (ace->Mask & FILE_APPEND_DATA) - *flags |= S_ISUID; - } - else if (ace_sid == owner_sid) - { - if (ace->Mask & FILE_READ_BITS) - *flags |= ((!(*anti & S_IRUSR)) ? S_IRUSR : 0); - if (ace->Mask & FILE_WRITE_BITS) - *flags |= ((!(*anti & S_IWUSR)) ? S_IWUSR : 0); - if (ace->Mask & FILE_EXEC_BITS) - *flags |= ((!(*anti & S_IXUSR)) ? S_IXUSR : 0); - } - else if (ace_sid == group_sid) - { - if (ace->Mask & FILE_READ_BITS) - *flags |= ((!(*anti & S_IRGRP)) ? S_IRGRP : 0) - | ((grp_member && !(*anti & S_IRUSR)) ? S_IRUSR : 0); - if (ace->Mask & FILE_WRITE_BITS) - *flags |= ((!(*anti & S_IWGRP)) ? S_IWGRP : 0) - | ((grp_member && !(*anti & S_IWUSR)) ? S_IWUSR : 0); - if (ace->Mask & FILE_EXEC_BITS) - *flags |= ((!(*anti & S_IXGRP)) ? S_IXGRP : 0) - | ((grp_member && !(*anti & S_IXUSR)) ? S_IXUSR : 0); - } - } - *attribute &= ~(S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX | S_ISGID | S_ISUID); - if (owner_sid && group_sid && EqualSid (owner_sid, group_sid) - /* FIXME: temporary exception for /var/empty */ - && well_known_system_sid != group_sid) - { - allow &= ~(S_IRGRP | S_IWGRP | S_IXGRP); - allow |= (((allow & S_IRUSR) ? S_IRGRP : 0) - | ((allow & S_IWUSR) ? S_IWGRP : 0) - | ((allow & S_IXUSR) ? S_IXGRP : 0)); - } - *attribute |= allow; -} - -static void -get_info_from_sd (PSECURITY_DESCRIPTOR psd, mode_t *attribute, - __uid32_t *uidret, __gid32_t *gidret) -{ - if (!psd) - { - /* If reading the security descriptor failed, treat the object - as unreadable. */ - if (attribute) - *attribute &= ~(S_IRWXU | S_IRWXG | S_IRWXO); - if (uidret) - *uidret = ILLEGAL_UID; - if (gidret) - *gidret = ILLEGAL_GID; - return; - } - - cygpsid owner_sid; - cygpsid group_sid; - BOOL dummy; - - if (!GetSecurityDescriptorOwner (psd, (PSID *) &owner_sid, &dummy)) - debug_printf ("GetSecurityDescriptorOwner %E"); - if (!GetSecurityDescriptorGroup (psd, (PSID *) &group_sid, &dummy)) - debug_printf ("GetSecurityDescriptorGroup %E"); - - __uid32_t uid; - __gid32_t gid; - bool grp_member = get_sids_info (owner_sid, group_sid, &uid, &gid); - if (uidret) - *uidret = uid; - if (gidret) - *gidret = gid; - - if (!attribute) - { - syscall_printf ("uid %d, gid %d", uid, gid); - return; - } - - PACL acl; - BOOL acl_exists; - - if (!GetSecurityDescriptorDacl (psd, &acl_exists, &acl, &dummy)) - { - __seterrno (); - debug_printf ("GetSecurityDescriptorDacl %E"); - *attribute &= ~(S_IRWXU | S_IRWXG | S_IRWXO); - } - else if (!acl_exists || !acl) - *attribute |= S_IRWXU | S_IRWXG | S_IRWXO; - else - get_attribute_from_acl (attribute, acl, owner_sid, group_sid, grp_member); - - syscall_printf ("%sACL %x, uid %d, gid %d", - (!acl_exists || !acl)?"NO ":"", *attribute, uid, gid); -} - -static int -get_reg_sd (HANDLE handle, security_descriptor &sd_ret) -{ - LONG ret; - DWORD len = 0; - - ret = RegGetKeySecurity ((HKEY) handle, ALL_SECURITY_INFORMATION, - sd_ret, &len); - if (ret == ERROR_INSUFFICIENT_BUFFER) - { - if (!sd_ret.malloc (len)) - set_errno (ENOMEM); - else - ret = RegGetKeySecurity ((HKEY) handle, ALL_SECURITY_INFORMATION, - sd_ret, &len); - } - if (ret != ERROR_SUCCESS) - { - __seterrno (); - return -1; - } - return 0; -} - -int -get_reg_attribute (HKEY hkey, mode_t *attribute, __uid32_t *uidret, - __gid32_t *gidret) -{ - security_descriptor sd; - - if (!get_reg_sd (hkey, sd)) - { - get_info_from_sd (sd, attribute, uidret, gidret); - return 0; - } - /* The entries are already set to default values */ - return -1; -} - -int -get_file_attribute (HANDLE handle, path_conv &pc, - mode_t *attribute, __uid32_t *uidret, __gid32_t *gidret) -{ - if (pc.has_acls ()) - { - security_descriptor sd; - - if (!get_file_sd (handle, pc, sd)) - { - get_info_from_sd (sd, attribute, uidret, gidret); - return 0; - } - else - { - if (uidret) - *uidret = ILLEGAL_UID; - if (gidret) - *gidret = ILLEGAL_GID; - - return -1; - } - } - - if (uidret) - *uidret = myself->uid; - if (gidret) - *gidret = myself->gid; - - return -1; -} - -bool -add_access_allowed_ace (PACL acl, int offset, DWORD attributes, - PSID sid, size_t &len_add, DWORD inherit) -{ - if (!AddAccessAllowedAce (acl, ACL_REVISION, attributes, sid)) - { - __seterrno (); - return false; - } - ACCESS_ALLOWED_ACE *ace; - if (inherit && GetAce (acl, offset, (PVOID *) &ace)) - ace->Header.AceFlags |= inherit; - len_add += sizeof (ACCESS_ALLOWED_ACE) - sizeof (DWORD) + GetLengthSid (sid); - return true; -} - -bool -add_access_denied_ace (PACL acl, int offset, DWORD attributes, - PSID sid, size_t &len_add, DWORD inherit) -{ - if (!AddAccessDeniedAce (acl, ACL_REVISION, attributes, sid)) - { - __seterrno (); - return false; - } - ACCESS_DENIED_ACE *ace; - if (inherit && GetAce (acl, offset, (PVOID *) &ace)) - ace->Header.AceFlags |= inherit; - len_add += sizeof (ACCESS_DENIED_ACE) - sizeof (DWORD) + GetLengthSid (sid); - return true; -} - -static PSECURITY_DESCRIPTOR -alloc_sd (path_conv &pc, __uid32_t uid, __gid32_t gid, int attribute, - security_descriptor &sd_ret) -{ - BOOL dummy; - - /* NOTE: If the high bit of attribute is set, we have just created - a file or directory. See below for an explanation. */ - - debug_printf("uid %d, gid %d, attribute %x", uid, gid, attribute); - - /* Get owner and group from current security descriptor. */ - PSID cur_owner_sid = NULL; - PSID cur_group_sid = NULL; - if (!GetSecurityDescriptorOwner (sd_ret, &cur_owner_sid, &dummy)) - debug_printf ("GetSecurityDescriptorOwner %E"); - if (!GetSecurityDescriptorGroup (sd_ret, &cur_group_sid, &dummy)) - debug_printf ("GetSecurityDescriptorGroup %E"); - - /* Get SID of owner. */ - cygsid owner_sid; - /* Check for current user first */ - if (uid == myself->uid) - owner_sid = cygheap->user.sid (); - else if (uid == ILLEGAL_UID) - owner_sid = cur_owner_sid; - else if (!owner_sid.getfrompw (internal_getpwuid (uid))) - { - set_errno (EINVAL); - return NULL; - } - owner_sid.debug_print ("alloc_sd: owner SID ="); - - /* Get SID of new group. */ - cygsid group_sid; - /* Check for current user first */ - if (gid == myself->gid) - group_sid = cygheap->user.groups.pgsid; - else if (gid == ILLEGAL_GID) - group_sid = cur_group_sid; - else if (!group_sid.getfromgr (internal_getgrgid (gid))) - { - set_errno (EINVAL); - return NULL; - } - group_sid.debug_print ("alloc_sd: group SID ="); - - /* Initialize local security descriptor. */ - SECURITY_DESCRIPTOR sd; - if (!InitializeSecurityDescriptor (&sd, SECURITY_DESCRIPTOR_REVISION)) - { - __seterrno (); - return NULL; - } - - /* We set the SE_DACL_PROTECTED flag here to prevent the DACL from being - * modified by inheritable ACEs. This flag is available since Win2K. */ - if (wincap.has_dacl_protect ()) - sd.Control |= SE_DACL_PROTECTED; - - /* Create owner for local security descriptor. */ - if (!SetSecurityDescriptorOwner (&sd, owner_sid, FALSE)) - { - __seterrno (); - return NULL; - } - - /* Create group for local security descriptor. */ - if (!SetSecurityDescriptorGroup (&sd, group_sid, FALSE)) - { - __seterrno (); - return NULL; - } - - /* Initialize local access control list. */ - PACL acl = (PACL) alloca (3072); - if (!InitializeAcl (acl, 3072, ACL_REVISION)) - { - __seterrno (); - return NULL; - } - - /* From here fill ACL. */ - size_t acl_len = sizeof (ACL); - int ace_off = 0; - - /* Construct allow attribute for owner. - Don't set FILE_READ/WRITE_ATTRIBUTES unconditionally on Samba, otherwise - it enforces read permissions. Same for other's below. */ - DWORD owner_allow = STANDARD_RIGHTS_ALL - | (pc.fs_is_samba () - ? 0 : (FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES)); - if (attribute & S_IRUSR) - owner_allow |= FILE_GENERIC_READ; - if (attribute & S_IWUSR) - owner_allow |= FILE_GENERIC_WRITE; - if (attribute & S_IXUSR) - owner_allow |= FILE_GENERIC_EXECUTE & ~FILE_READ_ATTRIBUTES; - if (S_ISDIR (attribute) - && (attribute & (S_IWUSR | S_IXUSR)) == (S_IWUSR | S_IXUSR)) - owner_allow |= FILE_DELETE_CHILD; - - /* Construct allow attribute for group. */ - DWORD group_allow = STANDARD_RIGHTS_READ - | (pc.fs_is_samba () ? 0 : FILE_READ_ATTRIBUTES); - if (attribute & S_IRGRP) - group_allow |= FILE_GENERIC_READ; - if (attribute & S_IWGRP) - group_allow |= FILE_GENERIC_WRITE; - if (attribute & S_IXGRP) - group_allow |= FILE_GENERIC_EXECUTE & ~FILE_READ_ATTRIBUTES; - if (S_ISDIR (attribute) - && (attribute & (S_IWGRP | S_IXGRP)) == (S_IWGRP | S_IXGRP) - && !(attribute & S_ISVTX)) - group_allow |= FILE_DELETE_CHILD; - - /* Construct allow attribute for everyone. */ - DWORD other_allow = STANDARD_RIGHTS_READ - | (pc.fs_is_samba () ? 0 : FILE_READ_ATTRIBUTES); - if (attribute & S_IROTH) - other_allow |= FILE_GENERIC_READ; - if (attribute & S_IWOTH) - other_allow |= FILE_GENERIC_WRITE; - if (attribute & S_IXOTH) - other_allow |= FILE_GENERIC_EXECUTE & ~FILE_READ_ATTRIBUTES; - if (S_ISDIR (attribute) - && (attribute & (S_IWOTH | S_IXOTH)) == (S_IWOTH | S_IXOTH) - && !(attribute & S_ISVTX)) - other_allow |= FILE_DELETE_CHILD; - - /* Construct SUID, SGID and VTX bits in NULL ACE. */ - DWORD null_allow = 0L; - if (attribute & (S_ISUID | S_ISGID | S_ISVTX)) - { - if (attribute & S_ISUID) - null_allow |= FILE_APPEND_DATA; - if (attribute & S_ISGID) - null_allow |= FILE_WRITE_DATA; - if (attribute & S_ISVTX) - null_allow |= FILE_READ_DATA; - } - - /* Add owner and group permissions if SIDs are equal - and construct deny attributes for group and owner. */ - bool isownergroup; - if ((isownergroup = (owner_sid == group_sid))) - owner_allow |= group_allow; - - DWORD owner_deny = ~owner_allow & (group_allow | other_allow); - owner_deny &= ~(STANDARD_RIGHTS_READ - | FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES); - - DWORD group_deny = ~group_allow & other_allow; - group_deny &= ~(STANDARD_RIGHTS_READ | FILE_READ_ATTRIBUTES); - - /* Set deny ACE for owner. */ - if (owner_deny - && !add_access_denied_ace (acl, ace_off++, owner_deny, - owner_sid, acl_len, NO_INHERITANCE)) - return NULL; - /* Set deny ACE for group here to respect the canonical order, - if this does not impact owner */ - if (group_deny && !(group_deny & owner_allow) && !isownergroup - && !add_access_denied_ace (acl, ace_off++, group_deny, - group_sid, acl_len, NO_INHERITANCE)) - return NULL; - /* Set allow ACE for owner. */ - if (!add_access_allowed_ace (acl, ace_off++, owner_allow, - owner_sid, acl_len, NO_INHERITANCE)) - return NULL; - /* Set deny ACE for group, if still needed. */ - if (group_deny & owner_allow && !isownergroup - && !add_access_denied_ace (acl, ace_off++, group_deny, - group_sid, acl_len, NO_INHERITANCE)) - return NULL; - /* Set allow ACE for group. */ - if (!isownergroup - && !add_access_allowed_ace (acl, ace_off++, group_allow, - group_sid, acl_len, NO_INHERITANCE)) - return NULL; - - /* Set allow ACE for everyone. */ - if (!add_access_allowed_ace (acl, ace_off++, other_allow, - well_known_world_sid, acl_len, NO_INHERITANCE)) - return NULL; - /* Set null ACE for special bits. */ - if (null_allow - && !add_access_allowed_ace (acl, ace_off++, null_allow, - well_known_null_sid, acl_len, NO_INHERITANCE)) - return NULL; - - /* Fill ACL with unrelated ACEs from current security descriptor. */ - PACL oacl; - BOOL acl_exists = FALSE; - ACCESS_ALLOWED_ACE *ace; - if (GetSecurityDescriptorDacl (sd_ret, &acl_exists, &oacl, &dummy) - && acl_exists && oacl) - for (DWORD i = 0; i < oacl->AceCount; ++i) - if (GetAce (oacl, i, (PVOID *) &ace)) - { - cygpsid ace_sid ((PSID) &ace->SidStart); - - /* Check for related ACEs. */ - if (ace_sid == well_known_null_sid) - continue; - if ((ace_sid == cur_owner_sid) - || (ace_sid == owner_sid) - || (ace_sid == cur_group_sid) - || (ace_sid == group_sid) - || (ace_sid == well_known_world_sid)) - { - if (ace->Header.AceFlags - & (CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE)) - ace->Header.AceFlags |= INHERIT_ONLY_ACE; - else - continue; - } - else if (attribute & S_JUSTCREATED) - { - /* Since files and dirs are created with a NULL descriptor, - inheritence rules kick in. If no inheritable entries exist - in the parent object, Windows will create entries from the - user token's default DACL in the file DACL. These entries - are not desired and we drop them silently. */ - if (!(ace->Header.AceFlags & INHERITED_ACE)) - continue; - /* Remove the INHERITED_ACE flag since on POSIX systems - inheritance is settled when the file has been created. - This also avoids error messages in Windows Explorer when - opening a file's security tab. Explorer complains if - inheritable ACEs are preceding non-inheritable ACEs. */ - ace->Header.AceFlags &= ~INHERITED_ACE; - } - /* - * Add unrelated ACCESS_DENIED_ACE to the beginning but - * behind the owner_deny, ACCESS_ALLOWED_ACE to the end. - * FIXME: this would break the order of the inherit-only ACEs - */ - if (!AddAce (acl, ACL_REVISION, - ace->Header.AceType == ACCESS_DENIED_ACE_TYPE - ? (owner_deny ? 1 : 0) : MAXDWORD, - (LPVOID) ace, ace->Header.AceSize)) - { - __seterrno (); - return NULL; - } - ace_off++; - acl_len += ace->Header.AceSize; - } - - /* Construct appropriate inherit attribute for new directories */ - if (S_ISDIR (attribute) && (attribute & S_JUSTCREATED)) - { - const DWORD inherit = CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE - | INHERIT_ONLY_ACE; -#if 0 /* FIXME: Not done currently as this breaks the canonical order */ - /* Set deny ACE for owner. */ - if (owner_deny - && !add_access_denied_ace (acl, ace_off++, owner_deny, - well_known_creator_owner_sid, acl_len, inherit)) - return NULL; - /* Set deny ACE for group here to respect the canonical order, - if this does not impact owner */ - if (group_deny && !(group_deny & owner_allow) - && !add_access_denied_ace (acl, ace_off++, group_deny, - well_known_creator_group_sid, acl_len, inherit)) - return NULL; -#endif - /* Set allow ACE for owner. */ - if (!add_access_allowed_ace (acl, ace_off++, owner_allow, - well_known_creator_owner_sid, acl_len, - inherit)) - return NULL; -#if 0 /* FIXME: Not done currently as this breaks the canonical order and - won't be preserved on chown and chmod */ - /* Set deny ACE for group, conflicting with owner_allow. */ - if (group_deny & owner_allow - && !add_access_denied_ace (acl, ace_off++, group_deny, - well_known_creator_group_sid, acl_len, inherit)) - return NULL; -#endif - /* Set allow ACE for group. */ - if (!add_access_allowed_ace (acl, ace_off++, group_allow, - well_known_creator_group_sid, acl_len, - inherit)) - return NULL; - /* Set allow ACE for everyone. */ - if (!add_access_allowed_ace (acl, ace_off++, other_allow, - well_known_world_sid, acl_len, inherit)) - return NULL; - } - - /* Set AclSize to computed value. */ - acl->AclSize = acl_len; - debug_printf ("ACL-Size: %d", acl_len); - - /* Create DACL for local security descriptor. */ - if (!SetSecurityDescriptorDacl (&sd, TRUE, acl, FALSE)) - { - __seterrno (); - return NULL; - } - - /* Make self relative security descriptor. */ - DWORD sd_size = 0; - MakeSelfRelativeSD (&sd, sd_ret, &sd_size); - if (sd_size <= 0) - { - __seterrno (); - return NULL; - } - if (!sd_ret.malloc (sd_size)) - { - set_errno (ENOMEM); - return NULL; - } - if (!MakeSelfRelativeSD (&sd, sd_ret, &sd_size)) - { - __seterrno (); - return NULL; - } - debug_printf ("Created SD-Size: %u", sd_ret.size ()); - - return sd_ret; -} - -void -set_security_attribute (path_conv &pc, int attribute, PSECURITY_ATTRIBUTES psa, - security_descriptor &sd) -{ - psa->lpSecurityDescriptor = sd.malloc (SECURITY_DESCRIPTOR_MIN_LENGTH); - InitializeSecurityDescriptor ((PSECURITY_DESCRIPTOR)psa->lpSecurityDescriptor, - SECURITY_DESCRIPTOR_REVISION); - psa->lpSecurityDescriptor = alloc_sd (pc, geteuid32 (), getegid32 (), - attribute, sd); -} - -int -set_file_attribute (HANDLE handle, path_conv &pc, - __uid32_t uid, __gid32_t gid, int attribute) -{ - int ret = -1; - - if (pc.has_acls ()) - { - security_descriptor sd; - - if (!get_file_sd (handle, pc, sd) - && alloc_sd (pc, uid, gid, attribute, sd)) - ret = set_file_sd (handle, pc, sd, - uid != ILLEGAL_UID || gid != ILLEGAL_GID); - } - else - ret = 0; - syscall_printf ("%d = set_file_attribute (%S, %d, %d, %p)", - ret, pc.get_nt_native_path (), uid, gid, attribute); - return ret; -} - -static int -check_access (security_descriptor &sd, GENERIC_MAPPING &mapping, - DWORD desired, int flags, bool effective) -{ - int ret = -1; - BOOL status; - DWORD granted; - DWORD plen = sizeof (PRIVILEGE_SET) + 3 * sizeof (LUID_AND_ATTRIBUTES); - PPRIVILEGE_SET pset = (PPRIVILEGE_SET) alloca (plen); - HANDLE tok = ((effective && cygheap->user.issetuid ()) - ? cygheap->user.imp_token () - : hProcImpToken); - - if (!tok && !DuplicateTokenEx (hProcToken, MAXIMUM_ALLOWED, NULL, - SecurityImpersonation, TokenImpersonation, - &hProcImpToken)) -#ifdef DEBUGGING - system_printf ("DuplicateTokenEx failed, %E"); -#else - syscall_printf ("DuplicateTokenEx failed, %E"); -#endif - else - tok = hProcImpToken; - - if (!AccessCheck (sd, tok, desired, &mapping, pset, &plen, &granted, &status)) - __seterrno (); - else if (!status) - { - /* CV, 2006-10-16: Now, that's really weird. Imagine a user who has no - standard access to a file, but who has backup and restore privileges - and these privileges are enabled in the access token. One would - expect that the AccessCheck function takes this into consideration - when returning the access status. Otherwise, why bother with the - pset parameter, right? - But not so. AccessCheck actually returns a status of "false" here, - even though opening a file with backup resp. restore intent - naturally succeeds for this user. This definitely spoils the results - of access(2) for administrative users or the SYSTEM account. So, in - case the access check fails, another check against the user's - backup/restore privileges has to be made. Sigh. */ - int granted_flags = 0; - if (flags & R_OK) - { - pset->PrivilegeCount = 1; - pset->Control = 0; - pset->Privilege[0].Luid.HighPart = 0L; - pset->Privilege[0].Luid.LowPart = SE_BACKUP_PRIVILEGE; - pset->Privilege[0].Attributes = 0; - if (PrivilegeCheck (tok, pset, &status) && status) - granted_flags |= R_OK; - } - if (flags & W_OK) - { - pset->PrivilegeCount = 1; - pset->Control = 0; - pset->Privilege[0].Luid.HighPart = 0L; - pset->Privilege[0].Luid.LowPart = SE_RESTORE_PRIVILEGE; - pset->Privilege[0].Attributes = 0; - if (PrivilegeCheck (tok, pset, &status) && status) - granted_flags |= W_OK; - } - if (granted_flags == flags) - ret = 0; - else - set_errno (EACCES); - } - else - ret = 0; - return ret; -} - -int -check_file_access (path_conv &pc, int flags, bool effective) -{ - security_descriptor sd; - int ret = -1; - static GENERIC_MAPPING NO_COPY mapping = { FILE_GENERIC_READ, - FILE_GENERIC_WRITE, - FILE_GENERIC_EXECUTE, - FILE_ALL_ACCESS }; - DWORD desired = 0; - if (flags & R_OK) - desired |= FILE_READ_DATA; - if (flags & W_OK) - desired |= FILE_WRITE_DATA; - if (flags & X_OK) - desired |= FILE_EXECUTE; - if (!get_file_sd (NULL, pc, sd)) - ret = check_access (sd, mapping, desired, flags, effective); - debug_printf ("flags %x, ret %d", flags, ret); - return ret; -} - -int -check_registry_access (HANDLE hdl, int flags, bool effective) -{ - security_descriptor sd; - int ret = -1; - static GENERIC_MAPPING NO_COPY mapping = { KEY_READ, - KEY_WRITE, - KEY_EXECUTE, - KEY_ALL_ACCESS }; - DWORD desired = 0; - if (flags & R_OK) - desired |= KEY_ENUMERATE_SUB_KEYS; - if (flags & W_OK) - desired |= KEY_SET_VALUE; - if (flags & X_OK) - desired |= KEY_QUERY_VALUE; - if (!get_reg_sd (hdl, sd)) - ret = check_access (sd, mapping, desired, flags, effective); - /* As long as we can't write the registry... */ - if (flags & W_OK) - { - set_errno (EROFS); - ret = -1; - } - debug_printf ("flags %x, ret %d", flags, ret); - return ret; -} diff --git a/winsup/cygwin/security.h b/winsup/cygwin/security.h deleted file mode 100644 index d239d0714..000000000 --- a/winsup/cygwin/security.h +++ /dev/null @@ -1,467 +0,0 @@ -/* security.h: security declarations - - Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, - 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SECURITY_H -#define _SECURITY_H - -#include - -/* Special file attribute set, for instance, in open() and mkdir() to - flag that a file has just been created. Used in alloc_sd, see there. */ -#define S_JUSTCREATED 0x80000000 - -#define DEFAULT_UID DOMAIN_USER_RID_ADMIN -#define UNKNOWN_UID 400 /* Non conflicting number */ -#define UNKNOWN_GID 401 - -#define MAX_SID_LEN 40 -#define MAX_DACL_LEN(n) (sizeof (ACL) \ - + (n) * (sizeof (ACCESS_ALLOWED_ACE) - sizeof (DWORD) + MAX_SID_LEN)) -#define SD_MIN_SIZE (sizeof (SECURITY_DESCRIPTOR) + MAX_DACL_LEN (1)) -#define ACL_DEFAULT_SIZE 3072 -#define NO_SID ((PSID)NULL) - -#ifndef SE_CREATE_TOKEN_PRIVILEGE -#define SE_CREATE_TOKEN_PRIVILEGE 2UL -#define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE 3UL -#define SE_LOCK_MEMORY_PRIVILEGE 4UL -#define SE_INCREASE_QUOTA_PRIVILEGE 5UL -#define SE_MACHINE_ACCOUNT_PRIVILEGE 6UL -#define SE_TCB_PRIVILEGE 7UL -#define SE_SECURITY_PRIVILEGE 8UL -#define SE_TAKE_OWNERSHIP_PRIVILEGE 9UL -#define SE_LOAD_DRIVER_PRIVILEGE 10UL -#define SE_SYSTEM_PROFILE_PRIVILEGE 11UL -#define SE_SYSTEMTIME_PRIVILEGE 12UL -#define SE_PROF_SINGLE_PROCESS_PRIVILEGE 13UL -#define SE_INC_BASE_PRIORITY_PRIVILEGE 14UL -#define SE_CREATE_PAGEFILE_PRIVILEGE 15UL -#define SE_CREATE_PERMANENT_PRIVILEGE 16UL -#define SE_BACKUP_PRIVILEGE 17UL -#define SE_RESTORE_PRIVILEGE 18UL -#define SE_SHUTDOWN_PRIVILEGE 19UL -#define SE_DEBUG_PRIVILEGE 20UL -#define SE_AUDIT_PRIVILEGE 21UL -#define SE_SYSTEM_ENVIRONMENT_PRIVILEGE 22UL -#define SE_CHANGE_NOTIFY_PRIVILEGE 23UL -#define SE_REMOTE_SHUTDOWN_PRIVILEGE 24UL -/* Starting with Windows 2000 */ -#define SE_UNDOCK_PRIVILEGE 25UL -#define SE_SYNC_AGENT_PRIVILEGE 26UL -#define SE_ENABLE_DELEGATION_PRIVILEGE 27UL -#define SE_MANAGE_VOLUME_PRIVILEGE 28UL -/* Starting with Windows 2000 SP4, XP SP2, 2003 Server */ -#define SE_IMPERSONATE_PRIVILEGE 29UL -#define SE_CREATE_GLOBAL_PRIVILEGE 30UL -/* Starting with Vista */ -#define SE_TRUSTED_CREDMAN_ACCESS_PRIVILEGE 31UL -#define SE_RELABEL_PRIVILEGE 32UL -#define SE_INCREASE_WORKING_SET_PRIVILEGE 33UL -#define SE_TIME_ZONE_PRIVILEGE 34UL -#define SE_CREATE_SYMBOLIC_LINK_PRIVILEGE 35UL - -#define SE_MAX_WELL_KNOWN_PRIVILEGE SE_CREATE_SYMBOLIC_LINK_PRIVILEGE - -#endif /* ! SE_CREATE_TOKEN_PRIVILEGE */ - -/* Added for debugging purposes. */ -typedef struct { - BYTE Revision; - BYTE SubAuthorityCount; - SID_IDENTIFIER_AUTHORITY IdentifierAuthority; - DWORD SubAuthority[8]; -} DBGSID, *PDBGSID; - -/* Macro to define variable length SID structures */ -#define MKSID(name, comment, authority, count, rid...) \ -static NO_COPY struct { \ - BYTE Revision; \ - BYTE SubAuthorityCount; \ - SID_IDENTIFIER_AUTHORITY IdentifierAuthority; \ - DWORD SubAuthority[count]; \ -} name##_struct = { SID_REVISION, count, {authority}, {rid}}; \ -cygpsid NO_COPY name = (PSID) &name##_struct; - -#define FILE_READ_BITS (FILE_READ_DATA | GENERIC_READ | GENERIC_ALL) -#define FILE_WRITE_BITS (FILE_WRITE_DATA | GENERIC_WRITE | GENERIC_ALL) -#define FILE_EXEC_BITS (FILE_EXECUTE | GENERIC_EXECUTE | GENERIC_ALL) - -class cygpsid { -protected: - PSID psid; -public: - cygpsid () {} - cygpsid (PSID nsid) { psid = nsid; } - operator PSID () const { return psid; } - const PSID operator= (PSID nsid) { return psid = nsid;} - __uid32_t get_id (BOOL search_grp, int *type = NULL); - int get_uid () { return get_id (FALSE); } - int get_gid () { return get_id (TRUE); } - - PWCHAR string (PWCHAR nsidstr) const; - char *string (char *nsidstr) const; - - bool operator== (const PSID nsid) const - { - if (!psid || !nsid) - return nsid == psid; - return EqualSid (psid, nsid); - } - bool operator!= (const PSID nsid) const - { return !(*this == nsid); } - bool operator== (const char *nsidstr) const; - bool operator!= (const char *nsidstr) const - { return !(*this == nsidstr); } - - void debug_print (const char *prefix = NULL) const - { - char buf[256] __attribute__ ((unused)); - debug_printf ("%s %s", prefix ?: "", string (buf) ?: "NULL"); - } -}; - -class cygsid : public cygpsid { - char sbuf[MAX_SID_LEN]; - bool well_known_sid; - - const PSID getfromstr (const char *nsidstr, bool well_known); - PSID get_sid (DWORD s, DWORD cnt, DWORD *r, bool well_known); - - inline const PSID assign (const PSID nsid, bool well_known) - { - if (!nsid) - psid = NO_SID; - else - { - psid = (PSID) sbuf; - CopySid (MAX_SID_LEN, psid, nsid); - well_known_sid = well_known; - } - return psid; - } - -public: - inline operator const PSID () { return psid; } - inline bool is_well_known_sid () { return well_known_sid; } - - /* Both, = and *= are assignment operators. = creates a "normal" SID, - *= marks the SID as being a well-known SID. This difference is - important when creating a SID list for LSA authentication. */ - inline const PSID operator= (cygsid &nsid) - { return assign (nsid, nsid.well_known_sid); } - inline const PSID operator= (const PSID nsid) - { return assign (nsid, false); } - inline const PSID operator= (const char *nsidstr) - { return getfromstr (nsidstr, false); } - inline const PSID operator*= (cygsid &nsid) - { return assign (nsid, true); } - inline const PSID operator*= (const PSID nsid) - { return assign (nsid, true); } - inline const PSID operator*= (const char *nsidstr) - { return getfromstr (nsidstr, true); } - - inline cygsid () : cygpsid ((PSID) sbuf), well_known_sid (false) {} - inline cygsid (const PSID nsid) { *this = nsid; } - inline cygsid (const char *nstrsid) { *this = nstrsid; } - - inline PSID set () { return psid = (PSID) sbuf; } - - BOOL getfrompw (const struct passwd *pw); - BOOL getfromgr (const struct __group32 *gr); - - void debug_print (const char *prefix = NULL) const - { - char buf[256] __attribute__ ((unused)); - debug_printf ("%s %s%s", prefix ?: "", string (buf) ?: "NULL", well_known_sid ? " (*)" : " (+)"); - } -}; - -typedef enum { cygsidlist_empty, cygsidlist_alloc, cygsidlist_auto } cygsidlist_type; -class cygsidlist { - int maxcnt; - int cnt; - - BOOL add (const PSID nsi, bool well_known); /* Only with auto for now */ - -public: - cygsid *sids; - cygsidlist_type type; - - cygsidlist (cygsidlist_type t, int m) - : maxcnt (m), cnt (0), type (t) - { - if (t == cygsidlist_alloc) - sids = alloc_sids (m); - else - sids = new cygsid [m]; - } - ~cygsidlist () { if (type == cygsidlist_auto) delete [] sids; } - - BOOL addfromgr (struct __group32 *gr) /* Only with alloc */ - { return sids[cnt].getfromgr (gr) && ++cnt; } - - /* += adds a "normal" SID, *= adds a well-known SID. See comment in class - cygsid above. */ - BOOL operator+= (cygsid &si) { return add ((PSID) si, false); } - BOOL operator+= (const char *sidstr) { cygsid nsi (sidstr); - return add ((PSID) nsi, false); } - BOOL operator+= (const PSID psid) { return add (psid, false); } - BOOL operator*= (cygsid &si) { return add ((PSID) si, true); } - BOOL operator*= (const char *sidstr) { cygsid nsi (sidstr); - return add ((PSID) nsi, true); } - BOOL operator*= (const PSID psid) { return add (psid, true); } - - void count (int ncnt) - { cnt = ncnt; } - int count () const { return cnt; } - int non_well_known_count () const - { - int wcnt = 0; - for (int i = 0; i < cnt; ++i) - if (!sids[i].is_well_known_sid ()) - ++wcnt; - return wcnt; - } - - int position (const PSID sid) const - { - for (int i = 0; i < cnt; ++i) - if (sids[i] == sid) - return i; - return -1; - } - - int next_non_well_known_sid (int idx) - { - while (++idx < cnt) - if (!sids[idx].is_well_known_sid ()) - return idx; - return -1; - } - BOOL contains (const PSID sid) const { return position (sid) >= 0; } - cygsid *alloc_sids (int n); - void free_sids (); - void debug_print (const char *prefix = NULL) const - { - debug_printf ("-- begin sidlist ---"); - if (!cnt) - debug_printf ("No elements"); - for (int i = 0; i < cnt; ++i) - sids[i].debug_print (prefix); - debug_printf ("-- ende sidlist ---"); - } -}; - -/* Wrapper class to allow simple deleting of buffer space allocated - by read_sd() */ -class security_descriptor { -protected: - PSECURITY_DESCRIPTOR psd; - DWORD sd_size; -public: - security_descriptor () : psd (NULL), sd_size (0) {} - ~security_descriptor () { free (); } - - PSECURITY_DESCRIPTOR malloc (size_t nsize); - PSECURITY_DESCRIPTOR realloc (size_t nsize); - void free (); - - inline DWORD size () const { return sd_size; } - inline DWORD copy (void *buf, DWORD buf_size) const { - if (buf_size < size ()) - return sd_size; - memcpy (buf, psd, sd_size); - return 0; - } - inline operator const PSECURITY_DESCRIPTOR () { return psd; } - inline operator PSECURITY_DESCRIPTOR *() { return &psd; } - inline void operator =(PSECURITY_DESCRIPTOR nsd) { psd = nsd; } -}; - -class user_groups { -public: - cygsid pgsid; - cygsidlist sgsids; - BOOL ischanged; - - BOOL issetgroups () const { return (sgsids.type == cygsidlist_alloc); } - void update_supp (const cygsidlist &newsids) - { - sgsids.free_sids (); - sgsids = newsids; - ischanged = TRUE; - } - void clear_supp () - { - if (issetgroups ()) - { - sgsids.free_sids (); - ischanged = TRUE; - } - } - void update_pgrp (const PSID sid) - { - pgsid = sid; - ischanged = TRUE; - } -}; - -extern cygpsid well_known_null_sid; -extern cygpsid well_known_world_sid; -extern cygpsid well_known_local_sid; -extern cygpsid well_known_creator_owner_sid; -extern cygpsid well_known_creator_group_sid; -extern cygpsid well_known_dialup_sid; -extern cygpsid well_known_network_sid; -extern cygpsid well_known_batch_sid; -extern cygpsid well_known_interactive_sid; -extern cygpsid well_known_service_sid; -extern cygpsid well_known_authenticated_users_sid; -extern cygpsid well_known_this_org_sid; -extern cygpsid well_known_system_sid; -extern cygpsid well_known_builtin_sid; -extern cygpsid well_known_admins_sid; -extern cygpsid well_known_users_sid; -extern cygpsid fake_logon_sid; -extern cygpsid mandatory_medium_integrity_sid; -extern cygpsid mandatory_high_integrity_sid; -extern cygpsid mandatory_system_integrity_sid; -extern cygpsid well_known_samba_unix_user_fake_sid; - -bool privilege_luid (const PWCHAR pname, LUID *luid); - -inline BOOL -legal_sid_type (SID_NAME_USE type) -{ - return type == SidTypeUser || type == SidTypeGroup - || type == SidTypeAlias || type == SidTypeWellKnownGroup; -} - -class path_conv; -/* File manipulation */ -int __stdcall get_file_attribute (HANDLE, path_conv &, mode_t *, - __uid32_t *, __gid32_t *); -int __stdcall set_file_attribute (HANDLE, path_conv &, - __uid32_t, __gid32_t, int); -int __stdcall get_reg_attribute (HKEY hkey, mode_t *, __uid32_t *, __gid32_t *); -LONG __stdcall get_file_sd (HANDLE fh, path_conv &, security_descriptor &sd); -LONG __stdcall set_file_sd (HANDLE fh, path_conv &, security_descriptor &sd, - bool is_chown); -bool __stdcall add_access_allowed_ace (PACL acl, int offset, DWORD attributes, PSID sid, size_t &len_add, DWORD inherit); -bool __stdcall add_access_denied_ace (PACL acl, int offset, DWORD attributes, PSID sid, size_t &len_add, DWORD inherit); -int __stdcall check_file_access (path_conv &, int, bool); -int __stdcall check_registry_access (HANDLE, int, bool); - -void set_security_attribute (path_conv &pc, int attribute, - PSECURITY_ATTRIBUTES psa, - security_descriptor &sd_buf); - -bool get_sids_info (cygpsid, cygpsid, __uid32_t * , __gid32_t *); - -/* sec_acl.cc */ -struct __acl32; -extern "C" int aclsort32 (int, int, __acl32 *); -extern "C" int acl32 (const char *, int, int, __acl32 *); -int getacl (HANDLE, path_conv &, int, __acl32 *); -int setacl (HANDLE, path_conv &, int, __acl32 *, bool &); - -/* Set impersonation or restricted token. */ -void set_imp_token (HANDLE token, int type); -/* Function creating a token by calling NtCreateToken. */ -HANDLE create_token (cygsid &usersid, user_groups &groups, struct passwd * pw); -/* LSA authentication function. */ -HANDLE lsaauth (cygsid &, user_groups &, struct passwd *); -/* LSA private key storage authentication, same as when using service logons. */ -HANDLE lsaprivkeyauth (struct passwd *pw); -/* Verify an existing token */ -bool verify_token (HANDLE token, cygsid &usersid, user_groups &groups, bool *pintern = NULL); -/* Get groups of a user */ -bool get_server_groups (cygsidlist &grp_list, PSID usersid, struct passwd *pw); - -/* Extract U-domain\user field from passwd entry. */ -void extract_nt_dom_user (const struct passwd *pw, PWCHAR domain, PWCHAR user); -/* Get default logonserver for a domain. */ -bool get_logon_server (PWCHAR domain, PWCHAR wserver, bool rediscovery); - -HANDLE open_local_policy (ACCESS_MASK access); - -/* sec_helper.cc: Security helper functions. */ -int set_privilege (HANDLE token, DWORD privilege, bool enable); -void set_cygwin_privileges (HANDLE token); - -#define _push_thread_privilege(_priv, _val, _check) { \ - HANDLE _dup_token = NULL; \ - HANDLE _token = (cygheap->user.issetuid () && (_check)) \ - ? cygheap->user.primary_token () : hProcToken; \ - if (!DuplicateTokenEx (_token, MAXIMUM_ALLOWED, NULL, \ - SecurityImpersonation, TokenImpersonation, \ - &_dup_token)) \ - debug_printf ("DuplicateTokenEx: %E"); \ - else if (!ImpersonateLoggedOnUser (_dup_token)) \ - debug_printf ("ImpersonateLoggedOnUser: %E"); \ - else \ - set_privilege (_dup_token, (_priv), (_val)); - -#define push_thread_privilege(_priv, _val) _push_thread_privilege(_priv,_val,1) -#define push_self_privilege(_priv, _val) _push_thread_privilege(_priv,_val,0) - -#define pop_thread_privilege() \ - if (_dup_token) \ - { \ - if (!cygheap->user.issetuid ()) \ - RevertToSelf (); \ - else \ - cygheap->user.reimpersonate (); \ - CloseHandle (_dup_token); \ - } \ - } - -#define pop_self_privilege() pop_thread_privilege() - -/* shared.cc: */ -/* Retrieve a security descriptor that allows all access */ -SECURITY_DESCRIPTOR *__stdcall get_null_sd (); - -/* Various types of security attributes for use in Create* functions. */ -extern SECURITY_ATTRIBUTES sec_none, sec_none_nih, sec_all, sec_all_nih; -extern SECURITY_ATTRIBUTES *__stdcall __sec_user (PVOID sa_buf, PSID sid1, PSID sid2, - DWORD access2, BOOL inherit) - __attribute__ ((regparm (3))); -extern PSECURITY_DESCRIPTOR _everyone_sd (void *buf, ACCESS_MASK access); -#define everyone_sd(access) (_everyone_sd (alloca (SD_MIN_SIZE), (access))) - -#define sec_none_cloexec(f) (((f) & O_CLOEXEC ? &sec_none_nih : &sec_none)) - -extern bool sec_acl (PACL acl, bool original, bool admins, PSID sid1 = NO_SID, - PSID sid2 = NO_SID, DWORD access2 = 0); - -ssize_t __stdcall read_ea (HANDLE hdl, path_conv &pc, const char *name, - char *value, size_t size); -int __stdcall write_ea (HANDLE hdl, path_conv &pc, const char *name, - const char *value, size_t size, int flags); - -/* Note: sid1 is usually (read: currently always) the current user's - effective sid (cygheap->user.sid ()). */ -extern inline SECURITY_ATTRIBUTES * -sec_user_nih (SECURITY_ATTRIBUTES *sa_buf, PSID sid1, PSID sid2 = NULL, - DWORD access2 = 0) -{ - return __sec_user (sa_buf, sid1, sid2, access2, FALSE); -} - -extern inline SECURITY_ATTRIBUTES * -sec_user (SECURITY_ATTRIBUTES *sa_buf, PSID sid1, PSID sid2 = NULL, - DWORD access2 = 0) -{ - return __sec_user (sa_buf, sid1, sid2, access2, TRUE); -} - -#endif /*_SECURITY_H*/ diff --git a/winsup/cygwin/security.sgml b/winsup/cygwin/security.sgml deleted file mode 100644 index b286ef540..000000000 --- a/winsup/cygwin/security.sgml +++ /dev/null @@ -1,45 +0,0 @@ - -cygwin_logon_user - - -extern "C" HANDLE -cygwin_logon_user -const struct passwd *passwd_entry -const char *password - - -Given a pointer ot a passwd entry of a user and a cleartext password, -returns a HANDLE to an impersonation token for this user which can be used -in a subsequent call to cygwin_set_impersonation_token -to impersonate that user. This function can only be called from a process -which has the required NT user rights to perform a logon. - -See also the chapter "New setuid concept" in the Cygwin user's guide. - - -See also cygwin_set_impersonation_token - - - - -cygwin_set_impersonation_token - - -extern "C" void -cygwin_set_impersonation_token -const HANDLE token - - -Use this function to enable the token given as parameter as -impersonation token for the next call to setuid or -seteuid. Use -cygwin_set_impersonation_token together with -cygwin_logon_user to impersonate users using -password authentication. - -See also the chapter "New setuid concept" in the Cygwin user's guide. - - -See also cygwin_logon_user - - diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc deleted file mode 100644 index e1906cb14..000000000 --- a/winsup/cygwin/select.cc +++ /dev/null @@ -1,1719 +0,0 @@ -/* select.cc - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* The following line means that the BSD socket definitions for - fd_set, FD_ISSET etc. are used in this file. */ - -#define __INSIDE_CYGWIN_NET__ - -#include "winsup.h" -#include -#include -#include "ntdll.h" - -#include -#include -#include -#define USE_SYS_TYPES_FD_SET -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "select.h" -#include "dtable.h" -#include "cygheap.h" -#include "pinfo.h" -#include "sigproc.h" -#include "cygtls.h" - -/* - * All these defines below should be in sys/types.h - * but because of the includes above, they may not have - * been included. We create special UNIX_xxxx versions here. - */ - -#ifndef NBBY -#define NBBY 8 /* number of bits in a byte */ -#endif /* NBBY */ - -/* - * Select uses bit masks of file descriptors in longs. - * These macros manipulate such bit fields (the filesystem macros use chars). - * FD_SETSIZE may be defined by the user, but the default here - * should be >= NOFILE (param.h). - */ - -typedef long fd_mask; -#define UNIX_NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */ -#ifndef unix_howmany -#define unix_howmany(x,y) (((x)+((y)-1))/(y)) -#endif - -#define unix_fd_set fd_set - -#define NULL_fd_set ((fd_set *) NULL) -#define sizeof_fd_set(n) \ - ((unsigned) (NULL_fd_set->fds_bits + unix_howmany ((n), UNIX_NFDBITS))) -#define UNIX_FD_SET(n, p) \ - ((p)->fds_bits[(n)/UNIX_NFDBITS] |= (1L << ((n) % UNIX_NFDBITS))) -#define UNIX_FD_CLR(n, p) \ - ((p)->fds_bits[(n)/UNIX_NFDBITS] &= ~(1L << ((n) % UNIX_NFDBITS))) -#define UNIX_FD_ISSET(n, p) \ - ((p)->fds_bits[(n)/UNIX_NFDBITS] & (1L << ((n) % UNIX_NFDBITS))) -#define UNIX_FD_ZERO(p, n) \ - memset ((caddr_t) (p), 0, sizeof_fd_set ((n))) - -#define allocfd_set(n) ((fd_set *) memset (alloca (sizeof_fd_set (n)), 0, sizeof_fd_set (n))) -#define copyfd_set(to, from, n) memcpy (to, from, sizeof_fd_set (n)); - -#define set_handle_or_return_if_not_open(h, s) \ - h = (s)->fh->get_handle (); \ - if (cygheap->fdtab.not_open ((s)->fd)) \ - { \ - (s)->thread_errno = EBADF; \ - return -1; \ - } \ - -/* The main select code. - */ -extern "C" int -cygwin_select (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, - struct timeval *to) -{ - select_stuff sel; - fd_set *dummy_readfds = allocfd_set (maxfds); - fd_set *dummy_writefds = allocfd_set (maxfds); - fd_set *dummy_exceptfds = allocfd_set (maxfds); - - select_printf ("%d, %p, %p, %p, %p", maxfds, readfds, writefds, exceptfds, to); - - if (!readfds) - readfds = dummy_readfds; - if (!writefds) - writefds = dummy_writefds; - if (!exceptfds) - exceptfds = dummy_exceptfds; - - for (int i = 0; i < maxfds; i++) - if (!sel.test_and_set (i, readfds, writefds, exceptfds)) - { - select_printf ("aborting due to test_and_set error"); - return -1; /* Invalid fd, maybe? */ - } - - /* Convert to milliseconds or INFINITE if to == NULL */ - DWORD ms = to ? (to->tv_sec * 1000) + (to->tv_usec / 1000) : INFINITE; - if (ms == 0 && to->tv_usec) - ms = 1; /* At least 1 ms granularity */ - - if (to) - select_printf ("to->tv_sec %d, to->tv_usec %d, ms %d", to->tv_sec, to->tv_usec, ms); - else - select_printf ("to NULL, ms %x", ms); - - select_printf ("sel.always_ready %d", sel.always_ready); - - int timeout = 0; - /* Allocate some fd_set structures using the number of fds as a guide. */ - fd_set *r = allocfd_set (maxfds); - fd_set *w = allocfd_set (maxfds); - fd_set *e = allocfd_set (maxfds); - - /* Degenerate case. No fds to wait for. Just wait. */ - if (sel.start.next == NULL) - { - if (WaitForSingleObject (signal_arrived, ms) == WAIT_OBJECT_0) - { - select_printf ("signal received"); - set_sig_errno (EINTR); - return -1; - } - timeout = 1; - } - else if (sel.always_ready || ms == 0) - /* Don't bother waiting. */; - else if ((timeout = sel.wait (r, w, e, ms) < 0)) - return -1; /* some kind of error */ - - sel.cleanup (); - copyfd_set (readfds, r, maxfds); - copyfd_set (writefds, w, maxfds); - copyfd_set (exceptfds, e, maxfds); - return timeout ? 0 : sel.poll (readfds, writefds, exceptfds); -} - -extern "C" int -pselect(int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, - const struct timespec *ts, const sigset_t *set) -{ - struct timeval tv; - sigset_t oldset = _my_tls.sigmask; - - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - if (ts) - { - tv.tv_sec = ts->tv_sec; - tv.tv_usec = ts->tv_nsec / 1000; - } - if (set) - set_signal_mask (*set, _my_tls.sigmask); - int ret = cygwin_select (maxfds, readfds, writefds, exceptfds, - ts ? &tv : NULL); - if (set) - set_signal_mask (oldset, _my_tls.sigmask); - return ret; -} - -/* Call cleanup functions for all inspected fds. Gets rid of any - executing threads. */ -void -select_stuff::cleanup () -{ - select_record *s = &start; - - select_printf ("calling cleanup routines"); - while ((s = s->next)) - if (s->cleanup) - { - s->cleanup (s, this); - s->cleanup = NULL; - } -} - -/* Destroy all storage associated with select stuff. */ -select_stuff::~select_stuff () -{ - cleanup (); - select_record *s = &start; - select_record *snext = start.next; - - select_printf ("deleting select records"); - while ((s = snext)) - { - snext = s->next; - delete s; - } -} - -/* Add a record to the select chain */ -bool -select_stuff::test_and_set (int i, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds) -{ - if (!UNIX_FD_ISSET (i, readfds) && !UNIX_FD_ISSET (i, writefds) - && ! UNIX_FD_ISSET (i, exceptfds)) - return true; - - select_record *s = new select_record; - if (!s) - return false; - - s->next = start.next; - start.next = s; - - if (UNIX_FD_ISSET (i, readfds) && !cygheap->fdtab.select_read (i, this)) - goto err; - if (UNIX_FD_ISSET (i, writefds) && !cygheap->fdtab.select_write (i, this)) - goto err; - if (UNIX_FD_ISSET (i, exceptfds) && !cygheap->fdtab.select_except (i, this)) - goto err; /* error */ - - if (s->read_ready || s->write_ready || s->except_ready) - always_ready = true; - - if (s->windows_handle) - windows_used = true; - - return true; - -err: - start.next = s->next; - delete s; - return false; -} - -/* The heart of select. Waits for an fd to do something interesting. */ -int -select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds, - DWORD ms) -{ - int wait_ret; - HANDLE w4[MAXIMUM_WAIT_OBJECTS]; - select_record *s = &start; - int m = 0; - int res = 0; - - w4[m++] = signal_arrived; /* Always wait for the arrival of a signal. */ - /* Loop through the select chain, starting up anything appropriate and - counting the number of active fds. */ - while ((s = s->next)) - { - if (m >= MAXIMUM_WAIT_OBJECTS) - { - set_sig_errno (EINVAL); - return -1; - } - if (!s->startup (s, this)) - { - s->set_select_errno (); - return -1; - } - if (s->h == NULL) - continue; - for (int i = 1; i < m; i++) - if (w4[i] == s->h) - goto next_while; - w4[m++] = s->h; - next_while: - continue; - } - - LONGLONG start_time = gtod.msecs (); /* Record the current time for later use. */ - - debug_printf ("m %d, ms %u", m, ms); - for (;;) - { - if (!windows_used) - wait_ret = WaitForMultipleObjects (m, w4, FALSE, ms); - else - wait_ret = MsgWaitForMultipleObjects (m, w4, FALSE, ms, QS_ALLINPUT); - - switch (wait_ret) - { - case WAIT_OBJECT_0: - select_printf ("signal received"); - set_sig_errno (EINTR); - return -1; - case WAIT_FAILED: - select_printf ("WaitForMultipleObjects failed"); - s->set_select_errno (); - return -1; - case WAIT_TIMEOUT: - select_printf ("timed out"); - res = 1; - goto out; - } - - select_printf ("woke up. wait_ret %d. verifying", wait_ret); - s = &start; - bool gotone = false; - /* Some types of objects (e.g., consoles) wake up on "inappropriate" events - like mouse movements. The verify function will detect these situations. - If it returns false, then this wakeup was a false alarm and we should go - back to waiting. */ - while ((s = s->next)) - if (s->saw_error ()) - { - set_errno (s->saw_error ()); - return -1; /* Somebody detected an error */ - } - else if ((((wait_ret >= m && s->windows_handle) || s->h == w4[wait_ret])) && - s->verify (s, readfds, writefds, exceptfds)) - gotone = true; - - select_printf ("gotone %d", gotone); - if (gotone) - goto out; - - if (ms == INFINITE) - { - select_printf ("looping"); - continue; - } - select_printf ("recalculating ms"); - - LONGLONG now = gtod.msecs (); - if (now > (start_time + ms)) - { - select_printf ("timed out after verification"); - goto out; - } - ms -= (now - start_time); - start_time = now; - select_printf ("ms now %u", ms); - } - -out: - select_printf ("returning %d", res); - return res; -} - -static int -set_bits (select_record *me, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds) -{ - int ready = 0; - fhandler_socket *sock; - select_printf ("me %p, testing fd %d (%s)", me, me->fd, me->fh->get_name ()); - if (me->read_selected && me->read_ready) - { - UNIX_FD_SET (me->fd, readfds); - ready++; - } - if (me->write_selected && me->write_ready) - { - UNIX_FD_SET (me->fd, writefds); - if (me->except_on_write && (sock = me->fh->is_socket ())) - { - /* Special AF_LOCAL handling. */ - if (!me->read_ready && sock->connect_state () == connect_pending - && sock->af_local_connect ()) - { - if (me->read_selected) - UNIX_FD_SET (me->fd, readfds); - sock->connect_state (connect_failed); - } - else - sock->connect_state (connected); - } - ready++; - } - if (me->except_selected && me->except_ready) - { - UNIX_FD_SET (me->fd, exceptfds); - ready++; - } - select_printf ("ready %d", ready); - return ready; -} - -/* Poll every fd in the select chain. Set appropriate fd in mask. */ -int -select_stuff::poll (fd_set *readfds, fd_set *writefds, fd_set *exceptfds) -{ - int n = 0; - select_record *s = &start; - while ((s = s->next)) - n += (!s->peek || s->peek (s, true)) ? - set_bits (s, readfds, writefds, exceptfds) : 0; - select_printf ("returning %d", n); - return n; -} - -static int -verify_true (select_record *, fd_set *, fd_set *, fd_set *) -{ - return 1; -} - -static int -verify_ok (select_record *me, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds) -{ - return set_bits (me, readfds, writefds, exceptfds); -} - -static int -no_startup (select_record *, select_stuff *) -{ - return 1; -} - -static int -no_verify (select_record *, fd_set *, fd_set *, fd_set *) -{ - return 0; -} - -static int -peek_pipe (select_record *s, bool from_select) -{ - int n = 0; - int gotone = 0; - fhandler_base *fh = s->fh; - - HANDLE h; - set_handle_or_return_if_not_open (h, s); - - /* Don't perform complicated tests if we don't need to. */ - if (!s->read_selected && !s->except_selected) - goto out; - - if (s->read_selected) - { - if (s->read_ready) - { - select_printf ("%s, already ready for read", fh->get_name ()); - gotone = 1; - goto out; - } - - switch (fh->get_major ()) - { - case DEV_TTYM_MAJOR: - if (((fhandler_pty_master *) fh)->need_nl) - { - gotone = s->read_ready = true; - goto out; - } - break; - default: - if (fh->get_readahead_valid ()) - { - select_printf ("readahead"); - gotone = s->read_ready = true; - goto out; - } - } - - if (fh->bg_check (SIGTTIN) <= bg_eof) - { - gotone = s->read_ready = true; - goto out; - } - } - - if (fh->get_device () == FH_PIPEW) - select_printf ("%s, select for read/except on write end of pipe", - fh->get_name ()); - else if (!PeekNamedPipe (h, NULL, 0, NULL, (DWORD *) &n, NULL)) - switch (GetLastError ()) - { - case ERROR_BAD_PIPE: - case ERROR_PIPE_BUSY: - case ERROR_NO_DATA: - case ERROR_PIPE_NOT_CONNECTED: - n = 0; - break; - default: - select_printf ("%s, PeekNamedPipe failed, %E", fh->get_name ()); - n = -1; - break; - } - - if (n < 0) - { - select_printf ("%s, n %d", fh->get_name (), n); - if (s->except_selected) - gotone += s->except_ready = true; - if (s->read_selected) - gotone += s->read_ready = true; - } - if (n > 0 && s->read_selected) - { - select_printf ("%s, ready for read: avail %d", fh->get_name (), n); - gotone += s->read_ready = true; - } - if (!gotone && s->fh->hit_eof ()) - { - select_printf ("%s, saw EOF", fh->get_name ()); - if (s->except_selected) - gotone += s->except_ready = true; - if (s->read_selected) - gotone += s->read_ready = true; - } - -out: - if (s->write_selected) - { - if (s->write_ready) - { - select_printf ("%s, already ready for write", fh->get_name ()); - gotone++; - } - /* Do we need to do anything about SIGTTOU here? */ - else if (fh->get_device () == FH_PIPER) - select_printf ("%s, select for write on read end of pipe", - fh->get_name ()); - else - { - IO_STATUS_BLOCK iosb = {0}; - FILE_PIPE_LOCAL_INFORMATION fpli = {0}; - - if (NtQueryInformationFile (h, - &iosb, - &fpli, - sizeof (fpli), - FilePipeLocalInformation)) - { - /* If NtQueryInformationFile fails, optimistically assume the - pipe is writable. This could happen if we somehow - inherit a pipe that doesn't permit FILE_READ_ATTRIBUTES - access on the write end. */ - select_printf ("%s, NtQueryInformationFile failed", - fh->get_name ()); - gotone += s->write_ready = true; - } - /* If there is anything available in the pipe buffer then signal - that. This means that a pipe could still block since you could - be trying to write more to the pipe than is available in the - buffer but that is the hazard of select(). */ - else if ((fpli.WriteQuotaAvailable = (fpli.OutboundQuota - fpli.ReadDataAvailable))) - { - select_printf ("%s, ready for write: size %lu, avail %lu", - fh->get_name (), - fpli.OutboundQuota, - fpli.WriteQuotaAvailable); - gotone += s->write_ready = true; - } - /* If we somehow inherit a tiny pipe (size < PIPE_BUF), then consider - the pipe writable only if it is completely empty, to minimize the - probability that a subsequent write will block. */ - else if (fpli.OutboundQuota < PIPE_BUF && - fpli.WriteQuotaAvailable == fpli.OutboundQuota) - { - select_printf ("%s, tiny pipe: size %lu, avail %lu", - fh->get_name (), - fpli.OutboundQuota, - fpli.WriteQuotaAvailable); - gotone += s->write_ready = true; - } - } - } - - return gotone; -} - -static int start_thread_pipe (select_record *me, select_stuff *stuff); - -select_pipe_info::select_pipe_info () -{ - n = 1; - w4[0] = CreateEvent (&sec_none_nih, true, false, NULL); -} - -select_pipe_info::~select_pipe_info () -{ - if (thread) - { - SetEvent (w4[0]); - stop_thread = true; - thread->detach (); - } - ForceCloseHandle (w4[0]); -} - -void -select_pipe_info::add_watch_handle (fhandler_pipe *fh) -{ - if (fh->get_overlapped () && fh->get_overlapped ()->hEvent) - w4[n++] = fh->get_overlapped ()->hEvent; -} - -static DWORD WINAPI -thread_pipe (void *arg) -{ - select_pipe_info *pi = (select_pipe_info *) arg; - bool gotone = false; - DWORD sleep_time = 0; - - for (;;) - { - select_record *s = pi->start; - if (pi->n > 1) - switch (WaitForMultipleObjects (pi->n, pi->w4, false, INFINITE)) - { - case WAIT_OBJECT_0: - goto out; - default: - break; - } - while ((s = s->next)) - if (s->startup == start_thread_pipe) - { - if (peek_pipe (s, true)) - gotone = true; - if (pi->stop_thread) - { - select_printf ("stopping"); - goto out; - } - } - /* Paranoid check */ - if (pi->stop_thread) - { - select_printf ("stopping from outer loop"); - break; - } - if (gotone) - break; - Sleep (sleep_time >> 3); - if (sleep_time < 80) - ++sleep_time; - } -out: - return 0; -} - -static int -start_thread_pipe (select_record *me, select_stuff *stuff) -{ - select_pipe_info *pi = stuff->device_specific_pipe; - if (pi->start) - me->h = *((select_pipe_info *) stuff->device_specific_pipe)->thread; - else - { - pi->start = &stuff->start; - pi->stop_thread = false; - pi->thread = new cygthread (thread_pipe, 0, pi, "select_pipe"); - me->h = *pi->thread; - if (!me->h) - return 0; - } - return 1; -} - -static void -pipe_cleanup (select_record *, select_stuff *stuff) -{ - if (stuff->device_specific_pipe) - { - delete stuff->device_specific_pipe; - stuff->device_specific_pipe = NULL; - } -} - -int -fhandler_pipe::ready_for_read (int fd, DWORD howlong) -{ - int res; - if (!howlong) - res = fhandler_base::ready_for_read (fd, howlong); - else - res = 1; - return res; -} - -select_record * -fhandler_pipe::select_read (select_stuff *ss) -{ - if (!ss->device_specific_pipe - && (ss->device_specific_pipe = new select_pipe_info) == NULL) - return NULL; - ss->device_specific_pipe->add_watch_handle (this); - - select_record *s = ss->start.next; - s->startup = start_thread_pipe; - s->peek = peek_pipe; - s->verify = verify_ok; - s->cleanup = pipe_cleanup; - s->read_selected = true; - s->read_ready = false; - return s; -} - -select_record * -fhandler_pipe::select_write (select_stuff *ss) -{ - if (!ss->device_specific_pipe - && (ss->device_specific_pipe = new select_pipe_info) == NULL) - return NULL; - ss->device_specific_pipe->add_watch_handle (this); - select_record *s = ss->start.next; - s->startup = start_thread_pipe; - s->peek = peek_pipe; - s->verify = verify_ok; - s->cleanup = pipe_cleanup; - s->write_selected = true; - s->write_ready = false; - return s; -} - -select_record * -fhandler_pipe::select_except (select_stuff *ss) -{ - if (!ss->device_specific_pipe - && (ss->device_specific_pipe = new select_pipe_info) == NULL) - return NULL; - ss->device_specific_pipe->add_watch_handle (this); - select_record *s = ss->start.next; - s->startup = start_thread_pipe; - s->peek = peek_pipe; - s->verify = verify_ok; - s->cleanup = pipe_cleanup; - s->except_selected = true; - s->except_ready = false; - return s; -} - -select_record * -fhandler_fifo::select_read (select_stuff *ss) -{ - if (!ss->device_specific_pipe - && (ss->device_specific_pipe = new select_pipe_info) == NULL) - return NULL; - select_record *s = ss->start.next; - s->startup = start_thread_pipe; - s->peek = peek_pipe; - s->verify = verify_ok; - s->cleanup = pipe_cleanup; - s->read_selected = true; - s->read_ready = false; - return s; -} - -select_record * -fhandler_fifo::select_write (select_stuff *ss) -{ - if (!ss->device_specific_pipe - && (ss->device_specific_pipe = new select_pipe_info) == NULL) - return NULL; - select_record *s = ss->start.next; - s->startup = start_thread_pipe; - s->peek = peek_pipe; - s->verify = verify_ok; - s->cleanup = pipe_cleanup; - s->write_selected = true; - s->write_ready = false; - return s; -} - -select_record * -fhandler_fifo::select_except (select_stuff *ss) -{ - if (!ss->device_specific_pipe - && (ss->device_specific_pipe = new select_pipe_info) == NULL) - return NULL; - select_record *s = ss->start.next; - s->startup = start_thread_pipe; - s->peek = peek_pipe; - s->verify = verify_ok; - s->cleanup = pipe_cleanup; - s->except_selected = true; - s->except_ready = false; - return s; -} - -static int -peek_console (select_record *me, bool) -{ - extern const char * get_nonascii_key (INPUT_RECORD& input_rec, char *); - fhandler_console *fh = (fhandler_console *) me->fh; - - if (!me->read_selected) - return me->write_ready; - - if (fh->get_readahead_valid ()) - { - select_printf ("readahead"); - return me->read_ready = true; - } - - if (me->read_ready) - { - select_printf ("already ready"); - return 1; - } - - INPUT_RECORD irec; - DWORD events_read; - HANDLE h; - char tmpbuf[17]; - set_handle_or_return_if_not_open (h, me); - - for (;;) - if (fh->bg_check (SIGTTIN) <= bg_eof) - return me->read_ready = true; - else if (!PeekConsoleInput (h, &irec, 1, &events_read) || !events_read) - break; - else - { - fh->send_winch_maybe (); - if (irec.EventType == KEY_EVENT) - { - if (irec.Event.KeyEvent.bKeyDown - && (irec.Event.KeyEvent.uChar.AsciiChar - || get_nonascii_key (irec, tmpbuf))) - return me->read_ready = true; - } - else - { - if (irec.EventType == MOUSE_EVENT - && fh->mouse_aware (irec.Event.MouseEvent)) - return me->read_ready = true; - if (irec.EventType == FOCUS_EVENT && fh->focus_aware ()) - return me->read_ready = true; - } - - /* Read and discard the event */ - ReadConsoleInput (h, &irec, 1, &events_read); - } - - return me->write_ready; -} - -static int -verify_console (select_record *me, fd_set *rfds, fd_set *wfds, - fd_set *efds) -{ - return peek_console (me, true); -} - - -select_record * -fhandler_console::select_read (select_stuff *ss) -{ - select_record *s = ss->start.next; - if (!s->startup) - { - s->startup = no_startup; - s->verify = verify_console; - set_cursor_maybe (); - } - - s->peek = peek_console; - s->h = get_handle (); - s->read_selected = true; - s->read_ready = false; - return s; -} - -select_record * -fhandler_console::select_write (select_stuff *ss) -{ - select_record *s = ss->start.next; - if (!s->startup) - { - s->startup = no_startup; - s->verify = no_verify; - set_cursor_maybe (); - } - - s->peek = peek_console; - s->write_selected = true; - s->write_ready = true; - return s; -} - -select_record * -fhandler_console::select_except (select_stuff *ss) -{ - select_record *s = ss->start.next; - if (!s->startup) - { - s->startup = no_startup; - s->verify = no_verify; - set_cursor_maybe (); - } - - s->peek = peek_console; - s->except_selected = true; - s->except_ready = false; - return s; -} - -select_record * -fhandler_tty_common::select_read (select_stuff *ss) -{ - return ((fhandler_pipe *) this)->fhandler_pipe::select_read (ss); -} - -select_record * -fhandler_tty_common::select_write (select_stuff *ss) -{ - return ((fhandler_pipe *) this)->fhandler_pipe::select_write (ss); -} - -select_record * -fhandler_tty_common::select_except (select_stuff *ss) -{ - return ((fhandler_pipe *) this)->fhandler_pipe::select_except (ss); -} - -static int -verify_tty_slave (select_record *me, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds) -{ - if (WaitForSingleObject (me->h, 0) == WAIT_OBJECT_0) - me->read_ready = true; - return set_bits (me, readfds, writefds, exceptfds); -} - -select_record * -fhandler_tty_slave::select_read (select_stuff *ss) -{ - select_record *s = ss->start.next; - s->h = input_available_event; - s->startup = no_startup; - s->peek = peek_pipe; - s->verify = verify_tty_slave; - s->read_selected = true; - s->read_ready = false; - s->cleanup = NULL; - return s; -} - -select_record * -fhandler_dev_null::select_read (select_stuff *ss) -{ - select_record *s = ss->start.next; - if (!s->startup) - { - s->startup = no_startup; - s->verify = no_verify; - } - s->h = get_handle (); - s->read_selected = true; - s->read_ready = true; - return s; -} - -select_record * -fhandler_dev_null::select_write (select_stuff *ss) -{ - select_record *s = ss->start.next; - if (!s->startup) - { - s->startup = no_startup; - s->verify = no_verify; - } - s->h = get_handle (); - s->write_selected = true; - s->write_ready = true; - return s; -} - -select_record * -fhandler_dev_null::select_except (select_stuff *ss) -{ - select_record *s = ss->start.next; - if (!s->startup) - { - s->startup = no_startup; - s->verify = no_verify; - } - s->h = get_handle (); - s->except_selected = true; - s->except_ready = false; - return s; -} - -static int start_thread_serial (select_record *me, select_stuff *stuff); - -static int -peek_serial (select_record *s, bool) -{ - COMSTAT st; - - fhandler_serial *fh = (fhandler_serial *) s->fh; - - if (fh->get_readahead_valid () || fh->overlapped_armed < 0) - return s->read_ready = true; - - select_printf ("fh->overlapped_armed %d", fh->overlapped_armed); - - HANDLE h; - set_handle_or_return_if_not_open (h, s); - int ready = 0; - - if ((s->read_selected && s->read_ready) || (s->write_selected && s->write_ready)) - { - select_printf ("already ready"); - ready = 1; - goto out; - } - - /* This is apparently necessary for the com0com driver. - See: http://cygwin.com/ml/cygwin/2009-01/msg00667.html */ - SetCommMask (h, 0); - - SetCommMask (h, EV_RXCHAR); - - if (!fh->overlapped_armed) - { - COMSTAT st; - - ResetEvent (fh->io_status.hEvent); - - if (!ClearCommError (h, &fh->ev, &st)) - { - debug_printf ("ClearCommError"); - goto err; - } - else if (st.cbInQue) - return s->read_ready = true; - else if (WaitCommEvent (h, &fh->ev, &fh->io_status)) - return s->read_ready = true; - else if (GetLastError () == ERROR_IO_PENDING) - fh->overlapped_armed = 1; - else - { - debug_printf ("WaitCommEvent"); - goto err; - } - } - - HANDLE w4[2]; - DWORD to; - - w4[0] = fh->io_status.hEvent; - w4[1] = signal_arrived; - to = 10; - - switch (WaitForMultipleObjects (2, w4, FALSE, to)) - { - case WAIT_OBJECT_0: - if (!ClearCommError (h, &fh->ev, &st)) - { - debug_printf ("ClearCommError"); - goto err; - } - else if (!st.cbInQue) - Sleep (to); - else - { - return s->read_ready = true; - select_printf ("got something"); - } - break; - case WAIT_OBJECT_0 + 1: - select_printf ("interrupt"); - set_sig_errno (EINTR); - ready = -1; - break; - case WAIT_TIMEOUT: - break; - default: - debug_printf ("WaitForMultipleObjects"); - goto err; - } - -out: - return ready; - -err: - if (GetLastError () == ERROR_OPERATION_ABORTED) - { - select_printf ("operation aborted"); - return ready; - } - - s->set_select_errno (); - select_printf ("error %E"); - return -1; -} - -static DWORD WINAPI -thread_serial (void *arg) -{ - select_serial_info *si = (select_serial_info *) arg; - bool gotone = false; - - for (;;) - { - select_record *s = si->start; - while ((s = s->next)) - if (s->startup == start_thread_serial) - { - if (peek_serial (s, true)) - gotone = true; - } - if (si->stop_thread) - { - select_printf ("stopping"); - break; - } - if (gotone) - break; - } - - select_printf ("exiting"); - return 0; -} - -static int -start_thread_serial (select_record *me, select_stuff *stuff) -{ - if (stuff->device_specific_serial) - me->h = *((select_serial_info *) stuff->device_specific_serial)->thread; - else - { - select_serial_info *si = new select_serial_info; - si->start = &stuff->start; - si->stop_thread = false; - si->thread = new cygthread (thread_serial, 0, si, "select_serial"); - me->h = *si->thread; - stuff->device_specific_serial = si; - } - return 1; -} - -static void -serial_cleanup (select_record *, select_stuff *stuff) -{ - select_serial_info *si = (select_serial_info *) stuff->device_specific_serial; - if (si && si->thread) - { - si->stop_thread = true; - si->thread->detach (); - delete si; - stuff->device_specific_serial = NULL; - } -} - -select_record * -fhandler_serial::select_read (select_stuff *ss) -{ - select_record *s = ss->start.next; - if (!s->startup) - { - s->startup = start_thread_serial; - s->verify = verify_ok; - s->cleanup = serial_cleanup; - } - s->peek = peek_serial; - s->read_selected = true; - s->read_ready = false; - return s; -} - -select_record * -fhandler_serial::select_write (select_stuff *ss) -{ - select_record *s = ss->start.next; - if (!s->startup) - { - s->startup = no_startup; - s->verify = verify_ok; - } - s->peek = peek_serial; - s->h = get_handle (); - s->write_selected = true; - s->write_ready = true; - return s; -} - -select_record * -fhandler_serial::select_except (select_stuff *ss) -{ - select_record *s = ss->start.next; - if (!s->startup) - { - s->startup = no_startup; - s->verify = verify_ok; - } - s->h = NULL; - s->peek = peek_serial; - s->except_selected = false; // Can't do this - s->except_ready = false; - return s; -} - -int -fhandler_base::ready_for_read (int fd, DWORD howlong) -{ - bool avail = false; - - select_stuff sel; - fd_set *thisfd = allocfd_set (fd + 1); - fd_set *dummy_writefds = allocfd_set (fd + 1); - fd_set *dummy_exceptfds = allocfd_set (fd + 1); - UNIX_FD_SET(fd, thisfd); - - if (!sel.test_and_set (fd, thisfd, dummy_writefds, dummy_exceptfds)) - select_printf ("aborting due to test_and_set error"); - else - { - select_record *me = sel.start.next; - while (!avail) - { - avail = me->read_ready ?: me->peek (me, false); - - if (fd >= 0 && cygheap->fdtab.not_open (fd)) - { - set_sig_errno (EBADF); - avail = false; - break; - } - - if (howlong != INFINITE) - { - if (!avail) - set_sig_errno (EAGAIN); - break; - } - - if (WaitForSingleObject (signal_arrived, avail ? 0 : 10) == WAIT_OBJECT_0) - { - debug_printf ("interrupted"); - set_sig_errno (EINTR); - avail = false; - break; - } - } - } - - select_printf ("read_ready %d, avail %d", sel.start.next->read_ready, avail); - sel.cleanup (); - return avail; -} - -select_record * -fhandler_base::select_read (select_stuff *ss) -{ - select_record *s = ss->start.next; - if (!s->startup) - { - s->startup = no_startup; - s->verify = verify_ok; - } - s->h = get_handle (); - s->read_selected = true; - s->read_ready = true; - return s; -} - -select_record * -fhandler_base::select_write (select_stuff *ss) -{ - select_record *s = ss->start.next; - if (!s->startup) - { - s->startup = no_startup; - s->verify = verify_ok; - } - s->h = get_handle (); - s->write_selected = true; - s->write_ready = true; - return s; -} - -select_record * -fhandler_base::select_except (select_stuff *ss) -{ - select_record *s = ss->start.next; - if (!s->startup) - { - s->startup = no_startup; - s->verify = verify_ok; - } - s->h = NULL; - s->except_selected = true; - s->except_ready = false; - return s; -} - -static int -peek_socket (select_record *me, bool) -{ - fhandler_socket *fh = (fhandler_socket *) me->fh; - long events; - /* Don't play with the settings again, unless having taken a deep look into - Richard W. Stevens Network Programming book. Thank you. */ - long evt_mask = (me->read_selected ? (FD_READ | FD_ACCEPT | FD_CLOSE) : 0) - | (me->write_selected ? (FD_WRITE | FD_CONNECT | FD_CLOSE) : 0) - | (me->except_selected ? FD_OOB : 0); - int ret = fh->evaluate_events (evt_mask, events, false); - if (me->read_selected) - me->read_ready |= ret || !!(events & (FD_READ | FD_ACCEPT | FD_CLOSE)); - if (me->write_selected) - me->write_ready |= ret || !!(events & (FD_WRITE | FD_CONNECT | FD_CLOSE)); - if (me->except_selected) - me->except_ready |= !!(events & FD_OOB); - - select_printf ("read_ready: %d, write_ready: %d, except_ready: %d", - me->read_ready, me->write_ready, me->except_ready); - return me->read_ready || me->write_ready || me->except_ready; -} - -static int start_thread_socket (select_record *, select_stuff *); - -static DWORD WINAPI -thread_socket (void *arg) -{ - select_socket_info *si = (select_socket_info *) arg; - DWORD timeout = (si->num_w4 <= MAXIMUM_WAIT_OBJECTS) - ? INFINITE - : (64 / (roundup2 (si->num_w4, MAXIMUM_WAIT_OBJECTS) - / MAXIMUM_WAIT_OBJECTS)); - bool event = false; - - select_printf ("stuff_start %p", si->start); - while (!event) - { - for (select_record *s = si->start; (s = s->next); ) - if (s->startup == start_thread_socket) - if (peek_socket (s, false)) - event = true; - if (!event) - for (int i = 0; i < si->num_w4; i += MAXIMUM_WAIT_OBJECTS) - switch (WaitForMultipleObjects (min (si->num_w4 - i, - MAXIMUM_WAIT_OBJECTS), - si->w4 + i, FALSE, timeout)) - { - case WAIT_FAILED: - goto out; - case WAIT_TIMEOUT: - continue; - case WAIT_OBJECT_0: - if (!i) /* Socket event set. */ - goto out; - /*FALLTHRU*/ - default: - break; - } - } -out: - select_printf ("leaving thread_socket"); - return 0; -} - -static inline bool init_tls_select_info () __attribute__ ((always_inline)); -static inline bool -init_tls_select_info () -{ - if (!_my_tls.locals.select.sockevt) - { - _my_tls.locals.select.sockevt = CreateEvent (&sec_none_nih, TRUE, FALSE, - NULL); - if (!_my_tls.locals.select.sockevt) - return false; - } - if (!_my_tls.locals.select.ser_num) - { - _my_tls.locals.select.ser_num - = (LONG *) malloc (MAXIMUM_WAIT_OBJECTS * sizeof (LONG)); - if (!_my_tls.locals.select.ser_num) - return false; - _my_tls.locals.select.w4 - = (HANDLE *) malloc (MAXIMUM_WAIT_OBJECTS * sizeof (HANDLE)); - if (!_my_tls.locals.select.w4) - { - free (_my_tls.locals.select.ser_num); - _my_tls.locals.select.ser_num = NULL; - return false; - } - _my_tls.locals.select.max_w4 = MAXIMUM_WAIT_OBJECTS; - } - return true; -} - -static int -start_thread_socket (select_record *me, select_stuff *stuff) -{ - select_socket_info *si; - - if ((si = (select_socket_info *) stuff->device_specific_socket)) - { - me->h = *si->thread; - return 1; - } - - si = new select_socket_info; - - if (!init_tls_select_info ()) - return 0; - - si->ser_num = _my_tls.locals.select.ser_num; - si->w4 = _my_tls.locals.select.w4; - - si->w4[0] = _my_tls.locals.select.sockevt; - si->num_w4 = 1; - - select_record *s = &stuff->start; - while ((s = s->next)) - if (s->startup == start_thread_socket) - { - /* No event/socket should show up multiple times. Every socket - is uniquely identified by its serial number in the global - wsock_events record. */ - const LONG ser_num = ((fhandler_socket *) s->fh)->serial_number (); - for (int i = 1; i < si->num_w4; ++i) - if (si->ser_num[i] == ser_num) - goto continue_outer_loop; - if (si->num_w4 >= _my_tls.locals.select.max_w4) - { - LONG *nser = (LONG *) realloc (si->ser_num, - (_my_tls.locals.select.max_w4 - + MAXIMUM_WAIT_OBJECTS) - * sizeof (LONG)); - if (!nser) - return 0; - _my_tls.locals.select.ser_num = si->ser_num = nser; - HANDLE *nw4 = (HANDLE *) realloc (si->w4, - (_my_tls.locals.select.max_w4 - + MAXIMUM_WAIT_OBJECTS) - * sizeof (HANDLE)); - if (!nw4) - return 0; - _my_tls.locals.select.w4 = si->w4 = nw4; - _my_tls.locals.select.max_w4 += MAXIMUM_WAIT_OBJECTS; - } - si->ser_num[si->num_w4] = ser_num; - si->w4[si->num_w4++] = ((fhandler_socket *) s->fh)->wsock_event (); - continue_outer_loop: - ; - } - stuff->device_specific_socket = si; - si->start = &stuff->start; - select_printf ("stuff_start %p", &stuff->start); - si->thread = new cygthread (thread_socket, 0, si, "select_socket"); - me->h = *si->thread; - return 1; -} - -void -socket_cleanup (select_record *, select_stuff *stuff) -{ - select_socket_info *si = (select_socket_info *) stuff->device_specific_socket; - select_printf ("si %p si->thread %p", si, si ? si->thread : NULL); - if (si && si->thread) - { - SetEvent (si->w4[0]); - /* Wait for thread to go away */ - si->thread->detach (); - ResetEvent (si->w4[0]); - stuff->device_specific_socket = NULL; - delete si; - } - select_printf ("returning"); -} - -select_record * -fhandler_socket::select_read (select_stuff *ss) -{ - select_record *s = ss->start.next; - if (!s->startup) - { - s->startup = start_thread_socket; - s->verify = verify_true; - s->cleanup = socket_cleanup; - } - s->peek = peek_socket; - s->read_ready = saw_shutdown_read (); - s->read_selected = true; - return s; -} - -select_record * -fhandler_socket::select_write (select_stuff *ss) -{ - select_record *s = ss->start.next; - if (!s->startup) - { - s->startup = start_thread_socket; - s->verify = verify_true; - s->cleanup = socket_cleanup; - } - s->peek = peek_socket; - s->write_ready = saw_shutdown_write () || connect_state () == unconnected; - s->write_selected = true; - if (connect_state () != unconnected) - { - s->except_ready = saw_shutdown_write () || saw_shutdown_read (); - s->except_on_write = true; - } - return s; -} - -select_record * -fhandler_socket::select_except (select_stuff *ss) -{ - select_record *s = ss->start.next; - if (!s->startup) - { - s->startup = start_thread_socket; - s->verify = verify_true; - s->cleanup = socket_cleanup; - } - s->peek = peek_socket; - /* FIXME: Is this right? Should these be used as criteria for except? */ - s->except_ready = saw_shutdown_write () || saw_shutdown_read (); - s->except_selected = true; - return s; -} - -static int -peek_windows (select_record *me, bool) -{ - MSG m; - HANDLE h; - set_handle_or_return_if_not_open (h, me); - - if (me->read_selected && me->read_ready) - return 1; - - if (PeekMessage (&m, (HWND) h, 0, 0, PM_NOREMOVE)) - { - me->read_ready = true; - select_printf ("window %d(%p) ready", me->fd, me->fh->get_handle ()); - return 1; - } - - select_printf ("window %d(%p) not ready", me->fd, me->fh->get_handle ()); - return me->write_ready; -} - -static int -verify_windows (select_record *me, fd_set *rfds, fd_set *wfds, - fd_set *efds) -{ - return peek_windows (me, true); -} - -select_record * -fhandler_windows::select_read (select_stuff *ss) -{ - select_record *s = ss->start.next; - if (!s->startup) - { - s->startup = no_startup; - } - s->verify = verify_windows; - s->peek = peek_windows; - s->read_selected = true; - s->read_ready = false; - s->h = get_handle (); - s->windows_handle = true; - return s; -} - -select_record * -fhandler_windows::select_write (select_stuff *ss) -{ - select_record *s = ss->start.next; - if (!s->startup) - { - s->startup = no_startup; - s->verify = verify_ok; - } - s->peek = peek_windows; - s->h = get_handle (); - s->write_selected = true; - s->write_ready = true; - s->windows_handle = true; - return s; -} - -select_record * -fhandler_windows::select_except (select_stuff *ss) -{ - select_record *s = ss->start.next; - if (!s->startup) - { - s->startup = no_startup; - s->verify = verify_ok; - } - s->peek = peek_windows; - s->h = get_handle (); - s->except_selected = true; - s->except_ready = false; - s->windows_handle = true; - return s; -} - -static int -peek_mailslot (select_record *me, bool) -{ - HANDLE h; - set_handle_or_return_if_not_open (h, me); - - if (me->read_selected && me->read_ready) - return 1; - DWORD msgcnt = 0; - if (!GetMailslotInfo (h, NULL, NULL, &msgcnt, NULL)) - { - select_printf ("mailslot %d(%p) error %E", me->fd, h); - return 1; - } - if (msgcnt > 0) - { - me->read_ready = true; - select_printf ("mailslot %d(%p) ready", me->fd, h); - return 1; - } - select_printf ("mailslot %d(%p) not ready", me->fd, h); - return 0; -} - -static int -verify_mailslot (select_record *me, fd_set *rfds, fd_set *wfds, - fd_set *efds) -{ - return peek_mailslot (me, true); -} - -static int start_thread_mailslot (select_record *me, select_stuff *stuff); - -static DWORD WINAPI -thread_mailslot (void *arg) -{ - select_mailslot_info *mi = (select_mailslot_info *) arg; - bool gotone = false; - DWORD sleep_time = 0; - - for (;;) - { - select_record *s = mi->start; - while ((s = s->next)) - if (s->startup == start_thread_mailslot) - { - if (peek_mailslot (s, true)) - gotone = true; - if (mi->stop_thread) - { - select_printf ("stopping"); - goto out; - } - } - /* Paranoid check */ - if (mi->stop_thread) - { - select_printf ("stopping from outer loop"); - break; - } - if (gotone) - break; - Sleep (sleep_time >> 3); - if (sleep_time < 80) - ++sleep_time; - } -out: - return 0; -} - -static int -start_thread_mailslot (select_record *me, select_stuff *stuff) -{ - if (stuff->device_specific_mailslot) - { - me->h = *((select_mailslot_info *) stuff->device_specific_mailslot)->thread; - return 1; - } - select_mailslot_info *mi = new select_mailslot_info; - mi->start = &stuff->start; - mi->stop_thread = false; - mi->thread = new cygthread (thread_mailslot, 0, mi, "select_mailslot"); - me->h = *mi->thread; - if (!me->h) - return 0; - stuff->device_specific_mailslot = mi; - return 1; -} - -static void -mailslot_cleanup (select_record *, select_stuff *stuff) -{ - select_mailslot_info *mi = (select_mailslot_info *) stuff->device_specific_mailslot; - if (mi && mi->thread) - { - mi->stop_thread = true; - mi->thread->detach (); - delete mi; - stuff->device_specific_mailslot = NULL; - } -} - -select_record * -fhandler_mailslot::select_read (select_stuff *ss) -{ - select_record *s = ss->start.next; - s->startup = start_thread_mailslot; - s->peek = peek_mailslot; - s->verify = verify_mailslot; - s->cleanup = mailslot_cleanup; - s->read_selected = true; - s->read_ready = false; - return s; -} diff --git a/winsup/cygwin/select.h b/winsup/cygwin/select.h deleted file mode 100644 index 743222ebd..000000000 --- a/winsup/cygwin/select.h +++ /dev/null @@ -1,97 +0,0 @@ -/* select.h - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SELECT_H_ -#define _SELECT_H_ - -struct select_record -{ - int fd; - HANDLE h; - fhandler_base *fh; - int thread_errno; - bool windows_handle; - bool read_ready, write_ready, except_ready; - bool read_selected, write_selected, except_selected; - bool except_on_write; - int (*startup) (select_record *me, class select_stuff *stuff); - int (*peek) (select_record *, bool); - int (*verify) (select_record *me, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds); - void (*cleanup) (select_record *me, class select_stuff *stuff); - struct select_record *next; - void set_select_errno () {__seterrno (); thread_errno = errno;} - int saw_error () {return thread_errno;} - select_record () {} - select_record (int): fd (0), h (NULL), fh (NULL), thread_errno (0), - windows_handle (false), read_ready (false), write_ready (false), - except_ready (false), read_selected (false), write_selected (false), - except_selected (false), except_on_write (false), - startup (NULL), peek (NULL), verify (NULL), cleanup (NULL), - next (NULL) {} -}; - -struct select_info -{ - cygthread *thread; - bool stop_thread; - select_record *start; - select_info () {} -}; - -struct select_pipe_info: public select_info -{ - DWORD n; - HANDLE w4[MAXIMUM_WAIT_OBJECTS]; - select_pipe_info (); - ~select_pipe_info (); - void add_watch_handle (fhandler_pipe *); -}; - -struct select_socket_info: public select_info -{ - int num_w4; - LONG *ser_num; - HANDLE *w4; -}; - -struct select_serial_info: public select_info -{ -}; - -struct select_mailslot_info: public select_info -{ -}; - -class select_stuff -{ -public: - ~select_stuff (); - bool always_ready, windows_used; - select_record start; - - select_pipe_info *device_specific_pipe; - select_socket_info *device_specific_socket; - select_serial_info *device_specific_serial; - select_mailslot_info *device_specific_mailslot; - - bool test_and_set (int i, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds); - int poll (fd_set *readfds, fd_set *writefds, fd_set *exceptfds); - int wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds, DWORD ms); - void cleanup (); - select_stuff (): always_ready (0), windows_used (0), start (0), - device_specific_pipe (0), - device_specific_socket (0), - device_specific_serial (0), - device_specific_mailslot (0) {} -}; -#endif /* _SELECT_H_ */ diff --git a/winsup/cygwin/sem.cc b/winsup/cygwin/sem.cc deleted file mode 100644 index a87ee3269..000000000 --- a/winsup/cygwin/sem.cc +++ /dev/null @@ -1,138 +0,0 @@ -/* sem.cc: XSI IPC interface for Cygwin. - - Copyright 2003, 2004, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include - -#include "sigproc.h" - -#include "cygserver_sem.h" -#include "cygtls.h" - -/* - * client_request_sem Constructors - */ - -client_request_sem::client_request_sem (int semid, - int semnum, - int cmd, - union semun *arg) - : client_request (CYGSERVER_REQUEST_SEM, &_parameters, sizeof (_parameters)) -{ - _parameters.in.semop = SEMOP_semctl; - ipc_set_proc_info (_parameters.in.ipcblk); - - _parameters.in.ctlargs.semid = semid; - _parameters.in.ctlargs.semnum = semnum; - _parameters.in.ctlargs.cmd = cmd; - _parameters.in.ctlargs.arg = arg; - - msglen (sizeof (_parameters.in)); -} - -client_request_sem::client_request_sem (key_t key, - int nsems, - int semflg) - : client_request (CYGSERVER_REQUEST_SEM, &_parameters, sizeof (_parameters)) -{ - _parameters.in.semop = SEMOP_semget; - ipc_set_proc_info (_parameters.in.ipcblk); - - _parameters.in.getargs.key = key; - _parameters.in.getargs.nsems = nsems; - _parameters.in.getargs.semflg = semflg; - - msglen (sizeof (_parameters.in)); -} - -client_request_sem::client_request_sem (int semid, - struct sembuf *sops, - size_t nsops) - : client_request (CYGSERVER_REQUEST_SEM, &_parameters, sizeof (_parameters)) -{ - _parameters.in.semop = SEMOP_semop; - ipc_set_proc_info (_parameters.in.ipcblk); - - _parameters.in.opargs.semid = semid; - _parameters.in.opargs.sops = sops; - _parameters.in.opargs.nsops = nsops; - - msglen (sizeof (_parameters.in)); -} - -/* - * XSI semaphore API. These are exported by the DLL. - */ - -extern "C" int -semctl (int semid, int semnum, int cmd, ...) -{ - union semun arg = {0}; - if (cmd == IPC_STAT || cmd == IPC_SET || cmd == IPC_INFO || cmd == SEM_INFO - || cmd == GETALL || cmd == SETALL || cmd == SETVAL) - { - va_list ap; - va_start (ap, cmd); - arg = va_arg (ap, union semun); - va_end (ap); - } - syscall_printf ("semctl (semid = %d, semnum = %d, cmd = %d, arg.val = 0x%x)", - semid, semnum, cmd, arg.val); - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - client_request_sem request (semid, semnum, cmd, &arg); - if (request.make_request () == -1 || request.retval () == -1) - { - syscall_printf ("-1 [%d] = semctl ()", request.error_code ()); - set_errno (request.error_code ()); - if (request.error_code () == ENOSYS) - raise (SIGSYS); - return -1; - } - return request.retval (); -} - -extern "C" int -semget (key_t key, int nsems, int semflg) -{ - syscall_printf ("semget (key = %U, nsems = %d, semflg = 0x%x)", - key, nsems, semflg); - client_request_sem request (key, nsems, semflg); - if (request.make_request () == -1 || request.retval () == -1) - { - syscall_printf ("-1 [%d] = semget ()", request.error_code ()); - set_errno (request.error_code ()); - if (request.error_code () == ENOSYS) - raise (SIGSYS); - return -1; - } - return request.retval (); -} - -extern "C" int -semop (int semid, struct sembuf *sops, size_t nsops) -{ - syscall_printf ("semop (semid = %d, sops = %p, nsops = %d)", - semid, sops, nsops); - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - client_request_sem request (semid, sops, nsops); - if (request.make_request () == -1 || request.retval () == -1) - { - syscall_printf ("-1 [%d] = semop ()", request.error_code ()); - set_errno (request.error_code ()); - if (request.error_code () == ENOSYS) - raise (SIGSYS); - return -1; - } - return request.retval (); -} diff --git a/winsup/cygwin/setlsapwd.cc b/winsup/cygwin/setlsapwd.cc deleted file mode 100644 index 7622de370..000000000 --- a/winsup/cygwin/setlsapwd.cc +++ /dev/null @@ -1,89 +0,0 @@ -/* setlsapwd.cc: Set LSA private data password for current user. - - Copyright 2008, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "shared_info.h" -#include "cygerrno.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "security.h" -#include "cygserver_setpwd.h" -#include "ntdll.h" -#include -#include -#include - -/* - * client_request_setpwd Constructor - */ - -client_request_setpwd::client_request_setpwd (PUNICODE_STRING passwd) - : client_request (CYGSERVER_REQUEST_SETPWD, &_parameters, sizeof (_parameters)) -{ - memset (_parameters.in.passwd, 0, sizeof _parameters.in.passwd); - if (passwd->Length > 0 && passwd->Length < 256 * sizeof (WCHAR)) - wcpncpy (_parameters.in.passwd, passwd->Buffer, 255); - - msglen (sizeof (_parameters.in)); -} - -unsigned long -setlsapwd (const char *passwd) -{ - unsigned long ret = (unsigned long) -1; - HANDLE lsa = INVALID_HANDLE_VALUE; - WCHAR sid[128]; - WCHAR key_name[128 + wcslen (CYGWIN_LSA_KEY_PREFIX)]; - PWCHAR data_buf = NULL; - UNICODE_STRING key; - UNICODE_STRING data; - - wcpcpy (wcpcpy (key_name, CYGWIN_LSA_KEY_PREFIX), - cygheap->user.get_windows_id (sid)); - RtlInitUnicodeString (&key, key_name); - if (!passwd || ! *passwd - || sys_mbstowcs_alloc (&data_buf, HEAP_NOTHEAP, passwd)) - { - memset (&data, 0, sizeof data); - if (data_buf) - RtlInitUnicodeString (&data, data_buf); - /* First try it locally. Works for admin accounts. */ - if ((lsa = open_local_policy (POLICY_CREATE_SECRET)) - != INVALID_HANDLE_VALUE) - { - NTSTATUS status = LsaStorePrivateData (lsa, &key, - data.Length ? &data : NULL); - /* Success or we're trying to remove a password entry which doesn't - exist. */ - if (NT_SUCCESS (status) - || (data.Length == 0 && status == STATUS_OBJECT_NAME_NOT_FOUND)) - ret = 0; - else - __seterrno_from_nt_status (status); - LsaClose (lsa); - } - else if (ret) - { - client_request_setpwd request (&data); - if (request.make_request () == -1 || request.error_code ()) - set_errno (request.error_code ()); - else - ret = 0; - } - if (data_buf) - { - memset (data.Buffer, 0, data.Length); - free (data_buf); - } - } - return ret; -} diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc deleted file mode 100644 index 47fc50ec5..000000000 --- a/winsup/cygwin/shared.cc +++ /dev/null @@ -1,495 +0,0 @@ -/* shared.cc: shared data area support. - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "miscfuncs.h" -#include -#include "cygerrno.h" -#include "pinfo.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "heap.h" -#include "shared_info_magic.h" -#include "registry.h" -#include "cygwin_version.h" -#include "pwdgrp.h" -#include "ntdll.h" -#include -#include -#include -#include - -shared_info NO_COPY *cygwin_shared; -user_info NO_COPY *user_shared; -HANDLE NO_COPY cygwin_shared_h; -HANDLE NO_COPY cygwin_user_h; - -WCHAR installation_root[PATH_MAX] __attribute__((section (".cygwin_dll_common"), shared)); -UNICODE_STRING installation_key __attribute__((section (".cygwin_dll_common"), shared)); -WCHAR installation_key_buf[18] __attribute__((section (".cygwin_dll_common"), shared)); -static bool inst_root_inited; - -/* Use absolute path of cygwin1.dll to derive the Win32 dir which - is our installation_root. Note that we can't handle Cygwin installation - root dirs of more than 4K path length. I assume that's ok... - - This function also generates the installation_key value. It's a 64 bit - hash value based on the path of the Cygwin DLL itself. It's subsequently - used when generating shared object names. Thus, different Cygwin - installations generate different object names and so are isolated from - each other. - - Having this information, the installation key together with the - installation root path is written to the registry. The idea is that - cygcheck can print the paths into which the Cygwin DLL has been - installed for debugging purposes. - - Last but not least, the new cygwin properties datastrcuture is checked - for the "disabled_key" value, which is used to determine whether the - installation key is actually added to all object names or not. This is - used as a last resort for debugging purposes, usually. However, there - could be another good reason to re-enable object name collisions between - multiple Cygwin DLLs, which we're just not aware of right now. Cygcheck - can be used to change the value in an existing Cygwin DLL binary. */ - -void -init_installation_root () -{ - if (!GetModuleFileNameW (cygwin_hmodule, installation_root, PATH_MAX)) - api_fatal ("Can't initialize Cygwin installation root dir.\n" - "GetModuleFileNameW(%p, %p, %u), %E", - cygwin_hmodule, installation_root, PATH_MAX); - PWCHAR p = installation_root; - if (wcsncmp (p, L"\\\\?\\", 4)) /* No long path prefix. */ - { - if (!wcsncasecmp (p, L"\\\\", 2)) /* UNC */ - { - p = wcpcpy (p, L"\\??\\UN"); - GetModuleFileNameW (cygwin_hmodule, p, PATH_MAX - 6); - *p = L'C'; - } - else - { - p = wcpcpy (p, L"\\??\\"); - GetModuleFileNameW (cygwin_hmodule, p, PATH_MAX - 4); - } - } - installation_root[1] = L'?'; - - RtlInitEmptyUnicodeString (&installation_key, installation_key_buf, - sizeof installation_key_buf); - RtlInt64ToHexUnicodeString (hash_path_name (0, installation_root), - &installation_key, FALSE); - - PWCHAR w = wcsrchr (installation_root, L'\\'); - if (w) - { - *w = L'\0'; - w = wcsrchr (installation_root, L'\\'); - } - if (!w) - api_fatal ("Can't initialize Cygwin installation root dir.\n" - "Invalid DLL path"); - *w = L'\0'; - - for (int i = 1; i >= 0; --i) - { - reg_key r (i, KEY_WRITE, CYGWIN_INFO_INSTALLATIONS_NAME, NULL); - if (r.set_string (installation_key_buf, installation_root) - == ERROR_SUCCESS) - break; - } - - if (cygwin_props.disable_key) - { - installation_key.Length = 0; - installation_key.Buffer[0] = L'\0'; - } - - inst_root_inited = true; -} - -/* This function returns a handle to the top-level directory in the global - NT namespace used to implement global objects including shared memory. */ - -HANDLE -get_shared_parent_dir () -{ - static HANDLE dir; - UNICODE_STRING uname; - OBJECT_ATTRIBUTES attr; - NTSTATUS status; - - if (!dir) - { - WCHAR bnoname[MAX_PATH]; - __small_swprintf (bnoname, L"\\BaseNamedObjects\\%s%s-%S", - cygwin_version.shared_id, - _cygwin_testing ? cygwin_version.dll_build_date : "", - &installation_key); - RtlInitUnicodeString (&uname, bnoname); - InitializeObjectAttributes (&attr, &uname, OBJ_INHERIT | OBJ_OPENIF, - NULL, everyone_sd (CYG_SHARED_DIR_ACCESS)); - status = NtCreateDirectoryObject (&dir, CYG_SHARED_DIR_ACCESS, &attr); - if (!NT_SUCCESS (status)) - api_fatal ("NtCreateDirectoryObject(%S): %p", &uname, status); - } - return dir; -} - -HANDLE -get_session_parent_dir () -{ - static HANDLE dir; - UNICODE_STRING uname; - OBJECT_ATTRIBUTES attr; - NTSTATUS status; - - if (!dir) - { - PROCESS_SESSION_INFORMATION psi; - status = NtQueryInformationProcess (NtCurrentProcess (), - ProcessSessionInformation, - &psi, sizeof psi, NULL); - if (!NT_SUCCESS (status) || psi.SessionId == 0) - dir = get_shared_parent_dir (); - else - { - WCHAR bnoname[MAX_PATH]; - __small_swprintf (bnoname, - L"\\Sessions\\BNOLINKS\\%d\\%s%s-%S", - psi.SessionId, cygwin_version.shared_id, - _cygwin_testing ? cygwin_version.dll_build_date : "", - &installation_key); - RtlInitUnicodeString (&uname, bnoname); - InitializeObjectAttributes (&attr, &uname, OBJ_INHERIT | OBJ_OPENIF, - NULL, everyone_sd(CYG_SHARED_DIR_ACCESS)); - status = NtCreateDirectoryObject (&dir, CYG_SHARED_DIR_ACCESS, &attr); - if (!NT_SUCCESS (status)) - api_fatal ("NtCreateDirectoryObject(%S): %p", &uname, status); - } - } - return dir; -} - -char * __stdcall -shared_name (char *ret_buf, const char *str, int num) -{ - __small_sprintf (ret_buf, "%s.%d", str, num); - return ret_buf; -} - -WCHAR * __stdcall -shared_name (WCHAR *ret_buf, const WCHAR *str, int num) -{ - __small_swprintf (ret_buf, L"%W.%d", str, num); - return ret_buf; -} - -#define page_const (65535) -#define pround(n) (((size_t) (n) + page_const) & ~page_const) - -static ptrdiff_t offsets[] = -{ - - pround (sizeof (shared_info)) - - pround (sizeof (user_info)) - - pround (sizeof (console_state)) - - pround (sizeof (_pinfo)), - - pround (sizeof (user_info)) - - pround (sizeof (console_state)) - - pround (sizeof (_pinfo)), - - pround (sizeof (console_state)) - - pround (sizeof (_pinfo)), - - pround (sizeof (_pinfo)), - 0 -}; - -#define off_addr(x) ((void *)((caddr_t) cygwin_hmodule + offsets[x])) - -void * __stdcall -open_shared (const WCHAR *name, int n, HANDLE& shared_h, DWORD size, - shared_locations& m, PSECURITY_ATTRIBUTES psa, DWORD access) -{ - void *shared; - - void *addr; - if (m == SH_JUSTCREATE || m == SH_JUSTOPEN) - addr = NULL; - else - { - addr = off_addr (m); - VirtualFree (addr, 0, MEM_RELEASE); - } - - WCHAR map_buf[MAX_PATH]; - WCHAR *mapname = NULL; - - if (shared_h) - m = SH_JUSTOPEN; - else - { - if (name) - mapname = shared_name (map_buf, name, n); - if (m == SH_JUSTOPEN) - shared_h = OpenFileMappingW (access, FALSE, mapname); - else - { - shared_h = CreateFileMappingW (INVALID_HANDLE_VALUE, psa, - PAGE_READWRITE, 0, size, mapname); - if (GetLastError () == ERROR_ALREADY_EXISTS) - m = SH_JUSTOPEN; - } - if (shared_h) - /* ok! */; - else if (m != SH_JUSTOPEN) - api_fatal ("CreateFileMapping %W, %E. Terminating.", mapname); - else - return NULL; - } - - shared = (shared_info *) - MapViewOfFileEx (shared_h, access, 0, 0, 0, addr); - - if (!shared && addr) - { - shared = (shared_info *) MapViewOfFileEx (shared_h, - FILE_MAP_READ|FILE_MAP_WRITE, - 0, 0, 0, NULL); -#ifdef DEBUGGING - system_printf ("relocating shared object %W(%d) from %p to %p", name, n, addr, shared); -#endif - offsets[0] = 0; - } - - if (!shared) - api_fatal ("MapViewOfFileEx '%W'(%p), %E. Terminating.", mapname, shared_h); - - if (m == SH_CYGWIN_SHARED && offsets[0]) - { - ptrdiff_t delta = (caddr_t) shared - (caddr_t) off_addr (0); - offsets[0] = (caddr_t) shared - (caddr_t) cygwin_hmodule; - for (int i = SH_USER_SHARED + 1; i < SH_TOTAL_SIZE; i++) - { - unsigned size = offsets[i + 1] - offsets[i]; - offsets[i] += delta; - if (!VirtualAlloc (off_addr (i), size, MEM_RESERVE, PAGE_NOACCESS)) - continue; /* oh well */ - } - offsets[SH_TOTAL_SIZE] += delta; - } - - debug_printf ("name %W, n %d, shared %p (wanted %p), h %p", mapname, n, shared, addr, shared_h); - - return shared; -} - -/* Second half of user shared initialization: Initialize content. */ -void -user_shared_initialize () -{ - DWORD sversion = (DWORD) InterlockedExchange ((LONG *) &user_shared->version, USER_VERSION_MAGIC); - /* Wait for initialization of the Cygwin per-user shared, if necessary */ - if (!sversion) - { - cygpsid sid (cygheap->user.sid ()); - struct passwd *pw = internal_getpwsid (sid); - /* Correct the user name with what's defined in /etc/passwd before - loading the user fstab file. */ - if (pw) - cygheap->user.set_name (pw->pw_name); - user_shared->mountinfo.init (); /* Initialize the mount table. */ - user_shared->cb = sizeof (*user_shared); - } - else - { - while (!user_shared->cb) - low_priority_sleep (0); // Should be hit only very very rarely - if (user_shared->version != sversion) - multiple_cygwin_problem ("user shared memory version", user_shared->version, sversion); - else if (user_shared->cb != sizeof (*user_shared)) - multiple_cygwin_problem ("user shared memory size", user_shared->cb, sizeof (*user_shared)); - } -} - -/* First half of user shared initialization: Create shared mem region. */ -void -user_shared_create (bool reinit) -{ - WCHAR name[UNLEN + 1] = L""; /* Large enough for SID */ - - if (reinit) - { - if (!UnmapViewOfFile (user_shared)) - debug_printf("UnmapViewOfFile %E"); - if (!ForceCloseHandle (cygwin_user_h)) - debug_printf("CloseHandle %E"); - cygwin_user_h = NULL; - } - - if (!cygwin_user_h) - cygheap->user.get_windows_id (name); - - shared_locations sh_user_shared = SH_USER_SHARED; - user_shared = (user_info *) open_shared (name, USER_VERSION, - cygwin_user_h, sizeof (user_info), - sh_user_shared, &sec_none); - debug_printf ("opening user shared for '%W' at %p", name, user_shared); - ProtectHandleINH (cygwin_user_h); - debug_printf ("user shared version %x", user_shared->version); - if (reinit) - user_shared_initialize (); -} - -void __stdcall -shared_destroy () -{ - ForceCloseHandle (cygwin_shared_h); - UnmapViewOfFile (cygwin_shared); - ForceCloseHandle (cygwin_user_h); - UnmapViewOfFile (user_shared); -} - -/* Initialize obcaseinsensitive. Default to case insensitive on pre-XP. */ -void -shared_info::init_obcaseinsensitive () -{ - HKEY key; - DWORD size = sizeof (DWORD); - - obcaseinsensitive = 1; - if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, - "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\kernel", - 0, KEY_READ, &key) == ERROR_SUCCESS) - { - RegQueryValueEx (key, "obcaseinsensitive", NULL, NULL, - (LPBYTE) &obcaseinsensitive, &size); - RegCloseKey (key); - } - debug_printf ("obcaseinsensitive set to %d", obcaseinsensitive); -} - -void -shared_info::initialize () -{ - DWORD sversion = (DWORD) InterlockedExchange ((LONG *) &version, SHARED_VERSION_MAGIC); - if (sversion) - { - if (sversion != SHARED_VERSION_MAGIC) - { - InterlockedExchange ((LONG *) &version, sversion); - multiple_cygwin_problem ("system shared memory version", sversion, SHARED_VERSION_MAGIC); - } - while (!cb) - low_priority_sleep (0); // Should be hit only very very rarely - } - - heap_init (); - get_session_parent_dir (); /* Create session dir if first process. */ - - if (!sversion) - { - init_obcaseinsensitive ();/* Initialize obcaseinsensitive. */ - tty.init (); /* Initialize tty table. */ - mt.initialize (); /* Initialize shared tape information. */ - cb = sizeof (*this); /* Do last, after all shared memory initialization */ - } - - if (cb != SHARED_INFO_CB) - system_printf ("size of shared memory region changed from %u to %u", - SHARED_INFO_CB, cb); -} - -void -memory_init (bool init_cygheap) -{ - getpagesize (); - - /* Initialize the Cygwin heap, if necessary */ - if (init_cygheap) - { - cygheap_init (); - cygheap->user.init (); - } - - /* Initialize installation root dir. */ - if (!installation_root[0]) - init_installation_root (); - - /* Initialize general shared memory */ - shared_locations sh_cygwin_shared; - cygwin_shared = (shared_info *) open_shared (L"shared", - CYGWIN_VERSION_SHARED_DATA, - cygwin_shared_h, - sizeof (*cygwin_shared), - sh_cygwin_shared = SH_CYGWIN_SHARED); - /* Defer debug output printing the installation root and installation key - up to this point. Debug output except for system_printf requires - the global shared memory to exist. */ - if (inst_root_inited) - debug_printf ("Installation root: <%W> key: <%S>", - installation_root, &installation_key); - cygwin_shared->initialize (); - user_shared_create (false); -} - -unsigned -shared_info::heap_slop_size () -{ - if (!heap_slop_inited) - { - /* Fetch from registry, first user then local machine. */ - for (int i = 0; i < 2; i++) - { - reg_key reg (i, KEY_READ, NULL); - - if ((heap_slop = reg.get_int ("heap_slop_in_mb", 0))) - break; - heap_slop = wincap.heapslop (); - } - heap_slop <<= 20; - heap_slop_inited = true; - } - - return heap_slop; -} - -unsigned -shared_info::heap_chunk_size () -{ - if (!heap_chunk) - { - /* Fetch from registry, first user then local machine. */ - for (int i = 0; i < 2; i++) - { - reg_key reg (i, KEY_READ, NULL); - - /* Note that reserving a huge amount of heap space does not result in - the use of swap since we are not committing it. */ - /* FIXME: We should not be restricted to a fixed size heap no matter - what the fixed size is. */ - - if ((heap_chunk = reg.get_int ("heap_chunk_in_mb", 0))) - break; - heap_chunk = 384; /* Default */ - } - - if (heap_chunk < 4) - heap_chunk = 4 * 1024 * 1024; - else - heap_chunk <<= 20; - if (!heap_chunk) - heap_chunk = 384 * 1024 * 1024; - } - - return heap_chunk; -} diff --git a/winsup/cygwin/shared_info.h b/winsup/cygwin/shared_info.h deleted file mode 100644 index 1fcb8ff86..000000000 --- a/winsup/cygwin/shared_info.h +++ /dev/null @@ -1,108 +0,0 @@ -/* shared_info.h: shared info for cygwin - - Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "tty.h" -#include "security.h" -#include "mtinfo.h" -#include "limits.h" -#include "mount.h" - -class user_info -{ -public: - DWORD version; - DWORD cb; - bool warned_msdos; - mount_info mountinfo; -}; -/******** Shared Info ********/ -/* Data accessible to all tasks */ - -#define SHARED_VERSION (unsigned)(cygwin_version.api_major << 8 | \ - cygwin_version.api_minor) -#define SHARED_VERSION_MAGIC CYGWIN_VERSION_MAGIC (SHARED_MAGIC, SHARED_VERSION) - -#define SHARED_INFO_CB 31136 - -#define CURR_SHARED_MAGIC 0x18da899eU - -#define USER_VERSION 1 // increment when mount table changes and -#define USER_VERSION_MAGIC CYGWIN_VERSION_MAGIC (USER_MAGIC, USER_VERSION) -#define CURR_USER_MAGIC 0xb2232e71U - -/* NOTE: Do not make gratuitous changes to the names or organization of the - below class. The layout is checksummed to determine compatibility between - different cygwin versions. */ -class shared_info -{ - DWORD version; - DWORD cb; - public: - unsigned heap_chunk; - bool heap_slop_inited; - unsigned heap_slop; - DWORD sys_mount_table_counter; - tty_list tty; - LONG last_used_bindresvport; - DWORD obcaseinsensitive; - mtinfo mt; - - void initialize (); - void init_obcaseinsensitive (); - unsigned heap_chunk_size (); - unsigned heap_slop_size (); -}; - -extern shared_info *cygwin_shared; -extern user_info *user_shared; -#define mount_table (&(user_shared->mountinfo)) -extern HANDLE cygwin_user_h; - -enum shared_locations -{ - SH_CYGWIN_SHARED, - SH_USER_SHARED, - SH_SHARED_CONSOLE, - SH_MYSELF, - SH_TOTAL_SIZE, - SH_JUSTCREATE, - SH_JUSTOPEN - -}; - -void memory_init (bool) __attribute__ ((regparm(1))); -void __stdcall shared_destroy (); - -#define shared_align_past(p) \ - ((char *) (system_info.dwAllocationGranularity * \ - (((DWORD) ((p) + 1) + system_info.dwAllocationGranularity - 1) / \ - system_info.dwAllocationGranularity))) - -#ifdef _FHANDLER_H_ -struct console_state -{ - tty_min tty_min_state; - dev_console dev_state; -}; -#endif - -HANDLE get_shared_parent_dir (); -HANDLE get_session_parent_dir (); -char *__stdcall shared_name (char *, const char *, int); -WCHAR *__stdcall shared_name (WCHAR *, const WCHAR *, int); -void *__stdcall open_shared (const WCHAR *name, int n, HANDLE &shared_h, - DWORD size, shared_locations&, - PSECURITY_ATTRIBUTES psa = &sec_all, - DWORD access = FILE_MAP_READ | FILE_MAP_WRITE); -extern void user_shared_create (bool reinit); -extern void user_shared_initialize (); -extern void init_installation_root (); -extern WCHAR installation_root[PATH_MAX]; -extern UNICODE_STRING installation_key; diff --git a/winsup/cygwin/shm.cc b/winsup/cygwin/shm.cc deleted file mode 100644 index 8b41a38df..000000000 --- a/winsup/cygwin/shm.cc +++ /dev/null @@ -1,388 +0,0 @@ -/* shm.cc: XSI IPC interface for Cygwin. - - Copyright 2003, 2004, 2007, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include - -#include "pinfo.h" -#include "sigproc.h" - -#include "cygserver_shm.h" -#include "cygtls.h" -#include "sync.h" -#include "ntdll.h" - -/* - * client_request_shm Constructors - */ - -client_request_shm::client_request_shm (int shmid, - const void *shmaddr, - int shmflg) - : client_request (CYGSERVER_REQUEST_SHM, &_parameters, sizeof (_parameters)) -{ - _parameters.in.shmop = SHMOP_shmat; - ipc_set_proc_info (_parameters.in.ipcblk); - - _parameters.in.atargs.shmid = shmid; - _parameters.in.atargs.shmaddr = shmaddr; - _parameters.in.atargs.shmflg = shmflg; - - msglen (sizeof (_parameters.in)); -} - -client_request_shm::client_request_shm (int shmid, - int cmd, - struct shmid_ds *buf) - : client_request (CYGSERVER_REQUEST_SHM, &_parameters, sizeof (_parameters)) -{ - _parameters.in.shmop = SHMOP_shmctl; - ipc_set_proc_info (_parameters.in.ipcblk); - - _parameters.in.ctlargs.shmid = shmid; - _parameters.in.ctlargs.cmd = cmd; - _parameters.in.ctlargs.buf = buf; - - msglen (sizeof (_parameters.in)); -} - -client_request_shm::client_request_shm (const void *shmaddr) - : client_request (CYGSERVER_REQUEST_SHM, &_parameters, sizeof (_parameters)) -{ - _parameters.in.shmop = SHMOP_shmdt; - ipc_set_proc_info (_parameters.in.ipcblk); - - _parameters.in.dtargs.shmaddr = shmaddr; - - msglen (sizeof (_parameters.in)); -} - -client_request_shm::client_request_shm (key_t key, - size_t size, - int shmflg) - : client_request (CYGSERVER_REQUEST_SHM, &_parameters, sizeof (_parameters)) -{ - _parameters.in.shmop = SHMOP_shmget; - ipc_set_proc_info (_parameters.in.ipcblk); - - _parameters.in.getargs.key = key; - _parameters.in.getargs.size = size; - _parameters.in.getargs.shmflg = shmflg; - - msglen (sizeof (_parameters.in)); -} - -client_request_shm::client_request_shm (proc *p1) - : client_request (CYGSERVER_REQUEST_SHM, &_parameters, sizeof (_parameters)) -{ - _parameters.in.shmop = SHMOP_shmfork; - ipc_set_proc_info (_parameters.in.ipcblk); - - _parameters.in.forkargs = *p1; -} - -/* List of shmid's with file mapping HANDLE and size, returned by shmget. */ -struct shm_shmid_list { - SLIST_ENTRY (shm_shmid_list) ssh_next; - int shmid; - vm_object_t hdl; - size_t size; - int ref_count; -}; - -static SLIST_HEAD (, shm_shmid_list) ssh_list; - -/* List of attached mappings, as returned by shmat. */ -struct shm_attached_list { - SLIST_ENTRY (shm_attached_list) sph_next; - vm_object_t ptr; - shm_shmid_list *parent; - ULONG access; -}; - -static SLIST_HEAD (, shm_attached_list) sph_list; - -static NO_COPY muto shm_guard; -#define SLIST_LOCK() (shm_guard.init ("shm_guard")->acquire ()) -#define SLIST_UNLOCK() (shm_guard.release ()) - -int __stdcall -fixup_shms_after_fork () -{ - if (!SLIST_FIRST (&sph_list)) - return 0; - pinfo p (myself->ppid); - proc parent = { myself->ppid, p->dwProcessId, p->uid, p->gid }; - - client_request_shm request (&parent); - if (request.make_request () == -1 || request.retval () == -1) - { - syscall_printf ("-1 [%d] = fixup_shms_after_fork ()", request.error_code ()); - set_errno (request.error_code ()); - return 0; - } - shm_attached_list *sph_entry; - /* Reconstruct map from list... */ - SLIST_FOREACH (sph_entry, &sph_list, sph_next) - { - NTSTATUS status; - vm_object_t ptr = sph_entry->ptr; - ULONG viewsize = sph_entry->parent->size; - status = NtMapViewOfSection (sph_entry->parent->hdl, NtCurrentProcess (), - &ptr, 0, sph_entry->parent->size, NULL, - &viewsize, ViewShare, 0, sph_entry->access); - if (!NT_SUCCESS (status) || ptr != sph_entry->ptr) - api_fatal ("fixup_shms_after_fork: NtMapViewOfSection (%p), status %p. Terminating.", - sph_entry->ptr, status); - } - return 0; -} - -/* - * XSI shmaphore API. These are exported by the DLL. - */ - -extern "C" void * -shmat (int shmid, const void *shmaddr, int shmflg) -{ - syscall_printf ("shmat (shmid = %d, shmaddr = %p, shmflg = 0x%x)", - shmid, shmaddr, shmflg); - - SLIST_LOCK (); - shm_shmid_list *ssh_entry; - SLIST_FOREACH (ssh_entry, &ssh_list, ssh_next) - { - if (ssh_entry->shmid == shmid) - break; - } - if (!ssh_entry) - { - /* The shmid is unknown to this process so far. Try to get it from - the server if it exists. Use special internal call to shmget, - which interprets the key as a shmid and only returns a valid - shmid if one exists. Since shmctl inserts a new entry for this - shmid into ssh_list automatically, we just have to go through - that list again. If that still fails, well, bad luck. */ - if (shmid && shmget ((key_t) shmid, 0, IPC_KEY_IS_SHMID) != -1) - { - SLIST_FOREACH (ssh_entry, &ssh_list, ssh_next) - { - if (ssh_entry->shmid == shmid) - break; - } - } - if (!ssh_entry) - { - /* Invalid shmid */ - set_errno (EINVAL); - SLIST_UNLOCK (); - return (void *) -1; - } - } - /* Early increment ref counter. This allows further actions to run with - unlocked lists, because shmdt or shmctl(IPC_RMID) won't delete this - ssh_entry. */ - ++ssh_entry->ref_count; - SLIST_UNLOCK (); - - vm_object_t attach_va = NULL; - if (shmaddr) - { - if (shmflg & SHM_RND) - attach_va = (vm_object_t)((vm_offset_t)shmaddr & ~(SHMLBA-1)); - else - attach_va = (vm_object_t)shmaddr; - /* Don't even bother to call anything if shmaddr is NULL or - not aligned. */ - if (!attach_va || (vm_offset_t)attach_va % SHMLBA) - { - set_errno (EINVAL); - --ssh_entry->ref_count; - return (void *) -1; - } - } - /* Try allocating memory before calling cygserver. */ - shm_attached_list *sph_entry = new (shm_attached_list); - if (!sph_entry) - { - set_errno (ENOMEM); - --ssh_entry->ref_count; - return (void *) -1; - } - NTSTATUS status; - vm_object_t ptr = NULL; - ULONG viewsize = ssh_entry->size; - ULONG access = (shmflg & SHM_RDONLY) ? PAGE_READONLY : PAGE_READWRITE; - status = NtMapViewOfSection (ssh_entry->hdl, NtCurrentProcess (), &ptr, 0, - ssh_entry->size, NULL, &viewsize, ViewShare, - MEM_TOP_DOWN, access); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - delete sph_entry; - --ssh_entry->ref_count; - return (void *) -1; - } - /* Use returned ptr address as is, so it's stored using the exact value - in cygserver. */ - client_request_shm request (shmid, ptr, shmflg & ~SHM_RND); - if (request.make_request () == -1 || request.ptrval () == NULL) - { - syscall_printf ("-1 [%d] = shmat ()", request.error_code ()); - UnmapViewOfFile (ptr); - delete sph_entry; - set_errno (request.error_code ()); - --ssh_entry->ref_count; - if (request.error_code () == ENOSYS) - raise (SIGSYS); - return (void *) -1; - } - sph_entry->ptr = ptr; - sph_entry->parent = ssh_entry; - sph_entry->access = access; - SLIST_LOCK (); - SLIST_INSERT_HEAD (&sph_list, sph_entry, sph_next); - SLIST_UNLOCK (); - return ptr; -} - -extern "C" int -shmctl (int shmid, int cmd, struct shmid_ds *buf) -{ - syscall_printf ("shmctl (shmid = %d, cmd = %d, buf = 0x%x)", - shmid, cmd, buf); - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - client_request_shm request (shmid, cmd, buf); - if (request.make_request () == -1 || request.retval () == -1) - { - syscall_printf ("-1 [%d] = shmctl ()", request.error_code ()); - set_errno (request.error_code ()); - if (request.error_code () == ENOSYS) - raise (SIGSYS); - return -1; - } - if (cmd == IPC_RMID) - { - /* Cleanup */ - shm_shmid_list *ssh_entry, *ssh_next_entry; - SLIST_LOCK (); - SLIST_FOREACH_SAFE (ssh_entry, &ssh_list, ssh_next, ssh_next_entry) - { - if (ssh_entry->shmid == shmid) - { - /* Remove this entry from the list and close the handle - only if it's not in use anymore. */ - if (ssh_entry->ref_count <= 0) - { - SLIST_REMOVE (&ssh_list, ssh_entry, shm_shmid_list, ssh_next); - CloseHandle (ssh_entry->hdl); - delete ssh_entry; - } - break; - } - } - SLIST_UNLOCK (); - } - return request.retval (); -} - -extern "C" int -shmdt (const void *shmaddr) -{ - syscall_printf ("shmdt (shmaddr = %p)", shmaddr); - client_request_shm request (shmaddr); - if (request.make_request () == -1 || request.retval () == -1) - { - syscall_printf ("-1 [%d] = shmdt ()", request.error_code ()); - set_errno (request.error_code ()); - if (request.error_code () == ENOSYS) - raise (SIGSYS); - return -1; - } - shm_attached_list *sph_entry, *sph_next_entry; - /* Remove map from list... */ - SLIST_LOCK (); - SLIST_FOREACH_SAFE (sph_entry, &sph_list, sph_next, sph_next_entry) - { - if (sph_entry->ptr == shmaddr) - { - SLIST_REMOVE (&sph_list, sph_entry, shm_attached_list, sph_next); - /* ...unmap view... */ - UnmapViewOfFile (sph_entry->ptr); - /* ...and, if this was the last reference to this shared section... */ - shm_shmid_list *ssh_entry = sph_entry->parent; - if (--ssh_entry->ref_count <= 0) - { - /* ...delete parent entry and close handle. */ - SLIST_REMOVE (&ssh_list, ssh_entry, shm_shmid_list, ssh_next); - CloseHandle (ssh_entry->hdl); - delete ssh_entry; - } - delete sph_entry; - break; - } - } - SLIST_UNLOCK (); - return request.retval (); -} - -extern "C" int -shmget (key_t key, size_t size, int shmflg) -{ - syscall_printf ("shmget (key = %U, size = %d, shmflg = 0x%x)", - key, size, shmflg); - /* Try allocating memory before calling cygserver. */ - shm_shmid_list *ssh_new_entry = new (shm_shmid_list); - if (!ssh_new_entry) - { - set_errno (ENOMEM); - return -1; - } - client_request_shm request (key, size, shmflg); - if (request.make_request () == -1 || request.retval () == -1) - { - syscall_printf ("-1 [%d] = shmget ()", request.error_code ()); - delete ssh_new_entry; - set_errno (request.error_code ()); - if (request.error_code () == ENOSYS) - raise (SIGSYS); - return -1; - } - int shmid = request.retval (); /* Shared mem ID */ - vm_object_t hdl = request.objval (); /* HANDLE associated with it. */ - shm_shmid_list *ssh_entry; - SLIST_LOCK (); - SLIST_FOREACH (ssh_entry, &ssh_list, ssh_next) - { - if (ssh_entry->shmid == shmid) - { - /* We already maintain an entry for this shmid. That means, - the hdl returned by cygserver is a superfluous duplicate - of the original hdl maintained by cygserver. We can safely - delete it. */ - CloseHandle (hdl); - delete ssh_new_entry; - SLIST_UNLOCK (); - return shmid; - } - } - /* We arrive here only if shmid is a new one for this process. Add the - shmid and hdl value to the list. */ - ssh_new_entry->shmid = shmid; - ssh_new_entry->hdl = hdl; - ssh_new_entry->size = size; - ssh_new_entry->ref_count = 0; - SLIST_INSERT_HEAD (&ssh_list, ssh_new_entry, ssh_next); - SLIST_UNLOCK (); - return shmid; -} diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc deleted file mode 100644 index e12f63e2d..000000000 --- a/winsup/cygwin/signal.cc +++ /dev/null @@ -1,598 +0,0 @@ -/* signal.cc - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009 Red Hat, Inc. - - Written by Steve Chamberlain of Cygnus Support, sac@cygnus.com - Significant changes by Sergey Okhapkin - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include "pinfo.h" -#include "sigproc.h" -#include "cygtls.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" - -int sigcatchers; /* FIXME: Not thread safe. */ - -#define _SA_NORESTART 0x8000 - -static int sigaction_worker (int, const struct sigaction *, struct sigaction *, bool) - __attribute__ ((regparm (3))); - -#define sigtrapped(func) ((func) != SIG_IGN && (func) != SIG_DFL) - -static inline void -set_sigcatchers (void (*oldsig) (int), void (*cursig) (int)) -{ -#ifdef DEBUGGING - int last_sigcatchers = sigcatchers; -#endif - if (!sigtrapped (oldsig) && sigtrapped (cursig)) - sigcatchers++; - else if (sigtrapped (oldsig) && !sigtrapped (cursig)) - sigcatchers--; -#ifdef DEBUGGING - if (last_sigcatchers != sigcatchers) - sigproc_printf ("last %d, old %d, cur %p, cur %p", last_sigcatchers, - sigcatchers, oldsig, cursig); -#endif -} - -extern "C" _sig_func_ptr -signal (int sig, _sig_func_ptr func) -{ - sig_dispatch_pending (); - _sig_func_ptr prev; - - /* check that sig is in right range */ - if (sig < 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP) - { - set_errno (EINVAL); - syscall_printf ("SIG_ERR = signal (%d, %p)", sig, func); - return (_sig_func_ptr) SIG_ERR; - } - - prev = global_sigs[sig].sa_handler; - struct sigaction& gs = global_sigs[sig]; - if (gs.sa_flags & _SA_NORESTART) - gs.sa_flags &= ~SA_RESTART; - else - gs.sa_flags |= SA_RESTART; - - gs.sa_mask = SIGTOMASK (sig); - gs.sa_handler = func; - gs.sa_flags &= ~SA_SIGINFO; - - set_sigcatchers (prev, func); - - syscall_printf ("%p = signal (%d, %p)", prev, sig, func); - return prev; -} - -extern "C" int -nanosleep (const struct timespec *rqtp, struct timespec *rmtp) -{ - int res = 0; - sig_dispatch_pending (); - pthread_testcancel (); - - if ((unsigned int) rqtp->tv_nsec > 999999999) - { - set_errno (EINVAL); - return -1; - } - unsigned int sec = rqtp->tv_sec; - DWORD resolution = gtod.resolution (); - bool done = false; - DWORD req; - DWORD rem; - - while (!done) - { - /* Divide user's input into transactions no larger than 49.7 - days at a time. */ - if (sec > HIRES_DELAY_MAX / 1000) - { - req = ((HIRES_DELAY_MAX + resolution - 1) - / resolution * resolution); - sec -= HIRES_DELAY_MAX / 1000; - } - else - { - req = ((sec * 1000 + (rqtp->tv_nsec + 999999) / 1000000 - + resolution - 1) / resolution) * resolution; - sec = 0; - done = true; - } - - DWORD end_time = gtod.dmsecs () + req; - syscall_printf ("nanosleep (%ld)", req); - - int rc = cancelable_wait (signal_arrived, req); - if ((rem = end_time - gtod.dmsecs ()) > HIRES_DELAY_MAX) - rem = 0; - if (rc == WAIT_OBJECT_0) - { - _my_tls.call_signal_handler (); - set_errno (EINTR); - res = -1; - break; - } - } - - if (rmtp) - { - rmtp->tv_sec = sec + rem / 1000; - rmtp->tv_nsec = (rem % 1000) * 1000000; - if (sec) - { - rmtp->tv_nsec += rqtp->tv_nsec; - if (rmtp->tv_nsec >= 1000000000) - { - rmtp->tv_nsec -= 1000000000; - rmtp->tv_sec++; - } - } - } - - syscall_printf ("%d = nanosleep (%ld, %ld)", res, req, rem); - return res; -} - -extern "C" unsigned int -sleep (unsigned int seconds) -{ - struct timespec req, rem; - req.tv_sec = seconds; - req.tv_nsec = 0; - if (nanosleep (&req, &rem)) - return rem.tv_sec + (rem.tv_nsec > 0); - return 0; -} - -extern "C" unsigned int -usleep (useconds_t useconds) -{ - struct timespec req; - req.tv_sec = useconds / 1000000; - req.tv_nsec = (useconds % 1000000) * 1000; - int res = nanosleep (&req, NULL); - return res; -} - -extern "C" int -sigprocmask (int how, const sigset_t *set, sigset_t *oldset) -{ - return handle_sigprocmask (how, set, oldset, _my_tls.sigmask); -} - -int __stdcall -handle_sigprocmask (int how, const sigset_t *set, sigset_t *oldset, sigset_t& opmask) -{ - /* check that how is in right range */ - if (how != SIG_BLOCK && how != SIG_UNBLOCK && how != SIG_SETMASK) - { - syscall_printf ("Invalid how value %d", how); - set_errno (EINVAL); - return -1; - } - - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - if (oldset) - *oldset = opmask; - - if (set) - { - sigset_t newmask = opmask; - switch (how) - { - case SIG_BLOCK: - /* add set to current mask */ - newmask |= *set; - break; - case SIG_UNBLOCK: - /* remove set from current mask */ - newmask &= ~*set; - break; - case SIG_SETMASK: - /* just set it */ - newmask = *set; - break; - } - set_signal_mask (newmask, opmask); - } - return 0; -} - -int __stdcall -_pinfo::kill (siginfo_t& si) -{ - sig_dispatch_pending (); - - int res = 0; - bool sendSIGCONT; - - if (!exists ()) - { - set_errno (ESRCH); - return -1; - } - - if ((sendSIGCONT = (si.si_signo < 0))) - si.si_signo = -si.si_signo; - - DWORD this_process_state = process_state; - if (si.si_signo == 0) - /* ok */; - else if ((res = sig_send (this, si))) - { - sigproc_printf ("%d = sig_send, %E ", res); - res = -1; - } - else if (sendSIGCONT) - { - siginfo_t si2 = {0}; - si2.si_signo = SIGCONT; - si2.si_code = SI_KERNEL; - sig_send (this, si2); - } - - syscall_printf ("%d = _pinfo::kill (%d, %d), process_state %p", res, pid, - si.si_signo, this_process_state); - return res; -} - -int -raise (int sig) -{ - return kill (myself->pid, sig); -} - -static int -kill0 (pid_t pid, siginfo_t& si) -{ - syscall_printf ("kill (%d, %d)", pid, si.si_signo); - /* check that sig is in right range */ - if (si.si_signo < 0 || si.si_signo >= NSIG) - { - set_errno (EINVAL); - syscall_printf ("signal %d out of range", si.si_signo); - return -1; - } - - /* Silently ignore stop signals from a member of orphaned process group. - FIXME: Why??? */ - if (ISSTATE (myself, PID_ORPHANED) && - (si.si_signo == SIGTSTP || si.si_signo == SIGTTIN || si.si_signo == SIGTTOU)) - si.si_signo = 0; - - return (pid > 0) ? pinfo (pid)->kill (si) : kill_pgrp (-pid, si); -} - -int -killsys (pid_t pid, int sig) -{ - siginfo_t si = {0}; - si.si_signo = sig; - si.si_code = SI_KERNEL; - return kill0 (pid, si); -} - -int -kill (pid_t pid, int sig) -{ - siginfo_t si = {0}; - si.si_signo = sig; - si.si_code = SI_USER; - return kill0 (pid, si); -} - -int -kill_pgrp (pid_t pid, siginfo_t& si) -{ - int res = 0; - int found = 0; - int killself = 0; - - sigproc_printf ("pid %d, signal %d", pid, si.si_signo); - - winpids pids ((DWORD) PID_MAP_RW); - for (unsigned i = 0; i < pids.npids; i++) - { - _pinfo *p = pids[i]; - - if (!p->exists ()) - continue; - - /* Is it a process we want to kill? */ - if ((pid == 0 && (p->pgid != myself->pgid || p->ctty != myself->ctty)) || - (pid > 1 && p->pgid != pid) || - (si.si_signo < 0 && NOTSTATE (p, PID_STOPPED))) - continue; - sigproc_printf ("killing pid %d, pgrp %d, p->%s, %s", p->pid, p->pgid, - p->__ctty (), myctty ()); - if (p == myself) - killself++; - else if (p->kill (si)) - res = -1; - found++; - } - - if (killself && !exit_state && myself->kill (si)) - res = -1; - - if (!found) - { - set_errno (ESRCH); - res = -1; - } - syscall_printf ("%d = kill (%d, %d)", res, pid, si.si_signo); - return res; -} - -extern "C" int -killpg (pid_t pgrp, int sig) -{ - return kill (-pgrp, sig); -} - -extern "C" void -abort (void) -{ - _my_tls.incyg++; - sig_dispatch_pending (); - /* Ensure that SIGABRT can be caught regardless of blockage. */ - sigset_t sig_mask; - sigfillset (&sig_mask); - sigdelset (&sig_mask, SIGABRT); - set_signal_mask (sig_mask, _my_tls.sigmask); - - raise (SIGABRT); - _my_tls.call_signal_handler (); /* Call any signal handler */ - - /* Flush all streams as per SUSv2. */ - if (_GLOBAL_REENT->__cleanup) - _GLOBAL_REENT->__cleanup (_GLOBAL_REENT); - do_exit (SIGABRT); /* signal handler didn't exit. Goodbye. */ -} - -static int -sigaction_worker (int sig, const struct sigaction *newact, struct sigaction *oldact, bool isinternal) -{ - sig_dispatch_pending (); - /* check that sig is in right range */ - if (sig < 0 || sig >= NSIG) - { - set_errno (EINVAL); - sigproc_printf ("signal %d, newact %p, oldact %p", sig, newact, oldact); - syscall_printf ("SIG_ERR = sigaction signal %d out of range", sig); - return -1; - } - - struct sigaction oa = global_sigs[sig]; - - if (!newact) - sigproc_printf ("signal %d, newact %p, oa %p", sig, newact, oa, oa.sa_handler); - else - { - sigproc_printf ("signal %d, newact %p (handler %p), oa %p", sig, newact, newact->sa_handler, oa, oa.sa_handler); - if (sig == SIGKILL || sig == SIGSTOP) - { - set_errno (EINVAL); - return -1; - } - struct sigaction na = *newact; - struct sigaction& gs = global_sigs[sig]; - if (!isinternal) - na.sa_flags &= ~_SA_INTERNAL_MASK; - gs = na; - if (!(gs.sa_flags & SA_NODEFER)) - gs.sa_mask |= SIGTOMASK(sig); - if (gs.sa_handler == SIG_IGN) - sig_clear (sig); - if (gs.sa_handler == SIG_DFL && sig == SIGCHLD) - sig_clear (sig); - set_sigcatchers (oa.sa_handler, gs.sa_handler); - if (sig == SIGCHLD) - { - myself->process_state &= ~PID_NOCLDSTOP; - if (gs.sa_flags & SA_NOCLDSTOP) - myself->process_state |= PID_NOCLDSTOP; - } - } - - if (oldact) - { - *oldact = oa; - oa.sa_flags &= ~_SA_INTERNAL_MASK; - } - - return 0; -} - -extern "C" int -sigaction (int sig, const struct sigaction *newact, struct sigaction *oldact) -{ - return sigaction_worker (sig, newact, oldact, false); -} - -extern "C" int -sigaddset (sigset_t *set, const int sig) -{ - /* check that sig is in right range */ - if (sig <= 0 || sig >= NSIG) - { - set_errno (EINVAL); - syscall_printf ("SIG_ERR = sigaddset signal %d out of range", sig); - return -1; - } - - *set |= SIGTOMASK (sig); - return 0; -} - -extern "C" int -sigdelset (sigset_t *set, const int sig) -{ - /* check that sig is in right range */ - if (sig <= 0 || sig >= NSIG) - { - set_errno (EINVAL); - syscall_printf ("SIG_ERR = sigdelset signal %d out of range", sig); - return -1; - } - - *set &= ~SIGTOMASK (sig); - return 0; -} - -extern "C" int -sigismember (const sigset_t *set, int sig) -{ - /* check that sig is in right range */ - if (sig <= 0 || sig >= NSIG) - { - set_errno (EINVAL); - syscall_printf ("SIG_ERR = sigdelset signal %d out of range", sig); - return -1; - } - - if (*set & SIGTOMASK (sig)) - return 1; - else - return 0; -} - -extern "C" int -sigemptyset (sigset_t *set) -{ - *set = (sigset_t) 0; - return 0; -} - -extern "C" int -sigfillset (sigset_t *set) -{ - *set = ~((sigset_t) 0); - return 0; -} - -extern "C" int -sigsuspend (const sigset_t *set) -{ - return handle_sigsuspend (*set); -} - -extern "C" int -sigpause (int signal_mask) -{ - return handle_sigsuspend ((sigset_t) signal_mask); -} - -extern "C" int -pause (void) -{ - return handle_sigsuspend (_my_tls.sigmask); -} - -extern "C" int -siginterrupt (int sig, int flag) -{ - struct sigaction act; - sigaction (sig, NULL, &act); - if (flag) - { - act.sa_flags &= ~SA_RESTART; - act.sa_flags |= _SA_NORESTART; - } - else - { - act.sa_flags &= ~_SA_NORESTART; - act.sa_flags |= SA_RESTART; - } - return sigaction_worker (sig, &act, NULL, true); -} - -extern "C" int -sigwait (const sigset_t *set, int *sig_ptr) -{ - int sig = sigwaitinfo (set, NULL); - if (sig > 0) - *sig_ptr = sig; - return sig > 0 ? 0 : -1; -} - -extern "C" int -sigwaitinfo (const sigset_t *set, siginfo_t *info) -{ - pthread_testcancel (); - HANDLE h; - h = _my_tls.event = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL); - if (!h) - { - __seterrno (); - return -1; - } - - _my_tls.sigwait_mask = *set; - sig_dispatch_pending (true); - - int res; - switch (WaitForSingleObject (h, INFINITE)) - { - case WAIT_OBJECT_0: - if (!sigismember (set, _my_tls.infodata.si_signo)) - { - set_errno (EINTR); - res = -1; - } - else - { - if (info) - *info = _my_tls.infodata; - res = _my_tls.infodata.si_signo; - InterlockedExchange ((LONG *) &_my_tls.sig, (LONG) 0); - } - break; - default: - __seterrno (); - res = -1; - } - CloseHandle (h); - sigproc_printf ("returning sig %d", res); - return res; -} - -/* FIXME: SUSv3 says that this function should block until the signal has - actually been delivered. Currently, this will only happen when sending - signals to the current process. It will not happen when sending signals - to other processes. */ -extern "C" int -sigqueue (pid_t pid, int sig, const union sigval value) -{ - siginfo_t si = {0}; - pinfo dest (pid); - if (!dest) - { - set_errno (ESRCH); - return -1; - } - si.si_signo = sig; - si.si_code = SI_QUEUE; - si.si_value = value; - return sig_send (dest, si); -} diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc deleted file mode 100644 index e940ebe6c..000000000 --- a/winsup/cygwin/sigproc.cc +++ /dev/null @@ -1,1298 +0,0 @@ -/* sigproc.cc: inter/intra signal and sub process handler - - Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008 Red Hat, Inc. - - Written by Christopher Faylor - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "miscfuncs.h" -#include -#include -#include "cygerrno.h" -#include "pinfo.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "child_info_magic.h" -#include "shared_info.h" -#include "cygtls.h" -#include "sigproc.h" -#include "ntdll.h" - -/* - * Convenience defines - */ -#define WSSC 60000 // Wait for signal completion -#define WPSP 40000 // Wait for proc_subproc mutex - -#define no_signals_available(x) (!hwait_sig || hwait_sig == INVALID_HANDLE_VALUE || ((x) && myself->exitcode & EXITCODE_SET) || &_my_tls == _sig_tls) - -#define NPROCS 256 - -/* - * Global variables - */ -struct sigaction *global_sigs; - -const char *__sp_fn ; -int __sp_ln; - -char NO_COPY myself_nowait_dummy[1] = {'0'};// Flag to sig_send that signal goes to - // current process but no wait is required -HANDLE NO_COPY signal_arrived; // Event signaled when a signal has - // resulted in a user-specified - // function call - -#define Static static NO_COPY - -HANDLE NO_COPY sigCONT; // Used to "STOP" a process - -cygthread NO_COPY *hwait_sig; -Static HANDLE wait_sig_inited; // Control synchronization of - // message queue startup -Static bool sigheld; // True if holding signals - -Static int nprocs; // Number of deceased children -Static char cprocs[(NPROCS + 1) * sizeof (pinfo)];// All my children info -#define procs ((pinfo *) cprocs) // All this just to avoid expensive - // constructor operation at DLL startup -Static waitq waitq_head; // Start of queue for wait'ing threads - -Static muto sync_proc_subproc; // Control access to subproc stuff - -_cygtls NO_COPY *_sig_tls; - -Static HANDLE my_sendsig; -Static HANDLE my_readsig; - -/* Function declarations */ -static int __stdcall checkstate (waitq *) __attribute__ ((regparm (1))); -static __inline__ bool get_proc_lock (DWORD, DWORD); -static bool __stdcall remove_proc (int); -static bool __stdcall stopped_or_terminated (waitq *, _pinfo *); -static DWORD WINAPI wait_sig (VOID *arg); - -/* wait_sig bookkeeping */ - -class pending_signals -{ - sigpacket sigs[NSIG + 1]; - sigpacket start; - sigpacket *end; - sigpacket *prev; - sigpacket *curr; -public: - void reset () {curr = &start; prev = &start;} - void add (sigpacket&); - void del (); - sigpacket *next (); - sigpacket *save () const {return curr;} - void restore (sigpacket *saved) {curr = saved;} - friend void __stdcall sig_dispatch_pending (bool); - friend DWORD WINAPI wait_sig (VOID *arg); -}; - -Static pending_signals sigq; - -/* Functions */ -void __stdcall -sigalloc () -{ - cygheap->sigs = global_sigs = - (struct sigaction *) ccalloc_abort (HEAP_SIGS, NSIG, sizeof (struct sigaction)); - global_sigs[SIGSTOP].sa_flags = SA_RESTART | SA_NODEFER; -} - -void __stdcall -signal_fixup_after_exec () -{ - global_sigs = cygheap->sigs; - /* Set up child's signal handlers */ - for (int i = 0; i < NSIG; i++) - { - global_sigs[i].sa_mask = 0; - if (global_sigs[i].sa_handler != SIG_IGN) - { - global_sigs[i].sa_handler = SIG_DFL; - global_sigs[i].sa_flags &= ~ SA_SIGINFO; - } - } -} - -void __stdcall -wait_for_sigthread () -{ - sigproc_printf ("wait_sig_inited %p", wait_sig_inited); - HANDLE hsig_inited = wait_sig_inited; - WaitForSingleObject (hsig_inited, INFINITE); - wait_sig_inited = NULL; - myself->sendsig = my_sendsig; - myself->process_state |= PID_ACTIVE; - myself->process_state &= ~PID_INITIALIZING; - ForceCloseHandle1 (hsig_inited, wait_sig_inited); - sigproc_printf ("process/signal handling enabled, state %p", myself->process_state); -} - -/* Get the sync_proc_subproc muto to control access to - * children, proc arrays. - * Attempt to handle case where process is exiting as we try to grab - * the mutex. - */ -static bool -get_proc_lock (DWORD what, DWORD val) -{ - Static int lastwhat = -1; - if (!sync_proc_subproc) - { - sigproc_printf ("sync_proc_subproc is NULL (1)"); - return false; - } - if (sync_proc_subproc.acquire (WPSP)) - { - lastwhat = what; - return true; - } - if (!sync_proc_subproc) - { - sigproc_printf ("sync_proc_subproc is NULL (2)"); - return false; - } - system_printf ("Couldn't acquire sync_proc_subproc for(%d,%d), last %d, %E", - what, val, lastwhat); - return true; -} - -static bool __stdcall -proc_can_be_signalled (_pinfo *p) -{ - if (!(p->exitcode & EXITCODE_SET)) - { - if (ISSTATE (p, PID_INITIALIZING) || - (((p)->process_state & (PID_ACTIVE | PID_IN_USE)) == - (PID_ACTIVE | PID_IN_USE))) - return true; - } - - set_errno (ESRCH); - return false; -} - -bool __stdcall -pid_exists (pid_t pid) -{ - return pinfo (pid)->exists (); -} - -/* Return true if this is one of our children, false otherwise. */ -static inline bool __stdcall -mychild (int pid) -{ - for (int i = 0; i < nprocs; i++) - if (procs[i]->pid == pid) - return true; - return false; -} - -/* Handle all subprocess requests - */ -int __stdcall -proc_subproc (DWORD what, DWORD val) -{ - int rc = 1; - int potential_match; - _pinfo *child; - int clearing; - waitq *w; - -#define wval ((waitq *) val) -#define vchild (*((pinfo *) val)) - - sigproc_printf ("args: %x, %d", what, val); - - if (!get_proc_lock (what, val)) // Serialize access to this function - { - system_printf ("couldn't get proc lock. what %d, val %d", what, val); - goto out1; - } - - switch (what) - { - /* Add a new subprocess to the children arrays. - * (usually called from the main thread) - */ - case PROC_ADDCHILD: - /* Filled up process table? */ - if (nprocs >= NPROCS) - { - sigproc_printf ("proc table overflow: hit %d processes, pid %d\n", - nprocs, vchild->pid); - rc = 0; - set_errno (EAGAIN); - break; - } - /* fall through intentionally */ - - case PROC_DETACHED_CHILD: - if (vchild != myself) - { - vchild->ppid = what == PROC_DETACHED_CHILD ? 1 : myself->pid; - vchild->uid = myself->uid; - vchild->gid = myself->gid; - vchild->pgid = myself->pgid; - vchild->sid = myself->sid; - vchild->ctty = myself->ctty; - vchild->cygstarted = true; - vchild->process_state |= PID_INITIALIZING | (myself->process_state & PID_USETTY); - } - if (what == PROC_DETACHED_CHILD) - break; - procs[nprocs] = vchild; - rc = procs[nprocs].wait (); - if (rc) - { - sigproc_printf ("added pid %d to proc table, slot %d", vchild->pid, - nprocs); - nprocs++; - } - break; - - /* Handle a wait4() operation. Allocates an event for the calling - * thread which is signaled when the appropriate pid exits or stops. - * (usually called from the main thread) - */ - case PROC_WAIT: - wval->ev = NULL; // Don't know event flag yet - - if (wval->pid == -1 || !wval->pid) - child = NULL; // Not looking for a specific pid - else if (!mychild (wval->pid)) - goto out; // invalid pid. flag no such child - - wval->status = 0; // Don't know status yet - sigproc_printf ("wval->pid %d, wval->options %d", wval->pid, wval->options); - - /* If the first time for this thread, create a new event, otherwise - * reset the event. - */ - if ((wval->ev = wval->thread_ev) == NULL) - { - wval->ev = wval->thread_ev = CreateEvent (&sec_none_nih, TRUE, FALSE, - NULL); - ProtectHandle1 (wval->ev, wq_ev); - } - - ResetEvent (wval->ev); - w = waitq_head.next; - waitq_head.next = wval; /* Add at the beginning. */ - wval->next = w; /* Link in rest of the list. */ - clearing = 0; - goto scan_wait; - - /* Clear all waiting threads. Called from exceptions.cc prior to - the main thread's dispatch to a signal handler function. - (called from wait_sig thread) */ - case PROC_CLEARWAIT: - /* Clear all "wait"ing threads. */ - if (val) - sigproc_printf ("clear waiting threads"); - else - sigproc_printf ("looking for processes to reap, nprocs %d", nprocs); - clearing = val; - - scan_wait: - /* Scan the linked list of wait()ing threads. If a wait's parameters - match this pid, then activate it. */ - for (w = &waitq_head; w->next != NULL; w = w->next) - { - if ((potential_match = checkstate (w)) > 0) - sigproc_printf ("released waiting thread"); - else if (!clearing && !(w->next->options & WNOHANG) && potential_match < 0) - sigproc_printf ("only found non-terminated children"); - else if (potential_match <= 0) // nothing matched - { - sigproc_printf ("waiting thread found no children"); - HANDLE oldw = w->next->ev; - w->next->pid = 0; - if (clearing) - w->next->status = -1; /* flag that a signal was received */ - else if (!potential_match || !(w->next->options & WNOHANG)) - w->next->ev = NULL; - if (!SetEvent (oldw)) - system_printf ("couldn't wake up wait event %p, %E", oldw); - w->next = w->next->next; - } - if (w->next == NULL) - break; - } - - if (!clearing) - sigproc_printf ("finished processing terminated/stopped child"); - else - { - waitq_head.next = NULL; - sigproc_printf ("finished clearing"); - } - - if (global_sigs[SIGCHLD].sa_handler == (void *) SIG_IGN) - for (int i = 0; i < nprocs; i += remove_proc (i)) - continue; - } - -out: - sync_proc_subproc.release (); // Release the lock -out1: - sigproc_printf ("returning %d", rc); - return rc; -#undef wval -#undef vchild -} - -// FIXME: This is inelegant -void -_cygtls::remove_wq (DWORD wait) -{ - if (exit_state < ES_FINAL && sync_proc_subproc - && sync_proc_subproc.acquire (wait)) - { - for (waitq *w = &waitq_head; w->next != NULL; w = w->next) - if (w->next == &wq) - { - ForceCloseHandle1 (wq.thread_ev, wq_ev); - w->next = wq.next; - break; - } - sync_proc_subproc.release (); - } -} - -/* Terminate the wait_subproc thread. - Called on process exit. - Also called by spawn_guts to disassociate any subprocesses from this - process. Subprocesses will then know to clean up after themselves and - will not become procs. */ -void __stdcall -proc_terminate () -{ - sigproc_printf ("nprocs %d", nprocs); - if (nprocs) - { - sync_proc_subproc.acquire (WPSP); - - proc_subproc (PROC_CLEARWAIT, 1); - - /* Clean out proc processes from the pid list. */ - int i; - for (i = 0; i < nprocs; i++) - { - procs[i]->ppid = 1; - if (procs[i].wait_thread) - { - // CloseHandle (procs[i].rd_proc_pipe); - procs[i].wait_thread->terminate_thread (); - } - procs[i].release (); - } - nprocs = 0; - sync_proc_subproc.release (); - } - sigproc_printf ("leaving"); -} - -/* Clear pending signal */ -void __stdcall -sig_clear (int target_sig) -{ - if (&_my_tls != _sig_tls) - sig_send (myself, -target_sig); - else - { - sigpacket *q; - sigpacket *save = sigq.save (); - sigq.reset (); - while ((q = sigq.next ())) - if (q->si.si_signo == target_sig) - { - q->si.si_signo = __SIGDELETE; - break; - } - sigq.restore (save); - } -} - -extern "C" int -sigpending (sigset_t *mask) -{ - sigset_t outset = (sigset_t) sig_send (myself, __SIGPENDING); - if (outset == SIG_BAD_MASK) - return -1; - *mask = outset; - return 0; -} - -/* Force the wait_sig thread to wake up and scan for pending signals */ -void __stdcall -sig_dispatch_pending (bool fast) -{ - if (exit_state || &_my_tls == _sig_tls) - { -#ifdef DEBUGGING - sigproc_printf ("exit_state %d, cur thread id %p, _sig_tls %p, sigq.start.next %p", - exit_state, GetCurrentThreadId (), _sig_tls, sigq.start.next); -#endif - return; - } - -#ifdef DEBUGGING - sigproc_printf ("flushing"); -#endif - sig_send (myself, fast ? __SIGFLUSHFAST : __SIGFLUSH); -} - -void __stdcall -create_signal_arrived () -{ - if (signal_arrived) - return; - /* local event signaled when main thread has been dispatched - to a signal handler function. */ - signal_arrived = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL); - ProtectHandle (signal_arrived); -} - -/* Signal thread initialization. Called from dll_crt0_1. - - This routine starts the signal handling thread. The wait_sig_inited - event is used to signal that the thread is ready to handle signals. - We don't wait for this during initialization but instead detect it - in sig_send to gain a little concurrency. */ -void __stdcall -sigproc_init () -{ - wait_sig_inited = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL); - ProtectHandle (wait_sig_inited); - - /* sync_proc_subproc is used by proc_subproc. It serialises - access to the children and proc arrays. */ - sync_proc_subproc.init ("sync_proc_subproc"); - - hwait_sig = new cygthread (wait_sig, 0, cygself, "sig"); - hwait_sig->zap_h (); -} - -/* Called on process termination to terminate signal and process threads. - */ -void __stdcall -sigproc_terminate (exit_states es) -{ - exit_states prior_exit_state = exit_state; - exit_state = es; - if (prior_exit_state >= ES_FINAL) - sigproc_printf ("already performed"); - else - { - sigproc_printf ("entering"); - sig_send (myself_nowait, __SIGEXIT); - proc_terminate (); // clean up process stuff - } -} - -int __stdcall -sig_send (_pinfo *p, int sig) -{ - if (sig == __SIGHOLD) - sigheld = true; - else if (!sigheld) - /* nothing */; - else if (sig == __SIGFLUSH || sig == __SIGFLUSHFAST) - return 0; - else if (sig == __SIGNOHOLD || sig == __SIGEXIT) - { - SetEvent (sigCONT); - sigheld = false; - } - else if (&_my_tls == _main_tls) - { -#ifdef DEBUGGING - system_printf ("signal %d sent to %p while signals are on hold", sig, p); -#endif - return -1; - } - siginfo_t si = {0}; - si.si_signo = sig; - si.si_code = SI_KERNEL; - si.si_pid = si.si_uid = si.si_errno = 0; - return sig_send (p, si); -} - -/* Send a signal to another process by raising its signal semaphore. - If pinfo *p == NULL, send to the current process. - If sending to this process, wait for notification that a signal has - completed before returning. */ -int __stdcall -sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls) -{ - int rc = 1; - bool its_me; - HANDLE sendsig; - sigpacket pack; - bool communing = si.si_signo == __SIGCOMMUNE; - - pack.wakeup = NULL; - bool wait_for_completion; - if (!(its_me = (!hExeced && (p == NULL || p == myself || p == myself_nowait)))) - { - /* It is possible that the process is not yet ready to receive messages - * or that it has exited. Detect this. - */ - if (!proc_can_be_signalled (p)) /* Is the process accepting messages? */ - { - sigproc_printf ("invalid pid %d(%x), signal %d", - p->pid, p->process_state, si.si_signo); - goto out; - } - wait_for_completion = false; - } - else - { - if (no_signals_available (si.si_signo != __SIGEXIT)) - { - sigproc_printf ("my_sendsig %p, myself->sendsig %p, exit_state %d", - my_sendsig, myself->sendsig, exit_state); - set_errno (EAGAIN); - goto out; // Either exiting or not yet initializing - } - if (wait_sig_inited) - wait_for_sigthread (); - wait_for_completion = p != myself_nowait && _my_tls.isinitialized () && !exit_state; - p = myself; - } - - - if (its_me) - sendsig = my_sendsig; - else - { - HANDLE dupsig; - DWORD dwProcessId; - for (int i = 0; !p->sendsig && i < 10000; i++) - low_priority_sleep (0); - if (p->sendsig) - { - dupsig = p->sendsig; - dwProcessId = p->dwProcessId; - } - else - { - dupsig = p->exec_sendsig; - dwProcessId = p->exec_dwProcessId; - } - if (!dupsig) - { - set_errno (EAGAIN); - sigproc_printf ("sendsig handle never materialized"); - goto out; - } - HANDLE hp = OpenProcess (PROCESS_DUP_HANDLE, false, dwProcessId); - if (!hp) - { - __seterrno (); - sigproc_printf ("OpenProcess failed, %E"); - goto out; - } - VerifyHandle (hp); - if (!DuplicateHandle (hp, dupsig, GetCurrentProcess (), &sendsig, false, - 0, DUPLICATE_SAME_ACCESS) || !sendsig) - { - __seterrno (); - sigproc_printf ("DuplicateHandle failed, %E"); - CloseHandle (hp); - goto out; - } - VerifyHandle (sendsig); - if (!communing) - CloseHandle (hp); - else - { - si._si_commune._si_process_handle = hp; - - HANDLE& tome = si._si_commune._si_write_handle; - HANDLE& fromthem = si._si_commune._si_read_handle; - if (!CreatePipe (&fromthem, &tome, &sec_all_nih, 0)) - { - sigproc_printf ("CreatePipe for __SIGCOMMUNE failed, %E"); - __seterrno (); - goto out; - } - if (!DuplicateHandle (GetCurrentProcess (), tome, hp, &tome, false, 0, - DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE)) - { - sigproc_printf ("DuplicateHandle for __SIGCOMMUNE failed, %E"); - __seterrno (); - goto out; - } - } - } - - sigproc_printf ("sendsig %p, pid %d, signal %d, its_me %d", sendsig, p->pid, si.si_signo, its_me); - - sigset_t pending; - if (!its_me) - pack.mask = NULL; - else if (si.si_signo == __SIGPENDING) - pack.mask = &pending; - else if (si.si_signo == __SIGFLUSH || si.si_signo > 0) - pack.mask = tls ? &tls->sigmask : &_main_tls->sigmask; - else - pack.mask = NULL; - - pack.si = si; - if (!pack.si.si_pid) - pack.si.si_pid = myself->pid; - if (!pack.si.si_uid) - pack.si.si_uid = myself->uid; - pack.pid = myself->pid; - pack.tls = tls; - if (wait_for_completion) - { - pack.wakeup = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL); - sigproc_printf ("wakeup %p", pack.wakeup); - ProtectHandle (pack.wakeup); - } - - char *leader; - size_t packsize; - if (!communing || !(si._si_commune._si_code & PICOM_EXTRASTR)) - { - leader = (char *) &pack; - packsize = sizeof (pack); - } - else - { - size_t n = strlen (si._si_commune._si_str); - char *p = leader = (char *) alloca (sizeof (pack) + sizeof (n) + n); - memcpy (p, &pack, sizeof (pack)); p += sizeof (pack); - memcpy (p, &n, sizeof (n)); p += sizeof (n); - memcpy (p, si._si_commune._si_str, n); p += n; - packsize = p - leader; - } - - DWORD nb; - if (!WriteFile (sendsig, leader, packsize, &nb, NULL) || nb != packsize) - { - /* Couldn't send to the pipe. This probably means that the - process is exiting. */ - if (!its_me) - { - __seterrno (); - sigproc_printf ("WriteFile for pipe %p failed, %E", sendsig); - ForceCloseHandle (sendsig); - } - else - { - if (no_signals_available (true)) - sigproc_printf ("I'm going away now"); - else if (!p->exec_sendsig) - system_printf ("error sending signal %d to pid %d, pipe handle %p, %E", - si.si_signo, p->pid, sendsig); - set_errno (EACCES); - } - goto out; - } - - - /* No need to wait for signal completion unless this was a signal to - this process. - - If it was a signal to this process, wait for a dispatched signal. - Otherwise just wait for the wait_sig to signal that it has finished - processing the signal. */ - if (wait_for_completion) - { - sigproc_printf ("Waiting for pack.wakeup %p", pack.wakeup); - rc = WaitForSingleObject (pack.wakeup, WSSC); - ForceCloseHandle (pack.wakeup); - } - else - { - rc = WAIT_OBJECT_0; - sigproc_printf ("Not waiting for sigcomplete. its_me %d signal %d", - its_me, si.si_signo); - if (!its_me) - ForceCloseHandle (sendsig); - } - - pack.wakeup = NULL; - if (rc == WAIT_OBJECT_0) - rc = 0; // Successful exit - else - { - if (!no_signals_available (true)) - system_printf ("wait for sig_complete event failed, signal %d, rc %d, %E", - si.si_signo, rc); - set_errno (ENOSYS); - rc = -1; - } - - if (wait_for_completion && si.si_signo != __SIGFLUSHFAST) - _my_tls.call_signal_handler (); - goto out; - -out: - if (communing && rc) - { - if (si._si_commune._si_process_handle) - CloseHandle (si._si_commune._si_process_handle); - if (si._si_commune._si_read_handle) - CloseHandle (si._si_commune._si_read_handle); - } - if (pack.wakeup) - ForceCloseHandle (pack.wakeup); - if (si.si_signo != __SIGPENDING) - /* nothing */; - else if (!rc) - rc = (int) pending; - else - rc = SIG_BAD_MASK; - sigproc_printf ("returning %p from sending signal %d", rc, si.si_signo); - return rc; -} - -int child_info::retry_count = 10; -/* Initialize some of the memory block passed to child processes - by fork/spawn/exec. */ - -child_info::child_info (unsigned in_cb, child_info_types chtype, bool need_subproc_ready) -{ - memset (this, 0, in_cb); - cb = in_cb; - - /* It appears that when running under WOW64 on Vista 64, the first DWORD - value in the datastructure lpReserved2 is pointing to (msv_count in - Cygwin), has to reflect the size of that datastructure as used in the - Microsoft C runtime (a count value, counting the number of elements in - two subsequent arrays, BYTE[count and HANDLE[count]), even though the C - runtime isn't used. Otherwise, if msv_count is 0 or too small, the - datastructure gets overwritten. - - This seems to be a bug in Vista's WOW64, which apparently copies the - lpReserved2 datastructure not using the cbReserved2 size information, - but using the information given in the first DWORD within lpReserved2 - instead. 32 bit Windows and former WOW64 don't care if msv_count is 0 - or a sensible non-0 count value. However, it's not clear if a non-0 - count doesn't result in trying to evaluate the content, so we do this - really only for Vista 64 for now. - - Note: It turns out that a non-zero value *does* harm operation on - XP 64 and 2K3 64 (Crash in CreateProcess call). - - The value is sizeof (child_info_*) / 5 which results in a count which - covers the full datastructure, plus not more than 4 extra bytes. This - is ok as long as the child_info structure is cosily stored within a bigger - datastructure. */ - msv_count = wincap.needs_count_in_si_lpres2 () ? in_cb / 5 : 0; - - intro = PROC_MAGIC_GENERIC; - magic = CHILD_INFO_MAGIC; - type = chtype; - fhandler_union_cb = sizeof (fhandler_union); - user_h = cygwin_user_h; - if (strace.attached ()) - flag |= _CI_STRACED; - if (need_subproc_ready) - { - subproc_ready = CreateEvent (&sec_all, FALSE, FALSE, NULL); - flag |= _CI_ISCYGWIN; - } - sigproc_printf ("subproc_ready %p", subproc_ready); - cygheap = ::cygheap; - cygheap_max = ::cygheap_max; - retry = child_info::retry_count; - /* Create an inheritable handle to pass to the child process. This will - allow the child to duplicate handles from the parent to itself. */ - parent = NULL; - if (!DuplicateHandle (GetCurrentProcess (), GetCurrentProcess (), - GetCurrentProcess (), &parent, 0, TRUE, - DUPLICATE_SAME_ACCESS)) - system_printf ("couldn't create handle to myself for child, %E"); -} - -child_info::~child_info () -{ - if (subproc_ready) - CloseHandle (subproc_ready); - if (parent) - CloseHandle (parent); -} - -child_info_fork::child_info_fork () : - child_info (sizeof *this, _PROC_FORK, true) -{ -} - -child_info_spawn::child_info_spawn (child_info_types chtype, bool need_subproc_ready) : - child_info (sizeof *this, chtype, need_subproc_ready) -{ -} - -void -child_info::ready (bool execed) -{ - if (!subproc_ready) - { - sigproc_printf ("subproc_ready not set"); - return; - } - - if (dynamically_loaded) - sigproc_printf ("not really ready"); - else if (!SetEvent (subproc_ready)) - api_fatal ("SetEvent failed"); - else - sigproc_printf ("signalled %p that I was ready", subproc_ready); - - if (execed) - { - CloseHandle (subproc_ready); - subproc_ready = NULL; - } -} - -bool -child_info::sync (pid_t pid, HANDLE& hProcess, DWORD howlong) -{ - bool res; - HANDLE w4[2]; - unsigned n = 0; - unsigned nsubproc_ready; - - if (!subproc_ready) - nsubproc_ready = WAIT_OBJECT_0 + 3; - else - { - w4[n++] = subproc_ready; - nsubproc_ready = 0; - } - w4[n++] = hProcess; - - sigproc_printf ("n %d, waiting for subproc_ready(%p) and child process(%p)", n, w4[0], w4[1]); - DWORD x = WaitForMultipleObjects (n, w4, FALSE, howlong); - x -= WAIT_OBJECT_0; - if (x >= n) - { - system_printf ("wait failed, pid %u, %E", pid); - res = false; - } - else - { - if (x != nsubproc_ready) - { - res = false; - GetExitCodeProcess (hProcess, &exit_code); - } - else - { - res = true; - exit_code = STILL_ACTIVE; - if (type == _PROC_EXEC && myself->wr_proc_pipe) - { - ForceCloseHandle1 (hProcess, childhProc); - hProcess = NULL; - } - } - sigproc_printf ("pid %u, WFMO returned %d, res %d", pid, x, res); - } - return res; -} - -DWORD -child_info::proc_retry (HANDLE h) -{ - if (!exit_code) - return EXITCODE_OK; - switch (exit_code) - { - case STILL_ACTIVE: /* shouldn't happen */ - sigproc_printf ("STILL_ACTIVE? How'd we get here?"); - break; - case STATUS_DLL_NOT_FOUND: - return exit_code; - case STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION: /* pseudo-reloc.c specific */ - return exit_code; - case STATUS_CONTROL_C_EXIT: - if (saw_ctrl_c ()) - return EXITCODE_OK; - /* fall through intentionally */ - case STATUS_DLL_INIT_FAILED: - case STATUS_DLL_INIT_FAILED_LOGOFF: - case EXITCODE_RETRY: - if (retry-- > 0) - exit_code = 0; - break; - /* Count down non-recognized exit codes more quickly since they aren't - due to known conditions. */ - default: - if (!iscygwin () && (exit_code & 0xffff0000) != 0xc0000000) - break; - if ((retry -= 2) < 0) - retry = 0; - else - exit_code = 0; - } - if (!exit_code) - ForceCloseHandle1 (h, childhProc); - return exit_code; -} - -bool -child_info_fork::handle_failure (DWORD err) -{ - if (retry > 0) - ExitProcess (EXITCODE_RETRY); - return 0; -} - -/* Check the state of all of our children to see if any are stopped or - * terminated. - */ -static int __stdcall -checkstate (waitq *parent_w) -{ - int potential_match = 0; - - sigproc_printf ("nprocs %d", nprocs); - - /* Check already dead processes first to see if they match the criteria - * given in w->next. */ - int res; - for (int i = 0; i < nprocs; i++) - if ((res = stopped_or_terminated (parent_w, procs[i]))) - { - remove_proc (i); - potential_match = 1; - goto out; - } - - sigproc_printf ("no matching terminated children found"); - potential_match = -!!nprocs; - -out: - sigproc_printf ("returning %d", potential_match); - return potential_match; -} - -/* Remove a proc from procs by swapping it with the last child in the list. - Also releases shared memory of exited processes. */ -static bool __stdcall -remove_proc (int ci) -{ - if (procs[ci]->exists ()) - return true; - - sigproc_printf ("removing procs[%d], pid %d, nprocs %d", ci, procs[ci]->pid, - nprocs); - if (procs[ci] != myself) - { - procs[ci].release (); - if (procs[ci].hProcess) - ForceCloseHandle1 (procs[ci].hProcess, childhProc); - } - if (ci < --nprocs) - { - /* Wait for proc_waiter thread to make a copy of this element before - moving it or it may become confused. The chances are very high that - the proc_waiter thread has already done this by the time we - get here. */ - while (!procs[nprocs].waiter_ready) - low_priority_sleep (0); - procs[ci] = procs[nprocs]; - } - return 0; -} - -/* Check status of child process vs. waitq member. - - parent_w is the pointer to the parent of the waitq member in question. - child is the subprocess being considered. - - Returns non-zero if waiting thread released. */ -static bool __stdcall -stopped_or_terminated (waitq *parent_w, _pinfo *child) -{ - int might_match; - waitq *w = parent_w->next; - - sigproc_printf ("considering pid %d", child->pid); - if (w->pid == -1) - might_match = 1; - else if (w->pid == 0) - might_match = child->pgid == myself->pgid; - else if (w->pid < 0) - might_match = child->pgid == -w->pid; - else - might_match = (w->pid == child->pid); - - if (!might_match) - return false; - - int terminated; - - if (!((terminated = (child->process_state == PID_EXITED)) - || ((w->options & WCONTINUED) && child->stopsig == SIGCONT) - || ((w->options & WUNTRACED) && child->stopsig && child->stopsig != SIGCONT))) - return false; - - parent_w->next = w->next; /* successful wait. remove from wait queue */ - w->pid = child->pid; - - if (!terminated) - { - sigproc_printf ("stopped child, stopsig %d", child->stopsig); - if (child->stopsig == SIGCONT) - w->status = __W_CONTINUED; - else - w->status = (child->stopsig << 8) | 0x7f; - child->stopsig = 0; - } - else - { - w->status = (__uint16_t) child->exitcode; - - add_rusage (&myself->rusage_children, &child->rusage_children); - add_rusage (&myself->rusage_children, &child->rusage_self); - - if (w->rusage) - { - add_rusage ((struct rusage *) w->rusage, &child->rusage_children); - add_rusage ((struct rusage *) w->rusage, &child->rusage_self); - } - } - - if (!SetEvent (w->ev)) /* wake up wait4 () immediately */ - system_printf ("couldn't wake up wait event %p, %E", w->ev); - return true; -} - -static void -talktome (siginfo_t *si) -{ - unsigned size = sizeof (*si); - sigproc_printf ("pid %d wants some information", si->si_pid); - if (si->_si_commune._si_code & PICOM_EXTRASTR) - { - size_t n; - DWORD nb; - if (!ReadFile (my_readsig, &n, sizeof (n), &nb, NULL) || nb != sizeof (n)) - return; - siginfo_t *newsi = (siginfo_t *) alloca (size += n + 1); - *newsi = *si; - newsi->_si_commune._si_str = (char *) (newsi + 1); - if (!ReadFile (my_readsig, newsi->_si_commune._si_str, n, &nb, NULL) || nb != n) - return; - newsi->_si_commune._si_str[n] = '\0'; - si = newsi; - } - - pinfo pi (si->si_pid); - if (pi) - new cygthread (commune_process, size, si, "commune_process"); -} - -void -pending_signals::add (sigpacket& pack) -{ - sigpacket *se; - if (sigs[pack.si.si_signo].si.si_signo) - return; - se = sigs + pack.si.si_signo; - *se = pack; - se->mask = &pack.tls->sigmask; - se->next = NULL; - if (end) - end->next = se; - end = se; - if (!start.next) - start.next = se; -} - -void -pending_signals::del () -{ - sigpacket *next = curr->next; - prev->next = next; - curr->si.si_signo = 0; -#ifdef DEBUGGING - curr->next = NULL; -#endif - if (end == curr) - end = prev; - curr = next; -} - -sigpacket * -pending_signals::next () -{ - sigpacket *res; - prev = curr; - if (!curr || !(curr = curr->next)) - res = NULL; - else - res = curr; - return res; -} - -/* Called separately to allow stack space reutilization by wait_sig. - This function relies on the fact that it will be called after cygheap - has been set up. For the case of non-dynamic DLL initialization this - means that it relies on the implicit serialization guarantted by being - run as part of DLL_PROCESS_ATTACH. */ -static void __attribute__ ((noinline)) -init_sig_pipe() -{ - char char_sa_buf[1024]; - PSECURITY_ATTRIBUTES sa_buf = sec_user_nih ((PSECURITY_ATTRIBUTES) char_sa_buf, cygheap->user.sid()); - if (!CreatePipe (&my_readsig, &my_sendsig, sa_buf, 0)) - api_fatal ("couldn't create signal pipe, %E"); - ProtectHandle (my_readsig); -} - - -/* Process signals by waiting for signal data to arrive in a pipe. - Set a completion event if one was specified. */ -static DWORD WINAPI -wait_sig (VOID *) -{ - init_sig_pipe (); - /* Initialization */ - SetThreadPriority (GetCurrentThread (), WAIT_SIG_PRIORITY); - - sigCONT = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL); - - SetEvent (wait_sig_inited); - - _sig_tls = &_my_tls; - sigproc_printf ("entering ReadFile loop, my_readsig %p, my_sendsig %p", - my_readsig, my_sendsig); - - sigpacket pack; - pack.si.si_signo = 0; - for (;;) - { - if (pack.si.si_signo == __SIGHOLD) - WaitForSingleObject (sigCONT, INFINITE); - DWORD nb; - pack.tls = NULL; - if (!ReadFile (my_readsig, &pack, sizeof (pack), &nb, NULL)) - break; - - if (nb != sizeof (pack)) - { - system_printf ("short read from signal pipe: %d != %d", nb, - sizeof (pack)); - continue; - } - - if (!pack.si.si_signo) - { -#ifdef DEBUGGING - system_printf ("zero signal?"); -#endif - continue; - } - - sigset_t dummy_mask; - if (!pack.mask) - { - dummy_mask = _main_tls->sigmask; - pack.mask = &dummy_mask; - } - - sigpacket *q; - bool clearwait = false; - switch (pack.si.si_signo) - { - case __SIGCOMMUNE: - talktome (&pack.si); - break; - case __SIGSTRACE: - strace.hello (); - break; - case __SIGPENDING: - *pack.mask = 0; - unsigned bit; - sigq.reset (); - while ((q = sigq.next ())) - if (pack.tls->sigmask & (bit = SIGTOMASK (q->si.si_signo))) - *pack.mask |= bit; - break; - case __SIGHOLD: - goto loop; - break; - case __SIGNOHOLD: - case __SIGFLUSH: - case __SIGFLUSHFAST: - sigq.reset (); - while ((q = sigq.next ())) - { - int sig = q->si.si_signo; - if (sig == __SIGDELETE || q->process () > 0) - sigq.del (); - if (sig == __SIGNOHOLD && q->si.si_signo == SIGCHLD) - clearwait = true; - } - break; - case __SIGEXIT: - hwait_sig = (cygthread *) INVALID_HANDLE_VALUE; - sigproc_printf ("saw __SIGEXIT"); - break; /* handle below */ - default: - if (pack.si.si_signo < 0) - sig_clear (-pack.si.si_signo); - else - { - int sig = pack.si.si_signo; - // FIXME: REALLY not right when taking threads into consideration. - // We need a per-thread queue since each thread can have its own - // list of blocked signals. CGF 2005-08-24 - if (sigq.sigs[sig].si.si_signo && sigq.sigs[sig].tls == pack.tls) - sigproc_printf ("sig %d already queued", pack.si.si_signo); - else - { - int sigres = pack.process (); - if (sigres <= 0) - { -#ifdef DEBUGGING2 - if (!sigres) - system_printf ("Failed to arm signal %d from pid %d", pack.sig, pack.pid); -#endif - sigq.add (pack); // FIXME: Shouldn't add this in !sh condition - } - } - if (sig == SIGCHLD) - clearwait = true; - } - break; - } - if (clearwait) - proc_subproc (PROC_CLEARWAIT, 0); - loop: - if (pack.wakeup) - { - sigproc_printf ("signalling pack.wakeup %p", pack.wakeup); - SetEvent (pack.wakeup); - } - if (pack.si.si_signo == __SIGEXIT) - break; - } - - ForceCloseHandle (my_readsig); - sigproc_printf ("signal thread exiting"); - ExitThread (0); -} diff --git a/winsup/cygwin/sigproc.h b/winsup/cygwin/sigproc.h deleted file mode 100644 index 7da1bc389..000000000 --- a/winsup/cygwin/sigproc.h +++ /dev/null @@ -1,98 +0,0 @@ -/* sigproc.h - - Copyright 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SIGPROC_H -#define _SIGPROC_H -#include - -#ifdef NSIG -enum -{ - __SIGFLUSH = -(NSIG + 1), - __SIGSTRACE = -(NSIG + 2), - __SIGCOMMUNE = -(NSIG + 3), - __SIGPENDING = -(NSIG + 4), - __SIGDELETE = -(NSIG + 5), - __SIGFLUSHFAST = -(NSIG + 6), - __SIGHOLD = -(NSIG + 7), - __SIGNOHOLD = -(NSIG + 8), - __SIGEXIT = -(NSIG + 9) -}; -#endif - -#define SIG_BAD_MASK (1 << (SIGKILL - 1)) - -enum procstuff -{ - PROC_ADDCHILD = 1, // add a new subprocess to list - PROC_DETACHED_CHILD = 2, // set up a detached child - PROC_CLEARWAIT = 3, // clear all waits - signal arrived - PROC_WAIT = 4, // setup for wait() for subproc - PROC_NOTHING = 5 // nothing, really -}; - -struct sigpacket -{ - siginfo_t si; - pid_t pid; - class _cygtls *tls; - sigset_t *mask; - union - { - HANDLE wakeup; - HANDLE thread_handle; - struct sigpacket *next; - }; - int __stdcall process () __attribute__ ((regparm (1))); -}; - -extern HANDLE signal_arrived; -extern HANDLE sigCONT; - -void __stdcall sig_dispatch_pending (bool fast = false); -#ifdef _PINFO_H -extern "C" void __stdcall set_signal_mask (sigset_t newmask, sigset_t&); -#endif -int __stdcall handle_sigprocmask (int sig, const sigset_t *set, - sigset_t *oldset, sigset_t& opmask) - __attribute__ ((regparm (3))); - -extern "C" void __stdcall reset_signal_arrived (); -void __stdcall sig_clear (int) __attribute__ ((regparm (1))); -void __stdcall sig_set_pending (int) __attribute__ ((regparm (1))); -int __stdcall handle_sigsuspend (sigset_t); - -int __stdcall proc_subproc (DWORD, DWORD) __attribute__ ((regparm (2))); - -class _pinfo; -void __stdcall proc_terminate (); -void __stdcall sigproc_init (); -#ifdef __INSIDE_CYGWIN__ -void __stdcall sigproc_terminate (enum exit_states); -#endif -bool __stdcall pid_exists (pid_t) __attribute__ ((regparm(1))); -int __stdcall sig_send (_pinfo *, siginfo_t&, class _cygtls *tls = NULL) __attribute__ ((regparm (3))); -int __stdcall sig_send (_pinfo *, int) __attribute__ ((regparm (2))); -void __stdcall signal_fixup_after_exec (); -void __stdcall wait_for_sigthread (); -void __stdcall sigalloc (); -void __stdcall create_signal_arrived (); - -int kill_pgrp (pid_t, siginfo_t&); -int killsys (pid_t, int); - -extern char myself_nowait_dummy[]; - -extern struct sigaction *global_sigs; - -#define WAIT_SIG_PRIORITY THREAD_PRIORITY_NORMAL - -#define myself_nowait ((_pinfo *) myself_nowait_dummy) -#endif /*_SIGPROC_H*/ diff --git a/winsup/cygwin/smallprint.cc b/winsup/cygwin/smallprint.cc deleted file mode 100644 index 0688ef75d..000000000 --- a/winsup/cygwin/smallprint.cc +++ /dev/null @@ -1,502 +0,0 @@ -/* smallprint.cc: small print routines for WIN32 - - Copyright 1996, 1998, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009 - Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "ntdll.h" -#include -#include -#include - -#define LLMASK (0xffffffffffffffffULL) -#define LMASK (0xffffffff) - -#define rnarg(dst, base, dosign, len, pad) __rn ((dst), (base), (dosign), va_arg (ap, long), len, pad, LMASK) -#define rnargLL(dst, base, dosign, len, pad) __rn ((dst), (base), (dosign), va_arg (ap, unsigned long long), len, pad, LLMASK) - -static const char hex_str[] = "0123456789ABCDEF"; - -static char __fastcall * -__rn (char *dst, int base, int dosign, long long val, int len, int pad, unsigned long long mask) -{ - /* longest number is ULLONG_MAX, 18446744073709551615, 20 digits */ - unsigned long long uval = 0; - char res[20]; - int l = 0; - - if (dosign && val < 0) - { - *dst++ = '-'; - uval = -val; - } - else if (dosign > 0 && val > 0) - { - *dst++ = '+'; - uval = val; - } - else - uval = val; - - uval &= mask; - - do - { - res[l++] = hex_str[uval % base]; - uval /= base; - } - while (uval); - - while (len-- > l) - *dst++ = pad; - - while (l > 0) - *dst++ = res[--l]; - - return dst; -} - -int -__small_vsprintf (char *dst, const char *fmt, va_list ap) -{ - char tmp[NT_MAX_PATH]; - char *orig = dst; - const char *s; - PWCHAR w; - UNICODE_STRING uw, *us; - - DWORD err = GetLastError (); - - while (*fmt) - { - int i, n = 0x7fff; - bool l_opt = false; - if (*fmt != '%') - *dst++ = *fmt++; - else - { - int len = 0; - char pad = ' '; - int addsign = -1; - - switch (*++fmt) - { - case '+': - addsign = 1; - fmt++; - break; - case '%': - *dst++ = *fmt++; - continue; - } - - for (;;) - { - char c = *fmt++; - switch (c) - { - case '0': - if (len == 0) - { - pad = '0'; - continue; - } - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - len = len * 10 + (c - '0'); - continue; - case 'l': - l_opt = true; - continue; - case 'c': - { - int c = va_arg (ap, int); - if (c > ' ' && c <= 127) - *dst++ = c; - else - { - *dst++ = '0'; - *dst++ = 'x'; - dst = __rn (dst, 16, 0, c, len, pad, LMASK); - } - } - break; - case 'C': - { - WCHAR wc = (WCHAR) va_arg (ap, int); - char buf[4], *c; - sys_wcstombs (buf, 4, &wc, 1); - for (c = buf; *c; ++c) - if (isprint (*c)) - *dst++ = *c; - else - { - *dst++ = '0'; - *dst++ = 'x'; - dst = __rn (dst, 16, 0, *c, len, pad, LMASK); - } - } - case 'E': - strcpy (dst, "Win32 error "); - dst = __rn (dst + sizeof ("Win32 error"), 10, 0, err, len, pad, LMASK); - break; - case 'd': - dst = rnarg (dst, 10, addsign, len, pad); - break; - case 'D': - dst = rnargLL (dst, 10, addsign, len, pad); - break; - case 'u': - dst = rnarg (dst, 10, 0, len, pad); - break; - case 'U': - dst = rnargLL (dst, 10, 0, len, pad); - break; - case 'o': - dst = rnarg (dst, 8, 0, len, pad); - break; - case 'p': - *dst++ = '0'; - *dst++ = 'x'; - /* fall through */ - case 'x': - dst = rnarg (dst, 16, 0, len, pad); - break; - case 'X': - dst = rnargLL (dst, 16, 0, len, pad); - break; - case 'P': - if (!GetModuleFileName (NULL, tmp, NT_MAX_PATH)) - s = "cygwin program"; - else - s = tmp; - goto fillin; - case '.': - n = strtol (fmt, (char **) &fmt, 10); - if (*fmt++ != 's') - goto endfor; - case 's': - s = va_arg (ap, char *); - if (s == NULL) - s = "(null)"; - fillin: - for (i = 0; *s && i < n; i++) - if (l_opt && ((*(unsigned char *)s <= 0x1f && *s != '\n') - || *(unsigned char *)s >= 0x7f)) - { - *dst++ = '\\'; - *dst++ = 'x'; - *dst++ = hex_str[*(unsigned char *)s >> 4]; - *dst++ = hex_str[*(unsigned char *)s++ & 0xf]; - } - else - *dst++ = *s++; - break; - case 'W': - w = va_arg (ap, PWCHAR); - RtlInitUnicodeString (us = &uw, w ?: L"(null)"); - goto wfillin; - case 'S': - us = va_arg (ap, PUNICODE_STRING); - if (!us) - RtlInitUnicodeString (us = &uw, L"(null)"); - wfillin: - if (l_opt) - { - for (USHORT i = 0; i < us->Length / sizeof (WCHAR); ++i) - { - WCHAR w = us->Buffer[i]; - if ((w <= 0x1f && w != '\n') || w >= 0x7f) - { - *dst++ = '\\'; - *dst++ = 'x'; - *dst++ = hex_str[(w >> 12) & 0xf]; - *dst++ = hex_str[(w >> 8) & 0xf]; - *dst++ = hex_str[(w >> 4) & 0xf]; - *dst++ = hex_str[w & 0xf]; - } - else - *dst++ = w; - } - } - else if (sys_wcstombs (tmp, NT_MAX_PATH, us->Buffer, - us->Length / sizeof (WCHAR))) - { - s = tmp; - goto fillin; - } - break; - default: - *dst++ = '?'; - *dst++ = fmt[-1]; - } - endfor: - break; - } - } - } - *dst = 0; - SetLastError (err); - return dst - orig; -} - -int -__small_sprintf (char *dst, const char *fmt, ...) -{ - int r; - va_list ap; - va_start (ap, fmt); - r = __small_vsprintf (dst, fmt, ap); - va_end (ap); - return r; -} - -void -small_printf (const char *fmt, ...) -{ - char buf[16384]; - va_list ap; - DWORD done; - int count; - -#if 0 /* Turn on to force console errors */ - extern SECURITY_ATTRIBUTES sec_none; - HANDLE h = CreateFileA ("CONOUT$", GENERIC_READ|GENERIC_WRITE, - FILE_SHARE_WRITE | FILE_SHARE_WRITE, &sec_none, - OPEN_EXISTING, 0, 0); - if (h) - SetStdHandle (STD_ERROR_HANDLE, h); -#endif - - va_start (ap, fmt); - count = __small_vsprintf (buf, fmt, ap); - va_end (ap); - - WriteFile (GetStdHandle (STD_ERROR_HANDLE), buf, count, &done, NULL); - FlushFileBuffers (GetStdHandle (STD_ERROR_HANDLE)); -} - -#ifdef DEBUGGING -static HANDLE NO_COPY console_handle = NULL; -void -console_printf (const char *fmt, ...) -{ - char buf[16384]; - va_list ap; - DWORD done; - int count; - - if (!console_handle) - console_handle = CreateFileA ("CON", GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, OPEN_EXISTING, 0, 0); - - if (console_handle == INVALID_HANDLE_VALUE) - console_handle = GetStdHandle (STD_ERROR_HANDLE); - - va_start (ap, fmt); - count = __small_vsprintf (buf, fmt, ap); - va_end (ap); - - WriteFile (console_handle, buf, count, &done, NULL); - FlushFileBuffers (console_handle); -} -#endif - -#define wrnarg(dst, base, dosign, len, pad) __wrn ((dst), (base), (dosign), va_arg (ap, long), len, pad, LMASK) -#define wrnargLL(dst, base, dosign, len, pad) __wrn ((dst), (base), (dosign), va_arg (ap, unsigned long long), len, pad, LLMASK) - -static PWCHAR __fastcall -__wrn (PWCHAR dst, int base, int dosign, long long val, int len, int pad, unsigned long long mask) -{ - /* longest number is ULLONG_MAX, 18446744073709551615, 20 digits */ - unsigned long long uval = 0; - WCHAR res[20]; - int l = 0; - - if (dosign && val < 0) - { - *dst++ = L'-'; - uval = -val; - } - else if (dosign > 0 && val > 0) - { - *dst++ = L'+'; - uval = val; - } - else - uval = val; - - uval &= mask; - - do - { - res[l++] = hex_str[uval % base]; - uval /= base; - } - while (uval); - - while (len-- > l) - *dst++ = pad; - - while (l > 0) - *dst++ = res[--l]; - - return dst; -} - -int -__small_vswprintf (PWCHAR dst, const WCHAR *fmt, va_list ap) -{ - WCHAR tmp[NT_MAX_PATH]; - PWCHAR orig = dst; - const char *s; - PWCHAR w; - UNICODE_STRING uw, *us; - - DWORD err = GetLastError (); - - while (*fmt) - { - unsigned int n = 0x7fff; - if (*fmt != L'%') - *dst++ = *fmt++; - else - { - int len = 0; - WCHAR pad = L' '; - int addsign = -1; - - switch (*++fmt) - { - case L'+': - addsign = 1; - fmt++; - break; - case L'%': - *dst++ = *fmt++; - continue; - } - - for (;;) - { - char c = *fmt++; - switch (c) - { - case L'0': - if (len == 0) - { - pad = L'0'; - continue; - } - case L'1' ... L'9': - len = len * 10 + (c - L'0'); - continue; - case L'l': - continue; - case L'c': - case L'C': - { - unsigned int c = va_arg (ap, unsigned int); - if (c > L' ' && c <= 127) - *dst++ = c; - else - { - *dst++ = L'0'; - *dst++ = L'x'; - dst = __wrn (dst, 16, 0, c, len, pad, LMASK); - } - } - break; - case L'E': - wcscpy (dst, L"Win32 error "); - dst = __wrn (dst + sizeof ("Win32 error"), 10, 0, err, len, pad, LMASK); - break; - case L'd': - dst = wrnarg (dst, 10, addsign, len, pad); - break; - case L'D': - dst = wrnargLL (dst, 10, addsign, len, pad); - break; - case L'u': - dst = wrnarg (dst, 10, 0, len, pad); - break; - case L'U': - dst = wrnargLL (dst, 10, 0, len, pad); - break; - case L'o': - dst = wrnarg (dst, 8, 0, len, pad); - break; - case L'p': - *dst++ = L'0'; - *dst++ = L'x'; - /* fall through */ - case L'x': - dst = wrnarg (dst, 16, 0, len, pad); - break; - case L'X': - dst = wrnargLL (dst, 16, 0, len, pad); - break; - case L'P': - if (!GetModuleFileNameW (NULL, tmp, NT_MAX_PATH)) - RtlInitUnicodeString (us = &uw, L"cygwin program"); - else - RtlInitUnicodeString (us = &uw, tmp); - goto fillin; - case L'.': - n = wcstoul (fmt, (wchar_t **) &fmt, 10); - if (*fmt++ != L's') - goto endfor; - case L's': - s = va_arg (ap, char *); - if (s == NULL) - s = "(null)"; - sys_mbstowcs (tmp, NT_MAX_PATH, s, n < 0x7fff ? (int) n : -1); - RtlInitUnicodeString (us = &uw, tmp); - goto fillin; - break; - case L'W': - w = va_arg (ap, PWCHAR); - RtlInitUnicodeString (us = &uw, w ?: L"(null)"); - goto fillin; - case L'S': - us = va_arg (ap, PUNICODE_STRING); - if (!us) - RtlInitUnicodeString (us = &uw, L"(null)"); - fillin: - if (us->Length / sizeof (WCHAR) < n) - n = us->Length / sizeof (WCHAR); - w = us->Buffer; - for (unsigned int i = 0; i < n; i++) - *dst++ = *w++; - break; - default: - *dst++ = L'?'; - *dst++ = fmt[-1]; - } - endfor: - break; - } - } - } - *dst = L'\0'; - SetLastError (err); - return dst - orig; -} - -int -__small_swprintf (PWCHAR dst, const WCHAR *fmt, ...) -{ - int r; - va_list ap; - va_start (ap, fmt); - r = __small_vswprintf (dst, fmt, ap); - va_end (ap); - return r; -} diff --git a/winsup/cygwin/sortdin b/winsup/cygwin/sortdin deleted file mode 100755 index dafb329ff..000000000 --- a/winsup/cygwin/sortdin +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/perl - -my %data = (); -my %code = (); - -my @out = (); - -my $fn = $ARGV[0]; - -while (<>) { - push(@out, $_); - /^\s*exports/i and last; -} - -while (<>) { - my $key; - $arr = /\sDATA\s*$/o ? \%data : \%code; - $_ =~ s/^\s+//; - my $key = (split(' ', $_))[0]; - substr($key, 0, 1) = '' while $key =~ /^_/o; - chomp $key; - $arr->{$key}->{$_} = 1; -} - -for my $k (sort keys %data) { - push(@out, sort {$b cmp $a} keys %{$data{$k}}); -} - -for my $k (sort keys %code) { - push(@out, sort {$b cmp $a} keys %{$code{$k}}); -} - -open(R, '>', $fn); -print R @out; -close R; diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc deleted file mode 100644 index c1033376c..000000000 --- a/winsup/cygwin/spawn.cc +++ /dev/null @@ -1,1144 +0,0 @@ -/* spawn.cc - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "cygerrno.h" -#include -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "sigproc.h" -#include "cygheap.h" -#include "child_info.h" -#include "pinfo.h" -#include "environ.h" -#include "cygtls.h" -#include "tls_pbuf.h" -#include "winf.h" -#include "ntdll.h" - -static suffix_info exe_suffixes[] = -{ - suffix_info ("", 1), - suffix_info (".exe", 1), - suffix_info (".com"), - suffix_info (NULL) -}; - -#if 0 -/* CV, 2009-11-05: Used to be used when searching for DLLs in calls to - dlopen(). However, dlopen() on other platforms never adds a suffix by - its own. Therefore we use stat_suffixes now, which only adds a .exe - suffix for symmetry. */ -static suffix_info dll_suffixes[] = -{ - suffix_info (".dll"), - suffix_info ("", 1), - suffix_info (".exe", 1), - suffix_info (NULL) -}; -#endif - -child_info_spawn *chExeced; - -/* Add .exe to PROG if not already present and see if that exists. - If not, return PROG (converted from posix to win32 rules if necessary). - The result is always BUF. - - Returns (possibly NULL) suffix */ - -static const char * -perhaps_suffix (const char *prog, path_conv& buf, int& err, unsigned opt) -{ - const char *ext; - - err = 0; - debug_printf ("prog '%s'", prog); - buf.check (prog, PC_SYM_FOLLOW | PC_NULLEMPTY, - (opt & FE_DLL) ? stat_suffixes : exe_suffixes); - - if (buf.isdir ()) - { - err = EACCES; - ext = NULL; - } - else if (!buf.exists ()) - { - err = ENOENT; - ext = NULL; - } - else if (buf.known_suffix) - ext = buf.get_win32 () + (buf.known_suffix - buf.get_win32 ()); - else - ext = strchr (buf.get_win32 (), '\0'); - - debug_printf ("buf %s, suffix found '%s'", (char *) buf.get_win32 (), ext); - return ext; -} - -/* Find an executable name, possibly by appending known executable - suffixes to it. The win32-translated name is placed in 'buf'. - Any found suffix is returned in known_suffix. - - If the file is not found and !null_if_not_found then the win32 version - of name is placed in buf and returned. Otherwise the contents of buf - is undefined and NULL is returned. */ - -const char * __stdcall -find_exec (const char *name, path_conv& buf, const char *mywinenv, - unsigned opt, const char **known_suffix) -{ - const char *suffix = ""; - debug_printf ("find_exec (%s)", name); - const char *retval; - tmp_pathbuf tp; - char *tmp = tp.c_get (); - const char *posix = (opt & FE_NATIVE) ? NULL : name; - bool has_slash = strchr (name, '/'); - int err; - - /* Check to see if file can be opened as is first. - Win32 systems always check . first, but PATH may not be set up to - do this. */ - if ((has_slash || opt & FE_CWD) - && (suffix = perhaps_suffix (name, buf, err, opt)) != NULL) - { - if (posix && !has_slash) - { - tmp[0] = '.'; - tmp[1] = '/'; - strcpy (tmp + 2, name); - posix = tmp; - } - retval = buf.get_win32 (); - goto out; - } - - win_env *winpath; - const char *path; - const char *posix_path; - - posix = (opt & FE_NATIVE) ? NULL : tmp; - - if (strchr (mywinenv, '/')) - { - /* it's not really an environment variable at all */ - int n = cygwin_conv_path_list (CCP_POSIX_TO_WIN_A, mywinenv, NULL, 0); - char *s = (char *) alloca (n); - if (cygwin_conv_path_list (CCP_POSIX_TO_WIN_A, mywinenv, s, n)) - goto errout; - path = s; - posix_path = mywinenv - 1; - } - else if (has_slash || strchr (name, '\\') || isdrive (name) - || !(winpath = getwinenv (mywinenv)) - || !(path = winpath->get_native ()) || *path == '\0') - /* Return the error condition if this is an absolute path or if there - is no PATH to search. */ - goto errout; - else - posix_path = winpath->get_posix () - 1; - - debug_printf ("%s%s", mywinenv, path); - /* Iterate over the specified path, looking for the file with and without - executable extensions. */ - do - { - posix_path++; - char *eotmp = strccpy (tmp, &path, ';'); - /* An empty path or '.' means the current directory, but we've - already tried that. */ - if (opt & FE_CWD && (tmp[0] == '\0' || (tmp[0] == '.' && tmp[1] == '\0'))) - continue; - - *eotmp++ = '\\'; - strcpy (eotmp, name); - - debug_printf ("trying %s", tmp); - - if ((suffix = perhaps_suffix (tmp, buf, err, opt)) != NULL) - { - if (buf.has_acls () && check_file_access (buf, X_OK, true)) - continue; - - if (posix == tmp) - { - eotmp = strccpy (tmp, &posix_path, ':'); - if (eotmp == tmp) - *eotmp++ = '.'; - *eotmp++ = '/'; - strcpy (eotmp, name); - } - retval = buf.get_win32 (); - goto out; - } - } - while (*path && *++path && (posix_path = strchr (posix_path, ':'))); - - errout: - posix = NULL; - /* Couldn't find anything in the given path. - Take the appropriate action based on null_if_not_found. */ - if (opt & FE_NNF) - retval = NULL; - else if (!(opt & FE_NATIVE)) - retval = name; - else - { - buf.check (name); - retval = buf.get_win32 (); - } - - out: - if (posix) - retval = buf.set_path (posix); - debug_printf ("%s = find_exec (%s)", (char *) buf.get_win32 (), name); - if (known_suffix) - *known_suffix = suffix ?: strchr (buf.get_win32 (), '\0'); - if (!retval && err) - set_errno (err); - return retval; -} - -/* Utility for spawn_guts. */ - -static HANDLE -handle (int fd, bool writing) -{ - HANDLE h; - cygheap_fdget cfd (fd); - - if (cfd < 0) - h = INVALID_HANDLE_VALUE; - else if (cfd->close_on_exec ()) - h = INVALID_HANDLE_VALUE; - else if (!writing) - h = cfd->get_handle (); - else - h = cfd->get_output_handle (); - - return h; -} - -int -iscmd (const char *argv0, const char *what) -{ - int n; - n = strlen (argv0) - strlen (what); - if (n >= 2 && argv0[1] != ':') - return 0; - return n >= 0 && strcasematch (argv0 + n, what) && - (n == 0 || isdirsep (argv0[n - 1])); -} - -struct pthread_cleanup -{ - _sig_func_ptr oldint; - _sig_func_ptr oldquit; - sigset_t oldmask; - pthread_cleanup (): oldint (NULL), oldquit (NULL), oldmask ((sigset_t) -1) {} -}; - -static void -do_cleanup (void *args) -{ -# define cleanup ((pthread_cleanup *) args) - if (cleanup->oldmask != (sigset_t) -1) - { - signal (SIGINT, cleanup->oldint); - signal (SIGQUIT, cleanup->oldquit); - sigprocmask (SIG_SETMASK, &(cleanup->oldmask), NULL); - } -# undef cleanup -} - - -int -spawn_guts (const char *prog_arg, const char *const *argv, - const char *const envp[], int mode, int __stdin, int __stdout) -{ - bool rc; - pid_t cygpid; - int res = -1; - - if (prog_arg == NULL) - { - syscall_printf ("prog_arg is NULL"); - set_errno (EFAULT); /* As on Linux. */ - return -1; - } - if (!prog_arg[0]) - { - syscall_printf ("prog_arg is empty"); - set_errno (ENOENT); /* Per POSIX */ - return -1; - } - - syscall_printf ("spawn_guts (%d, %.9500s)", mode, prog_arg); - - /* FIXME: This is no error condition on Linux. */ - if (argv == NULL) - { - syscall_printf ("argv is NULL"); - set_errno (EINVAL); - return -1; - } - - /* FIXME: There is a small race here and FIXME: not thread safe! */ - - pthread_cleanup cleanup; - if (mode == _P_SYSTEM) - { - sigset_t child_block; - cleanup.oldint = signal (SIGINT, SIG_IGN); - cleanup.oldquit = signal (SIGQUIT, SIG_IGN); - sigemptyset (&child_block); - sigaddset (&child_block, SIGCHLD); - sigprocmask (SIG_BLOCK, &child_block, &cleanup.oldmask); - } - pthread_cleanup_push (do_cleanup, (void *) &cleanup); - av newargv; - linebuf one_line; - child_info_spawn ch; - PWCHAR envblock = NULL; - path_conv real_path; - bool reset_sendsig = false; - - tmp_pathbuf tp; - PWCHAR runpath = tp.w_get (); - int c_flags; - bool wascygexec; - cygheap_exec_info *moreinfo; - - bool null_app_name = false; - STARTUPINFOW si = {}; - int looped = 0; - HANDLE orig_wr_proc_pipe = NULL; - - myfault efault; - if (efault.faulted ()) - { - if (get_errno () == ENOMEM) - set_errno (E2BIG); - else - set_errno (EFAULT); - res = -1; - goto out; - } - - child_info_types chtype; - if (mode != _P_OVERLAY) - chtype = PROC_SPAWN; - else - chtype = PROC_EXEC; - - moreinfo = (cygheap_exec_info *) ccalloc_abort (HEAP_1_EXEC, 1, - sizeof (cygheap_exec_info)); - moreinfo->old_title = NULL; - - /* CreateProcess takes one long string that is the command line (sigh). - We need to quote any argument that has whitespace or embedded "'s. */ - - int ac; - for (ac = 0; argv[ac]; ac++) - /* nothing */; - - newargv.set (ac, argv); - - int err; - const char *ext; - if ((ext = perhaps_suffix (prog_arg, real_path, err, FE_NADA)) == NULL) - { - set_errno (err); - res = -1; - goto out; - } - - - wascygexec = real_path.iscygexec (); - res = newargv.fixup (prog_arg, real_path, ext); - - if (res) - goto out; - - if (!real_path.iscygexec () - && (cygheap->cwd.drive_length == 0 - || cygheap->cwd.win32.Length >= MAX_PATH * sizeof (WCHAR))) - { - small_printf ("Error: Current working directory is a %s.\n" - "Can't start native Windows application from here.\n\n", - cygheap->cwd.drive_length == 0 - ? "virtual Cygwin directory" - : "path longer than allowed for a\n" - "Win32 working directory"); - set_errno (ENAMETOOLONG); - res = -1; - goto out; - } - - if (ac == 3 && argv[1][0] == '/' && argv[1][1] == 'c' && - (iscmd (argv[0], "command.com") || iscmd (argv[0], "cmd.exe"))) - { - real_path.check (prog_arg); - one_line.add ("\""); - if (!real_path.error) - one_line.add (real_path.get_win32 ()); - else - one_line.add (argv[0]); - one_line.add ("\""); - one_line.add (" "); - one_line.add (argv[1]); - one_line.add (" "); - one_line.add (argv[2]); - real_path.set_path (argv[0]); - null_app_name = true; - } - else - { - if (wascygexec) - newargv.dup_all (); - else if (!one_line.fromargv (newargv, real_path.get_win32 (), - real_path.iscygexec ())) - { - res = -1; - goto out; - } - - - newargv.all_calloced (); - moreinfo->argc = newargv.argc; - moreinfo->argv = newargv; - - if (mode != _P_OVERLAY || - !DuplicateHandle (GetCurrentProcess (), myself.shared_handle (), - GetCurrentProcess (), &moreinfo->myself_pinfo, - 0, TRUE, DUPLICATE_SAME_ACCESS)) - moreinfo->myself_pinfo = NULL; - else - VerifyHandle (moreinfo->myself_pinfo); - } - WCHAR wone_line[one_line.ix + 1]; - if (one_line.ix) - sys_mbstowcs (wone_line, one_line.ix + 1, one_line.buf); - else - wone_line[0] = L'\0'; - - PROCESS_INFORMATION pi; - pi.hProcess = pi.hThread = NULL; - pi.dwProcessId = pi.dwThreadId = 0; - - /* Set up needed handles for stdio */ - si.dwFlags = STARTF_USESTDHANDLES; - si.hStdInput = handle ((__stdin < 0 ? 0 : __stdin), false); - si.hStdOutput = handle ((__stdout < 0 ? 1 : __stdout), true); - si.hStdError = handle (2, true); - - si.cb = sizeof (si); - - c_flags = GetPriorityClass (GetCurrentProcess ()); - sigproc_printf ("priority class %d", c_flags); - c_flags |= CREATE_SEPARATE_WOW_VDM | CREATE_UNICODE_ENVIRONMENT; - - if (mode == _P_DETACH) - c_flags |= DETACHED_PROCESS; - else - fhandler_console::need_invisible (); - - if (mode != _P_OVERLAY) - myself->exec_sendsig = NULL; - else - { - /* Reset sendsig so that any process which wants to send a signal - to this pid will wait for the new process to become active. - Save the old value in case the exec fails. */ - if (!myself->exec_sendsig) - { - myself->exec_sendsig = myself->sendsig; - myself->exec_dwProcessId = myself->dwProcessId; - myself->sendsig = NULL; - reset_sendsig = true; - } - /* Save a copy of a handle to the current process around the first time we - exec so that the pid will not be reused. Why did I stop cygwin from - generating its own pids again? */ - if (cygheap->pid_handle) - /* already done previously */; - else if (DuplicateHandle (GetCurrentProcess (), GetCurrentProcess (), - GetCurrentProcess (), &cygheap->pid_handle, - PROCESS_QUERY_INFORMATION, TRUE, 0)) - ProtectHandleINH (cygheap->pid_handle); - else - system_printf ("duplicate to pid_handle failed, %E"); - } - - runpath = null_app_name ? NULL : real_path.get_wide_win32_path (runpath); - if (runpath) - { /* If the executable path length is < MAX_PATH, make sure the long path - win32 prefix is removed from the path to make subsequent native Win32 - child processes happy which are not long path aware. */ - USHORT len = real_path.get_nt_native_path ()->Length; - if (len < (MAX_PATH + 4) * sizeof (WCHAR) - || (runpath[5] != L':' /* UNC path */ - && len < (MAX_PATH + 6) * sizeof (WCHAR))) - { - PWCHAR r = runpath + 4; - if (r[1] != L':') /* UNC path */ - *(r += 2) = L'\\'; - if (!RtlIsDosDeviceName_U (r)) - runpath = r; - else if (*r == L'\\') - *r = L'C'; - } - } - - syscall_printf ("null_app_name %d (%W, %.9500W)", null_app_name, - runpath, wone_line); - - cygbench ("spawn-guts"); - - if (!real_path.iscygexec()) - cygheap->fdtab.set_file_pointers_for_exec (); - - moreinfo->envp = build_env (envp, envblock, moreinfo->envc, - real_path.iscygexec ()); - if (!moreinfo->envp || !envblock) - { - set_errno (E2BIG); - res = -1; - goto out; - } - ch.set (chtype, real_path.iscygexec ()); - ch.moreinfo = moreinfo; - ch.__stdin = __stdin; - ch.__stdout = __stdout; - - si.lpReserved2 = (LPBYTE) &ch; - si.cbReserved2 = sizeof (ch); - - /* Depends on ch.set call above. - Some file types might need extra effort in the parent after CreateProcess - and before copying the datastructures to the child. So we have to start - the child in suspend state, unfortunately, to avoid a race condition. */ - if (!newargv.win16_exe - && (!ch.iscygwin () || mode != _P_OVERLAY - || cygheap->fdtab.need_fixup_before ())) - c_flags |= CREATE_SUSPENDED; - - /* When ruid != euid we create the new process under the current original - account and impersonate in child, this way maintaining the different - effective vs. real ids. - FIXME: If ruid != euid and ruid != saved_uid we currently give - up on ruid. The new process will have ruid == euid. */ -loop: - cygheap->user.deimpersonate (); - - if (!cygheap->user.issetuid () - || (cygheap->user.saved_uid == cygheap->user.real_uid - && cygheap->user.saved_gid == cygheap->user.real_gid - && !cygheap->user.groups.issetgroups () - && !cygheap->user.setuid_to_restricted)) - { - rc = CreateProcessW (runpath, /* image name - with full path */ - wone_line, /* what was passed to exec */ - &sec_none_nih, /* process security attrs */ - &sec_none_nih, /* thread security attrs */ - TRUE, /* inherit handles from parent */ - c_flags, - envblock, /* environment */ - NULL, - &si, - &pi); - } - else - { - /* Give access to myself */ - if (mode == _P_OVERLAY) - myself.set_acl(); - - WCHAR wstname[1024] = { L'\0' }; - HWINSTA hwst_orig = NULL, hwst = NULL; - HDESK hdsk_orig = NULL, hdsk = NULL; - PSECURITY_ATTRIBUTES sa; - DWORD n; - - hwst_orig = GetProcessWindowStation (); - hdsk_orig = GetThreadDesktop (GetCurrentThreadId ()); - GetUserObjectInformationW (hwst_orig, UOI_NAME, wstname, 1024, &n); - /* Prior to Vista it was possible to start a service with the - "Interact with desktop" flag. This started the service in the - interactive window station of the console. A big security - risk, but we don't want to disable this behaviour for older - OSes because it's still heavily used by some users. They have - been warned. */ - if (!cygheap->user.setuid_to_restricted - && wcscasecmp (wstname, L"WinSta0") != 0) - { - WCHAR sid[128]; - - sa = sec_user ((PSECURITY_ATTRIBUTES) alloca (1024), - cygheap->user.sid ()); - /* We're creating a window station per user, not per logon session. - First of all we might not have a valid logon session for - the user (logon by create_token), and second, it doesn't - make sense in terms of security to create a new window - station for every logon of the same user. It just fills up - the system with window stations for no good reason. */ - hwst = CreateWindowStationW (cygheap->user.get_windows_id (sid), 0, - GENERIC_READ | GENERIC_WRITE, sa); - if (!hwst) - system_printf ("CreateWindowStation failed, %E"); - else if (!SetProcessWindowStation (hwst)) - system_printf ("SetProcessWindowStation failed, %E"); - else if (!(hdsk = CreateDesktopW (L"Default", NULL, NULL, 0, - GENERIC_ALL, sa))) - system_printf ("CreateDesktop failed, %E"); - else - { - wcpcpy (wcpcpy (wstname, sid), L"\\Default"); - si.lpDesktop = wstname; - debug_printf ("Desktop: %W", si.lpDesktop); - } - } - - rc = CreateProcessAsUserW (cygheap->user.primary_token (), - runpath, /* image name - with full path */ - wone_line, /* what was passed to exec */ - &sec_none_nih, /* process security attrs */ - &sec_none_nih, /* thread security attrs */ - TRUE, /* inherit handles from parent */ - c_flags, - envblock, /* environment */ - NULL, - &si, - &pi); - if (hwst) - { - SetProcessWindowStation (hwst_orig); - CloseWindowStation (hwst); - } - if (hdsk) - { - SetThreadDesktop (hdsk_orig); - CloseDesktop (hdsk); - } - } - - /* Restore impersonation. In case of _P_OVERLAY this isn't - allowed since it would overwrite child data. */ - if (mode != _P_OVERLAY || !rc) - cygheap->user.reimpersonate (); - - /* Set errno now so that debugging messages from it appear before our - final debugging message [this is a general rule for debugging - messages]. */ - if (!rc) - { - __seterrno (); - syscall_printf ("CreateProcess failed, %E"); - /* If this was a failed exec, restore the saved sendsig. */ - if (reset_sendsig) - { - myself->sendsig = myself->exec_sendsig; - myself->exec_sendsig = NULL; - } - res = -1; - goto out; - } - - if (!(c_flags & CREATE_SUSPENDED)) - strace.write_childpid (ch, pi.dwProcessId); - - /* Fixup the parent data structures if needed and resume the child's - main thread. */ - if (cygheap->fdtab.need_fixup_before ()) - cygheap->fdtab.fixup_before_exec (pi.dwProcessId); - - if (mode != _P_OVERLAY) - cygpid = cygwin_pid (pi.dwProcessId); - else - cygpid = myself->pid; - - /* We print the original program name here so the user can see that too. */ - syscall_printf ("%d = spawn_guts (%s, %.9500s)", - rc ? cygpid : (unsigned int) -1, prog_arg, one_line.buf); - - /* Name the handle similarly to proc_subproc. */ - ProtectHandle1 (pi.hProcess, childhProc); - - bool synced; - pid_t pid; - if (mode == _P_OVERLAY) - { - chExeced = &ch; /* FIXME: there's a race here if a user sneaks in CTRL-C */ - myself->dwProcessId = pi.dwProcessId; - strace.execing = 1; - myself.hProcess = hExeced = pi.hProcess; - strcpy (myself->progname, real_path.get_win32 ()); // FIXME: race? - sigproc_printf ("new process name %s", myself->progname); - /* If wr_proc_pipe doesn't exist then this process was not started by a cygwin - process. So, we need to wait around until the process we've just "execed" - dies. Use our own wait facility to wait for our own pid to exit (there - is some minor special case code in proc_waiter and friends to accommodate - this). - - If wr_proc_pipe exists, then it should be duplicated to the child. - If the child has exited already, that's ok. The parent will pick up - on this fact when we exit. dup_proc_pipe will close our end of the pipe. - Note that wr_proc_pipe may also be == INVALID_HANDLE_VALUE. That will make - dup_proc_pipe essentially a no-op. */ - if (!newargv.win16_exe && myself->wr_proc_pipe) - { - if (!looped) - myself->sync_proc_pipe (); /* Make sure that we own wr_proc_pipe - just in case we've been previously - execed. */ - orig_wr_proc_pipe = myself->dup_proc_pipe (pi.hProcess); - } - pid = myself->pid; - if (!ch.iscygwin ()) - close_all_files (); - } - else - { - myself->set_has_pgid_children (); - ProtectHandle (pi.hThread); - pinfo child (cygpid, PID_IN_USE); - if (!child) - { - syscall_printf ("pinfo failed"); - if (get_errno () != ENOMEM) - set_errno (EAGAIN); - res = -1; - goto out; - } - child->dwProcessId = pi.dwProcessId; - child.hProcess = pi.hProcess; - - strcpy (child->progname, real_path.get_win32 ()); - /* FIXME: This introduces an unreferenced, open handle into the child. - The purpose is to keep the pid shared memory open so that all of - the fields filled out by child.remember do not disappear and so there - is not a brief period during which the pid is not available. - However, we should try to find another way to do this eventually. */ - DuplicateHandle (GetCurrentProcess (), child.shared_handle (), - pi.hProcess, NULL, 0, 0, DUPLICATE_SAME_ACCESS); - child->start_time = time (NULL); /* Register child's starting time. */ - child->nice = myself->nice; - if (!child.remember (mode == _P_DETACH)) - { - /* FIXME: Child in strange state now */ - CloseHandle (pi.hProcess); - ForceCloseHandle (pi.hThread); - res = -1; - goto out; - } - pid = child->pid; - } - - /* Start the child running */ - if (c_flags & CREATE_SUSPENDED) - { - ResumeThread (pi.hThread); - strace.write_childpid (ch, pi.dwProcessId); - } - ForceCloseHandle (pi.hThread); - - sigproc_printf ("spawned windows pid %d", pi.dwProcessId); - - if ((mode == _P_DETACH || mode == _P_NOWAIT) && !ch.iscygwin ()) - synced = false; - else - synced = ch.sync (pi.dwProcessId, pi.hProcess, INFINITE); - - switch (mode) - { - case _P_OVERLAY: - myself.hProcess = pi.hProcess; - if (!synced) - { - if (orig_wr_proc_pipe) - { - myself->wr_proc_pipe_owner = GetCurrentProcessId (); - myself->wr_proc_pipe = orig_wr_proc_pipe; - } - if (!ch.proc_retry (pi.hProcess)) - { - looped++; - goto loop; - } - close_all_files (true); - } - else - { - close_all_files (true); - if (!myself->wr_proc_pipe - && WaitForSingleObject (pi.hProcess, 0) == WAIT_TIMEOUT) - { - extern bool is_toplevel_proc; - is_toplevel_proc = true; - myself.remember (false); - waitpid (myself->pid, &res, 0); - } - } - myself.exit (EXITCODE_NOSET); - break; - case _P_WAIT: - case _P_SYSTEM: - if (waitpid (cygpid, &res, 0) != cygpid) - res = -1; - break; - case _P_DETACH: - res = 0; /* Lost all memory of this child. */ - break; - case _P_NOWAIT: - case _P_NOWAITO: - case _P_VFORK: - res = cygpid; - break; - default: - break; - } - -out: - if (envblock) - free (envblock); - pthread_cleanup_pop (1); - return (int) res; -#undef ch -} - -extern "C" int -cwait (int *result, int pid, int) -{ - return waitpid (pid, result, 0); -} - -/* -* Helper function for spawn runtime calls. -* Doesn't search the path. -*/ - -extern "C" int -spawnve (int mode, const char *path, const char *const *argv, - const char *const *envp) -{ - int ret; -#ifdef NEWVFORK - vfork_save *vf = vfork_storage.val (); - - if (vf != NULL && (vf->pid < 0) && mode == _P_OVERLAY) - mode = _P_NOWAIT; - else - vf = NULL; -#endif - - syscall_printf ("spawnve (%s, %s, %x)", path, argv[0], envp); - - switch (mode) - { - case _P_OVERLAY: - /* We do not pass _P_SEARCH_PATH here. execve doesn't search PATH.*/ - /* Just act as an exec if _P_OVERLAY set. */ - spawn_guts (path, argv, envp, mode); - /* Errno should be set by spawn_guts. */ - ret = -1; - break; - case _P_VFORK: - case _P_NOWAIT: - case _P_NOWAITO: - case _P_WAIT: - case _P_DETACH: - case _P_SYSTEM: - ret = spawn_guts (path, argv, envp, mode); -#ifdef NEWVFORK - if (vf) - { - if (ret > 0) - { - debug_printf ("longjmping due to vfork"); - vf->restore_pid (ret); - } - } -#endif - break; - default: - set_errno (EINVAL); - ret = -1; - break; - } - return ret; -} - -/* -* spawn functions as implemented in the MS runtime library. -* Most of these based on (and copied from) newlib/libc/posix/execXX.c -*/ - -extern "C" int -spawnl (int mode, const char *path, const char *arg0, ...) -{ - int i; - va_list args; - const char *argv[256]; - - va_start (args, arg0); - argv[0] = arg0; - i = 1; - - do - argv[i] = va_arg (args, const char *); - while (argv[i++] != NULL); - - va_end (args); - - return spawnve (mode, path, (char * const *) argv, cur_environ ()); -} - -extern "C" int -spawnle (int mode, const char *path, const char *arg0, ...) -{ - int i; - va_list args; - const char * const *envp; - const char *argv[256]; - - va_start (args, arg0); - argv[0] = arg0; - i = 1; - - do - argv[i] = va_arg (args, const char *); - while (argv[i++] != NULL); - - envp = va_arg (args, const char * const *); - va_end (args); - - return spawnve (mode, path, (char * const *) argv, (char * const *) envp); -} - -extern "C" int -spawnlp (int mode, const char *path, const char *arg0, ...) -{ - int i; - va_list args; - const char *argv[256]; - - va_start (args, arg0); - argv[0] = arg0; - i = 1; - - do - argv[i] = va_arg (args, const char *); - while (argv[i++] != NULL); - - va_end (args); - - return spawnvpe (mode, path, (char * const *) argv, cur_environ ()); -} - -extern "C" int -spawnlpe (int mode, const char *path, const char *arg0, ...) -{ - int i; - va_list args; - const char * const *envp; - const char *argv[256]; - - va_start (args, arg0); - argv[0] = arg0; - i = 1; - - do - argv[i] = va_arg (args, const char *); - while (argv[i++] != NULL); - - envp = va_arg (args, const char * const *); - va_end (args); - - return spawnvpe (mode, path, (char * const *) argv, envp); -} - -extern "C" int -spawnv (int mode, const char *path, const char * const *argv) -{ - return spawnve (mode, path, argv, cur_environ ()); -} - -extern "C" int -spawnvp (int mode, const char *path, const char * const *argv) -{ - return spawnvpe (mode, path, argv, cur_environ ()); -} - -extern "C" int -spawnvpe (int mode, const char *file, const char * const *argv, - const char * const *envp) -{ - path_conv buf; - return spawnve (mode, find_exec (file, buf), argv, envp); -} - -int -av::fixup (const char *prog_arg, path_conv& real_path, const char *ext) -{ - const char *p; - bool exeext = ascii_strcasematch (ext, ".exe"); - if ((exeext && real_path.iscygexec ()) || ascii_strcasematch (ext, ".bat")) - return 0; - if (!*ext && ((p = ext - 4) > real_path.get_win32 ()) - && (ascii_strcasematch (p, ".bat") || ascii_strcasematch (p, ".cmd") - || ascii_strcasematch (p, ".btm"))) - return 0; - while (1) - { - char *pgm = NULL; - char *arg1 = NULL; - char *ptr, *buf; - OBJECT_ATTRIBUTES attr; - IO_STATUS_BLOCK io; - HANDLE h; - NTSTATUS status; - - status = NtOpenFile (&h, SYNCHRONIZE | GENERIC_READ, - real_path.get_object_attr (attr, sec_none_nih), - &io, FILE_SHARE_READ | FILE_SHARE_WRITE, - FILE_SYNCHRONOUS_IO_NONALERT - | FILE_OPEN_FOR_BACKUP_INTENT - | FILE_NON_DIRECTORY_FILE); - if (!NT_SUCCESS (status)) - { - /* File is not readable? Doesn't mean it's not executable. - Test for executablility and if so, just assume the file is - a cygwin executable and go ahead. */ - if (status == STATUS_ACCESS_DENIED && real_path.has_acls () - && check_file_access (real_path, X_OK, true) == 0) - { - real_path.set_cygexec (true); - break; - } - goto err; - } - - HANDLE hm = CreateFileMapping (h, &sec_none_nih, PAGE_READONLY, 0, 0, NULL); - NtClose (h); - if (!hm) - { - /* ERROR_FILE_INVALID indicates very likely an empty file. */ - if (GetLastError () == ERROR_FILE_INVALID) - { - debug_printf ("zero length file, treat as script."); - goto just_shell; - } - goto err; - } - buf = (char *) MapViewOfFile(hm, FILE_MAP_READ, 0, 0, 0); - CloseHandle (hm); - if (!buf) - goto err; - - { - myfault efault; - if (efault.faulted ()) - { - UnmapViewOfFile (buf); - real_path.set_cygexec (false); - break; - } - if (buf[0] == 'M' && buf[1] == 'Z') - { - WORD subsys; - unsigned off = (unsigned char) buf[0x18] | (((unsigned char) buf[0x19]) << 8); - win16_exe = off < sizeof (IMAGE_DOS_HEADER); - if (!win16_exe) - real_path.set_cygexec (!!hook_or_detect_cygwin (buf, NULL, subsys)); - else - real_path.set_cygexec (false); - UnmapViewOfFile (buf); - break; - } - } - - debug_printf ("%s is possibly a script", real_path.get_win32 ()); - - ptr = buf; - if (*ptr++ == '#' && *ptr++ == '!') - { - ptr += strspn (ptr, " \t"); - size_t len = strcspn (ptr, "\r\n"); - if (len) - { - char *namebuf = (char *) alloca (len + 1); - memcpy (namebuf, ptr, len); - namebuf[len] = '\0'; - for (ptr = pgm = namebuf; *ptr; ptr++) - if (!arg1 && (*ptr == ' ' || *ptr == '\t')) - { - /* Null terminate the initial command and step over any additional white - space. If we've hit the end of the line, exit the loop. Otherwise, - we've found the first argument. Position the current pointer on the - last known white space. */ - *ptr = '\0'; - char *newptr = ptr + 1; - newptr += strspn (newptr, " \t"); - if (!*newptr) - break; - arg1 = newptr; - ptr = newptr - 1; - } - } - } - UnmapViewOfFile (buf); -just_shell: - if (!pgm) - { - if (ascii_strcasematch (ext, ".com")) - break; - pgm = (char *) "/bin/sh"; - arg1 = NULL; - } - - /* Check if script is executable. Otherwise we start non-executable - scripts successfully, which is incorrect behaviour. */ - if (real_path.has_acls () - && check_file_access (real_path, X_OK, true) < 0) - return -1; /* errno is already set. */ - - /* Replace argv[0] with the full path to the script if this is the - first time through the loop. */ - replace0_maybe (prog_arg); - - /* pointers: - * pgm interpreter name - * arg1 optional string - */ - if (arg1) - unshift (arg1); - - /* FIXME: This should not be using FE_NATIVE. It should be putting - the posix path on the argv list. */ - find_exec (pgm, real_path, "PATH=", FE_NATIVE, &ext); - unshift (real_path.get_win32 (), 1); - } - return 0; - -err: - __seterrno (); - return -1; -} diff --git a/winsup/cygwin/speclib b/winsup/cygwin/speclib deleted file mode 100755 index 7ac4d1cff..000000000 --- a/winsup/cygwin/speclib +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/perl -use Getopt::Long; -use File::Temp qw'tempdir'; -use File::Basename; -use File::Spec; -use strict; - -sub dllname($;$); - -my $static; -my $inverse; -my @exclude; - -my ($ar, $as, $nm, $objcopy); -GetOptions('exclude=s'=>\@exclude, 'static!'=>\$static, 'v!'=>\$inverse, - 'ar=s'=>\$ar, 'as=s'=>\$as,'nm=s'=>\$nm, 'objcopy=s'=>\$objcopy); - -$_ = File::Spec->rel2abs($_) for @ARGV; - -my $libdll = shift; -my $lib = pop; -(my $iname = basename $lib) =~ s/\.a$//o; -$iname = '_' . $iname . '_dll_iname'; - -open my $nm_fd, '-|', $nm, '-Apg', '--defined-only', @ARGV, $libdll or - die "$0: execution of $nm for object files failed - $!\n"; - -my %match_syms = (); -my $symfiles = (); -my $lastfn; -my %extract = (); -my $exclude_regex = @exclude ? join('|', @exclude) : '\\UnLiKeLy//'; -$exclude_regex = qr/$exclude_regex/; -my $dllname; -while (<$nm_fd>) { - study; - if (/ I _(.*)_dll_iname/o) { - $dllname = $1; - } else { - my ($file, $member, $symbol) = m%^([^:]*):([^:]*(?=:))?.* T (.*)%o; - next if !defined($symbol) || $symbol =~ $exclude_regex; - if ($file ne $libdll) { - $match_syms{$symbol} = 1; - } elsif ($match_syms{$symbol} ? !$inverse : $inverse) { - $extract{$member} = 1; - } - } -} -close $nm_fd; - - -%extract or die "$0: couldn't find symbols for $lib\n"; - -my $dir = tempdir(CLEANUP => 1); - -chdir $dir; -# print join(' ', '+', $ar, 'x', sort keys %extract), "\n"; -my $res = system $ar, 'x', $libdll, sort keys %extract; -die "$0: $ar extraction exited with non-zero status\n" if $res; -unlink $lib; - -# Add a dummy .idata object for libtool so that it will think -# this library is an import library. -my $iname_o = 'd000000.o'; -$extract{$iname_o} = 1; -open my $as_fd, '|-', $as, '-R', '-o', $iname_o, "-"; -print $as_fd < -cygwin_stackdump - - -extern "C" void -cygwin_stackdump - - - - Outputs a stackdump to stderr from the called location. - - - diff --git a/winsup/cygwin/strace.cc b/winsup/cygwin/strace.cc deleted file mode 100644 index fb62e29dc..000000000 --- a/winsup/cygwin/strace.cc +++ /dev/null @@ -1,469 +0,0 @@ -/* strace.cc: system/windows tracing - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include -#include "cygerrno.h" -#include "pinfo.h" -#include "perprocess.h" -#include "cygwin_version.h" -#include "cygthread.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "child_info.h" - -#define PROTECT(x) x[sizeof (x)-1] = 0 -#define CHECK(x) if (x[sizeof (x)-1] != 0) { small_printf ("array bound exceeded %d\n", __LINE__); ExitProcess (1); } - -class strace NO_COPY strace; - -#ifndef NOSTRACE - -strace::strace () -{ - if (!dynamically_loaded && !_active && being_debugged ()) - { - char buf[30]; - __small_sprintf (buf, "cYg%8x %x", _STRACE_INTERFACE_ACTIVATE_ADDR, &_active); - OutputDebugString (buf); - } -} - -void -strace::hello () -{ - if (active ()) - { - char pidbuf[40]; - if (myself->progname[0]) - __small_sprintf (pidbuf, "(pid %d, ppid %d)", myself->pid, myself->ppid ?: 1); - else - { - GetModuleFileName (NULL, myself->progname, sizeof (myself->progname)); - __small_sprintf (pidbuf, "(windows pid %d)", GetCurrentProcessId ()); - } - prntf (1, NULL, "**********************************************"); - prntf (1, NULL, "Program name: %s %s", myself->progname, pidbuf); - prntf (1, NULL, "App version: %d.%d, api: %d.%d", - user_data->dll_major, user_data->dll_minor, - user_data->api_major, user_data->api_minor); - prntf (1, NULL, "DLL version: %d.%d, api: %d.%d", - cygwin_version.dll_major, cygwin_version.dll_minor, - cygwin_version.api_major, cygwin_version.api_minor); - prntf (1, NULL, "DLL build: %s", cygwin_version.dll_build_date); - prntf (1, NULL, "OS version: Windows %s", wincap.osname ()); - if (cygheap) - prntf (1, NULL, "Heap size: %u", cygheap->user_heap.chunk); - prntf (1, NULL, "**********************************************"); - } -} - -int -strace::microseconds () -{ - static hires_us now; - return (int) now.usecs (true); -} - -static int __stdcall -getfunc (char *in_dst, const char *func) -{ - const char *p; - const char *pe; - char *dst = in_dst; - for (p = func; (pe = strchr (p, '(')); p = pe + 1) - if (isalnum ((int)pe[-1]) || pe[-1] == '_') - break; - else if (isspace ((int)pe[-1])) - { - pe--; - break; - } - if (!pe) - pe = strchr (func, '\0'); - for (p = pe; p > func; p--) - if (p != pe && *p == ' ') - { - p++; - break; - } - if (*p == '*') - p++; - while (p < pe) - *dst++ = *p++; - - *dst++ = ':'; - *dst++ = ' '; - *dst = '\0'; - - return dst - in_dst; -} - -static char * -mypid (char *buf) -{ - if (myself && myself->pid) - __small_sprintf (buf, "%d", myself->pid); - else - __small_sprintf (buf, "(%d)", cygwin_pid (GetCurrentProcessId ())); - return buf; -} - -/* sprintf analog for use by output routines. */ -int -strace::vsprntf (char *buf, const char *func, const char *infmt, va_list ap) -{ - int count; - char fmt[80]; - static NO_COPY bool nonewline = false; - DWORD err = GetLastError (); - const char *tn = cygthread::name (); - - int microsec = microseconds (); - lmicrosec = microsec; - - __small_sprintf (fmt, "%7d [%s] %s ", microsec, tn, "%s %s%s"); - - SetLastError (err); - - if (nonewline) - count = 0; - else - { - char *pn; - if (!cygwin_finished_initializing) - pn = myself ? myself->progname : NULL; - else if (__progname) - pn = __progname; - else - pn = NULL; - - char *p; - char progname[NT_MAX_PATH]; - if (!pn) - GetModuleFileName (NULL, pn = progname, sizeof (progname)); - if (!pn) - /* hmm */; - else if ((p = strrchr (pn, '\\')) != NULL) - p++; - else if ((p = strrchr (pn, '/')) != NULL) - p++; - else - p = pn; - if (p != progname) - strcpy (progname, p); - if ((p = strrchr (progname, '.')) != NULL - && ascii_strcasematch (p, ".exe")) - *p = '\000'; - p = progname; - char tmpbuf[20]; - count = __small_sprintf (buf, fmt, p && *p ? p : "?", mypid (tmpbuf), - execing ? "!" : ""); - if (func) - count += getfunc (buf + count, func); - } - - count += __small_vsprintf (buf + count, infmt, ap); - char *p; - for (p = buf + count; p > buf; p--) - switch (p[-1]) - { - case '\n': - p[-1] = '\0'; - break; - case '\b': - *--p = '\0'; - nonewline = true; - goto done; - default: - goto addnl; - } - -addnl: - *p++ = '\n'; - *p = '\0'; - nonewline = false; - -done: - return p - buf; -} - -/* Write to strace file or strace queue. */ -void -strace::write (unsigned category, const char *buf, int count) -{ -# define PREFIX (3 + 8 + 1 + 8 + 1) - char outbuf[PREFIX + 1 + count + 1]; -# define outstuff (outbuf + 12) - __small_sprintf (outstuff, "%x %s", category, buf); - __small_sprintf (outbuf, "cYg%08x", strlen (outstuff) + 1); - outstuff[-1] = ' '; - OutputDebugString (outbuf); -#undef outstuff -#undef PREFIX -} - -void -strace::write_childpid (child_info& ch, DWORD pid) -{ - char buf[30]; - - if (!attached () || !being_debugged ()) - return; - WaitForSingleObject (ch.subproc_ready, 30000); - __small_sprintf (buf, "cYg%8x %x", _STRACE_CHILD_PID, pid); - OutputDebugString (buf); -} - -/* Printf function used when tracing system calls. - Warning: DO NOT SET ERRNO HERE! */ - -void -strace::vprntf (unsigned category, const char *func, const char *fmt, va_list ap) -{ - DWORD err = GetLastError (); - int len; - char buf[NT_MAX_PATH]; - - PROTECT (buf); - SetLastError (err); - - len = vsprntf (buf, func, fmt, ap); - CHECK (buf); - if (category & _STRACE_SYSTEM) - { - DWORD done; - WriteFile (GetStdHandle (STD_ERROR_HANDLE), buf, len, &done, 0); - FlushFileBuffers (GetStdHandle (STD_ERROR_HANDLE)); - /* Make sure that the message shows up on the screen, too, since this is - a serious error. */ - if (GetFileType (GetStdHandle (STD_ERROR_HANDLE)) != FILE_TYPE_CHAR) - { - HANDLE h = CreateFile ("CONOUT$", GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_WRITE | FILE_SHARE_WRITE, - &sec_none, OPEN_EXISTING, 0, 0); - if (h != INVALID_HANDLE_VALUE) - WriteFile (h, buf, len, &done, 0); - CloseHandle (h); - } - } - -#ifndef NOSTRACE - if (active ()) - write (category, buf, len); -#endif - SetLastError (err); -} - -void -strace::prntf (unsigned category, const char *func, const char *fmt, ...) -{ - va_list ap; - - va_start (ap, fmt); - vprntf (category, func, fmt, ap); - va_end (ap); -} - -extern "C" void -strace_printf (unsigned category, const char *func, const char *fmt, ...) -{ - va_list ap; - - if ((category & _STRACE_SYSTEM) || strace.active ()) - { - va_start (ap, fmt); - strace.vprntf (category, func, fmt, ap); - va_end (ap); - } -} - -static NO_COPY struct tab -{ - int v; - const char *n; -} -ta[] = -{ - { WM_NULL, "WM_NULL" }, - { WM_CREATE, "WM_CREATE" }, - { WM_DESTROY, "WM_DESTROY" }, - { WM_MOVE, "WM_MOVE" }, - { WM_SIZE, "WM_SIZE" }, - { WM_ACTIVATE, "WM_ACTIVATE" }, - { WM_SETFOCUS, "WM_SETFOCUS" }, - { WM_KILLFOCUS, "WM_KILLFOCUS" }, - { WM_ENABLE, "WM_ENABLE" }, - { WM_SETREDRAW, "WM_SETREDRAW" }, - { WM_SETTEXT, "WM_SETTEXT" }, - { WM_GETTEXT, "WM_GETTEXT" }, - { WM_GETTEXTLENGTH, "WM_GETTEXTLENGTH" }, - { WM_PAINT, "WM_PAINT" }, - { WM_CLOSE, "WM_CLOSE" }, - { WM_QUERYENDSESSION, "WM_QUERYENDSESSION" }, - { WM_QUIT, "WM_QUIT" }, - { WM_QUERYOPEN, "WM_QUERYOPEN" }, - { WM_ERASEBKGND, "WM_ERASEBKGND" }, - { WM_SYSCOLORCHANGE, "WM_SYSCOLORCHANGE" }, - { WM_ENDSESSION, "WM_ENDSESSION" }, - { WM_SHOWWINDOW, "WM_SHOWWINDOW" }, - { WM_WININICHANGE, "WM_WININICHANGE" }, - { WM_DEVMODECHANGE, "WM_DEVMODECHANGE" }, - { WM_ACTIVATEAPP, "WM_ACTIVATEAPP" }, - { WM_FONTCHANGE, "WM_FONTCHANGE" }, - { WM_TIMECHANGE, "WM_TIMECHANGE" }, - { WM_CANCELMODE, "WM_CANCELMODE" }, - { WM_SETCURSOR, "WM_SETCURSOR" }, - { WM_MOUSEACTIVATE, "WM_MOUSEACTIVATE" }, - { WM_CHILDACTIVATE, "WM_CHILDACTIVATE" }, - { WM_QUEUESYNC, "WM_QUEUESYNC" }, - { WM_GETMINMAXINFO, "WM_GETMINMAXINFO" }, - { WM_PAINTICON, "WM_PAINTICON" }, - { WM_ICONERASEBKGND, "WM_ICONERASEBKGND" }, - { WM_NEXTDLGCTL, "WM_NEXTDLGCTL" }, - { WM_SPOOLERSTATUS, "WM_SPOOLERSTATUS" }, - { WM_DRAWITEM, "WM_DRAWITEM" }, - { WM_MEASUREITEM, "WM_MEASUREITEM" }, - { WM_DELETEITEM, "WM_DELETEITEM" }, - { WM_VKEYTOITEM, "WM_VKEYTOITEM" }, - { WM_CHARTOITEM, "WM_CHARTOITEM" }, - { WM_SETFONT, "WM_SETFONT" }, - { WM_GETFONT, "WM_GETFONT" }, - { WM_SETHOTKEY, "WM_SETHOTKEY" }, - { WM_GETHOTKEY, "WM_GETHOTKEY" }, - { WM_QUERYDRAGICON, "WM_QUERYDRAGICON" }, - { WM_COMPAREITEM, "WM_COMPAREITEM" }, - { WM_COMPACTING, "WM_COMPACTING" }, - { WM_WINDOWPOSCHANGING, "WM_WINDOWPOSCHANGING" }, - { WM_WINDOWPOSCHANGED, "WM_WINDOWPOSCHANGED" }, - { WM_POWER, "WM_POWER" }, - { WM_COPYDATA, "WM_COPYDATA" }, - { WM_CANCELJOURNAL, "WM_CANCELJOURNAL" }, - { WM_NCCREATE, "WM_NCCREATE" }, - { WM_NCDESTROY, "WM_NCDESTROY" }, - { WM_NCCALCSIZE, "WM_NCCALCSIZE" }, - { WM_NCHITTEST, "WM_NCHITTEST" }, - { WM_NCPAINT, "WM_NCPAINT" }, - { WM_NCACTIVATE, "WM_NCACTIVATE" }, - { WM_GETDLGCODE, "WM_GETDLGCODE" }, - { WM_NCMOUSEMOVE, "WM_NCMOUSEMOVE" }, - { WM_NCLBUTTONDOWN, "WM_NCLBUTTONDOWN" }, - { WM_NCLBUTTONUP, "WM_NCLBUTTONUP" }, - { WM_NCLBUTTONDBLCLK, "WM_NCLBUTTONDBLCLK" }, - { WM_NCRBUTTONDOWN, "WM_NCRBUTTONDOWN" }, - { WM_NCRBUTTONUP, "WM_NCRBUTTONUP" }, - { WM_NCRBUTTONDBLCLK, "WM_NCRBUTTONDBLCLK" }, - { WM_NCMBUTTONDOWN, "WM_NCMBUTTONDOWN" }, - { WM_NCMBUTTONUP, "WM_NCMBUTTONUP" }, - { WM_NCMBUTTONDBLCLK, "WM_NCMBUTTONDBLCLK" }, - { WM_KEYFIRST, "WM_KEYFIRST" }, - { WM_KEYDOWN, "WM_KEYDOWN" }, - { WM_KEYUP, "WM_KEYUP" }, - { WM_CHAR, "WM_CHAR" }, - { WM_DEADCHAR, "WM_DEADCHAR" }, - { WM_SYSKEYDOWN, "WM_SYSKEYDOWN" }, - { WM_SYSKEYUP, "WM_SYSKEYUP" }, - { WM_SYSCHAR, "WM_SYSCHAR" }, - { WM_SYSDEADCHAR, "WM_SYSDEADCHAR" }, - { WM_KEYLAST, "WM_KEYLAST" }, - { WM_INITDIALOG, "WM_INITDIALOG" }, - { WM_COMMAND, "WM_COMMAND" }, - { WM_SYSCOMMAND, "WM_SYSCOMMAND" }, - { WM_TIMER, "WM_TIMER" }, - { WM_HSCROLL, "WM_HSCROLL" }, - { WM_VSCROLL, "WM_VSCROLL" }, - { WM_INITMENU, "WM_INITMENU" }, - { WM_INITMENUPOPUP, "WM_INITMENUPOPUP" }, - { WM_MENUSELECT, "WM_MENUSELECT" }, - { WM_MENUCHAR, "WM_MENUCHAR" }, - { WM_ENTERIDLE, "WM_ENTERIDLE" }, - { WM_CTLCOLORMSGBOX, "WM_CTLCOLORMSGBOX" }, - { WM_CTLCOLOREDIT, "WM_CTLCOLOREDIT" }, - { WM_CTLCOLORLISTBOX, "WM_CTLCOLORLISTBOX" }, - { WM_CTLCOLORBTN, "WM_CTLCOLORBTN" }, - { WM_CTLCOLORDLG, "WM_CTLCOLORDLG" }, - { WM_CTLCOLORSCROLLBAR, "WM_CTLCOLORSCROLLBAR" }, - { WM_CTLCOLORSTATIC, "WM_CTLCOLORSTATIC" }, - { WM_MOUSEFIRST, "WM_MOUSEFIRST" }, - { WM_MOUSEMOVE, "WM_MOUSEMOVE" }, - { WM_LBUTTONDOWN, "WM_LBUTTONDOWN" }, - { WM_LBUTTONUP, "WM_LBUTTONUP" }, - { WM_LBUTTONDBLCLK, "WM_LBUTTONDBLCLK" }, - { WM_RBUTTONDOWN, "WM_RBUTTONDOWN" }, - { WM_RBUTTONUP, "WM_RBUTTONUP" }, - { WM_RBUTTONDBLCLK, "WM_RBUTTONDBLCLK" }, - { WM_MBUTTONDOWN, "WM_MBUTTONDOWN" }, - { WM_MBUTTONUP, "WM_MBUTTONUP" }, - { WM_MBUTTONDBLCLK, "WM_MBUTTONDBLCLK" }, - { WM_MOUSELAST, "WM_MOUSELAST" }, - { WM_PARENTNOTIFY, "WM_PARENTNOTIFY" }, - { WM_ENTERMENULOOP, "WM_ENTERMENULOOP" }, - { WM_EXITMENULOOP, "WM_EXITMENULOOP" }, - { WM_MDICREATE, "WM_MDICREATE" }, - { WM_MDIDESTROY, "WM_MDIDESTROY" }, - { WM_MDIACTIVATE, "WM_MDIACTIVATE" }, - { WM_MDIRESTORE, "WM_MDIRESTORE" }, - { WM_MDINEXT, "WM_MDINEXT" }, - { WM_MDIMAXIMIZE, "WM_MDIMAXIMIZE" }, - { WM_MDITILE, "WM_MDITILE" }, - { WM_MDICASCADE, "WM_MDICASCADE" }, - { WM_MDIICONARRANGE, "WM_MDIICONARRANGE" }, - { WM_MDIGETACTIVE, "WM_MDIGETACTIVE" }, - { WM_MDISETMENU, "WM_MDISETMENU" }, - { WM_DROPFILES, "WM_DROPFILES" }, - { WM_MDIREFRESHMENU, "WM_MDIREFRESHMENU" }, - { WM_CUT, "WM_CUT" }, - { WM_COPY, "WM_COPY" }, - { WM_PASTE, "WM_PASTE" }, - { WM_CLEAR, "WM_CLEAR" }, - { WM_UNDO, "WM_UNDO" }, - { WM_RENDERFORMAT, "WM_RENDERFORMAT" }, - { WM_RENDERALLFORMATS, "WM_RENDERALLFORMATS" }, - { WM_DESTROYCLIPBOARD, "WM_DESTROYCLIPBOARD" }, - { WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD" }, - { WM_PAINTCLIPBOARD, "WM_PAINTCLIPBOARD" }, - { WM_VSCROLLCLIPBOARD, "WM_VSCROLLCLIPBOARD" }, - { WM_SIZECLIPBOARD, "WM_SIZECLIPBOARD" }, - { WM_ASKCBFORMATNAME, "WM_ASKCBFORMATNAME" }, - { WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN" }, - { WM_HSCROLLCLIPBOARD, "WM_HSCROLLCLIPBOARD" }, - { WM_QUERYNEWPALETTE, "WM_QUERYNEWPALETTE" }, - { WM_PALETTEISCHANGING, "WM_PALETTEISCHANGING" }, - { WM_PALETTECHANGED, "WM_PALETTECHANGED" }, - { WM_HOTKEY, "WM_HOTKEY" }, - { WM_PENWINFIRST, "WM_PENWINFIRST" }, - { WM_PENWINLAST, "WM_PENWINLAST" }, - { WM_ASYNCIO, "ASYNCIO" }, - { 0, 0 }}; - -void -strace::wm (int message, int word, int lon) -{ - if (active ()) - { - int i; - - for (i = 0; ta[i].n; i++) - { - if (ta[i].v == message) - { - prntf (_STRACE_WM, NULL, "wndproc %d %s %d %d", message, ta[i].n, word, lon); - return; - } - } - prntf (_STRACE_WM, NULL, "wndproc %d unknown %d %d", message, word, lon); - } -} -#endif /*NOSTRACE*/ diff --git a/winsup/cygwin/strfuncs.cc b/winsup/cygwin/strfuncs.cc deleted file mode 100644 index 6d9f4a232..000000000 --- a/winsup/cygwin/strfuncs.cc +++ /dev/null @@ -1,646 +0,0 @@ -/* strfuncs.cc: misc funcs that don't belong anywhere else - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include -#include -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" - -/* Transform characters invalid for Windows filenames to the Unicode private - use area in the U+f0XX range. The affected characters are all control - chars 1 <= c <= 31, as well as the characters " * : < > ? |. The backslash - is affected as well, but we can't transform it as long as we accept Win32 - paths as input. - The reverse functionality is in function sys_cp_wcstombs. */ -static const WCHAR tfx_chars[] = { - 0, 0xf000 | 1, 0xf000 | 2, 0xf000 | 3, - 0xf000 | 4, 0xf000 | 5, 0xf000 | 6, 0xf000 | 7, - 0xf000 | 8, 0xf000 | 9, 0xf000 | 10, 0xf000 | 11, - 0xf000 | 12, 0xf000 | 13, 0xf000 | 14, 0xf000 | 15, - 0xf000 | 16, 0xf000 | 17, 0xf000 | 18, 0xf000 | 19, - 0xf000 | 20, 0xf000 | 21, 0xf000 | 22, 0xf000 | 23, - 0xf000 | 24, 0xf000 | 25, 0xf000 | 26, 0xf000 | 27, - 0xf000 | 28, 0xf000 | 29, 0xf000 | 30, 0xf000 | 31, - ' ', '!', 0xf000 | '"', '#', - '$', '%', '&', 39, - '(', ')', 0xf000 | '*', '+', - ',', '-', '.', '\\', - '0', '1', '2', '3', - '4', '5', '6', '7', - '8', '9', 0xf000 | ':', ';', - 0xf000 | '<', '=', 0xf000 | '>', 0xf000 | '?', - '@', 'A', 'B', 'C', - 'D', 'E', 'F', 'G', - 'H', 'I', 'J', 'K', - 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', - 'T', 'U', 'V', 'W', - 'X', 'Y', 'Z', '[', - '\\', ']', '^', '_', - '`', 'a', 'b', 'c', - 'd', 'e', 'f', 'g', - 'h', 'i', 'j', 'k', - 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', - 't', 'u', 'v', 'w', - 'x', 'y', 'z', '{', - 0xf000 | '|', '}', '~', 127 -}; - -void -transform_chars (PWCHAR path, PWCHAR path_end) -{ - for (; path <= path_end; ++path) - if (*path < 128) - *path = tfx_chars[*path]; -} - -/* The SJIS, JIS and eucJP conversion in newlib does not use UTF as - wchar_t character representation. That's unfortunate for us since - we require UTF for the OS. What we do here is to have our own - implementation of the base functions for the conversion using - the MulitByteToWideChar/WideCharToMultiByte functions. */ - -/* FIXME: We can't support JIS (ISO-2022-JP) at all right now. It's a - stateful charset encoding. The translation from mbtowc to - MulitByteToWideChar is quite complex. Given that we support SJIS and - eucJP, the both most used Japanese charset encodings, this shouldn't - be such a big problem. */ - -/* GBK, eucKR, and Big5 conversions are not available so far in newlib. */ - -static int -__db_wctomb (struct _reent *r, char *s, wchar_t wchar, UINT cp) -{ - if (s == NULL) - return 0; - - if (wchar < 0x80) - { - *s = (char) wchar; - return 1; - } - - BOOL def_used = false; - int ret = WideCharToMultiByte (cp, WC_NO_BEST_FIT_CHARS, &wchar, 1, s, - 2, NULL, &def_used); - if (ret > 0 && !def_used) - return ret; - - r->_errno = EILSEQ; - return -1; -} - -extern "C" int -__sjis_wctomb (struct _reent *r, char *s, wchar_t wchar, const char *charset, - mbstate_t *state) -{ - return __db_wctomb (r,s, wchar, 932); -} - -extern "C" int -__eucjp_wctomb (struct _reent *r, char *s, wchar_t wchar, const char *charset, - mbstate_t *state) -{ - /* Unfortunately, the Windows eucJP codepage 20932 is not really 100% - compatible to eucJP. It's a cute approximation which makes it a - doublebyte codepage. - The JIS-X-0212 three byte codes (0x8f,0xa1-0xfe,0xa1-0xfe) are folded - into two byte codes as follows: The 0x8f is stripped, the next byte is - taken as is, the third byte is mapped into the lower 7-bit area by - masking it with 0x7f. So, for instance, the eucJP code 0x8f,0xdd,0xf8 - becomes 0xdd,0x78 in CP 20932. - - To be really eucJP compatible, we have to map the JIS-X-0212 characters - between CP 20932 and eucJP ourselves. */ - if (s == NULL) - return 0; - - if (wchar < 0x80) - { - *s = (char) wchar; - return 1; - } - - BOOL def_used = false; - int ret = WideCharToMultiByte (20932, WC_NO_BEST_FIT_CHARS, &wchar, 1, s, - 3, NULL, &def_used); - if (ret > 0 && !def_used) - { - /* CP20932 representation of JIS-X-0212 character? */ - if (ret == 2 && (unsigned char) s[1] <= 0x7f) - { - /* Yes, convert to eucJP three byte sequence */ - s[2] = s[1] | 0x80; - s[1] = s[0]; - s[0] = 0x8f; - ++ret; - } - return ret; - } - - r->_errno = EILSEQ; - return -1; -} - -extern "C" int -__gbk_wctomb (struct _reent *r, char *s, wchar_t wchar, const char *charset, - mbstate_t *state) -{ - return __db_wctomb (r,s, wchar, 936); -} - -extern "C" int -__kr_wctomb (struct _reent *r, char *s, wchar_t wchar, const char *charset, - mbstate_t *state) -{ - return __db_wctomb (r,s, wchar, 949); -} - -extern "C" int -__big5_wctomb (struct _reent *r, char *s, wchar_t wchar, const char *charset, - mbstate_t *state) -{ - return __db_wctomb (r,s, wchar, 950); -} - -static int -__db_mbtowc (struct _reent *r, wchar_t *pwc, const char *s, size_t n, UINT cp, - mbstate_t *state) -{ - wchar_t dummy; - int ret; - - if (s == NULL) - return 0; /* not state-dependent */ - - if (n == 0) - return -2; - - if (pwc == NULL) - pwc = &dummy; - - if (state->__count == 0) - { - if (*(unsigned char *) s < 0x80) - { - *pwc = *(unsigned char *) s; - return *s ? 1 : 0; - } - size_t cnt = min (n, 2); - ret = MultiByteToWideChar (cp, MB_ERR_INVALID_CHARS, s, cnt, pwc, 1); - if (ret) - return cnt; - if (n == 1) - { - state->__count = n; - state->__value.__wchb[0] = *s; - return -2; - } - /* These Win32 functions are really crappy. Assuming n is 2 but the - first byte is a singlebyte charcode, the function does not convert - that byte and return 1, rather it just returns 0. So, what we do - here is to check if the first byte returns a valid value... */ - else if (MultiByteToWideChar (cp, MB_ERR_INVALID_CHARS, s, 1, pwc, 1)) - return 1; - r->_errno = EILSEQ; - return -1; - } - state->__value.__wchb[state->__count] = *s; - ret = MultiByteToWideChar (cp, MB_ERR_INVALID_CHARS, - (const char *) state->__value.__wchb, 2, pwc, 1); - if (!ret) - { - r->_errno = EILSEQ; - return -1; - } - state->__count = 0; - return 1; -} - -extern "C" int -__sjis_mbtowc (struct _reent *r, wchar_t *pwc, const char *s, size_t n, - const char *charset, mbstate_t *state) -{ - return __db_mbtowc (r, pwc, s, n, 932, state); -} - -extern "C" int -__eucjp_mbtowc (struct _reent *r, wchar_t *pwc, const char *s, size_t n, - const char *charset, mbstate_t *state) -{ - /* See comment in __eucjp_wctomb above. */ - wchar_t dummy; - int ret = 0; - - if (s == NULL) - return 0; /* not state-dependent */ - - if (n == 0) - return -2; - - if (pwc == NULL) - pwc = &dummy; - - if (state->__count == 0) - { - if (*(unsigned char *) s < 0x80) - { - *pwc = *(unsigned char *) s; - return *s ? 1 : 0; - } - if (*(unsigned char *) s == 0x8f) /* JIS-X-0212 lead byte? */ - { - /* Yes. Store sequence in mbstate and handle in the __count != 0 - case at the end of the function. */ - size_t i; - for (i = 0; i < 3 && i < n; i++) - state->__value.__wchb[i] = s[i]; - if ((state->__count = i) < 3) /* Incomplete sequence? */ - return -2; - ret = 3; - goto jis_x_0212; - } - size_t cnt = min (n, 2); - if (MultiByteToWideChar (20932, MB_ERR_INVALID_CHARS, s, cnt, pwc, 1)) - return cnt; - if (n == 1) - { - state->__count = 1; - state->__value.__wchb[0] = *s; - return -2; - } - else if (MultiByteToWideChar (20932, MB_ERR_INVALID_CHARS, s, 1, pwc, 1)) - return 1; - r->_errno = EILSEQ; - return -1; - } - state->__value.__wchb[state->__count++] = *s; - ret = 1; -jis_x_0212: - if (state->__value.__wchb[0] == 0x8f) - { - if (state->__count == 2) - { - if (n == 1) - return -2; - state->__value.__wchb[state->__count] = s[1]; - ret = 2; - } - /* Ok, we have a full JIS-X-0212 sequence in mbstate. Convert it - to the CP 20932 representation and feed it to MultiByteToWideChar. */ - state->__value.__wchb[0] = state->__value.__wchb[1]; - state->__value.__wchb[1] = state->__value.__wchb[2] & 0x7f; - } - if (!MultiByteToWideChar (20932, MB_ERR_INVALID_CHARS, - (const char *) state->__value.__wchb, 2, pwc, 1)) - { - r->_errno = EILSEQ; - return -1; - } - state->__count = 0; - return ret; -} - -extern "C" int -__gbk_mbtowc (struct _reent *r, wchar_t *pwc, const char *s, size_t n, - const char *charset, mbstate_t *state) -{ - return __db_mbtowc (r, pwc, s, n, 936, state); -} - -extern "C" int -__kr_mbtowc (struct _reent *r, wchar_t *pwc, const char *s, size_t n, - const char *charset, mbstate_t *state) -{ - return __db_mbtowc (r, pwc, s, n, 949, state); -} - -extern "C" int -__big5_mbtowc (struct _reent *r, wchar_t *pwc, const char *s, size_t n, - const char *charset, mbstate_t *state) -{ - return __db_mbtowc (r, pwc, s, n, 950, state); -} - -/* Our own sys_wcstombs/sys_mbstowcs functions differ from the - wcstombs/mbstowcs API in three ways: - - - The UNICODE private use area is used in filenames to specify - characters not allowed in Windows filenames ('*', '?', etc). - The sys_wcstombs converts characters in the private use area - back to the corresponding ASCII chars. - - - If a wide character in a filename has no representation in the current - multibyte charset, then usually you wouldn't be able to access the - file. To fix this problem, sys_wcstombs creates a replacement multibyte - sequences for the non-representable wide-char. The sequence starts with - an ASCII CAN (0x18, Ctrl-X), followed by the UTF-8 representation of the - character. The sys_(cp_)mbstowcs function detects ASCII CAN characters - in the input multibyte string and converts the following multibyte - sequence in by treating it as an UTF-8 char. If that fails, the ASCII - CAN was probably standalone and it gets just copied over as ASCII CAN. - - - The functions always create 0-terminated results, no matter what. - If the result is truncated due to buffer size, it's a bug in Cygwin - and the buffer in the calling function should be raised. */ -size_t __stdcall -sys_cp_wcstombs (wctomb_p f_wctomb, const char *charset, char *dst, size_t len, - const wchar_t *src, size_t nwc) -{ - char buf[10]; - char *ptr = dst; - wchar_t *pwcs = (wchar_t *) src; - size_t n = 0; - mbstate_t ps; - save_errno save; - - memset (&ps, 0, sizeof ps); - if (dst == NULL) - len = (size_t) -1; - while (n < len && nwc-- > 0) - { - wchar_t pw = *pwcs; - int bytes; - unsigned char cwc; - - /* Convert UNICODE private use area. Reverse functionality for the - ASCII area <= 0x7f (only for path names) is transform_chars above. - Reverse functionality for invalid bytes in a multibyte sequence is - in sys_cp_mbstowcs below. */ - if ((pw & 0xff00) == 0xf000 - && (((cwc = (pw & 0xff)) <= 0x7f && tfx_chars[cwc] >= 0xf000) - || (cwc >= 0x80 && MB_CUR_MAX > 1))) - { - buf[0] = (char) cwc; - bytes = 1; - } - else - { - bytes = f_wctomb (_REENT, buf, pw, charset, &ps); - if (bytes == -1 && *charset != 'U'/*TF-8*/) - { - /* Convert chars invalid in the current codepage to a sequence - ASCII CAN; UTF-8 representation of invalid char. */ - buf[0] = 0x18; /* ASCII CAN */ - bytes = __utf8_wctomb (_REENT, buf + 1, pw, charset, &ps); - if (bytes == -1) - { - ++pwcs; - ps.__count = 0; - continue; - } - ++bytes; /* Add the ASCII CAN to the byte count. */ - if (ps.__count == -4 && nwc > 0) - { - /* First half of a surrogate pair. */ - ++pwcs; - if ((*pwcs & 0xfc00) != 0xdc00) /* Invalid second half. */ - { - ++pwcs; - ps.__count = 0; - continue; - } - bytes += __utf8_wctomb (_REENT, buf + bytes, *pwcs, charset, - &ps); - nwc--; - } - } - } - if (n + bytes <= len) - { - n += bytes; - if (dst) - { - for (int i = 0; i < bytes; ++i) - *ptr++ = buf[i]; - } - if (*pwcs++ == 0x00) - break; - } - else - break; - } - if (n && dst) - { - n = (n < len) ? n : len - 1; - dst[n] = '\0'; - } - - return n; -} - -size_t __stdcall -sys_wcstombs (char *dst, size_t len, const wchar_t * src, size_t nwc) -{ - return sys_cp_wcstombs (cygheap->locale.wctomb, cygheap->locale.charset, - dst, len, src, nwc); -} - -/* Allocate a buffer big enough for the string, always including the - terminating '\0'. The buffer pointer is returned in *dst_p, the return - value is the number of bytes written to the buffer, as usual. - The "type" argument determines where the resulting buffer is stored. - It's either one of the cygheap_types values, or it's "HEAP_NOTHEAP". - In the latter case the allocation uses simple calloc. - - Note that this code is shared by cygserver (which requires it via - __small_vsprintf) and so when built there plain calloc is the - only choice. */ -size_t __stdcall -sys_wcstombs_alloc (char **dst_p, int type, const wchar_t *src, size_t nwc) -{ - size_t ret; - - ret = sys_wcstombs (NULL, (size_t) -1, src, nwc); - if (ret > 0) - { - size_t dlen = ret + 1; - - if (type == HEAP_NOTHEAP) - *dst_p = (char *) calloc (dlen, sizeof (char)); - else - *dst_p = (char *) ccalloc ((cygheap_types) type, dlen, sizeof (char)); - if (!*dst_p) - return 0; - ret = sys_wcstombs (*dst_p, dlen, src, nwc); - } - return ret; -} - -/* sys_cp_mbstowcs is actually most of the time called as sys_mbstowcs with - a 0 codepage. If cp is not 0, the codepage is evaluated and used for the - conversion. This is so that fhandler_console can switch to an alternate - charset, which is the charset returned by GetConsoleCP (). Most of the - time this is used for box and line drawing characters. */ -size_t __stdcall -sys_cp_mbstowcs (mbtowc_p f_mbtowc, const char *charset, wchar_t *dst, - size_t dlen, const char *src, size_t nms) -{ - wchar_t *ptr = dst; - unsigned const char *pmbs = (unsigned const char *) src; - size_t count = 0; - size_t len = dlen; - int bytes; - mbstate_t ps; - save_errno save; - - memset (&ps, 0, sizeof ps); - if (dst == NULL) - len = (size_t)-1; - while (len > 0 && nms > 0) - { - /* ASCII CAN handling. */ - if (*pmbs == 0x18) - { - /* Sanity check: If this is a lead CAN byte for a following UTF-8 - sequence, there must be at least two more bytes left, and the - next byte must be a valid UTF-8 start byte. If the charset - isn't UTF-8 anyway, try to convert the following bytes as UTF-8 - sequence. */ - if (nms > 2 && pmbs[1] >= 0xc2 && pmbs[1] <= 0xf4 && *charset != 'U'/*TF-8*/) - { - bytes = __utf8_mbtowc (_REENT, ptr, (const char *) pmbs + 1, - nms - 1, charset, &ps); - if (bytes < 0) - { - /* Invalid UTF-8 sequence? Treat the ASCII CAN character as - stand-alone ASCII CAN char. */ - bytes = 1; - if (dst) - *ptr = 0x18; - memset (&ps, 0, sizeof ps); - } - else - { - ++bytes; /* Count CAN byte */ - if (bytes > 1 && ps.__count == 4) - { - /* First half of a surrogate. */ - wchar_t *ptr2 = dst ? ptr + 1 : NULL; - int bytes2 = __utf8_mbtowc (_REENT, ptr2, - (const char *) pmbs + bytes, - nms - bytes, charset, &ps); - if (bytes2 < 0) - memset (&ps, 0, sizeof ps); - else - { - bytes += bytes2; - ++count; - ptr = dst ? ptr + 1 : NULL; - --len; - } - } - } - } - /* Otherwise it's just a simple ASCII CAN. */ - else - { - bytes = 1; - if (dst) - *ptr = 0x18; - } - } - else if ((bytes = f_mbtowc (_REENT, ptr, (const char *) pmbs, nms, - charset, &ps)) < 0) - { - /* The technique is based on a discussion here: - http://www.mail-archive.com/linux-utf8@nl.linux.org/msg00080.html - - Invalid bytes in a multibyte secuence are converted to - the private use area which is already used to store ASCII - chars invalid in Windows filenames. This technque allows - to store them in a symmetric way. */ - bytes = 1; - if (dst) - *ptr = L'\xf000' | *pmbs; - memset (&ps, 0, sizeof ps); - } - - if (bytes > 0) - { - pmbs += bytes; - nms -= bytes; - ++count; - ptr = dst ? ptr + 1 : NULL; - --len; - } - else - { - if (bytes == 0) - ++count; - break; - } - } - - if (count && dst) - { - count = (count < dlen) ? count : dlen - 1; - dst[count] = L'\0'; - } - - return count; -} - -size_t __stdcall -sys_mbstowcs (wchar_t * dst, size_t dlen, const char *src, size_t nms) -{ - return sys_cp_mbstowcs (cygheap->locale.mbtowc, cygheap->locale.charset, - dst, dlen, src, nms); -} - -/* Same as sys_wcstombs_alloc, just backwards. */ -size_t __stdcall -sys_mbstowcs_alloc (wchar_t **dst_p, int type, const char *src, size_t nms) -{ - size_t ret; - - ret = sys_mbstowcs (NULL, (size_t) -1, src, nms); - if (ret > 0) - { - size_t dlen = ret + 1; - - if (type == HEAP_NOTHEAP) - *dst_p = (wchar_t *) calloc (dlen, sizeof (wchar_t)); - else - *dst_p = (wchar_t *) ccalloc ((cygheap_types) type, dlen, - sizeof (wchar_t)); - if (!*dst_p) - return 0; - ret = sys_mbstowcs (*dst_p, dlen, src, nms); - } - return ret; -} - -static WCHAR hex_wchars[] = L"0123456789abcdef"; - -NTSTATUS NTAPI -RtlInt64ToHexUnicodeString (ULONGLONG value, PUNICODE_STRING dest, - BOOLEAN append) -{ - USHORT len = append ? dest->Length : 0; - if (dest->MaximumLength - len < 16 * (int) sizeof (WCHAR)) - return STATUS_BUFFER_OVERFLOW; - wchar_t *end = (PWCHAR) ((PBYTE) dest->Buffer + len); - register PWCHAR p = end + 16; - while (p-- > end) - { - *p = hex_wchars[value & 0xf]; - value >>= 4; - } - dest->Length += 16 * sizeof (WCHAR); - return STATUS_SUCCESS; -} diff --git a/winsup/cygwin/string.h b/winsup/cygwin/string.h deleted file mode 100644 index b02fadb8f..000000000 --- a/winsup/cygwin/string.h +++ /dev/null @@ -1,126 +0,0 @@ -/* string.h: Extra string defs - - Copyright 2001, 2007, 2008 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGWIN_STRING_H -#define _CYGWIN_STRING_H - -#include_next - -#ifdef __cplusplus -extern "C" { -#endif - -#undef strechr -#define strechr cygwin_strechr -static inline __stdcall char * -strechr (const char *s, int c) -{ - register char * res; - __asm__ __volatile__ ("\ - movb %%al,%%ah\n\ -1: movb (%1),%%al\n\ - cmpb %%ah,%%al\n\ - je 2f\n\ - incl %1\n\ - testb %%al,%%al\n\ - jne 1b\n\ - decl %1\n\ -2: movl %1,%0\n\ - ":"=a" (res), "=r" (s) - :"0" (c), "1" (s)); - return res; -} - -#ifdef __INSIDE_CYGWIN__ - -extern const char isalpha_array[]; - -static inline int -ascii_strcasematch (const char *cs, const char *ct) -{ - register int __res; - int d0, d1; - __asm__ ("\ - .global _isalpha_array \n\ - cld \n\ - andl $0xff,%%eax \n\ -1: lodsb \n\ - scasb \n\ - je 2f \n\ - xorb _isalpha_array(%%eax),%%al \n\ - cmpb -1(%%edi),%%al \n\ - jne 3f \n\ -2: testb %%al,%%al \n\ - jnz 1b \n\ - movl $1,%%eax \n\ - jmp 4f \n\ -3: xor %0,%0 \n\ -4:" - :"=a" (__res), "=&S" (d0), "=&D" (d1) - : "1" (cs), "2" (ct)); - - return __res; -} - -static inline int -ascii_strncasematch (const char *cs, const char *ct, size_t n) -{ - register int __res; - int d0, d1, d2; - __asm__ ("\ - .global _isalpha_array; \n\ - cld \n\ - andl $0xff,%%eax \n\ -1: decl %3 \n\ - js 3f \n\ - lodsb \n\ - scasb \n\ - je 2f \n\ - xorb _isalpha_array(%%eax),%%al \n\ - cmpb -1(%%edi),%%al \n\ - jne 4f \n\ -2: testb %%al,%%al \n\ - jnz 1b \n\ -3: movl $1,%%eax \n\ - jmp 5f \n\ -4: xor %0,%0 \n\ -5:" - :"=a" (__res), "=&S" (d0), "=&D" (d1), "=&c" (d2) - :"1" (cs), "2" (ct), "3" (n)); - - return __res; -} - -#undef strcasecmp -#define strcasecmp cygwin_strcasecmp -int __stdcall cygwin_strcasecmp (const char *, const char *); - -#undef strncasecmp -#define strncasecmp cygwin_strncasecmp -int __stdcall cygwin_strncasecmp (const char *, const char *, size_t); - -#define strcasematch(s1,s2) (!cygwin_strcasecmp ((s1),(s2))) -#define strncasematch(s1,s2,n) (!cygwin_strncasecmp ((s1),(s2),(n))) - -#undef strlwr -#define strlwr cygwin_strlwr -char * __stdcall cygwin_strlwr (char *); - -#undef strupr -#define strupr cygwin_strupr -char * __stdcall cygwin_strupr (char *); - -#endif /* __INSIDE_CYGWIN__ */ - -#ifdef __cplusplus -} -#endif - -#endif /* _CYGWIN_STRING_H */ diff --git a/winsup/cygwin/strsep.cc b/winsup/cygwin/strsep.cc deleted file mode 100644 index f03df3d94..000000000 --- a/winsup/cygwin/strsep.cc +++ /dev/null @@ -1,64 +0,0 @@ -/* strsep.cc: strsep call */ - -#include - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - */ - -extern "C" char * -strsep (char **stringp, - const char *delim) -{ - register char *s; - register const char *spanp; - register int c, sc; - char *tok; - - if ((s = *stringp) == NULL) - return (NULL); - for (tok = s;;) { - c = *s++; - spanp = delim; - do { - if ((sc = *spanp++) == c) { - if (c == 0) - s = NULL; - else - s[-1] = 0; - *stringp = s; - return (tok); - } - } while (sc != 0); - } - /* NOTREACHED */ -} diff --git a/winsup/cygwin/strsig.cc b/winsup/cygwin/strsig.cc deleted file mode 100644 index 8bc8c1c8c..000000000 --- a/winsup/cygwin/strsig.cc +++ /dev/null @@ -1,97 +0,0 @@ -/* strsig.cc - - Copyright 2004 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include - -struct sigdesc -{ - int n; - const char *name; - const char *str; -}; - -#define __signals \ - _s(SIGHUP, "Hangup"), /* 1 */ \ - _s(SIGINT, "Interrupt"), /* 2 */ \ - _s(SIGQUIT, "Quit"), /* 3 */ \ - _s(SIGILL, "Illegal instruction"), /* 4 */ \ - _s(SIGTRAP, "Trace/breakpoint trap"), /* 5 */ \ - _s(SIGABRT, "Aborted"), /* 6 */ \ - _s(SIGEMT, "EMT instruction"), /* 7 */ \ - _s(SIGFPE, "Floating point exception"), /* 8 */ \ - _s(SIGKILL, "Killed"), /* 9 */ \ - _s(SIGBUS, "Bus error"), /* 10 */ \ - _s(SIGSEGV, "Segmentation fault"), /* 11 */ \ - _s(SIGSYS, "Bad system call"), /* 12 */ \ - _s(SIGPIPE, "Broken pipe"), /* 13 */ \ - _s(SIGALRM, "Alarm clock"), /* 14 */ \ - _s(SIGTERM, "Terminated"), /* 15 */ \ - _s(SIGURG, "Urgent I/O condition"), /* 16 */ \ - _s(SIGSTOP, "Stopped (signal)"), /* 17 */ \ - _s(SIGTSTP, "Stopped"), /* 18 */ \ - _s(SIGCONT, "Continued"), /* 19 */ \ - _s2(SIGCHLD, "Child exited", /* 20 */ \ - SIGCLD, "Child exited"), \ - _s(SIGTTIN, "Stopped (tty input)"), /* 21 */ \ - _s(SIGTTOU, "Stopped (tty output)"), /* 22 */ \ - _s2(SIGIO, "I/O possible", /* 23 */ \ - SIGPOLL, "I/O possible"), \ - _s(SIGXCPU, "CPU time limit exceeded"), /* 24 */ \ - _s(SIGXFSZ, "File size limit exceeded"), /* 25 */ \ - _s(SIGVTALRM, "Virtual timer expired"), /* 26 */ \ - _s(SIGPROF, "Profiling timer expired"), /* 27 */ \ - _s(SIGWINCH, "Window changed"), /* 28 */ \ - _s(SIGLOST, "Resource lost"), /* 29 */ \ - _s(SIGUSR1, "User defined signal 1"), /* 30 */ \ - _s(SIGUSR2, "User defined signal 2"), /* 31 */ \ - _s2(SIGRTMIN, "Real-time signal 0", /* 32 */ \ - SIGRTMAX, "Real-time signal 0") - -#define _s(n, s) #n -#define _s2(n, s, n1, s1) #n -const char *sys_sigabbrev[] NO_COPY_INIT = -{ - NULL, - __signals -}; - -#undef _s -#undef _s2 -#define _s(n, s) {n, #n, s} -#define _s2(n, s, n1, s1) {n, #n, s}, {n, #n1, #s1} -static const sigdesc siglist[] = -{ - __signals, - {0, NULL, NULL} -}; - -extern "C" char * -strsignal (int signo) -{ - const char *sigstring = "Unknown signal %d"; - for (int i = 0; siglist[i].n; i++) - if (siglist[i].n == signo) - { - sigstring = siglist[i].str; - break; - } - __small_sprintf (_my_tls.locals.signamebuf, sigstring, signo); - return _my_tls.locals.signamebuf; -} - -extern "C" int -strtosigno (const char *name) -{ - for (int i = 0; siglist[i].n; i++) - if (strcmp (siglist[i].name, name) == 0) - return siglist[i].n; - return 0; -} diff --git a/winsup/cygwin/sync.cc b/winsup/cygwin/sync.cc deleted file mode 100644 index 8fa0d93f0..000000000 --- a/winsup/cygwin/sync.cc +++ /dev/null @@ -1,151 +0,0 @@ -/* sync.cc: Synchronization functions for cygwin. - - This file implements the methods for controlling the "muto" class - which is intended to operate similarly to a mutex but attempts to - avoid making expensive calls to the kernel. - - Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "miscfuncs.h" -#include "sync.h" -#include "thread.h" -#include "cygtls.h" - -#undef WaitForSingleObject - -DWORD NO_COPY muto::exiting_thread; -muto NO_COPY lock_process::locker; - -void -muto::grab () -{ - tls = &_my_tls; -} - -/* Constructor */ -muto * -muto::init (const char *s) -{ - char *already_exists = (char *) InterlockedExchangePointer (&name, s); - if (already_exists) - while (!bruteforce) - low_priority_sleep (0); - else - { - waiters = -1; - /* Create event which is used in the fallback case when blocking is necessary */ - bruteforce = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL); - if (!bruteforce) - api_fatal ("couldn't allocate muto '%s', %E", s); - } - - return this; -} - -#if 0 /* FIXME: Do we need this? mutos aren't destroyed until process exit */ -/* Destructor (racy?) */ -muto::~muto () -{ - while (visits) - release (); - - HANDLE h = bruteforce; - bruteforce = NULL; - /* Just need to close the event handle */ - if (h) - CloseHandle (h); -} -#endif - -/* Acquire the lock. Argument is the number of milliseconds to wait for - the lock. Multiple visits from the same thread are allowed and should - be handled correctly. - - Note: The goal here is to minimize, as much as possible, calls to the - OS. Hence the use of InterlockedIncrement, etc., rather than (much) more - expensive OS mutexes. Also note that the only two valid "ms" times are - 0 and INFINITE. */ -int -muto::acquire (DWORD ms) -{ - void *this_tls = &_my_tls; -#if 0 - if (exiting_thread) - return this_tid == exiting_thread; -#endif - - if (tls != this_tls) - { - /* Increment the waiters part of the class. Need to do this first to - avoid potential races. */ - LONG was_waiting = ms ? InterlockedIncrement (&waiters) : 0; - - while (was_waiting || InterlockedExchange (&sync, 1) != 0) - switch (WaitForSingleObject (bruteforce, ms)) - { - case WAIT_OBJECT_0: - was_waiting = 0; - break; - default: - return 0; /* failed. */ - } - - /* Have to do it this way to avoid a race */ - if (!ms) - InterlockedIncrement (&waiters); - - tls = this_tls; /* register this thread. */ - } - - return ++visits; /* Increment visit count. */ -} - -bool -muto::acquired () -{ - return tls == &_my_tls; -} - -/* Return the muto lock. Needs to be called once per every acquire. */ -int -muto::release () -{ - void *this_tls = &_my_tls; - - if (tls != this_tls || !visits) - { - SetLastError (ERROR_NOT_OWNER); /* Didn't have the lock. */ - return 0; /* failed. */ - } - - /* FIXME: Need to check that other thread has not exited, too. */ - if (!--visits) - { - tls = 0; /* We were the last unlocker. */ - InterlockedExchange (&sync, 0); /* Reset trigger. */ - /* This thread had incremented waiters but had never decremented it. - Decrement it now. If it is >= 0 then there are possibly other - threads waiting for the lock, so trigger bruteforce. */ - if (InterlockedDecrement (&waiters) >= 0) - SetEvent (bruteforce); /* Wake up one of the waiting threads */ - else if (*name == '!') - { - CloseHandle (bruteforce); /* If *name == '!' and there are no - other waiters, then this is the - last time this muto will ever be - used, so close the handle. */ -#ifdef DEBUGGING - bruteforce = NULL; -#endif - } - } - - return 1; /* success. */ -} diff --git a/winsup/cygwin/sync.h b/winsup/cygwin/sync.h deleted file mode 100644 index dfe2c3921..000000000 --- a/winsup/cygwin/sync.h +++ /dev/null @@ -1,73 +0,0 @@ -/* sync.h: Header file for cygwin synchronization primitives. - - Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc. - - Written by Christopher Faylor - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _SYNC_H -#define _SYNC_H -/* FIXME: Note that currently this class cannot be allocated via `new' since - there are issues with malloc and fork. */ -class muto -{ -public: - const char *name; -private: - static DWORD exiting_thread; - LONG sync; /* Used to serialize access to this class. */ - LONG waiters; /* Number of threads waiting for lock. */ - HANDLE bruteforce; /* event handle used to control waiting for lock. */ -public: - LONG visits; /* Count of number of times a thread has called acquire. */ - void *tls; /* Tls of lock owner. */ - // class muto *next; - - /* The real constructor. */ - muto *init (const char *) __attribute__ ((regparm (2))); - -#if 0 /* FIXME: See comment in sync.cc */ - ~muto () -#endif - int acquire (DWORD ms = INFINITE) __attribute__ ((regparm (2))); /* Acquire the lock. */ - int release () __attribute__ ((regparm (1))); /* Release the lock. */ - - bool acquired () __attribute__ ((regparm (1))); - void upforgrabs () {tls = this;} // just set to an invalid address - void grab () __attribute__ ((regparm (1))); - operator int () const {return !!name;} - static void set_exiting_thread () {exiting_thread = GetCurrentThreadId ();} -}; - -class lock_process -{ - bool skip_unlock; - static muto locker; -public: - static void init () {locker.init ("lock_process");} - void dont_bother () {skip_unlock = true;} - lock_process (bool exiting = false) - { - locker.acquire (); - skip_unlock = exiting; - if (exiting && exit_state < ES_PROCESS_LOCKED) - { - exit_state = ES_PROCESS_LOCKED; - muto::set_exiting_thread (); - } - } - ~lock_process () - { - if (!skip_unlock) - locker.release (); - } - friend class dtable; - friend class fhandler_fifo; -}; - -#endif /*_SYNC_H*/ diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc deleted file mode 100644 index d105f4e82..000000000 --- a/winsup/cygwin/syscalls.cc +++ /dev/null @@ -1,4292 +0,0 @@ -/* syscalls.cc: syscalls - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#define fstat __FOOfstat__ -#define lstat __FOOlstat__ -#define stat __FOOstat__ -#define _close __FOO_close__ -#define _lseek __FOO_lseek__ -#define _open __FOO_open__ -#define _read __FOO_read__ -#define _write __FOO_write__ -#define _open64 __FOO_open64__ -#define _lseek64 __FOO_lseek64__ -#define _fstat64 __FOO_fstat64__ -#define pread __FOO_pread -#define pwrite __FOO_pwrite - -#include "winsup.h" -#include -#include "miscfuncs.h" -#include -#include /* needed for statfs */ -#include /* needed for statvfs */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ntdll.h" - -#undef fstat -#undef lstat -#undef stat -#undef pread -#undef pwrite - -#include -#include "cygerrno.h" -#include "perprocess.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "sigproc.h" -#include "pinfo.h" -#include "shared_info.h" -#include "cygheap.h" -#include "pwdgrp.h" -#include "cpuid.h" -#include "registry.h" -#include "environ.h" -#include "tls_pbuf.h" - -#undef _close -#undef _lseek -#undef _open -#undef _read -#undef _write -#undef _open64 -#undef _lseek64 -#undef _fstat64 - -static int __stdcall mknod_worker (const char *, mode_t, mode_t, _major_t, - _minor_t); - -/* Close all files and process any queued deletions. - Lots of unix style applications will open a tmp file, unlink it, - but never call close. This function is called by _exit to - ensure we don't leave any such files lying around. */ - -void __stdcall -close_all_files (bool norelease) -{ - cygheap->fdtab.lock (); - - semaphore::terminate (); - - fhandler_base *fh; - HANDLE h = NULL; - - for (int i = 0; i < (int) cygheap->fdtab.size; i++) - if ((fh = cygheap->fdtab[i]) != NULL) - { -#ifdef DEBUGGING - debug_printf ("closing fd %d", i); -#endif - if (i == 2) - DuplicateHandle (GetCurrentProcess (), fh->get_output_handle (), - GetCurrentProcess (), &h, - 0, false, DUPLICATE_SAME_ACCESS); - fh->close (); - if (!norelease) - cygheap->fdtab.release (i); - } - - if (!hExeced && cygheap->ctty) - cygheap->close_ctty (); - - if (h) - SetStdHandle (STD_ERROR_HANDLE, h); - cygheap->fdtab.unlock (); -} - -extern "C" int -dup (int fd) -{ - return cygheap->fdtab.dup3 (fd, cygheap_fdnew (), 0); -} - -extern "C" int -dup2 (int oldfd, int newfd) -{ - if (newfd >= OPEN_MAX_MAX) - { - syscall_printf ("-1 = dup2 (%d, %d) (%d too large)", oldfd, newfd, newfd); - set_errno (EBADF); - return -1; - } - if (newfd == oldfd) - { - cygheap_fdget cfd (oldfd); - if (cfd < 0) - { - syscall_printf ("-1 = dup2 (%d, %d) (oldfd not open)", oldfd, newfd); - return -1; - } - syscall_printf ("%d = dup2 (%d, %d) (newfd==oldfd)", oldfd, oldfd, newfd); - return oldfd; - } - return cygheap->fdtab.dup3 (oldfd, newfd, 0); -} - -extern "C" int -dup3 (int oldfd, int newfd, int flags) -{ - if (newfd >= OPEN_MAX_MAX) - { - syscall_printf ("-1 = dup3 (%d, %d, %p) (%d too large)", - oldfd, newfd, flags, newfd); - set_errno (EBADF); - return -1; - } - if (newfd == oldfd) - { - cygheap_fdget cfd (oldfd, false, false); - set_errno (cfd < 0 ? EBADF : EINVAL); - syscall_printf ("-1 = dup3 (%d, %d, %p) (newfd==oldfd)", - oldfd, newfd, flags); - return -1; - } - return cygheap->fdtab.dup3 (oldfd, newfd, flags); -} - -static char desktop_ini[] = - "[.ShellClassInfo]\r\nCLSID={645FF040-5081-101B-9F08-00AA002F954E}\r\n"; -static BYTE info2[] = -{ - 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x20, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -enum bin_status -{ - dont_move, - move_to_bin, - has_been_moved -}; - -static bin_status -try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access) -{ - bin_status bin_stat = move_to_bin; - NTSTATUS status; - OBJECT_ATTRIBUTES attr; - IO_STATUS_BLOCK io; - HANDLE rootdir = NULL, recyclerdir = NULL, tmp_fh = NULL; - USHORT recycler_base_len = 0, recycler_user_len = 0; - UNICODE_STRING root, recycler, fname; - WCHAR recyclerbuf[NAME_MAX + 1]; /* Enough for recycler + SID + filename */ - PFILE_NAME_INFORMATION pfni; - PFILE_INTERNAL_INFORMATION pfii; - PFILE_RENAME_INFORMATION pfri; - FILE_DISPOSITION_INFORMATION disp = { TRUE }; - - tmp_pathbuf tp; - PBYTE infobuf = (PBYTE) tp.w_get (); - - pfni = (PFILE_NAME_INFORMATION) infobuf; - status = NtQueryInformationFile (fh, &io, pfni, 65536, FileNameInformation); - if (!NT_SUCCESS (status)) - { - debug_printf ("NtQueryInformationFile (FileNameInformation) failed, %08x", - status); - goto out; - } - /* The filename could change, the parent dir not. So we split both paths - and take the prefix. However, there are two special cases: - - The handle refers to the root dir of the volume. - - The handle refers to the recycler or a subdir. - Both cases are handled by just returning and not even trying to move - them into the recycler. */ - if (pfni->FileNameLength == 2) /* root dir. */ - goto out; - /* Initialize recycler path. */ - RtlInitEmptyUnicodeString (&recycler, recyclerbuf, sizeof recyclerbuf); - if (!pc.isremote ()) - { - if (wincap.has_recycle_dot_bin ()) /* NTFS and FAT since Vista */ - RtlAppendUnicodeToString (&recycler, L"\\$Recycle.Bin\\"); - else if (pc.fs_is_ntfs ()) /* NTFS up to 2K3 */ - RtlAppendUnicodeToString (&recycler, L"\\RECYCLER\\"); - else if (pc.fs_is_fat ()) /* FAT up to 2K3 */ - RtlAppendUnicodeToString (&recycler, L"\\Recycled\\"); - else - goto out; - /* Is the file a subdir of the recycler? */ - RtlInitCountedUnicodeString(&fname, pfni->FileName, pfni->FileNameLength); - if (RtlEqualUnicodePathPrefix (&fname, &recycler, TRUE)) - goto out; - /* Is fname the recycler? Temporarily hide trailing backslash. */ - recycler.Length -= sizeof (WCHAR); - if (RtlEqualUnicodeString (&fname, &recycler, TRUE)) - goto out; - - /* Create root dir path from file name information. */ - RtlSplitUnicodePath (&fname, &fname, NULL); - RtlSplitUnicodePath (pc.get_nt_native_path (), &root, NULL); - root.Length -= fname.Length - sizeof (WCHAR); - - /* Open root directory. All recycler bin ops are caseinsensitive. */ - InitializeObjectAttributes (&attr, &root, OBJ_CASE_INSENSITIVE, - NULL, NULL); - status = NtOpenFile (&rootdir, FILE_TRAVERSE, &attr, &io, - FILE_SHARE_VALID_FLAGS, FILE_OPEN_FOR_BACKUP_INTENT); - if (!NT_SUCCESS (status)) - { - debug_printf ("NtOpenFile (%S) failed, %08x", &root, status); - goto out; - } - - /* Strip leading backslash */ - ++recycler.Buffer; - recycler.Length -= sizeof (WCHAR); - /* Store length of recycler base dir, if it's necessary to create it. */ - recycler_base_len = recycler.Length; - /* On NTFS the recycler dir contains user specific subdirs, which are the - actual recycle bins per user. The name if this dir is the string - representation of the user SID. */ - if (pc.fs_is_ntfs ()) - { - UNICODE_STRING sid; - WCHAR sidbuf[128]; - /* Unhide trailing backslash. */ - recycler.Length += sizeof (WCHAR); - RtlInitEmptyUnicodeString (&sid, sidbuf, sizeof sidbuf); - /* In contrast to what MSDN claims, this function is already available - since NT4. */ - RtlConvertSidToUnicodeString (&sid, cygheap->user.sid (), FALSE); - RtlAppendUnicodeStringToString (&recycler, &sid); - recycler_user_len = recycler.Length; - } - RtlAppendUnicodeToString (&recycler, L"\\"); - } - /* Create hopefully unique filename. - Since we have to stick to the current directory on remote shares, make - the new filename at least very unlikely to match by accident. It starts - with ".cyg", with "cyg" transposed into the Unicode low surrogate area - starting at U+dc00. Use plain ASCII chars on filesystems not supporting - Unicode. The rest of the filename is the inode number in hex encoding - and a hash of the full NT path in hex. The combination allows to remove - multiple hardlinks to the same file. */ - RtlAppendUnicodeToString (&recycler, - pc.fs_flags () & FILE_UNICODE_ON_DISK - ? L".\xdc63\xdc79\xdc67" : L".cyg"); - pfii = (PFILE_INTERNAL_INFORMATION) infobuf; - status = NtQueryInformationFile (fh, &io, pfii, 65536, - FileInternalInformation); - if (!NT_SUCCESS (status)) - { - debug_printf ("NtQueryInformationFile (FileInternalInformation) failed, " - "%08x", status); - goto out; - } - RtlInt64ToHexUnicodeString (pfii->FileId.QuadPart, &recycler, TRUE); - RtlInt64ToHexUnicodeString (hash_path_name (0, pc.get_nt_native_path ()), - &recycler, TRUE); - /* Shoot. */ - pfri = (PFILE_RENAME_INFORMATION) infobuf; - pfri->ReplaceIfExists = TRUE; - pfri->RootDirectory = pc.isremote () ? NULL : rootdir; - pfri->FileNameLength = recycler.Length; - memcpy (pfri->FileName, recycler.Buffer, recycler.Length); - status = NtSetInformationFile (fh, &io, pfri, 65536, FileRenameInformation); - if (status == STATUS_OBJECT_PATH_NOT_FOUND && !pc.isremote ()) - { - /* Ok, so the recycler and/or the recycler/SID directory don't exist. - First reopen root dir with permission to create subdirs. */ - NtClose (rootdir); - status = NtOpenFile (&rootdir, FILE_ADD_SUBDIRECTORY, &attr, &io, - FILE_SHARE_VALID_FLAGS, FILE_OPEN_FOR_BACKUP_INTENT); - if (!NT_SUCCESS (status)) - { - debug_printf ("NtOpenFile (%S) failed, %08x", &recycler, status); - goto out; - } - /* Then check if recycler exists by opening and potentially creating it. - Yes, we can really do that. Typically the recycle bin is created - by the first user actually using the bin. The permissions are the - default permissions propagated from the root directory. */ - InitializeObjectAttributes (&attr, &recycler, OBJ_CASE_INSENSITIVE, - rootdir, NULL); - recycler.Length = recycler_base_len; - status = NtCreateFile (&recyclerdir, - READ_CONTROL - | (pc.fs_is_ntfs () ? 0 : FILE_ADD_FILE), - &attr, &io, NULL, - FILE_ATTRIBUTE_DIRECTORY - | FILE_ATTRIBUTE_SYSTEM - | FILE_ATTRIBUTE_HIDDEN, - FILE_SHARE_VALID_FLAGS, FILE_OPEN_IF, - FILE_DIRECTORY_FILE, NULL, 0); - if (!NT_SUCCESS (status)) - { - debug_printf ("NtCreateFile (%S) failed, %08x", &recycler, status); - goto out; - } - /* Next, if necessary, check if the recycler/SID dir exists and - create it if not. */ - if (pc.fs_is_ntfs ()) - { - NtClose (recyclerdir); - recycler.Length = recycler_user_len; - status = NtCreateFile (&recyclerdir, READ_CONTROL | FILE_ADD_FILE, - &attr, &io, NULL, FILE_ATTRIBUTE_DIRECTORY - | FILE_ATTRIBUTE_SYSTEM - | FILE_ATTRIBUTE_HIDDEN, - FILE_SHARE_VALID_FLAGS, FILE_OPEN_IF, - FILE_DIRECTORY_FILE, NULL, 0); - if (!NT_SUCCESS (status)) - { - debug_printf ("NtCreateFile (%S) failed, %08x", - &recycler, status); - goto out; - } - } - /* The desktop.ini and INFO2 (pre-Vista) files are expected by - Windows Explorer. Otherwise, the created bin is treated as - corrupted */ - if (io.Information == FILE_CREATED) - { - RtlInitUnicodeString (&fname, L"desktop.ini"); - InitializeObjectAttributes (&attr, &fname, OBJ_CASE_INSENSITIVE, - recyclerdir, NULL); - status = NtCreateFile (&tmp_fh, FILE_GENERIC_WRITE, &attr, &io, NULL, - FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN, - FILE_SHARE_VALID_FLAGS, FILE_CREATE, - FILE_SYNCHRONOUS_IO_NONALERT - | FILE_NON_DIRECTORY_FILE, NULL, 0); - if (!NT_SUCCESS (status)) - debug_printf ("NtCreateFile (%S) failed, %08x", &recycler, status); - else - { - status = NtWriteFile (tmp_fh, NULL, NULL, NULL, &io, desktop_ini, - sizeof desktop_ini - 1, NULL, NULL); - if (!NT_SUCCESS (status)) - debug_printf ("NtWriteFile (%S) failed, %08x", &fname, status); - NtClose (tmp_fh); - } - if (!wincap.has_recycle_dot_bin ()) /* No INFO2 file since Vista */ - { - RtlInitUnicodeString (&fname, L"INFO2"); - status = NtCreateFile (&tmp_fh, FILE_GENERIC_WRITE, &attr, &io, - NULL, FILE_ATTRIBUTE_ARCHIVE - | FILE_ATTRIBUTE_HIDDEN, - FILE_SHARE_VALID_FLAGS, FILE_CREATE, - FILE_SYNCHRONOUS_IO_NONALERT - | FILE_NON_DIRECTORY_FILE, NULL, 0); - if (!NT_SUCCESS (status)) - debug_printf ("NtCreateFile (%S) failed, %08x", - &recycler, status); - else - { - status = NtWriteFile (tmp_fh, NULL, NULL, NULL, &io, info2, - sizeof info2, NULL, NULL); - if (!NT_SUCCESS (status)) - debug_printf ("NtWriteFile (%S) failed, %08x", - &fname, status); - NtClose (tmp_fh); - } - } - } - NtClose (recyclerdir); - /* Shoot again. */ - status = NtSetInformationFile (fh, &io, pfri, 65536, - FileRenameInformation); - } - if (!NT_SUCCESS (status)) - { - debug_printf ("Move %S to %S failed, status = %p", - pc.get_nt_native_path (), &recycler, status); - goto out; - } - /* Moving to the bin worked. */ - bin_stat = has_been_moved; - /* Now we try to set the delete disposition. If that worked, we're done. - We try this here first, as long as we still have the open handle. - Otherwise the below code closes the handle to allow replacing the file. */ - status = NtSetInformationFile (fh, &io, &disp, sizeof disp, - FileDispositionInformation); - /* In case of success, restore R/O attribute to accommodate hardlinks. - That leaves potentially hardlinks around with the R/O bit suddenly - off if setting the delete disposition failed, but please, keep in - mind this is really a border case only. */ - if ((access & FILE_WRITE_ATTRIBUTES) && NT_SUCCESS (status) && !pc.isdir ()) - NtSetAttributesFile (fh, pc.file_attributes ()); - NtClose (fh); - fh = NULL; /* So unlink_nt doesn't close the handle twice. */ - /* On success or when trying to unlink a directory we just return here. - The below code only works for files. */ - if (NT_SUCCESS (status) || pc.isdir ()) - goto out; - /* The final trick. We create a temporary file with delete-on-close - semantic and rename that file to the file just moved to the bin. - This typically overwrites the original file and we get rid of it, - even if neither setting the delete dispostion, nor setting - delete-on-close on the original file succeeds. There are still - cases in which this fails, for instance, when trying to delete a - hardlink to a DLL used by the unlinking application itself. */ - RtlAppendUnicodeToString (&recycler, L"X"); - InitializeObjectAttributes (&attr, &recycler, 0, rootdir, NULL); - status = NtCreateFile (&tmp_fh, DELETE, &attr, &io, NULL, - FILE_ATTRIBUTE_NORMAL, 0, FILE_SUPERSEDE, - FILE_NON_DIRECTORY_FILE | FILE_DELETE_ON_CLOSE, - NULL, 0); - if (!NT_SUCCESS (status)) - { - debug_printf ("Creating file for overwriting failed, status = %p", - status); - goto out; - } - status = NtSetInformationFile (tmp_fh, &io, pfri, 65536, - FileRenameInformation); - NtClose (tmp_fh); - if (!NT_SUCCESS (status)) - debug_printf ("Overwriting with another file failed, status = %p", - status); - -out: - if (rootdir) - NtClose (rootdir); - return bin_stat; -} - -static NTSTATUS -check_dir_not_empty (HANDLE dir) -{ - IO_STATUS_BLOCK io; - const ULONG bufsiz = 3 * sizeof (FILE_NAMES_INFORMATION) - + 3 * NAME_MAX * sizeof (WCHAR); - PFILE_NAMES_INFORMATION pfni = (PFILE_NAMES_INFORMATION) - alloca (bufsiz); - NTSTATUS status = NtQueryDirectoryFile (dir, NULL, NULL, 0, &io, pfni, - bufsiz, FileNamesInformation, - FALSE, NULL, TRUE); - if (!NT_SUCCESS (status)) - { - syscall_printf ("Checking if directory is empty failed, " - "status = %p", status); - return status; - } - int cnt = 1; - while (pfni->NextEntryOffset) - { - pfni = (PFILE_NAMES_INFORMATION) - ((caddr_t) pfni + pfni->NextEntryOffset); - ++cnt; - } - if (cnt > 2) - { - syscall_printf ("Directory not empty"); - return STATUS_DIRECTORY_NOT_EMPTY; - } - return STATUS_SUCCESS; -} - -NTSTATUS -unlink_nt (path_conv &pc) -{ - NTSTATUS status; - HANDLE fh, fh_ro = NULL; - OBJECT_ATTRIBUTES attr; - IO_STATUS_BLOCK io; - - bin_status bin_stat = dont_move; - - ACCESS_MASK access = DELETE; - ULONG flags = FILE_OPEN_FOR_BACKUP_INTENT; - /* Add the reparse point flag to native symlinks, otherwise we remove the - target, not the symlink. */ - if (pc.is_rep_symlink ()) - flags |= FILE_OPEN_REPARSE_POINT; - - pc.get_object_attr (attr, sec_none_nih); - /* If the R/O attribute is set, we have to open the file with - FILE_WRITE_ATTRIBUTES to be able to remove this flags before trying - to delete it. We do this separately because there are filesystems - out there (MVFS), which refuse a request to open a file for DELETE - if the DOS R/O attribute is set for the file. After removing the R/O - attribute, just re-open the file for DELETE and go ahead. */ - if (pc.file_attributes () & FILE_ATTRIBUTE_READONLY) - { - access |= FILE_WRITE_ATTRIBUTES; - status = NtOpenFile (&fh_ro, FILE_WRITE_ATTRIBUTES, &attr, &io, - FILE_SHARE_VALID_FLAGS, flags); - if (NT_SUCCESS (status)) - { - NtSetAttributesFile (fh_ro, pc.file_attributes () - & ~FILE_ATTRIBUTE_READONLY); - InitializeObjectAttributes (&attr, &ro_u_empty, - pc.objcaseinsensitive (), fh_ro, NULL); - } - } - /* First try to open the file with only allowing sharing for delete. If - the file has an open handle on it, other than just for deletion, this - will fail. That indicates that the file has to be moved to the recycle - bin so that it actually disappears from its directory even though its - in use. Otherwise, if opening doesn't fail, the file is not in use and - we can go straight to setting the delete disposition flag. */ - status = NtOpenFile (&fh, access, &attr, &io, FILE_SHARE_DELETE, flags); - if (status == STATUS_SHARING_VIOLATION || status == STATUS_LOCK_NOT_GRANTED) - { - /* STATUS_LOCK_NOT_GRANTED can be generated under not quite clear - circumstances when trying to open a file on NFS with FILE_SHARE_DELETE - only. This has been observed with SFU 3.5 if the NFS share has been - mounted under a drive letter. It's not generated for all files, but - only for some. If it's generated once for a file, it will be - generated all the time. It looks like wrong file state information - is stored within the NFS client, for no apparent reason, which never - times out. Opening the file with FILE_SHARE_VALID_FLAGS will work, - though, and it is then possible to delete the file quite normally. - - NFS implements its own mechanism to remove in-use files which - looks quite similar to what we do in try_to_bin for remote files. - That's why we don't call try_to_bin on NFS. */ - if (!pc.fs_is_nfs ()) - bin_stat = move_to_bin; - if (!pc.isdir () || pc.isremote ()) - status = NtOpenFile (&fh, access, &attr, &io, - FILE_SHARE_VALID_FLAGS, flags); - else - { - /* It's getting tricky. The directory is opened in some process, - so we're supposed to move it to the recycler and mark it for - deletion. But what if the directory is not empty? The move - will work, but the subsequent delete will fail. So we would - have to move it back. That's bad, because the directory would - be moved around which results in a temporary inconsistent state. - So, what we do here is to test if the directory is empty. If - not, we bail out with ERROR_DIR_NOT_EMTPY. The below code - tests for at least three entries in the directory, ".", "..", - and another one. Three entries means, not empty. This doesn't - work for the root directory of a drive, but the root dir can - neither be deleted, nor moved anyway. */ - status = NtOpenFile (&fh, access | FILE_LIST_DIRECTORY | SYNCHRONIZE, - &attr, &io, FILE_SHARE_VALID_FLAGS, - flags | FILE_SYNCHRONOUS_IO_NONALERT); - if (NT_SUCCESS (status)) - { - status = check_dir_not_empty (fh); - if (!NT_SUCCESS (status)) - { - NtClose (fh); - if (fh_ro) - NtClose (fh_ro); - return status; - } - } - } - } - if (fh_ro) - NtClose (fh_ro); - if (!NT_SUCCESS (status)) - { - if (status == STATUS_DELETE_PENDING) - { - syscall_printf ("Delete already pending"); - return 0; - } - syscall_printf ("Opening file for delete failed, status = %p", status); - return status; - } - /* Try to move to bin if a sharing violation occured. If that worked, - we're done. */ - if (bin_stat == move_to_bin - && (bin_stat = try_to_bin (pc, fh, access)) == has_been_moved) - return 0; - /* Try to set delete disposition. */ - FILE_DISPOSITION_INFORMATION disp = { TRUE }; - status = NtSetInformationFile (fh, &io, &disp, sizeof disp, - FileDispositionInformation); - if (!NT_SUCCESS (status)) - { - syscall_printf ("Setting delete disposition failed, status = %p", - status); - /* Trying to delete a hardlink to a file in use by the system in some - way (for instance, font files) by setting the delete disposition fails - with STATUS_CANNOT_DELETE. Strange enough, deleting these hardlinks - using delete-on-close semantic works... most of the time. - - Don't use delete-on-close on remote shares. If two processes - have open handles on a file and one of them calls unlink, the - file is removed from the remote share even though the other - process still has an open handle. That process than gets Win32 - error 59, ERROR_UNEXP_NET_ERR when trying to access the file. - Microsoft KB 837665 describes this problem as a bug in 2K3, but - I have reproduced it on other systems. */ - if (status == STATUS_CANNOT_DELETE && !pc.isremote ()) - { - HANDLE fh2; - - /* Re-open from handle so we open the correct file no matter if it - has been moved to the bin or not. */ - InitializeObjectAttributes (&attr, &ro_u_empty, 0, fh, NULL); - status = NtOpenFile (&fh2, DELETE, &attr, &io, - bin_stat == move_to_bin ? FILE_SHARE_VALID_FLAGS - : FILE_SHARE_DELETE, - flags | FILE_DELETE_ON_CLOSE); - if (!NT_SUCCESS (status)) - { - syscall_printf ("Setting delete-on-close failed, status = %p", - status); - /* This is really the last chance. If it hasn't been moved - to the bin already, try it now. If moving to the bin - succeeds, we got rid of the file in some way, even if - unlinking didn't work. */ - if (bin_stat == dont_move) - bin_stat = try_to_bin (pc, fh, access); - if (bin_stat == has_been_moved) - status = STATUS_SUCCESS; - } - else - NtClose (fh2); - } - } - if (fh) - { - /* Restore R/O attribute to accommodate hardlinks. Don't try this - with directories! For some reason the below NtSetInformationFile - changes the delete disposition back to FALSE, at least on XP. */ - if ((access & FILE_WRITE_ATTRIBUTES) - && (!NT_SUCCESS (status) || !pc.isdir ())) - NtSetAttributesFile (fh, pc.file_attributes ()); - NtClose (fh); - } - return status; -} - -extern "C" int -unlink (const char *ourname) -{ - int res = -1; - DWORD devn; - NTSTATUS status; - - path_conv win32_name (ourname, PC_SYM_NOFOLLOW, stat_suffixes); - - if (win32_name.error) - { - set_errno (win32_name.error); - goto done; - } - - devn = win32_name.get_devn (); - if (isproc_dev (devn)) - { - set_errno (EROFS); - goto done; - } - - if (!win32_name.exists ()) - { - syscall_printf ("unlinking a nonexistent file"); - set_errno (ENOENT); - goto done; - } - else if (win32_name.isdir ()) - { - syscall_printf ("unlinking a directory"); - set_errno (EPERM); - goto done; - } - - status = unlink_nt (win32_name); - if (NT_SUCCESS (status)) - res = 0; - else - __seterrno_from_nt_status (status); - - done: - syscall_printf ("%d = unlink (%s)", res, ourname); - return res; -} - -extern "C" int -_remove_r (struct _reent *, const char *ourname) -{ - path_conv win32_name (ourname, PC_SYM_NOFOLLOW); - - if (win32_name.error) - { - set_errno (win32_name.error); - syscall_printf ("-1 = remove (%s)", ourname); - return -1; - } - - return win32_name.isdir () ? rmdir (ourname) : unlink (ourname); -} - -extern "C" int -remove (const char *ourname) -{ - path_conv win32_name (ourname, PC_SYM_NOFOLLOW); - - if (win32_name.error) - { - set_errno (win32_name.error); - syscall_printf ("-1 = remove (%s)", ourname); - return -1; - } - - return win32_name.isdir () ? rmdir (ourname) : unlink (ourname); -} - -extern "C" pid_t -getpid () -{ - return myself->pid; -} - -extern "C" pid_t -_getpid_r (struct _reent *) -{ - return getpid (); -} - -/* getppid: POSIX 4.1.1.1 */ -extern "C" pid_t -getppid () -{ - return myself->ppid; -} - -/* setsid: POSIX 4.3.2.1 */ -extern "C" pid_t -setsid (void) -{ -#ifdef NEWVFORK - vfork_save *vf = vfork_storage.val (); - /* This is a horrible, horrible kludge */ - if (vf && vf->pid < 0) - { - pid_t pid = fork (); - if (pid > 0) - { - syscall_printf ("longjmping due to vfork"); - vf->restore_pid (pid); - } - /* assuming that fork was successful */ - } -#endif - - if (myself->pgid == myself->pid) - syscall_printf ("hmm. pgid %d pid %d", myself->pgid, myself->pid); - else - { - myself->ctty = -1; - cygheap->manage_console_count ("setsid", 0); - myself->sid = getpid (); - myself->pgid = getpid (); - if (cygheap->ctty) - cygheap->close_ctty (); - syscall_printf ("sid %d, pgid %d, %s", myself->sid, myself->pgid, myctty ()); - return myself->sid; - } - - set_errno (EPERM); - return -1; -} - -extern "C" pid_t -getsid (pid_t pid) -{ - pid_t res; - if (!pid) - res = myself->sid; - else - { - pinfo p (pid); - if (p) - res = p->sid; - else - { - set_errno (ESRCH); - res = -1; - } - } - return res; -} - -extern "C" ssize_t -read (int fd, void *ptr, size_t len) -{ - const iovec iov = - { - iov_base: ptr, - iov_len: len - }; - - return readv (fd, &iov, 1); -} - -extern "C" ssize_t -pread (int fd, void *ptr, size_t len, _off64_t off) -{ - ssize_t res; - cygheap_fdget cfd (fd); - if (cfd < 0) - res = -1; - else - res = cfd->pread (ptr, len, off); - - syscall_printf ("%d = pread (%d, %p, %d, %d), errno %d", - res, fd, ptr, len, off, get_errno ()); - return res; -} - -extern "C" ssize_t -pwrite (int fd, void *ptr, size_t len, _off64_t off) -{ - ssize_t res; - cygheap_fdget cfd (fd); - if (cfd < 0) - res = -1; - else - res = cfd->pwrite (ptr, len, off); - - syscall_printf ("%d = pwrite (%d, %p, %d, %d), errno %d", - res, fd, ptr, len, off, get_errno ()); - return res; -} - -EXPORT_ALIAS (read, _read) - -extern "C" ssize_t -write (int fd, const void *ptr, size_t len) -{ - const struct iovec iov = - { - iov_base: (void *) ptr, // const_cast - iov_len: len - }; - - return writev (fd, &iov, 1); -} - -EXPORT_ALIAS (write, _write) - -extern "C" ssize_t -readv (int fd, const struct iovec *const iov, const int iovcnt) -{ - extern int sigcatchers; - const int e = get_errno (); - - ssize_t res = -1; - - const ssize_t tot = check_iovec_for_read (iov, iovcnt); - - if (tot <= 0) - { - res = tot; - goto done; - } - - while (1) - { - cygheap_fdget cfd (fd); - if (cfd < 0) - break; - - if ((cfd->get_flags () & O_ACCMODE) == O_WRONLY) - { - set_errno (EBADF); - break; - } - - DWORD wait = cfd->is_nonblocking () ? 0 : INFINITE; - - /* Could block, so let user know we at least got here. */ - syscall_printf ("readv (%d, %p, %d) %sblocking, sigcatchers %d", - fd, iov, iovcnt, wait ? "" : "non", sigcatchers); - - if (wait && (!cfd->is_slow () || cfd->uninterruptible_io ())) - debug_printf ("no need to call ready_for_read"); - else if (!cfd->ready_for_read (fd, wait)) - { - res = -1; - goto out; - } - - /* FIXME: This is not thread safe. We need some method to - ensure that an fd, closed in another thread, aborts I/O - operations. */ - if (!cfd.isopen ()) - break; - - /* Check to see if this is a background read from a "tty", - sending a SIGTTIN, if appropriate */ - res = cfd->bg_check (SIGTTIN); - - if (!cfd.isopen ()) - { - res = -1; - break; - } - - if (res > bg_eof) - { - myself->process_state |= PID_TTYIN; - if (!cfd.isopen ()) - { - res = -1; - break; - } - res = cfd->readv (iov, iovcnt, tot); - myself->process_state &= ~PID_TTYIN; - } - - out: - if (res >= 0 || get_errno () != EINTR || !_my_tls.call_signal_handler ()) - break; - set_errno (e); - } - -done: - syscall_printf ("%d = readv (%d, %p, %d), errno %d", res, fd, iov, iovcnt, - get_errno ()); - MALLOC_CHECK; - return res; -} - -extern "C" ssize_t -writev (const int fd, const struct iovec *const iov, const int iovcnt) -{ - int res = -1; - const ssize_t tot = check_iovec_for_write (iov, iovcnt); - - cygheap_fdget cfd (fd); - if (cfd < 0) - goto done; - - if (tot <= 0) - { - res = tot; - goto done; - } - - if ((cfd->get_flags () & O_ACCMODE) == O_RDONLY) - { - set_errno (EBADF); - goto done; - } - - /* Could block, so let user know we at least got here. */ - if (fd == 1 || fd == 2) - paranoid_printf ("writev (%d, %p, %d)", fd, iov, iovcnt); - else - syscall_printf ("writev (%d, %p, %d)", fd, iov, iovcnt); - - res = cfd->bg_check (SIGTTOU); - - if (res > (int) bg_eof) - { - myself->process_state |= PID_TTYOU; - res = cfd->writev (iov, iovcnt, tot); - myself->process_state &= ~PID_TTYOU; - } - -done: - if (fd == 1 || fd == 2) - paranoid_printf ("%d = write (%d, %p, %d), errno %d", - res, fd, iov, iovcnt, get_errno ()); - else - syscall_printf ("%d = write (%d, %p, %d), errno %d", - res, fd, iov, iovcnt, get_errno ()); - - MALLOC_CHECK; - return res; -} - -/* _open */ -/* newlib's fcntl.h defines _open as taking variable args so we must - correspond. The third arg if it exists is: mode_t mode. */ -extern "C" int -open (const char *unix_path, int flags, ...) -{ - int res = -1; - va_list ap; - mode_t mode = 0; - sig_dispatch_pending (); - - syscall_printf ("open (%s, %p)", unix_path, flags); - myfault efault; - if (efault.faulted (EFAULT)) - /* errno already set */; - else if (!*unix_path) - set_errno (ENOENT); - else - { - /* check for optional mode argument */ - va_start (ap, flags); - mode = va_arg (ap, mode_t); - va_end (ap); - - fhandler_base *fh; - cygheap_fdnew fd; - - if (fd >= 0) - { - if (!(fh = build_fh_name (unix_path, - (flags & (O_NOFOLLOW | O_EXCL)) - ? PC_SYM_NOFOLLOW : PC_SYM_FOLLOW, - stat_suffixes))) - res = -1; // errno already set - else if ((flags & O_NOFOLLOW) && fh->issymlink ()) - { - delete fh; - res = -1; - set_errno (ELOOP); - } - else if ((flags & O_DIRECTORY) && !fh->pc.isdir ()) - { - delete fh; - res = -1; - set_errno (ENOTDIR); - } - else if (((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) && fh->exists ()) - { - delete fh; - res = -1; - set_errno (EEXIST); - } - else if (fh->is_fs_special () && fh->device_access_denied (flags)) - { - delete fh; - res = -1; - } - else - { - fh->close_on_exec (flags & O_CLOEXEC); - if (!fh->open (flags, (mode & 07777) & ~cygheap->umask)) - { - delete fh; - res = -1; - } - else - { - cygheap->fdtab[fd] = fh; - if ((res = fd) <= 2) - set_std_handle (res); - } - } - } - } - - syscall_printf ("%d = open (%s, %p)", res, unix_path, flags); - return res; -} - -EXPORT_ALIAS (open, _open ) -EXPORT_ALIAS (open, _open64 ) - -extern "C" _off64_t -lseek64 (int fd, _off64_t pos, int dir) -{ - _off64_t res; - - if (dir != SEEK_SET && dir != SEEK_CUR && dir != SEEK_END) - { - set_errno (EINVAL); - res = -1; - } - else - { - cygheap_fdget cfd (fd); - if (cfd >= 0) - res = cfd->lseek (pos, dir); - else - res = -1; - } - syscall_printf ("%D = lseek (%d, %D, %d)", res, fd, pos, dir); - - return res; -} - -EXPORT_ALIAS (lseek64, _lseek64) - -extern "C" _off_t -lseek (int fd, _off_t pos, int dir) -{ - return lseek64 (fd, (_off64_t) pos, dir); -} - -EXPORT_ALIAS (lseek, _lseek) - -extern "C" int -close (int fd) -{ - int res; - - syscall_printf ("close (%d)", fd); - - MALLOC_CHECK; - cygheap_fdget cfd (fd, true); - if (cfd < 0) - res = -1; - else - { - res = cfd->close (); - cfd.release (); - } - - syscall_printf ("%d = close (%d)", res, fd); - MALLOC_CHECK; - return res; -} - -EXPORT_ALIAS (close, _close) - -extern "C" int -isatty (int fd) -{ - int res; - - cygheap_fdget cfd (fd); - if (cfd < 0) - res = 0; - else - res = cfd->is_tty (); - syscall_printf ("%d = isatty (%d)", res, fd); - return res; -} -EXPORT_ALIAS (isatty, _isatty) - -extern "C" int -link (const char *oldpath, const char *newpath) -{ - int res = -1; - fhandler_base *fh; - - if (!(fh = build_fh_name (oldpath, PC_SYM_NOFOLLOW, stat_suffixes))) - goto error; - - if (fh->error ()) - { - debug_printf ("got %d error from build_fh_name", fh->error ()); - set_errno (fh->error ()); - } - else if (fh->pc.isdir ()) - set_errno (EPERM); /* We do not permit linking directories. */ - else if (!fh->pc.exists ()) - set_errno (ENOENT); - else - res = fh->link (newpath); - - delete fh; - error: - syscall_printf ("%d = link (%s, %s)", res, oldpath, newpath); - return res; -} - -/* chown: POSIX 5.6.5.1 */ -/* - * chown () is only implemented for Windows NT. Under other operating - * systems, it is only a stub that always returns zero. - */ -static int -chown_worker (const char *name, unsigned fmode, __uid32_t uid, __gid32_t gid) -{ - int res = -1; - fhandler_base *fh; - - if (!(fh = build_fh_name (name, fmode, stat_suffixes))) - goto error; - - if (fh->error ()) - { - debug_printf ("got %d error from build_fh_name", fh->error ()); - set_errno (fh->error ()); - } - else - res = fh->fchown (uid, gid); - - delete fh; - error: - syscall_printf ("%d = %schown (%s,...)", - res, (fmode & PC_SYM_NOFOLLOW) ? "l" : "", name); - return res; -} - -extern "C" int -chown32 (const char * name, __uid32_t uid, __gid32_t gid) -{ - return chown_worker (name, PC_SYM_FOLLOW, uid, gid); -} - -extern "C" int -chown (const char * name, __uid16_t uid, __gid16_t gid) -{ - return chown_worker (name, PC_SYM_FOLLOW, - uid16touid32 (uid), gid16togid32 (gid)); -} - -extern "C" int -lchown32 (const char * name, __uid32_t uid, __gid32_t gid) -{ - return chown_worker (name, PC_SYM_NOFOLLOW, uid, gid); -} - -extern "C" int -lchown (const char * name, __uid16_t uid, __gid16_t gid) -{ - return chown_worker (name, PC_SYM_NOFOLLOW, - uid16touid32 (uid), gid16togid32 (gid)); -} - -extern "C" int -fchown32 (int fd, __uid32_t uid, __gid32_t gid) -{ - cygheap_fdget cfd (fd); - if (cfd < 0) - { - syscall_printf ("-1 = fchown (%d,...)", fd); - return -1; - } - - int res = cfd->fchown (uid, gid); - - syscall_printf ("%d = fchown (%s,...)", res, cfd->get_name ()); - return res; -} - -extern "C" int -fchown (int fd, __uid16_t uid, __gid16_t gid) -{ - return fchown32 (fd, uid16touid32 (uid), gid16togid32 (gid)); -} - -/* umask: POSIX 5.3.3.1 */ -extern "C" mode_t -umask (mode_t mask) -{ - mode_t oldmask; - - oldmask = cygheap->umask; - cygheap->umask = mask & 0777; - return oldmask; -} - -int -chmod_device (path_conv& pc, mode_t mode) -{ - return mknod_worker (pc.get_win32 (), pc.dev.mode & S_IFMT, mode, pc.dev.major, pc.dev.minor); -} - -#define FILTERED_MODE(m) ((m) & (S_ISUID | S_ISGID | S_ISVTX \ - | S_IRWXU | S_IRWXG | S_IRWXO)) - -/* chmod: POSIX 5.6.4.1 */ -extern "C" int -chmod (const char *path, mode_t mode) -{ - int res = -1; - fhandler_base *fh; - if (!(fh = build_fh_name (path, PC_SYM_FOLLOW, stat_suffixes))) - goto error; - - if (fh->error ()) - { - debug_printf ("got %d error from build_fh_name", fh->error ()); - set_errno (fh->error ()); - } - else - res = fh->fchmod (FILTERED_MODE (mode)); - - delete fh; - error: - syscall_printf ("%d = chmod (%s, %p)", res, path, mode); - return res; -} - -/* fchmod: P96 5.6.4.1 */ - -extern "C" int -fchmod (int fd, mode_t mode) -{ - cygheap_fdget cfd (fd); - if (cfd < 0) - { - syscall_printf ("-1 = fchmod (%d, 0%o)", fd, mode); - return -1; - } - - return cfd->fchmod (FILTERED_MODE (mode)); -} - -static void -stat64_to_stat32 (struct __stat64 *src, struct __stat32 *dst) -{ - dst->st_dev = ((src->st_dev >> 8) & 0xff00) | (src->st_dev & 0xff); - dst->st_ino = ((unsigned) (src->st_ino >> 32)) | (unsigned) src->st_ino; - dst->st_mode = src->st_mode; - dst->st_nlink = src->st_nlink; - dst->st_uid = src->st_uid; - dst->st_gid = src->st_gid; - dst->st_rdev = ((src->st_rdev >> 8) & 0xff00) | (src->st_rdev & 0xff); - dst->st_size = src->st_size; - dst->st_atim = src->st_atim; - dst->st_mtim = src->st_mtim; - dst->st_ctim = src->st_ctim; - dst->st_blksize = src->st_blksize; - dst->st_blocks = src->st_blocks; -} - -extern "C" int -fstat64 (int fd, struct __stat64 *buf) -{ - int res; - - cygheap_fdget cfd (fd); - if (cfd < 0) - res = -1; - else - { - memset (buf, 0, sizeof (struct __stat64)); - res = cfd->fstat (buf); - if (!res) - { - if (!buf->st_ino) - buf->st_ino = cfd->get_ino (); - if (!buf->st_dev) - buf->st_dev = cfd->get_device (); - if (!buf->st_rdev) - buf->st_rdev = buf->st_dev; - } - } - - syscall_printf ("%d = fstat (%d, %p)", res, fd, buf); - return res; -} - -extern "C" int -_fstat64_r (struct _reent *ptr, int fd, struct __stat64 *buf) -{ - int ret; - - if ((ret = fstat64 (fd, buf)) == -1) - ptr->_errno = get_errno (); - return ret; -} - -extern "C" int -fstat (int fd, struct __stat32 *buf) -{ - struct __stat64 buf64; - int ret = fstat64 (fd, &buf64); - if (!ret) - stat64_to_stat32 (&buf64, buf); - return ret; -} - -extern "C" int -_fstat_r (struct _reent *ptr, int fd, struct __stat32 *buf) -{ - int ret; - - if ((ret = fstat (fd, buf)) == -1) - ptr->_errno = get_errno (); - return ret; -} - -/* fsync: P96 6.6.1.1 */ -extern "C" int -fsync (int fd) -{ - cygheap_fdget cfd (fd); - if (cfd < 0) - { - syscall_printf ("-1 = fsync (%d)", fd); - return -1; - } - return cfd->fsync (); -} - -EXPORT_ALIAS (fsync, fdatasync) - -static void -sync_worker (const char *vol) -{ - HANDLE fh = CreateFileA (vol, GENERIC_WRITE, FILE_SHARE_VALID_FLAGS, - &sec_none_nih, OPEN_EXISTING, 0, NULL); - if (fh != INVALID_HANDLE_VALUE) - { - FlushFileBuffers (fh); - CloseHandle (fh); - } - else - debug_printf ("Open failed with %E"); -} - -/* sync: SUSv3 */ -extern "C" void -sync () -{ - /* Per MSDN, 50 bytes should be enough here. */ - char vol[MAX_PATH]; - - if (wincap.has_guid_volumes ()) /* Win2k and newer */ - { - char a_drive[MAX_PATH] = {0}; - char b_drive[MAX_PATH] = {0}; - - if (is_floppy ("A:")) - GetVolumeNameForVolumeMountPointA ("A:\\", a_drive, MAX_PATH); - if (is_floppy ("B:")) - GetVolumeNameForVolumeMountPointA ("B:\\", b_drive, MAX_PATH); - - HANDLE sh = FindFirstVolumeA (vol, MAX_PATH); - if (sh != INVALID_HANDLE_VALUE) - { - do - { - debug_printf ("Try volume %s", vol); - - /* Check vol for being a floppy on A: or B:. Skip them. */ - if (strcasematch (vol, a_drive) || strcasematch (vol, b_drive)) - { - debug_printf ("Is floppy, don't sync"); - continue; - } - - /* Eliminate trailing backslash. */ - vol[strlen (vol) - 1] = '\0'; - sync_worker (vol); - } - while (FindNextVolumeA (sh, vol, MAX_PATH)); - FindVolumeClose (sh); - } - } - else - { - DWORD drives = GetLogicalDrives (); - DWORD mask = 1; - /* Skip floppies on A: and B: as in setmntent. */ - if ((drives & 1) && is_floppy ("A:")) - drives &= ~1; - if ((drives & 2) && is_floppy ("B:")) - drives &= ~2; - strcpy (vol, "\\\\.\\A:"); - do - { - /* Geeh. Try to sync only non-floppy drives. */ - if (drives & mask) - { - debug_printf ("Try volume %s", vol); - sync_worker (vol); - } - vol[4]++; - } - while ((mask <<= 1) <= 1 << 25); - } -} - -/* Cygwin internal */ -int __stdcall -stat_worker (path_conv &pc, struct __stat64 *buf) -{ - int res = -1; - - myfault efault; - if (efault.faulted (EFAULT)) - goto error; - - if (pc.error) - { - debug_printf ("got %d error from path_conv", pc.error); - set_errno (pc.error); - } - else if (pc.exists ()) - { - fhandler_base *fh; - - if (!(fh = build_fh_pc (pc))) - goto error; - - debug_printf ("(%S, %p, %p), file_attributes %d", - pc.get_nt_native_path (), buf, fh, (DWORD) *fh); - memset (buf, 0, sizeof (*buf)); - res = fh->fstat (buf); - if (!res) - { - if (!buf->st_ino) - buf->st_ino = fh->get_ino (); - if (!buf->st_dev) - buf->st_dev = fh->get_device (); - if (!buf->st_rdev) - buf->st_rdev = buf->st_dev; - } - delete fh; - } - else - set_errno (ENOENT); - - error: - MALLOC_CHECK; - syscall_printf ("%d = (%S, %p)", res, pc.get_nt_native_path (), buf); - return res; -} - -extern "C" int -stat64 (const char *name, struct __stat64 *buf) -{ - syscall_printf ("entering"); - path_conv pc (name, PC_SYM_FOLLOW | PC_POSIX, stat_suffixes); - return stat_worker (pc, buf); -} - -extern "C" int -_stat64_r (struct _reent *ptr, const char *name, struct __stat64 *buf) -{ - int ret; - - if ((ret = stat64 (name, buf)) == -1) - ptr->_errno = get_errno (); - return ret; -} - -extern "C" int -stat (const char *name, struct __stat32 *buf) -{ - struct __stat64 buf64; - int ret = stat64 (name, &buf64); - if (!ret) - stat64_to_stat32 (&buf64, buf); - return ret; -} - -extern "C" int -_stat_r (struct _reent *ptr, const char *name, struct __stat32 *buf) -{ - int ret; - - if ((ret = stat (name, buf)) == -1) - ptr->_errno = get_errno (); - return ret; -} - -/* lstat: Provided by SVR4 and 4.3+BSD, POSIX? */ -extern "C" int -lstat64 (const char *name, struct __stat64 *buf) -{ - syscall_printf ("entering"); - path_conv pc (name, PC_SYM_NOFOLLOW | PC_POSIX, stat_suffixes); - return stat_worker (pc, buf); -} - -/* lstat: Provided by SVR4 and 4.3+BSD, POSIX? */ -extern "C" int -lstat (const char *name, struct __stat32 *buf) -{ - struct __stat64 buf64; - int ret = lstat64 (name, &buf64); - if (!ret) - stat64_to_stat32 (&buf64, buf); - return ret; -} - -extern "C" int -access (const char *fn, int flags) -{ - // flags were incorrectly specified - int res = -1; - if (flags & ~(F_OK|R_OK|W_OK|X_OK)) - set_errno (EINVAL); - else - { - fhandler_base *fh = build_fh_name (fn, PC_SYM_FOLLOW, stat_suffixes); - if (fh) - { - res = fh->fhaccess (flags, false); - delete fh; - } - } - debug_printf ("returning %d", res); - return res; -} - -/* Linux provides this extension; it is basically a wrapper around the - POSIX:2008 faccessat (AT_FDCWD, fn, flags, AT_EACCESS). We also - provide eaccess as an alias for this, in cygwin.din. */ -extern "C" int -euidaccess (const char *fn, int flags) -{ - // flags were incorrectly specified - int res = -1; - if (flags & ~(F_OK|R_OK|W_OK|X_OK)) - set_errno (EINVAL); - else - { - fhandler_base *fh = build_fh_name (fn, PC_SYM_FOLLOW, stat_suffixes); - if (fh) - { - res = fh->fhaccess (flags, true); - delete fh; - } - } - debug_printf ("returning %d", res); - return res; -} - -static void -rename_append_suffix (path_conv &pc, const char *path, size_t len, - const char *suffix) -{ - char buf[len + 5]; - - if (ascii_strcasematch (path + len - 4, ".lnk") - || ascii_strcasematch (path + len - 4, ".exe")) - len -= 4; - stpcpy (stpncpy (buf, path, len), suffix); - pc.check (buf, PC_SYM_NOFOLLOW); -} - -static void -start_transaction (HANDLE &old_trans, HANDLE &trans) -{ - NTSTATUS status = NtCreateTransaction (&trans, - SYNCHRONIZE | TRANSACTION_ALL_ACCESS, - NULL, NULL, NULL, 0, 0, 0, NULL, NULL); - if (NT_SUCCESS (status)) - { - old_trans = RtlGetCurrentTransaction (); - RtlSetCurrentTransaction (trans); - } - else - { - debug_printf ("NtCreateTransaction failed, %p", status); - old_trans = trans = NULL; - } -} - -static NTSTATUS -stop_transaction (NTSTATUS status, HANDLE old_trans, HANDLE trans) -{ - RtlSetCurrentTransaction (old_trans); - if (NT_SUCCESS (status)) - status = NtCommitTransaction (trans, TRUE); - else - status = NtRollbackTransaction (trans, TRUE); - NtClose (trans); - return status; -} - -/* This function tests if a filename has one of the "approved" executable - suffix. This list is probably not complete... */ -static inline bool -nt_path_has_executable_suffix (PUNICODE_STRING upath) -{ - const PUNICODE_STRING blessed_executable_suffixes[] = - { - &ro_u_com, - &ro_u_dll, /* Messy, messy. Per MSDN, the GetBinaryType function is - supposed to return with ERROR_BAD_EXE_FORMAT. if the file - is a DLL. On 64-bit Windows, this works as expected for - 32-bit and 64-bit DLLs. On 32-bit Windows this only works - for 32-bit DLLs. For 64-bit DLLs, 32-bit Windows returns - true with the type set to SCS_64BIT_BINARY. */ - &ro_u_exe, - &ro_u_scr, - &ro_u_sys, - NULL - }; - - USHORT pos = upath->Length / sizeof (WCHAR); - PWCHAR path; - UNICODE_STRING usuf; - const PUNICODE_STRING *suf; - - /* Too short for a native path? */ - if (pos < 8) - return false; - /* Assumption: All executable suffixes have a length of three. */ - path = upath->Buffer + pos - 4; - if (*path != L'.') - return false; - RtlInitCountedUnicodeString (&usuf, path, 4 * sizeof (WCHAR)); - for (suf = blessed_executable_suffixes; *suf; ++suf) - if (RtlEqualUnicodeString (&usuf, *suf, TRUE)) - return true; - return false; -} - -extern "C" int -rename (const char *oldpath, const char *newpath) -{ - tmp_pathbuf tp; - int res = -1; - path_conv oldpc, newpc, new2pc, *dstpc, *removepc = NULL; - bool old_dir_requested = false, new_dir_requested = false; - bool old_explicit_suffix = false, new_explicit_suffix = false; - size_t olen, nlen; - bool equal_path; - NTSTATUS status = 0; - HANDLE fh = NULL, nfh; - HANDLE old_trans = NULL, trans = NULL; - OBJECT_ATTRIBUTES attr; - IO_STATUS_BLOCK io; - ULONG size; - FILE_STANDARD_INFORMATION ofsi; - PFILE_RENAME_INFORMATION pfri; - - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - if (!*oldpath || !*newpath) - { - /* Reject rename("","x"), rename("x",""). */ - set_errno (ENOENT); - goto out; - } - if (has_dot_last_component (oldpath, true)) - { - /* Reject rename("dir/.","x"). */ - oldpc.check (oldpath, PC_SYM_NOFOLLOW, stat_suffixes); - set_errno (oldpc.isdir () ? EINVAL : ENOTDIR); - goto out; - } - if (has_dot_last_component (newpath, true)) - { - /* Reject rename("dir","x/."). */ - newpc.check (newpath, PC_SYM_NOFOLLOW, stat_suffixes); - set_errno (!newpc.exists () ? ENOENT : newpc.isdir () ? EINVAL : ENOTDIR); - goto out; - } - - /* A trailing slash requires that the pathname points to an existing - directory. If it's not, it's a ENOTDIR condition. The same goes - for newpath a bit further down this function. */ - olen = strlen (oldpath); - if (isdirsep (oldpath[olen - 1])) - { - char *buf; - char *p = stpcpy (buf = tp.c_get (), oldpath) - 1; - oldpath = buf; - while (p >= oldpath && isdirsep (*p)) - *p-- = '\0'; - olen = p + 1 - oldpath; - if (!olen) - { - /* The root directory cannot be renamed. This also rejects - the corner case of rename("/","/"), even though it is the - same file. */ - set_errno (EINVAL); - goto out; - } - old_dir_requested = true; - } - oldpc.check (oldpath, PC_SYM_NOFOLLOW, stat_suffixes); - if (oldpc.error) - { - set_errno (oldpc.error); - goto out; - } - if (!oldpc.exists ()) - { - set_errno (ENOENT); - goto out; - } - if (oldpc.isspecial () && !oldpc.issocket ()) /* No renames from virtual FS */ - { - set_errno (EROFS); - goto out; - } - if (oldpc.has_attribute (FILE_ATTRIBUTE_REPARSE_POINT) && !oldpc.issymlink ()) - { - /* Volume mount point. If we try to rename a volume mount point, NT - returns STATUS_NOT_SAME_DEVICE ==> Win32 ERROR_NOT_SAME_DEVICE ==> - errno EXDEV. That's bad since mv(1) will now perform a cross-device - move. So what we do here is to treat the volume mount point just - like Linux treats a mount point. */ - set_errno (EBUSY); - goto out; - } - if (old_dir_requested && !oldpc.isdir ()) - { - /* Reject rename("file/","x"). */ - set_errno (ENOTDIR); - goto out; - } - if ((oldpc.known_suffix - && (ascii_strcasematch (oldpath + olen - 4, ".lnk") - || ascii_strcasematch (oldpath + olen - 4, ".exe"))) - || nt_path_has_executable_suffix (oldpc.get_nt_native_path ())) - old_explicit_suffix = true; - - nlen = strlen (newpath); - if (isdirsep (newpath[nlen - 1])) - { - char *buf; - char *p = stpcpy (buf = tp.c_get (), newpath) - 1; - newpath = buf; - while (p >= newpath && isdirsep (*p)) - *p-- = '\0'; - nlen = p + 1 - newpath; - if (!nlen) /* The root directory is never empty. */ - { - set_errno (ENOTEMPTY); - goto out; - } - new_dir_requested = true; - } - newpc.check (newpath, PC_SYM_NOFOLLOW, stat_suffixes); - if (newpc.error) - { - set_errno (newpc.error); - goto out; - } - if (newpc.isspecial () && !newpc.issocket ()) /* No renames to virtual FSes */ - { - set_errno (EROFS); - goto out; - } - if (new_dir_requested && !(newpc.exists () - ? newpc.isdir () : oldpc.isdir ())) - { - /* Reject rename("file1","file2/"), but allow rename("dir","d/"). */ - set_errno (newpc.exists () ? ENOTDIR : ENOENT); - goto out; - } - if (newpc.exists () && (oldpc.isdir () ? !newpc.isdir () : newpc.isdir ())) - { - /* Reject rename("file","dir") and rename("dir","file"). */ - set_errno (newpc.isdir () ? EISDIR : ENOTDIR); - goto out; - } - if (newpc.known_suffix - && (ascii_strcasematch (newpath + nlen - 4, ".lnk") - || ascii_strcasematch (newpath + nlen - 4, ".exe"))) - new_explicit_suffix = true; - - /* This test is necessary in almost every case, so just do it once here. */ - equal_path = RtlEqualUnicodeString (oldpc.get_nt_native_path (), - newpc.get_nt_native_path (), - oldpc.objcaseinsensitive ()); - - /* First check if oldpath and newpath only differ by case. If so, it's - just a request to change the case of the filename. By simply setting - the file attributes to INVALID_FILE_ATTRIBUTES (which translates to - "file doesn't exist"), all later tests are skipped. */ - if (oldpc.objcaseinsensitive () && newpc.exists () && equal_path - && old_explicit_suffix == new_explicit_suffix) - { - if (RtlEqualUnicodeString (oldpc.get_nt_native_path (), - newpc.get_nt_native_path (), - FALSE)) - { - res = 0; - goto out; - } - newpc.file_attributes (INVALID_FILE_ATTRIBUTES); - } - else if (oldpc.isdir ()) - { - /* Check for newpath being identical or a subdir of oldpath. */ - if (RtlPrefixUnicodeString (oldpc.get_nt_native_path (), - newpc.get_nt_native_path (), - TRUE)) - { - if (newpc.get_nt_native_path ()->Length - == oldpc.get_nt_native_path ()->Length) - { - res = 0; - goto out; - } - if (*(PWCHAR) ((PBYTE) newpc.get_nt_native_path ()->Buffer - + oldpc.get_nt_native_path ()->Length) == L'\\') - { - set_errno (EINVAL); - goto out; - } - } - } - else if (!newpc.exists ()) - { - if (equal_path && old_explicit_suffix != new_explicit_suffix) - { - newpc.check (newpath, PC_SYM_NOFOLLOW); - if (RtlEqualUnicodeString (oldpc.get_nt_native_path (), - newpc.get_nt_native_path (), - oldpc.objcaseinsensitive ())) - { - res = 0; - goto out; - } - } - else if (oldpc.is_lnk_symlink () - && !RtlEqualUnicodePathSuffix (newpc.get_nt_native_path (), - &ro_u_lnk, TRUE)) - rename_append_suffix (newpc, newpath, nlen, ".lnk"); - else if (oldpc.is_binary () && !old_explicit_suffix - && !nt_path_has_executable_suffix (newpc.get_nt_native_path ())) - /* To rename an executable foo.exe to bar-without-suffix, the - .exe suffix must be given explicitly in oldpath. */ - rename_append_suffix (newpc, newpath, nlen, ".exe"); - } - else - { - if (equal_path && old_explicit_suffix != new_explicit_suffix) - { - newpc.check (newpath, PC_SYM_NOFOLLOW); - if (RtlEqualUnicodeString (oldpc.get_nt_native_path (), - newpc.get_nt_native_path (), - oldpc.objcaseinsensitive ())) - { - res = 0; - goto out; - } - } - else if (oldpc.is_lnk_symlink ()) - { - if (!newpc.is_lnk_symlink () - && !RtlEqualUnicodePathSuffix (newpc.get_nt_native_path (), - &ro_u_lnk, TRUE)) - { - rename_append_suffix (new2pc, newpath, nlen, ".lnk"); - removepc = &newpc; - } - } - else if (oldpc.is_binary ()) - { - /* Never append .exe suffix if file has any suffix already. */ - if (!nt_path_has_executable_suffix (newpc.get_nt_native_path ())) - { - rename_append_suffix (new2pc, newpath, nlen, ".exe"); - removepc = &newpc; - } - } - else - { - if ((RtlEqualUnicodePathSuffix (newpc.get_nt_native_path (), - &ro_u_lnk, TRUE) - || RtlEqualUnicodePathSuffix (newpc.get_nt_native_path (), - &ro_u_exe, TRUE)) - && !new_explicit_suffix) - { - new2pc.check (newpath, PC_SYM_NOFOLLOW, stat_suffixes); - newpc.get_nt_native_path ()->Length -= 4 * sizeof (WCHAR); - if (new2pc.is_binary () || new2pc.is_lnk_symlink ()) - removepc = &new2pc; - } - } - } - dstpc = (removepc == &newpc) ? &new2pc : &newpc; - - /* Opening the file must be part of the transaction. It's not sufficient - to call only NtSetInformationFile under the transaction. Therefore we - have to start the transaction here, if necessary. */ - if (wincap.has_transactions () - && (dstpc->fs_flags () & FILE_SUPPORTS_TRANSACTIONS) - && (dstpc->isdir () - || (!removepc && dstpc->has_attribute (FILE_ATTRIBUTE_READONLY)))) - start_transaction (old_trans, trans); - - /* DELETE is required to rename a file. Samba (only some versions?) doesn't - like the FILE_SHARE_DELETE mode if the file has the R/O attribute set - and returns STATUS_ACCESS_DENIED in that case. */ - status = NtOpenFile (&fh, DELETE, oldpc.get_object_attr (attr, sec_none_nih), - &io, - oldpc.fs_is_samba () ? FILE_SHARE_READ | FILE_SHARE_WRITE - : FILE_SHARE_VALID_FLAGS, - FILE_OPEN_FOR_BACKUP_INTENT - | (oldpc.is_rep_symlink () ? FILE_OPEN_REPARSE_POINT : 0)); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - goto out; - } - - /* Renaming a dir to another, existing dir fails always, even if - ReplaceIfExists is set to TRUE and the existing dir is empty. So - we have to remove the destination dir first. This also covers the - case that the destination directory is not empty. In that case, - unlink_nt returns with STATUS_DIRECTORY_NOT_EMPTY. */ - if (dstpc->isdir ()) - { - status = unlink_nt (*dstpc); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - goto out; - } - } - /* You can't copy a file if the destination exists and has the R/O - attribute set. Remove the R/O attribute first. But first check - if a removepc exists. If so, dstpc points to a non-existing file - due to a mangled suffix. */ - else if (!removepc && dstpc->has_attribute (FILE_ATTRIBUTE_READONLY)) - { - status = NtOpenFile (&nfh, FILE_WRITE_ATTRIBUTES, - dstpc->get_object_attr (attr, sec_none_nih), - &io, FILE_SHARE_VALID_FLAGS, - FILE_OPEN_FOR_BACKUP_INTENT - | (dstpc->is_rep_symlink () - ? FILE_OPEN_REPARSE_POINT : 0)); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - goto out; - } - status = NtSetAttributesFile (nfh, dstpc->file_attributes () - & ~FILE_ATTRIBUTE_READONLY); - NtClose (nfh); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - goto out; - } - } - - /* SUSv3: If the old argument and the new argument resolve to the same - existing file, rename() shall return successfully and perform no - other action. - The test tries to be as quick as possible. First it tests for identical - volume serial numbers because that information is available anyway. - Then it tests if oldpath has more than 1 hardlink, then it opens newpath - and tests for identical file ids. If so, oldpath and newpath refer to - the same file. */ - if ((removepc || dstpc->exists ()) - && !oldpc.isdir () - && dstpc->fs_serial_number () == oldpc.fs_serial_number () - && NT_SUCCESS (NtQueryInformationFile (fh, &io, &ofsi, sizeof ofsi, - FileStandardInformation)) - && ofsi.NumberOfLinks > 1 - && NT_SUCCESS (NtOpenFile (&nfh, READ_CONTROL, - (removepc ?: dstpc)->get_object_attr (attr, sec_none_nih), - &io, FILE_SHARE_VALID_FLAGS, - FILE_OPEN_FOR_BACKUP_INTENT - | ((removepc ?: dstpc)->is_rep_symlink () - ? FILE_OPEN_REPARSE_POINT : 0)))) - { - FILE_INTERNAL_INFORMATION ofii, nfii; - - if (NT_SUCCESS (NtQueryInformationFile (fh, &io, &ofii, sizeof ofii, - FileInternalInformation)) - && NT_SUCCESS (NtQueryInformationFile (nfh, &io, &nfii, sizeof nfii, - FileInternalInformation)) - && ofii.FileId.QuadPart == nfii.FileId.QuadPart) - { - debug_printf ("%s and %s are the same file", oldpath, newpath); - NtClose (nfh); - res = 0; - goto out; - } - NtClose (nfh); - } - size = sizeof (FILE_RENAME_INFORMATION) - + dstpc->get_nt_native_path ()->Length; - if (size > NT_MAX_PATH * sizeof (WCHAR)) /* Hopefully very seldom. */ - pfri = (PFILE_RENAME_INFORMATION) alloca (size); - else - pfri = (PFILE_RENAME_INFORMATION) tp.w_get (); - pfri->ReplaceIfExists = TRUE; - pfri->RootDirectory = NULL; - pfri->FileNameLength = dstpc->get_nt_native_path ()->Length; - memcpy (&pfri->FileName, dstpc->get_nt_native_path ()->Buffer, - pfri->FileNameLength); - status = NtSetInformationFile (fh, &io, pfri, size, FileRenameInformation); - /* This happens if the access rights don't allow deleting the destination. - Even if the handle to the original file is opened with BACKUP - and/or RECOVERY, these flags don't apply to the destination of the - rename operation. So, a privileged user can't rename a file to an - existing file, if the permissions of the existing file aren't right. - Like directories, we have to handle this separately by removing the - destination before renaming. */ - if (status == STATUS_ACCESS_DENIED && dstpc->exists () && !dstpc->isdir ()) - { - if (wincap.has_transactions () - && (dstpc->fs_flags () & FILE_SUPPORTS_TRANSACTIONS) - && !trans) - { - start_transaction (old_trans, trans); - /* As mentioned earlier, opening the file must be part of the - transaction. Therefore we have to reopen the file here if the - transaction hasn't been started already. Unfortunately we can't - use the NT "reopen file from existing handle" feature. In that - case NtOpenFile returns STATUS_TRANSACTIONAL_CONFLICT. We *have* - to close the handle to the file first, *then* we can re-open it. - Fortunately nothing has happened yet, so the atomicity of the - rename functionality is not spoiled. */ - NtClose (fh); - status = NtOpenFile (&fh, DELETE, - oldpc.get_object_attr (attr, sec_none_nih), - &io, FILE_SHARE_VALID_FLAGS, - FILE_OPEN_FOR_BACKUP_INTENT - | (oldpc.is_rep_symlink () - ? FILE_OPEN_REPARSE_POINT : 0)); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - goto out; - } - } - if (NT_SUCCESS (status = unlink_nt (*dstpc))) - status = NtSetInformationFile (fh, &io, pfri, size, - FileRenameInformation); - } - if (NT_SUCCESS (status)) - { - if (removepc) - unlink_nt (*removepc); - res = 0; - } - else - __seterrno_from_nt_status (status); - -out: - if (fh) - NtClose (fh); - if (wincap.has_transactions () && trans) - stop_transaction (status, old_trans, trans); - syscall_printf ("%d = rename (%s, %s)", res, oldpath, newpath); - return res; -} - -extern "C" int -system (const char *cmdstring) -{ - pthread_testcancel (); - - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - int res; - const char* command[4]; - - if (cmdstring == NULL) - return 1; - - command[0] = "sh"; - command[1] = "-c"; - command[2] = cmdstring; - command[3] = (const char *) NULL; - - if ((res = spawnvp (_P_SYSTEM, "/bin/sh", command)) == -1) - { - // when exec fails, return value should be as if shell - // executed exit (127) - res = 127; - } - - return res; -} - -extern "C" int -setdtablesize (int size) -{ - if (size <= (int)cygheap->fdtab.size || cygheap->fdtab.extend (size - cygheap->fdtab.size)) - return 0; - - return -1; -} - -extern "C" int -getdtablesize () -{ - return cygheap->fdtab.size > OPEN_MAX ? cygheap->fdtab.size : OPEN_MAX; -} - -extern "C" int -getpagesize () -{ - if (!system_info.dwAllocationGranularity) - GetSystemInfo (&system_info); - return (size_t) system_info.dwAllocationGranularity; -} - -size_t -getsystempagesize () -{ - if (!system_info.dwPageSize) - GetSystemInfo (&system_info); - return (size_t) system_info.dwPageSize; -} - -/* FIXME: not all values are correct... */ -extern "C" long int -fpathconf (int fd, int v) -{ - cygheap_fdget cfd (fd); - if (cfd < 0) - return -1; - return cfd->fpathconf (v); -} - -extern "C" long int -pathconf (const char *file, int v) -{ - fhandler_base *fh; - long ret = -1; - - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - if (!*file) - { - set_errno (ENOENT); - return -1; - } - if (!(fh = build_fh_name (file, PC_SYM_FOLLOW, stat_suffixes))) - return -1; - if (!fh->exists ()) - set_errno (ENOENT); - else - ret = fh->fpathconf (v); - delete fh; - return ret; -} - -extern "C" int -ttyname_r (int fd, char *buf, size_t buflen) -{ - int ret = 0; - myfault efault; - if (efault.faulted ()) - ret = EFAULT; - else - { - cygheap_fdget cfd (fd, true); - if (cfd < 0) - ret = EBADF; - else if (!cfd->is_tty ()) - ret = ENOTTY; - else if (buflen < strlen (cfd->ttyname ()) + 1) - ret = ERANGE; - else - strcpy (buf, cfd->ttyname ()); - } - debug_printf ("returning %d tty: %s", ret, ret ? "NULL" : buf); - return ret; -} - -extern "C" char * -ttyname (int fd) -{ - static char name[TTY_NAME_MAX]; - int ret = ttyname_r (fd, name, TTY_NAME_MAX); - if (ret) - { - set_errno (ret); - return NULL; - } - return name; -} - -extern "C" char * -ctermid (char *str) -{ - static NO_COPY char buf[16]; - if (str == NULL) - str = buf; - if (!real_tty_attached (myself)) - strcpy (str, "/dev/conin"); - else - __small_sprintf (str, "/dev/tty%d", myself->ctty); - return str; -} - -/* Tells stdio if it should do the cr/lf conversion for this file */ -extern "C" int -_cygwin_istext_for_stdio (int fd) -{ - if (CYGWIN_VERSION_OLD_STDIO_CRLF_HANDLING) - { - syscall_printf ("fd %d: old API", fd); - return 0; /* we do it for old apps, due to getc/putc macros */ - } - - cygheap_fdget cfd (fd, false, false); - if (cfd < 0) - { - syscall_printf ("fd %d: not open", fd); - return 0; - } - -#if 0 - if (cfd->get_device () != FH_FS) - { - syscall_printf ("fd not disk file. Defaulting to binary."); - return 0; - } -#endif - - if (cfd->wbinary () || cfd->rbinary ()) - { - syscall_printf ("fd %d: opened as binary", fd); - return 0; - } - - syscall_printf ("fd %d: defaulting to text", fd); - return 1; -} - -/* internal newlib function */ -extern "C" int _fwalk (struct _reent *ptr, int (*function) (FILE *)); - -static int -setmode_helper (FILE *f) -{ - if (fileno (f) != _my_tls.locals.setmode_file) - { - syscall_printf ("improbable, but %d != %d", fileno (f), _my_tls.locals.setmode_file); - return 0; - } - syscall_printf ("file was %s now %s", f->_flags & __SCLE ? "text" : "binary", - _my_tls.locals.setmode_mode & O_TEXT ? "text" : "binary"); - if (_my_tls.locals.setmode_mode & O_TEXT) - f->_flags |= __SCLE; - else - f->_flags &= ~__SCLE; - return 0; -} - -extern "C" int -getmode (int fd) -{ - cygheap_fdget cfd (fd); - if (cfd < 0) - return -1; - - return cfd->get_flags () & (O_BINARY | O_TEXT); -} - -/* Set a file descriptor into text or binary mode, returning the - previous mode. */ - -extern "C" int -setmode (int fd, int mode) -{ - cygheap_fdget cfd (fd); - if (cfd < 0) - return -1; - if (mode != O_BINARY && mode != O_TEXT && mode != 0) - { - set_errno (EINVAL); - return -1; - } - - /* Note that we have no way to indicate the case that writes are - binary but not reads, or vice-versa. These cases can arise when - using the tty or console interface. People using those - interfaces should not use setmode. */ - - int res; - if (cfd->wbinary () && cfd->rbinary ()) - res = O_BINARY; - else if (cfd->wbinset () && cfd->rbinset ()) - res = O_TEXT; /* Specifically set O_TEXT */ - else - res = 0; - - if (!mode) - cfd->reset_to_open_binmode (); - else - cfd->set_flags ((cfd->get_flags () & ~(O_TEXT | O_BINARY)) | mode); - - syscall_printf ("(%d<%S>, %p) returning %s", fd, - cfd->pc.get_nt_native_path (), mode, - res & O_TEXT ? "text" : "binary"); - return res; -} - -extern "C" int -cygwin_setmode (int fd, int mode) -{ - int res = setmode (fd, mode); - if (res != -1) - { - _my_tls.locals.setmode_file = fd; - if (_cygwin_istext_for_stdio (fd)) - _my_tls.locals.setmode_mode = O_TEXT; - else - _my_tls.locals.setmode_mode = O_BINARY; - _fwalk (_GLOBAL_REENT, setmode_helper); - } - return res; -} - -extern "C" int -posix_fadvise (int fd, _off64_t offset, _off64_t len, int advice) -{ - int res = -1; - cygheap_fdget cfd (fd); - if (cfd >= 0) - res = cfd->fadvise (offset, len, advice); - else - set_errno (EBADF); - syscall_printf ("%d = posix_fadvice (%d, %D, %D, %d)", - res, fd, offset, len, advice); - return res; -} - -extern "C" int -posix_fallocate (int fd, _off64_t offset, _off64_t len) -{ - int res = -1; - if (offset < 0 || len == 0) - set_errno (EINVAL); - else - { - cygheap_fdget cfd (fd); - if (cfd >= 0) - res = cfd->ftruncate (offset + len, false); - else - set_errno (EBADF); - } - syscall_printf ("%d = posix_fallocate (%d, %D, %D)", res, fd, offset, len); - return res; -} - -extern "C" int -ftruncate64 (int fd, _off64_t length) -{ - int res = -1; - cygheap_fdget cfd (fd); - if (cfd >= 0) - res = cfd->ftruncate (length, true); - else - set_errno (EBADF); - syscall_printf ("%d = ftruncate (%d, %D)", res, fd, length); - return res; -} - -/* ftruncate: P96 5.6.7.1 */ -extern "C" int -ftruncate (int fd, _off_t length) -{ - return ftruncate64 (fd, (_off64_t)length); -} - -/* truncate: Provided by SVR4 and 4.3+BSD. Not part of POSIX.1 or XPG3 */ -extern "C" int -truncate64 (const char *pathname, _off64_t length) -{ - int fd; - int res = -1; - - fd = open (pathname, O_RDWR); - - if (fd != -1) - { - res = ftruncate64 (fd, length); - close (fd); - } - syscall_printf ("%d = truncate (%s, %D)", res, pathname, length); - - return res; -} - -/* truncate: Provided by SVR4 and 4.3+BSD. Not part of POSIX.1 or XPG3 */ -extern "C" int -truncate (const char *pathname, _off_t length) -{ - return truncate64 (pathname, (_off64_t)length); -} - -extern "C" long -get_osfhandle (int fd) -{ - long res; - - cygheap_fdget cfd (fd); - if (cfd >= 0) - res = (long) cfd->get_handle (); - else - res = -1; - - syscall_printf ("%d = get_osfhandle (%d)", res, fd); - return res; -} - -extern "C" int -fstatvfs (int fd, struct statvfs *sfs) -{ - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - cygheap_fdget cfd (fd); - if (cfd < 0) - return -1; - return cfd->fstatvfs (sfs); -} - -extern "C" int -statvfs (const char *name, struct statvfs *sfs) -{ - int res = -1; - fhandler_base *fh = NULL; - - myfault efault; - if (efault.faulted (EFAULT)) - goto error; - - if (!(fh = build_fh_name (name, PC_SYM_FOLLOW, stat_suffixes))) - goto error; - - if (fh->error ()) - { - debug_printf ("got %d error from build_fh_name", fh->error ()); - set_errno (fh->error ()); - } - else if (fh->exists ()) - { - debug_printf ("(%s, %p), file_attributes %d", name, sfs, (DWORD) *fh); - res = fh->fstatvfs (sfs); - } - else - set_errno (ENOENT); - - delete fh; - error: - MALLOC_CHECK; - syscall_printf ("%d = (%s, %p)", res, name, sfs); - return res; -} - -extern "C" int -fstatfs (int fd, struct statfs *sfs) -{ - struct statvfs vfs; - int ret = fstatvfs (fd, &vfs); - if (!ret) - { - sfs->f_type = vfs.f_flag; - sfs->f_bsize = vfs.f_bsize; - sfs->f_blocks = vfs.f_blocks; - sfs->f_bavail = vfs.f_bavail; - sfs->f_bfree = vfs.f_bfree; - sfs->f_files = -1; - sfs->f_ffree = -1; - sfs->f_fsid = vfs.f_fsid; - sfs->f_namelen = vfs.f_namemax; - } - return ret; -} - -extern "C" int -statfs (const char *fname, struct statfs *sfs) -{ - struct statvfs vfs; - int ret = statvfs (fname, &vfs); - if (!ret) - { - sfs->f_type = vfs.f_flag; - sfs->f_bsize = vfs.f_bsize; - sfs->f_blocks = vfs.f_blocks; - sfs->f_bavail = vfs.f_bavail; - sfs->f_bfree = vfs.f_bfree; - sfs->f_files = -1; - sfs->f_ffree = -1; - sfs->f_fsid = vfs.f_fsid; - sfs->f_namelen = vfs.f_namemax; - } - return ret; -} - -/* setpgid: POSIX 4.3.3.1 */ -extern "C" int -setpgid (pid_t pid, pid_t pgid) -{ - int res = -1; - if (pid == 0) - pid = getpid (); - if (pgid == 0) - pgid = pid; - - if (pgid < 0) - set_errno (EINVAL); - else - { - pinfo p (pid, PID_MAP_RW); - if (!p) - set_errno (ESRCH); - else if (p->pgid == pgid) - res = 0; - /* A process may only change the process group of itself and its children */ - else if (p != myself && p->ppid != myself->pid) - set_errno (EPERM); - else - { - p->pgid = pgid; - if (p->pid != p->pgid) - p->set_has_pgid_children (0); - res = 0; - } - } - - syscall_printf ("pid %d, pgid %d, res %d", pid, pgid, res); - return res; -} - -extern "C" pid_t -getpgid (pid_t pid) -{ - if (pid == 0) - pid = getpid (); - - pinfo p (pid); - if (p == 0) - { - set_errno (ESRCH); - return -1; - } - return p->pgid; -} - -extern "C" int -setpgrp (void) -{ - return setpgid (0, 0); -} - -extern "C" pid_t -getpgrp (void) -{ - return getpgid (0); -} - -extern "C" char * -ptsname (int fd) -{ - cygheap_fdget cfd (fd); - if (cfd < 0) - return 0; - return (char *) (cfd->ptsname ()); -} - -static int __stdcall -mknod_worker (const char *path, mode_t type, mode_t mode, _major_t major, - _minor_t minor) -{ - char buf[sizeof (":\\00000000:00000000:00000000") + PATH_MAX]; - sprintf (buf, ":\\%x:%x:%x", major, minor, - type | (mode & (S_IRWXU | S_IRWXG | S_IRWXO))); - return symlink_worker (buf, path, true, true); -} - -extern "C" int -mknod32 (const char *path, mode_t mode, __dev32_t dev) -{ - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - if (!*path) - { - set_errno (ENOENT); - return -1; - } - - if (strlen (path) >= PATH_MAX) - return -1; - - path_conv w32path (path, PC_SYM_NOFOLLOW); - if (w32path.exists ()) - { - set_errno (EEXIST); - return -1; - } - - mode_t type = mode & S_IFMT; - _major_t major = _major (dev); - _minor_t minor = _minor (dev); - switch (type) - { - case S_IFCHR: - case S_IFBLK: - break; - - case S_IFIFO: - major = _major (FH_FIFO); - minor = _minor (FH_FIFO); - break; - - case 0: - case S_IFREG: - { - int fd = open (path, O_CREAT, mode); - if (fd < 0) - return -1; - close (fd); - return 0; - } - - default: - set_errno (EINVAL); - return -1; - } - - return mknod_worker (w32path.get_win32 (), type, mode, major, minor); -} - -extern "C" int -mknod (const char *_path, mode_t mode, __dev16_t dev) -{ - return mknod32 (_path, mode, (__dev32_t) dev); -} - -extern "C" int -mkfifo (const char *path, mode_t mode) -{ - return mknod32 (path, (mode & ~S_IFMT) | S_IFIFO, 0); -} - -/* seteuid: standards? */ -extern "C" int -seteuid32 (__uid32_t uid) -{ - debug_printf ("uid: %u myself->uid: %u myself->gid: %u", - uid, myself->uid, myself->gid); - - /* Same uid as we're just running under is usually a no-op. - - Except we have an external token which is a restricted token. Or, - the external token is NULL, but the current impersonation token is - a restricted token. This allows to restrict user rights temporarily - like this: - - cygwin_internal(CW_SET_EXTERNAL_TOKEN, restricted_token, - CW_TOKEN_RESTRICTED); - setuid (getuid ()); - [...do stuff with restricted rights...] - cygwin_internal(CW_SET_EXTERNAL_TOKEN, INVALID_HANDLE_VALUE, - CW_TOKEN_RESTRICTED); - setuid (getuid ()); - - Note that using the current uid is a requirement! Starting with Windows - Vista, we have restricted tokens galore (UAC), so this is really just - a special case to restict your own processes to lesser rights. */ - bool request_restricted_uid_switch = (uid == myself->uid - && cygheap->user.ext_token_is_restricted); - if (uid == myself->uid && !cygheap->user.groups.ischanged - && !request_restricted_uid_switch) - { - debug_printf ("Nothing happens"); - return 0; - } - - cygsid usersid; - user_groups &groups = cygheap->user.groups; - HANDLE new_token = INVALID_HANDLE_VALUE; - struct passwd * pw_new; - bool token_is_internal, issamesid = false; - - pw_new = internal_getpwuid (uid); - if (!usersid.getfrompw (pw_new)) - { - set_errno (EINVAL); - return -1; - } - - cygheap->user.deimpersonate (); - - /* Verify if the process token is suitable. */ - /* First of all, skip all checks if a switch to a restricted token has been - requested, or if trying to switch back from it. */ - if (request_restricted_uid_switch) - { - if (cygheap->user.external_token != NO_IMPERSONATION) - { - debug_printf ("Switch to restricted token"); - new_token = cygheap->user.external_token; - } - else - { - debug_printf ("Switch back from restricted token"); - new_token = hProcToken; - cygheap->user.ext_token_is_restricted = false; - } - } - /* TODO, CV 2008-11-25: The check against saved_sid is a kludge and a - shortcut. We must check if it's really feasible in the long run. - The reason to add this shortcut is this: sshd switches back to the - privileged user running sshd at least twice in the process of - authentication. It calls seteuid first, then setegid. Due to this - order, the setgroups group list is still active when calling seteuid - and verify_token treats the original token of the privileged user as - insufficient. This in turn results in creating a new user token for - the privileged user instead of using the orignal token. This can have - unfortunate side effects. The created token has different group - memberships, different user rights, and misses possible network - credentials. - Therefore we try this shortcut now. When switching back to the - privileged user, we probably always want a correct (aka original) - user token for this privileged user, not only in sshd. */ - else if ((uid == cygheap->user.saved_uid - && usersid == cygheap->user.saved_sid ()) - || verify_token (hProcToken, usersid, groups)) - new_token = hProcToken; - /* Verify if the external token is suitable */ - else if (cygheap->user.external_token != NO_IMPERSONATION - && verify_token (cygheap->user.external_token, usersid, groups)) - new_token = cygheap->user.external_token; - /* Verify if the current token (internal or former external) is suitable */ - else if (cygheap->user.curr_primary_token != NO_IMPERSONATION - && cygheap->user.curr_primary_token != cygheap->user.external_token - && verify_token (cygheap->user.curr_primary_token, usersid, groups, - &token_is_internal)) - new_token = cygheap->user.curr_primary_token; - /* Verify if the internal token is suitable */ - else if (cygheap->user.internal_token != NO_IMPERSONATION - && cygheap->user.internal_token != cygheap->user.curr_primary_token - && verify_token (cygheap->user.internal_token, usersid, groups, - &token_is_internal)) - new_token = cygheap->user.internal_token; - - debug_printf ("Found token %d", new_token); - - /* If no impersonation token is available, try to authenticate using - LSA private data stored password, LSA authentication using our own - LSA module, or, as last chance, NtCreateToken. */ - if (new_token == INVALID_HANDLE_VALUE) - { - new_token = lsaprivkeyauth (pw_new); - if (new_token) - { - /* We have to verify this token since settings in /etc/group - might render it unusable im terms of group membership. */ - if (!verify_token (new_token, usersid, groups)) - { - CloseHandle (new_token); - new_token = NULL; - } - } - if (!new_token) - { - debug_printf ("lsaprivkeyauth failed, try lsaauth."); - if (!(new_token = lsaauth (usersid, groups, pw_new))) - { - debug_printf ("lsaauth failed, try create_token."); - new_token = create_token (usersid, groups, pw_new); - if (new_token == INVALID_HANDLE_VALUE) - { - debug_printf ("create_token failed, bail out of here"); - cygheap->user.reimpersonate (); - return -1; - } - } - } - - /* Keep at most one internal token */ - if (cygheap->user.internal_token != NO_IMPERSONATION) - CloseHandle (cygheap->user.internal_token); - cygheap->user.internal_token = new_token; - } - - if (new_token != hProcToken) - { - if (!request_restricted_uid_switch) - { - /* Avoid having HKCU use default user */ - WCHAR name[128]; - load_registry_hive (usersid.string (name)); - } - - /* Try setting owner to same value as user. */ - if (!SetTokenInformation (new_token, TokenOwner, - &usersid, sizeof usersid)) - debug_printf ("SetTokenInformation(user.token, TokenOwner), %E"); - /* Try setting primary group in token to current group */ - if (!SetTokenInformation (new_token, TokenPrimaryGroup, - &groups.pgsid, sizeof (cygsid))) - debug_printf ("SetTokenInformation(user.token, TokenPrimaryGroup), %E"); - /* Try setting default DACL */ - PACL dacl_buf = (PACL) alloca (MAX_DACL_LEN (5)); - if (sec_acl (dacl_buf, true, true, usersid)) - { - TOKEN_DEFAULT_DACL tdacl = { dacl_buf }; - if (!SetTokenInformation (new_token, TokenDefaultDacl, - &tdacl, sizeof (tdacl))) - debug_printf ("SetTokenInformation (TokenDefaultDacl), %E"); - } - } - - issamesid = (usersid == cygheap->user.sid ()); - cygheap->user.set_sid (usersid); - cygheap->user.curr_primary_token = new_token == hProcToken ? NO_IMPERSONATION - : new_token; - cygheap->user.curr_token_is_restricted = false; - cygheap->user.setuid_to_restricted = false; - if (cygheap->user.curr_imp_token != NO_IMPERSONATION) - { - CloseHandle (cygheap->user.curr_imp_token); - cygheap->user.curr_imp_token = NO_IMPERSONATION; - } - if (cygheap->user.curr_primary_token != NO_IMPERSONATION) - { - /* HANDLE_FLAG_INHERIT may be missing in external token. */ - if (!SetHandleInformation (cygheap->user.curr_primary_token, - HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT) - || !DuplicateTokenEx (cygheap->user.curr_primary_token, - MAXIMUM_ALLOWED, &sec_none, - SecurityImpersonation, TokenImpersonation, - &cygheap->user.curr_imp_token)) - { - __seterrno (); - cygheap->user.curr_primary_token = NO_IMPERSONATION; - return -1; - } - cygheap->user.curr_token_is_restricted = request_restricted_uid_switch; - set_cygwin_privileges (cygheap->user.curr_primary_token); - set_cygwin_privileges (cygheap->user.curr_imp_token); - } - if (!cygheap->user.reimpersonate ()) - { - __seterrno (); - return -1; - } - - cygheap->user.set_name (pw_new->pw_name); - myself->uid = uid; - groups.ischanged = FALSE; - if (!issamesid) - /* Recreate and fill out the user shared region for a new user. */ - user_shared_create (true); - return 0; -} - -extern "C" int -seteuid (__uid16_t uid) -{ - return seteuid32 (uid16touid32 (uid)); -} - -/* setuid: POSIX 4.2.2.1 */ -extern "C" int -setuid32 (__uid32_t uid) -{ - int ret = seteuid32 (uid); - if (!ret) - { - cygheap->user.real_uid = myself->uid; - /* If restricted token, forget original privileges on exec (). */ - cygheap->user.setuid_to_restricted = cygheap->user.curr_token_is_restricted; - } - debug_printf ("real: %d, effective: %d", cygheap->user.real_uid, myself->uid); - return ret; -} - -extern "C" int -setuid (__uid16_t uid) -{ - return setuid32 (uid16touid32 (uid)); -} - -extern "C" int -setreuid32 (__uid32_t ruid, __uid32_t euid) -{ - int ret = 0; - bool tried = false; - __uid32_t old_euid = myself->uid; - - if (ruid != ILLEGAL_UID && cygheap->user.real_uid != ruid && euid != ruid) - tried = !(ret = seteuid32 (ruid)); - if (!ret && euid != ILLEGAL_UID) - ret = seteuid32 (euid); - if (tried && (ret || euid == ILLEGAL_UID) && seteuid32 (old_euid)) - system_printf ("Cannot restore original euid %u", old_euid); - if (!ret && ruid != ILLEGAL_UID) - cygheap->user.real_uid = ruid; - debug_printf ("real: %u, effective: %u", cygheap->user.real_uid, myself->uid); - return ret; -} - -extern "C" int -setreuid (__uid16_t ruid, __uid16_t euid) -{ - return setreuid32 (uid16touid32 (ruid), uid16touid32 (euid)); -} - -/* setegid: from System V. */ -extern "C" int -setegid32 (__gid32_t gid) -{ - debug_printf ("new egid: %u current: %u", gid, myself->gid); - - if (gid == myself->gid) - { - myself->gid = gid; - return 0; - } - - user_groups * groups = &cygheap->user.groups; - cygsid gsid; - struct __group32 * gr = internal_getgrgid (gid); - - if (!gsid.getfromgr (gr)) - { - set_errno (EINVAL); - return -1; - } - myself->gid = gid; - - groups->update_pgrp (gsid); - if (cygheap->user.issetuid ()) - { - /* If impersonated, update impersonation token... */ - if (!SetTokenInformation (cygheap->user.primary_token (), - TokenPrimaryGroup, &gsid, sizeof gsid)) - debug_printf ("SetTokenInformation(primary_token, " - "TokenPrimaryGroup), %E"); - if (!SetTokenInformation (cygheap->user.imp_token (), TokenPrimaryGroup, - &gsid, sizeof gsid)) - debug_printf ("SetTokenInformation(token, TokenPrimaryGroup), %E"); - } - cygheap->user.deimpersonate (); - if (!SetTokenInformation (hProcToken, TokenPrimaryGroup, &gsid, sizeof gsid)) - debug_printf ("SetTokenInformation(hProcToken, TokenPrimaryGroup), %E"); - clear_procimptoken (); - cygheap->user.reimpersonate (); - return 0; -} - -extern "C" int -setegid (__gid16_t gid) -{ - return setegid32 (gid16togid32 (gid)); -} - -/* setgid: POSIX 4.2.2.1 */ -extern "C" int -setgid32 (__gid32_t gid) -{ - int ret = setegid32 (gid); - if (!ret) - cygheap->user.real_gid = myself->gid; - return ret; -} - -extern "C" int -setgid (__gid16_t gid) -{ - int ret = setegid32 (gid16togid32 (gid)); - if (!ret) - cygheap->user.real_gid = myself->gid; - return ret; -} - -extern "C" int -setregid32 (__gid32_t rgid, __gid32_t egid) -{ - int ret = 0; - bool tried = false; - __gid32_t old_egid = myself->gid; - - if (rgid != ILLEGAL_GID && cygheap->user.real_gid != rgid && egid != rgid) - tried = !(ret = setegid32 (rgid)); - if (!ret && egid != ILLEGAL_GID) - ret = setegid32 (egid); - if (tried && (ret || egid == ILLEGAL_GID) && setegid32 (old_egid)) - system_printf ("Cannot restore original egid %u", old_egid); - if (!ret && rgid != ILLEGAL_GID) - cygheap->user.real_gid = rgid; - debug_printf ("real: %u, effective: %u", cygheap->user.real_gid, myself->gid); - return ret; -} - -extern "C" int -setregid (__gid16_t rgid, __gid16_t egid) -{ - return setregid32 (gid16togid32 (rgid), gid16togid32 (egid)); -} - -/* chroot: privileged Unix system call. */ -/* FIXME: Not privileged here. How should this be done? */ -extern "C" int -chroot (const char *newroot) -{ - path_conv path (newroot, PC_SYM_FOLLOW | PC_POSIX); - - int ret = -1; - if (path.error) - set_errno (path.error); - else if (!path.exists ()) - set_errno (ENOENT); - else if (!path.isdir ()) - set_errno (ENOTDIR); - else if (path.isspecial ()) - set_errno (EPERM); - else - { - getwinenv("PATH="); /* Save the native PATH */ - cygheap->root.set (path.normalized_path, path.get_win32 (), - !!path.objcaseinsensitive ()); - ret = 0; - } - - syscall_printf ("%d = chroot (%s)", ret ? get_errno () : 0, - newroot ? newroot : "NULL"); - return ret; -} - -extern "C" int -creat (const char *path, mode_t mode) -{ - return open (path, O_WRONLY | O_CREAT | O_TRUNC, mode); -} - -extern "C" void -__assertfail () -{ - exit (99); -} - -extern "C" int -vhangup () -{ - set_errno (ENOSYS); - return -1; -} - -extern "C" int -setpriority (int which, id_t who, int value) -{ - DWORD prio = nice_to_winprio (value); - int error = 0; - - switch (which) - { - case PRIO_PROCESS: - if (!who) - who = myself->pid; - if ((pid_t) who == myself->pid) - { - if (!SetPriorityClass (GetCurrentProcess (), prio)) - { - set_errno (EACCES); - return -1; - } - myself->nice = value; - debug_printf ("Set nice to %d", myself->nice); - return 0; - } - break; - case PRIO_PGRP: - if (!who) - who = myself->pgid; - break; - case PRIO_USER: - if (!who) - who = myself->uid; - break; - default: - set_errno (EINVAL); - return -1; - } - winpids pids ((DWORD) PID_MAP_RW); - for (DWORD i = 0; i < pids.npids; ++i) - { - _pinfo *p = pids[i]; - if (p) - { - switch (which) - { - case PRIO_PROCESS: - if ((pid_t) who != p->pid) - continue; - break; - case PRIO_PGRP: - if ((pid_t) who != p->pgid) - continue; - break; - case PRIO_USER: - if ((__uid32_t) who != p->uid) - continue; - break; - } - HANDLE proc_h = OpenProcess (PROCESS_SET_INFORMATION, FALSE, - p->dwProcessId); - if (!proc_h) - error = EPERM; - else - { - if (!SetPriorityClass (proc_h, prio)) - error = EACCES; - else - p->nice = value; - CloseHandle (proc_h); - } - } - } - pids.reset (); - if (error) - { - set_errno (error); - return -1; - } - return 0; -} - -extern "C" int -getpriority (int which, id_t who) -{ - int nice = NZERO * 2; /* Illegal value */ - - switch (which) - { - case PRIO_PROCESS: - if (!who) - who = myself->pid; - if ((pid_t) who == myself->pid) - return myself->nice; - break; - case PRIO_PGRP: - if (!who) - who = myself->pgid; - break; - case PRIO_USER: - if (!who) - who = myself->uid; - break; - default: - set_errno (EINVAL); - return -1; - } - winpids pids ((DWORD) 0); - for (DWORD i = 0; i < pids.npids; ++i) - { - _pinfo *p = pids[i]; - if (p) - switch (which) - { - case PRIO_PROCESS: - if ((pid_t) who == p->pid) - { - nice = p->nice; - goto out; - } - break; - case PRIO_PGRP: - if ((pid_t) who == p->pgid && p->nice < nice) - nice = p->nice; - break; - case PRIO_USER: - if ((__uid32_t) who == p->uid && p->nice < nice) - nice = p->nice; - break; - } - } -out: - pids.reset (); - if (nice == NZERO * 2) - { - set_errno (ESRCH); - return -1; - } - return nice; -} - -extern "C" int -nice (int incr) -{ - return setpriority (PRIO_PROCESS, myself->pid, myself->nice + incr); -} - -/* - * Find the first bit set in I. - */ - -extern "C" int -ffs (int i) -{ - static const unsigned char table[] = - { - 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 - }; - unsigned long int a; - unsigned long int x = i & -i; - - a = x <= 0xffff ? (x <= 0xff ? 0 : 8) : (x <= 0xffffff ? 16 : 24); - - return table[x >> a] + a; -} - -static void -locked_append (int fd, const void * buf, size_t size) -{ - struct __flock64 lock_buffer = {F_WRLCK, SEEK_SET, 0, 0, 0}; - int count = 0; - - do - if ((lock_buffer.l_start = lseek64 (fd, 0, SEEK_END)) != (_off64_t) -1 - && fcntl64 (fd, F_SETLKW, &lock_buffer) != -1) - { - if (lseek64 (fd, 0, SEEK_END) != (_off64_t) -1) - write (fd, buf, size); - lock_buffer.l_type = F_UNLCK; - fcntl64 (fd, F_SETLK, &lock_buffer); - break; - } - while (count++ < 1000 - && (errno == EACCES || errno == EAGAIN) - && !usleep (1000)); -} - -extern "C" void -updwtmp (const char *wtmp_file, const struct utmp *ut) -{ - int fd; - - if ((fd = open (wtmp_file, O_WRONLY | O_BINARY, 0)) >= 0) - { - locked_append (fd, ut, sizeof *ut); - close (fd); - } -} - -static int utmp_fd = -1; -static bool utmp_readonly = false; -static char *utmp_file = (char *) _PATH_UTMP; - -static void -internal_setutent (bool force_readwrite) -{ - if (force_readwrite && utmp_readonly) - endutent (); - if (utmp_fd < 0) - { - utmp_fd = open (utmp_file, O_RDWR | O_BINARY); - /* If open fails, we assume an unprivileged process (who?). In this - case we try again for reading only unless the process calls - pututline() (==force_readwrite) in which case opening just fails. */ - if (utmp_fd < 0 && !force_readwrite) - { - utmp_fd = open (utmp_file, O_RDONLY | O_BINARY); - if (utmp_fd >= 0) - utmp_readonly = true; - } - } - else - lseek (utmp_fd, 0, SEEK_SET); -} - -extern "C" void -setutent () -{ - internal_setutent (false); -} - -extern "C" void -endutent () -{ - if (utmp_fd >= 0) - { - close (utmp_fd); - utmp_fd = -1; - utmp_readonly = false; - } -} - -extern "C" void -utmpname (const char *file) -{ - myfault efault; - if (efault.faulted () || !*file) - { - debug_printf ("Invalid file"); - return; - } - endutent (); - utmp_file = strdup (file); - debug_printf ("New UTMP file: %s", utmp_file); -} -EXPORT_ALIAS (utmpname, utmpxname) - -/* Note: do not make NO_COPY */ -static struct utmp utmp_data_buf[16]; -static unsigned utix = 0; -#define nutdbuf (sizeof (utmp_data_buf) / sizeof (utmp_data_buf[0])) -#define utmp_data ({ \ - if (utix > nutdbuf) \ - utix = 0; \ - utmp_data_buf + utix++; \ -}) - -static struct utmpx * -copy_ut_to_utx (struct utmp *ut, struct utmpx *utx) -{ - if (!ut) - return NULL; - memcpy (utx, ut, sizeof *ut); - utx->ut_tv.tv_sec = ut->ut_time; - utx->ut_tv.tv_usec = 0; - return utx; -} - -extern "C" struct utmp * -getutent () -{ - if (utmp_fd < 0) - { - internal_setutent (false); - if (utmp_fd < 0) - return NULL; - } - - utmp *ut = utmp_data; - if (read (utmp_fd, ut, sizeof *ut) != sizeof *ut) - return NULL; - return ut; -} - -extern "C" struct utmp * -getutid (const struct utmp *id) -{ - myfault efault; - if (efault.faulted (EFAULT)) - return NULL; - if (utmp_fd < 0) - { - internal_setutent (false); - if (utmp_fd < 0) - return NULL; - } - - utmp *ut = utmp_data; - while (read (utmp_fd, ut, sizeof *ut) == sizeof *ut) - { - switch (id->ut_type) - { - case RUN_LVL: - case BOOT_TIME: - case OLD_TIME: - case NEW_TIME: - if (id->ut_type == ut->ut_type) - return ut; - break; - case INIT_PROCESS: - case LOGIN_PROCESS: - case USER_PROCESS: - case DEAD_PROCESS: - if (strncmp (id->ut_id, ut->ut_id, UT_IDLEN) == 0) - return ut; - break; - default: - return NULL; - } - } - return NULL; -} - -extern "C" struct utmp * -getutline (const struct utmp *line) -{ - myfault efault; - if (efault.faulted (EFAULT)) - return NULL; - if (utmp_fd < 0) - { - internal_setutent (false); - if (utmp_fd < 0) - return NULL; - } - - utmp *ut = utmp_data; - while (read (utmp_fd, ut, sizeof *ut) == sizeof *ut) - if ((ut->ut_type == LOGIN_PROCESS || - ut->ut_type == USER_PROCESS) && - !strncmp (ut->ut_line, line->ut_line, sizeof (ut->ut_line))) - return ut; - - return NULL; -} - -extern "C" struct utmp * -pututline (const struct utmp *ut) -{ - myfault efault; - if (efault.faulted (EFAULT)) - return NULL; - internal_setutent (true); - if (utmp_fd < 0) - { - debug_printf ("error: utmp_fd %d", utmp_fd); - return NULL; - } - debug_printf ("ut->ut_type %d, ut->ut_pid %d, ut->ut_line '%s', ut->ut_id '%s'\n", - ut->ut_type, ut->ut_pid, ut->ut_line, ut->ut_id); - debug_printf ("ut->ut_user '%s', ut->ut_host '%s'\n", - ut->ut_user, ut->ut_host); - - struct utmp *u; - if ((u = getutid (ut))) - { - lseek (utmp_fd, -sizeof *ut, SEEK_CUR); - write (utmp_fd, ut, sizeof *ut); - } - else - locked_append (utmp_fd, ut, sizeof *ut); - /* The documentation says to return a pointer to this which implies that - this has to be cast from a const. That doesn't seem right but the - documentation seems pretty clear on this. */ - return (struct utmp *) ut; -} - -extern "C" void -setutxent () -{ - internal_setutent (false); -} - -extern "C" void -endutxent () -{ - endutent (); -} - -extern "C" struct utmpx * -getutxent () -{ - /* UGH. Not thread safe. */ - static struct utmpx utx; - return copy_ut_to_utx (getutent (), &utx); -} - -extern "C" struct utmpx * -getutxid (const struct utmpx *id) -{ - /* UGH. Not thread safe. */ - static struct utmpx utx; - - myfault efault; - if (efault.faulted (EFAULT)) - return NULL; - ((struct utmpx *)id)->ut_time = id->ut_tv.tv_sec; - return copy_ut_to_utx (getutid ((struct utmp *) id), &utx); -} - -extern "C" struct utmpx * -getutxline (const struct utmpx *line) -{ - /* UGH. Not thread safe. */ - static struct utmpx utx; - - myfault efault; - if (efault.faulted (EFAULT)) - return NULL; - ((struct utmpx *)line)->ut_time = line->ut_tv.tv_sec; - return copy_ut_to_utx (getutline ((struct utmp *) line), &utx); -} - -extern "C" struct utmpx * -pututxline (const struct utmpx *utmpx) -{ - /* UGH. Not thread safe. */ - static struct utmpx utx; - - myfault efault; - if (efault.faulted (EFAULT)) - return NULL; - ((struct utmpx *)utmpx)->ut_time = utmpx->ut_tv.tv_sec; - return copy_ut_to_utx (pututline ((struct utmp *) utmpx), &utx); -} - -extern "C" void -updwtmpx (const char *wtmpx_file, const struct utmpx *utmpx) -{ - ((struct utmpx *)utmpx)->ut_time = utmpx->ut_tv.tv_sec; - updwtmp (wtmpx_file, (const struct utmp *) utmpx); -} - -extern "C" -long gethostid (void) -{ - unsigned data[13] = {0x92895012, - 0x10293412, - 0x29602018, - 0x81928167, - 0x34601329, - 0x75630198, - 0x89860395, - 0x62897564, - 0x00194362, - 0x20548593, - 0x96839102, - 0x12219854, - 0x00290012}; - - bool has_cpuid = false; - - DWORD opmask = SetThreadAffinityMask (GetCurrentThread (), 1); - if (!opmask) - debug_printf ("SetThreadAffinityMask to 1 failed, %E"); - - if (!can_set_flag (0x00040000)) - debug_printf ("386 processor - no cpuid"); - else - { - debug_printf ("486 processor"); - if (can_set_flag (0x00200000)) - { - debug_printf ("processor supports CPUID instruction"); - has_cpuid = true; - } - else - debug_printf ("processor does not support CPUID instruction"); - } - if (has_cpuid) - { - unsigned maxf, unused[3]; - cpuid (&maxf, &unused[0], &unused[1], &unused[2], 0); - maxf &= 0xffff; - if (maxf >= 1) - { - unsigned features; - cpuid (&data[0], &unused[0], &unused[1], &features, 1); - if (features & (1 << 18)) - { - debug_printf ("processor has psn"); - if (maxf >= 3) - { - cpuid (&unused[0], &unused[1], &data[1], &data[2], 3); - debug_printf ("Processor PSN: %04x-%04x-%04x-%04x-%04x-%04x", - data[0] >> 16, data[0] & 0xffff, data[2] >> 16, data[2] & 0xffff, data[1] >> 16, data[1] & 0xffff); - } - } - else - debug_printf ("processor does not have psn"); - } - } - - UUID Uuid; - RPC_STATUS status = UuidCreateSequential (&Uuid); - if (GetLastError () == ERROR_PROC_NOT_FOUND) - status = UuidCreate (&Uuid); - if (status == RPC_S_OK) - { - data[4] = *(unsigned *)&Uuid.Data4[2]; - data[5] = *(unsigned short *)&Uuid.Data4[6]; - // Unfortunately Windows will sometimes pick a virtual Ethernet card - // e.g. VMWare Virtual Ethernet Adaptor - debug_printf ("MAC address of first Ethernet card: %02x:%02x:%02x:%02x:%02x:%02x", - Uuid.Data4[2], Uuid.Data4[3], Uuid.Data4[4], - Uuid.Data4[5], Uuid.Data4[6], Uuid.Data4[7]); - } - else - { - debug_printf ("no Ethernet card installed"); - } - - reg_key key (HKEY_LOCAL_MACHINE, KEY_READ, "SOFTWARE", "Microsoft", "Windows", "CurrentVersion", NULL); - key.get_string ("ProductId", (char *)&data[6], 24, "00000-000-0000000-00000"); - debug_printf ("Windows Product ID: %s", (char *)&data[6]); - - /* Contrary to MSDN, NT4 requires the second argument - or a STATUS_ACCESS_VIOLATION is generated */ - ULARGE_INTEGER availb; - GetDiskFreeSpaceEx ("C:\\", &availb, (PULARGE_INTEGER) &data[11], NULL); - - debug_printf ("hostid entropy: %08x %08x %08x %08x " - "%08x %08x %08x %08x " - "%08x %08x %08x %08x " - "%08x", - data[0], data[1], - data[2], data[3], - data[4], data[5], - data[6], data[7], - data[8], data[9], - data[10], data[11], - data[12]); - - long hostid = 0x40291372; - // a random hashing algorithm - // dependancy on md5 is probably too costly - for (int i=0;i<13;i++) - hostid ^= ((data[i] << (i << 2)) | (data[i] >> (32 - (i << 2)))); - - if (opmask && !SetThreadAffinityMask (GetCurrentThread (), opmask)) - debug_printf ("SetThreadAffinityMask to %p failed, %E", opmask); - - debug_printf ("hostid: %08x", hostid); - - return hostid; -} - -#define ETC_SHELLS "/etc/shells" -static int shell_index; -static struct __sFILE64 *shell_fp; - -extern "C" char * -getusershell () -{ - /* List of default shells if no /etc/shells exists, defined as on Linux. - FIXME: SunOS has a far longer list, containing all shells which - might be shipped with the OS. Should we do the same for the Cygwin - distro, adding bash, tcsh, ksh, pdksh and zsh? */ - static NO_COPY const char *def_shells[] = { - "/bin/sh", - "/bin/csh", - "/usr/bin/sh", - "/usr/bin/csh", - NULL - }; - static char buf[PATH_MAX]; - int ch, buf_idx; - - if (!shell_fp && !(shell_fp = fopen64 (ETC_SHELLS, "rt"))) - { - if (def_shells[shell_index]) - return strcpy (buf, def_shells[shell_index++]); - return NULL; - } - /* Skip white space characters. */ - while ((ch = getc (shell_fp)) != EOF && isspace (ch)) - ; - /* Get each non-whitespace character as part of the shell path as long as - it fits in buf. */ - for (buf_idx = 0; - ch != EOF && !isspace (ch) && buf_idx < PATH_MAX; - buf_idx++, ch = getc (shell_fp)) - buf[buf_idx] = ch; - /* Skip any trailing non-whitespace character not fitting in buf. If the - path is longer than PATH_MAX, it's invalid anyway. */ - while (ch != EOF && !isspace (ch)) - ch = getc (shell_fp); - if (buf_idx) - { - buf[buf_idx] = '\0'; - return buf; - } - return NULL; -} - -extern "C" void -setusershell () -{ - if (shell_fp) - fseek (shell_fp, 0L, SEEK_SET); - shell_index = 0; -} - -extern "C" void -endusershell () -{ - if (shell_fp) - { - fclose (shell_fp); - shell_fp = NULL; - } - shell_index = 0; -} - -extern "C" void -flockfile (FILE *file) -{ - _flockfile (file); -} - -extern "C" int -ftrylockfile (FILE *file) -{ - return _ftrylockfile (file); -} - -extern "C" void -funlockfile (FILE *file) -{ - _funlockfile (file); -} - -extern "C" FILE * -popen (const char *command, const char *in_type) -{ - const char *type = in_type; - char rw = *type++; - - /* Sanity check in_type */ - if (*type == 'b' || *type == 't') - type++; - if ((rw != 'r' && rw != 'w') || (*type != '\0')) - { - set_errno (EINVAL); - return NULL; - } - - int fds[2]; - if (pipe (fds) < 0) - return NULL; - - int myix = rw == 'r' ? 0 : 1; - - lock_process now; - FILE *fp = fdopen (fds[myix], in_type); - if (fp) - { - /* If fds are in the range of stdin/stdout/stderr, move them - out of the way (possibly temporarily). Otherwise, spawn_guts - will be confused. We do this here rather than adding logic to - spawn_guts because spawn_guts is likely to be a more frequently - used routine and having stdin/stdout/stderr closed and reassigned - to pipe handles is an unlikely event. */ - int orig_fds[2] = {fds[0], fds[1]}; - for (int i = 0; i < 2; i++) - if (fds[i] <= 2) - { - cygheap_fdnew newfd(3); - cygheap->fdtab.move_fd (fds[i], newfd); - fds[i] = newfd; - } - - int myfd = fds[myix]; /* myfd - convenience variable for manipulation - of the "parent" end of the pipe. */ - int stdchild = myix ^ 1; /* stdchild denotes the index into fd for the - handle which will be redirected to - stdin/stdout */ - int __std[2]; - __std[myix] = -1; /* -1 means don't pass this fd to the child - process */ - __std[stdchild] = fds[stdchild]; /* Do pass this as the std handle */ - - const char *argv[4] = - { - "/bin/sh", - "-c", - command, - NULL - }; - - /* Don't pass our end of the pipe to the child process */ - int fd_state = fcntl64 (myfd, F_GETFD, 0); - fcntl64 (myfd, F_SETFD, fd_state | FD_CLOEXEC); - - /* Also don't pass the file handle currently associated with stdin/stdout - to the child. This function may actually fail if the stdchild fd - is closed. But that's ok. */ - int stdchild_state = fcntl64 (stdchild, F_GETFD, 0); - fcntl64 (stdchild, F_SETFD, stdchild_state | FD_CLOEXEC); - - /* Start a shell process to run the given command without forking. */ - pid_t pid = spawn_guts ("/bin/sh", argv, cur_environ (), _P_NOWAIT, - __std[0], __std[1]); - - /* Reinstate the close-on-exec state */ - fcntl64 (stdchild, F_SETFD, stdchild_state); - - /* If pid >= 0 then spawn_guts succeeded. */ - if (pid >= 0) - { - close (fds[stdchild]); /* Close the child end of the pipe. */ - /* Move the fd back to its original slot if it has been moved since - we're always supposed to open the lowest numbered available fd - and, if fds[mix] != orig_fds[myix] then orig_fds[myix] is - presumably lower. */ - if (fds[myix] != orig_fds[myix]) - cygheap->fdtab.move_fd (fds[myix], myfd = orig_fds[myix]); - fhandler_pipe *fh = (fhandler_pipe *) cygheap->fdtab[myfd]; - /* Flag that this handle is associated with popen and then reset - the handle's original close-on-exec state. */ - fh->set_popen_pid (pid); - fcntl64 (myfd, F_SETFD, fd_state); - return fp; - } - } - - /* If we reach here we've seen an error but the pipe handles are open. - Close them and return NULL. */ - int save_errno = get_errno (); - close (fds[0]); - close (fds[1]); - set_errno (save_errno); - return NULL; -} - -int -pclose (FILE *fp) -{ - fhandler_pipe *fh = (fhandler_pipe *) cygheap->fdtab[fileno(fp)]; - - if (fh->get_device () != FH_PIPEW && fh->get_device () != FH_PIPER) - { - set_errno (EBADF); - return -1; - } - - int pid = fh->get_popen_pid (); - if (!pid) - { - set_errno (ECHILD); - return -1; - } - - if (fclose (fp)) - return -1; - - int status; - while (1) - if (waitpid (pid, &status, 0) == pid) - break; - else if (get_errno () == EINTR) - continue; - else - return -1; - - return status; -} - -/* Preliminary(?) implementation of the openat family of functions. */ - -static int -gen_full_path_at (char *path_ret, int dirfd, const char *pathname, - bool null_pathname_allowed = false) -{ - /* Set null_pathname_allowed to true to allow GLIBC compatible behaviour - for NULL pathname. Only used by futimesat. */ - if (!pathname && !null_pathname_allowed) - { - set_errno (EFAULT); - return -1; - } - if (pathname) - { - if (!*pathname) - { - set_errno (ENOENT); - return -1; - } - if (strlen (pathname) >= PATH_MAX) - { - set_errno (ENAMETOOLONG); - return -1; - } - } - if (pathname && isabspath (pathname)) - stpcpy (path_ret, pathname); - else - { - char *p; - - if (dirfd == AT_FDCWD) - { - cwdstuff::cwd_lock.acquire (); - p = stpcpy (path_ret, cygheap->cwd.get_posix ()); - cwdstuff::cwd_lock.release (); - } - else - { - cygheap_fdget cfd (dirfd); - if (cfd < 0) - return -1; - if (!cfd->pc.isdir ()) - { - set_errno (ENOTDIR); - return -1; - } - p = stpcpy (path_ret, cfd->get_name ()); - } - if (!p) - { - set_errno (ENOTDIR); - return -1; - } - if (pathname) - { - if (p[-1] != '/') - *p++ = '/'; - stpcpy (p, pathname); - } - } - return 0; -} - -extern "C" int -openat (int dirfd, const char *pathname, int flags, ...) -{ - tmp_pathbuf tp; - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - char *path = tp.c_get (); - if (gen_full_path_at (path, dirfd, pathname)) - return -1; - - va_list ap; - mode_t mode; - - va_start (ap, flags); - mode = va_arg (ap, mode_t); - va_end (ap); - return open (path, flags, mode); -} - -extern "C" int -faccessat (int dirfd, const char *pathname, int mode, int flags) -{ - tmp_pathbuf tp; - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - int res = -1; - char *path = tp.c_get (); - if (!gen_full_path_at (path, dirfd, pathname)) - { - if ((mode & ~(F_OK|R_OK|W_OK|X_OK)) - || (flags & ~(AT_SYMLINK_NOFOLLOW|AT_EACCESS))) - set_errno (EINVAL); - else - { - fhandler_base *fh = build_fh_name (path, - (flags & AT_SYMLINK_NOFOLLOW) - ? PC_SYM_NOFOLLOW : PC_SYM_FOLLOW, - stat_suffixes); - if (fh) - { - res = fh->fhaccess (mode, flags & AT_EACCESS); - delete fh; - } - } - } - debug_printf ("returning %d", res); - return res; -} - -extern "C" int -fchmodat (int dirfd, const char *pathname, mode_t mode, int flags) -{ - tmp_pathbuf tp; - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - if (flags) - { - /* BSD has lchmod, but Linux does not. POSIX says - AT_SYMLINK_NOFOLLOW is allowed to fail on symlinks; but Linux - blindly fails even for non-symlinks. */ - set_errno ((flags & ~AT_SYMLINK_NOFOLLOW) ? EINVAL : EOPNOTSUPP); - return -1; - } - char *path = tp.c_get (); - if (gen_full_path_at (path, dirfd, pathname)) - return -1; - return chmod (path, mode); -} - -extern "C" int -fchownat (int dirfd, const char *pathname, __uid32_t uid, __gid32_t gid, - int flags) -{ - tmp_pathbuf tp; - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - if (flags & ~AT_SYMLINK_NOFOLLOW) - { - set_errno (EINVAL); - return -1; - } - char *path = tp.c_get (); - if (gen_full_path_at (path, dirfd, pathname)) - return -1; - return chown_worker (path, (flags & AT_SYMLINK_NOFOLLOW) - ? PC_SYM_NOFOLLOW : PC_SYM_FOLLOW, uid, gid); -} - -extern "C" int -fstatat (int dirfd, const char *pathname, struct __stat64 *st, int flags) -{ - tmp_pathbuf tp; - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - if (flags & ~AT_SYMLINK_NOFOLLOW) - { - set_errno (EINVAL); - return -1; - } - char *path = tp.c_get (); - if (gen_full_path_at (path, dirfd, pathname)) - return -1; - return (flags & AT_SYMLINK_NOFOLLOW) ? lstat64 (path, st) : stat64 (path, st); -} - -extern int utimens_worker (path_conv &, const struct timespec *); - -extern "C" int -utimensat (int dirfd, const char *pathname, const struct timespec *times, - int flags) -{ - tmp_pathbuf tp; - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - char *path = tp.c_get (); - if (flags & ~AT_SYMLINK_NOFOLLOW) - { - set_errno (EINVAL); - return -1; - } - if (gen_full_path_at (path, dirfd, pathname)) - return -1; - path_conv win32 (path, PC_POSIX | ((flags & AT_SYMLINK_NOFOLLOW) - ? PC_SYM_NOFOLLOW : PC_SYM_FOLLOW), - stat_suffixes); - return utimens_worker (win32, times); -} - -extern "C" int -futimesat (int dirfd, const char *pathname, const struct timeval *times) -{ - tmp_pathbuf tp; - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - char *path = tp.c_get (); - if (gen_full_path_at (path, dirfd, pathname, true)) - return -1; - return utimes (path, times); -} - -extern "C" int -linkat (int olddirfd, const char *oldpathname, - int newdirfd, const char *newpathname, - int flags) -{ - tmp_pathbuf tp; - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - if (flags & ~AT_SYMLINK_FOLLOW) - { - set_errno (EINVAL); - return -1; - } - char *oldpath = tp.c_get (); - if (gen_full_path_at (oldpath, olddirfd, oldpathname)) - return -1; - char *newpath = tp.c_get (); - if (gen_full_path_at (newpath, newdirfd, newpathname)) - return -1; - if (flags & AT_SYMLINK_FOLLOW) - { - path_conv old_name (oldpath, PC_SYM_FOLLOW | PC_POSIX, stat_suffixes); - if (old_name.error) - { - set_errno (old_name.error); - return -1; - } - strcpy (oldpath, old_name.normalized_path); - } - return link (oldpath, newpath); -} - -extern "C" int -mkdirat (int dirfd, const char *pathname, mode_t mode) -{ - tmp_pathbuf tp; - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - char *path = tp.c_get (); - if (gen_full_path_at (path, dirfd, pathname)) - return -1; - return mkdir (path, mode); -} - -extern "C" int -mkfifoat (int dirfd, const char *pathname, mode_t mode) -{ - tmp_pathbuf tp; - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - char *path = tp.c_get (); - if (gen_full_path_at (path, dirfd, pathname)) - return -1; - return mkfifo (path, mode); -} - -extern "C" int -mknodat (int dirfd, const char *pathname, mode_t mode, __dev32_t dev) -{ - tmp_pathbuf tp; - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - char *path = tp.c_get (); - if (gen_full_path_at (path, dirfd, pathname)) - return -1; - return mknod32 (path, mode, dev); -} - -extern "C" ssize_t -readlinkat (int dirfd, const char *pathname, char *buf, size_t bufsize) -{ - tmp_pathbuf tp; - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - char *path = tp.c_get (); - if (gen_full_path_at (path, dirfd, pathname)) - return -1; - return readlink (path, buf, bufsize); -} - -extern "C" int -renameat (int olddirfd, const char *oldpathname, - int newdirfd, const char *newpathname) -{ - tmp_pathbuf tp; - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - char *oldpath = tp.c_get (); - if (gen_full_path_at (oldpath, olddirfd, oldpathname)) - return -1; - char *newpath = tp.c_get (); - if (gen_full_path_at (newpath, newdirfd, newpathname)) - return -1; - return rename (oldpath, newpath); -} - -extern "C" int -symlinkat (const char *oldpath, int newdirfd, const char *newpathname) -{ - tmp_pathbuf tp; - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - char *newpath = tp.c_get (); - if (gen_full_path_at (newpath, newdirfd, newpathname)) - return -1; - return symlink (oldpath, newpath); -} - -extern "C" int -unlinkat (int dirfd, const char *pathname, int flags) -{ - tmp_pathbuf tp; - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - if (flags & ~AT_REMOVEDIR) - { - set_errno (EINVAL); - return -1; - } - char *path = tp.c_get (); - if (gen_full_path_at (path, dirfd, pathname)) - return -1; - return (flags & AT_REMOVEDIR) ? rmdir (path) : unlink (path); -} diff --git a/winsup/cygwin/sysconf.cc b/winsup/cygwin/sysconf.cc deleted file mode 100644 index 84aced16a..000000000 --- a/winsup/cygwin/sysconf.cc +++ /dev/null @@ -1,319 +0,0 @@ -/* sysconf.cc - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "ntdll.h" - -static long -get_open_max (int in) -{ - long max = getdtablesize (); - if (max < OPEN_MAX) - max = OPEN_MAX; - return max; -} - -static long -get_page_size (int in) -{ - return getpagesize (); -} - -static long -get_nproc_values (int in) -{ - NTSTATUS ret; - SYSTEM_BASIC_INFORMATION sbi; - if ((ret = NtQuerySystemInformation (SystemBasicInformation, (PVOID) &sbi, - sizeof sbi, NULL)) != STATUS_SUCCESS) - { - __seterrno_from_nt_status (ret); - debug_printf ("NtQuerySystemInformation: ret %d, Dos(ret) %E", - ret); - return -1; - } - switch (in) - { - case _SC_NPROCESSORS_CONF: - return sbi.NumberProcessors; - case _SC_NPROCESSORS_ONLN: - { - int i = 0; - do - if (sbi.ActiveProcessors & 1) - i++; - while (sbi.ActiveProcessors >>= 1); - return i; - } - case _SC_PHYS_PAGES: - return sbi.NumberOfPhysicalPages - / (getpagesize () / getsystempagesize ()); - } - return -1; -} - -static long -get_avphys (int in) -{ - NTSTATUS ret; - SYSTEM_PERFORMANCE_INFORMATION spi; - if ((ret = NtQuerySystemInformation (SystemPerformanceInformation, - (PVOID) &spi, sizeof spi, NULL)) - != STATUS_SUCCESS) - { - __seterrno_from_nt_status (ret); - debug_printf ("NtQuerySystemInformation: ret %d, Dos(ret) %E", - ret); - return -1; - } - return spi.AvailablePages / (getpagesize () / getsystempagesize ()); -} - -enum sc_type { nsup, cons, func }; - -static struct -{ - sc_type type; - union - { - long c; - long (*f)(int); - }; -} sca[] = -{ - {cons, {c:ARG_MAX}}, /* 0, _SC_ARG_MAX */ - {cons, {c:CHILD_MAX}}, /* 1, _SC_CHILD_MAX */ - {cons, {c:CLOCKS_PER_SEC}}, /* 2, _SC_CLK_TCK */ - {cons, {c:NGROUPS_MAX}}, /* 3, _SC_NGROUPS_MAX */ - {func, {f:get_open_max}}, /* 4, _SC_OPEN_MAX */ - {cons, {c:_POSIX_JOB_CONTROL}}, /* 5, _SC_JOB_CONTROL */ - {cons, {c:_POSIX_SAVED_IDS}}, /* 6, _SC_SAVED_IDS */ - {cons, {c:_POSIX_VERSION}}, /* 7, _SC_VERSION */ - {func, {f:get_page_size}}, /* 8, _SC_PAGESIZE */ - {func, {f:get_nproc_values}}, /* 9, _SC_NPROCESSORS_CONF */ - {func, {f:get_nproc_values}}, /* 10, _SC_NPROCESSORS_ONLN */ - {func, {f:get_nproc_values}}, /* 11, _SC_PHYS_PAGES */ - {func, {f:get_avphys}}, /* 12, _SC_AVPHYS_PAGES */ - {cons, {c:MQ_OPEN_MAX}}, /* 13, _SC_MQ_OPEN_MAX */ - {cons, {c:MQ_PRIO_MAX}}, /* 14, _SC_MQ_PRIO_MAX */ - {cons, {c:RTSIG_MAX}}, /* 15, _SC_RTSIG_MAX */ - {cons, {c:-1L}}, /* 16, _SC_SEM_NSEMS_MAX */ - {cons, {c:SEM_VALUE_MAX}}, /* 17, _SC_SEM_VALUE_MAX */ - {cons, {c:SIGQUEUE_MAX}}, /* 18, _SC_SIGQUEUE_MAX */ - {cons, {c:TIMER_MAX}}, /* 19, _SC_TIMER_MAX */ - {nsup, {c:0}}, /* 20, _SC_TZNAME_MAX */ - {cons, {c:-1L}}, /* 21, _SC_ASYNCHRONOUS_IO */ - {cons, {c:_POSIX_FSYNC}}, /* 22, _SC_FSYNC */ - {cons, {c:_POSIX_MAPPED_FILES}}, /* 23, _SC_MAPPED_FILES */ - {cons, {c:-1L}}, /* 24, _SC_MEMLOCK */ - {cons, {c:_POSIX_MEMLOCK_RANGE}}, /* 25, _SC_MEMLOCK_RANGE */ - {cons, {c:_POSIX_MEMORY_PROTECTION}}, /* 26, _SC_MEMORY_PROTECTION */ - {cons, {c:_POSIX_MESSAGE_PASSING}}, /* 27, _SC_MESSAGE_PASSING */ - {cons, {c:-1L}}, /* 28, _SC_PRIORITIZED_IO */ - {cons, {c:_POSIX_REALTIME_SIGNALS}}, /* 29, _SC_REALTIME_SIGNALS */ - {cons, {c:_POSIX_SEMAPHORES}}, /* 30, _SC_SEMAPHORES */ - {cons, {c:_POSIX_SHARED_MEMORY_OBJECTS}}, /* 31, _SC_SHARED_MEMORY_OBJECTS */ - {cons, {c:_POSIX_SYNCHRONIZED_IO}}, /* 32, _SC_SYNCHRONIZED_IO */ - {cons, {c:_POSIX_TIMERS}}, /* 33, _SC_TIMERS */ - {nsup, {c:0}}, /* 34, _SC_AIO_LISTIO_MAX */ - {nsup, {c:0}}, /* 35, _SC_AIO_MAX */ - {nsup, {c:0}}, /* 36, _SC_AIO_PRIO_DELTA_MAX */ - {nsup, {c:0}}, /* 37, _SC_DELAYTIMER_MAX */ - {cons, {c:PTHREAD_KEYS_MAX}}, /* 38, _SC_THREAD_KEYS_MAX */ - {cons, {c:PTHREAD_STACK_MIN}}, /* 39, _SC_THREAD_STACK_MIN */ - {cons, {c:-1L}}, /* 40, _SC_THREAD_THREADS_MAX */ - {cons, {c:TTY_NAME_MAX}}, /* 41, _SC_TTY_NAME_MAX */ - {cons, {c:_POSIX_THREADS}}, /* 42, _SC_THREADS */ - {cons, {c:-1L}}, /* 43, _SC_THREAD_ATTR_STACKADDR */ - {cons, {c:_POSIX_THREAD_ATTR_STACKSIZE}}, /* 44, _SC_THREAD_ATTR_STACKSIZE */ - {cons, {c:_POSIX_THREAD_PRIORITY_SCHEDULING}}, /* 45, _SC_THREAD_PRIORITY_SCHEDULING */ - {cons, {c:-1L}}, /* 46, _SC_THREAD_PRIO_INHERIT */ - {cons, {c:-1L}}, /* 47, _SC_THREAD_PRIO_PROTECT */ - {cons, {c:_POSIX_THREAD_PROCESS_SHARED}}, /* 48, _SC_THREAD_PROCESS_SHARED */ - {cons, {c:_POSIX_THREAD_SAFE_FUNCTIONS}}, /* 49, _SC_THREAD_SAFE_FUNCTIONS */ - {cons, {c:16384L}}, /* 50, _SC_GETGR_R_SIZE_MAX */ - {cons, {c:16384L}}, /* 51, _SC_GETPW_R_SIZE_MAX */ - {cons, {c:LOGIN_NAME_MAX}}, /* 52, _SC_LOGIN_NAME_MAX */ - {cons, {c:PTHREAD_DESTRUCTOR_ITERATIONS}}, /* 53, _SC_THREAD_DESTRUCTOR_ITERATIONS */ - {cons, {c:_POSIX_ADVISORY_INFO}}, /* 54, _SC_ADVISORY_INFO */ - {cons, {c:ATEXIT_MAX}}, /* 55, _SC_ATEXIT_MAX */ - {cons, {c:-1L}}, /* 56, _SC_BARRIERS */ - {cons, {c:BC_BASE_MAX}}, /* 57, _SC_BC_BASE_MAX */ - {cons, {c:BC_DIM_MAX}}, /* 58, _SC_BC_DIM_MAX */ - {cons, {c:BC_SCALE_MAX}}, /* 59, _SC_BC_SCALE_MAX */ - {cons, {c:BC_STRING_MAX}}, /* 60, _SC_BC_STRING_MAX */ - {cons, {c:-1L}}, /* 61, _SC_CLOCK_SELECTION */ - {nsup, {c:0}}, /* 62, _SC_COLL_WEIGHTS_MAX */ - {cons, {c:-1L}}, /* 63, _SC_CPUTIME */ - {cons, {c:EXPR_NEST_MAX}}, /* 64, _SC_EXPR_NEST_MAX */ - {cons, {c:HOST_NAME_MAX}}, /* 65, _SC_HOST_NAME_MAX */ - {cons, {c:IOV_MAX}}, /* 66, _SC_IOV_MAX */ - {cons, {c:_POSIX_IPV6}}, /* 67, _SC_IPV6 */ - {cons, {c:LINE_MAX}}, /* 68, _SC_LINE_MAX */ - {cons, {c:-1L}}, /* 69, _SC_MONOTONIC_CLOCK */ - {cons, {c:_POSIX_RAW_SOCKETS}}, /* 70, _SC_RAW_SOCKETS */ - {cons, {c:_POSIX_READER_WRITER_LOCKS}}, /* 71, _SC_READER_WRITER_LOCKS */ - {cons, {c:_POSIX_REGEXP}}, /* 72, _SC_REGEXP */ - {cons, {c:RE_DUP_MAX}}, /* 73, _SC_RE_DUP_MAX */ - {cons, {c:_POSIX_SHELL}}, /* 74, _SC_SHELL */ - {cons, {c:-1L}}, /* 75, _SC_SPAWN */ - {cons, {c:-1L}}, /* 76, _SC_SPIN_LOCKS */ - {cons, {c:-1L}}, /* 77, _SC_SPORADIC_SERVER */ - {nsup, {c:0}}, /* 78, _SC_SS_REPL_MAX */ - {cons, {c:SYMLOOP_MAX}}, /* 79, _SC_SYMLOOP_MAX */ - {cons, {c:-1L}}, /* 80, _SC_THREAD_CPUTIME */ - {cons, {c:-1L}}, /* 81, _SC_THREAD_SPORADIC_SERVER */ - {cons, {c:-1L}}, /* 82, _SC_TIMEOUTS */ - {cons, {c:-1L}}, /* 83, _SC_TRACE */ - {cons, {c:-1L}}, /* 84, _SC_TRACE_EVENT_FILTER */ - {nsup, {c:0}}, /* 85, _SC_TRACE_EVENT_NAME_MAX */ - {cons, {c:-1L}}, /* 86, _SC_TRACE_INHERIT */ - {cons, {c:-1L}}, /* 87, _SC_TRACE_LOG */ - {nsup, {c:0}}, /* 88, _SC_TRACE_NAME_MAX */ - {nsup, {c:0}}, /* 89, _SC_TRACE_SYS_MAX */ - {nsup, {c:0}}, /* 90, _SC_TRACE_USER_EVENT_MAX */ - {cons, {c:-1L}}, /* 91, _SC_TYPED_MEMORY_OBJECTS */ - {cons, {c:-1L}}, /* 92, _SC_V6_ILP32_OFF32 */ - {cons, {c:_POSIX_V6_ILP32_OFFBIG}}, /* 93, _SC_V6_ILP32_OFFBIG */ - {cons, {c:-1L}}, /* 94, _SC_V6_LP64_OFF64 */ - {cons, {c:-1L}}, /* 95, _SC_V6_LPBIG_OFFBIG */ - {cons, {c:_XOPEN_CRYPT}}, /* 96, _SC_XOPEN_CRYPT */ - {cons, {c:_XOPEN_ENH_I18N}}, /* 97, _SC_XOPEN_ENH_I18N */ - {cons, {c:-1L}}, /* 98, _SC_XOPEN_LEGACY */ - {cons, {c:-1L}}, /* 99, _SC_XOPEN_REALTIME */ - {cons, {c:STREAM_MAX}}, /* 100, _SC_STREAM_MAX */ - {cons, {c:_POSIX_PRIORITY_SCHEDULING}}, /* 101, _SC_PRIORITY_SCHEDULING */ - {cons, {c:-1L}}, /* 102, _SC_XOPEN_REALTIME_THREADS */ - {cons, {c:_XOPEN_SHM}}, /* 103, _SC_XOPEN_SHM */ - {cons, {c:-1L}}, /* 104, _SC_XOPEN_STREAMS */ - {cons, {c:-1L}}, /* 105, _SC_XOPEN_UNIX */ - {cons, {c:_XOPEN_VERSION}}, /* 106, _SC_XOPEN_VERSION */ - {cons, {c:_POSIX2_CHAR_TERM}}, /* 107, _SC_2_CHAR_TERM */ - {cons, {c:_POSIX2_C_BIND}}, /* 108, _SC_2_C_BIND */ - {cons, {c:_POSIX2_C_BIND}}, /* 109, _SC_2_C_DEV */ - {cons, {c:-1L}}, /* 110, _SC_2_FORT_DEV */ - {cons, {c:-1L}}, /* 111, _SC_2_FORT_RUN */ - {cons, {c:-1L}}, /* 112, _SC_2_LOCALEDEF */ - {cons, {c:-1L}}, /* 113, _SC_2_PBS */ - {cons, {c:-1L}}, /* 114, _SC_2_PBS_ACCOUNTING */ - {cons, {c:-1L}}, /* 115, _SC_2_PBS_CHECKPOINT */ - {cons, {c:-1L}}, /* 116, _SC_2_PBS_LOCATE */ - {cons, {c:-1L}}, /* 117, _SC_2_PBS_MESSAGE */ - {cons, {c:-1L}}, /* 118, _SC_2_PBS_TRACK */ - {cons, {c:_POSIX2_SW_DEV}}, /* 119, _SC_2_SW_DEV */ - {cons, {c:_POSIX2_UPE}}, /* 120, _SC_2_UPE */ - {cons, {c:_POSIX2_VERSION}}, /* 121, _SC_2_VERSION */ -}; - -#define SC_MIN _SC_ARG_MAX -#define SC_MAX _SC_2_VERSION - -/* sysconf: POSIX 4.8.1.1 */ -/* Allows a portable app to determine quantities of resources or - presence of an option at execution time. */ -long int -sysconf (int in) -{ - if (in >= SC_MIN && in <= SC_MAX) - { - switch (sca[in].type) - { - case nsup: - break; - case cons: - return sca[in].c; - case func: - return sca[in].f (in); - } - } - /* Unimplemented sysconf name or invalid option value. */ - set_errno (EINVAL); - return -1L; -} - -#define ls(s) sizeof(s),s - -static struct -{ - size_t l; - const char *s; -} csa[] = -{ - {ls ("/bin:/usr/bin")}, /* _CS_PATH */ - {0, NULL}, /* _CS_POSIX_V6_ILP32_OFF32_CFLAGS */ - {0, NULL}, /* _CS_POSIX_V6_ILP32_OFF32_LDFLAGS */ - {0, NULL}, /* _CS_POSIX_V6_ILP32_OFF32_LIBS */ - {0, NULL}, /* _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS */ - {ls ("")}, /* _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS */ - {ls ("")}, /* _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS */ - {ls ("")}, /* _CS_POSIX_V6_ILP32_OFFBIG_LIBS */ - {ls ("")}, /* _CS_XBS5_ILP32_OFFBIG_LINTFLAGS */ - {0, NULL}, /* _CS_POSIX_V6_LP64_OFF64_CFLAGS */ - {0, NULL}, /* _CS_POSIX_V6_LP64_OFF64_LDFLAGS */ - {0, NULL}, /* _CS_POSIX_V6_LP64_OFF64_LIBS */ - {0, NULL}, /* _CS_XBS5_LP64_OFF64_LINTFLAGS */ - {0, NULL}, /* _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS */ - {0, NULL}, /* _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS */ - {0, NULL}, /* _CS_POSIX_V6_LPBIG_OFFBIG_LIBS */ - {0, NULL}, /* _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS */ - {ls ("POSIX_V6_ILP32_OFFBIG")}, /* _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS */ -}; - -#define CS_MIN _CS_PATH -#define CS_MAX _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS - -extern "C" size_t -confstr (int in, char *buf, size_t len) -{ - if (in >= CS_MIN && in <= CS_MAX) - { - if (csa[in].l && len) - { - buf[0] = 0; - strncat (buf, csa[in].s, min (len, csa[in].l) - 1); - } - return csa[in].l; - } - /* Invalid option value. */ - set_errno (EINVAL); - return 0; -} - -extern "C" int -get_nprocs_conf (void) -{ - return get_nproc_values (_SC_NPROCESSORS_CONF); -} - -extern "C" int -get_nprocs (void) -{ - return get_nproc_values (_SC_NPROCESSORS_ONLN); -} - -extern "C" long -get_phys_pages (void) -{ - return get_nproc_values (_SC_PHYS_PAGES); -} - -extern "C" long -get_avphys_pages (void) -{ - return get_avphys (_SC_AVPHYS_PAGES); -} diff --git a/winsup/cygwin/syslog.cc b/winsup/cygwin/syslog.cc deleted file mode 100644 index b27f0e716..000000000 --- a/winsup/cygwin/syslog.cc +++ /dev/null @@ -1,458 +0,0 @@ -/* syslog.cc - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#define __INSIDE_CYGWIN_NET__ - -#include "winsup.h" -#include -#include -#include -#include -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "cygtls.h" - -#define CYGWIN_LOG_NAME "Cygwin" - -/* openlog: save the passed args. Don't open the system log or /dev/log yet. */ -extern "C" void -openlog (const char *ident, int logopt, int facility) -{ - debug_printf ("openlog called with (%s, %d, %d)", - ident ? ident : "", logopt, facility); - - if (_my_tls.locals.process_ident != NULL) - { - free (_my_tls.locals.process_ident); - _my_tls.locals.process_ident = NULL; - } - if (ident) - { - _my_tls.locals.process_ident = (char *) malloc (strlen (ident) + 1); - if (!_my_tls.locals.process_ident) - { - debug_printf ("failed to allocate memory for _my_tls.locals.process_ident"); - return; - } - strcpy (_my_tls.locals.process_ident, ident); - } - _my_tls.locals.process_logopt = logopt; - _my_tls.locals.process_facility = facility; -} - -/* setlogmask: set the log priority mask and return previous mask. - If maskpri is zero, just return previous. */ -int -setlogmask (int maskpri) -{ - if (maskpri == 0) - return _my_tls.locals.process_logmask; - - int old_mask = _my_tls.locals.process_logmask; - _my_tls.locals.process_logmask = maskpri; - - return old_mask; -} - -/* Private class used to handle formatting of syslog message - It is named pass_handler because it does a two-pass handling of log - strings. The first pass counts the length of the string, and the second - one builds the string. */ - -class pass_handler -{ - private: - FILE *fp_; - char *message_; - int total_len_; - - void shutdown (); - - /* Explicitly disallow copies */ - pass_handler (const pass_handler &); - pass_handler & operator = (const pass_handler &); - - public: - pass_handler (); - ~pass_handler (); - - int initialize (int); - - int print (const char *,...); - int print_va (const char *, va_list); - char *get_message () const { return message_; } - void set_message (char *s) { message_ = s; *message_ = '\0'; } -}; - -pass_handler::pass_handler () : fp_ (0), message_ (0), total_len_ (0) -{ - ; -} - -pass_handler::~pass_handler () -{ - shutdown (); -} - -void -pass_handler::shutdown () -{ - if (fp_ != NULL) - { - fclose (fp_); - fp_ = 0; - } -} - -int -pass_handler::initialize (int pass_number) -{ - shutdown (); - if (pass_number) - return total_len_ + 1; - - fp_ = fopen ("/dev/null", "wb"); - setbuf (fp_, NULL); - if (fp_ == NULL) - { - debug_printf ("failed to open /dev/null"); - return -1; - } - total_len_ = 0; - return 0; -} - -int -pass_handler::print (const char *fmt, ...) -{ - va_list ap; - va_start (ap, fmt); - int ret = print_va (fmt, ap); - va_end (ap); - return ret; -} - -int -pass_handler::print_va (const char *fmt, va_list list) -{ - if (fp_ != NULL) - { - int len = vfprintf (fp_, fmt, list); - if (len < 0) - return -1; - total_len_ += len; - return 0; - } - else if (message_ != NULL) - { - char *printpos = &message_[strlen (message_)]; - vsprintf (printpos, fmt, list); - return 0; - } - debug_printf ("FAILURE ! fp_ and message_ both 0!! "); - return -1; -} - -static NO_COPY muto try_connect_guard; -static enum { - not_inited, - inited_failed, - inited_dgram, - inited_stream -} syslogd_inited; -static int syslogd_sock = -1; -extern "C" int cygwin_socket (int, int, int); -extern "C" int cygwin_connect (int, const struct sockaddr *, int); - -static void -connect_syslogd () -{ - struct __stat64 st; - int fd; - struct sockaddr_un sun; - - if (syslogd_inited != not_inited && syslogd_sock >= 0) - close (syslogd_sock); - syslogd_inited = inited_failed; - syslogd_sock = -1; - if (stat64 (_PATH_LOG, &st) || !S_ISSOCK (st.st_mode)) - return; - if ((fd = cygwin_socket (AF_LOCAL, SOCK_DGRAM, 0)) < 0) - return; - sun.sun_family = AF_LOCAL; - strncpy (sun.sun_path, _PATH_LOG, sizeof sun.sun_path); - if (cygwin_connect (fd, (struct sockaddr *) &sun, sizeof sun)) - { - if (get_errno () != EPROTOTYPE) - { - close (fd); - return; - } - /* Retry with SOCK_STREAM. */ - if ((fd = cygwin_socket (AF_LOCAL, SOCK_STREAM, 0)) < 0) - return; - if (cygwin_connect (fd, (struct sockaddr *) &sun, sizeof sun)) - { - close (fd); - return; - } - syslogd_inited = inited_stream; - } - else - syslogd_inited = inited_dgram; - syslogd_sock = fd; - fcntl64 (syslogd_sock, F_SETFD, FD_CLOEXEC); - return; -} - -static int -try_connect_syslogd (int priority, const char *msg, int len) -{ - ssize_t ret = -1; - - try_connect_guard.init ("try_connect_guard")->acquire (); - if (syslogd_inited == not_inited) - connect_syslogd (); - if (syslogd_sock >= 0) - { - char pribuf[16]; - sprintf (pribuf, "<%d>", priority); - struct iovec iv[2] = - { - { pribuf, strlen (pribuf) }, - { (char *) msg, len } - }; - - ret = writev (syslogd_sock, iv, 2); - /* If the syslog daemon has been restarted and /dev/log was - a stream socket, the connection is broken. In this case, - try to reopen the socket and try again. */ - if (ret < 0 && syslogd_inited == inited_stream) - { - connect_syslogd (); - if (syslogd_sock >= 0) - ret = writev (syslogd_sock, iv, 2); - } - /* If write fails and LOG_CONS is set, return failure to vsyslog so - it falls back to the usual logging method for this OS. */ - if (ret >= 0 || !(_my_tls.locals.process_logopt & LOG_CONS)) - ret = syslogd_sock; - } - try_connect_guard.release (); - return ret; -} - -/* syslog: creates the log message and writes to /dev/log, or to the - NT system log if /dev/log isn't available. - - FIXME. WinNT system log messages don't look pretty, but in order to - fix this we have to embed resources in the code and tell the NT - registry where we are, blech (what happens if we move ?). We could, - however, add the resources in Cygwin and always point to that. */ - -extern "C" void -vsyslog (int priority, const char *message, va_list ap) -{ - debug_printf ("%x %s", priority, message); - /* If the priority fails the current mask, reject */ - if ((LOG_MASK (LOG_PRI (priority)) & _my_tls.locals.process_logmask) == 0) - { - debug_printf ("failing message %x due to priority mask %x", - priority, _my_tls.locals.process_logmask); - return; - } - - /* Set default facility to LOG_USER if not yet set via openlog. */ - if (!_my_tls.locals.process_facility) - _my_tls.locals.process_facility = LOG_USER; - - /* Add default facility if not in the given priority. */ - if (!(priority & LOG_FACMASK)) - priority |= _my_tls.locals.process_facility; - - /* Translate %m in the message to error text */ - char *errtext = strerror (get_errno ()); - int errlen = strlen (errtext); - int numfound = 0; - - for (const char *cp = message; *cp; cp++) - if (*cp == '%' && cp[1] == 'm') - numfound++; - - char *newmessage = (char *) alloca (strlen (message) + - (errlen * numfound) + 1); - - if (newmessage == NULL) - { - debug_printf ("failed to allocate newmessage"); - return; - } - - char *dst = newmessage; - for (const char *cp2 = message; *cp2; cp2++) - if (*cp2 == '%' && cp2[1] == 'm') - { - cp2++; - strcpy (dst, errtext); - while (*dst) - dst++; - } - else - *dst++ = *cp2; - - *dst = '\0'; - message = newmessage; - - /* Work out the priority type - we ignore the facility for now.. */ - WORD eventType; - switch (LOG_PRI (priority)) - { - case LOG_EMERG: - case LOG_ALERT: - case LOG_CRIT: - case LOG_ERR: - eventType = EVENTLOG_ERROR_TYPE; - break; - case LOG_WARNING: - eventType = EVENTLOG_WARNING_TYPE; - break; - case LOG_NOTICE: - case LOG_INFO: - case LOG_DEBUG: - eventType = EVENTLOG_INFORMATION_TYPE; - break; - default: - eventType = EVENTLOG_ERROR_TYPE; - break; - } - - /* We need to know how long the buffer needs to be. - The only legal way I can see of doing this is to - do a vfprintf to /dev/null, and count the bytes - output, then do it again to a malloc'ed string. This - is ugly, slow, but prevents core dumps :-). - */ - pass_handler pass; - for (int pass_number = 0; pass_number < 2; ++pass_number) - { - int n = pass.initialize (pass_number); - if (n == -1) - return; - else if (n > 0) - pass.set_message ((char *) alloca (n)); - - /* Deal with ident_string */ - if (_my_tls.locals.process_ident != NULL) - { - if (pass.print ("%s: ", _my_tls.locals.process_ident) == -1) - return; - } - if (_my_tls.locals.process_logopt & LOG_PID) - { - if (pass.print ("PID %u: ", getpid ()) == -1) - return; - } - - /* Print out the variable part */ - if (pass.print_va (message, ap) == -1) - return; - - } - const char *msg_strings[1]; - char *total_msg = pass.get_message (); - int len = strlen (total_msg); - if (len != 0 && (total_msg[len - 1] == '\n')) - total_msg[--len] = '\0'; - - msg_strings[0] = total_msg; - - if (_my_tls.locals.process_logopt & LOG_PERROR) - { - write (STDERR_FILENO, total_msg, len); - write (STDERR_FILENO, "\n", 1); - } - - int fd; - if ((fd = try_connect_syslogd (priority, total_msg, len + 1)) < 0) - { - /* If syslogd isn't present, open the event log and send the message */ - HANDLE hEventSrc = RegisterEventSourceA (NULL, (_my_tls.locals.process_ident != NULL) ? - _my_tls.locals.process_ident : CYGWIN_LOG_NAME); - if (hEventSrc == NULL) - { - debug_printf ("RegisterEventSourceA failed with %E"); - return; - } - if (!ReportEventA (hEventSrc, eventType, 0, 0, - cygheap->user.sid (), 1, 0, msg_strings, NULL)) - debug_printf ("ReportEventA failed with %E"); - DeregisterEventSource (hEventSrc); - } -} - -extern "C" void -syslog (int priority, const char *message, ...) -{ - va_list ap; - va_start (ap, message); - vsyslog (priority, message, ap); - va_end (ap); -} - -static NO_COPY muto klog_guard; -fhandler_mailslot *dev_kmsg; - -extern "C" void -vklog (int priority, const char *message, va_list ap) -{ - /* TODO: kernel messages are under our control entirely and they should - be quick. No playing with /dev/null, but a fixed upper size for now. */ - char buf[2060]; /* 2048 + a prority */ - if (!(priority & ~LOG_PRIMASK)) - priority = LOG_KERN | LOG_PRI (priority); - __small_sprintf (buf, "<%d>", priority); - __small_vsprintf (buf + strlen (buf), message, ap); - klog_guard.init ("klog_guard")->acquire (); - if (!dev_kmsg) - dev_kmsg = (fhandler_mailslot *) build_fh_name ("/dev/kmsg"); - if (dev_kmsg && !dev_kmsg->get_handle ()) - dev_kmsg->open (O_WRONLY, 0); - if (dev_kmsg && dev_kmsg->get_handle ()) - dev_kmsg->write (buf, strlen (buf) + 1); - klog_guard.release (); -} - -extern "C" void -klog (int priority, const char *message, ...) -{ - va_list ap; - va_start (ap, message); - vklog (priority, message, ap); - va_end (ap); -} - -extern "C" void -closelog (void) -{ - try_connect_guard.init ("try_connect_guard")->acquire (); - if (syslogd_inited != not_inited && syslogd_sock >= 0) - { - close (syslogd_sock); - syslogd_sock = -1; - syslogd_inited = not_inited; - } - try_connect_guard.release (); -} diff --git a/winsup/cygwin/termios.cc b/winsup/cygwin/termios.cc deleted file mode 100644 index 0aa062300..000000000 --- a/winsup/cygwin/termios.cc +++ /dev/null @@ -1,324 +0,0 @@ -/* termios.cc: termios for WIN32. - - Copyright 1996, 1997, 1998, 2000, 2001, 2002 Red Hat, Inc. - - Written by Doug Evans and Steve Chamberlain of Cygnus Support - dje@cygnus.com, sac@cygnus.com - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "cygwin/version.h" -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "perprocess.h" -#include "cygtls.h" - -/* tcsendbreak: POSIX 7.2.2.1 */ -extern "C" int -tcsendbreak (int fd, int duration) -{ - int res = -1; - - cygheap_fdget cfd (fd); - if (cfd < 0) - goto out; - - if (!cfd->is_tty ()) - set_errno (ENOTTY); - else if ((res = cfd->bg_check (-SIGTTOU)) > bg_eof) - res = cfd->tcsendbreak (duration); - -out: - syscall_printf ("%d = tcsendbreak (%d, %d)", res, fd, duration); - return res; -} - -/* tcdrain: POSIX 7.2.2.1 */ -extern "C" int -tcdrain (int fd) -{ - int res = -1; - - termios_printf ("tcdrain"); - - cygheap_fdget cfd (fd); - if (cfd < 0) - goto out; - - if (!cfd->is_tty ()) - set_errno (ENOTTY); - else if ((res = cfd->bg_check (-SIGTTOU)) > bg_eof) - res = cfd->tcdrain (); - -out: - syscall_printf ("%d = tcdrain (%d)", res, fd); - return res; -} - -/* tcflush: POSIX 7.2.2.1 */ -extern "C" int -tcflush (int fd, int queue) -{ - int res = -1; - - cygheap_fdget cfd (fd); - if (cfd < 0) - goto out; - - if (!cfd->is_tty ()) - set_errno (ENOTTY); - else if (queue != TCIFLUSH && queue != TCOFLUSH && queue != TCIOFLUSH) - set_errno (EINVAL); - else if ((res = cfd->bg_check (-SIGTTOU)) > bg_eof) - res = cfd->tcflush (queue); - -out: - termios_printf ("%d = tcflush (%d, %d)", res, fd, queue); - return res; -} - -/* tcflow: POSIX 7.2.2.1 */ -extern "C" int -tcflow (int fd, int action) -{ - int res = -1; - - cygheap_fdget cfd (fd); - if (cfd < 0) - goto out; - - if (!cfd->is_tty ()) - set_errno (ENOTTY); - else if ((res = cfd->bg_check (-SIGTTOU)) > bg_eof) - res = cfd->tcflow (action); - -out: - syscall_printf ("%d = tcflow (%d, %d)", res, fd, action); - return res; -} - -/* tcsetattr: POSIX96 7.2.1.1 */ -extern "C" int -tcsetattr (int fd, int a, const struct termios *t) -{ - int res; - t = __tonew_termios (t); - int e = get_errno (); - - while (1) - { - res = -1; - cygheap_fdget cfd (fd); - if (cfd < 0) - { - e = get_errno (); - break; - } - - if (!cfd->is_tty ()) - { - e = ENOTTY; - break; - } - - res = cfd->bg_check (-SIGTTOU); - - switch (res) - { - case bg_eof: - e = get_errno (); - break; - case bg_ok: - if (cfd.isopen ()) - res = cfd->tcsetattr (a, t); - e = get_errno (); - break; - case bg_signalled: - if (_my_tls.call_signal_handler ()) - continue; - res = -1; - /* fall through intentionally */ - default: - e = get_errno (); - break; - } - break; - } - - set_errno (e); - termios_printf ("iflag %p, oflag %p, cflag %p, lflag %p, VMIN %d, VTIME %d", - t->c_iflag, t->c_oflag, t->c_cflag, t->c_lflag, t->c_cc[VMIN], - t->c_cc[VTIME]); - termios_printf ("%d = tcsetattr (%d, %d, %x)", res, fd, a, t); - return res; -} - -/* tcgetattr: POSIX 7.2.1.1 */ -extern "C" int -tcgetattr (int fd, struct termios *in_t) -{ - int res = -1; - struct termios *t = __makenew_termios (in_t); - - cygheap_fdget cfd (fd); - if (cfd < 0) - /* saw an error */; - else if (!cfd->is_tty ()) - set_errno (ENOTTY); - else if ((res = cfd->tcgetattr (t)) == 0) - __toapp_termios (in_t, t); - - if (res) - termios_printf ("%d = tcgetattr (%d, %p)", res, fd, in_t); - else - termios_printf ("iflag %x, oflag %x, cflag %x, lflag %x, VMIN %d, VTIME %d", - t->c_iflag, t->c_oflag, t->c_cflag, t->c_lflag, t->c_cc[VMIN], - t->c_cc[VTIME]); - - return res; -} - -/* tcgetpgrp: POSIX 7.2.3.1 */ -extern "C" int -tcgetpgrp (int fd) -{ - int res = -1; - - cygheap_fdget cfd (fd); - if (cfd < 0) - /* saw an error */; - else if (!cfd->is_tty ()) - set_errno (ENOTTY); - else - res = cfd->tcgetpgrp (); - - termios_printf ("%d = tcgetpgrp (%d)", res, fd); - return res; -} - -/* tcsetpgrp: POSIX 7.2.4.1 */ -extern "C" int -tcsetpgrp (int fd, pid_t pgid) -{ - int res = -1; - - cygheap_fdget cfd (fd); - if (cfd < 0) - /* saw an error */; - else if (!cfd->is_tty ()) - set_errno (ENOTTY); - else - res = cfd->tcsetpgrp (pgid); - - termios_printf ("%d = tcsetpgrp (%d, %d)", res, fd, pgid); - return res; -} - -/* NIST PCTS requires not macro-only implementation */ -#undef cfgetospeed -#undef cfgetispeed -#undef cfsetospeed -#undef cfsetispeed - -/* cfgetospeed: POSIX96 7.1.3.1 */ -extern "C" speed_t -cfgetospeed (struct termios *tp) -{ - return __tonew_termios (tp)->c_ospeed; -} - -/* cfgetispeed: POSIX96 7.1.3.1 */ -extern "C" speed_t -cfgetispeed (struct termios *tp) -{ - return __tonew_termios (tp)->c_ispeed; -} - -static inline int -setspeed (speed_t &set_speed, speed_t from_speed) -{ - int res; - switch (from_speed) - { - case B0: - case B50: - case B75: - case B110: - case B134: - case B150: - case B200: - case B300: - case B600: - case B1200: - case B1800: - case B2400: - case B4800: - case B9600: - case B19200: - case B38400: - case B57600: - case B115200: - case B128000: - case B230400: - case B256000: - case B460800: - case B500000: - case B576000: - case B921600: - case B1000000: - case B1152000: - case B1500000: - case B2000000: - case B2500000: - case B3000000: - set_speed = from_speed; - res = 0; - break; - default: - set_errno (EINVAL); - res = -1; - break; - } - return res; -} - -/* cfsetospeed: POSIX96 7.1.3.1 */ -extern "C" int -cfsetospeed (struct termios *in_tp, speed_t speed) -{ - struct termios *tp = __tonew_termios (in_tp); - int res = setspeed (tp->c_ospeed, speed); - __toapp_termios (in_tp, tp); - return res; -} - -/* cfsetispeed: POSIX96 7.1.3.1 */ -extern "C" int -cfsetispeed (struct termios *in_tp, speed_t speed) -{ - struct termios *tp = __tonew_termios (in_tp); - int res = setspeed (tp->c_ispeed, speed); - __toapp_termios (in_tp, tp); - return res; -} - -extern "C" void -cfmakeraw(struct termios *tp) -{ - tp->c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP - | INLCR | IGNCR | ICRNL | IXON); - tp->c_oflag &= ~OPOST; - tp->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); - tp->c_cflag &= ~(CSIZE | PARENB); - tp->c_cflag |= CS8; -} diff --git a/winsup/cygwin/textmode.c b/winsup/cygwin/textmode.c deleted file mode 100644 index 6d52d50f8..000000000 --- a/winsup/cygwin/textmode.c +++ /dev/null @@ -1,21 +0,0 @@ -/* binmode.c - - Copyright 2000 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include -#include -#include - -extern int _fmode; -void -cygwin_premain0 (int argc, char **argv, struct per_process *myself) -{ - _fmode &= ~_O_BINARY; - _fmode |= _O_TEXT; -} diff --git a/winsup/cygwin/textreadmode.c b/winsup/cygwin/textreadmode.c deleted file mode 100644 index a94106d98..000000000 --- a/winsup/cygwin/textreadmode.c +++ /dev/null @@ -1,25 +0,0 @@ -/* textreadmode.c - - Copyright 2004 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include -#include -#include - -extern int _fmode; -void -cygwin_premain0 (int argc, char **argv, struct per_process *myself) -{ - static struct __cygwin_perfile pf[] = - { - {"", O_RDONLY | O_TEXT}, - {NULL, 0} - }; - cygwin_internal (CW_PERFILE, pf); -} diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc deleted file mode 100644 index 53a4f8c31..000000000 --- a/winsup/cygwin/thread.cc +++ /dev/null @@ -1,3288 +0,0 @@ -/* thread.cc: Locking and threading module functions - - Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* Implementation overview and caveats: - - Win32 puts some contraints on what can and cannot be implemented. Where - possible we work around those contrainsts. Where we cannot work around - the constraints we either pretend to be conformant, or return an error - code. - - Some caveats: PROCESS_SHARED objects while they pretend to be process - shared, may not actually work. Some test cases are needed to determine - win32's behaviour. My suspicion is that the win32 handle needs to be - opened with different flags for proper operation. - - R.Collins, April 2001. */ - -#ifdef HAVE_CONFIG_H -#endif - -#include "winsup.h" -#include "miscfuncs.h" -#include "path.h" -#include -#include "pinfo.h" -#include "sigproc.h" -#include "perprocess.h" -#include "cygtls.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" - -extern "C" void __fp_lock_all (); -extern "C" void __fp_unlock_all (); -static inline verifyable_object_state - verifyable_object_isvalid (void const * objectptr, thread_magic_t magic, - void *static_ptr1 = NULL, - void *static_ptr2 = NULL, - void *static_ptr3 = NULL); - -extern int threadsafe; - -#undef __getreent -extern "C" struct _reent * -__getreent () -{ - return &_my_tls.local_clib; -} - -extern "C" void -__cygwin_lock_init (_LOCK_T *lock) -{ - *lock = _LOCK_T_INITIALIZER; -} - -extern "C" void -__cygwin_lock_init_recursive (_LOCK_T *lock) -{ - *lock = _LOCK_T_RECURSIVE_INITIALIZER; -} - -extern "C" void -__cygwin_lock_fini (_LOCK_T *lock) -{ - pthread_mutex_destroy ((pthread_mutex_t*) lock); -} - -extern "C" void -__cygwin_lock_lock (_LOCK_T *lock) -{ - paranoid_printf ("threadcount %d. locking", MT_INTERFACE->threadcount); - pthread_mutex_lock ((pthread_mutex_t*) lock); -} - -extern "C" int -__cygwin_lock_trylock (_LOCK_T *lock) -{ - return pthread_mutex_trylock ((pthread_mutex_t*) lock); -} - - -extern "C" void -__cygwin_lock_unlock (_LOCK_T *lock) -{ - pthread_mutex_unlock ((pthread_mutex_t*) lock); - paranoid_printf ("threadcount %d. unlocked", MT_INTERFACE->threadcount); -} - -static inline verifyable_object_state -verifyable_object_isvalid (void const *objectptr, thread_magic_t magic, void *static_ptr1, - void *static_ptr2, void *static_ptr3) -{ - myfault efault; - /* Check for NULL pointer specifically since it is a cheap test and avoids the - overhead of setting up the fault handler. */ - if (!objectptr || efault.faulted ()) - return INVALID_OBJECT; - - verifyable_object **object = (verifyable_object **) objectptr; - - if ((static_ptr1 && *object == static_ptr1) || - (static_ptr2 && *object == static_ptr2) || - (static_ptr3 && *object == static_ptr3)) - return VALID_STATIC_OBJECT; - if ((*object)->magic != magic) - return INVALID_OBJECT; - return VALID_OBJECT; -} - -/* static members */ -inline bool -pthread_attr::is_good_object (pthread_attr_t const *attr) -{ - if (verifyable_object_isvalid (attr, PTHREAD_ATTR_MAGIC) != VALID_OBJECT) - return false; - return true; -} - -inline bool -pthread_condattr::is_good_object (pthread_condattr_t const *attr) -{ - if (verifyable_object_isvalid (attr, PTHREAD_CONDATTR_MAGIC) != VALID_OBJECT) - return false; - return true; -} - -inline bool -pthread_rwlockattr::is_good_object (pthread_rwlockattr_t const *attr) -{ - if (verifyable_object_isvalid (attr, PTHREAD_RWLOCKATTR_MAGIC) != VALID_OBJECT) - return false; - return true; -} - -inline bool -pthread_key::is_good_object (pthread_key_t const *key) -{ - if (verifyable_object_isvalid (key, PTHREAD_KEY_MAGIC) != VALID_OBJECT) - return false; - return true; -} - -inline bool -pthread_mutex::is_good_object (pthread_mutex_t const *mutex) -{ - if (verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC) != VALID_OBJECT) - return false; - return true; -} - -inline bool -pthread_mutex::is_good_initializer (pthread_mutex_t const *mutex) -{ - if (verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC, - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - PTHREAD_NORMAL_MUTEX_INITIALIZER_NP, - PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP) != VALID_STATIC_OBJECT) - return false; - return true; -} - -inline bool -pthread_mutex::is_good_initializer_or_object (pthread_mutex_t const *mutex) -{ - if (verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC, - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - PTHREAD_NORMAL_MUTEX_INITIALIZER_NP, - PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP) == INVALID_OBJECT) - return false; - return true; -} - -inline bool -pthread_mutex::can_be_unlocked (pthread_mutex_t const *mutex) -{ - pthread_t self = pthread::self (); - - if (!is_good_object (mutex)) - return false; - /* Check if the mutex is owned by the current thread and can be unlocked. - * Also check for the ANONYMOUS owner to cover NORMAL mutexes as well. */ - return (*mutex)->recursion_counter == 1 - && pthread::equal ((*mutex)->owner, self); -} - -inline bool -pthread_mutexattr::is_good_object (pthread_mutexattr_t const * attr) -{ - if (verifyable_object_isvalid (attr, PTHREAD_MUTEXATTR_MAGIC) != VALID_OBJECT) - return false; - return true; -} - -inline bool __attribute__ ((used)) -pthread::is_good_object (pthread_t const *thread) -{ - if (verifyable_object_isvalid (thread, PTHREAD_MAGIC) != VALID_OBJECT) - return false; - return true; -} - -/* Thread synchronisation */ -inline bool -pthread_cond::is_good_object (pthread_cond_t const *cond) -{ - if (verifyable_object_isvalid (cond, PTHREAD_COND_MAGIC) != VALID_OBJECT) - return false; - return true; -} - -inline bool -pthread_cond::is_good_initializer (pthread_cond_t const *cond) -{ - if (verifyable_object_isvalid (cond, PTHREAD_COND_MAGIC, PTHREAD_COND_INITIALIZER) != VALID_STATIC_OBJECT) - return false; - return true; -} - -inline bool -pthread_cond::is_good_initializer_or_object (pthread_cond_t const *cond) -{ - if (verifyable_object_isvalid (cond, PTHREAD_COND_MAGIC, PTHREAD_COND_INITIALIZER) == INVALID_OBJECT) - return false; - return true; -} - -/* RW locks */ -inline bool -pthread_rwlock::is_good_object (pthread_rwlock_t const *rwlock) -{ - if (verifyable_object_isvalid (rwlock, PTHREAD_RWLOCK_MAGIC) != VALID_OBJECT) - return false; - return true; -} - -inline bool -pthread_rwlock::is_good_initializer (pthread_rwlock_t const *rwlock) -{ - if (verifyable_object_isvalid (rwlock, PTHREAD_RWLOCK_MAGIC, PTHREAD_RWLOCK_INITIALIZER) != VALID_STATIC_OBJECT) - return false; - return true; -} - -inline bool -pthread_rwlock::is_good_initializer_or_object (pthread_rwlock_t const *rwlock) -{ - if (verifyable_object_isvalid (rwlock, PTHREAD_RWLOCK_MAGIC, PTHREAD_RWLOCK_INITIALIZER) == INVALID_OBJECT) - return false; - return true; -} - -inline bool -semaphore::is_good_object (sem_t const * sem) -{ - if (verifyable_object_isvalid (sem, SEM_MAGIC) != VALID_OBJECT) - return false; - return true; -} - -void -MTinterface::Init () -{ - pthread_mutex::init_mutex (); - pthread_cond::init_mutex (); - pthread_rwlock::init_mutex (); -} - -void -MTinterface::fixup_before_fork () -{ - pthread_key::fixup_before_fork (); -} - -/* This function is called from a single threaded process */ -void -MTinterface::fixup_after_fork () -{ - pthread_key::fixup_after_fork (); - - threadcount = 0; - pthread::init_mainthread (); - - pthread::fixup_after_fork (); - pthread_mutex::fixup_after_fork (); - pthread_cond::fixup_after_fork (); - pthread_rwlock::fixup_after_fork (); - semaphore::fixup_after_fork (); -} - -/* pthread calls */ - -/* static methods */ -void -pthread::init_mainthread () -{ - pthread *thread = _my_tls.tid; - if (!thread) - { - thread = new pthread (); - if (!thread) - api_fatal ("failed to create mainthread object"); - } - - set_tls_self_pointer (thread); - thread->thread_id = GetCurrentThreadId (); - if (!DuplicateHandle (GetCurrentProcess (), GetCurrentThread (), - GetCurrentProcess (), &thread->win32_obj_id, - 0, FALSE, DUPLICATE_SAME_ACCESS)) - api_fatal ("failed to create mainthread handle"); - if (!thread->create_cancel_event ()) - api_fatal ("couldn't create cancel event for main thread"); - VerifyHandle (thread->win32_obj_id); - thread->postcreate (); -} - -pthread * -pthread::self () -{ - pthread *thread = _my_tls.tid; - if (!thread) - { - thread = pthread_null::get_null_pthread (); - set_tls_self_pointer (thread); - } - return thread; -} - -void -pthread::set_tls_self_pointer (pthread *thread) -{ - thread->cygtls = &_my_tls; - _my_tls.tid = thread; -} - -List pthread::threads; - -/* member methods */ -pthread::pthread ():verifyable_object (PTHREAD_MAGIC), win32_obj_id (0), - valid (false), suspended (false), - cancelstate (0), canceltype (0), cancel_event (0), - joiner (NULL), next (NULL), cleanup_stack (NULL) -{ - if (this != pthread_null::get_null_pthread ()) - threads.insert (this); - parent_tls = &_my_tls; -} - -pthread::~pthread () -{ - if (win32_obj_id) - CloseHandle (win32_obj_id); - if (cancel_event) - CloseHandle (cancel_event); - - if (this != pthread_null::get_null_pthread ()) - threads.remove (this); -} - -bool -pthread::create_cancel_event () -{ - cancel_event = ::CreateEvent (&sec_none_nih, TRUE, FALSE, NULL); - if (!cancel_event) - { - system_printf ("couldn't create cancel event, %E"); - /* we need the event for correct behaviour */ - return false; - } - return true; -} - -void -pthread::precreate (pthread_attr *newattr) -{ - pthread_mutex *verifyable_mutex_obj = &mutex; - - /* already running ? */ - if (win32_obj_id) - return; - - if (newattr) - { - attr.joinable = newattr->joinable; - attr.contentionscope = newattr->contentionscope; - attr.inheritsched = newattr->inheritsched; - attr.stacksize = newattr->stacksize; - } - - if (!pthread_mutex::is_good_object (&verifyable_mutex_obj)) - { - thread_printf ("New thread object access mutex is not valid. this %p", - this); - magic = 0; - return; - } - /* Change the mutex type to NORMAL to speed up mutex operations */ - mutex.type = PTHREAD_MUTEX_NORMAL; - if (!create_cancel_event ()) - magic = 0; -} - -bool -pthread::create (void *(*func) (void *), pthread_attr *newattr, - void *threadarg) -{ - bool retval; - - precreate (newattr); - if (!magic) - return false; - - function = func; - arg = threadarg; - - mutex.lock (); - win32_obj_id = ::CreateThread (&sec_none_nih, attr.stacksize, - thread_init_wrapper, this, 0, &thread_id); - - if (!win32_obj_id) - { - thread_printf ("CreateThread failed: this %p, %E", this); - magic = 0; - } - else - { - postcreate (); - while (!cygtls) - low_priority_sleep (0); - } - retval = magic; - mutex.unlock (); - return retval; -} - -void -pthread::postcreate () -{ - valid = true; - - InterlockedIncrement (&MT_INTERFACE->threadcount); - /* FIXME: set the priority appropriately for system contention scope */ - if (attr.inheritsched == PTHREAD_EXPLICIT_SCHED) - { - /* FIXME: set the scheduling settings for the new thread */ - /* sched_thread_setparam (win32_obj_id, attr.schedparam); */ - } -} - -void -pthread::exit (void *value_ptr) -{ - class pthread *thread = this; - - // run cleanup handlers - pop_all_cleanup_handlers (); - - pthread_key::run_all_destructors (); - - mutex.lock (); - // cleanup if thread is in detached state and not joined - if (equal (joiner, thread)) - delete this; - else - { - valid = false; - return_ptr = value_ptr; - mutex.unlock (); - } - - if (_my_tls.local_clib.__sdidinit < 0) - _my_tls.local_clib.__sdidinit = 0; - (_reclaim_reent) (_REENT); - - if (InterlockedDecrement (&MT_INTERFACE->threadcount) == 0) - ::exit (0); - else - ExitThread (0); -} - -int -pthread::cancel () -{ - class pthread *thread = this; - class pthread *self = pthread::self (); - - mutex.lock (); - - if (!valid) - { - mutex.unlock (); - return 0; - } - - if (canceltype == PTHREAD_CANCEL_DEFERRED || - cancelstate == PTHREAD_CANCEL_DISABLE) - { - // cancel deferred - mutex.unlock (); - SetEvent (cancel_event); - return 0; - } - else if (equal (thread, self)) - { - mutex.unlock (); - cancel_self (); - return 0; // Never reached - } - - // cancel asynchronous - SuspendThread (win32_obj_id); - if (WaitForSingleObject (win32_obj_id, 0) == WAIT_TIMEOUT) - { - CONTEXT context; - context.ContextFlags = CONTEXT_CONTROL; - GetThreadContext (win32_obj_id, &context); - context.Eip = (DWORD) pthread::static_cancel_self; - SetThreadContext (win32_obj_id, &context); - } - mutex.unlock (); - ResumeThread (win32_obj_id); - - return 0; -/* - TODO: insert pthread_testcancel into the required functions - the required function list is: *indicates done, X indicates not present in cygwin. -aio_suspend () -*close () -*creat () -fcntl () -fsync () -getmsg () -getpmsg () -lockf () -mq_receive () -mq_send () -msgrcv () -msgsnd () -msync () -nanosleep () -open () -*pause () -poll () -pread () -*pthread_cond_timedwait () -*pthread_cond_wait () -*pthread_join () -*pthread_testcancel () -putmsg () -putpmsg () -pwrite () -read () -readv () -select () -*sem_wait () -*sigpause () -*sigsuspend () -sigtimedwait () -sigwait () -sigwaitinfo () -*sleep () -*system () -tcdrain () -*usleep () -*wait () -*wait3() -waitid () -*waitpid () -write () -writev () - -the optional list is: -catclose () -catgets () -catopen () -closedir () -closelog () -ctermid () -dbm_close () -dbm_delete () -dbm_fetch () -dbm_nextkey () -dbm_open () -dbm_store () -dlclose () -dlopen () -endgrent () -endpwent () -endutxent () -fclose () -fcntl () -fflush () -fgetc () -fgetpos () -fgets () -fgetwc () -fgetws () -fopen () -fprintf () -fputc () -fputs () -fputwc () -fputws () -fread () -freopen () -fscanf () -fseek () -fseeko () -fsetpos () -ftell () -ftello () -ftw () -fwprintf () -fwrite () -fwscanf () -getc () -getc_unlocked () -getchar () -getchar_unlocked () -getcwd () -getdate () -getgrent () -getgrgid () -getgrgid_r () -getgrnam () -getgrnam_r () -getlogin () -getlogin_r () -getpwent () -*getpwnam () -*getpwnam_r () -*getpwuid () -*getpwuid_r () -gets () -getutxent () -getutxid () -getutxline () -getw () -getwc () -getwchar () -getwd () -glob () -iconv_close () -iconv_open () -ioctl () -lseek () -mkstemp () -nftw () -opendir () -openlog () -pclose () -perror () -popen () -printf () -putc () -putc_unlocked () -putchar () -putchar_unlocked () -puts () -pututxline () -putw () -putwc () -putwchar () -readdir () -readdir_r () -remove () -rename () -rewind () -rewinddir () -scanf () -seekdir () -semop () -setgrent () -setpwent () -setutxent () -strerror () -syslog () -tmpfile () -tmpnam () -ttyname () -ttyname_r () -ungetc () -ungetwc () -unlink () -vfprintf () -vfwprintf () -vprintf () -vwprintf () -wprintf () -wscanf () - -Note, that for fcntl (), for any value of the cmd argument. - -And we must not introduce cancellation points anywhere else that's part of the posix or -opengroup specs. - */ -} - -void -pthread::testcancel () -{ - if (cancelstate == PTHREAD_CANCEL_DISABLE) - return; - - if (WaitForSingleObject (cancel_event, 0) == WAIT_OBJECT_0) - cancel_self (); -} - -void -pthread::static_cancel_self () -{ - pthread::self ()->cancel_self (); -} - -DWORD -cancelable_wait (HANDLE object, DWORD timeout, - const cw_cancel_action cancel_action, - const enum cw_sig_wait sig_wait) -{ - DWORD res; - DWORD num = 0; - HANDLE wait_objects[3]; - pthread_t thread = pthread::self (); - - /* Do not change the wait order. - The object must have higher priority than the cancel event, - because WaitForMultipleObjects will return the smallest index - if both objects are signaled. */ - wait_objects[num++] = object; - DWORD cancel_n; - if (cancel_action == cw_no_cancel || !pthread::is_good_object (&thread) || - thread->cancelstate == PTHREAD_CANCEL_DISABLE) - cancel_n = (DWORD) -1; - else - { - cancel_n = WAIT_OBJECT_0 + num++; - wait_objects[cancel_n] = thread->cancel_event; - } - - DWORD sig_n; - if (sig_wait == cw_sig_nosig || &_my_tls != _main_tls) - sig_n = (DWORD) -1; - else - { - sig_n = WAIT_OBJECT_0 + num++; - wait_objects[sig_n] = signal_arrived; - } - - while (1) - { - res = WaitForMultipleObjects (num, wait_objects, FALSE, timeout); - if (res == cancel_n) - { - if (cancel_action == cw_cancel_self) - pthread::static_cancel_self (); - res = WAIT_CANCELED; - } - else if (res != sig_n) - /* all set */; - else if (sig_wait == cw_sig_eintr) - res = WAIT_SIGNALED; - else - { - _my_tls.call_signal_handler (); - continue; - } - break; - } - return res; -} - -int -pthread::setcancelstate (int state, int *oldstate) -{ - int result = 0; - - mutex.lock (); - - if (state != PTHREAD_CANCEL_ENABLE && state != PTHREAD_CANCEL_DISABLE) - result = EINVAL; - else - { - if (oldstate) - *oldstate = cancelstate; - cancelstate = state; - } - - mutex.unlock (); - - return result; -} - -int -pthread::setcanceltype (int type, int *oldtype) -{ - int result = 0; - - mutex.lock (); - - if (type != PTHREAD_CANCEL_DEFERRED && type != PTHREAD_CANCEL_ASYNCHRONOUS) - result = EINVAL; - else - { - if (oldtype) - *oldtype = canceltype; - canceltype = type; - } - - mutex.unlock (); - - return result; -} - -void -pthread::push_cleanup_handler (__pthread_cleanup_handler *handler) -{ - if (this != self ()) - // TODO: do it? - api_fatal ("Attempt to push a cleanup handler across threads"); - handler->next = cleanup_stack; - cleanup_stack = handler; -} - -void -pthread::pop_cleanup_handler (int const execute) -{ - if (this != self ()) - // TODO: send a signal or something to the thread ? - api_fatal ("Attempt to execute a cleanup handler across threads"); - - mutex.lock (); - - if (cleanup_stack != NULL) - { - __pthread_cleanup_handler *handler = cleanup_stack; - - if (execute) - (*handler->function) (handler->arg); - cleanup_stack = handler->next; - } - - mutex.unlock (); -} - -void -pthread::pop_all_cleanup_handlers () -{ - while (cleanup_stack != NULL) - pop_cleanup_handler (1); -} - -void -pthread::cancel_self () -{ - exit (PTHREAD_CANCELED); -} - -DWORD -pthread::get_thread_id () -{ - return thread_id; -} - -void -pthread::_fixup_after_fork () -{ - /* set thread to not running if it is not the forking thread */ - if (this != pthread::self ()) - { - magic = 0; - valid = false; - win32_obj_id = NULL; - cancel_event = NULL; - } -} - -void -pthread::suspend_except_self () -{ - if (valid && this != pthread::self ()) - SuspendThread (win32_obj_id); -} - -void -pthread::resume () -{ - if (valid) - ResumeThread (win32_obj_id); -} - -/* instance members */ - -pthread_attr::pthread_attr ():verifyable_object (PTHREAD_ATTR_MAGIC), -joinable (PTHREAD_CREATE_JOINABLE), contentionscope (PTHREAD_SCOPE_PROCESS), -inheritsched (PTHREAD_INHERIT_SCHED), stacksize (0) -{ - schedparam.sched_priority = 0; -} - -pthread_attr::~pthread_attr () -{ -} - -pthread_condattr::pthread_condattr ():verifyable_object - (PTHREAD_CONDATTR_MAGIC), shared (PTHREAD_PROCESS_PRIVATE) -{ -} - -pthread_condattr::~pthread_condattr () -{ -} - -List pthread_cond::conds; - -/* This is used for cond creation protection within a single process only */ -fast_mutex NO_COPY pthread_cond::cond_initialization_lock; - -/* We can only be called once. - TODO: (no rush) use a non copied memory section to - hold an initialization flag. */ -void -pthread_cond::init_mutex () -{ - if (!cond_initialization_lock.init ()) - api_fatal ("Could not create win32 Mutex for pthread cond static initializer support."); -} - -pthread_cond::pthread_cond (pthread_condattr *attr) : - verifyable_object (PTHREAD_COND_MAGIC), - shared (0), waiting (0), pending (0), sem_wait (NULL), - mtx_cond(NULL), next (NULL) -{ - pthread_mutex *verifyable_mutex_obj; - - if (attr) - if (attr->shared != PTHREAD_PROCESS_PRIVATE) - { - magic = 0; - return; - } - - verifyable_mutex_obj = &mtx_in; - if (!pthread_mutex::is_good_object (&verifyable_mutex_obj)) - { - thread_printf ("Internal cond mutex is not valid. this %p", this); - magic = 0; - return; - } - /* - * Change the mutex type to NORMAL. - * This mutex MUST be of type normal - */ - mtx_in.type = PTHREAD_MUTEX_NORMAL; - - verifyable_mutex_obj = &mtx_out; - if (!pthread_mutex::is_good_object (&verifyable_mutex_obj)) - { - thread_printf ("Internal cond mutex is not valid. this %p", this); - magic = 0; - return; - } - /* Change the mutex type to NORMAL to speed up mutex operations */ - mtx_out.type = PTHREAD_MUTEX_NORMAL; - - sem_wait = ::CreateSemaphore (&sec_none_nih, 0, LONG_MAX, NULL); - if (!sem_wait) - { - debug_printf ("CreateSemaphore failed. %E"); - magic = 0; - return; - } - - conds.insert (this); -} - -pthread_cond::~pthread_cond () -{ - if (sem_wait) - CloseHandle (sem_wait); - - conds.remove (this); -} - -void -pthread_cond::unblock (const bool all) -{ - unsigned long releaseable; - - /* - * Block outgoing threads (and avoid simultanous unblocks) - */ - mtx_out.lock (); - - releaseable = waiting - pending; - if (releaseable) - { - unsigned long released; - - if (!pending) - { - /* - * Block incoming threads until all waiting threads are released. - */ - mtx_in.lock (); - - /* - * Calculate releaseable again because threads can enter until - * the semaphore has been taken, but they can not leave, therefore pending - * is unchanged and releaseable can only get higher - */ - releaseable = waiting - pending; - } - - released = all ? releaseable : 1; - pending += released; - /* - * Signal threads - */ - ::ReleaseSemaphore (sem_wait, released, NULL); - } - - /* - * And let the threads release. - */ - mtx_out.unlock (); -} - -int -pthread_cond::wait (pthread_mutex_t mutex, DWORD dwMilliseconds) -{ - DWORD rv; - - mtx_in.lock (); - if (InterlockedIncrement ((long *)&waiting) == 1) - mtx_cond = mutex; - else if (mtx_cond != mutex) - { - InterlockedDecrement ((long *)&waiting); - mtx_in.unlock (); - return EINVAL; - } - mtx_in.unlock (); - - /* - * Release the mutex and wait on semaphore - */ - ++mutex->condwaits; - mutex->unlock (); - - rv = cancelable_wait (sem_wait, dwMilliseconds, cw_no_cancel_self, cw_sig_eintr); - - mtx_out.lock (); - - if (rv != WAIT_OBJECT_0) - { - /* - * It might happen that a signal is sent while the thread got canceled - * or timed out. Try to take one. - * If the thread gets one than a signal|broadcast is in progress. - */ - if (WaitForSingleObject (sem_wait, 0) == WAIT_OBJECT_0) - /* - * thread got cancelled ot timed out while a signalling is in progress. - * Set wait result back to signaled - */ - rv = WAIT_OBJECT_0; - } - - InterlockedDecrement ((long *)&waiting); - - if (rv == WAIT_OBJECT_0 && --pending == 0) - /* - * All signaled threads are released, - * new threads can enter Wait - */ - mtx_in.unlock (); - - mtx_out.unlock (); - - mutex->lock (); - --mutex->condwaits; - - if (rv == WAIT_CANCELED) - pthread::static_cancel_self (); - else if (rv == WAIT_SIGNALED) - /* SUSv3 states: If a signal is delivered to a thread waiting for a - condition variable, upon return from the signal handler the thread - resumes waiting for the condition variable as if it was not - interrupted, or it shall return zero due to spurious wakeup. - We opt for the latter choice here. */ - return 0; - else if (rv == WAIT_TIMEOUT) - return ETIMEDOUT; - - return 0; -} - -void -pthread_cond::_fixup_after_fork () -{ - waiting = pending = 0; - mtx_cond = NULL; - - /* Unlock eventually locked mutexes */ - mtx_in.unlock (); - mtx_out.unlock (); - - sem_wait = ::CreateSemaphore (&sec_none_nih, 0, LONG_MAX, NULL); - if (!sem_wait) - api_fatal ("pthread_cond::_fixup_after_fork () failed to recreate win32 semaphore"); -} - -pthread_rwlockattr::pthread_rwlockattr ():verifyable_object - (PTHREAD_RWLOCKATTR_MAGIC), shared (PTHREAD_PROCESS_PRIVATE) -{ -} - -pthread_rwlockattr::~pthread_rwlockattr () -{ -} - -List pthread_rwlock::rwlocks; - -/* This is used for rwlock creation protection within a single process only */ -fast_mutex NO_COPY pthread_rwlock::rwlock_initialization_lock; - -/* We can only be called once. - TODO: (no rush) use a non copied memory section to - hold an initialization flag. */ -void -pthread_rwlock::init_mutex () -{ - if (!rwlock_initialization_lock.init ()) - api_fatal ("Could not create win32 Mutex for pthread rwlock static initializer support."); -} - -pthread_rwlock::pthread_rwlock (pthread_rwlockattr *attr) : - verifyable_object (PTHREAD_RWLOCK_MAGIC), - shared (0), waiting_readers (0), waiting_writers (0), writer (NULL), - readers (NULL), readers_mx (), mtx (NULL), cond_readers (NULL), cond_writers (NULL), - next (NULL) -{ - pthread_mutex *verifyable_mutex_obj = &mtx; - pthread_cond *verifyable_cond_obj; - - if (!readers_mx.init ()) - { - thread_printf ("Internal rwlock synchronisation mutex is not valid. this %p", this); - magic = 0; - return; - } - - if (attr) - if (attr->shared != PTHREAD_PROCESS_PRIVATE) - { - magic = 0; - return; - } - - if (!pthread_mutex::is_good_object (&verifyable_mutex_obj)) - { - thread_printf ("Internal rwlock mutex is not valid. this %p", this); - magic = 0; - return; - } - /* Change the mutex type to NORMAL to speed up mutex operations */ - mtx.type = PTHREAD_MUTEX_NORMAL; - - verifyable_cond_obj = &cond_readers; - if (!pthread_cond::is_good_object (&verifyable_cond_obj)) - { - thread_printf ("Internal rwlock readers cond is not valid. this %p", this); - magic = 0; - return; - } - - verifyable_cond_obj = &cond_writers; - if (!pthread_cond::is_good_object (&verifyable_cond_obj)) - { - thread_printf ("Internal rwlock writers cond is not valid. this %p", this); - magic = 0; - return; - } - - - rwlocks.insert (this); -} - -pthread_rwlock::~pthread_rwlock () -{ - rwlocks.remove (this); -} - -int -pthread_rwlock::rdlock () -{ - int result = 0; - struct RWLOCK_READER *reader; - pthread_t self = pthread::self (); - - mtx.lock (); - - reader = lookup_reader (self); - if (reader) - { - if (reader->n < ULONG_MAX) - ++reader->n; - else - errno = EAGAIN; - goto DONE; - } - - reader = new struct RWLOCK_READER; - if (!reader) - { - result = EAGAIN; - goto DONE; - } - - while (writer || waiting_writers) - { - pthread_cleanup_push (pthread_rwlock::rdlock_cleanup, this); - - ++waiting_readers; - cond_readers.wait (&mtx); - --waiting_readers; - - pthread_cleanup_pop (0); - } - - reader->thread = self; - reader->n = 1; - add_reader (reader); - - DONE: - mtx.unlock (); - - return result; -} - -int -pthread_rwlock::tryrdlock () -{ - int result = 0; - pthread_t self = pthread::self (); - - mtx.lock (); - - if (writer || waiting_writers || lookup_reader (self)) - result = EBUSY; - else - { - struct RWLOCK_READER *reader; - - reader = lookup_reader (self); - if (reader && reader->n < ULONG_MAX) - ++reader->n; - else if ((reader = new struct RWLOCK_READER)) - { - reader->thread = self; - reader->n = 1; - add_reader (reader); - } - else - result = EAGAIN; - } - - mtx.unlock (); - - return result; -} - -int -pthread_rwlock::wrlock () -{ - int result = 0; - pthread_t self = pthread::self (); - - mtx.lock (); - - if (writer == self || lookup_reader (self)) - { - result = EDEADLK; - goto DONE; - } - - while (writer || readers) - { - pthread_cleanup_push (pthread_rwlock::wrlock_cleanup, this); - - ++waiting_writers; - cond_writers.wait (&mtx); - --waiting_writers; - - pthread_cleanup_pop (0); - } - - writer = self; - - DONE: - mtx.unlock (); - - return result; -} - -int -pthread_rwlock::trywrlock () -{ - int result = 0; - pthread_t self = pthread::self (); - - mtx.lock (); - - if (writer || readers) - result = EBUSY; - else - writer = self; - - mtx.unlock (); - - return result; -} - -int -pthread_rwlock::unlock () -{ - int result = 0; - pthread_t self = pthread::self (); - - mtx.lock (); - - if (writer) - { - if (writer != self) - { - result = EPERM; - goto DONE; - } - - writer = NULL; - } - else - { - struct RWLOCK_READER *reader = lookup_reader (self); - - if (!reader) - { - result = EPERM; - goto DONE; - } - if (--reader->n > 0) - goto DONE; - - remove_reader (reader); - delete reader; - } - - release (); - - DONE: - mtx.unlock (); - - return result; -} - -void -pthread_rwlock::add_reader (struct RWLOCK_READER *rd) -{ - List_insert (readers, rd); -} - -void -pthread_rwlock::remove_reader (struct RWLOCK_READER *rd) -{ - List_remove (readers_mx, readers, rd); -} - -struct pthread_rwlock::RWLOCK_READER * -pthread_rwlock::lookup_reader (pthread_t thread) -{ - readers_mx.lock (); - - struct RWLOCK_READER *cur = readers; - - while (cur && cur->thread != thread) - cur = cur->next; - - readers_mx.unlock (); - - return cur; -} - -void -pthread_rwlock::rdlock_cleanup (void *arg) -{ - pthread_rwlock *rwlock = (pthread_rwlock *) arg; - - --(rwlock->waiting_readers); - rwlock->release (); - rwlock->mtx.unlock (); -} - -void -pthread_rwlock::wrlock_cleanup (void *arg) -{ - pthread_rwlock *rwlock = (pthread_rwlock *) arg; - - --(rwlock->waiting_writers); - rwlock->release (); - rwlock->mtx.unlock (); -} - -void -pthread_rwlock::_fixup_after_fork () -{ - pthread_t self = pthread::self (); - struct RWLOCK_READER **temp = &readers; - - waiting_readers = 0; - waiting_writers = 0; - - if (!readers_mx.init ()) - api_fatal ("pthread_rwlock::_fixup_after_fork () failed to recreate mutex"); - - /* Unlock eventually locked mutex */ - mtx.unlock (); - /* - * Remove all readers except self - */ - while (*temp) - { - if ((*temp)->thread == self) - temp = &((*temp)->next); - else - { - struct RWLOCK_READER *cur = *temp; - *temp = (*temp)->next; - delete cur; - } - } -} - -/* pthread_key */ -/* static members */ -/* This stores pthread_key information across fork() boundaries */ -List pthread_key::keys; - -/* non-static members */ - -pthread_key::pthread_key (void (*aDestructor) (void *)):verifyable_object (PTHREAD_KEY_MAGIC), destructor (aDestructor) -{ - tls_index = TlsAlloc (); - if (tls_index == TLS_OUT_OF_INDEXES) - magic = 0; - else - keys.insert (this); -} - -pthread_key::~pthread_key () -{ - /* We may need to make the list code lock the list during operations - */ - if (magic != 0) - { - keys.remove (this); - TlsFree (tls_index); - } -} - -void -pthread_key::_fixup_before_fork () -{ - fork_buf = get (); -} - -void -pthread_key::_fixup_after_fork () -{ - tls_index = TlsAlloc (); - if (tls_index == TLS_OUT_OF_INDEXES) - api_fatal ("pthread_key::recreate_key_from_buffer () failed to reallocate Tls storage"); - set (fork_buf); -} - -void -pthread_key::run_destructor () -{ - if (destructor) - { - void *oldValue = get (); - if (oldValue) - { - set (NULL); - destructor (oldValue); - } - } -} - -/* pshared mutexs */ - -/* static members */ - -List pthread_mutex::mutexes; - -/* This is used for mutex creation protection within a single process only */ -fast_mutex NO_COPY pthread_mutex::mutex_initialization_lock; - -void -pthread_mutex::init_mutex () -{ - if (!mutex_initialization_lock.init ()) - api_fatal ("Could not create win32 Mutex for pthread mutex static initializer support."); -} - -pthread_mutex::pthread_mutex (pthread_mutexattr *attr) : - verifyable_object (0), /* set magic to zero initially */ - lock_counter (0), - win32_obj_id (NULL), recursion_counter (0), - condwaits (0), owner (NULL), -#ifdef DEBUGGING - tid (0), -#endif - type (PTHREAD_MUTEX_ERRORCHECK), - pshared (PTHREAD_PROCESS_PRIVATE) -{ - win32_obj_id = ::CreateEvent (&sec_none_nih, false, false, NULL); - if (!win32_obj_id) - return; - /*attr checked in the C call */ - if (!attr) - /* handled in the caller */; - else if (attr->pshared != PTHREAD_PROCESS_SHARED) - type = attr->mutextype; - else - return; /* Not implemented */ - - magic = PTHREAD_MUTEX_MAGIC; - mutexes.insert (this); -} - -pthread_mutex::~pthread_mutex () -{ - if (win32_obj_id) - CloseHandle (win32_obj_id); - - mutexes.remove (this); -} - -int -pthread_mutex::lock () -{ - pthread_t self = ::pthread_self (); - int result = 0; - - if (InterlockedIncrement ((long *)&lock_counter) == 1) - set_owner (self); - else if (type == PTHREAD_MUTEX_NORMAL || !pthread::equal (owner, self)) - { - cancelable_wait (win32_obj_id, INFINITE, cw_no_cancel, cw_sig_resume); - set_owner (self); - } - else - { - InterlockedDecrement ((long *) &lock_counter); - if (type == PTHREAD_MUTEX_RECURSIVE) - result = lock_recursive (); - else - result = EDEADLK; - } - - return result; -} - -int -pthread_mutex::unlock () -{ - pthread_t self = ::pthread_self (); - if (!pthread::equal (owner, self)) - return EPERM; - - /* Don't try to unlock anything if recursion_counter == 0 initially. - That means that we've forked. */ - if (recursion_counter > 0 && --recursion_counter == 0) - { - owner = NULL; -#ifdef DEBUGGING - tid = 0; -#endif - if (InterlockedDecrement ((long *) &lock_counter)) - ::SetEvent (win32_obj_id); // Another thread is waiting - } - - return 0; -} - -int -pthread_mutex::trylock () -{ - pthread_t self = ::pthread_self (); - int result = 0; - - if (InterlockedCompareExchange ((long *) &lock_counter, 1, 0) == 0) - set_owner (self); - else if (type == PTHREAD_MUTEX_RECURSIVE && pthread::equal (owner, self)) - result = lock_recursive (); - else - result = EBUSY; - - return result; -} - -int -pthread_mutex::destroy () -{ - if (condwaits || trylock ()) - // Do not destroy a condwaited or locked mutex - return EBUSY; - else if (recursion_counter > 1) - { - // Do not destroy a recursive locked mutex - recursion_counter--; - return EBUSY; - } - - delete this; - return 0; -} - -void -pthread_mutex::_fixup_after_fork () -{ - debug_printf ("mutex %p in _fixup_after_fork", this); - if (pshared != PTHREAD_PROCESS_PRIVATE) - api_fatal ("pthread_mutex::_fixup_after_fork () doesn't understand PROCESS_SHARED mutex's"); - - /* All waiting threads are gone after a fork */ - recursion_counter = 0; - lock_counter = 0; - condwaits = 0; -#ifdef DEBUGGING - tid = 0xffffffff; /* Don't know the tid after a fork */ -#endif - win32_obj_id = ::CreateEvent (&sec_none_nih, false, false, NULL); - if (!win32_obj_id) - api_fatal ("pthread_mutex::_fixup_after_fork () failed to recreate win32 semaphore for mutex"); -} - -pthread_mutexattr::pthread_mutexattr ():verifyable_object (PTHREAD_MUTEXATTR_MAGIC), -pshared (PTHREAD_PROCESS_PRIVATE), mutextype (PTHREAD_MUTEX_ERRORCHECK) -{ -} - -pthread_mutexattr::~pthread_mutexattr () -{ -} - -DWORD WINAPI -pthread::thread_init_wrapper (void *arg) -{ - pthread *thread = (pthread *) arg; - set_tls_self_pointer (thread); - - thread->mutex.lock (); - - // if thread is detached force cleanup on exit - if (thread->attr.joinable == PTHREAD_CREATE_DETACHED && thread->joiner == NULL) - thread->joiner = thread; - _my_tls.sigmask = thread->parent_tls->sigmask; - thread->mutex.unlock (); - - thread_printf ("started thread %p %p %p %p %p %p", arg, &_my_tls.local_clib, - _impure_ptr, thread, thread->function, thread->arg); - - // call the user's thread - void *ret = thread->function (thread->arg); - - thread->exit (ret); - - return 0; // just for show. Never returns. -} - -unsigned long -pthread::getsequence_np () -{ - return get_thread_id (); -} - -int -pthread::create (pthread_t *thread, const pthread_attr_t *attr, - void *(*start_routine) (void *), void *arg) -{ - if (attr && !pthread_attr::is_good_object (attr)) - return EINVAL; - - *thread = new pthread (); - if (!(*thread)->create (start_routine, attr ? *attr : NULL, arg)) - { - delete (*thread); - *thread = NULL; - return EAGAIN; - } - - return 0; -} - -int -pthread::once (pthread_once_t *once_control, void (*init_routine) (void)) -{ - // already done ? - if (once_control->state) - return 0; - - pthread_mutex_lock (&once_control->mutex); - /* Here we must set a cancellation handler to unlock the mutex if needed */ - /* but a cancellation handler is not the right thing. We need this in the thread - *cleanup routine. Assumption: a thread can only be in one pthread_once routine - *at a time. Stote a mutex_t *in the pthread_structure. if that's non null unlock - *on pthread_exit (); - */ - if (!once_control->state) - { - init_routine (); - once_control->state = 1; - } - /* Here we must remove our cancellation handler */ - pthread_mutex_unlock (&once_control->mutex); - return 0; -} - -int -pthread::cancel (pthread_t thread) -{ - if (!is_good_object (&thread)) - return ESRCH; - - return thread->cancel (); -} - -void -pthread::atforkprepare () -{ - callback *cb = MT_INTERFACE->pthread_prepare; - while (cb) - { - cb->cb (); - cb = cb->next; - } - - __fp_lock_all (); - - MT_INTERFACE->fixup_before_fork (); -} - -void -pthread::atforkparent () -{ - __fp_unlock_all (); - - callback *cb = MT_INTERFACE->pthread_parent; - while (cb) - { - cb->cb (); - cb = cb->next; - } -} - -void -pthread::atforkchild () -{ - MT_INTERFACE->fixup_after_fork (); - - __fp_unlock_all (); - - callback *cb = MT_INTERFACE->pthread_child; - while (cb) - { - cb->cb (); - cb = cb->next; - } -} - -/* Register a set of functions to run before and after fork. - prepare calls are called in LI-FC order. - parent and child calls are called in FI-FC order. */ -int -pthread::atfork (void (*prepare)(void), void (*parent)(void), void (*child)(void)) -{ - callback *prepcb = NULL, *parentcb = NULL, *childcb = NULL; - if (prepare) - { - prepcb = new callback; - if (!prepcb) - return ENOMEM; - } - if (parent) - { - parentcb = new callback; - if (!parentcb) - { - if (prepcb) - delete prepcb; - return ENOMEM; - } - } - if (child) - { - childcb = new callback; - if (!childcb) - { - if (prepcb) - delete prepcb; - if (parentcb) - delete parentcb; - return ENOMEM; - } - } - - if (prepcb) - { - prepcb->cb = prepare; - List_insert (MT_INTERFACE->pthread_prepare, prepcb); - } - if (parentcb) - { - parentcb->cb = parent; - callback **t = &MT_INTERFACE->pthread_parent; - while (*t) - t = &(*t)->next; - /* t = pointer to last next in the list */ - List_insert (*t, parentcb); - } - if (childcb) - { - childcb->cb = child; - callback **t = &MT_INTERFACE->pthread_child; - while (*t) - t = &(*t)->next; - /* t = pointer to last next in the list */ - List_insert (*t, childcb); - } - return 0; -} - -extern "C" int -pthread_attr_init (pthread_attr_t *attr) -{ - if (pthread_attr::is_good_object (attr)) - return EBUSY; - - *attr = new pthread_attr; - if (!pthread_attr::is_good_object (attr)) - { - delete (*attr); - *attr = NULL; - return ENOMEM; - } - return 0; -} - -extern "C" int -pthread_attr_getinheritsched (const pthread_attr_t *attr, - int *inheritsched) -{ - if (!pthread_attr::is_good_object (attr)) - return EINVAL; - *inheritsched = (*attr)->inheritsched; - return 0; -} - -extern "C" int -pthread_attr_getschedparam (const pthread_attr_t *attr, - struct sched_param *param) -{ - if (!pthread_attr::is_good_object (attr)) - return EINVAL; - *param = (*attr)->schedparam; - return 0; -} - -/* From a pure code point of view, this should call a helper in sched.cc, - to allow for someone adding scheduler policy changes to win32 in the future. - However that's extremely unlikely, so short and sweet will do us */ -extern "C" int -pthread_attr_getschedpolicy (const pthread_attr_t *attr, int *policy) -{ - if (!pthread_attr::is_good_object (attr)) - return EINVAL; - *policy = SCHED_FIFO; - return 0; -} - - -extern "C" int -pthread_attr_getscope (const pthread_attr_t *attr, int *contentionscope) -{ - if (!pthread_attr::is_good_object (attr)) - return EINVAL; - *contentionscope = (*attr)->contentionscope; - return 0; -} - -extern "C" int -pthread_attr_setdetachstate (pthread_attr_t *attr, int detachstate) -{ - if (!pthread_attr::is_good_object (attr)) - return EINVAL; - if (detachstate < 0 || detachstate > 1) - return EINVAL; - (*attr)->joinable = detachstate; - return 0; -} - -extern "C" int -pthread_attr_getdetachstate (const pthread_attr_t *attr, int *detachstate) -{ - if (!pthread_attr::is_good_object (attr)) - return EINVAL; - *detachstate = (*attr)->joinable; - return 0; -} - -extern "C" int -pthread_attr_setinheritsched (pthread_attr_t *attr, int inheritsched) -{ - if (!pthread_attr::is_good_object (attr)) - return EINVAL; - if (inheritsched != PTHREAD_INHERIT_SCHED - && inheritsched != PTHREAD_EXPLICIT_SCHED) - return ENOTSUP; - (*attr)->inheritsched = inheritsched; - return 0; -} - -extern "C" int -pthread_attr_setschedparam (pthread_attr_t *attr, - const struct sched_param *param) -{ - if (!pthread_attr::is_good_object (attr)) - return EINVAL; - if (!valid_sched_parameters (param)) - return ENOTSUP; - (*attr)->schedparam = *param; - return 0; -} - -/* See __pthread_attr_getschedpolicy for some notes */ -extern "C" int -pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy) -{ - if (!pthread_attr::is_good_object (attr)) - return EINVAL; - if (policy != SCHED_FIFO) - return ENOTSUP; - return 0; -} - -extern "C" int -pthread_attr_setscope (pthread_attr_t *attr, int contentionscope) -{ - if (!pthread_attr::is_good_object (attr)) - return EINVAL; - if (contentionscope != PTHREAD_SCOPE_SYSTEM - && contentionscope != PTHREAD_SCOPE_PROCESS) - return EINVAL; - /* In future, we may be able to support system scope by escalating the thread - priority to exceed the priority class. For now we only support PROCESS scope. */ - if (contentionscope != PTHREAD_SCOPE_PROCESS) - return ENOTSUP; - (*attr)->contentionscope = contentionscope; - return 0; -} - -extern "C" int -pthread_attr_setstacksize (pthread_attr_t *attr, size_t size) -{ - if (!pthread_attr::is_good_object (attr)) - return EINVAL; - (*attr)->stacksize = size; - return 0; -} - -extern "C" int -pthread_attr_getstacksize (const pthread_attr_t *attr, size_t *size) -{ - if (!pthread_attr::is_good_object (attr)) - return EINVAL; - *size = (*attr)->stacksize; - return 0; -} - -extern "C" int -pthread_attr_destroy (pthread_attr_t *attr) -{ - if (!pthread_attr::is_good_object (attr)) - return EINVAL; - delete (*attr); - *attr = NULL; - return 0; -} - -int -pthread::join (pthread_t *thread, void **return_val) -{ - pthread_t joiner = self (); - - joiner->testcancel (); - - // Initialize return val with NULL - if (return_val) - *return_val = NULL; - - if (!is_good_object (&joiner)) - return EINVAL; - - if (!is_good_object (thread)) - return ESRCH; - - if (equal (*thread,joiner)) - return EDEADLK; - - (*thread)->mutex.lock (); - - if ((*thread)->attr.joinable == PTHREAD_CREATE_DETACHED) - { - (*thread)->mutex.unlock (); - return EINVAL; - } - else - { - (*thread)->joiner = joiner; - (*thread)->attr.joinable = PTHREAD_CREATE_DETACHED; - (*thread)->mutex.unlock (); - - switch (cancelable_wait ((*thread)->win32_obj_id, INFINITE, cw_no_cancel_self, cw_sig_resume)) - { - case WAIT_OBJECT_0: - if (return_val) - *return_val = (*thread)->return_ptr; - delete (*thread); - break; - case WAIT_CANCELED: - // set joined thread back to joinable since we got canceled - (*thread)->joiner = NULL; - (*thread)->attr.joinable = PTHREAD_CREATE_JOINABLE; - joiner->cancel_self (); - // never reached - break; - default: - // should never happen - return EINVAL; - } - } - - return 0; -} - -int -pthread::detach (pthread_t *thread) -{ - if (!is_good_object (thread)) - return ESRCH; - - (*thread)->mutex.lock (); - if ((*thread)->attr.joinable == PTHREAD_CREATE_DETACHED) - { - (*thread)->mutex.unlock (); - return EINVAL; - } - - // check if thread is still alive - if ((*thread)->valid && WaitForSingleObject ((*thread)->win32_obj_id, 0) == WAIT_TIMEOUT) - { - // force cleanup on exit - (*thread)->joiner = *thread; - (*thread)->attr.joinable = PTHREAD_CREATE_DETACHED; - (*thread)->mutex.unlock (); - } - else - { - // thread has already terminated. - (*thread)->mutex.unlock (); - delete (*thread); - } - - return 0; -} - -int -pthread::suspend (pthread_t *thread) -{ - if (!is_good_object (thread)) - return ESRCH; - - if ((*thread)->suspended == false) - { - (*thread)->suspended = true; - SuspendThread ((*thread)->win32_obj_id); - } - - return 0; -} - - -int -pthread::resume (pthread_t *thread) -{ - if (!is_good_object (thread)) - return ESRCH; - - if ((*thread)->suspended == true) - ResumeThread ((*thread)->win32_obj_id); - (*thread)->suspended = false; - - return 0; -} - -/* provided for source level compatability. - See http://www.opengroup.org/onlinepubs/007908799/xsh/pthread_getconcurrency.html -*/ -extern "C" int -pthread_getconcurrency () -{ - return MT_INTERFACE->concurrency; -} - -/* keep this in sync with sched.cc */ -extern "C" int -pthread_getschedparam (pthread_t thread, int *policy, - struct sched_param *param) -{ - if (!pthread::is_good_object (&thread)) - return ESRCH; - *policy = SCHED_FIFO; - /* we don't return the current effective priority, we return the current - requested priority */ - *param = thread->attr.schedparam; - return 0; -} - -/* Thread Specific Data */ -extern "C" int -pthread_key_create (pthread_key_t *key, void (*destructor) (void *)) -{ - *key = new pthread_key (destructor); - - if (!pthread_key::is_good_object (key)) - { - delete (*key); - *key = NULL; - return EAGAIN; - } - return 0; -} - -extern "C" int -pthread_key_delete (pthread_key_t key) -{ - if (!pthread_key::is_good_object (&key)) - return EINVAL; - - delete (key); - return 0; -} - -/* provided for source level compatability. See -http://www.opengroup.org/onlinepubs/007908799/xsh/pthread_getconcurrency.html -*/ -extern "C" int -pthread_setconcurrency (int new_level) -{ - if (new_level < 0) - return EINVAL; - MT_INTERFACE->concurrency = new_level; - return 0; -} - -/* keep syncronised with sched.cc */ -extern "C" int -pthread_setschedparam (pthread_t thread, int policy, - const struct sched_param *param) -{ - if (!pthread::is_good_object (&thread)) - return ESRCH; - if (policy != SCHED_FIFO) - return ENOTSUP; - if (!param) - return EINVAL; - int rv = - sched_set_thread_priority (thread->win32_obj_id, param->sched_priority); - if (!rv) - thread->attr.schedparam.sched_priority = param->sched_priority; - return rv; -} - - -extern "C" int -pthread_setspecific (pthread_key_t key, const void *value) -{ - if (!pthread_key::is_good_object (&key)) - return EINVAL; - (key)->set (value); - return 0; -} - -extern "C" void * -pthread_getspecific (pthread_key_t key) -{ - if (!pthread_key::is_good_object (&key)) - return NULL; - - return (key)->get (); - -} - -extern "C" int -pthread_cond_destroy (pthread_cond_t *cond) -{ - if (pthread_cond::is_good_initializer (cond)) - return 0; - if (!pthread_cond::is_good_object (cond)) - return EINVAL; - - /* reads are atomic */ - if ((*cond)->waiting) - return EBUSY; - - delete (*cond); - *cond = NULL; - - return 0; -} - -int -pthread_cond::init (pthread_cond_t *cond, const pthread_condattr_t *attr) -{ - pthread_cond_t new_cond; - - if (attr && !pthread_condattr::is_good_object (attr)) - return EINVAL; - - cond_initialization_lock.lock (); - - new_cond = new pthread_cond (attr ? (*attr) : NULL); - if (!is_good_object (&new_cond)) - { - delete new_cond; - cond_initialization_lock.unlock (); - return EAGAIN; - } - - myfault efault; - if (efault.faulted ()) - { - delete new_cond; - cond_initialization_lock.unlock (); - return EINVAL; - } - - *cond = new_cond; - cond_initialization_lock.unlock (); - - return 0; -} - -extern "C" int -pthread_cond_broadcast (pthread_cond_t *cond) -{ - if (pthread_cond::is_good_initializer (cond)) - return 0; - if (!pthread_cond::is_good_object (cond)) - return EINVAL; - - (*cond)->unblock (true); - - return 0; -} - -extern "C" int -pthread_cond_signal (pthread_cond_t *cond) -{ - if (pthread_cond::is_good_initializer (cond)) - return 0; - if (!pthread_cond::is_good_object (cond)) - return EINVAL; - - (*cond)->unblock (false); - - return 0; -} - -static int -__pthread_cond_dowait (pthread_cond_t *cond, pthread_mutex_t *mutex, - DWORD waitlength) -{ - if (!pthread_mutex::is_good_object (mutex)) - return EINVAL; - if (!pthread_mutex::can_be_unlocked (mutex)) - return EPERM; - - if (pthread_cond::is_good_initializer (cond)) - pthread_cond::init (cond, NULL); - if (!pthread_cond::is_good_object (cond)) - return EINVAL; - - return (*cond)->wait (*mutex, waitlength); -} - -extern "C" int -pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex, - const struct timespec *abstime) -{ - struct timeval tv; - DWORD waitlength; - - myfault efault; - if (efault.faulted ()) - return EINVAL; - - pthread_testcancel (); - - /* According to SUSv3, the abstime value must be checked for validity. */ - if (abstime->tv_sec < 0 - || abstime->tv_nsec < 0 - || abstime->tv_nsec > 999999999) - return EINVAL; - - gettimeofday (&tv, NULL); - /* Check for immediate timeout before converting to microseconds, since - the resulting value can easily overflow long. This also allows to - evaluate microseconds directly in DWORD. */ - if (tv.tv_sec > abstime->tv_sec - || (tv.tv_sec == abstime->tv_sec - && tv.tv_usec > abstime->tv_nsec / 1000)) - return ETIMEDOUT; - - waitlength = (abstime->tv_sec - tv.tv_sec) * 1000; - waitlength += (abstime->tv_nsec / 1000 - tv.tv_usec) / 1000; - return __pthread_cond_dowait (cond, mutex, waitlength); -} - -extern "C" int -pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex) -{ - pthread_testcancel (); - - return __pthread_cond_dowait (cond, mutex, INFINITE); -} - -extern "C" int -pthread_condattr_init (pthread_condattr_t *condattr) -{ - if (pthread_condattr::is_good_object (condattr)) - return EBUSY; - - *condattr = new pthread_condattr; - if (!pthread_condattr::is_good_object (condattr)) - { - delete (*condattr); - *condattr = NULL; - return ENOMEM; - } - return 0; -} - -extern "C" int -pthread_condattr_getpshared (const pthread_condattr_t *attr, int *pshared) -{ - if (!pthread_condattr::is_good_object (attr)) - return EINVAL; - *pshared = (*attr)->shared; - return 0; -} - -extern "C" int -pthread_condattr_setpshared (pthread_condattr_t *attr, int pshared) -{ - if (!pthread_condattr::is_good_object (attr)) - return EINVAL; - if ((pshared < 0) || (pshared > 1)) - return EINVAL; - /* shared cond vars not currently supported */ - if (pshared != PTHREAD_PROCESS_PRIVATE) - return EINVAL; - (*attr)->shared = pshared; - return 0; -} - -extern "C" int -pthread_condattr_destroy (pthread_condattr_t *condattr) -{ - if (!pthread_condattr::is_good_object (condattr)) - return EINVAL; - delete (*condattr); - *condattr = NULL; - return 0; -} - -extern "C" int -pthread_rwlock_destroy (pthread_rwlock_t *rwlock) -{ - if (pthread_rwlock::is_good_initializer (rwlock)) - return 0; - if (!pthread_rwlock::is_good_object (rwlock)) - return EINVAL; - - if ((*rwlock)->writer || (*rwlock)->readers || - (*rwlock)->waiting_readers || (*rwlock)->waiting_writers) - return EBUSY; - - delete (*rwlock); - *rwlock = NULL; - - return 0; -} - -int -pthread_rwlock::init (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) -{ - pthread_rwlock_t new_rwlock; - - if (attr && !pthread_rwlockattr::is_good_object (attr)) - return EINVAL; - - rwlock_initialization_lock.lock (); - - new_rwlock = new pthread_rwlock (attr ? (*attr) : NULL); - if (!is_good_object (&new_rwlock)) - { - delete new_rwlock; - rwlock_initialization_lock.unlock (); - return EAGAIN; - } - - myfault efault; - if (efault.faulted ()) - { - delete new_rwlock; - rwlock_initialization_lock.unlock (); - return EINVAL; - } - - *rwlock = new_rwlock; - rwlock_initialization_lock.unlock (); - - return 0; -} - -extern "C" int -pthread_rwlock_rdlock (pthread_rwlock_t *rwlock) -{ - pthread_testcancel (); - - if (pthread_rwlock::is_good_initializer (rwlock)) - pthread_rwlock::init (rwlock, NULL); - if (!pthread_rwlock::is_good_object (rwlock)) - return EINVAL; - - return (*rwlock)->rdlock (); -} - -extern "C" int -pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock) -{ - if (pthread_rwlock::is_good_initializer (rwlock)) - pthread_rwlock::init (rwlock, NULL); - if (!pthread_rwlock::is_good_object (rwlock)) - return EINVAL; - - return (*rwlock)->tryrdlock (); -} - -extern "C" int -pthread_rwlock_wrlock (pthread_rwlock_t *rwlock) -{ - pthread_testcancel (); - - if (pthread_rwlock::is_good_initializer (rwlock)) - pthread_rwlock::init (rwlock, NULL); - if (!pthread_rwlock::is_good_object (rwlock)) - return EINVAL; - - return (*rwlock)->wrlock (); -} - -extern "C" int -pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock) -{ - if (pthread_rwlock::is_good_initializer (rwlock)) - pthread_rwlock::init (rwlock, NULL); - if (!pthread_rwlock::is_good_object (rwlock)) - return EINVAL; - - return (*rwlock)->trywrlock (); -} - -extern "C" int -pthread_rwlock_unlock (pthread_rwlock_t *rwlock) -{ - if (pthread_rwlock::is_good_initializer (rwlock)) - return 0; - if (!pthread_rwlock::is_good_object (rwlock)) - return EINVAL; - - return (*rwlock)->unlock (); -} - -extern "C" int -pthread_rwlockattr_init (pthread_rwlockattr_t *rwlockattr) -{ - if (pthread_rwlockattr::is_good_object (rwlockattr)) - return EBUSY; - - *rwlockattr = new pthread_rwlockattr; - if (!pthread_rwlockattr::is_good_object (rwlockattr)) - { - delete (*rwlockattr); - *rwlockattr = NULL; - return ENOMEM; - } - return 0; -} - -extern "C" int -pthread_rwlockattr_getpshared (const pthread_rwlockattr_t *attr, int *pshared) -{ - if (!pthread_rwlockattr::is_good_object (attr)) - return EINVAL; - *pshared = (*attr)->shared; - return 0; -} - -extern "C" int -pthread_rwlockattr_setpshared (pthread_rwlockattr_t *attr, int pshared) -{ - if (!pthread_rwlockattr::is_good_object (attr)) - return EINVAL; - if ((pshared < 0) || (pshared > 1)) - return EINVAL; - /* shared rwlock vars not currently supported */ - if (pshared != PTHREAD_PROCESS_PRIVATE) - return EINVAL; - (*attr)->shared = pshared; - return 0; -} - -extern "C" int -pthread_rwlockattr_destroy (pthread_rwlockattr_t *rwlockattr) -{ - if (!pthread_rwlockattr::is_good_object (rwlockattr)) - return EINVAL; - delete (*rwlockattr); - *rwlockattr = NULL; - return 0; -} - -/* Thread signal */ -extern "C" int -pthread_kill (pthread_t thread, int sig) -{ - // lock myself, for the use of thread2signal - // two different kills might clash: FIXME - - if (!pthread::is_good_object (&thread)) - return EINVAL; - - siginfo_t si = {0}; - si.si_signo = sig; - si.si_code = SI_USER; - si.si_pid = myself->pid; - si.si_uid = myself->uid; - int rval; - if (!thread->valid) - rval = ESRCH; - else if (sig) - { - thread->cygtls->set_threadkill (); - rval = sig_send (NULL, si, thread->cygtls); - } - else - switch (WaitForSingleObject (thread->win32_obj_id, 0)) - { - case WAIT_TIMEOUT: - rval = 0; - break; - default: - rval = ESRCH; - break; - } - - // unlock myself - return rval; -} - -extern "C" int -pthread_sigmask (int operation, const sigset_t *set, sigset_t *old_set) -{ - return handle_sigprocmask (operation, set, old_set, _my_tls.sigmask); -} - -/* ID */ - -extern "C" int -pthread_equal (pthread_t t1, pthread_t t2) -{ - return pthread::equal (t1, t2); -} - -/* Mutexes */ - -int -pthread_mutex::init (pthread_mutex_t *mutex, - const pthread_mutexattr_t *attr, - const pthread_mutex_t initializer) -{ - if (attr && !pthread_mutexattr::is_good_object (attr)) - return EINVAL; - - mutex_initialization_lock.lock (); - if (initializer == NULL || pthread_mutex::is_good_initializer (mutex)) - { - pthread_mutex_t new_mutex = new pthread_mutex (attr ? (*attr) : NULL); - if (!is_good_object (&new_mutex)) - { - delete new_mutex; - mutex_initialization_lock.unlock (); - return EAGAIN; - } - - if (!attr && initializer) - { - if (initializer == PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) - new_mutex->type = PTHREAD_MUTEX_RECURSIVE; - else if (initializer == PTHREAD_NORMAL_MUTEX_INITIALIZER_NP) - new_mutex->type = PTHREAD_MUTEX_NORMAL; - else if (initializer == PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP) - new_mutex->type = PTHREAD_MUTEX_ERRORCHECK; - } - - myfault efault; - if (efault.faulted ()) - { - delete new_mutex; - mutex_initialization_lock.unlock (); - return EINVAL; - } - - *mutex = new_mutex; - } - mutex_initialization_lock.unlock (); - - return 0; -} - -extern "C" int -pthread_mutex_getprioceiling (const pthread_mutex_t *mutex, - int *prioceiling) -{ - /* We don't define _POSIX_THREAD_PRIO_PROTECT because we do't currently support - mutex priorities. - - We can support mutex priorities in the future though: - Store a priority with each mutex. - When the mutex is optained, set the thread priority as appropriate - When the mutex is released, reset the thread priority. */ - return ENOSYS; -} - -extern "C" int -pthread_mutex_lock (pthread_mutex_t *mutex) -{ - if (pthread_mutex::is_good_initializer (mutex)) - pthread_mutex::init (mutex, NULL, *mutex); - if (!pthread_mutex::is_good_object (mutex)) - return EINVAL; - return (*mutex)->lock (); -} - -extern "C" int -pthread_mutex_trylock (pthread_mutex_t *mutex) -{ - if (pthread_mutex::is_good_initializer (mutex)) - pthread_mutex::init (mutex, NULL, *mutex); - if (!pthread_mutex::is_good_object (mutex)) - return EINVAL; - return (*mutex)->trylock (); -} - -extern "C" int -pthread_mutex_unlock (pthread_mutex_t *mutex) -{ - if (pthread_mutex::is_good_initializer (mutex)) - return EPERM; - if (!pthread_mutex::is_good_object (mutex)) - return EINVAL; - return (*mutex)->unlock (); -} - -extern "C" int -pthread_mutex_destroy (pthread_mutex_t *mutex) -{ - int rv; - - if (pthread_mutex::is_good_initializer (mutex)) - return 0; - if (!pthread_mutex::is_good_object (mutex)) - return EINVAL; - - rv = (*mutex)->destroy (); - if (rv) - return rv; - - *mutex = NULL; - return 0; -} - -extern "C" int -pthread_mutex_setprioceiling (pthread_mutex_t *mutex, int prioceiling, - int *old_ceiling) -{ - return ENOSYS; -} - -/* Win32 doesn't support mutex priorities - see __pthread_mutex_getprioceiling - for more detail */ -extern "C" int -pthread_mutexattr_getprotocol (const pthread_mutexattr_t *attr, - int *protocol) -{ - if (!pthread_mutexattr::is_good_object (attr)) - return EINVAL; - return ENOSYS; -} - -extern "C" int -pthread_mutexattr_getpshared (const pthread_mutexattr_t *attr, - int *pshared) -{ - if (!pthread_mutexattr::is_good_object (attr)) - return EINVAL; - *pshared = (*attr)->pshared; - return 0; -} - -extern "C" int -pthread_mutexattr_gettype (const pthread_mutexattr_t *attr, int *type) -{ - if (!pthread_mutexattr::is_good_object (attr)) - return EINVAL; - *type = (*attr)->mutextype; - return 0; -} - -/* FIXME: write and test process shared mutex's. */ -extern "C" int -pthread_mutexattr_init (pthread_mutexattr_t *attr) -{ - if (pthread_mutexattr::is_good_object (attr)) - return EBUSY; - - *attr = new pthread_mutexattr (); - if (!pthread_mutexattr::is_good_object (attr)) - { - delete (*attr); - *attr = NULL; - return ENOMEM; - } - return 0; -} - -extern "C" int -pthread_mutexattr_destroy (pthread_mutexattr_t *attr) -{ - if (!pthread_mutexattr::is_good_object (attr)) - return EINVAL; - delete (*attr); - *attr = NULL; - return 0; -} - - -/* Win32 doesn't support mutex priorities */ -extern "C" int -pthread_mutexattr_setprotocol (pthread_mutexattr_t *attr, int protocol) -{ - if (!pthread_mutexattr::is_good_object (attr)) - return EINVAL; - return ENOSYS; -} - -/* Win32 doesn't support mutex priorities */ -extern "C" int -pthread_mutexattr_setprioceiling (pthread_mutexattr_t *attr, - int prioceiling) -{ - if (!pthread_mutexattr::is_good_object (attr)) - return EINVAL; - return ENOSYS; -} - -extern "C" int -pthread_mutexattr_getprioceiling (const pthread_mutexattr_t *attr, - int *prioceiling) -{ - if (!pthread_mutexattr::is_good_object (attr)) - return EINVAL; - return ENOSYS; -} - -extern "C" int -pthread_mutexattr_setpshared (pthread_mutexattr_t *attr, int pshared) -{ - if (!pthread_mutexattr::is_good_object (attr)) - return EINVAL; - /* we don't use pshared for anything as yet. We need to test PROCESS_SHARED - *functionality - */ - if (pshared != PTHREAD_PROCESS_PRIVATE) - return EINVAL; - (*attr)->pshared = pshared; - return 0; -} - -/* see pthread_mutex_gettype */ -extern "C" int -pthread_mutexattr_settype (pthread_mutexattr_t *attr, int type) -{ - if (!pthread_mutexattr::is_good_object (attr)) - return EINVAL; - - switch (type) - { - case PTHREAD_MUTEX_ERRORCHECK: - case PTHREAD_MUTEX_RECURSIVE: - case PTHREAD_MUTEX_NORMAL: - (*attr)->mutextype = type; - break; - default: - return EINVAL; - } - - return 0; -} - -/* Semaphores */ - -List semaphore::semaphores; - -semaphore::semaphore (int pshared, unsigned int value) -: verifyable_object (SEM_MAGIC), - shared (pshared), - currentvalue (value), - fd (-1), - hash (0ULL), - sem (NULL) -{ - SECURITY_ATTRIBUTES sa = (pshared != PTHREAD_PROCESS_PRIVATE) - ? sec_all : sec_none_nih; - this->win32_obj_id = ::CreateSemaphore (&sa, value, LONG_MAX, NULL); - if (!this->win32_obj_id) - magic = 0; - - semaphores.insert (this); -} - -semaphore::semaphore (unsigned long long shash, LUID sluid, int sfd, - sem_t *ssem, int oflag, mode_t mode, unsigned int value) -: verifyable_object (SEM_MAGIC), - shared (PTHREAD_PROCESS_SHARED), - currentvalue (value), /* Unused for named semaphores. */ - fd (sfd), - hash (shash), - luid (sluid), - sem (ssem) -{ - char name[MAX_PATH]; - - __small_sprintf (name, "semaphore/%016X%08x%08x", - hash, luid.HighPart, luid.LowPart); - this->win32_obj_id = ::CreateSemaphore (&sec_all, value, LONG_MAX, name); - if (!this->win32_obj_id) - magic = 0; - if (GetLastError () == ERROR_ALREADY_EXISTS && (oflag & O_EXCL)) - { - __seterrno (); - CloseHandle (this->win32_obj_id); - magic = 0; - } - - semaphores.insert (this); -} - -semaphore::~semaphore () -{ - if (win32_obj_id) - CloseHandle (win32_obj_id); - - semaphores.remove (this); -} - -void -semaphore::_post () -{ - if (ReleaseSemaphore (win32_obj_id, 1, ¤tvalue)) - currentvalue++; -} - -int -semaphore::_getvalue (int *sval) -{ - long val; - - switch (WaitForSingleObject (win32_obj_id, 0)) - { - case WAIT_OBJECT_0: - ReleaseSemaphore (win32_obj_id, 1, &val); - *sval = val + 1; - break; - case WAIT_TIMEOUT: - *sval = 0; - break; - default: - set_errno (EAGAIN); - return -1; - } - return 0; -} - -int -semaphore::_trywait () -{ - /* FIXME: signals should be able to interrupt semaphores... - We probably need WaitForMultipleObjects here. */ - if (WaitForSingleObject (win32_obj_id, 0) == WAIT_TIMEOUT) - { - set_errno (EAGAIN); - return -1; - } - currentvalue--; - return 0; -} - -int -semaphore::_timedwait (const struct timespec *abstime) -{ - struct timeval tv; - long waitlength; - - myfault efault; - if (efault.faulted ()) - { - /* According to SUSv3, abstime need not be checked for validity, - if the semaphore can be locked immediately. */ - if (!_trywait ()) - return 0; - set_errno (EINVAL); - return -1; - } - - gettimeofday (&tv, NULL); - waitlength = abstime->tv_sec * 1000 + abstime->tv_nsec / (1000 * 1000); - waitlength -= tv.tv_sec * 1000 + tv.tv_usec / 1000; - if (waitlength < 0) - waitlength = 0; - switch (cancelable_wait (win32_obj_id, waitlength, cw_cancel_self, cw_sig_eintr)) - { - case WAIT_OBJECT_0: - currentvalue--; - break; - case WAIT_SIGNALED: - set_errno (EINTR); - return -1; - case WAIT_TIMEOUT: - set_errno (ETIMEDOUT); - return -1; - default: - debug_printf ("cancelable_wait failed. %E"); - __seterrno (); - return -1; - } - return 0; -} - -int -semaphore::_wait () -{ - switch (cancelable_wait (win32_obj_id, INFINITE, cw_cancel_self, cw_sig_eintr)) - { - case WAIT_OBJECT_0: - currentvalue--; - break; - case WAIT_SIGNALED: - set_errno (EINTR); - return -1; - default: - debug_printf ("cancelable_wait failed. %E"); - break; - } - return 0; -} - -void -semaphore::_fixup_after_fork () -{ - if (shared == PTHREAD_PROCESS_PRIVATE) - { - debug_printf ("sem %x in _fixup_after_fork", this); - /* FIXME: duplicate code here and in the constructor. */ - this->win32_obj_id = ::CreateSemaphore (&sec_none_nih, currentvalue, - LONG_MAX, NULL); - if (!win32_obj_id) - api_fatal ("failed to create new win32 semaphore, error %d"); - } -} - -void -semaphore::_terminate () -{ - int _sem_close (sem_t *, bool); - - if (sem) - _sem_close (sem, false); -} - -/* static members */ - -int -semaphore::init (sem_t *sem, int pshared, unsigned int value) -{ - /* opengroup calls this undefined */ - if (is_good_object (sem)) - return EBUSY; - - if (value > SEM_VALUE_MAX) - return EINVAL; - - *sem = new semaphore (pshared, value); - - if (!is_good_object (sem)) - { - delete (*sem); - *sem = NULL; - return EAGAIN; - } - return 0; -} - -int -semaphore::destroy (sem_t *sem) -{ - if (!is_good_object (sem)) - return EINVAL; - - /* It's invalid to destroy a semaphore not opened with sem_init. */ - if ((*sem)->fd != -1) - return EINVAL; - - /* FIXME - new feature - test for busy against threads... */ - - delete (*sem); - *sem = NULL; - return 0; -} - -int -semaphore::close (sem_t *sem) -{ - if (!is_good_object (sem)) - return EINVAL; - - /* It's invalid to close a semaphore not opened with sem_open. */ - if ((*sem)->fd == -1) - return EINVAL; - - delete (*sem); - delete sem; - return 0; -} - -sem_t * -semaphore::open (unsigned long long hash, LUID luid, int fd, int oflag, - mode_t mode, unsigned int value, bool &wasopen) -{ - if (value > SEM_VALUE_MAX) - { - set_errno (EINVAL); - return NULL; - } - - /* sem_open is supposed to return the same pointer, if the same named - semaphore is opened multiple times in the same process, as long as - the semaphore hasn't been closed or unlinked in the meantime. */ - semaphores.mx.lock (); - for (semaphore *sema = semaphores.head; sema; sema = sema->next) - if (sema->fd >= 0 && sema->hash == hash - && sema->luid.HighPart == luid.HighPart - && sema->luid.LowPart == sema->luid.LowPart) - { - wasopen = true; - semaphores.mx.unlock (); - return sema->sem; - } - semaphores.mx.unlock (); - - wasopen = false; - sem_t *sem = new sem_t; - if (!sem) - { - set_errno (ENOMEM); - return NULL; - } - - *sem = new semaphore (hash, luid, fd, sem, oflag, mode, value); - - if (!is_good_object (sem)) - { - delete *sem; - delete sem; - return NULL; - } - return sem; -} - -int -semaphore::wait (sem_t *sem) -{ - pthread_testcancel (); - - if (!is_good_object (sem)) - { - set_errno (EINVAL); - return -1; - } - - return (*sem)->_wait (); -} - -int -semaphore::trywait (sem_t *sem) -{ - if (!is_good_object (sem)) - { - set_errno (EINVAL); - return -1; - } - - return (*sem)->_trywait (); -} - -int -semaphore::timedwait (sem_t *sem, const struct timespec *abstime) -{ - if (!is_good_object (sem)) - { - set_errno (EINVAL); - return -1; - } - - return (*sem)->_timedwait (abstime); -} - -int -semaphore::post (sem_t *sem) -{ - if (!is_good_object (sem)) - { - set_errno (EINVAL); - return -1; - } - - (*sem)->_post (); - return 0; -} - -int -semaphore::getvalue (sem_t *sem, int *sval) -{ - myfault efault; - if (efault.faulted () || !is_good_object (sem)) - { - set_errno (EINVAL); - return -1; - } - - return (*sem)->_getvalue (sval); -} - -int -semaphore::getinternal (sem_t *sem, int *sfd, unsigned long long *shash, - LUID *sluid, unsigned int *sval) -{ - myfault efault; - if (efault.faulted () || !is_good_object (sem)) - { - set_errno (EINVAL); - return -1; - } - if ((*sfd = (*sem)->fd) < 0) - { - set_errno (EINVAL); - return -1; - } - *shash = (*sem)->hash; - *sluid = (*sem)->luid; - /* POSIX defines the value in calls to sem_init/sem_open as unsigned, but - the sem_getvalue gets a pointer to int to return the value. Go figure! */ - return (*sem)->_getvalue ((int *)sval); -} - -/* pthread_null */ -pthread * -pthread_null::get_null_pthread () -{ - /* because of weird entry points */ - _instance.magic = 0; - return &_instance; -} - -pthread_null::pthread_null () -{ - attr.joinable = PTHREAD_CREATE_DETACHED; - /* Mark ourselves as invalid */ - magic = 0; -} - -pthread_null::~pthread_null () -{ -} - -bool -pthread_null::create (void *(*)(void *), pthread_attr *, void *) -{ - return true; -} - -void -pthread_null::exit (void *value_ptr) -{ - _my_tls.remove (INFINITE); - ExitThread (0); -} - -int -pthread_null::cancel () -{ - return 0; -} - -void -pthread_null::testcancel () -{ -} - -int -pthread_null::setcancelstate (int state, int *oldstate) -{ - return EINVAL; -} - -int -pthread_null::setcanceltype (int type, int *oldtype) -{ - return EINVAL; -} - -void -pthread_null::push_cleanup_handler (__pthread_cleanup_handler *handler) -{ -} - -void -pthread_null::pop_cleanup_handler (int const execute) -{ -} - -unsigned long -pthread_null::getsequence_np () -{ - return 0; -} - -pthread_null pthread_null::_instance; diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h deleted file mode 100644 index 17f3b59cb..000000000 --- a/winsup/cygwin/thread.h +++ /dev/null @@ -1,683 +0,0 @@ -/* thread.h: Locking and threading module definitions - - Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, - 2008, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _THREAD_H -#define _THREAD_H - -#define LOCK_MMAP_LIST 1 - -#define WRITE_LOCK 1 -#define READ_LOCK 2 - -#include -#include -#include "security.h" -#include - -enum cw_sig_wait -{ - cw_sig_nosig, - cw_sig_eintr, - cw_sig_resume -}; - -enum cw_cancel_action -{ - cw_cancel_self, - cw_no_cancel_self, - cw_no_cancel -}; - -DWORD cancelable_wait (HANDLE, DWORD, const cw_cancel_action = cw_cancel_self, - const enum cw_sig_wait = cw_sig_nosig) - __attribute__ ((regparm (3))); - -class fast_mutex -{ -public: - fast_mutex () : - lock_counter (0), win32_obj_id (0) - { - } - - ~fast_mutex () - { - if(win32_obj_id) - CloseHandle (win32_obj_id); - } - - bool init () - { - lock_counter = 0; - win32_obj_id = ::CreateEvent (&sec_none_nih, false, false, NULL); - if (!win32_obj_id) - { - debug_printf ("CreateEvent failed. %E"); - return false; - } - return true; - } - - void lock () - { - if (InterlockedIncrement ((long *) &lock_counter) != 1) - cancelable_wait (win32_obj_id, INFINITE, cw_no_cancel, cw_sig_resume); - } - - void unlock () - { - if (InterlockedDecrement ((long *) &lock_counter)) - ::SetEvent (win32_obj_id); - } - -private: - unsigned long lock_counter; - HANDLE win32_obj_id; -}; - -class per_process; -class pinfo; - -#define PTHREAD_MAGIC 0xdf0df045 -#define PTHREAD_MUTEX_MAGIC PTHREAD_MAGIC+1 -#define PTHREAD_KEY_MAGIC PTHREAD_MAGIC+2 -#define PTHREAD_ATTR_MAGIC PTHREAD_MAGIC+3 -#define PTHREAD_MUTEXATTR_MAGIC PTHREAD_MAGIC+4 -#define PTHREAD_COND_MAGIC PTHREAD_MAGIC+5 -#define PTHREAD_CONDATTR_MAGIC PTHREAD_MAGIC+6 -#define SEM_MAGIC PTHREAD_MAGIC+7 -#define PTHREAD_ONCE_MAGIC PTHREAD_MAGIC+8 -#define PTHREAD_RWLOCK_MAGIC PTHREAD_MAGIC+9 -#define PTHREAD_RWLOCKATTR_MAGIC PTHREAD_MAGIC+10 - -#define MUTEX_OWNER_ANONYMOUS ((pthread_t) -1) - -typedef unsigned long thread_magic_t; - -/* verifyable_object should not be defined here - it's a general purpose class */ - -class verifyable_object -{ -public: - thread_magic_t magic; - - verifyable_object (thread_magic_t verifyer): magic (verifyer) {} - virtual ~verifyable_object () { magic = 0; } -}; - -typedef enum -{ - VALID_OBJECT, - INVALID_OBJECT, - VALID_STATIC_OBJECT -} verifyable_object_state; - -template inline void -List_insert (list_node *&head, list_node *node) -{ - if (!node) - return; - do - node->next = head; - while (InterlockedCompareExchangePointer (&head, node, node->next) != node->next); -} - -template inline void -List_remove (fast_mutex &mx, list_node *&head, list_node const *node) -{ - if (!node) - return; - mx.lock (); - if (head) - { - if (InterlockedCompareExchangePointer (&head, node->next, node) != node) - { - list_node *cur = head; - - while (cur->next && node != cur->next) - cur = cur->next; - if (node == cur->next) - cur->next = cur->next->next; - } - } - mx.unlock (); -} - - -template class List -{ - public: - List() : head(NULL) - { - mx_init (); - } - - ~List() - { - } - - void fixup_after_fork () - { - mx_init (); - } - - void insert (list_node *node) - { - List_insert (head, node); - } - - void remove (list_node *node) - { - List_remove (mx, head, node); - } - - void for_each (void (list_node::*callback) ()) - { - mx.lock (); - list_node *cur = head; - while (cur) - { - (cur->*callback) (); - cur = cur->next; - } - mx.unlock (); - } - - fast_mutex mx; - list_node *head; - -protected: - void mx_init () - { - if (!mx.init ()) - api_fatal ("Could not create mutex for list synchronisation."); - } -}; - -class pthread_key: public verifyable_object -{ - DWORD tls_index; -public: - static bool is_good_object (pthread_key_t const *); - - int set (const void *value) {TlsSetValue (tls_index, (void *) value); return 0;} - void *get () const {return TlsGetValue (tls_index);} - - pthread_key (void (*)(void *)); - ~pthread_key (); - static void fixup_before_fork () - { - keys.for_each (&pthread_key::_fixup_before_fork); - } - - static void fixup_after_fork () - { - keys.fixup_after_fork (); - keys.for_each (&pthread_key::_fixup_after_fork); - } - - static void run_all_destructors () - { - keys.for_each (&pthread_key::run_destructor); - } - - /* List support calls */ - class pthread_key *next; -private: - static List keys; - void _fixup_before_fork (); - void _fixup_after_fork (); - void (*destructor) (void *); - void run_destructor (); - void *fork_buf; -}; - -class pthread_attr: public verifyable_object -{ -public: - static bool is_good_object(pthread_attr_t const *); - int joinable; - int contentionscope; - int inheritsched; - struct sched_param schedparam; - size_t stacksize; - - pthread_attr (); - ~pthread_attr (); -}; - -class pthread_mutexattr: public verifyable_object -{ -public: - static bool is_good_object(pthread_mutexattr_t const *); - int pshared; - int mutextype; - pthread_mutexattr (); - ~pthread_mutexattr (); -}; - -class pthread_mutex: public verifyable_object -{ -public: - static bool is_good_object (pthread_mutex_t const *); - static bool is_good_initializer (pthread_mutex_t const *); - static bool is_good_initializer_or_object (pthread_mutex_t const *); - static bool is_good_initializer_or_bad_object (pthread_mutex_t const *); - static bool can_be_unlocked (pthread_mutex_t const *); - static void init_mutex (); - static int init (pthread_mutex_t *, const pthread_mutexattr_t *attr, - const pthread_mutex_t); - - unsigned long lock_counter; - HANDLE win32_obj_id; - unsigned int recursion_counter; - LONG condwaits; - pthread_t owner; -#ifdef DEBUGGING - DWORD tid; /* the thread id of the owner */ -#endif - int type; - int pshared; - - int lock (); - int trylock (); - int unlock (); - int destroy (); - void set_owner (pthread_t self) - { - recursion_counter = 1; - owner = self; -#ifdef DEBUGGING - tid = GetCurrentThreadId (); -#endif - } - - int lock_recursive () - { - if (UINT_MAX == recursion_counter) - return EAGAIN; - ++recursion_counter; - return 0; - } - - pthread_mutex (pthread_mutexattr * = NULL); - pthread_mutex (pthread_mutex_t *, pthread_mutexattr *); - ~pthread_mutex (); - - class pthread_mutex * next; - static void fixup_after_fork () - { - mutexes.fixup_after_fork (); - mutexes.for_each (&pthread_mutex::_fixup_after_fork); - } - -private: - void _fixup_after_fork (); - - static List mutexes; - static fast_mutex mutex_initialization_lock; -}; - -#define WAIT_CANCELED (WAIT_OBJECT_0 + 1) -#define WAIT_SIGNALED (WAIT_OBJECT_0 + 2) - -class _cygtls; -class pthread: public verifyable_object -{ -public: - HANDLE win32_obj_id; - class pthread_attr attr; - void *(*function) (void *); - void *arg; - void *return_ptr; - bool valid; - bool suspended; - int cancelstate, canceltype; - _cygtls *cygtls; - HANDLE cancel_event; - pthread_t joiner; - - virtual bool create (void *(*)(void *), pthread_attr *, void *); - - pthread (); - virtual ~pthread (); - - static void init_mainthread (); - static bool is_good_object(pthread_t const *); - static void atforkprepare(); - static void atforkparent(); - static void atforkchild(); - - /* API calls */ - static int cancel (pthread_t); - static int join (pthread_t * thread, void **return_val); - static int detach (pthread_t * thread); - static int create (pthread_t * thread, const pthread_attr_t * attr, - void *(*start_routine) (void *), void *arg); - static int once (pthread_once_t *, void (*)(void)); - static int atfork(void (*)(void), void (*)(void), void (*)(void)); - static int suspend (pthread_t * thread); - static int resume (pthread_t * thread); - - virtual void exit (void *value_ptr) __attribute__ ((noreturn)); - - virtual int cancel (); - - virtual void testcancel (); - static void static_cancel_self (); - - virtual int setcancelstate (int state, int *oldstate); - virtual int setcanceltype (int type, int *oldtype); - - virtual void push_cleanup_handler (__pthread_cleanup_handler *handler); - virtual void pop_cleanup_handler (int const execute); - - static pthread* self (); - static DWORD WINAPI thread_init_wrapper (void *); - - virtual unsigned long getsequence_np(); - - static int equal (pthread_t t1, pthread_t t2) - { - return t1 == t2; - } - - /* List support calls */ - class pthread *next; - static void fixup_after_fork () - { - threads.fixup_after_fork (); - threads.for_each (&pthread::_fixup_after_fork); - } - - static void suspend_all_except_self () - { - threads.for_each (&pthread::suspend_except_self); - } - - static void resume_all () - { - threads.for_each (&pthread::resume); - } - -private: - static List threads; - DWORD thread_id; - __pthread_cleanup_handler *cleanup_stack; - pthread_mutex mutex; - _cygtls *parent_tls; - - void suspend_except_self (); - void resume (); - - void _fixup_after_fork (); - - void pop_all_cleanup_handlers (); - void precreate (pthread_attr *); - void postcreate (); - bool create_cancel_event (); - static void set_tls_self_pointer (pthread *); - void cancel_self (); - DWORD get_thread_id (); -}; - -class pthread_null : public pthread -{ - public: - static pthread *get_null_pthread(); - ~pthread_null(); - - /* From pthread These should never get called - * as the ojbect is not verifyable - */ - bool create (void *(*)(void *), pthread_attr *, void *); - void exit (void *value_ptr) __attribute__ ((noreturn)); - int cancel (); - void testcancel (); - int setcancelstate (int state, int *oldstate); - int setcanceltype (int type, int *oldtype); - void push_cleanup_handler (__pthread_cleanup_handler *handler); - void pop_cleanup_handler (int const execute); - unsigned long getsequence_np(); - - private: - pthread_null (); - static pthread_null _instance; -}; - -class pthread_condattr: public verifyable_object -{ -public: - static bool is_good_object(pthread_condattr_t const *); - int shared; - - pthread_condattr (); - ~pthread_condattr (); -}; - -class pthread_cond: public verifyable_object -{ -public: - static bool is_good_object (pthread_cond_t const *); - static bool is_good_initializer (pthread_cond_t const *); - static bool is_good_initializer_or_object (pthread_cond_t const *); - static bool is_good_initializer_or_bad_object (pthread_cond_t const *); - static void init_mutex (); - static int init (pthread_cond_t *, const pthread_condattr_t *); - - int shared; - - unsigned long waiting; - unsigned long pending; - HANDLE sem_wait; - - pthread_mutex mtx_in; - pthread_mutex mtx_out; - - pthread_mutex_t mtx_cond; - - void unblock (const bool all); - int wait (pthread_mutex_t mutex, DWORD dwMilliseconds = INFINITE); - - pthread_cond (pthread_condattr *); - ~pthread_cond (); - - class pthread_cond * next; - static void fixup_after_fork () - { - conds.fixup_after_fork (); - conds.for_each (&pthread_cond::_fixup_after_fork); - } - -private: - void _fixup_after_fork (); - - static List conds; - static fast_mutex cond_initialization_lock; -}; - -class pthread_rwlockattr: public verifyable_object -{ -public: - static bool is_good_object(pthread_rwlockattr_t const *); - int shared; - - pthread_rwlockattr (); - ~pthread_rwlockattr (); -}; - -class pthread_rwlock: public verifyable_object -{ -public: - static bool is_good_object (pthread_rwlock_t const *); - static bool is_good_initializer (pthread_rwlock_t const *); - static bool is_good_initializer_or_object (pthread_rwlock_t const *); - static bool is_good_initializer_or_bad_object (pthread_rwlock_t const *); - static void init_mutex (); - static int init (pthread_rwlock_t *, const pthread_rwlockattr_t *); - - int shared; - - unsigned long waiting_readers; - unsigned long waiting_writers; - pthread_t writer; - struct RWLOCK_READER - { - struct RWLOCK_READER *next; - pthread_t thread; - unsigned long n; - } *readers; - fast_mutex readers_mx; - - int rdlock (); - int tryrdlock (); - - int wrlock (); - int trywrlock (); - - int unlock (); - - pthread_mutex mtx; - pthread_cond cond_readers; - pthread_cond cond_writers; - - pthread_rwlock (pthread_rwlockattr *); - ~pthread_rwlock (); - - class pthread_rwlock * next; - static void fixup_after_fork () - { - rwlocks.fixup_after_fork (); - rwlocks.for_each (&pthread_rwlock::_fixup_after_fork); - } - -private: - static List rwlocks; - - void add_reader (struct RWLOCK_READER *rd); - void remove_reader (struct RWLOCK_READER *rd); - struct RWLOCK_READER *lookup_reader (pthread_t thread); - - void release () - { - if (waiting_writers) - { - if (!readers) - cond_writers.unblock (false); - } - else if (waiting_readers) - cond_readers.unblock (true); - } - - - static void rdlock_cleanup (void *arg); - static void wrlock_cleanup (void *arg); - - void _fixup_after_fork (); - - static fast_mutex rwlock_initialization_lock; -}; - -class pthread_once -{ -public: - pthread_mutex_t mutex; - int state; -}; - -/* shouldn't be here */ -class semaphore: public verifyable_object -{ -public: - static bool is_good_object(sem_t const *); - /* API calls */ - static int init (sem_t *sem, int pshared, unsigned int value); - static int destroy (sem_t *sem); - static sem_t *open (unsigned long long hash, LUID luid, int fd, int oflag, - mode_t mode, unsigned int value, bool &wasopen); - static int close (sem_t *sem); - static int wait (sem_t *sem); - static int post (sem_t *sem); - static int getvalue (sem_t *sem, int *sval); - static int trywait (sem_t *sem); - static int timedwait (sem_t *sem, const struct timespec *abstime); - - static int getinternal (sem_t *sem, int *sfd, unsigned long long *shash, - LUID *sluid, unsigned int *sval); - - HANDLE win32_obj_id; - int shared; - long currentvalue; - int fd; - unsigned long long hash; - LUID luid; - sem_t *sem; - - semaphore (int, unsigned int); - semaphore (unsigned long long, LUID, int, sem_t *, int, mode_t, unsigned int); - ~semaphore (); - - class semaphore * next; - static void fixup_after_fork () - { - semaphores.fixup_after_fork (); - semaphores.for_each (&semaphore::_fixup_after_fork); - } - static void terminate () - { - semaphores.for_each (&semaphore::_terminate); - } - -private: - int _wait (); - void _post (); - int _getvalue (int *sval); - int _trywait (); - int _timedwait (const struct timespec *abstime); - - void _fixup_after_fork (); - void _terminate (); - - static List semaphores; -}; - -class callback -{ -public: - void (*cb)(void); - class callback * next; -}; - -struct MTinterface -{ - // General - int concurrency; - long int threadcount; - - callback *pthread_prepare; - callback *pthread_child; - callback *pthread_parent; - - void Init (); - void fixup_before_fork (); - void fixup_after_fork (); - -#if 0 // avoid initialization since zero is implied and - MTinterface () : - concurrency (0), threadcount (0), - pthread_prepare (NULL), pthread_child (NULL), pthread_parent (NULL) - { - } -#endif -}; - -#define MT_INTERFACE user_data->threadinterface -#endif // _THREAD_H diff --git a/winsup/cygwin/timer.cc b/winsup/cygwin/timer.cc deleted file mode 100644 index 9cf95848e..000000000 --- a/winsup/cygwin/timer.cc +++ /dev/null @@ -1,456 +0,0 @@ -/* timer.cc - - Copyright 2004, 2005 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "thread.h" -#include "cygtls.h" -#include "sigproc.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" - -#define TT_MAGIC 0x513e4a1c -struct timer_tracker -{ - unsigned magic; - clockid_t clock_id; - sigevent evp; - timespec it_interval; - HANDLE hcancel; - HANDLE syncthread; - long long interval_us; - long long sleepto_us; - bool cancel (); - struct timer_tracker *next; - int settime (int, const itimerspec *, itimerspec *); - void gettime (itimerspec *); - timer_tracker (clockid_t, const sigevent *); - ~timer_tracker (); - friend void fixup_timers_after_fork (); -}; - -timer_tracker NO_COPY ttstart (CLOCK_REALTIME, NULL); - -class lock_timer_tracker -{ - static muto protect; -public: - lock_timer_tracker (); - ~lock_timer_tracker (); -}; - -muto NO_COPY lock_timer_tracker::protect; - -lock_timer_tracker::lock_timer_tracker () -{ - protect.init ("timer_protect")->acquire (); -} - -lock_timer_tracker::~lock_timer_tracker () -{ - protect.release (); -} - -bool -timer_tracker::cancel () -{ - if (!hcancel) - return false; - - SetEvent (hcancel); - if (WaitForSingleObject (syncthread, INFINITE) != WAIT_OBJECT_0) - api_fatal ("WFSO failed waiting for timer thread, %E"); - return true; -} - -timer_tracker::~timer_tracker () -{ - if (cancel ()) - { - CloseHandle (hcancel); -#ifdef DEBUGGING - hcancel = NULL; -#endif - } - if (syncthread) - CloseHandle (syncthread); - magic = 0; -} - -timer_tracker::timer_tracker (clockid_t c, const sigevent *e) -{ - if (e != NULL) - evp = *e; - else - { - evp.sigev_notify = SIGEV_SIGNAL; - evp.sigev_signo = SIGALRM; - evp.sigev_value.sival_ptr = this; - } - clock_id = c; - magic = TT_MAGIC; - hcancel = NULL; - if (this != &ttstart) - { - lock_timer_tracker here; - next = ttstart.next; - ttstart.next = this; - } -} - -static long long -to_us (const timespec& ts) -{ - long long res = ts.tv_sec; - res *= 1000000; - res += ts.tv_nsec / 1000 + ((ts.tv_nsec % 1000) ? 1 : 0); - return res; -} - -static DWORD WINAPI -timer_thread (VOID *x) -{ - timer_tracker *tt = ((timer_tracker *) x); - long long now; - long long sleepto_us = tt->sleepto_us; - while (1) - { - long long sleep_us; - long sleep_ms; - /* Account for delays in starting thread - and sending the signal */ - now = gtod.usecs (); - sleep_us = sleepto_us - now; - if (sleep_us > 0) - { - tt->sleepto_us = sleepto_us; - sleep_ms = (sleep_us + 999) / 1000; - } - else - { - tt->sleepto_us = now; - sleep_ms = 0; - } - - debug_printf ("%p waiting for %u ms", x, sleep_ms); - switch (WaitForSingleObject (tt->hcancel, sleep_ms)) - { - case WAIT_TIMEOUT: - debug_printf ("timed out"); - break; - case WAIT_OBJECT_0: - debug_printf ("%p cancelled", x); - goto out; - default: - debug_printf ("%p wait failed, %E", x); - goto out; - } - - switch (tt->evp.sigev_notify) - { - case SIGEV_SIGNAL: - { - siginfo_t si = {0}; - si.si_signo = tt->evp.sigev_signo; - si.si_sigval.sival_ptr = tt->evp.sigev_value.sival_ptr; - si.si_code = SI_TIMER; - debug_printf ("%p sending sig %d", x, tt->evp.sigev_signo); - sig_send (myself_nowait, si); - break; - } - case SIGEV_THREAD: - { - pthread_t notify_thread; - debug_printf ("%p starting thread", x); - pthread_attr_t *attr; - pthread_attr_t default_attr; - if (tt->evp.sigev_notify_attributes) - attr = tt->evp.sigev_notify_attributes; - else - { - pthread_attr_init(attr = &default_attr); - pthread_attr_setdetachstate (attr, PTHREAD_CREATE_DETACHED); - } - - int rc = pthread_create (¬ify_thread, attr, - (void * (*) (void *)) tt->evp.sigev_notify_function, - tt->evp.sigev_value.sival_ptr); - if (rc) - { - debug_printf ("thread creation failed, %E"); - return 0; - } - // FIXME: pthread_join? - break; - } - } - if (!tt->interval_us) - break; - - sleepto_us = tt->sleepto_us + tt->interval_us; - debug_printf ("looping"); - } - -out: - _my_tls._ctinfo->auto_release (); /* automatically return the cygthread to the cygthread pool */ - return 0; -} - -static bool -it_bad (const timespec& t) -{ - if (t.tv_nsec < 0 || t.tv_nsec >= 1000000000 || t.tv_sec < 0) - { - set_errno (EINVAL); - return true; - } - return false; -} - -int -timer_tracker::settime (int in_flags, const itimerspec *value, itimerspec *ovalue) -{ - if (!value) - { - set_errno (EINVAL); - return -1; - } - - myfault efault; - if (efault.faulted (EFAULT) - || it_bad (value->it_value) - || it_bad (value->it_interval)) - return -1; - - long long now = in_flags & TIMER_ABSTIME ? 0 : gtod.usecs (); - - lock_timer_tracker here; - cancel (); - - if (ovalue) - gettime (ovalue); - - if (!value->it_value.tv_sec && !value->it_value.tv_nsec) - interval_us = sleepto_us = 0; - else - { - sleepto_us = now + to_us (value->it_value); - interval_us = to_us (value->it_interval); - it_interval = value->it_interval; - if (!hcancel) - hcancel = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL); - else - ResetEvent (hcancel); - if (!syncthread) - syncthread = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL); - else - ResetEvent (syncthread); - new cygthread (timer_thread, 0, this, "itimer", syncthread); - } - - return 0; -} - -void -timer_tracker::gettime (itimerspec *ovalue) -{ - if (!hcancel) - memset (ovalue, 0, sizeof (*ovalue)); - else - { - ovalue->it_interval = it_interval; - long long now = gtod.usecs (); - long long left_us = sleepto_us - now; - if (left_us < 0) - left_us = 0; - ovalue->it_value.tv_sec = left_us / 1000000; - ovalue->it_value.tv_nsec = (left_us % 1000000) * 1000; - } -} - -extern "C" int -timer_gettime (timer_t timerid, struct itimerspec *ovalue) -{ - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - timer_tracker *tt = (timer_tracker *) timerid; - if (tt->magic != TT_MAGIC) - { - set_errno (EINVAL); - return -1; - } - - tt->gettime (ovalue); - return 0; -} - -extern "C" int -timer_create (clockid_t clock_id, struct sigevent *evp, timer_t *timerid) -{ - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - if (clock_id != CLOCK_REALTIME) - { - set_errno (EINVAL); - return -1; - } - - *timerid = (timer_t) new timer_tracker (clock_id, evp); - return 0; -} - -extern "C" int -timer_settime (timer_t timerid, int flags, const struct itimerspec *value, - struct itimerspec *ovalue) -{ - timer_tracker *tt = (timer_tracker *) timerid; - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - if (tt->magic != TT_MAGIC) - { - set_errno (EINVAL); - return -1; - } - - return tt->settime (flags, value, ovalue); -} - -extern "C" int -timer_delete (timer_t timerid) -{ - timer_tracker *in_tt = (timer_tracker *) timerid; - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - if (in_tt->magic != TT_MAGIC) - { - set_errno (EINVAL); - return -1; - } - - lock_timer_tracker here; - for (timer_tracker *tt = &ttstart; tt->next != NULL; tt = tt->next) - if (tt->next == in_tt) - { - tt->next = in_tt->next; - delete in_tt; - return 0; - } - set_errno (EINVAL); - return 0; -} - -void -fixup_timers_after_fork () -{ - ttstart.hcancel = ttstart.syncthread = NULL; - for (timer_tracker *tt = &ttstart; tt->next != NULL; /* nothing */) - { - timer_tracker *deleteme = tt->next; - tt->next = deleteme->next; - deleteme->hcancel = deleteme->syncthread = NULL; - delete deleteme; - } -} - - -extern "C" int -setitimer (int which, const struct itimerval *value, struct itimerval *ovalue) -{ - if (which != ITIMER_REAL) - { - set_errno (EINVAL); - return -1; - } - struct itimerspec spec_value, spec_ovalue; - int ret; - spec_value.it_interval.tv_sec = value->it_interval.tv_sec; - spec_value.it_interval.tv_nsec = value->it_interval.tv_usec * 1000; - spec_value.it_value.tv_sec = value->it_value.tv_sec; - spec_value.it_value.tv_nsec = value->it_value.tv_usec * 1000; - ret = timer_settime ((timer_t) &ttstart, 0, &spec_value, &spec_ovalue); - if (!ret && ovalue) - { - ovalue->it_interval.tv_sec = spec_ovalue.it_interval.tv_sec; - ovalue->it_interval.tv_usec = spec_ovalue.it_interval.tv_nsec / 1000; - ovalue->it_value.tv_sec = spec_ovalue.it_value.tv_sec; - ovalue->it_value.tv_usec = spec_ovalue.it_value.tv_nsec / 1000; - } - syscall_printf ("%d = setitimer ()", ret); - return ret; -} - - -extern "C" int -getitimer (int which, struct itimerval *ovalue) -{ - if (which != ITIMER_REAL) - { - set_errno (EINVAL); - return -1; - } - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - struct itimerspec spec_ovalue; - int ret = timer_gettime ((timer_t) &ttstart, &spec_ovalue); - if (!ret) - { - ovalue->it_interval.tv_sec = spec_ovalue.it_interval.tv_sec; - ovalue->it_interval.tv_usec = spec_ovalue.it_interval.tv_nsec / 1000; - ovalue->it_value.tv_sec = spec_ovalue.it_value.tv_sec; - ovalue->it_value.tv_usec = spec_ovalue.it_value.tv_nsec / 1000; - } - syscall_printf ("%d = getitimer ()", ret); - return ret; -} - -/* FIXME: POSIX - alarm survives exec */ -extern "C" unsigned int -alarm (unsigned int seconds) -{ - struct itimerspec newt = {}, oldt; - /* alarm cannot fail, but only needs not be - correct for arguments < 64k. Truncate */ - if (seconds > (HIRES_DELAY_MAX / 1000 - 1)) - seconds = (HIRES_DELAY_MAX / 1000 - 1); - newt.it_value.tv_sec = seconds; - timer_settime ((timer_t) &ttstart, 0, &newt, &oldt); - int ret = oldt.it_value.tv_sec + (oldt.it_value.tv_nsec > 0); - syscall_printf ("%d = alarm (%d)", ret, seconds); - return ret; -} - -extern "C" useconds_t -ualarm (useconds_t value, useconds_t interval) -{ - struct itimerspec timer = {}, otimer; - /* ualarm cannot fail. - Interpret negative arguments as zero */ - if (value > 0) - { - timer.it_value.tv_sec = (unsigned int) value / 1000000; - timer.it_value.tv_nsec = ((unsigned int) value % 1000000) * 1000; - } - if (interval > 0) - { - timer.it_interval.tv_sec = (unsigned int) interval / 1000000; - timer.it_interval.tv_nsec = ((unsigned int) interval % 1000000) * 1000; - } - timer_settime ((timer_t) &ttstart, 0, &timer, &otimer); - useconds_t ret = otimer.it_value.tv_sec * 1000000 + (otimer.it_value.tv_nsec + 999) / 1000; - syscall_printf ("%d = ualarm (%d , %d)", ret, value, interval); - return ret; -} diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc deleted file mode 100644 index 39fc6546a..000000000 --- a/winsup/cygwin/times.cc +++ /dev/null @@ -1,791 +0,0 @@ -/* times.cc - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#define __timezonefunc__ -#include "winsup.h" -#include -#include -#include -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "pinfo.h" -#include "cygtls.h" -#include "ntdll.h" - -#define FACTOR (0x19db1ded53e8000LL) -#define NSPERSEC 10000000LL - -static inline LONGLONG -systime_ns () -{ - LARGE_INTEGER x; - FILETIME ft; - GetSystemTimeAsFileTime (&ft); - x.HighPart = ft.dwHighDateTime; - x.LowPart = ft.dwLowDateTime; - x.QuadPart -= FACTOR; /* Add conversion factor for UNIX vs. Windows base time */ - return x.QuadPart; -} - -static inline LONGLONG -systime () -{ - return systime_ns () / 10; -} - -/* Cygwin internal */ -static unsigned long long __stdcall -__to_clock_t (FILETIME *src, int flag) -{ - unsigned long long total = ((unsigned long long) src->dwHighDateTime << 32) + ((unsigned)src->dwLowDateTime); - syscall_printf ("dwHighDateTime %u, dwLowDateTime %u", src->dwHighDateTime, src->dwLowDateTime); - - /* Convert into clock ticks - the total is in 10ths of a usec. */ - if (flag) - total -= FACTOR; - - total /= (unsigned long long) (NSPERSEC / CLOCKS_PER_SEC); - syscall_printf ("total %08x %08x", (unsigned) (total>>32), (unsigned) (total)); - return total; -} - -/* times: POSIX 4.5.2.1 */ -extern "C" clock_t -times (struct tms *buf) -{ - FILETIME creation_time, exit_time, kernel_time, user_time; - - myfault efault; - if (efault.faulted (EFAULT)) - return ((clock_t) -1); - - LONGLONG ticks = gtod.uptime (); - /* Ticks is in milliseconds, convert to our ticks. Use long long to prevent - overflow. */ - clock_t tc = (clock_t) (ticks * CLOCKS_PER_SEC / 1000); - - GetProcessTimes (GetCurrentProcess (), &creation_time, &exit_time, - &kernel_time, &user_time); - - syscall_printf ("ticks %d, CLOCKS_PER_SEC %d", ticks, CLOCKS_PER_SEC); - syscall_printf ("user_time %d, kernel_time %d, creation_time %d, exit_time %d", - user_time, kernel_time, creation_time, exit_time); - buf->tms_stime = __to_clock_t (&kernel_time, 0); - buf->tms_utime = __to_clock_t (&user_time, 0); - timeval_to_filetime (&myself->rusage_children.ru_stime, &kernel_time); - buf->tms_cstime = __to_clock_t (&kernel_time, 1); - timeval_to_filetime (&myself->rusage_children.ru_utime, &user_time); - buf->tms_cutime = __to_clock_t (&user_time, 1); - - return tc; -} - -EXPORT_ALIAS (times, _times) - -/* settimeofday: BSD */ -extern "C" int -settimeofday (const struct timeval *tv, const struct timezone *tz) -{ - SYSTEMTIME st; - struct tm *ptm; - int res; - - tz = tz; /* silence warning about unused variable */ - - ptm = gmtime (&tv->tv_sec); - st.wYear = ptm->tm_year + 1900; - st.wMonth = ptm->tm_mon + 1; - st.wDayOfWeek = ptm->tm_wday; - st.wDay = ptm->tm_mday; - st.wHour = ptm->tm_hour; - st.wMinute = ptm->tm_min; - st.wSecond = ptm->tm_sec; - st.wMilliseconds = tv->tv_usec / 1000; - - res = !SetSystemTime (&st); - - syscall_printf ("%d = settimeofday (%x, %x)", res, tv, tz); - - return res; -} - -/* timezone: standards? */ -extern "C" char * -timezone (void) -{ - char *b = _my_tls.locals.timezone_buf; - - tzset (); - __small_sprintf (b,"GMT%+d:%02d", (int) (-_timezone / 3600), (int) (abs (_timezone / 60) % 60)); - return b; -} - -/* Cygwin internal */ -void __stdcall -totimeval (struct timeval *dst, FILETIME *src, int sub, int flag) -{ - long long x = __to_clock_t (src, flag); - - x *= (int) (1e6) / CLOCKS_PER_SEC; /* Turn x into usecs */ - x -= (long long) sub * (int) (1e6); - - dst->tv_usec = x % (long long) (1e6); /* And split */ - dst->tv_sec = x / (long long) (1e6); -} - -hires_ms NO_COPY gtod; - -/* FIXME: Make thread safe */ -extern "C" int -gettimeofday (struct timeval *tv, void *tzvp) -{ - struct timezone *tz = (struct timezone *) tzvp; - static bool tzflag; - LONGLONG now = gtod.usecs (); - - if (now == (LONGLONG) -1) - return -1; - - tv->tv_sec = now / 1000000; - tv->tv_usec = now % 1000000; - - if (tz != NULL) - { - if (!tzflag) - { - tzset (); - tzflag = true; - } - tz->tz_minuteswest = _timezone / 60; - tz->tz_dsttime = _daylight; - } - - return 0; -} - -EXPORT_ALIAS (gettimeofday, _gettimeofday) - -/* Cygwin internal */ -void -time_t_to_filetime (time_t time_in, FILETIME *out) -{ - long long x = time_in * NSPERSEC + FACTOR; - out->dwHighDateTime = x >> 32; - out->dwLowDateTime = x; -} - -/* Cygwin internal */ -void __stdcall -timespec_to_filetime (const struct timespec *time_in, FILETIME *out) -{ - if (time_in->tv_nsec == UTIME_OMIT) - out->dwHighDateTime = out->dwLowDateTime = 0; - else - { - long long x = time_in->tv_sec * NSPERSEC + - time_in->tv_nsec / (1000000000/NSPERSEC) + FACTOR; - out->dwHighDateTime = x >> 32; - out->dwLowDateTime = x; - } -} - -/* Cygwin internal */ -void __stdcall -timeval_to_filetime (const struct timeval *time_in, FILETIME *out) -{ - long long x = time_in->tv_sec * NSPERSEC + - time_in->tv_usec * (NSPERSEC/1000000) + FACTOR; - out->dwHighDateTime = x >> 32; - out->dwLowDateTime = x; -} - -/* Cygwin internal */ -static timeval __stdcall -time_t_to_timeval (time_t in) -{ - timeval res; - res.tv_sec = in; - res.tv_usec = 0; - return res; -} - -/* Cygwin internal */ -static const struct timespec * -timeval_to_timespec (const struct timeval *tvp, struct timespec *tmp) -{ - if (!tvp) - return NULL; - - tmp[0].tv_sec = tvp[0].tv_sec; - tmp[0].tv_nsec = tvp[0].tv_usec * 1000; - if (tmp[0].tv_nsec < 0) - tmp[0].tv_nsec = 0; - else if (tmp[0].tv_nsec > 999999999) - tmp[0].tv_nsec = 999999999; - - tmp[1].tv_sec = tvp[1].tv_sec; - tmp[1].tv_nsec = tvp[1].tv_usec * 1000; - if (tmp[1].tv_nsec < 0) - tmp[1].tv_nsec = 0; - else if (tmp[1].tv_nsec > 999999999) - tmp[1].tv_nsec = 999999999; - - return tmp; -} - -/* Cygwin internal */ -/* Convert a Win32 time to "UNIX" format. */ -long __stdcall -to_time_t (FILETIME *ptr) -{ - /* A file time is the number of 100ns since jan 1 1601 - stuffed into two long words. - A time_t is the number of seconds since jan 1 1970. */ - - long long x = ((long long) ptr->dwHighDateTime << 32) + ((unsigned)ptr->dwLowDateTime); - - /* pass "no time" as epoch */ - if (x == 0) - return 0; - - x -= FACTOR; /* number of 100ns between 1601 and 1970 */ - x /= (long long) NSPERSEC; /* number of 100ns in a second */ - return x; -} - -/* Cygwin internal */ -/* Convert a Win32 time to "UNIX" timestruc_t format. */ -void __stdcall -to_timestruc_t (FILETIME *ptr, timestruc_t *out) -{ - /* A file time is the number of 100ns since jan 1 1601 - stuffed into two long words. - A timestruc_t is the number of seconds and microseconds since jan 1 1970 - stuffed into a time_t and a long. */ - - long rem; - long long x = ((long long) ptr->dwHighDateTime << 32) + ((unsigned)ptr->dwLowDateTime); - - /* pass "no time" as epoch */ - if (x == 0) - { - out->tv_sec = 0; - out->tv_nsec = 0; - return; - } - - x -= FACTOR; /* number of 100ns between 1601 and 1970 */ - rem = x % ((long long)NSPERSEC); - x /= (long long) NSPERSEC; /* number of 100ns in a second */ - out->tv_nsec = rem * 100; /* as tv_nsec is in nanoseconds */ - out->tv_sec = x; -} - -/* Cygwin internal */ -/* Get the current time as a "UNIX" timestruc_t format. */ -void __stdcall -time_as_timestruc_t (timestruc_t * out) -{ - FILETIME filetime; - - GetSystemTimeAsFileTime (&filetime); - to_timestruc_t (&filetime, out); -} - -/* time: POSIX 4.5.1.1, C 4.12.2.4 */ -/* Return number of seconds since 00:00 UTC on jan 1, 1970 */ -extern "C" time_t -time (time_t * ptr) -{ - time_t res; - FILETIME filetime; - - GetSystemTimeAsFileTime (&filetime); - res = to_time_t (&filetime); - if (ptr) - *ptr = res; - - syscall_printf ("%d = time (%x)", res, ptr); - - return res; -} - -/* - * localtime_r.c - * Original Author: Adapted from tzcode maintained by Arthur David Olson. - * - * Converts the calendar time pointed to by tim_p into a broken-down time - * expressed as local time. Returns a pointer to a structure containing the - * broken-down time. - */ - -#define SECSPERMIN 60 -#define MINSPERHOUR 60 -#define HOURSPERDAY 24 -#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) -#define SECSPERDAY (SECSPERHOUR * HOURSPERDAY) -#define DAYSPERWEEK 7 -#define MONSPERYEAR 12 - -#define YEAR_BASE 1900 -#define EPOCH_YEAR 1970 -#define EPOCH_WDAY 4 - -#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0) - -#if 0 /* POSIX_LOCALTIME */ - -static _CONST int mon_lengths[2][MONSPERYEAR] = { - {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, - {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} -}; - -static _CONST int year_lengths[2] = { - 365, - 366 -}; - -/* - * Convert a time_t into a struct tm *. - * Does NO timezone conversion. - */ - -/* Cygwin internal */ -static struct tm * __stdcall -corelocaltime (const time_t * tim_p) -{ - long days, rem; - int y; - int yleap; - _CONST int *ip; - struct tm &localtime_buf=_my_tls.locals.localtime_buf; - - time_t tim = *tim_p; - struct tm *res = &localtime_buf; - - days = ((long) tim) / SECSPERDAY; - rem = ((long) tim) % SECSPERDAY; - - while (rem < 0) - { - rem += SECSPERDAY; - --days; - } - while (rem >= SECSPERDAY) - { - rem -= SECSPERDAY; - ++days; - } - - /* compute hour, min, and sec */ - res->tm_hour = (int) (rem / SECSPERHOUR); - rem %= SECSPERHOUR; - res->tm_min = (int) (rem / SECSPERMIN); - res->tm_sec = (int) (rem % SECSPERMIN); - - /* compute day of week */ - if ((res->tm_wday = ((EPOCH_WDAY + days) % DAYSPERWEEK)) < 0) - res->tm_wday += DAYSPERWEEK; - - /* compute year & day of year */ - y = EPOCH_YEAR; - if (days >= 0) - { - for (;;) - { - yleap = isleap (y); - if (days < year_lengths[yleap]) - break; - y++; - days -= year_lengths[yleap]; - } - } - else - { - do - { - --y; - yleap = isleap (y); - days += year_lengths[yleap]; - } while (days < 0); - } - - res->tm_year = y - YEAR_BASE; - res->tm_yday = days; - ip = mon_lengths[yleap]; - for (res->tm_mon = 0; days >= ip[res->tm_mon]; ++res->tm_mon) - days -= ip[res->tm_mon]; - res->tm_mday = days + 1; - - /* set daylight saving time flag */ - res->tm_isdst = -1; - - syscall_printf ("%d = corelocaltime (%x)", res, tim_p); - - return (res); -} - -/* localtime: POSIX 8.1.1, C 4.12.3.4 */ -/* - * localtime takes a time_t (which is in UTC) - * and formats it into a struct tm as a local time. - */ -extern "C" struct tm * -localtime (const time_t *tim_p) -{ - time_t tim = *tim_p; - struct tm *rtm; - - tzset (); - - tim -= _timezone; - - rtm = corelocaltime (&tim); - - rtm->tm_isdst = _daylight; - - syscall_printf ("%x = localtime (%x)", rtm, tim_p); - - return rtm; -} - -/* gmtime: C 4.12.3.3 */ -/* - * gmtime takes a time_t (which is already in UTC) - * and just puts it into a struct tm. - */ -extern "C" struct tm * -gmtime (const time_t *tim_p) -{ - time_t tim = *tim_p; - - struct tm *rtm = corelocaltime (&tim); - /* UTC has no daylight savings time */ - rtm->tm_isdst = 0; - - syscall_printf ("%x = gmtime (%x)", rtm, tim_p); - - return rtm; -} - -#endif /* POSIX_LOCALTIME */ - -int -utimens_worker (path_conv &win32, const struct timespec *tvp) -{ - int res = -1; - - if (win32.error) - set_errno (win32.error); - else - { - fhandler_base *fh = NULL; - bool fromfd = false; - - cygheap_fdenum cfd (true); - while (cfd.next () >= 0) - if (cfd->get_access () & (FILE_WRITE_ATTRIBUTES | GENERIC_WRITE) - && RtlEqualUnicodeString (cfd->pc.get_nt_native_path (), - win32.get_nt_native_path (), - cfd->pc.objcaseinsensitive ())) - { - fh = cfd; - fromfd = true; - break; - } - - if (!fh) - { - if (!(fh = build_fh_pc (win32))) - goto error; - - if (fh->error ()) - { - debug_printf ("got %d error from build_fh_pc", fh->error ()); - set_errno (fh->error ()); - } - } - - res = fh->utimens (tvp); - - if (!fromfd) - delete fh; - } - -error: - syscall_printf ("%d = utimes (%S, %p)", - res, win32.get_nt_native_path (), tvp); - return res; -} - -/* utimes: POSIX/SUSv3 */ -extern "C" int -utimes (const char *path, const struct timeval *tvp) -{ - path_conv win32 (path, PC_POSIX | PC_SYM_FOLLOW, stat_suffixes); - struct timespec tmp[2]; - return utimens_worker (win32, timeval_to_timespec (tvp, tmp)); -} - -/* BSD */ -extern "C" int -lutimes (const char *path, const struct timeval *tvp) -{ - path_conv win32 (path, PC_POSIX | PC_SYM_NOFOLLOW, stat_suffixes); - struct timespec tmp[2]; - return utimens_worker (win32, timeval_to_timespec (tvp, tmp)); -} - -/* futimens: POSIX/SUSv4 */ -extern "C" int -futimens (int fd, const struct timespec *tvp) -{ - int res; - - cygheap_fdget cfd (fd); - if (cfd < 0) - res = -1; - else if (cfd->get_access () & (FILE_WRITE_ATTRIBUTES | GENERIC_WRITE)) - res = cfd->utimens (tvp); - else - res = utimens_worker (cfd->pc, tvp); - syscall_printf ("%d = futimens (%d, %p)", res, fd, tvp); - return res; -} - -/* BSD */ -extern "C" int -futimes (int fd, const struct timeval *tvp) -{ - struct timespec tmp[2]; - return futimens (fd, timeval_to_timespec (tvp, tmp)); -} - -/* utime: POSIX 5.6.6.1 */ -extern "C" int -utime (const char *path, const struct utimbuf *buf) -{ - struct timeval tmp[2]; - - if (buf == 0) - return utimes (path, 0); - - debug_printf ("incoming utime act %x", buf->actime); - tmp[0] = time_t_to_timeval (buf->actime); - tmp[1] = time_t_to_timeval (buf->modtime); - - return utimes (path, tmp); -} - -/* ftime: standards? */ -extern "C" int -ftime (struct timeb *tp) -{ - struct timeval tv; - struct timezone tz; - - if (gettimeofday (&tv, &tz) < 0) - return -1; - - tp->time = tv.tv_sec; - tp->millitm = tv.tv_usec / 1000; - tp->timezone = tz.tz_minuteswest; - tp->dstflag = tz.tz_dsttime; - - return 0; -} - -/* obsolete, changed to cygwin_tzset when localtime.c was added - dj */ -extern "C" void -cygwin_tzset () -{ -} - -#define stupid_printf if (cygwin_finished_initializing) debug_printf -void -hires_us::prime () -{ - LARGE_INTEGER ifreq; - if (!QueryPerformanceFrequency (&ifreq)) - { - inited = -1; - return; - } - - int priority = GetThreadPriority (GetCurrentThread ()); - - SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_TIME_CRITICAL); - if (!QueryPerformanceCounter (&primed_pc)) - { - SetThreadPriority (GetCurrentThread (), priority); - inited = -1; - return; - } - - primed_ft.QuadPart = systime (); - freq = (double) ((double) 1000000. / (double) ifreq.QuadPart); - inited = true; - SetThreadPriority (GetCurrentThread (), priority); -} - -LONGLONG -hires_us::usecs (bool justdelta) -{ - if (!inited) - prime (); - if (inited < 0) - { - set_errno (ENOSYS); - return (long long) -1; - } - - LARGE_INTEGER now; - if (!QueryPerformanceCounter (&now)) - { - set_errno (ENOSYS); - return -1; - } - - // FIXME: Use round() here? - now.QuadPart = (LONGLONG) (freq * (double) (now.QuadPart - primed_pc.QuadPart)); - LONGLONG res = justdelta ? now.QuadPart : primed_ft.QuadPart + now.QuadPart; - return res; -} - -void -hires_ms::prime () -{ - if (!inited) - { - int priority = GetThreadPriority (GetCurrentThread ()); - SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_TIME_CRITICAL); - initime_ns = systime_ns () - (((LONGLONG) timeGetTime ()) * 10000LL); - inited = true; - SetThreadPriority (GetCurrentThread (), priority); - } - return; -} - -LONGLONG -hires_ms::nsecs () -{ - if (!inited) - prime (); - - LONGLONG t = systime_ns (); - LONGLONG res = initime_ns + (((LONGLONG) timeGetTime ()) * 10000LL); - if (res < (t - 40 * 10000LL)) - { - inited = false; - prime (); - res = initime_ns + (((LONGLONG) timeGetTime ()) * 10000LL); - } - return res; -} - -extern "C" int -clock_gettime (clockid_t clk_id, struct timespec *tp) -{ - if (clk_id != CLOCK_REALTIME) - { - set_errno (ENOSYS); - return -1; - } - - LONGLONG now = gtod.nsecs (); - if (now == (LONGLONG) -1) - return -1; - - tp->tv_sec = now / NSPERSEC; - tp->tv_nsec = (now % NSPERSEC) * (1000000000 / NSPERSEC); - return 0; -} - -static DWORD minperiod; // FIXME: Maintain period after a fork. - -UINT -hires_ms::resolution () -{ - if (!minperiod) - { - /* Try to empirically determine current timer resolution */ - int priority = GetThreadPriority (GetCurrentThread ()); - SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_TIME_CRITICAL); - DWORD period = 0; - for (int i = 0; i < 4; i++) - { - DWORD now; - DWORD then = timeGetTime (); - while ((now = timeGetTime ()) == then) - continue; - then = now; - while ((now = timeGetTime ()) == then) - continue; - period += now - then; - } - SetThreadPriority (GetCurrentThread (), priority); - period /= 4; - minperiod = period; - } - return minperiod; -} - -extern "C" int -clock_getres (clockid_t clk_id, struct timespec *tp) -{ - if (clk_id != CLOCK_REALTIME) - { - set_errno (ENOSYS); - return -1; - } - - DWORD period = gtod.resolution (); - - tp->tv_sec = period / 1000; - tp->tv_nsec = (period % 1000) * 1000000; - - return 0; -} - -extern "C" int -clock_setres (clockid_t clk_id, struct timespec *tp) -{ - static NO_COPY bool period_set; - if (clk_id != CLOCK_REALTIME) - { - set_errno (ENOSYS); - return -1; - } - - if (period_set) - timeEndPeriod (minperiod); - - DWORD period = (tp->tv_sec * 1000) + ((tp->tv_nsec) / 1000000); - - if (timeBeginPeriod (period)) - { - minperiod = period; - period_set = true; - } - else - { - __seterrno (); - timeBeginPeriod (minperiod); - return -1; - } - - return 0; -} diff --git a/winsup/cygwin/tls_pbuf.cc b/winsup/cygwin/tls_pbuf.cc deleted file mode 100644 index 1f4b74807..000000000 --- a/winsup/cygwin/tls_pbuf.cc +++ /dev/null @@ -1,59 +0,0 @@ -/* tls_pbuf.cc - - Copyright 2008 Red Hat, Inc. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include -#include -#include "cygtls.h" -#include "tls_pbuf.h" - -#define tls_pbuf _my_tls.locals.pathbufs - -void -tls_pathbuf::destroy () -{ - for (int i = 0; i < TP_NUM_C_BUFS; ++i) - if (c_buf[i]) - free (c_buf[i]); - for (int i = 0; i < TP_NUM_W_BUFS; ++i) - if (w_buf[i]) - free (w_buf[i]); -} - -tmp_pathbuf::tmp_pathbuf () -: c_buf_old (tls_pbuf.c_cnt), - w_buf_old (tls_pbuf.w_cnt) -{} - -tmp_pathbuf::~tmp_pathbuf () -{ - tls_pbuf.c_cnt = c_buf_old; - tls_pbuf.w_cnt = w_buf_old; -} - -char * -tmp_pathbuf::c_get () -{ - if (tls_pbuf.c_cnt >= TP_NUM_C_BUFS) - api_fatal ("Internal error: TP_NUM_C_BUFS too small."); - if (!tls_pbuf.c_buf[tls_pbuf.c_cnt] - && !(tls_pbuf.c_buf[tls_pbuf.c_cnt] = (char *) malloc (NT_MAX_PATH))) - api_fatal ("Internal error: Out of memory for new path buf."); - return tls_pbuf.c_buf[tls_pbuf.c_cnt++]; -} - -PWCHAR -tmp_pathbuf::w_get () -{ - if (tls_pbuf.w_cnt >= TP_NUM_W_BUFS) - api_fatal ("Internal error: TP_NUM_W_BUFS too small."); - if (!tls_pbuf.w_buf[tls_pbuf.w_cnt] - && !(tls_pbuf.w_buf[tls_pbuf.w_cnt] - = (PWCHAR) malloc (NT_MAX_PATH * sizeof (WCHAR)))) - api_fatal ("Internal error: Out of memory for new wide path buf."); - return tls_pbuf.w_buf[tls_pbuf.w_cnt++]; -} diff --git a/winsup/cygwin/tls_pbuf.h b/winsup/cygwin/tls_pbuf.h deleted file mode 100644 index d4143aaf1..000000000 --- a/winsup/cygwin/tls_pbuf.h +++ /dev/null @@ -1,27 +0,0 @@ -/* tls_pbuf.h - - Copyright 2008 Red Hat, Inc. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -class tmp_pathbuf -{ - int c_buf_old; - int w_buf_old; -public: - tmp_pathbuf (); - ~tmp_pathbuf (); - - char *c_get (); /* Create temporary TLS path buf of size NT_MAX_PATH. */ - PWCHAR w_get (); /* Create temporary TLS path buf of size 2 * NT_MAX_PATH. */ - inline char *t_get () { return (char *) w_get (); } - inline PUNICODE_STRING u_get (PUNICODE_STRING up) - { - up->Length = 0; - up->MaximumLength = (NT_MAX_PATH - 1) * sizeof (WCHAR); - up->Buffer = w_get (); - return up; - } -}; diff --git a/winsup/cygwin/tlsoffsets.h b/winsup/cygwin/tlsoffsets.h deleted file mode 100644 index cdc423def..000000000 --- a/winsup/cygwin/tlsoffsets.h +++ /dev/null @@ -1,121 +0,0 @@ -//;# autogenerated: Do not edit. - -//; $tls::sizeof__cygtls = 4324; -//; $tls::func = -12700; -//; $tls::pfunc = 0; -//; $tls::el = -12696; -//; $tls::pel = 4; -//; $tls::saved_errno = -12688; -//; $tls::psaved_errno = 12; -//; $tls::sa_flags = -12684; -//; $tls::psa_flags = 16; -//; $tls::oldmask = -12680; -//; $tls::poldmask = 20; -//; $tls::deltamask = -12676; -//; $tls::pdeltamask = 24; -//; $tls::event = -12672; -//; $tls::pevent = 28; -//; $tls::errno_addr = -12668; -//; $tls::perrno_addr = 32; -//; $tls::sigmask = -12664; -//; $tls::psigmask = 36; -//; $tls::sigwait_mask = -12660; -//; $tls::psigwait_mask = 40; -//; $tls::sigwait_info = -12656; -//; $tls::psigwait_info = 44; -//; $tls::thread_context = -12652; -//; $tls::pthread_context = 48; -//; $tls::thread_id = -12440; -//; $tls::pthread_id = 260; -//; $tls::threadkill = -12436; -//; $tls::pthreadkill = 264; -//; $tls::infodata = -12432; -//; $tls::pinfodata = 268; -//; $tls::tid = -12284; -//; $tls::ptid = 416; -//; $tls::local_clib = -12280; -//; $tls::plocal_clib = 420; -//; $tls::__dontuse = -12280; -//; $tls::p__dontuse = 420; -//; $tls::locals = -11192; -//; $tls::plocals = 1508; -//; $tls::_ctinfo = -9472; -//; $tls::p_ctinfo = 3228; -//; $tls::andreas = -9468; -//; $tls::pandreas = 3232; -//; $tls::wq = -9452; -//; $tls::pwq = 3248; -//; $tls::sig = -9424; -//; $tls::psig = 3276; -//; $tls::incyg = -9420; -//; $tls::pincyg = 3280; -//; $tls::spinning = -9416; -//; $tls::pspinning = 3284; -//; $tls::stacklock = -9412; -//; $tls::pstacklock = 3288; -//; $tls::stackptr = -9408; -//; $tls::pstackptr = 3292; -//; $tls::stack = -9404; -//; $tls::pstack = 3296; -//; $tls::initialized = -8380; -//; $tls::pinitialized = 4320; -//; __DATA__ - -#define tls_func (-12700) -#define tls_pfunc (0) -#define tls_el (-12696) -#define tls_pel (4) -#define tls_saved_errno (-12688) -#define tls_psaved_errno (12) -#define tls_sa_flags (-12684) -#define tls_psa_flags (16) -#define tls_oldmask (-12680) -#define tls_poldmask (20) -#define tls_deltamask (-12676) -#define tls_pdeltamask (24) -#define tls_event (-12672) -#define tls_pevent (28) -#define tls_errno_addr (-12668) -#define tls_perrno_addr (32) -#define tls_sigmask (-12664) -#define tls_psigmask (36) -#define tls_sigwait_mask (-12660) -#define tls_psigwait_mask (40) -#define tls_sigwait_info (-12656) -#define tls_psigwait_info (44) -#define tls_thread_context (-12652) -#define tls_pthread_context (48) -#define tls_thread_id (-12440) -#define tls_pthread_id (260) -#define tls_threadkill (-12436) -#define tls_pthreadkill (264) -#define tls_infodata (-12432) -#define tls_pinfodata (268) -#define tls_tid (-12284) -#define tls_ptid (416) -#define tls_local_clib (-12280) -#define tls_plocal_clib (420) -#define tls___dontuse (-12280) -#define tls_p__dontuse (420) -#define tls_locals (-11192) -#define tls_plocals (1508) -#define tls__ctinfo (-9472) -#define tls_p_ctinfo (3228) -#define tls_andreas (-9468) -#define tls_pandreas (3232) -#define tls_wq (-9452) -#define tls_pwq (3248) -#define tls_sig (-9424) -#define tls_psig (3276) -#define tls_incyg (-9420) -#define tls_pincyg (3280) -#define tls_spinning (-9416) -#define tls_pspinning (3284) -#define tls_stacklock (-9412) -#define tls_pstacklock (3288) -#define tls_stackptr (-9408) -#define tls_pstackptr (3292) -#define tls_stack (-9404) -#define tls_pstack (3296) -#define tls_initialized (-8380) -#define tls_pinitialized (4320) diff --git a/winsup/cygwin/tty.cc b/winsup/cygwin/tty.cc deleted file mode 100644 index 624805f20..000000000 --- a/winsup/cygwin/tty.cc +++ /dev/null @@ -1,407 +0,0 @@ -/* tty.cc - - Copyright 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 - Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "miscfuncs.h" -#include -#include -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "pinfo.h" -#include "shared_info.h" - -extern fhandler_tty_master *tty_master; - -extern "C" int -posix_openpt (int oflags) -{ - return open ("/dev/ptmx", oflags); -} - -extern "C" int -grantpt (int fd) -{ - return 0; -} - -extern "C" int -unlockpt (int fd) -{ - return 0; -} - -extern "C" int -revoke (char *ttyname) -{ - set_errno (ENOSYS); - return -1; -} - -extern "C" int -ttyslot (void) -{ - if (NOTSTATE (myself, PID_USETTY)) - return -1; - return myself->ctty; -} - -HANDLE NO_COPY tty_list::mutex = NULL; - -void __stdcall -tty_list::init_session () -{ - char mutex_name[MAX_PATH]; - /* tty_list::mutex is used while searching for a tty slot. It's necessary - while finding console window handle */ - - char *name = shared_name (mutex_name, "tty_list::mutex", 0); - if (!(mutex = CreateMutex (&sec_all_nih, FALSE, name))) - api_fatal ("can't create tty_list::mutex '%s', %E", name); - ProtectHandle (mutex); -} - -void __stdcall -tty::init_session () -{ - if (!myself->cygstarted && NOTSTATE (myself, PID_CYGPARENT)) - cygheap->fdtab.get_debugger_info (); - - if (NOTSTATE (myself, PID_USETTY)) - return; - if (myself->ctty != -1) - /* nothing to do */; - else if (NOTSTATE (myself, PID_CYGPARENT)) - myself->ctty = cygwin_shared->tty.attach (myself->ctty); - else - return; - if (myself->ctty == -1) - termios_printf ("Can't attach to tty"); -} - -/* Create session's master tty */ - -void __stdcall -tty::create_master (int ttynum) -{ - device ttym = *ttym_dev; - ttym.setunit (ttynum); /* CGF FIXME device */ - tty_master = (fhandler_tty_master *) build_fh_dev (ttym); - if (tty_master->init ()) - api_fatal ("can't create master tty"); - else - { - /* Log utmp entry */ - struct utmp our_utmp; - DWORD len = sizeof our_utmp.ut_host; - - bzero ((char *) &our_utmp, sizeof (utmp)); - time (&our_utmp.ut_time); - strncpy (our_utmp.ut_name, getlogin (), sizeof (our_utmp.ut_name)); - GetComputerName (our_utmp.ut_host, &len); - __small_sprintf (our_utmp.ut_line, "tty%d", ttynum); - if ((len = strlen (our_utmp.ut_line)) >= UT_IDLEN) - len -= UT_IDLEN; - else - len = 0; - strncpy (our_utmp.ut_id, our_utmp.ut_line + len, UT_IDLEN); - our_utmp.ut_type = USER_PROCESS; - our_utmp.ut_pid = myself->pid; - myself->ctty = ttynum; - login (&our_utmp); - } -} - -int __stdcall -tty_list::attach (int num) -{ - if (num != -1) - { - return connect (num); - } - if (NOTSTATE (myself, PID_USETTY)) - return -1; - return allocate (true); -} - -void -tty_list::terminate () -{ - if (NOTSTATE (myself, PID_USETTY)) - return; - int ttynum = myself->ctty; - - /* Keep master running till there are connected clients */ - if (ttynum != -1 && tty_master && ttys[ttynum].master_pid == myself->pid) - { - tty *t = ttys + ttynum; - /* Wait for children which rely on tty handling in this process to - go away */ - for (int i = 0; ; i++) - { - if (!t->slave_alive ()) - break; - if (i >= 100) - { - small_printf ("waiting for children using tty%d to terminate\n", - ttynum); - i = 0; - } - - low_priority_sleep (200); - } - - lock_ttys here (); - CloseHandle (tty_master->from_master); - CloseHandle (tty_master->to_master); - - termios_printf ("tty %d master about to finish", ttynum); - CloseHandle (tty_master->get_io_handle ()); - CloseHandle (tty_master->get_output_handle ()); - - t->init (); - - char buf[20]; - __small_sprintf (buf, "tty%d", ttynum); - logout (buf); - } -} - -int -tty_list::connect (int ttynum) -{ - if (ttynum < 0 || ttynum >= NTTYS) - { - termios_printf ("ttynum (%d) out of range", ttynum); - return -1; - } - if (!ttys[ttynum].exists ()) - { - termios_printf ("tty %d was not allocated", ttynum); - return -1; - } - - return ttynum; -} - -void -tty_list::init () -{ - for (int i = 0; i < NTTYS; i++) - { - ttys[i].init (); - ttys[i].setntty (i); - } -} - -/* Search for tty class for our console. Allocate new tty if our process is - the only cygwin process in the current console. - Return tty number or -1 if error. - If with_console == 0, just find a free tty. - */ -int -tty_list::allocate (bool with_console) -{ - HWND console; - int freetty = -1; - HANDLE hmaster = NULL; - - lock_ttys here; - - if (!with_console) - console = NULL; - else if (!(console = GetConsoleWindow ())) - { - termios_printf ("Can't find console window"); - goto out; - } - - /* Is a tty allocated for console? */ - for (int i = 0; i < NTTYS; i++) - { - if (!ttys[i].exists ()) - { - if (freetty < 0) /* Scanning? */ - freetty = i; /* Yes. */ - if (!with_console) /* Do we want to attach this to a console? */ - break; /* No. We've got one. */ - } - - /* FIXME: Is this right? We can potentially query a "nonexistent" - tty slot after falling through from the above? */ - if (with_console && ttys[i].gethwnd () == console) - { - termios_printf ("console %x already associated with tty%d", - console, i); - /* Is the master alive? */ - hmaster = OpenProcess (PROCESS_DUP_HANDLE, FALSE, ttys[i].master_pid); - if (hmaster) - { - CloseHandle (hmaster); - freetty = i; - goto out; - } - /* Master is dead */ - freetty = i; - break; - } - } - - /* There is no tty allocated to console; allocate the first free found */ - if (freetty == -1) - goto out; - - tty *t; - t = ttys + freetty; - t->init (); - t->setsid (-1); - t->sethwnd (console); - -out: - if (freetty < 0) - system_printf ("No tty allocated"); - else if (!with_console) - { - termios_printf ("tty%d allocated", freetty); - here.dont_release (); /* exit with mutex still held -- caller has more work to do */ - } - else - { - termios_printf ("console %p associated with tty%d", console, freetty); - if (!hmaster) - tty::create_master (freetty); - } - return freetty; -} - -bool -tty::slave_alive () -{ - return alive (TTY_SLAVE_ALIVE); -} - -bool -tty::exists () -{ - /* Attempt to open the from-master side of the tty. If it is accessible - then it exists although it may have been privileges to actually use it. */ - char pipename[sizeof("ttyNNNN-from-master")]; - __small_sprintf (pipename, "tty%d-from-master", ntty); - HANDLE r, w; - int res = fhandler_pipe::create_selectable (&sec_none_nih, r, w, 0, pipename); - if (res) - return true; - - CloseHandle (r); - CloseHandle (w); - - HANDLE h = open_output_mutex (); - if (h) - { - CloseHandle (h); - return true; - } - return slave_alive (); -} - -bool -tty::alive (const char *fmt) -{ - HANDLE ev; - char buf[MAX_PATH]; - - shared_name (buf, fmt, ntty); - if ((ev = OpenEvent (EVENT_ALL_ACCESS, FALSE, buf))) - CloseHandle (ev); - return ev != NULL; -} - -HANDLE -tty::open_output_mutex () -{ - return open_mutex (OUTPUT_MUTEX); -} - -HANDLE -tty::open_input_mutex () -{ - return open_mutex (INPUT_MUTEX); -} - -HANDLE -tty::open_mutex (const char *mutex) -{ - char buf[MAX_PATH]; - shared_name (buf, mutex, ntty); - return OpenMutex (MUTEX_ALL_ACCESS, TRUE, buf); -} - -HANDLE -tty::create_inuse (const char *fmt) -{ - HANDLE h; - char buf[MAX_PATH]; - - shared_name (buf, fmt, ntty); - h = CreateEvent (&sec_all, TRUE, FALSE, buf); - termios_printf ("%s %p", buf, h); - if (!h) - termios_printf ("couldn't open inuse event, %E", buf); - return h; -} - -void -tty::init () -{ - output_stopped = 0; - setsid (0); - pgid = 0; - hwnd = NULL; - was_opened = 0; - master_pid = 0; -} - -HANDLE -tty::get_event (const char *fmt, BOOL manual_reset) -{ - HANDLE hev; - char buf[MAX_PATH]; - - shared_name (buf, fmt, ntty); - if (!(hev = CreateEvent (&sec_all, manual_reset, FALSE, buf))) - { - termios_printf ("couldn't create %s", buf); - set_errno (ENOENT); /* FIXME this can't be the right errno */ - return NULL; - } - - termios_printf ("created event %s", buf); - return hev; -} - -lock_ttys::lock_ttys (DWORD howlong): release_me (true) -{ - if (WaitForSingleObject (tty_list::mutex, howlong) == WAIT_FAILED) - { - termios_printf ("WFSO for mutex %p failed, %E", tty_list::mutex); - release_me = false; - } -} - -void -lock_ttys::release () -{ - ReleaseMutex (tty_list::mutex); -} diff --git a/winsup/cygwin/tty.h b/winsup/cygwin/tty.h deleted file mode 100644 index b4c02a411..000000000 --- a/winsup/cygwin/tty.h +++ /dev/null @@ -1,143 +0,0 @@ -/* tty.h: shared tty info for cygwin - - Copyright 2000, 2001, 2002, 2003, 2004, 2006 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -/* tty tables */ - -#define INP_BUFFER_SIZE 256 -#define OUT_BUFFER_SIZE 256 -#define NTTYS 128 -#define real_tty_attached(p) ((p)->ctty >= 0 && (p)->ctty != TTY_CONSOLE) - -/* Input/Output/ioctl events */ - -#define OUTPUT_DONE_EVENT "cygtty.output.done" -#define IOCTL_REQUEST_EVENT "cygtty.ioctl.request" -#define IOCTL_DONE_EVENT "cygtty.ioctl.done" -#define RESTART_OUTPUT_EVENT "cygtty.output.restart" -#define INPUT_AVAILABLE_EVENT "cygtty.input.avail" -#define OUTPUT_MUTEX "cygtty.output.mutex" -#define INPUT_MUTEX "cygtty.input.mutex" -#define TTY_SLAVE_ALIVE "cygtty.slave_alive" -#define TTY_MASTER_ALIVE "cygtty.master_alive" - -#include - -#ifndef MIN_CTRL_C_SLOP -#define MIN_CTRL_C_SLOP 50 -#endif - -class tty_min -{ - pid_t sid; /* Session ID of tty */ - struct status_flags - { - unsigned initialized : 1; /* Set if tty is initialized */ - unsigned rstcons : 1; /* Set if console needs to be set to "non-cooked" */ - } status; - -public: - pid_t pgid; - int output_stopped; - int ntty; - DWORD last_ctrl_c; /* tick count of last ctrl-c */ - HWND hwnd; /* Console window handle tty belongs to */ - - IMPLEMENT_STATUS_FLAG (bool, initialized) - IMPLEMENT_STATUS_FLAG (bool, rstcons) - - struct termios ti; - struct winsize winsize; - - /* ioctl requests buffer */ - int cmd; - union - { - struct termios termios; - struct winsize winsize; - int value; - pid_t pid; - } arg; - /* XXX_retval variables holds master's completion codes. Error are stored as - * -ERRNO - */ - int ioctl_retval; - int write_error; - - void setntty (int n) {ntty = n;} - pid_t getpgid () {return pgid;} - void setpgid (int pid) {pgid = pid;} - int getsid () {return sid;} - void setsid (pid_t tsid) {sid = tsid;} - void kill_pgrp (int sig); - HWND gethwnd () {return hwnd;} - void sethwnd (HWND wnd) {hwnd = wnd;} -}; - -class fhandler_pty_master; - -class tty: public tty_min -{ - HANDLE get_event (const char *fmt, BOOL manual_reset = FALSE) - __attribute__ ((regparm (3))); -public: - pid_t master_pid; /* PID of tty master process */ - - HANDLE from_master, to_master; - - int read_retval; - bool was_opened; /* True if opened at least once. */ - - void init (); - HANDLE create_inuse (const char *); - bool alive (const char *fmt); - bool slave_alive (); - bool master_alive (); - HANDLE open_mutex (const char *mutex); - HANDLE open_output_mutex (); - HANDLE open_input_mutex (); - bool exists (); - void set_master_closed () {master_pid = -1;} - static void __stdcall create_master (int); - static void __stdcall init_session (); - friend class fhandler_pty_master; -}; - -class tty_list -{ - tty ttys[NTTYS]; - static HANDLE mutex; - -public: - tty * operator [](int n) {return ttys + n;} - int allocate (bool); /* true if allocate a tty, pty otherwise */ - int connect (int); - void terminate (); - void init (); - tty_min *get_tty (int n); - int __stdcall attach (int); - static void __stdcall init_session (); - friend class lock_ttys; -}; - -class lock_ttys -{ - bool release_me; -public: - lock_ttys (DWORD = INFINITE); - static void release (); - void dont_release () {release_me = false;} - ~lock_ttys () - { - if (release_me) - release (); - } -}; - -extern "C" int ttyslot (void); diff --git a/winsup/cygwin/tz_posixrules.h b/winsup/cygwin/tz_posixrules.h deleted file mode 100644 index dea668e2f..000000000 --- a/winsup/cygwin/tz_posixrules.h +++ /dev/null @@ -1,48 +0,0 @@ -/* generated with bin2h from zoneinfo/posixrules */ - -static NO_COPY unsigned char _posixrules_data[] = { -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0, -0,1,16,0,0,0,2,0,0,0,8,0,151,254,240,1,135,225,224,2,119,224,240,3,112,254,96,4,96,253,112,5,80, -224,96,6,64,223,112,7,48,194,96,7,141,25,112,9,16,164,96,9,173,148,240,10,240,134,96,11,224,133,112,12,217,162, -224,13,192,103,112,14,185,132,224,15,169,131,240,16,153,102,224,17,137,101,240,18,121,72,224,19,105,71,240,20,89,42,224, -21,73,41,240,22,57,12,224,23,41,11,240,24,34,41,96,25,8,237,240,26,2,11,96,26,242,10,112,27,225,237,96,28, -209,236,112,29,193,207,96,30,177,206,112,31,161,177,96,32,118,0,240,33,129,147,96,34,85,226,240,35,106,175,224,36,53, -196,240,37,74,145,224,38,21,166,240,39,42,115,224,39,254,195,112,41,10,85,224,41,222,165,112,42,234,55,224,43,190,135, -112,44,211,84,96,45,158,105,112,46,179,54,96,47,126,75,112,48,147,24,96,49,103,103,240,50,114,250,96,51,71,73,240, -52,82,220,96,53,39,43,240,54,50,190,96,55,7,13,240,56,27,218,224,56,230,239,240,57,251,188,224,58,198,209,240,59, -219,158,224,60,175,238,112,61,187,128,224,62,143,208,112,63,155,98,224,64,111,178,112,65,132,127,96,66,79,148,112,67,100, -97,96,68,47,118,112,69,68,67,96,70,15,88,112,71,36,37,96,71,248,116,240,73,4,7,96,73,216,86,240,74,227,233, -96,75,184,56,240,76,205,5,224,77,152,26,240,78,172,231,224,79,119,252,240,80,140,201,224,81,97,25,112,82,108,171,224, -83,64,251,112,84,76,141,224,85,32,221,112,86,44,111,224,87,0,191,112,88,21,140,96,88,224,161,112,89,245,110,96,90, -192,131,112,91,213,80,96,92,169,159,240,93,181,50,96,94,137,129,240,95,149,20,96,96,105,99,240,97,126,48,224,98,73, -69,240,99,94,18,224,100,41,39,240,101,61,244,224,102,18,68,112,103,29,214,224,103,242,38,112,104,253,184,224,105,210,8, -112,106,221,154,224,107,177,234,112,108,198,183,96,109,145,204,112,110,166,153,96,111,113,174,112,112,134,123,96,113,90,202,240, -114,102,93,96,115,58,172,240,116,70,63,96,117,26,142,240,118,47,91,224,118,250,112,240,120,15,61,224,120,218,82,240,121, -239,31,224,122,186,52,240,123,207,1,224,124,163,81,112,125,174,227,224,126,131,51,112,127,142,197,224,128,99,21,112,129,119, -226,96,130,66,247,112,131,87,196,96,132,34,217,112,133,55,166,96,134,11,245,240,135,23,136,96,135,235,215,240,136,247,106, -96,137,203,185,240,138,215,76,96,139,171,155,240,140,192,104,224,141,139,125,240,142,160,74,224,143,107,95,240,144,128,44,224, -145,84,124,112,146,96,14,224,147,52,94,112,148,63,240,224,149,20,64,112,150,41,13,96,150,244,34,112,152,8,239,96,152, -212,4,112,153,232,209,96,154,189,32,240,155,200,179,96,156,157,2,240,157,168,149,96,158,124,228,240,159,136,119,96,160,92, -198,240,161,113,147,224,162,60,168,240,163,81,117,224,164,28,138,240,165,49,87,224,166,5,167,112,167,17,57,224,167,229,137, -112,168,241,27,224,169,197,107,112,170,218,56,96,171,165,77,112,172,186,26,96,173,133,47,112,174,153,252,96,175,101,17,112, -176,121,222,96,177,78,45,240,178,89,192,96,179,46,15,240,180,57,162,96,181,13,241,240,182,34,190,224,182,237,211,240,184, -2,160,224,184,205,181,240,185,226,130,224,186,182,210,112,187,194,100,224,188,150,180,112,189,162,70,224,190,118,150,112,191,130, -40,224,192,86,120,112,193,107,69,96,194,54,90,112,195,75,39,96,196,22,60,112,197,43,9,96,197,255,88,240,199,10,235, -96,199,223,58,240,200,234,205,96,201,191,28,240,202,211,233,224,203,158,254,240,204,179,203,224,205,126,224,240,206,147,173,224, -207,103,253,112,208,115,143,224,209,71,223,112,210,83,113,224,211,39,193,112,212,51,83,224,213,7,163,112,214,28,112,96,214, -231,133,112,215,252,82,96,216,199,103,112,217,220,52,96,218,176,131,240,219,188,22,96,220,144,101,240,221,155,248,96,222,112, -71,240,223,133,20,224,224,80,41,240,225,100,246,224,226,48,11,240,227,68,216,224,228,15,237,240,229,36,186,224,229,249,10, -112,231,4,156,224,231,216,236,112,232,228,126,224,233,184,206,112,234,205,155,96,235,152,176,112,236,173,125,96,237,120,146,112, -238,141,95,96,239,97,174,240,240,109,65,96,241,65,144,240,242,77,35,96,243,33,114,240,244,45,5,96,245,1,84,240,246, -22,33,224,246,225,54,240,247,246,3,224,248,193,24,240,249,213,229,224,250,160,250,240,251,181,199,224,252,138,23,112,253,149, -169,224,254,105,249,112,255,117,139,224,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, -1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, -0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, -1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, -0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, -1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, -0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, -1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, -0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,255,255,199,192,1,0,255,255,185,176,0,4,69,68,84, -0,69,83,84,0,0,0 -}; diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc deleted file mode 100644 index 2695d8176..000000000 --- a/winsup/cygwin/uinfo.cc +++ /dev/null @@ -1,581 +0,0 @@ -/* uinfo.cc: user info (uid, gid, etc...) - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include -#include -#include -#include -#include -#include "cygerrno.h" -#include "pinfo.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "shared_info.h" -#include "registry.h" -#include "child_info.h" -#include "environ.h" -#include "pwdgrp.h" -#include "tls_pbuf.h" -#include "ntdll.h" - -/* Initialize the part of cygheap_user that does not depend on files. - The information is used in shared.cc for the user shared. - Final initialization occurs in uinfo_init */ -void -cygheap_user::init () -{ - char user_name[UNLEN + 1]; - DWORD user_name_len = UNLEN + 1; - - set_name (GetUserName (user_name, &user_name_len) ? user_name : "unknown"); - - DWORD siz; - PSECURITY_DESCRIPTOR psd; - - if (!GetTokenInformation (hProcToken, TokenPrimaryGroup, - &groups.pgsid, sizeof (cygsid), &siz)) - system_printf ("GetTokenInformation (TokenPrimaryGroup), %E"); - - /* Get the SID from current process and store it in effec_cygsid */ - if (!GetTokenInformation (hProcToken, TokenUser, &effec_cygsid, - sizeof (cygsid), &siz)) - { - system_printf ("GetTokenInformation (TokenUser), %E"); - return; - } - - /* Set token owner to the same value as token user */ - if (!SetTokenInformation (hProcToken, TokenOwner, &effec_cygsid, - sizeof (cygsid))) - debug_printf ("SetTokenInformation(TokenOwner), %E"); - - /* Standard way to build a security descriptor with the usual DACL */ - PSECURITY_ATTRIBUTES sa_buf = (PSECURITY_ATTRIBUTES) alloca (1024); - psd = (PSECURITY_DESCRIPTOR) - (sec_user_nih (sa_buf, sid()))->lpSecurityDescriptor; - - BOOL acl_exists, dummy; - TOKEN_DEFAULT_DACL dacl; - if (GetSecurityDescriptorDacl (psd, &acl_exists, &dacl.DefaultDacl, &dummy) - && acl_exists && dacl.DefaultDacl) - { - NTSTATUS status; - - /* Set the default DACL and the process DACL */ - if (!SetTokenInformation (hProcToken, TokenDefaultDacl, &dacl, - sizeof (dacl))) - system_printf ("SetTokenInformation (TokenDefaultDacl), %E"); - if ((status = NtSetSecurityObject (NtCurrentProcess (), - DACL_SECURITY_INFORMATION, psd))) - system_printf ("NtSetSecurityObject, %lx", status); - } - else - system_printf("Cannot get dacl, %E"); -} - -void -internal_getlogin (cygheap_user &user) -{ - struct passwd *pw = NULL; - - cygpsid psid = user.sid (); - pw = internal_getpwsid (psid); - - if (!pw && !(pw = internal_getpwnam (user.name ())) - && !(pw = internal_getpwuid (DEFAULT_UID))) - debug_printf ("user not found in augmented /etc/passwd"); - else - { - cygsid gsid; - - myself->uid = pw->pw_uid; - myself->gid = pw->pw_gid; - user.set_name (pw->pw_name); - if (gsid.getfromgr (internal_getgrgid (pw->pw_gid))) - { - if (gsid != user.groups.pgsid) - { - /* Set primary group to the group in /etc/passwd. */ - if (!SetTokenInformation (hProcToken, TokenPrimaryGroup, - &gsid, sizeof gsid)) - debug_printf ("SetTokenInformation(TokenPrimaryGroup), %E"); - else - user.groups.pgsid = gsid; - clear_procimptoken (); - } - } - else - debug_printf ("gsid not found in augmented /etc/group"); - } - cygheap->user.ontherange (CH_HOME, pw); -} - -void -uinfo_init () -{ - if (child_proc_info && !cygheap->user.has_impersonation_tokens ()) - return; - - if (!child_proc_info) - internal_getlogin (cygheap->user); /* Set the cygheap->user. */ - /* Conditions must match those in spawn to allow starting child - processes with ruid != euid and rgid != egid. */ - else if (cygheap->user.issetuid () - && cygheap->user.saved_uid == cygheap->user.real_uid - && cygheap->user.saved_gid == cygheap->user.real_gid - && !cygheap->user.groups.issetgroups () - && !cygheap->user.setuid_to_restricted) - { - cygheap->user.reimpersonate (); - return; - } - else - cygheap->user.close_impersonation_tokens (); - - cygheap->user.saved_uid = cygheap->user.real_uid = myself->uid; - cygheap->user.saved_gid = cygheap->user.real_gid = myself->gid; - cygheap->user.external_token = NO_IMPERSONATION; - cygheap->user.internal_token = NO_IMPERSONATION; - cygheap->user.curr_primary_token = NO_IMPERSONATION; - cygheap->user.curr_imp_token = NO_IMPERSONATION; - cygheap->user.ext_token_is_restricted = false; - cygheap->user.curr_token_is_restricted = false; - cygheap->user.setuid_to_restricted = false; - cygheap->user.set_saved_sid (); /* Update the original sid */ - cygheap->user.deimpersonate (); -} - -extern "C" int -getlogin_r (char *name, size_t namesize) -{ - char *login = getlogin (); - size_t len = strlen (login) + 1; - if (len > namesize) - return ERANGE; - myfault efault; - if (efault.faulted ()) - return EFAULT; - strncpy (name, login, len); - return 0; -} - -extern "C" char * -getlogin (void) -{ - return strcpy (_my_tls.locals.username, cygheap->user.name ()); -} - -extern "C" __uid32_t -getuid32 (void) -{ - return cygheap->user.real_uid; -} - -extern "C" __uid16_t -getuid (void) -{ - return cygheap->user.real_uid; -} - -extern "C" __gid32_t -getgid32 (void) -{ - return cygheap->user.real_gid; -} - -extern "C" __gid16_t -getgid (void) -{ - return cygheap->user.real_gid; -} - -extern "C" __uid32_t -geteuid32 (void) -{ - return myself->uid; -} - -extern "C" __uid16_t -geteuid (void) -{ - return myself->uid; -} - -extern "C" __gid32_t -getegid32 (void) -{ - return myself->gid; -} - -extern "C" __gid16_t -getegid (void) -{ - return myself->gid; -} - -/* Not quite right - cuserid can change, getlogin can't */ -extern "C" char * -cuserid (char *src) -{ - if (!src) - return getlogin (); - - strcpy (src, getlogin ()); - return src; -} - -const char * -cygheap_user::ontherange (homebodies what, struct passwd *pw) -{ - LPUSER_INFO_3 ui = NULL; - WCHAR wuser[UNLEN + 1]; - NET_API_STATUS ret; - char homedrive_env_buf[3]; - char *newhomedrive = NULL; - char *newhomepath = NULL; - tmp_pathbuf tp; - - debug_printf ("what %d, pw %p", what, pw); - if (what == CH_HOME) - { - char *p; - - if ((p = getenv ("HOME"))) - debug_printf ("HOME is already in the environment %s", p); - else - { - if (pw && pw->pw_dir && *pw->pw_dir) - { - debug_printf ("Set HOME (from /etc/passwd) to %s", pw->pw_dir); - setenv ("HOME", pw->pw_dir, 1); - } - else - { - char home[strlen (name ()) + 8]; - - debug_printf ("Set HOME to default /home/USER"); - __small_sprintf (home, "/home/%s", name ()); - setenv ("HOME", home, 1); - } - } - } - - if (what != CH_HOME && homepath == NULL && newhomepath == NULL) - { - char *homepath_env_buf = tp.c_get (); - if (!pw) - pw = internal_getpwnam (name ()); - if (pw && pw->pw_dir && *pw->pw_dir) - cygwin_conv_path (CCP_POSIX_TO_WIN_A, pw->pw_dir, homepath_env_buf, - NT_MAX_PATH); - else - { - homepath_env_buf[0] = homepath_env_buf[1] = '\0'; - if (logsrv ()) - { - WCHAR wlogsrv[INTERNET_MAX_HOST_NAME_LENGTH + 3]; - sys_mbstowcs (wlogsrv, sizeof (wlogsrv) / sizeof (*wlogsrv), - logsrv ()); - sys_mbstowcs (wuser, sizeof (wuser) / sizeof (*wuser), winname ()); - if (!(ret = NetUserGetInfo (wlogsrv, wuser, 3, (LPBYTE *) &ui))) - { - sys_wcstombs (homepath_env_buf, NT_MAX_PATH, - ui->usri3_home_dir); - if (!homepath_env_buf[0]) - { - sys_wcstombs (homepath_env_buf, NT_MAX_PATH, - ui->usri3_home_dir_drive); - if (homepath_env_buf[0]) - strcat (homepath_env_buf, "\\"); - else - cygwin_conv_path (CCP_POSIX_TO_WIN_A | CCP_ABSOLUTE, - "/", homepath_env_buf, NT_MAX_PATH); - } - } - } - if (ui) - NetApiBufferFree (ui); - } - - if (homepath_env_buf[1] != ':') - { - newhomedrive = almost_null; - newhomepath = homepath_env_buf; - } - else - { - homedrive_env_buf[0] = homepath_env_buf[0]; - homedrive_env_buf[1] = homepath_env_buf[1]; - homedrive_env_buf[2] = '\0'; - newhomedrive = homedrive_env_buf; - newhomepath = homepath_env_buf + 2; - } - } - - if (newhomedrive && newhomedrive != homedrive) - cfree_and_set (homedrive, (newhomedrive == almost_null) - ? almost_null : cstrdup (newhomedrive)); - - if (newhomepath && newhomepath != homepath) - cfree_and_set (homepath, cstrdup (newhomepath)); - - switch (what) - { - case CH_HOMEDRIVE: - return homedrive; - case CH_HOMEPATH: - return homepath; - default: - return homepath; - } -} - -const char * -cygheap_user::test_uid (char *&what, const char *name, size_t namelen) -{ - if (!what && !issetuid ()) - what = getwinenveq (name, namelen, HEAP_STR); - return what; -} - -const char * -cygheap_user::env_logsrv (const char *name, size_t namelen) -{ - if (test_uid (plogsrv, name, namelen)) - return plogsrv; - - const char *mydomain = domain (); - const char *myname = winname (); - if (!mydomain || ascii_strcasematch (myname, "SYSTEM")) - return almost_null; - - WCHAR wdomain[MAX_DOMAIN_NAME_LEN + 1]; - WCHAR wlogsrv[INTERNET_MAX_HOST_NAME_LENGTH + 3]; - sys_mbstowcs (wdomain, MAX_DOMAIN_NAME_LEN + 1, mydomain); - cfree_and_set (plogsrv, almost_null); - if (get_logon_server (wdomain, wlogsrv, false)) - sys_wcstombs_alloc (&plogsrv, HEAP_STR, wlogsrv); - return plogsrv; -} - -const char * -cygheap_user::env_domain (const char *name, size_t namelen) -{ - if (pwinname && test_uid (pdomain, name, namelen)) - return pdomain; - - char username[UNLEN + 1]; - DWORD ulen = sizeof (username); - char userdomain[DNLEN + 1]; - DWORD dlen = sizeof (userdomain); - SID_NAME_USE use; - - cfree_and_set (pwinname, almost_null); - cfree_and_set (pdomain, almost_null); - if (!LookupAccountSid (NULL, sid (), username, &ulen, - userdomain, &dlen, &use)) - __seterrno (); - else - { - pwinname = cstrdup (username); - pdomain = cstrdup (userdomain); - } - return pdomain; -} - -const char * -cygheap_user::env_userprofile (const char *name, size_t namelen) -{ - if (test_uid (puserprof, name, namelen)) - return puserprof; - - WCHAR userprofile_env_buf[NT_MAX_PATH]; - WCHAR win_id[UNLEN + 1]; /* Large enough for SID */ - - cfree_and_set (puserprof, almost_null); - if (get_registry_hive_path (get_windows_id (win_id), userprofile_env_buf)) - sys_wcstombs_alloc (&puserprof, HEAP_STR, userprofile_env_buf); - - return puserprof; -} - -const char * -cygheap_user::env_homepath (const char *name, size_t namelen) -{ - return ontherange (CH_HOMEPATH); -} - -const char * -cygheap_user::env_homedrive (const char *name, size_t namelen) -{ - return ontherange (CH_HOMEDRIVE); -} - -const char * -cygheap_user::env_name (const char *name, size_t namelen) -{ - if (!test_uid (pwinname, name, namelen)) - domain (); - return pwinname; -} - -const char * -cygheap_user::env_systemroot (const char *name, size_t namelen) -{ - if (!psystemroot) - { - int size = GetWindowsDirectory (NULL, 0); - if (size > 0) - { - psystemroot = (char *) cmalloc_abort (HEAP_STR, ++size); - size = GetWindowsDirectory (psystemroot, size); - if (size <= 0) - { - cfree (psystemroot); - psystemroot = NULL; - } - } - if (size <= 0) - debug_printf ("GetWindowsDirectory(), %E"); - } - return psystemroot; -} - -char * -pwdgrp::next_str (char c) -{ - char *res = lptr; - lptr = strechr (lptr, c); - if (*lptr) - *lptr++ = '\0'; - return res; -} - -bool -pwdgrp::next_num (unsigned long& n) -{ - char *p = next_str (':'); - char *cp; - n = strtoul (p, &cp, 10); - return p != cp && !*cp; -} - -char * -pwdgrp::add_line (char *eptr) -{ - if (eptr) - { - lptr = eptr; - eptr = strchr (lptr, '\n'); - if (eptr) - { - if (eptr > lptr && eptr[-1] == '\r') - eptr[-1] = '\0'; - else - *eptr = '\0'; - eptr++; - } - if (curr_lines >= max_lines) - { - max_lines += 10; - *pwdgrp_buf = realloc (*pwdgrp_buf, max_lines * pwdgrp_buf_elem_size); - } - if ((this->*parse) ()) - curr_lines++; - } - return eptr; -} - -void -pwdgrp::load (const wchar_t *rel_path) -{ - static const char failed[] = "failed"; - static const char succeeded[] = "succeeded"; - const char *res = failed; - HANDLE fh = NULL; - - NTSTATUS status; - OBJECT_ATTRIBUTES attr; - IO_STATUS_BLOCK io; - FILE_STANDARD_INFORMATION fsi; - - if (buf) - free (buf); - buf = NULL; - curr_lines = 0; - - if (!path && - !(path = (PWCHAR) malloc ((wcslen (installation_root) - + wcslen (rel_path) + 1) * sizeof (WCHAR)))) - { - paranoid_printf ("malloc (%W) failed", rel_path); - goto out; - } - wcpcpy (wcpcpy (path, installation_root), rel_path); - RtlInitUnicodeString (&upath, path); - - InitializeObjectAttributes (&attr, &upath, OBJ_CASE_INSENSITIVE, NULL, NULL); - etc_ix = etc::init (etc_ix, &attr); - - paranoid_printf ("%S", &upath); - - status = NtOpenFile (&fh, SYNCHRONIZE | FILE_READ_DATA, &attr, &io, - FILE_SHARE_VALID_FLAGS, - FILE_SYNCHRONOUS_IO_NONALERT - | FILE_OPEN_FOR_BACKUP_INTENT); - if (!NT_SUCCESS (status)) - { - paranoid_printf ("NtOpenFile(%S) failed, status %p", &upath, status); - goto out; - } - status = NtQueryInformationFile (fh, &io, &fsi, sizeof fsi, - FileStandardInformation); - if (!NT_SUCCESS (status)) - { - paranoid_printf ("NtQueryInformationFile(%S) failed, status %p", - &upath, status); - goto out; - } - /* FIXME: Should we test for HighPart set? If so, the - passwd or group file is way beyond what we can handle. */ - /* FIXME 2: It's still ugly that we keep the file in memory. - Big organizations have naturally large passwd files. */ - buf = (char *) malloc (fsi.EndOfFile.LowPart + 1); - if (!buf) - { - paranoid_printf ("malloc (%d) failed", fsi.EndOfFile.LowPart); - goto out; - } - status = NtReadFile (fh, NULL, NULL, NULL, &io, buf, fsi.EndOfFile.LowPart, - NULL, NULL); - if (!NT_SUCCESS (status)) - { - paranoid_printf ("NtReadFile(%S) failed, status %p", &upath, status); - free (buf); - goto out; - } - buf[fsi.EndOfFile.LowPart] = '\0'; - for (char *eptr = buf; (eptr = add_line (eptr)); ) - continue; - debug_printf ("%W curr_lines %d", rel_path, curr_lines); - res = succeeded; - -out: - if (fh) - NtClose (fh); - debug_printf ("%W load %s", rel_path, res); - initialized = true; -} diff --git a/winsup/cygwin/uname.cc b/winsup/cygwin/uname.cc deleted file mode 100644 index 639c941f7..000000000 --- a/winsup/cygwin/uname.cc +++ /dev/null @@ -1,104 +0,0 @@ -/* uname.cc - - Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007 Red Hat, Inc. - Written by Steve Chamberlain of Cygnus Support, sac@cygnus.com - Rewritten by Geoffrey Noer of Cygnus Solutions, noer@cygnus.com - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include "cygwin_version.h" -#include "cygtls.h" - -/* uname: POSIX 4.4.1.1 */ -extern "C" int -uname (struct utsname *name) -{ - SYSTEM_INFO sysinfo; - - myfault efault; - if (efault.faulted (EFAULT)) - return -1; - - char *snp = strstr (cygwin_version.dll_build_date, "SNP"); - - memset (name, 0, sizeof (*name)); - __small_sprintf (name->sysname, "CYGWIN_%s", wincap.osname ()); - -#if 0 - /* Recognition of the real 64 bit CPU inside of a WOW64 system, irritates - build systems which think the native system is a 64 bit system. Since - we're actually running in a 32 bit environment, it looks more correct - just to use the CPU info given by WOW64. */ - if (wincap.is_wow64 ()) - GetNativeSystemInfo (&sysinfo); - else -#else - /* But it seems ok to add a hint to the sysname, that we're running under - WOW64. This might give an early clue if somebody encounters problems. */ - if (wincap.is_wow64 ()) - strncat (name->sysname, "-WOW64", - sizeof name->sysname - strlen (name->sysname) - 1); -#endif - GetSystemInfo (&sysinfo); - - /* Computer name */ - cygwin_gethostname (name->nodename, sizeof (name->nodename) - 1); - - /* Cygwin dll release */ - __small_sprintf (name->release, "%d.%d.%d%s(%d.%d/%d/%d)", - cygwin_version.dll_major / 1000, - cygwin_version.dll_major % 1000, - cygwin_version.dll_minor, - snp ? "s" : "", - cygwin_version.api_major, - cygwin_version.api_minor, - cygwin_version.shared_data, - cygwin_version.mount_registry); - - /* Cygwin "version" aka build date */ - strcpy (name->version, cygwin_version.dll_build_date); - if (snp) - name->version[snp - cygwin_version.dll_build_date] = '\0'; - - /* CPU type */ - switch (sysinfo.wProcessorArchitecture) - { - case PROCESSOR_ARCHITECTURE_INTEL: - unsigned int ptype; - if (sysinfo.wProcessorLevel < 3) /* Shouldn't happen. */ - ptype = 3; - else if (sysinfo.wProcessorLevel > 9) /* P4 */ - ptype = 6; - else - ptype = sysinfo.wProcessorLevel; - __small_sprintf (name->machine, "i%d86", ptype); - break; - case PROCESSOR_ARCHITECTURE_IA64: - strcpy (name->machine, "ia64"); - break; - case PROCESSOR_ARCHITECTURE_AMD64: - strcpy (name->machine, "x86_64"); - break; - case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64: - strcpy (name->machine, "ia32-win64"); - break; - case PROCESSOR_ARCHITECTURE_ALPHA: - strcpy (name->machine, "alpha"); - break; - case PROCESSOR_ARCHITECTURE_MIPS: - strcpy (name->machine, "mips"); - break; - default: - strcpy (name->machine, "unknown"); - break; - } - - return 0; -} diff --git a/winsup/cygwin/wait.cc b/winsup/cygwin/wait.cc deleted file mode 100644 index 3286434ba..000000000 --- a/winsup/cygwin/wait.cc +++ /dev/null @@ -1,117 +0,0 @@ -/* wait.cc: Posix wait routines. - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include "sigproc.h" -#include "thread.h" -#include "cygtls.h" - -/* This is called _wait and not wait because the real wait is defined - in libc/syscalls/syswait.c. It calls us. */ - -extern "C" pid_t -wait (int *status) -{ - return wait4 (-1, status, 0, NULL); -} - -extern "C" pid_t -waitpid (pid_t intpid, int *status, int options) -{ - return wait4 (intpid, status, options, NULL); -} - -extern "C" pid_t -wait3 (int *status, int options, struct rusage *r) -{ - return wait4 (-1, status, options, r); -} - -/* Wait for any child to complete. - * Note: this is not thread safe. Use of wait in multiple threads will - * not work correctly. - */ - -extern "C" pid_t -wait4 (int intpid, int *status, int options, struct rusage *r) -{ - int res; - HANDLE waitfor; - waitq *w = &_my_tls.wq; - - pthread_testcancel (); - - while (1) - { - sig_dispatch_pending (); - if (options & ~(WNOHANG | WUNTRACED | WCONTINUED)) - { - set_errno (EINVAL); - res = -1; - break; - } - - if (r) - memset (r, 0, sizeof (*r)); - - w->pid = intpid; - w->options = options; - w->rusage = r; - sigproc_printf ("calling proc_subproc, pid %d, options %d", - w->pid, w->options); - if (!proc_subproc (PROC_WAIT, (DWORD) w)) - { - set_errno (ENOSYS); - paranoid_printf ("proc_subproc returned 0"); - res = -1; - break; - } - - if ((waitfor = w->ev) == NULL) - goto nochildren; - - res = cancelable_wait (waitfor, INFINITE); - - sigproc_printf ("%d = WaitForSingleObject (...)", res); - - if (w->ev == NULL) - { - nochildren: - /* found no children */ - set_errno (ECHILD); - res = -1; - break; - } - - if (w->status == -1) - { - if (_my_tls.call_signal_handler ()) - continue; - set_sig_errno (EINTR); - res = -1; - } - else if (res != WAIT_OBJECT_0) - { - set_errno (EINVAL); - res = -1; - } - else if ((res = w->pid) != 0 && status) - *status = w->status; - break; - } - - sigproc_printf ("intpid %d, status %p, w->status %d, options %d, res %d", - intpid, status, w->status, options, res); - w->status = -1; - if (res < 0) - sigproc_printf ("*** errno %d", get_errno ()); - return res; -} diff --git a/winsup/cygwin/wchar.h b/winsup/cygwin/wchar.h deleted file mode 100644 index fbeb04c70..000000000 --- a/winsup/cygwin/wchar.h +++ /dev/null @@ -1,75 +0,0 @@ -/* wchar.h: Extra wchar defs - - Copyright 2007, 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _CYGWIN_WCHAR_H -#define _CYGWIN_WCHAR_H - -#include_next - -#define ENCODING_LEN 31 - -#ifdef __cplusplus -extern "C" { -#endif - -typedef int mbtowc_f (struct _reent *, wchar_t *, const char *, size_t, - const char *, mbstate_t *); -typedef mbtowc_f *mbtowc_p; - -extern mbtowc_p __mbtowc; -extern mbtowc_f __ascii_mbtowc; -extern mbtowc_f __utf8_mbtowc; -extern mbtowc_f __iso_mbtowc; -extern mbtowc_f __cp_mbtowc; -extern mbtowc_f __sjis_mbtowc; -extern mbtowc_f __eucjp_mbtowc; -extern mbtowc_f __gbk_mbtowc; -extern mbtowc_f __kr_mbtowc; -extern mbtowc_f __big5_mbtowc; - -typedef int wctomb_f (struct _reent *, char *, wchar_t, const char *, - mbstate_t *); -typedef wctomb_f *wctomb_p; - -extern wctomb_p __wctomb; -extern wctomb_f __ascii_wctomb; -extern wctomb_f __utf8_wctomb; - -extern char *__locale_charset (); - -#ifdef __cplusplus -} -#endif - -#ifdef __INSIDE_CYGWIN__ -#ifdef __cplusplus -size_t __stdcall sys_cp_wcstombs (wctomb_p, const char *, char *, size_t, - const wchar_t *, size_t = (size_t) -1) - __attribute__ ((regparm(3))); -size_t __stdcall sys_wcstombs (char *dst, size_t len, const wchar_t * src, - size_t nwc = (size_t) -1) - __attribute__ ((regparm(3))); -size_t __stdcall sys_wcstombs_alloc (char **, int, const wchar_t *, - size_t = (size_t) -1) - __attribute__ ((regparm(3))); - -size_t __stdcall sys_cp_mbstowcs (mbtowc_p, const char *, wchar_t *, size_t, - const char *, size_t = (size_t) -1) - __attribute__ ((regparm(3))); -size_t __stdcall sys_mbstowcs (wchar_t * dst, size_t dlen, const char *src, - size_t nms = (size_t) -1) - __attribute__ ((regparm(3))); -size_t __stdcall sys_mbstowcs_alloc (wchar_t **, int, const char *, - size_t = (size_t) -1) - __attribute__ ((regparm(3))); -#endif /* __cplusplus */ -#endif /* __INSIDE_CYGWIN__ */ - -#endif /* _CYGWIN_WCHAR_H */ diff --git a/winsup/cygwin/winbase.h b/winsup/cygwin/winbase.h deleted file mode 100644 index 00c71a923..000000000 --- a/winsup/cygwin/winbase.h +++ /dev/null @@ -1,76 +0,0 @@ -/* winbase.h - - Copyright 2002, 2003, 2004, 2008 Red Hat, Inc. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include_next "winbase.h" - -#ifndef _WINBASE2_H -#define _WINBASE2_H - -extern __inline__ long -ilockincr (volatile long *m) -{ - register int __res; - __asm__ __volatile__ ("\n\ - movl $1,%0\n\ - lock xadd %0,%1\n\ - inc %0\n\ - ": "=&r" (__res), "=m" (*m): "m" (*m): "cc"); - return __res; -} - -extern __inline__ long -ilockdecr (volatile long *m) -{ - register int __res; - __asm__ __volatile__ ("\n\ - movl $0xffffffff,%0\n\ - lock xadd %0,%1\n\ - dec %0\n\ - ": "=&r" (__res), "=m" (*m): "m" (*m): "cc"); - return __res; -} - -extern __inline__ long -ilockexch (volatile long *t, long v) -{ - return - ({ - register long ret __asm ("%eax"); - __asm __volatile ("\n" - "1: lock cmpxchgl %2, %1\n" - " jne 1b\n" - : "=a" (ret), "=m" (*t) - : "r" (v), "m" (*t), "0" (*t) - : "memory"); - ret; - }); -} - -extern __inline__ long -ilockcmpexch (volatile long *t, long v, long c) -{ - return - ({ - register long ret __asm ("%eax"); - __asm __volatile ("lock cmpxchgl %2, %1" - : "=a" (ret), "=m" (*t) - : "r" (v), "m" (*t), "0" (c) - : "memory"); - ret; - }); -} - -#undef InterlockedIncrement -#define InterlockedIncrement ilockincr -#undef InterlockedDecrement -#define InterlockedDecrement ilockdecr -#undef InterlockedExchange -#define InterlockedExchange ilockexch -#undef InterlockedCompareExchange -#define InterlockedCompareExchange ilockcmpexch -#endif /*_WINBASE2_H*/ diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc deleted file mode 100644 index 56aac2453..000000000 --- a/winsup/cygwin/wincap.cc +++ /dev/null @@ -1,576 +0,0 @@ -/* wincap.cc -- figure out on which OS we're running. Set the - capability class to the appropriate values. - - Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, - 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include "security.h" -#include "ntdll.h" - -/* CV, 2008-10-23: All wincapc's have to be in the .cygwin_dll_common section, - same as wincap itself. Otherwise the capability changes made in - wincapc::init() are not propagated to any subsequently started process - in the same session. I'm only writing this longish comment because I'm - puzzled that this has never been noticed before... */ - -/* Minimal set of capabilities which is equivalent to NT4. */ -wincaps wincap_unknown __attribute__((section (".cygwin_dll_common"), shared)) = { - chunksize:0, - heapslop:0x0, - max_sys_priv:SE_CHANGE_NOTIFY_PRIVILEGE, - is_server:false, - has_dacl_protect:false, - has_ip_helper_lib:false, - has_broken_if_oper_status:false, - has_physical_mem_access:true, - has_process_io_counters:false, - has_terminal_services:false, - has_create_global_privilege:false, - has_ioctl_storage_get_media_types_ex:false, - has_extended_priority_class:false, - has_guid_volumes:false, - has_disk_ex_ioctls:false, - has_disabled_user_tos_setting:false, - has_fileid_dirinfo:false, - has_exclusiveaddruse:false, - has_enhanced_socket_security:false, - has_buggy_restart_scan:false, - has_mandatory_integrity_control:false, - needs_logon_sid_in_sid_list:true, - needs_count_in_si_lpres2:false, - has_recycle_dot_bin:false, - has_gaa_prefixes:false, - has_gaa_on_link_prefix:false, - supports_all_posix_ai_flags:false, - has_restricted_stack_args:false, - has_transactions:false, - ts_has_dep_problem:false, - has_recvmsg:false, - has_sendmsg:false, - has_broken_udf:false, - has_console_handle_problem:false, - has_broken_alloc_console:false, - has_always_all_codepages:false, - has_localenames:false, -}; - -wincaps wincap_nt4 __attribute__((section (".cygwin_dll_common"), shared)) = { - chunksize:0, - heapslop:0x0, - max_sys_priv:SE_CHANGE_NOTIFY_PRIVILEGE, - is_server:false, - has_dacl_protect:false, - has_ip_helper_lib:false, - has_broken_if_oper_status:false, - has_physical_mem_access:true, - has_process_io_counters:false, - has_terminal_services:false, - has_create_global_privilege:false, - has_ioctl_storage_get_media_types_ex:false, - has_extended_priority_class:false, - has_guid_volumes:false, - has_disk_ex_ioctls:false, - has_disabled_user_tos_setting:false, - has_fileid_dirinfo:false, - has_exclusiveaddruse:false, - has_enhanced_socket_security:false, - has_buggy_restart_scan:false, - has_mandatory_integrity_control:false, - needs_logon_sid_in_sid_list:true, - needs_count_in_si_lpres2:false, - has_recycle_dot_bin:false, - has_gaa_prefixes:false, - has_gaa_on_link_prefix:false, - supports_all_posix_ai_flags:false, - has_restricted_stack_args:false, - has_transactions:false, - ts_has_dep_problem:false, - has_recvmsg:false, - has_sendmsg:false, - has_broken_udf:false, - has_console_handle_problem:false, - has_broken_alloc_console:false, - has_always_all_codepages:false, - has_localenames:false, -}; - -wincaps wincap_nt4sp4 __attribute__((section (".cygwin_dll_common"), shared)) = { - chunksize:0, - heapslop:0x0, - max_sys_priv:SE_CHANGE_NOTIFY_PRIVILEGE, - is_server:false, - has_dacl_protect:false, - has_ip_helper_lib:true, - has_broken_if_oper_status:true, - has_physical_mem_access:true, - has_process_io_counters:false, - has_terminal_services:false, - has_create_global_privilege:false, - has_ioctl_storage_get_media_types_ex:false, - has_extended_priority_class:false, - has_guid_volumes:false, - has_disk_ex_ioctls:false, - has_disabled_user_tos_setting:false, - has_fileid_dirinfo:false, - has_exclusiveaddruse:true, - has_enhanced_socket_security:false, - has_buggy_restart_scan:false, - has_mandatory_integrity_control:false, - needs_logon_sid_in_sid_list:true, - needs_count_in_si_lpres2:false, - has_recycle_dot_bin:false, - has_gaa_prefixes:false, - has_gaa_on_link_prefix:false, - supports_all_posix_ai_flags:false, - has_restricted_stack_args:false, - has_transactions:false, - ts_has_dep_problem:false, - has_recvmsg:false, - has_sendmsg:false, - has_broken_udf:false, - has_console_handle_problem:false, - has_broken_alloc_console:false, - has_always_all_codepages:false, - has_localenames:false, -}; - -wincaps wincap_2000 __attribute__((section (".cygwin_dll_common"), shared)) = { - chunksize:0, - heapslop:0x0, - max_sys_priv:SE_MANAGE_VOLUME_PRIVILEGE, - is_server:false, - has_dacl_protect:true, - has_ip_helper_lib:true, - has_broken_if_oper_status:false, - has_physical_mem_access:true, - has_process_io_counters:true, - has_terminal_services:true, - has_create_global_privilege:false, - has_ioctl_storage_get_media_types_ex:false, - has_extended_priority_class:true, - has_guid_volumes:true, - has_disk_ex_ioctls:false, - has_disabled_user_tos_setting:true, - has_fileid_dirinfo:true, - has_exclusiveaddruse:true, - has_enhanced_socket_security:false, - has_buggy_restart_scan:true, - has_mandatory_integrity_control:false, - needs_logon_sid_in_sid_list:true, - needs_count_in_si_lpres2:false, - has_recycle_dot_bin:false, - has_gaa_prefixes:false, - has_gaa_on_link_prefix:false, - supports_all_posix_ai_flags:false, - has_restricted_stack_args:false, - has_transactions:false, - ts_has_dep_problem:false, - has_recvmsg:false, - has_sendmsg:false, - has_broken_udf:true, - has_console_handle_problem:false, - has_broken_alloc_console:false, - has_always_all_codepages:false, - has_localenames:false, -}; - -wincaps wincap_2000sp4 __attribute__((section (".cygwin_dll_common"), shared)) = { - chunksize:0, - heapslop:0x0, - max_sys_priv:SE_CREATE_GLOBAL_PRIVILEGE, - is_server:false, - has_dacl_protect:true, - has_ip_helper_lib:true, - has_broken_if_oper_status:false, - has_physical_mem_access:true, - has_process_io_counters:true, - has_terminal_services:true, - has_create_global_privilege:true, - has_ioctl_storage_get_media_types_ex:false, - has_extended_priority_class:true, - has_guid_volumes:true, - has_disk_ex_ioctls:false, - has_disabled_user_tos_setting:true, - has_fileid_dirinfo:true, - has_exclusiveaddruse:true, - has_enhanced_socket_security:false, - has_buggy_restart_scan:true, - has_mandatory_integrity_control:false, - needs_logon_sid_in_sid_list:true, - needs_count_in_si_lpres2:false, - has_recycle_dot_bin:false, - has_gaa_prefixes:false, - has_gaa_on_link_prefix:false, - supports_all_posix_ai_flags:false, - has_restricted_stack_args:false, - has_transactions:false, - ts_has_dep_problem:false, - has_recvmsg:false, - has_sendmsg:false, - has_broken_udf:true, - has_console_handle_problem:false, - has_broken_alloc_console:false, - has_always_all_codepages:false, - has_localenames:false, -}; - -wincaps wincap_xp __attribute__((section (".cygwin_dll_common"), shared)) = { - chunksize:0, - heapslop:0x0, - max_sys_priv:SE_MANAGE_VOLUME_PRIVILEGE, - is_server:false, - has_dacl_protect:true, - has_ip_helper_lib:true, - has_broken_if_oper_status:false, - has_physical_mem_access:true, - has_process_io_counters:true, - has_terminal_services:true, - has_create_global_privilege:false, - has_ioctl_storage_get_media_types_ex:true, - has_extended_priority_class:true, - has_guid_volumes:true, - has_disk_ex_ioctls:true, - has_disabled_user_tos_setting:true, - has_fileid_dirinfo:true, - has_exclusiveaddruse:true, - has_enhanced_socket_security:false, - has_buggy_restart_scan:false, - has_mandatory_integrity_control:false, - needs_logon_sid_in_sid_list:false, - needs_count_in_si_lpres2:false, - has_recycle_dot_bin:false, - has_gaa_prefixes:false, - has_gaa_on_link_prefix:false, - supports_all_posix_ai_flags:false, - has_restricted_stack_args:false, - has_transactions:false, - ts_has_dep_problem:false, - has_recvmsg:true, - has_sendmsg:false, - has_broken_udf:true, - has_console_handle_problem:false, - has_broken_alloc_console:false, - has_always_all_codepages:false, - has_localenames:false, -}; - -wincaps wincap_xpsp1 __attribute__((section (".cygwin_dll_common"), shared)) = { - chunksize:0, - heapslop:0x0, - max_sys_priv:SE_MANAGE_VOLUME_PRIVILEGE, - is_server:false, - has_dacl_protect:true, - has_ip_helper_lib:true, - has_broken_if_oper_status:false, - has_physical_mem_access:true, - has_process_io_counters:true, - has_terminal_services:true, - has_create_global_privilege:false, - has_ioctl_storage_get_media_types_ex:true, - has_extended_priority_class:true, - has_guid_volumes:true, - has_disk_ex_ioctls:true, - has_disabled_user_tos_setting:true, - has_fileid_dirinfo:true, - has_exclusiveaddruse:true, - has_enhanced_socket_security:false, - has_buggy_restart_scan:false, - has_mandatory_integrity_control:false, - needs_logon_sid_in_sid_list:false, - needs_count_in_si_lpres2:false, - has_recycle_dot_bin:false, - has_gaa_prefixes:true, - has_gaa_on_link_prefix:false, - supports_all_posix_ai_flags:false, - has_restricted_stack_args:false, - has_transactions:false, - ts_has_dep_problem:false, - has_recvmsg:true, - has_sendmsg:false, - has_broken_udf:true, - has_console_handle_problem:false, - has_broken_alloc_console:false, - has_always_all_codepages:false, - has_localenames:false, -}; - -wincaps wincap_xpsp2 __attribute__((section (".cygwin_dll_common"), shared)) = { - chunksize:0, - heapslop:0x0, - max_sys_priv:SE_CREATE_GLOBAL_PRIVILEGE, - is_server:false, - has_dacl_protect:true, - has_ip_helper_lib:true, - has_broken_if_oper_status:false, - has_physical_mem_access:true, - has_process_io_counters:true, - has_terminal_services:true, - has_create_global_privilege:true, - has_ioctl_storage_get_media_types_ex:true, - has_extended_priority_class:true, - has_guid_volumes:true, - has_disk_ex_ioctls:true, - has_disabled_user_tos_setting:true, - has_fileid_dirinfo:true, - has_exclusiveaddruse:true, - has_enhanced_socket_security:false, - has_buggy_restart_scan:false, - has_mandatory_integrity_control:false, - needs_logon_sid_in_sid_list:false, - needs_count_in_si_lpres2:false, - has_recycle_dot_bin:false, - has_gaa_prefixes:true, - has_gaa_on_link_prefix:false, - supports_all_posix_ai_flags:false, - has_restricted_stack_args:false, - has_transactions:false, - ts_has_dep_problem:false, - has_recvmsg:true, - has_sendmsg:false, - has_broken_udf:true, - has_console_handle_problem:false, - has_broken_alloc_console:false, - has_always_all_codepages:false, - has_localenames:false, -}; - -wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = { - chunksize:0, - heapslop:0x4, - max_sys_priv:SE_CREATE_GLOBAL_PRIVILEGE, - is_server:true, - has_dacl_protect:true, - has_ip_helper_lib:true, - has_broken_if_oper_status:false, - has_physical_mem_access:false, - has_process_io_counters:true, - has_terminal_services:true, - has_create_global_privilege:true, - has_ioctl_storage_get_media_types_ex:true, - has_extended_priority_class:true, - has_guid_volumes:true, - has_disk_ex_ioctls:true, - has_disabled_user_tos_setting:true, - has_fileid_dirinfo:true, - has_exclusiveaddruse:true, - has_enhanced_socket_security:true, - has_buggy_restart_scan:false, - has_mandatory_integrity_control:false, - needs_logon_sid_in_sid_list:false, - needs_count_in_si_lpres2:false, - has_recycle_dot_bin:false, - has_gaa_prefixes:true, - has_gaa_on_link_prefix:false, - supports_all_posix_ai_flags:false, - has_restricted_stack_args:true, - has_transactions:false, - ts_has_dep_problem:false, - has_recvmsg:true, - has_sendmsg:false, - has_broken_udf:true, - has_console_handle_problem:false, - has_broken_alloc_console:false, - has_always_all_codepages:false, - has_localenames:false, -}; - -wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = { - chunksize:0, - heapslop:0x4, - max_sys_priv:SE_CREATE_SYMBOLIC_LINK_PRIVILEGE, - is_server:false, - has_dacl_protect:true, - has_ip_helper_lib:true, - has_broken_if_oper_status:false, - has_physical_mem_access:false, - has_process_io_counters:true, - has_terminal_services:true, - has_create_global_privilege:true, - has_ioctl_storage_get_media_types_ex:true, - has_extended_priority_class:true, - has_guid_volumes:true, - has_disk_ex_ioctls:true, - has_disabled_user_tos_setting:true, - has_fileid_dirinfo:true, - has_exclusiveaddruse:true, - has_enhanced_socket_security:true, - has_buggy_restart_scan:false, - has_mandatory_integrity_control:true, - needs_logon_sid_in_sid_list:false, - needs_count_in_si_lpres2:true, - has_recycle_dot_bin:true, - has_gaa_prefixes:true, - has_gaa_on_link_prefix:true, - supports_all_posix_ai_flags:true, - has_restricted_stack_args:false, - has_transactions:true, - ts_has_dep_problem:false, - has_recvmsg:true, - has_sendmsg:true, - has_broken_udf:false, - has_console_handle_problem:false, - has_broken_alloc_console:false, - has_always_all_codepages:true, - has_localenames:true, -}; - -wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = { - chunksize:0, - heapslop:0x4, - max_sys_priv:SE_CREATE_SYMBOLIC_LINK_PRIVILEGE, - is_server:false, - has_dacl_protect:true, - has_ip_helper_lib:true, - has_broken_if_oper_status:false, - has_physical_mem_access:false, - has_process_io_counters:true, - has_terminal_services:true, - has_create_global_privilege:true, - has_ioctl_storage_get_media_types_ex:true, - has_extended_priority_class:true, - has_guid_volumes:true, - has_disk_ex_ioctls:true, - has_disabled_user_tos_setting:true, - has_fileid_dirinfo:true, - has_exclusiveaddruse:true, - has_enhanced_socket_security:true, - has_buggy_restart_scan:false, - has_mandatory_integrity_control:true, - needs_logon_sid_in_sid_list:false, - needs_count_in_si_lpres2:true, - has_recycle_dot_bin:true, - has_gaa_prefixes:true, - has_gaa_on_link_prefix:true, - supports_all_posix_ai_flags:true, - has_restricted_stack_args:false, - has_transactions:true, - ts_has_dep_problem:false, - has_recvmsg:true, - has_sendmsg:true, - has_broken_udf:false, - has_console_handle_problem:true, - has_broken_alloc_console:true, - has_always_all_codepages:true, - has_localenames:true, -}; - -wincapc wincap __attribute__((section (".cygwin_dll_common"), shared)); - -void -wincapc::init () -{ - bool has_osversioninfoex = true; - - if (caps) - return; // already initialized - - memset (&version, 0, sizeof version); - /* Request versionex info first, which is available on all systems since - NT4 SP6 anyway. If that fails, call the simple version. */ - version.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX); - if (!GetVersionEx (reinterpret_cast(&version))) - { - has_osversioninfoex = false; - version.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); - GetVersionEx (reinterpret_cast(&version)); - } - - switch (version.dwPlatformId) - { - case VER_PLATFORM_WIN32_NT: - switch (version.dwMajorVersion) - { - case 4: - if (!has_osversioninfoex - && strcmp (version.szCSDVersion, "Service Pack 4") < 0) - caps = &wincap_nt4; - else - caps = &wincap_nt4sp4; - break; - case 5: - switch (version.dwMinorVersion) - { - case 0: - if (version.wServicePackMajor < 4) - caps = &wincap_2000; - else - caps = &wincap_2000sp4; - break; - - case 1: - caps = &wincap_xp; - switch (version.wServicePackMajor) - { - case 0: - caps = &wincap_xp; - case 1: - caps = &wincap_xpsp1; - default: - caps = &wincap_xpsp2; - } - break; - - default: - caps = &wincap_2003; - } - break; - case 6: - switch (version.dwMinorVersion) - { - case 0: - caps = &wincap_vista; - break; - default: - caps = &wincap_7; - break; - } - break; - default: - caps = &wincap_unknown; - break; - } - break; - case VER_PLATFORM_WIN32_WINDOWS: - /* I'd be very surprised if this code is ever hit, but it doesn't - hurt to keep it. */ - api_fatal ("Windows 95/98/Me are not supported."); - break; - default: - caps = &wincap_unknown; - break; - } - - if (has_osversioninfoex && version.wProductType != VER_NT_WORKSTATION) - { - ((wincaps *)caps)->is_server = true; - if (version.dwMajorVersion >= 6 - && (version.wSuiteMask - & (VER_SUITE_TERMINAL | VER_SUITE_SINGLEUSERTS)) - == VER_SUITE_TERMINAL) - ((wincaps *)caps)->ts_has_dep_problem = true; - } - if (NT_SUCCESS (NtQueryInformationProcess (NtCurrentProcess (), - ProcessWow64Information, - &wow64, sizeof wow64, NULL)) - && !wow64) - { - ((wincaps *)caps)->needs_count_in_si_lpres2 = false; - ((wincaps *)caps)->has_restricted_stack_args = false; - } - - __small_sprintf (osnam, "NT-%d.%d", version.dwMajorVersion, - version.dwMinorVersion); -} - -void -wincapc::set_chunksize (DWORD nchunksize) -{ - ((wincaps *)caps)->chunksize = nchunksize; -} diff --git a/winsup/cygwin/wincap.h b/winsup/cygwin/wincap.h deleted file mode 100644 index 6a698d2f0..000000000 --- a/winsup/cygwin/wincap.h +++ /dev/null @@ -1,116 +0,0 @@ -/* wincap.h: Header for OS capability class. - - Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, - 2009, 2010 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _WINCAP_H -#define _WINCAP_H - -struct wincaps -{ - DWORD chunksize; - DWORD heapslop; - DWORD max_sys_priv; - unsigned is_server : 1; - unsigned has_dacl_protect : 1; - unsigned has_ip_helper_lib : 1; - unsigned has_broken_if_oper_status : 1; - unsigned has_physical_mem_access : 1; - unsigned has_process_io_counters : 1; - unsigned has_terminal_services : 1; - unsigned has_create_global_privilege : 1; - unsigned has_ioctl_storage_get_media_types_ex : 1; - unsigned has_extended_priority_class : 1; - unsigned has_guid_volumes : 1; - unsigned has_disk_ex_ioctls : 1; - unsigned has_disabled_user_tos_setting : 1; - unsigned has_fileid_dirinfo : 1; - unsigned has_exclusiveaddruse : 1; - unsigned has_enhanced_socket_security : 1; - unsigned has_buggy_restart_scan : 1; - unsigned has_mandatory_integrity_control : 1; - unsigned needs_logon_sid_in_sid_list : 1; - unsigned needs_count_in_si_lpres2 : 1; - unsigned has_recycle_dot_bin : 1; - unsigned has_gaa_prefixes : 1; - unsigned has_gaa_on_link_prefix : 1; - unsigned supports_all_posix_ai_flags : 1; - unsigned has_restricted_stack_args : 1; - unsigned has_transactions : 1; - unsigned ts_has_dep_problem : 1; - unsigned has_recvmsg : 1; - unsigned has_sendmsg : 1; - unsigned has_broken_udf : 1; - unsigned has_console_handle_problem : 1; - unsigned has_broken_alloc_console : 1; - unsigned has_always_all_codepages : 1; - unsigned has_localenames : 1; -}; - -class wincapc -{ - OSVERSIONINFOEX version; - char osnam[40]; - ULONG wow64; - void *caps; - -public: - void init (); - - void set_chunksize (DWORD nchunksize); - - const char *osname () const { return osnam; } - const bool is_wow64 () const { return wow64; } - -#define IMPLEMENT(cap) cap() const { return ((wincaps *) this->caps)->cap; } - - DWORD IMPLEMENT (chunksize) - DWORD IMPLEMENT (heapslop) - DWORD IMPLEMENT (max_sys_priv) - bool IMPLEMENT (is_server) - bool IMPLEMENT (has_dacl_protect) - bool IMPLEMENT (has_ip_helper_lib) - bool IMPLEMENT (has_broken_if_oper_status) - bool IMPLEMENT (has_physical_mem_access) - bool IMPLEMENT (has_process_io_counters) - bool IMPLEMENT (has_terminal_services) - bool IMPLEMENT (has_create_global_privilege) - bool IMPLEMENT (has_ioctl_storage_get_media_types_ex) - bool IMPLEMENT (has_extended_priority_class) - bool IMPLEMENT (has_guid_volumes) - bool IMPLEMENT (has_disk_ex_ioctls) - bool IMPLEMENT (has_disabled_user_tos_setting) - bool IMPLEMENT (has_fileid_dirinfo) - bool IMPLEMENT (has_exclusiveaddruse) - bool IMPLEMENT (has_enhanced_socket_security) - bool IMPLEMENT (has_buggy_restart_scan) - bool IMPLEMENT (has_mandatory_integrity_control) - bool IMPLEMENT (needs_logon_sid_in_sid_list) - bool IMPLEMENT (needs_count_in_si_lpres2) - bool IMPLEMENT (has_recycle_dot_bin) - bool IMPLEMENT (has_gaa_prefixes) - bool IMPLEMENT (has_gaa_on_link_prefix) - bool IMPLEMENT (supports_all_posix_ai_flags) - bool IMPLEMENT (has_restricted_stack_args) - bool IMPLEMENT (has_transactions) - bool IMPLEMENT (ts_has_dep_problem) - bool IMPLEMENT (has_recvmsg) - bool IMPLEMENT (has_sendmsg) - bool IMPLEMENT (has_broken_udf) - bool IMPLEMENT (has_console_handle_problem) - bool IMPLEMENT (has_broken_alloc_console) - bool IMPLEMENT (has_always_all_codepages) - bool IMPLEMENT (has_localenames) - -#undef IMPLEMENT -}; - -extern wincapc wincap; - -#endif /* _WINCAP_H */ diff --git a/winsup/cygwin/window.cc b/winsup/cygwin/window.cc deleted file mode 100644 index ac00a0c0e..000000000 --- a/winsup/cygwin/window.cc +++ /dev/null @@ -1,133 +0,0 @@ -/* window.cc: hidden windows for signals/itimer support - - Copyright 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005 Red Hat, Inc. - - Written by Sergey Okhapkin - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include -#include -#define USE_SYS_TYPES_FD_SET -#include -#include "perprocess.h" -#include "cygtls.h" -#include "sync.h" -#include "wininfo.h" - -wininfo NO_COPY winmsg; - -muto NO_COPY wininfo::_lock; - -int __stdcall -wininfo::process (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ -#ifndef NOSTRACE - strace.wm (uMsg, wParam, lParam); -#endif - switch (uMsg) - { - case WM_PAINT: - return 0; - case WM_DESTROY: - PostQuitMessage (0); - return 0; - case WM_ASYNCIO: - if (WSAGETSELECTEVENT (lParam) == FD_OOB) - raise (SIGURG); - else - raise (SIGIO); - return 0; - default: - return DefWindowProc (hwnd, uMsg, wParam, lParam); - } -} - -static LRESULT CALLBACK -process_window_events (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - return winmsg.process (hwnd, uMsg, wParam, lParam); -} - -/* Handle windows events. Inherits ownership of the wininfo lock */ -DWORD WINAPI -wininfo::winthread () -{ - MSG msg; - WNDCLASS wc; - static NO_COPY char classname[] = "CygwinWndClass"; - - _lock.grab (); - /* Register the window class for the main window. */ - - wc.style = 0; - wc.lpfnWndProc = (WNDPROC) process_window_events; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = user_data->hmodule; - wc.hIcon = NULL; - wc.hCursor = NULL; - wc.hbrBackground = NULL; - wc.lpszMenuName = NULL; - wc.lpszClassName = classname; - - if (!RegisterClass (&wc)) - api_fatal ("cannot register window class, %E"); - - /* Create hidden window. */ - hwnd = CreateWindow (classname, classname, WS_POPUP, CW_USEDEFAULT, - CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - (HWND) NULL, (HMENU) NULL, user_data->hmodule, - (LPVOID) NULL); - if (!hwnd) - api_fatal ("couldn't create window, %E"); - release (); - - while (GetMessage (&msg, hwnd, 0, 0) == TRUE) - DispatchMessage (&msg); - - return 0; -} - -static DWORD WINAPI -winthread (VOID *arg) -{ - return ((wininfo *) arg)->winthread (); -} - -wininfo::operator -HWND () -{ - if (hwnd) - return hwnd; - - lock (); - if (!hwnd) - { - _lock.upforgrabs (); - cygthread *h = new cygthread (::winthread, 0, this, "win"); - h->SetThreadPriority (THREAD_PRIORITY_HIGHEST); - h->zap_h (); - lock (); - } - release (); - return hwnd; -} - -void -wininfo::lock () -{ - _lock.init ("wininfo_lock")->acquire (); -} - -void -wininfo::release () -{ - _lock.release (); -} diff --git a/winsup/cygwin/winf.cc b/winsup/cygwin/winf.cc deleted file mode 100644 index 136874b21..000000000 --- a/winsup/cygwin/winf.cc +++ /dev/null @@ -1,154 +0,0 @@ -/* winf.cc - - Copyright 2003, 2004, 2005, 2006, 2008 Red Hat, Inc. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include -#include "cygerrno.h" -#include "security.h" -#include "path.h" -#include "fhandler.h" -#include "dtable.h" -#include "cygheap.h" -#include "tls_pbuf.h" -#include "winf.h" -#include "sys/cygwin.h" - -void -linebuf::finish (bool cmdlenoverflow_ok) -{ - if (!ix) - add ("", 1); - else - { - if (ix-- > MAXCYGWINCMDLEN && cmdlenoverflow_ok) - ix = MAXCYGWINCMDLEN - 1; - buf[ix] = '\0'; - } -} - -void -linebuf::add (const char *what, int len) -{ - size_t newix = ix + len; - if (newix >= alloced || !buf) - { - alloced += LINE_BUF_CHUNK + newix; - buf = (char *) realloc (buf, alloced + 1); - } - memcpy (buf + ix, what, len); - ix = newix; - buf[ix] = '\0'; -} - -void -linebuf::prepend (const char *what, int len) -{ - int buflen; - size_t newix; - if ((newix = ix + len) >= alloced) - { - alloced += LINE_BUF_CHUNK + newix; - buf = (char *) realloc (buf, alloced + 1); - buf[ix] = '\0'; - } - if ((buflen = strlen (buf))) - memmove (buf + len, buf, buflen + 1); - else - buf[newix] = '\0'; - memcpy (buf, what, len); - ix = newix; -} - -bool -linebuf::fromargv (av& newargv, const char *real_path, bool cmdlenoverflow_ok) -{ - bool success = true; - for (int i = 0; i < newargv.argc; i++) - { - char *p = NULL; - const char *a; - - newargv.dup_maybe (i); - a = i ? newargv[i] : (char *) real_path; - int len = strlen (a); - if (len != 0 && !strpbrk (a, " \t\n\r\"")) - add (a, len); - else - { - add ("\"", 1); - /* Handle embedded special characters " and \. - A " is always preceded by a \. - A \ is not special unless it precedes a ". If it does, - then all preceding \'s must be doubled to avoid having - the Windows command line parser interpret the \ as quoting - the ". This rule applies to a string of \'s before the end - of the string, since cygwin/windows uses a " to delimit the - argument. */ - for (; (p = strpbrk (a, "\"\\")); a = ++p) - { - add (a, p - a); - /* Find length of string of backslashes */ - int n = strspn (p, "\\"); - if (!n) - add ("\\\"", 2); /* No backslashes, so it must be a ". - The " has to be protected with a backslash. */ - else - { - add (p, n); /* Add the run of backslashes */ - /* Need to double up all of the preceding - backslashes if they precede a quote or EOS. */ - if (!p[n] || p[n] == '"') - add (p, n); - p += n - 1; /* Point to last backslash */ - } - } - if (*a) - add (a); - add ("\"", 1); - } - add (" ", 1); - } - - finish (cmdlenoverflow_ok); - - if (ix >= MAXWINCMDLEN) - { - debug_printf ("command line too long (>32K), return E2BIG"); - set_errno (E2BIG); - success = false; - } - - return success; -} - -int -av::unshift (const char *what, int conv) -{ - char **av; - av = (char **) crealloc (argv, (argc + 2) * sizeof (char *)); - if (!av) - return 0; - - argv = av; - memmove (argv + 1, argv, (argc + 1) * sizeof (char *)); - tmp_pathbuf tp; - char *buf = tp.c_get (); - if (conv) - { - cygwin_conv_path (CCP_WIN_A_TO_POSIX | CCP_RELATIVE, what, buf, - NT_MAX_PATH); - char *p = strchr (buf, '\0') - 4; - if (p > buf && ascii_strcasematch (p, ".exe")) - *p = '\0'; - what = buf; - } - *argv = cstrdup1 (what); - calloced++; - argc++; - return 1; -} diff --git a/winsup/cygwin/winf.h b/winsup/cygwin/winf.h deleted file mode 100644 index a58fb49a9..000000000 --- a/winsup/cygwin/winf.h +++ /dev/null @@ -1,89 +0,0 @@ -/* winf.h - - Copyright 2006, 2007 Red Hat, Inc. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _WINF_H -#define _WINF_H - -/* Hack for Cygwin processes. If the Windows command line length gets slightly - bigger than this value, the stack position is suddenly moved up by 64K for - no apparent reason, which results in subsequent forks failing. Since Cygwin - processes get the full command line as argv array anyway, this only affects - the maximum command line length of Cygwin applications which nonsensically - have a WinMain instead of a main entry point or which use GetCommandLine. */ -#define MAXCYGWINCMDLEN 30000 - -#define MAXWINCMDLEN 32767 -#define LINE_BUF_CHUNK (MAX_PATH * 2) - -class av -{ - char **argv; - int calloced; - public: - int argc; - bool win16_exe; - av (): argv (NULL) {} - av (int ac_in, const char * const *av_in) : calloced (0), argc (ac_in), win16_exe (false) - { - argv = (char **) cmalloc_abort (HEAP_1_ARGV, (argc + 5) * sizeof (char *)); - memcpy (argv, av_in, (argc + 1) * sizeof (char *)); - } - void *operator new (size_t, void *p) __attribute__ ((nothrow)) {return p;} - void set (int ac_in, const char * const *av_in) {new (this) av (ac_in, av_in);} - ~av () - { - if (argv) - { - for (int i = 0; i < calloced; i++) - if (argv[i]) - cfree (argv[i]); - cfree (argv); - } - } - int unshift (const char *what, int conv = 0); - operator char **() {return argv;} - void all_calloced () {calloced = argc;} - void replace0_maybe (const char *arg0) - { - /* Note: Assumes that argv array has not yet been "unshifted" */ - if (!calloced) - { - argv[0] = cstrdup1 (arg0); - calloced = true; - } - } - void dup_maybe (int i) - { - if (i >= calloced) - argv[i] = cstrdup1 (argv[i]); - } - void dup_all () - { - for (int i = calloced; i < argc; i++) - argv[i] = cstrdup1 (argv[i]); - } - int fixup (const char *, path_conv&, const char *); -}; - -class linebuf -{ - public: - size_t ix; - char *buf; - size_t alloced; - linebuf () : ix (0), buf (NULL), alloced (0) {} - ~linebuf () {if (buf) free (buf);} - void add (const char *, int) __attribute__ ((regparm (3))); - void add (const char *what) {add (what, strlen (what));} - void prepend (const char *, int); - void finish (bool) __attribute__ ((regparm (2))); - bool fromargv(av&, const char *, bool) __attribute__ ((regparm (3)));; - operator char *() {return buf;} -}; - -#endif /*_WINF_H*/ diff --git a/winsup/cygwin/wininfo.h b/winsup/cygwin/wininfo.h deleted file mode 100644 index f67cf9a4b..000000000 --- a/winsup/cygwin/wininfo.h +++ /dev/null @@ -1,25 +0,0 @@ -/* wininfo.h: main Cygwin header file. - - Copyright 2004 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -class muto; -class wininfo -{ - HWND hwnd; - static muto _lock; -public: - operator HWND (); - int __stdcall process (HWND, UINT, WPARAM, LPARAM) - __attribute__ ((regparm (3))); - void lock (); - void release (); - DWORD WINAPI winthread () __attribute__ ((regparm (1))); -}; - -extern wininfo winmsg; diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h deleted file mode 100644 index 7f0377ef8..000000000 --- a/winsup/cygwin/winsup.h +++ /dev/null @@ -1,330 +0,0 @@ -/* winsup.h: main Cygwin header file. - - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifdef DEBUGIT -#define spf(a, b, c) small_printf (a, b, c) -#else -#define spf(a, b, c) do {} while (0) -#endif - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#define __INSIDE_CYGWIN__ - -#define NO_COPY __attribute__((nocommon)) __attribute__((section(".data_cygwin_nocopy"))) -#define NO_COPY_INIT __attribute__((section(".data_cygwin_nocopy"))) - -#define EXPORT_ALIAS(sym,symalias) extern "C" __typeof (sym) symalias __attribute__ ((alias(#sym))); - -#define WINVER 0x0601 -#define _NO_W32_PSEUDO_MODIFIERS - -#include -#include - -/* Declarations for functions used in C and C++ code. */ -#ifdef __cplusplus -extern "C" { -#endif -__uid32_t getuid32 (); -__uid32_t geteuid32 (); -int seteuid32 (__uid32_t); -__gid32_t getegid32 (void); -struct passwd *getpwuid32 (__uid32_t); -struct passwd *getpwnam (const char *); -struct __sFILE64 *fopen64 (const char *, const char *); -struct hostent *cygwin_gethostbyname (const char *name); -/* Don't enforce definition of in_addr_t. */ -uint32_t cygwin_inet_addr (const char *cp); -int fcntl64 (int fd, int cmd, ...); -#ifdef __cplusplus -} -#endif - -/* Note that MAX_PATH is defined in the windows headers */ -/* There is also PATH_MAX and MAXPATHLEN. - PATH_MAX is from Posix and does include the trailing NUL. - MAXPATHLEN is from Unix. - - Thou shalt *not* use CYG_MAX_PATH anymore. Use NT_MAX_PATH or - dynamic allocation instead when accessing real files. Use - MAX_PATH in case you need a convenient small buffer when creating - names for synchronization objects or named pipes. */ -#define CYG_MAX_PATH (MAX_PATH) - -/* There's no define for the maximum path length the NT kernel can handle. - That's why we define our own to use in path length test and for path - buffer sizes. As MAX_PATH and PATH_MAX, this is defined including the - trailing 0. Internal buffers and internal path routines should use - NT_MAX_PATH. PATH_MAX as defined in limits.h is the maximum length of - application provided path strings we handle. */ -#define NT_MAX_PATH 32768 - -#ifdef __cplusplus - -extern const char case_folded_lower[]; -#define cyg_tolower(c) (case_folded_lower[(unsigned char)(c)]) -extern const char case_folded_upper[]; -#define cyg_toupper(c) (case_folded_upper[(unsigned char)(c)]) - -#ifndef MALLOC_DEBUG -#define cfree newlib_cfree_dont_use -#endif - -#define WIN32_LEAN_AND_MEAN 1 -#define _WINGDI_H -#define _WINUSER_H -#define _WINNLS_H -#define _WINVER_H -#define _WINNETWK_H -#define _WINSVC_H -#include -#include -#include -#include -#undef _WINGDI_H -#undef _WINUSER_H -#undef _WINNLS_H -#undef _WINVER_H -#undef _WINNETWK_H -#undef _WINSVC_H - -#include "wincap.h" - -/* The one function we use from winuser.h most of the time */ -extern "C" DWORD WINAPI GetLastError (void); - -/* Used as type by sys_wcstombs_alloc and sys_mbstowcs_alloc. For a - description see there. */ -#define HEAP_NOTHEAP -1 - -/* Used to check if Cygwin DLL is dynamically loaded. */ - -extern int cygserver_running; - -#define _MT_SAFE // DELETEME someday - -#define TITLESIZE 1024 - -#include "debug.h" - -#include - -/**************************** Convenience ******************************/ - -/* Used to define status flag accessor methods */ -#define IMPLEMENT_STATUS_FLAG(type,flag) \ - type flag (type val) { return (type) (status.flag = (val)); } \ - type flag () const { return (type) status.flag; } - -/* Used when treating / and \ as equivalent. */ -#define iswdirsep(ch) \ - ({ \ - WCHAR __c = (ch); \ - ((__c) == L'/' || (__c) == L'\\'); \ - }) - -#define isdirsep(ch) \ - ({ \ - char __c = (ch); \ - ((__c) == '/' || (__c) == '\\'); \ - }) - -/* Convert a signal to a signal mask */ -#define SIGTOMASK(sig) (1 << ((sig) - 1)) - -#define set_api_fatal_return(n) do {extern int __api_fatal_exit_val; __api_fatal_exit_val = (n);} while (0) -#define api_fatal(fmt, args...) __api_fatal (fmt,## args) - -#undef issep -#define issep(ch) (strchr (" \t\n\r", (ch)) != NULL) - -/* Every path beginning with / or \, as well as every path being X: - or starting with X:/ or X:\ */ -#define isabspath_u(p) \ - ((p)->Length && \ - (iswdirsep ((p)->Buffer[0]) || \ - ((p)->Length > sizeof (WCHAR) && iswalpha ((p)->Buffer[0]) \ - && (p)->Buffer[1] == L':' && \ - ((p)->Length == 2 * sizeof (WCHAR) || iswdirsep ((p)->Buffer[2]))))) - -#define iswabspath(p) \ - (iswdirsep (*(p)) || (iswalpha (*(p)) && (p)[1] == L':' && (!(p)[2] || iswdirsep ((p)[2])))) - -#define isabspath(p) \ - (isdirsep (*(p)) || (isalpha (*(p)) && (p)[1] == ':' && (!(p)[2] || isdirsep ((p)[2])))) - -/******************** Initialization/Termination **********************/ - -class per_process; -/* cygwin .dll initialization */ -void dll_crt0 (per_process *) __asm__ ("_dll_crt0__FP11per_process"); -extern "C" void __stdcall _dll_crt0 (); -void dll_crt0_1 (void *); -void dll_dllcrt0_1 (void *); -int spawn_guts (const char * prog_arg, const char *const *argv, - const char *const envp[], int mode, int __stdin = -1, - int __stdout = -1) __attribute__ ((regparm(3))); - -/* dynamically loaded dll initialization */ -extern "C" int dll_dllcrt0 (HMODULE, per_process *); - -/* dynamically loaded dll initialization for non-cygwin apps */ -extern "C" int dll_noncygwin_dllcrt0 (HMODULE, per_process *); -void __stdcall do_exit (int) __attribute__ ((regparm (1), noreturn)); - -/* libstdc++ malloc operator wrapper support. */ -extern struct per_process_cxx_malloc default_cygwin_cxx_malloc; - -/* UID/GID */ -void uinfo_init (); - -#define ILLEGAL_UID16 ((__uid16_t)-1) -#define ILLEGAL_UID ((__uid32_t)-1) -#define ILLEGAL_GID16 ((__gid16_t)-1) -#define ILLEGAL_GID ((__gid32_t)-1) -#define ILLEGAL_SEEK ((_off64_t)-1) - -#define uid16touid32(u16) ((u16)==ILLEGAL_UID16?ILLEGAL_UID:(__uid32_t)(u16)) -#define gid16togid32(g16) ((g16)==ILLEGAL_GID16?ILLEGAL_GID:(__gid32_t)(g16)) - -/* Convert LARGE_INTEGER into long long */ -#define get_ll(pl) (((long long) (pl).HighPart << 32) | (pl).LowPart) - -/* various events */ -void events_init (); -void events_terminate (); - -void __stdcall close_all_files (bool = false); - -/* debug_on_trap support. see exceptions.cc:try_to_debug() */ -extern "C" void error_start_init (const char*); -extern "C" int try_to_debug (bool waitloop = 1); - -void ld_preload (); -const char *find_first_notloaded_dll (class path_conv &); - -extern bool cygwin_finished_initializing; - -/**************************** Miscellaneous ******************************/ - -void __stdcall set_std_handle (int); -int __stdcall stat_dev (DWORD, int, unsigned long, struct __stat64 *); - -__ino64_t __stdcall hash_path_name (__ino64_t hash, PUNICODE_STRING name) __attribute__ ((regparm(2))); -__ino64_t __stdcall hash_path_name (__ino64_t hash, PCWSTR name) __attribute__ ((regparm(2))); -__ino64_t __stdcall hash_path_name (__ino64_t hash, const char *name) __attribute__ ((regparm(2))); -void __stdcall nofinalslash (const char *src, char *dst) __attribute__ ((regparm(2))); - -/* String manipulation */ -extern "C" char *__stdcall strccpy (char *s1, const char **s2, char c); - -void *hook_or_detect_cygwin (const char *, const void *, WORD&) __attribute__ ((regparm (3))); - -/* Time related */ -void __stdcall totimeval (struct timeval *, FILETIME *, int, int); -long __stdcall to_time_t (FILETIME *); -void __stdcall to_timestruc_t (FILETIME *, timestruc_t *); -void __stdcall time_as_timestruc_t (timestruc_t *); -void __stdcall timespec_to_filetime (const struct timespec *, FILETIME *); -void __stdcall timeval_to_filetime (const struct timeval *, FILETIME *); - -/* Console related */ -void __stdcall set_console_title (char *); -void init_console_handler (bool); - -void init_global_security (); - -void __set_winsock_errno (const char *fn, int ln) __attribute__ ((regparm(2))); -#define set_winsock_errno() __set_winsock_errno (__FUNCTION__, __LINE__) - -extern bool wsock_started; - -/* Printf type functions */ -extern "C" void __api_fatal (const char *, ...) __attribute__ ((noreturn)); -int __small_sprintf (char *dst, const char *fmt, ...) /*__attribute__ ((regparm (2)))*/; -int __small_vsprintf (char *dst, const char *fmt, va_list ap) /*__attribute__ ((regparm (3)))*/; -int __small_swprintf (PWCHAR dst, const WCHAR *fmt, ...) /*__attribute__ ((regparm (2)))*/; -int __small_vswprintf (PWCHAR dst, const WCHAR *fmt, va_list ap) /*__attribute__ ((regparm (3)))*/; -void multiple_cygwin_problem (const char *, unsigned, unsigned); - -extern "C" void vklog (int priority, const char *message, va_list ap); -extern "C" void klog (int priority, const char *message, ...); -bool child_copy (HANDLE, bool, ...); - -int symlink_worker (const char *, const char *, bool, bool) - __attribute__ ((regparm (3))); - -class path_conv; - -int __stdcall stat_worker (path_conv &pc, struct __stat64 *buf) __attribute__ ((regparm (2))); - -__ino64_t __stdcall readdir_get_ino (const char *path, bool dot_dot) __attribute__ ((regparm (2))); - -/* Returns the real page size, not the allocation size. */ -size_t getsystempagesize (); - -/* mmap functions. */ -enum mmap_region_status - { - MMAP_NONE, - MMAP_RAISE_SIGBUS, - MMAP_NORESERVE_COMMITED - }; -mmap_region_status mmap_is_attached_or_noreserve (void *addr, size_t len); - -inline bool flush_file_buffers (HANDLE h) -{ - return (GetFileType (h) != FILE_TYPE_PIPE) ? FlushFileBuffers (h) : true; -} -#define FlushFileBuffers flush_file_buffers - -/**************************** Exports ******************************/ - -extern "C" { -int cygwin_select (int , fd_set *, fd_set *, fd_set *, - struct timeval *to); -int cygwin_gethostname (char *__name, size_t __len); -}; - -/*************************** Unsorted ******************************/ - -#define WM_ASYNCIO 0x8000 // WM_APP - - -#define STD_RBITS (S_IRUSR | S_IRGRP | S_IROTH) -#define STD_WBITS (S_IWUSR) -#define STD_XBITS (S_IXUSR | S_IXGRP | S_IXOTH) -#define NO_W ~(S_IWUSR | S_IWGRP | S_IWOTH) -#define NO_R ~(S_IRUSR | S_IRGRP | S_IROTH) -#define NO_X ~(S_IXUSR | S_IXGRP | S_IXOTH) - - -extern "C" char _data_start__, _data_end__, _bss_start__, _bss_end__; -extern "C" void (*__CTOR_LIST__) (void); -extern "C" void (*__DTOR_LIST__) (void); - -#if !defined(_GLOBALS_H) -#include "globals.h" -inline void clear_procimptoken () -{ - if (hProcImpToken) - { - HANDLE old_procimp = hProcImpToken; - hProcImpToken = NULL; - CloseHandle (old_procimp); - } -} -#endif - -#endif /* defined __cplusplus */ diff --git a/winsup/cygwin/winver.rc b/winsup/cygwin/winver.rc deleted file mode 100644 index 29b62982e..000000000 --- a/winsup/cygwin/winver.rc +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include - -#define STRINGIFY1(x) #x -#define STRINGIFY(x) STRINGIFY1(x) - -#define CYGWIN_DLL_NAME CYGWIN_VERSION_DLL_IDENTIFIER STRINGIFY(.dll) - -#define CYGWIN_API_VERSION STRINGIFY(CYGWIN_VERSION_API_MAJOR) "." \ - STRINGIFY(CYGWIN_VERSION_API_MINOR) - -#define CYGWIN_BUILD_DATE_TIME STRINGIFY(CYGWIN_BUILD_DATE) " " \ - STRINGIFY(CYGWIN_BUILD_TIME) - -VS_VERSION_INFO VERSIONINFO - FILEVERSION CYGWIN_VERSION_DLL_MAJOR,CYGWIN_VERSION_DLL_MINOR,0,0 - PRODUCTVERSION CYGWIN_VERSION_DLL_MAJOR,CYGWIN_VERSION_DLL_MINOR,0,0 - FILEFLAGSMASK 0x3fL -#ifdef DEBUGGING - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0x0L -#endif - FILEOS VOS__WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "CompanyName", "Red Hat" - VALUE "FileDescription", "Cygwin\256 POSIX Emulation DLL" - VALUE "FileVersion", STRINGIFY(CYGWIN_VERSION) - VALUE "InternalName", CYGWIN_DLL_NAME - VALUE "LegalCopyright", "Copyright \251 Red Hat, Inc. 1996-2009" - VALUE "OriginalFilename", CYGWIN_DLL_NAME - VALUE "ProductName", "Cygwin" - VALUE "ProductVersion", STRINGIFY(CYGWIN_VERSION) - VALUE "APIVersion", CYGWIN_API_VERSION - VALUE "SharedMemoryVersion", STRINGIFY(CYGWIN_VERSION_SHARED_DATA) - VALUE "RegistryKey", CYGWIN_INFO_CYGWIN_REGISTRY_NAME - VALUE "BuildDate", CYGWIN_BUILD_DATE_TIME - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END -- cgit v1.2.3