sysctl: Refactor function parsefile()
Let the caller open the file and pass in the file handler. This can
benefit an upcoming change so that we will have cleaner logic.
No functional change intended.
Suggested by: markj
MFC after: 1 week
(cherry picked from commit 6193855fc76c591ffabe6168cd674e6ec0dafa8e)