diff options
Diffstat (limited to 'ports/darwin/guts')
32 files changed, 537 insertions, 0 deletions
diff --git a/ports/darwin/guts/acct.c b/ports/darwin/guts/acct.c new file mode 100644 index 0000000..a99dab1 --- /dev/null +++ b/ports/darwin/guts/acct.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int acct(const char *path) + * int rc = -1; + */ + + rc = real_acct(path); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/chmod.c b/ports/darwin/guts/chmod.c new file mode 100644 index 0000000..5ec331e --- /dev/null +++ b/ports/darwin/guts/chmod.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int chmod(const char *path, mode_t mode) + * int rc = -1; + */ + + rc = real_chmod(path, mode); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/chown.c b/ports/darwin/guts/chown.c new file mode 100644 index 0000000..04414e7 --- /dev/null +++ b/ports/darwin/guts/chown.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int chown(const char *path, uid_t owner, gid_t group) + * int rc = -1; + */ + + rc = real_chown(path, owner, group); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/fcntl.c b/ports/darwin/guts/fcntl.c new file mode 100644 index 0000000..464e12a --- /dev/null +++ b/ports/darwin/guts/fcntl.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int fcntl(int fd, int cmd, ... { struct flock *lock }) + * int rc = -1; + */ + + rc = real_fcntl(fd, cmd, lock); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/fgetgrent_r.c b/ports/darwin/guts/fgetgrent_r.c new file mode 100644 index 0000000..e760cdd --- /dev/null +++ b/ports/darwin/guts/fgetgrent_r.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int fgetgrent_r(FILE *fp, struct group*gbuf, char *buf, size_t buflen, struct group **gbufp) + * int rc = -1; + */ + + rc = real_fgetgrent_r(fp, gbuf, buf, buflen, gbufp); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/fgetpwent_r.c b/ports/darwin/guts/fgetpwent_r.c new file mode 100644 index 0000000..cfea5b8 --- /dev/null +++ b/ports/darwin/guts/fgetpwent_r.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int fgetpwent_r(FILE *fp, struct passwd *pbuf, char *buf, size_t buflen, struct passwd **pbufp) + * int rc = -1; + */ + + rc = real_fgetpwent_r(fp, pbuf, buf, buflen, pbufp); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/fgetxattr.c b/ports/darwin/guts/fgetxattr.c new file mode 100644 index 0000000..1752dff --- /dev/null +++ b/ports/darwin/guts/fgetxattr.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * ssize_t fgetxattr(int filedes, const char *name, void *value, size_t size) + * ssize_t rc = -1; + */ + + rc = real_fgetxattr(filedes, name, value, size); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/flistxattr.c b/ports/darwin/guts/flistxattr.c new file mode 100644 index 0000000..2c0fe7c --- /dev/null +++ b/ports/darwin/guts/flistxattr.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * ssize_t flistxattr(int filedes, char *list, size_t size) + * ssize_t rc = -1; + */ + + rc = real_flistxattr(filedes, list, size); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/fsetxattr.c b/ports/darwin/guts/fsetxattr.c new file mode 100644 index 0000000..0de3dfc --- /dev/null +++ b/ports/darwin/guts/fsetxattr.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int fsetxattr(int filedes, const char *name, const void *value, size_t size, int flags) + * int rc = -1; + */ + + rc = real_fsetxattr(filedes, name, value, size, flags); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/fstat.c b/ports/darwin/guts/fstat.c new file mode 100644 index 0000000..7695147 --- /dev/null +++ b/ports/darwin/guts/fstat.c @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int fstat(int fd, struct stat *buf) + * int rc = -1; + */ + pseudo_msg_t *msg; + + rc = real_fstat(fd, buf); + + if (rc == -1) { + return rc; + } + + /* query database + * note that symlink canonicalizing is now automatic, so we + * don't need to check for a symlink on this end + */ + msg = pseudo_client_op(OP_FSTAT, 0, fd, -1, 0, buf); + if (msg && msg->result == RESULT_SUCCEED) { + pseudo_stat_msg(buf, msg); + } + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/getgrent_r.c b/ports/darwin/guts/getgrent_r.c new file mode 100644 index 0000000..9d5db5a --- /dev/null +++ b/ports/darwin/guts/getgrent_r.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int getgrent_r(struct group *gbuf, char *buf, size_t buflen, struct group **gbufp) + * int rc = -1; + */ + + rc = real_getgrent_r(gbuf, buf, buflen, gbufp); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/getgrouplist.c b/ports/darwin/guts/getgrouplist.c new file mode 100644 index 0000000..85fccc9 --- /dev/null +++ b/ports/darwin/guts/getgrouplist.c @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2010 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * static int + * wrap_getgrouplist(const char *name, int basegid, int *groups, int *ngroups) { + * int rc = -1; + */ + + int found = 0; + int found_group = 0; + char buf[PSEUDO_PWD_MAX]; + struct group grp, *gbuf = &grp; + + setgrent(); + while ((rc = wrap_getgrent_r(gbuf, buf, PSEUDO_PWD_MAX, &gbuf)) == 0) { + int i = 0; + for (i = 0; gbuf->gr_mem[i]; ++i) { + if (!strcmp(gbuf->gr_mem[i], name)) { + if (found < *ngroups) + groups[found] = gbuf->gr_gid; + ++found; + if ((int) gbuf->gr_gid == basegid) + found_group = 1; + } + } + } + endgrent(); + if (!found_group) { + if (found < *ngroups) + groups[found] = basegid; + ++found; + } + if (found >= *ngroups) + rc = -1; + else + rc = found; + *ngroups = found; + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/getgroups.c b/ports/darwin/guts/getgroups.c new file mode 100644 index 0000000..3cbeb76 --- /dev/null +++ b/ports/darwin/guts/getgroups.c @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2010 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * static int + * wrap_getgroups(int size, gid_t *list) { + * int rc = -1; + */ + struct passwd *p = wrap_getpwuid(wrap_getuid()); + int oldsize = size; + + if (p) { + rc = wrap_getgrouplist(p->pw_name, wrap_getgid(), (int *) list, &size); + if (oldsize == 0 || size <= oldsize) + rc = size; + } else { + errno = ENOENT; + } + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/getpwent_r.c b/ports/darwin/guts/getpwent_r.c new file mode 100644 index 0000000..3de41b9 --- /dev/null +++ b/ports/darwin/guts/getpwent_r.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int getpwent_r(struct passwd *pwbuf, char *buf, size_t buflen, struct passwd **pwbufp) + * int rc = -1; + */ + + rc = real_getpwent_r(pwbuf, buf, buflen, pwbufp); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/getxattr.c b/ports/darwin/guts/getxattr.c new file mode 100644 index 0000000..96fc1e8 --- /dev/null +++ b/ports/darwin/guts/getxattr.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * ssize_t getxattr(const char *pathname, const char *name, void *value, size_t size) + * ssize_t rc = -1; + */ + + rc = real_getxattr(pathname, name, value, size); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/lchown.c b/ports/darwin/guts/lchown.c new file mode 100644 index 0000000..19de904 --- /dev/null +++ b/ports/darwin/guts/lchown.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int lchown(const char *path, uid_t owner, gid_t group) + * int rc = -1; + */ + + rc = real_lchown(path, owner, group); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/link.c b/ports/darwin/guts/link.c new file mode 100644 index 0000000..04d29a1 --- /dev/null +++ b/ports/darwin/guts/link.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int link(const char *oldpath, const char *newpath) + * int rc = -1; + */ + + rc = real_link(oldpath, newpath); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/listxattr.c b/ports/darwin/guts/listxattr.c new file mode 100644 index 0000000..4b48ac6 --- /dev/null +++ b/ports/darwin/guts/listxattr.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * ssize_t listxattr(const char *pathname, char *list, size_t size) + * ssize_t rc = -1; + */ + + rc = real_listxattr(pathname, list, size); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/lstat.c b/ports/darwin/guts/lstat.c new file mode 100644 index 0000000..01e0f30 --- /dev/null +++ b/ports/darwin/guts/lstat.c @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int lstat(const char *path, struct stat *buf) + * int rc = -1; + */ + + pseudo_msg_t *msg; + + rc = real_lstat(path, buf); + if (rc == -1) { + return rc; + } + + /* query database + * note that symlink canonicalizing is now automatic, so we + * don't need to check for a symlink on this end + */ + msg = pseudo_client_op(OP_STAT, 0, -1, -1, path, buf); + if (msg && msg->result == RESULT_SUCCEED) { + pseudo_stat_msg(buf, msg); + } + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/mkdir.c b/ports/darwin/guts/mkdir.c new file mode 100644 index 0000000..932b211 --- /dev/null +++ b/ports/darwin/guts/mkdir.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int mkdir(const char *path, mode_t mode) + * int rc = -1; + */ + + rc = real_mkdir(path, mode); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/mkfifo.c b/ports/darwin/guts/mkfifo.c new file mode 100644 index 0000000..e7b1c9c --- /dev/null +++ b/ports/darwin/guts/mkfifo.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int mkfifo(const char *path, mode_t mode) + * int rc = -1; + */ + + rc = real_mkfifo(path, mode); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/mknod.c b/ports/darwin/guts/mknod.c new file mode 100644 index 0000000..25c2962 --- /dev/null +++ b/ports/darwin/guts/mknod.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int mknod(const char *path, mode_t mode, dev_t dev) + * int rc = -1; + */ + + rc = real_mknod(path, mode, dev); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/mkstemp.c b/ports/darwin/guts/mkstemp.c new file mode 100644 index 0000000..73b0200 --- /dev/null +++ b/ports/darwin/guts/mkstemp.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int mkstemp(char *template) + * int rc = -1; + */ + + rc = real_mkstemp(template); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/open.c b/ports/darwin/guts/open.c new file mode 100644 index 0000000..64cb6ad --- /dev/null +++ b/ports/darwin/guts/open.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int open(const char *path, int flags, ... { int mode }) + * int rc = -1; + */ + + struct stat buf; + int existed = 1; + int save_errno; + + /* if a creation has been requested, check whether file exists */ + if (flags & O_CREAT) { + save_errno = errno; + rc = real_stat(path, &buf); + existed = (rc != -1); + if (!existed) + pseudo_debug(2, "open_creat: %s -> 0%o\n", path, mode); + errno = save_errno; + } + + /* because we are not actually root, secretly mask in 0700 to the + * underlying mode + */ + rc = real_open(path, flags, PSEUDO_FS_MODE(mode)); + save_errno = errno; + + if (rc != -1) { + int stat_rc; + stat_rc = real_stat(path, &buf); + + if (stat_rc != -1) { + buf.st_mode = PSEUDO_DB_MODE(buf.st_mode, mode); + if (!existed) { + pseudo_client_op(OP_CREAT, 0, -1, -1, path, &buf); + } + pseudo_client_op(OP_OPEN, PSEUDO_ACCESS(flags), rc, -1, path, &buf); + } else { + pseudo_debug(1, "open (fd %d, path %s, flags %d) succeeded, but stat failed (%s).\n", + rc, path, flags, strerror(errno)); + pseudo_client_op(OP_OPEN, PSEUDO_ACCESS(flags), rc, -1, path, 0); + } + errno = save_errno; + } + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/readlink.c b/ports/darwin/guts/readlink.c new file mode 100644 index 0000000..7de7586 --- /dev/null +++ b/ports/darwin/guts/readlink.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * ssize_t readlink(const char *path, char *buf, size_t bufsiz) + * ssize_t rc = -1; + */ + + rc = real_readlink(path, buf, bufsiz); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/rename.c b/ports/darwin/guts/rename.c new file mode 100644 index 0000000..a9b6bee --- /dev/null +++ b/ports/darwin/guts/rename.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int rename(const char *oldpath, const char *newpath) + * int rc = -1; + */ + + rc = real_rename(oldpath, newpath); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/rmdir.c b/ports/darwin/guts/rmdir.c new file mode 100644 index 0000000..43d7550 --- /dev/null +++ b/ports/darwin/guts/rmdir.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int rmdir(const char *path) + * int rc = -1; + */ + + rc = real_rmdir(path); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/scandir.c b/ports/darwin/guts/scandir.c new file mode 100644 index 0000000..6492b1b --- /dev/null +++ b/ports/darwin/guts/scandir.c @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2010 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * static int + * wrap_scandir(const char *path, struct dirent ***namelist, int (*filter)(struct dirent *), int (*compar)(const void *, const void *)) { + * int rc = -1; + */ + + rc = real_scandir(path, namelist, filter, compar); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/setxattr.c b/ports/darwin/guts/setxattr.c new file mode 100644 index 0000000..9458a69 --- /dev/null +++ b/ports/darwin/guts/setxattr.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int setxattr(const char *pathname, const char *name, const void *value, size_t size, int flags) + * int rc = -1; + */ + + rc = real_setxattr(pathname, name, value, size, flags); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/stat.c b/ports/darwin/guts/stat.c new file mode 100644 index 0000000..1e1cf67 --- /dev/null +++ b/ports/darwin/guts/stat.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int stat(const char *path, struct stat *buf) + * int rc = -1; + */ + + pseudo_msg_t *msg; + int save_errno; + + rc = real_stat(path, buf); + if (rc == -1) { + return rc; + } + save_errno = errno; + + /* query database + * note that symlink canonicalizing is now automatic, so we + * don't need to check for a symlink on this end + */ + msg = pseudo_client_op(OP_STAT, 0, -1, AT_FDCWD, path, buf); + if (msg) { + pseudo_stat_msg(buf, msg); + } + + errno = save_errno; + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/symlink.c b/ports/darwin/guts/symlink.c new file mode 100644 index 0000000..da0d703 --- /dev/null +++ b/ports/darwin/guts/symlink.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int symlink(const char *oldname, const char *newpath) + * int rc = -1; + */ + + rc = real_symlink(oldname, newpath); + +/* return rc; + * } + */ diff --git a/ports/darwin/guts/unlink.c b/ports/darwin/guts/unlink.c new file mode 100644 index 0000000..8bd6e6c --- /dev/null +++ b/ports/darwin/guts/unlink.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int unlink(const char *path) + * int rc = -1; + */ + + rc = real_unlink(path); + +/* return rc; + * } + */ |