Issue Details (XML | Word | Printable)

Key: CORE-3199
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Trivial Trivial
Assignee: Alexander Peshkov
Reporter: Christian Heimes
Votes: 1
Watchers: 3
Operations

If you were logged in you would be able to see more operations.
Firebird Core

nbackup fails due to O_NOATIME flag in database open

Created: 27/Oct/10 01:12 AM   Updated: 23/Apr/13 11:44 AM
Component/s: NBACKUP
Affects Version/s: 2.1.3, 3.0 Initial, 2.5.0
Fix Version/s: 2.5.1, 3.0 Alpha 1

Time Tracking:
Not Specified

Environment: Linux
Issue Links:
Duplicate
 

Planning Status: Unspecified


 Description  « Hide
nbackup is unable to open a FDB file when the file is not owner by the current user although the current user has read permission. This happens because O_NOATIME is only allowed if the current user either owns the file or is root.

open(".../database.fdb", O_RDONLY|O_DIRECT|O_NOATIME) = -1 EPERM (Operation not permitted)

Proposed fix:


--- src/utilities/nbackup.cpp.orig 2010-10-27 03:00:32.068887122 +0200
+++ src/utilities/nbackup.cpp 2010-10-27 03:03:36.801352983 +0200
@@ -336,6 +336,10 @@
 #define O_DIRECT 0
 #endif // O_DIRECT
        dbase = open(dbname.c_str(), O_RDONLY | O_LARGEFILE | O_NOATIME | O_DIRECT);
+ if (dbase < 0 && O_NOATIME)
+ // O_NOATIME fails unless we are either root or the owner of the file
+ // try again without O_NOATIME
+ dbase = open(dbname.c_str(), O_RDONLY | O_LARGEFILE | O_DIRECT);
        if (dbase < 0)
                b_error::raise("Error (%d) opening database file: %s", errno, dbname.c_str());
 #ifdef HAVE_POSIX_FADVISE



 All   Comments   Work Log   Change History   Version Control   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Alexander Peshkov added a comment - 01/Jun/11 12:17 PM
Slightly modified patch applied.