df2: reorg code & add user ioctl