delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/02/01/15:58:36

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/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
From: ericblake AT comcast DOT net
To: cygwin AT cygwin DOT com
Subject: several more bugs found by coreutils
Date: Tue, 01 Feb 2005 20:58:03 +0000
Message-Id: <020120052058.2301.41FFED5A000D5EEC000008FD22007614380A050E040D0C079D0A@comcast.net>
X-Authenticated-Sender: ZXJpY2JsYWtlQGNvbWNhc3QubmV0

Further coreutils-5.3.0 debugging turned up more POSIX bugs in cygwin:

<pwd.h> defines struct passwd with the pw_uid and pw_gid members as ints, although POSIX requires uid_t and gid_t.
http://www.opengroup.org/onlinepubs/009695399/basedefs/dirent.h.html

<sys/time.h> defines utimes with non-const second parameter, although POSIX requires it to be const; likewise for utime in <utime.h> (deferred to <sys/utime.h>).  Additionally, both utimes() and utime() are required to touch file ctime on success.
http://www.opengroup.org/onlinepubs/009695399/functions/utimes.html

readdir() populates the dirent.d_ino member with a hashed filename, regardless of whether the file is located on NTFS and actually has an inode.  This means that readdir() and stat()'s idea of inode are different, and this breaks the pwd program (it tries to find a directory member in ".." using readdir that has the same node as "." according to stat).

#include <unistd.h>
#include <stdio.h>
#include <sys/resource.h>
#include <errno.h>
#include <dirent.h>
#include <sys/stat.h>
int main(int argc, char**argv)
{
   int i;
   DIR* dir;
   struct dirent* ent;
   struct stat st;
   mkdir("d");
   dir = opendir("d");
   while ((ent = readdir(dir)))
   {
      printf("Found `%s', inode %llu\n", ent->d_name, ent->d_ino);
   }
   stat("d", &st);
   printf("`.' inode should have been %llu\n", st.st_ino);
   stat(".", &st);
   printf("`..' inode should have been %llu\n", st.st_ino);
   rmdir("d");
   return 0;
}


--
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