[PATCH v4] Print absolute paths in printpathn when -yy is used

Dmitry V. Levin ldv at altlinux.org
Fri Jun 27 00:44:08 UTC 2014


Hi Zubin,

On Fri, Jun 20, 2014 at 11:04:15AM +0530, zubin.mithra at gmail.com wrote:
> --- a/util.c
> +++ b/util.c
> @@ -563,6 +563,42 @@ string_quote(const char *instr, char *outstr, long len, int size)
>  	return 0;
>  }
>  
> +
> +/*
> + * Print the current working directory of the tracee process
> + */
> +static bool
> +print_tracee_cwd(struct tcb *tcp)
> +{
> +	char *linkpath = NULL;
> +	char cwd[MAXPATHLEN + 2];
> +	int retval;
> +	ssize_t n;
> +
> +	retval = asprintf(&linkpath, "/proc/%u/cwd", tcp->pid);
> +	if (retval == -1)
> +		return false;

Do you really like this approach?
In cases like this (when a buffer of 21 bytes is surely enough)
I'd rather use stack.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20140627/01409f72/attachment.bin>


More information about the Strace-devel mailing list