From: David Oberhollenzer Date: Wed, 3 Apr 2019 10:54:16 +0000 (+0200) Subject: mkfs.ubifs: fix regression when trying to store device special files X-Git-Tag: v2.1.1~15 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2a26da4468197884d1381bffafe9161453863505;p=mtd-utils.git mkfs.ubifs: fix regression when trying to store device special files Commit a767dd30 added a check to add_inode that bails when trying to store extra data in anything other than a symlink. The symlink encryption support added by that commit relies on the assumption. Unfortionately it was overlooked that device special files also store the device number as additional data in the inode. The check added in commit a767dd30 broke support for device files in mkfs.ubifs. This commit adds a quick and dirty fix, moving the check into the fscrypt branch, breaking only the fscrypt version but restoring old functionality for unencrypted file systems. Signed-off-by: David Oberhollenzer --- diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c index e0c42f3..4b31979 100644 --- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c +++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c @@ -1531,12 +1531,13 @@ static int add_inode(struct stat *st, ino_t inum, void *data, ino->flags = cpu_to_le32(use_flags); ino->compr_type = cpu_to_le16(c->default_compr); if (data_len) { - if (!S_ISLNK(st->st_mode)) - return err_msg("Expected symlink"); - if (!fctx) { memcpy(&ino->data, data, data_len); } else { + /* TODO: what about device files? */ + if (!S_ISLNK(st->st_mode)) + return err_msg("Expected symlink"); + ret = encrypt_symlink(&ino->data, data, data_len, fctx); if (ret < 0) return ret;