My apologies for posting in English. I do read German (and write a bit), so feel free to answer in German
I noticed that Enigma only shows free space on the HDD if it is recording, and I also noticed that the function call showHDDSpaceLeft was commented out, with the comment 'i don't like always running HDD !!'. I completely agree with that comment, but I do like to see the amount of free space.
Below is a patch which fixes this. I modified the function freeRecordSpace to check if the drive is sleeping, before accessing the disk. If the drive is in standby or sleeping, it is not woken up, unless we want it to (for example, when starting a recording). The code to check if the drive is sleeping is taken from hdparm.
Comments and suggestions welcome
Best regards,
Ruud
Patch is available here.
Edit: Added link to patch
Code: Alles auswählen
Index: src/enigma_dyn.cpp
===================================================================
RCS file: /cvs/tuxbox/apps/tuxbox/enigma/src/enigma_dyn.cpp,v
retrieving revision 1.430
diff -u -r1.430 enigma_dyn.cpp
--- a/src/enigma_dyn.cpp 21 Jan 2005 20:52:15 -0000 1.430
+++ b/src/enigma_dyn.cpp 22 Jan 2005 22:17:08 -0000
@@ -4576,7 +4576,7 @@
}
#ifndef DISABLE_FILE
-extern int freeRecordSpace(void); // implemented in enigma_main.cpp
+extern int freeRecordSpace(bool); // implemented in enigma_main.cpp
#endif
static eString data(eString request, eString dirpath, eString opt, eHTTPConnection *content)
@@ -4615,7 +4615,7 @@
// free recording space on disk
#ifndef DISABLE_FILE
- int fds = freeRecordSpace();
+ int fds = freeRecordSpace(false);
#else
int fds = 0;
#endif
Index: src/enigma_main.cpp
===================================================================
RCS file: /cvs/tuxbox/apps/tuxbox/enigma/src/enigma_main.cpp,v
retrieving revision 1.248
diff -u -r1.248 enigma_main.cpp
--- a/src/enigma_main.cpp 21 Jan 2005 09:58:11 -0000 1.248
+++ b/src/enigma_main.cpp 22 Jan 2005 22:17:09 -0000
@@ -10,6 +10,7 @@
#include <sys/vfs.h>
#include <unistd.h>
#include <sys/ioctl.h>
+#include <linux/hdreg.h>
#include <streaminfo.h>
#include <parentallock.h>
@@ -2988,14 +2989,53 @@
recordDVR(1, 1);
}
-int freeRecordSpace()
+int freeRecordSpace(bool wakeup)
{
+static int free = -1;
+ bool drive_sleeping = false;
+#ifdef HDIO_DRIVE_CMD
+#ifndef WIN_CHECKPOWERMODE1
+#define WIN_CHECKPOWERMODE1 0xE5
+#endif
+#ifndef WIN_CHECKPOWERMODE2
+#define WIN_CHECKPOWERMODE2 0x98
+#endif
+ //Open drive
+ if (!wakeup) {
+ int fd;
+
+ fd = open ("/dev/ide/host0/bus0/target0/lun0/disc", O_RDONLY|O_NONBLOCK); //hardcoded for now
+ if (fd >= 0) {
+ unsigned char args[4] = {WIN_CHECKPOWERMODE1,0,0,0};
+
+
+ if (ioctl(fd, HDIO_DRIVE_CMD, &args)
+ && (args[0] = WIN_CHECKPOWERMODE2) /* try again with 0x98 */
+ && ioctl(fd, HDIO_DRIVE_CMD, &args)) {
+ drive_sleeping = true;//sleeping or unknown, don't wake drive if unknown;
+ } else {
+ drive_sleeping = (args[2] == 255) ? false : true;
+ }
+ close(fd);
+ }
+ }
+#endif //HDIO_DRIVE_CMD
struct statfs s;
- int free;
- if (statfs(MOVIEDIR, &s)<0)
- free=-1;
- else
- free=s.f_bfree/1000*s.f_bsize/1000;
+#ifdef HDIO_DRIVE_CMD
+ if (!drive_sleeping || wakeup) {
+#endif
+ if (statfs(MOVIEDIR, &s)<0)
+ free=-1;
+ else
+ free=s.f_bfree/1000*s.f_bsize/1000;
+#ifdef HDIO_DRIVE_CMD
+ }
+#endif
return free;
}
@@ -3010,7 +3050,7 @@
if (onoff) // start recording
{
- if ( freeRecordSpace() < 10) // less than 10MB free (or directory not found)
+ if ( freeRecordSpace(true) < 10) // less than 10MB free (or directory not found)
{
handleServiceEvent(eServiceEvent(eServiceEvent::evtRecordFailed));
return -3;
@@ -5038,7 +5078,7 @@
static int cnt=0;
static int swp=0;
- int fds=freeRecordSpace();
+ int fds=freeRecordSpace(true);
if (fds)
{
if (!(cnt++ % 7))
@@ -5714,7 +5754,7 @@
#ifndef DISABLE_FILE
case eServiceEvent::evtRecordFailed:
{
- int freespace = freeRecordSpace();
+ int freespace = freeRecordSpace(false);
if ( state&stateInTimerMode )
{
@@ -6694,7 +6734,7 @@
{
static int swp;
- int fds = freeRecordSpace();
+ int fds = freeRecordSpace(false);
if (fds != -1)
{
swp^=1;
@@ -6730,7 +6770,9 @@
dvrInfoBar->show();
#ifndef DISABLE_FILE
// i don't like always running HDD !!
-// showHDDSpaceLeft(DVRSpaceLeft);
+#ifdef HDIO_DRIVE_CMD
+ showHDDSpaceLeft(DVRSpaceLeft);
+#endif
#endif
prepareDVRHelp();
} else