diff options
| author | Jim Blandy | 1993-05-11 01:39:42 +0000 |
|---|---|---|
| committer | Jim Blandy | 1993-05-11 01:39:42 +0000 |
| commit | a253bab22d706a30c3742757cb4c370f0bf19003 (patch) | |
| tree | 70f6b40ffbecd20570c5fa6ba96bfbed023d4494 /src | |
| parent | 5cbdb35688ab0b979c047eb48f980279d2440ba5 (diff) | |
| download | emacs-a253bab22d706a30c3742757cb4c370f0bf19003.tar.gz emacs-a253bab22d706a30c3742757cb4c370f0bf19003.zip | |
* fileio.c (ro_fsys) [SOLARIS_BROKEN_ACCESS]: Check for the
filesystem being ro, since Solaris 2.1 doesn't.
(file-writable-p): Call ro_fsys.
* s/sol2.h (SOLARIS_BROKEN_ACCESS): Define this.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileio.c | 31 | ||||
| -rw-r--r-- | src/s/sol2.h | 7 |
2 files changed, 36 insertions, 2 deletions
diff --git a/src/fileio.c b/src/fileio.c index 7927a52d1b1..5e6f048b9c2 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -2065,6 +2065,30 @@ Otherwise returns NIL.") | |||
| 2065 | #endif /* not S_IFLNK */ | 2065 | #endif /* not S_IFLNK */ |
| 2066 | } | 2066 | } |
| 2067 | 2067 | ||
| 2068 | #ifdef SOLARIS_BROKEN_ACCESS | ||
| 2069 | /* In Solaris 2.1, the readonly-ness of the filesystem is not | ||
| 2070 | considered by the access system call. This is Sun's bug, but we | ||
| 2071 | still have to make Emacs work. */ | ||
| 2072 | |||
| 2073 | #include <sys/statvfs.h> | ||
| 2074 | |||
| 2075 | static int | ||
| 2076 | ro_fsys (path) | ||
| 2077 | char *path; | ||
| 2078 | { | ||
| 2079 | struct statvfs statvfsb; | ||
| 2080 | |||
| 2081 | if (statvfs(path, &statvfsb)) | ||
| 2082 | return 1; /* error from statvfs, be conservative and say not wrtable */ | ||
| 2083 | else | ||
| 2084 | /* Otherwise, fsys is ro if bit is set. */ | ||
| 2085 | return statvfsb.f_flag & ST_RDONLY; | ||
| 2086 | } | ||
| 2087 | #else | ||
| 2088 | /* But on every other os, access has already done the right thing. */ | ||
| 2089 | #define ro_fsys(path) 0 | ||
| 2090 | #endif | ||
| 2091 | |||
| 2068 | /* Having this before file-symlink-p mysteriously caused it to be forgotten | 2092 | /* Having this before file-symlink-p mysteriously caused it to be forgotten |
| 2069 | on the RT/PC. */ | 2093 | on the RT/PC. */ |
| 2070 | DEFUN ("file-writable-p", Ffile_writable_p, Sfile_writable_p, 1, 1, 0, | 2094 | DEFUN ("file-writable-p", Ffile_writable_p, Sfile_writable_p, 1, 1, 0, |
| @@ -2085,13 +2109,16 @@ DEFUN ("file-writable-p", Ffile_writable_p, Sfile_writable_p, 1, 1, 0, | |||
| 2085 | return call2 (handler, Qfile_writable_p, abspath); | 2109 | return call2 (handler, Qfile_writable_p, abspath); |
| 2086 | 2110 | ||
| 2087 | if (access (XSTRING (abspath)->data, 0) >= 0) | 2111 | if (access (XSTRING (abspath)->data, 0) >= 0) |
| 2088 | return (access (XSTRING (abspath)->data, 2) >= 0) ? Qt : Qnil; | 2112 | return ((access (XSTRING (abspath)->data, 2) >= 0 |
| 2113 | && ! ro_fsys (XSTRING (abspath))) | ||
| 2114 | ? Qt : Qnil); | ||
| 2089 | dir = Ffile_name_directory (abspath); | 2115 | dir = Ffile_name_directory (abspath); |
| 2090 | #ifdef VMS | 2116 | #ifdef VMS |
| 2091 | if (!NILP (dir)) | 2117 | if (!NILP (dir)) |
| 2092 | dir = Fdirectory_file_name (dir); | 2118 | dir = Fdirectory_file_name (dir); |
| 2093 | #endif /* VMS */ | 2119 | #endif /* VMS */ |
| 2094 | return (access (!NILP (dir) ? (char *) XSTRING (dir)->data : "", 2) >= 0 | 2120 | return ((access (!NILP (dir) ? (char *) XSTRING (dir)->data : "", 2) >= 0 |
| 2121 | && ! ro_fsys ((char *) XSTRING (dir))) | ||
| 2095 | ? Qt : Qnil); | 2122 | ? Qt : Qnil); |
| 2096 | } | 2123 | } |
| 2097 | 2124 | ||
diff --git a/src/s/sol2.h b/src/s/sol2.h index ac499294f25..18d6d74f1cc 100644 --- a/src/s/sol2.h +++ b/src/s/sol2.h | |||
| @@ -17,3 +17,10 @@ | |||
| 17 | #else /* GCC */ | 17 | #else /* GCC */ |
| 18 | #define C_SWITCH_SYSTEM -traditional | 18 | #define C_SWITCH_SYSTEM -traditional |
| 19 | #endif /* GCC */ | 19 | #endif /* GCC */ |
| 20 | |||
| 21 | /* Karl Berry writes: | ||
| 22 | If you have the misfortune to be running Solaris 2.1, you may have | ||
| 23 | noticed that the access system call does not check the readonlyness of | ||
| 24 | the filesystem the path refers to. This is a bug, according to | ||
| 25 | access(2), but in the meantime, some of us need the right behavior. */ | ||
| 26 | #define SOLARIS_BROKEN_ACCESS | ||