Skip to content

Instantly share code, notes, and snippets.

@rlibby
Created April 19, 2011 03:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rlibby/926782 to your computer and use it in GitHub Desktop.
Save rlibby/926782 to your computer and use it in GitHub Desktop.
Patches squashfs4.2/squashfs-tools to compile cleanly under Cygwin. Based on this: http://comsul.blogspot.com/2008/12/squashfs-on-cygwin.html
diff -u original/squashfs4.2/squashfs-tools/mksquashfs.c patched/squashfs4.2/squashfs-tools/mksquashfs.c
--- original/squashfs4.2/squashfs-tools/mksquashfs.c 2011-02-28 14:24:09.000000000 -0800
+++ patched/squashfs4.2/squashfs-tools/mksquashfs.c 2011-04-18 19:42:17.042515000 -0700
@@ -51,10 +51,12 @@
#include <sys/wait.h>
#ifndef linux
+#ifndef __CYGWIN__
#define __BYTE_ORDER BYTE_ORDER
#define __BIG_ENDIAN BIG_ENDIAN
#define __LITTLE_ENDIAN LITTLE_ENDIAN
#include <sys/sysctl.h>
+#endif /* __CYGWIN__ */
#else
#include <endian.h>
#include <sys/sysinfo.h>
@@ -4062,6 +4064,9 @@
signal(SIGUSR1, sigusr1_handler);
+#ifdef __CYGWIN__
+ processors = atoi(getenv("NUMBER_OF_PROCESSORS"));
+#else
if(processors == -1) {
#ifndef linux
int mib[2];
@@ -4083,6 +4088,7 @@
processors = sysconf(_SC_NPROCESSORS_ONLN);
#endif
}
+#endif /* __CYGWIN__ */
thread = malloc((2 + processors * 2) * sizeof(pthread_t));
if(thread == NULL)
diff -u original/squashfs4.2/squashfs-tools/read_fs.c patched/squashfs4.2/squashfs-tools/read_fs.c
--- original/squashfs4.2/squashfs-tools/read_fs.c 2011-02-11 07:49:24.000000000 -0800
+++ patched/squashfs4.2/squashfs-tools/read_fs.c 2011-04-18 19:42:17.026897900 -0700
@@ -33,9 +33,11 @@
#include <sys/mman.h>
#ifndef linux
+#ifndef __CYGWIN__
#define __BYTE_ORDER BYTE_ORDER
#define __BIG_ENDIAN BIG_ENDIAN
#define __LITTLE_ENDIAN LITTLE_ENDIAN
+#endif /* __CYGWIN__ */
#else
#include <endian.h>
#endif
diff -u original/squashfs4.2/squashfs-tools/read_xattrs.c patched/squashfs4.2/squashfs-tools/read_xattrs.c
--- original/squashfs4.2/squashfs-tools/read_xattrs.c 2011-02-11 07:49:24.000000000 -0800
+++ patched/squashfs4.2/squashfs-tools/read_xattrs.c 2011-04-18 19:54:34.385093700 -0700
@@ -32,9 +32,11 @@
#include <string.h>
#ifndef linux
+#ifndef __CYGWIN__
#define __BYTE_ORDER BYTE_ORDER
#define __BIG_ENDIAN BIG_ENDIAN
#define __LITTLE_ENDIAN LITTLE_ENDIAN
+#endif /* __CYGWIN__ */
#else
#include <endian.h>
#endif
diff -u original/squashfs4.2/squashfs-tools/squashfs_fs.h patched/squashfs4.2/squashfs-tools/squashfs_fs.h
--- original/squashfs4.2/squashfs-tools/squashfs_fs.h 2011-02-11 07:49:24.000000000 -0800
+++ patched/squashfs4.2/squashfs-tools/squashfs_fs.h 2011-04-18 19:51:46.309356100 -0700
@@ -270,6 +270,10 @@
typedef long long squashfs_block;
typedef long long squashfs_inode;
+#ifdef __CYGWIN__
+#define FNM_EXTMATCH (1 << 5)
+#endif
+
#define ZLIB_COMPRESSION 1
#define LZMA_COMPRESSION 2
#define LZO_COMPRESSION 3
diff -u original/squashfs4.2/squashfs-tools/unsquashfs.c patched/squashfs4.2/squashfs-tools/unsquashfs.c
--- original/squashfs4.2/squashfs-tools/unsquashfs.c 2011-02-28 14:27:06.000000000 -0800
+++ patched/squashfs4.2/squashfs-tools/unsquashfs.c 2011-04-18 20:23:11.790227800 -0700
@@ -456,14 +456,22 @@
user = getpwuid(inode->uid);
if(user == NULL) {
+#ifdef __CYGWIN__
+ sprintf(dummy, "%lu", inode->uid);
+#else
sprintf(dummy, "%d", inode->uid);
+#endif /* __CYGWIN__ */
userstr = dummy;
} else
userstr = user->pw_name;
group = getgrgid(inode->gid);
if(group == NULL) {
+#ifdef __CYGWIN__
+ sprintf(dummy2, "%lu", inode->gid);
+#else
sprintf(dummy2, "%d", inode->gid);
+#endif /* __CYGWIN__ */
groupstr = dummy2;
} else
groupstr = group->gr_name;
@@ -1809,6 +1817,9 @@
EXIT_UNSQUASH("Failed to set signal mask in intialise_threads"
"\n");
+#ifdef __CYGWIN__
+ processors = atoi(getenv("NUMBER_OF_PROCESSORS"));
+#else /* __CYGWIN__ */
if(processors == -1) {
#ifndef linux
int mib[2];
@@ -1830,6 +1841,7 @@
processors = sysconf(_SC_NPROCESSORS_ONLN);
#endif
}
+#endif /* __CYGWIN__ */
thread = malloc((3 + processors) * sizeof(pthread_t));
if(thread == NULL)
diff -u original/squashfs4.2/squashfs-tools/unsquashfs.h patched/squashfs4.2/squashfs-tools/unsquashfs.h
--- original/squashfs4.2/squashfs-tools/unsquashfs.h 2011-02-11 07:49:24.000000000 -0800
+++ patched/squashfs4.2/squashfs-tools/unsquashfs.h 2011-04-18 19:53:10.627116100 -0700
@@ -46,9 +46,11 @@
#include <sys/time.h>
#ifndef linux
+#ifndef __CYGWIN__
#define __BYTE_ORDER BYTE_ORDER
#define __BIG_ENDIAN BIG_ENDIAN
#define __LITTLE_ENDIAN LITTLE_ENDIAN
+#endif /* __CYGWIN__ */
#else
#include <endian.h>
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment