diff options
-rw-r--r-- | user/tlecarrour.mdwn | 2 | ||||
-rw-r--r-- | user/tlecarrour/memstat.mdwn | 31 |
2 files changed, 8 insertions, 25 deletions
diff --git a/user/tlecarrour.mdwn b/user/tlecarrour.mdwn index 11b7dd15..515dd855 100644 --- a/user/tlecarrour.mdwn +++ b/user/tlecarrour.mdwn @@ -30,7 +30,7 @@ my [[porting guide for dummies|porting_guide_for_dummies]]. For each patch make sure to respect the [[patch life cycle|patch_life_cycle]]. -* [[memstat]] (PATH_MAX), **submitted** +* [[memstat]] (PATH_MAX), **stopped** * [[auto-apt]] (PATH_MAX), **discussing** * [[rng-tools]] (PATH_MAX), **discussing** * [[suckless-tools]] (PATH_MAX), **submitted** diff --git a/user/tlecarrour/memstat.mdwn b/user/tlecarrour/memstat.mdwn index 3ef58794..fc12bd25 100644 --- a/user/tlecarrour/memstat.mdwn +++ b/user/tlecarrour/memstat.mdwn @@ -28,6 +28,7 @@ Log * **Discussed**: [2012-01-21](http://lists.debian.org/debian-hurd/2012/01/msg00081.html) * **Draft Submitted**: [2012-01-25](http://lists.debian.org/debian-hurd/2012/01/msg00122.html) * **Submitted**: 2012-02-02, Bug#[658384](http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=658384) +* **Stopped**: 2012-02-07, depends on `/proc` which is not yet totally implemented on the Hurd. * **Accepted**: - @@ -130,33 +131,15 @@ filename will be declared later. Same as above with `FMT_PROC_MAPS`. - + if (lstat(filename, &sb) == -1) { - + perror("lstat"); - + deleted = 1; - + } - + else { - + linkname = malloc(sb.st_size + 1); - + if (linkname == NULL) { - + fprintf(stderr, "insufficient memory\n"); - + deleted = 1; - + } - + else { - + len = readlink(filename, linkname, sb.st_size + 1); - + } - + } - + if (len < 0 || len > sb.st_size) { - fprintf(stderr, "Cannot read link information for %s\n", filename); - deleted = 1; - } - - linkname[len] = '\0'; - + else { - + linkname[sb.st_size] = '\0'; - + } + + char filename[sizeof(FMT_PROC_EXE) + (sizeof(int) * 3) + 1]; + + sprintf(filename, FMT_PROC_EXE, pid); + + linkname = readlink_malloc(filename); + + if (linkname == NULL) { -Use `readlink()` as explained in the porting guide. -Require lstat to get the link size. +Use `readlink_malloc()` as explained in the porting guide because `/proc/PID/exe` doesn't work with `readlink()` + free(linkname); + Free dynamically allocated variable that is not used anymore. |