Add dup{,2,3}() family of functions

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>