automatic rebuild by autodist [release 2.1.0-4mamba;Mon Jul 15 2013]

This commit is contained in:
Automatic Build System 2024-01-05 18:17:43 +01:00
parent 9000d893d5
commit 806495976b
3 changed files with 266 additions and 0 deletions

View File

@ -1,2 +1,4 @@
# sysfsutils
A consistant and stable interface for querying system device information exposed through sysfs.

View File

@ -0,0 +1,164 @@
diff -upr sysfsutils-2.1.0-old/lib/sysfs_utils.c sysfsutils-2.1.0/lib/sysfs_utils.c
--- sysfsutils-2.1.0-old/lib/sysfs_utils.c 2006-08-07 07:08:01.000000000 +0200
+++ sysfsutils-2.1.0/lib/sysfs_utils.c 2008-05-13 07:42:50.000000000 +0200
@@ -117,84 +117,104 @@ int sysfs_get_link(const char *path, cha
{
char devdir[SYSFS_PATH_MAX];
char linkpath[SYSFS_PATH_MAX];
- char temp_path[SYSFS_PATH_MAX];
- char *d = NULL, *s = NULL;
- int slashes = 0, count = 0;
+ char *d, *s;
+ int count;
if (!path || !target || len == 0) {
errno = EINVAL;
return -1;
}
- memset(devdir, 0, SYSFS_PATH_MAX);
- memset(linkpath, 0, SYSFS_PATH_MAX);
- memset(temp_path, 0, SYSFS_PATH_MAX);
- safestrcpy(devdir, path);
-
- if ((readlink(path, linkpath, SYSFS_PATH_MAX)) < 0) {
+ count = readlink(path, linkpath, SYSFS_PATH_MAX);
+ if (count < 0)
return -1;
- }
- d = linkpath;
+ else
+ linkpath[count] = '\0';
/*
* Three cases here:
* 1. relative path => format ../..
* 2. absolute path => format /abcd/efgh
* 3. relative path _from_ this dir => format abcd/efgh
*/
- switch (*d) {
- case '.':
+ if (*linkpath == '/') {
+ /* absolute path - copy as is */
+ safestrcpymax(target, linkpath, len);
+ return 0;
+ }
+
+ safestrcpy(devdir, path);
+ s = strrchr(devdir, '/');
+ if (s == NULL)
+ s = devdir - 1;
+ d = linkpath;
+ while (*d == '.') {
+ if (*(d+1) == '/') {
/*
* handle the case where link is of type ./abcd/xxx
*/
- safestrcpy(temp_path, devdir);
- if (*(d+1) == '/')
- d += 2;
- else if (*(d+1) == '.')
- goto parse_path;
- s = strrchr(temp_path, '/');
- if (s != NULL) {
- *(s+1) = '\0';
- safestrcat(temp_path, d);
- } else {
- safestrcpy(temp_path, d);
- }
- safestrcpymax(target, temp_path, len);
- break;
+ d += 2;
+ while (*d == '/')
+ d++;
+ continue;
+ } else if (*(d+1) != '.' || *(d+2) != '/')
/*
- * relative path, getting rid of leading "../.."
+ * relative path from this directory, starting
+ * with a hidden directory
*/
-parse_path:
- while (*d == '/' || *d == '.') {
- if (*d == '/')
- slashes++;
- d++;
- }
- d--;
- s = &devdir[strlen(devdir)-1];
- while (s != NULL && count != (slashes+1)) {
+ break;
+
+ /*
+ * relative path, getting rid of leading "../.."; must
+ * be careful here since any path component of devdir
+ * could be a symlink again
+ */
+ for (;;) {
+ while (s > devdir && *s == '/') {
s--;
- if (*s == '/')
- count++;
+ if (*s == '.'
+ && (s == devdir || *(s-1) == '/'))
+ s--;
}
- safestrcpymax(s, d, (SYSFS_PATH_MAX-strlen(devdir)));
- safestrcpymax(target, devdir, len);
- break;
- case '/':
- /* absolute path - copy as is */
- safestrcpymax(target, linkpath, len);
- break;
- default:
- /* relative path from this directory */
- safestrcpy(temp_path, devdir);
- s = strrchr(temp_path, '/');
- if (s != NULL) {
- *(s+1) = '\0';
- safestrcat(temp_path, linkpath);
- } else {
- safestrcpy(temp_path, linkpath);
+ *(s+1) = '\0';
+ if (*devdir == '\0' || sysfs_path_is_link(devdir))
+ /*
+ * condition will be true eventually
+ * because we already know that all
+ * but the last component of path
+ * resolve to a directory
+ */
+ break;
+ if (sysfs_get_link(devdir, devdir, SYSFS_PATH_MAX))
+ return -1;
+ s = devdir + strlen(devdir) - 1;
+ }
+ while (s >= devdir) {
+ if (*s == '/') {
+ if (*(s+1) != '.' || *(s+2) != '.'
+ || *(s+3) != '\0') {
+ d += 3;
+ while (*d == '/')
+ d++;
+ } else
+ s += 2;
+ break;
}
- safestrcpymax(target, temp_path, len);
+ s--;
+ }
+ if (s < devdir || *(s+1) == '\0')
+ break;
}
+
+ /*
+ * appending to devdir a slash and the (possibly shortened)
+ * relative path to the link source
+ */
+ s++;
+ if (s > devdir && *s == '\0')
+ *s++ = '/';
+ *s = '\0';
+ safestrcpymax(s, d, SYSFS_PATH_MAX-(s-devdir));
+ safestrcpymax(target, devdir, len);
return 0;
}

100
sysfsutils.spec Normal file
View File

@ -0,0 +1,100 @@
Name: sysfsutils
Version: 2.1.0
Release: 4mamba
Summary: System utilities based on sysfs
Group: System/Tools
Vendor: openmamba
Distribution: openmamba
Packager: Silvan Calarco <silvan.calarco@mambasoft.it>
URL: http://linux-diag.sourceforge.net/Sysfsutils.html
Source: http://downloads.sourceforge.net/sourceforge/linux-diag/sysfsutils-%{version}.tar.gz
Source1: http://downloads.sourceforge.net/sourceforge/linux-diag/sysfsutils-1.3.0.tar.gz
Patch0: %{name}-2.1.0-kernel_2.6.25.patch
License: GPL
BuildRoot: %{_tmppath}/%{name}-%{version}-root
Provides: sysfs
Obsoletes: sysfs
Requires: libsysfs = %{version}-%{release}
%description
A consistant and stable interface for querying system device information exposed through sysfs.
%package -n libsysfs
Group: System/Libraries
Summary: System library for accessing sysfs
Obsoletes: libsysfs1
%description -n libsysfs
A consistant and stable interface for querying system device information exposed through sysfs.
This package contains command line tools for querying and diagnostics.
%package -n libsysfs-devel
Group: Development/Libraries
Summary: Static libraries and headers for libsysfs
Requires: libsysfs = %{version}-%{release}
%description -n libsysfs-devel
A consistant and stable interface for querying system device information exposed through sysfs.
This package contains static libraries and header files need for development.
%prep
%setup -q -a1
%patch0 -p1
%build
%configure
%make
%install
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
%makeinstall
%clean
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
%post -n libsysfs -p /sbin/ldconfig
%postun -n libsysfs -p /sbin/ldconfig
%files
%defattr(-,root,root)
%{_bindir}/dlist_test
%{_bindir}/get_device
%{_bindir}/get_driver
%{_bindir}/get_module
%{_bindir}/systool
%{_mandir}/man1/systool.*
%files -n libsysfs
%defattr(-,root,root)
%{_libdir}/libsysfs.so.*
%doc AUTHORS COPYING CREDITS ChangeLog INSTALL NEWS README TODO
%files -n libsysfs-devel
%defattr(-,root,root)
%{_includedir}/sysfs/*.h
%{_libdir}/libsysfs.a
%{_libdir}/libsysfs.la
%{_libdir}/libsysfs.so
%changelog
* Mon Jul 15 2013 Automatic Build System <autodist@mambasoft.it> 2.1.0-4mamba
- automatic rebuild by autodist
* Thu Jun 25 2009 Silvan Calarco <silvan.calarco@mambasoft.it> 2.1.0-3mamba
- systool man moved from lib to sysfsutils package
* Mon Sep 29 2008 Silvan Calarco <silvan.calarco@mambasoft.it> 2.1.0-2mamba
- added patch to fix behaviour with kernel >=2.6.25 and CONFIG_SYSFS_DEPRECATED_V2 not set
- disabled build and obsoleted compatibility library libsysfs1
* Thu Jul 19 2007 Silvan Calarco <silvan.calarco@mambasoft.it> 2.1.0-1mamba
- update to 2.1.0
* Mon Dec 19 2005 Stefano Cotta Ramusino <stefano.cotta@qilinux.it> 2.0.0-2qilnx
- added missing %%post and %%postun for %{name}1 subpackage
* Fri Dec 16 2005 Stefano Cotta Ramusino <stefano.cotta@qilinux.it> 2.0.0-1qilnx
- update to version 2.0.0 by autospec
- new compatibility package %{name}1
* Thu Jul 14 2005 Silvan Calarco <silvan.calarco@mambasoft.it> 1.3.0-1qilnx
- package created by autospec