mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 15:32:59 +02:00
- controlapi: add statfs output for a given path
This commit is contained in:
@@ -251,6 +251,11 @@
|
|||||||
<td><a href="http://box_ip/control/config">
|
<td><a href="http://box_ip/control/config">
|
||||||
http://box_ip/control/config</a></td>
|
http://box_ip/control/config</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><a href="#statfs">Dateisystemstatistiken</a></td>
|
||||||
|
<td><a href="http://box_ip/control/statfs">
|
||||||
|
http://box_ip/control/statfs</a></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="#build_live_url">Streaming URL anfordern</a></td>
|
<td><a href="#build_live_url">Streaming URL anfordern</a></td>
|
||||||
<td><a href="http://box_ip/control/build_live_url">
|
<td><a href="http://box_ip/control/build_live_url">
|
||||||
@@ -2130,6 +2135,14 @@ Beispiel:<br>
|
|||||||
...<br>
|
...<br>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- ----------------------------------------------------------- -->
|
||||||
|
<div class="title1"><a name="statfs"></a><b>Dateisystemstatistiken</b></div>
|
||||||
|
<div class="URL">Handler: http://box_ip/control/statfs</div>
|
||||||
|
<br>
|
||||||
|
<b>Parameter:</b> keine oder path=<path>; format=<plain|xml|json><br><br>
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- ----------------------------------------------------------- -->
|
<!-- ----------------------------------------------------------- -->
|
||||||
<div class="title1"><a name="build_live_url"></a><b>Streaming URL anfordern</b></div>
|
<div class="title1"><a name="build_live_url"></a><b>Streaming URL anfordern</b></div>
|
||||||
<div class="URL">Handler: http://box_ip/control/build_live_url</div>
|
<div class="URL">Handler: http://box_ip/control/build_live_url</div>
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
// system
|
// system
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/vfs.h> // for statfs
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
@@ -221,6 +222,7 @@ const CControlAPI::TyCgiCall CControlAPI::yCgiCallList[]=
|
|||||||
{"config", &CControlAPI::ConfigCGI, "text/plain"},
|
{"config", &CControlAPI::ConfigCGI, "text/plain"},
|
||||||
// filehandling
|
// filehandling
|
||||||
{"file", &CControlAPI::FileCGI, "+xml"},
|
{"file", &CControlAPI::FileCGI, "+xml"},
|
||||||
|
{"statfs", &CControlAPI::StatfsCGI, "+xml"},
|
||||||
{"getdir", &CControlAPI::getDirCGI, "+xml"}
|
{"getdir", &CControlAPI::getDirCGI, "+xml"}
|
||||||
|
|
||||||
|
|
||||||
@@ -3224,6 +3226,86 @@ void CControlAPI::FileCGI(CyhookHandler *hh) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
/** Get a list of statfs output for a given path
|
||||||
|
*
|
||||||
|
* @param hh CyhookHandler
|
||||||
|
*
|
||||||
|
* @par nhttpd-usage
|
||||||
|
* @code
|
||||||
|
* /control/statfs[?path={path}][&format=plain|xml|json]
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* @par example:
|
||||||
|
* @code
|
||||||
|
* /control/statfs
|
||||||
|
* /control/statfs?path=/media/sda1/movies&format=json
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* @par output
|
||||||
|
* @code
|
||||||
|
* {"success": "true", "data":
|
||||||
|
* {
|
||||||
|
* "statfs": [{
|
||||||
|
* "path": "/media/sda1/movies",
|
||||||
|
* "f_type": "0x4d44",
|
||||||
|
* "f_bsize": "4096",
|
||||||
|
* "f_blocks": "488444",
|
||||||
|
* "f_bfree": "365874",
|
||||||
|
* "f_bavail": "365874",
|
||||||
|
* "f_files": "0",
|
||||||
|
* "f_ffree": "0",
|
||||||
|
* "f_fsid": "0x801, 0",
|
||||||
|
* "f_namelen": "1530",
|
||||||
|
* "f_frsize": "24"
|
||||||
|
* }]
|
||||||
|
* }}
|
||||||
|
* @endcode
|
||||||
|
*/
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CControlAPI::StatfsCGI(CyhookHandler *hh) {
|
||||||
|
std::string result = "";
|
||||||
|
|
||||||
|
if (hh->ParamList["path"].empty())
|
||||||
|
hh->ParamList["path"] = "/";
|
||||||
|
|
||||||
|
TOutType outType = hh->outStart();
|
||||||
|
|
||||||
|
std::string path = hh->ParamList["path"];
|
||||||
|
struct statfs s;
|
||||||
|
if (::statfs(path.c_str(), &s) == 0)
|
||||||
|
{
|
||||||
|
std::string item = "";
|
||||||
|
item += hh->outPair("path", path.c_str(), true);
|
||||||
|
item += hh->outPair("f_type", string_printf("%#lx", (unsigned long) s.f_type), true);
|
||||||
|
item += hh->outPair("f_bsize", string_printf("%lu", (unsigned long) s.f_bsize), true);
|
||||||
|
item += hh->outPair("f_blocks", string_printf("%lu", (unsigned long) s.f_blocks), true);
|
||||||
|
item += hh->outPair("f_bfree", string_printf("%lu", (unsigned long) s.f_bfree), true);
|
||||||
|
item += hh->outPair("f_bavail", string_printf("%lu", (unsigned long) s.f_bavail), true);
|
||||||
|
item += hh->outPair("f_files", string_printf("%lu", (unsigned long) s.f_files), true);
|
||||||
|
item += hh->outPair("f_ffree", string_printf("%lu", (unsigned long) s.f_ffree), true);
|
||||||
|
item += hh->outPair("f_fsid", string_printf("%#x, %#x", (unsigned) s.f_fsid.__val[0], (unsigned) s.f_fsid.__val[1]), true);
|
||||||
|
item += hh->outPair("f_namelen", string_printf("%lu", (unsigned long) s.f_namelen), true);
|
||||||
|
item += hh->outPair("f_frsize", string_printf("%lu", (unsigned long) s.f_frsize), false);
|
||||||
|
|
||||||
|
result = hh->outArrayItem("path", item, false);
|
||||||
|
result = hh->outArray("statfs", result);
|
||||||
|
|
||||||
|
if (outType == json)
|
||||||
|
hh->WriteLn(json_out_success(result));
|
||||||
|
else
|
||||||
|
hh->WriteLn(result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (outType == json)
|
||||||
|
hh->WriteLn(json_out_error("statfs failed"));
|
||||||
|
else
|
||||||
|
hh->SendError();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/** Get neutrino directories
|
/** Get neutrino directories
|
||||||
*
|
*
|
||||||
|
@@ -127,6 +127,7 @@ private:
|
|||||||
void logoCGI(CyhookHandler *hh);
|
void logoCGI(CyhookHandler *hh);
|
||||||
void ConfigCGI(CyhookHandler *hh);
|
void ConfigCGI(CyhookHandler *hh);
|
||||||
void FileCGI(CyhookHandler *hh);
|
void FileCGI(CyhookHandler *hh);
|
||||||
|
void StatfsCGI(CyhookHandler *hh);
|
||||||
void SignalInfoCGI(CyhookHandler *hh);
|
void SignalInfoCGI(CyhookHandler *hh);
|
||||||
void getDirCGI(CyhookHandler *hh);
|
void getDirCGI(CyhookHandler *hh);
|
||||||
std::string getSubdirectories(CyhookHandler *hh, std::string path, std::string result);
|
std::string getSubdirectories(CyhookHandler *hh, std::string path, std::string result);
|
||||||
|
Reference in New Issue
Block a user