Message ID | 155085405082.5141.12150949924461780415.stgit@magnolia (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | xfsdump: update to use fallocate | expand |
Looks ok. Reviewed-by: Allison Collins <allison.henderson@oracle.com> On 2/22/19 9:47 AM, Darrick J. Wong wrote: > From: Darrick J. Wong <darrick.wong@oracle.com> > > Check the return value of the unlink call when creating a new file. > > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> > --- > 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) >
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)