hal/hald/linux2/probing .cvsignore, 1.1, 1.2 Makefile.am, 1.9, 1.10 probe-serial.c, NONE, 1.1

Richard Hughes hughsient at freedesktop.org
Wed Sep 28 09:34:01 PDT 2005


Update of /cvs/hal/hal/hald/linux2/probing
In directory gabe:/tmp/cvs-serv11654

Modified Files:
	.cvsignore Makefile.am 
Added Files:
	probe-serial.c 
Log Message:
New file to probe serial ports to see if they actually exist. Drivers such as 8250 are considered legacy and very enumeration-unfriendly, and just create up to 32	devices that don't actually exist.

Index: .cvsignore
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/probing/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- .cvsignore	21 Jun 2005 16:57:21 -0000	1.1
+++ .cvsignore	28 Sep 2005 16:33:59 -0000	1.2
@@ -11,3 +11,4 @@
 hald-probe-smbios
 hald-probe-storage
 hald-probe-volume
+hald-probe-serial

Index: Makefile.am
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/probing/Makefile.am,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- Makefile.am	25 Aug 2005 19:36:29 -0000	1.9
+++ Makefile.am	28 Sep 2005 16:33:59 -0000	1.10
@@ -10,7 +10,7 @@
 
 if HALD_COMPILE_LINUX2
 libexec_PROGRAMS = hald-probe-input hald-probe-hiddev hald-probe-storage hald-probe-volume hald-probe-printer \
-	           hald-probe-pc-floppy hald-probe-smbios
+	           hald-probe-pc-floppy hald-probe-smbios hald-probe-serial
 endif
 
 hald_probe_smbios_SOURCES = probe-smbios.c shared.h
@@ -26,6 +26,9 @@
 hald_probe_hiddev_SOURCES = probe-hiddev.c shared.h
 hald_probe_hiddev_LDADD = $(top_builddir)/libhal/libhal.la
 
+hald_probe_serial_SOURCES = probe-serial.c shared.h
+hald_probe_serial_LDADD = $(top_builddir)/libhal/libhal.la
+
 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
 

--- NEW FILE: probe-serial.c ---
/***************************************************************************
 * CVSID: $Id: probe-serial.c,v 1.1 2005/09/28 16:33:59 hughsient Exp $
 *
 * probe-serial.c : Probe serial ports
 *
 * Copyright (C) 2005 Pierre Ossman <drzeus at drzeus.cx>
 *
 * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  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 <stdint.h>
#include <sys/stat.h>
#include <stdint.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/serial.h>

#include "libhal/libhal.h"

#include "shared.h"

int 
main (int argc, char *argv[])
{
	int fd;
	int ret;
	char *udi;
	char *device_file;
	struct serial_struct ss;

	fd = -1;

	/* assume failure */
	ret = 1;

	if ((udi = getenv ("UDI")) == NULL)
		goto out;
	if ((device_file = getenv ("HAL_PROP_SERIAL_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;
	}
	
	if (ioctl (fd, TIOCGSERIAL, &ss)) {
		dbg ("TIOCGSERIAL failed for %s", device_file);
		goto out;
	}
	
	if (ss.type == 0) {
		dbg ("serial port %s seems not to exist", device_file);
		goto out;
	}

	/* works */
	ret = 0;

out:
	if (fd >= 0)
		close (fd);

	return ret;
}




More information about the hal-commit mailing list