Robocopy: MS power copy tool

Been using robocopy for a while and I thought it would be useful to list a few things it can do:

  1. Delete long directories or filenames:
    robocopy /purge c:\empty [to be deleted directory]
  2. Copy all drive/directories/files without changing any attributes:
    robocopy /copyall /mir /xj [sourcefile] [destination]
  3. Copy all drive/directories/files excluding duplicates:
    robocopy /copyall /mir /xj /xc /xn /xo [sourcefile] [destination]
  4. Copy all drive/directories/files excluding duplicates and skip failed reads/writes instead of retrying infinitely:
    robocopy /copyall /mir /xj /xc /xn /xo /w:1 /r:1 [sourcefile] [destination]

NOTE: The /mir option will delete the destination’s files/directories if they do not exist in source. So if you don’t want that to happen, replace /mir with a /e instead.

OpenWRT: TP-Link routers wifi dropping

TP-Link routers/AP seems to have problem with the OpenWRT firmware with wifi constantly dropping.

A check on system log reveals the error message “disconnected due to excessive missing ACKs”.

To circumvent this problem, edit /etc/config/wireless file and append ‘option disassoc_low_ack 0’.

Update: This problem is fixed in the latest OpenWRT.

Memory Allocator in Linux Kernel

There are three different memory allocator for the Linux kernel – SLAB, SLUB and SLOB. For larger system, Linux kernel uses SLAB until kernel version 2.6.23 and now the default is SLUB. SLOB on the otherhand is for small embedded system.

If you’re compiling any modules and get an undefined reference to malloc_sizes error during linking, it’s very possible that module is old and uses SLAB. Check if that module includes  <linux/slab_def.h> or <linux/slab.h>. The SLAB algorithm defines cache for storage and this cache is represented as extern struct malloc_sizes.

The solution to this is either configure the kernel to use SLAB (CONFIG_SLAB=y) – so you can get the malloc_sizes reference. Or modify your module to use SLUB instead. SLOB is not much of use unless you’re doing embedded system.