# Le\_fs\_\* seems broken

**URL:** <https://mangoh.discourse.group/t/le-fs-seems-broken/5296>\
**Category:** mangOH Red\
**Created:** [September 24, 2020, 11:58pm UTC](https://mangoh.discourse.group/t/le-fs-seems-broken/5296 "2020-09-24T23:58:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![CT1](https://avatars.discourse-cdn.com/v4/letter/c/f6c823/32.png) [@CT1](https://mangoh.discourse.group/u/CT1)\
**Post date:** [September 24, 2020, 11:58pm UTC](https://mangoh.discourse.group/t/le-fs-seems-broken/5296/1 "2020-09-24T23:58:56Z")

</div>

So instead of using the standard linux _open(), write(), close()_ we have to use le\_fs\_Open(), le\_fs\_Write(), le\_fs\_Close().

They aren’t working though. le\_fs\_Open() will return a file descriptor, but write will not write to files. I’ve given my application permission to access the parent directories in the .adef. Any help is appreciated.

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [September 25, 2020, 12:05am UTC](https://mangoh.discourse.group/t/le-fs-seems-broken/5296/2 "2020-09-25T00:05:29Z")

</div>

Why don’t you use standard linux api if it is working fine?

---

<div class="post-metadata">

**Author:** ![CT1](https://avatars.discourse-cdn.com/v4/letter/c/f6c823/32.png) [@CT1](https://mangoh.discourse.group/u/CT1)\
**Post date:** [September 25, 2020, 12:09am UTC](https://mangoh.discourse.group/t/le-fs-seems-broken/5296/3 "2020-09-25T00:09:19Z")

</div>

Standard linux calls aren’t working. R13, legato 19.11.2 and 20.04.0

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [September 25, 2020, 12:11am UTC](https://mangoh.discourse.group/t/le-fs-seems-broken/5296/4 "2020-09-25T00:11:53Z")

</div>

How about fopen(), fread() ???

---

<div class="post-metadata">

**Author:** ![CT1](https://avatars.discourse-cdn.com/v4/letter/c/f6c823/32.png) [@CT1](https://mangoh.discourse.group/u/CT1)\
**Post date:** [September 25, 2020, 12:22am UTC](https://mangoh.discourse.group/t/le-fs-seems-broken/5296/5 "2020-09-25T00:22:18Z")

</div>

I rewrote with fopen(), and it fails.

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [September 25, 2020, 12:28am UTC](https://mangoh.discourse.group/t/le-fs-seems-broken/5296/6 "2020-09-25T00:28:18Z")

</div>

Other user does not find problem, you can have a look here:

> [@Write value in mangOH /sys files](https://mangoh.discourse.group/t/write-value-in-mangoh-sys-files/4717/6):
>
> Blockquote When using unsandboxed application, you need to specify the full path when fopen() . I did that, but i had the same error (Bad file descriptor). But I tried (in unsandboxed mode) to use open instead of fopen and write instead of fprintf and it worked ! If anyone is interested, here is my code: #include "interfaces.h" #include "legato.h" #include \<errno.h\> #include \<unistd.h\> #include \<fcntl.h\> #include \<string.h\> COMPONENT\_INIT { int rc; int fp = open("/sys/bus/i2c/devi…

---

<div class="post-metadata">

**Author:** ![pinst](https://avatars.discourse-cdn.com/v4/letter/p/d78d45/32.png) [@pinst](https://mangoh.discourse.group/u/pinst)\
**Post date:** [September 25, 2020, 7:48pm UTC](https://mangoh.discourse.group/t/le-fs-seems-broken/5296/7 "2020-09-25T19:48:33Z")

</div>

open(), etc. are working for me.  
Firmware Version: SWI9X06Y\_02.35.02.00 5208b3 jenkins 2020/06/10 00:30:12.  
Legato Version: 19.11.2\_625c7d1acfd1ca45b2dbe189b4cb1ce7\_modified

---

<div class="post-metadata">

**Author:** ![jchitty](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jchitty/32/846_2.png) [@jchitty](https://mangoh.discourse.group/u/jchitty)\
**Post date:** [October 2, 2020, 7:11pm UTC](https://mangoh.discourse.group/t/le-fs-seems-broken/5296/8 "2020-10-02T19:11:44Z")

</div>

If your application is sandboxed, you won’t have access to much of the file system. If you unsandbox your application (by adding a line “`sandboxed: false`” to your `.adef` file), then you’ll have access to all of the file system. It doesn’t matter whether you use `fopen()` or `open()`. They should both work.

Of course, it’s better to run sandboxed. There are some features in the `Component.cdef` and `.adef` files that allow you to remain sandboxed but still have access to certain files in the root file system (see `requires:`). Sometimes that can not work as expected, though, because the file must exist when your app starts, and some files, like `/etc/resolv.conf` may get created later, or deleted and re-created as things happen at run time.

Another option is to build a small, simple, unsandboxed app that does the file system access and exports an application specific API for use by your main application code, which remains sandboxed.

I hope this helps.

–Jen
