Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
aa34ffe7
K
Kernel Liteos A
项目概览
OpenHarmony
/
Kernel Liteos A
大约 1 年 前同步成功
通知
452
Star
414
Fork
55
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel Liteos A
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
aa34ffe7
编写于
4月 27, 2021
作者:
M
mucor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:remove redundant code
Change-Id: I8662952ac9d7912aaf2e2e72f779b3def41d14c4
上级
34f35524
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
5 addition
and
461 deletion
+5
-461
fs/include/fs/fs_operation.h
fs/include/fs/fs_operation.h
+0
-58
fs/vfs/disk/disk.c
fs/vfs/disk/disk.c
+3
-2
fs/vfs/operation/fs_getlabel.c
fs/vfs/operation/fs_getlabel.c
+0
-162
fs/vfs/operation/fs_virstatfs.c
fs/vfs/operation/fs_virstatfs.c
+2
-96
kernel/base/vm/los_vm_filemap.c
kernel/base/vm/los_vm_filemap.c
+0
-143
未找到文件。
fs/include/fs/fs_operation.h
浏览文件 @
aa34ffe7
...
...
@@ -163,30 +163,6 @@ void clear_fd(int fd);
extern
char
*
rindex
(
const
char
*
s
,
int
c
);
/**
* @ingroup fs
* @brief list directory contents.
*
* @par Description:
* Get the volume label of the FAT partition.
*
* @attention
* <ul>
* <li>The function support FAT filesystem only.</li>
* <li>The label must allocated more than 11 charactors space first</li>
* </ul>
*
* @param target [IN] Type #const char* The file pathname.
* @param label [OUT] Type #const char* The string pointer transform the label massge back.
*
* @retval #int Point the status which is successed or failed.
*
* @par Dependency:
* <ul><li>fs.h: the header file that contains the API declaration.</li></ul>
*/
int
getlabel
(
const
char
*
target
,
char
*
label
);
/**
* @ingroup fs
*
...
...
@@ -349,40 +325,6 @@ int fscheck(const char *path);
extern
int
virstatfs
(
const
char
*
path
,
struct
statfs
*
buf
);
/**
* @ingroup fs
* @set the virtual partition information.
*
* @par Description:
* The los_set_virpartparam() function use for set virtual partition parameter.
* The parameter include virtual partition number, virtual partition percent, virtual partition name
* and the partition path which need mount virtual partition.
*
* @attention
* <ul>
* <li>This function only support for FAT32.</li>
* <li>This function only support for the virtual partition feature.</li>
* <li>This function only can be used before mount function.</li>
* <li>The function can be invoked once before umount partition.</li>
* <li>Now support set single partition,the partition information will be replaced
* if it used for set another partition name.</li>
* <li>The function has no effert if virtual partition information is already in the partition.</li>
* </ul>
*
* @param virtualinfo [IN] Type #virpartinfo The struct which include virtual partition information.
*
* @retval #0 los_set_virpartparam success.
* @retval #-1 los_set_virpartparam failed.
*
* @par Dependency:
* <ul><li>fs.h: the header file that contains the API declaration.</li></ul>
* @see
*
*/
#ifdef VFS_IMPL_LATER
int
los_set_virpartparam
(
virpartinfo
virtualinfo
);
#endif
#endif
/**
...
...
fs/vfs/disk/disk.c
浏览文件 @
aa34ffe7
...
...
@@ -1148,15 +1148,16 @@ ERROR_HANDLE:
INT32
los_disk_cache_clear
(
INT32
drvID
)
{
INT32
result
;
los_part
*
part
=
get_part
(
drvID
);
los_disk
*
disk
=
NULL
;
result
=
OsSdSync
(
drvID
);
result
=
OsSdSync
(
part
->
disk_id
);
if
(
result
!=
0
)
{
PRINTK
(
"[ERROR]disk_cache_clear SD sync failed!
\n
"
);
return
result
;
}
disk
=
get_disk
(
drvID
);
disk
=
get_disk
(
part
->
disk_id
);
if
(
disk
==
NULL
)
{
return
-
1
;
}
...
...
fs/vfs/operation/fs_getlabel.c
已删除
100644 → 0
浏览文件 @
34f35524
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/****************************************************************************
* Included Files
****************************************************************************/
#include "vfs_config.h"
#include "sys/mount.h"
#include "errno.h"
#include "fs/fs.h"
#include "stdlib.h"
#include "string.h"
#include "disk.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Variables
****************************************************************************/
/****************************************************************************
* Public Variables
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: getlabel()
*
* Description:
* getlabel() get the volume label of partition(disk) from FAT filesystem by
* the 'target' path
*
* Parameters:
* target : the path which is the mount point of FAT filesystem device.
* label : the string var pointer, by which passed out label string.
*
* Return:
* Zero is returned on success; -1 is returned on an error and errno is
* set appropriately:
*
* ENOMEM There is no memory for allocated space for var.
* EFAULT The pointer 'target' does not pass in corretly.
* ENOENT The pointer 'target' pointed to a wrong location.
* EPERM The pointer 'target' does not point to a mount inode.
* EINVAL The pointer 'label' does not pass in correctly.
* EACCES The filesystem which 'target' point to is not supported.
*
****************************************************************************/
int
getlabel
(
const
char
*
target
,
char
*
label
)
{
#ifdef VFS_IMPL_LATER
struct
inode
*
mountpt_inode
=
NULL
;
int
errcode
=
OK
;
int
status
;
char
*
fullpath
=
NULL
;
struct
inode_search_s
desc
;
int
ret
;
/* Verify required pointer arguments */
if
(
target
==
NULL
||
label
==
NULL
)
{
errcode
=
EFAULT
;
goto
errout
;
}
/* Get a absolute path */
errcode
=
vfs_normalize_path
((
const
char
*
)
NULL
,
target
,
&
fullpath
);
if
(
errcode
<
0
)
{
errcode
=
-
errcode
;
goto
errout
;
}
/* Find the mountpt */
SETUP_SEARCH
(
&
desc
,
fullpath
,
false
);
ret
=
inode_find
(
&
desc
);
if
(
ret
<
0
)
{
errcode
=
EACCES
;
goto
errout_with_fullpath
;
}
mountpt_inode
=
desc
.
node
;
/* Verfy the path is a mountpoint path or file path */
if
(
!
INODE_IS_MOUNTPT
(
mountpt_inode
)
&&
!
INODE_IS_BLOCK
(
mountpt_inode
))
{
errcode
=
EPERM
;
goto
errout_with_release
;
}
if
(
mountpt_inode
->
u
.
i_mops
)
{
status
=
LOS_OK
;
if
(
status
<
0
)
{
/* The inode is unhappy with the blkdrvr for some reason */
errcode
=
-
status
;
goto
errout_with_release
;
}
inode_release
(
mountpt_inode
);
free
(
fullpath
);
return
OK
;
}
else
{
errcode
=
EACCES
;
goto
errout_with_release
;
}
/* A lot of goto's! But they make the error handling much simpler */
errout_with_release:
inode_release
(
mountpt_inode
);
errout_with_fullpath:
free
(
fullpath
);
errout:
set_errno
(
errcode
);
return
VFS_ERROR
;
#endif
return
0
;
}
fs/vfs/operation/fs_virstatfs.c
浏览文件 @
aa34ffe7
...
...
@@ -53,101 +53,7 @@
#ifdef LOSCFG_FS_FAT_VIRTUAL_PARTITION
int
virstatfs
(
const
char
*
path
,
struct
statfs
*
buf
)
{
#ifdef VFS_IMPL_LATER
struct
inode
*
inode
=
NULL
;
int
ret
=
OK
;
char
*
fullpath
=
NULL
;
struct
inode_search_s
desc
;
/* Sanity checks */
if
(
!
path
||
!
buf
)
{
ret
=
EFAULT
;
goto
errout
;
}
if
(
!
path
[
0
])
{
ret
=
ENOENT
;
goto
errout
;
}
ret
=
vfs_normalize_path
((
const
char
*
)
NULL
,
path
,
&
fullpath
);
if
(
ret
<
0
)
{
ret
=
-
ret
;
goto
errout
;
}
/* Get an inode for this file */
SETUP_SEARCH
(
&
desc
,
fullpath
,
false
);
ret
=
inode_find
(
&
desc
);
if
(
ret
<
0
)
{
/* This name does not refer to a psudeo-inode and there is no
* mountpoint that includes in this path.
*/
ret
=
EACCES
;
free
(
fullpath
);
goto
errout
;
}
inode
=
desc
.
node
;
/* The way we handle the statfs depends on the type of inode that we
* are dealing with.
*/
#ifndef CONFIG_DISABLE_MOUNTPOINT
if
(
INODE_IS_MOUNTPT
(
inode
))
{
/* The node is a file system mointpoint. Verify that the mountpoint
* supports the statfs() method
*/
if
(
inode
->
u
.
i_mops
)
{
/* Perform the statfs() operation */
ret
=
LOS_OK
;
}
else
{
ret
=
EINVAL
;
goto
errout_with_inode
;
}
}
else
#endif
{
ret
=
EINVAL
;
goto
errout_with_inode
;
}
/* Check if the statfs operation was successful */
if
(
ret
<
0
)
{
ret
=
-
ret
;
goto
errout_with_inode
;
}
/* Successfully statfs'ed the file */
inode_release
(
inode
);
free
(
fullpath
);
return
OK
;
/* Failure conditions always set the errno appropriately */
errout_with_inode:
inode_release
(
inode
);
free
(
fullpath
);
errout:
set_errno
(
ret
);
return
VFS_ERROR
;
#endif
return
0
;
//currently not implemented
return
LOS_OK
;
}
#endif
kernel/base/vm/los_vm_filemap.c
浏览文件 @
aa34ffe7
...
...
@@ -123,149 +123,6 @@ VOID OsDeletePageCacheLru(LosFilePage *page)
OsPageCacheDel
(
page
);
}
#if VFS_IMPL_LATER
STATIC
LosFilePage
*
OsPagecacheGetPageAndFill
(
struct
file
*
filp
,
VM_OFFSET_T
pgOff
,
size_t
*
readSize
,
VADDR_T
*
kvaddr
)
{
LosFilePage
*
page
=
NULL
;
struct
page_mapping
*
mapping
=
filp
->
f_mapping
;
page
=
OsFindGetEntry
(
mapping
,
pgOff
);
if
(
page
!=
NULL
)
{
OsSetPageLocked
(
page
->
vmPage
);
OsPageRefIncLocked
(
page
);
*
kvaddr
=
(
VADDR_T
)(
UINTPTR
)
OsVmPageToVaddr
(
page
->
vmPage
);
*
readSize
=
PAGE_SIZE
;
}
else
{
page
=
OsPageCacheAlloc
(
mapping
,
pgOff
);
if
(
page
==
NULL
)
{
VM_ERR
(
"Failed to alloc a page frame"
);
return
page
;
}
OsSetPageLocked
(
page
->
vmPage
);
*
kvaddr
=
(
VADDR_T
)(
UINTPTR
)
OsVmPageToVaddr
(
page
->
vmPage
);
file_seek
(
filp
,
pgOff
<<
PAGE_SHIFT
,
SEEK_SET
);
/* "ReadPage" func exists definitely in this procedure */
*
readSize
=
filp
->
f_vnode
->
u
.
i_mops
->
readpage
(
filp
,
(
char
*
)(
UINTPTR
)
*
kvaddr
,
PAGE_SIZE
);
if
(
*
readSize
==
0
)
{
VM_ERR
(
"read 0 bytes"
);
OsCleanPageLocked
(
page
->
vmPage
);
}
OsAddToPageacheLru
(
page
,
mapping
,
pgOff
);
}
return
page
;
}
ssize_t
OsMappingRead
(
struct
file
*
filp
,
char
*
buf
,
size_t
size
)
{
INT32
ret
;
vaddr_t
kvaddr
=
0
;
UINT32
intSave
;
struct
stat
bufStat
;
size_t
readSize
=
0
;
size_t
readTotal
=
0
;
size_t
readLeft
=
size
;
LosFilePage
*
page
=
NULL
;
VM_OFFSET_T
pos
=
file_seek
(
filp
,
0
,
SEEK_CUR
);
VM_OFFSET_T
pgOff
=
pos
>>
PAGE_SHIFT
;
INT32
offInPage
=
pos
%
PAGE_SIZE
;
struct
page_mapping
*
mapping
=
filp
->
f_mapping
;
INT32
nPages
=
(
ROUNDUP
(
pos
+
size
,
PAGE_SIZE
)
-
ROUNDDOWN
(
pos
,
PAGE_SIZE
))
>>
PAGE_SHIFT
;
ret
=
stat
(
filp
->
f_path
,
&
bufStat
);
if
(
ret
!=
OK
)
{
VM_ERR
(
"Get file size failed. (filepath=%s)"
,
filp
->
f_path
);
return
0
;
}
if
(
pos
>=
bufStat
.
st_size
)
{
PRINT_INFO
(
"%s filp->f_pos >= bufStat.st_size (pos=%ld, fileSize=%ld)
\n
"
,
filp
->
f_path
,
pos
,
bufStat
.
st_size
);
return
0
;
}
LOS_SpinLockSave
(
&
mapping
->
list_lock
,
&
intSave
);
for
(
INT32
i
=
0
;
(
i
<
nPages
)
&&
readLeft
;
i
++
,
pgOff
++
)
{
page
=
OsPagecacheGetPageAndFill
(
filp
,
pgOff
,
&
readSize
,
&
kvaddr
);
if
((
page
==
NULL
)
||
(
readSize
==
0
))
{
break
;
}
if
(
readSize
<
PAGE_SIZE
)
{
readLeft
=
readSize
;
}
readSize
=
MIN2
((
PAGE_SIZE
-
offInPage
),
readLeft
);
(
VOID
)
memcpy_s
((
VOID
*
)
buf
,
readLeft
,
(
char
*
)(
UINTPTR
)
kvaddr
+
offInPage
,
readSize
);
buf
+=
readSize
;
readLeft
-=
readSize
;
readTotal
+=
readSize
;
offInPage
=
0
;
OsCleanPageLocked
(
page
->
vmPage
);
}
LOS_SpinUnlockRestore
(
&
mapping
->
list_lock
,
intSave
);
file_seek
(
filp
,
pos
+
readTotal
,
SEEK_SET
);
return
readTotal
;
}
#endif
ssize_t
OsMappingWrite
(
struct
file
*
filp
,
const
char
*
buf
,
size_t
size
)
{
VADDR_T
kvaddr
;
UINT32
intSave
;
INT32
writeSize
=
0
;
size_t
writeLeft
=
size
;
VM_OFFSET_T
pos
=
file_seek
(
filp
,
0
,
SEEK_CUR
);
VM_OFFSET_T
pgOff
=
pos
>>
PAGE_SHIFT
;
INT32
offInPage
=
pos
%
PAGE_SIZE
;
LosFilePage
*
page
=
NULL
;
struct
page_mapping
*
mapping
=
filp
->
f_mapping
;
INT32
nPages
=
(
ROUNDUP
(
pos
+
size
,
PAGE_SIZE
)
-
ROUNDDOWN
(
pos
,
PAGE_SIZE
))
>>
PAGE_SHIFT
;
LOS_SpinLockSave
(
&
mapping
->
list_lock
,
&
intSave
);
for
(
INT32
i
=
0
;
i
<
nPages
;
i
++
,
pgOff
++
)
{
page
=
OsFindGetEntry
(
mapping
,
pgOff
);
if
(
page
)
{
kvaddr
=
(
VADDR_T
)(
UINTPTR
)
OsVmPageToVaddr
(
page
->
vmPage
);
OsSetPageLocked
(
page
->
vmPage
);
OsPageRefIncLocked
(
page
);
}
else
{
page
=
OsPageCacheAlloc
(
mapping
,
pgOff
);
if
(
page
==
NULL
)
{
VM_ERR
(
"Failed to alloc a page frame"
);
break
;
}
kvaddr
=
(
VADDR_T
)(
UINTPTR
)
OsVmPageToVaddr
(
page
->
vmPage
);
OsAddToPageacheLru
(
page
,
mapping
,
pgOff
);
OsSetPageLocked
(
page
->
vmPage
);
}
writeSize
=
MIN2
((
PAGE_SIZE
-
offInPage
),
writeLeft
);
(
VOID
)
memcpy_s
((
char
*
)(
UINTPTR
)
kvaddr
+
offInPage
,
writeLeft
,
buf
,
writeSize
);
buf
+=
writeSize
;
writeLeft
-=
writeSize
;
OsMarkPageDirty
(
page
,
NULL
,
offInPage
,
writeSize
);
offInPage
=
0
;
OsCleanPageLocked
(
page
->
vmPage
);
}
LOS_SpinUnlockRestore
(
&
mapping
->
list_lock
,
intSave
);
file_seek
(
filp
,
pos
+
size
-
writeLeft
,
SEEK_SET
);
return
(
size
-
writeLeft
);
}
STATIC
VOID
OsPageCacheUnmap
(
LosFilePage
*
fpage
,
LosArchMmu
*
archMmu
,
VADDR_T
vaddr
)
{
UINT32
intSave
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录