<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>13426</bug_id>
          
          <creation_ts>2019-07-03 14:59:04 +0000</creation_ts>
          <short_desc>Loses track of data if file rename()d to same name</short_desc>
          <delta_ts>2020-08-28 09:39:05 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>6</classification_id>
          <classification>Yocto Project Subprojects</classification>
          <product>Pseudo</product>
          <component>pseudo</component>
          <version>master</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>3.2 M3</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ross Burton">ross.burton</reporter>
          <assigned_to name="Joe Slater">joe.slater</assigned_to>
          <cc>randy.macleod</cc>
    
    <cc>seebs</cc>
    
    <cc>yp.pseudo.watcher</cc>
    
    <cc>yp.watcher</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>84362</commentid>
    <comment_count>0</comment_count>
      <attachid>4535</attachid>
    <who name="Ross Burton">ross.burton</who>
    <bug_when>2019-07-03 14:59:04 +0000</bug_when>
    <thetext>Created attachment 4535
Test case

Nothing stops rename() being told to rename foo to foo. For example this doesn&apos;t produe an error:

$ touch foo
$ python3 -c &quot;import os; os.rename(&apos;foo&apos;, &apos;foo&apos;)&quot;

However when run under pseudo the rename() wrappers throw away the information for the old name, losing ownership data etc.

Attached is a test case to demonstrate this.

A simple strcmp in the rename() wrapper is enough to fix this, although that&apos;s both horrible and doesn&apos;t fix renameat().</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86053</commentid>
    <comment_count>1</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2020-01-16 16:19:31 +0000</bug_when>
    <thetext>Seems mostly harmless but it might be causing some autobuilder failures or other problems.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88011</commentid>
    <comment_count>2</comment_count>
    <who name="Joe Slater">joe.slater</who>
    <bug_when>2020-08-21 13:07:39 +0000</bug_when>
    <thetext>Only just started looking, but it seems like if the target of a rename exists, info about it is deleted.  Then, the info for the renamed file is assigned to the rename target.  Of course, in this case, that info is gone.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88036</commentid>
    <comment_count>3</comment_count>
    <who name="Joe Slater">joe.slater</who>
    <bug_when>2020-08-25 15:56:26 +0000</bug_when>
    <thetext>In the appropriate &quot;guts&quot; files, move the check for old/new identity to before playing with the pseudo database.  Works for rename() and should work for renameat() and renameat2().</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88040</commentid>
    <comment_count>4</comment_count>
      <attachid>4716</attachid>
    <who name="Joe Slater">joe.slater</who>
    <bug_when>2020-08-26 12:01:50 +0000</bug_when>
    <thetext>Created attachment 4716
testcase for rename() and renameat()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88059</commentid>
    <comment_count>5</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2020-08-28 09:39:05 +0000</bug_when>
    <thetext>merged to master and seems to be passing tests so closing:
   https://git.openembedded.org/openembedded-core/commit/?id=6b3d109f42385ad1cf1f297a6c06ea7eb6509f26</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>4535</attachid>
            <date>2019-07-03 14:59:04 +0000</date>
            <delta_ts>2019-07-03 14:59:04 +0000</delta_ts>
            <desc>Test case</desc>
            <filename>test-rename-same.sh</filename>
            <type>text/plain</type>
            <size>465</size>
            <attacher name="Ross Burton">ross.burton</attacher>
            
              <data encoding="base64">IyEvYmluL2Jhc2gKIwojIFNQRFgtTGljZW5zZS1JZGVudGlmaWVyOiBMR1BMLTIuMS1vbmx5CiMK
