From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1.windriver.com (mail1.windriver.com [147.11.146.13]) by mx.groups.io with SMTP id smtpd.web10.4674.1598475670913792113 for ; Wed, 26 Aug 2020 14:01:11 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: windriver.com, ip: 147.11.146.13, mailfrom: randy.macleod@windriver.com) Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail1.windriver.com (8.15.2/8.15.2) with ESMTPS id 07QL183Q025789 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Wed, 26 Aug 2020 14:01:09 -0700 (PDT) Received: from [172.25.44.3] (172.25.44.3) by ALA-HCA.corp.ad.wrs.com (147.11.189.50) with Microsoft SMTP Server (TLS) id 14.3.487.0; Wed, 26 Aug 2020 14:01:08 -0700 Subject: Re: [oe-core][PATCH 1/1] pseudo: fix renaming to self From: "Randy MacLeod" To: Joe Slater , , Seebs References: <20200826185857.24292-1-joe.slater@windriver.com> <20200826185857.24292-2-joe.slater@windriver.com> Message-ID: <4f1b7794-19fd-d981-03bc-1f80d65a42a6@windriver.com> Date: Wed, 26 Aug 2020 17:01:05 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [172.25.44.3] Content-Type: multipart/alternative; boundary="------------8B869DB4A1D43C7854A90D48" Content-Language: en-CA --------------8B869DB4A1D43C7854A90D48 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mail1.windriver.com id 07QL183Q025789 On 2020-08-26 4:04 p.m., Randy MacLeod wrote: > > Add Seebs. > > Joe, > How did you test this change? Oops, I see that you attached the test to the defect: https://bugzilla.yoctoproject.org/show_bug.cgi?id=3D13426 See below for (barfy) src. ;-) ../Randy /* * test for pseudo renaming * * Run in a directory named arf with files arf and arfat existing. */ #include #include int main(int argc, char **argv) { if (!rename("arf","barf")) printf("arf to barf\n"); if (!rename("barf","barf")) printf("barf to barf\n"); if (!rename("barf","../arf/barf")) printf("barf to ../arf/barf\n"); if (!renameat(AT_FDCWD,"arfat",AT_FDCWD,"barfat")) printf("arfat to barfat\n"); if (!renameat(AT_FDCWD,"barfat",AT_FDCWD,"barfat")) printf("barfat to barfat\n"); #ifdef UNDEFINED if (!renameat2(AT_FDCWD,"arf2",AT_FDCWD,"barf2",0)) printf("arf2 to barf2\n"); if (!renameat2(AT_FDCWD,"barf2",AT_FDCWD,"barf2",0)) printf("barf2 to barf2\n"); #endif return 0; } > > ../Randy > > On 2020-08-26 2:58 p.m., Joe Slater wrote: >> Pseudo tests for an item being renamed to itself only after >> information about it has been deleted.=C2=A0 Move the test to before >> we change the database. >> >> Note that pseudo does not support renameat2(), but neither does >> glibc. >> >> Signed-off-by: Joe Slater >> --- >> =C2=A0 .../pseudo/files/rename.patch=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 73 +++++++= ++++++++++++ >> =C2=A0 meta/recipes-devtools/pseudo/pseudo_git.bb=C2=A0=C2=A0=C2=A0 |=C2= =A0 1 + >> =C2=A0 2 files changed, 74 insertions(+) >> =C2=A0 create mode 100644 meta/recipes-devtools/pseudo/files/rename.pa= tch >> >> diff --git a/meta/recipes-devtools/pseudo/files/rename.patch=20 >> b/meta/recipes-devtools/pseudo/files/rename.patch >> new file mode 100644 >> index 0000000000..bc344db3b5 >> --- /dev/null >> +++ b/meta/recipes-devtools/pseudo/files/rename.patch >> @@ -0,0 +1,73 @@ >> +pseudo: fix renaming to self >> + >> +The pseudo rename guts test for an item being renamed to >> +itself, only after information about it has been deleted. >> +We move the test to before we play with the database. >> + >> +Note that pseudo does not support renameat2(). >> + >> +Upstream-Status: Pending >> + >> +Signed-off-by: Joe Slater >> + >> + >> +--- a/ports/unix/guts/rename.c >> ++++ b/ports/unix/guts/rename.c >> +@@ -29,6 +29,14 @@ >> +=C2=A0=C2=A0=C2=A0=C2=A0 newrc =3D base_lstat(newpath, &newbuf); >> +=C2=A0=C2=A0=C2=A0=C2=A0 oldrc =3D base_lstat(oldpath, &oldbuf); >> + >> ++=C2=A0=C2=A0=C2=A0 /* nothing to do for a "rename" of a link to itse= lf */ >> ++=C2=A0=C2=A0=C2=A0 if (newrc !=3D -1 && oldrc !=3D -1 && >> ++=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 newbuf.st_dev =3D=3D oldb= uf.st_dev && >> ++=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 newbuf.st_ino =3D=3D oldb= uf.st_ino) { >> ++=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pseudo_debug(PDBGF_OP, "r= ename: paths are the same\n"); >> ++=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return real_rename(oldpat= h, newpath); >> ++=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> ++ >> +=C2=A0=C2=A0=C2=A0=C2=A0 errno =3D save_errno; >> + >> +=C2=A0=C2=A0=C2=A0=C2=A0 /* newpath must be removed. */ >> +@@ -58,12 +66,6 @@ >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return rc; >> +=C2=A0=C2=A0=C2=A0=C2=A0 } >> +=C2=A0=C2=A0=C2=A0=C2=A0 save_errno =3D errno; >> +-=C2=A0=C2=A0=C2=A0 /* nothing to do for a "rename" of a link to itse= lf */ >> +-=C2=A0=C2=A0=C2=A0 if (newrc !=3D -1 && oldrc !=3D -1 && >> +-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 newbuf.st_dev =3D=3D oldb= uf.st_dev && >> +-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 newbuf.st_ino =3D=3D oldb= uf.st_ino) { >> +-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return rc; >> +-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> + >> +=C2=A0=C2=A0=C2=A0=C2=A0 /* rename(3) is not mv(1).=C2=A0 rename(file= , dir) fails; you must=20 >> provide >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * the corrected path yourself.=C2=A0 Y= ou can rename over a=20 >> directory only >> +--- a/ports/unix/guts/renameat.c >> ++++ b/ports/unix/guts/renameat.c >> +@@ -41,6 +41,14 @@ >> +=C2=A0=C2=A0=C2=A0=C2=A0 newrc =3D base_fstatat(newdirfd, newpath, &n= ewbuf,=20 >> AT_SYMLINK_NOFOLLOW); >> + #endif >> + >> ++=C2=A0=C2=A0=C2=A0 /* nothing to do for a "rename" of a link to itse= lf */ >> ++=C2=A0=C2=A0=C2=A0 if (newrc !=3D -1 && oldrc !=3D -1 && >> ++=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 newbuf.st_dev =3D=3D oldb= uf.st_dev && >> ++=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 newbuf.st_ino =3D=3D oldb= uf.st_ino) { >> ++=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pseudo_debug(PDBGF_OP, "r= enameat: paths are the same\n"); >> ++=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return real_renameat(oldd= irfd, oldpath, newdirfd, newpath); >> ++=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> ++ >> +=C2=A0=C2=A0=C2=A0=C2=A0 errno =3D save_errno; >> + >> +=C2=A0=C2=A0=C2=A0=C2=A0 /* newpath must be removed. */ >> +@@ -71,12 +79,6 @@ >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return rc; >> +=C2=A0=C2=A0=C2=A0=C2=A0 } >> +=C2=A0=C2=A0=C2=A0=C2=A0 save_errno =3D errno; >> +-=C2=A0=C2=A0=C2=A0 /* nothing to do for a "rename" of a link to itse= lf */ >> +-=C2=A0=C2=A0=C2=A0 if (newrc !=3D -1 && oldrc !=3D -1 && >> +-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 newbuf.st_dev =3D=3D oldb= uf.st_dev && >> +-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 newbuf.st_ino =3D=3D oldb= uf.st_ino) { >> +-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return rc; >> +-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> + >> +=C2=A0=C2=A0=C2=A0=C2=A0 /* rename(3) is not mv(1).=C2=A0 rename(file= , dir) fails; you must=20 >> provide >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * the corrected path yourself.=C2=A0 Y= ou can rename over a=20 >> directory only >> diff --git a/meta/recipes-devtools/pseudo/pseudo_git.bb=20 >> b/meta/recipes-devtools/pseudo/pseudo_git.bb >> index 9a22304bba..8d8cf8d523 100644 >> --- a/meta/recipes-devtools/pseudo/pseudo_git.bb >> +++ b/meta/recipes-devtools/pseudo/pseudo_git.bb >> @@ -4,6 +4,7 @@ SRC_URI =3D=20 >> "git://git.yoctoproject.org/pseudo;branch=3Doe-core \ >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= file://0001-configure-Prune-PIE-flags.patch \ >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= file://fallback-passwd \ >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= file://fallback-group \ >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 file://r= ename.patch \ >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= " >> =C2=A0 =C2=A0 SRCREV =3D "8efb082863ff0ceec7b7e46f9a44750e12f48039" > > --=20 # Randy MacLeod # Wind River Linux --------------8B869DB4A1D43C7854A90D48 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mail1.windriver.com id 07QL183Q025789
On 2020-08-26 4:04 p.m., Randy MacLeod wrote:

