Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
swym
firmware
Commits
8648f41d
Commit
8648f41d
authored
5 years ago
by
swym
Committed by
rahix
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
efs_lock_global: make signature more straight-forward
parent
4e22cb10
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
epicardium/fs/fileops.c
+16
-16
16 additions, 16 deletions
epicardium/fs/fileops.c
epicardium/fs/internal.h
+1
-1
1 addition, 1 deletion
epicardium/fs/internal.h
epicardium/modules/filesystem_fat.c
+5
-9
5 additions, 9 deletions
epicardium/modules/filesystem_fat.c
with
22 additions
and
26 deletions
epicardium/fs/fileops.c
+
16
−
16
View file @
8648f41d
...
@@ -11,8 +11,8 @@
...
@@ -11,8 +11,8 @@
int
epic_file_open
(
const
char
*
filename
,
const
char
*
mode
)
int
epic_file_open
(
const
char
*
filename
,
const
char
*
mode
)
{
{
EpicFileSystem
*
fs
;
EpicFileSystem
*
fs
;
int
res
;
int
res
=
efs_lock_global
(
&
fs
)
;
if
(
efs_lock_global
(
&
fs
,
&
res
)
)
{
if
(
res
==
0
)
{
res
=
efs_open
(
fs
,
filename
,
mode
);
res
=
efs_open
(
fs
,
filename
,
mode
);
efs_unlock_global
(
fs
);
efs_unlock_global
(
fs
);
}
}
...
@@ -22,8 +22,8 @@ int epic_file_open(const char *filename, const char *mode)
...
@@ -22,8 +22,8 @@ int epic_file_open(const char *filename, const char *mode)
int
epic_file_close
(
int
fd
)
int
epic_file_close
(
int
fd
)
{
{
EpicFileSystem
*
fs
;
EpicFileSystem
*
fs
;
int
res
;
int
res
=
efs_lock_global
(
&
fs
)
;
if
(
efs_lock_global
(
&
fs
,
&
res
)
)
{
if
(
res
==
0
)
{
res
=
efs_close
(
fs
,
fd
);
res
=
efs_close
(
fs
,
fd
);
efs_unlock_global
(
fs
);
efs_unlock_global
(
fs
);
}
}
...
@@ -33,8 +33,8 @@ int epic_file_close(int fd)
...
@@ -33,8 +33,8 @@ int epic_file_close(int fd)
int
epic_file_read
(
int
fd
,
void
*
buf
,
size_t
nbytes
)
int
epic_file_read
(
int
fd
,
void
*
buf
,
size_t
nbytes
)
{
{
EpicFileSystem
*
fs
;
EpicFileSystem
*
fs
;
int
res
;
int
res
=
efs_lock_global
(
&
fs
)
;
if
(
efs_lock_global
(
&
fs
,
&
res
)
)
{
if
(
res
==
0
)
{
res
=
efs_read
(
fs
,
fd
,
buf
,
nbytes
);
res
=
efs_read
(
fs
,
fd
,
buf
,
nbytes
);
efs_unlock_global
(
fs
);
efs_unlock_global
(
fs
);
}
}
...
@@ -44,8 +44,8 @@ int epic_file_read(int fd, void *buf, size_t nbytes)
...
@@ -44,8 +44,8 @@ int epic_file_read(int fd, void *buf, size_t nbytes)
int
epic_file_write
(
int
fd
,
const
void
*
buf
,
size_t
nbytes
)
int
epic_file_write
(
int
fd
,
const
void
*
buf
,
size_t
nbytes
)
{
{
EpicFileSystem
*
fs
;
EpicFileSystem
*
fs
;
int
res
;
int
res
=
efs_lock_global
(
&
fs
)
;
if
(
efs_lock_global
(
&
fs
,
&
res
)
)
{
if
(
res
==
0
)
{
res
=
efs_write
(
fs
,
fd
,
buf
,
nbytes
);
res
=
efs_write
(
fs
,
fd
,
buf
,
nbytes
);
efs_unlock_global
(
fs
);
efs_unlock_global
(
fs
);
}
}
...
@@ -55,8 +55,8 @@ int epic_file_write(int fd, const void *buf, size_t nbytes)
...
@@ -55,8 +55,8 @@ int epic_file_write(int fd, const void *buf, size_t nbytes)
int
epic_file_flush
(
int
fd
)
int
epic_file_flush
(
int
fd
)
{
{
EpicFileSystem
*
fs
;
EpicFileSystem
*
fs
;
int
res
;
int
res
=
efs_lock_global
(
&
fs
)
;
if
(
efs_lock_global
(
&
fs
,
&
res
)
)
{
if
(
res
==
0
)
{
res
=
efs_flush
(
fs
,
fd
);
res
=
efs_flush
(
fs
,
fd
);
efs_unlock_global
(
fs
);
efs_unlock_global
(
fs
);
}
}
...
@@ -66,8 +66,8 @@ int epic_file_flush(int fd)
...
@@ -66,8 +66,8 @@ int epic_file_flush(int fd)
int
epic_file_seek
(
int
fd
,
long
offset
,
int
whence
)
int
epic_file_seek
(
int
fd
,
long
offset
,
int
whence
)
{
{
EpicFileSystem
*
fs
;
EpicFileSystem
*
fs
;
int
res
;
int
res
=
efs_lock_global
(
&
fs
)
;
if
(
efs_lock_global
(
&
fs
,
&
res
)
)
{
if
(
res
==
0
)
{
res
=
efs_seek
(
fs
,
fd
,
offset
,
whence
);
res
=
efs_seek
(
fs
,
fd
,
offset
,
whence
);
efs_unlock_global
(
fs
);
efs_unlock_global
(
fs
);
}
}
...
@@ -77,8 +77,8 @@ int epic_file_seek(int fd, long offset, int whence)
...
@@ -77,8 +77,8 @@ int epic_file_seek(int fd, long offset, int whence)
int
epic_file_tell
(
int
fd
)
int
epic_file_tell
(
int
fd
)
{
{
EpicFileSystem
*
fs
;
EpicFileSystem
*
fs
;
int
res
;
int
res
=
efs_lock_global
(
&
fs
)
;
if
(
efs_lock_global
(
&
fs
,
&
res
)
)
{
if
(
res
==
0
)
{
res
=
efs_tell
(
fs
,
fd
);
res
=
efs_tell
(
fs
,
fd
);
efs_unlock_global
(
fs
);
efs_unlock_global
(
fs
);
}
}
...
@@ -88,8 +88,8 @@ int epic_file_tell(int fd)
...
@@ -88,8 +88,8 @@ int epic_file_tell(int fd)
int
epic_file_stat
(
const
char
*
filename
,
struct
epic_stat
*
stat
)
int
epic_file_stat
(
const
char
*
filename
,
struct
epic_stat
*
stat
)
{
{
EpicFileSystem
*
fs
;
EpicFileSystem
*
fs
;
int
res
;
int
res
=
efs_lock_global
(
&
fs
)
;
if
(
efs_lock_global
(
&
fs
,
&
res
)
)
{
if
(
res
==
0
)
{
res
=
efs_stat
(
fs
,
filename
,
stat
);
res
=
efs_stat
(
fs
,
filename
,
stat
);
efs_unlock_global
(
fs
);
efs_unlock_global
(
fs
);
}
}
...
...
This diff is collapsed.
Click to expand it.
epicardium/fs/internal.h
+
1
−
1
View file @
8648f41d
...
@@ -35,7 +35,7 @@ int efs_stat(EpicFileSystem *fs, const char *filename, struct epic_stat *stat);
...
@@ -35,7 +35,7 @@ int efs_stat(EpicFileSystem *fs, const char *filename, struct epic_stat *stat);
* Upon successful return, the filesystem has to be re-locked with epic_fs_unlock_global
* Upon successful return, the filesystem has to be re-locked with epic_fs_unlock_global
* In case of error, the filesystem will be left in a locked state.
* In case of error, the filesystem will be left in a locked state.
*/
*/
bool
efs_lock_global
(
EpicFileSystem
**
fs
,
int
*
ec
);
int
efs_lock_global
(
EpicFileSystem
**
fs
);
void
efs_unlock_global
(
EpicFileSystem
*
fs
);
void
efs_unlock_global
(
EpicFileSystem
*
fs
);
#endif// EPICARCIUM_FS_INTERNAL_H_INCLUDED
#endif// EPICARCIUM_FS_INTERNAL_H_INCLUDED
This diff is collapsed.
Click to expand it.
epicardium/modules/filesystem_fat.c
+
5
−
9
View file @
8648f41d
...
@@ -139,9 +139,8 @@ int fatfs_attach()
...
@@ -139,9 +139,8 @@ int fatfs_attach()
void
fatfs_detach
()
void
fatfs_detach
()
{
{
FRESULT
ff_res
;
FRESULT
ff_res
;
int
rc
;
EpicFileSystem
*
fs
;
EpicFileSystem
*
fs
;
if
(
efs_lock_global
(
&
fs
,
&
rc
)
)
{
if
(
efs_lock_global
(
&
fs
)
==
0
)
{
efs_close_all
(
fs
);
efs_close_all
(
fs
);
//unmount by passing NULL as fs object, will destroy our sync object via ff_del_syncobj
//unmount by passing NULL as fs object, will destroy our sync object via ff_del_syncobj
...
@@ -188,21 +187,18 @@ static void globalLockRelease()
...
@@ -188,21 +187,18 @@ static void globalLockRelease()
xSemaphoreGive
(
s_globalLock
);
xSemaphoreGive
(
s_globalLock
);
}
}
bool
efs_lock_global
(
EpicFileSystem
**
fs
,
int
*
rc
)
int
efs_lock_global
(
EpicFileSystem
**
fs
)
{
{
*
fs
=
NULL
;
*
fs
=
NULL
;
if
(
!
globalLockAccquire
())
{
if
(
!
globalLockAccquire
())
{
*
rc
=
-
EBUSY
;
return
-
EBUSY
;
return
false
;
}
}
if
(
!
s_globalFileSystem
.
initialized
)
{
if
(
!
s_globalFileSystem
.
initialized
)
{
globalLockRelease
();
globalLockRelease
();
*
rc
=
-
ENODEV
;
return
-
ENODEV
;
return
false
;
}
}
*
fs
=
&
s_globalFileSystem
;
*
fs
=
&
s_globalFileSystem
;
*
rc
=
0
;
return
0
;
return
true
;
}
}
void
efs_unlock_global
(
EpicFileSystem
*
fs
)
void
efs_unlock_global
(
EpicFileSystem
*
fs
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment