[merge] with upstream
This commit is contained in:
commit
4c73fc0f53
@ -1,6 +1,7 @@
|
|||||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
*
|
*
|
||||||
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
|
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
|
||||||
|
* Copyright 2018, Adriaan de Groot <groot@kde.org>
|
||||||
*
|
*
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -29,6 +30,18 @@ struct FstabEntry
|
|||||||
QString options;
|
QString options;
|
||||||
int dump;
|
int dump;
|
||||||
int pass;
|
int pass;
|
||||||
|
|
||||||
|
/// Does this entry make sense and is it complete?
|
||||||
|
bool isValid() const; // implemented in Partutils.cpp
|
||||||
|
|
||||||
|
/** @brief Create an entry from a live of /etc/fstab
|
||||||
|
*
|
||||||
|
* Splits the given string (which ought to follow the format
|
||||||
|
* of /etc/fstab) and returns a corresponding Fstab entry.
|
||||||
|
* If the string isn't valid (e.g. comment-line, or broken
|
||||||
|
* fstab entry) then the entry that is returned is invalid.
|
||||||
|
*/
|
||||||
|
static FstabEntry fromEtcFstab( const QString& ); // implemented in Partutils.cpp
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QList< FstabEntry > FstabEntryList;
|
typedef QList< FstabEntry > FstabEntryList;
|
||||||
|
@ -164,7 +164,7 @@ lookForFstabEntries( const QString& partitionPath )
|
|||||||
{
|
{
|
||||||
FstabEntryList fstabEntries;
|
FstabEntryList fstabEntries;
|
||||||
QTemporaryDir mountsDir;
|
QTemporaryDir mountsDir;
|
||||||
mountsDir.setAutoRemove(false); // Avoid data cleanup - https://github.com/calamares/calamares/issues/1044
|
mountsDir.setAutoRemove( false );
|
||||||
|
|
||||||
int exit = QProcess::execute( "mount", { partitionPath, mountsDir.path() } );
|
int exit = QProcess::execute( "mount", { partitionPath, mountsDir.path() } );
|
||||||
if ( !exit ) // if all is well
|
if ( !exit ) // if all is well
|
||||||
@ -176,28 +176,17 @@ lookForFstabEntries( const QString& partitionPath )
|
|||||||
.split( '\n' );
|
.split( '\n' );
|
||||||
|
|
||||||
for ( const QString& rawLine : fstabLines )
|
for ( const QString& rawLine : fstabLines )
|
||||||
{
|
fstabEntries.append( FstabEntry::fromEtcFstab( rawLine ) );
|
||||||
QString line = rawLine.simplified();
|
|
||||||
if ( line.startsWith( '#' ) )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
QStringList splitLine = line.split( ' ' );
|
|
||||||
if ( splitLine.length() != 6 )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
fstabEntries.append( { splitLine.at( 0 ), // path, or UUID, or LABEL, etc.
|
|
||||||
splitLine.at( 1 ), // mount point
|
|
||||||
splitLine.at( 2 ), // fs type
|
|
||||||
splitLine.at( 3 ), // options
|
|
||||||
splitLine.at( 4 ).toInt(), //dump
|
|
||||||
splitLine.at( 5 ).toInt() //pass
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
fstabFile.close();
|
fstabFile.close();
|
||||||
|
std::remove_if( fstabEntries.begin(), fstabEntries.end(), [](const FstabEntry& x) { return !x.isValid(); } );
|
||||||
}
|
}
|
||||||
|
|
||||||
QProcess::execute( "umount", { "-R", mountsDir.path() } );
|
if ( QProcess::execute( "umount", { "-R", mountsDir.path() } ) )
|
||||||
|
{
|
||||||
|
cWarning() << "Could not unmount" << mountsDir.path();
|
||||||
|
// There is stuff left in there, really don't remove
|
||||||
|
mountsDir.setAutoRemove( false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return fstabEntries;
|
return fstabEntries;
|
||||||
@ -374,3 +363,31 @@ isEfiBootable( const Partition* candidate )
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // nmamespace PartUtils
|
} // nmamespace PartUtils
|
||||||
|
|
||||||
|
/* Implementation of methods for FstabEntry, from OsproberEntry.h */
|
||||||
|
|
||||||
|
bool
|
||||||
|
FstabEntry::isValid() const
|
||||||
|
{
|
||||||
|
return !partitionNode.isEmpty() && !mountPoint.isEmpty() && !fsType.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
FstabEntry
|
||||||
|
FstabEntry::fromEtcFstab( const QString& rawLine )
|
||||||
|
{
|
||||||
|
QString line = rawLine.simplified();
|
||||||
|
if ( line.startsWith( '#' ) )
|
||||||
|
return FstabEntry{ QString(), QString(), QString(), QString(), 0, 0 };
|
||||||
|
|
||||||
|
QStringList splitLine = line.split( ' ' );
|
||||||
|
if ( splitLine.length() != 6 )
|
||||||
|
return FstabEntry{ QString(), QString(), QString(), QString(), 0, 0 };
|
||||||
|
|
||||||
|
return FstabEntry{ splitLine.at( 0 ), // path, or UUID, or LABEL, etc.
|
||||||
|
splitLine.at( 1 ), // mount point
|
||||||
|
splitLine.at( 2 ), // fs type
|
||||||
|
splitLine.at( 3 ), // options
|
||||||
|
splitLine.at( 4 ).toInt(), //dump
|
||||||
|
splitLine.at( 5 ).toInt() //pass
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user