From: Mathieu Desnoyers Date: Fri, 26 Nov 2010 01:52:52 +0000 (-0500) Subject: Handle release of parent files X-Git-Tag: v2.0-pre1~210 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=0a84a57fc9409a29d63b0dec930a56da4a0a743c;p=lttng-modules.git Handle release of parent files Signed-off-by: Mathieu Desnoyers --- diff --git a/ltt-debugfs-abi.c b/ltt-debugfs-abi.c index d08459c0..4717b81e 100644 --- a/ltt-debugfs-abi.c +++ b/ltt-debugfs-abi.c @@ -75,6 +75,7 @@ int lttng_abi_create_session(void) ret = PTR_ERR(session_filp); goto file_error; } + session->file = session_filp; fd_install(session_fd, session_filp); return session_fd; @@ -153,6 +154,7 @@ int lttng_abi_create_channel(struct file *session_filp, ret = -ENOMEM; goto chan_error; } + channel->file = chan_filp; chan_filp->private_data = chan; fd_install(chan_fd, chan_filp); /* The channel created holds a reference on the session */ @@ -363,6 +365,14 @@ unsigned int lttng_channel_poll(struct file *filp, poll_table *wait) } +static +int lttng_channel_release(struct inode *inode, struct file *file) +{ + struct ltt_channel *channel = file->private_data; + fput(channel->session->file); + return 0; +} + static const struct file_operations lttng_channel_fops = { .release = lttng_channel_release, .poll = lttng_channel_poll, @@ -372,6 +382,18 @@ static const struct file_operations lttng_channel_fops = { #endif } +static +int lttng_event_release(struct inode *inode, struct file *file) +{ + struct ltt_event *event = file->private_data; + fput(event->chan->file); + return 0; +} + +static const struct file_operations lttng_event_fops = { + .release = lttng_event_release, +} + static int __init ltt_debugfs_abi_init(void) { int ret = 0;