iustin / pyxattr

A python module for accessing filesystem Extended Attributes
https://pyxattr.k1024.org/
GNU Lesser General Public License v2.1
30 stars 15 forks source link

Better error message when trying to write EAs too big for file system #23

Closed ericzolf closed 1 year ago

ericzolf commented 4 years ago

Hi,

we've got a bug reported which actually didn't have anything to do with a file system full, but most probably to too big EAs on ext4 (according to man 5 xattr it has a limit of 1, 2 or 4KB):

touch xxx
python3
>>> x = '0123456789' * 1024  # 10KB size
>>> import xattr
>>> xattr.setxattr('xxx', 'user.comment', x)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 28] No space left on device

The error message should be more helpful, something like "extended attribute too big for file system limit".

iustin commented 4 years ago

Hmm, interesting. Note that this is the error message coming from the operating system, I'm not processing it in any way.

The man page for the setxattr function mentions both ENOSPC: There is insufficient space remaining to store the extended attribute., and ERANGE: The size of name or value exceeds a filesystem-specific limit.. I would expect the latter (ERANGE) to be returned here, not ENOSPC. I wonder if this can be improved in the ext4 driver?

I did not think about failure modes here, I'll follow-up to see how this fails with various file systems.

joachimmetz commented 3 years ago

FYI per https://ext4.wiki.kernel.org/index.php/Ext4_Disk_Layout#Extended_Attributes

If the disk block fills up, the filesystem returns -ENOSPC.

So ENOSPC corresponds with the documentation

ericzolf commented 3 years ago

That makes it indeed difficult to address properly. Sad, but I wouldn't mind if you chose the issue.

iustin commented 1 year ago

Will close indeed since the problem is upstream.