Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,32 @@ jobs:
run: |
make static

build-musl:
name: musl libc build on Debian
runs-on: ubuntu-latest
container:
image: ghcr.io/linux-nvme/debian:latest
steps:
- uses: actions/checkout@v5
- name: Mark repo as safe for git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: build
run: |
CC=musl-gcc scripts/build.sh musl

build-alpine:
name: musl libc build on Alpine
runs-on: ubuntu-latest
container:
image: ghcr.io/linux-nvme/alpine:next
steps:
- uses: actions/checkout@v5
- name: Mark repo as safe for git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: build
run: |
scripts/build.sh musl

build-distro:
name: build libnvme and nvme-cli separately
runs-on: ubuntu-latest
Expand Down
6 changes: 1 addition & 5 deletions libnvme/src/nvme/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,11 @@ static int __nvme_transport_handle_open_direct(
{
struct nvme_passthru_cmd dummy = { 0 };
_cleanup_free_ char *path = NULL;
_cleanup_free_ char *_devname = NULL;
char *name;
int ret, id, ns;
bool c = true;

_devname = strdup(devname);
if (!_devname)
return -ENOMEM;
name = basename(_devname);
name = nvme_basename(devname);

hdl->type = NVME_TRANSPORT_HANDLE_TYPE_DIRECT;

Expand Down
4 changes: 4 additions & 0 deletions libnvme/src/nvme/linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
#include <string.h>
#include <errno.h>

#ifndef _GNU_SOURCE
#include <libgen.h>
#endif

#include <sys/param.h>
#include <sys/stat.h>
#include <fcntl.h>
Expand Down
9 changes: 9 additions & 0 deletions libnvme/src/nvme/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,3 +981,12 @@

return ctx->ifaddrs_cache;
}

/* This used instead of basename() due to behavioral differences between
* the POSIX and the GNU version. This is the glibc implementation.
* Original source: https://github.com/bminor/glibc/blob/master/string/basename.c */

Check failure on line 987 in libnvme/src/nvme/util.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: Block comments use a trailing */ on a separate line
char *nvme_basename(const char *path)
{
char *p = (char *) strrchr(path, '/');
return p ? p + 1 : (char *) path;

Check failure on line 991 in libnvme/src/nvme/util.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: Missing a blank line after declarations
Comment thread
MichaelRabek marked this conversation as resolved.
}
7 changes: 7 additions & 0 deletions libnvme/src/nvme/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,10 @@ int nvme_uuid_random(unsigned char uuid[NVME_UUID_LEN]);
*/
int nvme_uuid_find(struct nvme_id_uuid_list *uuid_list, const unsigned char uuid[NVME_UUID_LEN]);

/**
* nvme_basename - Return the final path component (the one after the last '/')
* @path: A string containing a filesystem path
*
* Return: A pointer into the original null-terminated path string.
*/
char *nvme_basename(const char *path);
5 changes: 4 additions & 1 deletion libnvme/test/ioctl/mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,12 @@
real_ioctl = dlsym(RTLD_NEXT, "ioctl");
if (!real_ioctl)
fail("Error: dlsym failed to find original ioctl\n");
#else
#elif defined(HAVE_GLIBC_IOCTL) && HAVE_GLIBC_IOCTL == 1
fprintf(stderr, "Warning: unhandled ioctl %lx\n", request);
return -ENOTTY;
#else
fprintf(stderr, "Warning: unhandled ioctl %x\n", request);

Check failure on line 164 in libnvme/test/ioctl/mock.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: Prefer using '"%s...", __func__' to using 'ioctl', this function's name, in a string
return -ENOTTY;
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion libnvme/test/nbft/nbft-dump-diff.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ if [ $# -ne 2 ]; then
exit 255
fi

"@NBFT_DUMP_PATH@" "$1" | diff --unified "$2" -
"@NBFT_DUMP_PATH@" "$1" | diff -u "$2" -
17 changes: 17 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,23 @@ config_meson_default() {
"${BUILDDIR}"
}

config_meson_musl() {
local c_args="-U_GNU_SOURCE \
-idirafter /usr/include -idirafter \
/usr/include/x86_64-linux-gnu"

CC="${CC}" "${MESON}" setup \
--werror \
--buildtype="${BUILDTYPE}" \
-Dc_args="${c_args}" \
-Ddefault_library=static \
-Djson-c=disabled \
-Dopenssl=disabled \
-Dkeyutils=disabled \
-Dpython=disabled \
"${BUILDDIR}"
Comment thread
MichaelRabek marked this conversation as resolved.
}

config_meson_libdbus() {
CC="${CC}" "${MESON}" setup \
--werror \
Expand Down
20 changes: 17 additions & 3 deletions unit/test-uint128.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,30 @@
void tostr_test(struct tostr_test *test)
{
char *str;
const char *exp = test->exp;

if (!setlocale(LC_NUMERIC, test->locale))
return;

if (test->locale)
if (test->locale) {
/* For locale tests, adapt to what the system provides.
* musl libc may not support thousands_sep for all locales. */

Check failure on line 59 in unit/test-uint128.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: Block comments use a trailing */ on a separate line
struct lconv *lc = localeconv();
const char *sep = lc->thousands_sep;

if (!sep || !*sep) {
/* No separator available, skip test */
fprintf(stderr, "WARNING: thousands_sep is empty for "
"this system's %s locale! Skipping test...\n",

Check failure on line 66 in unit/test-uint128.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: quoted string split across lines
test->locale);
return;
}
str = uint128_t_to_l10n_string(test->val);
else
} else {
str = uint128_t_to_string(test->val);
}

check_str(test->val, test->exp, str);
check_str(test->val, exp, str);
}

int main(void)
Expand Down
Loading