diff options
Diffstat (limited to 'ports')
-rw-r--r-- | ports/unix/guts/fchmod.c | 16 | ||||
-rw-r--r-- | ports/unix/guts/fchmodat.c | 31 | ||||
-rw-r--r-- | ports/unix/guts/fchown.c | 16 | ||||
-rw-r--r-- | ports/unix/guts/fchownat.c | 16 | ||||
-rw-r--r-- | ports/unix/guts/mknodat.c | 4 | ||||
-rw-r--r-- | ports/unix/wrapfuncs.in | 2 |
6 files changed, 39 insertions, 46 deletions
diff --git a/ports/unix/guts/fchmod.c b/ports/unix/guts/fchmod.c index 1d4fae8..e2301e3 100644 --- a/ports/unix/guts/fchmod.c +++ b/ports/unix/guts/fchmod.c @@ -1,12 +1,11 @@ /* - * Copyright (c) 2008-2010, 2012 Wind River Systems; see + * Copyright (c) 2008-2010, 2012, 2013 Wind River Systems; see * guts/COPYRIGHT for information. * * static int * wrap_fchmod(int fd, mode_t mode) { * int rc = -1; */ - pseudo_msg_t *msg; PSEUDO_STATBUF buf; int save_errno = errno; @@ -15,16 +14,11 @@ return -1; } buf.st_mode = (buf.st_mode & ~07777) | (mode & 07777); - msg = pseudo_client_op(OP_FCHMOD, 0, fd, -1, 0, &buf); + pseudo_client_op(OP_FCHMOD, 0, fd, -1, 0, &buf); real_fchmod(fd, PSEUDO_FS_MODE(mode, S_ISDIR(buf.st_mode))); - if (msg && msg->result != RESULT_SUCCEED) { - errno = EPERM; - rc = -1; - } else { - /* just pretend we worked */ - errno = save_errno; - rc = 0; - } + /* just pretend we worked */ + errno = save_errno; + rc = 0; /* return rc; * } diff --git a/ports/unix/guts/fchmodat.c b/ports/unix/guts/fchmodat.c index a14d1b1..59a92ce 100644 --- a/ports/unix/guts/fchmodat.c +++ b/ports/unix/guts/fchmodat.c @@ -1,14 +1,13 @@ /* - * Copyright (c) 2008-2010, 2012 Wind River Systems; see + * Copyright (c) 2008-2010, 2012, 2013 Wind River Systems; see * guts/COPYRIGHT for information. * * static int * wrap_fchmodat(int dirfd, const char *path, mode_t mode, int flags) { * int rc = -1; */ - pseudo_msg_t *msg; PSEUDO_STATBUF buf; - int save_errno; + int save_errno = errno; #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS if (dirfd != AT_FDCWD) { @@ -33,8 +32,13 @@ } save_errno = errno; +#if 0 + pseudo_msg_t *msg; /* purely for debugging purposes: check whether file - * is already in database. + * is already in database. We don't need the resulting + * information for anything. This is currently ifdefed + * out because it's only useful when trying to track where + * files are coming from. */ msg = pseudo_client_op(OP_STAT, 0, -1, -1, path, &buf); if (!msg || msg->result != RESULT_SUCCEED) { @@ -42,6 +46,7 @@ mode, dirfd, path, (unsigned long long) buf.st_ino); } +#endif /* user bits added so "root" can always access files. */ #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS @@ -53,18 +58,18 @@ #endif /* we ignore a failure from underlying fchmod, because pseudo * may believe you are permitted to change modes that the filesystem - * doesn't. + * doesn't. Note that we also don't need to know whether the + * file might be a (pseudo) block device or some such; pseudo + * will only modify permission bits based on an OP_CHMOD, and does + * not care about device/file type mismatches, only directory/file + * or symlink/file. */ buf.st_mode = (buf.st_mode & ~07777) | (mode & 07777); - msg = pseudo_client_op(OP_CHMOD, 0, -1, dirfd, path, &buf); - if (msg && msg->result != RESULT_SUCCEED) { - errno = EPERM; - rc = -1; - } else { - /* if server is down, just pretend we worked */ - rc = 0; - } + pseudo_client_op(OP_CHMOD, 0, -1, dirfd, path, &buf); + /* don't change errno from what it was originally */ + errno = save_errno; + rc = 0; /* return rc; * } diff --git a/ports/unix/guts/fchown.c b/ports/unix/guts/fchown.c index 72a1e46..1514e35 100644 --- a/ports/unix/guts/fchown.c +++ b/ports/unix/guts/fchown.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2010, 2012 Wind River Systems; see + * Copyright (c) 2008-2010, 2012, 2013 Wind River Systems; see * guts/COPYRIGHT for information. * * static int @@ -8,7 +8,7 @@ */ pseudo_msg_t *msg; PSEUDO_STATBUF buf; - int save_errno; + int save_errno = errno; if (base_fstat(fd, &buf) == -1) { save_errno = errno; @@ -41,14 +41,10 @@ } pseudo_debug(2, "fchown, fd %d: %d:%d -> %d:%d\n", fd, owner, group, buf.st_uid, buf.st_gid); - msg = pseudo_client_op(OP_FCHOWN, 0, fd, -1, 0, &buf); - if (msg && msg->result != RESULT_SUCCEED) { - errno = EPERM; - rc = -1; - } else { - /* just pretend we worked */ - rc = 0; - } + pseudo_client_op(OP_FCHOWN, 0, fd, -1, 0, &buf); + /* pretend we worked, errno should be unchanged */ + errno = save_errno; + rc = 0; /* return rc; * } diff --git a/ports/unix/guts/fchownat.c b/ports/unix/guts/fchownat.c index 8d3ee05..60ccfa5 100644 --- a/ports/unix/guts/fchownat.c +++ b/ports/unix/guts/fchownat.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2010, 2012 Wind River Systems; see + * Copyright (c) 2008-2010, 2012, 2013 Wind River Systems; see * guts/COPYRIGHT for information. * * static int @@ -8,7 +8,7 @@ */ pseudo_msg_t *msg; PSEUDO_STATBUF buf; - int save_errno; + int save_errno = errno; int doing_link = 0; #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS @@ -53,14 +53,10 @@ if (group != (gid_t) -1) { buf.st_gid = group; } - msg = pseudo_client_op(OP_CHOWN, 0, -1, dirfd, path, &buf); - if (msg && msg->result != RESULT_SUCCEED) { - errno = EPERM; - rc = -1; - } else { - /* just pretend we worked */ - rc = 0; - } + pseudo_client_op(OP_CHOWN, 0, -1, dirfd, path, &buf); + /* just pretend we worked */ + errno = save_errno; + rc = 0; /* return rc; * } diff --git a/ports/unix/guts/mknodat.c b/ports/unix/guts/mknodat.c index 32a4d5b..6fd5b42 100644 --- a/ports/unix/guts/mknodat.c +++ b/ports/unix/guts/mknodat.c @@ -8,6 +8,7 @@ pseudo_msg_t *msg; PSEUDO_STATBUF buf; + int save_errno = errno; #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS if (dirfd != AT_FDCWD) { @@ -50,10 +51,11 @@ rc = -1; } else { /* just pretend we worked */ + errno = save_errno; rc = 0; } if (rc == -1) { - int save_errno = errno; + save_errno = errno; #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS real_unlink(path); #else diff --git a/ports/unix/wrapfuncs.in b/ports/unix/wrapfuncs.in index a0f191c..8460a65 100644 --- a/ports/unix/wrapfuncs.in +++ b/ports/unix/wrapfuncs.in @@ -63,7 +63,7 @@ FILE *popen(const char *command, const char *mode); /* hand_wrapped=1 */ # during filesystem assembly. int fsync(int fd); /* async_skip=0 */ int fdatasync(int fd); /* async_skip=0 */ -void sync(void); /* async_skip=0 */ +void sync(void); /* async_skip= */ int syncfs(int fd); /* async_skip=0 */ int sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags); /* async_skip=0 */ int msync(void *addr, size_t length, int flags); /* async_skip=0 */ |