diff mbox series

[OpenWrt-Devel,1/2] fstools: allow to customize the mount option for the overlay

Message ID 1526652463-27784-1-git-send-email-pme.lebleu@gmail.com
State Changes Requested
Delegated to: John Crispin
Headers show
Series [OpenWrt-Devel,1/2] fstools: allow to customize the mount option for the overlay | expand

Commit Message

Pierre Lebleu May 18, 2018, 2:07 p.m. UTC
In order to give some extra options (specific to the filesystem used),
a new CMake option (eg: CMAKE_OVL_MOUNT_OPTION) has been added.

Example: cmake -DCMAKE_OVL_MOUNT_OPTION="compr=zlib"

Signed-off-by: Pierre Lebleu <pme.lebleu@gmail.com>
---
 CMakeLists.txt       | 6 ++++++
 libfstools/overlay.c | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

Comments

John Crispin May 22, 2018, 5 a.m. UTC | #1
On 18/05/18 16:07, Pierre Lebleu wrote:
> In order to give some extra options (specific to the filesystem used),
> a new CMake option (eg: CMAKE_OVL_MOUNT_OPTION) has been added.
>
> Example: cmake -DCMAKE_OVL_MOUNT_OPTION="compr=zlib"
>
> Signed-off-by: Pierre Lebleu <pme.lebleu@gmail.com>
> ---
>   CMakeLists.txt       | 6 ++++++
>   libfstools/overlay.c | 2 +-
>   2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index 9e855bd..484d716 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -52,6 +52,12 @@ INSTALL(FILES libubi/libubi-tiny.h libubi/libubi.h libubi/ubi-media.h
>   	DESTINATION include
>   )
>   
> +IF(DEFINED CMAKE_OVL_MOUNT_OPTION)
> +	ADD_DEFINITIONS(-DOVL_MOUNT_OPTION=${CMAKE_OVL_MOUNT_OPTION})
> +ELSE(DEFINED CMAKE_OVL_MOUNT_OPTION)
> +	ADD_DEFINITIONS(-DOVL_MOUNT_OPTION=NULL)
> +ENDIF(DEFINED CMAKE_OVL_MOUNT_OPTION)
> +

Hi Pierre,
might be better to has an option compress=y/n
     John
>   ADD_EXECUTABLE(mount_root mount_root.c)
>   TARGET_LINK_LIBRARIES(mount_root fstools)
>   INSTALL(TARGETS mount_root RUNTIME DESTINATION sbin)
> diff --git a/libfstools/overlay.c b/libfstools/overlay.c
> index ebc43f7..5d5a985 100644
> --- a/libfstools/overlay.c
> +++ b/libfstools/overlay.c
> @@ -341,7 +341,7 @@ static int overlay_mount_fs(struct volume *v)
>   		return -1;
>   	}
>   
> -	if (mount(v->blk, "/tmp/overlay", fstype, MS_NOATIME, NULL)) {
> +	if (mount(v->blk, "/tmp/overlay", fstype, MS_NOATIME, OVL_MOUNT_OPTION)) {
>   		ULOG_ERR("failed to mount -t %s %s /tmp/overlay: %m\n",
>   		         fstype, v->blk);
>   		return -1;
John Crispin May 22, 2018, 7:05 p.m. UTC | #2
On 22/05/18 19:04, Pierre Lebleu wrote:
> In order to allow the mounting of the filesystem with the zlib compression,
> a new CMake option (eg: CMAKE_OVL_MOUNT_COMPRESS_ZLIB) has been added.
>
> Signed-off-by: Pierre Lebleu <pme.lebleu@gmail.com>
> ---
> v2: change the option name
>   CMakeLists.txt       | 6 ++++++
>   libfstools/overlay.c | 2 +-
>   2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index 9e855bd..6b98ba6 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -52,6 +52,12 @@ INSTALL(FILES libubi/libubi-tiny.h libubi/libubi.h libubi/ubi-media.h
>   	DESTINATION include
>   )
>   
> +IF(DEFINED CMAKE_OVL_MOUNT_COMPRESS_ZLIB)
> +	ADD_DEFINITIONS(-DOVL_MOUNT_OPTION="compr=zlib")
> +ELSE(DEFINED CMAKE_OVL_MOUNT_COMPRESS_ZLIB)
> +	ADD_DEFINITIONS(-DOVL_MOUNT_OPTION=NULL)
> +ENDIF(DEFINED CMAKE_OVL_MOUNT_COMPRESS_ZLIB)

modifying code like this is sub optimal. I'd prefer if we did a 
-DOVL_COMPR_ZLIB only

> +
>   ADD_EXECUTABLE(mount_root mount_root.c)
>   TARGET_LINK_LIBRARIES(mount_root fstools)
>   INSTALL(TARGETS mount_root RUNTIME DESTINATION sbin)
> diff --git a/libfstools/overlay.c b/libfstools/overlay.c
> index ebc43f7..5d5a985 100644
> --- a/libfstools/overlay.c
> +++ b/libfstools/overlay.c
> @@ -341,7 +341,7 @@ static int overlay_mount_fs(struct volume *v)
>   		return -1;
>   	}
>   
> -	if (mount(v->blk, "/tmp/overlay", fstype, MS_NOATIME, NULL)) {
> +	if (mount(v->blk, "/tmp/overlay", fstype, MS_NOATIME, OVL_MOUNT_OPTION)) {

if (mount(v->blk, "/tmp/overlay", fstype, MS_NOATIME,
#ifdef OVL_COMPR_ZLIB
	  "compr=zlib"
#else
	  NULL
#endif
	  ))

	John

>   		ULOG_ERR("failed to mount -t %s %s /tmp/overlay: %m\n",
>   		         fstype, v->blk);
>   		return -1;
diff mbox series

Patch

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9e855bd..484d716 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,6 +52,12 @@  INSTALL(FILES libubi/libubi-tiny.h libubi/libubi.h libubi/ubi-media.h
 	DESTINATION include
 )
 
+IF(DEFINED CMAKE_OVL_MOUNT_OPTION)
+	ADD_DEFINITIONS(-DOVL_MOUNT_OPTION=${CMAKE_OVL_MOUNT_OPTION})
+ELSE(DEFINED CMAKE_OVL_MOUNT_OPTION)
+	ADD_DEFINITIONS(-DOVL_MOUNT_OPTION=NULL)
+ENDIF(DEFINED CMAKE_OVL_MOUNT_OPTION)
+
 ADD_EXECUTABLE(mount_root mount_root.c)
 TARGET_LINK_LIBRARIES(mount_root fstools)
 INSTALL(TARGETS mount_root RUNTIME DESTINATION sbin)
diff --git a/libfstools/overlay.c b/libfstools/overlay.c
index ebc43f7..5d5a985 100644
--- a/libfstools/overlay.c
+++ b/libfstools/overlay.c
@@ -341,7 +341,7 @@  static int overlay_mount_fs(struct volume *v)
 		return -1;
 	}
 
-	if (mount(v->blk, "/tmp/overlay", fstype, MS_NOATIME, NULL)) {
+	if (mount(v->blk, "/tmp/overlay", fstype, MS_NOATIME, OVL_MOUNT_OPTION)) {
 		ULOG_ERR("failed to mount -t %s %s /tmp/overlay: %m\n",
 		         fstype, v->blk);
 		return -1;