diff mbox series

misc: Turn generic chflags, fchflags into compat symbols

Message ID 87pnbtxiqv.fsf@mid.deneb.enyo.de
State New
Headers show
Series misc: Turn generic chflags, fchflags into compat symbols | expand

Commit Message

Florian Weimer April 27, 2020, 11:36 a.m. UTC
Hurd has implementations for these functions, but no defined flags
(“The file_chflags RPC changes the flags of the file. It should be
legitimate to change the flags to any value without restriction.
No standard meanings have been assigned to the flags yet, but we
intend to do so.”).  The hurd version still overrides the generic
version and provides a non-compat definition.

Alpha has osf_cfhlags, osf_fchflags system calls, but they are not
implemented on Linux.

-----
 misc/chflags.c                 | 20 +++++---------------
 misc/fchflags.c                | 20 +++++---------------
 sysdeps/unix/bsd/syscalls.list |  2 --
 3 files changed, 10 insertions(+), 32 deletions(-)

Comments

Zack Weinberg April 27, 2020, 12:39 p.m. UTC | #1
On Mon, Apr 27, 2020 at 7:37 AM Florian Weimer <fw@deneb.enyo.de> wrote:
>
> Hurd has implementations for these functions, but no defined flags
> (“The file_chflags RPC changes the flags of the file. It should be
> legitimate to change the flags to any value without restriction.
> No standard meanings have been assigned to the flags yet, but we
> intend to do so.”).  The hurd version still overrides the generic
> version and provides a non-compat definition.

It might be worth mentioning in the commit message that these
functions are declared as public APIs in the Hurd bits/stat.h but
nowhere else.

Otherwise LGTM.

zw
Florian Weimer April 28, 2020, 10:37 a.m. UTC | #2
* Zack Weinberg:

> On Mon, Apr 27, 2020 at 7:37 AM Florian Weimer <fw@deneb.enyo.de> wrote:
>>
>> Hurd has implementations for these functions, but no defined flags
>> (“The file_chflags RPC changes the flags of the file. It should be
>> legitimate to change the flags to any value without restriction.
>> No standard meanings have been assigned to the flags yet, but we
>> intend to do so.”).  The hurd version still overrides the generic
>> version and provides a non-compat definition.
>
> It might be worth mentioning in the commit message that these
> functions are declared as public APIs in the Hurd bits/stat.h but
> nowhere else.
>
> Otherwise LGTM.

Thanks.  New version below, also with a NEWS update.

8<------------------------------------------------------------------8<
On Linux, the functions always failed and were not declared in an installed
header file.

Hurd has implementations for these functions (declared in <bits/stat.h>),
but no defined flags (“The file_chflags RPC changes the flags of the file.
It should be legitimate to change the flags to any value without
restriction.  No standard meanings have been assigned to the flags yet,
but we intend to do so.”).  The hurd version still overrides the generic
version and provides a non-compat definition.

Alpha has osf_cfhlags, osf_fchflags system calls, but they are not
implemented on Linux.

-----
 NEWS                           |  4 ++++
 misc/chflags.c                 | 20 +++++---------------
 misc/fchflags.c                | 20 +++++---------------
 sysdeps/unix/bsd/syscalls.list |  2 --
 4 files changed, 14 insertions(+), 32 deletions(-)

diff --git a/NEWS b/NEWS
index f58436c91a..4029f2b5df 100644
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,10 @@ Deprecated and removed features, and other changes affecting compatibility:
   Its implementation always returned with a failure, and the function
   was not declared in any header file.
 
+* On Linux, the chflags and fchflags functions are no longer available
+  to newly linked binaries.  Their implementation always returned with a
+  failure, and the functions were not declared in any header file.
+
 Changes to build and runtime requirements:
 
   [Add changes to build and runtime requirements here]
diff --git a/misc/chflags.c b/misc/chflags.c
index c52cbe96ec..0953511a97 100644
--- a/misc/chflags.c
+++ b/misc/chflags.c
@@ -16,24 +16,14 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
-#include <stddef.h>
-#include <sys/stat.h>
+#include <shlib-compat.h>
 
