Package: rrdtool
Version: 1.4.7-2
I notice that the HURD build is failing with an error about PATH_MAX
This is a common issue. PATH_MAX doesn't exist in HURD and it is very
trivial to work around
Full build log:
https://buildd.debian.org/status/fetch.php?pkg=rrdtool&arch=hurd-i386&ver=1.4.7-2&stamp=1343897555
Error:
rrd_client.c: In function 'rrdc_update':
rrd_client.c:586:18: error: 'PATH_MAX' undeclared (first use in this function)
rrd_client.c:586:18: note: each undeclared identifier is reported only once for
each function it appears in
rrd_client.c:586:8: warning: unused variable 'file_path' [-Wunused-variable]
rrd_client.c: In function 'rrdc_flush':
rrd_client.c:647:18: error: 'PATH_MAX' undeclared (first use in this function)
rrd_client.c:647:8: warning: unused variable 'file_path' [-Wunused-variable]
make[3]: *** [rrd_client.lo] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all] Error 2
make: *** [build-arch-stamp] Error 2
Discussion:
http://www.gnu.org/software/hurd/community/gsoc/project_ideas/maxpath.html
Potential solution:
http://www.gnu.org/software/hurd/hurd/porting/guidelines.html#PATH_MAX_tt_MAX_PATH_tt_MAXPATHL
Attached is an example of a patch from another project, it appears easy enough
to cut and paste into rrd_client.c
--- cpulimit-1.1.orig/cpulimit.c 2005-06-27 00:15:23.000000000 +0000
+++ cpulimit-1.1/cpulimit.c 2006-08-07 10:14:37.000000000 +0000
@@ -134,6 +134,22 @@ done:
}
+char* xreadlink(const char *filename) {
+ int nchars;
+ int size = 1024;
+ char *buffer;
+ if ((buffer=(char*)malloc(size))==NULL)
+ return NULL;
+ while ((nchars=readlink(filename,buffer,size))<size) {
+ if (nchars<0)
+ return NULL;
+ buffer=realloc(buffer,size);
+ size *= 2;
+ }
+ buffer[nchars]='\0';
+ return buffer;
+}
+
//this function periodically scans process list and looks for executable path names
//it should be executed in a low priority context, since precise timing does not matter
//if a process is found then its pid is returned
@@ -148,7 +164,7 @@ int getpidof(const char *process) {
}
char exelink[20];
- char exepath[PATH_MAX+1];
+ char *exepath = NULL;
int pid=0;
int i=0;
@@ -169,8 +185,9 @@ int getpidof(const char *process) {
pid=atoi(dit->d_name);
if (pid>0) {
sprintf(exelink,"/proc/%d/exe",pid);
- int size=readlink(exelink,exepath,sizeof(exepath));
- if (size>0) {
+ exepath=xreadlink(exelink);
+ if (exepath) {
+ size_t size = strlen(exepath);
int found=0;
if (process[0]=='/' && strncmp(exepath,process,size)==0 && size==strlen(process)) {
//process starts with / then it's an absolute path
@@ -191,6 +208,7 @@ int getpidof(const char *process) {
fprintf(stderr,"Error: Process %d detected, but you don't have permission to control it\n",pid);
}
}
+ free(exepath);
}
}
}