Anonymous | Login | Signup for a new account | 11-10-2008 11:22 PST |
Main | My View | View Issues | Change Log | Docs |
Viewing Issue Simple Details [ Jump to Notes ] | [ View Advanced ] [ Issue History ] [ Print ] | ||||||||
ID | Category | Severity | Reproducibility | Date Submitted | Last Update | ||||
0001619 | [BusyBox] Standards Compliance | major | always | 11-30-07 01:53 | 02-10-08 03:13 | ||||
Reporter | vicser | View Status | public | ||||||
Assigned To | BusyBox | ||||||||
Priority | normal | Resolution | fixed | ||||||
Status | closed | Product Version | |||||||
Summary | 0001619: BusyBox 1.8.2 fdisk doesn't read from stdin | ||||||||
Description |
busybox is used for unattended Linux installations. During the installation hard drive is partitioned by means of fdisk. fdisk is used in a batch mode. This means text file with fdisk commands is prepared - see attached fdisk-commands file (partition size values are variable, fdisk-commands is used to create 3 partitions -boot root and swap). And then fdisk-commands file is passed to fdisk through the stdin. Somthing like fdisk /dev/hda < fdisk-commands In all busybox till 1.7.3 this works fine But in busybox 1.8.0-1.8.2 fdisk doesn't read commands from stdin. |
||||||||
Additional Information | |||||||||
Attached Files |
fdisk-commands [^] (62 bytes) 11-30-07 01:53 fixlineinput.patch [^] (826 bytes) 02-10-08 00:34 |
||||||||
|
Notes | |
(0002994) vda 12-01-07 19:41 |
Just built busybox 1.8.2 and tested it: # echo q >Q # strace -o fdisk.log ./busybox fdisk /dev/sda1 <Q Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel. Changes will remain in memory only, until you decide to write them. After that the previous content won't be recoverable. Warning: invalid flag 0x00,0x00 of partition table 4 will be corrected by w(rite) Command (m for help): q # strace log clearly shows that it did read from stdin: write(1, "Command (m for help): ", 22) = 22 read(0, "q", 1) = 1 write(1, "q", 1) = 1 read(0, "\n", 1) = 1 write(1, "\n", 1) = 1 Please provide more details (your .config, and strace log of fdisk invocation which doesn't work for you) |
(0003624) iluxa 01-30-08 12:55 |
Apparently this busybox version expects all input to be line-buffered. As a workaround, calling sync after sending each line will fix the problem. (line reading should be fixed instead, of course) |
(0003674) vda 02-03-08 17:08 |
> Apparently this busybox version expects all input to be line-buffered. 1.9.0 uses fgets() in fdisk (indirectly through read_line_input) if input is coming from non-tty. What is the problem? > As a workaround, calling sync after sending each line will fix the problem. What "sync"? > (line reading should be fixed instead, of course) I need understandable bug report first. |
(0003704) hshao 02-04-08 13:22 |
it is noticed that some changes in libbb/lineedit.c cause this problem. A quick fix is to follow the patch below: --- busybox-1.8.2/libbb/lineedit.c.orig 2008-02-04 11:38:51.000000000 -0800 +++ busybox-1.8.2/libbb/lineedit.c 2008-02-04 11:39:47.000000000 -0800 @@ -1270,6 +1270,8 @@ smalluint prevc; #endif +//fix the issue: fdisk can't take input from non-tty mode +#if 0 getTermSettings(0, (void *) &initial_settings); /* Happens when e.g. stty -echo was run before */ if (!(initial_settings.c_lflag & ECHO)) { @@ -1278,6 +1280,7 @@ fgets(command, maxsize, stdin); return strlen(command); } +#endif // FIXME: audit & improve this if (maxsize > MAX_LINELEN) @@ -1296,6 +1299,7 @@ command_ps = command; command[0] = '\0'; + getTermSettings(0, (void *) &initial_settings); memcpy(&new_settings, &initial_settings, sizeof(new_settings)); new_settings.c_lflag &= ~ICANON; /* unbuffered input */ /* Turn off echoing and CTRL-C, so we can trap it */ |
(0003714) iluxa 02-04-08 20:30 |
I took a look at 1.8 code, and it comes down to the same fgets call. This may be a bug in the way busybox and glibc interact, since in this case it is busybox statically linked with glibc 2.3 The "sync" I was referring to above was sync command. Example: Original way: fdisk /dev/sda << EOF n p 1 w EOF Had to be replaced with: (echo n;sync; echo p; sync; echo 1; sync; echo; sync; echo; sync; echo w;)|fdisk /dev/sda |
(0003744) vda 02-08-08 10:43 |
Oh. It seems to be a simple thing which is fixed in 1.9.0 already. Does this patch help? http://busybox.net/downloads/fixes-1.8.2/busybox-1.8.2-lineedit.patch [^] |
(0003784) iluxa 02-10-08 00:33 |
The patch (slightly modified) worked. Will attach my version. |
(0003814) vda 02-10-08 03:13 |
Thanks for testing/fixing. Closing the issue. |
Copyright © 2000 - 2006 Mantis Group |