[BusyBox] Another bug(?) in cp
Brian Webb
webbb at desertscenes.net
Mon Apr 30 09:54:21 UTC 2001
Matt,
I see that code that you're refering to that should be changing the
permissions, but for some reason it doesn't seem to be working in all cases
on my system. The place that it is getting executed is from a script run as
init (init=/sbin/restore_defaults on the boot line). This is a script that
copies files from the cramfs root partition to a jffs partition.
The script looks like:
#!/bin/sh
echo "Doing device reset"
/defaults/ramdisk
/defaults/flashdisk
echo "Hard reset the machine now."
while `true`
do
X=1
done
#aka infinite loop
#
/defaults/ramdisk:
#!/bin/sh
echo Mounting ramfs
mount -n -t ramfs none /ram
echo Making var and tmp directories
mkdir /ram/var
mkdir /ram/var/lib
mkdir /ram/var/lock
mkdir /ram/var/lock/subsys
mkdir /ram/var/log
mkdir /ram/var/run
mkdir /ram/var/run/utmp
mkdir /ram/tmp
chmod a+rwx /ram/tmp
/defaults/flashdisk:
#!/bin/sh
echo Erasing flashdisk
/sbin/eraseall /dev/mtd0
echo Mounting flashdisk
mount -n -t jffs /dev/mtdblock0 /flash
echo Copying defaults to flashdisk
cp -a /defaults/* /flash
echo Setting up permissions on /home/default
# NOTE: I am concerned about this following links,
# but it appears that BusyBox chown/chgrp don't
# support the -h flag.
chown -R default /flash/home/default
chgrp -R users /flash/home/default
Used in this mode it doesn't set the permissions correctly unless I add the
umask patch. For reference, I tried booting into /bin/bash and running
/sbin/restore_defaults with the same results. If I do the copy on the
command line it seems to work, although I haven't verified that the
permissions are exactly correct.
Any ideas why it would work different in these situations? I initially
thought it was a umask problem because it acts differently depending on
where it's run from, so the only meaningful difference I could think of is
that the umask may be set differently somehow.
BTW, In all cases I am using bash. The startup scripts on this system use
VAR=val syntax all over, so lash doesn't work.
Thanks,
Brian
> On Sat, Apr 28, 2001 at 08:56:57AM -0700, Brian Webb wrote:
>> I'm not sure if this is a bug, but it works different than on my
>> desktop,so I think it is. The problem is that "cp -a" uses the umask
>> when copying devide files, so "cp -a" does not preserve complete file
>> permissions. I'm not sure exactly how it should work, but on my
>> desktop I can copy my /dev directory with "cp -a" and all permissions
>> are preserved.
>> Also it seems reasonable for "cp -a" or "cp -p" to work that way.
>>
>> The following is a patch that fixes the problem (at least it works for
>> me). It looks a little different than the other, similar code around
>> it, but it seems to me like it should be correct.
>
> For what it's worth, I just copied the /dev directory on my
> machine using BusyBox cp -a, and the only differences were the
> modification times for the symlinks, the size of the pts
> directory, and the size of the xconsole device.
>
> Matt
More information about the busybox
mailing list