validate parameters for share count/numbers

Returns nonzero with errno == EINVAL if something incorrect is given.