debian/0000755000000000000000000000000011772067130007172 5ustar debian/changelog0000644000000000000000000002706311772067130011054 0ustar pcmciautils (018-8) unstable; urgency=low * Mark pcmciautils and pcmciautils-udeb Architecture: linux-any. -- Colin Watson Mon, 25 Jun 2012 14:57:42 +0100 pcmciautils (018-7) unstable; urgency=low * Use dpkg-buildflags to enable hardening options. -- Colin Watson Fri, 22 Jun 2012 13:55:20 +0100 pcmciautils (018-6) unstable; urgency=low * Prevent the upstream build system calling strip, and rely on dh_strip instead to honour Debian policy requirements. -- Colin Watson Wed, 21 Mar 2012 18:49:30 +0000 pcmciautils (018-5) unstable; urgency=low * Use dh_installdeb's maintscript support rather than writing it into maintainer scripts by hand. We now just pre-depend on a sufficient version of dpkg rather than using 'dpkg-maintscript-helper supports rm_conffile' guards. -- Colin Watson Sat, 11 Feb 2012 14:27:49 +0000 pcmciautils (018-4) unstable; urgency=low * Add cross-compiling support. -- Colin Watson Fri, 16 Sep 2011 10:59:13 +0100 pcmciautils (018-3) unstable; urgency=low * Also remove libsysfs-dev from build-deps. -- Per Olofsson Sun, 12 Jun 2011 20:29:55 +0200 pcmciautils (018-2) unstable; urgency=low [ Per Olofsson ] * Remove module-init-tools and lsb-base from Depends, since the init script is now gone. * Rename debian/pcmciautils.docs to debian/docs. * Actually remove unnecessary-linkage.patch, not only from series. * Add patch remove-libsysfs-dep.patch from upstream to remove dependency on libsysfs. Closes: #627648. [ Colin Watson ] * Update Vcs-Bzr field for Alioth changes. -- Per Olofsson Sun, 12 Jun 2011 19:53:52 +0200 pcmciautils (018-1) unstable; urgency=low [ Colin Watson ] * udev rules are now installed in /lib/udev/rules.d/ (closes: #575830). Preserve any user changes found in /etc/udev/pcmcia.rules. * Convert to source format 3.0 (quilt) and DEP-3 patch tagging. [ Per Olofsson ] * New upstream release. - Drop unnecessary-linkage.patch, applied upstream. * Remove obsolete README.Debian. * Bump Standards-Version to 3.9.2. No changes. * Remove init script. Driver module should be loaded by udev or /etc/modules. Add note to NEWS.Debian. * Simplify debian/rules. * Remove old cruft from maintainer scripts. * Create /etc/pcmcia directory if it doesn't exist. -- Per Olofsson Mon, 25 Apr 2011 22:33:46 +0200 pcmciautils (015-1) unstable; urgency=low * New upstream release. - Simplified the setting of sysfs attributes; requires udev 098. * Vcs-Bzr is now an official field. * Add a Homepage field. * Don't link pcmcia-check-broken-cis against libsysfs; dpkg-shlibdeps reports that it doesn't need it. * The init script should either print a message and exit non-zero, or be silent and exit zero, not somewhere in between. Of the cases where the init script bails out, having an old kernel or not having udev enabled are more or less error cases, but not having configured a bridge module probably just means that you're on hardware that doesn't need this. Regularise our output to make sense in light of this. Thanks to Kel Modderman for reporting this. * Upgrade to debhelper v7. * Only list udev in init script's Should-Start, not Required-Start, and require $local_fs to start first instead (thanks, Petter Reinholdtsen; closes: #548621). * Start init script before networking if possible (thanks, Petter Reinholdtsen). * Attempt to cope slightly better with udev not being installed (closes: #419172). * Refer to versioned GPL file in debian/copyright. -- Colin Watson Tue, 05 Jan 2010 11:57:54 +0000 pcmciautils (014-4) unstable; urgency=low [ Per Olofsson ] * Add XS-Vcs-Bzr field to debian/control and remove obsolete URL from debian/copyright. [ Colin Watson ] * Adjust pccardctl(8) to note that the status command is now implemented and to document the ls command and lspcmcia (closes: #392436). * Add Required-Start and Required-Stop LSB headers to init script. * Change Default-Start LSB header to S and make Default-Stop empty to match our update-rc.d invocation. * Fix lspcmcia crash on out-of-range function ids (thanks, Samuel Thibault; closes: #406251). -- Colin Watson Sun, 19 Aug 2007 13:59:40 +0100 pcmciautils (014-3) unstable; urgency=low * Honour PCMCIA=no (or false) in /etc/default/pcmciautils (closes: https://launchpad.net/bugs/52231). * Fall back to /usr/lib/pcmciautils/config.opts if /etc/pcmcia/config.opts doesn't exist (closes: #392222). -- Colin Watson Mon, 27 Nov 2006 13:52:32 +0000 pcmciautils (014-2) unstable; urgency=low [ Colin Watson ] * Depend on lsb-base (>= 3.0-6). [ Scott James Remnant ] * Remove stop links from rc0 and rc6. -- Colin Watson Fri, 21 Jul 2006 11:23:36 +0100 pcmciautils (014-1) unstable; urgency=low * New upstream release. * Don't mention persistent udev mappings in README.Debian, they are taken care of automatically nowadays. * Updated Standards-Version to 3.7.2. * Removed /usr/share/doc/cardmgr-to-pcmciautils.txt.gz because it doesn't really apply much to Debian. -- Per Olofsson Thu, 22 Jun 2006 15:22:44 +0200 pcmciautils (013-2) unstable; urgency=low * Use ENV{MODALIAS} instead of MODALIAS in udev rules, since the latter is deprecated. * Move init script to /etc/init.d/pcmciautils in the udeb, so that pcmciautils-udeb and pcmcia-cs-udeb don't have to contain the same file (and thus break if pcmcia-cs-udeb accidentally gets unpacked into a 2.6 installer). Requires hw-detect 1.36. -- Colin Watson Wed, 7 Jun 2006 01:46:04 +0100 pcmciautils (013-1) unstable; urgency=low * New upstream release. - Use new sysfs pm_state interface instead of power/state which will (likely) go away. - Add 'pccardctl ls' (or 'lspcmcia') to provide extended debugging output. * Fix unintentional fallthrough to insert from pccardctl ls. -- Colin Watson Mon, 27 Mar 2006 12:07:13 +0100 pcmciautils (012-5) unstable; urgency=low [ Colin Watson ] * Improve efficiency of udev rules by checking at the top for ACTION="add" and otherwise jumping to the end. Requires udev 064 (closes: #350381). [ Per Olofsson ] * Rebuild against libsysfs2. Closes: #355535. -- Per Olofsson Mon, 6 Mar 2006 15:05:08 +0100 pcmciautils (012-4) unstable; urgency=low [ Colin Watson ] * Remove unnecessary ancient-shell paranoia from init script (#350381). [ Per Olofsson ] * Install a special config.opts on some archs. * Remove /etc/pcmcia/config.opts when purging. This file has been taken over from pcmcia-cs now. * Also remove /etc/pcmcia/ if empty. * Put config.opts in /usr/lib/pcmciautils instead of /usr/share/pcmciautils since it's different on different architectures. * Simplify the init script and make it print less confusing messages. Closes: #351545. * Build with V=true to get verbose output from the build process. * Document the allow-hotplug /etc/network/interfaces option in README.Debian. Closes: #352038. * Add debian/watch. -- Per Olofsson Sat, 18 Feb 2006 23:10:39 +0100 pcmciautils (012-3) unstable; urgency=low * Don't depend on udev, only recommend it. This makes it possible for pcmcia-cs to depend on pcmciautils without requiring people to install udev. This makes upgrades smooth. udev also isn't strictly required, it's possible to use pcmciautils without it depending on the circumstances. Closes: #350182. * Added note about udev to the description also. -- Per Olofsson Sat, 28 Jan 2006 13:58:27 +0100 pcmciautils (012-2) unstable; urgency=low * Make init script exit immediately if pcmciautils has been removed but not purged (closes: #348749). * Create udev rules symlink on initial install too (closes: #345795). -- Colin Watson Sun, 22 Jan 2006 21:57:54 +0000 pcmciautils (012-1) unstable; urgency=low * New upstream release. - Incorporates our config.opts fixes, and some config.opts changes from OpenSuSE. - Avoids deprecated libsysfs functions for compatibility with libsysfs2. - Implements 'pccardctl status'. * Build-depend on debhelper 4.2 for udeb support. * Merge from Ubuntu: - Use 'modprobe -b' from module-init-tools 3.2.2 so that PCMCIA bridges can be blacklisted. - Use 'modprobe -b' to load pcmcia and pcmcia_core. * Fix udev rules symlink (thanks, Tobias Gruetzmacher; closes: #343193). -- Colin Watson Sat, 24 Dec 2005 11:10:54 +0000 pcmciautils (011-1) unstable; urgency=low * New upstream release. * Use upstream's man page rather than our own. * Ship new upstream documentation. * Update FSF address in debian/copyright. -- Colin Watson Tue, 6 Dec 2005 11:01:13 +0000 pcmciautils (010-1) unstable; urgency=low * Initial upload to Debian (closes: #319583). * Add Per Olofsson as uploader. -- Colin Watson Mon, 5 Dec 2005 21:24:31 +0000 pcmciautils (010-0ubuntu6) dapper; urgency=low * Ship /etc/pcmcia; the postinst needs it. -- Colin Watson Fri, 25 Nov 2005 12:14:12 +0000 pcmciautils (010-0ubuntu5) dapper; urgency=low * Add an init script (mostly borrowed from pcmcia-cs) to probe old ISA bridges. Copy /etc/default/pcmcia to /etc/default/pcmciautils on new installs or upgrades from earlier versions to make sure that this doesn't stop working when pcmcia-cs is purged. * Add init script to the udeb too, as /etc/init.d/pcmcia; this conflicts with pcmcia-cs-udeb but that's OK and it's what hw-detect expects. -- Colin Watson Thu, 24 Nov 2005 16:43:45 +0000 pcmciautils (010-0ubuntu4) dapper; urgency=low * For now, back out GOTO/LABEL changes that unnecessarily require new udev. * Instead, add explicit ACTION=="add" to pcmcia_socket rules. * Add a man page for pccardctl, derived from cardctl(8). -- Colin Watson Tue, 22 Nov 2005 17:00:48 +0000 pcmciautils (010-0ubuntu3) dapper; urgency=low * Simplify config.opts to make it easier for d-i to modify. * Remove 0x800-0x8ff range - it seems to cause problems on many machines (Matthew Garrett). * Exclude 0xcf8-0xcff too to work better on Sony Vaios (Tollef Fog Heen, https://bugzilla.ubuntu.com/show_bug.cgi?id=8677). -- Colin Watson Tue, 22 Nov 2005 16:21:56 +0000 pcmciautils (010-0ubuntu2) dapper; urgency=low * Add a pcmciautils-udeb package for use in the installer. * Fix various bugs in udev rules, thanks to Scott James Remnant: - Remove redundant and non-functional modalias rule. - Use MODALIAS="?*" rather than MODALIAS="*", since the latter matches every event. - Match SUBSYSTEM rather than setting it. - $DEVPATH should be $devpath. - Bracket the whole file with an ACTION!="add" check (two of the rules were missing ACTION=="add"). Requires udev 064. * Import packaging into bzr; add note to debian/copyright with location. -- Colin Watson Tue, 22 Nov 2005 16:12:36 +0000 pcmciautils (010-0ubuntu1) dapper; urgency=low * Initial release, configured only with udev support. * Move udev rules to position 85. * Move udev helpers to /lib/udev. -- Colin Watson Mon, 21 Nov 2005 08:42:49 +0000 debian/rules0000755000000000000000000000204511771065337010261 0ustar #! /usr/bin/make -f export V := true %: dh $@ DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) CROSS := else CROSS := CROSS=$(DEB_HOST_GNU_TYPE)- endif CPPFLAGS := $(shell dpkg-buildflags --get CPPFLAGS) CFLAGS := $(shell dpkg-buildflags --get CFLAGS) LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS) BUILDFLAGS := CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" override_dh_auto_build: $(BUILDFLAGS) $(MAKE) $(CROSS) STRIPCMD=true override_dh_auto_install: dh_auto_install --destdir=debian/pcmciautils -- \ pcmciaconfdir=/usr/lib/pcmciautils override_dh_install: dh_install --sourcedir=debian/pcmciautils # You only need to run this immediately after checking out the package from # revision control. quilt-setup: [ ! -d .pc ] set -e; for patch in $$(quilt series | tac); do \ patch -p1 -R --no-backup-if-mismatch <"debian/patches/$$patch"; \ done quilt push -a .PHONY: quilt-setup debian/maintscript0000644000000000000000000000013511715473751011460 0ustar rm_conffile /etc/udev/pcmcia.rules 015-1+b100 rm_conffile /etc/init.d/pcmciautils 015-1+b100 debian/watch0000644000000000000000000000012410451171512010211 0ustar version=3 http://kernel.org/pub/linux/utils/kernel/pcmcia/pcmciautils-(.*)\.tar\.gz debian/compat0000644000000000000000000000000211241502743010363 0ustar 7 debian/source/0000755000000000000000000000000011353772630010475 5ustar debian/source/format0000644000000000000000000000001411353772630011703 0ustar 3.0 (quilt) debian/control0000644000000000000000000000344111771603455010604 0ustar Source: pcmciautils Section: admin Priority: extra Maintainer: Colin Watson Uploaders: Per Olofsson Standards-Version: 3.9.2 Vcs-Bzr: http://anonscm.debian.org/bzr/pkg-pcmciautils/debian Build-Depends: dpkg-dev (>= 1.15.7~), debhelper (>= 8.1.0~), flex, bison Homepage: http://www.kernel.org/pub/linux/utils/kernel/pcmcia/pcmcia.html Package: pcmciautils Architecture: linux-any Pre-Depends: ${misc:Pre-Depends} Depends: ${shlibs:Depends}, ${misc:Depends} Recommends: udev Suggests: wireless-tools Description: PCMCIA utilities for Linux 2.6 This package provides PCMCIA initialisation tools for Linux 2.6.13-rc1 or later, replacing the old pcmcia-cs tools used with earlier kernel versions. PCMCIA cards are commonly used in laptops to provide expanded capabilities such as network connections, modems, increased memory, etc. . To use PCMCIA you need to have kernel modules available to support it. These are included in the stock Debian 2.6 kernel packages. You will most likely also need udev, although it isn't always required. . The wireless-tools package is required by many wireless network adapters. Package: pcmciautils-udeb XC-Package-Type: udeb Section: debian-installer Architecture: linux-any Depends: udev-udeb, ${shlibs:Depends} Description: PCMCIA utilities for Linux 2.6 This package provides PCMCIA initialisation tools for Linux 2.6.13-rc1 or later, replacing the old pcmcia-cs tools used with earlier kernel versions. PCMCIA cards are commonly used in laptops to provide expanded capabilities such as network connections, modems, increased memory, etc. . To use PCMCIA you need to have kernel modules available to support it. These are included in the stock Debian 2.6 kernel packages. . This is a minimal package for use in debian-installer. debian/patches/0000755000000000000000000000000011634616677010636 5ustar debian/patches/no-modprobe-rules.patch0000644000000000000000000000100711570655512015214 0ustar Description: Remove redundant modalias rule, already handled by udev Author: Scott James Remnant Author: Colin Watson Forwarded: no Last-Update: 2010-03-29 --- a/Makefile +++ b/Makefile @@ -212,7 +212,7 @@ endif #udev rules collection UDEV_RULES_FILE = udev/60-pcmcia.rules -UDEV_RULES = udev/rules-start udev/rules-modprobe udev/rules-base +UDEV_RULES = udev/rules-start udev/rules-base ifneq ($(strip $(STARTUP)),false) UDEV_RULES += udev/rules-nonstaticsocket endif debian/patches/config-opts-fallback.patch0000644000000000000000000000126111570655512015632 0ustar Description: Configuration file fallback Fall back to /usr/lib/pcmciautils/config.opts if /etc/pcmcia/config.opts doesn't exist. . This is Debian-specific, to deal with migration from the old pcmcia-cs package. Author: Colin Watson Bug-Debian: http://bugs.debian.org/392222 Forwarded: not-needed Last-Update: 2010-03-29 --- a/src/startup.c +++ b/src/startup.c @@ -186,7 +186,8 @@ static void load_config(void) syslog(LOG_ERR, "chdir to %s failed: %m", configpath); exit(EXIT_FAILURE); } - parse_configfile("config.opts"); + if (parse_configfile("config.opts") == -1) + parse_configfile("/usr/lib/pcmciautils/config.opts"); return; } debian/patches/series0000644000000000000000000000011511634616677012050 0ustar no-modprobe-rules.patch config-opts-fallback.patch remove-libsysfs-dep.patch debian/patches/remove-libsysfs-dep.patch0000644000000000000000000003521011634616677015557 0ustar Subject: pcmciautils: remove dependency on libsysfs Author: Dominik Brodowski Origin: upstream, http://git.kernel.org/?p=linux/pcmcia/pcmciautils.git;a=commit;h=f31a75997f33c8c1ac291d657eb26ea0a1189459 Bug-Debian: http://bugs.debian.org/627648 --- a/Makefile +++ b/Makefile @@ -156,12 +156,12 @@ CFLAGS += -I$(PWD)/src CFLAGS += $(WARNINGS) -I$(GCCINCDIR) -LIB_OBJS = -lc -lsysfs +LIB_OBJS = -lc LIB_PLAIN_OBJS = -lc LIB_PCI_OBJS = -lc -lpci ifeq ($(strip $(STATIC)),true) - LIB_OBJS = -lsysfs + LIB_OBJS = LIB_PLAIN_OBJS = LIB_PCI_OBJS = -lpci LDFLAGS += -static --- a/doc/mini-howto.txt +++ b/doc/mini-howto.txt @@ -112,8 +112,7 @@ Table of contents: 2.3. Dependencies ----------------- - To use any of the PCMCIAutils tools, you need sysfsutils 1.3.0 or - newer. However, if you do not need a resource database, you do not run + If you do not need a resource database, you do not run a modular kernel and you are lucky, you might not need any userspace tools at all. --- a/src/pccardctl.c +++ b/src/pccardctl.c @@ -19,12 +19,13 @@ #include #include #include - -#include - +#include +#include +#include #include #define MAX_SOCKET 8 +#define SYSFS_PATH_MAX 255 static const char * const fn[] = { "multifunction", @@ -51,87 +52,89 @@ static unsigned int crc32(unsigned char return crc; } +static int sysfs_write_file(const char *fname, const char *value, size_t len) +{ + ssize_t numwrite; + int fd; + int ret = 0; + + fd = open(fname, O_WRONLY); + if (fd <= 0) + return fd; + + numwrite = write(fd, value, len); + if ((numwrite < 1) || ((size_t) numwrite != len)) + ret = -EIO; + + close(fd); + return ret; +} static int pccardctl_power_socket(unsigned long socket_no, unsigned int power) { - int ret; char file[SYSFS_PATH_MAX]; - struct sysfs_attribute *attr; snprintf(file, SYSFS_PATH_MAX, "/sys/class/pcmcia_socket/pcmcia_socket%lu/card_pm_state", socket_no); - attr = sysfs_open_attribute(file); - if (!attr) - return -ENODEV; - - ret = sysfs_write_attribute(attr, power ? "off" : "on", power ? 3 : 2); - - sysfs_close_attribute(attr); - - return ret; + return sysfs_write_file(file, power ? "off" : "on", power ? 3 : 2); } static int pccardctl_echo_one(unsigned long socket_no, const char *in_file) { - int ret; char file[SYSFS_PATH_MAX]; - struct sysfs_attribute *attr; snprintf(file, SYSFS_PATH_MAX, "/sys/class/pcmcia_socket/pcmcia_socket%lu/%s", socket_no, in_file); - attr = sysfs_open_attribute(file); - if (!attr) - return -ENODEV; - - ret = sysfs_write_attribute(attr, "42", 2); - - sysfs_close_attribute(attr); - - return ret; + return sysfs_write_file(file, "42", 2); } static int pccardctl_socket_exists(unsigned long socket_no) { char file[SYSFS_PATH_MAX]; + struct stat st; snprintf(file, SYSFS_PATH_MAX, "/sys/class/pcmcia_socket/pcmcia_socket%lu/card_insert", socket_no); - return !(sysfs_path_is_file(file)); + return !stat(file, &st); } -static int read_out_file(char *file, char **output) +static int sysfs_read_whole_file(char *file, char **output) { - struct sysfs_attribute *attr = sysfs_open_attribute(file); - int ret; char *result = NULL; + ssize_t numread; + off_t size; + int fd, ret = 0; *output = NULL; - if (!attr) - return -EIO; - ret = sysfs_read_attribute(attr); - - if (ret || !attr->value || !attr->len || (attr->len > SYSFS_PATH_MAX)) - goto close_out; - - result = malloc(attr->len + 1); - if (result) { - memcpy(result, attr->value, attr->len); - result[attr->len] = '\0'; - if (result[attr->len - 1] == '\n') - result[attr->len - 1] = '\0'; + fd = open(file, O_RDONLY); + if (fd <= 0) + return fd; + + /* determine size */ + size = lseek(fd, 0, SEEK_END) + SYSFS_PATH_MAX; + result = malloc(size); + if (!result) { + close(fd); + return -ENOMEM; + } + + lseek(fd, 0, SEEK_SET); + numread = read(fd, result, size - 1); + if (numread < 1) + ret = -EIO; + else { + result[numread] = '\0'; *output = result; - } else - ret = -ENOMEM; + } - close_out: - sysfs_close_attribute(attr); + close(fd); return ret; } @@ -144,7 +147,7 @@ static int pccardctl_get_string_socket(u "/sys/class/pcmcia_socket/pcmcia_socket%lu/%s", socket_no, in_file); - return read_out_file(file, output); + return sysfs_read_whole_file(file, output); } static int pccardctl_get_string(unsigned long socket_no, @@ -155,7 +158,7 @@ static int pccardctl_get_string(unsigned snprintf(file, SYSFS_PATH_MAX, "/sys/bus/pcmcia/devices/%lu.0/%s", socket_no, in_file); - return read_out_file(file, output); + return sysfs_read_whole_file(file, output); } static int pccardctl_get_one_f(unsigned long socket_no, unsigned int dev, @@ -163,17 +166,19 @@ static int pccardctl_get_one_f(unsigned { char *value; char file[SYSFS_PATH_MAX]; - int ret; + int ret = 0; snprintf(file, SYSFS_PATH_MAX, "/sys/bus/pcmcia/devices/%lu.%u/%s", socket_no, dev, in_file); - ret = read_out_file(file, &value); + ret = sysfs_read_whole_file(file, &value); if (ret || !value) return -EINVAL; if (sscanf(value, "0x%X", result) != 1) - return -EIO; - return 0; + ret = -EIO; + + free(value); + return ret; } static int pccardctl_get_one(unsigned long socket_no, const char *in_file, @@ -187,36 +192,40 @@ static int pccardctl_get_power_device(un { char *value; char file[SYSFS_PATH_MAX]; + int ret = -ENODEV; snprintf(file, SYSFS_PATH_MAX, "/sys/bus/pcmcia/devices/%lu.%u/pm_state", socket_no, func); - read_out_file(file, &value); + sysfs_read_whole_file(file, &value); if (value) { if (!strncmp(value, "off", 3)) - return 1; - return 0; + ret = 1; + ret = 0; + free(value); } - return -ENODEV; + return ret; } static int pccardctl_get_power_socket(unsigned long socket_no) { char *value; char file[SYSFS_PATH_MAX]; + int ret = -ENODEV; snprintf(file, SYSFS_PATH_MAX, "/sys/class/pcmcia_socket/pcmcia_socket%lu/card_pm_state", socket_no); - read_out_file(file, &value); + sysfs_read_whole_file(file, &value); if (value) { if (!strncmp(value, "off", 3)) - return 1; - return 0; + ret = 1; + ret = 0; + free(value); } - return -ENODEV; + return ret; } @@ -262,7 +271,6 @@ static int pccardctl_ident(unsigned long printf(" function: %d (%s)\n", manf_id, s); } - return 0; } @@ -323,6 +331,8 @@ static int pccardctl_status(unsigned lon printf(" %s %s %s", card_voltage, card_type, is_cardbus ? "CardBus card" : "PC Card"); + free(card_type); + free(card_voltage); susp = pccardctl_get_power_socket(socket_no); if (susp > 0) @@ -365,7 +375,7 @@ static int pccardctl_status(unsigned lon static void print_header(void) { printf("pcmciautils %s\n", PCMCIAUTILS_VERSION); - printf("Copyright (C) 2004-2005 Dominik Brodowski, " + printf("Copyright (C) 2004-2011 Dominik Brodowski, " "(C) 1999 David A. Hinds\n"); printf("Report errors and bugs to ," "please.\n"); @@ -412,7 +422,6 @@ static void lspcmcia_socket_available_re char *which) { char file[SYSFS_PATH_MAX]; - struct sysfs_attribute *attr; int ret, length, first = 0; char *sep; char *result = NULL; @@ -421,27 +430,10 @@ static void lspcmcia_socket_available_re "/sys/class/pcmcia_socket/pcmcia_socket%lu/available_resources_%s", socket_no, which); - attr = sysfs_open_attribute(file); - if (!attr) - return; - - - ret = sysfs_read_attribute(attr); - if (ret) - goto close_out; - printf("\t\t\tAvailable %s:\t", which[0] == 'i' ? "ioports" : "iomem"); - if (!attr->value || !attr->len || (attr->len < 5)) - goto close_out; - - result = malloc(attr->len + 1); - if (result) { - memcpy(result, attr->value, attr->len); - result[attr->len] = '\0'; - if (result[attr->len - 1] == '\n') - result[attr->len - 1] = '\0'; - } else + ret = sysfs_read_whole_file(file, &result); + if (ret) goto close_out; ret = 0; @@ -458,15 +450,13 @@ static void lspcmcia_socket_available_re ret += length + 1; } } while (sep); - if (result) { - printf("%s\n", &result[ret]); - first++; - } + printf("%s\n", &result[ret]); + first++; + free(result); close_out: if (!first) printf("--none--\n"); - sysfs_close_attribute(attr); return; } @@ -479,7 +469,6 @@ static void lspcmcia_socket(unsigned lon pccardctl_get_string_socket(socket_no, "available_resources_setup_done", &ready); - printf("\tConfiguration:\tstate: %s\tready: %s\n", pm_state ? "suspended" : "on", ready ? ready : "unknown"); @@ -489,6 +478,10 @@ static void lspcmcia_socket(unsigned lon if (card_voltage && card_vpp && card_vcc) printf("\t\t\tVoltage: %s Vcc: %s Vpp: %s\n", card_voltage, card_vcc, card_vpp); + free(card_voltage); + free(card_vpp); + free(card_vcc); + free(ready); if (verbose > 1) { char *irq_mask_s; @@ -511,7 +504,7 @@ static void lspcmcia_socket(unsigned lon printf("none"); printf("\n"); } - + free(irq_mask_s); lspcmcia_socket_available_resources(socket_no, "io"); lspcmcia_socket_available_resources(socket_no, "mem"); } @@ -521,7 +514,6 @@ static void lspcmcia_socket(unsigned lon static void lspcmcia_device_resources(unsigned long socket_no, int fun) { char file[SYSFS_PATH_MAX]; - struct sysfs_attribute *attr; int ret, length; char *sep; char *result = NULL; @@ -529,25 +521,9 @@ static void lspcmcia_device_resources(un snprintf(file, SYSFS_PATH_MAX, "/sys/bus/pcmcia/devices/%lu.%u/resources", socket_no, fun); - attr = sysfs_open_attribute(file); - if (!attr) - return; - - ret = sysfs_read_attribute(attr); + ret = sysfs_read_whole_file(file, &result); if (ret) - goto close_out; - - if (!attr->value || !attr->len || (attr->len < 5)) - goto close_out; - - result = malloc(attr->len + 1); - if (result) { - memcpy(result, attr->value, attr->len); - result[attr->len] = '\0'; - if (result[attr->len - 1] == '\n') - result[attr->len - 1] = '\0'; - } else - goto close_out; + return; ret = 0; printf("\t\t\t"); @@ -563,11 +539,9 @@ static void lspcmcia_device_resources(un ret += length + 1; } } while (sep); - if (result) - printf("%s\n", &result[ret]); + printf("%s\n", &result[ret]); - close_out: - sysfs_close_attribute(attr); + free(result); return; } @@ -620,7 +594,6 @@ static int lspcmcia(unsigned long socket if (verbose) lspcmcia_socket(socket_no, verbose, drv); - pccardctl_get_string_socket(socket_no, "card_type", &res); if (!res) return 0; @@ -628,8 +601,10 @@ static int lspcmcia(unsigned long socket if (!strncmp(res, "32", 2)) { printf(" CardBus card -- see \"lspci\" " "for more information\n"); + free(res); return 0; } + free(res); for (i = 0; i < 4; i++) { int function; @@ -666,6 +641,7 @@ static int lspcmcia(unsigned long socket pccardctl_get_string(socket_no, file, &res); if (res) printf("%s ", res); + free(res); } printf("\n"); @@ -694,6 +670,7 @@ static int lspcmcia(unsigned long socket printf("prod_id(%u): --- (---)\n", j); if (j < 4) printf("\t\t\t"); + free(res); } } } --- a/src/read-cis.c +++ b/src/read-cis.c @@ -18,11 +18,10 @@ #include #include -#include - #include "cistpl.h" #define MAX_TUPLES 0x200 +#define SYSFS_PATH_MAX 255 #define PATH_TO_SOCKET "/sys/class/pcmcia_socket/" --- a/src/startup.c +++ b/src/startup.c @@ -15,10 +15,11 @@ #include #include #include +#include +#include +#include #include -#include - #include "startup.h" /* uncomment for debug output */ @@ -48,6 +49,46 @@ static const char *resource_files[MAX_RE #define PATH_TO_SOCKET "/sys/class/pcmcia_socket/" +#define SYSFS_PATH_MAX 255 + + +static int sysfs_read_file(const char *fname, char *buf, size_t buflen) +{ + ssize_t numread; + int fd; + int ret = 0; + + fd = open(fname, O_RDONLY); + if (fd <= 0) + return fd; + + numread = read(fd, buf, buflen - 1); + if (numread < 1) + ret = -EIO; + else + buf[numread] = '\0'; + + close(fd); + return ret; +} + +static int sysfs_write_file(const char *fname, const char *value, size_t len) +{ + ssize_t numwrite; + int fd; + int ret = 0; + + fd = open(fname, O_WRONLY); + if (fd <= 0) + return fd; + + numwrite = write(fd, value, len); + if ((numwrite < 1) || ((size_t) numwrite != len)) + ret = -EIO; + + close(fd); + return ret; +} static int add_available_resource(unsigned int socket_no, unsigned int type, unsigned int action, @@ -55,7 +96,6 @@ static int add_available_resource(unsign { char file[SYSFS_PATH_MAX]; char content[SYSFS_PATH_MAX]; - struct sysfs_attribute *attr; int ret; size_t len; @@ -85,44 +125,24 @@ static int add_available_resource(unsign return -EINVAL; } - dprintf("content is %s\n", content); - - dprintf("file is %s\n", file); - - attr = sysfs_open_attribute(file); - if (!attr) - return -ENODEV; - - dprintf("open, len %zu\n", len); + dprintf("content is %s, file is %s\n", content, file); - ret = sysfs_write_attribute(attr, content, len); + ret = sysfs_write_file(file, content, len); dprintf("ret is %d\n", ret); - sysfs_close_attribute(attr); - return ret; } static int setup_done(unsigned int socket_no) { - int ret; char file[SYSFS_PATH_MAX]; - struct sysfs_attribute *attr; snprintf(file, SYSFS_PATH_MAX, PATH_TO_SOCKET "pcmcia_socket%u/available_resources_setup_done", socket_no); - attr = sysfs_open_attribute(file); - if (!attr) - return -ENODEV; - - ret = sysfs_write_attribute(attr, "42", 2); - - sysfs_close_attribute(attr); - - return ret; + return sysfs_write_file(file, "42", 2); } @@ -130,7 +150,6 @@ static int disallow_irq(unsigned int soc { char file[SYSFS_PATH_MAX]; char content[SYSFS_PATH_MAX]; - struct sysfs_attribute *attr; unsigned int mask = 0xfff; unsigned int new_mask; int ret; @@ -144,24 +163,13 @@ static int disallow_irq(unsigned int soc socket_no); dprintf("file is %s\n", file); - attr = sysfs_open_attribute(file); - if (!attr) + ret = sysfs_read_file(file, content, SYSFS_PATH_MAX); + if (ret) return -ENODEV; - dprintf("open, len %zu\n", len); - - ret = sysfs_read_attribute(attr); - if (ret) { - ret = -EINVAL; - goto out; - } - - if (!attr->value || (attr->len < 6)) { - ret = -EIO; - goto out; - } - - ret = sscanf(attr->value, "0x%x\n", &mask); + ret = sscanf(content, "0x%x\n", &mask); + if (ret != 1) + return -EIO; new_mask = 1 << irq; @@ -171,12 +179,7 @@ static int disallow_irq(unsigned int soc dprintf("content is %s\n", content); - ret = sysfs_write_attribute(attr, content, len); - - out: - sysfs_close_attribute(attr); - - return ret; + return sysfs_write_file(file, content, len); } debian/NEWS0000644000000000000000000000054211570655512007675 0ustar pcmciautils (018-1) unstable; urgency=low /etc/init.d/pcmciautils is now gone and pcmciautils will no longer load any driver modules. If you need to load a driver module which is not automatically loaded (e.g. i82365 if you lack PNP), then please add it to /etc/modules. -- Per Olofsson Mon, 25 Apr 2011 21:40:14 +0200 debian/copyright0000644000000000000000000000235711320624451011126 0ustar Colin Watson packaged pcmciautils on Sun, 20 Nov 2005 23:24:16 +0000. It was downloaded from: http://kernel.org/pub/linux/utils/kernel/pcmcia/pcmcia.html Upstream Author: Dominik Brodowski Copyright and licence: Copyright (C) 1999 David A. Hinds Copyright (C) 2002-2003 Mike Gleason, NcFTP Software Copyright (C) 2003,2004 Greg Kroah-Hartman Copyright (C) 2004-2005 Dominik Brodowski 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; version 2 of the License. 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 On Debian/Ubuntu systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL-2'. debian/postinst0000644000000000000000000000132311715474245011005 0ustar #! /bin/sh set -e # Insert debhelper fragments before calling 'update-rc.d pcmciautils # remove', since that will fail if the init script has not yet been removed. #DEBHELPER# case $1 in configure) if dpkg --compare-versions "$2" le 015-1+b100 && [ -h /etc/udev/rules.d/85-pcmcia.rules ]; then rm /etc/udev/rules.d/85-pcmcia.rules fi if dpkg --compare-versions "$2" le 015-1+b100; then update-rc.d pcmciautils remove >/dev/null fi if [ ! -f /etc/pcmcia/config.opts ]; then [ -d /etc/pcmcia ] || mkdir /etc/pcmcia cp -a /usr/lib/pcmciautils/config.opts /etc/pcmcia/ fi ;; esac debian/pcmciautils-udeb.install0000644000000000000000000000007711570655512014023 0ustar lib/udev lib/ usr/lib/pcmciautils/config.opts etc/pcmciautils/ debian/docs0000644000000000000000000000002310451171512010031 0ustar doc/mini-howto.txt debian/postrm0000644000000000000000000000033511715474070010444 0ustar #! /bin/sh set -e case $1 in purge) rm -f /etc/default/pcmciautils rm -f /etc/udev/rules.d/60-pcmcia.rules rm -f /etc/pcmcia/config.opts /etc/pcmcia/config.opts~ rmdir /etc/pcmcia || true ;; esac #DEBHELPER#