# App access to /tmp

**URL:** <https://forum.legato.io/t/app-access-to-tmp/3480>\
**Category:** Legato Application Framework\
**Created:** [July 27, 2018, 4:27am UTC](https://forum.legato.io/t/app-access-to-tmp/3480 "2018-07-27T04:27:51Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidc](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@davidc](https://forum.legato.io/u/davidc)\
**Post date:** [July 27, 2018, 4:27am UTC](https://forum.legato.io/t/app-access-to-tmp/3480/1 "2018-07-27T04:27:51Z")

</div>

Hiya,

Is it possible for an app to get read and write access to the `/tmp` directory to store intermediate and volatile data files?

I’ve tried `require:`'ing the /tmp directory into my app in the adef file - both as sandboxed and unsandboxed.

I’ve also tried simply creating a file in /tmp as an unsandboxed application.

Nether method wrote to the system /tmp directory - they all seemed to create a tmp directory in the application’s /legato/…/appWritable/application/ directory (same place as bin, dev, lib etc are created.

Questions:

1. is it possible for an app to write to the system /tmp area? If so, how?
2. I can’t use the legato created tmp directory as it goes away if the application stops and restarts. Is there any other volatile file storage on the module that an app can write to?

ciao, Dave

---

<div class="post-metadata">

**Author:** ![lotam](https://avatars.discourse-cdn.com/v4/letter/l/958977/32.png) [@lotam](https://forum.legato.io/u/lotam)\
**Post date:** [July 30, 2018, 4:32am UTC](https://forum.legato.io/t/app-access-to-tmp/3480/2 "2018-07-30T04:32:11Z")

</div>

Hi Dave,

May I ask which Legato/product you are using?

In my case, I can read/write to /tmp/test.txt whenever app is not run inside sandbox, as expected I don’t even need to specify in requires section.

Thx

---

<div class="post-metadata">

**Author:** ![davidc](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@davidc](https://forum.legato.io/u/davidc)\
**Post date:** [July 30, 2018, 4:47am UTC](https://forum.legato.io/t/app-access-to-tmp/3480/3 "2018-07-30T04:47:36Z")

</div>

Hi Lotam,

I’ve been testing against a WP7702 with Legato 18.05.1 installed.

I was also somewhat confused about not being able to write to /tmp in an unsandboxed app.

Quite literally, all my code does is the following:

```auto
#include "legato.h"
#include "interfaces.h"	/* include auto-generated api interfaces from Component.cdef */

COMPONENT_INIT
{
    LE_INFO( "tmpDirTest Init: Enter" );

    char template[128] = { 0 };
    int fd = -1;
    
    sprintf(template, "/tmp/mytmpXXXXXX");
    
    if ( -1 == (fd = mkstemp(template)) )
    {
        LE_WARN("mkstemp failed [%d:%m]", errno );
    }
    else
    {
        LE_INFO( "Opened [%s] as fd[%d]", template, fd );
        
        close( fd );
    }

    LE_INFO( "tmpDirTest Init: Exit" );
    
}

```

Can’t be much simpler than this …

But unsandboxed or not, it never creates the file in /tmp … but only in the app local tmp folder.

ciao, Dave

---

<div class="post-metadata">

**Author:** ![lotam](https://avatars.discourse-cdn.com/v4/letter/l/958977/32.png) [@lotam](https://forum.legato.io/u/lotam)\
**Post date:** [July 30, 2018, 7:32am UTC](https://forum.legato.io/t/app-access-to-tmp/3480/4 "2018-07-30T07:32:07Z")

</div>

Hi Dave,

Thanks for the code snippet.  
It works quite well on my WP77 18.05.1 as I marked “sandboxed: false” in .adef.

Below the .adef and test log:

> executables:  
> {  
> helloWorld = ( helloComponent )  
> }
> 
> processes:  
> {  
> envVars:  
> {  
> LE\_LOG\_LEVEL = DEBUG  
> }
> 
> ```
> run:
> {
> ( helloWorld )
> }
> 
> ```
> 
> }  
> sandboxed: false  
> start: manual

Test log:

> root@swi-mdm9x28:~# legato version  
> 18.05.1\_aad562713e05df40ebc4a49c57fa8e97  
> root@swi-mdm9x28:~# ls -l /tmp/  
> drwx-----x 2 root root 120 Jan 6 00:37 legato  
> drwx------ 2 root root 80 Jan 6 00:37 pkgdwl  
> drw-r–r-- 2 root root 60 Jan 6 00:37 psm\_socket  
> srwx------ 1 root root 0 Jan 6 00:37 sock0  
> srwxr-xr-x 1 root root 0 Jan 6 00:37 thermal\_engi\_ipc  
> root@swi-mdm9x28:~# logread -f &  
> root@swi-mdm9x28:~# app start helloWorld  
> root@swi-mdm9x28:~# Jan 6 00:39:25 swi-mdm9x28 user.info Legato: INFO | supervisor[699]/supervisor T=main | app.c app\_Create() 2716 | Creating app ‘helloWorld’  
> Jan 6 00:39:25 swi-mdm9x28 user.info Legato: INFO | supervisor[699]/supervisor T=main | proc.c GetFaultAction() 323 | No fault action specified for process ‘helloWorld’. Assuming ‘ignore’.  
> Jan 6 00:39:25 swi-mdm9x28 user.warn Legato: -WRN- | supervisor[699]/supervisor T=main | proc.c GetWatchdogAction() 359 | helloWorld watchdogAction ‘’ in proc section  
> Jan 6 00:39:25 swi-mdm9x28 user.warn Legato: -WRN- | supervisor[699]/supervisor T=main | proc.c GetWatchdogAction() 359 | helloWorld watchdogAction ‘’ in proc section  
> Jan 6 00:39:25 swi-mdm9x28 user.info Legato: INFO | supervisor[699]/supervisor T=main | app.c CreateFileLink() 1605 | Created file link ‘/legato/systems/current/apps/helloWorld/read-only/lib/libComponent\_helloComponent.so’ to '/legato/systems/current/appsWriteable/helloW  
> Jan 6 00:39:25 swi-mdm9x28 user.info Legato: INFO | supervisor[699]/supervisor T=main | app.c CreateFileLink() 1605 | Created file link ‘/legato/systems/current/apps/helloWorld/read-only/bin/helloWorld’ to ‘/legato/systems/current/appsWriteable/helloWorld/bin/helloWorld’  
> Jan 6 00:39:25 swi-mdm9x28 user.info Legato: INFO | supervisor[699]/supervisor T=main | app.c app\_Start() 2915 | Starting app ‘helloWorld’  
> Jan 6 00:39:25 swi-mdm9x28 user.info Legato: INFO | supervisor[699]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxCoreDumpFileBytes to value 102400.  
> Jan 6 00:39:25 swi-mdm9x28 user.info Legato: INFO | supervisor[699]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxFileBytes to value 102400.  
> Jan 6 00:39:25 swi-mdm9x28 user.info Legato: INFO | supervisor[699]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxLockedMemoryBytes to value 8192.  
> Jan 6 00:39:25 swi-mdm9x28 user.info Legato: INFO | supervisor[699]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxFileDescriptors to value 256.  
> Jan 6 00:39:25 swi-mdm9x28 user.info Legato: INFO | supervisor[699]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxMQueueBytes to value 512.  
> Jan 6 00:39:25 swi-mdm9x28 user.info Legato: INFO | supervisor[699]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxThreads to value 20.  
> Jan 6 00:39:25 swi-mdm9x28 user.info Legato: INFO | supervisor[699]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxQueuedSignals to value 100.  
> Jan 6 00:39:25 swi-mdm9x28 user.info Legato: INFO | supervisor[699]/supervisor T=main | proc.c proc\_Start() 1389 | Starting process ‘helloWorld’ with pid 1701  
> Jan 6 00:39:25 swi-mdm9x28 user.info Legato: INFO | supervisor[699]/supervisor T=main | supervisor.c SigChildHandler() 783 | Reaping unconfigured child process 1700.  
> Jan 6 00:39:25 swi-mdm9x28 user.info Legato: INFO | supervisor[1701]/supervisor T=main | proc.c proc\_Start() 1354 | Execing ‘helloWorld’  
> Jan 6 00:39:25 swi-mdm9x28 user.debug Legato: DBUG | _UNKNOWN_[1701]/framework T=unknown | LE\_FILENAME InitPool() 303 | Memory pool name ‘framework.hashMap\_refPathIteratorMap’ is truncated to ‘framework.hashMap\_refPathIterat’  
> Jan 6 00:39:25 swi-mdm9x28 user.debug Legato: DBUG | _UNKNOWN_[1701]/framework T=main | LE\_FILENAME InitPool() 303 | Memory pool name ‘framework.hashMap\_refEventHandlers’ is truncated to ‘framework.hashMap\_refEventHandl’  
> Jan 6 00:39:25 swi-mdm9x28 user.debug Legato: DBUG | _UNKNOWN_[1701]/framework T=main | LE\_FILENAME InitPool() 303 | Memory pool name ‘framework.hashMap\_refDefault Timer SafeRe’ is truncated to ‘framework.hashMap\_refDefault Ti’  
> Jan 6 00:39:25 swi-mdm9x28 user.debug Legato: DBUG | _UNKNOWN_[1701]/framework T=main | LE\_FILENAME InitPool() 303 | Memory pool name ‘framework.MessagingClientInterfaces’ is truncated to ‘framework.MessagingClientInterf’  
> Jan 6 00:39:25 swi-mdm9x28 user.debug Legato: DBUG | _UNKNOWN_[1701]/framework T=main | LE\_FILENAME InitPool() 303 | Memory pool name ‘framework.hashMap\_refHandlersRef’ is truncated to ‘framework.hashMap\_refHandlersRe’  
> Jan 6 00:39:25 swi-mdm9x28 user.debug Legato: DBUG | _UNKNOWN_[1701]/framework T=main | LE\_FILENAME InitPool() 303 | Memory pool name ‘framework.hashMap\_MessagingServices’ is truncated to ‘framework.hashMap\_MessagingServ’  
> Jan 6 00:39:25 swi-mdm9x28 user.debug Legato: DBUG | _UNKNOWN_[1701]/framework T=main | LE\_FILENAME InitPool() 303 | Memory pool name ‘framework.hashMap\_MessagingClients’ is truncated to ‘framework.hashMap\_MessagingClie’  
> Jan 6 00:39:25 swi-mdm9x28 user.debug Legato: DBUG | _UNKNOWN_[1701]/framework T=main | LE\_FILENAME InitPool() 303 | Memory pool name ‘framework.PipelineSIGCHLD-reports’ is truncated to ‘framework.PipelineSIGCHLD-repor’  
> Jan 6 00:39:25 swi-mdm9x28 user.debug Legato: DBUG | _UNKNOWN_[1701]/framework T=main | LE\_FILENAME fs\_Init() 838 | FS prefix path “/data/le\_fs/”  
> Jan 6 00:39:25 swi-mdm9x28 user.debug Legato: DBUG | _UNKNOWN_[1701]/framework T=main | LE\_FILENAME InitPool() 303 | Memory pool name ‘framework.hashMap\_refFsFileRefMap’ is truncated to ‘framework.hashMap\_refFsFileRefM’  
> Jan 6 00:39:25 swi-mdm9x28 user.debug Legato: DBUG | _UNKNOWN_[1701]/framework T=main | LE\_FILENAME le\_mem\_ForceAlloc() 841 | Memory pool ‘framework.DestructorObjs’ overflowed. Expanded to 1 blocks.  
> Jan 6 00:39:25 swi-mdm9x28 user.debug Legato: DBUG | _UNKNOWN_[1701]/ T=main | \_componentMain.c \_helloComponent\_Init() 26 | Initializing helloComponent component library.  
> Jan 6 00:39:25 swi-mdm9x28 user.debug Legato: DBUG | helloWorld[1701]/framework T=main | LE\_FILENAME InitPool() 303 | Memory pool name ‘framework.msgs-LogControlProtocol’ is truncated to ‘framework.msgs-LogControlProtoc’  
> Jan 6 00:39:25 swi-mdm9x28 user.debug Legato: DBUG | helloWorld[1701]/framework T=main | LE\_FILENAME le\_mem\_ForceAlloc() 841 | Memory pool ‘framework.SigMonitor’ overflowed. Expanded to 1 blocks.  
> Jan 6 00:39:25 swi-mdm9x28 user.debug Legato: DBUG | helloWorld[1701]/framework T=main | LE\_FILENAME le\_mem\_ForceAlloc() 841 | Memory pool ‘framework.SigHandler’ overflowed. Expanded to 1 blocks.  
> Jan 6 00:39:25 swi-mdm9x28 user.debug Legato: DBUG | helloWorld[1701]/helloWorld\_exe T=main | \_main.c main() 60 | == Starting Event Processing Loop ==  
> Jan 6 00:39:25 swi-mdm9x28 user.info Legato: INFO | helloWorld[1701]/helloComponent T=main | helloWorld.c \_helloComponent\_COMPONENT\_INIT() 7 | tmpDirTest Init: Enter  
> Jan 6 00:39:25 swi-mdm9x28 user.info Legato: INFO | helloWorld[1701]/helloComponent T=main | helloWorld.c \_helloComponent\_COMPONENT\_INIT() 20 | Opened [/tmp/mytmpkvmjRv] as fd[8]  
> Jan 6 00:39:25 swi-mdm9x28 user.info Legato: INFO | helloWorld[1701]/helloComponent T=main | helloWorld.c \_helloComponent\_COMPONENT\_INIT() 25 | tmpDirTest Init: Exit
> 
> root@swi-mdm9x28:~# ls -l /tmp  
> drwx-----x 2 root root 120 Jan 6 00:37 legato  
> -rw------- 1 root root 0 Jan 6 00:39 mytmpkvmjRv  
> drwx------ 2 root root 80 Jan 6 00:37 pkgdwl  
> drw-r–r-- 2 root root 60 Jan 6 00:37 psm\_socket  
> srwx------ 1 root root 0 Jan 6 00:37 sock0  
> srwxr-xr-x 1 root root 0 Jan 6 00:37 thermal\_engi\_ipc  
> -rw-r–r-- 1 root root 534 Jan 6 00:39 tmpfdbtable.txt  
> root@swi-mdm9x28:~#

---

<div class="post-metadata">

**Author:** ![HudriWudri](https://avatars.discourse-cdn.com/v4/letter/h/a6a055/32.png) [@HudriWudri](https://forum.legato.io/u/HudriWudri)\
**Post date:** [March 2, 2023, 3:50pm UTC](https://forum.legato.io/t/app-access-to-tmp/3480/5 "2023-03-02T15:50:57Z")

</div>

Hi, I’m having the same issue with sandboxed apps. If the app is not sandboxed the access to /tmp is no problem, but a sandboxed app cannot open the required file in read mode.

In the .adef

```auto
requires:
{
    dir:
    {
        /tmp /tmp
        /proc /proc
        /home /home
    }

    file:
    {
    }
}

```

In the component:

```auto
FILE *fp = fopen("/tmp/alive", "r");

```

I can see that the file exists and the content is right. However, the file-pointer is NULL.

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [March 2, 2023, 4:45pm UTC](https://forum.legato.io/t/app-access-to-tmp/3480/6 "2023-03-02T16:45:46Z")

</div>

you can see here:

> [@Opening Files in Sandboxed App](https://forum.legato.io/t/opening-files-in-sandboxed-app/5525/3):
>
> I read through it and tried changing the permissions, but i still can’t even read the file. Do i need to add something else except requires: { file: { /tmp/test.txt /tmp/ } } in order to read it?

---

<div class="post-metadata">

**Author:** ![HudriWudri](https://avatars.discourse-cdn.com/v4/letter/h/a6a055/32.png) [@HudriWudri](https://forum.legato.io/u/HudriWudri)\
**Post date:** [March 3, 2023, 5:52am UTC](https://forum.legato.io/t/app-access-to-tmp/3480/7 "2023-03-03T05:52:07Z")

</div>

Unfortunatelly, that doesn’t work, because /tmp/alive does not exist when the app tries to start and therefore, the _requires_ condition is not fulfilled which means that the whole app cannot start properly. So I don’t even get to the point where _fopen_ is called. Also, after the file has been created by the other app and the app which wants to read the file is restarted, the _fopen_ command still returns null. Please try it in one of your test applications if you can access a file in _/tmp_ from a sandboxed app.

```auto
requires:
{
    dir:
    {
        /proc /proc
        /home /home
    }

    file:
    {
        /tmp/alive /tmp/alive
    }
}

```

```auto
FILE *fp = fopen("/tmp/alive", "rw+");

```

I don’t understand why it’s not possible to just map the whole directory. That should be no problem but for some reason it seems to be. At least with _/tmp._

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [March 3, 2023, 6:42am UTC](https://forum.legato.io/t/app-access-to-tmp/3480/8 "2023-03-03T06:42:01Z")

</div>

you can create the file in the init script:

> [@Adding scripts to run at startup](https://forum.legato.io/t/adding-scripts-to-run-at-startup/2412/7):
>
> I just tried on WP76 R9, I found that modifying mount\_early is not working. Instead I modify /etc/init.d/startlegato.sh, and I can add my command there. case “$1” in start) echo “Legato start sequence 123” echo 123 \> /tmp/123.txt You can have a try there.

---

<div class="post-metadata">

**Author:** ![HudriWudri](https://avatars.discourse-cdn.com/v4/letter/h/a6a055/32.png) [@HudriWudri](https://forum.legato.io/u/HudriWudri)\
**Post date:** [March 3, 2023, 6:58am UTC](https://forum.legato.io/t/app-access-to-tmp/3480/9 "2023-03-03T06:58:45Z")

</div>

Can startlegato.sh be included into the package that is being installed via _/legato/systems/current/bin/update_? Because we don’t want to have to add specific files manually to the device. Also this wouldn’t solve the problem, that the file can obviously not be read.

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [March 3, 2023, 7:14am UTC](https://forum.legato.io/t/app-access-to-tmp/3480/10 "2023-03-03T07:14:54Z")

</div>

modified startlegato.sh should be stored in /mnt/flash/ufs/etc/init.d/startlegato.sh

then why don’t you add an unsandboxed application to create the file during each power on?

---

<div class="post-metadata">

**Author:** ![HudriWudri](https://avatars.discourse-cdn.com/v4/letter/h/a6a055/32.png) [@HudriWudri](https://forum.legato.io/u/HudriWudri)\
**Post date:** [March 3, 2023, 7:16am UTC](https://forum.legato.io/t/app-access-to-tmp/3480/11 "2023-03-03T07:16:02Z")

</div>

We already have this kind of process. The file however, as mentioned above, cannot be accessed in read-mode for some reason. Please try it in one of your test apps. Maybe I’m doing something wrong or missed something that prevents me from accessing the file from a sandboxed app. Because I just tried it with an unsandboxed app, which works perfectly fine.

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [March 3, 2023, 8:32am UTC](https://forum.legato.io/t/app-access-to-tmp/3480/12 "2023-03-03T08:32:14Z")

</div>

I found that you must manually enter these commands in the console instead of using unsandboxed legato app to create it:

```auto
echo hello_everybody > /tmp/hello.txt
chmod o+w /tmp/hello.txt
xattr set 'security.SMACK64' 'app.hello7rwx' /tmp/hello.txt
app start hello7

```

Or you can choose to use unsandboxed app to access the files outside

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [March 3, 2023, 8:41am UTC](https://forum.legato.io/t/app-access-to-tmp/3480/13 "2023-03-03T08:41:50Z")

</div>

you can do this which is working on my side:

1. edit /etc/init.d/startlegato.sh

```auto
case "$1" in
start)
echo "Legato start sequence 123"

echo hello_everybody > /tmp/hello.txt

```

1. create a hello1 unsandboxed app to change the attribute:

```auto
system("chmod o+w /tmp/hello.txt");
system("/mnt/legato/system/bin/xattr set 'security.SMACK64' 'app.hello7rwx' /tmp/hello.txt");

```

1. create another hello7 sandboxed app to read the /tmp/hello.txt

---

<div class="post-metadata">

**Author:** ![HudriWudri](https://avatars.discourse-cdn.com/v4/letter/h/a6a055/32.png) [@HudriWudri](https://forum.legato.io/u/HudriWudri)\
**Post date:** [March 3, 2023, 9:46am UTC](https://forum.legato.io/t/app-access-to-tmp/3480/14 "2023-03-03T09:46:57Z")

</div>

I tried this, but it still doesn’t work. _fopen_ still keeps returning NULL. Weird.

Unsandboxed app:

```c
/* Write alive file */
FILE *fp = fopen("/tmp/alive", "w");
if (fp)
{
    system("chmod o+w /tmp/alive");
    system("chmod o+r /tmp/alive");
    system("/mnt/legato/system/bin/xattr set 'security.SMACK64' 'app.Health' /tmp/alive");
    fputc((currentNrAppsAlive == NR_APPS) ? IPC_VALUE_APPS_ALIVE_OK : IPC_VALUE_APPS_ALIVE_NOK, fp);
    fclose(fp);
}

```

Sandboxed Health app:

```c
FILE *fp = fopen("/tmp/alive", "r");

```

Health app .adef:

```auto
requires:
{
    dir:
    {
        /proc /proc
        /home /home
    }

    file:
    {
        /tmp/alive /tmp/alive
    }
}

```

![image](https://us1.discourse-cdn.com/flex019/uploads/legato1/original/2X/9/92a5abbebf541e3c5018269c64bdfc106ea07523.png)

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [March 3, 2023, 9:49am UTC](https://forum.legato.io/t/app-access-to-tmp/3480/15 "2023-03-03T09:49:01Z")

</div>

as said before, you cannot create the file with any unsandboxed app if you want sandboxed app to access it

---

<div class="post-metadata">

**Author:** ![HudriWudri](https://avatars.discourse-cdn.com/v4/letter/h/a6a055/32.png) [@HudriWudri](https://forum.legato.io/u/HudriWudri)\
**Post date:** [March 3, 2023, 10:43am UTC](https://forum.legato.io/t/app-access-to-tmp/3480/16 "2023-03-03T10:43:52Z")

</div>

Yes you can. You just can’t in the _/tmp_ directory. Just tried it with _/home/root_ which works fine. Alright, then I will just use the home directory.

To wrap it up (if someone comes back to this thread).

- The _start_ attribute of the app which requires a specific file is set to _manual_ in the .adef file.
- The file is mapped into the sandboxed application within the _.adef_ file (e.g. [rw] /tmp/alive /).
- An unsandboxed app writes the file on startup and starts the application which requires the file (le\_appCtrl\_Start).
- Everyone is happy that it works somehow.

Thanks for your support.

* * *

FYI:

```auto
requires:
{
    dir:
    {
        /proc /proc
        /home /home
    }

    file:
    {
        [rw] /tmp/alive /
    }
}

```

Throws the following error: **“Cannot set access permission of: /tmp/alive”** , while **[rw] /home/root/alive /** works as intended.

* * *

Please mark this post as solution, if you agree.

---

<div class="post-metadata">

**Author:** ![davidc](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@davidc](https://forum.legato.io/u/davidc)\
**Post date:** [March 3, 2023, 11:20pm UTC](https://forum.legato.io/t/app-access-to-tmp/3480/17 "2023-03-03T23:20:14Z")

</div>

Hiya,

Just a quick note about using /home as opposed to /tmp.

Don’t forget that /tmp is a volatile partition - constructed in RAM each time the module boots, so (a) anything that’s put there probably won’t survive a cold boot; & (b) As it’s in RAM you have an effectively infinite erase/write cycles.

/home on the other hand is in flash - on the up side the data is persistent across reboots; on the down side you’ve got a limited number or erase/write cycles so if you’re using the file for rapid temporary storage purposes then you run the risk of wearing out the flash.

Another quiet issue I’ve run into previously - don’t let a flash partition fill up completely. There (used to be - haven’t checked recently) a sneaky little bug in the flash file system where the file system required at least one unused block to allow erasing of files (because of the way the file system did a read - modify - write when deleting data). Sadly, the file system didn’t automatically reserve a flash block for this purpose so you could fill up the flash and then not be able to erase it without a low level format of the entire partition.

ciao, Dave

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [March 4, 2023, 4:37am UTC](https://forum.legato.io/t/app-access-to-tmp/3480/18 "2023-03-04T04:37:52Z")

</div>

On my side, if I change the unsandboxed application to create a file in /tmp, and then create another symbolic link in /home/root to this file, then the sandboxed application can still access this symbolic link.

```auto
	system("echo hello_everybody > /tmp/hello.txt");
	system("ln -s /tmp/hello.txt /home/root/hello.txt");
	system("chmod o+w /home/root/hello.txt");
	system("/mnt/legato/system/bin/xattr set 'security.SMACK64' 'app.hello7rwx' /home/root/hello.txt");

```

So it seems we can still create the file in /tmp folder and use sandboxed application to access it.

hello7.adef:

```auto

sandboxed:true
start: manual
requires:
{
   
    file:
	{
		
	[rw] /home/root/hello.txt /
	
	}
}

```

---

<div class="post-metadata">

**Author:** ![HudriWudri](https://avatars.discourse-cdn.com/v4/letter/h/a6a055/32.png) [@HudriWudri](https://forum.legato.io/u/HudriWudri)\
**Post date:** [March 6, 2023, 5:53am UTC](https://forum.legato.io/t/app-access-to-tmp/3480/19 "2023-03-06T05:53:13Z")

</div>

Hey davidc,

thanks for the follow-up. Yes, that was the purpose, the file should be deleted each time the device is rebootet. However, the flash’s write-erase cycles are a good point to consider. I’ll try to either reduce the write cycles or, as jyijyi mentioned, try to use a symbolic link to the file.

BR  
Hudri
