On Fri, 9 Apr 2010 18:23:09 +0200 (CEST) Guennadi Liakhovetski <g.liakhovetski@xxxxxx> wrote: > On Fri, 9 Apr 2010, Anatolij Gustschin wrote: > > > Sometimes not all objects from the image directory are > > imported. Removing this dentry->d_name zero-termination > > seems to fix the problem. dentry->d_name is zero-terminated, > > no need to terminate it. > > Sorry, do not understand. The only possibility for this is if the name > doesn't fit, and then it overwrites following fields in dentry... So, I'm > hesitant to accept this fix. Can you verify exactly which cases fail? on > which files? It fails on quite many files. Attached is a simple test program to show the issue. Similar problem shows up on files in the image directory, file names got truncated while listing if this zero termination is used. If I run e.g.: ag@wker:~$ ./lsdir /lib > /tmp/ls-ok ag@wker:~$ ./lsdir /lib fail > /tmp/ls-not-ok ag@wker:~$ diff /tmp/ls-ok /tmp/ls-not-ok 8c8 < libnss_mdns6_minimal.so.2 --- > libnss_mdns6_minimal.so 17,19c17,19 < libudev.so.0.5.0 < libticw.so.5 < libcidn-2.10.1.so --- > libudev.so.0.5. > libticw > libcidn-2.10.1. 21c21 < libnss_compat.so.2 --- > libnss_ 30,32c30,32 < libext2fs.so.2 < librt.so.1 < libkeyutils.so.1 --- > libext2 > librt.s > libkeyutils.so. 39c39 < libparted-1.8.so.12 --- > libparted-1.8.s 45c45 < libparted-1.8.so.12.0.0 --- > libpart 47,49c47,49 < libnss_nisplus-2.10.1.so < libkeyutils-1.2.so < libgpg-error.so.0.4.0 --- > libnss_nisplus-2.10.1.s > libkeyutils-1.2 > libgpg-error.so ... Anatolij
#include <dirent.h> #include <stdio.h> #include <string.h> #include <unistd.h> static int print_file_names(const char *path, int fail) { struct dirent *dentry; DIR *d; int ret; ret = chdir(path); if (ret < 0) return ret; d = opendir("."); while ((dentry = readdir(d))) { printf("%s\n", dentry->d_name); if (fail) dentry->d_name[sizeof(dentry->d_name) - 1] = '\0'; } return 0; } int main(int argc, char *argv[]) { print_file_names(argv[1], argc > 2 ? 1 : 0); return 0; }