-/* Change the flags of FILE to FLAGS.  */
-
-int chflags (const char *file, unsigned long int flags) __THROW;
-
-int
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_32)
+int attribute_compat_text_section
 chflags (const char *file, unsigned long int flags)
 {
-  if (file == NULL)
-    {
-      __set_errno (EINVAL);
-      return -1;
-    }
-
   __set_errno (ENOSYS);
   return -1;
 }
-
-stub_warning (chflags)
+compat_symbol (libc, chflags, chflags, GLIBC_2_0);
+#endif
diff --git a/misc/fchflags.c b/misc/fchflags.c
index 712687aae1..c18944ce1d 100644
--- a/misc/fchflags.c
+++ b/misc/fchflags.c
@@ -16,24 +16,14 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
-#include <stddef.h>
-#include <sys/stat.h>
+#include <shlib-compat.h>
 
-/* Change the flags of the file referenced by FD to FLAGS.  */
-
-int fchflags (int fd, unsigned long int flags) __THROW;
-
-int
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_32)
+int attribute_compat_text_section
 fchflags (int fd, unsigned long int flags)
 {
-  if (fd < 0)
-    {
-      __set_errno (EINVAL);
-      return -1;
-    }
-
   __set_errno (ENOSYS);
   return -1;
 }
-
-stub_warning (fchflags)
+compat_symbol (libc, fchflags, fchflags, GLIBC_2_0);
+#endif
diff --git a/sysdeps/unix/bsd/syscalls.list b/sysdeps/unix/bsd/syscalls.list
index 0b4d5fcd54..9660203ecc 100644
--- a/sysdeps/unix/bsd/syscalls.list
+++ b/sysdeps/unix/bsd/syscalls.list
@@ -1,7 +1,5 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
-chflags		-	chflags		2	chflags
-fchflags	-	fchflags	2	fchflags
 flock		-	flock		2	__flock		flock
 getdents	-	getdirentries	4	__getdirentries	getdirentries
 getdtsz		-	getdtablesize	0	__getdtablesize	getdtablesize
diff mbox series

Patch

diff --git a/misc/chflags.c b/misc/chflags.c
index c52cbe96ec..0953511a97 100644
--- a/misc/chflags.c
+++ b/misc/chflags.c
@@ -16,24 +16,14 @@ 
    <https://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
-#include <stddef.h>
-#include <sys/stat.h>
+#include <shlib-compat.h>
 
-/* Change the flags of FILE to FLAGS.  */
-
-int chflags (const char *file, unsigned long int flags) __THROW;
-
-int
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_32)
+int attribute_compat_text_section
 chflags (const char *file, unsigned long int flags)
 {
-  if (file == NULL)
-    {
-      __set_errno (EINVAL);
-      return -1;
-    }
-
   __set_errno (ENOSYS);
   return -1;
 }
-
-stub_warning (chflags)
+compat_symbol (libc, chflags, chflags, GLIBC_2_0);
+#endif
diff --git a/misc/fchflags.c b/misc/fchflags.c
index 712687aae1..c18944ce1d 100644
--- a/misc/fchflags.c
+++ b/misc/fchflags.c
@@ -16,24 +16,14 @@ 
    <https://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
-#include <stddef.h>
-#include <sys/stat.h>
+#include <shlib-compat.h>
 
-/* Change the flags of the file referenced by FD to FLAGS.  */
-
-int fchflags (int fd, unsigned long int flags) __THROW;
-
-int
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_32)
+int attribute_compat_text_section
 fchflags (int fd, unsigned long int flags)
 {
-  if (fd < 0)
-    {
-      __set_errno (EINVAL);
-      return -1;
-    }
-
   __set_errno (ENOSYS);
   return -1;
 }
-
-stub_warning (fchflags)
+compat_symbol (libc, fchflags, fchflags, GLIBC_2_0);
+#endif
diff --git a/sysdeps/unix/bsd/syscalls.list b/sysdeps/unix/bsd/syscalls.list
index 0b4d5fcd54..9660203ecc 100644
--- a/sysdeps/unix/bsd/syscalls.list
+++ b/sysdeps/unix/bsd/syscalls.list
@@ -1,7 +1,5 @@ 
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
-chflags		-	chflags		2	chflags
-fchflags	-	fchflags	2	fchflags
 flock		-	flock		2	__flock		flock
 getdents	-	getdirentries	4	__getdirentries	getdirentries
 getdtsz		-	getdtablesize	0	__getdtablesize	getdtablesize