Re: [Toybox] Differences between modinfo in toybox and standard version

2013-04-22 Thread idunham
On Mon, Apr 22, 2013 at 07:36:18PM -0500, Rob Landley wrote:
> On 04/22/2013 05:40:28 PM, Isaac Dunham wrote:
> >Hello,
> >The kernel maps all occurences of '-' in module names to '_', so
> >that if you load a module such as snd-pcm-oss.ko or phc-k8.ko, it
> >is presented by lsmod and /proc/modules as module snd_pcm_oss or
> >phc_k8.
> >Modinfo from module-init-tools makes up for that by reversing the
> >logic and treating '-' and '_' as equivalent, while toybox takes
> >only the string passed.
> 
> Happy to accept patches, but I'm not currently up to speed on the
> corner cases of module loading and haven't got spare brain to fit it
> in just now. (If I read through it in the half hour this starbucks
> is still open, I won't finish and will forget what I read by
> morning.)

Understood.
It's not a major issue for me, especially given that I can't boot a
(straight | mostly) toybox system yet.

> >Another difference is that standard modinfo is documented to
> >accept a filename
> >as a parameter (modinfo /path/to/module.ko).
> >
> >Thanks,
> >Isaac Dunham
> 
> I only recently added toys/pending and there are a number of third
> party contributions I never did properly triage and clean up.
> (login.c is another one...)
> 
> Should I move them into pending so we can track them?

Not really concerned about this part--however you see fit.

> Right now my aboriginal linux build is the main real world test for
> this code, and it doesn't do a modular build. (It also doesn't use
> login, it does oneit straight to a shell prompt instead.) Presumably
> the people who contributed it are using it, but then it works for
> them pretty much by definition...
> 
> Thanks for the heads up,
> 
> Rob

___
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net


Re: [Toybox] Differences between modinfo in toybox and standard version

2013-04-22 Thread Rob Landley

On 04/22/2013 05:40:28 PM, Isaac Dunham wrote:

Hello,
The kernel maps all occurences of '-' in module names to '_', so that  
if you load a module such as snd-pcm-oss.ko or phc-k8.ko, it is  
presented by lsmod and /proc/modules as module snd_pcm_oss or phc_k8.
Modinfo from module-init-tools makes up for that by reversing the  
logic and treating '-' and '_' as equivalent, while toybox takes only  
the string passed.
This can result in missing results that should be returned,  
especially in commands like this:

for m in `lsmod |cut -f 1 -d ' '`; do /sbin/modinfo $m; done
(ie, anything that relies on lsmod's output to get a name for  
modinfo).
As far as I am aware, there are no modules that use both an  
underscore and a

hyphen in the filename.


Happy to accept patches, but I'm not currently up to speed on the  
corner cases of module loading and haven't got spare brain to fit it in  
just now. (If I read through it in the half hour this starbucks is  
still open, I won't finish and will forget what I read by morning.)


Another difference is that standard modinfo is documented to accept a  
filename

as a parameter (modinfo /path/to/module.ko).

Thanks,
Isaac Dunham


I only recently added toys/pending and there are a number of third  
party contributions I never did properly triage and clean up. (login.c  
is another one...)


Should I move them into pending so we can track them?

Right now my aboriginal linux build is the main real world test for  
this code, and it doesn't do a modular build. (It also doesn't use  
login, it does oneit straight to a shell prompt instead.) Presumably  
the people who contributed it are using it, but then it works for them  
pretty much by definition...


Thanks for the heads up,

Rob
___
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net


Re: [Toybox] [CLEANUP] [PATCH] stat: Some cleanup

2013-04-22 Thread Rob Landley

On 04/22/2013 04:27:56 PM, Felix Janda wrote:

On 04/21/13 at 11:30pm, Rob Landley wrote:
> > Should "%T" be implemented?
>
> I'd wait for somebody to complain about its absence.

I like that approach. Attached is another patch removing unimplemented
options/formats and doing a bit of cleanup (mainly of the help text,
which has some resemblance with the GNU manual page).


I've lost the plot somewhere, neither of these patches apply to my  
current tree. Last two commit to that file I have (from you) are:


changeset:   872:793972c94560
user:Felix Janda 
date:Sat Apr 20 00:18:17 2013 +0200
files:   toys/pending/stat.c
description:
stat cleanup


changeset:   871:8aa07b575cd6
user:Felix Janda 
date:Fri Apr 19 21:29:36 2013 +0200
files:   toys/pending/stat.c
description:
stat: Reindent from 4 to 2 spaces

When I "hg import -f" the attached files it's a bunch of rejected  
hunks. What did I miss?


Rob
___
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net


[Toybox] Differences between modinfo in toybox and standard version

