public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin/main] Cygwin: FS_IOC_[GS]ETFLAGS: handle pinned and unpinned attributes
Date: Fri,  8 Mar 2024 20:58:32 +0000 (GMT)	[thread overview]
Message-ID: <20240308205832.369743858D33@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=06aa5a751682118ef1d7f2456f8937b4ac181fac

commit 06aa5a751682118ef1d7f2456f8937b4ac181fac
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Fri Mar 8 21:54:58 2024 +0100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Fri Mar 8 21:54:58 2024 +0100

    Cygwin: FS_IOC_[GS]ETFLAGS: handle pinned and unpinned attributes
    
    Add FS_PINNED_FL and FS_UNPINNED_FL flags and handle them with
    mode bits 'p' and 'u' in chattr(1) and lsattr(1).
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/fhandler/disk_file.cc | 4 +++-
 winsup/cygwin/include/cygwin/fs.h   | 6 ++++--
 winsup/doc/utils.xml                | 6 +++++-
 winsup/utils/chattr.c               | 8 ++++++--
 winsup/utils/lsattr.c               | 6 +++++-
 5 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/winsup/cygwin/fhandler/disk_file.cc b/winsup/cygwin/fhandler/disk_file.cc
index f3592148fc5b..9aadbb539f01 100644
--- a/winsup/cygwin/fhandler/disk_file.cc
+++ b/winsup/cygwin/fhandler/disk_file.cc
@@ -2763,7 +2763,9 @@ fhandler_disk_file::fs_ioc_getflags ()
 				 | FS_SYSTEM_FL \
 				 | FS_ARCHIVE_FL \
 				 | FS_TEMP_FL \
-				 | FS_NOTINDEXED_FL)
+				 | FS_NOTINDEXED_FL\
+				 | FS_PINNED_FL \
+				 | FS_UNPINNED_FL)
 
 int
 fhandler_disk_file::fs_ioc_setflags (uint64_t flags)
diff --git a/winsup/cygwin/include/cygwin/fs.h b/winsup/cygwin/include/cygwin/fs.h
index 9b4baf30227a..76d92453808d 100644
--- a/winsup/cygwin/include/cygwin/fs.h
+++ b/winsup/cygwin/include/cygwin/fs.h
@@ -41,10 +41,12 @@ details. */
 #define FS_OFFLINE_FL		0x000001000ULL /* DOS Offline */
 #define FS_NOTINDEXED_FL	0x000002000ULL /* DOS Not context indexed */
 #define FS_ENCRYPT_FL		0x000004000ULL /* Encrypted file */
+#define FS_PINNED_FL		0x000080000ULL /* Pinned file */
+#define FS_UNPINNED_FL		0x000100000ULL /* Unpinned file */
 #define FS_CASESENS_FL		0x100000000ULL /* Case sensitive dir */
 
-#define FS_FL_USER_VISIBLE	0x100007f27ULL /* User visible flags */
-#define FS_FL_USER_MODIFIABLE	0x100006b27ULL /* User modifiable flags */
+#define FS_FL_USER_VISIBLE	0x100187f27ULL /* User visible flags */
+#define FS_FL_USER_MODIFIABLE	0x100186b27ULL /* User modifiable flags */
 
 /* Flags for renameat2, from /usr/include/linux/fs.h.  For now we
    support only RENAME_NOREPLACE. */
diff --git a/winsup/doc/utils.xml b/winsup/doc/utils.xml
index b93671b16dba..fbb39f5f2791 100644
--- a/winsup/doc/utils.xml
+++ b/winsup/doc/utils.xml
@@ -68,7 +68,7 @@
       case sensitivity.
     </para>
 
-    <para>The format of 'mode' is {+-=}[acCehnrsSt]</para>
+    <para>The format of 'mode' is {+-=}[acCehnprsStu]</para>
 
     <para>The operator '+' causes the selected attributes to be added to the
       existing attributes of the files; '-' causes them to be removed; and
@@ -88,6 +88,8 @@
   'n', 'Notindexed':    file or directory is not to be indexed by the
 			content indexing service
   'e', 'Encrypted':     file is encrypted
