Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 19 Sep 2014, 22:56
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
busybox extras
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 5 [75 Posts]   Goto page: Previous 1, 2, 3, 4, 5 Next
Author Message
Ibidem

Joined: 25 May 2010
Posts: 489
Location: State of Jefferson

PostPosted: Fri 17 May 2013, 01:59    Post subject:  

jamesbond wrote:
technosaurus wrote:
jamesbond wrote:
Attached is a patch that will make bb_guess_fstype
I bet Denys would accept it as a replacement for blkid if we added UUID and label - they are just at different offsets and most seem to already be documented in the source already.
I'm not so sure, I thought that's what blkid is for. The code in volume_id is actually meant for blkid, and in all the filesystem probes they actually stores both the label and the UUID if available (in fact, some of the unused probes seem to work right but they don't have UUID and labels identified properly and my guess is that why Denys left them out atm). I would be happy to drop guess_fstype altogether if only busybox blkid can specify which device to probe (instead of probing all) - but alas they are not.

Do you mean like "busybox blkid /dev/sda1" ?
If so, it works with busybox 1.21.
But if you mean like "busybox blkid /dev/sda", that doesn't work; you must use "for d in /dev/sda*; do blkid $d; done"
blkid does need to print at least TYPE and LABEL as well to match the standard version.
Back to top
View user's profile Send private message 
jamesbond

Joined: 26 Feb 2007
Posts: 2161
Location: The Blue Marble

PostPosted: Sun 19 May 2013, 02:00    Post subject:  

Ibidem wrote:
Do you mean like "busybox blkid /dev/sda1" ?
If so, it works with busybox 1.21.
But if you mean like "busybox blkid /dev/sda", that doesn't work; you must use "for d in /dev/sda*; do blkid $d; done"
blkid does need to print at least TYPE and LABEL as well to match the standard version.
Actually, I was wrong and you are right - even my current 1.19.4 busybox already does that Embarassed

The real problem is this: if I pass a devpath for something that blkid doesn't understand (try passing an "extended partition" device)
a) util-linux blkid will produce no output.
b) busybox blkid will dump output for *ALL* devices.
Of course we can get around that in scripts, but that's *annoying*.

_________________
Fatdog64, Slacko and Puppeee user. Puppy user since 2.13.
Contributed Fatdog64 packages thread
Back to top
View user's profile Send private message 
Ibidem

Joined: 25 May 2010
Posts: 489
Location: State of Jefferson

PostPosted: Mon 20 May 2013, 04:15    Post subject:  

jamesbond wrote:
Ibidem wrote:
Do you mean like "busybox blkid /dev/sda1" ?
If so, it works with busybox 1.21.
But if you mean like "busybox blkid /dev/sda", that doesn't work; you must use "for d in /dev/sda*; do blkid $d; done"
blkid does need to print at least TYPE and LABEL as well to match the standard version.
Actually, I was wrong and you are right - even my current 1.19.4 busybox already does that Embarassed

The real problem is this: if I pass a devpath for something that blkid doesn't understand (try passing an "extended partition" device)
a) util-linux blkid will produce no output.
b) busybox blkid will dump output for *ALL* devices.
Of course we can get around that in scripts, but that's *annoying*.

With busybox 1.21.0, it will produce no output (tested with /dev/sda4)
This is proper behavior, since that device has no UUID.
Also, it seems LABEL is now supported. TYPE, however, isn't.

Hmm...I wonder if an mdev hook could use blkid for /dev/disks/by-*

And I believe busybox has code to detect filesystems, but good luck finding it.
Back to top
View user's profile Send private message 
Ibidem

Joined: 25 May 2010
Posts: 489
Location: State of Jefferson

PostPosted: Mon 20 May 2013, 16:23    Post subject:  

musher0 wrote:
To whom it may concern:

At least reintroduce the prompt function and the command function in busybox's less (-P and !<command> parameters).

Or remove less from busybox altogether. Because, as it is now, busybox's less is a joke.

It's a shame that such an excellent pager/reader with so many useful options be reduced to not even a workable skeleton of itself in busybox.

It's also misrepresentation, on an ethical level, but that is another subject.

musher0

