1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-07-13 01:20:24 +02:00

doc update and schema update

This commit is contained in:
Kelly Brazil
2022-09-19 20:32:26 -07:00
parent 7c772d3a5a
commit 52d98a1157
2 changed files with 177 additions and 104 deletions

View File

@ -31,46 +31,81 @@ Schema:
[ [
{ {
"module": string, "mount_id": integer,
"size": integer, "parent_id": integer,
"used": integer, "maj": integer,
"used_by": [ "min": integer,
"root": string,
"mount_point": string,
"mount_options": [
string string
], ],
"status": string, "optional_fields": { # [0]
"location": string "<key>": integer
},
"fs_type": string,
"mount_source": string,
"super_options": [
string
],
"super_options_fields": {
"<key>": string
}
} }
] ]
[0] if empty, then unbindable
Examples: Examples:
$ cat /proc/1/mountinfo | jc --proc -p $ cat /proc/1/mountinfo | jc --proc -p
[ [
{ {
"module": "binfmt_misc", "mount_id": 24,
"size": 24576, "parent_id": 30,
"used": 1, "maj": 0,
"used_by": [], "min": 22,
"status": "Live", "root": "/",
"location": "0xffffffffc0ab4000" "mount_point": "/sys",
}, "mount_options": [
{ "rw",
"module": "vsock_loopback", "nosuid",
"size": 16384, "nodev",
"used": 0, "noexec",
"used_by": [], "relatime"
"status": "Live",
"location": "0xffffffffc0a14000"
},
{
"module": "vmw_vsock_virtio_transport_common",
"size": 36864,
"used": 1,
"used_by": [
"vsock_loopback"
], ],
"status": "Live", "optional_fields": {
"location": "0xffffffffc0a03000" "master": 1,
"shared": 7
},
"fs_type": "sysfs",
"mount_source": "sysfs",
"super_options": [
"rw"
]
},
{
"mount_id": 25,
"parent_id": 30,
"maj": 0,
"min": 23,
"root": "/",
"mount_point": "/proc",
"mount_options": [
"rw",
"nosuid",
"nodev",
"noexec",
"relatime"
],
"optional_fields": {
"shared": 14
},
"fs_type": "proc",
"mount_source": "proc",
"super_options": [
"rw"
]
}, },
... ...
] ]
@ -78,30 +113,30 @@ Examples:
$ cat /proc/1/mountinfo | jc --proc_pid-mountinfo -p -r $ cat /proc/1/mountinfo | jc --proc_pid-mountinfo -p -r
[ [
{ {
"module": "binfmt_misc", "mount_id": "24",
"size": "24576", "parent_id": "30",
"used": "1", "maj": "0",
"used_by": [], "min": "22",
"status": "Live", "root": "/",
"location": "0xffffffffc0ab4000" "mount_point": "/sys",
"mount_options": "rw,nosuid,nodev,noexec,relatime",
"optional_fields": "master:1 shared:7 ",
"fs_type": "sysfs",
"mount_source": "sysfs",
"super_options": "rw"
}, },
{ {
"module": "vsock_loopback", "mount_id": "25",
"size": "16384", "parent_id": "30",
"used": "0", "maj": "0",
"used_by": [], "min": "23",
"status": "Live", "root": "/",
"location": "0xffffffffc0a14000" "mount_point": "/proc",
}, "mount_options": "rw,nosuid,nodev,noexec,relatime",
{ "optional_fields": "shared:14 ",
"module": "vmw_vsock_virtio_transport_common", "fs_type": "proc",
"size": "36864", "mount_source": "proc",
"used": "1", "super_options": "rw"
"used_by": [
"vsock_loopback"
],
"status": "Live",
"location": "0xffffffffc0a03000"
}, },
... ...
] ]

View File

