lkml.org 
[lkml]   [1999]   [Jun]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: How can Emacs get a unique ID per Linux reboot?
Date
In muc.lists.linux-kernel, you wrote:
>I'm trying to help RMS fix a problem with Linux and recent test
>releases of GNU Emacs. When the user edits a file FOO, Emacs 20.3.10
>creates a symbolic link from .#FOO to USER@HOSTNAME:PID:BOOTID, where
>BOOTID is a unique identifier for this reboot of the kernel. This
>symlink lets Emacs determine whether someone else is editing this
>file. The symlink is stale if BOOTID does not correspond to last time
>that the kernel was rebooted. (Emacs doesn't rely on lockf or its
>relatives to create advisory locks on files; I believe that this is
>because they aren't portable and reliable enough with networked file
>systems.)
>
>For most operating systems, BOOTID is the timestamp of the last
>reboot. For example, if I edit FOO on Solaris 7, Emacs might create a
>symbolic link from .#FOO to eggert@shade.twinsun.com.18323:924306205,
>since shade.twinsun.com was last rebooted 924306205 seconds after
>1970-01-01 00:00:00 UTC.
>
>Unfortunately, RMS and I haven't been able to discover a documented,
>guaranteed, and fast way to get a unique reboot ID for Linux.

On RedHat systems you could read /var/run/random-seed, the saved state from
/dev/random on last reboot (with a sanity check that its mtime is <= /proc/uptime).
It should be pretty unlikely that there are collisions because it is 512 bytes of
random data. I don't know if other distributions have a similar mechanism.
I would suggest against relying on wtmp, because wtmp is notouriously unreliable
on Linux when multiple libc versions are in use.



-Andi

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:52    [W:1.383 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site