From bf9cb250edf776454d0600b4341c6667974bedb8 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Wed, 12 Oct 2022 16:12:27 -0400 Subject: [PATCH] bcachefs: Don't allow hardlinks when inherited attrs would change This is the right thing to do, and conforms with our own behaviour on rename and xfs's behaviour on hardlink. Signed-off-by: Kent Overstreet --- fs/bcachefs/fs-common.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/bcachefs/fs-common.c b/fs/bcachefs/fs-common.c index 53ffc684223c..e9dd1d13ec7e 100644 --- a/fs/bcachefs/fs-common.c +++ b/fs/bcachefs/fs-common.c @@ -212,6 +212,11 @@ int bch2_link_trans(struct btree_trans *trans, if (ret) goto err; + if (bch2_reinherit_attrs(inode_u, dir_u)) { + ret = -EXDEV; + goto err; + } + dir_u->bi_mtime = dir_u->bi_ctime = now; dir_hash = bch2_hash_info_init(c, dir_u); -- 2.25.1