aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2002-05-12 03:08:59 +0000
committerChristopher Faylor <me@cgf.cx>2002-05-12 03:08:59 +0000
commit29ee580d07d537ec3f57c7ba1f95488513a81eff (patch)
treeaf40e2848dddd0489cc09af4919a780efdb9c5b5
parentb84621d2e3bfcf29f1ce1e700e3b4cd895dff2fd (diff)
downloadnewlib-29ee580d07d537ec3f57c7ba1f95488513a81eff.zip
newlib-29ee580d07d537ec3f57c7ba1f95488513a81eff.tar.gz
newlib-29ee580d07d537ec3f57c7ba1f95488513a81eff.tar.bz2
* fhandler.h (executable_states): For now, make dont_care_if_executable
equivalent to not_executable. * sys/mount.h: Define MOUNT_NOTEXEC. * path.h (fs_info): New class. (path_conv): Move fs-specific fields to new 'fs' structure. (path_conv::update_fs_info): Move to fs_info and rename to just 'update'. * path.cc (fs_info::update): Ditto. Return 'true' if successful. (fillout_mntent): Add ',noexec' to list of reported options.
-rw-r--r--winsup/cygwin/ChangeLog11
-rw-r--r--winsup/cygwin/fhandler.h2
-rw-r--r--winsup/cygwin/include/sys/mount.h4
-rw-r--r--winsup/cygwin/path.cc91
-rw-r--r--winsup/cygwin/path.h32
5 files changed, 80 insertions, 60 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index a894b9d..09ba326 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,16 @@
2002-05-11 Christopher Faylor <cgf@redhat.com>
+ * fhandler.h (executable_states): For now, make dont_care_if_executable
+ equivalent to not_executable.
+ * sys/mount.h: Define MOUNT_NOTEXEC.
+ * path.h (fs_info): New class.
+ (path_conv): Move fs-specific fields to new 'fs' structure.
+ (path_conv::update_fs_info): Move to fs_info and rename to just 'update'.
+ * path.cc (fs_info::update): Ditto. Return 'true' if successful.
+ (fillout_mntent): Add ',noexec' to list of reported options.
+
+2002-05-11 Christopher Faylor <cgf@redhat.com>
+
* fhandler_virtual.cc (fhandler_virtual::close): Quiet a compiler
warning.
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 1a48073..bafcefa 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -123,8 +123,8 @@ enum bg_check_types
enum executable_states
{
is_executable,
- not_executable,
dont_care_if_executable,
+ not_executable = dont_care_if_executable,
dont_know_if_executable
};
diff --git a/winsup/cygwin/include/sys/mount.h b/winsup/cygwin/include/sys/mount.h
index 00b7a01..a7ae25c 100644
--- a/winsup/cygwin/include/sys/mount.h
+++ b/winsup/cygwin/include/sys/mount.h
@@ -24,7 +24,9 @@ enum
MOUNT_AUTO = 0x020, /* mount point refers to auto device mount */
MOUNT_CYGWIN_EXEC = 0x040, /* file or directory is or contains a cygwin
executable */
- MOUNT_MIXED = 0x080, /* reads are text, writes are binary */
+ MOUNT_MIXED = 0x080, /* reads are text, writes are binary
+ not yet implemented */
+ MOUNT_NOTEXEC = 0x100 /* don't check files for executable magic */
};
int mount (const char *, const char *, unsigned __flags);
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 1966be4..ebf3571 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -324,8 +324,8 @@ mkrelpath (char *path)
strcpy (path, ".");
}
-void
-path_conv::update_fs_info (const char* win32_path)
+bool
+fs_info::update (const char *win32_path)
{
char tmp_buf [MAX_PATH];
strncpy (tmp_buf, win32_path, MAX_PATH);
@@ -333,39 +333,37 @@ path_conv::update_fs_info (const char* win32_path)
if (!rootdir (tmp_buf))
{
debug_printf ("Cannot get root component of path %s", win32_path);
- root_dir [0] = fs_name [0] = '\0';
- fs_flags = fs_serial = 0;
- sym_opt = 0;
- return;
+ name [0] = '\0';
+ sym_opt = flags = serial = 0;
+ return false;
}
- if (strcmp (tmp_buf, root_dir) != 0)
- {
- strncpy (root_dir, tmp_buf, MAX_PATH);
- drive_type = GetDriveType (root_dir);
- if (drive_type == DRIVE_REMOTE || (drive_type == DRIVE_UNKNOWN && (root_dir[0] == '\\' && root_dir[1] == '\\')))
- is_remote_drive = 1;
- else
- is_remote_drive = 0;
+ if (strcmp (tmp_buf, root_dir) == 0)
+ return 1;
- if (!GetVolumeInformation (root_dir, NULL, 0, &fs_serial, NULL, &fs_flags,
- fs_name, sizeof (fs_name)))
- {
- debug_printf ("Cannot get volume information (%s), %E", root_dir);
- fs_name [0] = '\0';
- fs_flags = fs_serial = 0;
- sym_opt = 0;
- }
- else
- {
- /* FIXME: Samba by default returns "NTFS" in file system name, but
- * doesn't support Extended Attributes. If there's some fast way to
- * distinguish between samba and real ntfs, it should be implemented
- * here.
- */
- sym_opt = (!is_remote_drive && strcmp (fs_name, "NTFS") == 0) ? PC_CHECK_EA : 0;
- }
+ strncpy (root_dir, tmp_buf, MAX_PATH);
+ drive_type = GetDriveType (root_dir);
+ if (drive_type == DRIVE_REMOTE || (drive_type == DRIVE_UNKNOWN && (root_dir[0] == '\\' && root_dir[1] == '\\')))
+ is_remote_drive = 1;
+ else
+ is_remote_drive = 0;
+
+ if (!GetVolumeInformation (root_dir, NULL, 0, &serial, NULL, &flags,
+ name, sizeof (name)))
+ {
+ debug_printf ("Cannot get volume information (%s), %E", root_dir);
+ name [0] = '\0';
+ sym_opt = flags = serial = 0;
+ return false;
}
+ /* FIXME: Samba by default returns "NTFS" in file system name, but
+ * doesn't support Extended Attributes. If there's some fast way to
+ * distinguish between samba and real ntfs, it should be implemented
+ * here.
+ */
+ sym_opt = (!is_remote_drive && strcmp (name, "NTFS") == 0) ? PC_CHECK_EA : 0;
+
+ return true;
}
void
@@ -429,12 +427,12 @@ path_conv::check (const char *src, unsigned opt,
fileattr = INVALID_FILE_ATTRIBUTES;
case_clash = false;
devn = unit = 0;
- root_dir[0] = '\0';
- fs_name[0] = '\0';
- fs_flags = fs_serial = 0;
- sym_opt = 0;
- drive_type = 0;
- is_remote_drive = 0;
+ fs.root_dir[0] = '\0';
+ fs.name[0] = '\0';
+ fs.flags = fs.serial = 0;
+ fs.sym_opt = 0;
+ fs.drive_type = 0;
+ fs.is_remote_drive = 0;
normalized_path = NULL;
if (!(opt & PC_NULLEMPTY))
@@ -548,7 +546,8 @@ path_conv::check (const char *src, unsigned opt,
goto out; /* Found a device. Stop parsing. */
}
- update_fs_info (full_path);
+ if (!fs.update (full_path))
+ fs.root_dir[0] = '\0';
/* Eat trailing slashes */
char *dostail = strchr (full_path, '\0');
@@ -572,7 +571,7 @@ path_conv::check (const char *src, unsigned opt,
goto out;
}
- int len = sym.check (full_path, suff, opt | sym_opt);
+ int len = sym.check (full_path, suff, opt | fs.sym_opt);
if (sym.case_clash)
{
@@ -742,9 +741,9 @@ out:
if (devn == FH_BAD)
{
- update_fs_info (path);
- if (!fs_name[0])
+ if (!fs.update (path))
{
+ fs.root_dir[0] = '\0';
set_has_acls (false);
set_has_buggy_open (false);
}
@@ -752,14 +751,14 @@ out:
{
set_isdisk ();
debug_printf ("root_dir(%s), this->path(%s), set_has_acls(%d)",
- root_dir, this->path, fs_flags & FS_PERSISTENT_ACLS);
- if (!allow_smbntsec && is_remote_drive)
+ fs.root_dir, this->path, fs.flags & FS_PERSISTENT_ACLS);
+ if (!allow_smbntsec && fs.is_remote_drive)
set_has_acls (false);
else
- set_has_acls (fs_flags & FS_PERSISTENT_ACLS);
+ set_has_acls (fs.flags & FS_PERSISTENT_ACLS);
/* Known file systems with buggy open calls. Further explanation
in fhandler.cc (fhandler_disk_file::open). */
- set_has_buggy_open (strcmp (fs_name, "SUNWNFS") == 0);
+ set_has_buggy_open (strcmp (fs.name, "SUNWNFS") == 0);
}
}
#if 0
@@ -2418,6 +2417,8 @@ fillout_mntent (const char *native_path, const char *posix_path, unsigned flags)
strcat (_reent_winsup ()->mnt_opts, (char *) ",cygexec");
else if (flags & MOUNT_EXEC)
strcat (_reent_winsup ()->mnt_opts, (char *) ",exec");
+ else if (flags & MOUNT_NOTEXEC)
+ strcat (_reent_winsup ()->mnt_opts, (char *) ",noexec");
if ((flags & MOUNT_AUTO)) /* cygdrive */
strcat (_reent_winsup ()->mnt_opts, (char *) ",noumount");
diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h
index 7b47720..7024610 100644
--- a/winsup/cygwin/path.h
+++ b/winsup/cygwin/path.h
@@ -44,10 +44,10 @@ enum path_types
PATH_SYMLINK = MOUNT_SYMLINK,
PATH_BINARY = MOUNT_BINARY,
PATH_EXEC = MOUNT_EXEC,
+ PATH_NOTEXEC = MOUNT_NOTEXEC,
PATH_CYGWIN_EXEC = MOUNT_CYGWIN_EXEC,
PATH_ALL_EXEC = (PATH_CYGWIN_EXEC | PATH_EXEC),
PATH_ISDISK = 0x04000000,
- PATH_NOTEXEC = 0x08000000,
PATH_HAS_SYMLINKS = 0x10000000,
PATH_HASBUGGYOPEN = 0x20000000,
PATH_SOCKET = 0x40000000,
@@ -55,18 +55,22 @@ enum path_types
};
class symlink_info;
-class path_conv
+struct fs_info
{
- char path[MAX_PATH];
+ char name[MAX_PATH];
char root_dir[MAX_PATH];
- char fs_name[MAX_PATH];
- DWORD fs_flags;
- DWORD fs_serial;
+ DWORD flags;
+ DWORD serial;
DWORD sym_opt; /* additional options to pass to symlink_info resolver */
- void add_ext_from_sym (symlink_info&);
- void update_fs_info (const char*);
+ DWORD is_remote_drive;
DWORD drive_type;
- bool is_remote_drive;
+ bool update (const char *);
+};
+class path_conv
+{
+ char path[MAX_PATH];
+ fs_info fs;
+ void add_ext_from_sym (symlink_info&);
public:
unsigned path_flags;
@@ -79,7 +83,7 @@ class path_conv
char *normalized_path;
int isdisk () const { return path_flags & PATH_ISDISK;}
- int isremote () const {return is_remote_drive;}
+ int isremote () const {return fs.is_remote_drive;}
int has_acls () const {return path_flags & PATH_HASACLS;}
int has_symlinks () const {return path_flags & PATH_HAS_SYMLINKS;}
int hasgood_inode () const {return path_flags & PATH_HASACLS;} // Not strictly correct
@@ -126,7 +130,9 @@ class path_conv
check (src, opt | PC_NULLEMPTY, suffixes);
}
- path_conv (): path_flags (0), known_suffix (NULL), error (0), devn (0), unit (0), fileattr (INVALID_FILE_ATTRIBUTES), normalized_path (NULL) {path[0] = '\0';}
+ path_conv (): path_flags (0), known_suffix (NULL), error (0), devn (0),
+ unit (0), fileattr (INVALID_FILE_ATTRIBUTES),
+ normalized_path (NULL) {path[0] = '\0';}
~path_conv ();
inline char *get_win32 () { return path; }
@@ -138,8 +144,8 @@ class path_conv
DWORD get_devn () {return devn == FH_BAD ? (DWORD) FH_DISK : devn;}
short get_unitn () {return devn == FH_BAD ? 0 : unit;}
DWORD file_attributes () {return fileattr;}
- DWORD get_drive_type () {return drive_type;}
- BOOL fs_fast_ea () {return sym_opt & PC_CHECK_EA;}
+ DWORD get_drive_type () {return fs.drive_type;}
+ BOOL fs_fast_ea () {return fs.sym_opt & PC_CHECK_EA;}
void set_path (const char *p) {strcpy (path, p);}
void clear_normalized_path ();
};