[Mono-list] Mono.Posix.Syscall

Joshua Tauberer tauberer@for.net
Tue, 14 Sep 2004 18:47:00 -0400


I'm always happy to see Mono.Posix get new functionality.  It's a fun 
little assembly...  Anyway, I have a few comments (merely from the point 
of view of a fellow Mono.Posix.Syscall hacker):

Most of the functions in Syscall are named after the equivalent library 
function.  I'd suggest changing your passwd function to "getpwnam." 
Also, your function is accidentally private.

Stylistically, I'd also change the Account field of the Passwd structure 
to "Name," which seems more natural to me.  (Also, HomeDirectory could 
just be "Home.")  This is a picky point, I know...

I didn't know much about these functions before looking them up, but it 
appears there is a getpwuid function, which is the same as getpwnam 
function but looks up a user by uid.  It'd be great if you added that to 
Syscall also, since it would only take a few more lines of code.  You 
can reuse the same C function (like I did for stat and lstat).

Lastly, in your C implementation, rather than using getpwent_r and 
looping through the results for the right one, it'd be more concise to 
use getpwnam_r and getpwuid_r.  (Again, I had no idea these functions 
even existed until just a few minutes ago. :) )

Anywho, cool.

- Joshua Tauberer


** Nothing Unreal Exists **

Loren Bandiera wrote:
 > I've been using Mono for some software I'm writing and I needed a way to
 > get an entry from a UNIX password file.  I looked around
 > Mono.Posix.Syscall but I didn't find what I was looking for.
 > So I wrote some code to allow Mono.Posix.Syscall to call getpwent_r(3).
 > See attached patches.
 > My problem is now, I'm having issues trying to test it.  I patched 
the mcs
 > and mono source, built it and installed it in /usr/local.  When trying to
 > compile a simple program to use my new code, it told me it couldn't find
 > it in Mono.Posix.Syscall.  I guess my default mono install is causing the
 > confusion.
 > Since I run Gentoo Linux, my next idea was to modify the Mono ebuild and
 > have it add my patches.  I didn't get too far with that due to some other
 > issues in the ebuild, which I won't get into here.
 > Can I have two instances of mono installed?  (say in /usr and 
 >  If so, did I miss something?  Or what is the recommended way to this?