Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Friday, 30 August 2019

cat: -: No such file or directory

A weird error that took me a while to track down. I came across it in the iproute2 configure script which was setting the TMPDIR environment variable before using a cat heredoc statement (e.g. when you include some data in a shell script which demarked using markers - in this case 'EOF'):
TMPDIR=$(mktemp -d config.XXXXXX)
cat >test.c <<EOF
stuff and more stuff
EOF 
The problem is that the TMPDIR variable is used by the cat command. And in this case the TMPDIR is set to the output of mktemp which creates a temporary directory in the current working directory, but this is not usable by the cat command and results in the above error - it seems that cat command will only accept a TMPDIR if it is in /tmp and fails if it is set to another base directory?! According the man page mktemp is supposed to default to using /tmp but it's not working on Linux - It works fine on MacOS. Anyway so one just need to make the following change:
TMPDIR=$(mktemp -d /tmp/config.XXXXXX)

Tuesday, 7 June 2016

Regenerate missing modules.dep.bin

If you're seeing a problem with a missing modules.dep.bin or modules.dep file(s) on your Linux/Ubuntu/Arch box (e.g. libkmod: ERROR ../libkmod/libkmod.c:XXX kmod_search_moddep: could not open moddep file '/lib/modules/kernel_release/modules.dep.bin'), then it may be rebuilt using the depmod command:
sudo depmod

Friday, 29 April 2016

Using cheap SIM card readers

I ordered one of those cheap SIM (Smart card) card readers (often in blue plastic) that take a while to arrive from China. When it showed up I plugged it into my on Linux box and it was recognised as:
$ lsusb
Bus 001 Device 017: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
...
And it had created a serial device: /dev/ttyUSB0. So how do you actually use the thing? It ships with a dodgy mini-CD full of some apparently even dodgier Windows software - not much use. If you try to connect to the serial port using minicom etc you don't get much.

However it is possible to use it on Linux (Whilst OSX has shipped with the relevant deamon pcscd for a while, it seems that openct is not fully supported so it may not work with this little blue one - unless someone ports it). There are two ways to use it - the simplest way is to use apps that can talk directly to the serial port and communicate with the device such as pysimreader or pysim.

The second more advanced way requires some setup on Linux - so you'll need to install a few packages:
$ sudo apt-get install pcscd openct pcsc-tools
Then to get the SIM reader going you need to add the following to the openct config file (/etc/openct.conf) - so it knows where to find the SIM reader (it's known as a "phoenix" style reader):
reader phoenix {
    driver = phoenix;
    device = serial:/dev/ttyUSB0;
};
And uncomment the following lines in openct config file for pcscd (/etc/reader.conf.d/openct) - so that it recognises openct devices:
FRIENDLYNAME     "OpenCT"
DEVICENAME       /dev/null
LIBPATH          /usr/lib/openct-ifd.so
CHANNELID        0
Then you make sure the SIM reader is plugged in and restart the daemons:
$ sudo /etc/init.d/openct restart
sudo /etc/init.d/pcscd restart
Then you should be good to go. You can check the device has been recognised by using the pcsc_scan utility - and you should see it find the OpenCT Reader as below:
$ pcsc_scan 
PC/SC device scanner
V 1.4.22 (c) 2001-2011, Ludovic Rousseau <ludovic.rousseau@free.fr>
Compiled with PC/SC lite version: 1.8.10
Using reader plug'n play mechanism
Scanning present readers...
0: OpenCT 00 00

Fri Apr 29 16:25:33 2016
Reader 0: OpenCT 00 00
  Card state: Card inserted, Shared Mode, 
  ATR: .....

Then you can try out apps like cardpeek and others - install it using apt-get:
$ sudo apt-get install cardpeek

One can use it to read any compatible smart card chip using the reader. If you want to try reading a credit card you'll need to chop out the smart card section to make it into a SIM shape so it can fit into the unit. There's a bunch of more esoteric apps/libs on Github for this stuff like card, simLAB, etc. It is also possible to use the device to authenticate to EAP-SIM/AKA WiFi (thanks to this guy for his blog post that helped me on some of the above).

Note: If you find that the apps aren't working properly (check the logs for weird behaviour - enable logging - in openct edit /etc/openct.conf and add/modify debug = 9, for pcscd start it manually: sudo pcscd -a -d and then you'll have them both log to syslog) you may have a buggy version of openct (I had a problem with openct 0.6.20-1.2ubuntu1) so you'll need to get the latest version from the openct site and install that instead. Note that you'll probably need to build it from source e.g:
$ git clone https://github.com/OpenSC/openct.git
cd openct
./bootstrap
./configure --enable-pcsc
make
sudo make install
Then you'll need to edit the openct config file for pcscd (/etc/reader.conf.d/openct) - so that it uses the newly installed version of openct in /usr/local:
 LIBPATH          /usr/local/lib/openct-ifd.so
Then restart things:
$ sudo /etc/init.d/openct stop
sudo /usr/local/sbin/openct-control init 
sudo /etc/init.d/pcscd restart
Now you should be on track again.
[Updated: 5may16: Adding simple serial apps]

Wednesday, 30 September 2015

MythTV on Kodi (XBMC)

I've been playing with Kodi (once known as XBMC) which is a slick open-source media centre system that runs on almost everything (OSX, Linux, Raspberry Pi, Android, Windowz, even [jailbroken] iOS). I wanted to connect it to MythTV, which is rather a handy open-source DVR for TV streaming and recording. So in Kodi (v15.1) I went to System->Settings->Add-ons->My Add-ons->PVR Client->MythTV PVR Client and then added the IP address of my MythTV server. That's all then I thought... so how does it work...?

It's not entirely obvious - but very simple when you know how - you then need to go to System->Settings->TV->Enable and just enable it! Then a new TV menu item appears on the main screen with various options for interacting with MythTV - like watching live TV, or recorded shows etc.

Also it seems that one can reduce the CPU load when running Kodi with the current versions by switching off the RSS display on the main screen by going to System->Appearance->Show RSS news feeds and disabling the option.

Sunday, 22 June 2014

Mounting OSX Time Capsule shared drive on Linux

If you've been trying to mount an OS X Time Capsule disk over the network using Samba/CIFS/SMB and you've recently run into the problem: "mount error(13): Permission denied", and you KNOW the password is right then this may help. Basically you now need to inform Linux CIFS of the specific security mechanism to use (sec=ntlm). E.g. To mount the drive as root (where share_pwd is the password required to access the drive):
# mount -t cifs //server_ip/Data /mnt/Data -opasswd=share_pwd,sec=ntlm

As an alternative it is also possible to use the Netatalk package under Linux to mount the Time Capsule drive using Apple Filesharing Protocol (AFP).

PS: If you were hoping to mount the Time capsule drive that you either had plugged in or removed from inside your Time Capsule see my earlier post.

[28jun14: Updated to clarify that this regarding network mounting]

Thursday, 7 November 2013

VLAN's on linux

A quick search for VLAN setup on Linux brings up a few old docs which suggest the use of the 'vconfig' utility. But these days one can use the very versatile 'ip' command as explained here. For example one can create a VLAN interface on the eth0 hardware interface with VLAN ID 2 like this:
sudo ip link add link eth0 name eth0.2 type vlan id 2
One can assign an address to the interface like a normal interface:
sudo ip addr add 192.168.2.2/24 dev eth0.2
And to delete the address:
sudo ip link del dev vlan0  type vlan id 2
To show list full details of the interfaces (including VLAN id):
ip -d link

Tuesday, 22 October 2013

Compressing videos quickly

I was compressing some videos today using the venerable ffmpeg and noticed things going rather slowly. Then I spotted that the H.264 library libx264 was saying: "using cpu capabilities: none!" - Ah that might explain it...

I'm on a Mac OSX machine using a version of libx264 from MacPorts. It turns out that the default install does not enable any CPU optimisations. So I just needed to rebuild it with asm variant to enable it's assembly code based optimisations:
sudo port -u install x264 +asm
I reran ffmpeg and libx264 logged that it was using a whole string of it's CPU specific optimisations and running a whole lot faster!

If you're on Linux/Windows/Raspberry-Pi you're probably running the same problem. This is because the people who ship software need to compile it in a way that runs on most machines - which means it's not going be tailored to run best on your particular machine. So the helpful folks at ffmpeg have put together a compilation guide on how to do it yourself.

Thursday, 20 June 2013

Accessing the contents of a Time Capsule disk

