mirror_zfs/cmd
наб 510ee280c0 Remove enable_extended_FILE_stdio()
Even on Illumos it's only available in the 32-bit programming
environment, and, quoth enable_extended_FILE_stdio(3C):
> Historically, 32-bit Solaris applications have been limited to using
> only the file descriptors 0 through 255 with the standard I/O
> functions (see stdio(3C)) in the C library. The extended FILE
> facility allows well-behaved 32-bit applications to use any
> valid file descriptor with the standard I/O functions.
where "well-behaved" means that it
> does not directly access any fields in the FILE structure pointed
> to by the FILE pointer associated with any standard I/O stream,

And the stdio/flush.c implementation reads:
  /*
   * if this is not an internal extended FILE then check
   * if _file is being changed from underneath us.
   * It should not be because if
   * it is then then we lose our ability to guard against
   * silent data corruption.
   */
  if (!iop->__xf_nocheck && bad_fd > -1 && iop->_magic != bad_fd) {
      (void) fprintf(stderr,
          "Application violated extended FILE safety mechanism.\n"
          "Please read the man page for extendedFILE.\nAborting\n");
      abort();
  }

This appears to be an insane workaround for broken implementation with
exposed FILE internals and _file being an u8, both only on non-LP64;
it's shimmed out on all LP64 targets in Illumos,
and we shim it out as well: just get rid of it

This appears to've been originally fixed in illumos-gate
a5f69788de7ac07553de47f7fec8c05a9a94c105 ("PSARC 2006/162 Extended FILE
space for 32-bit Solaris processes", "1085341 32-bit stdio routines
should support file descriptors >255"), which also bears extendedFILE
and enable_extended_FILE_stdio(3C):
  -       unsigned char   _file;  /* UNIX System file descriptor */
  +       unsigned char   _magic; /* Old home of the file descriptor */
  +                               /* Only fileno(3C) can retrieve the
  				value now */
and
  +/*
  + * Macros to aid the extended fd FILE work.
  + * This helps isolate the changes to only the 32-bit code
  + * since 64-bit Solaris is not affected by this.
  + */
  +#ifdef  _LP64
  +#define        GET_FD(iop)             ((iop)->_file)
  +#define        SET_FILE(iop, fd)       ((iop)->_file = (fd))
  +#else
  +#define        GET_FD(iop)             \
  +               (((iop)->__extendedfd) ? _file_get(iop) : (iop)->_magic)
  +#define        SET_FILE(iop, fd)       (iop)->_magic = (fd); (iop)->__extendedfd = 0
  +#endif

Also remove the 1k setrlimit(NOFILE) calls: that's the default on Linux,
with 64k on Illumos and 171k on FreeBSD

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13411
2022-05-11 10:33:12 -07:00
..
raidz_test autoconf: use include directives instead of recursing down cmd 2022-05-10 10:18:38 -07:00
zdb Remove enable_extended_FILE_stdio() 2022-05-11 10:33:12 -07:00
zed autoconf: use include directives instead of recursing down cmd 2022-05-10 10:18:38 -07:00
zfs autoconf: use include directives instead of recursing down cmd 2022-05-10 10:18:38 -07:00
zinject autoconf: use include directives instead of recursing down cmd 2022-05-10 10:18:38 -07:00
zpool autoconf: use include directives instead of recursing down cmd 2022-05-10 10:18:38 -07:00
zpool_influxdb autoconf: use include directives instead of recursing down cmd 2022-05-10 10:18:38 -07:00
zstream autoconf: use include directives instead of recursing down cmd 2022-05-10 10:18:38 -07:00
arc_summary cmd: move single-file binaries up, extract udev programs to udev/ 2022-05-10 10:20:34 -07:00
arcstat.in cmd: move single-file binaries up, extract udev programs to udev/ 2022-05-10 10:20:34 -07:00
dbufstat.in cmd: move single-file binaries up, extract udev programs to udev/ 2022-05-10 10:20:34 -07:00
fsck.zfs.in cmd: move single-file binaries up, extract udev programs to udev/ 2022-05-10 10:20:34 -07:00
Makefile.am cmd: move single-file binaries up, extract udev programs to udev/ 2022-05-10 10:20:34 -07:00
mount_zfs.c cmd: move single-file binaries up, extract udev programs to udev/ 2022-05-10 10:20:34 -07:00
zfs_ids_to_path.c cmd: move single-file binaries up, extract udev programs to udev/ 2022-05-10 10:20:34 -07:00
zgenhostid.c cmd: move single-file binaries up, extract udev programs to udev/ 2022-05-10 10:20:34 -07:00
zhack.c cmd: move single-file binaries up, extract udev programs to udev/ 2022-05-10 10:20:34 -07:00
ztest.c Remove enable_extended_FILE_stdio() 2022-05-11 10:33:12 -07:00
zvol_wait cmd: move single-file binaries up, extract udev programs to udev/ 2022-05-10 10:20:34 -07:00