From unknown Thu Jun 19 16:20:24 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#14628 <14628@debbugs.gnu.org> To: bug#14628 <14628@debbugs.gnu.org> Subject: Status: mv: safeguard against renaming dir with open files Reply-To: bug#14628 <14628@debbugs.gnu.org> Date: Thu, 19 Jun 2025 23:20:24 +0000 retitle 14628 mv: safeguard against renaming dir with open files reassign 14628 coreutils submitter 14628 "S. Dara" severity 14628 wishlist thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 15 16:17:56 2013 Received: (at submit) by debbugs.gnu.org; 15 Jun 2013 20:17:56 +0000 Received: from localhost ([127.0.0.1]:46786 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Unwv6-0004u4-4F for submit@debbugs.gnu.org; Sat, 15 Jun 2013 16:17:56 -0400 Received: from eggs.gnu.org ([208.118.235.92]:54819) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1UnwgJ-0004Pe-1g for submit@debbugs.gnu.org; Sat, 15 Jun 2013 16:02:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UnwgB-0005dI-Ax for submit@debbugs.gnu.org; Sat, 15 Jun 2013 16:02:33 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_20,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:37346) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnwgB-0005dC-7x for submit@debbugs.gnu.org; Sat, 15 Jun 2013 16:02:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Unwg8-0001aT-G4 for bug-coreutils@gnu.org; Sat, 15 Jun 2013 16:02:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Unwg5-0005bu-ST for bug-coreutils@gnu.org; Sat, 15 Jun 2013 16:02:28 -0400 Received: from mail-we0-x233.google.com ([2a00:1450:400c:c03::233]:36656) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Unwg5-0005bU-Li for bug-coreutils@gnu.org; Sat, 15 Jun 2013 16:02:25 -0400 Received: by mail-we0-f179.google.com with SMTP id w59so1359829wes.38 for ; Sat, 15 Jun 2013 13:02:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=dGtFpm30noDWyWtkbjnF+JfotRKlSJ2K6BEH4iVbp+4=; b=rH90FLYB84oZVLJTBwl0zUjejBVdapwHwQs/JKS+GJ4Gmo8YlWVTk8oz2UZxAvzXCF 7RbHX+ThWF+ph1IYzSxYakFXWrr0Ah/DlbtSoYULEe8xhCnNxOcTq0WTzgDTZVZ+7AQc OQZB7qJfCi0DReNx1fGG8XC0Oifni7MfqIx+wQLEA/71JNV02LROaev82uiCpgSAIDtG oUtw8ABBq1HCrX83TTsnIbtkoIjfjweTIoah3oe1dGRzCk88wzdos5ajPDdTjh1xUiKa rZ8zc4lR2K7V7+hQUYHJk5YwhlEyvNtPLqtxrw8OxXuCo1wC7sT/4XaiL5grmh220WQu f46Q== X-Received: by 10.194.176.41 with SMTP id cf9mr4277612wjc.66.1371326544083; Sat, 15 Jun 2013 13:02:24 -0700 (PDT) Received: from localhost.localdomain (82-169-73-247.ip.telfort.nl. [82.169.73.247]) by mx.google.com with ESMTPSA id dz8sm11691608wib.11.2013.06.15.13.02.23 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 15 Jun 2013 13:02:23 -0700 (PDT) Message-ID: <51BCC84E.4010508@gmail.com> Date: Sat, 15 Jun 2013 22:02:22 +0200 From: "S. Dara" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6 MIME-Version: 1.0 To: bug-coreutils@gnu.org Subject: mv command (and suggesting a feature for it) Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.3 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sat, 15 Jun 2013 16:17:54 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.3 (----) Dear authors of the mv command, With this email, I would like to suggest a feature for the mv command. I believe this command should contain a safeguard feature which will deny renaming a directory that contains files which are currently opened by the user. For example, I have a directory named 'my directory'. In this directory, there is a .txt file which I had opened and was entering text in it. In the command prompt, I decided to change the name of 'my directory' to 'mydirectory' using the command 'mv -ivT my\ directory mydirectory'. Although command succeeded, when I wanted to save the text file which I was working on I got an error from my text editor saying the directory does not exist. This is due to the name change of the parent directory of the .txt-file. I hope the problem is clear by above example. If there already exists such safeguard by providing some specific option to the mv command, then please discard this email and my apologies. With kind regards, Saif Dara From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 15 19:36:02 2013 Received: (at 14628) by debbugs.gnu.org; 15 Jun 2013 23:36:02 +0000 Received: from localhost ([127.0.0.1]:47026 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Uo00m-00036A-Pp for submit@debbugs.gnu.org; Sat, 15 Jun 2013 19:36:01 -0400 Received: from mail3.vodafone.ie ([213.233.128.45]:47906) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Uo00g-00035j-Oe; Sat, 15 Jun 2013 19:35:58 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjgDAIn5vFFtTeTX/2dsb2JhbAANTb9egmkDAYEagxcBAQEEMgFGEAsNCwkWDwkDAgECAUUGDQEHAQGvTZFHjgVjXweDYAOeBI4QgXA Received: from unknown (HELO [192.168.1.79]) ([109.77.228.215]) by mail3.vodafone.ie with ESMTP; 16 Jun 2013 00:35:48 +0100 Message-ID: <51BCFA54.3090704@draigBrady.com> Date: Sun, 16 Jun 2013 00:35:48 +0100 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: "S. Dara" Subject: Re: bug#14628: mv command (and suggesting a feature for it) References: <51BCC84E.4010508@gmail.com> In-Reply-To: <51BCC84E.4010508@gmail.com> X-Enigmail-Version: 1.5.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 14628 Cc: 14628@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) tag 14628 wishlist stop On 06/15/2013 09:02 PM, S. Dara wrote: > Dear authors of the mv command, > > With this email, I would like to suggest a feature for the mv command. I believe this command should contain a safeguard feature which will deny renaming a directory that contains files which are currently opened by the user. > > For example, I have a directory named 'my directory'. In this directory, there is a .txt file which I had opened and was entering text in it. In the command prompt, I decided to change the name of 'my directory' to 'mydirectory' using the command 'mv -ivT my\ directory mydirectory'. Although command succeeded, when I wanted to save the text file which I was working on I got an error from my text editor saying the directory does not exist. This is due to the name change of the parent directory of the .txt-file. > > I hope the problem is clear by above example. If there already exists such safeguard by providing some specific option to the mv command, then please discard this email and my apologies. > > > With kind regards, While I see the issue, I think it's probably outside the remit of mv to make such checks. Depending on how the open file is being processed, it may be immune to renames. I.E. if the file descriptor is just being manipulated, then naming is irrelevant. Also if name operations are done on relative paths and the rename is higher in the directory hierarchy, again the rename is irrelevant. I'm thinking that something external to mv could be used here, like: safe_rename() { lsof +D "$1" >/dev/null 2>&1 || mv "$1" "$2"; } Note however lsof as presented there at least doesn't support this with the correct exit code, due to it requiring _all_ files rather than _any_ files in the hierarchy under "$1" to be open. This is also a very expensive operation as noted in the lsof man page. cheers, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 19 12:53:16 2018 Received: (at 14628) by debbugs.gnu.org; 19 Oct 2018 16:53:16 +0000 Received: from localhost ([127.0.0.1]:59722 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gDY1U-0008Uv-AQ for submit@debbugs.gnu.org; Fri, 19 Oct 2018 12:53:16 -0400 Received: from mail-pf1-f176.google.com ([209.85.210.176]:39842) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gDY1Q-0008Ua-He; Fri, 19 Oct 2018 12:53:12 -0400 Received: by mail-pf1-f176.google.com with SMTP id c25-v6so16736482pfe.6; Fri, 19 Oct 2018 09:53:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=hgygihm0jeBNIiSvZRpc/FyNttLdgnBqRQjPpo2r0oc=; b=dy/1y+EiPV8WwaYefCcVyPOo4uycikNpj+w6SNl+FZD+6LT6ILPLQsaaePHMeieMFd 3l9r+LMf+Vkp269OeH+roC7EKlkjtw71NllTYtLbmJDR1RXQawPwuHc0FRbmPvHgbRNp 8kNK/9PdgS6tlz1KHMW8+gt4LcQTTU2k53860tT9Zzeh0IUQuto7zkTseUtYWcW1Iiyf g9RUGjvj7g1dyLDPzmLr1YNszxx1PpNKizYogYZYu7ngo+EHlT+hbBImx4IFsD6QMJLa GgCoUZGEFOe3n7zglEwt3sHTu50VjMirZgjnQl/n1ClGofaRlfzj5yLA76wq2EPdlMae 7qfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=hgygihm0jeBNIiSvZRpc/FyNttLdgnBqRQjPpo2r0oc=; b=BO65xllj/GOc7E+GY5M4430G8dR7uuinCxNF45Tq3zwARhRztBwBetGgFnOEhLvvB/ E4xJQcu2T/XtW1OTSmsOJO5TAKQa7acirys6blZfMOogWnuPgeZ1sIkbxhNvJTlRca/F SQg+Z2fz7fOB8SnNv3hQG1EEjAWHN5gYmBRK3MatKm44gzb0eg1h8vkVzdNstCBAGttm rpBdzeorKRG16GH5Lr5Zvmzg626g1YTDoA3s8DohaGlhwSvxJ3eYCn4i+Wn6t2Emp7So QKBxgNUR43p2Jy9SHmSr7Tn0qGk2YkQB4mmRpRhxjsGjAvKDgL9XerRcQ2DO62POsuMu nI2w== X-Gm-Message-State: ABuFfoiDrUAAashAvuKP4QlyUg8KaLOCafPWhub7zKW5glJbNT7dS6rK roShC/Q2Bb4wdWeUuNDdhwNwnhXrZ/Y= X-Google-Smtp-Source: ACcGV60dO3YSAR1DWo2ZDP/vTmOj0ZRBwXUBUvTBJKNbqAJCx3zuHJnKFUOXvKZLHejDhYCu31tfPw== X-Received: by 2002:a63:7e0d:: with SMTP id z13-v6mr5750264pgc.190.1539967986179; Fri, 19 Oct 2018 09:53:06 -0700 (PDT) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id b62-v6sm43008745pfa.159.2018.10.19.09.53.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Oct 2018 09:53:05 -0700 (PDT) Subject: Re: bug#14628: mv command (and suggesting a feature for it) To: 14628@debbugs.gnu.org References: <51BCC84E.4010508@gmail.com> <51BCFA54.3090704@draigBrady.com> From: Assaf Gordon Message-ID: <5a3147a0-3370-6a99-d796-9de1186534a2@gmail.com> Date: Fri, 19 Oct 2018 10:53:04 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <51BCFA54.3090704@draigBrady.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 14628 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) severity 14628 wishlist retitle 14628 mv: safeguard against renaming dir with open files close 14628 stop (triaging old bugs) On 15/06/13 05:35 PM, Pádraig Brady wrote: > > On 06/15/2013 09:02 PM, S. Dara wrote: >> >> With this email, I would like to suggest a feature for the mv command. I believe this command should contain a safeguard feature which will deny renaming a directory that contains files which are currently opened by the user. > > While I see the issue, I think it's probably outside the remit > of mv to make such checks. With no further comments in 5 years, I'm closing this item. -assaf From unknown Thu Jun 19 16:20:24 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 17 Nov 2018 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator