77637b9478
Fix saving to an NFS target. OBS-URL: https://build.opensuse.org/request/show/505675 OBS-URL: https://build.opensuse.org/package/show/Kernel:kdump/kdump?expand=0&rev=134
81 lines
2.7 KiB
Diff
81 lines
2.7 KiB
Diff
From: Petr Tesarik <ptesarik@suse.com>
|
|
Date: Thu Jun 22 14:23:02 2017 +0200
|
|
Subject: Fix save_dump to NFS targets
|
|
References: bsc#1045541
|
|
Upstream: v0.8.17
|
|
Git-commit: 11d36a645ab99c9805f9fa3ca9eabce3aa2a9418
|
|
|
|
For NFS, the parent directory of the target must be mounted, because
|
|
the target directory itself does not exist yet.
|
|
|
|
For this to work, split the target path to directory (i.e. parent
|
|
directory) and basename. Then construct a unique mount point from the
|
|
host name and the parent directory, and finally append the base name
|
|
again to form a subdirectory in the target (to be created by the file
|
|
transfer method).
|
|
|
|
Signed-off-by: Petr Tesarik <ptesarik@suse.com>
|
|
|
|
---
|
|
kdumptool/transfer.cc | 24 +++++++++++-------------
|
|
kdumptool/transfer.h | 4 +---
|
|
2 files changed, 12 insertions(+), 16 deletions(-)
|
|
|
|
--- a/kdumptool/transfer.cc
|
|
+++ b/kdumptool/transfer.cc
|
|
@@ -462,22 +462,20 @@ RootDirURL NFSTransfer::translate(const
|
|
if (!rt.check(config->KDUMP_NET_TIMEOUT.value()))
|
|
cerr << "WARNING: Dump target not reachable" << endl;
|
|
|
|
- string mountedDir = parser.getPath();
|
|
- FileUtil::nfsmount(parser.getHostname(), mountedDir,
|
|
- DEFAULT_MOUNTPOINT, options);
|
|
-
|
|
+ FilePath path = parser.getPath();
|
|
+ string mountedDir = path.dirName();
|
|
+ string rest = path.baseName();
|
|
|
|
m_mountpoint = DEFAULT_MOUNTPOINT;
|
|
- m_rest = parser.getPath();
|
|
- m_rest.replace(m_rest.begin(), m_rest.begin() + mountedDir.size(), "");
|
|
- m_rest.ltrim("/");
|
|
+ m_mountpoint.appendPath(parser.getHostname()).appendPath(mountedDir);
|
|
+ m_mountpoint.mkdir(true);
|
|
+ Debug::debug()->dbg("Path: %s, Mountpoint: %s, Rest: %s",
|
|
+ path.c_str(), m_mountpoint.c_str(), rest.c_str());
|
|
|
|
- (m_prefix = m_mountpoint).appendPath(m_rest);
|
|
-
|
|
- Debug::debug()->dbg("Mountpoint: %s, Rest: %s, Prefix: $s",
|
|
- m_mountpoint.c_str(), m_rest.c_str(), m_prefix.c_str());
|
|
+ FileUtil::nfsmount(parser.getHostname(), mountedDir,
|
|
+ m_mountpoint, options);
|
|
|
|
- return RootDirURL("file://" + m_prefix, "");
|
|
+ return RootDirURL("file://" + m_mountpoint + PATH_SEPARATOR + rest, "");
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
@@ -507,7 +505,7 @@ void NFSTransfer::close()
|
|
throw (KError)
|
|
{
|
|
Debug::debug()->trace("NFSTransfer::close()");
|
|
- if (m_mountpoint.size() > 0) {
|
|
+ if (!m_mountpoint.empty()) {
|
|
FileUtil::umount(m_mountpoint);
|
|
m_mountpoint.clear();
|
|
}
|
|
--- a/kdumptool/transfer.h
|
|
+++ b/kdumptool/transfer.h
|
|
@@ -271,9 +271,7 @@ class NFSTransfer : public URLTransfer {
|
|
|
|
|
|
private:
|
|
- std::string m_mountpoint;
|
|
- KString m_rest;
|
|
- FilePath m_prefix;
|
|
+ FilePath m_mountpoint;
|
|
FileTransfer *m_fileTransfer;
|
|
};
|
|
|