2008-12-25 23:55:31 +08:00
|
|
|
/* mount.h: mount definitions.
|
|
|
|
|
|
|
|
This file is part of Cygwin.
|
|
|
|
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
|
|
|
#ifndef _MOUNT_H
|
|
|
|
#define _MOUNT_H
|
|
|
|
|
2016-02-09 22:00:30 +08:00
|
|
|
#define __CCP_APP_SLASH 0x10000000 /* Internal flag for conv_to_posix_path.
|
|
|
|
always append slash, even if path
|
|
|
|
is "X:\\" only. */
|
|
|
|
|
2012-02-16 19:02:05 +08:00
|
|
|
enum disk_type
|
|
|
|
{
|
|
|
|
DT_NODISK,
|
|
|
|
DT_CDROM,
|
|
|
|
DT_FLOPPY,
|
|
|
|
DT_HARDDISK,
|
|
|
|
DT_SHARE_SMB,
|
|
|
|
DT_SHARE_NFS
|
|
|
|
};
|
|
|
|
|
|
|
|
disk_type get_disk_type (LPCWSTR);
|
|
|
|
|
2012-08-14 17:49:25 +08:00
|
|
|
/* Don't add new fs types without adding them to fs_names in mount.cc!
|
|
|
|
Don't reorder without reordering fs_names in mount.cc! */
|
2009-07-28 18:39:55 +08:00
|
|
|
enum fs_info_type
|
|
|
|
{
|
|
|
|
none = 0,
|
|
|
|
fat,
|
2018-12-24 00:53:55 +08:00
|
|
|
exfat,
|
2009-07-28 18:39:55 +08:00
|
|
|
ntfs,
|
2012-06-04 00:46:53 +08:00
|
|
|
refs,
|
2009-07-28 18:39:55 +08:00
|
|
|
samba,
|
|
|
|
nfs,
|
|
|
|
netapp,
|
|
|
|
cdrom,
|
|
|
|
udf,
|
|
|
|
csc_cache,
|
|
|
|
unixfs,
|
|
|
|
mvfs,
|
|
|
|
cifs,
|
2010-01-12 22:47:46 +08:00
|
|
|
nwfs,
|
2011-10-21 16:29:19 +08:00
|
|
|
ncfsd,
|
2013-04-24 18:16:13 +08:00
|
|
|
afs,
|
2015-11-02 19:08:25 +08:00
|
|
|
prlfs,
|
2009-07-28 18:39:55 +08:00
|
|
|
/* Always last. */
|
|
|
|
max_fs_type
|
|
|
|
};
|
|
|
|
|
2010-08-09 16:18:30 +08:00
|
|
|
extern struct fs_names_t {
|
|
|
|
const char *name;
|
|
|
|
bool block_device;
|
|
|
|
} fs_names[];
|
|
|
|
|
2010-11-22 22:19:50 +08:00
|
|
|
#define IMPLEMENT_FS_FLAG(type) \
|
|
|
|
bool is_##type (bool val) { if (val) status.fs_type = type; return val; } \
|
|
|
|
bool is_##type () const { return status.fs_type == type; }
|
2009-07-28 18:39:55 +08:00
|
|
|
|
2008-12-25 23:55:31 +08:00
|
|
|
class fs_info
|
|
|
|
{
|
|
|
|
struct status_flags
|
|
|
|
{
|
2009-07-28 18:39:55 +08:00
|
|
|
ULONG flags; /* Volume flags */
|
|
|
|
ULONG samba_version; /* Samba version if available */
|
|
|
|
ULONG name_len; /* MaximumComponentNameLength */
|
|
|
|
fs_info_type fs_type; /* Filesystem type */
|
2008-12-25 23:55:31 +08:00
|
|
|
unsigned is_remote_drive : 1;
|
2023-12-01 05:13:49 +08:00
|
|
|
unsigned is_ssd : 1;
|
2008-12-25 23:55:31 +08:00
|
|
|
unsigned has_acls : 1;
|
|
|
|
unsigned hasgood_inode : 1;
|
|
|
|
unsigned caseinsensitive : 1;
|
2010-09-22 00:32:22 +08:00
|
|
|
unsigned has_buggy_reopen : 1;
|
2009-07-28 18:39:55 +08:00
|
|
|
unsigned has_buggy_fileid_dirinfo : 1;
|
2010-01-12 22:47:46 +08:00
|
|
|
unsigned has_buggy_basic_info : 1;
|
2010-04-23 01:33:28 +08:00
|
|
|
unsigned has_dos_filenames_only : 1;
|
2008-12-25 23:55:31 +08:00
|
|
|
} status;
|
2009-07-28 18:39:55 +08:00
|
|
|
ULONG sernum; /* Volume Serial Number */
|
|
|
|
char fsn[80]; /* Windows filesystem name */
|
2009-07-16 17:56:25 +08:00
|
|
|
|
2008-12-25 23:55:31 +08:00
|
|
|
public:
|
2009-07-23 19:46:06 +08:00
|
|
|
void clear ()
|
|
|
|
{
|
|
|
|
memset (&status, 0 , sizeof status);
|
2011-06-06 13:02:13 +08:00
|
|
|
sernum = 0UL;
|
2009-07-23 19:46:06 +08:00
|
|
|
fsn[0] = '\0';
|
|
|
|
}
|
2008-12-25 23:55:31 +08:00
|
|
|
fs_info () { clear (); }
|
|
|
|
|
|
|
|
IMPLEMENT_STATUS_FLAG (ULONG, flags)
|
|
|
|
IMPLEMENT_STATUS_FLAG (ULONG, samba_version)
|
|
|
|
IMPLEMENT_STATUS_FLAG (ULONG, name_len)
|
|
|
|
IMPLEMENT_STATUS_FLAG (bool, is_remote_drive)
|
2023-12-01 05:13:49 +08:00
|
|
|
IMPLEMENT_STATUS_FLAG (bool, is_ssd)
|
2008-12-25 23:55:31 +08:00
|
|
|
IMPLEMENT_STATUS_FLAG (bool, has_acls)
|
|
|
|
IMPLEMENT_STATUS_FLAG (bool, hasgood_inode)
|
|
|
|
IMPLEMENT_STATUS_FLAG (bool, caseinsensitive)
|
2010-09-22 00:32:22 +08:00
|
|
|
IMPLEMENT_STATUS_FLAG (bool, has_buggy_reopen)
|
2009-07-28 18:39:55 +08:00
|
|
|
IMPLEMENT_STATUS_FLAG (bool, has_buggy_fileid_dirinfo)
|
2010-01-12 22:47:46 +08:00
|
|
|
IMPLEMENT_STATUS_FLAG (bool, has_buggy_basic_info)
|
2010-04-23 01:33:28 +08:00
|
|
|
IMPLEMENT_STATUS_FLAG (bool, has_dos_filenames_only)
|
2010-11-22 22:19:50 +08:00
|
|
|
IMPLEMENT_FS_FLAG (fat)
|
2018-12-24 00:53:55 +08:00
|
|
|
IMPLEMENT_FS_FLAG (exfat)
|
2010-11-22 22:19:50 +08:00
|
|
|
IMPLEMENT_FS_FLAG (ntfs)
|
2012-06-04 00:46:53 +08:00
|
|
|
IMPLEMENT_FS_FLAG (refs)
|
2010-11-22 22:19:50 +08:00
|
|
|
IMPLEMENT_FS_FLAG (samba)
|
|
|
|
IMPLEMENT_FS_FLAG (nfs)
|
|
|
|
IMPLEMENT_FS_FLAG (netapp)
|
|
|
|
IMPLEMENT_FS_FLAG (cdrom)
|
|
|
|
IMPLEMENT_FS_FLAG (udf)
|
|
|
|
IMPLEMENT_FS_FLAG (csc_cache)
|
|
|
|
IMPLEMENT_FS_FLAG (unixfs)
|
|
|
|
IMPLEMENT_FS_FLAG (mvfs)
|
|
|
|
IMPLEMENT_FS_FLAG (cifs)
|
|
|
|
IMPLEMENT_FS_FLAG (nwfs)
|
2011-10-21 16:29:19 +08:00
|
|
|
IMPLEMENT_FS_FLAG (ncfsd)
|
2013-04-24 18:16:13 +08:00
|
|
|
IMPLEMENT_FS_FLAG (afs)
|
2015-11-02 19:08:25 +08:00
|
|
|
IMPLEMENT_FS_FLAG (prlfs)
|
2009-07-28 18:39:55 +08:00
|
|
|
fs_info_type what_fs () const { return status.fs_type; }
|
2012-04-02 19:08:07 +08:00
|
|
|
bool got_fs () const { return status.fs_type != none; }
|
2009-07-28 18:39:55 +08:00
|
|
|
|
2008-12-25 23:55:31 +08:00
|
|
|
ULONG serial_number () const { return sernum; }
|
|
|
|
|
2009-07-23 19:46:06 +08:00
|
|
|
const char *fsname () const { return fsn[0] ? fsn : "unknown"; }
|
2009-07-16 17:56:25 +08:00
|
|
|
|
2022-05-24 03:52:52 +08:00
|
|
|
bool update (PUNICODE_STRING, HANDLE);
|
2010-04-26 21:48:04 +08:00
|
|
|
bool inited () const { return !!status.flags; }
|
2008-12-25 23:55:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Mount table entry */
|
|
|
|
|
|
|
|
class mount_item
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/* FIXME: Nasty static allocation. Need to have a heap in the shared
|
|
|
|
area [with the user being able to configure at runtime the max size]. */
|
|
|
|
/* Win32-style mounted partition source ("C:\foo\bar").
|
|
|
|
native_path[0] == 0 for unused entries. */
|
|
|
|
char native_path[CYG_MAX_PATH];
|
|
|
|
int native_pathlen;
|
|
|
|
|
|
|
|
/* POSIX-style mount point ("/foo/bar") */
|
|
|
|
char posix_path[CYG_MAX_PATH];
|
|
|
|
int posix_pathlen;
|
|
|
|
|
|
|
|
unsigned flags;
|
|
|
|
|
|
|
|
void init (const char *dev, const char *path, unsigned flags);
|
|
|
|
|
|
|
|
struct mntent *getmntent ();
|
|
|
|
int build_win32 (char *, const char *, unsigned *, unsigned);
|
|
|
|
};
|
|
|
|
|
2022-08-04 00:14:39 +08:00
|
|
|
/* Don't change this number willy-nilly. What we need is to have a more
|
|
|
|
dynamic allocation scheme, but the current scheme should be satisfactory
|
|
|
|
for a long while yet. */
|
2011-05-27 03:30:00 +08:00
|
|
|
#define MAX_MOUNTS 64
|
2008-12-25 23:55:31 +08:00
|
|
|
|
|
|
|
class reg_key;
|
|
|
|
struct device;
|
|
|
|
|
|
|
|
/* NOTE: Do not make gratuitous changes to the names or organization of the
|
|
|
|
below class. The layout is checksummed to determine compatibility between
|
|
|
|
different cygwin versions. */
|
|
|
|
class mount_info
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int nmounts;
|
|
|
|
mount_item mount[MAX_MOUNTS];
|
|
|
|
|
2009-05-14 11:25:45 +08:00
|
|
|
static bool got_usr_bin;
|
|
|
|
static bool got_usr_lib;
|
|
|
|
static int root_idx;
|
|
|
|
|
2008-12-25 23:55:31 +08:00
|
|
|
/* cygdrive_prefix is used as the root of the path automatically
|
|
|
|
prepended to a path when the path has no associated mount.
|
|
|
|
cygdrive_flags are the default flags for the cygdrives. */
|
|
|
|
char cygdrive[CYG_MAX_PATH];
|
|
|
|
size_t cygdrive_len;
|
|
|
|
unsigned cygdrive_flags;
|
|
|
|
private:
|
|
|
|
int posix_sorted[MAX_MOUNTS];
|
|
|
|
int native_sorted[MAX_MOUNTS];
|
|
|
|
|
|
|
|
public:
|
2014-11-28 00:49:41 +08:00
|
|
|
void init (bool);
|
2008-12-25 23:55:31 +08:00
|
|
|
int add_item (const char *dev, const char *path, unsigned flags);
|
|
|
|
int del_item (const char *path, unsigned flags);
|
|
|
|
|
|
|
|
int conv_to_win32_path (const char *src_path, char *dst, device&,
|
|
|
|
unsigned *flags = NULL);
|
2015-12-07 00:25:48 +08:00
|
|
|
int conv_to_posix_path (PWCHAR src_path, char *posix_path, int ccp_flags);
|
2008-12-25 23:55:31 +08:00
|
|
|
int conv_to_posix_path (const char *src_path, char *posix_path,
|
2015-12-07 00:25:48 +08:00
|
|
|
int ccp_flags);
|
2008-12-25 23:55:31 +08:00
|
|
|
struct mntent *getmntent (int x);
|
|
|
|
|
|
|
|
int write_cygdrive_info (const char *cygdrive_prefix, unsigned flags);
|
|
|
|
int get_cygdrive_info (char *user, char *system, char* user_flags,
|
|
|
|
char* system_flags);
|
2015-12-07 00:25:48 +08:00
|
|
|
void cygdrive_posix_path (const char *src, char *dst, int flags);
|
2022-08-05 05:48:19 +08:00
|
|
|
size_t get_mounts_here (const char *parent_dir, size_t,
|
|
|
|
PUNICODE_STRING mount_points,
|
|
|
|
PUNICODE_STRING cygd);
|
|
|
|
void free_mounts_here (PUNICODE_STRING, int, PUNICODE_STRING);
|
|
|
|
|
2008-12-25 23:55:31 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
void sort ();
|
|
|
|
void mount_slash ();
|
|
|
|
void create_root_entry (const PWCHAR root);
|
|
|
|
|
|
|
|
bool from_fstab_line (char *line, bool user);
|
|
|
|
bool from_fstab (bool user, WCHAR [], PWCHAR);
|
|
|
|
|
|
|
|
int cygdrive_win32_path (const char *src, char *dst, int& unit);
|
|
|
|
};
|
2011-12-22 20:25:10 +08:00
|
|
|
|
|
|
|
class dos_drive_mappings
|
|
|
|
{
|
|
|
|
struct mapping
|
|
|
|
{
|
|
|
|
mapping *next;
|
|
|
|
size_t doslen;
|
|
|
|
size_t ntlen;
|
|
|
|
wchar_t *dospath;
|
|
|
|
wchar_t *ntdevpath;
|
|
|
|
};
|
|
|
|
mapping *mappings;
|
|
|
|
|
|
|
|
public:
|
|
|
|
dos_drive_mappings ();
|
|
|
|
~dos_drive_mappings ();
|
|
|
|
wchar_t *fixup_if_match (wchar_t *path);
|
|
|
|
};
|
2008-12-25 23:55:31 +08:00
|
|
|
#endif
|