#define _LTTNG_WRAPPER_FDTABLE_H
#include <lttng/kernel-version.h>
+#include <linux/file.h>
#include <linux/fdtable.h>
#include <linux/sched.h>
-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,7,0))
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,13,0))
+static inline
+struct file *lttng_lookup_fdget_rcu(unsigned int fd)
+{
+ return fget_raw(fd);
+}
+#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,7,0))
static inline
struct file *lttng_lookup_fdget_rcu(unsigned int fd)
{
return file_ref_get(&file->f_ref);
}
-static inline
+static inline __must_check
bool lttng_file_ref_put(struct file *file)
{
- /* This is __must_check */
return file_ref_put(&file->f_ref);
}
return true;
}
-static inline
+static inline __must_check
bool lttng_file_ref_put(struct file *file)
{
atomic_long_dec(&file->f_count);
return chan_fd;
chan_error:
- lttng_file_ref_put(session_file);
+ if (!lttng_file_ref_put(session_file)) {
+ ret = -EINVAL;
+ }
refcount_error:
fput(chan_file);
file_error:
return ret;
fd_error:
- lttng_file_ref_put(notif_file);
+ if (!lttng_file_ref_put(notif_file)) {
+ /* Don't change return code */
+ }
refcount_error:
event_notifier_group->ops->priv->buffer_read_close(buf);
return ret;
return event_fd;
event_error:
- lttng_file_ref_put(channel_file);
+ if (!lttng_file_ref_put(channel_file)) {
+ ret = -EINVAL;
+ }
refcount_error:
fput(event_file);
file_error:
return event_fd;
event_error:
- lttng_file_ref_put(channel_file);
+ if (!lttng_file_ref_put(channel_file)) {
+ /* Don't change return code */
+ }
refcount_error:
fput(event_file);
file_error:
return event_notifier_fd;
event_notifier_error:
- lttng_file_ref_put(event_notifier_group_file);
+ if (!lttng_file_ref_put(event_notifier_group_file)) {
+ /* Don't change return code */
+ }
refcount_error:
fput(event_notifier_file);
file_error:
return counter_fd;
create_error:
- lttng_file_ref_put(session->priv->file);
+ if (!lttng_file_ref_put(session->priv->file)) {
+ /* Don't change return code */
+ }
refcount_error:
fput(counter_file);
file_error:
return counter_fd;
create_error:
- lttng_file_ref_put(event_notifier_group_file);
+ if (!lttng_file_ref_put(event_notifier_group_file)) {
+ /* Don't change return code */
+ }
refcount_error:
fput(counter_file);
file_error: