Skip to content

csplit: seq 10 | csplit - 1 silently ignores EIO (tests/csplit/csplit-io-err.sh?) #9853

Description

@oech3

As similar with #9832 ,

$ run0 dmsetup create ioerr --table "0 8 error"
$ chmod 777 /dev/mapper/ioerr
$ ln -sf /dev/mapper/ioerr xx01
$ seq 10 | uu-csplit - 1 # success
$ file xx01
xx01: symbolic link to /dev/mapper/ioerr
$ seq 10 | gnu-csplit - 1
0
csplit: write error for 'xx01': Input/output error
$ file xx01
xx01: cannot open `xx01' (No such file or directory)

Activity

  1. oech3 commented on Dec 26, 2025

    @oech3
    ContributorAuthor

    It seems this is not csplit-io-err.sh too. @ChrisDryden Can you remove LD_PRELOAD?

  2. ChrisDryden commented on Dec 26, 2025

    @ChrisDryden
    Collaborator

    Are you saying to rewrite the test to not use LD_PRELOAD? From initial investigation I think the easier adapting is to have a wrapper for fwrite. I have modified the test to work with write but it appears there is still an underlying issue that needs to be fixed.

  3. oech3 commented on Dec 26, 2025

    @oech3
    ContributorAuthor
  4. ChrisDryden commented on Dec 26, 2025

    @ChrisDryden
    Collaborator

    I'll see if they're open to the idea of changing that test to be a symlink to /dev/full since that would give the error code. Have you gone through the process of proposing changing the tests, I have an example new test that would cover the same cases but I'm not familiar with how open they are to update the tests?

  5. ChrisDryden commented on Dec 26, 2025

    @ChrisDryden
    Collaborator
      #!/bin/sh
      # Ensure we handle i/o errors correctly in csplit
    
      # Copyright (C) 2015-2025 Free Software Foundation, Inc.
    
      # This program is free software: you can redistribute it and/or modify
      # it under the terms of the GNU General Public License as published by
      # the Free Software Foundation, either version 3 of the License, or
      # (at your option) any later version.
    
      # This program is distributed in the hope that it will be useful,
      # but WITHOUT ANY WARRANTY; without even the implied warranty of
      # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      # GNU General Public License for more details.
    
      # You should have received a copy of the GNU General Public License
      # along with this program.  If not, see <https://www.gnu.org/licenses/>.
    
      . "${srcdir=.}/tests/init.sh";
      print_ver_ csplit
    
      if ! test -w /dev/full || ! test -c /dev/full; then
        skip_ '/dev/full is required'
      fi
    
      # Ensure error messages are in English
      LC_ALL=C
      export LC_ALL
    
      # Get the wording of the OS-dependent ENOSPC message
      returns_ 1 seq 1 >/dev/full 2>msgt || framework_failure_
      sed 's/seq: write error: //' msgt > msg || framework_failure_
    
      # Create the expected error message
      { printf "%s" "csplit: write error for 'xx01': " ; cat msg ; } > exp \
        || framework_failure_
    
      # Create symlink so xx01 writes to /dev/full (triggers ENOSPC)
      ln -s /dev/full xx01 || framework_failure_
    
      # Split the input - xx00 succeeds (empty), xx01 fails
      # the 'csplit' command should fail with exit code 1
      seq 10 | returns_ 1 csplit - 1 4 2>out || fail=1
    
      # Ensure we got the expected error message
      compare exp out || fail=1
    
      Exit $fail
    
  6. oech3 commented on Dec 26, 2025

    @oech3
    ContributorAuthor

    I think csplit: write error for 'xx01' is difficult to repro by symlink.

  7. oech3 commented on Dec 26, 2025

    @oech3
    ContributorAuthor
  8. ChrisDryden commented on Dec 26, 2025

    @ChrisDryden
    Collaborator

    I think its only because we have an issue with our implementation, let me publish my draft branch and it works with the symlink test too

  9. oech3 commented on Dec 26, 2025

    @oech3
    ContributorAuthor
  10. ChrisDryden commented on Dec 26, 2025

    @ChrisDryden
    Collaborator

    I think #9855 addresses that? Let me create the commands you can run to validate that this matches the gnu implementation

  11. oech3 commented on Jan 1, 2026

    @oech3
    ContributorAuthor

    Fixed. Thankyou. It would be nice to use the word "Fixes ISSUE_TAG" at next PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions