mem: add internal API to get and set segment fd