hal/hald/linux2/probing Makefile.am, 1.5, 1.6 probe-pc-floppy.c,
NONE, 1.1
David Zeuthen
david at freedesktop.org
Fri Feb 25 14:01:16 PST 2005
Update of /cvs/hal/hal/hald/linux2/probing
In directory gabe:/tmp/cvs-serv11139/hald/linux2/probing
Modified Files:
Makefile.am
Added Files:
probe-pc-floppy.c
Log Message:
2005-02-25 David Zeuthen <davidz at redhat.com>
* hald/linux2/probing/probe-pc-floppy.c: New file; test for floppy
drive
* hald/linux2/probing/Makefile.am: Add build rules for hald-probe-
pc-floppy
* hald/linux2/blockdev.c (blockdev_callouts_preprobing_storage_done):
Do a special probe to see if the PC Floppy Drive is actually there -
since many IDE laptops got the controller chip but not the drive.
(hotplug_event_begin_add_blockdev): Learn how to spell; floppy not
floopy :-/
Index: Makefile.am
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/probing/Makefile.am,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Makefile.am 24 Feb 2005 17:33:03 -0000 1.5
+++ Makefile.am 25 Feb 2005 22:01:14 -0000 1.6
@@ -8,7 +8,8 @@
-I$(top_srcdir) \
@PACKAGE_CFLAGS@
-libexec_PROGRAMS = hald-probe-input hald-probe-hiddev hald-probe-storage hald-probe-volume hald-probe-printer
+libexec_PROGRAMS = hald-probe-input hald-probe-hiddev hald-probe-storage hald-probe-volume hald-probe-printer \
+ hald-probe-pc-floppy
hald_probe_printer_SOURCES = probe-printer.c shared.h
hald_probe_printer_LDADD = $(top_builddir)/libhal/libhal.la @PACKAGE_LIBS@
@@ -23,6 +24,8 @@
hald_probe_storage_SOURCES = probe-storage.c linux_dvd_rw_utils.c linux_dvd_rw_utils.h shared.h
hald_probe_storage_LDADD = $(top_builddir)/libhal/libhal.la $(top_builddir)/drive_id/libdrive_id.la $(top_builddir)/volume_id/libvolume_id.la
+hald_probe_pc_floppy_SOURCES = probe-pc-floppy.c
+
hald_probe_volume_SOURCES = probe-volume.c linux_dvd_rw_utils.c linux_dvd_rw_utils.h shared.h
hald_probe_volume_LDADD = $(top_builddir)/libhal/libhal.la $(top_builddir)/drive_id/libdrive_id.la $(top_builddir)/volume_id/libvolume_id.la
--- NEW FILE: probe-pc-floppy.c ---
/***************************************************************************
* CVSID: $Id: probe-pc-floppy.c,v 1.1 2005/02/25 22:01:14 david Exp $
*
* probe-storage.c : Probe storage devices
*
* Copyright (C) 2004 David Zeuthen, <david at fubar.dk>
*
* Licensed under the Academic Free License version 2.0
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
**************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <asm/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/kdev_t.h>
#include <linux/cdrom.h>
#include <linux/fs.h>
#include <linux/fd.h>
#include "libhal/libhal.h"
#include "shared.h"
int
main (int argc, char *argv[])
{
int fd;
int ret;
char *udi;
char *device_file;
LibHalContext *ctx = NULL;
DBusError error;
DBusConnection *conn;
char name[256];
struct floppy_drive_struct ds;
fd = -1;
/* assume failure */
ret = 1;
if ((udi = getenv ("UDI")) == NULL)
goto out;
if ((device_file = getenv ("HAL_PROP_BLOCK_DEVICE")) == NULL)
goto out;
if ((getenv ("HALD_VERBOSE")) != NULL)
is_verbose = TRUE;
dbg ("Checking if %s is actually present", device_file);
/* Check that there actually is a drive at the other end */
fd = open (device_file, O_RDONLY | O_NONBLOCK);
if (fd < 0) {
dbg ("Could not open %s", device_file);
goto out;
}
/* @todo Could use the name here */
ioctl (fd, FDRESET, NULL);
if (ioctl (fd, FDGETDRVTYP, name) != 0) {
dbg ("FDGETDRVTYP failed for %s", device_file);
goto out;
}
dbg ("floppy drive name is '%s'", name);
if (ioctl (fd, FDPOLLDRVSTAT, &ds)) {
dbg ("FDPOLLDRVSTAT failed for %s", device_file);
goto out;
}
if (ds.track < 0) {
dbg ("floppy drive %s seems not to exist", device_file);
goto out;
}
/* works */
ret = 0;
out:
if (fd >= 0)
close (fd);
if (ctx != NULL) {
dbus_error_init (&error);
libhal_ctx_shutdown (ctx, &error);
libhal_ctx_free (ctx);
}
return ret;
}
More information about the hal-commit
mailing list