[Fakeroot-commits] [SCM] fakeroot branch, upstream, updated. debian/1.14.3-200-gb232f8a

Clint Adams schizo at debian.org
Tue Aug 23 13:06:28 UTC 2011


The following commit has been merged in the upstream branch:
commit 2f70360974eb812af3b6abe2f12bc9267425ca44
Author: Clint Adams <schizo at debian.org>
Date:   Tue Oct 27 01:32:52 2009 -0400

    Apply patch (tweaked) from VMware: "Wrap *getattrlist() functions (Mac OS-specific, used on HFS+ filesystems)."

diff --git a/libfakeroot.c b/libfakeroot.c
index e10fa30..4ae3af4 100644
--- a/libfakeroot.c
+++ b/libfakeroot.c
@@ -156,6 +156,9 @@ void load_library_symbols(void);
 
 int fakeroot_disabled = 0;
 
+#ifdef __APPLE__
+#include "patchattr.h"
+#endif
 #include "wrapped.h"
 #include "wraptmpf.h"
 #include "wrapdef.h"
@@ -1426,3 +1429,61 @@ FTSENT *fts_children(FTS *ftsp, int options) {
   return first;
 }
 #endif /* HAVE_FTS_CHILDREN */
+
+#ifdef __APPLE__
+#ifdef __LP64__
+int
+getattrlist(const char *path, void *attrList, void *attrBuf,
+            size_t attrBufSize, unsigned int options)
+#else
+int
+getattrlist(const char *path, void *attrList, void *attrBuf,
+            size_t attrBufSize, unsigned long options)
+#endif
+{
+  int r;
+  struct stat st;
+
+  r=next_getattrlist(path, attrList, attrBuf, attrBufSize, options);
+  if (r) {
+    return r;
+  }
+  if (options & FSOPT_NOFOLLOW) {
+    r=lstat(path, &st);
+  } else {
+    r=stat(path, &st);
+  }
+  if (r) {
+    return r;
+  }
+  patchattr(attrList, attrBuf, st.st_uid, st.st_gid);
+
+  return 0;
+}
+
+#ifdef __LP64__
+int
+fgetattrlist(int fd, void *attrList, void *attrBuf,
+             size_t attrBufSize, unsigned int options)
+#else
+int
+fgetattrlist(int fd, void *attrList, void *attrBuf,
+             size_t attrBufSize, unsigned long options)
+#endif
+{
+  int r;
+  struct stat st;
+
+  r=next_fgetattrlist(fd, attrList, attrBuf, attrBufSize, options);
+  if (r) {
+    return r;
+  }
+  r=fstat(fd, &st);
+  if (r) {
+    return r;
+  }
+  patchattr(attrList, attrBuf, st.st_uid, st.st_gid);
+
+  return 0;
+}
+#endif /* ifdef __APPLE__ */
diff --git a/libfakeroot_unix2003.c b/libfakeroot_unix2003.c
index f8d0884..a77deb6 100644
--- a/libfakeroot_unix2003.c
+++ b/libfakeroot_unix2003.c
@@ -61,6 +61,7 @@
 #include <fts.h>
 #endif /* HAVE_FTS_H */
 
+#include "patchattr.h"
 #include "wrapped.h"
 
 extern int fakeroot_disabled;
@@ -160,4 +161,28 @@ int setregid(SETREGID_ARG rgid, SETREGID_ARG egid){
     return next_setregid$UNIX2003(rgid, egid);
   return set_faked_regid(rgid, egid);
 }
+
+int
+getattrlist(const char *path, void *attrList, void *attrBuf,
+            size_t attrBufSize, unsigned long options)
+{
+  int r;
+  struct stat st;
+
+  r=next_getattrlist$UNIX2003(path, attrList, attrBuf, attrBufSize, options);
+  if (r) {
+    return r;
+  }
+  if (options & FSOPT_NOFOLLOW) {
+    r=lstat(path, &st);
+  } else {
+    r=stat(path, &st);
+  }
+  if (r) {
+    return r;
+  }
+  patchattr(attrList, attrBuf, st.st_uid, st.st_gid);
+
+  return 0;
+}
 #endif /* if defined __APPLE__ && !defined __LP64__ */
diff --git a/patchattr.h b/patchattr.h
new file mode 100644
index 0000000..cad4693
--- /dev/null
+++ b/patchattr.h
@@ -0,0 +1,67 @@
+/*
+  Copyright: GPL. 
+  Author: regis duchesne  (hpreg at vmware.com)
+*/
+
+#include <sys/attr.h>
+#include <sys/mount.h>
+
+static void
+patchattr(void *attrList, void *attrBuf, uid_t uid, gid_t gid)
+{
+  /* Attributes, in the order in which they are returned (which is the same as
+     the order they are described in the man page).
+  */
+  static const struct {
+    u_int32_t value;
+    size_t size;
+  } attrs[] = {
+#define PATCHATTR(a,b) { a, b, }
+    PATCHATTR(ATTR_CMN_RETURNED_ATTRS, sizeof (attribute_set_t)),
+    PATCHATTR(ATTR_CMN_NAME, sizeof (attrreference_t)),
+    PATCHATTR(ATTR_CMN_DEVID, sizeof (dev_t)),
+    PATCHATTR(ATTR_CMN_FSID, sizeof (fsid_t)),
+    PATCHATTR(ATTR_CMN_OBJTYPE, sizeof (fsobj_type_t)),
+    PATCHATTR(ATTR_CMN_OBJTAG, sizeof (fsobj_tag_t)),
+    PATCHATTR(ATTR_CMN_OBJID, sizeof (fsobj_id_t)),
+    PATCHATTR(ATTR_CMN_OBJPERMANENTID, sizeof (fsobj_id_t)),
+    PATCHATTR(ATTR_CMN_PAROBJID, sizeof (fsobj_id_t)),
+    PATCHATTR(ATTR_CMN_SCRIPT, sizeof (text_encoding_t)),
+    PATCHATTR(ATTR_CMN_CRTIME, sizeof (struct timespec)),
+    PATCHATTR(ATTR_CMN_MODTIME, sizeof (struct timespec)),
+    PATCHATTR(ATTR_CMN_CHGTIME, sizeof (struct timespec)),
+    PATCHATTR(ATTR_CMN_ACCTIME, sizeof (struct timespec)),
+    PATCHATTR(ATTR_CMN_BKUPTIME, sizeof (struct timespec)),
+    PATCHATTR(ATTR_CMN_FNDRINFO, 32),
+    PATCHATTR(ATTR_CMN_OWNERID, sizeof (uid_t)),
+    PATCHATTR(ATTR_CMN_GRPID, sizeof (gid_t)),
+    PATCHATTR(ATTR_CMN_ACCESSMASK, sizeof (u_int32_t)),
+    PATCHATTR(ATTR_CMN_NAMEDATTRCOUNT, sizeof (u_int32_t)),
+    PATCHATTR(ATTR_CMN_NAMEDATTRLIST, sizeof (attrreference_t)),
+    PATCHATTR(ATTR_CMN_FLAGS, sizeof (u_int32_t)),
+    PATCHATTR(ATTR_CMN_USERACCESS, sizeof (u_int32_t)),
+    PATCHATTR(ATTR_CMN_EXTENDED_SECURITY, sizeof (attrreference_t)),
+    PATCHATTR(ATTR_CMN_UUID, sizeof (guid_t)),
+    PATCHATTR(ATTR_CMN_GRPUUID, sizeof (guid_t)),
+    PATCHATTR(ATTR_CMN_FILEID, sizeof (u_int64_t)),
+    PATCHATTR(ATTR_CMN_PARENTID, sizeof (u_int64_t)),
+    PATCHATTR(ATTR_CMN_FULLPATH, sizeof (attrreference_t)),
+#undef PATCHATTR
+  };
+  struct attrlist *l = attrList;
+  unsigned char *b = attrBuf;
+  unsigned i;
+
+  b += sizeof (u_int32_t);
+  for (i = 0; i < sizeof attrs / sizeof attrs[0]; i++) {
+    if (l->commonattr & attrs[i].value) {
+      if (attrs[i].value == ATTR_CMN_OWNERID) {
+        *(uid_t *)b = uid;
+      }
+      if (attrs[i].value == ATTR_CMN_GRPID) {
+        *(gid_t *)b = gid;
+      }
+      b += (attrs[i].size + 3) & ~3;
+    }
+  }
+}
diff --git a/wrapfunc.inp b/wrapfunc.inp
index e04a458..5e4bbda 100644
--- a/wrapfunc.inp
+++ b/wrapfunc.inp
@@ -33,6 +33,14 @@ WRAP_FSTATAT64;int;FSTATAT64_ARG(int ver, int dir_fd, const char *path, struct s
 #endif /* STAT64_SUPPORT */
 
 #ifdef __APPLE__
+#ifdef __LP64__
+getattrlist;int;(const char *path, void *attrList, void *attrBuf, size_t attrBufSize, unsigned int options);(path, attrList, attrBuf, attrBufSize, options)
+fgetattrlist;int;(int fd, void *attrList, void *attrBuf, size_t attrBufSize, unsigned int options);(fd, attrList, attrBuf, attrBufSize, options)
+#else
+getattrlist;int;(const char *path, void *attrList, void *attrBuf, size_t attrBufSize, unsigned long options);(path, attrList, attrBuf, attrBufSize, options)
+fgetattrlist;int;(int fd, void *attrList, void *attrBuf, size_t attrBufSize, unsigned long options);(fd, attrList, attrBuf, attrBufSize, options)
+getattrlist$UNIX2003;int;(const char *path, void *attrList, void *attrBuf, size_t attrBufSize, unsigned long options);(path, attrList, attrBuf, attrBufSize, options)
+#endif
 lstat$INODE64;int;(const char *file_name, struct stat *buf);(file_name, buf)
 stat$INODE64;int;(const char *file_name, struct stat *buf);(file_name, buf)
 fstat$INODE64;int;(int fd, struct stat *buf);(fd, buf)

-- 
fakeroot



More information about the Fakeroot-commits mailing list