[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: testing for a remote file to include file on a Windows mappeddrive
From: |
Michael Albinus |
Subject: |
Re: testing for a remote file to include file on a Windows mappeddrive |
Date: |
Sun, 27 Jan 2008 12:18:43 +0100 |
User-agent: |
Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.50 (gnu/linux) |
Eli Zaretskii <address@hidden> writes:
>> Rough idea: maybe one could use the device number, returned as last
>> attribute of `file-attributes', for a check whether a file has been
>> "mounted". I haven't seen code evaluating the device number. And I
>> don't know whether it is set to a useful value on W32, for example.
>
> Maybe I'm missing something, but how can the device number be used,
> even on Posix platforms, to check if the file is on a mounted volume?
> Can you show sample code?
Not Elisp code, but see this from the shell (on my Ubuntu machine):
I get all filesystems per name and type by this:
arthur:~> cut -f2 -d" " /proc/mounts | xargs stat -f -c "-%n %T"
-/ ext2/ext3
-/sys sysfs
-/proc proc
-/dev tmpfs
-/sys/fs/fuse/connections UNKNOWN (0x65735543)
-/ ext2/ext3
-/dev/.static/dev ext2/ext3
-/var/run tmpfs
-/var/lock tmpfs
-/lib/modules/2.6.22-14-generic/volatile tmpfs
-/dev/shm tmpfs
-/dev/pts devpts
-/var/run tmpfs
-/var/lock tmpfs
-/sys/kernel/security UNKNOWN (0x73636673)
-/proc/sys/fs/binfmt_misc UNKNOWN (0x42494e4d)
-/mnt/albinus UNKNOWN (0x65735546)
-/mnt/src UNKNOWN (0x65735546)
I get the device numbers of the filesystems by this:
arthur:~> cut -f2 -d" " /proc/mounts | xargs stat -c "%n %d"
/ 2049
/sys 0
/proc 3
/dev 14
/sys/fs/fuse/connections 16
/ 2049
/dev/.static/dev 2049
/var/run 18
/var/lock 19
/lib/modules/2.6.22-14-generic/volatile 20
/dev/shm 21
/dev/pts 11
/var/run 18
/var/lock 19
/sys/kernel/security 15
/proc/sys/fs/binfmt_misc 22
/mnt/albinus 23
/mnt/src 24
In Emacs, I evaluate
(nth 11 (file-attributes "~/src/emacs/lisp"))
=> 2049
(nth 11 (file-attributes "~/src/tramp/lisp"))
=> 24
"~/src/emacs" is a link to "/usr/local/src/emacs". The device number
2049 is related to device "/", which has the device type "ext2/ext3".
"~/src/tramp" is a link to "/mnt/src/tramp". The device number 24 is
related to device "/mnt/src", which has the device type "UNKNOWN".
These information (and other ones, if necessary) might be sufficient to
determine whether a given file is "mounted locally". Implementation
shall happen in Emacs C core,of course.
For remote files (in the sense of Tramp) it is obvious:
(nth 11 (file-attributes "/ssh::~/src/tramp/lisp"))
=> (-1 0)
(nth 11 (file-attributes "/ssh::~/src/emacs/lisp"))
=> (-1 0)
Best regards, Michael.
- RE: testing for a remote file to include file on a Windows mappeddrive, (continued)
- Re: testing for a remote file to include file on a Windows mappeddrive, Michael Albinus, 2008/01/26
- Re: testing for a remote file to include file on a Windows mappeddrive, Jason Rumney, 2008/01/26
- RE: testing for a remote file to include file on a Windows mappeddrive, Drew Adams, 2008/01/26
- Re: testing for a remote file to include file on a Windows mappeddrive, Stefan Monnier, 2008/01/26
- Re: testing for a remote file to include file on a Windows mappeddrive, Michael Albinus, 2008/01/26
- Re: testing for a remote file to include file on a Windows mappeddrive, Eli Zaretskii, 2008/01/26
- Re: testing for a remote file to include file on a Windows mappeddrive,
Michael Albinus <=
- Re: testing for a remote file to include file on a Windows mappeddrive, Eli Zaretskii, 2008/01/27
- Re: testing for a remote file to include file on a Windows mappeddrive, Andreas Schwab, 2008/01/27
- Re: testing for a remote file to include file on a Windows mappeddrive, Michael Albinus, 2008/01/27
- RE: testing for a remote file to include file on a Windows mappeddrive, Drew Adams, 2008/01/26
- Re: testing for a remote file to include file on a Windows mappeddrive, Stefan Monnier, 2008/01/27
- Re: testing for a remote file to include file on a Windows mappeddrive, Stefan Monnier, 2008/01/27
- Re: testing for a remote file to include file on a Windows mappeddrive, Michael Albinus, 2008/01/29
- Re: testing for a remote file to include file on a Windows mappeddrive, Richard Stallman, 2008/01/30
- Re: testing for a remote file to include file on a Windows mappeddrive, Michael Albinus, 2008/01/30
- Re: testing for a remote file to include file on a Windows mappeddrive, Stefan Monnier, 2008/01/30