So I took my (1st Gen) Time Capsule apart and switched the old 500GB drive for a 3TB drive - which worked in principle. I was impressed that the old thing could handle a 3TB drive ok. The problem that I increasing encountered was that Apple's File Sharing (AFP) server kept crashing - which basically meant my Time Machine stopped working and I had to go and manually switch it on and off every day.

To fix this issue I took the disk out of the Time Capsule and put it into an externally powered USB 3TB capable enclosure so that Time Capsule finally worked reliably again (and no longer crashed). The reason this worked was because the crashing was down to overloading of the power supply (which led to the crashes) in the Time Capsule itself - by moving the disk outside meant that the power to main board of the Time Capsule was now more stable, plus it wasn't getting over heated (which is another problem that besets such small embedded systems).

But along the way when I took the hard drive out of the Time Capsule and tried to look at it on my computer I only found two rather oddly named partitions - APswap APconfig. After searching on the net it seemed there should have been a third partition named Data but it was not showing up?! I was very puzzled as it showed up when inside my Time Capsule. After a lot of faffing about I finally discovered that problem was down to a hardware issue - all the harddrive enclosures I had tried with my drive were not actually capable of reading a 3TB drive - though they were all happy reading a 2TB drive (but quite few enclosures can only read 1Tb or less - so check this if you're having this issue). So I finally managed to find a 3TB capable enclosure and it reads the disk fine and mounts the Data partition (and may be used for external connection of the disk to my Time Capsule so it works as I explained above).

I did also try to mount the disk from Linux but the default filesystem used by the Time Capsule is Apple's HFS+ with journaling enabled used to be not so straightforward to mount. It seems that Linux now mounts hfsplus disks with journaling switched on without a problem (though I'm not clear whether what happens to the jornaling?). On older versions it's also possible to force mount the drive using Linux's hfsplus filesystem driver. It seems that under Lion it's no longer possible to switch off journaling on HFS+ using Disk Utility which is a pain - though I understand that it can be switched off using the diskutil command.

One final thing I tried was set up a Linux box as Time Machine capable network drive. One thing I learned along the way was that Linux's HFS support (i.e. Apple formatted disks) is not rock solid and it would crash when running the backups so I had to change the disk format of my backup drive to use Linux's ext3 filesystem instead (then I could use the ext2/3 fuse filesystem to mount it on OSX). This basically seemed to work on one of my machines, but unfortunately it seemed less reliable on another (It lead to this error message every so often: "Time Machine completed a verification of your backups. To improve reliability, Time Machine must create a new backup for you." - which makes it useless) so I've gone back to using the old Time Capsule with an USB external disk (having removed the internal one which means it no longer crashes).
[updated:9sept13]

Tuesday, 29 January 2013

Using bluetooth audio in Linux

I just spent a while trying to find out how to get my laptop to play audio to a Bluetooth Headset. It seems a lot of the info out there is out of date. Here are some instructions that work with bluez version 4.9X on Ubuntu 12.04.

Firstly make sure you've got the following packages e.g.:
% sudo apt-get install bluez alsa-utils

To do it you need to make sure all the bluetooth kernel modules are loaded - the following command should show the bluetooth modules if they're loaded e.g.:
% lsmod | grep blue
bluetooth 158479  23 bnep,rfcomm,btusb

Then you can check the bluetooth adapter is operational by showing its address info e.g.:
$ hciconfig
hci0:    Type: BR/EDR  Bus: USB
    BD Address: 00:02:7e:16:0D:0a  ACL MTU: 384:8  SCO MTU: 64:8
    UP RUNNING PSCAN ISCAN 
    RX bytes:58444 acl:314 sco:0 events:6846 errors:0
    TX bytes:4821276 acl:17765 sco:0 commands:152 errors:0

Next you need to switch on your headset and put it into discovery mode (e.g. push and hold the power button or something). Then you get your laptop to scan for it e.g.:
% hcitool scan
Scanning ...
    00:0B:E4:9A:15:E4    Nokia BH-214

