From b765a6db5fc0b679751f7aabf507f090d1a3db40 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Jul 2024 12:57:06 +0200 Subject: Adding upstream version 0.0.3. Signed-off-by: Daniel Baumann --- .dockerignore | 2 ++ .github/workflows/ci.yaml | 16 +++++++++++----- .github/workflows/release.yaml | 5 ----- Dockerfile | 2 +- Makefile | 13 +++++++++++++ README.md | 14 +++++++++----- inotify-info.cpp | 10 +++++----- 7 files changed, 41 insertions(+), 21 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6fcce79 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +_release +_debug diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 319f4cc..06249d1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,29 +24,35 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: {fetch-depth: 0} - run: sudo apt-get install -y build-essential - - run: make CFG=${{ matrix.cfg}} -j$(nproc) - - run: _${{ matrix.cfg }}/inotify-info + - run: make VERBOSE=1 CFG=${{ matrix.cfg}} -j$(nproc) + - run: | + _${{ matrix.cfg }}/inotify-info --version + _${{ matrix.cfg }}/inotify-info build-with-zig: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: {fetch-depth: 0} - uses: actions/cache@v4 with: key: zig-sdk-and-cache-${{ hashFiles('.github/workflows/ci.yaml') }} path: ~/.cache/zig - run: | wget --progress=dot:mega \ - https://ziglang.org/download/0.12.0/zig-linux-$(uname -m)-0.12.0.tar.xz + https://ziglang.org/download/0.13.0/zig-linux-$(uname -m)-0.13.0.tar.xz tar -xJf zig-linux-*.tar.xz rm zig-linux-*.xz mv zig-linux-* zig-sdk - run: | - make -j$(nproc) \ + make VERBOSE=1 -j$(nproc) \ CC="zig-sdk/zig cc -target $(uname -m)-linux-musl" \ CXX="zig-sdk/zig c++ -target $(uname -m)-linux-musl" - - run: _release/inotify-info + - run: | + _release/inotify-info --version + _release/inotify-info build-with-docker: runs-on: ubuntu-latest diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index f5e422f..f6e08ef 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -8,15 +8,10 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Archive - run: make inotify-info-${{ github.ref_name }}.tar.gz - name: Release uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/v') with: - files: inotify-info-${{ github.ref_name }}.tar.gz generate_release_notes: true draft: true prerelease: true diff --git a/Dockerfile b/Dockerfile index aa19614..0f523db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ COPY . . RUN CC="zig cc -target $(uname -m)-linux-musl" \ CXX="zig c++ -target $(uname -m)-linux-musl" \ - make + make VERBOSE=1 FROM scratch COPY --from=0 /inotify-info/_release/inotify-info /inotify-info diff --git a/Makefile b/Makefile index cb95bb4..9163e54 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,9 @@ ifeq ($(CFG), debug) ASAN ?= 1 endif +PREFIX ?= /usr/local +BINDIR := $(PREFIX)/bin + LD = $(CC) RM = rm -f MKDIR = mkdir -p @@ -121,6 +124,16 @@ clean: $(VERBOSE_PREFIX)$(RM) $(OBJS:.o=.d) $(VERBOSE_PREFIX)$(RM) $(OBJS:.o=.dwo) +.PHONY: install + +install: all + install -D $(PROJ) $(BINDIR)/$(NAME) + +.PHONY: uninstall + +uninstall: + $(RM) $(BINDIR)/$(NAME) + define RELEASE_RULES inotify-info-$(TAG).tar.gz: git archive --prefix=inotify-info-$(TAG)/ v$(TAG) | gzip -n > $$@ diff --git a/README.md b/README.md index 3c64833..c5fe0ae 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,10 @@ Linking _debug/inotify-info... ``` ## Install -You are free to copy the resulting executable to any suitable location in your `$PATH`. -``` -cp _release/inotify-info /usr/local/bin/ -``` + +The resulting executable will be at `_release/inotify-info`. You are free to +copy the resulting executable to any suitable location in your `$PATH` or run +`make install` to install to `/usr/local/bin`. ## Run (Prints Summary) ``` @@ -154,13 +154,16 @@ Searching '/' for listed inodes... (8 threads) 94111468 [10304h] /home/mikesart/.cache/xfce4/xfce4-appfinder/ ``` -## Run on Docker +## Run on Docker/podman ```sh docker build . -t inotify-info docker run --rm --privileged -v /proc:/proc inotify-info ``` +When running under [podman][podman] non-root mode, append `--ulimit +nofile=65535:65535` to the `podman build` command. + ## Run on Nix(OS) ``` @@ -176,3 +179,4 @@ nix run nixpkgs#inotify-info [problem2]: https://unix.stackexchange.com/questions/15509/whos-consuming-my-inotify-resources [lfqueue]: https://github.com/Taymindis/lfqueue [bsd]: https://github.com/Taymindis/lfqueue/blob/master/LICENSE +[podman]: https://podman.io/ diff --git a/inotify-info.cpp b/inotify-info.cpp index ae5e61e..7706e84 100644 --- a/inotify-info.cpp +++ b/inotify-info.cpp @@ -389,7 +389,7 @@ struct statx mystatx(const char* filename, unsigned int mask = 0) int flags = AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW | AT_STATX_DONT_SYNC; if (statx(0, filename, flags, mask, &statxbuf) == -1) { - printf("ERROR: statx-ino( %s ) failed. Errno: %d\n", filename, errno); + printf("ERROR: statx-ino( %s ) failed. Errno: %d (%s)\n", filename, errno, strerror(errno)); memset(&statxbuf, 0, sizeof(statxbuf)); } @@ -418,7 +418,7 @@ static dev_t stat_get_dev_t(const char* filename) int ret = stat(filename, &statbuf); if (ret == -1) { - printf("ERROR: stat-dev_t( %s ) failed. Errno: %d\n", filename, errno); + printf("ERROR: stat-dev_t( %s ) failed. Errno: %d (%s)\n", filename, errno, strerror(errno)); return 0; } return statbuf.st_dev; @@ -430,7 +430,7 @@ static uint64_t stat_get_ino(const char* filename) int ret = stat(filename, &statbuf); if (ret == -1) { - printf("ERROR: stat-ino( %s ) failed. Errno: %d\n", filename, errno); + printf("ERROR: stat-ino( %s ) failed. Errno: %d (%s)\n", filename, errno, strerror(errno)); return 0; } @@ -543,7 +543,7 @@ int thread_info_t::parse_dirqueue_entry() } if (spew_error) { - printf("ERROR: sys_getdents64 failed on '%s': %d errno:%d\n", path, ret, errno); + printf("ERROR: sys_getdents64 failed on '%s': %d errno: %d (%s)\n", path, ret, errno, strerror(errno)); } break; } @@ -631,7 +631,7 @@ static bool init_inotify_proclist(std::vector& inotify_proclist) DIR* dir_proc = opendir("/proc"); if (!dir_proc) { - printf("ERROR: opendir /proc failed: %d\n", errno); + printf("ERROR: opendir /proc failed: %d (%s)\n", errno, strerror(errno)); return false; } -- cgit v1.2.3