Add Seebs.

Joe,
How did you test this change?

Oops, I see that you attached the test to the defect:

https://bugzilla.yoctoproject.org/sho= w_bug.cgi?id=3D13426

See below for (barfy) src. ;-)

../Randy


/*
 * test for pseudo renaming
 *
 *   Run in a directory named arf with files arf and arfat existing.
 */


#include <fcntl.h>
#include <stdio.h>

int main(int argc, char **argv)
 {
   if (!rename("arf","barf"))  printf("arf to barf\n");
   if (!rename("barf","barf"))  printf("barf to barf\n");
   if (!rename("barf","../arf/barf"))  printf("barf to ../arf/barf\n");

   if (!renameat(AT_FDCWD,"arfat",AT_FDCWD,"barfat"))
      printf("arfat to barfat\n");
   if (!renameat(AT_FDCWD,"barfat",AT_FDCWD,"barfat"))
      printf("barfat to barfat\n");

#ifdef UNDEFINED
   if (!renameat2(AT_FDCWD,"arf2",AT_FDCWD,"barf2",0))
      printf("arf2 to barf2\n");
   if (!renameat2(AT_FDCWD,"barf2",AT_FDCWD,"barf2",0))
      printf("barf2 to barf2\n");
#endif

   return 0;

 }

../Randy