2013-04-22 Thread Isaac Dunham
Hello,
The kernel maps all occurences of '-' in module names to '_', so that if you 
load a module such as snd-pcm-oss.ko or phc-k8.ko, it is presented by lsmod and 
/proc/modules as module snd_pcm_oss or phc_k8.
Modinfo from module-init-tools makes up for that by reversing the logic and 
treating '-' and '_' as equivalent, while toybox takes only the string passed.
This can result in missing results that should be returned, especially in 
commands like this:
for m in `lsmod |cut -f 1 -d ' '`; do /sbin/modinfo $m; done
(ie, anything that relies on lsmod's output to get a name for modinfo).
As far as I am aware, there are no modules that use both an underscore and a 
hyphen in the filename.

Another difference is that standard modinfo is documented to accept a filename 
as a parameter (modinfo /path/to/module.ko).

Thanks,
Isaac Dunham

___
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net


Re: [Toybox] More find cleanup

2013-04-22 Thread Felix Janda
On 04/21/13 at 11:01pm, Rob Landley wrote:
> [snip]
> > Ok, I thought more about the extra jumping around than about the  
> > integer
> > checks. But actually it should only 2 additional jumps (jumping to the
> > case label and jumping out of the switch with "break").
> 
> Disk access should totally dominate here. Even if it's cached, the  
> syscalls to fetch the next directory entries should dominate. If it  
> doesn't, then worry about it.

Actually it matters even less since the command line is processed only
once...

Felix
___
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net


Re: [Toybox] [CLEANUP] [PATCH] stat: Some cleanup

2013-04-22 Thread Felix Janda
On 04/21/13 at 11:30pm, Rob Landley wrote:
> On 04/21/2013 04:40:16 PM, Felix Janda wrote:
> > > If you can come up with a clean way to share the code, go for it.
> > 
> > Ok, actually I'd only put something like get_access_str() of stat into
> > the lib.
> 
> Cool. Although a quick glance at the one in stat implies it doesn't  
> handle the fun combinations of "suid and sgid bits without  
> corresponding executable bit when applied to a directory so it's the  
> sticky bit" that I had to make work in ls.
> 
>stat /dev/null
>stat /tmp
> 
> So if you actually need that behavior you'll need the blob of ls  
> starting around line 340...

The only thing get_access_str() printed apart from the permissions was
whether it's a directory or not. But I'm very certain that it should be
identical to ls. Thanks for the pointer to the relevant part of ls,
attached is a patch moving it into a library function.

> > > I'm leaning against it. If you saw my toybox talk at ELC (it's on
> > > youtube) I talked about security approaches and containers vs  
> > selinux.
> > 
> > I anticipated that (and read your outline and skimmed the video). So  
> > it
> > would be ok to remove the SELinux parts from the command (which anyway
> > only say that they are not implemented)?
> 
> Yes.
> 
> > Should "%T" be implemented?
> 
> I'd wait for somebody to complain about its absence.

I like that approach. Attached is another patch removing unimplemented
options/formats and doing a bit of cleanup (mainly of the help text,
which has some resemblance with the GNU manual page).

Felix
# HG changeset patch
# User Felix Janda 
# Date 132583 -7200
# Node ID 2e1d78d8d61a815b3e2ccf8fa9d49e11eeaf970f
# Parent  96ce8f013db472a194e906facd116e4f4769
Add library function for the file permission formatting in ls and stat

diff -r 96ce8f013db4 -r 2e1d78d8d61a lib/lib.c
--- a/lib/lib.c	Sun Apr 21 23:45:35 2013 +0200
+++ b/lib/lib.c	Mon Apr 22 22:29:43 2013 +0200
@@ -1154,6 +1154,32 @@
   error_exit("bad mode '%s'", modestr);
 }
 
+// Format a mode for ls and stat
+void format_mode(char (*buf)[11], mode_t mode)
+{
+  char c, d;
+  int i, bit;
+
+  (*buf)[10]=0;
+  for (i=0; i<9; i++) {
+bit = mode & (1< access_string; s-=3) {
-memcpy(s, rwx[permission & 7], 3);
-permission >>= 3;
-  }
-
-  access_string[10] = '\0';
-  return access_string;
-}
-
 static char * date_stat_format(time_t time)
 {
   static char buf[36];
@@ -252,7 +233,7 @@
 TT.user_name = getpwuid(TT.toystat->st_uid);
 TT.group_name = getgrgid(TT.toystat->st_gid);
 // function to get access in human readable format
-TT.access_str = get_access_str(TT.toystat->st_mode & ~S_IFMT, TT.toystat->st_mode);
+format_mode(&TT.access_str, TT.toystat->st_mode);
   } else do_statfs(*toys.optargs);
   print_stat_format(fmts[!flag_c*flag_f+flag_c], flag_f);
 }
diff -r 96ce8f013db4 -r 2e1d78d8d61a toys/posix/ls.c
--- a/toys/posix/ls.c	Sun Apr 21 23:45:35 2013 +0200
+++ b/toys/posix/ls.c	Mon Apr 22 22:29:43 2013 +0200
@@ -335,28 +335,9 @@
 
 if (flags & (FLAG_l|FLAG_o|FLAG_n|FLAG_g)) {
   struct tm *tm;
-  char perm[11], thyme[64], c, d, *usr, *upad, *grp, *grpad;
-  int i, bit;
+  char perm[11], thyme[64], *usr, *upad, *grp, *grpad;
 
-  perm[10]=0;
-  for (i=0; i<9; i++) {
-bit = mode & (1

Re: [Toybox] [PATCH] ifconfig FTBFS here-needs sys/un.h

2013-04-22 Thread Rob Landley

On 04/21/2013 06:56:03 PM, Isaac Dunham wrote:

Hello,
I did make allyesconfig; make (to test ifconfig) and get this:

Compile toybox...
toys/pending/ifconfig.c: In function 'is_host_unix':
toys/pending/ifconfig.c:121: error: invalid application of 'sizeof'  
to incomplete type 'struct sockaddr_un'


Oops, I moved a header to toynet.h and forgot to check it in. Fixing  
that now.


Rob
___
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net