Changeset View
Changeset View
Standalone View
Standalone View
src/engine/fsutils.cpp
Show All 15 Lines | |||||
16 | * You should have received a copy of the GNU Library General Public License | 16 | * You should have received a copy of the GNU Library General Public License | ||
17 | * along with this library; see the file COPYING.LIB. If not, write to | 17 | * along with this library; see the file COPYING.LIB. If not, write to | ||
18 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
19 | * Boston, MA 02110-1301, USA. | 19 | * Boston, MA 02110-1301, USA. | ||
20 | * | 20 | * | ||
21 | */ | 21 | */ | ||
22 | 22 | | |||
23 | #include "fsutils.h" | 23 | #include "fsutils.h" | ||
24 | 24 | #include "enginedebug.h" | |||
25 | #include <QDebug> | | |||
26 | 25 | | |||
27 | #ifdef Q_OS_LINUX | 26 | #ifdef Q_OS_LINUX | ||
28 | #include <errno.h> | 27 | #include <errno.h> | ||
29 | #include <unistd.h> | 28 | #include <unistd.h> | ||
30 | #include <sys/ioctl.h> | 29 | #include <sys/ioctl.h> | ||
31 | #include <fcntl.h> | 30 | #include <fcntl.h> | ||
32 | #endif | 31 | #endif | ||
33 | 32 | | |||
Show All 15 Lines | 46 | #endif | |||
49 | // Disable COW on file | 48 | // Disable COW on file | ||
50 | #ifndef FS_NOCOW_FL | 49 | #ifndef FS_NOCOW_FL | ||
51 | #define FS_NOCOW_FL 0x00800000 | 50 | #define FS_NOCOW_FL 0x00800000 | ||
52 | #endif | 51 | #endif | ||
53 | 52 | | |||
54 | ulong flags = 0; | 53 | ulong flags = 0; | ||
55 | const int fd = open(qPrintable(path), O_RDONLY); | 54 | const int fd = open(qPrintable(path), O_RDONLY); | ||
56 | if (fd == -1) { | 55 | if (fd == -1) { | ||
57 | qWarning() << "Failed to open" << path << "to modify flags (" << errno << ")"; | 56 | qCWarning(ENGINE) << "Failed to open" << path << "to modify flags (" << errno << ")"; | ||
58 | return; | 57 | return; | ||
59 | } | 58 | } | ||
60 | 59 | | |||
61 | if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1) { | 60 | if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1) { | ||
62 | const int errno_ioctl = errno; | 61 | const int errno_ioctl = errno; | ||
63 | // ignore ENOTTY, filesystem does not support attrs (and likely neither supports COW) | 62 | // ignore ENOTTY, filesystem does not support attrs (and likely neither supports COW) | ||
64 | if (errno_ioctl != ENOTTY) { | 63 | if (errno_ioctl != ENOTTY) { | ||
65 | qWarning() << "ioctl error: failed to get file flags (" << errno_ioctl << ")"; | 64 | qCWarning(ENGINE) << "ioctl error: failed to get file flags (" << errno_ioctl << ")"; | ||
66 | } | 65 | } | ||
67 | close(fd); | 66 | close(fd); | ||
68 | return; | 67 | return; | ||
69 | } | 68 | } | ||
70 | if (!(flags & FS_NOCOW_FL)) { | 69 | if (!(flags & FS_NOCOW_FL)) { | ||
71 | flags |= FS_NOCOW_FL; | 70 | flags |= FS_NOCOW_FL; | ||
72 | if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == -1) { | 71 | if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == -1) { | ||
73 | const int errno_ioctl = errno; | 72 | const int errno_ioctl = errno; | ||
74 | // ignore EOPNOTSUPP, returned on filesystems not supporting COW | 73 | // ignore EOPNOTSUPP, returned on filesystems not supporting COW | ||
75 | if (errno_ioctl != EOPNOTSUPP) { | 74 | if (errno_ioctl != EOPNOTSUPP) { | ||
76 | qWarning() << "ioctl error: failed to set file flags (" << errno_ioctl << ")"; | 75 | qCWarning(ENGINE) << "ioctl error: failed to set file flags (" << errno_ioctl << ")"; | ||
77 | } | 76 | } | ||
78 | close(fd); | 77 | close(fd); | ||
79 | return; | 78 | return; | ||
80 | } | 79 | } | ||
81 | } | 80 | } | ||
82 | close(fd); | 81 | close(fd); | ||
83 | #endif | 82 | #endif | ||
84 | } | 83 | } | ||
85 | 84 | |