From nobody Sun Feb 18 01:14:28 2024 X-Original-To: freebsd-questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Tcnl01zTkz5BM0n for ; Sun, 18 Feb 2024 01:14:36 +0000 (UTC) (envelope-from grog@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Tcnkz5gjjz47Gx; Sun, 18 Feb 2024 01:14:35 +0000 (UTC) (envelope-from grog@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708218876; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=l74f0aPaLxVNgXyMaxMj4nJV1nmlI5uI4sZWhhVQT2o=; b=PmvIzkrpkYxdwh0osbSJERvpkyAFStSzBR/ySF77Dm+89IqfL7OfSZtTZLGZtvIFOTMWF0 FKQyBNAh4tyovQJBOFeCWTynec+pembcFv0d3GuYVAiX+q8PvwtJ5IQDTa/bF3eiAL7Lr5 o1dFr1NSroZNB1q9vKGsQdkUsGR72CfYRUS7fhQLXKNDm9Mzl9XLB/RWTw8IvsAhZf5FEP 2REar3bJ1/VbTePQeDAbJt6+8xKiTfdkK5R8FHU6IFmEfFLzcvwhE91jlp1PKQ12RNCNHU cbfKMO7XR6lwbL1aT5la99NHpXpLr8sx1HXTbk1H2fclhX+QvwT6uvA/px8Ggw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708218876; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=l74f0aPaLxVNgXyMaxMj4nJV1nmlI5uI4sZWhhVQT2o=; b=ie5mXF7OhCVPg7X3b1LT1Qy/P6q0hZYCLB1w7op+wOG/1jqXtWT8bDpIcvhcGlSM8CvxtH zyzlxIDgXuHfIkf1ShB1D7gKugJ7P+GZu9E1cXpZveSaFbvlmb6NI1wRyy5ePe2/ELsUy1 HB10GvLMLSXzxxJBp9BJ1lXTVeVK9W6KLNOQr5N28wSJf7ZYM1SxINaDmEvc5SzlypadiB 5DlToorrqnt0/uLXxSQmRBZE8XOHDNQDBzK/0USLaG0oUAOlHPZMepS/uWjeUJYYuqN0+A 9s0YIVcroLZUCPARTtvGCP/mtWWndj2a+xQKk39Se6KlQMC+4Vmb/h0sGnMHig== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708218876; a=rsa-sha256; cv=none; b=TUECguzyp9iP2AjZMqMyjOv5w53YUcb6XVQYEpcib9w6NsLURWTSGjmUeTHJcJSrvVNRYY Tt3qU+ThPCduMtJgR1o7ck3+YDR8ljisFEjF+Lr0GFeSgUHbGheLSRN2v2DK8Rux6Wzj1z FUPDC8NXkLk0i2Y3+ZGONBJ+W7iMz69injHGMRb3lbEXX7HKepyRJXz9RjbYAQQsKz6yGV SG8Esg3Zn4pW4YiqolWD6F/mc5yoI2mFmwHPWb0W8370Vy0YxyWWIRA/33tied/gK3uT/Y VZAzO3EHhT8CzRhjZrTUUqZ38Lt2+rwvHSukHlgNFrNlYgV63hwB3zWr8fay5Q== Received: from hydra.lemis.com (121-200-11-253.79c80b.mel.nbn.aussiebb.net [121.200.11.253]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: grog/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4Tcnky3Gq8z1GY6; Sun, 18 Feb 2024 01:14:34 +0000 (UTC) (envelope-from grog@freebsd.org) Date: Sun, 18 Feb 2024 12:14:28 +1100 From: Greg 'groggy' Lehey To: Gary Aitken Cc: FreeBSD Mailing List Subject: Re: hard link pointing to itself? Message-ID: References: List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="IbZgwB8LFlK7lVhp" Content-Disposition: inline In-Reply-To: Organization: The FreeBSD Project Phone: +61-3-5309-0418 Mobile: +61-490-494-038. Use only as instructed. WWW-Home-Page: https://www.FreeBSD X-PGP-Fingerprint: 9A1B 8202 BCCE B846 F92F 09AC 22E6 F290 507A 4223 --IbZgwB8LFlK7lVhp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Saturday, 17 February 2024 at 8:28:53 -0700, Gary Aitken wrote: > running 13.2-release, > created a tar archive, went to extract on another 13.2-release system, > and got several messages of the form: > > $ tar xf tmp.tar path-to-file/filename.jpg: > Skipping hardlink pointing to itself: path-to-file/filename.jpg: > File exists Fascinating. I'm rearranging the rest of your message to hopefully explain things better. > How does one tell it's a hard link? The simple answer is: it *is* a hard link. But read on. There's also a complicated answer. > I can get the inode number using ls -il, but that doesn't tell me > much regarding its being a hard link when there is only one file. Yes, it does. The inode number tells you that it's a hard link. A step back: the Unix file systems identify files by the inode number. The names are something like an afterthought: they're stored in directories (and emphatically *not* folders), with a pointer to the inode number, rather like names in a telephone directory. And this combination is called a link, from the name to the inode. Later symbolic links came along. They're a different beast: instead of pointing to an inode, they point to another name. But that gave rise to the term "hard link" to distinguish real links from symbolic links. > If I go to the source directory on the original system and do: > > find . | grep filename.jpg > > I see only one file. > > Any idea how this file could have been created? Yes, it's confusing. It confused me too. I went and took a look at the sources (in this case the file /usr/src/contrib/libarchive/libarchive/archive_write_disk_posix.c), and found what's going on--I think. The hard links aren't in the file system, they're in the tar archive. And one of the more obscure things about a tar archive is that it needs to keep track of files with multiple links (names). It stores the file under one name, and if there are any more, it creates a reference to the same file. It seems that this somewhat confusing message is saying that it discovered some inconsistency that it (and the author of libarchive) wasn't expecting. From the source to archive_write_disk_header() (round line 563): /* * Extract this entry to disk. * * TODO: Validate hardlinks. According to the standards, we're * supposed to check each extracted hardlink and squawk if it refers * to a file that we didn't restore. I'm not entirely convinced this * is a good idea, but more importantly: Is there any way to validate * hardlinks without keeping a complete list of filenames from the * entire archive?? Ugh. */ Without going into too much detail, this looks like some kind of bug. I've tried to think of a number of scenarios, but I can't at the moment. It would be interesting to know what you were trying to do. Does it happen when you try to extract the entire archive to an empty hierarchy? Does this file have multiple links? That's the number in the second column of ls -l output. Normally it's 1 for a file, but if there are additional links, it will show the number. Another thing that might be interesting would be to try GNU tar (gtar, in the ports). It might accept the archive, or it might produce a different error result. > I'm pretty sure the original was a lower-resolution file written > from gimp, but that wouldn't have been a hard link. There's a > reasonable chance I tried to create a hard link at some point, but I > don't see a reference to it. There's not much to reference. To create a link, you do ln existing-file new-file That's a normal ("hard") link. A symlink would be ln -s existing-file new-file > Suspiciously, the tarball had several of these, and quit after > reporting a few on extraction. My guess is that there might be two different issues here. The message you show is a warning, though it does mean that the file doesn't get restored. Was there another message at the end? Greg -- When replying to this message, please copy the original recipients. If you don't, I may ignore the reply or reply to the original recipients. For more information, see http://www.lemis.com/questions.html Sent from my desktop computer. See complete headers for address and phone numbers. This message is digitally signed. If your Microsoft mail program reports problems, please read http://lemis.com/broken-MUA.php --IbZgwB8LFlK7lVhp Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EARECAB0WIQSaG4ICvM64RvkvCawi5vKQUHpCIwUCZdFZ8AAKCRAi5vKQUHpC I516AJ4kV0zsEU5hfQhmkfdQDZ5p/h10EgCgnLLQ3UtFA3IYmZWeyv++wh4rb4w= =568O -----END PGP SIGNATURE----- --IbZgwB8LFlK7lVhp--