Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
bmiddha committed Sep 25, 2024
0 parents commit 1ac87e7
Show file tree
Hide file tree
Showing 11 changed files with 643 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
UseTab: false
IndentWidth: 2
BreakBeforeBraces: Allman
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
ColumnLimit: 120
SortIncludes: false
46 changes: 46 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Setup clang
run: make apt-install

- name: Build
run: make build

- name: Run clang-tidy
run: make tidy

- name: Run clang-format
run: make format

- name: Upload build artifacts
uses: actions/upload-artifact@v2
with:
name: fs-trace-linux-amd64
path: bin/fs-trace

publish-npm:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-latest
steps:
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: "18"
- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin/
18 changes: 18 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/node_modules/node-addon-api/**",
"/usr/local/share/nvm/versions/node/v18.19.1/include/node/**"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++14",
"intelliSenseMode": "linux-clang-x64"
}
],
"version": 4
}
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
build:
mkdir -p bin
clang -std=gnu11 -O3 -o bin/fs-trace fs-trace.c

build-debug:
mkdir -p bin
clang -std=gnu11 -O0 -DDEBUG=1 -o bin/fs-trace fs-trace.c

tidy:
clang-tidy fs-trace.c -- -std=gnu11

format:
clang-format -style=file -i fs-trace.c

apt-install:
sudo apt-get -y install clang clang-format
Empty file added README.md
Empty file.
18 changes: 18 additions & 0 deletions fs-trace.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "trace_exec.c"
#include <stdio.h>
#include <sys/ptrace.h>
#include <stdarg.h>

int main(int argc, char *argv[])
{
if (argc < 2)
{
fprintf(stderr, "Usage: %s <program> [args...]\n", argv[0]);
return 1;
}

char *program = argv[1];
char **args = &argv[1];

return trace_exec(program, args);
}
21 changes: 21 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "fs-trace",
"version": "0.0.1",
"description": "Trace file system calls",
"os": [
"linux"
],
"cpu": [
"x64"
],
"bin": {
"fs-trace": "./bin/fs-trace"
},
"files": [
"bin/fs-trace",
"package.json"
],
"repository": {
"type": "git",
"url": "git+https://github.com/bmiddha/fs-trace.git"
}
}
7 changes: 7 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/usr/bin/mkdir /tmp/bar
/usr/bin/echo foo >> /tmp/foo
/usr/bin/echo foo > /tmp/foo
/usr/bin/rm -r /tmp/bar
/usr/bin/rm /tmp/foo
test -f /tmp/foo222 && echo foo
readlink /etc/localtime
Loading

0 comments on commit 1ac87e7

Please sign in to comment.