by Jerry.Zhong <quickmouse@263.net>
Filename: utmp.c
Function: write_utmp
Description:
Let's look at the segment of write_utmp dealing with writing delayed boot record. It depends on variable wrote_utmp_reboot. This variable will NOT be zero when UTMP_FILE is exist, but that does NOT mean a write process can be successful, for example the filesystem is in readonly states.
120: if (access(UTMP_FILE, F_OK) < 0)
121: return;
122:
123:#ifdef INIT_MAIN
124: /*
125: * Note if we are going to write a boot record.
126: */
127: if (type == BOOT_TIME) wrote_utmp_reboot++;
128:
129: /*
130: * See if we need to write a reboot record. The reason that
131: * we are being so paranoid is that when we first tried to
132: * write the reboot record, /var was possibly not mounted
133: * yet. As soon as we can open WTMP we write a delayed boot record.
134: */
135: if (wrote_utmp_reboot == 0 && type != BOOT_TIME)
136: write_utmp("reboot", "~~", 0, BOOT_TIME, "~", NULL);
137:#endif
Please compare this segment to write_wtmp function. It uses a file open function to check whether the write can be processed.
Trackback: http://tb.donews.net/TrackBack.aspx?PostId=1039379