On 2020-08-26 2:58 p.m., Joe Slater wrote:
Pseudo tests for an item being renamed to itself only after
information about it has been deleted.=C2=A0 Move the test to bef= ore
we change the database.

Note that pseudo does not support renameat2(), but neither does
glibc.

Signed-off-by: Joe Slater <joe.slater@windriver.com>
---
=C2=A0 .../pseudo/files/rename.patch=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 73 +++++++++++++++++++
=C2=A0 meta/recipes-devtools/pseudo/pseudo_git.bb=C2=A0=C2=A0=C2=A0= |=C2=A0 1 +
=C2=A0 2 files changed, 74 insertions(+)
=C2=A0 create mode 100644 meta/recipes-devtools/pseudo/files/rename.patch

diff --git a/meta/recipes-devtools/pseudo/files/rename.patch b/meta/recipes-devtools/pseudo/files/rename.patch
new file mode 100644
index 0000000000..bc344db3b5
--- /dev/null
+++ b/meta/recipes-devtools/pseudo/files/rename.patch
@@ -0,0 +1,73 @@
+pseudo: fix renaming to self
+
+The pseudo rename guts test for an item being renamed to
+itself, only after information about it has been deleted.
+We move the test to before we play with the database.
+
+Note that pseudo does not support renameat2().
+
+Upstream-Status: Pending
+
+Signed-off-by: Joe Slater <joe.slater@windriver.com>
+
+
+--- a/ports/unix/guts/rename.c
++++ b/ports/unix/guts/rename.c
+@@ -29,6 +29,14 @@
+=C2=A0=C2=A0=C2=A0=C2=A0 newrc =3D base_lstat(newpath, &newb= uf);
+=C2=A0=C2=A0=C2=A0=C2=A0 oldrc =3D base_lstat(oldpath, &oldb= uf);
+
++=C2=A0=C2=A0=C2=A0 /* nothing to do for a "rename" of a link to= itself */
++=C2=A0=C2=A0=C2=A0 if (newrc !=3D -1 && oldrc !=3D -1 &= amp;&
++=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 newbuf.st_dev =3D=3D= oldbuf.st_dev &&
++=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 newbuf.st_ino =3D=3D= oldbuf.st_ino) {
++=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pseudo_debug(PDBGF_O= P, "rename: paths are the same\n");
++=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return real_rename(o= ldpath, newpath);
++=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }
++
+=C2=A0=C2=A0=C2=A0=C2=A0 errno =3D save_errno;
+
+=C2=A0=C2=A0=C2=A0=C2=A0 /* newpath must be removed. */
+@@ -58,12 +66,6 @@
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return rc;
+=C2=A0=C2=A0=C2=A0=C2=A0 }
+=C2=A0=C2=A0=C2=A0=C2=A0 save_errno =3D errno;
+-=C2=A0=C2=A0=C2=A0 /* nothing to do for a "rename" of a link to= itself */
+-=C2=A0=C2=A0=C2=A0 if (newrc !=3D -1 && oldrc !=3D -1 &= amp;&
+-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 newbuf.st_dev =3D=3D= oldbuf.st_dev &&
+-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 newbuf.st_ino =3D=3D= oldbuf.st_ino) {
+-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return rc;
+-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }
+
+=C2=A0=C2=A0=C2=A0=C2=A0 /* rename(3) is not mv(1).=C2=A0 rename= (file, dir) fails; you must provide
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * the corrected path yourself.=C2= =A0 You can rename over a directory only
+--- a/ports/unix/guts/renameat.c
++++ b/ports/unix/guts/renameat.c
+@@ -41,6 +41,14 @@
+=C2=A0=C2=A0=C2=A0=C2=A0 newrc =3D base_fstatat(newdirfd, newpat= h, &newbuf, AT_SYMLINK_NOFOLLOW);
+ #endif
+
++=C2=A0=C2=A0=C2=A0 /* nothing to do for a "rename" of a link to= itself */
++=C2=A0=C2=A0=C2=A0 if (newrc !=3D -1 && oldrc !=3D -1 &= amp;&
++=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 newbuf.st_dev =3D=3D= oldbuf.st_dev &&
++=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 newbuf.st_ino =3D=3D= oldbuf.st_ino) {
++=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pseudo_debug(PDBGF_O= P, "renameat: paths are the same\n");
++=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return real_renameat= (olddirfd, oldpath, newdirfd, newpath);
++=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }
++
+=C2=A0=C2=A0=C2=A0=C2=A0 errno =3D save_errno;
+
+=C2=A0=C2=A0=C2=A0=C2=A0 /* newpath must be removed. */
+@@ -71,12 +79,6 @@
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return rc;
+=C2=A0=C2=A0=C2=A0=C2=A0 }
+=C2=A0=C2=A0=C2=A0=C2=A0 save_errno =3D errno;
+-=C2=A0=C2=A0=C2=A0 /* nothing to do for a "rename" of a link to= itself */
+-=C2=A0=C2=A0=C2=A0 if (newrc !=3D -1 && oldrc !=3D -1 &= amp;&
+-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 newbuf.st_dev =3D=3D= oldbuf.st_dev &&
+-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 newbuf.st_ino =3D=3D= oldbuf.st_ino) {
+-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return rc;
+-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }
+
+=C2=A0=C2=A0=C2=A0=C2=A0 /* rename(3) is not mv(1).=C2=A0 rename= (file, dir) fails; you must provide
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * the corrected path yourself.=C2= =A0 You can rename over a directory only
diff --git a/meta/recipes-devtools/pseudo/pseudo_git.bb b/meta/recipes-devtools/pseudo/pseudo_git.bb
index 9a22304bba..8d8cf8d523 100644
--- a/meta/recipes-devtools/pseudo/pseudo_git.bb
+++ b/meta/recipes-devtools/pseudo/pseudo_git.bb
@@ -4,6 +4,7 @@ SRC_URI =3D "git://git.yoctoproject.org/pseudo;branch=3Doe-core \
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0
file://0001-configure-Prune-PIE-flags.patch \
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 file://fallback-passwd \
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 = file://fallback-group \
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 file://renam= e.patch \
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 "
=C2=A0 =C2=A0 SRCREV =3D "8efb082863ff0ceec7b7e46f9a44750e12f4803= 9"



--=20
# Randy MacLeod
# Wind River Linux
--------------8B869DB4A1D43C7854A90D48--