comparison src/fileio.c @ 2741:1d72336294c6

* 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.
author Jim Blandy <jimb@redhat.com>
date Tue, 11 May 1993 01:39:42 +0000
parents f378d89945e1
children 1ed91566882a
comparison
equal deleted inserted replaced
2740:d7ed0a89ee41 2741:1d72336294c6
2063 #else /* not S_IFLNK */ 2063 #else /* not S_IFLNK */
2064 return Qnil; 2064 return Qnil;
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,
2071 "Return t if file FILENAME can be written or created by you.") 2095 "Return t if file FILENAME can be written or created by you.")
2072 (filename) 2096 (filename)
2083 handler = Ffind_file_name_handler (abspath); 2107 handler = Ffind_file_name_handler (abspath);
2084 if (!NILP (handler)) 2108 if (!NILP (handler))
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
2098 DEFUN ("file-directory-p", Ffile_directory_p, Sfile_directory_p, 1, 1, 0, 2125 DEFUN ("file-directory-p", Ffile_directory_p, Sfile_directory_p, 1, 1, 0,
2099 "Return t if file FILENAME is the name of a directory as a file.\n\ 2126 "Return t if file FILENAME is the name of a directory as a file.\n\