emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Should Emacs provide a uuid function?


From: Eli Zaretskii
Subject: Re: Should Emacs provide a uuid function?
Date: Mon, 09 May 2011 10:23:06 +0300

> From: Leo <address@hidden>
> Date: Mon, 09 May 2011 14:29:20 +0800
> Cc: Ken Raeburn <address@hidden>, Emacs Dev <address@hidden>
> 
> (defun secure-random-bytes (n)
>   (let ((file (cond
>                ((file-exists-p "/dev/random")  "/dev/random")
>                ((file-exists-p "/dev/urandom") "/dev/urandom")
>                (t (error "Secure random device not available")))))

Feh.  Using platform-dependent interfaces in Lisp is not the Emacs
way, in my book.  How about a primitive which would read from
/dev/random or /dev/urandom if they are available, or use other
methods if they are not?

> -  if (!S_ISREG (st.st_mode))
> +  if (!S_ISREG (st.st_mode) && !S_ISCHR (st.st_mode))
>      {
>        not_regular = 1;

This is wrong, I think.  We will now treat character devices as
regular files, and will trust their st_size, seek them for `coding'
cookies, allow to visit them, etc. -- search the function for all the
uses of not_regular, and you will see.

This all will be avoided if we instead provide a primitive that will
both hide system-dependent stuff and avoid the need to teach
insert-file-contents about this special device.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]