Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
To: cygwin@cygwin.com
Cc: prj@po.cwru.edu (Paul Jarc)
Subject: link() bug
From: Jim Pritts <jpritts@sdf.lonestar.org>
Date: Mon, 02 Aug 2004 23:44:13 -0400
Message-ID: <80vfg0ubqq.fsf@sdf.lonestar.org>
User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through Obscurity, cygwin32)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-IsSubscribed: yes

I created a program that demonstrates a bug with link() in Cygwin.
The program first creates a file named "dummy" and then creates 1050
hard links to file "dummy" by calling link().  link() reports no error
for all 1050 calls.  However when an "ls -la dummy" is performed, only
1024 hard links to dummy are reported.  In addition, if an ls -la is
performed on any hard link greater than 1023, then the report is that
there is only one hard link to the underlying inode.  If link() cannot
perform the hard link properly, then it should report an error which
it does not. Source and makefile are included to demonstrate the bug.

source:

#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>

extern int errno;

int main() 
{
  FILE* f = fopen("dummy", "w");
  fclose(f);
  char buff[1000];
  for (int i=0; i < 1050; ++i) {
    sprintf(buff, "%d", i);
    int err = link("dummy", buff);
    switch(err) {
    case 0:
      printf("no error: %d\n", i);
      break;
    case -1:
      printf("error: %s\n", strerror(errno));
      break;
    }
  }
}

makefile:

test: main.cc 
	g++ -o test main.cc


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

