From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: Function to find symlink target Date: Sat, 28 May 2022 19:08:57 +0300 Message-ID: <83pmjxljvq.fsf@gnu.org> References: <875ylxe98k.fsf@dataswamp.org> <878rqsyo1x.fsf@dataswamp.org> <87wneb690a.fsf@dataswamp.org> <871qwjzqg5.fsf@web.de> <87o7zn65jp.fsf@dataswamp.org> <87ilpvd5s1.fsf@web.de> <87bkvn9x12.fsf@dataswamp.org> <87czg35n3g.fsf@web.de> <871qwif973.fsf@web.de> <87fskv9gm8.fsf@dataswamp.org> <87pmjxoev5.fsf@dataswamp.org> <87leuloe7v.fsf@dataswamp.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25005"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat May 28 18:09:27 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nuz0J-0006MS-AQ for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 28 May 2022 18:09:27 +0200 Original-Received: from localhost ([::1]:59062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nuz0I-00043X-1e for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 28 May 2022 12:09:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuyzs-00043L-Sz for help-gnu-emacs@gnu.org; Sat, 28 May 2022 12:09:00 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:58808) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuyzs-0000bf-KE for help-gnu-emacs@gnu.org; Sat, 28 May 2022 12:09:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=7vJjKeMR0Jce7T01+q5k7Q+N9uuGNT5P6wen2pJdUnU=; b=loXeFeMrOdSL hTLHJIhIKzKThLbvL+gf/GWP8Aa5InAfuTuI5I3FoS3PIpxLfxoMUxenYQv1xRaSwMOlTOeyYvgGf cCSYtTWdPMORynn4dZh8ilg9A1HZ0sPrByu6mErH2g23v+DUA1bPm6id9tLiPD8zy7XM5VY2gpxbF n7FNZnE4xVu9mshi5WTR2pk5Yi6xENy/+PnMF1NJcqvw25dXd2MGkILF2ZUo8CxurqWa6QtehmPp8 LiTMwhVo4DcTeZMR3Y1MvlpILKq1kgnt1Z497yOwuxcQeM3C8IER8xjuqBOmKHlBxWCyTUFjvF9cm elzewkzypdSuvLncLJBk2Q==; Original-Received: from [87.69.77.57] (port=3466 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuyzs-0005te-4l for help-gnu-emacs@gnu.org; Sat, 28 May 2022 12:09:00 -0400 In-Reply-To: <87leuloe7v.fsf@dataswamp.org> (message from Emanuel Berg on Sat, 28 May 2022 17:43:00 +0200) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:137451 Archived-At: > From: Emanuel Berg > Date: Sat, 28 May 2022 17:43:00 +0200 > > > How big is a symlink? > > > > $ touch a.txt > > $ ln -s a.txt a-sy.txt > > $ du -b a-sl.txt > > 5 > > > > 5 bytes. The path to a.txt > ^ relative > > Yes, if one places the symlink in some another dir than the > target then the size increases. > > Observe > > $ cd > $ mkdir -p test/sl > $ cd !:2 > $ touch a > $ ln -s a b > $ cd > $ ln -s test/sl/a l > > then compare > > $ du -b test/sl/b > 1 test/slb/ > > $ du -b l > 9 l > > Lesson: There is a lot of space to save by placing symlinks correctly! Actually, for short enough symlinks (like shorter than 60 bytes), there are no disk space savings at all, regardless of the actual length of the reference target. You evidently assume that a symlink is stored in some particular way on disk, but the reality is different from your assumption. What 'ls' and 'du' show you is largely an illusion.