Skip to content

Commit 6ad1aad

Browse files
amir73iljankara
authored andcommitted
fanotify: distinguish between fid encode error and null fid
In fanotify_encode_fh(), both cases of NULL inode and failure to encode ended up with fh type FILEID_INVALID. Distiguish the case of NULL inode, by setting fh type to FILEID_ROOT. This is just a semantic difference at this point. Remove stale comment and unneeded check from fid event compare helpers. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Amir Goldstein <[email protected]> Signed-off-by: Jan Kara <[email protected]>
1 parent 103ff6a commit 6ad1aad

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

fs/notify/fanotify/fanotify.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ static bool fanotify_fh_equal(struct fanotify_fh *fh1,
3434
if (fh1->type != fh2->type || fh1->len != fh2->len)
3535
return false;
3636

37-
/* Do not merge events if we failed to encode fh */
38-
if (fh1->type == FILEID_INVALID)
39-
return false;
40-
4137
return !fh1->len ||
4238
!memcmp(fanotify_fh_buf(fh1), fanotify_fh_buf(fh2), fh1->len);
4339
}
@@ -56,10 +52,7 @@ static bool fanotify_fid_event_equal(struct fanotify_fid_event *ffe1,
5652
static bool fanotify_name_event_equal(struct fanotify_name_event *fne1,
5753
struct fanotify_name_event *fne2)
5854
{
59-
/*
60-
* Do not merge name events without dir fh.
61-
* FAN_DIR_MODIFY does not encode object fh, so it may be empty.
62-
*/
55+
/* Do not merge name events without dir fh */
6356
if (!fne1->dir_fh.len)
6457
return false;
6558

@@ -290,8 +283,10 @@ static void fanotify_encode_fh(struct fanotify_fh *fh, struct inode *inode,
290283
void *buf = fh->buf;
291284
int err;
292285

286+
fh->type = FILEID_ROOT;
287+
fh->len = 0;
293288
if (!inode)
294-
goto out;
289+
return;
295290

296291
dwords = 0;
297292
err = -ENOENT;
@@ -326,7 +321,6 @@ static void fanotify_encode_fh(struct fanotify_fh *fh, struct inode *inode,
326321
type, bytes, err);
327322
kfree(ext_buf);
328323
*fanotify_fh_ext_buf_ptr(fh) = NULL;
329-
out:
330324
/* Report the event without a file identifier on encode error */
331325
fh->type = FILEID_INVALID;
332326
fh->len = 0;

0 commit comments

Comments
 (0)