CnNldCAtZQoKcm0gLWYgZjEKCnRvdWNoIGYxCmZpbGV1aWQ9YFxscyAtbjEgZjEgfCBhd2sgJ3sg
cHJpbnQgJDMgfSdgCmlmIFsgIiRmaWxldWlkIiAhPSAiJFVJRCIgXQp0aGVuCgllY2hvIFVJRCB3
cm9uZwoJZXhpdCAxCmZpCgpjaG93biByb290LnJvb3QgZjEKZmlsZXVpZD1gXGxzIC1uMSBmMSB8
IGF3ayAneyBwcmludCAkMyB9J2AKaWYgWyAiJGZpbGV1aWQiICE9ICIwIiBdCnRoZW4KCWVjaG8g
VUlEIHdyb25nCglleGl0IDEKZmkKCnB5dGhvbjMgLWMgJ2ltcG9ydCBvczsgb3MucmVuYW1lKCJm
MSIsICJmMSIpJwpmaWxldWlkPWBcbHMgLW4xIGYxIHwgYXdrICd7IHByaW50ICQzIH0nYAppZiBb
ICIkZmlsZXVpZCIgIT0gIjAiIF0KdGhlbgoJZWNobyBVSUQgd3JvbmcgZ290ICRmaWxldWlkCgll
eGl0IDEKZmkK
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>4716</attachid>
            <date>2020-08-26 12:01:50 +0000</date>
            <delta_ts>2020-08-26 12:01:50 +0000</delta_ts>
            <desc>testcase for rename() and renameat()</desc>
            <filename>arftest.c</filename>
            <type>text/plain</type>
            <size>770</size>
            <attacher name="Joe Slater">joe.slater</attacher>
            
              <data encoding="base64">LyoKICogdGVzdCBmb3IgcHNldWRvIHJlbmFtaW5nCiAqCiAqICAgUnVuIGluIGEgZGlyZWN0b3J5
IG5hbWVkIGFyZiB3aXRoIGZpbGVzIGFyZiBhbmQgYXJmYXQgZXhpc3RpbmcuCiAqLwoKCiNpbmNs
dWRlIDxmY250bC5oPgojaW5jbHVkZSA8c3RkaW8uaD4KCmludCBtYWluKGludCBhcmdjLCBjaGFy
ICoqYXJndikKIHsKICAgaWYgKCFyZW5hbWUoImFyZiIsImJhcmYiKSkgIHByaW50ZigiYXJmIHRv
IGJhcmZcbiIpOwogICBpZiAoIXJlbmFtZSgiYmFyZiIsImJhcmYiKSkgIHByaW50ZigiYmFyZiB0
byBiYXJmXG4iKTsKICAgaWYgKCFyZW5hbWUoImJhcmYiLCIuLi9hcmYvYmFyZiIpKSAgcHJpbnRm
KCJiYXJmIHRvIC4uL2FyZi9iYXJmXG4iKTsKCiAgIGlmICghcmVuYW1lYXQoQVRfRkRDV0QsImFy
ZmF0IixBVF9GRENXRCwiYmFyZmF0IikpCiAgICAgIHByaW50ZigiYXJmYXQgdG8gYmFyZmF0XG4i
KTsKICAgaWYgKCFyZW5hbWVhdChBVF9GRENXRCwiYmFyZmF0IixBVF9GRENXRCwiYmFyZmF0Iikp
CiAgICAgIHByaW50ZigiYmFyZmF0IHRvIGJhcmZhdFxuIik7CgojaWZkZWYgVU5ERUZJTkVECiAg
IGlmICghcmVuYW1lYXQyKEFUX0ZEQ1dELCJhcmYyIixBVF9GRENXRCwiYmFyZjIiLDApKQogICAg
ICBwcmludGYoImFyZjIgdG8gYmFyZjJcbiIpOwogICBpZiAoIXJlbmFtZWF0MihBVF9GRENXRCwi
YmFyZjIiLEFUX0ZEQ1dELCJiYXJmMiIsMCkpCiAgICAgIHByaW50ZigiYmFyZjIgdG8gYmFyZjJc
biIpOwojZW5kaWYKCiAgIHJldHVybiAwOwoKIH0=
</data>

          </attachment>
      

    </bug>

</bugzilla>