Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSEP551
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Krishna Vinnakota
CSEP551
Commits
c88bf235
Commit
c88bf235
authored
17 years ago
by
rsc
Browse files
Options
Downloads
Patches
Plain Diff
check unlink of non-empty directory
parent
bd39955e
No related branches found
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
usertests.c
+27
-5
27 additions, 5 deletions
usertests.c
with
27 additions
and
5 deletions
usertests.c
+
27
−
5
View file @
c88bf235
...
@@ -782,6 +782,11 @@ subdir(void)
...
@@ -782,6 +782,11 @@ subdir(void)
}
}
write
(
fd
,
"ff"
,
2
);
write
(
fd
,
"ff"
,
2
);
close
(
fd
);
close
(
fd
);
if
(
unlink
(
"dd"
)
>=
0
){
printf
(
1
,
"unlink dd (non-empty dir) succeeded!
\n
"
);
exit
();
}
if
(
mkdir
(
"/dd/dd"
)
!=
0
){
if
(
mkdir
(
"/dd/dd"
)
!=
0
){
printf
(
1
,
"subdir mkdir dd/dd failed
\n
"
);
printf
(
1
,
"subdir mkdir dd/dd failed
\n
"
);
...
@@ -817,6 +822,10 @@ subdir(void)
...
@@ -817,6 +822,10 @@ subdir(void)
printf
(
1
,
"unlink dd/dd/ff failed
\n
"
);
printf
(
1
,
"unlink dd/dd/ff failed
\n
"
);
exit
();
exit
();
}
}
if
(
open
(
"dd/dd/ff"
,
O_RDONLY
)
>=
0
){
printf
(
1
,
"open (unlinked) dd/dd/ff succeeded
\n
"
);
exit
();
}
if
(
chdir
(
"dd"
)
!=
0
){
if
(
chdir
(
"dd"
)
!=
0
){
printf
(
1
,
"chdir dd failed
\n
"
);
printf
(
1
,
"chdir dd failed
\n
"
);
...
@@ -826,6 +835,10 @@ subdir(void)
...
@@ -826,6 +835,10 @@ subdir(void)
printf
(
1
,
"chdir dd/../../dd failed
\n
"
);
printf
(
1
,
"chdir dd/../../dd failed
\n
"
);
exit
();
exit
();
}
}
if
(
chdir
(
"dd/../../../dd"
)
!=
0
){
printf
(
1
,
"chdir dd/../../dd failed
\n
"
);
exit
();
}
if
(
chdir
(
"./.."
)
!=
0
){
if
(
chdir
(
"./.."
)
!=
0
){
printf
(
1
,
"chdir ./.. failed
\n
"
);
printf
(
1
,
"chdir ./.. failed
\n
"
);
exit
();
exit
();
...
@@ -842,8 +855,8 @@ subdir(void)
...
@@ -842,8 +855,8 @@ subdir(void)
}
}
close
(
fd
);
close
(
fd
);
if
(
open
(
"dd/dd/ff"
,
0
)
>=
0
){
if
(
open
(
"dd/dd/ff"
,
O_RDONLY
)
>=
0
){
printf
(
1
,
"open dd/dd/ff succeeded!
\n
"
);
printf
(
1
,
"open
(unlinked)
dd/dd/ff succeeded!
\n
"
);
exit
();
exit
();
}
}
...
@@ -916,9 +929,18 @@ subdir(void)
...
@@ -916,9 +929,18 @@ subdir(void)
printf
(
1
,
"unlink dd/ff failed
\n
"
);
printf
(
1
,
"unlink dd/ff failed
\n
"
);
exit
();
exit
();
}
}
if
(
unlink
(
"dd"
)
==
0
){
// unlink dd/dd
printf
(
1
,
"unlink non-empty dd succeeded!
\n
"
);
// unlink dd
exit
();
}
if
(
unlink
(
"dd/dd"
)
<
0
){
printf
(
1
,
"unlink dd/dd failed
\n
"
);
exit
();
}
if
(
unlink
(
"dd"
)
<
0
){
printf
(
1
,
"unlink dd failed
\n
"
);
exit
();
}
printf
(
1
,
"subdir ok
\n
"
);
printf
(
1
,
"subdir ok
\n
"
);
}
}
...
...
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