Re: [LTP] [PATCH]mktemp command in runltp version issue

Garrett Cooper
2010-09-09T16:19:01Z

On Thu, Sep 9, 2010 at 1:08 AM, lina.zhao <lina.zhao@windriver.com> wrote:
> but $TMPDIR may not be defined in the environment, so we need --tmpdir / -p
> to specify the directory

export TMPDIR=$TMP

Done.

> -p is support on most of versions.

The key word you used there is `most'. We need to support all logical
versions of mktemp, which means that it needs to work for about all of
them (I don't care about package versions from back in the kernel
2.4.x days too terribly much, and the other earlier versions, i.e.
2.2, etc, are a non-issue).

> mnt_pnt=`mktemp -d $TMP/mnt_pnt.XXXXXX` doesn't work well
>
> lina@lina-desktop:~$  export TMP=/home/lina/tmp/
> lina@lina-desktop:~$ mktemp -d $TMP/mnt_pnt.XXXXXX
> /home/lina/tmp//mnt_pnt.i12144
> lina@lina-desktop:~$ mktemp -d -p $TMP mnt_pnt.XXXXXX
> /home/lina/tmp/mnt_pnt.Q12146
>
> if $TMP include / in end, then there will be 2 // for the temp file

So... what's the issue if there are 2 or more slashes? FWIW that issue
is extremely easy to work around anyhow...

TMP=`dirname $TMP/GARBAGE`

(GARBAGE is required so that it maintains the desired contents in $TMP)

>> On Sep 8, 2010, at 11:22 PM, lina.zhao wrote:
>>
>>> Hi,
>>>
>>> In runltp:
>>>
>>> if [ -n "$DEVICE" ]; then
>>>     mnt_pnt=`mktemp -d --tmpdir=${TMP} mnt_pnt.XXXXXX`
>>>
>>> --tmpdir is a invalid option for mktemp version 1.5, which is used
>>> widely. The valid option to specify a directory for version 1.5 is
>>> -p directory.
>>
>> Or just remove --tmpdir=<blah> altogether? If $TMPDIR is defined in the
>> environment, then it is the fallback if --tmpdir / -p isn't specified
>> (please see the manpage for more details)... OR... just do:
>>
>> mnt_pnt=`mktemp -d $TMP/mnt_pnt.XXXXXX`
>>
>> The same change will probably need to be applied to the runltp lite
>> script.

Simple universal solutions are what I seek :). See if either of the
two suggestions I provided above meets your approval (and FWIW if we
change TMP to TMPDIR, stuff might start working a lot better in LTP
because TMPDIR is the standard variable used for mktemp, not $TMP, etc
that we define in the environment).

Cheers,
-Garrett