!357 修改/proc/mounts显示格式

Merge pull request !357 from JING/mount
This commit is contained in:
openharmony_ci 2021-06-24 08:27:32 +00:00 committed by Gitee
commit 112cdebe41
2 changed files with 9 additions and 4 deletions

View File

@ -53,6 +53,7 @@ struct Mount {
uint32_t hashseed; /* Random seed for vfshash */ uint32_t hashseed; /* Random seed for vfshash */
unsigned long mountFlags; /* Flags for mount */ unsigned long mountFlags; /* Flags for mount */
char pathName[PATH_MAX]; /* path name of mount point */ char pathName[PATH_MAX]; /* path name of mount point */
char devName[PATH_MAX]; /* path name of dev point */
}; };
struct MountOps { struct MountOps {
@ -61,7 +62,8 @@ struct MountOps {
int (*Statfs)(struct Mount *mount, struct statfs *sbp); int (*Statfs)(struct Mount *mount, struct statfs *sbp);
}; };
typedef int (*foreach_mountpoint_t)(const char *mountpoint, typedef int (*foreach_mountpoint_t)(const char *devpoint,
const char *mountpoint,
struct statfs *statbuf, struct statfs *statbuf,
void *arg); void *arg);

View File

@ -38,7 +38,7 @@
#include "fs/mount.h" #include "fs/mount.h"
#include "internal.h" #include "internal.h"
static int ShowType(const char *mountPoint, struct statfs *statBuf, void *arg) static int ShowType(const char *devPoint, const char *mountPoint, struct statfs *statBuf, void *arg)
{ {
struct SeqBuf *seqBuf = (struct SeqBuf *)arg; struct SeqBuf *seqBuf = (struct SeqBuf *)arg;
char *type = NULL; char *type = NULL;
@ -66,14 +66,17 @@ static int ShowType(const char *mountPoint, struct statfs *statBuf, void *arg)
return 0; return 0;
} }
(void)LosBufPrintf(seqBuf, "%s\t%s\n", type, mountPoint); if (strlen(devPoint) == 0) {
(void)LosBufPrintf(seqBuf, "%s %s %s %s %d %d\n", type, mountPoint, type, "()", 0, 0);
} else {
(void)LosBufPrintf(seqBuf, "%s %s %s %s %d %d\n", devPoint, mountPoint, type, "()", 0, 0);
}
return 0; return 0;
} }
static int MountsProcFill(struct SeqBuf *m, void *v) static int MountsProcFill(struct SeqBuf *m, void *v)
{ {
(void)LosBufPrintf(m, "%s\t%s\n", "Type", "MountPoint");
foreach_mountpoint_t handler = ShowType; foreach_mountpoint_t handler = ShowType;
(void)foreach_mountpoint(handler, (void *)m); (void)foreach_mountpoint(handler, (void *)m);