summaryrefslogtreecommitdiff
path: root/tools.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <kls (at) cadsoft (dot) de>2002-04-01 18:00:00 +0200
committerKlaus Schmidinger <kls (at) cadsoft (dot) de>2002-04-01 18:00:00 +0200
commit262327908d329a8c292d8ae71fe9d135390a3cde (patch)
tree033135443f0f387557d1f988445abacd30c0dbe4 /tools.c
parent217fcb26808f74c9de81b4c653757f75ba13852f (diff)
downloadvdr-patch-lnbsharing-262327908d329a8c292d8ae71fe9d135390a3cde.tar.gz
vdr-patch-lnbsharing-262327908d329a8c292d8ae71fe9d135390a3cde.tar.bz2
Version 1.0.0pre5vdr-1.0.0pre5
- Fixed restoring CICAM setup values for a fourth DVB card (thanks to Klaus Wolf). - Completed internationalization of OSD texts (thanks to Hannu Savolainen, Arnold Niessen, Paulo Lopes, Jean-Claude Repetto, Alberto Carraro, Matjaz Thaler and Truls Slevigen). - Improved file I/O in case of EINTR, which may occur e.g. with heavy system load (thanks to Werner Fink). - Now writing the title of a recording into the 'summary.vdr' file. - Workaround for displaying still frames with the unpatched LinuxDVB driver (if anybody ever finds out why the unpatched driver doesn't display VDR's still frames, please let me know). - When executing a command from the "Commands" menu, the title of that command is now immediately shown in the status line (followed by "...") to give the user some feedback that the command is being executed, which is especially important if this takes some time. - Fixed scrolling the "Channels" menu in case the cursor ends up on a group delimiter (thanks to Bernd Zierath for helping to debug this one). - Added manual pages vdr(1) and vdr(5) (which made the FORMATS file obsolete). - New command command line option '-V' to display the VDR version. - Adjusting column width for channel numbers in case there are more than 999 channels. - Checking the return value of '...FileRady...' calls in dvbapi.c for better performance under heavy system load. - New 'make' target 'install', which copies the manual pages and executables to their appropriate system locations and creates the /video directory if it doesn't exist yet. - Automatic hotkey assignment is now suppressed if the first entry in commands.conf starts with a digit in the range '1'...'9', followed by a blank. - Fixed a bug in switching back the replay mode display in time shift mode (thanks to Achim Lange for reporting this one). - Fixed a bug in the 'First day' timer parameter for timers that record over midnight. - Added units to Setup parameters. - Changed time entry in the 'Jump' command during replay, so that it is filled up from right to left. - Now using statfs() to determine the amount of free disk space, which avoids the use of an external 'df' command (thanks to Ruben Nunez Francisco). - Fixed skipping the next hit of a repeating timer (thanks to Rainer Zocholl for reporting this one). - Fixed a bug when a timer records over midnight of a day that had a change in Daylight Saving Time. - Added Polish language texts (thanks to Michael Rakowski). - Fixed a bug in parsing group separators in channels.conf (thanks to Henning Holtschneider for reporting this one). - Changed the default 'Ok' key when using the PC keyboard from '5' (in the numeric block) to 'Enter', because the '5' key didn't work on keyboards with the F-keys on top. - Fixed a bug in the EPG bugfix mechanism if the extended description is shorter than 3 characters (thanks to Andreas Schultz).
Diffstat (limited to 'tools.c')
-rw-r--r--tools.c55
1 files changed, 25 insertions, 30 deletions
diff --git a/tools.c b/tools.c
index 3764a64..099fb7d 100644
--- a/tools.c
+++ b/tools.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: tools.c 1.59 2002/02/17 12:57:23 kls Exp $
+ * $Id: tools.c 1.62 2002/03/31 20:51:06 kls Exp $
*/
#include "tools.h"
@@ -13,6 +13,7 @@
#include <errno.h>
#include <stdlib.h>
#include <sys/time.h>
+#include <sys/vfs.h>
#include <time.h>
#include <unistd.h>
#include "i18n.h"
@@ -33,14 +34,22 @@ ssize_t safe_read(int filedes, void *buffer, size_t size)
ssize_t safe_write(int filedes, const void *buffer, size_t size)
{
- for (;;) {
- ssize_t p = write(filedes, buffer, size);
- if (p < 0 && errno == EINTR) {
- dsyslog(LOG_INFO, "EINTR while writing to file handle %d - retrying", filedes);
- continue;
- }
- return p;
- }
+ ssize_t p = 0;
+ ssize_t written = size;
+ const unsigned char *ptr = (const unsigned char *)buffer;
+ while (size > 0) {
+ p = write(filedes, ptr, size);
+ if (p < 0) {
+ if (errno == EINTR) {
+ dsyslog(LOG_INFO, "EINTR while writing to file handle %d - retrying", filedes);
+ continue;
+ }
+ break;
+ }
+ ptr += p;
+ size -= p;
+ }
+ return p < 0 ? p : written;
}
void writechar(int filedes, char c)
@@ -235,34 +244,20 @@ const char *AddDirectory(const char *DirName, const char *FileName)
return buf;
}
-#define DFCMD "df -m -P '%s'"
-
int FreeDiskSpaceMB(const char *Directory, int *UsedMB)
{
- //TODO Find a simpler way to determine the amount of free disk space!
if (UsedMB)
*UsedMB = 0;
int Free = 0;
- char *cmd = NULL;
- asprintf(&cmd, DFCMD, Directory);
- FILE *p = popen(cmd, "r");
- if (p) {
- char *s;
- while ((s = readline(p)) != NULL) {
- if (strchr(s, '/')) {
- int used, available;
- sscanf(s, "%*s %*d %d %d", &used, &available);
- if (UsedMB)
- *UsedMB = used;
- Free = available;
- break;
- }
- }
- pclose(p);
+ struct statfs statFs;
+ if (statfs(Directory, &statFs) == 0) {
+ int blocksPerMeg = 1024 * 1024 / statFs.f_bsize;
+ if (UsedMB)
+ *UsedMB = (statFs.f_blocks - statFs.f_bfree) / blocksPerMeg;
+ Free = statFs.f_bavail / blocksPerMeg;
}
else
- esyslog(LOG_ERR, "ERROR: can't open pipe for cmd '%s'", cmd);
- delete cmd;
+ LOG_ERROR_STR(Directory);
return Free;
}