From: millert Date: Sun, 19 Apr 2015 01:10:59 +0000 (+0000) Subject: Don't lock the file for "vi -R" or "view". OK deraadt@ X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=622a37692318a83b9e81e6674180a5cc98a15cfd;p=openbsd Don't lock the file for "vi -R" or "view". OK deraadt@ --- diff --git a/usr.bin/vi/common/exf.c b/usr.bin/vi/common/exf.c index 96b7c35ae43..43d14008859 100644 --- a/usr.bin/vi/common/exf.c +++ b/usr.bin/vi/common/exf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exf.c,v 1.34 2015/03/27 04:11:25 brynet Exp $ */ +/* $OpenBSD: exf.c,v 1.35 2015/04/19 01:10:59 millert Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -333,7 +333,7 @@ file_init(SCR *sp, FREF *frp, char *rcv_name, int flags) * when locking is a little more reliable, this should change to be * an error. */ - if (rcv_name == NULL) + if (rcv_name == NULL && !O_ISSET(sp, O_READONLY)) switch (file_lock(sp, oname, &ep->fcntl_fd, ep->db->fd(ep->db), 0)) { case LOCK_FAILED: @@ -341,10 +341,8 @@ file_init(SCR *sp, FREF *frp, char *rcv_name, int flags) break; case LOCK_UNAVAIL: readonly = 1; - if (!O_ISSET(sp, O_READONLY)) { - msgq_str(sp, M_INFO, oname, - "239|%s already locked, session is read-only"); - } + msgq_str(sp, M_INFO, oname, + "239|%s already locked, session is read-only"); break; case LOCK_SUCCESS: break;