I have created files in appswriteable folder on mangOH yellow.
But I am not sure How can I access read or write into those files. Can Someone guide. what should be my code structure?
I have created files in appswriteable folder on mangOH yellow.
But I am not sure How can I access read or write into those files. Can Someone guide. what should be my code structure?
you can see this application on how to read/write file inside sandbox application:
//audio playback:
app runProc audioPlaybackRec audioPlaybackRecTest --exe=audioPlaybackRecTest – PB_SAMPLES MIC /usr/share/sounds/0-to-9.wav 1 8000 16
//audio recording
app runProc audioPlaybackRec audioPlaybackRecTest --exe=audioPlaybackRecTest – REC MIC /record/remote.wav WAV
you can also see this:
I have created a app SecStore, below mentioned are automatic folders created under my app.
root@swi-mdm9x28-wp:/legato/systems/current/appsWriteable/SecStore# ls
bin data dev lib tmp
In which folder I should keep my test dummy files, to check read and write operations thorugh app?
You can create a file there and check which folder is containing the new file
I have one simple question
while app installation in mangOH yellow, the directory is created like this. my app name is SecStore
/legato/systems/current/appsWriteable/SecStore/
when I check what all folders are present in SecStore then I see this
bin data dev lib tmp
Is it possible to access any of these folders from SecStore.c code directly by giving “/legato/systems/current/appsWriteable/SecStore/“ path ?
If yes then how to give this path in code becase I am not able to access this path from my source code in Runtime.
please answer this @jyijyi
in case it is use sandbox feature, it will not be having full path
you can try to create a file in /tmp inside your code and see if it appears your application path
#include “legato.h”
#include “le_fs.h”
#include <sys/stat.h>
COMPONENT_INIT
{
// Build the path to tmp/USER inside the app's writable sandbox
char userPath\[256\];
snprintf(userPath, sizeof(userPath),
"%s/tmp",
LE_FS_WRITEABLE_PATH);
// Check if the folder exists
struct stat st;
if (stat(userPath, &st) == 0 && S_ISDIR(st.st_mode))
{
LE_INFO("tmp folder exists at: %s", userPath);
}
else
{
LE_WARN("tmp folder NOT found at: %s", userPath);
}
}
I am only trying to check if tmp folder exists or not while runtime, it is giving me below error.
FAILED: /home/abharati/myWorkspace/_build_SecStore/wp77xx/component/0d8f594f26cb24c9187394c4779da87f/obj/c50f3e85e49a203d4ff5d8b809d1e69e.o
/home/abharati/myWorkspace/leaf-data/WP77_503/wp77-toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc --sysroot=/home/abharati/myWorkspace/leaf-data/WP77_503/wp77-toolchain/sysroots/armv7a-neon-poky-linux-gnueabi -MMD -MF /home/abharati/myWorkspace/_build_SecStore/wp77xx/component/0d8f594f26cb24c9187394c4779da87f/obj/c50f3e85e49a203d4ff5d8b809d1e69e.o.d -Wall -Werror -fvisibility=hidden -c /home/abharati/myWorkspace/Gitlab_Mobildemonstrator/ziel-i4-arbeitsprojekt/App5_Secure_File_System/Provisioner_Component/Provisioner.c -o /home/abharati/myWorkspace/_build_SecStore/wp77xx/component/0d8f594f26cb24c9187394c4779da87f/obj/c50f3e85e49a203d4ff5d8b809d1e69e.o -DLE_FILENAME=basename /home/abharati/myWorkspace/Gitlab_Mobildemonstrator/ziel-i4-arbeitsprojekt/App5_Secure_File_System/Provisioner_Component/Provisioner.c -DMK_TOOLS_BUILD -DLEGATO_EMBEDDED -fPIC -I /home/abharati/myWorkspace/_build_SecStore/wp77xx -I/home/abharati/myWorkspace/leaf-data/WP77_503/wp77-legato/interfaces -I/home/abharati/myWorkspace/leaf-data/WP77_503/wp77-legato/framework/include -I/home/abharati/myWorkspace/leaf-data/WP77_503/wp77-legato/build/wp77xx/framework/include -I/home/abharati/myWorkspace/Gitlab_Mobildemonstrator/ziel-i4-arbeitsprojekt/App5_Secure_File_System -I/home/abharati/myWorkspace/_build_SecStore/wp77xx/component/0d8f594f26cb24c9187394c4779da87f/src -I/home/abharati/myWorkspace/_build_SecStore/wp77xx/api/99d7c76bdd41c0734feca80b816537b7 -I/home/abharati/myWorkspace/_build_SecStore/wp77xx/api/99d7c76bdd41c0734feca80b816537b7 -I/home/abharati/myWorkspace/_build_SecStore/wp77xx/api/99d7c76bdd41c0734feca80b816537b7/client -I/home/abharati/myWorkspace/_build_SecStore/wp77xx/api/99d7c76bdd41c0734feca80b816537b7/client -DLE_COMPONENT_NAME=Provisioner_Component -DLE_LOG_SESSION=Provisioner_Component_LogSession -DLE_LOG_LEVEL_FILTER_PTR=Provisioner_Component_LogLevelFilterPtr
/home/abharati/myWorkspace/Gitlab_Mobildemonstrator/ziel-i4-arbeitsprojekt/App5_Secure_File_System/Provisioner_Component/Provisioner.c: In function ‘_Provisioner_Component_COMPONENT_INIT’:
/home/abharati/myWorkspace/Gitlab_Mobildemonstrator/ziel-i4-arbeitsprojekt/App5_Secure_File_System/Provisioner_Component/Provisioner.c:11:14: error: ‘LE_FS_WRITEABLE_PATH’ undeclared (first use in this function); did you mean ‘LE_FS_CREAT’?
LE_FS_WRITEABLE_PATH);
^~~~~~~~~~~~~~~~~~~~
LE_FS_CREAT
/home/abharati/myWorkspace/Gitlab_Mobildemonstrator/ziel-i4-arbeitsprojekt/App5_Secure_File_System/Provisioner_Component/Provisioner.c:11:14: note: each undeclared identifier is reported only once for each function it appears in
[6/16] Compiling C source
ninja: build stopped: subcommand failed.
You better try with fopen() fwrite() api to create file
or you can see here on how to use legato file system API: