Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jaroslav Kysela <perex@perex.cz>
To: Julian Scheel <julian@jusst.de>, alsa-devel@alsa-project.org
Subject: Re: [PATCH] alsactl: Store lockfile in /tmp
Date: Tue, 06 May 2014 16:55:43 +0200	[thread overview]
Message-ID: <5368F7EF.1020300@perex.cz> (raw)
In-Reply-To: <5368F74C.1020907@perex.cz>

Date 6.5.2014 16:53, Jaroslav Kysela wrote:
> Date 6.5.2014 13:57, Julian Scheel wrote:
>> 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.
> 
> Apart the missing free for the mallocated string and ommiting the TMPDIR

I'm sorry, the filename variable is not mallocated, forget this part,
please.

> environment variable, I think that the right directory for global locks
> is /var/lock . The default asound.state directory is now /var/lib/alsa -
> I don't see the benefit.
> 
> What's the reason for this change? Perhaps using an environmental
> variable to override the lock path may be more appropriate for a custom
> directory structure.
> 
>                                    Jaroslav
> 
>>
>> Signed-off-by: Julian Scheel <julian@jusst.de>
>> ---
>>  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;
>>
> 
> 


-- 
Jaroslav Kysela <perex@perex.cz>
Linux Kernel Sound Maintainer
ALSA Project; Red Hat, Inc.

  reply	other threads:[~2014-05-06 14:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-06 11:57 [PATCH] alsactl: Store lockfile in /tmp Julian Scheel
2014-05-06 14:53 ` Jaroslav Kysela
2014-05-06 14:55   ` Jaroslav Kysela [this message]
2014-05-06 15:00   ` Julian Scheel
2014-05-06 16:44     ` Takashi Iwai
2014-05-06 15:05   ` Takashi Iwai
2014-05-06 18:55     ` Julian Scheel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5368F7EF.1020300@perex.cz \
    --to=perex@perex.cz \
    --cc=alsa-devel@alsa-project.org \
    --cc=julian@jusst.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox