delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/05/10/13:08:05

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <3EBD3179.6070004@ece.gatech.edu>
Date: Sat, 10 May 2003 13:06:01 -0400
From: Charles Wilson <cwilson AT ece DOT gatech DOT edu>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4a) Gecko/20030401
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: cygipc (and PostgreSQL) XP problem resolved!
References: <20030506174725 DOT GE1652 AT tishler DOT net> <3EB84F52 DOT 3020608 AT ece DOT gatech DOT edu> <20030507133326 DOT GA1824 AT tishler DOT net> <3EB9A54B DOT 8060500 AT ece DOT gatech DOT edu> <20030508135217 DOT GD512 AT tishler DOT net> <3EBB22F5 DOT 4000801 AT ece DOT gatech DOT edu> <1052541657 DOT 1675 DOT 5 DOT camel AT localhost> <3EBC8ED0 DOT 4040906 AT ece DOT gatech DOT edu> <20030510072239 DOT GA19367 AT cygbert DOT vinschen DOT de> <1052554219 DOT 1824 DOT 14 DOT camel AT localhost> <20030510082949 DOT GD19367 AT cygbert DOT vinschen DOT de>
In-Reply-To: <20030510082949.GD19367@cygbert.vinschen.de>

Corinna Vinschen wrote:

> 
> Is there actually a need to convert key_t to 64 bit?
> 
> Corinna
>

with old 32bit key_t, cygipc uses this to create a key for a given 
filepath and id#:

   key = ((st.st_ino & 0xffff) | ((st.st_dev & 0xff) << 16)
          | ((id & 0xff) << 24));

Given the sizes of the various fields of st, there are obvious problems 
with aliasing here.

cygdaemon (and cygipc) with 64bit key_t uses:

   /* dev_t is short for cygwin
    * ino_t is long for cygwin
    * and we need 8 bits for the id.
    * thus key_t is long long.
    */
   return ((long long) statbuf.st_dev << (5*8)) |
           (statbuf.st_ino << (8) ) |
           (id & 0x00ff);

Currently, the above code is in winsup/cygwin/ipc.cc -- but if key_t is 
32 bits, the (long long) cast gets recast down to 32bits by the 'return' 
statement.  Which means that the ftok() function currently exported by 
cygwin is more or less broken -- fortunately nothing uses that except 
cygdaemon.

--Chuck



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019