On 10/21/15 9:39 , Garrett D'Amore wrote:
> Changing the “default” globally for illumos is incorrect.  (And yes, its
> quite possible that SmartOS gets this “wrong”, if it uses a USB flash media
> or somesuch.  But I *suspect* the intent is that this is only this way in
> the GZ, where the use of tmp files ought to be rather limited — and that
> instead you should be using the zones pool to host a “real” /var/tmp.  In
> that context, SmartOS *doesn’t* get it wrong, at least IMO.)

Just to clarify, SmartOS is no different from other illumos
distributions as far as I can tell. /tmp in the GZ is from tmpfs and
/var/tmp is from persistent stable storage.

Robert

> On Wed, Oct 21, 2015 at 9:08 AM, Richard PALO <[email protected]> wrote:
> 
>> In digging around as to why /var/tmp is used so much causing a ruckus on
>> my rpool..
>>
>> It turns out that things like gcc use libiberty or similar which operate
>> more or less as the following snippet does:
>>> 115 #ifdef VMS
>>> 116       /* Try VMS standard temp logical.  */
>>> 117       base = try_dir ("/sys$scratch", base);
>>> 118 #else
>>> 119       base = try_dir (getenv ("TMPDIR"), base);
>>> 120       base = try_dir (getenv ("TMP"), base);
>>> 121       base = try_dir (getenv ("TEMP"), base);
>>> 122 #endif
>>> 123
>>> 124 #ifdef P_tmpdir
>>> 125       /* We really want a directory name here as if concatenated
>> with say \d    ir
>>> 126          we do not end up with a double \\ which defines an UNC
>> path.  */
>>> 127       if (strcmp (P_tmpdir, "\\") == 0)
>>> 128         base = try_dir ("\\.", base);
>>> 129       else
>>> 130         base = try_dir (P_tmpdir, base);
>>> 131 #endif
>>> 132
>>> 133       /* Try /var/tmp, /usr/tmp, then /tmp.  */
>>> 134       base = try_dir (vartmp, base);
>>> 135       base = try_dir (usrtmp, base);
>>> 136       base = try_dir (tmp, base);
>>
>> This code has included <stdio.h> which can provide P_tmpdir as follows:
>>> 205 #if defined(__EXTENSIONS__) || \
>>> 206         (!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \
>>> 207         defined(_XOPEN_SOURCE)
>>> 208
>>> 209 #define P_tmpdir        "/var/tmp/"
>>> 210 #endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) ... */
>>
>> some define P_tmpdir (if not already defined) as "/usr/tmp" which, on most
>> modern systems including solaris is a simply a symlink to "/var/tmp"
>>
>> In the end, the problem is that in absence of TMPDIR environment variable
>> being defined, frequently programs will not use the solaris default "/tmp"
>> but "/var/tmp".
>>
>> This can be problematic in the sense that "/tmp", in being typically a
>> tmpfs, doesn't
>> write to disk unless swapping... and then to the defined swap locations.
>> But when /var/tmp is being used, it is generally always to disk (man
>> filesystem(5)):
>>> ...
>>>        /tmp
>>>            Temporary files; cleared during the boot operation.
>>>
>>> ...
>>>        /var/tmp
>>>            Files that vary in size or presence during normal system
>>>            operations. This directory is not cleared during the boot
>>>            operation. An approved installation location for bundled
>> Solaris
>>>            software and for add-on system software and applications.
>>>
>>>            It is possible to change the default behavior for /var/tmp to
>> clear
>>>            all of the files except editor temporary files by setting the
>>>            clean_vartmp property value of the rmtmpfiles service. This
>> is done
>>>            with the following commands:
>>>
>>>              # svccfg -s svc:/system/rmtmpfiles setprop \
>>>                    options/clean_vartmp = "true"
>>>              # svcadm refresh svc:/system/rmtmpfiles:default
>>>
>>>            The solaris.smf.value.rmtmpfiles authorization is required to
>>>            modify this property.
>>
>> Worse, if the root disk rpool is "supposed" to be more or less read-only,
>> and
>> can often even be a poor old usb key or compact flash card not intended to
>> be
>> "abused", it makes for a big surprise when behind your back your compiler
>> doesn't use the memory and additional storage resources system management
>> put into place.
>>
>> Such is the case at hand.
>>
>> Adding now the environment variable TMPDIR=</tmp or something else fast>
>> everywhere
>> is not necessary feasible, so I can't help but wonder if it is not time to
>> change
>> P_tmpdir to "/tmp".
>>
>> Furthermore, mktemp also defaults to "/tmp"
>>
>> So, what eats me is sometimes it defaults to "/tmp", sometimes to
>> "/var/tmp".
>> programatically, something as simple as __EXTENSIONS__ or _XOPEN_SOURCE=600
>> can give you surprises!
>>
>> Also, the gate builds libc with __EXTENSIONS__ so functions such as tmpnam
>> and tempnam
>> generate by default "/var/tmp"!
>>
>> /usr/bin/mktemp doesn't even peek at P_tmpnam but uses "/tmp" unless
>> TMPDIR is assigned.
>>
>> Naturally, anything that can overuse "/tmp" *needs* to be dealt with such
>> as
>> huge files that can quickly fill up the tmpfs.  Normally those
>> "exceptions" are
>> the ones that need intervention by defining TMPDIR.
>>
>> enough ranting now, any other opinions or observations?
>>
>> --
>> Richard PALO
>>
> 
> 


-------------------------------------------
illumos-discuss
Archives: https://www.listbox.com/member/archive/182180/=now
RSS Feed: https://www.listbox.com/member/archive/rss/182180/21175430-2e6923be
Modify Your Subscription: 
https://www.listbox.com/member/?member_id=21175430&id_secret=21175430-6a77cda4
Powered by Listbox: http://www.listbox.com

Reply via email to