Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libbpf-bootstrap
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Luis Gerhorst
libbpf-bootstrap
Commits
f4d7cabd
Commit
f4d7cabd
authored
Jul 8, 2021
by
Luis Gerhorst
Browse files
Options
Downloads
Patches
Plain Diff
task_find: Print files matching first char
parent
063b9cb3
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
libbpf
+1
-1
1 addition, 1 deletion
libbpf
src/task_find.bpf.c
+9
-5
9 additions, 5 deletions
src/task_find.bpf.c
src/task_lib.bpf.h
+1
-0
1 addition, 0 deletions
src/task_lib.bpf.h
with
11 additions
and
6 deletions
libbpf
@
c91f1175
Compare
8f836922
...
c91f1175
Subproject commit
8f8369223c327743277a8e4fcbf87c5d9d6f3c88
Subproject commit
c91f1175e2273825767160fdc54448c19c97ba13
This diff is collapsed.
Click to expand it.
src/task_find.bpf.c
+
9
−
5
View file @
f4d7cabd
...
@@ -28,7 +28,7 @@ void *u_newline;
...
@@ -28,7 +28,7 @@ void *u_newline;
void
*
u_iterdents64_buf
;
void
*
u_iterdents64_buf
;
size_t
root_namelen
;
size_t
root_namelen
;
static
long
iter_dir
(
size_t
namelen
)
{
static
long
iter_dir
(
size_t
namelen
,
bool
print
)
{
long
err
=
0
;
long
err
=
0
;
if
(
namelen
+
1
>
PATHLEN
)
{
if
(
namelen
+
1
>
PATHLEN
)
{
...
@@ -66,8 +66,10 @@ static long iter_dir(size_t namelen) {
...
@@ -66,8 +66,10 @@ static long iter_dir(size_t namelen) {
int
dfd
=
openat
(
*
parent_dfd
,
name_user
,
O_RDONLY
|
O_DIRECTORY
,
0777
);
int
dfd
=
openat
(
*
parent_dfd
,
name_user
,
O_RDONLY
|
O_DIRECTORY
,
0777
);
if
(
dfd
<
0
)
{
if
(
dfd
<
0
)
{
bpf_printk
(
"file, depth = %d"
,
depth
);
bpf_printk
(
"file, depth = %d"
,
depth
);
if
(
print
)
{
write
(
STDOUT_FILENO
,
name_user
,
namelen
);
write
(
STDOUT_FILENO
,
name_user
,
namelen
);
write
(
STDOUT_FILENO
,
u_newline
,
1
);
write
(
STDOUT_FILENO
,
u_newline
,
1
);
}
/* Not a directory, no need to iterate. */
/* Not a directory, no need to iterate. */
goto
end
;
goto
end
;
}
}
...
@@ -118,7 +120,7 @@ int entry(void *ctx)
...
@@ -118,7 +120,7 @@ int entry(void *ctx)
{
{
long
err
=
0
;
long
err
=
0
;
err
=
iter_dir
(
root_namelen
);
err
=
iter_dir
(
root_namelen
,
false
);
if
(
err
)
{
if
(
err
)
{
goto
end
;
goto
end
;
}
}
...
@@ -129,12 +131,14 @@ end:
...
@@ -129,12 +131,14 @@ end:
SEC
(
"iterdents64"
)
SEC
(
"iterdents64"
)
int
process_dirent
(
struct
bpf_dirent64
*
d
)
{
int
process_dirent
(
struct
bpf_dirent64
*
d
)
{
int
err
=
0
;
int
err
=
0
;
bool
match
=
false
;
/* Skip "." and "..": */
/* Skip "." and "..": */
if
(
!
(
d
->
name
+
2
>
(
char
*
)
d
->
name_end
))
{
if
(
!
(
d
->
name
+
2
>
(
char
*
)
d
->
name_end
))
{
if
(
d
->
name
[
0
]
==
'.'
&&
d
->
namelen
==
1
)
{
if
(
d
->
name
[
0
]
==
'.'
&&
d
->
namelen
==
1
)
{
goto
end
;
goto
end
;
}
}
match
=
d
->
name
[
0
]
==
'a'
;
}
}
if
(
!
(
d
->
name
+
3
>
(
char
*
)
d
->
name_end
))
{
if
(
!
(
d
->
name
+
3
>
(
char
*
)
d
->
name_end
))
{
...
@@ -143,7 +147,7 @@ int process_dirent(struct bpf_dirent64 *d) {
...
@@ -143,7 +147,7 @@ int process_dirent(struct bpf_dirent64 *d) {
}
}
}
}
err
=
iter_dir
(
d
->
namelen
);
err
=
iter_dir
(
d
->
namelen
,
match
);
if
(
err
)
{
if
(
err
)
{
goto
end
;
goto
end
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/task_lib.bpf.h
+
1
−
0
View file @
f4d7cabd
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
#define NULL ((void *) 0)
#define NULL ((void *) 0)
typedef
int
bool
;
#define false ((bool) 0)
#define false ((bool) 0)
#define true ((bool) 1)
#define true ((bool) 1)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment