Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Miosix Kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Avionics
Software Development
Miosix Kernel
Commits
0f7d4ede
Commit
0f7d4ede
authored
Jan 31, 2014
by
Terraneo Federico
Browse files
Options
Downloads
Patches
Plain Diff
Moving to size_t in path resolution code
parent
077b0b21
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
miosix/filesystem/file_access.cpp
+17
-17
17 additions, 17 deletions
miosix/filesystem/file_access.cpp
miosix_np_2/nbproject/private/private.xml
+0
-2
0 additions, 2 deletions
miosix_np_2/nbproject/private/private.xml
with
17 additions
and
19 deletions
miosix/filesystem/file_access.cpp
+
17
−
17
View file @
0f7d4ede
...
...
@@ -67,14 +67,14 @@ public:
* \param off offset into path where the subpath relative to the current
* filesystem starts
*/
ResolvedPath
(
intrusive_ref_ptr
<
FilesystemBase
>
fs
,
in
t
offset
)
ResolvedPath
(
intrusive_ref_ptr
<
FilesystemBase
>
fs
,
size_
t
offset
)
:
result
(
0
),
fs
(
fs
),
off
(
offset
)
{}
int
result
;
///< 0 on success, a negative number on failure
intrusive_ref_ptr
<
FilesystemBase
>
fs
;
///< pointer to the filesystem to which the file belongs
/// path.c_str()+off is a string containing the relative path into the
/// filesystem for the looked up file
in
t
off
;
size_
t
off
;
};
//
...
...
@@ -158,7 +158,7 @@ int FileDescriptorTable::getcwd(char *buf, size_t len)
int
FileDescriptorTable
::
chdir
(
const
char
*
name
)
{
if
(
name
==
0
||
name
[
0
]
==
'\0'
)
return
-
EFAULT
;
in
t
len
=
strlen
(
name
);
size_
t
len
=
strlen
(
name
);
if
(
name
[
len
-
1
]
!=
'/'
)
len
++
;
//Reserve room for trailing slash
Lock
<
FastMutex
>
l
(
mutex
);
if
(
name
[
0
]
!=
'/'
)
len
+=
cwd
.
length
();
...
...
@@ -242,7 +242,7 @@ FileDescriptorTable::~FileDescriptorTable()
string
FileDescriptorTable
::
absolutePath
(
const
char
*
path
)
{
in
t
len
=
strlen
(
path
);
size_
t
len
=
strlen
(
path
);
if
(
len
>
PATH_MAX
)
return
""
;
if
(
path
[
0
]
==
'/'
)
return
path
;
Lock
<
FastMutex
>
l
(
mutex
);
...
...
@@ -280,7 +280,7 @@ private:
* \param slash path[slash] is the / character after the ..
* \return 0 on success, a negative number on error
*/
int
upPathComponent
(
string
&
path
,
in
t
slash
);
int
upPathComponent
(
string
&
path
,
size_
t
slash
);
/**
* Handle a normal path component in a path, i.e, a path component
...
...
@@ -319,10 +319,10 @@ private:
bool
syms
;
/// path[index] is first unhandled char
unsigned
in
t
index
;
size_
t
index
;
/// path.substr(indexIntoFs) is the relative path to current filesystem
unsigned
in
t
indexIntoFs
;
size_
t
indexIntoFs
;
/// How many components does the relative path have in current fs
int
depthIntoFs
;
...
...
@@ -347,7 +347,7 @@ ResolvedPath PathResolution::resolvePath(string& path, bool followLastSymlink)
linksFollowed
=
0
;
for
(;;)
{
unsigned
in
t
slash
=
path
.
find_first_of
(
'/'
,
index
);
size_
t
slash
=
path
.
find_first_of
(
'/'
,
index
);
//cout<<path.substr(0,slash)<<endl;
//Last component (no trailing /)
if
(
slash
==
string
::
npos
)
slash
=
path
.
length
();
//NOTE: one past the last
...
...
@@ -374,7 +374,7 @@ ResolvedPath PathResolution::resolvePath(string& path, bool followLastSymlink)
if
(
index
>=
path
.
length
())
{
//Remove trailing /
unsigned
in
t
last
=
path
.
length
()
-
1
;
size_
t
last
=
path
.
length
()
-
1
;
if
(
path
[
last
]
==
'/'
)
{
path
.
erase
(
last
,
1
);
...
...
@@ -386,10 +386,10 @@ ResolvedPath PathResolution::resolvePath(string& path, bool followLastSymlink)
}
}
int
PathResolution
::
upPathComponent
(
string
&
path
,
in
t
slash
)
int
PathResolution
::
upPathComponent
(
string
&
path
,
size_
t
slash
)
{
if
(
index
<=
1
)
return
-
ENOENT
;
//root dir has no parent
unsigned
in
t
removeStart
=
path
.
find_last_of
(
'/'
,
index
-
2
);
size_
t
removeStart
=
path
.
find_last_of
(
'/'
,
index
-
2
);
if
(
removeStart
==
string
::
npos
)
return
-
ENOENT
;
//should not happen
path
.
erase
(
removeStart
,
slash
-
removeStart
);
index
=
removeStart
+
1
;
...
...
@@ -444,7 +444,7 @@ int PathResolution::followSymlink(string& path)
if
(
target
[
0
]
==
'/'
)
{
//Symlink is absolute
in
t
newPathLen
=
target
.
length
()
+
path
.
length
()
-
index
+
1
;
size_
t
newPathLen
=
target
.
length
()
+
path
.
length
()
-
index
+
1
;
if
(
newPathLen
>
PATH_MAX
)
return
-
ENAMETOOLONG
;
string
newPath
;
newPath
.
reserve
(
newPathLen
);
...
...
@@ -459,8 +459,8 @@ int PathResolution::followSymlink(string& path)
depthIntoFs
=
1
;
}
else
{
//Symlink is relative
in
t
removeStart
=
path
.
find_last_of
(
'/'
,
index
-
2
);
in
t
newPathLen
=
path
.
length
()
-
(
index
-
removeStart
-
2
)
+
target
.
length
();
size_
t
removeStart
=
path
.
find_last_of
(
'/'
,
index
-
2
);
size_
t
newPathLen
=
path
.
length
()
-
(
index
-
removeStart
-
2
)
+
target
.
length
();
if
(
newPathLen
>
PATH_MAX
)
return
-
ENAMETOOLONG
;
string
newPath
;
newPath
.
reserve
(
newPathLen
);
...
...
@@ -478,7 +478,7 @@ int PathResolution::followSymlink(string& path)
int
PathResolution
::
recursiveFindFs
(
string
&
path
)
{
depthIntoFs
=
1
;
unsigned
in
t
backIndex
=
index
;
size_
t
backIndex
=
index
;
for
(;;)
{
backIndex
=
path
.
find_last_of
(
'/'
,
backIndex
-
1
);
...
...
@@ -517,7 +517,7 @@ int FilesystemManager::kmount(const char* path, intrusive_ref_ptr<FilesystemBase
{
if
(
path
==
0
||
path
[
0
]
==
'\0'
||
fs
==
0
)
return
-
EFAULT
;
Lock
<
FastMutex
>
l
(
mutex
);
in
t
len
=
strlen
(
path
);
size_
t
len
=
strlen
(
path
);
if
(
len
>
PATH_MAX
)
return
-
ENAMETOOLONG
;
string
temp
(
path
);
if
(
!
(
temp
==
"/"
&&
filesystems
.
empty
()))
//Skip check when mounting /
...
...
@@ -541,7 +541,7 @@ int FilesystemManager::umount(const char* path, bool force)
typename
map
<
StringPart
,
intrusive_ref_ptr
<
FilesystemBase
>
>::
iterator
fsIt
;
if
(
path
==
0
||
path
[
0
]
==
'\0'
)
return
-
ENOENT
;
in
t
len
=
strlen
(
path
);
size_
t
len
=
strlen
(
path
);
if
(
len
>
PATH_MAX
)
return
-
ENAMETOOLONG
;
Lock
<
FastMutex
>
l
(
mutex
);
//A reader-writer lock would be better
fsIt
it
=
filesystems
.
find
(
StringPart
(
path
));
...
...
This diff is collapsed.
Click to expand it.
miosix_np_2/nbproject/private/private.xml
+
0
−
2
View file @
0f7d4ede
...
...
@@ -12,12 +12,10 @@
<open-files
xmlns=
"http://www.netbeans.org/ns/projectui-open-files/2"
>
<group>
<file>
file:/media/truecrypt1/Projects/ARM/miosix/miosix-kernel/miosix/kernel/process.h
</file>
<file>
file:/media/truecrypt1/Projects/ARM/miosix/miosix-kernel/miosix/filesystem/file_access.h
</file>
<file>
file:/media/truecrypt1/Projects/ARM/miosix/miosix-kernel/miosix/kernel/kernel.h
</file>
<file>
file:/media/truecrypt1/Projects/ARM/miosix/miosix-kernel/miosix/kernel/process.cpp
</file>
<file>
file:/media/truecrypt1/Projects/ARM/miosix/miosix-kernel/miosix/kernel/kernel.cpp
</file>
<file>
file:/media/truecrypt1/Projects/ARM/miosix/miosix-kernel/main.cpp
</file>
<file>
file:/media/truecrypt1/Projects/ARM/miosix/miosix-kernel/miosix/filesystem/file_access.cpp
</file>
</group>
</open-files>
</project-private>
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