Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-WM-Posted-At: avacado.atomice.net; Fri, 5 Jul 02 18:29:51 +0100 Message-ID: <004f01c22449$91da71a0$0100a8c0@advent02> From: "Chris January" To: Cc: References: Subject: Re: /proc/uptime etc. - NtQuerySystemInformation() needs bigger structure Date: Fri, 5 Jul 2002 18:29:51 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 > /proc/uptime, /proc/stat, and /proc/*/stat seem not to be working for > me with cygwin 1.3.12. I think I've found a fix, though. > > Looking at the code for uptime, it seems to be using > NtQuerySystemInformation() -- a function which I investigated fairly > thoroughly a while back while when disassembling win2k's taskmgr.exe > (in order to write a wrapper to tweak its output to ignore specified > processes in its usage graph). > > One thing I noticed was that function 8 (named SystemProcessorTimes in > the cygwin source) needs an extra DWORD member at the end of its > structure. This isn't overwritten, yet needs to be included in the > structure size. (Who am I to suggest that MS simply got it wrong, and > require the wrong size as a parameter; it's clearly just an usused > value. :-) ) This is consistent with strace's report of > NtQuerySystemInformation returning 0xc0000004 > (STATUS_INFO_LENGTH_MISMATCH). > > The following patch seems to fix the problem. I've not done thorough > tests to see if it's broken anything else. I just altered ntdll.h, > and attempted to build from source. This didn't get further than > having problems with memset in winsup/utils/cygcheck.cc (and I've not > yet had chance to investigate why, other than to recognise it as the > same problem I had much earlier with #include_next until I > built into a separate dir from the source), but it did get as far as > building new-cygwin1.dll before giving up. Putting this dll (named as > cygwin1.dll) in a dir together with cat.exe, and, from a non-cygwin > shell, running "cat /proc/uptime" seems to work. I've not tried > putting it in /usr/bin/cygwin1.dll, so there's a small chance it would > break something else. > > The diff is against the released source, not the latest cvs version, > but I assume the patch will still apply. (I've not got enough > bandwidth at home to justify getting the CVS version (though hopefully > I soon will), and the firewall at work prevents it (though I wouldn't > have enough time there, anyway).) > > Please CC me any reply (if one happens to be needed), rather than > sending just to the list (as I'm not yet subscribed). > > > --- winsup/cygwin/ntdll.h.old 2002-05-30 21:21:04.000000000 +0100 > +++ winsup/cygwin/ntdll.h 2002-07-05 11:15:52.000000000 +0100 > @@ -58,6 +58,7 @@ typedef struct _SYSTEM_PROCESSOR_TIMES > LARGE_INTEGER DpcTime; > LARGE_INTEGER InterruptTime; > ULONG InterruptCount; > + ULONG Unused; > } SYSTEM_PROCESSOR_TIMES, *PSYSTEM_PROCESSOR_TIMES; > > typedef LONG KPRIORITY; I will look at this patch tonight, but I would be grateful if you could answer the following questions: What version of binutils are you using? If you compiled Cygwin using just the 1.3.12 sources with no modifications, does /proc/uptime have any content? Chris -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/