From patchwork Tue May 6 11:57:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Scheel X-Patchwork-Id: 4120631 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7EA509F271 for ; Tue, 6 May 2014 11:58:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C7B7C201E4 for ; Tue, 6 May 2014 11:58:20 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id DE85C201DE for ; Tue, 6 May 2014 11:58:19 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 6DB592619F3; Tue, 6 May 2014 13:58:13 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 6B4862610A1; Tue, 6 May 2014 13:58:02 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id C5EBA2610A5; Tue, 6 May 2014 13:58:00 +0200 (CEST) Received: from smtp1.work.de (smtp1.work.de [212.12.40.178]) by alsa0.perex.cz (Postfix) with ESMTP id 992C02608E8 for ; Tue, 6 May 2014 13:57:52 +0200 (CEST) Received: from [127.0.0.1] (helo=avionic-0108.net.jusst.de.) by smtp1.work.de with esmtpa (Exim 4.72) (envelope-from ) id 1Whe0O-0008VO-5S; Tue, 06 May 2014 13:57:52 +0200 From: Julian Scheel To: alsa-devel@alsa-project.org Date: Tue, 6 May 2014 13:57:07 +0200 Message-Id: <1399377427-23907-1-git-send-email-julian@jusst.de> X-Mailer: git-send-email 1.9.2 Cc: Julian Scheel Subject: [alsa-devel] [PATCH] alsactl: Store lockfile in /tmp X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP It can not be generally assumed that the directories in which asound.state resides are writable. Instead using /tmp as location for lock files seems more reliable. Signed-off-by: Julian Scheel --- alsactl/lock.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/alsactl/lock.c b/alsactl/lock.c index 587a109..7ca3a09 100644 --- a/alsactl/lock.c +++ b/alsactl/lock.c @@ -36,17 +36,24 @@ static int state_lock_(const char *file, int lock, int timeout) struct flock lck; struct stat st; char lcktxt[12]; + char *filename; char *nfile; if (!do_lock) return 0; - nfile = malloc(strlen(file) + 6); + + /* only use the actual filename, not the path */ + filename = strrchr(file, '/'); + if (!filename) + filename = file; + + nfile = malloc(strlen(filename) + 10); if (nfile == NULL) { error("No enough memory..."); return -ENOMEM; } - strcpy(nfile, file); - strcat(nfile, ".lock"); + + sprintf(nfile, "/tmp/%s.lock", filename); lck.l_type = lock ? F_WRLCK : F_UNLCK; lck.l_whence = SEEK_SET; lck.l_start = 0;