From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 0B2F23870C14; Thu, 30 Nov 2023 21:40:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0B2F23870C14 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1701380410; bh=uIuzTjz0SSLYF5TRJvtzoN5xGNy0AEAJzqkXrrPjJ1A=; h=From:To:Subject:Date:From; b=aBw0tKVvNVMKK3mqJ4pMjV852ztD9Yutw0Wt0BnzYopoemJmhlv6n4BPc+4D62+rk xz3/UBoLM2SNcyZ5ZwU9o/oeArrbQ16eB9244eMwRJXOuZzVmvAf9uCJoyCvgBJZfr 5LUgvBHKY9Jfc5LFp/uZBhHZUHLv0W4m47xMUSJY= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: fs_info: check for SSD X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: 61f49ada90b2541925d56183e91e7d57aad1547a X-Git-Newrev: 8b01c5d6903fbcbb14c52db45c12494b53493c5a Message-Id: <20231130214010.0B2F23870C14@sourceware.org> Date: Thu, 30 Nov 2023 21:40:10 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D8b01c5d6903= fbcbb14c52db45c12494b53493c5a commit 8b01c5d6903fbcbb14c52db45c12494b53493c5a Author: Corinna Vinschen AuthorDate: Thu Nov 30 22:13:49 2023 +0100 Commit: Corinna Vinschen CommitDate: Thu Nov 30 22:37:35 2023 +0100 Cygwin: fs_info: check for SSD =20 During fs_info::update, check for the file being on an SSD. =20 Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/local_includes/mount.h | 4 ++++ winsup/cygwin/mount.cc | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/winsup/cygwin/local_includes/mount.h b/winsup/cygwin/local_inc= ludes/mount.h index 5bb84b9769cb..57c89e010161 100644 --- a/winsup/cygwin/local_includes/mount.h +++ b/winsup/cygwin/local_includes/mount.h @@ -69,6 +69,7 @@ class fs_info ULONG name_len; /* MaximumComponentNameLength */ fs_info_type fs_type; /* Filesystem type */ unsigned is_remote_drive : 1; + unsigned is_ssd : 1; unsigned has_acls : 1; unsigned hasgood_inode : 1; unsigned caseinsensitive : 1; @@ -80,6 +81,8 @@ class fs_info ULONG sernum; /* Volume Serial Number */ char fsn[80]; /* Windows filesystem name */ =20 + void check_ssd (HANDLE); + public: void clear () { @@ -93,6 +96,7 @@ class fs_info IMPLEMENT_STATUS_FLAG (ULONG, samba_version) IMPLEMENT_STATUS_FLAG (ULONG, name_len) IMPLEMENT_STATUS_FLAG (bool, is_remote_drive) + IMPLEMENT_STATUS_FLAG (bool, is_ssd) IMPLEMENT_STATUS_FLAG (bool, has_acls) IMPLEMENT_STATUS_FLAG (bool, hasgood_inode) IMPLEMENT_STATUS_FLAG (bool, caseinsensitive) diff --git a/winsup/cygwin/mount.cc b/winsup/cygwin/mount.cc index 13ace6250438..9545d22e0768 100644 --- a/winsup/cygwin/mount.cc +++ b/winsup/cygwin/mount.cc @@ -523,8 +523,22 @@ fs_info::update (PUNICODE_STRING upath, HANDLE in_vol) caseinsensitive ((!(flags () & FILE_CASE_SENSITIVE_SEARCH) || is_samba (= )) && !is_nfs ()); =20 + /* Check for being an SSD */ + if (!is_remote_drive () && !is_cdrom ()) + { + /* Theoretically FileFsVolumeFlagsInformation would be sufficient, + but apparently it's not exposed into userspace. */ + FILE_FS_SECTOR_SIZE_INFORMATION ffssi; + + status =3D NtQueryVolumeInformationFile (vol, &io, &ffssi, sizeof ff= ssi, + FileFsSectorSizeInformation); + if (NT_SUCCESS (status)) + is_ssd (!!(ffssi.Flags & SSINFO_FLAGS_NO_SEEK_PENALTY)); + } + if (!in_vol) NtClose (vol); + fsi_cache.add (hash, this); return true; }