directory-handle: query if instance is backed by a file descriptor
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 29 Jan 2020 04:39:01 +0000 (23:39 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 30 Jan 2020 06:55:34 +0000 (01:55 -0500)
Allow a user of a directory handle to know if a given instance is
backed by a file descriptor. This is needed to ensure the fd-tracker
can accurately track the number of file descriptors in use at a given
moment.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I64aeeae2623a35ed07964432bb18b16aeeeb89ec

src/common/compat/directory-handle.c
src/common/compat/directory-handle.h

index 9548da216298ff23980e5e84dcf8cc24975c5608..729f69cb9ca41060cd4503f6fc70338a10ffe4bc 100644 (file)
@@ -248,6 +248,13 @@ int lttng_directory_handle_stat(const struct lttng_directory_handle *handle,
        return fstatat(handle->dirfd, path, st, 0);
 }
 
+LTTNG_HIDDEN
+bool lttng_directory_handle_uses_fd(
+               const struct lttng_directory_handle *handle)
+{
+       return handle->dirfd != AT_FDCWD;
+}
+
 static
 int lttng_directory_handle_mkdir(
                const struct lttng_directory_handle *handle,
@@ -617,6 +624,13 @@ end:
        return ret;
 }
 
+LTTNG_HIDDEN
+bool lttng_directory_handle_uses_fd(
+               const struct lttng_directory_handle *handle)
+{
+       return false;
+}
+
 static
 int lttng_directory_handle_mkdir(const struct lttng_directory_handle *handle,
                const char *subdirectory, mode_t mode)
index 551fa50b439b84c85cc6d2bfa667943836973454..b6ee8b3846fdc7a70a77f19c295ab49b23bd3555 100644 (file)
@@ -267,6 +267,14 @@ int lttng_directory_handle_stat(
                const char *name,
                struct stat *stat_buf);
 
+/*
+ * Returns true if this directory handle is backed by a file
+ * descriptor, false otherwise.
+ */
+LTTNG_HIDDEN
+bool lttng_directory_handle_uses_fd(
+               const struct lttng_directory_handle *handle);
+
 /*
  * Compare two directory handles.
  *
This page took 0.035351 seconds and 4 git commands to generate.