mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-11-16 12:34:43 +00:00
gdb: implement linux namespace support for fileio_lstat and vFile::lstat
The new algorithm to look for a build-id-based debug file
(introduced by commit 22836ca885)
makes use of fileio_lstat. As lstat was not supported by
linux-namespace.c, all lstat calls would be performed on the host
and not inside the namespace. Fixed by adding namespace lstat
support.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32956
Approved-By: Andrew Burgess <aburgess@redhat.com>
This commit is contained in:
committed by
Andrew Burgess
parent
c29a37f741
commit
bd389c9515
@@ -525,7 +525,7 @@ handle_stat (char *own_buf, int *new_packet_len)
|
||||
static void
|
||||
handle_lstat (char *own_buf, int *new_packet_len)
|
||||
{
|
||||
int bytes_sent;
|
||||
int ret, bytes_sent;
|
||||
char *p;
|
||||
struct stat st;
|
||||
struct fio_stat fst;
|
||||
@@ -540,7 +540,12 @@ handle_lstat (char *own_buf, int *new_packet_len)
|
||||
return;
|
||||
}
|
||||
|
||||
if (lstat (filename, &st) == -1)
|
||||
if (hostio_fs_pid != 0)
|
||||
ret = the_target->multifs_lstat (hostio_fs_pid, filename, &st);
|
||||
else
|
||||
ret = lstat (filename, &st);
|
||||
|
||||
if (ret == -1)
|
||||
{
|
||||
hostio_error (own_buf);
|
||||
return;
|
||||
|
||||
@@ -6049,6 +6049,12 @@ linux_process_target::multifs_open (int pid, const char *filename,
|
||||
return linux_mntns_open_cloexec (pid, filename, flags, mode);
|
||||
}
|
||||
|
||||
int
|
||||
linux_process_target::multifs_lstat (int pid, const char *filename, struct stat *sb)
|
||||
{
|
||||
return linux_mntns_lstat (pid, filename, sb);
|
||||
}
|
||||
|
||||
int
|
||||
linux_process_target::multifs_unlink (int pid, const char *filename)
|
||||
{
|
||||
|
||||
@@ -304,6 +304,8 @@ public:
|
||||
int multifs_open (int pid, const char *filename, int flags,
|
||||
mode_t mode) override;
|
||||
|
||||
int multifs_lstat (int pid, const char *filename, struct stat *st) override;
|
||||
|
||||
int multifs_unlink (int pid, const char *filename) override;
|
||||
|
||||
ssize_t multifs_readlink (int pid, const char *filename, char *buf,
|
||||
|
||||
@@ -772,6 +772,13 @@ process_stratum_target::multifs_open (int pid, const char *filename,
|
||||
return open (filename, flags, mode);
|
||||
}
|
||||
|
||||
int
|
||||
process_stratum_target::multifs_lstat (int pid, const char *filename,
|
||||
struct stat *sb)
|
||||
{
|
||||
return lstat (filename, sb);
|
||||
}
|
||||
|
||||
int
|
||||
process_stratum_target::multifs_unlink (int pid, const char *filename)
|
||||
{
|
||||
|
||||
@@ -441,6 +441,12 @@ public:
|
||||
virtual int multifs_open (int pid, const char *filename,
|
||||
int flags, mode_t mode);
|
||||
|
||||
/* Multiple-filesystem-aware lstat. Like lstat(2), but operating in
|
||||
the filesystem as it appears to process PID. Systems where all
|
||||
processes share a common filesystem should not override this.
|
||||
The default behavior is to use lstat(2). */
|
||||
virtual int multifs_lstat (int pid, const char *filename, struct stat *sb);
|
||||
|
||||
/* Multiple-filesystem-aware unlink. Like unlink(2), but operates
|
||||
in the filesystem as it appears to process PID. Systems where
|
||||
all processes share a common filesystem should not override this.
|
||||
|
||||
Reference in New Issue
Block a user