I am in the process of learning systems programming in FreeBSD 12.1. I'm reading and working through Bruce Molay's 2002 book, "Understanding Unix/Linux Programming: A Guide to Theory and Practice." The author says the best way to learn systems programming is to think about, investigate, and emulate existing systems programs. I agree with him and have started doing this with FreeBSD. It's been fun and informative, but I'm dissatisfied with my work on the
1. Use the getutxent access function and its cousins to read /var/run/utx.active into utmpx structures and print those out (works ok)
2. Read the file directly into futx structures and convert those to utmpx's (should work)
Unfortunately, while the second option is appealing as it doesn't rely on intermediary access functions, it isn't documented, as far as I can tell. So, I have a couple of questions :
1. Why doesn't /var/run/utx.active contain utmpx records?
2. Why, if futx is a better format, isn't it documented and its functions available in the system libraries?
Forgive me if I misstated the situation, but it's all pretty new territory to me and the learning curve is awe inspiring. I look forward to any help y'all can give.
Thanks,
Will
who
command. I did my investigation man who
man utx
, etc. I specifically chose not to look at the who.c source code until after I've tried to implement it from the man pages and include files. It seemed like it should be as simple as reading in a utmpx struct from /var/run/utx.active and displaying it's fields. It didn't take long to realize that the file /var/run/utx.active doesn't contain utmpx structs... However, this was only apparent after I pulled it up in a debugger and looked at the alignment of the fields. After a search on the internet, I found a reference to struct futx. Then I dug around the source and found its header and c implementation. OK... it seems like I have 2 choices:1. Use the getutxent access function and its cousins to read /var/run/utx.active into utmpx structures and print those out (works ok)
2. Read the file directly into futx structures and convert those to utmpx's (should work)
Unfortunately, while the second option is appealing as it doesn't rely on intermediary access functions, it isn't documented, as far as I can tell. So, I have a couple of questions :
1. Why doesn't /var/run/utx.active contain utmpx records?
2. Why, if futx is a better format, isn't it documented and its functions available in the system libraries?
Forgive me if I misstated the situation, but it's all pretty new territory to me and the learning curve is awe inspiring. I look forward to any help y'all can give.
Thanks,
Will