2016-10-05 21:31:48 +02:00
|
|
|
// -*- Mode: Go; indent-tabs-mode: t -*-
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2014-2016 Canonical Ltd
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License version 3 as
|
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*
|
|
|
|
|
*/
|
2017-01-17 16:47:23 +01:00
|
|
|
|
2016-10-05 21:31:48 +02:00
|
|
|
package osutil
|
|
|
|
|
|
2018-02-14 16:21:48 +01:00
|
|
|
// IsMounted checks if a given directory is a mount point.
|
2016-10-05 21:31:48 +02:00
|
|
|
func IsMounted(baseDir string) (bool, error) {
|
2020-04-07 07:16:19 -05:00
|
|
|
entries, err := LoadMountInfo()
|
2016-10-05 21:31:48 +02:00
|
|
|
if err != nil {
|
|
|
|
|
return false, err
|
|
|
|
|
}
|
2018-02-14 16:21:48 +01:00
|
|
|
for _, entry := range entries {
|
|
|
|
|
if baseDir == entry.MountDir {
|
2016-10-05 21:31:48 +02:00
|
|
|
return true, nil
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-02-14 16:21:48 +01:00
|
|
|
return false, nil
|
2016-10-05 21:31:48 +02:00
|
|
|
}
|