Commit b962e731 authored by Brian Rogers's avatar Brian Rogers Committed by Eric Paris

inotify: do not send a block of zeros when no pathname is available

When an event has no pathname, there's no need to pad it with a null byte and
therefore generate an inotify_event sized block of zeros. This fixes a
regression introduced by commit 0db501bd where
my system wouldn't finish booting because some process was being confused by
this.
Signed-off-by: default avatarBrian Rogers <brian@xyzw.org>
Signed-off-by: default avatarEric Paris <eparis@redhat.com>
parent 326ba501
...@@ -180,7 +180,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group, ...@@ -180,7 +180,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
struct fsnotify_event_private_data *fsn_priv; struct fsnotify_event_private_data *fsn_priv;
struct inotify_event_private_data *priv; struct inotify_event_private_data *priv;
size_t event_size = sizeof(struct inotify_event); size_t event_size = sizeof(struct inotify_event);
size_t name_len; size_t name_len = 0;
/* we get the inotify watch descriptor from the event private data */ /* we get the inotify watch descriptor from the event private data */
spin_lock(&event->lock); spin_lock(&event->lock);
...@@ -196,9 +196,11 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group, ...@@ -196,9 +196,11 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
inotify_free_event_priv(fsn_priv); inotify_free_event_priv(fsn_priv);
} }
/* round up event->name_len so it is a multiple of event_size /*
* round up event->name_len so it is a multiple of event_size
* plus an extra byte for the terminating '\0'. * plus an extra byte for the terminating '\0'.
*/ */
if (event->name_len)
name_len = roundup(event->name_len + 1, event_size); name_len = roundup(event->name_len + 1, event_size);
inotify_event.len = name_len; inotify_event.len = name_len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment