From owner-freebsd-bugs@FreeBSD.ORG Fri Feb 4 21:21:00 2005 Return-Path: Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5B38E16A4CE for ; Fri, 4 Feb 2005 21:21:00 +0000 (GMT) Received: from rosebud.otenet.gr (rosebud.otenet.gr [195.170.0.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9907A43D45 for ; Fri, 4 Feb 2005 21:20:57 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from gothmog.gr (patr530-a208.otenet.gr [212.205.215.208]) j14LJq2W032490; Fri, 4 Feb 2005 23:19:53 +0200 Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.13.1/8.13.1) with ESMTP id j14LJnB9001311; Fri, 4 Feb 2005 23:19:49 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from giorgos@localhost) by gothmog.gr (8.13.1/8.13.1/Submit) id j14LJnNm001310; Fri, 4 Feb 2005 23:19:49 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Fri, 4 Feb 2005 23:19:49 +0200 From: Giorgos Keramidas To: Mario Hoerich Message-ID: <20050204211949.GC1041@gothmog.gr> References: <200502040930.j149UQDc043307@freefall.freebsd.org> <20050204201622.GA29998@Pandora.MHoerich.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050204201622.GA29998@Pandora.MHoerich.de> cc: freebsd-bugs@freebsd.org cc: Fergus Cameron Subject: Re: bin/77031: [patch] comm(1) unable to handle lines greater than LINE_MAX (2048) X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Feb 2005 21:21:00 -0000 On 2005-02-04 21:16, Mario Hoerich wrote: > # Fergus Cameron: > > http://people.freebsd.org/~keramida/fergus/comm.c-diff > > Now to your patch. What I've noticed while doing a preliminary > review (bit short on time right now) was: > > file1 = file( argv[0] ) ; > file2 = file( argv[1] ) ; > > if( file1 == file2 ) > errx(EXIT_FAILURE, "cannot match file against self"); > > You sure this is guaranteed to trigger? I'm not standard- > savvy enough to know for sure, but it seems like a potential > problem. Anyone with a definitive answer? It is not guaranteed by any standard that I know of. A small sample program like the following shows it is, in fact, not going to work on FreeBSD: % #include % #include % % int % main(int argc, char *argv[0]) % { % FILE *fp, *fp2; % % if (argc != 2) % errx(1, "usage: foo FILENAME"); % fp = fopen(argv[1], "r"); % if (fp == NULL) % err(1, "fopen: %s", argv[1]); % fp2 = fopen(argv[1], "r"); % if (fp2 == NULL) { % fclose(fp); % err(1, "fopen: %s", argv[1]); % } % printf("%p\n%p\n", fp, fp2); % fclose(fp); % fclose(fp2); % return (0); % } This will not print the same pointer value for fp and fp2, regardless of the fopen() calls being passed the same filename as their first argument: % $ ./foo foo % 0x28148880 % 0x281488d8 FWIW, a good way to find if two files are, indeed, pointers to the same i-node (i.e. hard links to the same disk file) is to compare the device major/minor numbers *AND* the i-node number.