From owner-freebsd-hackers Tue Aug 24 1:35:14 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from not.demophon.com (ns.demophon.com [193.65.70.13]) by hub.freebsd.org (Postfix) with ESMTP id C7A3E14CF3 for ; Tue, 24 Aug 1999 01:35:10 -0700 (PDT) (envelope-from will@not.demophon.com) Received: (from will@localhost) by not.demophon.com (8.9.3/8.8.7) id LAA57436; Tue, 24 Aug 1999 11:34:24 +0300 (EEST) (envelope-from will) To: grog@lemis.com (Greg Lehey) Cc: hackers@freebsd.org Subject: Re: Mandatory locking? References: <19990823223645.A14001@netmonger.net> <19990824131036.B83273@freebie.lemis.com> From: Ville-Pertti Keinonen Date: 24 Aug 1999 11:34:24 +0300 In-Reply-To: grog@lemis.com's message of "24 Aug 1999 06:43:30 +0300" Message-ID: <86r9ktk25r.fsf@not.demophon.com> Lines: 27 X-Mailer: Gnus v5.5/XEmacs 20.4 - "Emerald" Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG grog@lemis.com (Greg Lehey) writes: > an agreement of some kind. But what if I want to merge the contents > of another mail folder: > cat oldmail >>/var/mail/grog > That works, but it's playing with fire: if sendmail is delivering a > message at the same time, it won't see me, and my cat doesn't get a > lock beforehand, so both an incoming message and part of my mail > folder could end up getting written to the same location. With > mandatory locking, it would work, transparently. Certainly not with range-locking rather than file-locking. cat is certainly not guaranteed to be atomic, and while you shouldn't end up writing things in the same location, what might happen unless you are preventing multiple openers is: cat writes part of oldmail to /var/mail/grog sendmail locks /var/mail/grog (cat may try to write more to /var/mail/grog but blocks) sendmail delivers new mail sendmail unlocks /var/mail/grog cat writes the rest of oldmail to /var/mail/grog You'll still probably end up with a broken mailbox. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message