+  'p', 'Pinned':        file is pinned
+  'u', 'Unpinned':      file is unpinned
   'C', 'Casesensitive': directory is handled case sensitive
     </screen>
     </refsect1>
@@ -1448,6 +1450,8 @@ bash$ locale noexpr
   'n', 'Notindexed':    file or directory is not to be indexed by the
                         content indexing service
   'e', 'Encrypted':     file is encrypted
+  'p', 'Pinned':        file is pinned
+  'u', 'Unpinned':      file is unpinned
   'C', 'Casesensitive': directory is handled case sensitive
                         (Windows 10 1803 or later, local NTFS only,
                          WSL must be installed)
diff --git a/winsup/utils/chattr.c b/winsup/utils/chattr.c
index 4b074133cf6f..4ba977112d94 100644
--- a/winsup/utils/chattr.c
+++ b/winsup/utils/chattr.c
@@ -53,10 +53,12 @@ struct
   { FS_OFFLINE_FL,	'o',	NULL },
   { FS_NOTINDEXED_FL,	'n',	"Notindexed" },
   { FS_ENCRYPT_FL,	'e',	"Encrypted" },
+  { FS_PINNED_FL,	'p',	"Pinned" },
+  { FS_UNPINNED_FL,	'u',	"Unpinned" },
   { FS_CASESENS_FL,	'C',	"Casesensitive" },
   { 0,			'\0',	NULL },
 };
-const char *supp_list = "rhsatSrconeC";
+const char *supp_list = "rhsatSrconepuC";
 
 void
 print_flags (uint64_t flags)
@@ -245,7 +247,7 @@ usage (FILE *stream)
       "  -H, --help          this help text\n"
       "  -v, --version       display the program version\n"
       "\n"
-      "The format of 'mode' is {+-=}[acCehnrsSt]\n"
+      "The format of 'mode' is {+-=}[acCehnprsStu]\n"
       "\n"
       "The operator '+' causes the selected attributes to be added to the\n"
       "existing attributes of the files; '-' causes them to be removed; and\n"
@@ -264,6 +266,8 @@ usage (FILE *stream)
       "  'n', 'Notindexed':    file or directory is not to be indexed by the\n"
       "                        content indexing service\n"
       "  'e', 'Encrypted':     file is encrypted\n"
+      "  'p', 'Pinned':        file is pinned\n"
+      "  'u', 'Unpinned':      file is unpinned\n"
       "  'C', 'Casesensitive': directory is handled case sensitive\n");
   exit (stream == stdout ? 0 : 1);
 }
diff --git a/winsup/utils/lsattr.c b/winsup/utils/lsattr.c
index 70022803d068..50935f682ea5 100644
--- a/winsup/utils/lsattr.c
+++ b/winsup/utils/lsattr.c
@@ -53,6 +53,8 @@ struct
   { FS_OFFLINE_FL,	'o',	"Offline" },
   { FS_NOTINDEXED_FL,	'n',	"Notindexed" },
   { FS_ENCRYPT_FL,	'e',	"Encrypted" },
+  { FS_PINNED_FL,	'p',	"Pinned" },
+  { FS_UNPINNED_FL,	'u',	"Unpinned" },
   { FS_CASESENS_FL,	'C',	"Casesensitive" },
   { 0,			'\0',	NULL },
 };
@@ -218,6 +220,8 @@ usage (FILE *stream)
       "  'n', 'Notindexed':    file or directory is not to be indexed by the\n"
       "                        content indexing service\n"
       "  'e', 'Encrypted':     file is encrypted\n"
+      "  'p', 'Pinned':        file is pinned\n"
+      "  'u', 'Unpinned':      file is unpinned\n"
       "  'C', 'Casesensitive': directory is handled case sensitive\n"
       "                        (Windows 10 1803 or later, local NTFS only,\n"
       "                         WSL must be installed)\n");
@@ -284,7 +288,7 @@ main (int argc, char **argv)
 	    ret = 1;
 	}
       else if (lsattr (argv[optind]))
-      	ret = 1;
+	ret = 1;
     }
   return ret;
 }

                 reply	other threads:[~2024-03-08 20:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240308205832.369743858D33@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).