From "reintroduce" I get the impression that you are saying it was in busybox at one point...if that is correct, when was that? (I couldn't find any indications in the git log.)

By the way, for my own purposes, (current) busybox less is quite adequate in a way that more falls far short of.
Back to top
View user's profile Send private message 
jamesbond

Joined: 26 Feb 2007
Posts: 2161
Location: The Blue Marble

PostPosted: Tue 21 May 2013, 11:40    Post subject:  

Ibidem wrote:
With busybox 1.21.0, it will produce no output (tested with /dev/sda4)
This is proper behavior, since that device has no UUID.
Also, it seems LABEL is now supported. TYPE, however, isn't.

Well Shocked It wasn't obvious from the code. Perhaps it's time to upgrade Evil or Very Mad I'm quite sure it supports type because in 1.19.4 it does show type. Perhaps you didn't enable a compile-time option.

Quote:
Hmm...I wonder if an mdev hook could use blkid for /dev/disks/by-*
Probably.

Quote:
And I believe busybox has code to detect filesystems, but good luck finding it.
It does, in util-linux/volume_id. That's what my patch is for Wink to make a standalone executable out of these filesystem detection code.
_________________
Fatdog64, Slacko and Puppeee user. Puppy user since 2.13.
Contributed Fatdog64 packages thread
Back to top
View user's profile Send private message 
Ibidem

Joined: 25 May 2010
Posts: 489
Location: State of Jefferson

PostPosted: Wed 22 May 2013, 19:36    Post subject:  

jamesbond wrote:
Ibidem wrote:
With busybox 1.21.0, it will produce no output (tested with /dev/sda4)
This is proper behavior, since that device has no UUID.
Also, it seems LABEL is now supported. TYPE, however, isn't.

Well Shocked It wasn't obvious from the code. Perhaps it's time to upgrade Evil or Very Mad I'm quite sure it supports type because in 1.19.4 it does show type. Perhaps you didn't enable a compile-time option.

Quote:
Hmm...I wonder if an mdev hook could use blkid for /dev/disks/by-*
Probably.

Quote:
And I believe busybox has code to detect filesystems, but good luck finding it.
It does, in util-linux/volume_id. That's what my patch is for Wink to make a standalone executable out of these filesystem detection code.


You are correct, I hadn't enabled it.Embarassed
TYPE is conditional.

LABEL support, however, was present by 2008 according to the git log (one commit from just before 1.13.0 was tagged shows sample output with LABEL included)...
Edit: Whoops, you meant the change of behavior when the device specified doesn't have a UUID. That would be this commit:
Code:
commit e8cfc3f693e8a0cbfc489564c76e00c074f63066
Author: Denys Vlasenko
Date:   Sat Mar 3 15:09:07 2012 +0100

    blkid: if parameters are given, do not scan /dev
   
    Signed-off-by: Denys Vlasenko


Also, here's something I'd forgotten about.
Code:
#!/bin/busybox ash
#Assume $MDEV is the device name
#Make /dev/disk/by-* symlinks

if [ -z "$MDEV" ]
then
 echo 'Use from mdev/conf'; env >>/var/log/mdev-blk.log
# This expands to "export" when no output, or to a sequence of assignments
else
 export `blkid "/dev/$MDEV" |cut -d : -f 2` >/dev/null|| true
 [ -n "$LABEL" ] && mkdir -p /dev/disk/by-label && \
 ln -sf "/dev/$MDEV" "/dev/disk/by-label/`echo $LABEL|tr -d '"'`" || true
 [ -n "$UUID" ] && mkdir -p /dev/disk/by-uuid && \
 ln -sf "/dev/$MDEV" "/dev/disk/by-uuid/`echo $UUID|tr -d '"'`" || true

 exec >>/var/log/mdev-blk.log
 echo "blkln $@"
 env
 echo ===
fi

There may be issues with this, I didn't throw any pathological cases at it.

Last edited by Ibidem on Wed 22 May 2013, 20:03; edited 1 time in total
Back to top
View user's profile Send private message 
Ibidem

Joined: 25 May 2010
Posts: 489
Location: State of Jefferson

PostPosted: Wed 22 May 2013, 19:49    Post subject:  

And here's the old nroff applet (as gzipped patch)
Part of this is a tweak to man that deletes the use of gtbl.

md5sum:
93ab39ade0b6f8b4c85750e0aed55ee4 bb-nroff.diff.gz
bb-nroff.diff.gz
Description  gzip'd git diff: use zcat bb-nroff.diff.gz |patch -p1 to apply.
gz

 Download 
Filename  bb-nroff.diff.gz 
Filesize  3.06 KB 
Downloaded  306 Time(s) 
Back to top
View user's profile Send private message 
Ibidem

Joined: 25 May 2010
Posts: 489
Location: State of Jefferson

PostPosted: Thu 23 May 2013, 02:33    Post subject:  

jamesbond wrote:

Anyway, as it is now, busybox guess_fstype takes 2.5 times the time of the original guess_fstype Shocked, but I'll take use it anyway because it is still in milliseconds range and it is more maintainable. I am re-posting the patch because the original one I posted was buggy (forgot to return pointer value in xzalloc Evil or Very Mad - but it worked previously as long as I didn't turn on optimisation ...).


