未验证 提交 ea825345 编写于 作者: O openharmony_ci 提交者: Gitee

!1115 修复xts用例失败的问题

Merge pull request !1115 from zhangdengyu/fixXtsTestCase
...@@ -132,10 +132,8 @@ int VfsProcfsRead(struct file *filep, char *buffer, size_t buflen) ...@@ -132,10 +132,8 @@ int VfsProcfsRead(struct file *filep, char *buffer, size_t buflen)
return -EPERM; return -EPERM;
} }
spin_lock(&entry->pdeUnloadLock);
size = (ssize_t)ReadProcFile(entry, (void *)buffer, buflen); size = (ssize_t)ReadProcFile(entry, (void *)buffer, buflen);
filep->f_pos = entry->pf->fPos; filep->f_pos = entry->pf->fPos;
spin_unlock(&entry->pdeUnloadLock);
VnodeDrop(); VnodeDrop();
return size; return size;
} }
...@@ -155,10 +153,8 @@ int VfsProcfsWrite(struct file *filep, const char *buffer, size_t buflen) ...@@ -155,10 +153,8 @@ int VfsProcfsWrite(struct file *filep, const char *buffer, size_t buflen)
return -EPERM; return -EPERM;
} }
spin_lock(&entry->pdeUnloadLock);
size = (ssize_t)WriteProcFile(entry, (void *)buffer, buflen); size = (ssize_t)WriteProcFile(entry, (void *)buffer, buflen);
filep->f_pos = entry->pf->fPos; filep->f_pos = entry->pf->fPos;
spin_unlock(&entry->pdeUnloadLock);
VnodeDrop(); VnodeDrop();
return size; return size;
} }
...@@ -173,11 +169,9 @@ int VfsProcfsLookup(struct Vnode *parent, const char *name, int len, struct Vnod ...@@ -173,11 +169,9 @@ int VfsProcfsLookup(struct Vnode *parent, const char *name, int len, struct Vnod
return -ENODATA; return -ENODATA;
} }
spin_lock(&procfsLock);
entry = entry->subdir; entry = entry->subdir;
while (1) { while (1) {
if (entry == NULL) { if (entry == NULL) {
spin_unlock(&procfsLock);
return -ENOENT; return -ENOENT;
} }
if (EntryMatch(name, len, entry)) { if (EntryMatch(name, len, entry)) {
...@@ -185,7 +179,6 @@ int VfsProcfsLookup(struct Vnode *parent, const char *name, int len, struct Vnod ...@@ -185,7 +179,6 @@ int VfsProcfsLookup(struct Vnode *parent, const char *name, int len, struct Vnod
} }
entry = entry->next; entry = entry->next;
} }
spin_unlock(&procfsLock);
*vpp = EntryToVnode(entry); *vpp = EntryToVnode(entry);
if ((*vpp) == NULL) { if ((*vpp) == NULL) {
...@@ -241,9 +234,7 @@ int VfsProcfsStat(struct Vnode *node, struct stat *buf) ...@@ -241,9 +234,7 @@ int VfsProcfsStat(struct Vnode *node, struct stat *buf)
return -EPERM; return -EPERM;
} }
(void)memset_s(buf, sizeof(struct stat), 0, sizeof(struct stat)); (void)memset_s(buf, sizeof(struct stat), 0, sizeof(struct stat));
spin_lock(&entry->pdeUnloadLock);
buf->st_mode = entry->mode; buf->st_mode = entry->mode;
spin_unlock(&entry->pdeUnloadLock);
VnodeDrop(); VnodeDrop();
return LOS_OK; return LOS_OK;
} }
...@@ -269,11 +260,9 @@ int VfsProcfsReaddir(struct Vnode *node, struct fs_dirent_s *dir) ...@@ -269,11 +260,9 @@ int VfsProcfsReaddir(struct Vnode *node, struct fs_dirent_s *dir)
return -EPERM; return -EPERM;
} }
spin_lock(&pde->pdeUnloadLock);
while (i < dir->read_cnt) { while (i < dir->read_cnt) {
buffer = (char *)zalloc(sizeof(char) * NAME_MAX); buffer = (char *)zalloc(sizeof(char) * NAME_MAX);
if (buffer == NULL) { if (buffer == NULL) {
spin_unlock(&pde->pdeUnloadLock);
VnodeDrop(); VnodeDrop();
PRINT_ERR("malloc failed\n"); PRINT_ERR("malloc failed\n");
return -ENOMEM; return -ENOMEM;
...@@ -288,7 +277,6 @@ int VfsProcfsReaddir(struct Vnode *node, struct fs_dirent_s *dir) ...@@ -288,7 +277,6 @@ int VfsProcfsReaddir(struct Vnode *node, struct fs_dirent_s *dir)
minSize = (dstNameSize < NAME_MAX) ? dstNameSize : NAME_MAX; minSize = (dstNameSize < NAME_MAX) ? dstNameSize : NAME_MAX;
result = strncpy_s(dir->fd_dir[i].d_name, dstNameSize, buffer, minSize); result = strncpy_s(dir->fd_dir[i].d_name, dstNameSize, buffer, minSize);
if (result != EOK) { if (result != EOK) {
spin_unlock(&pde->pdeUnloadLock);
VnodeDrop(); VnodeDrop();
free(buffer); free(buffer);
return -ENAMETOOLONG; return -ENAMETOOLONG;
...@@ -301,7 +289,6 @@ int VfsProcfsReaddir(struct Vnode *node, struct fs_dirent_s *dir) ...@@ -301,7 +289,6 @@ int VfsProcfsReaddir(struct Vnode *node, struct fs_dirent_s *dir)
i++; i++;
free(buffer); free(buffer);
} }
spin_unlock(&pde->pdeUnloadLock);
VnodeDrop(); VnodeDrop();
return i; return i;
} }
...@@ -315,15 +302,12 @@ int VfsProcfsOpendir(struct Vnode *node, struct fs_dirent_s *dir) ...@@ -315,15 +302,12 @@ int VfsProcfsOpendir(struct Vnode *node, struct fs_dirent_s *dir)
return -EINVAL; return -EINVAL;
} }
spin_lock(&pde->pdeUnloadLock);
pde->pdirCurrent = pde->subdir; pde->pdirCurrent = pde->subdir;
if (pde->pf == NULL) { if (pde->pf == NULL) {
spin_unlock(&pde->pdeUnloadLock);
VnodeDrop(); VnodeDrop();
return -EINVAL; return -EINVAL;
} }
pde->pf->fPos = 0; pde->pf->fPos = 0;
spin_unlock(&pde->pdeUnloadLock);
VnodeDrop(); VnodeDrop();
return LOS_OK; return LOS_OK;
} }
...@@ -341,9 +325,7 @@ int VfsProcfsOpen(struct file *filep) ...@@ -341,9 +325,7 @@ int VfsProcfsOpen(struct file *filep)
return -EPERM; return -EPERM;
} }
spin_lock(&pde->pdeUnloadLock);
if (ProcOpen(pde->pf) != OK) { if (ProcOpen(pde->pf) != OK) {
spin_unlock(&pde->pdeUnloadLock);
return -ENOMEM; return -ENOMEM;
} }
if (S_ISREG(pde->mode) && (pde->procFileOps != NULL) && (pde->procFileOps->open != NULL)) { if (S_ISREG(pde->mode) && (pde->procFileOps != NULL) && (pde->procFileOps->open != NULL)) {
...@@ -354,7 +336,6 @@ int VfsProcfsOpen(struct file *filep) ...@@ -354,7 +336,6 @@ int VfsProcfsOpen(struct file *filep)
pde->pf->fPos = 0; pde->pf->fPos = 0;
} }
filep->f_priv = (void *)pde; filep->f_priv = (void *)pde;
spin_unlock(&pde->pdeUnloadLock);
VnodeDrop(); VnodeDrop();
return LOS_OK; return LOS_OK;
} }
...@@ -374,14 +355,12 @@ int VfsProcfsClose(struct file *filep) ...@@ -374,14 +355,12 @@ int VfsProcfsClose(struct file *filep)
return -EPERM; return -EPERM;
} }
spin_lock(&pde->pdeUnloadLock);
pde->pf->fPos = 0; pde->pf->fPos = 0;
if ((pde->procFileOps != NULL) && (pde->procFileOps->release != NULL)) { if ((pde->procFileOps != NULL) && (pde->procFileOps->release != NULL)) {
result = pde->procFileOps->release((struct Vnode *)pde, pde->pf); result = pde->procFileOps->release((struct Vnode *)pde, pde->pf);
} }
LosBufRelease(pde->pf->sbuf); LosBufRelease(pde->pf->sbuf);
pde->pf->sbuf = NULL; pde->pf->sbuf = NULL;
spin_unlock(&pde->pdeUnloadLock);
VnodeDrop(); VnodeDrop();
return result; return result;
} }
...@@ -411,11 +390,9 @@ ssize_t VfsProcfsReadlink(struct Vnode *vnode, char *buffer, size_t bufLen) ...@@ -411,11 +390,9 @@ ssize_t VfsProcfsReadlink(struct Vnode *vnode, char *buffer, size_t bufLen)
return -EPERM; return -EPERM;
} }
spin_lock(&pde->pdeUnloadLock);
if ((pde->procFileOps != NULL) && (pde->procFileOps->readLink != NULL)) { if ((pde->procFileOps != NULL) && (pde->procFileOps->readLink != NULL)) {
result = pde->procFileOps->readLink(pde, buffer, bufLen); result = pde->procFileOps->readLink(pde, buffer, bufLen);
} }
spin_unlock(&pde->pdeUnloadLock);
return result; return result;
} }
......
...@@ -406,7 +406,6 @@ static void FreeProcEntry(struct ProcDirEntry *entry) ...@@ -406,7 +406,6 @@ static void FreeProcEntry(struct ProcDirEntry *entry)
ProcEntryClearVnode(entry); ProcEntryClearVnode(entry);
spin_lock(&entry->pdeUnloadLock);
if (entry->pf != NULL) { if (entry->pf != NULL) {
free(entry->pf); free(entry->pf);
entry->pf = NULL; entry->pf = NULL;
...@@ -415,7 +414,6 @@ static void FreeProcEntry(struct ProcDirEntry *entry) ...@@ -415,7 +414,6 @@ static void FreeProcEntry(struct ProcDirEntry *entry)
free(entry->data); free(entry->data);
entry->data = NULL; entry->data = NULL;
} }
spin_unlock(&entry->pdeUnloadLock);
free(entry); free(entry);
} }
...@@ -592,16 +590,13 @@ struct ProcDirEntry *OpenProcFile(const char *fileName, int flags, ...) ...@@ -592,16 +590,13 @@ struct ProcDirEntry *OpenProcFile(const char *fileName, int flags, ...)
return NULL; return NULL;
} }
spin_lock(&pn->pdeUnloadLock);
if (S_ISREG(pn->mode) && (pn->count != 1)) { if (S_ISREG(pn->mode) && (pn->count != 1)) {
spin_unlock(&pn->pdeUnloadLock);
return NULL; return NULL;
} }
pn->flags = (unsigned int)(pn->flags) | (unsigned int)flags; pn->flags = (unsigned int)(pn->flags) | (unsigned int)flags;
atomic_set(&pn->count, PROC_INUSE); atomic_set(&pn->count, PROC_INUSE);
if (ProcOpen(pn->pf) != OK) { if (ProcOpen(pn->pf) != OK) {
spin_unlock(&pn->pdeUnloadLock);
return NULL; return NULL;
} }
if (S_ISREG(pn->mode) && (pn->procFileOps != NULL) && (pn->procFileOps->open != NULL)) { if (S_ISREG(pn->mode) && (pn->procFileOps != NULL) && (pn->procFileOps->open != NULL)) {
...@@ -611,7 +606,6 @@ struct ProcDirEntry *OpenProcFile(const char *fileName, int flags, ...) ...@@ -611,7 +606,6 @@ struct ProcDirEntry *OpenProcFile(const char *fileName, int flags, ...)
pn->pdirCurrent = pn->subdir; pn->pdirCurrent = pn->subdir;
pn->pf->fPos = 0; pn->pf->fPos = 0;
} }
spin_unlock(&pn->pdeUnloadLock);
return pn; return pn;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册