Skip to content

Commit 80f4bc2

Browse files
author
Jan Engelhardt
committed
Add open flags translation layer
1 parent e5999e3 commit 80f4bc2

File tree

6 files changed

+358
-296
lines changed

6 files changed

+358
-296
lines changed

gen_xl.pl

+2-20
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
use strict;
44

5+
open(STDOUT, ">xl_errno.c");
6+
57
if (scalar(@ARGV) == 0) {
68
@ARGV = qw(
79
/usr/include/asm-generic/errno-base.h
@@ -14,8 +16,6 @@
1416
print <<"--EOT";
1517
/* Generated by gen_xl_errno.pl */
1618
#include <errno.h>
17-
#include "xl_errno.h"
18-
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
1919
2020
static const int arch_to_generic_table[] = {
2121
[0] = 0,
@@ -42,22 +42,4 @@
4242

4343
print <<"--EOT";
4444
};
45-
46-
/* x is always negative or zero */
47-
int generic_errno(int x)
48-
{
49-
if (x < -ARRAY_SIZE(arch_to_generic_table))
50-
return x;
51-
else
52-
return arch_to_generic_table[-x];
53-
}
54-
55-
/* x is always negative or zero */
56-
int arch_errno(int x)
57-
{
58-
if (x < -ARRAY_SIZE(generic_to_arch_table))
59-
return x;
60-
else
61-
return generic_to_arch_table[-x];
62-
}
6345
--EOT

src/mount.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static int ccgfs_create(const char *path, mode_t mode,
124124

125125
rq = mpkt_init(CCGFS_CREATE_REQUEST, PV_STRING + 2 * PV_32);
126126
pkt_push_s(rq, path);
127-
pkt_push_32(rq, filp->flags);
127+
pkt_push_32(rq, generic_openflags(filp->flags));
128128
pkt_push_32(rq, mode);
129129
mpkt_send(out_fd, rq);
130130

@@ -343,7 +343,7 @@ static int ccgfs_open(const char *path, struct fuse_file_info *filp)
343343

344344
rq = mpkt_init(CCGFS_OPEN_REQUEST, PV_STRING + PV_32);
345345
pkt_push_s(rq, path);
346-
pkt_push_32(rq, filp->flags);
346+
pkt_push_32(rq, generic_openflags(filp->flags));
347347
mpkt_send(out_fd, rq);
348348

349349
ret = mpkt_recv(CCGFS_OPEN_RESPONSE, &rp);

src/storage.c

+4-9
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,8 @@ static int localfs_create(int fd, struct lo_packet *rq)
9292
struct lo_packet *rp;
9393
int ret;
9494

95-
#ifdef ENABLE_WORKAROUNDS
96-
/* No idea why that is needed for older kernels... */
97-
rq_flags &= ~O_NOATIME;
98-
#endif
99-
if ((ret = openat(root_fd, at(rq_path), rq_flags, rq_mode)) < 0)
95+
ret = openat(root_fd, at(rq_path), arch_openflags(rq_flags), rq_mode);
96+
if (ret < 0)
10097
return -errno;
10198

10299
rp = pkt_init(CCGFS_CREATE_RESPONSE, PV_32);
@@ -285,10 +282,8 @@ static int localfs_open(int fd, struct lo_packet *rq)
285282
struct lo_packet *rp;
286283
int ret;
287284

288-
#ifdef ENABLE_WORKAROUNDS
289-
rq_flags &= ~O_NOATIME;
290-
#endif
291-
if ((ret = openat(root_fd, at(rq_path), rq_flags)) < 0)
285+
ret = openat(root_fd, at(rq_path), arch_openflags(rq_flags));
286+
if (ret < 0)
292287
return -errno;
293288

294289
rp = pkt_init(CCGFS_OPEN_RESPONSE, PV_32);

0 commit comments

Comments
 (0)