On 03/29/2015 12:18 PM, enh wrote: > On Sun, Mar 29, 2015 at 9:27 AM, Rich Felker <[email protected]> wrote: >> I agree with chopping out linux/*.h includes especially since they >> tend to randomly break by introducing conflicts with libc headers. >> Here it seems your motive is more that you want to avoid making the >> command gratuitously Linux-dependent. However I'm not sure if it's >> safe to send an 'unknown' ioctl to a random block device you just >> opened. Worst case, the number could mean something completely >> different like "format the drive".
Do you really see that as likely? I did check in Linux. This ioctl was allocated early, back when the high bytes were a letter for the subsystem, and it's not used for anything else in the tree. Nobody checks what kind of device it is when calling losetup -d on a block device, so "random format the drive when you do that" would be a problem there too. (Maybe not as big of one, but still the same category.) > yeah, that's what worried me, seeing this on the same day that Darwin > support was mentioned... it seems safer to fail to compile than to > send random ioctls. I've been holding off on adding infrastructure until there _were_ ports, because I avoid infrastructure in search of a user. But having portability.h define TOYBOX_LINUX or TOYBOX_BSD isn't out of the question. (More likely I'd just factor out a loopdev_detach() function and move it to portability.c.) >> As far as I know Linux only has a >> small known number of 'overloaded' ioctl numbers (ones with different >> meanings for different device types) and this isn't one of them, but I >> don't know whether the number is used for different things on other >> systems, so in the absence of that information it might be best to >> skip making the ioctl on non-Linux targets. I checked what linux is doing. I can't check what non-linux is doing because I don't have a mac or ios development environment. I'm just responding to external interest there. :) (I note that ifconfig also cares what the ioctl numbers work out to, because it's masking against them to determine which of the command table branches to go down.) Rob _______________________________________________ Toybox mailing list [email protected] http://lists.landley.net/listinfo.cgi/toybox-landley.net
