From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from elasmtp-galgo.atl.sa.earthlink.net ([209.86.89.61]:40778 "EHLO elasmtp-galgo.atl.sa.earthlink.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752580AbcGRU1w convert rfc822-to-8bit (ORCPT ); Mon, 18 Jul 2016 16:27:52 -0400 From: "Frank Filz" To: "'Peter Chen'" , References: In-Reply-To: Subject: RE: Getting the file path of a file descriptor Date: Mon, 18 Jul 2016 13:27:36 -0700 Message-ID: <008c01d1e132$d2ba63a0$782f2ae0$@mindspring.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Content-Language: en-us Sender: linux-fsdevel-owner@vger.kernel.org List-ID: > I was wondering if I intercepted the system call such as read(). Can I get the > file path of the file descriptor somehow from the kernel process's internal > data structures or some helper functions? For example if I had previously > opened a file "abcd.txt", and then called read on it, I would like to get the > filepath "abcd.txt" from the fd for the read(). There may be zero to N paths to an open file descriptor... > Also aside, I was wondering if it was all possible to get the file path of the > executable of the process itself. So if I was running a program such as "ping", > when I intercept the system calls of the program, I want to know the filepath > of the ping program. Argv[0], and that is the specific name the executable was invoked by (some utilities actually use this to behave differently based on execution name...). Frank --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus