Friday 28 January 2011

Skype 5 for OSX is out

Well they released an official version of it yesterday... I guess I'm getting used to it - the do seem to have made the final version a bit smaller so I suppose it's ok. The group video stuff sounds good and it all seems to work well so far...

Anyway it's good to see they're actually working on Skype for OSX - it's been a while since 2.8 was out. I guess you could give it try....!

Tuesday 18 January 2011

Shrinking Linux virtual disks on OSX VMWare fusion

So your virtual disk is taking up tonnes of space - despite the fact it's not that big when you check its size in the Virtual machine. It's annoying that VMWare images don't do better auto shrinking...

Anyway I tried to run the vmware-tools which I installed (after a bit of jiggery-pokery) and it comes up with a 'Shrink' tab but no disks appear in the list to shrink?! Any suggestion as to how to get disks to show up there are welcome but I couldn't find much on the web about it...

So instead I looked about and the best way is to take the following steps:
  1. Start your VM OS up and optionally remove any cruft. At least run:
    sudo apt-get autoclean
  2. To prepare for the shrinking process run:
    sudo cat /dev/zero > zero;sync;sleep 1;sudo rm zero
    This fills all remaining space on your virtual disk with a file full of zeros so the space can be reclaimed in the shrinking step.
    Note: Your hard disk WILL NOT fill up as the vmdk images do actually optimise the storage of files containing zeros
  3. Shutdown VM OS and delete any snapshots available then Quit VMWare Fusion
  4. To start the shrinking process in OSX run (Replacing path_to_your/disk with something like '/Users/username/Documents/Virtual Machines/Ubuntu/Ubuntu.vmdk'):
    cd '/Applications/VMware Fusion.app/Contents/Library'
    ./vmware-vdiskmanager -d path_to_your/disc.vmdk
    ./vmware-vdiskmanager -k path_to_your/disc.vmdk
    
    The first command defragments the disk, whilst the second actually does the shrinking.
    (Note: The directory for 'cd' for 3.X of VMware Fusion was:
    /Library/Application Support/VMware Fusion/) 
[27jan12: Updated for VMware Fusion 4.X]

Thursday 13 January 2011

New Apps not showing up in Apple+Tab

So I was using my Mac (probably with way too much stuff running) and started a new App and then hid it (Apple+H) and then tried to Apple+Tab (Cmd-Tab) back to it but it didn't appear in the list of App Icons. The same happened when i started another Application.... I could always use Expose but I like Tab switcher...

So then I wondered which process controls the Tab switcher... It turns out that the Dock process not only runs the Dock bar at the bottom but also powers the Tab Switcher. So by just killing the Dock process it will then relaunch (by launchd) and sort it self out (provided you're not totally out of memory/disk space or something). You can do this from a Terminal window, using the following command:
killall Dock 

Monday 10 January 2011

Counting lines of source code...

It seems easy at firstly sight (wc anyone?) then there's all the awkward stuff like comments, blank lines, coding style, header files, and stuff....

Anyway I came across a nice tool: sloccount which works on Linux, OSX and probably others, which does a good job of estimating "Source Code Line Count (SLOC)". Plus it also spits out coding time estimates based on some heuristics. There are other tools out there of course but this one just seems good.

Thursday 6 January 2011

Fixing vmxnet for vmwaretools-7.9.9 on Linux-2.6.32+

I just tried to load up vmwaretools on Ubuntu 10.04 Karmic (Kernel linux-2.6.32 - for later kernels see below) and things went ok till it tried to compile vmxnet.c - things have changed and VMware haven't kept up... So I fixed it - see attached patch below. I took a short cut to get the modified file into the vmware-install.pl build process: It copies the src files to a directory in /tmp/vmware-configX/ (where X is a number) - You'll need to run the vmware-install.pl script and then suspend (hit Ctrl-Z) it once it has got to the very first step of compiling vmxnet (ie before it starts the actual compilation) - then copy in the patched file and put the installer into the foreground (type '%'). I guess it's possible to copy it to a tar file somewhere but I didn't bother locating the correct one.

--- vmxnet.c 2011-01-05 17:46:30.820624430 +0000
+++ vmxnet.c.orig 2010-11-20 02:24:48.000000000 +0000
@@ -162,31 +162,6 @@
#define VMXNET_LOG(msg...)
#endif // VMXNET_DEBUG

-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,43)
-/*
- *-----------------------------------------------------------------------------
- *
- * vmxnet_tx_timeout --
- *
- * Network device tx_timeout routine. Called by Linux when the tx
- * queue has been stopped for more than dev->watchdog_timeo jiffies.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Tries to restart the transmit queue.
- *
- *-----------------------------------------------------------------------------
- */
-static void
-vmxnet_tx_timeout(struct net_device *dev)
-{
- netif_wake_queue(dev);
-}
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,43) */
-
-
/* Data structure used when determining what hardware the driver supports. */