Just for reference: here's a "guess_fs" patch based on the previous patches that provides an applet.
I did a bit of cleanup and used the //config: //applet: //kbuild: approach, which reduces the risk of patches getting stale.
Also, I added support for multiple device names.
guessfs.diff.gz
Description 
gz

 Download 
Filename  guessfs.diff.gz 
Filesize  2.55 KB 
Downloaded  301 Time(s) 
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 4236
Location: Gatineau (Qc), Canada

PostPosted: Thu 30 May 2013, 04:34    Post subject:  

Ibidem wrote:
musher0 wrote:
To whom it may concern:

At least reintroduce the prompt function and the command function in busybox's less (-P and !<command> parameters).

Or remove less from busybox altogether. Because, as it is now, busybox's less is a joke.

It's a shame that such an excellent pager/reader with so many useful options be reduced to not even a workable skeleton of itself in busybox.

It's also misrepresentation, on an ethical level, but that is another subject.

musher0

From "reintroduce" I get the impression that you are saying it was in busybox at one point...if that is correct, when was that? (I couldn't find any indications in the git log.)

By the way, for my own purposes, (current) busybox less is quite adequate in a way that more falls far short of.


Hello, Ibidem.

"Re-introduce" in the sense of putting back in the busybox less some of the functions it removed from the real less. I don't think those functions mentioned above were ever in the busybox less.

The difference can be illustrated by the size of the --help :
if I remember correctly : busybox less -> 4 lines
the real less -> 4 pages.

In my mind, it's clear that the busybox less is mis-representing the real less. Is there a doc telling the user what functions busybox has removed from the utilities it is supposed to replace? If not...

BTW, if you look in the /bin directory, you'll see quite a few busybox functions that BK himself has marked as "BB-NOT-USED". And he then provided the real program or a suitable replacement.

The problem here is that the user is not made aware of what (s)he is missing. If I had not searched the Internet, I would still not know all the possibilities of the real less. But not all users are as persistent.

You never know when you will need the full version of the utility replaced by a busybox "applet".

Best regards.

musher0

_________________
"Logical entities must not be multiplied needlessly." / "Il ne faut pas multiplier les êtres logiques inutilement." (Ockham)
Back to top
View user's profile Send private message Visit poster's website 
jamesbond

Joined: 26 Feb 2007
Posts: 2161
Location: The Blue Marble

PostPosted: Tue 04 Jun 2013, 13:26    Post subject:  

Ibidem wrote:
Just for reference: here's a "guess_fs" patch based on the previous patches that provides an applet.
I did a bit of cleanup and used the //config: //applet: //kbuild: approach, which reduces the risk of patches getting stale.
Also, I added support for multiple device names.

Thanks Ibidem,

This is indeed excellent! .
There is no reason to keep the old guess_fstype anymore Smile

_________________
Fatdog64, Slacko and Puppeee user. Puppy user since 2.13.
Contributed Fatdog64 packages thread
Back to top
View user's profile Send private message 
Ibidem

Joined: 25 May 2010
Posts: 489
Location: State of Jefferson

PostPosted: Tue 04 Jun 2013, 23:08    Post subject:  

musher0 wrote:
Ibidem wrote:
musher0 wrote:
To whom it may concern:

At least reintroduce the prompt function and the command function in busybox's less (-P and !<command> parameters).

Or remove less from busybox altogether. Because, as it is now, busybox's less is a joke.

It's a shame that such an excellent pager/reader with so many useful options be reduced to not even a workable skeleton of itself in busybox.

It's also misrepresentation, on an ethical level, but that is another subject.

musher0

From "reintroduce" I get the impression that you are saying it was in busybox at one point...if that is correct, when was that? (I couldn't find any indications in the git log.)

By the way, for my own purposes, (current) busybox less is quite adequate in a way that more falls far short of.


Hello, Ibidem.

"Re-introduce" in the sense of putting back in the busybox less some of the functions it removed from the real less. I don't think those functions mentioned above were ever in the busybox less.

The difference can be illustrated by the size of the --help :
if I remember correctly : busybox less -> 4 lines
the real less -> 4 pages.

In my mind, it's clear that the busybox less is mis-representing the real less. Is there a doc telling the user what functions busybox has removed from the utilities it is supposed to replace? If not...

BTW, if you look in the /bin directory, you'll see quite a few busybox functions that BK himself has marked as "BB-NOT-USED". And he then provided the real program or a suitable replacement.

The problem here is that the user is not made aware of what (s)he is missing. If I had not searched the Internet, I would still not know all the possibilities of the real less. But not all users are as persistent.

You never know when you will need the full version of the utility replaced by a busybox "applet".

Best regards.

musher0


Standard Busybox policy (documented somewhere-I-forget-where-it-was Wink ) is to implement what is needed for scripts to work; SUSv3 conformance is not essential (especially when it's obscure options that aren't used anywhere...), but is considered desireable.

It is designed primarily as a scripting environment, but one that happens to be quite functional if you need to login to some embedded device.
That "embedded device" is a key part of the design process though. If busybox included every option of all the commands implemented, it would likely be a 20MB binary instead of 1-2 MB, and it would take half an hour to build instead of a couple minutes... And if that were the case, there would be many areas where busybox would fall out of use due to bloat. And we'd get stuck with even crappier alternatives.

But I'd like to ask you one question: when was the last time you needed
!<command> in less? I could see the reason if it were vi you were talking about, but have never desired that in a pager.
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 4236
Location: Gatineau (Qc), Canada

PostPosted: Wed 05 Jun 2013, 18:00    Post subject:  

Hi, Ibidem.

Ibidem wrote:
> But I'd like to ask you one question: when was the last time you needed
!<command> in less? I could see the reason if it were vi you were
talking about, but have never desired that in a pager.


Oh! I find quite handy. I use it a lot. It saves me the trouble of going
back to the menu or to a desktop icon to launch urxvt, for example, or
a script, or any other program. I now use it even to see what drives
are mounted and for access to them (see attached pic).

What I find particularly interesting in the full less is that it can act a real
reader (its main purpose). Through proper setting of its variables, it can
launch an editor (say, geany, or joe) if you need to edit anything.

I have made it my "defaulttextviewer"; it's much faster than the current
practice in Puppy, of using leafpad or nicoedit as the viewer. Also, since
you can't edit anything in less, while reading the text, you can't introduce
accidental errors if you press a wrong key.

Other uses:
You can team it up with cal to see a month or a year (see pic 2, and
code below)

Use less instead of gtk-dialog or yaf-splash; if you use the transparent
effect (-tr, -tint, and/or -sh parameters) in urxvt, it makes for a more
visually interesting message.

Highlight important words in a text you're sending to friends, members
or subscribers.

Etc., etc.

Thanks for reading this. BFN.

musher0

~~~~~~~~~~~~~~
Example: Script to view previous, current, or next year in less.

Code:
#!/bin/ash
# $BINS/annee.sh
#
# annee, sans paramètre ou avec le paramètre 0, donne
#   le calendrier de l'annee courante;
# annee +, celui de l'année suivante;
# annee -, celui de l'année précédente.
#
#(c) musher0, June 5, 2013.
####
a="`date +\"%Y\"`"
case $@ in
   +) an="`expr $a + 1`" ;;
   -) an="`expr $a - 1`" ;;
   0|*) an=$a ;;
esac
cal -s $an > /tmp/$an
AN="`head -n 1 /tmp/$an`"
GM="g 66x36+280+280"
urxvt -fn "xft:Proc2:pixelsize=12:autohint=true" +sb -$GM -tr -e less -L -j 36 -~ -P "$AN" /tmp/$an
rm /tmp/$an


Console usage (translated):
annee.sh 0 -> calendar of current year
annee.sh + -> ... of next year
annee.sh - -> ... of previous year

You can integrate the above directly in a pekwm, icewm or aewm
menu. Or you can create *.desktop files for the three possibilities for
other wm's. Or link to an icon on your desktop.

Note. The proportional Proc2 font is used here on purpose to create
the "wider" effect. Usually, for ease of reading, you'd use a "mono"
font (e.g., Monaco or Liberation Mono) with urxvt/less.
Less_showing_current_year.jpg
 Description   
 Filesize   65.74 KB
 Viewed   397 Time(s)

Less_showing_current_year.jpg

Less_showing_free_mem_on_drives.jpg
 Description   
 Filesize   40.72 KB
 Viewed   397 Time(s)

Less_showing_free_mem_on_drives.jpg


_________________
"Logical entities must not be multiplied needlessly." / "Il ne faut pas multiplier les êtres logiques inutilement." (Ockham)
Back to top
View user's profile Send private message Visit poster's website 
scsijon

