<font face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size="2">(me found a new mailer option)<br><br>Around 02/23/2016 05:02PM in some time zone, Joel Stanley wrote:<br>><br>>On Wed, Feb 24, 2016 at 1:15 AM, Andrew Jeffery <<a target="_blank" href="mailto:andrew@aj.id.au">andrew@aj.id.au</a>><br>>wrote:<br>>> Busybox's blkid is a little hamstrung, requiring some processing of<br>>>the<br>>> output to emulate what can be achieved with a couple of options<br>>>with<br>>> blkid from util-linux.<br>>><br>>> Similar to findmtd(), the code for probe_fs_type() and<br>>>blkid_fs_type()<br>>> is duplicated between obmc-{init,update}.sh. Some consideration<br>>>should<br>>> be given to splitting out common functionality into well-defined<br>>> sourcable scripts.<br>><br>>Why not do that? :)<br><br>Well, for one , it reduces the reliability of the script and increases <br>the time by requiring opening and finding additional files.  But we <br>could put all these variables in that file with it.<br><br>I vote for later.<br><br>><br>>Put an example of the input and what you expect as the output in the<br>>comment.<br>><br><br>One can run the command if they need to see it, and its common to<br>ubuntu and busybox.<br><br>>> +       blkid $1 \<br>>> +               | tr ' ' '\n' \<br>>> +               | awk -F= '/TYPE/ { print $2 }' \<br>>> +               | tr -d '"'<br>>> +}<br>>> +<br><br>But more awk less pipes!<br><br>-       blkid $1 \<br>-               | tr ' ' '\n' \<br>-               | awk -F= '/TYPE/ { print $2 }' \<br>-               | tr -d '"'<br>+       blkid $1 | awk ' { if (match($0, / TYPE="[^"]*"/)) {<br>+                               print substr ($0, RSTART+7, RLENGTH-8);<br>+                               exit 0; }<br>+                       }'<br><br>busybox awk does not have the gawk match third arg; the exit 0 <br>says first arg only which should be redundant, and the extra new line <br>makes it a bit more readable at the expense of being the 4th line.<br>alternatively we could look at each arg in a for loop but I decided it<br>just added more code than matching the leading space.<br><br>This also gets rid of those trailing backslashes (otherwise accomplished <br>by putting the pipe at the end of the line).<br><br>(I'll submit this as a patch on top; you can fold or rebase).<br><br>>> +probe_fs_type() {>> +       fst=$(blkid_fs_type $1)<br>>> +       echo ${fst:=jffs2}<br>>> +}<br>>> +<br>>>  rwfs=$(findmtd rwfs)<br>>><br>>>  rwdev=/dev/mtdblock${rwfs#mtd}<br>>> -rwfst=ext4<br>><br>>Would it make sense to do the same as the init case, where you set<br>>rwfst to $(probe_fs_type $rwdev)?<br><br>Not as useful because the type needs be able to change <br>between before and after ... so we need 2 options and one can <br>not be probed until after flashing.<br><br>milton<br></font><BR>