nlm: use appropriate open flags while locking

In case of a shared/read lock, open the file in O_RDONLY
mode, and in the case of an exclusive lock, open the file
in O_WRONLY mode to emulate the behaviour posix fcntl
implementation as given in the man pages.

Change-Id: Ib9eab6570c3bc65f8bd48a14a9d801616213b295
BUG: 916930
Signed-off-by: Rajesh Amaravathi <rajesh@redhat.com>
Reviewed-on: http://review.gluster.org/4603
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>