Joined: 23 May 2007
Posts: 1042
Location: the australian mallee

PostPosted: Wed 05 Jun 2013, 19:07    Post subject:  

I sugest that you have a look at toybox and see what they have needed to added in there to extend busybox's functions.
Back to top
View user's profile Send private message Visit poster's website 
Ibidem

Joined: 25 May 2010
Posts: 489
Location: State of Jefferson

PostPosted: Thu 06 Jun 2013, 02:46    Post subject:  

scsijon wrote:
I sugest that you have a look at toybox and see what they have needed to added in there to extend busybox's functions.


Current toybox implements these commands (with expr find ifconfig mdev xzcat being partially implemented; toysh might work by chance on some platforms) :
Code:
$ ./toybox
basename bzcat cal cat catv chgrp chmod chown chroot chvt cksum clear
cmp comm count cp cut date df dirname dmesg dos2unix du echo env expand
expr false find free groups head help hostname id ifconfig insmod
kill killall link ln login logname losetup ls lsmod lsusb md5sum mdev
mkdir mkfifo mknod mkswap mktemp modinfo mountpoint nc netcat nice
nohup od oneit passwd patch pidof printenv pwd readahead readlink
realpath rev rm rmdir rmmod seq setsid sha1sum sleep sort stat swapoff
swapon switch_root sync tac tail taskset tee time touch true truncate
tty uname uniq unix2dos unlink unshare uptime usleep uudecode uuencode
vconfig vmstat w wc which who whoami xargs xzcat yes


(I'm the one who prepared xzcat.)
As you can see, there's a lot of work left to do...
Which is why Rob Landley is putting together an indiegogo project to fund work on it.
The main objective for toybox is ostensibly to provide a POSIX cli mcb that takes care of whatever a self-hosting Android needs. But Rob has a good bit more on the agenda, per his notes (basically, toybox should eventually replace all the minor collections of CLI tools, like busybox nash s6...besides being enough to build LFS.)
See http://landley.net/code/toybox/roadmap.html for more details on that score.
Currently the toybox license is pretty much PD.

The ones that are lacking for boot: grep (maybe sed awk tr), mount (beware! this should be ~600 lines; Rob got a 1400 line submission that he has not merged yet)

route is needed for networking, and a dhcp client also.
Back to top
View user's profile Send private message 
scsijon

Joined: 23 May 2007
Posts: 1042
Location: the australian mallee

PostPosted: Thu 06 Jun 2013, 22:02    Post subject:  

thank you ibidem,

I was was leading to the idea that maybe we should add toybox to our 'standard puppy' like aborigonal and others have done to extend some commands without having to use the 'full' command due to lack of functionality with the current busybox's version of a command. It may even allow us to remove some of the full commands we use now.

Alternately, the busybox group maybe need to revisit it's command set and extend a number of them with what users actually now need to have.

My apologies technosaurus for taking your ropic off-topic.

regards to all
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 2 of 5 [75 Posts]   Goto page: Previous 1, 2, 3, 4, 5 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1731s ][ Queries: 13 (0.0073s) ][ GZIP on ]