From 0a84a57fc9409a29d63b0dec930a56da4a0a743c Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 25 Nov 2010 20:52:52 -0500 Subject: [PATCH] Handle release of parent files Signed-off-by: Mathieu Desnoyers --- ltt-debugfs-abi.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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; -- 2.34.1