summaryrefslogtreecommitdiff
path: root/src/xine-utils/xine_check.c
diff options
context:
space:
mode:
authorStephen Torri <storri@users.sourceforge.net>2002-10-20 02:17:36 +0000
committerStephen Torri <storri@users.sourceforge.net>2002-10-20 02:17:36 +0000
commit07803fea4ffca299c39a7e427521614e96519c69 (patch)
tree0f9b96f3d9b480eaadbdbf5294f1d52037485261 /src/xine-utils/xine_check.c
parent0710ff792af82006ee882d46e3f48fdf8da99dc7 (diff)
downloadxine-lib-07803fea4ffca299c39a7e427521614e96519c69.tar.gz
xine-lib-07803fea4ffca299c39a7e427521614e96519c69.tar.bz2
AUTHORS:
Added myself to AUTHORS configure.ac: Removed a '-O' flag from DEBUG_CFLAGS when its initialized. The flag is added later depending on architecture of CPU. include/xine.h.in: src/xine-utils/Makefile.am: src/xine-utils/xine_check.h: src/xine-utils/xine_check.c: misc/xine-config.in: Moved some of the system checks from xine-config.in to xine_check.c. Now some of the checks are written in C instead of shell script. This is the first beta/bleeding edge/kick the tires/it might break for you version. It works for me (Intel P3). It will report to the stdout your kernel version, MTRR (x86) architecture only (depends on kernel), symbolic link for CDROM is ok, symbolic link for DVD is ok, and if environment variable "DISPLAY" is set. It will later support telling if DMA is turned on for IDE based DVD drives (Need help here - see below) and XVinfo. DMA: <HELP REQUIRED>: DMA is successfully check but I cannot determine that from the /dev/dvd symbolic link for those DVD drives that need to use the ide-scsi module (e.g. My DVD/CDRW). I can verify DMA is set if I hard code the link into the code (obviously not a prime choice). So if any solutions are known please pass them along. misc/Makefile.am: misc/xine-config.in: src/xine-engine/Makefile.am: Removed xine_logo information from xine-lib. Please let me know if I missed anyting. CVS patchset: 2869 CVS date: 2002/10/20 02:17:36
Diffstat (limited to 'src/xine-utils/xine_check.c')
-rw-r--r--src/xine-utils/xine_check.c265
1 files changed, 265 insertions, 0 deletions
diff --git a/src/xine-utils/xine_check.c b/src/xine-utils/xine_check.c
new file mode 100644
index 000000000..6fd65515d
--- /dev/null
+++ b/src/xine-utils/xine_check.c
@@ -0,0 +1,265 @@
+#include "xine_check.h"
+#include <stdio.h>
+#include "xineutils.h"
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <sys/utsname.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <linux/major.h>
+#include <linux/hdreg.h>
+#include <errno.h>
+
+typedef struct {
+ FILE *fd;
+ char *filename;
+ char *ln;
+ char buf[256];
+} file_info_t;
+
+int xine_health_check()
+{
+ int retval = 0;
+
+#if 0
+ if (xine_health_check_os() < 0)
+ {
+ retval = -1;
+ }
+#endif
+
+ if (xine_health_check_kernel() < 0)
+ {
+ retval = -1;
+ }
+
+#if ARCH_X86
+ if (xine_health_check_mtrr() < 0)
+ {
+ retval = -1;
+ }
+#endif /* ARCH_X86 */
+
+ if (xine_health_check_cdrom() < 0)
+ {
+ retval = -1;
+ }
+
+ if (xine_health_check_dvdrom() < 0)
+ {
+ retval = -1;
+ }
+
+#if 0
+ if (xine_health_check_dma() < 0)
+ {
+ retval = -1;
+ }
+#endif
+
+ if (xine_health_check_x() < 0)
+ {
+ retval = -1;
+ }
+
+ if (xine_health_check_xv() < 0)
+ {
+ retval = -1;
+ }
+
+ return retval;
+}
+
+int xine_health_check_os(void)
+{
+ fprintf(stdout, "xine health_check (OS): ");
+ int retval = 0;
+
+ return retval;
+}
+
+int xine_health_check_kernel(void)
+{
+ fprintf(stdout, "xine health_check (Kernel):\n");
+
+ struct utsname kernel;
+ if (uname(&kernel) == 0)
+ {
+ fprintf(stdout," sysname: %s\n", kernel.sysname);
+ fprintf(stdout," release: %s\n", kernel.release);
+ fprintf(stdout," machine: %s\n", kernel.machine);
+ }
+ else
+ {
+ fprintf(stdout," FAILURE - Could not get kernel information.\n");
+ return -1;
+ }
+ return 0;
+}
+
+int xine_health_check_mtrr(void)
+{
+ fprintf(stdout, "xine health_check (MTRR):\n");
+
+ char *file = "/proc/mtrr";
+ FILE *fd;
+ fd = fopen(file, "r");
+ if (fd < 0)
+ {
+ fprintf(stdout, " FAILED: mtrr is not enabled.\n");
+ return -1;
+ }
+ else {
+ fprintf(stdout, " SUCCESS: mtrr is enabled.\n");
+ fclose(fd);
+ }
+ return 0;
+}
+
+int xine_health_check_cdrom(void)
+{
+ fprintf(stdout, "xine health_check (CDROM):\n");
+ char* cdrom_name = "/dev/cdrom";
+ struct stat cdrom_st;
+
+ if (stat(cdrom_name,&cdrom_st) < 0)
+ {
+ fprintf(stdout, " FAILED - could not cdrom: %s.\n", cdrom_name);
+ return -1;
+ }
+ else
+ {
+ fprintf(stdout, " SUCCESS - cdrom link %s is present.\n",cdrom_name);
+ }
+
+ if ((cdrom_st.st_mode & S_IFMT) != S_IFBLK)
+ {
+ fprintf(stdout, " FAILED - %s is not a block device.\n", cdrom_name);
+ return -1;
+ }
+ else
+ {
+ fprintf(stdout, " SUCCESS - %s is a block device.\n", cdrom_name);
+ }
+
+ if ((cdrom_st.st_mode & S_IFMT & S_IRWXU & S_IRWXG & S_IRWXO) != (S_IRUSR & S_IXUSR & S_IRGRP & S_IXGRP & S_IROTH & S_IXOTH))
+ {
+ fprintf(stdout, " FAILED - %s permissions are not 'rwxrwxrx'.\n",cdrom_name);
+ }
+ else {
+ fprintf(stdout, " SUCCESS - %s does have proper permission.\n",cdrom_name);
+ }
+
+ return 0;
+}
+
+int xine_health_check_dvdrom(void)
+{
+ fprintf(stdout, "xine health_check (DVDROM):\n");
+ char* dvdrom_name = "/dev/dvd";
+ struct stat dvdrom_st;
+
+ if (stat(dvdrom_name,&dvdrom_st) < 0)
+ {
+ fprintf(stdout, " FAILED - could not dvdrom: %s.\n", dvdrom_name);
+ return -1;
+ }
+ else
+ {
+ fprintf(stdout, " SUCCESS - dvdrom link %s is present.\n",dvdrom_name);
+ }
+
+ if ((dvdrom_st.st_mode & S_IFMT) != S_IFBLK)
+ {
+ fprintf(stdout, " FAILED - %s is not a block device.\n", dvdrom_name);
+ return -1;
+ }
+ else
+ {
+ fprintf(stdout, " SUCCESS - %s is a block device.\n", dvdrom_name);
+ }
+
+ if ((dvdrom_st.st_mode & S_IFMT & S_IRWXU & S_IRWXG & S_IRWXO) != (S_IRUSR & S_IXUSR & S_IRGRP & S_IXGRP & S_IROTH & S_IXOTH))
+ {
+ fprintf(stdout, " FAILED - %s permissions are not 'rwxrwxrx'.\n",dvdrom_name);
+ }
+ else {
+ fprintf(stdout, " SUCCESS - %s does have proper permission.\n",dvdrom_name);
+ }
+
+ return 0;
+}
+
+int xine_health_check_dma(void)
+{
+ fprintf(stdout, "xine health_check (DMA):\n");
+ int retval = 0;
+ int is_scsi_dev = 0;
+ int fd = 0;
+ static long param = 0;
+
+ /* If /dev/dvd points to /dev/scd0 but the drive is IDE (e.g. /dev/hdc) and not scsi
+ * how do we detect the correct one */
+ char* name = "/dev/hdc";
+ struct stat st;
+ if (stat(name, &st)){
+ perror(name);
+ exit(errno);
+ }
+
+ if (major(st.st_rdev) == LVM_BLK_MAJOR){
+ is_scsi_dev = 1;
+ fprintf(stdout, " SKIPPED - Operation not supported on SCSI disks.\n");
+ }
+
+ /* At this time due to the way my system is setup user 'root' must be runnning xine */
+ fd = open(name, O_RDONLY | O_NONBLOCK);
+ if (fd < 0)
+ {
+ perror(name);
+ exit(errno);
+ }
+
+ if (!is_scsi_dev){
+ if(ioctl(fd, HDIO_GET_DMA, &param))
+ {
+ fprintf(stdout, " FAILED - HDIO_GET_DMA failed. Ensure the permissions for %s are 0664.\n", name);
+ }
+ if (param != 1)
+ {
+ fprintf(stdout, " FAILED - DMA not turned on for %s.\n", name);
+ }
+ else
+ {
+ fprintf(stdout, " SUCCESS - DMA turned on for %s.\n", name);
+ close(fd);
+ }
+ }
+
+ return retval;
+}
+
+int xine_health_check_x(void)
+{
+ fprintf(stdout, "xine health_check (X):\n");
+ char* env_display = getenv("DISPLAY");
+ if (strlen(env_display) == 0)
+ {
+ fprintf(stdout, " FAILED - DISPLAY environment variable not set.\n");
+ return -1;
+ }
+ else
+ {
+ fprintf(stdout, " SUCCESS - DISPLAY environment variable is set.\n");
+ }
+ return 0;
+}
+
+int xine_health_check_xv(void)
+{
+ fprintf(stdout, "xine health_check (XV):\n");
+ int retval = 0;
+
+ return retval;
+}
+