Compare commits

..

10 Commits

Author SHA1 Message Date
openharmony_ci
4d1fd22b1c !1060 LTS 补丁升级适配
Merge pull request !1060 from gaochao/master
2022-11-14 09:16:06 +00:00
openharmony_ci
efa336ab26 !1061 time相关系统调用内核栈信息泄露排查
Merge pull request !1061 from zhushengle/time
2022-11-11 06:44:21 +00:00
zhushengle
0b05a46691 task: time相关系统调用内核栈信息泄露排查
解决方案:
    在涉及从内核拷贝数据到用户态的场景时,先将内核的数据进行清零操作,再填充内核数据
Close #I60M1P

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Ia61d4e39b9e190accea477ff5b361e41d0eed2af
2022-11-11 14:24:07 +08:00
gaochao
177f32283f LTS 补丁升级适配
Signed-off-by: gaochao <gaochao49@huawei.com>
2022-11-10 16:32:48 +08:00
openharmony_ci
6888193e3f !1052 LTS 5.10 补丁升级适配
Merge pull request !1052 from gaochao/master
2022-11-04 07:23:25 +00:00
gc1202
6c352a7b10 LTS 补丁升级适配
Signed-off-by: gc1202 <gaochao49@huawei.com>
2022-11-02 14:23:47 +08:00
openharmony_ci
73a9587f02 !1046 Fix : 内核告警清理
Merge pull request !1046 from yinjiaming/fix
2022-10-27 12:50:29 +00:00
openharmony_ci
cbd03bd7e0 !913 删除PLATFORM_QEMU_ARM_VIRT_CA7侵入内核的所有代码
Merge pull request !913 from laokz/jffs2fat
2022-10-26 03:52:16 +00:00
yinjiaming
8d55bb1d8c fix: 内核告警清理
【背景】
内核告警清理

【修改方案】
删去了多余的空格,更改了魔数字

【影响】
对现有的产品编译不会有影响。

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Iba21be6cb23027dfb369576847d7d21e85f936b4
2022-10-26 10:57:08 +08:00
laokz
059c1c22b1 fix(PLATFORM_QEMU_ARM_VIRT_CA7): remove all invasive code
arm-virt emulation rootfs change to vfat from jffs2,
root device change to eMMC from CFI flash

Signed-off-by: laokz <laokz@foxmail.com>
Change-Id: If284809b989918cf10f5d32803df42c8c57830b2
2022-06-25 18:25:39 +08:00
27 changed files with 468 additions and 201 deletions

View File

@@ -82,9 +82,6 @@ endif
ifeq ($(LOSCFG_STORAGE_SPINAND), y) ifeq ($(LOSCFG_STORAGE_SPINAND), y)
FSTYPE = yaffs2 FSTYPE = yaffs2
endif endif
ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y)
FSTYPE = jffs2
endif
ROOTFS_DIR = $(OUT)/rootfs ROOTFS_DIR = $(OUT)/rootfs
ROOTFS_ZIP = $(OUT)/rootfs.zip ROOTFS_ZIP = $(OUT)/rootfs.zip

View File

@@ -49,7 +49,7 @@ ShellCB *OsGetShellCb()
return g_shellCB; return g_shellCB;
} }
static void ShellDeinit(ShellCB *shellCB) void ShellDeinit(ShellCB *shellCB)
{ {
(void)pthread_mutex_destroy(&shellCB->historyMutex); (void)pthread_mutex_destroy(&shellCB->historyMutex);
(void)pthread_mutex_destroy(&shellCB->keyMutex); (void)pthread_mutex_destroy(&shellCB->keyMutex);
@@ -65,23 +65,27 @@ static int OsShellCreateTask(ShellCB *shellCB)
ret = sched_getparam(getpid(), &param); ret = sched_getparam(getpid(), &param);
if (ret != SH_OK) { if (ret != SH_OK) {
return ret; goto OUT;
} }
param.sched_priority = SHELL_PROCESS_PRIORITY_INIT; param.sched_priority = SHELL_PROCESS_PRIORITY_INIT;
ret = sched_setparam(getpid(), &param); ret = sched_setparam(getpid(), &param);
if (ret != SH_OK) { if (ret != SH_OK) {
return ret; goto OUT;
} }
ret = ShellTaskInit(shellCB); ret = ShellTaskInit(shellCB);
if (ret != SH_OK) { if (ret != SH_OK) {
return ret; goto OUT;
} }
shellCB->shellEntryHandle = pthread_self(); shellCB->shellEntryHandle = pthread_self();
return 0; return 0;
OUT:
ShellDeinit(shellCB);
return ret;
} }
static int DoShellExec(char **argv) static int DoShellExec(char **argv)
@@ -144,7 +148,7 @@ int main(int argc, char **argv)
shellCB = (ShellCB *)malloc(sizeof(ShellCB)); shellCB = (ShellCB *)malloc(sizeof(ShellCB));
if (shellCB == NULL) { if (shellCB == NULL) {
return SH_NOK; goto ERR_OUT1;
} }
ret = memset_s(shellCB, sizeof(ShellCB), 0, sizeof(ShellCB)); ret = memset_s(shellCB, sizeof(ShellCB), 0, sizeof(ShellCB));
if (ret != SH_OK) { if (ret != SH_OK) {
@@ -172,9 +176,7 @@ int main(int argc, char **argv)
g_shellCB = shellCB; g_shellCB = shellCB;
ret = OsShellCreateTask(shellCB); ret = OsShellCreateTask(shellCB);
if (ret != SH_OK) { if (ret != SH_OK) {
ShellDeinit(shellCB); goto ERR_OUT3;
g_shellCB = NULL;
return ret;
} }
ShellEntry(shellCB); ShellEntry(shellCB);

View File

@@ -1465,7 +1465,7 @@ INT32 los_disk_init(const CHAR *diskName, const struct block_operations *bops,
ret = VnodeLookup(diskName, &blkDriver, 0); ret = VnodeLookup(diskName, &blkDriver, 0);
if (ret < 0) { if (ret < 0) {
VnodeDrop(); VnodeDrop();
PRINT_ERR("disk_init : %s, failed to find the vnode, ERRNO=%d\n", diskName, ret); ret = ENOENT;
goto DISK_FIND_ERROR; goto DISK_FIND_ERROR;
} }
struct block_operations *bops2 = (struct block_operations *)((struct drv_data *)blkDriver->data)->ops; struct block_operations *bops2 = (struct block_operations *)((struct drv_data *)blkDriver->data)->ops;

View File

@@ -39,10 +39,6 @@ kernel_module(module_name) {
include_dirs = [ "$LITEOSTOPDIR/fs/jffs2/include" ] include_dirs = [ "$LITEOSTOPDIR/fs/jffs2/include" ]
if (defined(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7)) {
include_dirs += [ "//device/qemu/drivers/cfiflash" ]
}
public_configs = [ ":public" ] public_configs = [ ":public" ]
} }

View File

@@ -36,10 +36,6 @@ LOCAL_SRCS := $(wildcard src/*.c)
LOCAL_INCLUDE := \ LOCAL_INCLUDE := \
-I $(LITEOSTOPDIR)/fs/jffs2/include -I $(LITEOSTOPDIR)/fs/jffs2/include
ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y)
LOCAL_INCLUDE += -I $(LITEOSTOPDIR)/../../device/qemu/drivers/cfiflash
endif
LOCAL_FLAGS := $(LOCAL_INCLUDE) LOCAL_FLAGS := $(LOCAL_INCLUDE)
include $(MODULE) include $(MODULE)

View File

@@ -39,11 +39,6 @@
#include "fs/driver.h" #include "fs/driver.h"
#include "mtd/mtd_legacy_lite.h" #include "mtd/mtd_legacy_lite.h"
#ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
#include "cfiflash.h"
#endif
#define DRIVER_NAME_ADD_SIZE 3 #define DRIVER_NAME_ADD_SIZE 3
pthread_mutex_t g_mtdPartitionLock = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t g_mtdPartitionLock = PTHREAD_MUTEX_INITIALIZER;
@@ -134,17 +129,10 @@ static VOID MtdNorParamAssign(partition_param *spinorParam, const struct MtdDev
* you can change the SPIBLK_NAME or SPICHR_NAME to NULL. * you can change the SPIBLK_NAME or SPICHR_NAME to NULL.
*/ */
spinorParam->flash_mtd = (struct MtdDev *)spinorMtd; spinorParam->flash_mtd = (struct MtdDev *)spinorMtd;
#ifndef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
spinorParam->flash_ops = GetDevSpinorOps(); spinorParam->flash_ops = GetDevSpinorOps();
spinorParam->char_ops = GetMtdCharFops(); spinorParam->char_ops = GetMtdCharFops();
spinorParam->blockname = SPIBLK_NAME; spinorParam->blockname = SPIBLK_NAME;
spinorParam->charname = SPICHR_NAME; spinorParam->charname = SPICHR_NAME;
#else
spinorParam->flash_ops = GetCfiBlkOps();
spinorParam->char_ops = NULL;
spinorParam->blockname = CFI_DRIVER;
spinorParam->charname = NULL;
#endif
spinorParam->partition_head = g_spinorPartitionHead; spinorParam->partition_head = g_spinorPartitionHead;
spinorParam->block_size = spinorMtd->eraseSize; spinorParam->block_size = spinorMtd->eraseSize;
} }
@@ -158,11 +146,7 @@ static VOID MtdDeinitSpinorParam(VOID)
static partition_param *MtdInitSpinorParam(partition_param *spinorParam) static partition_param *MtdInitSpinorParam(partition_param *spinorParam)
{ {
#ifndef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
struct MtdDev *spinorMtd = GetMtd("spinor"); struct MtdDev *spinorMtd = GetMtd("spinor");
#else
struct MtdDev *spinorMtd = GetCfiMtdDev();
#endif
if (spinorMtd == NULL) { if (spinorMtd == NULL) {
return NULL; return NULL;
} }

View File

@@ -2778,7 +2778,11 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
ri->version = cpu_to_je32(++f->highest_version); ri->version = cpu_to_je32(++f->highest_version);
+ ri->uid = cpu_to_je16(inode->i_uid); + ri->uid = cpu_to_je16(inode->i_uid);
+ ri->gid = cpu_to_je16(inode->i_gid); + ri->gid = cpu_to_je16(inode->i_gid);
+
- ri->uid = cpu_to_je16((ivalid & ATTR_UID)?
- from_kuid(&init_user_ns, iattr->ia_uid):i_uid_read(inode));
- ri->gid = cpu_to_je16((ivalid & ATTR_GID)?
- from_kgid(&init_user_ns, iattr->ia_gid):i_gid_read(inode));
+ if (ivalid & CHG_UID) { + if (ivalid & CHG_UID) {
+ if (((c_uid != inode->i_uid) || (attr->attr_chg_uid != inode->i_uid)) && (!IsCapPermit(CAP_CHOWN))) { + if (((c_uid != inode->i_uid) || (attr->attr_chg_uid != inode->i_uid)) && (!IsCapPermit(CAP_CHOWN))) {
+ jffs2_complete_reservation(c); + jffs2_complete_reservation(c);
@@ -2800,16 +2804,7 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
+ ri->gid = cpu_to_je16(attr->attr_chg_gid); + ri->gid = cpu_to_je16(attr->attr_chg_gid);
+ } + }
+ } + }
+
- ri->uid = cpu_to_je16((ivalid & ATTR_UID)?
- from_kuid(&init_user_ns, iattr->ia_uid):i_uid_read(inode));
- ri->gid = cpu_to_je16((ivalid & ATTR_GID)?
- from_kgid(&init_user_ns, iattr->ia_gid):i_gid_read(inode));
-
- if (ivalid & ATTR_MODE)
- ri->mode = cpu_to_jemode(iattr->ia_mode);
- else
- ri->mode = cpu_to_jemode(inode->i_mode);
+ if (ivalid & CHG_MODE) { + if (ivalid & CHG_MODE) {
+ if (!IsCapPermit(CAP_FOWNER) && (c_uid != inode->i_uid)) { + if (!IsCapPermit(CAP_FOWNER) && (c_uid != inode->i_uid)) {
+ jffs2_complete_reservation(c); + jffs2_complete_reservation(c);
@@ -2823,6 +2818,10 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
+ } + }
+ } + }
- if (ivalid & ATTR_MODE)
- ri->mode = cpu_to_jemode(iattr->ia_mode);
- else
- ri->mode = cpu_to_jemode(inode->i_mode);
+ if (ivalid & CHG_ATIME) { + if (ivalid & CHG_ATIME) {
+ if ((c_uid != inode->i_uid) || (attr->attr_chg_uid != inode->i_uid)) { + if ((c_uid != inode->i_uid) || (attr->attr_chg_uid != inode->i_uid)) {
+ return -EPERM; + return -EPERM;
@@ -2832,7 +2831,7 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
+ } else { + } else {
+ ri->atime = cpu_to_je32(inode->i_atime); + ri->atime = cpu_to_je32(inode->i_atime);
+ } + }
+
+ if (ivalid & CHG_MTIME) { + if (ivalid & CHG_MTIME) {
+ if ((c_uid != inode->i_uid) || (attr->attr_chg_uid != inode->i_uid)) { + if ((c_uid != inode->i_uid) || (attr->attr_chg_uid != inode->i_uid)) {
+ return -EPERM; + return -EPERM;
@@ -2884,7 +2883,7 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
if (IS_ERR(new_metadata)) { if (IS_ERR(new_metadata)) {
jffs2_complete_reservation(c); jffs2_complete_reservation(c);
jffs2_free_raw_inode(ri); jffs2_free_raw_inode(ri);
@@ -147,23 +140,20 @@ int jffs2_do_setattr (struct inode *inod @@ -147,23 +140,20 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
return PTR_ERR(new_metadata); return PTR_ERR(new_metadata);
} }
/* It worked. Update the inode */ /* It worked. Update the inode */
@@ -2917,7 +2916,7 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
f->metadata = NULL; f->metadata = NULL;
} else { } else {
f->metadata = new_metadata; f->metadata = new_metadata;
@@ -182,315 +172,201 @@ int jffs2_do_setattr (struct inode *inod @@ -182,315 +172,201 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
We are protected from a simultaneous write() extending i_size We are protected from a simultaneous write() extending i_size
back past iattr->ia_size, because do_truncate() holds the back past iattr->ia_size, because do_truncate() holds the
generic inode semaphore. */ generic inode semaphore. */
@@ -2936,31 +2935,43 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
{ {
- struct inode *inode = d_inode(dentry); - struct inode *inode = d_inode(dentry);
- int rc; - int rc;
-
- rc = setattr_prepare(dentry, iattr);
- if (rc)
- return rc;
-
- rc = jffs2_do_setattr(inode, iattr);
- if (!rc && (iattr->ia_valid & ATTR_MODE))
- rc = posix_acl_chmod(inode, inode->i_mode);
+ /* We can forget about this inode for now - drop all + /* We can forget about this inode for now - drop all
+ * the nodelists associated with it, etc. + * the nodelists associated with it, etc.
+ */ + */
+ struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb); + struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
+ struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); + struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
+
+ jffs2_do_clear_inode(c, f);
+}
- rc = setattr_prepare(dentry, iattr);
- if (rc)
- return rc;
+static struct jffs2_inode *ilookup(struct super_block *sb, uint32_t ino)
+{
+ struct jffs2_inode *node = NULL;
- rc = jffs2_do_setattr(inode, iattr);
- if (!rc && (iattr->ia_valid & ATTR_MODE))
- rc = posix_acl_chmod(inode, inode->i_mode);
+ if (sb->s_root == NULL) {
+ return NULL;
+ }
- return rc; - return rc;
+ jffs2_do_clear_inode(c, f); + // Check for this inode in the cache
+ Jffs2NodeLock();
+ (void)Jffs2HashGet(&sb->s_node_hash_lock, &sb->s_node_hash[0], sb, ino, &node);
+ Jffs2NodeUnlock();
+ return node;
} }
-int jffs2_statfs(struct dentry *dentry, struct kstatfs *buf) -int jffs2_statfs(struct dentry *dentry, struct kstatfs *buf)
+static struct jffs2_inode *ilookup(struct super_block *sb, uint32_t ino) +struct jffs2_inode *new_inode(struct super_block *sb)
{ {
- struct jffs2_sb_info *c = JFFS2_SB_INFO(dentry->d_sb); - struct jffs2_sb_info *c = JFFS2_SB_INFO(dentry->d_sb);
- unsigned long avail; - unsigned long avail;
+ struct jffs2_inode *node = NULL; -
- buf->f_type = JFFS2_SUPER_MAGIC; - buf->f_type = JFFS2_SUPER_MAGIC;
- buf->f_bsize = 1 << PAGE_SHIFT; - buf->f_bsize = 1 << PAGE_SHIFT;
- buf->f_blocks = c->flash_size >> PAGE_SHIFT; - buf->f_blocks = c->flash_size >> PAGE_SHIFT;
@@ -2979,47 +2990,35 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
- spin_unlock(&c->erase_completion_lock); - spin_unlock(&c->erase_completion_lock);
- -
- buf->f_bavail = buf->f_bfree = avail >> PAGE_SHIFT; - buf->f_bavail = buf->f_bfree = avail >> PAGE_SHIFT;
+ if (sb->s_root == NULL) { + struct jffs2_inode *inode = NULL;
+ return NULL;
+ }
- return 0; - return 0;
+ // Check for this inode in the cache -}
+ Jffs2NodeLock(); + inode = zalloc(sizeof (struct jffs2_inode));
+ (void)Jffs2HashGet(&sb->s_node_hash_lock, &sb->s_node_hash[0], sb, ino, &node); + if (inode == NULL)
+ Jffs2NodeUnlock(); + return 0;
+ return node;
} + D2(PRINTK("malloc new_inode %x ####################################\n",
+ inode));
-
-void jffs2_evict_inode (struct inode *inode) -void jffs2_evict_inode (struct inode *inode)
+struct jffs2_inode *new_inode(struct super_block *sb) -{
{
- /* We can forget about this inode for now - drop all - /* We can forget about this inode for now - drop all
- * the nodelists associated with it, etc. - * the nodelists associated with it, etc.
- */ - */
- struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb); - struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
- struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); - struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
+ struct jffs2_inode *inode = NULL; + inode->i_sb = sb;
+ inode->i_ino = 1;
+ inode->i_nlink = 1; // Let JFFS2 manage the link count
+ inode->i_size = 0;
+ LOS_ListInit((&(inode->i_hashlist)));
- jffs2_dbg(1, "%s(): ino #%lu mode %o\n", - jffs2_dbg(1, "%s(): ino #%lu mode %o\n",
- __func__, inode->i_ino, inode->i_mode); - __func__, inode->i_ino, inode->i_mode);
- truncate_inode_pages_final(&inode->i_data); - truncate_inode_pages_final(&inode->i_data);
- clear_inode(inode); - clear_inode(inode);
- jffs2_do_clear_inode(c, f); - jffs2_do_clear_inode(c, f);
+ inode = zalloc(sizeof (struct jffs2_inode));
+ if (inode == NULL)
+ return 0;
+
+ D2(PRINTK("malloc new_inode %x ####################################\n",
+ inode));
+
+ inode->i_sb = sb;
+ inode->i_ino = 1;
+ inode->i_nlink = 1; // Let JFFS2 manage the link count
+ inode->i_size = 0;
+ LOS_ListInit((&(inode->i_hashlist)));
+
+ return inode; + return inode;
} }
@@ -3084,16 +3083,16 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
- inode->i_ctime = ITIME(je32_to_cpu(latest_node.ctime)); - inode->i_ctime = ITIME(je32_to_cpu(latest_node.ctime));
- -
- set_nlink(inode, f->inocache->pino_nlink); - set_nlink(inode, f->inocache->pino_nlink);
-
- inode->i_blocks = (inode->i_size + 511) >> 9;
+ inode->i_atime = je32_to_cpu(latest_node.atime); + inode->i_atime = je32_to_cpu(latest_node.atime);
+ inode->i_mtime = je32_to_cpu(latest_node.mtime); + inode->i_mtime = je32_to_cpu(latest_node.mtime);
+ inode->i_ctime = je32_to_cpu(latest_node.ctime); + inode->i_ctime = je32_to_cpu(latest_node.ctime);
+ inode->i_nlink = f->inocache->pino_nlink; + inode->i_nlink = f->inocache->pino_nlink;
- inode->i_blocks = (inode->i_size + 511) >> 9; - switch (inode->i_mode & S_IFMT) {
+ (void)mutex_unlock(&f->sem); + (void)mutex_unlock(&f->sem);
- switch (inode->i_mode & S_IFMT) {
-
- case S_IFLNK: - case S_IFLNK:
- inode->i_op = &jffs2_symlink_inode_operations; - inode->i_op = &jffs2_symlink_inode_operations;
- inode->i_link = f->target; - inode->i_link = f->target;
@@ -3163,20 +3162,21 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
jffs2_dbg(1, "jffs2_read_inode() returning\n"); jffs2_dbg(1, "jffs2_read_inode() returning\n");
- unlock_new_inode(inode); - unlock_new_inode(inode);
- return inode; - return inode;
- + Jffs2NodeUnlock();
-error_io: -error_io:
- ret = -EIO; - ret = -EIO;
-error: -error:
- mutex_unlock(&f->sem); - mutex_unlock(&f->sem);
- iget_failed(inode); - iget_failed(inode);
- return ERR_PTR(ret); - return ERR_PTR(ret);
-} + return inode;
+ Jffs2NodeUnlock(); }
-void jffs2_dirty_inode(struct inode *inode, int flags) -void jffs2_dirty_inode(struct inode *inode, int flags)
-{ -{
- struct iattr iattr; - struct iattr iattr;
-
- if (!(inode->i_state & I_DIRTY_DATASYNC)) { - if (!(inode->i_state & I_DIRTY_DATASYNC)) {
- jffs2_dbg(2, "%s(): not calling setattr() for ino #%lu\n", - jffs2_dbg(2, "%s(): not calling setattr() for ino #%lu\n",
- __func__, inode->i_ino); - __func__, inode->i_ino);
@@ -3195,16 +3195,19 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
- iattr.ia_ctime = inode->i_ctime; - iattr.ia_ctime = inode->i_ctime;
- -
- jffs2_do_setattr(inode, &iattr); - jffs2_do_setattr(inode, &iattr);
+ return inode; -}
} +// -------------------------------------------------------------------------
+// Decrement the reference count on an inode. If this makes the ref count
+// zero, then this inode can be freed.
-int jffs2_do_remount_fs(struct super_block *sb, struct fs_context *fc) -int jffs2_do_remount_fs(struct super_block *sb, struct fs_context *fc)
-{ +int jffs2_iput(struct jffs2_inode *i)
{
- struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); - struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);
- -
- if (c->flags & JFFS2_SB_FLAG_RO && !sb_rdonly(sb)) - if (c->flags & JFFS2_SB_FLAG_RO && !sb_rdonly(sb))
- return -EROFS; - return -EROFS;
-
- /* We stop if it was running, then restart if it needs to. - /* We stop if it was running, then restart if it needs to.
- This also catches the case where it was stopped and this - This also catches the case where it was stopped and this
- is just a remount to restart it. - is just a remount to restart it.
@@ -3215,12 +3218,9 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
- jffs2_flush_wbuf_pad(c); - jffs2_flush_wbuf_pad(c);
- mutex_unlock(&c->alloc_sem); - mutex_unlock(&c->alloc_sem);
- } - }
+// ------------------------------------------------------------------------- -
+// Decrement the reference count on an inode. If this makes the ref count - if (!(fc->sb_flags & SB_RDONLY))
+// zero, then this inode can be freed. - jffs2_start_garbage_collect_thread(c);
+
+int jffs2_iput(struct jffs2_inode *i)
+{
+ // Called in jffs2_find + // Called in jffs2_find
+ // (and jffs2_open and jffs2_ops_mkdir?) + // (and jffs2_open and jffs2_ops_mkdir?)
+ // super.c jffs2_fill_super, + // super.c jffs2_fill_super,
@@ -3242,9 +3242,6 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
+ free(i); + free(i);
+ Jffs2NodeUnlock(); + Jffs2NodeUnlock();
- if (!(fc->sb_flags & SB_RDONLY))
- jffs2_start_garbage_collect_thread(c);
-
- fc->sb_flags |= SB_NOATIME; - fc->sb_flags |= SB_NOATIME;
return 0; return 0;
} }
@@ -3351,7 +3348,7 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
{ {
/* /*
* Pick a inocache hash size based on the size of the medium. * Pick a inocache hash size based on the size of the medium.
@@ -510,117 +386,17 @@ static int calculate_inocache_hashsize(u @@ -510,118 +386,17 @@ static int calculate_inocache_hashsize(uint32_t flash_size)
return hashsize; return hashsize;
} }
@@ -3447,8 +3444,9 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
- jffs2_free_ino_caches(c); - jffs2_free_ino_caches(c);
- jffs2_free_raw_node_refs(c); - jffs2_free_raw_node_refs(c);
- kvfree(c->blocks); - kvfree(c->blocks);
- out_inohash:
- jffs2_clear_xattr_subsystem(c); - jffs2_clear_xattr_subsystem(c);
- jffs2_sum_exit(c);
- out_inohash:
- kfree(c->inocache_list); - kfree(c->inocache_list);
- out_wbuf: - out_wbuf:
- jffs2_flash_cleanup(c); - jffs2_flash_cleanup(c);
@@ -3457,8 +3455,7 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
-} -}
- -
void jffs2_gc_release_inode(struct jffs2_sb_info *c, void jffs2_gc_release_inode(struct jffs2_sb_info *c,
- struct jffs2_inode_info *f) struct jffs2_inode_info *f)
+ struct jffs2_inode_info *f)
{ {
- iput(OFNI_EDONI_2SFFJ(f)); - iput(OFNI_EDONI_2SFFJ(f));
+ struct jffs2_inode *node = OFNI_EDONI_2SFFJ(f); + struct jffs2_inode *node = OFNI_EDONI_2SFFJ(f);
@@ -3473,7 +3470,7 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
struct jffs2_inode_cache *ic; struct jffs2_inode_cache *ic;
if (unlinked) { if (unlinked) {
@@ -668,72 +444,9 @@ struct jffs2_inode_info *jffs2_gc_fetch_ @@ -669,72 +444,9 @@ struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c,
Just iget() it, and if read_inode() is necessary that's OK. Just iget() it, and if read_inode() is necessary that's OK.
*/ */
inode = jffs2_iget(OFNI_BS_2SFFJ(c), inum); inode = jffs2_iget(OFNI_BS_2SFFJ(c), inum);
@@ -5565,7 +5562,7 @@ diff -Nupr old/fs/jffs2/scan.c new/fs/jffs2/scan.c
#define DEFAULT_EMPTY_SCAN_SIZE 256 #define DEFAULT_EMPTY_SCAN_SIZE 256
@@ -74,7 +73,7 @@ static int file_dirty(struct jffs2_sb_in @@ -74,7 +73,7 @@ static int file_dirty(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
return ret; return ret;
if ((ret = jffs2_scan_dirty_space(c, jeb, jeb->free_size))) if ((ret = jffs2_scan_dirty_space(c, jeb, jeb->free_size)))
return ret; return ret;
@@ -5574,15 +5571,13 @@ diff -Nupr old/fs/jffs2/scan.c new/fs/jffs2/scan.c
think it's recoverable now. */ think it's recoverable now. */
jeb->dirty_size += jeb->wasted_size; jeb->dirty_size += jeb->wasted_size;
c->dirty_size += jeb->wasted_size; c->dirty_size += jeb->wasted_size;
@@ -95,40 +94,26 @@ int jffs2_scan_medium(struct jffs2_sb_in @@ -95,40 +94,26 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
unsigned char *flashbuf = NULL; unsigned char *flashbuf = NULL;
uint32_t buf_size = 0; uint32_t buf_size = 0;
struct jffs2_summary *s = NULL; /* summary info collected by the scan process */ struct jffs2_summary *s = NULL; /* summary info collected by the scan process */
-#ifndef __ECOS -#ifndef __ECOS
- size_t pointlen, try_size; - size_t pointlen, try_size;
+ struct super_block *sb = NULL; -
+ struct MtdNorDev *device = NULL;
- ret = mtd_point(c->mtd, 0, c->mtd->size, &pointlen, - ret = mtd_point(c->mtd, 0, c->mtd->size, &pointlen,
- (void **)&flashbuf, NULL); - (void **)&flashbuf, NULL);
- if (!ret && pointlen < c->mtd->size) { - if (!ret && pointlen < c->mtd->size) {
@@ -5595,6 +5590,9 @@ diff -Nupr old/fs/jffs2/scan.c new/fs/jffs2/scan.c
- if (ret && ret != -EOPNOTSUPP) - if (ret && ret != -EOPNOTSUPP)
- jffs2_dbg(1, "MTD point failed %d\n", ret); - jffs2_dbg(1, "MTD point failed %d\n", ret);
-#endif -#endif
+ struct super_block *sb = NULL;
+ struct MtdNorDev *device = NULL;
+
if (!flashbuf) { if (!flashbuf) {
/* For NAND it's quicker to read a whole eraseblock at a time, /* For NAND it's quicker to read a whole eraseblock at a time,
apparently */ apparently */
@@ -5622,7 +5620,7 @@ diff -Nupr old/fs/jffs2/scan.c new/fs/jffs2/scan.c
} }
if (jffs2_sum_active()) { if (jffs2_sum_active()) {
@@ -140,7 +125,9 @@ int jffs2_scan_medium(struct jffs2_sb_in @@ -140,7 +125,9 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
} }
} }
@@ -5633,7 +5631,7 @@ diff -Nupr old/fs/jffs2/scan.c new/fs/jffs2/scan.c
struct jffs2_eraseblock *jeb = &c->blocks[i]; struct jffs2_eraseblock *jeb = &c->blocks[i];
cond_resched(); cond_resched();
@@ -269,19 +256,12 @@ int jffs2_scan_medium(struct jffs2_sb_in @@ -269,14 +256,10 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
ret = -EIO; ret = -EIO;
goto out; goto out;
} }
@@ -5643,20 +5641,13 @@ diff -Nupr old/fs/jffs2/scan.c new/fs/jffs2/scan.c
} }
ret = 0; ret = 0;
out: out:
- if (buf_size) - jffs2_sum_reset_collected(s);
- kfree(flashbuf);
-#ifndef __ECOS
- else
- mtd_unpoint(c->mtd, 0, c->mtd->size);
-#endif
- kfree(s); - kfree(s);
+
+ kfree(flashbuf); + kfree(flashbuf);
+ out_buf:
return ret; if (buf_size)
} kfree(flashbuf);
@@ -413,7 +396,7 @@ static int jffs2_scan_xref_node(struct jffs2_sb_info *c, struct jffs2_eraseblock
@@ -411,7 +391,7 @@ static int jffs2_scan_xref_node(struct j
if (!ref) if (!ref)
return -ENOMEM; return -ENOMEM;
@@ -5665,7 +5656,7 @@ diff -Nupr old/fs/jffs2/scan.c new/fs/jffs2/scan.c
* and AFTER xattr_ref is marked as a dead xref, * and AFTER xattr_ref is marked as a dead xref,
* ref->xid is used to store 32bit xid, xd is not used * ref->xid is used to store 32bit xid, xd is not used
* ref->ino is used to store 32bit inode-number, ic is not used * ref->ino is used to store 32bit inode-number, ic is not used
@@ -484,10 +464,10 @@ static int jffs2_scan_eraseblock (struct @@ -486,10 +469,10 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
struct jffs2_sum_marker *sm; struct jffs2_sum_marker *sm;
void *sumptr = NULL; void *sumptr = NULL;
uint32_t sumlen; uint32_t sumlen;
@@ -5678,7 +5669,7 @@ diff -Nupr old/fs/jffs2/scan.c new/fs/jffs2/scan.c
if (je32_to_cpu(sm->magic) == JFFS2_SUM_MAGIC) { if (je32_to_cpu(sm->magic) == JFFS2_SUM_MAGIC) {
sumptr = buf + je32_to_cpu(sm->offset); sumptr = buf + je32_to_cpu(sm->offset);
sumlen = c->sector_size - je32_to_cpu(sm->offset); sumlen = c->sector_size - je32_to_cpu(sm->offset);
@@ -500,13 +480,13 @@ static int jffs2_scan_eraseblock (struct @@ -502,13 +485,13 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
buf_len = sizeof(*sm); buf_len = sizeof(*sm);
/* Read as much as we want into the _end_ of the preallocated buffer */ /* Read as much as we want into the _end_ of the preallocated buffer */
@@ -5695,7 +5686,7 @@ diff -Nupr old/fs/jffs2/scan.c new/fs/jffs2/scan.c
if (je32_to_cpu(sm->magic) == JFFS2_SUM_MAGIC) { if (je32_to_cpu(sm->magic) == JFFS2_SUM_MAGIC) {
sumlen = c->sector_size - je32_to_cpu(sm->offset); sumlen = c->sector_size - je32_to_cpu(sm->offset);
sumptr = buf + buf_size - sumlen; sumptr = buf + buf_size - sumlen;
@@ -521,18 +501,15 @@ static int jffs2_scan_eraseblock (struct @@ -523,18 +506,15 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
sumptr = kmalloc(sumlen, GFP_KERNEL); sumptr = kmalloc(sumlen, GFP_KERNEL);
if (!sumptr) if (!sumptr)
return -ENOMEM; return -ENOMEM;
@@ -5718,7 +5709,7 @@ diff -Nupr old/fs/jffs2/scan.c new/fs/jffs2/scan.c
} }
} }
@@ -543,7 +520,7 @@ static int jffs2_scan_eraseblock (struct @@ -545,7 +525,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
if (buf_size && sumlen > buf_size) if (buf_size && sumlen > buf_size)
kfree(sumptr); kfree(sumptr);
@@ -5727,7 +5718,7 @@ diff -Nupr old/fs/jffs2/scan.c new/fs/jffs2/scan.c
If it returns positive, that's a block classification If it returns positive, that's a block classification
(i.e. BLK_STATE_xxx) so return that too. (i.e. BLK_STATE_xxx) so return that too.
If it returns zero, fall through to full scan. */ If it returns zero, fall through to full scan. */
@@ -605,7 +582,7 @@ full_scan: @@ -607,7 +587,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
/* Now ofs is a complete physical flash offset as it always was... */ /* Now ofs is a complete physical flash offset as it always was... */
ofs += jeb->offset; ofs += jeb->offset;
@@ -5736,7 +5727,7 @@ diff -Nupr old/fs/jffs2/scan.c new/fs/jffs2/scan.c
dbg_summary("no summary found in jeb 0x%08x. Apply original scan.\n",jeb->offset); dbg_summary("no summary found in jeb 0x%08x. Apply original scan.\n",jeb->offset);
@@ -698,7 +675,7 @@ scan_more: @@ -700,7 +680,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
scan_end = buf_len; scan_end = buf_len;
goto more_empty; goto more_empty;
} }
@@ -5745,7 +5736,7 @@ diff -Nupr old/fs/jffs2/scan.c new/fs/jffs2/scan.c
/* See how much more there is to read in this eraseblock... */ /* See how much more there is to read in this eraseblock... */
buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs);
if (!buf_len) { if (!buf_len) {
@@ -948,7 +925,7 @@ scan_more: @@ -950,7 +930,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
jffs2_dbg(1, "Block at 0x%08x: free 0x%08x, dirty 0x%08x, unchecked 0x%08x, used 0x%08x, wasted 0x%08x\n", jffs2_dbg(1, "Block at 0x%08x: free 0x%08x, dirty 0x%08x, unchecked 0x%08x, used 0x%08x, wasted 0x%08x\n",
jeb->offset, jeb->free_size, jeb->dirty_size, jeb->offset, jeb->free_size, jeb->dirty_size,
jeb->unchecked_size, jeb->used_size, jeb->wasted_size); jeb->unchecked_size, jeb->used_size, jeb->wasted_size);
@@ -5754,7 +5745,7 @@ diff -Nupr old/fs/jffs2/scan.c new/fs/jffs2/scan.c
/* mark_node_obsolete can add to wasted !! */ /* mark_node_obsolete can add to wasted !! */
if (jeb->wasted_size) { if (jeb->wasted_size) {
jeb->dirty_size += jeb->wasted_size; jeb->dirty_size += jeb->wasted_size;
@@ -976,7 +953,6 @@ struct jffs2_inode_cache *jffs2_scan_mak @@ -978,7 +958,6 @@ struct jffs2_inode_cache *jffs2_scan_make_ino_cache(struct jffs2_sb_info *c, uin
pr_notice("%s(): allocation of inode cache failed\n", __func__); pr_notice("%s(): allocation of inode cache failed\n", __func__);
return NULL; return NULL;
} }
@@ -5762,7 +5753,7 @@ diff -Nupr old/fs/jffs2/scan.c new/fs/jffs2/scan.c
ic->ino = ino; ic->ino = ino;
ic->nodes = (void *)ic; ic->nodes = (void *)ic;
@@ -1067,7 +1043,7 @@ static int jffs2_scan_dirent_node(struct @@ -1069,7 +1048,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
pseudo_random += je32_to_cpu(rd->version); pseudo_random += je32_to_cpu(rd->version);
/* Should never happen. Did. (OLPC trac #4184)*/ /* Should never happen. Did. (OLPC trac #4184)*/
@@ -5771,7 +5762,7 @@ diff -Nupr old/fs/jffs2/scan.c new/fs/jffs2/scan.c
if (checkedlen < rd->nsize) { if (checkedlen < rd->nsize) {
pr_err("Dirent at %08x has zeroes in name. Truncating to %d chars\n", pr_err("Dirent at %08x has zeroes in name. Truncating to %d chars\n",
ofs, checkedlen); ofs, checkedlen);
@@ -1079,7 +1055,7 @@ static int jffs2_scan_dirent_node(struct @@ -1081,7 +1060,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
memcpy(&fd->name, rd->name, checkedlen); memcpy(&fd->name, rd->name, checkedlen);
fd->name[checkedlen] = 0; fd->name[checkedlen] = 0;
@@ -5780,7 +5771,248 @@ diff -Nupr old/fs/jffs2/scan.c new/fs/jffs2/scan.c
if (crc != je32_to_cpu(rd->name_crc)) { if (crc != je32_to_cpu(rd->name_crc)) {
pr_notice("%s(): Name CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", pr_notice("%s(): Name CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
__func__, ofs, je32_to_cpu(rd->name_crc), crc); __func__, ofs, je32_to_cpu(rd->name_crc), crc);
@@ -1104,7 +1080,7 @@ static int jffs2_scan_dirent_node(struct @@ -1106,7 +1085,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
fd->next = NULL;
fd->version = je32_to_cpu(rd->version);
fd->ino = je32_to_cpu(rd->ino);
- fd->nhash = full_name_hash(NULL, fd->name, checkedlen);
+ fd->nhash = full_name_hash(fd->name, checkedlen);
fd->type = rd->type;
jffs2_add_fd_to_list(c, fd, &ic->scan_dents);
diff
@@ -9,18 +9,17 @@
*
*/
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/slab.h>
-#include <linux/mtd/mtd.h>
#include <linux/pagemap.h>
-#include <linux/crc32.h>
#include <linux/compiler.h>
#include "nodelist.h"
#include "summary.h"
#include "debug.h"
+#include "mtd_dev.h"
+#include "los_typedef.h"
+#include "los_crc32.h"
#define DEFAULT_EMPTY_SCAN_SIZE 256
@@ -74,7 +73,7 @@ static int file_dirty(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
return ret;
if ((ret = jffs2_scan_dirty_space(c, jeb, jeb->free_size)))
return ret;
- /* Turned wasted size into dirty, since we apparently
+ /* Turned wasted size into dirty, since we apparently
think it's recoverable now. */
jeb->dirty_size += jeb->wasted_size;
c->dirty_size += jeb->wasted_size;
@@ -95,40 +94,26 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
unsigned char *flashbuf = NULL;
uint32_t buf_size = 0;
struct jffs2_summary *s = NULL; /* summary info collected by the scan process */
-#ifndef __ECOS
- size_t pointlen, try_size;
-
- ret = mtd_point(c->mtd, 0, c->mtd->size, &pointlen,
- (void **)&flashbuf, NULL);
- if (!ret && pointlen < c->mtd->size) {
- /* Don't muck about if it won't let us point to the whole flash */
- jffs2_dbg(1, "MTD point returned len too short: 0x%zx\n",
- pointlen);
- mtd_unpoint(c->mtd, 0, pointlen);
- flashbuf = NULL;
- }
- if (ret && ret != -EOPNOTSUPP)
- jffs2_dbg(1, "MTD point failed %d\n", ret);
-#endif
+ struct super_block *sb = NULL;
+ struct MtdNorDev *device = NULL;
+
if (!flashbuf) {
/* For NAND it's quicker to read a whole eraseblock at a time,
apparently */
if (jffs2_cleanmarker_oob(c))
- try_size = c->sector_size;
+ buf_size = c->sector_size;
else
- try_size = PAGE_SIZE;
+ buf_size = PAGE_SIZE;
jffs2_dbg(1, "Trying to allocate readbuf of %zu "
- "bytes\n", try_size);
+ "bytes\n", buf_size);
- flashbuf = mtd_kmalloc_up_to(c->mtd, &try_size);
+ flashbuf = kmalloc(buf_size, GFP_KERNEL);
if (!flashbuf)
return -ENOMEM;
jffs2_dbg(1, "Allocated readbuf of %zu bytes\n",
- try_size);
-
- buf_size = (uint32_t)try_size;
+ buf_size);
}
if (jffs2_sum_active()) {
@@ -140,7 +125,9 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
}
}
- for (i=0; i<c->nr_blocks; i++) {
+ sb = OFNI_BS_2SFFJ(c);
+ device = (struct MtdNorDev*)(sb->s_dev);
+ for (i=device->blockStart; i<c->nr_blocks + device->blockStart; i++) {
struct jffs2_eraseblock *jeb = &c->blocks[i];
cond_resched();
@@ -269,14 +256,10 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
ret = -EIO;
goto out;
}
- spin_lock(&c->erase_completion_lock);
- jffs2_garbage_collect_trigger(c);
- spin_unlock(&c->erase_completion_lock);
}
ret = 0;
out:
- jffs2_sum_reset_collected(s);
- kfree(s);
+ kfree(flashbuf);
out_buf:
if (buf_size)
kfree(flashbuf);
@@ -413,7 +396,7 @@ static int jffs2_scan_xref_node(struct jffs2_sb_info *c, struct jffs2_eraseblock
if (!ref)
return -ENOMEM;
- /* BEFORE jffs2_build_xattr_subsystem() called,
+ /* BEFORE jffs2_build_xattr_subsystem() called,
* and AFTER xattr_ref is marked as a dead xref,
* ref->xid is used to store 32bit xid, xd is not used
* ref->ino is used to store 32bit inode-number, ic is not used
@@ -486,10 +469,10 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
struct jffs2_sum_marker *sm;
void *sumptr = NULL;
uint32_t sumlen;
-
+
if (!buf_size) {
/* XIP case. Just look, point at the summary if it's there */
- sm = (void *)buf + c->sector_size - sizeof(*sm);
+ sm = (struct jffs2_sum_marker *)((uint8_t *)buf + c->sector_size - sizeof(*sm));
if (je32_to_cpu(sm->magic) == JFFS2_SUM_MAGIC) {
sumptr = buf + je32_to_cpu(sm->offset);
sumlen = c->sector_size - je32_to_cpu(sm->offset);
@@ -502,13 +485,13 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
buf_len = sizeof(*sm);
/* Read as much as we want into the _end_ of the preallocated buffer */
- err = jffs2_fill_scan_buf(c, buf + buf_size - buf_len,
+ err = jffs2_fill_scan_buf(c, buf + buf_size - buf_len,
jeb->offset + c->sector_size - buf_len,
- buf_len);
+ buf_len);
if (err)
return err;
- sm = (void *)buf + buf_size - sizeof(*sm);
+ sm = (struct jffs2_sum_marker *)((uint8_t *)buf + buf_size - sizeof(*sm));
if (je32_to_cpu(sm->magic) == JFFS2_SUM_MAGIC) {
sumlen = c->sector_size - je32_to_cpu(sm->offset);
sumptr = buf + buf_size - sumlen;
@@ -523,18 +506,15 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
sumptr = kmalloc(sumlen, GFP_KERNEL);
if (!sumptr)
return -ENOMEM;
- memcpy(sumptr + sumlen - buf_len, buf + buf_size - buf_len, buf_len);
+ memcpy((uint8_t *)sumptr + sumlen - buf_len, buf + buf_size - buf_len, buf_len);
}
if (buf_len < sumlen) {
/* Need to read more so that the entire summary node is present */
- err = jffs2_fill_scan_buf(c, sumptr,
+ err = jffs2_fill_scan_buf(c, sumptr,
jeb->offset + c->sector_size - sumlen,
- sumlen - buf_len);
- if (err) {
- if (sumlen > buf_size)
- kfree(sumptr);
+ sumlen - buf_len);
+ if (err)
return err;
- }
}
}
@@ -545,7 +525,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
if (buf_size && sumlen > buf_size)
kfree(sumptr);
- /* If it returns with a real error, bail.
+ /* If it returns with a real error, bail.
If it returns positive, that's a block classification
(i.e. BLK_STATE_xxx) so return that too.
If it returns zero, fall through to full scan. */
@@ -607,7 +587,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
/* Now ofs is a complete physical flash offset as it always was... */
ofs += jeb->offset;
- noise = 10;
+ noise = 1;
dbg_summary("no summary found in jeb 0x%08x. Apply original scan.\n",jeb->offset);
@@ -700,7 +680,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
scan_end = buf_len;
goto more_empty;
}
-
+
/* See how much more there is to read in this eraseblock... */
buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs);
if (!buf_len) {
@@ -950,7 +930,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
jffs2_dbg(1, "Block at 0x%08x: free 0x%08x, dirty 0x%08x, unchecked 0x%08x, used 0x%08x, wasted 0x%08x\n",
jeb->offset, jeb->free_size, jeb->dirty_size,
jeb->unchecked_size, jeb->used_size, jeb->wasted_size);
-
+
/* mark_node_obsolete can add to wasted !! */
if (jeb->wasted_size) {
jeb->dirty_size += jeb->wasted_size;
@@ -978,7 +958,6 @@ struct jffs2_inode_cache *jffs2_scan_make_ino_cache(struct jffs2_sb_info *c, uin
pr_notice("%s(): allocation of inode cache failed\n", __func__);
return NULL;
}
- memset(ic, 0, sizeof(*ic));
ic->ino = ino;
ic->nodes = (void *)ic;
@@ -1069,7 +1048,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
pseudo_random += je32_to_cpu(rd->version);
/* Should never happen. Did. (OLPC trac #4184)*/
- checkedlen = strnlen(rd->name, rd->nsize);
+ checkedlen = strnlen((const char *)rd->name, rd->nsize);
if (checkedlen < rd->nsize) {
pr_err("Dirent at %08x has zeroes in name. Truncating to %d chars\n",
ofs, checkedlen);
@@ -1081,7 +1060,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
memcpy(&fd->name, rd->name, checkedlen);
fd->name[checkedlen] = 0;
- crc = crc32(0, fd->name, checkedlen);
+ crc = crc32(0, fd->name, rd->nsize);
if (crc != je32_to_cpu(rd->name_crc)) {
pr_notice("%s(): Name CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
__func__, ofs, je32_to_cpu(rd->name_crc), crc);
@@ -1106,7 +1085,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
fd->next = NULL; fd->next = NULL;
fd->version = je32_to_cpu(rd->version); fd->version = je32_to_cpu(rd->version);
fd->ino = je32_to_cpu(rd->ino); fd->ino = je32_to_cpu(rd->ino);

View File

@@ -33,10 +33,6 @@ MODULE_NAME := rootfs
LOCAL_SRCS := $(wildcard los_rootfs.c los_bootargs.c) LOCAL_SRCS := $(wildcard los_rootfs.c los_bootargs.c)
ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y)
LOCAL_INCLUDE += -I $(LITEOSTOPDIR)/../../device/qemu/drivers/cfiflash
endif
LOCAL_FLAGS := $(LOCAL_INCLUDE) LOCAL_FLAGS := $(LOCAL_INCLUDE)
include $(MODULE) include $(MODULE)

View File

@@ -32,14 +32,10 @@
#include "los_base.h" #include "los_base.h"
#include "string.h" #include "string.h"
#if defined(LOSCFG_STORAGE_SPINOR) || defined(LOSCFG_STORAGE_SPINAND) || defined(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7) #if defined(LOSCFG_STORAGE_SPINOR) || defined(LOSCFG_STORAGE_SPINAND)
#include "mtd_list.h" #include "mtd_list.h"
#endif #endif
#ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
#include "cfiflash.h"
#endif
#ifdef LOSCFG_STORAGE_EMMC #ifdef LOSCFG_STORAGE_EMMC
#include "disk.h" #include "disk.h"
#endif #endif
@@ -98,19 +94,6 @@ INT32 LOS_GetCmdLine(VOID)
} }
#endif #endif
#ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
struct MtdDev *mtd = GetCfiMtdDev();
if (mtd == NULL) {
PRINT_ERR("Get CFI mtd failed!\n");
goto ERROUT;
}
g_alignSize = mtd->eraseSize;
ret = mtd->read(mtd, CFIFLASH_BOOTARGS_ADDR, COMMAND_LINE_SIZE, g_cmdLine);
if (ret == COMMAND_LINE_SIZE) {
return LOS_OK;
}
#endif
PRINT_ERR("Read cmdline error!\n"); PRINT_ERR("Read cmdline error!\n");
ERROUT: ERROUT:
free(g_cmdLine); free(g_cmdLine);

View File

@@ -37,15 +37,11 @@
#include "sys/stat.h" #include "sys/stat.h"
#include "sys/types.h" #include "sys/types.h"
#if defined(LOSCFG_STORAGE_SPINOR) || defined(LOSCFG_STORAGE_SPINAND) || defined(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7) #if defined(LOSCFG_STORAGE_SPINOR) || defined(LOSCFG_STORAGE_SPINAND)
#include "mtd_list.h" #include "mtd_list.h"
#include "mtd_partition.h" #include "mtd_partition.h"
#endif #endif
#ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
#include "cfiflash.h"
#endif
#ifdef LOSCFG_STORAGE_EMMC #ifdef LOSCFG_STORAGE_EMMC
#include "disk.h" #include "disk.h"
#include "ff.h" #include "ff.h"
@@ -128,14 +124,7 @@ STATIC INT32 AddEmmcParts(INT32 rootAddr, INT32 rootSize, INT32 userAddr, INT32
STATIC INT32 AddPartitions(CHAR *dev, UINT64 rootAddr, UINT64 rootSize, UINT64 userAddr, UINT64 userSize) STATIC INT32 AddPartitions(CHAR *dev, UINT64 rootAddr, UINT64 rootSize, UINT64 userAddr, UINT64 userSize)
{ {
#ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7 #if defined(LOSCFG_STORAGE_SPINOR) || defined(LOSCFG_STORAGE_SPINAND)
if ((strcmp(dev, "cfi-flash") == 0) && (rootAddr != CFIFLASH_ROOT_ADDR)) {
PRINT_ERR("Error rootAddr, must be %#0x!\n", CFIFLASH_ROOT_ADDR);
return LOS_NOK;
}
#endif
#if defined(LOSCFG_STORAGE_SPINOR) || defined(LOSCFG_STORAGE_SPINAND) || defined(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7)
INT32 ret; INT32 ret;
INT32 blk0 = 0; INT32 blk0 = 0;
INT32 blk2 = 2; INT32 blk2 = 2;

View File

@@ -59,12 +59,6 @@
#define ROOTFS_ADDR 0x600000 #define ROOTFS_ADDR 0x600000
#define ROOTFS_SIZE 0x800000 #define ROOTFS_SIZE 0x800000
#define USERFS_SIZE 0x80000 #define USERFS_SIZE 0x80000
#elif defined (LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7)
#define ROOT_DEV_NAME "/dev/cfiflash0"
#define USER_DEV_NAME "/dev/cfiflash2"
#define ROOTFS_ADDR CFIFLASH_ROOT_ADDR
#define ROOTFS_SIZE 0x1B00000
#define USERFS_SIZE (CFIFLASH_CAPACITY - ROOTFS_ADDR - ROOTFS_SIZE)
#elif defined (LOSCFG_STORAGE_EMMC) #elif defined (LOSCFG_STORAGE_EMMC)
#define ROOT_DEV_NAME "/dev/mmcblk0p0" #define ROOT_DEV_NAME "/dev/mmcblk0p0"
#ifdef LOSCFG_PLATFORM_PATCHFS #ifdef LOSCFG_PLATFORM_PATCHFS

View File

@@ -146,6 +146,7 @@ UINT32 OsKProcessPmUsage(LosVmSpace *kSpace, UINT32 *actualPm)
LosVmSpace *space = NULL; LosVmSpace *space = NULL;
LOS_DL_LIST *spaceList = NULL; LOS_DL_LIST *spaceList = NULL;
UINT32 UProcessUsed = 0; UINT32 UProcessUsed = 0;
UINT32 pmTmp;
if (actualPm == NULL) { if (actualPm == NULL) {
return 0; return 0;
@@ -166,7 +167,8 @@ UINT32 OsKProcessPmUsage(LosVmSpace *kSpace, UINT32 *actualPm)
if (space == LOS_GetKVmSpace()) { if (space == LOS_GetKVmSpace()) {
continue; continue;
} }
UProcessUsed += OsUProcessPmUsage(space, NULL, NULL); (VOID)OsUProcessPmUsage(space, NULL, &pmTmp);
UProcessUsed += pmTmp;
} }
(VOID)LOS_MuxRelease(vmSpaceListMux); (VOID)LOS_MuxRelease(vmSpaceListMux);

View File

@@ -233,8 +233,14 @@ static int HiLogWriteRingBuffer(unsigned char *buffer, size_t bufLen)
static void HiLogHeadInit(struct HiLogEntry *header, size_t len) static void HiLogHeadInit(struct HiLogEntry *header, size_t len)
{ {
struct timespec now = {0}; struct timespec now;
(void)clock_gettime(CLOCK_REALTIME, &now); int ret;
ret = clock_gettime(CLOCK_REALTIME, &now);
if (ret != 0) {
PRINTK("In %s line %d,clock_gettime fail\n", __FUNCTION__, __LINE__);
return;
}
header->len = len; header->len = len;
header->pid = LOS_GetCurrProcessID(); header->pid = LOS_GetCurrProcessID();

View File

@@ -2175,6 +2175,8 @@ u32_t osShellPing6(int argc, const char **argv)
/* Setting the start time of the entire ping task for statistics */ /* Setting the start time of the entire ping task for statistics */
(void)clock_gettime(CLOCK_MONOTONIC_RAW, &first); (void)clock_gettime(CLOCK_MONOTONIC_RAW, &first);
nsent = 0;
for (nsent = 0; nsent < ping6_params.pingcount; nsent++) { for (nsent = 0; nsent < ping6_params.pingcount; nsent++) {
/* capture the start tick to calculate rtt */ /* capture the start tick to calculate rtt */
(void)clock_gettime(CLOCK_MONOTONIC_RAW, &start); (void)clock_gettime(CLOCK_MONOTONIC_RAW, &start);
@@ -3168,6 +3170,7 @@ void netstat_internal(void *ctx)
} }
/* For listen PCBs */ /* For listen PCBs */
recvQlen = 0;
sendQlen = 0; sendQlen = 0;
for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) { for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) {
@@ -3667,7 +3670,7 @@ u32_t netdebug_sock(int argc, const char **argv)
int idx; int idx;
u32_t ret = LOS_NOK; u32_t ret = LOS_NOK;
if (argc == 2) { /* 2: Number of command parameters */ if (argc == 2) {
if (!strcmp("-i", argv[1])) { if (!strcmp("-i", argv[1])) {
/* netdebug sock -i */ /* netdebug sock -i */
for (idx = 0; idx < (int)LWIP_CONFIG_NUM_SOCKETS; idx++) { for (idx = 0; idx < (int)LWIP_CONFIG_NUM_SOCKETS; idx++) {
@@ -3675,9 +3678,10 @@ u32_t netdebug_sock(int argc, const char **argv)
} }
ret = LOS_OK; ret = LOS_OK;
} }
} else if (argc == 3) { /* 3: Number of command parameters */ } else if (argc == 3) {
if (!strcmp("-d", argv[1])) { if (!strcmp("-d", argv[1])) {
idx = atoi(argv[2]); /* 2: netdebug sock -d <idx> */ /* netdebug sock -d <idx> */
idx = atoi(argv[2]);
if (idx >= 0) { if (idx >= 0) {
debug_socket_info(idx, 1, 1); debug_socket_info(idx, 1, 1);
ret = LOS_OK; ret = LOS_OK;

View File

@@ -55,6 +55,7 @@ static int Testcase(VOID)
ICUNIT_GOTO_EQUAL(ds.shm_perm.uid, getuid(), ds.shm_perm.uid, ERROR_OUT); ICUNIT_GOTO_EQUAL(ds.shm_perm.uid, getuid(), ds.shm_perm.uid, ERROR_OUT);
ret = shmctl(shmid, SHM_STAT, &ds); ret = shmctl(shmid, SHM_STAT, &ds);
// ICUNIT_GOTO_EQUAL(ret, 0x10000, ret, ERROR_OUT);
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, ERROR_OUT); ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, ERROR_OUT);
ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, ERROR_OUT); ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, ERROR_OUT);
@@ -69,7 +70,7 @@ static int Testcase(VOID)
ICUNIT_GOTO_EQUAL(info.shmmax, 0x1000000, info.shmmax, ERROR_OUT); ICUNIT_GOTO_EQUAL(info.shmmax, 0x1000000, info.shmmax, ERROR_OUT);
ICUNIT_GOTO_EQUAL(info.shmmin, 1, info.shmmin, ERROR_OUT); ICUNIT_GOTO_EQUAL(info.shmmin, 1, info.shmmin, ERROR_OUT);
ICUNIT_GOTO_EQUAL(info.shmmni, 192, info.shmmni, ERROR_OUT); ICUNIT_GOTO_EQUAL(info.shmmni, 192, info.shmmni, ERROR_OUT);
ICUNIT_GOTO_EQUAL(info.shmseg, 128, info.shmseg, ERROR_OUT); // 128: expected value of shmseg ICUNIT_GOTO_EQUAL(info.shmseg, 128, info.shmseg, ERROR_OUT);
ICUNIT_GOTO_EQUAL(info.shmall, 0x1000, info.shmall, ERROR_OUT); ICUNIT_GOTO_EQUAL(info.shmall, 0x1000, info.shmall, ERROR_OUT);
ret = shmdt(shm); ret = shmdt(shm);

View File

@@ -63,11 +63,13 @@ static int LiteIpcTest(void)
/* testing mmap liteipc mem pool with different size and flag */ /* testing mmap liteipc mem pool with different size and flag */
retptr = mmap(nullptr, 1024 * 4096, PROT_READ, MAP_PRIVATE, fd, 0); retptr = mmap(nullptr, 1024 * 4096, PROT_READ, MAP_PRIVATE, fd, 0);
ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr); ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
//retptr = mmap(nullptr, 0, PROT_READ, MAP_PRIVATE, fd, 0);
//ICUNIT_ASSERT_EQUAL((int)(intptr_t)retptr, -1, retptr);
retptr = mmap(nullptr, -1, PROT_READ, MAP_PRIVATE, fd, 0); retptr = mmap(nullptr, -1, PROT_READ, MAP_PRIVATE, fd, 0);
ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr); ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
retptr = mmap(nullptr, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); retptr = mmap(nullptr, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr); ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
retptr = mmap(nullptr, 4096, PROT_READ, MAP_SHARED, fd, 0); // 4096: length of mapped memory retptr = mmap(nullptr, 4096, PROT_READ, MAP_SHARED, fd, 0);
ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr); ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
retptr = mmap(nullptr, 1, PROT_READ, MAP_PRIVATE, fd, 0); retptr = mmap(nullptr, 1, PROT_READ, MAP_PRIVATE, fd, 0);
@@ -79,7 +81,7 @@ static int LiteIpcTest(void)
char buf[10] = {0}; char buf[10] = {0};
ret = read(fd, buf, 10); ret = read(fd, buf, 10);
ICUNIT_ASSERT_EQUAL(ret, -1, ret); ICUNIT_ASSERT_EQUAL(ret, -1, ret);
ret = write(fd, buf, 10); // 10: size of buf ret = write(fd, buf, 10);
ICUNIT_ASSERT_EQUAL(ret, -1, ret); ICUNIT_ASSERT_EQUAL(ret, -1, ret);
/* before set cms, testing ioctl cmd */ /* before set cms, testing ioctl cmd */
@@ -94,7 +96,7 @@ static int LiteIpcTest(void)
sleep(2); sleep(2);
/* after set cms, testing set cms cmd */ /* after set cms, testing set cms cmd */
ret = ioctl(fd, IPC_SET_CMS, 200); // 200: use 200 for set cms cmd testing ret = ioctl(fd, IPC_SET_CMS, 200);
ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
exit(0); exit(0);

View File

@@ -60,6 +60,17 @@ static int TestCase()
exit(0); exit(0);
} }
/* sig = SIGTERM;
ret = sigaction(sig, (struct sigaction *)1, &oldAct);
printf("ret == %d\n", ret);
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
ret = sigaction(sig, &sigAct, (struct sigaction *)1);
printf("ret === %d\n", ret);
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno); */
ret = waitpid(fpid, &status, 0); ret = waitpid(fpid, &status, 0);
ICUNIT_ASSERT_EQUAL(ret, fpid, ret); ICUNIT_ASSERT_EQUAL(ret, fpid, ret);
ICUNIT_ASSERT_EQUAL(WEXITSTATUS(status), 0, WEXITSTATUS(status)); ICUNIT_ASSERT_EQUAL(WEXITSTATUS(status), 0, WEXITSTATUS(status));

View File

@@ -37,6 +37,7 @@ static UINT32 testcase(VOID)
time_t currtime; time_t currtime;
struct tm *timer = {nullptr}; struct tm *timer = {nullptr};
char buffer[80]; char buffer[80];
//locale_t loc = malloc(sizeof(locale_t);
time(&currtime); time(&currtime);
timer = localtime(&currtime); timer = localtime(&currtime);
@@ -45,17 +46,17 @@ static UINT32 testcase(VOID)
printf("getenv MUSL_LOCPATH=%s\n", getenv("MUSL_LOCPATH")); printf("getenv MUSL_LOCPATH=%s\n", getenv("MUSL_LOCPATH"));
printf("Locale is: %s\n", setlocale(LC_TIME, "en_US.UTF-8")); printf("Locale is: %s\n", setlocale(LC_TIME, "en_US.UTF-8"));
(void)strftime(buffer, sizeof(buffer), "%c", timer); strftime(buffer, 80, "%c", timer);
printf("Date is: %s\n", buffer); printf("Date is: %s\n", buffer);
ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1); ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1);
printf("Locale is: %s\n", setlocale(LC_TIME, "zh_CN.UTF-8")); printf("Locale is: %s\n", setlocale(LC_TIME, "zh_CN.UTF-8"));
(void)strftime(buffer, sizeof(buffer), "%c", timer); strftime(buffer, 80, "%c", timer);
printf("Date is: %s\n", buffer); printf("Date is: %s\n", buffer);
ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1); ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1);
printf("Locale is: %s\n", setlocale(LC_TIME, "")); printf("Locale is: %s\n", setlocale(LC_TIME, ""));
(void)strftime(buffer, sizeof(buffer), "%c", timer); strftime(buffer, 80, "%c", timer);
printf("Date is: %s\n", buffer); printf("Date is: %s\n", buffer);
ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1); ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1);
setlocale(LC_ALL, "C"); setlocale(LC_ALL, "C");

View File

@@ -145,6 +145,26 @@ HWTEST_F(MiscTest, ItTestMisc009, TestSize.Level0)
ItTestMisc009(); ItTestMisc009();
} }
/* *
* @tc.name: IT_TEST_MISC_010
* @tc.desc: function for MiscTest
* @tc.type: FUNC
*/
/*HWTEST_F(MiscTest, ItTestMisc010, TestSize.Level0)
{
ItTestMisc010();
}*/
/* *
* @tc.name: IT_TEST_MISC_011
* @tc.desc: function for MiscTest
* @tc.type: FUNC
*/
/*HWTEST_F(MiscTest, ItTestMisc011, TestSize.Level0)
{
ItTestMisc011();
}*/
/* * /* *
* @tc.name: IT_TEST_MISC_012 * @tc.name: IT_TEST_MISC_012
* @tc.desc: function for MiscTest * @tc.desc: function for MiscTest
@@ -154,6 +174,16 @@ HWTEST_F(MiscTest, ItTestMisc012, TestSize.Level0)
{ {
ItTestMisc012(); ItTestMisc012();
} }
/* *
* @tc.name: IT_TEST_MISC_013
* @tc.desc: function for MiscTest
* @tc.type: FUNC
*/
/*HWTEST_F(MiscTest, ItTestMisc013, TestSize.Level0)
{
ItTestMisc013();
}*/
#endif #endif
} // namespace OHOS } // namespace OHOS

View File

@@ -56,7 +56,7 @@
#define TEST_HwiTrigger(HWI_NUM_TEST) #define TEST_HwiTrigger(HWI_NUM_TEST)
#define LOS_TaskLock() #define LOS_TaskLock()
#define LOS_TaskUnlock() #define LOS_TaskUnlock()
#define LOS_MS2Tick(ms) ((ms) / 10) #define LOS_MS2Tick(ms) (ms / 10)
#define OS_TASK_PRIORITY_HIGHEST 0 #define OS_TASK_PRIORITY_HIGHEST 0
#define OS_TASK_PRIORITY_LOWEST 31 #define OS_TASK_PRIORITY_LOWEST 31
@@ -228,7 +228,12 @@ struct testdata {
}; };
extern struct testdata g_td; extern struct testdata g_td;
extern unsigned int sleep(unsigned int seconds);
extern unsigned int alarm(unsigned int seconds);
extern int map_errno(UINT32 err); extern int map_errno(UINT32 err);
extern long sysconf(int name);
extern void posix_signal_start(void); extern void posix_signal_start(void);
VOID ScenarInit(VOID); VOID ScenarInit(VOID);

View File

@@ -34,6 +34,7 @@ static void *pthread_f01(void *tmp)
{ {
int rc = 0; int rc = 0;
g_testCount++; g_testCount++;
// printf("www\n");
/* acquire the mutex */ /* acquire the mutex */
rc = pthread_mutex_lock(&g_pthreadMutexTest1); rc = pthread_mutex_lock(&g_pthreadMutexTest1);
@@ -68,7 +69,7 @@ static UINT32 Testcase(VOID)
/* Let the other thread run */ /* Let the other thread run */
LosTaskDelay(2); LosTaskDelay(2);
ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2: expected value of g_testCount ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount);
/* Try to destroy the cond var. This should return an error */ /* Try to destroy the cond var. This should return an error */
rc = pthread_cond_destroy(&g_pthreadCondTest1); rc = pthread_cond_destroy(&g_pthreadCondTest1);
@@ -78,7 +79,7 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(rc, 0, rc); ICUNIT_ASSERT_EQUAL(rc, 0, rc);
LosTaskDelay(2); LosTaskDelay(2);
ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4: expected value of g_testCount ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount);
rc = pthread_cond_destroy(&g_pthreadCondTest1); rc = pthread_cond_destroy(&g_pthreadCondTest1);
ICUNIT_ASSERT_EQUAL(rc, 0, rc); ICUNIT_ASSERT_EQUAL(rc, 0, rc);

View File

@@ -51,6 +51,10 @@ static UINT32 Testcase(VOID)
tmp = pthread_equal(a, b); tmp = pthread_equal(a, b);
// pthread_join(a, NULL);
// pthread_detach(a);
pthread_attr_init(&aa); pthread_attr_init(&aa);
pthread_attr_getdetachstate(&aa, &detachstate); pthread_attr_getdetachstate(&aa, &detachstate);
@@ -59,6 +63,19 @@ static UINT32 Testcase(VOID)
pthread_attr_destroy(&aa); pthread_attr_destroy(&aa);
// pthread_mutex_init(&c, NULL);
// pthread_mutex_destroy(&c);
// pthread_mutex_lock(&c);
// pthread_mutex_trylock(&c);
// pthread_mutex_unlock(&c);
// pthread_mutexattr_init(&c);
// pthread_mutexattr_destroy(&c);
ret = pthread_join(aThread, NULL); ret = pthread_join(aThread, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_EQUAL(ret, 0, ret);

View File

@@ -36,6 +36,8 @@ static void *ThreadF01(void *arg)
/* Shouldn't reach here. If we do, then the pthread_cancel() /* Shouldn't reach here. If we do, then the pthread_cancel()
* function did not succeed. */ * function did not succeed. */
// uart_printf_func("Could not send cancel request correctly\n");
// ICUNIT_TRACK_EQUAL(1, 0, errno);
pthread_exit(nullptr); pthread_exit(nullptr);
return NULL; return NULL;
} }
@@ -60,6 +62,7 @@ static UINT32 Testcase(VOID)
ret = pthread_join(newTh, (void **)&temp); ret = pthread_join(newTh, (void **)&temp);
ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_EQUAL(ret, 0, ret);
// ICUNIT_ASSERT_EQUAL(temp, (UINTPTR)PTHREAD_CANCELED, temp);
return PTHREAD_NO_ERROR; return PTHREAD_NO_ERROR;
} }

View File

@@ -34,6 +34,7 @@ static void *ThreadF01(void *arg)
{ {
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
// while (1)
sleep(1); sleep(1);
pthread_exit(nullptr); pthread_exit(nullptr);
@@ -47,6 +48,7 @@ static UINT32 Testcase(VOID)
pthread_t a; pthread_t a;
/* SIGALRM will be sent in 5 seconds. */ /* SIGALRM will be sent in 5 seconds. */
// alarm(5);//alarm NOT SUPPORT
/* Create a new thread. */ /* Create a new thread. */
if (pthread_create(&a, NULL, ThreadF01, NULL) != 0) { if (pthread_create(&a, NULL, ThreadF01, NULL) != 0) {
@@ -59,6 +61,7 @@ static UINT32 Testcase(VOID)
/* If 'main' has reached here, then the test passed because it means /* If 'main' has reached here, then the test passed because it means
* that the thread is truly asynchronise, and main isn't waiting for * that the thread is truly asynchronise, and main isn't waiting for
* it to return in order to move on. */ * it to return in order to move on. */
// printf("Test PASSED\n");
ret = pthread_join(a, &temp); ret = pthread_join(a, &temp);
ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_EQUAL(ret, 0, ret);

View File

@@ -176,5 +176,16 @@ HWTEST_F(NetSocketTest, NetSocketTest012, TestSize.Level0)
NetSocketTest012(); NetSocketTest012();
} }
/* *
* @tc.name: NetSocketTest013
* @tc.desc: function for NetSocketTest
* @tc.type: FUNC
*/
/*
HWTEST_F(NetSocketTest, NetSocketTest013, TestSize.Level0)
{
//NetSocketTest013(); // broadcast to self to be supported.
}
*/
#endif #endif
} }

View File

@@ -131,6 +131,7 @@ def parse_user_pc_ulr(excinfo_file, rootfs_dir, string, addr2line_cmd, objdump_c
ret = commands.getoutput(cmd) ret = commands.getoutput(cmd)
print(ret) print(ret)
cmd = "%s%s%s %s" % (addr2line_cmd, rootfs_dir, strlist[4], strlist[6]) cmd = "%s%s%s %s" % (addr2line_cmd, rootfs_dir, strlist[4], strlist[6])
#print(cmd)
ret = commands.getoutput(cmd) ret = commands.getoutput(cmd)
ret = ret.split('\n') ret = ret.split('\n')
print("<%s>%s<%s><%s>\n" % (string, ret[0], strlist[6], strlist[4])) print("<%s>%s<%s><%s>\n" % (string, ret[0], strlist[6], strlist[4]))

View File

@@ -38,7 +38,7 @@ get_line()
{ {
SYM_ADDR=$(echo $1 | awk '{print $2}') SYM_ADDR=$(echo $1 | awk '{print $2}')
ELF_OFFSET=$(echo ${SYM_ADDR} | cut -d '[' -f2 | cut -d ']' -f1) ELF_OFFSET=$(echo ${SYM_ADDR} | cut -d '[' -f2 | cut -d ']' -f1)
FILE_LINE=$(${ADDR2LINE} -f -e $2 ${ELF_OFFSET} | awk 'NR==2') FILE_LINE=$(${ADDR2LINE} -f -e $2 ${ELF_OFFSET} | awk 'NR==2'`)
if [[ "${FILE_LINE}" == *"?"* ]]; then if [[ "${FILE_LINE}" == *"?"* ]]; then
typeset ELF_OFFSET=$((ELF_OFFSET+LOAD_BASE)) typeset ELF_OFFSET=$((ELF_OFFSET+LOAD_BASE))
ELF_OFFSET=$(echo "obase=16;${ELF_OFFSET}" | bc) ELF_OFFSET=$(echo "obase=16;${ELF_OFFSET}" | bc)