allow TS only if >1G of free space
authorFelix Domke <tmbinc@elitedvb.net>
Fri, 27 Jan 2006 13:55:51 +0000 (13:55 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Fri, 27 Jan 2006 13:55:51 +0000 (13:55 +0000)
lib/service/servicedvb.cpp

index d1cc4ef83bedc2f7a695b0ea303e8ffe80f7a351..7beb6c2506ab137f63e850ca3a6456e35367cb78 100644 (file)
 #include <lib/dvb/tstools.h>
 #include <lib/python/python.h>
 
+#include <sys/vfs.h>
+
+#define TSPATH "/media/hdd"
+
 class eStaticServiceDVBInformation: public iStaticServiceInformation
 {
        DECLARE_REF(eStaticServiceDVBInformation);
@@ -685,7 +689,7 @@ RESULT eDVBServicePlay::setFastForward(int ratio)
        {
                skipmode = 0;
                ffratio = 0;
-       } else if (ratio < 0)
+       } else // if (ratio < 0)
        {
                skipmode = ratio;
                ffratio = 1;
@@ -837,12 +841,28 @@ RESULT eDVBServicePlay::subServices(ePtr<iSubserviceList> &ptr)
 
 RESULT eDVBServicePlay::timeshift(ePtr<iTimeshiftService> &ptr)
 {
+       ptr = 0;
        if (m_timeshift_enabled || !m_is_pvr)
        {
+               if (!m_timeshift_enabled)
+               {
+                               /* we need enough diskspace */
+                       struct statfs fs;
+                       if (statfs(TSPATH "/.", &fs) < 0)
+                       {
+                               eDebug("statfs failed!");
+                               return -2;
+                       }
+               
+                       if (((off_t)fs.f_bavail) * ((off_t)fs.f_bsize) < 1024*1024*1024LL)
+                       {
+                               eDebug("not enough diskspace for timeshift! (less than 1GB)");
+                               return -3;
+                       }
+               }
                ptr = this;
                return 0;
        }
-       ptr = 0;
        return -1;
 }
 
@@ -1085,7 +1105,7 @@ RESULT eDVBServicePlay::startTimeshift()
        if (!m_record)
                return -3;
 
-       char templ[]="/media/hdd/timeshift.XXXXXX";
+       char templ[]=TSPATH "/timeshift.XXXXXX";
        m_timeshift_fd = mkstemp(templ);
        m_timeshift_file = templ;