Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mdmngr
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
IOPSYS
mdmngr
Commits
57c4ea0c
Commit
57c4ea0c
authored
7 years ago
by
Jakob Olsson
Browse files
Options
Downloads
Patches
Plain Diff
start replacing recursion with DFS
parent
fb8b51cb
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dongle_infrastructure.c
+58
-6
58 additions, 6 deletions
dongle_infrastructure.c
with
58 additions
and
6 deletions
dongle_infrastructure.c
+
58
−
6
View file @
57c4ea0c
...
...
@@ -29,8 +29,8 @@ const struct blobmsg_policy dev_policy[__DEV_MAX] = {
};
LIST_HEAD
(
devices
);
LIST_HEAD
(
stack
);
LIST_HEAD
(
visited
);
LIST_HEAD
(
unvisited
);
int
devices_status
(
struct
uloop_timeout
*
t
)
{
...
...
@@ -219,17 +219,70 @@ fail:
return
NULL
;
}
char
*
dfs_get_path_name
(
char
*
folder_name
)
{
char
path
[
PATH_MAX
]
=
{
0
},
*
name
;
struct
stat
st
;
struct
dirent
*
de
;
DIR
*
dr
;
FILE
*
fp
;
struct
node
*
n
;
while
((
dr
=
opendir
(
folder_name
))
!=
NULL
)
{
if
(
!
dr
)
{
perror
(
"opendir"
);
goto
fail_opendir
;
}
n
->
path
=
strdup
(
folder_name
);
stack_enqueue
(
n
,
&
stack
);
//while !list_empty(stack) ? eller nått
while
((
de
=
readdir
(
dr
))
!=
NULL
)
{
if
(
strcmp
(
de
->
d_name
,
"."
)
==
0
||
strcmp
(
de
->
d_name
,
".."
)
==
0
)
continue
;
if
(
fstatat
(
dirfd
(
dr
),
de
->
d_name
,
&
st
,
AT_SYMLINK_NOFOLLOW
)
<
0
)
{
perror
(
"fstatat"
);
continue
;
}
if
(
!
S_ISDIR
(
st
.
st_mode
))
continue
;
if
(
!
strstr
(
de
->
d_name
,
"eth"
)
&&
!
strstr
(
de
->
d_name
,
"usb"
))
{
snprintf
(
path
,
PATH_MAX
,
"%s/%s"
,
folder_name
,
de
->
d_name
);
name
=
get_path_name
(
path
);
if
(
name
)
goto
success
;
continue
;
}
if
(
strcmp
(
reverse_lexer
(
&
folder_name
,
'/'
),
"net"
)
==
0
)
{
printf
(
"de->d_name %s
\n
"
,
de
->
d_name
);
name
=
strdup
(
de
->
d_name
);
goto
success
;
}
}
closedir
(
dr
);
}
fail_opendir:
return
NULL
;
success:
closedir
(
dr
);
return
name
;
}
char
*
get_path_name
(
char
*
folder_name
)
{
char
path
[
PATH_MAX
]
=
{
0
},
*
name
;
//query max?
char
path
[
PATH_MAX
]
=
{
0
},
*
name
;
struct
stat
st
;
struct
dirent
*
de
,
net_de
;
struct
dirent
*
de
;
DIR
*
dr
;
FILE
*
fp
;
dr
=
opendir
(
folder_name
);
if
(
!
dr
)
{
//
perror("opendir");
perror
(
"opendir"
);
goto
fail_opendir
;
}
...
...
@@ -238,7 +291,7 @@ char *get_path_name(char *folder_name)
continue
;
if
(
fstatat
(
dirfd
(
dr
),
de
->
d_name
,
&
st
,
AT_SYMLINK_NOFOLLOW
)
<
0
)
{
//
perror("fstatat");
perror
(
"fstatat"
);
continue
;
}
...
...
@@ -265,7 +318,6 @@ fail_opendir:
success:
closedir
(
dr
);
return
name
;
}
char
*
get_interface_name
(
char
*
usb_path
,
char
*
sub_dir_name
)
...
...
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