summaryrefslogtreecommitdiff
path: root/patches
diff options
context:
space:
mode:
authorThomas Bächler <thomas@archlinux.org>2008-04-05 12:04:21 +0200
committerThomas Bächler <thomas@archlinux.org>2008-04-05 12:04:21 +0200
commit32c8c733f296ea76d599c0c90aff7307d85a4eb3 (patch)
tree7acd0f0d313f088d4e24179e5b04254f9b6868e3 /patches
Initial commit of the patch generation script and the patches used in 2.6.24.4-ARCH
Diffstat (limited to 'patches')
-rw-r--r--patches/2100_sd-sr-medium-detection.patch207
-rw-r--r--patches/2101_sr-follow-tray-status.patch119
-rw-r--r--patches/2102_sr-test-unit-ready.patch126
-rw-r--r--patches/2405_sis190-eeprom-mac.patch45
-rw-r--r--patches/2700_alsa-hda-lifebook-e8410.patch19
-rw-r--r--patches/acpi-buggy-bios.patch36
-rw-r--r--patches/acpi-dsdt-initrd-v0.8.4-2.6.21.patch275
-rw-r--r--patches/ata-2.6.24.patch102
-rw-r--r--patches/drm-spinlock-fix.patch196
-rw-r--r--patches/fix-capabilities.patch65
-rw-r--r--patches/fix-gcc43.patch11
-rw-r--r--patches/hanftek.patch11
-rw-r--r--patches/lhash-2.6.24.patch43
-rw-r--r--patches/linux-phc-0.3.0-kernel-vanilla-2.6.23rc3.patch530
-rw-r--r--patches/logo_linux_clut224.ppm883
-rw-r--r--patches/logo_linux_mono.pbm323
-rw-r--r--patches/logo_linux_vga16.ppm323
-rw-r--r--patches/mactel-linux-2.6.24.patch1266
-rw-r--r--patches/put_filp-2.6.24.patch16
-rw-r--r--patches/sec_perm-2.6.24.patch16
-rw-r--r--patches/sis671-intelgly-2.6.24.patch49
-rw-r--r--patches/squashfs3.3-patch4234
-rw-r--r--patches/toshiba-bluetooth.patch241
-rw-r--r--patches/usb-storage-unusual-devs.patch19
-rw-r--r--patches/winfast-2000.patch20
25 files changed, 9175 insertions, 0 deletions
diff --git a/patches/2100_sd-sr-medium-detection.patch b/patches/2100_sd-sr-medium-detection.patch
new file mode 100644
index 0000000..fe7006c
--- /dev/null
+++ b/patches/2100_sd-sr-medium-detection.patch
@@ -0,0 +1,207 @@
+From: James Bottomley <James.Bottomley@SteelEye.com>
+Date: Sun, 2 Dec 2007 17:10:40 +0000 (+0200)
+Subject: [SCSI] sd,sr: add early detection of medium not present
+X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=001aac257cf8adbe90cdcba6e07f8d12dfc8fa6b
+
+[SCSI] sd,sr: add early detection of medium not present
+
+The current scsi_test_unit_ready() is updated to return sense code
+information (in struct scsi_sense_hdr). The sd and sr drivers are
+changed to interpret the sense code return asc 0x3a as no media and
+adjust the device status accordingly.
+
+Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
+[dsd@gentoo.org: rediff for 2.6.24]
+---
+
+Index: linux-2.6.24-gentoo/drivers/scsi/scsi_ioctl.c
+===================================================================
+--- linux-2.6.24-gentoo.orig/drivers/scsi/scsi_ioctl.c
++++ linux-2.6.24-gentoo/drivers/scsi/scsi_ioctl.c
+@@ -239,7 +239,7 @@ int scsi_ioctl(struct scsi_device *sdev,
+ return scsi_set_medium_removal(sdev, SCSI_REMOVAL_ALLOW);
+ case SCSI_IOCTL_TEST_UNIT_READY:
+ return scsi_test_unit_ready(sdev, IOCTL_NORMAL_TIMEOUT,
+- NORMAL_RETRIES);
++ NORMAL_RETRIES, NULL);
+ case SCSI_IOCTL_START_UNIT:
+ scsi_cmd[0] = START_STOP;
+ scsi_cmd[1] = 0;
+Index: linux-2.6.24-gentoo/drivers/scsi/scsi_lib.c
+===================================================================
+--- linux-2.6.24-gentoo.orig/drivers/scsi/scsi_lib.c
++++ linux-2.6.24-gentoo/drivers/scsi/scsi_lib.c
+@@ -1981,27 +1981,57 @@ scsi_mode_sense(struct scsi_device *sdev
+ }
+ EXPORT_SYMBOL(scsi_mode_sense);
+
++/**
++ * scsi_test_unit_ready - test if unit is ready
++ * @sdev: scsi device to change the state of.
++ * @timeout: command timeout
++ * @retries: number of retries before failing
++ * @sshdr_external: Optional pointer to struct scsi_sense_hdr for
++ * returning sense. Make sure that this is cleared before passing
++ * in.
++ *
++ * Returns zero if unsuccessful or an error if TUR failed. For
++ * removable media, a return of NOT_READY or UNIT_ATTENTION is
++ * translated to success, with the ->changed flag updated.
++ **/
+ int
+-scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries)
++scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries,
++ struct scsi_sense_hdr *sshdr_external)
+ {
+ char cmd[] = {
+ TEST_UNIT_READY, 0, 0, 0, 0, 0,
+ };
+- struct scsi_sense_hdr sshdr;
++ struct scsi_sense_hdr *sshdr;
+ int result;
+-
+- result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, &sshdr,
+- timeout, retries);
++
++ if (!sshdr_external)
++ sshdr = kzalloc(sizeof(*sshdr), GFP_KERNEL);
++ else
++ sshdr = sshdr_external;
++
++ /* try to eat the UNIT_ATTENTION if there are enough retries */
++ do {
++ result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, sshdr,
++ timeout, retries);
++ } while ((driver_byte(result) & DRIVER_SENSE) &&
++ sshdr && sshdr->sense_key == UNIT_ATTENTION &&
++ --retries);
++
++ if (!sshdr)
++ /* could not allocate sense buffer, so can't process it */
++ return result;
+
+ if ((driver_byte(result) & DRIVER_SENSE) && sdev->removable) {
+
+- if ((scsi_sense_valid(&sshdr)) &&
+- ((sshdr.sense_key == UNIT_ATTENTION) ||
+- (sshdr.sense_key == NOT_READY))) {
++ if ((scsi_sense_valid(sshdr)) &&
++ ((sshdr->sense_key == UNIT_ATTENTION) ||
++ (sshdr->sense_key == NOT_READY))) {
+ sdev->changed = 1;
+ result = 0;
+ }
+ }
++ if (!sshdr_external)
++ kfree(sshdr);
+ return result;
+ }
+ EXPORT_SYMBOL(scsi_test_unit_ready);
+Index: linux-2.6.24-gentoo/drivers/scsi/sd.c
+===================================================================
+--- linux-2.6.24-gentoo.orig/drivers/scsi/sd.c
++++ linux-2.6.24-gentoo/drivers/scsi/sd.c
+@@ -736,6 +736,7 @@ static int sd_media_changed(struct gendi
+ {
+ struct scsi_disk *sdkp = scsi_disk(disk);
+ struct scsi_device *sdp = sdkp->device;
++ struct scsi_sense_hdr *sshdr = NULL;
+ int retval;
+
+ SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_media_changed\n"));
+@@ -762,8 +763,11 @@ static int sd_media_changed(struct gendi
+ * sd_revalidate() is called.
+ */
+ retval = -ENODEV;
+- if (scsi_block_when_processing_errors(sdp))
+- retval = scsi_test_unit_ready(sdp, SD_TIMEOUT, SD_MAX_RETRIES);
++ if (scsi_block_when_processing_errors(sdp)) {
++ sshdr = kzalloc(sizeof(*sshdr), GFP_KERNEL);
++ retval = scsi_test_unit_ready(sdp, SD_TIMEOUT, SD_MAX_RETRIES,
++ sshdr);
++ }
+
+ /*
+ * Unable to test, unit probably not ready. This usually
+@@ -771,7 +775,9 @@ static int sd_media_changed(struct gendi
+ * and we will figure it out later once the drive is
+ * available again.
+ */
+- if (retval)
++ if (retval || (scsi_sense_valid(sshdr) &&
++ /* 0x3a is medium not present */
++ sshdr->asc == 0x3a))
+ goto not_present;
+
+ /*
+@@ -784,10 +790,12 @@ static int sd_media_changed(struct gendi
+ retval = sdp->changed;
+ sdp->changed = 0;
+
++ kfree(sshdr);
+ return retval;
+
+ not_present:
+ set_media_not_present(sdkp);
++ kfree(sshdr);
+ return 1;
+ }
+
+Index: linux-2.6.24-gentoo/drivers/scsi/sr.c
+===================================================================
+--- linux-2.6.24-gentoo.orig/drivers/scsi/sr.c
++++ linux-2.6.24-gentoo/drivers/scsi/sr.c
+@@ -179,19 +179,26 @@ static int sr_media_change(struct cdrom_
+ {
+ struct scsi_cd *cd = cdi->handle;
+ int retval;
++ struct scsi_sense_hdr *sshdr;
+
+ if (CDSL_CURRENT != slot) {
+ /* no changer support */
+ return -EINVAL;
+ }
+
+- retval = scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES);
+- if (retval) {
+- /* Unable to test, unit probably not ready. This usually
+- * means there is no disc in the drive. Mark as changed,
+- * and we will figure it out later once the drive is
+- * available again. */
++ sshdr = kzalloc(sizeof(*sshdr), GFP_KERNEL);
++ retval = scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES,
++ sshdr);
++ if (retval || (scsi_sense_valid(sshdr) &&
++ /* 0x3a is medium not present */
++ sshdr->asc == 0x3a)) {
++ /* Media not present or unable to test, unit probably not
++ * ready. This usually means there is no disc in the drive.
++ * Mark as changed, and we will figure it out later once
++ * the drive is available again.
++ */
+ cd->device->changed = 1;
++ kfree(sshdr);
+ return 1; /* This will force a flush, if called from
+ * check_disk_change */
+ };
+@@ -206,6 +213,7 @@ static int sr_media_change(struct cdrom_
+
+ get_sectorsize(cd);
+ }
++ kfree(sshdr);
+ return retval;
+ }
+
+Index: linux-2.6.24-gentoo/include/scsi/scsi_device.h
+===================================================================
+--- linux-2.6.24-gentoo.orig/include/scsi/scsi_device.h
++++ linux-2.6.24-gentoo/include/scsi/scsi_device.h
+@@ -295,7 +295,7 @@ extern int scsi_mode_select(struct scsi_
+ struct scsi_mode_data *data,
+ struct scsi_sense_hdr *);
+ extern int scsi_test_unit_ready(struct scsi_device *sdev, int timeout,
+- int retries);
++ int retries, struct scsi_sense_hdr *sshdr);
+ extern int scsi_device_set_state(struct scsi_device *sdev,
+ enum scsi_device_state state);
+ extern struct scsi_event *sdev_evt_alloc(enum scsi_device_event evt_type,
diff --git a/patches/2101_sr-follow-tray-status.patch b/patches/2101_sr-follow-tray-status.patch
new file mode 100644
index 0000000..7c24314
--- /dev/null
+++ b/patches/2101_sr-follow-tray-status.patch
@@ -0,0 +1,119 @@
+From: James Bottomley <James.Bottomley@HansenPartnership.com>
+Date: Sat, 5 Jan 2008 16:39:51 +0000 (-0600)
+Subject: [SCSI] sr: update to follow tray status correctly
+X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=210ba1d1724f5c4ed87a2ab1a21ca861a915f734
+
+[SCSI] sr: update to follow tray status correctly
+
+Based on an original patch from: David Martin <tasio@tasio.net>
+
+When trying to get the drive status via ioctl CDROM_DRIVE_STATUS, with
+no disk it gives CDS_TRAY_OPEN even if the tray is closed.
+
+ioctl works as expected with ide-cd driver.
+
+Gentoo bug report: http://bugs.gentoo.org/show_bug.cgi?id=196879
+
+Cc: Maarten Bressers <mbres@gentoo.org>
+Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
+---
+
+diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
+index 896be4a..1fcee16 100644
+--- a/drivers/scsi/sr.c
++++ b/drivers/scsi/sr.c
+@@ -67,8 +67,6 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_WORM);
+
+ #define SR_DISKS 256
+
+-#define MAX_RETRIES 3
+-#define SR_TIMEOUT (30 * HZ)
+ #define SR_CAPABILITIES \
+ (CDC_CLOSE_TRAY|CDC_OPEN_TRAY|CDC_LOCK|CDC_SELECT_SPEED| \
+ CDC_SELECT_DISC|CDC_MULTI_SESSION|CDC_MCN|CDC_MEDIA_CHANGED| \
+diff --git a/drivers/scsi/sr.h b/drivers/scsi/sr.h
+index 0d04e28..81fbc0b 100644
+--- a/drivers/scsi/sr.h
++++ b/drivers/scsi/sr.h
+@@ -20,6 +20,9 @@
+ #include <linux/genhd.h>
+ #include <linux/kref.h>
+
++#define MAX_RETRIES 3
++#define SR_TIMEOUT (30 * HZ)
++
+ struct scsi_device;
+
+ /* The CDROM is fairly slow, so we need a little extra time */
+diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
+index e1589f9..d5cebff 100644
+--- a/drivers/scsi/sr_ioctl.c
++++ b/drivers/scsi/sr_ioctl.c
+@@ -275,18 +275,6 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
+ /* ---------------------------------------------------------------------- */
+ /* interface to cdrom.c */
+
+-static int test_unit_ready(Scsi_CD *cd)
+-{
+- struct packet_command cgc;
+-
+- memset(&cgc, 0, sizeof(struct packet_command));
+- cgc.cmd[0] = GPCMD_TEST_UNIT_READY;
+- cgc.quiet = 1;
+- cgc.data_direction = DMA_NONE;
+- cgc.timeout = IOCTL_TIMEOUT;
+- return sr_do_ioctl(cd, &cgc);
+-}
+-
+ int sr_tray_move(struct cdrom_device_info *cdi, int pos)
+ {
+ Scsi_CD *cd = cdi->handle;
+@@ -310,14 +298,46 @@ int sr_lock_door(struct cdrom_device_info *cdi, int lock)
+
+ int sr_drive_status(struct cdrom_device_info *cdi, int slot)
+ {
++ struct scsi_cd *cd = cdi->handle;
++ struct scsi_sense_hdr sshdr;
++ struct media_event_desc med;
++
+ if (CDSL_CURRENT != slot) {
+ /* we have no changer support */
+ return -EINVAL;
+ }
+- if (0 == test_unit_ready(cdi->handle))
++ if (0 == scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES,
++ &sshdr))
+ return CDS_DISC_OK;
+
+- return CDS_TRAY_OPEN;
++ if (!cdrom_get_media_event(cdi, &med)) {
++ if (med.media_present)
++ return CDS_DISC_OK;
++ else if (med.door_open)
++ return CDS_TRAY_OPEN;
++ else
++ return CDS_NO_DISC;
++ }
++
++ /*
++ * 0x04 is format in progress .. but there must be a disc present!
++ */
++ if (sshdr.sense_key == NOT_READY && sshdr.asc == 0x04)
++ return CDS_DISC_OK;
++
++ /*
++ * If not using Mt Fuji extended media tray reports,
++ * just return TRAY_OPEN since ATAPI doesn't provide
++ * any other way to detect this...
++ */
++ if (scsi_sense_valid(&sshdr) &&
++ /* 0x3a is medium not present */
++ sshdr.asc == 0x3a)
++ return CDS_NO_DISC;
++ else
++ return CDS_TRAY_OPEN;
++
++ return CDS_DRIVE_NOT_READY;
+ }
+
+ int sr_disk_status(struct cdrom_device_info *cdi)
diff --git a/patches/2102_sr-test-unit-ready.patch b/patches/2102_sr-test-unit-ready.patch
new file mode 100644
index 0000000..21c78ce
--- /dev/null
+++ b/patches/2102_sr-test-unit-ready.patch
@@ -0,0 +1,126 @@
+From: James Bottomley <James.Bottomley@HansenPartnership.com>
+Date: Wed, 6 Feb 2008 19:01:58 +0000 (-0600)
+Subject: [SCSI] sr: fix test unit ready responses
+X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Fjejb%2Fscsi-misc-2.6.git;a=commitdiff_plain;h=a827a50b0a2efb11ebb22fa22759e516574c1b1a
+
+[SCSI] sr: fix test unit ready responses
+
+Commit 210ba1d1724f5c4ed87a2ab1a21ca861a915f734 updated sr.c to use
+the scsi_test_unit_ready() function. Unfortunately, this has the
+wrong characteristic of eating NOT_READY returns which sr.c relies on
+for tray status.
+
+Fix by rolling an internal sr_test_unit_ready() that doesn't do this.
+
+Tested-by: Daniel Drake <dsd@gentoo.org>
+Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
+---
+
+diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
+index 50ba492..208565b 100644
+--- a/drivers/scsi/sr.c
++++ b/drivers/scsi/sr.c
+@@ -163,6 +163,29 @@ static void scsi_cd_put(struct scsi_cd *cd)
+ mutex_unlock(&sr_ref_mutex);
+ }
+
++/* identical to scsi_test_unit_ready except that it doesn't
++ * eat the NOT_READY returns for removable media */
++int sr_test_unit_ready(struct scsi_device *sdev, struct scsi_sense_hdr *sshdr)
++{
++ int retries = MAX_RETRIES;
++ int the_result;
++ u8 cmd[] = {TEST_UNIT_READY, 0, 0, 0, 0, 0 };
++
++ /* issue TEST_UNIT_READY until the initial startup UNIT_ATTENTION
++ * conditions are gone, or a timeout happens
++ */
++ do {
++ the_result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL,
++ 0, sshdr, SR_TIMEOUT,
++ retries--);
++
++ } while (retries > 0 &&
++ (!scsi_status_is_good(the_result) ||
++ (scsi_sense_valid(sshdr) &&
++ sshdr->sense_key == UNIT_ATTENTION)));
++ return the_result;
++}
++
+ /*
+ * This function checks to see if the media has been changed in the
+ * CDROM drive. It is possible that we have already sensed a change,
+@@ -185,8 +208,7 @@ static int sr_media_change(struct cdrom_device_info *cdi, int slot)
+ }
+
+ sshdr = kzalloc(sizeof(*sshdr), GFP_KERNEL);
+- retval = scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES,
+- sshdr);
++ retval = sr_test_unit_ready(cd->device, sshdr);
+ if (retval || (scsi_sense_valid(sshdr) &&
+ /* 0x3a is medium not present */
+ sshdr->asc == 0x3a)) {
+@@ -733,10 +755,8 @@ static void get_capabilities(struct scsi_cd *cd)
+ {
+ unsigned char *buffer;
+ struct scsi_mode_data data;
+- unsigned char cmd[MAX_COMMAND_SIZE];
+ struct scsi_sense_hdr sshdr;
+- unsigned int the_result;
+- int retries, rc, n;
++ int rc, n;
+
+ static const char *loadmech[] =
+ {
+@@ -758,23 +778,8 @@ static void get_capabilities(struct scsi_cd *cd)
+ return;
+ }
+
+- /* issue TEST_UNIT_READY until the initial startup UNIT_ATTENTION
+- * conditions are gone, or a timeout happens
+- */
+- retries = 0;
+- do {
+- memset((void *)cmd, 0, MAX_COMMAND_SIZE);
+- cmd[0] = TEST_UNIT_READY;
+-
+- the_result = scsi_execute_req (cd->device, cmd, DMA_NONE, NULL,
+- 0, &sshdr, SR_TIMEOUT,
+- MAX_RETRIES);
+-
+- retries++;
+- } while (retries < 5 &&
+- (!scsi_status_is_good(the_result) ||
+- (scsi_sense_valid(&sshdr) &&
+- sshdr.sense_key == UNIT_ATTENTION)));
++ /* eat unit attentions */
++ sr_test_unit_ready(cd->device, &sshdr);
+
+ /* ask for mode page 0x2a */
+ rc = scsi_mode_sense(cd->device, 0, 0x2a, buffer, 128,
+diff --git a/drivers/scsi/sr.h b/drivers/scsi/sr.h
+index 81fbc0b..1e144df 100644
+--- a/drivers/scsi/sr.h
++++ b/drivers/scsi/sr.h
+@@ -61,6 +61,7 @@ int sr_select_speed(struct cdrom_device_info *cdi, int speed);
+ int sr_audio_ioctl(struct cdrom_device_info *, unsigned int, void *);
+
+ int sr_is_xa(Scsi_CD *);
++int sr_test_unit_ready(struct scsi_device *sdev, struct scsi_sense_hdr *sshdr);
+
+ /* sr_vendor.c */
+ void sr_vendor_init(Scsi_CD *);
+diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
+index d5cebff..ae87d08 100644
+--- a/drivers/scsi/sr_ioctl.c
++++ b/drivers/scsi/sr_ioctl.c
+@@ -306,8 +306,7 @@ int sr_drive_status(struct cdrom_device_info *cdi, int slot)
+ /* we have no changer support */
+ return -EINVAL;
+ }
+- if (0 == scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES,
+- &sshdr))
++ if (0 == sr_test_unit_ready(cd->device, &sshdr))
+ return CDS_DISC_OK;
+
+ if (!cdrom_get_media_event(cdi, &med)) {
diff --git a/patches/2405_sis190-eeprom-mac.patch b/patches/2405_sis190-eeprom-mac.patch
new file mode 100644
index 0000000..989faa4
--- /dev/null
+++ b/patches/2405_sis190-eeprom-mac.patch
@@ -0,0 +1,45 @@
+From: Francois Romieu <romieu@fr.zoreil.com>
+Date: Mon, 18 Feb 2008 20:20:32 +0000 (+0100)
+Subject: sis190: read the mac address from the eeprom first
+X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Fjgarzik%2Fnetdev-2.6.git;a=commitdiff_plain;h=563e0ae06ff18f0b280f11cf706ba0172255ce52
+
+sis190: read the mac address from the eeprom first
+
+Reading a serie of zero from the cmos sram area do not work
+well with is_valid_ether_addr(). Let's read the mac address
+from the eeprom first as it seems more reliable.
+
+Fix for http://bugzilla.kernel.org/show_bug.cgi?id=9831
+
+Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
+Signed-off-by: Jeff Garzik <jeff@garzik.org>
+---
+
+diff --git a/drivers/net/sis190.c b/drivers/net/sis190.c
+index 202fdf3..20745fd 100644
+--- a/drivers/net/sis190.c
++++ b/drivers/net/sis190.c
+@@ -1633,13 +1633,18 @@ static inline void sis190_init_rxfilter(struct net_device *dev)
+ static int __devinit sis190_get_mac_addr(struct pci_dev *pdev,
+ struct net_device *dev)
+ {
+- u8 from;
++ int rc;
++
++ rc = sis190_get_mac_addr_from_eeprom(pdev, dev);
++ if (rc < 0) {
++ u8 reg;
+
+- pci_read_config_byte(pdev, 0x73, &from);
++ pci_read_config_byte(pdev, 0x73, &reg);
+
+- return (from & 0x00000001) ?
+- sis190_get_mac_addr_from_apc(pdev, dev) :
+- sis190_get_mac_addr_from_eeprom(pdev, dev);
++ if (reg & 0x00000001)
++ rc = sis190_get_mac_addr_from_apc(pdev, dev);
++ }
++ return rc;
+ }
+
+ static void sis190_set_speed_auto(struct net_device *dev)
diff --git a/patches/2700_alsa-hda-lifebook-e8410.patch b/patches/2700_alsa-hda-lifebook-e8410.patch
new file mode 100644
index 0000000..487496f
--- /dev/null
+++ b/patches/2700_alsa-hda-lifebook-e8410.patch
@@ -0,0 +1,19 @@
+hda-codec - Add Fujitsu Lifebook E8410 to quirk table
+
+From: Tony Vroon <chainsaw@gentoo.org>
+
+Add the proper model entry for Fujitsu Lifebook E8410 with ALC262 codec.
+http://hg-mirror.alsa-project.org/alsa-kernel/rev/f86467a0bc3b
+
+Index: linux-2.6.24-gentoo-r3/sound/pci/hda/patch_realtek.c
+===================================================================
+--- linux-2.6.24-gentoo-r3.orig/sound/pci/hda/patch_realtek.c
++++ linux-2.6.24-gentoo-r3/sound/pci/hda/patch_realtek.c
+@@ -8510,6 +8510,7 @@ static struct snd_pci_quirk alc262_cfg_t
+ SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
+ SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
+ SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
++ SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
+ SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
+ SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
+ SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
diff --git a/patches/acpi-buggy-bios.patch b/patches/acpi-buggy-bios.patch
new file mode 100644
index 0000000..3e1ac43
--- /dev/null
+++ b/patches/acpi-buggy-bios.patch
@@ -0,0 +1,36 @@
+---
+ drivers/acpi/processor_perflib.c | 11 +++++++++++
+ 1 files changed, 11 insertions(+)
+
+http://bugzilla.kernel.org/attachment.cgi?id=9798&action=view
+
+Index: linux-2.6.19/drivers/acpi/processor_perflib.c
+===================================================================
+--- linux-2.6.19.orig/drivers/acpi/processor_perflib.c 2006-12-25 15:40:47.000000000 +0800
++++ linux-2.6.19/drivers/acpi/processor_perflib.c 2006-12-26 09:20:14.000000000 +0800
+@@ -258,6 +258,7 @@ static int acpi_processor_get_performanc
+ for (i = 0; i < pr->performance->state_count; i++) {
+
+ struct acpi_processor_px *px = &(pr->performance->states[i]);
++ int j;
+
+ state.length = sizeof(struct acpi_processor_px);
+ state.pointer = px;
+@@ -273,6 +274,16 @@ static int acpi_processor_get_performanc
+ goto end;
+ }
+
++ /*
++ * Fixme: Duplicated core frequency is allowed, if they have the same control and status
++ */
++ if (px->core_frequency == 1992)
++ for (j = 0; j < i; j++) {
++ if (pr->performance->states[j].control == px->control && pr->performance->states[j].core_frequency > 1992)
++ ACPI_DEBUG_PRINT((ACPI_DB_WARN, "States [%d] :Wrong processor core frequency %u, set it to 1992\n", j, (u32)pr->performance->states[j].core_frequency));
++ pr->performance->states[j].core_frequency = 1992;
++ }
++
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+ "State [%d]: core_frequency[%d] power[%d] transition_latency[%d] bus_master_latency[%d] control[0x%x] status[0x%x]\n",
+ i,
+
diff --git a/patches/acpi-dsdt-initrd-v0.8.4-2.6.21.patch b/patches/acpi-dsdt-initrd-v0.8.4-2.6.21.patch
new file mode 100644
index 0000000..98794ed
--- /dev/null
+++ b/patches/acpi-dsdt-initrd-v0.8.4-2.6.21.patch
@@ -0,0 +1,275 @@
+diff -urpN -X linux-2.6.21/Documentation/dontdiff linux-2.6.21-rc4.bak/Documentation/dsdt-initrd.txt linux-2.6.21/Documentation/dsdt-initrd.txt
+--- linux-2.6.21-rc4.bak/Documentation/dsdt-initrd.txt 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.21/Documentation/dsdt-initrd.txt 2007-03-03 23:06:58.000000000 +0100
+@@ -0,0 +1,98 @@
++ACPI Custom DSDT read from initramfs
++
++2003 by Markuss Gaugusch < dsdt at gaugusch dot org >
++Special thanks go to Thomas Renninger from SuSE, who updated the patch for
++2.6.0 and later modified it to read inside initramfs
++2004 - 2007 maintained by Eric Piel < eric dot piel at tremplin-utc dot net >
++
++This option is intended for people who would like to hack their DSDT and don't want
++to recompile their kernel after every change. It can also be useful to distros
++which offers pre-compiled kernels and want to allow their users to use a
++modified DSDT. In the Kernel config, enable the initial RAM filesystem support
++(in Device Drivers|Block Devices) and enable ACPI_CUSTOM_DSDT_INITRD at the ACPI
++options (General Setup|ACPI Support|Read custom DSDT from initrd).
++
++A custom DSDT (Differentiated System Description Table) is useful when your
++computer uses ACPI but problems occur due to broken implementation. Typically,
++your computer works but there are some troubles with the hardware detection or
++the power management. You can check that troubles come from errors in the DSDT by
++activating the ACPI debug option and reading the logs. This table is provided
++by the BIOS, therefore it might be a good idea to check for BIOS update on your
++vendor website before going any further. Errors are often caused by vendors
++testing their hardware only with Windows or because there is code which is
++executed only on a specific OS with a specific version and Linux hasn't been
++considered during the development.
++
++Before you run away from customising your DSDT, you should note that already
++corrected tables are available for a fair amount of computers on this web-page:
++http://acpi.sf.net/dsdt . If you are part of the unluckies who cannot find
++their hardware in this database, you can modify your DSDT by yourself. This
++process is less painful than it sounds. Download the Intel ASL
++compiler/decompiler at http://www.intel.com/technology/IAPC/acpi/downloads.htm .
++As root, you then have to dump your DSDT and decompile it. By using the
++compiler messages as well as the kernel ACPI debug messages and the reference book
++(available at the Intel website and also at http://www.acpi.info), it is quite
++easy to obtain a fully working table.
++
++Once your new DSDT is ready you'll have to add it to an initrd so that the
++kernel can read the table at the very beginning of the boot. As the file has
++to be accessed very early during the boot process the initrd has to be an
++initramfs. The file is contained into the initramfs under the name /DSDT.aml .
++To obtain such an initrd, you might have to modify your mkinitrd script or you
++can add it later to the initrd with the script appended to this document. The
++command will look like:
++initrd-add-dsdt initrd.img my-dsdt.aml
++
++In case you don't use any initrd, the possibilities you have are to either start
++using one (try mkinitrd or yaird), or use the "Include Custom DSDT" configure
++option to directly include your DSDT inside the kernel.
++
++The message "Looking for DSDT in initramfs..." will tell you if the DSDT was
++found or not. If you need to update your DSDT, generate a new initrd and
++perform the steps above. Don't forget that with Lilo, you'll have to re-run it.
++
++
++======================= Here starts initrd-add-dsdt ===============================
++#!/bin/bash
++# Adds a DSDT file to the initrd (if it's an initramfs)
++# first argument is the name of archive
++# second argurment is the name of the file to add
++# The file will be copied as /DSDT.aml
++
++# 20060126: fix "Premature end of file" with some old cpio (Roland Robic)
++# 20060205: this time it should really work
++
++# check the arguments
++if [ $# -ne 2 ]; then
++ program_name=$(basename $0)
++ echo "\
++$program_name: too few arguments
++Usage: $program_name initrd-name.img DSDT-to-add.aml
++Adds a DSDT file to an initrd (in initramfs format)
++
++ initrd-name.img: filename of the initrd in initramfs format
++ DSDT-to-add.aml: filename of the DSDT file to add
++ " 1>&2
++ exit 1
++fi
++
++# we should check it's an initramfs
++
++tempcpio=$(mktemp -d)
++# cleanup on exit, hangup, interrupt, quit, termination
++trap 'rm -rf $tempcpio' 0 1 2 3 15
++
++# extract the archive
++gunzip -c "$1" > "$tempcpio"/initramfs.cpio || exit 1
++
++# copy the DSDT file at the root of the directory so that we can call it "/DSDT.aml"
++cp -f "$2" "$tempcpio"/DSDT.aml
++
++# add the file
++cd "$tempcpio"
++(echo DSDT.aml | cpio --quiet -H newc -o -A -O "$tempcpio"/initramfs.cpio) || exit 1
++cd "$OLDPWD"
++
++# re-compress the archive
++gzip -c "$tempcpio"/initramfs.cpio > "$1"
++
+diff -urpN -X linux-2.6.21/Documentation/dontdiff linux-2.6.21-rc4.bak/drivers/acpi/Kconfig linux-2.6.21/drivers/acpi/Kconfig
+--- linux-2.6.21-rc4.bak/drivers/acpi/Kconfig 2007-03-18 12:58:03.000000000 +0100
++++ linux-2.6.21/drivers/acpi/Kconfig 2007-03-17 01:28:53.000000000 +0100
+@@ -298,6 +298,23 @@ config ACPI_CUSTOM_DSDT_FILE
+ Enter the full path name to the file which includes the AmlCode
+ declaration.
+
++config ACPI_CUSTOM_DSDT_INITRD
++ bool "Read Custom DSDT from initramfs"
++ depends on BLK_DEV_INITRD
++ default y
++ help
++ The DSDT (Differentiated System Description Table) often needs to be
++ overridden because of broken BIOS implementations. If this feature is
++ activated you will be able to provide a customized DSDT by adding it
++ to your initramfs. For now you need to use a special mkinitrd tool.
++ For more details see <file:Documentation/dsdt-initrd.txt> or
++ <http://gaugusch.at/kernel.shtml>. If there is no table found, it
++ will fallback to the custom DSDT in-kernel (if activated) or to the
++ DSDT from the BIOS.
++
++ Even if you do not need a new one at the moment, you may want to use a
++ better implemented DSDT later. It is safe to say Y here.
++
+ config ACPI_BLACKLIST_YEAR
+ int "Disable ACPI for systems before Jan 1st this year" if X86_32
+ default 0
+diff -urpN -X linux-2.6.21/Documentation/dontdiff linux-2.6.21-rc4.bak/drivers/acpi/osl.c linux-2.6.21/drivers/acpi/osl.c
+--- linux-2.6.21-rc4.bak/drivers/acpi/osl.c 2007-03-18 12:55:13.000000000 +0100
++++ linux-2.6.21/drivers/acpi/osl.c 2007-03-17 10:26:06.000000000 +0100
+@@ -256,6 +256,67 @@ acpi_os_predefined_override(const struct
+ return AE_OK;
+ }
+
++#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD
++struct acpi_table_header * acpi_find_dsdt_initrd(void)
++{
++ struct file *firmware_file;
++ mm_segment_t oldfs;
++ unsigned long len, len2;
++ struct acpi_table_header *dsdt_buffer, *ret = NULL;
++ struct kstat stat;
++ /* maybe this could be an argument on the cmd line, but let's keep it simple for now */
++ char *ramfs_dsdt_name = "/DSDT.aml";
++
++ printk(KERN_INFO PREFIX "Looking for DSDT in initramfs... ");
++
++ /*
++ * Never do this at home, only the user-space is allowed to open a file.
++ * The clean way would be to use the firmware loader. But this code must be run
++ * before there is any userspace available. So we need a static/init firmware
++ * infrastructure, which doesn't exist yet...
++ */
++ if (vfs_stat(ramfs_dsdt_name, &stat) < 0) {
++ printk("error, file %s not found.\n", ramfs_dsdt_name);
++ return ret;
++ }
++
++ len = stat.size;
++ /* check especially against empty files */
++ if (len <= 4) {
++ printk("error file is too small, only %lu bytes.\n", len);
++ return ret;
++ }
++
++ firmware_file = filp_open(ramfs_dsdt_name, O_RDONLY, 0);
++ if (IS_ERR(firmware_file)) {
++ printk("error, could not open file %s.\n", ramfs_dsdt_name);
++ return ret;
++ }
++
++ dsdt_buffer = ACPI_ALLOCATE(len);
++ if (!dsdt_buffer) {
++ printk("error when allocating %lu bytes of memory.\n", len);
++ goto err;
++ }
++
++ oldfs = get_fs();
++ set_fs(KERNEL_DS);
++ len2 = vfs_read(firmware_file, (char __user *)dsdt_buffer, len, &firmware_file->f_pos);
++ set_fs(oldfs);
++ if (len2 < len) {
++ printk("error trying to read %lu bytes from %s.\n", len, ramfs_dsdt_name);
++ ACPI_FREE(dsdt_buffer);
++ goto err;
++ }
++
++ printk("successfully read %lu bytes from %s.\n", len, ramfs_dsdt_name);
++ ret = dsdt_buffer;
++err:
++ filp_close(firmware_file, NULL);
++ return ret;
++}
++#endif
++
+ acpi_status
+ acpi_os_table_override(struct acpi_table_header * existing_table,
+ struct acpi_table_header ** new_table)
+@@ -263,13 +324,18 @@ acpi_os_table_override(struct acpi_table
+ if (!existing_table || !new_table)
+ return AE_BAD_PARAMETER;
+
++ *new_table = NULL;
++
+ #ifdef CONFIG_ACPI_CUSTOM_DSDT
+ if (strncmp(existing_table->signature, "DSDT", 4) == 0)
+ *new_table = (struct acpi_table_header *)AmlCode;
+- else
+- *new_table = NULL;
+-#else
+- *new_table = NULL;
++#endif
++#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD
++ if (strncmp(existing_table->signature, "DSDT", 4) == 0) {
++ struct acpi_table_header* initrd_table = acpi_find_dsdt_initrd();
++ if (initrd_table)
++ *new_table = initrd_table;
++ }
+ #endif
+ return AE_OK;
+ }
+diff -urpN -X linux-2.6.21/Documentation/dontdiff linux-2.6.21-rc4.bak/init/initramfs.c linux-2.6.21/init/initramfs.c
+--- linux-2.6.21-rc4.bak/init/initramfs.c 2007-03-18 12:56:47.000000000 +0100
++++ linux-2.6.21/init/initramfs.c 2007-03-03 23:07:05.000000000 +0100
+@@ -541,6 +541,26 @@ skip:
+
+ #endif
+
++/* Tries to read the initramfs if it's already there, for ACPI Table Overiding */
++void __init early_populate_rootfs(void)
++{
++ char *err = unpack_to_rootfs(__initramfs_start,
++ __initramfs_end - __initramfs_start, 0);
++ if (err)
++ return;
++#ifdef CONFIG_BLK_DEV_INITRD
++ if (initrd_start) {
++ printk(KERN_INFO "Early unpacking initramfs...");
++ err = unpack_to_rootfs((char *)initrd_start,
++ initrd_end - initrd_start, 0);
++ if (err)
++ return;
++ printk(" done\n");
++ }
++#endif
++ return;
++}
++
+ static int __init populate_rootfs(void)
+ {
+ char *err = unpack_to_rootfs(__initramfs_start,
+diff -urpN -X linux-2.6.21/Documentation/dontdiff linux-2.6.21-rc4.bak/init/main.c linux-2.6.21/init/main.c
+--- linux-2.6.21-rc4.bak/init/main.c 2007-03-18 12:56:47.000000000 +0100
++++ linux-2.6.21/init/main.c 2007-03-03 23:07:05.000000000 +0100
+@@ -97,8 +97,10 @@ extern void free_initmem(void);
+ extern void prepare_namespace(void);
+ #ifdef CONFIG_ACPI
+ extern void acpi_early_init(void);
++extern void early_populate_rootfs(void);
+ #else
+ static inline void acpi_early_init(void) { }
++static inline void early_populate_rootfs(void) { }
+ #endif
+ #ifndef CONFIG_DEBUG_RODATA
+ static inline void mark_rodata_ro(void) { }
+@@ -635,6 +637,7 @@ asmlinkage void __init start_kernel(void
+
+ check_bugs();
+
++ early_populate_rootfs(); /* For DSDT override from initramfs */
+ acpi_early_init(); /* before LAPIC and SMP init */
+
+ /* Do the rest non-__init'ed, we're now alive */
diff --git a/patches/ata-2.6.24.patch b/patches/ata-2.6.24.patch
new file mode 100644
index 0000000..d97bb28
--- /dev/null
+++ b/patches/ata-2.6.24.patch
@@ -0,0 +1,102 @@
+diff --git a/linux-2.6.24-rc7/drivers/ata/libata-core.c
+b/linux-2.6.24-rc7-twam/drivers/ata/libata-core.c
+index 4753a18..ac5a0d4 100644
+--- a/linux-2.6.24-rc7/drivers/ata/libata-core.c
++++ b/linux-2.6.24-rc7-twam/drivers/ata/libata-core.c
+@@ -119,6 +119,10 @@ int libata_noacpi = 0;
+ module_param_named(noacpi, libata_noacpi, int, 0444);
+ MODULE_PARM_DESC(noacpi, "Disables the use of ACPI in probe/suspend/resume when set");
+
++int libata_force_cbl = 0;
++module_param_named(force_cbl, libata_force_cbl, int, 0644);
++MODULE_PARM_DESC(force_cbl, "force PATA cable type (0=keep, 40=40c, 80=80c)");
++
+ MODULE_AUTHOR("Jeff Garzik");
+ MODULE_DESCRIPTION("Library module for ATA devices");
+ MODULE_LICENSE("GPL");
+@@ -4318,16 +4322,29 @@ static void ata_dev_xfermask(struct ata_device *dev)
+ * drive side as well. Cases where we know a 40wire cable
+ * is used safely for 80 are not checked here.
+ */
+- if (xfer_mask & (0xF8 << ATA_SHIFT_UDMA))
+- /* UDMA/44 or higher would be available */
+- if ((ap->cbl == ATA_CBL_PATA40) ||
+- (ata_is_40wire(dev) &&
+- (ap->cbl == ATA_CBL_PATA_UNK ||
+- ap->cbl == ATA_CBL_PATA80))) {
+- ata_dev_printk(dev, KERN_WARNING,
+- "limited to UDMA/33 due to 40-wire cable\n");
+- xfer_mask &= ~(0xF8 << ATA_SHIFT_UDMA);
++ if (xfer_mask & (0xF8 << ATA_SHIFT_UDMA)) {
++ switch (libata_force_cbl) {
++ case 40:
++ /* limit to UDMA/33 */
++ ata_dev_printk(dev, KERN_INFO, "forcing 40c\n");
++ xfer_mask &= ~(0xF8 << ATA_SHIFT_UDMA);
++ break;
++ case 80:
++ /* ignore cable checks */
++ ata_dev_printk(dev, KERN_INFO, "forcing 80c\n");
++ break;
++ default:
++ /* UDMA/44 or higher would be available */
++ if ((ap->cbl == ATA_CBL_PATA40) ||
++ (ata_is_40wire(dev) &&
++ (ap->cbl == ATA_CBL_PATA_UNK ||
++ ap->cbl == ATA_CBL_PATA80))) {
++ ata_dev_printk(dev, KERN_WARNING,
++ "limited to UDMA/33 due to 40-wire cable\n");
++ xfer_mask &= ~(0xF8 << ATA_SHIFT_UDMA);
++ }
+ }
++ }
+
+ ata_unpack_xfermask(xfer_mask, &dev->pio_mask,
+ &dev->mwdma_mask, &dev->udma_mask);
+diff --git a/linux-2.6.24-rc7/drivers/ata/libata-eh.c
+b/linux-2.6.24-rc7-twam/drivers/ata/libata-eh.c
+index f0124a8..7c607e0 100644
+--- a/linux-2.6.24-rc7/drivers/ata/libata-eh.c
++++ b/linux-2.6.24-rc7-twam/drivers/ata/libata-eh.c
+@@ -2288,9 +2288,27 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
+
+ /* PDIAG- should have been released, ask cable type if post-reset */
+ if (ata_is_host_link(link) && ap->ops->cable_detect &&
+- (ehc->i.flags & ATA_EHI_DID_RESET))
++ (ehc->i.flags & ATA_EHI_DID_RESET)) {
+ ap->cbl = ap->ops->cable_detect(ap);
+
++ if (!(ap->flags & ATA_FLAG_SATA) && libata_force_cbl) {
++ switch (libata_force_cbl) {
++ case 40:
++ ata_port_printk(ap, KERN_INFO, "forcing 40c\n");
++ ap->cbl = ATA_CBL_PATA40;
++ break;
++ case 80:
++ ata_port_printk(ap, KERN_INFO, "forcing 80c\n");
++ ap->cbl = ATA_CBL_PATA80;
++ break;
++ default:
++ ata_port_printk(ap, KERN_WARNING,
++ "invalid force_cbl value %d\n",
++ libata_force_cbl);
++ }
++ }
++ }
++
+ /* Configure new devices forward such that user doesn't see
+ * device detection messages backwards.
+ */
+diff --git a/linux-2.6.24-rc7/drivers/ata/libata.h
+b/linux-2.6.24-rc7-twam/drivers/ata/libata.h
+index bbe59c2..b990a8d 100644
+--- a/linux-2.6.24-rc7/drivers/ata/libata.h
++++ b/linux-2.6.24-rc7-twam/drivers/ata/libata.h
+@@ -60,6 +60,7 @@ extern int atapi_dmadir;
+ extern int atapi_passthru16;
+ extern int libata_fua;
+ extern int libata_noacpi;
++extern int libata_force_cbl;
+ extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev);
+ extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
+ u64 block, u32 n_block, unsigned int tf_flags,
diff --git a/patches/drm-spinlock-fix.patch b/patches/drm-spinlock-fix.patch
new file mode 100644
index 0000000..92993c3
--- /dev/null
+++ b/patches/drm-spinlock-fix.patch
@@ -0,0 +1,196 @@
+
+drm: Fix spinlock race condition that can lockup the kernel
+
+From: Mike Isely <isely@pobox.com>
+
+The i915_vblank_swap() function schedules an automatic buffer swap
+upon receipt of the vertical sync interrupt. Such an operation is
+lengthy so it can't happen normal interrupt context, so the DRM
+implements this by scheduling the work in a kernel softirq-scheduled
+tasklet. In order for the buffer swap to work safely, the DRM's
+central lock must be taken, via a call to drm_lock_take() in drm_irq.c
+within the function drm_locked_tasklet_func(). The lock-taking logic
+uses a non-interrupt-blocking spinlock to implement the manipulations
+needed to take the lock. Note that a non-interrupt-blocking spinlock
+blocks kernel pre-emption and atomically sets a flag, but interrupts
+are still enabled. This semantic is safe if ALL attempts to use the
+spinlock only happen from process context. However this buffer swap
+happens from softirq context which is really a form of interrupt
+context that WILL pre-empt execution even when normal thread
+pre-emption is otherwise disabled. Thus we have an unsafe situation,
+in that drm_locked_tasklet_func() can block on a spinlock already
+taken by a thread in process context which will never get scheduled
+again because of the blocked softirq tasklet. This wedges the kernel
+hard.
+
+It's a very small race condition, but a race nonetheless with a very
+undesirable potential outcome. To trigger this bug, run a dual-head
+cloned mode configuration which uses the i915 drm, then execute an
+opengl application which synchronizes buffer swaps against the
+vertical sync interrupt. In my testing, a lockup always results after
+running anywhere from 5 minutes to an hour and a half. I believe
+dual-head is needed to really trigger the problem because then the
+vertical sync interrupt handling is no longer predictable (due to
+being interrupt-sourced from two different heads running at different
+speeds). This raises the probability of a the tasklet trying to run
+while the userspace DRI is doing things to the GPU (and manipulating
+the DRM lock).
+
+The fix is to change the relevant spinlock semantics to be the
+interrupt-blocking form. Thus all calls for this spinlock change from
+spin_lock() to spin_lock_irqsave() and similarly calls to
+spin_unlock() change to spin_unlock_irqrestore(). After this change I
+am no longer able to trigger the lockup; the longest test run so far
+was 6 hours (test stopped after that point).
+
+Signed-off-by: Mike Isely <isely@pobox.com>
+
+---
+
+ drivers/char/drm/drm_fops.c | 5 ++--
+ drivers/char/drm/drm_lock.c | 35 +++++++++++++++++++---------------
+ 2 files changed, 23 insertions(+), 17 deletions(-)
+
+diff -uprN -X linux-2.6.24.3/Documentation/dontdiff linux-2.6.24.3/drivers/char/drm/drm_fops.c linux-2.6.24.3-drm-spinlock-fix/drivers/char/drm/drm_fops.c
+--- linux-2.6.24.3/drivers/char/drm/drm_fops.c 2008-02-25 18:20:20.000000000 -0600
++++ linux-2.6.24.3-drm-spinlock-fix/drivers/char/drm/drm_fops.c 2008-03-06 15:23:26.000000000 -0600
+@@ -326,6 +326,7 @@ int drm_release(struct inode *inode, str
+ struct drm_file *file_priv = filp->private_data;
+ struct drm_device *dev = file_priv->head->dev;
+ int retcode = 0;
++ unsigned long irqflags;
+
+ lock_kernel();
+
+@@ -357,9 +358,9 @@ int drm_release(struct inode *inode, str
+ */
+
+ do{
+- spin_lock(&dev->lock.spinlock);
++ spin_lock_irqsave(&dev->lock.spinlock, irqflags);
+ locked = dev->lock.idle_has_lock;
+- spin_unlock(&dev->lock.spinlock);
++ spin_unlock_irqrestore(&dev->lock.spinlock, irqflags);
+ if (locked)
+ break;
+ schedule();
+diff -uprN -X linux-2.6.24.3/Documentation/dontdiff linux-2.6.24.3/drivers/char/drm/drm_lock.c linux-2.6.24.3-drm-spinlock-fix/drivers/char/drm/drm_lock.c
+--- linux-2.6.24.3/drivers/char/drm/drm_lock.c 2008-02-25 18:20:20.000000000 -0600
++++ linux-2.6.24.3-drm-spinlock-fix/drivers/char/drm/drm_lock.c 2008-03-06 15:23:34.000000000 -0600
+@@ -53,6 +53,7 @@ int drm_lock(struct drm_device *dev, voi
+ DECLARE_WAITQUEUE(entry, current);
+ struct drm_lock *lock = data;
+ int ret = 0;
++ unsigned long irqflags;
+
+ ++file_priv->lock_count;
+
+@@ -71,9 +72,9 @@ int drm_lock(struct drm_device *dev, voi
+ return -EINVAL;
+
+ add_wait_queue(&dev->lock.lock_queue, &entry);
+- spin_lock(&dev->lock.spinlock);
++ spin_lock_irqsave(&dev->lock.spinlock, irqflags);
+ dev->lock.user_waiters++;
+- spin_unlock(&dev->lock.spinlock);
++ spin_unlock_irqrestore(&dev->lock.spinlock, irqflags);
+ for (;;) {
+ __set_current_state(TASK_INTERRUPTIBLE);
+ if (!dev->lock.hw_lock) {
+@@ -95,9 +96,9 @@ int drm_lock(struct drm_device *dev, voi
+ break;
+ }
+ }
+- spin_lock(&dev->lock.spinlock);
++ spin_lock_irqsave(&dev->lock.spinlock, irqflags);
+ dev->lock.user_waiters--;
+- spin_unlock(&dev->lock.spinlock);
++ spin_unlock_irqrestore(&dev->lock.spinlock, irqflags);
+ __set_current_state(TASK_RUNNING);
+ remove_wait_queue(&dev->lock.lock_queue, &entry);
+
+@@ -198,8 +199,9 @@ int drm_lock_take(struct drm_lock_data *
+ {
+ unsigned int old, new, prev;
+ volatile unsigned int *lock = &lock_data->hw_lock->lock;
++ unsigned long irqflags;
+
+- spin_lock(&lock_data->spinlock);
++ spin_lock_irqsave(&lock_data->spinlock, irqflags);
+ do {
+ old = *lock;
+ if (old & _DRM_LOCK_HELD)
+@@ -211,7 +213,7 @@ int drm_lock_take(struct drm_lock_data *
+ }
+ prev = cmpxchg(lock, old, new);
+ } while (prev != old);
+- spin_unlock(&lock_data->spinlock);
++ spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
+
+ if (_DRM_LOCKING_CONTEXT(old) == context) {
+ if (old & _DRM_LOCK_HELD) {
+@@ -272,15 +274,16 @@ int drm_lock_free(struct drm_lock_data *
+ {
+ unsigned int old, new, prev;
+ volatile unsigned int *lock = &lock_data->hw_lock->lock;
++ unsigned long irqflags;
+
+- spin_lock(&lock_data->spinlock);
++ spin_lock_irqsave(&lock_data->spinlock, irqflags);
+ if (lock_data->kernel_waiters != 0) {
+ drm_lock_transfer(lock_data, 0);
+ lock_data->idle_has_lock = 1;
+- spin_unlock(&lock_data->spinlock);
++ spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
+ return 1;
+ }
+- spin_unlock(&lock_data->spinlock);
++ spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
+
+ do {
+ old = *lock;
+@@ -344,19 +347,20 @@ static int drm_notifier(void *priv)
+ void drm_idlelock_take(struct drm_lock_data *lock_data)
+ {
+ int ret = 0;
++ unsigned long irqflags;
+
+- spin_lock(&lock_data->spinlock);
++ spin_lock_irqsave(&lock_data->spinlock, irqflags);
+ lock_data->kernel_waiters++;
+ if (!lock_data->idle_has_lock) {
+
+- spin_unlock(&lock_data->spinlock);
++ spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
+ ret = drm_lock_take(lock_data, DRM_KERNEL_CONTEXT);
+- spin_lock(&lock_data->spinlock);
++ spin_lock_irqsave(&lock_data->spinlock, irqflags);
+
+ if (ret == 1)
+ lock_data->idle_has_lock = 1;
+ }
+- spin_unlock(&lock_data->spinlock);
++ spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
+ }
+ EXPORT_SYMBOL(drm_idlelock_take);
+
+@@ -364,8 +368,9 @@ void drm_idlelock_release(struct drm_loc
+ {
+ unsigned int old, prev;
+ volatile unsigned int *lock = &lock_data->hw_lock->lock;
++ unsigned long irqflags;
+
+- spin_lock(&lock_data->spinlock);
++ spin_lock_irqsave(&lock_data->spinlock, irqflags);
+ if (--lock_data->kernel_waiters == 0) {
+ if (lock_data->idle_has_lock) {
+ do {
+@@ -376,7 +381,7 @@ void drm_idlelock_release(struct drm_loc
+ lock_data->idle_has_lock = 0;
+ }
+ }
+- spin_unlock(&lock_data->spinlock);
++ spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
+ }
+ EXPORT_SYMBOL(drm_idlelock_release);
+
diff --git a/patches/fix-capabilities.patch b/patches/fix-capabilities.patch
new file mode 100644
index 0000000..2b01bb0
--- /dev/null
+++ b/patches/fix-capabilities.patch
@@ -0,0 +1,65 @@
+From: Serge Hallyn <serge@hallyn.com>
+Date: Fri, 29 Feb 2008 15:14:57 +0000 (+0000)
+Subject: file capabilities: remove cap_task_kill()
+X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=aedb60a67c10a0861af179725d060765262ba0fb
+
+file capabilities: remove cap_task_kill()
+
+The original justification for cap_task_kill() was as follows:
+
+ check_kill_permission() does appropriate uid equivalence checks.
+ However with file capabilities it becomes possible for an
+ unprivileged user to execute a file with file capabilities
+ resulting in a more privileged task with the same uid.
+
+However now that cap_task_kill() always returns 0 (permission
+granted) when p->uid==current->uid, the whole hook is worthless,
+and only likely to create more subtle problems in the corner cases
+where it might still be called but return -EPERM. Those cases
+are basically when uids are different but euid/suid is equivalent
+as per the check in check_kill_permission().
+
+One example of a still-broken application is 'at' for non-root users.
+
+This patch removes cap_task_kill().
+
+Signed-off-by: Serge Hallyn <serge@hallyn.com>
+Acked-by: Andrew G. Morgan <morgan@kernel.org>
+Earlier-version-tested-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
+Acked-by: Casey Schaufler <casey@schaufler-ca.com>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+---
+
+diff --git a/include/linux/security.h b/include/linux/security.h
+index b07357c..c673dfd 100644
+--- a/include/linux/security.h
++++ b/include/linux/security.h
+@@ -57,7 +57,6 @@ extern int cap_inode_need_killpriv(struct dentry *dentry);
+ extern int cap_inode_killpriv(struct dentry *dentry);
+ extern int cap_task_post_setuid (uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags);
+ extern void cap_task_reparent_to_init (struct task_struct *p);
+-extern int cap_task_kill(struct task_struct *p, struct siginfo *info, int sig, u32 secid);
+ extern int cap_task_setscheduler (struct task_struct *p, int policy, struct sched_param *lp);
+ extern int cap_task_setioprio (struct task_struct *p, int ioprio);
+ extern int cap_task_setnice (struct task_struct *p, int nice);
+@@ -2187,7 +2186,7 @@ static inline int security_task_kill (struct task_struct *p,
+ struct siginfo *info, int sig,
+ u32 secid)
+ {
+- return cap_task_kill(p, info, sig, secid);
++ return 0;
+ }
+
+ static inline int security_task_wait (struct task_struct *p)
+diff --git a/security/capability.c b/security/capability.c
+index 9e99f36..2c6e06d 100644
+--- a/security/capability.c
++++ b/security/capability.c
+@@ -40,7 +40,6 @@ static struct security_operations capability_ops = {
+ .inode_need_killpriv = cap_inode_need_killpriv,
+ .inode_killpriv = cap_inode_killpriv,
+
+- .task_kill = cap_task_kill,
+ .task_setscheduler = cap_task_setscheduler,
+ .task_setioprio = cap_task_setioprio,
+ .task_setnice = cap_task_setnice,
diff --git a/patches/fix-gcc43.patch b/patches/fix-gcc43.patch
new file mode 100644
index 0000000..37ca018
--- /dev/null
+++ b/patches/fix-gcc43.patch
@@ -0,0 +1,11 @@
+--- linux-2.6.24.noarch.orig/include/linux/time.h
++++ linux-2.6.24.noarch/include/linux/time.h
+@@ -169,7 +169,7 @@ extern struct timeval ns_to_timeval(cons
+ * @a: pointer to timespec to be incremented
+ * @ns: unsigned nanoseconds value to be added
+ */
+-static inline void timespec_add_ns(struct timespec *a, u64 ns)
++static inline void timespec_add_ns(struct timespec *a, volatile u64 ns)
+ {
+ ns += a->tv_nsec;
+ while(unlikely(ns >= NSEC_PER_SEC)) {
diff --git a/patches/hanftek.patch b/patches/hanftek.patch
new file mode 100644
index 0000000..30831ab
--- /dev/null
+++ b/patches/hanftek.patch
@@ -0,0 +1,11 @@
+--- linux-2.6.24.pristine/drivers/media/dvb/dvb-usb/umt-010.c 2008-02-15 17:02:15.000000000 +0100
++++ linux-2.6.24/drivers/media/dvb/dvb-usb/umt-010.c 2008-02-15 17:02:21.000000000 +0100
+@@ -104,7 +104,7 @@
+ /* parameter for the MPEG2-data transfer */
+ .stream = {
+ .type = USB_BULK,
+- .count = 20,
++ .count = 10,
+ .endpoint = 0x06,
+ .u = {
+ .bulk = { \ No newline at end of file
diff --git a/patches/lhash-2.6.24.patch b/patches/lhash-2.6.24.patch
new file mode 100644
index 0000000..208e33c
--- /dev/null
+++ b/patches/lhash-2.6.24.patch
@@ -0,0 +1,43 @@
+Index: linux-2.6.22/fs/namei.c
+===================================================================
+RCS file: /ext1/sysadm/transparent/repository/linux-2.6.22/fs/namei.c,v
+retrieving revision 1.1
+retrieving revision 1.3
+diff -u -p -r1.1 -r1.3
+--- linux-2.6.24/fs/namei.c 12 Jul 2007 02:55:19 -0000 1.1
++++ linux-2.6.24/fs/namei.c 12 Jul 2007 03:00:50 -0000 1.3
+@@ -1289,8 +1289,8 @@
+ return err;
+ }
+
+-static struct dentry *__lookup_hash(struct qstr *name,
+- struct dentry *base, struct nameidata *nd)
++struct dentry * __lookup_hash(struct qstr *name,
++ struct dentry *base, struct nameidata *nd)
+ {
+ struct dentry *dentry;
+ struct inode *inode;
+@@ -2766,6 +2766,7 @@ EXPORT_SYMBOL(follow_up);
+ EXPORT_SYMBOL(get_write_access); /* binfmt_aout */
+ EXPORT_SYMBOL(getname);
+ EXPORT_SYMBOL(lock_rename);
++EXPORT_SYMBOL(__lookup_hash);
+ EXPORT_SYMBOL(lookup_one_len);
+ EXPORT_SYMBOL(page_follow_link_light);
+ EXPORT_SYMBOL(page_put_link);
+Index: linux-2.6.22/include/linux/namei.h
+===================================================================
+RCS file: /ext1/sysadm/transparent/repository/linux-2.6.22/include/linux/namei.h,v
+retrieving revision 1.1
+retrieving revision 1.2
+diff -u -p -r1.1 -r1.2
+--- linux-2.6.22/include/linux/namei.h 12 Jul 2007 02:55:19 -0000 1.1
++++ linux-2.6.22/include/linux/namei.h 12 Jul 2007 02:55:20 -0000 1.2
+@@ -81,6 +81,7 @@ extern struct file *lookup_instantiate_f
+ extern struct file *nameidata_to_filp(struct nameidata *nd, int flags);
+ extern void release_open_intent(struct nameidata *);
+
++struct dentry * __lookup_hash(struct qstr *name, struct dentry * base, struct nameidata *nd);
+ extern struct dentry *lookup_one_len(const char *, struct dentry *, int);
+ extern struct dentry *lookup_one_noperm(const char *, struct dentry *);
+
diff --git a/patches/linux-phc-0.3.0-kernel-vanilla-2.6.23rc3.patch b/patches/linux-phc-0.3.0-kernel-vanilla-2.6.23rc3.patch
new file mode 100644
index 0000000..215cd08
--- /dev/null
+++ b/patches/linux-phc-0.3.0-kernel-vanilla-2.6.23rc3.patch
@@ -0,0 +1,530 @@
+diff --new-file -a --unified=5 --recursive linux-2.6.23-rc3/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c linux-source-2.6.23-rc3/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
+--- linux-2.6.23-rc3/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c 2007-08-13 06:25:24.000000000 +0200
++++ linux-source-2.6.23-rc3/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c 2007-08-14 15:33:30.000000000 +0200
+@@ -23,10 +23,15 @@
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
++/* This file has been patched with Linux PHC: https://www.dedigentoo.org/trac/linux-phc
++ * Patch version: linux-phc-0.3.0-kernel-vanilla-2.6.23.patch
++ */
++
++
+ #include <linux/kernel.h>
+ #include <linux/module.h>
+ #include <linux/init.h>
+ #include <linux/smp.h>
+ #include <linux/sched.h>
+@@ -57,16 +62,22 @@
+ };
+
+ #define INTEL_MSR_RANGE (0xffff)
+ #define CPUID_6_ECX_APERFMPERF_CAPABILITY (0x1)
+
++#define INTEL_MSR_VID_MASK (0x00ff)
++#define INTEL_MSR_FID_MASK (0xff00)
++#define INTEL_MSR_FID_SHIFT (0x8)
++#define PHC_VERSION_STRING "0.3.0"
++
+ struct acpi_cpufreq_data {
+ struct acpi_processor_performance *acpi_data;
+ struct cpufreq_frequency_table *freq_table;
+ unsigned int max_freq;
+ unsigned int resume;
+ unsigned int cpu_feature;
++ acpi_integer *original_controls;
+ };
+
+ static struct acpi_cpufreq_data *drv_data[NR_CPUS];
+ /* acpi_perf_data is a pointer to percpu data. */
+ static struct acpi_processor_performance *acpi_perf_data;
+@@ -101,17 +112,19 @@
+ }
+
+ static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data)
+ {
+ int i;
++ u32 fid;
+ struct acpi_processor_performance *perf;
+
+- msr &= INTEL_MSR_RANGE;
++ fid = msr & INTEL_MSR_FID_MASK;
+ perf = data->acpi_data;
+
+ for (i=0; data->freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {
+- if (msr == perf->states[data->freq_table[i].index].status)
++ if (fid == (perf->states[data->freq_table[i].index].status &
++ INTEL_MSR_FID_MASK))
+ return data->freq_table[i].frequency;
+ }
+ return data->freq_table[0].frequency;
+ }
+
+@@ -729,10 +742,12 @@
+ if (data) {
+ cpufreq_frequency_table_put_attr(policy->cpu);
+ drv_data[policy->cpu] = NULL;
+ acpi_processor_unregister_performance(data->acpi_data,
+ policy->cpu);
++ if (data->original_controls)
++ kfree(data->original_controls);
+ kfree(data);
+ }
+
+ return 0;
+ }
+@@ -746,12 +761,452 @@
+ data->resume = 1;
+
+ return 0;
+ }
+
++
++
++
++/* sysfs interface to change operating points voltages */
++
++static unsigned int extract_fid_from_control(unsigned int control)
++{
++ return ((control & INTEL_MSR_FID_MASK) >> INTEL_MSR_FID_SHIFT);
++}
++
++static unsigned int extract_vid_from_control(unsigned int control)
++{
++ return (control & INTEL_MSR_VID_MASK);
++}
++
++static ssize_t check_origial_table (struct acpi_cpufreq_data *data)
++{
++ struct acpi_processor_performance *acpi_data;
++ struct cpufreq_frequency_table *freq_table;
++ unsigned int state_index;
++
++ acpi_data = data->acpi_data;
++ freq_table = data->freq_table;
++
++ if (data->original_controls == NULL) {
++ // Backup original control values
++ data->original_controls = kcalloc(acpi_data->state_count,
++ sizeof(acpi_integer), GFP_KERNEL);
++ if (data->original_controls == NULL) {
++ printk("failed to allocate memory for original control values\n");
++ return -ENOMEM;
++ }
++ for (state_index = 0; state_index < acpi_data->state_count; state_index++) {
++ data->original_controls[state_index] = acpi_data->states[state_index].control;
++ }
++ }
++ return 0;
++}
++
++static ssize_t show_freq_attr_vids(struct cpufreq_policy *policy, char *buf)
++{
++ struct acpi_cpufreq_data *data = drv_data[policy->cpu];
++ struct acpi_processor_performance *acpi_data;
++ struct cpufreq_frequency_table *freq_table;
++ unsigned int i;
++ unsigned int vid;
++ ssize_t count = 0;
++
++ if (unlikely(data == NULL ||
++ data->acpi_data == NULL ||
++ data->freq_table == NULL ||
++ data->cpu_feature != SYSTEM_INTEL_MSR_CAPABLE)) {
++ return -ENODEV;
++ }
++
++ acpi_data = data->acpi_data;
++ freq_table = data->freq_table;
++
++ for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {
++ vid = extract_vid_from_control(acpi_data->states[freq_table[i].index].control);
++ count += sprintf(&buf[count], "%u ", vid);
++ }
++ count += sprintf(&buf[count], "\n");
++
++ return count;
++}
++
++static ssize_t show_freq_attr_default_vids(struct cpufreq_policy *policy, char *buf)
++{
++ struct acpi_cpufreq_data *data = drv_data[policy->cpu];
++ struct cpufreq_frequency_table *freq_table;
++ unsigned int i;
++ unsigned int vid;
++ ssize_t count = 0;
++ ssize_t retval;
++
++ if (unlikely(data == NULL ||
++ data->acpi_data == NULL ||
++ data->freq_table == NULL ||
++ data->cpu_feature != SYSTEM_INTEL_MSR_CAPABLE)) {
++ return -ENODEV;
++ }
++
++ retval = check_origial_table(data);
++ if (0 != retval)
++ return retval;
++
++ freq_table = data->freq_table;
++
++ for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {
++ vid = extract_vid_from_control(data->original_controls[freq_table[i].index]);
++ count += sprintf(&buf[count], "%u ", vid);
++ }
++ count += sprintf(&buf[count], "\n");
++
++ return count;
++}
++
++static ssize_t show_freq_attr_fids(struct cpufreq_policy *policy, char *buf)
++{
++ struct acpi_cpufreq_data *data = drv_data[policy->cpu];
++ struct acpi_processor_performance *acpi_data;
++ struct cpufreq_frequency_table *freq_table;
++ unsigned int i;
++ unsigned int fid;
++ ssize_t count = 0;
++
++ if (unlikely(data == NULL ||
++ data->acpi_data == NULL ||
++ data->freq_table == NULL ||
++ data->cpu_feature != SYSTEM_INTEL_MSR_CAPABLE)) {
++ return -ENODEV;
++ }
++
++ acpi_data = data->acpi_data;
++ freq_table = data->freq_table;
++
++ for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {
++ fid = extract_fid_from_control(acpi_data->states[freq_table[i].index].control);
++ count += sprintf(&buf[count], "%u ", fid);
++ }
++ count += sprintf(&buf[count], "\n");
++
++ return count;
++}
++
++static ssize_t show_freq_attr_controls(struct cpufreq_policy *policy, char *buf)
++{
++ struct acpi_cpufreq_data *data = drv_data[policy->cpu];
++ struct acpi_processor_performance *acpi_data;
++ struct cpufreq_frequency_table *freq_table;
++ unsigned int i;
++ unsigned int fid;
++ unsigned int vid;
++ ssize_t count = 0;
++
++ if (unlikely(data == NULL ||
++ data->acpi_data == NULL ||
++ data->freq_table == NULL ||
++ data->cpu_feature != SYSTEM_INTEL_MSR_CAPABLE)) {
++ return -ENODEV;
++ }
++
++ acpi_data = data->acpi_data;
++ freq_table = data->freq_table;
++
++ for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {
++ fid = extract_fid_from_control(acpi_data->states[freq_table[i].index].control);
++ vid = extract_vid_from_control(acpi_data->states[freq_table[i].index].control);
++ count += sprintf(&buf[count], "%u:%u ", fid, vid);
++ }
++ count += sprintf(&buf[count], "\n");
++
++ return count;
++}
++
++static ssize_t show_freq_attr_default_controls(struct cpufreq_policy *policy, char *buf)
++{
++ struct acpi_cpufreq_data *data = drv_data[policy->cpu];
++ struct cpufreq_frequency_table *freq_table;
++ unsigned int i;
++ unsigned int fid;
++ unsigned int vid;
++ ssize_t count = 0;
++ ssize_t retval;
++
++ if (unlikely(data == NULL ||
++ data->acpi_data == NULL ||
++ data->freq_table == NULL ||
++ data->cpu_feature != SYSTEM_INTEL_MSR_CAPABLE)) {
++ return -ENODEV;
++ }
++
++ retval = check_origial_table(data);
++ if (0 != retval)
++ return retval;
++
++ freq_table = data->freq_table;
++
++ for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {
++ fid = extract_fid_from_control(data->original_controls[freq_table[i].index]);
++ vid = extract_vid_from_control(data->original_controls[freq_table[i].index]);
++ count += sprintf(&buf[count], "%u:%u ", fid, vid);
++ }
++ count += sprintf(&buf[count], "\n");
++
++ return count;
++}
++
++
++static ssize_t store_freq_attr_vids(struct cpufreq_policy *policy, const char *buf, size_t count)
++{
++ struct acpi_cpufreq_data *data = drv_data[policy->cpu];
++ struct acpi_processor_performance *acpi_data;
++ struct cpufreq_frequency_table *freq_table;
++ unsigned int freq_index;
++ unsigned int state_index;
++ unsigned int new_vid;
++ unsigned int original_vid;
++ unsigned int new_control;
++ unsigned int original_control;
++ const char *curr_buf = buf;
++ char *next_buf;
++ ssize_t retval;
++
++ if (unlikely(data == NULL ||
++ data->acpi_data == NULL ||
++ data->freq_table == NULL ||
++ data->cpu_feature != SYSTEM_INTEL_MSR_CAPABLE)) {
++ return -ENODEV;
++ }
++
++ retval = check_origial_table(data);
++ if (0 != retval)
++ return retval;
++
++ acpi_data = data->acpi_data;
++ freq_table = data->freq_table;
++
++ for (freq_index = 0; freq_table[freq_index].frequency != CPUFREQ_TABLE_END; freq_index++) {
++ new_vid = simple_strtoul(curr_buf, &next_buf, 10);
++ if (next_buf == curr_buf) {
++ if ((curr_buf - buf == count - 1) && (*curr_buf == '\n')) {
++ curr_buf++;
++ break;
++ }
++ printk("failed to parse vid value at %i (%s)\n", freq_index, curr_buf);
++ return -EINVAL;
++ }
++
++ state_index = freq_table[freq_index].index;
++ original_control = data->original_controls[state_index];
++ original_vid = original_control & INTEL_MSR_VID_MASK;
++ if (new_vid <= original_vid) {
++ new_control = (original_control & ~INTEL_MSR_VID_MASK) | new_vid;
++ dprintk("setting control at %i to %x (default is %x)\n",
++ freq_index, new_control, original_control);
++ acpi_data->states[state_index].control = new_control;
++
++ } else {
++ printk("skipping vid at %i, %u is greater than default %u\n",
++ freq_index, new_vid, original_vid);
++ }
++
++ curr_buf = next_buf;
++ while ((curr_buf - buf < count) && ((*curr_buf == ' ') || (*curr_buf == ','))) {
++ curr_buf++;
++ }
++ }
++
++ /* set new voltage at current frequency */
++ data->resume = 1;
++ acpi_cpufreq_target(policy, get_cur_freq_on_cpu(policy->cpu), CPUFREQ_RELATION_L);
++
++ return curr_buf - buf;
++}
++
++static ssize_t store_freq_attr_controls(struct cpufreq_policy *policy, const char *buf, size_t count)
++{
++ struct acpi_cpufreq_data *data = drv_data[policy->cpu];
++ struct acpi_processor_performance *acpi_data;
++ struct cpufreq_frequency_table *freq_table;
++ const char *curr_buf;
++ unsigned int op_count;
++ unsigned int state_index;
++ int isok;
++ char *next_buf;
++ ssize_t retval;
++ unsigned int new_vid;
++ unsigned int original_vid;
++ unsigned int new_fid;
++ unsigned int old_fid;
++ unsigned int original_control;
++ unsigned int old_control;
++ unsigned int new_control;
++ int found;
++
++ if (unlikely(data == NULL ||
++ data->acpi_data == NULL ||
++ data->freq_table == NULL ||
++ data->cpu_feature != SYSTEM_INTEL_MSR_CAPABLE)) {
++ return -ENODEV;
++ }
++
++ retval = check_origial_table(data);
++ if (0 != retval)
++ return retval;
++
++ acpi_data = data->acpi_data;
++ freq_table = data->freq_table;
++
++ op_count = 0;
++ curr_buf = buf;
++ next_buf = NULL;
++ isok = 1;
++
++ while ( (isok) && (curr_buf != NULL) )
++ {
++ op_count++;
++ // Parse fid
++ new_fid = simple_strtoul(curr_buf, &next_buf, 10);
++ if ((next_buf != curr_buf) && (next_buf != NULL))
++ {
++ // Parse separator between frequency and voltage
++ curr_buf = next_buf;
++ next_buf = NULL;
++ if (*curr_buf==':')
++ {
++ curr_buf++;
++ // Parse vid
++ new_vid = simple_strtoul(curr_buf, &next_buf, 10);
++ if ((next_buf != curr_buf) && (next_buf != NULL))
++ {
++ found = 0;
++ for (state_index = 0; state_index < acpi_data->state_count; state_index++) {
++ old_control = acpi_data->states[state_index].control;
++ old_fid = extract_fid_from_control(old_control);
++ if (new_fid == old_fid)
++ {
++ found = 1;
++ original_control = data->original_controls[state_index];
++ original_vid = extract_vid_from_control(original_control);
++ if (new_vid <= original_vid)
++ {
++ new_control = (original_control & ~INTEL_MSR_VID_MASK) | new_vid;
++ dprintk("setting control at %i to %x (default is %x)\n",
++ state_index, new_control, original_control);
++ acpi_data->states[state_index].control = new_control;
++
++ } else {
++ printk("skipping vid at %i, %u is greater than default %u\n",
++ state_index, new_vid, original_vid);
++ }
++ }
++ }
++
++ if (found == 0)
++ {
++ printk("operating point # %u not found (FID = %u)\n", op_count, new_fid);
++ isok = 0;
++ }
++
++ // Parse seprator before next operating point, if any
++ curr_buf = next_buf;
++ next_buf = NULL;
++ if ((*curr_buf == ',') || (*curr_buf == ' '))
++ curr_buf++;
++ else
++ curr_buf = NULL;
++ }
++ else
++ {
++ printk("failed to parse VID of operating point # %u (%s)\n", op_count, curr_buf);
++ isok = 0;
++ }
++ }
++ else
++ {
++ printk("failed to parse operating point # %u (%s)\n", op_count, curr_buf);
++ isok = 0;
++ }
++ }
++ else
++ {
++ printk("failed to parse FID of operating point # %u (%s)\n", op_count, curr_buf);
++ isok = 0;
++ }
++ }
++
++ if (isok)
++ {
++ retval = count;
++ /* set new voltage at current frequency */
++ data->resume = 1;
++ acpi_cpufreq_target(policy, get_cur_freq_on_cpu(policy->cpu), CPUFREQ_RELATION_L);
++ }
++ else
++ {
++ retval = -EINVAL;
++ }
++
++ return retval;
++}
++
++static ssize_t show_freq_attr_phc_version(struct cpufreq_policy *policy, char *buf)
++{
++ ssize_t count = 0;
++ count += sprintf(&buf[count], "%s\n", PHC_VERSION_STRING);
++ return count;
++}
++
++static struct freq_attr cpufreq_freq_attr_phc_version =
++{
++ .attr = { .name = "phc_version", .mode = 0444, .owner = THIS_MODULE },
++ .show = show_freq_attr_phc_version,
++ .store = NULL,
++};
++
++static struct freq_attr cpufreq_freq_attr_vids =
++{
++ .attr = { .name = "phc_vids", .mode = 0644, .owner = THIS_MODULE },
++ .show = show_freq_attr_vids,
++ .store = store_freq_attr_vids,
++};
++
++static struct freq_attr cpufreq_freq_attr_default_vids =
++{
++ .attr = { .name = "phc_default_vids", .mode = 0444, .owner = THIS_MODULE },
++ .show = show_freq_attr_default_vids,
++ .store = NULL,
++};
++
++static struct freq_attr cpufreq_freq_attr_fids =
++{
++ .attr = { .name = "phc_fids", .mode = 0444, .owner = THIS_MODULE },
++ .show = show_freq_attr_fids,
++ .store = NULL,
++};
++
++static struct freq_attr cpufreq_freq_attr_controls =
++{
++ .attr = { .name = "phc_controls", .mode = 0644, .owner = THIS_MODULE },
++ .show = show_freq_attr_controls,
++ .store = store_freq_attr_controls,
++};
++
++static struct freq_attr cpufreq_freq_attr_default_controls =
++{
++ .attr = { .name = "phc_default_controls", .mode = 0444, .owner = THIS_MODULE },
++ .show = show_freq_attr_default_controls,
++ .store = NULL,
++};
++
++
+ static struct freq_attr *acpi_cpufreq_attr[] = {
++ &cpufreq_freq_attr_phc_version,
+ &cpufreq_freq_attr_scaling_available_freqs,
++ &cpufreq_freq_attr_vids,
++ &cpufreq_freq_attr_default_vids,
++ &cpufreq_freq_attr_fids,
++ &cpufreq_freq_attr_controls,
++ &cpufreq_freq_attr_default_controls,
+ NULL,
+ };
+
+ static struct cpufreq_driver acpi_cpufreq_driver = {
+ .verify = acpi_cpufreq_verify,
diff --git a/patches/logo_linux_clut224.ppm b/patches/logo_linux_clut224.ppm
new file mode 100644
index 0000000..524d022
--- /dev/null
+++ b/patches/logo_linux_clut224.ppm
@@ -0,0 +1,883 @@
+P3
+80 80
+255
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 32 44
+9 36 51 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 34 98 130
+51 116 148 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 13 19 43 149 202
+77 164 208 12 23 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 14 66 93 70 168 217
+73 170 219 46 89 110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 46 133 178 72 170 218
+71 169 219 91 165 202 1 6 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 36 51 70 168 217 73 170 219
+71 169 219 91 178 222 27 58 72 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 34 98 130 74 171 219 73 170 219
+73 170 219 82 175 221 71 136 167 3 6 8 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 3 16 22 67 158 204 75 171 219 74 171 219
+74 171 219 75 171 219 105 185 225 20 41 51 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 29 73 94 74 171 219 75 171 219 76 172 219
+75 171 219 75 171 219 95 181 223 62 117 146 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 3 6 7 46 133 178 78 172 220 77 172 220 77 172 220
+77 172 220 76 172 219 88 177 222 95 170 207 12 24 31 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 12 46 63 76 170 216 79 173 220 78 173 220 78 172 220
+78 172 220 78 172 220 81 174 221 105 185 225 46 89 110 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 51 116 148 80 174 220 80 174 220 79 173 220 79 173 220
+78 173 220 78 173 220 78 172 220 99 182 224 91 165 202 2 8 11 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 8 27 36 72 166 212 81 174 221 81 174 221 80 174 220 80 174 220
+80 174 220 79 173 220 79 173 220 88 177 222 105 185 225 29 73 94 1 1 1 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 2 3 39 93 119 83 175 221 83 175 221 82 175 221 82 175 221 81 174 221
+81 174 221 80 174 220 80 174 220 84 174 220 108 186 226 73 152 191 2 4 5 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 3 12 16 67 158 204 85 176 221 84 175 221 83 175 221 83 175 221 83 175 221
+82 175 221 82 175 221 81 174 221 81 174 221 99 182 224 108 186 226 22 48 61 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 1 2 29 73 94 87 176 221 86 176 221 85 176 221 85 176 221 84 175 221 84 175 221
+83 175 221 83 175 221 83 175 221 82 175 221 87 176 221 110 187 226 71 136 167 1 3 4
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+2 8 11 68 147 187 85 176 221 86 176 221 86 176 221 86 176 221 86 176 221 85 176 221
+85 176 221 84 175 221 84 175 221 83 175 221 84 175 221 103 184 225 102 182 223 19 37 46
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+27 58 72 84 174 220 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 85 176 221 85 176 221 84 175 221 91 178 222 110 188 227 62 117 146
+0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2
+61 131 166 83 175 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 110 187 226 97 173 211
+11 26 33 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 20 41 51
+83 172 216 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 99 182 224 113 189 227
+50 102 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 39 93 119
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 89 177 222 111 188 227
+97 173 211 6 14 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 16 21
+65 134 168 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 102 182 223
+112 189 227 42 89 113 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 3 6 8 0 0 0
+6 14 19 65 134 168 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 89 177 222
+111 188 227 95 170 207 5 14 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 26 33 73 152 191 22 48 61
+0 1 1 5 12 15 65 134 168 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+99 182 224 113 189 227 42 89 113 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 50 104 131 86 176 221 82 169 212
+42 89 113 5 12 15 5 12 15 59 124 156 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+89 177 222 111 188 227 91 165 202 6 17 23 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 11 26 33 77 164 208 86 176 221 86 176 221
+87 176 221 68 147 187 22 48 61 5 10 13 50 104 131 85 175 219 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 99 182 224 112 188 227 42 89 113 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 50 104 131 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 85 175 219 59 124 156 20 41 51 29 73 94 83 169 213 87 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 88 177 222 111 188 227 91 165 202 6 16 21 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 14 28 34 83 168 211 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 83 169 213 59 124 156 40 85 109 73 152 191
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 99 182 224 112 188 227 42 89 113 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 50 104 131 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 87 176 221 83 172 216 73 152 191
+82 169 212 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 88 177 221 110 187 226 93 168 206 3 12 16 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 12 23 29 83 169 213 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 95 181 223 112 189 227 40 85 109 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 1 1 1 55 107 134 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 87 176 221 105 185 225 93 168 206 6 14 19 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 14 28 34 83 168 211 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 91 178 222 112 188 227 42 89 113 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 2 55 107 134 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 102 182 223 91 165 202 6 17 23
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+19 37 46 83 169 213 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 88 177 222 110 187 226 46 89 110
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
+62 117 146 85 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 86 176 221 86 176 221 86 176 221 82 174 220 71 169 219 59 164 216 46 158 213
+42 156 213 37 153 212 33 152 211 32 151 211 32 151 211 33 152 211 39 155 212 46 158 213
+54 161 215 63 165 217 72 170 218 84 174 220 86 176 221 86 176 221 95 181 223 95 170 207
+7 16 21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 20 41 51
+83 169 213 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221
+86 176 221 78 173 220 59 164 216 39 155 212 28 149 210 24 147 209 23 147 209 24 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 24 148 209 28 149 210 39 155 212 54 161 215 74 170 219 105 185 225
+47 93 116 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 63 128 161
+86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 86 176 221 83 175 221 66 167 217
+42 156 213 26 149 210 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 24 148 209 38 154 212
+72 166 212 6 17 23 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 20 41 51 85 175 219
+86 176 221 86 176 221 86 176 221 86 176 221 83 175 221 59 164 216 32 151 211 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+37 153 212 34 98 130 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 4 5 61 131 166 87 176 221
+86 176 221 86 176 221 82 174 220 54 161 215 29 150 210 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 43 149 202 8 27 36 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 22 48 61 85 175 219 86 176 221
+84 175 221 63 165 217 32 151 211 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 26 149 210 34 98 130 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 3 6 7 65 134 168 88 177 222 71 169 219
+38 154 212 24 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 29 150 210 8 32 44 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 27 58 72 76 170 216 46 158 213 24 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 146 207 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 24 147 209 23 146 207 17 106 151 0 1 1 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 1 6 8 46 133 178 24 148 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 22 144 204 15 94 133 6 37 53 2 12 16
+1 8 11 6 37 53 15 94 133 22 144 204 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 24 147 209 23 144 204 9 36 51 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 9 59 84 23 146 208 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 21 135 192 7 44 62 0 2 2 0 0 0 0 0 0
+0 0 0 0 0 0 0 2 2 7 44 62 21 135 192 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 17 110 156 0 2 2 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 1 8 11 20 131 186 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 22 140 198 6 38 54 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 6 38 54 22 140 198 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 146 208 7 42 60 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 11 73 105 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 146 208 10 66 94 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 66 94 23 146 208 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 18 116 165 1 5 7 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 3 18 26 21 135 193 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 18 116 166 0 3 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 4 18 116 166 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 146 208 8 51 72 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 1 1 14 86 123 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 146 207 8 50 71 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 50 71 23 146 207
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 19 120 171 1 7 11
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+4 27 39 22 140 198 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+20 127 180 1 6 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 6 8 20 127 180
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 146 208 9 59 84
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1
+16 101 144 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+13 85 121 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 13 85 121
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 20 129 184
+1 8 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 38 54
+22 144 204 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+7 42 60 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 42 60
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 146 208
+11 70 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 4 17 111 157
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 22 142 202
+3 18 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 18 25
+22 142 202 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 146 208 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+21 133 189 2 12 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 48 68 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 20 127 181
+1 9 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 9 12
+20 127 181 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 22 142 202 17 106 151 17 110 156 22 143 203 23 147 209 23 147 209 23 147 209
+23 147 209 12 75 107 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 7 11 19 122 173 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 18 116 165
+0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2
+18 116 165 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 146 207 16 101 144 5 34 49 9 59 84 17 108 154 22 143 203
+23 147 209 21 136 193 3 19 27 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 63 89 23 146 208 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 17 111 157
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+17 111 157 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 22 140 198 12 80 113 2 13 19 4 25 35
+13 85 121 21 135 192 13 85 121 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 2 13 19 20 129 184 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 17 107 152
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+17 107 152 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 19 119 169 5 34 49
+0 1 1 3 18 26 12 75 107 3 17 25 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 12 76 107 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 17 110 156
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+17 110 156 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 22 142 202
+12 75 107 1 3 5 0 0 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 3 18 25 22 140 198 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 18 118 167
+0 2 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 3
+18 118 167 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 17 107 152 3 17 24 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 1 2 14 89 127 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 20 129 183
+1 9 13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 9 13
+20 129 183 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 20 127 180 5 34 49 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 4 27 39 22 142 202 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 145 207 21 135 192
+3 17 24 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 17 24
+21 135 192 23 145 207 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 22 139 198 9 57 81 0 2 2 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 2 3 16 101 144 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 22 143 203 17 111 157 11 71 102 6 38 54 2 10 14
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+2 10 14 6 38 54 11 71 102 17 108 154 22 142 202 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 146 207 13 83 118 1 3 5 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 6 41 58 23 145 206 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+22 139 198 16 101 144 8 51 72 2 12 16 0 2 2 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 1 2 2 12 16 8 50 71 15 100 141 22 138 196
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 146 207 8 50 71 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 4 6 17 113 161 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 144 204 19 121 172 10 66 94
+3 19 27 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 18 25
+10 65 92 19 120 171 23 144 204 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 19 120 171 1 6 9
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+8 52 74 23 145 207 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 21 137 195 14 89 127 6 36 52 1 4 6 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 1 3 5 6 36 52 14 89 127 21 137 195 23 147 209 23 147 209 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 146 207 9 59 84
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 5 7
+20 127 180 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+23 147 209 20 130 185 11 70 100 2 10 15 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 2 10 14 11 70 100 20 129 183 23 147 209
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 20 131 186
+1 7 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 66 94
+23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 19 125 178
+10 63 89 1 9 13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 9 12 10 63 89
+19 125 178 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209 23 147 209
+11 71 102 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 13 19 21 133 189
+23 147 209 23 147 209 23 147 209 23 147 209 23 146 207 19 122 173 9 57 81 1 9 12
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 8 11 9 57 81 19 122 173 23 146 207 23 147 209 23 147 209 23 147 209 23 147 209
+21 135 192 3 16 22 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 80 113 23 147 209
+23 147 209 23 147 209 23 146 208 19 125 178 8 52 74 1 6 8 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 1 6 9 8 52 74 19 125 178 23 146 208 23 147 209 23 147 209
+23 147 209 13 83 118 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 21 31 22 138 196 23 147 209
+23 147 209 20 130 185 10 63 89 1 4 6 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 1 4 6 10 63 89 20 130 185 23 147 209
+23 147 209 22 139 198 4 25 35 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 15 94 133 23 147 209 21 137 195
+12 76 107 2 12 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 12 17 12 76 107
+21 137 195 23 147 209 15 94 133 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 5 32 45 21 135 193 14 92 130 3 21 31
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+3 21 31 14 92 130 21 136 193 5 32 45 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 10 64 91 5 31 44 0 1 1 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 1 1 5 31 44 10 65 92 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
diff --git a/patches/logo_linux_mono.pbm b/patches/logo_linux_mono.pbm
new file mode 100644
index 0000000..1535936
--- /dev/null
+++ b/patches/logo_linux_mono.pbm
@@ -0,0 +1,323 @@
+P2
+80 80
+255
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 255 255 255 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 255 255 255 255 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 255 255 255 255 255 255 255 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 255 255 255 255 255 255 255 255 255 0 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255
+255 255 255 255 255 255 255 255 255 0 0 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 0 0 255 255 255 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 255 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 0 0 0 0
+0 0
+0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 0 0 0 0
+0 0
+0 0 0 0 0 0 0 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 0 0 0
+0 0
+0 0 0 0 0 0 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 0 0 0
+0 0
+0 0 0 0 0 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 0 0
+0 0
+0 0 0 0 0 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 0 0
+0 0
+0 0 0 0 0 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
diff --git a/patches/logo_linux_vga16.ppm b/patches/logo_linux_vga16.ppm
new file mode 100644
index 0000000..2f5d132
--- /dev/null
+++ b/patches/logo_linux_vga16.ppm
@@ -0,0 +1,323 @@
+P2
+80 80
+255
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 85 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 85 255 170 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 170 255 255 85 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 170 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 85 255 255 255 255 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 170 255 255 255 255 85 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 85 255 255 255 255 255 170 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 170 255 255 255 255 255 255 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 85 255 255 255 255 255 255 255 170 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 170 255 255 255 255 255 255 255 170 85 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 170 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 85 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 85 170 255 255 255 255 255 255 255 255 255 255 85 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 170 255 255 255 255 255 255 255 255 255 255 255 170 85 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 85 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 85 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 170 255 255 255 255 255 255 255 255 255 255 255 255 255 255 85 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 170 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 85 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 85 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 170 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 170 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 170 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 85 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 170 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 170 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 85 85 0 0 170 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 85
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 170 255 170 0 0 85 170 255 255 255 255 255 255 255 255 255 255 255 255 255 255 170
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 85 255 255 255 170 85 0 85 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 255 255 255 255 255 170 170 0 85 170 255 255 255 255 255 255 255 255 255 255 255 255 255
+170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 85 255 255 255 255 255 255 255 255 170 85 170 255 255 255 255 255 255 255 255 255 255 255 255
+255 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 170 255 255 255 255 255 255 255 255 255 170 170 170 255 255 255 255 255 255 255 255 255 255 255
+255 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 85 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+85 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+170 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 170 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 255 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 170 255 170 170 255 170 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 170 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 255 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 170 85 0 85 85 0 85 170 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 255 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 170 0 0 0 0 0 0 0 0 170 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 170 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 255 170 0 0 0 0 0 0 0 0 0 0 170 255 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 170 85 0 0 0 0 0 0 0 0 0 0 85 170 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 170 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 85 0 0 0 0 0 0 0 0 0 0 0 0 85 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 170 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 85 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 170 85 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 170 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 255 255
+255 255 255 255 255 255 255 170 255 255 255 255 255 255 85 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 255 255
+255 255 255 255 255 255 255 255 170 85 170 170 170 255 170 85 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 85 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 255 255
+255 255 255 255 255 255 255 255 255 255 85 0 85 170 255 170 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 170 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 85 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 85 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 170 85 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 170 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 170 85 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 85 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 170 85 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 255 255 255 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 255 255
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 170 85 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 85 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+255 255 255 170 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 170
+255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 85 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 85 170 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+170 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 85 170 170 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 85 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 85 170 255 255 255 255 255 255 255 255 255 255 255 255 255 170 85 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 85 170 255 255 255 255 255 255 255 255 255 255 255 255 255 255 85 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 170 170 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 85 170 255 255 255 255 255 255 255 255 255 255 255 170 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 170 255 255 255 255 255 255 255 255 255 255 85 85 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 85 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 85 255 255 255 255 255 255 255 255 170 85 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 170 255 255 255 255 255 255 255 255 170 0 0 0 0
+0 0
+0 0 0 0 0 0 85 170 255 255 255 255 255 255 170 85 85 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 85 85 85 255 255 255 255 255 255 255 85 0 0 0
+0 0
+0 0 0 0 0 0 170 255 255 255 255 255 170 85 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 255 255 255 255 255 170 0 0 0
+0 0
+0 0 0 0 0 0 255 255 255 255 255 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 255 255 255 255 85 0 0
+0 0
+0 0 0 0 0 85 255 255 170 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 170 255 255 170 0 0
+0 0
+0 0 0 0 85 170 255 170 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 255 255 85 0
+0 0
+0 0 0 0 170 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 170 0
+0 0
+0 0 0 0 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0
diff --git a/patches/mactel-linux-2.6.24.patch b/patches/mactel-linux-2.6.24.patch
new file mode 100644
index 0000000..644bd25
--- /dev/null
+++ b/patches/mactel-linux-2.6.24.patch
@@ -0,0 +1,1266 @@
+Add sensors set for MacBook2, from register dump on a mid-2007 MacBook2.
+
+From: Riki Oktarianto <rkoktarianto@gmail.com>
+
+
+---
+
+ drivers/hwmon/applesmc.c | 29 +++++++++++++++++++----------
+ 1 files changed, 19 insertions(+), 10 deletions(-)
+
+diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
+index 377c96d..4dca4cd 100644
+--- a/drivers/hwmon/applesmc.c
++++ b/drivers/hwmon/applesmc.c
+@@ -86,12 +86,15 @@ static const char* temperature_sensors_sets[][36] = {
+ /* Set 0: Macbook Pro */
+ { "TA0P", "TB0T", "TC0D", "TC0P", "TG0H", "TG0P", "TG0T", "Th0H",
+ "Th1H", "Tm0P", "Ts0P", "Ts1P", NULL },
+-/* Set 1: Macbook set */
++/* Set 1: Macbook2 set */
++ { "TB0T", "TC0D", "TC0P", "TM0P", "TN0P", "TN1P", "TTF0", "Th0H",
++ "Th0S", "Th1H", NULL },
++/* Set 2: Macbook set */
+ { "TB0T", "TC0D", "TC0P", "TM0P", "TN0P", "TN1P", "Th0H", "Th0S",
+ "Th1H", "Ts0P", NULL },
+-/* Set 2: Macmini set */
++/* Set 3: Macmini set */
+ { "TC0D", "TC0P", NULL },
+-/* Set 3: Mac Pro (2 x Quad-Core) */
++/* Set 4: Mac Pro (2 x Quad-Core) */
+ { "TA0P", "TCAG", "TCAH", "TCBG", "TCBH", "TC0C", "TC0D", "TC0P",
+ "TC1C", "TC1D", "TC2C", "TC2D", "TC3C", "TC3D", "THTG", "TH0P",
+ "TH1P", "TH2P", "TH3P", "TMAP", "TMAS", "TMBS", "TM0P", "TM0S",
+@@ -1247,12 +1250,14 @@ static void applesmc_release_accelerometer(void)
+ static __initdata struct dmi_match_data applesmc_dmi_data[] = {
+ /* MacBook Pro: accelerometer, backlight and temperature set 0 */
+ { .accelerometer = 1, .light = 1, .temperature_set = 0 },
+-/* MacBook: accelerometer and temperature set 1 */
++/* MacBook2: accelerometer and temperature set 1 */
+ { .accelerometer = 1, .light = 0, .temperature_set = 1 },
+-/* MacMini: temperature set 2 */
+- { .accelerometer = 0, .light = 0, .temperature_set = 2 },
+-/* MacPro: temperature set 3 */
++/* MacBook: accelerometer and temperature set 2 */
++ { .accelerometer = 1, .light = 0, .temperature_set = 2 },
++/* MacMini: temperature set 3 */
+ { .accelerometer = 0, .light = 0, .temperature_set = 3 },
++/* MacPro: temperature set 4 */
++ { .accelerometer = 0, .light = 0, .temperature_set = 4 },
+ };
+
+ /* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1".
+@@ -1264,16 +1269,20 @@ static __initdata struct dmi_system_id applesmc_whitelist[] = {
+ (void*)&applesmc_dmi_data[0]},
+ { applesmc_dmi_match, "Apple MacBook", {
+ DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
+- DMI_MATCH(DMI_PRODUCT_NAME,"MacBook") },
++ DMI_MATCH(DMI_PRODUCT_NAME,"MacBook2") },
+ (void*)&applesmc_dmi_data[1]},
++ { applesmc_dmi_match, "Apple MacBook", {
++ DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
++ DMI_MATCH(DMI_PRODUCT_NAME,"MacBook") },
++ (void*)&applesmc_dmi_data[2]},
+ { applesmc_dmi_match, "Apple Macmini", {
+ DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
+ DMI_MATCH(DMI_PRODUCT_NAME,"Macmini") },
+- (void*)&applesmc_dmi_data[2]},
++ (void*)&applesmc_dmi_data[3]},
+ { applesmc_dmi_match, "Apple MacPro2", {
+ DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
+ DMI_MATCH(DMI_PRODUCT_NAME,"MacPro2") },
+- (void*)&applesmc_dmi_data[3]},
++ (void*)&applesmc_dmi_data[4]},
+ { .ident = NULL }
+ };
+
+Retry up to 200 ms when reading or writing keys.
+
+From: Nicolas Boichat <nicolas@boichat.ch>
+
+
+---
+
+ drivers/hwmon/applesmc.c | 69 +++++++++++++++++++++++++++++++---------------
+ 1 files changed, 47 insertions(+), 22 deletions(-)
+
+diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
+index 4dca4cd..0950839 100644
+--- a/drivers/hwmon/applesmc.c
++++ b/drivers/hwmon/applesmc.c
+@@ -114,6 +114,9 @@ static const char* fan_speed_keys[] = {
+ #define INIT_TIMEOUT_MSECS 5000 /* wait up to 5s for device init ... */
+ #define INIT_WAIT_MSECS 50 /* ... in 50ms increments */
+
++#define ACCESS_TIMEOUT_MSECS 500 /* wait up to 500ms when accessing a key */
++#define ACCESS_WAIT_MSECS 5 /* ... in 5ms increments */
++
+ #define APPLESMC_POLL_INTERVAL 50 /* msecs */
+ #define APPLESMC_INPUT_FUZZ 4 /* input event threshold */
+ #define APPLESMC_INPUT_FLAT 4
+@@ -188,12 +191,13 @@ static int __wait_status(u8 val)
+
+ /*
+ * applesmc_read_key - reads len bytes from a given key, and put them in buffer.
++ * Tries up to ACCESS_WAIT_MSECS to read the value.
+ * Returns zero on success or a negative error on failure. Callers must
+ * hold applesmc_lock.
+ */
+ static int applesmc_read_key(const char* key, u8* buffer, u8 len)
+ {
+- int i;
++ int i, total, ret;
+
+ if (len > APPLESMC_MAX_DATA_LENGTH) {
+ printk(KERN_ERR "applesmc_read_key: cannot read more than "
+@@ -201,33 +205,54 @@ static int applesmc_read_key(const char* key, u8* buffer, u8 len)
+ return -EINVAL;
+ }
+
+- outb(APPLESMC_READ_CMD, APPLESMC_CMD_PORT);
+- if (__wait_status(0x0c))
+- return -EIO;
++ for (total = ACCESS_TIMEOUT_MSECS; total > 0;
++ total -= ACCESS_WAIT_MSECS) {
++ ret = 0;
++ outb(APPLESMC_READ_CMD, APPLESMC_CMD_PORT);
++ if (__wait_status(0x0c)) {
++ ret = -EIO;
++ goto wait_fail;
++ }
+
+- for (i = 0; i < 4; i++) {
+- outb(key[i], APPLESMC_DATA_PORT);
+- if (__wait_status(0x04))
+- return -EIO;
+- }
+- if (debug)
+- printk(KERN_DEBUG "<%s", key);
++ for (i = 0; i < 4; i++) {
++ outb(key[i], APPLESMC_DATA_PORT);
++ if (__wait_status(0x04)) {
++ ret = -EIO;
++ goto wait_fail;
++ }
++ }
++ if (debug)
++ printk(KERN_DEBUG "<%s", key);
+
+- outb(len, APPLESMC_DATA_PORT);
+- if (debug)
+- printk(KERN_DEBUG ">%x", len);
++ outb(len, APPLESMC_DATA_PORT);
++ if (debug)
++ printk(KERN_DEBUG ">%x", len);
+
+- for (i = 0; i < len; i++) {
+- if (__wait_status(0x05))
+- return -EIO;
+- buffer[i] = inb(APPLESMC_DATA_PORT);
++ for (i = 0; i < len; i++) {
++ if (__wait_status(0x05)) {
++ ret = -EIO;
++ goto wait_fail;
++ }
++ buffer[i] = inb(APPLESMC_DATA_PORT);
++ if (debug)
++ printk(KERN_DEBUG "<%x", buffer[i]);
++ }
+ if (debug)
+- printk(KERN_DEBUG "<%x", buffer[i]);
++ printk(KERN_DEBUG "\n");
++
++ break;
++
++wait_fail:
++ msleep(ACCESS_WAIT_MSECS);
++ continue;
+ }
+- if (debug)
+- printk(KERN_DEBUG "\n");
+
+- return 0;
++ if (total != ACCESS_TIMEOUT_MSECS) {
++ printk(KERN_DEBUG "Read: Waited %d ms for the value\n",
++ ACCESS_TIMEOUT_MSECS-total);
++ }
++
++ return ret;
+ }
+
+ /*
+Add interrupt support for the accelerometer. A message is printed in dmesg when an interrupt occurs, but no further handling is done.
+
+From: Nicolas Boichat <nicolas@boichat.ch>
+
+
+---
+
+ drivers/hwmon/applesmc.c | 320 +++++++++++++++++++++++++++++++++++++++++++---
+ 1 files changed, 297 insertions(+), 23 deletions(-)
+
+diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
+index 3b09cdb..8f75b57 100644
+--- a/drivers/hwmon/applesmc.c
++++ b/drivers/hwmon/applesmc.c
+@@ -39,14 +39,20 @@
+ #include <linux/leds.h>
+ #include <linux/hwmon.h>
+ #include <linux/workqueue.h>
++#include <linux/interrupt.h>
+
+ /* data port used by Apple SMC */
+ #define APPLESMC_DATA_PORT 0x300
+ /* command/status port used by Apple SMC */
+ #define APPLESMC_CMD_PORT 0x304
++/* status port used by Apple SMC to get which interrupt type just happened */
++#define APPLESMC_INT_PORT 0x31f
+
+ #define APPLESMC_NR_PORTS 32 /* 0x300-0x31f */
+
++/* Defined in ACPI DSDT table, should we read it from there? */
++#define APPLESMC_IRQ 6
++
+ #define APPLESMC_MAX_DATA_LENGTH 32
+
+ #define APPLESMC_STATUS_MASK 0x0f
+@@ -57,6 +63,8 @@
+
+ #define KEY_COUNT_KEY "#KEY" /* r-o ui32 */
+
++#define INTERRUPT_OK_KEY "NTOK" /* w-o ui8 */
++
+ #define LIGHT_SENSOR_LEFT_KEY "ALV0" /* r-o {alv (6 bytes) */
+ #define LIGHT_SENSOR_RIGHT_KEY "ALV1" /* r-o {alv (6 bytes) */
+ #define BACKLIGHT_KEY "LKSB" /* w-o {lkb (2 bytes) */
+@@ -68,6 +76,19 @@
+ #define MOTION_SENSOR_Z_KEY "MO_Z" /* r-o sp78 (2 bytes) */
+ #define MOTION_SENSOR_KEY "MOCN" /* r/w ui16 */
+
++/*
++ * Interrupt controls.
++ * If the norm of the position (sqrt(MO_X^2+MO_Y^2+MO_Z^2)) is smaller than
++ * MOLT (free fall), or bigger than MOHT (high acceleration) for longer than the
++ * value of MOLD (or MOHD), SMC will trigger an interrupt.
++ */
++#define MOTION_LOW_NORM "MOLT" /* r/w sp78 (2 bytes) */
++#define MOTION_HIGH_NORM "MOHT" /* r/w sp78 (2 bytes) */
++#define MOTION_LOW_NORM_INTERVAL "MOLD" /* r/w ui8 */
++#define MOTION_HIGH_NORM_INTERVAL "MOHD" /* r/w ui8 */
++
++#define MSDW_KEY "MSDW" /* r/w flag (1 byte) */
++
+ #define FANS_COUNT "FNum" /* r-o ui8 */
+ #define FANS_MANUAL "FS! " /* r-w ui16 */
+ #define FAN_ACTUAL_SPEED "F0Ac" /* r-o fpe2 (2 bytes) */
+@@ -385,12 +406,83 @@ static int applesmc_read_motion_sensor(int index, s16* value)
+ }
+
+ /*
++ * applesmc_init_check_key_value - checks if a given key contains the bytes in
++ * buffer, if not, writes these bytes.
++ * In case of failure retry every INIT_WAIT_MSECS msec, and timeout if it
++ * waited more than INIT_TIMEOUT_MSECS in total.
++ * Returns zero on success or a negative error on failure. Callers must
++ * hold applesmc_lock.
++ */
++static int applesmc_init_check_key_value(const char *key, u8 *buffer, u8 len)
++{
++ int total, ret, i, compare;
++ u8 rdbuffer[APPLESMC_MAX_DATA_LENGTH];
++
++ if (len > APPLESMC_MAX_DATA_LENGTH) {
++ printk(KERN_ERR "applesmc_init_check_key_value: cannot "
++ "read/write more than %d bytes",
++ APPLESMC_MAX_DATA_LENGTH);
++ return -EINVAL;
++ }
++
++ for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) {
++ ret = applesmc_read_key(key, rdbuffer, len);
++ if (!ret) {
++ compare = 1;
++ for (i = 0; i < len; i++) {
++ if (rdbuffer[i] != buffer[i]) {
++ compare = 0;
++ break;
++ }
++ }
++
++ if (compare) {
++ return 0;
++ }
++ }
++ ret = applesmc_write_key(key, buffer, len);
++ msleep(INIT_WAIT_MSECS);
++ }
++
++ if (ret)
++ return ret;
++ else
++ return -EIO;
++}
++
++irqreturn_t applesmc_irq_handler(int irq, void *dev_id)
++{
++ u8 int_type = inb(APPLESMC_INT_PORT);
++
++ switch (int_type) {
++ case 0x60:
++ printk(KERN_INFO "applesmc: received a free fall interrupt\n");
++ break;
++ case 0x6f:
++ printk(KERN_INFO
++ "applesmc: received a high acceleration interrupt\n");
++ break;
++ case 0x80:
++ printk(KERN_INFO "applesmc: received a shock interrupt\n");
++ break;
++ default:
++ printk(KERN_INFO
++ "applesmc: received an unknown interrupt %x\n",
++ int_type);
++ }
++
++ return IRQ_HANDLED;
++}
++
++/*
+ * applesmc_device_init - initialize the accelerometer. Returns zero on success
+ * and negative error code on failure. Can sleep.
+ */
+ static int applesmc_device_init(void)
+ {
+- int total, ret = -ENXIO;
++ int total;
++ int ret = -ENXIO;
++ int ret1, ret2;
+ u8 buffer[2];
+
+ if (!applesmc_accelerometer)
+@@ -398,32 +490,79 @@ static int applesmc_device_init(void)
+
+ mutex_lock(&applesmc_lock);
+
++ /* Accept interrupts */
++ buffer[0] = 0x01;
+ for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) {
+- if (debug)
+- printk(KERN_DEBUG "applesmc try %d\n", total);
+- if (!applesmc_read_key(MOTION_SENSOR_KEY, buffer, 2) &&
+- (buffer[0] != 0x00 || buffer[1] != 0x00)) {
+- if (total == INIT_TIMEOUT_MSECS) {
+- printk(KERN_DEBUG "applesmc: device has"
+- " already been initialized"
+- " (0x%02x, 0x%02x).\n",
+- buffer[0], buffer[1]);
+- } else {
+- printk(KERN_DEBUG "applesmc: device"
+- " successfully initialized"
+- " (0x%02x, 0x%02x).\n",
+- buffer[0], buffer[1]);
+- }
+- ret = 0;
+- goto out;
+- }
+- buffer[0] = 0xe0;
+- buffer[1] = 0x00;
+- applesmc_write_key(MOTION_SENSOR_KEY, buffer, 2);
++ ret1 = applesmc_write_key(INTERRUPT_OK_KEY, buffer, 1);
++ msleep(INIT_WAIT_MSECS);
++
++ if (!ret1)
++ break;
++ }
++ if (ret1)
++ printk(KERN_WARNING "applesmc: Cannot set NTOK key, "
++ "will not receive interrupts.\n");
++
++ /* Setup interrupt controls. */
++ buffer[0] = 20; /* 20 msecs */
++ ret1 = applesmc_init_check_key_value(MOTION_LOW_NORM_INTERVAL,
++ buffer, 1);
++
++ buffer[0] = 20; /* 20 msecs */
++ ret2 = applesmc_init_check_key_value(MOTION_HIGH_NORM_INTERVAL,
++ buffer, 1);
++
++ if (ret1 || ret2) {
++ printk(KERN_WARNING "applesmc: Cannot set motion sensor "
++ "interrupt interval, might not receive "
++ "some interrupts.");
++ }
++
++ buffer[0] = 0x00;
++ buffer[1] = 0x60;
++ ret1 = applesmc_init_check_key_value(MOTION_LOW_NORM, buffer, 2);
++
++ buffer[0] = 0x01;
++ buffer[1] = 0xc0;
++ ret2 = applesmc_init_check_key_value(MOTION_HIGH_NORM, buffer, 2);
++
++ if (ret1 || ret2) {
++ printk(KERN_WARNING "applesmc: Cannot set motion sensor "
++ "min/max norm parameters, "
++ "might not receive some interrupts.");
++ }
++
++ /* Mysterious key. */
++ buffer[0] = 0x01;
++ for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) {
++ ret1 = applesmc_write_key(MSDW_KEY, buffer, 1);
+ msleep(INIT_WAIT_MSECS);
++
++ if (!ret1)
++ break;
++ }
++ if (ret1)
++ printk(KERN_WARNING "applesmc: Cannot set MSDW key\n");
++
++ /* Initialize the device. */
++ buffer[0] = 0xe0;
++ buffer[1] = 0xf8;
++ if (applesmc_init_check_key_value(MOTION_SENSOR_KEY, buffer, 2)) {
++ printk(KERN_WARNING "applesmc: failed to init "
++ "the accelerometer\n");
++ goto out;
+ }
+
+- printk(KERN_WARNING "applesmc: failed to init the device\n");
++ ret1 = request_irq(APPLESMC_IRQ, applesmc_irq_handler, IRQF_DISABLED,
++ "applesmc_irq_handler", NULL);
++
++ if (ret1) {
++ printk(KERN_WARNING "applesmc: cannot setup irq handler\n");
++ }
++
++ printk(KERN_DEBUG "applesmc: accelerometer "
++ "successfully initialized.\n");
++ ret = 0;
+
+ out:
+ mutex_unlock(&applesmc_lock);
+@@ -468,9 +607,16 @@ static int applesmc_resume(struct platform_device *dev)
+ return applesmc_device_init();
+ }
+
++static int applesmc_remove(struct platform_device *dev)
++{
++ free_irq(APPLESMC_IRQ, NULL);
++ return 0;
++}
++
+ static struct platform_driver applesmc_driver = {
+ .probe = applesmc_probe,
+ .resume = applesmc_resume,
++ .remove = applesmc_remove,
+ .driver = {
+ .name = "applesmc",
+ .owner = THIS_MODULE,
+@@ -932,6 +1078,122 @@ static ssize_t applesmc_key_at_index_store(struct device *dev,
+ return count;
+ }
+
++static ssize_t applesmc_accelerometer_show(struct device *dev,
++ struct device_attribute *attr, char *sysfsbuf)
++{
++ int ret;
++ unsigned int value = 0;
++ u8 buffer[2];
++ char *key;
++ int length;
++ struct sensor_device_attribute_2 *sensor_attr =
++ to_sensor_dev_attr_2(attr);
++
++ switch (sensor_attr->index) {
++ case 0:
++ key = MOTION_LOW_NORM_INTERVAL;
++ length = 1;
++ break;
++ case 1:
++ key = MOTION_HIGH_NORM_INTERVAL;
++ length = 1;
++ break;
++ case 2:
++ key = MOTION_LOW_NORM;
++ length = 2;
++ break;
++ case 3:
++ key = MOTION_HIGH_NORM;
++ length = 2;
++ break;
++ default:
++ printk(KERN_ERR
++ "Invalid index for applesmc_accelerometer_show");
++ return -EINVAL;
++ }
++
++ mutex_lock(&applesmc_lock);
++
++ ret = applesmc_read_key(key, buffer, length);
++ if (length == 2)
++ value = ((unsigned int)buffer[0] << 8) | buffer[1];
++ else if (length == 1)
++ value = buffer[0];
++ else {
++ printk("Invalid length for applesmc_param_show");
++ ret = -EINVAL;
++ }
++
++ mutex_unlock(&applesmc_lock);
++ if (ret)
++ return ret;
++ else
++ return snprintf(sysfsbuf, PAGE_SIZE, "%u\n", value);
++}
++
++static ssize_t applesmc_accelerometer_store(struct device *dev,
++ struct device_attribute *attr,
++ const char *sysfsbuf, size_t count)
++{
++ int ret;
++ u32 value;
++ u8 buffer[2];
++ char *key;
++ int length;
++ struct sensor_device_attribute_2 *sensor_attr =
++ to_sensor_dev_attr_2(attr);
++
++ switch (sensor_attr->index) {
++ case 0:
++ key = MOTION_LOW_NORM_INTERVAL;
++ length = 1;
++ break;
++ case 1:
++ key = MOTION_HIGH_NORM_INTERVAL;
++ length = 1;
++ break;
++ case 2:
++ key = MOTION_LOW_NORM;
++ length = 2;
++ break;
++ case 3:
++ key = MOTION_HIGH_NORM;
++ length = 2;
++ break;
++ default:
++ printk("Invalid index for applesmc_accelerometer_show");
++ return -EINVAL;
++ }
++
++ value = simple_strtoul(sysfsbuf, NULL, 10);
++
++ if (length == 2) {
++ if (value > 0xffff)
++ return -EINVAL;
++
++ buffer[0] = (value >> 8) & 0xff;
++ buffer[1] = value & 0xff;
++ } else if (length == 1) {
++ if (value > 0xff)
++ return -EINVAL;
++
++ buffer[0] = value & 0xff;
++ } else {
++ printk("Invalid length for applesmc_param_store");
++ return -EINVAL;
++ }
++
++ mutex_lock(&applesmc_lock);
++
++ ret = applesmc_write_key(key, buffer, length);
++
++ mutex_unlock(&applesmc_lock);
++
++ if (ret)
++ return ret;
++ else
++ return count;
++}
+ static struct led_classdev applesmc_backlight = {
+ .name = "smc:kbd_backlight",
+ .default_trigger = "nand-disk",
+@@ -943,10 +1205,22 @@ static DEVICE_ATTR(name, 0444, applesmc_name_show, NULL);
+ static DEVICE_ATTR(position, 0444, applesmc_position_show, NULL);
+ static DEVICE_ATTR(calibrate, 0644,
+ applesmc_calibrate_show, applesmc_calibrate_store);
++static SENSOR_DEVICE_ATTR(low_norm_trigger_interval, 0644,
++ applesmc_accelerometer_show, applesmc_accelerometer_store, 0);
++static SENSOR_DEVICE_ATTR(high_norm_trigger_interval, 0644,
++ applesmc_accelerometer_show, applesmc_accelerometer_store, 1);
++static SENSOR_DEVICE_ATTR(low_norm_trigger, 0644,
++ applesmc_accelerometer_show, applesmc_accelerometer_store, 2);
++static SENSOR_DEVICE_ATTR(high_norm_trigger, 0644,
++ applesmc_accelerometer_show, applesmc_accelerometer_store, 3);
+
+ static struct attribute *accelerometer_attributes[] = {
+ &dev_attr_position.attr,
+ &dev_attr_calibrate.attr,
++ &sensor_dev_attr_low_norm_trigger.dev_attr.attr,
++ &sensor_dev_attr_high_norm_trigger.dev_attr.attr,
++ &sensor_dev_attr_low_norm_trigger_interval.dev_attr.attr,
++ &sensor_dev_attr_high_norm_trigger_interval.dev_attr.attr,
+ NULL
+ };
+
+Appletouch driver ATP_THRESHOLD fix.
+
+From: Ortwin Glück <odi@odi.ch>
+
+
+---
+
+ drivers/input/mouse/appletouch.c | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c
+index a1804bf..51cc7c3 100644
+--- a/drivers/input/mouse/appletouch.c
++++ b/drivers/input/mouse/appletouch.c
+@@ -127,7 +127,7 @@ MODULE_DEVICE_TABLE (usb, atp_table);
+ * Threshold for the touchpad sensors. Any change less than ATP_THRESHOLD is
+ * ignored.
+ */
+-#define ATP_THRESHOLD 5
++#define ATP_THRESHOLD 3
+
+ /* MacBook Pro (Geyser 3 & 4) initialization constants */
+ #define ATP_GEYSER3_MODE_READ_REQUEST_ID 1
+Added IDs for macbook3,1 trackpad
+
+From: Chris Irwin <chris@chrisirwin.ca>
+
+
+---
+
+ drivers/input/mouse/appletouch.c | 15 ++++++++++++++-
+ 1 files changed, 14 insertions(+), 1 deletions(-)
+
+diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c
+index 17381a9..dcd9a0d 100644
+--- a/drivers/input/mouse/appletouch.c
++++ b/drivers/input/mouse/appletouch.c
+@@ -62,6 +62,11 @@
+ #define GEYSER4_ISO_PRODUCT_ID 0x021B
+ #define GEYSER4_JIS_PRODUCT_ID 0x021C
+
++/* Macbook3,1 devices */
++#define GEYSER4_HF_ANSI_PRODUCT_ID 0x0229
++#define GEYSER4_HF_ISO_PRODUCT_ID 0x022A
++#define GEYSER4_HF_JIS_PRODUCT_ID 0x021B
++
+ #define ATP_DEVICE(prod) \
+ .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
+ USB_DEVICE_ID_MATCH_INT_CLASS | \
+@@ -93,6 +98,11 @@ static struct usb_device_id atp_table [] = {
+ { ATP_DEVICE(GEYSER4_ISO_PRODUCT_ID) },
+ { ATP_DEVICE(GEYSER4_JIS_PRODUCT_ID) },
+
++ /* Core2 Duo MacBook3,1 */
++ { ATP_DEVICE(GEYSER4_HF_ANSI_PRODUCT_ID) },
++ { ATP_DEVICE(GEYSER4_HF_ISO_PRODUCT_ID) },
++ { ATP_DEVICE(GEYSER4_HF_JIS_PRODUCT_ID) },
++
+ /* Terminating entry */
+ { }
+ };
+@@ -217,7 +227,10 @@ static inline int atp_is_geyser_3(struct atp *dev)
+ (productId == GEYSER3_JIS_PRODUCT_ID) ||
+ (productId == GEYSER4_ANSI_PRODUCT_ID) ||
+ (productId == GEYSER4_ISO_PRODUCT_ID) ||
+- (productId == GEYSER4_JIS_PRODUCT_ID);
++ (productId == GEYSER4_JIS_PRODUCT_ID) ||
++ (productId == GEYSER4_HF_ANSI_PRODUCT_ID) ||
++ (productId == GEYSER4_HF_ISO_PRODUCT_ID) ||
++ (productId == GEYSER4_HF_JIS_PRODUCT_ID);
+ }
+
+ /*
+Display Macbook Pro 1st gen controls when the subsystem id is wrong (0x100).
+
+From: Nicolas Boichat <nicolas@boichat.ch>
+
+
+---
+
+ sound/pci/hda/patch_sigmatel.c | 4 +++-
+ 1 files changed, 3 insertions(+), 1 deletions(-)
+
+diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
+index 3f25de7..f210051 100644
+--- a/sound/pci/hda/patch_sigmatel.c
++++ b/sound/pci/hda/patch_sigmatel.c
+@@ -2125,10 +2125,12 @@ static int patch_stac922x(struct hda_codec *codec)
+ case 0x106b1700:
+ case 0x106b0200:
+ case 0x106b1e00:
++ case 0x100: /* Invalid subsystem ID, happens randomly on
++ * MacBook Pro 1st generation
++ */
+ spec->board_config = STAC_INTEL_MAC_V3;
+ break;
+ case 0x106b1a00:
+- case 0x00000100:
+ spec->board_config = STAC_INTEL_MAC_V4;
+ break;
+ case 0x106b0a00:
+Fixes audio on Macbook v2.
+
+From: Marek Sterzik <marek@milimetr.org>
+
+
+---
+
+ sound/pci/hda/patch_sigmatel.c | 2 ++
+ 1 files changed, 2 insertions(+), 0 deletions(-)
+
+diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
+index f210051..271cb77 100644
+--- a/sound/pci/hda/patch_sigmatel.c
++++ b/sound/pci/hda/patch_sigmatel.c
+@@ -69,6 +69,7 @@ enum {
+ /* for backward compitability */
+ STAC_MACMINI,
+ STAC_MACBOOK,
++ STAC_MACBOOK_V2,
+ STAC_MACBOOK_PRO_V1,
+ STAC_MACBOOK_PRO_V2,
+ STAC_IMAC_INTEL,
+@@ -623,6 +624,7 @@ static const char *stac922x_models[STAC_922X_MODELS] = {
+ /* for backward compitability */
+ [STAC_MACMINI] = "macmini",
+ [STAC_MACBOOK] = "macbook",
++ [STAC_MACBOOK_V2] = "macbook-v2",
+ [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
+ [STAC_MACBOOK_PRO_V2] = "macbook-pro",
+ [STAC_IMAC_INTEL] = "imac-intel",
+New appletouch driver.
+
+From: Sven Anders <anders@anduras.de>
+
+
+---
+
+ drivers/input/mouse/appletouch.c | 160 +++++++++++++++++++++++++++++---------
+ 1 files changed, 121 insertions(+), 39 deletions(-)
+
+diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c
+index dcd9a0d..5a3459c 100644
+--- a/drivers/input/mouse/appletouch.c
++++ b/drivers/input/mouse/appletouch.c
+@@ -8,6 +8,7 @@
+ * Copyright (C) 2005 Peter Osterlund (petero2@telia.com)
+ * Copyright (C) 2005 Michael Hanselmann (linux-kernel@hansmi.ch)
+ * Copyright (C) 2006 Nicolas Boichat (nicolas@boichat.ch)
++ * Copyright (C) 2007-2008 Sven Anders (anders@anduras.de)
+ *
+ * Thanks to Alex Harper <basilisk@foobox.net> for his inputs.
+ *
+@@ -38,16 +39,18 @@
+ #define APPLE_VENDOR_ID 0x05AC
+
+ /* These names come from Info.plist in AppleUSBTrackpad.kext */
++
++/* PowerBooks Feb 2005 / iBooks */
+ #define FOUNTAIN_ANSI_PRODUCT_ID 0x020E
+ #define FOUNTAIN_ISO_PRODUCT_ID 0x020F
+-
+ #define FOUNTAIN_TP_ONLY_PRODUCT_ID 0x030A
+
+ #define GEYSER1_TP_ONLY_PRODUCT_ID 0x030B
+
+-#define GEYSER_ANSI_PRODUCT_ID 0x0214
+-#define GEYSER_ISO_PRODUCT_ID 0x0215
+-#define GEYSER_JIS_PRODUCT_ID 0x0216
++/* PowerBooks Oct 2005 */
++#define GEYSER2_ANSI_PRODUCT_ID 0x0214
++#define GEYSER2_ISO_PRODUCT_ID 0x0215
++#define GEYSER2_JIS_PRODUCT_ID 0x0216
+
+ /* MacBook devices */
+ #define GEYSER3_ANSI_PRODUCT_ID 0x0217
+@@ -58,9 +61,14 @@
+ * Geyser IV: same as Geyser III according to Info.plist in AppleUSBTrackpad.kext
+ * -> same IOClass (AppleUSBGrIIITrackpad), same acceleration tables
+ */
+-#define GEYSER4_ANSI_PRODUCT_ID 0x021A
+-#define GEYSER4_ISO_PRODUCT_ID 0x021B
+-#define GEYSER4_JIS_PRODUCT_ID 0x021C
++#define GEYSER4_ANSI_PRODUCT_ID 0x021A
++#define GEYSER4_ISO_PRODUCT_ID 0x021B
++#define GEYSER4_JIS_PRODUCT_ID 0x021C
++
++/* Macbook3,1 devices */
++#define GEYSER4_HF_ANSI_PRODUCT_ID 0x0229
++#define GEYSER4_HF_ISO_PRODUCT_ID 0x022A
++#define GEYSER4_HF_JIS_PRODUCT_ID 0x021B
+
+ /* Macbook3,1 devices */
+ #define GEYSER4_HF_ANSI_PRODUCT_ID 0x0229
+@@ -78,15 +86,17 @@
+
+ /* table of devices that work with this driver */
+ static struct usb_device_id atp_table [] = {
++
++ /* PowerBooks Feb 2005, iBooks G4 */
+ { ATP_DEVICE(FOUNTAIN_ANSI_PRODUCT_ID) },
+ { ATP_DEVICE(FOUNTAIN_ISO_PRODUCT_ID) },
+ { ATP_DEVICE(FOUNTAIN_TP_ONLY_PRODUCT_ID) },
+ { ATP_DEVICE(GEYSER1_TP_ONLY_PRODUCT_ID) },
+
+ /* PowerBooks Oct 2005 */
+- { ATP_DEVICE(GEYSER_ANSI_PRODUCT_ID) },
+- { ATP_DEVICE(GEYSER_ISO_PRODUCT_ID) },
+- { ATP_DEVICE(GEYSER_JIS_PRODUCT_ID) },
++ { ATP_DEVICE(GEYSER2_ANSI_PRODUCT_ID) },
++ { ATP_DEVICE(GEYSER2_ISO_PRODUCT_ID) },
++ { ATP_DEVICE(GEYSER2_JIS_PRODUCT_ID) },
+
+ /* Core Duo MacBook & MacBook Pro */
+ { ATP_DEVICE(GEYSER3_ANSI_PRODUCT_ID) },
+@@ -103,6 +113,11 @@ static struct usb_device_id atp_table [] = {
+ { ATP_DEVICE(GEYSER4_HF_ISO_PRODUCT_ID) },
+ { ATP_DEVICE(GEYSER4_HF_JIS_PRODUCT_ID) },
+
++ /* Core2 Duo MacBook3,1 */
++ { ATP_DEVICE(GEYSER4_HF_ANSI_PRODUCT_ID) },
++ { ATP_DEVICE(GEYSER4_HF_ISO_PRODUCT_ID) },
++ { ATP_DEVICE(GEYSER4_HF_JIS_PRODUCT_ID) },
++
+ /* Terminating entry */
+ { }
+ };
+@@ -146,12 +161,21 @@ MODULE_DEVICE_TABLE (usb, atp_table);
+ #define ATP_GEYSER_MODE_REQUEST_INDEX 0
+ #define ATP_GEYSER_MODE_VENDOR_VALUE 0x04
+
++/*
++ * Meaning of the status bits (only Geyser 3/4?)
++ */
++#define ATP_STATUS_BIT_BUTTON 0x01 /* The button was pressed */
++#define ATP_STATUS_BIT_UNKNOWN1 0x02 /* Unknown or unused */
++#define ATP_STATUS_BIT_BASE_UPDATE 0x04 /* Update of the base values (untouched pad) */
++#define ATP_STATUS_BIT_UNKNOWN2 0x08 /* Unknown or unused */
++#define ATP_STATUS_BIT_FROM_RESET 0x10 /* Reset previously performed */
++
+ /* Structure to hold all of our device specific stuff */
+ struct atp {
+ char phys[64];
+ struct usb_device * udev; /* usb device */
+ struct urb * urb; /* usb request block */
+- signed char * data; /* transferred data */
++ u8 * data; /* transferred data */
+ struct input_dev * input; /* input dev */
+ unsigned char open; /* non-zero if opened */
+ unsigned char valid; /* are the sensors valid ? */
+@@ -166,8 +190,8 @@ struct atp {
+ /* accumulated sensors */
+ int xy_acc[ATP_XSENSORS + ATP_YSENSORS];
+ int datalen; /* size of an USB urb transfer */
+- int idlecount; /* number of empty packets */
+- struct work_struct work;
++ int idle_counter; /* number of empty packets */
++ struct work_struct work; /* kernel workqueue entry (for re-init) */
+ };
+
+ #define dbg_dump(msg, tab) \
+@@ -184,8 +208,12 @@ struct atp {
+ if (debug) printk(KERN_DEBUG format, ##a); \
+ } while (0)
+
+-MODULE_AUTHOR("Johannes Berg, Stelian Pop, Frank Arnold, Michael Hanselmann");
+-MODULE_DESCRIPTION("Apple PowerBooks USB touchpad driver");
++MODULE_AUTHOR("Johannes Berg");
++MODULE_AUTHOR("Stelian Pop");
++MODULE_AUTHOR("Frank Arnold");
++MODULE_AUTHOR("Michael Hanselmann");
++MODULE_AUTHOR("Sven Anders");
++MODULE_DESCRIPTION("Apple PowerBook and MacBook USB touchpad driver");
+ MODULE_LICENSE("GPL");
+
+ /*
+@@ -195,7 +223,7 @@ static int threshold = ATP_THRESHOLD;
+ module_param(threshold, int, 0644);
+ MODULE_PARM_DESC(threshold, "Discards any change in data from a sensor (trackpad has hundreds of these sensors) less than this value");
+
+-static int debug = 1;
++static int debug;
+ module_param(debug, int, 0644);
+ MODULE_PARM_DESC(debug, "Activate debugging output");
+
+@@ -213,12 +241,12 @@ static inline int atp_is_geyser_2(struct atp *dev)
+ {
+ u16 productId = le16_to_cpu(dev->udev->descriptor.idProduct);
+
+- return (productId == GEYSER_ANSI_PRODUCT_ID) ||
+- (productId == GEYSER_ISO_PRODUCT_ID) ||
+- (productId == GEYSER_JIS_PRODUCT_ID);
++ return (productId == GEYSER2_ANSI_PRODUCT_ID) ||
++ (productId == GEYSER2_ISO_PRODUCT_ID) ||
++ (productId == GEYSER2_JIS_PRODUCT_ID);
+ }
+
+-static inline int atp_is_geyser_3(struct atp *dev)
++static inline int atp_is_geyser_3_4(struct atp *dev)
+ {
+ u16 productId = le16_to_cpu(dev->udev->descriptor.idProduct);
+
+@@ -242,7 +270,7 @@ static int atp_geyser_init(struct usb_device *udev)
+ {
+ char data[8];
+ int size;
+-
++
+ size = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
+ ATP_GEYSER_MODE_READ_REQUEST_ID,
+ USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+@@ -250,6 +278,13 @@ static int atp_geyser_init(struct usb_device *udev)
+ ATP_GEYSER_MODE_REQUEST_INDEX, &data, 8, 5000);
+
+ if (size != 8) {
++ if (debug)
++ {
++ int i;
++ printk("appletouch atp_geyser_init READ error\n");
++ for (i=0; i<8; i++)
++ printk("appletouch[%d]: %d\n", i, (int) data[i]);
++ }
+ err("Could not do mode read request from device"
+ " (Geyser Raw mode)");
+ return -EIO;
+@@ -265,6 +300,13 @@ static int atp_geyser_init(struct usb_device *udev)
+ ATP_GEYSER_MODE_REQUEST_INDEX, &data, 8, 5000);
+
+ if (size != 8) {
++ if (debug)
++ {
++ int i;
++ printk("appletouch atp_geyser_init WRITE error\n");
++ for (i=0; i<8; i++)
++ printk("appletouch[%d]: %d\n", i, (int) data[i]);
++ }
+ err("Could not do mode write request to device"
+ " (Geyser Raw mode)");
+ return -EIO;
+@@ -282,8 +324,7 @@ static void atp_reinit(struct work_struct *work)
+ struct usb_device *udev = dev->udev;
+ int retval;
+
+- dev->idlecount = 0;
+-
++ dprintk("appletouch: putting appletouch to sleep (reinit)\n");
+ atp_geyser_init(udev);
+
+ retval = usb_submit_urb(dev->urb, GFP_ATOMIC);
+@@ -398,7 +439,7 @@ static void atp_complete(struct urb* urb)
+ }
+
+ /* reorder the sensors values */
+- if (atp_is_geyser_3(dev)) {
++ if (atp_is_geyser_3_4(dev)) {
+ memset(dev->xy_cur, 0, sizeof(dev->xy_cur));
+
+ /*
+@@ -455,13 +496,20 @@ static void atp_complete(struct urb* urb)
+ dbg_dump("sample", dev->xy_cur);
+
+ if (!dev->valid) {
+- /* first sample */
++ /* first sample after init or resume */
+ dev->valid = 1;
+ dev->x_old = dev->y_old = -1;
+ memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old));
++ dev->idle_counter = 0;
++
++ /* store first sample on older Geyser */
++ if ((dev->data[dev->datalen-1] & ATP_STATUS_BIT_BASE_UPDATE) ||
++ !atp_is_geyser_3_4(dev))
++ memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old));
++
+
+ if (dev->size_detect_done ||
+- atp_is_geyser_3(dev)) /* No 17" Macbooks (yet) */
++ atp_is_geyser_3_4(dev)) /* No 17" Macbooks (yet) */
+ goto exit;
+
+ /* 17" Powerbooks have extra X sensors */
+@@ -487,26 +535,47 @@ static void atp_complete(struct urb* urb)
+ goto exit;
+ }
+
++ /* Just update the base values (i.e. touchpad in untouched state) */
++ if (dev->data[dev->datalen-1] & ATP_STATUS_BIT_BASE_UPDATE)
++ {
++ if (debug > 0) printk("appletouch: updated base values\n");
++
++ memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old));
++ goto exit;
++ }
++
+ for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) {
+- /* accumulate the change */
+- signed char change = dev->xy_old[i] - dev->xy_cur[i];
+- dev->xy_acc[i] -= change;
++ /* calculate the change */
++ dev->xy_acc[i] = dev->xy_cur[i] - dev->xy_old[i];
++
++ /* this is a round-robin value, so couple with that */
++ if (dev->xy_acc[i] > 127)
++ dev->xy_acc[i] -= 256;
++
++ if (dev->xy_acc[i] < -127)
++ dev->xy_acc[i] += 256;
++
++ /* Needed for the older Geyser */
++ if (!atp_is_geyser_3_4(dev))
++ {
++ /* store new 'untouched' value, if any new */
++ if (dev->xy_acc[i] < -1)
++ dev->xy_old[i] = dev->xy_cur[i];
++ }
+
+ /* prevent down drifting */
+ if (dev->xy_acc[i] < 0)
+ dev->xy_acc[i] = 0;
+ }
+
+- memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old));
+-
+ dbg_dump("accumulator", dev->xy_acc);
+
+ x = atp_calculate_abs(dev->xy_acc, ATP_XSENSORS,
+ ATP_XFACT, &x_z, &x_f);
+ y = atp_calculate_abs(dev->xy_acc + ATP_XSENSORS, ATP_YSENSORS,
+ ATP_YFACT, &y_z, &y_f);
+- key = dev->data[dev->datalen - 1] & 1;
+-
++ key = dev->data[dev->datalen - 1] & ATP_STATUS_BIT_BUTTON;
++
+ if (x && y) {
+ if (dev->x_old != -1) {
+ x = (dev->x_old * 3 + x) >> 2;
+@@ -551,16 +620,28 @@ static void atp_complete(struct urb* urb)
+ * work on Fountain touchpads.
+ */
+ if (!atp_is_fountain(dev)) {
++
++ /* Button must not be pressed when entering suspend,
++ otherwise we will never release the button. */
+ if (!x && !y && !key) {
+- dev->idlecount++;
+- if (dev->idlecount == 10) {
+- dev->valid = 0;
++
++ /* Idle counter */
++ dev->idle_counter++;
++
++ /* Wait for 10 more packages before suspending */
++ if (dev->idle_counter > 10) {
++
++ /* Reset counter */
++ dev->idle_counter = 0;
++
++ /* Prepare for device reset */
+ schedule_work(&dev->work);
++
+ /* Don't resubmit urb here, wait for reinit */
+ return;
+ }
+ } else
+- dev->idlecount = 0;
++ dev->idle_counter = 0;
+ }
+
+ exit:
+@@ -628,7 +709,7 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id
+ dev->udev = udev;
+ dev->input = input_dev;
+ dev->overflowwarn = 0;
+- if (atp_is_geyser_3(dev))
++ if (atp_is_geyser_3_4(dev))
+ dev->datalen = 64;
+ else if (atp_is_geyser_2(dev))
+ dev->datalen = 64;
+@@ -671,7 +752,7 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id
+
+ set_bit(EV_ABS, input_dev->evbit);
+
+- if (atp_is_geyser_3(dev)) {
++ if (atp_is_geyser_3_4(dev)) {
+ /*
+ * MacBook have 20 X sensors, 10 Y sensors
+ */
+@@ -714,6 +795,7 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id
+ /* save our data pointer in this interface device */
+ usb_set_intfdata(iface, dev);
+
++ /* initialize kernel work queue for re-init out of interrupt context */
+ INIT_WORK(&dev->work, atp_reinit);
+
+ return 0;
+diff -uNr linux-2.6.24/drivers/hid/hid-input.c linux-2.6.24-macbookair/drivers/hid/hid-input.c
+--- linux-2.6.24/drivers/hid/hid-input.c 2008-01-24 23:58:37.000000000 +0100
++++ linux-2.6.24-macbookair/drivers/hid/hid-input.c 2008-03-03 09:00:02.000000000 +0100
+@@ -119,6 +119,30 @@
+ { }
+ };
+
++static struct hidinput_key_translation apple_keyboard_fn_keys[] = {
++ { KEY_BACKSPACE, KEY_DELETE },
++ { KEY_F1, KEY_BRIGHTNESSDOWN, POWERBOOK_FLAG_FKEY },
++ { KEY_F2, KEY_BRIGHTNESSUP, POWERBOOK_FLAG_FKEY },
++ { KEY_F3, KEY_CYCLEWINDOWS, POWERBOOK_FLAG_FKEY },
++ { KEY_F4, KEY_CONFIG, POWERBOOK_FLAG_FKEY },
++ { KEY_F7, KEY_PREVIOUSSONG, POWERBOOK_FLAG_FKEY },
++ { KEY_F8, KEY_PLAYPAUSE, POWERBOOK_FLAG_FKEY },
++ { KEY_F9, KEY_NEXTSONG, POWERBOOK_FLAG_FKEY },
++ { KEY_F10, KEY_MUTE, POWERBOOK_FLAG_FKEY },
++ { KEY_F11, KEY_VOLUMEDOWN, POWERBOOK_FLAG_FKEY },
++ { KEY_F12, KEY_VOLUMEUP, POWERBOOK_FLAG_FKEY },
++ { KEY_UP, KEY_PAGEUP },
++ { KEY_DOWN, KEY_PAGEDOWN },
++ { KEY_LEFT, KEY_HOME },
++ { KEY_RIGHT, KEY_END },
++ { }
++};
++
++static struct hidinput_key_translation apple_keyboard[] = {
++ { KEY_VOLUMEUP, KEY_EJECTCD },
++ { }
++};
++
+ static struct hidinput_key_translation powerbook_numlock_keys[] = {
+ { KEY_J, KEY_KP1 },
+ { KEY_K, KEY_KP2 },
+@@ -176,8 +200,10 @@
+
+ if (hid_pb_fnmode) {
+ int do_translate;
+-
+- trans = find_translation(powerbook_fn_keys, usage->code);
++ if (hid->quirks & HID_QUIRK_APPLE_KEYBOARD)
++ trans = find_translation(apple_keyboard_fn_keys, usage->code);
++ else
++ trans = find_translation(powerbook_fn_keys, usage->code);
+ if (trans) {
+ if (test_bit(usage->code, hid->pb_pressed_fn))
+ do_translate = 1;
+@@ -200,8 +226,8 @@
+ }
+ }
+
+- if (test_bit(usage->code, hid->pb_pressed_numlock) ||
+- test_bit(LED_NUML, input->led)) {
++ if (!(hid->quirks & HID_QUIRK_APPLE_KEYBOARD) && (test_bit(usage->code, hid->pb_pressed_numlock) ||
++ test_bit(LED_NUML, input->led))) {
+ trans = find_translation(powerbook_numlock_keys, usage->code);
+
+ if (trans) {
+@@ -217,6 +243,14 @@
+ }
+ }
+
++ if (hid->quirks & HID_QUIRK_APPLE_KEYBOARD) {
++ trans = find_translation(apple_keyboard, usage->code);
++ if (trans) {
++ input_event(input, usage->type, trans->to, value);
++ return 1;
++ }
++ }
++
+ if (hid->quirks & HID_QUIRK_POWERBOOK_ISO_KEYBOARD) {
+ trans = find_translation(powerbook_iso_keyboard, usage->code);
+ if (trans) {
+@@ -241,6 +275,12 @@
+ for (trans = powerbook_numlock_keys; trans->from; trans++)
+ set_bit(trans->to, input->keybit);
+
++ for (trans = apple_keyboard_fn_keys; trans->from; trans++)
++ set_bit(trans->to, input->keybit);
++
++ for (trans = apple_keyboard; trans->from; trans++)
++ set_bit(trans->to, input->keybit);
++
+ for (trans = powerbook_iso_keyboard; trans->from; trans++)
+ set_bit(trans->to, input->keybit);
+
+diff -uNr linux-2.6.24/drivers/hid/usbhid/hid-quirks.c linux-2.6.24-macbookair/drivers/hid/usbhid/hid-quirks.c
+--- linux-2.6.24/drivers/hid/usbhid/hid-quirks.c 2008-01-24 23:58:37.000000000 +0100
++++ linux-2.6.24-macbookair/drivers/hid/usbhid/hid-quirks.c 2008-03-03 09:00:35.000000000 +0100
+@@ -59,6 +59,32 @@
+ #define USB_DEVICE_ID_APPLE_GEYSER4_ANSI 0x021a
+ #define USB_DEVICE_ID_APPLE_GEYSER4_ISO 0x021b
+ #define USB_DEVICE_ID_APPLE_GEYSER4_JIS 0x021c
++
++/* Apple 2007 Wired keyboards */
++#define USB_DEVICE_ID_APPLE_KEYBOARD_ANSI 0x0220
++#define USB_DEVICE_ID_APPLE_KEYBOARD_ISO 0x0221
++#define USB_DEVICE_ID_APPLE_KEYBOARD_JIS 0x0222
++
++/* macbook3,1 keyboards */
++#define USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI 0x0229
++#define USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO 0x022a
++#define USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS 0x022b
++
++/* Apple WellSpring keyboard + trackpad */
++#define USB_PRODUCT_ID_WELLSPRING_ANSI 0x0223
++#define USB_PRODUCT_ID_WELLSPRING_ISO 0x0224
++#define USB_PRODUCT_ID_WELLSPRING_JIS 0x0225
++
++/* Apple WellSpring II keyboard + trackpad */
++#define USB_PRODUCT_ID_WELLSPRING2_ANSI 0x0230
++#define USB_PRODUCT_ID_WELLSPRING2_ISO 0x0231
++#define USB_PRODUCT_ID_WELLSPRING2_JIS 0x0232
++
++/* Apple 2007 Wireless keyboards */
++#define USB_DEVICE_ID_APPLE_WIRELESS_KEYBOARD_ANSI 0x022c
++#define USB_DEVICE_ID_APPLE_WIRELESS_KEYBOARD_ISO 0x022d
++#define USB_DEVICE_ID_APPLE_WIRELESS_KEYBOARD_JIS 0x022e
++
+ #define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
+ #define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
+ #define USB_DEVICE_ID_APPLE_IRCONTROL4 0x8242
+@@ -551,6 +577,32 @@
+ { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
+ { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_POWERBOOK_ISO_KEYBOARD},
+ { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
++
++ /* Apple 2007 Wired keyboards */
++ { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_KEYBOARD_ANSI, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_APPLE_KEYBOARD},
++ { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_KEYBOARD_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_APPLE_KEYBOARD | HID_QUIRK_POWERBOOK_ISO_KEYBOARD},
++ { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_KEYBOARD_JIS, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_APPLE_KEYBOARD},
++
++ /* macbook3,1 keyboards */
++ { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_APPLE_KEYBOARD},
++ { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_APPLE_KEYBOARD | HID_QUIRK_POWERBOOK_ISO_KEYBOARD},
++ { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_APPLE_KEYBOARD},
++
++ /* Apple 2007 Wireless keyboards */
++ { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WIRELESS_KEYBOARD_ANSI, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_APPLE_KEYBOARD},
++ { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WIRELESS_KEYBOARD_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_APPLE_KEYBOARD | HID_QUIRK_POWERBOOK_ISO_KEYBOARD},
++ { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WIRELESS_KEYBOARD_JIS, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_APPLE_KEYBOARD},
++
++ /* Apple WellSpring keyboard + trackpad */
++ { USB_VENDOR_ID_APPLE, USB_PRODUCT_ID_WELLSPRING_ANSI, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_APPLE_KEYBOARD},
++ { USB_VENDOR_ID_APPLE, USB_PRODUCT_ID_WELLSPRING_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_APPLE_KEYBOARD | HID_QUIRK_POWERBOOK_ISO_KEYBOARD},
++ { USB_VENDOR_ID_APPLE, USB_PRODUCT_ID_WELLSPRING_JIS, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_APPLE_KEYBOARD},
++
++ /* Apple WellSpring II keyboard + trackpad */
++ { USB_VENDOR_ID_APPLE, USB_PRODUCT_ID_WELLSPRING2_ANSI, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_APPLE_KEYBOARD},
++ { USB_VENDOR_ID_APPLE, USB_PRODUCT_ID_WELLSPRING2_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_APPLE_KEYBOARD | HID_QUIRK_POWERBOOK_ISO_KEYBOARD},
++ { USB_VENDOR_ID_APPLE, USB_PRODUCT_ID_WELLSPRING2_JIS, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_APPLE_KEYBOARD},
++
+ { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
+ { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
+
+diff -uNr linux-2.6.24/include/linux/hid.h linux-2.6.24-macbookair/include/linux/hid.h
+--- linux-2.6.24/include/linux/hid.h 2008-01-24 23:58:37.000000000 +0100
++++ linux-2.6.24-macbookair/include/linux/hid.h 2008-03-03 09:00:02.000000000 +0100
+@@ -281,6 +281,7 @@
+ #define HID_QUIRK_LOGITECH_IGNORE_DOUBLED_WHEEL 0x00400000
+ #define HID_QUIRK_LOGITECH_EXPANDED_KEYMAP 0x00800000
+ #define HID_QUIRK_IGNORE_HIDINPUT 0x01000000
++#define HID_QUIRK_APPLE_KEYBOARD 0x02000000
+
+ /*
+ * Separate quirks for runtime report descriptor fixup
diff --git a/patches/put_filp-2.6.24.patch b/patches/put_filp-2.6.24.patch
new file mode 100644
index 0000000..90640a0
--- /dev/null
+++ b/patches/put_filp-2.6.24.patch
@@ -0,0 +1,16 @@
+Index: fs/file_table.c
+===================================================================
+RCS file: /ext1/sysadm/transparent/repository/linux-2.6.23-rc6/fs/file_table.c,v
+retrieving revision 1.1
+retrieving revision 1.2
+diff -u -p -r1.1 -r1.2
+--- fs/file_table.c 12 Sep 2007 16:24:04 -0000 1.1
++++ fs/file_table.c 12 Sep 2007 16:24:38 -0000 1.2
+@@ -243,6 +243,7 @@ void put_filp(struct file *file)
+ file_free(file);
+ }
+ }
++EXPORT_SYMBOL(put_filp);
+
+ void file_move(struct file *file, struct list_head *list)
+ {
diff --git a/patches/sec_perm-2.6.24.patch b/patches/sec_perm-2.6.24.patch
new file mode 100644
index 0000000..de9b299
--- /dev/null
+++ b/patches/sec_perm-2.6.24.patch
@@ -0,0 +1,16 @@
+Index: linux-2.6.24-rc3/security/security.c
+===================================================================
+RCS file: /ext1/sysadm/transparent/repository/linux-2.6.24-rc3/security/security.c,v
+retrieving revision 1.1
+retrieving revision 1.2
+diff -u -p -r1.1 -r1.2
+--- linux-2.6.24-rc3/security/security.c 21 Nov 2007 13:03:11 -0000 1.1
++++ linux-2.6.24-rc3/security/security.c 21 Nov 2007 13:07:55 -0000 1.2
+@@ -409,6 +409,7 @@ int security_inode_permission(struct ino
+ return 0;
+ return security_ops->inode_permission(inode, mask, nd);
+ }
++EXPORT_SYMBOL(security_inode_permission);
+
+ int security_inode_setattr(struct dentry *dentry, struct iattr *attr)
+ {
diff --git a/patches/sis671-intelgly-2.6.24.patch b/patches/sis671-intelgly-2.6.24.patch
new file mode 100644
index 0000000..d137fa1
--- /dev/null
+++ b/patches/sis671-intelgly-2.6.24.patch
@@ -0,0 +1,49 @@
+diff -urN linux-2.6.23.1-orig/drivers/char/agp/sis-agp.c linux-2.6.23.1/drivers/char/agp/sis-agp.c
+--- linux-2.6.23.1-orig/drivers/char/agp/sis-agp.c 2007-10-12 19:43:44.000000000 +0300
++++ linux-2.6.23.1/drivers/char/agp/sis-agp.c 2007-11-07 10:46:49.000000000 +0200
+@@ -331,6 +331,22 @@
+ .class = (PCI_CLASS_BRIDGE_HOST << 8),
+ .class_mask = ~0,
+ .vendor = PCI_VENDOR_ID_SI,
++ .device = PCI_DEVICE_ID_SI_662,
++ .subvendor = PCI_ANY_ID,
++ .subdevice = PCI_ANY_ID,
++ },
++ {
++ .class = (PCI_CLASS_BRIDGE_HOST << 8),
++ .class_mask = ~0,
++ .vendor = PCI_VENDOR_ID_SI,
++ .device = PCI_DEVICE_ID_SI_671,
++ .subvendor = PCI_ANY_ID,
++ .subdevice = PCI_ANY_ID,
++ },
++ {
++ .class = (PCI_CLASS_BRIDGE_HOST << 8),
++ .class_mask = ~0,
++ .vendor = PCI_VENDOR_ID_SI,
+ .device = PCI_DEVICE_ID_SI_730,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
+diff -urN linux-2.6.23.1-orig/drivers/char/drm/drm_pciids.h linux-2.6.23.1/drivers/char/drm/drm_pciids.h
+--- linux-2.6.23.1-orig/drivers/char/drm/drm_pciids.h 2007-10-12 19:43:44.000000000 +0300
++++ linux-2.6.23.1/drivers/char/drm/drm_pciids.h 2007-11-07 10:48:10.000000000 +0200
+@@ -218,6 +218,7 @@
+ {0x1039, 0x5300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
+ {0x1039, 0x6300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
+ {0x1039, 0x6330, PCI_ANY_ID, PCI_ANY_ID, 0, 0, SIS_CHIP_315}, \
++ {0x1039, 0x6351, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* new add */ \
+ {0x1039, 0x7300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
+ {0x18CA, 0x0040, PCI_ANY_ID, PCI_ANY_ID, 0, 0, SIS_CHIP_315}, \
+ {0x18CA, 0x0042, PCI_ANY_ID, PCI_ANY_ID, 0, 0, SIS_CHIP_315}, \
+diff -urN linux-2.6.23.1-orig/include/linux/pci_ids.h linux-2.6.23.1/include/linux/pci_ids.h
+--- linux-2.6.23.1-orig/include/linux/pci_ids.h 2007-11-05 11:35:50.000000000 +0200
++++ linux-2.6.23.1/include/linux/pci_ids.h 2007-11-07 10:49:16.000000000 +0200
+@@ -654,6 +654,8 @@
+ #define PCI_DEVICE_ID_SI_651 0x0651
+ #define PCI_DEVICE_ID_SI_655 0x0655
+ #define PCI_DEVICE_ID_SI_661 0x0661
++#define PCI_DEVICE_ID_SI_662 0x0662 /* new add */
++#define PCI_DEVICE_ID_SI_671 0x0671 /* new add */
+ #define PCI_DEVICE_ID_SI_730 0x0730
+ #define PCI_DEVICE_ID_SI_733 0x0733
+ #define PCI_DEVICE_ID_SI_630_VGA 0x6300
diff --git a/patches/squashfs3.3-patch b/patches/squashfs3.3-patch
new file mode 100644
index 0000000..cb9a5c4
--- /dev/null
+++ b/patches/squashfs3.3-patch
@@ -0,0 +1,4234 @@
+diff -x .gitignore -Nurp linux-2.6.24/fs/Kconfig linux-2.6.24-squashfs3.3/fs/Kconfig
+--- linux-2.6.24/fs/Kconfig 2007-10-25 17:41:45.000000000 +0100
++++ linux-2.6.24-squashfs3.3/fs/Kconfig 2007-11-01 05:06:25.000000000 +0000
+@@ -1396,6 +1396,56 @@ config CRAMFS
+
+ If unsure, say N.
+
++config SQUASHFS
++ tristate "SquashFS 3.3 - Squashed file system support"
++ select ZLIB_INFLATE
++ help
++ Saying Y here includes support for SquashFS 3.3 (a Compressed
++ Read-Only File System). Squashfs is a highly compressed read-only
++ filesystem for Linux. It uses zlib compression to compress both
++ files, inodes and directories. Inodes in the system are very small
++ and all blocks are packed to minimise data overhead. Block sizes
++ greater than 4K are supported up to a maximum of 1 Mbytes (default
++ block size 128K). SquashFS 3.3 supports 64 bit filesystems and files
++ (larger than 4GB), full uid/gid information, hard links and timestamps.
++
++ Squashfs is intended for general read-only filesystem use, for
++ archival use (i.e. in cases where a .tar.gz file may be used), and in
++ embedded systems where low overhead is needed. Further information
++ and filesystem tools are available from http://squashfs.sourceforge.net.
++
++ If you want to compile this as a module ( = code which can be
++ inserted in and removed from the running kernel whenever you want),
++ say M here and read <file:Documentation/modules.txt>. The module
++ will be called squashfs. Note that the root file system (the one
++ containing the directory /) cannot be compiled as a module.
++
++ If unsure, say N.
++
++config SQUASHFS_EMBEDDED
++
++ bool "Additional option for memory-constrained systems"
++ depends on SQUASHFS
++ default n
++ help
++ Saying Y here allows you to specify cache size.
++
++ If unsure, say N.
++
++config SQUASHFS_FRAGMENT_CACHE_SIZE
++ int "Number of fragments cached" if SQUASHFS_EMBEDDED
++ depends on SQUASHFS
++ default "3"
++ help
++ By default SquashFS caches the last 3 fragments read from
++ the filesystem. Increasing this amount may mean SquashFS
++ has to re-read fragments less often from disk, at the expense
++ of extra system memory. Decreasing this amount will mean
++ SquashFS uses less memory at the expense of extra reads from disk.
++
++ Note there must be at least one cached fragment. Anything
++ much more than three will probably not make much difference.
++
+ config VXFS_FS
+ tristate "FreeVxFS file system support (VERITAS VxFS(TM) compatible)"
+ depends on BLOCK
+diff -x .gitignore -Nurp linux-2.6.24/fs/Makefile linux-2.6.24-squashfs3.3/fs/Makefile
+--- linux-2.6.24/fs/Makefile 2007-10-25 17:41:45.000000000 +0100
++++ linux-2.6.24-squashfs3.3/fs/Makefile 2007-11-01 05:08:09.000000000 +0000
+@@ -72,6 +72,7 @@ obj-$(CONFIG_JBD) += jbd/
+ obj-$(CONFIG_JBD2) += jbd2/
+ obj-$(CONFIG_EXT2_FS) += ext2/
+ obj-$(CONFIG_CRAMFS) += cramfs/
++obj-$(CONFIG_SQUASHFS) += squashfs/
+ obj-y += ramfs/
+ obj-$(CONFIG_HUGETLBFS) += hugetlbfs/
+ obj-$(CONFIG_CODA_FS) += coda/
+diff -x .gitignore -Nurp linux-2.6.24/fs/squashfs/inode.c linux-2.6.24-squashfs3.3/fs/squashfs/inode.c
+--- linux-2.6.24/fs/squashfs/inode.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.24-squashfs3.3/fs/squashfs/inode.c 2007-11-01 05:05:00.000000000 +0000
+@@ -0,0 +1,2192 @@
++/*
++ * Squashfs - a compressed read only filesystem for Linux
++ *
++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007
++ * Phillip Lougher <phillip@lougher.demon.co.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version 2,
++ * or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++ *
++ * inode.c
++ */
++
++#include <linux/squashfs_fs.h>
++#include <linux/module.h>
++#include <linux/zlib.h>
++#include <linux/fs.h>
++#include <linux/squashfs_fs_sb.h>
++#include <linux/squashfs_fs_i.h>
++#include <linux/buffer_head.h>
++#include <linux/vfs.h>
++#include <linux/vmalloc.h>
++#include <linux/smp_lock.h>
++#include <linux/exportfs.h>
++
++#include "squashfs.h"
++
++int squashfs_cached_blks;
++
++static void vfs_read_inode(struct inode *i);
++static struct dentry *squashfs_get_parent(struct dentry *child);
++static int squashfs_read_inode(struct inode *i, squashfs_inode_t inode);
++static int squashfs_statfs(struct dentry *, struct kstatfs *);
++static int squashfs_symlink_readpage(struct file *file, struct page *page);
++static long long read_blocklist(struct inode *inode, int index,
++ int readahead_blks, char *block_list,
++ unsigned short **block_p, unsigned int *bsize);
++static int squashfs_readpage(struct file *file, struct page *page);
++static int squashfs_readdir(struct file *, void *, filldir_t);
++static struct dentry *squashfs_lookup(struct inode *, struct dentry *,
++ struct nameidata *);
++static int squashfs_remount(struct super_block *s, int *flags, char *data);
++static void squashfs_put_super(struct super_block *);
++static int squashfs_get_sb(struct file_system_type *,int, const char *, void *,
++ struct vfsmount *);
++static struct inode *squashfs_alloc_inode(struct super_block *sb);
++static void squashfs_destroy_inode(struct inode *inode);
++static int init_inodecache(void);
++static void destroy_inodecache(void);
++
++static struct file_system_type squashfs_fs_type = {
++ .owner = THIS_MODULE,
++ .name = "squashfs",
++ .get_sb = squashfs_get_sb,
++ .kill_sb = kill_block_super,
++ .fs_flags = FS_REQUIRES_DEV
++};
++
++static const unsigned char squashfs_filetype_table[] = {
++ DT_UNKNOWN, DT_DIR, DT_REG, DT_LNK, DT_BLK, DT_CHR, DT_FIFO, DT_SOCK
++};
++
++static struct super_operations squashfs_super_ops = {
++ .alloc_inode = squashfs_alloc_inode,
++ .destroy_inode = squashfs_destroy_inode,
++ .statfs = squashfs_statfs,
++ .put_super = squashfs_put_super,
++ .remount_fs = squashfs_remount
++};
++
++static struct super_operations squashfs_export_super_ops = {
++ .alloc_inode = squashfs_alloc_inode,
++ .destroy_inode = squashfs_destroy_inode,
++ .statfs = squashfs_statfs,
++ .put_super = squashfs_put_super,
++ .read_inode = vfs_read_inode
++};
++
++static struct export_operations squashfs_export_ops = {
++ .get_parent = squashfs_get_parent
++};
++
++SQSH_EXTERN const struct address_space_operations squashfs_symlink_aops = {
++ .readpage = squashfs_symlink_readpage
++};
++
++SQSH_EXTERN const struct address_space_operations squashfs_aops = {
++ .readpage = squashfs_readpage
++};
++
++static const struct file_operations squashfs_dir_ops = {
++ .read = generic_read_dir,
++ .readdir = squashfs_readdir
++};
++
++SQSH_EXTERN struct inode_operations squashfs_dir_inode_ops = {
++ .lookup = squashfs_lookup
++};
++
++
++static struct buffer_head *get_block_length(struct super_block *s,
++ int *cur_index, int *offset, int *c_byte)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ unsigned short temp;
++ struct buffer_head *bh;
++
++ if (!(bh = sb_bread(s, *cur_index)))
++ goto out;
++
++ if (msblk->devblksize - *offset == 1) {
++ if (msblk->swap)
++ ((unsigned char *) &temp)[1] = *((unsigned char *)
++ (bh->b_data + *offset));
++ else
++ ((unsigned char *) &temp)[0] = *((unsigned char *)
++ (bh->b_data + *offset));
++ brelse(bh);
++ if (!(bh = sb_bread(s, ++(*cur_index))))
++ goto out;
++ if (msblk->swap)
++ ((unsigned char *) &temp)[0] = *((unsigned char *)
++ bh->b_data);
++ else
++ ((unsigned char *) &temp)[1] = *((unsigned char *)
++ bh->b_data);
++ *c_byte = temp;
++ *offset = 1;
++ } else {
++ if (msblk->swap) {
++ ((unsigned char *) &temp)[1] = *((unsigned char *)
++ (bh->b_data + *offset));
++ ((unsigned char *) &temp)[0] = *((unsigned char *)
++ (bh->b_data + *offset + 1));
++ } else {
++ ((unsigned char *) &temp)[0] = *((unsigned char *)
++ (bh->b_data + *offset));
++ ((unsigned char *) &temp)[1] = *((unsigned char *)
++ (bh->b_data + *offset + 1));
++ }
++ *c_byte = temp;
++ *offset += 2;
++ }
++
++ if (SQUASHFS_CHECK_DATA(msblk->sblk.flags)) {
++ if (*offset == msblk->devblksize) {
++ brelse(bh);
++ if (!(bh = sb_bread(s, ++(*cur_index))))
++ goto out;
++ *offset = 0;
++ }
++ if (*((unsigned char *) (bh->b_data + *offset)) !=
++ SQUASHFS_MARKER_BYTE) {
++ ERROR("Metadata block marker corrupt @ %x\n",
++ *cur_index);
++ brelse(bh);
++ goto out;
++ }
++ (*offset)++;
++ }
++ return bh;
++
++out:
++ return NULL;
++}
++
++
++SQSH_EXTERN unsigned int squashfs_read_data(struct super_block *s, char *buffer,
++ long long index, unsigned int length,
++ long long *next_index, int srclength)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ struct buffer_head **bh;
++ unsigned int offset = index & ((1 << msblk->devblksize_log2) - 1);
++ unsigned int cur_index = index >> msblk->devblksize_log2;
++ int bytes, avail_bytes, b = 0, k = 0;
++ unsigned int compressed;
++ unsigned int c_byte = length;
++
++ bh = kmalloc(((sblk->block_size >> msblk->devblksize_log2) + 1) *
++ sizeof(struct buffer_head *), GFP_KERNEL);
++ if (bh == NULL)
++ goto read_failure;
++
++ if (c_byte) {
++ bytes = msblk->devblksize - offset;
++ compressed = SQUASHFS_COMPRESSED_BLOCK(c_byte);
++ c_byte = SQUASHFS_COMPRESSED_SIZE_BLOCK(c_byte);
++
++ TRACE("Block @ 0x%llx, %scompressed size %d, src size %d\n", index,
++ compressed ? "" : "un", (unsigned int) c_byte, srclength);
++
++ if (c_byte > srclength || index < 0 || (index + c_byte) > sblk->bytes_used)
++ goto read_failure;
++
++ bh[0] = sb_getblk(s, cur_index);
++ if (bh[0] == NULL)
++ goto block_release;
++
++ for (b = 1; bytes < c_byte; b++) {
++ bh[b] = sb_getblk(s, ++cur_index);
++ if (bh[b] == NULL)
++ goto block_release;
++ bytes += msblk->devblksize;
++ }
++ ll_rw_block(READ, b, bh);
++ } else {
++ if (index < 0 || (index + 2) > sblk->bytes_used)
++ goto read_failure;
++
++ bh[0] = get_block_length(s, &cur_index, &offset, &c_byte);
++ if (bh[0] == NULL)
++ goto read_failure;
++
++ bytes = msblk->devblksize - offset;
++ compressed = SQUASHFS_COMPRESSED(c_byte);
++ c_byte = SQUASHFS_COMPRESSED_SIZE(c_byte);
++
++ TRACE("Block @ 0x%llx, %scompressed size %d\n", index, compressed
++ ? "" : "un", (unsigned int) c_byte);
++
++ if (c_byte > srclength || (index + c_byte) > sblk->bytes_used)
++ goto read_failure;
++
++ for (b = 1; bytes < c_byte; b++) {
++ bh[b] = sb_getblk(s, ++cur_index);
++ if (bh[b] == NULL)
++ goto block_release;
++ bytes += msblk->devblksize;
++ }
++ ll_rw_block(READ, b - 1, bh + 1);
++ }
++
++ if (compressed) {
++ int zlib_err = 0;
++
++ /*
++ * uncompress block
++ */
++
++ mutex_lock(&msblk->read_data_mutex);
++
++ msblk->stream.next_out = buffer;
++ msblk->stream.avail_out = srclength;
++
++ for (bytes = 0; k < b; k++) {
++ avail_bytes = min(c_byte - bytes, msblk->devblksize - offset);
++
++ wait_on_buffer(bh[k]);
++ if (!buffer_uptodate(bh[k]))
++ goto release_mutex;
++
++ msblk->stream.next_in = bh[k]->b_data + offset;
++ msblk->stream.avail_in = avail_bytes;
++
++ if (k == 0) {
++ zlib_err = zlib_inflateInit(&msblk->stream);
++ if (zlib_err != Z_OK) {
++ ERROR("zlib_inflateInit returned unexpected result 0x%x,"
++ " srclength %d\n", zlib_err, srclength);
++ goto release_mutex;
++ }
++
++ if (avail_bytes == 0) {
++ offset = 0;
++ brelse(bh[k]);
++ continue;
++ }
++ }
++
++ zlib_err = zlib_inflate(&msblk->stream, Z_NO_FLUSH);
++ if (zlib_err != Z_OK && zlib_err != Z_STREAM_END) {
++ ERROR("zlib_inflate returned unexpected result 0x%x,"
++ " srclength %d, avail_in %d, avail_out %d\n", zlib_err,
++ srclength, msblk->stream.avail_in, msblk->stream.avail_out);
++ goto release_mutex;
++ }
++
++ bytes += avail_bytes;
++ offset = 0;
++ brelse(bh[k]);
++ }
++
++ if (zlib_err != Z_STREAM_END)
++ goto release_mutex;
++
++ zlib_err = zlib_inflateEnd(&msblk->stream);
++ if (zlib_err != Z_OK) {
++ ERROR("zlib_inflateEnd returned unexpected result 0x%x,"
++ " srclength %d\n", zlib_err, srclength);
++ goto release_mutex;
++ }
++ bytes = msblk->stream.total_out;
++ mutex_unlock(&msblk->read_data_mutex);
++ } else {
++ int i;
++
++ for(i = 0; i < b; i++) {
++ wait_on_buffer(bh[i]);
++ if (!buffer_uptodate(bh[i]))
++ goto block_release;
++ }
++
++ for (bytes = 0; k < b; k++) {
++ avail_bytes = min(c_byte - bytes, msblk->devblksize - offset);
++
++ memcpy(buffer + bytes, bh[k]->b_data + offset, avail_bytes);
++ bytes += avail_bytes;
++ offset = 0;
++ brelse(bh[k]);
++ }
++ }
++
++ if (next_index)
++ *next_index = index + c_byte + (length ? 0 :
++ (SQUASHFS_CHECK_DATA(msblk->sblk.flags) ? 3 : 2));
++
++ kfree(bh);
++ return bytes;
++
++release_mutex:
++ mutex_unlock(&msblk->read_data_mutex);
++
++block_release:
++ for (; k < b; k++)
++ brelse(bh[k]);
++
++read_failure:
++ ERROR("sb_bread failed reading block 0x%x\n", cur_index);
++ kfree(bh);
++ return 0;
++}
++
++
++SQSH_EXTERN int squashfs_get_cached_block(struct super_block *s, void *buffer,
++ long long block, unsigned int offset,
++ int length, long long *next_block,
++ unsigned int *next_offset)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ int n, i, bytes, return_length = length;
++ long long next_index;
++
++ TRACE("Entered squashfs_get_cached_block [%llx:%x]\n", block, offset);
++
++ while (1) {
++ for (i = 0; i < squashfs_cached_blks; i++)
++ if (msblk->block_cache[i].block == block)
++ break;
++
++ mutex_lock(&msblk->block_cache_mutex);
++
++ if (i == squashfs_cached_blks) {
++ /* read inode header block */
++ if (msblk->unused_cache_blks == 0) {
++ mutex_unlock(&msblk->block_cache_mutex);
++ wait_event(msblk->waitq, msblk->unused_cache_blks);
++ continue;
++ }
++
++ i = msblk->next_cache;
++ for (n = 0; n < squashfs_cached_blks; n++) {
++ if (msblk->block_cache[i].block != SQUASHFS_USED_BLK)
++ break;
++ i = (i + 1) % squashfs_cached_blks;
++ }
++
++ msblk->next_cache = (i + 1) % squashfs_cached_blks;
++
++ if (msblk->block_cache[i].block == SQUASHFS_INVALID_BLK) {
++ msblk->block_cache[i].data = vmalloc(SQUASHFS_METADATA_SIZE);
++ if (msblk->block_cache[i].data == NULL) {
++ ERROR("Failed to allocate cache block\n");
++ mutex_unlock(&msblk->block_cache_mutex);
++ goto out;
++ }
++ }
++
++ msblk->block_cache[i].block = SQUASHFS_USED_BLK;
++ msblk->unused_cache_blks --;
++ mutex_unlock(&msblk->block_cache_mutex);
++
++ msblk->block_cache[i].length = squashfs_read_data(s,
++ msblk->block_cache[i].data, block, 0, &next_index,
++ SQUASHFS_METADATA_SIZE);
++
++ if (msblk->block_cache[i].length == 0) {
++ ERROR("Unable to read cache block [%llx:%x]\n", block, offset);
++ mutex_lock(&msblk->block_cache_mutex);
++ msblk->block_cache[i].block = SQUASHFS_INVALID_BLK;
++ msblk->unused_cache_blks ++;
++ smp_mb();
++ vfree(msblk->block_cache[i].data);
++ wake_up(&msblk->waitq);
++ mutex_unlock(&msblk->block_cache_mutex);
++ goto out;
++ }
++
++ mutex_lock(&msblk->block_cache_mutex);
++ msblk->block_cache[i].block = block;
++ msblk->block_cache[i].next_index = next_index;
++ msblk->unused_cache_blks ++;
++ smp_mb();
++ wake_up(&msblk->waitq);
++ TRACE("Read cache block [%llx:%x]\n", block, offset);
++ }
++
++ if (msblk->block_cache[i].block != block) {
++ mutex_unlock(&msblk->block_cache_mutex);
++ continue;
++ }
++
++ bytes = msblk->block_cache[i].length - offset;
++
++ if (bytes < 1) {
++ mutex_unlock(&msblk->block_cache_mutex);
++ goto out;
++ } else if (bytes >= length) {
++ if (buffer)
++ memcpy(buffer, msblk->block_cache[i].data + offset, length);
++ if (msblk->block_cache[i].length - offset == length) {
++ *next_block = msblk->block_cache[i].next_index;
++ *next_offset = 0;
++ } else {
++ *next_block = block;
++ *next_offset = offset + length;
++ }
++ mutex_unlock(&msblk->block_cache_mutex);
++ goto finish;
++ } else {
++ if (buffer) {
++ memcpy(buffer, msblk->block_cache[i].data + offset, bytes);
++ buffer = (char *) buffer + bytes;
++ }
++ block = msblk->block_cache[i].next_index;
++ mutex_unlock(&msblk->block_cache_mutex);
++ length -= bytes;
++ offset = 0;
++ }
++ }
++
++finish:
++ return return_length;
++out:
++ return 0;
++}
++
++
++static int get_fragment_location(struct super_block *s, unsigned int fragment,
++ long long *fragment_start_block,
++ unsigned int *fragment_size)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ long long start_block =
++ msblk->fragment_index[SQUASHFS_FRAGMENT_INDEX(fragment)];
++ int offset = SQUASHFS_FRAGMENT_INDEX_OFFSET(fragment);
++ struct squashfs_fragment_entry fragment_entry;
++
++ if (msblk->swap) {
++ struct squashfs_fragment_entry sfragment_entry;
++
++ if (!squashfs_get_cached_block(s, &sfragment_entry, start_block, offset,
++ sizeof(sfragment_entry), &start_block, &offset))
++ goto out;
++ SQUASHFS_SWAP_FRAGMENT_ENTRY(&fragment_entry, &sfragment_entry);
++ } else
++ if (!squashfs_get_cached_block(s, &fragment_entry, start_block, offset,
++ sizeof(fragment_entry), &start_block, &offset))
++ goto out;
++
++ *fragment_start_block = fragment_entry.start_block;
++ *fragment_size = fragment_entry.size;
++
++ return 1;
++
++out:
++ return 0;
++}
++
++
++SQSH_EXTERN void release_cached_fragment(struct squashfs_sb_info *msblk,
++ struct squashfs_fragment_cache *fragment)
++{
++ mutex_lock(&msblk->fragment_mutex);
++ fragment->locked --;
++ if (fragment->locked == 0) {
++ msblk->unused_frag_blks ++;
++ smp_mb();
++ wake_up(&msblk->fragment_wait_queue);
++ }
++ mutex_unlock(&msblk->fragment_mutex);
++}
++
++
++SQSH_EXTERN
++struct squashfs_fragment_cache *get_cached_fragment(struct super_block *s,
++ long long start_block, int length)
++{
++ int i, n;
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++
++ while (1) {
++ mutex_lock(&msblk->fragment_mutex);
++
++ for (i = 0; i < SQUASHFS_CACHED_FRAGMENTS &&
++ msblk->fragment[i].block != start_block; i++);
++
++ if (i == SQUASHFS_CACHED_FRAGMENTS) {
++ if (msblk->unused_frag_blks == 0) {
++ mutex_unlock(&msblk->fragment_mutex);
++ wait_event(msblk->fragment_wait_queue, msblk->unused_frag_blks);
++ continue;
++ }
++
++ i = msblk->next_fragment;
++ for (n = 0; n < SQUASHFS_CACHED_FRAGMENTS; n++) {
++ if (msblk->fragment[i].locked == 0)
++ break;
++ i = (i + 1) % SQUASHFS_CACHED_FRAGMENTS;
++ }
++
++ msblk->next_fragment = (msblk->next_fragment + 1) %
++ SQUASHFS_CACHED_FRAGMENTS;
++
++ if (msblk->fragment[i].data == NULL) {
++ msblk->fragment[i].data = vmalloc(sblk->block_size);
++ if (msblk->fragment[i].data == NULL) {
++ ERROR("Failed to allocate fragment cache block\n");
++ mutex_unlock(&msblk->fragment_mutex);
++ goto out;
++ }
++ }
++
++ msblk->unused_frag_blks --;
++ msblk->fragment[i].block = SQUASHFS_INVALID_BLK;
++ msblk->fragment[i].locked = 1;
++ mutex_unlock(&msblk->fragment_mutex);
++
++ msblk->fragment[i].length = squashfs_read_data(s,
++ msblk->fragment[i].data, start_block, length, NULL,
++ sblk->block_size);
++
++ if (msblk->fragment[i].length == 0) {
++ ERROR("Unable to read fragment cache block [%llx]\n", start_block);
++ msblk->fragment[i].locked = 0;
++ msblk->unused_frag_blks ++;
++ smp_mb();
++ wake_up(&msblk->fragment_wait_queue);
++ goto out;
++ }
++
++ mutex_lock(&msblk->fragment_mutex);
++ msblk->fragment[i].block = start_block;
++ TRACE("New fragment %d, start block %lld, locked %d\n",
++ i, msblk->fragment[i].block, msblk->fragment[i].locked);
++ mutex_unlock(&msblk->fragment_mutex);
++ break;
++ }
++
++ if (msblk->fragment[i].locked == 0)
++ msblk->unused_frag_blks --;
++ msblk->fragment[i].locked++;
++ mutex_unlock(&msblk->fragment_mutex);
++ TRACE("Got fragment %d, start block %lld, locked %d\n", i,
++ msblk->fragment[i].block, msblk->fragment[i].locked);
++ break;
++ }
++
++ return &msblk->fragment[i];
++
++out:
++ return NULL;
++}
++
++
++static void squashfs_new_inode(struct squashfs_sb_info *msblk, struct inode *i,
++ struct squashfs_base_inode_header *inodeb)
++{
++ i->i_ino = inodeb->inode_number;
++ i->i_mtime.tv_sec = inodeb->mtime;
++ i->i_atime.tv_sec = inodeb->mtime;
++ i->i_ctime.tv_sec = inodeb->mtime;
++ i->i_uid = msblk->uid[inodeb->uid];
++ i->i_mode = inodeb->mode;
++ i->i_size = 0;
++
++ if (inodeb->guid == SQUASHFS_GUIDS)
++ i->i_gid = i->i_uid;
++ else
++ i->i_gid = msblk->guid[inodeb->guid];
++}
++
++
++static squashfs_inode_t squashfs_inode_lookup(struct super_block *s, int ino)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ long long start = msblk->inode_lookup_table[SQUASHFS_LOOKUP_BLOCK(ino - 1)];
++ int offset = SQUASHFS_LOOKUP_BLOCK_OFFSET(ino - 1);
++ squashfs_inode_t inode;
++
++ TRACE("Entered squashfs_inode_lookup, inode_number = %d\n", ino);
++
++ if (msblk->swap) {
++ squashfs_inode_t sinode;
++
++ if (!squashfs_get_cached_block(s, &sinode, start, offset,
++ sizeof(sinode), &start, &offset))
++ goto out;
++ SQUASHFS_SWAP_INODE_T((&inode), &sinode);
++ } else if (!squashfs_get_cached_block(s, &inode, start, offset,
++ sizeof(inode), &start, &offset))
++ goto out;
++
++ TRACE("squashfs_inode_lookup, inode = 0x%llx\n", inode);
++
++ return inode;
++
++out:
++ return SQUASHFS_INVALID_BLK;
++}
++
++
++static void vfs_read_inode(struct inode *i)
++{
++ struct squashfs_sb_info *msblk = i->i_sb->s_fs_info;
++ squashfs_inode_t inode = squashfs_inode_lookup(i->i_sb, i->i_ino);
++
++ TRACE("Entered vfs_read_inode\n");
++
++ if(inode != SQUASHFS_INVALID_BLK)
++ (msblk->read_inode)(i, inode);
++}
++
++
++static struct dentry *squashfs_get_parent(struct dentry *child)
++{
++ struct inode *i = child->d_inode;
++ struct inode *parent = iget(i->i_sb, SQUASHFS_I(i)->u.s2.parent_inode);
++ struct dentry *rv;
++
++ TRACE("Entered squashfs_get_parent\n");
++
++ if(parent == NULL) {
++ rv = ERR_PTR(-EACCES);
++ goto out;
++ }
++
++ rv = d_alloc_anon(parent);
++ if(rv == NULL)
++ rv = ERR_PTR(-ENOMEM);
++
++out:
++ return rv;
++}
++
++
++SQSH_EXTERN struct inode *squashfs_iget(struct super_block *s,
++ squashfs_inode_t inode, unsigned int inode_number)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct inode *i = iget_locked(s, inode_number);
++
++ TRACE("Entered squashfs_iget\n");
++
++ if(i && (i->i_state & I_NEW)) {
++ (msblk->read_inode)(i, inode);
++ unlock_new_inode(i);
++ }
++
++ return i;
++}
++
++
++static int squashfs_read_inode(struct inode *i, squashfs_inode_t inode)
++{
++ struct super_block *s = i->i_sb;
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ long long block = SQUASHFS_INODE_BLK(inode) + sblk->inode_table_start;
++ unsigned int offset = SQUASHFS_INODE_OFFSET(inode);
++ long long next_block;
++ unsigned int next_offset;
++ union squashfs_inode_header id, sid;
++ struct squashfs_base_inode_header *inodeb = &id.base, *sinodeb = &sid.base;
++
++ TRACE("Entered squashfs_read_inode\n");
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, sinodeb, block, offset,
++ sizeof(*sinodeb), &next_block, &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_BASE_INODE_HEADER(inodeb, sinodeb, sizeof(*sinodeb));
++ } else
++ if (!squashfs_get_cached_block(s, inodeb, block, offset,
++ sizeof(*inodeb), &next_block, &next_offset))
++ goto failed_read;
++
++ squashfs_new_inode(msblk, i, inodeb);
++
++ switch(inodeb->inode_type) {
++ case SQUASHFS_FILE_TYPE: {
++ unsigned int frag_size;
++ long long frag_blk;
++ struct squashfs_reg_inode_header *inodep = &id.reg;
++ struct squashfs_reg_inode_header *sinodep = &sid.reg;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, sinodep, block, offset,
++ sizeof(*sinodep), &next_block, &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_REG_INODE_HEADER(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, inodep, block, offset,
++ sizeof(*inodep), &next_block, &next_offset))
++ goto failed_read;
++
++ frag_blk = SQUASHFS_INVALID_BLK;
++
++ if (inodep->fragment != SQUASHFS_INVALID_FRAG)
++ if(!get_fragment_location(s, inodep->fragment, &frag_blk,
++ &frag_size))
++ goto failed_read;
++
++ i->i_nlink = 1;
++ i->i_size = inodep->file_size;
++ i->i_fop = &generic_ro_fops;
++ i->i_mode |= S_IFREG;
++ i->i_blocks = ((i->i_size - 1) >> 9) + 1;
++ SQUASHFS_I(i)->u.s1.fragment_start_block = frag_blk;
++ SQUASHFS_I(i)->u.s1.fragment_size = frag_size;
++ SQUASHFS_I(i)->u.s1.fragment_offset = inodep->offset;
++ SQUASHFS_I(i)->start_block = inodep->start_block;
++ SQUASHFS_I(i)->u.s1.block_list_start = next_block;
++ SQUASHFS_I(i)->offset = next_offset;
++ i->i_data.a_ops = &squashfs_aops;
++
++ TRACE("File inode %x:%x, start_block %llx, "
++ "block_list_start %llx, offset %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ inodep->start_block, next_block,
++ next_offset);
++ break;
++ }
++ case SQUASHFS_LREG_TYPE: {
++ unsigned int frag_size;
++ long long frag_blk;
++ struct squashfs_lreg_inode_header *inodep = &id.lreg;
++ struct squashfs_lreg_inode_header *sinodep = &sid.lreg;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, sinodep, block, offset,
++ sizeof(*sinodep), &next_block, &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_LREG_INODE_HEADER(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, inodep, block, offset,
++ sizeof(*inodep), &next_block, &next_offset))
++ goto failed_read;
++
++ frag_blk = SQUASHFS_INVALID_BLK;
++
++ if (inodep->fragment != SQUASHFS_INVALID_FRAG)
++ if (!get_fragment_location(s, inodep->fragment, &frag_blk,
++ &frag_size))
++ goto failed_read;
++
++ i->i_nlink = inodep->nlink;
++ i->i_size = inodep->file_size;
++ i->i_fop = &generic_ro_fops;
++ i->i_mode |= S_IFREG;
++ i->i_blocks = ((i->i_size - 1) >> 9) + 1;
++ SQUASHFS_I(i)->u.s1.fragment_start_block = frag_blk;
++ SQUASHFS_I(i)->u.s1.fragment_size = frag_size;
++ SQUASHFS_I(i)->u.s1.fragment_offset = inodep->offset;
++ SQUASHFS_I(i)->start_block = inodep->start_block;
++ SQUASHFS_I(i)->u.s1.block_list_start = next_block;
++ SQUASHFS_I(i)->offset = next_offset;
++ i->i_data.a_ops = &squashfs_aops;
++
++ TRACE("File inode %x:%x, start_block %llx, "
++ "block_list_start %llx, offset %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ inodep->start_block, next_block,
++ next_offset);
++ break;
++ }
++ case SQUASHFS_DIR_TYPE: {
++ struct squashfs_dir_inode_header *inodep = &id.dir;
++ struct squashfs_dir_inode_header *sinodep = &sid.dir;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, sinodep, block, offset,
++ sizeof(*sinodep), &next_block, &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_DIR_INODE_HEADER(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, inodep, block, offset,
++ sizeof(*inodep), &next_block, &next_offset))
++ goto failed_read;
++
++ i->i_nlink = inodep->nlink;
++ i->i_size = inodep->file_size;
++ i->i_op = &squashfs_dir_inode_ops;
++ i->i_fop = &squashfs_dir_ops;
++ i->i_mode |= S_IFDIR;
++ SQUASHFS_I(i)->start_block = inodep->start_block;
++ SQUASHFS_I(i)->offset = inodep->offset;
++ SQUASHFS_I(i)->u.s2.directory_index_count = 0;
++ SQUASHFS_I(i)->u.s2.parent_inode = inodep->parent_inode;
++
++ TRACE("Directory inode %x:%x, start_block %x, offset "
++ "%x\n", SQUASHFS_INODE_BLK(inode),
++ offset, inodep->start_block,
++ inodep->offset);
++ break;
++ }
++ case SQUASHFS_LDIR_TYPE: {
++ struct squashfs_ldir_inode_header *inodep = &id.ldir;
++ struct squashfs_ldir_inode_header *sinodep = &sid.ldir;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, sinodep, block, offset,
++ sizeof(*sinodep), &next_block, &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_LDIR_INODE_HEADER(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, inodep, block, offset,
++ sizeof(*inodep), &next_block, &next_offset))
++ goto failed_read;
++
++ i->i_nlink = inodep->nlink;
++ i->i_size = inodep->file_size;
++ i->i_op = &squashfs_dir_inode_ops;
++ i->i_fop = &squashfs_dir_ops;
++ i->i_mode |= S_IFDIR;
++ SQUASHFS_I(i)->start_block = inodep->start_block;
++ SQUASHFS_I(i)->offset = inodep->offset;
++ SQUASHFS_I(i)->u.s2.directory_index_start = next_block;
++ SQUASHFS_I(i)->u.s2.directory_index_offset = next_offset;
++ SQUASHFS_I(i)->u.s2.directory_index_count = inodep->i_count;
++ SQUASHFS_I(i)->u.s2.parent_inode = inodep->parent_inode;
++
++ TRACE("Long directory inode %x:%x, start_block %x, offset %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ inodep->start_block, inodep->offset);
++ break;
++ }
++ case SQUASHFS_SYMLINK_TYPE: {
++ struct squashfs_symlink_inode_header *inodep = &id.symlink;
++ struct squashfs_symlink_inode_header *sinodep = &sid.symlink;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, sinodep, block, offset,
++ sizeof(*sinodep), &next_block, &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_SYMLINK_INODE_HEADER(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, inodep, block, offset,
++ sizeof(*inodep), &next_block, &next_offset))
++ goto failed_read;
++
++ i->i_nlink = inodep->nlink;
++ i->i_size = inodep->symlink_size;
++ i->i_op = &page_symlink_inode_operations;
++ i->i_data.a_ops = &squashfs_symlink_aops;
++ i->i_mode |= S_IFLNK;
++ SQUASHFS_I(i)->start_block = next_block;
++ SQUASHFS_I(i)->offset = next_offset;
++
++ TRACE("Symbolic link inode %x:%x, start_block %llx, offset %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ next_block, next_offset);
++ break;
++ }
++ case SQUASHFS_BLKDEV_TYPE:
++ case SQUASHFS_CHRDEV_TYPE: {
++ struct squashfs_dev_inode_header *inodep = &id.dev;
++ struct squashfs_dev_inode_header *sinodep = &sid.dev;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, sinodep, block, offset,
++ sizeof(*sinodep), &next_block, &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_DEV_INODE_HEADER(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, inodep, block, offset,
++ sizeof(*inodep), &next_block, &next_offset))
++ goto failed_read;
++
++ i->i_nlink = inodep->nlink;
++ i->i_mode |= (inodeb->inode_type == SQUASHFS_CHRDEV_TYPE) ?
++ S_IFCHR : S_IFBLK;
++ init_special_inode(i, i->i_mode, old_decode_dev(inodep->rdev));
++
++ TRACE("Device inode %x:%x, rdev %x\n",
++ SQUASHFS_INODE_BLK(inode), offset, inodep->rdev);
++ break;
++ }
++ case SQUASHFS_FIFO_TYPE:
++ case SQUASHFS_SOCKET_TYPE: {
++ struct squashfs_ipc_inode_header *inodep = &id.ipc;
++ struct squashfs_ipc_inode_header *sinodep = &sid.ipc;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, sinodep, block, offset,
++ sizeof(*sinodep), &next_block, &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_IPC_INODE_HEADER(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, inodep, block, offset,
++ sizeof(*inodep), &next_block, &next_offset))
++ goto failed_read;
++
++ i->i_nlink = inodep->nlink;
++ i->i_mode |= (inodeb->inode_type == SQUASHFS_FIFO_TYPE)
++ ? S_IFIFO : S_IFSOCK;
++ init_special_inode(i, i->i_mode, 0);
++ break;
++ }
++ default:
++ ERROR("Unknown inode type %d in squashfs_iget!\n",
++ inodeb->inode_type);
++ goto failed_read1;
++ }
++
++ return 1;
++
++failed_read:
++ ERROR("Unable to read inode [%llx:%x]\n", block, offset);
++
++failed_read1:
++ make_bad_inode(i);
++ return 0;
++}
++
++
++static int read_inode_lookup_table(struct super_block *s)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ unsigned int length = SQUASHFS_LOOKUP_BLOCK_BYTES(sblk->inodes);
++
++ TRACE("In read_inode_lookup_table, length %d\n", length);
++
++ /* Allocate inode lookup table */
++ msblk->inode_lookup_table = kmalloc(length, GFP_KERNEL);
++ if (msblk->inode_lookup_table == NULL) {
++ ERROR("Failed to allocate inode lookup table\n");
++ return 0;
++ }
++
++ if (!squashfs_read_data(s, (char *) msblk->inode_lookup_table,
++ sblk->lookup_table_start, length |
++ SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, length)) {
++ ERROR("unable to read inode lookup table\n");
++ return 0;
++ }
++
++ if (msblk->swap) {
++ int i;
++ long long block;
++
++ for (i = 0; i < SQUASHFS_LOOKUP_BLOCKS(sblk->inodes); i++) {
++ /* XXX */
++ SQUASHFS_SWAP_LOOKUP_BLOCKS((&block),
++ &msblk->inode_lookup_table[i], 1);
++ msblk->inode_lookup_table[i] = block;
++ }
++ }
++
++ return 1;
++}
++
++
++static int read_fragment_index_table(struct super_block *s)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ unsigned int length = SQUASHFS_FRAGMENT_INDEX_BYTES(sblk->fragments);
++
++ if(length == 0)
++ return 1;
++
++ /* Allocate fragment index table */
++ msblk->fragment_index = kmalloc(length, GFP_KERNEL);
++ if (msblk->fragment_index == NULL) {
++ ERROR("Failed to allocate fragment index table\n");
++ return 0;
++ }
++
++ if (!squashfs_read_data(s, (char *) msblk->fragment_index,
++ sblk->fragment_table_start, length |
++ SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, length)) {
++ ERROR("unable to read fragment index table\n");
++ return 0;
++ }
++
++ if (msblk->swap) {
++ int i;
++ long long fragment;
++
++ for (i = 0; i < SQUASHFS_FRAGMENT_INDEXES(sblk->fragments); i++) {
++ /* XXX */
++ SQUASHFS_SWAP_FRAGMENT_INDEXES((&fragment),
++ &msblk->fragment_index[i], 1);
++ msblk->fragment_index[i] = fragment;
++ }
++ }
++
++ return 1;
++}
++
++
++static int readahead_metadata(struct super_block *s)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ int i;
++
++ squashfs_cached_blks = SQUASHFS_CACHED_BLKS;
++
++ /* Init inode_table block pointer array */
++ msblk->block_cache = kmalloc(sizeof(struct squashfs_cache) *
++ squashfs_cached_blks, GFP_KERNEL);
++ if (msblk->block_cache == NULL) {
++ ERROR("Failed to allocate block cache\n");
++ goto failed;
++ }
++
++ for (i = 0; i < squashfs_cached_blks; i++)
++ msblk->block_cache[i].block = SQUASHFS_INVALID_BLK;
++
++ msblk->next_cache = 0;
++ msblk->unused_cache_blks = squashfs_cached_blks;
++
++ return 1;
++
++failed:
++ return 0;
++}
++
++
++static int supported_squashfs_filesystem(struct squashfs_sb_info *msblk, int silent)
++{
++ struct squashfs_super_block *sblk = &msblk->sblk;
++
++ msblk->read_inode = squashfs_read_inode;
++ msblk->read_blocklist = read_blocklist;
++ msblk->read_fragment_index_table = read_fragment_index_table;
++
++ if (sblk->s_major == 1) {
++ if (!squashfs_1_0_supported(msblk)) {
++ SERROR("Major/Minor mismatch, Squashfs 1.0 filesystems "
++ "are unsupported\n");
++ SERROR("Please recompile with Squashfs 1.0 support enabled\n");
++ return 0;
++ }
++ } else if (sblk->s_major == 2) {
++ if (!squashfs_2_0_supported(msblk)) {
++ SERROR("Major/Minor mismatch, Squashfs 2.0 filesystems "
++ "are unsupported\n");
++ SERROR("Please recompile with Squashfs 2.0 support enabled\n");
++ return 0;
++ }
++ } else if(sblk->s_major != SQUASHFS_MAJOR || sblk->s_minor >
++ SQUASHFS_MINOR) {
++ SERROR("Major/Minor mismatch, trying to mount newer %d.%d "
++ "filesystem\n", sblk->s_major, sblk->s_minor);
++ SERROR("Please update your kernel\n");
++ return 0;
++ }
++
++ return 1;
++}
++
++
++static int squashfs_fill_super(struct super_block *s, void *data, int silent)
++{
++ struct squashfs_sb_info *msblk;
++ struct squashfs_super_block *sblk;
++ int i;
++ char b[BDEVNAME_SIZE];
++ struct inode *root;
++
++ TRACE("Entered squashfs_fill_superblock\n");
++
++ s->s_fs_info = kzalloc(sizeof(struct squashfs_sb_info), GFP_KERNEL);
++ if (s->s_fs_info == NULL) {
++ ERROR("Failed to allocate superblock\n");
++ goto failure;
++ }
++ msblk = s->s_fs_info;
++
++ msblk->stream.workspace = vmalloc(zlib_inflate_workspacesize());
++ if (msblk->stream.workspace == NULL) {
++ ERROR("Failed to allocate zlib workspace\n");
++ goto failure;
++ }
++ sblk = &msblk->sblk;
++
++ msblk->devblksize = sb_min_blocksize(s, BLOCK_SIZE);
++ msblk->devblksize_log2 = ffz(~msblk->devblksize);
++
++ mutex_init(&msblk->read_data_mutex);
++ mutex_init(&msblk->read_page_mutex);
++ mutex_init(&msblk->block_cache_mutex);
++ mutex_init(&msblk->fragment_mutex);
++ mutex_init(&msblk->meta_index_mutex);
++
++ init_waitqueue_head(&msblk->waitq);
++ init_waitqueue_head(&msblk->fragment_wait_queue);
++
++ /* sblk->bytes_used is checked in squashfs_read_data to ensure reads are not
++ * beyond filesystem end. As we're using squashfs_read_data to read sblk here,
++ * first set sblk->bytes_used to a useful value */
++ sblk->bytes_used = sizeof(struct squashfs_super_block);
++ if (!squashfs_read_data(s, (char *) sblk, SQUASHFS_START,
++ sizeof(struct squashfs_super_block) |
++ SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, sizeof(struct squashfs_super_block))) {
++ SERROR("unable to read superblock\n");
++ goto failed_mount;
++ }
++
++ /* Check it is a SQUASHFS superblock */
++ if ((s->s_magic = sblk->s_magic) != SQUASHFS_MAGIC) {
++ if (sblk->s_magic == SQUASHFS_MAGIC_SWAP) {
++ struct squashfs_super_block ssblk;
++
++ WARNING("Mounting a different endian SQUASHFS filesystem on %s\n",
++ bdevname(s->s_bdev, b));
++
++ SQUASHFS_SWAP_SUPER_BLOCK(&ssblk, sblk);
++ memcpy(sblk, &ssblk, sizeof(struct squashfs_super_block));
++ msblk->swap = 1;
++ } else {
++ SERROR("Can't find a SQUASHFS superblock on %s\n",
++ bdevname(s->s_bdev, b));
++ goto failed_mount;
++ }
++ }
++
++ /* Check the MAJOR & MINOR versions */
++ if(!supported_squashfs_filesystem(msblk, silent))
++ goto failed_mount;
++
++ /* Check the filesystem does not extend beyond the end of the
++ block device */
++ if(sblk->bytes_used < 0 || sblk->bytes_used > i_size_read(s->s_bdev->bd_inode))
++ goto failed_mount;
++
++ /* Check the root inode for sanity */
++ if (SQUASHFS_INODE_OFFSET(sblk->root_inode) > SQUASHFS_METADATA_SIZE)
++ goto failed_mount;
++
++ TRACE("Found valid superblock on %s\n", bdevname(s->s_bdev, b));
++ TRACE("Inodes are %scompressed\n", SQUASHFS_UNCOMPRESSED_INODES(sblk->flags)
++ ? "un" : "");
++ TRACE("Data is %scompressed\n", SQUASHFS_UNCOMPRESSED_DATA(sblk->flags)
++ ? "un" : "");
++ TRACE("Check data is %spresent in the filesystem\n",
++ SQUASHFS_CHECK_DATA(sblk->flags) ? "" : "not ");
++ TRACE("Filesystem size %lld bytes\n", sblk->bytes_used);
++ TRACE("Block size %d\n", sblk->block_size);
++ TRACE("Number of inodes %d\n", sblk->inodes);
++ if (sblk->s_major > 1)
++ TRACE("Number of fragments %d\n", sblk->fragments);
++ TRACE("Number of uids %d\n", sblk->no_uids);
++ TRACE("Number of gids %d\n", sblk->no_guids);
++ TRACE("sblk->inode_table_start %llx\n", sblk->inode_table_start);
++ TRACE("sblk->directory_table_start %llx\n", sblk->directory_table_start);
++ if (sblk->s_major > 1)
++ TRACE("sblk->fragment_table_start %llx\n", sblk->fragment_table_start);
++ TRACE("sblk->uid_start %llx\n", sblk->uid_start);
++
++ s->s_maxbytes = MAX_LFS_FILESIZE;
++ s->s_flags |= MS_RDONLY;
++ s->s_op = &squashfs_super_ops;
++
++ if (readahead_metadata(s) == 0)
++ goto failed_mount;
++
++ /* Allocate read_page block */
++ msblk->read_page = vmalloc(sblk->block_size);
++ if (msblk->read_page == NULL) {
++ ERROR("Failed to allocate read_page block\n");
++ goto failed_mount;
++ }
++
++ /* Allocate uid and gid tables */
++ msblk->uid = kmalloc((sblk->no_uids + sblk->no_guids) *
++ sizeof(unsigned int), GFP_KERNEL);
++ if (msblk->uid == NULL) {
++ ERROR("Failed to allocate uid/gid table\n");
++ goto failed_mount;
++ }
++ msblk->guid = msblk->uid + sblk->no_uids;
++
++ if (msblk->swap) {
++ unsigned int suid[sblk->no_uids + sblk->no_guids];
++
++ if (!squashfs_read_data(s, (char *) &suid, sblk->uid_start,
++ ((sblk->no_uids + sblk->no_guids) *
++ sizeof(unsigned int)) |
++ SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, (sblk->no_uids + sblk->no_guids) * sizeof(unsigned int))) {
++ ERROR("unable to read uid/gid table\n");
++ goto failed_mount;
++ }
++
++ SQUASHFS_SWAP_DATA(msblk->uid, suid, (sblk->no_uids +
++ sblk->no_guids), (sizeof(unsigned int) * 8));
++ } else
++ if (!squashfs_read_data(s, (char *) msblk->uid, sblk->uid_start,
++ ((sblk->no_uids + sblk->no_guids) *
++ sizeof(unsigned int)) |
++ SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, (sblk->no_uids + sblk->no_guids) * sizeof(unsigned int))) {
++ ERROR("unable to read uid/gid table\n");
++ goto failed_mount;
++ }
++
++
++ if (sblk->s_major == 1 && squashfs_1_0_supported(msblk))
++ goto allocate_root;
++
++ msblk->fragment = kzalloc(sizeof(struct squashfs_fragment_cache) *
++ SQUASHFS_CACHED_FRAGMENTS, GFP_KERNEL);
++ if (msblk->fragment == NULL) {
++ ERROR("Failed to allocate fragment block cache\n");
++ goto failed_mount;
++ }
++
++ for (i = 0; i < SQUASHFS_CACHED_FRAGMENTS; i++) {
++ msblk->fragment[i].block = SQUASHFS_INVALID_BLK;
++ }
++
++ msblk->next_fragment = 0;
++ msblk->unused_frag_blks = SQUASHFS_CACHED_FRAGMENTS;
++
++ /* Allocate and read fragment index table */
++ if (msblk->read_fragment_index_table(s) == 0)
++ goto failed_mount;
++
++ if(sblk->s_major < 3 || sblk->lookup_table_start == SQUASHFS_INVALID_BLK)
++ goto allocate_root;
++
++ /* Allocate and read inode lookup table */
++ if (read_inode_lookup_table(s) == 0)
++ goto failed_mount;
++
++ s->s_op = &squashfs_export_super_ops;
++ s->s_export_op = &squashfs_export_ops;
++
++allocate_root:
++ root = new_inode(s);
++ if ((msblk->read_inode)(root, sblk->root_inode) == 0)
++ goto failed_mount;
++ insert_inode_hash(root);
++
++ s->s_root = d_alloc_root(root);
++ if (s->s_root == NULL) {
++ ERROR("Root inode create failed\n");
++ iput(root);
++ goto failed_mount;
++ }
++
++ TRACE("Leaving squashfs_fill_super\n");
++ return 0;
++
++failed_mount:
++ kfree(msblk->inode_lookup_table);
++ kfree(msblk->fragment_index);
++ kfree(msblk->fragment);
++ kfree(msblk->uid);
++ vfree(msblk->read_page);
++ kfree(msblk->block_cache);
++ kfree(msblk->fragment_index_2);
++ vfree(msblk->stream.workspace);
++ kfree(s->s_fs_info);
++ s->s_fs_info = NULL;
++ return -EINVAL;
++
++failure:
++ return -ENOMEM;
++}
++
++
++static int squashfs_statfs(struct dentry *dentry, struct kstatfs *buf)
++{
++ struct squashfs_sb_info *msblk = dentry->d_sb->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++
++ TRACE("Entered squashfs_statfs\n");
++
++ buf->f_type = SQUASHFS_MAGIC;
++ buf->f_bsize = sblk->block_size;
++ buf->f_blocks = ((sblk->bytes_used - 1) >> sblk->block_log) + 1;
++ buf->f_bfree = buf->f_bavail = 0;
++ buf->f_files = sblk->inodes;
++ buf->f_ffree = 0;
++ buf->f_namelen = SQUASHFS_NAME_LEN;
++
++ return 0;
++}
++
++
++static int squashfs_symlink_readpage(struct file *file, struct page *page)
++{
++ struct inode *inode = page->mapping->host;
++ int index = page->index << PAGE_CACHE_SHIFT, length, bytes, avail_bytes;
++ long long block = SQUASHFS_I(inode)->start_block;
++ int offset = SQUASHFS_I(inode)->offset;
++ void *pageaddr = kmap(page);
++
++ TRACE("Entered squashfs_symlink_readpage, page index %ld, start block "
++ "%llx, offset %x\n", page->index,
++ SQUASHFS_I(inode)->start_block,
++ SQUASHFS_I(inode)->offset);
++
++ for (length = 0; length < index; length += bytes) {
++ bytes = squashfs_get_cached_block(inode->i_sb, NULL, block,
++ offset, PAGE_CACHE_SIZE, &block, &offset);
++ if (bytes == 0) {
++ ERROR("Unable to read symbolic link [%llx:%x]\n", block, offset);
++ goto skip_read;
++ }
++ }
++
++ if (length != index) {
++ ERROR("(squashfs_symlink_readpage) length != index\n");
++ bytes = 0;
++ goto skip_read;
++ }
++
++ avail_bytes = min_t(int, i_size_read(inode) - length, PAGE_CACHE_SIZE);
++
++ bytes = squashfs_get_cached_block(inode->i_sb, pageaddr, block, offset,
++ avail_bytes, &block, &offset);
++ if (bytes == 0)
++ ERROR("Unable to read symbolic link [%llx:%x]\n", block, offset);
++
++skip_read:
++ memset(pageaddr + bytes, 0, PAGE_CACHE_SIZE - bytes);
++ kunmap(page);
++ flush_dcache_page(page);
++ SetPageUptodate(page);
++ unlock_page(page);
++
++ return 0;
++}
++
++
++struct meta_index *locate_meta_index(struct inode *inode, int index, int offset)
++{
++ struct meta_index *meta = NULL;
++ struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
++ int i;
++
++ mutex_lock(&msblk->meta_index_mutex);
++
++ TRACE("locate_meta_index: index %d, offset %d\n", index, offset);
++
++ if (msblk->meta_index == NULL)
++ goto not_allocated;
++
++ for (i = 0; i < SQUASHFS_META_NUMBER; i ++) {
++ if (msblk->meta_index[i].inode_number == inode->i_ino &&
++ msblk->meta_index[i].offset >= offset &&
++ msblk->meta_index[i].offset <= index &&
++ msblk->meta_index[i].locked == 0) {
++ TRACE("locate_meta_index: entry %d, offset %d\n", i,
++ msblk->meta_index[i].offset);
++ meta = &msblk->meta_index[i];
++ offset = meta->offset;
++ }
++ }
++
++ if (meta)
++ meta->locked = 1;
++
++not_allocated:
++ mutex_unlock(&msblk->meta_index_mutex);
++
++ return meta;
++}
++
++
++struct meta_index *empty_meta_index(struct inode *inode, int offset, int skip)
++{
++ struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
++ struct meta_index *meta = NULL;
++ int i;
++
++ mutex_lock(&msblk->meta_index_mutex);
++
++ TRACE("empty_meta_index: offset %d, skip %d\n", offset, skip);
++
++ if (msblk->meta_index == NULL) {
++ msblk->meta_index = kmalloc(sizeof(struct meta_index) *
++ SQUASHFS_META_NUMBER, GFP_KERNEL);
++ if (msblk->meta_index == NULL) {
++ ERROR("Failed to allocate meta_index\n");
++ goto failed;
++ }
++ for (i = 0; i < SQUASHFS_META_NUMBER; i++) {
++ msblk->meta_index[i].inode_number = 0;
++ msblk->meta_index[i].locked = 0;
++ }
++ msblk->next_meta_index = 0;
++ }
++
++ for (i = SQUASHFS_META_NUMBER; i &&
++ msblk->meta_index[msblk->next_meta_index].locked; i --)
++ msblk->next_meta_index = (msblk->next_meta_index + 1) %
++ SQUASHFS_META_NUMBER;
++
++ if (i == 0) {
++ TRACE("empty_meta_index: failed!\n");
++ goto failed;
++ }
++
++ TRACE("empty_meta_index: returned meta entry %d, %p\n",
++ msblk->next_meta_index,
++ &msblk->meta_index[msblk->next_meta_index]);
++
++ meta = &msblk->meta_index[msblk->next_meta_index];
++ msblk->next_meta_index = (msblk->next_meta_index + 1) %
++ SQUASHFS_META_NUMBER;
++
++ meta->inode_number = inode->i_ino;
++ meta->offset = offset;
++ meta->skip = skip;
++ meta->entries = 0;
++ meta->locked = 1;
++
++failed:
++ mutex_unlock(&msblk->meta_index_mutex);
++ return meta;
++}
++
++
++void release_meta_index(struct inode *inode, struct meta_index *meta)
++{
++ meta->locked = 0;
++ smp_mb();
++}
++
++
++static int read_block_index(struct super_block *s, int blocks, char *block_list,
++ long long *start_block, int *offset)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ unsigned int *block_listp;
++ int block = 0;
++
++ if (msblk->swap) {
++ char sblock_list[blocks << 2];
++
++ if (!squashfs_get_cached_block(s, sblock_list, *start_block,
++ *offset, blocks << 2, start_block, offset)) {
++ ERROR("Fail reading block list [%llx:%x]\n", *start_block, *offset);
++ goto failure;
++ }
++ SQUASHFS_SWAP_INTS(((unsigned int *)block_list),
++ ((unsigned int *)sblock_list), blocks);
++ } else {
++ if (!squashfs_get_cached_block(s, block_list, *start_block,
++ *offset, blocks << 2, start_block, offset)) {
++ ERROR("Fail reading block list [%llx:%x]\n", *start_block, *offset);
++ goto failure;
++ }
++ }
++
++ for (block_listp = (unsigned int *) block_list; blocks;
++ block_listp++, blocks --)
++ block += SQUASHFS_COMPRESSED_SIZE_BLOCK(*block_listp);
++
++ return block;
++
++failure:
++ return -1;
++}
++
++
++#define SIZE 256
++
++static inline int calculate_skip(int blocks) {
++ int skip = (blocks - 1) / ((SQUASHFS_SLOTS * SQUASHFS_META_ENTRIES + 1) * SQUASHFS_META_INDEXES);
++ return skip >= 7 ? 7 : skip + 1;
++}
++
++
++static int get_meta_index(struct inode *inode, int index,
++ long long *index_block, int *index_offset,
++ long long *data_block, char *block_list)
++{
++ struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ int skip = calculate_skip(i_size_read(inode) >> sblk->block_log);
++ int offset = 0;
++ struct meta_index *meta;
++ struct meta_entry *meta_entry;
++ long long cur_index_block = SQUASHFS_I(inode)->u.s1.block_list_start;
++ int cur_offset = SQUASHFS_I(inode)->offset;
++ long long cur_data_block = SQUASHFS_I(inode)->start_block;
++ int i;
++
++ index /= SQUASHFS_META_INDEXES * skip;
++
++ while (offset < index) {
++ meta = locate_meta_index(inode, index, offset + 1);
++
++ if (meta == NULL) {
++ meta = empty_meta_index(inode, offset + 1, skip);
++ if (meta == NULL)
++ goto all_done;
++ } else {
++ if(meta->entries == 0)
++ goto failed;
++ /* XXX */
++ offset = index < meta->offset + meta->entries ? index :
++ meta->offset + meta->entries - 1;
++ /* XXX */
++ meta_entry = &meta->meta_entry[offset - meta->offset];
++ cur_index_block = meta_entry->index_block + sblk->inode_table_start;
++ cur_offset = meta_entry->offset;
++ cur_data_block = meta_entry->data_block;
++ TRACE("get_meta_index: offset %d, meta->offset %d, "
++ "meta->entries %d\n", offset, meta->offset, meta->entries);
++ TRACE("get_meta_index: index_block 0x%llx, offset 0x%x"
++ " data_block 0x%llx\n", cur_index_block,
++ cur_offset, cur_data_block);
++ }
++
++ for (i = meta->offset + meta->entries; i <= index &&
++ i < meta->offset + SQUASHFS_META_ENTRIES; i++) {
++ int blocks = skip * SQUASHFS_META_INDEXES;
++
++ while (blocks) {
++ int block = blocks > (SIZE >> 2) ? (SIZE >> 2) : blocks;
++ int res = read_block_index(inode->i_sb, block, block_list,
++ &cur_index_block, &cur_offset);
++
++ if (res == -1)
++ goto failed;
++
++ cur_data_block += res;
++ blocks -= block;
++ }
++
++ meta_entry = &meta->meta_entry[i - meta->offset];
++ meta_entry->index_block = cur_index_block - sblk->inode_table_start;
++ meta_entry->offset = cur_offset;
++ meta_entry->data_block = cur_data_block;
++ meta->entries ++;
++ offset ++;
++ }
++
++ TRACE("get_meta_index: meta->offset %d, meta->entries %d\n",
++ meta->offset, meta->entries);
++
++ release_meta_index(inode, meta);
++ }
++
++all_done:
++ *index_block = cur_index_block;
++ *index_offset = cur_offset;
++ *data_block = cur_data_block;
++
++ return offset * SQUASHFS_META_INDEXES * skip;
++
++failed:
++ release_meta_index(inode, meta);
++ return -1;
++}
++
++
++static long long read_blocklist(struct inode *inode, int index,
++ int readahead_blks, char *block_list,
++ unsigned short **block_p, unsigned int *bsize)
++{
++ long long block_ptr;
++ int offset;
++ long long block;
++ int res = get_meta_index(inode, index, &block_ptr, &offset, &block,
++ block_list);
++
++ TRACE("read_blocklist: res %d, index %d, block_ptr 0x%llx, offset"
++ " 0x%x, block 0x%llx\n", res, index, block_ptr, offset, block);
++
++ if(res == -1)
++ goto failure;
++
++ index -= res;
++
++ while (index) {
++ int blocks = index > (SIZE >> 2) ? (SIZE >> 2) : index;
++ int res = read_block_index(inode->i_sb, blocks, block_list,
++ &block_ptr, &offset);
++ if (res == -1)
++ goto failure;
++ block += res;
++ index -= blocks;
++ }
++
++ if (read_block_index(inode->i_sb, 1, block_list, &block_ptr, &offset) == -1)
++ goto failure;
++ *bsize = *((unsigned int *) block_list);
++
++ return block;
++
++failure:
++ return 0;
++}
++
++
++static int squashfs_readpage(struct file *file, struct page *page)
++{
++ struct inode *inode = page->mapping->host;
++ struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ unsigned char *block_list = NULL;
++ long long block;
++ unsigned int bsize, i;
++ int bytes;
++ int index = page->index >> (sblk->block_log - PAGE_CACHE_SHIFT);
++ void *pageaddr;
++ struct squashfs_fragment_cache *fragment = NULL;
++ char *data_ptr = msblk->read_page;
++
++ int mask = (1 << (sblk->block_log - PAGE_CACHE_SHIFT)) - 1;
++ int start_index = page->index & ~mask;
++ int end_index = start_index | mask;
++ int file_end = i_size_read(inode) >> sblk->block_log;
++ int sparse = 0;
++
++ TRACE("Entered squashfs_readpage, page index %lx, start block %llx\n",
++ page->index, SQUASHFS_I(inode)->start_block);
++
++ if (page->index >= ((i_size_read(inode) + PAGE_CACHE_SIZE - 1) >>
++ PAGE_CACHE_SHIFT))
++ goto out;
++
++ if (SQUASHFS_I(inode)->u.s1.fragment_start_block == SQUASHFS_INVALID_BLK
++ || index < file_end) {
++ block_list = kmalloc(SIZE, GFP_KERNEL);
++ if (block_list == NULL) {
++ ERROR("Failed to allocate block_list\n");
++ goto error_out;
++ }
++
++ block = (msblk->read_blocklist)(inode, index, 1, block_list, NULL, &bsize);
++ if (block == 0)
++ goto error_out;
++
++ if (bsize == 0) { /* hole */
++ bytes = index == file_end ?
++ (i_size_read(inode) & (sblk->block_size - 1)) : sblk->block_size;
++ sparse = 1;
++ } else {
++ mutex_lock(&msblk->read_page_mutex);
++
++ bytes = squashfs_read_data(inode->i_sb, msblk->read_page, block,
++ bsize, NULL, sblk->block_size);
++
++ if (bytes == 0) {
++ ERROR("Unable to read page, block %llx, size %x\n", block, bsize);
++ mutex_unlock(&msblk->read_page_mutex);
++ goto error_out;
++ }
++ }
++ } else {
++ fragment = get_cached_fragment(inode->i_sb,
++ SQUASHFS_I(inode)-> u.s1.fragment_start_block,
++ SQUASHFS_I(inode)->u.s1.fragment_size);
++
++ if (fragment == NULL) {
++ ERROR("Unable to read page, block %llx, size %x\n",
++ SQUASHFS_I(inode)->u.s1.fragment_start_block,
++ (int) SQUASHFS_I(inode)->u.s1.fragment_size);
++ goto error_out;
++ }
++ bytes = i_size_read(inode) & (sblk->block_size - 1);
++ data_ptr = fragment->data + SQUASHFS_I(inode)->u.s1.fragment_offset;
++ }
++
++ for (i = start_index; i <= end_index && bytes > 0; i++,
++ bytes -= PAGE_CACHE_SIZE, data_ptr += PAGE_CACHE_SIZE) {
++ struct page *push_page;
++ int avail = sparse ? 0 : min_t(unsigned int, bytes, PAGE_CACHE_SIZE);
++
++ TRACE("bytes %d, i %d, available_bytes %d\n", bytes, i, avail);
++
++ push_page = (i == page->index) ? page :
++ grab_cache_page_nowait(page->mapping, i);
++
++ if (!push_page)
++ continue;
++
++ if (PageUptodate(push_page))
++ goto skip_page;
++
++ pageaddr = kmap_atomic(push_page, KM_USER0);
++ memcpy(pageaddr, data_ptr, avail);
++ memset(pageaddr + avail, 0, PAGE_CACHE_SIZE - avail);
++ kunmap_atomic(pageaddr, KM_USER0);
++ flush_dcache_page(push_page);
++ SetPageUptodate(push_page);
++skip_page:
++ unlock_page(push_page);
++ if(i != page->index)
++ page_cache_release(push_page);
++ }
++
++ if (SQUASHFS_I(inode)->u.s1.fragment_start_block == SQUASHFS_INVALID_BLK
++ || index < file_end) {
++ if (!sparse)
++ mutex_unlock(&msblk->read_page_mutex);
++ kfree(block_list);
++ } else
++ release_cached_fragment(msblk, fragment);
++
++ return 0;
++
++error_out:
++ SetPageError(page);
++out:
++ pageaddr = kmap_atomic(page, KM_USER0);
++ memset(pageaddr, 0, PAGE_CACHE_SIZE);
++ kunmap_atomic(pageaddr, KM_USER0);
++ flush_dcache_page(page);
++ if (!PageError(page))
++ SetPageUptodate(page);
++ unlock_page(page);
++
++ kfree(block_list);
++ return 0;
++}
++
++
++static int get_dir_index_using_offset(struct super_block *s,
++ long long *next_block, unsigned int *next_offset,
++ long long index_start, unsigned int index_offset, int i_count,
++ long long f_pos)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ int i, length = 0;
++ struct squashfs_dir_index index;
++
++ TRACE("Entered get_dir_index_using_offset, i_count %d, f_pos %d\n",
++ i_count, (unsigned int) f_pos);
++
++ f_pos =- 3;
++ if (f_pos == 0)
++ goto finish;
++
++ for (i = 0; i < i_count; i++) {
++ if (msblk->swap) {
++ struct squashfs_dir_index sindex;
++ squashfs_get_cached_block(s, &sindex, index_start, index_offset,
++ sizeof(sindex), &index_start, &index_offset);
++ SQUASHFS_SWAP_DIR_INDEX(&index, &sindex);
++ } else
++ squashfs_get_cached_block(s, &index, index_start, index_offset,
++ sizeof(index), &index_start, &index_offset);
++
++ if (index.index > f_pos)
++ break;
++
++ squashfs_get_cached_block(s, NULL, index_start, index_offset,
++ index.size + 1, &index_start, &index_offset);
++
++ length = index.index;
++ *next_block = index.start_block + sblk->directory_table_start;
++ }
++
++ *next_offset = (length + *next_offset) % SQUASHFS_METADATA_SIZE;
++
++finish:
++ return length + 3;
++}
++
++
++static int get_dir_index_using_name(struct super_block *s,
++ long long *next_block, unsigned int *next_offset,
++ long long index_start, unsigned int index_offset, int i_count,
++ const char *name, int size)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ int i, length = 0;
++ struct squashfs_dir_index *index;
++ char *str;
++
++ TRACE("Entered get_dir_index_using_name, i_count %d\n", i_count);
++
++ str = kmalloc(sizeof(struct squashfs_dir_index) +
++ (SQUASHFS_NAME_LEN + 1) * 2, GFP_KERNEL);
++ if (str == NULL) {
++ ERROR("Failed to allocate squashfs_dir_index\n");
++ goto failure;
++ }
++
++ index = (struct squashfs_dir_index *) (str + SQUASHFS_NAME_LEN + 1);
++ strncpy(str, name, size);
++ str[size] = '\0';
++
++ for (i = 0; i < i_count; i++) {
++ if (msblk->swap) {
++ struct squashfs_dir_index sindex;
++ squashfs_get_cached_block(s, &sindex, index_start, index_offset,
++ sizeof(sindex), &index_start, &index_offset);
++ SQUASHFS_SWAP_DIR_INDEX(index, &sindex);
++ } else
++ squashfs_get_cached_block(s, index, index_start, index_offset,
++ sizeof(struct squashfs_dir_index), &index_start, &index_offset);
++
++ squashfs_get_cached_block(s, index->name, index_start, index_offset,
++ index->size + 1, &index_start, &index_offset);
++
++ index->name[index->size + 1] = '\0';
++
++ if (strcmp(index->name, str) > 0)
++ break;
++
++ length = index->index;
++ *next_block = index->start_block + sblk->directory_table_start;
++ }
++
++ *next_offset = (length + *next_offset) % SQUASHFS_METADATA_SIZE;
++ kfree(str);
++
++failure:
++ return length + 3;
++}
++
++
++static int squashfs_readdir(struct file *file, void *dirent, filldir_t filldir)
++{
++ struct inode *i = file->f_dentry->d_inode;
++ struct squashfs_sb_info *msblk = i->i_sb->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ long long next_block = SQUASHFS_I(i)->start_block +
++ sblk->directory_table_start;
++ int next_offset = SQUASHFS_I(i)->offset, length = 0, dir_count;
++ struct squashfs_dir_header dirh;
++ struct squashfs_dir_entry *dire;
++
++ TRACE("Entered squashfs_readdir [%llx:%x]\n", next_block, next_offset);
++
++ dire = kmalloc(sizeof(struct squashfs_dir_entry) +
++ SQUASHFS_NAME_LEN + 1, GFP_KERNEL);
++ if (dire == NULL) {
++ ERROR("Failed to allocate squashfs_dir_entry\n");
++ goto finish;
++ }
++
++ while(file->f_pos < 3) {
++ char *name;
++ int size, i_ino;
++
++ if(file->f_pos == 0) {
++ name = ".";
++ size = 1;
++ i_ino = i->i_ino;
++ } else {
++ name = "..";
++ size = 2;
++ i_ino = SQUASHFS_I(i)->u.s2.parent_inode;
++ }
++ TRACE("Calling filldir(%x, %s, %d, %d, %d, %d)\n",
++ (unsigned int) dirent, name, size, (int)
++ file->f_pos, i_ino, squashfs_filetype_table[1]);
++
++ if (filldir(dirent, name, size, file->f_pos, i_ino,
++ squashfs_filetype_table[1]) < 0) {
++ TRACE("Filldir returned less than 0\n");
++ goto finish;
++ }
++ file->f_pos += size;
++ }
++
++ length = get_dir_index_using_offset(i->i_sb, &next_block, &next_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_start,
++ SQUASHFS_I(i)->u.s2.directory_index_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_count, file->f_pos);
++
++ while (length < i_size_read(i)) {
++ /* read directory header */
++ if (msblk->swap) {
++ struct squashfs_dir_header sdirh;
++
++ if (!squashfs_get_cached_block(i->i_sb, &sdirh, next_block,
++ next_offset, sizeof(sdirh), &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdirh);
++ SQUASHFS_SWAP_DIR_HEADER(&dirh, &sdirh);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, &dirh, next_block,
++ next_offset, sizeof(dirh), &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(dirh);
++ }
++
++ dir_count = dirh.count + 1;
++ while (dir_count--) {
++ if (msblk->swap) {
++ struct squashfs_dir_entry sdire;
++ if (!squashfs_get_cached_block(i->i_sb, &sdire, next_block,
++ next_offset, sizeof(sdire), &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdire);
++ SQUASHFS_SWAP_DIR_ENTRY(dire, &sdire);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, dire, next_block,
++ next_offset, sizeof(*dire), &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(*dire);
++ }
++
++ if (!squashfs_get_cached_block(i->i_sb, dire->name, next_block,
++ next_offset, dire->size + 1, &next_block, &next_offset))
++ goto failed_read;
++
++ length += dire->size + 1;
++
++ if (file->f_pos >= length)
++ continue;
++
++ dire->name[dire->size + 1] = '\0';
++
++ TRACE("Calling filldir(%x, %s, %d, %d, %x:%x, %d, %d)\n",
++ (unsigned int) dirent, dire->name, dire->size + 1,
++ (int) file->f_pos, dirh.start_block, dire->offset,
++ dirh.inode_number + dire->inode_number,
++ squashfs_filetype_table[dire->type]);
++
++ if (filldir(dirent, dire->name, dire->size + 1, file->f_pos,
++ dirh.inode_number + dire->inode_number,
++ squashfs_filetype_table[dire->type]) < 0) {
++ TRACE("Filldir returned less than 0\n");
++ goto finish;
++ }
++ file->f_pos = length;
++ }
++ }
++
++finish:
++ kfree(dire);
++ return 0;
++
++failed_read:
++ ERROR("Unable to read directory block [%llx:%x]\n", next_block,
++ next_offset);
++ kfree(dire);
++ return 0;
++}
++
++
++static struct dentry *squashfs_lookup(struct inode *i, struct dentry *dentry,
++ struct nameidata *nd)
++{
++ const unsigned char *name = dentry->d_name.name;
++ int len = dentry->d_name.len;
++ struct inode *inode = NULL;
++ struct squashfs_sb_info *msblk = i->i_sb->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ long long next_block = SQUASHFS_I(i)->start_block +
++ sblk->directory_table_start;
++ int next_offset = SQUASHFS_I(i)->offset, length = 0, dir_count;
++ struct squashfs_dir_header dirh;
++ struct squashfs_dir_entry *dire;
++
++ TRACE("Entered squashfs_lookup [%llx:%x]\n", next_block, next_offset);
++
++ dire = kmalloc(sizeof(struct squashfs_dir_entry) +
++ SQUASHFS_NAME_LEN + 1, GFP_KERNEL);
++ if (dire == NULL) {
++ ERROR("Failed to allocate squashfs_dir_entry\n");
++ goto exit_lookup;
++ }
++
++ if (len > SQUASHFS_NAME_LEN)
++ goto exit_lookup;
++
++ length = get_dir_index_using_name(i->i_sb, &next_block, &next_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_start,
++ SQUASHFS_I(i)->u.s2.directory_index_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_count, name, len);
++
++ while (length < i_size_read(i)) {
++ /* read directory header */
++ if (msblk->swap) {
++ struct squashfs_dir_header sdirh;
++ if (!squashfs_get_cached_block(i->i_sb, &sdirh, next_block,
++ next_offset, sizeof(sdirh), &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdirh);
++ SQUASHFS_SWAP_DIR_HEADER(&dirh, &sdirh);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, &dirh, next_block,
++ next_offset, sizeof(dirh), &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(dirh);
++ }
++
++ dir_count = dirh.count + 1;
++ while (dir_count--) {
++ if (msblk->swap) {
++ struct squashfs_dir_entry sdire;
++ if (!squashfs_get_cached_block(i->i_sb, &sdire, next_block,
++ next_offset, sizeof(sdire), &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdire);
++ SQUASHFS_SWAP_DIR_ENTRY(dire, &sdire);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, dire, next_block,
++ next_offset, sizeof(*dire), &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(*dire);
++ }
++
++ if (!squashfs_get_cached_block(i->i_sb, dire->name, next_block,
++ next_offset, dire->size + 1, &next_block, &next_offset))
++ goto failed_read;
++
++ length += dire->size + 1;
++
++ if (name[0] < dire->name[0])
++ goto exit_lookup;
++
++ if ((len == dire->size + 1) && !strncmp(name, dire->name, len)) {
++ squashfs_inode_t ino = SQUASHFS_MKINODE(dirh.start_block,
++ dire->offset);
++
++ TRACE("calling squashfs_iget for directory entry %s, inode"
++ " %x:%x, %d\n", name, dirh.start_block, dire->offset,
++ dirh.inode_number + dire->inode_number);
++
++ inode = squashfs_iget(i->i_sb, ino, dirh.inode_number + dire->inode_number);
++
++ goto exit_lookup;
++ }
++ }
++ }
++
++exit_lookup:
++ kfree(dire);
++ if (inode)
++ return d_splice_alias(inode, dentry);
++ d_add(dentry, inode);
++ return ERR_PTR(0);
++
++failed_read:
++ ERROR("Unable to read directory block [%llx:%x]\n", next_block,
++ next_offset);
++ goto exit_lookup;
++}
++
++
++static int squashfs_remount(struct super_block *s, int *flags, char *data)
++{
++ *flags |= MS_RDONLY;
++ return 0;
++}
++
++
++static void squashfs_put_super(struct super_block *s)
++{
++ int i;
++
++ if (s->s_fs_info) {
++ struct squashfs_sb_info *sbi = s->s_fs_info;
++ if (sbi->block_cache)
++ for (i = 0; i < squashfs_cached_blks; i++)
++ if (sbi->block_cache[i].block != SQUASHFS_INVALID_BLK)
++ vfree(sbi->block_cache[i].data);
++ if (sbi->fragment)
++ for (i = 0; i < SQUASHFS_CACHED_FRAGMENTS; i++)
++ vfree(sbi->fragment[i].data);
++ kfree(sbi->fragment);
++ kfree(sbi->block_cache);
++ vfree(sbi->read_page);
++ kfree(sbi->uid);
++ kfree(sbi->fragment_index);
++ kfree(sbi->fragment_index_2);
++ kfree(sbi->meta_index);
++ vfree(sbi->stream.workspace);
++ kfree(s->s_fs_info);
++ s->s_fs_info = NULL;
++ }
++}
++
++
++static int squashfs_get_sb(struct file_system_type *fs_type, int flags,
++ const char *dev_name, void *data, struct vfsmount *mnt)
++{
++ return get_sb_bdev(fs_type, flags, dev_name, data, squashfs_fill_super,
++ mnt);
++}
++
++
++static int __init init_squashfs_fs(void)
++{
++ int err = init_inodecache();
++ if (err)
++ goto out;
++
++ printk(KERN_INFO "squashfs: version 3.3 (2007/10/31) "
++ "Phillip Lougher\n");
++
++ err = register_filesystem(&squashfs_fs_type);
++ if (err)
++ destroy_inodecache();
++
++out:
++ return err;
++}
++
++
++static void __exit exit_squashfs_fs(void)
++{
++ unregister_filesystem(&squashfs_fs_type);
++ destroy_inodecache();
++}
++
++
++static struct kmem_cache * squashfs_inode_cachep;
++
++
++static struct inode *squashfs_alloc_inode(struct super_block *sb)
++{
++ struct squashfs_inode_info *ei;
++ ei = kmem_cache_alloc(squashfs_inode_cachep, GFP_KERNEL);
++ return ei ? &ei->vfs_inode : NULL;
++}
++
++
++static void squashfs_destroy_inode(struct inode *inode)
++{
++ kmem_cache_free(squashfs_inode_cachep, SQUASHFS_I(inode));
++}
++
++
++static void init_once(struct kmem_cache *cachep, void *foo)
++{
++ struct squashfs_inode_info *ei = foo;
++
++ inode_init_once(&ei->vfs_inode);
++}
++
++
++static int __init init_inodecache(void)
++{
++ squashfs_inode_cachep = kmem_cache_create("squashfs_inode_cache",
++ sizeof(struct squashfs_inode_info), 0,
++ SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT, init_once);
++ if (squashfs_inode_cachep == NULL)
++ return -ENOMEM;
++ return 0;
++}
++
++
++static void destroy_inodecache(void)
++{
++ kmem_cache_destroy(squashfs_inode_cachep);
++}
++
++
++module_init(init_squashfs_fs);
++module_exit(exit_squashfs_fs);
++MODULE_DESCRIPTION("squashfs 3.2-r2-CVS, a compressed read-only filesystem");
++MODULE_AUTHOR("Phillip Lougher <phillip@lougher.demon.co.uk>");
++MODULE_LICENSE("GPL");
+diff -x .gitignore -Nurp linux-2.6.24/fs/squashfs/Makefile linux-2.6.24-squashfs3.3/fs/squashfs/Makefile
+--- linux-2.6.24/fs/squashfs/Makefile 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.24-squashfs3.3/fs/squashfs/Makefile 2005-11-20 14:31:00.000000000 +0000
+@@ -0,0 +1,7 @@
++#
++# Makefile for the linux squashfs routines.
++#
++
++obj-$(CONFIG_SQUASHFS) += squashfs.o
++squashfs-y += inode.o
++squashfs-y += squashfs2_0.o
+diff -x .gitignore -Nurp linux-2.6.24/fs/squashfs/squashfs2_0.c linux-2.6.24-squashfs3.3/fs/squashfs/squashfs2_0.c
+--- linux-2.6.24/fs/squashfs/squashfs2_0.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.24-squashfs3.3/fs/squashfs/squashfs2_0.c 2007-10-25 00:43:59.000000000 +0100
+@@ -0,0 +1,740 @@
++/*
++ * Squashfs - a compressed read only filesystem for Linux
++ *
++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007
++ * Phillip Lougher <phillip@lougher.demon.co.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version 2,
++ * or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++ *
++ * squashfs2_0.c
++ */
++
++#include <linux/squashfs_fs.h>
++#include <linux/module.h>
++#include <linux/zlib.h>
++#include <linux/fs.h>
++#include <linux/squashfs_fs_sb.h>
++#include <linux/squashfs_fs_i.h>
++
++#include "squashfs.h"
++static int squashfs_readdir_2(struct file *file, void *dirent, filldir_t filldir);
++static struct dentry *squashfs_lookup_2(struct inode *, struct dentry *,
++ struct nameidata *);
++
++static struct file_operations squashfs_dir_ops_2 = {
++ .read = generic_read_dir,
++ .readdir = squashfs_readdir_2
++};
++
++static struct inode_operations squashfs_dir_inode_ops_2 = {
++ .lookup = squashfs_lookup_2
++};
++
++static unsigned char squashfs_filetype_table[] = {
++ DT_UNKNOWN, DT_DIR, DT_REG, DT_LNK, DT_BLK, DT_CHR, DT_FIFO, DT_SOCK
++};
++
++static int read_fragment_index_table_2(struct super_block *s)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++
++ if (!(msblk->fragment_index_2 = kmalloc(SQUASHFS_FRAGMENT_INDEX_BYTES_2
++ (sblk->fragments), GFP_KERNEL))) {
++ ERROR("Failed to allocate uid/gid table\n");
++ return 0;
++ }
++
++ if (SQUASHFS_FRAGMENT_INDEX_BYTES_2(sblk->fragments) &&
++ !squashfs_read_data(s, (char *)
++ msblk->fragment_index_2,
++ sblk->fragment_table_start,
++ SQUASHFS_FRAGMENT_INDEX_BYTES_2
++ (sblk->fragments) |
++ SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, SQUASHFS_FRAGMENT_INDEX_BYTES_2(sblk->fragments))) {
++ ERROR("unable to read fragment index table\n");
++ return 0;
++ }
++
++ if (msblk->swap) {
++ int i;
++ unsigned int fragment;
++
++ for (i = 0; i < SQUASHFS_FRAGMENT_INDEXES_2(sblk->fragments);
++ i++) {
++ SQUASHFS_SWAP_FRAGMENT_INDEXES_2((&fragment),
++ &msblk->fragment_index_2[i], 1);
++ msblk->fragment_index_2[i] = fragment;
++ }
++ }
++
++ return 1;
++}
++
++
++static int get_fragment_location_2(struct super_block *s, unsigned int fragment,
++ long long *fragment_start_block,
++ unsigned int *fragment_size)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ long long start_block =
++ msblk->fragment_index_2[SQUASHFS_FRAGMENT_INDEX_2(fragment)];
++ int offset = SQUASHFS_FRAGMENT_INDEX_OFFSET_2(fragment);
++ struct squashfs_fragment_entry_2 fragment_entry;
++
++ if (msblk->swap) {
++ struct squashfs_fragment_entry_2 sfragment_entry;
++
++ if (!squashfs_get_cached_block(s, (char *) &sfragment_entry,
++ start_block, offset,
++ sizeof(sfragment_entry), &start_block,
++ &offset))
++ goto out;
++ SQUASHFS_SWAP_FRAGMENT_ENTRY_2(&fragment_entry, &sfragment_entry);
++ } else
++ if (!squashfs_get_cached_block(s, (char *) &fragment_entry,
++ start_block, offset,
++ sizeof(fragment_entry), &start_block,
++ &offset))
++ goto out;
++
++ *fragment_start_block = fragment_entry.start_block;
++ *fragment_size = fragment_entry.size;
++
++ return 1;
++
++out:
++ return 0;
++}
++
++
++static void squashfs_new_inode(struct squashfs_sb_info *msblk, struct inode *i,
++ struct squashfs_base_inode_header_2 *inodeb, unsigned int ino)
++{
++ struct squashfs_super_block *sblk = &msblk->sblk;
++
++ i->i_ino = ino;
++ i->i_mtime.tv_sec = sblk->mkfs_time;
++ i->i_atime.tv_sec = sblk->mkfs_time;
++ i->i_ctime.tv_sec = sblk->mkfs_time;
++ i->i_uid = msblk->uid[inodeb->uid];
++ i->i_mode = inodeb->mode;
++ i->i_nlink = 1;
++ i->i_size = 0;
++ if (inodeb->guid == SQUASHFS_GUIDS)
++ i->i_gid = i->i_uid;
++ else
++ i->i_gid = msblk->guid[inodeb->guid];
++}
++
++
++static int squashfs_read_inode_2(struct inode *i, squashfs_inode_t inode)
++{
++ struct super_block *s = i->i_sb;
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ unsigned int block = SQUASHFS_INODE_BLK(inode) +
++ sblk->inode_table_start;
++ unsigned int offset = SQUASHFS_INODE_OFFSET(inode);
++ unsigned int ino = SQUASHFS_MK_VFS_INODE(block -
++ sblk->inode_table_start, offset);
++ long long next_block;
++ unsigned int next_offset;
++ union squashfs_inode_header_2 id, sid;
++ struct squashfs_base_inode_header_2 *inodeb = &id.base,
++ *sinodeb = &sid.base;
++
++ TRACE("Entered squashfs_read_inode_2\n");
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *) sinodeb, block,
++ offset, sizeof(*sinodeb), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_BASE_INODE_HEADER_2(inodeb, sinodeb,
++ sizeof(*sinodeb));
++ } else
++ if (!squashfs_get_cached_block(s, (char *) inodeb, block,
++ offset, sizeof(*inodeb), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ squashfs_new_inode(msblk, i, inodeb, ino);
++
++ switch(inodeb->inode_type) {
++ case SQUASHFS_FILE_TYPE: {
++ struct squashfs_reg_inode_header_2 *inodep = &id.reg;
++ struct squashfs_reg_inode_header_2 *sinodep = &sid.reg;
++ long long frag_blk;
++ unsigned int frag_size = 0;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_REG_INODE_HEADER_2(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ frag_blk = SQUASHFS_INVALID_BLK;
++ if (inodep->fragment != SQUASHFS_INVALID_FRAG &&
++ !get_fragment_location_2(s,
++ inodep->fragment, &frag_blk, &frag_size))
++ goto failed_read;
++
++ i->i_size = inodep->file_size;
++ i->i_fop = &generic_ro_fops;
++ i->i_mode |= S_IFREG;
++ i->i_mtime.tv_sec = inodep->mtime;
++ i->i_atime.tv_sec = inodep->mtime;
++ i->i_ctime.tv_sec = inodep->mtime;
++ i->i_blocks = ((i->i_size - 1) >> 9) + 1;
++ SQUASHFS_I(i)->u.s1.fragment_start_block = frag_blk;
++ SQUASHFS_I(i)->u.s1.fragment_size = frag_size;
++ SQUASHFS_I(i)->u.s1.fragment_offset = inodep->offset;
++ SQUASHFS_I(i)->start_block = inodep->start_block;
++ SQUASHFS_I(i)->u.s1.block_list_start = next_block;
++ SQUASHFS_I(i)->offset = next_offset;
++ i->i_data.a_ops = &squashfs_aops;
++
++ TRACE("File inode %x:%x, start_block %x, "
++ "block_list_start %llx, offset %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ inodep->start_block, next_block,
++ next_offset);
++ break;
++ }
++ case SQUASHFS_DIR_TYPE: {
++ struct squashfs_dir_inode_header_2 *inodep = &id.dir;
++ struct squashfs_dir_inode_header_2 *sinodep = &sid.dir;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_DIR_INODE_HEADER_2(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ i->i_size = inodep->file_size;
++ i->i_op = &squashfs_dir_inode_ops_2;
++ i->i_fop = &squashfs_dir_ops_2;
++ i->i_mode |= S_IFDIR;
++ i->i_mtime.tv_sec = inodep->mtime;
++ i->i_atime.tv_sec = inodep->mtime;
++ i->i_ctime.tv_sec = inodep->mtime;
++ SQUASHFS_I(i)->start_block = inodep->start_block;
++ SQUASHFS_I(i)->offset = inodep->offset;
++ SQUASHFS_I(i)->u.s2.directory_index_count = 0;
++ SQUASHFS_I(i)->u.s2.parent_inode = 0;
++
++ TRACE("Directory inode %x:%x, start_block %x, offset "
++ "%x\n", SQUASHFS_INODE_BLK(inode),
++ offset, inodep->start_block,
++ inodep->offset);
++ break;
++ }
++ case SQUASHFS_LDIR_TYPE: {
++ struct squashfs_ldir_inode_header_2 *inodep = &id.ldir;
++ struct squashfs_ldir_inode_header_2 *sinodep = &sid.ldir;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_LDIR_INODE_HEADER_2(inodep,
++ sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ i->i_size = inodep->file_size;
++ i->i_op = &squashfs_dir_inode_ops_2;
++ i->i_fop = &squashfs_dir_ops_2;
++ i->i_mode |= S_IFDIR;
++ i->i_mtime.tv_sec = inodep->mtime;
++ i->i_atime.tv_sec = inodep->mtime;
++ i->i_ctime.tv_sec = inodep->mtime;
++ SQUASHFS_I(i)->start_block = inodep->start_block;
++ SQUASHFS_I(i)->offset = inodep->offset;
++ SQUASHFS_I(i)->u.s2.directory_index_start = next_block;
++ SQUASHFS_I(i)->u.s2.directory_index_offset =
++ next_offset;
++ SQUASHFS_I(i)->u.s2.directory_index_count =
++ inodep->i_count;
++ SQUASHFS_I(i)->u.s2.parent_inode = 0;
++
++ TRACE("Long directory inode %x:%x, start_block %x, "
++ "offset %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ inodep->start_block, inodep->offset);
++ break;
++ }
++ case SQUASHFS_SYMLINK_TYPE: {
++ struct squashfs_symlink_inode_header_2 *inodep =
++ &id.symlink;
++ struct squashfs_symlink_inode_header_2 *sinodep =
++ &sid.symlink;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_SYMLINK_INODE_HEADER_2(inodep,
++ sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ i->i_size = inodep->symlink_size;
++ i->i_op = &page_symlink_inode_operations;
++ i->i_data.a_ops = &squashfs_symlink_aops;
++ i->i_mode |= S_IFLNK;
++ SQUASHFS_I(i)->start_block = next_block;
++ SQUASHFS_I(i)->offset = next_offset;
++
++ TRACE("Symbolic link inode %x:%x, start_block %llx, "
++ "offset %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ next_block, next_offset);
++ break;
++ }
++ case SQUASHFS_BLKDEV_TYPE:
++ case SQUASHFS_CHRDEV_TYPE: {
++ struct squashfs_dev_inode_header_2 *inodep = &id.dev;
++ struct squashfs_dev_inode_header_2 *sinodep = &sid.dev;
++
++ if (msblk->swap) {
++ if (!squashfs_get_cached_block(s, (char *)
++ sinodep, block, offset,
++ sizeof(*sinodep), &next_block,
++ &next_offset))
++ goto failed_read;
++ SQUASHFS_SWAP_DEV_INODE_HEADER_2(inodep, sinodep);
++ } else
++ if (!squashfs_get_cached_block(s, (char *)
++ inodep, block, offset,
++ sizeof(*inodep), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ i->i_mode |= (inodeb->inode_type ==
++ SQUASHFS_CHRDEV_TYPE) ? S_IFCHR :
++ S_IFBLK;
++ init_special_inode(i, i->i_mode,
++ old_decode_dev(inodep->rdev));
++
++ TRACE("Device inode %x:%x, rdev %x\n",
++ SQUASHFS_INODE_BLK(inode), offset,
++ inodep->rdev);
++ break;
++ }
++ case SQUASHFS_FIFO_TYPE:
++ case SQUASHFS_SOCKET_TYPE: {
++
++ i->i_mode |= (inodeb->inode_type == SQUASHFS_FIFO_TYPE)
++ ? S_IFIFO : S_IFSOCK;
++ init_special_inode(i, i->i_mode, 0);
++ break;
++ }
++ default:
++ ERROR("Unknown inode type %d in squashfs_iget!\n",
++ inodeb->inode_type);
++ goto failed_read1;
++ }
++
++ return 1;
++
++failed_read:
++ ERROR("Unable to read inode [%x:%x]\n", block, offset);
++
++failed_read1:
++ return 0;
++}
++
++
++static int get_dir_index_using_offset(struct super_block *s, long long
++ *next_block, unsigned int *next_offset,
++ long long index_start,
++ unsigned int index_offset, int i_count,
++ long long f_pos)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ int i, length = 0;
++ struct squashfs_dir_index_2 index;
++
++ TRACE("Entered get_dir_index_using_offset, i_count %d, f_pos %d\n",
++ i_count, (unsigned int) f_pos);
++
++ if (f_pos == 0)
++ goto finish;
++
++ for (i = 0; i < i_count; i++) {
++ if (msblk->swap) {
++ struct squashfs_dir_index_2 sindex;
++ squashfs_get_cached_block(s, (char *) &sindex,
++ index_start, index_offset,
++ sizeof(sindex), &index_start,
++ &index_offset);
++ SQUASHFS_SWAP_DIR_INDEX_2(&index, &sindex);
++ } else
++ squashfs_get_cached_block(s, (char *) &index,
++ index_start, index_offset,
++ sizeof(index), &index_start,
++ &index_offset);
++
++ if (index.index > f_pos)
++ break;
++
++ squashfs_get_cached_block(s, NULL, index_start, index_offset,
++ index.size + 1, &index_start,
++ &index_offset);
++
++ length = index.index;
++ *next_block = index.start_block + sblk->directory_table_start;
++ }
++
++ *next_offset = (length + *next_offset) % SQUASHFS_METADATA_SIZE;
++
++finish:
++ return length;
++}
++
++
++static int get_dir_index_using_name(struct super_block *s, long long
++ *next_block, unsigned int *next_offset,
++ long long index_start,
++ unsigned int index_offset, int i_count,
++ const char *name, int size)
++{
++ struct squashfs_sb_info *msblk = s->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ int i, length = 0;
++ struct squashfs_dir_index_2 *index;
++ char *str;
++
++ TRACE("Entered get_dir_index_using_name, i_count %d\n", i_count);
++
++ if (!(str = kmalloc(sizeof(struct squashfs_dir_index) +
++ (SQUASHFS_NAME_LEN + 1) * 2, GFP_KERNEL))) {
++ ERROR("Failed to allocate squashfs_dir_index\n");
++ goto failure;
++ }
++
++ index = (struct squashfs_dir_index_2 *) (str + SQUASHFS_NAME_LEN + 1);
++ strncpy(str, name, size);
++ str[size] = '\0';
++
++ for (i = 0; i < i_count; i++) {
++ if (msblk->swap) {
++ struct squashfs_dir_index_2 sindex;
++ squashfs_get_cached_block(s, (char *) &sindex,
++ index_start, index_offset,
++ sizeof(sindex), &index_start,
++ &index_offset);
++ SQUASHFS_SWAP_DIR_INDEX_2(index, &sindex);
++ } else
++ squashfs_get_cached_block(s, (char *) index,
++ index_start, index_offset,
++ sizeof(struct squashfs_dir_index_2),
++ &index_start, &index_offset);
++
++ squashfs_get_cached_block(s, index->name, index_start,
++ index_offset, index->size + 1,
++ &index_start, &index_offset);
++
++ index->name[index->size + 1] = '\0';
++
++ if (strcmp(index->name, str) > 0)
++ break;
++
++ length = index->index;
++ *next_block = index->start_block + sblk->directory_table_start;
++ }
++
++ *next_offset = (length + *next_offset) % SQUASHFS_METADATA_SIZE;
++ kfree(str);
++failure:
++ return length;
++}
++
++
++static int squashfs_readdir_2(struct file *file, void *dirent, filldir_t filldir)
++{
++ struct inode *i = file->f_dentry->d_inode;
++ struct squashfs_sb_info *msblk = i->i_sb->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ long long next_block = SQUASHFS_I(i)->start_block +
++ sblk->directory_table_start;
++ int next_offset = SQUASHFS_I(i)->offset, length = 0,
++ dir_count;
++ struct squashfs_dir_header_2 dirh;
++ struct squashfs_dir_entry_2 *dire;
++
++ TRACE("Entered squashfs_readdir_2 [%llx:%x]\n", next_block, next_offset);
++
++ if (!(dire = kmalloc(sizeof(struct squashfs_dir_entry) +
++ SQUASHFS_NAME_LEN + 1, GFP_KERNEL))) {
++ ERROR("Failed to allocate squashfs_dir_entry\n");
++ goto finish;
++ }
++
++ length = get_dir_index_using_offset(i->i_sb, &next_block, &next_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_start,
++ SQUASHFS_I(i)->u.s2.directory_index_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_count,
++ file->f_pos);
++
++ while (length < i_size_read(i)) {
++ /* read directory header */
++ if (msblk->swap) {
++ struct squashfs_dir_header_2 sdirh;
++
++ if (!squashfs_get_cached_block(i->i_sb, (char *) &sdirh,
++ next_block, next_offset, sizeof(sdirh),
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdirh);
++ SQUASHFS_SWAP_DIR_HEADER_2(&dirh, &sdirh);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, (char *) &dirh,
++ next_block, next_offset, sizeof(dirh),
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(dirh);
++ }
++
++ dir_count = dirh.count + 1;
++ while (dir_count--) {
++ if (msblk->swap) {
++ struct squashfs_dir_entry_2 sdire;
++ if (!squashfs_get_cached_block(i->i_sb, (char *)
++ &sdire, next_block, next_offset,
++ sizeof(sdire), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdire);
++ SQUASHFS_SWAP_DIR_ENTRY_2(dire, &sdire);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, (char *)
++ dire, next_block, next_offset,
++ sizeof(*dire), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += sizeof(*dire);
++ }
++
++ if (!squashfs_get_cached_block(i->i_sb, dire->name,
++ next_block, next_offset,
++ dire->size + 1, &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += dire->size + 1;
++
++ if (file->f_pos >= length)
++ continue;
++
++ dire->name[dire->size + 1] = '\0';
++
++ TRACE("Calling filldir(%x, %s, %d, %d, %x:%x, %d)\n",
++ (unsigned int) dirent, dire->name,
++ dire->size + 1, (int) file->f_pos,
++ dirh.start_block, dire->offset,
++ squashfs_filetype_table[dire->type]);
++
++ if (filldir(dirent, dire->name, dire->size + 1,
++ file->f_pos, SQUASHFS_MK_VFS_INODE(
++ dirh.start_block, dire->offset),
++ squashfs_filetype_table[dire->type])
++ < 0) {
++ TRACE("Filldir returned less than 0\n");
++ goto finish;
++ }
++ file->f_pos = length;
++ }
++ }
++
++finish:
++ kfree(dire);
++ return 0;
++
++failed_read:
++ ERROR("Unable to read directory block [%llx:%x]\n", next_block,
++ next_offset);
++ kfree(dire);
++ return 0;
++}
++
++
++static struct dentry *squashfs_lookup_2(struct inode *i, struct dentry *dentry,
++ struct nameidata *nd)
++{
++ const unsigned char *name = dentry->d_name.name;
++ int len = dentry->d_name.len;
++ struct inode *inode = NULL;
++ struct squashfs_sb_info *msblk = i->i_sb->s_fs_info;
++ struct squashfs_super_block *sblk = &msblk->sblk;
++ long long next_block = SQUASHFS_I(i)->start_block +
++ sblk->directory_table_start;
++ int next_offset = SQUASHFS_I(i)->offset, length = 0,
++ dir_count;
++ struct squashfs_dir_header_2 dirh;
++ struct squashfs_dir_entry_2 *dire;
++ int sorted = sblk->s_major == 2 && sblk->s_minor >= 1;
++
++ TRACE("Entered squashfs_lookup_2 [%llx:%x]\n", next_block, next_offset);
++
++ if (!(dire = kmalloc(sizeof(struct squashfs_dir_entry) +
++ SQUASHFS_NAME_LEN + 1, GFP_KERNEL))) {
++ ERROR("Failed to allocate squashfs_dir_entry\n");
++ goto exit_loop;
++ }
++
++ if (len > SQUASHFS_NAME_LEN)
++ goto exit_loop;
++
++ length = get_dir_index_using_name(i->i_sb, &next_block, &next_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_start,
++ SQUASHFS_I(i)->u.s2.directory_index_offset,
++ SQUASHFS_I(i)->u.s2.directory_index_count, name,
++ len);
++
++ while (length < i_size_read(i)) {
++ /* read directory header */
++ if (msblk->swap) {
++ struct squashfs_dir_header_2 sdirh;
++ if (!squashfs_get_cached_block(i->i_sb, (char *) &sdirh,
++ next_block, next_offset, sizeof(sdirh),
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdirh);
++ SQUASHFS_SWAP_DIR_HEADER_2(&dirh, &sdirh);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, (char *) &dirh,
++ next_block, next_offset, sizeof(dirh),
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += sizeof(dirh);
++ }
++
++ dir_count = dirh.count + 1;
++ while (dir_count--) {
++ if (msblk->swap) {
++ struct squashfs_dir_entry_2 sdire;
++ if (!squashfs_get_cached_block(i->i_sb, (char *)
++ &sdire, next_block,next_offset,
++ sizeof(sdire), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += sizeof(sdire);
++ SQUASHFS_SWAP_DIR_ENTRY_2(dire, &sdire);
++ } else {
++ if (!squashfs_get_cached_block(i->i_sb, (char *)
++ dire, next_block,next_offset,
++ sizeof(*dire), &next_block,
++ &next_offset))
++ goto failed_read;
++
++ length += sizeof(*dire);
++ }
++
++ if (!squashfs_get_cached_block(i->i_sb, dire->name,
++ next_block, next_offset, dire->size + 1,
++ &next_block, &next_offset))
++ goto failed_read;
++
++ length += dire->size + 1;
++
++ if (sorted && name[0] < dire->name[0])
++ goto exit_loop;
++
++ if ((len == dire->size + 1) && !strncmp(name,
++ dire->name, len)) {
++ squashfs_inode_t ino =
++ SQUASHFS_MKINODE(dirh.start_block,
++ dire->offset);
++ unsigned int inode_number = SQUASHFS_MK_VFS_INODE(dirh.start_block,
++ dire->offset);
++
++ TRACE("calling squashfs_iget for directory "
++ "entry %s, inode %x:%x, %lld\n", name,
++ dirh.start_block, dire->offset, ino);
++
++ inode = squashfs_iget(i->i_sb, ino, inode_number);
++
++ goto exit_loop;
++ }
++ }
++ }
++
++exit_loop:
++ kfree(dire);
++ d_add(dentry, inode);
++ return ERR_PTR(0);
++
++failed_read:
++ ERROR("Unable to read directory block [%llx:%x]\n", next_block,
++ next_offset);
++ goto exit_loop;
++}
++
++
++int squashfs_2_0_supported(struct squashfs_sb_info *msblk)
++{
++ struct squashfs_super_block *sblk = &msblk->sblk;
++
++ msblk->read_inode = squashfs_read_inode_2;
++ msblk->read_fragment_index_table = read_fragment_index_table_2;
++
++ sblk->bytes_used = sblk->bytes_used_2;
++ sblk->uid_start = sblk->uid_start_2;
++ sblk->guid_start = sblk->guid_start_2;
++ sblk->inode_table_start = sblk->inode_table_start_2;
++ sblk->directory_table_start = sblk->directory_table_start_2;
++ sblk->fragment_table_start = sblk->fragment_table_start_2;
++
++ return 1;
++}
+diff -x .gitignore -Nurp linux-2.6.24/fs/squashfs/squashfs.h linux-2.6.24-squashfs3.3/fs/squashfs/squashfs.h
+--- linux-2.6.24/fs/squashfs/squashfs.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.24-squashfs3.3/fs/squashfs/squashfs.h 2007-08-19 04:23:16.000000000 +0100
+@@ -0,0 +1,86 @@
++/*
++ * Squashfs - a compressed read only filesystem for Linux
++ *
++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007
++ * Phillip Lougher <phillip@lougher.demon.co.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version 2,
++ * or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++ *
++ * squashfs.h
++ */
++
++#ifdef CONFIG_SQUASHFS_1_0_COMPATIBILITY
++#undef CONFIG_SQUASHFS_1_0_COMPATIBILITY
++#endif
++
++#ifdef SQUASHFS_TRACE
++#define TRACE(s, args...) printk(KERN_NOTICE "SQUASHFS: "s, ## args)
++#else
++#define TRACE(s, args...) {}
++#endif
++
++#define ERROR(s, args...) printk(KERN_ERR "SQUASHFS error: "s, ## args)
++
++#define SERROR(s, args...) do { \
++ if (!silent) \
++ printk(KERN_ERR "SQUASHFS error: "s, ## args);\
++ } while(0)
++
++#define WARNING(s, args...) printk(KERN_WARNING "SQUASHFS: "s, ## args)
++
++static inline struct squashfs_inode_info *SQUASHFS_I(struct inode *inode)
++{
++ return list_entry(inode, struct squashfs_inode_info, vfs_inode);
++}
++
++#if defined(CONFIG_SQUASHFS_1_0_COMPATIBILITY ) || defined(CONFIG_SQUASHFS_2_0_COMPATIBILITY)
++#define SQSH_EXTERN
++extern unsigned int squashfs_read_data(struct super_block *s, char *buffer,
++ long long index, unsigned int length,
++ long long *next_index, int srclength);
++extern int squashfs_get_cached_block(struct super_block *s, void *buffer,
++ long long block, unsigned int offset,
++ int length, long long *next_block,
++ unsigned int *next_offset);
++extern void release_cached_fragment(struct squashfs_sb_info *msblk, struct
++ squashfs_fragment_cache *fragment);
++extern struct squashfs_fragment_cache *get_cached_fragment(struct super_block
++ *s, long long start_block,
++ int length);
++extern struct inode *squashfs_iget(struct super_block *s, squashfs_inode_t inode, unsigned int inode_number);
++extern const struct address_space_operations squashfs_symlink_aops;
++extern const struct address_space_operations squashfs_aops;
++extern struct inode_operations squashfs_dir_inode_ops;
++#else
++#define SQSH_EXTERN static
++#endif
++
++#ifdef CONFIG_SQUASHFS_1_0_COMPATIBILITY
++extern int squashfs_1_0_supported(struct squashfs_sb_info *msblk);
++#else
++static inline int squashfs_1_0_supported(struct squashfs_sb_info *msblk)
++{
++ return 0;
++}
++#endif
++
++#ifdef CONFIG_SQUASHFS_2_0_COMPATIBILITY
++extern int squashfs_2_0_supported(struct squashfs_sb_info *msblk);
++#else
++static inline int squashfs_2_0_supported(struct squashfs_sb_info *msblk)
++{
++ return 0;
++}
++#endif
+diff -x .gitignore -Nurp linux-2.6.24/include/linux/squashfs_fs.h linux-2.6.24-squashfs3.3/include/linux/squashfs_fs.h
+--- linux-2.6.24/include/linux/squashfs_fs.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.24-squashfs3.3/include/linux/squashfs_fs.h 2007-11-01 03:50:57.000000000 +0000
+@@ -0,0 +1,935 @@
++#ifndef SQUASHFS_FS
++#define SQUASHFS_FS
++
++/*
++ * Squashfs
++ *
++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007
++ * Phillip Lougher <phillip@lougher.demon.co.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version 2,
++ * or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++ *
++ * squashfs_fs.h
++ */
++
++#ifndef CONFIG_SQUASHFS_2_0_COMPATIBILITY
++#define CONFIG_SQUASHFS_2_0_COMPATIBILITY
++#endif
++
++#define SQUASHFS_CACHED_FRAGMENTS CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE
++#define SQUASHFS_MAJOR 3
++#define SQUASHFS_MINOR 1
++#define SQUASHFS_MAGIC 0x73717368
++#define SQUASHFS_MAGIC_SWAP 0x68737173
++#define SQUASHFS_START 0
++
++/* size of metadata (inode and directory) blocks */
++#define SQUASHFS_METADATA_SIZE 8192
++#define SQUASHFS_METADATA_LOG 13
++
++/* default size of data blocks */
++#define SQUASHFS_FILE_SIZE 131072
++#define SQUASHFS_FILE_LOG 17
++
++#define SQUASHFS_FILE_MAX_SIZE 1048576
++
++/* Max number of uids and gids */
++#define SQUASHFS_UIDS 256
++#define SQUASHFS_GUIDS 255
++
++/* Max length of filename (not 255) */
++#define SQUASHFS_NAME_LEN 256
++
++#define SQUASHFS_INVALID ((long long) 0xffffffffffff)
++#define SQUASHFS_INVALID_FRAG ((unsigned int) 0xffffffff)
++#define SQUASHFS_INVALID_BLK ((long long) -1)
++#define SQUASHFS_USED_BLK ((long long) -2)
++
++/* Filesystem flags */
++#define SQUASHFS_NOI 0
++#define SQUASHFS_NOD 1
++#define SQUASHFS_CHECK 2
++#define SQUASHFS_NOF 3
++#define SQUASHFS_NO_FRAG 4
++#define SQUASHFS_ALWAYS_FRAG 5
++#define SQUASHFS_DUPLICATE 6
++#define SQUASHFS_EXPORT 7
++
++#define SQUASHFS_BIT(flag, bit) ((flag >> bit) & 1)
++
++#define SQUASHFS_UNCOMPRESSED_INODES(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_NOI)
++
++#define SQUASHFS_UNCOMPRESSED_DATA(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_NOD)
++
++#define SQUASHFS_UNCOMPRESSED_FRAGMENTS(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_NOF)
++
++#define SQUASHFS_NO_FRAGMENTS(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_NO_FRAG)
++
++#define SQUASHFS_ALWAYS_FRAGMENTS(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_ALWAYS_FRAG)
++
++#define SQUASHFS_DUPLICATES(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_DUPLICATE)
++
++#define SQUASHFS_EXPORTABLE(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_EXPORT)
++
++#define SQUASHFS_CHECK_DATA(flags) SQUASHFS_BIT(flags, \
++ SQUASHFS_CHECK)
++
++#define SQUASHFS_MKFLAGS(noi, nod, check_data, nof, no_frag, always_frag, \
++ duplicate_checking, exortable) (noi | (nod << 1) | (check_data << 2) \
++ | (nof << 3) | (no_frag << 4) | (always_frag << 5) | \
++ (duplicate_checking << 6) | (exportable << 7))
++
++/* Max number of types and file types */
++#define SQUASHFS_DIR_TYPE 1
++#define SQUASHFS_FILE_TYPE 2
++#define SQUASHFS_SYMLINK_TYPE 3
++#define SQUASHFS_BLKDEV_TYPE 4
++#define SQUASHFS_CHRDEV_TYPE 5
++#define SQUASHFS_FIFO_TYPE 6
++#define SQUASHFS_SOCKET_TYPE 7
++#define SQUASHFS_LDIR_TYPE 8
++#define SQUASHFS_LREG_TYPE 9
++
++/* 1.0 filesystem type definitions */
++#define SQUASHFS_TYPES 5
++#define SQUASHFS_IPC_TYPE 0
++
++/* Flag whether block is compressed or uncompressed, bit is set if block is
++ * uncompressed */
++#define SQUASHFS_COMPRESSED_BIT (1 << 15)
++
++#define SQUASHFS_COMPRESSED_SIZE(B) (((B) & ~SQUASHFS_COMPRESSED_BIT) ? \
++ (B) & ~SQUASHFS_COMPRESSED_BIT : SQUASHFS_COMPRESSED_BIT)
++
++#define SQUASHFS_COMPRESSED(B) (!((B) & SQUASHFS_COMPRESSED_BIT))
++
++#define SQUASHFS_COMPRESSED_BIT_BLOCK (1 << 24)
++
++#define SQUASHFS_COMPRESSED_SIZE_BLOCK(B) ((B) & \
++ ~SQUASHFS_COMPRESSED_BIT_BLOCK)
++
++#define SQUASHFS_COMPRESSED_BLOCK(B) (!((B) & SQUASHFS_COMPRESSED_BIT_BLOCK))
++
++/*
++ * Inode number ops. Inodes consist of a compressed block number, and an
++ * uncompressed offset within that block
++ */
++#define SQUASHFS_INODE_BLK(a) ((unsigned int) ((a) >> 16))
++
++#define SQUASHFS_INODE_OFFSET(a) ((unsigned int) ((a) & 0xffff))
++
++#define SQUASHFS_MKINODE(A, B) ((squashfs_inode_t)(((squashfs_inode_t) (A)\
++ << 16) + (B)))
++
++/* Compute 32 bit VFS inode number from squashfs inode number */
++#define SQUASHFS_MK_VFS_INODE(a, b) ((unsigned int) (((a) << 8) + \
++ ((b) >> 2) + 1))
++/* XXX */
++
++/* Translate between VFS mode and squashfs mode */
++#define SQUASHFS_MODE(a) ((a) & 0xfff)
++
++/* fragment and fragment table defines */
++#define SQUASHFS_FRAGMENT_BYTES(A) ((A) * sizeof(struct squashfs_fragment_entry))
++
++#define SQUASHFS_FRAGMENT_INDEX(A) (SQUASHFS_FRAGMENT_BYTES(A) / \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_FRAGMENT_INDEX_OFFSET(A) (SQUASHFS_FRAGMENT_BYTES(A) % \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_FRAGMENT_INDEXES(A) ((SQUASHFS_FRAGMENT_BYTES(A) + \
++ SQUASHFS_METADATA_SIZE - 1) / \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_FRAGMENT_INDEX_BYTES(A) (SQUASHFS_FRAGMENT_INDEXES(A) *\
++ sizeof(long long))
++
++/* inode lookup table defines */
++#define SQUASHFS_LOOKUP_BYTES(A) ((A) * sizeof(squashfs_inode_t))
++
++#define SQUASHFS_LOOKUP_BLOCK(A) (SQUASHFS_LOOKUP_BYTES(A) / \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_LOOKUP_BLOCK_OFFSET(A) (SQUASHFS_LOOKUP_BYTES(A) % \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_LOOKUP_BLOCKS(A) ((SQUASHFS_LOOKUP_BYTES(A) + \
++ SQUASHFS_METADATA_SIZE - 1) / \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_LOOKUP_BLOCK_BYTES(A) (SQUASHFS_LOOKUP_BLOCKS(A) *\
++ sizeof(long long))
++
++/* cached data constants for filesystem */
++#define SQUASHFS_CACHED_BLKS 8
++
++#define SQUASHFS_MAX_FILE_SIZE_LOG 64
++
++#define SQUASHFS_MAX_FILE_SIZE ((long long) 1 << \
++ (SQUASHFS_MAX_FILE_SIZE_LOG - 2))
++
++#define SQUASHFS_MARKER_BYTE 0xff
++
++/* meta index cache */
++#define SQUASHFS_META_INDEXES (SQUASHFS_METADATA_SIZE / sizeof(unsigned int))
++#define SQUASHFS_META_ENTRIES 31
++#define SQUASHFS_META_NUMBER 8
++#define SQUASHFS_SLOTS 4
++
++struct meta_entry {
++ long long data_block;
++ unsigned int index_block;
++ unsigned short offset;
++ unsigned short pad;
++};
++
++struct meta_index {
++ unsigned int inode_number;
++ unsigned int offset;
++ unsigned short entries;
++ unsigned short skip;
++ unsigned short locked;
++ unsigned short pad;
++ struct meta_entry meta_entry[SQUASHFS_META_ENTRIES];
++};
++
++
++/*
++ * definitions for structures on disk
++ */
++
++typedef long long squashfs_block_t;
++typedef long long squashfs_inode_t;
++
++struct squashfs_super_block {
++ unsigned int s_magic;
++ unsigned int inodes;
++ unsigned int bytes_used_2;
++ unsigned int uid_start_2;
++ unsigned int guid_start_2;
++ unsigned int inode_table_start_2;
++ unsigned int directory_table_start_2;
++ unsigned int s_major:16;
++ unsigned int s_minor:16;
++ unsigned int block_size_1:16;
++ unsigned int block_log:16;
++ unsigned int flags:8;
++ unsigned int no_uids:8;
++ unsigned int no_guids:8;
++ unsigned int mkfs_time /* time of filesystem creation */;
++ squashfs_inode_t root_inode;
++ unsigned int block_size;
++ unsigned int fragments;
++ unsigned int fragment_table_start_2;
++ long long bytes_used;
++ long long uid_start;
++ long long guid_start;
++ long long inode_table_start;
++ long long directory_table_start;
++ long long fragment_table_start;
++ long long lookup_table_start;
++} __attribute__ ((packed));
++
++struct squashfs_dir_index {
++ unsigned int index;
++ unsigned int start_block;
++ unsigned char size;
++ unsigned char name[0];
++} __attribute__ ((packed));
++
++#define SQUASHFS_BASE_INODE_HEADER \
++ unsigned int inode_type:4; \
++ unsigned int mode:12; \
++ unsigned int uid:8; \
++ unsigned int guid:8; \
++ unsigned int mtime; \
++ unsigned int inode_number;
++
++struct squashfs_base_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++} __attribute__ ((packed));
++
++struct squashfs_ipc_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++ unsigned int nlink;
++} __attribute__ ((packed));
++
++struct squashfs_dev_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++ unsigned int nlink;
++ unsigned short rdev;
++} __attribute__ ((packed));
++
++struct squashfs_symlink_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++ unsigned int nlink;
++ unsigned short symlink_size;
++ char symlink[0];
++} __attribute__ ((packed));
++
++struct squashfs_reg_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++ squashfs_block_t start_block;
++ unsigned int fragment;
++ unsigned int offset;
++ unsigned int file_size;
++ unsigned short block_list[0];
++} __attribute__ ((packed));
++
++struct squashfs_lreg_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++ unsigned int nlink;
++ squashfs_block_t start_block;
++ unsigned int fragment;
++ unsigned int offset;
++ long long file_size;
++ unsigned short block_list[0];
++} __attribute__ ((packed));
++
++struct squashfs_dir_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++ unsigned int nlink;
++ unsigned int file_size:19;
++ unsigned int offset:13;
++ unsigned int start_block;
++ unsigned int parent_inode;
++} __attribute__ ((packed));
++
++struct squashfs_ldir_inode_header {
++ SQUASHFS_BASE_INODE_HEADER;
++ unsigned int nlink;
++ unsigned int file_size:27;
++ unsigned int offset:13;
++ unsigned int start_block;
++ unsigned int i_count:16;
++ unsigned int parent_inode;
++ struct squashfs_dir_index index[0];
++} __attribute__ ((packed));
++
++union squashfs_inode_header {
++ struct squashfs_base_inode_header base;
++ struct squashfs_dev_inode_header dev;
++ struct squashfs_symlink_inode_header symlink;
++ struct squashfs_reg_inode_header reg;
++ struct squashfs_lreg_inode_header lreg;
++ struct squashfs_dir_inode_header dir;
++ struct squashfs_ldir_inode_header ldir;
++ struct squashfs_ipc_inode_header ipc;
++};
++
++struct squashfs_dir_entry {
++ unsigned int offset:13;
++ unsigned int type:3;
++ unsigned int size:8;
++ int inode_number:16;
++ char name[0];
++} __attribute__ ((packed));
++
++struct squashfs_dir_header {
++ unsigned int count:8;
++ unsigned int start_block;
++ unsigned int inode_number;
++} __attribute__ ((packed));
++
++struct squashfs_fragment_entry {
++ long long start_block;
++ unsigned int size;
++ unsigned int pending;
++} __attribute__ ((packed));
++
++extern int squashfs_uncompress_block(void *d, int dstlen, void *s, int srclen);
++extern int squashfs_uncompress_init(void);
++extern int squashfs_uncompress_exit(void);
++
++/*
++ * macros to convert each packed bitfield structure from little endian to big
++ * endian and vice versa. These are needed when creating or using a filesystem
++ * on a machine with different byte ordering to the target architecture.
++ *
++ */
++
++#define SQUASHFS_SWAP_START \
++ int bits;\
++ int b_pos;\
++ unsigned long long val;\
++ unsigned char *s;\
++ unsigned char *d;
++
++#define SQUASHFS_SWAP_SUPER_BLOCK(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_super_block));\
++ SQUASHFS_SWAP((s)->s_magic, d, 0, 32);\
++ SQUASHFS_SWAP((s)->inodes, d, 32, 32);\
++ SQUASHFS_SWAP((s)->bytes_used_2, d, 64, 32);\
++ SQUASHFS_SWAP((s)->uid_start_2, d, 96, 32);\
++ SQUASHFS_SWAP((s)->guid_start_2, d, 128, 32);\
++ SQUASHFS_SWAP((s)->inode_table_start_2, d, 160, 32);\
++ SQUASHFS_SWAP((s)->directory_table_start_2, d, 192, 32);\
++ SQUASHFS_SWAP((s)->s_major, d, 224, 16);\
++ SQUASHFS_SWAP((s)->s_minor, d, 240, 16);\
++ SQUASHFS_SWAP((s)->block_size_1, d, 256, 16);\
++ SQUASHFS_SWAP((s)->block_log, d, 272, 16);\
++ SQUASHFS_SWAP((s)->flags, d, 288, 8);\
++ SQUASHFS_SWAP((s)->no_uids, d, 296, 8);\
++ SQUASHFS_SWAP((s)->no_guids, d, 304, 8);\
++ SQUASHFS_SWAP((s)->mkfs_time, d, 312, 32);\
++ SQUASHFS_SWAP((s)->root_inode, d, 344, 64);\
++ SQUASHFS_SWAP((s)->block_size, d, 408, 32);\
++ SQUASHFS_SWAP((s)->fragments, d, 440, 32);\
++ SQUASHFS_SWAP((s)->fragment_table_start_2, d, 472, 32);\
++ SQUASHFS_SWAP((s)->bytes_used, d, 504, 64);\
++ SQUASHFS_SWAP((s)->uid_start, d, 568, 64);\
++ SQUASHFS_SWAP((s)->guid_start, d, 632, 64);\
++ SQUASHFS_SWAP((s)->inode_table_start, d, 696, 64);\
++ SQUASHFS_SWAP((s)->directory_table_start, d, 760, 64);\
++ SQUASHFS_SWAP((s)->fragment_table_start, d, 824, 64);\
++ SQUASHFS_SWAP((s)->lookup_table_start, d, 888, 64);\
++}
++
++#define SQUASHFS_SWAP_BASE_INODE_CORE(s, d, n)\
++ SQUASHFS_MEMSET(s, d, n);\
++ SQUASHFS_SWAP((s)->inode_type, d, 0, 4);\
++ SQUASHFS_SWAP((s)->mode, d, 4, 12);\
++ SQUASHFS_SWAP((s)->uid, d, 16, 8);\
++ SQUASHFS_SWAP((s)->guid, d, 24, 8);\
++ SQUASHFS_SWAP((s)->mtime, d, 32, 32);\
++ SQUASHFS_SWAP((s)->inode_number, d, 64, 32);
++
++#define SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, n) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, n)\
++}
++
++#define SQUASHFS_SWAP_IPC_INODE_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
++ sizeof(struct squashfs_ipc_inode_header))\
++ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\
++}
++
++#define SQUASHFS_SWAP_DEV_INODE_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
++ sizeof(struct squashfs_dev_inode_header)); \
++ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\
++ SQUASHFS_SWAP((s)->rdev, d, 128, 16);\
++}
++
++#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
++ sizeof(struct squashfs_symlink_inode_header));\
++ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\
++ SQUASHFS_SWAP((s)->symlink_size, d, 128, 16);\
++}
++
++#define SQUASHFS_SWAP_REG_INODE_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
++ sizeof(struct squashfs_reg_inode_header));\
++ SQUASHFS_SWAP((s)->start_block, d, 96, 64);\
++ SQUASHFS_SWAP((s)->fragment, d, 160, 32);\
++ SQUASHFS_SWAP((s)->offset, d, 192, 32);\
++ SQUASHFS_SWAP((s)->file_size, d, 224, 32);\
++}
++
++#define SQUASHFS_SWAP_LREG_INODE_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
++ sizeof(struct squashfs_lreg_inode_header));\
++ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\
++ SQUASHFS_SWAP((s)->start_block, d, 128, 64);\
++ SQUASHFS_SWAP((s)->fragment, d, 192, 32);\
++ SQUASHFS_SWAP((s)->offset, d, 224, 32);\
++ SQUASHFS_SWAP((s)->file_size, d, 256, 64);\
++}
++
++#define SQUASHFS_SWAP_DIR_INODE_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
++ sizeof(struct squashfs_dir_inode_header));\
++ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\
++ SQUASHFS_SWAP((s)->file_size, d, 128, 19);\
++ SQUASHFS_SWAP((s)->offset, d, 147, 13);\
++ SQUASHFS_SWAP((s)->start_block, d, 160, 32);\
++ SQUASHFS_SWAP((s)->parent_inode, d, 192, 32);\
++}
++
++#define SQUASHFS_SWAP_LDIR_INODE_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
++ sizeof(struct squashfs_ldir_inode_header));\
++ SQUASHFS_SWAP((s)->nlink, d, 96, 32);\
++ SQUASHFS_SWAP((s)->file_size, d, 128, 27);\
++ SQUASHFS_SWAP((s)->offset, d, 155, 13);\
++ SQUASHFS_SWAP((s)->start_block, d, 168, 32);\
++ SQUASHFS_SWAP((s)->i_count, d, 200, 16);\
++ SQUASHFS_SWAP((s)->parent_inode, d, 216, 32);\
++}
++
++#define SQUASHFS_SWAP_DIR_INDEX(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_index));\
++ SQUASHFS_SWAP((s)->index, d, 0, 32);\
++ SQUASHFS_SWAP((s)->start_block, d, 32, 32);\
++ SQUASHFS_SWAP((s)->size, d, 64, 8);\
++}
++
++#define SQUASHFS_SWAP_DIR_HEADER(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_header));\
++ SQUASHFS_SWAP((s)->count, d, 0, 8);\
++ SQUASHFS_SWAP((s)->start_block, d, 8, 32);\
++ SQUASHFS_SWAP((s)->inode_number, d, 40, 32);\
++}
++
++#define SQUASHFS_SWAP_DIR_ENTRY(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_entry));\
++ SQUASHFS_SWAP((s)->offset, d, 0, 13);\
++ SQUASHFS_SWAP((s)->type, d, 13, 3);\
++ SQUASHFS_SWAP((s)->size, d, 16, 8);\
++ SQUASHFS_SWAP((s)->inode_number, d, 24, 16);\
++}
++
++#define SQUASHFS_SWAP_FRAGMENT_ENTRY(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_fragment_entry));\
++ SQUASHFS_SWAP((s)->start_block, d, 0, 64);\
++ SQUASHFS_SWAP((s)->size, d, 64, 32);\
++}
++
++#define SQUASHFS_SWAP_INODE_T(s, d) SQUASHFS_SWAP_LONG_LONGS(s, d, 1)
++
++#define SQUASHFS_SWAP_SHORTS(s, d, n) {\
++ int entry;\
++ int bit_position;\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, n * 2);\
++ for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += \
++ 16)\
++ SQUASHFS_SWAP(s[entry], d, bit_position, 16);\
++}
++
++#define SQUASHFS_SWAP_INTS(s, d, n) {\
++ int entry;\
++ int bit_position;\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, n * 4);\
++ for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += \
++ 32)\
++ SQUASHFS_SWAP(s[entry], d, bit_position, 32);\
++}
++
++#define SQUASHFS_SWAP_LONG_LONGS(s, d, n) {\
++ int entry;\
++ int bit_position;\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, n * 8);\
++ for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += \
++ 64)\
++ SQUASHFS_SWAP(s[entry], d, bit_position, 64);\
++}
++
++#define SQUASHFS_SWAP_DATA(s, d, n, bits) {\
++ int entry;\
++ int bit_position;\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, n * bits / 8);\
++ for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += \
++ bits)\
++ SQUASHFS_SWAP(s[entry], d, bit_position, bits);\
++}
++
++#define SQUASHFS_SWAP_FRAGMENT_INDEXES(s, d, n) SQUASHFS_SWAP_LONG_LONGS(s, d, n)
++#define SQUASHFS_SWAP_LOOKUP_BLOCKS(s, d, n) SQUASHFS_SWAP_LONG_LONGS(s, d, n)
++
++#ifdef CONFIG_SQUASHFS_1_0_COMPATIBILITY
++
++struct squashfs_base_inode_header_1 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:4; /* index into uid table */
++ unsigned int guid:4; /* index into guid table */
++} __attribute__ ((packed));
++
++struct squashfs_ipc_inode_header_1 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:4; /* index into uid table */
++ unsigned int guid:4; /* index into guid table */
++ unsigned int type:4;
++ unsigned int offset:4;
++} __attribute__ ((packed));
++
++struct squashfs_dev_inode_header_1 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:4; /* index into uid table */
++ unsigned int guid:4; /* index into guid table */
++ unsigned short rdev;
++} __attribute__ ((packed));
++
++struct squashfs_symlink_inode_header_1 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:4; /* index into uid table */
++ unsigned int guid:4; /* index into guid table */
++ unsigned short symlink_size;
++ char symlink[0];
++} __attribute__ ((packed));
++
++struct squashfs_reg_inode_header_1 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:4; /* index into uid table */
++ unsigned int guid:4; /* index into guid table */
++ unsigned int mtime;
++ unsigned int start_block;
++ unsigned int file_size:32;
++ unsigned short block_list[0];
++} __attribute__ ((packed));
++
++struct squashfs_dir_inode_header_1 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:4; /* index into uid table */
++ unsigned int guid:4; /* index into guid table */
++ unsigned int file_size:19;
++ unsigned int offset:13;
++ unsigned int mtime;
++ unsigned int start_block:24;
++} __attribute__ ((packed));
++
++union squashfs_inode_header_1 {
++ struct squashfs_base_inode_header_1 base;
++ struct squashfs_dev_inode_header_1 dev;
++ struct squashfs_symlink_inode_header_1 symlink;
++ struct squashfs_reg_inode_header_1 reg;
++ struct squashfs_dir_inode_header_1 dir;
++ struct squashfs_ipc_inode_header_1 ipc;
++};
++
++#define SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, n) \
++ SQUASHFS_MEMSET(s, d, n);\
++ SQUASHFS_SWAP((s)->inode_type, d, 0, 4);\
++ SQUASHFS_SWAP((s)->mode, d, 4, 12);\
++ SQUASHFS_SWAP((s)->uid, d, 16, 4);\
++ SQUASHFS_SWAP((s)->guid, d, 20, 4);
++
++#define SQUASHFS_SWAP_BASE_INODE_HEADER_1(s, d, n) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, n)\
++}
++
++#define SQUASHFS_SWAP_IPC_INODE_HEADER_1(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, \
++ sizeof(struct squashfs_ipc_inode_header_1));\
++ SQUASHFS_SWAP((s)->type, d, 24, 4);\
++ SQUASHFS_SWAP((s)->offset, d, 28, 4);\
++}
++
++#define SQUASHFS_SWAP_DEV_INODE_HEADER_1(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, \
++ sizeof(struct squashfs_dev_inode_header_1));\
++ SQUASHFS_SWAP((s)->rdev, d, 24, 16);\
++}
++
++#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER_1(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, \
++ sizeof(struct squashfs_symlink_inode_header_1));\
++ SQUASHFS_SWAP((s)->symlink_size, d, 24, 16);\
++}
++
++#define SQUASHFS_SWAP_REG_INODE_HEADER_1(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, \
++ sizeof(struct squashfs_reg_inode_header_1));\
++ SQUASHFS_SWAP((s)->mtime, d, 24, 32);\
++ SQUASHFS_SWAP((s)->start_block, d, 56, 32);\
++ SQUASHFS_SWAP((s)->file_size, d, 88, 32);\
++}
++
++#define SQUASHFS_SWAP_DIR_INODE_HEADER_1(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, \
++ sizeof(struct squashfs_dir_inode_header_1));\
++ SQUASHFS_SWAP((s)->file_size, d, 24, 19);\
++ SQUASHFS_SWAP((s)->offset, d, 43, 13);\
++ SQUASHFS_SWAP((s)->mtime, d, 56, 32);\
++ SQUASHFS_SWAP((s)->start_block, d, 88, 24);\
++}
++
++#endif
++
++#ifdef CONFIG_SQUASHFS_2_0_COMPATIBILITY
++
++struct squashfs_dir_index_2 {
++ unsigned int index:27;
++ unsigned int start_block:29;
++ unsigned char size;
++ unsigned char name[0];
++} __attribute__ ((packed));
++
++struct squashfs_base_inode_header_2 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:8; /* index into uid table */
++ unsigned int guid:8; /* index into guid table */
++} __attribute__ ((packed));
++
++struct squashfs_ipc_inode_header_2 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:8; /* index into uid table */
++ unsigned int guid:8; /* index into guid table */
++} __attribute__ ((packed));
++
++struct squashfs_dev_inode_header_2 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:8; /* index into uid table */
++ unsigned int guid:8; /* index into guid table */
++ unsigned short rdev;
++} __attribute__ ((packed));
++
++struct squashfs_symlink_inode_header_2 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:8; /* index into uid table */
++ unsigned int guid:8; /* index into guid table */
++ unsigned short symlink_size;
++ char symlink[0];
++} __attribute__ ((packed));
++
++struct squashfs_reg_inode_header_2 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:8; /* index into uid table */
++ unsigned int guid:8; /* index into guid table */
++ unsigned int mtime;
++ unsigned int start_block;
++ unsigned int fragment;
++ unsigned int offset;
++ unsigned int file_size:32;
++ unsigned short block_list[0];
++} __attribute__ ((packed));
++
++struct squashfs_dir_inode_header_2 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:8; /* index into uid table */
++ unsigned int guid:8; /* index into guid table */
++ unsigned int file_size:19;
++ unsigned int offset:13;
++ unsigned int mtime;
++ unsigned int start_block:24;
++} __attribute__ ((packed));
++
++struct squashfs_ldir_inode_header_2 {
++ unsigned int inode_type:4;
++ unsigned int mode:12; /* protection */
++ unsigned int uid:8; /* index into uid table */
++ unsigned int guid:8; /* index into guid table */
++ unsigned int file_size:27;
++ unsigned int offset:13;
++ unsigned int mtime;
++ unsigned int start_block:24;
++ unsigned int i_count:16;
++ struct squashfs_dir_index_2 index[0];
++} __attribute__ ((packed));
++
++union squashfs_inode_header_2 {
++ struct squashfs_base_inode_header_2 base;
++ struct squashfs_dev_inode_header_2 dev;
++ struct squashfs_symlink_inode_header_2 symlink;
++ struct squashfs_reg_inode_header_2 reg;
++ struct squashfs_dir_inode_header_2 dir;
++ struct squashfs_ldir_inode_header_2 ldir;
++ struct squashfs_ipc_inode_header_2 ipc;
++};
++
++struct squashfs_dir_header_2 {
++ unsigned int count:8;
++ unsigned int start_block:24;
++} __attribute__ ((packed));
++
++struct squashfs_dir_entry_2 {
++ unsigned int offset:13;
++ unsigned int type:3;
++ unsigned int size:8;
++ char name[0];
++} __attribute__ ((packed));
++
++struct squashfs_fragment_entry_2 {
++ unsigned int start_block;
++ unsigned int size;
++} __attribute__ ((packed));
++
++#define SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, n)\
++ SQUASHFS_MEMSET(s, d, n);\
++ SQUASHFS_SWAP((s)->inode_type, d, 0, 4);\
++ SQUASHFS_SWAP((s)->mode, d, 4, 12);\
++ SQUASHFS_SWAP((s)->uid, d, 16, 8);\
++ SQUASHFS_SWAP((s)->guid, d, 24, 8);\
++
++#define SQUASHFS_SWAP_BASE_INODE_HEADER_2(s, d, n) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, n)\
++}
++
++#define SQUASHFS_SWAP_IPC_INODE_HEADER_2(s, d) \
++ SQUASHFS_SWAP_BASE_INODE_HEADER_2(s, d, sizeof(struct squashfs_ipc_inode_header_2))
++
++#define SQUASHFS_SWAP_DEV_INODE_HEADER_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, \
++ sizeof(struct squashfs_dev_inode_header_2)); \
++ SQUASHFS_SWAP((s)->rdev, d, 32, 16);\
++}
++
++#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, \
++ sizeof(struct squashfs_symlink_inode_header_2));\
++ SQUASHFS_SWAP((s)->symlink_size, d, 32, 16);\
++}
++
++#define SQUASHFS_SWAP_REG_INODE_HEADER_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, \
++ sizeof(struct squashfs_reg_inode_header_2));\
++ SQUASHFS_SWAP((s)->mtime, d, 32, 32);\
++ SQUASHFS_SWAP((s)->start_block, d, 64, 32);\
++ SQUASHFS_SWAP((s)->fragment, d, 96, 32);\
++ SQUASHFS_SWAP((s)->offset, d, 128, 32);\
++ SQUASHFS_SWAP((s)->file_size, d, 160, 32);\
++}
++
++#define SQUASHFS_SWAP_DIR_INODE_HEADER_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, \
++ sizeof(struct squashfs_dir_inode_header_2));\
++ SQUASHFS_SWAP((s)->file_size, d, 32, 19);\
++ SQUASHFS_SWAP((s)->offset, d, 51, 13);\
++ SQUASHFS_SWAP((s)->mtime, d, 64, 32);\
++ SQUASHFS_SWAP((s)->start_block, d, 96, 24);\
++}
++
++#define SQUASHFS_SWAP_LDIR_INODE_HEADER_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_SWAP_BASE_INODE_CORE_2(s, d, \
++ sizeof(struct squashfs_ldir_inode_header_2));\
++ SQUASHFS_SWAP((s)->file_size, d, 32, 27);\
++ SQUASHFS_SWAP((s)->offset, d, 59, 13);\
++ SQUASHFS_SWAP((s)->mtime, d, 72, 32);\
++ SQUASHFS_SWAP((s)->start_block, d, 104, 24);\
++ SQUASHFS_SWAP((s)->i_count, d, 128, 16);\
++}
++
++#define SQUASHFS_SWAP_DIR_INDEX_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_index_2));\
++ SQUASHFS_SWAP((s)->index, d, 0, 27);\
++ SQUASHFS_SWAP((s)->start_block, d, 27, 29);\
++ SQUASHFS_SWAP((s)->size, d, 56, 8);\
++}
++#define SQUASHFS_SWAP_DIR_HEADER_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_header_2));\
++ SQUASHFS_SWAP((s)->count, d, 0, 8);\
++ SQUASHFS_SWAP((s)->start_block, d, 8, 24);\
++}
++
++#define SQUASHFS_SWAP_DIR_ENTRY_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_entry_2));\
++ SQUASHFS_SWAP((s)->offset, d, 0, 13);\
++ SQUASHFS_SWAP((s)->type, d, 13, 3);\
++ SQUASHFS_SWAP((s)->size, d, 16, 8);\
++}
++
++#define SQUASHFS_SWAP_FRAGMENT_ENTRY_2(s, d) {\
++ SQUASHFS_SWAP_START\
++ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_fragment_entry_2));\
++ SQUASHFS_SWAP((s)->start_block, d, 0, 32);\
++ SQUASHFS_SWAP((s)->size, d, 32, 32);\
++}
++
++#define SQUASHFS_SWAP_FRAGMENT_INDEXES_2(s, d, n) SQUASHFS_SWAP_INTS(s, d, n)
++
++/* fragment and fragment table defines */
++#define SQUASHFS_FRAGMENT_BYTES_2(A) (A * sizeof(struct squashfs_fragment_entry_2))
++
++#define SQUASHFS_FRAGMENT_INDEX_2(A) (SQUASHFS_FRAGMENT_BYTES_2(A) / \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_FRAGMENT_INDEX_OFFSET_2(A) (SQUASHFS_FRAGMENT_BYTES_2(A) % \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_FRAGMENT_INDEXES_2(A) ((SQUASHFS_FRAGMENT_BYTES_2(A) + \
++ SQUASHFS_METADATA_SIZE - 1) / \
++ SQUASHFS_METADATA_SIZE)
++
++#define SQUASHFS_FRAGMENT_INDEX_BYTES_2(A) (SQUASHFS_FRAGMENT_INDEXES_2(A) *\
++ sizeof(int))
++
++#endif
++
++#ifdef __KERNEL__
++
++/*
++ * macros used to swap each structure entry, taking into account
++ * bitfields and different bitfield placing conventions on differing
++ * architectures
++ */
++
++#include <asm/byteorder.h>
++
++#ifdef __BIG_ENDIAN
++ /* convert from little endian to big endian */
++#define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, \
++ tbits, b_pos)
++#else
++ /* convert from big endian to little endian */
++#define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, \
++ tbits, 64 - tbits - b_pos)
++#endif
++
++#define _SQUASHFS_SWAP(value, p, pos, tbits, SHIFT) {\
++ b_pos = pos % 8;\
++ val = 0;\
++ s = (unsigned char *)p + (pos / 8);\
++ d = ((unsigned char *) &val) + 7;\
++ for(bits = 0; bits < (tbits + b_pos); bits += 8) \
++ *d-- = *s++;\
++ value = (val >> (SHIFT))/* & ((1 << tbits) - 1)*/;\
++}
++
++#define SQUASHFS_MEMSET(s, d, n) memset(s, 0, n);
++
++#endif
++#endif
+diff -x .gitignore -Nurp linux-2.6.24/include/linux/squashfs_fs_i.h linux-2.6.24-squashfs3.3/include/linux/squashfs_fs_i.h
+--- linux-2.6.24/include/linux/squashfs_fs_i.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.24-squashfs3.3/include/linux/squashfs_fs_i.h 2007-08-19 04:24:08.000000000 +0100
+@@ -0,0 +1,45 @@
++#ifndef SQUASHFS_FS_I
++#define SQUASHFS_FS_I
++/*
++ * Squashfs
++ *
++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007
++ * Phillip Lougher <phillip@lougher.demon.co.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version 2,
++ * or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++ *
++ * squashfs_fs_i.h
++ */
++
++struct squashfs_inode_info {
++ long long start_block;
++ unsigned int offset;
++ union {
++ struct {
++ long long fragment_start_block;
++ unsigned int fragment_size;
++ unsigned int fragment_offset;
++ long long block_list_start;
++ } s1;
++ struct {
++ long long directory_index_start;
++ unsigned int directory_index_offset;
++ unsigned int directory_index_count;
++ unsigned int parent_inode;
++ } s2;
++ } u;
++ struct inode vfs_inode;
++};
++#endif
+diff -x .gitignore -Nurp linux-2.6.24/include/linux/squashfs_fs_sb.h linux-2.6.24-squashfs3.3/include/linux/squashfs_fs_sb.h
+--- linux-2.6.24/include/linux/squashfs_fs_sb.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.24-squashfs3.3/include/linux/squashfs_fs_sb.h 2007-08-19 04:24:26.000000000 +0100
+@@ -0,0 +1,76 @@
++#ifndef SQUASHFS_FS_SB
++#define SQUASHFS_FS_SB
++/*
++ * Squashfs
++ *
++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007
++ * Phillip Lougher <phillip@lougher.demon.co.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version 2,
++ * or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++ *
++ * squashfs_fs_sb.h
++ */
++
++#include <linux/squashfs_fs.h>
++
++struct squashfs_cache {
++ long long block;
++ int length;
++ long long next_index;
++ char *data;
++};
++
++struct squashfs_fragment_cache {
++ long long block;
++ int length;
++ unsigned int locked;
++ char *data;
++};
++
++struct squashfs_sb_info {
++ struct squashfs_super_block sblk;
++ int devblksize;
++ int devblksize_log2;
++ int swap;
++ struct squashfs_cache *block_cache;
++ struct squashfs_fragment_cache *fragment;
++ int next_cache;
++ int next_fragment;
++ int next_meta_index;
++ unsigned int *uid;
++ unsigned int *guid;
++ long long *fragment_index;
++ unsigned int *fragment_index_2;
++ char *read_page;
++ struct mutex read_data_mutex;
++ struct mutex read_page_mutex;
++ struct mutex block_cache_mutex;
++ struct mutex fragment_mutex;
++ struct mutex meta_index_mutex;
++ wait_queue_head_t waitq;
++ wait_queue_head_t fragment_wait_queue;
++ struct meta_index *meta_index;
++ z_stream stream;
++ long long *inode_lookup_table;
++ int unused_cache_blks;
++ int unused_frag_blks;
++ int (*read_inode)(struct inode *i, squashfs_inode_t \
++ inode);
++ long long (*read_blocklist)(struct inode *inode, int \
++ index, int readahead_blks, char *block_list, \
++ unsigned short **block_p, unsigned int *bsize);
++ int (*read_fragment_index_table)(struct super_block *s);
++};
++#endif
+diff -x .gitignore -Nurp linux-2.6.24/init/do_mounts_rd.c linux-2.6.24-squashfs3.3/init/do_mounts_rd.c
+--- linux-2.6.24/init/do_mounts_rd.c 2007-10-25 17:41:49.000000000 +0100
++++ linux-2.6.24-squashfs3.3/init/do_mounts_rd.c 2007-11-01 05:06:25.000000000 +0000
+@@ -5,6 +5,7 @@
+ #include <linux/ext2_fs.h>
+ #include <linux/romfs_fs.h>
+ #include <linux/cramfs_fs.h>
++#include <linux/squashfs_fs.h>
+ #include <linux/initrd.h>
+ #include <linux/string.h>
+
+@@ -39,6 +40,7 @@ static int __init crd_load(int in_fd, in
+ * numbers could not be found.
+ *
+ * We currently check for the following magic numbers:
++ * squashfs
+ * minix
+ * ext2
+ * romfs
+@@ -53,6 +55,7 @@ identify_ramdisk_image(int fd, int start
+ struct ext2_super_block *ext2sb;
+ struct romfs_super_block *romfsb;
+ struct cramfs_super *cramfsb;
++ struct squashfs_super_block *squashfsb;
+ int nblocks = -1;
+ unsigned char *buf;
+
+@@ -64,6 +67,7 @@ identify_ramdisk_image(int fd, int start
+ ext2sb = (struct ext2_super_block *) buf;
+ romfsb = (struct romfs_super_block *) buf;
+ cramfsb = (struct cramfs_super *) buf;
++ squashfsb = (struct squashfs_super_block *) buf;
+ memset(buf, 0xe5, size);
+
+ /*
+@@ -101,6 +105,18 @@ identify_ramdisk_image(int fd, int start
+ goto done;
+ }
+
++ /* squashfs is at block zero too */
++ if (squashfsb->s_magic == SQUASHFS_MAGIC) {
++ printk(KERN_NOTICE
++ "RAMDISK: squashfs filesystem found at block %d\n",
++ start_block);
++ if (squashfsb->s_major < 3)
++ nblocks = (squashfsb->bytes_used_2+BLOCK_SIZE-1)>>BLOCK_SIZE_BITS;
++ else
++ nblocks = (squashfsb->bytes_used+BLOCK_SIZE-1)>>BLOCK_SIZE_BITS;
++ goto done;
++ }
++
+ /*
+ * Read block 1 to test for minix and ext2 superblock
+ */
diff --git a/patches/toshiba-bluetooth.patch b/patches/toshiba-bluetooth.patch
new file mode 100644
index 0000000..50752d8
--- /dev/null
+++ b/patches/toshiba-bluetooth.patch
@@ -0,0 +1,241 @@
+--- linux-source-2.6.14.orig/drivers/acpi/toshiba_acpi.c 2005-10-28 02:02:08.000000000 +0200
++++ linux-source-2.6.14/drivers/acpi/toshiba_acpi.c 2005-11-12 14:14:05.000000000 +0100
+@@ -33,7 +33,7 @@
+ *
+ */
+
+-#define TOSHIBA_ACPI_VERSION "0.18"
++#define TOSHIBA_ACPI_VERSION "0.18-p1"
+ #define PROC_INTERFACE_VERSION 1
+
+ #include <linux/kernel.h>
+@@ -209,6 +209,31 @@ static acpi_status hci_read1(u32 reg, u3
+ return status;
+ }
+
++static acpi_status
++hci_write2(u32 reg, u32 in1, u32 in2, u32* result)
++{
++ u32 in[HCI_WORDS] = { HCI_SET, reg, in1, in2, 0, 0 };
++ u32 out[HCI_WORDS];
++ acpi_status status = hci_raw(in, out);
++ *result = (status == AE_OK) ? out[0] : HCI_FAILURE;
++ return status;
++}
++
++static acpi_status
++hci_read2(u32 reg, u32* out1, u32* out2, u32* result)
++{
++ u32 in[HCI_WORDS] = { HCI_GET, reg, *out1, *out2, 0, 0 };
++ u32 out[HCI_WORDS];
++ acpi_status status = hci_raw(in, out);
++ *out1 = out[2];
++ *out2 = out[3];
++ *result = (status == AE_OK) ? out[0] : HCI_FAILURE;
++ return status;
++}
++
++
++
++
+ static struct proc_dir_entry *toshiba_proc_dir /*= 0*/ ;
+ static struct backlight_device *toshiba_backlight_device;
+ static int force_fan;
+@@ -214,6 +214,7 @@
+ static int force_fan;
+ static int last_key_event;
+ static int key_event_valid;
++static int arbitrary, arbitrary2, arbitrary1;
+
+ typedef struct _ProcItem {
+ const char *name;
+@@ -455,6 +481,171 @@ static unsigned long write_keys(const ch
+ return count;
+ }
+
++static char*
++read_wk(char* p)
++{
++ u32 hci_result;
++ u32 value, value2;
++ value = 0;
++ value2 = 0x0001;
++ hci_read2(0x0056, &value, &value2, &hci_result);
++ if (hci_result == HCI_SUCCESS) {
++ p += sprintf(p,"wireless key: %d\n", value );
++ } else {
++ p += sprintf(p, "ERROR\n");
++ }
++
++ return p;
++}
++
++static char*
++read_bt(char* p)
++{
++ u32 hci_result;
++ u32 value, value2;
++ value = 0;
++ value2 = 0;
++ hci_read2(0x0056, &value, &value2, &hci_result);
++ if (hci_result == HCI_SUCCESS) {
++/* p += sprintf(p,"present: %d\n", value);*/
++ p += sprintf(p,"present: %d\n", (value & 0x0f)?1:0);
++ } else {
++ p += sprintf(p, "ERROR\n");
++ }
++ value = 0;
++ value2 = 0x0001;
++ hci_read2(0x0056, &value, &value2, &hci_result);
++ if (hci_result == HCI_SUCCESS) {
++ p += sprintf(p,"power: %d\n", (value & 128) >> 7);
++ p += sprintf(p,"attach: %d\n", (value & 64) >> 6);
++ p += sprintf(p,"wireless: %d\n", (value & 512) >> 9);
++ } else {
++ p += sprintf(p, "ERROR\n");
++ }
++
++ return p;
++}
++
++static unsigned long
++write_bt(const char* buffer, unsigned long count)
++{
++ int value, value2;
++ u32 hci_result;
++ value2 = 0x0080;
++
++ if (sscanf(buffer, " power : %i", &value) == 1 &&
++ value >= 0 && value <= 1) {
++ hci_write2(0x0056, value, value2, &hci_result);
++ if (hci_result != HCI_SUCCESS)
++ return -EFAULT;
++ } else
++ if (sscanf(buffer, " attach : %i", &value) == 1 &&
++ value >= 0 && value <= 1) {
++ value2 = 0x0040;
++ hci_write2(0x0056, value, value2, &hci_result);
++ if (hci_result != HCI_SUCCESS)
++ return -EFAULT;
++ } else
++ if (sscanf(buffer, " orinoco : %i", &value) == 1 &&
++ value >= 0 && value <= 1) {
++ value2 = 0x0200;
++ hci_write2(0x0056, value, value2, &hci_result);
++ if (hci_result != HCI_SUCCESS)
++ return -EFAULT;
++ } else {
++ return -EINVAL;
++ }
++
++ return count;
++}
++
++static char*
++read_arb(char* p)
++{
++ u32 hci_result;
++ u32 value, value2;
++ value = 0;
++ value2 = arbitrary2;
++ p += sprintf(p,"arg1 : %d\n", value );
++ p += sprintf(p,"arg2 : %d\n", value2 );
++ hci_read2(arbitrary, &value, &value2, &hci_result);
++ if (hci_result == HCI_SUCCESS) {
++ p += sprintf(p,"arbitrary call: %d\n", arbitrary);
++
++ p += sprintf(p,"return1: %x\n", value);
++ p += sprintf(p,"return2: %x\n",value2);
++ } else
++ p += sprintf(p, "ERROR\n");
++
++ return p;
++}
++
++static unsigned long
++write_arb(const char* buffer, unsigned long count)
++{
++ int value, value2, i;
++ u32 hci_result;
++ value2 = 0x0080;
++
++ sscanf(buffer, " arb : %i", &value) ;
++ arbitrary=value;
++ i=0;
++ while(buffer[i]!=';')i++;
++ if (sscanf(buffer+i+1, " arb2 : %i", &value) == 1 )
++ arbitrary2=value;
++ else
++ return -EINVAL;
++
++ return count;
++}
++
++
++static char*
++read_arb_c(char* p)
++{
++ u32 hci_result;
++ u32 value, value2;
++
++ value = arbitrary1;
++ value2 = arbitrary2;
++ p += sprintf(p,"arg1 : %d\n", value );
++ p += sprintf(p,"arg2 : %d\n", value2 );
++
++ hci_write2(arbitrary, value, value2, &hci_result);
++ if (hci_result == HCI_SUCCESS) {
++ p += sprintf(p,"arbitrary call: %d\n", arbitrary);
++ p += sprintf(p,"return1: %d\n", value);
++ p += sprintf(p,"return2: %d\n",value2);
++ } else
++ p += sprintf(p, "ERROR\n");
++
++ return p;
++}
++
++static unsigned long
++write_arb_c(const char* buffer, unsigned long count)
++{
++ int value, value2, i;
++ u32 hci_result;
++ value2 = 0x0080;
++
++ sscanf(buffer, " arb : %i", &value) ;
++ arbitrary=value;
++ i=0;
++ while(buffer[i]!=';')i++;
++ sscanf(buffer+i+1, " arb2 : %i", &value);
++ arbitrary2=value;
++ i++;
++ while(buffer[i]!=';')i++;
++ if (sscanf(buffer+i+1, " arb1 : %i", &value) == 1 )
++ arbitrary1=value;
++ else
++ return -EINVAL;
++
++ return count;
++}
++
++
+ static char *read_version(char *p)
+ {
+ p += sprintf(p, "driver: %s\n", TOSHIBA_ACPI_VERSION);
+@@ -474,6 +665,8 @@ static ProcItem proc_items[] = {
+ {"fan", read_fan, write_fan},
+ {"keys", read_keys, write_keys},
+ {"version", read_version, NULL},
++ { "wireless_key", read_wk , 0 },
++ { "bluetooth" , read_bt , write_bt },
+ {NULL}
+ };
+
+@@ -484,7 +677,7 @@ static acpi_status __init add_device(voi
+
+ for (item = proc_items; item->name; ++item) {
+ proc = create_proc_read_entry(item->name,
+- S_IFREG | S_IRUGO | S_IWUSR,
++ S_IFREG | S_IRUGO | S_IWUGO,
+ toshiba_proc_dir,
+ (read_proc_t *) dispatch_read,
+ item);
diff --git a/patches/usb-storage-unusual-devs.patch b/patches/usb-storage-unusual-devs.patch
new file mode 100644
index 0000000..1d508ad
--- /dev/null
+++ b/patches/usb-storage-unusual-devs.patch
@@ -0,0 +1,19 @@
+--- linux-2.6.20.orig/drivers/usb/storage/unusual_devs.h
++++ linux-2.6.20/drivers/usb/storage/unusual_devs.h
+@@ -1332,6 +1332,16 @@
+ US_SC_DEVICE, US_PR_DEVICE, NULL,
+ US_FL_IGNORE_RESIDUE ),
+
++/* Reported by Thomas Baechler <thomas@archlinux.org>
++ * Fixes I/O errors with Teac HD-35PU devices
++ */
++
++UNUSUAL_DEV( 0x1652, 0x6600, 0x0201, 0x0201,
++ "Super Top",
++ "USB 2.0 IDE DEVICE",
++ US_SC_DEVICE, US_PR_DEVICE, NULL,
++ US_FL_IGNORE_RESIDUE),
++
+ /* patch submitted by Davide Perini <perini.davide@dpsoftware.org>
+ * and Renato Perini <rperini@email.it>
+ */
diff --git a/patches/winfast-2000.patch b/patches/winfast-2000.patch
new file mode 100644
index 0000000..b43c961
--- /dev/null
+++ b/patches/winfast-2000.patch
@@ -0,0 +1,20 @@
+--- drivers/media/video/bt8xx/bttv-input.c.orig 2006-10-15 18:57:11.000000000 +0300
++++ drivers/media/video/bt8xx/bttv-input.c 2006-10-15 18:28:08.000000000 +0300
+@@ -65,6 +65,8 @@
+ (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
+ ir_input_keydown(ir->dev,&ir->ir,data,data);
+ } else {
++
++ if (btv->c.type == BTTV_BOARD_WINFAST2000) ir_input_keydown(ir->dev,&ir->ir,data,data);
+ ir_input_nokey(ir->dev,&ir->ir);
+ }
+
+@@ -313,7 +315,7 @@
+
+ case BTTV_BOARD_WINFAST2000:
+ ir_codes = ir_codes_winfast;
+- ir->mask_keycode = 0x1f8;
++ ir->mask_keycode = 0x8f8;
+ break;
+ case BTTV_BOARD_MAGICTVIEW061:
+ case BTTV_BOARD_MAGICTVIEW063: