Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-apps-camogm
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
elphel-apps-camogm
Commits
2997e18c
Commit
2997e18c
authored
Sep 23, 2016
by
Mikhail Karpenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add raw device detection
parent
1a586b78
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
1 deletion
+63
-1
camogm_interface.php
src/camogmgui/camogm_interface.php
+63
-1
No files found.
src/camogmgui/camogm_interface.php
View file @
2997e18c
...
@@ -400,7 +400,12 @@ else
...
@@ -400,7 +400,12 @@ else
}
}
echo
"</item>"
;
echo
"</item>"
;
}
}
break
;
case
"list_raw_devices"
:
$devices
=
get_raw_dev
();
foreach
(
$devices
as
$device
)
{
echo
"<raw_device>"
.
$device
.
"</raw_device>"
;
}
break
;
break
;
case
"mkdir"
:
case
"mkdir"
:
$dir_name
=
$_GET
[
'name'
];
$dir_name
=
$_GET
[
'name'
];
...
@@ -601,6 +606,63 @@ function xml_footer() {
...
@@ -601,6 +606,63 @@ function xml_footer() {
echo
"</camogm_interface>
\n
"
;
echo
"</camogm_interface>
\n
"
;
}
}
/** Get a list of disk devices which have file system and can be mounted. This function
* uses 'blkid' command from busybox.
*/
function
get_mnt_dev
()
{
exec
(
"blkid"
,
$ids
);
$i
=
0
;
foreach
(
$ids
as
$id
)
{
$devices
[
$i
]
=
preg_replace
(
'/: +.*/'
,
""
,
$id
);
if
(
preg_match
(
'/(?<=TYPE=")[a-z0-9]+(?=")/'
,
$id
,
$fs
)
==
1
)
$fs_types
[
$i
]
=
$fs
[
0
];
else
$fs_types
[
$i
]
=
"none"
;
$i
++
;
}
return
array
(
"devices"
=>
$devices
,
"types"
=>
$fs_types
);
}
/** Get a list of devices whithout file system which can be used for raw disk storage from camogm. */
function
get_raw_dev
()
{
$j
=
0
;
$regexp
=
'/sd[a-z0-9]+$/'
;
$names
=
array
();
$ret
=
get_mnt_dev
();
$devices
=
$ret
[
"devices"
];
$types
=
$ret
[
"types"
];
exec
(
"cat /proc/partitions"
,
$partitions
);
// get a list of all suitable partitions
// the first two elements of an array are table header and empty line delimiter, skip them
for
(
$i
=
2
;
$i
<
count
(
$partitions
);
$i
++
)
{
// select SATA devices only
if
(
preg_match
(
$regexp
,
$partitions
[
$i
],
$name
)
==
1
)
{
$names
[
$j
]
=
$name
[
0
];
$j
++
;
}
}
// filter out partitions with file system
$i
=
0
;
$raw_devices
=
array
();
foreach
(
$names
as
$name
)
{
$found
=
false
;
foreach
(
$devices
as
$device
)
{
if
(
strpos
(
$device
,
$name
)
!==
false
)
$found
=
true
;
}
if
(
$found
===
false
)
{
// current partition is not found in the blkid list, add it to raw devices
$raw_devices
[
$i
]
=
"/dev/"
.
$name
;
$i
++
;
}
}
return
$raw_devices
;
}
?>
?>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment