Skip to content

Incorrect readdir d_type when use link2symlink #350

@A4-Tacks

Description

@A4-Tacks

Problem description

The d_type read using readdir does not match ls -l and stat

Link to rust-lang/rust#155798

Steps to reproduce

dtype.c:

#include <stdio.h>
#include <dirent.h>

int main() {
    DIR* dirp = opendir(".");
    struct dirent* dp;
    while ((dp = readdir(dirp)) != NULL) {
        printf("%s: %d\n", dp->d_name, dp->d_type);
    }
}

reproduction.sh:

#!/usr/bin/bash
set -e
dir=ubuntu-base-rootfs
rm -rf -- "$dir"
mkdir "$dir" && cd "$dir"
proot=$(which proot)

"$proot" --link2symlink tar -xf /storage/emulated/0/Download/backup/rootfs/ubuntu-base-22.04.1-base-arm64.tar.xz
export PATH=/bin:/usr/bin:/sbin:/usr/sbin LD_PRELOAD=''
cp ~/.local/share/tmoe-linux/containers/proot/arch_arm64/home/lrne/command/dtype.out . # compiled path
"$proot" --link2symlink -w / -r "$PWD" -0 <<< '
touch foo
ln foo foobar
(./dtype.out; ls -l) | grep foo'
  1. In some proot env run: gcc dtype.c -o dtype.out
  2. In termux env, run bash reproduction.sh

Expected behavior

.l2s.foo0001: 10
.l2s.foo0001.0002: 8
foo: 8
foobar: 8
-rw-------  2 root root     0 Apr 26 07:32 foo
-rw-------  2 root root     0 Apr 26 07:32 foobar

Current behavior

.l2s.foo0001: 10
.l2s.foo0001.0002: 8
foo: 10
foobar: 10
-rw-------  2 root root     0 Apr 26 07:32 foo
-rw-------  2 root root     0 Apr 26 07:32 foobar

Additional information

Termux Variables:
TERMUX_API_VERSION=0.50.1
TERMUX_APK_RELEASE=F_DROID
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=30455
TERMUX_IS_DEBUGGABLE_BUILD=0
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.0
TERMUX__USER_ID=0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://mirrors.bfsu.edu.cn/termux/apt/termux-main stable main
Updatable packages:
openssh-sftp-server/stable 10.3p1-1 aarch64 [upgradable from: 10.3p1]
openssh/stable 10.3p1-1 aarch64 [upgradable from: 10.3p1]
termux-tools version:
1.45.0
Android version:
10
Kernel build information:
Linux localhost 4.14.116 #1 SMP PREEMPT Tue Mar 22 15:13:10 CST 2022 aarch64 Android
Device manufacturer:
HUAWEI
Device model:
BAH3-W09
Supported ABIs:
SUPPORTED_ABIS: arm64-v8a,armeabi-v7a,armeabi
SUPPORTED_32_BIT_ABIS: armeabi-v7a,armeabi
SUPPORTED_64_BIT_ABIS: arm64-v8a
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec-ld-preload.so
Installed termux plugins:
com.termux.api versionCode:51
com.termux.boot versionCode:7
com.termux.styling versionCode:29
com.termux.widget versionCode:13
com.termux.window versionCode:15

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions