Looks ok.
Reviewed-by: Allison Collins <allison.henderson@xxxxxxxxxx>
On 2/22/19 9:47 AM, Darrick J. Wong wrote:
From: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
Check the return value of the unlink call when creating a new file.
Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
---
restore/dirattr.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/restore/dirattr.c b/restore/dirattr.c
index 0fb2877..4257a1b 100644
--- a/restore/dirattr.c
+++ b/restore/dirattr.c
@@ -67,7 +67,9 @@ create_filled_file(
int fd;
int ret;
- (void)unlink(pathname);
+ ret = unlink(pathname);
+ if (ret && errno != ENOENT)
+ return ret;
fd = open(pathname, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
if (fd < 0)