File system status check page

This page shows how to check the file system status of the internal hard drive.

<html>
<head>
<script language="Javascript">

function setStatus(status, append)
{
  if (!append) {
    document.getElementById("status").innerHTML = status;
  }
  else {
    document.getElementById("status").innerHTML += "<br>" + status;
  }
}

function checkLocalStorage()
{
  var devicesIds;
  try {
    devicesIds = toi.storageService.getStorageDeviceIds();
  }
  catch (ex) {
    setStatus("DVR not activated");
    return;
  }

  setStatus("Scanning for local storage");
  var foundInternal = false;

  // Search for the internal storage device
  var devicesIds = toi.storageService.getStorageDeviceIds();
  for (var i = 0; i < devicesIds.length; i++) {
    var device = toi.storageService.getStorageDevice(devicesIds[i]);
    var info = device.getStorageInfo();

    if (info.isInternal) {
      // Check all partitions for file system status and schedule a reformat of
      // those that are broken.
      for (var j = 0; j < info.partitions.length; j++) {
        foundInternal = true;

        var partInfo = device.getPartitionInfo(info.partitions[j]);
        switch (partInfo.fsStatus) {
        case device.FS_STATUS_OK:
        case device.FS_STATUS_ERRORS_CORRECTED:
          setStatus("Storage device " + info.id + " partition " +
                    partInfo.id + " OK", true);
          break;
        case device.FS_STATUS_ERRORS_LEFT_UNCORRECTED:
        case device.FS_STATUS_MAJOR_FAILURE:
          setStatus("Storage device " + info.id + " partition " +
                    partInfo.id + " BROKEN; will reformat on next boot", true);
          device.scheduleReformatOnNextReboot(partInfo.id);
          break;
        }
      }
    }
  }

  if (!foundInternal) {
    setStatus("Could not find any local storage", true);
    return;
  }
}

function onLoad()
{
  checkLocalStorage();
}

</script>
</head>
<body onLoad="onLoad();">
  <embed type="application/x-motorola-toi" hidden="true" />
  <div style="margin-top: 200px;">
    <p style="text-align: center" id="status">Loading...</p>
  </div>
</body>
</html>