Added parameter checking and safety around filename parameter usage in sys_open().