add new flag to control if path should be umounted
this is only useful if the mount point specified by path is already
mounted outside of swupdate.
Signed-off-by: Ayoub Zaki <
ayoub...@embetrix.com>
---
doc/source/sw-description.rst | 6 ++++++
handlers/archive_handler.c | 8 ++++++++
include/swupdate.h | 1 +
parser/parser.c | 1 +
4 files changed, 16 insertions(+)
diff --git a/doc/source/sw-description.rst b/doc/source/sw-description.rst
index a5182d6..13bba2e 100644
--- a/doc/source/sw-description.rst
+++ b/doc/source/sw-description.rst
@@ -1319,6 +1319,12 @@ There are 4 main sections inside sw-description:
| | | | "filesystem" type. (path is always |
| | | | relative to the mount point.) |
+-------------+----------+------------+---------------------------------------+
+ | umount | bool | files | flag to control whether the given |
+ | | | | mount point specified by path |
+ | | | | (absolute) where the files are |
+ | | | | are installed if already mounted |
+ | | | | outside SWUpdate should be umounted |
+ +-------------+----------+------------+---------------------------------------+
| preserve-\ | bool | files | flag to control whether the following |
| attributes | | | attributes will be preserved when |
| | | | files are unpacked from an archive |
diff --git a/handlers/archive_handler.c b/handlers/archive_handler.c
index e3a1463..553287f 100644
--- a/handlers/archive_handler.c
+++ b/handlers/archive_handler.c
@@ -228,6 +228,7 @@ static int install_archive_image(struct img_type *img,
struct extract_data tf;
pthread_attr_t attr;
int use_mount = (strlen(img->device) && strlen(img->filesystem)) ? 1 : 0;
+ int use_umount = img->umount;
int is_mounted = 0;
int exitval = -EFAULT;
char *DATADST_DIR = NULL;
@@ -380,6 +381,13 @@ out:
}
}
+ if (use_umount && !use_mount) {
+ ret = swupdate_umount(img->path);
+ if (ret) {
+ TRACE("Failed to unmount directory %s", img->path);
+ }
+ }
+
free(DATADST_DIR);
free(FIFO);
diff --git a/include/swupdate.h b/include/swupdate.h
index 4cce892..89f64ea 100644
--- a/include/swupdate.h
+++ b/include/swupdate.h
@@ -81,6 +81,7 @@ struct img_type {
int provided;
int compressed;
int preserve_attributes; /* whether to preserve attributes in archives */
+ bool umount;
bool is_encrypted;
char ivt_ascii[33];
int install_directly;
diff --git a/parser/parser.c b/parser/parser.c
index 5607031..81f69be 100644
--- a/parser/parser.c
+++ b/parser/parser.c
@@ -436,6 +436,7 @@ static int parse_common_attributes(parsertype p, void *elem, struct img_type *im
}
get_field(p, elem, "installed-directly", &image->install_directly);
get_field(p, elem, "preserve-attributes", &image->preserve_attributes);
+ get_field(p, elem, "umount", &image->umount);
get_field(p, elem, "install-if-different", &image->id.install_if_different);
get_field(p, elem, "install-if-higher", &image->id.install_if_higher);
get_field(p, elem, "encrypted", &image->is_encrypted);
--
2.34.1