static const struct pci_device_id vmxnet_chips[] =
@@ -210,26 +185,6 @@
.probe = vmxnet_probe_device,
.remove = vmxnet_remove_device,
};
-static struct net_device_ops
-vmxnet_netdev_ops = {
- .ndo_open = vmxnet_open,
- .ndo_start_xmit = vmxnet_start_tx,
- .ndo_stop = vmxnet_close,
- .ndo_get_stats = vmxnet_get_stats,
- .ndo_set_multicast_list = vmxnet_set_multicast_list,
-#ifdef HAVE_CHANGE_MTU
- .ndo_change_mtu = vmxnet_change_mtu,
-#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,43)
- .ndo_tx_timeout = vmxnet_tx_timeout,
-#endif
-#ifdef VMW_HAVE_POLL_CONTROLLER
- .ndo_poll_controller = vmxnet_netpoll,
-#endif
- /* Do this after ether_setup(), which sets the default value. */
- .ndo_set_mac_address = vmxnet_set_mac_address,
-};
-

#ifdef HAVE_CHANGE_MTU
static int
@@ -373,6 +328,8 @@
.set_tso = vmxnet_set_tso,
#endif
};
+
+
#else /* !defined(SET_ETHTOOL_OPS) */


@@ -649,6 +606,30 @@
}


+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,43)
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmxnet_tx_timeout --
+ *
+ * Network device tx_timeout routine. Called by Linux when the tx
+ * queue has been stopped for more than dev->watchdog_timeo jiffies.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Tries to restart the transmit queue.
+ *
+ *-----------------------------------------------------------------------------
+ */
+static void
+vmxnet_tx_timeout(struct net_device *dev)
+{
+ netif_wake_queue(dev);
+}
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,43) */
+

/*
*-----------------------------------------------------------------------------
@@ -1072,9 +1053,25 @@
#endif

dev->irq = irq_line;
+
+ dev->open = &vmxnet_open;
+ dev->hard_start_xmit = &vmxnet_start_tx;
+ dev->stop = &vmxnet_close;
+ dev->get_stats = &vmxnet_get_stats;
+ dev->set_multicast_list = &vmxnet_set_multicast_list;
+#ifdef HAVE_CHANGE_MTU
+ dev->change_mtu = &vmxnet_change_mtu;
+#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,43)
+ dev->tx_timeout = &vmxnet_tx_timeout;
dev->watchdog_timeo = VMXNET_WATCHDOG_TIMEOUT;
+#endif
+#ifdef VMW_HAVE_POLL_CONTROLLER
+ dev->poll_controller = vmxnet_netpoll;
+#endif

- dev->netdev_ops = &vmxnet_netdev_ops;
+ /* Do this after ether_setup(), which sets the default value. */
+ dev->set_mac_address = &vmxnet_set_mac_address;

#ifdef SET_ETHTOOL_OPS
SET_ETHTOOL_OPS(dev, &vmxnet_ethtool_ops);


If you're running linux-2.6.35 (Ubuntu 10.10 Maverick) then you'll also need to apply the following patch (once you've applied the above one):

--- vmxnet.c 2011-01-06 14:44:41.000000000 +0000
+++ vmxnet.c.linux2.6.32 2011-01-06 14:44:41.000000000 +0000
@@ -2405,10 +2405,9 @@
{
struct Vmxnet_Private *lp = netdev_priv(dev);
volatile u16 *mcast_table = (u16 *)lp->dd->LADRF;
- struct netdev_hw_addr_list *mc_list = &dev->mc;
- struct netdev_hw_addr *ha;
+ struct dev_mc_list *dmi = dev->mc_list;
char *addrs;
- int j, bit, byte;
+ int i, j, bit, byte;
u32 crc, poly = CRC_POLYNOMIAL_LE;

/* clear the multicast filter */
@@ -2416,9 +2415,9 @@
lp->dd->LADRF[1] = 0;

/* Add addresses */
-
- netdev_hw_addr_list_for_each(ha, mc_list) {
- addrs = ha->addr;
+ for (i = 0; i < dev->mc_count; i++){
+ addrs = dmi->dmi_addr;
+ dmi = dmi->next;

/* multicast address? */
if (!(*addrs & 1))
@@ -2441,7 +2440,7 @@
crc = crc >> 26;
mcast_table [crc >> 4] |= 1 << (crc & 0xf); } - return mc_list->count;
+ return i;
}

/*