From b73ba7f15caf9c1f555f41e3f5ea4a4df0f352f5 Mon Sep 17 00:00:00 2001 From: jpandre Date: Sat, 17 Jan 2009 08:39:23 +0000 Subject: [PATCH] Avoided errno pollution when removing a reparse point --- libntfs-3g/reparse.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libntfs-3g/reparse.c b/libntfs-3g/reparse.c index 75ffbf6a..193e75fe 100644 --- a/libntfs-3g/reparse.c +++ b/libntfs-3g/reparse.c @@ -4,7 +4,7 @@ * This module is part of ntfs-3g library, but may also be * integrated in tools running over Linux or Windows * - * Copyright (c) 2008 Jean-Pierre Andre + * Copyright (c) 2008-2009 Jean-Pierre Andre * * This program/include file is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as published @@ -1028,6 +1028,7 @@ int ntfs_remove_ntfs_reparse_data(const char *path __attribute__((unused)), ntfs_inode *ni) { int res; + int olderrno; ntfs_attr *na; res = 0; @@ -1042,6 +1043,11 @@ int ntfs_remove_ntfs_reparse_data(const char *path __attribute__((unused)), res = ntfs_attr_rm(na); if (!res) ni->flags &= ~FILE_ATTR_REPARSE_POINT; + olderrno = errno; + ntfs_attr_close(na); + /* avoid errno pollution */ + if (errno == ENOENT) + errno = olderrno; } else { errno = ENODATA; res = -1;