@ -26,46 +26,81 @@ Schema:
[ [
{ {
"module": string, "mount_id": integer,
"size": integer, "parent_id": integer,
"used": integer, "maj": integer,
"used_by": [ "min": integer,
"root": string,
"mount_point": string,
"mount_options": [
string string
], ],
"status": string, "optional_fields": { # [0]
"location": string "<key>": integer
},
"fs_type": string,
"mount_source": string,
"super_options": [
string
],
"super_options_fields": {
"<key>": string
}
} }
] ]
[0] if empty, then unbindable
Examples: Examples:
$ cat /proc/1/mountinfo | jc --proc -p $ cat /proc/1/mountinfo | jc --proc -p
[ [
{ {
"module": "binfmt_misc", "mount_id": 24,
"size": 24576, "parent_id": 30,
"used": 1, "maj": 0,
"used_by": [], "min": 22,
"status": "Live", "root": "/",
"location": "0xffffffffc0ab4000" "mount_point": "/sys",
}, "mount_options": [
{ "rw",
"module": "vsock_loopback", "nosuid",
"size": 16384, "nodev",
"used": 0, "noexec",
"used_by": [], "relatime"
"status": "Live",
"location": "0xffffffffc0a14000"
},
{
"module": "vmw_vsock_virtio_transport_common",
"size": 36864,
"used": 1,
"used_by": [
"vsock_loopback"
], ],
"status": "Live", "optional_fields": {
"location": "0xffffffffc0a03000" "master": 1,
"shared": 7
},
"fs_type": "sysfs",
"mount_source": "sysfs",
"super_options": [
"rw"
]
},
{
"mount_id": 25,
"parent_id": 30,
"maj": 0,
"min": 23,
"root": "/",
"mount_point": "/proc",
"mount_options": [
"rw",
"nosuid",
"nodev",
"noexec",
"relatime"
],
"optional_fields": {
"shared": 14
},
"fs_type": "proc",
"mount_source": "proc",
"super_options": [
"rw"
]
}, },
... ...
] ]
@ -73,30 +108,30 @@ Examples:
$ cat /proc/1/mountinfo | jc --proc_pid-mountinfo -p -r $ cat /proc/1/mountinfo | jc --proc_pid-mountinfo -p -r
[ [
{ {
"module": "binfmt_misc", "mount_id": "24",
"size": "24576", "parent_id": "30",
"used": "1", "maj": "0",
"used_by": [], "min": "22",
"status": "Live", "root": "/",
"location": "0xffffffffc0ab4000" "mount_point": "/sys",
"mount_options": "rw,nosuid,nodev,noexec,relatime",
"optional_fields": "master:1 shared:7 ",
"fs_type": "sysfs",
"mount_source": "sysfs",
"super_options": "rw"
}, },
{ {
"module": "vsock_loopback", "mount_id": "25",
"size": "16384", "parent_id": "30",
"used": "0", "maj": "0",
"used_by": [], "min": "23",
"status": "Live", "root": "/",
"location": "0xffffffffc0a14000" "mount_point": "/proc",
}, "mount_options": "rw,nosuid,nodev,noexec,relatime",
{ "optional_fields": "shared:14 ",
"module": "vmw_vsock_virtio_transport_common", "fs_type": "proc",
"size": "36864", "mount_source": "proc",
"used": "1", "super_options": "rw"
"used_by": [
"vsock_loopback"
],
"status": "Live",
"location": "0xffffffffc0a03000"
}, },
... ...
] ]
@ -131,7 +166,7 @@ def _process(proc_data: List[Dict]) -> List[Dict]:
List of Dictionaries. Structured to conform to the schema. List of Dictionaries. Structured to conform to the schema.
""" """
int_list = {'size', 'used'} int_list = {'mount_id', 'parent_id', 'maj', 'min'}
for entry in proc_data: for entry in proc_data:
for key in entry: for key in entry:
@ -142,7 +177,7 @@ def _process(proc_data: List[Dict]) -> List[Dict]:
entry['mount_options'] = entry['mount_options'].split(',') entry['mount_options'] = entry['mount_options'].split(',')
if 'optional_fields' in entry: if 'optional_fields' in entry:
entry['optional_fields'] = {x.split(':')[0]: x.split(':')[1] for x in entry['optional_fields'].split()} entry['optional_fields'] = {x.split(':')[0]: int(x.split(':')[1]) for x in entry['optional_fields'].split()}
if 'super_options' in entry: if 'super_options' in entry:
if entry['super_options']: if entry['super_options']:
@ -163,6 +198,9 @@ def _process(proc_data: List[Dict]) -> List[Dict]:
key, val = field.split('=') key, val = field.split('=')
entry['super_options_fields'][key] = val entry['super_options_fields'][key] = val
else:
del entry['super_options']
return proc_data return proc_data