From patchwork Mon Nov 19 19:27:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1000065 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-97358-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="Ijy1H7Dw"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42zJl355g2z9s3C for ; Tue, 20 Nov 2018 06:27:42 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; q=dns; s=default; b=wOu EE2LKeRF7WXyQu8TcObZ/CW0gH4C9uS/YA2N9TixYyAoYhokht9F/Ybvv8PVC37a z02FNkuszFkcu0k2NMFtWrYMSS8U4UwC1DEEwpgvMRLIbEBEEHnc4xTUycnCXwrf bLQq5Qp+nQn4/Ig/lwogC4vshO7DjZlvcuVVtv2k= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; s=default; bh=Kp8CLxIdz Eg4C4X/i7lIQ0RPHgA=; b=Ijy1H7DwCLDqhYbfdaiGBrl8YBN6cpi257tCe9Qcl WBAKGWKy7LzRC0l1qcq0wIzh0btu04rgz7DtAtZ6csQmYZxaUPW7mNIldvjhcE7j RMQBQb0xUsaPrkAGafdZy53T7F9nPJyO+Ea+a+UyY7AKgYLCZVAR4Rsf4TT+LfIe cY= Received: (qmail 114425 invoked by alias); 19 Nov 2018 19:27:36 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 114378 invoked by uid 89); 19 Nov 2018 19:27:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NEUTRAL autolearn=ham version=3.3.2 spammy=H*r:local, HContent-Transfer-Encoding:8bit X-HELO: hera.aquilenet.fr From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd,commited] hurd: Support lockf at offset 0 with size 0 or 1. Date: Mon, 19 Nov 2018 20:27:27 +0100 Message-Id: <20181119192727.5889-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 * sysdeps/mach/hurd/f_setlk.c: Include . (__f_setlk): When whence is SEEK_CUR, use __lseek64 to convert it to SEEK_SET. --- ChangeLog | 6 ++++++ sysdeps/mach/hurd/f_setlk.c | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/ChangeLog b/ChangeLog index fdd7bf3081..bb2824c715 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2018-11-19 Samuel Thibault + + * sysdeps/mach/hurd/f_setlk.c: Include . + (__f_setlk): When whence is SEEK_CUR, use __lseek64 to convert it to + SEEK_SET. + 2018-11-19 Mao Han * scripts/config.guess: Update to version 2018-08-29. diff --git a/sysdeps/mach/hurd/f_setlk.c b/sysdeps/mach/hurd/f_setlk.c index 718af67e32..edfb292dbf 100644 --- a/sysdeps/mach/hurd/f_setlk.c +++ b/sysdeps/mach/hurd/f_setlk.c @@ -19,6 +19,7 @@ #include #include #include +#include #include /* XXX @@ -45,6 +46,18 @@ __f_setlk (int fd, int type, int whence, __off64_t start, __off64_t len, int wai if (cmd != LOCK_UN && wait == 0) cmd |= LOCK_NB; + if (whence == SEEK_CUR) + { + /* In case the target position is 0, we can support it below. */ + __off64_t cur = __lseek64 (fd, 0, SEEK_CUR); + + if (cur >= 0) + { + start = cur + start; + whence = SEEK_SET; + } + } + switch (whence) { case SEEK_SET: