From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v4 1/6] API: Add safe openat, printfat, readat and unlinkat
Date: Wed, 28 Apr 2021 19:48:23 +0200 [thread overview]
Message-ID: <YImf5zpy71k1sKqM@pevik> (raw)
In-Reply-To: <20210428142719.8065-2-rpalethorpe@suse.com>
Hi Richie,
> Add 'at' variants for a number of system calls and LTP SAFE API
> functions. This avoids using sprintf everywhere to build paths.
> diff --git a/lib/tst_safe_file_at.c b/lib/tst_safe_file_at.c
> new file mode 100644
> index 000000000..a92a48fb2
> --- /dev/null
> +++ b/lib/tst_safe_file_at.c
> @@ -0,0 +1,170 @@
> +#define _GNU_SOURCE
> +#include "lapi/fcntl.h"
> +#include "tst_safe_file_at.h"
This requires <stdio.h> (sprintf).
Also file should have SPDX license + copyright.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
> +#define TST_NO_DEFAULT_MAIN
> +#include "tst_test.h"
> +
> +char fd_path[PATH_MAX];
> +
> +char *tst_decode_fd(int fd)
> +{
> + ssize_t ret;
> + char proc_path[32];
> +
> + if (fd < 0)
> + return "!";
> +
> + sprintf(proc_path, "/proc/self/fd/%d", fd);
> + ret = readlink(proc_path, fd_path, sizeof(fd_path));
...
next prev parent reply other threads:[~2021-04-28 17:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-28 14:27 [LTP] [PATCH v4 0/6] CGroup API rewrite Richard Palethorpe
2021-04-28 14:27 ` [LTP] [PATCH v4 1/6] API: Add safe openat, printfat, readat and unlinkat Richard Palethorpe
2021-04-28 17:48 ` Petr Vorel [this message]
2021-04-28 14:27 ` [LTP] [PATCH v4 2/6] Add new CGroups APIs Richard Palethorpe
2021-04-29 15:13 ` Cyril Hrubis
2021-04-28 14:27 ` [LTP] [PATCH v4 3/6] Add new CGroups API library tests Richard Palethorpe
2021-04-28 14:27 ` [LTP] [PATCH v4 4/6] docs: Update CGroups API Richard Palethorpe
2021-04-28 14:27 ` [LTP] [PATCH v4 5/6] mem: Convert tests to new " Richard Palethorpe
2021-04-28 14:27 ` [LTP] [PATCH v4 6/6] madvise06: Convert " Richard Palethorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YImf5zpy71k1sKqM@pevik \
--to=pvorel@suse.cz \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.