access_table() challenge - win a Samba t-shirt!

Andrew Tridgell tridge at linuxcare.com
Sun Jan 16 13:28:43 GMT 2000


I've just spent quite some time re-doing our deny mode code in
Samba. We now pass (ie. match NT4) on all possible deny mode
combinations.

The core of this code is a function called access_table(). It works
out what access is allowed by a second open when there is an existing
open on the file. It looks like this:

static int access_table(int new_deny,int old_deny,int old_mode,
	                 BOOL same_pid, BOOL isexe)
{
....
}

the first two parameters can take on 6 different values, the next
parameter can take 3 parameters, the last two are boolean. The result
is one of 4 possible values.

The challenge now is to recode access_table() so that it is as small
as possible. Right now it is horrendous, but I suspect there is an
underlying pattern that I have missed.

So, if you want to win a Samba tshirt from nerdgear then grab
ftp://samba.org/pub/tridge/misc/atable.c and modify access_table2() so
that it is small, neat and generally appealing. Then make sure that it
still works. Send me the resulting function. The function I like the
best gets the tshirt.

Those of you good with digital logic problems should find this easy :)

Cheers, Tridge


More information about the samba-technical mailing list