Simple interface for Mbed Cloud Client
Embed:
(wiki syntax)
Show/hide line numbers
FileSystemInit.c
00001 /******************************************************************************* 00002 * Copyright 2016, 2017 ARM Ltd. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 *******************************************************************************/ 00016 #include "pal.h" 00017 #include <errno.h> 00018 #include <sys/stat.h> 00019 #include <sys/types.h> 00020 #include <stdio.h> 00021 00022 00023 #ifndef PRIMARY_PARTITION_NAME 00024 #define PRIMARY_PARTITION_NAME "/dev/mmcblk0p3" 00025 #endif 00026 00027 #ifndef SECONDARY_PARTITION_NAME 00028 #define SECONDARY_PARTITION_NAME "/dev/mmcblk0p4" 00029 #endif 00030 00031 #ifndef PAL_PARTITION_FORMAT_TYPE 00032 #define PAL_PARTITION_FORMAT_TYPE "ext4" 00033 #endif 00034 00035 #ifndef PARTITION_FORMAT_ADDITIONAL_PARAMS 00036 #define PARTITION_FORMAT_ADDITIONAL_PARAMS NULL 00037 #endif 00038 00039 bool FileSystemInit = true; 00040 00041 // Desktop Linux 00042 // In order for tests to pass for all partition configurations we need to simulate the case of multiple 00043 // partitions using a single folder. We do this by creating one or two different sub-folders, depending on 00044 // the configuration. 00045 int fileSystemCreateRootFolders(void) 00046 { 00047 int status = 0; 00048 char folder[PAL_MAX_FILE_AND_FOLDER_LENGTH] = {0}; 00049 00050 // Get default mount point. 00051 status = pal_fsGetMountPoint(PAL_FS_PARTITION_PRIMARY, PAL_MAX_FILE_AND_FOLDER_LENGTH, folder); 00052 if(status != 0) 00053 { 00054 return 1; 00055 } 00056 printf("Mount point for primary partition: %s\r\n",folder); 00057 // Make the sub-folder 00058 int res = mkdir(folder,0744); 00059 if(res) 00060 { 00061 // Ignore error if it exists 00062 if( errno != EEXIST) 00063 { 00064 printf("mkdir failed errno= %d\r\n",errno); 00065 return 1; 00066 } 00067 } 00068 00069 00070 // Get default mount point. 00071 memset(folder,0,sizeof(folder)); 00072 status = pal_fsGetMountPoint(PAL_FS_PARTITION_SECONDARY, PAL_MAX_FILE_AND_FOLDER_LENGTH, folder); 00073 printf("Mount point for secondary partition: %s\r\n",folder); 00074 if(status != 0) 00075 { 00076 return 1; 00077 } 00078 00079 // Make the sub-folder 00080 res = mkdir(folder,0744); 00081 if(res) 00082 { 00083 // Ignore error if it exists 00084 if( errno != EEXIST) 00085 { 00086 printf("mkdir failed errno= %d\r\n",errno); 00087 return 1; 00088 } 00089 } 00090 return status; 00091 }
Generated on Tue Jul 12 2022 19:01:34 by 1.7.2