Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NuttX RTOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
f4grx
NuttX RTOS
Commits
834ee93c
Commit
834ee93c
authored
11 years ago
by
Gregory Nutt
Browse files
Options
Downloads
Patches
Plain Diff
mkdir can now be used to create empty directories in the pseudo-filesystem.
parent
5bae65fa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ChangeLog
+3
-2
3 additions, 2 deletions
ChangeLog
fs/Makefile
+7
-5
7 additions, 5 deletions
fs/Makefile
fs/fs_mkdir.c
+56
-26
56 additions, 26 deletions
fs/fs_mkdir.c
with
66 additions
and
33 deletions
ChangeLog
+
3
−
2
View file @
834ee93c
...
...
@@ -6610,7 +6610,8 @@
* fs/fs_opendir.c, fs_readdir.c, et al: Modified so that errors
will not be reported if you attempt to list a empty pseudo-directory
(2014-2-19).
* fs/fs_rmdir.c: rmdir can be used to remove
d
empty directories in
* fs/fs_rmdir.c: rmdir can
now
be used to remove empty directories in
the pseudo-filesystem such as might be left after umounting a
file system (2014-2-19).
* fs/fs_mkdir.c: mkdir can now be used to create empty directories in
the pseudo-filesystem (2014-2-19).
This diff is collapsed.
Click to expand it.
fs/Makefile
+
7
−
5
View file @
834ee93c
...
...
@@ -62,13 +62,15 @@ else
# Common file/socket descriptor support
CSRCS
+=
fs_close.c fs_closedir.c fs_dup.c fs_dup2.c fs_fcntl.c
CSRCS
+=
fs_filedup.c fs_filedup2.c fs_ioctl.c fs_lseek.c fs_open.c
CSRCS
+=
fs_opendir.c fs_poll.c fs_read.c fs_readdir.c fs_rewinddir.c
CSRCS
+=
fs_rmdir.c fs_seekdir.c fs_stat.c fs_statfs.c fs_select.c
CSRCS
+=
fs_write.c
CSRCS
+=
fs_filedup.c fs_filedup2.c fs_ioctl.c fs_lseek.c fs_mkdir.c
CSRCS
+=
fs_open.c fs_opendir.c fs_poll.c fs_read.c fs_readdir.c
CSRCS
+=
fs_rewinddir.c fs_rmdir.c fs_seekdir.c fs_stat.c fs_statfs.c
CSRCS
+=
fs_select.c fs_write.c
CSRCS
+=
fs_files.c fs_foreachinode.c fs_inode.c fs_inodeaddref.c
CSRCS
+=
fs_inodefind.c fs_inoderelease.c fs_inoderemove.c
CSRCS
+=
fs_inodereserve.c
CSRCS
+=
fs_registerdriver.c fs_unregisterdriver.c
CSRCS
+=
fs_registerblockdriver.c fs_unregisterblockdriver.c
CSRCS
+=
fs_findblockdriver.c fs_openblockdriver.c fs_closeblockdriver.c
...
...
@@ -102,7 +104,7 @@ endif
ifneq
($(CONFIG_DISABLE_MOUNTPOINT),y)
CSRCS
+=
fs_fsync.c
fs_mkdir.c
fs_mount.c fs_rename.c fs_umount.c
CSRCS
+=
fs_fsync.c fs_mount.c fs_rename.c fs_umount.c
CSRCS
+=
fs_unlink.c
CSRCS
+=
fs_foreachmountpoint.c
...
...
This diff is collapsed.
Click to expand it.
fs/fs_mkdir.c
+
56
−
26
View file @
834ee93c
/****************************************************************************
* fs/fs_mkdir.c
*
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Copyright (C) 2007, 2008
, 2014
Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
...
...
@@ -76,55 +76,85 @@ int mkdir(const char *pathname, mode_t mode)
{
FAR
struct
inode
*
inode
;
const
char
*
relpath
=
NULL
;
int
errcode
;
int
ret
;
/*
Get an inode for this file
*/
/*
Find the inode that includes this path
*/
inode
=
inode_find
(
pathname
,
&
relpath
);
if
(
!
inode
)
if
(
inode
)
{
/* There is no mountpoint that includes in this path */
/* An inode was found that includes this path and possibly refers to a
* mountpoint.
*/
ret
=
ENOENT
;
goto
errout
;
}
#ifndef CONFIG_DISABLE_MOUNTPOINT
/* Check if the inode is a valid mountpoint. */
/* Verify that the inode is a valid mountpoint. */
if
(
!
INODE_IS_MOUNTPT
(
inode
)
||
!
inode
->
u
.
i_mops
)
{
/* The inode is not a mountpoint */
if
(
!
INODE_IS_MOUNTPT
(
inode
)
||
!
inode
->
u
.
i_mops
)
{
ret
=
ENXIO
;
goto
errout_with_inode
;
errcode
=
ENXIO
;
goto
errout_with_inode
;
}
/* Perform the mkdir operation using the relative path
* at the mountpoint.
*/
if
(
inode
->
u
.
i_mops
->
mkdir
)
{
ret
=
inode
->
u
.
i_mops
->
mkdir
(
inode
,
relpath
,
mode
);
if
(
ret
<
0
)
{
errcode
=
-
ret
;
goto
errout_with_inode
;
}
}
else
{
errcode
=
ENOSYS
;
goto
errout_with_inode
;
}
/* Release our reference on the inode */
inode_release
(
inode
);
#else
/* But mountpoints are not supported in this configuration */
errocode
=
EEXIST
;
goto
errout_with_inode
;
#endif
}
/*
Perform the mkdir operation us
in
g
th
e
re
l
at
ive pa
th
*
at the mountpoint
.
/*
No inode exists that conta
in
s
th
is path. C
reat
e a new inode in
th
e
*
pseudo-filesystem at this location
.
*/
if
(
inode
->
u
.
i_mops
->
mkdir
)
else
{
ret
=
inode
->
u
.
i_mops
->
mkdir
(
inode
,
relpath
,
mode
);
/* Create an inode in the pseudo-filesystem at this path */
inode_semtake
();
ret
=
inode_reserve
(
pathname
,
&
inode
);
inode_semgive
();
if
(
ret
<
0
)
{
ret
=
-
ret
;
goto
errout
_with_inode
;
errcode
=
-
ret
;
goto
errout
;
}
}
else
{
ret
=
ENOSYS
;
goto
errout_with_inode
;
}
/* Directory successfully created */
inode_release
(
inode
);
return
OK
;
errout_with_inode:
inode_release
(
inode
);
errout:
set_errno
(
ret
);
set_errno
(
errcode
);
return
ERROR
;
}
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