On Sat, Sep 5, 2026 at 3:39 PM Pádraig Brady <[email protected]> wrote:
>
> On 05/09/2026 13:53, Daniel Hofstetter wrote:
> > Hi,
> >
> > I noticed that if I provide a folder as reference, a "file too large"
> > error is shown. If the specified file exists, no truncation happens.
> > Otherwise, an empty file is created. It's admittedly an edge case, so
> > I'm not sure what the expected behavior is.
> >
> > Here are the steps to reproduce:
> >
> > $ mkdir folder
> > $ truncate --reference=folder/ foobar
> > truncate: failed to truncate 'foobar' at 9223372036854775807 bytes:
> > File too large
> > $ echo $?
> > 1
> > $ ls -l foobar
> > -rw-r--r-- 1 dho dho 0 Sep  5 14:05 foobar
> >
> > I'm using coreutils 9.11.
> >
> > Context: I noticed it while working on uutils coreutils.
> >
> > Regards,
> > Daniel
>
> since the meaning of st_size is not defined for directories
> we use the fallback of lseek(..., SEEK_END).
>
> On your (file) system it's returning OFF_T_MAX.
> What file system are you using?
>
> On tmpfs lseek() returns EINVAL,
> on BTRFS it returns the same as st_size from stat.
>
> Perhaps we could prefer st_size for directories,
> but it is an edge case as there is no real meaning
> to the st_size of a directory.
>
> cheers,
> Padraig

I'm using ext4.

Regards,
Daniel



Reply via email to