On Wednesday, 12 July 2017 18:39:49 CEST Richard W.M. Jones wrote:
The ext2 filesystem on disk format has two ways to store symlinks.
For symlinks >= 60 bytes in length, they are stored as files
(so-called "slow symlinks"). For shorter symlinks the symlink is
stored in the inode ("fast symlinks").
Previously we only created slow symlinks even if there are shorter
than 60 bytes. This didn't matter until recently, when a change went
upstream which assumes that symlinks shorter than 60 bytes are always
stored in the inode, thus breaking the filesystems that we created
before:
https://bugzilla.redhat.com/show_bug.cgi?id=1470157#c4
This changes the code to use the ext2fs_symlink function instead which
creates fast and slow symlinks properly.
This fix is required if you use supermin with any Linux kernel >= 4.13.
The actual fix is two lines replacing ext2_write_file with a simpler
call to ext2fs_symlink. The majority of this fix is removing the
ext2_write_file function which is no longer referenced after that
change.
Thanks: Eric Sandeen
---
Mostly LGTM, there's one thing to fix.
@@ -833,7 +792,8 @@ ext2_copy_file (struct ext2_data *data, const
char *src, const char *dest)
ssize_t r = readlink (src, buf, sizeof buf);
if (r == -1)
unix_error (errno, (char *) "readlink", caml_copy_string (src));
- ext2_write_file (data->fs, ino, buf, r, dest);
+ buf[r] = '\0';
+ ext2fs_symlink (data->fs, dir_ino, ino, dest, buf);
Since now we write a trailing zero to 'buf', then the size passed to
the readlink() above must be sizeof(buf)-1, otherwise we truncate the
last character in the rare case the symlink target is long as much as
the buffer passed. And theoretically a target could be longer than the
arbitrary PATH_MAX, but that's material for a separate change...
--
Pino Toscano