summaryrefslogtreecommitdiff
path: root/os
AgeCommit message (Collapse)AuthorFilesLines
2013-02-15os: Ensure <dix-config.h> is included in strndup.cJeremy Huddleston Sequoia1-0/+4
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-08-23os: fix typo, fsync when WIN32 is _not_ definedPeter Hutterer1-1/+1
Introduced in 164b38c72fe9c69d13ea4f9c46d4ccc46566d826 Reported-by: Jon TURNEY <jon.turney@dronecode.org.uk> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Keith Packard <keithp@keithp.com>
2012-08-21os: don't block signal-unsafe logging, merely warn about it.Peter Hutterer1-14/+24
Throw an error into the log file, but continue anyway. And after three warnings, stop complaining. Not all input drivers will be fixed in time (or ever) and our printf implementation is vastly inferior, so there is still a use-case for non-sigsafe logging. This also adds more linebreaks to the message. CC: Chase Douglas <chase.douglas@canonical.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-08-21os: add support for %d and %i to pnprintfPeter Hutterer1-0/+10
The mouse driver uses %i in some debug messages Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-08-21Add FormatInt64 to convert signed integers in signal-safe mannerPeter Hutterer1-0/+14
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-08-07os: don't unconditionally unblock SIGIO in OsReleaseSignals()Peter Hutterer1-8/+5
Calling OsReleaseSignal() inside the signal handler releases SIGIO, causing the signal handler to be called again from within the handler. Practical use-case: when synaptics calls TimerSet in the signal handler, this causes the signals to be released, eventually hanging the server. Regression introduced in 08962951de. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2012-08-03os: Fix TMP fall-back in Win32TempDir()Colin Harrison1-1/+1
Fix Win32TempDir() in the case where we fell back to checking the TMP environment variable. It looks like this has been wrong since forever. Signed-off-by: Colin Harrison <colin.harrison@virgin.net> Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2012-07-17xwin: Clean up os wrappers for System, Popen and Pclose on WindowsKeith Packard1-0/+73
Popen and Pclose are never used on Windows, so don't bother to even try to define them. System(s) was defined as system(s), but the two users of that function are in xkb, which carefully redefines that as Win32System. Move Win32System and Win32TempDir to os/utils.c, renaming Win32System to be just System, which simplifies the xkb code Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2012-07-10Merge branch 'local-fixes'Keith Packard2-0/+14
2012-07-10GLX: Remove unused noGlxVisualInitDaniel Stone1-1/+0
No-one ever did anything with this variable except assign its default value to it. Signed-off-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Adam Jackson <ajax@redhat.com> Acked-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-09Don't make failure to -nolisten fatalDaniel Stone1-2/+2
If failing to disable a protocol specified by -nolisten failed, we'd throw a FatalError and bomb startup entirely. From poking at xtrans, it looks like the only way we can get a failure here is because we've specified a protocol name which doesn't exist, which probably doesn't constitute a security risk. And it makes it possible to start gdm even though you've built with --disable-tcp-transport. Signed-off-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-09Replace padlength tables with inline functions from misc.hAlan Coopersmith1-4/+2
Adds new function padding_for_int32() and uses existing pad_to_int32() depending on required results. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Keith Packard <keithp@keithp.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Tested-by: Daniel Stone <daniel@fooishbar.org>
2012-07-09Initialize padding bits to 0 in ErrorConnMax()Alan Coopersmith1-1/+1
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Keith Packard <keithp@keithp.com> Tested-by: Daniel Stone <daniel@fooishbar.org>
2012-07-09Set padding bytes to 0 in WriteToClientAlan Coopersmith1-1/+5
Clear them out when needed instead of leaving whatever values were present in previously sent messages. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Keith Packard <keithp@keithp.com> Tested-by: Daniel Stone <daniel@fooishbar.org>
2012-07-09Reliably reset signals at server init timeKeith Packard2-0/+14
Each DDX currently calls OsReleaseSIGIO in case it was suspended when the server regen started. This causes a BUG to occur if SIGIO was *not* blocked at that time. Instead of relying on each DDX, make the OS layer reliably reset all signal state at server init time, ensuring that signals are suitably unblocked and that the various signal state counting variables are set back to zero. Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-04Merge branch 'sigio-vt-switch-issues' into for-keithPeter Hutterer1-3/+51
Conflicts: test/Makefile.am Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-07-03os: add OsBlockSIGIO and OsReleaseSIGIOPeter Hutterer1-3/+51
Let the dix be in charge of changing the sigprocmask so we only have one entity that changes it. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Keith Packard <keithp@keithp.com>
2012-07-02Merge branch 'sigsafe-logging-varargs'Keith Packard4-28/+250
This merge includes a minor fixup for '%p' arguments; must cast to uintptr_t instead of uint64_t as we use -Werror=pointer-to-int-cast which complains when doing a cast (even explicitly) from a pointer to an integer of different size.
2012-07-02Log safely in fatal signal handlerChase Douglas1-4/+4
While we probably don't need to be signal safe here since we will never return to the normal context, the logging signal context check will cause unsafe logging to be unhandled. Using signal safe logging here resolves the issue. Signed-off-by: Chase Douglas <chase.douglas@canonical.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-07-02Warn when attempting to log in a signal unsafe manner from signal contextChase Douglas1-0/+20
Also, print out the offending message format. This will hopefully help developers track down unsafe logging. Signed-off-by: Chase Douglas <chase.douglas@canonical.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-07-02Print backtrace in a signal-safe mannerChase Douglas1-20/+29
Backtraces are often printed in signal context, such as when a segfault occurs. Signed-off-by: Chase Douglas <chase.douglas@canonical.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> os: print offset as unsigned int, not long unsigned int pnprintf() takes unsigned int for %u Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-07-02Add ErrorFSigSafe() alternative to ErrorF()Chase Douglas1-0/+16
ErrorF() is not signal safe. Use ErrorSigSafe() whenever an error message may be logged in signal context. [whot: edited to "ErrorFSigSafe"] Signed-off-by: Chase Douglas <chase.douglas@canonical.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-07-02Add LogMessageVerbSigSafe() for logging messages while in signal contextChase Douglas1-4/+131
[whot: edited to use varargs, squashed commit below] Signed-off-by: Chase Douglas <chase.douglas@canonical.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> os: fix vararg length calculation Make %u and %x sizeof(unsigned int), %p sizeof(void*). This is printf behaviour and we can't guarantee that void* is uint64_t anyway. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-06-22os: print newline after printing display namePeter Hutterer1-0/+1
Much easier for scripts that try to read the display value off the file descriptor. Plus, this restores the behaviour we had for this patch in Fedora since server 1.6 (April 2009). Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-06-21Add FormatUInt64{,Hex}() for formatting numbers in a signal safe mannerChase Douglas1-0/+44
Signed-off-by: Chase Douglas <chase.douglas@canonical.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-06-21Save log file file descriptor for signal context loggingChase Douglas1-0/+4
None of the FILE based functions are signal safe, including fileno(), so we need to save the file descriptor for when we are in signal context. Signed-off-by: Chase Douglas <chase.douglas@canonical.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-06-21Add global variable inSignalContextChase Douglas1-0/+2
This will be used for checking for proper logging when in signal context. Signed-off-by: Chase Douglas <chase.douglas@canonical.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-05-09Merge remote-tracking branch 'whot/for-keith'Keith Packard2-55/+94
2012-05-04os: Add CryptoAPI as a choice of SHA1 implementationYaakov Selkowitz1-0/+42
Both Cygwin and MinGW can use Windows' native CryptoAPI for SHA1, saving a dependency on libgcrypt or OpenSSL. The necessary functions are in ADVAPI32.DLL, which is among the default lib flags and is already used in hw/xwin for accessing the registry. Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net> Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net> Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk> Reviewed-by: Colin Harrison <colin.harrison@virgin.net> Tested-by: Colin Harrison <colin.harrison@virgin.net>
2012-05-03os/log: refactor loggingDaniel Kurtz1-51/+46
It is not safe to ever use an arbitrary (possibly user supplied) string as part of the format for a *sprintf() call. For example: 1. Name a Bluetooth keyboard "%n%n%n%n%n%n%n%n" 2. Pair it with a computer running X and try to use it 3. X is not happy when trying to do the following in xf86-input-evdev: xf86IDrvMsg(pInfo, X_CONFIG, "Device: \"%s\"\n", device); because LogVHdrMessageVerb() has put the %n from the device name into a format string of the form: "evdev: %n%n%n%n%n%n%n%n: Device: \"%s\"\n" Instead, build up a log message in place by appending successive formatted strings by sncprintf'ing to the end of the previous. Signed-off-by: Daniel Kurtz <djkurtz@chromium.org> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-05-03os/log: only write timestamp if a message is actually written to logfileDaniel Kurtz1-9/+9
The current code will write a timestamps into the logFile whenever the last message ended with a '\n' - even if the verb for that timestamp is at too high a level. This timestamp will sit there with no matching message until the next call to LogVWrite with a valid verb. In other words, in some cases, timestamps in the X.org.log are for some completely unrelated message that was previously ignored due to insufficient verbosity, and not for the message that appears next to it in the log file. We keep the current policy which appears to be to only apply timestamps if a message is actually written to a log file. That is, no timestamps on stderr, or in the mem buffer. Therefore, the timestamp stringification is moved to the conditional where it is used. Since logging uses a fixed length buffer, this patch also forces a '\n' whenever a buffer is terminated due to a too-long write request. This allows the newline detection to work even on overflow, and also cleans up the log a bit in the overflow case. Signed-off-by: Daniel Kurtz <djkurtz@chromium.org> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-05-03os/xprintf: add Xvscnprintf and XscnprintfDaniel Kurtz1-0/+44
Normal snprintf() usually returns the number of bytes that would have been written into a buffer had the buffer been long enough. The scnprintf() variants return the actual number of bytes written, excluding the trailing '\0'. Signed-off-by: Daniel Kurtz <djkurtz@chromium.org> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-05-03os/log: trivial cleanupsDaniel Kurtz1-2/+2
* space->tab * remove comment that doesn't make any sense Signed-off-by: Daniel Kurtz <djkurtz@chromium.org> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-05-01os: make timers signal-safePeter Hutterer1-2/+16
If TimerSet() is called from a signal handler (synaptics tap handling code) may result in list corruption if we're currently inside TimerSet(). See backtrace in https://bugzilla.redhat.com/show_bug.cgi?id=814869 Block signals for all list manipulations in the timers. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-05-01os: Add -displayfd optionChase Douglas2-20/+57
This option specifies a file descriptor in the launching process. X will scan for an available display number and write that number back to the launching process, at the same time as SIGUSR1 generation. This means display managers don't need to guess at available display numbers. As a consequence, if X fails to start when using -displayfd, it's not because the display was in use, so there's no point in retrying the X launch on a higher display number. Signed-off-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Chase Douglas <chase.douglas@canonical.com> Reviewed-by: Julien Cristau <jcristau@debian.org> Tested-by: Julien Cristau <jcristau@debian.org> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-03-30os: Fix regression with FatalError not calling va_startJeremy Huddleston1-0/+2
Regression From: a818b305989bbcde4e585112a7ee70cbc0b14a92 Found-by: Colin Harrison <colin.harrison@virgin.net> Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2012-03-24os: Pass the FatalError message to OsVendorFatalErrorJeremy Huddleston1-7/+11
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com> Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2012-03-22Merge branch 'per-device-sync-counters' into for-keithPeter Hutterer2-2/+2
2012-03-22Change lastDeviceIdleTime to be per-devicePeter Hutterer2-2/+2
Preparation work for per-device idle counters. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: James Jones <jajones@nvidia.com>
2012-03-22include: add an X_DEBUG message typePeter Hutterer1-0/+5
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jamey Sharp <jamey@minilop.net>
2012-03-21Introduce a consistent coding styleKeith Packard24-6961/+6675
This is strictly the application of the script 'x-indent-all.sh' from util/modular. Compared to the patch that Daniel posted in January, I've added a few indent flags: -bap -psl -T PrivatePtr -T pmWait -T _XFUNCPROTOBEGIN -T _XFUNCPROTOEND -T _X_EXPORT The typedefs were needed to make the output of sdksyms.sh match the previous output, otherwise, the code is formatted badly enough that sdksyms.sh generates incorrect output. The generated code was compared with the previous version and found to be essentially identical -- "assert" line numbers and BUILD_TIME were the only differences found. The comparison was done with this script: dir1=$1 dir2=$2 for dir in $dir1 $dir2; do (cd $dir && find . -name '*.o' | while read file; do dir=`dirname $file` base=`basename $file .o` dump=$dir/$base.dump objdump -d $file > $dump done) done find $dir1 -name '*.dump' | while read dump; do otherdump=`echo $dump | sed "s;$dir1;$dir2;"` diff -u $dump $otherdump done Signed-off-by: Keith Packard <keithp@keithp.com> Acked-by: Daniel Stone <daniel@fooishbar.org> Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-01-13os: prettify backtrace outputPeter Hutterer1-2/+6
Changes to output: * "Backtrace:" now appears on a separate line _with_ a timestamp * A blank line is inserted after the last backtrace line Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Julien Cristau <jcristau@debian.org>
2012-01-12Revert "os: Repack ConnectionOutput for LP64"Keith Packard1-1/+1
This reverts commit d5f724544afd2949cebfcf4f0b4510ec0c701bec. ABI change pended for 1.13
2012-01-12Revert "dix: Pull client-is-local flag up to the ClientRec"Keith Packard3-2/+10
This reverts commit 49d38b75c8f3276cfce33ffe6b8c4fbeb1081b96. ABI change pended for 1.13
2012-01-12Revert "dix: Extend initial connection handshake for forwarding proxies"Keith Packard1-5/+5
This reverts commit 78fa121f4097d29458e5453c13473595df06e26e. ABI change pended for 1.13
2012-01-12Revert "os: Hide the Connection{In,Out}put implementation details"Keith Packard3-21/+18
This reverts commit 48e7a2ef574c8b38c4f8f07b45f54c8bfd02552b. ABI change pended for 1.13
2012-01-09Add OpenBSD support to DetermineClientCmd()Matthieu Herrb1-1/+42
Uses kvm_getargv() from libkvm. Signed-off-by: Matthieu Herrb <matthieu.herrb@laas.fr> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2012-01-09Merge commit '777bf90abeac37087a3d0538b847742523d5acf2'Keith Packard4-37/+32
2012-01-09Merge remote-tracking branch 'kibi/master'Keith Packard1-1/+5
2012-01-06os: Minor header cleanupAdam Jackson3-4/+4
Move some constants near their only users, and remove some getdtablesize() logic that's second-guessing configure. Reviewed-by: Daniel Stone <daniel@fooishbar.org> Signed-off-by: Adam Jackson <ajax@redhat.com>