Description of Problem: (ultra low priority enhancement request) nash can redirect stdout on 'echo' commands, but cannot do so for execve'd apps. Occasionally it's nice to be able to do this, e.g. the kernel starts fine, begins running the initrd fine, but hangs while loading a module. It can be handy to stick static apps in the initrd to run before those insmods (like say, 'mptable'. Patch provided against 3.3.4-3 is untested (testing mode keeps getting in the way), but I believe it's correct, and would appreciate a review. Version-Release number of selected component (if applicable): 3.3.4-3 diff -urNp --exclude-from=/home/mdomsch/excludes mkinitrd-3.3.4.orig/nash/nash.c mkinitrd-3.3.4/nash/nash.c --- mkinitrd-3.3.4.orig/nash/nash.c Wed Jan 16 14:15:39 2002 +++ mkinitrd-3.3.4/nash/nash.c Thu Mar 14 15:47:35 2002 @@ -212,6 +212,7 @@ int otherCommand(char * bin, char * cmd, const static char * sysPath = PATH; const char * pathStart; const char * pathEnd; + FILE *outFile = NULL; nextArg = args; @@ -255,6 +256,13 @@ int otherCommand(char * bin, char * cmd, } else { if (!doFork || !(pid = fork())) { /* child */ + if ((nextArg - args >= 2) && !strcmp(*(nextArg - 2), ">")) { + outFile = freopen(*(nextArg - 1), "a", stdout); + if (outFile) { + *(nextArg - 2) = NULL; + *(nextArg - 1) = NULL; + } + } execve(args[0], args, env); printf("ERROR: failed in exec of %s\n", args[0]); return 1;
anything for you matt ;-) it's in 3.3.11 (via a slightly different patch)
Thanks Erik! I know my patch didn't quite work - hope it wasn't too much trouble to make it do the right thing.
nah, it was easy enough fwiw, you can test nash out by giving it "--force" on the command line, which overrides test mode. this was broken recently, but it's fixed in CVS (along with the other change you wanted)