[PATCH] df does not work for devices deep in /dev directory.

Denis Vlasenko vda.linux at googlemail.com
Fri Apr 13 14:00:35 PDT 2007


On Friday 13 April 2007 17:35, Kirill K. Smirnov wrote:
> Hi,
> I have embedded system with root filesystem /dev/mtdblock/3
> df does not display it in list.
> The attached patch deals with this problem.

                char devpath[PATH_MAX];
-               sprintf(devpath,"/dev/%s", entry->d_name);
+               sprintf(devpath,"%s/%s", path, entry->d_name);

From sheer paranoia I am adding overflow check.

Allocating on stack ~1K *for each iteration* is another thing
I would like to get rid of. (Actually, for glibc it's 4K).

                if (!stat(devpath, &st) && S_ISBLK(st.st_mode) && st.st_rdev == dev) {
                        retpath = xstrdup(devpath);
                        break;
                }
+               else if (!stat(devpath, &st) &&
+                        S_ISDIR(st.st_mode) &&
+                        entry->d_name[0]!='.')
+               {
+                       retpath = find_block_device_in_dir(dev, devpath);
+                       if (retpath) break;
+               }

"else" is superfluous. You do stat twice. Why '.names' are not ok?

Please try attached version.
--
vda
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 3.patch
Type: text/x-diff
Size: 1927 bytes
Desc: not available
Url : http://busybox.net/lists/busybox/attachments/20070413/fed86c99/attachment.bin 


More information about the busybox mailing list