diff mbox series

[OpenWrt-Devel] fstools: add ntfs support

Message ID 20180928230102.251-1-ansuelsmth@gmail.com
State Accepted
Delegated to: John Crispin
Headers show
Series [OpenWrt-Devel] fstools: add ntfs support | expand

Commit Message

Christian Marangi Sept. 28, 2018, 11:01 p.m. UTC
This adds ntfs support to block-mount

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---
 block.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Rosen Penev Sept. 28, 2018, 11:28 p.m. UTC | #1
On Fri, Sep 28, 2018 at 16:01 Ansuel Smith <ansuelsmth@gmail.com> wrote:

> This adds ntfs support to block-mount

What’s the point of this? This is also read only if I’m not mistaken.

>
>
> Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
> ---
>  block.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/block.c b/block.c
> index b377429..2e3841a 100644
> --- a/block.c
> +++ b/block.c
> @@ -711,6 +711,7 @@ static void check_filesystem(struct probe_info *pr)
>         const char *f2fsck = "/usr/sbin/fsck.f2fs";
>         const char *dosfsck = "/usr/sbin/dosfsck";
>         const char *btrfsck = "/usr/bin/btrfsck";
> +       const char *ntfsck = "/usr/bin/ntfsfix";
>         const char *ckfs;
>
>         /* UBIFS does not need stuff like fsck */
> @@ -725,6 +726,8 @@ static void check_filesystem(struct probe_info *pr)
>                 ckfs = e2fsck;
>         } else if (!strncmp(pr->type, "btrfs", 5)) {
>                 ckfs = btrfsck;
> +       } else if (!strncmp(pr->type, "ntfs", 4)) {
> +               ckfs = ntfsck;
>         } else {
>                 ULOG_ERR("check_filesystem: %s is not supported\n",
> pr->type);
>                 return;
> @@ -743,6 +746,9 @@ static void check_filesystem(struct probe_info *pr)
>                 } else if(!strncmp(pr->type, "btrfs", 5)) {
>                         execl(ckfs, ckfs, "--repair", pr->dev, NULL);
>                         exit(-1);
> +               } else if(!strncmp(pr->type, "ntfs", 4)) {
> +                       execl(ckfs, ckfs, "-b", pr->dev, NULL);
> +                       exit(-1);
>                 } else {
>                         execl(ckfs, ckfs, "-p", pr->dev, NULL);
>                         exit(-1);
> @@ -1437,8 +1443,9 @@ static int mount_extroot(char *cfg)
>                 if (strncmp(pr->type, "ext", 3) &&
>                     strncmp(pr->type, "f2fs", 4) &&
>                     strncmp(pr->type, "btrfs", 5) &&
> +                   strncmp(pr->type, "ntfs", 4) &&
>                     strncmp(pr->type, "ubifs", 5)) {
> -                       ULOG_ERR("extroot: unsupported filesystem %s, try
> ext4, f2fs, btrfs or ubifs\n", pr->type);
> +                       ULOG_ERR("extroot: unsupported filesystem %s, try
> ext4, f2fs, btrfs, ntfs or ubifs\n", pr->type);
>                         return -1;
>                 }
>
> --
> 2.17.1
>
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
>
<div><br></div><div><br><div class="gmail_quote"><div dir="ltr">On Fri, Sep 28, 2018 at 16:01 Ansuel Smith &lt;<a href="mailto:ansuelsmth@gmail.com">ansuelsmth@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This adds ntfs support to block-mount</blockquote><div dir="auto">What’s the point of this? This is also read only if I’m not mistaken.</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
Signed-off-by: Ansuel Smith &lt;<a href="mailto:ansuelsmth@gmail.com" target="_blank">ansuelsmth@gmail.com</a>&gt;<br>
---<br>
 block.c | 9 ++++++++-<br>
 1 file changed, 8 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/block.c b/block.c<br>
index b377429..2e3841a 100644<br>
--- a/block.c<br>
+++ b/block.c<br>
@@ -711,6 +711,7 @@ static void check_filesystem(struct probe_info *pr)<br>
        const char *f2fsck = &quot;/usr/sbin/fsck.f2fs&quot;;<br>
        const char *dosfsck = &quot;/usr/sbin/dosfsck&quot;;<br>
        const char *btrfsck = &quot;/usr/bin/btrfsck&quot;;<br>
+       const char *ntfsck = &quot;/usr/bin/ntfsfix&quot;;<br>
        const char *ckfs;<br>
<br>
        /* UBIFS does not need stuff like fsck */<br>
@@ -725,6 +726,8 @@ static void check_filesystem(struct probe_info *pr)<br>
                ckfs = e2fsck;<br>
        } else if (!strncmp(pr-&gt;type, &quot;btrfs&quot;, 5)) {<br>
                ckfs = btrfsck;<br>
+       } else if (!strncmp(pr-&gt;type, &quot;ntfs&quot;, 4)) {<br>
+               ckfs = ntfsck;<br>
        } else {<br>
                ULOG_ERR(&quot;check_filesystem: %s is not supported\n&quot;, pr-&gt;type);<br>
                return;<br>
@@ -743,6 +746,9 @@ static void check_filesystem(struct probe_info *pr)<br>
                } else if(!strncmp(pr-&gt;type, &quot;btrfs&quot;, 5)) {<br>
                        execl(ckfs, ckfs, &quot;--repair&quot;, pr-&gt;dev, NULL);<br>
                        exit(-1);<br>
+               } else if(!strncmp(pr-&gt;type, &quot;ntfs&quot;, 4)) {<br>
+                       execl(ckfs, ckfs, &quot;-b&quot;, pr-&gt;dev, NULL);<br>
+                       exit(-1);<br>
                } else {<br>
                        execl(ckfs, ckfs, &quot;-p&quot;, pr-&gt;dev, NULL);<br>
                        exit(-1);<br>
@@ -1437,8 +1443,9 @@ static int mount_extroot(char *cfg)<br>
                if (strncmp(pr-&gt;type, &quot;ext&quot;, 3) &amp;&amp;<br>
                    strncmp(pr-&gt;type, &quot;f2fs&quot;, 4) &amp;&amp;<br>
                    strncmp(pr-&gt;type, &quot;btrfs&quot;, 5) &amp;&amp;<br>
+                   strncmp(pr-&gt;type, &quot;ntfs&quot;, 4) &amp;&amp;<br>
                    strncmp(pr-&gt;type, &quot;ubifs&quot;, 5)) {<br>
-                       ULOG_ERR(&quot;extroot: unsupported filesystem %s, try ext4, f2fs, btrfs or ubifs\n&quot;, pr-&gt;type);<br>
+                       ULOG_ERR(&quot;extroot: unsupported filesystem %s, try ext4, f2fs, btrfs, ntfs or ubifs\n&quot;, pr-&gt;type);<br>
                        return -1;<br>
                }<br>
<br>
-- <br>
2.17.1<br>
<br>
<br>
_______________________________________________<br>
openwrt-devel mailing list<br>
<a href="mailto:openwrt-devel@lists.openwrt.org" target="_blank">openwrt-devel@lists.openwrt.org</a><br>
<a href="https://lists.openwrt.org/mailman/listinfo/openwrt-devel" rel="noreferrer" target="_blank">https://lists.openwrt.org/mailman/listinfo/openwrt-devel</a><br>
</blockquote></div></div>
Rosen Penev Sept. 28, 2018, 11:36 p.m. UTC | #2
> On Sep 28, 2018, at 16:31, Ansuel Smith <ansuelsmth@gmail.com> wrote:
> 
> If you also install ntfs-3g it's not read only 
Hmm? That requires specifying NTFS-3G manually, no?
> 
> Il Sab 29 Set 2018, 01:28 Rosen Penev <rosenp@gmail.com> ha scritto:
>> 
>> 
>>> On Fri, Sep 28, 2018 at 16:01 Ansuel Smith <ansuelsmth@gmail.com> wrote:
>>> This adds ntfs support to block-mount
>> What’s the point of this? This is also read only if I’m not mistaken.
>>> 
>>> 
>>> Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
>>> ---
>>>  block.c | 9 ++++++++-
>>>  1 file changed, 8 insertions(+), 1 deletion(-)
>>> 
>>> diff --git a/block.c b/block.c
>>> index b377429..2e3841a 100644
>>> --- a/block.c
>>> +++ b/block.c
>>> @@ -711,6 +711,7 @@ static void check_filesystem(struct probe_info *pr)
>>>         const char *f2fsck = "/usr/sbin/fsck.f2fs";
>>>         const char *dosfsck = "/usr/sbin/dosfsck";
>>>         const char *btrfsck = "/usr/bin/btrfsck";
>>> +       const char *ntfsck = "/usr/bin/ntfsfix";
>>>         const char *ckfs;
>>> 
>>>         /* UBIFS does not need stuff like fsck */
>>> @@ -725,6 +726,8 @@ static void check_filesystem(struct probe_info *pr)
>>>                 ckfs = e2fsck;
>>>         } else if (!strncmp(pr->type, "btrfs", 5)) {
>>>                 ckfs = btrfsck;
>>> +       } else if (!strncmp(pr->type, "ntfs", 4)) {
>>> +               ckfs = ntfsck;
>>>         } else {
>>>                 ULOG_ERR("check_filesystem: %s is not supported\n", pr->type);
>>>                 return;
>>> @@ -743,6 +746,9 @@ static void check_filesystem(struct probe_info *pr)
>>>                 } else if(!strncmp(pr->type, "btrfs", 5)) {
>>>                         execl(ckfs, ckfs, "--repair", pr->dev, NULL);
>>>                         exit(-1);
>>> +               } else if(!strncmp(pr->type, "ntfs", 4)) {
>>> +                       execl(ckfs, ckfs, "-b", pr->dev, NULL);
>>> +                       exit(-1);
>>>                 } else {
>>>                         execl(ckfs, ckfs, "-p", pr->dev, NULL);
>>>                         exit(-1);
>>> @@ -1437,8 +1443,9 @@ static int mount_extroot(char *cfg)
>>>                 if (strncmp(pr->type, "ext", 3) &&
>>>                     strncmp(pr->type, "f2fs", 4) &&
>>>                     strncmp(pr->type, "btrfs", 5) &&
>>> +                   strncmp(pr->type, "ntfs", 4) &&
>>>                     strncmp(pr->type, "ubifs", 5)) {
>>> -                       ULOG_ERR("extroot: unsupported filesystem %s, try ext4, f2fs, btrfs or ubifs\n", pr->type);
>>> +                       ULOG_ERR("extroot: unsupported filesystem %s, try ext4, f2fs, btrfs, ntfs or ubifs\n", pr->type);
>>>                         return -1;
>>>                 }
>>> 
>>> -- 
>>> 2.17.1
>>> 
>>> 
>>> _______________________________________________
>>> openwrt-devel mailing list
>>> openwrt-devel@lists.openwrt.org
>>> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div dir="ltr"></div><div dir="ltr"><br></div><div dir="ltr"><br>On Sep 28, 2018, at 16:31, Ansuel Smith &lt;<a href="mailto:ansuelsmth@gmail.com">ansuelsmth@gmail.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div dir="ltr"><div dir="auto">If you also install ntfs-3g it's not read only&nbsp;</div></div></blockquote>Hmm? That requires specifying NTFS-3G manually, no?<br><blockquote type="cite"><div dir="ltr"><br><div class="gmail_quote"><div dir="ltr">Il Sab 29 Set 2018, 01:28 Rosen Penev &lt;<a href="mailto:rosenp@gmail.com">rosenp@gmail.com</a>&gt; ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><br></div><div><br><div class="gmail_quote"><div dir="ltr">On Fri, Sep 28, 2018 at 16:01 Ansuel Smith &lt;<a href="mailto:ansuelsmth@gmail.com" target="_blank" rel="noreferrer">ansuelsmth@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This adds ntfs support to block-mount</blockquote><div dir="auto">What’s the point of this? This is also read only if I’m not mistaken.</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
Signed-off-by: Ansuel Smith &lt;<a href="mailto:ansuelsmth@gmail.com" target="_blank" rel="noreferrer">ansuelsmth@gmail.com</a>&gt;<br>
---<br>
&nbsp;block.c | 9 ++++++++-<br>
&nbsp;1 file changed, 8 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/block.c b/block.c<br>
index b377429..2e3841a 100644<br>
--- a/block.c<br>
+++ b/block.c<br>
@@ -711,6 +711,7 @@ static void check_filesystem(struct probe_info *pr)<br>
&nbsp; &nbsp; &nbsp; &nbsp; const char *f2fsck = "/usr/sbin/fsck.f2fs";<br>
&nbsp; &nbsp; &nbsp; &nbsp; const char *dosfsck = "/usr/sbin/dosfsck";<br>
&nbsp; &nbsp; &nbsp; &nbsp; const char *btrfsck = "/usr/bin/btrfsck";<br>
+&nbsp; &nbsp; &nbsp; &nbsp;const char *ntfsck = "/usr/bin/ntfsfix";<br>
&nbsp; &nbsp; &nbsp; &nbsp; const char *ckfs;<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; /* UBIFS does not need stuff like fsck */<br>
@@ -725,6 +726,8 @@ static void check_filesystem(struct probe_info *pr)<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ckfs = e2fsck;<br>
&nbsp; &nbsp; &nbsp; &nbsp; } else if (!strncmp(pr-&gt;type, "btrfs", 5)) {<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ckfs = btrfsck;<br>
+&nbsp; &nbsp; &nbsp; &nbsp;} else if (!strncmp(pr-&gt;type, "ntfs", 4)) {<br>
+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ckfs = ntfsck;<br>
&nbsp; &nbsp; &nbsp; &nbsp; } else {<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ULOG_ERR("check_filesystem: %s is not supported\n", pr-&gt;type);<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<br>
@@ -743,6 +746,9 @@ static void check_filesystem(struct probe_info *pr)<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else if(!strncmp(pr-&gt;type, "btrfs", 5)) {<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; execl(ckfs, ckfs, "--repair", pr-&gt;dev, NULL);<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(-1);<br>
+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} else if(!strncmp(pr-&gt;type, "ntfs", 4)) {<br>
+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;execl(ckfs, ckfs, "-b", pr-&gt;dev, NULL);<br>
+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit(-1);<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else {<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; execl(ckfs, ckfs, "-p", pr-&gt;dev, NULL);<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(-1);<br>
@@ -1437,8 +1443,9 @@ static int mount_extroot(char *cfg)<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (strncmp(pr-&gt;type, "ext", 3) &amp;&amp;<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strncmp(pr-&gt;type, "f2fs", 4) &amp;&amp;<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strncmp(pr-&gt;type, "btrfs", 5) &amp;&amp;<br>
+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;strncmp(pr-&gt;type, "ntfs", 4) &amp;&amp;<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strncmp(pr-&gt;type, "ubifs", 5)) {<br>
-&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ULOG_ERR("extroot: unsupported filesystem %s, try ext4, f2fs, btrfs or ubifs\n", pr-&gt;type);<br>
+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ULOG_ERR("extroot: unsupported filesystem %s, try ext4, f2fs, btrfs, ntfs or ubifs\n", pr-&gt;type);<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return -1;<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>
<br>
-- <br>
2.17.1<br>
<br>
<br>
_______________________________________________<br>
openwrt-devel mailing list<br>
<a href="mailto:openwrt-devel@lists.openwrt.org" target="_blank" rel="noreferrer">openwrt-devel@lists.openwrt.org</a><br>
<a href="https://lists.openwrt.org/mailman/listinfo/openwrt-devel" rel="noreferrer noreferrer" target="_blank">https://lists.openwrt.org/mailman/listinfo/openwrt-devel</a><br>
</blockquote></div></div>
</blockquote></div>
</div></blockquote></body></html>
diff mbox series

Patch

diff --git a/block.c b/block.c
index b377429..2e3841a 100644
--- a/block.c
+++ b/block.c
@@ -711,6 +711,7 @@  static void check_filesystem(struct probe_info *pr)
 	const char *f2fsck = "/usr/sbin/fsck.f2fs";
 	const char *dosfsck = "/usr/sbin/dosfsck";
 	const char *btrfsck = "/usr/bin/btrfsck";
+	const char *ntfsck = "/usr/bin/ntfsfix";
 	const char *ckfs;
 
 	/* UBIFS does not need stuff like fsck */
@@ -725,6 +726,8 @@  static void check_filesystem(struct probe_info *pr)
 		ckfs = e2fsck;
 	} else if (!strncmp(pr->type, "btrfs", 5)) {
 		ckfs = btrfsck;
+	} else if (!strncmp(pr->type, "ntfs", 4)) {
+		ckfs = ntfsck;
 	} else {
 		ULOG_ERR("check_filesystem: %s is not supported\n", pr->type);
 		return;
@@ -743,6 +746,9 @@  static void check_filesystem(struct probe_info *pr)
 		} else if(!strncmp(pr->type, "btrfs", 5)) {
 			execl(ckfs, ckfs, "--repair", pr->dev, NULL);
 			exit(-1);
+		} else if(!strncmp(pr->type, "ntfs", 4)) {
+			execl(ckfs, ckfs, "-b", pr->dev, NULL);
+			exit(-1);
 		} else {
 			execl(ckfs, ckfs, "-p", pr->dev, NULL);
 			exit(-1);
@@ -1437,8 +1443,9 @@  static int mount_extroot(char *cfg)
 		if (strncmp(pr->type, "ext", 3) &&
 		    strncmp(pr->type, "f2fs", 4) &&
 		    strncmp(pr->type, "btrfs", 5) &&
+		    strncmp(pr->type, "ntfs", 4) &&
 		    strncmp(pr->type, "ubifs", 5)) {
-			ULOG_ERR("extroot: unsupported filesystem %s, try ext4, f2fs, btrfs or ubifs\n", pr->type);
+			ULOG_ERR("extroot: unsupported filesystem %s, try ext4, f2fs, btrfs, ntfs or ubifs\n", pr->type);
 			return -1;
 		}