[PATCH] df does not work for devices deep in /dev directory.
Kirill K. Smirnov
lich at math.spbu.ru
Fri Apr 13 15:59:18 PDT 2007
It is much better than my version, but checking for '.' and '..' are missing.
It is critical so I've added it.
I attached the final version, it should be ok.
--
Kirill
P.S. Yes, I was too rude to check for '.' and '..' just checking
d_name[0]=='.' in my first patch. Now it is performed correctly via strcmp.
> 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: busybox-1.5.0.patch
Type: text/x-diff
Size: 2089 bytes
Desc: not available
Url : http://busybox.net/lists/busybox/attachments/20070414/daaa8f5b/attachment.bin
More information about the busybox
mailing list