Friday, May 18, 2007

Exporting server home directories

In order to preserve permissions on the home directories of users on *nix server, while exporting them using NFS, they must be exported with the following options:

Assume we have user foo(uid=505) who is part of group foobar(gid=501). His home directory is obviously /home/foo.

In order to export it foo's PC with IP 10.10.10.10 the following line is added to /etc/exports:

/home/foo 10.10.10.10(rw,sync,all_squash,anonuid=505,anongid=501)

Reload/Restart the nfs daemon and mount the directory on foo's machine.

Doing an ls on foo's PC you might see odd user and group id's but these depend solely on foo's /etc/passwd and /etc/group number associations.

That's it

Thursday, May 3, 2007

Linux _syscallX macros removed in kernel 2.6.x

It seems that as of kernel version 2.6.x (which x? does anybody know?) the macros _syscallX (where X=1,2,3,4,5,6) have been removed. Now what is a poor developer to do in order to get a system call to work?

I haven't been able to find a proper written document describing the "Novo ordo seclorum" of the kernel but what I did is simple and seems to work (compiling at least).


The _syscallX macros produced a wrapper function for the standard glibc function syscall(). This is what I did also but without the macro.

Let's say you want to use

int sys_foo(char* arg1,int arg2,struct bar* arg3).


Back in the old kernel days you whould put the following in your C source file:

_syscall3(int, sys_foo, char*, arg1, int, arg2, struct bar*, arg3) /* mind the comma's */

and you would use sys_foo normally as being defined in the same source file.

Observe to what this macro expands:

int sys_foo (char* arg1, int arg2, struct bar* arg3)
{
return syscall( __NR_sys_futex, arg1, arg2, arg3);
}

Case solved. Use the above function prototype as a guide and you will be rubbing your eyes*



(*) Direct greek translation of the expression "τρίβω τα μάτια μου". It is meant as a greek joke. All foreign speaking visitors please ignore and replace with "you will be astonished" or something similar.