Then you need to pair with this device as follows - It will ask you for the PIN code for your device (e.g. 0000 or 1111 or something) and then it will add it to the list on your machine (you'll need to replace the bluetooth interface 'hci#' with your one in this part e.g. hci0) e.g.:
% sudo bluez-simple-agent hci# 00:0B:E4:9A:15:E4
RequestPinCode (/org/bluez/9261/hci0/dev_00_0B_E4_9A_15_E4)
Enter PIN Code: 0000
Release
New device (/org/bluez/9261/hci0/dev_00_0B_E4_9A_15_E4)

Now you need to set up the device for use by ALSA sound system - create a file called ~/.asoundrc containing the following (you'll need to replace the bluetooth address with your one in this part) e.g.:
pcm.bluetooth {
   type bluetooth
   device 00:0B:E4:9A:15:E4
}

Finally you can now play audio to your headset:
aplay -D bluetooth myaudio.wav

Or you can select the bluetooth audio device in other audio apps.

Friday, 26 October 2012

Playback/display YUV video file

I was trying to play a YUV file (e.g. the foreman.yuv clip from somewhere like here, or here) - the simplest way seems to be to get mplayer and run it like this (note the -rawvideo option indicates the file format - see mplayer man page for more info):
mplayer foreman.yuv -demuxer rawvideo -rawvideo cif

Or you can use Gstreamer (available for Linux, Windows, and OSX, though there's a problem using autovideosink on the cmd line on the Mac) like this:
gst-launch filesrc location=foreman.yuv ! videoparse width=352 height=288 framerate=25/1 ! ffmpegcolorspace ! autovideosink

You'll obviously need to change the resolution and potentially framerate for different video samples but these work with 'foreman' clip.

BTW if you want to compute the PSNR between two YUV files you can use ffmpeg's tiny_psnr utility like so:
tiny_psnr foreman.yuv foreman-mangled.yuv

Saturday, 20 October 2012

How to change the 'original' date on a JPEG photo

So you've got a photo with a weird date on it - how do you change it? Well on OSX or Linux you can do it the terminal using a handy utility called exif (which you'll need to get from macports or apt):

exif --tag 0x9003 --ifd='EXIF' --set-value='2012:10:17 16:30:37' myphoto.jpg

It will create a new file with the new date called myphoto.jpg.modified.jpg which you can then rename to the original or something else.

There are of course other tools but this one works for me. I'll list others if/when I come across them.

Note: In theory you could use iPhoto on OSX but it is unfortunately buggy - so if you have a date like 1/2/1911 and you try moving it forward with iPhoto then it sets a date earlier in time?!

Thursday, 1 December 2011

Linux traffic Control (tc)

The world of Linux's Traffic control is a mysterious thing - you end up spending hours Googling or days reading source code.

For some nitty gritty on tc see an earlier post of mine on tc rate limiting and pitfalls.

TC Queuing Disciplines (qdisc)

Creating:
E.g Add a tbf qdisc on eth0:
sudo tc qdisc add dev eth0 root tbf rate 10mbit burst 100kb latency 50ms

Listing:
E.g. Show qdiscs on all interfaces:
tc qdisc show

Delete:
E.g. Delete all qdiscs on eth0 interface:
sudo tc qdisc delete dev eth0 root


TC Filters

Creating:
Here's some good info on the u32 filter (here and here). Some more with a quick overview from LARTC mail list (the source of most useful info on tc etc). Someone put together a tc manual.

Listing:
E.g. Show filters on eth0 interface:
sudo tc filter show dev eth0 root

Here's some example output:
filter parent ffff: protocol ip pref 49152 u32

Deleting:
To delete the above example filter (bold section copied from filter show output):
sudo tc filter del dev eth0 parent ffff: protocol ip pref 49152 u32

[updated:17feb12, 5,6jul12,29jan20: more explanations+archive.org link for 1st link as it's gone MIA, link to older article of mine; Added TC qdisc cmds]

Thursday, 21 April 2011

Sorting out clock wierdness on dual boot Windows and OSX/Linux

I just installed Windows 7 on my MacBook and Windows STILL stores the local time in the hardware clock (as opposed to UTC) so when you reboot between the two OSes the time changes - dang! It turns out that there's a secret registry key that gets Windows to behave 'normally' in this respect. You just need to add a new DWORD key, called RealTimeIsUniversal (which should be set to 1), at the following place in the registry (and then reboot to make it take effect):
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation

Here's all the details from a man who knows....

Thursday, 24 February 2011

Hard disc full again?

Yeah even if you've got GigaBytes of it you still seem to run out! Here's a few free tools that are good for visualising used space - using a nice visualisation technique known as treemaps:

Windows: WinDirStat, SequoiaView (a bit old)
Mac OSX: Disk Inventory X, GrandPerspective. (Baobab is available thru darwinpaorts)
Linux: Disk Usage Analyzer (aka Baobab)

There's also plenty of others out there but I've not tried 'em.

Updated: 1jul15

Sunday, 20 February 2011

Using the Linux tbf qdisc for rate limiting on local or loopback interfaces

If you have ever played with the Linux tbf (Token Bucket Filter) on either some local interfaces, or on the loopback interface (lo) then you may have run into problems - like the attained rate is only a few hundred kilobits/s or less (zero)....?
tc qdisc add dev lo root tbf rate 10Mbit burst 10kb latency 5ms 

Basically if your interface has TSO/GSO enabled (check using ethtool -k ethX), or you're using the loopback interface - then you'll probably hit a problem. It turns out that the loopback interface has GSO/TSO enabled as default, plus since it is a software interface its default mtu is 16384 (as compared to 1500 for normal Ethernet interface). This matters as the tbf queue checks the size of the incoming 'packets' - which in the case of GSO/TSO are much larger than a normal on-the-wire packet - instead they're up to 9 x iface's mtu. So for normal interfaces it's about 12K, but for loopback it is about 100k!

In which case you'll need to add the 'mtu' argument to the tc command and then it might work( but check update below in case not):
tc q a dev eth0 root tbf rate 10Mbit burst 10kb latency 5ms mtu 100000
  
Update [29jan20]: It is also important that the burst parameter is greater than the MTU (you will see warnings in dmesg to this effect if your burst size if too small) if running on an interface that has a large MTU like the loopback interface which is now commonly set to 65535 :
tc q a dev eth0 root tbf rate 10Mbit burst 70kb latency 5ms mtu 100000

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]

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;
}

/*

Thursday, 11 November 2010

Too many package managers

On every system someone seems to invent a new package management system which means you've gotta learn the nearly the same thing over and over again. Tedious... Here's some notes to myself about how you can do basic stuff in a few I use (OSX/MacPorts[port], Ubuntu/Debian[aptitude,apt], RedHat/RPM[rpm,yum]).

Install Package
OSX% port install ThatPeskyPackage
ubuntu% aptitude install ThatPeskyPackage
ubuntu% apt-get install ThatPeskyPackage
ubuntu% dpkg -i ThatPeskyPackage.deb
RedHat% yum install ThatPeskyPackage
RedHat% rpm -i ThatPeskyPackage.rpm

Remove Package
OSX% port uninstall ThatPeskyPackage [version]
ubuntu% aptitude remove ThatPeskyPackage
ubuntu% apt-get remove ThatPeskyPackage
RedHat% yum erase ThatPeskyPackage
RedHat% rpm -e ThatPeskyPackage.rpm

Package Info
OSX% port info ThatPeskyPackage
ubuntu% aptitude install ThatPeskyPackage
ubuntu% apt-get install ThatPeskyPackage
RedHat% yum info ThatPeskyPackage
RedHat% rpm -qi ThatPeskyPackage

Package Content: What files did it install?
OSX% port contents ThatPeskyPackage
ubuntu% dpkg -L ThatPeskyPackage
RedHat% rpm -ql ThatPeskyPackage

What package does this file belong to?
OSX% port provides /usr/some/place/weird/whatisthis
ubuntu% dpkg -S /usr/some/place/weird/whatisthis
RedHat% rpm -qf /usr/some/place/weird/whatisthis

Which packages have I got installed?
OSX% port installed
ubuntu% dpkg --get-selections
RedHat% rpm -qa
RedHat% yum list

Tuesday, 9 November 2010

What Linux release am I running?

For every Linux distribution/distro there seems to be a different way to work out which release version/name/codename you're running. Here's a the ways I've found, on the command line, to find out:

Ubuntu
lsb_release -a
cat /etc/lsb-release
cat /etc/debian_version
Note: For Ubuntu /etc/debian_version seems to contain the Debian base from which this version of Ubuntu originates.

Debian
cat /etc/debian_version
cat /etc/lsb-release
lsb_release -a
Note: The latter two are not always available on pure Debian systems.

Redhat/CentOS/Fedora
cat /etc/redhat-release

Gentoo
cat /etc/gentoo-release