Question for Vodz about getopt_ulflags

Tito farmatito at tiscali.it
Wed May 3 20:18:03 UTC 2006


On Wednesday 3 May 2006 15:09, Vladimir N. Oleynik wrote:
> Tito,
> 
> > Hi Vodz,
> > I am trying to use bb_getopt_ulflags in hdparm,
> > but it seems to me that unsigned long opts
> > returned by bb_getopt_ulflags is not big enough
> > to hold the value for all the options.
> > 
> > For test:
> > int hdparm_main(int argc, char **argv)
> > {
> > 	unsigned long opts;
> > 
> > 	opts = bb_getopt_ulflags(argc, argv, hdparm_options);
> > 	printf("opts %ld\n", opts);
> > 	return 0;
> > }
> > 
> > ./busybox hdparm -Z
> > opts 1073741824
> > ./busybox hdparm -U
> > opts -2147483648
> > ./busybox hdparm -R
> > BusyBox v1.2.0-pre0 (2006.04.28-12:28+0000) multi-call binary
> > 
> > Usage: hdparm [options] [device] ..
> > 
> > The opt strings is:
> > 
> > static const char hdparm_options[]= "VvgfqunprmckaBtThdSDPXKALWCyYzZURQwxb";
> > 
> > Is there a solution?
> 
> The small patch for getopt_ulflags attached.
> Usage example also added:
> 
> If applet_opts have more sizeof(long) count a chars, use this trik.
> 
 static const char hdparm_options1[]= "VvgfqunprmckaBtThdSDPXKALWCyYzZURQwxb";
 static const char hdparm_options2[]= "RQwxb";
 flags1 = bb_getopt_ulflags(argc, argv, hdparm_options1);
 optind = 0;
 flags2 = bb_getopt_ulflags(argc, argv, hdparm_options2);

This works fine  for me.
It seems to work also without the patch or maybe I need to test it more.

Thanks,
Tito

> 
> --w
> vodz
> 



More information about the busybox mailing list