diff options
author | cvs2svn <> | 2013-06-05 11:57:40 +0400 |
---|---|---|
committer | cvs2svn <> | 2013-06-05 11:57:40 +0400 |
commit | 310a2eeef1d094d59ea9897be0ddb1b33869b885 (patch) | |
tree | 6c061f692be2a0be45d81351d4b9dfc06ec9fe9c /winsup/cygwin/flock.cc | |
parent | c82eac05c783fa1cb82eac9216dab1ed8aa482ae (diff) |
This commit was manufactured by cvs2svn to create tag 'cygwin-cygwin-1_7_19-release
1_7_19-release'.
Sprout from cygwin-64bit-premerge-branch 2013-04-22 17:11:23 UTC cvs2svn 'This commit was manufactured by cvs2svn to create branch 'cygwin-64bit-'
Cherrypick from master 2013-06-05 07:57:39 UTC Corinna Vinschen <corinna@vinschen.de> ' * faq-programming.xml: Convert url to refer to new flat faq.html file.':
COPYING.NEWLIB
ChangeLog
config.guess
config.sub
config/ChangeLog
config/bootstrap-asan.mk
config/dfp.m4
config/picflag.m4
include/ChangeLog
include/elf/ChangeLog
include/elf/aarch64.h
include/elf/common.h
include/elf/mips.h
include/elf/msp430.h
include/opcode/ChangeLog
include/opcode/avr.h
include/opcode/mips.h
include/opcode/msp430.h
newlib/ChangeLog
newlib/MAINTAINERS
newlib/configure
newlib/configure.host
newlib/configure.in
newlib/libc/configure
newlib/libc/configure.in
newlib/libc/ctype/ctype_.c
newlib/libc/ctype/isalnum.c
newlib/libc/ctype/isalpha.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/isxdigit.c
newlib/libc/include/machine/ieeefp.h
newlib/libc/include/machine/setjmp.h
newlib/libc/include/reent.h
newlib/libc/include/sys/cdefs.h
newlib/libc/include/sys/config.h
newlib/libc/include/sys/features.h
newlib/libc/include/sys/reent.h
newlib/libc/include/sys/stat.h
newlib/libc/libc.texinfo
newlib/libc/machine/arm/Makefile.am
newlib/libc/machine/arm/Makefile.in
newlib/libc/machine/arm/memcpy-armv7a.S
newlib/libc/machine/arm/memcpy-armv7m.S
newlib/libc/machine/arm/memcpy-stub.c
newlib/libc/machine/arm/memcpy.S
newlib/libc/machine/arm/strcmp.S
newlib/libc/machine/configure
newlib/libc/machine/configure.in
newlib/libc/machine/powerpc/Makefile.am
newlib/libc/machine/powerpc/Makefile.in
newlib/libc/reent/reent.c
newlib/libc/stdio/fgetc.c
newlib/libc/stdio/fgetwc.c
newlib/libc/stdio/fgetws.c
newlib/libc/stdio/findfp.c
newlib/libc/stdio/fputc.c
newlib/libc/stdio/fputwc.c
newlib/libc/stdio/fputws.c
newlib/libc/stdio/getc.c
newlib/libc/stdio/getchar.c
newlib/libc/stdio/local.h
newlib/libc/stdio/putc.c
newlib/libc/stdio/putchar.c
newlib/libc/stdio/scanf.c
newlib/libc/stdio/setvbuf.c
newlib/libc/stdio/ungetwc.c
newlib/libc/stdio/vfscanf.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/vwprintf.c
newlib/libc/stdio/vwscanf.c
newlib/libc/stdio/wscanf.c
newlib/libc/stdlib/Makefile.am
newlib/libc/stdlib/Makefile.in
newlib/libc/stdlib/__atexit.c
newlib/libc/stdlib/__call_atexit.c
newlib/libc/stdlib/ecvtbuf.c
newlib/libc/stdlib/mblen.c
newlib/libc/stdlib/mbrlen.c
newlib/libc/stdlib/mbrtowc.c
newlib/libc/stdlib/mbtowc.c
newlib/libc/stdlib/nano-mallocr.c
newlib/libc/stdlib/rand.c
newlib/libc/stdlib/strtod.c
newlib/libc/stdlib/wcrtomb.c
newlib/libc/stdlib/wctob.c
newlib/libc/stdlib/wctomb.c
newlib/libc/string/strtok.c
newlib/libc/time/asctime.c
newlib/libc/time/gmtime.c
newlib/libc/time/lcltime.c
newlib/libm/libm.texinfo
winsup/cygserver/ChangeLog
winsup/cygserver/ChangeLog.64bit
winsup/cygserver/Makefile.in
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/client.cc
winsup/cygserver/cygserver.cc
winsup/cygserver/msg.cc
winsup/cygserver/process.h
winsup/cygserver/sem.cc
winsup/cygserver/shm.cc
winsup/cygserver/sysv_shm.cc
winsup/cygserver/threaded_queue.h
winsup/cygwin/ChangeLog
winsup/cygwin/ChangeLog.64bit
winsup/cygwin/Makefile.in
winsup/cygwin/aclocal.m4
winsup/cygwin/advapi32.cc
winsup/cygwin/autoload.cc
winsup/cygwin/automode.c
winsup/cygwin/binmode.c
winsup/cygwin/child_info.h
winsup/cygwin/common.din
winsup/cygwin/configure
winsup/cygwin/configure.ac
winsup/cygwin/cpuid.h
winsup/cygwin/cygerrno.h
winsup/cygwin/cygheap.cc
winsup/cygwin/cygheap.h
winsup/cygwin/cygmagic
winsup/cygwin/cygmalloc.h
winsup/cygwin/cygserver.h
winsup/cygwin/cygserver_ipc.h
winsup/cygwin/cygthread.cc
winsup/cygwin/cygtls.cc
winsup/cygwin/cygtls.h
winsup/cygwin/cygwin.sc.in
winsup/cygwin/dcrt0.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/dtable.cc
winsup/cygwin/environ.cc
winsup/cygwin/environ.h
winsup/cygwin/errno.cc
winsup/cygwin/exception.h
winsup/cygwin/exceptions.cc
winsup/cygwin/external.cc
winsup/cygwin/fcntl.cc
winsup/cygwin/fenv.cc
winsup/cygwin/fhandler.cc
winsup/cygwin/fhandler.h
winsup/cygwin/fhandler_clipboard.cc
winsup/cygwin/fhandler_console.cc
winsup/cygwin/fhandler_dev.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_proc.cc
winsup/cygwin/fhandler_process.cc
winsup/cygwin/fhandler_procnet.cc
winsup/cygwin/fhandler_procsys.cc
winsup/cygwin/fhandler_procsysvipc.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/gendef
winsup/cygwin/gentls_offsets
winsup/cygwin/glob.cc
winsup/cygwin/globals.cc
winsup/cygwin/grp.cc
winsup/cygwin/heap.cc
winsup/cygwin/hookapi.cc
winsup/cygwin/i686.din
winsup/cygwin/include/a.out.h
winsup/cygwin/include/asm/byteorder.h
winsup/cygwin/include/bits/wordsize.h
winsup/cygwin/include/cygwin/acl.h
winsup/cygwin/include/cygwin/config.h
winsup/cygwin/include/cygwin/cygwin_dll.h
winsup/cygwin/include/cygwin/grp.h
winsup/cygwin/include/cygwin/if.h
winsup/cygwin/include/cygwin/ipc.h
winsup/cygwin/include/cygwin/msg.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/stat.h
winsup/cygwin/include/cygwin/stdlib.h
winsup/cygwin/include/cygwin/sysproto.h
winsup/cygwin/include/cygwin/time.h
winsup/cygwin/include/cygwin/types.h
winsup/cygwin/include/cygwin/version.h
winsup/cygwin/include/fcntl.h
winsup/cygwin/include/fts.h
winsup/cygwin/include/ftw.h
winsup/cygwin/include/glob.h
winsup/cygwin/include/inttypes.h
winsup/cygwin/include/io.h
winsup/cygwin/include/limits.h
winsup/cygwin/include/mntent.h
winsup/cygwin/include/stdint.h
winsup/cygwin/include/sys/cygwin.h
winsup/cygwin/include/sys/dirent.h
winsup/cygwin/include/sys/resource.h
winsup/cygwin/include/sys/socket.h
winsup/cygwin/include/sys/strace.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/premain0.c
winsup/cygwin/lib/premain1.c
winsup/cygwin/lib/premain2.c
winsup/cygwin/lib/premain3.c
winsup/cygwin/libc/arc4random.cc
winsup/cygwin/libc/base64.c
winsup/cygwin/libc/bsdlib.cc
winsup/cygwin/libc/fts.c
winsup/cygwin/libc/ftw.c
winsup/cygwin/libc/inet_network.c
winsup/cygwin/libc/minires-os-if.c
winsup/cygwin/libc/minires.c
winsup/cygwin/libc/nftw.c
winsup/cygwin/libc/rcmd.cc
winsup/cygwin/libc/rexec.cc
winsup/cygwin/libstdcxx_wrapper.cc
winsup/cygwin/localtime.cc
winsup/cygwin/malloc_wrapper.cc
winsup/cygwin/miscfuncs.cc
winsup/cygwin/mkimport
winsup/cygwin/mktemp.cc
winsup/cygwin/mmap.cc
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.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/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/pwdgrp.h
winsup/cygwin/regex/engine.c
winsup/cygwin/regex/regcomp.c
winsup/cygwin/registry.cc
winsup/cygwin/regparm.h
winsup/cygwin/release/1.7.19
winsup/cygwin/resource.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/select.cc
winsup/cygwin/select.h
winsup/cygwin/sem.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/spawn.cc
winsup/cygwin/speclib
winsup/cygwin/spinlock.h
winsup/cygwin/strace.cc
winsup/cygwin/strfuncs.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/tlsoffsets.h
winsup/cygwin/tlsoffsets64.h
winsup/cygwin/tty.cc
winsup/cygwin/tty.h
winsup/cygwin/uinfo.cc
winsup/cygwin/wait.cc
winsup/cygwin/winbase.h
winsup/cygwin/wincap.cc
winsup/cygwin/wincap.h
winsup/cygwin/window.cc
winsup/cygwin/winlean.h
winsup/cygwin/winsup.h
winsup/cygwin/wow64.cc
winsup/cygwin/wow64.h
winsup/cygwin/x86_64.din
winsup/doc/.cvsignore
winsup/doc/ChangeLog
winsup/doc/Makefile.in
winsup/doc/Wishlist
winsup/doc/bodysnatcher.pl
winsup/doc/configure
winsup/doc/configure.ac
winsup/doc/cygserver.xml
winsup/doc/cygwin-api.in.xml
winsup/doc/cygwin-ug-net.xml
winsup/doc/cygwin.xsl
winsup/doc/cygwinenv.xml
winsup/doc/dll.xml
winsup/doc/effectively.xml
winsup/doc/faq-api.xml
winsup/doc/faq-copyright.xml
winsup/doc/faq-programming.xml
winsup/doc/faq-resources.xml
winsup/doc/faq-setup.xml
winsup/doc/faq-using.xml
winsup/doc/faq-what.xml
winsup/doc/faq.xml
winsup/doc/filemodes.xml
winsup/doc/gcc.xml
winsup/doc/gdb.xml
winsup/doc/highlights.xml
winsup/doc/legal.xml
winsup/doc/new-features.xml
winsup/doc/ntsec.xml
winsup/doc/ov-ex-unix.xml
winsup/doc/ov-ex-win.xml
winsup/doc/overview.xml
winsup/doc/pathnames.xml
winsup/doc/programming.xml
winsup/doc/setup-env.xml
winsup/doc/setup-files.xml
winsup/doc/setup-locale.xml
winsup/doc/setup-maxmem.xml
winsup/doc/setup-net.xml
winsup/doc/specialnames.xml
winsup/doc/textbinary.xml
winsup/doc/ug-info.xml
winsup/doc/using.xml
winsup/doc/windres.xml
winsup/doc/xidepend
winsup/lsaauth/ChangeLog
winsup/lsaauth/ChangeLog.64bit
winsup/lsaauth/Makefile.in
winsup/lsaauth/configure
winsup/lsaauth/configure.ac
winsup/utils/ChangeLog
winsup/utils/ChangeLog.64bit
winsup/utils/Makefile.in
winsup/utils/aclocal.m4
winsup/utils/configure
winsup/utils/cygcheck.cc
winsup/utils/dumper.cc
winsup/utils/dumper.h
winsup/utils/kill.cc
winsup/utils/ldd.cc
winsup/utils/locale.cc
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/ps.cc
winsup/utils/regtool.cc
winsup/utils/ssp.c
winsup/utils/strace.cc
winsup/utils/tzset.c
winsup/utils/utils.xml
Delete:
COPYING3
COPYING3.LIB
config.rpath
configure.ac
ltgcc.m4
newlib/libc/machine/aarch64/Makefile.am
newlib/libc/machine/aarch64/Makefile.in
newlib/libc/machine/aarch64/aclocal.m4
newlib/libc/machine/aarch64/configure
newlib/libc/machine/aarch64/configure.in
newlib/libc/machine/aarch64/memcmp-stub.c
newlib/libc/machine/aarch64/memcmp.S
newlib/libc/machine/aarch64/memcpy-stub.c
newlib/libc/machine/aarch64/memcpy.S
newlib/libc/machine/aarch64/memmove-stub.c
newlib/libc/machine/aarch64/memmove.S
newlib/libc/machine/aarch64/memset-stub.c
newlib/libc/machine/aarch64/memset.S
newlib/libc/machine/aarch64/setjmp.S
newlib/libc/machine/aarch64/strcmp-stub.c
newlib/libc/machine/aarch64/strcmp.S
newlib/libc/machine/aarch64/strlen-stub.c
newlib/libc/machine/aarch64/strlen.S
newlib/libc/machine/aarch64/strncmp-stub.c
newlib/libc/machine/aarch64/strncmp.S
newlib/libc/machine/aarch64/strnlen-stub.c
newlib/libc/machine/aarch64/strnlen.S
newlib/libc/machine/epiphany/Makefile.am
newlib/libc/machine/epiphany/Makefile.in
newlib/libc/machine/epiphany/aclocal.m4
newlib/libc/machine/epiphany/configure
newlib/libc/machine/epiphany/configure.in
newlib/libc/machine/epiphany/machine/stdlib.h
newlib/libc/machine/epiphany/setjmp.S
newlib/libc/machine/powerpc/times.c
newlib/libc/sys/epiphany/Makefile.am
newlib/libc/sys/epiphany/Makefile.in
newlib/libc/sys/epiphany/aclocal.m4
newlib/libc/sys/epiphany/configure
newlib/libc/sys/epiphany/configure.in
newlib/libc/sys/epiphany/e_printf.c
newlib/libm/machine/aarch64/Makefile.am
newlib/libm/machine/aarch64/Makefile.in
newlib/libm/machine/aarch64/aclocal.m4
newlib/libm/machine/aarch64/configure
newlib/libm/machine/aarch64/configure.in
newlib/libm/machine/aarch64/s_ceil.c
newlib/libm/machine/aarch64/s_floor.c
newlib/libm/machine/aarch64/s_fma.c
newlib/libm/machine/aarch64/s_fmax.c
newlib/libm/machine/aarch64/s_fmin.c
newlib/libm/machine/aarch64/s_llrint.c
newlib/libm/machine/aarch64/s_llround.c
newlib/libm/machine/aarch64/s_lrint.c
newlib/libm/machine/aarch64/s_lround.c
newlib/libm/machine/aarch64/s_nearbyint.c
newlib/libm/machine/aarch64/s_rint.c
newlib/libm/machine/aarch64/s_round.c
newlib/libm/machine/aarch64/s_trunc.c
newlib/libm/machine/aarch64/sf_ceil.c
newlib/libm/machine/aarch64/sf_floor.c
newlib/libm/machine/aarch64/sf_fma.c
newlib/libm/machine/aarch64/sf_fmax.c
newlib/libm/machine/aarch64/sf_fmin.c
newlib/libm/machine/aarch64/sf_llrint.c
newlib/libm/machine/aarch64/sf_llround.c
newlib/libm/machine/aarch64/sf_lrint.c
newlib/libm/machine/aarch64/sf_lround.c
newlib/libm/machine/aarch64/sf_nearbyint.c
newlib/libm/machine/aarch64/sf_rint.c
newlib/libm/machine/aarch64/sf_round.c
newlib/libm/machine/aarch64/sf_trunc.c
winsup/cygwin/cygwin.din
winsup/cygwin/cygwin.sc
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/effectively.sgml
winsup/doc/faq-sections.xml
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/utils/utils.sgml
Diffstat (limited to 'winsup/cygwin/flock.cc')
-rw-r--r-- | winsup/cygwin/flock.cc | 291 |
1 files changed, 254 insertions, 37 deletions
diff --git a/winsup/cygwin/flock.cc b/winsup/cygwin/flock.cc index 0a2ff9ea2..c9d7eb6ea 100644 --- a/winsup/cygwin/flock.cc +++ b/winsup/cygwin/flock.cc @@ -1,6 +1,6 @@ /* flock.cc. NT specific implementation of advisory file locking. - Copyright 2003, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc. + Copyright 2003, 2008, 2009, 2010, 2011, 2012, 2013 Red Hat, Inc. This file is part of Cygwin. @@ -170,7 +170,7 @@ allow_others_to_sync () MAX_PROCESS_SD_SIZE, &len); if (!NT_SUCCESS (status)) { - debug_printf ("NtQuerySecurityObject: %p", status); + debug_printf ("NtQuerySecurityObject: %y", status); return; } /* Create a valid dacl pointer and set its size to be as big as @@ -197,14 +197,14 @@ allow_others_to_sync () well_known_world_sid); if (!NT_SUCCESS (status)) { - debug_printf ("RtlAddAccessAllowedAce: %p", status); + debug_printf ("RtlAddAccessAllowedAce: %y", status); return; } /* Set the size of the DACL correctly. */ status = RtlFirstFreeAce (dacl, &ace); if (!NT_SUCCESS (status)) { - debug_printf ("RtlFirstFreeAce: %p", status); + debug_printf ("RtlFirstFreeAce: %y", status); return; } dacl->AclSize = (char *) ace - (char *) dacl; @@ -212,7 +212,7 @@ allow_others_to_sync () status = NtSetSecurityObject (NtCurrentProcess (), DACL_SECURITY_INFORMATION, sd); if (!NT_SUCCESS (status)) { - debug_printf ("NtSetSecurityObject: %p", status); + debug_printf ("NtSetSecurityObject: %y", status); return; } done = true; @@ -228,7 +228,7 @@ get_obj_handle_count (HANDLE h) status = NtQueryObject (h, ObjectBasicInformation, &obi, sizeof obi, NULL); if (!NT_SUCCESS (status)) - debug_printf ("NtQueryObject: %p\n", status); + debug_printf ("NtQueryObject: %y", status); else hdl_cnt = obi.HandleCount; return hdl_cnt; @@ -248,9 +248,9 @@ class lockf_t public: uint16_t lf_flags; /* Semantics: F_POSIX, F_FLOCK, F_WAIT */ uint16_t 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) */ - int64_t lf_id; /* Cygwin PID for POSIX locks, a unique id per + off_t lf_start; /* Byte # of the start of the lock */ + off_t lf_end; /* Byte # of the end of the lock (-1=EOF) */ + int64_t 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 */ uint16_t lf_ver; /* Version number of the lock. If a released @@ -268,7 +268,7 @@ class lockf_t 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, + short flags, short type, off_t start, off_t end, long long id, DWORD wid, uint16_t ver) : lf_flags (flags), lf_type (type), lf_start (start), lf_end (end), lf_id (id), lf_wid (wid), lf_ver (ver), lf_head (head), lf_inode (node), @@ -308,8 +308,8 @@ class inode_t 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 */ + dev_t i_dev; /* Device ID */ + ino_t i_ino; /* inode number */ private: HANDLE i_dir; @@ -317,7 +317,7 @@ class inode_t uint32_t i_cnt; /* # of threads referencing this instance. */ public: - inode_t (__dev32_t dev, __ino64_t ino); + inode_t (dev_t dev, ino_t ino); ~inode_t (); void *operator new (size_t size) @@ -325,7 +325,7 @@ class inode_t void operator delete (void *p) { cfree (p); } - static inode_t *get (__dev32_t dev, __ino64_t ino, + static inode_t *get (dev_t dev, ino_t ino, bool create_if_missing, bool lock); void LOCK () { WaitForSingleObject (i_mtx, INFINITE); } @@ -482,7 +482,7 @@ fixup_lockf_after_exec () 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, bool lock) +inode_t::get (dev_t dev, ino_t ino, bool create_if_missing, bool lock) { inode_t *node; @@ -504,7 +504,7 @@ inode_t::get (__dev32_t dev, __ino64_t ino, bool create_if_missing, bool lock) return node; } -inode_t::inode_t (__dev32_t dev, __ino64_t ino) +inode_t::inode_t (dev_t dev, ino_t ino) : i_lockf (NULL), i_all_lf (NULL), i_dev (dev), i_ino (ino), i_cnt (0L) { HANDLE parent_dir; @@ -522,14 +522,14 @@ inode_t::inode_t (__dev32_t dev, __ino64_t ino) 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); + api_fatal ("NtCreateDirectoryObject(inode): %y", 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); + api_fatal ("NtCreateMutant(inode): %y", status); } /* Enumerate all lock event objects for this file and create a lockf_t @@ -554,10 +554,10 @@ lockf_t::from_obj_name (inode_t *node, lockf_t **head, const wchar_t *name) lf_type = wcstol (endptr + 1, &endptr, 16); if ((lf_type != F_RDLCK && lf_type != F_WRLCK) || !endptr || *endptr != L'-') return false; - lf_start = (_off64_t) wcstoull (endptr + 1, &endptr, 16); + lf_start = (off_t) wcstoull (endptr + 1, &endptr, 16); if (lf_start < 0 || !endptr || *endptr != L'-') return false; - lf_end = (_off64_t) wcstoull (endptr + 1, &endptr, 16); + lf_end = (off_t) wcstoull (endptr + 1, &endptr, 16); if (lf_end < -1LL || (lf_end > 0 && lf_end < lf_start) || !endptr || *endptr != L'-') @@ -640,8 +640,8 @@ create_lock_in_parent (PVOID param) OBJECT_NAME_INFORMATION *ntfn; NTSTATUS status; wchar_t *lockname, *inodename, *endptr; - __dev32_t dev; - __ino64_t ino; + dev_t dev; + ino_t ino; inode_t *node; lockf_t newlock, *lock; int cnt; @@ -753,7 +753,7 @@ lockf_t::create_lock_obj () if (!NT_SUCCESS (status)) { if (status != STATUS_OBJECT_NAME_COLLISION) - api_fatal ("NtCreateEvent(lock): %p", status); + api_fatal ("NtCreateEvent(lock): %y", status); /* If we get a STATUS_OBJECT_NAME_COLLISION, the event still exists because some other process is waiting for it in lf_setlock. If so, check the event's signal state. If we can't open it, it @@ -764,7 +764,7 @@ lockf_t::create_lock_obj () if (open_lock_obj ()) { if (!IsEventSignalled (lf_obj)) - api_fatal ("NtCreateEvent(lock): %p", status); + api_fatal ("NtCreateEvent(lock): %y", status); close_lock_obj (); /* Increment the lf_ver field until we have no collision. */ ++lf_ver; @@ -910,15 +910,25 @@ static int maxlockdepth = MAXDEPTH; 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_getlock (lockf_t *, inode_t *, struct flock *); 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); +/* This is the fcntl advisory lock implementation. For the implementation + of mandatory locks using the Windows mandatory locking functions, see the + fhandler_disk_file::mand_lock method at the end of this file. */ int -fhandler_disk_file::lock (int a_op, struct __flock64 *fl) +fhandler_base::lock (int, struct flock *) { - _off64_t start, end, oadd; + set_errno (EINVAL); + return -1; +} + +int +fhandler_disk_file::lock (int a_op, struct flock *fl) +{ + off_t start, end, oadd; int error = 0; short a_flags = fl->l_type & (F_POSIX | F_FLOCK); @@ -1499,7 +1509,7 @@ lf_clearlock (lockf_t *unlock, lockf_t **clean, HANDLE fhdl) * and if so return its process identifier. */ static int -lf_getlock (lockf_t *lock, inode_t *node, struct __flock64 *fl) +lf_getlock (lockf_t *lock, inode_t *node, struct flock *fl) { lockf_t *block; tmp_pathbuf tp; @@ -1577,7 +1587,7 @@ static int lf_findoverlap (lockf_t *lf, lockf_t *lock, int type, lockf_t ***prev, lockf_t **overlap) { - _off64_t start, end; + off_t start, end; *overlap = lf; if (lf == NOLOCKF) @@ -1716,7 +1726,7 @@ flock (int fd, int operation) { int res = -1; int cmd; - struct __flock64 fl = { 0, SEEK_SET, 0, 0, 0 }; + struct flock fl = { 0, SEEK_SET, 0, 0, 0 }; myfault efault; if (efault.faulted (EFAULT)) @@ -1730,19 +1740,22 @@ flock (int fd, int operation) switch (operation & (~LOCK_NB)) { case LOCK_EX: - fl.l_type = F_WRLCK | F_FLOCK; + fl.l_type = F_WRLCK; break; case LOCK_SH: - fl.l_type = F_RDLCK | F_FLOCK; + fl.l_type = F_RDLCK; break; case LOCK_UN: - fl.l_type = F_UNLCK | F_FLOCK; + fl.l_type = F_UNLCK; break; default: set_errno (EINVAL); goto done; } - res = cfd->lock (cmd, &fl); + if (!cfd->mandatory_locking ()) + fl.l_type |= F_FLOCK; + res = cfd->mandatory_locking () ? cfd->mand_lock (cmd, &fl) + : cfd->lock (cmd, &fl); if ((res == -1) && ((get_errno () == EAGAIN) || (get_errno () == EACCES))) set_errno (EWOULDBLOCK); done: @@ -1751,11 +1764,11 @@ done: } extern "C" int -lockf (int filedes, int function, _off64_t size) +lockf (int filedes, int function, off_t size) { int res = -1; int cmd; - struct __flock64 fl; + struct flock fl; pthread_testcancel (); @@ -1800,8 +1813,212 @@ lockf (int filedes, int function, _off64_t size) goto done; /* NOTREACHED */ } - res = cfd->lock (cmd, &fl); + res = cfd->mandatory_locking () ? cfd->mand_lock (cmd, &fl) + : cfd->lock (cmd, &fl); done: syscall_printf ("%R = lockf(%d, %d, %D)", res, filedes, function, size); return res; } + +/* This is the fcntl lock implementation for mandatory locks using the + Windows mandatory locking functions. For the UNIX-like advisory locking + implementation see the fhandler_disk_file::lock method earlier in this + file. */ +struct lock_parms { + HANDLE h; + PIO_STATUS_BLOCK pio; + PLARGE_INTEGER poff; + PLARGE_INTEGER plen; + BOOL type; + NTSTATUS status; +}; + +static DWORD WINAPI +blocking_lock_thr (LPVOID param) +{ + struct lock_parms *lp = (struct lock_parms *) param; + lp->status = NtLockFile (lp->h, NULL, NULL, NULL, lp->pio, lp->poff, + lp->plen, 0, FALSE, lp->type); + return 0; +} + +int +fhandler_base::mand_lock (int, struct flock *) +{ + set_errno (EINVAL); + return -1; +} + +int +fhandler_disk_file::mand_lock (int a_op, struct flock *fl) +{ + NTSTATUS status; + IO_STATUS_BLOCK io; + FILE_POSITION_INFORMATION fpi; + FILE_STANDARD_INFORMATION fsi; + off_t startpos; + LARGE_INTEGER offset; + LARGE_INTEGER length; + + /* Calculate where to start from, then adjust this by fl->l_start. */ + switch (fl->l_whence) + { + case SEEK_SET: + startpos = 0; + break; + case SEEK_CUR: + status = NtQueryInformationFile (get_handle (), &io, &fpi, sizeof fpi, + FilePositionInformation); + if (!NT_SUCCESS (status)) + { + __seterrno_from_nt_status (status); + return -1; + } + startpos = fpi.CurrentByteOffset.QuadPart; + break; + case SEEK_END: + status = NtQueryInformationFile (get_handle (), &io, &fsi, sizeof fsi, + FileStandardInformation); + if (!NT_SUCCESS (status)) + { + __seterrno_from_nt_status (status); + return -1; + } + startpos = fsi.EndOfFile.QuadPart; + break; + default: + set_errno (EINVAL); + return -1; + } + /* Adjust start and length until they make sense. */ + offset.QuadPart = startpos + fl->l_start; + if (fl->l_len < 0) + { + offset.QuadPart -= fl->l_len; + length.QuadPart = -fl->l_len; + } + else + length.QuadPart = fl->l_len; + if (offset.QuadPart < 0) + { + length.QuadPart -= -offset.QuadPart; + if (length.QuadPart <= 0) + { + set_errno (EINVAL); + return -1; + } + offset.QuadPart = 0; + } + /* Special case if len == 0. For POSIX this means lock to the end of + the entire file, even when file grows later. */ + if (length.QuadPart == 0) + length.QuadPart = UINT64_MAX; + /* Action! */ + if (fl->l_type == F_UNLCK) + { + status = NtUnlockFile (get_handle (), &io, &offset, &length, 0); + if (status == STATUS_RANGE_NOT_LOCKED) /* Not an error */ + status = STATUS_SUCCESS; + } + else if (a_op == F_SETLKW) + { + /* We open file handles synchronously. To allow asynchronous operation + the file locking functions require a file handle opened in asynchronous + mode. Since Windows locks are per-process/per-file object, we can't + open another handle asynchrously and lock/unlock using that handle: + The original file handle would not have placed the lock and would be + restricted by the lock like any other file handle. + So, what we do here is to start a thread which calls the potentially + blocking NtLockFile call. Then we wait for thread completion in an + interruptible fashion. */ + OBJECT_ATTRIBUTES attr; + HANDLE evt; + struct lock_parms lp = { get_handle (), &io, &offset, &length, + fl->l_type == F_WRLCK, 0 }; + cygthread *thr = NULL; + + InitializeObjectAttributes (&attr, NULL, 0, NULL, NULL); + status = NtCreateEvent (&evt, EVENT_ALL_ACCESS, &attr, + NotificationEvent, FALSE); + if (evt) + thr = new cygthread (blocking_lock_thr, &lp, "blk_lock", evt); + if (!thr) + { + /* Thread creation failed. Fall back to blocking lock call. */ + if (evt) + NtClose (evt); + status = NtLockFile (get_handle (), NULL, NULL, NULL, &io, &offset, + &length, 0, FALSE, fl->l_type == F_WRLCK); + } + else + { + /* F_SETLKW and lock cannot be established. Wait until the lock can + be established, or a signal request arrived. We deliberately + don't handle thread cancel requests here. */ + DWORD wait_res = cygwait (evt, INFINITE, cw_sig | cw_sig_eintr); + NtClose (evt); + switch (wait_res) + { + case WAIT_OBJECT_0: + /* Fetch completion status. */ + status = lp.status; + thr->detach (); + break; + default: + /* Signal arrived. */ + /* Starting with Vista, CancelSynchronousIo works, and we wait + for the thread to exit. lp.status will be either + STATUS_SUCCESS, or STATUS_CANCELLED. We only call + NtUnlockFile in the first case. + Prior to Vista, CancelSynchronousIo doesn't exist, so we + terminated the thread and always call NtUnlockFile since + lp.status was 0 to begin with. */ + if (CancelSynchronousIo (thr->thread_handle ())) + thr->detach (); + else + thr->terminate_thread (); + if (NT_SUCCESS (lp.status)) + NtUnlockFile (get_handle (), &io, &offset, &length, 0); + /* Per SUSv4: If a signal is received while fcntl is waiting, + fcntl shall be interrupted. Upon return from the signal + handler, fcntl shall return -1 with errno set to EINTR, + and the lock operation shall not be done. */ + _my_tls.call_signal_handler (); + set_errno (EINTR); + return -1; + } + } + } + else + { + status = NtLockFile (get_handle (), NULL, NULL, NULL, &io, &offset, + &length, 0, TRUE, fl->l_type == F_WRLCK); + if (a_op == F_GETLK) + { + /* This is non-atomic, but there's no other way on Windows to detect + if another lock is blocking our lock, other than trying to place + the lock, and then having to unlock it again. */ + if (NT_SUCCESS (status)) + { + NtUnlockFile (get_handle (), &io, &offset, &length, 0); + fl->l_type = F_UNLCK; + } + else + { + /* FAKE! FAKE! FAKE! */ + fl->l_type = F_WRLCK; + fl->l_whence = SEEK_SET; + fl->l_start = offset.QuadPart; + fl->l_len = length.QuadPart; + fl->l_pid = (pid_t) -1; + } + status = STATUS_SUCCESS; + } + } + if (!NT_SUCCESS (status)) + { + __seterrno_from_nt_status (status); + return -1; + } + return 0; +} |