Monday, 10 September 2012

NFSv4 on Virtual Box VMs

Setting up NFSv4 mounts from the host (server) to the VirtualBox VM (client): You can't use the normal NAT network - you'll get "Operation not permitted". Setup a host-only network, and configure those devices on the host and vms. That allows the connection to proceed to the next point.

Thursday, 3 May 2012

Locations in Ubuntu datetime indicator

Ubuntu datetime indicator is a right pain to add extra timezones to.
The Locations... seems to be very poor when you try to add a new location at determining locations' full entry.
As an alternative you can add them to the configuration directly.
  • First install dconf-editor.
  • Open dconf-editor.
  • Navigate to con/canonical/indicator/datetime and edit the locations item with the locations you want.
Valid locations:
  • America/Vancouver Vancouver
  • Australia/Sydney Sydney
  • Pacific/Auckland Auckland
  • Asia/Tokyo Tokyo
  • America/Toronto Ottawa

Wednesday, 7 March 2012

Programmatically find out if a file is sparse

You can work out if a file is sparse using stat (or fstat etc).

    struct stat statbuf;
    int ret = ::stat(tmp, &tatbuf);
    ASSERT_NE(ret, -1);

    // statbuf.st_size - virtual size in bytes
    // statbuf.st_blocks - physical size in 512-byte blocks
So if st_blocks * 512 < st.size then you definitely have a sparse file.