This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
Re: [PATCH v2] Introduce the 'usertemp' filesystem type
- From: Johannes Schindelin <Johannes dot Schindelin at gmx dot de>
- To: cygwin-patches at cygwin dot com
- Date: Tue, 1 Dec 2015 15:07:08 +0100 (CET)
- Subject: Re: [PATCH v2] Introduce the 'usertemp' filesystem type
- Authentication-results: sourceware.org; auth=none
- References: <0MIuft-1ZZdDB2IaP-002Y2r at mail dot gmx dot com> <3ddcb7adf1004c146964beda2f90521bb1c19d4a dot 1448978434 dot git dot johannes dot schindelin at gmx dot de>
... and here is the interdiff vs v1 (compare also to the 'pseudo Pull
Request' at
https://github.com/dscho/msys2-runtime/compare/tempfs-cygwin-v1-rebased...tempfs-cygwin-v2):
diff --git a/winsup/cygwin/include/sys/mount.h
b/winsup/cygwin/include/sys/mount.h
index 458cf80..ec92794 100644
--- a/winsup/cygwin/include/sys/mount.h
+++ b/winsup/cygwin/include/sys/mount.h
@@ -44,7 +44,8 @@ enum
MOUNT_DOS = 0x40000, /* convert leading spaces and trailing
dots and spaces to private use area */
MOUNT_IHASH = 0x80000, /* Enforce hash values for inode numbers */
- MOUNT_BIND = 0x100000 /* Allows bind syntax in fstab file. */
+ MOUNT_BIND = 0x100000, /* Allows bind syntax in fstab file. */
+ MOUNT_USER_TEMP = 0x200000 /* Mount the user's $TMP. */
};
int mount (const char *, const char *, unsigned __flags);
diff --git a/winsup/cygwin/mount.cc b/winsup/cygwin/mount.cc
index be5de61..fc080c9 100644
--- a/winsup/cygwin/mount.cc
+++ b/winsup/cygwin/mount.cc
@@ -1200,14 +1200,15 @@ mount_info::from_fstab_line (char *line, bool user)
}
else if (!strcmp (fs_type, "usertemp"))
{
- WCHAR tmp[MAX_PATH];
+ WCHAR tmp[PATH_MAX + 1];
- if (GetEnvironmentVariableW (L"TEMP", tmp, sizeof(tmp)) && *tmp)
+ if (GetTempPathW (PATH_MAX, tmp))
{
- DWORD len;
- char mb_tmp[len = sys_wcstombs (NULL, 0, tmp)];
- sys_wcstombs (mb_tmp, len, tmp);
+ tmp_pathbuf tp;
+ char *mb_tmp = tp.c_get ();
+ sys_wcstombs (mb_tmp, PATH_MAX, tmp);
+ mount_flags |= MOUNT_USER_TEMP;
int res = mount_table->add_item (mb_tmp, posix_path, mount_flags);
if (res && get_errno () == EMFILE)
return false;
@@ -1670,6 +1671,9 @@ fillout_mntent (const char *native_path, const char *posix_path, unsigned flags)
if (flags & (MOUNT_BIND))
strcat (_my_tls.locals.mnt_opts, (char *) ",bind");
+ if (flags & (MOUNT_USER_TEMP))
+ strcat (_my_tls.locals.mnt_opts, (char *) ",usertemp");
+
ret.mnt_opts = _my_tls.locals.mnt_opts;
ret.mnt_freq = 1;