Date: Mon, 21 Jul 1997 20:10:59 +1000 From: David Nugent <davidn@labs.usn.blaze.net.au> To: Michael Smith <msmith@atrad.adelaide.edu.au> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: utmp/wtmp interface Message-ID: <199707211011.UAA00760@labs.usn.blaze.net.au> In-Reply-To: Your message of "Mon, 21 Jul 1997 12:37:42 %2B0930." <199707210307.MAA20639@genesis.atrad.adelaide.edu.au>
next in thread | previous in thread | raw e-mail | index | archive | help
Thanks for the feedback. > Hmm. "More documentation" 8) It's all there. What's missing? > Seriously; I think that perhaps going in a similar direction to the > /etc/passwd approach might be good; write the 'old-format' files > when generating the records, but use an improved binary format under a > new (but related) filename when accessing it from the library. IMHO, this idea sucks. wtmp files on real systems get large enough already without doing it twice. :-( It isn't too hard to modify legacy code here, and if you looked at the proposed new wtmp.h, you'll find it'll spit out compile warnings (maybe should be error?) for any file that includes it unless it defines a macro first. I'm not certain that this is *the* way to go, though, but I can't think of anything better. > In particular, a self-describing format for something like utmp/wtmp > would be very sexy. Could you explain that further? What is a "self-describing format"? > modes = xl->ll_time ? (O_RDWR|O_CREAT) : O_RDONLY; > if (xl == NULL) > errno = EINVAL; Ouch. I must have been half asleep when I inserted the first line. Fixed, thanks. > This fragment is pretty bad. > > static char sbuf[sizeof(pl) * 2]; > > /* time */ > xl->ll_time = pl.ll_time; > /* line */ > xl->ll_line = strncpy(sbuf + l, pl.ll_line, > sizeof(pl.ll_line)); > sbuf[l + sizeof(pl.ll_line)] = '\0'; > if (!*xl->ll_line) > xl->ll_line = NULL; > else > l += strlen(xl->ll_line) + 1; > /* host */ > xl->ll_host = strncpy(sbuf + l, pl.ll_host, > sizeof(pl.ll_host)); > sbuf[l + sizeof(pl.ll_host)] = '\0'; > if (!*xl->ll_host) > xl->ll_host = NULL; Could you be a little more specific than "pretty bad"? > Using a static buffer here isn't so great either. It's going to give > the threaded version cooties by default. 8) These calls are not intended to be reentrant. There are similar 'problems' with all of the get{pw,gr}*() routines, for example. Calling any of these functions from separate threads is something you just don't do, and for the life of me I can't think of a single reason why you'd ever need to in lastlog's case. :) The alternative is to get into memory allocation, along with all the penalties in runtime and resource use, not to mention bloat. Regards, David -- David Nugent - Unique Computing Pty Ltd - Melbourne, Australia Voice +61-3-9791-9547 Data/BBS +61-3-9792-3507 3:632/348@fidonet davidn@freebsd.org davidn@blaze.net.au http://www.blaze.net.au/~davidn/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199707211011.UAA00760>